@arcblock/bridge 2.8.15 → 2.8.17
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 +20 -10
- package/package.json +2 -2
- package/src/index.js +17 -9
package/lib/index.js
CHANGED
|
@@ -4,8 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var
|
|
8
|
-
function
|
|
7
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
8
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
9
|
+
function callBridge() {
|
|
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
|
+
dsbridge.call(...args);
|
|
15
|
+
}).catch(err => {
|
|
16
|
+
console.error('load dsbridge error', err);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
9
19
|
var _default = {
|
|
10
20
|
// 基本功能
|
|
11
21
|
shareMessage(params) {
|
|
@@ -19,7 +29,7 @@ var _default = {
|
|
|
19
29
|
fail('params error');
|
|
20
30
|
return;
|
|
21
31
|
}
|
|
22
|
-
|
|
32
|
+
callBridge('arcShare', JSON.stringify({
|
|
23
33
|
content,
|
|
24
34
|
imgUrl
|
|
25
35
|
}), result => {
|
|
@@ -34,14 +44,14 @@ var _default = {
|
|
|
34
44
|
});
|
|
35
45
|
},
|
|
36
46
|
showLoading() {
|
|
37
|
-
|
|
47
|
+
callBridge('arcShowLoading');
|
|
38
48
|
},
|
|
39
49
|
hideLoading() {
|
|
40
|
-
|
|
50
|
+
callBridge('arcHideLoading');
|
|
41
51
|
},
|
|
42
52
|
showToast(msg) {
|
|
43
53
|
if (msg && typeof msg === 'string') {
|
|
44
|
-
|
|
54
|
+
callBridge('arcToast', msg);
|
|
45
55
|
}
|
|
46
56
|
},
|
|
47
57
|
// 图片功能
|
|
@@ -51,7 +61,7 @@ var _default = {
|
|
|
51
61
|
success,
|
|
52
62
|
fail
|
|
53
63
|
} = params;
|
|
54
|
-
|
|
64
|
+
callBridge('arcChooseImgs', JSON.stringify({
|
|
55
65
|
limit
|
|
56
66
|
}), result => {
|
|
57
67
|
const parseResult = JSON.parse(result);
|
|
@@ -71,7 +81,7 @@ var _default = {
|
|
|
71
81
|
if (!imgs || imgs.length === 0) {
|
|
72
82
|
return;
|
|
73
83
|
}
|
|
74
|
-
|
|
84
|
+
callBridge('arcPreviewImgs', JSON.stringify(params));
|
|
75
85
|
},
|
|
76
86
|
// 钱包功能
|
|
77
87
|
isSetPWD(params) {
|
|
@@ -79,7 +89,7 @@ var _default = {
|
|
|
79
89
|
success,
|
|
80
90
|
fail
|
|
81
91
|
} = params;
|
|
82
|
-
|
|
92
|
+
callBridge('arcIsSetPWD', '', result => {
|
|
83
93
|
const parseResult = JSON.parse(result);
|
|
84
94
|
if (parseResult && parseResult.code === 0) {
|
|
85
95
|
if (typeof success === 'function') {
|
|
@@ -95,7 +105,7 @@ var _default = {
|
|
|
95
105
|
success,
|
|
96
106
|
fail
|
|
97
107
|
} = params;
|
|
98
|
-
|
|
108
|
+
callBridge('arcIsCodeABOk', '', result => {
|
|
99
109
|
const parseResult = JSON.parse(result);
|
|
100
110
|
if (parseResult && parseResult.code === 0) {
|
|
101
111
|
if (typeof success === 'function') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/bridge",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.17",
|
|
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": "bd7a8f9d5bfbd61bcb0f6ff57de4600d8afded7b"
|
|
45
45
|
}
|
package/src/index.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
function callBridge(...args) {
|
|
2
|
+
import('dsbridge')
|
|
3
|
+
.then((dsbridge) => {
|
|
4
|
+
dsbridge.call(...args);
|
|
5
|
+
})
|
|
6
|
+
.catch((err) => {
|
|
7
|
+
console.error('load dsbridge error', err);
|
|
8
|
+
});
|
|
9
|
+
}
|
|
2
10
|
|
|
3
11
|
export default {
|
|
4
12
|
// 基本功能
|
|
@@ -8,7 +16,7 @@ export default {
|
|
|
8
16
|
fail('params error');
|
|
9
17
|
return;
|
|
10
18
|
}
|
|
11
|
-
|
|
19
|
+
callBridge('arcShare', JSON.stringify({ content, imgUrl }), (result) => {
|
|
12
20
|
const parseResult = JSON.parse(result);
|
|
13
21
|
if (parseResult && parseResult.code === 0) {
|
|
14
22
|
if (typeof success === 'function') {
|
|
@@ -20,20 +28,20 @@ export default {
|
|
|
20
28
|
});
|
|
21
29
|
},
|
|
22
30
|
showLoading() {
|
|
23
|
-
|
|
31
|
+
callBridge('arcShowLoading');
|
|
24
32
|
},
|
|
25
33
|
hideLoading() {
|
|
26
|
-
|
|
34
|
+
callBridge('arcHideLoading');
|
|
27
35
|
},
|
|
28
36
|
showToast(msg) {
|
|
29
37
|
if (msg && typeof msg === 'string') {
|
|
30
|
-
|
|
38
|
+
callBridge('arcToast', msg);
|
|
31
39
|
}
|
|
32
40
|
},
|
|
33
41
|
// 图片功能
|
|
34
42
|
chooseImgs(params) {
|
|
35
43
|
const { limit, success, fail } = params;
|
|
36
|
-
|
|
44
|
+
callBridge('arcChooseImgs', JSON.stringify({ limit }), (result) => {
|
|
37
45
|
const parseResult = JSON.parse(result);
|
|
38
46
|
if (parseResult && parseResult.code === 0) {
|
|
39
47
|
if (typeof success === 'function') {
|
|
@@ -49,12 +57,12 @@ export default {
|
|
|
49
57
|
if (!imgs || imgs.length === 0) {
|
|
50
58
|
return;
|
|
51
59
|
}
|
|
52
|
-
|
|
60
|
+
callBridge('arcPreviewImgs', JSON.stringify(params));
|
|
53
61
|
},
|
|
54
62
|
// 钱包功能
|
|
55
63
|
isSetPWD(params) {
|
|
56
64
|
const { success, fail } = params;
|
|
57
|
-
|
|
65
|
+
callBridge('arcIsSetPWD', '', (result) => {
|
|
58
66
|
const parseResult = JSON.parse(result);
|
|
59
67
|
if (parseResult && parseResult.code === 0) {
|
|
60
68
|
if (typeof success === 'function') {
|
|
@@ -67,7 +75,7 @@ export default {
|
|
|
67
75
|
},
|
|
68
76
|
isCodeABOk(params) {
|
|
69
77
|
const { success, fail } = params;
|
|
70
|
-
|
|
78
|
+
callBridge('arcIsCodeABOk', '', (result) => {
|
|
71
79
|
const parseResult = JSON.parse(result);
|
|
72
80
|
if (parseResult && parseResult.code === 0) {
|
|
73
81
|
if (typeof success === 'function') {
|