@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.js CHANGED
@@ -645,12 +645,13 @@ var Call = class {
645
645
  // package.json
646
646
  var package_default = {
647
647
  name: "@koi-design/callkit",
648
- version: "2.0.3",
648
+ version: "2.0.4",
649
649
  description: "callkit",
650
650
  author: "koi",
651
651
  license: "ISC",
652
652
  scripts: {
653
653
  build: "tsup",
654
+ "build:watch": "tsup --watch",
654
655
  dev: "vite",
655
656
  lint: "eslint -c ../../.eslintrc.js --ext .jsx,.js,.tsx,.ts ./package --fix",
656
657
  release: "tsup && node scripts/pkg.js"
@@ -1918,13 +1919,9 @@ var Connect = class {
1918
1919
  var RECONNECT_CONFIG = {
1919
1920
  enabled: true,
1920
1921
  maxAttempts: 3,
1921
- delay: 500,
1922
- backoffMultiplier: 1.5,
1922
+ delay: 1e3,
1923
1923
  pingInterval: 3e4,
1924
- pingTimeout: 5e3,
1925
- maxConnectsPerWindow: 5,
1926
- timeWindow: 6e4
1927
- // 60 seconds
1924
+ pingTimeout: 5e3
1928
1925
  };
1929
1926
  var Socket = class {
1930
1927
  callKit;
@@ -1939,8 +1936,6 @@ var Socket = class {
1939
1936
  isReconnecting = false;
1940
1937
  reconnectAttempts = 0;
1941
1938
  socketError = false;
1942
- // Track connection attempts for rate limiting
1943
- connectAttemptTimes = [];
1944
1939
  constructor(callKit) {
1945
1940
  this.callKit = callKit;
1946
1941
  const { reconnect } = this.callKit.config.getConfig();
@@ -1969,6 +1964,9 @@ var Socket = class {
1969
1964
  });
1970
1965
  return;
1971
1966
  }
1967
+ if (this.socketError) {
1968
+ return;
1969
+ }
1972
1970
  if (this.isReconnecting) {
1973
1971
  return;
1974
1972
  }
@@ -1996,7 +1994,6 @@ var Socket = class {
1996
1994
  if (this.ws) {
1997
1995
  this.clearWebSocket();
1998
1996
  }
1999
- this.connectAttemptTimes.push(Date.now());
2000
1997
  this.ws = new WebSocket(socketUrl);
2001
1998
  this.ws.onopen = (ev) => this.onOpen(ev);
2002
1999
  this.ws.onclose = (ev) => this.onClose(ev);
@@ -2042,9 +2039,6 @@ var Socket = class {
2042
2039
  type: "INCALL",
2043
2040
  content: { ev }
2044
2041
  });
2045
- if (this.socketError) {
2046
- return;
2047
- }
2048
2042
  this.handleDisconnect();
2049
2043
  }
2050
2044
  onError(ev) {
@@ -2373,8 +2367,6 @@ var Socket = class {
2373
2367
  this.resetReconnectState();
2374
2368
  this.lastPingTime = void 0;
2375
2369
  this.satrtConfirm = false;
2376
- this.socketError = false;
2377
- this.connectAttemptTimes = [];
2378
2370
  this.clearWebSocket();
2379
2371
  }
2380
2372
  attemptReconnect() {
@@ -2382,29 +2374,6 @@ var Socket = class {
2382
2374
  clearTimeout(this.reconnectTimer);
2383
2375
  this.reconnectTimer = void 0;
2384
2376
  }
2385
- const { maxConnectsPerWindow, timeWindow } = this.socketConfig;
2386
- if (maxConnectsPerWindow && timeWindow) {
2387
- const now = Date.now();
2388
- this.connectAttemptTimes = this.connectAttemptTimes.filter(
2389
- (time) => now - time < timeWindow
2390
- );
2391
- if (this.connectAttemptTimes.length >= maxConnectsPerWindow) {
2392
- this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
2393
- event: "INCALL_RECONNECT_ERROR"
2394
- });
2395
- this.callKit.logger.warn("Connection rate limit exceeded", {
2396
- caller: "Socket.attemptReconnect",
2397
- type: "INCALL",
2398
- content: {
2399
- errCode: ErrorCode.SOCKET_RECONNECT_FAILED,
2400
- attempts: this.connectAttemptTimes.length,
2401
- maxConnectsPerWindow,
2402
- timeWindow
2403
- }
2404
- });
2405
- return;
2406
- }
2407
- }
2408
2377
  if (this.reconnectAttempts >= this.socketConfig.maxAttempts) {
2409
2378
  this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
2410
2379
  event: "INCALL_RECONNECT_ERROR"