@rocketman-streamkit/types 1.0.5 → 1.0.7
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/README.md +1 -1
- package/addon.d.ts +128 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ API reference, manifest format, permissions, and addon categories are published
|
|
|
14
14
|
|
|
15
15
|
**[github.com/RocketMan-StreamKit/types](https://github.com/RocketMan-StreamKit/types)**
|
|
16
16
|
|
|
17
|
-
Open the branch that matches your target app version (for example `1.0.
|
|
17
|
+
Open the branch that matches your target app version (for example `1.0.7`) and start from [`index.md`](https://github.com/RocketMan-StreamKit/types/blob/1.0.7/index.md).
|
|
18
18
|
|
|
19
19
|
This npm package provides **TypeScript typings only**; the docs repo is the full written guide.
|
|
20
20
|
|
package/addon.d.ts
CHANGED
|
@@ -103,6 +103,60 @@ declare global {
|
|
|
103
103
|
sourceAddonId?: string;
|
|
104
104
|
};
|
|
105
105
|
|
|
106
|
+
type OverlayTriggerType = | 'donation'
|
|
107
|
+
| 'subscribe'
|
|
108
|
+
| 'subgift'
|
|
109
|
+
| 'follow'
|
|
110
|
+
| 'custom';
|
|
111
|
+
|
|
112
|
+
type OverlayEventTrigger = {
|
|
113
|
+
type: OverlayTriggerType;
|
|
114
|
+
key?: string;
|
|
115
|
+
value?: string | number | boolean;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Currency code key from the built-in exchange rates table.
|
|
120
|
+
*/
|
|
121
|
+
type CurrencyCode = string;
|
|
122
|
+
|
|
123
|
+
type DashboardRecordType = | 'donation'
|
|
124
|
+
| 'subscribe'
|
|
125
|
+
| 'follow'
|
|
126
|
+
| 'custom'
|
|
127
|
+
| 'timer';
|
|
128
|
+
|
|
129
|
+
type DashboardRecordValue = {
|
|
130
|
+
id: string;
|
|
131
|
+
type: DashboardRecordType;
|
|
132
|
+
amount?: [number, CurrencyCode];
|
|
133
|
+
platform: string;
|
|
134
|
+
message?: DashboardLocalizedString;
|
|
135
|
+
from?: string;
|
|
136
|
+
attach?: { type: string; value: string }[];
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Payload delivered to addons subscribed via `dashboard.onRecord`.
|
|
141
|
+
*/
|
|
142
|
+
type DashboardRecordIncomingPayload = {
|
|
143
|
+
id: string;
|
|
144
|
+
created: number;
|
|
145
|
+
updated: number;
|
|
146
|
+
record: DashboardRecordValue;
|
|
147
|
+
user?: {
|
|
148
|
+
id: string;
|
|
149
|
+
name: string;
|
|
150
|
+
avatar: string;
|
|
151
|
+
platform: string;
|
|
152
|
+
color?: string;
|
|
153
|
+
icons?: string[];
|
|
154
|
+
};
|
|
155
|
+
sourceAddonId?: string;
|
|
156
|
+
/** Trigger entries used for overlay/sound/hotkey/timer matching. */
|
|
157
|
+
triggers?: OverlayEventTrigger[];
|
|
158
|
+
};
|
|
159
|
+
|
|
106
160
|
type AddonConfigFieldType = | 'text'
|
|
107
161
|
| 'color'
|
|
108
162
|
| 'number'
|
|
@@ -350,6 +404,19 @@ declare global {
|
|
|
350
404
|
* @requires AddonsPermission.NOTIFY
|
|
351
405
|
*/
|
|
352
406
|
Send: (payload: { id?: string | undefined; type?: "error" | "success" | "info" | "warning" | undefined; title?: DashboardLocalizedString | undefined; message: DashboardLocalizedString; temp?: boolean | undefined; }) => void;
|
|
407
|
+
/**
|
|
408
|
+
* Removes a notification previously created by this addon.
|
|
409
|
+
Notifications from other addons or the main process are ignored.
|
|
410
|
+
* @requires AddonsPermission.NOTIFY
|
|
411
|
+
* @param id Notification record id (same value passed to `Send`).
|
|
412
|
+
* @example notify.Send({
|
|
413
|
+
id: `${data.id}_status`,
|
|
414
|
+
type: 'success',
|
|
415
|
+
message: { en: 'Connected' },
|
|
416
|
+
});
|
|
417
|
+
notify.Remove(`${data.id}_status`);
|
|
418
|
+
*/
|
|
419
|
+
Remove: (id: string) => void;
|
|
353
420
|
};
|
|
354
421
|
/**
|
|
355
422
|
* Permission helpers for the running addon instance.
|
|
@@ -382,9 +449,28 @@ declare global {
|
|
|
382
449
|
/**
|
|
383
450
|
* In-addon event bus. Used mainly to handle HTTP endpoint callbacks registered via `network.endpoints.create`.
|
|
384
451
|
Handlers run in the integration worker when the main process forwards `customEvent` messages.
|
|
452
|
+
|
|
453
|
+
**Built-in events (main process → addon)**
|
|
454
|
+
|
|
455
|
+
| Event | When | Payload |
|
|
456
|
+
| --- | --- | --- |
|
|
457
|
+
| `overlayTriggerValue:{provider}:list\|create\|release` | Dynamic trigger value UI in settings | See `registerTriggers` dynamic contract |
|
|
458
|
+
| `triggers:applied-changed` | After settings save when trigger bindings for this addon changed | `{ previous, current }` grouped by system (`overlay`, `timer`, `game`, `gameInput`, `sounds`, `hotkeys`) |
|
|
459
|
+
| `gameInputTrigger` | Matching dashboard event for a game input rule | `{ actionId, trigger, record, user }` |
|
|
385
460
|
* @example events.On('onDonation', payload => {
|
|
386
461
|
console.log('Donation', payload.body);
|
|
387
462
|
return { ok: true };
|
|
463
|
+
});
|
|
464
|
+
* @example // React when saved trigger bindings change (e.g. clear internal caches)
|
|
465
|
+
events.On('triggers:applied-changed', ({ previous, current }) => {
|
|
466
|
+
const removed = (previous.overlay || []).filter(
|
|
467
|
+
item => !(current.overlay || []).some(
|
|
468
|
+
next => next.targetId === item.targetId && next.trigger.value === item.trigger.value
|
|
469
|
+
)
|
|
470
|
+
);
|
|
471
|
+
if (removed.length) {
|
|
472
|
+
console.log('Overlay rules removed', removed);
|
|
473
|
+
}
|
|
388
474
|
});
|
|
389
475
|
*/
|
|
390
476
|
var events: {
|
|
@@ -849,11 +935,20 @@ declare global {
|
|
|
849
935
|
|
|
850
936
|
**Dynamic provider contract**
|
|
851
937
|
|
|
852
|
-
- `overlayTriggerValue:{provider}:list` → `{ success, items
|
|
853
|
-
- `overlayTriggerValue:{provider}:create` → `{ success, valueId?, label?, meta? }`
|
|
938
|
+
- `overlayTriggerValue:{provider}:list` → `{ success, items?, message?, notify? }`
|
|
939
|
+
- `overlayTriggerValue:{provider}:create` → `{ success, valueId?, label?, meta?, message?, notify? }`
|
|
854
940
|
(payload includes `title`, `overlayId`, `context` from `requireValue`)
|
|
855
|
-
- `overlayTriggerValue:{provider}:release` → `{ success }` (payload: `valueId`;
|
|
941
|
+
- `overlayTriggerValue:{provider}:release` → `{ success, message?, notify? }` (payload: `valueId`;
|
|
856
942
|
called on settings save when the value is no longer referenced)
|
|
943
|
+
|
|
944
|
+
Optional `notify` shows a modal in settings (`variant`: `success` | `error` | `info`; `title?`, `message`).
|
|
945
|
+
|
|
946
|
+
**Trigger bindings after save**
|
|
947
|
+
|
|
948
|
+
When the user saves settings and bindings for this addon change, the main process fires
|
|
949
|
+
`triggers:applied-changed` with `{ previous, current }`. Each side groups rules by consumer
|
|
950
|
+
system: `overlay`, `timer`, `game` (as event source), `gameInput` (game addons as target),
|
|
951
|
+
`sounds`, `hotkeys`. Omitted groups mean no rules in that system.
|
|
857
952
|
* @example // Follow — no value field
|
|
858
953
|
await dashboard.registerTriggers([
|
|
859
954
|
{ type: 'follow', label: { en: 'New follower', ru: 'Новый фолловер' } },
|
|
@@ -916,9 +1011,15 @@ declare global {
|
|
|
916
1011
|
},
|
|
917
1012
|
},
|
|
918
1013
|
]);
|
|
919
|
-
events.On('overlayTriggerValue:rewards:
|
|
1014
|
+
events.On('overlayTriggerValue:rewards:create', async ({ title, context }) => ({
|
|
920
1015
|
success: true,
|
|
921
|
-
|
|
1016
|
+
valueId: 'abc',
|
|
1017
|
+
label: title,
|
|
1018
|
+
notify: {
|
|
1019
|
+
variant: 'success',
|
|
1020
|
+
title: { en: 'Reward created', ru: 'Награда создана' },
|
|
1021
|
+
message: { en: `Cost: ${context?.cost}`, ru: `Стоимость: ${context?.cost}` },
|
|
1022
|
+
},
|
|
922
1023
|
}));
|
|
923
1024
|
* @example // Pass matching trigger when pushing dashboard events
|
|
924
1025
|
await dashboard.addRecord(
|
|
@@ -984,6 +1085,24 @@ declare global {
|
|
|
984
1085
|
* @requires AddonsPermission.DASHBOARD_CHAT_INCOMING
|
|
985
1086
|
*/
|
|
986
1087
|
offChatMessage: () => Promise<unknown>;
|
|
1088
|
+
/**
|
|
1089
|
+
* Subscribes to new event records shown in the latest-events dashboard widget.
|
|
1090
|
+
The handler receives the stored record (including system `attach` entries
|
|
1091
|
+
for matched overlays, sounds, hotkeys, and timers), resolved user info,
|
|
1092
|
+
trigger entries used for matching, and the source addon id (if any).
|
|
1093
|
+
Unlike chat incoming, the source addon also receives its own records so it
|
|
1094
|
+
can inspect match results after `dashboard.addRecord`.
|
|
1095
|
+
* @requires AddonsPermission.DASHBOARD_EVENTS_INCOMING
|
|
1096
|
+
* @example dashboard.onRecord(payload => {
|
|
1097
|
+
console.log(payload.record.type, payload.record.attach, payload.sourceAddonId);
|
|
1098
|
+
});
|
|
1099
|
+
*/
|
|
1100
|
+
onRecord: (handler: (payload: DashboardRecordIncomingPayload) => void | Promise<void>) => Promise<unknown>;
|
|
1101
|
+
/**
|
|
1102
|
+
* Unsubscribes from incoming dashboard event records.
|
|
1103
|
+
* @requires AddonsPermission.DASHBOARD_EVENTS_INCOMING
|
|
1104
|
+
*/
|
|
1105
|
+
offRecord: () => Promise<unknown>;
|
|
987
1106
|
};
|
|
988
1107
|
/**
|
|
989
1108
|
* Game integration API for `manifest.type: "game"` addons.
|
|
@@ -1144,6 +1263,10 @@ declare global {
|
|
|
1144
1263
|
* Receive new chat messages from the chat dashboard window
|
|
1145
1264
|
*/
|
|
1146
1265
|
| 'DASHBOARD_CHAT_INCOMING'
|
|
1266
|
+
/**
|
|
1267
|
+
* Receive new event records from the latest-events dashboard widget
|
|
1268
|
+
*/
|
|
1269
|
+
| 'DASHBOARD_EVENTS_INCOMING'
|
|
1147
1270
|
/**
|
|
1148
1271
|
* Create Socket.IO namespaces for addon web pages and external clients
|
|
1149
1272
|
*/
|