@callstack/repack-dev-server 1.0.2 → 4.0.0-rc.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/CHANGELOG.md +16 -0
- package/LICENSE +21 -0
- package/dist/createServer.d.ts +1 -1
- package/dist/createServer.js +16 -17
- package/dist/createServer.js.map +1 -1
- package/dist/plugins/api/apiPlugin.js +3 -9
- package/dist/plugins/api/apiPlugin.js.map +1 -1
- package/dist/plugins/api/index.js.map +1 -1
- package/dist/plugins/compiler/compilerPlugin.d.ts +4 -3
- package/dist/plugins/compiler/compilerPlugin.js +8 -18
- package/dist/plugins/compiler/compilerPlugin.js.map +1 -1
- package/dist/plugins/compiler/index.js.map +1 -1
- package/dist/plugins/devtools/devtoolsPlugin.d.ts +4 -3
- package/dist/plugins/devtools/devtoolsPlugin.js +6 -8
- package/dist/plugins/devtools/devtoolsPlugin.js.map +1 -1
- package/dist/plugins/devtools/index.js.map +1 -1
- package/dist/plugins/favicon/faviconPlugin.d.ts +3 -2
- package/dist/plugins/favicon/faviconPlugin.js +2 -3
- package/dist/plugins/favicon/faviconPlugin.js.map +1 -1
- package/dist/plugins/favicon/index.js.map +1 -1
- package/dist/plugins/multipart/index.js.map +1 -1
- package/dist/plugins/multipart/multipartPlugin.d.ts +3 -2
- package/dist/plugins/multipart/multipartPlugin.js +1 -14
- package/dist/plugins/multipart/multipartPlugin.js.map +1 -1
- package/dist/plugins/symbolicate/Symbolicator.js +13 -32
- package/dist/plugins/symbolicate/Symbolicator.js.map +1 -1
- package/dist/plugins/symbolicate/index.js.map +1 -1
- package/dist/plugins/symbolicate/sybmolicatePlugin.d.ts +4 -3
- package/dist/plugins/symbolicate/sybmolicatePlugin.js +2 -4
- package/dist/plugins/symbolicate/sybmolicatePlugin.js.map +1 -1
- package/dist/plugins/wss/WebSocketRouter.js +2 -6
- package/dist/plugins/wss/WebSocketRouter.js.map +1 -1
- package/dist/plugins/wss/WebSocketServer.js +2 -5
- package/dist/plugins/wss/WebSocketServer.js.map +1 -1
- package/dist/plugins/wss/index.js.map +1 -1
- package/dist/plugins/wss/servers/HermesInspectorProxy.js +1 -19
- package/dist/plugins/wss/servers/HermesInspectorProxy.js.map +1 -1
- package/dist/plugins/wss/servers/WebSocketApiServer.js +5 -11
- package/dist/plugins/wss/servers/WebSocketApiServer.js.map +1 -1
- package/dist/plugins/wss/servers/WebSocketDebuggerServer.js +6 -20
- package/dist/plugins/wss/servers/WebSocketDebuggerServer.js.map +1 -1
- package/dist/plugins/wss/servers/WebSocketDevClientServer.js +3 -12
- package/dist/plugins/wss/servers/WebSocketDevClientServer.js.map +1 -1
- package/dist/plugins/wss/servers/WebSocketEventsServer.js +18 -25
- package/dist/plugins/wss/servers/WebSocketEventsServer.js.map +1 -1
- package/dist/plugins/wss/servers/WebSocketHMRServer.js +3 -13
- package/dist/plugins/wss/servers/WebSocketHMRServer.js.map +1 -1
- package/dist/plugins/wss/servers/WebSocketMessageServer.d.ts +1 -1
- package/dist/plugins/wss/servers/WebSocketMessageServer.js +21 -51
- package/dist/plugins/wss/servers/WebSocketMessageServer.js.map +1 -1
- package/dist/plugins/wss/wssPlugin.d.ts +4 -3
- package/dist/plugins/wss/wssPlugin.js +0 -2
- package/dist/plugins/wss/wssPlugin.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js +9 -34
- package/dist/types.js.map +1 -1
- package/package.json +26 -29
- package/docs/README.md +0 -28
- package/docs/enums/Internal.EventTypes.md +0 -41
- package/docs/functions/createServer.md +0 -21
- package/docs/interfaces/CodeFrame.md +0 -48
- package/docs/interfaces/CompilerDelegate.md +0 -83
- package/docs/interfaces/HmrDelegate.md +0 -51
- package/docs/interfaces/InputStackFrame.md +0 -76
- package/docs/interfaces/ProgressData.md +0 -34
- package/docs/interfaces/ReactNativeStackFrame.md +0 -58
- package/docs/interfaces/Server.Api.Asset.md +0 -36
- package/docs/interfaces/Server.Api.CompilationStats.md +0 -9
- package/docs/interfaces/Server.Api.Delegate.md +0 -75
- package/docs/interfaces/Server.Config.md +0 -49
- package/docs/interfaces/Server.Delegate.md +0 -88
- package/docs/interfaces/Server.DelegateContext.md +0 -134
- package/docs/interfaces/Server.LoggerDelegate.md +0 -33
- package/docs/interfaces/Server.MessagesDelegate.md +0 -44
- package/docs/interfaces/Server.Options.md +0 -70
- package/docs/interfaces/StackFrame.md +0 -85
- package/docs/interfaces/SymbolicatorDelegate.md +0 -77
- package/docs/interfaces/SymbolicatorResults.md +0 -30
- package/docs/modules/Internal.md +0 -11
- package/docs/modules/Server.Api.md +0 -11
- package/docs/modules/Server.md +0 -16
- package/docs/types/SendProgress.md +0 -26
|
@@ -3,7 +3,9 @@ import { WebSocketServer } from "../WebSocketServer.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Holds {@link ReactNativeMessage} `id` data.
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Message representation used by {@link WebSocketMessageServer}.
|
|
8
|
+
*/
|
|
7
9
|
/**
|
|
8
10
|
* Class for creating a WebSocket server and sending messages between development server
|
|
9
11
|
* and the React Native applications.
|
|
@@ -14,6 +16,7 @@ import { WebSocketServer } from "../WebSocketServer.js";
|
|
|
14
16
|
*/
|
|
15
17
|
export class WebSocketMessageServer extends WebSocketServer {
|
|
16
18
|
static PROTOCOL_VERSION = 2;
|
|
19
|
+
|
|
17
20
|
/**
|
|
18
21
|
* Check if message is a broadcast request.
|
|
19
22
|
*
|
|
@@ -21,45 +24,42 @@ export class WebSocketMessageServer extends WebSocketServer {
|
|
|
21
24
|
* @returns True if message is a broadcast request and should be broadcasted
|
|
22
25
|
* with {@link sendBroadcast}.
|
|
23
26
|
*/
|
|
24
|
-
|
|
25
27
|
static isBroadcast(message) {
|
|
26
28
|
return typeof message.method === 'string' && message.id === undefined && message.target === undefined;
|
|
27
29
|
}
|
|
30
|
+
|
|
28
31
|
/**
|
|
29
32
|
* Check if message is a method request.
|
|
30
33
|
*
|
|
31
34
|
* @param message Message to check.
|
|
32
35
|
* @returns True if message is a request.
|
|
33
36
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
37
|
static isRequest(message) {
|
|
37
38
|
return typeof message.method === 'string' && typeof message.target === 'string';
|
|
38
39
|
}
|
|
40
|
+
|
|
39
41
|
/**
|
|
40
42
|
* Check if message is a response with results of performing some request.
|
|
41
43
|
*
|
|
42
44
|
* @param message Message to check.
|
|
43
45
|
* @returns True if message is a response.
|
|
44
46
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
47
|
static isResponse(message) {
|
|
48
48
|
return typeof message.id === 'object' && typeof message.id.requestId !== 'undefined' && typeof message.id.clientId === 'string' && (message.result !== undefined || message.error !== undefined);
|
|
49
49
|
}
|
|
50
|
-
|
|
51
50
|
clients = new Map();
|
|
52
51
|
nextClientId = 0;
|
|
52
|
+
|
|
53
53
|
/**
|
|
54
54
|
* Create new instance of WebSocketMessageServer and attach it to the given Fastify instance.
|
|
55
55
|
* Any logging information, will be passed through standard `fastify.log` API.
|
|
56
56
|
*
|
|
57
57
|
* @param fastify Fastify instance to attach the WebSocket server to.
|
|
58
58
|
*/
|
|
59
|
-
|
|
60
59
|
constructor(fastify) {
|
|
61
60
|
super(fastify, '/message');
|
|
62
61
|
}
|
|
62
|
+
|
|
63
63
|
/**
|
|
64
64
|
* Parse stringified message into a {@link ReactNativeMessage}.
|
|
65
65
|
*
|
|
@@ -67,8 +67,6 @@ export class WebSocketMessageServer extends WebSocketServer {
|
|
|
67
67
|
* @param binary Additional binary data if any.
|
|
68
68
|
* @returns Parsed message or `undefined` if parsing failed.
|
|
69
69
|
*/
|
|
70
|
-
|
|
71
|
-
|
|
72
70
|
parseMessage(data, binary) {
|
|
73
71
|
if (binary) {
|
|
74
72
|
this.fastify.log.error({
|
|
@@ -76,14 +74,11 @@ export class WebSocketMessageServer extends WebSocketServer {
|
|
|
76
74
|
});
|
|
77
75
|
return undefined;
|
|
78
76
|
}
|
|
79
|
-
|
|
80
77
|
try {
|
|
81
78
|
const message = JSON.parse(data);
|
|
82
|
-
|
|
83
79
|
if (message.version === WebSocketMessageServer.PROTOCOL_VERSION.toString()) {
|
|
84
80
|
return message;
|
|
85
81
|
}
|
|
86
|
-
|
|
87
82
|
this.fastify.log.error({
|
|
88
83
|
msg: 'Received message had wrong protocol version',
|
|
89
84
|
message
|
|
@@ -94,9 +89,9 @@ export class WebSocketMessageServer extends WebSocketServer {
|
|
|
94
89
|
data
|
|
95
90
|
});
|
|
96
91
|
}
|
|
97
|
-
|
|
98
92
|
return undefined;
|
|
99
93
|
}
|
|
94
|
+
|
|
100
95
|
/**
|
|
101
96
|
* Get client's WebSocket connection for given `clientId`.
|
|
102
97
|
* Throws if no such client is connected.
|
|
@@ -104,17 +99,14 @@ export class WebSocketMessageServer extends WebSocketServer {
|
|
|
104
99
|
* @param clientId Id of the client.
|
|
105
100
|
* @returns WebSocket connection.
|
|
106
101
|
*/
|
|
107
|
-
|
|
108
|
-
|
|
109
102
|
getClientSocket(clientId) {
|
|
110
103
|
const socket = this.clients.get(clientId);
|
|
111
|
-
|
|
112
104
|
if (socket === undefined) {
|
|
113
105
|
throw new Error(`Could not find client with id "${clientId}"`);
|
|
114
106
|
}
|
|
115
|
-
|
|
116
107
|
return socket;
|
|
117
108
|
}
|
|
109
|
+
|
|
118
110
|
/**
|
|
119
111
|
* Process error by sending an error message to the client whose message caused the error
|
|
120
112
|
* to occur.
|
|
@@ -123,8 +115,6 @@ export class WebSocketMessageServer extends WebSocketServer {
|
|
|
123
115
|
* @param message Original message which caused the error.
|
|
124
116
|
* @param error Concrete instance of an error that occurred.
|
|
125
117
|
*/
|
|
126
|
-
|
|
127
|
-
|
|
128
118
|
handleError(clientId, message, error) {
|
|
129
119
|
const errorMessage = {
|
|
130
120
|
id: message.id,
|
|
@@ -134,7 +124,6 @@ export class WebSocketMessageServer extends WebSocketServer {
|
|
|
134
124
|
params: message.params === undefined ? 'undefined' : 'defined',
|
|
135
125
|
result: message.result === undefined ? 'undefined' : 'defined'
|
|
136
126
|
};
|
|
137
|
-
|
|
138
127
|
if (message.id === undefined) {
|
|
139
128
|
this.fastify.log.error({
|
|
140
129
|
msg: 'Handling message failed',
|
|
@@ -159,6 +148,7 @@ export class WebSocketMessageServer extends WebSocketServer {
|
|
|
159
148
|
}
|
|
160
149
|
}
|
|
161
150
|
}
|
|
151
|
+
|
|
162
152
|
/**
|
|
163
153
|
* Send given request `message` to it's designated client's socket based on `message.target`.
|
|
164
154
|
* The target client must be connected, otherwise it will throw an error.
|
|
@@ -166,8 +156,6 @@ export class WebSocketMessageServer extends WebSocketServer {
|
|
|
166
156
|
* @param clientId Id of the client that requested the forward.
|
|
167
157
|
* @param message Message to forward.
|
|
168
158
|
*/
|
|
169
|
-
|
|
170
|
-
|
|
171
159
|
forwardRequest(clientId, message) {
|
|
172
160
|
if (!message.target) {
|
|
173
161
|
this.fastify.log.error({
|
|
@@ -177,7 +165,6 @@ export class WebSocketMessageServer extends WebSocketServer {
|
|
|
177
165
|
});
|
|
178
166
|
return;
|
|
179
167
|
}
|
|
180
|
-
|
|
181
168
|
const socket = this.getClientSocket(message.target);
|
|
182
169
|
socket.send(JSON.stringify({
|
|
183
170
|
version: WebSocketMessageServer.PROTOCOL_VERSION,
|
|
@@ -189,6 +176,7 @@ export class WebSocketMessageServer extends WebSocketServer {
|
|
|
189
176
|
}
|
|
190
177
|
}));
|
|
191
178
|
}
|
|
179
|
+
|
|
192
180
|
/**
|
|
193
181
|
* Send given response `message` to it's designated client's socket based
|
|
194
182
|
* on `message.id.clientId`.
|
|
@@ -196,13 +184,10 @@ export class WebSocketMessageServer extends WebSocketServer {
|
|
|
196
184
|
*
|
|
197
185
|
* @param message Message to forward.
|
|
198
186
|
*/
|
|
199
|
-
|
|
200
|
-
|
|
201
187
|
forwardResponse(message) {
|
|
202
188
|
if (!message.id) {
|
|
203
189
|
return;
|
|
204
190
|
}
|
|
205
|
-
|
|
206
191
|
const socket = this.getClientSocket(message.id.clientId);
|
|
207
192
|
socket.send(JSON.stringify({
|
|
208
193
|
version: WebSocketMessageServer.PROTOCOL_VERSION,
|
|
@@ -211,6 +196,7 @@ export class WebSocketMessageServer extends WebSocketServer {
|
|
|
211
196
|
id: message.id.requestId
|
|
212
197
|
}));
|
|
213
198
|
}
|
|
199
|
+
|
|
214
200
|
/**
|
|
215
201
|
* Process request message targeted towards this {@link WebSocketMessageServer}
|
|
216
202
|
* and send back the results.
|
|
@@ -218,27 +204,22 @@ export class WebSocketMessageServer extends WebSocketServer {
|
|
|
218
204
|
* @param clientId Id of the client who send the message.
|
|
219
205
|
* @param message The message to process by the server.
|
|
220
206
|
*/
|
|
221
|
-
|
|
222
|
-
|
|
223
207
|
processServerRequest(clientId, message) {
|
|
224
208
|
let result;
|
|
225
|
-
|
|
226
209
|
switch (message.method) {
|
|
227
210
|
case 'getid':
|
|
228
211
|
result = clientId;
|
|
229
212
|
break;
|
|
230
|
-
|
|
231
213
|
case 'getpeers':
|
|
232
214
|
{
|
|
233
215
|
const output = {};
|
|
234
216
|
this.clients.forEach((peerSocket, peerId) => {
|
|
235
217
|
if (clientId !== peerId) {
|
|
236
|
-
var _peerSocket$upgradeRe;
|
|
237
|
-
|
|
238
218
|
const {
|
|
239
219
|
searchParams
|
|
240
|
-
} = new URL(
|
|
241
|
-
output[peerId] = [...searchParams.entries()].reduce((acc, [key, value]) => ({
|
|
220
|
+
} = new URL(peerSocket.upgradeReq?.url || '');
|
|
221
|
+
output[peerId] = [...searchParams.entries()].reduce((acc, [key, value]) => ({
|
|
222
|
+
...acc,
|
|
242
223
|
[key]: value
|
|
243
224
|
}), {});
|
|
244
225
|
}
|
|
@@ -246,14 +227,12 @@ export class WebSocketMessageServer extends WebSocketServer {
|
|
|
246
227
|
result = output;
|
|
247
228
|
break;
|
|
248
229
|
}
|
|
249
|
-
|
|
250
230
|
default:
|
|
251
231
|
throw new Error(`Cannot process server request - unknown method ${JSON.stringify({
|
|
252
232
|
clientId,
|
|
253
233
|
message
|
|
254
234
|
})}`);
|
|
255
235
|
}
|
|
256
|
-
|
|
257
236
|
const socket = this.getClientSocket(clientId);
|
|
258
237
|
socket.send(JSON.stringify({
|
|
259
238
|
version: WebSocketMessageServer.PROTOCOL_VERSION,
|
|
@@ -261,27 +240,24 @@ export class WebSocketMessageServer extends WebSocketServer {
|
|
|
261
240
|
id: message.id
|
|
262
241
|
}));
|
|
263
242
|
}
|
|
243
|
+
|
|
264
244
|
/**
|
|
265
245
|
* Broadcast given message to all connected clients.
|
|
266
246
|
*
|
|
267
247
|
* @param broadcasterId Id of the client who is broadcasting.
|
|
268
248
|
* @param message Message to broadcast.
|
|
269
249
|
*/
|
|
270
|
-
|
|
271
|
-
|
|
272
250
|
sendBroadcast(broadcasterId, message) {
|
|
273
251
|
const forwarded = {
|
|
274
252
|
version: WebSocketMessageServer.PROTOCOL_VERSION,
|
|
275
253
|
method: message.method,
|
|
276
254
|
params: message.params
|
|
277
255
|
};
|
|
278
|
-
|
|
279
256
|
if (this.clients.size === 0) {
|
|
280
257
|
this.fastify.log.warn({
|
|
281
258
|
msg: 'No apps connected. ' + `Sending "${message.method}" to all React Native apps failed. ` + 'Make sure your app is running in the simulator or on a phone connected via USB.'
|
|
282
259
|
});
|
|
283
260
|
}
|
|
284
|
-
|
|
285
261
|
for (const [clientId, socket] of this.clients) {
|
|
286
262
|
if (clientId !== broadcasterId) {
|
|
287
263
|
try {
|
|
@@ -297,28 +273,26 @@ export class WebSocketMessageServer extends WebSocketServer {
|
|
|
297
273
|
}
|
|
298
274
|
}
|
|
299
275
|
}
|
|
276
|
+
|
|
300
277
|
/**
|
|
301
278
|
* Send method broadcast to all connected clients.
|
|
302
279
|
*
|
|
303
280
|
* @param method Method name to broadcast.
|
|
304
281
|
* @param params Method parameters.
|
|
305
282
|
*/
|
|
306
|
-
|
|
307
|
-
|
|
308
283
|
broadcast(method, params) {
|
|
309
284
|
this.sendBroadcast(undefined, {
|
|
310
285
|
method,
|
|
311
286
|
params
|
|
312
287
|
});
|
|
313
288
|
}
|
|
289
|
+
|
|
314
290
|
/**
|
|
315
291
|
* Process new client's WebSocket connection.
|
|
316
292
|
*
|
|
317
293
|
* @param socket Incoming WebSocket connection.
|
|
318
294
|
* @param request Upgrade request for the connection.
|
|
319
295
|
*/
|
|
320
|
-
|
|
321
|
-
|
|
322
296
|
onConnection(socket, request) {
|
|
323
297
|
const clientId = `client#${this.nextClientId++}`;
|
|
324
298
|
let client = socket;
|
|
@@ -328,7 +302,6 @@ export class WebSocketMessageServer extends WebSocketServer {
|
|
|
328
302
|
msg: 'Message client connected',
|
|
329
303
|
clientId
|
|
330
304
|
});
|
|
331
|
-
|
|
332
305
|
const onClose = () => {
|
|
333
306
|
this.fastify.log.debug({
|
|
334
307
|
msg: 'Message client disconnected',
|
|
@@ -337,13 +310,12 @@ export class WebSocketMessageServer extends WebSocketServer {
|
|
|
337
310
|
socket.removeAllListeners();
|
|
338
311
|
this.clients.delete(clientId);
|
|
339
312
|
};
|
|
340
|
-
|
|
341
313
|
socket.addEventListener('error', onClose);
|
|
342
314
|
socket.addEventListener('close', onClose);
|
|
343
315
|
socket.addEventListener('message', event => {
|
|
344
|
-
const message = this.parseMessage(event.data.toString(),
|
|
316
|
+
const message = this.parseMessage(event.data.toString(),
|
|
317
|
+
// @ts-ignore
|
|
345
318
|
event.binary);
|
|
346
|
-
|
|
347
319
|
if (!message) {
|
|
348
320
|
this.fastify.log.error({
|
|
349
321
|
msg: 'Received message not matching protocol',
|
|
@@ -352,7 +324,6 @@ export class WebSocketMessageServer extends WebSocketServer {
|
|
|
352
324
|
});
|
|
353
325
|
return;
|
|
354
326
|
}
|
|
355
|
-
|
|
356
327
|
try {
|
|
357
328
|
if (WebSocketMessageServer.isBroadcast(message)) {
|
|
358
329
|
this.sendBroadcast(clientId, message);
|
|
@@ -375,6 +346,5 @@ export class WebSocketMessageServer extends WebSocketServer {
|
|
|
375
346
|
}
|
|
376
347
|
});
|
|
377
348
|
}
|
|
378
|
-
|
|
379
349
|
}
|
|
380
350
|
//# sourceMappingURL=WebSocketMessageServer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebSocketMessageServer.js","names":["URL","WebSocketServer","WebSocketMessageServer","PROTOCOL_VERSION","isBroadcast","message","method","id","undefined","target","isRequest","isResponse","requestId","clientId","result","error","clients","Map","nextClientId","constructor","fastify","parseMessage","data","binary","log","msg","JSON","parse","version","toString","e","getClientSocket","socket","get","Error","handleError","errorMessage","params","send","stringify","forwardRequest","forwardResponse","processServerRequest","output","forEach","peerSocket","peerId","searchParams","upgradeReq","url","entries","reduce","acc","key","value","sendBroadcast","broadcasterId","forwarded","size","warn","broadcast","onConnection","request","client","set","debug","onClose","removeAllListeners","delete","addEventListener","event"],"sources":["../../../../src/plugins/wss/servers/WebSocketMessageServer.ts"],"sourcesContent":["import type { IncomingMessage } from 'http';\nimport { URL } from 'url';\nimport type { FastifyInstance } from 'fastify';\nimport WebSocket from 'ws';\nimport { WebSocketServer } from '../WebSocketServer';\n\n/**\n * Holds {@link ReactNativeMessage} `id` data.\n */\nexport interface ReactNativeIdObject {\n requestId: string;\n clientId: string;\n}\n\n/**\n * Message representation used by {@link WebSocketMessageServer}.\n */\nexport interface ReactNativeMessage {\n version?: string;\n id?: ReactNativeIdObject;\n method?: string;\n target: string;\n result?: any;\n error?: Error;\n params?: Record<string, any>;\n}\n\ntype WebSocketWithUpgradeReq = WebSocket & { upgradeReq?: IncomingMessage };\n\n/**\n * Class for creating a WebSocket server and sending messages between development server\n * and the React Native applications.\n *\n * Based on: https://github.com/react-native-community/cli/blob/v4.14.0/packages/cli-server-api/src/websocket/messageSocketServer.ts\n *\n * @category Development server\n */\nexport class WebSocketMessageServer extends WebSocketServer {\n static readonly PROTOCOL_VERSION = 2;\n\n /**\n * Check if message is a broadcast request.\n *\n * @param message Message to check.\n * @returns True if message is a broadcast request and should be broadcasted\n * with {@link sendBroadcast}.\n */\n static isBroadcast(message: Partial<ReactNativeMessage>) {\n return (\n typeof message.method === 'string' &&\n message.id === undefined &&\n message.target === undefined\n );\n }\n\n /**\n * Check if message is a method request.\n *\n * @param message Message to check.\n * @returns True if message is a request.\n */\n static isRequest(message: Partial<ReactNativeMessage>) {\n return (\n typeof message.method === 'string' && typeof message.target === 'string'\n );\n }\n\n /**\n * Check if message is a response with results of performing some request.\n *\n * @param message Message to check.\n * @returns True if message is a response.\n */\n static isResponse(message: Partial<ReactNativeMessage>) {\n return (\n typeof message.id === 'object' &&\n typeof message.id.requestId !== 'undefined' &&\n typeof message.id.clientId === 'string' &&\n (message.result !== undefined || message.error !== undefined)\n );\n }\n\n private clients = new Map<string, WebSocketWithUpgradeReq>();\n private nextClientId = 0;\n\n /**\n * Create new instance of WebSocketMessageServer and attach it to the given Fastify instance.\n * Any logging information, will be passed through standard `fastify.log` API.\n *\n * @param fastify Fastify instance to attach the WebSocket server to.\n */\n constructor(fastify: FastifyInstance) {\n super(fastify, '/message');\n }\n\n /**\n * Parse stringified message into a {@link ReactNativeMessage}.\n *\n * @param data Stringified message.\n * @param binary Additional binary data if any.\n * @returns Parsed message or `undefined` if parsing failed.\n */\n parseMessage(\n data: string,\n binary: any\n ): Partial<ReactNativeMessage> | undefined {\n if (binary) {\n this.fastify.log.error({\n msg: 'Failed to parse message - expected text message, got binary',\n });\n return undefined;\n }\n try {\n const message = JSON.parse(data) as Partial<ReactNativeMessage>;\n if (\n message.version === WebSocketMessageServer.PROTOCOL_VERSION.toString()\n ) {\n return message;\n }\n this.fastify.log.error({\n msg: 'Received message had wrong protocol version',\n message,\n });\n } catch (e) {\n this.fastify.log.error({\n msg: 'Failed to parse the message as JSON',\n data,\n });\n }\n return undefined;\n }\n\n /**\n * Get client's WebSocket connection for given `clientId`.\n * Throws if no such client is connected.\n *\n * @param clientId Id of the client.\n * @returns WebSocket connection.\n */\n getClientSocket(clientId: string) {\n const socket = this.clients.get(clientId);\n if (socket === undefined) {\n throw new Error(`Could not find client with id \"${clientId}\"`);\n }\n return socket;\n }\n\n /**\n * Process error by sending an error message to the client whose message caused the error\n * to occur.\n *\n * @param clientId Id of the client whose message caused an error.\n * @param message Original message which caused the error.\n * @param error Concrete instance of an error that occurred.\n */\n handleError(\n clientId: string,\n message: Partial<ReactNativeMessage>,\n error: Error\n ) {\n const errorMessage = {\n id: message.id,\n method: message.method,\n target: message.target,\n error: message.error === undefined ? 'undefined' : 'defined',\n params: message.params === undefined ? 'undefined' : 'defined',\n result: message.result === undefined ? 'undefined' : 'defined',\n };\n\n if (message.id === undefined) {\n this.fastify.log.error({\n msg: 'Handling message failed',\n clientId,\n error,\n errorMessage,\n });\n } else {\n try {\n const socket = this.getClientSocket(clientId);\n socket.send(\n JSON.stringify({\n version: WebSocketMessageServer.PROTOCOL_VERSION,\n error,\n id: message.id,\n })\n );\n } catch (error) {\n this.fastify.log.error('Failed to reply', {\n clientId,\n error,\n errorMessage,\n });\n }\n }\n }\n\n /**\n * Send given request `message` to it's designated client's socket based on `message.target`.\n * The target client must be connected, otherwise it will throw an error.\n *\n * @param clientId Id of the client that requested the forward.\n * @param message Message to forward.\n */\n forwardRequest(clientId: string, message: Partial<ReactNativeMessage>) {\n if (!message.target) {\n this.fastify.log.error({\n msg: 'Failed to forward request - message.target is missing',\n clientId,\n message,\n });\n return;\n }\n\n const socket = this.getClientSocket(message.target);\n socket.send(\n JSON.stringify({\n version: WebSocketMessageServer.PROTOCOL_VERSION,\n method: message.method,\n params: message.params,\n id:\n message.id === undefined\n ? undefined\n : { requestId: message.id, clientId },\n })\n );\n }\n\n /**\n * Send given response `message` to it's designated client's socket based\n * on `message.id.clientId`.\n * The target client must be connected, otherwise it will throw an error.\n *\n * @param message Message to forward.\n */\n forwardResponse(message: Partial<ReactNativeMessage>) {\n if (!message.id) {\n return;\n }\n\n const socket = this.getClientSocket(message.id.clientId);\n socket.send(\n JSON.stringify({\n version: WebSocketMessageServer.PROTOCOL_VERSION,\n result: message.result,\n error: message.error,\n id: message.id.requestId,\n })\n );\n }\n\n /**\n * Process request message targeted towards this {@link WebSocketMessageServer}\n * and send back the results.\n *\n * @param clientId Id of the client who send the message.\n * @param message The message to process by the server.\n */\n processServerRequest(clientId: string, message: Partial<ReactNativeMessage>) {\n let result: string | Record<string, Record<string, string>>;\n\n switch (message.method) {\n case 'getid':\n result = clientId;\n break;\n case 'getpeers': {\n const output: Record<string, Record<string, string>> = {};\n this.clients.forEach((peerSocket, peerId) => {\n if (clientId !== peerId) {\n const { searchParams } = new URL(peerSocket.upgradeReq?.url || '');\n output[peerId] = [...searchParams.entries()].reduce(\n (acc, [key, value]) => ({\n ...acc,\n [key]: value,\n }),\n {}\n );\n }\n });\n result = output;\n break;\n }\n default:\n throw new Error(\n `Cannot process server request - unknown method ${JSON.stringify({\n clientId,\n message,\n })}`\n );\n }\n\n const socket = this.getClientSocket(clientId);\n socket.send(\n JSON.stringify({\n version: WebSocketMessageServer.PROTOCOL_VERSION,\n result,\n id: message.id,\n })\n );\n }\n\n /**\n * Broadcast given message to all connected clients.\n *\n * @param broadcasterId Id of the client who is broadcasting.\n * @param message Message to broadcast.\n */\n sendBroadcast(\n broadcasterId: string | undefined,\n message: Partial<ReactNativeMessage>\n ) {\n const forwarded = {\n version: WebSocketMessageServer.PROTOCOL_VERSION,\n method: message.method,\n params: message.params,\n };\n\n if (this.clients.size === 0) {\n this.fastify.log.warn({\n msg:\n 'No apps connected. ' +\n `Sending \"${message.method}\" to all React Native apps failed. ` +\n 'Make sure your app is running in the simulator or on a phone connected via USB.',\n });\n }\n\n for (const [clientId, socket] of this.clients) {\n if (clientId !== broadcasterId) {\n try {\n socket.send(JSON.stringify(forwarded));\n } catch (error) {\n this.fastify.log.error({\n msg: 'Failed to send broadcast',\n clientId,\n error,\n forwarded,\n });\n }\n }\n }\n }\n\n /**\n * Send method broadcast to all connected clients.\n *\n * @param method Method name to broadcast.\n * @param params Method parameters.\n */\n broadcast(method: string, params?: Record<string, any>) {\n this.sendBroadcast(undefined, { method, params });\n }\n\n /**\n * Process new client's WebSocket connection.\n *\n * @param socket Incoming WebSocket connection.\n * @param request Upgrade request for the connection.\n */\n onConnection(socket: WebSocket, request: IncomingMessage) {\n const clientId = `client#${this.nextClientId++}`;\n let client: WebSocketWithUpgradeReq = socket;\n client.upgradeReq = request;\n this.clients.set(clientId, client);\n this.fastify.log.debug({ msg: 'Message client connected', clientId });\n\n const onClose = () => {\n this.fastify.log.debug({ msg: 'Message client disconnected', clientId });\n socket.removeAllListeners();\n this.clients.delete(clientId);\n };\n\n socket.addEventListener('error', onClose);\n socket.addEventListener('close', onClose);\n socket.addEventListener('message', (event) => {\n const message = this.parseMessage(\n event.data.toString(),\n // @ts-ignore\n event.binary\n );\n\n if (!message) {\n this.fastify.log.error({\n msg: 'Received message not matching protocol',\n clientId,\n message,\n });\n return;\n }\n\n try {\n if (WebSocketMessageServer.isBroadcast(message)) {\n this.sendBroadcast(clientId, message);\n } else if (WebSocketMessageServer.isRequest(message)) {\n if (message.target === 'server') {\n this.processServerRequest(clientId, message);\n } else {\n this.forwardRequest(clientId, message);\n }\n } else if (WebSocketMessageServer.isResponse(message)) {\n this.forwardResponse(message);\n } else {\n throw new Error(\n `Invalid message, did not match the protocol ${JSON.stringify({\n clientId,\n message,\n })}`\n );\n }\n } catch (error) {\n this.handleError(clientId, message, error as Error);\n }\n });\n }\n}\n"],"mappings":"AACA,SAASA,GAAT,QAAoB,KAApB;SAGSC,e;AAET;AACA;AACA;;AAqBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAN,SAAqCD,eAArC,CAAqD;EAC1B,OAAhBE,gBAAgB,GAAG,CAAH;EAEhC;AACF;AACA;AACA;AACA;AACA;AACA;;EACoB,OAAXC,WAAW,CAACC,OAAD,EAAuC;IACvD,OACE,OAAOA,OAAO,CAACC,MAAf,KAA0B,QAA1B,IACAD,OAAO,CAACE,EAAR,KAAeC,SADf,IAEAH,OAAO,CAACI,MAAR,KAAmBD,SAHrB;EAKD;EAED;AACF;AACA;AACA;AACA;AACA;;;EACkB,OA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R,OAApC;UACD,CAFD,MAEO;YACL,KAAKmC,cAAL,CAAoB3B,QAApB,EAA8BR,OAA9B;UACD;QACF,CANM,MAMA,IAAIH,sBAAsB,CAACS,UAAvB,CAAkCN,OAAlC,CAAJ,EAAgD;UACrD,KAAKoC,eAAL,CAAqBpC,OAArB;QACD,CAFM,MAEA;UACL,MAAM,IAAI6B,KAAJ,CACH,+CAA8CR,IAAI,CAACa,SAAL,CAAe;YAC5D1B,QAD4D;YAE5DR;UAF4D,CAAf,CAG5C,EAJC,CAAN;QAMD;MACF,CAnBD,CAmBE,OAAOU,KAAP,EAAc;QACd,KAAKoB,WAAL,CAAiBtB,QAAjB,EAA2BR,OAA3B,EAAoCU,KAApC;MACD;IACF,CAtCD;EAuCD;;AAtXyD"}
|
|
1
|
+
{"version":3,"file":"WebSocketMessageServer.js","names":["URL","WebSocketServer","WebSocketMessageServer","PROTOCOL_VERSION","isBroadcast","message","method","id","undefined","target","isRequest","isResponse","requestId","clientId","result","error","clients","Map","nextClientId","constructor","fastify","parseMessage","data","binary","log","msg","JSON","parse","version","toString","e","getClientSocket","socket","get","Error","handleError","errorMessage","params","send","stringify","forwardRequest","forwardResponse","processServerRequest","output","forEach","peerSocket","peerId","searchParams","upgradeReq","url","entries","reduce","acc","key","value","sendBroadcast","broadcasterId","forwarded","size","warn","broadcast","onConnection","request","client","set","debug","onClose","removeAllListeners","delete","addEventListener","event"],"sources":["../../../../src/plugins/wss/servers/WebSocketMessageServer.ts"],"sourcesContent":["import type { IncomingMessage } from 'http';\nimport { URL } from 'url';\nimport type { FastifyInstance } from 'fastify';\nimport WebSocket from 'ws';\nimport { WebSocketServer } from '../WebSocketServer';\n\n/**\n * Holds {@link ReactNativeMessage} `id` data.\n */\nexport interface ReactNativeIdObject {\n requestId: string;\n clientId: string;\n}\n\n/**\n * Message representation used by {@link WebSocketMessageServer}.\n */\nexport interface ReactNativeMessage {\n version?: string;\n id?: ReactNativeIdObject;\n method?: string;\n target: string;\n result?: any;\n error?: Error;\n params?: Record<string, any>;\n}\n\ntype WebSocketWithUpgradeReq = WebSocket & { upgradeReq?: IncomingMessage };\n\n/**\n * Class for creating a WebSocket server and sending messages between development server\n * and the React Native applications.\n *\n * Based on: https://github.com/react-native-community/cli/blob/v4.14.0/packages/cli-server-api/src/websocket/messageSocketServer.ts\n *\n * @category Development server\n */\nexport class WebSocketMessageServer extends WebSocketServer {\n static readonly PROTOCOL_VERSION = 2;\n\n /**\n * Check if message is a broadcast request.\n *\n * @param message Message to check.\n * @returns True if message is a broadcast request and should be broadcasted\n * with {@link sendBroadcast}.\n */\n static isBroadcast(message: Partial<ReactNativeMessage>) {\n return (\n typeof message.method === 'string' &&\n message.id === undefined &&\n message.target === undefined\n );\n }\n\n /**\n * Check if message is a method request.\n *\n * @param message Message to check.\n * @returns True if message is a request.\n */\n static isRequest(message: Partial<ReactNativeMessage>) {\n return (\n typeof message.method === 'string' && typeof message.target === 'string'\n );\n }\n\n /**\n * Check if message is a response with results of performing some request.\n *\n * @param message Message to check.\n * @returns True if message is a response.\n */\n static isResponse(message: Partial<ReactNativeMessage>) {\n return (\n typeof message.id === 'object' &&\n typeof message.id.requestId !== 'undefined' &&\n typeof message.id.clientId === 'string' &&\n (message.result !== undefined || message.error !== undefined)\n );\n }\n\n private clients = new Map<string, WebSocketWithUpgradeReq>();\n private nextClientId = 0;\n\n /**\n * Create new instance of WebSocketMessageServer and attach it to the given Fastify instance.\n * Any logging information, will be passed through standard `fastify.log` API.\n *\n * @param fastify Fastify instance to attach the WebSocket server to.\n */\n constructor(fastify: FastifyInstance) {\n super(fastify, '/message');\n }\n\n /**\n * Parse stringified message into a {@link ReactNativeMessage}.\n *\n * @param data Stringified message.\n * @param binary Additional binary data if any.\n * @returns Parsed message or `undefined` if parsing failed.\n */\n parseMessage(\n data: string,\n binary: any\n ): Partial<ReactNativeMessage> | undefined {\n if (binary) {\n this.fastify.log.error({\n msg: 'Failed to parse message - expected text message, got binary',\n });\n return undefined;\n }\n try {\n const message = JSON.parse(data) as Partial<ReactNativeMessage>;\n if (\n message.version === WebSocketMessageServer.PROTOCOL_VERSION.toString()\n ) {\n return message;\n }\n this.fastify.log.error({\n msg: 'Received message had wrong protocol version',\n message,\n });\n } catch (e) {\n this.fastify.log.error({\n msg: 'Failed to parse the message as JSON',\n data,\n });\n }\n return undefined;\n }\n\n /**\n * Get client's WebSocket connection for given `clientId`.\n * Throws if no such client is connected.\n *\n * @param clientId Id of the client.\n * @returns WebSocket connection.\n */\n getClientSocket(clientId: string) {\n const socket = this.clients.get(clientId);\n if (socket === undefined) {\n throw new Error(`Could not find client with id \"${clientId}\"`);\n }\n return socket;\n }\n\n /**\n * Process error by sending an error message to the client whose message caused the error\n * to occur.\n *\n * @param clientId Id of the client whose message caused an error.\n * @param message Original message which caused the error.\n * @param error Concrete instance of an error that occurred.\n */\n handleError(\n clientId: string,\n message: Partial<ReactNativeMessage>,\n error: Error\n ) {\n const errorMessage = {\n id: message.id,\n method: message.method,\n target: message.target,\n error: message.error === undefined ? 'undefined' : 'defined',\n params: message.params === undefined ? 'undefined' : 'defined',\n result: message.result === undefined ? 'undefined' : 'defined',\n };\n\n if (message.id === undefined) {\n this.fastify.log.error({\n msg: 'Handling message failed',\n clientId,\n error,\n errorMessage,\n });\n } else {\n try {\n const socket = this.getClientSocket(clientId);\n socket.send(\n JSON.stringify({\n version: WebSocketMessageServer.PROTOCOL_VERSION,\n error,\n id: message.id,\n })\n );\n } catch (error) {\n this.fastify.log.error('Failed to reply', {\n clientId,\n error,\n errorMessage,\n });\n }\n }\n }\n\n /**\n * Send given request `message` to it's designated client's socket based on `message.target`.\n * The target client must be connected, otherwise it will throw an error.\n *\n * @param clientId Id of the client that requested the forward.\n * @param message Message to forward.\n */\n forwardRequest(clientId: string, message: Partial<ReactNativeMessage>) {\n if (!message.target) {\n this.fastify.log.error({\n msg: 'Failed to forward request - message.target is missing',\n clientId,\n message,\n });\n return;\n }\n\n const socket = this.getClientSocket(message.target);\n socket.send(\n JSON.stringify({\n version: WebSocketMessageServer.PROTOCOL_VERSION,\n method: message.method,\n params: message.params,\n id:\n message.id === undefined\n ? undefined\n : { requestId: message.id, clientId },\n })\n );\n }\n\n /**\n * Send given response `message` to it's designated client's socket based\n * on `message.id.clientId`.\n * The target client must be connected, otherwise it will throw an error.\n *\n * @param message Message to forward.\n */\n forwardResponse(message: Partial<ReactNativeMessage>) {\n if (!message.id) {\n return;\n }\n\n const socket = this.getClientSocket(message.id.clientId);\n socket.send(\n JSON.stringify({\n version: WebSocketMessageServer.PROTOCOL_VERSION,\n result: message.result,\n error: message.error,\n id: message.id.requestId,\n })\n );\n }\n\n /**\n * Process request message targeted towards this {@link WebSocketMessageServer}\n * and send back the results.\n *\n * @param clientId Id of the client who send the message.\n * @param message The message to process by the server.\n */\n processServerRequest(clientId: string, message: Partial<ReactNativeMessage>) {\n let result: string | Record<string, Record<string, string>>;\n\n switch (message.method) {\n case 'getid':\n result = clientId;\n break;\n case 'getpeers': {\n const output: Record<string, Record<string, string>> = {};\n this.clients.forEach((peerSocket, peerId) => {\n if (clientId !== peerId) {\n const { searchParams } = new URL(peerSocket.upgradeReq?.url || '');\n output[peerId] = [...searchParams.entries()].reduce(\n (acc, [key, value]) => ({\n ...acc,\n [key]: value,\n }),\n {}\n );\n }\n });\n result = output;\n break;\n }\n default:\n throw new Error(\n `Cannot process server request - unknown method ${JSON.stringify({\n clientId,\n message,\n })}`\n );\n }\n\n const socket = this.getClientSocket(clientId);\n socket.send(\n JSON.stringify({\n version: WebSocketMessageServer.PROTOCOL_VERSION,\n result,\n id: message.id,\n })\n );\n }\n\n /**\n * Broadcast given message to all connected clients.\n *\n * @param broadcasterId Id of the client who is broadcasting.\n * @param message Message to broadcast.\n */\n sendBroadcast(\n broadcasterId: string | undefined,\n message: Partial<ReactNativeMessage>\n ) {\n const forwarded = {\n version: WebSocketMessageServer.PROTOCOL_VERSION,\n method: message.method,\n params: message.params,\n };\n\n if (this.clients.size === 0) {\n this.fastify.log.warn({\n msg:\n 'No apps connected. ' +\n `Sending \"${message.method}\" to all React Native apps failed. ` +\n 'Make sure your app is running in the simulator or on a phone connected via USB.',\n });\n }\n\n for (const [clientId, socket] of this.clients) {\n if (clientId !== broadcasterId) {\n try {\n socket.send(JSON.stringify(forwarded));\n } catch (error) {\n this.fastify.log.error({\n msg: 'Failed to send broadcast',\n clientId,\n error,\n forwarded,\n });\n }\n }\n }\n }\n\n /**\n * Send method broadcast to all connected clients.\n *\n * @param method Method name to broadcast.\n * @param params Method parameters.\n */\n broadcast(method: string, params?: Record<string, any>) {\n this.sendBroadcast(undefined, { method, params });\n }\n\n /**\n * Process new client's WebSocket connection.\n *\n * @param socket Incoming WebSocket connection.\n * @param request Upgrade request for the connection.\n */\n onConnection(socket: WebSocket, request: IncomingMessage) {\n const clientId = `client#${this.nextClientId++}`;\n let client: WebSocketWithUpgradeReq = socket;\n client.upgradeReq = request;\n this.clients.set(clientId, client);\n this.fastify.log.debug({ msg: 'Message client connected', clientId });\n\n const onClose = () => {\n this.fastify.log.debug({ msg: 'Message client disconnected', clientId });\n socket.removeAllListeners();\n this.clients.delete(clientId);\n };\n\n socket.addEventListener('error', onClose);\n socket.addEventListener('close', onClose);\n socket.addEventListener('message', (event) => {\n const message = this.parseMessage(\n event.data.toString(),\n // @ts-ignore\n event.binary\n );\n\n if (!message) {\n this.fastify.log.error({\n msg: 'Received message not matching protocol',\n clientId,\n message,\n });\n return;\n }\n\n try {\n if (WebSocketMessageServer.isBroadcast(message)) {\n this.sendBroadcast(clientId, message);\n } else if (WebSocketMessageServer.isRequest(message)) {\n if (message.target === 'server') {\n this.processServerRequest(clientId, message);\n } else {\n this.forwardRequest(clientId, message);\n }\n } else if (WebSocketMessageServer.isResponse(message)) {\n this.forwardResponse(message);\n } else {\n throw new Error(\n `Invalid message, did not match the protocol ${JSON.stringify({\n clientId,\n message,\n })}`\n );\n }\n } catch (error) {\n this.handleError(clientId, message, error as Error);\n }\n });\n }\n}\n"],"mappings":"AACA,SAASA,G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AK,CAAChD,IAAI,CAACO,QAAQ,CAAC,CAAC;MACrB;MACAyC,KAAK,CAAC/C,MACR,CAAC;MAED,IAAI,CAAClB,OAAO,EAAE;QACZ,IAAI,CAACe,OAAO,CAACI,GAAG,CAACT,KAAK,CAAC;UACrBU,GAAG,EAAE,wCAAwC;UAC7CZ,QAAQ;UACRR;QACF,CAAC,CAAC;QACF;MACF;MAEA,IAAI;QACF,IAAIH,sBAAsB,CAACE,WAAW,CAACC,OAAO,CAAC,EAAE;UAC/C,IAAI,CAACkD,aAAa,CAAC1C,QAAQ,EAAER,OAAO,CAAC;QACvC,CAAC,MAAM,IAAIH,sBAAsB,CAACQ,SAAS,CAACL,OAAO,CAAC,EAAE;UACpD,IAAIA,OAAO,CAACI,MAAM,KAAK,QAAQ,EAAE;YAC/B,IAAI,CAACiC,oBAAoB,CAAC7B,QAAQ,EAAER,OAAO,CAAC;UAC9C,CAAC,MAAM;YACL,IAAI,CAACmC,cAAc,CAAC3B,QAAQ,EAAER,OAAO,CAAC;UACxC;QACF,CAAC,MAAM,IAAIH,sBAAsB,CAACS,UAAU,CAACN,OAAO,CAAC,EAAE;UACrD,IAAI,CAACoC,eAAe,CAACpC,OAAO,CAAC;QAC/B,CAAC,MAAM;UACL,MAAM,IAAI6B,KAAK,CACZ,+CAA8CR,IAAI,CAACa,SAAS,CAAC;YAC5D1B,QAAQ;YACRR;UACF,CAAC,CAAE,EACL,CAAC;QACH;MACF,CAAC,CAAC,OAAOU,KAAK,EAAE;QACd,IAAI,CAACoB,WAAW,CAACtB,QAAQ,EAAER,OAAO,EAAEU,KAAc,CAAC;MACrD;IACF,CAAC,CAAC;EACJ;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import type { FastifyInstance } from 'fastify';
|
|
2
2
|
import type { Server } from '../../types';
|
|
3
3
|
import { WebSocketDebuggerServer } from './servers/WebSocketDebuggerServer';
|
|
4
4
|
import { WebSocketDevClientServer } from './servers/WebSocketDevClientServer';
|
|
@@ -22,8 +22,9 @@ declare module 'fastify' {
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
declare
|
|
25
|
+
declare function wssPlugin(instance: FastifyInstance, { options, delegate, }: {
|
|
26
26
|
options: Server.Options;
|
|
27
27
|
delegate: Server.Delegate;
|
|
28
|
-
}
|
|
28
|
+
}): Promise<void>;
|
|
29
|
+
declare const _default: typeof wssPlugin;
|
|
29
30
|
export default _default;
|
|
@@ -7,7 +7,6 @@ import { HermesInspectorProxy } from "./servers/HermesInspectorProxy.js";
|
|
|
7
7
|
import { WebSocketApiServer } from "./servers/WebSocketApiServer.js";
|
|
8
8
|
import { WebSocketHMRServer } from "./servers/WebSocketHMRServer.js";
|
|
9
9
|
import { WebSocketRouter } from "./WebSocketRouter.js";
|
|
10
|
-
|
|
11
10
|
async function wssPlugin(instance, {
|
|
12
11
|
options,
|
|
13
12
|
delegate
|
|
@@ -40,7 +39,6 @@ async function wssPlugin(instance, {
|
|
|
40
39
|
router
|
|
41
40
|
});
|
|
42
41
|
}
|
|
43
|
-
|
|
44
42
|
export default fastifyPlugin(wssPlugin, {
|
|
45
43
|
name: 'wss-plugin'
|
|
46
44
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wssPlugin.js","names":["fastifyPlugin","WebSocketDebuggerServer","WebSocketDevClientServer","WebSocketMessageServer","WebSocketEventsServer","HermesInspectorProxy","WebSocketApiServer","WebSocketHMRServer","WebSocketRouter","wssPlugin","instance","options","delegate","router","debuggerServer","devClientServer","messageServer","eventsServer","webSocketMessageServer","hermesInspectorProxy","apiServer","hmrServer","hmr","registerServer","decorate","name"],"sources":["../../../src/plugins/wss/wssPlugin.ts"],"sourcesContent":["import type { FastifyInstance } from 'fastify';\nimport fastifyPlugin from 'fastify-plugin';\nimport type { Server } from '../../types';\nimport { WebSocketDebuggerServer } from './servers/WebSocketDebuggerServer';\nimport { WebSocketDevClientServer } from './servers/WebSocketDevClientServer';\nimport { WebSocketMessageServer } from './servers/WebSocketMessageServer';\nimport { WebSocketEventsServer } from './servers/WebSocketEventsServer';\nimport { HermesInspectorProxy } from './servers/HermesInspectorProxy';\nimport { WebSocketApiServer } from './servers/WebSocketApiServer';\nimport { WebSocketHMRServer } from './servers/WebSocketHMRServer';\nimport { WebSocketRouter } from './WebSocketRouter';\n\ndeclare module 'fastify' {\n interface FastifyInstance {\n wss: {\n debuggerServer: WebSocketDebuggerServer;\n devClientServer: WebSocketDevClientServer;\n messageServer: WebSocketMessageServer;\n eventsServer: WebSocketEventsServer;\n hermesInspectorProxy: HermesInspectorProxy;\n apiServer: WebSocketApiServer;\n hmrServer: WebSocketHMRServer;\n router: WebSocketRouter;\n };\n }\n}\n\nasync function wssPlugin(\n instance: FastifyInstance,\n {\n options,\n delegate,\n }: {\n options: Server.Options;\n delegate: Server.Delegate;\n }\n) {\n const router = new WebSocketRouter(instance);\n\n const debuggerServer = new WebSocketDebuggerServer(instance);\n const devClientServer = new WebSocketDevClientServer(instance);\n const messageServer = new WebSocketMessageServer(instance);\n const eventsServer = new WebSocketEventsServer(instance, {\n webSocketMessageServer: messageServer,\n });\n const hermesInspectorProxy = new HermesInspectorProxy(instance, options);\n const apiServer = new WebSocketApiServer(instance);\n const hmrServer = new WebSocketHMRServer(instance, delegate.hmr);\n\n router.registerServer(debuggerServer);\n router.registerServer(devClientServer);\n router.registerServer(messageServer);\n router.registerServer(eventsServer);\n router.registerServer(hermesInspectorProxy);\n router.registerServer(apiServer);\n router.registerServer(hmrServer);\n\n instance.decorate('wss', {\n debuggerServer,\n devClientServer,\n messageServer,\n eventsServer,\n hermesInspectorProxy,\n apiServer,\n hmrServer,\n router,\n });\n}\n\nexport default fastifyPlugin(wssPlugin, {\n name: 'wss-plugin',\n});\n"],"mappings":"AACA,OAAOA,
|
|
1
|
+
{"version":3,"file":"wssPlugin.js","names":["fastifyPlugin","WebSocketDebuggerServer","WebSocketDevClientServer","WebSocketMessageServer","WebSocketEventsServer","HermesInspectorProxy","WebSocketApiServer","WebSocketHMRServer","WebSocketRouter","wssPlugin","instance","options","delegate","router","debuggerServer","devClientServer","messageServer","eventsServer","webSocketMessageServer","hermesInspectorProxy","apiServer","hmrServer","hmr","registerServer","decorate","name"],"sources":["../../../src/plugins/wss/wssPlugin.ts"],"sourcesContent":["import type { FastifyInstance } from 'fastify';\nimport fastifyPlugin from 'fastify-plugin';\nimport type { Server } from '../../types';\nimport { WebSocketDebuggerServer } from './servers/WebSocketDebuggerServer';\nimport { WebSocketDevClientServer } from './servers/WebSocketDevClientServer';\nimport { WebSocketMessageServer } from './servers/WebSocketMessageServer';\nimport { WebSocketEventsServer } from './servers/WebSocketEventsServer';\nimport { HermesInspectorProxy } from './servers/HermesInspectorProxy';\nimport { WebSocketApiServer } from './servers/WebSocketApiServer';\nimport { WebSocketHMRServer } from './servers/WebSocketHMRServer';\nimport { WebSocketRouter } from './WebSocketRouter';\n\ndeclare module 'fastify' {\n interface FastifyInstance {\n wss: {\n debuggerServer: WebSocketDebuggerServer;\n devClientServer: WebSocketDevClientServer;\n messageServer: WebSocketMessageServer;\n eventsServer: WebSocketEventsServer;\n hermesInspectorProxy: HermesInspectorProxy;\n apiServer: WebSocketApiServer;\n hmrServer: WebSocketHMRServer;\n router: WebSocketRouter;\n };\n }\n}\n\nasync function wssPlugin(\n instance: FastifyInstance,\n {\n options,\n delegate,\n }: {\n options: Server.Options;\n delegate: Server.Delegate;\n }\n) {\n const router = new WebSocketRouter(instance);\n\n const debuggerServer = new WebSocketDebuggerServer(instance);\n const devClientServer = new WebSocketDevClientServer(instance);\n const messageServer = new WebSocketMessageServer(instance);\n const eventsServer = new WebSocketEventsServer(instance, {\n webSocketMessageServer: messageServer,\n });\n const hermesInspectorProxy = new HermesInspectorProxy(instance, options);\n const apiServer = new WebSocketApiServer(instance);\n const hmrServer = new WebSocketHMRServer(instance, delegate.hmr);\n\n router.registerServer(debuggerServer);\n router.registerServer(devClientServer);\n router.registerServer(messageServer);\n router.registerServer(eventsServer);\n router.registerServer(hermesInspectorProxy);\n router.registerServer(apiServer);\n router.registerServer(hmrServer);\n\n instance.decorate('wss', {\n debuggerServer,\n devClientServer,\n messageServer,\n eventsServer,\n hermesInspectorProxy,\n apiServer,\n hmrServer,\n router,\n });\n}\n\nexport default fastifyPlugin(wssPlugin, {\n name: 'wss-plugin',\n});\n"],"mappings":"AACA,OAAOA,aAAa,MAAM,gBAAgB;AAAC,SAElCC,uBAAuB;AAAA,SACvBC,wBAAwB;AAAA,SACxBC,sBAAsB;AAAA,SACtBC,qBAAqB;AAAA,SACrBC,oBAAoB;AAAA,SACpBC,kBAAkB;AAAA,SAClBC,kBAAkB;AAAA,SAClBC,eAAe;AAiBxB,eAAeC,SAASA,CACtBC,QAAyB,EACzB;EACEC,OAAO;EACPC;AAIF,CAAC,EACD;EACA,MAAMC,MAAM,GAAG,IAAIL,eAAe,CAACE,QAAQ,CAAC;EAE5C,MAAMI,cAAc,GAAG,IAAIb,uBAAuB,CAACS,QAAQ,CAAC;EAC5D,MAAMK,eAAe,GAAG,IAAIb,wBAAwB,CAACQ,QAAQ,CAAC;EAC9D,MAAMM,aAAa,GAAG,IAAIb,sBAAsB,CAACO,QAAQ,CAAC;EAC1D,MAAMO,YAAY,GAAG,IAAIb,qBAAqB,CAACM,QAAQ,EAAE;IACvDQ,sBAAsB,EAAEF;EAC1B,CAAC,CAAC;EACF,MAAMG,oBAAoB,GAAG,IAAId,oBAAoB,CAACK,QAAQ,EAAEC,OAAO,CAAC;EACxE,MAAMS,SAAS,GAAG,IAAId,kBAAkB,CAACI,QAAQ,CAAC;EAClD,MAAMW,SAAS,GAAG,IAAId,kBAAkB,CAACG,QAAQ,EAAEE,QAAQ,CAACU,GAAG,CAAC;EAEhET,MAAM,CAACU,cAAc,CAACT,cAAc,CAAC;EACrCD,MAAM,CAACU,cAAc,CAACR,eAAe,CAAC;EACtCF,MAAM,CAACU,cAAc,CAACP,aAAa,CAAC;EACpCH,MAAM,CAACU,cAAc,CAACN,YAAY,CAAC;EACnCJ,MAAM,CAACU,cAAc,CAACJ,oBAAoB,CAAC;EAC3CN,MAAM,CAACU,cAAc,CAACH,SAAS,CAAC;EAChCP,MAAM,CAACU,cAAc,CAACF,SAAS,CAAC;EAEhCX,QAAQ,CAACc,QAAQ,CAAC,KAAK,EAAE;IACvBV,cAAc;IACdC,eAAe;IACfC,aAAa;IACbC,YAAY;IACZE,oBAAoB;IACpBC,SAAS;IACTC,SAAS;IACTR;EACF,CAAC,CAAC;AACJ;AAEA,eAAeb,aAAa,CAACS,SAAS,EAAE;EACtCgB,IAAI,EAAE;AACR,CAAC,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -143,7 +143,7 @@ export interface ProgressData {
|
|
|
143
143
|
* Used by {@link CompilerDelegate} in `getAsset` function to send the compilation
|
|
144
144
|
* progress to the client who requested the asset.
|
|
145
145
|
*/
|
|
146
|
-
export
|
|
146
|
+
export type SendProgress = (data: ProgressData) => void;
|
|
147
147
|
/**
|
|
148
148
|
* Internal types. Do not use.
|
|
149
149
|
*
|
package/dist/types.js
CHANGED
|
@@ -1,49 +1,24 @@
|
|
|
1
1
|
export let Server;
|
|
2
2
|
/** Representation of the compilation progress. */
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* A complete delegate with implementations for all server functionalities.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* A delegate context used in `delegate` builder in {@link Config}.
|
|
15
|
-
*
|
|
16
|
-
* Allows to emit logs, notify about compilation events and broadcast events to connected clients.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Delegate with implementation for logging functions.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Delegate with implementation for messages used in route handlers.
|
|
25
|
-
*/
|
|
26
|
-
let Api;
|
|
27
|
-
|
|
28
|
-
(function (_Api) {})(Api || (Api = _Server.Api || (_Server.Api = {})));
|
|
29
|
-
})(Server || (Server = {}));
|
|
30
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Type representing a function to send the progress.
|
|
5
|
+
*
|
|
6
|
+
* Used by {@link CompilerDelegate} in `getAsset` function to send the compilation
|
|
7
|
+
* progress to the client who requested the asset.
|
|
8
|
+
*/
|
|
31
9
|
/**
|
|
32
10
|
* Internal types. Do not use.
|
|
33
11
|
*
|
|
34
12
|
* @internal
|
|
35
13
|
*/
|
|
36
14
|
export let Internal;
|
|
37
|
-
|
|
38
15
|
(function (_Internal) {
|
|
39
|
-
let EventTypes
|
|
40
|
-
|
|
41
|
-
(function (EventTypes) {
|
|
16
|
+
let EventTypes = /*#__PURE__*/function (EventTypes) {
|
|
42
17
|
EventTypes["BuildStart"] = "BuildStart";
|
|
43
18
|
EventTypes["BuildEnd"] = "BuildEnd";
|
|
44
19
|
EventTypes["HmrEvent"] = "HmrEvent";
|
|
45
|
-
|
|
46
|
-
|
|
20
|
+
return EventTypes;
|
|
21
|
+
}({});
|
|
47
22
|
_Internal.EventTypes = EventTypes;
|
|
48
23
|
})(Internal || (Internal = {}));
|
|
49
24
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["
|
|
1
|
+
{"version":3,"file":"types.js","names":["Server","Internal","_Internal","EventTypes"],"sources":["../src/types.ts"],"sourcesContent":["import { FastifyLoggerInstance } from 'fastify';\nimport type { CompilerDelegate } from './plugins/compiler';\nimport type { SymbolicatorDelegate } from './plugins/symbolicate';\nimport type { HmrDelegate } from './plugins/wss';\n\nexport type { CompilerDelegate } from './plugins/compiler';\nexport type {\n SymbolicatorDelegate,\n ReactNativeStackFrame,\n InputStackFrame,\n StackFrame,\n CodeFrame,\n SymbolicatorResults,\n} from './plugins/symbolicate';\nexport type { HmrDelegate } from './plugins/wss';\n\nexport namespace Server {\n /** Development server configuration. */\n export interface Config {\n /** Development server options to configure e.g: `port`, `host` etc. */\n options: Options;\n\n /** Function to create a delegate, which implements crucial functionalities. */\n delegate: (context: DelegateContext) => Delegate;\n }\n\n /** Development server options. */\n export interface Options {\n /** Root directory of the project. */\n rootDir: string;\n\n /** Port under which to run the development server. */\n port: number;\n\n /**\n * Hostname or IP address under which to run the development server.\n * When left unspecified, it will listen on all available network interfaces, similarly to listening on '0.0.0.0'.\n */\n host?: string;\n\n /** Options for running the server as HTTPS. If `undefined`, the server will run as HTTP. */\n https?: {\n /** Path to certificate when running server as HTTPS. */\n cert?: string;\n\n /** Path to certificate key when running server as HTTPS. */\n key?: string;\n };\n }\n\n /**\n * A complete delegate with implementations for all server functionalities.\n */\n export interface Delegate {\n /** A compiler delegate. */\n compiler: CompilerDelegate;\n\n /** A symbolicator delegate. */\n symbolicator: SymbolicatorDelegate;\n\n /** A logger delegate. */\n logger: LoggerDelegate;\n\n /** An HMR delegate. */\n hmr: HmrDelegate;\n\n /** An messages delegate. */\n messages: MessagesDelegate;\n\n /** An API delegate. */\n api?: Api.Delegate;\n }\n\n /**\n * A delegate context used in `delegate` builder in {@link Config}.\n *\n * Allows to emit logs, notify about compilation events and broadcast events to connected clients.\n */\n export interface DelegateContext {\n /** A logger instance, useful for emitting logs from the delegate. */\n log: FastifyLoggerInstance;\n\n /** Send notification about compilation start for given `platform`. */\n notifyBuildStart: (platform: string) => void;\n\n /** Send notification about compilation end for given `platform`. */\n notifyBuildEnd: (platform: string) => void;\n\n /**\n * Broadcast arbitrary event to all connected HMR clients for given `platform`.\n *\n * @param event Arbitrary event to broadcast.\n * @param platform Platform of the clients to which broadcast should be sent.\n * @param clientIds Ids of the client to which broadcast should be sent.\n * If `undefined` the broadcast will be sent to all connected clients for the given `platform`.\n */\n broadcastToHmrClients: <E = any>(\n event: E,\n platform: string,\n clientIds?: string[]\n ) => void;\n\n /**\n * Broadcast arbitrary method-like event to all connected message clients.\n *\n * @param event Arbitrary method-like event to broadcast.\n */\n broadcastToMessageClients: <\n E extends { method: string; params?: Record<string, any> },\n >(\n event: E\n ) => void;\n }\n\n /**\n * Delegate with implementation for logging functions.\n */\n export interface LoggerDelegate {\n /**\n * Callback for when a new log is emitted.\n *\n * @param log An object with log data.\n */\n onMessage: (log: any) => void;\n }\n\n /**\n * Delegate with implementation for messages used in route handlers.\n */\n export interface MessagesDelegate {\n /** Get message to send as a reply for `GET /` route. */\n getHello: () => string;\n\n /** Get message to send as a reply for `GET /status` route. */\n getStatus: () => string;\n }\n\n export namespace Api {\n /** A compilation asset representation for API clients. */\n export interface Asset {\n name: string;\n size: number;\n [key: string]: any;\n }\n\n /** A compilation stats representation for API clients. */\n export interface CompilationStats {\n [key: string]: any;\n }\n\n /**\n * Delegate with implementation for API endpoints.\n */\n export interface Delegate {\n /** Get all platforms - either with already existing compilations or all supported platforms. */\n getPlatforms: () => Promise<string[]>;\n\n /**\n * Get all assets from compilation for given platform.\n * Should return `[]` if the compilation does not exists for given platform.\n */\n getAssets: (platform: string) => Promise<Asset[]>;\n\n /**\n * Get compilation stats for a given platform.\n * Should return `null` if the compilation does not exists for given platform.\n */\n getCompilationStats: (\n platform: string\n ) => Promise<CompilationStats | null>;\n }\n }\n}\n\n/** Representation of the compilation progress. */\nexport interface ProgressData {\n /** Number of modules built. */\n completed: number;\n\n /** Total number of modules detect as part of compilation. */\n total: number;\n}\n\n/**\n * Type representing a function to send the progress.\n *\n * Used by {@link CompilerDelegate} in `getAsset` function to send the compilation\n * progress to the client who requested the asset.\n */\nexport type SendProgress = (data: ProgressData) => void;\n\n/**\n * Internal types. Do not use.\n *\n * @internal\n */\nexport namespace Internal {\n export enum EventTypes {\n BuildStart = 'BuildStart',\n BuildEnd = 'BuildEnd',\n HmrEvent = 'HmrEvent',\n }\n}\n"],"mappings":"WAgBiBA,MAAM;AA8JvB;AASA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAJA,WAKiBC,QAAQ;AAAA,WAAAC,SAAA;EAAA,IACXC,UAAU,0BAAVA,UAAU;IAAVA,UAAU;IAAVA,UAAU;IAAVA,UAAU;IAAA,OAAVA,UAAU;EAAA;EAAAD,SAAA,CAAAC,UAAA,GAAAA,UAAA;AAAA,GADPF,QAAQ,KAARA,QAAQ"}
|