@arcblock/did-connect-react 3.4.0 → 3.4.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/Connect/assets/locale.js +4 -2
- package/lib/Connect/components/login-item/connect-choose-list.js +120 -114
- package/lib/Connect/components/login-item/connect-provider-list.js +187 -180
- package/lib/Connect/components/login-item/login-method-item.js +63 -47
- package/lib/Connect/components/login-item/passkey-login-item.js +17 -15
- package/lib/Connect/components/login-item/wallet-login-options.js +42 -40
- package/lib/Connect/connect.js +88 -86
- package/lib/Connect/contexts/state.js +73 -64
- package/lib/Connect/hooks/provider-list.js +43 -33
- package/lib/Connect/plugins/email/list-item.js +19 -18
- package/lib/Passkey/actions.js +80 -75
- package/lib/package.json.js +1 -1
- package/package.json +5 -5
- package/src/Connect/assets/locale.js +2 -0
- package/src/Connect/components/login-item/connect-choose-list.jsx +12 -5
- package/src/Connect/components/login-item/connect-provider-list.jsx +11 -4
- package/src/Connect/components/login-item/login-method-item.jsx +24 -7
- package/src/Connect/components/login-item/passkey-login-item.jsx +3 -1
- package/src/Connect/components/login-item/wallet-login-options.jsx +3 -2
- package/src/Connect/connect.jsx +2 -0
- package/src/Connect/contexts/state.jsx +10 -0
- package/src/Connect/hooks/provider-list.js +43 -17
- package/src/Connect/plugins/email/list-item.jsx +3 -2
- package/src/Passkey/actions.jsx +5 -0
package/lib/Connect/connect.js
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { jsx as t, jsxs as b, Fragment as
|
|
2
|
-
import { use as
|
|
1
|
+
import { jsx as t, jsxs as b, Fragment as He } from "react/jsx-runtime";
|
|
2
|
+
import { use as Ve, useRef as le, useState as Ye, useEffect as ue } from "react";
|
|
3
3
|
import e from "prop-types";
|
|
4
|
-
import { Box as i, Skeleton as
|
|
5
|
-
import { useUpdate as
|
|
4
|
+
import { Box as i, Skeleton as Ge, Divider as Ke } from "@mui/material";
|
|
5
|
+
import { useUpdate as Qe, useSize as Xe, useCreation as u, useMount as de, useMemoizedFn as F, useDebounceFn as Je, usePrevious as Ze, useUpdateEffect as $e } from "ahooks";
|
|
6
6
|
import C from "lodash/noop";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { DID_CONNECT_MEDIUM_WIDTH as N, LOGIN_PROVIDER_NAME as
|
|
10
|
-
import
|
|
11
|
-
import { DIDConnectFooter as
|
|
12
|
-
import { useTheme as
|
|
13
|
-
import
|
|
7
|
+
import et from "lodash/isUndefined";
|
|
8
|
+
import tt from "@arcblock/ux/lib/CloseButton";
|
|
9
|
+
import { DID_CONNECT_MEDIUM_WIDTH as N, LOGIN_PROVIDER_NAME as ot, DID_CONNECT_SMALL_WIDTH as rt, OAUTH_PROVIDER as j, LOGIN_PROVIDER as nt } from "@arcblock/ux/lib/Util/constant";
|
|
10
|
+
import it from "@arcblock/ux/lib/QRCode";
|
|
11
|
+
import { DIDConnectFooter as st } from "@arcblock/ux/lib/DIDConnect";
|
|
12
|
+
import { useTheme as at } from "@arcblock/ux/lib/Theme";
|
|
13
|
+
import ct from "@arcblock/ux/lib/DIDConnect/provider-icon";
|
|
14
14
|
import "@fontsource/lexend/400.css";
|
|
15
15
|
import "@fontsource/lexend/600.css";
|
|
16
|
-
import { SessionContext as
|
|
17
|
-
import { StateProvider as
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import { useOAuth as
|
|
22
|
-
import
|
|
23
|
-
import { usePasskey as
|
|
24
|
-
import { CHECK_STATUS_INTERVAL as
|
|
16
|
+
import { SessionContext as lt } from "../Session/context.js";
|
|
17
|
+
import { StateProvider as ut, useStateContext as dt } from "./contexts/state.js";
|
|
18
|
+
import ft from "./components/login-item/connect-provider-list.js";
|
|
19
|
+
import mt from "./components/auto-height.js";
|
|
20
|
+
import pt from "./hooks/token.js";
|
|
21
|
+
import { useOAuth as ht } from "../OAuth/context.js";
|
|
22
|
+
import bt from "./components/connect-status.js";
|
|
23
|
+
import { usePasskey as gt } from "../Passkey/context.js";
|
|
24
|
+
import { CHECK_STATUS_INTERVAL as xt, API_DID_PREFIX as Ct, BUSY_STATUS as w, DEFAULT_TIMEOUT as yt } from "../constant.js";
|
|
25
25
|
import "../utils.js";
|
|
26
|
-
import
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import
|
|
30
|
-
import { getWalletDid as
|
|
31
|
-
import
|
|
32
|
-
import { getWebWalletUrl as
|
|
26
|
+
import St from "./components/did-connect-title.js";
|
|
27
|
+
import kt from "./components/download-tips.js";
|
|
28
|
+
import wt from "./hooks/provider-list.js";
|
|
29
|
+
import It from "./hooks/auth-url.js";
|
|
30
|
+
import { getWalletDid as vt } from "../User/use-did.js";
|
|
31
|
+
import Pt from "./fallback-connect.js";
|
|
32
|
+
import { getWebWalletUrl as _t } from "@arcblock/ux/lib/Util/wallet";
|
|
33
33
|
function fe({
|
|
34
34
|
hideCloseButton: y = !1,
|
|
35
35
|
mode: p = "dialog",
|
|
36
36
|
action: I,
|
|
37
37
|
baseUrl: g = "",
|
|
38
38
|
checkFn: v,
|
|
39
|
-
checkInterval: P =
|
|
40
|
-
checkTimeout: _ =
|
|
41
|
-
prefix: D =
|
|
39
|
+
checkInterval: P = xt,
|
|
40
|
+
checkTimeout: _ = yt * 1e3,
|
|
41
|
+
prefix: D = Ct,
|
|
42
42
|
tokenKey: B = "_t_",
|
|
43
43
|
locale: q = "en",
|
|
44
44
|
encKey: me = "_ek_",
|
|
@@ -50,7 +50,7 @@ function fe({
|
|
|
50
50
|
provider: ge = "",
|
|
51
51
|
messages: d = {},
|
|
52
52
|
passkeyBehavior: Y = "none",
|
|
53
|
-
webWalletUrl: xe =
|
|
53
|
+
webWalletUrl: xe = _t(),
|
|
54
54
|
enabledConnectTypes: Ce = ["web", "mobile", ...Object.keys(j)],
|
|
55
55
|
extraContent: G = null,
|
|
56
56
|
disableSwitchApp: T = !1,
|
|
@@ -62,7 +62,7 @@ function fe({
|
|
|
62
62
|
onRecreateSession: X = C,
|
|
63
63
|
setColor: Se = C
|
|
64
64
|
}) {
|
|
65
|
-
const A =
|
|
65
|
+
const A = at(), J = Qe(), ke = Ve(lt), we = vt(ke?.session?.user), {
|
|
66
66
|
t: Z,
|
|
67
67
|
staticState: Ie,
|
|
68
68
|
connectState: s,
|
|
@@ -74,8 +74,9 @@ function fe({
|
|
|
74
74
|
blocklet: $,
|
|
75
75
|
masterBlocklet: _e,
|
|
76
76
|
showWalletOptions: f,
|
|
77
|
-
setShowWalletOptions: De
|
|
78
|
-
|
|
77
|
+
setShowWalletOptions: De,
|
|
78
|
+
lastLoginMethod: Te
|
|
79
|
+
} = dt(), { state: o, generate: ee, cancelWhenScanned: Oe } = pt({
|
|
79
80
|
action: I,
|
|
80
81
|
baseUrl: g,
|
|
81
82
|
checkFn: v,
|
|
@@ -93,17 +94,17 @@ function fe({
|
|
|
93
94
|
saveConnect: he,
|
|
94
95
|
useSocket: be,
|
|
95
96
|
provider: ge
|
|
96
|
-
}), z = le(!1), te = le(null), x =
|
|
97
|
+
}), z = le(!1), te = le(null), x = Xe(te), oe = u(() => x ? x.width < N - 50 : !0, [x, x?.width]), [re, Re] = Ye(!1);
|
|
97
98
|
de(() => {
|
|
98
|
-
|
|
99
|
+
Re(x?.width < N - 50);
|
|
99
100
|
});
|
|
100
|
-
const { oauthState: c, setBaseUrl:
|
|
101
|
+
const { oauthState: c, setBaseUrl: Ae } = ht(), { passkeyState: l, setTargetAppPid: We } = gt();
|
|
101
102
|
de(() => {
|
|
102
|
-
|
|
103
|
+
Ae(g), We($?.appPid), o.reset(), c.reset(), l.reset();
|
|
103
104
|
}), ue(() => {
|
|
104
105
|
Se(W);
|
|
105
106
|
}, [W]);
|
|
106
|
-
const
|
|
107
|
+
const ze = u(() => ({
|
|
107
108
|
confirm: d.confirm,
|
|
108
109
|
success: d.success,
|
|
109
110
|
error: a?.state?.error || o.error || l.error || c.error || ""
|
|
@@ -116,34 +117,35 @@ function fe({
|
|
|
116
117
|
a?.state?.error
|
|
117
118
|
]), S = u(() => w.includes(l.status) || w.includes(c.status) || w.includes(o.status) || w.includes(a?.state?.computedStatus), [o.status, c.status, l.status, a?.state?.computedStatus]), ne = F(async () => {
|
|
118
119
|
X(), c.reset(), l.reset(), await ee(!1);
|
|
119
|
-
}), ze = F(() => {
|
|
120
|
-
s?.retryConnect();
|
|
121
120
|
}), Ee = F(() => {
|
|
122
|
-
|
|
123
|
-
}),
|
|
121
|
+
s?.retryConnect();
|
|
122
|
+
}), Le = F(() => {
|
|
123
|
+
X(), c.reset(), l.reset(), a?.state?.reset(), Ie.current.cancelCount++, Oe();
|
|
124
|
+
}), { run: Me } = Je(
|
|
124
125
|
() => {
|
|
125
126
|
z.current || o.status === "timeout" && (z.current = !0, o.reset(), ne(), z.current = !1);
|
|
126
127
|
},
|
|
127
128
|
{ leading: !0, trailing: !1 }
|
|
128
129
|
);
|
|
129
|
-
ue(
|
|
130
|
-
const
|
|
130
|
+
ue(Me, [o.status]);
|
|
131
|
+
const Ue = u(() => ot[s.chooseMethod] || "DID Wallet", [s.chooseMethod]), { providerList: Fe, hideQRCode: m, hideChooseList: r, loadingProviderList: Ne } = wt({
|
|
131
132
|
action: o.action,
|
|
132
133
|
sourceAppPid: s?.sourceAppPid,
|
|
133
134
|
allowWallet: V,
|
|
134
135
|
passkeyBehavior: Y,
|
|
135
136
|
mode: p,
|
|
136
137
|
blocklet: s?.sourceAppPid ? _e : $,
|
|
137
|
-
isSmallView: oe
|
|
138
|
-
|
|
139
|
-
Ze(
|
|
140
|
-
|
|
138
|
+
isSmallView: oe,
|
|
139
|
+
lastLoginMethod: Te
|
|
140
|
+
}), je = Ze(s?.sourceAppPid);
|
|
141
|
+
$e(() => {
|
|
142
|
+
et(je) || ee();
|
|
141
143
|
}, [s?.sourceAppPid]);
|
|
142
144
|
const n = (k) => {
|
|
143
145
|
const h = A.spacing(k);
|
|
144
146
|
return parseInt(h, 10);
|
|
145
|
-
},
|
|
146
|
-
|
|
147
|
+
}, Be = u(() => y ? null : /* @__PURE__ */ t(
|
|
148
|
+
tt,
|
|
147
149
|
{
|
|
148
150
|
onClose: O,
|
|
149
151
|
sx: {
|
|
@@ -164,39 +166,39 @@ function fe({
|
|
|
164
166
|
justifyContent: "center"
|
|
165
167
|
},
|
|
166
168
|
children: /* @__PURE__ */ t(i, { children: /* @__PURE__ */ t(
|
|
167
|
-
|
|
169
|
+
bt,
|
|
168
170
|
{
|
|
169
171
|
status: a?.state?.computedStatus || c.status || l.status || o.status,
|
|
170
172
|
nextWorkflow: o.nextWorkflow,
|
|
171
173
|
mfaCode: o.mfaCode,
|
|
172
|
-
onCancel:
|
|
173
|
-
onRetry:
|
|
174
|
+
onCancel: Le,
|
|
175
|
+
onRetry: Ee,
|
|
174
176
|
onClose: O,
|
|
175
|
-
messages:
|
|
177
|
+
messages: ze,
|
|
176
178
|
locale: q,
|
|
177
179
|
className: "did-connect__auth-status auth-status",
|
|
178
|
-
loadingIcon: s.chooseMethod ? /* @__PURE__ */ t(
|
|
179
|
-
chooseMethod:
|
|
180
|
+
loadingIcon: s.chooseMethod ? /* @__PURE__ */ t(ct, { provider: s.chooseMethod, sx: { color: "text.primary" } }) : null,
|
|
181
|
+
chooseMethod: Ue,
|
|
180
182
|
hideRetry: s.chooseMethod === "email",
|
|
181
183
|
hideBack: !!K
|
|
182
184
|
}
|
|
183
185
|
) })
|
|
184
186
|
}
|
|
185
187
|
));
|
|
186
|
-
const se =
|
|
188
|
+
const se = It({ disableSwitchApp: T, tokenState: o }), E = u(() => {
|
|
187
189
|
const k = A.mode === "dark" ? A.palette.grey[600] : "white";
|
|
188
|
-
let h = r ? 240 - n(3) * 2 : 196 - n(2) * 2,
|
|
189
|
-
return f && (
|
|
190
|
+
let h = r ? 240 - n(3) * 2 : 196 - n(2) * 2, U = r ? 3 : 2;
|
|
191
|
+
return f && (U = 1, h += n(U) * 2), /* @__PURE__ */ t(
|
|
190
192
|
i,
|
|
191
193
|
{
|
|
192
194
|
className: "did-connect__qrcode",
|
|
193
195
|
sx: {
|
|
194
|
-
p:
|
|
196
|
+
p: U,
|
|
195
197
|
width: (r ? 240 : 196) + n(1) * 2,
|
|
196
198
|
height: (r ? 240 : 196) + n(1) * 2
|
|
197
199
|
},
|
|
198
200
|
children: o.url ? /* @__PURE__ */ t(
|
|
199
|
-
|
|
201
|
+
it,
|
|
200
202
|
{
|
|
201
203
|
data: se,
|
|
202
204
|
size: h,
|
|
@@ -220,7 +222,7 @@ function fe({
|
|
|
220
222
|
}
|
|
221
223
|
}
|
|
222
224
|
) : /* @__PURE__ */ t(
|
|
223
|
-
|
|
225
|
+
Ge,
|
|
224
226
|
{
|
|
225
227
|
animation: "wave",
|
|
226
228
|
variant: "rectangular",
|
|
@@ -239,7 +241,7 @@ function fe({
|
|
|
239
241
|
)
|
|
240
242
|
}
|
|
241
243
|
);
|
|
242
|
-
}, [se, r, f]),
|
|
244
|
+
}, [se, r, f]), qe = u(() => r ? "column-reverse" : !m && re ? "column" : "row", [r, re, m]), ae = u(() => E ? /* @__PURE__ */ t(
|
|
243
245
|
i,
|
|
244
246
|
{
|
|
245
247
|
sx: {
|
|
@@ -289,7 +291,7 @@ function fe({
|
|
|
289
291
|
children: [
|
|
290
292
|
Z("scanWithWallet1"),
|
|
291
293
|
" ",
|
|
292
|
-
/* @__PURE__ */ t(
|
|
294
|
+
/* @__PURE__ */ t(kt, {}),
|
|
293
295
|
" ",
|
|
294
296
|
Z("scanWithWallet2")
|
|
295
297
|
]
|
|
@@ -299,13 +301,13 @@ function fe({
|
|
|
299
301
|
}
|
|
300
302
|
)
|
|
301
303
|
}
|
|
302
|
-
) : null, [E, r, f]),
|
|
304
|
+
) : null, [E, r, f]), L = /* @__PURE__ */ b(
|
|
303
305
|
i,
|
|
304
306
|
{
|
|
305
307
|
className: "did-connect__body",
|
|
306
308
|
sx: {
|
|
307
309
|
display: "flex",
|
|
308
|
-
flexDirection:
|
|
310
|
+
flexDirection: qe,
|
|
309
311
|
justifyContent: "center",
|
|
310
312
|
alignItems: "stretch",
|
|
311
313
|
flex: 1,
|
|
@@ -314,10 +316,10 @@ function fe({
|
|
|
314
316
|
px: r ? 2 : 0
|
|
315
317
|
},
|
|
316
318
|
children: [
|
|
317
|
-
!S && !m ? /* @__PURE__ */ b(
|
|
319
|
+
!S && !m ? /* @__PURE__ */ b(He, { children: [
|
|
318
320
|
ae,
|
|
319
321
|
r ? null : /* @__PURE__ */ t(i, { children: /* @__PURE__ */ t(
|
|
320
|
-
|
|
322
|
+
Ke,
|
|
321
323
|
{
|
|
322
324
|
orientation: "vertical",
|
|
323
325
|
sx: {
|
|
@@ -341,7 +343,7 @@ function fe({
|
|
|
341
343
|
children: [
|
|
342
344
|
ie,
|
|
343
345
|
/* @__PURE__ */ t(
|
|
344
|
-
|
|
346
|
+
ft,
|
|
345
347
|
{
|
|
346
348
|
slotProps: {
|
|
347
349
|
root: {
|
|
@@ -365,7 +367,7 @@ function fe({
|
|
|
365
367
|
magicToken: K,
|
|
366
368
|
baseUrl: g,
|
|
367
369
|
customItems: ye,
|
|
368
|
-
providerList:
|
|
370
|
+
providerList: Fe,
|
|
369
371
|
qrcode: ae
|
|
370
372
|
}
|
|
371
373
|
)
|
|
@@ -375,15 +377,15 @@ function fe({
|
|
|
375
377
|
]
|
|
376
378
|
}
|
|
377
379
|
);
|
|
378
|
-
let
|
|
379
|
-
a ?
|
|
380
|
-
fallback:
|
|
380
|
+
let M = L;
|
|
381
|
+
a ? M = a.renderPlaceholder({
|
|
382
|
+
fallback: L,
|
|
381
383
|
forceUpdate: J,
|
|
382
384
|
onSuccess: R,
|
|
383
385
|
onError: Q
|
|
384
|
-
}) :
|
|
385
|
-
const ce = m || S ?
|
|
386
|
-
return
|
|
386
|
+
}) : M = L;
|
|
387
|
+
const ce = m || S ? rt : N;
|
|
388
|
+
return Ne ? /* @__PURE__ */ t(Pt, {}) : /* @__PURE__ */ b(
|
|
387
389
|
i,
|
|
388
390
|
{
|
|
389
391
|
ref: te,
|
|
@@ -408,7 +410,7 @@ function fe({
|
|
|
408
410
|
children: [
|
|
409
411
|
/* @__PURE__ */ t(i, { "data-did-auth-url": o.url, sx: { display: "none" } }),
|
|
410
412
|
/* @__PURE__ */ t(
|
|
411
|
-
|
|
413
|
+
St,
|
|
412
414
|
{
|
|
413
415
|
title: d.title,
|
|
414
416
|
description: d.scan,
|
|
@@ -418,9 +420,9 @@ function fe({
|
|
|
418
420
|
onBack: () => De(!1)
|
|
419
421
|
}
|
|
420
422
|
),
|
|
421
|
-
/* @__PURE__ */ t(
|
|
422
|
-
/* @__PURE__ */ t(
|
|
423
|
-
|
|
423
|
+
/* @__PURE__ */ t(mt, { initHeight: 72, children: M }),
|
|
424
|
+
/* @__PURE__ */ t(st, { currentAppInfo: Pe, currentAppColor: W }),
|
|
425
|
+
Be
|
|
424
426
|
]
|
|
425
427
|
}
|
|
426
428
|
);
|
|
@@ -447,7 +449,7 @@ fe.propTypes = {
|
|
|
447
449
|
enabledConnectTypes: e.arrayOf(e.oneOf(["web", "mobile", ...Object.keys(j)])),
|
|
448
450
|
webWalletUrl: e.string,
|
|
449
451
|
allowWallet: e.bool,
|
|
450
|
-
provider: e.oneOf([
|
|
452
|
+
provider: e.oneOf([nt.WALLET, ...Object.keys(j), ""]),
|
|
451
453
|
hideCloseButton: e.bool,
|
|
452
454
|
disableSwitchApp: e.bool,
|
|
453
455
|
onClose: e.func,
|
|
@@ -458,12 +460,12 @@ fe.propTypes = {
|
|
|
458
460
|
magicToken: e.string,
|
|
459
461
|
customItems: e.arrayOf(e.node)
|
|
460
462
|
};
|
|
461
|
-
function
|
|
463
|
+
function Dt({ testOnlyBorderColor: y = void 0, ...p }) {
|
|
462
464
|
const { checkFn: I, extraParams: g = {}, blocklet: v, masterBlocklet: P, action: _, locale: D = "en" } = p;
|
|
463
465
|
if (typeof I != "function")
|
|
464
466
|
throw new Error("Cannot initialize did connect component without a fetchFn");
|
|
465
467
|
return /* @__PURE__ */ t(
|
|
466
|
-
|
|
468
|
+
ut,
|
|
467
469
|
{
|
|
468
470
|
blocklet: v,
|
|
469
471
|
masterBlocklet: P,
|
|
@@ -487,7 +489,7 @@ function _t({ testOnlyBorderColor: y = void 0, ...p }) {
|
|
|
487
489
|
}
|
|
488
490
|
);
|
|
489
491
|
}
|
|
490
|
-
|
|
492
|
+
Dt.propTypes = {
|
|
491
493
|
checkFn: e.func.isRequired,
|
|
492
494
|
extraParams: e.object,
|
|
493
495
|
blocklet: e.object.isRequired,
|
|
@@ -497,5 +499,5 @@ _t.propTypes = {
|
|
|
497
499
|
testOnlyBorderColor: e.string
|
|
498
500
|
};
|
|
499
501
|
export {
|
|
500
|
-
|
|
502
|
+
Dt as default
|
|
501
503
|
};
|
|
@@ -1,57 +1,64 @@
|
|
|
1
1
|
import { jsx as O } from "react/jsx-runtime";
|
|
2
2
|
import r from "prop-types";
|
|
3
|
-
import { useState as S, use as
|
|
3
|
+
import { useState as S, use as W, useRef as D, useEffect as V, createContext as X } from "react";
|
|
4
4
|
import Y from "@arcblock/react-hooks/lib/useBrowser";
|
|
5
|
-
import { useUpdate as Z, useCreation as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { Box as
|
|
9
|
-
import { translate as
|
|
10
|
-
import { getMaster as
|
|
11
|
-
import { getDIDMotifInfo as
|
|
12
|
-
import { isEthereumDid as
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import de from "
|
|
16
|
-
|
|
5
|
+
import { useUpdate as Z, useCreation as n, useMemoizedFn as h, useLatest as $, useReactive as ee, useSize as te } from "ahooks";
|
|
6
|
+
import E from "lodash/isUndefined";
|
|
7
|
+
import oe from "lodash/noop";
|
|
8
|
+
import { Box as re } from "@mui/material";
|
|
9
|
+
import { translate as ne } from "@arcblock/ux/lib/Locale/util";
|
|
10
|
+
import { getMaster as T, getCurrentApp as se } from "@arcblock/ux/lib/Util/federated";
|
|
11
|
+
import { getDIDMotifInfo as ie } from "@arcblock/did-motif";
|
|
12
|
+
import { isEthereumDid as ce, getDIDColor as pe } from "@arcblock/ux/lib/Util";
|
|
13
|
+
import { GA_LAST_LOGIN_METHOD as ue } from "@arcblock/ux/lib/withTracker/constant";
|
|
14
|
+
import ae from "../hooks/use-apps.js";
|
|
15
|
+
import { SessionContext as de } from "../../Session/context.js";
|
|
16
|
+
import le from "../assets/locale.js";
|
|
17
|
+
const x = X({
|
|
17
18
|
isWalletWebview: !1,
|
|
18
19
|
isMobile: !1,
|
|
19
20
|
matchSmallScreen: !1,
|
|
20
21
|
blocklet: null
|
|
21
|
-
}), { Provider:
|
|
22
|
-
function
|
|
23
|
-
children:
|
|
24
|
-
blocklet:
|
|
22
|
+
}), { Provider: fe, Consumer: We } = x;
|
|
23
|
+
function me({
|
|
24
|
+
children: R,
|
|
25
|
+
blocklet: c,
|
|
25
26
|
masterBlocklet: P = void 0,
|
|
26
|
-
action:
|
|
27
|
+
action: a,
|
|
27
28
|
extraParams: t = {},
|
|
28
|
-
locale:
|
|
29
|
+
locale: d = "en",
|
|
29
30
|
testOnlyBorderColor: l = void 0,
|
|
30
|
-
...
|
|
31
|
+
...L
|
|
31
32
|
}) {
|
|
32
|
-
const w = Z(), [f,
|
|
33
|
+
const w = Z(), [f, j] = S([]), [N, q] = S(!1), [m, z] = S(""), G = n(() => new Map(f.map((e) => [e.name, e])), [f]), J = h((e) => G.get(e)), U = $(m), _ = h((e, i = {}) => ne(le, e, d, "en", i)), g = W(de), o = ee({
|
|
33
34
|
sourceAppPid: void 0,
|
|
34
35
|
status: "created",
|
|
35
36
|
autoActiveWebview: !0,
|
|
36
37
|
deeplink: void 0,
|
|
37
38
|
chooseMethod: "",
|
|
38
|
-
retryConnect:
|
|
39
|
-
}),
|
|
39
|
+
retryConnect: oe
|
|
40
|
+
}), k = D({
|
|
40
41
|
cancelCount: 0
|
|
41
|
-
}),
|
|
42
|
-
blocklet:
|
|
42
|
+
}), s = Y(), { appInfoList: b, autoGenerateSourceAppPid: A, canSwitchApp: v } = ae({
|
|
43
|
+
blocklet: c,
|
|
43
44
|
connectState: o,
|
|
44
|
-
action:
|
|
45
|
+
action: a,
|
|
45
46
|
sourceAppPid: t?.sourceAppPid,
|
|
46
47
|
enableSwitchApp: t?.forceSwitch || t?.enableSwitchApp
|
|
47
|
-
}),
|
|
48
|
+
}), B = n(() => {
|
|
49
|
+
try {
|
|
50
|
+
return localStorage.getItem(ue);
|
|
51
|
+
} catch {
|
|
52
|
+
return "";
|
|
53
|
+
}
|
|
54
|
+
}, []), C = D(null), M = te(C), y = n(() => (M?.width || 0) < 500, [M?.width]), p = n(() => {
|
|
48
55
|
if (v)
|
|
49
56
|
return {
|
|
50
57
|
...t,
|
|
51
|
-
sourceAppPid:
|
|
58
|
+
sourceAppPid: E(o.sourceAppPid) ? A : o.sourceAppPid
|
|
52
59
|
};
|
|
53
|
-
const e =
|
|
54
|
-
return g?.session?.user && (e ===
|
|
60
|
+
const e = T(c)?.appPid, i = T(globalThis.blocklet)?.appPid;
|
|
61
|
+
return g?.session?.user && (e === i || !e) ? E(t?.sourceAppPid) ? {
|
|
55
62
|
...t,
|
|
56
63
|
sourceAppPid: g.session.user?.sourceAppPid
|
|
57
64
|
} : t : {
|
|
@@ -62,70 +69,72 @@ function le({
|
|
|
62
69
|
v,
|
|
63
70
|
t,
|
|
64
71
|
o.sourceAppPid,
|
|
65
|
-
|
|
72
|
+
a,
|
|
66
73
|
A,
|
|
67
74
|
g?.session?.user
|
|
68
|
-
]),
|
|
75
|
+
]), F = n(() => {
|
|
69
76
|
const e = window?.navigator?.userAgent;
|
|
70
77
|
return e.indexOf("Edge") > -1 || e.indexOf("Edg") > -1 ? "edge" : e.indexOf("Chrome") > -1 ? "chrome" : "unknown";
|
|
71
78
|
}, []);
|
|
72
79
|
V(() => {
|
|
73
|
-
o.sourceAppPid =
|
|
74
|
-
}, [
|
|
80
|
+
o.sourceAppPid = p.sourceAppPid;
|
|
81
|
+
}, [p.sourceAppPid]);
|
|
75
82
|
const H = h((e) => {
|
|
76
83
|
o.status = e || "created";
|
|
77
|
-
}), u = globalThis.blocklet ?
|
|
84
|
+
}), u = globalThis.blocklet ? se(c) : globalThis.env, I = n(() => {
|
|
78
85
|
if (l)
|
|
79
86
|
return l;
|
|
80
|
-
const e = u.appPid,
|
|
81
|
-
return
|
|
82
|
-
}, [u.appId, l]), K =
|
|
83
|
-
isWalletWebview:
|
|
84
|
-
isMobile:
|
|
87
|
+
const e = u.appPid, i = ce(e), Q = i ? void 0 : ie(e);
|
|
88
|
+
return i ? pe(e) : Q.color;
|
|
89
|
+
}, [u.appId, l]), K = n(() => ({
|
|
90
|
+
isWalletWebview: s.wallet || s.arcSphere,
|
|
91
|
+
isMobile: s.mobile.any,
|
|
85
92
|
matchSmallScreen: y,
|
|
86
93
|
connectState: o,
|
|
87
|
-
staticState:
|
|
94
|
+
staticState: k,
|
|
88
95
|
reactiveState: o,
|
|
89
96
|
appInfoList: b,
|
|
90
|
-
extraParams:
|
|
91
|
-
blocklet:
|
|
97
|
+
extraParams: p,
|
|
98
|
+
blocklet: c,
|
|
92
99
|
masterBlocklet: P,
|
|
93
|
-
browserBrand:
|
|
100
|
+
browserBrand: F,
|
|
94
101
|
currentAppInfo: u,
|
|
95
102
|
currentAppColor: I,
|
|
96
|
-
t:
|
|
97
|
-
locale:
|
|
98
|
-
action:
|
|
103
|
+
t: _,
|
|
104
|
+
locale: d,
|
|
105
|
+
action: a,
|
|
99
106
|
changeStatus: H,
|
|
100
|
-
getPlugin:
|
|
101
|
-
latestActivePlugin:
|
|
107
|
+
getPlugin: J,
|
|
108
|
+
latestActivePlugin: U,
|
|
102
109
|
plugins: f,
|
|
103
|
-
setPlugins:
|
|
110
|
+
setPlugins: j,
|
|
104
111
|
selectedPlugin: m,
|
|
105
|
-
setSelectedPlugin:
|
|
112
|
+
setSelectedPlugin: z,
|
|
106
113
|
forceUpdate: w,
|
|
107
114
|
// 控制钱包登录的显示
|
|
108
|
-
showWalletOptions:
|
|
109
|
-
setShowWalletOptions:
|
|
115
|
+
showWalletOptions: N,
|
|
116
|
+
setShowWalletOptions: q,
|
|
117
|
+
// 用于记录上一次登录方式
|
|
118
|
+
lastLoginMethod: B
|
|
110
119
|
}), [
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
120
|
+
s.wallet,
|
|
121
|
+
s.arcSphere,
|
|
122
|
+
s.mobile.any,
|
|
114
123
|
y,
|
|
115
124
|
JSON.stringify(o),
|
|
116
125
|
JSON.stringify(b),
|
|
117
|
-
JSON.stringify(
|
|
118
|
-
|
|
126
|
+
JSON.stringify(p),
|
|
127
|
+
c,
|
|
119
128
|
P,
|
|
120
|
-
|
|
129
|
+
d,
|
|
121
130
|
m,
|
|
122
131
|
w,
|
|
123
132
|
u,
|
|
124
133
|
I
|
|
125
134
|
]);
|
|
126
|
-
return /* @__PURE__ */ O(
|
|
135
|
+
return /* @__PURE__ */ O(fe, { value: K, children: /* @__PURE__ */ O(re, { ...L, ref: C, children: R }) });
|
|
127
136
|
}
|
|
128
|
-
|
|
137
|
+
me.propTypes = {
|
|
129
138
|
children: r.any.isRequired,
|
|
130
139
|
blocklet: r.object.isRequired,
|
|
131
140
|
masterBlocklet: r.object,
|
|
@@ -135,11 +144,11 @@ le.propTypes = {
|
|
|
135
144
|
testOnlyBorderColor: r.string
|
|
136
145
|
};
|
|
137
146
|
function xe() {
|
|
138
|
-
return
|
|
147
|
+
return W(x);
|
|
139
148
|
}
|
|
140
149
|
export {
|
|
141
150
|
We as StateConsumer,
|
|
142
|
-
|
|
143
|
-
|
|
151
|
+
x as StateContext,
|
|
152
|
+
me as StateProvider,
|
|
144
153
|
xe as useStateContext
|
|
145
154
|
};
|