angelia.io 1.66.0 → 2.2.0
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/client/index.js +13 -27
- package/package.json +1 -1
- package/readme.md +1 -0
package/client/index.js
CHANGED
|
@@ -240,20 +240,18 @@ class Client {
|
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
const io = new Worker(
|
|
243
|
-
URL.createObjectURL(
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
type: 'application/javascript; charset=utf-8',
|
|
247
|
-
},
|
|
248
|
-
),
|
|
243
|
+
URL.createObjectURL(new Blob(["'use strict';new (" + ClientWebWorker + ')']), {
|
|
244
|
+
type: 'application/javascript; charset=utf-8',
|
|
245
|
+
}),
|
|
249
246
|
)
|
|
247
|
+
let shouldConnect = options.dontConnect !== undefined ? !options.dontConnect : true
|
|
250
248
|
|
|
251
249
|
Object.assign(this, {
|
|
252
250
|
url: options.url,
|
|
253
251
|
params: options.params,
|
|
254
252
|
longLiveFlash: options.longLiveFlash,
|
|
255
|
-
|
|
256
|
-
connected:
|
|
253
|
+
shouldConnect: shouldConnect,
|
|
254
|
+
connected: shouldConnect,
|
|
257
255
|
messages: [],
|
|
258
256
|
listeners: {
|
|
259
257
|
'': [this.oncallback.bind(this)],
|
|
@@ -277,7 +275,7 @@ class Client {
|
|
|
277
275
|
window.addEventListener('unload', () => this.disconnect(true), true)
|
|
278
276
|
|
|
279
277
|
// to send messages fast without waiting for the connection
|
|
280
|
-
Promise.resolve().then(() => this.connect())
|
|
278
|
+
shouldConnect && Promise.resolve().then(() => this.connect())
|
|
281
279
|
}
|
|
282
280
|
|
|
283
281
|
// public API
|
|
@@ -317,28 +315,16 @@ class Client {
|
|
|
317
315
|
this.listeners[k].push(v)
|
|
318
316
|
return () => this.off(k, v)
|
|
319
317
|
} else {
|
|
320
|
-
console.error(
|
|
321
|
-
'ws - socket.on("' +
|
|
322
|
-
k +
|
|
323
|
-
'", callback) key and callback cannot be empty',
|
|
324
|
-
)
|
|
318
|
+
console.error('ws - socket.on("' + k + '", callback) key and callback cannot be empty')
|
|
325
319
|
}
|
|
326
320
|
}
|
|
327
321
|
off(k, v) {
|
|
328
322
|
if (!this.listeners[k]) {
|
|
329
|
-
console.error(
|
|
330
|
-
'ws - socket.off("' + k + '", callback)',
|
|
331
|
-
k,
|
|
332
|
-
'key not found',
|
|
333
|
-
)
|
|
323
|
+
console.error('ws - socket.off("' + k + '", callback)', k, 'key not found')
|
|
334
324
|
} else {
|
|
335
325
|
let i = this.listeners[k].indexOf(v)
|
|
336
326
|
if (i === -1) {
|
|
337
|
-
console.error(
|
|
338
|
-
'ws - socket.off("' + k + '", callback)',
|
|
339
|
-
v,
|
|
340
|
-
'callback not found',
|
|
341
|
-
)
|
|
327
|
+
console.error('ws - socket.off("' + k + '", callback)', v, 'callback not found')
|
|
342
328
|
} else {
|
|
343
329
|
this.listeners[k].splice(i, 1)
|
|
344
330
|
}
|
|
@@ -410,7 +396,7 @@ class Client {
|
|
|
410
396
|
break
|
|
411
397
|
}
|
|
412
398
|
case 'connect': {
|
|
413
|
-
this.connect()
|
|
399
|
+
if (this.shouldConnect) this.connect()
|
|
414
400
|
break
|
|
415
401
|
}
|
|
416
402
|
case 'connected': {
|
|
@@ -419,10 +405,10 @@ class Client {
|
|
|
419
405
|
}
|
|
420
406
|
}
|
|
421
407
|
}
|
|
422
|
-
decode(s){
|
|
408
|
+
decode(s) {
|
|
423
409
|
if (s.b) {
|
|
424
410
|
return fetch(s.b).then(r => r.blob())
|
|
425
|
-
} else if(s.a) {
|
|
411
|
+
} else if (s.a) {
|
|
426
412
|
return fetch(s.a).then(r => r.arrayBuffer())
|
|
427
413
|
}
|
|
428
414
|
}
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -91,6 +91,7 @@ const server = new Server.listen({
|
|
|
91
91
|
| `port` | Number | 3001 | the port to use for this server |
|
|
92
92
|
| `maxMessageSize` | Number | 5 | max size in mb of a message received |
|
|
93
93
|
| `skipUTF8Validation` | Boolean | false | allows to skip utf8 validation |
|
|
94
|
+
| `dontConnect` | Boolean | false | allows to instance the socket without connecting |
|
|
94
95
|
| `cert` | String | '' | path to the cert file for using https fullchain.pem |
|
|
95
96
|
| `key` | String | '' | path to the key file for using https privkey.pem |
|
|
96
97
|
|