Save files once and keep every version
This is the storage side of Loopy: archive a site, recognize identical files, reconstruct older versions, and export ZIPs. Different sites can share the same underlying bytes without losing their separate histories.
Read and write ZIPs
import { Archive } from '@chaoticka/nsite-loopy-sdk';
const zip = Archive.writeZip({
'index.html': '<h1>Hello</h1>',
'manifest.json': '{"version":1}',
});
const files = await Archive.readZip(zip);
readZip validates central directory boundaries, CRC32, entry names, sizes, symlink markers and expansion bounds. Stored entries work directly; DEFLATE uses Node zlib or an injected browser decompressor.
Content-addressed storage
import { Archive, Storage } from '@chaoticka/nsite-loopy-sdk';
const store = Archive.contentStore(Storage.memoryStore());
const { hash } = await store.put('exact original bytes');
const recovered = await store.get(hash);
console.log(await store.verify(hash));
Compare and restore versions
Use Archive.diffVersions, Archive.materializeVersion, and Archive.groupVersions for path-by-path historical comparisons and reconstruction. Searchable catalog helpers support non-destructive filtering—hidden entries remain recoverable in raw source state.