@crowbartools/firebot-types 5.67.0-alpha8 → 5.67.0-alpha9
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/crowbar-relay/crowbar-relay-websocket.d.ts +1 -0
- package/backend/notifications/notification-manager.d.ts +1 -26
- package/backend/overlay-widgets/overlay-widgets-manager.d.ts +2 -0
- package/backend/{custom-scripts → scripts}/executors/script-executor.interface.d.ts +1 -0
- package/backend/{custom-scripts → scripts}/script-api/context.d.ts +2 -1
- package/backend/scripts/script-api/namespaces/notifications.d.ts +2 -0
- package/backend/scripts/script-api/namespaces/plugins.d.ts +2 -0
- package/backend/scripts/script-api/namespaces/settings.d.ts +2 -0
- package/package.json +1 -1
- package/types/index.d.ts +1 -0
- package/types/notifications.d.ts +33 -0
- package/types/plugins.d.ts +12 -18
- package/types/script-api.d.ts +51 -1
- package/backend/{custom-scripts → scripts}/executors/effect-script-executor.d.ts +0 -0
- package/backend/{custom-scripts → scripts}/executors/legacy-effect-script-executor.d.ts +0 -0
- package/backend/{custom-scripts → scripts}/executors/legacy-startup-script-executor.d.ts +0 -0
- package/backend/{custom-scripts → scripts}/executors/plugin-executor.d.ts +0 -0
- package/backend/{custom-scripts → scripts}/plugin-config-manager.d.ts +0 -0
- package/backend/{custom-scripts → scripts}/plugin-manifest-utils.d.ts +0 -0
- package/backend/{custom-scripts → scripts}/script-api/index.d.ts +0 -0
- package/backend/{custom-scripts → scripts}/script-api/internal/define-namespace.d.ts +0 -0
- package/backend/{custom-scripts → scripts}/script-api/internal/dispose-bag.d.ts +0 -0
- package/backend/{custom-scripts → scripts}/script-api/internal/name-normalizer.d.ts +0 -0
- package/backend/{custom-scripts → scripts}/script-api/internal/script-data-dir.d.ts +0 -0
- package/backend/{custom-scripts → scripts}/script-api/namespaces/effects.d.ts +0 -0
- package/backend/{custom-scripts → scripts}/script-api/namespaces/events.d.ts +0 -0
- package/backend/{custom-scripts → scripts}/script-api/namespaces/frontend-communicator.d.ts +0 -0
- package/backend/{custom-scripts → scripts}/script-api/namespaces/logger.d.ts +0 -0
- package/backend/{custom-scripts → scripts}/script-api/namespaces/parameters.d.ts +0 -0
- package/backend/{custom-scripts → scripts}/script-api/namespaces/storage.d.ts +0 -0
- package/backend/{custom-scripts → scripts}/script-api/namespaces/twitch.d.ts +0 -0
- package/backend/{custom-scripts → scripts}/script-api/namespaces/webhooks.d.ts +0 -0
- package/backend/{custom-scripts → scripts}/script-manager.d.ts +1 -1
|
@@ -1,29 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
EXTERNAL = "external",
|
|
3
|
-
INTERNAL = "internal",
|
|
4
|
-
SCRIPT = "script"
|
|
5
|
-
}
|
|
6
|
-
export declare enum NotificationType {
|
|
7
|
-
INFO = "info",
|
|
8
|
-
TIP = "tip",
|
|
9
|
-
UPDATE = "update",
|
|
10
|
-
ALERT = "alert"
|
|
11
|
-
}
|
|
12
|
-
export type NotificationBase = {
|
|
13
|
-
title: string;
|
|
14
|
-
message: string;
|
|
15
|
-
type: NotificationType;
|
|
16
|
-
source?: NotificationSource;
|
|
17
|
-
scriptName?: string;
|
|
18
|
-
externalId?: string;
|
|
19
|
-
metadata?: Record<string, unknown>;
|
|
20
|
-
};
|
|
21
|
-
export type Notification = NotificationBase & {
|
|
22
|
-
id: string;
|
|
23
|
-
timestamp: Date;
|
|
24
|
-
saved: boolean;
|
|
25
|
-
read: boolean;
|
|
26
|
-
};
|
|
1
|
+
import { Notification, NotificationBase } from "../../types";
|
|
27
2
|
declare class NotificationManager {
|
|
28
3
|
private _externalCheckInterval;
|
|
29
4
|
private _notificationCache;
|
|
@@ -2,11 +2,13 @@ import { OverlayWidgetConfig, OverlayWidgetType, WidgetUIAction, WidgetOverlayEv
|
|
|
2
2
|
import { TypedEmitter } from "tiny-typed-emitter";
|
|
3
3
|
type Events = {
|
|
4
4
|
"overlay-widget-type-registered": (overlayWidgetType: OverlayWidgetType) => void;
|
|
5
|
+
"overlay-widget-type-unregistered": (id: string) => void;
|
|
5
6
|
};
|
|
6
7
|
declare class OverlayWidgetsManager extends TypedEmitter<Events> {
|
|
7
8
|
private overlayWidgetTypes;
|
|
8
9
|
constructor();
|
|
9
10
|
registerOverlayWidgetType(overlayWidgetType: OverlayWidgetType<any, any>): void;
|
|
11
|
+
unregisterOverlayWidgetType(id: string): void;
|
|
10
12
|
getOverlayWidgetType(id: string): OverlayWidgetType | null;
|
|
11
13
|
getOverlayWidgetTypesForFrontend(): (Pick<OverlayWidgetType, "id" | "name" | "description" | "icon" | "settingsSchema" | "userCanConfigure" | "supportsLivePreview" | "initialState" | "initialAspectRatio" | "nonEditableSettings"> & {
|
|
12
14
|
uiActions?: Omit<WidgetUIAction, "click">[];
|
|
@@ -31,14 +31,15 @@ export interface ScriptApiContext {
|
|
|
31
31
|
export interface ScriptApiContextHandle {
|
|
32
32
|
readonly context: ScriptApiContext;
|
|
33
33
|
readonly disposeBag: DisposeBag;
|
|
34
|
-
setManifest(manifest: Manifest | undefined): void;
|
|
35
34
|
}
|
|
36
35
|
export type ScriptApiContextSource = {
|
|
37
36
|
kind: "plugin";
|
|
38
37
|
config: InstalledPluginConfig;
|
|
38
|
+
manifest: Manifest;
|
|
39
39
|
} | {
|
|
40
40
|
kind: "effect-script";
|
|
41
41
|
fileName: string;
|
|
42
|
+
manifest: Manifest;
|
|
42
43
|
};
|
|
43
44
|
export declare function createScriptApiContext(source: ScriptApiContextSource): ScriptApiContextHandle;
|
|
44
45
|
export { normalizeName };
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export type NotificationSource = "external" | "internal" | "script";
|
|
2
|
+
|
|
3
|
+
export type NotificationType = "info" | "tip" | "update" | "alert";
|
|
4
|
+
|
|
5
|
+
export type ExternalNotification = {
|
|
6
|
+
id: string;
|
|
7
|
+
title: string;
|
|
8
|
+
message: string;
|
|
9
|
+
type: NotificationType;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type NotificationBase = {
|
|
13
|
+
title: string;
|
|
14
|
+
message: string;
|
|
15
|
+
type: NotificationType;
|
|
16
|
+
source?: NotificationSource;
|
|
17
|
+
scriptName?: string;
|
|
18
|
+
externalId?: string;
|
|
19
|
+
metadata?: Record<string, unknown>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type Notification = NotificationBase & {
|
|
23
|
+
id: string;
|
|
24
|
+
timestamp: Date;
|
|
25
|
+
saved: boolean;
|
|
26
|
+
read: boolean;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export interface NotificationCache {
|
|
30
|
+
dbVersion?: string;
|
|
31
|
+
notifications: Notification[];
|
|
32
|
+
knownExternalIds: string[];
|
|
33
|
+
}
|
package/types/plugins.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { FirebotParams, FirebotParameterArray } from "./parameters";
|
|
|
10
10
|
import { FirebotGame } from "./games";
|
|
11
11
|
import { Integration } from "./integrations";
|
|
12
12
|
import { UIExtension } from "./ui-extensions";
|
|
13
|
+
import { OverlayWidgetType } from "./overlay-widgets";
|
|
13
14
|
|
|
14
15
|
type NoResult = Awaitable<void>;
|
|
15
16
|
|
|
@@ -100,28 +101,21 @@ export interface ScriptBase<Params extends FirebotParams = FirebotParams> {
|
|
|
100
101
|
manifest: Manifest;
|
|
101
102
|
|
|
102
103
|
parametersSchema?: FirebotParameterArray<Params>;
|
|
103
|
-
|
|
104
|
-
// if uninstalled is true, the script is being removed by the user, thus the script should remove related data files/assets
|
|
105
|
-
// otherwise the script should assume firebot is closing or the script is being reloaded
|
|
106
|
-
onUnload?: (context: ScriptContext<Params>, isUninstalling?: boolean) => NoResult;
|
|
107
104
|
}
|
|
108
105
|
|
|
109
|
-
// Supplants the "Run Script" effect script functionality
|
|
110
106
|
export interface EffectScript<Params extends FirebotParams = FirebotParams> extends ScriptBase<Params> {
|
|
111
107
|
run: (context: ScriptContext<Params>) => Awaitable<void | EffectScriptResult>;
|
|
112
108
|
}
|
|
113
109
|
|
|
114
|
-
// Supplants the "Start up" script functionality
|
|
115
110
|
export interface Plugin<Params extends FirebotParams = FirebotParams> extends ScriptBase<Params> {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
111
|
+
/**
|
|
112
|
+
* Automatically handles registration with appropriate managers for definitions
|
|
113
|
+
* when the script is unloaded, definitions will automagically be unregistered.
|
|
114
|
+
*
|
|
115
|
+
* Array entries can be direct definitions or functions that return definitions
|
|
116
|
+
* (or promises of definitions) for dynamic registration based on context (e.g. parameter values).
|
|
117
|
+
*/
|
|
121
118
|
registers?: {
|
|
122
|
-
|
|
123
|
-
// If value within array is a function, call said function to get definition
|
|
124
|
-
// If definition is or evaluates to promise, await promise
|
|
125
119
|
effects?: DynamicArray<EffectType<any, any>>;
|
|
126
120
|
eventSources?: DynamicArray<EventSource>;
|
|
127
121
|
variables?: DynamicArray<ReplaceVariable>;
|
|
@@ -131,15 +125,16 @@ export interface Plugin<Params extends FirebotParams = FirebotParams> extends Sc
|
|
|
131
125
|
systemCommands?: DynamicArray<SystemCommand<any>>;
|
|
132
126
|
games?: DynamicArray<FirebotGame>;
|
|
133
127
|
uiExtensions?: DynamicArray<UIExtension>;
|
|
128
|
+
overlayWidgets?: DynamicArray<OverlayWidgetType<any, any>>;
|
|
134
129
|
};
|
|
135
130
|
|
|
136
|
-
|
|
131
|
+
/** Called when the plugin is loaded */
|
|
137
132
|
onLoad?: (context: ScriptContext<Params>, isInstalling?: boolean) => NoResult;
|
|
138
133
|
|
|
139
|
-
|
|
134
|
+
/** Called when Firebot is closing or plugin is disabled / removed */
|
|
140
135
|
onUnload?: (context: ScriptContext<Params>, isUninstalling?: boolean) => NoResult;
|
|
141
136
|
|
|
142
|
-
|
|
137
|
+
/** Called when the user updates plugin-specific parameters */
|
|
143
138
|
onParameterUpdate?: (context: ScriptContext<Params>) => NoResult;
|
|
144
139
|
}
|
|
145
140
|
|
|
@@ -151,7 +146,6 @@ export type InstalledPlugin = {
|
|
|
151
146
|
};
|
|
152
147
|
|
|
153
148
|
/* Legacy types */
|
|
154
|
-
|
|
155
149
|
type LegacyScriptParameters = Record<
|
|
156
150
|
string,
|
|
157
151
|
{
|
package/types/script-api.d.ts
CHANGED
|
@@ -7,6 +7,10 @@
|
|
|
7
7
|
import type { TriggeredEvent } from "./events";
|
|
8
8
|
import type { RunEffectsContext } from "./effects";
|
|
9
9
|
import type { TwitchApi } from "../backend/streaming-platforms/twitch/api";
|
|
10
|
+
import type { Notification } from "./notifications";
|
|
11
|
+
import type { FirebotAccount } from "./accounts";
|
|
12
|
+
import type { FirebotSettingsTypes } from "./settings";
|
|
13
|
+
import type { InstalledPlugin } from "./plugins";
|
|
10
14
|
|
|
11
15
|
export type ScriptLogMethod = (message: string, ...meta: unknown[]) => void;
|
|
12
16
|
|
|
@@ -129,6 +133,22 @@ export interface ScriptParametersApi {
|
|
|
129
133
|
getAll<T extends Record<string, unknown> = Record<string, unknown>>(): T;
|
|
130
134
|
}
|
|
131
135
|
|
|
136
|
+
export interface ScriptNotificationsApi {
|
|
137
|
+
/**
|
|
138
|
+
* Create a new notification. Pass `permanentlySave` as `true` to persist it
|
|
139
|
+
* across restarts.
|
|
140
|
+
*/
|
|
141
|
+
add(notification: Pick<Notification, "title" | "message" | "type" | "metadata">, permanentlySave?: boolean): Notification;
|
|
142
|
+
/** Look up one of this script's notifications by id. */
|
|
143
|
+
get(id: string): Notification | null;
|
|
144
|
+
/** All notifications owned by this script. */
|
|
145
|
+
getAll(): Notification[];
|
|
146
|
+
/** Delete one of this script's notifications by id. */
|
|
147
|
+
delete(id: string): void;
|
|
148
|
+
/** Delete all of this script's notifications. */
|
|
149
|
+
clearAll(): void;
|
|
150
|
+
}
|
|
151
|
+
|
|
132
152
|
export interface ScriptFrontendCommunicatorApi {
|
|
133
153
|
/** Send a synchronous event to the frontend. */
|
|
134
154
|
send<ExpectedArg = unknown>(eventName: string, data?: ExpectedArg): void;
|
|
@@ -161,11 +181,37 @@ export interface ScriptFrontendCommunicatorApi {
|
|
|
161
181
|
): () => void;
|
|
162
182
|
}
|
|
163
183
|
|
|
184
|
+
export interface ScriptSettingsApi {
|
|
185
|
+
/**
|
|
186
|
+
* Get a Firebot setting value or its default
|
|
187
|
+
*
|
|
188
|
+
* @param settingName Name of the setting to get
|
|
189
|
+
* @returns Setting value, or the default if one isn't explicitly set
|
|
190
|
+
*/
|
|
191
|
+
getSetting<SettingName extends keyof FirebotSettingsTypes>(settingName: SettingName): FirebotSettingsTypes[SettingName];
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export interface ScriptPluginsApi {
|
|
195
|
+
/**
|
|
196
|
+
* Get a list of currently installed plugins installed by the user
|
|
197
|
+
*/
|
|
198
|
+
getInstalledPlugins(): Promise<Array<InstalledPlugin>>;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export interface Accounts {
|
|
202
|
+
streamer: FirebotAccount;
|
|
203
|
+
bot: FirebotAccount;
|
|
204
|
+
}
|
|
205
|
+
|
|
164
206
|
export interface FirebotScriptApi {
|
|
165
|
-
/** Running Firebot version, e.g. `"5.
|
|
207
|
+
/** Running Firebot version, e.g. `"5.67.0"`. */
|
|
166
208
|
version: string;
|
|
209
|
+
/** The streamer and bot accounts currently in use. */
|
|
210
|
+
accounts: Accounts;
|
|
167
211
|
/** Scoped logger. */
|
|
168
212
|
logger: ScriptLoggerApi;
|
|
213
|
+
/** Access to Firebot settings. */
|
|
214
|
+
settings: ScriptSettingsApi;
|
|
169
215
|
/** Webhooks owned by this script. */
|
|
170
216
|
webhooks: ScriptWebhooksApi;
|
|
171
217
|
/** Simple persistent storage rooted at this script's data directory. */
|
|
@@ -180,4 +226,8 @@ export interface FirebotScriptApi {
|
|
|
180
226
|
parameters: ScriptParametersApi;
|
|
181
227
|
/** Two-way messaging between the script and the frontend. */
|
|
182
228
|
frontendCommunicator: ScriptFrontendCommunicatorApi;
|
|
229
|
+
/** Notifications owned by this script. */
|
|
230
|
+
notifications: ScriptNotificationsApi;
|
|
231
|
+
/** Access to installed plugins. */
|
|
232
|
+
plugins: ScriptPluginsApi;
|
|
183
233
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -10,10 +10,10 @@ type GetScriptDetailsResult = {
|
|
|
10
10
|
error: string;
|
|
11
11
|
};
|
|
12
12
|
declare class ScriptManager {
|
|
13
|
+
private startingPlugins;
|
|
13
14
|
private activePlugins;
|
|
14
15
|
private pendingApiInstances;
|
|
15
16
|
private effectScriptApiInstances;
|
|
16
|
-
private startingPlugins;
|
|
17
17
|
private requireInterceptorInstalled;
|
|
18
18
|
private pluginExecutors;
|
|
19
19
|
private effectScriptExecutors;
|