docs(docs): R4.6 J2 recette (procedure, results grid, kit script), export harness phases and dist override, export series script, ledger targets of the app PDF suites, CLAUDE.md export flow; export driver publishes its User Timing split

This commit is contained in:
bchanot committed 2026-10-19 01:41:57 +02:00
1 parent 9cb3cb75d4
commit cdcdda8e1c
12 files changed
+679 -39

No files matched your search

+64 -10
View File
@@ -49,6 +49,47 @@ function assertNotAborted(signal: AbortSignal | undefined): void {
if (signal?.aborted) throw new DOMException('export aborted', 'AbortError')
}
/** Where the time went, for the DEV console and the browser harness (User Timing). */
interface ExportTiming {
startedAt: number
coreMs: number
rasterMs: number
requests: number
}
/** Runs a core call and charges its time. */
function timed<T>(timing: ExportTiming, call: () => T): T {
const started = performance.now()
try {
return call()
} finally {
timing.coreMs += performance.now() - started
}
}
/**
* One `performance.measure('faunosteo:export')` entry with the split in its detail:
* nothing the page shows, what the harness reads. Absent where User Timing lacks the
* options form.
*/
function publishTiming(timing: ExportTiming, parts: number, bytes: number): void {
try {
performance.measure('faunosteo:export', {
start: timing.startedAt,
end: performance.now(),
detail: {
coreMs: timing.coreMs,
rasterMs: timing.rasterMs,
requests: timing.requests,
parts,
bytes,
},
})
} catch {
// An older engine: no measure, nothing else changes.
}
}
/**
* One batch of the session's requests rasterised under `Promise.all`, as the engine did:
* a raster that fails is reported as it rejects (the warning order the engine recorded),
@@ -60,7 +101,10 @@ async function answerBatch(
session: CoreExportSession,
requests: RasterRequest[],
signal: AbortSignal | undefined,
timing: ExportTiming,
): Promise<void> {
timing.requests += requests.length
const rasterStarted = performance.now()
const settled = await Promise.all(
requests.map(async (request) => {
try {
@@ -71,15 +115,16 @@ async function answerBatch(
return { key: request.key, png }
} catch {
assertNotAborted(signal)
unwrap(session.rasterFailed(request.key))
unwrap(timed(timing, () => session.rasterFailed(request.key)))
return { key: request.key, png: null }
}
}),
)
timing.rasterMs += performance.now() - rasterStarted
for (const { key, png } of settled) {
if (!png) continue
assertNotAborted(signal)
unwrap(session.addRaster(key, png))
unwrap(timed(timing, () => session.addRaster(key, png)))
}
}
@@ -109,23 +154,32 @@ export async function exportReportToPdf(
exportedAt: new Date().toISOString(),
}
assertNotAborted(opts.signal)
const session = unwrap(openExportSession(coreRuntime(), JSON.stringify(input)))
const timing: ExportTiming = {
startedAt: performance.now(),
coreMs: 0,
rasterMs: 0,
requests: 0,
}
const text = JSON.stringify(input)
const session = unwrap(
timed(timing, () => openExportSession(coreRuntime(), text)),
)
try {
for (;;) {
assertNotAborted(opts.signal)
const step = unwrap(session.next())
const step = unwrap(timed(timing, () => session.next()))
if (step.step === 'done') break
await answerBatch(session, step.requests, opts.signal)
await answerBatch(session, step.requests, opts.signal, timing)
}
const parts = unwrap(session.finish())
const parts = unwrap(timed(timing, () => session.finish()))
const warnings = unwrap(session.warnings())
for (const warning of warnings) {
console.warn('PDF export warning', warning)
}
return {
pdf: new Blob(parts as BlobPart[], { type: 'application/pdf' }),
warnings,
}
const pdf = new Blob(parts as BlobPart[], { type: 'application/pdf' })
publishTiming(timing, parts.length, pdf.size)
if (import.meta.env.DEV) console.info('PDF export', timing)
return { pdf, warnings }
} finally {
session.free()
}