@laplace.live/ws 6.3.7 → 6.3.8

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/dist/browser.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { L as Live, I as Inflates, a as LiveOptions, K as KeepLive } from './common-DWwvds2J.js';
2
- export { D as DataEvent, E as EventEvent } from './common-DWwvds2J.js';
1
+ import { L as Live, I as Inflates, a as LiveOptions, K as KeepLive } from './common-CdO2EmGc.js';
2
+ export { D as DataEvent, E as EventEvent } from './common-CdO2EmGc.js';
3
3
 
4
4
  type WSOptions = LiveOptions & {
5
5
  address?: string;
package/dist/browser.js CHANGED
@@ -65,12 +65,10 @@ var makeDecoder = ({ inflateAsync: inflateAsync2, brotliDecompressAsync: brotliD
65
65
  return decoder;
66
66
  };
67
67
  var encoder = (type, body = "") => {
68
- if (typeof body !== "string") {
69
- body = JSON.stringify(body);
70
- }
68
+ const encoded = typeof body === "string" ? body : JSON.stringify(body);
71
69
  const head = new Uint8Array(16);
72
70
  const headView = new DataView(head.buffer, head.byteOffset, head.byteLength);
73
- const buffer = textEncoder.encode(body);
71
+ const buffer = textEncoder.encode(encoded);
74
72
  headView.setInt32(0, buffer.length + head.length);
75
73
  headView.setInt16(4, 16);
76
74
  headView.setInt16(6, 1);
@@ -162,10 +160,7 @@ var Live = class extends EventTarget {
162
160
  });
163
161
  this.addEventListener("open", () => {
164
162
  if (authBody) {
165
- if (typeof authBody === "object") {
166
- authBody = encoder("join", authBody);
167
- }
168
- this.send(authBody);
163
+ this.send(authBody instanceof Uint8Array ? authBody : encoder("join", authBody));
169
164
  } else {
170
165
  const hi = { uid, roomid, protover, platform: "web", type: 2 };
171
166
  if (key) {
@@ -6,7 +6,7 @@ type Inflates = {
6
6
  type LiveOptions = {
7
7
  protover?: 1 | 2 | 3;
8
8
  key?: string;
9
- authBody?: any;
9
+ authBody?: Uint8Array | Record<string, unknown>;
10
10
  uid?: number;
11
11
  buvid?: string;
12
12
  };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { L as Live, I as Inflates, a as LiveOptions, K as KeepLive } from './common-DWwvds2J.js';
2
- export { D as DataEvent, E as EventEvent } from './common-DWwvds2J.js';
1
+ import { L as Live, I as Inflates, a as LiveOptions, K as KeepLive } from './common-CdO2EmGc.js';
2
+ export { D as DataEvent, E as EventEvent } from './common-CdO2EmGc.js';
3
3
  import { Socket } from 'node:net';
4
4
  import { Agent } from 'node:http';
5
5
  import WS from 'ws';
package/dist/index.js CHANGED
@@ -65,12 +65,10 @@ var makeDecoder = ({ inflateAsync: inflateAsync2, brotliDecompressAsync: brotliD
65
65
  return decoder;
66
66
  };
67
67
  var encoder = (type, body = "") => {
68
- if (typeof body !== "string") {
69
- body = JSON.stringify(body);
70
- }
68
+ const encoded = typeof body === "string" ? body : JSON.stringify(body);
71
69
  const head = new Uint8Array(16);
72
70
  const headView = new DataView(head.buffer, head.byteOffset, head.byteLength);
73
- const buffer = textEncoder.encode(body);
71
+ const buffer = textEncoder.encode(encoded);
74
72
  headView.setInt32(0, buffer.length + head.length);
75
73
  headView.setInt16(4, 16);
76
74
  headView.setInt16(6, 1);
@@ -162,10 +160,7 @@ var Live = class extends EventTarget {
162
160
  });
163
161
  this.addEventListener("open", () => {
164
162
  if (authBody) {
165
- if (typeof authBody === "object") {
166
- authBody = encoder("join", authBody);
167
- }
168
- this.send(authBody);
163
+ this.send(authBody instanceof Uint8Array ? authBody : encoder("join", authBody));
169
164
  } else {
170
165
  const hi = { uid, roomid, protover, platform: "web", type: 2 };
171
166
  if (key) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laplace.live/ws",
3
- "version": "6.3.7",
3
+ "version": "6.3.8",
4
4
  "description": "Bilibili Live WebSocket/TCP API",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",