Update readme.md
This commit is contained in:
commit
1d436da13c
62
readme.md
Normal file
62
readme.md
Normal file
|
@ -0,0 +1,62 @@
|
|||
# L'Math Plugin API
|
||||
Hello, and welcome to the "beautiful" (horrible) documentation of L'Math's WIP plugin API.
|
||||
The purpose of this API is to allow users (...nerds) extend and enhance the software.
|
||||
|
||||
## Basics
|
||||
Just like L'Math itself, user-created plugins are written in **JavaScript**. Feel free to use any languages that transpile to ES6 compliant vanilla JS. Basic node.js features can be used, but the developer will not provide any support whatsoever outside the provided API.
|
||||
|
||||
Plugins are stored and loaded from the data folder
|
||||
* `%APPDATA%\LMath\plugins` on Windows
|
||||
* `~/Library/Application Support/LMath/plugins` on macOS
|
||||
* `~/.local/share/LMath/plugins` on GNU/Linux
|
||||
|
||||
The plugin api was introduced in version **r1.7**, so, you won't find the plugins folder if you haven't updated.
|
||||
|
||||
Plugins have to be installed in the following fashion:
|
||||
* `plugins/`
|
||||
* `plugin-id`
|
||||
* `plugin.json` - the metadata file
|
||||
* `...` - any other files
|
||||
* `another-plugin-id`
|
||||
* `plugin.json`
|
||||
* `...`
|
||||
|
||||
Every plugin is its own folder, **named with the plugin's id** defined in the **plugin.json** file.
|
||||
|
||||
## plugin.json
|
||||
The **plugin.json** file is the **metadata file**.
|
||||
The main purpose of the file is to act as an information source.
|
||||
This file contains information about the plugin, including the id, version, author and modules to be loaded.
|
||||
The plugin.json file has similarities with a typical package.json file, but it's not to be confused with one.
|
||||
L'Math reads and interprets plugin.json files in its own way.
|
||||
|
||||
### Example plugin.json
|
||||
```json
|
||||
{
|
||||
"id": "test-plugin",
|
||||
"name": "Test plugin 123",
|
||||
"description": "Just a test plugin.",
|
||||
"author": "Roni Lehto",
|
||||
"modules": [
|
||||
{
|
||||
"type": "backend",
|
||||
"file": "plugin.js"
|
||||
},
|
||||
{
|
||||
"type": "frontend",
|
||||
"file": "front.js"
|
||||
}
|
||||
],
|
||||
"pluginVersion": "1.0",
|
||||
"requiredVersion": "r1.7"
|
||||
}
|
||||
```
|
||||
|
||||
The `id` field **has to equal to the folder name**, otherwise the plugin will not be loaded.
|
||||
If the plugin.json file doesn't exist, the folder will be ignored.
|
||||
|
||||
## Backend and frontend
|
||||
L'Math consists of two parts: the node.js backend and the Electron frontend.
|
||||
Even though L'Math isn't sandboxed and node.js integration is allowed on the frontend,
|
||||
it is highly recommended to use the messaging channel provided by the plugin API.
|
||||
The plugin api uses the ipc messaging channel, and its sole purpose is to enable communicate between the two processes.
|
Loading…
Reference in New Issue
Block a user