@widy/sdk 1.0.14 → 1.0.16
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 +26 -0
- package/dist/enums.d.ts +12 -2
- package/dist/enums.js +11 -0
- package/dist/rsBuildHotReloadPlugin.d.ts +2 -1
- package/dist/rsBuildHotReloadPlugin.js +5 -2
- package/dist/types.d.ts +29 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@ npm install @widy/sdk
|
|
|
13
13
|
## Package Exports
|
|
14
14
|
|
|
15
15
|
- `WidgetOutboundBridge` - the main bridge class for widget outbound communication
|
|
16
|
+
- `rsBuildHotReloadPlugin` - a development plugin for automatic widget reloads during rsbuild watch builds
|
|
16
17
|
- `enums` - shared enum values used across the SDK
|
|
17
18
|
- `types` - rich TypeScript interfaces for messages, events, alerts, donations, subscriptions, goals, settings, and more
|
|
18
19
|
|
|
@@ -40,6 +41,31 @@ bridge.destroy();
|
|
|
40
41
|
|
|
41
42
|
> `WidgetOutboundBridge` is intended for use inside a browser widget iframe. It communicates with `window.parent` using `postMessage` and listens for replies via `message` events.
|
|
42
43
|
|
|
44
|
+
## Development Hot Reload
|
|
45
|
+
|
|
46
|
+
This package also exports `rsBuildHotReloadPlugin`, a helper plugin for `rsbuild` watch mode. It injects a small client-side script into the configured entry file and sends a reload signal over WebSocket after every build.
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { rsBuildHotReloadPlugin } from "@widy/sdk";
|
|
50
|
+
|
|
51
|
+
export default {
|
|
52
|
+
plugins: [
|
|
53
|
+
rsBuildHotReloadPlugin({
|
|
54
|
+
port: 4777,
|
|
55
|
+
delay: 400,
|
|
56
|
+
entryFilePath: "src/index.ts",
|
|
57
|
+
}),
|
|
58
|
+
],
|
|
59
|
+
};
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Options:
|
|
63
|
+
- `port?: number` — WebSocket port to listen on (default: `4777`)
|
|
64
|
+
- `delay?: number` — milliseconds to wait before reloading the browser after a rebuild (default: `400`)
|
|
65
|
+
- `entryFilePath: string` — path to the entry file that should receive the hot reload snippet
|
|
66
|
+
|
|
67
|
+
When `rsbuild` runs with `--watch`, the plugin starts a WebSocket server and reloads the widget in the browser automatically after rebuilds.
|
|
68
|
+
|
|
43
69
|
## `WidgetOutboundBridge` API
|
|
44
70
|
|
|
45
71
|
### `new WidgetOutboundBridge()`
|
package/dist/enums.d.ts
CHANGED
|
@@ -52,7 +52,9 @@ export declare enum AppEvent {
|
|
|
52
52
|
TwitchRewardRedemptionAdd = "TwitchRewardRedemptionAdd",
|
|
53
53
|
CreateDonationAccount = "CreateDonationAccount",
|
|
54
54
|
WidgetViewStorage = "WidgetViewStorage",
|
|
55
|
-
WidgetControlStorage = "WidgetControlStorage"
|
|
55
|
+
WidgetControlStorage = "WidgetControlStorage",
|
|
56
|
+
NsfwDetection = "NsfwDetection",
|
|
57
|
+
NsfwSettings = "NsfwSettings"
|
|
56
58
|
}
|
|
57
59
|
export declare enum StreamElementsEvent {
|
|
58
60
|
Connect = "Connect",
|
|
@@ -129,7 +131,8 @@ export declare enum ServiceType {
|
|
|
129
131
|
DonationAlerts = "DonationAlerts",
|
|
130
132
|
StreamLabs = "StreamLabs",
|
|
131
133
|
Donatello = "Donatello",
|
|
132
|
-
Donatik = "Donatik"
|
|
134
|
+
Donatik = "Donatik",
|
|
135
|
+
DonatePay = "DonatePay"
|
|
133
136
|
}
|
|
134
137
|
export declare enum StreamElementsEventType {
|
|
135
138
|
tip = "tip"
|
|
@@ -157,3 +160,10 @@ export declare enum Gender {
|
|
|
157
160
|
Male = "Male",
|
|
158
161
|
Female = "Edge"
|
|
159
162
|
}
|
|
163
|
+
export declare enum NsfwLabel {
|
|
164
|
+
anus = "anus",
|
|
165
|
+
make_love = "make_love",
|
|
166
|
+
nipple = "nipple",
|
|
167
|
+
penis = "penis",
|
|
168
|
+
vagina = "vagina"
|
|
169
|
+
}
|
package/dist/enums.js
CHANGED
|
@@ -56,6 +56,8 @@ export var AppEvent;
|
|
|
56
56
|
AppEvent["CreateDonationAccount"] = "CreateDonationAccount";
|
|
57
57
|
AppEvent["WidgetViewStorage"] = "WidgetViewStorage";
|
|
58
58
|
AppEvent["WidgetControlStorage"] = "WidgetControlStorage";
|
|
59
|
+
AppEvent["NsfwDetection"] = "NsfwDetection";
|
|
60
|
+
AppEvent["NsfwSettings"] = "NsfwSettings";
|
|
59
61
|
})(AppEvent || (AppEvent = {}));
|
|
60
62
|
export var StreamElementsEvent;
|
|
61
63
|
(function (StreamElementsEvent) {
|
|
@@ -142,6 +144,7 @@ export var ServiceType;
|
|
|
142
144
|
ServiceType["StreamLabs"] = "StreamLabs";
|
|
143
145
|
ServiceType["Donatello"] = "Donatello";
|
|
144
146
|
ServiceType["Donatik"] = "Donatik";
|
|
147
|
+
ServiceType["DonatePay"] = "DonatePay";
|
|
145
148
|
})(ServiceType || (ServiceType = {}));
|
|
146
149
|
export var StreamElementsEventType;
|
|
147
150
|
(function (StreamElementsEventType) {
|
|
@@ -175,3 +178,11 @@ export var Gender;
|
|
|
175
178
|
Gender["Male"] = "Male";
|
|
176
179
|
Gender["Female"] = "Edge";
|
|
177
180
|
})(Gender || (Gender = {}));
|
|
181
|
+
export var NsfwLabel;
|
|
182
|
+
(function (NsfwLabel) {
|
|
183
|
+
NsfwLabel["anus"] = "anus";
|
|
184
|
+
NsfwLabel["make_love"] = "make_love";
|
|
185
|
+
NsfwLabel["nipple"] = "nipple";
|
|
186
|
+
NsfwLabel["penis"] = "penis";
|
|
187
|
+
NsfwLabel["vagina"] = "vagina";
|
|
188
|
+
})(NsfwLabel || (NsfwLabel = {}));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { RsbuildPlugin } from "@rsbuild/core";
|
|
2
|
-
export declare function rsBuildHotReloadPlugin({ port, delay, entryFilePath, }: {
|
|
2
|
+
export declare function rsBuildHotReloadPlugin({ port, delay, entryFilePath, isExtension, }: {
|
|
3
3
|
port?: number;
|
|
4
4
|
delay?: number;
|
|
5
5
|
entryFilePath: string;
|
|
6
|
+
isExtension?: boolean;
|
|
6
7
|
}): RsbuildPlugin;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WebSocketServer } from "ws";
|
|
2
|
-
export function rsBuildHotReloadPlugin({ port = 4777, delay = 400, entryFilePath, }) {
|
|
2
|
+
export function rsBuildHotReloadPlugin({ port = 4777, delay = 400, entryFilePath, isExtension = false, }) {
|
|
3
3
|
const isWatch = process.argv.includes("--watch");
|
|
4
4
|
return {
|
|
5
5
|
name: "hot-reload-widget",
|
|
@@ -9,6 +9,9 @@ export function rsBuildHotReloadPlugin({ port = 4777, delay = 400, entryFilePath
|
|
|
9
9
|
const ws = new WebSocketServer({ port });
|
|
10
10
|
api.transform({}, ({ code, resourcePath }) => {
|
|
11
11
|
if (resourcePath === entryFilePath) {
|
|
12
|
+
const runtimeReload = isExtension
|
|
13
|
+
? "chrome.runtime.reload()"
|
|
14
|
+
: "window.location.reload()";
|
|
12
15
|
const hotReloadSnippet = `
|
|
13
16
|
(function() {
|
|
14
17
|
function connect() {
|
|
@@ -16,7 +19,7 @@ export function rsBuildHotReloadPlugin({ port = 4777, delay = 400, entryFilePath
|
|
|
16
19
|
|
|
17
20
|
ws.addEventListener('message', (event) => {
|
|
18
21
|
if (event.data === 'hot-reload-widget') {
|
|
19
|
-
setTimeout(() =>
|
|
22
|
+
setTimeout(() => ${runtimeReload}, ${delay});
|
|
20
23
|
}
|
|
21
24
|
});
|
|
22
25
|
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AlertVariationConditions, AppEvent, Currency, Gender, GoalProgressLayout, GoalTextPosition, GoalType, MediaType, MessageType, ServiceType, StreamElementsEventType, TtsType, ViewType, WidyNetwork } from "./enums";
|
|
1
|
+
import type { AlertVariationConditions, AppEvent, Currency, Gender, GoalProgressLayout, GoalTextPosition, GoalType, MediaType, MessageType, NsfwLabel, ServiceType, StreamElementsEventType, TtsType, ViewType, WidyNetwork } from "./enums";
|
|
2
2
|
export interface IClientMessage {
|
|
3
3
|
id: string;
|
|
4
4
|
type: MessageType;
|
|
@@ -120,6 +120,7 @@ export interface ISettings {
|
|
|
120
120
|
currency: Currency;
|
|
121
121
|
tts_type: TtsType;
|
|
122
122
|
tts_settings?: IEdgeTtsSettings;
|
|
123
|
+
widget_token: string;
|
|
123
124
|
}
|
|
124
125
|
export interface IAuctionSettings {
|
|
125
126
|
id: number;
|
|
@@ -212,9 +213,12 @@ export interface IImportedLot {
|
|
|
212
213
|
investors: [];
|
|
213
214
|
}
|
|
214
215
|
export interface IEventsService extends ISubscriptions {
|
|
216
|
+
connected: boolean;
|
|
215
217
|
connect: () => void;
|
|
216
218
|
disconnect: () => void;
|
|
217
219
|
send: <T>(message: IEventMessage<T>) => void;
|
|
220
|
+
addStatusListener: (listener: (connected: boolean) => void) => void;
|
|
221
|
+
removeStatusListener: (listener: (connected: boolean) => void) => void;
|
|
218
222
|
}
|
|
219
223
|
export interface IGoal {
|
|
220
224
|
id: string;
|
|
@@ -254,6 +258,9 @@ export interface IStreamElementsAuth {
|
|
|
254
258
|
export interface IDonationAlertsAuth {
|
|
255
259
|
token: string;
|
|
256
260
|
}
|
|
261
|
+
export interface IDonatePayAuth {
|
|
262
|
+
access_token: string;
|
|
263
|
+
}
|
|
257
264
|
export interface IStreamLabsAuth {
|
|
258
265
|
jwt: string;
|
|
259
266
|
}
|
|
@@ -399,3 +406,24 @@ export interface IManifest {
|
|
|
399
406
|
scopes: string[];
|
|
400
407
|
connect_src: string[];
|
|
401
408
|
}
|
|
409
|
+
export interface IWindowInfo {
|
|
410
|
+
title: string;
|
|
411
|
+
id: number;
|
|
412
|
+
selected: boolean;
|
|
413
|
+
}
|
|
414
|
+
export interface INsfwSettings {
|
|
415
|
+
id: number;
|
|
416
|
+
labels_confidence: ILabelsConfidence;
|
|
417
|
+
blur_timeout_duration: number;
|
|
418
|
+
}
|
|
419
|
+
export interface ILabelsConfidence {
|
|
420
|
+
anus: number;
|
|
421
|
+
make_love: number;
|
|
422
|
+
nipple: number;
|
|
423
|
+
penis: number;
|
|
424
|
+
vagina: number;
|
|
425
|
+
}
|
|
426
|
+
export interface INsfwDetection {
|
|
427
|
+
label: NsfwLabel;
|
|
428
|
+
confidence: number;
|
|
429
|
+
}
|