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/vite.js CHANGED
@@ -4169,6 +4169,7 @@ __export(native_bridge_exports, {
4169
4169
  computeCacheStatsNative: () => computeCacheStatsNative,
4170
4170
  extractClassesNative: () => extractClassesNative,
4171
4171
  generateSubComponentTypesNative: () => generateSubComponentTypesNative,
4172
+ getLoadedScannerBindingPath: () => getLoadedScannerBindingPath,
4172
4173
  hasNativeScannerBinding: () => hasNativeScannerBinding,
4173
4174
  hasNativeWatchBinding: () => hasNativeWatchBinding,
4174
4175
  hashContentNative: () => hashContentNative,
@@ -4196,6 +4197,13 @@ function getDirname2() {
4196
4197
  }
4197
4198
  return process.cwd();
4198
4199
  }
4200
+ function getLoadedScannerBindingPath() {
4201
+ try {
4202
+ scannerGetBinding();
4203
+ } catch {
4204
+ }
4205
+ return scannerBridgeLoader.getLoadedPath();
4206
+ }
4199
4207
  function scanWorkspaceNative(root, extensions) {
4200
4208
  return scannerGetBinding().scanWorkspace(root, extensions ?? null);
4201
4209
  }
@@ -4415,7 +4423,8 @@ var init_native_bridge = __esm({
4415
4423
  const _state = {
4416
4424
  binding: void 0,
4417
4425
  loadError: null,
4418
- candidatePaths: []
4426
+ candidatePaths: [],
4427
+ loadedPath: null
4419
4428
  };
4420
4429
  const throwNativeBindingError = () => {
4421
4430
  const lines = [
@@ -4453,7 +4462,7 @@ var init_native_bridge = __esm({
4453
4462
  includeDefaultCandidates: true
4454
4463
  });
4455
4464
  _state.candidatePaths = candidates;
4456
- const { binding, loadErrors } = loadNativeBinding({
4465
+ const { binding, loadedPath, loadErrors } = loadNativeBinding({
4457
4466
  runtimeDir,
4458
4467
  candidates,
4459
4468
  isValid: isValidScannerBinding,
@@ -4462,6 +4471,7 @@ var init_native_bridge = __esm({
4462
4471
  if (binding) {
4463
4472
  log2(`scanner native binding loaded successfully`);
4464
4473
  _state.binding = binding;
4474
+ _state.loadedPath = loadedPath ?? null;
4465
4475
  return _state.binding;
4466
4476
  }
4467
4477
  if (loadErrors.length > 0) {
@@ -4473,10 +4483,12 @@ var init_native_bridge = __esm({
4473
4483
  return {
4474
4484
  get: scannerGetBinding2,
4475
4485
  scannerGetBinding: scannerGetBinding2,
4486
+ getLoadedPath: () => _state.loadedPath,
4476
4487
  reset: () => {
4477
4488
  _state.binding = void 0;
4478
4489
  _state.loadError = null;
4479
4490
  _state.candidatePaths = [];
4491
+ _state.loadedPath = null;
4480
4492
  }
4481
4493
  };
4482
4494
  };
@@ -4491,9 +4503,42 @@ function defaultCachePath(rootDir, cacheDir) {
4491
4503
  const dir = cacheDir ? import_node_path6.default.resolve(rootDir, cacheDir) : import_node_path6.default.join(process.cwd(), ".cache", "tailwind-styled");
4492
4504
  return import_node_path6.default.join(dir, "scanner-cache.json");
4493
4505
  }
4506
+ function metaPathFor(cachePath) {
4507
+ return cachePath.replace(/\.json$/, ".meta.json");
4508
+ }
4509
+ function getBinaryFingerprint() {
4510
+ if (_cachedFingerprint !== void 0) return _cachedFingerprint;
4511
+ try {
4512
+ const loadedPath = getLoadedScannerBindingPath();
4513
+ if (!loadedPath) {
4514
+ _cachedFingerprint = null;
4515
+ return null;
4516
+ }
4517
+ const stat = import_node_fs5.default.statSync(loadedPath);
4518
+ _cachedFingerprint = `${stat.mtimeMs}:${stat.size}`;
4519
+ } catch {
4520
+ _cachedFingerprint = null;
4521
+ }
4522
+ return _cachedFingerprint;
4523
+ }
4494
4524
  function readCache(rootDir, cacheDir) {
4495
4525
  const cachePath = defaultCachePath(rootDir, cacheDir);
4496
4526
  import_node_fs5.default.mkdirSync(import_node_path6.default.dirname(cachePath), { recursive: true });
4527
+ const currentFingerprint = getBinaryFingerprint();
4528
+ if (currentFingerprint !== null) {
4529
+ const metaPath = metaPathFor(cachePath);
4530
+ let storedFingerprint = null;
4531
+ try {
4532
+ storedFingerprint = JSON.parse(import_node_fs5.default.readFileSync(metaPath, "utf8")).binaryFingerprint ?? null;
4533
+ } catch {
4534
+ }
4535
+ if (storedFingerprint !== currentFingerprint) {
4536
+ console.warn(
4537
+ "[scanner] cache invalidated: native binary berubah sejak cache terakhir ditulis"
4538
+ );
4539
+ return [];
4540
+ }
4541
+ }
4497
4542
  const result = cacheReadNative(cachePath);
4498
4543
  if (!result) return [];
4499
4544
  return result.entries.map((e) => ({
@@ -4515,6 +4560,17 @@ function writeCache(rootDir, entries, cacheDir) {
4515
4560
  "Native cacheWrite failed. Run 'npm run build:rust' to rebuild native bindings."
4516
4561
  );
4517
4562
  }
4563
+ const currentFingerprint = getBinaryFingerprint();
4564
+ if (currentFingerprint !== null) {
4565
+ try {
4566
+ import_node_fs5.default.writeFileSync(
4567
+ metaPathFor(cachePath),
4568
+ JSON.stringify({ binaryFingerprint: currentFingerprint }),
4569
+ "utf8"
4570
+ );
4571
+ } catch {
4572
+ }
4573
+ }
4518
4574
  }
4519
4575
  function filePriority(mtimeMs, size, cached, nowMs = Date.now()) {
4520
4576
  return cachePriorityNative(
@@ -4527,7 +4583,7 @@ function filePriority(mtimeMs, size, cached, nowMs = Date.now()) {
4527
4583
  nowMs
4528
4584
  );
4529
4585
  }
4530
- var import_node_fs5, import_node_path6, STALE_THRESHOLD_MS;
4586
+ var import_node_fs5, import_node_path6, _cachedFingerprint, STALE_THRESHOLD_MS;
4531
4587
  var init_cache_native = __esm({
4532
4588
  "packages/domain/scanner/src/cache-native.ts"() {
4533
4589
  "use strict";