@soundworks/core 5.5.0 → 5.7.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/CHANGELOG.md +13 -0
- package/README.md +6 -0
- package/package.json +17 -11
- package/src/client/Client.js +7 -4
- package/src/client/ClientSocket.js +2 -3
- package/src/common/BasePlugin.js +2 -2
- package/src/common/BasePluginManager.js +2 -2
- package/src/common/BaseStateManager.js +253 -221
- package/src/common/ParameterBag.js +14 -14
- package/src/common/SharedState.js +405 -247
- package/src/common/SharedStateCollection.js +82 -32
- package/src/common/constants.js +2 -0
- package/src/common/isomorphic/colored-logger.browser.js +17 -0
- package/src/common/isomorphic/colored-logger.node.js +19 -0
- package/src/common/isomorphic/web-socket.browser.js +1 -0
- package/src/common/isomorphic/web-socket.node.js +3 -0
- package/src/common/logs/gated-logger.js +30 -0
- package/src/common/logs/warnings.js +36 -0
- package/src/common/shared-state-utils.js +102 -0
- package/src/common/version.js +1 -1
- package/src/server/Server.js +23 -35
- package/src/server/ServerClient.js +7 -3
- package/src/server/ServerStateManager.js +242 -227
- package/src/server/SharedStatePrivate.js +105 -68
- package/src/server/create-http-server.js +81 -39
- package/src/server/crypto.js +2 -3
- package/types/client/Client.d.ts.map +1 -1
- package/types/client/ClientSocket.d.ts.map +1 -1
- package/types/common/BaseStateManager.d.ts +34 -47
- package/types/common/BaseStateManager.d.ts.map +1 -1
- package/types/common/ParameterBag.d.ts +28 -6
- package/types/common/ParameterBag.d.ts.map +1 -1
- package/types/common/SharedState.d.ts +55 -29
- package/types/common/SharedState.d.ts.map +1 -1
- package/types/common/SharedStateCollection.d.ts +26 -8
- package/types/common/SharedStateCollection.d.ts.map +1 -1
- package/types/common/constants.d.ts +1 -0
- package/types/common/constants.d.ts.map +1 -1
- package/types/common/isomorphic/colored-logger.browser.d.ts +8 -0
- package/types/common/isomorphic/colored-logger.browser.d.ts.map +1 -0
- package/types/common/isomorphic/colored-logger.node.d.ts +8 -0
- package/types/common/isomorphic/colored-logger.node.d.ts.map +1 -0
- package/types/common/isomorphic/web-socket.browser.d.ts +10 -0
- package/types/common/isomorphic/web-socket.browser.d.ts.map +1 -0
- package/types/common/isomorphic/web-socket.node.d.ts +2 -0
- package/types/common/isomorphic/web-socket.node.d.ts.map +1 -0
- package/types/common/logs/gated-logger.d.ts +9 -0
- package/types/common/logs/gated-logger.d.ts.map +1 -0
- package/types/common/logs/warnings.d.ts +7 -0
- package/types/common/logs/warnings.d.ts.map +1 -0
- package/types/common/shared-state-utils.d.ts +12 -0
- package/types/common/shared-state-utils.d.ts.map +1 -0
- package/types/common/version.d.ts +1 -1
- package/types/server/Server.d.ts.map +1 -1
- package/types/server/ServerClient.d.ts.map +1 -1
- package/types/server/ServerStateManager.d.ts +10 -10
- package/types/server/ServerStateManager.d.ts.map +1 -1
- package/types/server/SharedStatePrivate.d.ts +2 -3
- package/types/server/SharedStatePrivate.d.ts.map +1 -1
- package/types/server/create-http-server.d.ts +1 -0
- package/types/server/create-http-server.d.ts.map +1 -1
- package/types/server/crypto.d.ts.map +1 -1
- package/src/common/logger.js +0 -150
- package/types/common/logger.d.ts +0 -19
- package/types/common/logger.d.ts.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import cloneDeep from 'lodash/cloneDeep.js';
|
|
2
|
-
import equal from 'fast-deep-equal';
|
|
3
|
-
|
|
4
1
|
import {
|
|
5
2
|
isPlainObject,
|
|
6
3
|
} from '@ircam/sc-utils';
|
|
4
|
+
import {
|
|
5
|
+
dequal,
|
|
6
|
+
} from 'dequal/lite';
|
|
7
7
|
|
|
8
8
|
export const sharedOptions = {
|
|
9
9
|
nullable: false,
|
|
@@ -19,7 +19,7 @@ export const types = {
|
|
|
19
19
|
boolean: {
|
|
20
20
|
required: ['default'],
|
|
21
21
|
get defaultOptions() {
|
|
22
|
-
return Object.assign(
|
|
22
|
+
return Object.assign(structuredClone(sharedOptions), {});
|
|
23
23
|
},
|
|
24
24
|
coerceFunction: (name, def, value) => {
|
|
25
25
|
if (typeof value !== 'boolean') {
|
|
@@ -32,7 +32,7 @@ export const types = {
|
|
|
32
32
|
string: {
|
|
33
33
|
required: ['default'],
|
|
34
34
|
get defaultOptions() {
|
|
35
|
-
return Object.assign(
|
|
35
|
+
return Object.assign(structuredClone(sharedOptions), {});
|
|
36
36
|
},
|
|
37
37
|
coerceFunction: (name, def, value) => {
|
|
38
38
|
if (typeof value !== 'string') {
|
|
@@ -45,7 +45,7 @@ export const types = {
|
|
|
45
45
|
integer: {
|
|
46
46
|
required: ['default'],
|
|
47
47
|
get defaultOptions() {
|
|
48
|
-
return Object.assign(
|
|
48
|
+
return Object.assign(structuredClone(sharedOptions), {
|
|
49
49
|
min: -Infinity,
|
|
50
50
|
max: +Infinity,
|
|
51
51
|
});
|
|
@@ -78,7 +78,7 @@ export const types = {
|
|
|
78
78
|
float: {
|
|
79
79
|
required: ['default'],
|
|
80
80
|
get defaultOptions() {
|
|
81
|
-
return Object.assign(
|
|
81
|
+
return Object.assign(structuredClone(sharedOptions), {
|
|
82
82
|
min: -Infinity,
|
|
83
83
|
max: +Infinity,
|
|
84
84
|
});
|
|
@@ -111,7 +111,7 @@ export const types = {
|
|
|
111
111
|
enum: {
|
|
112
112
|
required: ['default', 'list'],
|
|
113
113
|
get defaultOptions() {
|
|
114
|
-
return Object.assign(
|
|
114
|
+
return Object.assign(structuredClone(sharedOptions), {});
|
|
115
115
|
},
|
|
116
116
|
coerceFunction: (name, def, value) => {
|
|
117
117
|
if (def.list.indexOf(value) === -1) {
|
|
@@ -125,7 +125,7 @@ export const types = {
|
|
|
125
125
|
any: {
|
|
126
126
|
required: ['default'],
|
|
127
127
|
get defaultOptions() {
|
|
128
|
-
return Object.assign(
|
|
128
|
+
return Object.assign(structuredClone(sharedOptions), {});
|
|
129
129
|
},
|
|
130
130
|
coerceFunction: (name, def, value) => {
|
|
131
131
|
// no check as it can have any type...
|
|
@@ -176,7 +176,7 @@ class ParameterBag {
|
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
static getFullDescription(description) {
|
|
179
|
-
const fullDescription =
|
|
179
|
+
const fullDescription = structuredClone(description);
|
|
180
180
|
|
|
181
181
|
for (let [name, def] of Object.entries(fullDescription)) {
|
|
182
182
|
if (types[def.type].sanitizeDescription) {
|
|
@@ -213,7 +213,7 @@ class ParameterBag {
|
|
|
213
213
|
ParameterBag.validateDescription(description);
|
|
214
214
|
|
|
215
215
|
description = ParameterBag.getFullDescription(description);
|
|
216
|
-
initValues =
|
|
216
|
+
initValues = structuredClone(initValues);
|
|
217
217
|
|
|
218
218
|
// make sure initValues make sens according to the given description
|
|
219
219
|
for (let name in initValues) {
|
|
@@ -308,7 +308,7 @@ class ParameterBag {
|
|
|
308
308
|
if (this.#description[name].type === 'any') {
|
|
309
309
|
// we return a deep copy of the object as we don't want the client code to
|
|
310
310
|
// be able to modify our underlying data.
|
|
311
|
-
return
|
|
311
|
+
return structuredClone(this.#values[name]);
|
|
312
312
|
} else {
|
|
313
313
|
return this.#values[name];
|
|
314
314
|
}
|
|
@@ -369,7 +369,7 @@ class ParameterBag {
|
|
|
369
369
|
set(name, value) {
|
|
370
370
|
value = this.coerceValue(name, value);
|
|
371
371
|
const currentValue = this.#values[name];
|
|
372
|
-
const updated = !
|
|
372
|
+
const updated = !dequal(currentValue, value);
|
|
373
373
|
|
|
374
374
|
// we store a deep copy of the object as we don't want the client to be able
|
|
375
375
|
// to modify our underlying data, which leads to unexpected behavior where the
|
|
@@ -377,7 +377,7 @@ class ParameterBag {
|
|
|
377
377
|
// @see tests/common.state-manager.spec.js
|
|
378
378
|
// 'should copy stored value for "any" type to have a predictable behavior'
|
|
379
379
|
if (this.#description[name].type === 'any') {
|
|
380
|
-
value =
|
|
380
|
+
value = structuredClone(value);
|
|
381
381
|
}
|
|
382
382
|
|
|
383
383
|
this.#values[name] = value;
|