@crowbartools/firebot-types 5.67.0-alpha1

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 (62) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +43 -0
  3. package/index.d.ts +5 -0
  4. package/index.js +5 -0
  5. package/package.json +44 -0
  6. package/types/accounts.d.ts +13 -0
  7. package/types/auth.d.ts +51 -0
  8. package/types/channel-rewards.d.ts +63 -0
  9. package/types/chat.d.ts +159 -0
  10. package/types/commands.d.ts +138 -0
  11. package/types/counters.d.ts +13 -0
  12. package/types/currency.d.ts +15 -0
  13. package/types/discord.d.ts +10 -0
  14. package/types/effects.d.ts +223 -0
  15. package/types/events.d.ts +99 -0
  16. package/types/expressionish.d.ts +74 -0
  17. package/types/games.d.ts +22 -0
  18. package/types/goals.d.ts +7 -0
  19. package/types/hotkeys.d.ts +12 -0
  20. package/types/icons.d.ts +6 -0
  21. package/types/import.d.ts +69 -0
  22. package/types/index.d.ts +40 -0
  23. package/types/integrations.d.ts +93 -0
  24. package/types/moderation.d.ts +59 -0
  25. package/types/modules/event-manager.d.ts +29 -0
  26. package/types/modules/frontend-communicator.d.ts +53 -0
  27. package/types/modules/index.d.ts +2 -0
  28. package/types/overlay-widgets.d.ts +240 -0
  29. package/types/parameters.d.ts +414 -0
  30. package/types/plugins.d.ts +201 -0
  31. package/types/power-ups.d.ts +20 -0
  32. package/types/pronouns.d.ts +11 -0
  33. package/types/quick-actions.d.ts +18 -0
  34. package/types/quotes.d.ts +17 -0
  35. package/types/ranks.d.ts +23 -0
  36. package/types/restrictions.d.ts +65 -0
  37. package/types/roles.d.ts +21 -0
  38. package/types/script-api.d.ts +95 -0
  39. package/types/settings.d.ts +131 -0
  40. package/types/setups.d.ts +49 -0
  41. package/types/sort-tags.d.ts +4 -0
  42. package/types/timers.d.ts +36 -0
  43. package/types/triggers.d.ts +61 -0
  44. package/types/ui/angular.d.ts +31 -0
  45. package/types/ui/backend-communicator.d.ts +8 -0
  46. package/types/ui/effect-helper-service.d.ts +5 -0
  47. package/types/ui/effect-queues-service.d.ts +10 -0
  48. package/types/ui/firebot-root-scope.d.ts +5 -0
  49. package/types/ui/index.d.ts +12 -0
  50. package/types/ui/modal-factory.d.ts +30 -0
  51. package/types/ui/modal-service.d.ts +21 -0
  52. package/types/ui/ng-toast.d.ts +3 -0
  53. package/types/ui/object-copy-helper.d.ts +9 -0
  54. package/types/ui/platform-service.d.ts +7 -0
  55. package/types/ui/preset-effect-lists-service.d.ts +20 -0
  56. package/types/ui/settings-service.d.ts +5 -0
  57. package/types/util-types.d.ts +52 -0
  58. package/types/variable-macros.d.ts +7 -0
  59. package/types/variables.d.ts +59 -0
  60. package/types/viewers.d.ts +30 -0
  61. package/types/webhooks.d.ts +5 -0
  62. package/types/websocket.d.ts +70 -0
@@ -0,0 +1,29 @@
1
+ import type { EventSource } from "../events";
2
+
3
+ export type EventManagerModule = {
4
+ /**
5
+ * Registers an event source in Firebot.
6
+ * @param eventSource The {@linkcode EventSource} you want to register.
7
+ */
8
+ registerEventSource: (eventSource: EventSource) => void;
9
+
10
+ /**
11
+ * Unregisters an event source from Firebot.
12
+ * @param eventSourceId The ID of the event source to unregister.
13
+ */
14
+ unregisterEventSource: (eventSourceId: string) => void;
15
+
16
+ /**
17
+ * Triggers an event in Firebot.
18
+ * @param eventSourceId The ID of the event source.
19
+ * @param eventId The ID of the event.
20
+ * @param meta Any metadata you want to include with the event.
21
+ * @param isManual `true` if the event is being triggered manually, `false` otherwise.
22
+ */
23
+ triggerEvent: (
24
+ eventSourceId: string,
25
+ eventId: string,
26
+ meta: Record<string, unknown>,
27
+ isManual?: boolean
28
+ ) => void;
29
+ };
@@ -0,0 +1,53 @@
1
+ export interface FrontendCommunicatorModule {
2
+ /** Send a synchronous event to the frontend.
3
+ * @template ExpectedArg The type of event data to supply.
4
+ * @param eventName The name of the event to send.
5
+ * @param data Data to provide to the event handler.
6
+ */
7
+ send<ExpectedArg = unknown>(
8
+ eventName: string,
9
+ data?: ExpectedArg
10
+ ): void;
11
+
12
+ /** Handle a synchronous event triggered by the frontend.
13
+ * @template ExpectedArgs The type of data provided with the event.
14
+ * @template ReturnPayload The type of data returned from the event handler.
15
+ * @param eventName The name of the event to handle.
16
+ * @param callback A function to handle the event.
17
+ * @returns Unique ID of the registered event handler.
18
+ */
19
+ on<ExpectedArgs extends Array<unknown> = [], ReturnPayload = void>(
20
+ eventName: string,
21
+ callback: (...args: ExpectedArgs) => ReturnPayload
22
+ ): void;
23
+
24
+ /** Handle an asynchronous event triggered by the frontend.
25
+ * @template ExpectedArgs The type of data provided with the event.
26
+ * @template ReturnPayload The type of data returned from the event handler.
27
+ * @param eventName The name of the event to handle asynchronously.
28
+ * @param callback A function to asynchronously handle the event.
29
+ * @returns Unique ID of the registered event handler.
30
+ */
31
+ onAsync<ExpectedArgs extends Array<unknown> = [], ReturnPayload = void>(
32
+ eventName: string,
33
+ callback: (...args: ExpectedArgs) => Promise<ReturnPayload>
34
+ ): void;
35
+
36
+ /** Send an asynchronous event to the frontend that is capable of returning a result.
37
+ * @template ReturnPayload The type of data returned from the event handler.
38
+ * @template ExpectedArg The type of data provided with the event.
39
+ * @param eventName The name of the event to send.
40
+ * @param data The data to provide with the event.
41
+ */
42
+ fireEventAsync<ReturnPayload = void, ExpectedArg = unknown>(
43
+ eventName: string,
44
+ data?: ExpectedArg
45
+ ): Promise<ReturnPayload>;
46
+
47
+ /**
48
+ * Unregisters a previously registered frontend event handler.
49
+ * @param eventName The name of the event.
50
+ * @param id The unique ID of the event handler to unregister. This ID is returned when you create an event handler using {@linkcode FrontendCommunicator.on | on} or {@linkcode FrontendCommunicator.onAsync | onAsync}.
51
+ */
52
+ off(eventName: string, id: string): void;
53
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./event-manager";
2
+ export * from "./frontend-communicator";
@@ -0,0 +1,240 @@
1
+ import type { FirebotParameterArray, FontOptions } from "./parameters";
2
+ import type { Awaitable } from "./util-types";
3
+
4
+ export type Position = {
5
+ x: number;
6
+ y: number;
7
+ width: number;
8
+ height: number;
9
+ };
10
+
11
+ export type Animation = {
12
+ /**
13
+ * CSS class name for the animation (e.g., from Animate.css)
14
+ */
15
+ class: string;
16
+ /**
17
+ * Custom duration in seconds
18
+ */
19
+ duration?: number;
20
+ };
21
+
22
+ type WidgetEvent<Settings, State> = OverlayWidgetConfig<Settings, State> & {
23
+ previewMode: boolean;
24
+ previousState?: State;
25
+ persisted?: boolean;
26
+ };
27
+
28
+ export type WidgetEventResult<State> = {
29
+ newState?: State | null;
30
+ /**
31
+ * If true, the new state will be persisted to file.
32
+ * @default false
33
+ */
34
+ persistState?: boolean;
35
+ };
36
+
37
+ export type WidgetEventHandler<Settings, State, Return = WidgetEventResult<State>> = (event: WidgetEvent<Settings, State>) => Awaitable<Return | undefined>;
38
+
39
+ export type WidgetUIAction<
40
+ Settings extends Record<string, unknown> = Record<string, unknown>,
41
+ State = Record<string, unknown>
42
+ > = {
43
+ id: string;
44
+ label: string;
45
+ icon: string;
46
+
47
+ click: (config: OverlayWidgetConfig<Settings, State>) => Awaitable<{
48
+ newState?: State | null;
49
+ } | void>;
50
+ };
51
+
52
+ export type OverlayWidgetType<
53
+ Settings extends Record<string, unknown> = Record<string, unknown>,
54
+ State = Record<string, unknown>
55
+ > = {
56
+ id: string;
57
+ name: string;
58
+ description: string;
59
+ icon: string;
60
+ userCanConfigure?: {
61
+ /**
62
+ * @default true
63
+ */
64
+ position?: boolean;
65
+ /**
66
+ * @default true
67
+ */
68
+ zIndex?: boolean;
69
+ /**
70
+ * @default true
71
+ */
72
+ entryAnimation?: boolean;
73
+ /**
74
+ * @default true
75
+ */
76
+ exitAnimation?: boolean;
77
+ };
78
+ /**
79
+ * Initial aspect ratio for the widget. Used to set a default size when adding the widget.
80
+ * @example { width: 16, height: 9 } for a 16:9 aspect ratio.
81
+ * @default { width: 16, height: 9 } (16:9)
82
+ */
83
+ initialAspectRatio?: {
84
+ width: number;
85
+ height: number;
86
+ };
87
+ /**
88
+ * Settings allow the user to customize the widget instance (e.g., font to use, colors, etc.)
89
+ */
90
+ settingsSchema?: FirebotParameterArray<Settings>;
91
+
92
+ /**
93
+ * Array of setting keys that cannot be edited in the Update Overlay Widget Settings effect.
94
+ */
95
+ nonEditableSettings?: (keyof Settings)[];
96
+
97
+ /**
98
+ * Initial state for the widget instance (e.g., current count for a counter widget)
99
+ */
100
+ initialState?: State;
101
+ /**
102
+ * Whether the widget supports live preview mode when adding or editing the widget.
103
+ * Widget types should only enable this if all settings have default values or
104
+ * the widget gracefully handles missing settings.
105
+ *
106
+ * Default is false.
107
+ */
108
+ supportsLivePreview?: boolean;
109
+ /**
110
+ * State that is used when the widget is shown in live preview mode.
111
+ */
112
+ livePreviewState?: State;
113
+
114
+ /**
115
+ * Array of setting keys that reference local resource paths.
116
+ * These properties will be automatically converted to resource tokens when sent to the overlay,
117
+ */
118
+ resourceKeys?: Array<keyof Settings>;
119
+ /**
120
+ * Function that returns a short string representing the current state of the widget.
121
+ * This is shown in the overlay widget list to give the user a quick overview of the widget's state.
122
+ * If null or undefined, no state display is shown.
123
+ */
124
+
125
+ stateDisplay?: (config: OverlayWidgetConfig<Settings, State>) => string | null;
126
+ /**
127
+ * Actions are buttons shown in the overlay widget list for each widget instance.
128
+ * They allow the user to quickly perform common actions on the widget (e.g., start or stop a countdown timer).
129
+ */
130
+ uiActions?: WidgetUIAction<Settings, State>[];
131
+ /**
132
+ * Called before the widget is shown on the overlay. You can modify state here.
133
+ */
134
+ onShow?: WidgetEventHandler<Settings, State>;
135
+ /**
136
+ * Called when the widget settings are updated. You can modify state here.
137
+ */
138
+ onSettingsUpdate?: WidgetEventHandler<Settings, State>;
139
+ /**
140
+ * Called when the widget state is updated. You can't modify state here (would cause infinite loop).
141
+ */
142
+ onStateUpdate?: WidgetEventHandler<Settings, State, void>;
143
+ /**
144
+ * Called before the widget is removed from the overlay. You can modify state here.
145
+ */
146
+ onRemove?: WidgetEventHandler<Settings, State>;
147
+ /**
148
+ * Called when the widget sends a message from the overlay.
149
+ */
150
+ onOverlayMessage?: (config: OverlayWidgetConfig<Settings, State>, messageName: string, messageData?: unknown) => Awaitable<void>;
151
+ /**
152
+ * This code is injected into the overlay. Do not reference any variables outside this scope.
153
+ */
154
+ overlayExtension: {
155
+ dependencies?: {
156
+ css?: string[];
157
+ js?: Array<string | { module: boolean, url: string }>;
158
+ globalStyles?: string;
159
+ };
160
+
161
+ eventHandler: (event: WidgetOverlayEvent, utils: IOverlayWidgetEventUtils) => void;
162
+ /**
163
+ * Called when the overlay is loaded. Can be async.
164
+ */
165
+ onInitialLoad?: (utils: IOverlayWidgetInitUtils) => Awaitable<void>;
166
+ };
167
+ };
168
+
169
+ type OverlayWidgetConfig<Settings = Record<string, unknown>, State = Record<string, unknown>> = {
170
+ id: string;
171
+ name: string;
172
+ type: string;
173
+ /**
174
+ * Whether the overlay widget is active and should be rendered on the overlay.
175
+ * Default is true.
176
+ */
177
+ active?: boolean;
178
+ position: Position;
179
+ zIndex?: number;
180
+ /**
181
+ * Overlay instance ID where this widget should be shown.
182
+ * If null or undefined, the widget will be shown on the default overlay.
183
+ */
184
+ overlayInstance?: string | null;
185
+ entryAnimation?: Animation | null;
186
+ exitAnimation?: Animation | null;
187
+ settings: Settings;
188
+ state?: State;
189
+ };
190
+
191
+ export type WidgetOverlayEvent<Settings = Record<string, unknown>, State = Record<string, unknown>> = {
192
+ name: "show" | "settings-update" | "state-update" | "message" | "remove";
193
+ data: {
194
+ widgetConfig: Pick<OverlayWidgetConfig<Settings, State>, "id" | "name" | "type" | "position" | "entryAnimation" | "exitAnimation" | "settings" | "state" | "overlayInstance" | "zIndex"> & {
195
+ resourceTokens: {
196
+ [K in keyof Settings]: string;
197
+ };
198
+ };
199
+ widgetType: Pick<OverlayWidgetType, "id" | "userCanConfigure">;
200
+ previewMode: boolean;
201
+ /**
202
+ * For "message" events, the name of the message being sent.
203
+ */
204
+ messageName?: string;
205
+ /**
206
+ * For "message" events, any data associated with the message.
207
+ */
208
+ messageData?: unknown;
209
+ };
210
+ };
211
+
212
+ /**
213
+ * Utility functions for managing overlay widgets. These functions can used within the overlayExtension.eventHandler
214
+ */
215
+ export interface IOverlayWidgetEventUtils {
216
+ /**
217
+ * Automatically handles overlay events for the widget, including showing, updating, and removing the widget using the provided HTML generator function.
218
+ *
219
+ * @param generateWidgetHtml Function that generates the HTML for the widget based on its current configuration.
220
+ * @param updateOnMessage If true, the widget HTML will be updated when a "message" event is received. Default is false.
221
+ */
222
+ handleOverlayEvent(generateWidgetHtml: (widgetConfig: WidgetOverlayEvent["data"]["widgetConfig"]) => string, updateOnMessage?: boolean): void;
223
+ getWidgetPositionStyle(position?: Position): string;
224
+ getWidgetContainerElement(): HTMLElement | null;
225
+ initializeWidget(
226
+ html: string
227
+ ): void;
228
+ updateWidgetContent(
229
+ newHtml: string,
230
+ ): void;
231
+ updateWidgetPosition(): void;
232
+ removeWidget(): void;
233
+ stylesToString(styles: Record<string, string | number | undefined>): string;
234
+ getFontOptionsStyles(fontOptions?: FontOptions): Record<string, string | number | undefined>;
235
+ sendMessageToFirebot(messageName: string, messageData?: unknown): void;
236
+ }
237
+
238
+ export interface IOverlayWidgetInitUtils {
239
+ getWidgetContainerElements(): NodeListOf<HTMLElement>;
240
+ }