stelar-time-real 2.0.2 → 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.
Files changed (2) hide show
  1. package/README.md +162 -162
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -1,37 +1,37 @@
1
1
  # stelar-time-real
2
2
 
3
- Tu propio sistema de tiempo real personalizado. Una librería ligera y sin dependencias para comunicación en tiempo real via WebSockets.
3
+ Your own custom real-time system. A lightweight, dependency-free library for real-time communication via WebSockets.
4
4
 
5
5
  ![npm](https://img.shields.io/npm/v/stelar-time-real)
6
6
  ![license](https://img.shields.io/npm/l/stelar-time-real)
7
7
  ![size](https://img.shields.io/bundlephobia/min/stelar-time-real)
8
8
 
9
- ## ¿Por qué stelar-time-real?
9
+ ## Why stelar-time-real?
10
10
 
11
- - ⚡ **Ultra ligera** - Solo ~13MB de heap
12
- - 🚀 **Sin dependencias** - Usa solo `ws` (WebSocket nativo)
13
- - 🎯 **Personalizable** - Vos controlás todo, nada de código ajeno
14
- - 🔌 **Compatible** - Funciona con Express, Fastify, HTTP nativo, etc.
15
- - 💓 **Heartbeat incluido** - Detecta desconexiones automáticamente
16
- - 🌐 **Namespaces** - Múltiples canales independientes (`/chat`, `/game`, etc.)
17
- - ⚡ **ACK ultra rápido** - Request-response con Promesas, sin overhead
18
- - 📦 **Binarios** - Envía imágenes, archivos, audio, video sin overhead de base64
11
+ - ⚡ **Ultra lightweight** - Only ~13MB of heap
12
+ - 🚀 **No dependencies** - Uses only native `ws` (WebSocket)
13
+ - 🎯 **Fully customizable** - You control everything, no one else's code
14
+ - 🔌 **Compatible** - Works with Express, Fastify, native HTTP, etc.
15
+ - 💓 **Heartbeat included** - Automatically detects disconnections
16
+ - 🌐 **Namespaces** - Multiple independent channels (`/chat`, `/game`, etc.)
17
+ - ⚡ **Ultra fast ACK** - Request-response with Promises, no overhead
18
+ - 📦 **Binaries** - Send images, files, audio, video without base64 overhead
19
19
 
20
- ## Instalación
20
+ ## Installation
21
21
 
22
22
  ```bash
23
23
  npm install stelar-time-real
24
24
  ```
25
25
 
26
- ## Inicio Rápido
26
+ ## Quick Start
27
27
 
28
- ### Un solo import para todo
28
+ ### One import for everything
29
29
 
30
30
  ```javascript
31
31
  import StelarServer, { StelarClient } from 'stelar-time-real';
32
32
  ```
33
33
 
34
- ### Servidor
34
+ ### Server
35
35
 
36
36
  ```javascript
37
37
  import express from 'express';
@@ -43,18 +43,18 @@ const server = app.listen(3000);
43
43
  const stelar = new StelarServer({ server });
44
44
 
45
45
  stelar.onConnection((client) => {
46
- console.log('Nuevo cliente:', client.id);
47
- client.emit('bienvenida', '¡Hola! Bienvenido a stelar-time-real');
46
+ console.log('New client:', client.id);
47
+ client.emit('welcome', 'Hello! Welcome to stelar-time-real');
48
48
  });
49
49
 
50
- stelar.on('mensaje', (ctx) => {
51
- ctx.broadcast('mensaje', ctx.data);
50
+ stelar.on('message', (ctx) => {
51
+ ctx.broadcast('message', ctx.data);
52
52
  });
53
53
 
54
54
  stelar.start();
55
55
  ```
56
56
 
57
- ### Cliente
57
+ ### Client
58
58
 
59
59
  ```javascript
60
60
  import { StelarClient } from 'stelar-time-real';
@@ -62,19 +62,19 @@ import { StelarClient } from 'stelar-time-real';
62
62
  const client = new StelarClient('localhost:3000');
63
63
 
64
64
  client.on('connect', () => {
65
- console.log('Conectado!');
65
+ console.log('Connected!');
66
66
  });
67
67
 
68
- client.on('bienvenida', (msg) => {
68
+ client.on('welcome', (msg) => {
69
69
  console.log(msg);
70
70
  });
71
71
 
72
72
  client.connect();
73
73
  ```
74
74
 
75
- ## API Completa
75
+ ## Full API
76
76
 
77
- ### StelarServer (Lado del Servidor)
77
+ ### StelarServer (Server Side)
78
78
 
79
79
  #### Constructor
80
80
 
@@ -82,21 +82,21 @@ client.connect();
82
82
  new StelarServer({ server, port, heartbeatInterval })
83
83
  ```
84
84
 
85
- | Opción | Tipo | Default | Descripción |
85
+ | Option | Type | Default | Description |
86
86
  |--------|------|---------|-------------|
87
- | server | http.Server | null | Tu server HTTP existente |
88
- | port | number | 3000 | Puerto si no pasás server |
89
- | heartbeatInterval | number | 30000 | Intervalo de ping en ms |
87
+ | server | http.Server | null | Your existing HTTP server |
88
+ | port | number | 3000 | Port if you don't pass server |
89
+ | heartbeatInterval | number | 30000 | Ping interval in ms |
90
90
 
91
- #### Métodos
91
+ #### Methods
92
92
 
93
93
  **`.use(middleware)`**
94
- Agregar middleware para validar conexiones.
94
+ Add middleware to validate connections.
95
95
 
96
96
  ```javascript
97
97
  stelar.use((ctx, next) => {
98
98
  const token = ctx.req.headers['x-token'];
99
- if (token === 'secreto') {
99
+ if (token === 'secret') {
100
100
  next();
101
101
  } else {
102
102
  ctx.socket.close();
@@ -105,125 +105,125 @@ stelar.use((ctx, next) => {
105
105
  ```
106
106
 
107
107
  **`.on(event, handler)`**
108
- Escuchar eventos del cliente.
108
+ Listen for client events.
109
109
 
110
110
  ```javascript
111
111
  stelar.on('chat', (ctx) => {
112
- console.log('Mensaje:', ctx.data);
112
+ console.log('Message:', ctx.data);
113
113
  ctx.broadcast('chat', ctx.data);
114
114
  });
115
115
  ```
116
116
 
117
117
  **`.onAll(handler)`**
118
- Escuchar todos los eventos (útil para debug).
118
+ Listen for all events (useful for debug).
119
119
 
120
120
  ```javascript
121
121
  stelar.onAll(({ event, data }) => {
122
- console.log(`Evento: ${event}`, data);
122
+ console.log(`Event: ${event}`, data);
123
123
  });
124
124
  ```
125
125
 
126
126
  **`.onConnection(handler)`**
127
- Ejecutar cuando un cliente se conecta.
127
+ Execute when a client connects.
128
128
 
129
129
  ```javascript
130
130
  stelar.onConnection((client) => {
131
- client.emit('bienvenida', 'Hola!');
131
+ client.emit('welcome', 'Hello!');
132
132
  });
133
133
  ```
134
134
 
135
135
  **`.broadcast(event, data)`**
136
- Enviar a todos los clientes.
136
+ Send to all clients.
137
137
 
138
138
  ```javascript
139
- stelar.broadcast('chat', { mensaje: 'Hola a todos' });
139
+ stelar.broadcast('chat', { message: 'Hello everyone' });
140
140
  ```
141
141
 
142
142
  **`.to(room, event, data)`**
143
- Enviar a una sala específica.
143
+ Send to a specific room.
144
144
 
145
145
  ```javascript
146
- stelar.to('sala-1', 'chat', { mensaje: 'Hola sala 1' });
146
+ stelar.to('room-1', 'chat', { message: 'Hello room 1' });
147
147
  ```
148
148
 
149
149
  **`.toId(id, event, data)`**
150
- Enviar a un cliente específico por ID.
150
+ Send to a specific client by ID.
151
151
 
152
152
  ```javascript
153
- stelar.toId('abc123', 'privado', 'Solo para ti');
153
+ stelar.toId('abc123', 'private', 'Just for you');
154
154
  ```
155
155
 
156
156
  **`.getClients(room)`**
157
- Obtener lista de clientes.
157
+ Get list of clients.
158
158
 
159
159
  ```javascript
160
- const todos = stelar.getClients();
161
- const sala = stelar.getClients('mi-sala');
160
+ const all = stelar.getClients();
161
+ const room = stelar.getClients('my-room');
162
162
  ```
163
163
 
164
164
  **`.getPort()`**
165
- Obtener el puerto donde está corriendo.
165
+ Get the port where it's running.
166
166
 
167
167
  ```javascript
168
- console.log('Puerto:', stelar.getPort());
168
+ console.log('Port:', stelar.getPort());
169
169
  ```
170
170
 
171
171
  **`.start(callback)`**
172
- Iniciar el servidor WebSocket.
172
+ Start the WebSocket server.
173
173
 
174
174
  ```javascript
175
175
  await stelar.start();
176
- console.log('Iniciado!');
176
+ console.log('Started!');
177
177
  ```
178
178
 
179
179
  **`.stop()`**
180
- Detener el servidor.
180
+ Stop the server.
181
181
 
182
182
  ```javascript
183
183
  stelar.stop();
184
184
  ```
185
185
 
186
- #### Contexto (ctx) en handlers
186
+ #### Context (ctx) in handlers
187
187
 
188
- Cuando escuchás un evento, recibís un `ctx` con:
188
+ When you listen to an event, you receive a `ctx` with:
189
189
 
190
190
  ```javascript
191
- stelar.on('mensaje', (ctx) => {
192
- ctx.id // ID único del cliente
193
- ctx.socket // WebSocket del cliente
194
- ctx.req // Request HTTP original
195
- ctx.data // Datos recibidos
191
+ stelar.on('message', (ctx) => {
192
+ ctx.id // Unique client ID
193
+ ctx.socket // Client's WebSocket
194
+ ctx.req // Original HTTP request
195
+ ctx.data // Received data
196
196
 
197
- // Métodos disponibles:
198
- ctx.emit('evento', data) // Enviar solo a este cliente
199
- ctx.send('respuesta', data) // Responder a un ACK
200
- ctx.broadcast('evento', data) // Enviar a todos
201
- ctx.to('sala', 'evento', data) // Enviar a una sala
202
- ctx.toId('id', 'evento', data) // Enviar a un cliente específico
203
- ctx.getClients('sala') // Ver clientes en sala
204
- ctx.joinRoom('sala') // Unir a sala
205
- ctx.leaveRoom() // Salir de sala
206
- ctx.ack('miAck', data) // Responder a un ACK personalizado
197
+ // Available methods:
198
+ ctx.emit('event', data) // Send to this client only
199
+ ctx.send('response', data) // Reply to an ACK
200
+ ctx.broadcast('event', data) // Send to everyone
201
+ ctx.to('room', 'event', data) // Send to a room
202
+ ctx.toId('id', 'event', data) // Send to specific client
203
+ ctx.getClients('room') // See clients in room
204
+ ctx.joinRoom('room') // Join room
205
+ ctx.leaveRoom() // Leave room
206
+ ctx.ack('myAck', data) // Reply to a custom ACK
207
207
  });
208
208
  ```
209
209
 
210
210
  #### Namespaces
211
211
 
212
- Crear canales independientes:
212
+ Create independent channels:
213
213
 
214
214
  ```javascript
215
215
  import { StelarServer } from 'stelar-time-real';
216
216
 
217
- // Namespace principal
217
+ // Main namespace
218
218
  const main = new StelarServer({ server, namespace: '/' });
219
219
 
220
- // Namespace de chat
220
+ // Chat namespace
221
221
  const chat = StelarServer.of('/chat', { server });
222
222
  chat.on('message', (ctx) => {
223
223
  ctx.broadcast('message', ctx.data);
224
224
  });
225
225
 
226
- // Namespace de game
226
+ // Game namespace
227
227
  const game = StelarServer.of('/game', { server });
228
228
  game.on('move', (ctx) => {
229
229
  ctx.to(ctx.data.room, 'move', ctx.data);
@@ -232,45 +232,45 @@ game.on('move', (ctx) => {
232
232
 
233
233
  #### ACK (Request-Response)
234
234
 
235
- Sistema ultra eficiente con Promesas:
235
+ Ultra efficient system with Promises:
236
236
 
237
- **Servidor:**
237
+ **Server:**
238
238
 
239
239
  ```javascript
240
- // Registrar un ACK handler
240
+ // Register an ACK handler
241
241
  stelar.onAck('getUser', (ctx) => {
242
242
  return { id: ctx.data.id, name: 'John' };
243
243
  });
244
244
 
245
- // O con lógica más compleja
245
+ // Or with more complex logic
246
246
  stelar.onAck('saveData', (ctx) => {
247
247
  const result = saveToDatabase(ctx.data);
248
248
  return { success: true, id: result.id };
249
249
  });
250
250
  ```
251
251
 
252
- **Cliente:**
252
+ **Client:**
253
253
 
254
254
  ```javascript
255
- // Usando request() - retorna Promise
255
+ // Using request() - returns Promise
256
256
  const user = await client.request('getUser', { id: 1 }, 'userData');
257
257
  console.log(user); // { id: 1, name: 'John' }
258
258
 
259
- // O emitiendo con callback
259
+ // Or emit with callback
260
260
  client.emit('getUser', { id: 1 }, { ack: 'userData' });
261
261
  client.on('userData', (data) => {
262
262
  console.log(data);
263
263
  });
264
264
 
265
- // ACK desde el servidor al cliente
265
+ // ACK from server to client
266
266
  client.onAck('serverPush', (data) => {
267
- console.log('El servidor envió:', data);
267
+ console.log('Server sent:', data);
268
268
  });
269
269
  ```
270
270
 
271
271
  ---
272
272
 
273
- ### StelarClient (Lado del Cliente)
273
+ ### StelarClient (Client Side)
274
274
 
275
275
  #### Constructor
276
276
 
@@ -278,22 +278,22 @@ client.onAck('serverPush', (data) => {
278
278
  new StelarClient(urlOrPort, options)
279
279
  ```
280
280
 
281
- | Param | Tipo | Default | Descripción |
281
+ | Param | Type | Default | Description |
282
282
  |-------|------|---------|-------------|
283
- | urlOrPort | string/number | localhost:3000 | URL o puerto del servidor |
284
- | options.reconnection | boolean | true | Reconectar automáticamente |
285
- | options.reconnectionAttempts | number | 5 | Intentos de reconexión |
286
- | options.reconnectionDelay | number | 1000 | Delay entre intentos (ms) |
287
- | options.heartbeatInterval | number | 30000 | Intervalo de ping |
283
+ | urlOrPort | string/number | localhost:3000 | Server URL or port |
284
+ | options.reconnection | boolean | true | Auto reconnect |
285
+ | options.reconnectionAttempts | number | 5 | Reconnection attempts |
286
+ | options.reconnectionDelay | number | 1000 | Delay between attempts (ms) |
287
+ | options.heartbeatInterval | number | 30000 | Ping interval |
288
288
 
289
289
  ```javascript
290
- // Solo puerto
290
+ // Just port
291
291
  const client = new StelarClient(3000);
292
292
 
293
- // URL completa
294
- const client = new StelarClient('ws://midominio.com/ws');
293
+ // Full URL
294
+ const client = new StelarClient('ws://mydomain.com/ws');
295
295
 
296
- // Con opciones
296
+ // With options
297
297
  const client = new StelarClient(3000, {
298
298
  reconnection: true,
299
299
  reconnectionAttempts: 10,
@@ -301,19 +301,19 @@ const client = new StelarClient(3000, {
301
301
  });
302
302
  ```
303
303
 
304
- #### Métodos
304
+ #### Methods
305
305
 
306
306
  **`.on(event, handler)`**
307
- Escuchar eventos del servidor.
307
+ Listen for server events.
308
308
 
309
309
  ```javascript
310
- client.on('bienvenida', (data) => {
310
+ client.on('welcome', (data) => {
311
311
  console.log(data);
312
312
  });
313
313
  ```
314
314
 
315
315
  **`.onAll(handler)`**
316
- Escuchar todos los eventos.
316
+ Listen for all events.
317
317
 
318
318
  ```javascript
319
319
  client.onAll(({ event, data }) => {
@@ -322,93 +322,93 @@ client.onAll(({ event, data }) => {
322
322
  ```
323
323
 
324
324
  **`.onAck(name, handler)`**
325
- Escuchar respuestas de ACK del servidor.
325
+ Listen for ACK responses from the server.
326
326
 
327
327
  ```javascript
328
328
  client.onAck('userData', (data) => {
329
- console.log('Datos recibidos:', data);
329
+ console.log('Data received:', data);
330
330
  });
331
331
  ```
332
332
 
333
333
  **`.emit(event, data, opts)`**
334
- Enviar eventos al servidor. Soporta `opts.ack` para ACKs.
334
+ Send events to the server. Supports `opts.ack` for ACKs.
335
335
 
336
336
  ```javascript
337
- client.emit('chat', { mensaje: 'Hola!' });
337
+ client.emit('chat', { message: 'Hello!' });
338
338
  client.emit('getUser', { id: 1 }, { ack: 'userData' });
339
339
  ```
340
340
 
341
341
  **`.request(event, data, ackName)`**
342
- Enviar y esperar respuesta como Promise.
342
+ Send and wait for response as Promise.
343
343
 
344
344
  ```javascript
345
345
  const result = await client.request('getUser', { id: 1 }, 'userData');
346
346
  console.log(result); // { id: 1, name: 'John' }
347
347
 
348
- // Con timeout opcional
348
+ // With optional timeout
349
349
  const client = new StelarClient(3000, { ackTimeout: 10000 });
350
350
  ```
351
351
 
352
352
  **`.joinRoom(room)`**
353
- Unirse a una sala.
353
+ Join a room.
354
354
 
355
355
  ```javascript
356
- client.joinRoom('sala-1');
356
+ client.joinRoom('room-1');
357
357
  ```
358
358
 
359
359
  **`.leaveRoom()`**
360
- Salir de la sala actual.
360
+ Leave current room.
361
361
 
362
362
  ```javascript
363
363
  client.leaveRoom();
364
364
  ```
365
365
 
366
366
  **`.connect(callback)`**
367
- Conectar al servidor.
367
+ Connect to the server.
368
368
 
369
369
  ```javascript
370
370
  client.connect(() => {
371
- console.log('Conectado!');
371
+ console.log('Connected!');
372
372
  });
373
373
  ```
374
374
 
375
375
  **`.disconnect()`**
376
- Desconectar manualmente.
376
+ Manually disconnect.
377
377
 
378
378
  ```javascript
379
379
  client.disconnect();
380
380
  ```
381
381
 
382
382
  **`.isConnected()`**
383
- Verificar estado de conexión.
383
+ Check connection status.
384
384
 
385
385
  ```javascript
386
386
  if (client.isConnected()) {
387
- console.log('Conectado');
387
+ console.log('Connected');
388
388
  }
389
389
  ```
390
390
 
391
391
  **`.getUrl()`**
392
- Obtener la URL de conexión.
392
+ Get connection URL.
393
393
 
394
394
  ```javascript
395
395
  console.log(client.getUrl());
396
396
  ```
397
397
 
398
- #### Eventos del Cliente
398
+ #### Client Events
399
399
 
400
400
  ```javascript
401
- client.on('connect', () => {}); // Cuando se conecta
402
- client.on('disconnect', () => {}); // Cuando se desconecta
403
- client.on('reconnecting', (attempt) => {}); // Cuando intenta reconectar
404
- client.on('error', (err) => {}); // Cuando hay error
401
+ client.on('connect', () => {}); // When connected
402
+ client.on('disconnect', () => {}); // When disconnected
403
+ client.on('reconnecting', (attempt) => {}); // When trying to reconnect
404
+ client.on('error', (err) => {}); // When there's an error
405
405
  ```
406
406
 
407
407
  ---
408
408
 
409
- ## Ejemplos
409
+ ## Examples
410
410
 
411
- ### Chat Básico
411
+ ### Basic Chat
412
412
 
413
413
  **server.js**
414
414
  ```javascript
@@ -421,7 +421,7 @@ const server = app.listen(3000);
421
421
  const stelar = new StelarServer({ server });
422
422
 
423
423
  stelar.onConnection((client) => {
424
- client.broadcast('system', 'Un usuario se unió');
424
+ client.broadcast('system', 'A user joined');
425
425
  });
426
426
 
427
427
  stelar.on('chat', (ctx) => {
@@ -429,7 +429,7 @@ stelar.on('chat', (ctx) => {
429
429
  });
430
430
 
431
431
  stelar.start();
432
- console.log('Chat en http://localhost:3000');
432
+ console.log('Chat at http://localhost:3000');
433
433
  ```
434
434
 
435
435
  **cliente.html**
@@ -439,51 +439,51 @@ console.log('Chat en http://localhost:3000');
439
439
 
440
440
  const client = new StelarClient(3000);
441
441
 
442
- client.on('connect', () => console.log('Conectado'));
442
+ client.on('connect', () => console.log('Connected'));
443
443
  client.on('chat', (msg) => console.log('Chat:', msg));
444
- client.on('system', (msg) => console.log('Sistema:', msg));
444
+ client.on('system', (msg) => console.log('System:', msg));
445
445
 
446
446
  client.connect();
447
447
 
448
- // Enviar mensajes
449
- function enviar(mensaje) {
450
- client.emit('chat', mensaje);
448
+ // Send messages
449
+ function send(message) {
450
+ client.emit('chat', message);
451
451
  }
452
452
  </script>
453
453
  ```
454
454
 
455
- ### Sistema de Rooms
455
+ ### Room System
456
456
 
457
457
  ```javascript
458
- // Servidor
459
- stelar.on('unirse-sala', (ctx) => {
460
- const sala = ctx.data.sala;
461
- ctx.joinRoom(sala);
462
- ctx.emit('bienvenida', `Te uniste a ${sala}`);
458
+ // Server
459
+ stelar.on('join-room', (ctx) => {
460
+ const room = ctx.data.room;
461
+ ctx.joinRoom(room);
462
+ ctx.emit('welcome', `You joined ${room}`);
463
463
  });
464
464
 
465
- stelar.on('mensaje-sala', (ctx) => {
466
- ctx.to(ctx.data.sala, 'mensaje-sala', ctx.data.mensaje);
465
+ stelar.on('room-message', (ctx) => {
466
+ ctx.to(ctx.data.room, 'room-message', ctx.data.message);
467
467
  });
468
468
 
469
- // Cliente
470
- client.on('unirse-sala', (sala) => client.joinRoom(sala));
469
+ // Client
470
+ client.on('join-room', (room) => client.joinRoom(room));
471
471
  ```
472
472
 
473
- ### Con Middleware de Auth
473
+ ### With Auth Middleware
474
474
 
475
475
  ```javascript
476
476
  stelar.use((ctx, next) => {
477
477
  const token = ctx.req.headers['authorization'];
478
478
  if (token && token.startsWith('Bearer ')) {
479
- next(); // Permitir conexión
479
+ next(); // Allow connection
480
480
  } else {
481
- ctx.socket.close(); // Rechazar
481
+ ctx.socket.close(); // Reject
482
482
  }
483
483
  });
484
484
  ```
485
485
 
486
- ### Con Reconexión Automática
486
+ ### With Auto Reconnection
487
487
 
488
488
  ```javascript
489
489
  import { StelarClient } from 'stelar-time-real';
@@ -494,28 +494,28 @@ const client = new StelarClient('localhost:3000', {
494
494
  reconnectionDelay: 1000
495
495
  });
496
496
 
497
- client.on('connect', () => console.log('Conectado!'));
498
- client.on('disconnect', () => console.log('Desconectado'));
499
- client.on('reconnecting', (attempt) => console.log(`Reintentando ${attempt}/5`));
497
+ client.on('connect', () => console.log('Connected!'));
498
+ client.on('disconnect', () => console.log('Disconnected'));
499
+ client.on('reconnecting', (attempt) => console.log(`Retrying ${attempt}/5`));
500
500
 
501
501
  client.connect();
502
502
  ```
503
503
 
504
- ### Enviar Archivos Binarios
504
+ ### Send Binary Files
505
505
 
506
506
  ```javascript
507
- // Servidor - recibir imagen
507
+ // Server - receive image
508
508
  stelar.on('image', (ctx) => {
509
- // ctx.buffer es un Uint8Array
510
- console.log('Recibido:', ctx.buffer.byteLength, 'bytes');
511
- // Guardar o procesar la imagen
509
+ // ctx.buffer is a Uint8Array
510
+ console.log('Received:', ctx.buffer.byteLength, 'bytes');
511
+ // Save or process the image
512
512
  saveImage(ctx.buffer);
513
513
 
514
- // Responder al cliente
514
+ // Respond to client
515
515
  ctx.emit('imageSaved', { success: true });
516
516
  });
517
517
 
518
- // Cliente - enviar imagen
518
+ // Client - send image
519
519
  const input = document.querySelector('input[type="file"]');
520
520
  input.addEventListener('change', async (e) => {
521
521
  const file = e.target.files[0];
@@ -523,7 +523,7 @@ input.addEventListener('change', async (e) => {
523
523
  client.emitBinary('image', buffer);
524
524
  });
525
525
 
526
- // Cliente - recibir imagen
526
+ // Client - receive image
527
527
  client.on('image', (buffer) => {
528
528
  const blob = new Blob([buffer], { type: 'image/png' });
529
529
  const url = URL.createObjectURL(blob);
@@ -531,35 +531,35 @@ client.on('image', (buffer) => {
531
531
  });
532
532
  ```
533
533
 
534
- ### Broadcast de Binarios
534
+ ### Binary Broadcast
535
535
 
536
536
  ```javascript
537
- // Servidor - compartir archivo con todos
537
+ // Server - share file with everyone
538
538
  stelar.on('upload', (ctx) => {
539
539
  ctx.broadcastBinary('file', ctx.buffer);
540
540
  });
541
541
 
542
- // Cliente - enviar archivo
542
+ // Client - send file
543
543
  const fileData = await file.arrayBuffer();
544
544
  client.emitBinary('upload', fileData);
545
545
  ```
546
546
 
547
547
  ---
548
548
 
549
- ## Diferencia con Socket.io
549
+ ## Difference with Socket.io
550
550
 
551
- | Característica | stelar-time-real | Socket.io |
552
- |----------------|------------------|-----------|
553
- | Tamaño heap | ~13 MB | ~50-100 MB |
554
- | Dependencias | ws (1) | múltiples |
555
- | Configuración | mínima | compleja |
556
- | Flexibilidad | total | opinionada |
557
- | Ideal para | proyectos propios | producción rápida |
551
+ | Feature | stelar-time-real | Socket.io |
552
+ |---------|------------------|-----------|
553
+ | Heap size | ~13 MB | ~50-100 MB |
554
+ | Dependencies | ws (1) | multiple |
555
+ | Configuration | minimal | complex |
556
+ | Flexibility | total | opinionated |
557
+ | Ideal for | own projects | quick production |
558
558
 
559
- ## Licencia
559
+ ## License
560
560
 
561
561
  MIT - Stelar
562
562
 
563
- ## Autor
563
+ ## Author
564
564
 
565
565
  Stelar
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stelar-time-real",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
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",
@@ -22,12 +22,12 @@
22
22
  "license": "MIT",
23
23
  "repository": {
24
24
  "type": "git",
25
- "url": "https://github.com/stelar-time-real/stelar-time-real"
25
+ "url": "https://github.com/foxytp/stelar-time-real"
26
26
  },
27
27
  "bugs": {
28
- "url": "https://github.com/stelar-time-real/stelar-time-real/issues"
28
+ "url": "https://github.com/foxytp/stelar-time-real/issues"
29
29
  },
30
- "homepage": "https://github.com/stelar-time-real/stelar-time-real#readme",
30
+ "homepage": "https://github.com/foxytp/stelar-time-real#readme",
31
31
  "exports": {
32
32
  ".": "./src/index.js",
33
33
  "./client": "./src/client.js",