Skip to content

Commit

Permalink
0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
danielstjules committed Mar 5, 2015
1 parent b9de228 commit 9b680c9
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 22 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cross-storage",
"version": "0.5.1",
"version": "0.6.0",
"description": "Cross domain local storage",
"license": "Apache-2.0",
"authors": [
Expand Down
12 changes: 6 additions & 6 deletions dist/client.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* cross-storage - Cross domain local storage
*
* @version 0.5.1
* @version 0.6.0
* @link https://github.com/zendesk/cross-storage
* @author Daniel St. Jules <[email protected]>
* @copyright Zendesk
Expand Down Expand Up @@ -275,7 +275,7 @@ CrossStorageClient.prototype._installListener = function() {
if (message.origin !== client._origin) return;

// LocalStorage isn't available in the hub
if (message.data === 'unavailable') {
if (message.data === 'cross-storage:unavailable') {
if (!client._closed) client.close();
if (!client._requests.connect) return;

Expand All @@ -288,7 +288,7 @@ CrossStorageClient.prototype._installListener = function() {
}

// Handle initial connection
if (!client._connected) {
if (message.data.indexOf('cross-storage:') !== -1 && !client._connected) {
client._connected = true;
if (!client._requests.connect) return;

Expand All @@ -298,7 +298,7 @@ CrossStorageClient.prototype._installListener = function() {
delete client._requests.connect;
}

if (message.data === 'ready') return;
if (message.data === 'cross-storage:ready') return;

// All other messages
try {
Expand Down Expand Up @@ -335,7 +335,7 @@ CrossStorageClient.prototype._poll = function() {
if (client._connected) return clearInterval(interval);
if (!client._hub) return;

client._hub.postMessage('poll', client._origin);
client._hub.postMessage('cross-storage:poll', client._origin);
}, 1000);
};

Expand Down Expand Up @@ -391,7 +391,7 @@ CrossStorageClient.prototype._request = function(method, params) {

req = {
id: this._id + ':' + client._count,
method: method,
method: 'cross-storage:' + method,
params: params
};

Expand Down
4 changes: 2 additions & 2 deletions dist/client.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 14 additions & 10 deletions dist/hub.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* cross-storage - Cross domain local storage
*
* @version 0.5.1
* @version 0.6.0
* @link https://github.com/zendesk/cross-storage
* @author Daniel St. Jules <[email protected]>
* @copyright Zendesk
Expand Down Expand Up @@ -40,15 +40,15 @@ CrossStorageHub.init = function(permissions) {

if (!available) {
try {
return window.parent.postMessage('unavailable', '*');
return window.parent.postMessage('cross-storage:unavailable', '*');
} catch (e) {
return;
}
}

CrossStorageHub._permissions = permissions || [];
CrossStorageHub._installListener();
window.parent.postMessage('ready', '*');
window.parent.postMessage('cross-storage:ready', '*');
};

/**
Expand All @@ -75,22 +75,26 @@ CrossStorageHub._installListener = function() {
* @param {MessageEvent} message A message to be processed
*/
CrossStorageHub._listener = function(message) {
var uri, available, request, error, result, response;
var uri, available, request, method, error, result, response;

// Handle polling for a ready message
if (message.data === 'poll') {
return window.parent.postMessage('ready', message.origin);
if (message.data === 'cross-storage:poll') {
return window.parent.postMessage('cross-storage:ready', message.origin);
}

// Ignore the ready message when viewing the hub directly
if (message.data === 'ready') return;
if (message.data === 'cross-storage:ready') return;

request = JSON.parse(message.data);
method = request.method.split('cross-storage:')[1];

if (!CrossStorageHub._permitted(message.origin, request.method)) {
error = 'Invalid permissions for ' + request.method;
if (!method) {
return;
} else if (!CrossStorageHub._permitted(message.origin, method)) {
error = 'Invalid permissions for ' + method;
} else {
try {
result = CrossStorageHub['_' + request.method](request.params);
result = CrossStorageHub['_' + method](request.params);
} catch (err) {
error = err.message;
}
Expand Down
4 changes: 2 additions & 2 deletions dist/hub.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cross-storage",
"version": "0.5.1",
"version": "0.6.0",
"description": "Cross domain local storage",
"keywords": [
"local",
Expand Down

0 comments on commit 9b680c9

Please sign in to comment.