# `Session`

> Contract 2.0.0 · package sha256 `a857eca95b35921109faf997094bb4192f12527d9d0fcd4be7e97f06425bad6e` · generated from `configurator-runtime.d.ts` by `services/onsite-scripter/scripts/build-contract-docs.mjs`; edit the source, not this file.

Interface · `import type { Session } from '@holostep-configurators/runtime-client/contract';` · stable · since 2.0.0 · section 5. Writers, transactions, session

A configurator session. Every member except [`destroy()`](Session.destroy.md) throws DOMException 'InvalidStateError'
after [`destroy()`](Session.destroy.md); the terminal calls (every `dispose()`, every disposer a registration returns:
[`on`](Session.on.md), [`onFrame`](Session.onFrame.md), `follow`, [`beforeCommit`](Session.beforeCommit.md), [`input.drag`](Input.drag.md), [`labs.lightLinking`](Labs.lightLinking.md);
[`overlays.anchors.clear()`](Overlays.anchors.clear.md), [`overlays.hotspots.set([])`](Overlays.hotspots.set.md), [`overlays.hotspots.clear()`](Overlays.hotspots.clear.md)) do
nothing then, as [`destroy()`](Session.destroy.md) does (spec section 6.5).

## Members

| Member | Kind | Summary |
| --- | --- | --- |
| <a id="revision"></a>[`revision`](Session.revision.md) | property | Read class: intent. |
| <a id="seq"></a>[`seq`](Session.seq.md) | property | Read class: intent. |
| <a id="history"></a>[`history`](Session.history.md) | property | Undo state, undo groups and the history floor. |
| <a id="input"></a>[`input`](Session.input.md) | property | Picking, raycasts and drags on the canvas. |
| <a id="overlays"></a>[`overlays`](Session.overlays.md) | property | Screen overlays the runtime draws or tracks: hotspot badges, anchors and dimension rulers. |
| <a id="document"></a>[`document`](Session.document.md) | property | The merged viewer document, in version-2 form: platform defaults, then your page document, then account defaults, then the configurator's stored document, which wins. |
| <a id="transaction"></a>[`transaction`](Session.transaction.md) | method | One all-or-nothing change that may await (loads, attach). |
| <a id="beforecommit"></a>[`beforeCommit?`](Session.beforeCommit.md) | method · labs | Registers a hook that runs inside every recorded commit (writes, queued writes, undo, redo, restore, reload), after loads and before the commit point. |
| <a id="undo"></a>[`undo`](Session.undo.md) | method | Undoes the last committed step (recorded). |
| <a id="redo"></a>[`redo`](Session.redo.md) | method | Redoes the last undone step. |
| <a id="on"></a>[`on`](Session.on.md) | method | Subscribes. |
| <a id="onframe"></a>[`onFrame`](Session.onFrame.md) | method | A per-frame hook. |
| <a id="idle"></a>[`idle`](Session.idle.md) | method | Resolves when nothing is open, queued, loading or animating, and the latest commit is shown: the frame that draws it has been drawn, so [`info().scene`](InfoReport.scene.md), the canvas or a screenshot read right after it shows that state. |
| <a id="capture"></a>[`capture`](Session.capture.md) | method | Captures committed state as an image. |
| <a id="export"></a>[`export`](Session.export.md) | method | Exports the matched parts (role 'product' by default) as a GLB or USDZ file. |
| <a id="activatear"></a>[`activateAR`](Session.activateAR.md) | method | Launches AR for the product. |
| <a id="cantryon"></a>[`canTryOn?`](Session.canTryOn.md) | method · labs | Whether the product on screen can be tried on in this page now: Holostep's camera try-on (glasses, shoes, watches). |
| <a id="tryon"></a>[`tryOn?`](Session.tryOn.md) | method · labs | Opens try-on. |
| <a id="endar"></a>[`endAR?`](Session.endAR.md) | method · labs | Closes Holostep's in-page AR or try-on from page code; their pending [`activateAR()`](Session.activateAR.md) or [`tryOn()`](Session.tryOn.md) resolves. |
| <a id="describe"></a>[`describe`](Session.describe.md) | method | Read class: authored. |
| <a id="supports"></a>[`supports`](Session.supports.md) | method | Whether this runtime implements a capability. |
| <a id="permits"></a>[`permits`](Session.permits.md) | method | Whether this account may use a gated capability ('export', 'labs.geometry.read'). |
| <a id="applydocument"></a>[`applyDocument`](Session.applyDocument.md) | method | Replaces the page document layer (version 2). |
| <a id="info"></a>[`info`](Session.info.md) | method | A diagnostic snapshot, sync: the contract, runtime version, renderer backend and tier, device limits, the AR modes this device can open, document layers and recorded problems. |
| <a id="destroy"></a>[`destroy`](Session.destroy.md) | method | Terminal and immediate. |

Inherited from [`Writer`](Writer.md): [`node`](Writer.node.md), [`find`](Writer.find.md), [`collection`](Writer.collection.md), [`apply`](Writer.apply.md), [`applyPatch`](Writer.applyPatch.md), [`setSceneModel`](Writer.setSceneModel.md), [`select`](Writer.select.md), [`stage`](Writer.stage.md), [`materials`](Writer.materials.md), [`assembly`](Writer.assembly.md), [`camera`](Writer.camera.md), [`animations`](Writer.animations.md), [`labs`](Writer.labs.md), [`state`](Writer.state.md), [`getSceneModel`](Writer.getSceneModel.md).

## Declaration

```ts
export interface Session extends Writer<CommitOptions> {
  readonly revision: number;
  readonly seq: number;
  readonly history: History;
  readonly input: Input;
  readonly overlays: Overlays;
  readonly document: ViewerDocumentJson;
  transaction<T>(work: (tx: Tx) => T | Promise<T>, options?: TransactionOptions): Promise<TransactionReport<T>>;
  beforeCommit?(name: string, fn: (commit: BeforeCommitContext) => void | Promise<void>, options?: SignalOption): () => void;
  undo(options?: WriteOptions): Promise<Report>;
  redo(options?: WriteOptions): Promise<Report>;
  on<K extends keyof Events, R>(event: K, handler: (payload: Events[K]) => NotAsync<R>, options?: SignalOption): () => void;
  onFrame<R>(callback: (frame: Frame) => NotAsync<R>, options?: FrameOptions): () => void;
  idle(options?: SignalOption): Promise<void>;
  capture(spec?: CaptureSpec, options?: SignalOption): Promise<CaptureResult>;
  export(options: ExportOptions, extra?: SignalOption): Promise<ExportResult>;
  activateAR(options?: ActivateAROptions): Promise<ActivateARReport>;
  canTryOn?(): TryOnAvailability;
  tryOn?(options?: TryOnOptions): Promise<TryOnReport>;
  endAR?(): void;
  describe(node: string): ModelDescription | null;
  supports(capability: Capability): boolean;
  permits(capability: 'export' | 'labs.geometry.read' | (string & {})): boolean;
  applyDocument(document: ViewerDocumentJson, options?: SignalOption): Promise<ApplyReport>;
  info(): InfoReport;
  destroy(): void;
}
```

## Generic-API test (spec 3.1)

| Rule | Result |
| --- | --- |
| 1. Neutral name | pass: `Session` names no product |
| 2. A precedent | not recorded: no ledger row (coverage.json) names this member or its owner |
| 3. Two apps, or labs | not recorded: no ledger row names this member or its owner |
| 4. The cheaper fix first | not recorded per member (Appendix B decides it per need) |
