32 lines
1.6 KiB
TypeScript
32 lines
1.6 KiB
TypeScript
// THE entry to data. Screens import from here and do not know what is behind it: today a mock
|
|
// network, tomorrow the platform over the same HTTP. The rule is machine-enforced, not on a
|
|
// reviewer's conscience — eslint.config.js forbids importing `src/mock/` and every network
|
|
// transport outside `src/api/`.
|
|
//
|
|
// With the engine the frontend never speaks at all: the platform stands between them, and reading
|
|
// the engine's store is a ratified anti-pattern (D39.85, FRONTEND_PLAN.md §0.2).
|
|
|
|
export type * from './contract';
|
|
export * from './queries';
|
|
export * from './scenarios';
|
|
export { ApiError } from './client';
|
|
export { subscribeToRun, supportedMajor, majorOf, readFrame } from './stream';
|
|
export type { ConnectionState, Frame } from './stream';
|
|
export { bookStatus, noteSeverity, pausedReason, termKind, termStatus } from './vocabulary';
|
|
export type { Tone } from './vocabulary';
|
|
|
|
/**
|
|
* Starts the mock network and resolves once it is intercepting. Awaited before the first render: a
|
|
* request that leaves before the worker is ready reaches the real network instead.
|
|
*
|
|
* The fixture world is chosen by the path, because the router does not exist yet at this point.
|
|
*
|
|
* ⚠ **Skipped when the dev server is proxying a real platform.** Otherwise the proxy configured for
|
|
* `TM_PLATFORM` (vite.config.ts) could never be reached: the worker would answer every request
|
|
* before it left the browser, and the setting would look broken rather than shadowed.
|
|
*/
|
|
export async function startMocking(pathname: string): Promise<void> {
|
|
if (import.meta.env.VITE_TM_PLATFORM) return;
|
|
const { startWorker } = await import('../mock/browser');
|
|
await startWorker(pathname);
|
|
}
|