@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
@@ -36,5 +36,10 @@ declare class Client {
36
36
  * @type {server.Socket}
37
37
  */
38
38
  socket: server.Socket;
39
+ /**
40
+ * Is set in server._onSocketConnection
41
+ * @private
42
+ */
43
+ private token;
39
44
  }
40
45
  //# sourceMappingURL=Client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../../src/server/Client.js"],"names":[],"mappings":";AAMA;;;;;;GAMG;AACH;IACE;;;OAGG;IACH,iDA4BC;IA3BC;;;;OAIG;IACH,aAAgB;IAEhB;;;;OAIG;IACH,WAAiC;IAEjC;;;;OAIG;IACH,aAAkB;IAElB;;;;OAIG;IACH,sBAAoB;CAEvB"}
1
+ {"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../../src/server/Client.js"],"names":[],"mappings":";AAKA;;;;;;GAMG;AACH;IACE;;;OAGG;IACH,iDAkCC;IAjCC;;;;OAIG;IACH,aAAgB;IAEhB;;;;OAIG;IACH,WAAiC;IAEjC;;;;OAIG;IACH,aAAkB;IAElB;;;;OAIG;IACH,sBAAoB;IAEpB;;;OAGG;IACH,cAAiB;CAEpB"}
@@ -1,59 +1,199 @@
1
1
  export default Context;
2
2
  /**
3
- * Base class to extend in order to create the server-side counterpart of
4
- * a {@link client.Context}. If not defined, a default context will be created
3
+ * Base class to extend in order to implment the optionnal server-side counterpart
4
+ * of a {@link client.Context}. If not defined, a default context will be created
5
5
  * and used by the server.
6
6
  *
7
+ * In the `soundworks` paradigm, a client has a "role" (e.g. _player_, _controller_)
8
+ * see {@link client.Client#role}) and can be in different "contexts" (e.g. different
9
+ * part of the experience such as sections of a music piece, etc.). The
10
+ * {@link client.Context} and optionnal {@link serverContext} abstractions provide
11
+ * a simple and unified way to model these reccuring aspects of an application.
12
+ *
13
+ * If a `server.Context` is recognized as the server-side counterpart of a
14
+ * {@link client.Context}, based on their respective `name` (see {@link client.Context#name}
15
+ * and {@link server.Context#name}), `soundworks` will ensure the logic defined
16
+ * by the server-side Context will be executed at the beginning of the
17
+ * {@link client.Client#enter} and {@link client.Client#exit} methods. The example
18
+ * show how soundwords handles (and guarantees) the order of the `enter()` steps
19
+ * between the client-side and the server-side parts of the context. The same goes
20
+ * for the `exit()` method.
21
+ *
22
+ * ```
23
+ * // client-side
24
+ * import { Context } from '@soundworks/core/client.js';
25
+ *
26
+ * class MyContext extends Context {
27
+ * async enter() {
28
+ * // 1. client side context enter() starts
29
+ * // server-side logic is triggered first
30
+ * await super.enter();
31
+ * // 4. server-side context enter() is fully done
32
+ * // some async job can be done here
33
+ * await new Promise(resolve => setTimeout(resolve, 1000));
34
+ * // 5. client-side context enter() ends
35
+ * }
36
+ * }
37
+ *
38
+ * // Instanciate the context (assuming the `client.role` is 'test')
39
+ * const myContext = new MyContext(client);
40
+ *
41
+ * // At some point in the application, the client enters the context trigerring
42
+ * // the steps 1 to 5 described in the client-side and server-side `enter()`
43
+ * // implementations. Note that the server-side `enter()` is never called manually.
44
+ * await myContext.enter();
45
+ * ```
46
+ *
47
+ * ```
48
+ * // server-side
49
+ * import { Context } from '@soundworks/core/server.js';
50
+ *
51
+ * class MyContext extends Context {
52
+ * async enter(client) {
53
+ * // 2. server-side context enter() starts
54
+ * await super.enter(client);
55
+ * // some async job can be done here
56
+ * await new Promise(resolve => setTimeout(resolve, 1000));
57
+ * // 3. server-side context enter() ends
58
+ * }
59
+ * }
60
+ *
61
+ * // Instantiate the context
62
+ * const myContext = new Context(server);
63
+ * ```
64
+ *
7
65
  * @memberof server
8
66
  */
9
67
  declare class Context {
10
- constructor(server: any, roles?: any[]);
68
+ /**
69
+ * @param {client.Client} client - The soundworks client instance.
70
+ * @param {string|string[]} [roles=[]] - Optionnal list of client roles that can
71
+ * use this context. In large applications, this may be usefull to guarantee
72
+ * that a context can be consumed only by specific client roles, throwing an
73
+ * error if any other client role tries to use it. If empty, no access policy
74
+ * will be used.
75
+ * @throws Will throw if the first argument is not a soundworks server instance.
76
+ */
77
+ constructor(server: any, roles?: string | string[]);
11
78
  /**
12
79
  * soundworks server
13
80
  * @type {server.Server}
81
+ * @readonly
14
82
  */
15
- server: server.Server;
83
+ readonly server: server.Server;
16
84
  /**
17
85
  * List of clients that are currently in this context
18
- * @type {Client[]}
86
+ * @type {server.Client[]}
19
87
  */
20
- clients: Client[];
88
+ clients: server.Client[];
21
89
  /**
22
90
  * Status of the context ('idle', 'inited', 'started' or 'errored')
23
- * @type {String}
91
+ * @type {string}
92
+ * @readonly
24
93
  */
25
- status: string;
26
- roles: Set<any>;
94
+ readonly status: string;
95
+ roles: Set<string>;
27
96
  /**
28
- * Name of the context, default to the class name.
29
- * Override the `get name()` getter to use a user-defined context name.
97
+ * Optionnal user-defined name of the context (defaults to the class name).
98
+ *
99
+ * The context manager will match the client-side and server-side contexts based
100
+ * on this name. If the {@link server.ContextManager} don't find a corresponding
101
+ * user-defined context with the same name, it will use a default (noop) context.
102
+ *
103
+ * @readonly
104
+ * @type {string}
105
+ * @example
106
+ * // server-side and client-side contexts are matched based on their respective `name`
107
+ * class MyContext extends Context {
108
+ * get name() {
109
+ * return 'my-user-defined-context-name';
110
+ * }
111
+ * }
30
112
  */
31
- get name(): string;
113
+ readonly get name(): string;
32
114
  /**
33
- * Method automatically called when the server starts, or lazilly called if
34
- * the context is created after `server.start()`
115
+ * Start the context. This method is lazilly called when a client enters the
116
+ * context for the first time (cf. ${server.Context#enter}). If you know some
117
+ * some heavy and/or potentially long job has to be done when starting the context
118
+ * (e.g. connect to a database, parsing a long file) it may be a good practice
119
+ * to call it explicitely.
35
120
  *
36
- * _WARNING: this method should never be called manually._
121
+ * This method should be implemented to perform operations that are valid for the
122
+ * whole lifetime of the context, regardless a client enters or exits the context.
123
+ *
124
+ * @example
125
+ * import { Context } from '@soundworks/core/server.js';
126
+ *
127
+ * class MyContext extends Context {
128
+ * async start() {
129
+ * await super.start();
130
+ * await this.doSomeLongJob();
131
+ * }
132
+ * }
133
+ *
134
+ * // Instantiate the context
135
+ * const myContext = new Context(server, ['test']);
136
+ * // manually start the context to perform the long operation before the first
137
+ * // client enters the context
138
+ * await myContext.start();
139
+ * ```
37
140
  */
38
141
  start(): Promise<void>;
39
142
  /**
40
- * Method automatically called when the server stops.
143
+ * Stop the context. The method that is automatically called when the server
144
+ * stops. It should be used to cleanup context wise operations made in `start()`
145
+ * (e.g. disconnect from a database, release a file handle).
41
146
  *
42
147
  * _WARNING: this method should never be called manually._
43
148
  */
44
149
  stop(): Promise<void>;
45
150
  /**
46
- * Method automatically called when the client enters the context.
151
+ * Enter the context. Implement this method to define the logic that should be
152
+ * done (e.g. creating a shared state, etc.) when a client enters the context.
153
+ *
154
+ * If the context has not been started yet, the `start` method is implicitely executed.
47
155
  *
48
156
  * _WARNING: this method should never be called manually._
157
+ *
158
+ * @param {server.Client} client - Server-side representation of the client
159
+ * that enters the context.
160
+ * @returns {Promise} - Promise that resolves when the context is entered.
161
+ * @example
162
+ * class MyContext extends Context {
163
+ * async enter(client) {
164
+ * await super.enter(client);
165
+ * registerTheClientSomewhere(client);
166
+ * }
167
+ *
168
+ * async exit(client) {
169
+ * await super.exit(client);
170
+ * unregisterTheClientSomewhere(client);
171
+ * }
172
+ * }
49
173
  */
50
- enter(client: any): Promise<void>;
174
+ enter(client: server.Client): Promise<any>;
51
175
  /**
52
- * Method automatically called when the client exits the context.
176
+ * Exit the context. Implement this method to define the logic that should be
177
+ * done (e.g. delete a shared state, etc.) when a client exits the context.
53
178
  *
54
- * _WARNING: this method should never be called manually._
179
+ * * _WARNING: this method should never be called manually._
180
+ *
181
+ * @param {server.Client} client - Server-side representation of the client
182
+ * that exits the context.
183
+ * @returns {Promise} - Promise that resolves when the context is exited.
184
+ * @example
185
+ * class MyContext extends Context {
186
+ * async enter(client) {
187
+ * await super.enter(client);
188
+ * this.state = await this.client.stateManager.create('my-context-state');
189
+ * }
190
+ *
191
+ * async exit(client) {
192
+ * await super.exit(client);
193
+ * await this.state.delete();
194
+ * }
195
+ * }
55
196
  */
56
- exit(client: any): Promise<void>;
197
+ exit(client: server.Client): Promise<any>;
57
198
  }
58
- import Client from "./Client.js";
59
199
  //# sourceMappingURL=Context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../src/server/Context.js"],"names":[],"mappings":";AAGA;;;;;;GAMG;AACH;IACE,wCAmCC;IA1BC;;;OAGG;IACH,sBAAoB;IAEpB;;;OAGG;IACH,SAFU,MAAM,EAAE,CAEM;IAExB;;;OAGG;IACH,eAAoB;IAMpB,gBAA2B;IAM7B;;;OAGG;IACH,mBAEC;IAED;;;;;OAKG;IACH,uBAAgB;IAEhB;;;;OAIG;IACH,sBAAe;IAEf;;;;OAIG;IACH,kCAMC;IAED;;;;OAIG;IACH,iCAMC;CACF"}
1
+ {"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../src/server/Context.js"],"names":[],"mappings":";AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AACH;IACE;;;;;;;;OAQG;IACH,iCAPW,MAAM,GAAC,MAAM,EAAE,EA+CzB;IAnCC;;;;OAIG;IACH,+BAAoB;IAEpB;;;OAGG;IACH,SAFU,eAAe,CAED;IAExB;;;;OAIG;IACH,iBAHU,MAAM,CAGI;IAapB,mBAA2B;IAM7B;;;;;;;;;;;;;;;;OAgBG;IACH,4BAEC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,uBAAgB;IAEhB;;;;;;OAMG;IACH,sBAAe;IAEf;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,2CAMC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,0CAMC;CACF"}
@@ -6,6 +6,7 @@ export default ContextManager;
6
6
  * _WARNING: Most of the time, you should not have to manipulate the context manager directly._
7
7
  *
8
8
  * @memberof server
9
+ * @hideconstructor
9
10
  */
10
11
  declare class ContextManager {
11
12
  /**
@@ -30,12 +31,11 @@ declare class ContextManager {
30
31
  /**
31
32
  * Retrieve a started context from its name.
32
33
  *
33
- * @see {server.Context#name}
34
- * @param {String} contextName - Name of the context.
34
+ * _WARNING: Most of the time, you should not have to call this method manually._
35
35
  *
36
- * @private
36
+ * @param {server.Context#name} contextName - Name of the context.
37
37
  */
38
- private get;
38
+ get(contextName: any): Promise<any>;
39
39
  /**
40
40
  * Called when a client connects to the server (websocket handshake)
41
41
  *
@@ -1 +1 @@
1
- {"version":3,"file":"ContextManager.d.ts","sourceRoot":"","sources":["../../src/server/ContextManager.js"],"names":[],"mappings":";AAoDA;;;;;;;GAOG;AACH;IACE;;OAEG;IACH,mCAOC;IANC,eAAe;IACf,eAAoB;IACpB,eAAe;IACf,kBAAwC;IACxC,eAAe;IACf,8BAAsC;IAGxC;;;;;;;OAOG;IACH,iBAOC;IAED;;;;;;;OAOG;IACH,YAyBC;IAED;;;;;;OAMG;IACH,kBA0FC;IAED;;;;;;OAMG;IACH,qBAUC;IAED;;;;;OAKG;IACH,cAGC;IAED;;;;OAIG;IACH,aAGC;CACF"}
1
+ {"version":3,"file":"ContextManager.d.ts","sourceRoot":"","sources":["../../src/server/ContextManager.js"],"names":[],"mappings":";AAoDA;;;;;;;;GAQG;AACH;IACE;;OAEG;IACH,mCAOC;IANC,eAAe;IACf,eAAoB;IACpB,eAAe;IACf,kBAAwC;IACxC,eAAe;IACf,8BAAsC;IAGxC;;;;;;;OAOG;IACH,iBAOC;IAED;;;;;;OAMG;IACH,oCAyBC;IAED;;;;;;OAMG;IACH,kBAyFC;IAED;;;;;;OAMG;IACH,qBAUC;IAED;;;;;OAKG;IACH,cAGC;IAED;;;;OAIG;IACH,aAGC;CACF"}
@@ -3,68 +3,69 @@ export namespace server {
3
3
  /**
4
4
  * ~onStateChangeCallback
5
5
  */
6
- export type Plugin = (#state: server.Plugin) => any;
6
+ type Plugin = (#state: server.Plugin) => any;
7
+ }
8
+ /**
9
+ * Callback executed when the plugin state is updated.
10
+ *
11
+ * @callback server.Plugin~onStateChangeCallback
12
+ * @param {server.Plugin#state} state - Current state of the plugin.
13
+ */
14
+ /**
15
+ * Delete the registered {@link server.Plugin~onStateChangeCallback}.
16
+ *
17
+ * @callback server.Plugin~deleteOnStateChangeCallback
18
+ */
19
+ /**
20
+ * Base class to extend in order to create the server-side counterpart of a
21
+ * `soundworks` plugin.
22
+ *
23
+ * In the `soundworks` paradigm, a plugin is a component that allows to extend
24
+ * the framework capabilities by encapsulating common and reusable logic in
25
+ * an application wise perspective. For example, plugins are available to handle
26
+ * clock synchronization, to deal with the file system, etc. Plugin should always
27
+ * have both a client-side and a server-side part.
28
+ *
29
+ * See [https://soundworks.dev/guide/ecosystem](https://soundworks.dev/guide/ecosystem)
30
+ * for more informations on the available plugins.
31
+ *
32
+ * _Creating new plugins should be considered an advanced usage._
33
+ *
34
+ * @memberof server
35
+ * @extends BasePlugin
36
+ * @inheritdoc
37
+ */
38
+ declare class Plugin extends BasePlugin {
7
39
  /**
8
- * Callback executed when the plugin state is updated.
9
- *
10
- * @callback server.Plugin~onStateChangeCallback
11
- * @param {server.Plugin#state} state - Current state of the plugin.
40
+ * @param {server.Server} server - The soundworks server instance.
41
+ * @param {string} id - User defined id of the plugin as defined in
42
+ * {@link server.PluginManager#register}.
12
43
  */
44
+ constructor(server: server.Server, id: string);
13
45
  /**
14
- * Delete the registered {@link server.Plugin~onStateChangeCallback}.
15
- *
16
- * @callback server.Plugin~deleteOnStateChangeCallback
46
+ * Instance of soundworks server.
47
+ * @type {server.Server}
48
+ * @see {@link server.Server}
17
49
  */
50
+ server: server.Server;
51
+ /** @private */
52
+ private clients;
18
53
  /**
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.
54
+ * Method called when a client (which registered the client-side plugin),
55
+ * connects to the application. Override this method if you need to perform
56
+ * some particular logic (e.g. creating a shared state) for each clients.
26
57
  *
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._
58
+ * @param {server.Client} client
59
+ */
60
+ addClient(client: server.Client): Promise<void>;
61
+ /**
62
+ * Method called when a client (which registered the client-side plugin),
63
+ * disconnects from the application. Override this method if you need to perform
64
+ * some particular logic (e.g. creating a shared state) for each clients.
31
65
  *
32
- * @memberof server
33
- * @extends BasePlugin
34
- * @inheritdoc
66
+ * @param {server.Client} client
35
67
  */
36
- class Plugin extends BasePlugin {
37
- /**
38
- * @param {server.Server} server - The soundworks server instance.
39
- * @param {string} id - User defined id of the plugin as defined in
40
- * {@link server.PluginManager#register}.
41
- */
42
- constructor(server: server.Server, id: string);
43
- /**
44
- * Instance of soundworks server.
45
- * @type {server.Server}
46
- * @see {@link server.Server}
47
- */
48
- server: server.Server;
49
- /** @private */
50
- private clients;
51
- /**
52
- * Method called when a client (which registered the client-side plugin),
53
- * connects to the application. Override this method if you need to perform
54
- * some particular logic (e.g. creating a shared state) for each clients.
55
- *
56
- * @param {server.Client} client
57
- */
58
- addClient(client: server.Client): Promise<void>;
59
- /**
60
- * Method called when a client (which registered the client-side plugin),
61
- * disconnects from the application. Override this method if you need to perform
62
- * some particular logic (e.g. creating a shared state) for each clients.
63
- *
64
- * @param {server.Client} client
65
- */
66
- removeClient(client: server.Client): Promise<void>;
67
- }
68
+ removeClient(client: server.Client): Promise<void>;
68
69
  }
69
- import BasePlugin from "../common/BasePlugin.js";
70
+ import BasePlugin from '../common/BasePlugin.js';
70
71
  //# sourceMappingURL=Plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../src/server/Plugin.js"],"names":[],"mappings":";;;;;kCAMW,aAAa;IAJxB;;;;;OAKG;IAEH;;;;OAIG;IAEH;;;;;;;;;;;;;;;;;OAiBG;IACH;QACE;;;;WAIG;QACH,uCAHW,MAAM,EAehB;QATC;;;;WAIG;QACH,sBAAoB;QAEpB,eAAe;QACf,gBAAwB;QAG1B;;;;;;WAMG;QACH,gDAEC;QAED;;;;;;WAMG;QACH,mDAEC;KACF"}
1
+ {"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../src/server/Plugin.js"],"names":[],"mappings":";;;;;2BAMW,aAAa;;AAJxB;;;;;GAKG;AAEH;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AACH;IACE;;;;OAIG;IACH,uCAHW,MAAM,EAehB;IATC;;;;OAIG;IACH,sBAAoB;IAEpB,eAAe;IACf,gBAAwB;IAG1B;;;;;;OAMG;IACH,gDAEC;IAED;;;;;;OAMG;IACH,mDAEC;CACF;uBA3EsB,yBAAyB"}
@@ -24,7 +24,7 @@ export namespace server {
24
24
  *
25
25
  * Plugins should always be registered both client-side and server-side,
26
26
  * and before {@link client.Client#start} or {@link server.Server#start}
27
- * are called for proper initialization.
27
+ * to be properly initialized.
28
28
  *
29
29
  * In some sitautions, you might want to register the same plugin factory several times
30
30
  * using different ids (e.g. for watching several parts of the file system, etc.).
@@ -34,12 +34,32 @@ export namespace server {
34
34
  * for more informations on the available plugins.
35
35
  *
36
36
  * ```
37
+ * // client-side
38
+ * import { Client } from '@soundworks/core/client.js';
39
+ * import syncPlugin from '@soundworks/plugin-sync/client.js';
40
+ *
41
+ * const client = new Client(config);
42
+ * // register the plugin before `client.start()`
43
+ * client.pluginManager.register('sync', syncPlugin);
44
+ *
45
+ * await client.start();
46
+ *
47
+ * const sync = await client.pluginManager.get('sync');
48
+ *
49
+ * setInterval(() => {
50
+ * // log the estimated global synced clock alongside the local clock.
51
+ * console.log(sync.getSyncTime(), sync.getLocalTime());
52
+ * }, 1000);
53
+ * ```
54
+ *
55
+ * ```
56
+ * // server-side
37
57
  * import { Server } from '@soundworks/core/server.js';
38
- * import platformPlugin from '@soundworks/plugin-sync/server.js';
58
+ * import syncPlugin from '@soundworks/plugin-sync/server.js';
39
59
  *
40
60
  * const server = new Server(config);
41
61
  * // register the plugin before `server.start()`
42
- * server.pluginManager.register('sync', pluginSync);
62
+ * server.pluginManager.register('sync', syncPlugin);
43
63
  *
44
64
  * await server.start();
45
65
  *
@@ -70,8 +90,8 @@ declare class PluginManager extends BasePluginManager {
70
90
  * initialization (e.g. to display initialization screen, etc.), you should rely
71
91
  * on the `onStateChange` method.
72
92
  *
73
- * _Note: the async API is designed to enable the dynamic creation of plugins (hopefully
74
- * without brealing changes) in a future release._
93
+ * _Note: the async API is designed to enable the dynamic creation of plugins
94
+ * (hopefully without brealing changes) in a future release._
75
95
  *
76
96
  * @param {server.Plugin#id} id - Id of the plugin as defined when registered.
77
97
  * @returns {server.Plugin}
@@ -87,5 +107,5 @@ declare class PluginManager extends BasePluginManager {
87
107
  /** @private */
88
108
  private removeClient;
89
109
  }
90
- import BasePluginManager from "../common/BasePluginManager.js";
110
+ import BasePluginManager from '../common/BasePluginManager.js';
91
111
  //# sourceMappingURL=PluginManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PluginManager.d.ts","sourceRoot":"","sources":["../../src/server/PluginManager.js"],"names":[],"mappings":";;;;;4BAQW,MAAM,aACN,gBAAc,IAAI;;AAL7B;;;;;;;;GAQG;AAEH;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH;IASE,mEAQC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,YAMC;IAID,cAAc;IACd,qDAYC;IAED,eAAe;IACf,kBAUC;IAED,eAAe;IACf,qBAUC;CACF"}
1
+ {"version":3,"file":"PluginManager.d.ts","sourceRoot":"","sources":["../../src/server/PluginManager.js"],"names":[],"mappings":";;;;;4BAQW,MAAM,aACN,gBAAc,IAAI;;AAL7B;;;;;;;;GAQG;AAEH;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH;IASE,mEAQC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,YAMC;IAID,cAAc;IACd,qDAYC;IAED,eAAe;IACf,kBAUC;IAED,eAAe;IACf,qBAUC;CACF;8BAvK6B,gCAAgC"}