This page describes design & (Logseq side) development practices for the plugin system.
This page is a work in progress. Contributions are welcome.
@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.
To define a service, you need to:
Define the service register in Logseq, in src/main/logseq/api.cljs
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:
Implement the call-service! logic in Logseq, and invoke the service call in Logseq
Implement the service hook logic in libs/src/modules, which handles / replies the service calls (3.) from Logseq