@soundworks/core
Advanced tools
Comparing version 3.0.2 to 3.0.3
@@ -37,3 +37,2 @@ "use strict"; | ||
*/ | ||
// import { default as TmpService } from './Service'; | ||
// `import soundworks from '@soundworks/core/client'`` | ||
@@ -40,0 +39,0 @@ // or |
@@ -76,5 +76,12 @@ "use strict"; | ||
const { | ||
let { | ||
path | ||
} = config.env.websockets; | ||
} = config.env.websockets; // @note: keep this check | ||
// backward compatibility w/ assetsDomain and websocket old config way | ||
// cf. https://github.com/collective-soundworks/soundworks/issues/35 | ||
if (config.env.subpath) { | ||
path = `${config.env.subpath}/${path}`; | ||
} | ||
let url; | ||
@@ -81,0 +88,0 @@ |
@@ -78,2 +78,4 @@ "use strict"; | ||
this._onDeleteCallbacks.forEach(callback => callback()); | ||
this._clearDetach(); | ||
}); | ||
@@ -94,2 +96,4 @@ | ||
this._clearDetach(); | ||
(0, _sharedStateUtils.resolveRequest)(reqId, this); | ||
@@ -111,2 +115,4 @@ }); | ||
this._clearDetach(); | ||
(0, _sharedStateUtils.resolveRequest)(reqId, this); | ||
@@ -121,2 +127,14 @@ }); // the state does not exists anymore in the server (should not happen) | ||
_clearDetach() { | ||
this._onDetachCallbacks.clear(); | ||
this._onDeleteCallbacks.clear(); // Monkey patch detach so it throws we called twice. Doing nothing blocks | ||
// the process on a second `detach` call as the Promise was never resolved | ||
this.detach = () => { | ||
throw new Error(`State "${this.schemaName} (${this.id})" already detached, cannot detach twice`); | ||
}; | ||
} | ||
_clearTransport() { | ||
@@ -123,0 +141,0 @@ // remove listeners |
{ | ||
"name": "@soundworks/core", | ||
"version": "3.0.2", | ||
"version": "3.0.3", | ||
"description": "full-stack javascript framework for distributed audio visual experiences on the web", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -47,4 +47,4 @@ "use strict"; | ||
AbstractExperience: _AbstractExperience2.default, | ||
Client: _Server2.default | ||
Server: _Server2.default | ||
}; | ||
exports.default = _default; |
@@ -16,2 +16,4 @@ "use strict"; | ||
var _lodash = _interopRequireDefault(require("lodash.merge")); | ||
var _path = _interopRequireDefault(require("path")); | ||
@@ -70,7 +72,4 @@ | ||
* port: 8000, | ||
* "websockets": { | ||
* "path": "socket", | ||
* "pingInterval": 5000 | ||
* }, | ||
* "useHttps": false, | ||
* subfolder: '', | ||
* useHttps: false, | ||
* }, | ||
@@ -190,2 +189,5 @@ * app: { | ||
* listen | ||
* @param {String} [config.subpath] - If the application runs behind a | ||
* proxy server (e.g. https://my-domain.com/my-app/`), path to the | ||
* application root (i.e. 'my-app') | ||
* @param {Boolean} [config.useHttps=false] - Define wheter to use or not an | ||
@@ -197,5 +199,2 @@ * an https server. | ||
* will consider the application as not safe in the case. | ||
* @param {Object} [config.websocket={}] - TBD | ||
* @param {String} [config.templateDirectory='src/server/tmpl'] - Folder in | ||
* which the server will look for the `index.html` template. | ||
* | ||
@@ -212,7 +211,4 @@ * @param {Function} clientConfigFunction - function that filters / defines | ||
* port: 8000, | ||
* "websockets": { | ||
* "path": "socket", | ||
* "pingInterval": 5000 | ||
* }, | ||
* "useHttps": false, | ||
* subpath: '', | ||
* useHttps: false, | ||
* }, | ||
@@ -231,19 +227,36 @@ * app: { | ||
async init(config = { | ||
env: { | ||
type: 'development', | ||
port: 8000, | ||
"websockets": { | ||
"path": "socket", | ||
"pingInterval": 5000 | ||
async init(config, clientConfigFunction = (clientType, serverConfig, httpRequest) => ({ | ||
clientType | ||
})) { | ||
const defaultConfig = { | ||
env: { | ||
type: 'development', | ||
port: 8000, | ||
subpath: '', | ||
websockets: { | ||
path: 'socket', | ||
pingInterval: 5000 | ||
}, | ||
useHttps: false | ||
}, | ||
"useHttps": false | ||
}, | ||
app: { | ||
name: 'soundworks' | ||
app: { | ||
name: 'soundworks' | ||
} | ||
}; | ||
this.config = (0, _lodash.default)({}, defaultConfig, config); // @note: do not remove | ||
// backward compatibility w/ assetsDomain and `soundworks-template` | ||
// cf. https://github.com/collective-soundworks/soundworks/issues/35 | ||
// see also '@soundworks/plugin-audio-buffer-loader' (could be updated more | ||
// easily as the `assetsDomain` entry was not documented) | ||
// - we need to handle 3 cases: | ||
// + old config style / old template | ||
// + new config style / old template | ||
// + new template | ||
// @note: keep `websocket.path` as defined should be enough | ||
if (!this.config.env.assetsDomain && this.config.env.subpath) { | ||
const subpath = this.config.env.subpath.replace(/^\//, '').replace(/\/$/, ''); | ||
this.config.env.assetsDomain = `/${subpath}/`; | ||
} | ||
}, clientConfigFunction = (clientType, serverConfig, httpRequest) => ({ | ||
clientType | ||
})) { | ||
this.config = config; | ||
this._clientConfigFunction = clientConfigFunction; | ||
@@ -490,4 +503,11 @@ return Promise.resolve(); | ||
router.get(route, (req, res) => { | ||
const data = this._clientConfigFunction(clientType, this.config, req); | ||
const data = this._clientConfigFunction(clientType, this.config, req); // @note: do not remove | ||
// backward compatibility w/ assetsDomain and `soundworks-template` | ||
// cf. https://github.com/collective-soundworks/soundworks/issues/35 | ||
if (this.config.env.subpath && !data.env.subpath) { | ||
data.env.subpath = this.config.env.subpath; | ||
} | ||
const appIndex = tmpl(data); | ||
@@ -494,0 +514,0 @@ res.end(appIndex); |
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
131183
3293