feat(app): R4.3b/c import worker, client, controller; HomeRoute on the disposable worker
Protocol v1 (task → ready → result | failed with phase and kind), the worker entry with the glue bundled statically and the page's compiled Module posted, the file streamed into the module's memory; client with start and task timers (paused while hidden), settle-once, terminate always, error events never masked; module-level controller (one import at a time, cancel on leaving Home, worker chunk prefetched once the engine is loaded); the settlement mapped to the B.1.8 messages (OD-5: a trap, a timeout or an unreadable file is « Erreur de lecture du PDF. », never a corrupt PDF). HomeRoute keeps its routing and size pre-checks, loads its own index after acceptance, drops a result when the session changed. Tests: handler and client in-process, the corpus message test (O8 51, O7 stored inputs, O2/O3/Step 5), the six existing suites migrated to the real worker logic.
This commit is contained in:
1 parent
52471dbbc0
commit
6d1cce6e06
26 files changed
+2164
-247
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import type { SheetIndexData } from '@faunosteo/core-wasm/types'
|
||||
import { coreRuntime } from '@/core/runtime'
|
||||
import { prefetchImportWorker } from '@/core/worker/controller'
|
||||
import { SheetOps } from '@/core/sheetOps'
|
||||
import { SheetIndex } from '@/services/sheetIndex'
|
||||
import {
|
||||
@@ -50,10 +51,13 @@ async function loadIntoCore(speciesId: string): Promise<SheetLoad> {
|
||||
const data = session.call<SheetIndexData>('index_data', '')
|
||||
if (data.ok) {
|
||||
const index = new SheetIndex(data.value, new SheetOps(session))
|
||||
// The engine is loaded: warm the import worker's chunk for a later offline import.
|
||||
prefetchImportWorker()
|
||||
return { status: 'ready', index }
|
||||
}
|
||||
return {
|
||||
status: data.kind === 'invalid_sheet' ? 'invalid_sheet' : 'core_unavailable',
|
||||
status:
|
||||
data.kind === 'invalid_sheet' ? 'invalid_sheet' : 'core_unavailable',
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +77,17 @@ export function loadSheet(speciesId: string): Promise<SheetLoad> {
|
||||
return pending
|
||||
}
|
||||
|
||||
/**
|
||||
* The bundled payload as the text the core's `SheetHandle` reads, for the import worker
|
||||
* (R4.3): the same text the page's own session was built from. Null without a sheet.
|
||||
*/
|
||||
export async function loadSheetBundleText(
|
||||
speciesId: string,
|
||||
): Promise<string | null> {
|
||||
const bundle = await provider.getReferenceSheet(speciesId)
|
||||
return bundle ? JSON.stringify(bundle) : null
|
||||
}
|
||||
|
||||
/** The ready index, or null (tests and callers that need the sheet or nothing). */
|
||||
export async function loadSheetIndex(
|
||||
speciesId: string,
|
||||
@@ -99,7 +114,8 @@ export function useSheet(speciesId: string | undefined): SheetState {
|
||||
void loadSheet(speciesId).then((load) => {
|
||||
if (cancelled) return
|
||||
if (load.status === 'ready' || load.status === 'none') setState(load)
|
||||
else if (load.status === 'invalid_sheet') setState({ status: load.status, retry })
|
||||
else if (load.status === 'invalid_sheet')
|
||||
setState({ status: load.status, retry })
|
||||
else setState({ status: 'core_unavailable', retry })
|
||||
})
|
||||
return () => {
|
||||
|
||||
Reference in new issue
Block a user