Skip to Content
Bear documentation

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

PropertyTypeDescription
anchorstring-
descriptorRelationTargetDescriptor-
port?stringThe 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
ParameterType
astring
bstring
axisPlanarAxis
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
ParameterType
anchorstring
targetRelationTargetDescriptor
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
ParameterType
anchorstring
atVec2
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
ParameterType
anchorstring
targetRelationTargetDescriptor
facestring
Returns

void

pin()
pin(
   anchor, 
   axis, 
   value
): void;

Defined in: bear/engine/solvable.ts:77

Pin one coordinate of an anchor.

Parameters
ParameterType
anchorstring
axisPlanarAxis
valuenumber
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
ParameterType
anchorstring
targetBearingTarget
Returns

void


SolvableDecl

Defined in: bear/engine/solvable.ts:98

Type Parameters

Type Parameter
P extends object

Properties

PropertyTypeDescription
anchorsreadonly 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) => BearElementThe component body: a pure props → JSX function.
complete(anchors) => Partial<P>Rebuild the completed placement props from solved anchor positions.
lower(props, c, grid) => voidLower 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.
namestringThe 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

PropertyTypeDescription
alignsAlign[]-
anchorsreadonly string[]-
attachmentsAttachment[]-
boundbooleanTrue when the body ran (placement known); false for a stub.
buildError?stringThe body rejected its solved placement (e.g. a degenerate span).
elementBearElementThe element the wrapper returned; resolves to the tree node.
keystring-
pinsPin[]-
stubBearElementThe placeholder it stands in as while unbound, or once it fails to build.

Vec2

Defined in: bear/engine/solvable.ts:39

Properties

PropertyType
xnumber
ynumber

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

ParameterType
node{ type: unknown; }
node.typeunknown

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

ParameterType
instanceSolvableInstance
errorunknown

Returns

BearElement


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

Type Parameter
P extends object

Parameters

ParameterType
declSolvableDecl<P>

Returns

AssemblyFn<P> & object

On this page