recker 1.0.70 → 1.0.71-next.3d76470

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.
@@ -1,5 +1,4 @@
1
1
  import { EventEmitter } from 'node:events';
2
- import { WebSocket, type RawData } from 'ws';
3
2
  export interface MockWebSocketServerOptions {
4
3
  port?: number;
5
4
  host?: string;
@@ -13,15 +12,15 @@ export interface MockWebSocketServerOptions {
13
12
  }
14
13
  export interface MockWebSocketClient {
15
14
  id: string;
16
- socket: WebSocket;
15
+ socket: import('ws').WebSocket;
17
16
  connectedAt: number;
18
17
  messageCount: number;
19
- lastMessage?: RawData;
18
+ lastMessage?: import('ws').RawData;
20
19
  metadata: Record<string, any>;
21
20
  }
22
21
  export interface MockWebSocketMessage {
23
22
  clientId: string;
24
- data: RawData;
23
+ data: import('ws').RawData;
25
24
  timestamp: number;
26
25
  isBinary: boolean;
27
26
  }
@@ -1,6 +1,23 @@
1
1
  import { EventEmitter } from 'node:events';
2
- import { WebSocketServer, WebSocket } from 'ws';
3
2
  import { createServer } from 'node:http';
3
+ let wsModule = null;
4
+ let WebSocketServer;
5
+ const WS_OPEN = 1;
6
+ async function loadWsModule() {
7
+ if (wsModule)
8
+ return wsModule;
9
+ try {
10
+ wsModule = await import('ws');
11
+ WebSocketServer = wsModule.WebSocketServer;
12
+ return wsModule;
13
+ }
14
+ catch {
15
+ throw new Error('MockWebSocketServer requires the "ws" package. Install it with:\n\n' +
16
+ ' pnpm add ws\n' +
17
+ ' # or\n' +
18
+ ' npm install ws\n');
19
+ }
20
+ }
4
21
  export class MockWebSocketServer extends EventEmitter {
5
22
  options;
6
23
  httpServer = null;
@@ -58,6 +75,7 @@ export class MockWebSocketServer extends EventEmitter {
58
75
  if (this._started) {
59
76
  throw new Error('Server already started');
60
77
  }
78
+ await loadWsModule();
61
79
  return new Promise((resolve, reject) => {
62
80
  this.httpServer = createServer();
63
81
  this.wss = new WebSocketServer({
@@ -152,7 +170,7 @@ export class MockWebSocketServer extends EventEmitter {
152
170
  }
153
171
  send(clientId, data) {
154
172
  const client = this.clients.get(clientId);
155
- if (!client || client.socket.readyState !== WebSocket.OPEN) {
173
+ if (!client || client.socket.readyState !== WS_OPEN) {
156
174
  return false;
157
175
  }
158
176
  const message = typeof data === 'object' && !Buffer.isBuffer(data)
@@ -236,7 +254,7 @@ export class MockWebSocketServer extends EventEmitter {
236
254
  this.emit('connection', client);
237
255
  if (this.options.autoCloseAfter > 0) {
238
256
  setTimeout(() => {
239
- if (socket.readyState === WebSocket.OPEN) {
257
+ if (socket.readyState === WS_OPEN) {
240
258
  socket.close(1000, 'Auto-close timeout');
241
259
  }
242
260
  }, this.options.autoCloseAfter);
@@ -277,7 +295,7 @@ export class MockWebSocketServer extends EventEmitter {
277
295
  await new Promise((resolve) => setTimeout(resolve, this.options.delay));
278
296
  }
279
297
  const response = this.getResponse(data.toString(), client);
280
- if (response !== null && client.socket.readyState === WebSocket.OPEN) {
298
+ if (response !== null && client.socket.readyState === WS_OPEN) {
281
299
  client.socket.send(response);
282
300
  this.stats.totalBytesSent += Buffer.byteLength(response);
283
301
  }
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
- const VERSION = '1.0.70';
1
+ const VERSION = '1.0.71-next.3d76470';
2
2
  let _version = null;
3
3
  export async function getVersion() {
4
4
  if (_version)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "recker",
3
- "version": "1.0.70",
3
+ "version": "1.0.71-next.3d76470",
4
4
  "description": "Multi-Protocol SDK for the AI Era - HTTP, WebSocket, DNS, FTP, SFTP, Telnet, HLS unified with AI providers and MCP tools",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -221,17 +221,18 @@
221
221
  },
222
222
  "dependencies": {
223
223
  "@maxmind/geoip2-node": "^6.3.4",
224
- "cli-args-parser": "^1.0.3",
224
+ "cli-args-parser": "^1.0.6",
225
225
  "css-select": "^6.0.0",
226
226
  "he": "^1.2.0",
227
- "tuiuiu.js": "^1.0.51",
228
- "undici": "^7.18.2",
229
- "zod": "^4.3.5"
227
+ "tuiuiu.js": "^1.0.53",
228
+ "undici": "^7.19.0",
229
+ "zod": "^4.3.6"
230
230
  },
231
231
  "peerDependencies": {
232
232
  "cardinal": "^2.1.0",
233
233
  "ioredis": "^5.0.0",
234
- "ssh2-sftp-client": "^11.0.0"
234
+ "ssh2-sftp-client": "^11.0.0",
235
+ "ws": "^8.0.0"
235
236
  },
236
237
  "peerDependenciesMeta": {
237
238
  "cardinal": {
@@ -242,24 +243,27 @@
242
243
  },
243
244
  "ssh2-sftp-client": {
244
245
  "optional": true
246
+ },
247
+ "ws": {
248
+ "optional": true
245
249
  }
246
250
  },
247
251
  "devDependencies": {
248
252
  "@hapi/wreck": "^18.1.0",
249
253
  "@types/he": "^1.2.3",
250
254
  "@types/needle": "^3.3.0",
251
- "@types/node": "^25.0.9",
255
+ "@types/node": "^25.0.10",
252
256
  "@types/ssh2-sftp-client": "^9.0.6",
253
257
  "@types/superagent": "^8.1.9",
254
258
  "@types/ws": "^8.18.1",
255
- "@vitest/coverage-v8": "^4.0.17",
259
+ "@vitest/coverage-v8": "^4.0.18",
256
260
  "axios": "^1.13.2",
257
261
  "cardinal": "^2.1.1",
258
262
  "cross-fetch": "^4.1.0",
259
263
  "domhandler": "^5.0.3",
260
264
  "esbuild": "^0.27.2",
261
265
  "got": "^14.6.6",
262
- "happy-dom": "^20.3.1",
266
+ "happy-dom": "^20.3.4",
263
267
  "husky": "^9.1.7",
264
268
  "ky": "^1.14.2",
265
269
  "make-fetch-happen": "^15.0.3",
@@ -274,10 +278,10 @@
274
278
  "superagent": "^10.3.0",
275
279
  "tsx": "^4.21.0",
276
280
  "typescript": "^5.9.3",
277
- "vitest": "^4.0.17",
281
+ "vitest": "^4.0.18",
278
282
  "wretch": "^3.0.6",
279
283
  "ws": "^8.19.0",
280
- "zod": "^4.3.5"
284
+ "zod": "^4.3.6"
281
285
  },
282
286
  "scripts": {
283
287
  "build": "pnpm build:node && pnpm build:browser",