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/tw.js CHANGED
@@ -3493,6 +3493,7 @@ __export(native_bridge_exports, {
3493
3493
  computeCacheStatsNative: () => computeCacheStatsNative,
3494
3494
  extractClassesNative: () => extractClassesNative,
3495
3495
  generateSubComponentTypesNative: () => generateSubComponentTypesNative,
3496
+ getLoadedScannerBindingPath: () => getLoadedScannerBindingPath,
3496
3497
  hasNativeScannerBinding: () => hasNativeScannerBinding,
3497
3498
  hasNativeWatchBinding: () => hasNativeWatchBinding,
3498
3499
  hashContentNative: () => hashContentNative,
@@ -3520,6 +3521,13 @@ function getDirname2() {
3520
3521
  }
3521
3522
  return process.cwd();
3522
3523
  }
3524
+ function getLoadedScannerBindingPath() {
3525
+ try {
3526
+ scannerGetBinding();
3527
+ } catch {
3528
+ }
3529
+ return scannerBridgeLoader.getLoadedPath();
3530
+ }
3523
3531
  function scanWorkspaceNative(root, extensions) {
3524
3532
  return scannerGetBinding().scanWorkspace(root, extensions ?? null);
3525
3533
  }
@@ -3739,7 +3747,8 @@ var init_native_bridge = __esm({
3739
3747
  const _state = {
3740
3748
  binding: void 0,
3741
3749
  loadError: null,
3742
- candidatePaths: []
3750
+ candidatePaths: [],
3751
+ loadedPath: null
3743
3752
  };
3744
3753
  const throwNativeBindingError = () => {
3745
3754
  const lines = [
@@ -3777,7 +3786,7 @@ var init_native_bridge = __esm({
3777
3786
  includeDefaultCandidates: true
3778
3787
  });
3779
3788
  _state.candidatePaths = candidates;
3780
- const { binding, loadErrors } = loadNativeBinding({
3789
+ const { binding, loadedPath, loadErrors } = loadNativeBinding({
3781
3790
  runtimeDir,
3782
3791
  candidates,
3783
3792
  isValid: isValidScannerBinding,
@@ -3786,6 +3795,7 @@ var init_native_bridge = __esm({
3786
3795
  if (binding) {
3787
3796
  log(`scanner native binding loaded successfully`);
3788
3797
  _state.binding = binding;
3798
+ _state.loadedPath = loadedPath ?? null;
3789
3799
  return _state.binding;
3790
3800
  }
3791
3801
  if (loadErrors.length > 0) {
@@ -3797,10 +3807,12 @@ var init_native_bridge = __esm({
3797
3807
  return {
3798
3808
  get: scannerGetBinding2,
3799
3809
  scannerGetBinding: scannerGetBinding2,
3810
+ getLoadedPath: () => _state.loadedPath,
3800
3811
  reset: () => {
3801
3812
  _state.binding = void 0;
3802
3813
  _state.loadError = null;
3803
3814
  _state.candidatePaths = [];
3815
+ _state.loadedPath = null;
3804
3816
  }
3805
3817
  };
3806
3818
  };
@@ -3815,9 +3827,42 @@ function defaultCachePath(rootDir, cacheDir) {
3815
3827
  const dir = cacheDir ? import_node_path3.default.resolve(rootDir, cacheDir) : import_node_path3.default.join(process.cwd(), ".cache", "tailwind-styled");
3816
3828
  return import_node_path3.default.join(dir, "scanner-cache.json");
3817
3829
  }
3830
+ function metaPathFor(cachePath) {
3831
+ return cachePath.replace(/\.json$/, ".meta.json");
3832
+ }
3833
+ function getBinaryFingerprint() {
3834
+ if (_cachedFingerprint !== void 0) return _cachedFingerprint;
3835
+ try {
3836
+ const loadedPath = getLoadedScannerBindingPath();
3837
+ if (!loadedPath) {
3838
+ _cachedFingerprint = null;
3839
+ return null;
3840
+ }
3841
+ const stat = import_node_fs2.default.statSync(loadedPath);
3842
+ _cachedFingerprint = `${stat.mtimeMs}:${stat.size}`;
3843
+ } catch {
3844
+ _cachedFingerprint = null;
3845
+ }
3846
+ return _cachedFingerprint;
3847
+ }
3818
3848
  function readCache(rootDir, cacheDir) {
3819
3849
  const cachePath = defaultCachePath(rootDir, cacheDir);
3820
3850
  import_node_fs2.default.mkdirSync(import_node_path3.default.dirname(cachePath), { recursive: true });
3851
+ const currentFingerprint = getBinaryFingerprint();
3852
+ if (currentFingerprint !== null) {
3853
+ const metaPath = metaPathFor(cachePath);
3854
+ let storedFingerprint = null;
3855
+ try {
3856
+ storedFingerprint = JSON.parse(import_node_fs2.default.readFileSync(metaPath, "utf8")).binaryFingerprint ?? null;
3857
+ } catch {
3858
+ }
3859
+ if (storedFingerprint !== currentFingerprint) {
3860
+ console.warn(
3861
+ "[scanner] cache invalidated: native binary berubah sejak cache terakhir ditulis"
3862
+ );
3863
+ return [];
3864
+ }
3865
+ }
3821
3866
  const result = cacheReadNative(cachePath);
3822
3867
  if (!result) return [];
3823
3868
  return result.entries.map((e) => ({
@@ -3839,6 +3884,17 @@ function writeCache(rootDir, entries, cacheDir) {
3839
3884
  "Native cacheWrite failed. Run 'npm run build:rust' to rebuild native bindings."
3840
3885
  );
3841
3886
  }
3887
+ const currentFingerprint = getBinaryFingerprint();
3888
+ if (currentFingerprint !== null) {
3889
+ try {
3890
+ import_node_fs2.default.writeFileSync(
3891
+ metaPathFor(cachePath),
3892
+ JSON.stringify({ binaryFingerprint: currentFingerprint }),
3893
+ "utf8"
3894
+ );
3895
+ } catch {
3896
+ }
3897
+ }
3842
3898
  }
3843
3899
  function filePriority(mtimeMs, size, cached, nowMs = Date.now()) {
3844
3900
  return cachePriorityNative(
@@ -3851,7 +3907,7 @@ function filePriority(mtimeMs, size, cached, nowMs = Date.now()) {
3851
3907
  nowMs
3852
3908
  );
3853
3909
  }
3854
- var import_node_fs2, import_node_path3, STALE_THRESHOLD_MS;
3910
+ var import_node_fs2, import_node_path3, _cachedFingerprint, STALE_THRESHOLD_MS;
3855
3911
  var init_cache_native = __esm({
3856
3912
  "packages/domain/scanner/src/cache-native.ts"() {
3857
3913
  "use strict";