@soundworks/core 5.0.0 → 5.0.2
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/package.json +3 -2
- package/src/client/ClientPlugin.js +9 -5
- package/src/client/ClientPluginManager.js +3 -3
- package/src/common/BasePlugin.js +2 -1
- package/src/common/version.js +1 -1
- package/src/server/ServerPlugin.js +8 -5
- package/src/server/ServerPluginManager.js +3 -3
- package/types/client/ClientPlugin.d.ts +8 -8
- package/types/client/ClientPluginManager.d.ts +0 -1
- package/types/common/version.d.ts +1 -1
- package/types/server/ServerPlugin.d.ts +4 -4
- package/types/server/ServerPluginManager.d.ts +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soundworks/core",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"description": "Open-source creative coding framework for distributed applications based on Web technologies",
|
|
5
5
|
"collaborators": [
|
|
6
6
|
"Benjamin Matuszewski",
|
|
@@ -47,9 +47,10 @@
|
|
|
47
47
|
"doc": "npm run types && rm -rf docs && jsdoc -c .jsdoc --verbose && cp -R misc/assets docs/",
|
|
48
48
|
"lint": "npx eslint src",
|
|
49
49
|
"test": "npx mocha tests/*/*.spec.js",
|
|
50
|
+
"test:ci": "npx mocha tests/*/*.spec.js --ci",
|
|
50
51
|
"test:only": "npx mocha",
|
|
51
52
|
"types": "rm -rf types && tsc",
|
|
52
|
-
"preversion": "node ./misc/scripts/generate-version-file.js $npm_new_version && npm run types",
|
|
53
|
+
"preversion": "npm run lint && npm run test && node ./misc/scripts/generate-version-file.js $npm_new_version && npm run types",
|
|
53
54
|
"postversion": "node ./misc/scripts/check-changelog.js && git commit -am \"$npm_new_version\" --allow-empty"
|
|
54
55
|
},
|
|
55
56
|
"dependencies": {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import BasePlugin from '../common/BasePlugin.js';
|
|
2
2
|
|
|
3
|
+
export const kClientPluginName = Symbol.for('soundworks:client-plugin-name');
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* Callback executed when the plugin state is updated.
|
|
5
7
|
*
|
|
@@ -31,12 +33,16 @@ import BasePlugin from '../common/BasePlugin.js';
|
|
|
31
33
|
* @extends BasePlugin
|
|
32
34
|
* @inheritdoc
|
|
33
35
|
*/
|
|
34
|
-
class ClientPlugin extends BasePlugin {
|
|
36
|
+
export default class ClientPlugin extends BasePlugin {
|
|
37
|
+
// Note: we need this workaround in plugin tests, because the test app and
|
|
38
|
+
// the tested plugin will import different versions of ServerPlugin
|
|
39
|
+
static [kClientPluginName] = 'ClientPlugin';
|
|
40
|
+
|
|
35
41
|
#client = null;
|
|
42
|
+
|
|
36
43
|
/**
|
|
37
44
|
* @param {Client} client - A soundworks client instance.
|
|
38
|
-
* @param {string} id - User defined id of the plugin as defined in
|
|
39
|
-
* {@link ClientPluginManager#register}.
|
|
45
|
+
* @param {string} id - User defined id of the plugin as defined in {@link ClientPluginManager#register}.
|
|
40
46
|
*/
|
|
41
47
|
constructor(client, id) {
|
|
42
48
|
super(id);
|
|
@@ -67,5 +73,3 @@ class ClientPlugin extends BasePlugin {
|
|
|
67
73
|
// */
|
|
68
74
|
// async deactivate() {}
|
|
69
75
|
}
|
|
70
|
-
|
|
71
|
-
export default ClientPlugin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import BasePluginManager from '../common/BasePluginManager.js';
|
|
2
|
-
import ClientPlugin from './ClientPlugin.js';
|
|
3
1
|
import Client from './Client.js';
|
|
2
|
+
import BasePluginManager from '../common/BasePluginManager.js';
|
|
3
|
+
import { kClientPluginName } from './ClientPlugin.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The `PluginManager` allows to register and retrieve `soundworks` plugins.
|
|
@@ -98,7 +98,7 @@ class ClientPluginManager extends BasePluginManager {
|
|
|
98
98
|
*/
|
|
99
99
|
register(id, ctor, options = {}, deps = []) {
|
|
100
100
|
// Note that other arguments are checked on the BasePluginManager
|
|
101
|
-
if (!ctor ||
|
|
101
|
+
if (!ctor || ctor[kClientPluginName] !== 'ClientPlugin') {
|
|
102
102
|
throw new TypeError(`Cannot execute 'register' on ClientPluginManager: argument 2 must be a class that extends 'ClientPlugin'`);
|
|
103
103
|
}
|
|
104
104
|
|
package/src/common/BasePlugin.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import merge from 'lodash/merge.js';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// Notes: we use Symbol.for because we need to override this in helpers test
|
|
4
|
+
export const kBasePluginStatus = Symbol.for('soundworks:base-plugin-status');
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Callback executed when the plugin state is updated.
|
package/src/common/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// [WARNING] This file is generated, do not edit
|
|
2
|
-
export default '5.0.
|
|
2
|
+
export default '5.0.2';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import BasePlugin from '../common/BasePlugin.js';
|
|
2
2
|
|
|
3
|
+
export const kServerPluginName = Symbol.for('soundworks:server-plugin-name');
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* Base class to extend in order to create the server-side counterpart of a
|
|
5
7
|
* `soundworks` plugin.
|
|
@@ -18,14 +20,17 @@ import BasePlugin from '../common/BasePlugin.js';
|
|
|
18
20
|
* @extends {BasePlugin}
|
|
19
21
|
* @inheritdoc
|
|
20
22
|
*/
|
|
21
|
-
class ServerPlugin extends BasePlugin {
|
|
23
|
+
export default class ServerPlugin extends BasePlugin {
|
|
24
|
+
// Note: we need this workaround in plugin tests, because the test app and
|
|
25
|
+
// the tested plugin will import different versions of ServerPlugin
|
|
26
|
+
static [kServerPluginName] = 'ServerPlugin';
|
|
27
|
+
|
|
22
28
|
#server = null;
|
|
23
29
|
#clients = new Set();
|
|
24
30
|
|
|
25
31
|
/**
|
|
26
32
|
* @param {Server} server - The soundworks server instance.
|
|
27
|
-
* @param {string} id - User defined id of the plugin as defined in
|
|
28
|
-
* {@link ServerPluginManager#register}.
|
|
33
|
+
* @param {string} id - User defined id of the plugin as defined in {@link ServerPluginManager#register}.
|
|
29
34
|
*/
|
|
30
35
|
constructor(server, id) {
|
|
31
36
|
super(id);
|
|
@@ -72,5 +77,3 @@ class ServerPlugin extends BasePlugin {
|
|
|
72
77
|
this.#clients.delete(client);
|
|
73
78
|
}
|
|
74
79
|
}
|
|
75
|
-
|
|
76
|
-
export default ServerPlugin;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import Server from './Server.js';
|
|
1
2
|
import BasePluginManager, {
|
|
2
3
|
kPluginManagerInstances,
|
|
3
4
|
} from '../common/BasePluginManager.js';
|
|
4
|
-
import
|
|
5
|
-
import Server from './Server.js';
|
|
5
|
+
import { kServerPluginName } from './ServerPlugin.js';
|
|
6
6
|
|
|
7
7
|
export const kServerPluginManagerCheckRegisteredPlugins = Symbol('soundworks:server-plugin-manager-check-registered-plugins');
|
|
8
8
|
export const kServerPluginManagerAddClient = Symbol('soundworks:server-plugin-manager-add-client');
|
|
@@ -140,7 +140,7 @@ class ServerPluginManager extends BasePluginManager {
|
|
|
140
140
|
*/
|
|
141
141
|
register(id, ctor, options = {}, deps = []) {
|
|
142
142
|
// Note that other arguments are checked on the BasePluginManager
|
|
143
|
-
if (!ctor ||
|
|
143
|
+
if (!ctor || ctor[kServerPluginName] !== 'ServerPlugin') {
|
|
144
144
|
throw new TypeError(`Cannot execute 'register' on ServerPluginManager (id: ${id}): argument 2 must be a class that extends 'ServerPlugin'`);
|
|
145
145
|
}
|
|
146
146
|
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
/**
|
|
3
|
-
* ~onStateChangeCallback
|
|
4
|
-
*/
|
|
5
|
-
export type ClientPlugin = (#state: ClientPlugin) => any;
|
|
1
|
+
export const kClientPluginName: unique symbol;
|
|
6
2
|
/**
|
|
7
3
|
* Callback executed when the plugin state is updated.
|
|
8
4
|
*
|
|
@@ -32,11 +28,11 @@ export type ClientPlugin = (#state: ClientPlugin) => any;
|
|
|
32
28
|
* @extends BasePlugin
|
|
33
29
|
* @inheritdoc
|
|
34
30
|
*/
|
|
35
|
-
|
|
31
|
+
export default class ClientPlugin extends BasePlugin {
|
|
32
|
+
static [kClientPluginName]: string;
|
|
36
33
|
/**
|
|
37
34
|
* @param {Client} client - A soundworks client instance.
|
|
38
|
-
* @param {string} id - User defined id of the plugin as defined in
|
|
39
|
-
* {@link ClientPluginManager#register}.
|
|
35
|
+
* @param {string} id - User defined id of the plugin as defined in {@link ClientPluginManager#register}.
|
|
40
36
|
*/
|
|
41
37
|
constructor(client: Client, id: string);
|
|
42
38
|
/**
|
|
@@ -48,4 +44,8 @@ declare class ClientPlugin extends BasePlugin {
|
|
|
48
44
|
get client(): Client;
|
|
49
45
|
#private;
|
|
50
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* ~onStateChangeCallback
|
|
49
|
+
*/
|
|
50
|
+
export type ClientPlugin = (#state: ClientPlugin) => any;
|
|
51
51
|
import BasePlugin from '../common/BasePlugin.js';
|
|
@@ -108,5 +108,4 @@ declare class ClientPluginManager<T> extends BasePluginManager {
|
|
|
108
108
|
get(id: string): Promise<T<ClientPlugin>>;
|
|
109
109
|
}
|
|
110
110
|
import BasePluginManager from '../common/BasePluginManager.js';
|
|
111
|
-
import ClientPlugin from './ClientPlugin.js';
|
|
112
111
|
import Client from './Client.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "5.0.
|
|
1
|
+
declare const _default: "5.0.2";
|
|
2
2
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const kServerPluginName: unique symbol;
|
|
2
2
|
/**
|
|
3
3
|
* Base class to extend in order to create the server-side counterpart of a
|
|
4
4
|
* `soundworks` plugin.
|
|
@@ -17,11 +17,11 @@ export default ServerPlugin;
|
|
|
17
17
|
* @extends {BasePlugin}
|
|
18
18
|
* @inheritdoc
|
|
19
19
|
*/
|
|
20
|
-
|
|
20
|
+
export default class ServerPlugin extends BasePlugin {
|
|
21
|
+
static [kServerPluginName]: string;
|
|
21
22
|
/**
|
|
22
23
|
* @param {Server} server - The soundworks server instance.
|
|
23
|
-
* @param {string} id - User defined id of the plugin as defined in
|
|
24
|
-
* {@link ServerPluginManager#register}.
|
|
24
|
+
* @param {string} id - User defined id of the plugin as defined in {@link ServerPluginManager#register}.
|
|
25
25
|
*/
|
|
26
26
|
constructor(server: Server, id: string);
|
|
27
27
|
/**
|