@crowbartools/firebot-types 5.67.0-alpha7 → 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.
Files changed (33) hide show
  1. package/backend/crowbar-relay/crowbar-relay-websocket.d.ts +1 -0
  2. package/backend/notifications/notification-manager.d.ts +1 -26
  3. package/backend/overlay-widgets/overlay-widgets-manager.d.ts +2 -0
  4. package/backend/{custom-scripts → scripts}/executors/script-executor.interface.d.ts +1 -0
  5. package/backend/{custom-scripts → scripts}/script-api/context.d.ts +2 -1
  6. package/backend/scripts/script-api/namespaces/notifications.d.ts +2 -0
  7. package/backend/scripts/script-api/namespaces/plugins.d.ts +2 -0
  8. package/backend/scripts/script-api/namespaces/settings.d.ts +2 -0
  9. package/package.json +1 -1
  10. package/types/index.d.ts +1 -0
  11. package/types/notifications.d.ts +33 -0
  12. package/types/plugins.d.ts +18 -23
  13. package/types/script-api.d.ts +51 -1
  14. package/backend/{custom-scripts → scripts}/executors/effect-script-executor.d.ts +0 -0
  15. package/backend/{custom-scripts → scripts}/executors/legacy-effect-script-executor.d.ts +0 -0
  16. package/backend/{custom-scripts → scripts}/executors/legacy-startup-script-executor.d.ts +0 -0
  17. package/backend/{custom-scripts → scripts}/executors/plugin-executor.d.ts +0 -0
  18. package/backend/{custom-scripts → scripts}/plugin-config-manager.d.ts +0 -0
  19. package/backend/{custom-scripts → scripts}/plugin-manifest-utils.d.ts +0 -0
  20. package/backend/{custom-scripts → scripts}/script-api/index.d.ts +0 -0
  21. package/backend/{custom-scripts → scripts}/script-api/internal/define-namespace.d.ts +0 -0
  22. package/backend/{custom-scripts → scripts}/script-api/internal/dispose-bag.d.ts +0 -0
  23. package/backend/{custom-scripts → scripts}/script-api/internal/name-normalizer.d.ts +0 -0
  24. package/backend/{custom-scripts → scripts}/script-api/internal/script-data-dir.d.ts +0 -0
  25. package/backend/{custom-scripts → scripts}/script-api/namespaces/effects.d.ts +0 -0
  26. package/backend/{custom-scripts → scripts}/script-api/namespaces/events.d.ts +0 -0
  27. package/backend/{custom-scripts → scripts}/script-api/namespaces/frontend-communicator.d.ts +0 -0
  28. package/backend/{custom-scripts → scripts}/script-api/namespaces/logger.d.ts +0 -0
  29. package/backend/{custom-scripts → scripts}/script-api/namespaces/parameters.d.ts +0 -0
  30. package/backend/{custom-scripts → scripts}/script-api/namespaces/storage.d.ts +0 -0
  31. package/backend/{custom-scripts → scripts}/script-api/namespaces/twitch.d.ts +0 -0
  32. package/backend/{custom-scripts → scripts}/script-api/namespaces/webhooks.d.ts +0 -0
  33. package/backend/{custom-scripts → scripts}/script-manager.d.ts +1 -1
@@ -7,6 +7,7 @@ declare class CrowbarRelayWebSocket extends TypedEmitter<{
7
7
  }) => void;
8
8
  }> {
9
9
  private ws;
10
+ private logger;
10
11
  constructor();
11
12
  private start;
12
13
  send(event: string, data?: unknown): void;
@@ -1,29 +1,4 @@
1
- export declare enum NotificationSource {
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">[];
@@ -13,6 +13,7 @@ export interface PluginRegistrations {
13
13
  integrationIds?: string[];
14
14
  gameIds?: string[];
15
15
  uiExtensionIds?: string[];
16
+ overlayWidgetIds?: string[];
16
17
  }
17
18
  export type PluginExecutionResult = {
18
19
  success: true;
@@ -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 };
@@ -0,0 +1,2 @@
1
+ import type { ScriptNotificationsApi } from "../../../../types/script-api";
2
+ export declare const createNotificationsApi: import("../internal/define-namespace").ScriptApiNamespaceFactory<ScriptNotificationsApi>;
@@ -0,0 +1,2 @@
1
+ import type { ScriptPluginsApi } from "../../../../types/script-api";
2
+ export declare const createPluginsApi: import("../internal/define-namespace").ScriptApiNamespaceFactory<ScriptPluginsApi>;
@@ -0,0 +1,2 @@
1
+ import type { ScriptSettingsApi } from "../../../../types/script-api";
2
+ export declare const createSettingsApi: import("../internal/define-namespace").ScriptApiNamespaceFactory<ScriptSettingsApi>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowbartools/firebot-types",
3
- "version": "5.67.0-alpha7",
3
+ "version": "5.67.0-alpha9",
4
4
  "description": "Type definitions and script API for Firebot plugins and custom scripts.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
package/types/index.d.ts CHANGED
@@ -17,6 +17,7 @@ export * from "./import";
17
17
  export * from "./integrations";
18
18
  export * from "./moderation";
19
19
  export * from "./modules";
20
+ export * from "./notifications";
20
21
  export * from "./overlay-widgets";
21
22
  export * from "./parameters";
22
23
  export * from "./pronouns";
@@ -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
+ }
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
1
2
  import { EffectInstance, EffectList, EffectType } from "./effects";
2
3
  import { Trigger } from "./triggers";
3
4
  import { Awaitable } from "./util-types";
@@ -9,6 +10,7 @@ import { FirebotParams, FirebotParameterArray } from "./parameters";
9
10
  import { FirebotGame } from "./games";
10
11
  import { Integration } from "./integrations";
11
12
  import { UIExtension } from "./ui-extensions";
13
+ import { OverlayWidgetType } from "./overlay-widgets";
12
14
 
13
15
  type NoResult = Awaitable<void>;
14
16
 
@@ -99,46 +101,40 @@ export interface ScriptBase<Params extends FirebotParams = FirebotParams> {
99
101
  manifest: Manifest;
100
102
 
101
103
  parametersSchema?: FirebotParameterArray<Params>;
102
-
103
- // if uninstalled is true, the script is being removed by the user, thus the script should remove related data files/assets
104
- // otherwise the script should assume firebot is closing or the script is being reloaded
105
- onUnload?: (context: ScriptContext<Params>, isUninstalling?: boolean) => NoResult;
106
104
  }
107
105
 
108
- // Supplants the "Run Script" effect script functionality
109
106
  export interface EffectScript<Params extends FirebotParams = FirebotParams> extends ScriptBase<Params> {
110
107
  run: (context: ScriptContext<Params>) => Awaitable<void | EffectScriptResult>;
111
108
  }
112
109
 
113
- // Supplants the "Start up" script functionality
114
110
  export interface Plugin<Params extends FirebotParams = FirebotParams> extends ScriptBase<Params> {
115
- // Note: At least one is required: onLoad or registers.*
116
- // if not met, the script will not be loaded and it should be logged the script does nothing
117
-
118
- // Automatically handles registration with appropriate managers for definitions
119
- // when the script is unloaded, definitions will automagically be unregistered
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
+ */
120
118
  registers?: {
121
-
122
- // If value within array is a function, call said function to get definition
123
- // If definition is or evaluates to promise, await promise
124
- effects?: DynamicArray<EffectType>;
119
+ effects?: DynamicArray<EffectType<any, any>>;
125
120
  eventSources?: DynamicArray<EventSource>;
126
121
  variables?: DynamicArray<ReplaceVariable>;
127
- integrations?: DynamicArray<Integration>;
122
+ integrations?: DynamicArray<Integration<any>>;
128
123
  filters?: DynamicArray<EventFilter>;
129
- restrictions?: DynamicArray<RestrictionType>;
130
- systemCommands?: DynamicArray<SystemCommand>;
124
+ restrictions?: DynamicArray<RestrictionType<any>>;
125
+ systemCommands?: DynamicArray<SystemCommand<any>>;
131
126
  games?: DynamicArray<FirebotGame>;
132
127
  uiExtensions?: DynamicArray<UIExtension>;
128
+ overlayWidgets?: DynamicArray<OverlayWidgetType<any, any>>;
133
129
  };
134
130
 
135
- // Called when the script is loaded
131
+ /** Called when the plugin is loaded */
136
132
  onLoad?: (context: ScriptContext<Params>, isInstalling?: boolean) => NoResult;
137
133
 
138
- // Called when firebot is closing or plugin is disabled / removed
134
+ /** Called when Firebot is closing or plugin is disabled / removed */
139
135
  onUnload?: (context: ScriptContext<Params>, isUninstalling?: boolean) => NoResult;
140
136
 
141
- // called when the user updates plugin-specific parameters
137
+ /** Called when the user updates plugin-specific parameters */
142
138
  onParameterUpdate?: (context: ScriptContext<Params>) => NoResult;
143
139
  }
144
140
 
@@ -150,11 +146,10 @@ export type InstalledPlugin = {
150
146
  };
151
147
 
152
148
  /* Legacy types */
153
-
154
149
  type LegacyScriptParameters = Record<
155
150
  string,
156
151
  {
157
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
152
+
158
153
  type: any;
159
154
  title?: string;
160
155
  description?: string;
@@ -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.65.0"`. */
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
  }
@@ -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;