Bläck StudioPlugin SDK v1.0.0 · API 10
Contents

Start

Building

Beyond Bläck Studio

How it runs

Sharing

Look up

The manifest

{
  "id": "word-of-the-day",
  "name": "Word of the day",
  "version": "1.0.0",
  "description": "A word to use today, every morning.",
  "author": "You",
  "apiVersion": 1,
  "main": "main.js",
  "sandboxed": false,
  "permissions": ["project:write", "network:api.example.com", "files:read", "exec:pandoc"],
  "permissionReasons": {
    "network:api.example.com": "fetch today's word from Example (api.example.com)"
  },
  "category": "writing",
  "locales": {
    "sv": { "name": "Dagens ord", "description": "Ett ord att använda i dag, varje morgon." }
  }
}
  • id: lower-case letters, digits and dashes. It's also the folder name.
  • apiVersion: the plugin API version the plugin needs. It defaults to 1. Set it to the version that added the newest feature you use:
    • 2: the dashboard and the library
    • 3: the microphone
    • 4: app.speech
    • 5: dictation drafts, pauses and microphone choice
    • 6: actions on marks
    • 7: book importers
    • 8: permissionReasons and category in the manifest. A plugin that uses only these two doesn't need version 8, because older versions of the app ignore them.
    • 9: quiet marks
    • 10: app.folder and project:folder, network:ask, app.net.streamBytes, during, addVersionHistory, project.flush and project.getProjectData
  • sandboxed: runs the plugin in a separate worker, apart from the window (see below).
  • locales: the plugin's name and description in other languages, by language code. Settings → Plugins, the plugin list and the permission questions show them in the writer's language. You choose the plugin's other strings (commands, settings, notices) yourself, using this.app.language. When the writer changes the language, Bläck Studio reloads the plugin, so onload runs again in the new language.
  • permissions: what the plugin needs beyond reading the book.
    • project:write lets the plugin change the book.
    • project:folder lets the plugin read and change every file in the open project's folder, and nothing outside it (see The project's folder). It needs "apiVersion": 10.
    • library:read lets the plugin see the writer's recent books and their series (app.library), for example to build the welcome screen's dashboard. It needs "apiVersion": 2.
    • microphone lets a plugin in the window record, with navigator.mediaDevices.getUserMedia({ audio: true }). Bläck Studio gives the page access to the microphone only while a plugin with this permission is on, and never gives it a camera. It needs "apiVersion": 3. Release the stream as soon as you're done, so the system stops showing that it's listening. With "apiVersion": 4 the plugin also gets app.speech, which turns what the writer says into text on the device itself. Nothing is sent anywhere. On a computer this uses Whisper, and Bläck Studio downloads its model once, after asking the writer. On a phone or tablet it uses the system's own recogniser, which gives you the words as they come. Call status(language) first. If it isn't ready, prepare(language) gets what's missing. Then call listen() and keep listening until stop(). onLevel reports how loud the sound is, so you can show that the plugin is hearing something. The session can also pause() and resume(). Older versions of Bläck Studio have neither of these, so check that they exist.
    • network:<host> lets the plugin reach a host. network:*.<host> also covers that host's subdomains, and network:* lets the plugin reach anywhere on the internet. It doesn't cover this computer or the network it's on (a router, a NAS). The plugin can reach those only by name, for example network:127.0.0.1.
    • files:read and files:write let the plugin use files and folders that the writer chooses for it in the system's own dialog (app.files.pickFolder, pickFile). It never gets the whole disk.
    • exec:<program> lets the plugin run that one program. The program is found by name on the PATH, gets its arguments as you give them, and runs with no shell. exec:pandoc runs Pandoc and nothing else.

Bläck Studio marks network:* and every exec: permission as reaching beyond the app, with a warning. A shell, Python or Node gets a stronger warning.

The writer is asked to allow these permissions when they turn the plugin on. If a new version asks for more, it stays off until the writer allows that too.

Running in Bläck Studio's window (without sandboxed) is also a permission the writer is asked to allow, and it's shown as unrestricted: a plugin there can do anything the window can.

  • optionalPermissions: permissions the plugin may ask for later with app.permissions.request. Use it when the writer chooses something that needs a permission (a service to send to, say), instead of asking when the plugin is turned on. It takes the same kinds as permissions, and needs "apiVersion": 5.
  • permissionReasons: why the plugin asks, by permission. Bläck Studio shows each reason to the writer when it asks them to allow the permission, with its own description of what the permission allows underneath. Say what is sent where and what for, so that your text completes the sentence "it needs to …". It can be one text, or one text per language code:

``json "permissionReasons": { "network:api.example.com": { "en": "fetch today's word from Example (api.example.com)", "sv": "hämta dagens ord från Example (api.example.com)" } } ``

Each reason belongs to a permission in permissions or optionalPermissions, and can be up to 300 characters. Bläck Studio reads it from plugin API 8 on. Older versions leave it out, so your plugin doesn't need to ask for API 8 to include it.

  • category: where Manage Plugins lists the plugin: writing, planning, welcome (the welcome screen), import-export or other. Bläck Studio reads it from plugin API 8 on, and older versions leave it out, just like permissionReasons.