e4dc0ce029
Wires pkg/calc/ship.go into the WASM Core boundary as seven thin
wrappers (DriveEffective, EmptyMass, WeaponsBlockMass, FullMass,
Speed, CargoCapacity, CarryingMass). The ship-class designer reads
Core through a new CORE_CONTEXT_KEY populated by the in-game layout
and renders a five-row preview pane (mass, full-load mass, max
speed, range at full load, cargo capacity) that updates reactively
on every form edit and on the player's localPlayer{Drive,Weapons,
Shields,Cargo} tech levels — three of which are now decoded from
the report's Player block alongside the existing localPlayerDrive.
CarryingMass is the seventh wrapper added to the original six-function
list so that "full-load mass" composes through pkg/calc/ functions
without putting math in TypeScript.
32 lines
910 B
TypeScript
32 lines
910 B
TypeScript
// Exposes the WASM `Core` instance through a Svelte context so views
|
|
// that need its math bridge (Phase 18 ship-class preview, future
|
|
// inspector calculators) can read it without re-booting the module.
|
|
// The layout populates `core` after `loadCore()` resolves; consumers
|
|
// observe `null` while the boot is in flight and the live `Core`
|
|
// once the runtime is ready.
|
|
|
|
import type { Core } from "../platform/core/index";
|
|
|
|
/**
|
|
* CORE_CONTEXT_KEY is the Svelte context key the in-game shell
|
|
* layout uses to expose its booted `Core` to descendants such as
|
|
* the ship-class designer preview pane.
|
|
*/
|
|
export const CORE_CONTEXT_KEY = Symbol("core");
|
|
|
|
export interface CoreHandle {
|
|
readonly core: Core | null;
|
|
}
|
|
|
|
export class CoreHolder implements CoreHandle {
|
|
#core: Core | null = $state(null);
|
|
|
|
get core(): Core | null {
|
|
return this.#core;
|
|
}
|
|
|
|
set(core: Core | null): void {
|
|
this.#core = core;
|
|
}
|
|
}
|