skikrumb-api 2.1.6 → 2.1.7

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
@@ -17,6 +17,7 @@ declare class SkiKrumbRealtimeClient {
17
17
  private scheduleReconnect;
18
18
  disconnect(): void;
19
19
  ping(): void;
20
+ sendPong(): void;
20
21
  requestRefresh(): void;
21
22
  on(event: string, callback: Function): void;
22
23
  off(event: string, callback?: Function): void;
package/dist/index.js CHANGED
@@ -68,6 +68,10 @@ class SkiKrumbRealtimeClient {
68
68
  (_a = this.websocket) === null || _a === void 0 ? void 0 : _a.close();
69
69
  reject(new Error(`Connection failed: ${message.message || message.error}`));
70
70
  }
71
+ else if (message.type === 'ping') {
72
+ // Server-initiated ping - respond with pong
73
+ this.sendPong();
74
+ }
71
75
  else if (message.type === 'session_replaced') {
72
76
  this.emit('session_replaced', message);
73
77
  }
@@ -146,7 +150,6 @@ class SkiKrumbRealtimeClient {
146
150
  this.reconnectAttempts++;
147
151
  // Exponential backoff with 5-minute cap
148
152
  const delay = Math.min(this.reconnectDelay * Math.pow(2, this.reconnectAttempts - 1), this.maxReconnectDelay);
149
- console.log(`🔄 Scheduling reconnect attempt #${this.reconnectAttempts} in ${delay / 1000}s`);
150
153
  setTimeout(() => {
151
154
  this.connect().catch((error) => {
152
155
  // Errors are expected during reconnection, will keep trying
@@ -176,6 +179,11 @@ class SkiKrumbRealtimeClient {
176
179
  this.websocket.send(JSON.stringify({ type: 'ping', timestamp: new Date().toISOString() }));
177
180
  }
178
181
  }
182
+ sendPong() {
183
+ if (this.websocket && this.websocket.readyState === WebSocket.OPEN) {
184
+ this.websocket.send(JSON.stringify({ type: 'pong', timestamp: new Date().toISOString() }));
185
+ }
186
+ }
179
187
  requestRefresh() {
180
188
  if (this.websocket && this.websocket.readyState === WebSocket.OPEN) {
181
189
  this.websocket.send(JSON.stringify({
@@ -475,9 +483,7 @@ export const skiKrumb = (options = {
475
483
  'x-client': options.requestedWith,
476
484
  },
477
485
  });
478
- const response = await requestWithAuth
479
- .get('auth/profiles')
480
- .json();
486
+ const response = await requestWithAuth.get('auth/profiles').json();
481
487
  return response;
482
488
  };
483
489
  const getLatestDeviceData = async (serialNumber) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skikrumb-api",
3
- "version": "2.1.6",
3
+ "version": "2.1.7",
4
4
  "description": "Wrapper for the skiKrumb API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",