@soundworks/core
Advanced tools
Comparing version 3.1.0-beta.0 to 3.1.0-beta.1
@@ -144,3 +144,4 @@ "use strict"; | ||
if (this._registeredPlugins[name]) { | ||
throw new Error(`Plugin "${name}" already registered`); | ||
const ctor = factory(_AbstractPlugin.default); | ||
throw new Error(`[soundworks:core] plugin "${name}" of type "${ctor.name}" already registered`); | ||
} | ||
@@ -147,0 +148,0 @@ |
{ | ||
"name": "@soundworks/core", | ||
"version": "3.1.0-beta.0", | ||
"version": "3.1.0-beta.1", | ||
"description": "full-stack javascript framework for distributed audio visual experiences on the web", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -59,2 +59,3 @@ # `soundworks` | ||
- Benjamin Matuszewski. A Web-Based Framework for Distributed Music System Research and Creation. AES - Journal of the Audio Engineering Society Audio-Accoustics-Application, Audio Engineering Society Inc, 2020. <[hal-03033143](https://hal.archives-ouvertes.fr/hal-03033143)> | ||
- Benjamin Matuszewski. Soundworks - A Framework for Networked Music Systems on the Web - State of Affairs and New Developments. Proceedings of the Web Audio Conference (WAC) 2019, Dec 2019, Trondheim, Norway. <[hal-02387783](https://hal.archives-ouvertes.fr/hal-02387783)> | ||
@@ -61,0 +62,0 @@ - Benjamin Matuszewski, Norbert Schnell, Frédéric Bevilacqua. Interaction Topologies in Mobile-Based Situated Networked Music Systems. Wireless Communications and Mobile Computing, Hindawi Publishing Corporation, 2019, 2019, pp.9142490. ⟨10.1155/2019/9142490⟩. <[hal-02086673](https://hal.archives-ouvertes.fr/hal-02086673)> |
@@ -89,3 +89,4 @@ "use strict"; | ||
if (this._registeredPlugins[name]) { | ||
throw new Error(`Plugin "${name}" already registered`); | ||
const ctor = factory(_AbstractPlugin.default); | ||
throw new Error(`[soundworks:core] plugin "${name}" of type "${ctor.name}" already registered`); | ||
} | ||
@@ -92,0 +93,0 @@ |
@@ -38,8 +38,13 @@ "use strict"; | ||
var _Db = _interopRequireDefault(require("./utils/Db.js")); | ||
var _logger = _interopRequireDefault(require("./utils/logger.js")); | ||
var _keyv = _interopRequireDefault(require("keyv")); | ||
var _keyvFile = _interopRequireDefault(require("keyv-file")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
let _dbNamespaces = new Set(); | ||
let _dbStore = null; | ||
/** | ||
@@ -62,2 +67,3 @@ * Server side entry point for a `soundworks` application. | ||
*/ | ||
class Server { | ||
@@ -103,3 +109,3 @@ constructor() { | ||
this.db = new _Db.default(); | ||
this.db = this.createNamespacedDb('core'); | ||
/** | ||
@@ -326,4 +332,4 @@ * The {@link server.Sockets} instance. A small wrapper around | ||
return new Promise(async (resolve, reject) => { | ||
const key = await this.db.get('server:httpsKey'); | ||
const cert = await this.db.get('server:httpsCert'); | ||
const key = await this.db.get('httpsKey'); | ||
const cert = await this.db.get('httpsCert'); | ||
@@ -353,4 +359,4 @@ if (key && cert) { | ||
}; | ||
await this.db.set('server:httpsKey', this._httpsInfos.key); | ||
await this.db.set('server:httpsCert', this._httpsInfos.cert); | ||
await this.db.set('httpsKey', this._httpsInfos.key); | ||
await this.db.set('httpsCert', this._httpsInfos.cert); | ||
@@ -574,3 +580,41 @@ const httpsServer = _https.default.createServer(this._httpsInfos); | ||
} | ||
/** | ||
* Create namespaced databases for core and plugins | ||
* (kind of experiemental API do not expose in doc for now) | ||
* | ||
* @note - introduced in v3.1.0-beta.1 | ||
* @note - used by core and plugin-audio-streams | ||
* @private | ||
*/ | ||
createNamespacedDb(namespace = null) { | ||
if (namespace === null || !(typeof namespace === 'string')) { | ||
throw new Error(`[soundworks:core] Invalid namespace for ".createNamespacedDb(namespace)", namespace is mandatory and should be a string`); | ||
} | ||
if (_dbNamespaces.has(namespace)) { | ||
throw new Error(`[soundworks:core] Invalid namespace for ".createNamespacedDb(namespace)", namespace "${namespace}" already exists`); | ||
} | ||
const dbDirectory = _path.default.join(process.cwd(), '.data'); | ||
if (!_fs.default.existsSync(dbDirectory)) { | ||
_fs.default.mkdirSync(dbDirectory); | ||
} | ||
const filename = _path.default.join(dbDirectory, `soundworks-${namespace}.db`); // at note keyv-file doesn't seems to works | ||
const store = new _keyvFile.default({ | ||
filename | ||
}); | ||
const db = new _keyv.default({ | ||
namespace, | ||
store | ||
}); | ||
db.on('error', err => console.log(chalk.red('[soundworks:core] db ${namespace} error:'), err)); | ||
return db; | ||
} | ||
} | ||
@@ -577,0 +621,0 @@ |
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
159845
79
1
27
3945