@dxos/app-graph - v0.16.0
    Preparing search index...

    Class GraphBuilder

    The generic expansion engine specialized to the app vocabulary: app nodes and relations over an Graph.ExpandableGraph, extensions carrying a UrlBinding, and connector-produced nodes stamped with their URL segment as they enter the graph.

    Hierarchy

    Index

    Constructors

    Properties

    _collectedAskKey?: string
    _collectPromise: Promise<void>
    _collectScheduled: boolean
    _decorateNode: (
        node: NodeArg,
        extension?: Readonly<
            {
                connector?: Connector<
                    Readonly<
                        {
                            cacheable?: string[];
                            data: any;
                            id: string;
                            properties: Readonly<Record<string, any>>;
                            type: string;
                        },
                    >,
                    NodeArg<any, Record<string, any>>,
                >;
                id: string;
                meta?: UrlBinding;
                position?: number;
                relation?: RelationInput;
            },
        >,
    ) => NodeArg
    _detached: Map<string, Map<string, Detached>>

    By node, what each relation torn down by release wrote and still holds in the store; its next expansion diffs against it, or the outputs that stayed would never be removed.

    _expansions: Map<string, Set<string>>

    Expanded connector keys, by the node they belong to. Nested rather than flat: removal untracks a node's expansions, and a flat set makes that a scan of every expansion in the graph per removed node.

    _extensions: Writable<
        Record<
            string,
            Readonly<
                {
                    connector?: Connector<
                        Readonly<
                            {
                                cacheable?: string[];
                                data: any;
                                id: string;
                                properties: Readonly<Record<string, any>>;
                                type: string;
                            },
                        >,
                        NodeArg<any, Record<string, any>>,
                    >;
                    id: string;
                    meta?: UrlBinding;
                    position?: number;
                    relation?: RelationInput;
                },
            >,
        >,
    >
    _flushed: Map<string, Flushed<NodeArg<any, Record<string, any>>>>

    What each connector key last wrote into the store; a key without an entry has never flushed.

    _flushPromise: Promise<void>

    Resolves when the current flush completes.

    _flushScheduled: boolean

    Whether a dirty-flush task is already scheduled.

    _inline: Inline<NodeArg<any, Record<string, any>>>
    _registry: AtomRegistry
    _relationKey: (relation: undefined | RelationInput) => string
    _retentions: readonly Retention<string>[]
    _store: Store<
        Readonly<
            {
                cacheable?: string[];
                data: any;
                id: string;
                properties: Readonly<Record<string, any>>;
                type: string;
            },
        >,
        NodeArg<any, Record<string, any>>,
        ExpandableGraph,
    >
    _tracker: ConnectorTracker<ConnectorEntry<NodeArg<any, Record<string, any>>>[]>

    The expanded connectors; a dirty one is read only when flushed.

    _unchanged: (
        prev: readonly NodeArg<any, Record<string, any>>[],
        next: readonly NodeArg<any, Record<string, any>>[],
    ) => boolean
    _unsubscribeRetention?: CleanupFn
    _updatePromise: Promise<void>

    Resolves when the queued update flush completes.

    _updateScheduled: boolean

    Whether a flush of updates to connectors already in the store is queued.

    "[OwnerId]": {
        finalizer: FinalizationRegistry<() => void>;
        registry: AtomRegistry;
    }

    Type declaration

    • Readonlyfinalizer: FinalizationRegistry<() => void>

      Unmounts a collected owner's atoms. One per class, held in a static field: a registry the instance created would be collected with it and never run.

    • Readonlyregistry: AtomRegistry

      The registry the owner's atoms are mounted in.

    "[TypeId]": typeof TypeId
    urlGrammar: UrlGrammar

    The URL grammar (see UrlGrammar); the keys are absent when URLs are not in play.

    Accessors

    • get extensions(): Atom<
          Record<
              string,
              Readonly<
                  {
                      connector?: Connector<Node, Arg>;
                      id: string;
                      meta?: Meta;
                      position?: number;
                      relation?: Rel;
                  },
              >,
          >,
      >

      Returns Atom<
          Record<
              string,
              Readonly<
                  {
                      connector?: Connector<Node, Arg>;
                      id: string;
                      meta?: Meta;
                      position?: number;
                      relation?: Rel;
                  },
              >,
          >,
      >

    • get graph(): G

      Returns G

    Methods

    • Every inline descendant of node, at every depth.

      Parameters

      Returns NodeArg<any, Record<string, any>>[]

    • Apply a set of node changes for a single connector key.

      Parameters

      • key: string
      • nodes: NodeArg<any, Record<string, any>>[]

      Returns void

    • Returns void

    • Returns void

    • Returns Iterable<ConnectorState>

    • Keeps what key wrote that survives released, for its next expansion to diff against.

      Parameters

      • key: string
      • released: ReadonlySet<string>

      Returns void

    • Parameters

      • id: string
      • relation: string

      Returns void

    • Reads each selected dirty connector, then applies whatever changed, until none is left: applying one key's output can dirty another, such as a key whose node it rewrote. The budget covers the reads, which are most of the cost: a key the budget does not reach stays dirty and unread.

      Parameters

      • Optionalselect: (key: string) => boolean
      • Optionalbudget: FrameBudget

      Returns void

    • Drops the expansion, the tracking and the flushed state of key; reading its relation re-expands it.

      Parameters

      • key: string

      Returns void

    • What an update flush may spend in the current frame; unlimited by default.

      Returns undefined | FrameBudget

    • A relation of a node was read for the first time; track every connector declared for it. Override to expand additional relations alongside the requested one.

      Parameters

      • id: string
      • relation: string

      Returns void

    • A relation is being torn down by release: drop its expansion so the next read expands it again. Override to unwind whatever expansion bookkeeping the layer keeps.

      Parameters

      • target: { id: string; relation: string }

      Returns void

    • Parameters

      • id: string

      Returns void

    • Parameters

      • ids: readonly string[]

      Returns void

    • Reads a connector and returns its output if it differs from what was last flushed; peek leaves it dirty.

      Parameters

      • key: string
      • Optionalpeek: boolean

      Returns undefined | NodeArg<any, Record<string, any>>[]

    • Qualify a node argument's id against its parent, recursively through its inline descendants.

      Parameters

      Returns NodeArg

    • Every node the connectors declared for key's relation produce, tagged with its extension.

      Parameters

      • get: AtomContext
      • key: string

      Returns ConnectorEntry<NodeArg<any, Record<string, any>>>[]

    • Hand flushes to the scheduler so a large expansion yields to the main thread.

      Parameters

      • callback: () => void

      Returns Promise<void>

    • An update to output already in the store flushes on a microtask, so an edit renders in the frame it was made, until the frame's budget runs out; the rest, and a connector's first output, wait for GraphBuilder._schedule.

      Parameters

      • update: boolean

      Returns void

    • Read the currently registered extensions synchronously.

      Returns Record<
          string,
          Readonly<
              {
                  connector?: Connector<
                      Readonly<
                          {
                              cacheable?: string[];
                              data: any;
                              id: string;
                              properties: Readonly<Record<string, any>>;
                              type: string;
                          },
                      >,
                      NodeArg<any, Record<string, any>>,
                  >;
                  id: string;
                  meta?: UrlBinding;
                  position?: number;
                  relation?: RelationInput;
              },
          >,
      >

    • Returns unknown