This commit is contained in:
2026-06-24 20:21:29 +08:00
parent c38fb6ac4c
commit b7712d3d9d
2 changed files with 10 additions and 12 deletions
+7 -8
View File
@@ -10,13 +10,12 @@ class HotReloadState
public function store(array $changedFiles): void public function store(array $changedFiles): void
{ {
$normalizedFiles = array_map([$this, 'normalizePath'], array_filter($changedFiles));
$normalizedFiles = array_values(array_unique($normalizedFiles));
$payload = [ $payload = [
'timestamp' => time(), 'timestamp' => time(),
'changed_files' => $changedFiles 'changed_files' => $normalizedFiles,
|> array_filter(...)
|> (fn($x) => array_map([$this, 'normalizePath'], $x))
|> array_unique(...)
|> array_values(...),
]; ];
$directory = dirname($this->getFilePath()); $directory = dirname($this->getFilePath());
@@ -50,9 +49,9 @@ class HotReloadState
} }
$files = is_array($data['changed_files'] ?? null) ? $data['changed_files'] : []; $files = is_array($data['changed_files'] ?? null) ? $data['changed_files'] : [];
return array_map([$this, 'normalizePath'], $files) $files = array_map([$this, 'normalizePath'], $files);
|> array_unique(...) $files = array_values(array_unique($files));
|> array_values(...); return $files;
} }
private function getFilePath(): string private function getFilePath(): string
+3 -4
View File
@@ -85,10 +85,9 @@ class ScanManifest
return array_keys($this->entries); return array_keys($this->entries);
} }
return $this->entries $keys = array_keys($this->entries);
|> array_keys(...) $filtered = array_filter($keys, fn(string $path) => str_starts_with($path, $prefix));
|> (fn($x) => array_filter($x, fn(string $path) => str_starts_with($path, $prefix))) return array_values($filtered);
|> array_values(...);
} }