taon 21.0.52 → 21.0.54
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/browser/package.json +1 -1
- package/browser-prod/package.json +1 -1
- package/icon-menu-taon.svg +15 -15
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/package.json +1 -1
- package/lib/ui/index.js +2 -2
- package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
- package/lib-prod/base-classes/base-abstract-entity.js +19 -0
- package/lib-prod/base-classes/base-angular-service.js +84 -0
- package/lib-prod/base-classes/base-class.js +35 -0
- package/lib-prod/base-classes/{base-context.ts → base-context.js} +13 -15
- package/lib-prod/base-classes/base-controller.js +154 -0
- package/lib-prod/base-classes/base-crud-controller.js +264 -0
- package/lib-prod/base-classes/base-custom-repository.js +9 -0
- package/lib-prod/base-classes/{base-electron-service.ts → base-electron-service.js} +1 -12
- package/lib-prod/base-classes/base-entity.js +22 -0
- package/lib-prod/base-classes/base-file-upload.middleware.js +75 -0
- package/lib-prod/base-classes/base-injector.js +184 -0
- package/lib-prod/base-classes/base-middleware.js +9 -0
- package/lib-prod/base-classes/base-migration.js +20 -0
- package/lib-prod/base-classes/{base-provider.ts → base-provider.js} +2 -2
- package/lib-prod/base-classes/base-repository.js +617 -0
- package/lib-prod/base-classes/base-subscriber-for-entity.js +145 -0
- package/lib-prod/base-classes/{base.ts → base.js} +2 -15
- package/lib-prod/{build-info._auto-generated_.ts → build-info._auto-generated_.js} +1 -2
- package/lib-prod/config/controller-config.js +28 -0
- package/lib-prod/config/controller-options.js +3 -0
- package/lib-prod/config/method-config.js +7 -0
- package/lib-prod/config/param-config.js +3 -0
- package/lib-prod/constants.js +33 -0
- package/lib-prod/context-db-migrations.js +342 -0
- package/lib-prod/create-context.js +217 -0
- package/lib-prod/decorators/classes/controller-decorator.js +17 -0
- package/lib-prod/decorators/classes/entity-decorator.js +28 -0
- package/lib-prod/decorators/classes/middleware-decorator.js +16 -0
- package/lib-prod/decorators/classes/migration-decorator.js +15 -0
- package/lib-prod/decorators/classes/provider-decorator.js +15 -0
- package/lib-prod/decorators/classes/repository-decorator.js +15 -0
- package/lib-prod/decorators/classes/subscriber-decorator.js +15 -0
- package/lib-prod/decorators/decorator-abstract-opt.js +2 -0
- package/lib-prod/decorators/http/http-decorators.js +20 -0
- package/lib-prod/decorators/http/http-methods-decorators.js +102 -0
- package/lib-prod/decorators/http/http-params-decorators.js +42 -0
- package/lib-prod/dependency-injection/di-container.js +30 -0
- package/lib-prod/endpoint-context-storage.js +31 -0
- package/lib-prod/endpoint-context.js +2397 -0
- package/lib-prod/entity-process.js +225 -0
- package/lib-prod/env/{env.angular-node-app.ts → env.angular-node-app.js} +1 -1
- package/lib-prod/env/{env.docs-webapp.ts → env.docs-webapp.js} +1 -1
- package/lib-prod/env/{env.electron-app.ts → env.electron-app.js} +1 -1
- package/lib-prod/env/{env.mobile-app.ts → env.mobile-app.js} +1 -1
- package/lib-prod/env/{env.npm-lib-and-cli-tool.ts → env.npm-lib-and-cli-tool.js} +1 -1
- package/lib-prod/env/{env.vscode-plugin.ts → env.vscode-plugin.js} +1 -1
- package/lib-prod/express-types.js +1 -0
- package/lib-prod/formly/formly.models.js +1 -0
- package/lib-prod/formly/fromly.js +205 -0
- package/lib-prod/formly/type-from-entity.js +51 -0
- package/lib-prod/get-response-value.js +22 -0
- package/lib-prod/global-state/taon-global-state/{index.ts → index.js} +2 -2
- package/lib-prod/global-state/taon-global-state/{taon-global-state.abstract.context.ts → taon-global-state.abstract.context.js} +9 -11
- package/lib-prod/global-state/taon-global-state/taon-global-state.constants.js +7 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.controller.js +42 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.entity.js +35 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.middleware.js +12 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.models.js +44 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.provider.js +12 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.repository.js +46 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.subscriber.js +22 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.utils.js +11 -0
- package/lib-prod/global-state/taon-transaction-registry/{index.ts → index.js} +2 -2
- package/lib-prod/global-state/taon-transaction-registry/{taon-transaction-registry.abstract.context.ts → taon-transaction-registry.abstract.context.js} +10 -12
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.constants.js +5 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.js +36 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.entity.js +36 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.middleware.js +12 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.models.js +7 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.provider.js +12 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.repository.js +31 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.js +22 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.js +5 -0
- package/lib-prod/helpers/class-helpers.js +228 -0
- package/lib-prod/helpers/clone-obj.js +17 -0
- package/lib-prod/helpers/taon-helpers.js +147 -0
- package/lib-prod/{index._auto-generated_.ts → index._auto-generated_.js} +1 -1
- package/lib-prod/index.js +252 -0
- package/lib-prod/{inject.ts → inject.js} +35 -57
- package/lib-prod/migrations/index.js +2 -0
- package/lib-prod/migrations/{migrations_index._auto-generated_.ts → migrations_index._auto-generated_.js} +0 -2
- package/lib-prod/models.js +78 -0
- package/lib-prod/orm/columns.js +64 -0
- package/lib-prod/orm/index.js +56 -0
- package/lib-prod/package.json +1 -1
- package/lib-prod/realtime/realtime-client.js +198 -0
- package/lib-prod/realtime/realtime-core.js +81 -0
- package/lib-prod/realtime/realtime-server.js +237 -0
- package/lib-prod/realtime/realtime-strategy/{index.ts → index.js} +1 -1
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.js +280 -0
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.js +289 -0
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-socket-io.js +27 -0
- package/lib-prod/realtime/realtime-strategy/realtime-strategy.js +11 -0
- package/lib-prod/realtime/realtime-subs-manager.js +88 -0
- package/lib-prod/realtime/realtime.models.js +2 -0
- package/lib-prod/symbols.js +108 -0
- package/lib-prod/ui/index.js +1 -0
- package/lib-prod/ui/taon-admin-mode-configuration/index.js +1 -0
- package/lib-prod/validators.js +80 -0
- package/lib-prod.split-namespaces.json +31 -91
- package/package.json +1 -1
- package/websql/package.json +1 -1
- package/websql-prod/package.json +1 -1
- package/lib-prod/base-classes/base-abstract-entity.ts +0 -34
- package/lib-prod/base-classes/base-angular-service.ts +0 -107
- package/lib-prod/base-classes/base-class.ts +0 -46
- package/lib-prod/base-classes/base-controller.ts +0 -240
- package/lib-prod/base-classes/base-crud-controller.ts +0 -298
- package/lib-prod/base-classes/base-custom-repository.ts +0 -10
- package/lib-prod/base-classes/base-entity.ts +0 -28
- package/lib-prod/base-classes/base-file-upload.middleware.ts +0 -92
- package/lib-prod/base-classes/base-injector.ts +0 -278
- package/lib-prod/base-classes/base-middleware.ts +0 -71
- package/lib-prod/base-classes/base-migration.ts +0 -26
- package/lib-prod/base-classes/base-repository.ts +0 -942
- package/lib-prod/base-classes/base-subscriber-for-entity.ts +0 -196
- package/lib-prod/config/controller-config.ts +0 -58
- package/lib-prod/config/controller-options.ts +0 -19
- package/lib-prod/config/method-config.ts +0 -55
- package/lib-prod/config/param-config.ts +0 -16
- package/lib-prod/constants.ts +0 -63
- package/lib-prod/context-db-migrations.ts +0 -488
- package/lib-prod/create-context.ts +0 -345
- package/lib-prod/decorators/classes/controller-decorator.ts +0 -25
- package/lib-prod/decorators/classes/entity-decorator.ts +0 -57
- package/lib-prod/decorators/classes/middleware-decorator.ts +0 -29
- package/lib-prod/decorators/classes/migration-decorator.ts +0 -27
- package/lib-prod/decorators/classes/provider-decorator.ts +0 -28
- package/lib-prod/decorators/classes/repository-decorator.ts +0 -26
- package/lib-prod/decorators/classes/subscriber-decorator.ts +0 -28
- package/lib-prod/decorators/decorator-abstract-opt.ts +0 -4
- package/lib-prod/decorators/http/http-decorators.ts +0 -26
- package/lib-prod/decorators/http/http-methods-decorators.ts +0 -275
- package/lib-prod/decorators/http/http-params-decorators.ts +0 -105
- package/lib-prod/dependency-injection/di-container.ts +0 -39
- package/lib-prod/endpoint-context-storage.ts +0 -47
- package/lib-prod/endpoint-context.ts +0 -3110
- package/lib-prod/entity-process.ts +0 -286
- package/lib-prod/express-types.ts +0 -4
- package/lib-prod/formly/formly.models.ts +0 -7
- package/lib-prod/formly/fromly.ts +0 -261
- package/lib-prod/formly/type-from-entity.ts +0 -80
- package/lib-prod/get-response-value.ts +0 -30
- package/lib-prod/global-state/taon-global-state/taon-global-state.constants.ts +0 -9
- package/lib-prod/global-state/taon-global-state/taon-global-state.controller.ts +0 -44
- package/lib-prod/global-state/taon-global-state/taon-global-state.entity.ts +0 -40
- package/lib-prod/global-state/taon-global-state/taon-global-state.middleware.ts +0 -12
- package/lib-prod/global-state/taon-global-state/taon-global-state.models.ts +0 -48
- package/lib-prod/global-state/taon-global-state/taon-global-state.provider.ts +0 -16
- package/lib-prod/global-state/taon-global-state/taon-global-state.repository.ts +0 -47
- package/lib-prod/global-state/taon-global-state/taon-global-state.subscriber.ts +0 -18
- package/lib-prod/global-state/taon-global-state/taon-global-state.utils.ts +0 -21
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.constants.ts +0 -7
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.ts +0 -38
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.entity.ts +0 -54
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.middleware.ts +0 -12
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.models.ts +0 -6
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.provider.ts +0 -16
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.repository.ts +0 -29
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.ts +0 -20
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.ts +0 -9
- package/lib-prod/helpers/class-helpers.ts +0 -315
- package/lib-prod/helpers/clone-obj.ts +0 -24
- package/lib-prod/helpers/taon-helpers.ts +0 -181
- package/lib-prod/index.ts +0 -323
- package/lib-prod/lib-info.md +0 -8
- package/lib-prod/migrations/index.ts +0 -2
- package/lib-prod/migrations/migrations-info.md +0 -6
- package/lib-prod/models.ts +0 -427
- package/lib-prod/orm/columns.ts +0 -121
- package/lib-prod/orm/index.ts +0 -62
- package/lib-prod/realtime/realtime-client.ts +0 -288
- package/lib-prod/realtime/realtime-core.ts +0 -134
- package/lib-prod/realtime/realtime-server.ts +0 -398
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.ts +0 -344
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.ts +0 -349
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-socket-io.ts +0 -30
- package/lib-prod/realtime/realtime-strategy/realtime-strategy.ts +0 -21
- package/lib-prod/realtime/realtime-subs-manager.ts +0 -127
- package/lib-prod/realtime/realtime.models.ts +0 -33
- package/lib-prod/symbols.ts +0 -136
- package/lib-prod/ui/index.ts +0 -1
- package/lib-prod/ui/taon-admin-mode-configuration/index.ts +0 -1
- package/lib-prod/validators.ts +0 -103
- /package/lib-prod/env/{index.ts → index.js} +0 -0
|
@@ -1,344 +0,0 @@
|
|
|
1
|
-
//#region imports
|
|
2
|
-
/* */
|
|
3
|
-
import type * as Electron from 'electron';
|
|
4
|
-
import { ipcMain } from 'electron'; // @backend
|
|
5
|
-
import { Server, ServerOptions } from 'socket.io';
|
|
6
|
-
import type { io, ManagerOptions, SocketOptions } from 'socket.io-client';
|
|
7
|
-
|
|
8
|
-
import { EndpointContext } from '../../endpoint-context';
|
|
9
|
-
import { Symbols__NS__classMethodsNames, Symbols__NS__classNameStaticProperty, Symbols__NS__ctxInClassOrClassObj, Symbols__NS__fullClassNameStaticProperty, Symbols__NS__metadata, Symbols__NS__old, Symbols__NS__orignalClass, Symbols__NS__orignalClassClonesObj, Symbols__NS__REALTIME } from '../../symbols';
|
|
10
|
-
import { RealtimeModels__NS__ChangeOption, RealtimeModels__NS__EventHandler, RealtimeModels__NS__SubsManagerOpt } from '../realtime.models';
|
|
11
|
-
|
|
12
|
-
import { RealtimeStrategy } from './realtime-strategy';
|
|
13
|
-
//#endregion
|
|
14
|
-
|
|
15
|
-
//#region mock server ipc
|
|
16
|
-
export class MockServerIpc {
|
|
17
|
-
static serverByContextName = new Map<string, MockServerIpc>();
|
|
18
|
-
|
|
19
|
-
static from(contextName: string): MockServerIpc {
|
|
20
|
-
if (!MockServerIpc.serverByContextName.has(contextName)) {
|
|
21
|
-
MockServerIpc.serverByContextName.set(
|
|
22
|
-
contextName,
|
|
23
|
-
new MockServerIpc(contextName),
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
return MockServerIpc.serverByContextName.get(contextName);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
namespacesByName = new Map<string, MockNamespaceIpc>();
|
|
30
|
-
|
|
31
|
-
//#region constructor
|
|
32
|
-
constructor(public contextName: string) {
|
|
33
|
-
MockServerIpc.serverByContextName.set(contextName, this);
|
|
34
|
-
}
|
|
35
|
-
//#endregion
|
|
36
|
-
|
|
37
|
-
//#region of
|
|
38
|
-
of(namespace: string): MockNamespaceIpc {
|
|
39
|
-
if (!this.namespacesByName.has(namespace)) {
|
|
40
|
-
this.namespacesByName.set(
|
|
41
|
-
namespace,
|
|
42
|
-
new MockNamespaceIpc(namespace, this),
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
return this.namespacesByName.get(namespace);
|
|
46
|
-
}
|
|
47
|
-
//#endregion
|
|
48
|
-
}
|
|
49
|
-
//#endregion
|
|
50
|
-
|
|
51
|
-
//#region mock namespace ipc
|
|
52
|
-
export class MockNamespaceIpc {
|
|
53
|
-
//#region fields & getters
|
|
54
|
-
electronClients = new Set<Electron.WebContents>();
|
|
55
|
-
roomsByRoomName: {
|
|
56
|
-
[roomName: string]: Set<Electron.WebContents>;
|
|
57
|
-
} = {};
|
|
58
|
-
|
|
59
|
-
private namespaceEventHandlers: {
|
|
60
|
-
[eventName: string]: Set<RealtimeModels__NS__EventHandler>;
|
|
61
|
-
} = {};
|
|
62
|
-
//#endregion
|
|
63
|
-
|
|
64
|
-
//#region constructor
|
|
65
|
-
constructor(
|
|
66
|
-
/**
|
|
67
|
-
* Namespace name
|
|
68
|
-
*/
|
|
69
|
-
public name: string,
|
|
70
|
-
public server: MockServerIpc,
|
|
71
|
-
) {}
|
|
72
|
-
//#endregion
|
|
73
|
-
|
|
74
|
-
//#region on
|
|
75
|
-
on(eventName: string, callback: RealtimeModels__NS__EventHandler) {
|
|
76
|
-
//#region @backendFunc
|
|
77
|
-
const listenKey = `(${this.name}) "${eventName}"`;
|
|
78
|
-
|
|
79
|
-
if (!this.namespaceEventHandlers[eventName]) {
|
|
80
|
-
this.namespaceEventHandlers[eventName] = new Set();
|
|
81
|
-
}
|
|
82
|
-
this.namespaceEventHandlers[eventName].add(callback);
|
|
83
|
-
|
|
84
|
-
ipcMain.on(listenKey, (eventElectron, ...args) => {
|
|
85
|
-
this.electronClients.add(eventElectron.sender);
|
|
86
|
-
|
|
87
|
-
const connectionListener = `(${this.name}) "connection"`;
|
|
88
|
-
if (connectionListener === listenKey) {
|
|
89
|
-
callback(this, ...args);
|
|
90
|
-
} else {
|
|
91
|
-
if (eventName.includes(`:${Symbols__NS__REALTIME.KEYroomSubscribe}`)) {
|
|
92
|
-
const roomName = args[0];
|
|
93
|
-
this.join(eventElectron.sender, roomName);
|
|
94
|
-
} else if (
|
|
95
|
-
eventName.includes(`:${Symbols__NS__REALTIME.KEYroomUnsubscribe}`)
|
|
96
|
-
) {
|
|
97
|
-
const roomName = args[0];
|
|
98
|
-
this.leave(eventElectron.sender, roomName);
|
|
99
|
-
} else {
|
|
100
|
-
callback(...args);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
// this.emit(listenKey); // QUICK_FIX
|
|
105
|
-
//#endregion
|
|
106
|
-
}
|
|
107
|
-
//#endregion
|
|
108
|
-
|
|
109
|
-
//#region off
|
|
110
|
-
off(event: string, callback?: RealtimeModels__NS__EventHandler) {
|
|
111
|
-
//#region @backendFunc
|
|
112
|
-
if (!this.namespaceEventHandlers[event]) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (callback) {
|
|
117
|
-
this.namespaceEventHandlers[event].delete(callback);
|
|
118
|
-
} else {
|
|
119
|
-
delete this.namespaceEventHandlers[event];
|
|
120
|
-
}
|
|
121
|
-
const removeKey = `(${this.name}) "${event}"`;
|
|
122
|
-
ipcMain.removeListener(removeKey, callback);
|
|
123
|
-
//#endregion
|
|
124
|
-
}
|
|
125
|
-
//#endregion
|
|
126
|
-
|
|
127
|
-
//#region emit
|
|
128
|
-
emit(eventName: string, ...args: any[]) {
|
|
129
|
-
//#region @backendFunc
|
|
130
|
-
const sendEventKey = `(${this.name}) "${eventName}"`;
|
|
131
|
-
for (const webContents of this.electronClients) {
|
|
132
|
-
webContents.send(sendEventKey, ...args);
|
|
133
|
-
}
|
|
134
|
-
// const allWindows = Electron.BrowserWindow.getAllWindows();
|
|
135
|
-
// allWindows.forEach((win, index) => {
|
|
136
|
-
// win.webContents.send(sendEventKey, ...args);
|
|
137
|
-
// });
|
|
138
|
-
//#endregion
|
|
139
|
-
}
|
|
140
|
-
//#endregion
|
|
141
|
-
|
|
142
|
-
//#region to
|
|
143
|
-
to(roomName: string) {
|
|
144
|
-
const electronClientsInroom = this.roomsByRoomName[roomName];
|
|
145
|
-
return new RoomEmitterIpc(electronClientsInroom, this.name, true);
|
|
146
|
-
}
|
|
147
|
-
//#endregion
|
|
148
|
-
|
|
149
|
-
//#region in
|
|
150
|
-
in(roomName: string) {
|
|
151
|
-
const electronClientsInroom = this.roomsByRoomName[roomName];
|
|
152
|
-
return new RoomEmitterIpc(electronClientsInroom, this.name, false);
|
|
153
|
-
}
|
|
154
|
-
//#endregion
|
|
155
|
-
|
|
156
|
-
//#region join
|
|
157
|
-
join(webContents: Electron.WebContents, roomName: string) {
|
|
158
|
-
if (!this.roomsByRoomName[roomName]) {
|
|
159
|
-
this.roomsByRoomName[roomName] = new Set();
|
|
160
|
-
}
|
|
161
|
-
this.roomsByRoomName[roomName].add(webContents);
|
|
162
|
-
}
|
|
163
|
-
//#endregion
|
|
164
|
-
|
|
165
|
-
//#region leave
|
|
166
|
-
leave(webContents: Electron.WebContents, roomName: string) {
|
|
167
|
-
if (this.roomsByRoomName[roomName]) {
|
|
168
|
-
this.roomsByRoomName[roomName].delete(webContents);
|
|
169
|
-
if (this.roomsByRoomName[roomName].size === 0) {
|
|
170
|
-
delete this.roomsByRoomName[roomName];
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
//#endregion
|
|
175
|
-
|
|
176
|
-
//#region path
|
|
177
|
-
path() {
|
|
178
|
-
return this.name;
|
|
179
|
-
}
|
|
180
|
-
//#endregion
|
|
181
|
-
|
|
182
|
-
//#region get nsp
|
|
183
|
-
get nsp() {
|
|
184
|
-
const self = this;
|
|
185
|
-
return {
|
|
186
|
-
get name() {
|
|
187
|
-
return self.name;
|
|
188
|
-
},
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
//#endregion
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
//#endregion
|
|
195
|
-
|
|
196
|
-
//#region room emitter ipc
|
|
197
|
-
class RoomEmitterIpc {
|
|
198
|
-
//#region constructor
|
|
199
|
-
constructor(
|
|
200
|
-
private electronClients: Set<Electron.WebContents>,
|
|
201
|
-
/**
|
|
202
|
-
* namespace name
|
|
203
|
-
*/
|
|
204
|
-
private name: string,
|
|
205
|
-
private includeSender: boolean = false,
|
|
206
|
-
private sender: MockSocketIpc = null, // TODO QUICK FIX how to include sender
|
|
207
|
-
) {}
|
|
208
|
-
//#endregion
|
|
209
|
-
|
|
210
|
-
//#region emit in room
|
|
211
|
-
emit(eventName: string, ...args: any[]): void {
|
|
212
|
-
const emitEvent = `(${this.name}) "${eventName}"`;
|
|
213
|
-
this.electronClients?.forEach(webContents => {
|
|
214
|
-
webContents.send(emitEvent, ...args);
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
//#endregion
|
|
218
|
-
}
|
|
219
|
-
//#endregion
|
|
220
|
-
|
|
221
|
-
//#region mock socket ipc
|
|
222
|
-
export class MockSocketIpc {
|
|
223
|
-
//#region fields & getters
|
|
224
|
-
|
|
225
|
-
//#region fields & getters / ipc renderer
|
|
226
|
-
/* */
|
|
227
|
-
/* */
|
|
228
|
-
|
|
229
|
-
//#endregion
|
|
230
|
-
|
|
231
|
-
//#region fields & getters / event handlers by name
|
|
232
|
-
private socketEventHandlers = {} as {
|
|
233
|
-
[eventName: string]: Set<RealtimeModels__NS__EventHandler>;
|
|
234
|
-
};
|
|
235
|
-
//#endregion
|
|
236
|
-
|
|
237
|
-
//#region fields & getters / name
|
|
238
|
-
get name() {
|
|
239
|
-
return this.namespaceName;
|
|
240
|
-
}
|
|
241
|
-
//#endregion
|
|
242
|
-
|
|
243
|
-
//#endregion
|
|
244
|
-
|
|
245
|
-
//#region constructor
|
|
246
|
-
/**
|
|
247
|
-
* @param namespaceName instead url for ipc
|
|
248
|
-
*/
|
|
249
|
-
constructor(public namespaceName: string) {
|
|
250
|
-
/* */
|
|
251
|
-
/* */
|
|
252
|
-
|
|
253
|
-
}
|
|
254
|
-
//#endregion
|
|
255
|
-
|
|
256
|
-
//#region on
|
|
257
|
-
on(eventName: string, callback: (event: any, ...args: any[]) => void) {
|
|
258
|
-
/* */
|
|
259
|
-
/* */
|
|
260
|
-
/* */
|
|
261
|
-
/* */
|
|
262
|
-
/* */
|
|
263
|
-
/* */
|
|
264
|
-
/* */
|
|
265
|
-
/* */
|
|
266
|
-
/* */
|
|
267
|
-
/* */
|
|
268
|
-
/* */
|
|
269
|
-
/* */
|
|
270
|
-
/* */
|
|
271
|
-
/* */
|
|
272
|
-
/* */
|
|
273
|
-
|
|
274
|
-
}
|
|
275
|
-
//#endregion
|
|
276
|
-
|
|
277
|
-
//#region off
|
|
278
|
-
off(event: string, callback?: (event: any, ...args: any[]) => void) {
|
|
279
|
-
/* */
|
|
280
|
-
/* */
|
|
281
|
-
/* */
|
|
282
|
-
/* */
|
|
283
|
-
/* */
|
|
284
|
-
/* */
|
|
285
|
-
/* */
|
|
286
|
-
/* */
|
|
287
|
-
/* */
|
|
288
|
-
/* */
|
|
289
|
-
/* */
|
|
290
|
-
/* */
|
|
291
|
-
/* */
|
|
292
|
-
/* */
|
|
293
|
-
/* */
|
|
294
|
-
|
|
295
|
-
}
|
|
296
|
-
//#endregion
|
|
297
|
-
|
|
298
|
-
//#region emit
|
|
299
|
-
emit(event: string, ...args: any[]) {
|
|
300
|
-
/* */
|
|
301
|
-
/* */
|
|
302
|
-
/* */
|
|
303
|
-
|
|
304
|
-
}
|
|
305
|
-
//#endregion
|
|
306
|
-
}
|
|
307
|
-
//#endregion
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* Purpose:
|
|
311
|
-
* - backend-browser communication between 2 processes in electron mode
|
|
312
|
-
*/
|
|
313
|
-
export class RealtimeStrategyIpc extends RealtimeStrategy {
|
|
314
|
-
//#region to string
|
|
315
|
-
toString(): string {
|
|
316
|
-
return 'ipc';
|
|
317
|
-
}
|
|
318
|
-
//#endregion
|
|
319
|
-
|
|
320
|
-
//#region constructor
|
|
321
|
-
constructor(protected ctx: EndpointContext) {
|
|
322
|
-
super(ctx);
|
|
323
|
-
}
|
|
324
|
-
//#endregion
|
|
325
|
-
|
|
326
|
-
//#region server & io
|
|
327
|
-
ioServer(__: string, opt: ServerOptions) {
|
|
328
|
-
const namespace = opt?.path || '/';
|
|
329
|
-
const server = MockServerIpc.from(this.ctx.contextName);
|
|
330
|
-
return server.of(namespace) as any;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
get ioClient() {
|
|
334
|
-
const clientIo = (
|
|
335
|
-
__: string,
|
|
336
|
-
opt?: Partial<ManagerOptions & SocketOptions>,
|
|
337
|
-
): MockSocketIpc => {
|
|
338
|
-
const namespace = opt?.path || '/';
|
|
339
|
-
return new MockSocketIpc(namespace);
|
|
340
|
-
};
|
|
341
|
-
return clientIo as any;
|
|
342
|
-
}
|
|
343
|
-
//#endregion
|
|
344
|
-
}
|
|
@@ -1,349 +0,0 @@
|
|
|
1
|
-
//#region imports
|
|
2
|
-
import type { EndpointContext } from '../../endpoint-context';
|
|
3
|
-
import { RealtimeStrategy } from './realtime-strategy';
|
|
4
|
-
import { Symbols__NS__classMethodsNames, Symbols__NS__classNameStaticProperty, Symbols__NS__ctxInClassOrClassObj, Symbols__NS__fullClassNameStaticProperty, Symbols__NS__metadata, Symbols__NS__old, Symbols__NS__orignalClass, Symbols__NS__orignalClassClonesObj, Symbols__NS__REALTIME } from '../../symbols';
|
|
5
|
-
import { ManagerOptions, SocketOptions } from 'socket.io-client';
|
|
6
|
-
import { RealtimeModels__NS__ChangeOption, RealtimeModels__NS__EventHandler, RealtimeModels__NS__SubsManagerOpt } from '../realtime.models';
|
|
7
|
-
import { ServerOptions } from 'socket.io';
|
|
8
|
-
//#endregion
|
|
9
|
-
|
|
10
|
-
//#region mock server
|
|
11
|
-
class MockServer {
|
|
12
|
-
static serverByUrl = new Map<string, MockServer>();
|
|
13
|
-
static from(url: string): MockServer {
|
|
14
|
-
if (!MockServer.serverByUrl.has(url)) {
|
|
15
|
-
MockServer.serverByUrl.set(url, new MockServer(url));
|
|
16
|
-
}
|
|
17
|
-
return MockServer.serverByUrl.get(url);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
get allServers() {
|
|
21
|
-
return Array.from(MockServer.serverByUrl.values());
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
namespacesByName = new Map<string, MockNamespace>();
|
|
25
|
-
|
|
26
|
-
//#region constructor
|
|
27
|
-
constructor(public url: string) {
|
|
28
|
-
MockServer.serverByUrl.set(url, this);
|
|
29
|
-
}
|
|
30
|
-
//#endregion
|
|
31
|
-
|
|
32
|
-
//#region of
|
|
33
|
-
of(namespace: string): MockNamespace {
|
|
34
|
-
if (!this.namespacesByName.has(namespace)) {
|
|
35
|
-
this.namespacesByName.set(namespace, new MockNamespace(namespace, this));
|
|
36
|
-
}
|
|
37
|
-
return this.namespacesByName.get(namespace);
|
|
38
|
-
}
|
|
39
|
-
//#endregion
|
|
40
|
-
|
|
41
|
-
//#region path
|
|
42
|
-
path() {
|
|
43
|
-
return this.url;
|
|
44
|
-
}
|
|
45
|
-
//#endregion
|
|
46
|
-
}
|
|
47
|
-
//#endregion
|
|
48
|
-
|
|
49
|
-
//#region mock namespace
|
|
50
|
-
class MockNamespace {
|
|
51
|
-
/**
|
|
52
|
-
* All sockets connected to this namespace
|
|
53
|
-
*/
|
|
54
|
-
public readonly allSocketsForNamespace = new Set<MockSocket>();
|
|
55
|
-
/**
|
|
56
|
-
* Rooms and their sockets
|
|
57
|
-
*/
|
|
58
|
-
private socketByRoomName: {
|
|
59
|
-
[roomName: string]: Set<MockSocket>;
|
|
60
|
-
} = {};
|
|
61
|
-
/**
|
|
62
|
-
* Event handlers for this namespace
|
|
63
|
-
*/
|
|
64
|
-
public namespaceEventHandlers: {
|
|
65
|
-
[eventName: string]: Set<RealtimeModels__NS__EventHandler>;
|
|
66
|
-
} = {};
|
|
67
|
-
|
|
68
|
-
//#region constructor
|
|
69
|
-
constructor(
|
|
70
|
-
/**
|
|
71
|
-
* unique namespace name
|
|
72
|
-
*/
|
|
73
|
-
public name: string,
|
|
74
|
-
public server: MockServer,
|
|
75
|
-
) {}
|
|
76
|
-
//#endregion
|
|
77
|
-
|
|
78
|
-
//#region on
|
|
79
|
-
on(eventName: string, handler: RealtimeModels__NS__EventHandler): void {
|
|
80
|
-
// console.log(`ON EVNET event "${eventName}"`);
|
|
81
|
-
if (!this.namespaceEventHandlers[eventName]) {
|
|
82
|
-
this.namespaceEventHandlers[eventName] =
|
|
83
|
-
new Set<RealtimeModels__NS__EventHandler>();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (!this.namespaceEventHandlers[eventName].has(handler)) {
|
|
87
|
-
this.namespaceEventHandlers[eventName].add(handler);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// QUICK_FIX Emit connection event for backend
|
|
91
|
-
// TODO make it in emit
|
|
92
|
-
if (eventName === 'connection') {
|
|
93
|
-
setTimeout(() => {
|
|
94
|
-
this.emit('connection', this);
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
//#endregion
|
|
99
|
-
|
|
100
|
-
//#region emit
|
|
101
|
-
emit(event: string, ...args: any[]): void {
|
|
102
|
-
this.allSocketsForNamespace?.forEach(socket => {
|
|
103
|
-
socket.emit(event, ...args);
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
//#endregion
|
|
107
|
-
|
|
108
|
-
//#region connect
|
|
109
|
-
connect(socket: MockSocket): void {
|
|
110
|
-
this.allSocketsForNamespace.add(socket);
|
|
111
|
-
socket.namespaceInstance = this;
|
|
112
|
-
}
|
|
113
|
-
//#endregion
|
|
114
|
-
|
|
115
|
-
//#region to
|
|
116
|
-
to(roomName: string): RoomEmitter {
|
|
117
|
-
const socketsInRoom = this.socketByRoomName[roomName];
|
|
118
|
-
return new RoomEmitter(socketsInRoom, true);
|
|
119
|
-
}
|
|
120
|
-
//#endregion
|
|
121
|
-
|
|
122
|
-
//#region to room
|
|
123
|
-
in(roomName: string): RoomEmitter {
|
|
124
|
-
const socketsInRoom = this.socketByRoomName[roomName];
|
|
125
|
-
return new RoomEmitter(socketsInRoom, false);
|
|
126
|
-
}
|
|
127
|
-
//#endregion
|
|
128
|
-
|
|
129
|
-
//#region join room
|
|
130
|
-
joinRoom(roomName: string, socket: MockSocket): void {
|
|
131
|
-
if (!this.socketByRoomName[roomName]) {
|
|
132
|
-
this.socketByRoomName[roomName] = new Set<MockSocket>();
|
|
133
|
-
}
|
|
134
|
-
this.socketByRoomName[roomName].add(socket);
|
|
135
|
-
}
|
|
136
|
-
//#endregion
|
|
137
|
-
|
|
138
|
-
//#region leave room
|
|
139
|
-
leaveRoom(roomName: string, socket: MockSocket): void {
|
|
140
|
-
const roomSockets = this.socketByRoomName[roomName];
|
|
141
|
-
if (roomSockets) {
|
|
142
|
-
this.socketByRoomName[roomName].delete(socket);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
//#endregion
|
|
146
|
-
|
|
147
|
-
//#region nsp + name
|
|
148
|
-
get nsp() {
|
|
149
|
-
const self = this;
|
|
150
|
-
return {
|
|
151
|
-
get name() {
|
|
152
|
-
return self.name;
|
|
153
|
-
},
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
//#endregion
|
|
157
|
-
|
|
158
|
-
path() {
|
|
159
|
-
return this.name;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
//#endregion
|
|
163
|
-
|
|
164
|
-
//#region room emitter
|
|
165
|
-
class RoomEmitter {
|
|
166
|
-
//#region constructor
|
|
167
|
-
constructor(
|
|
168
|
-
private sockets: Set<MockSocket>,
|
|
169
|
-
private includeSender: boolean = false,
|
|
170
|
-
private sender: MockSocket = null, // TODO QUICK FIX how to include sender
|
|
171
|
-
) {}
|
|
172
|
-
//#endregion
|
|
173
|
-
|
|
174
|
-
//#region emit in room
|
|
175
|
-
emit(event: string, ...args: any[]): void {
|
|
176
|
-
// console.log(
|
|
177
|
-
// `emit room emiter ${event} , this.sockets ${this.sockets.length}`,
|
|
178
|
-
// );
|
|
179
|
-
this.sockets?.forEach(socket => {
|
|
180
|
-
// console.log(`emit event ${event} to socket ${socket.id}`);
|
|
181
|
-
if (this.includeSender || socket !== this.sender) {
|
|
182
|
-
socket.emit(event, ...args);
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
//#endregion
|
|
187
|
-
}
|
|
188
|
-
//#endregion
|
|
189
|
-
|
|
190
|
-
//#region mock socket
|
|
191
|
-
class MockSocket {
|
|
192
|
-
public namespaceInstance: MockNamespace;
|
|
193
|
-
private socketEventHandlers = {} as {
|
|
194
|
-
[eventName: string]: Set<RealtimeModels__NS__EventHandler>;
|
|
195
|
-
};
|
|
196
|
-
get id() {
|
|
197
|
-
return this.nsp.name;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
//#region constructor
|
|
201
|
-
constructor(
|
|
202
|
-
public url: string,
|
|
203
|
-
opts?: Partial<ManagerOptions & SocketOptions>,
|
|
204
|
-
) {
|
|
205
|
-
// @ts-ignore
|
|
206
|
-
const [baseUrl, namespace] = [url, opts.path || '/'];
|
|
207
|
-
// console.log({ url, baseUrl, namespace });
|
|
208
|
-
const namespaceName = namespace || '/';
|
|
209
|
-
|
|
210
|
-
// Look up the server instance from the registry
|
|
211
|
-
const server = MockServer.from(url);
|
|
212
|
-
|
|
213
|
-
const ns = server.of(namespaceName);
|
|
214
|
-
ns.connect(this);
|
|
215
|
-
}
|
|
216
|
-
//#endregion
|
|
217
|
-
|
|
218
|
-
//#region nsp + name
|
|
219
|
-
get nsp() {
|
|
220
|
-
const self = this;
|
|
221
|
-
return {
|
|
222
|
-
get name() {
|
|
223
|
-
return self.namespaceInstance?.name;
|
|
224
|
-
},
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
//#endregion
|
|
228
|
-
|
|
229
|
-
//#region path
|
|
230
|
-
path() {
|
|
231
|
-
return this.namespaceInstance?.name;
|
|
232
|
-
}
|
|
233
|
-
//#endregion
|
|
234
|
-
|
|
235
|
-
//#region on
|
|
236
|
-
on(eventName: string, handler: RealtimeModels__NS__EventHandler): void {
|
|
237
|
-
if (!this.socketEventHandlers[eventName]) {
|
|
238
|
-
this.socketEventHandlers[eventName] =
|
|
239
|
-
new Set<RealtimeModels__NS__EventHandler>();
|
|
240
|
-
}
|
|
241
|
-
this.socketEventHandlers[eventName].add(handler);
|
|
242
|
-
|
|
243
|
-
// QUICK_FIX client initing itself
|
|
244
|
-
if (eventName === 'connect') {
|
|
245
|
-
setTimeout(() => {
|
|
246
|
-
this.emit('connect');
|
|
247
|
-
// this.namespaceInstance.emit('connection', this); @UNCOMMNENT
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
//#endregion
|
|
252
|
-
|
|
253
|
-
//#region emit
|
|
254
|
-
emit(eventName: string, ...args: any[]): void {
|
|
255
|
-
eventName = eventName || '';
|
|
256
|
-
|
|
257
|
-
if (eventName.includes(`:${Symbols__NS__REALTIME.KEYroomSubscribe}`)) {
|
|
258
|
-
const room = args[0];
|
|
259
|
-
this.join(room);
|
|
260
|
-
} else if (eventName.includes(`:${Symbols__NS__REALTIME.KEYroomUnsubscribe}`)) {
|
|
261
|
-
const room = args[0];
|
|
262
|
-
this.leave(room);
|
|
263
|
-
} else {
|
|
264
|
-
// console.log('try to emit event (to server)', event);
|
|
265
|
-
if (this.namespaceInstance) {
|
|
266
|
-
const namespaceEventHandlers =
|
|
267
|
-
this.namespaceInstance.namespaceEventHandlers[eventName] || [];
|
|
268
|
-
|
|
269
|
-
// emit to namespace events
|
|
270
|
-
for (const namespaceEventHandler of namespaceEventHandlers) {
|
|
271
|
-
if (namespaceEventHandler) {
|
|
272
|
-
namespaceEventHandler(...args);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
const allSocketsForNamespaceExceptCurrent = Array.from(
|
|
277
|
-
this.namespaceInstance.allSocketsForNamespace.values(),
|
|
278
|
-
).filter(socket => socket !== this);
|
|
279
|
-
|
|
280
|
-
// emit to all sockets in namespace
|
|
281
|
-
for (const socket of allSocketsForNamespaceExceptCurrent) {
|
|
282
|
-
const socketEventHandlers = socket.socketEventHandlers[eventName];
|
|
283
|
-
for (const socketEventHandler of socketEventHandlers) {
|
|
284
|
-
if (socketEventHandler) {
|
|
285
|
-
socketEventHandler(...args);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
// Emit to current socket
|
|
291
|
-
const socketEventHandlers = this.socketEventHandlers[eventName] || [];
|
|
292
|
-
for (const clientHandler of socketEventHandlers) {
|
|
293
|
-
if (clientHandler) {
|
|
294
|
-
clientHandler(...args);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
//#endregion
|
|
301
|
-
|
|
302
|
-
//#region join room
|
|
303
|
-
join(roomName: string): void {
|
|
304
|
-
this.namespaceInstance.joinRoom(roomName, this);
|
|
305
|
-
}
|
|
306
|
-
//#endregion
|
|
307
|
-
|
|
308
|
-
//#region leave room
|
|
309
|
-
leave(roomName: string): void {
|
|
310
|
-
this.namespaceInstance.leaveRoom(roomName, this);
|
|
311
|
-
}
|
|
312
|
-
//#endregion
|
|
313
|
-
}
|
|
314
|
-
//#endregion
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* Purpose:
|
|
318
|
-
* - browser-browser communication mock (in websql mode)
|
|
319
|
-
*/
|
|
320
|
-
export class RealtimeStrategyMock extends RealtimeStrategy {
|
|
321
|
-
//#region toString
|
|
322
|
-
toString(): string {
|
|
323
|
-
return 'mock';
|
|
324
|
-
}
|
|
325
|
-
//#endregion
|
|
326
|
-
|
|
327
|
-
//#region constructor
|
|
328
|
-
constructor(protected ctx: EndpointContext) {
|
|
329
|
-
super(ctx);
|
|
330
|
-
}
|
|
331
|
-
//#endregion
|
|
332
|
-
|
|
333
|
-
//#region server & io
|
|
334
|
-
ioServer(url: string, opt: ServerOptions) {
|
|
335
|
-
const server = MockServer.from(url || this.ctx.uriOrigin);
|
|
336
|
-
return server.of(opt?.path || '/') as any;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
get ioClient() {
|
|
340
|
-
const clientIo = (
|
|
341
|
-
uri: string,
|
|
342
|
-
opts?: Partial<ManagerOptions & SocketOptions>,
|
|
343
|
-
): MockSocket => {
|
|
344
|
-
return new MockSocket(uri || this.ctx.uriOrigin, opts as any);
|
|
345
|
-
};
|
|
346
|
-
return clientIo as any;
|
|
347
|
-
}
|
|
348
|
-
//#endregion
|
|
349
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { EndpointContext } from '../../endpoint-context';
|
|
2
|
-
import { RealtimeStrategy } from './realtime-strategy';
|
|
3
|
-
//#region @backend
|
|
4
|
-
import { Server, ServerOptions } from 'socket.io';
|
|
5
|
-
//#endregion
|
|
6
|
-
import { io, ManagerOptions, Socket, SocketOptions } from 'socket.io-client';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Purpose:
|
|
10
|
-
* - backend-browser communication
|
|
11
|
-
* - backend-backend communication
|
|
12
|
-
*/
|
|
13
|
-
export class RealtimeStrategySocketIO extends RealtimeStrategy {
|
|
14
|
-
toString(): string {
|
|
15
|
-
return 'socket-io';
|
|
16
|
-
}
|
|
17
|
-
constructor(protected ctx: EndpointContext) {
|
|
18
|
-
super(ctx);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
ioServer(...args) {
|
|
22
|
-
//#region @backendFunc
|
|
23
|
-
return new Server(...args);
|
|
24
|
-
//#endregion
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
get ioClient() {
|
|
28
|
-
return io;
|
|
29
|
-
}
|
|
30
|
-
}
|