Files
bchanot 343d6f4c1f feat(workspace): R2.4 core runtime — lazy load, poison on trap, offline re-instantiation, per-generation sheet handles
packages/core-wasm: browser-safe CoreRuntime (synchronous calls once ready;
a WebAssembly.RuntimeError poisons the instance, the call answers internal,
a fresh instance comes from the kept compiled module and a glue record
imported in advance; at most 3 recoveries per page; retry after a load
failure), SheetSession (handle rebuilt per instance generation, never
called on a dropped one; invalid_sheet without poisoning), Node source.
crates/wasm: SheetHandle (sheet held in the module memory). Two builds:
pkg/ shipped without trap exports (checked), pkg-proofs/ for the trap
tests; BUILD_STAMP (hash of the Rust sources) refused when missing or
stale by the vitest global setup instead of skipping. Failure envelope
carries a numeric found version; compact JS-number output.
2026-10-14 00:12:04 +02:00

28 lines
1.1 KiB
TypeScript

/**
* D-R13 budget: the served module (gzip) stays under 600 KB; the numbers are printed for
* RUST.md (raw and compressed size, compile + instantiate time on Node).
*/
import { readFileSync } from 'node:fs'
import { gzipSync } from 'node:zlib'
import { CoreRuntime } from '../src/index'
import { coreWasmPath, nodeCoreSource } from '../src/node'
/** D-R13: the served module (compressed) stays under this many bytes. */
const COMPRESSED_BUDGET_BYTES = 600_000
describe('module size and instantiate time (shipped wasm build)', () => {
it('stays under the compressed budget and reports its numbers', async () => {
const bytes = readFileSync(coreWasmPath('pkg'))
const gzip = gzipSync(bytes, { level: 9 }).length
const started = performance.now()
const runtime = new CoreRuntime(nodeCoreSource('pkg'))
expect(await runtime.ready()).toBe(true)
const readyMs = performance.now() - started
console.info(
`[core-wasm] faunosteo_wasm_bg.wasm: ${bytes.length} bytes raw, ${gzip} bytes gzip-9, compile + instantiate ${readyMs.toFixed(1)} ms`,
)
expect(gzip).toBeLessThanOrEqual(COMPRESSED_BUDGET_BYTES)
})
})