Skip to main content
A plugin imports the SDK and nothing else from the editor.

The plugin entry

activate may be async. The editor waits for it before running the command or showing the panel that activated the plugin.

The context

Everything that registers something returns a disposable. Pass it to context.subscriptions.add(...).

Services

From @nanoforge-dev/editor-sdk/ui:

Observables

Values that change are Observables: get() reads, subscribe(listener) listens and returns an unsubscribe function. In Svelte, read one as a store with $.
observe calls the listener at once and on every change, and returns a disposable.

Disposables and events

  • DisposableStore: holds disposables and disposes them together. context.subscriptions is one.
  • toDisposable(fn): makes a disposable of a function.
  • Emitter<T>: an event source. emitter.event(listener) subscribes and returns a disposable; emitter.fire(value) notifies.

Calling the editor’s server

The server speaks typed contracts. The SDK exports those a plugin may need.
Errors are RpcErrors with a code (NOT_FOUND, FORBIDDEN, UNAVAILABLE…). A hosted editor refuses with FORBIDDEN what only a local editor can do.

Server entries

A plugin with entry.server runs code in the editor’s server (Bun), for what a browser cannot do. It implements a contract in its own namespace, plugin.<name>, which its client entry then calls.
The server context has name, manifest, subscriptions, logger, namespace and implement(contract, implementation). Inputs and outputs are checked against the contract’s schemas.
Server entries are less finished than the rest. The plugin build does not handle them: a server entry must not import the SDK (those imports only work in the editor’s page), and must bundle what it imports (zod here) or be built apart with a bundler targeting Bun, then shipped in the plugin’s folder.
A server entry runs with the rights of the editor’s server. It starts when the plugin is installed and stops when it is uninstalled. A project plugin’s server entry never runs in a hosted editor.

Dialogs

Mount a Svelte component from a command, and unmount it when it closes. The kit’s Dialog handles focus and the overlay.