testing.FakeSession.rulers ​Contract 2.0.0 · package sha256
a857eca95b35921109faf997094bb4192f12527d9d0fcd4be7e97f06425bad6e· generated fromtesting.d.tsbyservices/onsite-scripter/scripts/build-contract-docs.mjs; edit the source, not this file.
Method of testing.FakeSession · labs, @experimental · since 2.0.0 · optional: reach it through has()
rulers?(): ReadonlyArray<{
readonly axis: 'width' | 'height' | 'depth';
readonly metres: number;
readonly label: string;
readonly part: Part | null;
}>;
The rulers overlays.dimensions shows now, as the shopper reads them, so a planner's test
asserts its labels, its per-module split and that they follow its writes: one entry per
ruler, in set order (one set for per: 'all', else one per matched part or model, in
document order) and each set's axes order. A dimensions call shows at the next drawn
frame, and the rulers are measured again at each drawn frame from current bounds, so after
a write, an undo or a redo they follow at the next frame() or tick(16). Empty before
that frame, after dimensions(null), while nothing it matched is visible, and after
destroy(); it never throws and records nothing.
Experimental, so optional in this declaration: a test calls fake.rulers?.().
Default: [] (no rulers shown)
Imports: values (has, validate, the Holo*Error classes, the pure helpers) from @holostep-configurators/runtime-client, types from @holostep-configurators/runtime-client/contract, /math and /testing names from those entries; boot from the runtime module the root's loadRuntimeAtFloor resolves to. A type your page defines is your app's: declare it there, never import it from the package.
Compiled under the contract's strict settings (examples/declaration/24-FakeSession.rulers.ts):
import { createFakeSession } from '@holostep-configurators/runtime-client/testing';
import type { Session } from '@holostep-configurators/runtime-client/contract';
declare const session: Session;
declare const signal: AbortSignal;
// A kitchen planner labels its run of base cabinets in millimetres.
const box = (width: number) => ({
nodes: [{
name: 'Carcass',
mesh: true,
bounds: { min: { x: 0, y: 0, z: -0.29 }, max: { x: width, y: 0.85, z: 0.29 } },
}],
});
const at = (nodeId: string, glbUrl: string, x: number) => ({
nodeId, type: 'ModelNode' as const, enabled: true, glbUrl,
position: { x, y: 0, z: 0 }, rotation: { x: 0, y: 0, z: 0 }, scale: { x: 1, y: 1, z: 1 },
});
const fake = createFakeSession({
models: { 'b60.glb': box(0.6), 'b30.glb': box(0.3) },
root: [at('sink', 'b60.glb', 0), at('drawers', 'b30.glb', 0.6)],
});
let loaded = false;
void fake.idle().then(() => (loaded = true));
for (let i = 0; i < 100 && !loaded; i++) {
fake.tick(16);
await new Promise((resolve) => setTimeout(resolve, 0));
}
fake.overlays.dimensions(
{ role: 'product' },
{ per: 'node', axes: ['width'], format: { unit: 'mm' } },
);
fake.frame(); // the rulers draw
export const labels = (fake.rulers?.() ?? []).map((r) => `${r.part?.node}: ${r.label}`);
if (labels.join(', ') !== 'sink: 600 mm, drawers: 300 mm') {
throw new Error('the per-module rulers did not read as planned');
}
| Rule | Result |
|---|---|
| 1. Neutral name | pass: rulers names no product |
| 2. A precedent | not recorded: no ledger row (coverage.json) names this member or its owner |
| 3. Two apps, or labs | labs (@experimental at a stable path, reached through has() or supports()): it graduates when a second app uses it |
| 4. The cheaper fix first | not recorded per member (Appendix B decides it per need) |