angelia.io 2.4.79 → 3.4.80
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 +1 -16
- package/index.js +1 -3
- package/package.json +3 -2
- package/server/Listeners.js +3 -3
- package/server/Server.js +24 -16
- package/server/Socket.js +2 -6
- package/server/index.js +2 -2
- package/server/rooms/Manager.js +3 -7
- package/server/rooms/Room.js +2 -6
- package/server/rooms/Rooms.js +2 -6
- package/server/rooms/constants.js +5 -16
package/client/index.js
CHANGED
|
@@ -227,7 +227,7 @@ class ClientWebWorker {
|
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
-
class Client {
|
|
230
|
+
export class Client {
|
|
231
231
|
constructor(options) {
|
|
232
232
|
if (!options || typeof options === 'string') {
|
|
233
233
|
options = {
|
|
@@ -441,18 +441,3 @@ class Client {
|
|
|
441
441
|
}
|
|
442
442
|
}
|
|
443
443
|
}
|
|
444
|
-
|
|
445
|
-
;(function (root) {
|
|
446
|
-
if (typeof exports !== 'undefined') {
|
|
447
|
-
if (typeof module !== 'undefined' && module.exports) {
|
|
448
|
-
exports = module.exports = Client
|
|
449
|
-
}
|
|
450
|
-
exports.Client = Client
|
|
451
|
-
} else if (typeof define === 'function' && define.amd) {
|
|
452
|
-
define([], function () {
|
|
453
|
-
return Client
|
|
454
|
-
})
|
|
455
|
-
} else {
|
|
456
|
-
root.Client = Client
|
|
457
|
-
}
|
|
458
|
-
})(this)
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "angelia.io",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.4.80",
|
|
4
4
|
"description": "WebSockets Server and Client API for node.js and the browser, with rooms support.",
|
|
5
5
|
"homepage": "https://github.com/titoBouzout/angelia.io",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/titoBouzout/angelia.io"
|
|
9
9
|
},
|
|
10
|
+
"type": "module",
|
|
10
11
|
"main": "index.js",
|
|
11
12
|
"keywords": [
|
|
12
13
|
"Client",
|
|
@@ -32,7 +33,7 @@
|
|
|
32
33
|
"isobject": "^4.0.0",
|
|
33
34
|
"to-fast-properties": "^3.0.1",
|
|
34
35
|
"utf-8-validate": "^5.0.4",
|
|
35
|
-
"ws": "^
|
|
36
|
+
"ws": "^8.x.x"
|
|
36
37
|
},
|
|
37
38
|
"prettier": {
|
|
38
39
|
"printWidth": 70,
|
package/server/Listeners.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
1
|
const inspect = Symbol.for('nodejs.util.inspect.custom')
|
|
4
2
|
|
|
5
3
|
class Listeners {
|
|
@@ -196,4 +194,6 @@ class Listeners {
|
|
|
196
194
|
|
|
197
195
|
Listeners.prototype.isClass()
|
|
198
196
|
|
|
199
|
-
|
|
197
|
+
const listeners = new Listeners()
|
|
198
|
+
|
|
199
|
+
export { listeners as Listeners }
|
package/server/Server.js
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
1
|
const inspect = Symbol.for('nodejs.util.inspect.custom')
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import { Listeners } from './Listeners.js'
|
|
4
|
+
|
|
5
|
+
import { Manager } from './rooms/Manager.js'
|
|
6
|
+
import { Room } from './rooms/Room.js'
|
|
7
|
+
// const toFastProperties = require('to-fast-properties')
|
|
8
|
+
import url from 'node:url'
|
|
9
|
+
import { Socket } from './Socket.js'
|
|
10
|
+
|
|
11
|
+
import fs from 'node:fs'
|
|
12
|
+
|
|
13
|
+
import * as http from 'http'
|
|
14
|
+
import * as https from 'https'
|
|
7
15
|
|
|
8
|
-
|
|
16
|
+
import WebSocket, { WebSocketServer } from 'ws'
|
|
9
17
|
|
|
10
18
|
class ServerSingleton {
|
|
11
19
|
constructor() {
|
|
@@ -49,16 +57,17 @@ class ServerSingleton {
|
|
|
49
57
|
|
|
50
58
|
_track: Manager.track,
|
|
51
59
|
rooms: Manager.rooms,
|
|
52
|
-
Room
|
|
60
|
+
Room,
|
|
53
61
|
observe: Manager.observe,
|
|
54
62
|
|
|
55
63
|
cacheIds: Symbol('cache'),
|
|
56
64
|
cacheId: 1,
|
|
57
65
|
cache: Object.create(null),
|
|
58
66
|
|
|
59
|
-
URL:
|
|
60
|
-
Socket
|
|
61
|
-
WebSocket
|
|
67
|
+
URL: url,
|
|
68
|
+
Socket,
|
|
69
|
+
WebSocket,
|
|
70
|
+
WebSocketServer,
|
|
62
71
|
WebSocketFrame: {
|
|
63
72
|
readOnly: false,
|
|
64
73
|
mask: false,
|
|
@@ -111,7 +120,7 @@ class ServerSingleton {
|
|
|
111
120
|
})
|
|
112
121
|
this.timeoutCheck = this.timeout / 2
|
|
113
122
|
|
|
114
|
-
this.ensureFastProperties()
|
|
123
|
+
// this.ensureFastProperties()
|
|
115
124
|
|
|
116
125
|
// updates ping and checks for disconnections
|
|
117
126
|
setInterval(this.ping, this.timeoutCheck)
|
|
@@ -124,8 +133,7 @@ class ServerSingleton {
|
|
|
124
133
|
res.end()
|
|
125
134
|
}
|
|
126
135
|
if (this.cert && this.key) {
|
|
127
|
-
|
|
128
|
-
this.http = require('https').createServer(
|
|
136
|
+
this.http = https.createServer(
|
|
129
137
|
{
|
|
130
138
|
cert: fs.readFileSync(this.cert), // fullchain.pem
|
|
131
139
|
key: fs.readFileSync(this.key), // privkey.pem
|
|
@@ -133,11 +141,11 @@ class ServerSingleton {
|
|
|
133
141
|
handle,
|
|
134
142
|
)
|
|
135
143
|
} else {
|
|
136
|
-
this.http =
|
|
144
|
+
this.http = http.createServer(handle)
|
|
137
145
|
}
|
|
138
146
|
}
|
|
139
147
|
|
|
140
|
-
let io = new this.
|
|
148
|
+
let io = new this.WebSocketServer({
|
|
141
149
|
server: this.http,
|
|
142
150
|
perMessageDeflate: false,
|
|
143
151
|
maxPayload: this.maxMessageSize * 1024 * 1024,
|
|
@@ -175,7 +183,7 @@ class ServerSingleton {
|
|
|
175
183
|
},
|
|
176
184
|
})
|
|
177
185
|
|
|
178
|
-
this.ensureFastProperties()
|
|
186
|
+
// this.ensureFastProperties()
|
|
179
187
|
}
|
|
180
188
|
|
|
181
189
|
// emits to everyone connected to the server
|
|
@@ -514,4 +522,4 @@ class ServerSingleton {
|
|
|
514
522
|
|
|
515
523
|
const Server = new ServerSingleton()
|
|
516
524
|
|
|
517
|
-
|
|
525
|
+
export { Server, Server as default }
|
package/server/Socket.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
1
|
const inspect = Symbol.for('nodejs.util.inspect.custom')
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
import { leave } from './rooms/constants.js'
|
|
6
4
|
|
|
7
|
-
class Socket {
|
|
5
|
+
export class Socket {
|
|
8
6
|
constructor(socket, server) {
|
|
9
7
|
Object.assign(this, {
|
|
10
8
|
server: server,
|
|
@@ -225,5 +223,3 @@ class Socket {
|
|
|
225
223
|
}
|
|
226
224
|
}
|
|
227
225
|
}
|
|
228
|
-
|
|
229
|
-
module.exports = Socket
|
package/server/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
export { Server as default } from './Server.js'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export * from './Server.js'
|
package/server/rooms/Manager.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { join, leave } from './constants.js'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const Rooms = require('./Rooms.js')
|
|
3
|
+
import { Rooms } from './Rooms.js'
|
|
6
4
|
|
|
7
5
|
class ManagerSingleton {
|
|
8
6
|
constructor() {
|
|
@@ -107,6 +105,4 @@ class ManagerSingleton {
|
|
|
107
105
|
}
|
|
108
106
|
}
|
|
109
107
|
|
|
110
|
-
const Manager = new ManagerSingleton()
|
|
111
|
-
|
|
112
|
-
module.exports = Manager
|
|
108
|
+
export const Manager = new ManagerSingleton()
|
package/server/rooms/Room.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { join, leave, parent, add, remove } from './constants.js'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class Room {
|
|
3
|
+
export class Room {
|
|
6
4
|
constructor() {
|
|
7
5
|
this.sockets = new Set()
|
|
8
6
|
}
|
|
@@ -97,5 +95,3 @@ class Room {
|
|
|
97
95
|
return this.sockets[Symbol.iterator]()
|
|
98
96
|
}
|
|
99
97
|
}
|
|
100
|
-
|
|
101
|
-
module.exports = Room
|
package/server/rooms/Rooms.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { add, remove } from './constants.js'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class Rooms {
|
|
3
|
+
export class Rooms {
|
|
6
4
|
constructor(path) {
|
|
7
5
|
Object.assign(this, {
|
|
8
6
|
path: path,
|
|
@@ -36,5 +34,3 @@ class Rooms {
|
|
|
36
34
|
return this.rooms[Symbol.iterator]()
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
|
-
|
|
40
|
-
module.exports = Rooms
|
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
const join = Symbol.for('Room.join')
|
|
2
|
-
const leave = Symbol.for('Room.leave')
|
|
3
|
-
const parent = Symbol.for('Room.parent')
|
|
1
|
+
export const join = Symbol.for('Room.join')
|
|
2
|
+
export const leave = Symbol.for('Room.leave')
|
|
3
|
+
export const parent = Symbol.for('Room.parent')
|
|
4
4
|
|
|
5
|
-
const add = Symbol.for('Rooms.add')
|
|
6
|
-
const remove = Symbol.for('Rooms.remove')
|
|
7
|
-
|
|
8
|
-
module.exports = {
|
|
9
|
-
// Room
|
|
10
|
-
join,
|
|
11
|
-
leave,
|
|
12
|
-
parent,
|
|
13
|
-
|
|
14
|
-
// Rooms
|
|
15
|
-
add,
|
|
16
|
-
remove,
|
|
17
|
-
}
|
|
5
|
+
export const add = Symbol.for('Rooms.add')
|
|
6
|
+
export const remove = Symbol.for('Rooms.remove')
|