@arcblock/did-playground 3.0.8 → 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.
- package/lib/Action/index.js +52 -52
- package/package.json +5 -5
package/lib/Action/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as n, jsxs as l, Fragment as
|
|
1
|
+
import { jsx as n, jsxs as l, Fragment as M } from "react/jsx-runtime";
|
|
2
2
|
import { use as ne, useState as d, useEffect as ie } from "react";
|
|
3
3
|
import t from "prop-types";
|
|
4
4
|
import { useSize as ae } from "ahooks";
|
|
@@ -7,10 +7,10 @@ import { styled as le, useTheme as ue } from "@arcblock/ux/lib/Theme";
|
|
|
7
7
|
import s from "lodash/isUndefined";
|
|
8
8
|
import { CircularProgress as fe, Dialog as me, DialogContent as de } from "@mui/material";
|
|
9
9
|
import ge from "@arcblock/did-connect/lib/Connect";
|
|
10
|
-
import
|
|
10
|
+
import k from "@arcblock/ux/lib/Button";
|
|
11
11
|
import { mergeProps as pe } from "@arcblock/ux/lib/Util";
|
|
12
12
|
import { SessionContext as be } from "./session.js";
|
|
13
|
-
import { getMessage as i, actions as
|
|
13
|
+
import { getMessage as i, actions as $, getActionName as q, getActionParams as he } from "./actions.js";
|
|
14
14
|
function h({ onClose: u }) {
|
|
15
15
|
return /* @__PURE__ */ n(Ce, { onClick: u, children: "×" });
|
|
16
16
|
}
|
|
@@ -26,39 +26,39 @@ const Ce = le("div")`
|
|
|
26
26
|
cursor: pointer;
|
|
27
27
|
user-select: none;
|
|
28
28
|
`;
|
|
29
|
-
function
|
|
29
|
+
function E({ ...u }) {
|
|
30
30
|
const e = Object.assign({}, u);
|
|
31
31
|
s(e.autoClose) && (e.autoClose = !0), s(e.buttonText) && (e.buttonText = ""), s(e.buttonColor) && (e.buttonColor = "primary"), s(e.buttonVariant) && (e.buttonVariant = "contained"), s(e.buttonSize) && (e.buttonSize = "large"), s(e.buttonRounded) && (e.buttonRounded = !1), s(e.scanMessage) && (e.scanMessage = "Scan the QR Code with your DID Wallet"), s(e.confirmMessage) && (e.confirmMessage = "Confirm in your DID Wallet"), s(e.successMessage) && (e.successMessage = "Operation success!"), s(e.extraParams) && (e.extraParams = {}), s(e.timeout) && (e.timeout = 5 * 60 * 1e3), s(e.successUrl) && (e.successUrl = ""), s(e.successTarget) && (e.successTarget = "_self"), s(e.frameProps) && (e.frameProps = {}), s(e.webWalletUrl) && (e.webWalletUrl = "");
|
|
32
|
-
const
|
|
33
|
-
autoClose:
|
|
32
|
+
const I = pe(e, E, ["buttonRounded", "extraParams", "timeout"]), {
|
|
33
|
+
autoClose: B,
|
|
34
34
|
action: g,
|
|
35
|
-
buttonText:
|
|
35
|
+
buttonText: z,
|
|
36
36
|
buttonColor: C,
|
|
37
37
|
buttonVariant: w,
|
|
38
38
|
buttonSize: y,
|
|
39
39
|
buttonRounded: P,
|
|
40
|
-
children:
|
|
40
|
+
children: R,
|
|
41
41
|
disableClose: we,
|
|
42
42
|
title: S,
|
|
43
|
-
scanMessage:
|
|
44
|
-
successMessage:
|
|
43
|
+
scanMessage: H,
|
|
44
|
+
successMessage: U,
|
|
45
45
|
successUrl: r,
|
|
46
46
|
successTarget: p,
|
|
47
|
-
frameProps:
|
|
48
|
-
confirmMessage:
|
|
49
|
-
extraParams:
|
|
50
|
-
timeout:
|
|
51
|
-
webWalletUrl:
|
|
47
|
+
frameProps: K,
|
|
48
|
+
confirmMessage: L,
|
|
49
|
+
extraParams: N,
|
|
50
|
+
timeout: Q,
|
|
51
|
+
webWalletUrl: G,
|
|
52
52
|
...a
|
|
53
|
-
} =
|
|
53
|
+
} = I, D = ue(), W = ce(), { api: j, session: o } = ne(be), [x, T] = d(!1), [J, v] = d(!1), [X, Y] = d({}), Z = ae(document.body), [b, F] = d(!1), [c, _] = d(b && r && p === "frame"), ee = Z?.width || 0;
|
|
54
54
|
if (ie(
|
|
55
55
|
() => () => {
|
|
56
|
-
|
|
56
|
+
F(!1), _(!1);
|
|
57
57
|
},
|
|
58
58
|
[x]
|
|
59
59
|
), g === "login")
|
|
60
|
-
return o.user ? /* @__PURE__ */ n(
|
|
61
|
-
|
|
60
|
+
return o.user ? /* @__PURE__ */ n(k, { ...a, rounded: P, color: C, variant: w, size: y, children: i(U || `Hello ${o.user.name}`, o) }) : /* @__PURE__ */ n(
|
|
61
|
+
k,
|
|
62
62
|
{
|
|
63
63
|
...a,
|
|
64
64
|
rounded: P,
|
|
@@ -66,40 +66,40 @@ function I({ ...u }) {
|
|
|
66
66
|
variant: w,
|
|
67
67
|
size: y,
|
|
68
68
|
onClick: () => o.login(),
|
|
69
|
-
children: i(
|
|
69
|
+
children: i(z || S, o)
|
|
70
70
|
}
|
|
71
71
|
);
|
|
72
|
-
const f =
|
|
73
|
-
if (
|
|
72
|
+
const f = $[g];
|
|
73
|
+
if (!$[g])
|
|
74
74
|
throw new Error(`Unsupported playground action ${g}`);
|
|
75
|
-
const
|
|
75
|
+
const A = async () => {
|
|
76
76
|
if (typeof f.onStart == "function") {
|
|
77
77
|
try {
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
|
|
78
|
+
v(!0);
|
|
79
|
+
const V = await f.onStart(j, o);
|
|
80
|
+
Y(V), v(!1);
|
|
81
81
|
} catch {
|
|
82
|
-
console.error(`Cannot generate dynamicParams for playground action ${
|
|
82
|
+
console.error(`Cannot generate dynamicParams for playground action ${q(f, a)}`);
|
|
83
83
|
}
|
|
84
84
|
T(!0);
|
|
85
85
|
} else
|
|
86
86
|
T(!0);
|
|
87
87
|
}, te = async () => {
|
|
88
88
|
if (!o.user) {
|
|
89
|
-
o.login(
|
|
89
|
+
o.login(A);
|
|
90
90
|
return;
|
|
91
91
|
}
|
|
92
|
-
await
|
|
92
|
+
await A();
|
|
93
93
|
}, m = () => T(!1), se = () => {
|
|
94
|
-
|
|
95
|
-
}, oe = () => /* @__PURE__ */ l(
|
|
94
|
+
F(!0), r ? p === "frame" ? _(!!r) : p === "_blank" ? window.open(r, "_blank") : window.open(r, "_self") : R || B && setTimeout(m, 2e3);
|
|
95
|
+
}, oe = () => /* @__PURE__ */ l(M, { children: [
|
|
96
96
|
/* @__PURE__ */ n(h, { onClose: m }),
|
|
97
97
|
/* @__PURE__ */ l("div", { children: [
|
|
98
98
|
"Redirecting to",
|
|
99
99
|
" ",
|
|
100
100
|
/* @__PURE__ */ n("a", { href: r, target: p, children: r })
|
|
101
101
|
] })
|
|
102
|
-
] }), re = () => /* @__PURE__ */ l(
|
|
102
|
+
] }), re = () => /* @__PURE__ */ l(M, { children: [
|
|
103
103
|
/* @__PURE__ */ n(h, { onClose: m }),
|
|
104
104
|
/* @__PURE__ */ n(
|
|
105
105
|
"iframe",
|
|
@@ -109,13 +109,13 @@ function I({ ...u }) {
|
|
|
109
109
|
id: "successFrame",
|
|
110
110
|
title: "successFrame",
|
|
111
111
|
src: r,
|
|
112
|
-
...
|
|
112
|
+
...K
|
|
113
113
|
}
|
|
114
114
|
)
|
|
115
|
-
] }),
|
|
116
|
-
return /* @__PURE__ */ l(
|
|
115
|
+
] }), O = !r || r && !b;
|
|
116
|
+
return /* @__PURE__ */ l(M, { children: [
|
|
117
117
|
/* @__PURE__ */ l(
|
|
118
|
-
|
|
118
|
+
k,
|
|
119
119
|
{
|
|
120
120
|
...a,
|
|
121
121
|
rounded: P,
|
|
@@ -124,18 +124,18 @@ function I({ ...u }) {
|
|
|
124
124
|
size: y,
|
|
125
125
|
onClick: te,
|
|
126
126
|
children: [
|
|
127
|
-
i(
|
|
127
|
+
i(z || S, o),
|
|
128
128
|
" ",
|
|
129
|
-
|
|
129
|
+
J && /* @__PURE__ */ n(fe, { size: 12, sx: { color: "#fff" } })
|
|
130
130
|
]
|
|
131
131
|
}
|
|
132
132
|
),
|
|
133
|
-
x && !
|
|
133
|
+
x && !O && /* @__PURE__ */ n(
|
|
134
134
|
me,
|
|
135
135
|
{
|
|
136
136
|
open: !0,
|
|
137
137
|
disableEscapeKeyDown: !0,
|
|
138
|
-
fullScreen: ee <
|
|
138
|
+
fullScreen: ee < D.breakpoints.values.sm && !(W.wallet || W.arcSphere),
|
|
139
139
|
fullWidth: c,
|
|
140
140
|
maxWidth: c ? "lg" : "",
|
|
141
141
|
children: /* @__PURE__ */ l(
|
|
@@ -146,7 +146,7 @@ function I({ ...u }) {
|
|
|
146
146
|
display: "flex",
|
|
147
147
|
justifyContent: "center",
|
|
148
148
|
alignItems: "center",
|
|
149
|
-
height: c ?
|
|
149
|
+
height: c ? D.breakpoints.values.md : ""
|
|
150
150
|
},
|
|
151
151
|
children: [
|
|
152
152
|
/* @__PURE__ */ n(h, { onClose: m }),
|
|
@@ -161,25 +161,25 @@ function I({ ...u }) {
|
|
|
161
161
|
ge,
|
|
162
162
|
{
|
|
163
163
|
popup: !0,
|
|
164
|
-
open: x &&
|
|
165
|
-
action:
|
|
166
|
-
checkFn:
|
|
164
|
+
open: x && O,
|
|
165
|
+
action: q(f, a),
|
|
166
|
+
checkFn: j.get,
|
|
167
167
|
onClose: m,
|
|
168
168
|
onSuccess: se,
|
|
169
|
-
checkTimeout:
|
|
170
|
-
extraParams: Object.assign(he(f, a, o),
|
|
171
|
-
webWalletUrl:
|
|
169
|
+
checkTimeout: Q,
|
|
170
|
+
extraParams: Object.assign(he(f, a, o), X, N),
|
|
171
|
+
webWalletUrl: G,
|
|
172
172
|
messages: {
|
|
173
173
|
title: i(S, o),
|
|
174
|
-
scan: i(
|
|
175
|
-
confirm: i(
|
|
176
|
-
success:
|
|
174
|
+
scan: i(H, o),
|
|
175
|
+
confirm: i(L, o),
|
|
176
|
+
success: R || i(U, o)
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
)
|
|
180
180
|
] });
|
|
181
181
|
}
|
|
182
|
-
|
|
182
|
+
E.propTypes = {
|
|
183
183
|
action: t.string.isRequired,
|
|
184
184
|
autoClose: t.bool,
|
|
185
185
|
buttonText: t.string,
|
|
@@ -199,5 +199,5 @@ I.propTypes = {
|
|
|
199
199
|
webWalletUrl: t.string
|
|
200
200
|
};
|
|
201
201
|
export {
|
|
202
|
-
|
|
202
|
+
E as default
|
|
203
203
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/did-playground",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.10",
|
|
4
4
|
"description": "React components that works with wallet-playground",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
"url": "https://github.com/ArcBlock/wallet-playground/issues"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@arcblock/did-connect": "3.0.
|
|
34
|
-
"@arcblock/react-hooks": "3.0.
|
|
33
|
+
"@arcblock/did-connect": "3.0.10",
|
|
34
|
+
"@arcblock/react-hooks": "3.0.10",
|
|
35
35
|
"ahooks": "^3.8.5",
|
|
36
36
|
"axios": "^1.10.0",
|
|
37
37
|
"mustache": "^4.2.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@arcblock/ux": "
|
|
40
|
+
"@arcblock/ux": "^3.0.8",
|
|
41
41
|
"@emotion/react": "^11.14.0",
|
|
42
42
|
"@emotion/styled": "^11.14.0",
|
|
43
43
|
"@mui/material": "^7.1.2",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "8e4b3b4f9cc52c8f1f1d270ab03a3c566073617a"
|
|
50
50
|
}
|