@coinjinja/coinview-sdk
Advanced tools
Comparing version 1.0.12-dev to 1.0.13-dev
@@ -7,3 +7,3 @@ 'use strict'; | ||
var VERSION = '1.0.12'; | ||
var VERSION = '1.0.13'; | ||
@@ -96,2 +96,6 @@ var callbacks = {}; | ||
coinview.log = function () { | ||
return undefined; | ||
}; | ||
coinview.init = function (appId, debug, host) { | ||
@@ -104,2 +108,26 @@ if (_inited) { | ||
if (debug && host) { | ||
coinview.log = function (tag) { | ||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
return bridge.send('console', { | ||
tag: tag, | ||
args: args | ||
}); | ||
}; | ||
window.onerror = function (msg, url, line, col, error) { | ||
return bridge.send('error', { | ||
msg: msg, | ||
url: url, | ||
line: line, | ||
col: col, | ||
error: error, | ||
stack: error.stack | ||
}); | ||
}; | ||
} | ||
return bridge.init({ | ||
@@ -106,0 +134,0 @@ appId: appId, |
@@ -1,1 +0,1 @@ | ||
var coinview=function(){"use strict";for(var n,a=(function(n){var e="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(e){var r=new Uint8Array(16);n.exports=function(){return e(r),r}}else{var t=new Array(16);n.exports=function(){for(var n,e=0;e<16;e++)0==(3&e)&&(n=4294967296*Math.random()),t[e]=n>>>((3&e)<<3)&255;return t}}}(n={exports:{}},n.exports),n.exports),o=[],e=0;e<256;++e)o[e]=(e+256).toString(16).substr(1);var s=function(n,e){var r=e||0,t=o;return[t[n[r++]],t[n[r++]],t[n[r++]],t[n[r++]],"-",t[n[r++]],t[n[r++]],"-",t[n[r++]],t[n[r++]],"-",t[n[r++]],t[n[r++]],"-",t[n[r++]],t[n[r++]],t[n[r++]],t[n[r++]],t[n[r++]],t[n[r++]]].join("")};var u=function(n,e,r){var t=e&&r||0;"string"==typeof n&&(e="binary"===n?new Array(16):null,n=null);var o=(n=n||{}).random||(n.rng||a)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,e)for(var i=0;i<16;++i)e[t+i]=o[i];return e||s(o)},c={};function r(o,i){var a=0;return new Promise(function(r,t){function e(n,e){n?t(n):r(e)}!function n(){window.originalPostMessage?function(n,e,r){var t=u();c[t]=r;var o={method:n,uuid:t};e&&(o.payload=e),window.postMessage(JSON.stringify(o))}(o,i,e):3e3<a?t(new Error("Timeout")):(a+=10,setTimeout(n,10))}()})}function t(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(n){return console.error("Invalid data:",e)}if(e.uuid){var n=c[e.uuid];n?(n(e.error,e.payload),delete c[e.uuid]):console.warn("Unregistered callback:",e.uuid)}else console.error("Invalid data:",e)}var i={send:r,receive:t,init:function(n){return window.document.addEventListener("message",function(n){t(n.data)}),n.$version="1.0.12",n.$url=location.href,r("app.init",n)}},f={},l=null,d=!1;f.init=function(n,e,r){return d?new Promise(function(n,e){n(f)}):i.init({appId:n,debug:e,host:r}).then(function(n){return d=!0,l=n,f})},f.app=function(){if(!d)throw new Error('Please call after "coinview.init"');return new Promise(function(e,n){!function n(){l?e(l):setTimeout(n,10)}()})};var p=["user.profile","user.assets","user.address","user.signMessage","payment.create","navigate.back","navigate.close","navigate.openWallet","ui.notice","ui.confirm","utils.setClipboard","utils.screenshot","utils.share","utils.scanQR","utils._choosePhoto","utils._openUrl"];return p.forEach(function(e){var n=e.split("."),r=n[0],t=n[1];f[r]||(f[r]={}),f[r][t]=function(n){if(!d)throw new Error('Please call after "coinview.init"');return i.send(e,n)}}),f._methods=p,f}(); | ||
var coinview=function(){"use strict";for(var n,a=(function(n){var r="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(r){var e=new Uint8Array(16);n.exports=function(){return r(e),e}}else{var t=new Array(16);n.exports=function(){for(var n,r=0;r<16;r++)0==(3&r)&&(n=4294967296*Math.random()),t[r]=n>>>((3&r)<<3)&255;return t}}}(n={exports:{}},n.exports),n.exports),o=[],r=0;r<256;++r)o[r]=(r+256).toString(16).substr(1);var s=function(n,r){var e=r||0,t=o;return[t[n[e++]],t[n[e++]],t[n[e++]],t[n[e++]],"-",t[n[e++]],t[n[e++]],"-",t[n[e++]],t[n[e++]],"-",t[n[e++]],t[n[e++]],"-",t[n[e++]],t[n[e++]],t[n[e++]],t[n[e++]],t[n[e++]],t[n[e++]]].join("")};var u=function(n,r,e){var t=r&&e||0;"string"==typeof n&&(r="binary"===n?new Array(16):null,n=null);var o=(n=n||{}).random||(n.rng||a)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,r)for(var i=0;i<16;++i)r[t+i]=o[i];return r||s(o)},c={};function e(o,i){var a=0;return new Promise(function(e,t){function r(n,r){n?t(n):e(r)}!function n(){window.originalPostMessage?function(n,r,e){var t=u();c[t]=e;var o={method:n,uuid:t};r&&(o.payload=r),window.postMessage(JSON.stringify(o))}(o,i,r):3e3<a?t(new Error("Timeout")):(a+=10,setTimeout(n,10))}()})}function t(r){if("string"==typeof r)try{r=JSON.parse(r)}catch(n){return console.error("Invalid data:",r)}if(r.uuid){var n=c[r.uuid];n?(n(r.error,r.payload),delete c[r.uuid]):console.warn("Unregistered callback:",r.uuid)}else console.error("Invalid data:",r)}var i={send:e,receive:t,init:function(n){return window.document.addEventListener("message",function(n){t(n.data)}),n.$version="1.0.13",n.$url=location.href,e("app.init",n)}},l={},f=null,d=!1;l.log=function(){},l.init=function(n,r,e){return d?new Promise(function(n,r){n(l)}):(r&&e&&(l.log=function(n){for(var r=arguments.length,e=new Array(1<r?r-1:0),t=1;t<r;t++)e[t-1]=arguments[t];return i.send("console",{tag:n,args:e})},window.onerror=function(n,r,e,t,o){return i.send("error",{msg:n,url:r,line:e,col:t,error:o,stack:o.stack})}),i.init({appId:n,debug:r,host:e}).then(function(n){return d=!0,f=n,l}))},l.app=function(){if(!d)throw new Error('Please call after "coinview.init"');return new Promise(function(r,n){!function n(){f?r(f):setTimeout(n,10)}()})};var p=["user.profile","user.assets","user.address","user.signMessage","payment.create","navigate.back","navigate.close","navigate.openWallet","ui.notice","ui.confirm","utils.setClipboard","utils.screenshot","utils.share","utils.scanQR","utils._choosePhoto","utils._openUrl"];return p.forEach(function(r){var n=r.split("."),e=n[0],t=n[1];l[e]||(l[e]={}),l[e][t]=function(n){if(!d)throw new Error('Please call after "coinview.init"');return i.send(r,n)}}),l._methods=p,l}(); |
@@ -7,2 +7,4 @@ export as namespace Coinview | ||
export function log(): Promise<void> | ||
export namespace user { | ||
@@ -9,0 +11,0 @@ export function profile(): Promise<UserProfile> |
{ | ||
"name": "@coinjinja/coinview-sdk", | ||
"version": "1.0.12-dev", | ||
"version": "1.0.13-dev", | ||
"author": "coinjinja", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -1,1 +0,1 @@ | ||
export const VERSION = '1.0.12' | ||
export const VERSION = '1.0.13' |
@@ -8,2 +8,4 @@ import bridge from './_bridge' | ||
coinview.log = () => undefined | ||
coinview.init = function (appId, debug, host) { | ||
@@ -15,2 +17,13 @@ if (_inited) { | ||
} | ||
if (debug && host) { | ||
coinview.log = function (tag, ...args) { | ||
return bridge.send('console', { tag, args }) | ||
} | ||
window.onerror = function(msg, url, line, col, error) { | ||
return bridge.send('error', { | ||
msg, url, line, col, error, | ||
stack: error.stack, | ||
}) | ||
}; | ||
} | ||
return bridge.init({ appId, debug, host }).then(data => { | ||
@@ -17,0 +30,0 @@ _inited = true |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27024
474