@sdeck/plugin 0.0.0-stage → 0.1.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.
- package/dist/bridge.d.ts +42 -0
- package/dist/bridge.d.ts.map +1 -0
- package/dist/connection.d.ts +44 -0
- package/dist/connection.d.ts.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3352 -0
- package/dist/index.js.map +37 -0
- package/dist/manifest.d.ts +45 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/plugin.d.ts +304 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/settings.d.ts +107 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/shared.d.ts +9 -0
- package/dist/shared.d.ts.map +1 -0
- package/package.json +41 -4
- package/src/bridge.ts +128 -0
- package/src/connection.ts +206 -0
- package/src/index.ts +83 -0
- package/src/manifest.ts +85 -0
- package/src/plugin.ts +541 -0
- package/src/settings.ts +232 -0
- package/src/shared.ts +34 -0
- package/README.md +0 -3
|
@@ -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"}
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
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 InferSettings, type SelectOption, type SettingsSchema } from "./settings.ts";
|
|
6
|
+
/** Bumped when the plugin contract changes incompatibly. Hosts refuse plugins built for another. */
|
|
7
|
+
export declare const PLUGIN_API_VERSION = 2;
|
|
8
|
+
/** Where an action can be placed. */
|
|
9
|
+
export type SlotKind = "key" | "sensor" | "window";
|
|
10
|
+
/**
|
|
11
|
+
* What a plugin declares it does. Shown to the user before enabling it. Plugins run in the host
|
|
12
|
+
* process, so this is information, not a sandbox.
|
|
13
|
+
*/
|
|
14
|
+
export type Permission = "shell" | "process" | "filesystem" | "network" | "input" | "audio" | "clipboard";
|
|
15
|
+
export declare const PERMISSIONS: readonly Permission[];
|
|
16
|
+
/** Given to a plugin's `activate`, its actions, state providers and triggers. */
|
|
17
|
+
export interface PluginContext {
|
|
18
|
+
readonly pluginId: string;
|
|
19
|
+
/** Prefix of this plugin's state keys and events (`system` → `system.cpu`). */
|
|
20
|
+
readonly namespace: string;
|
|
21
|
+
/** A writable directory for this plugin's own files (created on first use). */
|
|
22
|
+
readonly dataDir: string;
|
|
23
|
+
/** Logs to the host, tagged with the plugin id. */
|
|
24
|
+
log(...args: unknown[]): void;
|
|
25
|
+
/** The plugin's own settings (secrets included), resolved against `PluginDef.settings`. */
|
|
26
|
+
settings(): Record<string, unknown>;
|
|
27
|
+
/** Called after the plugin's settings change; returns a function that stops. */
|
|
28
|
+
onSettings(listener: () => void): () => void;
|
|
29
|
+
/** Values the plugin keeps private between runs (tokens it obtained, for example). */
|
|
30
|
+
readonly secrets: {
|
|
31
|
+
get(key: string): string | undefined;
|
|
32
|
+
set(key: string, value: string | undefined): Promise<void>;
|
|
33
|
+
};
|
|
34
|
+
/** Shown with the plugin in the UI (`Connected`, `Sign in to continue`). `undefined` clears. */
|
|
35
|
+
status(text: string | undefined, level?: StatusLevel): void;
|
|
36
|
+
/** Live state: `set` publishes `<namespace>.<id>`, `get` reads any key (`system.cpu`). */
|
|
37
|
+
readonly state: {
|
|
38
|
+
set(id: string, value: unknown): void;
|
|
39
|
+
get(key: string): unknown;
|
|
40
|
+
};
|
|
41
|
+
/** Emits `<namespace>:<event>` on the event bus (workflows can trigger on it). */
|
|
42
|
+
emit(event: string, payload?: unknown): void;
|
|
43
|
+
/** Global user variables. */
|
|
44
|
+
readonly vars: {
|
|
45
|
+
get(name: string): unknown;
|
|
46
|
+
set(name: string, value: unknown): void;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** How a plugin's status reads: fine, needing attention, or failing. */
|
|
50
|
+
export type StatusLevel = "ok" | "info" | "error";
|
|
51
|
+
/** Something the user can run from the plugin's page (sign in, reconnect). */
|
|
52
|
+
export interface PluginCommand {
|
|
53
|
+
/** Unique within the plugin. */
|
|
54
|
+
id: string;
|
|
55
|
+
name: string;
|
|
56
|
+
description?: string;
|
|
57
|
+
/** What it returns, if a string, is opened in the user's browser. Throw to fail. */
|
|
58
|
+
run(context: PluginContext): unknown | Promise<unknown>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* One step of setting a plugin up. Studio walks the user through the steps right after the plugin
|
|
62
|
+
* is installed, and again from its "Get started" button.
|
|
63
|
+
*/
|
|
64
|
+
export interface OnboardingStep {
|
|
65
|
+
/** Unique within the plugin's steps. */
|
|
66
|
+
id: string;
|
|
67
|
+
title: string;
|
|
68
|
+
/**
|
|
69
|
+
* What to do, in plain words. Blank lines start paragraphs; `**bold**`, `` `code` `` and
|
|
70
|
+
* `[links](https://…)` work.
|
|
71
|
+
*/
|
|
72
|
+
body?: string;
|
|
73
|
+
/** The plugin's own settings this step asks for, by key (secrets too). */
|
|
74
|
+
settings?: readonly string[];
|
|
75
|
+
/** One of the plugin's commands, run from a button in this step (sign in, find devices). */
|
|
76
|
+
command?: string;
|
|
77
|
+
/** A web page to open, such as where to create an API key. */
|
|
78
|
+
link?: {
|
|
79
|
+
label: string;
|
|
80
|
+
url: string;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Whether the step is done: a key is saved, the sign-in went through. Without it, a step that
|
|
84
|
+
* asks for settings is done once they all have a value.
|
|
85
|
+
*/
|
|
86
|
+
done?(context: PluginContext): boolean | Promise<boolean>;
|
|
87
|
+
/** Not needed to use the plugin (Bluetooth lights need no cloud key). */
|
|
88
|
+
optional?: boolean;
|
|
89
|
+
}
|
|
90
|
+
/** Keys a plugin offers as a page of their own at the end of onboarding. */
|
|
91
|
+
export interface StarterPage {
|
|
92
|
+
/** The page's name (default: the plugin's). */
|
|
93
|
+
name?: string;
|
|
94
|
+
/** By key index: the action's id and settings. */
|
|
95
|
+
keys: Readonly<Record<number, {
|
|
96
|
+
action: string;
|
|
97
|
+
settings?: Record<string, unknown>;
|
|
98
|
+
}>>;
|
|
99
|
+
sensors?: Readonly<Record<number, {
|
|
100
|
+
action: string;
|
|
101
|
+
settings?: Record<string, unknown>;
|
|
102
|
+
}>>;
|
|
103
|
+
window?: {
|
|
104
|
+
action: string;
|
|
105
|
+
settings?: Record<string, unknown>;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/** How a plugin is set up after it is installed. */
|
|
109
|
+
export interface Onboarding {
|
|
110
|
+
/** A sentence or two shown before the steps. */
|
|
111
|
+
intro?: string;
|
|
112
|
+
steps: readonly OnboardingStep[];
|
|
113
|
+
/**
|
|
114
|
+
* The page of keys offered at the end. By default the plugin's first eight actions for keys;
|
|
115
|
+
* `false` offers none.
|
|
116
|
+
*/
|
|
117
|
+
starterPage?: StarterPage | false;
|
|
118
|
+
}
|
|
119
|
+
/** Props of an action's component. */
|
|
120
|
+
export interface ActionProps<S extends SettingsSchema = SettingsSchema> {
|
|
121
|
+
/** This placement's settings, resolved against the schema (always complete and typed). */
|
|
122
|
+
settings: InferSettings<S>;
|
|
123
|
+
/** Saves changed settings for this placement (persisted and shown in the UI). */
|
|
124
|
+
setSettings(patch: Partial<InferSettings<S>>): void;
|
|
125
|
+
/** Where the action is drawn. */
|
|
126
|
+
slot: SlotInfo;
|
|
127
|
+
plugin: PluginContext;
|
|
128
|
+
}
|
|
129
|
+
/** Given to an action's `run`. */
|
|
130
|
+
export interface RunContext<S extends SettingsSchema = SettingsSchema> {
|
|
131
|
+
/** Settings with `{{templates}}` already resolved, then checked against the schema. */
|
|
132
|
+
settings: InferSettings<S>;
|
|
133
|
+
plugin: PluginContext;
|
|
134
|
+
/** What started the run (a key, a trigger, a workflow…). */
|
|
135
|
+
source: ExecSource;
|
|
136
|
+
/** Aborted when the execution is cancelled. Long work should stop. */
|
|
137
|
+
signal: AbortSignal;
|
|
138
|
+
/** The triggering event's payload, if any. */
|
|
139
|
+
event: unknown;
|
|
140
|
+
/** Controls of the deck the run started on (every deck, for triggers and workflows). */
|
|
141
|
+
deck: DeckControls;
|
|
142
|
+
}
|
|
143
|
+
/** What a headless action can do to the decks. */
|
|
144
|
+
export interface DeckControls {
|
|
145
|
+
/** Moves between pages, as a `navigate` workflow step does. Throws for an unknown page. */
|
|
146
|
+
navigate(to: NavigateTarget, page?: string, options?: {
|
|
147
|
+
wrap?: boolean;
|
|
148
|
+
}): void;
|
|
149
|
+
/** The current brightness (0–100). */
|
|
150
|
+
brightness(): number;
|
|
151
|
+
/** Sets the brightness (0–100). */
|
|
152
|
+
setBrightness(level: number): Promise<void>;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* What `run` gives back. `undo` reverts what the run did; it is recorded in the action history
|
|
156
|
+
* and used by toggle buttons and the `undo` step.
|
|
157
|
+
*/
|
|
158
|
+
export interface RunOutcome {
|
|
159
|
+
result?: unknown;
|
|
160
|
+
undo?: () => unknown;
|
|
161
|
+
/** Summary for the history, e.g. `Volume 30%`. */
|
|
162
|
+
label?: string;
|
|
163
|
+
}
|
|
164
|
+
export type RunResult = RunOutcome | undefined;
|
|
165
|
+
export interface ActionDef<S extends SettingsSchema = SettingsSchema> {
|
|
166
|
+
/** Unique within the plugin, e.g. `"clock"`. */
|
|
167
|
+
id: string;
|
|
168
|
+
name: string;
|
|
169
|
+
description?: string;
|
|
170
|
+
/** Groups actions in the picker (default: the plugin's name). */
|
|
171
|
+
category?: string;
|
|
172
|
+
/**
|
|
173
|
+
* Icon for the UI: a [lucide](https://lucide.dev/icons) icon name in kebab case (`"timer"`),
|
|
174
|
+
* or an image URL / `data:` URI.
|
|
175
|
+
*/
|
|
176
|
+
icon?: string;
|
|
177
|
+
/** Slot kinds the action supports (default: keys only). */
|
|
178
|
+
slots?: readonly SlotKind[];
|
|
179
|
+
/** Settings shown in the UI, as a form. */
|
|
180
|
+
settings?: S;
|
|
181
|
+
/**
|
|
182
|
+
* Does the work, without drawing anything: it can run from a key, a trigger or a workflow.
|
|
183
|
+
* Throw to fail. An action needs `run`, `component`, or both.
|
|
184
|
+
*/
|
|
185
|
+
run?(context: RunContext<S>): RunResult | void | Promise<RunResult | void>;
|
|
186
|
+
/**
|
|
187
|
+
* Draws the action itself (it then handles its own input). It runs inside the deck's React
|
|
188
|
+
* tree, so the `@sdeck/app` hooks and components work as in any app. Without it, the host
|
|
189
|
+
* draws the button's look and runs `run` on press.
|
|
190
|
+
*/
|
|
191
|
+
component?: ComponentType<ActionProps<S>>;
|
|
192
|
+
/** The look a new button with this action starts with (default: its name on a dark key). */
|
|
193
|
+
look?(settings: InferSettings<S>): Look;
|
|
194
|
+
}
|
|
195
|
+
export type RunFn = (context: RunContext) => RunResult | undefined | Promise<RunResult | undefined>;
|
|
196
|
+
/** An action with its settings type erased, as stored on a plugin. */
|
|
197
|
+
export interface Action {
|
|
198
|
+
readonly id: string;
|
|
199
|
+
readonly name: string;
|
|
200
|
+
readonly description?: string;
|
|
201
|
+
readonly category?: string;
|
|
202
|
+
readonly icon?: string;
|
|
203
|
+
readonly slots: readonly SlotKind[];
|
|
204
|
+
readonly settings: SettingsSchema;
|
|
205
|
+
readonly run?: RunFn;
|
|
206
|
+
readonly component?: ComponentType<ActionProps>;
|
|
207
|
+
readonly look?: (settings: Record<string, unknown>) => Look;
|
|
208
|
+
}
|
|
209
|
+
/** A live value the plugin publishes as `<namespace>.<id>`. */
|
|
210
|
+
export interface StateDef {
|
|
211
|
+
/** Letters, digits, `-`, `_` and `.` (`cpu`, `core.0`). */
|
|
212
|
+
id: string;
|
|
213
|
+
name: string;
|
|
214
|
+
type: StateValueType;
|
|
215
|
+
unit?: string;
|
|
216
|
+
description?: string;
|
|
217
|
+
/** Read every `everyMs` while something shows or waits on the value. */
|
|
218
|
+
poll?: {
|
|
219
|
+
everyMs: number;
|
|
220
|
+
read(context: PluginContext): unknown | Promise<unknown>;
|
|
221
|
+
};
|
|
222
|
+
/** Push updates while watched; return a stop function. */
|
|
223
|
+
start?(set: (value: unknown) => void, context: PluginContext): (() => void) | void;
|
|
224
|
+
}
|
|
225
|
+
/** Given to a trigger's `subscribe`. */
|
|
226
|
+
export interface TriggerContext<S extends SettingsSchema = SettingsSchema> {
|
|
227
|
+
settings: InferSettings<S>;
|
|
228
|
+
plugin: PluginContext;
|
|
229
|
+
/** Starts the trigger's workflow; `event` becomes `event` in its expressions. */
|
|
230
|
+
fire(event?: unknown): void;
|
|
231
|
+
}
|
|
232
|
+
export interface TriggerDef<S extends SettingsSchema = SettingsSchema> {
|
|
233
|
+
/** Unique within the plugin; the trigger type is `<plugin id>:<id>`. */
|
|
234
|
+
id: string;
|
|
235
|
+
name: string;
|
|
236
|
+
description?: string;
|
|
237
|
+
settings?: S;
|
|
238
|
+
/** Starts watching; returns a function that stops. */
|
|
239
|
+
subscribe(context: TriggerContext<S>): (() => void) | void;
|
|
240
|
+
}
|
|
241
|
+
export interface Trigger {
|
|
242
|
+
readonly id: string;
|
|
243
|
+
readonly name: string;
|
|
244
|
+
readonly description?: string;
|
|
245
|
+
readonly settings: SettingsSchema;
|
|
246
|
+
readonly subscribe: (context: TriggerContext) => (() => void) | undefined;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Fills fields that name it in `source` (OBS scenes, audio devices…). `settings` holds the
|
|
250
|
+
* fields the asking field `dependsOn` (a server whose channels to list).
|
|
251
|
+
*/
|
|
252
|
+
export type OptionSource = (context: PluginContext, settings: Readonly<Record<string, unknown>>) => SelectOption[] | Promise<SelectOption[]>;
|
|
253
|
+
/** Undoes what `activate` did. */
|
|
254
|
+
export type Deactivate = () => void | Promise<void>;
|
|
255
|
+
export interface PluginDef {
|
|
256
|
+
/** Unique id; for an installed plugin this must be its package name. */
|
|
257
|
+
id: string;
|
|
258
|
+
name: string;
|
|
259
|
+
/** Semver version. */
|
|
260
|
+
version: string;
|
|
261
|
+
description?: string;
|
|
262
|
+
author?: string;
|
|
263
|
+
homepage?: string;
|
|
264
|
+
/** State key and event prefix (default: derived from the id, `@sdeck/plugin-system` → `system`). */
|
|
265
|
+
namespace?: string;
|
|
266
|
+
actions: readonly Action[];
|
|
267
|
+
state?: readonly StateDef[];
|
|
268
|
+
triggers?: readonly Trigger[];
|
|
269
|
+
optionSources?: Readonly<Record<string, OptionSource>>;
|
|
270
|
+
permissions?: readonly Permission[];
|
|
271
|
+
/** The plugin's own settings (a server address, a token), shown on its page. */
|
|
272
|
+
settings?: SettingsSchema;
|
|
273
|
+
/** Buttons on the plugin's page. */
|
|
274
|
+
commands?: readonly PluginCommand[];
|
|
275
|
+
/**
|
|
276
|
+
* How to set the plugin up, step by step, shown after it is installed. Without it, Studio asks
|
|
277
|
+
* for the plugin's settings and offers its commands in one step.
|
|
278
|
+
*/
|
|
279
|
+
onboarding?: Onboarding;
|
|
280
|
+
/** Runs when the plugin is enabled (and when the host starts). May return a cleanup. */
|
|
281
|
+
activate?(context: PluginContext): void | Deactivate | Promise<void | Deactivate>;
|
|
282
|
+
}
|
|
283
|
+
/** The namespace a plugin's state and events use. */
|
|
284
|
+
export declare function pluginNamespace(def: Pick<PluginDef, "id" | "namespace">): string;
|
|
285
|
+
/**
|
|
286
|
+
* Defines an action. `settings` is inferred, so `run` and `component` get typed settings:
|
|
287
|
+
*
|
|
288
|
+
* ```ts
|
|
289
|
+
* export const hello = defineAction({
|
|
290
|
+
* id: "hello",
|
|
291
|
+
* name: "Hello",
|
|
292
|
+
* settings: { name: { type: "text", label: "Name", default: "world" } },
|
|
293
|
+
* run: ({ settings, plugin }) => plugin.log(`Hi ${settings.name}`),
|
|
294
|
+
* });
|
|
295
|
+
* ```
|
|
296
|
+
*/
|
|
297
|
+
export declare function defineAction<const S extends SettingsSchema = Record<never, never>>(def: ActionDef<S>): Action;
|
|
298
|
+
/** Defines a trigger type with typed settings. */
|
|
299
|
+
export declare function defineTrigger<const S extends SettingsSchema = Record<never, never>>(def: TriggerDef<S>): Trigger;
|
|
300
|
+
/** Defines a plugin, checking it. A plugin module's default export must be one of these. */
|
|
301
|
+
export declare function definePlugin(def: PluginDef): PluginDef;
|
|
302
|
+
/** Problems with something that should be a plugin (empty when it is fine). */
|
|
303
|
+
export declare function checkPlugin(value: unknown): string[];
|
|
304
|
+
//# sourceMappingURL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,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;IACvD,WAAW,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IACpC,gFAAgF;IAChF,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,oCAAoC;IACpC,QAAQ,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;IACpC;;;OAGG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,wFAAwF;IAExF,QAAQ,CAAC,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,GAAG,UAAU,GAAG,OAAO,CAAC,IAAI,GAAG,UAAU,CAAC,CAAC;CACnF;AAMD,qDAAqD;AACrD,wBAAgB,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,GAAG,WAAW,CAAC,GAAG,MAAM,CAShF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,KAAK,CAAC,CAAC,SAAS,cAAc,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,EAChF,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,GAChB,MAAM,CAMR;AAED,kDAAkD;AAClD,wBAAgB,aAAa,CAAC,KAAK,CAAC,CAAC,SAAS,cAAc,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,EACjF,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,GACjB,OAAO,CAET;AAED,4FAA4F;AAC5F,wBAAgB,YAAY,CAAC,GAAG,EAAE,SAAS,GAAG,SAAS,CAMtD;AAoBD,+EAA+E;AAC/E,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CAgHpD"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Action settings are described by a plain-data schema. The host turns it into a form in the
|
|
3
|
+
* configuration UI, and `resolveSettings` turns whatever is stored into well-typed values.
|
|
4
|
+
*/
|
|
5
|
+
type Primitive = string | number | boolean;
|
|
6
|
+
interface FieldBase {
|
|
7
|
+
/** Label shown in the configuration UI. */
|
|
8
|
+
label: string;
|
|
9
|
+
/** Help text under the field. */
|
|
10
|
+
description?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Shown only while other fields have these values: `{ to: "page" }` or
|
|
13
|
+
* `{ mode: ["a", "b"] }`. Hidden fields keep their value.
|
|
14
|
+
*/
|
|
15
|
+
visibleIf?: Readonly<Record<string, Primitive | readonly Primitive[]>>;
|
|
16
|
+
}
|
|
17
|
+
export interface TextField extends FieldBase {
|
|
18
|
+
type: "text";
|
|
19
|
+
default?: string;
|
|
20
|
+
placeholder?: string;
|
|
21
|
+
multiline?: boolean;
|
|
22
|
+
/** Suggestions from one of the plugin's `optionSources` (any text is still allowed). */
|
|
23
|
+
source?: string;
|
|
24
|
+
/** Other fields the suggestions depend on, passed to the source. */
|
|
25
|
+
dependsOn?: readonly string[];
|
|
26
|
+
}
|
|
27
|
+
export interface NumberField extends FieldBase {
|
|
28
|
+
type: "number";
|
|
29
|
+
default?: number;
|
|
30
|
+
min?: number;
|
|
31
|
+
max?: number;
|
|
32
|
+
step?: number;
|
|
33
|
+
}
|
|
34
|
+
export interface BooleanField extends FieldBase {
|
|
35
|
+
type: "boolean";
|
|
36
|
+
default?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A password or token, only for a plugin's own settings. It is kept in the host's secrets file
|
|
40
|
+
* (never in the config, so it is safe to share or commit) and the UI never reads it back.
|
|
41
|
+
*/
|
|
42
|
+
export interface SecretField extends FieldBase {
|
|
43
|
+
type: "secret";
|
|
44
|
+
default?: string;
|
|
45
|
+
placeholder?: string;
|
|
46
|
+
}
|
|
47
|
+
/** A `#rrggbb` colour. */
|
|
48
|
+
export interface ColorField extends FieldBase {
|
|
49
|
+
type: "color";
|
|
50
|
+
default?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface SelectOption {
|
|
53
|
+
value: string;
|
|
54
|
+
label: string;
|
|
55
|
+
}
|
|
56
|
+
export interface SelectField extends FieldBase {
|
|
57
|
+
type: "select";
|
|
58
|
+
/** Fixed options. With `source`, shown before the fetched ones. */
|
|
59
|
+
options: readonly SelectOption[];
|
|
60
|
+
/**
|
|
61
|
+
* Options fetched from one of the plugin's `optionSources` when the form opens (OBS
|
|
62
|
+
* scenes, audio devices). Any stored string is then kept, since the list can change.
|
|
63
|
+
*/
|
|
64
|
+
source?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Other fields the fetched options depend on, passed to the source. The form asks for them
|
|
67
|
+
* first, and clears this field when one of them changes.
|
|
68
|
+
*/
|
|
69
|
+
dependsOn?: readonly string[];
|
|
70
|
+
default?: string;
|
|
71
|
+
}
|
|
72
|
+
/** The name of one of the user's pages (the UI shows a page picker). */
|
|
73
|
+
export interface PageField extends FieldBase {
|
|
74
|
+
type: "page";
|
|
75
|
+
default?: string;
|
|
76
|
+
}
|
|
77
|
+
/** An image: an `http(s)` URL or a `data:` URI (the UI accepts a URL or a file). */
|
|
78
|
+
export interface ImageField extends FieldBase {
|
|
79
|
+
type: "image";
|
|
80
|
+
default?: string;
|
|
81
|
+
}
|
|
82
|
+
export type SettingField = TextField | NumberField | BooleanField | ColorField | SelectField | PageField | ImageField | SecretField;
|
|
83
|
+
export type SettingsSchema = Readonly<Record<string, SettingField>>;
|
|
84
|
+
/** The value type of one field. */
|
|
85
|
+
export type FieldValue<F extends SettingField> = F extends NumberField ? number : F extends BooleanField ? boolean : F extends SelectField ? F extends {
|
|
86
|
+
source: string;
|
|
87
|
+
} ? string : F["options"][number]["value"] : string;
|
|
88
|
+
/** The settings object an action receives for a schema. */
|
|
89
|
+
export type InferSettings<S extends SettingsSchema> = {
|
|
90
|
+
-readonly [K in keyof S]: FieldValue<S[K]>;
|
|
91
|
+
};
|
|
92
|
+
/** The value a field takes when nothing (valid) is stored. */
|
|
93
|
+
export declare function defaultValue(field: SettingField): string | number | boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Stored settings, made safe: every field of `schema` is present and of the right type (invalid
|
|
96
|
+
* or missing values get the default, numbers are clamped), and unknown keys are dropped.
|
|
97
|
+
*/
|
|
98
|
+
export declare function resolveSettings<S extends SettingsSchema>(schema: S, stored: Readonly<Record<string, unknown>> | undefined): InferSettings<S>;
|
|
99
|
+
/** Whether `field` is shown for these (resolved) settings. */
|
|
100
|
+
export declare function isFieldVisible(field: SettingField, settings: Readonly<Record<string, unknown>>): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Problems with a schema (empty when it is fine). Used when a plugin is loaded. `sources` are
|
|
103
|
+
* the plugin's option sources, checked against fields that name one.
|
|
104
|
+
*/
|
|
105
|
+
export declare function checkSchema(schema: SettingsSchema, sources?: Readonly<Record<string, unknown>>): string[];
|
|
106
|
+
export {};
|
|
107
|
+
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE3C,UAAU,SAAS;IACjB,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,SAAS,EAAE,CAAC,CAAC,CAAC;CACxE;AAED,MAAM,WAAW,SAAU,SAAQ,SAAS;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,wFAAwF;IACxF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC/B;AAED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AAC,MAAM,EAAE,OAAO,CAAC,CAAM,GAC9C,MAAM,EAAE,CAsCV"}
|
package/dist/shared.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** A source started on the first listener and stopped after the last one leaves. */
|
|
2
|
+
export declare class Shared<T> {
|
|
3
|
+
#private;
|
|
4
|
+
constructor(start: (emit: (value: T) => void) => () => void);
|
|
5
|
+
/** The latest value, if any arrived since it started. */
|
|
6
|
+
get last(): T | undefined;
|
|
7
|
+
listen(listener: (value: T) => void): () => void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,qBAAa,MAAM,CAAC,CAAC;;IAMnB,YAAY,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,KAAK,MAAM,IAAI,EAE1D;IAED,yDAAyD;IACzD,IAAI,IAAI,IAAI,CAAC,GAAG,SAAS,CAExB;IAED,MAAM,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAgB/C;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdeck/plugin",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "SDK for sdeck plugins: actions that run headless or draw with React, live state, triggers and option sources.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"src"
|
|
11
|
+
],
|
|
12
|
+
"main": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"bun": "./src/index.ts",
|
|
18
|
+
"import": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./package.json": "./package.json"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "bun ../../scripts/build-package.ts",
|
|
24
|
+
"clean": "rm -rf dist",
|
|
25
|
+
"test": "bun test"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@sdeck/app": "0.1.0",
|
|
29
|
+
"@sdeck/engine": "0.1.0",
|
|
30
|
+
"@sdeck/schema": "0.1.0"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"react": ">=19.3"
|
|
34
|
+
},
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "git+https://github.com/ivanoliverfabra/sdeck.git",
|
|
38
|
+
"directory": "packages/plugin"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
}
|
|
43
|
+
}
|