Type Alias LibraryContext

LibraryContext: {
    local: Library;
    connected: Library[];
    availableLibraries(): Promise<LibrarySummary[]>;
    connectLibrary(libraryId: string): Promise<Library>;
}

Represents the context of Penpot libraries, including both local and connected libraries. This type contains references to the local library and an array of connected libraries.

Type declaration

  • Readonlylocal: Library

    The local library in the Penpot context.

    const localLibrary = libraryContext.local;
    
  • Readonlyconnected: Library[]

    An array of connected libraries in the Penpot context.

    const connectedLibraries = libraryContext.connected;
    
  • availableLibraries:function
    • Retrieves a summary of available libraries that can be connected to.

      Returns Promise<LibrarySummary[]>

      Returns a promise that resolves to an array of LibrarySummary objects representing available libraries.

      const availableLibraries = await libraryContext.availableLibraries();
      
  • connectLibrary:function
    • Connects to a specific library identified by its ID.

      Parameters

      • libraryId: string

        The ID of the library to connect to.

      Returns Promise<Library>

      Returns a promise that resolves to the Library object representing the connected library.

      const connectedLibrary = await libraryContext.connectLibrary('library-id');