js: Release v0.4.0
This commit is contained in:
parent
3eca1675a2
commit
24f9a2ac3b
@ -90,12 +90,13 @@ Feature release.
|
||||
|
||||
**Mopidy.js client library**
|
||||
|
||||
This version has been released to npm as Mopidy.js v0.4.0.
|
||||
|
||||
- Update Mopidy.js to use when.js 3. If you maintain a Mopidy client, you
|
||||
should review the `differences between when.js 2 and 3
|
||||
<https://github.com/cujojs/when/blob/master/docs/api.md#upgrading-to-30-from-2x>`_
|
||||
and the `when.js debugging guide
|
||||
<https://github.com/cujojs/when/blob/master/docs/api.md#debugging-promises>`_.
|
||||
This version has been released to npm as Mopidy.js v0.3.0.
|
||||
|
||||
- All of Mopidy.js' promise rejection values are now of the Error type. This
|
||||
ensures that all JavaScript VMs will show a useful stack trace if a rejected
|
||||
|
||||
@ -80,7 +80,7 @@ To run other [grunt](http://gruntjs.com/) targets which isn't predefined in
|
||||
Changelog
|
||||
---------
|
||||
|
||||
### 0.4.0 (UNRELEASED)
|
||||
### 0.4.0 (2014-06-24)
|
||||
|
||||
- Add support for method calls with by-name arguments. The old calling
|
||||
convention, "by-position-only", is still the default, but this will change in
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "mopidy",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"description": "Client lib for controlling a Mopidy music server over a WebSocket",
|
||||
"keywords": [
|
||||
"mopidy",
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/*! Mopidy.js v0.3.0 - built 2014-06-16
|
||||
/*! Mopidy.js v0.4.0 - built 2014-06-24
|
||||
* http://www.mopidy.com/
|
||||
* Copyright (c) 2014 Stein Magnus Jodal and contributors
|
||||
* Licensed under the Apache License, Version 2.0 */
|
||||
@ -2337,8 +2337,8 @@ function Mopidy(settings) {
|
||||
return new Mopidy(settings);
|
||||
}
|
||||
|
||||
this._console = this._getConsole(settings || {});
|
||||
this._settings = this._configure(settings || {});
|
||||
this._console = this._getConsole();
|
||||
|
||||
this._backoffDelay = this._settings.backoffDelayMin;
|
||||
this._pendingRequests = {};
|
||||
@ -2368,6 +2368,20 @@ Mopidy.ServerError.prototype.constructor = Mopidy.ServerError;
|
||||
|
||||
Mopidy.WebSocket = websocket.Client;
|
||||
|
||||
Mopidy.prototype._getConsole = function (settings) {
|
||||
if (typeof settings.console !== "undefined") {
|
||||
return settings.console;
|
||||
}
|
||||
|
||||
var con = typeof console !== "undefined" && console || {};
|
||||
|
||||
con.log = con.log || function () {};
|
||||
con.warn = con.warn || function () {};
|
||||
con.error = con.error || function () {};
|
||||
|
||||
return con;
|
||||
};
|
||||
|
||||
Mopidy.prototype._configure = function (settings) {
|
||||
var currentHost = (typeof document !== "undefined" &&
|
||||
document.location.host) || "localhost";
|
||||
@ -2381,19 +2395,18 @@ Mopidy.prototype._configure = function (settings) {
|
||||
settings.backoffDelayMin = settings.backoffDelayMin || 1000;
|
||||
settings.backoffDelayMax = settings.backoffDelayMax || 64000;
|
||||
|
||||
if (typeof settings.callingConvention === "undefined") {
|
||||
this._console.warn(
|
||||
"Mopidy.js is using the default calling convention. The " +
|
||||
"default will change in the future. You should explicitly " +
|
||||
"specify which calling convention you use.");
|
||||
}
|
||||
settings.callingConvention = (
|
||||
settings.callingConvention || "by-position-only");
|
||||
|
||||
return settings;
|
||||
};
|
||||
|
||||
Mopidy.prototype._getConsole = function () {
|
||||
var console = typeof console !== "undefined" && console || {};
|
||||
|
||||
console.log = console.log || function () {};
|
||||
console.warn = console.warn || function () {};
|
||||
console.error = console.error || function () {};
|
||||
|
||||
return console;
|
||||
};
|
||||
|
||||
Mopidy.prototype._delegateEvents = function () {
|
||||
// Remove existing event handlers
|
||||
this.off("websocket:close");
|
||||
@ -2573,18 +2586,36 @@ Mopidy.prototype._handleEvent = function (eventMessage) {
|
||||
|
||||
Mopidy.prototype._getApiSpec = function () {
|
||||
return this._send({method: "core.describe"})
|
||||
.then(this._createApi.bind(this), this._handleWebSocketError)
|
||||
.then(null, this._handleWebSocketError);
|
||||
.then(this._createApi.bind(this))
|
||||
.catch(this._handleWebSocketError);
|
||||
};
|
||||
|
||||
Mopidy.prototype._createApi = function (methods) {
|
||||
var byPositionOrByName = (
|
||||
this._settings.callingConvention === "by-position-or-by-name");
|
||||
|
||||
var caller = function (method) {
|
||||
return function () {
|
||||
var params = Array.prototype.slice.call(arguments);
|
||||
return this._send({
|
||||
method: method,
|
||||
params: params
|
||||
});
|
||||
var message = {method: method};
|
||||
if (arguments.length === 0) {
|
||||
return this._send(message);
|
||||
}
|
||||
if (!byPositionOrByName) {
|
||||
message.params = Array.prototype.slice.call(arguments);
|
||||
return this._send(message);
|
||||
}
|
||||
if (arguments.length > 1) {
|
||||
return when.reject(new Error(
|
||||
"Expected zero arguments, a single array, " +
|
||||
"or a single object."));
|
||||
}
|
||||
if (!Array.isArray(arguments[0]) &&
|
||||
arguments[0] !== Object(arguments[0])) {
|
||||
return when.reject(new TypeError(
|
||||
"Expected an array or an object."));
|
||||
}
|
||||
message.params = arguments[0];
|
||||
return this._send(message);
|
||||
}.bind(this);
|
||||
}.bind(this);
|
||||
|
||||
|
||||
4
mopidy/http/data/mopidy.min.js
vendored
4
mopidy/http/data/mopidy.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user