From f66048b76b1a12ab390a09992a50da1abe3bf6fb Mon Sep 17 00:00:00 2001 From: Jeronimo Vallelunga Date: Sat, 23 Mar 2019 08:35:45 -0300 Subject: [PATCH] Updates --- asset-manifest.json | 6 +++--- index.html | 2 +- ... precache-manifest.a59bf36c1501653bbf809bcd226f0263.js | 8 ++++---- service-worker.js | 2 +- static/js/main.a183410a.chunk.js.map | 1 - .../js/{main.a183410a.chunk.js => main.fa05bdea.chunk.js} | 4 ++-- static/js/main.fa05bdea.chunk.js.map | 1 + 7 files changed, 12 insertions(+), 12 deletions(-) rename precache-manifest.7fc2964b65498580db133edcb525afbd.js => precache-manifest.a59bf36c1501653bbf809bcd226f0263.js (66%) delete mode 100644 static/js/main.a183410a.chunk.js.map rename static/js/{main.a183410a.chunk.js => main.fa05bdea.chunk.js} (89%) create mode 100644 static/js/main.fa05bdea.chunk.js.map diff --git a/asset-manifest.json b/asset-manifest.json index ac29471..029e0ca 100644 --- a/asset-manifest.json +++ b/asset-manifest.json @@ -1,13 +1,13 @@ { "main.css": "/redux-bluetooth/static/css/main.66a8e5c7.chunk.css", - "main.js": "/redux-bluetooth/static/js/main.a183410a.chunk.js", - "main.js.map": "/redux-bluetooth/static/js/main.a183410a.chunk.js.map", + "main.js": "/redux-bluetooth/static/js/main.fa05bdea.chunk.js", + "main.js.map": "/redux-bluetooth/static/js/main.fa05bdea.chunk.js.map", "runtime~main.js": "/redux-bluetooth/static/js/runtime~main.62cbf256.js", "runtime~main.js.map": "/redux-bluetooth/static/js/runtime~main.62cbf256.js.map", "static/js/2.2698f9e4.chunk.js": "/redux-bluetooth/static/js/2.2698f9e4.chunk.js", "static/js/2.2698f9e4.chunk.js.map": "/redux-bluetooth/static/js/2.2698f9e4.chunk.js.map", "index.html": "/redux-bluetooth/index.html", - "precache-manifest.7fc2964b65498580db133edcb525afbd.js": "/redux-bluetooth/precache-manifest.7fc2964b65498580db133edcb525afbd.js", + "precache-manifest.a59bf36c1501653bbf809bcd226f0263.js": "/redux-bluetooth/precache-manifest.a59bf36c1501653bbf809bcd226f0263.js", "service-worker.js": "/redux-bluetooth/service-worker.js", "static/css/main.66a8e5c7.chunk.css.map": "/redux-bluetooth/static/css/main.66a8e5c7.chunk.css.map" } \ No newline at end of file diff --git a/index.html b/index.html index 32dfdb0..7b70648 100644 --- a/index.html +++ b/index.html @@ -1 +1 @@ -React App
\ No newline at end of file +React App
\ No newline at end of file diff --git a/precache-manifest.7fc2964b65498580db133edcb525afbd.js b/precache-manifest.a59bf36c1501653bbf809bcd226f0263.js similarity index 66% rename from precache-manifest.7fc2964b65498580db133edcb525afbd.js rename to precache-manifest.a59bf36c1501653bbf809bcd226f0263.js index 4426fb5..ab14941 100644 --- a/precache-manifest.7fc2964b65498580db133edcb525afbd.js +++ b/precache-manifest.a59bf36c1501653bbf809bcd226f0263.js @@ -4,19 +4,19 @@ self.__precacheManifest = [ "url": "/redux-bluetooth/static/js/runtime~main.62cbf256.js" }, { - "revision": "59176551ac5239ebcf6f", - "url": "/redux-bluetooth/static/js/main.a183410a.chunk.js" + "revision": "8e975dff305c42d95967", + "url": "/redux-bluetooth/static/js/main.fa05bdea.chunk.js" }, { "revision": "53cc343935e499d42616", "url": "/redux-bluetooth/static/js/2.2698f9e4.chunk.js" }, { - "revision": "59176551ac5239ebcf6f", + "revision": "8e975dff305c42d95967", "url": "/redux-bluetooth/static/css/main.66a8e5c7.chunk.css" }, { - "revision": "002191b5d321f22289e6d8b0f3e03cd4", + "revision": "70471dc36aa2c3ae9307e82dd552116b", "url": "/redux-bluetooth/index.html" } ]; \ No newline at end of file diff --git a/service-worker.js b/service-worker.js index 5475747..88e6dac 100644 --- a/service-worker.js +++ b/service-worker.js @@ -14,7 +14,7 @@ importScripts("https://storage.googleapis.com/workbox-cdn/releases/3.6.3/workbox-sw.js"); importScripts( - "/redux-bluetooth/precache-manifest.7fc2964b65498580db133edcb525afbd.js" + "/redux-bluetooth/precache-manifest.a59bf36c1501653bbf809bcd226f0263.js" ); workbox.clientsClaim(); diff --git a/static/js/main.a183410a.chunk.js.map b/static/js/main.a183410a.chunk.js.map deleted file mode 100644 index a4ec296..0000000 --- a/static/js/main.a183410a.chunk.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../../src/webapp/actions/types.js","../../../src/webapp/central/status.js","../../../src/common/config/index.js","../../../src/webapp/central/index.js","../../../src/webapp/actions/index.js","../../../src/webapp/actions/actions.js","../../../src/webapp/central/central.js","../../../src/common/encoder/index.js","../../../src/webapp/middleware/index.js","../../../src/webapp/reducers/initial.js","../../../src/webapp/reducers/index.js","../../../src/webapp/index.js","../../../src/webapp/store/index.js","actions/types.js","app/component.jsx","app/index.js","actions/index.js","index.js"],"names":["BLUETOOTH_CONNECTING","BLUETOOTH_CONNECTED","BLUETOOTH_DISCONNECTING","BLUETOOTH_DISCONNECTED","BLUETOOTH_ERROR","BLUETOOTH_READ","BLUETOOTH_SYNC","BLUETOOTH_SEND","BLUETOOTH_CONNECT_REQUEST","BLUETOOTH_DISCONNECT_REQUEST","BLUETOOTH_SEND_REQUEST","BLUETOOTH_SYNC_REQUEST","INIT","DISCONNECTED","DISCONNECTING","CONNECTING","CONNECTED","ERROR","CONFIG","SERVICE_UUID","CHARACTERISTIC_UUID","CENTRAL_CONFIG","replace","_window","window","central_navigator","navigator","TextDecoder","TextEncoder","webapp_actions","central","TYPES","syncState","state","type","payload","sendAction","action","request","write","connectStore","name","dispatch","connect","then","handler","disconnectStore","disconnect","id","bluetooth","_ref","_ref2","encode","decode","server","characteristic","message","configuration","limit","isConnected","connected","listener","callback","event","chunk","target","value","concat","startsWith","endsWith","json","JSON","parse","slice","length","requestDevice","filters","services","device","gatt","getPrimaryService","service","getCharacteristic","startNotifications","eventListener","addEventListener","Promise","reject","stringify","key","dataSize","writes","i","next","end","Math","min","data","buffer","Uint8Array","set","push","reduce","promise","writeValue","resolve","Date","now","encoder","decoder","string","Encoder","types_namespaceObject","REQUESTS","middleware","actions","arguments","undefined","store","includes","initial","status","reducers_status","remote","console","log","src_webapp_actions","createSyncStore","reducer","middlewares","enhancers","redux_es","apply","__REDUX_DEVTOOLS_EXTENSION__","Object","local","INCREMENT","DECREMENT","App","props","_this","classCallCheck","this","possibleConstructorReturn","getPrototypeOf","call","handlerConnect","bind","assertThisInitialized","onConnect","_this$props","counter","quote","onIncrement","onDecrement","nCounter","Number","className","react_default","a","createElement","onClick","PureComponent","defaultProps","mapAction","predatorQuotes","random","objectSpread","Component","keys","render","es","app","document","getElementById"],"mappings":"kwCAAOA,EAAA,yBACAC,EAAA,wBACAC,EAAA,4BACAC,EAAA,2BACAC,EAAA,oBACAC,EAAA,mBACAC,EAAA,mBACAC,EAAA,mBACAC,EAAA,8BACAC,EAAA,iCACAC,EAAA,2BACAC,EAAA,2BCXAC,EAAA,OACAC,EAAA,eACAC,EAAA,gBACAC,EAAA,aACAC,EAAA,YACAC,EAAA,QCLPC,EAAA,CACAC,aAAA,uCACAC,oBAAA,wCAEOC,EAAAH,EAEPA,EAAAC,aAAAG,QAAA,SACAJ,EAAAE,oBAAAE,QAAA,SCHA,IAAAC,EAAAC,OACIC,EAASF,EAAAG,UACbC,EAAAJ,EAAAI,YACAC,EAAAL,EAAAK,YCJe,IAAAC,ECHA,SAAAC,EAAAC,GACf,IAAAC,EAAA,SAAAC,GACA,OACAC,KAAAH,EAAAzB,eACA6B,QAAAF,IAIAG,EAAA,SAAAC,GACA,OACAH,KAAAH,EAAArB,uBACA4B,QAAA,WACA,OAAAR,EAAAS,MAAAF,MAiDA,OACAG,aA7CA,SAAAC,GACA,OACAP,KAAAH,EAAAvB,0BACA8B,QAAA,SAAAI,GAIA,OAHAA,EAAA,CACAR,KAAAH,EAAA/B,uBAEA8B,EAAAa,QAAAF,GAAAG,KAAA,WACA,OAAAd,EAAAe,QAAA,SAAAZ,GACA,OAAAS,EAAAV,EAAAC,QAESW,KAAA,WACT,OAAAF,EAAA,CACAR,KAAAH,EAAA9B,wBAES2C,KAAA,WACT,OAAAF,EAAAN,EAAA,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QH,UAAU,qBAAqBI,QAASR,GAAhD,KAGU,cAAXhC,GACCqC,EAAAC,EAAAC,cAAA,UAAQH,UAAU,qBAAqBI,QAASP,GAAhD,cAxCqBQ,kBA0DjCxB,GAAIyB,aAAe,CACjBZ,QAAS,EACTC,MAAO,GACP/B,OAAQ,GACR4B,UAAW,kBAAM,GACjBI,YAAa,kBAAM,GACnBC,YAAa,kBAAM,IC9DrB,IAWMU,GAAY,CAChBf,UAAWlC,EAAQ3E,aACnBiH,YCjBK,WACL,MAAO,CACLvH,KAAMH,EACNI,QAASkI,IAAeC,WDe1BZ,YCXK,WACL,MAAO,CACLxH,KAAMH,EACNI,QAASkI,IAAeC,YDYb3H,eAlBE,SAACV,GAAU,IAClBwF,EAAkBxF,EAAlBwF,OAAQH,EAAUrF,EAAVqF,MAIhB,OAHAM,QAAQC,IAAI,SAAUJ,GACtBG,QAAQC,IAAI,QAASP,GACrBM,QAAQC,IAAI,QAAS5F,GACdqG,OAAAiC,EAAA,EAAAjC,CAAA,CACLb,UACGH,IAW0B8C,GAAlBzH,CAA6B6H,IEVtClD,GAAQS,EAHEO,OAAOmC,KAAK1I,IAI5B2I,iBACEZ,EAAAC,EAAAC,cAACW,EAAA,EAAD,CAAUrD,MAAOA,IACfwC,EAAAC,EAAAC,cAACY,GAAD,OAEFC,SAASC,eAAe","file":"static/js/main.a183410a.chunk.js","sourcesContent":["export var BLUETOOTH_CONNECTING = '@@bluetooth/CONNECTING';\nexport var BLUETOOTH_CONNECTED = '@@bluetooth/CONNECTED';\nexport var BLUETOOTH_DISCONNECTING = '@@bluetooth/DISCONNECTING';\nexport var BLUETOOTH_DISCONNECTED = '@@bluetooth/DISCONNECTED';\nexport var BLUETOOTH_ERROR = '@@bluetooth/ERROR';\nexport var BLUETOOTH_READ = '@@bluetooth/READ';\nexport var BLUETOOTH_SYNC = '@@bluetooth/SYNC';\nexport var BLUETOOTH_SEND = '@@bluetooth/SEND';\nexport var BLUETOOTH_CONNECT_REQUEST = '@@bluetooth/CONNECT_REQUEST';\nexport var BLUETOOTH_DISCONNECT_REQUEST = '@@bluetooth/DISCONNECT_REQUEST';\nexport var BLUETOOTH_SEND_REQUEST = '@@bluetooth/SEND_REQUEST';\nexport var BLUETOOTH_SYNC_REQUEST = '@@bluetooth/SYNC_REQUEST';","export var INIT = 'INIT';\nexport var DISCONNECTED = 'DISCONNECTED';\nexport var DISCONNECTING = 'DISCONNECTING';\nexport var CONNECTING = 'CONNECTING';\nexport var CONNECTED = 'CONNECTED';\nexport var ERROR = 'ERROR';","var CONFIG = {\n SERVICE_UUID: '13333333-3333-3333-3333-333333333337',\n CHARACTERISTIC_UUID: '13333333-3333-3333-3333-333333330001'\n};\nexport var CENTRAL_CONFIG = CONFIG;\nexport var BLENO_CONFIG = {\n SERVICE_UUID: CONFIG.SERVICE_UUID.replace(/-/g, ''),\n CHARACTERISTIC_UUID: CONFIG.CHARACTERISTIC_UUID.replace(/-/g, ''),\n DESCRIPTOR_UUID: '2901'\n};\nexport var COMMON_TYPES = {\n BLUETOOTH_SYNC_REQUEST: '@@bluetooth/SYNC_REQUEST'\n};","/* global window */\nimport { CENTRAL_CONFIG } from '../../common/config';\nimport Encoder from '../../common/encoder';\nimport Central from './central';\nvar _window = window,\n navigator = _window.navigator,\n TextDecoder = _window.TextDecoder,\n TextEncoder = _window.TextEncoder;\nexport default new Central(\"\".concat(Date.now()).slice(4, 13), // Client ID\nnavigator.bluetooth, Encoder({\n TextEncoder: TextEncoder,\n TextDecoder: TextDecoder\n}), CENTRAL_CONFIG);","import central from '../central';\nimport * as TYPES from './types';\nimport Actions from './actions';\nexport default Actions(central, TYPES);","export default function Actions(central, TYPES) {\n var syncState = function syncState(state) {\n return {\n type: TYPES.BLUETOOTH_SYNC,\n payload: state\n };\n };\n\n var sendAction = function sendAction(action) {\n return {\n type: TYPES.BLUETOOTH_SEND_REQUEST,\n request: function request() {\n return central.write(action);\n }\n };\n };\n\n var connectStore = function connectStore(name) {\n return {\n type: TYPES.BLUETOOTH_CONNECT_REQUEST,\n request: function request(dispatch) {\n dispatch({\n type: TYPES.BLUETOOTH_CONNECTING\n });\n return central.connect(name).then(function () {\n return central.handler(function (state) {\n return dispatch(syncState(state));\n });\n }).then(function () {\n return dispatch({\n type: TYPES.BLUETOOTH_CONNECTED\n });\n }).then(function () {\n return dispatch(sendAction({\n type: TYPES.BLUETOOTH_SEND_REQUEST,\n request: function request() {\n return central.write({\n type: TYPES.BLUETOOTH_SYNC_REQUEST\n });\n }\n }));\n });\n }\n };\n };\n\n var disconnectStore = function disconnectStore() {\n return {\n type: TYPES.BLUETOOTH_DISCONNECT_REQUEST,\n request: function request(dispatch) {\n dispatch({\n type: TYPES.BLUETOOTH_DISCONNECTING\n });\n central.disconnect();\n dispatch({\n type: TYPES.BLUETOOTH_DISCONNECTED\n });\n }\n };\n };\n\n return {\n connectStore: connectStore,\n disconnectStore: disconnectStore,\n syncState: syncState,\n sendAction: sendAction\n };\n}","export default function Central(id, bluetooth, _ref, _ref2) {\n var encode = _ref.encode,\n decode = _ref.decode;\n var SERVICE_UUID = _ref2.SERVICE_UUID,\n CHARACTERISTIC_UUID = _ref2.CHARACTERISTIC_UUID;\n var state = {\n server: null,\n characteristic: null,\n message: '',\n configuration: {\n limit: 20 // HARDCODE: https://devzone.nordicsemi.com/question/3860/largest-allowed-setting-for-variable-length-characteristic/\n\n },\n id: id\n };\n\n var isConnected = function isConnected() {\n return state.server && state.server.connected;\n };\n\n var connect = function connect(name) {\n return bluetooth.requestDevice({\n filters: [{\n services: [SERVICE_UUID],\n name: name\n }]\n }).then(function (device) {\n state.device = device;\n return device.gatt.connect();\n }).then(function (server) {\n state.server = server;\n return server.getPrimaryService(SERVICE_UUID);\n }).then(function (service) {\n return service.getCharacteristic(CHARACTERISTIC_UUID);\n }).then(function (characteristic) {\n state.characteristic = characteristic;\n });\n };\n\n var disconnect = function disconnect() {\n if (isConnected()) {\n state.device.gatt.disconnect();\n }\n };\n\n var listener = function listener(callback) {\n return function (event) {\n var chunk = decode(event.target.value);\n var message = \"\".concat(state.message).concat(chunk);\n\n if (message.startsWith('[[[') && message.endsWith(']]]')) {\n var json = JSON.parse(message.slice(3, message.length - 3));\n callback(json);\n state.message = '';\n } else if (message.startsWith('|||') && message.endsWith('|||')) {\n state.message = '';\n } else {\n state.message = message;\n }\n\n return state.message;\n };\n };\n\n var handler = function handler(callback) {\n return state.characteristic.startNotifications().then(function () {\n var eventListener = listener(callback);\n state.characteristic.addEventListener('characteristicvaluechanged', eventListener);\n return state.configuration;\n });\n };\n\n var write = function write(action) {\n if (!state.server || !state.server.connected || !state.characteristic) return Promise.reject();\n var stringify = \"[[[\".concat(JSON.stringify(action), \"]]]\");\n var message = encode(stringify);\n var key = encode(\"\".concat(state.id, \":\"));\n var dataSize = state.configuration.limit - key.length;\n var writes = [];\n var i = 0;\n\n do {\n var next = i + dataSize;\n var end = Math.min(next, message.length);\n var data = message.slice(i, end);\n var buffer = new Uint8Array(key.length + data.length);\n buffer.set(key, 0);\n buffer.set(data, key.length);\n writes.push(buffer);\n i = next;\n } while (i < message.length); // Serialize Promises\n\n\n return writes.reduce(function (promise, chunk) {\n return promise.then(function () {\n return state.characteristic.writeValue(chunk);\n });\n }, Promise.resolve());\n };\n\n return {\n connected: isConnected(),\n connect: connect,\n disconnect: disconnect,\n handler: handler,\n write: write,\n listener: listener\n };\n}","export default function Encoder(_ref) {\n var TextEncoder = _ref.TextEncoder,\n TextDecoder = _ref.TextDecoder;\n var encoder = new TextEncoder('utf-8');\n var decoder = new TextDecoder('utf-8');\n\n var encode = function encode(string) {\n return encoder.encode(string);\n };\n\n var decode = function decode(data) {\n return decoder.decode(data);\n };\n\n return {\n encode: encode,\n decode: decode\n };\n}","import ACTIONS from '../actions';\nimport * as TYPES from '../actions/types';\nvar sendAction = ACTIONS.sendAction;\nvar BLUETOOTH_CONNECT_REQUEST = TYPES.BLUETOOTH_CONNECT_REQUEST,\n BLUETOOTH_DISCONNECT_REQUEST = TYPES.BLUETOOTH_DISCONNECT_REQUEST,\n BLUETOOTH_SEND_REQUEST = TYPES.BLUETOOTH_SEND_REQUEST;\nvar REQUESTS = [BLUETOOTH_CONNECT_REQUEST, BLUETOOTH_DISCONNECT_REQUEST, BLUETOOTH_SEND_REQUEST];\nexport default (function () {\n var actions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n return function (store) {\n return function (next) {\n return function (action) {\n if (typeof action !== 'object') {\n return next(action);\n }\n\n var type = action.type;\n if (REQUESTS.includes(type)) action.request(store.dispatch);\n if (actions.includes(type)) store.dispatch(sendAction(action));\n return next(action);\n };\n };\n };\n});","import * as STATUS from '../central/status';\nexport default {\n status: STATUS.INIT\n};","import * as TYPES from '../actions/types';\nimport * as STATUS from '../central/status';\nimport initial from './initial';\nexport function status() {\n var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initial.status;\n\n var _ref = arguments.length > 1 ? arguments[1] : undefined,\n type = _ref.type;\n\n switch (type) {\n case TYPES.BLUETOOTH_CONNECTING:\n return STATUS.CONNECTING;\n\n case TYPES.BLUETOOTH_CONNECTED:\n return STATUS.CONNECTED;\n\n case TYPES.BLUETOOTH_DISCONNECTING:\n return STATUS.DISCONNECTING;\n\n case TYPES.BLUETOOTH_DISCONNECTED:\n return STATUS.DISCONNECTED;\n\n default:\n return state;\n }\n}\nexport function remote() {\n var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n\n var _ref2 = arguments.length > 1 ? arguments[1] : undefined,\n type = _ref2.type,\n payload = _ref2.payload;\n\n console.log('remote: ', type, payload);\n\n switch (type) {\n case TYPES.BLUETOOTH_SYNC:\n return payload;\n\n default:\n return state;\n }\n}","import * as TYPES from './actions/types';\nimport * as STATUS from './central/status';\nimport ACTIONS from './actions';\nimport MIDDLEWARE from './middleware';\nimport * as REDUCERS from './reducers';\nimport STORE from './store';\nvar connectStore = ACTIONS.connectStore,\n disconnectStore = ACTIONS.disconnectStore;\nexport var types = TYPES;\nexport var status = STATUS;\nexport var actions = {\n connectStore: connectStore,\n disconnectStore: disconnectStore\n};\nexport var reducers = REDUCERS;\nexport var middleware = MIDDLEWARE;\nexport var createSyncStore = STORE;","/* global window */\nimport { createStore, combineReducers, applyMiddleware, compose } from 'redux';\nimport middleware from '../middleware';\nimport { status, remote } from '../reducers';\nexport default (function (actions) {\n var reducer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {\n return true;\n };\n var middlewares = [middleware(actions)];\n var enhancers = [applyMiddleware.apply(void 0, middlewares)];\n /* eslint-disable no-underscore-dangle */\n\n if (typeof window === 'object' && window.__REDUX_DEVTOOLS_EXTENSION__) {\n enhancers.push(window.__REDUX_DEVTOOLS_EXTENSION__());\n }\n /* eslint-enable */\n\n\n return createStore(combineReducers({\n status: status,\n remote: remote,\n local: reducer\n }), compose.apply(void 0, enhancers));\n});","export const INCREMENT = 'INCREMENT';\nexport const DECREMENT = 'DECREMENT';\n","import React, { PureComponent } from 'react';\nimport PropTypes from 'prop-types';\n\nimport './style.css';\n\nexport default class App extends PureComponent {\n constructor(props) {\n super(props);\n\n this.handlerConnect = this.handlerConnect.bind(this);\n }\n\n handlerConnect() {\n const { onConnect } = this.props;\n onConnect('Counter');\n }\n\n render() {\n const { counter, quote, status, onIncrement, onDecrement } = this.props;\n\n const nCounter = Number(counter);\n let className = 'app-counter';\n if (nCounter > 0) className += ' app-counter--positive';\n if (nCounter < 0) className += ' app-counter--negative';\n\n return (\n
\n {status === 'CONNECTED' &&\n
\n {counter}\n
\n version: 6\n
\n {quote}\n
}\n
\n {status !== 'CONNECTED' &&\n }\n {status === 'CONNECTED' &&\n }\n {status === 'CONNECTED' &&\n }\n
\n
\n );\n }\n}\n\nApp.propTypes = {\n counter: PropTypes.number,\n quote: PropTypes.string,\n status: PropTypes.string,\n onConnect: PropTypes.func,\n onIncrement: PropTypes.func,\n onDecrement: PropTypes.func,\n};\n\nApp.defaultProps = {\n counter: 0,\n quote: '',\n status: '',\n onConnect: () => true,\n onIncrement: () => true,\n onDecrement: () => true,\n};\n","import { connect } from 'react-redux';\nimport { actions } from 'redux-bluetooth/src/webapp';\n\nimport { increment, decrement } from '../actions';\n\nimport Component from './component';\n\nconst mapState = (state) => {\n const { status, store } = state;\n console.log('status', status);\n console.log('store', store);\n console.log('state', state);\n return ({\n status,\n ...store,\n });\n};\n\nconst mapAction = {\n onConnect: actions.connectStore,\n onIncrement: increment,\n onDecrement: decrement,\n};\n\nexport { Component };\nexport default connect(mapState, mapAction)(Component);\n","import predatorQuotes from 'predator-quotes';\nimport * as TYPES from './types';\n\nexport function increment() {\n return {\n type: TYPES.INCREMENT,\n payload: predatorQuotes.random(),\n };\n}\n\nexport function decrement() {\n return {\n type: TYPES.DECREMENT,\n payload: predatorQuotes.random(),\n };\n}\n","/* global document */\nimport React from 'react';\nimport { render } from 'react-dom';\nimport { Provider } from 'react-redux';\n\nimport { createSyncStore } from 'redux-bluetooth/src/webapp';\n\nimport './index.css';\nimport * as TYPES from './actions/types';\n\nimport App from './app';\n\nconst ACTIONS = Object.keys(TYPES);\n\n/* eslint-disable react/jsx-filename-extension */\nconst store = createSyncStore(ACTIONS);\nrender(\n \n \n ,\n document.getElementById('root'),\n);\n/* eslint-enable */\n"],"sourceRoot":""} \ No newline at end of file diff --git a/static/js/main.a183410a.chunk.js b/static/js/main.fa05bdea.chunk.js similarity index 89% rename from static/js/main.a183410a.chunk.js rename to static/js/main.fa05bdea.chunk.js index d5427ea..5751281 100644 --- a/static/js/main.a183410a.chunk.js +++ b/static/js/main.fa05bdea.chunk.js @@ -1,2 +1,2 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[0],{101:function(t,e,n){t.exports=n(199)},194:function(t,e,n){},198:function(t,e,n){},199:function(t,e,n){"use strict";n.r(e);var r={};n.r(r),n.d(r,"BLUETOOTH_CONNECTING",function(){return l}),n.d(r,"BLUETOOTH_CONNECTED",function(){return T}),n.d(r,"BLUETOOTH_DISCONNECTING",function(){return N}),n.d(r,"BLUETOOTH_DISCONNECTED",function(){return d}),n.d(r,"BLUETOOTH_ERROR",function(){return O}),n.d(r,"BLUETOOTH_READ",function(){return C}),n.d(r,"BLUETOOTH_SYNC",function(){return f}),n.d(r,"BLUETOOTH_SEND",function(){return h}),n.d(r,"BLUETOOTH_CONNECT_REQUEST",function(){return p}),n.d(r,"BLUETOOTH_DISCONNECT_REQUEST",function(){return S}),n.d(r,"BLUETOOTH_SEND_REQUEST",function(){return _}),n.d(r,"BLUETOOTH_SYNC_REQUEST",function(){return v});var c={};n.r(c),n.d(c,"INIT",function(){return D}),n.d(c,"DISCONNECTED",function(){return I}),n.d(c,"DISCONNECTING",function(){return U}),n.d(c,"CONNECTING",function(){return m}),n.d(c,"CONNECTED",function(){return b}),n.d(c,"ERROR",function(){return R});var o={};n.r(o),n.d(o,"status",function(){return q}),n.d(o,"remote",function(){return x});var u={};n.r(u),n.d(u,"INCREMENT",function(){return P}),n.d(u,"DECREMENT",function(){return J});var a=n(4),i=n.n(a),E=n(89),s=n(34),l="@@bluetooth/CONNECTING",T="@@bluetooth/CONNECTED",N="@@bluetooth/DISCONNECTING",d="@@bluetooth/DISCONNECTED",O="@@bluetooth/ERROR",C="@@bluetooth/READ",f="@@bluetooth/SYNC",h="@@bluetooth/SEND",p="@@bluetooth/CONNECT_REQUEST",S="@@bluetooth/DISCONNECT_REQUEST",_="@@bluetooth/SEND_REQUEST",v="@@bluetooth/SYNC_REQUEST",D="INIT",I="DISCONNECTED",U="DISCONNECTING",m="CONNECTING",b="CONNECTED",R="ERROR",g={SERVICE_UUID:"13333333-3333-3333-3333-333333333337",CHARACTERISTIC_UUID:"13333333-3333-3333-3333-333333330001"},y=g;g.SERVICE_UUID.replace(/-/g,""),g.CHARACTERISTIC_UUID.replace(/-/g,"");var w=window,H=w.navigator,L=w.TextDecoder,B=w.TextEncoder;var j=function(t,e){var n=function(t){return{type:e.BLUETOOTH_SYNC,payload:t}},r=function(n){return{type:e.BLUETOOTH_SEND_REQUEST,request:function(){return t.write(n)}}};return{connectStore:function(c){return{type:e.BLUETOOTH_CONNECT_REQUEST,request:function(o){return o({type:e.BLUETOOTH_CONNECTING}),t.connect(c).then(function(){return t.handler(function(t){return o(n(t))})}).then(function(){return o({type:e.BLUETOOTH_CONNECTED})}).then(function(){return o(r({type:e.BLUETOOTH_SEND_REQUEST,request:function(){return t.write({type:e.BLUETOOTH_SYNC_REQUEST})}}))})}}},disconnectStore:function(){return{type:e.BLUETOOTH_DISCONNECT_REQUEST,request:function(n){n({type:e.BLUETOOTH_DISCONNECTING}),t.disconnect(),n({type:e.BLUETOOTH_DISCONNECTED})}}},syncState:n,sendAction:r}}(new function(t,e,n,r){var c=n.encode,o=n.decode,u=r.SERVICE_UUID,a=r.CHARACTERISTIC_UUID,i={server:null,characteristic:null,message:"",configuration:{limit:20},id:t},E=function(){return i.server&&i.server.connected},s=function(t){return function(e){var n=o(e.target.value),r="".concat(i.message).concat(n);if(r.startsWith("[[[")&&r.endsWith("]]]")){var c=JSON.parse(r.slice(3,r.length-3));t(c),i.message=""}else r.startsWith("|||")&&r.endsWith("|||")?i.message="":i.message=r;return i.message}};return{connected:E(),connect:function(t){return e.requestDevice({filters:[{services:[u],name:t}]}).then(function(t){return i.device=t,t.gatt.connect()}).then(function(t){return i.server=t,t.getPrimaryService(u)}).then(function(t){return t.getCharacteristic(a)}).then(function(t){i.characteristic=t})},disconnect:function(){E()&&i.device.gatt.disconnect()},handler:function(t){return i.characteristic.startNotifications().then(function(){var e=s(t);return i.characteristic.addEventListener("characteristicvaluechanged",e),i.configuration})},write:function(t){if(!i.server||!i.server.connected||!i.characteristic)return Promise.reject();var e="[[[".concat(JSON.stringify(t),"]]]"),n=c(e),r=c("".concat(i.id,":")),o=i.configuration.limit-r.length,u=[],a=0;do{var E=a+o,s=Math.min(E,n.length),l=n.slice(a,s),T=new Uint8Array(r.length+l.length);T.set(r,0),T.set(l,r.length),u.push(T),a=E}while(a0&&void 0!==arguments[0]?arguments[0]:[];return function(e){return function(n){return function(r){if("object"!==typeof r)return n(r);var c=r.type;return A.includes(c)&&r.request(e.dispatch),t.includes(c)&&e.dispatch(Q(r)),n(r)}}}},k={status:D};function q(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:k.status;switch((arguments.length>1?arguments[1]:void 0).type){case l:return m;case T:return b;case N:return U;case d:return I;default:return t}}function x(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1?arguments[1]:void 0,n=e.type,r=e.payload;switch(console.log("remote: ",n,r),n){case f:return r;default:return t}}var V=n(25),Y={connectStore:j.connectStore,disconnectStore:j.disconnectStore},M=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){return!0},n=[G(t)],r=[V.a.apply(void 0,n)];return"object"===typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__&&r.push(window.__REDUX_DEVTOOLS_EXTENSION__()),Object(V.d)(Object(V.b)({status:q,remote:x,local:e}),V.c.apply(void 0,r))},P=(n(194),"INCREMENT"),J="DECREMENT",W=n(98),X=n(55),z=n.n(X);var F=n(95),K=n(96),Z=n(99),$=n(97),tt=n(100),et=n(24),nt=(n(198),function(t){function e(t){var n;return Object(F.a)(this,e),(n=Object(Z.a)(this,Object($.a)(e).call(this,t))).handlerConnect=n.handlerConnect.bind(Object(et.a)(Object(et.a)(n))),n}return Object(tt.a)(e,t),Object(K.a)(e,[{key:"handlerConnect",value:function(){(0,this.props.onConnect)("Counter")}},{key:"render",value:function(){var t=this.props,e=t.counter,n=t.quote,r=t.status,c=t.onIncrement,o=t.onDecrement,u=Number(e),a="app-counter";return u>0&&(a+=" app-counter--positive"),u<0&&(a+=" app-counter--negative"),i.a.createElement("div",{className:"app"},"CONNECTED"===r&&i.a.createElement("div",null,i.a.createElement("span",{className:a},e),i.a.createElement("br",null),i.a.createElement("span",null,"version: 6"),i.a.createElement("br",null),i.a.createElement("span",null,n)),i.a.createElement("div",{className:"app-actions"},"CONNECTED"!==r&&i.a.createElement("button",{className:"app-actions__buton",onClick:this.handlerConnect},"Connect"),"CONNECTED"===r&&i.a.createElement("button",{className:"app-actions__buton",onClick:c},"+"),"CONNECTED"===r&&i.a.createElement("button",{className:"app-actions__buton",onClick:o},"-")))}}]),e}(a.PureComponent));nt.defaultProps={counter:0,quote:"",status:"",onConnect:function(){return!0},onIncrement:function(){return!0},onDecrement:function(){return!0}};var rt={onConnect:Y.connectStore,onIncrement:function(){return{type:P,payload:z.a.random()}},onDecrement:function(){return{type:J,payload:z.a.random()}}},ct=Object(s.b)(function(t){var e=t.status,n=t.store;return console.log("status",e),console.log("store",n),console.log("state",t),Object(W.a)({status:e},n)},rt)(nt),ot=M(Object.keys(u));Object(E.render)(i.a.createElement(s.a,{store:ot},i.a.createElement(ct,null)),document.getElementById("root"))}},[[101,1,2]]]); -//# sourceMappingURL=main.a183410a.chunk.js.map \ No newline at end of file +(window.webpackJsonp=window.webpackJsonp||[]).push([[0],{101:function(t,e,n){t.exports=n(199)},194:function(t,e,n){},198:function(t,e,n){},199:function(t,e,n){"use strict";n.r(e);var r={};n.r(r),n.d(r,"BLUETOOTH_CONNECTING",function(){return T}),n.d(r,"BLUETOOTH_CONNECTED",function(){return l}),n.d(r,"BLUETOOTH_DISCONNECTING",function(){return N}),n.d(r,"BLUETOOTH_DISCONNECTED",function(){return d}),n.d(r,"BLUETOOTH_ERROR",function(){return O}),n.d(r,"BLUETOOTH_READ",function(){return C}),n.d(r,"BLUETOOTH_SYNC",function(){return f}),n.d(r,"BLUETOOTH_SEND",function(){return h}),n.d(r,"BLUETOOTH_CONNECT_REQUEST",function(){return p}),n.d(r,"BLUETOOTH_DISCONNECT_REQUEST",function(){return S}),n.d(r,"BLUETOOTH_SEND_REQUEST",function(){return _}),n.d(r,"BLUETOOTH_SYNC_REQUEST",function(){return v});var c={};n.r(c),n.d(c,"INIT",function(){return D}),n.d(c,"DISCONNECTED",function(){return I}),n.d(c,"DISCONNECTING",function(){return U}),n.d(c,"CONNECTING",function(){return m}),n.d(c,"CONNECTED",function(){return b}),n.d(c,"ERROR",function(){return R});var o={};n.r(o),n.d(o,"status",function(){return q}),n.d(o,"remote",function(){return x});var u={};n.r(u),n.d(u,"INCREMENT",function(){return P}),n.d(u,"DECREMENT",function(){return J});var a=n(4),i=n.n(a),E=n(89),s=n(34),T="@@bluetooth/CONNECTING",l="@@bluetooth/CONNECTED",N="@@bluetooth/DISCONNECTING",d="@@bluetooth/DISCONNECTED",O="@@bluetooth/ERROR",C="@@bluetooth/READ",f="@@bluetooth/SYNC",h="@@bluetooth/SEND",p="@@bluetooth/CONNECT_REQUEST",S="@@bluetooth/DISCONNECT_REQUEST",_="@@bluetooth/SEND_REQUEST",v="@@bluetooth/SYNC_REQUEST",D="INIT",I="DISCONNECTED",U="DISCONNECTING",m="CONNECTING",b="CONNECTED",R="ERROR",g={SERVICE_UUID:"13333333-3333-3333-3333-333333333337",CHARACTERISTIC_UUID:"13333333-3333-3333-3333-333333330001"},y=g;g.SERVICE_UUID.replace(/-/g,""),g.CHARACTERISTIC_UUID.replace(/-/g,"");var w=window,H=w.navigator,L=w.TextDecoder,B=w.TextEncoder;var j=function(t,e){var n=function(t){return{type:e.BLUETOOTH_SYNC,payload:t}},r=function(n){return{type:e.BLUETOOTH_SEND_REQUEST,request:function(){return t.write(n)}}};return{connectStore:function(c){return{type:e.BLUETOOTH_CONNECT_REQUEST,request:function(o){return o({type:e.BLUETOOTH_CONNECTING}),t.connect(c).then(function(){return t.handler(function(t){return o(n(t))})}).then(function(){return o({type:e.BLUETOOTH_CONNECTED})}).then(function(){return o(r({type:e.BLUETOOTH_SEND_REQUEST,request:function(){return t.write({type:e.BLUETOOTH_SYNC_REQUEST})}}))})}}},disconnectStore:function(){return{type:e.BLUETOOTH_DISCONNECT_REQUEST,request:function(n){n({type:e.BLUETOOTH_DISCONNECTING}),t.disconnect(),n({type:e.BLUETOOTH_DISCONNECTED})}}},syncState:n,sendAction:r}}(new function(t,e,n,r){var c=n.encode,o=n.decode,u=r.SERVICE_UUID,a=r.CHARACTERISTIC_UUID,i={server:null,characteristic:null,message:"",configuration:{limit:20},id:t},E=function(){return i.server&&i.server.connected},s=function(t){return function(e){var n=o(e.target.value),r="".concat(i.message).concat(n);if(r.startsWith("[[[")&&r.endsWith("]]]")){var c=JSON.parse(r.slice(3,r.length-3));t(c),i.message=""}else r.startsWith("|||")&&r.endsWith("|||")?i.message="":i.message=r;return i.message}};return{connected:E(),connect:function(t){return e.requestDevice({filters:[{services:[u],name:t}]}).then(function(t){return i.device=t,t.gatt.connect()}).then(function(t){return i.server=t,t.getPrimaryService(u)}).then(function(t){return t.getCharacteristic(a)}).then(function(t){i.characteristic=t})},disconnect:function(){E()&&i.device.gatt.disconnect()},handler:function(t){return i.characteristic.startNotifications().then(function(){var e=s(t);return i.characteristic.addEventListener("characteristicvaluechanged",e),i.configuration})},write:function(t){if(!i.server||!i.server.connected||!i.characteristic)return Promise.reject();var e="[[[".concat(JSON.stringify(t),"]]]"),n=c(e),r=c("".concat(i.id,":")),o=i.configuration.limit-r.length,u=[],a=0;do{var E=a+o,s=Math.min(E,n.length),T=n.slice(a,s),l=new Uint8Array(r.length+T.length);l.set(r,0),l.set(T,r.length),u.push(l),a=E}while(a0&&void 0!==arguments[0]?arguments[0]:[];return function(e){return function(n){return function(r){if("object"!==typeof r)return n(r);var c=r.type;return A.includes(c)&&r.request(e.dispatch),t.includes(c)&&e.dispatch(Q(r)),n(r)}}}},k={status:D};function q(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:k.status;switch((arguments.length>1?arguments[1]:void 0).type){case T:return m;case l:return b;case N:return U;case d:return I;default:return t}}function x(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1?arguments[1]:void 0,n=e.type,r=e.payload;switch(console.log("remote: ",n,r),n){case f:return r;default:return t}}var V=n(25),Y={connectStore:j.connectStore,disconnectStore:j.disconnectStore},M=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){return!0},n=[G(t)],r=[V.a.apply(void 0,n)];return"object"===typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__&&r.push(window.__REDUX_DEVTOOLS_EXTENSION__()),Object(V.d)(Object(V.b)({status:q,remote:x,local:e}),V.c.apply(void 0,r))},P=(n(194),"INCREMENT"),J="DECREMENT",W=n(98),X=n(55),z=n.n(X);var F=n(95),K=n(96),Z=n(99),$=n(97),tt=n(100),et=n(24),nt=(n(198),function(t){function e(t){var n;return Object(F.a)(this,e),(n=Object(Z.a)(this,Object($.a)(e).call(this,t))).handlerConnect=n.handlerConnect.bind(Object(et.a)(Object(et.a)(n))),n}return Object(tt.a)(e,t),Object(K.a)(e,[{key:"handlerConnect",value:function(){(0,this.props.onConnect)("Counter")}},{key:"render",value:function(){var t=this.props,e=t.counter,n=t.quote,r=t.status,c=t.onIncrement,o=t.onDecrement,u=Number(e),a="app-counter";return u>0&&(a+=" app-counter--positive"),u<0&&(a+=" app-counter--negative"),i.a.createElement("div",{className:"app"},"CONNECTED"===r&&i.a.createElement("div",null,i.a.createElement("span",{className:a},e),i.a.createElement("br",null),i.a.createElement("span",null,"version: 7"),i.a.createElement("br",null),i.a.createElement("span",null,n)),i.a.createElement("div",{className:"app-actions"},"CONNECTED"!==r&&i.a.createElement("button",{className:"app-actions__buton",onClick:this.handlerConnect},"Connect"),"CONNECTED"===r&&i.a.createElement("button",{className:"app-actions__buton",onClick:c},"+"),"CONNECTED"===r&&i.a.createElement("button",{className:"app-actions__buton",onClick:o},"-")))}}]),e}(a.PureComponent));nt.defaultProps={counter:0,quote:"",status:"",onConnect:function(){return!0},onIncrement:function(){return!0},onDecrement:function(){return!0}};var rt={onConnect:Y.connectStore,onIncrement:function(){return{type:P,payload:z.a.random()}},onDecrement:function(){return{type:J,payload:z.a.random()}}},ct=Object(s.b)(function(t){var e=t.status,n=t.remote;return Object(W.a)({status:e},n)},rt)(nt),ot=M(Object.keys(u));Object(E.render)(i.a.createElement(s.a,{store:ot},i.a.createElement(ct,null)),document.getElementById("root"))}},[[101,1,2]]]); +//# sourceMappingURL=main.fa05bdea.chunk.js.map \ No newline at end of file diff --git a/static/js/main.fa05bdea.chunk.js.map b/static/js/main.fa05bdea.chunk.js.map new file mode 100644 index 0000000..c2d36e2 --- /dev/null +++ b/static/js/main.fa05bdea.chunk.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../src/webapp/actions/types.js","../../../src/webapp/central/status.js","../../../src/common/config/index.js","../../../src/webapp/central/index.js","../../../src/webapp/actions/index.js","../../../src/webapp/actions/actions.js","../../../src/webapp/central/central.js","../../../src/common/encoder/index.js","../../../src/webapp/middleware/index.js","../../../src/webapp/reducers/initial.js","../../../src/webapp/reducers/index.js","../../../src/webapp/index.js","../../../src/webapp/store/index.js","actions/types.js","app/component.jsx","app/index.js","actions/index.js","index.js"],"names":["BLUETOOTH_CONNECTING","BLUETOOTH_CONNECTED","BLUETOOTH_DISCONNECTING","BLUETOOTH_DISCONNECTED","BLUETOOTH_ERROR","BLUETOOTH_READ","BLUETOOTH_SYNC","BLUETOOTH_SEND","BLUETOOTH_CONNECT_REQUEST","BLUETOOTH_DISCONNECT_REQUEST","BLUETOOTH_SEND_REQUEST","BLUETOOTH_SYNC_REQUEST","INIT","DISCONNECTED","DISCONNECTING","CONNECTING","CONNECTED","ERROR","CONFIG","SERVICE_UUID","CHARACTERISTIC_UUID","CENTRAL_CONFIG","replace","_window","window","central_navigator","navigator","TextDecoder","TextEncoder","webapp_actions","central","TYPES","syncState","state","type","payload","sendAction","action","request","write","connectStore","name","dispatch","connect","then","handler","disconnectStore","disconnect","id","bluetooth","_ref","_ref2","encode","decode","server","characteristic","message","configuration","limit","isConnected","connected","listener","callback","event","chunk","target","value","concat","startsWith","endsWith","json","JSON","parse","slice","length","requestDevice","filters","services","device","gatt","getPrimaryService","service","getCharacteristic","startNotifications","eventListener","addEventListener","Promise","reject","stringify","key","dataSize","writes","i","next","end","Math","min","data","buffer","Uint8Array","set","push","reduce","promise","writeValue","resolve","Date","now","encoder","decoder","string","Encoder","types_namespaceObject","REQUESTS","middleware","actions","arguments","undefined","store","includes","initial","status","reducers_status","reducers_remote","console","log","src_webapp_actions","createSyncStore","reducer","middlewares","enhancers","redux_es","apply","__REDUX_DEVTOOLS_EXTENSION__","Object","remote","local","INCREMENT","DECREMENT","App","props","_this","classCallCheck","this","possibleConstructorReturn","getPrototypeOf","call","handlerConnect","bind","assertThisInitialized","onConnect","_this$props","counter","quote","onIncrement","onDecrement","nCounter","Number","className","react_default","a","createElement","onClick","PureComponent","defaultProps","mapAction","predatorQuotes","random","objectSpread","Component","keys","render","es","app","document","getElementById"],"mappings":"kwCAAOA,EAAA,yBACAC,EAAA,wBACAC,EAAA,4BACAC,EAAA,2BACAC,EAAA,oBACAC,EAAA,mBACAC,EAAA,mBACAC,EAAA,mBACAC,EAAA,8BACAC,EAAA,iCACAC,EAAA,2BACAC,EAAA,2BCXAC,EAAA,OACAC,EAAA,eACAC,EAAA,gBACAC,EAAA,aACAC,EAAA,YACAC,EAAA,QCLPC,EAAA,CACAC,aAAA,uCACAC,oBAAA,wCAEOC,EAAAH,EAEPA,EAAAC,aAAAG,QAAA,SACAJ,EAAAE,oBAAAE,QAAA,SCHA,IAAAC,EAAAC,OACIC,EAASF,EAAAG,UACbC,EAAAJ,EAAAI,YACAC,EAAAL,EAAAK,YCJe,IAAAC,ECHA,SAAAC,EAAAC,GACf,IAAAC,EAAA,SAAAC,GACA,OACAC,KAAAH,EAAAzB,eACA6B,QAAAF,IAIAG,EAAA,SAAAC,GACA,OACAH,KAAAH,EAAArB,uBACA4B,QAAA,WACA,OAAAR,EAAAS,MAAAF,MAiDA,OACAG,aA7CA,SAAAC,GACA,OACAP,KAAAH,EAAAvB,0BACA8B,QAAA,SAAAI,GAIA,OAHAA,EAAA,CACAR,KAAAH,EAAA/B,uBAEA8B,EAAAa,QAAAF,GAAAG,KAAA,WACA,OAAAd,EAAAe,QAAA,SAAAZ,GACA,OAAAS,EAAAV,EAAAC,QAESW,KAAA,WACT,OAAAF,EAAA,CACAR,KAAAH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AArD,WAGU,cAAX1B,GACCsC,EAAAC,EAAAC,cAAA,UAAQH,UAAU,qBAAqBI,QAASR,GAAhD,KAGU,cAAXjC,GACCsC,EAAAC,EAAAC,cAAA,UAAQH,UAAU,qBAAqBI,QAASP,GAAhD,cAxCqBQ,kBA0DjCxB,GAAIyB,aAAe,CACjBZ,QAAS,EACTC,MAAO,GACPhC,OAAQ,GACR6B,UAAW,kBAAM,GACjBI,YAAa,kBAAM,GACnBC,YAAa,kBAAM,IC9DrB,IAQMU,GAAY,CAChBf,UAAWnC,EAAQ3E,aACnBkH,YCdK,WACL,MAAO,CACLxH,KAAMH,EACNI,QAASmI,IAAeC,WDY1BZ,YCRK,WACL,MAAO,CACLzH,KAAMH,EACNI,QAASmI,IAAeC,YDSb5H,eAfE,SAACV,GAAU,IAClBwF,EAAmBxF,EAAnBwF,OAAQc,EAAWtG,EAAXsG,OAChB,OAAOD,OAAAkC,EAAA,EAAAlC,CAAA,CACLb,UACGc,IAW0B8B,GAAlB1H,CAA6B8H,IEPtCnD,GAAQS,EAHEO,OAAOoC,KAAK3I,IAI5B4I,iBACEZ,EAAAC,EAAAC,cAACW,EAAA,EAAD,CAAUtD,MAAOA,IACfyC,EAAAC,EAAAC,cAACY,GAAD,OAEFC,SAASC,eAAe","file":"static/js/main.fa05bdea.chunk.js","sourcesContent":["export var BLUETOOTH_CONNECTING = '@@bluetooth/CONNECTING';\nexport var BLUETOOTH_CONNECTED = '@@bluetooth/CONNECTED';\nexport var BLUETOOTH_DISCONNECTING = '@@bluetooth/DISCONNECTING';\nexport var BLUETOOTH_DISCONNECTED = '@@bluetooth/DISCONNECTED';\nexport var BLUETOOTH_ERROR = '@@bluetooth/ERROR';\nexport var BLUETOOTH_READ = '@@bluetooth/READ';\nexport var BLUETOOTH_SYNC = '@@bluetooth/SYNC';\nexport var BLUETOOTH_SEND = '@@bluetooth/SEND';\nexport var BLUETOOTH_CONNECT_REQUEST = '@@bluetooth/CONNECT_REQUEST';\nexport var BLUETOOTH_DISCONNECT_REQUEST = '@@bluetooth/DISCONNECT_REQUEST';\nexport var BLUETOOTH_SEND_REQUEST = '@@bluetooth/SEND_REQUEST';\nexport var BLUETOOTH_SYNC_REQUEST = '@@bluetooth/SYNC_REQUEST';","export var INIT = 'INIT';\nexport var DISCONNECTED = 'DISCONNECTED';\nexport var DISCONNECTING = 'DISCONNECTING';\nexport var CONNECTING = 'CONNECTING';\nexport var CONNECTED = 'CONNECTED';\nexport var ERROR = 'ERROR';","var CONFIG = {\n SERVICE_UUID: '13333333-3333-3333-3333-333333333337',\n CHARACTERISTIC_UUID: '13333333-3333-3333-3333-333333330001'\n};\nexport var CENTRAL_CONFIG = CONFIG;\nexport var BLENO_CONFIG = {\n SERVICE_UUID: CONFIG.SERVICE_UUID.replace(/-/g, ''),\n CHARACTERISTIC_UUID: CONFIG.CHARACTERISTIC_UUID.replace(/-/g, ''),\n DESCRIPTOR_UUID: '2901'\n};\nexport var COMMON_TYPES = {\n BLUETOOTH_SYNC_REQUEST: '@@bluetooth/SYNC_REQUEST'\n};","/* global window */\nimport { CENTRAL_CONFIG } from '../../common/config';\nimport Encoder from '../../common/encoder';\nimport Central from './central';\nvar _window = window,\n navigator = _window.navigator,\n TextDecoder = _window.TextDecoder,\n TextEncoder = _window.TextEncoder;\nexport default new Central(\"\".concat(Date.now()).slice(4, 13), // Client ID\nnavigator.bluetooth, Encoder({\n TextEncoder: TextEncoder,\n TextDecoder: TextDecoder\n}), CENTRAL_CONFIG);","import central from '../central';\nimport * as TYPES from './types';\nimport Actions from './actions';\nexport default Actions(central, TYPES);","export default function Actions(central, TYPES) {\n var syncState = function syncState(state) {\n return {\n type: TYPES.BLUETOOTH_SYNC,\n payload: state\n };\n };\n\n var sendAction = function sendAction(action) {\n return {\n type: TYPES.BLUETOOTH_SEND_REQUEST,\n request: function request() {\n return central.write(action);\n }\n };\n };\n\n var connectStore = function connectStore(name) {\n return {\n type: TYPES.BLUETOOTH_CONNECT_REQUEST,\n request: function request(dispatch) {\n dispatch({\n type: TYPES.BLUETOOTH_CONNECTING\n });\n return central.connect(name).then(function () {\n return central.handler(function (state) {\n return dispatch(syncState(state));\n });\n }).then(function () {\n return dispatch({\n type: TYPES.BLUETOOTH_CONNECTED\n });\n }).then(function () {\n return dispatch(sendAction({\n type: TYPES.BLUETOOTH_SEND_REQUEST,\n request: function request() {\n return central.write({\n type: TYPES.BLUETOOTH_SYNC_REQUEST\n });\n }\n }));\n });\n }\n };\n };\n\n var disconnectStore = function disconnectStore() {\n return {\n type: TYPES.BLUETOOTH_DISCONNECT_REQUEST,\n request: function request(dispatch) {\n dispatch({\n type: TYPES.BLUETOOTH_DISCONNECTING\n });\n central.disconnect();\n dispatch({\n type: TYPES.BLUETOOTH_DISCONNECTED\n });\n }\n };\n };\n\n return {\n connectStore: connectStore,\n disconnectStore: disconnectStore,\n syncState: syncState,\n sendAction: sendAction\n };\n}","export default function Central(id, bluetooth, _ref, _ref2) {\n var encode = _ref.encode,\n decode = _ref.decode;\n var SERVICE_UUID = _ref2.SERVICE_UUID,\n CHARACTERISTIC_UUID = _ref2.CHARACTERISTIC_UUID;\n var state = {\n server: null,\n characteristic: null,\n message: '',\n configuration: {\n limit: 20 // HARDCODE: https://devzone.nordicsemi.com/question/3860/largest-allowed-setting-for-variable-length-characteristic/\n\n },\n id: id\n };\n\n var isConnected = function isConnected() {\n return state.server && state.server.connected;\n };\n\n var connect = function connect(name) {\n return bluetooth.requestDevice({\n filters: [{\n services: [SERVICE_UUID],\n name: name\n }]\n }).then(function (device) {\n state.device = device;\n return device.gatt.connect();\n }).then(function (server) {\n state.server = server;\n return server.getPrimaryService(SERVICE_UUID);\n }).then(function (service) {\n return service.getCharacteristic(CHARACTERISTIC_UUID);\n }).then(function (characteristic) {\n state.characteristic = characteristic;\n });\n };\n\n var disconnect = function disconnect() {\n if (isConnected()) {\n state.device.gatt.disconnect();\n }\n };\n\n var listener = function listener(callback) {\n return function (event) {\n var chunk = decode(event.target.value);\n var message = \"\".concat(state.message).concat(chunk);\n\n if (message.startsWith('[[[') && message.endsWith(']]]')) {\n var json = JSON.parse(message.slice(3, message.length - 3));\n callback(json);\n state.message = '';\n } else if (message.startsWith('|||') && message.endsWith('|||')) {\n state.message = '';\n } else {\n state.message = message;\n }\n\n return state.message;\n };\n };\n\n var handler = function handler(callback) {\n return state.characteristic.startNotifications().then(function () {\n var eventListener = listener(callback);\n state.characteristic.addEventListener('characteristicvaluechanged', eventListener);\n return state.configuration;\n });\n };\n\n var write = function write(action) {\n if (!state.server || !state.server.connected || !state.characteristic) return Promise.reject();\n var stringify = \"[[[\".concat(JSON.stringify(action), \"]]]\");\n var message = encode(stringify);\n var key = encode(\"\".concat(state.id, \":\"));\n var dataSize = state.configuration.limit - key.length;\n var writes = [];\n var i = 0;\n\n do {\n var next = i + dataSize;\n var end = Math.min(next, message.length);\n var data = message.slice(i, end);\n var buffer = new Uint8Array(key.length + data.length);\n buffer.set(key, 0);\n buffer.set(data, key.length);\n writes.push(buffer);\n i = next;\n } while (i < message.length); // Serialize Promises\n\n\n return writes.reduce(function (promise, chunk) {\n return promise.then(function () {\n return state.characteristic.writeValue(chunk);\n });\n }, Promise.resolve());\n };\n\n return {\n connected: isConnected(),\n connect: connect,\n disconnect: disconnect,\n handler: handler,\n write: write,\n listener: listener\n };\n}","export default function Encoder(_ref) {\n var TextEncoder = _ref.TextEncoder,\n TextDecoder = _ref.TextDecoder;\n var encoder = new TextEncoder('utf-8');\n var decoder = new TextDecoder('utf-8');\n\n var encode = function encode(string) {\n return encoder.encode(string);\n };\n\n var decode = function decode(data) {\n return decoder.decode(data);\n };\n\n return {\n encode: encode,\n decode: decode\n };\n}","import ACTIONS from '../actions';\nimport * as TYPES from '../actions/types';\nvar sendAction = ACTIONS.sendAction;\nvar BLUETOOTH_CONNECT_REQUEST = TYPES.BLUETOOTH_CONNECT_REQUEST,\n BLUETOOTH_DISCONNECT_REQUEST = TYPES.BLUETOOTH_DISCONNECT_REQUEST,\n BLUETOOTH_SEND_REQUEST = TYPES.BLUETOOTH_SEND_REQUEST;\nvar REQUESTS = [BLUETOOTH_CONNECT_REQUEST, BLUETOOTH_DISCONNECT_REQUEST, BLUETOOTH_SEND_REQUEST];\nexport default (function () {\n var actions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n return function (store) {\n return function (next) {\n return function (action) {\n if (typeof action !== 'object') {\n return next(action);\n }\n\n var type = action.type;\n if (REQUESTS.includes(type)) action.request(store.dispatch);\n if (actions.includes(type)) store.dispatch(sendAction(action));\n return next(action);\n };\n };\n };\n});","import * as STATUS from '../central/status';\nexport default {\n status: STATUS.INIT\n};","import * as TYPES from '../actions/types';\nimport * as STATUS from '../central/status';\nimport initial from './initial';\nexport function status() {\n var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initial.status;\n\n var _ref = arguments.length > 1 ? arguments[1] : undefined,\n type = _ref.type;\n\n switch (type) {\n case TYPES.BLUETOOTH_CONNECTING:\n return STATUS.CONNECTING;\n\n case TYPES.BLUETOOTH_CONNECTED:\n return STATUS.CONNECTED;\n\n case TYPES.BLUETOOTH_DISCONNECTING:\n return STATUS.DISCONNECTING;\n\n case TYPES.BLUETOOTH_DISCONNECTED:\n return STATUS.DISCONNECTED;\n\n default:\n return state;\n }\n}\nexport function remote() {\n var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n\n var _ref2 = arguments.length > 1 ? arguments[1] : undefined,\n type = _ref2.type,\n payload = _ref2.payload;\n\n console.log('remote: ', type, payload);\n\n switch (type) {\n case TYPES.BLUETOOTH_SYNC:\n return payload;\n\n default:\n return state;\n }\n}","import * as TYPES from './actions/types';\nimport * as STATUS from './central/status';\nimport ACTIONS from './actions';\nimport MIDDLEWARE from './middleware';\nimport * as REDUCERS from './reducers';\nimport STORE from './store';\nvar connectStore = ACTIONS.connectStore,\n disconnectStore = ACTIONS.disconnectStore;\nexport var types = TYPES;\nexport var status = STATUS;\nexport var actions = {\n connectStore: connectStore,\n disconnectStore: disconnectStore\n};\nexport var reducers = REDUCERS;\nexport var middleware = MIDDLEWARE;\nexport var createSyncStore = STORE;","/* global window */\nimport { createStore, combineReducers, applyMiddleware, compose } from 'redux';\nimport middleware from '../middleware';\nimport { status, remote } from '../reducers';\nexport default (function (actions) {\n var reducer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {\n return true;\n };\n var middlewares = [middleware(actions)];\n var enhancers = [applyMiddleware.apply(void 0, middlewares)];\n /* eslint-disable no-underscore-dangle */\n\n if (typeof window === 'object' && window.__REDUX_DEVTOOLS_EXTENSION__) {\n enhancers.push(window.__REDUX_DEVTOOLS_EXTENSION__());\n }\n /* eslint-enable */\n\n\n return createStore(combineReducers({\n status: status,\n remote: remote,\n local: reducer\n }), compose.apply(void 0, enhancers));\n});","export const INCREMENT = 'INCREMENT';\nexport const DECREMENT = 'DECREMENT';\n","import React, { PureComponent } from 'react';\nimport PropTypes from 'prop-types';\n\nimport './style.css';\n\nexport default class App extends PureComponent {\n constructor(props) {\n super(props);\n\n this.handlerConnect = this.handlerConnect.bind(this);\n }\n\n handlerConnect() {\n const { onConnect } = this.props;\n onConnect('Counter');\n }\n\n render() {\n const { counter, quote, status, onIncrement, onDecrement } = this.props;\n\n const nCounter = Number(counter);\n let className = 'app-counter';\n if (nCounter > 0) className += ' app-counter--positive';\n if (nCounter < 0) className += ' app-counter--negative';\n\n return (\n
\n {status === 'CONNECTED' &&\n
\n {counter}\n
\n version: 7\n
\n {quote}\n
}\n
\n {status !== 'CONNECTED' &&\n }\n {status === 'CONNECTED' &&\n }\n {status === 'CONNECTED' &&\n }\n
\n
\n );\n }\n}\n\nApp.propTypes = {\n counter: PropTypes.number,\n quote: PropTypes.string,\n status: PropTypes.string,\n onConnect: PropTypes.func,\n onIncrement: PropTypes.func,\n onDecrement: PropTypes.func,\n};\n\nApp.defaultProps = {\n counter: 0,\n quote: '',\n status: '',\n onConnect: () => true,\n onIncrement: () => true,\n onDecrement: () => true,\n};\n","import { connect } from 'react-redux';\nimport { actions } from 'redux-bluetooth/src/webapp';\n\nimport { increment, decrement } from '../actions';\n\nimport Component from './component';\n\nconst mapState = (state) => {\n const { status, remote } = state;\n return ({\n status,\n ...remote,\n });\n};\n\nconst mapAction = {\n onConnect: actions.connectStore,\n onIncrement: increment,\n onDecrement: decrement,\n};\n\nexport { Component };\nexport default connect(mapState, mapAction)(Component);\n","import predatorQuotes from 'predator-quotes';\nimport * as TYPES from './types';\n\nexport function increment() {\n return {\n type: TYPES.INCREMENT,\n payload: predatorQuotes.random(),\n };\n}\n\nexport function decrement() {\n return {\n type: TYPES.DECREMENT,\n payload: predatorQuotes.random(),\n };\n}\n","/* global document */\nimport React from 'react';\nimport { render } from 'react-dom';\nimport { Provider } from 'react-redux';\n\nimport { createSyncStore } from 'redux-bluetooth/src/webapp';\n\nimport './index.css';\nimport * as TYPES from './actions/types';\n\nimport App from './app';\n\nconst ACTIONS = Object.keys(TYPES);\n\n/* eslint-disable react/jsx-filename-extension */\nconst store = createSyncStore(ACTIONS);\nrender(\n \n \n ,\n document.getElementById('root'),\n);\n/* eslint-enable */\n"],"sourceRoot":""} \ No newline at end of file