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/tw.mjs CHANGED
@@ -3501,6 +3501,7 @@ __export(native_bridge_exports, {
3501
3501
  computeCacheStatsNative: () => computeCacheStatsNative,
3502
3502
  extractClassesNative: () => extractClassesNative,
3503
3503
  generateSubComponentTypesNative: () => generateSubComponentTypesNative,
3504
+ getLoadedScannerBindingPath: () => getLoadedScannerBindingPath,
3504
3505
  hasNativeScannerBinding: () => hasNativeScannerBinding,
3505
3506
  hasNativeWatchBinding: () => hasNativeWatchBinding,
3506
3507
  hashContentNative: () => hashContentNative,
@@ -3530,6 +3531,13 @@ function getDirname3() {
3530
3531
  }
3531
3532
  return process.cwd();
3532
3533
  }
3534
+ function getLoadedScannerBindingPath() {
3535
+ try {
3536
+ scannerGetBinding();
3537
+ } catch {
3538
+ }
3539
+ return scannerBridgeLoader.getLoadedPath();
3540
+ }
3533
3541
  function scanWorkspaceNative(root, extensions) {
3534
3542
  return scannerGetBinding().scanWorkspace(root, extensions ?? null);
3535
3543
  }
@@ -3746,7 +3754,8 @@ var init_native_bridge = __esm({
3746
3754
  const _state = {
3747
3755
  binding: void 0,
3748
3756
  loadError: null,
3749
- candidatePaths: []
3757
+ candidatePaths: [],
3758
+ loadedPath: null
3750
3759
  };
3751
3760
  const throwNativeBindingError = () => {
3752
3761
  const lines = [
@@ -3784,7 +3793,7 @@ var init_native_bridge = __esm({
3784
3793
  includeDefaultCandidates: true
3785
3794
  });
3786
3795
  _state.candidatePaths = candidates;
3787
- const { binding, loadErrors } = loadNativeBinding({
3796
+ const { binding, loadedPath, loadErrors } = loadNativeBinding({
3788
3797
  runtimeDir,
3789
3798
  candidates,
3790
3799
  isValid: isValidScannerBinding,
@@ -3793,6 +3802,7 @@ var init_native_bridge = __esm({
3793
3802
  if (binding) {
3794
3803
  log(`scanner native binding loaded successfully`);
3795
3804
  _state.binding = binding;
3805
+ _state.loadedPath = loadedPath ?? null;
3796
3806
  return _state.binding;
3797
3807
  }
3798
3808
  if (loadErrors.length > 0) {
@@ -3804,10 +3814,12 @@ var init_native_bridge = __esm({
3804
3814
  return {
3805
3815
  get: scannerGetBinding2,
3806
3816
  scannerGetBinding: scannerGetBinding2,
3817
+ getLoadedPath: () => _state.loadedPath,
3807
3818
  reset: () => {
3808
3819
  _state.binding = void 0;
3809
3820
  _state.loadError = null;
3810
3821
  _state.candidatePaths = [];
3822
+ _state.loadedPath = null;
3811
3823
  }
3812
3824
  };
3813
3825
  };
@@ -3824,9 +3836,42 @@ function defaultCachePath(rootDir, cacheDir) {
3824
3836
  const dir = cacheDir ? path5.resolve(rootDir, cacheDir) : path5.join(process.cwd(), ".cache", "tailwind-styled");
3825
3837
  return path5.join(dir, "scanner-cache.json");
3826
3838
  }
3839
+ function metaPathFor(cachePath) {
3840
+ return cachePath.replace(/\.json$/, ".meta.json");
3841
+ }
3842
+ function getBinaryFingerprint() {
3843
+ if (_cachedFingerprint !== void 0) return _cachedFingerprint;
3844
+ try {
3845
+ const loadedPath = getLoadedScannerBindingPath();
3846
+ if (!loadedPath) {
3847
+ _cachedFingerprint = null;
3848
+ return null;
3849
+ }
3850
+ const stat = fs3.statSync(loadedPath);
3851
+ _cachedFingerprint = `${stat.mtimeMs}:${stat.size}`;
3852
+ } catch {
3853
+ _cachedFingerprint = null;
3854
+ }
3855
+ return _cachedFingerprint;
3856
+ }
3827
3857
  function readCache(rootDir, cacheDir) {
3828
3858
  const cachePath = defaultCachePath(rootDir, cacheDir);
3829
3859
  fs3.mkdirSync(path5.dirname(cachePath), { recursive: true });
3860
+ const currentFingerprint = getBinaryFingerprint();
3861
+ if (currentFingerprint !== null) {
3862
+ const metaPath = metaPathFor(cachePath);
3863
+ let storedFingerprint = null;
3864
+ try {
3865
+ storedFingerprint = JSON.parse(fs3.readFileSync(metaPath, "utf8")).binaryFingerprint ?? null;
3866
+ } catch {
3867
+ }
3868
+ if (storedFingerprint !== currentFingerprint) {
3869
+ console.warn(
3870
+ "[scanner] cache invalidated: native binary berubah sejak cache terakhir ditulis"
3871
+ );
3872
+ return [];
3873
+ }
3874
+ }
3830
3875
  const result = cacheReadNative(cachePath);
3831
3876
  if (!result) return [];
3832
3877
  return result.entries.map((e) => ({
@@ -3848,6 +3893,17 @@ function writeCache(rootDir, entries, cacheDir) {
3848
3893
  "Native cacheWrite failed. Run 'npm run build:rust' to rebuild native bindings."
3849
3894
  );
3850
3895
  }
3896
+ const currentFingerprint = getBinaryFingerprint();
3897
+ if (currentFingerprint !== null) {
3898
+ try {
3899
+ fs3.writeFileSync(
3900
+ metaPathFor(cachePath),
3901
+ JSON.stringify({ binaryFingerprint: currentFingerprint }),
3902
+ "utf8"
3903
+ );
3904
+ } catch {
3905
+ }
3906
+ }
3851
3907
  }
3852
3908
  function filePriority(mtimeMs, size, cached, nowMs = Date.now()) {
3853
3909
  return cachePriorityNative(
@@ -3860,7 +3916,7 @@ function filePriority(mtimeMs, size, cached, nowMs = Date.now()) {
3860
3916
  nowMs
3861
3917
  );
3862
3918
  }
3863
- var STALE_THRESHOLD_MS;
3919
+ var _cachedFingerprint, STALE_THRESHOLD_MS;
3864
3920
  var init_cache_native = __esm({
3865
3921
  "packages/domain/scanner/src/cache-native.ts"() {
3866
3922
  "use strict";