@soundworks/core 4.0.0-alpha.21 → 4.0.0-alpha.23
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 +14 -3
- package/package.json +15 -15
- package/src/client/Client.js +233 -188
- package/src/client/Socket.js +84 -247
- package/src/client/index.js +6 -0
- package/src/common/constants.js +0 -1
- package/src/common/logger.js +15 -0
- package/src/common/sockets-utils.js +0 -63
- package/src/common/version.js +2 -0
- package/src/server/Plugin.js +22 -10
- package/src/server/Server.js +37 -36
- package/src/server/Socket.js +126 -250
- package/src/server/Sockets.js +103 -127
- package/src/server/audit-network-latency.worker.js +4 -3
- package/src/server/index.js +6 -0
- package/types/client/Client.d.ts +41 -8
- package/types/client/Client.d.ts.map +1 -1
- package/types/client/Context.d.ts +40 -14
- package/types/client/Context.d.ts.map +1 -1
- package/types/client/Plugin.d.ts +42 -41
- package/types/client/Plugin.d.ts.map +1 -1
- package/types/client/PluginManager.d.ts +26 -11
- package/types/client/PluginManager.d.ts.map +1 -1
- package/types/client/SharedState.d.ts +1 -1
- package/types/client/SharedState.d.ts.map +1 -1
- package/types/client/SharedStateCollection.d.ts +41 -0
- package/types/client/SharedStateCollection.d.ts.map +1 -0
- package/types/client/Socket.d.ts +41 -30
- package/types/client/Socket.d.ts.map +1 -1
- package/types/client/StateManager.d.ts +1 -1
- package/types/client/StateManager.d.ts.map +1 -1
- package/types/client/index.d.ts +0 -8
- package/types/common/BasePlugin.d.ts +24 -19
- package/types/common/BasePlugin.d.ts.map +1 -1
- package/types/common/BasePluginManager.d.ts +17 -5
- package/types/common/BasePluginManager.d.ts.map +1 -1
- package/types/common/BaseSharedState.d.ts +100 -29
- package/types/common/BaseSharedState.d.ts.map +1 -1
- package/types/common/BaseSharedStateCollection.d.ts +183 -0
- package/types/common/BaseSharedStateCollection.d.ts.map +1 -0
- package/types/common/BaseStateManager.d.ts +83 -18
- package/types/common/BaseStateManager.d.ts.map +1 -1
- package/types/common/BatchedTransport.d.ts +21 -0
- package/types/common/BatchedTransport.d.ts.map +1 -0
- package/types/common/ParameterBag.d.ts +61 -40
- package/types/common/ParameterBag.d.ts.map +1 -1
- package/types/common/PromiseStore.d.ts +11 -0
- package/types/common/PromiseStore.d.ts.map +1 -0
- package/types/common/SharedStatePrivate.d.ts +4 -3
- package/types/common/SharedStatePrivate.d.ts.map +1 -1
- package/types/common/constants.d.ts +10 -1
- package/types/common/constants.d.ts.map +1 -1
- package/types/common/logger.d.ts +1 -1
- package/types/common/sockets-utils.d.ts.map +1 -1
- package/types/common/version.d.ts +3 -0
- package/types/common/version.d.ts.map +1 -0
- package/types/server/Client.d.ts +5 -0
- package/types/server/Client.d.ts.map +1 -1
- package/types/server/Context.d.ts +162 -22
- package/types/server/Context.d.ts.map +1 -1
- package/types/server/ContextManager.d.ts +4 -4
- package/types/server/ContextManager.d.ts.map +1 -1
- package/types/server/Plugin.d.ts +56 -55
- package/types/server/Plugin.d.ts.map +1 -1
- package/types/server/PluginManager.d.ts +26 -6
- package/types/server/PluginManager.d.ts.map +1 -1
- package/types/server/Server.d.ts +207 -70
- package/types/server/Server.d.ts.map +1 -1
- package/types/server/SharedState.d.ts +1 -1
- package/types/server/SharedState.d.ts.map +1 -1
- package/types/server/SharedStateCollection.d.ts +41 -0
- package/types/server/SharedStateCollection.d.ts.map +1 -0
- package/types/server/Socket.d.ts +93 -57
- package/types/server/Socket.d.ts.map +1 -1
- package/types/server/Sockets.d.ts +32 -25
- package/types/server/Sockets.d.ts.map +1 -1
- package/types/server/StateManager.d.ts +242 -27
- package/types/server/StateManager.d.ts.map +1 -1
- package/types/server/audit-network-latency.worker.d.ts +2 -1
- package/types/server/audit-schema.d.ts +8 -8
- package/types/server/crypto.d.ts +3 -0
- package/types/server/crypto.d.ts.map +1 -0
- package/types/server/index.d.ts +0 -4
- package/types/common/promise-store.d.ts +0 -4
- package/types/common/promise-store.d.ts.map +0 -1
- package/types/common/utils.d.ts +0 -5
- package/types/common/utils.d.ts.map +0 -1
package/types/server/Server.d.ts
CHANGED
|
@@ -1,100 +1,155 @@
|
|
|
1
1
|
export default Server;
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Configuration object for the server.
|
|
4
|
+
*/
|
|
5
|
+
export type ServerConfig = any;
|
|
6
|
+
/**
|
|
7
|
+
* The `Server` class is the main entry point for the server-side of a soundworks
|
|
8
|
+
* application.
|
|
4
9
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
10
|
+
* The `Server` instance allows to access soundworks components such as {@link server.StateManager},
|
|
11
|
+
* {@link server.PluginManager},{@link server.Socket} or {@link server.ContextManager}.
|
|
12
|
+
* Its is also responsible for handling the initialization lifecycles of the different
|
|
13
|
+
* soundworks components.
|
|
8
14
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* @param {server.ServerConfig} config
|
|
12
|
-
* @example
|
|
15
|
+
* ```
|
|
13
16
|
* import { Server } from '@soundworks/core/server';
|
|
17
|
+
*
|
|
14
18
|
* const server = new Server({
|
|
15
19
|
* app: {
|
|
16
20
|
* name: 'my-example-app',
|
|
17
|
-
* clients: {
|
|
21
|
+
* clients: {
|
|
22
|
+
* player: { target: 'browser', default: true },
|
|
23
|
+
* controller: { target: 'browser' },
|
|
24
|
+
* thing: { target: 'node' }
|
|
25
|
+
* },
|
|
18
26
|
* },
|
|
19
27
|
* env: {
|
|
20
|
-
* port:
|
|
28
|
+
* port: 8000,
|
|
21
29
|
* },
|
|
22
30
|
* });
|
|
23
|
-
*
|
|
31
|
+
*
|
|
24
32
|
* await server.start();
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* According to the clients definitions provided in `config.app.clients`, the
|
|
36
|
+
* server will automatically create a dedicated route for each browser client role.
|
|
37
|
+
* For example, given the config object of the example above that defines two
|
|
38
|
+
* different client roles for browser targets (i.e. `player` and `controller`):
|
|
39
|
+
*
|
|
40
|
+
* ```
|
|
41
|
+
* config.app.clients = {
|
|
42
|
+
* player: { target: 'browser', default: true },
|
|
43
|
+
* controller: { target: 'browser' },
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* The server will listen to the following URLs:
|
|
48
|
+
* - `http://127.0.0.1:8000/` for the `player` role, which is defined as the default client.
|
|
49
|
+
* - `http://127.0.0.1:8000/controller` for the `controller` role.
|
|
50
|
+
*
|
|
51
|
+
* @memberof server
|
|
25
52
|
*/
|
|
26
53
|
declare class Server {
|
|
27
|
-
constructor(config: any);
|
|
28
54
|
/**
|
|
29
|
-
* Configuration
|
|
30
|
-
*
|
|
31
|
-
*
|
|
55
|
+
* @param {server.ServerConfig} config - Configuration object for the server.
|
|
56
|
+
* @throws
|
|
57
|
+
* - If `config.app.clients` is empty.
|
|
58
|
+
* - If a `node` client is defined but `config.env.serverAddress` is not defined.
|
|
59
|
+
* - if `config.env.useHttps` is `true` and `config.env.httpsInfos` is not `null`
|
|
60
|
+
* (which generates self signed certificated), `config.env.httpsInfos.cert` and
|
|
61
|
+
* `config.env.httpsInfos.key` should point to valid cert files.
|
|
62
|
+
*/
|
|
63
|
+
constructor(config: server.ServerConfig);
|
|
64
|
+
/**
|
|
65
|
+
* @description Given config object merged with the following defaults:
|
|
66
|
+
* @example
|
|
32
67
|
* {
|
|
33
68
|
* env: {
|
|
34
69
|
* type: 'development',
|
|
35
70
|
* port: 8000,
|
|
36
|
-
*
|
|
71
|
+
* serverAddress: null,
|
|
72
|
+
* subpath: '',
|
|
73
|
+
* websockets: {
|
|
74
|
+
* path: 'socket',
|
|
75
|
+
* pingInterval: 5000,
|
|
76
|
+
* },
|
|
37
77
|
* useHttps: false,
|
|
38
78
|
* httpsInfos: null,
|
|
79
|
+
* crossOriginIsolated: true,
|
|
80
|
+
* verbose: true,
|
|
39
81
|
* },
|
|
40
82
|
* app: {
|
|
41
83
|
* name: 'soundworks',
|
|
42
84
|
* clients: {},
|
|
43
|
-
* }
|
|
85
|
+
* }
|
|
44
86
|
* }
|
|
45
|
-
* ```
|
|
46
87
|
*/
|
|
47
88
|
config: any;
|
|
89
|
+
version: string;
|
|
48
90
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
91
|
+
* Instance of the express router.
|
|
92
|
+
*
|
|
93
|
+
* The router can be used to open new route, for example to expose a directory
|
|
94
|
+
* of static assets (in default soundworks applications only the `public` is exposed).
|
|
95
|
+
*
|
|
96
|
+
* @see {@link https://github.com/expressjs/express}
|
|
97
|
+
* @example
|
|
98
|
+
* import { Server } from '@soundworks/core/server.js';
|
|
99
|
+
* import express from 'express';
|
|
100
|
+
*
|
|
101
|
+
* // create the soundworks server instance
|
|
102
|
+
* const server = new Server(config);
|
|
103
|
+
*
|
|
104
|
+
* // expose assets located in the `soundfiles` directory on the network
|
|
105
|
+
* server.router.use('/soundfiles', express.static('soundfiles')));
|
|
51
106
|
*/
|
|
52
107
|
router: any;
|
|
53
108
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
109
|
+
* Raw Node.js `http` or `https` instance
|
|
110
|
+
*
|
|
111
|
+
* @see {@link https://nodejs.org/api/http.html}
|
|
112
|
+
* @see {@link https://nodejs.org/api/https.html}
|
|
56
113
|
*/
|
|
57
114
|
httpServer: any;
|
|
58
115
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* @private
|
|
62
|
-
*/
|
|
63
|
-
private db;
|
|
64
|
-
/**
|
|
65
|
-
* The {@link server.Sockets} instance. A small wrapper around
|
|
66
|
-
* [`ws`](https://github.com/websockets/ws) server.
|
|
116
|
+
* Instance of the {@link server.Sockets} class.
|
|
117
|
+
*
|
|
67
118
|
* @see {@link server.Sockets}
|
|
68
119
|
* @type {server.Sockets}
|
|
69
120
|
*/
|
|
70
121
|
sockets: server.Sockets;
|
|
71
122
|
/**
|
|
72
|
-
*
|
|
123
|
+
* Instance of the {@link server.PluginManager} class.
|
|
124
|
+
*
|
|
73
125
|
* @see {@link server.PluginManager}
|
|
74
126
|
* @type {server.PluginManager}
|
|
75
127
|
*/
|
|
76
128
|
pluginManager: server.PluginManager;
|
|
77
129
|
/**
|
|
78
|
-
*
|
|
130
|
+
* Instance of the {@link server.StateManager} class.
|
|
131
|
+
*
|
|
79
132
|
* @see {@link server.StateManager}
|
|
80
133
|
* @type {server.StateManager}
|
|
81
134
|
*/
|
|
82
135
|
stateManager: server.StateManager;
|
|
83
136
|
/**
|
|
84
|
-
*
|
|
137
|
+
* Instance of the {@link server.ContextManager} class.
|
|
85
138
|
*
|
|
139
|
+
* @see {@link server.ContextManager}
|
|
140
|
+
* @type {server.ContextManager}
|
|
86
141
|
*/
|
|
87
|
-
contextManager: ContextManager;
|
|
142
|
+
contextManager: server.ContextManager;
|
|
88
143
|
/**
|
|
89
|
-
* If https is required,
|
|
90
|
-
*
|
|
144
|
+
* If `https` is required, hold informations about the certificates, e.g. if
|
|
145
|
+
* self-signed, the dates of validity of the certificates, etc.
|
|
91
146
|
*/
|
|
92
147
|
httpsInfos: {
|
|
93
148
|
selfSigned: boolean;
|
|
94
|
-
CN:
|
|
95
|
-
altNames:
|
|
96
|
-
validFrom:
|
|
97
|
-
validTo:
|
|
149
|
+
CN: string;
|
|
150
|
+
altNames: string[];
|
|
151
|
+
validFrom: string;
|
|
152
|
+
validTo: string;
|
|
98
153
|
isValid: boolean;
|
|
99
154
|
daysRemaining: number;
|
|
100
155
|
} | {
|
|
@@ -115,28 +170,55 @@ declare class Server {
|
|
|
115
170
|
daysRemaining?: undefined;
|
|
116
171
|
};
|
|
117
172
|
/**
|
|
118
|
-
*
|
|
173
|
+
* Status of the server, 'idle', 'inited', 'started' or 'errored'.
|
|
174
|
+
*
|
|
175
|
+
* @type {string}
|
|
119
176
|
*/
|
|
120
177
|
status: string;
|
|
178
|
+
/**
|
|
179
|
+
* Simple key / value database with Promise based Map API store on filesystem,
|
|
180
|
+
* basically a tiny wrapper around the `kvey` package.
|
|
181
|
+
*
|
|
182
|
+
* @private
|
|
183
|
+
* @see {@link https://github.com/lukechilds/keyv}
|
|
184
|
+
*/
|
|
185
|
+
private db;
|
|
121
186
|
/** @private */
|
|
122
|
-
private
|
|
187
|
+
private _applicationTemplateOptions;
|
|
123
188
|
/** @private */
|
|
124
189
|
private _onStatusChangeCallbacks;
|
|
125
190
|
/** @private */
|
|
191
|
+
private _onClientConnectCallbacks;
|
|
192
|
+
/** @private */
|
|
193
|
+
private _onClientDisconnectCallbacks;
|
|
194
|
+
/** @private */
|
|
126
195
|
private _auditState;
|
|
196
|
+
/** @private */
|
|
197
|
+
private _pendingConnectionTokens;
|
|
198
|
+
/** @private */
|
|
199
|
+
private _trustedClients;
|
|
127
200
|
/**
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
201
|
+
* Id of the server, a constant set to -1
|
|
202
|
+
* @type {Number}
|
|
203
|
+
* @readonly
|
|
204
|
+
*/
|
|
205
|
+
readonly get id(): number;
|
|
206
|
+
/**
|
|
207
|
+
* The `init` method is part of the initialization lifecycle of the `soundworks`
|
|
208
|
+
* server. Most of the time, the `init` method will be implicitly called by the
|
|
209
|
+
* {@link server.Server#start} method.
|
|
210
|
+
*
|
|
211
|
+
* In some situations you might want to call this method manually, in such cases
|
|
212
|
+
* the method should be called before the {@link server.Server#start} method.
|
|
131
213
|
*
|
|
132
214
|
* What it does:
|
|
133
215
|
* - create the audit state
|
|
134
216
|
* - prepapre http(s) server and routing according to the informations
|
|
135
217
|
* declared in `config.app.clients`
|
|
136
|
-
* -
|
|
218
|
+
* - initialize all registered plugins
|
|
137
219
|
*
|
|
138
|
-
* After `await server.init()
|
|
139
|
-
*
|
|
220
|
+
* After `await server.init()` is fulfilled, the {@link server.Server#stateManager}
|
|
221
|
+
* and all registered plugins can be safely used.
|
|
140
222
|
*
|
|
141
223
|
* @example
|
|
142
224
|
* const server = new Server(config);
|
|
@@ -148,22 +230,41 @@ declare class Server {
|
|
|
148
230
|
*/
|
|
149
231
|
init(): Promise<void>;
|
|
150
232
|
/**
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
233
|
+
* The `start` method is part of the initialization lifecycle of the `soundworks`
|
|
234
|
+
* server. The `start` method will implicitly call the {@link server.Server#init}
|
|
235
|
+
* method if it has not been called manually.
|
|
154
236
|
*
|
|
155
237
|
* What it does:
|
|
156
|
-
* -
|
|
157
|
-
*
|
|
158
|
-
* - start
|
|
159
|
-
*
|
|
238
|
+
* - implicitely call {@link server.Server#init} if not done manually
|
|
239
|
+
* - launch the HTTP and WebSocket servers
|
|
240
|
+
* - start all created contexts. To this end, you will have to call `server.init`
|
|
241
|
+
* manually and instantiate the contexts between `server.init()` and `server.start()`
|
|
242
|
+
*
|
|
243
|
+
* After `await server.start()` the server is ready to accept incoming connections
|
|
160
244
|
*
|
|
161
|
-
*
|
|
245
|
+
* @example
|
|
246
|
+
* import { Server } from '@soundworks/core/server.js'
|
|
247
|
+
*
|
|
248
|
+
* const server = new Server(config);
|
|
249
|
+
* await server.start();
|
|
162
250
|
*/
|
|
163
251
|
start(): Promise<any>;
|
|
164
252
|
/**
|
|
165
|
-
*
|
|
166
|
-
*
|
|
253
|
+
* Stops all started contexts, plugins, close all the socket connections and
|
|
254
|
+
* the http(s) server.
|
|
255
|
+
*
|
|
256
|
+
* In most situations, you might not need to call this method. However, it can
|
|
257
|
+
* be usefull for unit testing or similar situations where you want to create
|
|
258
|
+
* and delete several servers in the same process.
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* import { Server } from '@soundworks/core/server.js'
|
|
262
|
+
*
|
|
263
|
+
* const server = new Server(config);
|
|
264
|
+
* await server.start();
|
|
265
|
+
*
|
|
266
|
+
* await new Promise(resolve => setTimeout(resolve, 1000));
|
|
267
|
+
* await server.stop();
|
|
167
268
|
*/
|
|
168
269
|
stop(): Promise<void>;
|
|
169
270
|
/**
|
|
@@ -171,6 +272,8 @@ declare class Server {
|
|
|
171
272
|
* @private
|
|
172
273
|
*/
|
|
173
274
|
private _openClientRoute;
|
|
275
|
+
onClientConnect(callback: any): () => boolean;
|
|
276
|
+
onClientDisconnect(callback: any): () => boolean;
|
|
174
277
|
/**
|
|
175
278
|
* Socket connection callback.
|
|
176
279
|
* @private
|
|
@@ -189,8 +292,8 @@ declare class Server {
|
|
|
189
292
|
/** @private */
|
|
190
293
|
private _dispatchStatus;
|
|
191
294
|
/**
|
|
192
|
-
* Configure the server to work
|
|
193
|
-
*
|
|
295
|
+
* Configure the server to work _out-of-the-box_ within the soundworks application
|
|
296
|
+
* template provided by `@soundworks/create.
|
|
194
297
|
*
|
|
195
298
|
* - uses [template-literal](https://www.npmjs.com/package/template-literal) package
|
|
196
299
|
* as html templateEngine
|
|
@@ -202,22 +305,56 @@ declare class Server {
|
|
|
202
305
|
* Also expose two public directory:
|
|
203
306
|
* - the `public` directory which is exposed behind the root path
|
|
204
307
|
* - the `./.build/public` directory which is exposed behind the `build` path
|
|
308
|
+
*
|
|
309
|
+
* _Note: except in very rare cases (so rare that they are quite difficult to imagine),
|
|
310
|
+
* you should rely on these defaults._
|
|
205
311
|
*/
|
|
206
|
-
|
|
312
|
+
useDefaultApplicationTemplate(): void;
|
|
207
313
|
/**
|
|
208
|
-
* Define
|
|
209
|
-
* This method is for very advanced use-cases and
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
* If you end up using this, please contact me to explain your use-case :)
|
|
314
|
+
* Define custom template path, template engine, and clientConfig function.
|
|
315
|
+
* This method is proposed for very advanced use-cases and should very probably
|
|
316
|
+
* be improved. If you consider using this for some reason, please get in touch
|
|
317
|
+
* first to explain your use-case :)
|
|
213
318
|
*/
|
|
214
|
-
|
|
319
|
+
setCustomApplicationTemplateOptions(options: any): void;
|
|
215
320
|
/**
|
|
216
|
-
*
|
|
321
|
+
* Attach and retrieve the global audit state of the application.
|
|
322
|
+
*
|
|
323
|
+
* The audit state is a {@link server.SharedState} instance that keeps track of
|
|
324
|
+
* global informations about the application such as, the number of connected
|
|
325
|
+
* clients, network latency estimation, etc.
|
|
217
326
|
*
|
|
327
|
+
* The audit state is created by the server on start up.
|
|
328
|
+
*
|
|
329
|
+
* @returns {Promise<server.SharedState>}
|
|
218
330
|
* @throws Will throw if called before `server.init()`
|
|
331
|
+
* @see {@link server.SharedState}
|
|
332
|
+
* @example
|
|
333
|
+
* const auditState = await server.getAuditState();
|
|
334
|
+
* auditState.onUpdate(() => console.log(auditState.getValues()), true);
|
|
335
|
+
*/
|
|
336
|
+
getAuditState(): Promise<server.SharedState>;
|
|
337
|
+
/** @private */
|
|
338
|
+
private isProtected;
|
|
339
|
+
/** @private */
|
|
340
|
+
private isValidConnectionToken;
|
|
341
|
+
/**
|
|
342
|
+
* Check if the given client is trusted, i.e. config.env.type == 'production'
|
|
343
|
+
* and the client is protected behind a password.
|
|
344
|
+
*
|
|
345
|
+
* @param {server.Client} client - Client to be tested
|
|
346
|
+
* @returns {Boolean}
|
|
347
|
+
*/
|
|
348
|
+
isTrustedClient(client: server.Client): boolean;
|
|
349
|
+
/**
|
|
350
|
+
* Check if the token from a client is trusted, i.e. config.env.type == 'production'
|
|
351
|
+
* and the client is protected behind a password.
|
|
352
|
+
*
|
|
353
|
+
* @param {Number} clientId - Id of the client
|
|
354
|
+
* @param {Number} clientIp - Ip of the client
|
|
355
|
+
* @param {String} token - Token to be tested
|
|
356
|
+
* @returns {Boolean}
|
|
219
357
|
*/
|
|
220
|
-
|
|
358
|
+
isTrustedToken(clientId: number, clientIp: number, token: string): boolean;
|
|
221
359
|
}
|
|
222
|
-
import ContextManager from "./ContextManager.js";
|
|
223
360
|
//# sourceMappingURL=Server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Server.d.ts","sourceRoot":"","sources":["../../src/server/Server.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Server.d.ts","sourceRoot":"","sources":["../../src/server/Server.js"],"names":[],"mappings":";;;;;AAuGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH;IACE;;;;;;;;OAQG;IACH,yCAoLC;IA/KC;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,YAA+C;IAuC/C,gBAAsB;IAEtB;;;;;;;;;;;;;;;;OAgBG;IAGH,YAAuB;IAIvB;;;;;OAKG;IACH,gBAAsB;IAEtB;;;;;OAKG;IACH,wBAA4B;IAE5B;;;;;OAKG;IACH,oCAA4C;IAE5C;;;;;OAKG;IACH,kCAAsC;IAEtC;;;;;OAKG;IACH,sCAA8C;IAE9C;;;OAGG;IACH;;;;;;;;;;;;;;;;;;;;;;;;MAAsB;IAEtB;;;;OAIG;IACH,QAFU,MAAM,CAEI;IAEpB;;;;;;OAMG;IACH,WAAyC;IAEzC,eAAe;IACf,oCAIC;IAED,eAAe;IACf,iCAAyC;IACzC,eAAe;IACf,kCAA0C;IAC1C,eAAe;IACf,qCAA6C;IAC7C,eAAe;IACf,oBAAuB;IACvB,eAAe;IACf,iCAAyC;IACzC,eAAe;IACf,wBAAgC;IASlC;;;;OAIG;IACH,0BAEC;IAED;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,sBAgPC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,sBAwFC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,sBAgBC;IAED;;;OAGG;IACH,yBA2EC;IAED,8CAIC;IAED,iDAIC;IAED;;;OAGG;IACH,4BAkHC;IAED;;;;;;;OAOG;IACH,2BAmBC;IAED,6CAIC;IAED,eAAe;IACf,wBAgBC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,sCAkDC;IAED;;;;;OAKG;IACH,wDAEC;IAED;;;;;;;;;;;;;;;OAeG;IACH,iBAPa,2BAA2B,CAavC;IAED,eAAe;IACf,oBAMC;IAED,eAAe;IACf,+BAkBC;IAED;;;;;;OAMG;IACH,gDAMC;IAED;;;;;;;;OAQG;IAEH,2EAkBC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SharedState.d.ts","sourceRoot":"","sources":["../../src/server/SharedState.js"],"names":[],"mappings":";;;;;;;AAIA;;;;;;;;GAQG;AAEH;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"SharedState.d.ts","sourceRoot":"","sources":["../../src/server/SharedState.js"],"names":[],"mappings":";;;;;;;AAIA;;;;;;;;GAQG;AAEH;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH;CAA4C;4BAjFhB,8BAA8B"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export default SharedStateCollection;
|
|
2
|
+
export namespace server {
|
|
3
|
+
/**
|
|
4
|
+
* ~onUpdateCallback
|
|
5
|
+
*/
|
|
6
|
+
type SharedStateCollection = (state: server.SharedState, newValues: any, oldValues: any, context?: Mixed) => any;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* @callback server.SharedStateCollection~onUpdateCallback
|
|
10
|
+
* @param {server.SharedState} state - State that triggered the update.
|
|
11
|
+
* @param {Object} newValues - Key / value pairs of the updates that have been
|
|
12
|
+
* applied to the state.
|
|
13
|
+
* @param {Object} oldValues - Key / value pairs of the updated params before
|
|
14
|
+
* the updates has been applied to the state.
|
|
15
|
+
* @param {Mixed} [context=null] - Optionnal context object that has been passed
|
|
16
|
+
* with the values updates in the `set` call.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* The `SharedStateCollection` interface represent a collection of all states
|
|
20
|
+
* created from a given schema name on the network.
|
|
21
|
+
*
|
|
22
|
+
* It can optionnaly exclude the states created by the current node.
|
|
23
|
+
*
|
|
24
|
+
* See {@link server.StateManager#getCollection} for factory method API
|
|
25
|
+
*
|
|
26
|
+
* ```
|
|
27
|
+
* const collection = await server.stateManager.getCollection('my-schema');
|
|
28
|
+
* const allValues = collection.getValues();
|
|
29
|
+
* collection.onUpdate((state, newValues, oldValues, context) => {
|
|
30
|
+
* // do something
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
* @memberof server
|
|
34
|
+
* @extends BaseSharedStateCollection
|
|
35
|
+
* @inheritdoc
|
|
36
|
+
* @hideconstructor
|
|
37
|
+
*/
|
|
38
|
+
declare class SharedStateCollection extends BaseSharedStateCollection {
|
|
39
|
+
}
|
|
40
|
+
import BaseSharedStateCollection from '../common/BaseSharedStateCollection.js';
|
|
41
|
+
//# sourceMappingURL=SharedStateCollection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SharedStateCollection.d.ts","sourceRoot":"","sources":["../../src/server/SharedStateCollection.js"],"names":[],"mappings":";;;;;;;AAIA;;;;;;;;;GASG;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH;CAAgE;sCAnC1B,wCAAwC"}
|