-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from ianwith/dev
Updating v0.2.0
- Loading branch information
Showing
18 changed files
with
385 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
|
||
var _utils = require('./utils'); | ||
|
||
/** | ||
* Assemble payload for message | ||
* | ||
* assemblePayload({ data: '' }) | ||
* | ||
* @param {object} obj | ||
* @param {string} base | ||
* @returns {string} | ||
*/ | ||
var assemblePayload = function assemblePayload(obj) { | ||
var base = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; | ||
|
||
if ((0, _utils.getType)(obj) !== 'Object' || (0, _utils.getType)(base) !== 'String') { | ||
throw new Error('assemblePayload arguments type error'); | ||
} | ||
var query = Object.getOwnPropertyNames(obj).map(function (key) { | ||
var value = obj[key]; | ||
// Q: does callback need to be registed | ||
if ((0, _utils.getType)(value) === 'Object') { | ||
value = JSON.stringify(value); | ||
} | ||
return encodeURIComponent(key) + '=' + encodeURIComponent(value); | ||
}).join('&'); | ||
if (base) { | ||
base = '/' + base; | ||
} | ||
return (base + '&' + query).replace(/[&?]/, '?'); | ||
}; | ||
|
||
exports.default = assemblePayload; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
|
||
var _utils = require('./utils'); | ||
|
||
/** | ||
* Curry function for callback register | ||
* | ||
* callbackListener('Rexxar.Widget.AlertDialog')('clickHandler')(()=>{})) | ||
* | ||
* @param {string} ns | ||
* @returns {string} The callback name | ||
*/ | ||
var callbackListener = function callbackListener(ns) { | ||
return function (name) { | ||
return function (callback) { | ||
(0, _utils.namespace)(ns)[name] = function (jsonStr) { | ||
var data = void 0; | ||
try { | ||
data = JSON.parse(jsonStr); | ||
} catch (e) { | ||
data = jsonStr; | ||
} | ||
callback(data); | ||
}; | ||
return ns + '.' + name; | ||
}; | ||
}; | ||
}; | ||
|
||
exports.default = callbackListener; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
|
||
var _utils = require('./utils'); | ||
|
||
/** | ||
* Dispatch message to client | ||
* | ||
* @param {string} msg | ||
*/ | ||
var dispatch = function dispatch(msg) { | ||
(0, _utils.callUri)(msg); | ||
}; | ||
|
||
exports.default = dispatch; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
|
||
var _utils = require('./utils'); | ||
|
||
/** | ||
* Dispatch message to client | ||
* | ||
* @param {string} msg | ||
*/ | ||
var dispatchMessage = function dispatchMessage(msg) { | ||
(0, _utils.callUri)(msg); | ||
}; | ||
|
||
exports.default = dispatchMessage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.