Function types for each command available on the papi. Each extension can extend this interface to add commands that it registers on the papi with papi.commands.registerCommand.

Note: Command names must consist of two strings separated by at least one period. We recommend one period and lower camel case in case we expand the api in the future to allow dot notation.

An extension can extend this interface to add types for the commands it registers by adding the following to its .d.ts file:

declare module 'papi-shared-types' {
export interface CommandHandlers {
'myExtension.myCommand1': (foo: string, bar: number) => string;
'myExtension.myCommand2': (foo: string) => Promise<void>;
}
}
interface CommandHandlers {
    "platform.about": () => Promise<void>;
    "platform.getOSPlatform": () => Promise<undefined | string>;
    "platform.isFullScreen": () => Promise<boolean>;
    "platform.openDeveloperDocumentationUrl": () => Promise<void>;
    "platform.openProjectSettings": (webViewId: string) => Promise<void>;
    "platform.openSettings": (webViewId?: string) => Promise<void>;
    "platform.openUserSettings": () => Promise<void>;
    "platform.openWindow": (url: string) => Promise<void>;
    "platform.quit": () => Promise<void>;
    "platform.restart": () => Promise<void>;
    "platform.restartExtensionHost": () => Promise<void>;
    "test.addMany": (...nums: number[]) => number;
    "test.echo": (message: string) => string;
    "test.echoExtensionHost": (message: string) => Promise<string>;
    "test.throwError": (message: string) => void;
    "test.throwErrorExtensionHost": (message: string) => void;
}

Properties

"platform.about": () => Promise<void>

Open a dialog that displays essential information about the application

"platform.getOSPlatform": () => Promise<undefined | string>

Get the operating system platform

"platform.isFullScreen": () => Promise<boolean>

If the browser window is in full screen

"platform.openDeveloperDocumentationUrl": () => Promise<void>

Open a browser to the platform's OpenRPC documentation

"platform.openProjectSettings": (webViewId: string) => Promise<void>

3 December 2024. Renamed to platform.openSettings

"platform.openSettings": (webViewId?: string) => Promise<void>
"platform.openUserSettings": () => Promise<void>

3 December 2024. Renamed to platform.openSettings

"platform.openWindow": (url: string) => Promise<void>

Open a link in a new browser window. Like window.open in the frontend with target='_blank' Consider using a visual indication along with this. E.g. for a menu download the https://lucide.dev/icons/external-link icon, add it to your extension's assets folder and use it like

  • "iconPathAfter": "papi-extension://<yourExtension>/assets/icons/external-link.svg". We plan to provide a common set of icons via an API in the future.

For a button that opens external urls add

  • aria-label="{localizedStrings['%ariaLabel_opensInBrowser%']}"
  • Lucide icon <ExternalLink />
"platform.quit": () => Promise<void>

Shut down the application

"platform.restart": () => Promise<void>

Restart the application

"platform.restartExtensionHost": () => Promise<void>
"test.addMany": (...nums: number[]) => number
"test.echo": (message: string) => string
"test.echoExtensionHost": (message: string) => Promise<string>
"test.throwError": (message: string) => void
"test.throwErrorExtensionHost": (message: string) => void