stelar-time-real 2.0.0 → 2.0.2
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/README.md +0 -42
- package/package.json +1 -1
- package/src/client.js +1 -1
- package/src/client.ts +1 -1
- package/src/index.d.ts.map +1 -1
- package/src/index.js +6 -3
- package/src/index.ts +6 -3
package/README.md
CHANGED
|
@@ -556,48 +556,6 @@ client.emitBinary('upload', fileData);
|
|
|
556
556
|
| Flexibilidad | total | opinionada |
|
|
557
557
|
| Ideal para | proyectos propios | producción rápida |
|
|
558
558
|
|
|
559
|
-
## Changelog
|
|
560
|
-
|
|
561
|
-
### v2.0.0
|
|
562
|
-
- 🎉 **TypeScript!** - Código fuente ahora es TypeScript
|
|
563
|
-
- Tipos completos para IDEs (VS Code, WebStorm, etc.)
|
|
564
|
-
- Autocompletado y verificación de tipos
|
|
565
|
-
- Compatibilidad total con JS (los usuarios reciben archivos .js)
|
|
566
|
-
- Los tipos .d.ts se generan automáticamente
|
|
567
|
-
|
|
568
|
-
### v1.2.3
|
|
569
|
-
- Cleanup: código fantasma eliminado (_parent, _children, _externalServer)
|
|
570
|
-
|
|
571
|
-
### v1.2.2
|
|
572
|
-
- Bugfix: métodos duplicados en client.js
|
|
573
|
-
|
|
574
|
-
### v1.2.0
|
|
575
|
-
- Soporte binarios: envía imágenes, archivos, audio, video sin base64
|
|
576
|
-
- `ctx.emitBinary('event', buffer)` y `client.emitBinary('event', buffer)`
|
|
577
|
-
- `client.sendFile(file)` y `client.sendImage(blob)`
|
|
578
|
-
- Eficiente: usa WebSocket binary diretamente, sin overhead
|
|
579
|
-
|
|
580
|
-
### v1.1.0
|
|
581
|
-
- Namespaces: `StelarServer.of('/chat')` para múltiples canales
|
|
582
|
-
- ACK personalizado: `ctx.ack('nombre', data)` y `client.request(event, data, 'ackName')`
|
|
583
|
-
- Sistema de request-response con Promesas, ultra eficiente
|
|
584
|
-
|
|
585
|
-
### v1.0.3
|
|
586
|
-
- Exportación mejorada: un solo import para servidor y cliente
|
|
587
|
-
- `import { StelarServer, StelarClient } from 'stelar-time-real'`
|
|
588
|
-
|
|
589
|
-
### v1.0.2
|
|
590
|
-
- Exportación mejorada: un solo import para servidor y cliente
|
|
591
|
-
|
|
592
|
-
### v1.0.0
|
|
593
|
-
- Lanzamiento inicial
|
|
594
|
-
- WebSockets con ws
|
|
595
|
-
- Heartbeat automático
|
|
596
|
-
- Reconexión cliente
|
|
597
|
-
- Middlewares
|
|
598
|
-
- Rooms y broadcast
|
|
599
|
-
- Soporte para servidor externo
|
|
600
|
-
|
|
601
559
|
## Licencia
|
|
602
560
|
|
|
603
561
|
MIT - Stelar
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stelar-time-real",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "WebSocket liviano y rápido sin dependendas en TypeScript. Alternativa a socket.io, namespaces, ACKs y archivos binarios.",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
package/src/client.js
CHANGED
|
@@ -177,7 +177,7 @@ class StelarClient {
|
|
|
177
177
|
const reconHandler = this.events.get('reconnecting');
|
|
178
178
|
if (reconHandler)
|
|
179
179
|
reconHandler(this._reconnectAttempts);
|
|
180
|
-
setTimeout(() => this.
|
|
180
|
+
setTimeout(() => this._connect(), this.options.reconnectionDelay * this._reconnectAttempts);
|
|
181
181
|
}
|
|
182
182
|
};
|
|
183
183
|
this.ws.onerror = (err) => {
|
package/src/client.ts
CHANGED
|
@@ -215,7 +215,7 @@ class StelarClient {
|
|
|
215
215
|
this._reconnectAttempts++;
|
|
216
216
|
const reconHandler = this.events.get('reconnecting');
|
|
217
217
|
if (reconHandler) reconHandler(this._reconnectAttempts);
|
|
218
|
-
setTimeout(() => this.
|
|
218
|
+
setTimeout(() => this._connect(), this.options.reconnectionDelay * this._reconnectAttempts);
|
|
219
219
|
}
|
|
220
220
|
};
|
|
221
221
|
|
package/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,eAAe,EAAE,MAAM,EAAkB,MAAM,MAAM,CAAC;AAC7E,OAAO,EAAmB,SAAS,EAAW,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,eAAe,EAAE,MAAM,EAAkB,MAAM,MAAM,CAAC;AAC7E,OAAO,EAAmB,SAAS,EAAW,MAAM,IAAI,CAAC;AAGzD,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,SAAS,CAAC;IAClB,GAAG,EAAE,eAAe,CAAC;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAC9C,UAA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AAI,MAAM;IAQjB,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,cAAc;IAatB,OAAO,CAAC,gBAAgB;IAwIxB,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC;IAuCzD,IAAI,IAAI,IAAI;CAMb;AAED,eAAe,YAAY,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,CAAC;AACxB,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createServer } from 'http';
|
|
2
2
|
import { WebSocketServer } from 'ws';
|
|
3
|
+
import { randomUUID } from 'crypto';
|
|
3
4
|
class StelarServer {
|
|
4
5
|
constructor(options = {}) {
|
|
5
6
|
this.server = null;
|
|
@@ -116,7 +117,7 @@ class StelarServer {
|
|
|
116
117
|
client.close();
|
|
117
118
|
return;
|
|
118
119
|
}
|
|
119
|
-
const clientId =
|
|
120
|
+
const clientId = randomUUID();
|
|
120
121
|
const clientInfo = { id: clientId, room: null, lastPing: Date.now() };
|
|
121
122
|
this.clients.set(client, clientInfo);
|
|
122
123
|
const ctx = {
|
|
@@ -189,8 +190,10 @@ class StelarServer {
|
|
|
189
190
|
return;
|
|
190
191
|
}
|
|
191
192
|
if (event === 'join-room') {
|
|
192
|
-
|
|
193
|
-
|
|
193
|
+
if (typeof data === 'string') {
|
|
194
|
+
clientInfo.room = data;
|
|
195
|
+
client.send(JSON.stringify({ event: 'joined-room', data }));
|
|
196
|
+
}
|
|
194
197
|
}
|
|
195
198
|
if (event === 'leave-room') {
|
|
196
199
|
clientInfo.room = null;
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createServer, IncomingMessage, Server, ServerResponse } from 'http';
|
|
2
2
|
import { WebSocketServer, WebSocket, RawData } from 'ws';
|
|
3
|
+
import { randomUUID } from 'crypto';
|
|
3
4
|
|
|
4
5
|
export interface StelarOptions {
|
|
5
6
|
port?: number;
|
|
@@ -179,7 +180,7 @@ class StelarServer {
|
|
|
179
180
|
return;
|
|
180
181
|
}
|
|
181
182
|
|
|
182
|
-
const clientId =
|
|
183
|
+
const clientId = randomUUID();
|
|
183
184
|
const clientInfo: StelarClientInfo = { id: clientId, room: null, lastPing: Date.now() };
|
|
184
185
|
this.clients.set(client, clientInfo);
|
|
185
186
|
|
|
@@ -258,8 +259,10 @@ class StelarServer {
|
|
|
258
259
|
}
|
|
259
260
|
|
|
260
261
|
if (event === 'join-room') {
|
|
261
|
-
|
|
262
|
-
|
|
262
|
+
if (typeof data === 'string') {
|
|
263
|
+
clientInfo.room = data;
|
|
264
|
+
client.send(JSON.stringify({ event: 'joined-room', data }));
|
|
265
|
+
}
|
|
263
266
|
}
|
|
264
267
|
|
|
265
268
|
if (event === 'leave-room') {
|