@eidos.space/plugin-sdk
v0.11.0
Published
Versioned browser SDK and offline package contract for Eidos Lite file editors
Readme
Eidos Plugin SDK
Type-only API for the Plugin API 3.12 contract.
Private storage can opt into storage: { maxBytes, atomic: true } with
requires.pluginApi: "3.11.0". storage.readVersioned(key) returns bytes and an
opaque version token. Pass that token to storage.compareAndWrite(key, version,
bytes) and retry from a fresh read when applied is false. This preserves
concurrent updates from multiple Views or windows. Ordinary storage remains
available without the opt-in; atomic storage is Lite-only.
Native integrations can declare sidecar.maxOutputFrameBytes with
requires.pluginApi: "3.12.0". This limits each stdout JSONL record in UTF-8
bytes, excluding CRLF: the default is 1 MiB and the maximum is 16 MiB. Oversized
or invalid output stops the process with an explicit error; the host never
silently truncates a record. It does not change stdin or grant additional access.
Lite API 3.8 adds manifest.sidecar: { command, args? } and optional
ctx.capabilities.sidecar for standalone page and file Views. Lite discovers
an installed local program and requests native startup approval. The program
retains OS permissions outside the JavaScript file/network capability sandbox.
Closing a View detaches it; stopping, revoking, updating, leaving its Space or
quitting Lite stops the owned process. CLI Serve and mobile do not expose this
capability. See local native programs
and the API reference.
Plugins can declare i18n.defaultLocale, i18n.messages JSON paths and optional
i18n.readme Markdown paths. Use %message.key% in manifest display fields and
ctx.i18n.t("message.key", { name: "value" }) in views/actions. Subscribe with
ctx.subscriptions.add(ctx.i18n.onDidChangeLocale(render)) to update mounted UI
without clearing user state. Declare requires.pluginApi: "3.7.0"; check and pack
bundle all declared text resources in format 3. Localization requires Eidos Lite
0.29.0 or later and Plugin SDK/tools 0.9.0 or later.
Import with import type; the host injects operations. There is no runtime SDK
connection. Use matching SDK and tools versions for checking and packaging.
Lite 3.2 adds static fileTemplates (id, title, extension, view,
content) to the New File dialog. Templates reference a document View and a
matching file/open placement. UTF-8 content is limited to 256 KiB; the host
creates without overwriting and opens the selected View.
File Views with Space read permission can feature-detect ctx.capabilities.ui.resources.
listViews(relativePath) lists saved views from another Eidos file, or matching
enabled plugin Views and the built-in preview for ordinary files.
File View choices return { kind: "file", editor, name, type }; pass
editor in a file source to select that View. Use
mount(element, { kind: "eidos-view", path, tableId, viewId }) or
mount(element, { kind: "file", path }) for a host-rendered read-only panel.
Paths are relative to the bound file and stay inside the Space. Add the returned
handle to subscriptions; it exposes refresh() and dispose(). Lite supports
up to 12 panels, one level deep. Child plugins receive
ctx.presentation?.mode === "embedded" and retain independent grants.
Views have kind: "page" | "file". File views declare document for text, or combine
eidos/schema, eidos/table and eidos/config for Eidos data. Bindings contain metadata only; operations
live under ctx.capabilities. Shared services are optional when host support differs.
import type { Mount } from "@eidos.space/plugin-sdk"
const mount: Mount = async (ctx, root) => {
const document = ctx.capabilities.document
if (!document) throw new Error("Document capability required")
root.textContent = (await document.read()).text
}
export default mountDeclare the minimum plugin API required by your features: 3.0.0 for basic
View/action profiles, or 3.4.0 for backgrounds. Lite supports page/file views,
extensions, scoped filesystem, settings, private storage, network and connections.
Serve supports file views with eidos/table, notification UI and generated-file export. Check the
actual target with plugin-tools; do not assume feature parity. Themes retain
their independent data-only API 1.6.0 compatibility.
Use document edit/save/undo/redo for text working copies. Direct filesystem mutation must not bypass an existing plugin-service working copy. Workspace file access requires explicit workspace.files and writes require contribution access.
Lite API 3.1 exposes native namespace metadata under ctx.capabilities.filemeta.
Declare namespaces and optional write permission in workspace.filemeta.
filemeta.read(path, namespace) returns the complete namespace object;
filemeta.patch(path, namespace, { set?, remove? }) preserves other keys.
Writes also require contribution write access. The host uses sqlite-fs-meta.
Extensions retain activate and register through capabilities.actions/formatters.
Lite API 3.4 supports a separate background.entry and
ctx.capabilities.background in Views and action handlers:
start, stop, postMessage, request, onMessage, and requestDevice.
Startup and BLE device grants are approved by the host. Closing a View leaves
the background alive; stopping, disabling, updating or leaving the Space ends it.
See the background guide
(中文) and
the runnable counter and
BLE examples.
Plugin API 3.3 adds capabilities.hooks.register(id, handler) for declared
document.saved and file.renamed hooks. Handlers receive a versioned local
document snapshot, settings and signal, and return { text?, name? } for that
file. Declare access: "write" to return mutations. The host checks versions,
name collisions and plugin enablement, maintains Markdown links, and prevents
hook mutations from triggering hooks again. Hooks run in isolation without
filesystem, database or network capabilities; use portable JavaScript without
DOM or Node globals. Android and iOS support Markdown hooks; CLI Serve does not.
Table providers retain getItems/run with eidos.table/eidos.config/target/task/connections under
capabilities; task.declareOutputs validates output samples and establishes writable fields.
Eidos config read/write/watch use an explicit tableId and remain scoped to the
bound file (or current table) and plugin namespace. Connections are a common
capability and keep credentials in the host.
Method names describe their behavior: read returns data, list enumerates,
set replaces a value, update applies a partial change, and delete removes
an entry. watch sends invalidation notifications; document.observe also
returns an initial snapshot. Boolean queries use is, as in isConfigured.
eidos.config.write uses an expected version to protect replacement from conflicts.
table.setViewConfig replaces the saved view's plugin configuration; merge keys
that must be retained before calling it.
See the bilingual migration guide
(中文) and
API reference.
Build with pnpm --filter @eidos.space/plugin-sdk build and run test from the root.
Runtime validation and sandboxing belong to plugin-runtime, not this package.
Views can check ctx.capabilities.ui.exportFile to export generated bytes without
filesystem write access. Call it with { name: "chart.png", mimeType: "image/png",
data: pngBytes } (at most 16 MiB). Lite opens a native save dialog and returns
saved or cancelled in result.status; Serve returns download-started after
dispatching a browser download. Missing support and rejected promises need visible
feedback. Mobile and action contexts currently omit this optional method.
