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