@t3mode/plugin-sdk 1.0.2 → 1.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.
- package/dist/index.d.ts +42 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -23,9 +23,39 @@ export interface PluginReport {
|
|
|
23
23
|
readonly state: "active" | "waiting";
|
|
24
24
|
readonly detail: string;
|
|
25
25
|
}
|
|
26
|
+
export interface RowOptions {
|
|
27
|
+
readonly title?: string;
|
|
28
|
+
/** Text, or nodes such as a textarea, under the title. */
|
|
29
|
+
readonly description?: string | Node;
|
|
30
|
+
/** Shown on the right, or under the text in a narrow pane. */
|
|
31
|
+
readonly control?: Node | null;
|
|
32
|
+
}
|
|
33
|
+
export interface ButtonOptions {
|
|
34
|
+
readonly text: string;
|
|
35
|
+
readonly variant?: "ghost" | "outline";
|
|
36
|
+
readonly onClick: () => void;
|
|
37
|
+
}
|
|
38
|
+
/** T3 Code's own settings components, so a settings panel looks native. */
|
|
39
|
+
export interface PluginUi {
|
|
40
|
+
/** A bordered group of rows, with a line between rows. */
|
|
41
|
+
readonly group: (...rows: ReadonlyArray<Node>) => HTMLElement;
|
|
42
|
+
readonly row: (options: RowOptions) => HTMLElement;
|
|
43
|
+
readonly button: (options: ButtonOptions) => HTMLButtonElement;
|
|
44
|
+
}
|
|
45
|
+
export interface LocalSocket {
|
|
46
|
+
readonly name: string;
|
|
47
|
+
write(data: Uint8Array): void;
|
|
48
|
+
close(): void;
|
|
49
|
+
onData(callback: (data: Uint8Array) => void): void;
|
|
50
|
+
onClose(callback: (error?: string) => void): void;
|
|
51
|
+
}
|
|
26
52
|
export interface PluginApi<O extends OptionsSpec = OptionsSpec> {
|
|
27
53
|
/** The id from the plugin's manifest.json. */
|
|
28
54
|
readonly id: string;
|
|
55
|
+
/** Connects to a local socket whose name must be declared in the manifest. */
|
|
56
|
+
readonly sockets: {
|
|
57
|
+
readonly connect: (name: string) => Promise<LocalSocket>;
|
|
58
|
+
};
|
|
29
59
|
readonly options: OptionValues<O>;
|
|
30
60
|
/** Adds a stylesheet, removed when the plugin stops. */
|
|
31
61
|
readonly css: (text: string) => void;
|
|
@@ -38,9 +68,21 @@ export interface PluginApi<O extends OptionsSpec = OptionsSpec> {
|
|
|
38
68
|
readonly onCleanup: (cleanup: () => void) => void;
|
|
39
69
|
/** JSON in <home>/plugin-data/<id>.json. Deleted when the plugin is removed or uninstall --purge runs. */
|
|
40
70
|
readonly storage: {
|
|
71
|
+
/**
|
|
72
|
+
* False when the file exists but isn't a JSON object. `get` then returns each fallback and
|
|
73
|
+
* `set` stores nothing, so the file is never written over. A fix takes effect on reload.
|
|
74
|
+
*/
|
|
75
|
+
readonly readable: boolean;
|
|
76
|
+
/** The file's absolute path, to show the user. */
|
|
77
|
+
readonly path: string;
|
|
41
78
|
readonly get: <T>(key: string, fallback: T) => T;
|
|
42
79
|
readonly set: (key: string, value: unknown) => void;
|
|
43
80
|
};
|
|
81
|
+
/** A section on the plugin's settings page, below Options, filled by `render` on each draw. */
|
|
82
|
+
readonly settingsPanel: (title: string, render: (host: HTMLElement) => void) => void;
|
|
83
|
+
/** A short message in the window's corner. Dropped once the plugin has stopped. */
|
|
84
|
+
readonly toast: (message: string, kind?: "info" | "error") => void;
|
|
85
|
+
readonly ui: PluginUi;
|
|
44
86
|
readonly log: (level: LogLevel, message: string) => void;
|
|
45
87
|
readonly report: (report: PluginReport) => void;
|
|
46
88
|
/** The first element matching any of the selectors, tried in order: newest markup first. */
|