Comparing version 1.2.0-rc.0 to 1.2.0
# Changelog | ||
## 1.2.0-rc.0 (2016-4-28) | ||
See these [`1.1.x` to `1.2.0` upgrade instructions](https://gist.github.com/chrismccord/29100e16d3990469c47f851e3142f766) to bring your existing apps up to speed. | ||
## 1.2.0 (2016-6-23) | ||
See these [`1.1.x` to `1.2.x` upgrade instructions](https://gist.github.com/chrismccord/29100e16d3990469c47f851e3142f766) to bring your existing apps up to speed. | ||
* Enhancements | ||
* [CodeReloader] The `lib/` directory is now code reloaded by default along with `web/` in development | ||
* [Channel] Add `subscribe/2` and `unsubscribe/2` to handle external topic subscriptions for a socket | ||
* [Channel] Add `:phoenix_channel_join` instrumentation hook | ||
* [View] Generate private `render_template/2` clauses for views to allow overriding `render/2` clauses before rendering templates | ||
* [Channel] Add `:phoenix_channel_join` instrumentation hook | ||
* [View] Add `:path` and `:pattern` options to allow wildcard template inclusion as well as customized template directory locations | ||
* JavaScript client enhancements | ||
* Add Presence object for syncing presence state between client and server | ||
* Deprecations | ||
* [Endpoint] Generated `subscribe/3` and `unsubscribe/2` clauses have been deprecated in favor of `subscribe/2` and `unsubscribe/1` which uses the caller's pid | ||
* [PubSub] `Phoenix.PubSub.subscribe/3` and `Phoenix.PubSub.unsubscribe/2` have been deprecated in favor of `subscribe/2` and `unsubscribe/1` which uses the caller's pid | ||
* [Watcher] Using the `:root` endpoint configuration for watchers is deprecated. Pass the :cd option at the end of your watcher argument list in config/dev.exs. For example: | ||
```elixir | ||
watchers: [node: ["node_modules/brunch/bin/brunch", "watch", "--stdin", | ||
cd: Path.expand("../", __DIR__)]] | ||
``` | ||
* Bug Fixes | ||
* [Template] Prevent infinite call stack when rendering a non-existent template from `template_not_found` | ||
* Backward incompatible changes | ||
* [Channel] `subscribe/1` and `unsubscribe/1` have been removed in favor of calling subscribe and unsubscribe off the endpoint directly | ||
* JavaScript client enhancements | ||
* Add Presence object for syncing presence state between client and server | ||
* Use return value of channel onMessage callback for specialized message transformations before dispatching to the channel | ||
* JavaScript client backward incompatible changes | ||
* `Presence.syncState` and `Presence.syncDiff` now return a copy of the state instead of mutating it | ||
## 1.1.6 (2016-6-03) | ||
* Enhancements | ||
* Add Erlang 19 compatibility | ||
## 1.1.5 (2016-6-01) | ||
* Enhancements | ||
* Fix warnings for Elixir 1.3 | ||
## 1.1.4 (2016-1-25) | ||
@@ -21,0 +50,0 @@ |
{ | ||
"name": "phoenix", | ||
"version": "1.2.0-rc.0", | ||
"version": "1.2.0", | ||
"description": "The official JavaScript client for the Phoenix web framework.", | ||
"license": "MIT", | ||
"main": "./priv/static/phoenix.js", | ||
@@ -5,0 +7,0 @@ "repository": { |
@@ -41,3 +41,3 @@ (function(exports){ | ||
// | ||
// let channel = socket.channel("rooms:123", {token: roomToken}) | ||
// let channel = socket.channel("room:123", {token: roomToken}) | ||
// channel.on("new_msg", msg => console.log("Got message", msg) ) | ||
@@ -146,3 +146,3 @@ // $input.onEnter( e => { | ||
// let state = {} | ||
// Presence.syncState(state, stateFromServer) | ||
// state = Presence.syncState(state, stateFromServer) | ||
// let listBy = (id, {metas: [first, ...rest]}) => { | ||
@@ -177,3 +177,3 @@ // first.count = rest.length + 1 // count of this user's presences | ||
// myChannel.on("presences", state => { | ||
// Presence.syncState(presences, state, onJoin, onLeave) | ||
// presences = Presence.syncState(presences, state, onJoin, onLeave) | ||
// displayUsers(Presence.list(presences)) | ||
@@ -183,3 +183,3 @@ // }) | ||
// myChannel.on("presence_diff", diff => { | ||
// Presence.syncDiff(presences, diff, onJoin, onLeave) | ||
// presences = Presence.syncDiff(presences, diff, onJoin, onLeave) | ||
// this.setState({users: Presence.list(room.presences, listBy)}) | ||
@@ -363,2 +363,3 @@ // }) | ||
this.onClose(function () { | ||
_this2.rejoinTimer.reset(); | ||
_this2.socket.log("channel", "close " + _this2.topic + " " + _this2.joinRef()); | ||
@@ -369,2 +370,5 @@ _this2.state = CHANNEL_STATES.closed; | ||
this.onError(function (reason) { | ||
if (_this2.isLeaving() || _this2.isClosed()) { | ||
return; | ||
} | ||
_this2.socket.log("channel", "error " + _this2.topic, reason); | ||
@@ -375,6 +379,5 @@ _this2.state = CHANNEL_STATES.errored; | ||
this.joinPush.receive("timeout", function () { | ||
if (_this2.state !== CHANNEL_STATES.joining) { | ||
if (!_this2.isJoining()) { | ||
return; | ||
} | ||
_this2.socket.log("channel", "timeout " + _this2.topic, _this2.joinPush.timeout); | ||
@@ -437,3 +440,3 @@ _this2.state = CHANNEL_STATES.errored; | ||
value: function canPush() { | ||
return this.socket.isConnected() && this.state === CHANNEL_STATES.joined; | ||
return this.socket.isConnected() && this.isJoined(); | ||
} | ||
@@ -501,6 +504,11 @@ }, { | ||
// Receives all events for specialized message handling | ||
// before dispatching to the channel callbacks. | ||
// | ||
// Must return the payload, modified or unmodified | ||
}, { | ||
key: "onMessage", | ||
value: function onMessage(event, payload, ref) {} | ||
value: function onMessage(event, payload, ref) { | ||
return payload; | ||
} | ||
@@ -529,3 +537,3 @@ // private | ||
var timeout = arguments.length <= 0 || arguments[0] === undefined ? this.timeout : arguments[0]; | ||
if (this.state === CHANNEL_STATES.leaving) { | ||
if (this.isLeaving()) { | ||
return; | ||
@@ -546,7 +554,11 @@ } | ||
} | ||
this.onMessage(event, payload, ref); | ||
var handledPayload = this.onMessage(event, payload, ref); | ||
if (payload && !handledPayload) { | ||
throw "channel onMessage callbacks must return the payload, modified or unmodified"; | ||
} | ||
this.bindings.filter(function (bind) { | ||
return bind.event === event; | ||
}).map(function (bind) { | ||
return bind.callback(payload, ref); | ||
return bind.callback(handledPayload, ref); | ||
}); | ||
@@ -559,2 +571,27 @@ } | ||
} | ||
}, { | ||
key: "isClosed", | ||
value: function isClosed() { | ||
return this.state === CHANNEL_STATES.closed; | ||
} | ||
}, { | ||
key: "isErrored", | ||
value: function isErrored() { | ||
return this.state === CHANNEL_STATES.errored; | ||
} | ||
}, { | ||
key: "isJoined", | ||
value: function isJoined() { | ||
return this.state === CHANNEL_STATES.joined; | ||
} | ||
}, { | ||
key: "isJoining", | ||
value: function isJoining() { | ||
return this.state === CHANNEL_STATES.joining; | ||
} | ||
}, { | ||
key: "isLeaving", | ||
value: function isLeaving() { | ||
return this.state === CHANNEL_STATES.leaving; | ||
} | ||
}]); | ||
@@ -1088,5 +1125,6 @@ | ||
var Presence = exports.Presence = { | ||
syncState: function syncState(state, newState, onJoin, onLeave) { | ||
syncState: function syncState(currentState, newState, onJoin, onLeave) { | ||
var _this12 = this; | ||
var state = this.clone(currentState); | ||
var joins = {}; | ||
@@ -1097,3 +1135,3 @@ var leaves = {}; | ||
if (!newState[key]) { | ||
leaves[key] = _this12.clone(presence); | ||
leaves[key] = presence; | ||
} | ||
@@ -1130,8 +1168,9 @@ }); | ||
}); | ||
this.syncDiff(state, { joins: joins, leaves: leaves }, onJoin, onLeave); | ||
return this.syncDiff(state, { joins: joins, leaves: leaves }, onJoin, onLeave); | ||
}, | ||
syncDiff: function syncDiff(state, _ref2, onJoin, onLeave) { | ||
syncDiff: function syncDiff(currentState, _ref2, onJoin, onLeave) { | ||
var joins = _ref2.joins; | ||
var leaves = _ref2.leaves; | ||
var state = this.clone(currentState); | ||
if (!onJoin) { | ||
@@ -1170,2 +1209,3 @@ onJoin = function onJoin() {}; | ||
}); | ||
return state; | ||
}, | ||
@@ -1172,0 +1212,0 @@ list: function list(presences, chooser) { |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
81041
5
1169
1
0
76
1