@arcblock/bridge 3.0.9 → 3.0.10

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.
Files changed (2) hide show
  1. package/lib/index.js +40 -40
  2. package/package.json +2 -2
package/lib/index.js CHANGED
@@ -1,24 +1,24 @@
1
- import o from "./dsbridge.js";
1
+ import n from "./dsbridge.js";
2
2
  const f = "1", g = {
3
3
  register(...e) {
4
- o.canUseBridge() ? o.register(...e) : console.warn("dsbridge is not available");
4
+ n.canUseBridge() ? n.register(...e) : console.warn("dsbridge is not available");
5
5
  },
6
6
  registerAsyn(...e) {
7
- o.canUseBridge() ? o.registerAsyn(...e) : console.warn("dsbridge is not available");
7
+ n.canUseBridge() ? n.registerAsyn(...e) : console.warn("dsbridge is not available");
8
8
  },
9
9
  call(...e) {
10
- o.call(...e);
10
+ n.call(...e);
11
11
  },
12
12
  asyncCall(...e) {
13
- return new Promise((s, n) => {
14
- o.call(...e, (a) => {
13
+ return new Promise((s, r) => {
14
+ n.call(...e, (a) => {
15
15
  try {
16
16
  const c = JSON.parse(a);
17
17
  if (c.code === 0) {
18
- const r = JSON.parse(c.data);
19
- s(r);
18
+ const o = JSON.parse(c.data);
19
+ s(o);
20
20
  } else
21
- n(new Error(c.error));
21
+ r(new Error(c.error));
22
22
  } catch {
23
23
  s(a);
24
24
  }
@@ -27,50 +27,50 @@ const f = "1", g = {
27
27
  },
28
28
  // 基本功能
29
29
  shareMessage(e) {
30
- const { content: s, imgUrl: n, success: a, fail: c } = e;
31
- if (!s && !n) {
30
+ const { content: s, imgUrl: r, success: a, fail: c } = e;
31
+ if (!s && !r) {
32
32
  c("params error");
33
33
  return;
34
34
  }
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);
35
+ n.call("arcShare", JSON.stringify({ content: s, imgUrl: r }), (o) => {
36
+ const t = JSON.parse(o);
37
+ t && t.code === 0 ? typeof a == "function" && a(o) : typeof c == "function" && c(o);
38
38
  });
39
39
  },
40
40
  showLoading() {
41
- o.call("arcShowLoading");
41
+ n.call("arcShowLoading");
42
42
  },
43
43
  hideLoading() {
44
- o.call("arcHideLoading");
44
+ n.call("arcHideLoading");
45
45
  },
46
46
  showToast(e) {
47
- e && typeof e == "string" && o.call("arcToast", e);
47
+ e && typeof e == "string" && n.call("arcToast", e);
48
48
  },
49
49
  // 图片功能
50
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);
51
+ const { limit: s, success: r, fail: a } = e;
52
+ n.call("arcChooseImgs", JSON.stringify({ limit: s }), (c) => {
53
+ const o = JSON.parse(c);
54
+ o && o.code === 0 ? typeof r == "function" && r(c) : typeof a == "function" && a(c);
55
55
  });
56
56
  },
57
57
  previewImgs(e) {
58
58
  const { imgs: s } = e;
59
- !s || s.length === 0 || o.call("arcPreviewImgs", JSON.stringify(e));
59
+ !s || s.length === 0 || n.call("arcPreviewImgs", JSON.stringify(e));
60
60
  },
61
61
  // 钱包功能
62
62
  isSetPWD(e) {
63
- const { success: s, fail: n } = e;
64
- o.call("arcIsSetPWD", "", (a) => {
63
+ const { success: s, fail: r } = e;
64
+ n.call("arcIsSetPWD", "", (a) => {
65
65
  const c = JSON.parse(a);
66
- c && c.code === 0 ? typeof s == "function" && s(a) : typeof n == "function" && n(a);
66
+ c && c.code === 0 ? typeof s == "function" && s(a) : typeof r == "function" && r(a);
67
67
  });
68
68
  },
69
69
  isCodeABOk(e) {
70
- const { success: s, fail: n } = e;
71
- o.call("arcIsCodeABOk", "", (a) => {
70
+ const { success: s, fail: r } = e;
71
+ n.call("arcIsCodeABOk", "", (a) => {
72
72
  const c = JSON.parse(a);
73
- c && c.code === 0 ? typeof s == "function" && s(a) : typeof n == "function" && n(a);
73
+ c && c.code === 0 ? typeof s == "function" && s(a) : typeof r == "function" && r(a);
74
74
  });
75
75
  },
76
76
  /**
@@ -80,42 +80,42 @@ const f = "1", g = {
80
80
  * @returns {Promise<any>}
81
81
  */
82
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) => {
83
+ return new Promise((r, a) => {
84
+ const o = ["arc", e].join("__"), t = { ...s, _version: f };
85
+ n.call(o, t, (l) => {
86
86
  try {
87
87
  const i = JSON.parse(l);
88
- if ((i == null ? void 0 : i._version) === f)
88
+ if (i?._version === f)
89
89
  if (i.code === 0)
90
90
  try {
91
91
  const d = JSON.parse(i.data);
92
- n(d);
92
+ r(d);
93
93
  } catch {
94
- console.warn("Failed to parse result.data"), n(i.data);
94
+ console.warn("Failed to parse result.data"), r(i.data);
95
95
  }
96
96
  else
97
97
  a(new Error(i.error));
98
98
  else
99
- n(i);
99
+ r(i);
100
100
  } catch {
101
- console.warn("Failed to parse resString"), n(l);
101
+ console.warn("Failed to parse resString"), r(l);
102
102
  }
103
103
  });
104
104
  });
105
105
  },
106
106
  registerBlocklet(e, s = () => {
107
107
  }) {
108
- if (o.canUseBridge()) {
108
+ if (n.canUseBridge()) {
109
109
  const a = ["blocklet", e].join("__");
110
- o.registerAsyn(a, (...c) => {
111
- const r = c.map((t) => {
110
+ n.registerAsyn(a, (...c) => {
111
+ const o = c.map((t) => {
112
112
  try {
113
113
  return JSON.parse(t);
114
114
  } catch {
115
115
  return t;
116
116
  }
117
117
  });
118
- s(...r);
118
+ s(...o);
119
119
  });
120
120
  } else
121
121
  console.warn("dsbridge is not available");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/bridge",
3
- "version": "3.0.9",
3
+ "version": "3.0.10",
4
4
  "description": "a bridge sdk support all js api from DID Wallet.",
5
5
  "keywords": [
6
6
  "bridge",
@@ -34,5 +34,5 @@
34
34
  "eslint-plugin-react-hooks": "^4.6.2",
35
35
  "jest": "^29.7.0"
36
36
  },
37
- "gitHead": "e2283285cb6e99f09146cde5e1af002e55091619"
37
+ "gitHead": "8e4b3b4f9cc52c8f1f1d270ab03a3c566073617a"
38
38
  }