# `Writer.node`

> 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.

Method of [`Writer`](Writer.md) · inherited by [`Tx`](Tx.md), [`Session`](Session.md), [`testing.FakeSession`](testing.FakeSession.md) · stable · since 2.0.0 · called as `session.node`

```ts
node(nodeId: string): Part<C>;
```

The root part of the ModelNode `nodeId`: pose it, hide it, follow it or bound it as a whole.
Sync; `exists: false` when no such node is loaded. Precedent: DOM `getElementById`.
An address handle: a write through it is a rule bound to that model's root (spec section 6.10,
Q3, Q4), so a write made while a queued scene write still loads the node is pending
(`pending: true`) and applies when it loads, as [`find({ node: nodeId })`](Writer.find.md) does. A `null` write
removes the rule whether or not the node is loaded. It never records 'handle-disposed'. A new
`glbUrl` keeps the node, so a handle kept in module scope still works after a style switch:
its rules re-match the new content (spec section 6.9, ID4). An id that names a stored node
placing nothing (a GroupNode, a MaterialNode) or a node's `_id` or name matches no part: its
'target-unmatched' says which, with the ModelNode ids (or that node's `nodeId`) in
`didYouMean` (delivery-run cycle 18, R2-GAP-7).
Not for: every part of the model, which is [`find({ node: nodeId })`](Writer.find.md).

## Example

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/05-Writer.node.ts`):

```ts
import type { Session } from '@holostep-configurators/runtime-client/contract';
declare const session: Session;
declare const signal: AbortSignal;
declare const doorId: string;
declare const handleIds: readonly string[];
// the model's root; find({ node: doorId }) is every part of it
const door = session.node(doorId);
// each handle rides the door
const stops = handleIds.map((id) => session.node(id).follow(door, { offset: 'current' }));
// turns about the model's origin, its authored hinge
await door.set({ pose: { rotationDeg: { x: 0, y: 95, z: 0 } } }, { durationMs: 900 });
// derived: the whole model's world bounds, swung open
console.log(door.bounds()?.size);
export async function closeDoor(): Promise<void> {
  // a pose rule is temporary: reset it with null
  await door.set({ pose: null }, { durationMs: 900 });
  stops.forEach((stop) => stop());
}
```

## Generic-API test (spec 3.1)

| Rule | Result |
| --- | --- |
| 1. Neutral name | pass: `node` names no product |
| 2. A precedent | pass: [DOM Document.getElementById](https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById) (row `G31`); [Unity Animations.ParentConstraint (offsets)](https://docs.unity3d.com/ScriptReference/Animations.ParentConstraint.html) (row `G6`); [Unity RaycastHit.transform](https://docs.unity3d.com/ScriptReference/RaycastHit-transform.html) (row `K44`); [Unity Renderer.bounds](https://docs.unity3d.com/ScriptReference/Renderer-bounds.html) (row `K57`) |
| 3. Two apps, or labs | pass: 13 apps (ledger: app-04c2774145, app-0c773a4ee3, app-b362a81c85, app-c1384707fc, app-f9a32142f1, app-fc07850558, app-fc306ec3dc; fleet cross-check: app-04c2774145, app-4762caacdc, app-4f16d2f6da, app-b362a81c85, app-b4ae2fce25, app-bcb7ef21da, app-c1384707fc, app-ddfb017681 and 4 more) |
| 4. The cheaper fix first | decided per need in Appendix B: rows `G31`, `G6`, `K44`, `K57` at tier stable (a member only where no rule, data, asset or app code serves the need) |
