Skip to content

Theia Plugin Implementation

Paul Maréchal edited this page Nov 10, 2020 · 8 revisions

In this document we'll go over the basic mechanics involved for the plugin system.

Plugins are querying Theia's state via RPC and they are commonly run inside a "host process". It is a sub-process spawned by Theia's backend to run the plugin isolated from the main process. We refer to the plugin code as ext, and use main when talking about Theia-facing implementations.

The main side hooks into the diverse Theia extension apis, and forwards calls to the ext side over RPC.

You can find the Theia glue code under packages/plugin-ext/src/main, and the plugin api implementation under packages/plugin-ext/src/plugin. The main side should run in the browser context, since this is where most of the IDE state is.

The RPC interfaces are defined under packages/plugin-ext/src/common/plugin-api-rpc.ts. The ext side code will run in the "extension host process", keep this in mind as you should expect to not have access to globals or other symbols from that runtime. If you need something from Theia, it has to be fetched over RPC by querying the main side from the ext side.

You need the following elements for a given component to work:

  • A main proxy identifier
  • An ext proxy identifier
  • A main interface
  • An ext interface
  • A main implementation
  • An ext implementation

Methods to be called via RPC must start with $.

Example - Task API:

Note how the main implementation refers to the ext interface, and vice-versa.