diff --git a/index.js b/index.js new file mode 100644 index 0000000..f617052 --- /dev/null +++ b/index.js @@ -0,0 +1,23 @@ +import ActionCable from 'actioncable' + +ActionCable.getConfig = () => null +ActionCable.createWebSocketURL = (url) => { + const result = url.replace(/^http/, 'ws') + console.log(result) + return result +} +ActionCable.startDebugging() + +const oldOpen = ActionCable.Connection.prototype.open +ActionCable.Connection.prototype.open = function () { + const result = oldOpen.apply(this) + this.webSocket.protocol = 'actioncable-v1-json' + return result +} + +global.document = { + addEventListener () {}, + removeEventListener () {} +} + +export default ActionCable diff --git a/package.json b/package.json new file mode 100644 index 0000000..ea84848 --- /dev/null +++ b/package.json @@ -0,0 +1,27 @@ +{ + "name": "react-native-actioncable", + "version": "0.0.1", + "description": "ActionCable for react native", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/cpunion/react-native-actioncable.git" + }, + "keywords": [ + "ActionCable", + "react", + "native" + ], + "author": "Li Jie ", + "license": "MIT", + "bugs": { + "url": "https://github.com/cpunion/react-native-actioncable/issues" + }, + "homepage": "https://github.com/cpunion/react-native-actioncable#readme", + "dependencies": { + "actioncable": "^5.0.0" + } +}