solvable
Import from bear/engine/solvable.
Interfaces
Attachment
Defined in: bear/engine/solvable.ts:62
One anchor attached to a relation target: the edge and the constraint are two projections of this one declaration. Consumed by solve.
Properties
| Property | Type | Description |
|---|---|---|
anchor | string | - |
descriptor | RelationTargetDescriptor | - |
port? | string | The target's face, when named apart from the target (a name has no ref). |
Lowerer
Defined in: bear/engine/solvable.ts:73
What lower() may state about a component's anchors.
Methods
align()
align(
a,
b,
axis
): void;Defined in: bear/engine/solvable.ts:79
Constrain two anchors to share a coordinate.
Parameters
| Parameter | Type |
|---|---|
a | string |
b | string |
axis | PlanarAxis |
Returns
void
attach()
attach(
anchor,
target,
face?
): void;Defined in: bear/engine/solvable.ts:86
Attach an anchor to a relation target: declares the edge on the
element (as bearsOn={...} would) and constrains the anchor to the
target's interface by the kind's mate rule. Rotation is never solved:
the mate pins the anchor's position only.
Parameters
| Parameter | Type |
|---|---|
anchor | string |
target | RelationTargetDescriptor |
face? | string |
Returns
void
fix()
fix(anchor, at): void;Defined in: bear/engine/solvable.ts:75
Pin both coordinates of an anchor (fully authored placement).
Parameters
| Parameter | Type |
|---|---|
anchor | string |
at | Vec2 |
Returns
void
onPlane()
onPlane(
anchor,
target,
face
): void;Defined in: bear/engine/solvable.ts:95
attach's constraint without its edge: the anchor lies on the
target's face by the kind's mate rule. For an element whose owner
states the connection once (a wall's joins edge) while each of its
layers lands on the other wall's faces.
Parameters
| Parameter | Type |
|---|---|
anchor | string |
target | RelationTargetDescriptor |
face | string |
Returns
void
pin()
pin(
anchor,
axis,
value
): void;Defined in: bear/engine/solvable.ts:77
Pin one coordinate of an anchor.
Parameters
| Parameter | Type |
|---|---|
anchor | string |
axis | PlanarAxis |
value | number |
Returns
void
rest()
rest(anchor, target): void;Defined in: bear/engine/solvable.ts:88
attach(anchor, bears(target)): the anchor rests on its support.
Parameters
| Parameter | Type |
|---|---|
anchor | string |
target | BearingTarget |
Returns
void
SolvableDecl
Defined in: bear/engine/solvable.ts:98
Type Parameters
Properties
| Property | Type | Description |
|---|---|---|
anchors | readonly string[] | Named anchor points. Their coordinates are the only solver variables. The first is the one the body lays out from: every ref the element or anything inside it publishes rides it, unless the publishing node's rides prop names another (a span's end plane rides end). |
body | (props) => BearElement | The component body: a pure props → JSX function. |
complete | (anchors) => Partial<P> | Rebuild the completed placement props from solved anchor positions. |
lower | (props, c, grid) => void | Lower authored placement props to constraints on the anchors. Runs at collect time, every pass, from authored props alone. Everything not stated here comes from Dims. |
name | string | The component's name, for messages and the tree: Wall, Opening. |
refs? | readonly string[] | Named refs the component publishes (attached to its JSX elements). |
SolvableInstance
Defined in: bear/engine/solvable.ts:128
Engine-internal: a solvable element occurrence in the current collect
pass, consumed by solve. The key names the logical solvable (see
instanceKey) and is stable across passes because the authored JSX is
deterministic.
Properties
| Property | Type | Description |
|---|---|---|
aligns | Align[] | - |
anchors | readonly string[] | - |
attachments | Attachment[] | - |
bound | boolean | True when the body ran (placement known); false for a stub. |
buildError? | string | The body rejected its solved placement (e.g. a degenerate span). |
element | BearElement | The element the wrapper returned; resolves to the tree node. |
key | string | - |
pins | Pin[] | - |
stub | BearElement | The placeholder it stands in as while unbound, or once it fails to build. |
Vec2
Defined in: bear/engine/solvable.ts:39
Properties
Type Aliases
BearingTarget
type BearingTarget =
| RelationTarget
| RelationTargetDescriptor<"bears">;Defined in: bear/engine/solvable.ts:70
What a bears attachment may point at: a bare target, or one with edge props.
PlanarAxis
type PlanarAxis = "x" | "y";Defined in: bear/engine/solvable.ts:37
SolvedBindings
type SolvedBindings = ReadonlyMap<string, Record<string, Vec2>>;Defined in: bear/engine/solvable.ts:148
Engine-internal: solved anchor positions per instance key, fed forward between render passes.
Functions
isSolvableStub()
function isSolvableStub(node): boolean;Defined in: bear/engine/solvable.ts:341
Is this node an unbound solvable's placeholder?
Parameters
| Parameter | Type |
|---|---|
node | { type: unknown; } |
node.type | unknown |
Returns
boolean
rejectBuild()
function rejectBuild(instance, error): BearElement;Defined in: bear/engine/solvable.ts:330
A bound instance that could not be built at its solved position (a degenerate span, a run whose openings overlap) falls back to its stub, and the reason becomes its diagnostic, never a render abort. A pass's placement is provisional until the loop converges: an early pass can hand a body seed values nothing has placed yet, and the next pass may build. Only the converged pass's failure reaches the user.
Parameters
| Parameter | Type |
|---|---|
instance | SolvableInstance |
error | unknown |
Returns
solvable()
function solvable<P>(decl): AssemblyFn<P> & object;Defined in: bear/engine/solvable.ts:155
Wrap a component so the solver may complete its placement. The wrapper is an ordinary assembly function; fully authored placement never touches the solver.
Type Parameters
Parameters
| Parameter | Type |
|---|---|
decl | SolvableDecl<P> |
Returns
AssemblyFn<P> & object