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