@soundworks/core
Advanced tools
Comparing version 4.0.0-alpha.4 to 4.0.0-alpha.5
{ | ||
"name": "@soundworks/core", | ||
"version": "4.0.0-alpha.4", | ||
"version": "4.0.0-alpha.5", | ||
"description": "Open-source creative coding framework for distributed applications based on Web technologies", | ||
@@ -56,2 +56,3 @@ "authors": [ | ||
"@ircam/sc-gettime": "^1.0.0", | ||
"@ircam/sc-utils": "^1.0.1", | ||
"chalk": "^5.2.0", | ||
@@ -63,3 +64,2 @@ "columnify": "^1.6.0", | ||
"fast-text-encoding": "^1.0.0", | ||
"is-plain-obj": "^4.1.0", | ||
"isomorphic-ws": "^5.0.0", | ||
@@ -86,3 +86,3 @@ "keyv": "^4.2.2", | ||
"eslint": "^8.32.0", | ||
"eslint-plugin-jsdoc": "^39.6.4", | ||
"eslint-plugin-jsdoc": "^40.0.0", | ||
"generate-changelog": "^1.8.0", | ||
@@ -89,0 +89,0 @@ "jsdoc": "^4.0.0", |
@@ -1,2 +0,2 @@ | ||
# `soundworks` | ||
# soundworks | ||
@@ -24,3 +24,3 @@ [![npm version](https://badge.fury.io/js/@soundworks%2Fcore.svg)](https://badge.fury.io/js/@soundworks%2Fcore) | ||
See [https://soundworks.dev/guides/getting-started.html](https://soundworks.dev/guides/getting-started.html) for more informations on the wizard and how to start with `soundworks`. | ||
See [https://soundworks.dev/tutorials/getting-started.html](https://soundworks.dev/tutorials/getting-started.html) for more informations on the wizard and how to start with `soundworks`. | ||
@@ -27,0 +27,0 @@ <!-- |
@@ -1,2 +0,2 @@ | ||
import isPlainObject from 'is-plain-obj'; | ||
import { isBrowser, isPlainObject } from '@ircam/sc-utils'; | ||
@@ -13,3 +13,2 @@ import ContextManager from './ContextManager.js'; | ||
} from '../common/constants.js'; | ||
import { isBrowser } from '../common/utils.js'; | ||
import logger from '../common/logger.js'; | ||
@@ -255,3 +254,3 @@ | ||
switch(err.type) { | ||
switch (err.type) { | ||
case 'invalid-client-type': | ||
@@ -280,3 +279,3 @@ msg = `[soundworks:Client] ${err.message}`; | ||
}); | ||
} catch(err) { | ||
} catch (err) { | ||
throw new Error(err); | ||
@@ -283,0 +282,0 @@ } |
@@ -212,3 +212,3 @@ import Client from './Client.js'; | ||
}); | ||
} catch(err) { | ||
} catch (err) { | ||
throw new Error(err); | ||
@@ -247,3 +247,3 @@ } | ||
}); | ||
} catch(err) { | ||
} catch (err) { | ||
throw new Error(err); | ||
@@ -250,0 +250,0 @@ } |
@@ -81,3 +81,3 @@ /** @private */ | ||
context.status = 'started'; | ||
} catch(err) { | ||
} catch (err) { | ||
context.status = 'errored'; | ||
@@ -84,0 +84,0 @@ throw new Error(err); |
@@ -0,1 +1,2 @@ | ||
import { isBrowser } from '@ircam/sc-utils'; | ||
import WebSocket from 'isomorphic-ws'; | ||
@@ -10,3 +11,2 @@ | ||
import logger from '../common/logger.js'; | ||
import { isBrowser } from '../common/utils.js'; | ||
@@ -13,0 +13,0 @@ // WebSocket events: |
@@ -1,5 +0,4 @@ | ||
import isPlainObject from 'is-plain-obj'; | ||
import { isPlainObject, isString } from '@ircam/sc-utils'; | ||
import logger from './logger.js'; | ||
import { isString } from './utils.js'; | ||
@@ -114,5 +113,5 @@ /** | ||
this.status = 'started'; | ||
} catch(err) { | ||
} catch (err) { | ||
this.status = 'errored'; | ||
throw new Error(err); | ||
throw err; // throw initial error | ||
} | ||
@@ -174,3 +173,3 @@ } | ||
await startPromise; | ||
} catch(err) { | ||
} catch (err) { | ||
errored = true; | ||
@@ -177,0 +176,0 @@ this._propagateStateChange(instance, 'errored'); |
@@ -0,1 +1,2 @@ | ||
import { isPlainObject } from '@ircam/sc-utils'; | ||
import ParameterBag from './ParameterBag.js'; | ||
@@ -37,3 +38,3 @@ import { | ||
this._parameters = new ParameterBag(schema, initValues); | ||
} catch(err) { | ||
} catch (err) { | ||
console.error(err.stack); | ||
@@ -259,2 +260,10 @@ | ||
async set(updates, context = null) { | ||
if (!isPlainObject(updates)) { | ||
throw new ReferenceError(`[SharedState] State "${this.schemaName}": state.set(updates[, context]) should receive an object as first parameter`); | ||
} | ||
if (context !== null && !isPlainObject(context)) { | ||
throw new ReferenceError(`[SharedState] State "${this.schemaName}": state.set(updates[, context]) should receive an object as second parameter`); | ||
} | ||
// handle immediate option | ||
@@ -268,3 +277,3 @@ const immediateNewValues = {}; | ||
if (!this._parameters.has(name)) { | ||
throw new ReferenceError(`[stateManager] Cannot set value of undefined parameter "${name}"`); | ||
throw new ReferenceError(`[SharedState] State "${this.schemaName}": cannot set value of undefined parameter "${name}"`); | ||
} | ||
@@ -413,3 +422,3 @@ | ||
} else { | ||
throw new Error(`[stateManager] can delete state "${this.schemaName}", only owner of the state (i.e. the node that "create[d]" it) can delete it`); | ||
throw new Error(`[SharedState] Cannot delete state "${this.schemaName}", only the owner of the state (i.e. the node that created it) can delete the state. Use "detach" instead.`); | ||
} | ||
@@ -416,0 +425,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { idGenerator } from './utils.js'; | ||
import { idGenerator } from '@ircam/sc-utils'; | ||
@@ -3,0 +3,0 @@ const generateRequestId = idGenerator(); |
@@ -0,5 +1,4 @@ | ||
import { idGenerator } from '@ircam/sc-utils'; | ||
import { v4 as uuid } from 'uuid'; | ||
import { idGenerator } from '../common/utils.js'; | ||
const generateId = idGenerator(); | ||
@@ -6,0 +5,0 @@ |
@@ -117,3 +117,3 @@ import Context from './Context.js'; | ||
context.status = 'started'; | ||
} catch(err) { | ||
} catch (err) { | ||
context.status = 'errored'; | ||
@@ -148,3 +148,3 @@ throw new Error(err); | ||
context = await this.get(contextName); | ||
} catch(err) { | ||
} catch (err) { | ||
client.socket.send( | ||
@@ -190,3 +190,3 @@ CONTEXT_ENTER_ERROR, | ||
client.socket.send(CONTEXT_ENTER_RESPONSE, reqId, contextName); | ||
} catch(err) { | ||
} catch (err) { | ||
client.socket.send(CONTEXT_ENTER_ERROR, reqId, contextName, err.message); | ||
@@ -213,3 +213,3 @@ } | ||
client.socket.send(CONTEXT_EXIT_RESPONSE, reqId, contextName); | ||
} catch(err) { | ||
} catch (err) { | ||
client.socket.send(CONTEXT_EXIT_ERROR, reqId, contextName, err.message); | ||
@@ -216,0 +216,0 @@ } |
@@ -8,6 +8,6 @@ import fs from 'node:fs'; | ||
import { isPlainObject } from '@ircam/sc-utils'; | ||
import chalk from 'chalk'; | ||
import compression from 'compression'; | ||
import express from 'express'; | ||
import isPlainObject from 'is-plain-obj'; | ||
import Keyv from 'keyv'; | ||
@@ -240,3 +240,3 @@ import { KeyvFile } from 'keyv-file'; | ||
*/ | ||
this.router = express(); | ||
this.router = express.Router(); | ||
// compression (must be set before serve-static) | ||
@@ -362,3 +362,3 @@ this.router.use(compression()); | ||
if (this.config.env.auth) { | ||
this.router.use((req, res, next) => { | ||
const soundworksAuth = (req, res, next) => { | ||
@@ -392,3 +392,5 @@ const isProtected = this.config.env.auth.clients | ||
} | ||
}); | ||
}; | ||
this.router.use(soundworksAuth); | ||
} | ||
@@ -418,3 +420,3 @@ | ||
x509 = new X509Certificate(cert); | ||
} catch(err) { | ||
} catch (err) { | ||
this._dispatchStatus('errored'); | ||
@@ -431,3 +433,3 @@ throw new Error(`[soundworks:Server] Invalid https cert file`); | ||
} | ||
} catch(err) { | ||
} catch (err) { | ||
this._dispatchStatus('errored'); | ||
@@ -456,3 +458,3 @@ throw new Error(`[soundworks:Server] Invalid https key file`); | ||
this.httpServer = https.createServer({ key, cert }, this.router); | ||
} catch(err) { | ||
} catch (err) { | ||
logger.error(` | ||
@@ -736,3 +738,3 @@ Invalid certificate files, please check your: | ||
template = stats.isFile() ? clientTmpl : defaultTmpl; | ||
} catch(err) { | ||
} catch (err) { | ||
template = defaultTmpl; | ||
@@ -745,3 +747,3 @@ } | ||
tmplString = fs.readFileSync(template, 'utf8'); | ||
} catch(err) { | ||
} catch (err) { | ||
throw new Error(`[soundworks:Server] html template file "${template}" not found`); | ||
@@ -751,4 +753,4 @@ } | ||
const tmpl = templateEngine.compile(tmplString); | ||
// http request | ||
router.get(route, (req, res) => { | ||
const soundworksClientHandler = (req, res) => { | ||
const data = clientConfigFunction(role, this.config, req); | ||
@@ -769,3 +771,5 @@ | ||
res.end(appIndex); | ||
}); | ||
}; | ||
// http request | ||
router.get(route, soundworksClientHandler); | ||
@@ -819,3 +823,3 @@ // return route infos for logging on server start | ||
this.pluginManager.checkRegisteredPlugins(registeredPlugins); | ||
} catch(err) { | ||
} catch (err) { | ||
socket.send(CLIENT_HANDSHAKE_ERROR, { | ||
@@ -822,0 +826,0 @@ type: 'invalid-plugin-list', |
@@ -21,3 +21,2 @@ import BaseSharedState from '../common/BaseSharedState.js'; | ||
/** | ||
@@ -24,0 +23,0 @@ * The `SharedState` is one of the most important and versatile abstraction provided |
import EventEmitter from 'node:events'; | ||
import { idGenerator, isString, isPlainObject } from '@ircam/sc-utils'; | ||
import clonedeep from 'lodash.clonedeep'; | ||
@@ -8,3 +9,2 @@ | ||
import SharedStatePrivate from '../common/SharedStatePrivate.js'; | ||
import { isString, isPlainObject } from '../common/utils.js'; | ||
import { | ||
@@ -26,4 +26,4 @@ SERVER_ID, | ||
} from '../common/constants.js'; | ||
import { idGenerator } from '../common/utils.js'; | ||
const generateStateId = idGenerator(); | ||
@@ -366,3 +366,3 @@ const generateRemoteId = idGenerator(); | ||
}); | ||
} catch(err) { | ||
} catch (err) { | ||
client.transport.emit(CREATE_ERROR, reqId, err.message); | ||
@@ -369,0 +369,0 @@ console.error(err.message); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
331422
0
8556
0
+ Added@ircam/sc-utils@^1.0.1
+ Added@ircam/sc-utils@1.8.0(transitive)
+ Addednumber-precision@1.6.0(transitive)
- Removedis-plain-obj@^4.1.0