@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
|
@@ -1,16 +1,241 @@
|
|
|
1
1
|
export default StateManager;
|
|
2
2
|
export namespace server {
|
|
3
3
|
/**
|
|
4
|
-
* ~
|
|
4
|
+
* ~schema
|
|
5
|
+
*
|
|
6
|
+
* Description of a schema to be registered by the {@link server.StateManagerregisterSchema }
|
|
7
|
+
*
|
|
8
|
+
* A schema is the blueprint, or definition from which shared states can be created.
|
|
9
|
+
*
|
|
10
|
+
* It consists of a set of key / value pairs where the key is the name of
|
|
11
|
+
* the parameter, and the value is an object describing the parameter.
|
|
12
|
+
*
|
|
13
|
+
* The value can be of any of the foolowing types:
|
|
14
|
+
* - {@link server.StateManager ~schemaBooleanDefinition}
|
|
15
|
+
* - {@link server.StateManager ~schemaStringDefinition}
|
|
16
|
+
* - {@link server.StateManager ~schemaIntegerDefinition}
|
|
17
|
+
* - {@link server.StateManager ~schemaFloatDefinition}
|
|
18
|
+
* - {@link server.StateManager ~schemaEnumDefinition}
|
|
19
|
+
* - {@link server.StateManager ~schemaAnyDefinition}
|
|
5
20
|
*/
|
|
6
|
-
type StateManager =
|
|
21
|
+
type StateManager = object;
|
|
7
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* @typedef {object} server.StateManager~schema
|
|
25
|
+
*
|
|
26
|
+
* Description of a schema to be registered by the {@link server.StateManager#registerSchema}
|
|
27
|
+
*
|
|
28
|
+
* A schema is the blueprint, or definition from which shared states can be created.
|
|
29
|
+
*
|
|
30
|
+
* It consists of a set of key / value pairs where the key is the name of
|
|
31
|
+
* the parameter, and the value is an object describing the parameter.
|
|
32
|
+
*
|
|
33
|
+
* The value can be of any of the foolowing types:
|
|
34
|
+
* - {@link server.StateManager~schemaBooleanDefinition}
|
|
35
|
+
* - {@link server.StateManager~schemaStringDefinition}
|
|
36
|
+
* - {@link server.StateManager~schemaIntegerDefinition}
|
|
37
|
+
* - {@link server.StateManager~schemaFloatDefinition}
|
|
38
|
+
* - {@link server.StateManager~schemaEnumDefinition}
|
|
39
|
+
* - {@link server.StateManager~schemaAnyDefinition}
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* const mySchema = {
|
|
43
|
+
* triggerSound: {
|
|
44
|
+
* type: 'boolean',
|
|
45
|
+
* event: true,
|
|
46
|
+
* },
|
|
47
|
+
* volume: {
|
|
48
|
+
* type: 'float'
|
|
49
|
+
* default: 0,
|
|
50
|
+
* min: -80,
|
|
51
|
+
* max: 6,
|
|
52
|
+
* }
|
|
53
|
+
* };
|
|
54
|
+
*
|
|
55
|
+
* server.stateManager.registerSchema('my-schema-name', mySchema);
|
|
56
|
+
*/
|
|
57
|
+
/**
|
|
58
|
+
* Describe a {@link server.StateManager~schema} entry of "boolean" type.
|
|
59
|
+
*
|
|
60
|
+
* @typedef {object} server.StateManager~schemaBooleanDefinition
|
|
61
|
+
* @property {string} type='boolean' - Define a boolean parameter.
|
|
62
|
+
* @property {boolean} default - Default value of the parameter.
|
|
63
|
+
* @property {boolean} [nullable=false] - Define if the parameter is nullable. If
|
|
64
|
+
* set to `true` the parameter `default` is set to `null`.
|
|
65
|
+
* @property {boolean} [event=false] - Define if the parameter is a volatile, e.g.
|
|
66
|
+
* set its value back to `null` after propagation. When `true`, `nullable` is
|
|
67
|
+
* automatically set to `true` and `default` to `null`.
|
|
68
|
+
* @property {boolean} [filterChange=true] - Setting this option to `false` forces
|
|
69
|
+
* the propagation of a parameter even when its value do not change. It
|
|
70
|
+
* offers a kind of middle ground between the default bahavior (e.g. where
|
|
71
|
+
* only changed values are propagated) and the behavior of the `event` option
|
|
72
|
+
* (which has no state per se). As such, setting this options to `false` if
|
|
73
|
+
* `event=true` does not make sens.
|
|
74
|
+
* @property {boolean} [immediate=false] - Setting this option to `true` will
|
|
75
|
+
* trigger any change (e.g. call the `onUpdate` listeners) immediately on the
|
|
76
|
+
* state that generate the update (i.e. calling `set`), before propagating the
|
|
77
|
+
* change on the network. This option can be usefull in cases the network
|
|
78
|
+
* would introduce a noticeable latency on the client. If for some reason
|
|
79
|
+
* the value is overriden server-side (e.g. in an `updateHook`) the listeners
|
|
80
|
+
* will be called again on when the "real" / final value will be received.
|
|
81
|
+
* @property {object} [metas={}] - Optionnal metadata of the parameter.
|
|
82
|
+
*/
|
|
83
|
+
/**
|
|
84
|
+
* Describe a {@link server.StateManager~schema} entry of "string" type.
|
|
85
|
+
*
|
|
86
|
+
* @typedef {object} server.StateManager~schemaStringDefinition
|
|
87
|
+
* @property {string} type='string' - Define a boolean parameter.
|
|
88
|
+
* @property {string} default - Default value of the parameter.
|
|
89
|
+
* @property {boolean} [nullable=false] - Define if the parameter is nullable. If
|
|
90
|
+
* set to `true` the parameter `default` is set to `null`.
|
|
91
|
+
* @property {boolean} [event=false] - Define if the parameter is a volatile, e.g.
|
|
92
|
+
* set its value back to `null` after propagation. When `true`, `nullable` is
|
|
93
|
+
* automatically set to `true` and `default` to `null`.
|
|
94
|
+
* @property {boolean} [filterChange=true] - Setting this option to `false` forces
|
|
95
|
+
* the propagation of a parameter even when its value do not change. It
|
|
96
|
+
* offers a kind of middle ground between the default bahavior (e.g. where
|
|
97
|
+
* only changed values are propagated) and the behavior of the `event` option
|
|
98
|
+
* (which has no state per se). As such, setting this options to `false` if
|
|
99
|
+
* `event=true` does not make sens.
|
|
100
|
+
* @property {boolean} [immediate=false] - Setting this option to `true` will
|
|
101
|
+
* trigger any change (e.g. call the `onUpdate` listeners) immediately on the
|
|
102
|
+
* state that generate the update (i.e. calling `set`), before propagating the
|
|
103
|
+
* change on the network. This option can be usefull in cases the network
|
|
104
|
+
* would introduce a noticeable latency on the client. If for some reason
|
|
105
|
+
* the value is overriden server-side (e.g. in an `updateHook`) the listeners
|
|
106
|
+
* will be called again on when the "real" / final value will be received.
|
|
107
|
+
* @property {object} [metas={}] - Optionnal metadata of the parameter.
|
|
108
|
+
*/
|
|
109
|
+
/**
|
|
110
|
+
* Describe a {@link server.StateManager~schema} entry of "integer" type.
|
|
111
|
+
*
|
|
112
|
+
* @typedef {object} server.StateManager~schemaIntegerDefinition
|
|
113
|
+
* @property {string} type='integer' - Define a boolean parameter.
|
|
114
|
+
* @property {number} default - Default value of the parameter.
|
|
115
|
+
* @property {number} [min=-Infinity] - Minimum value of the parameter.
|
|
116
|
+
* @property {number} [max=+Infinity] - Maximum value of the parameter.
|
|
117
|
+
* @property {boolean} [nullable=false] - Define if the parameter is nullable. If
|
|
118
|
+
* set to `true` the parameter `default` is set to `null`.
|
|
119
|
+
* @property {boolean} [event=false] - Define if the parameter is a volatile, e.g.
|
|
120
|
+
* set its value back to `null` after propagation. When `true`, `nullable` is
|
|
121
|
+
* automatically set to `true` and `default` to `null`.
|
|
122
|
+
* @property {boolean} [filterChange=true] - Setting this option to `false` forces
|
|
123
|
+
* the propagation of a parameter even when its value do not change. It
|
|
124
|
+
* offers a kind of middle ground between the default bahavior (e.g. where
|
|
125
|
+
* only changed values are propagated) and the behavior of the `event` option
|
|
126
|
+
* (which has no state per se). As such, setting this options to `false` if
|
|
127
|
+
* `event=true` does not make sens.
|
|
128
|
+
* @property {boolean} [immediate=false] - Setting this option to `true` will
|
|
129
|
+
* trigger any change (e.g. call the `onUpdate` listeners) immediately on the
|
|
130
|
+
* state that generate the update (i.e. calling `set`), before propagating the
|
|
131
|
+
* change on the network. This option can be usefull in cases the network
|
|
132
|
+
* would introduce a noticeable latency on the client. If for some reason
|
|
133
|
+
* the value is overriden server-side (e.g. in an `updateHook`) the listeners
|
|
134
|
+
* will be called again on when the "real" / final value will be received.
|
|
135
|
+
* @property {object} [metas={}] - Optionnal metadata of the parameter.
|
|
136
|
+
*/
|
|
137
|
+
/**
|
|
138
|
+
* Describe a {@link server.StateManager~schema} entry of "float" type.
|
|
139
|
+
*
|
|
140
|
+
* @typedef {object} server.StateManager~schemaFloatDefinition
|
|
141
|
+
* @property {string} [type='float'] - Float parameter.
|
|
142
|
+
* @property {number} default - Default value.
|
|
143
|
+
* @property {number} [min=-Infinity] - Minimum value.
|
|
144
|
+
* @property {number} [max=+Infinity] - Maximum value.
|
|
145
|
+
* @property {boolean} [nullable=false] - Define if the parameter is nullable. If
|
|
146
|
+
* set to `true` the parameter `default` is set to `null`.
|
|
147
|
+
* @property {boolean} [event=false] - Define if the parameter is a volatile, e.g.
|
|
148
|
+
* set its value back to `null` after propagation. When `true`, `nullable` is
|
|
149
|
+
* automatically set to `true` and `default` to `null`.
|
|
150
|
+
* @property {boolean} [filterChange=true] - Setting this option to `false` forces
|
|
151
|
+
* the propagation of a parameter even when its value do not change. It
|
|
152
|
+
* offers a kind of middle ground between the default bahavior (e.g. where
|
|
153
|
+
* only changed values are propagated) and the behavior of the `event` option
|
|
154
|
+
* (which has no state per se). As such, setting this options to `false` if
|
|
155
|
+
* `event=true` does not make sens.
|
|
156
|
+
* @property {boolean} [immediate=false] - Setting this option to `true` will
|
|
157
|
+
* trigger any change (e.g. call the `onUpdate` listeners) immediately on the
|
|
158
|
+
* state that generate the update (i.e. calling `set`), before propagating the
|
|
159
|
+
* change on the network. This option can be usefull in cases the network
|
|
160
|
+
* would introduce a noticeable latency on the client. If for some reason
|
|
161
|
+
* the value is overriden server-side (e.g. in an `updateHook`) the listeners
|
|
162
|
+
* will be called again on when the "real" / final value will be received.
|
|
163
|
+
* @property {object} [metas={}] - Optionnal metadata of the parameter.
|
|
164
|
+
*/
|
|
165
|
+
/**
|
|
166
|
+
* Describe a {@link server.StateManager~schema} entry of "enum" type.
|
|
167
|
+
*
|
|
168
|
+
* @typedef {object} server.StateManager~schemaEnumDefinition
|
|
169
|
+
* @property {string} [type='enum'] - Enum parameter.
|
|
170
|
+
* @property {string} default - Default value of the parameter.
|
|
171
|
+
* @property {Array} list - Possible values of the parameter.
|
|
172
|
+
* @property {boolean} [nullable=false] - Define if the parameter is nullable. If
|
|
173
|
+
* set to `true` the parameter `default` is set to `null`.
|
|
174
|
+
* @property {boolean} [event=false] - Define if the parameter is a volatile, e.g.
|
|
175
|
+
* set its value back to `null` after propagation. When `true`, `nullable` is
|
|
176
|
+
* automatically set to `true` and `default` to `null`.
|
|
177
|
+
* @property {boolean} [filterChange=true] - Setting this option to `false` forces
|
|
178
|
+
* the propagation of a parameter even when its value do not change. It
|
|
179
|
+
* offers a kind of middle ground between the default bahavior (e.g. where
|
|
180
|
+
* only changed values are propagated) and the behavior of the `event` option
|
|
181
|
+
* (which has no state per se). As such, setting this options to `false` if
|
|
182
|
+
* `event=true` does not make sens.
|
|
183
|
+
* @property {boolean} [immediate=false] - Setting this option to `true` will
|
|
184
|
+
* trigger any change (e.g. call the `onUpdate` listeners) immediately on the
|
|
185
|
+
* state that generate the update (i.e. calling `set`), before propagating the
|
|
186
|
+
* change on the network. This option can be usefull in cases the network
|
|
187
|
+
* would introduce a noticeable latency on the client. If for some reason
|
|
188
|
+
* the value is overriden server-side (e.g. in an `updateHook`) the listeners
|
|
189
|
+
* will be called again on when the "real" / final value will be received.
|
|
190
|
+
* @property {object} [metas={}] - Optionnal metadata of the parameter.
|
|
191
|
+
*/
|
|
192
|
+
/**
|
|
193
|
+
* Describe a {@link server.StateManager~schema} entry of "any" type.
|
|
194
|
+
*
|
|
195
|
+
* Note that the `any` type always return a shallow copy of the state internal
|
|
196
|
+
* value. Mutating the returned value will therefore not modify the internal state.
|
|
197
|
+
*
|
|
198
|
+
* @typedef {object} server.StateManager~schemaAnyDefinition
|
|
199
|
+
* @property {string} [type='any'] - Parameter of any type.
|
|
200
|
+
* @property {*} default - Default value of the parameter.
|
|
201
|
+
* @property {boolean} [nullable=false] - Define if the parameter is nullable. If
|
|
202
|
+
* set to `true` the parameter `default` is set to `null`.
|
|
203
|
+
* @property {boolean} [event=false] - Define if the parameter is a volatile, e.g.
|
|
204
|
+
* set its value back to `null` after propagation. When `true`, `nullable` is
|
|
205
|
+
* automatically set to `true` and `default` to `null`.
|
|
206
|
+
* @property {boolean} [filterChange=true] - Setting this option to `false` forces
|
|
207
|
+
* the propagation of a parameter even when its value do not change. It
|
|
208
|
+
* offers a kind of middle ground between the default bahavior (e.g. where
|
|
209
|
+
* only changed values are propagated) and the behavior of the `event` option
|
|
210
|
+
* (which has no state per se). As such, setting this options to `false` if
|
|
211
|
+
* `event=true` does not make sens.
|
|
212
|
+
* @property {boolean} [immediate=false] - Setting this option to `true` will
|
|
213
|
+
* trigger any change (e.g. call the `onUpdate` listeners) immediately on the
|
|
214
|
+
* state that generate the update (i.e. calling `set`), before propagating the
|
|
215
|
+
* change on the network. This option can be usefull in cases the network
|
|
216
|
+
* would introduce a noticeable latency on the client. If for some reason
|
|
217
|
+
* the value is overriden server-side (e.g. in an `updateHook`) the listeners
|
|
218
|
+
* will be called again on when the "real" / final value will be received.
|
|
219
|
+
* @property {object} [metas={}] - Optionnal metadata of the parameter.
|
|
220
|
+
*/
|
|
8
221
|
/**
|
|
9
222
|
* @callback server.StateManager~ObserveCallback
|
|
10
223
|
* @async
|
|
11
|
-
* @param {
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
224
|
+
* @param {string} schemaName - name of the schema
|
|
225
|
+
* @param {number} stateId - id of the state
|
|
226
|
+
* @param {number} nodeId - id of the node that created the state
|
|
227
|
+
*/
|
|
228
|
+
/**
|
|
229
|
+
* @callback server.StateManager~updateHook
|
|
230
|
+
* @async
|
|
231
|
+
*
|
|
232
|
+
* @param {object} updates - Update object as given on a set callback, or
|
|
233
|
+
* result of the previous hook
|
|
234
|
+
* @param {object} currentValues - Current values of the state.
|
|
235
|
+
* @param {object} [context=null] - Optionnal context passed by the creator
|
|
236
|
+
* of the update.
|
|
237
|
+
*
|
|
238
|
+
* @return {object} The "real" updates to be applied on the state.
|
|
14
239
|
*/
|
|
15
240
|
/**
|
|
16
241
|
* The `StateManager` allows to create new {@link server.SharedState}s, or attach
|
|
@@ -71,9 +296,8 @@ export namespace server {
|
|
|
71
296
|
* @hideconstructor
|
|
72
297
|
*/
|
|
73
298
|
declare class StateManager extends BaseStateManager {
|
|
74
|
-
constructor();
|
|
75
299
|
_clientByNodeId: Map<any, any>;
|
|
76
|
-
|
|
300
|
+
_sharedStatePrivateById: Map<any, any>;
|
|
77
301
|
_schemas: Map<any, any>;
|
|
78
302
|
_observers: Set<any>;
|
|
79
303
|
_hooksBySchemaName: Map<any, any>;
|
|
@@ -82,10 +306,10 @@ declare class StateManager extends BaseStateManager {
|
|
|
82
306
|
*
|
|
83
307
|
* This is automatically handled by the {@link server.Server} when a client connects.
|
|
84
308
|
*
|
|
85
|
-
* @param {
|
|
309
|
+
* @param {number} nodeId - Id of the client node, as given in
|
|
86
310
|
* {@link client.StateManager}
|
|
87
|
-
* @param {
|
|
88
|
-
* client.
|
|
311
|
+
* @param {object} transport - Transport mecanism to communicate with the
|
|
312
|
+
* client. Must implement a basic EventEmitter API.
|
|
89
313
|
*
|
|
90
314
|
* @private
|
|
91
315
|
*/
|
|
@@ -95,7 +319,7 @@ declare class StateManager extends BaseStateManager {
|
|
|
95
319
|
*
|
|
96
320
|
* This is automatically handled by the {@link server.Server} when a client disconnects.
|
|
97
321
|
*
|
|
98
|
-
* @param {
|
|
322
|
+
* @param {number} nodeId - Id of the client node, as given in
|
|
99
323
|
* {@link client.StateManager}
|
|
100
324
|
*
|
|
101
325
|
* @private
|
|
@@ -105,7 +329,7 @@ declare class StateManager extends BaseStateManager {
|
|
|
105
329
|
* Register a schema from which shared states (cf. {@link common.SharedState})
|
|
106
330
|
* can be instanciated.
|
|
107
331
|
*
|
|
108
|
-
* @param {
|
|
332
|
+
* @param {string} schemaName - Name of the schema.
|
|
109
333
|
* @param {server.StateManager~schema} schema - Data structure
|
|
110
334
|
* describing the states that will be created from this schema.
|
|
111
335
|
*
|
|
@@ -129,25 +353,14 @@ declare class StateManager extends BaseStateManager {
|
|
|
129
353
|
registerSchema(schemaName: string, schema: any): void;
|
|
130
354
|
/**
|
|
131
355
|
* Delete a schema and all associated states.
|
|
356
|
+
*
|
|
132
357
|
* When a schema is deleted, all states created from this schema are deleted
|
|
133
358
|
* as well, therefore all attached clients are detached and the `onDetach`
|
|
134
359
|
* and `onDelete` callbacks are called on the related states.
|
|
135
360
|
*
|
|
136
|
-
* @param {
|
|
361
|
+
* @param {string} schemaName - Name of the schema.
|
|
137
362
|
*/
|
|
138
363
|
deleteSchema(schemaName: string): void;
|
|
139
|
-
/**
|
|
140
|
-
* @callback server.StateManager~updateHook
|
|
141
|
-
* @async
|
|
142
|
-
*
|
|
143
|
-
* @param {Object} updates - Update object as given on a set callback, or
|
|
144
|
-
* result of the previous hook
|
|
145
|
-
* @param {Object} currentValues - Current values of the state.
|
|
146
|
-
* @param {Object} [context=null] - Optionnal context passed by the creator
|
|
147
|
-
* of the update.
|
|
148
|
-
*
|
|
149
|
-
* @return {Object} The "real" updates to be applied on the state.
|
|
150
|
-
*/
|
|
151
364
|
/**
|
|
152
365
|
* Register a function for a given schema (e.g. will be applied on all states
|
|
153
366
|
* created from this schema) that will be executed before the update values
|
|
@@ -160,7 +373,7 @@ declare class StateManager extends BaseStateManager {
|
|
|
160
373
|
* server-side regarless the node on which `set` has been called and before
|
|
161
374
|
* the "actual" update of the state (e.g. before the call of `onUpdate`).
|
|
162
375
|
*
|
|
163
|
-
* @param {
|
|
376
|
+
* @param {string} schemaName - Kind of states on which applying the hook.
|
|
164
377
|
* @param {server.StateManager~updateHook} updateHook - Function
|
|
165
378
|
* called between the `set` call and the actual update.
|
|
166
379
|
*
|
|
@@ -185,6 +398,8 @@ declare class StateManager extends BaseStateManager {
|
|
|
185
398
|
* assert.deepEqual(result, { name: 'test', numUpdates: 1 });
|
|
186
399
|
*/
|
|
187
400
|
registerUpdateHook(schemaName: string, updateHook: any): Fuction;
|
|
401
|
+
[kIsObservableState](state: any): boolean;
|
|
188
402
|
}
|
|
189
|
-
import BaseStateManager from
|
|
403
|
+
import BaseStateManager from '../common/BaseStateManager.js';
|
|
404
|
+
declare const kIsObservableState: unique symbol;
|
|
190
405
|
//# sourceMappingURL=StateManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateManager.d.ts","sourceRoot":"","sources":["../../src/server/StateManager.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"StateManager.d.ts","sourceRoot":"","sources":["../../src/server/StateManager.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;wBAkCa,MAAM;;AADnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH;;;;;;GAMG;AAEH;;;;;;;;;;;GAWG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH;IAII,+BAAgC;IAChC,uCAAwC;IACxC,wBAAyB;IACzB,qBAA2B;IAC3B,kCAAmC;IAerC;;;;;;;;;;;OAWG;IACH,kBA4KC;IAED;;;;;;;;;OASG;IACH,qBAoCC;IAED;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,2BArBW,MAAM,qBAuChB;IAED;;;;;;;;OAQG;IACH,yBAFW,MAAM,QAwBhB;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACH,+BAxBW,MAAM,4BAkChB;IA5WD,0CAIC;CAyWF;6BAlrB4B,+BAA+B;AA4B5D,gDAAqE"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
declare const _default: "\nconst { parentPort } = require('node:worker_threads');\n\nlet stack = [];\nlet averageLatencyWindow = 5;\nlet averageLatencyPeriod = 2;\n\nlet intervalId = null;\nlet meanLatency = 0;\n\nlet getTime;\nlet inited = new Promise(async (resolve) => {\n module = await import('@ircam/sc-utils');\n getTime = module.getTime;\n resolve(true);\n});\n\nparentPort.on('message', async msg => {\n switch (msg.type) {\n case 'config': {\n averageLatencyWindow = msg.value.averageLatencyWindow;\n averageLatencyPeriod = msg.value.averageLatencyPeriod;\n\n await inited;\n\n // launch compute in its own loop so that the number of computation is\n // decoupled from the number of connected clients\n clearInterval(intervalId);\n intervalId = setInterval(computeAverageLatency, averageLatencyPeriod * 1000);\n break;\n }\n case 'add-measurement': {\n // compute latency considering ping and pong time are equal\n const entry = msg.value;\n entry.latency = (entry.pong - entry.ping) / 2;\n // add new measure to the stack\n stack.push(entry);\n }\n }\n});\n\nfunction computeAverageLatency() {\n const now = getTime();\n // remove old measurements from stack\n stack = stack.filter(entry => entry.pong >= now - averageLatencyWindow);\n\n // prevent dividing by zero, just return last computed value\n if (stack.length === 0) {\n parentPort.postMessage({\n type: 'computed-average-latency',\n value: meanLatency,\n });\n } else {\n // compute mean\n let sum = 0;\n stack.forEach(entry => sum += entry.latency);\n\n meanLatency = sum / stack.length;\n // send result to main thread\n parentPort.postMessage({\n type: 'computed-average-latency',\n value: meanLatency,\n });\n }\n}\n";
|
|
2
|
+
export default _default;
|
|
2
3
|
//# sourceMappingURL=audit-network-latency.worker.d.ts.map
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
declare namespace _default {
|
|
2
2
|
namespace numClients {
|
|
3
|
-
export
|
|
4
|
-
|
|
3
|
+
export let type: string;
|
|
4
|
+
let _default: {};
|
|
5
5
|
export { _default as default };
|
|
6
6
|
}
|
|
7
7
|
namespace averageNetworkLatency {
|
|
8
|
-
|
|
8
|
+
let type_1: string;
|
|
9
9
|
export { type_1 as type };
|
|
10
|
-
|
|
10
|
+
let _default_1: number;
|
|
11
11
|
export { _default_1 as default };
|
|
12
12
|
}
|
|
13
13
|
namespace averageNetworkLatencyWindow {
|
|
14
|
-
|
|
14
|
+
let type_2: string;
|
|
15
15
|
export { type_2 as type };
|
|
16
|
-
|
|
16
|
+
let _default_2: number;
|
|
17
17
|
export { _default_2 as default };
|
|
18
18
|
}
|
|
19
19
|
namespace averageNetworkLatencyPeriod {
|
|
20
|
-
|
|
20
|
+
let type_3: string;
|
|
21
21
|
export { type_3 as type };
|
|
22
|
-
|
|
22
|
+
let _default_3: number;
|
|
23
23
|
export { _default_3 as default };
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/server/crypto.js"],"names":[],"mappings":"AAuBA,8CAKC;AAED,qDAMC"}
|
package/types/server/index.d.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"promise-store.d.ts","sourceRoot":"","sources":["../../src/common/promise-store.js"],"names":[],"mappings":"AAKA,8EAKC;AAED,4DAKC;AAED,2DAKC"}
|
package/types/common/utils.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/common/utils.js"],"names":[],"mappings":"AAGA,gEAQC;AAED,4CAEC;AAED,+CAGC;AAnBD,iCAA6F"}
|