@flighthq/socket 0.5.1-next.903.f434bc2 → 0.5.1-next.905.5fbf787
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/package.json +5 -5
- package/src/socket.test.ts +33 -27
package/README.md
CHANGED
|
@@ -13,5 +13,5 @@ Import the supported application-facing API from `@flighthq/socket`. The `@fligh
|
|
|
13
13
|
This package is part of the locked-version Flight SDK graph. Applications may instead install and import `@flighthq/sdk` when package-level tree shaking is sufficient.
|
|
14
14
|
|
|
15
15
|
- [Flight project](https://github.com/flighthq/flight)
|
|
16
|
-
- [Source for @flighthq/socket@0.5.1-next.
|
|
17
|
-
- [License](https://github.com/flighthq/flight/blob/
|
|
16
|
+
- [Source for @flighthq/socket@0.5.1-next.905.5fbf787](https://github.com/flighthq/flight/tree/5fbf7874064c384307542d68b4dcb6a895ff0dcf/packages/socket)
|
|
17
|
+
- [License](https://github.com/flighthq/flight/blob/5fbf7874064c384307542d68b4dcb6a895ff0dcf/LICENSE.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/socket",
|
|
3
|
-
"version": "0.5.1-next.
|
|
3
|
+
"version": "0.5.1-next.905.5fbf787",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@flighthq/entity": "0.5.1-next.
|
|
42
|
-
"@flighthq/log": "0.5.1-next.
|
|
43
|
-
"@flighthq/signals": "0.5.1-next.
|
|
44
|
-
"@flighthq/types": "0.5.1-next.
|
|
41
|
+
"@flighthq/entity": "0.5.1-next.905.5fbf787",
|
|
42
|
+
"@flighthq/log": "0.5.1-next.905.5fbf787",
|
|
43
|
+
"@flighthq/signals": "0.5.1-next.905.5fbf787",
|
|
44
|
+
"@flighthq/types": "0.5.1-next.905.5fbf787"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"typescript": "^5.3.0"
|
package/src/socket.test.ts
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
disposeSocket,
|
|
21
21
|
enableSocketSignals,
|
|
22
22
|
getSocketReadyState,
|
|
23
|
+
initializeWebSocketBackend,
|
|
23
24
|
sendSocketMessage,
|
|
24
25
|
setSocketGuard,
|
|
25
26
|
} from './socket';
|
|
@@ -393,6 +394,12 @@ describe('getSocketReadyState', () => {
|
|
|
393
394
|
});
|
|
394
395
|
});
|
|
395
396
|
|
|
397
|
+
describe('initializeWebSocketBackend', () => {
|
|
398
|
+
it('is the construction initializer of createWebSocketBackend', () => {
|
|
399
|
+
expect(typeof initializeWebSocketBackend).toBe('function');
|
|
400
|
+
});
|
|
401
|
+
});
|
|
402
|
+
|
|
396
403
|
describe('openTcpSocket', () => {
|
|
397
404
|
it('forwards the endpoint unchanged and returns the backend connection by identity', () => {
|
|
398
405
|
const expected = tcpConnection();
|
|
@@ -482,33 +489,6 @@ describe('sendSocketMessage', () => {
|
|
|
482
489
|
});
|
|
483
490
|
});
|
|
484
491
|
|
|
485
|
-
describe('setSocketGuard', () => {
|
|
486
|
-
it('installs and removes the core notice hook', () => {
|
|
487
|
-
const notices: string[] = [];
|
|
488
|
-
setSocketGuard((notice) => notices.push(`${notice.operation}:${notice.reason}`));
|
|
489
|
-
const unsupported = fakeBackend();
|
|
490
|
-
unsupported.openReturnsNull = true;
|
|
491
|
-
const host = hostOf(unsupported.backend);
|
|
492
|
-
createSocket(host, { url: 'tcp://x' });
|
|
493
|
-
|
|
494
|
-
const supported = fakeBackend();
|
|
495
|
-
const socket = createSocket(hostOf(supported.backend), { url: 'ws://x' });
|
|
496
|
-
disposeSocket(socket);
|
|
497
|
-
closeSocket(socket);
|
|
498
|
-
sendSocketMessage(socket, 'x');
|
|
499
|
-
enableSocketSignals(socket);
|
|
500
|
-
setSocketGuard(null);
|
|
501
|
-
closeSocket(socket);
|
|
502
|
-
|
|
503
|
-
expect(notices).toEqual([
|
|
504
|
-
'createSocket:no-connection',
|
|
505
|
-
'closeSocket:disposed',
|
|
506
|
-
'sendSocketMessage:disposed',
|
|
507
|
-
'enableSocketSignals:disposed',
|
|
508
|
-
]);
|
|
509
|
-
});
|
|
510
|
-
});
|
|
511
|
-
|
|
512
492
|
function noopSink(): SocketEventSink {
|
|
513
493
|
return {
|
|
514
494
|
handleSocketOpen() {},
|
|
@@ -565,3 +545,29 @@ function installFakeWebSocket(): () => void {
|
|
|
565
545
|
(globalThis as { WebSocket?: unknown }).WebSocket = original;
|
|
566
546
|
};
|
|
567
547
|
}
|
|
548
|
+
describe('setSocketGuard', () => {
|
|
549
|
+
it('installs and removes the core notice hook', () => {
|
|
550
|
+
const notices: string[] = [];
|
|
551
|
+
setSocketGuard((notice) => notices.push(`${notice.operation}:${notice.reason}`));
|
|
552
|
+
const unsupported = fakeBackend();
|
|
553
|
+
unsupported.openReturnsNull = true;
|
|
554
|
+
const host = hostOf(unsupported.backend);
|
|
555
|
+
createSocket(host, { url: 'tcp://x' });
|
|
556
|
+
|
|
557
|
+
const supported = fakeBackend();
|
|
558
|
+
const socket = createSocket(hostOf(supported.backend), { url: 'ws://x' });
|
|
559
|
+
disposeSocket(socket);
|
|
560
|
+
closeSocket(socket);
|
|
561
|
+
sendSocketMessage(socket, 'x');
|
|
562
|
+
enableSocketSignals(socket);
|
|
563
|
+
setSocketGuard(null);
|
|
564
|
+
closeSocket(socket);
|
|
565
|
+
|
|
566
|
+
expect(notices).toEqual([
|
|
567
|
+
'createSocket:no-connection',
|
|
568
|
+
'closeSocket:disposed',
|
|
569
|
+
'sendSocketMessage:disposed',
|
|
570
|
+
'enableSocketSignals:disposed',
|
|
571
|
+
]);
|
|
572
|
+
});
|
|
573
|
+
});
|