Comparing version 0.0.9 to 0.0.10
38
index.js
@@ -24,2 +24,4 @@ var portalPostMessage; | ||
printReceipt: onPrintReceipt, | ||
getEventData: onGetEventData, | ||
setBarTitle: onSetBarTitle | ||
}; | ||
@@ -183,2 +185,36 @@ | ||
async function onGetEventData({ success, fail }) { | ||
await sleep(100); | ||
var eventData; | ||
switch (platform) { | ||
case PLATFORM_MOBILE_APP: | ||
eventData = window.revenuemonster.getEventData(); | ||
success({ eventData }) | ||
break; | ||
case PLATFORM_TERMINAL: | ||
eventData = window.Native.getEventData(); | ||
success({ eventData }); | ||
break; | ||
} | ||
} | ||
function onSetBarTitle({ title }) { | ||
switch (platform) { | ||
case PLATFORM_MOBILE_APP: | ||
window.ReactNativeWebView.postMessage( | ||
JSON.stringify({ | ||
action: 'NAVBAR_TITLE', | ||
message: title, | ||
}) | ||
); | ||
break; | ||
case PLATFORM_TERMINAL: | ||
window.Native.setBarTitle(title); | ||
break; | ||
} | ||
} | ||
export default { | ||
@@ -199,2 +235,4 @@ getSignedRequest: onPrepareSignedRequest, | ||
printReceipt: onPrintReceipt, | ||
getEventData: onGetEventData, | ||
setBarTitle: onSetBarTitle, | ||
PLATFORM_MOBILE_APP, | ||
@@ -201,0 +239,0 @@ PLATFORM_TERMINAL, |
@@ -30,3 +30,5 @@ "use strict"; | ||
showAlert: onShowAlert, | ||
printReceipt: onPrintReceipt | ||
printReceipt: onPrintReceipt, | ||
getEventData: onGetEventData, | ||
setBarTitle: onSetBarTitle | ||
}; // util for sleep | ||
@@ -273,2 +275,63 @@ | ||
function onGetEventData(_x3) { | ||
return _onGetEventData.apply(this, arguments); | ||
} | ||
function _onGetEventData() { | ||
_onGetEventData = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(_ref6) { | ||
var success, fail, eventData; | ||
return regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
success = _ref6.success, fail = _ref6.fail; | ||
_context3.next = 3; | ||
return sleep(100); | ||
case 3: | ||
_context3.t0 = platform; | ||
_context3.next = _context3.t0 === PLATFORM_MOBILE_APP ? 6 : _context3.t0 === PLATFORM_TERMINAL ? 9 : 12; | ||
break; | ||
case 6: | ||
eventData = window.revenuemonster.getEventData(); | ||
success({ | ||
eventData: eventData | ||
}); | ||
return _context3.abrupt("break", 12); | ||
case 9: | ||
eventData = window.Native.getEventData(); | ||
success({ | ||
eventData: eventData | ||
}); | ||
return _context3.abrupt("break", 12); | ||
case 12: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
} | ||
}, _callee3); | ||
})); | ||
return _onGetEventData.apply(this, arguments); | ||
} | ||
function onSetBarTitle(_ref7) { | ||
var title = _ref7.title; | ||
switch (platform) { | ||
case PLATFORM_MOBILE_APP: | ||
window.ReactNativeWebView.postMessage(JSON.stringify({ | ||
action: 'NAVBAR_TITLE', | ||
message: title | ||
})); | ||
break; | ||
case PLATFORM_TERMINAL: | ||
window.Native.setBarTitle(title); | ||
break; | ||
} | ||
} | ||
var _default = { | ||
@@ -289,2 +352,4 @@ getSignedRequest: onPrepareSignedRequest, | ||
printReceipt: onPrintReceipt, | ||
getEventData: onGetEventData, | ||
setBarTitle: onSetBarTitle, | ||
PLATFORM_MOBILE_APP: PLATFORM_MOBILE_APP, | ||
@@ -291,0 +356,0 @@ PLATFORM_TERMINAL: PLATFORM_TERMINAL, |
{ | ||
"name": "rm-plugin", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "", |
@@ -60,2 +60,8 @@ # RM Plugin SDK <img alt="npm" src="https://img.shields.io/npm/v/rm-plugin"> | ||
}) | ||
// show navbar title (only for terminal and merchant-app) | ||
rm.setBarTitle({ | ||
title: 'hello world' | ||
}) | ||
``` |
Sorry, the diff of this file is not supported yet
20646
514
66