Skip to content

Plugin

How a plugin runs, whatever language it’s in.

Runs plugins of one kind, provided as wraith.kind.<name> at major 1. JS and Lua are built in.

start(guest: import("salamander").Given<Wraith.Plugin.Guest>): Wraith.Plugin

Fails with StartError. Uses Plugin.Guest, Plugin.

One running plugin, from its kind’s start.

stop(): void
unload(): void
module(): number
serviceFor(trait: string): object | null

Its owner’s closed already, so nothing calls into what it gave out.

Nothing points at its code anymore.

Where its module’s loaded, or 0 for things like scripts.

What its main exports for a [Service] trait in its schemas, or nothing.

What can go wrong, besides Cancelled, Unsupported and Gone.

Code Error
1 Failed

What a plugin gets as it starts.

A struct, 0x50 bytes, aligned to 8.

Offset Field Type
0x0 name string
0x10 dir string A copy of its folder, deleted once it’s unloaded
0x20 wraith Api Stops working once it’s unloaded.
0x30 schema string Wraith’s, its own and its dependencies’ schemas as one bundle, for languages that read them at runtime.
0x40 services []Plugin.Service One per [Service] trait in its dependencies’ schemas.
name: string
dir: string
wraith: Wraith.Api
schema: string
services: Array<Wraith.Plugin.Service>

A plugin’s [Service] trait, as its main exports it.

A struct, 0x30 bytes, aligned to 8.

Offset Field Type
0x0 plugin string
0x10 trait string
0x20 obj object
plugin: string
trait: string
obj: object | null

Made with ♥ by Asgard