Files
pplus-web/src/core/provenance.ts
T
2026-10-05 03:03:38 +00:00

15 lines
705 B
TypeScript

/**
* Where the Mojo on screen came from (restructure plan, section 2.4). One pure function answers for every view,
* so no screen has to work it out for itself: the Bridge's Mojo is always generated; anywhere else it is whatever
* `mojoOrigin` records (absent: written by hand, or an exercise's own program).
*/
import type { PlayState } from './state.js';
import type { AreaId } from './areas.js';
export type MojoProvenance = 'generated' | 'generated-edited' | null;
export function mojoProvenance(s: { area: AreaId | null; state: Pick<PlayState, 'mojoOrigin'> }, area: AreaId | null = s.area): MojoProvenance {
if (area === 'bridge') return 'generated';
return s.state.mojoOrigin ?? null;
}