@arcblock/bridge 2.13.70 → 3.0.1
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/dsbridge.js +63 -125
- package/lib/index.js +81 -169
- package/package.json +5 -9
- package/vite.config.mjs +16 -0
package/lib/dsbridge.js
CHANGED
|
@@ -1,79 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* @copyright https://www.npmjs.com/package/dsbridge
|
|
10
|
-
* @description 只添加方法劫持前的判断,其余不做任何改动,确保不会有任何影响
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
var bridge = {
|
|
14
|
-
call: function call(method, args, cb) {
|
|
15
|
-
var ret = '';
|
|
16
|
-
if (typeof args == 'function') {
|
|
17
|
-
cb = args;
|
|
18
|
-
args = {};
|
|
1
|
+
var n = {
|
|
2
|
+
call: function(s, i, r) {
|
|
3
|
+
var e = "";
|
|
4
|
+
typeof i == "function" && (r = i, i = {});
|
|
5
|
+
var a = { data: i === void 0 ? null : i };
|
|
6
|
+
if (typeof r == "function") {
|
|
7
|
+
var t = "dscb" + window.dscb++;
|
|
8
|
+
window[t] = r, a._dscbstub = t;
|
|
19
9
|
}
|
|
20
|
-
|
|
21
|
-
data: args === undefined ? null : args
|
|
22
|
-
};
|
|
23
|
-
if (typeof cb == 'function') {
|
|
24
|
-
var cbName = 'dscb' + window.dscb++;
|
|
25
|
-
window[cbName] = cb;
|
|
26
|
-
arg['_dscbstub'] = cbName;
|
|
27
|
-
}
|
|
28
|
-
arg = JSON.stringify(arg);
|
|
29
|
-
|
|
30
|
-
//if in webview that dsBridge provided, call!
|
|
31
|
-
if (window._dsbridge) {
|
|
32
|
-
ret = _dsbridge.call(method, arg);
|
|
33
|
-
} else if (window._dswk || navigator.userAgent.indexOf('_dsbridge') != -1) {
|
|
34
|
-
ret = prompt('_dsbridge=' + method, arg);
|
|
35
|
-
}
|
|
36
|
-
return JSON.parse(ret || '{}').data;
|
|
10
|
+
return a = JSON.stringify(a), window._dsbridge ? e = _dsbridge.call(s, a) : (window._dswk || navigator.userAgent.indexOf("_dsbridge") != -1) && (e = prompt("_dsbridge=" + s, a)), JSON.parse(e || "{}").data;
|
|
37
11
|
},
|
|
38
|
-
register: function
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
setTimeout(function () {
|
|
44
|
-
bridge.call('_dsb.dsinit');
|
|
45
|
-
}, 0);
|
|
46
|
-
}
|
|
47
|
-
if (typeof fun == 'object') {
|
|
48
|
-
q._obs[name] = fun;
|
|
49
|
-
} else {
|
|
50
|
-
q[name] = fun;
|
|
51
|
-
}
|
|
12
|
+
register: function(s, i, r) {
|
|
13
|
+
var e = r ? window._dsaf : window._dsf;
|
|
14
|
+
window._dsInit || (window._dsInit = !0, setTimeout(function() {
|
|
15
|
+
n.call("_dsb.dsinit");
|
|
16
|
+
}, 0)), typeof i == "object" ? e._obs[s] = i : e[s] = i;
|
|
52
17
|
},
|
|
53
|
-
registerAsyn: function
|
|
54
|
-
this.register(
|
|
18
|
+
registerAsyn: function(s, i) {
|
|
19
|
+
this.register(s, i, !0);
|
|
55
20
|
},
|
|
56
|
-
hasNativeMethod: function
|
|
57
|
-
return this.call(
|
|
58
|
-
name: name,
|
|
59
|
-
type: type || 'all'
|
|
60
|
-
});
|
|
21
|
+
hasNativeMethod: function(s, i) {
|
|
22
|
+
return this.call("_dsb.hasNativeMethod", { name: s, type: i || "all" });
|
|
61
23
|
},
|
|
62
|
-
disableJavascriptDialogBlock: function
|
|
63
|
-
this.call(
|
|
64
|
-
disable:
|
|
24
|
+
disableJavascriptDialogBlock: function(s) {
|
|
25
|
+
this.call("_dsb.disableJavascriptDialogBlock", {
|
|
26
|
+
disable: s !== !1
|
|
65
27
|
});
|
|
66
28
|
},
|
|
67
29
|
canUseBridge() {
|
|
68
|
-
return !!(window._dsbridge || window._dswk || navigator.userAgent.indexOf(
|
|
30
|
+
return !!(window._dsbridge || window._dswk || navigator.userAgent.indexOf("_dsbridge") != -1);
|
|
69
31
|
}
|
|
70
32
|
};
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const originClose = window.close;
|
|
76
|
-
var ob = {
|
|
33
|
+
(function() {
|
|
34
|
+
if (!n.canUseBridge() || window._dsf) return;
|
|
35
|
+
const s = window.close;
|
|
36
|
+
var i = {
|
|
77
37
|
_dsf: {
|
|
78
38
|
_obs: {}
|
|
79
39
|
},
|
|
@@ -81,72 +41,50 @@ var bridge = {
|
|
|
81
41
|
_obs: {}
|
|
82
42
|
},
|
|
83
43
|
dscb: 0,
|
|
84
|
-
dsBridge:
|
|
85
|
-
close: function
|
|
86
|
-
|
|
87
|
-
originClose();
|
|
44
|
+
dsBridge: n,
|
|
45
|
+
close: function() {
|
|
46
|
+
n.call("_dsb.closePage"), s();
|
|
88
47
|
},
|
|
89
|
-
_handleMessageFromNative: function
|
|
90
|
-
var
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
48
|
+
_handleMessageFromNative: function(e) {
|
|
49
|
+
var a = JSON.parse(e.data), t = {
|
|
50
|
+
id: e.callbackId,
|
|
51
|
+
complete: !0
|
|
52
|
+
}, o = this._dsf[e.method], l = this._dsaf[e.method], w = function(u, v) {
|
|
53
|
+
t.data = u.apply(v, a), n.call("_dsb.returnValue", t);
|
|
54
|
+
}, g = function(u, v) {
|
|
55
|
+
a.push(function(h, y) {
|
|
56
|
+
t.data = h, t.complete = y !== !1, n.call("_dsb.returnValue", t);
|
|
57
|
+
}), u.apply(v, a);
|
|
94
58
|
};
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
bridge.call('_dsb.returnValue', ret);
|
|
106
|
-
});
|
|
107
|
-
f.apply(ob, arg);
|
|
108
|
-
};
|
|
109
|
-
if (f) {
|
|
110
|
-
callSyn(f, this._dsf);
|
|
111
|
-
} else if (af) {
|
|
112
|
-
callAsyn(af, this._dsaf);
|
|
113
|
-
} else {
|
|
114
|
-
//with namespace
|
|
115
|
-
var name = info.method.split('.');
|
|
116
|
-
if (name.length < 2) return;
|
|
117
|
-
var method = name.pop();
|
|
118
|
-
var namespace = name.join('.');
|
|
119
|
-
var obs = this._dsf._obs;
|
|
120
|
-
var ob = obs[namespace] || {};
|
|
121
|
-
var m = ob[method];
|
|
122
|
-
if (m && typeof m == 'function') {
|
|
123
|
-
callSyn(m, ob);
|
|
59
|
+
if (o)
|
|
60
|
+
w(o, this._dsf);
|
|
61
|
+
else if (l)
|
|
62
|
+
g(l, this._dsaf);
|
|
63
|
+
else {
|
|
64
|
+
var c = e.method.split(".");
|
|
65
|
+
if (c.length < 2) return;
|
|
66
|
+
var p = c.pop(), b = c.join("."), _ = this._dsf._obs, f = _[b] || {}, d = f[p];
|
|
67
|
+
if (d && typeof d == "function") {
|
|
68
|
+
w(d, f);
|
|
124
69
|
return;
|
|
125
70
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
m = ob[method];
|
|
129
|
-
if (m && typeof m == 'function') {
|
|
130
|
-
callAsyn(m, ob);
|
|
71
|
+
if (_ = this._dsaf._obs, f = _[b] || {}, d = f[p], d && typeof d == "function") {
|
|
72
|
+
g(d, f);
|
|
131
73
|
return;
|
|
132
74
|
}
|
|
133
75
|
}
|
|
134
76
|
}
|
|
135
77
|
};
|
|
136
|
-
for (var
|
|
137
|
-
window[
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
// with namespace
|
|
145
|
-
var method = name.pop();
|
|
146
|
-
var namespace = name.join('.');
|
|
147
|
-
var ob = _dsf._obs[namespace] || _dsaf._obs[namespace];
|
|
148
|
-
return ob && !!ob[method];
|
|
149
|
-
}
|
|
78
|
+
for (var r in i)
|
|
79
|
+
window[r] = i[r];
|
|
80
|
+
n.register("_hasJavascriptMethod", function(e, a) {
|
|
81
|
+
var t = e.split(".");
|
|
82
|
+
if (t.length < 2)
|
|
83
|
+
return !!(_dsf[t] || _dsaf[t]);
|
|
84
|
+
var e = t.pop(), o = t.join("."), l = _dsf._obs[o] || _dsaf._obs[o];
|
|
85
|
+
return l && !!l[e];
|
|
150
86
|
});
|
|
151
|
-
}();
|
|
152
|
-
|
|
87
|
+
})();
|
|
88
|
+
export {
|
|
89
|
+
n as default
|
|
90
|
+
};
|
package/lib/index.js
CHANGED
|
@@ -1,152 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _dsbridge = _interopRequireDefault(require("./dsbridge"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
12
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
13
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
14
|
-
const BRIDGE_VERSION = '1';
|
|
15
|
-
var _default = exports.default = {
|
|
16
|
-
register() {
|
|
17
|
-
if (_dsbridge.default.canUseBridge()) {
|
|
18
|
-
_dsbridge.default.register(...arguments);
|
|
19
|
-
} else {
|
|
20
|
-
console.warn('dsbridge is not available');
|
|
21
|
-
}
|
|
1
|
+
import o from "./dsbridge.js";
|
|
2
|
+
const f = "1", g = {
|
|
3
|
+
register(...e) {
|
|
4
|
+
o.canUseBridge() ? o.register(...e) : console.warn("dsbridge is not available");
|
|
22
5
|
},
|
|
23
|
-
registerAsyn() {
|
|
24
|
-
|
|
25
|
-
_dsbridge.default.registerAsyn(...arguments);
|
|
26
|
-
} else {
|
|
27
|
-
console.warn('dsbridge is not available');
|
|
28
|
-
}
|
|
6
|
+
registerAsyn(...e) {
|
|
7
|
+
o.canUseBridge() ? o.registerAsyn(...e) : console.warn("dsbridge is not available");
|
|
29
8
|
},
|
|
30
|
-
call() {
|
|
31
|
-
|
|
9
|
+
call(...e) {
|
|
10
|
+
o.call(...e);
|
|
32
11
|
},
|
|
33
|
-
asyncCall() {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
return new Promise((resolve, reject) => {
|
|
38
|
-
_dsbridge.default.call(...args, resString => {
|
|
12
|
+
asyncCall(...e) {
|
|
13
|
+
return new Promise((s, n) => {
|
|
14
|
+
o.call(...e, (a) => {
|
|
39
15
|
try {
|
|
40
|
-
const
|
|
41
|
-
if (
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
} else
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
resolve(resString);
|
|
16
|
+
const c = JSON.parse(a);
|
|
17
|
+
if (c.code === 0) {
|
|
18
|
+
const r = JSON.parse(c.data);
|
|
19
|
+
s(r);
|
|
20
|
+
} else
|
|
21
|
+
n(new Error(c.error));
|
|
22
|
+
} catch {
|
|
23
|
+
s(a);
|
|
49
24
|
}
|
|
50
25
|
});
|
|
51
26
|
});
|
|
52
27
|
},
|
|
53
28
|
// 基本功能
|
|
54
|
-
shareMessage(
|
|
55
|
-
const {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
success,
|
|
59
|
-
fail
|
|
60
|
-
} = params;
|
|
61
|
-
if (!content && !imgUrl) {
|
|
62
|
-
fail('params error');
|
|
29
|
+
shareMessage(e) {
|
|
30
|
+
const { content: s, imgUrl: n, success: a, fail: c } = e;
|
|
31
|
+
if (!s && !n) {
|
|
32
|
+
c("params error");
|
|
63
33
|
return;
|
|
64
34
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}), result => {
|
|
69
|
-
const parseResult = JSON.parse(result);
|
|
70
|
-
if (parseResult && parseResult.code === 0) {
|
|
71
|
-
if (typeof success === 'function') {
|
|
72
|
-
success(result);
|
|
73
|
-
}
|
|
74
|
-
} else if (typeof fail === 'function') {
|
|
75
|
-
fail(result);
|
|
76
|
-
}
|
|
35
|
+
o.call("arcShare", JSON.stringify({ content: s, imgUrl: n }), (r) => {
|
|
36
|
+
const t = JSON.parse(r);
|
|
37
|
+
t && t.code === 0 ? typeof a == "function" && a(r) : typeof c == "function" && c(r);
|
|
77
38
|
});
|
|
78
39
|
},
|
|
79
40
|
showLoading() {
|
|
80
|
-
|
|
41
|
+
o.call("arcShowLoading");
|
|
81
42
|
},
|
|
82
43
|
hideLoading() {
|
|
83
|
-
|
|
44
|
+
o.call("arcHideLoading");
|
|
84
45
|
},
|
|
85
|
-
showToast(
|
|
86
|
-
|
|
87
|
-
_dsbridge.default.call('arcToast', msg);
|
|
88
|
-
}
|
|
46
|
+
showToast(e) {
|
|
47
|
+
e && typeof e == "string" && o.call("arcToast", e);
|
|
89
48
|
},
|
|
90
49
|
// 图片功能
|
|
91
|
-
chooseImgs(
|
|
92
|
-
const {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
} = params;
|
|
97
|
-
_dsbridge.default.call('arcChooseImgs', JSON.stringify({
|
|
98
|
-
limit
|
|
99
|
-
}), result => {
|
|
100
|
-
const parseResult = JSON.parse(result);
|
|
101
|
-
if (parseResult && parseResult.code === 0) {
|
|
102
|
-
if (typeof success === 'function') {
|
|
103
|
-
success(result);
|
|
104
|
-
}
|
|
105
|
-
} else if (typeof fail === 'function') {
|
|
106
|
-
fail(result);
|
|
107
|
-
}
|
|
50
|
+
chooseImgs(e) {
|
|
51
|
+
const { limit: s, success: n, fail: a } = e;
|
|
52
|
+
o.call("arcChooseImgs", JSON.stringify({ limit: s }), (c) => {
|
|
53
|
+
const r = JSON.parse(c);
|
|
54
|
+
r && r.code === 0 ? typeof n == "function" && n(c) : typeof a == "function" && a(c);
|
|
108
55
|
});
|
|
109
56
|
},
|
|
110
|
-
previewImgs(
|
|
111
|
-
const {
|
|
112
|
-
|
|
113
|
-
} = params;
|
|
114
|
-
if (!imgs || imgs.length === 0) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
_dsbridge.default.call('arcPreviewImgs', JSON.stringify(params));
|
|
57
|
+
previewImgs(e) {
|
|
58
|
+
const { imgs: s } = e;
|
|
59
|
+
!s || s.length === 0 || o.call("arcPreviewImgs", JSON.stringify(e));
|
|
118
60
|
},
|
|
119
61
|
// 钱包功能
|
|
120
|
-
isSetPWD(
|
|
121
|
-
const {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
_dsbridge.default.call('arcIsSetPWD', '', result => {
|
|
126
|
-
const parseResult = JSON.parse(result);
|
|
127
|
-
if (parseResult && parseResult.code === 0) {
|
|
128
|
-
if (typeof success === 'function') {
|
|
129
|
-
success(result);
|
|
130
|
-
}
|
|
131
|
-
} else if (typeof fail === 'function') {
|
|
132
|
-
fail(result);
|
|
133
|
-
}
|
|
62
|
+
isSetPWD(e) {
|
|
63
|
+
const { success: s, fail: n } = e;
|
|
64
|
+
o.call("arcIsSetPWD", "", (a) => {
|
|
65
|
+
const c = JSON.parse(a);
|
|
66
|
+
c && c.code === 0 ? typeof s == "function" && s(a) : typeof n == "function" && n(a);
|
|
134
67
|
});
|
|
135
68
|
},
|
|
136
|
-
isCodeABOk(
|
|
137
|
-
const {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
_dsbridge.default.call('arcIsCodeABOk', '', result => {
|
|
142
|
-
const parseResult = JSON.parse(result);
|
|
143
|
-
if (parseResult && parseResult.code === 0) {
|
|
144
|
-
if (typeof success === 'function') {
|
|
145
|
-
success(result);
|
|
146
|
-
}
|
|
147
|
-
} else if (typeof fail === 'function') {
|
|
148
|
-
fail(result);
|
|
149
|
-
}
|
|
69
|
+
isCodeABOk(e) {
|
|
70
|
+
const { success: s, fail: n } = e;
|
|
71
|
+
o.call("arcIsCodeABOk", "", (a) => {
|
|
72
|
+
const c = JSON.parse(a);
|
|
73
|
+
c && c.code === 0 ? typeof s == "function" && s(a) : typeof n == "function" && n(a);
|
|
150
74
|
});
|
|
151
75
|
},
|
|
152
76
|
/**
|
|
@@ -155,60 +79,48 @@ var _default = exports.default = {
|
|
|
155
79
|
* @param {object} [params] 调用的参数,只能为 object
|
|
156
80
|
* @returns {Promise<any>}
|
|
157
81
|
*/
|
|
158
|
-
callArc(
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
const fnName = [namespace, eventName].join('__');
|
|
163
|
-
const mergedParams = _objectSpread(_objectSpread({}, params), {}, {
|
|
164
|
-
_version: BRIDGE_VERSION
|
|
165
|
-
});
|
|
166
|
-
_dsbridge.default.call(fnName, mergedParams, resString => {
|
|
82
|
+
callArc(e, s = {}) {
|
|
83
|
+
return new Promise((n, a) => {
|
|
84
|
+
const r = ["arc", e].join("__"), t = { ...s, _version: f };
|
|
85
|
+
o.call(r, t, (l) => {
|
|
167
86
|
try {
|
|
168
|
-
const
|
|
169
|
-
if ((
|
|
170
|
-
if (
|
|
87
|
+
const i = JSON.parse(l);
|
|
88
|
+
if ((i == null ? void 0 : i._version) === f)
|
|
89
|
+
if (i.code === 0)
|
|
171
90
|
try {
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
} catch
|
|
175
|
-
console.warn(
|
|
176
|
-
resolve(result.data);
|
|
91
|
+
const d = JSON.parse(i.data);
|
|
92
|
+
n(d);
|
|
93
|
+
} catch {
|
|
94
|
+
console.warn("Failed to parse result.data"), n(i.data);
|
|
177
95
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
} catch (_unused3) {
|
|
186
|
-
console.warn('Failed to parse resString');
|
|
187
|
-
resolve(resString);
|
|
96
|
+
else
|
|
97
|
+
a(new Error(i.error));
|
|
98
|
+
else
|
|
99
|
+
n(i);
|
|
100
|
+
} catch {
|
|
101
|
+
console.warn("Failed to parse resString"), n(l);
|
|
188
102
|
}
|
|
189
103
|
});
|
|
190
104
|
});
|
|
191
105
|
},
|
|
192
|
-
registerBlocklet(
|
|
193
|
-
|
|
194
|
-
if (
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
199
|
-
args[_key2] = arguments[_key2];
|
|
200
|
-
}
|
|
201
|
-
const parsedArgs = args.map(x => {
|
|
106
|
+
registerBlocklet(e, s = () => {
|
|
107
|
+
}) {
|
|
108
|
+
if (o.canUseBridge()) {
|
|
109
|
+
const a = ["blocklet", e].join("__");
|
|
110
|
+
o.registerAsyn(a, (...c) => {
|
|
111
|
+
const r = c.map((t) => {
|
|
202
112
|
try {
|
|
203
|
-
return JSON.parse(
|
|
204
|
-
} catch
|
|
205
|
-
return
|
|
113
|
+
return JSON.parse(t);
|
|
114
|
+
} catch {
|
|
115
|
+
return t;
|
|
206
116
|
}
|
|
207
117
|
});
|
|
208
|
-
|
|
118
|
+
s(...r);
|
|
209
119
|
});
|
|
210
|
-
} else
|
|
211
|
-
console.warn(
|
|
212
|
-
}
|
|
120
|
+
} else
|
|
121
|
+
console.warn("dsbridge is not available");
|
|
213
122
|
}
|
|
214
|
-
};
|
|
123
|
+
};
|
|
124
|
+
export {
|
|
125
|
+
g as default
|
|
126
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/bridge",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "a bridge sdk support all js api from DID Wallet.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bridge",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
18
|
"lint": "echo 'lint'",
|
|
19
|
-
"build": "
|
|
20
|
-
"watch": "
|
|
19
|
+
"build": "vite build",
|
|
20
|
+
"watch": "vite build --watch",
|
|
21
21
|
"precommit": "CI=1 npm run lint",
|
|
22
22
|
"prepush": "CI=1 npm run lint",
|
|
23
23
|
"prepublish": "npm run build",
|
|
@@ -31,12 +31,8 @@
|
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"
|
|
35
|
-
"@babel/core": "^7.19.3",
|
|
36
|
-
"@babel/preset-env": "^7.19.3",
|
|
37
|
-
"@babel/preset-react": "^7.18.6",
|
|
38
|
-
"eslint-plugin-react-hooks": "^4.6.0",
|
|
34
|
+
"eslint-plugin-react-hooks": "^4.6.2",
|
|
39
35
|
"jest": "^29.7.0"
|
|
40
36
|
},
|
|
41
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "36d86df0c9fd5fdf668fb3505492c830e437b3a5"
|
|
42
38
|
}
|
package/vite.config.mjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import fg from 'fast-glob';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
build: {
|
|
6
|
+
lib: {
|
|
7
|
+
entry: fg.sync('src/**/*.{tsx,ts,jsx,js}', {
|
|
8
|
+
ignore: ['**/stories/**', '**/demo/**', '**/*.d.ts', '**/*.stories.*'],
|
|
9
|
+
}),
|
|
10
|
+
formats: ['es'],
|
|
11
|
+
fileName: (format, entryName) => `${entryName}.js`,
|
|
12
|
+
},
|
|
13
|
+
outDir: 'lib',
|
|
14
|
+
emptyOutDir: true,
|
|
15
|
+
},
|
|
16
|
+
});
|