Interface ExtensionContext

Rokii provides the extensions with a context that contains relevant information about the current state of the application.

The context is provided every time the extension is executed.

Some of the information provided in the context includes:

  • The input term that the user has entered.
  • A function that can be called to display the results of the extension.
interface ExtensionContext {
    actions: {
        copyToClipboard: ((text: string) => Promise<void>);
        hideWindow: (() => Promise<void>);
        open: ((url: string) => Promise<void>);
        replaceTerm: ((term: string) => void);
        reveal: ((path: string) => Promise<void>);
    };
    display: ((items: Item[]) => Promise<void>);
    hide: ((id: string) => void);
    settings: Record<string, any>;
    term: string;
    update: ((id: string, item: Item) => void);
}

Properties

actions: {
    copyToClipboard: ((text: string) => Promise<void>);
    hideWindow: (() => Promise<void>);
    open: ((url: string) => Promise<void>);
    replaceTerm: ((term: string) => void);
    reveal: ((path: string) => Promise<void>);
}

Common actions that the extension can perform.

Type declaration

  • copyToClipboard: ((text: string) => Promise<void>)

    Copy the given text to the clipboard.

      • (text): Promise<void>
      • Parameters

        • text: string

        Returns Promise<void>

  • hideWindow: (() => Promise<void>)

    Hide the Rokii window.

      • (): Promise<void>
      • Returns Promise<void>

  • open: ((url: string) => Promise<void>)

    Open the given URL in the default browser.

      • (url): Promise<void>
      • Parameters

        • url: string

        Returns Promise<void>

  • replaceTerm: ((term: string) => void)

    Replace the current term with the given term.

      • (term): void
      • Parameters

        • term: string

        Returns void

  • reveal: ((path: string) => Promise<void>)

    Open the given path in the file explorer.

      • (path): Promise<void>
      • Parameters

        • path: string

        Returns Promise<void>

display: ((items: Item[]) => Promise<void>)

A function that can be called to display the results of the extension.

hide: ((id: string) => void)

Hide result from results list by id. You can use it to remove temporar results, like "loading..." placeholder

settings: Record<string, any>

An object containing the user settings for the extension.

term: string

The input term that the user has entered.

update: ((id: string, item: Item) => void)

A function that can be called to update the results of the extension.

Type declaration

    • (id, item): void
    • Parameters

      • id: string

        A unique identifier for the item.

      • item: Item

        The item that will replace the current item.

      Returns void