Socket
Socket
Sign inDemoInstall

@soundworks/core

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@soundworks/core - npm Package Compare versions

Comparing version 3.1.0-beta.2 to 3.1.0-beta.3

27

common/ParameterBag.js

@@ -15,2 +15,3 @@ "use strict";

// import types from './types';
// import shallowClone from 'shallow-clone';

@@ -186,2 +187,5 @@ /**

*
* Note that the `any` type always return a shallow copy of the state internal
* value. Mutating the returned value will not modify the internal state.
*
* @property {String} [type='any'] - Parameter of any type.

@@ -214,4 +218,4 @@ * @property {Mixed} default - Default value of the parameter.

metas: {},
filterChange: true // immediate: false,
filterChange: true,
immediate: false
};

@@ -429,6 +433,13 @@ exports.sharedOptions = sharedOptions;

getValues() {
return Object.assign({}, this._values);
let values = {};
for (let name in this._values) {
values[name] = this.get(name);
}
return values;
}
/**
* Return the value of the given parameter.
* Return the value of the given parameter. If the parameter is of `any` type,
* a deep copy is returned.
*

@@ -445,3 +456,7 @@ * @param {String} name - Name of the parameter.

return this._values[name];
if (this._schema[name].type === 'any') {
return (0, _lodash.default)(this._values[name]);
} else {
return this._values[name];
}
}

@@ -492,2 +507,4 @@ /**

* Reset a parameter to its initialization values. Reset all parameters if no argument.
* @note - prefer `state.set(state.getInitValues())`
* or `state.set(state.getDefaultValues())`
*

@@ -494,0 +511,0 @@ * @param {String} [name=null] - Name of the parameter to reset.

49

common/SharedState.js

@@ -49,16 +49,14 @@ "use strict";

client.transport.addListener(`${_sharedStateUtils.UPDATE_RESPONSE}-${id}-${this.remoteId}`, (reqId, updates, context) => {
const updated = this._commit(updates, context, true, true);
client.transport.addListener(`${_sharedStateUtils.UPDATE_RESPONSE}-${id}-${this.remoteId}`, async (reqId, updates, context) => {
const updated = await this._commit(updates, context, true, true);
(0, _sharedStateUtils.resolveRequest)(reqId, updated);
}); // retrieve values but do not propagate to subscriptions
client.transport.addListener(`${_sharedStateUtils.UPDATE_ABORT}-${id}-${this.remoteId}`, (reqId, updates, context) => {
const updated = this._commit(updates, context, false, true);
client.transport.addListener(`${_sharedStateUtils.UPDATE_ABORT}-${id}-${this.remoteId}`, async (reqId, updates, context) => {
const updated = await this._commit(updates, context, false, true);
(0, _sharedStateUtils.resolveRequest)(reqId, updated);
});
client.transport.addListener(`${_sharedStateUtils.UPDATE_NOTIFICATION}-${id}-${this.remoteId}`, (updates, context) => {
client.transport.addListener(`${_sharedStateUtils.UPDATE_NOTIFICATION}-${id}-${this.remoteId}`, async (updates, context) => {
// cf. https://github.com/collective-soundworks/soundworks/issues/18
this._commit(updates, context, true, false);
await this._commit(updates, context, true, false);
}); // ---------------------------------------------

@@ -149,3 +147,3 @@ // DELETE initiated by creator, or schema deleted

_commit(updates, context, propagate = true, initiator = false) {
async _commit(updates, context, propagate = true, initiator = false) {
const newValues = {};

@@ -159,4 +157,8 @@ const oldValues = {};

event
} = this._parameters.getSchema(name);
} = this._parameters.getSchema(name); // @note 20211209 - we have an issue here server-side, because if the value
// is an object or an array, the reference is shared by everybody, therefore
// `changed` is always false and the new value is never propagated...
// FIXED - `state.get` now returns a deep copy when `type` is `any`
const oldValue = this._parameters.get(name);

@@ -183,11 +185,34 @@

let promises = [];
if (propagate && Object.keys(newValues).length > 0) {
this._subscriptions.forEach(listener => listener(newValues, oldValues, context));
this._subscriptions.forEach(listener => {
promises.push(listener(newValues, oldValues, context));
});
}
await Promise.all(promises);
return newValues;
}
/**
* Updates values of the state.
* Updates values of the state. Wait for all subscriptions to be resolved
* before resolving itself, i.e.:
*
* ```js
* const a = await server.stateManager.create('a');
* let asyncCallbackCalled = false;
*
* a.subscribe(updates => {
* return new Promise(resolve => {
* setTimeout(() => {
* asyncCallbackCalled = true;
* resolve();
* }, 100);
* });
* });
*
* await a.set({ bool: true });
* assert.equal(asyncCallbackCalled, true);
* ```
*
* @async

@@ -194,0 +219,0 @@ * @param {Object} updates - key / value pairs of updates to apply to the state.

{
"name": "@soundworks/core",
"version": "3.1.0-beta.2",
"version": "3.1.0-beta.3",
"description": "full-stack javascript framework for distributed audio visual experiences on the web",

@@ -42,3 +42,2 @@ "authors": [

"isomorphic-ws": "^4.0.1",
"jsdoc-template": "^1.2.0",
"keyv": "^4.0.3",

@@ -45,0 +44,0 @@ "keyv-file": "^0.2.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc