@tsed/socketio 7.0.0-alpha.2 → 7.0.0-beta.11
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/.mocharc.js +2 -2
- package/.nycrc +1 -0
- package/lib/{SocketIOModule.js → cjs/SocketIOModule.js} +28 -24
- package/lib/cjs/SocketIOModule.js.map +1 -0
- package/lib/{class → cjs/class}/SocketHandlersBuilder.js +18 -15
- package/lib/cjs/class/SocketHandlersBuilder.js.map +1 -0
- package/lib/{class → cjs/class}/SocketProviderMetadata.js +0 -0
- package/lib/cjs/class/SocketProviderMetadata.js.map +1 -0
- package/lib/{constants/index.js → cjs/constants/constants.js} +1 -1
- package/lib/cjs/constants/constants.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/args.js +1 -1
- package/lib/cjs/decorators/args.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/broadcast.js +1 -1
- package/lib/cjs/decorators/broadcast.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/broadcastOthers.js +1 -1
- package/lib/cjs/decorators/broadcastOthers.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/emit.js +1 -1
- package/lib/cjs/decorators/emit.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/input.js +0 -0
- package/lib/cjs/decorators/input.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/inputAndBroadcast.js +2 -2
- package/lib/cjs/decorators/inputAndBroadcast.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/inputAndBroadcastOthers.js +2 -2
- package/lib/cjs/decorators/inputAndBroadcastOthers.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/inputAndEmit.js +2 -2
- package/lib/cjs/decorators/inputAndEmit.js.map +1 -0
- package/lib/cjs/decorators/io.js +13 -0
- package/lib/cjs/decorators/io.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/nsp.js +2 -2
- package/lib/cjs/decorators/nsp.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/socket.js +1 -1
- package/lib/cjs/decorators/socket.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/socketErr.js +1 -1
- package/lib/cjs/decorators/socketErr.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/socketEventName.js +1 -1
- package/lib/cjs/decorators/socketEventName.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/socketFilter.js +0 -0
- package/lib/cjs/decorators/socketFilter.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/socketMiddleware.js +4 -4
- package/lib/cjs/decorators/socketMiddleware.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/socketMiddlewareError.js +2 -2
- package/lib/cjs/decorators/socketMiddlewareError.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/socketReturns.js +0 -0
- package/lib/cjs/decorators/socketReturns.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/socketService.js +2 -2
- package/lib/cjs/decorators/socketService.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/socketSession.js +1 -1
- package/lib/cjs/decorators/socketSession.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/socketUseAfter.js +0 -0
- package/lib/cjs/decorators/socketUseAfter.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/socketUseBefore.js +0 -0
- package/lib/cjs/decorators/socketUseBefore.js.map +1 -0
- package/lib/{index.js → cjs/index.js} +21 -10
- package/lib/cjs/index.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/OnNamespaceInit.js +0 -0
- package/lib/cjs/interfaces/OnNamespaceInit.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/SocketFilters.js +0 -0
- package/lib/cjs/interfaces/SocketFilters.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/SocketHandlerMetadata.js +0 -0
- package/lib/cjs/interfaces/SocketHandlerMetadata.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/SocketInjectableNsp.js +0 -0
- package/lib/cjs/interfaces/SocketInjectableNsp.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/SocketParamMetadata.js +0 -0
- package/lib/cjs/interfaces/SocketParamMetadata.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/SocketProviderTypes.js +0 -0
- package/lib/cjs/interfaces/SocketProviderTypes.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/SocketReturnsTypes.js +0 -0
- package/lib/cjs/interfaces/SocketReturnsTypes.js.map +1 -0
- package/lib/cjs/interfaces/interfaces.js +3 -0
- package/lib/cjs/interfaces/interfaces.js.map +1 -0
- package/lib/cjs/package.json +3 -0
- package/lib/{registries → cjs/registries}/NspSessionRegistry.js +0 -0
- package/lib/cjs/registries/NspSessionRegistry.js.map +1 -0
- package/lib/{services → cjs/services}/SocketIOServer.js +2 -2
- package/lib/cjs/services/SocketIOServer.js.map +1 -0
- package/lib/{services → cjs/services}/SocketIOService.js +1 -1
- package/lib/cjs/services/SocketIOService.js.map +1 -0
- package/lib/esm/SocketIOModule.js +109 -0
- package/lib/esm/SocketIOModule.js.map +1 -0
- package/lib/esm/class/SocketHandlersBuilder.js +207 -0
- package/lib/esm/class/SocketHandlersBuilder.js.map +1 -0
- package/lib/esm/class/SocketProviderMetadata.js +44 -0
- package/lib/esm/class/SocketProviderMetadata.js.map +1 -0
- package/lib/esm/constants/constants.js +2 -0
- package/lib/esm/constants/constants.js.map +1 -0
- package/lib/esm/decorators/args.js +57 -0
- package/lib/esm/decorators/args.js.map +1 -0
- package/lib/esm/decorators/broadcast.js +28 -0
- package/lib/esm/decorators/broadcast.js.map +1 -0
- package/lib/esm/decorators/broadcastOthers.js +28 -0
- package/lib/esm/decorators/broadcastOthers.js.map +1 -0
- package/lib/esm/decorators/emit.js +28 -0
- package/lib/esm/decorators/emit.js.map +1 -0
- package/lib/esm/decorators/input.js +33 -0
- package/lib/esm/decorators/input.js.map +1 -0
- package/lib/esm/decorators/inputAndBroadcast.js +28 -0
- package/lib/esm/decorators/inputAndBroadcast.js.map +1 -0
- package/lib/esm/decorators/inputAndBroadcastOthers.js +28 -0
- package/lib/esm/decorators/inputAndBroadcastOthers.js.map +1 -0
- package/lib/esm/decorators/inputAndEmit.js +28 -0
- package/lib/esm/decorators/inputAndEmit.js.map +1 -0
- package/lib/esm/decorators/io.js +9 -0
- package/lib/esm/decorators/io.js.map +1 -0
- package/lib/esm/decorators/nsp.js +83 -0
- package/lib/esm/decorators/nsp.js.map +1 -0
- package/lib/esm/decorators/socket.js +28 -0
- package/lib/esm/decorators/socket.js.map +1 -0
- package/lib/esm/decorators/socketErr.js +26 -0
- package/lib/esm/decorators/socketErr.js.map +1 -0
- package/lib/esm/decorators/socketEventName.js +26 -0
- package/lib/esm/decorators/socketEventName.js.map +1 -0
- package/lib/esm/decorators/socketFilter.js +25 -0
- package/lib/esm/decorators/socketFilter.js.map +1 -0
- package/lib/esm/decorators/socketMiddleware.js +70 -0
- package/lib/esm/decorators/socketMiddleware.js.map +1 -0
- package/lib/esm/decorators/socketMiddlewareError.js +67 -0
- package/lib/esm/decorators/socketMiddlewareError.js.map +1 -0
- package/lib/esm/decorators/socketReturns.js +23 -0
- package/lib/esm/decorators/socketReturns.js.map +1 -0
- package/lib/esm/decorators/socketService.js +20 -0
- package/lib/esm/decorators/socketService.js.map +1 -0
- package/lib/esm/decorators/socketSession.js +27 -0
- package/lib/esm/decorators/socketSession.js.map +1 -0
- package/lib/esm/decorators/socketUseAfter.js +70 -0
- package/lib/esm/decorators/socketUseAfter.js.map +1 -0
- package/lib/esm/decorators/socketUseBefore.js +74 -0
- package/lib/esm/decorators/socketUseBefore.js.map +1 -0
- package/lib/esm/index.js +40 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/interfaces/OnNamespaceInit.js +2 -0
- package/lib/esm/interfaces/OnNamespaceInit.js.map +1 -0
- package/lib/esm/interfaces/SocketFilters.js +13 -0
- package/lib/esm/interfaces/SocketFilters.js.map +1 -0
- package/lib/esm/interfaces/SocketHandlerMetadata.js +2 -0
- package/lib/esm/interfaces/SocketHandlerMetadata.js.map +1 -0
- package/lib/esm/interfaces/SocketInjectableNsp.js +2 -0
- package/lib/esm/interfaces/SocketInjectableNsp.js.map +1 -0
- package/lib/esm/interfaces/SocketParamMetadata.js +2 -0
- package/lib/esm/interfaces/SocketParamMetadata.js.map +1 -0
- package/lib/esm/interfaces/SocketProviderTypes.js +9 -0
- package/lib/esm/interfaces/SocketProviderTypes.js.map +1 -0
- package/lib/esm/interfaces/SocketReturnsTypes.js +10 -0
- package/lib/esm/interfaces/SocketReturnsTypes.js.map +1 -0
- package/lib/esm/interfaces/interfaces.js +2 -0
- package/lib/esm/interfaces/interfaces.js.map +1 -0
- package/lib/esm/package.json +3 -0
- package/lib/esm/registries/NspSessionRegistry.js +12 -0
- package/lib/esm/registries/NspSessionRegistry.js.map +1 -0
- package/lib/esm/services/SocketIOServer.js +12 -0
- package/lib/esm/services/SocketIOServer.js.map +1 -0
- package/lib/esm/services/SocketIOService.js +63 -0
- package/lib/esm/services/SocketIOService.js.map +1 -0
- package/lib/types/SocketIOModule.d.ts +28 -0
- package/lib/{class → types/class}/SocketHandlersBuilder.d.ts +2 -2
- package/lib/{class → types/class}/SocketProviderMetadata.d.ts +2 -1
- package/lib/{constants/index.d.ts → types/constants/constants.d.ts} +0 -0
- package/lib/{decorators → types/decorators}/args.d.ts +0 -0
- package/lib/{decorators → types/decorators}/broadcast.d.ts +0 -0
- package/lib/{decorators → types/decorators}/broadcastOthers.d.ts +0 -0
- package/lib/{decorators → types/decorators}/emit.d.ts +0 -0
- package/lib/{decorators → types/decorators}/input.d.ts +0 -0
- package/lib/{decorators → types/decorators}/inputAndBroadcast.d.ts +0 -0
- package/lib/{decorators → types/decorators}/inputAndBroadcastOthers.d.ts +0 -0
- package/lib/{decorators → types/decorators}/inputAndEmit.d.ts +0 -0
- package/lib/{decorators → types/decorators}/io.d.ts +1 -0
- package/lib/{decorators → types/decorators}/nsp.d.ts +0 -0
- package/lib/{decorators → types/decorators}/socket.d.ts +0 -0
- package/lib/{decorators → types/decorators}/socketErr.d.ts +0 -0
- package/lib/{decorators → types/decorators}/socketEventName.d.ts +0 -0
- package/lib/{decorators → types/decorators}/socketFilter.d.ts +0 -0
- package/lib/{decorators → types/decorators}/socketMiddleware.d.ts +0 -0
- package/lib/{decorators → types/decorators}/socketMiddlewareError.d.ts +0 -0
- package/lib/{decorators → types/decorators}/socketReturns.d.ts +0 -0
- package/lib/{decorators → types/decorators}/socketService.d.ts +0 -0
- package/lib/{decorators → types/decorators}/socketSession.d.ts +0 -0
- package/lib/{decorators → types/decorators}/socketUseAfter.d.ts +0 -0
- package/lib/{decorators → types/decorators}/socketUseBefore.d.ts +0 -0
- package/lib/{index.d.ts → types/index.d.ts} +21 -7
- package/lib/{interfaces → types/interfaces}/OnNamespaceInit.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/SocketFilters.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/SocketHandlerMetadata.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/SocketInjectableNsp.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/SocketParamMetadata.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/SocketProviderTypes.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/SocketReturnsTypes.d.ts +0 -0
- package/lib/types/interfaces/interfaces.d.ts +8 -0
- package/lib/{registries → types/registries}/NspSessionRegistry.d.ts +0 -0
- package/lib/{services → types/services}/SocketIOServer.d.ts +0 -0
- package/lib/{services → types/services}/SocketIOService.d.ts +0 -0
- package/package.json +46 -26
- package/readme.md +80 -96
- package/tsconfig.compile.esm.json +12 -0
- package/lib/SocketIOModule.d.ts +0 -29
- package/lib/SocketIOModule.js.map +0 -1
- package/lib/class/SocketHandlersBuilder.js.map +0 -1
- package/lib/class/SocketProviderMetadata.js.map +0 -1
- package/lib/constants/index.js.map +0 -1
- package/lib/decorators/args.js.map +0 -1
- package/lib/decorators/broadcast.js.map +0 -1
- package/lib/decorators/broadcastOthers.js.map +0 -1
- package/lib/decorators/emit.js.map +0 -1
- package/lib/decorators/input.js.map +0 -1
- package/lib/decorators/inputAndBroadcast.js.map +0 -1
- package/lib/decorators/inputAndBroadcastOthers.js.map +0 -1
- package/lib/decorators/inputAndEmit.js.map +0 -1
- package/lib/decorators/io.js +0 -27
- package/lib/decorators/io.js.map +0 -1
- package/lib/decorators/nsp.js.map +0 -1
- package/lib/decorators/socket.js.map +0 -1
- package/lib/decorators/socketErr.js.map +0 -1
- package/lib/decorators/socketEventName.js.map +0 -1
- package/lib/decorators/socketFilter.js.map +0 -1
- package/lib/decorators/socketMiddleware.js.map +0 -1
- package/lib/decorators/socketMiddlewareError.js.map +0 -1
- package/lib/decorators/socketReturns.js.map +0 -1
- package/lib/decorators/socketService.js.map +0 -1
- package/lib/decorators/socketSession.js.map +0 -1
- package/lib/decorators/socketUseAfter.js.map +0 -1
- package/lib/decorators/socketUseBefore.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/interfaces/OnNamespaceInit.js.map +0 -1
- package/lib/interfaces/SocketFilters.js.map +0 -1
- package/lib/interfaces/SocketHandlerMetadata.js.map +0 -1
- package/lib/interfaces/SocketInjectableNsp.js.map +0 -1
- package/lib/interfaces/SocketParamMetadata.js.map +0 -1
- package/lib/interfaces/SocketProviderTypes.js.map +0 -1
- package/lib/interfaces/SocketReturnsTypes.js.map +0 -1
- package/lib/interfaces/index.d.ts +0 -15
- package/lib/interfaces/index.js +0 -11
- package/lib/interfaces/index.js.map +0 -1
- package/lib/registries/NspSessionRegistry.js.map +0 -1
- package/lib/services/SocketIOServer.js.map +0 -1
- package/lib/services/SocketIOService.js.map +0 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { __decorate, __metadata, __param } from "tslib";
|
|
2
|
+
import { InjectorService, Service } from "@tsed/common";
|
|
3
|
+
import SocketIO from "socket.io"; // tslint:disable-line: no-unused-variable
|
|
4
|
+
import { SocketHandlersBuilder } from "../class/SocketHandlersBuilder.js";
|
|
5
|
+
import { SocketProviderMetadata } from "../class/SocketProviderMetadata.js";
|
|
6
|
+
import { IO } from "../decorators/io.js";
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
let SocketIOService = class SocketIOService {
|
|
11
|
+
constructor(injector, io) {
|
|
12
|
+
this.injector = injector;
|
|
13
|
+
this.io = io;
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @type {Map<any, any>}
|
|
17
|
+
*/
|
|
18
|
+
this.namespaces = new Map();
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @param {string} namespace
|
|
23
|
+
* @returns {SocketIO.Namespace}
|
|
24
|
+
*/
|
|
25
|
+
getNsp(namespace = "/") {
|
|
26
|
+
if (!this.namespaces.has(namespace)) {
|
|
27
|
+
const conf = { nsp: this.io.of(namespace), instances: [] };
|
|
28
|
+
this.namespaces.set(namespace, conf);
|
|
29
|
+
conf.nsp.on("connection", (socket) => {
|
|
30
|
+
conf.instances.forEach((builder) => {
|
|
31
|
+
builder.onConnection(socket, conf.nsp);
|
|
32
|
+
});
|
|
33
|
+
socket.on("disconnect", () => {
|
|
34
|
+
conf.instances.forEach((builder) => {
|
|
35
|
+
builder.onDisconnect(socket, conf.nsp);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return this.namespaces.get(namespace);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* @param {Provider<any>} provider
|
|
45
|
+
*/
|
|
46
|
+
addSocketProvider(provider) {
|
|
47
|
+
const wsConfig = new SocketProviderMetadata(provider.store.get("socketIO"));
|
|
48
|
+
const nspConfig = this.getNsp(wsConfig.namespace);
|
|
49
|
+
const nsps = new Map();
|
|
50
|
+
this.namespaces.forEach((value, nsp) => {
|
|
51
|
+
nsps.set(nsp, value.nsp);
|
|
52
|
+
});
|
|
53
|
+
const builder = new SocketHandlersBuilder(provider, this.injector).build(nsps);
|
|
54
|
+
nspConfig.instances.push(builder);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
SocketIOService = __decorate([
|
|
58
|
+
Service(),
|
|
59
|
+
__param(1, IO),
|
|
60
|
+
__metadata("design:paramtypes", [InjectorService, SocketIO.Server])
|
|
61
|
+
], SocketIOService);
|
|
62
|
+
export { SocketIOService };
|
|
63
|
+
//# sourceMappingURL=SocketIOService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SocketIOService.js","sourceRoot":"","sources":["../../../src/services/SocketIOService.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,eAAe,EAAY,OAAO,EAAC,MAAM,cAAc,CAAC;AAChE,OAAO,QAAQ,MAAM,WAAW,CAAC,CAAC,0CAA0C;AAC5E,OAAO,EAAC,qBAAqB,EAAC,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAC,sBAAsB,EAAC,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAC,EAAE,EAAC,MAAM,kBAAkB,CAAC;AAEpC;;GAEG;AAEH,IAAa,eAAe,GAA5B,MAAa,eAAe;IAO1B,YAAoB,QAAyB,EAAc,EAAmB;QAA1D,aAAQ,GAAR,QAAQ,CAAiB;QAAc,OAAE,GAAF,EAAE,CAAiB;QAN9E;;;WAGG;QACK,eAAU,GAA2D,IAAI,GAAG,EAAE,CAAC;IAEN,CAAC;IAElF;;;;OAIG;IACI,MAAM,CAAC,YAAoB,GAAG;QACnC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YACnC,MAAM,IAAI,GAAG,EAAC,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,EAAE,EAAC,CAAC;YAEzD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YAErC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,YAAY,EAAE,CAAC,MAAM,EAAE,EAAE;gBACnC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,OAA8B,EAAE,EAAE;oBACxD,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;gBACzC,CAAC,CAAC,CAAC;gBAEH,MAAM,CAAC,EAAE,CAAC,YAAY,EAAE,GAAG,EAAE;oBAC3B,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,OAA8B,EAAE,EAAE;wBACxD,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;oBACzC,CAAC,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;SACJ;QAED,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAE,CAAC;IACzC,CAAC;IAED;;;OAGG;IACI,iBAAiB,CAAC,QAAuB;QAC9C,MAAM,QAAQ,GAA2B,IAAI,sBAAsB,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;QAEpG,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAClD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;QAEvB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YACrC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,IAAI,qBAAqB,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAE/E,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;CACF,CAAA;AAtDY,eAAe;IAD3B,OAAO,EAAE;IAQwC,WAAA,EAAE,CAAA;qCAApB,eAAe,EAAkB,QAAQ,CAAC,MAAM;GAPnE,eAAe,CAsD3B;SAtDY,eAAe","sourcesContent":["import {InjectorService, Provider, Service} from \"@tsed/common\";\nimport SocketIO from \"socket.io\"; // tslint:disable-line: no-unused-variable\nimport {SocketHandlersBuilder} from \"../class/SocketHandlersBuilder\";\nimport {SocketProviderMetadata} from \"../class/SocketProviderMetadata\";\nimport {IO} from \"../decorators/io\";\n\n/**\n *\n */\n@Service()\nexport class SocketIOService {\n /**\n *\n * @type {Map<any, any>}\n */\n private namespaces: Map<string, {nsp: SocketIO.Namespace; instances: any}> = new Map();\n\n constructor(private injector: InjectorService, @IO private io: SocketIO.Server) {}\n\n /**\n *\n * @param {string} namespace\n * @returns {SocketIO.Namespace}\n */\n public getNsp(namespace: string = \"/\"): {nsp: SocketIO.Namespace; instances: any[]} {\n if (!this.namespaces.has(namespace)) {\n const conf = {nsp: this.io.of(namespace), instances: []};\n\n this.namespaces.set(namespace, conf);\n\n conf.nsp.on(\"connection\", (socket) => {\n conf.instances.forEach((builder: SocketHandlersBuilder) => {\n builder.onConnection(socket, conf.nsp);\n });\n\n socket.on(\"disconnect\", () => {\n conf.instances.forEach((builder: SocketHandlersBuilder) => {\n builder.onDisconnect(socket, conf.nsp);\n });\n });\n });\n }\n\n return this.namespaces.get(namespace)!;\n }\n\n /**\n *\n * @param {Provider<any>} provider\n */\n public addSocketProvider(provider: Provider<any>) {\n const wsConfig: SocketProviderMetadata = new SocketProviderMetadata(provider.store.get(\"socketIO\"));\n\n const nspConfig = this.getNsp(wsConfig.namespace);\n const nsps = new Map();\n\n this.namespaces.forEach((value, nsp) => {\n nsps.set(nsp, value.nsp);\n });\n\n const builder = new SocketHandlersBuilder(provider, this.injector).build(nsps);\n\n nspConfig.instances.push(builder);\n }\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { AfterListen, InjectorService, OnDestroy, Provider } from "@tsed/common";
|
|
3
|
+
import { ServerOptions } from "socket.io";
|
|
4
|
+
import Http from "http";
|
|
5
|
+
import Https from "https";
|
|
6
|
+
/**
|
|
7
|
+
* @ignore
|
|
8
|
+
*/
|
|
9
|
+
export declare class SocketIOModule implements AfterListen, OnDestroy {
|
|
10
|
+
protected disableRoutesSummary: boolean;
|
|
11
|
+
protected settings: Partial<ServerOptions>;
|
|
12
|
+
protected injector: InjectorService;
|
|
13
|
+
protected httpServer: Http.Server | null;
|
|
14
|
+
protected httpsServer: Https.Server | null;
|
|
15
|
+
private io;
|
|
16
|
+
private socketIOService;
|
|
17
|
+
$afterListen(): Promise<void>;
|
|
18
|
+
$onDestroy(): any;
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @returns {Provider<any>[]}
|
|
22
|
+
*/
|
|
23
|
+
protected getWebsocketServices(): Provider<any>[];
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
*/
|
|
27
|
+
protected printSocketEvents(): void;
|
|
28
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InjectorService, Provider } from "@tsed/
|
|
1
|
+
import { InjectorService, Provider } from "@tsed/di";
|
|
2
2
|
import { Namespace, Socket } from "socket.io";
|
|
3
3
|
/**
|
|
4
4
|
* @ignore
|
|
@@ -7,7 +7,7 @@ export declare class SocketHandlersBuilder {
|
|
|
7
7
|
private provider;
|
|
8
8
|
private injector;
|
|
9
9
|
private socketProviderMetadata;
|
|
10
|
-
constructor(provider: Provider
|
|
10
|
+
constructor(provider: Provider, injector: InjectorService);
|
|
11
11
|
/**
|
|
12
12
|
*
|
|
13
13
|
* @param {SocketHandlerMetadata} handlerMetadata
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { SocketHandlerMetadata
|
|
1
|
+
import { SocketHandlerMetadata } from "../interfaces/SocketHandlerMetadata";
|
|
2
|
+
import { SocketInjectableNsp } from "../interfaces/SocketInjectableNsp";
|
|
2
3
|
import { SocketProviderTypes } from "../interfaces/SocketProviderTypes";
|
|
3
4
|
export declare class SocketProviderMetadata {
|
|
4
5
|
type: SocketProviderTypes;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,25 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Automatically generated by barrelsby.
|
|
3
|
+
*/
|
|
1
4
|
export * from "./SocketIOModule";
|
|
2
|
-
export * from "./
|
|
5
|
+
export * from "./class/SocketHandlersBuilder";
|
|
3
6
|
export * from "./class/SocketProviderMetadata";
|
|
4
|
-
export * from "./
|
|
7
|
+
export * from "./constants/constants";
|
|
5
8
|
export * from "./decorators/args";
|
|
6
|
-
export * from "./decorators/io";
|
|
7
|
-
export * from "./decorators/nsp";
|
|
8
|
-
export * from "./decorators/emit";
|
|
9
9
|
export * from "./decorators/broadcast";
|
|
10
10
|
export * from "./decorators/broadcastOthers";
|
|
11
|
-
export * from "./decorators/
|
|
11
|
+
export * from "./decorators/emit";
|
|
12
|
+
export * from "./decorators/input";
|
|
12
13
|
export * from "./decorators/inputAndBroadcast";
|
|
13
14
|
export * from "./decorators/inputAndBroadcastOthers";
|
|
15
|
+
export * from "./decorators/inputAndEmit";
|
|
16
|
+
export * from "./decorators/io";
|
|
17
|
+
export * from "./decorators/nsp";
|
|
14
18
|
export * from "./decorators/socket";
|
|
15
19
|
export * from "./decorators/socketErr";
|
|
20
|
+
export * from "./decorators/socketEventName";
|
|
16
21
|
export * from "./decorators/socketFilter";
|
|
17
22
|
export * from "./decorators/socketMiddleware";
|
|
18
23
|
export * from "./decorators/socketMiddlewareError";
|
|
24
|
+
export * from "./decorators/socketReturns";
|
|
19
25
|
export * from "./decorators/socketService";
|
|
20
26
|
export * from "./decorators/socketSession";
|
|
21
27
|
export * from "./decorators/socketUseAfter";
|
|
22
28
|
export * from "./decorators/socketUseBefore";
|
|
23
|
-
export * from "./
|
|
29
|
+
export * from "./interfaces/OnNamespaceInit";
|
|
30
|
+
export * from "./interfaces/SocketFilters";
|
|
31
|
+
export * from "./interfaces/SocketHandlerMetadata";
|
|
32
|
+
export * from "./interfaces/SocketInjectableNsp";
|
|
33
|
+
export * from "./interfaces/SocketParamMetadata";
|
|
34
|
+
export * from "./interfaces/SocketProviderTypes";
|
|
35
|
+
export * from "./interfaces/SocketReturnsTypes";
|
|
36
|
+
export * from "./interfaces/interfaces";
|
|
37
|
+
export * from "./registries/NspSessionRegistry";
|
|
24
38
|
export * from "./services/SocketIOServer";
|
|
25
39
|
export * from "./services/SocketIOService";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/socketio",
|
|
3
|
-
"version": "7.0.0-
|
|
3
|
+
"version": "7.0.0-beta.11",
|
|
4
4
|
"description": "Socket.io package for Ts.ED framework",
|
|
5
|
-
"source": "./src/index.ts",
|
|
6
|
-
"main": "./lib/index.js",
|
|
7
|
-
"typings": "./lib/index.d.ts",
|
|
8
5
|
"private": false,
|
|
9
6
|
"keywords": [
|
|
10
7
|
"tsed",
|
|
@@ -13,43 +10,66 @@
|
|
|
13
10
|
"server",
|
|
14
11
|
"realtime"
|
|
15
12
|
],
|
|
13
|
+
"source": "./src/index.ts",
|
|
14
|
+
"main": "./lib/cjs/index.js",
|
|
15
|
+
"module": "./lib/esm/index.js",
|
|
16
|
+
"typings": "./lib/types/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
"types": "./lib/types/index.d.ts",
|
|
19
|
+
"import": "./lib/esm/index.js",
|
|
20
|
+
"require": "./lib/cjs/index.js",
|
|
21
|
+
"default": "./lib/esm/index.js"
|
|
22
|
+
},
|
|
16
23
|
"scripts": {
|
|
17
|
-
"build": "
|
|
24
|
+
"build": "yarn barrels && yarn run build:esm && yarn run build:cjs",
|
|
25
|
+
"build:cjs": "tsc --build tsconfig.compile.json",
|
|
26
|
+
"build:esm": "tsc --build tsconfig.compile.esm.json",
|
|
27
|
+
"barrels": "yarn barrelsby --delete -d ./src -e \"\\.spec\\.ts\" -e \"__mock__\" -e \".benchmark.ts\"",
|
|
18
28
|
"start": "ts-node -r tsconfig-paths/register test/app/index.ts",
|
|
19
29
|
"test": "cross-env NODE_ENV=test nyc mocha"
|
|
20
30
|
},
|
|
21
31
|
"dependencies": {
|
|
22
|
-
"tslib": "2.
|
|
32
|
+
"tslib": "2.3.1"
|
|
23
33
|
},
|
|
24
34
|
"devDependencies": {
|
|
25
|
-
"@tsed/common": "7.0.0-
|
|
26
|
-
"@tsed/core": "7.0.0-
|
|
27
|
-
"@tsed/di": "7.0.0-
|
|
28
|
-
"@tsed/json-mapper": "7.0.0-
|
|
29
|
-
"@tsed/openspec": "7.0.0-
|
|
30
|
-
"@tsed/
|
|
35
|
+
"@tsed/common": "7.0.0-beta.11",
|
|
36
|
+
"@tsed/core": "7.0.0-beta.11",
|
|
37
|
+
"@tsed/di": "7.0.0-beta.11",
|
|
38
|
+
"@tsed/json-mapper": "7.0.0-beta.11",
|
|
39
|
+
"@tsed/openspec": "7.0.0-beta.11",
|
|
40
|
+
"@tsed/platform-middlewares": "7.0.0-beta.11",
|
|
41
|
+
"@tsed/schema": "7.0.0-beta.11",
|
|
31
42
|
"express": "^4.17.1",
|
|
32
|
-
"socket.io": "4.1
|
|
43
|
+
"socket.io": "4.4.1",
|
|
33
44
|
"socket.io-client": "^4.1.2"
|
|
34
45
|
},
|
|
35
46
|
"peerDependencies": {
|
|
36
|
-
"@tsed/
|
|
37
|
-
"@tsed/
|
|
38
|
-
"@tsed/
|
|
39
|
-
"@tsed/
|
|
40
|
-
"@tsed/
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
47
|
+
"@tsed/di": "^7.0.0-beta.11",
|
|
48
|
+
"@tsed/json-mapper": "^7.0.0-beta.11",
|
|
49
|
+
"@tsed/logger": ">=6.1.1",
|
|
50
|
+
"@tsed/platform-middlewares": "^7.0.0-beta.11",
|
|
51
|
+
"@tsed/schema": "^7.0.0-beta.11",
|
|
52
|
+
"socket.io": ">=4.0.0"
|
|
53
|
+
},
|
|
54
|
+
"peerDependenciesMeta": {
|
|
55
|
+
"@tsed/di": {
|
|
56
|
+
"optional": false
|
|
57
|
+
},
|
|
58
|
+
"@tsed/json-mapper": {
|
|
59
|
+
"optional": false
|
|
60
|
+
},
|
|
61
|
+
"@tsed/platform-middlewares": {
|
|
62
|
+
"optional": false
|
|
63
|
+
},
|
|
64
|
+
"@tsed/schema": {
|
|
65
|
+
"optional": false
|
|
66
|
+
}
|
|
44
67
|
},
|
|
45
68
|
"repository": "https://github.com/tsedio/tsed",
|
|
46
69
|
"bugs": {
|
|
47
70
|
"url": "https://github.com/tsedio/tsed/issues"
|
|
48
71
|
},
|
|
49
|
-
"homepage": "https://github.com/tsedio/tsed/tree/
|
|
72
|
+
"homepage": "https://github.com/tsedio/tsed/tree/beta/packages/third-parties/socketio",
|
|
50
73
|
"author": "Romain Lenzotti",
|
|
51
|
-
"license": "MIT"
|
|
52
|
-
"publishConfig": {
|
|
53
|
-
"tag": "alpha"
|
|
54
|
-
}
|
|
74
|
+
"license": "MIT"
|
|
55
75
|
}
|