collection
Import from bear/engine/collection.
Interfaces
Collected
Defined in: bear/engine/collection.ts:64
What collection produces: the finished tree and what was learned building it.
Properties
| Property | Type | Description |
|---|---|---|
diagnostics | readonly Diagnostic[] | Placement findings. |
elementMap | ReadonlyMap<BearElement<object>, TreeNode> | Maps each BearElement (from JSX) to the node it produced. |
instances | readonly SolvableInstance[] | The solvable elements this pass registered, in collect order. |
root | TreeNode | - |
seal | (result) => void | Seal the tree into its result: node.model on every node, then a shallow freeze. materialize() calls this once, for the converged pass. |
Functions
boxOf()
function boxOf(target): Box | undefined;Defined in: bear/engine/collection.ts:313
An already-collected element's box in the collecting assembly's frame, for a body that lays out between elements it did not make (joists between a ledger and a beam). Parts and assemblies alike. Undefined while the element is an unbound solvable: the loop places it and comes back, and only the converged pass is observable.
Parameters
| Parameter | Type |
|---|---|
target | BearElement<object> | Ref |
Returns
Box | undefined
collect()
function collect(element, bindings?): Collected;Defined in: bear/engine/collection.ts:344
Evaluates a BearElement tree (JSX output) into the node tree. Assembly
functions are called, fragments are spliced, and fully qualified names
(FQNs) are assigned from the name prop on each element. The tree is
sealed by Collected.seal once it has a result.
Parameters
| Parameter | Type |
|---|---|
element | BearElement |
bindings? | SolvedBindings |
Returns
collectionParent()
function collectionParent(): TreeNode | null;Defined in: bear/engine/collection.ts:894
The node the element being collected will hang under, with the siblings collected so far beneath it. For the rare assembly that reads other elements' final poses and refs (Envelope grouping wall faces): those are props on already-collected nodes, so a body can look them up.
Returns
TreeNode | null
contributeToHost()
function contributeToHost(
key,
name,
describe
): void;Defined in: bear/engine/collection.ts:230
Called by a typed HostSlot while its member's component is collected.
Parameters
| Parameter | Type |
|---|---|
key | symbol |
name | string |
describe | (member) => unknown |
Returns
void
extentsOf()
function extentsOf(element): ReferenceExtents;Defined in: bear/engine/collection.ts:196
What a part element will measure, from its props alone. For assembly bodies that size or pose children before materializing them: a wall reads its sheathing's thickness, a floor its joists' depth. Parts only; an assembly's facts derive from the data that builds it.
Parameters
| Parameter | Type |
|---|---|
element | BearElement |
Returns
getCollectionContext()
function getCollectionContext<T>(context): T | undefined;Defined in: bear/engine/collection.ts:177
Read a typed context value from the current collection-time ancestor chain.
Only valid inside an assembly function body during collection.
Returns undefined if no ancestor provides the context.
Type Parameters
Parameters
| Parameter | Type |
|---|---|
context | BearContext<T> |
Returns
T | undefined
host()
function host<P>(component): BearElement<P>;Defined in: bear/engine/collection.ts:223
The nearest enclosing element of a component: a hosted body's handle on
its host, the same element <Wall … /> made. Its refs resolve like any
other (resolveRef(getRef(host(Wall), "finishInt"))).
Type Parameters
Parameters
| Parameter | Type |
|---|---|
component | | AssemblyFn<P> | PartDef<P, string, string> |
Returns
BearElement<P>
isCollectedAssembly()
function isCollectedAssembly(fn): boolean;Defined in: bear/engine/collection.ts:421
Has this function ever been expanded as an assembly component?
Parameters
| Parameter | Type |
|---|---|
fn | object |
Returns
boolean
resolveRef()
function resolveRef(ref): Surface;Defined in: bear/engine/collection.ts:213
The surface a Ref names, expressed in the collecting parent's frame. The source must already be collected: an earlier sibling, or an earlier child of the same parent.
Parameters
| Parameter | Type |
|---|---|
ref | Ref |
Returns
solvablePass()
function solvablePass(): object;Defined in: bear/engine/collection.ts:154
Pass state solvable() reads and writes.
Returns
object
| Name | Type |
|---|---|
bindings | SolvedBindings | undefined |
instances | SolvableInstance[] |