has ​Contract 2.0.0 · package sha256
a857eca95b35921109faf997094bb4192f12527d9d0fcd4be7e97f06425bad6e· generated fromconfigurator-runtime.d.tsbyservices/onsite-scripter/scripts/build-contract-docs.mjs; edit the source, not this file.
Function · import { has } from '@holostep-configurators/runtime-client'; · stable · since 2.0.0 · section 22. Pure helpers (root of the package; run in Node and the fake)
How app code reaches an experimental member: a type guard over session.supports(id). The member
is optional in this declaration, so it compiles only after has() returned true for its id.
if (has(session, 'beforeCommit')) session.beforeCommit('layout', fn). Sync.
export declare function has<S extends Session, K extends keyof CapabilityMembers>(session: S, id: K): session is S & CapabilityMembers[K];
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/22-has.ts):
import { has } from '@holostep-configurators/runtime-client';
import type { Part, ScreenPoint, Session } from '@holostep-configurators/runtime-client/contract';
declare const session: Session;
declare const signal: AbortSignal;
declare const longPress: {
onFire(cb: (e: { pointerId: number; at: ScreenPoint }, part: Part) => void): void;
};
longPress.onFire((e, part) => {
if (has(session, 'input.startDrag')) {
session.input.startDrag(part, { pointerId: e.pointerId, at: e.at });
} else {
console.info('long-press drag is not in this runtime'); // a guard, never a crash
}
});
| Rule | Result |
|---|---|
| 1. Neutral name | pass: has names no product |
| 2. A precedent | pass: model-viewer canActivateAR and activateAR() (row G66); XRSession.end() (row G66); Navigator.share() (resolves when the share UI closes) (row G66) |
| 3. Two apps, or labs | pass: 2 apps (ledger: configurator-template, tryon-template) |
| 4. The cheaper fix first | decided per need in Appendix B: rows G66 at tier labs (a member only where no rule, data, asset or app code serves the need) |