Reference
API reference
Package modules#
Expand a module for its exports. Open a type to see its fields, or expand a factory’s returned methods to see what its controller can do after mounting. Try searching for GraphOptions or setLayoutSpeed.
16 modules in loom-core 0.1.0
loom-coreMount a WebGL2 graph, read its camera, and serialize graph data.
WebGL2UnavailableErrorblueprintcreate<N extends GraphNode = GraphNode, E extends GraphLink = GraphLink>(canvas: HTMLCanvasElement, options: GraphOptions<N, E>): LoomGraph<N, E>Returned methods (23)
destroy(): voidfit(immediate?: boolean): voidfocus(id: string): voidgetFrame(): GraphFramegetPosition(id: string): { x: number; y: number; z: number; pinned: boolean; }getViewport(): GraphViewportinvalidate(): voidon<K extends keyof GraphEvents>(type: K, listener: (value: GraphEvents[K]) => void): () => voidonFrame(listener: (frame: GraphFrame) => void): () => voidonTiming(probe: FrameProbe): () => voidpause(): voidpin(id: string, position?: { x: number; y: number; z?: number; }): voidreset(): voidresize(): voidresume(): voidscreenToWorld(x: number, y: number, depth?: number): { x: number; y: number; z: number; }select(id: string | null): voidsetLayout(options: LayoutOptions<N>): voidsetMode(mode: Mode): voidsetTheme(theme: Theme<N, E>): voidsetViewport(viewport: GraphViewport): voidstats(): GraphStatsunpin(id: string): void
createGraph<N extends GraphNode = GraphNode, E extends GraphLink = GraphLink>(canvas: HTMLCanvasElement, options: GraphOptions<N, E>): LoomGraph<N, E>Returned methods (23)
destroy(): voidfit(immediate?: boolean): voidfocus(id: string): voidgetFrame(): GraphFramegetPosition(id: string): { x: number; y: number; z: number; pinned: boolean; }getViewport(): GraphViewportinvalidate(): voidon<K extends keyof GraphEvents>(type: K, listener: (value: GraphEvents[K]) => void): () => voidonFrame(listener: (frame: GraphFrame) => void): () => voidonTiming(probe: FrameProbe): () => voidpause(): voidpin(id: string, position?: { x: number; y: number; z?: number; }): voidreset(): voidresize(): voidresume(): voidscreenToWorld(x: number, y: number, depth?: number): { x: number; y: number; z: number; }select(id: string | null): voidsetLayout(options: LayoutOptions<N>): voidsetMode(mode: Mode): voidsetTheme(theme: Theme<N, E>): voidsetViewport(viewport: GraphViewport): voidstats(): GraphStatsunpin(id: string): void
fromBinary(buffer: Uint8Array | ArrayBuffer): { nodes: GraphNode[]; links: GraphLink[]; }fromConsole<N extends GraphNode, E extends GraphLink>(graph: { nodes: readonly N[]; edges: readonly E[]; }): { nodes: readonly N[]; links: readonly E[]; }inkknowledgeConsoleparchmenttoBinary(data: GraphData): Uint8ArrayTypes
FrameProbe
interface FrameProbe {
beginDraw(gl: WebGL2RenderingContext): void;
endDraw(): void;
sample(time: number, mainThreadMs: number, intervalMs: number, painted: boolean): void;
}GraphData
interface GraphData<N extends GraphNode = GraphNode, E extends GraphLink = GraphLink> {
nodes: readonly N[];
links: readonly E[];
}GraphEvents
interface GraphEvents {
select: string | null;
/** A click or tap on a node or its label, including repeated clicks on the current selection. */
nodeclick: string;
/** A completed pointer drag. Read the released world coordinates with getPosition(id). */
nodedrop: string;
hover: string | null;
open: string;
/** A clean click on empty graph space, in canvas CSS pixels. Nodes and labels take precedence. */
backgroundclick: {
x: number;
y: number;
clicks: number;
};
modechange: Mode;
destroy: undefined;
}GraphFrame
CSS-pixel screen coordinates are borrowed until the next draw, in input node order.
interface GraphFrame {
/** Changes when the graph rebuilds its projected coordinates. Older frame providers may omit it. */
readonly projectionVersion?: number;
/** Four floats per node: screen x, screen y, visible radius, camera depth. */
readonly points: Readonly<Float32Array>;
readonly width: number;
readonly height: number;
readonly mode: Mode;
readonly zoom: number;
readonly yaw: number;
readonly pitch: number;
/** Screen coordinate of world zero on the lane axis. */
readonly laneOrigin: number;
readonly vertical: boolean;
/** Lane identifiers and their world-space offsets, in visual order. */
readonly lanes: ReadonlyMap<string, number>;
}GraphLink
interface GraphLink {
/** Optional stable document identity. The editor assigns IDs to older anonymous links. */
id?: string;
source: string;
target: string;
kind?: string;
weight?: number;
metrics?: Readonly<Record<string, number>>;
}GraphNode
interface GraphNode {
id: string;
label?: string;
kind?: string;
/** Authored overrides for this marker, applied after theme and taxonomy styling. */
markerColor?: string;
markerShape?: NodeShape;
x?: number;
y?: number;
z?: number;
/** Defaults to true for nodes supplied with both x and y. Set false to seed a movable node. */
pinned?: boolean;
art?: string;
degree?: number;
section?: string;
summary?: string;
content?: string;
/** Authored content size in bytes. The metric helper can also measure supplied text. */
contentSize?: number;
complexity?: number;
metrics?: Readonly<Record<string, number>>;
}GraphOptions
interface GraphOptions<N extends GraphNode = GraphNode, E extends GraphLink = GraphLink> extends GraphData<N, E> {
/** Rendering extension supplied by loom-core/wires. */
wireProgram?: WireProgram;
/** Composite marks over a host background, for example an SVG group boundary layer. Set on the canvas's first mount. */
transparentBackground?: boolean;
mode?: Mode;
theme?: Theme<NoInfer<N>, NoInfer<E>>;
layout?: LayoutOptions<NoInfer<N>>;
art?: {
urlFor: (node: NoInfer<N>) => string | undefined;
};
sim?: 'main' | 'worker';
workerURL?: string | URL;
reducedMotion?: 'respect' | 'ignore';
}GraphStats
interface GraphStats {
firstSubmitMs: number;
frames: number;
simTicks: number;
drawCalls: number;
labels: number;
imageTiles: number;
/** Bytes in the packed position/radius and edge-endpoint arrays. */
geometryBytes: number;
dpr: number;
pendingFrame: boolean;
transport: 'main' | 'transfer' | 'shared';
}GraphViewport
interface GraphViewport {
x: number;
y: number;
z: number;
zoom: number;
yaw: number;
pitch: number;
}LayoutOptions
interface LayoutOptions<N extends GraphNode = GraphNode> {
/** 0 uses the active force mode. 1 places movable nodes exactly on their anchors. */
blend?: number;
laneOrder?: readonly string[];
/** Classify nodes into lanes. The default uses node.kind. */
laneBy?: (node: N, index: number) => string;
laneGap?: number;
/** Minimum world-space distance between successive orbit rings. */
orbitGap?: number;
/** Depth multiplier for generated Cloud coordinates. Authored z coordinates take precedence. */
cloudDepth?: number;
/** Slowly orbit an idle Cloud. Reduced motion suppresses automatic rotation. */
autoRotate?: boolean;
rowGap?: number;
direction?: 'horizontal' | 'vertical';
anchor?: ((node: N, index: number) => {
x: number;
y: number;
z?: number;
} | null | undefined) | null;
repulsion?: number;
linkDistance?: number;
springStrength?: number;
/** Per-kind rest distances and multipliers for the global spring strength. */
springsByKind?: Readonly<Record<string, {
distance?: number;
strength?: number;
}>>;
pinOnDrag?: boolean;
guides?: boolean;
}LoomGraph
interface LoomGraph<N extends GraphNode = GraphNode, E extends GraphLink = GraphLink> {
/** Request one paint on the existing scheduler. Honors pause, visibility and disposal. */
invalidate(): void;
/** Subscribe to actual paints. The first subscription wakes an idle graph once. */
onFrame(listener: (frame: GraphFrame) => void): () => void;
/** Read current projected points synchronously, including while the graph is paused. */
getFrame(): GraphFrame;
/** Attach an optional timing probe to this graph. Returns its detach function. */
onTiming(probe: FrameProbe): () => void;
select(id: string | null): void;
focus(id: string): void;
setMode(mode: Mode): void;
setLayout(options: LayoutOptions<N>): void;
setTheme(theme: Theme<N, E>): void;
/** Convert canvas CSS pixels to the camera-facing world plane at the given camera depth. */
screenToWorld(x: number, y: number, depth?: number): {
x: number;
y: number;
z: number;
};
getViewport(): GraphViewport;
setViewport(viewport: GraphViewport): void;
getPosition(id: string): {
x: number;
y: number;
z: number;
pinned: boolean;
};
pin(id: string, position?: {
x: number;
y: number;
z?: number;
}): void;
unpin(id: string): void;
/** Frame the graph bounds. Pass true to apply the fitted viewport synchronously. */
fit(immediate?: boolean): void;
reset(): void;
pause(): void;
resume(): void;
resize(): void;
destroy(): void;
on<K extends keyof GraphEvents>(type: K, listener: (value: GraphEvents[K]) => void): () => void;
stats(): GraphStats;
}Mode
type Mode = 'drift' | 'lanes' | 'orbit' | 'cloud';NodeShape
type NodeShape = 'circle' | 'ring' | 'square' | 'rounded-square';NodeStyle
interface NodeStyle {
shape?: NodeShape;
color?: string;
/** Absolute world-space radius. Omit to retain degree-based sizing. */
radius?: number;
}Theme
interface Theme<N extends GraphNode = GraphNode, E extends GraphLink = GraphLink> {
kind: Readonly<Record<string, string>>;
ink: string;
dim: string;
accent: string;
bg: string;
bezel: string;
font: string;
fontSize: number;
radii: {
hub: number;
content: number;
};
plateAlpha: number;
nodes?: {
scale?: number;
artwork?: boolean;
ringWidth?: number;
fill?: number;
byKind?: Readonly<Record<string, NodeStyle>>;
resolve?: (node: N, degree: number) => NodeStyle | undefined;
};
wires?: WireStyle & {
routing?: WireRoute;
hotWidth?: number;
byKind?: Readonly<Record<string, WireStyle>>;
resolve?: (link: E, index: number) => WireStyle | undefined;
};
grid?: {
spacing?: number;
color?: string;
opacity?: number;
};
labels?: {
density?: number;
visibility?: 'auto' | 'focus' | 'none';
alternateSide?: boolean;
};
}WirePattern
type WirePattern = 'solid' | 'dashed' | 'dotted';WireRoute
type WireRoute = 'arc' | 'patch' | 'straight';WireStyle
interface WireStyle {
color?: string;
opacity?: number;
width?: number;
pattern?: WirePattern;
}loom-core/editorPreview, apply and undo revision-guarded document edits.
createEditor<T extends GraphData>(data: T, { historyLimit, documentId }?: { historyLimit?: number | undefined; documentId?: string | undefined; })A document session shared by UI controls and JSON clients. No DOM or renderer is required.
Returned methods (13)
apply(input: unknown): EditorReceiptcheckpoint(): EditorCheckpointdescribe(): { version: 1; documentId: string; revision: number; nodes: number; links: number; canUndo: boolean; canRedo: boolean; operations: string[]; }getLink(id: string): Readonly<GraphLink & { id: string; } & Record<string, unknown>> | undefinedgetNode(id: string): Readonly<GraphNode & Record<string, unknown>> | undefinedgetSnapshot(): EditorSnapshotpreview(input: unknown): EditorReceiptquery({ entity, text, kind, incidentTo, offset, limit }: EditorQuery): { revision: number; total: number; items: { id: string; kind?: string; label?: string; source?: string; target?: string; }[]; nextOffset: number | null; }redo(expectedRevision?: number): EditorReceiptreplaceData(data: GraphData, expectedRevision?: number): EditorReceiptsubscribe(fn: () => void): () => voidtransact(operations: readonly EditorOperation[], expectedRevision?: number): EditorReceiptundo(expectedRevision?: number): EditorReceipt
editorSchemarestoreEditor(checkpoint: unknown, { historyLimit }?: { historyLimit?: number | undefined; })Restore JSON readback and revision. Undo history belongs to the original session.
Returned methods (13)
apply(input: unknown): EditorReceiptcheckpoint(): EditorCheckpointdescribe(): { version: 1; documentId: string; revision: number; nodes: number; links: number; canUndo: boolean; canRedo: boolean; operations: string[]; }getLink(id: string): Readonly<GraphLink & { id: string; } & Record<string, unknown>> | undefinedgetNode(id: string): Readonly<GraphNode & Record<string, unknown>> | undefinedgetSnapshot(): EditorSnapshotpreview(input: unknown): EditorReceiptquery({ entity, text, kind, incidentTo, offset, limit }: EditorQuery): { revision: number; total: number; items: { id: string; kind?: string; label?: string; source?: string; target?: string; }[]; nextOffset: number | null; }redo(expectedRevision?: number): EditorReceiptreplaceData(data: GraphData, expectedRevision?: number): EditorReceiptsubscribe(fn: () => void): () => voidtransact(operations: readonly EditorOperation[], expectedRevision?: number): EditorReceiptundo(expectedRevision?: number): EditorReceipt
Types
EditorChange
interface EditorChange {
op: EditorOperation['op'] | 'graph.replace';
id: string;
}EditorCheckpoint
interface EditorCheckpoint {
readonly version: 1;
readonly documentId: string;
readonly revision: number;
readonly data: EditorData;
}EditorData
interface EditorData extends GraphData<EditorNode, EditorLink> {
readonly nodes: readonly EditorNode[];
readonly links: readonly EditorLink[];
readonly [field: string]: unknown;
}EditorErrorCode
type EditorErrorCode = 'invalid_input' | 'wrong_document' | 'stale_revision' | 'duplicate_id' | 'not_found' | 'missing_endpoint' | 'connected_node' | 'empty_history';EditorLink
type EditorLink = Readonly<GraphLink & {
id: string;
} & Record<string, unknown>>;EditorNode
type EditorNode = Readonly<GraphNode & Record<string, unknown>>;EditorOperation
type EditorOperation = {
op: 'node.add';
value: GraphNode | EditorNode;
} | {
op: 'link.add';
value: (GraphLink & {
id: string;
}) | EditorLink;
} | ({
op: 'node.update';
id: string;
} & Patch<GraphNode>) | ({
op: 'link.update';
id: string;
} & Patch<GraphLink>) | {
op: 'node.remove';
id: string;
cascade?: boolean;
} | {
op: 'link.remove';
id: string;
};EditorQuery
interface EditorQuery {
entity: 'node' | 'link';
text?: string;
kind?: string;
incidentTo?: string;
offset?: number;
limit?: number;
}EditorReceipt
type EditorReceipt = {
ok: true;
revision: number;
changes: readonly EditorChange[];
} | {
ok: false;
revision: number;
error: {
code: EditorErrorCode;
path: string;
message: string;
};
};EditorSnapshot
interface EditorSnapshot extends EditorCheckpoint {
readonly canUndo: boolean;
readonly canRedo: boolean;
}EditorTransaction
interface EditorTransaction {
version: 1;
documentId?: string;
expectedRevision?: number;
operations: readonly EditorOperation[];
}loom-core/wiresDraw separated connections, directional flow and sketch-style markers.
createWireGraph<N extends GraphNode = GraphNode, E extends GraphLink = GraphLink>(canvas: HTMLCanvasElement, options: Omit<GraphOptions<N, E>, 'wireProgram'> & { wireEffects?: Partial<WireEffects>; drawingStyle?: Partial<DrawingStyle>; }): WireGraph<N, E>Create a normal Loom graph with separated connections and optional direction markers.
Returned methods (27)
destroy(): voidfit(immediate?: boolean): voidfocus(id: string): voidgetDrawingStyle(): Readonly<DrawingStyle>getFrame(): GraphFramegetPosition(id: string): { x: number; y: number; z: number; pinned: boolean; }getViewport(): GraphViewportgetWireEffects(): Readonly<WireEffects>invalidate(): voidon<K extends keyof GraphEvents>(type: K, listener: (value: GraphEvents[K]) => void): () => voidonFrame(listener: (frame: GraphFrame) => void): () => voidonTiming(probe: FrameProbe): () => voidpause(): voidpin(id: string, position?: { x: number; y: number; z?: number; }): voidreset(): voidresize(): voidresume(): voidscreenToWorld(x: number, y: number, depth?: number): { x: number; y: number; z: number; }select(id: string | null): voidsetDrawingStyle(patch: Partial<DrawingStyle>): voidsetLayout(options: LayoutOptions<N>): voidsetMode(mode: Mode): voidsetTheme(theme: Theme<N, E>): voidsetViewport(viewport: GraphViewport): voidsetWireEffects(patch: Partial<WireEffects>): voidstats(): GraphStatsunpin(id: string): void
defaultDrawingStyledefaultWireEffectsdrawingStyleSchemasketchbookwireEffectsSchemaJSON Schema for a partial settings patch. Defaults describe a newly mounted wire graph.
Types
DrawingStyle
interface DrawingStyle {
fill: 'solid' | 'hachure' | 'cross-hatch';
/** Zero uses exact geometry. Higher values perturb outlines and wire handles. */
roughness: number;
/** Perpendicular distance between hatch lines, in CSS pixels. */
hatchSpacing: number;
}WireEffects
interface WireEffects {
/** Centre-to-centre separation of parallel paths at their midpoint, in CSS pixels. */
separation: number;
direction: 'none' | 'arrow' | 'flow';
scope: 'selected' | 'all';
/** Distance the pulse travels in CSS pixels per second. */
speed: number;
}WireGraph
interface WireGraph<N extends GraphNode = GraphNode, E extends GraphLink = GraphLink> extends LoomGraph<N, E> {
getWireEffects(): Readonly<WireEffects>;
setWireEffects(patch: Partial<WireEffects>): void;
getDrawingStyle(): Readonly<DrawingStyle>;
setDrawingStyle(patch: Partial<DrawingStyle>): void;
}loom-core/scene
captureScene<D extends GraphData>(data: D, options?: SceneCaptureOptions<D['nodes'][number], D['links'][number]>): GraphScene<D['nodes'][number], D['links'][number]> & { data: D; }Sample layout and appearance callbacks once, so a JSON consumer never needs the author's code.
mountScene<N extends GraphNode, E extends GraphLink>(canvas: HTMLCanvasElement, scene: GraphScene<N, E>, options?: Pick<GraphOptions, 'workerURL' | 'sim' | 'reducedMotion'>): WireGraph<N, E>Render a saved scene in a sized canvas. The caller owns the returned graph and calls destroy() on unmount.
Returned methods (27)
destroy(): voidfit(immediate?: boolean): voidfocus(id: string): voidgetDrawingStyle(): Readonly<DrawingStyle>getFrame(): GraphFramegetPosition(id: string): { x: number; y: number; z: number; pinned: boolean; }getViewport(): GraphViewportgetWireEffects(): Readonly<WireEffects>invalidate(): voidon<K extends keyof GraphEvents>(type: K, listener: (value: GraphEvents[K]) => void): () => voidonFrame(listener: (frame: GraphFrame) => void): () => voidonTiming(probe: FrameProbe): () => voidpause(): voidpin(id: string, position?: { x: number; y: number; z?: number; }): voidreset(): voidresize(): voidresume(): voidscreenToWorld(x: number, y: number, depth?: number): { x: number; y: number; z: number; }select(id: string | null): voidsetDrawingStyle(patch: Partial<DrawingStyle>): voidsetLayout(options: LayoutOptions<N>): voidsetMode(mode: Mode): voidsetTheme(theme: Theme<N, E>): voidsetViewport(viewport: GraphViewport): voidsetWireEffects(patch: Partial<WireEffects>): voidstats(): GraphStatsunpin(id: string): void
Types
GraphScene
A portable graph and its canvas appearance. Node and link records retain their application fields.
interface GraphScene<N extends GraphNode = GraphNode, E extends GraphLink = GraphLink> {
version: 1;
data: GraphData<N, E>;
mode?: Mode;
layout?: Omit<LayoutOptions, 'laneBy' | 'anchor'>;
theme?: SceneTheme;
drawingStyle?: Partial<DrawingStyle>;
wireEffects?: Partial<WireEffects>;
lanes?: Table<string>;
anchors?: Table<Anchor>;
nodeStyles?: Table<NodeStyle>;
/** Keys are link indices so parallel and anonymous edges retain their individual styling. */
linkStyles?: Table<WireStyle>;
/** Each resolved image URL is stored once, even when many nodes share a data URL. */
artwork?: {
urls: readonly string[];
byNode: Table<number>;
};
positions?: Table<Position>;
viewport?: GraphViewport;
selected?: string;
}SceneCaptureOptions
interface SceneCaptureOptions<N extends GraphNode = GraphNode, E extends GraphLink = GraphLink> extends Pick<GraphOptions<N, E>, 'layout' | 'theme' | 'art' | 'mode'> {
drawingStyle?: Partial<DrawingStyle>;
wireEffects?: Partial<WireEffects>;
/** Capture live coordinates, pin states and the camera from the graph showing these records. */
graph?: Pick<LoomGraph, 'getPosition' | 'getViewport'>;
selected?: string | null;
}loom-core/consoleAdapt a knowledge-console snapshot and read its host theme.
consoleLayoutfromConsole<N extends GraphNode, E extends GraphLink>(graph: { nodes: readonly N[]; edges: readonly E[]; }): { nodes: readonly N[]; links: readonly E[]; }mountConsoleGraph<N extends GraphNode, E extends GraphLink, Legacy>(canvas: HTMLCanvasElement, graph: { nodes: readonly N[]; edges: readonly E[]; }, enabled: boolean, legacy: (canvas: HTMLCanvasElement, graph: { nodes: readonly N[]; edges: readonly E[]; }) => Legacy, options?: Omit<GraphOptions<N, E>, keyof GraphData>): Legacy | LoomGraph<N, E>readConsoleTheme(element: Element): Themeloom-core/drilldownNavigate graph scopes and restore a breadcrumb trail.
createDrilldown<N extends GraphNode = GraphNode, E extends GraphLink = GraphLink>(source: GraphData<N, E>, initial?: DrilldownOptions<N, E>)A headless controller. Bind one live renderer at a time and remount it only when snapshot.data changes.
Returned methods (15)
activate(id: string): booleanback(): booleanbind(graph: GraphPort, data?: GraphData<N, E>): () => voidfollowNode(id: string, patch?: Neighborhood<E>): booleangetSnapshot(): DrilldownSnapshot<N, E>getTrail(): { level: DrilldownLevel; selected: string | null; }[]goTo(depth: number): booleaninspect(id: string | null): voidopenGroup(group: DrilldownGroup, override?: GroupAction): booleanopenNeighborhood(id: string, patch?: Neighborhood<E>): booleanresolveLayout(mode: Mode, layout?: LayoutOptions<N>): { mode: Mode; layout: LayoutOptions<N>; }select(id: string | null): voidsetGroupView(action: GroupView): booleansetOptions(patch: DrilldownOptions<N, E>): voidsubscribe(listener: () => void): () => void
drilldownGroup(group: TaxonGroup, nodes: readonly GraphNode[]): DrilldownGroupConvert a compiled group's indices using the same node array used for its taxonomy index.
Types
DrilldownGroup
interface DrilldownGroup {
taxonomy: string;
id: string;
label?: string;
/** Stable node IDs, including all overlapping memberships. */
members: readonly string[];
}DrilldownLevel
type DrilldownLevel = {
kind: 'overview';
label: string;
} | {
kind: 'node';
id: string;
label: string;
hops: number;
direction: LinkDirection;
fromOverview?: true;
} | {
kind: 'group';
taxonomy: string;
id: string;
label: string;
memberCount: number;
action: GroupView;
};DrilldownOptions
interface DrilldownOptions<N extends GraphNode = GraphNode, E extends GraphLink = GraphLink> {
selectAction?: NodeAction | ((node: N) => NodeAction);
openAction?: NodeAction | ((node: N) => NodeAction);
groupAction?: GroupAction | ((group: DrilldownGroup) => GroupAction);
groupFor?: (node: N) => DrilldownGroup | undefined;
neighborhood?: Neighborhood<E>;
/** The default isolated detail uses free Drift. An empty object inherits the overview settings. */
detail?: {
mode?: Mode;
layout?: LayoutOptions<N>;
};
/** Ring spacing or radial expansion multiplier. Defaults to 2. */
spread?: number;
arrangement?: 'rings' | 'radial';
/** World-space spacing for ring targets or coincident radial members. */
memberSpacing?: number;
/** Force-to-anchor blend during in-place expansion. Defaults to 0.7. */
expansionBlend?: number;
}DrilldownSnapshot
interface DrilldownSnapshot<N extends GraphNode, E extends GraphLink> {
/** Directly mountable, in source order. Only a scope change replaces this object. */
readonly data: GraphData<N, E>;
readonly path: readonly DrilldownLevel[];
/** All members of the current group in parent source order, empty at other levels. */
readonly groupMembers: readonly N[];
readonly selected: string | null;
readonly options: Readonly<DrilldownOptions<N, E>>;
}GroupAction
type GroupAction = GroupView | 'none';GroupView
type GroupView = 'isolate' | 'expand';LinkDirection
type LinkDirection = 'both' | 'incoming' | 'outgoing';Neighborhood
interface Neighborhood<E extends GraphLink = GraphLink> {
hops?: number;
direction?: LinkDirection;
includeLink?: (link: E) => boolean;
}NodeAction
type NodeAction = 'inspect' | 'focus' | 'neighbors' | 'group';loom-core/exploreIndex article titles, directed neighbors and group boundaries.
createGraphIndex<N extends GraphNode, E extends GraphLink>(data: GraphData<N, E>)A read-only index of a graph snapshot. Rebuild after editing the document.
Returned methods (3)
boundary(members: Iterable<string>): BoundaryNode<N>[]neighbors(id: string, direction: "incoming" | "outgoing"): Neighbor<N, E>[]search(query: string, { within, limit }?: SearchOptions): N[]
Types
BoundaryNode
interface BoundaryNode<N> {
node: N;
/** Counts relative to the supplied group. */
incoming: number;
outgoing: number;
}Neighbor
interface Neighbor<N, E> {
node: N;
/** Parallel links in source order. */
links: readonly E[];
}SearchOptions
interface SearchOptions {
/** Restrict results to a drilldown or group without rebuilding the index. */
within?: ReadonlySet<string>;
limit?: number;
}loom-core/atlasManage topic blocks, layout choices, cached reads and cross-topic links.
atlasConnections(manifest: AtlasManifest, topic: number): { topic: number; incoming: number; outgoing: number; total: number; }[]Rank neighboring topics from the small manifest, including topics that have never been opened.
atlasLayoutscreateAtlas(manifest: AtlasManifest, readers: AtlasReaders, loading?: AtlasLoading, initialLayout?: AtlasLayout)A transport-independent, observable atlas. Multiple topics can be open at once.
Returned methods (10)
block(id: number): AtlasBlock | undefinedclose(): voidcrossings(left: number, right: number): AtlasCrossing[]getSnapshot(): AtlasSnapshotretry(): Promise<void>setExpanded(ids: Iterable<number>): Promise<void>setLayout(next: AtlasLayout): voidsetLoading(next: AtlasLoading): Promise<void>subscribe(fn: () => void): () => voidtoggle(id: number): Promise<void>
createFullAtlasReader(url: string | URL): AtlasReaderAn eagerly fetched version of the same logical blocks, usable without WebAssembly.
Returned methods (3)
close(): voidread(topics: readonly number[]): Promise<AtlasBlock[]>stats(): AtlasReads
Types
Atlas
type Atlas = ReturnType<typeof createAtlas>;AtlasBlock
interface AtlasBlock {
topic: number;
articles: [id: number, title: string, degree: number][];
edges: [source: number, target: number][];
}AtlasCrossing
interface AtlasCrossing {
source: number;
target: number;
sourceTitle: string;
targetTitle: string;
sourceTopic: number;
targetTopic: number;
}AtlasLayout
type AtlasLayout = (typeof atlasLayouts)[number];AtlasLink
interface AtlasLink extends GraphLink {
sourceTopic: number;
targetTopic: number;
}AtlasLoading
type AtlasLoading = 'on-demand' | 'full';AtlasManifest
interface AtlasManifest {
topics: readonly AtlasTopic[];
/** [source topic, target topic, hyperlink count], including links within a topic. */
connections: readonly (readonly number[])[];
}AtlasNode
interface AtlasNode extends GraphNode {
topic: number;
article?: number;
}AtlasReader
interface AtlasReader {
read(topics: readonly number[]): Promise<AtlasBlock[]>;
stats(): AtlasReads;
close(): void;
}AtlasReaders
type AtlasReaders = Record<AtlasLoading, () => AtlasReader>;AtlasReads
interface AtlasReads {
bytes: number;
requests: number;
}AtlasScene
type AtlasScene = GraphData<AtlasNode, AtlasLink>;AtlasSnapshot
interface AtlasSnapshot {
mode: AtlasLoading;
layout: AtlasLayout;
expanded: readonly number[];
loaded: readonly number[];
pending: readonly number[];
reads: AtlasReads;
scene: AtlasScene;
error: string | null;
}AtlasTopic
interface AtlasTopic {
id: number;
label: string;
color: string;
first: number;
count: number;
x: number;
y: number;
}loom-core/atlas-mapMount a topic map and control its camera, gravity and layout transitions.
atlasLayoutSpeedatlasSpringControlsmountAtlasMap(canvas: HTMLCanvasElement, atlas: Atlas, options: AtlasMapOptions)Move topics and their members in world coordinates, independently of camera and data loading.
Returned methods (26)
destroy(): voidfit(): voidfocus(id: string): voidfocusConnection(source: string, target: string): voidgetFollowedNode(): string | nullgetFrame(): GraphFramegetLayoutSpeed(): numbergetPosition(id: string): { x: number; y: number; z: number; pinned: boolean; }getPositions(): AtlasPositionsgetSpring(): { strength: number; damping: number; }getViewport(): GraphViewportisAnimatingLayout(): booleanmoveTopic(id: number, position: Point): voidmoveTopicByScreen(id: number, dx: number, dy: number): voidopen(id: string): voidpick(id: string): voidresetPositions(): voidselect(id: string | null): voidsetAnimateLayouts(value: boolean): voidsetKeepView(value: boolean): voidsetLayoutSpeed(value: number): voidsetMemberMotion(value: AtlasMemberMotion): voidsetMoveMembers(value: boolean): voidsetSpring(patch: Partial<AtlasSpringSettings>): voidsetTheme(next: Theme<AtlasNode, AtlasLink>): voidzoom(factor: number): void
Types
AtlasMapOptions
interface AtlasMapOptions {
theme: Theme<AtlasNode, AtlasLink>;
keepView?: boolean;
/** Ease visible nodes and the camera between layouts. Defaults to false. */
animateLayouts?: boolean;
/** Playback rate for layout changes. 1 takes 700 ms. Can be adjusted mid-transition. */
layoutSpeed?: number;
/** The node the camera follows across layouts, or null when manual navigation takes over. */
onFollowChange?: (id: string | null) => void;
/** Translate article positions with their topic, including articles that load later. Defaults to true. */
moveMembers?: boolean;
/** How carried articles approach their new positions. Defaults to rigid. Springs respect reduced motion. */
memberMotion?: AtlasMemberMotion;
/** Strength and damping for carried articles. Both default to 1. */
spring?: Partial<AtlasSpringSettings>;
positions?: AtlasPositions;
onPositionsChange?: (positions: AtlasPositions) => void;
onPick?: (node: AtlasNode) => void;
/** Override double-click, double-tap or Enter. By default a topic opens and the camera focuses the node. */
onOpen?: (node: AtlasNode) => void;
/** A background click after node hit testing, with its current projected scene. */
onBackgroundClick?: (point: GraphEvents['backgroundclick'], frame: GraphFrame, scene: AtlasScene) => void;
onFrame?: (frame: GraphFrame, scene: AtlasScene) => void;
}AtlasMemberMotion
type AtlasMemberMotion = 'rigid' | 'spring';AtlasPositions
Sparse, world-space offsets relative to the chosen layout. Older 2D offsets remain usable.
interface AtlasPositions {
topics: Record<string, Point>;
members: Record<string, Point>;
articles: Record<string, Point>;
}AtlasSpringSettings
interface AtlasSpringSettings {
/** Stiffness relative to the original atlas spring. Lower values produce a longer trail. */
strength: number;
/** Damping ratio. At 1, a resting article catches up without overshooting a fixed target. */
damping: number;
}loom-core/wikipedia-imagesLook up lead images, canonical titles and file credits.
createWikipediaImages(request?: typeof fetch)Coalesce concurrent lookups into serial MediaWiki PageImages requests. Missing images resolve to null.
Returned methods (2)
cancel(): voidlookup(title: string): Promise<Result>
Types
WikipediaImage
A current, freely licensed Wikipedia lead image and its file description with credits.
interface WikipediaImage {
title: string;
src: string;
width: number;
height: number;
fileUrl: string;
}loom-core/atlas-sqliteRead SQLite pages in a worker when a topic opens.
createSQLiteAtlasReader(options: AtlasSQLiteOptions): AtlasReaderRange-read the atlas schema in a dedicated SQLite/WASM worker. No worker or WASM is loaded until read().
Returned methods (3)
close(): voidread(topics: readonly number[]): Promise<AtlasBlock[]>stats(): AtlasReads
Types
AtlasSQLiteOptions
interface AtlasSQLiteOptions {
database: string | URL;
/** Uncompressed database size. Supply this when the host may compress HEAD responses. */
databaseBytes?: number;
worker: string | URL;
wasm: string | URL;
pageSize: number;
}loom-core/cardsRender an SVG neighborhood with relationship labels and draggable cards.
cardNeighborhood<N extends GraphNode, E extends GraphLink>(data: GraphData<N, E>, root: string, limit?: number): GraphData<N, E>Take up to limit distinct one-hop neighbors in input order, retaining their directed links to the root.
createCardGraph<N extends GraphNode, E extends GraphLink>(svg: SVGSVGElement, initial: GraphData<N, E>, initialOptions?: CardOptions<N, E>)An accessible SVG view for a bounded neighborhood. All user-supplied labels render as text.
Returned methods (7)
destroy(): voidfit(): voidfocus(id: string): voidselect(id: string | null, notify?: boolean): voidsetData(next: GraphData<N, E>): voidsetOptions(patch: Partial<CardOptions<N, E>>): voidzoom(factor: number): void
Types
CardOptions
interface CardOptions<N extends GraphNode, E extends GraphLink> {
root?: string;
appearance?: 'cards' | 'dots';
showLabels?: boolean;
showPorts?: boolean;
showArrows?: boolean;
/** Center a card on double-click, double-tap or Enter. Defaults to true. */
focusOnOpen?: boolean;
/** Use authored coordinates if supplied. Set false to arrange a neighborhood around its root. */
useNodePositions?: boolean;
image?: (node: N) => string | undefined;
badge?: (node: N) => string;
tint?: (node: N) => string;
relationship?: (edge: E) => string;
onSelect?: (node: N) => void;
/** Report the card's world coordinates once per completed drag or keyboard move. */
onMove?: (node: N, position: {
x: number;
y: number;
}) => void;
/** Disable moving cards while leaving selection and camera navigation available. */
movable?: boolean;
}loom-core/clustersCompute connected components and pack groups around stable anchors.
clusterLayout<N extends GraphNode>(nodes: readonly N[], groupBy: (node: N, index: number) => string, { gap, spacing, dimensions, depth, aspectRatio }?: ClusterOptions)Stable packed rows of disks or volumes. The returned anchor works in both simulation transports.
Returned methods (1)
anchor(node: N): ClusterPoint | undefined
connectedComponents<N extends GraphNode, E extends GraphLink>(data: GraphData<N, E>, include?: (link: E) => boolean): (node: N) => stringUndirected connected components of the included links. The smallest member id names each component.
Types
ClusterGroup
interface ClusterGroup {
readonly id: string;
readonly center: Readonly<ClusterPoint>;
readonly radius: number;
readonly members: readonly string[];
}ClusterOptions
interface ClusterOptions {
/** World units between neighbouring group envelopes. */
gap?: number;
/** Controls density within each group, in world units. */
spacing?: number;
/** Preferred width divided by height when packing rows. */
aspectRatio?: number;
dimensions?: 2 | 3;
depth?: number;
}ClusterPoint
interface ClusterPoint {
x: number;
y: number;
z: number;
}loom-core/metricsMap numeric data to node radii and wire widths.
contentBytes(node: GraphNode): number | undefinedExplicit byte counts take precedence, including zero. Otherwise measure the provided content or summary.
mapNodeRadius<N extends GraphNode>(data: GraphData<N>, by: NodeMetric<N>, options?: ScaleOptions): (node: N) => NodeStyle | undefinedA precomputed theme.nodes.resolve rule. Missing values inherit the theme radius.
mapWireWidth<E extends GraphLink>(data: GraphData<GraphNode, E>, by: WireMetric<E>, options?: ScaleOptions): (link: E, index: number) => WireStyle | undefinedA precomputed theme.wires.resolve rule, indexed in the input link order.
Types
NodeMetric
type NodeMetric<N extends GraphNode = GraphNode> = 'degree' | 'contentSize' | 'complexity' | Accessor<N>;ScaleOptions
interface ScaleOptions {
domain?: readonly [number, number];
range?: readonly [number, number];
curve?: 'linear' | 'sqrt' | 'log';
}WireMetric
type WireMetric<E extends GraphLink = GraphLink> = 'connections' | 'multiplicity' | 'weight' | Accessor<E>;loom-core/performanceSample rendering work, layout ticks and GPU timing.
observePerformance(graph: Pick<LoomGraph, 'onTiming' | 'on' | 'stats'>, listener: (sample: PerformanceSample) => void): () => voidSamples existing renderer work. Sleeping graphs produce one final idle update.
Types
GPUStatus
type GPUStatus = 'waiting' | 'measured' | 'unavailable' | 'disjoint';PerformanceSample
interface PerformanceSample extends GraphStats {
idle: boolean;
/** Graph draw submissions per second over the last second. */
fps: number;
/** Mean main-thread time in a Loom scheduler callback over the last second. */
mainThreadMs: number | null;
p95FrameMs: number | null;
frameIntervals: readonly number[];
/** Most recent asynchronous GPU draw sample, in milliseconds. */
gpuMs: number | null;
gpuStatus: GPUStatus;
/** Browser-reported JavaScript heap usage, in bytes, when available. */
heapBytes: number | null;
}loom-core/taxonomyClassify nodes and attach legends, annotations and group outlines.
attachAnnotations(graph: Pick<LoomGraph, 'on' | 'onFrame'>, host: HTMLElement, index: TaxonomyIndex, options?: AnnotationOptions): GraphAnnotationsThe host should cover the canvas in the same CSS-pixel coordinate space.
Returned methods (3)
destroy(): voidsetIndex(index: TaxonomyIndex): voidsetOptions(options: Partial<AnnotationOptions>): void
compileTaxonomies<N extends GraphNode, E extends GraphLink>(data: GraphData<N, E>, { taxonomies, language }: TaxonomyConfig<N, E>): TaxonomyIndexCompile once per dataset or definition change. Graph data stays immutable.
Returned methods (6)
describe(id: string): NodeDescription | undefinedlaneBy(taxonomy: string): (node: GraphNode) => stringlegend(taxonomy: string): readonly TaxonGroup[]nodeIndex(id: string): number | undefinedprimary(id: string, taxonomy: string): TaxonGroup | undefinedtooltip(id: string): TooltipContent | undefined
parseTaxonomy(json: string): TaxonomyDefinitionRead the declarative subset used by the studio's configuration editor.
scopeTaxonomies(source: TaxonomyIndex, nodes: readonly GraphNode[]): TaxonomyIndexKeep the source classification and language, with member indices in a visible subgraph's order.
Returned methods (6)
describe(id: string): NodeDescription | undefinedlaneBy(taxonomy: string): (node: GraphNode) => stringlegend(taxonomy: string): readonly TaxonGroup[]nodeIndex(id: string): number | undefinedprimary(id: string, taxonomy: string): TaxonGroup | undefinedtooltip(id: string): TooltipContent | undefined
Types
AnnotationOptions
interface AnnotationOptions {
/** Taxonomy id to all its groups, or an explicit list of term ids. */
bubbles?: Readonly<Record<string, true | readonly string[]>>;
/** Hide every boundary and its canvas hit area while retaining per-taxonomy choices. Defaults to true. */
bubblesVisible?: boolean;
/** Label visible group boundaries at their upper edge. Labels can open the group. */
bubbleLabels?: boolean;
padding?: number;
laneTaxonomy?: string;
tooltips?: boolean;
colorFor?: (group: TaxonGroup) => string;
boundary?: BoundaryStyle;
boundaryFor?: (group: TaxonGroup) => BoundaryStyle | undefined;
/** An optional sibling behind a transparent graph canvas, in the same coordinate space. */
underlay?: HTMLElement;
activeGroup?: {
taxonomy: string;
id: string;
boundary?: 'outline' | 'fade' | 'hide' | 'keep';
shape?: BoundaryStyle['shape'];
};
/** Defaults to double-click. Controls keeps the canvas available for graph gestures. */
groupGesture?: 'click' | 'double-click' | 'controls';
/** Called by a lane button or the configured gesture in a visible bubble, after node picking. */
onOpenGroup?: (group: TaxonGroup) => void;
}BoundaryStyle
interface BoundaryStyle {
shape?: 'hull' | 'cloud';
/** Screen-space padding around each projected node radius. */
padding?: number;
color?: string;
fillOpacity?: number;
strokeOpacity?: number;
width?: number;
pattern?: WirePattern;
}GraphAnnotations
interface GraphAnnotations {
setOptions(options: Partial<AnnotationOptions>): void;
setIndex(index: TaxonomyIndex): void;
destroy(): void;
}GraphLanguage
interface GraphLanguage<N extends GraphNode = GraphNode> {
title?: (node: N) => string;
connections?: (count: number) => string;
tooltip?: (node: N, description: NodeDescription) => TooltipContent;
ungrouped?: string;
}Membership
type Membership = string | readonly string[] | null | undefined;NodeDescription
interface NodeDescription {
title: string;
connections: string;
groups: readonly TaxonGroup[];
}RelationGrouping
interface RelationGrouping {
relation: string;
groupEnd: 'source' | 'target';
}TaxonGroup
interface TaxonGroup extends TaxonTerm {
readonly taxonomy: string;
readonly id: string;
readonly key: string;
readonly color: string;
/** Indices in the original graph's nodes array. */
readonly members: readonly number[];
}TaxonTerm
interface TaxonTerm {
label: string;
color?: string;
shape?: NodeShape;
description?: string;
}TaxonomyConfig
interface TaxonomyConfig<N extends GraphNode = GraphNode, E extends GraphLink = GraphLink> {
taxonomies: readonly TaxonomyDefinition<N, E>[];
language?: GraphLanguage<N>;
}TaxonomyContext
interface TaxonomyContext<N extends GraphNode, E extends GraphLink> {
nodes: ReadonlyMap<string, N>;
linksFor(id: string): readonly E[];
}TaxonomyDefinition
interface TaxonomyDefinition<N extends GraphNode = GraphNode, E extends GraphLink = GraphLink> {
id: string;
label: string;
by: MembershipField<N> | RelationGrouping | ((node: N, context: TaxonomyContext<N, E>) => Membership);
/** When provided, only the listed input values contribute memberships. */
remap?: Readonly<Record<string, string | readonly string[]>>;
terms?: Readonly<Record<string, TaxonTerm>>;
}TaxonomyIndex
interface TaxonomyIndex {
readonly groups: readonly TaxonGroup[];
readonly ungrouped: string;
legend(taxonomy: string): readonly TaxonGroup[];
describe(id: string): NodeDescription | undefined;
/** First membership, shared by exclusive lane placement and marker styling. */
primary(id: string, taxonomy: string): TaxonGroup | undefined;
tooltip(id: string): TooltipContent | undefined;
/** Multi-membership nodes use their first membership for exclusive lane placement. */
laneBy(taxonomy: string): (node: GraphNode) => string;
nodeIndex(id: string): number | undefined;
}TooltipContent
interface TooltipContent {
title: string;
lines: readonly string[];
}Schemas and runtime files#
loom-core/editor.schema.jsondescribes versioned document transactions. Open the editor schemaloom-core/wire-effects.schema.jsonandloom-core/drawing-style.schema.jsondescribe drawing controls. Wire effects · Drawing styleloom-core/layout-worker.jsis the optional force-layout worker. The SQLite worker and its WASM binary ship separately underloom-core/atlas-runtime/*. Set up a streaming atlas
Read the index from code#
The same versioned JSON index powers this page and ships in the package. Look up an import, enumerate its exports, or inspect a controller’s methods. TypeScript declarations in the archive contain the full types.
import index from 'loom-core/api-index.json' with { type: 'json' }
const atlas = index.modules.find(module => module.name === 'loom-core/atlas-map')
const mount = atlas.exports.find(item => item.name === 'mountAtlasMap')
console.log(mount.methods.find(method => method.name === 'setLayoutSpeed'))An assistant can retrieve individual Markdown chapters from the documentation index. The tool-host example shows how to combine API discovery with reads and writes against a particular graph. Documentation index · Build an AI graph tool