Skip to content

Commit

Permalink
fix: update dependencies, fix some type problems
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdesu committed Aug 1, 2020
1 parent dc46f0d commit 1476d20
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 83 deletions.
133 changes: 85 additions & 48 deletions dist/abcwallet.umd.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/abcwallet.umd.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/abcwallet.umd.min.js.map

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "abcwallet",
"version": "1.4.0",
"version": "1.4.1",
"description": "The only and best SDK for ABCWallet application development.",
"repository": "https://github.com/BlockABC/abcwallet.js",
"license": "MIT",
Expand Down Expand Up @@ -38,10 +38,10 @@
"module": "./esm/index.js",
"browser": "./dist/abcwallet.umd.min.js",
"dependencies": {
"eventemitter3": "^4.0.0",
"eventemitter3": "^4.0.4",
"lodash-es": "^4.17.15",
"loglevel": "^1.6.3",
"ts-custom-error": "^3.0.0"
"loglevel": "^1.6.8",
"ts-custom-error": "^3.1.1"
},
"devDependencies": {
"@semantic-release/changelog": "^5.0.0",
Expand All @@ -60,7 +60,7 @@
"semantic-release": "^17.0.4",
"ts-jest": "^24.0.0",
"ts-loader": "^5.0.0",
"typescript": "^3.0.0",
"typescript": "^3.9.7",
"webpack": "^4.29.6",
"webpack-bundle-analyzer": "^3.3.2",
"webpack-cli": "^3.3.0",
Expand Down
59 changes: 36 additions & 23 deletions src/ABCWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import isFunction from 'lodash-es/isFunction'
import { Logger } from 'loglevel'
import * as EventEmitter from 'eventemitter3'

import { IRequest, IPromise, IChannel } from './interface'
import { IPromise, IChannel } from './interface'
import { isRequest } from './helper'
import api, { WebviewAPI, DappAPI, PrivateAPI, BTCAPI, BCHAPI, ETHAPI, EOSAPI, ABCIDAPI, PartnerAPI, BrowserAPI } from './api'
import { NativeChannel, IframeChannel } from './channel'
Expand Down Expand Up @@ -51,12 +51,12 @@ export class ABCWallet extends EventEmitter {

this._timer = setInterval((): void => {
const now = (new Date()).getTime()
for (const [, promise] of this._promises) {
this._promises.forEach((promise) => {
const duration = now - promise.createdAt.getTime()
if (duration > 3600 * 1000) {
this.log.warn('ABCWallet.response take too long(more than 5000ms):', promise.path)
}
}
})
}, 1000)
}

Expand Down Expand Up @@ -166,13 +166,43 @@ export class ABCWallet extends EventEmitter {

get clientVersion (): string {
// todo 某个版本的 iOS 的 UA 设置了两次,后面一次是对的,所以这里做了一下兼容,后面择机去掉兼容
const matches: any = window.navigator.userAgent.match(/ABCWallet\/([a-zA-Z-_]+)/g) // 形如 Language/zh-CN
const splitParts: any = matches && matches[matches.length - 1] && matches[matches.length - 1].split('/')
const version = splitParts && splitParts[1]
const matches = window.navigator.userAgent.match(/ABCWallet\/([a-zA-Z-_]+)/g) // 形如 Language/zh-CN
const splitParts = matches && matches[matches.length - 1] && matches[matches.length - 1].split('/')

let version = ''
if (splitParts[1]) {
version = splitParts[1]
}

return version
}

get clientLanguage (): string {
// todo 某个版本的 iOS 的 UA 设置了两次,后面一次是对的,所以这里做了一下兼容,后面择机去掉兼容
const matches: any = window.navigator.userAgent.match(/Language\/([a-zA-Z-_]+)/g) // 形如 Language/zh-CN
const splitParts: any = matches && matches[matches.length - 1] && matches[matches.length - 1].split('/')

let language = ''
if (splitParts[1]) {
language = splitParts[1]
}

return language
}

get clientFiat (): string {
// todo 某个版本的 iOS 的 UA 设置了两次,后面一次是对的,所以这里做了一下兼容,后面择机去掉兼容
const matches: any = window.navigator.userAgent.match(/Fiat\/([a-zA-Z-_]+)/g)
const splitParts: any = matches && matches[matches.length - 1] && matches[matches.length - 1].split('/')

let fiat = ''
if (splitParts[1]) {
fiat = splitParts[1]
}

return fiat
}

/**
* check if clientVersion is greater/smaller/equal to targetVersion
* @param targetVersion
Expand Down Expand Up @@ -203,23 +233,6 @@ export class ABCWallet extends EventEmitter {

return 0
}

get clientLanguage (): string {
// todo 某个版本的 iOS 的 UA 设置了两次,后面一次是对的,所以这里做了一下兼容,后面择机去掉兼容
const matches: any = window.navigator.userAgent.match(/Language\/([a-zA-Z-_]+)/g) // 形如 Language/zh-CN
const splitParts: any = matches && matches[matches.length - 1] && matches[matches.length - 1].split('/')
const language = splitParts && splitParts[1]

return language
}

get clientFiat (): string {
// todo 某个版本的 iOS 的 UA 设置了两次,后面一次是对的,所以这里做了一下兼容,后面择机去掉兼容
const matches: any = window.navigator.userAgent.match(/Fiat\/([a-zA-Z-_]+)/g)
const splitParts: any = matches && matches[matches.length - 1] && matches[matches.length - 1].split('/')
const fiat = splitParts && splitParts[1]
return fiat
}
}

export default ABCWallet
2 changes: 1 addition & 1 deletion tsconfig.cjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"outDir": "cjs",
"outDir": "cjs"
}
}
2 changes: 1 addition & 1 deletion tsconfig.esm.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"compilerOptions": {
"target": "es6",
"module": "es6",
"outDir": "esm",
"outDir": "esm"
}
}
4 changes: 2 additions & 2 deletions types/ABCWallet.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export declare class ABCWallet extends EventEmitter {
call(msg: any): void;
get isABCWallet(): boolean;
get clientVersion(): string;
get clientLanguage(): string;
get clientFiat(): string;
/**
* check if clientVersion is greater/smaller/equal to targetVersion
* @param targetVersion
Expand All @@ -33,7 +35,5 @@ export declare class ABCWallet extends EventEmitter {
* @return null unknown, maybe not in ABCWallet
*/
compareVersion(targetVersion: string): -1 | 1 | 0 | null;
get clientLanguage(): string;
get clientFiat(): string;
}
export default ABCWallet;

0 comments on commit 1476d20

Please sign in to comment.