@soundworks/core 3.6.0 → 4.0.0-alpha.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.
- package/.eslintrc +16 -0
- package/LICENSE +1 -1
- package/README.md +32 -30
- package/package.json +57 -26
- package/src/client/Client.js +391 -0
- package/src/client/Context.js +225 -0
- package/src/client/ContextManager.js +111 -0
- package/src/client/Plugin.js +66 -0
- package/src/client/PluginManager.js +123 -0
- package/src/client/SharedState.js +84 -0
- package/src/client/Socket.js +389 -0
- package/src/client/StateManager.js +67 -0
- package/src/client/index.js +77 -0
- package/src/common/BasePlugin.js +163 -0
- package/src/common/BasePluginManager.js +227 -0
- package/src/common/BaseSharedState.js +473 -0
- package/src/common/BaseStateManager.js +200 -0
- package/{common → src/common}/ParameterBag.js +82 -122
- package/{common → src/common}/SharedStatePrivate.js +56 -64
- package/src/common/constants.js +51 -0
- package/src/common/logger.js +154 -0
- package/src/common/promise-store.js +25 -0
- package/src/common/sockets-utils.js +73 -0
- package/src/common/utils.js +22 -0
- package/src/server/Client.js +50 -0
- package/src/server/Context.js +99 -0
- package/src/server/ContextManager.js +266 -0
- package/src/server/Plugin.js +77 -0
- package/src/server/PluginManager.js +150 -0
- package/src/server/Server.js +849 -0
- package/src/server/SharedState.js +86 -0
- package/{server → src/server}/Socket.js +119 -94
- package/{server → src/server}/Sockets.js +73 -61
- package/{common/SharedStateManagerServer.js → src/server/StateManager.js} +183 -131
- package/src/server/audit-network-latency.worker.js +57 -0
- package/src/server/audit-schema.js +42 -0
- package/src/server/index.js +45 -0
- package/tsconfig.json +21 -0
- package/types/client/Client.d.ts +194 -0
- package/types/client/Client.d.ts.map +1 -0
- package/types/client/Context.d.ts +139 -0
- package/types/client/Context.d.ts.map +1 -0
- package/types/client/ContextManager.d.ts +45 -0
- package/types/client/ContextManager.d.ts.map +1 -0
- package/types/client/Plugin.d.ts +53 -0
- package/types/client/Plugin.d.ts.map +1 -0
- package/types/client/PluginManager.d.ts +96 -0
- package/types/client/PluginManager.d.ts.map +1 -0
- package/types/client/SharedState.d.ts +85 -0
- package/types/client/SharedState.d.ts.map +1 -0
- package/types/client/Socket.d.ts +138 -0
- package/types/client/Socket.d.ts.map +1 -0
- package/types/client/StateManager.d.ts +72 -0
- package/types/client/StateManager.d.ts.map +1 -0
- package/types/client/index.d.ts +11 -0
- package/types/client/index.d.ts.map +1 -0
- package/types/common/BasePlugin.d.ts +145 -0
- package/types/common/BasePlugin.d.ts.map +1 -0
- package/types/common/BasePluginManager.d.ts +88 -0
- package/types/common/BasePluginManager.d.ts.map +1 -0
- package/types/common/BaseSharedState.d.ts +173 -0
- package/types/common/BaseSharedState.d.ts.map +1 -0
- package/types/common/BaseStateManager.d.ts +70 -0
- package/types/common/BaseStateManager.d.ts.map +1 -0
- package/types/common/ParameterBag.d.ts +143 -0
- package/types/common/ParameterBag.d.ts.map +1 -0
- package/types/common/SharedStatePrivate.d.ts +20 -0
- package/types/common/SharedStatePrivate.d.ts.map +1 -0
- package/types/common/constants.d.ts +35 -0
- package/types/common/constants.d.ts.map +1 -0
- package/types/common/logger.d.ts +16 -0
- package/types/common/logger.d.ts.map +1 -0
- package/types/common/promise-store.d.ts +4 -0
- package/types/common/promise-store.d.ts.map +1 -0
- package/types/common/sockets-utils.d.ts +9 -0
- package/types/common/sockets-utils.d.ts.map +1 -0
- package/types/common/utils.d.ts +5 -0
- package/types/common/utils.d.ts.map +1 -0
- package/types/server/Client.d.ts +40 -0
- package/types/server/Client.d.ts.map +1 -0
- package/types/server/Context.d.ts +59 -0
- package/types/server/Context.d.ts.map +1 -0
- package/types/server/ContextManager.d.ts +69 -0
- package/types/server/ContextManager.d.ts.map +1 -0
- package/types/server/Plugin.d.ts +70 -0
- package/types/server/Plugin.d.ts.map +1 -0
- package/types/server/PluginManager.d.ts +91 -0
- package/types/server/PluginManager.d.ts.map +1 -0
- package/types/server/Server.d.ts +223 -0
- package/types/server/Server.d.ts.map +1 -0
- package/types/server/SharedState.d.ts +86 -0
- package/types/server/SharedState.d.ts.map +1 -0
- package/types/server/Socket.d.ts +128 -0
- package/types/server/Socket.d.ts.map +1 -0
- package/types/server/Sockets.d.ts +73 -0
- package/types/server/Sockets.d.ts.map +1 -0
- package/types/server/StateManager.d.ts +190 -0
- package/types/server/StateManager.d.ts.map +1 -0
- package/types/server/audit-network-latency.worker.d.ts +2 -0
- package/types/server/audit-network-latency.worker.d.ts.map +1 -0
- package/types/server/audit-schema.d.ts +27 -0
- package/types/server/audit-schema.d.ts.map +1 -0
- package/types/server/index.d.ts +7 -0
- package/types/server/index.d.ts.map +1 -0
- package/client/AbstractExperience.js +0 -54
- package/client/AbstractPlugin.js +0 -230
- package/client/Client.js +0 -190
- package/client/PluginManager.js +0 -267
- package/client/Socket.js +0 -338
- package/client/index.js +0 -48
- package/client.js +0 -28
- package/common/SharedState.js +0 -480
- package/common/SharedStateManagerClient.js +0 -194
- package/common/Signal.js +0 -40
- package/common/SignalAll.js +0 -44
- package/common/shared-state-utils.js +0 -90
- package/common/sockets-encoder-decoder.js +0 -73
- package/server/AbstractExperience.js +0 -126
- package/server/AbstractPlugin.js +0 -211
- package/server/Client.js +0 -70
- package/server/PluginManager.js +0 -177
- package/server/Server.js +0 -746
- package/server/index.js +0 -49
- package/server/utils/logger.js +0 -134
- package/server.js +0 -28
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export default BaseStateManager;
|
|
2
|
+
/**
|
|
3
|
+
* @private
|
|
4
|
+
*/
|
|
5
|
+
declare class BaseStateManager {
|
|
6
|
+
/**
|
|
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.
|
|
10
|
+
*/
|
|
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>;
|
|
20
|
+
/**
|
|
21
|
+
* Create a `SharedState` instance from a registered schema.
|
|
22
|
+
*
|
|
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}
|
|
29
|
+
* @example
|
|
30
|
+
* const state = await client.stateManager.create('my-schema');
|
|
31
|
+
*/
|
|
32
|
+
create(schemaName: string, initValues?: any): client.SharedState | server.SharedState;
|
|
33
|
+
/**
|
|
34
|
+
* Attach to an existing `SharedState` instance.
|
|
35
|
+
*
|
|
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
|
+
* @example
|
|
45
|
+
* const state = await client.stateManager.attach('my-schema');
|
|
46
|
+
*/
|
|
47
|
+
attach(schemaName: string, stateId?: any): client.SharedState | server.SharedState;
|
|
48
|
+
/**
|
|
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.
|
|
53
|
+
*
|
|
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
|
+
* @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());
|
|
65
|
+
* }
|
|
66
|
+
* });
|
|
67
|
+
*/
|
|
68
|
+
observe(callback: any): Promise<Function>;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=BaseStateManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseStateManager.d.ts","sourceRoot":"","sources":["../../src/common/BaseStateManager.js"],"names":[],"mappings":";AAoBA;;GAEG;AACH;IACE;;;;OAIG;IACH,wCA4FC;IA3FC;;;MAA+B;IAE/B,2BAA4B;IAC5B,4BAAkC;IAClC,8BAA+B;IAC/B,wCAAyC;IAwF3C;;;;;;;;;;;OAWG;IACH,8CANa,uCAAqC,CAYjD;IAED;;;;;;;;;;;;;OAaG;IACH,2CANa,uCAAqC,CAajD;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,wBAXa,iBAAiB,CAoB7B;CACF"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
export namespace sharedOptions {
|
|
2
|
+
const nullable: boolean;
|
|
3
|
+
const event: boolean;
|
|
4
|
+
const metas: {};
|
|
5
|
+
const filterChange: boolean;
|
|
6
|
+
const immediate: boolean;
|
|
7
|
+
}
|
|
8
|
+
export namespace types {
|
|
9
|
+
export namespace boolean {
|
|
10
|
+
const required: string[];
|
|
11
|
+
function coerceFunction(name: any, def: any, value: any): boolean;
|
|
12
|
+
}
|
|
13
|
+
export namespace string {
|
|
14
|
+
const required_1: string[];
|
|
15
|
+
export { required_1 as required };
|
|
16
|
+
export function coerceFunction_1(name: any, def: any, value: any): string;
|
|
17
|
+
export { coerceFunction_1 as coerceFunction };
|
|
18
|
+
}
|
|
19
|
+
export namespace integer {
|
|
20
|
+
const required_2: string[];
|
|
21
|
+
export { required_2 as required };
|
|
22
|
+
export function sanitizeSchema(def: any): any;
|
|
23
|
+
export function coerceFunction_2(name: any, def: any, value: any): number;
|
|
24
|
+
export { coerceFunction_2 as coerceFunction };
|
|
25
|
+
}
|
|
26
|
+
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 };
|
|
31
|
+
export function coerceFunction_3(name: any, def: any, value: any): number;
|
|
32
|
+
export { coerceFunction_3 as coerceFunction };
|
|
33
|
+
}
|
|
34
|
+
export namespace _enum {
|
|
35
|
+
const required_4: string[];
|
|
36
|
+
export { required_4 as required };
|
|
37
|
+
export function coerceFunction_4(name: any, def: any, value: any): any;
|
|
38
|
+
export { coerceFunction_4 as coerceFunction };
|
|
39
|
+
}
|
|
40
|
+
export { _enum as enum };
|
|
41
|
+
export namespace any {
|
|
42
|
+
const required_5: string[];
|
|
43
|
+
export { required_5 as required };
|
|
44
|
+
export function coerceFunction_5(name: any, def: any, value: any): any;
|
|
45
|
+
export { coerceFunction_5 as coerceFunction };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export default ParameterBag;
|
|
49
|
+
export namespace server {
|
|
50
|
+
/**
|
|
51
|
+
* ~schema
|
|
52
|
+
*
|
|
53
|
+
* Description of a schema to be register by the {@link server.ServerStateManagerServer }
|
|
54
|
+
* A schema consists of a combinaison of key value pairs where the key is the
|
|
55
|
+
* name of the parameter, and the value is an object describing the parameter.
|
|
56
|
+
*
|
|
57
|
+
* Available types are:
|
|
58
|
+
* - {@link server.SharedStateManagerServer ~schemaBooleanDef}
|
|
59
|
+
* - {@link server.SharedStateManagerServer ~schemaStringDef}
|
|
60
|
+
* - {@link server.SharedStateManagerServer ~schemaIntegerDef}
|
|
61
|
+
* - {@link server.SharedStateManagerServer ~schemaFloatDef}
|
|
62
|
+
* - {@link server.SharedStateManagerServer ~schemaEnumDef}
|
|
63
|
+
* - {@link server.SharedStateManagerServer ~schemaAnyDef}
|
|
64
|
+
*/
|
|
65
|
+
type SharedStateManagerServer = any;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Bag of parameters.
|
|
69
|
+
* @private
|
|
70
|
+
*/
|
|
71
|
+
declare class ParameterBag {
|
|
72
|
+
static validateSchema(schema: any): void;
|
|
73
|
+
constructor(schema: any, initValues?: {});
|
|
74
|
+
/**
|
|
75
|
+
* List of parameters.
|
|
76
|
+
*
|
|
77
|
+
* @type {Object<String, Param>}
|
|
78
|
+
* @name _params
|
|
79
|
+
* @memberof ParameterBag
|
|
80
|
+
* @instance
|
|
81
|
+
* @private
|
|
82
|
+
*/
|
|
83
|
+
private _values;
|
|
84
|
+
/**
|
|
85
|
+
* List of schema with init values.
|
|
86
|
+
*
|
|
87
|
+
* @type {Object<String, paramDefinition>}
|
|
88
|
+
* @name _schema
|
|
89
|
+
* @memberof ParameterBag
|
|
90
|
+
* @instance
|
|
91
|
+
* @private
|
|
92
|
+
*/
|
|
93
|
+
private _schema;
|
|
94
|
+
/**
|
|
95
|
+
* Define if the parameter exists.
|
|
96
|
+
*
|
|
97
|
+
* @param {String} name - Name of the parameter.
|
|
98
|
+
* @return {Boolean}
|
|
99
|
+
*/
|
|
100
|
+
has(name: string): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Return values of all parameters as a flat object.
|
|
103
|
+
*
|
|
104
|
+
* @return {Object}
|
|
105
|
+
*/
|
|
106
|
+
getValues(): any;
|
|
107
|
+
/**
|
|
108
|
+
* Return the value of the given parameter. If the parameter is of `any` type,
|
|
109
|
+
* a deep copy is returned.
|
|
110
|
+
*
|
|
111
|
+
* @param {String} name - Name of the parameter.
|
|
112
|
+
* @return {Mixed} - Value of the parameter.
|
|
113
|
+
*/
|
|
114
|
+
get(name: string): Mixed;
|
|
115
|
+
/**
|
|
116
|
+
* Set the value of a parameter. If the value of the parameter is updated
|
|
117
|
+
* (aka if previous value is different from new value) all registered
|
|
118
|
+
* callbacks are registered.
|
|
119
|
+
*
|
|
120
|
+
* @param {String} name - Name of the parameter.
|
|
121
|
+
* @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
|
+
* @return {Array} - [new value, updated flag].
|
|
125
|
+
*/
|
|
126
|
+
set(name: string, value: Mixed): any[];
|
|
127
|
+
/**
|
|
128
|
+
* Reset a parameter to its initialization values. Reset all parameters if no argument.
|
|
129
|
+
* @note - prefer `state.set(state.getInitValues())`
|
|
130
|
+
* or `state.set(state.getDefaultValues())`
|
|
131
|
+
*
|
|
132
|
+
* @param {String} [name=null] - Name of the parameter to reset.
|
|
133
|
+
*/
|
|
134
|
+
/**
|
|
135
|
+
* Return the given schema along with the initialization values.
|
|
136
|
+
*
|
|
137
|
+
* @return {Object}
|
|
138
|
+
*/
|
|
139
|
+
getSchema(name?: any): any;
|
|
140
|
+
getInitValues(): {};
|
|
141
|
+
getDefaults(): {};
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=ParameterBag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ParameterBag.d.ts","sourceRoot":"","sources":["../../src/common/ParameterBag.js"],"names":[],"mappings":";;;;;;;;;;QA8MoB,kEAMf;;;;;QAOe,0EAMf;;;;;;QAUe,8CAgBf;QACe,0EAMf;;;;;;QAUe,gDAgBf;;QACe,0EAMf;;;;;;QAOe,uEAOf;;;;;;;QAOe,uEAGf;;;;;;;;;;;;;;;;;;;;;;;AAKL;;;GAGG;AACH;IACE,yCAsBC;IAED,0CAsEC;IA9DC;;;;;;;;OAQG;IACH,gBAAiB;IAEjB;;;;;;;;OAQG;IACH,gBAAiB;IA4CnB;;;;;OAKG;IACH,2BAEC;IAED;;;;OAIG;IACH,iBAQC;IAED;;;;;;OAMG;IACH,yBAUC;IAED;;;;;;;;;;OAUG;IACH,uCAuBC;IAED;;;;;;OAMG;IAWH;;;;OAIG;IACH,2BAUC;IAGD,oBAMC;IAGD,kBAMC;CACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SharedStatePrivate.d.ts","sourceRoot":"","sources":["../../src/common/SharedStatePrivate.js"],"names":[],"mappings":";AAaA;;;;GAIG;AACH;IACE,kFAUC;IATC,QAAY;IACZ,gBAA4B;IAE5B,cAAuB;IACvB,0BAAuD;IACvD,gCAAiC;IAEjC,sBAA4B;IAC5B,gBAAsB;IAGxB,mEAmJC;IAED,gDAMC;CACF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export const SERVER_ID: -1;
|
|
2
|
+
export const CREATE_REQUEST: "s:c:req";
|
|
3
|
+
export const CREATE_RESPONSE: "s:c:res";
|
|
4
|
+
export const CREATE_ERROR: "s:c:err";
|
|
5
|
+
export const DELETE_REQUEST: "s:dl:req";
|
|
6
|
+
export const DELETE_RESPONSE: "s:dl:res";
|
|
7
|
+
export const DELETE_ERROR: "s:dl:err";
|
|
8
|
+
export const DELETE_NOTIFICATION: "s:dl:not";
|
|
9
|
+
export const ATTACH_REQUEST: "s:a:req";
|
|
10
|
+
export const ATTACH_RESPONSE: "s:a:res";
|
|
11
|
+
export const ATTACH_ERROR: "s:a:err";
|
|
12
|
+
export const DETACH_REQUEST: "s:dt:req";
|
|
13
|
+
export const DETACH_RESPONSE: "s:dt:res";
|
|
14
|
+
export const DETACH_ERROR: "s:dt:err";
|
|
15
|
+
export const OBSERVE_REQUEST: "s:o:req";
|
|
16
|
+
export const OBSERVE_RESPONSE: "s:o:res";
|
|
17
|
+
export const OBSERVE_NOTIFICATION: "s:o:not";
|
|
18
|
+
export const UNOBSERVE_NOTIFICATION: "s:uo:not";
|
|
19
|
+
export const UPDATE_REQUEST: "s:u:req";
|
|
20
|
+
export const UPDATE_RESPONSE: "s:u:res";
|
|
21
|
+
export const UPDATE_ABORT: "s:u:ab";
|
|
22
|
+
export const UPDATE_NOTIFICATION: "s:u:not";
|
|
23
|
+
export const DELETE_SCHEMA: "s:d:s";
|
|
24
|
+
export const CONTEXT_ENTER_REQUEST: "c:en:req";
|
|
25
|
+
export const CONTEXT_ENTER_RESPONSE: "c:en:res";
|
|
26
|
+
export const CONTEXT_ENTER_ERROR: "c:en:err";
|
|
27
|
+
export const CONTEXT_EXIT_REQUEST: "c:ex:req";
|
|
28
|
+
export const CONTEXT_EXIT_RESPONSE: "c:ex:res";
|
|
29
|
+
export const CONTEXT_EXIT_ERROR: "c:ex:err";
|
|
30
|
+
export const CLIENT_HANDSHAKE_REQUEST: "cl:h:req";
|
|
31
|
+
export const CLIENT_HANDSHAKE_RESPONSE: "cl:h:res";
|
|
32
|
+
export const CLIENT_HANDSHAKE_ERROR: "cl:h:err";
|
|
33
|
+
export const AUDIT_STATE_NAME: "s:c:audit";
|
|
34
|
+
export const PRIVATE_STATES: string[];
|
|
35
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/common/constants.js"],"names":[],"mappings":"AACA,2BAA4B;AAG5B,uCAAwC;AACxC,wCAAyC;AACzC,qCAAsC;AAEtC,wCAAyC;AACzC,yCAA0C;AAC1C,sCAAuC;AACvC,6CAA8C;AAE9C,uCAAwC;AACxC,wCAAyC;AACzC,qCAAsC;AAEtC,wCAAyC;AACzC,yCAA0C;AAC1C,sCAAuC;AAEvC,wCAAyC;AACzC,yCAA0C;AAC1C,6CAA8C;AAE9C,gDAAiD;AAEjD,uCAAwC;AACxC,wCAAyC;AACzC,oCAAqC;AACrC,4CAA6C;AAE7C,oCAAqC;AAGrC,+CAAgD;AAChD,gDAAiD;AACjD,6CAA8C;AAE9C,8CAA+C;AAC/C,+CAAgD;AAChD,4CAA6C;AAG7C,kDAAmD;AACnD,mDAAoD;AACpD,gDAAiD;AAGjD,2CAA4C;AAC5C,sCAAiD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export default logger;
|
|
2
|
+
declare namespace logger {
|
|
3
|
+
const verbose: boolean;
|
|
4
|
+
function configure(verbose: any): void;
|
|
5
|
+
function title(msg: any): void;
|
|
6
|
+
function clientConfigAndRouting(routes: any, config: any): void;
|
|
7
|
+
function ip(protocol: any, address: any, port: any): void;
|
|
8
|
+
function pluginStart(name: any): void;
|
|
9
|
+
function pluginStarted(name: any): void;
|
|
10
|
+
function pluginReady(name: any): void;
|
|
11
|
+
function pluginErrored(name: any): void;
|
|
12
|
+
function log(msg: any): void;
|
|
13
|
+
function warn(msg: any): void;
|
|
14
|
+
function error(msg: any): void;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promise-store.d.ts","sourceRoot":"","sources":["../../src/common/promise-store.js"],"names":[],"mappings":"AAKA,8EAKC;AAED,4DAKC;AAED,2DAKC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** @private */
|
|
2
|
+
export function packBinaryMessage(channel: any, data: any): ArrayBufferLike;
|
|
3
|
+
/** @private */
|
|
4
|
+
export function unpackBinaryMessage(buffer: any): any[];
|
|
5
|
+
/** @private */
|
|
6
|
+
export function packStringMessage(channel: any, ...args: any[]): string;
|
|
7
|
+
/** @private */
|
|
8
|
+
export function unpackStringMessage(data: any): any;
|
|
9
|
+
//# sourceMappingURL=sockets-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sockets-utils.d.ts","sourceRoot":"","sources":["../../src/common/sockets-utils.js"],"names":[],"mappings":"AAsBA,eAAe;AACf,4EAqBC;AAED,eAAe;AACf,wDAeC;AAED,eAAe;AACf,wEAEC;AAED,eAAe;AACf,oDAEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/common/utils.js"],"names":[],"mappings":"AAGA,gEAQC;AAED,4CAEC;AAED,+CAGC;AAnBD,iCAA6F"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export default Client;
|
|
2
|
+
/**
|
|
3
|
+
* Server-side representation of a `soundworks` client.
|
|
4
|
+
*
|
|
5
|
+
* @memberof server
|
|
6
|
+
* @hideconstructor
|
|
7
|
+
* @see {@link client.Client}
|
|
8
|
+
*/
|
|
9
|
+
declare class Client {
|
|
10
|
+
/**
|
|
11
|
+
* @param {String} role - Role of the client
|
|
12
|
+
* @param {server.Socket} socket - Socket connection with the client
|
|
13
|
+
*/
|
|
14
|
+
constructor(role: string, socket: server.Socket);
|
|
15
|
+
/**
|
|
16
|
+
* Client role, as specified in client side config {@link client.Client}.
|
|
17
|
+
*
|
|
18
|
+
* @type {String}
|
|
19
|
+
*/
|
|
20
|
+
role: string;
|
|
21
|
+
/**
|
|
22
|
+
* Session Id (incremented positive number).
|
|
23
|
+
*
|
|
24
|
+
* @type {Number}
|
|
25
|
+
*/
|
|
26
|
+
id: number;
|
|
27
|
+
/**
|
|
28
|
+
* Unique session Id (uuidv4).
|
|
29
|
+
*
|
|
30
|
+
* @type {String}
|
|
31
|
+
*/
|
|
32
|
+
uuid: string;
|
|
33
|
+
/**
|
|
34
|
+
* Socket connection with the remote client {@link client.Client}.
|
|
35
|
+
*
|
|
36
|
+
* @type {server.Socket}
|
|
37
|
+
*/
|
|
38
|
+
socket: server.Socket;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=Client.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export default Context;
|
|
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
|
|
5
|
+
* and used by the server.
|
|
6
|
+
*
|
|
7
|
+
* @memberof server
|
|
8
|
+
*/
|
|
9
|
+
declare class Context {
|
|
10
|
+
constructor(server: any, roles?: any[]);
|
|
11
|
+
/**
|
|
12
|
+
* soundworks server
|
|
13
|
+
* @type {server.Server}
|
|
14
|
+
*/
|
|
15
|
+
server: server.Server;
|
|
16
|
+
/**
|
|
17
|
+
* List of clients that are currently in this context
|
|
18
|
+
* @type {Client[]}
|
|
19
|
+
*/
|
|
20
|
+
clients: Client[];
|
|
21
|
+
/**
|
|
22
|
+
* Status of the context ('idle', 'inited', 'started' or 'errored')
|
|
23
|
+
* @type {String}
|
|
24
|
+
*/
|
|
25
|
+
status: string;
|
|
26
|
+
roles: Set<any>;
|
|
27
|
+
/**
|
|
28
|
+
* Name of the context, default to the class name.
|
|
29
|
+
* Override the `get name()` getter to use a user-defined context name.
|
|
30
|
+
*/
|
|
31
|
+
get name(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Method automatically called when the server starts, or lazilly called if
|
|
34
|
+
* the context is created after `server.start()`
|
|
35
|
+
*
|
|
36
|
+
* _WARNING: this method should never be called manually._
|
|
37
|
+
*/
|
|
38
|
+
start(): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Method automatically called when the server stops.
|
|
41
|
+
*
|
|
42
|
+
* _WARNING: this method should never be called manually._
|
|
43
|
+
*/
|
|
44
|
+
stop(): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Method automatically called when the client enters the context.
|
|
47
|
+
*
|
|
48
|
+
* _WARNING: this method should never be called manually._
|
|
49
|
+
*/
|
|
50
|
+
enter(client: any): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Method automatically called when the client exits the context.
|
|
53
|
+
*
|
|
54
|
+
* _WARNING: this method should never be called manually._
|
|
55
|
+
*/
|
|
56
|
+
exit(client: any): Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
import Client from "./Client.js";
|
|
59
|
+
//# sourceMappingURL=Context.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export default ContextManager;
|
|
2
|
+
/**
|
|
3
|
+
* Manage the different server-side contexts and their lifecycle. The `ContextManager`
|
|
4
|
+
* is automatically instantiated by the {@link server.Server}.
|
|
5
|
+
*
|
|
6
|
+
* _WARNING: Most of the time, you should not have to manipulate the context manager directly._
|
|
7
|
+
*
|
|
8
|
+
* @memberof server
|
|
9
|
+
*/
|
|
10
|
+
declare class ContextManager {
|
|
11
|
+
/**
|
|
12
|
+
* @param {server.Server} server - Instance of the soundworks server.
|
|
13
|
+
*/
|
|
14
|
+
constructor(server: server.Server);
|
|
15
|
+
/** @private */
|
|
16
|
+
private server;
|
|
17
|
+
/** @private */
|
|
18
|
+
private _contexts;
|
|
19
|
+
/** @private */
|
|
20
|
+
private _contextStartPromises;
|
|
21
|
+
/**
|
|
22
|
+
* Register a context in the manager.
|
|
23
|
+
* This method is called in the {@link server.Context} constructor
|
|
24
|
+
*
|
|
25
|
+
* @param {server.Context} context - Context instance to register.
|
|
26
|
+
*
|
|
27
|
+
* @private
|
|
28
|
+
*/
|
|
29
|
+
private register;
|
|
30
|
+
/**
|
|
31
|
+
* Retrieve a started context from its name.
|
|
32
|
+
*
|
|
33
|
+
* @see {server.Context#name}
|
|
34
|
+
* @param {String} contextName - Name of the context.
|
|
35
|
+
*
|
|
36
|
+
* @private
|
|
37
|
+
*/
|
|
38
|
+
private get;
|
|
39
|
+
/**
|
|
40
|
+
* Called when a client connects to the server (websocket handshake)
|
|
41
|
+
*
|
|
42
|
+
* @param {server.Client} client
|
|
43
|
+
*
|
|
44
|
+
* @private
|
|
45
|
+
*/
|
|
46
|
+
private addClient;
|
|
47
|
+
/**
|
|
48
|
+
* Called when a client connects to the server (websocket 'close' event)
|
|
49
|
+
*
|
|
50
|
+
* @param {server.Client} client
|
|
51
|
+
*
|
|
52
|
+
* @private
|
|
53
|
+
*/
|
|
54
|
+
private removeClient;
|
|
55
|
+
/**
|
|
56
|
+
* Start all contexts registered before `await server.start()`.
|
|
57
|
+
* Called on {@link server.Server#start}
|
|
58
|
+
*
|
|
59
|
+
* @private
|
|
60
|
+
*/
|
|
61
|
+
private start;
|
|
62
|
+
/**
|
|
63
|
+
* Stop all contexts. Called on {@link server.Server#stop}
|
|
64
|
+
*
|
|
65
|
+
* @private
|
|
66
|
+
*/
|
|
67
|
+
private stop;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=ContextManager.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export default Plugin;
|
|
2
|
+
export namespace server {
|
|
3
|
+
/**
|
|
4
|
+
* ~onStateChangeCallback
|
|
5
|
+
*/
|
|
6
|
+
export type Plugin = (#state: server.Plugin) => any;
|
|
7
|
+
/**
|
|
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.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Delete the registered {@link server.Plugin~onStateChangeCallback}.
|
|
15
|
+
*
|
|
16
|
+
* @callback server.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 server
|
|
33
|
+
* @extends BasePlugin
|
|
34
|
+
* @inheritdoc
|
|
35
|
+
*/
|
|
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
|
+
}
|
|
69
|
+
import BasePlugin from "../common/BasePlugin.js";
|
|
70
|
+
//# sourceMappingURL=Plugin.d.ts.map
|
|
@@ -0,0 +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"}
|