@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.mjs CHANGED
@@ -612,12 +612,13 @@ var Call = class {
612
612
  // package.json
613
613
  var package_default = {
614
614
  name: "@koi-design/callkit",
615
- version: "2.0.3",
615
+ version: "2.0.4",
616
616
  description: "callkit",
617
617
  author: "koi",
618
618
  license: "ISC",
619
619
  scripts: {
620
620
  build: "tsup",
621
+ "build:watch": "tsup --watch",
621
622
  dev: "vite",
622
623
  lint: "eslint -c ../../.eslintrc.js --ext .jsx,.js,.tsx,.ts ./package --fix",
623
624
  release: "tsup && node scripts/pkg.js"
@@ -1891,13 +1892,9 @@ var Connect = class {
1891
1892
  var RECONNECT_CONFIG = {
1892
1893
  enabled: true,
1893
1894
  maxAttempts: 3,
1894
- delay: 500,
1895
- backoffMultiplier: 1.5,
1895
+ delay: 1e3,
1896
1896
  pingInterval: 3e4,
1897
- pingTimeout: 5e3,
1898
- maxConnectsPerWindow: 5,
1899
- timeWindow: 6e4
1900
- // 60 seconds
1897
+ pingTimeout: 5e3
1901
1898
  };
1902
1899
  var Socket = class {
1903
1900
  callKit;
@@ -1912,8 +1909,6 @@ var Socket = class {
1912
1909
  isReconnecting = false;
1913
1910
  reconnectAttempts = 0;
1914
1911
  socketError = false;
1915
- // Track connection attempts for rate limiting
1916
- connectAttemptTimes = [];
1917
1912
  constructor(callKit) {
1918
1913
  this.callKit = callKit;
1919
1914
  const { reconnect } = this.callKit.config.getConfig();
@@ -1942,6 +1937,9 @@ var Socket = class {
1942
1937
  });
1943
1938
  return;
1944
1939
  }
1940
+ if (this.socketError) {
1941
+ return;
1942
+ }
1945
1943
  if (this.isReconnecting) {
1946
1944
  return;
1947
1945
  }
@@ -1969,7 +1967,6 @@ var Socket = class {
1969
1967
  if (this.ws) {
1970
1968
  this.clearWebSocket();
1971
1969
  }
1972
- this.connectAttemptTimes.push(Date.now());
1973
1970
  this.ws = new WebSocket(socketUrl);
1974
1971
  this.ws.onopen = (ev) => this.onOpen(ev);
1975
1972
  this.ws.onclose = (ev) => this.onClose(ev);
@@ -2015,9 +2012,6 @@ var Socket = class {
2015
2012
  type: "INCALL",
2016
2013
  content: { ev }
2017
2014
  });
2018
- if (this.socketError) {
2019
- return;
2020
- }
2021
2015
  this.handleDisconnect();
2022
2016
  }
2023
2017
  onError(ev) {
@@ -2346,8 +2340,6 @@ var Socket = class {
2346
2340
  this.resetReconnectState();
2347
2341
  this.lastPingTime = void 0;
2348
2342
  this.satrtConfirm = false;
2349
- this.socketError = false;
2350
- this.connectAttemptTimes = [];
2351
2343
  this.clearWebSocket();
2352
2344
  }
2353
2345
  attemptReconnect() {
@@ -2355,29 +2347,6 @@ var Socket = class {
2355
2347
  clearTimeout(this.reconnectTimer);
2356
2348
  this.reconnectTimer = void 0;
2357
2349
  }
2358
- const { maxConnectsPerWindow, timeWindow } = this.socketConfig;
2359
- if (maxConnectsPerWindow && timeWindow) {
2360
- const now = Date.now();
2361
- this.connectAttemptTimes = this.connectAttemptTimes.filter(
2362
- (time) => now - time < timeWindow
2363
- );
2364
- if (this.connectAttemptTimes.length >= maxConnectsPerWindow) {
2365
- this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
2366
- event: "INCALL_RECONNECT_ERROR"
2367
- });
2368
- this.callKit.logger.warn("Connection rate limit exceeded", {
2369
- caller: "Socket.attemptReconnect",
2370
- type: "INCALL",
2371
- content: {
2372
- errCode: ErrorCode.SOCKET_RECONNECT_FAILED,
2373
- attempts: this.connectAttemptTimes.length,
2374
- maxConnectsPerWindow,
2375
- timeWindow
2376
- }
2377
- });
2378
- return;
2379
- }
2380
- }
2381
2350
  if (this.reconnectAttempts >= this.socketConfig.maxAttempts) {
2382
2351
  this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
2383
2352
  event: "INCALL_RECONNECT_ERROR"