5623b11Recorder simulator: MATLAB jet-drive model and interactive web appJeremy Magland 1// The MFile shape and the content hash, kept free of Vite-specific APIs so
2// the render worker (and the Node harnesses) can import them without
3// touching import.meta.glob.
5export interface MFile {
6 name: string;
7 source: string;
8}
10// Cheap content hash (FNV-1a) so the worker can key its caches on the code.
11export function hashMFiles(files: MFile[]): string {
12 let h = 0x811c9dc5;
13 for (const f of files) {
14 const s = f.name + ' ' + f.source + '';
15 for (let i = 0; i < s.length; i++) {
16 h ^= s.charCodeAt(i);
17 h = Math.imul(h, 0x01000193);
18 }
19 }
20 return (h >>> 0).toString(36);
21}