mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-10-08 03:10:26 +00:00
Some checks are pending
Rust / Format (push) Waiting to run
Rust / Clippy (push) Waiting to run
Rust / Generated Docs (push) Waiting to run
Rust / Test (Linux) (push) Waiting to run
Rust / Test (macOS) (push) Waiting to run
TypeScript / Typecheck (push) Waiting to run
TypeScript / Test (push) Waiting to run
TypeScript / Build (push) Waiting to run
Always route non-empty Files Changed views through Pierre's Virtualizer and worker pool, with full-height layout propagation and stable per-file cache keys. Copy Pierre worker assets during the web build so the static worker URL resolves in production.
26 lines
622 B
TypeScript
26 lines
622 B
TypeScript
export type FileCacheSide = "old" | "new";
|
|
|
|
export function stringHash(value: string): string {
|
|
let hash = 0x811c9dc5;
|
|
for (let index = 0; index < value.length; index += 1) {
|
|
hash ^= value.charCodeAt(index);
|
|
hash = Math.imul(hash, 0x01000193);
|
|
}
|
|
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
}
|
|
|
|
export function fileCacheKey({
|
|
runId,
|
|
toSha,
|
|
side,
|
|
path,
|
|
contents,
|
|
}: {
|
|
runId: string;
|
|
toSha: string | null | undefined;
|
|
side: FileCacheSide;
|
|
path: string;
|
|
contents: string;
|
|
}): string {
|
|
return `fabro-run-file:${runId}:${toSha ?? "no-sha"}:${side}:${path}:${stringHash(contents)}`;
|
|
}
|