@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.
Files changed (87) hide show
  1. package/CHANGELOG.md +14 -3
  2. package/package.json +15 -15
  3. package/src/client/Client.js +233 -188
  4. package/src/client/Socket.js +84 -247
  5. package/src/client/index.js +6 -0
  6. package/src/common/constants.js +0 -1
  7. package/src/common/logger.js +15 -0
  8. package/src/common/sockets-utils.js +0 -63
  9. package/src/common/version.js +2 -0
  10. package/src/server/Plugin.js +22 -10
  11. package/src/server/Server.js +37 -36
  12. package/src/server/Socket.js +126 -250
  13. package/src/server/Sockets.js +103 -127
  14. package/src/server/audit-network-latency.worker.js +4 -3
  15. package/src/server/index.js +6 -0
  16. package/types/client/Client.d.ts +41 -8
  17. package/types/client/Client.d.ts.map +1 -1
  18. package/types/client/Context.d.ts +40 -14
  19. package/types/client/Context.d.ts.map +1 -1
  20. package/types/client/Plugin.d.ts +42 -41
  21. package/types/client/Plugin.d.ts.map +1 -1
  22. package/types/client/PluginManager.d.ts +26 -11
  23. package/types/client/PluginManager.d.ts.map +1 -1
  24. package/types/client/SharedState.d.ts +1 -1
  25. package/types/client/SharedState.d.ts.map +1 -1
  26. package/types/client/SharedStateCollection.d.ts +41 -0
  27. package/types/client/SharedStateCollection.d.ts.map +1 -0
  28. package/types/client/Socket.d.ts +41 -30
  29. package/types/client/Socket.d.ts.map +1 -1
  30. package/types/client/StateManager.d.ts +1 -1
  31. package/types/client/StateManager.d.ts.map +1 -1
  32. package/types/client/index.d.ts +0 -8
  33. package/types/common/BasePlugin.d.ts +24 -19
  34. package/types/common/BasePlugin.d.ts.map +1 -1
  35. package/types/common/BasePluginManager.d.ts +17 -5
  36. package/types/common/BasePluginManager.d.ts.map +1 -1
  37. package/types/common/BaseSharedState.d.ts +100 -29
  38. package/types/common/BaseSharedState.d.ts.map +1 -1
  39. package/types/common/BaseSharedStateCollection.d.ts +183 -0
  40. package/types/common/BaseSharedStateCollection.d.ts.map +1 -0
  41. package/types/common/BaseStateManager.d.ts +83 -18
  42. package/types/common/BaseStateManager.d.ts.map +1 -1
  43. package/types/common/BatchedTransport.d.ts +21 -0
  44. package/types/common/BatchedTransport.d.ts.map +1 -0
  45. package/types/common/ParameterBag.d.ts +61 -40
  46. package/types/common/ParameterBag.d.ts.map +1 -1
  47. package/types/common/PromiseStore.d.ts +11 -0
  48. package/types/common/PromiseStore.d.ts.map +1 -0
  49. package/types/common/SharedStatePrivate.d.ts +4 -3
  50. package/types/common/SharedStatePrivate.d.ts.map +1 -1
  51. package/types/common/constants.d.ts +10 -1
  52. package/types/common/constants.d.ts.map +1 -1
  53. package/types/common/logger.d.ts +1 -1
  54. package/types/common/sockets-utils.d.ts.map +1 -1
  55. package/types/common/version.d.ts +3 -0
  56. package/types/common/version.d.ts.map +1 -0
  57. package/types/server/Client.d.ts +5 -0
  58. package/types/server/Client.d.ts.map +1 -1
  59. package/types/server/Context.d.ts +162 -22
  60. package/types/server/Context.d.ts.map +1 -1
  61. package/types/server/ContextManager.d.ts +4 -4
  62. package/types/server/ContextManager.d.ts.map +1 -1
  63. package/types/server/Plugin.d.ts +56 -55
  64. package/types/server/Plugin.d.ts.map +1 -1
  65. package/types/server/PluginManager.d.ts +26 -6
  66. package/types/server/PluginManager.d.ts.map +1 -1
  67. package/types/server/Server.d.ts +207 -70
  68. package/types/server/Server.d.ts.map +1 -1
  69. package/types/server/SharedState.d.ts +1 -1
  70. package/types/server/SharedState.d.ts.map +1 -1
  71. package/types/server/SharedStateCollection.d.ts +41 -0
  72. package/types/server/SharedStateCollection.d.ts.map +1 -0
  73. package/types/server/Socket.d.ts +93 -57
  74. package/types/server/Socket.d.ts.map +1 -1
  75. package/types/server/Sockets.d.ts +32 -25
  76. package/types/server/Sockets.d.ts.map +1 -1
  77. package/types/server/StateManager.d.ts +242 -27
  78. package/types/server/StateManager.d.ts.map +1 -1
  79. package/types/server/audit-network-latency.worker.d.ts +2 -1
  80. package/types/server/audit-schema.d.ts +8 -8
  81. package/types/server/crypto.d.ts +3 -0
  82. package/types/server/crypto.d.ts.map +1 -0
  83. package/types/server/index.d.ts +0 -4
  84. package/types/common/promise-store.d.ts +0 -4
  85. package/types/common/promise-store.d.ts.map +0 -1
  86. package/types/common/utils.d.ts +0 -5
  87. package/types/common/utils.d.ts.map +0 -1
@@ -0,0 +1,183 @@
1
+ export default BaseSharedStateCollection;
2
+ /** @private */
3
+ declare class BaseSharedStateCollection {
4
+ constructor(stateManager: any, schemaName: any, filter?: any, options?: {});
5
+ _stateManager: any;
6
+ _schemaName: any;
7
+ _filter: any;
8
+ _options: {
9
+ excludeLocal: boolean;
10
+ };
11
+ _schema: any;
12
+ _states: any[];
13
+ _onUpdateCallbacks: Set<any>;
14
+ _onAttachCallbacks: Set<any>;
15
+ _onDetachCallbacks: Set<any>;
16
+ _unobserve: any;
17
+ /** @private */
18
+ private _init;
19
+ /**
20
+ * Size of the collection, alias `size`
21
+ * @type {number}
22
+ * @readonly
23
+ */
24
+ readonly get length(): number;
25
+ /**
26
+ * Size of the collection, , alias `length`
27
+ * @type {number}
28
+ * @readonly
29
+ */
30
+ readonly get size(): number;
31
+ /**
32
+ * Name of the schema from which the collection has been created.
33
+ * @type {String}
34
+ * @readonly
35
+ */
36
+ readonly get schemaName(): string;
37
+ /**
38
+ * Definition of schema from which the collection has been created.
39
+ *
40
+ * @param {string} [name=null] - If given, returns only the definition
41
+ * corresponding to the given param name.
42
+ * @throws Throws if `name` does not correspond to an existing field
43
+ * of the schema.
44
+ * @return {object}
45
+ * @example
46
+ * const schema = collection.getSchema();
47
+ */
48
+ getSchema(name?: string): object;
49
+ /**
50
+ * Get the default values as declared in the schema.
51
+ *
52
+ * @return {object}
53
+ * @example
54
+ * const defaults = state.getDefaults();
55
+ */
56
+ getDefaults(): object;
57
+ /**
58
+ * Return the current values of all the states in the collection.
59
+ * @return {Object[]}
60
+ */
61
+ getValues(): any[];
62
+ /**
63
+ * Return the current values of all the states in the collection.
64
+ *
65
+ * Similar to `getValues` but returns a reference to the underlying value in
66
+ * case of `any` type. May be usefull if the underlying value is big (e.g.
67
+ * sensors recordings, etc.) and deep cloning expensive. Be aware that if
68
+ * changes are made on the returned object, the state of your application will
69
+ * become inconsistent.
70
+ *
71
+ * @return {Object[]}
72
+ */
73
+ getValuesUnsafe(): any[];
74
+ /**
75
+ * Return the current param value of all the states in the collection.
76
+ *
77
+ * @param {String} name - Name of the parameter
78
+ * @return {any[]}
79
+ */
80
+ get(name: string): any[];
81
+ /**
82
+ * Similar to `get` but returns a reference to the underlying value in case of
83
+ * `any` type. May be usefull if the underlying value is big (e.g. sensors
84
+ * recordings, etc.) and deep cloning expensive. Be aware that if changes are
85
+ * made on the returned object, the state of your application will become
86
+ * inconsistent.
87
+ *
88
+ * @param {String} name - Name of the parameter
89
+ * @return {any[]}
90
+ */
91
+ getUnsafe(name: string): any[];
92
+ /**
93
+ * Update all states of the collection with given values.
94
+ * @param {object} updates - key / value pairs of updates to apply to the state.
95
+ * @param {mixed} [context=null] - optionnal contextual object that will be propagated
96
+ * alongside the updates of the state. The context is valid only for the
97
+ * current call and will be passed as third argument to all update listeners.
98
+ */
99
+ set(updates: object, context?: mixed): Promise<any[]>;
100
+ /**
101
+ * Subscribe to any state update of the collection.
102
+ *
103
+ * @param {server.SharedStateCollection~onUpdateCallback|client.SharedStateCollection~onUpdateCallback}
104
+ * callback - Callback to execute when an update is applied on a state.
105
+ * @param {Boolean} [executeListener=false] - Execute the callback immediately
106
+ * for all underlying states with current state values. (`oldValues` will be
107
+ * set to `{}`, and `context` to `null`)
108
+ * @returns {Function} - Function that delete the registered listener.
109
+ */
110
+ onUpdate(callback: any, executeListener?: boolean): Function;
111
+ /**
112
+ * Register a function to execute when a state is added to the collection.
113
+ *
114
+ * @param {Function} callback - callback to execute when a state is added to
115
+ * the collection.
116
+ * @param {Function} executeListener - execute the callback with the states
117
+ * already present in the collection.
118
+ * @returns {Function} - Function that delete the registered listener.
119
+ */
120
+ onAttach(callback: Function, executeListener?: Function): Function;
121
+ /**
122
+ * Register a function to execute when a state is removed from the collection.
123
+ *
124
+ * @param {Function} callback - callback to execute when a state is removed
125
+ * from the collection.
126
+ * @returns {Function} - Function that delete the registered listener.
127
+ */
128
+ onDetach(callback: Function): Function;
129
+ /**
130
+ * Detach from the collection, i.e. detach all underlying shared states.
131
+ * @type {number}
132
+ */
133
+ detach(): Promise<void>;
134
+ /**
135
+ * Execute the given function once for each states of the collection (see `Array.forEach`).
136
+ *
137
+ * @param {Function} func - A function to execute for each element in the array.
138
+ * Its return value is discarded.
139
+ */
140
+ forEach(func: Function): void;
141
+ /**
142
+ * Creates a new array populated with the results of calling a provided function
143
+ * on every state of the collection (see `Array.map`).
144
+ *
145
+ * @param {Function} func - A function to execute for each element in the array.
146
+ * Its return value is added as a single element in the new array.
147
+ */
148
+ map(func: Function): any[];
149
+ /**
150
+ * Creates a shallow copy of a portion of the collection, filtered down to just
151
+ * the estates that pass the test implemented by the provided function (see `Array.filter`).
152
+ *
153
+ * @param {Function} func - A function to execute for each element in the array.
154
+ * It should return a truthy to keep the element in the resulting array, and a f
155
+ * alsy value otherwise.
156
+ */
157
+ filter(func: Function): any[];
158
+ /**
159
+ * Sort the elements of the collection in place (see `Array.sort`).
160
+ *
161
+ * @param {Function} func - Function that defines the sort order.
162
+ */
163
+ sort(func: Function): void;
164
+ /**
165
+ * Returns the first element of the collection that satisfies the provided testing
166
+ * function. If no values satisfy the testing function, undefined is returned.
167
+ *
168
+ * @param {Function} func - Function to execute for each element in the array.
169
+ * It should return a truthy value to indicate a matching element has been found.
170
+ * @return {}
171
+ */
172
+ find(func: Function): any;
173
+ /**
174
+ * Iterable API, e.g. for use in `for .. of` loops
175
+ */
176
+ [Symbol.iterator](): {
177
+ next: () => {
178
+ value: any;
179
+ done: boolean;
180
+ };
181
+ };
182
+ }
183
+ //# sourceMappingURL=BaseSharedStateCollection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseSharedStateCollection.d.ts","sourceRoot":"","sources":["../../src/common/BaseSharedStateCollection.js"],"names":[],"mappings":";AAAA,eAAe;AACf;IACE,4EAaC;IAZC,mBAAiC;IACjC,iBAA6B;IAC7B,aAAqB;IACrB;;MAA+D;IAE/D,aAAmB;IACnB,eAAiB;IAEjB,6BAAmC;IACnC,6BAAmC;IACnC,6BAAmC;IACnC,gBAAsB;IAGxB,eAAe;IACf,cAiCC;IAED;;;;OAIG;IACH,8BAEC;IAED;;;;OAIG;IACH,4BAEC;IAED;;;;OAIG;IACH,kCAEC;IAED;;;;;;;;;;OAUG;IACH,iBARW,MAAM,GAIL,MAAM,CAUjB;IAED;;;;;;OAMG;IACH,eAJY,MAAM,CAUjB;IAED;;;OAGG;IACH,aAFY,KAAQ,CAInB;IAED;;;;;;;;;;OAUG;IACH,mBAFY,KAAQ,CAInB;IAED;;;;;OAKG;IACH,mBAFY,GAAG,EAAE,CAMhB;IAED;;;;;;;;;OASG;IACH,yBAFY,GAAG,EAAE,CAMhB;IAED;;;;;;OAMG;IACH,aALW,MAAM,mCAUhB;IAED;;;;;;;;;OASG;IACH,6DAcC;IAED;;;;;;;;OAQG;IACH,mEAQC;IAED;;;;;;OAMG;IACH,uCAIC;IAED;;;OAGG;IACH,wBAQC;IAED;;;;;OAKG;IACH,8BAEC;IAED;;;;;;OAMG;IACH,2BAEC;IAED;;;;;;;OAOG;IACH,8BAEC;IAED;;;;OAIG;IACH,2BAEC;IAED;;;;;;;OAOG;IACH,0BAEC;IAED;;OAEG;IACH;;;;;MAYC;CACF"}
@@ -1,22 +1,34 @@
1
1
  export default BaseStateManager;
2
- /**
3
- * @private
4
- */
2
+ /** @private */
5
3
  declare class BaseStateManager {
4
+ _statesById: Map<any, any>;
5
+ _cachedSchemas: Map<any, any>;
6
+ _observeListeners: Set<any>;
7
+ _observeRequestCallbacks: Map<any, any>;
8
+ _promiseStore: PromiseStore;
6
9
  /**
10
+ * Executed on `client.init`
7
11
  * @param {Number} id - Id of the node.
8
- * @param {Object} transport - Transport to use for synchronizing the state.
12
+ * @param {Object} transport - Transport to use for synchronizing the states.
9
13
  * Must implement a basic EventEmitter API.
10
14
  */
11
- constructor(id: number, transport: any);
15
+ /** @private */
16
+ private init;
12
17
  client: {
13
- id: number;
14
- transport: any;
18
+ id: any;
19
+ transport: BatchedTransport;
15
20
  };
16
- _statesById: Map<any, any>;
17
- _observeListeners: Set<any>;
18
- _cachedSchemas: Map<any, any>;
19
- _observeRequestCallbacks: Map<any, any>;
21
+ /** @private */
22
+ private _filterObserve;
23
+ /**
24
+ * Return the schema from a given registered schema name
25
+ *
26
+ * @param {String} schemaName - Name of the schema as given on registration
27
+ * (cf. ServerStateManager)
28
+ * @example
29
+ * const schema = await client.stateManager.getSchema('my-schema');
30
+ */
31
+ getSchema(schemaName: string): Promise<any>;
20
32
  /**
21
33
  * Create a `SharedState` instance from a registered schema.
22
34
  *
@@ -33,38 +45,91 @@ declare class BaseStateManager {
33
45
  /**
34
46
  * Attach to an existing `SharedState` instance.
35
47
  *
48
+ * Alternative signatures:
49
+ * - `stateManager.attach(schemaName)`
50
+ * - `stateManager.attach(schemaName, stateId)`
51
+ * - `stateManager.attach(schemaName, filter)`
52
+ * - `stateManager.attach(schemaName, stateId, filter)`
53
+ *
36
54
  * @param {String} schemaName - Name of the schema as given on registration
37
55
  * (cf. ServerStateManager)
38
56
  * @param {Object} [stateId=null] - Id of the state to attach to. If `null`,
39
57
  * attach to the first state found with the given schema name (usefull for
40
58
  * globally shared states owned by the server).
59
+ * @param {array|null} [filter=null] - Filter parameters of interest in the
60
+ * returned state. If set to `null`, no filter applied.
41
61
  * @returns {client.SharedState|server.SharedState}
42
62
  * @see {@link client.SharedState}
43
63
  * @see {@link server.SharedState}
64
+ *
44
65
  * @example
45
66
  * const state = await client.stateManager.attach('my-schema');
46
67
  */
47
- attach(schemaName: string, stateId?: any): client.SharedState | server.SharedState;
68
+ attach(schemaName: string, stateIdOrFilter?: any, filter?: any[] | null, ...args: any[]): client.SharedState | server.SharedState;
48
69
  /**
49
70
  * Observe all the `SharedState` instances that are created on the network.
50
71
  * This can be usefull for clients with some controller role that might want to track
51
72
  * the state of all other clients of the application, to monitor them and/or take
52
73
  * control over them from a single point.
53
74
  *
54
- * @todo Optionnal schema name
75
+ * Notes:
76
+ * - The order of execution is not guaranted between nodes, i.e. an state attached
77
+ * in the `observe` callback could be created before the `async create` method resolves.
78
+ * - Filtering, i.e. `observedSchemaName` and `options.excludeLocal` are handled
79
+ * on the node side, the server just notify all state creation activity and
80
+ * the node executes the given callbacks according to the different filter rules.
81
+ * Such strategy allows to share the observe notifications between all observers.
82
+ *
83
+ * Alternative signatures:
84
+ * - `stateManager.observe(callback)`
85
+ * - `stateManager.observe(schemaName, callback)`
86
+ * - `stateManager.observe(callback, options)`
87
+ * - `stateManager.observe(schemaName, callback, options)`
88
+ *
89
+ * @param {string} [schemaName] - optionnal schema name to filter the observed
90
+ * states.
55
91
  * @param {server.StateManager~ObserveCallback|client.StateManager~ObserveCallback}
56
92
  * callback - Function to be called when a new state is created on the network.
57
- * @returns {Promise<Function>} - Return a Promise that resolves when the callback
58
- * as been executed for the first time. The promise value is a function which
59
- * allows to stop observing the network.
93
+ * @param {object} options - Options.
94
+ * @param {boolean} [options.excludeLocal = false] - If set to true, exclude states
95
+ * created locallly, i.e. by the same node, from the collection.
96
+ * @returns {Promise<Function>} - Returns a Promise that resolves when the given
97
+ * callback as been executed on each existing states. The promise value is a
98
+ * function which allows to stop observing the states on the network.
99
+ *
60
100
  * @example
61
- * client.stateManager.observe(async (schemaName, stateId, nodeId) => {
101
+ * client.stateManager.observe(async (schemaName, stateId) => {
62
102
  * if (schemaName === 'something') {
63
103
  * const state = await this.client.stateManager.attach(schemaName, stateId);
64
104
  * console.log(state.getValues());
65
105
  * }
66
106
  * });
67
107
  */
68
- observe(callback: any): Promise<Function>;
108
+ observe(...args: any[]): Promise<Function>;
109
+ /**
110
+ * Returns a collection of all the states created from the schema name.
111
+ *
112
+ * Alternitive signatures:
113
+ * - `stateManager.getCollection(schemaName)`
114
+ * - `stateManager.getCollection(schemaName, filter)`
115
+ * - `stateManager.getCollection(schemaName, options)`
116
+ * - `stateManager.getCollection(schemaName, filter, options)`
117
+ *
118
+ * @param {string} schemaName - Name of the schema.
119
+ * @param {array|null} [filter=null] - Filter parameter of interest for each
120
+ * state of the collection. If set to `null`, no filter applied.
121
+ * @param {object} [options={}] - Options.
122
+ * @param {boolean} [options.excludeLocal=false] - If set to true, exclude states
123
+ * created by the same node from the collection.
124
+ * @returns {server.SharedStateCollection|client.SharedStateCollection}
125
+ *
126
+ * @example
127
+ * const collection = await client.stateManager.getCollection(schemaName);
128
+ */
129
+ getCollection(schemaName: string, filterOrOptions?: any, options?: {
130
+ excludeLocal?: boolean;
131
+ }, ...args: any[]): server.SharedStateCollection | client.SharedStateCollection;
69
132
  }
133
+ import PromiseStore from './PromiseStore.js';
134
+ import BatchedTransport from './BatchedTransport.js';
70
135
  //# sourceMappingURL=BaseStateManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseStateManager.d.ts","sourceRoot":"","sources":["../../src/common/BaseStateManager.js"],"names":[],"mappings":";AAoBA;;GAEG;AACH;IACE;;;;OAIG;IACH,wCA4FC;IA3FC;;;MAA+B;IAE/B,2BAA4B;IAC5B,4BAAkC;IAClC,8BAA+B;IAC/B,wCAAyC;IAwF3C;;;;;;;;;;;OAWG;IACH,8CANa,uCAAqC,CAYjD;IAED;;;;;;;;;;;;;OAaG;IACH,2CANa,uCAAqC,CAajD;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,wBAXa,iBAAiB,CAoB7B;CACF"}
1
+ {"version":3,"file":"BaseStateManager.d.ts","sourceRoot":"","sources":["../../src/common/BaseStateManager.js"],"names":[],"mappings":";AAwBA,eAAe;AACf;IAEI,2BAA4B;IAC5B,8BAA+B;IAE/B,4BAAkC;IAClC,wCAAyC;IAEzC,4BAAuC;IAGzC;;;;;OAKG;IACH,eAAe;IACf,aAgIC;IA9HC;;;MAAiD;IAgInD,eAAe;IACf,uBAYC;IAED;;;;;;;OAOG;IACH,4CAYC;IAED;;;;;;;;;;;OAWG;IACH,8CANa,uCAAqC,CAYjD;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,2DATW,QAAM,IAAI,mBAER,uCAAqC,CA8CjD;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsCG;IAIH,yBAfa,iBAAiB,CAsH7B;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,0BAXW,MAAM;QAIY,YAAY,GAA9B,OAAO;wBAEL,2DAAyD,CA2CrE;CACF;yBA/ewB,mBAAmB;6BAFf,uBAAuB"}
@@ -0,0 +1,21 @@
1
+ export default BatchedTransport;
2
+ /**
3
+ * This class proxies transports given the SharedStateManager to batch messages
4
+ *
5
+ * @param {number} [options.wait=0] - Wait for given number of milliseconds
6
+ * for stacking messages before emitting on the network. If 0 is given, network
7
+ * message is emitted on next microtask
8
+ * @private
9
+ */
10
+ declare class BatchedTransport {
11
+ constructor(transport: any);
12
+ _transport: any;
13
+ _listeners: Map<any, any>;
14
+ _stack: any[];
15
+ _sending: boolean;
16
+ addListener(channel: any, callback: any): void;
17
+ emit(channel: any, ...args: any[]): Promise<void>;
18
+ removeListener(channel: any, callback: any): void;
19
+ removeAllListeners(channel?: any): void;
20
+ }
21
+ //# sourceMappingURL=BatchedTransport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BatchedTransport.d.ts","sourceRoot":"","sources":["../../src/common/BatchedTransport.js"],"names":[],"mappings":";AAIA;;;;;;;GAOG;AACH;IACE,4BAkBC;IAjBC,gBAA2B;IAC3B,0BAA2B;IAC3B,cAAgB;IAChB,kBAAqB;IAgBvB,+CAOC;IAED,kDAWC;IAED,kDAKC;IAED,wCAOC;CACF"}
@@ -1,69 +1,62 @@
1
1
  export namespace sharedOptions {
2
- const nullable: boolean;
3
- const event: boolean;
4
- const metas: {};
5
- const filterChange: boolean;
6
- const immediate: boolean;
2
+ let nullable: boolean;
3
+ let event: boolean;
4
+ let metas: {};
5
+ let filterChange: boolean;
6
+ let immediate: boolean;
7
7
  }
8
8
  export namespace types {
9
9
  export namespace boolean {
10
- const required: string[];
10
+ let required: string[];
11
+ const defaultOptions: any;
11
12
  function coerceFunction(name: any, def: any, value: any): boolean;
12
13
  }
13
14
  export namespace string {
14
- const required_1: string[];
15
+ let required_1: string[];
15
16
  export { required_1 as required };
17
+ const defaultOptions_1: any;
18
+ export { defaultOptions_1 as defaultOptions };
16
19
  export function coerceFunction_1(name: any, def: any, value: any): string;
17
20
  export { coerceFunction_1 as coerceFunction };
18
21
  }
19
22
  export namespace integer {
20
- const required_2: string[];
23
+ let required_2: string[];
21
24
  export { required_2 as required };
25
+ const defaultOptions_2: any;
26
+ export { defaultOptions_2 as defaultOptions };
22
27
  export function sanitizeSchema(def: any): any;
23
28
  export function coerceFunction_2(name: any, def: any, value: any): number;
24
29
  export { coerceFunction_2 as coerceFunction };
25
30
  }
26
31
  export namespace float {
27
- const required_3: string[];
32
+ let required_3: string[];
28
33
  export { required_3 as required };
34
+ const defaultOptions_3: any;
35
+ export { defaultOptions_3 as defaultOptions };
29
36
  export function sanitizeSchema_1(def: any): any;
30
37
  export { sanitizeSchema_1 as sanitizeSchema };
31
38
  export function coerceFunction_3(name: any, def: any, value: any): number;
32
39
  export { coerceFunction_3 as coerceFunction };
33
40
  }
34
41
  export namespace _enum {
35
- const required_4: string[];
42
+ let required_4: string[];
36
43
  export { required_4 as required };
44
+ const defaultOptions_4: any;
45
+ export { defaultOptions_4 as defaultOptions };
37
46
  export function coerceFunction_4(name: any, def: any, value: any): any;
38
47
  export { coerceFunction_4 as coerceFunction };
39
48
  }
40
49
  export { _enum as enum };
41
50
  export namespace any {
42
- const required_5: string[];
51
+ let required_5: string[];
43
52
  export { required_5 as required };
53
+ const defaultOptions_5: any;
54
+ export { defaultOptions_5 as defaultOptions };
44
55
  export function coerceFunction_5(name: any, def: any, value: any): any;
45
56
  export { coerceFunction_5 as coerceFunction };
46
57
  }
47
58
  }
48
59
  export default ParameterBag;
49
- export namespace server {
50
- /**
51
- * ~schema
52
- *
53
- * Description of a schema to be register by the {@link server.ServerStateManagerServer }
54
- * A schema consists of a combinaison of key value pairs where the key is the
55
- * name of the parameter, and the value is an object describing the parameter.
56
- *
57
- * Available types are:
58
- * - {@link server.SharedStateManagerServer ~schemaBooleanDef}
59
- * - {@link server.SharedStateManagerServer ~schemaStringDef}
60
- * - {@link server.SharedStateManagerServer ~schemaIntegerDef}
61
- * - {@link server.SharedStateManagerServer ~schemaFloatDef}
62
- * - {@link server.SharedStateManagerServer ~schemaEnumDef}
63
- * - {@link server.SharedStateManagerServer ~schemaAnyDef}
64
- */
65
- type SharedStateManagerServer = any;
66
- }
67
60
  /**
68
61
  * Bag of parameters.
69
62
  * @private
@@ -94,33 +87,61 @@ declare class ParameterBag {
94
87
  /**
95
88
  * Define if the parameter exists.
96
89
  *
97
- * @param {String} name - Name of the parameter.
90
+ * @param {string} name - Name of the parameter.
98
91
  * @return {Boolean}
99
92
  */
100
93
  has(name: string): boolean;
101
94
  /**
102
- * Return values of all parameters as a flat object.
95
+ * Return values of all parameters as a flat object. If a parameter is of `any`
96
+ * type, a deep copy is made.
103
97
  *
104
- * @return {Object}
98
+ * @return {object}
105
99
  */
106
- getValues(): any;
100
+ getValues(): object;
101
+ /**
102
+ * Return values of all parameters as a flat object. Similar to `getValues` but
103
+ * returns a reference to the underlying value in case of `any` type. May be
104
+ * usefull if the underlying value is big (e.g. sensors recordings, etc.) and
105
+ * deep cloning expensive. Be aware that if changes are made on the returned
106
+ * object, the state of your application will become inconsistent.
107
+ *
108
+ * @return {object}
109
+ */
110
+ getValuesUnsafe(): object;
107
111
  /**
108
112
  * Return the value of the given parameter. If the parameter is of `any` type,
109
113
  * a deep copy is returned.
110
114
  *
111
- * @param {String} name - Name of the parameter.
115
+ * @param {string} name - Name of the parameter.
112
116
  * @return {Mixed} - Value of the parameter.
113
117
  */
114
118
  get(name: string): Mixed;
119
+ /**
120
+ * Similar to `get` but returns a reference to the underlying value in case of
121
+ * `any` type. May be usefull if the underlying value is big (e.g. sensors
122
+ * recordings, etc.) and deep cloning expensive. Be aware that if changes are
123
+ * made on the returned object, the state of your application will become
124
+ * inconsistent.
125
+ *
126
+ * @param {string} name - Name of the parameter.
127
+ * @return {Mixed} - Value of the parameter.
128
+ */
129
+ getUnsafe(name: string): Mixed;
130
+ /**
131
+ * Check that the value is valid according to the schema and return it coerced
132
+ * to the schema definition
133
+ *
134
+ * @param {String} name - Name of the parameter.
135
+ * @param {Mixed} value - Value of the parameter.
136
+ */
137
+ coerceValue(name: string, value: Mixed): Mixed;
115
138
  /**
116
139
  * Set the value of a parameter. If the value of the parameter is updated
117
140
  * (aka if previous value is different from new value) all registered
118
141
  * callbacks are registered.
119
142
  *
120
- * @param {String} name - Name of the parameter.
143
+ * @param {string} name - Name of the parameter.
121
144
  * @param {Mixed} value - Value of the parameter.
122
- * @param {Boolean} [forcePropagation=false] - if true, propagate value even
123
- * if the value has not changed.
124
145
  * @return {Array} - [new value, updated flag].
125
146
  */
126
147
  set(name: string, value: Mixed): any[];
@@ -129,14 +150,14 @@ declare class ParameterBag {
129
150
  * @note - prefer `state.set(state.getInitValues())`
130
151
  * or `state.set(state.getDefaultValues())`
131
152
  *
132
- * @param {String} [name=null] - Name of the parameter to reset.
153
+ * @param {string} [name=null] - Name of the parameter to reset.
133
154
  */
134
155
  /**
135
156
  * Return the given schema along with the initialization values.
136
157
  *
137
- * @return {Object}
158
+ * @return {object}
138
159
  */
139
- getSchema(name?: any): any;
160
+ getSchema(name?: any): object;
140
161
  getInitValues(): {};
141
162
  getDefaults(): {};
142
163
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ParameterBag.d.ts","sourceRoot":"","sources":["../../src/common/ParameterBag.js"],"names":[],"mappings":";;;;;;;;;;QA8MoB,kEAMf;;;;;QAOe,0EAMf;;;;;;QAUe,8CAgBf;QACe,0EAMf;;;;;;QAUe,gDAgBf;;QACe,0EAMf;;;;;;QAOe,uEAOf;;;;;;;QAOe,uEAGf;;;;;;;;;;;;;;;;;;;;;;;AAKL;;;GAGG;AACH;IACE,yCAsBC;IAED,0CAsEC;IA9DC;;;;;;;;OAQG;IACH,gBAAiB;IAEjB;;;;;;;;OAQG;IACH,gBAAiB;IA4CnB;;;;;OAKG;IACH,2BAEC;IAED;;;;OAIG;IACH,iBAQC;IAED;;;;;;OAMG;IACH,yBAUC;IAED;;;;;;;;;;OAUG;IACH,uCAuBC;IAED;;;;;;OAMG;IAWH;;;;OAIG;IACH,2BAUC;IAGD,oBAMC;IAGD,kBAMC;CACF"}
1
+ {"version":3,"file":"ParameterBag.d.ts","sourceRoot":"","sources":["../../src/common/ParameterBag.js"],"names":[],"mappings":";;;;;;;;;;;QAiBoB,kEAMf;;;;;;;QAOe,0EAMf;;;;;;;;QAUe,8CAgBf;QACe,0EAMf;;;;;;;;QAUe,gDAgBf;;QACe,0EAMf;;;;;;;;QAOe,uEAOf;;;;;;;;;QAOe,uEAGf;;;;;AAKL;;;GAGG;AACH;IACE,yCAsBC;IAED,0CAqEC;IA7DC;;;;;;;;OAQG;IACH,gBAAiB;IAEjB;;;;;;;;OAQG;IACH,gBAAiB;IA2CnB;;;;;OAKG;IACH,UAHW,MAAM,WAKhB;IAED;;;;;OAKG;IACH,aAFY,MAAM,CAUjB;IAED;;;;;;;;OAQG;IACH,mBAFY,MAAM,CAUjB;IAED;;;;;;OAMG;IACH,UAHW,MAAM,SAehB;IAED;;;;;;;;;OASG;IACH,gBAHW,MAAM,SAShB;IAED;;;;;;OAMG;IACH,+CAiBC;IAED;;;;;;;;OAQG;IACH,UAJW,MAAM,uBAsBhB;IAED;;;;;;OAMG;IAWH;;;;OAIG;IACH,uBAFY,MAAM,CAYjB;IAGD,oBAQC;IAGD,kBAQC;CACF"}
@@ -0,0 +1,11 @@
1
+ export default class PromiseStore {
2
+ constructor(name: any);
3
+ name: any;
4
+ store: Map<any, any>;
5
+ generateRequestId: any;
6
+ add(resolve: any, reject: any, type: any, localParams: any): any;
7
+ resolve(reqId: any, data: any): void;
8
+ reject(reqId: any, msg: any): void;
9
+ flush(): void;
10
+ }
11
+ //# sourceMappingURL=PromiseStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PromiseStore.d.ts","sourceRoot":"","sources":["../../src/common/PromiseStore.js"],"names":[],"mappings":"AAEA;IACE,uBAIC;IAHC,UAAgB;IAChB,qBAAsB;IACtB,uBAAsC;IAGxC,iEAKC;IAED,qCAcC;IAED,mCASC;IAGD,cAOC;CACF"}
@@ -1,7 +1,8 @@
1
1
  export default SharedStatePrivate;
2
2
  /**
3
3
  * The "real" state, this instance is kept private by the server.StateManager.
4
- * It cannot be accessed without a SharedState proxy
4
+ * It can only be accessed through a SharedState proxy.
5
+ *
5
6
  * @private
6
7
  */
7
8
  declare class SharedStatePrivate {
@@ -13,8 +14,8 @@ declare class SharedStatePrivate {
13
14
  _attachedClients: Map<any, any>;
14
15
  _creatorRemoteId: any;
15
16
  _creatorId: any;
16
- _attachClient(remoteId: any, client: any, isOwner?: boolean): void;
17
+ _attachClient(remoteId: any, client: any, isOwner: any, filter: any): void;
17
18
  _detachClient(remoteId: any, client: any): void;
18
19
  }
19
- import ParameterBag from "../common/ParameterBag.js";
20
+ import ParameterBag from '../common/ParameterBag.js';
20
21
  //# sourceMappingURL=SharedStatePrivate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SharedStatePrivate.d.ts","sourceRoot":"","sources":["../../src/common/SharedStatePrivate.js"],"names":[],"mappings":";AAaA;;;;GAIG;AACH;IACE,kFAUC;IATC,QAAY;IACZ,gBAA4B;IAE5B,cAAuB;IACvB,0BAAuD;IACvD,gCAAiC;IAEjC,sBAA4B;IAC5B,gBAAsB;IAGxB,mEAmJC;IAED,gDAMC;CACF"}
1
+ {"version":3,"file":"SharedStatePrivate.d.ts","sourceRoot":"","sources":["../../src/common/SharedStatePrivate.js"],"names":[],"mappings":";AAgCA;;;;;GAKG;AACH;IACE,kFAUC;IATC,QAAY;IACZ,gBAA4B;IAE5B,cAAuB;IACvB,0BAAuD;IACvD,gCAAiC;IAEjC,sBAA4B;IAC5B,gBAAsB;IAGxB,2EAwKC;IAED,gDAMC;CACF;yBApOwB,2BAA2B"}
@@ -1,4 +1,9 @@
1
1
  export const SERVER_ID: -1;
2
+ export const PING_INTERVAL: number;
3
+ export const PING_LATENCY_TOLERANCE: 1000;
4
+ export const PING_MESSAGE: "h:ping";
5
+ export const PONG_MESSAGE: "h:pong";
6
+ export const BATCHED_TRANSPORT_CHANNEL: "b:t";
2
7
  export const CREATE_REQUEST: "s:c:req";
3
8
  export const CREATE_RESPONSE: "s:c:res";
4
9
  export const CREATE_ERROR: "s:c:err";
@@ -14,6 +19,7 @@ export const DETACH_RESPONSE: "s:dt:res";
14
19
  export const DETACH_ERROR: "s:dt:err";
15
20
  export const OBSERVE_REQUEST: "s:o:req";
16
21
  export const OBSERVE_RESPONSE: "s:o:res";
22
+ export const OBSERVE_ERROR: "s:o:err";
17
23
  export const OBSERVE_NOTIFICATION: "s:o:not";
18
24
  export const UNOBSERVE_NOTIFICATION: "s:uo:not";
19
25
  export const UPDATE_REQUEST: "s:u:req";
@@ -21,6 +27,9 @@ export const UPDATE_RESPONSE: "s:u:res";
21
27
  export const UPDATE_ABORT: "s:u:ab";
22
28
  export const UPDATE_NOTIFICATION: "s:u:not";
23
29
  export const DELETE_SCHEMA: "s:d:s";
30
+ export const GET_SCHEMA_REQUEST: "s:s:req";
31
+ export const GET_SCHEMA_RESPONSE: "s:s:res";
32
+ export const GET_SCHEMA_ERROR: "s:s:err";
24
33
  export const CONTEXT_ENTER_REQUEST: "c:en:req";
25
34
  export const CONTEXT_ENTER_RESPONSE: "c:en:res";
26
35
  export const CONTEXT_ENTER_ERROR: "c:en:err";
@@ -30,6 +39,6 @@ export const CONTEXT_EXIT_ERROR: "c:ex:err";
30
39
  export const CLIENT_HANDSHAKE_REQUEST: "cl:h:req";
31
40
  export const CLIENT_HANDSHAKE_RESPONSE: "cl:h:res";
32
41
  export const CLIENT_HANDSHAKE_ERROR: "cl:h:err";
33
- export const AUDIT_STATE_NAME: "s:c:audit";
42
+ export const AUDIT_STATE_NAME: "p:s:audit";
34
43
  export const PRIVATE_STATES: string[];
35
44
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/common/constants.js"],"names":[],"mappings":"AACA,2BAA4B;AAG5B,uCAAwC;AACxC,wCAAyC;AACzC,qCAAsC;AAEtC,wCAAyC;AACzC,yCAA0C;AAC1C,sCAAuC;AACvC,6CAA8C;AAE9C,uCAAwC;AACxC,wCAAyC;AACzC,qCAAsC;AAEtC,wCAAyC;AACzC,yCAA0C;AAC1C,sCAAuC;AAEvC,wCAAyC;AACzC,yCAA0C;AAC1C,6CAA8C;AAE9C,gDAAiD;AAEjD,uCAAwC;AACxC,wCAAyC;AACzC,oCAAqC;AACrC,4CAA6C;AAE7C,oCAAqC;AAGrC,+CAAgD;AAChD,gDAAiD;AACjD,6CAA8C;AAE9C,8CAA+C;AAC/C,+CAAgD;AAChD,4CAA6C;AAG7C,kDAAmD;AACnD,mDAAoD;AACpD,gDAAiD;AAGjD,2CAA4C;AAC5C,sCAAiD"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/common/constants.js"],"names":[],"mappings":"AACA,2BAA4B;AAE5B,mCAAuC;AACvC,0CAA2C;AAC3C,oCAAqC;AACrC,oCAAqC;AAGrC,8CAA+C;AAG/C,uCAAwC;AACxC,wCAAyC;AACzC,qCAAsC;AAEtC,wCAAyC;AACzC,yCAA0C;AAC1C,sCAAuC;AACvC,6CAA8C;AAE9C,uCAAwC;AACxC,wCAAyC;AACzC,qCAAsC;AAEtC,wCAAyC;AACzC,yCAA0C;AAC1C,sCAAuC;AAEvC,wCAAyC;AACzC,yCAA0C;AAC1C,sCAAuC;AACvC,6CAA8C;AAE9C,gDAAiD;AAEjD,uCAAwC;AACxC,wCAAyC;AACzC,oCAAqC;AACrC,4CAA6C;AAE7C,oCAAqC;AAErC,2CAA4C;AAC5C,4CAA6C;AAC7C,yCAA0C;AAG1C,+CAAgD;AAChD,gDAAiD;AACjD,6CAA8C;AAE9C,8CAA+C;AAC/C,+CAAgD;AAChD,4CAA6C;AAG7C,kDAAmD;AACnD,mDAAoD;AACpD,gDAAiD;AAGjD,2CAA4C;AAC5C,sCAAiD"}
@@ -1,6 +1,6 @@
1
1
  export default logger;
2
2
  declare namespace logger {
3
- const verbose: boolean;
3
+ let verbose: boolean;
4
4
  function configure(verbose: any): void;
5
5
  function title(msg: any): void;
6
6
  function clientConfigAndRouting(routes: any, config: any): void;
@@ -1 +1 @@
1
- {"version":3,"file":"sockets-utils.d.ts","sourceRoot":"","sources":["../../src/common/sockets-utils.js"],"names":[],"mappings":"AAsBA,eAAe;AACf,4EAqBC;AAED,eAAe;AACf,wDAeC;AAED,eAAe;AACf,wEAEC;AAED,eAAe;AACf,oDAEC"}
1
+ {"version":3,"file":"sockets-utils.d.ts","sourceRoot":"","sources":["../../src/common/sockets-utils.js"],"names":[],"mappings":"AAqBA,eAAe;AACf,4EAqBC;AAED,eAAe;AACf,wDAeC;AAED,eAAe;AACf,wEAEC;AAED,eAAe;AACf,oDAEC"}
@@ -0,0 +1,3 @@
1
+ declare const _default: "4.0.0-alpha.22";
2
+ export default _default;
3
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/common/version.js"],"names":[],"mappings":""}