@soundworks/core 5.4.0 → 5.4.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soundworks/core",
3
- "version": "5.4.0",
3
+ "version": "5.4.1",
4
4
  "description": "Open-source creative coding framework for distributed applications based on Web technologies",
5
5
  "collaborators": [
6
6
  "Benjamin Matuszewski",
@@ -430,6 +430,19 @@ class ParameterBag {
430
430
 
431
431
  return defaults;
432
432
  }
433
+
434
+ // @todo - should cache result
435
+ getParamListByDescriptor(descriptorName, descriptorValue) {
436
+ const result = [];
437
+
438
+ for (let [name, def] of Object.entries(this.#description)) {
439
+ if (def[descriptorName] === descriptorValue) {
440
+ result.push(name);
441
+ }
442
+ }
443
+
444
+ return result;
445
+ }
433
446
  }
434
447
 
435
448
  export default ParameterBag;
@@ -1,2 +1,2 @@
1
1
  // [WARNING] This file is generated, do not edit
2
- export default '5.4.0';
2
+ export default '5.4.1';
@@ -127,6 +127,9 @@ class SharedStatePrivate {
127
127
  // apply registered hooks
128
128
  const hooks = this.#manager[kServerStateManagerGetUpdateHooks](this.className);
129
129
  const values = this.#parameters.getValues();
130
+ // make sur we don't propagate back to requester param that are marked as `acknowledge=false`
131
+ const acknowledgeFilter = this.#parameters.getParamListByDescriptor('acknowledge', false);
132
+
130
133
  let hookAborted = false;
131
134
 
132
135
  // cf. https://github.com/collective-soundworks/soundworks/issues/45
@@ -145,13 +148,12 @@ class SharedStatePrivate {
145
148
 
146
149
  if (hookAborted === false) {
147
150
  let acknowledgedUpdates = {};
148
- let acknowledgeFilter = [];
149
151
 
150
152
  for (let name in updates) {
151
153
  const [newValue, changed] = this.#parameters.set(name, updates[name]);
152
154
  // if `filterChange` is set to `false` we don't check if the value
153
155
  // has been changed or not, it is always propagated to client states
154
- const { event, filterChange, acknowledge } = this.#parameters.getDescription(name);
156
+ const { event, filterChange } = this.#parameters.getDescription(name);
155
157
 
156
158
  // if event type reset internal value to null
157
159
  if (event) {
@@ -160,10 +162,6 @@ class SharedStatePrivate {
160
162
 
161
163
  if ((filterChange && changed) || !filterChange) {
162
164
  acknowledgedUpdates[name] = newValue;
163
-
164
- if (acknowledge === false) {
165
- acknowledgeFilter.push(name);
166
- }
167
165
  }
168
166
  }
169
167
 
@@ -247,18 +245,27 @@ class SharedStatePrivate {
247
245
  }
248
246
  }
249
247
  } else {
250
- // propagate back to the requester that the update has been aborted, ignore all peers
251
- client.transport.emit(`${UPDATE_ABORT}-${this.id}-${instanceId}`, reqId, updates);
248
+ // @note - abort messages are only sent back to requester
249
+ const requesterFilteredUpdates = blackListFilterUpdates(updates, acknowledgeFilter);
250
+
251
+ if (Object.keys(requesterFilteredUpdates).length > 0) {
252
+ // propagate back to the requester that the update has been aborted, ignore all peers
253
+ client.transport.emit(`${UPDATE_ABORT}-${this.id}-${instanceId}`, reqId, requesterFilteredUpdates);
254
+ }
252
255
  }
253
256
  } else {
254
- // retrieve values from inner state (also handle immediate appropriately)
255
- const oldValues = {};
257
+ // @note - abort messages are only sent back to requester
258
+ // explicitly aborted by hook (return `null`), send back current values to requester
259
+ const currentValues = {};
256
260
 
257
261
  for (let name in updates) {
258
- oldValues[name] = this.#parameters.get(name);
262
+ currentValues[name] = this.#parameters.get(name);
263
+ }
264
+
265
+ const requesterFilteredUpdates = blackListFilterUpdates(currentValues, acknowledgeFilter);
266
+ if (Object.keys(requesterFilteredUpdates).length > 0) {
267
+ client.transport.emit(`${UPDATE_ABORT}-${this.id}-${instanceId}`, reqId, requesterFilteredUpdates);
259
268
  }
260
- // aborted by hook (updates have been overridden to {})
261
- client.transport.emit(`${UPDATE_ABORT}-${this.id}-${instanceId}`, reqId, oldValues);
262
269
  }
263
270
  });
264
271
 
@@ -138,5 +138,6 @@ declare class ParameterBag {
138
138
  getDescription(name?: any): object;
139
139
  getInitValues(): {};
140
140
  getDefaults(): {};
141
+ getParamListByDescriptor(descriptorName: any, descriptorValue: any): string[];
141
142
  #private;
142
143
  }
@@ -1,2 +1,2 @@
1
- declare const _default: "5.4.0";
1
+ declare const _default: "5.4.1";
2
2
  export default _default;