@soundworks/core 4.0.0-alpha.9 → 5.0.1

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 +64 -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,53 +0,0 @@
1
- export default Plugin;
2
- export namespace client {
3
- /**
4
- * ~onStateChangeCallback
5
- */
6
- export type Plugin = (#state: client.Plugin) => any;
7
- /**
8
- * Callback executed when the plugin state is updated.
9
- *
10
- * @callback client.Plugin~onStateChangeCallback
11
- * @param {client.Plugin#state} state - Current state of the plugin.
12
- */
13
- /**
14
- * Delete the registered {@link client.Plugin~onStateChangeCallback}.
15
- *
16
- * @callback client.Plugin~deleteOnStateChangeCallback
17
- */
18
- /**
19
- * Base class to extend in order to create new `soundworks` plugins.
20
- *
21
- * In the `soundworks` paradigm, a plugin is a component that allows to extend
22
- * the framework capabilities by encapsulating common and reusable logic in
23
- * an application wise perspective. For example, plugins are available to handle
24
- * clock synchronization, to deal with the file system, etc. Plugin should always
25
- * have both a client-side and a server-side part.
26
- *
27
- * See [https://soundworks.dev/guide/ecosystem](https://soundworks.dev/guide/ecosystem)
28
- * for more informations on the available plugins.
29
- *
30
- * _Creating new plugins should be considered an advanced usage._
31
- *
32
- * @memberof client
33
- * @extends BasePlugin
34
- * @inheritdoc
35
- */
36
- class Plugin extends BasePlugin {
37
- /**
38
- * @param {client.Client} client - The soundworks client instance.
39
- * @param {string} id - User defined id of the plugin as defined in
40
- * {@link client.PluginManager#register}.
41
- */
42
- constructor(client: client.Client, id: string);
43
- /**
44
- * Instance of soundworks client.
45
- *
46
- * @type {client.Client}
47
- * @see {@link client.Client}
48
- */
49
- client: client.Client;
50
- }
51
- }
52
- import BasePlugin from "../common/BasePlugin.js";
53
- //# sourceMappingURL=Plugin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../src/client/Plugin.js"],"names":[],"mappings":";;;;;kCAMW,aAAa;IAJxB;;;;;OAKG;IAEH;;;;OAIG;IAEH;;;;;;;;;;;;;;;;;OAiBG;IACH;QACE;;;;WAIG;QACH,uCAHW,MAAM,EAahB;QAPC;;;;;WAKG;QACH,sBAAoB;KAevB"}
@@ -1,96 +0,0 @@
1
- export default PluginManager;
2
- export namespace client {
3
- /**
4
- * ~onStateChangeCallback
5
- */
6
- type PluginManager = (: object, initiator: client.Plugin | null) => any;
7
- }
8
- /**
9
- * Callback executed when a plugin internal state is updated.
10
- *
11
- * @callback client.PluginManager~onStateChangeCallback
12
- * @param {object<client.Plugin#id, client.Plugin>} fullState - List of all plugins.
13
- * @param {client.Plugin|null} initiator - Plugin that initiated the update or `null`
14
- * if the change was initiated by the state manager (i.e. when the initialization
15
- * of the plugins starts).
16
- */
17
- /**
18
- * Delete the registered {@link client.PluginManager~onStateChangeCallback}.
19
- *
20
- * @callback client.PluginManager~deleteOnStateChangeCallback
21
- */
22
- /**
23
- * The `PluginManager` allows to register and retrieve `soundworks` plugins.
24
- *
25
- * Plugins should always be registered both client-side and server-side,
26
- * and before {@link client.Client#start} or {@link server.Server#start}
27
- * are called for proper initialization.
28
- *
29
- * In some sitautions, you might want to register the same plugin factory several times
30
- * using different ids (e.g. for watching several parts of the file system, etc.).
31
- *
32
- * Refer to the plugins' documentation for more precise examples, and the specific API
33
- * they expose. See [https://soundworks.dev/guide/ecosystem](https://soundworks.dev/guide/ecosystem)
34
- * for more informations on the available plugins.
35
- *
36
- * See {@link client.Client#pluginManager}
37
- *
38
- * ```
39
- * import { Client } from '@soundworks/core/client.js';
40
- * import platformPlugin from '@soundworks/plugin-sync/client.js';
41
- *
42
- * const client = new Client(config);
43
- * // register the plugin before `client.start()`
44
- * client.pluginManager.register('sync', pluginSync);
45
- *
46
- * await client.start();
47
- *
48
- * const sync = await client.pluginManager.get('sync');
49
- *
50
- * setInterval(() => {
51
- * // log the estimated global synced clock alongside the local clock.
52
- * console.log(sync.getSyncTime(), sync.getLocalTime());
53
- * }, 1000);
54
- * ```
55
- *
56
- * @memberof client
57
- * @extends BasePluginManager
58
- * @inheritdoc
59
- * @hideconstructor
60
- */
61
- declare class PluginManager extends BasePluginManager {
62
- /**
63
- * @param {client.Client} client - The soundworks client instance.
64
- */
65
- constructor(client: client.Client);
66
- register(id: any, factory: any, options?: {}, deps?: any[]): void;
67
- /**
68
- * Retrieve an fully started instance of a registered plugin.
69
- *
70
- * Be aware that the `get` method resolves only when the plugin is fully 'started',
71
- * which is what we want 99.99% of the time. As such, and to prevent the application
72
- * to be stuck in some kind of Promise dead lock, this method will throw if
73
- * used before `client.init()` (or `client.start()`).
74
- *
75
- * To handle the remaining 0.01% cases and access plugin instances during their
76
- * initialization (e.g. to display initialization screen, etc.), you should rely
77
- * on the `onStateChange` method.
78
- *
79
- * _Note: the async API is designed to enable the dynamic creation of plugins (hopefully
80
- * without brealing changes) in a future release._
81
- *
82
- * @param {client.Plugin#id} id - Id of the plugin as defined when registered.
83
- * @returns {client.Plugin}
84
- * @see {@link client.PluginManager#onStateChange}
85
- *
86
- * @private
87
- */
88
- private get;
89
- /**
90
- * @protected
91
- * @ignore
92
- */
93
- protected getRegisteredPlugins(): any[];
94
- }
95
- import BasePluginManager from "../common/BasePluginManager.js";
96
- //# sourceMappingURL=PluginManager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PluginManager.d.ts","sourceRoot":"","sources":["../../src/client/PluginManager.js"],"names":[],"mappings":";;;;;4BAQW,MAAM,aACN,gBAAc,IAAI;;AAL7B;;;;;;;;GAQG;AAEH;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH;IACE;;OAEG;IACH,mCAMC;IAED,kEAQC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,YAMC;IAKD;;;OAGG;IACH,wCAEC;CACF"}
@@ -1,85 +0,0 @@
1
- export default SharedState;
2
- export namespace client {
3
- /**
4
- * ~onUpdateCallback
5
- */
6
- type SharedState = (newValues: any, oldValues: any, context?: Mixed) => any;
7
- }
8
- /**
9
- * @callback client.SharedState~onUpdateCallback
10
- * @param {Object} newValues - Key / value pairs of the updates that have been
11
- * applied to the state.
12
- * @param {Object} oldValues - Key / value pairs of the updated params before
13
- * the updates has been applied to the state.
14
- * @param {Mixed} [context=null] - Optionnal context object that has been passed
15
- * with the values updates in the `set` call.
16
- */
17
- /**
18
- * Delete the registered {@link client.SharedState~onUpdateCallback}.
19
- *
20
- * @callback client.SharedState~deleteOnUpdateCallback
21
- */
22
- /**
23
- * The `SharedState` is one of the most important and versatile abstraction provided
24
- * by `soundworks`. It represents a set of parameters that are synchronized accross
25
- * every nodes of the application (clients and server) that declared some interest
26
- * to the shared state.
27
- *
28
- * A `SharedState` is created according to a "schema" (in the sense of a database
29
- * schema) that must be declared and registered server-side. Any number of `SharedState`s
30
- * can be created from a single schema.
31
- *
32
- * A shared state can be created both by the clients or by the server (in which case
33
- * it is generally considered as a global state of the application). Similarly any
34
- * node of the application (clients or server) can declare interest and "attach" to
35
- * a state created by another node. All node attached to a state can modify its values
36
- * and/or react to the modifications applied by other nodes.
37
- *
38
- * Tutorial: {@link https://soundworks.dev/guide/state-manager.html}
39
- *
40
- * ```
41
- * // server-side
42
- * import { Server } from '@soundworks/server/index.js';
43
- *
44
- * const server = new Server(config);
45
- * // declare and register the schema of a shared state.
46
- * server.stateManager.registerSchema('some-global-state', {
47
- * myRandom: {
48
- * type: 'float',
49
- * default: 0,
50
- * }
51
- * });
52
- *
53
- * await server.start();
54
- *
55
- * // create a global state server-side
56
- * const globalState = await server.stateManager.create('some-global-state');
57
- * // listen and react to the changes made by the clients
58
- * globalState.onUpdate(updates => console.log(updates));
59
- * ```
60
- *
61
- * ```
62
- * // client-side
63
- * import { Client } from '@soundworks/client.index.js';
64
- *
65
- * const client = new Client(config);
66
- * await client.start();
67
- *
68
- * // attach to the global state created by the server
69
- * const globalState = await client.stateManager.attach('some-global-state');
70
- *
71
- * // update the value of a `myRandom` parameter every seconds
72
- * setInterval(() => {
73
- * globalState.set({ myRandom: Math.random() });
74
- * }, 1000);
75
- * ```
76
- *
77
- * @memberof client
78
- * @extends BaseSharedState
79
- * @inheritdoc
80
- * @hideconstructor
81
- */
82
- declare class SharedState extends BaseSharedState {
83
- }
84
- import BaseSharedState from "../common/BaseSharedState.js";
85
- //# sourceMappingURL=SharedState.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SharedState.d.ts","sourceRoot":"","sources":["../../src/client/SharedState.js"],"names":[],"mappings":";;;;;;;AAIA;;;;;;;;GAQG;AAEH;;;;GAIG;AAGH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH;CAA4C"}
@@ -1,138 +0,0 @@
1
- export default Socket;
2
- /**
3
- * The Socket class is a simple publish / subscribe wrapper built on top of the
4
- * [isomorphic-ws](https://github.com/heineiuo/isomorphic-ws) library.
5
- * An instance of `Socket` is automatically created by the `soundworks.Client`.
6
- *
7
- * _Important: In most cases, you should consider using a {@link client.SharedState} rather than
8
- * sending messages directly through the sockets._
9
- *
10
- * The Socket class concurrently opens two different WebSockets:
11
- * - a socket configured with `binaryType = 'string'` for JSON compatible string
12
- * messages.
13
- * - a socket configured with `binaryType=arraybuffer` for efficient streaming
14
- * of binary data.
15
- *
16
- * Both sockets re-emits all "native" ws events ('open', 'upgrade', 'close', 'error'
17
- * and 'message'.
18
- *
19
- * See {@link client.Client#socket}
20
- *
21
- * @memberof client
22
- * @hideconstructor
23
- */
24
- declare class Socket {
25
- /**
26
- * WebSocket instance w/ string protocol, i.e. `binaryType = 'string'`.
27
- *
28
- * @private
29
- */
30
- private ws;
31
- /**
32
- * WebSocket instance w/ binary protocol, i.e. `binaryType = 'arraybuffer'`.
33
- *
34
- * @private
35
- */
36
- private binaryWs;
37
- /** @private */
38
- private _stringListeners;
39
- /** @private */
40
- private _binaryListeners;
41
- /**
42
- * Initialize a websocket connection with the server. Automatically called
43
- * during `client.init()`
44
- *
45
- * @param {string} role - Role of the client (see {@link client.Client#role})
46
- * @param {object} config - Configuration of the sockets
47
- * @protected
48
- * @ignore
49
- */
50
- protected init(role: string, config: object): Promise<void>;
51
- /**
52
- * @param {boolean} binary - Emit to either the string or binary socket.
53
- * @param {string} channel - Channel name.
54
- * @param {...*} args - Content of the message.
55
- * @private
56
- */
57
- private _emit;
58
- /**
59
- * @param {Function[]} listeners - List of listeners, either for the string or binary socket.
60
- * @param {string} channel - Channel name.
61
- * @param {Function} callback - The function to be added to the listeners.
62
- * @private
63
- */
64
- private _addListener;
65
- /**
66
- * @param {Function[]} listeners - List of listeners, either for the string or binary socket.
67
- * @param {string} channel - Channel name.
68
- * @param {Function} callback - The function to be removed from the listeners.
69
- * @private
70
- */
71
- private _removeListener;
72
- /**
73
- * @param {Function[]} listeners - List of listeners, either for the string or binary socket.
74
- * @param {string} [channel=null] - Channel name of the listeners to remove. If null
75
- * all the listeners are cleared.
76
- * @private
77
- */
78
- private _removeAllListeners;
79
- /**
80
- * Send JSON compatible messages on a given channel.
81
- *
82
- * @param {string} channel - Channel name of the message.
83
- * @param {...*} args - Message list, as many as needed, of any serializable type).
84
- */
85
- send(channel: string, ...args: any[]): void;
86
- /**
87
- * Listen to JSON compatible messages on a given channel.
88
- *
89
- * @param {string} channel - Channel name of the message.
90
- * @param {Function} callback - Callback to execute when a message is received.
91
- */
92
- addListener(channel: string, callback: Function): void;
93
- /**
94
- * Remove a listener from JSON compatible messages on a given channel.
95
- *
96
- * @param {string} channel - Channel name of the message.
97
- * @param {Function} callback - Callback to remove.
98
- */
99
- removeListener(channel: string, callback: Function): void;
100
- /**
101
- * Remove all listeners from JSON compatible messages on a given channel.
102
- *
103
- * @param {string} channel - Channel name of the message.
104
- */
105
- removeAllListeners(channel?: string): void;
106
- /**
107
- * Send binary messages on a given channel.
108
- *
109
- * @param {string} channel - Channel name of the message.
110
- * @param {TypedArray} typedArray - Binary data to be sent.
111
- */
112
- sendBinary(channel: string, typedArray: TypedArray): void;
113
- /**
114
- * Listen binary messages on a given channel.
115
- *
116
- * @param {string} channel - Channel name of the message.
117
- * @param {Function} callback - Callback to execute when a message is received.
118
- */
119
- addBinaryListener(channel: string, callback: Function): void;
120
- /**
121
- * Remove a listener from binary compatible messages on a given channel
122
- *
123
- * @param {string} channel - Channel of the message.
124
- * @param {Function} callback - Callback to cancel.
125
- */
126
- removeBinaryListener(channel: string, callback: Function): void;
127
- /**
128
- * Remove all listeners from binary compatible messages on a given channel
129
- *
130
- * @param {string} channel - Channel of the message.
131
- */
132
- removeAllBinaryListeners(channel?: string): void;
133
- /**
134
- * Removes all listeners and immediately close the two sockets.
135
- */
136
- terminate(): Promise<void>;
137
- }
138
- //# sourceMappingURL=Socket.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Socket.d.ts","sourceRoot":"","sources":["../../src/client/Socket.js"],"names":[],"mappings":";AA2BA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;IAEI;;;;OAIG;IACH,WAAc;IACd;;;;OAIG;IACH,iBAAoB;IACpB,eAAe;IACf,yBAAiC;IACjC,eAAe;IACf,yBAAiC;IAGnC;;;;;;;;OAQG;IACH,qBALW,MAAM,UACN,MAAM,iBA6JhB;IAED;;;;;OAKG;IACH,cAOC;IAED;;;;;OAKG;IACH,qBAOC;IAED;;;;;OAKG;IACH,wBASC;IAED;;;;;OAKG;IACH,4BAMC;IAED;;;;;OAKG;IACH,cAHW,MAAM,wBAMhB;IAED;;;;;OAKG;IACH,qBAHW,MAAM,4BAKhB;IAED;;;;;OAKG;IACH,wBAHW,MAAM,4BAKhB;IAED;;;;OAIG;IACH,6BAFW,MAAM,QAIhB;IAED;;;;;OAKG;IACH,oBAHW,MAAM,gCAMhB;IAED;;;;;OAKG;IACH,2BAHW,MAAM,4BAKhB;IAED;;;;;OAKG;IACH,8BAHW,MAAM,4BAKhB;IAED;;;;OAIG;IACH,mCAFW,MAAM,QAIhB;IAED;;OAEG;IACH,2BAQC;CACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"StateManager.d.ts","sourceRoot":"","sources":["../../src/client/StateManager.js"],"names":[],"mappings":";;;;;;;AAEA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH;CAA8C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.js"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"BasePlugin.d.ts","sourceRoot":"","sources":["../../src/common/BasePlugin.js"],"names":[],"mappings":";AAEA;;GAEG;AACH;IACE,qBAoDC;IAnDC;;;;;;OAMG;IACH,IAJU,MAAM,CAIJ;IAEZ;;;;;;;;;OASG;IACH,eAHU,MAAM,CAGiB;IAEjC;;;;OAIG;IACH,SAFU,MAAM,CAEC;IAEjB;;;;;;;;;;;OAWG;IACH,iBAPU,MAAM,CAOD;IAEf;;;;OAIG;IACH,QAFU,MAAM,CAEI;IAEpB,eAAe;IACf,gCAAwC;IAG1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,uBAAgB;IAEhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,sBAAe;IAEf;;;;;;;;;;;;;OAaG;IACH,4CAGC;IAED;;;;;;;;;;OAUG;IACH,8BANW,MAAM,QAShB;CACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"BasePluginManager.d.ts","sourceRoot":"","sources":["../../src/common/BasePluginManager.js"],"names":[],"mappings":";AAKA;;;;GAIG;AACH;IACE,uBAcC;IAZC,eAAe;IACf,cAAiB;IACjB,eAAe;IACf,2BAAmC;IACnC,eAAe;IACf,mBAA2B;IAC3B,eAAe;IACf,+BAAuC;IACvC,eAAe;IACf,gCAAwC;IAExC,eAAoB;IAGtB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,aAfW,MAAM,uBAGN,MAAM,sBAqChB;IAED;;;;OAIG;IACH,cA2BC;IAED,sBAIC;IAED;;;;;;OAMG;IACH,kBAqDC;IAED;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,4CAGC;IAED,eAAe;IACf,8BAaC;CACF"}
@@ -1,173 +0,0 @@
1
- export default BaseSharedState;
2
- declare class BaseSharedState {
3
- constructor(id: any, remoteId: any, schemaName: any, schema: any, client: any, isOwner: any, manager: any, initValues?: {});
4
- id: any;
5
- remoteId: any;
6
- schemaName: any;
7
- /** @private */
8
- private _isOwner;
9
- /** @private */
10
- private _client;
11
- /** @private */
12
- private _manager;
13
- /** @private */
14
- private _parameters;
15
- /** @private */
16
- private _onUpdateCallbacks;
17
- /** @private */
18
- private _onDetachCallbacks;
19
- /** @private */
20
- private _onDeleteCallbacks;
21
- /** @private */
22
- private _clearDetach;
23
- /**
24
- * Detach from the state. If the client is the creator of the state, the state
25
- * is deleted and all attached nodes get notified
26
- *
27
- * @example
28
- * const state = await client.state.attach('globals');
29
- * // later
30
- * await state.detach();
31
- */
32
- detach(): Promise<any>;
33
- /** @private */
34
- private _clearTransport;
35
- /** @private */
36
- private _commit;
37
- /**
38
- * Update values of the state.
39
- *
40
- * The returned `Promise` resolves on the applied updates, when all the `onUpdate`
41
- * callbacks have resolved themselves, i.e.:
42
- *
43
- * ```js
44
- * server.stateManager.registerSchema('test', {
45
- * myBool: { type: 'boolean', default: false },
46
- * });
47
- * const a = await server.stateManager.create('a');
48
- * let asyncCallbackCalled = false;
49
- *
50
- * a.onUpdate(updates => {
51
- * return new Promise(resolve => {
52
- * setTimeout(() => {
53
- * asyncCallbackCalled = true;
54
- * resolve();
55
- * }, 100);
56
- * });
57
- * });
58
- *
59
- * const updates = await a.set({ myBool: true });
60
- * assert.equal(asyncCallbackCalled, true);
61
- * assert.deepEqual(updates, { myBool: true });
62
- * ```
63
- *
64
- * @param {object} updates - key / value pairs of updates to apply to the state.
65
- * @param {mixed} [context=null] - optionnal contextual object that will be propagated
66
- * alongside the updates of the state. The context is valid only for the
67
- * current call and will be passed as third argument to all update listeners.
68
- * @returns {Promise<Object>} A promise to the (coerced) updates.
69
- * @example
70
- * const state = await client.state.attach('globals');
71
- * const updates = await state.set({ myParam: Math.random() });
72
- */
73
- set(updates: object, context?: mixed): Promise<any>;
74
- /**
75
- * Get the value of a paramter of the state.
76
- *
77
- * @param {string} name - Name of the param.
78
- * @throws Throws if `name` does not correspond to an existing field
79
- * of the state.
80
- * @return {mixed}
81
- * @example
82
- * const value = state.get('name');
83
- */
84
- get(name: string): mixed;
85
- /**
86
- * Get all the key / value pairs of the state.
87
- *
88
- * @return {object}
89
- * @example
90
- * const values = state.getValues();
91
- */
92
- getValues(): object;
93
- /**
94
- * Get the schema from which the state has been created.
95
- *
96
- * @param {string} [name=null] - If given, returns only the definition corresponding
97
- * to the given param name.
98
- * @throws Throws if `name` does not correspond to an existing field
99
- * of the state.
100
- * @return {object}
101
- * @example
102
- * const schema = state.getSchema();
103
- */
104
- getSchema(name?: string): object;
105
- /**
106
- * Get the values with which the state has been created. May defer from the
107
- * default values declared in the schema.
108
- *
109
- * @return {object}
110
- * @example
111
- * const initValues = state.getInitValues();
112
- */
113
- getInitValues(): object;
114
- /**
115
- * Get the default values as declared in the schema.
116
- *
117
- * @return {object}
118
- * @example
119
- * const defaults = state.getDefaults();
120
- */
121
- getDefaults(): object;
122
- /**
123
- * Delete the state. Only the creator/owner of the state can use this method.
124
- * All nodes attached to the state will be deteched, triggering the `onDetach`
125
- * callback. The creator of the state will also have its `onDelete` callback
126
- * triggered.
127
- *
128
- * @throws Throws if the method is called by a node which is not the owner of
129
- * the state.
130
- * @example
131
- * const state = await client.state.create('my-schema-name');
132
- * // later
133
- * await state.delete();
134
- */
135
- delete(): Promise<any>;
136
- /**
137
- * Subscribe to state updates.
138
- *
139
- * @param {client.SharedState~onUpdateCallback|client.SharedState~onUpdateCallback} callback
140
- * Callback to execute when an update is applied on the state.
141
- * @param {Boolean} [executeListener=false] - Execute the callback immediately
142
- * with current state values. (`oldValues` will be set to `{}`, and `context` to `null`)
143
- * @returns {client.SharedState~deleteOnUpdateCallback|server.SharedState~deleteOnUpdateCallback}
144
- * @example
145
- * const unsubscribe = state.onUpdate(async (newValues, oldValues, context) => {
146
- * for (let [key, value] of Object.entries(newValues)) {
147
- * switch (key) {
148
- * // do something
149
- * }
150
- * }
151
- * });
152
- *
153
- * // later
154
- * unsubscribe();
155
- */
156
- onUpdate(listener: any, executeListener?: boolean): client.SharedState;
157
- /**
158
- * Register a function to execute when detaching from the state
159
- *
160
- * @param {Function} callback - callback to execute when detaching from the state.
161
- * wether the client as called `detach`, or the state has been deleted by its
162
- * creator.
163
- */
164
- onDetach(callback: Function): () => boolean;
165
- /**
166
- * Register a function to execute when the state is deleted. Only called if the
167
- * node was the creator of the state. Is called after `onDetach`
168
- *
169
- * @param {Function} callback - callback to execute when the state is deleted.
170
- */
171
- onDelete(callback: Function): () => boolean;
172
- }
173
- //# sourceMappingURL=BaseSharedState.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BaseSharedState.d.ts","sourceRoot":"","sources":["../../src/common/BaseSharedState.js"],"names":[],"mappings":";AAoBA;IACE,4HAwHC;IAvHC,QAAY;IACZ,cAAwB;IACxB,gBAA4B;IAE5B,eAAe;IACf,iBAAuB;IACvB,eAAe;IACf,gBAAqB;IACrB,eAAe;IACf,iBAAuB;IAGrB,eAAe;IACf,oBAAuD;IAQzD,eAAe;IACf,2BAAmC;IACnC,eAAe;IACf,2BAAmC;IACnC,eAAe;IACf,2BAAmC;IA+FrC,eAAe;IACf,qBASC;IAsND;;;;;;;;OAQG;IACH,uBAcC;IA3OD,eAAe;IACf,wBAOC;IAED,eAAe;IACf,gBAoDC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACH,aATW,MAAM,oBAIJ,YAAe,CAmD3B;IAED;;;;;;;;;OASG;IACH,UAPW,MAAM,SAShB;IAED;;;;;;OAMG;IACH,aAJY,MAAM,CAMjB;IAED;;;;;;;;;;OAUG;IACH,iBARW,MAAM,GAIL,MAAM,CAMjB;IAED;;;;;;;OAOG;IACH,iBAJY,MAAM,CAMjB;IAED;;;;;;OAMG;IACH,eAJY,MAAM,CAMjB;IA2BD;;;;;;;;;;;;OAYG;IACH,uBAMC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,uEAaC;IAED;;;;;;OAMG;IACH,4CAGC;IAED;;;;;OAKG;IACH,4CAGC;CACF"}
@@ -1 +0,0 @@
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 +0,0 @@
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,20 +0,0 @@
1
- export default SharedStatePrivate;
2
- /**
3
- * The "real" state, this instance is kept private by the server.StateManager.
4
- * It cannot be accessed without a SharedState proxy
5
- * @private
6
- */
7
- declare class SharedStatePrivate {
8
- constructor(id: any, schemaName: any, schema: any, manager: any, initValues?: {});
9
- id: any;
10
- schemaName: any;
11
- _manager: any;
12
- _parameters: ParameterBag;
13
- _attachedClients: Map<any, any>;
14
- _creatorRemoteId: any;
15
- _creatorId: any;
16
- _attachClient(remoteId: any, client: any, isOwner?: boolean): void;
17
- _detachClient(remoteId: any, client: any): void;
18
- }
19
- import ParameterBag from "../common/ParameterBag.js";
20
- //# sourceMappingURL=SharedStatePrivate.d.ts.map
@@ -1 +0,0 @@
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 +0,0 @@
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 +0,0 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/common/logger.js"],"names":[],"mappings":";;;IASE,uCAEC;IAED,+BAOC;IAED,gEAgEC;IAED,0DAMC;IAED,sCAMC;IAED,wCAMC;IAED,sCAMC;IAED,wCAMC;IAED,6BAMC;IAED,8BAMC;IAED,+BAMC"}
@@ -1,4 +0,0 @@
1
- export function storeRequestPromise(resolve: any, reject: any): number | void;
2
- export function resolveRequest(reqId: any, data: any): void;
3
- export function rejectRequest(reqId: any, data: any): void;
4
- //# sourceMappingURL=promise-store.d.ts.map
@@ -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"}
@@ -1 +0,0 @@
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,5 +0,0 @@
1
- export function idGenerator(): Generator<number, void, unknown>;
2
- export function isString(val: any): boolean;
3
- export function isFunction(func: any): boolean;
4
- export const isBrowser: Function;
5
- //# sourceMappingURL=utils.d.ts.map
@@ -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"}