@koi-design/callkit 2.0.3 → 2.0.4

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.ts CHANGED
@@ -55,11 +55,8 @@ interface SocketConfig {
55
55
  enabled: boolean;
56
56
  maxAttempts: number;
57
57
  delay: number;
58
- backoffMultiplier: number;
59
58
  pingInterval: number;
60
59
  pingTimeout: number;
61
- maxConnectsPerWindow?: number;
62
- timeWindow?: number;
63
60
  }
64
61
  declare class Socket {
65
62
  private callKit;
@@ -73,7 +70,6 @@ declare class Socket {
73
70
  private isReconnecting;
74
71
  private reconnectAttempts;
75
72
  private socketError;
76
- private connectAttemptTimes;
77
73
  constructor(callKit: CallKit);
78
74
  init(): void;
79
75
  private handleDisconnect;
@@ -3810,12 +3810,13 @@ var WebCall = (() => {
3810
3810
  // package.json
3811
3811
  var package_default = {
3812
3812
  name: "@koi-design/callkit",
3813
- version: "2.0.3",
3813
+ version: "2.0.4",
3814
3814
  description: "callkit",
3815
3815
  author: "koi",
3816
3816
  license: "ISC",
3817
3817
  scripts: {
3818
3818
  build: "tsup",
3819
+ "build:watch": "tsup --watch",
3819
3820
  dev: "vite",
3820
3821
  lint: "eslint -c ../../.eslintrc.js --ext .jsx,.js,.tsx,.ts ./package --fix",
3821
3822
  release: "tsup && node scripts/pkg.js"
@@ -19481,13 +19482,9 @@ var WebCall = (() => {
19481
19482
  var RECONNECT_CONFIG = {
19482
19483
  enabled: true,
19483
19484
  maxAttempts: 3,
19484
- delay: 500,
19485
- backoffMultiplier: 1.5,
19485
+ delay: 1e3,
19486
19486
  pingInterval: 3e4,
19487
- pingTimeout: 5e3,
19488
- maxConnectsPerWindow: 5,
19489
- timeWindow: 6e4
19490
- // 60 seconds
19487
+ pingTimeout: 5e3
19491
19488
  };
19492
19489
  var Socket = class {
19493
19490
  callKit;
@@ -19502,8 +19499,6 @@ var WebCall = (() => {
19502
19499
  isReconnecting = false;
19503
19500
  reconnectAttempts = 0;
19504
19501
  socketError = false;
19505
- // Track connection attempts for rate limiting
19506
- connectAttemptTimes = [];
19507
19502
  constructor(callKit) {
19508
19503
  this.callKit = callKit;
19509
19504
  const { reconnect } = this.callKit.config.getConfig();
@@ -19532,6 +19527,9 @@ var WebCall = (() => {
19532
19527
  });
19533
19528
  return;
19534
19529
  }
19530
+ if (this.socketError) {
19531
+ return;
19532
+ }
19535
19533
  if (this.isReconnecting) {
19536
19534
  return;
19537
19535
  }
@@ -19559,7 +19557,6 @@ var WebCall = (() => {
19559
19557
  if (this.ws) {
19560
19558
  this.clearWebSocket();
19561
19559
  }
19562
- this.connectAttemptTimes.push(Date.now());
19563
19560
  this.ws = new WebSocket(socketUrl);
19564
19561
  this.ws.onopen = (ev) => this.onOpen(ev);
19565
19562
  this.ws.onclose = (ev) => this.onClose(ev);
@@ -19605,9 +19602,6 @@ var WebCall = (() => {
19605
19602
  type: "INCALL",
19606
19603
  content: { ev }
19607
19604
  });
19608
- if (this.socketError) {
19609
- return;
19610
- }
19611
19605
  this.handleDisconnect();
19612
19606
  }
19613
19607
  onError(ev) {
@@ -19936,8 +19930,6 @@ var WebCall = (() => {
19936
19930
  this.resetReconnectState();
19937
19931
  this.lastPingTime = void 0;
19938
19932
  this.satrtConfirm = false;
19939
- this.socketError = false;
19940
- this.connectAttemptTimes = [];
19941
19933
  this.clearWebSocket();
19942
19934
  }
19943
19935
  attemptReconnect() {
@@ -19945,29 +19937,6 @@ var WebCall = (() => {
19945
19937
  clearTimeout(this.reconnectTimer);
19946
19938
  this.reconnectTimer = void 0;
19947
19939
  }
19948
- const { maxConnectsPerWindow, timeWindow } = this.socketConfig;
19949
- if (maxConnectsPerWindow && timeWindow) {
19950
- const now = Date.now();
19951
- this.connectAttemptTimes = this.connectAttemptTimes.filter(
19952
- (time) => now - time < timeWindow
19953
- );
19954
- if (this.connectAttemptTimes.length >= maxConnectsPerWindow) {
19955
- this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
19956
- event: "INCALL_RECONNECT_ERROR"
19957
- });
19958
- this.callKit.logger.warn("Connection rate limit exceeded", {
19959
- caller: "Socket.attemptReconnect",
19960
- type: "INCALL",
19961
- content: {
19962
- errCode: ErrorCode.SOCKET_RECONNECT_FAILED,
19963
- attempts: this.connectAttemptTimes.length,
19964
- maxConnectsPerWindow,
19965
- timeWindow
19966
- }
19967
- });
19968
- return;
19969
- }
19970
- }
19971
19940
  if (this.reconnectAttempts >= this.socketConfig.maxAttempts) {
19972
19941
  this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
19973
19942
  event: "INCALL_RECONNECT_ERROR"