@crowbartools/firebot-types 5.67.0-alpha5 → 5.67.0-alpha6
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/backend/custom-scripts/executors/legacy-startup-script-executor.d.ts +2 -2
- package/backend/custom-scripts/executors/plugin-executor.d.ts +2 -2
- package/backend/custom-scripts/executors/script-executor.interface.d.ts +3 -6
- package/backend/custom-scripts/plugin-manifest-utils.d.ts +8 -0
- package/backend/custom-scripts/script-api/namespaces/frontend-communicator.d.ts +2 -0
- package/backend/custom-scripts/script-manager.d.ts +16 -5
- package/backend/ui-extensions/ui-extension-manager.d.ts +1 -1
- package/package.json +1 -1
- package/types/index.d.ts +1 -0
- package/types/plugins.d.ts +28 -5
- package/types/script-api.d.ts +34 -0
- package/types/settings.d.ts +1 -0
- package/types/ui-extensions.d.ts +103 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ScriptBase, LegacyCustomScript, InstalledPluginConfig, ScriptDetails } from "../../../types";
|
|
2
|
-
import { IPluginExecutor,
|
|
2
|
+
import { IPluginExecutor, PluginExecutionResult } from "./script-executor.interface";
|
|
3
3
|
/**
|
|
4
4
|
* Executor for legacy startup scripts (scripts that export a getScriptManifest function that returns an object with startupOnly: true)
|
|
5
5
|
*/
|
|
6
6
|
export declare class LegacyStartUpScript extends IPluginExecutor {
|
|
7
7
|
constructor();
|
|
8
8
|
canHandle(script: ScriptBase | LegacyCustomScript): Promise<boolean>;
|
|
9
|
-
executePlugin(script: ScriptBase | LegacyCustomScript, config: InstalledPluginConfig): Promise<
|
|
9
|
+
executePlugin(script: ScriptBase | LegacyCustomScript, config: InstalledPluginConfig): Promise<PluginExecutionResult>;
|
|
10
10
|
unloadPlugin(script: ScriptBase | LegacyCustomScript): Promise<void>;
|
|
11
11
|
updateParameters(script: ScriptBase | LegacyCustomScript, config: InstalledPluginConfig): Promise<void>;
|
|
12
12
|
getScriptDetails(script: ScriptBase | LegacyCustomScript): Promise<ScriptDetails>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ScriptBase, LegacyCustomScript, Plugin, InstalledPluginConfig, ScriptDetails } from "../../../types";
|
|
2
|
-
import { IPluginExecutor, PluginRegistrations,
|
|
2
|
+
import { IPluginExecutor, PluginRegistrations, PluginExecutionResult } from "./script-executor.interface";
|
|
3
3
|
/**
|
|
4
4
|
* Executor for new-spec Plugins (manifest.type === "plugin")
|
|
5
5
|
*/
|
|
@@ -7,7 +7,7 @@ export declare class PluginExecutor extends IPluginExecutor {
|
|
|
7
7
|
constructor();
|
|
8
8
|
canHandle(script: ScriptBase | LegacyCustomScript): script is Plugin<import("../../../types").FirebotParams>;
|
|
9
9
|
getScriptDetails(script: ScriptBase | LegacyCustomScript): ScriptDetails | null;
|
|
10
|
-
executePlugin(script: ScriptBase | LegacyCustomScript, config: InstalledPluginConfig, isInstalling?: boolean): Promise<
|
|
10
|
+
executePlugin(script: ScriptBase | LegacyCustomScript, config: InstalledPluginConfig, isInstalling?: boolean): Promise<PluginExecutionResult>;
|
|
11
11
|
unloadPlugin(script: ScriptBase | LegacyCustomScript, config: InstalledPluginConfig, registrations?: PluginRegistrations, isUninstalling?: boolean): Promise<void>;
|
|
12
12
|
updateParameters(script: ScriptBase | LegacyCustomScript, config: InstalledPluginConfig): Promise<void>;
|
|
13
13
|
private registerAll;
|
|
@@ -3,10 +3,6 @@ declare abstract class IBaseScriptExecutor {
|
|
|
3
3
|
abstract canHandle(script: ScriptBase | LegacyCustomScript): Awaitable<boolean>;
|
|
4
4
|
abstract getScriptDetails(script: ScriptBase | LegacyCustomScript): Awaitable<ScriptDetails | null>;
|
|
5
5
|
}
|
|
6
|
-
/**
|
|
7
|
-
* Bookkeeping of items a plugin registered with various managers so they
|
|
8
|
-
* can be cleanly unregistered on unload.
|
|
9
|
-
*/
|
|
10
6
|
export interface PluginRegistrations {
|
|
11
7
|
effectIds?: string[];
|
|
12
8
|
variableHandles?: string[];
|
|
@@ -16,8 +12,9 @@ export interface PluginRegistrations {
|
|
|
16
12
|
restrictionIds?: string[];
|
|
17
13
|
integrationIds?: string[];
|
|
18
14
|
gameIds?: string[];
|
|
15
|
+
uiExtensionIds?: string[];
|
|
19
16
|
}
|
|
20
|
-
export type
|
|
17
|
+
export type PluginExecutionResult = {
|
|
21
18
|
success: true;
|
|
22
19
|
registrations?: PluginRegistrations;
|
|
23
20
|
} | {
|
|
@@ -25,7 +22,7 @@ export type ScriptExecutionResult = {
|
|
|
25
22
|
error: string;
|
|
26
23
|
};
|
|
27
24
|
export declare abstract class IPluginExecutor extends IBaseScriptExecutor {
|
|
28
|
-
abstract executePlugin(script: ScriptBase | LegacyCustomScript, config: InstalledPluginConfig, isInstalling?: boolean): Awaitable<
|
|
25
|
+
abstract executePlugin(script: ScriptBase | LegacyCustomScript, config: InstalledPluginConfig, isInstalling?: boolean): Awaitable<PluginExecutionResult>;
|
|
29
26
|
abstract unloadPlugin(script: ScriptBase | LegacyCustomScript, config: InstalledPluginConfig, registrations?: PluginRegistrations, isUninstalling?: boolean): Awaitable<void>;
|
|
30
27
|
updateParameters?(script: ScriptBase | LegacyCustomScript, config: InstalledPluginConfig): Awaitable<void>;
|
|
31
28
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Manifest } from "../../types";
|
|
2
|
+
/**
|
|
3
|
+
* Resolves the external links (repo / website / support) for a plugin manifest.
|
|
4
|
+
*
|
|
5
|
+
* When the manifest `repo` points at a GitHub repository, `website` and `support`
|
|
6
|
+
* are auto-populated when not explicitly provided.
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolvePluginManifestLinks<T extends Manifest>(manifest: T): T;
|
|
@@ -11,16 +11,22 @@ type GetScriptDetailsResult = {
|
|
|
11
11
|
};
|
|
12
12
|
declare class ScriptManager {
|
|
13
13
|
private activePlugins;
|
|
14
|
-
private activePluginsByFileName;
|
|
15
14
|
private pendingApiInstances;
|
|
16
15
|
private effectScriptApiInstances;
|
|
16
|
+
private startingPlugins;
|
|
17
17
|
private requireInterceptorInstalled;
|
|
18
18
|
private pluginExecutors;
|
|
19
19
|
private effectScriptExecutors;
|
|
20
20
|
constructor();
|
|
21
21
|
startPlugin(pluginConfig: InstalledPluginConfig, installing?: boolean): Promise<void>;
|
|
22
|
+
private doStartPlugin;
|
|
22
23
|
startPlugins(): Promise<void>;
|
|
23
24
|
stopPlugin(pluginId: string, uninstalling?: boolean): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Convenience helper for hot-reloading. Finds an active plugin by its script file
|
|
27
|
+
* name and restarts it (stop then start). Does nothing if no active plugin matches.
|
|
28
|
+
*/
|
|
29
|
+
restartPluginByFileName(fileName: string): Promise<void>;
|
|
24
30
|
stopAllPlugins(): Promise<void>;
|
|
25
31
|
/**
|
|
26
32
|
* Handle a config change. Starts/stops as needed, and on a still-enabled plugin
|
|
@@ -50,14 +56,18 @@ declare class ScriptManager {
|
|
|
50
56
|
cancelInstall(fileName: string): Promise<void>;
|
|
51
57
|
/**
|
|
52
58
|
* Called by PluginConfigManager when a config is deleted, so we can stop the
|
|
53
|
-
* plugin
|
|
59
|
+
* plugin.
|
|
54
60
|
*/
|
|
55
61
|
onPluginConfigDeleted(pluginConfig: InstalledPluginConfig): Promise<void>;
|
|
62
|
+
deleteScriptFileIfUnreferenced(fileName: string): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Remove an installed plugin. Stops the plugin and deletes its config, and
|
|
65
|
+
* optionally deletes the underlying script file from the scripts folder.
|
|
66
|
+
*/
|
|
67
|
+
deletePlugin(pluginId: string, deleteScriptFile?: boolean): Promise<boolean>;
|
|
56
68
|
/**
|
|
57
69
|
* Replace the underlying script file for an existing plugin config with a new file
|
|
58
|
-
* chosen on disk.
|
|
59
|
-
* swaps the file (deleting the old one when the name changes), then re-starts the
|
|
60
|
-
* plugin so the new code is picked up dynamically.
|
|
70
|
+
* chosen on disk.
|
|
61
71
|
*/
|
|
62
72
|
updatePluginFromPath(pluginId: string, sourcePath: string, overwrite?: boolean): Promise<GetScriptDetailsResult | {
|
|
63
73
|
success: false;
|
|
@@ -70,6 +80,7 @@ declare class ScriptManager {
|
|
|
70
80
|
}, trigger?: Trigger): Promise<EffectScriptExecutionResult | undefined>;
|
|
71
81
|
private disposeEffectScriptApi;
|
|
72
82
|
private getScriptFilePath;
|
|
83
|
+
private getActivePluginByFileName;
|
|
73
84
|
private findPluginExecutor;
|
|
74
85
|
private installRequireInterceptor;
|
|
75
86
|
private createApiInstance;
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
package/types/plugins.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { RestrictionType } from "./restrictions";
|
|
|
8
8
|
import { FirebotParams, FirebotParameterArray } from "./parameters";
|
|
9
9
|
import { FirebotGame } from "./games";
|
|
10
10
|
import { Integration } from "./integrations";
|
|
11
|
+
import { UIExtension } from "./ui-extensions";
|
|
11
12
|
|
|
12
13
|
type NoResult = Awaitable<void>;
|
|
13
14
|
|
|
@@ -47,21 +48,42 @@ export interface Manifest {
|
|
|
47
48
|
author: string;
|
|
48
49
|
description: string | ManifestDescription;
|
|
49
50
|
|
|
50
|
-
keywords?: string[];
|
|
51
|
+
// keywords?: string[];
|
|
51
52
|
|
|
53
|
+
/**
|
|
54
|
+
* A link to the plugin's source code repository
|
|
55
|
+
*/
|
|
52
56
|
repo?: string;
|
|
53
57
|
|
|
54
|
-
|
|
58
|
+
/**
|
|
59
|
+
* A link to the plugin's website
|
|
60
|
+
* If the repo is on GitHub and the website is not specified, it will default to the GitHub repo URL.
|
|
61
|
+
*/
|
|
55
62
|
website?: string;
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
/**
|
|
64
|
+
* A link to the plugin's issue tracker or support server (e.g. Discord).
|
|
65
|
+
* If the repo is on GitHub and support is not specified, it will default to the GitHub issues URL.
|
|
66
|
+
*/
|
|
67
|
+
support?: string;
|
|
58
68
|
|
|
59
69
|
minimumFirebotVersion?: ManifestFirebotVersion;
|
|
60
70
|
maximumFirebotVersion?: ManifestFirebotVersion;
|
|
61
71
|
|
|
72
|
+
/**
|
|
73
|
+
* A FontAwesome icon name shown in the UI (eg. "fa-cogs").
|
|
74
|
+
*/
|
|
62
75
|
icon?: `fa-${string}`;
|
|
76
|
+
/**
|
|
77
|
+
* A hex color code (eg. "#FF0000") used for the icon.
|
|
78
|
+
*/
|
|
63
79
|
color?: string;
|
|
64
80
|
|
|
81
|
+
/**
|
|
82
|
+
* If true, the plugin will be initialized before parameters are shown to the user,
|
|
83
|
+
* allowing the plugin to provide custom parameter types that can be used in its own parametersSchema.
|
|
84
|
+
*/
|
|
85
|
+
initBeforeShowingParams?: boolean;
|
|
86
|
+
|
|
65
87
|
type: ScriptType;
|
|
66
88
|
}
|
|
67
89
|
|
|
@@ -102,12 +124,12 @@ export interface Plugin<Params extends FirebotParams = FirebotParams> extends Sc
|
|
|
102
124
|
effects?: DynamicArray<EffectType>;
|
|
103
125
|
eventSources?: DynamicArray<EventSource>;
|
|
104
126
|
variables?: DynamicArray<ReplaceVariable>;
|
|
105
|
-
// endpoints?: DynamicArray<HttpEndpoint>;
|
|
106
127
|
integrations?: DynamicArray<Integration>;
|
|
107
128
|
filters?: DynamicArray<EventFilter>;
|
|
108
129
|
restrictions?: DynamicArray<RestrictionType>;
|
|
109
130
|
systemCommands?: DynamicArray<SystemCommand>;
|
|
110
131
|
games?: DynamicArray<FirebotGame>;
|
|
132
|
+
uiExtensions?: DynamicArray<UIExtension>;
|
|
111
133
|
};
|
|
112
134
|
|
|
113
135
|
// Called when the script is loaded
|
|
@@ -177,6 +199,7 @@ type LegacyCustomScriptManifest = {
|
|
|
177
199
|
author: string;
|
|
178
200
|
website?: string;
|
|
179
201
|
startupOnly?: boolean;
|
|
202
|
+
initBeforeShowingParams?: boolean;
|
|
180
203
|
firebotVersion?: "5";
|
|
181
204
|
};
|
|
182
205
|
|
package/types/script-api.d.ts
CHANGED
|
@@ -121,6 +121,38 @@ export interface ScriptTwitchApi {
|
|
|
121
121
|
api: typeof TwitchApi;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
+
export interface ScriptFrontendCommunicatorApi {
|
|
125
|
+
/** Send a synchronous event to the frontend. */
|
|
126
|
+
send<ExpectedArg = unknown>(eventName: string, data?: ExpectedArg): void;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Send an asynchronous event to the frontend and await the reply it sends
|
|
130
|
+
* back.
|
|
131
|
+
*/
|
|
132
|
+
fireEventAsync<ReturnPayload = void, ExpectedArg = unknown>(
|
|
133
|
+
eventName: string,
|
|
134
|
+
data?: ExpectedArg
|
|
135
|
+
): Promise<ReturnPayload>;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Handle a synchronous event triggered by the frontend. Returns an
|
|
139
|
+
* `unsubscribe` function.
|
|
140
|
+
*/
|
|
141
|
+
on<ExpectedArgs extends Array<unknown> = [], ReturnPayload = void>(
|
|
142
|
+
eventName: string,
|
|
143
|
+
callback: (...args: ExpectedArgs) => ReturnPayload
|
|
144
|
+
): () => void;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Handle an asynchronous event triggered by the frontend. Returns an
|
|
148
|
+
* `unsubscribe` function.
|
|
149
|
+
*/
|
|
150
|
+
onAsync<ExpectedArgs extends Array<unknown> = [], ReturnPayload = void>(
|
|
151
|
+
eventName: string,
|
|
152
|
+
callback: (...args: ExpectedArgs) => Promise<ReturnPayload>
|
|
153
|
+
): () => void;
|
|
154
|
+
}
|
|
155
|
+
|
|
124
156
|
export interface FirebotScriptApi {
|
|
125
157
|
/** Running Firebot version, e.g. `"5.65.0"`. */
|
|
126
158
|
version: string;
|
|
@@ -136,4 +168,6 @@ export interface FirebotScriptApi {
|
|
|
136
168
|
effects: ScriptEffectsApi;
|
|
137
169
|
/** Access to Firebot's Twitch API wrappers (Helix, chat, auth, etc). */
|
|
138
170
|
twitch: ScriptTwitchApi;
|
|
171
|
+
/** Two-way messaging between the script and the frontend. */
|
|
172
|
+
frontendCommunicator: ScriptFrontendCommunicatorApi;
|
|
139
173
|
}
|
package/types/settings.d.ts
CHANGED
|
@@ -83,6 +83,7 @@ export type FirebotSettingsTypes = {
|
|
|
83
83
|
LegacySortTagsImported: boolean;
|
|
84
84
|
LoggedInProfile: string;
|
|
85
85
|
MaxBackupCount: number | "All";
|
|
86
|
+
MigratedLegacyStartUpScriptsToPlugins: boolean;
|
|
86
87
|
MinimizeToTray: boolean;
|
|
87
88
|
NotifyOnBeta: boolean;
|
|
88
89
|
OpenEffectQueueMonitorOnLaunch: boolean;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unsafe-function-type */
|
|
2
|
+
export type BasePage = {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
icon: `fa-${string}`;
|
|
6
|
+
fullPage?: boolean;
|
|
7
|
+
disableScroll?: boolean;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type AngularJsPage = BasePage & {
|
|
11
|
+
type: 'angularjs';
|
|
12
|
+
template: string;
|
|
13
|
+
controller: Function;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type IframePage = BasePage & {
|
|
17
|
+
type: 'iframe';
|
|
18
|
+
// Other properties TBD
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type AngularJsFactory = {
|
|
22
|
+
name: string;
|
|
23
|
+
function: Function;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type AngularJsComponent = {
|
|
27
|
+
name: string;
|
|
28
|
+
bindings: Record<string, string>;
|
|
29
|
+
template: string;
|
|
30
|
+
transclude?: boolean | string | { [slot: string]: string };
|
|
31
|
+
controller: Function;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A specialized AngularJS component for rendering Firebot parameters.
|
|
37
|
+
* These components will always have the following bindings:
|
|
38
|
+
* - `$ctrl.schema`: The parameter schema (any properties in the parameter object)
|
|
39
|
+
* - `$ctrl.value`: The current value of the parameter
|
|
40
|
+
* - `$ctrl.onInput`: A callback function to call when the parameter value changes
|
|
41
|
+
* - `$ctrl.onTouched`: A callback function to call when the parameter is touched
|
|
42
|
+
*/
|
|
43
|
+
export type AngularJsFirebotParameterComponent = {
|
|
44
|
+
parameterConfig: {
|
|
45
|
+
/**
|
|
46
|
+
* The type of parameter this component handles.
|
|
47
|
+
* This value is what will go in the "type" field of a parameter schema.
|
|
48
|
+
*/
|
|
49
|
+
type: string;
|
|
50
|
+
hideTitle?: boolean;
|
|
51
|
+
hideDescription?: boolean;
|
|
52
|
+
};
|
|
53
|
+
template: string;
|
|
54
|
+
controller: Function;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export type AngularJsDirective = {
|
|
58
|
+
name: string;
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
|
+
function: (...args: any[]) => {
|
|
61
|
+
compile?: Function;
|
|
62
|
+
controller?: Function;
|
|
63
|
+
link?: Function;
|
|
64
|
+
multiElement?: boolean;
|
|
65
|
+
name?: string;
|
|
66
|
+
priority?: number;
|
|
67
|
+
require?: string | string[] | { [controller: string]: string };
|
|
68
|
+
restrict?: string;
|
|
69
|
+
scope?: boolean | object;
|
|
70
|
+
template?: string;
|
|
71
|
+
terminal?: boolean;
|
|
72
|
+
transclude?: boolean | string | { [slot: string]: string };
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export type AngularJsFilter = {
|
|
77
|
+
name: string;
|
|
78
|
+
function: {
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
80
|
+
(...args: any[]): Function;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export type UIExtension = {
|
|
85
|
+
id: string;
|
|
86
|
+
/**
|
|
87
|
+
* Adds new sidebar entries under an "Extensions" category
|
|
88
|
+
*/
|
|
89
|
+
pages?: AngularJsPage[];
|
|
90
|
+
/**
|
|
91
|
+
* Add your own AngularJS services, components, directives, filters
|
|
92
|
+
*/
|
|
93
|
+
providers?: {
|
|
94
|
+
factories?: AngularJsFactory[];
|
|
95
|
+
components?: AngularJsComponent[];
|
|
96
|
+
directives?: AngularJsDirective[];
|
|
97
|
+
filters?: AngularJsFilter[];
|
|
98
|
+
/**
|
|
99
|
+
* Add your own parameter components for rendering custom parameter types
|
|
100
|
+
*/
|
|
101
|
+
parameters?: AngularJsFirebotParameterComponent[];
|
|
102
|
+
};
|
|
103
|
+
};
|