plugin-system.md 1.1 KB

Description

This page describes design & (Logseq side) development practices for the plugin system.

This page is a work in progress. Contributions are welcome.

Basic concepts

@logseq/libs are the dependencies for the plugin sandbox environment side. It should be imported by the plugin. Refer plugin dev documents for detail.

The entry point of Logseq APIs in ClojureScript is src/main/logseq/api.cljs.

Then they will be exposed to plugin sandbox environment in libs/src/LSPlugin.user.ts. The Plugin -> Logseq communication is done via _execCallableAPI or _execCallableAPIAsync in libs.

Service

To define a service, you need to:

  1. Define the service register in Logseq, in src/main/logseq/api.cljs

  2. Define the service register in plugin sandbox environment, in libs/src/LSPlugin.user.ts

Then a plugin can register the service. Next, we want to call the registered service from Logseq:

  1. Implement the call-service! logic in Logseq, and invoke the service call in Logseq

  2. Implement the service hook logic in libs/src/modules, which handles / replies the service calls (3.) from Logseq