@arcblock/bridge 2.9.62 → 2.9.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +34 -24
- package/package.json +2 -2
- package/src/index.js +31 -21
package/lib/index.js
CHANGED
|
@@ -4,23 +4,33 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
11
|
-
args[_key] = arguments[_key];
|
|
12
|
-
}
|
|
13
|
-
Promise.resolve().then(() => _interopRequireWildcard(require('dsbridge'))).then(dsbridge => {
|
|
14
|
-
if (!dsbridge.call) {
|
|
15
|
-
// eslint-disable-next-line no-param-reassign
|
|
16
|
-
dsbridge = dsbridge.default;
|
|
17
|
-
}
|
|
18
|
-
dsbridge.call(...args);
|
|
19
|
-
}).catch(err => {
|
|
20
|
-
console.error('load dsbridge error', err);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
7
|
+
var _dsbridge2 = _interopRequireDefault(require("dsbridge"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
const dsbridge = _dsbridge2.default.call ? _dsbridge2.default : _dsbridge2.default.default;
|
|
23
10
|
var _default = exports.default = {
|
|
11
|
+
call() {
|
|
12
|
+
dsbridge.call(...arguments);
|
|
13
|
+
},
|
|
14
|
+
asyncCall() {
|
|
15
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
16
|
+
args[_key] = arguments[_key];
|
|
17
|
+
}
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
dsbridge.call(...args, resString => {
|
|
20
|
+
try {
|
|
21
|
+
const result = JSON.parse(resString);
|
|
22
|
+
if (result.code === 0) {
|
|
23
|
+
const data = JSON.parse(result.data);
|
|
24
|
+
resolve(data);
|
|
25
|
+
} else {
|
|
26
|
+
reject(new Error(result.error));
|
|
27
|
+
}
|
|
28
|
+
} catch (_unused) {
|
|
29
|
+
resolve(resString);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
},
|
|
24
34
|
// 基本功能
|
|
25
35
|
shareMessage(params) {
|
|
26
36
|
const {
|
|
@@ -33,7 +43,7 @@ var _default = exports.default = {
|
|
|
33
43
|
fail('params error');
|
|
34
44
|
return;
|
|
35
45
|
}
|
|
36
|
-
|
|
46
|
+
dsbridge.call('arcShare', JSON.stringify({
|
|
37
47
|
content,
|
|
38
48
|
imgUrl
|
|
39
49
|
}), result => {
|
|
@@ -48,14 +58,14 @@ var _default = exports.default = {
|
|
|
48
58
|
});
|
|
49
59
|
},
|
|
50
60
|
showLoading() {
|
|
51
|
-
|
|
61
|
+
dsbridge.call('arcShowLoading');
|
|
52
62
|
},
|
|
53
63
|
hideLoading() {
|
|
54
|
-
|
|
64
|
+
dsbridge.call('arcHideLoading');
|
|
55
65
|
},
|
|
56
66
|
showToast(msg) {
|
|
57
67
|
if (msg && typeof msg === 'string') {
|
|
58
|
-
|
|
68
|
+
dsbridge.call('arcToast', msg);
|
|
59
69
|
}
|
|
60
70
|
},
|
|
61
71
|
// 图片功能
|
|
@@ -65,7 +75,7 @@ var _default = exports.default = {
|
|
|
65
75
|
success,
|
|
66
76
|
fail
|
|
67
77
|
} = params;
|
|
68
|
-
|
|
78
|
+
dsbridge.call('arcChooseImgs', JSON.stringify({
|
|
69
79
|
limit
|
|
70
80
|
}), result => {
|
|
71
81
|
const parseResult = JSON.parse(result);
|
|
@@ -85,7 +95,7 @@ var _default = exports.default = {
|
|
|
85
95
|
if (!imgs || imgs.length === 0) {
|
|
86
96
|
return;
|
|
87
97
|
}
|
|
88
|
-
|
|
98
|
+
dsbridge.call('arcPreviewImgs', JSON.stringify(params));
|
|
89
99
|
},
|
|
90
100
|
// 钱包功能
|
|
91
101
|
isSetPWD(params) {
|
|
@@ -93,7 +103,7 @@ var _default = exports.default = {
|
|
|
93
103
|
success,
|
|
94
104
|
fail
|
|
95
105
|
} = params;
|
|
96
|
-
|
|
106
|
+
dsbridge.call('arcIsSetPWD', '', result => {
|
|
97
107
|
const parseResult = JSON.parse(result);
|
|
98
108
|
if (parseResult && parseResult.code === 0) {
|
|
99
109
|
if (typeof success === 'function') {
|
|
@@ -109,7 +119,7 @@ var _default = exports.default = {
|
|
|
109
119
|
success,
|
|
110
120
|
fail
|
|
111
121
|
} = params;
|
|
112
|
-
|
|
122
|
+
dsbridge.call('arcIsCodeABOk', '', result => {
|
|
113
123
|
const parseResult = JSON.parse(result);
|
|
114
124
|
if (parseResult && parseResult.code === 0) {
|
|
115
125
|
if (typeof success === 'function') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/bridge",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.64",
|
|
4
4
|
"description": "a bridge sdk support all js api from DID Wallet.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bridge",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
42
42
|
"jest": "^28.1.3"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "07512d499517211d456222e096484cc7e89e5420"
|
|
45
45
|
}
|
package/src/index.js
CHANGED
|
@@ -1,18 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
if (!dsbridge.call) {
|
|
5
|
-
// eslint-disable-next-line no-param-reassign
|
|
6
|
-
dsbridge = dsbridge.default;
|
|
7
|
-
}
|
|
8
|
-
dsbridge.call(...args);
|
|
9
|
-
})
|
|
10
|
-
.catch((err) => {
|
|
11
|
-
console.error('load dsbridge error', err);
|
|
12
|
-
});
|
|
13
|
-
}
|
|
1
|
+
import _dsbridge from 'dsbridge';
|
|
2
|
+
|
|
3
|
+
const dsbridge = _dsbridge.call ? _dsbridge : _dsbridge.default;
|
|
14
4
|
|
|
15
5
|
export default {
|
|
6
|
+
call(...args) {
|
|
7
|
+
dsbridge.call(...args);
|
|
8
|
+
},
|
|
9
|
+
asyncCall(...args) {
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
dsbridge.call(...args, (resString) => {
|
|
12
|
+
try {
|
|
13
|
+
const result = JSON.parse(resString);
|
|
14
|
+
if (result.code === 0) {
|
|
15
|
+
const data = JSON.parse(result.data);
|
|
16
|
+
resolve(data);
|
|
17
|
+
} else {
|
|
18
|
+
reject(new Error(result.error));
|
|
19
|
+
}
|
|
20
|
+
} catch {
|
|
21
|
+
resolve(resString);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
},
|
|
16
26
|
// 基本功能
|
|
17
27
|
shareMessage(params) {
|
|
18
28
|
const { content, imgUrl, success, fail } = params;
|
|
@@ -20,7 +30,7 @@ export default {
|
|
|
20
30
|
fail('params error');
|
|
21
31
|
return;
|
|
22
32
|
}
|
|
23
|
-
|
|
33
|
+
dsbridge.call('arcShare', JSON.stringify({ content, imgUrl }), (result) => {
|
|
24
34
|
const parseResult = JSON.parse(result);
|
|
25
35
|
if (parseResult && parseResult.code === 0) {
|
|
26
36
|
if (typeof success === 'function') {
|
|
@@ -32,20 +42,20 @@ export default {
|
|
|
32
42
|
});
|
|
33
43
|
},
|
|
34
44
|
showLoading() {
|
|
35
|
-
|
|
45
|
+
dsbridge.call('arcShowLoading');
|
|
36
46
|
},
|
|
37
47
|
hideLoading() {
|
|
38
|
-
|
|
48
|
+
dsbridge.call('arcHideLoading');
|
|
39
49
|
},
|
|
40
50
|
showToast(msg) {
|
|
41
51
|
if (msg && typeof msg === 'string') {
|
|
42
|
-
|
|
52
|
+
dsbridge.call('arcToast', msg);
|
|
43
53
|
}
|
|
44
54
|
},
|
|
45
55
|
// 图片功能
|
|
46
56
|
chooseImgs(params) {
|
|
47
57
|
const { limit, success, fail } = params;
|
|
48
|
-
|
|
58
|
+
dsbridge.call('arcChooseImgs', JSON.stringify({ limit }), (result) => {
|
|
49
59
|
const parseResult = JSON.parse(result);
|
|
50
60
|
if (parseResult && parseResult.code === 0) {
|
|
51
61
|
if (typeof success === 'function') {
|
|
@@ -61,12 +71,12 @@ export default {
|
|
|
61
71
|
if (!imgs || imgs.length === 0) {
|
|
62
72
|
return;
|
|
63
73
|
}
|
|
64
|
-
|
|
74
|
+
dsbridge.call('arcPreviewImgs', JSON.stringify(params));
|
|
65
75
|
},
|
|
66
76
|
// 钱包功能
|
|
67
77
|
isSetPWD(params) {
|
|
68
78
|
const { success, fail } = params;
|
|
69
|
-
|
|
79
|
+
dsbridge.call('arcIsSetPWD', '', (result) => {
|
|
70
80
|
const parseResult = JSON.parse(result);
|
|
71
81
|
if (parseResult && parseResult.code === 0) {
|
|
72
82
|
if (typeof success === 'function') {
|
|
@@ -79,7 +89,7 @@ export default {
|
|
|
79
89
|
},
|
|
80
90
|
isCodeABOk(params) {
|
|
81
91
|
const { success, fail } = params;
|
|
82
|
-
|
|
92
|
+
dsbridge.call('arcIsCodeABOk', '', (result) => {
|
|
83
93
|
const parseResult = JSON.parse(result);
|
|
84
94
|
if (parseResult && parseResult.code === 0) {
|
|
85
95
|
if (typeof success === 'function') {
|