@soundworks/core 4.0.0-alpha.27 → 4.0.0-alpha.29
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/.jsdoc +3 -1
- package/CHANGELOG.md +15 -5
- package/package.json +5 -5
- package/src/client/Client.js +78 -83
- package/src/client/{Context.js → ClientContext.js} +48 -38
- package/src/client/ClientContextManager.js +115 -0
- package/src/client/{Plugin.js → ClientPlugin.js} +22 -18
- package/src/client/{PluginManager.js → ClientPluginManager.js} +39 -35
- package/src/client/{Socket.js → ClientSocket.js} +54 -65
- package/src/client/{StateManager.js → ClientStateManager.js} +7 -8
- package/src/client/index.js +17 -41
- package/src/common/BasePlugin.js +56 -51
- package/src/common/BasePluginManager.js +175 -139
- package/src/common/BaseStateManager.js +316 -120
- package/src/common/BatchedTransport.js +24 -24
- package/src/common/ParameterBag.js +18 -6
- package/src/common/PromiseStore.js +1 -0
- package/src/common/{BaseSharedState.js → SharedState.js} +271 -199
- package/src/common/{BaseSharedStateCollection.js → SharedStateCollection.js} +92 -61
- package/src/common/logger.js +5 -0
- package/src/common/shared-state-types.js +76 -0
- package/src/common/version.js +1 -1
- package/src/server/Server.js +391 -354
- package/src/server/ServerClient.js +73 -0
- package/src/server/{Context.js → ServerContext.js} +85 -66
- package/src/server/{ContextManager.js → ServerContextManager.js} +98 -85
- package/src/server/{Plugin.js → ServerPlugin.js} +10 -24
- package/src/server/{PluginManager.js → ServerPluginManager.js} +76 -69
- package/src/server/{Socket.js → ServerSocket.js} +19 -18
- package/src/server/{Sockets.js → ServerSockets.js} +36 -27
- package/src/server/ServerStateManager.js +515 -0
- package/src/{common → server}/SharedStatePrivate.js +61 -26
- package/src/server/audit-network-latency.worker.js +9 -7
- package/src/server/audit-schema.js +1 -1
- package/src/server/crypto.js +2 -0
- package/src/server/index.js +18 -21
- package/types/client/Client.d.ts +74 -95
- package/types/client/{Context.d.ts → ClientContext.d.ts} +25 -26
- package/types/client/{ContextManager.d.ts → ClientContextManager.d.ts} +19 -22
- package/types/client/{Plugin.d.ts → ClientPlugin.d.ts} +17 -20
- package/types/client/{PluginManager.d.ts → ClientPluginManager.d.ts} +13 -36
- package/types/client/ClientSocket.d.ts +74 -0
- package/types/client/{StateManager.d.ts → ClientStateManager.d.ts} +11 -15
- package/types/client/index.d.ts +26 -2
- package/types/common/BasePlugin.d.ts +52 -46
- package/types/common/BasePluginManager.d.ts +68 -44
- package/types/common/BaseStateManager.d.ts +207 -97
- package/types/common/BatchedTransport.d.ts +1 -5
- package/types/common/ParameterBag.d.ts +16 -18
- package/types/common/PromiseStore.d.ts +1 -1
- package/types/common/SharedState.d.ts +297 -0
- package/types/common/{BaseSharedStateCollection.d.ts → SharedStateCollection.d.ts} +34 -18
- package/types/common/constants.d.ts +0 -2
- package/types/common/logger.d.ts +2 -1
- package/types/common/shared-state-types.d.ts +83 -0
- package/types/common/sockets-utils.d.ts +0 -5
- package/types/common/version.d.ts +1 -2
- package/types/server/Server.d.ts +78 -132
- package/types/server/ServerClient.d.ts +45 -0
- package/types/server/{Context.d.ts → ServerContext.d.ts} +53 -43
- package/types/server/ServerContextManager.d.ts +80 -0
- package/types/server/{Plugin.d.ts → ServerPlugin.d.ts} +19 -33
- package/types/server/{PluginManager.d.ts → ServerPluginManager.d.ts} +39 -37
- package/types/server/ServerSocket.d.ts +85 -0
- package/types/server/ServerSockets.d.ts +50 -0
- package/types/server/ServerStateManager.d.ts +189 -0
- package/types/server/SharedStatePrivate.d.ts +21 -0
- package/types/server/audit-network-latency.worker.d.ts +1 -2
- package/types/server/audit-schema.d.ts +0 -1
- package/types/server/crypto.d.ts +2 -1
- package/types/server/index.d.ts +24 -2
- package/src/client/ContextManager.js +0 -111
- package/src/client/SharedState.js +0 -84
- package/src/client/SharedStateCollection.js +0 -38
- package/src/server/Client.js +0 -55
- package/src/server/SharedState.js +0 -85
- package/src/server/SharedStateCollection.js +0 -39
- package/src/server/StateManager.js +0 -696
- package/types/client/Client.d.ts.map +0 -1
- package/types/client/Context.d.ts.map +0 -1
- package/types/client/ContextManager.d.ts.map +0 -1
- package/types/client/Plugin.d.ts.map +0 -1
- package/types/client/PluginManager.d.ts.map +0 -1
- package/types/client/SharedState.d.ts +0 -85
- package/types/client/SharedState.d.ts.map +0 -1
- package/types/client/SharedStateCollection.d.ts +0 -41
- package/types/client/SharedStateCollection.d.ts.map +0 -1
- package/types/client/Socket.d.ts +0 -149
- package/types/client/Socket.d.ts.map +0 -1
- package/types/client/StateManager.d.ts.map +0 -1
- package/types/client/index.d.ts.map +0 -1
- package/types/common/BasePlugin.d.ts.map +0 -1
- package/types/common/BasePluginManager.d.ts.map +0 -1
- package/types/common/BaseSharedState.d.ts +0 -244
- package/types/common/BaseSharedState.d.ts.map +0 -1
- package/types/common/BaseSharedStateCollection.d.ts.map +0 -1
- package/types/common/BaseStateManager.d.ts.map +0 -1
- package/types/common/BatchedTransport.d.ts.map +0 -1
- package/types/common/ParameterBag.d.ts.map +0 -1
- package/types/common/PromiseStore.d.ts.map +0 -1
- package/types/common/SharedStatePrivate.d.ts +0 -21
- package/types/common/SharedStatePrivate.d.ts.map +0 -1
- package/types/common/constants.d.ts.map +0 -1
- package/types/common/logger.d.ts.map +0 -1
- package/types/common/sockets-utils.d.ts.map +0 -1
- package/types/common/version.d.ts.map +0 -1
- package/types/server/Client.d.ts +0 -45
- package/types/server/Client.d.ts.map +0 -1
- package/types/server/Context.d.ts.map +0 -1
- package/types/server/ContextManager.d.ts +0 -69
- package/types/server/ContextManager.d.ts.map +0 -1
- package/types/server/Plugin.d.ts.map +0 -1
- package/types/server/PluginManager.d.ts.map +0 -1
- package/types/server/Server.d.ts.map +0 -1
- package/types/server/SharedState.d.ts +0 -86
- package/types/server/SharedState.d.ts.map +0 -1
- package/types/server/SharedStateCollection.d.ts +0 -41
- package/types/server/SharedStateCollection.d.ts.map +0 -1
- package/types/server/Socket.d.ts +0 -164
- package/types/server/Socket.d.ts.map +0 -1
- package/types/server/Sockets.d.ts +0 -80
- package/types/server/Sockets.d.ts.map +0 -1
- package/types/server/StateManager.d.ts +0 -405
- package/types/server/StateManager.d.ts.map +0 -1
- package/types/server/audit-network-latency.worker.d.ts.map +0 -1
- package/types/server/audit-schema.d.ts.map +0 -1
- package/types/server/crypto.d.ts.map +0 -1
- package/types/server/index.d.ts.map +0 -1
|
@@ -1,54 +1,85 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @callback sharedStateCollectionOnUpdateCallback
|
|
3
|
+
* @param {SharedState} state - State that triggered the update.
|
|
4
|
+
* @param {Object} newValues - Key / value pairs of the updates that have been
|
|
5
|
+
* applied to the state.
|
|
6
|
+
* @param {Object} oldValues - Key / value pairs of the updated params before
|
|
7
|
+
* the updates has been applied to the state.
|
|
8
|
+
* @param {Mixed} [context=null] - Optionnal context object that has been passed
|
|
9
|
+
* with the values updates in the `set` call.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The `SharedStateCollection` interface represent a collection of all states
|
|
14
|
+
* created from a given schema name on the network.
|
|
15
|
+
*
|
|
16
|
+
* It can optionnaly exclude the states created by the current node.
|
|
17
|
+
*
|
|
18
|
+
* See {@link ClientStateManager#getCollection} and
|
|
19
|
+
* {@link ServerStateManager#getCollection} for factory methods API
|
|
20
|
+
*
|
|
21
|
+
* ```
|
|
22
|
+
* const collection = await client.stateManager.getCollection('my-schema');
|
|
23
|
+
* const allValues = collection.getValues();
|
|
24
|
+
* collection.onUpdate((state, newValues, oldValues, context) => {
|
|
25
|
+
* // do something
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
* @hideconstructor
|
|
29
|
+
*/
|
|
30
|
+
class SharedStateCollection {
|
|
31
|
+
#stateManager = null;
|
|
32
|
+
#schemaName = null;
|
|
33
|
+
#filter = null;
|
|
34
|
+
#options = null;
|
|
35
|
+
#schema = null;
|
|
36
|
+
#states = [];
|
|
37
|
+
#onUpdateCallbacks = new Set();
|
|
38
|
+
#onAttachCallbacks = new Set();
|
|
39
|
+
#onDetachCallbacks = new Set();
|
|
40
|
+
#unobserve = null;
|
|
41
|
+
|
|
3
42
|
constructor(stateManager, schemaName, filter = null, options = {}) {
|
|
4
|
-
this
|
|
5
|
-
this
|
|
6
|
-
this
|
|
7
|
-
this
|
|
8
|
-
|
|
9
|
-
this._schema = null;
|
|
10
|
-
this._states = [];
|
|
11
|
-
|
|
12
|
-
this._onUpdateCallbacks = new Set();
|
|
13
|
-
this._onAttachCallbacks = new Set();
|
|
14
|
-
this._onDetachCallbacks = new Set();
|
|
15
|
-
this._unobserve = null;
|
|
43
|
+
this.#stateManager = stateManager;
|
|
44
|
+
this.#schemaName = schemaName;
|
|
45
|
+
this.#filter = filter;
|
|
46
|
+
this.#options = Object.assign({ excludeLocal: false }, options);
|
|
16
47
|
}
|
|
17
48
|
|
|
18
49
|
/** @private */
|
|
19
50
|
async _init() {
|
|
20
|
-
this
|
|
51
|
+
this.#schema = await this.#stateManager.getSchema(this.#schemaName);
|
|
21
52
|
|
|
22
53
|
// if filter is set, check that it contains only valid param names
|
|
23
|
-
if (this
|
|
24
|
-
const keys = Object.keys(this
|
|
54
|
+
if (this.#filter !== null) {
|
|
55
|
+
const keys = Object.keys(this.#schema);
|
|
25
56
|
|
|
26
|
-
for (let filter of this
|
|
57
|
+
for (let filter of this.#filter) {
|
|
27
58
|
if (!keys.includes(filter)) {
|
|
28
|
-
throw new ReferenceError(`[SharedStateCollection] Invalid filter key (${filter}) for schema "${this
|
|
59
|
+
throw new ReferenceError(`[SharedStateCollection] Invalid filter key (${filter}) for schema "${this.#schemaName}"`)
|
|
29
60
|
}
|
|
30
61
|
}
|
|
31
62
|
}
|
|
32
63
|
|
|
33
|
-
this
|
|
34
|
-
const state = await this.
|
|
35
|
-
this.
|
|
64
|
+
this.#unobserve = await this.#stateManager.observe(this.#schemaName, async (schemaName, stateId) => {
|
|
65
|
+
const state = await this.#stateManager.attach(schemaName, stateId, this.#filter);
|
|
66
|
+
this.#states.push(state);
|
|
36
67
|
|
|
37
68
|
state.onDetach(() => {
|
|
38
|
-
const index = this.
|
|
39
|
-
this.
|
|
69
|
+
const index = this.#states.indexOf(state);
|
|
70
|
+
this.#states.splice(index, 1);
|
|
40
71
|
|
|
41
|
-
this.
|
|
72
|
+
this.#onDetachCallbacks.forEach(callback => callback(state));
|
|
42
73
|
});
|
|
43
74
|
|
|
44
75
|
state.onUpdate((newValues, oldValues, context) => {
|
|
45
|
-
Array.from(this
|
|
76
|
+
Array.from(this.#onUpdateCallbacks).forEach(callback => {
|
|
46
77
|
callback(state, newValues, oldValues, context);
|
|
47
78
|
});
|
|
48
79
|
});
|
|
49
80
|
|
|
50
|
-
this.
|
|
51
|
-
}, this
|
|
81
|
+
this.#onAttachCallbacks.forEach(callback => callback(state));
|
|
82
|
+
}, this.#options);
|
|
52
83
|
}
|
|
53
84
|
|
|
54
85
|
/**
|
|
@@ -57,7 +88,7 @@ class BaseSharedStateCollection {
|
|
|
57
88
|
* @readonly
|
|
58
89
|
*/
|
|
59
90
|
get length() {
|
|
60
|
-
return this.
|
|
91
|
+
return this.#states.length;
|
|
61
92
|
}
|
|
62
93
|
|
|
63
94
|
/**
|
|
@@ -66,7 +97,7 @@ class BaseSharedStateCollection {
|
|
|
66
97
|
* @readonly
|
|
67
98
|
*/
|
|
68
99
|
get size() {
|
|
69
|
-
return this.
|
|
100
|
+
return this.#states.length;
|
|
70
101
|
}
|
|
71
102
|
|
|
72
103
|
/**
|
|
@@ -75,7 +106,7 @@ class BaseSharedStateCollection {
|
|
|
75
106
|
* @readonly
|
|
76
107
|
*/
|
|
77
108
|
get schemaName() {
|
|
78
|
-
return this
|
|
109
|
+
return this.#schemaName;
|
|
79
110
|
}
|
|
80
111
|
|
|
81
112
|
/**
|
|
@@ -91,10 +122,10 @@ class BaseSharedStateCollection {
|
|
|
91
122
|
*/
|
|
92
123
|
getSchema(name = null) {
|
|
93
124
|
if (name) {
|
|
94
|
-
return this
|
|
125
|
+
return this.#schema[name];
|
|
95
126
|
}
|
|
96
127
|
|
|
97
|
-
return this
|
|
128
|
+
return this.#schema;
|
|
98
129
|
}
|
|
99
130
|
|
|
100
131
|
/**
|
|
@@ -106,8 +137,8 @@ class BaseSharedStateCollection {
|
|
|
106
137
|
*/
|
|
107
138
|
getDefaults() {
|
|
108
139
|
const defaults = {};
|
|
109
|
-
for (let name in this
|
|
110
|
-
defaults[name] = this
|
|
140
|
+
for (let name in this.#schema) {
|
|
141
|
+
defaults[name] = this.#schema[name].default;
|
|
111
142
|
}
|
|
112
143
|
return defaults;
|
|
113
144
|
}
|
|
@@ -117,7 +148,7 @@ class BaseSharedStateCollection {
|
|
|
117
148
|
* @return {Object[]}
|
|
118
149
|
*/
|
|
119
150
|
getValues() {
|
|
120
|
-
return this.
|
|
151
|
+
return this.#states.map(state => state.getValues());
|
|
121
152
|
}
|
|
122
153
|
|
|
123
154
|
/**
|
|
@@ -132,7 +163,7 @@ class BaseSharedStateCollection {
|
|
|
132
163
|
* @return {Object[]}
|
|
133
164
|
*/
|
|
134
165
|
getValuesUnsafe() {
|
|
135
|
-
return this.
|
|
166
|
+
return this.#states.map(state => state.getValues());
|
|
136
167
|
}
|
|
137
168
|
|
|
138
169
|
/**
|
|
@@ -144,7 +175,7 @@ class BaseSharedStateCollection {
|
|
|
144
175
|
get(name) {
|
|
145
176
|
// we can delegate to the state.get(name) method for throwing in case of filtered
|
|
146
177
|
// keys, as the Promise.all will reject on first reject Promise
|
|
147
|
-
return this.
|
|
178
|
+
return this.#states.map(state => state.get(name));
|
|
148
179
|
}
|
|
149
180
|
|
|
150
181
|
/**
|
|
@@ -160,7 +191,7 @@ class BaseSharedStateCollection {
|
|
|
160
191
|
getUnsafe(name) {
|
|
161
192
|
// we can delegate to the state.get(name) method for throwing in case of filtered
|
|
162
193
|
// keys, as the Promise.all will reject on first reject Promise
|
|
163
|
-
return this.
|
|
194
|
+
return this.#states.map(state => state.get(name));
|
|
164
195
|
}
|
|
165
196
|
|
|
166
197
|
/**
|
|
@@ -173,14 +204,14 @@ class BaseSharedStateCollection {
|
|
|
173
204
|
async set(updates, context = null) {
|
|
174
205
|
// we can delegate to the state.set(update) method for throwing in case of
|
|
175
206
|
// filtered keys, as the Promise.all will reject on first reject Promise
|
|
176
|
-
const promises = this.
|
|
207
|
+
const promises = this.#states.map(state => state.set(updates, context));
|
|
177
208
|
return Promise.all(promises);
|
|
178
209
|
}
|
|
179
210
|
|
|
180
211
|
/**
|
|
181
212
|
* Subscribe to any state update of the collection.
|
|
182
213
|
*
|
|
183
|
-
* @param {
|
|
214
|
+
* @param {sharedStateCollectionOnUpdateCallback}
|
|
184
215
|
* callback - Callback to execute when an update is applied on a state.
|
|
185
216
|
* @param {Boolean} [executeListener=false] - Execute the callback immediately
|
|
186
217
|
* for all underlying states with current state values. (`oldValues` will be
|
|
@@ -188,10 +219,10 @@ class BaseSharedStateCollection {
|
|
|
188
219
|
* @returns {Function} - Function that delete the registered listener.
|
|
189
220
|
*/
|
|
190
221
|
onUpdate(callback, executeListener = false) {
|
|
191
|
-
this.
|
|
222
|
+
this.#onUpdateCallbacks.add(callback);
|
|
192
223
|
|
|
193
224
|
if (executeListener === true) {
|
|
194
|
-
this.
|
|
225
|
+
this.#states.forEach(state => {
|
|
195
226
|
const currentValues = state.getValues();
|
|
196
227
|
const oldValues = {};
|
|
197
228
|
const context = null;
|
|
@@ -200,7 +231,7 @@ class BaseSharedStateCollection {
|
|
|
200
231
|
});
|
|
201
232
|
}
|
|
202
233
|
|
|
203
|
-
return () => this.
|
|
234
|
+
return () => this.#onUpdateCallbacks.delete(callback);
|
|
204
235
|
}
|
|
205
236
|
|
|
206
237
|
/**
|
|
@@ -214,12 +245,12 @@ class BaseSharedStateCollection {
|
|
|
214
245
|
*/
|
|
215
246
|
onAttach(callback, executeListener = false) {
|
|
216
247
|
if (executeListener === true) {
|
|
217
|
-
this.
|
|
248
|
+
this.#states.forEach(state => callback(state));
|
|
218
249
|
}
|
|
219
250
|
|
|
220
|
-
this.
|
|
251
|
+
this.#onAttachCallbacks.add(callback);
|
|
221
252
|
|
|
222
|
-
return () => this.
|
|
253
|
+
return () => this.#onAttachCallbacks.delete(callback);
|
|
223
254
|
}
|
|
224
255
|
|
|
225
256
|
/**
|
|
@@ -230,9 +261,9 @@ class BaseSharedStateCollection {
|
|
|
230
261
|
* @returns {Function} - Function that delete the registered listener.
|
|
231
262
|
*/
|
|
232
263
|
onDetach(callback) {
|
|
233
|
-
this.
|
|
264
|
+
this.#onDetachCallbacks.add(callback);
|
|
234
265
|
|
|
235
|
-
return () => this.
|
|
266
|
+
return () => this.#onDetachCallbacks.delete(callback);
|
|
236
267
|
}
|
|
237
268
|
|
|
238
269
|
/**
|
|
@@ -240,13 +271,13 @@ class BaseSharedStateCollection {
|
|
|
240
271
|
* @type {number}
|
|
241
272
|
*/
|
|
242
273
|
async detach() {
|
|
243
|
-
this
|
|
244
|
-
this.
|
|
274
|
+
this.#unobserve();
|
|
275
|
+
this.#onUpdateCallbacks.clear();
|
|
245
276
|
|
|
246
|
-
const promises = this.
|
|
277
|
+
const promises = this.#states.map(state => state.detach());
|
|
247
278
|
await Promise.all(promises);
|
|
248
279
|
|
|
249
|
-
this.
|
|
280
|
+
this.#onDetachCallbacks.clear();
|
|
250
281
|
}
|
|
251
282
|
|
|
252
283
|
/**
|
|
@@ -256,7 +287,7 @@ class BaseSharedStateCollection {
|
|
|
256
287
|
* Its return value is discarded.
|
|
257
288
|
*/
|
|
258
289
|
forEach(func) {
|
|
259
|
-
this.
|
|
290
|
+
this.#states.forEach(func);
|
|
260
291
|
}
|
|
261
292
|
|
|
262
293
|
/**
|
|
@@ -267,7 +298,7 @@ class BaseSharedStateCollection {
|
|
|
267
298
|
* Its return value is added as a single element in the new array.
|
|
268
299
|
*/
|
|
269
300
|
map(func) {
|
|
270
|
-
return this.
|
|
301
|
+
return this.#states.map(func);
|
|
271
302
|
}
|
|
272
303
|
|
|
273
304
|
/**
|
|
@@ -279,7 +310,7 @@ class BaseSharedStateCollection {
|
|
|
279
310
|
* alsy value otherwise.
|
|
280
311
|
*/
|
|
281
312
|
filter(func) {
|
|
282
|
-
return this.
|
|
313
|
+
return this.#states.filter(func);
|
|
283
314
|
}
|
|
284
315
|
|
|
285
316
|
/**
|
|
@@ -288,7 +319,7 @@ class BaseSharedStateCollection {
|
|
|
288
319
|
* @param {Function} func - Function that defines the sort order.
|
|
289
320
|
*/
|
|
290
321
|
sort(func) {
|
|
291
|
-
this.
|
|
322
|
+
this.#states.sort(func);
|
|
292
323
|
}
|
|
293
324
|
|
|
294
325
|
/**
|
|
@@ -300,7 +331,7 @@ class BaseSharedStateCollection {
|
|
|
300
331
|
* @return {}
|
|
301
332
|
*/
|
|
302
333
|
find(func) {
|
|
303
|
-
return this.
|
|
334
|
+
return this.#states.find(func);
|
|
304
335
|
}
|
|
305
336
|
|
|
306
337
|
/**
|
|
@@ -311,14 +342,14 @@ class BaseSharedStateCollection {
|
|
|
311
342
|
|
|
312
343
|
return {
|
|
313
344
|
next: () => {
|
|
314
|
-
if (index >= this.
|
|
345
|
+
if (index >= this.#states.length) {
|
|
315
346
|
return { value: undefined, done: true };
|
|
316
347
|
} else {
|
|
317
|
-
return { value: this
|
|
348
|
+
return { value: this.#states[index++], done: false };
|
|
318
349
|
}
|
|
319
350
|
},
|
|
320
351
|
};
|
|
321
352
|
}
|
|
322
353
|
}
|
|
323
354
|
|
|
324
|
-
export default
|
|
355
|
+
export default SharedStateCollection;
|
package/src/common/logger.js
CHANGED
|
@@ -164,6 +164,11 @@ dependencies on both your server and clients.
|
|
|
164
164
|
|
|
165
165
|
console.error(chalk.red(msg));
|
|
166
166
|
},
|
|
167
|
+
|
|
168
|
+
deprecated(oldAPI, newAPI) {
|
|
169
|
+
const msg = `[warning] '${oldAPI}' is deprecated and will be removed in next major version, please use '${newAPI}' instead`;
|
|
170
|
+
console.warn(chalk.yellow(msg));
|
|
171
|
+
}
|
|
167
172
|
};
|
|
168
173
|
|
|
169
174
|
export default logger;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User defined name for a class of {@link SharedState}
|
|
3
|
+
*
|
|
4
|
+
* @typedef {string} SharedStateClassName
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Description of a {@link SharedState} data structure that describes the structure
|
|
9
|
+
* of a class of {@link SharedState} to be registered by {@link ServerStateManager#registerSchema}
|
|
10
|
+
*
|
|
11
|
+
* A schema is the blueprint, or the definition from which shared states from a
|
|
12
|
+
* given class can be created.
|
|
13
|
+
*
|
|
14
|
+
* It consists of a set of key / value pairs where the key is the name of
|
|
15
|
+
* the parameter (cf. ${SharedStateParameterName}), and the value is an object
|
|
16
|
+
* describing the parameter (cf. ${SharedStateParameterDescription}).
|
|
17
|
+
*
|
|
18
|
+
* @typedef {Object.<SharedStateParameterName, SharedStateParameterDescription>} SharedStateClassSchema
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* const mySchema = {
|
|
22
|
+
* triggerSound: {
|
|
23
|
+
* type: 'boolean',
|
|
24
|
+
* event: true,
|
|
25
|
+
* },
|
|
26
|
+
* volume: {
|
|
27
|
+
* type: 'float'
|
|
28
|
+
* default: 0,
|
|
29
|
+
* min: -80,
|
|
30
|
+
* max: 6,
|
|
31
|
+
* }
|
|
32
|
+
* };
|
|
33
|
+
*
|
|
34
|
+
* server.stateManager.registerSchema('my-class-name', mySchema);
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* User defined name of a parameter in a class of {@link SharedState}
|
|
39
|
+
*
|
|
40
|
+
* @typedef {string} SharedStateParameterName
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Description of a parameter in a class of {@link SharedState}
|
|
45
|
+
*
|
|
46
|
+
* @typedef {object} SharedStateParameterDescription
|
|
47
|
+
* @property {'boolean'|'string'|'integer'|'float'|'enum'|'any'} type - Type of the parameter
|
|
48
|
+
* @property {any} default - Default value of the parameter. Optional only if
|
|
49
|
+
* `nullable = true` or `event = true`
|
|
50
|
+
* @property {boolean} [nullable=false] - Defines if the parameter is nullable.
|
|
51
|
+
* When `true` the parameter `default` is set to `null`.
|
|
52
|
+
* @property {boolean} [event=false] - Define if the parameter is a volatile, i.e.
|
|
53
|
+
* its value only exists on an update and is set back to `null` after propagation.
|
|
54
|
+
* When `true`, `nullable` is automatically set to `true` and `default` to `null`.
|
|
55
|
+
* @property {boolean} [filterChange=true] - When set to `false`, an update will
|
|
56
|
+
* trigger the propagation of a parameter even when its value didn't change.
|
|
57
|
+
* This option provides a sort of middle ground between the default bahavior
|
|
58
|
+
* (e.g. where only changed values are propagated) and the behavior of the `event`
|
|
59
|
+
* option (which has no state per se). Hence, setting this options to `false` if
|
|
60
|
+
* `event=true` makes no sens.
|
|
61
|
+
* @property {boolean} [immediate=false] - When set to `true`, an update will
|
|
62
|
+
* trigger the update listeners immediately on the node that generated the update,
|
|
63
|
+
* before propagating the change on the network.
|
|
64
|
+
* This option is usefull in cases the network would introduce a noticeable
|
|
65
|
+
* latency on the client.
|
|
66
|
+
* If for some reason the value is overriden server-side (e.g. in an `updateHook`)
|
|
67
|
+
* the listeners will be called again when the "real" value is received.
|
|
68
|
+
* @property {number} [min=-Number.MIN_VALUE] - Minimum value of the parameter. Only applies
|
|
69
|
+
* for `integer` and `float` types.
|
|
70
|
+
* @property {number} [max=Number.MAX_VALUE] - Maximum value of the parameter. Only applies
|
|
71
|
+
* for `integer` and `float` types.
|
|
72
|
+
* @property {Array<any>} [list] - Possible values of the parameter. Only applies and
|
|
73
|
+
* mandatory for `enum` type.
|
|
74
|
+
* @property {object} [metas={}] - Optional metadata of the parameter.
|
|
75
|
+
*/
|
|
76
|
+
|
package/src/common/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// [WARNING] This file is generated, do not edit
|
|
2
|
-
export default '4.0.0-alpha.
|
|
2
|
+
export default '4.0.0-alpha.29';
|