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