Options
All
  • Public
  • Public/Protected
  • All
Menu

@visdesignlab/trrack

Index

Type aliases

ActionFunction

ActionFunction<T, Args>: (state: T, ...args: Args) => void
param

Application state

Type parameters

  • T

    Type of application state

  • Args: any[]

    Represents the types for the arguments

Type declaration

    • (state: T, ...args: Args): void
    • Parameters

      • state: T
      • Rest ...args: Args

      Returns void

ActionObject

ActionObject<T, S, Args>: { saveStateMode: (mode: ActionSaveStateMode) => ActionObject<T, S, Args>; setActionType: (actionType: ActionType) => ActionObject<T, S, Args>; setEventType: (eventType: S) => ActionObject<T, S, Args>; setLabel: (label: string) => ActionObject<T, S, Args>; setMetaData: (metadata: Meta) => ActionObject<T, S, Args> } & (...args: Args) => ApplyObject<T, S>

Type parameters

  • T

  • S

  • Args: any[]

ActionReturnType

ActionReturnType<T, S>: { actionType: ActionType; eventType: S; label: string; meta: Meta; state: T; stateSaveMode: ActionSaveStateMode }

Type parameters

  • T

  • S

Type declaration

ActionSaveStateMode

ActionSaveStateMode: "Complete" | "Diff"

Complete for saving the entire state

Diff for using diff algorithm

ActionType

ActionType: "Ephemeral" | "Regular"

Ephemeral for actions which are shortlived. e.g. hovering

Regular for all you other actions.

Annotation

Annotation: BaseArtifact & { annotation: string }

ApplyObject

ApplyObject<T, S>: { apply: (state: T, label?: undefined | string) => ActionReturnType<T, S> }

Type parameters

  • T

  • S

Type declaration

Artifact

Artifact<A>: BaseArtifact & { artifact: A }

Type parameters

  • A

Artifacts

Artifacts<A>: { annotations: Annotation[]; customArtifacts: Artifact<A>[] }

Type parameters

  • A

Type declaration

BaseArtifact

BaseArtifact: { timestamp: number }

Type declaration

  • timestamp: number

ChangeType

ChangeType: "CurrentChanged" | "NodeAdded" | "Any"

CurrentNode

CurrentNode<S, A>: ProvenanceNode<S, A>

Type parameters

  • S

  • A

Deserializer

Deserializer<T>: (obj: JsonValue) => T

Type parameters

  • T

Type declaration

DiffExport

DiffExport<L, R>: Diff<L, R>

Type parameters

  • L

  • R = L

GlobalObserver

GlobalObserver<S, A>: (graph?: ProvenanceGraph<S, A>, changeType?: ChangeType) => void

Type parameters

  • S

  • A

Type declaration

JsonValue

JsonValue: {}

Type declaration

  • [key: string]: JsonValue | number | string | unknown[]

Meta

Meta: {}

Type declaration

  • [key: string]: any

NodeID

NodeID: string

NodeMetadata

NodeMetadata<S>: { createdOn?: undefined | number; eventType: S | "Root" } & Meta

Type parameters

  • S

Nodes

Nodes<S, A>: {}

Type parameters

  • S

  • A

Type declaration

ObserverEffect

ObserverEffect<P>: (state?: P, previousState?: P) => void

Type parameters

  • P

Type declaration

    • (state?: P, previousState?: P): void
    • Parameters

      • Optional state: P
      • Optional previousState: P

      Returns void

ObserverExpression

ObserverExpression<T, P>: (state: T) => P

Type parameters

  • T

  • P

Type declaration

    • (state: T): P
    • Parameters

      • state: T

      Returns P

Provenance

Provenance<T, S, A>: { addAnnotation: (annotation: string, id?: NodeID) => void; addArtifact: (artifact: A, id?: NodeID) => void; addGlobalObserver: (observer: GlobalObserver<S, A>) => void; addObserver: <P>(expression: ObserverExpression<T, P>, effect: ObserverEffect<P>) => void; apply: (action: ApplyObject<T, S>, label?: undefined | string) => void; config: ProvenanceOpts<T>; current: ProvenanceNode<S, A>; done: () => void; exportProvenanceGraph: () => string; exportState: (partial?: undefined | false | true) => string; getAllAnnotation: (id?: NodeID) => Annotation[]; getAllArtifacts: (id?: NodeID) => Artifact<A>[]; getAllBookmarks: () => NodeID[]; getBookmark: (id: NodeID) => boolean; getLatestAnnotation: (id?: NodeID) => Annotation | null; getLatestArtifact: (id?: NodeID) => Artifact<A> | null; getState: (node: ProvenanceNode<S, A> | NodeID) => T; goBackOneStep: () => void; goBackToNonEphemeral: () => void; goForwardOneStep: (to?: "latest" | "oldest") => void; goForwardToNonEphemeral: (to?: "latest" | "oldest") => void; goToNode: (id: NodeID) => void; graph: ProvenanceGraph<S, A>; importProvenanceGraph: (graph: string | ProvenanceGraph<S, A>) => void; importState: (state: string | JsonValue) => void; redo: (to?: "latest" | "oldest") => void; redoNonEphemeral: (to?: "latest" | "oldest") => void; reset: () => void; root: RootNode<S>; setBookmark: (id: NodeID, bookmark: boolean) => void; state: T; undo: () => void; undoNonEphemeral: () => void; usingDefaultSerializer: boolean }

Type parameters

  • T

  • S = void

  • A = void

Type declaration

  • addAnnotation: (annotation: string, id?: NodeID) => void

    Adds an artifact to the given node

    param

    Artifact to be added

    param

    nodeID for which to add the artifact too. Defaults to current node.

      • (annotation: string, id?: NodeID): void
      • Parameters

        • annotation: string
        • Optional id: NodeID

        Returns void

  • addArtifact: (artifact: A, id?: NodeID) => void

    Adds an artifact to the given node

    param

    Artifact to be added

    param

    nodeID for which to add the artifact too. Defaults to current node.

      • (artifact: A, id?: NodeID): void
      • Parameters

        • artifact: A
        • Optional id: NodeID

        Returns void

  • addGlobalObserver: (observer: GlobalObserver<S, A>) => void

    Observer function which is called whenever any part of the state changes. Also called when an artifact changes.

    param

    Function which is called when the observer is triggered.

  • addObserver: <P>(expression: ObserverExpression<T, P>, effect: ObserverEffect<P>) => void

    Adds an observer to the key which is returned from the ObserverExpression function. Second parameter is a subscriber function which is called when the observer is triggered For example { selected: 'A', position: { A: 10 B: 5 C: 13 } }

    And you wanted an observer which was called whenever a node is selected, you would have addObserver((state) => state.selected, () => {doSomething}).

    If you wanted an observer strictly for when the position of A changed, you would have addObserver((state) => state.position.A, () => {doSomething}).

  • apply: (action: ApplyObject<T, S>, label?: undefined | string) => void

    Applies the given action. Creates a new node based on the action, sets that node to current, and calls observers accordingly.

    param

    applies an action

      • (action: ApplyObject<T, S>, label?: undefined | string): void
      • Parameters

        • action: ApplyObject<T, S>
        • Optional label: undefined | string

        Returns void

  • config: ProvenanceOpts<T>
  • current: ProvenanceNode<S, A>

    Returns the current Provenance Node object

  • done: () => void

    Function to call when finished setting up observers. Allows for url state sharing easily.

      • (): void
      • Returns void

  • exportProvenanceGraph: () => string

    Exports the entire provenance graph in JSON form. Not compressed.

      • (): string
      • Returns string

  • exportState: (partial?: undefined | false | true) => string

    Exports the current nodes state. Returns a compressed string representing the JSON form of the current state

      • (partial?: undefined | false | true): string
      • Parameters

        • Optional partial: undefined | false | true

        Returns string

  • getAllAnnotation: (id?: NodeID) => Annotation[]

    Returns a list of all annotations for the given node

    param

    nodeID which we are retrieving annotations from. Defaults to current node.

  • getAllArtifacts: (id?: NodeID) => Artifact<A>[]

    Returns a list of all Artifacts for the given node

    param

    nodeID which we are retrieving artifacts from. Defaults to current node.

  • getAllBookmarks: () => NodeID[]

    Gets the bookmark of the node with the given ID.

    param

    NodeID for the bookmark we are retrieving

  • getBookmark: (id: NodeID) => boolean

    Gets the bookmark of the node with the given ID.

    param

    NodeID for the bookmark we are retrieving

      • Parameters

        Returns boolean

  • getLatestAnnotation: (id?: NodeID) => Annotation | null

    Returns the most recent Artifact for the given node

    param

    nodeID which we are retrieving an annotations from. Defaults to current node.

  • getLatestArtifact: (id?: NodeID) => Artifact<A> | null

    Returns the most recent Artifact for the given node

    param

    nodeID which we are retrieving an artifact from. Defaults to current node.

  • getState: (node: ProvenanceNode<S, A> | NodeID) => T

    Returns the state for the designated node.

    param

    ProvenanceNode object for which we are retrieving the state

  • goBackOneStep: () => void

    Goes one step backwards in the provenance graph. Equivalent to 'undo' Calls any observers for which their associated state has changed with the new node. Also calls the global observer if any part of the state changed.

      • (): void
      • Returns void

  • goBackToNonEphemeral: () => void

    Equivalent to undo, but while ignoring ephemeral nodes. Goes one step backwards in the provenance graph, not including ephemeral nodes. Calls any observers for which their associated state has changed with the new node. Also calls the global observer if any part of the state changed.

      • (): void
      • Returns void

  • goForwardOneStep: (to?: "latest" | "oldest") => void

    Equivalent to redo Goes forward one step in the provenance graph. If there are two or more chld nodes, you may specify to go to the most recent or the oldest. Calls any observers for which their associated state has changed with the new node. Also calls the global observer if any part of the state changed.

    param

    specify whether to jump to the latest or the oldest child. Defaults to oldest.

      • (to?: "latest" | "oldest"): void
      • Parameters

        • Optional to: "latest" | "oldest"

        Returns void

  • goForwardToNonEphemeral: (to?: "latest" | "oldest") => void

    Equivalent to redo, but while ignoring ephemeral nodes. Goes forward one step in the provenance graph, not including ephemeral nodes. If there are two or more chld nodes, you may specify to go to the most recent or the oldest. Calls any observers for which their associated state has changed with the new node. Also calls the global observer if any part of the state changed.

    param

    specify whether to jump to the latest or the oldest child. Defaults to oldest.

      • (to?: "latest" | "oldest"): void
      • Parameters

        • Optional to: "latest" | "oldest"

        Returns void

  • goToNode: (id: NodeID) => void

    Jumps to the node in the provenance graph with the given id. Calls any observers for which their associated state has changed with the new node. Also calls the global observer if any part of the state changed.

    param

    NodeID of the node in the ProvenanceGraph to jump to.

  • graph: ProvenanceGraph<S, A>

    Returns the ProvenanceGraph object

  • importProvenanceGraph: (graph: string | ProvenanceGraph<S, A>) => void

    Imports an entire, non compressed provenance graph in JSON form.

    Replaces the current provenance graph with the new one.

    param

    JSON string that represents the graph, or a pre built provenance graph object.

  • importState: (state: string | JsonValue) => void

    Imports the given state. Decompresses the given string and creates a new node with that state.

    param

    Decompressed string recieved from exportState function to import.

  • redo: (to?: "latest" | "oldest") => void

    Goes forward one step in the provenance graph. If there are two or more chld nodes, you may specify to go to the most recent or the oldest. Calls any observers for which their associated state has changed with the new node. Also calls the global observer if any part of the state changed.

    param

    specify whether to jump to the latest or the oldest child. Defaults to oldest.

      • (to?: "latest" | "oldest"): void
      • Parameters

        • Optional to: "latest" | "oldest"

        Returns void

  • redoNonEphemeral: (to?: "latest" | "oldest") => void

    Equivalent to redo, but while ignoring ephemeral nodes. Goes forward one step in the provenance graph, not including ephemeral nodes. If there are two or more chld nodes, you may specify to go to the most recent or the oldest. Calls any observers for which their associated state has changed with the new node. Also calls the global observer if any part of the state changed.

    param

    specify whether to jump to the latest or the oldest child. Defaults to oldest.

      • (to?: "latest" | "oldest"): void
      • Parameters

        • Optional to: "latest" | "oldest"

        Returns void

  • reset: () => void

    Returns to the root node.

      • (): void
      • Returns void

  • root: RootNode<S>

    Returns the Root Node object

  • setBookmark: (id: NodeID, bookmark: boolean) => void

    Sets the bookmark of the node with the given ID. the bookmark is set to true or false, equivalent on the second parameter.

    param

    NodeID for which we are editing

    param

    boolean value for whether or not the bookmark is set.

      • (id: NodeID, bookmark: boolean): void
      • Parameters

        • id: NodeID
        • bookmark: boolean

        Returns void

  • state: T

    Returns the state type

  • undo: () => void

    Goes one step backwards in the provenance graph. Calls any observers for which their associated state has changed with the new node. Also calls the global observer if any part of the state changed.

      • (): void
      • Returns void

  • undoNonEphemeral: () => void

    Equivalent to undo, but while ignoring ephemeral nodes. Goes one step backwards in the provenance graph, not including ephemeral nodes. Calls any observers for which their associated state has changed with the new node. Also calls the global observer if any part of the state changed.

      • (): void
      • Returns void

  • usingDefaultSerializer: boolean

    Returns if using default serializer/deserializer

ProvenanceNode

ProvenanceNode<S, A>: RootNode<S> | StateNode<S, A> | DiffNode<S, A>

Type parameters

  • S

  • A

ProvenanceOpts

ProvenanceOpts<T>: { _deserializer: Deserializer<T> | undefined; _serializer: Serializer<T> | undefined; firebaseConfig: any; loadFromUrl: boolean }

Type parameters

  • T

Type declaration

  • _deserializer: Deserializer<T> | undefined
  • _serializer: Serializer<T> | undefined
  • firebaseConfig: any
  • loadFromUrl: boolean

Serializer

Serializer<T>: (obj: T) => JsonValue

Type parameters

  • T

Type declaration

Variables

Const PROVSTATEKEY

PROVSTATEKEY: "provState" = "provState"

Const applyActionFunction

applyActionFunction: (Anonymous function) = action(<T, S, A>(_graph: ProvenanceGraph<S, A>,actionFn: ApplyObject<T, S>,currentState: T,// eslint-disable-next-line no-unused-varsserialize: Serializer<T>,customLabel?: string,) => {const graph = _graph;const { current: currentId } = graph;const currentNode = graph.nodes[currentId];let previousState: JsonValue | null = null;let previousStateID: NodeID | null = null;if (isDiffNode(currentNode)) {previousState = getState(graph, graph.nodes[currentNode.lastStateNode]);previousStateID = currentNode.lastStateNode;} else {previousState = getState(graph, currentNode);previousStateID = currentNode.id;}let saveDiff = isChildNode(currentNode);const { state, stateSaveMode, actionType, label, eventType, meta } = actionFn.apply(currentState,customLabel,);const parentId = graph.current;const serializedState = serialize(state);const diffs = differ(previousState, serializedState) || [];if (saveDiff && Object.keys(previousState).length / 2 < diffs.length) {saveDiff = false;}saveDiff = saveDiff && stateSaveMode === 'Diff';const newNode = saveDiff? createNewDiffNode<S, A>(parentId,label,diffs,actionType,previousStateID,eventType,meta,): createNewStateNode<S, A>(parentId, serializedState, label, actionType, eventType, meta);graph.nodes[newNode.id] = newNode;graph.nodes[currentId].children.push(newNode.id);graph.current = newNode.id;return graph.nodes[graph.current];// End},)

Const goToNode

goToNode: (Anonymous function) = action(<S, A>(graph: ProvenanceGraph<S, A>, id: NodeID) => {const newCurrentNode = graph.nodes[id];if (!newCurrentNode) throw new Error(`Node with id: ${id} does not exist`);graph.current = newCurrentNode.id;})

Const importState

importState: (Anonymous function) = action(<S, A>(graph: ProvenanceGraph<S, A>, importedState: JsonValue) => {const newNode = createNewStateNode(graph.current,importedState,'Import','Regular',(null as unknown) as S,{},);graph.nodes[newNode.id] = newNode;graph.current = newNode.id;},)

Functions

createAction

  • Type parameters

    • T

      State of the application

    • Args: unknown[] = unknown[]

    • S = void

      Represents the given event types in your application. Event types are used to differentiate between different actions that create nodes.

    Parameters

    • func: ActionFunction<T, Args>

      Defines the function which will be executed on provenance apply

    Returns ActionObject<T, S, Args>

createNewDiffNode

createNewStateNode

createProvenanceGraph

createStore

deepCopy

  • deepCopy<T>(target: T): T

defaultDeserializer

defaultSerializer

differ

  • differ<T>(obj1: T, obj2: T): undefined | Diff<T, T>[]
  • Type parameters

    • T

    Parameters

    • obj1: T
    • obj2: T

    Returns undefined | Diff<T, T>[]

generateTimeStamp

  • generateTimeStamp(): number

generateUUID

  • generateUUID(): string

getState

  • * Retrieve the state of a node.

    template

    Represents the given state of an application as defined in initProvenance.

    Type parameters

    • S

      Represents the given event types in your application. Event types are used to differentiate between different actions that create nodes.

    • A

      Represents the given "extra" type for storing metadata. Extra is a way to store customized metadata.

    Parameters

    Returns JsonValue

initProvenance

  • Type parameters

    • T

      Represents the given state of an application as defined in initProvenance.

    • S

      Represents the given event types in your application. Event types are used to differentiate between different actions that create nodes.

    • A = void

      Represents the given "extra" type for storing metadata. Extra is a way to store customized metadata.

    Parameters

    • initialState: T
    • Default value _opts: Partial<ProvenanceOpts<T>> = {}

    Returns Provenance<T, S, A>

initializeFirebase

  • initializeFirebase(config: any): { app: App; config: any; db: Database }

isChildNode

  • isChildNode<S, A>(node: ProvenanceNode<S, A>): node is DiffNode<S, A> | StateNode<S, A>
  • Function for checking if a node is a child node.

    template

    Represents the given state of an application as defined in initProvenance.

    Type parameters

    • S

      Represents the given event types in your application. Event types are used to differentiate between different actions that create nodes.

    • A

      Represents the given "extra" type for storing metadata. Extra is a way to store customized metadata.

    Parameters

    Returns node is DiffNode<S, A> | StateNode<S, A>

isDiffNode

  • isDiffNode<S, A>(node: ProvenanceNode<S, A>): node is DiffNode<S, A>
  • Function for checking if a node is a diff node.

    template

    Represents the given state of an application as defined in initProvenance.

    Type parameters

    • S

      Represents the given event types in your application. Event types are used to differentiate between different actions that create nodes.

    • A

      Represents the given "extra" type for storing metadata. Extra is a way to store customized metadata.

    Parameters

    Returns node is DiffNode<S, A>

isRootNode

  • Function for checking if a node is the root node.

    template

    Represents the given state of an application as defined in initProvenance.

    Type parameters

    • S

      Represents the given event types in your application. Event types are used to differentiate between different actions that create nodes.

    • A

      Represents the given "extra" type for storing metadata. Extra is a way to store customized metadata.

    Parameters

    Returns node is RootNode<S>

isStateNode

  • isStateNode<S, A>(node: ProvenanceNode<S, A>): node is StateNode<S, A>
  • Function for checking if a node is a state node.

    template

    Represents the given state of an application as defined in initProvenance.

    Type parameters

    • S

      Represents the given event types in your application. Event types are used to differentiate between different actions that create nodes.

    • A

      Represents the given "extra" type for storing metadata. Extra is a way to store customized metadata.

    Parameters

    Returns node is StateNode<S, A>

logToFirebase

  • logToFirebase(rtd: Database): (Anonymous function)

Generated using TypeDoc