@sdeck/plugin 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts", "../src/bridge.ts", "../src/connection.ts", "../src/permissions.ts", "../src/settings.ts", "../src/plugin.ts", "../src/manifest.ts", "../src/shared.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * `@sdeck/plugin`: everything a plugin needs. Define actions that run headless (from keys,\n * triggers and workflows) or draw themselves with React, publish live state, offer trigger types,\n * and use the `@sdeck/app` hooks and components (re-exported here) for input and navigation.\n */\nexport * from \"@sdeck/app\";\nexport {\n type HostBridge,\n HostBridgeContext,\n useExpression,\n useHostState,\n useImage,\n useRunAction,\n useTemplate,\n useVariable,\n} from \"./bridge.ts\";\nexport {\n type ConnectionOptions,\n type ConnectionState,\n type Link,\n ManagedConnection,\n PermanentError,\n} from \"./connection.ts\";\nexport {\n HOST_MODULES,\n type ManifestResult,\n PLUGIN_KEYWORD,\n type PluginManifest,\n parseManifest,\n SUPPORTED_API_VERSIONS,\n} from \"./manifest.ts\";\nexport {\n PERMISSION_TEXTS,\n PERMISSIONS,\n type Permission,\n PermissionError,\n type PermissionText,\n} from \"./permissions.ts\";\nexport {\n type Action,\n type ActionDef,\n type ActionProps,\n checkPlugin,\n type Deactivate,\n type DeckControls,\n defineAction,\n definePlugin,\n defineTrigger,\n type Onboarding,\n type OnboardingStep,\n type OptionSource,\n PLUGIN_API_VERSION,\n type PluginCommand,\n type PluginContext,\n type PluginDef,\n pluginNamespace,\n type RunContext,\n type RunFn,\n type RunOutcome,\n type RunResult,\n type SlotKind,\n type StarterPage,\n type StateDef,\n type StatusLevel,\n type Trigger,\n type TriggerContext,\n type TriggerDef,\n} from \"./plugin.ts\";\nexport {\n type BooleanField,\n behaviorFields,\n type ColorField,\n checkSchema,\n defaultValue,\n type FieldValue,\n type GroupsField,\n type ImageField,\n type InferSettings,\n isFieldVisible,\n type NumberField,\n type OptionGroup,\n optionGroups,\n type PageField,\n resolveSettings,\n type SecretField,\n type SelectField,\n type SelectOption,\n type SettingField,\n type SettingsSchema,\n type SettingValue,\n type TextField,\n} from \"./settings.ts\";\nexport { Shared } from \"./shared.ts\";\n",
6
+ "/**\n * Live state for action components. The host provides a `HostBridge` around every slot; these\n * hooks subscribe to exactly what they read and re-render when it changes.\n */\nimport { compile, type Scope, sameValue, template } from \"@sdeck/engine\";\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n} from \"react\";\n\nexport interface HostBridge {\n /**\n * Watches state keys and variables behind expression paths (`system.cpu`, `vars.mode`).\n * Starts providers as needed. Returns a function that stops watching.\n */\n watch(paths: readonly string[], listener: () => void): () => void;\n /** The current expression scope (state namespaces, `vars`, `self`…). */\n scope(): Scope;\n /** Runs a plugin action as a workflow step would (recorded in the history). */\n run(plugin: string, action: string, settings?: Record<string, unknown>): Promise<unknown>;\n /** Sets a global variable. */\n setVariable(name: string, value: unknown): void;\n /**\n * What to draw for an image source (an icon reference, a URL or a `data:` URI), or\n * `undefined` while it loads. `color` applies to icons.\n */\n image(src: string, color?: string): string | undefined;\n /** Called when an image finishes loading. */\n watchImages(listener: () => void): () => void;\n}\n\nexport const HostBridgeContext = createContext<HostBridge | undefined>(undefined);\n\nfunction useBridge(): HostBridge {\n const bridge = useContext(HostBridgeContext);\n if (!bridge)\n throw new Error(\"sdeck live-state hooks must be used inside an action drawn by the host\");\n return bridge;\n}\n\n/** Re-renders every second while `on` (for `now()`/`time()` in templates). */\nfunction useClock(on: boolean): number {\n const [tick, setTick] = useState(0);\n useEffect(() => {\n if (!on) return;\n const timer = setInterval(() => setTick((t) => t + 1), 1000);\n return () => clearInterval(timer);\n }, [on]);\n return tick;\n}\n\nfunction useWatched<T>(paths: readonly string[], read: () => T): T {\n const bridge = useBridge();\n const key = paths.join(\"\\n\");\n // biome-ignore lint/correctness/useExhaustiveDependencies: `key` stands for `paths`.\n const subscribe = useCallback(\n (listener: () => void) => bridge.watch(paths, listener),\n [bridge, key],\n );\n // Expressions can build fresh arrays/objects; keep the previous one while equal so React does\n // not see a new snapshot on every read.\n const last = useRef<{ value: T } | undefined>(undefined);\n const snapshot = () => {\n const value = read();\n if (last.current && sameValue(last.current.value, value)) return last.current.value;\n last.current = { value };\n return value;\n };\n return useSyncExternalStore(subscribe, snapshot);\n}\n\n/**\n * The value of an expression (`system.cpu > 80`, `vars.mode`), kept up to date. Values the plugin\n * is not allowed to read (`state`, `variables`) are missing.\n */\nexport function useExpression(source: string): unknown {\n const bridge = useBridge();\n const expression = useMemo(() => compile(source), [source]);\n useClock(expression.timeDependent);\n return useWatched(expression.paths, () => expression.evaluate(bridge.scope()));\n}\n\n/** A `{{template}}` rendered to text, kept up to date: `useTemplate(\"CPU {{system.cpu}}%\")`. */\nexport function useTemplate(source: string): string {\n const bridge = useBridge();\n const compiled = useMemo(() => template(source), [source]);\n useClock(compiled.timeDependent);\n return useWatched(compiled.paths, () => compiled.render(bridge.scope()));\n}\n\n/** A live state value by key (`system.cpu`). */\nexport function useHostState(key: string): unknown {\n const bridge = useBridge();\n const paths = useMemo(() => [key], [key]);\n return useWatched(paths, () => {\n const dot = key.indexOf(\".\");\n const ns = bridge.scope()[key.slice(0, dot)] as Record<string, unknown> | undefined;\n return dot > 0 ? ns?.[key.slice(dot + 1)] : undefined;\n });\n}\n\n/** A global variable and a setter for it. */\nexport function useVariable(name: string): [unknown, (value: unknown) => void] {\n const bridge = useBridge();\n const paths = useMemo(() => [`vars.${name}`], [name]);\n const value = useWatched(paths, () => (bridge.scope().vars as Record<string, unknown>)[name]);\n const set = useCallback((v: unknown) => bridge.setVariable(name, v), [bridge, name]);\n return [value, set];\n}\n\n/**\n * Runs an action from a component (`run(\"@sdeck/plugin-system\", \"open\", {...})`).\n * Other plugins' actions need the `actions` permission.\n */\nexport function useRunAction(): HostBridge[\"run\"] {\n return useBridge().run;\n}\n\n/**\n * An image ready to draw with `<img src>`: an icon (`icon:lucide/play`, `icon:si/SiDiscord`) in\n * `color`, a URL or a `data:` URI. `undefined` until it has loaded.\n */\nexport function useImage(src: string, color?: string): string | undefined {\n const bridge = useBridge();\n return useSyncExternalStore(bridge.watchImages, () =>\n src ? bridge.image(src, color) : undefined,\n );\n}\n",
7
+ "/**\n * A connection to another program or service, opened only while something needs it and reopened\n * when it drops. Plugins hold it while their state is watched or a trigger listens, and borrow it\n * to run actions.\n */\n\nexport interface Link<C> {\n /** What callers use. */\n value: C;\n close(): void;\n}\n\n/** Retrying cannot help (a wrong password, nothing configured) until something changes. */\nexport class PermanentError extends Error {}\n\nexport type ConnectionState = \"connecting\" | \"connected\" | \"disconnected\";\n\nexport interface ConnectionOptions<C> {\n /**\n * Opens the connection. Call `lost` if it drops later. `signal` aborts when nobody wants it\n * any more.\n */\n open(lost: (error: Error) => void, signal: AbortSignal): Promise<Link<C>>;\n onStatus?: (state: ConnectionState, error?: Error) => void;\n /** How long it stays open after the last holder leaves (default 3000). */\n lingerMs?: number;\n /** First and longest pause between attempts (default 1000 and 30000). */\n retry?: { minMs: number; maxMs: number };\n}\n\ninterface Waiter<C> {\n resolve: (value: C) => void;\n reject: (error: Error) => void;\n}\n\nexport class ManagedConnection<C> {\n readonly #options: ConnectionOptions<C>;\n readonly #waiters = new Set<Waiter<C>>();\n #holders = 0;\n #link: Link<C> | undefined;\n #attempt: AbortController | undefined;\n #retry: ReturnType<typeof setTimeout> | undefined;\n #linger: ReturnType<typeof setTimeout> | undefined;\n #delay: number;\n /** Set by a {@link PermanentError}; cleared by {@link restart}. */\n #failed: Error | undefined;\n\n constructor(options: ConnectionOptions<C>) {\n this.#options = options;\n this.#delay = options.retry?.minMs ?? 1000;\n }\n\n /** The open connection, if there is one. */\n get current(): C | undefined {\n return this.#link?.value;\n }\n\n /** Keeps the connection wanted until the returned function is called. */\n hold(): () => void {\n this.#holders++;\n clearTimeout(this.#linger);\n this.#connect();\n let released = false;\n return () => {\n if (released) return;\n released = true;\n this.#holders--;\n if (this.#holders > 0) return;\n this.#linger = setTimeout(() => this.#drop(), this.#options.lingerMs ?? 3000);\n };\n }\n\n /** Runs `use` with the connection, opening it first if needed. */\n async with<T>(use: (value: C) => T | Promise<T>, timeoutMs = 5000): Promise<T> {\n const release = this.hold();\n try {\n return await use(await this.#ready(timeoutMs));\n } finally {\n release();\n }\n }\n\n /** Starts over (the settings changed). */\n restart(): void {\n this.#failed = undefined;\n this.#delay = this.#options.retry?.minMs ?? 1000;\n this.#drop();\n if (this.#holders > 0) this.#connect();\n }\n\n /** Closes it for good, whoever holds it. */\n close(): void {\n this.#holders = 0;\n clearTimeout(this.#linger);\n this.#drop();\n this.#reject(new Error(\"the connection was closed\"));\n }\n\n #ready(timeoutMs: number): Promise<C> {\n if (this.#link) return Promise.resolve(this.#link.value);\n if (this.#failed) return Promise.reject(this.#failed);\n // Someone is waiting: no point sitting out the pause between attempts.\n if (this.#retry) {\n clearTimeout(this.#retry);\n this.#retry = undefined;\n this.#connect();\n }\n return new Promise<C>((resolve, reject) => {\n let last: Error | undefined;\n const waiter: Waiter<C> = {\n resolve: (value) => {\n clearTimeout(timer);\n resolve(value);\n },\n reject: (error) => {\n last = error;\n clearTimeout(timer);\n this.#waiters.delete(waiter);\n reject(last);\n },\n };\n const timer = setTimeout(\n () => waiter.reject(new Error(\"could not connect in time\")),\n timeoutMs,\n );\n this.#waiters.add(waiter);\n });\n }\n\n #connect(): void {\n if (this.#link || this.#attempt || this.#retry || this.#failed) return;\n const attempt = new AbortController();\n this.#attempt = attempt;\n this.#options.onStatus?.(\"connecting\");\n let lostEarly: Error | undefined;\n let link: Link<C> | undefined;\n const lost = (error: Error) => {\n if (!link) {\n lostEarly = error;\n return;\n }\n if (this.#link !== link) return;\n this.#link = undefined;\n link.close();\n this.#options.onStatus?.(\"disconnected\", error);\n this.#schedule(error);\n };\n const open = async () => {\n const opened = await this.#options.open(lost, attempt.signal);\n if (attempt.signal.aborted) {\n opened.close();\n return;\n }\n if (lostEarly) {\n opened.close();\n throw lostEarly;\n }\n link = opened;\n this.#attempt = undefined;\n this.#link = opened;\n this.#delay = this.#options.retry?.minMs ?? 1000;\n this.#options.onStatus?.(\"connected\");\n for (const waiter of this.#waiters) waiter.resolve(opened.value);\n this.#waiters.clear();\n };\n open().catch((error: Error) => {\n if (attempt.signal.aborted || this.#attempt !== attempt) return;\n this.#attempt = undefined;\n this.#options.onStatus?.(\"disconnected\", error);\n this.#reject(error);\n this.#schedule(error);\n });\n }\n\n #schedule(error: Error): void {\n if (error instanceof PermanentError) {\n this.#failed = error;\n this.#reject(error);\n return;\n }\n if (this.#holders <= 0) return;\n clearTimeout(this.#retry);\n this.#retry = setTimeout(() => {\n this.#retry = undefined;\n if (this.#holders > 0) this.#connect();\n }, this.#delay);\n this.#delay = Math.min(this.#delay * 2, this.#options.retry?.maxMs ?? 30_000);\n }\n\n #reject(error: Error): void {\n for (const waiter of [...this.#waiters]) waiter.reject(error);\n this.#waiters.clear();\n }\n\n #drop(): void {\n clearTimeout(this.#retry);\n this.#retry = undefined;\n this.#attempt?.abort();\n this.#attempt = undefined;\n const link = this.#link;\n this.#link = undefined;\n if (!link) return;\n link.close();\n this.#options.onStatus?.(\"disconnected\");\n }\n}\n",
8
+ "/**\n * What a plugin can ask to do. The user decides about each permission separately, and a plugin\n * gets nothing it did not ask for and nothing the user did not allow.\n */\nexport type Permission =\n | \"network\"\n | \"filesystem\"\n | \"process\"\n | \"shell\"\n | \"input\"\n | \"clipboard\"\n | \"audio\"\n | \"environment\"\n | \"variables\"\n | \"state\"\n | \"actions\"\n | \"native\";\n\n/** A permission as the user reads it. */\nexport interface PermissionText {\n name: string;\n /** What allowing it makes possible. */\n description: string;\n /** Finishes \"the plugin is not allowed to …\". */\n action: string;\n /** Allowing it lets the plugin do nearly anything the user can. */\n powerful?: boolean;\n}\n\n/** Every permission, in the order the UI lists them. */\nexport const PERMISSION_TEXTS: Readonly<Record<Permission, PermissionText>> = {\n network: {\n name: \"Network\",\n description: \"Connect to the internet and to devices on your network.\",\n action: \"use the network\",\n },\n filesystem: {\n name: \"Files\",\n description: \"Read and change your files. Its own data folder is always allowed.\",\n action: \"use files outside its own folder\",\n },\n process: {\n name: \"Start programs\",\n description: \"Open apps and run programs that are installed on this computer.\",\n action: \"start programs\",\n powerful: true,\n },\n shell: {\n name: \"Run commands\",\n description: \"Run any command line. Commands can do everything you can.\",\n action: \"run commands\",\n powerful: true,\n },\n input: {\n name: \"Keyboard and mouse\",\n description: \"Press keys, type text and control media playback.\",\n action: \"press keys\",\n },\n clipboard: {\n name: \"Clipboard\",\n description: \"Read and change what you copied.\",\n action: \"use the clipboard\",\n },\n audio: {\n name: \"Sound\",\n description: \"Change volumes, mute apps and switch audio devices.\",\n action: \"control sound\",\n },\n environment: {\n name: \"Environment variables\",\n description: \"Read environment variables, which can contain keys and tokens.\",\n action: \"read environment variables\",\n },\n variables: {\n name: \"Your variables\",\n description: \"Read and change the variables your workflows use.\",\n action: \"use your variables\",\n },\n state: {\n name: \"Other plugins' values\",\n description: \"Read live values from other plugins, such as the app in front.\",\n action: \"read other plugins' values\",\n },\n actions: {\n name: \"Other plugins' actions\",\n description: \"Run actions of other plugins, with the permissions those have.\",\n action: \"run other plugins' actions\",\n powerful: true,\n },\n native: {\n name: \"Native code\",\n description: \"Load compiled code, which sdeck cannot limit in any way.\",\n action: \"load native code\",\n powerful: true,\n },\n};\n\nexport const PERMISSIONS = Object.keys(PERMISSION_TEXTS) as readonly Permission[];\n\n/** Thrown when a plugin does something the user has not allowed. The message is for the user. */\nexport class PermissionError extends Error {\n override readonly name = \"PermissionError\";\n /** As Node's file system reports a refused path, so libraries treat it the same way. */\n readonly code = \"EACCES\";\n\n constructor(\n /** The plugin's name or id. */\n plugin: string,\n readonly permission: Permission,\n /** What was refused, when that helps (a path, an address). */\n detail?: string,\n ) {\n const { name, action } = PERMISSION_TEXTS[permission];\n super(\n `${plugin} is not allowed to ${action}${detail ? ` (${detail})` : \"\"}. ` +\n `Allow \"${name}\" in the plugin's permissions.`,\n );\n }\n}\n",
9
+ "/**\n * Action settings are described by a plain-data schema. The host turns it into a form in the\n * configuration UI, and `resolveSettings` turns whatever is stored into well-typed values.\n */\n\ntype Primitive = string | number | boolean;\n\ninterface FieldBase {\n /** Label shown in the configuration UI. */\n label: string;\n /** Help text under the field. */\n description?: string;\n /**\n * It only changes how the button looks. It is asked for on a button, but not in a step of a\n * workflow or gesture, where nothing is drawn.\n */\n appearance?: boolean;\n /**\n * Shown only while other fields have these values: `{ to: \"page\" }` or\n * `{ mode: [\"a\", \"b\"] }`. Hidden fields keep their value.\n */\n visibleIf?: Readonly<Record<string, Primitive | readonly Primitive[]>>;\n}\n\nexport interface TextField extends FieldBase {\n type: \"text\";\n default?: string;\n placeholder?: string;\n multiline?: boolean;\n /** Suggestions from one of the plugin's `optionSources` (any text is still allowed). */\n source?: string;\n /** Other fields the suggestions depend on, passed to the source. */\n dependsOn?: readonly string[];\n}\n\nexport interface NumberField extends FieldBase {\n type: \"number\";\n default?: number;\n min?: number;\n max?: number;\n step?: number;\n}\n\nexport interface BooleanField extends FieldBase {\n type: \"boolean\";\n default?: boolean;\n}\n\n/**\n * A password or token, only for a plugin's own settings. It is kept in the host's secrets file\n * (never in the config, so it is safe to share or commit) and the UI never reads it back.\n */\nexport interface SecretField extends FieldBase {\n type: \"secret\";\n default?: string;\n placeholder?: string;\n}\n\n/** A `#rrggbb` colour. */\nexport interface ColorField extends FieldBase {\n type: \"color\";\n default?: string;\n}\n\nexport interface SelectOption {\n value: string;\n label: string;\n}\n\nexport interface SelectField extends FieldBase {\n type: \"select\";\n /** Fixed options. With `source`, shown before the fetched ones. */\n options: readonly SelectOption[];\n /**\n * Options fetched from one of the plugin's `optionSources` when the form opens (OBS\n * scenes, audio devices). Any stored string is then kept, since the list can change.\n */\n source?: string;\n /**\n * Other fields the fetched options depend on, passed to the source. The form asks for them\n * first, and clears this field when one of them changes.\n */\n dependsOn?: readonly string[];\n default?: string;\n}\n\n/** The name of one of the user's pages (the UI shows a page picker). */\nexport interface PageField extends FieldBase {\n type: \"page\";\n default?: string;\n}\n\n/** An image: an `http(s)` URL or a `data:` URI (the UI accepts a URL or a file). */\nexport interface ImageField extends FieldBase {\n type: \"image\";\n default?: string;\n}\n\n/** A named set the user made of options, from a `groups` field. */\nexport interface OptionGroup {\n /** Stays the same when the group is renamed; refer to the group by it. */\n id: string;\n name: string;\n /** The chosen options' values. */\n members: readonly string[];\n}\n\n/** Named sets of options the user puts together (rooms of lights), only for a plugin's own settings. */\nexport interface GroupsField extends FieldBase {\n type: \"groups\";\n /** The plugin's `optionSources` entry that lists what a group can contain. */\n source: string;\n /** What a group contains, for the form, e.g. `lights` (default: `items`). */\n noun?: string;\n default?: readonly OptionGroup[];\n}\n\nexport type SettingField =\n | TextField\n | NumberField\n | BooleanField\n | ColorField\n | SelectField\n | PageField\n | ImageField\n | GroupsField\n | SecretField;\n\nexport type SettingsSchema = Readonly<Record<string, SettingField>>;\n\n/** The value type of one field. */\nexport type FieldValue<F extends SettingField> = F extends NumberField\n ? number\n : F extends BooleanField\n ? boolean\n : F extends GroupsField\n ? readonly OptionGroup[]\n : F extends SelectField\n ? F extends { source: string }\n ? string\n : F[\"options\"][number][\"value\"]\n : string;\n\n/** A value of any field. */\nexport type SettingValue = Primitive | readonly OptionGroup[];\n\n/** The settings object an action receives for a schema. */\nexport type InferSettings<S extends SettingsSchema> = {\n -readonly [K in keyof S]: FieldValue<S[K]>;\n};\n\nconst HEX = /^#[0-9a-f]{6}$/i;\n\n/** The value a field takes when nothing (valid) is stored. */\nexport function defaultValue(field: SettingField): SettingValue {\n switch (field.type) {\n case \"number\":\n return field.default ?? field.min ?? 0;\n case \"boolean\":\n return field.default ?? false;\n case \"color\":\n return field.default ?? \"#000000\";\n case \"groups\":\n return field.default ?? [];\n case \"select\":\n return field.default ?? field.options[0]?.value ?? \"\";\n default:\n return field.default ?? \"\";\n }\n}\n\n/** The valid groups in a stored value, or `undefined` if it isn't a list. */\nexport function optionGroups(value: unknown): OptionGroup[] | undefined {\n if (!Array.isArray(value)) return undefined;\n const ids = new Set<string>();\n return value.flatMap((group: Partial<OptionGroup> | null) => {\n if (typeof group?.id !== \"string\" || !group.id || ids.has(group.id)) return [];\n ids.add(group.id);\n const members = Array.isArray(group.members) ? group.members : [];\n return [\n {\n id: group.id,\n name: typeof group.name === \"string\" ? group.name : \"\",\n members: [...new Set(members.filter((m) => typeof m === \"string\"))],\n },\n ];\n });\n}\n\nfunction coerce(field: SettingField, value: unknown): SettingValue {\n switch (field.type) {\n case \"number\": {\n const n = typeof value === \"string\" && value.trim() !== \"\" ? Number(value) : value;\n if (typeof n !== \"number\" || !Number.isFinite(n)) return defaultValue(field);\n return Math.min(field.max ?? Infinity, Math.max(field.min ?? -Infinity, n));\n }\n case \"boolean\":\n return typeof value === \"boolean\" ? value : defaultValue(field);\n case \"color\":\n return typeof value === \"string\" && HEX.test(value)\n ? value.toLowerCase()\n : defaultValue(field);\n case \"groups\":\n return optionGroups(value) ?? defaultValue(field);\n case \"select\":\n if (typeof value !== \"string\") return defaultValue(field);\n if (field.source !== undefined) return value;\n return field.options.some((o) => o.value === value) ? value : defaultValue(field);\n default:\n return typeof value === \"string\" ? value : defaultValue(field);\n }\n}\n\n/**\n * Stored settings, made safe: every field of `schema` is present and of the right type (invalid\n * or missing values get the default, numbers are clamped), and unknown keys are dropped.\n */\nexport function resolveSettings<S extends SettingsSchema>(\n schema: S,\n stored: Readonly<Record<string, unknown>> | undefined,\n): InferSettings<S> {\n const out: Record<string, unknown> = {};\n for (const [key, field] of Object.entries(schema)) out[key] = coerce(field, stored?.[key]);\n return out as InferSettings<S>;\n}\n\n/** The fields that change what an action does, without those for how its button looks. */\nexport function behaviorFields(schema: SettingsSchema): SettingsSchema {\n return Object.fromEntries(Object.entries(schema).filter(([, field]) => !field.appearance));\n}\n\n/** Whether `field` is shown for these (resolved) settings. */\nexport function isFieldVisible(\n field: SettingField,\n settings: Readonly<Record<string, unknown>>,\n): boolean {\n if (!field.visibleIf) return true;\n return Object.entries(field.visibleIf).every(([key, want]) => {\n const value = settings[key];\n return Array.isArray(want) ? want.includes(value as Primitive) : value === want;\n });\n}\n\n/**\n * Problems with a schema (empty when it is fine). Used when a plugin is loaded. `sources` are\n * the plugin's option sources, checked against fields that name one.\n */\nexport function checkSchema(\n schema: SettingsSchema,\n sources: Readonly<Record<string, unknown>> = {},\n): string[] {\n const problems: string[] = [];\n const types = new Set([\n \"text\",\n \"number\",\n \"boolean\",\n \"color\",\n \"select\",\n \"page\",\n \"image\",\n \"groups\",\n \"secret\",\n ]);\n for (const [key, field] of Object.entries(schema)) {\n if (!field || typeof field !== \"object\" || !types.has(field.type)) {\n problems.push(`setting \"${key}\" has an unknown type`);\n continue;\n }\n if (typeof field.label !== \"string\") problems.push(`setting \"${key}\" needs a label`);\n const source = \"source\" in field ? field.source : undefined;\n if (field.type === \"groups\" && source === undefined) {\n problems.push(`setting \"${key}\" needs a source`);\n }\n if (source !== undefined && !(source in sources)) {\n problems.push(`setting \"${key}\" uses unknown option source \"${source}\"`);\n }\n if (\n field.type === \"select\" &&\n (!Array.isArray(field.options) || (field.options.length === 0 && source === undefined))\n ) {\n problems.push(`setting \"${key}\" needs at least one option or a source`);\n }\n for (const other of (\"dependsOn\" in field && field.dependsOn) || []) {\n if (!(other in schema)) problems.push(`setting \"${key}\" depends on unknown \"${other}\"`);\n }\n if (field.visibleIf !== undefined) {\n for (const other of Object.keys(field.visibleIf)) {\n if (!(other in schema)) problems.push(`setting \"${key}\" depends on unknown \"${other}\"`);\n }\n }\n }\n return problems;\n}\n",
10
+ "import type { SlotInfo } from \"@sdeck/app\";\nimport type { ExecSource, StateValueType } from \"@sdeck/engine\";\nimport type { Look, NavigateTarget } from \"@sdeck/schema\";\nimport type { ComponentType } from \"react\";\nimport { PERMISSIONS, type Permission } from \"./permissions.ts\";\nimport {\n checkSchema,\n type InferSettings,\n type SelectOption,\n type SettingsSchema,\n} from \"./settings.ts\";\n\n/** Bumped when the plugin contract changes incompatibly. Hosts refuse plugins built for another. */\nexport const PLUGIN_API_VERSION = 2;\n\n/** Where an action can be placed. */\nexport type SlotKind = \"key\" | \"sensor\" | \"window\";\n\n/** Given to a plugin's `activate`, its actions, state providers and triggers. */\nexport interface PluginContext {\n readonly pluginId: string;\n /** Prefix of this plugin's state keys and events (`system` → `system.cpu`). */\n readonly namespace: string;\n /** A writable directory for this plugin's own files (created on first use). */\n readonly dataDir: string;\n /** Logs to the host, tagged with the plugin id. */\n log(...args: unknown[]): void;\n /** The plugin's own settings (secrets included), resolved against `PluginDef.settings`. */\n settings(): Record<string, unknown>;\n /** Called after the plugin's settings change; returns a function that stops. */\n onSettings(listener: () => void): () => void;\n /** Values the plugin keeps private between runs (tokens it obtained, for example). */\n readonly secrets: {\n get(key: string): string | undefined;\n set(key: string, value: string | undefined): Promise<void>;\n };\n /** Shown with the plugin in the UI (`Connected`, `Sign in to continue`). `undefined` clears. */\n status(text: string | undefined, level?: StatusLevel): void;\n /** Live state: `set` publishes `<namespace>.<id>`, `get` reads any key (`system.cpu`). */\n readonly state: {\n set(id: string, value: unknown): void;\n /** Keys of other plugins need the `state` permission. */\n get(key: string): unknown;\n };\n /** Emits `<namespace>:<event>` on the event bus (workflows can trigger on it). */\n emit(event: string, payload?: unknown): void;\n /** Global user variables. Needs the `variables` permission. */\n readonly vars: {\n get(name: string): unknown;\n set(name: string, value: unknown): void;\n };\n}\n\n/** How a plugin's status reads: fine, needing attention, or failing. */\nexport type StatusLevel = \"ok\" | \"info\" | \"error\";\n\n/** Something the user can run from the plugin's settings (sign in, reconnect). */\nexport interface PluginCommand {\n /** Unique within the plugin. */\n id: string;\n name: string;\n description?: string;\n /**\n * What it needs, out of the plugin's `permissions` (default: all of them; `[]` for nothing).\n * Without them it is refused.\n */\n permissions?: readonly Permission[];\n /** What it returns, if a string, is opened in the user's browser. Throw to fail. */\n run(context: PluginContext): unknown | Promise<unknown>;\n}\n\n/**\n * One step of setting a plugin up. Studio walks the user through the steps right after the plugin\n * is installed, and again from its \"Get started\" button.\n */\nexport interface OnboardingStep {\n /** Unique within the plugin's steps. */\n id: string;\n title: string;\n /**\n * What to do, in plain words. Blank lines start paragraphs; `**bold**`, `` `code` `` and\n * `[links](https://…)` work.\n */\n body?: string;\n /** The plugin's own settings this step asks for, by key (secrets too). */\n settings?: readonly string[];\n /** One of the plugin's commands, run from a button in this step (sign in, find devices). */\n command?: string;\n /** A web page to open, such as where to create an API key. */\n link?: { label: string; url: string };\n /**\n * Whether the step is done: a key is saved, the sign-in went through. Without it, a step that\n * asks for settings is done once they all have a value.\n */\n done?(context: PluginContext): boolean | Promise<boolean>;\n /** Not needed to use the plugin (Bluetooth lights need no cloud key). */\n optional?: boolean;\n}\n\n/** Keys a plugin offers as a page of their own at the end of onboarding. */\nexport interface StarterPage {\n /** The page's name (default: the plugin's). */\n name?: string;\n /** By key index: the action's id and settings. */\n keys: Readonly<Record<number, { action: string; settings?: Record<string, unknown> }>>;\n sensors?: Readonly<Record<number, { action: string; settings?: Record<string, unknown> }>>;\n window?: { action: string; settings?: Record<string, unknown> };\n}\n\n/** How a plugin is set up after it is installed. */\nexport interface Onboarding {\n /** A sentence or two shown before the steps. */\n intro?: string;\n steps: readonly OnboardingStep[];\n /**\n * The page of keys offered at the end. By default the plugin's first eight actions for keys;\n * `false` offers none.\n */\n starterPage?: StarterPage | false;\n}\n\n/** Props of an action's component. */\nexport interface ActionProps<S extends SettingsSchema = SettingsSchema> {\n /** This placement's settings, resolved against the schema (always complete and typed). */\n settings: InferSettings<S>;\n /** Saves changed settings for this placement (persisted and shown in the UI). */\n setSettings(patch: Partial<InferSettings<S>>): void;\n /** Where the action is drawn. */\n slot: SlotInfo;\n plugin: PluginContext;\n}\n\n/** Given to an action's `run`. */\nexport interface RunContext<S extends SettingsSchema = SettingsSchema> {\n /** Settings with `{{templates}}` already resolved, then checked against the schema. */\n settings: InferSettings<S>;\n plugin: PluginContext;\n /** What started the run (a key, a trigger, a workflow…). */\n source: ExecSource;\n /** Aborted when the execution is cancelled. Long work should stop. */\n signal: AbortSignal;\n /** The triggering event's payload, if any. */\n event: unknown;\n /** Controls of the deck the run started on (every deck, for triggers and workflows). */\n deck: DeckControls;\n}\n\n/** What a headless action can do to the decks. */\nexport interface DeckControls {\n /** Moves between pages, as a `navigate` workflow step does. Throws for an unknown page. */\n navigate(to: NavigateTarget, page?: string, options?: { wrap?: boolean }): void;\n /** The current brightness (0–100). */\n brightness(): number;\n /** Sets the brightness (0–100). */\n setBrightness(level: number): Promise<void>;\n}\n\n/**\n * What `run` gives back. `undo` reverts what the run did; it is recorded in the action history\n * and used by toggle buttons and the `undo` step.\n */\nexport interface RunOutcome {\n result?: unknown;\n undo?: () => unknown;\n /** Summary for the history, e.g. `Volume 30%`. */\n label?: string;\n}\n\nexport type RunResult = RunOutcome | undefined;\n\nexport interface ActionDef<S extends SettingsSchema = SettingsSchema> {\n /** Unique within the plugin, e.g. `\"clock\"`. */\n id: string;\n name: string;\n description?: string;\n /** Groups actions in the picker (default: the plugin's name). */\n category?: string;\n /**\n * Icon for the UI: a [lucide](https://lucide.dev/icons) icon name in kebab case (`\"timer\"`),\n * or an image URL / `data:` URI.\n */\n icon?: string;\n /** Slot kinds the action supports (default: keys only). */\n slots?: readonly SlotKind[];\n /** Settings shown in the UI, as a form. */\n settings?: S;\n /**\n * What it needs, out of the plugin's `permissions` (default: all of them; `[]` for nothing).\n * Without them it cannot run or draw itself.\n */\n permissions?: readonly Permission[];\n /**\n * It only shows something. It is offered for buttons, but not as a step of a workflow or\n * gesture, and needs no `run`.\n */\n display?: boolean;\n /**\n * Does the work, without drawing anything: it can run from a key, a trigger or a workflow.\n * Throw to fail. An action needs `run`, `component`, or both, unless it is `display`.\n */\n // biome-ignore lint/suspicious/noConfusingVoidType: lets `run` simply not return anything.\n run?(context: RunContext<S>): RunResult | void | Promise<RunResult | void>;\n /**\n * Draws the action itself (it then handles its own input). It runs inside the deck's React\n * tree, so the `@sdeck/app` hooks and components work as in any app. Without it, the host\n * draws the button's look and runs `run` on press.\n */\n component?: ComponentType<ActionProps<S>>;\n /** The look a new button with this action starts with (default: its name on a dark key). */\n look?(settings: InferSettings<S>): Look;\n}\n\nexport type RunFn = (context: RunContext) => RunResult | undefined | Promise<RunResult | undefined>;\n\n/** An action with its settings type erased, as stored on a plugin. */\nexport interface Action {\n readonly id: string;\n readonly name: string;\n readonly description?: string;\n readonly category?: string;\n readonly icon?: string;\n readonly slots: readonly SlotKind[];\n readonly settings: SettingsSchema;\n readonly permissions?: readonly Permission[];\n readonly display?: boolean;\n readonly run?: RunFn;\n readonly component?: ComponentType<ActionProps>;\n readonly look?: (settings: Record<string, unknown>) => Look;\n}\n\n/** A live value the plugin publishes as `<namespace>.<id>`. */\nexport interface StateDef {\n /** Letters, digits, `-`, `_` and `.` (`cpu`, `core.0`). */\n id: string;\n name: string;\n type: StateValueType;\n unit?: string;\n description?: string;\n /**\n * What reading it needs, out of the plugin's `permissions` (default: all of them; `[]` for nothing).\n * Without them it has no value.\n */\n permissions?: readonly Permission[];\n /** Read every `everyMs` while something shows or waits on the value. */\n poll?: { everyMs: number; read(context: PluginContext): unknown | Promise<unknown> };\n /** Push updates while watched; return a stop function. */\n // biome-ignore lint/suspicious/noConfusingVoidType: lets `start` simply not return anything.\n start?(set: (value: unknown) => void, context: PluginContext): (() => void) | void;\n}\n\n/** Given to a trigger's `subscribe`. */\nexport interface TriggerContext<S extends SettingsSchema = SettingsSchema> {\n settings: InferSettings<S>;\n plugin: PluginContext;\n /** Starts the trigger's workflow; `event` becomes `event` in its expressions. */\n fire(event?: unknown): void;\n}\n\nexport interface TriggerDef<S extends SettingsSchema = SettingsSchema> {\n /** Unique within the plugin; the trigger type is `<plugin id>:<id>`. */\n id: string;\n name: string;\n description?: string;\n settings?: S;\n /**\n * What it needs, out of the plugin's `permissions` (default: all of them; `[]` for nothing).\n * Without them it never fires.\n */\n permissions?: readonly Permission[];\n /** Starts watching; returns a function that stops. */\n // biome-ignore lint/suspicious/noConfusingVoidType: lets `subscribe` simply not return anything.\n subscribe(context: TriggerContext<S>): (() => void) | void;\n}\n\nexport interface Trigger {\n readonly id: string;\n readonly name: string;\n readonly description?: string;\n readonly settings: SettingsSchema;\n readonly permissions?: readonly Permission[];\n readonly subscribe: (context: TriggerContext) => (() => void) | undefined;\n}\n\n/**\n * Fills fields that name it in `source` (OBS scenes, audio devices…). `settings` holds the\n * fields the asking field `dependsOn` (a server whose channels to list).\n */\nexport type OptionSource = (\n context: PluginContext,\n settings: Readonly<Record<string, unknown>>,\n) => SelectOption[] | Promise<SelectOption[]>;\n\n/** Undoes what `activate` did. */\nexport type Deactivate = () => void | Promise<void>;\n\nexport interface PluginDef {\n /** Unique id; for an installed plugin this must be its package name. */\n id: string;\n name: string;\n /** Semver version. */\n version: string;\n description?: string;\n author?: string;\n homepage?: string;\n /** State key and event prefix (default: derived from the id, `@sdeck/plugin-system` → `system`). */\n namespace?: string;\n actions: readonly Action[];\n state?: readonly StateDef[];\n triggers?: readonly Trigger[];\n optionSources?: Readonly<Record<string, OptionSource>>;\n /**\n * Everything the plugin asks to be allowed to do. The user decides about each one, and can\n * change their mind at any time: handle being refused. What is not listed is never allowed.\n */\n permissions?: readonly Permission[];\n /** The plugin's own settings (a server address, a token), shown on its page. */\n settings?: SettingsSchema;\n /** Buttons in the plugin's settings. */\n commands?: readonly PluginCommand[];\n /**\n * How to set the plugin up, step by step, shown after it is installed. Without it, Studio asks\n * for the plugin's settings and offers its commands in one step.\n */\n onboarding?: Onboarding;\n /** Runs when the plugin is enabled (and when the host starts). May return a cleanup. */\n // biome-ignore lint/suspicious/noConfusingVoidType: lets `activate` simply not return anything.\n activate?(context: PluginContext): void | Deactivate | Promise<void | Deactivate>;\n}\n\nconst ID = /^(@[a-z0-9][\\w.-]*\\/)?[a-z0-9][\\w.-]*$/;\nconst NAMESPACE = /^[a-z][\\w-]{0,31}$/;\nconst LOCAL_ID = /^[\\w.-]+$/;\n\n/** The namespace a plugin's state and events use. */\nexport function pluginNamespace(def: Pick<PluginDef, \"id\" | \"namespace\">): string {\n if (def.namespace) return def.namespace;\n const base = def.id\n .replace(/^@[^/]+\\//, \"\")\n .replace(/^sdeck-plugin-/, \"\")\n .replace(/^plugin-/, \"\")\n .toLowerCase()\n .replace(/[^\\w-]/g, \"-\");\n return /^[a-z]/.test(base) ? base.slice(0, 32) : `p-${base}`.slice(0, 32);\n}\n\n/**\n * Defines an action. `settings` is inferred, so `run` and `component` get typed settings:\n *\n * ```ts\n * export const hello = defineAction({\n * id: \"hello\",\n * name: \"Hello\",\n * settings: { name: { type: \"text\", label: \"Name\", default: \"world\" } },\n * run: ({ settings, plugin }) => plugin.log(`Hi ${settings.name}`),\n * });\n * ```\n */\nexport function defineAction<const S extends SettingsSchema = Record<never, never>>(\n def: ActionDef<S>,\n): Action {\n return {\n ...def,\n slots: def.slots ?? [\"key\"],\n settings: def.settings ?? {},\n } as unknown as Action;\n}\n\n/** Defines a trigger type with typed settings. */\nexport function defineTrigger<const S extends SettingsSchema = Record<never, never>>(\n def: TriggerDef<S>,\n): Trigger {\n return { ...def, settings: def.settings ?? {} } as unknown as Trigger;\n}\n\n/** Defines a plugin, checking it. A plugin module's default export must be one of these. */\nexport function definePlugin(def: PluginDef): PluginDef {\n const problems = checkPlugin(def);\n if (problems.length > 0) {\n throw new TypeError(`invalid plugin \"${def?.id}\": ${problems.join(\"; \")}`);\n }\n return def;\n}\n\n/** Problems with the `permissions` of one of a plugin's parts. */\nfunction checkNeeds(part: string, needs: unknown, asked: unknown): string[] {\n if (needs === undefined) return [];\n if (!Array.isArray(needs)) return [`${part}: permissions must be an array`];\n const missing = needs.filter((p) => !Array.isArray(asked) || !asked.includes(p));\n return missing.map(\n (p) => `${part}: permission \"${String(p)}\" is not in the plugin's permissions`,\n );\n}\n\nfunction checkLocalIds(\n kind: string,\n items: readonly { id?: unknown }[],\n problems: string[],\n): Set<string> {\n const seen = new Set<string>();\n for (const item of items) {\n const name = typeof item?.id === \"string\" ? item.id : \"?\";\n if (typeof item?.id !== \"string\" || !LOCAL_ID.test(item.id)) {\n problems.push(`${kind} \"${name}\": id must be letters, digits, \".\", \"-\" or \"_\"`);\n } else if (seen.has(item.id)) {\n problems.push(`${kind} \"${name}\" is defined twice`);\n }\n seen.add(name);\n }\n return seen;\n}\n\n/** Problems with something that should be a plugin (empty when it is fine). */\nexport function checkPlugin(value: unknown): string[] {\n if (!value || typeof value !== \"object\") return [\"not an object\"];\n const def = value as Partial<PluginDef>;\n const problems: string[] = [];\n if (typeof def.id !== \"string\" || !ID.test(def.id)) {\n problems.push(\"id must be a package-style name (lowercase, e.g. `my-plugin` or `@me/plugin`)\");\n }\n if (typeof def.name !== \"string\" || def.name === \"\") problems.push(\"name is required\");\n if (typeof def.version !== \"string\" || def.version === \"\") problems.push(\"version is required\");\n if (def.namespace !== undefined && !NAMESPACE.test(def.namespace)) {\n problems.push(\"namespace must be lowercase letters, digits, - or _ (starting with a letter)\");\n }\n if (def.activate !== undefined && typeof def.activate !== \"function\") {\n problems.push(\"activate must be a function\");\n }\n if (def.permissions !== undefined) {\n if (!Array.isArray(def.permissions)) problems.push(\"permissions must be an array\");\n else\n for (const p of def.permissions)\n if (!PERMISSIONS.includes(p)) problems.push(`unknown permission \"${String(p)}\"`);\n }\n if (def.settings !== undefined) {\n for (const p of checkSchema(def.settings, def.optionSources ?? {})) {\n problems.push(`plugin ${p}`);\n }\n }\n if (def.commands !== undefined) {\n if (!Array.isArray(def.commands)) problems.push(\"commands must be an array\");\n else {\n checkLocalIds(\"command\", def.commands, problems);\n for (const c of def.commands as Partial<PluginCommand>[]) {\n const name = typeof c?.id === \"string\" ? c.id : \"?\";\n if (typeof c?.name !== \"string\") problems.push(`command \"${name}\": name is required`);\n if (typeof c?.run !== \"function\") problems.push(`command \"${name}\": run is required`);\n problems.push(...checkNeeds(`command \"${name}\"`, c?.permissions, def.permissions));\n }\n }\n }\n if (def.onboarding !== undefined) problems.push(...checkOnboarding(def));\n const sources = def.optionSources ?? {};\n if (typeof sources !== \"object\") problems.push(\"optionSources must be an object\");\n else\n for (const [name, fn] of Object.entries(sources))\n if (typeof fn !== \"function\") problems.push(`option source \"${name}\" must be a function`);\n\n if (!Array.isArray(def.actions)) return [...problems, \"actions must be an array\"];\n checkLocalIds(\"action\", def.actions, problems);\n for (const action of def.actions as Partial<Action>[]) {\n const name = typeof action?.id === \"string\" ? action.id : \"?\";\n if (typeof action?.name !== \"string\") problems.push(`action \"${name}\": name is required`);\n const hasComponent =\n typeof action?.component === \"function\" || typeof action?.component === \"object\";\n const hasRun = typeof action?.run === \"function\";\n if (!hasComponent && !hasRun && !action?.display) {\n problems.push(`action \"${name}\": needs run or component`);\n }\n problems.push(...checkNeeds(`action \"${name}\"`, action?.permissions, def.permissions));\n if (action?.look !== undefined && typeof action.look !== \"function\") {\n problems.push(`action \"${name}\": look must be a function`);\n }\n const slots = action?.slots ?? [\"key\"];\n if (\n !Array.isArray(slots) ||\n slots.length === 0 ||\n slots.some((s) => ![\"key\", \"sensor\", \"window\"].includes(s))\n ) {\n problems.push(`action \"${name}\": slots must list \"key\", \"sensor\" and/or \"window\"`);\n }\n for (const p of checkSchema(action?.settings ?? {}, sources)) {\n problems.push(`action \"${name}\": ${p}`);\n }\n // Action settings are stored in the config, which must stay free of secrets.\n for (const [key, field] of Object.entries(action?.settings ?? {})) {\n if (field?.type === \"secret\") {\n problems.push(`action \"${name}\": setting \"${key}\": secrets belong in the plugin settings`);\n }\n if (field?.type === \"groups\") {\n problems.push(`action \"${name}\": setting \"${key}\": groups belong in the plugin settings`);\n }\n }\n }\n\n if (def.state !== undefined) {\n if (!Array.isArray(def.state)) problems.push(\"state must be an array\");\n else {\n checkLocalIds(\"state\", def.state, problems);\n for (const s of def.state as Partial<StateDef>[]) {\n const name = typeof s?.id === \"string\" ? s.id : \"?\";\n if (typeof s?.name !== \"string\") problems.push(`state \"${name}\": name is required`);\n if (![\"number\", \"string\", \"boolean\", \"json\"].includes(s?.type as string)) {\n problems.push(`state \"${name}\": type must be number, string, boolean or json`);\n }\n problems.push(...checkNeeds(`state \"${name}\"`, s?.permissions, def.permissions));\n if (s?.poll && (typeof s.poll.read !== \"function\" || !(s.poll.everyMs > 0))) {\n problems.push(`state \"${name}\": poll needs read() and everyMs > 0`);\n }\n if (s?.start !== undefined && typeof s.start !== \"function\") {\n problems.push(`state \"${name}\": start must be a function`);\n }\n }\n }\n }\n\n if (def.triggers !== undefined) {\n if (!Array.isArray(def.triggers)) problems.push(\"triggers must be an array\");\n else {\n checkLocalIds(\"trigger\", def.triggers, problems);\n for (const t of def.triggers as Partial<Trigger>[]) {\n const name = typeof t?.id === \"string\" ? t.id : \"?\";\n if (typeof t?.name !== \"string\") problems.push(`trigger \"${name}\": name is required`);\n if (typeof t?.subscribe !== \"function\") {\n problems.push(`trigger \"${name}\": subscribe is required`);\n }\n problems.push(...checkNeeds(`trigger \"${name}\"`, t?.permissions, def.permissions));\n for (const p of checkSchema(t?.settings ?? {}, sources)) {\n problems.push(`trigger \"${name}\": ${p}`);\n }\n }\n }\n }\n return problems;\n}\n\n/** Problems with a plugin's onboarding: steps that name settings, commands or actions it lacks. */\nfunction checkOnboarding(def: Partial<PluginDef>): string[] {\n const onboarding = def.onboarding as Partial<Onboarding>;\n if (!Array.isArray(onboarding?.steps)) return [\"onboarding: steps must be an array\"];\n const problems: string[] = [];\n checkLocalIds(\"onboarding step\", onboarding.steps, problems);\n const settings = def.settings ?? {};\n const commands = new Set((def.commands ?? []).map((c) => c.id));\n for (const step of onboarding.steps as Partial<OnboardingStep>[]) {\n const name = typeof step?.id === \"string\" ? step.id : \"?\";\n if (typeof step?.title !== \"string\")\n problems.push(`onboarding step \"${name}\": title is required`);\n for (const key of step?.settings ?? []) {\n if (!(key in settings)) problems.push(`onboarding step \"${name}\": no setting \"${key}\"`);\n }\n if (step?.command !== undefined && !commands.has(step.command)) {\n problems.push(`onboarding step \"${name}\": no command \"${step.command}\"`);\n }\n if (step?.done !== undefined && typeof step.done !== \"function\") {\n problems.push(`onboarding step \"${name}\": done must be a function`);\n }\n }\n const page = onboarding.starterPage;\n if (page) {\n const actions = new Set((def.actions ?? []).map((a) => a.id));\n const used = [\n ...Object.values(page.keys ?? {}),\n ...Object.values(page.sensors ?? {}),\n ...(page.window ? [page.window] : []),\n ];\n for (const { action } of used) {\n if (!actions.has(action)) problems.push(`onboarding starter page: no action \"${action}\"`);\n }\n }\n return problems;\n}\n",
11
+ "import { PLUGIN_API_VERSION } from \"./plugin.ts\";\n\n/**\n * What makes an npm package an sdeck plugin. In its `package.json`:\n *\n * ```json\n * {\n * \"name\": \"sdeck-plugin-weather\",\n * \"version\": \"1.0.0\",\n * \"type\": \"module\",\n * \"keywords\": [\"sdeck-plugin\"],\n * \"sdeck\": { \"apiVersion\": 2, \"entry\": \"./dist/index.js\" }\n * }\n * ```\n *\n * The entry's default export is the `definePlugin(...)` result. `react`, `@sdeck/plugin`,\n * `@sdeck/app`, `@sdeck/core`, `@sdeck/engine` and `@sdeck/schema` are provided by the host: list them as peer dependencies and\n * keep them out of the bundle.\n */\nexport interface PluginManifest {\n /** Package name; also the plugin id. */\n name: string;\n version: string;\n description?: string;\n /** Path of the module to import, relative to the package (default: `main`, else `index.js`). */\n entry: string;\n apiVersion: number;\n}\n\n/** The npm keyword that lists a package in the plugin registry. */\nexport const PLUGIN_KEYWORD = \"sdeck-plugin\";\n\n/** Modules the host provides to plugins; plugins must not bundle their own copy. */\nexport const HOST_MODULES = [\n \"react\",\n \"react/jsx-runtime\",\n \"react/jsx-dev-runtime\",\n \"@sdeck/plugin\",\n \"@sdeck/app\",\n \"@sdeck/core\",\n \"@sdeck/engine\",\n \"@sdeck/schema\",\n] as const;\n\n/**\n * Plugin APIs this host loads. Version 1 plugins (actions that draw themselves) are a subset of\n * version 2 and run unchanged.\n */\nexport const SUPPORTED_API_VERSIONS: readonly number[] = [1, PLUGIN_API_VERSION];\n\nexport type ManifestResult = { ok: true; manifest: PluginManifest } | { ok: false; error: string };\n\n/** Reads the plugin manifest out of a parsed `package.json`. */\nexport function parseManifest(pkg: unknown): ManifestResult {\n if (!pkg || typeof pkg !== \"object\") return { ok: false, error: \"package.json is not an object\" };\n const p = pkg as Record<string, unknown>;\n const sdeck = p.sdeck as Record<string, unknown> | undefined;\n if (typeof p.name !== \"string\") return { ok: false, error: \"package.json has no name\" };\n if (!sdeck || typeof sdeck !== \"object\") {\n return { ok: false, error: `${p.name} is not an sdeck plugin (no \"sdeck\" field)` };\n }\n const apiVersion = sdeck.apiVersion;\n if (typeof apiVersion !== \"number\" || !SUPPORTED_API_VERSIONS.includes(apiVersion)) {\n return {\n ok: false,\n error: `${p.name} targets plugin API ${String(apiVersion)}, this host supports ${SUPPORTED_API_VERSIONS.join(\" and \")}`,\n };\n }\n const entry =\n typeof sdeck.entry === \"string\"\n ? sdeck.entry\n : typeof p.main === \"string\"\n ? p.main\n : \"index.js\";\n return {\n ok: true,\n manifest: {\n name: p.name,\n version: typeof p.version === \"string\" ? p.version : \"0.0.0\",\n ...(typeof p.description === \"string\" && { description: p.description }),\n entry,\n apiVersion,\n },\n };\n}\n",
12
+ "/** A source started on the first listener and stopped after the last one leaves. */\nexport class Shared<T> {\n readonly #listeners = new Set<(value: T) => void>();\n readonly #start: (emit: (value: T) => void) => () => void;\n #stop: (() => void) | undefined;\n #last: { value: T } | undefined;\n\n constructor(start: (emit: (value: T) => void) => () => void) {\n this.#start = start;\n }\n\n /** The latest value, if any arrived since it started. */\n get last(): T | undefined {\n return this.#last?.value;\n }\n\n listen(listener: (value: T) => void): () => void {\n this.#listeners.add(listener);\n if (!this.#stop) {\n this.#stop = this.#start((value) => {\n this.#last = { value };\n for (const l of [...this.#listeners]) l(value);\n });\n }\n return () => {\n this.#listeners.delete(listener);\n if (this.#listeners.size === 0) {\n this.#stop?.();\n this.#stop = undefined;\n this.#last = undefined;\n }\n };\n }\n}\n"
13
+ ],
14
+ "mappings": ";AAKA;;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,MACR,SAAS,OAAO,EAAE,YAAY,WAAW,EAAE,UAAU;AAAA,SACjD,OAAO,EAAE,gBAAgB,YAAY,EAAE,aAAa,EAAE,YAAY;AAAA,MACtE;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA;;AClFK,MAAM,OAAU;AAAA,EACZ,aAAa,IAAI;AAAA,EACjB;AAAA,EACT;AAAA,EACA;AAAA,EAEA,WAAW,CAAC,OAAiD;AAAA,IAC3D,KAAK,SAAS;AAAA;AAAA,MAIZ,IAAI,GAAkB;AAAA,IACxB,OAAO,KAAK,OAAO;AAAA;AAAA,EAGrB,MAAM,CAAC,UAA0C;AAAA,IAC/C,KAAK,WAAW,IAAI,QAAQ;AAAA,IAC5B,IAAI,CAAC,KAAK,OAAO;AAAA,MACf,KAAK,QAAQ,KAAK,OAAO,CAAC,UAAU;AAAA,QAClC,KAAK,QAAQ,EAAE,MAAM;AAAA,QACrB,WAAW,KAAK,CAAC,GAAG,KAAK,UAAU;AAAA,UAAG,EAAE,KAAK;AAAA,OAC9C;AAAA,IACH;AAAA,IACA,OAAO,MAAM;AAAA,MACX,KAAK,WAAW,OAAO,QAAQ;AAAA,MAC/B,IAAI,KAAK,WAAW,SAAS,GAAG;AAAA,QAC9B,KAAK,QAAQ;AAAA,QACb,KAAK,QAAQ;AAAA,QACb,KAAK,QAAQ;AAAA,MACf;AAAA;AAAA;AAGN;",
15
+ "debugId": "C5D6970438DF66E064756E2164756E21",
16
+ "names": []
17
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * What makes an npm package an sdeck plugin. In its `package.json`:
3
+ *
4
+ * ```json
5
+ * {
6
+ * "name": "sdeck-plugin-weather",
7
+ * "version": "1.0.0",
8
+ * "type": "module",
9
+ * "keywords": ["sdeck-plugin"],
10
+ * "sdeck": { "apiVersion": 2, "entry": "./dist/index.js" }
11
+ * }
12
+ * ```
13
+ *
14
+ * The entry's default export is the `definePlugin(...)` result. `react`, `@sdeck/plugin`,
15
+ * `@sdeck/app`, `@sdeck/core`, `@sdeck/engine` and `@sdeck/schema` are provided by the host: list them as peer dependencies and
16
+ * keep them out of the bundle.
17
+ */
18
+ export interface PluginManifest {
19
+ /** Package name; also the plugin id. */
20
+ name: string;
21
+ version: string;
22
+ description?: string;
23
+ /** Path of the module to import, relative to the package (default: `main`, else `index.js`). */
24
+ entry: string;
25
+ apiVersion: number;
26
+ }
27
+ /** The npm keyword that lists a package in the plugin registry. */
28
+ export declare const PLUGIN_KEYWORD = "sdeck-plugin";
29
+ /** Modules the host provides to plugins; plugins must not bundle their own copy. */
30
+ export declare const HOST_MODULES: readonly ["react", "react/jsx-runtime", "react/jsx-dev-runtime", "@sdeck/plugin", "@sdeck/app", "@sdeck/core", "@sdeck/engine", "@sdeck/schema"];
31
+ /**
32
+ * Plugin APIs this host loads. Version 1 plugins (actions that draw themselves) are a subset of
33
+ * version 2 and run unchanged.
34
+ */
35
+ export declare const SUPPORTED_API_VERSIONS: readonly number[];
36
+ export type ManifestResult = {
37
+ ok: true;
38
+ manifest: PluginManifest;
39
+ } | {
40
+ ok: false;
41
+ error: string;
42
+ };
43
+ /** Reads the plugin manifest out of a parsed `package.json`. */
44
+ export declare function parseManifest(pkg: unknown): ManifestResult;
45
+ //# sourceMappingURL=manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,cAAc;IAC7B,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gGAAgG;IAChG,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,mEAAmE;AACnE,eAAO,MAAM,cAAc,iBAAiB,CAAC;AAE7C,oFAAoF;AACpF,eAAO,MAAM,YAAY,YACvB,OAAO,EACP,mBAAmB,EACnB,uBAAuB,EACvB,eAAe,EACf,YAAY,EACZ,aAAa,EACb,eAAe,EACf,eAAe,CACP,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAAS,MAAM,EAA4B,CAAC;AAEjF,MAAM,MAAM,cAAc,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,cAAc,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnG,gEAAgE;AAChE,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,cAAc,CA+B1D"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * What a plugin can ask to do. The user decides about each permission separately, and a plugin
3
+ * gets nothing it did not ask for and nothing the user did not allow.
4
+ */
5
+ export type Permission = "network" | "filesystem" | "process" | "shell" | "input" | "clipboard" | "audio" | "environment" | "variables" | "state" | "actions" | "native";
6
+ /** A permission as the user reads it. */
7
+ export interface PermissionText {
8
+ name: string;
9
+ /** What allowing it makes possible. */
10
+ description: string;
11
+ /** Finishes "the plugin is not allowed to …". */
12
+ action: string;
13
+ /** Allowing it lets the plugin do nearly anything the user can. */
14
+ powerful?: boolean;
15
+ }
16
+ /** Every permission, in the order the UI lists them. */
17
+ export declare const PERMISSION_TEXTS: Readonly<Record<Permission, PermissionText>>;
18
+ export declare const PERMISSIONS: readonly Permission[];
19
+ /** Thrown when a plugin does something the user has not allowed. The message is for the user. */
20
+ export declare class PermissionError extends Error {
21
+ readonly permission: Permission;
22
+ readonly name = "PermissionError";
23
+ /** As Node's file system reports a refused path, so libraries treat it the same way. */
24
+ readonly code = "EACCES";
25
+ constructor(
26
+ /** The plugin's name or id. */
27
+ plugin: string, permission: Permission,
28
+ /** What was refused, when that helps (a path, an address). */
29
+ detail?: string);
30
+ }
31
+ //# sourceMappingURL=permissions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,UAAU,GAClB,SAAS,GACT,YAAY,GACZ,SAAS,GACT,OAAO,GACP,OAAO,GACP,WAAW,GACX,OAAO,GACP,aAAa,GACb,WAAW,GACX,OAAO,GACP,SAAS,GACT,QAAQ,CAAC;AAEb,yCAAyC;AACzC,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,mEAAmE;IACnE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wDAAwD;AACxD,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,cAAc,CAAC,CAiEzE,CAAC;AAEF,eAAO,MAAM,WAAW,EAAoC,SAAS,UAAU,EAAE,CAAC;AAElF,iGAAiG;AACjG,qBAAa,eAAgB,SAAQ,KAAK;IAQtC,QAAQ,CAAC,UAAU,EAAE,UAAU;IAPjC,SAAkB,IAAI,qBAAqB;IAC3C,wFAAwF;IACxF,QAAQ,CAAC,IAAI,YAAY;IAEzB;IACE,+BAA+B;IAC/B,MAAM,EAAE,MAAM,EACL,UAAU,EAAE,UAAU;IAC/B,8DAA8D;IAC9D,MAAM,CAAC,EAAE,MAAM,EAOhB;CACF"}
@@ -0,0 +1,332 @@
1
+ import type { SlotInfo } from "@sdeck/app";
2
+ import type { ExecSource, StateValueType } from "@sdeck/engine";
3
+ import type { Look, NavigateTarget } from "@sdeck/schema";
4
+ import type { ComponentType } from "react";
5
+ import { type Permission } from "./permissions.ts";
6
+ import { type InferSettings, type SelectOption, type SettingsSchema } from "./settings.ts";
7
+ /** Bumped when the plugin contract changes incompatibly. Hosts refuse plugins built for another. */
8
+ export declare const PLUGIN_API_VERSION = 2;
9
+ /** Where an action can be placed. */
10
+ export type SlotKind = "key" | "sensor" | "window";
11
+ /** Given to a plugin's `activate`, its actions, state providers and triggers. */
12
+ export interface PluginContext {
13
+ readonly pluginId: string;
14
+ /** Prefix of this plugin's state keys and events (`system` → `system.cpu`). */
15
+ readonly namespace: string;
16
+ /** A writable directory for this plugin's own files (created on first use). */
17
+ readonly dataDir: string;
18
+ /** Logs to the host, tagged with the plugin id. */
19
+ log(...args: unknown[]): void;
20
+ /** The plugin's own settings (secrets included), resolved against `PluginDef.settings`. */
21
+ settings(): Record<string, unknown>;
22
+ /** Called after the plugin's settings change; returns a function that stops. */
23
+ onSettings(listener: () => void): () => void;
24
+ /** Values the plugin keeps private between runs (tokens it obtained, for example). */
25
+ readonly secrets: {
26
+ get(key: string): string | undefined;
27
+ set(key: string, value: string | undefined): Promise<void>;
28
+ };
29
+ /** Shown with the plugin in the UI (`Connected`, `Sign in to continue`). `undefined` clears. */
30
+ status(text: string | undefined, level?: StatusLevel): void;
31
+ /** Live state: `set` publishes `<namespace>.<id>`, `get` reads any key (`system.cpu`). */
32
+ readonly state: {
33
+ set(id: string, value: unknown): void;
34
+ /** Keys of other plugins need the `state` permission. */
35
+ get(key: string): unknown;
36
+ };
37
+ /** Emits `<namespace>:<event>` on the event bus (workflows can trigger on it). */
38
+ emit(event: string, payload?: unknown): void;
39
+ /** Global user variables. Needs the `variables` permission. */
40
+ readonly vars: {
41
+ get(name: string): unknown;
42
+ set(name: string, value: unknown): void;
43
+ };
44
+ }
45
+ /** How a plugin's status reads: fine, needing attention, or failing. */
46
+ export type StatusLevel = "ok" | "info" | "error";
47
+ /** Something the user can run from the plugin's settings (sign in, reconnect). */
48
+ export interface PluginCommand {
49
+ /** Unique within the plugin. */
50
+ id: string;
51
+ name: string;
52
+ description?: string;
53
+ /**
54
+ * What it needs, out of the plugin's `permissions` (default: all of them; `[]` for nothing).
55
+ * Without them it is refused.
56
+ */
57
+ permissions?: readonly Permission[];
58
+ /** What it returns, if a string, is opened in the user's browser. Throw to fail. */
59
+ run(context: PluginContext): unknown | Promise<unknown>;
60
+ }
61
+ /**
62
+ * One step of setting a plugin up. Studio walks the user through the steps right after the plugin
63
+ * is installed, and again from its "Get started" button.
64
+ */
65
+ export interface OnboardingStep {
66
+ /** Unique within the plugin's steps. */
67
+ id: string;
68
+ title: string;
69
+ /**
70
+ * What to do, in plain words. Blank lines start paragraphs; `**bold**`, `` `code` `` and
71
+ * `[links](https://…)` work.
72
+ */
73
+ body?: string;
74
+ /** The plugin's own settings this step asks for, by key (secrets too). */
75
+ settings?: readonly string[];
76
+ /** One of the plugin's commands, run from a button in this step (sign in, find devices). */
77
+ command?: string;
78
+ /** A web page to open, such as where to create an API key. */
79
+ link?: {
80
+ label: string;
81
+ url: string;
82
+ };
83
+ /**
84
+ * Whether the step is done: a key is saved, the sign-in went through. Without it, a step that
85
+ * asks for settings is done once they all have a value.
86
+ */
87
+ done?(context: PluginContext): boolean | Promise<boolean>;
88
+ /** Not needed to use the plugin (Bluetooth lights need no cloud key). */
89
+ optional?: boolean;
90
+ }
91
+ /** Keys a plugin offers as a page of their own at the end of onboarding. */
92
+ export interface StarterPage {
93
+ /** The page's name (default: the plugin's). */
94
+ name?: string;
95
+ /** By key index: the action's id and settings. */
96
+ keys: Readonly<Record<number, {
97
+ action: string;
98
+ settings?: Record<string, unknown>;
99
+ }>>;
100
+ sensors?: Readonly<Record<number, {
101
+ action: string;
102
+ settings?: Record<string, unknown>;
103
+ }>>;
104
+ window?: {
105
+ action: string;
106
+ settings?: Record<string, unknown>;
107
+ };
108
+ }
109
+ /** How a plugin is set up after it is installed. */
110
+ export interface Onboarding {
111
+ /** A sentence or two shown before the steps. */
112
+ intro?: string;
113
+ steps: readonly OnboardingStep[];
114
+ /**
115
+ * The page of keys offered at the end. By default the plugin's first eight actions for keys;
116
+ * `false` offers none.
117
+ */
118
+ starterPage?: StarterPage | false;
119
+ }
120
+ /** Props of an action's component. */
121
+ export interface ActionProps<S extends SettingsSchema = SettingsSchema> {
122
+ /** This placement's settings, resolved against the schema (always complete and typed). */
123
+ settings: InferSettings<S>;
124
+ /** Saves changed settings for this placement (persisted and shown in the UI). */
125
+ setSettings(patch: Partial<InferSettings<S>>): void;
126
+ /** Where the action is drawn. */
127
+ slot: SlotInfo;
128
+ plugin: PluginContext;
129
+ }
130
+ /** Given to an action's `run`. */
131
+ export interface RunContext<S extends SettingsSchema = SettingsSchema> {
132
+ /** Settings with `{{templates}}` already resolved, then checked against the schema. */
133
+ settings: InferSettings<S>;
134
+ plugin: PluginContext;
135
+ /** What started the run (a key, a trigger, a workflow…). */
136
+ source: ExecSource;
137
+ /** Aborted when the execution is cancelled. Long work should stop. */
138
+ signal: AbortSignal;
139
+ /** The triggering event's payload, if any. */
140
+ event: unknown;
141
+ /** Controls of the deck the run started on (every deck, for triggers and workflows). */
142
+ deck: DeckControls;
143
+ }
144
+ /** What a headless action can do to the decks. */
145
+ export interface DeckControls {
146
+ /** Moves between pages, as a `navigate` workflow step does. Throws for an unknown page. */
147
+ navigate(to: NavigateTarget, page?: string, options?: {
148
+ wrap?: boolean;
149
+ }): void;
150
+ /** The current brightness (0–100). */
151
+ brightness(): number;
152
+ /** Sets the brightness (0–100). */
153
+ setBrightness(level: number): Promise<void>;
154
+ }
155
+ /**
156
+ * What `run` gives back. `undo` reverts what the run did; it is recorded in the action history
157
+ * and used by toggle buttons and the `undo` step.
158
+ */
159
+ export interface RunOutcome {
160
+ result?: unknown;
161
+ undo?: () => unknown;
162
+ /** Summary for the history, e.g. `Volume 30%`. */
163
+ label?: string;
164
+ }
165
+ export type RunResult = RunOutcome | undefined;
166
+ export interface ActionDef<S extends SettingsSchema = SettingsSchema> {
167
+ /** Unique within the plugin, e.g. `"clock"`. */
168
+ id: string;
169
+ name: string;
170
+ description?: string;
171
+ /** Groups actions in the picker (default: the plugin's name). */
172
+ category?: string;
173
+ /**
174
+ * Icon for the UI: a [lucide](https://lucide.dev/icons) icon name in kebab case (`"timer"`),
175
+ * or an image URL / `data:` URI.
176
+ */
177
+ icon?: string;
178
+ /** Slot kinds the action supports (default: keys only). */
179
+ slots?: readonly SlotKind[];
180
+ /** Settings shown in the UI, as a form. */
181
+ settings?: S;
182
+ /**
183
+ * What it needs, out of the plugin's `permissions` (default: all of them; `[]` for nothing).
184
+ * Without them it cannot run or draw itself.
185
+ */
186
+ permissions?: readonly Permission[];
187
+ /**
188
+ * It only shows something. It is offered for buttons, but not as a step of a workflow or
189
+ * gesture, and needs no `run`.
190
+ */
191
+ display?: boolean;
192
+ /**
193
+ * Does the work, without drawing anything: it can run from a key, a trigger or a workflow.
194
+ * Throw to fail. An action needs `run`, `component`, or both, unless it is `display`.
195
+ */
196
+ run?(context: RunContext<S>): RunResult | void | Promise<RunResult | void>;
197
+ /**
198
+ * Draws the action itself (it then handles its own input). It runs inside the deck's React
199
+ * tree, so the `@sdeck/app` hooks and components work as in any app. Without it, the host
200
+ * draws the button's look and runs `run` on press.
201
+ */
202
+ component?: ComponentType<ActionProps<S>>;
203
+ /** The look a new button with this action starts with (default: its name on a dark key). */
204
+ look?(settings: InferSettings<S>): Look;
205
+ }
206
+ export type RunFn = (context: RunContext) => RunResult | undefined | Promise<RunResult | undefined>;
207
+ /** An action with its settings type erased, as stored on a plugin. */
208
+ export interface Action {
209
+ readonly id: string;
210
+ readonly name: string;
211
+ readonly description?: string;
212
+ readonly category?: string;
213
+ readonly icon?: string;
214
+ readonly slots: readonly SlotKind[];
215
+ readonly settings: SettingsSchema;
216
+ readonly permissions?: readonly Permission[];
217
+ readonly display?: boolean;
218
+ readonly run?: RunFn;
219
+ readonly component?: ComponentType<ActionProps>;
220
+ readonly look?: (settings: Record<string, unknown>) => Look;
221
+ }
222
+ /** A live value the plugin publishes as `<namespace>.<id>`. */
223
+ export interface StateDef {
224
+ /** Letters, digits, `-`, `_` and `.` (`cpu`, `core.0`). */
225
+ id: string;
226
+ name: string;
227
+ type: StateValueType;
228
+ unit?: string;
229
+ description?: string;
230
+ /**
231
+ * What reading it needs, out of the plugin's `permissions` (default: all of them; `[]` for nothing).
232
+ * Without them it has no value.
233
+ */
234
+ permissions?: readonly Permission[];
235
+ /** Read every `everyMs` while something shows or waits on the value. */
236
+ poll?: {
237
+ everyMs: number;
238
+ read(context: PluginContext): unknown | Promise<unknown>;
239
+ };
240
+ /** Push updates while watched; return a stop function. */
241
+ start?(set: (value: unknown) => void, context: PluginContext): (() => void) | void;
242
+ }
243
+ /** Given to a trigger's `subscribe`. */
244
+ export interface TriggerContext<S extends SettingsSchema = SettingsSchema> {
245
+ settings: InferSettings<S>;
246
+ plugin: PluginContext;
247
+ /** Starts the trigger's workflow; `event` becomes `event` in its expressions. */
248
+ fire(event?: unknown): void;
249
+ }
250
+ export interface TriggerDef<S extends SettingsSchema = SettingsSchema> {
251
+ /** Unique within the plugin; the trigger type is `<plugin id>:<id>`. */
252
+ id: string;
253
+ name: string;
254
+ description?: string;
255
+ settings?: S;
256
+ /**
257
+ * What it needs, out of the plugin's `permissions` (default: all of them; `[]` for nothing).
258
+ * Without them it never fires.
259
+ */
260
+ permissions?: readonly Permission[];
261
+ /** Starts watching; returns a function that stops. */
262
+ subscribe(context: TriggerContext<S>): (() => void) | void;
263
+ }
264
+ export interface Trigger {
265
+ readonly id: string;
266
+ readonly name: string;
267
+ readonly description?: string;
268
+ readonly settings: SettingsSchema;
269
+ readonly permissions?: readonly Permission[];
270
+ readonly subscribe: (context: TriggerContext) => (() => void) | undefined;
271
+ }
272
+ /**
273
+ * Fills fields that name it in `source` (OBS scenes, audio devices…). `settings` holds the
274
+ * fields the asking field `dependsOn` (a server whose channels to list).
275
+ */
276
+ export type OptionSource = (context: PluginContext, settings: Readonly<Record<string, unknown>>) => SelectOption[] | Promise<SelectOption[]>;
277
+ /** Undoes what `activate` did. */
278
+ export type Deactivate = () => void | Promise<void>;
279
+ export interface PluginDef {
280
+ /** Unique id; for an installed plugin this must be its package name. */
281
+ id: string;
282
+ name: string;
283
+ /** Semver version. */
284
+ version: string;
285
+ description?: string;
286
+ author?: string;
287
+ homepage?: string;
288
+ /** State key and event prefix (default: derived from the id, `@sdeck/plugin-system` → `system`). */
289
+ namespace?: string;
290
+ actions: readonly Action[];
291
+ state?: readonly StateDef[];
292
+ triggers?: readonly Trigger[];
293
+ optionSources?: Readonly<Record<string, OptionSource>>;
294
+ /**
295
+ * Everything the plugin asks to be allowed to do. The user decides about each one, and can
296
+ * change their mind at any time: handle being refused. What is not listed is never allowed.
297
+ */
298
+ permissions?: readonly Permission[];
299
+ /** The plugin's own settings (a server address, a token), shown on its page. */
300
+ settings?: SettingsSchema;
301
+ /** Buttons in the plugin's settings. */
302
+ commands?: readonly PluginCommand[];
303
+ /**
304
+ * How to set the plugin up, step by step, shown after it is installed. Without it, Studio asks
305
+ * for the plugin's settings and offers its commands in one step.
306
+ */
307
+ onboarding?: Onboarding;
308
+ /** Runs when the plugin is enabled (and when the host starts). May return a cleanup. */
309
+ activate?(context: PluginContext): void | Deactivate | Promise<void | Deactivate>;
310
+ }
311
+ /** The namespace a plugin's state and events use. */
312
+ export declare function pluginNamespace(def: Pick<PluginDef, "id" | "namespace">): string;
313
+ /**
314
+ * Defines an action. `settings` is inferred, so `run` and `component` get typed settings:
315
+ *
316
+ * ```ts
317
+ * export const hello = defineAction({
318
+ * id: "hello",
319
+ * name: "Hello",
320
+ * settings: { name: { type: "text", label: "Name", default: "world" } },
321
+ * run: ({ settings, plugin }) => plugin.log(`Hi ${settings.name}`),
322
+ * });
323
+ * ```
324
+ */
325
+ export declare function defineAction<const S extends SettingsSchema = Record<never, never>>(def: ActionDef<S>): Action;
326
+ /** Defines a trigger type with typed settings. */
327
+ export declare function defineTrigger<const S extends SettingsSchema = Record<never, never>>(def: TriggerDef<S>): Trigger;
328
+ /** Defines a plugin, checking it. A plugin module's default export must be one of these. */
329
+ export declare function definePlugin(def: PluginDef): PluginDef;
330
+ /** Problems with something that should be a plugin (empty when it is fine). */
331
+ export declare function checkPlugin(value: unknown): string[];
332
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"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