@fluxerjs/ws 1.0.2 → 1.0.5

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/index.d.mts CHANGED
@@ -1,5 +1,6 @@
1
+ import * as _fluxerjs_types from '@fluxerjs/types';
2
+ import { GatewaySendPayload, GatewayPresenceUpdateData } from '@fluxerjs/types';
1
3
  import { EventEmitter } from 'events';
2
- import { GatewaySendPayload } from '@fluxerjs/types';
3
4
 
4
5
  type WebSocketLike = {
5
6
  send(data: string | ArrayBufferLike): void;
@@ -13,6 +14,7 @@ interface WebSocketShardOptions {
13
14
  url: string;
14
15
  token: string;
15
16
  intents: number;
17
+ presence?: _fluxerjs_types.GatewayPresenceUpdateData;
16
18
  shardId: number;
17
19
  numShards: number;
18
20
  /** Gateway API version (e.g. "1" for Fluxer). Defaults to "1" when not set. */
@@ -55,6 +57,7 @@ interface WebSocketManagerOptions {
55
57
  get: (route: string) => Promise<unknown>;
56
58
  };
57
59
  version?: string;
60
+ presence?: GatewayPresenceUpdateData;
58
61
  shardIds?: number[];
59
62
  shardCount?: number;
60
63
  WebSocket?: WebSocketConstructor;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
+ import * as _fluxerjs_types from '@fluxerjs/types';
2
+ import { GatewaySendPayload, GatewayPresenceUpdateData } from '@fluxerjs/types';
1
3
  import { EventEmitter } from 'events';
2
- import { GatewaySendPayload } from '@fluxerjs/types';
3
4
 
4
5
  type WebSocketLike = {
5
6
  send(data: string | ArrayBufferLike): void;
@@ -13,6 +14,7 @@ interface WebSocketShardOptions {
13
14
  url: string;
14
15
  token: string;
15
16
  intents: number;
17
+ presence?: _fluxerjs_types.GatewayPresenceUpdateData;
16
18
  shardId: number;
17
19
  numShards: number;
18
20
  /** Gateway API version (e.g. "1" for Fluxer). Defaults to "1" when not set. */
@@ -55,6 +57,7 @@ interface WebSocketManagerOptions {
55
57
  get: (route: string) => Promise<unknown>;
56
58
  };
57
59
  version?: string;
60
+ presence?: GatewayPresenceUpdateData;
58
61
  shardIds?: number[];
59
62
  shardCount?: number;
60
63
  WebSocket?: WebSocketConstructor;
package/dist/index.js CHANGED
@@ -244,18 +244,18 @@ var WebSocketShard = class extends import_events.EventEmitter {
244
244
  }
245
245
  });
246
246
  } else {
247
- this.send({
248
- op: import_types.GatewayOpcodes.Identify,
249
- d: {
250
- token: this.options.token,
251
- intents: this.options.intents,
252
- properties: {
253
- os: process.platform ?? "unknown",
254
- browser: "fluxer-core.js",
255
- device: "fluxer-core.js"
256
- }
247
+ const identify = {
248
+ token: this.options.token,
249
+ intents: this.options.intents,
250
+ properties: {
251
+ os: process.platform ?? "unknown",
252
+ browser: "fluxerjs",
253
+ device: "fluxerjs"
257
254
  }
258
- });
255
+ };
256
+ if (this.options.presence) identify.presence = this.options.presence;
257
+ console.log("[ws] sending identify payload:", JSON.stringify({ op: 2, d: { ...identify, token: identify.token ? "[REDACTED]" : identify.token } }, null, 2));
258
+ this.send({ op: import_types.GatewayOpcodes.Identify, d: identify });
259
259
  }
260
260
  }
261
261
  startHeartbeat(interval) {
@@ -355,6 +355,7 @@ var WebSocketManager = class extends import_events2.EventEmitter {
355
355
  url: this.gatewayUrl,
356
356
  token: this.options.token,
357
357
  intents: this.options.intents,
358
+ presence: this.options.presence,
358
359
  shardId: id,
359
360
  numShards: this.shardCount,
360
361
  version,
package/dist/index.mjs CHANGED
@@ -211,18 +211,18 @@ var WebSocketShard = class extends EventEmitter {
211
211
  }
212
212
  });
213
213
  } else {
214
- this.send({
215
- op: GatewayOpcodes.Identify,
216
- d: {
217
- token: this.options.token,
218
- intents: this.options.intents,
219
- properties: {
220
- os: process.platform ?? "unknown",
221
- browser: "fluxer-core.js",
222
- device: "fluxer-core.js"
223
- }
214
+ const identify = {
215
+ token: this.options.token,
216
+ intents: this.options.intents,
217
+ properties: {
218
+ os: process.platform ?? "unknown",
219
+ browser: "fluxerjs",
220
+ device: "fluxerjs"
224
221
  }
225
- });
222
+ };
223
+ if (this.options.presence) identify.presence = this.options.presence;
224
+ console.log("[ws] sending identify payload:", JSON.stringify({ op: 2, d: { ...identify, token: identify.token ? "[REDACTED]" : identify.token } }, null, 2));
225
+ this.send({ op: GatewayOpcodes.Identify, d: identify });
226
226
  }
227
227
  }
228
228
  startHeartbeat(interval) {
@@ -322,6 +322,7 @@ var WebSocketManager = class extends EventEmitter2 {
322
322
  url: this.gatewayUrl,
323
323
  token: this.options.token,
324
324
  intents: this.options.intents,
325
+ presence: this.options.presence,
325
326
  shardId: id,
326
327
  numShards: this.shardCount,
327
328
  version,
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.0.2",
6
+ "version": "1.0.5",
7
7
  "description": "WebSocket manager for the Fluxer Gateway",
8
8
  "main": "./dist/index.js",
9
9
  "module": "./dist/index.mjs",
@@ -20,7 +20,7 @@
20
20
  ],
21
21
  "dependencies": {
22
22
  "ws": "^8.18.0",
23
- "@fluxerjs/types": "1.0.2"
23
+ "@fluxerjs/types": "1.0.5"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/node": "^20.0.0",