@widy/sdk 1.0.13 → 1.0.15

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 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()`
@@ -1,12 +1,12 @@
1
1
  import { WebSocketServer } from "ws";
2
2
  export function rsBuildHotReloadPlugin({ port = 4777, delay = 400, entryFilePath, }) {
3
3
  const isWatch = process.argv.includes("--watch");
4
- const ws = new WebSocketServer({ port });
5
4
  return {
6
5
  name: "hot-reload-widget",
7
6
  setup(api) {
8
7
  if (!isWatch)
9
8
  return;
9
+ const ws = new WebSocketServer({ port });
10
10
  api.transform({}, ({ code, resourcePath }) => {
11
11
  if (resourcePath === entryFilePath) {
12
12
  const hotReloadSnippet = `
package/dist/types.d.ts CHANGED
@@ -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;
@@ -374,7 +375,7 @@ export type WidgetScopes = WidgetQuery | WidgetSubscription | WidgetMutation;
374
375
  export interface IWidgetRequest<T = unknown> {
375
376
  id: string;
376
377
  scope: WidgetScopes;
377
- payload?: T;
378
+ arg?: T;
378
379
  }
379
380
  export interface IWidgetResponse<T = unknown> {
380
381
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widy/sdk",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "A TypeScript SDK for Widy widget integrations.",
5
5
  "license": "ISC",
6
6
  "author": "ik1s3v",