@soundworks/core 4.0.0-alpha.9 → 5.0.0

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 (144) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/README.md +14 -29
  3. package/package.json +24 -42
  4. package/src/client/Client.js +306 -256
  5. package/src/client/{Context.js → ClientContext.js} +63 -54
  6. package/src/client/ClientContextManager.js +115 -0
  7. package/src/client/{Plugin.js → ClientPlugin.js} +23 -19
  8. package/src/client/{PluginManager.js → ClientPluginManager.js} +43 -40
  9. package/src/client/ClientSocket.js +270 -0
  10. package/src/client/{StateManager.js → ClientStateManager.js} +13 -13
  11. package/src/client/index.js +36 -39
  12. package/src/common/BasePlugin.js +63 -58
  13. package/src/common/BasePluginManager.js +191 -142
  14. package/src/common/BaseStateManager.js +635 -145
  15. package/src/common/BatchedTransport.js +73 -0
  16. package/src/common/ParameterBag.js +90 -93
  17. package/src/common/PromiseStore.js +54 -0
  18. package/src/common/SharedState.js +821 -0
  19. package/src/common/SharedStateCollection.js +492 -0
  20. package/src/common/constants.js +14 -2
  21. package/src/common/logger.js +64 -68
  22. package/src/common/shared-state-types.js +82 -0
  23. package/src/common/sockets-utils.js +0 -64
  24. package/src/common/version.js +2 -0
  25. package/src/server/Server.js +552 -824
  26. package/src/server/ServerClient.js +74 -0
  27. package/src/server/{Context.js → ServerContext.js} +96 -77
  28. package/src/server/{ContextManager.js → ServerContextManager.js} +107 -87
  29. package/src/server/{Plugin.js → ServerPlugin.js} +30 -32
  30. package/src/server/ServerPluginManager.js +177 -0
  31. package/src/server/ServerSocket.js +256 -0
  32. package/src/server/ServerSockets.js +150 -0
  33. package/src/server/ServerStateManager.js +706 -0
  34. package/src/server/SharedStatePrivate.js +277 -0
  35. package/src/server/audit-network-latency.worker.js +19 -4
  36. package/src/server/{audit-schema.js → audit-state-class-description.js} +3 -2
  37. package/src/server/create-http-server.js +127 -0
  38. package/src/server/crypto.js +8 -7
  39. package/src/server/index.js +60 -17
  40. package/types/client/Client.d.ts +95 -70
  41. package/types/client/{Context.d.ts → ClientContext.d.ts} +59 -34
  42. package/types/client/{ContextManager.d.ts → ClientContextManager.d.ts} +19 -22
  43. package/types/client/ClientPlugin.d.ts +51 -0
  44. package/types/client/ClientPluginManager.d.ts +112 -0
  45. package/types/client/ClientSocket.d.ts +76 -0
  46. package/types/client/{StateManager.d.ts → ClientStateManager.d.ts} +18 -21
  47. package/types/client/index.d.ts +33 -6
  48. package/types/common/BasePlugin.d.ts +64 -53
  49. package/types/common/BasePluginManager.d.ts +84 -39
  50. package/types/common/BaseStateManager.d.ts +227 -49
  51. package/types/common/BatchedTransport.d.ts +17 -0
  52. package/types/common/ParameterBag.d.ts +73 -76
  53. package/types/common/PromiseStore.d.ts +11 -0
  54. package/types/common/SharedState.d.ts +291 -0
  55. package/types/common/SharedStateCollection.d.ts +311 -0
  56. package/types/common/constants.d.ts +10 -3
  57. package/types/common/logger.d.ts +8 -6
  58. package/types/common/shared-state-types.d.ts +95 -0
  59. package/types/common/sockets-utils.d.ts +0 -5
  60. package/types/common/version.d.ts +2 -0
  61. package/types/server/Server.d.ts +215 -136
  62. package/types/server/ServerClient.d.ts +45 -0
  63. package/types/server/ServerContext.d.ts +209 -0
  64. package/types/server/ServerContextManager.d.ts +75 -0
  65. package/types/server/ServerPlugin.d.ts +57 -0
  66. package/types/server/ServerPluginManager.d.ts +115 -0
  67. package/types/server/ServerSocket.d.ts +69 -0
  68. package/types/server/ServerSockets.d.ts +42 -0
  69. package/types/server/ServerStateManager.d.ts +284 -0
  70. package/types/server/SharedStatePrivate.d.ts +23 -0
  71. package/types/server/audit-network-latency.worker.d.ts +2 -2
  72. package/types/server/{audit-schema.d.ts → audit-state-class-description.d.ts} +8 -9
  73. package/types/server/create-http-server.d.ts +5 -0
  74. package/types/server/crypto.d.ts +4 -0
  75. package/types/server/index.d.ts +51 -3
  76. package/.eslintrc +0 -15
  77. package/.github/workflows/gh-pages.yml +0 -31
  78. package/.github/workflows/unit-tests.yml +0 -18
  79. package/src/client/ContextManager.js +0 -111
  80. package/src/client/SharedState.js +0 -84
  81. package/src/client/SharedStateCollection.js +0 -35
  82. package/src/client/Socket.js +0 -402
  83. package/src/common/BaseSharedState.js +0 -583
  84. package/src/common/BaseSharedStateCollection.js +0 -179
  85. package/src/common/SharedStatePrivate.js +0 -192
  86. package/src/common/promise-store.js +0 -25
  87. package/src/server/Client.js +0 -55
  88. package/src/server/PluginManager.js +0 -170
  89. package/src/server/SharedState.js +0 -85
  90. package/src/server/SharedStateCollection.js +0 -36
  91. package/src/server/Socket.js +0 -396
  92. package/src/server/Sockets.js +0 -224
  93. package/src/server/StateManager.js +0 -620
  94. package/tsconfig.json +0 -21
  95. package/types/client/Client.d.ts.map +0 -1
  96. package/types/client/Context.d.ts.map +0 -1
  97. package/types/client/ContextManager.d.ts.map +0 -1
  98. package/types/client/Plugin.d.ts +0 -53
  99. package/types/client/Plugin.d.ts.map +0 -1
  100. package/types/client/PluginManager.d.ts +0 -96
  101. package/types/client/PluginManager.d.ts.map +0 -1
  102. package/types/client/SharedState.d.ts +0 -85
  103. package/types/client/SharedState.d.ts.map +0 -1
  104. package/types/client/Socket.d.ts +0 -138
  105. package/types/client/Socket.d.ts.map +0 -1
  106. package/types/client/StateManager.d.ts.map +0 -1
  107. package/types/client/index.d.ts.map +0 -1
  108. package/types/common/BasePlugin.d.ts.map +0 -1
  109. package/types/common/BasePluginManager.d.ts.map +0 -1
  110. package/types/common/BaseSharedState.d.ts +0 -173
  111. package/types/common/BaseSharedState.d.ts.map +0 -1
  112. package/types/common/BaseStateManager.d.ts.map +0 -1
  113. package/types/common/ParameterBag.d.ts.map +0 -1
  114. package/types/common/SharedStatePrivate.d.ts +0 -20
  115. package/types/common/SharedStatePrivate.d.ts.map +0 -1
  116. package/types/common/constants.d.ts.map +0 -1
  117. package/types/common/logger.d.ts.map +0 -1
  118. package/types/common/promise-store.d.ts +0 -4
  119. package/types/common/promise-store.d.ts.map +0 -1
  120. package/types/common/sockets-utils.d.ts.map +0 -1
  121. package/types/common/utils.d.ts +0 -5
  122. package/types/common/utils.d.ts.map +0 -1
  123. package/types/server/Client.d.ts +0 -40
  124. package/types/server/Client.d.ts.map +0 -1
  125. package/types/server/Context.d.ts +0 -59
  126. package/types/server/Context.d.ts.map +0 -1
  127. package/types/server/ContextManager.d.ts +0 -69
  128. package/types/server/ContextManager.d.ts.map +0 -1
  129. package/types/server/Plugin.d.ts +0 -70
  130. package/types/server/Plugin.d.ts.map +0 -1
  131. package/types/server/PluginManager.d.ts +0 -91
  132. package/types/server/PluginManager.d.ts.map +0 -1
  133. package/types/server/Server.d.ts.map +0 -1
  134. package/types/server/SharedState.d.ts +0 -86
  135. package/types/server/SharedState.d.ts.map +0 -1
  136. package/types/server/Socket.d.ts +0 -128
  137. package/types/server/Socket.d.ts.map +0 -1
  138. package/types/server/Sockets.d.ts +0 -73
  139. package/types/server/Sockets.d.ts.map +0 -1
  140. package/types/server/StateManager.d.ts +0 -190
  141. package/types/server/StateManager.d.ts.map +0 -1
  142. package/types/server/audit-network-latency.worker.d.ts.map +0 -1
  143. package/types/server/audit-schema.d.ts.map +0 -1
  144. package/types/server/index.d.ts.map +0 -1
@@ -1,70 +1,248 @@
1
+ export const kStateManagerInit: unique symbol;
2
+ export const kStateManagerDeleteState: unique symbol;
3
+ export const kStateManagerClient: unique symbol;
1
4
  export default BaseStateManager;
2
5
  /**
3
- * @private
6
+ * Callback executed when a state is created on the network.
4
7
  */
8
+ export type stateManagerObserveCallback = () => any;
9
+ /**
10
+ * Callback to execute in order to remove a {@link stateManagerObserveCallback}
11
+ * from the list of observer.
12
+ */
13
+ export type stateManagerDeleteObserveCallback = () => any;
14
+ /**
15
+ * Callback executed when a state is created on the network.
16
+ *
17
+ * @callback stateManagerObserveCallback
18
+ * @async
19
+ * @param {string} className - name of the class
20
+ * @param {number} stateId - id of the state
21
+ * @param {number} nodeId - id of the node that created the state
22
+ */
23
+ /**
24
+ * Callback to execute in order to remove a {@link stateManagerObserveCallback}
25
+ * from the list of observer.
26
+ *
27
+ * @callback stateManagerDeleteObserveCallback
28
+ */
29
+ /** @private */
5
30
  declare class BaseStateManager {
6
31
  /**
7
- * @param {Number} id - Id of the node.
8
- * @param {Object} transport - Transport to use for synchronizing the state.
9
- * Must implement a basic EventEmitter API.
32
+ * Return a class description from a given class name
33
+ *
34
+ * @param {SharedStateClassName} className - Name of the shared state class.
35
+ * (cf. ServerStateManager)
36
+ * @return {SharedStateClassDescription}
37
+ * @example
38
+ * const classDescription = await client.stateManager.getClassDescription('my-class');
10
39
  */
11
- constructor(id: number, transport: any);
12
- client: {
13
- id: number;
14
- transport: any;
15
- };
16
- _statesById: Map<any, any>;
17
- _observeListeners: Set<any>;
18
- _cachedSchemas: Map<any, any>;
19
- _observeRequestCallbacks: Map<any, any>;
40
+ getClassDescription(className: SharedStateClassName): SharedStateClassDescription;
20
41
  /**
21
- * Create a `SharedState` instance from a registered schema.
42
+ * @deprecated Use {@link BaseStateManager#getClassDescription} instead.
43
+ */
44
+ getSchema(className: any): Promise<any>;
45
+ /**
46
+ * Create a {@link SharedState} instance from a registered class.
22
47
  *
23
- * @param {String} schemaName - Name of the schema as given on registration
24
- * (cf. ServerStateManager)
25
- * @param {Object} [initValues={}] - Default values for the state.
26
- * @returns {client.SharedState|server.SharedState}
27
- * @see {@link client.SharedState}
28
- * @see {@link server.SharedState}
48
+ * @param {SharedStateClassName} className - Name of the class.
49
+ * @param {Object.<string, any>} [initValues={}] - Default values of the created shared state.
50
+ * @returns {Promise<SharedState>}
29
51
  * @example
30
- * const state = await client.stateManager.create('my-schema');
52
+ * const state = await client.stateManager.create('my-class');
31
53
  */
32
- create(schemaName: string, initValues?: any): client.SharedState | server.SharedState;
54
+ create(className: SharedStateClassName, initValues?: {
55
+ [x: string]: any;
56
+ }): Promise<SharedState>;
33
57
  /**
34
- * Attach to an existing `SharedState` instance.
58
+ * Attach to an existing {@link SharedState} instance.
59
+ *
60
+ * @overload
61
+ * @param {SharedStateClassName} className - Name of the class.
62
+ * @returns {Promise<SharedState>}
35
63
  *
36
- * @param {String} schemaName - Name of the schema as given on registration
37
- * (cf. ServerStateManager)
38
- * @param {Object} [stateId=null] - Id of the state to attach to. If `null`,
39
- * attach to the first state found with the given schema name (usefull for
40
- * globally shared states owned by the server).
41
- * @returns {client.SharedState|server.SharedState}
42
- * @see {@link client.SharedState}
43
- * @see {@link server.SharedState}
44
64
  * @example
45
- * const state = await client.stateManager.attach('my-schema');
65
+ * const state = await client.stateManager.attach('my-class');
46
66
  */
47
- attach(schemaName: string, stateId?: any): client.SharedState | server.SharedState;
67
+ attach(className: SharedStateClassName): Promise<SharedState>;
48
68
  /**
49
- * Observe all the `SharedState` instances that are created on the network.
50
- * This can be usefull for clients with some controller role that might want to track
51
- * the state of all other clients of the application, to monitor them and/or take
52
- * control over them from a single point.
69
+ * Attach to an existing {@link SharedState} instance.
70
+ *
71
+ * @overload
72
+ * @param {SharedStateClassName} className - Name of the class.
73
+ * @param {number} stateId - Id of the state
74
+ * @returns {Promise<SharedState>}
53
75
  *
54
- * @todo Optionnal schema name
55
- * @param {server.StateManager~ObserveCallback|client.StateManager~ObserveCallback}
56
- * 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.
60
76
  * @example
61
- * client.stateManager.observe(async (schemaName, stateId, nodeId) => {
62
- * if (schemaName === 'something') {
63
- * const state = await this.client.stateManager.attach(schemaName, stateId);
64
- * console.log(state.getValues());
77
+ * const state = await client.stateManager.attach('my-class', stateId);
78
+ */
79
+ attach(className: SharedStateClassName, stateId: number): Promise<SharedState>;
80
+ /**
81
+ * Attach to an existing {@link SharedState} instance.
82
+ *
83
+ * @overload
84
+ * @param {SharedStateClassName} className - Name of the class.
85
+ * @param {string[]} filter - List of parameters of interest
86
+ * @returns {Promise<SharedState>}
87
+ *
88
+ * @example
89
+ * const state = await client.stateManager.attach('my-class', ['some-param']);
90
+ */
91
+ attach(className: SharedStateClassName, filter: string[]): Promise<SharedState>;
92
+ /**
93
+ * Attach to an existing {@link SharedState} instance.
94
+ *
95
+ * @overload
96
+ * @param {SharedStateClassName} className - Name of the class.
97
+ * @param {number} stateId - Id of the state
98
+ * @param {string[]} filter - List of parameters of interest
99
+ * @returns {Promise<SharedState>}
100
+ *
101
+ * @example
102
+ * const state = await client.stateManager.attach('my-class', stateId, ['some-param']);
103
+ */
104
+ attach(className: SharedStateClassName, stateId: number, filter: string[]): Promise<SharedState>;
105
+ /**
106
+ * Observe all the {@link SharedState} instances that are created on the network.
107
+ *
108
+ * @overload
109
+ * @param {stateManagerObserveCallback} callback - Function to execute when a
110
+ * new {@link SharedState} is created on the network.
111
+ * @example
112
+ * client.stateManager.observe(async (className, stateId) => {
113
+ * if (className === 'my-shared-state-class') {
114
+ * const attached = await client.stateManager.attach(className, stateId);
65
115
  * }
66
116
  * });
67
117
  */
68
- observe(callback: any): Promise<Function>;
118
+ observe(callback: stateManagerObserveCallback): any;
119
+ /**
120
+ * Observe all the {@link SharedState} instances of given {@link SharedStateClassName}
121
+ * that are created on the network.
122
+ *
123
+ * @overload
124
+ * @param {SharedStateClassName} className - Observe only ${@link SharedState}
125
+ * of given name.
126
+ * @param {stateManagerObserveCallback} callback - Function to execute when a
127
+ * new {@link SharedState} is created on the network.
128
+ * @example
129
+ * client.stateManager.observe('my-shared-state-class', async (className, stateId) => {
130
+ * const attached = await client.stateManager.attach(className, stateId);
131
+ * });
132
+ */
133
+ observe(className: SharedStateClassName, callback: stateManagerObserveCallback): any;
134
+ /**
135
+ * Observe all the {@link SharedState} instances of given excluding the ones
136
+ * created by the current node.
137
+ *
138
+ * @overload
139
+ * @param {stateManagerObserveCallback} callback - Function to execute when a
140
+ * new {@link SharedState} is created on the network.
141
+ * @param {object} options - Options.
142
+ * @param {boolean} options.excludeLocal=false - If set to true, exclude states
143
+ * created by the same node from the collection.
144
+ * @example
145
+ * client.stateManager.observe(async (className, stateId) => {
146
+ * if (className === 'my-shared-state-class') {
147
+ * const attached = await client.stateManager.attach(className, stateId);
148
+ * }
149
+ * }, { excludeLocal: true });
150
+ */
151
+ observe(callback: stateManagerObserveCallback, options: {
152
+ excludeLocal: boolean;
153
+ }): any;
154
+ /**
155
+ * Observe all the {@link SharedState} instances of given {@link SharedStateClassName}
156
+ * that are created on the network, excluding the ones created by the current node.
157
+ *
158
+ * @overload
159
+ * @param {SharedStateClassName} className - Observe only ${@link SharedState}
160
+ * of given name.
161
+ * @param {stateManagerObserveCallback} callback - Function to execute when a
162
+ * new {@link SharedState} is created on the network.
163
+ * @param {object} options - Options.
164
+ * @param {boolean} options.excludeLocal=false - If set to true, exclude states
165
+ * created by the same node from the collection.
166
+ * @example
167
+ * client.stateManager.observe('my-shared-state-class', async (className, stateId) => {
168
+ * const attached = await client.stateManager.attach(className, stateId);
169
+ * }, { excludeLocal: true });
170
+ */
171
+ observe(className: SharedStateClassName, callback: stateManagerObserveCallback, options: {
172
+ excludeLocal: boolean;
173
+ }): any;
174
+ /**
175
+ * Returns a collection of all the states created from a given shared state class.
176
+ *
177
+ * @overload
178
+ * @param {SharedStateClassName} className - Name of the shared state class.
179
+ * @returns {Promise<SharedStateCollection>}
180
+ *
181
+ * @example
182
+ * const collection = await client.stateManager.getCollection(className);
183
+ */
184
+ getCollection(className: SharedStateClassName): Promise<SharedStateCollection>;
185
+ /**
186
+ * Returns a collection of all the states created from a given shared state class.
187
+ *
188
+ * @overload
189
+ * @param {SharedStateClassName} className - Name of the shared state class.
190
+ * @param {SharedStateParameterName[]} filter - Filter parameter of interest for each
191
+ * state of the collection.
192
+ * @returns {Promise<SharedStateCollection>}
193
+ *
194
+ * @example
195
+ * const collection = await client.stateManager.getCollection(className, ['my-param']);
196
+ */
197
+ getCollection(className: SharedStateClassName, filter: SharedStateParameterName[]): Promise<SharedStateCollection>;
198
+ /**
199
+ * Returns a collection of all the states created from a given shared state class.
200
+ *
201
+ * @overload
202
+ * @param {SharedStateClassName} className - Name of the shared state class.
203
+ * @param {object} options - Options.
204
+ * @param {boolean} options.excludeLocal=false - If set to true, exclude states
205
+ * created by the same node from the collection.
206
+ * @returns {Promise<SharedStateCollection>}
207
+ *
208
+ * @example
209
+ * const collection = await client.stateManager.getCollection(className, { excludeLocal: true });
210
+ */
211
+ getCollection(className: SharedStateClassName, options: {
212
+ excludeLocal: boolean;
213
+ }): Promise<SharedStateCollection>;
214
+ /**
215
+ * Returns a collection of all the states created from a given shared state class.
216
+ *
217
+ * @overload
218
+ * @param {SharedStateClassName} className - Name of the shared state class.
219
+ * @param {SharedStateParameterName[]} filter - Filter parameter of interest for each
220
+ * state of the collection.
221
+ * @param {object} options - Options.
222
+ * @param {boolean} options.excludeLocal=false - If set to true, exclude states
223
+ * created by the same node from the collection.
224
+ * @returns {Promise<SharedStateCollection>}
225
+ *
226
+ * @example
227
+ * const collection = await client.stateManager.getCollection(className, ['my-param'], { excludeLocal: true });
228
+ */
229
+ getCollection(className: SharedStateClassName, filter: SharedStateParameterName[], options: {
230
+ excludeLocal: boolean;
231
+ }): Promise<SharedStateCollection>;
232
+ /** @private */
233
+ private [kStateManagerDeleteState];
234
+ /**
235
+ * Executed on `client.init`
236
+ * @param {Number} id - Id of the node.
237
+ * @param {Object} transport - Transport to use for synchronizing the states.
238
+ * Must implement a basic EventEmitter API.
239
+ *
240
+ * @private
241
+ */
242
+ private [kStateManagerInit];
243
+ /** @private */
244
+ private [kStateManagerClient];
245
+ #private;
69
246
  }
70
- //# sourceMappingURL=BaseStateManager.d.ts.map
247
+ import SharedState from './SharedState.js';
248
+ import SharedStateCollection from './SharedStateCollection.js';
@@ -0,0 +1,17 @@
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
+ addListener(channel: any, callback: any): void;
13
+ emit(channel: any, ...args: any[]): Promise<void>;
14
+ removeListener(channel: any, callback: any): void;
15
+ removeAllListeners(channel?: any): void;
16
+ #private;
17
+ }
@@ -1,126 +1,125 @@
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 required: boolean;
5
+ let metas: {};
6
+ let filterChange: boolean;
7
+ let immediate: boolean;
7
8
  }
8
9
  export namespace types {
9
10
  export namespace boolean {
10
- const required: string[];
11
- function coerceFunction(name: any, def: any, value: any): boolean;
11
+ let required_1: string[];
12
+ export { required_1 as required };
13
+ export const defaultOptions: any;
14
+ export function coerceFunction(name: any, def: any, value: any): boolean;
12
15
  }
13
16
  export namespace string {
14
- const required_1: string[];
15
- export { required_1 as required };
17
+ let required_2: string[];
18
+ export { required_2 as required };
19
+ const defaultOptions_1: any;
20
+ export { defaultOptions_1 as defaultOptions };
16
21
  export function coerceFunction_1(name: any, def: any, value: any): string;
17
22
  export { coerceFunction_1 as coerceFunction };
18
23
  }
19
24
  export namespace integer {
20
- const required_2: string[];
21
- export { required_2 as required };
22
- export function sanitizeSchema(def: any): any;
25
+ let required_3: string[];
26
+ export { required_3 as required };
27
+ const defaultOptions_2: any;
28
+ export { defaultOptions_2 as defaultOptions };
29
+ export function sanitizeDescription(def: any): any;
23
30
  export function coerceFunction_2(name: any, def: any, value: any): number;
24
31
  export { coerceFunction_2 as coerceFunction };
25
32
  }
26
33
  export namespace float {
27
- const required_3: string[];
28
- export { required_3 as required };
29
- export function sanitizeSchema_1(def: any): any;
30
- export { sanitizeSchema_1 as sanitizeSchema };
34
+ let required_4: string[];
35
+ export { required_4 as required };
36
+ const defaultOptions_3: any;
37
+ export { defaultOptions_3 as defaultOptions };
38
+ export function sanitizeDescription_1(def: any): any;
39
+ export { sanitizeDescription_1 as sanitizeDescription };
31
40
  export function coerceFunction_3(name: any, def: any, value: any): number;
32
41
  export { coerceFunction_3 as coerceFunction };
33
42
  }
34
43
  export namespace _enum {
35
- const required_4: string[];
36
- export { required_4 as required };
44
+ let required_5: string[];
45
+ export { required_5 as required };
46
+ const defaultOptions_4: any;
47
+ export { defaultOptions_4 as defaultOptions };
37
48
  export function coerceFunction_4(name: any, def: any, value: any): any;
38
49
  export { coerceFunction_4 as coerceFunction };
39
50
  }
40
51
  export { _enum as enum };
41
52
  export namespace any {
42
- const required_5: string[];
43
- export { required_5 as required };
53
+ let required_6: string[];
54
+ export { required_6 as required };
55
+ const defaultOptions_5: any;
56
+ export { defaultOptions_5 as defaultOptions };
44
57
  export function coerceFunction_5(name: any, def: any, value: any): any;
45
58
  export { coerceFunction_5 as coerceFunction };
46
59
  }
47
60
  }
48
61
  export default ParameterBag;
49
- export namespace server {
62
+ /** @private */
63
+ declare class ParameterBag {
64
+ static validateDescription(description: any): void;
65
+ constructor(description: any, initValues?: {});
50
66
  /**
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.
67
+ * Define if the parameter exists.
56
68
  *
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}
69
+ * @param {string} name - Name of the parameter.
70
+ * @return {Boolean}
64
71
  */
65
- type SharedStateManagerServer = any;
66
- }
67
- /**
68
- * Bag of parameters.
69
- * @private
70
- */
71
- declare class ParameterBag {
72
- static validateSchema(schema: any): void;
73
- constructor(schema: any, initValues?: {});
72
+ has(name: string): boolean;
74
73
  /**
75
- * List of parameters.
74
+ * Return values of all parameters as a flat object. If a parameter is of `any`
75
+ * type, a deep copy is made.
76
76
  *
77
- * @type {Object<String, Param>}
78
- * @name _params
79
- * @memberof ParameterBag
80
- * @instance
81
- * @private
77
+ * @return {object}
82
78
  */
83
- private _values;
79
+ getValues(): object;
84
80
  /**
85
- * List of schema with init values.
81
+ * Return values of all parameters as a flat object. Similar to `getValues` but
82
+ * returns a reference to the underlying value in case of `any` type. May be
83
+ * useful if the underlying value is big (e.g. sensors recordings, etc.) and
84
+ * deep cloning expensive. Be aware that if changes are made on the returned
85
+ * object, the state of your application will become inconsistent.
86
86
  *
87
- * @type {Object<String, paramDefinition>}
88
- * @name _schema
89
- * @memberof ParameterBag
90
- * @instance
91
- * @private
87
+ * @return {object}
92
88
  */
93
- private _schema;
89
+ getValuesUnsafe(): object;
94
90
  /**
95
- * Define if the parameter exists.
91
+ * Return the value of the given parameter. If the parameter is of `any` type,
92
+ * a deep copy is returned.
96
93
  *
97
- * @param {String} name - Name of the parameter.
98
- * @return {Boolean}
94
+ * @param {string} name - Name of the parameter.
95
+ * @return {Mixed} - Value of the parameter.
99
96
  */
100
- has(name: string): boolean;
97
+ get(name: string): Mixed;
101
98
  /**
102
- * Return values of all parameters as a flat object.
99
+ * Similar to `get` but returns a reference to the underlying value in case of
100
+ * `any` type. May be useful if the underlying value is big (e.g. sensors
101
+ * recordings, etc.) and deep cloning expensive. Be aware that if changes are
102
+ * made on the returned object, the state of your application will become
103
+ * inconsistent.
103
104
  *
104
- * @return {Object}
105
+ * @param {string} name - Name of the parameter.
106
+ * @return {Mixed} - Value of the parameter.
105
107
  */
106
- getValues(): any;
108
+ getUnsafe(name: string): Mixed;
107
109
  /**
108
- * Return the value of the given parameter. If the parameter is of `any` type,
109
- * a deep copy is returned.
110
+ * Check that the value is valid according to the class definition and return it coerced.
110
111
  *
111
112
  * @param {String} name - Name of the parameter.
112
- * @return {Mixed} - Value of the parameter.
113
+ * @param {Mixed} value - Value of the parameter.
113
114
  */
114
- get(name: string): Mixed;
115
+ coerceValue(name: string, value: Mixed): Mixed;
115
116
  /**
116
117
  * Set the value of a parameter. If the value of the parameter is updated
117
118
  * (aka if previous value is different from new value) all registered
118
119
  * callbacks are registered.
119
120
  *
120
- * @param {String} name - Name of the parameter.
121
+ * @param {string} name - Name of the parameter.
121
122
  * @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
123
  * @return {Array} - [new value, updated flag].
125
124
  */
126
125
  set(name: string, value: Mixed): any[];
@@ -129,15 +128,13 @@ declare class ParameterBag {
129
128
  * @note - prefer `state.set(state.getInitValues())`
130
129
  * or `state.set(state.getDefaultValues())`
131
130
  *
132
- * @param {String} [name=null] - Name of the parameter to reset.
131
+ * @param {string} [name=null] - Name of the parameter to reset.
133
132
  */
134
133
  /**
135
- * Return the given schema along with the initialization values.
136
- *
137
- * @return {Object}
134
+ * @return {object}
138
135
  */
139
- getSchema(name?: any): any;
136
+ getDescription(name?: any): object;
140
137
  getInitValues(): {};
141
138
  getDefaults(): {};
139
+ #private;
142
140
  }
143
- //# sourceMappingURL=ParameterBag.d.ts.map
@@ -0,0 +1,11 @@
1
+ /** @private */
2
+ export default class PromiseStore {
3
+ constructor(name: any);
4
+ name: any;
5
+ store: Map<any, any>;
6
+ generateRequestId: any;
7
+ add(resolve: any, reject: any, type: any, localParams: any): any;
8
+ resolve(reqId: any, data: any): void;
9
+ reject(reqId: any, msg: any): void;
10
+ flush(): void;
11
+ }