import type { RenderResult } from '../visualQa/harness'; import type { ResolvedItem } from '../visualQa/resolve'; import type { VisualQaAssert } from '../visualQa/types'; import { type DeclaredStance } from '../visualQa/vehicleStance'; import { type Json, type PreviewGlb } from '../visualQa/vehiclePreview'; import { type PreviewAddOn } from './previewAddon'; import { type VehicleIssue } from './validate'; import { type CabinFitReportLike, type CabinFitRow } from '../visualQa/vehicleCabinFit'; import { type ReferenceWheel } from './wheelDesign'; /** A published, Try-Now-able vehicle the preview rides on. Any published vehicle works; this one is long-lived. */ export declare const DEFAULT_PROXY_ITEM_ID = "280e49b0-39e9-40cd-9d41-4cc4d9ef7ab5"; export interface CandidateFiles { dir: string; packageFile: string; glbFile: string; thumbnailFile?: string; } /** Pick the one `.glb` of a directory: `model.glb`, else the only `*.glb`. Pure over the listing. */ export declare function pickGlb(files: string[]): { glb?: string; problem?: string; }; /** Resolve `` (+ `--glb`) to the files to render. Throws a one-line, actionable message. */ export declare function locateCandidate(target: string, glbOption?: string): CandidateFiles; /** Parse the package file. Accepts the bare package, `{ vehiclePackage }` (a publish body) and `{ package }` (the runtime's identity wrapper). */ export declare function parseCandidatePackage(text: string, file: string): Json; /** `glTF` magic + version 2 + a sane declared length. Throws when the bytes are not a binary glTF. */ export declare function describeGlb(bytes: Uint8Array, file: string): PreviewGlb; export type PreviewVerdict = 'pass' | 'fail' | 'error'; /** pass: no harness error, every blocking assert passed. fail: a blocking assert failed. error: the harness could not measure. */ export declare function previewVerdict(asserts: VisualQaAssert[], errors: string[], frames: number): { verdict: PreviewVerdict; exitCode: 0 | 1 | 2; reasons: string[]; }; export interface PreviewWheelRow { id: string; hub: number[] | null; drawn: number[] | null; deltaCm: number[] | null; drawnRadiusM: number | null; declaredRadiusM: number; /** Body origin height above this wheel's drawn tyre bottom / physics ground. */ originAboveDrawnGroundM: number | null; originAbovePhysicsGroundM: number; /** Lowest body point above this wheel's contact level (local ride height). */ bodyClearanceM: number | null; rollingRadiusM: number | null; } export interface PreviewBoarding { boarded: boolean; /** The candidate cabin seat the avatar sat in (a `seat_*` node of the candidate GLB), its role, and the candidate's own manifest key for it. */ seatId: string | null; role: string | null; seatKey: string | null; candidate: { keys: string[]; driverKey: string | null; cabinSeats: string[]; glbSeatNodes: string[]; platformDefault: boolean; } | null; /** The stand-in car's vocabulary (what the room understands). */ standIn: { keys: string[]; driverKey: string | null; cabinSeats: string[]; platformDefault: boolean; } | null; /** true: the two vocabularies already agreed and nothing was rewritten. */ vocabulariesIdentical: boolean | null; /** Candidate seats the stand-in room has no seat for. */ unmappedSeats: string[]; bridgeInstalled: boolean | null; /** Every seat send the client made: what it asked for in the candidate's vocabulary and what was sent to the room. */ sends: Array<{ intent: { kind: string; cabin: string; } | null; candidate: { moduleId?: string; action?: string; args?: unknown; }; sent: { moduleId?: string; action?: string; args?: unknown; } | null; translated: boolean; /** Set when the stand-in room has no such seat: the grant was synthesised in this page's room state (see previewSeats.ts). */ synthetic?: { key: string; enter: boolean; ok: boolean; }; why: string | null; }>; problems: string[]; } /** One `--addon` as the preview fitted it (the per-assert verdicts are in `asserts`, ids `preview.addon..*`). */ export interface PreviewAddOnSummary { index: number; dir: string; title: string; /** Synthetic id naming the fitted row; nothing was minted. */ itemId: string; slotType: string; /** wheel | socket | host | tune | unframed — how the placement was judged. */ kind: string; /** The slot the engine's board gave it, and how it is filled. */ slotId: string | null; fill: 'all' | 'each' | null; mountSocket: string[]; glb: { file: string; sha256: string; bytes: number; servedFromDisk: number; } | null; /** Drawn copies the runtime mounted, with where their geometry landed (body frame, metres). */ drawn: Array<{ name: string; socketNode: string | null; centre: number[] | null; min: number[] | null; max: number[] | null; triangles: number; }>; /** Tune ops read back out of the live tuning (tune-only add-ons, and the ops of any add-on). */ tuning: { ops: number; applied: number; changedLeaves: number; } | null; notes: string[]; /** Every `preview.addon..*` assert passed. */ pass: boolean; } /** One fixed appearance pose (`pose.front` … `pose.cockpit`, always all seven, in that order). */ export interface PreviewPose { id: string; label: string; file: string | null; why: string | null; } /** `--occupants`: where the runtime seated each occupant vs where the seat was authored (see visualQa/vehicleCabinFit.ts). */ export interface PreviewCabinFit { maxMoveM: number; rows: CabinFitRow[]; steering: CabinFitReportLike['steering'] | null; pedals: NonNullable; driverFit: { status: string; reason: string | null; } | null; warnings: string[]; } /** Every occupant assert with the threshold it is judged against (printed, so nobody has to read the harness). */ export interface PreviewOccupantCheck { id: string; status: 'PASS' | 'FAIL' | 'WARN' | 'NOT_MEASURED'; threshold: string; detail: string; } /** The thresholds behind each occupant assert, in words. Read from the same constants the judges use. */ export declare const OCCUPANT_THRESHOLD_TEXT: Record; export interface PreviewSummary { verdict: PreviewVerdict; exitCode: 0 | 1 | 2; reasons: string[]; /** `car`: the candidate car was rendered and measured. `addon`: `--addon` — fitted add-ons were measured on a car. */ mode: 'car' | 'addon'; /** The candidate car. In `addon` mode without a car directory (a published car via `--item`) the file fields are empty. */ candidate: { package: string; glb: string; glbSha256: string; glbBytes: number; thumbnail: string | null; displayName: string | null; packageChecksumSha256: string | null; }; addOns: PreviewAddOnSummary[]; /** * Boarding, with the CANDIDATE's own seat ids. The room hosting the Try Now car holds the stand-in's seats, so the client's seat * request (in the candidate's vocabulary) is translated at the room send; `seatId` is the candidate cabin seat the avatar was * actually seated in. Null in add-on mode (nothing is driven). */ boarding: PreviewBoarding | null; proxyItem: { id: string; title: string; }; runtime: { renderer: string | null; engineVersion: string | null; world: string; }; stance: { declared: DeclaredStance; /** Body origin height above the drawn tyre bottoms / the physics ground, and how far each is from the declared value. */ measuredDrawnM: number | null; measuredPhysicsM: number | null; deltaDrawnCm: number | null; deltaPhysicsCm: number | null; toleranceCm: number; pitchDeg: number | null; rollDeg: number | null; groundClearanceM: number | null; groundClearanceMesh: string | null; /** What to declare if the model's stance is the intended one. */ suggestedGroundToBodyOriginM: number | null; }; wheels: PreviewWheelRow[]; /** The fixed appearance poses (car mode; empty in add-on mode). */ poses: PreviewPose[]; /** `--occupants` only. */ cabinFit: PreviewCabinFit | null; occupants: PreviewOccupantCheck[] | null; asserts: Array<{ id: string; status: 'PASS' | 'FAIL' | 'WARN' | 'NOT_MEASURED'; severity: 'block' | 'warn'; detail: string; }>; proof: { sessionsRewritten: number; candidateGlbServedFromDisk: number; candidateAudioServedFromDisk: number; proxyModelFetched: string[]; packageIdentityMatch: boolean | null; renderedBytesFetched: boolean; }; files: { out: string; bundle: string; summary: string; contactSheet: string | null; posesSheet: string | null; frames: string[]; }; /** The gauntlet inspection sheets (car mode, unless both the inspection and the occupants were switched off). */ inspection?: { dir: string; index: string; verdict: 'pass' | 'fail'; sheets: Array<{ id: string; file: string; look: string; missing: number; }>; } | null; errors: string[]; timings: { totalMs: number; }; } export declare function assertStatus(a: VisualQaAssert): 'PASS' | 'FAIL' | 'WARN' | 'NOT_MEASURED'; /** Turn what the route measured into the numbers an author acts on. Pure: everything it reads is in `facts`. */ export declare function buildPreviewSummary(input: { files: CandidateFiles; glb: PreviewGlb; pkg: Json; proxy: { id: string; title: string; }; result: RenderResult; out: string; contactSheet: string | null; posesSheet?: string | null; totalMs: number; addOns?: PreviewAddOn[]; }): PreviewSummary; /** The human summary: the stance verdict first, because that is the number that locks at mint. */ export declare function renderAddOnPreviewText(s: PreviewSummary): string; export declare function renderPreviewText(s: PreviewSummary): string; export interface VehiclePreviewOptions { /** The candidate car (directory or package JSON). Optional when `addOns` is given: then the car is a published one (`item`). */ target?: string; /** `--addon`: unpublished add-on directories to fit to the car and measure. */ addOns?: string[]; /** `--item`: with `addOns` and no `target`, the published car to fit them to (default: the proxy item). */ item?: string; /** Overrides the per-kind placement tolerance (cm): wheels 1, socket-framed and host-framed parts 3. */ toleranceCm?: number; glb?: string; out?: string; proxyItem?: string; /** Seat an avatar in every seat and judge the cabin, the posture and the hands over time. ON unless `false` (a quick * iteration run; never a gate result: a car is only inspected with every seat occupied). */ occupants?: boolean; /** Render the gauntlet inspection set (8 angles day and night, each lamp lit) and write the contact sheets under * `/inspection/`. ON unless `false`. */ inspection?: boolean; /** Reference body paint colour (`#rrggbb`), sampled from the reference photo. When set, the body paint is rendered alone in the Try Now daylight and judged on hue, saturation, lightness and highlight wash. */ referencePaint?: string; /** Maximum circular hue distance (degrees) the rendered body may sit from a chromatic reference paint. Default 12. */ paintToleranceDeg?: number; /** Reference wheel close-up (see wheelDesign.ts `ReferenceWheel`). When set, the candidate's front-left wheel face is rendered square-on and judged on spoke count, finish and centre cap. */ referenceWheel?: ReferenceWheel; apiBase: string; webBase: string; token?: string | null; storageState?: string; chrome?: string; quiet?: boolean; } /** The minimal ResolvedItem the vehicle route needs for a candidate that has no published record. */ export declare function candidateResolved(o: { proxyId: string; proxyTitle: string; pkg: Json; glb: PreviewGlb; }): ResolvedItem; export declare class PreviewInputError extends Error { } /** * Before any browser: the engine's own validator, as the runtime runs it at spawn. A package it refuses is never * presented (the runtime throws while composing the car, the page reports nothing), so a preview would sit out two * 120 s presentation timeouts and end "the vehicle was never presented" with every wheel check "not measured". A * sealed package copied out of an Item's properties (audio rows with no url, say) is the usual cause: `helix vehicle * pull` writes a publishable copy, `--item ` inspects the published car itself. */ export declare function enginePackagePreflight(pkg: Json): Promise; /** * Before any browser: every host-frame add-on's bind (socket, root) must resolve against the car's own nodes. The runtime * throws while composing the car when it does not, the car is never presented, and the page reports no error — so a * preview would sit out its whole presentation timeout. Returns the findings (errors refuse the preview). */ export declare function hostBindPreflight(addOns: readonly PreviewAddOn[], hostGlb: Buffer, hostLabel: string): Promise; /** * Give every audio row backed by a local WAV (`{ name, file }`, the way an unpublished package is authored and the way * the BeamNG importer emits it) a content URL on PREVIEW_AUDIO_ORIGIN plus its checksum/bytes/cid, and return the * files to serve. Rows that already carry a url are left alone. Without this the engine's validator rejects the * package and the car never spawns. */ export declare function serveLocalAudio(pkg: Json, dir: string): { pkg: Json; audio: PreviewGlb[]; }; export declare function runVehiclePreview(opts: VehiclePreviewOptions): Promise;