@blocklet/did-space-react 1.0.4 → 1.0.6
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/dist/cjs/components/auth-connect-to/index.d.ts +1 -1
- package/dist/cjs/components/base-connect-to/index.d.ts +3 -3
- package/dist/cjs/components/base-connect-to/index.js +20 -5
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/libs/constants.d.ts +1 -0
- package/dist/cjs/libs/constants.js +2 -0
- package/dist/cjs/locales/en.js +1 -1
- package/dist/cjs/locales/zh.js +1 -1
- package/dist/cjs/package.json.js +1 -1
- package/dist/es/components/auth-connect-to/index.d.ts +1 -1
- package/dist/es/components/base-connect-to/index.d.ts +3 -3
- package/dist/es/components/base-connect-to/index.js +22 -7
- package/dist/es/index.js +1 -1
- package/dist/es/libs/constants.d.ts +1 -0
- package/dist/es/libs/constants.js +2 -1
- package/dist/es/locales/en.js +1 -1
- package/dist/es/locales/zh.js +1 -1
- package/dist/es/package.json.js +1 -1
- package/package.json +7 -7
|
@@ -5,7 +5,7 @@ import { BaseAuth, type BaseAuthProps } from './base-auth';
|
|
|
5
5
|
import { BaseAuthOptions, DIDSpaceGateway } from '../../types';
|
|
6
6
|
export interface DIDSpaceConnectOptions extends BaseAuthOptions, Record<string, any> {
|
|
7
7
|
}
|
|
8
|
-
export interface DIDSpaceConnectProps extends
|
|
8
|
+
export interface DIDSpaceConnectProps extends Omit<ButtonProps, 'onClick' | 'onError'> {
|
|
9
9
|
session?: {
|
|
10
10
|
refresh: Function;
|
|
11
11
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface BaseConnectToProps extends Omit<
|
|
1
|
+
import { ButtonProps } from '@mui/material';
|
|
2
|
+
export interface BaseConnectToProps extends Omit<ButtonProps, 'onClick'> {
|
|
3
3
|
onWalletClick?: () => void;
|
|
4
4
|
onGatewayConfirm?: (params: {
|
|
5
5
|
spaceDid: string;
|
|
@@ -7,4 +7,4 @@ export interface BaseConnectToProps extends Omit<SplitButtonProps, 'menu' | 'onC
|
|
|
7
7
|
}) => void;
|
|
8
8
|
}
|
|
9
9
|
/** 基础连接按钮组件,只负责前端 ux */
|
|
10
|
-
export declare function BaseConnectTo({
|
|
10
|
+
export declare function BaseConnectTo({ sx, onWalletClick, onGatewayConfirm, ...rest }: BaseConnectToProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -14,7 +14,7 @@ const util = require('../../libs/util.js');
|
|
|
14
14
|
const gateway = require('../../libs/gateway.js');
|
|
15
15
|
const useLocale = require('../../hooks/use-locale.js');
|
|
16
16
|
|
|
17
|
-
function BaseConnectTo({
|
|
17
|
+
function BaseConnectTo({ sx, onWalletClick, onGatewayConfirm, ...rest }) {
|
|
18
18
|
const { t, locale } = useLocale();
|
|
19
19
|
const [url, setUrl] = React.useState("");
|
|
20
20
|
const [loading, setLoading] = React.useState(false);
|
|
@@ -50,8 +50,20 @@ function BaseConnectTo({ style, onWalletClick, onGatewayConfirm, ...rest }) {
|
|
|
50
50
|
setCorsBlocked(false);
|
|
51
51
|
setOpen(true);
|
|
52
52
|
};
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
let button = /* @__PURE__ */ jsxRuntime.jsx(
|
|
54
|
+
Button,
|
|
55
|
+
{
|
|
56
|
+
variant: "contained",
|
|
57
|
+
color: "primary",
|
|
58
|
+
sx: { textTransform: "none", fontWeight: "bold", fontSize: "1rem", ...sx },
|
|
59
|
+
size: "small",
|
|
60
|
+
...rest,
|
|
61
|
+
onClick: onWalletClick,
|
|
62
|
+
children: t("storage.spaces.connect.useWallet")
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
if (constants.isDebugMode) {
|
|
66
|
+
button = /* @__PURE__ */ jsxRuntime.jsx(
|
|
55
67
|
SplitButton,
|
|
56
68
|
{
|
|
57
69
|
menu: [
|
|
@@ -70,13 +82,16 @@ function BaseConnectTo({ style, onWalletClick, onGatewayConfirm, ...rest }) {
|
|
|
70
82
|
)
|
|
71
83
|
],
|
|
72
84
|
color: "primary",
|
|
73
|
-
|
|
85
|
+
sx: { textTransform: "none", fontWeight: "bold", fontSize: "1rem", ...sx },
|
|
74
86
|
size: "small",
|
|
75
87
|
...rest,
|
|
76
88
|
onClick: onWalletClick,
|
|
77
89
|
children: /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { sx: { fontWeight: "bold", textTransform: "none" }, children: t("storage.spaces.connect.useWallet") })
|
|
78
90
|
}
|
|
79
|
-
)
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
94
|
+
button,
|
|
80
95
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
81
96
|
Dialog,
|
|
82
97
|
{
|
package/dist/cjs/index.js
CHANGED
|
@@ -40,6 +40,7 @@ exports.AUTHORIZE = constants.AUTHORIZE;
|
|
|
40
40
|
exports.SPACE_CONNECT_ERROR_CODE = constants.SPACE_CONNECT_ERROR_CODE;
|
|
41
41
|
exports.copyGatewayPageUrl = constants.copyGatewayPageUrl;
|
|
42
42
|
exports.fixCorsErrorPageUrl = constants.fixCorsErrorPageUrl;
|
|
43
|
+
exports.isDebugMode = constants.isDebugMode;
|
|
43
44
|
exports.classNames = util.classNames;
|
|
44
45
|
exports.decryptSpaceGateway = util.decryptSpaceGateway;
|
|
45
46
|
exports.extraDIDSpacesCoreUrl = util.extraDIDSpacesCoreUrl;
|
|
@@ -21,3 +21,4 @@ export declare const AUTHORIZE: {
|
|
|
21
21
|
};
|
|
22
22
|
export declare const copyGatewayPageUrl = "https://www.arcblock.io/content/docs/did-spaces/how-to-obtain-space-gateway-url";
|
|
23
23
|
export declare const fixCorsErrorPageUrl = "https://www.arcblock.io/docs/did-spaces/fixing-cors-errors-when-connecting-to-space";
|
|
24
|
+
export declare const isDebugMode: boolean;
|
|
@@ -23,8 +23,10 @@ const AUTHORIZE = {
|
|
|
23
23
|
};
|
|
24
24
|
const copyGatewayPageUrl = "https://www.arcblock.io/content/docs/did-spaces/how-to-obtain-space-gateway-url";
|
|
25
25
|
const fixCorsErrorPageUrl = "https://www.arcblock.io/docs/did-spaces/fixing-cors-errors-when-connecting-to-space";
|
|
26
|
+
const isDebugMode = window.blocklet?.DEBUG_MODE === "true" || window.localStorage.getItem("debug") === "true";
|
|
26
27
|
|
|
27
28
|
exports.AUTHORIZE = AUTHORIZE;
|
|
28
29
|
exports.SPACE_CONNECT_ERROR_CODE = SPACE_CONNECT_ERROR_CODE;
|
|
29
30
|
exports.copyGatewayPageUrl = copyGatewayPageUrl;
|
|
30
31
|
exports.fixCorsErrorPageUrl = fixCorsErrorPageUrl;
|
|
32
|
+
exports.isDebugMode = isDebugMode;
|
package/dist/cjs/locales/en.js
CHANGED
|
@@ -23,7 +23,7 @@ const en = flat.flatten({
|
|
|
23
23
|
connect: {
|
|
24
24
|
reconnect: "Reconnect Now",
|
|
25
25
|
useSpaceGateway: "Connect using the DID Spaces gateway",
|
|
26
|
-
useWallet: "Connect
|
|
26
|
+
useWallet: "Connect to DID Spaces",
|
|
27
27
|
howToGetGatewayUrl: "How to get the url of did spaces",
|
|
28
28
|
providerForStorage: "Please connect your DID Spaces"
|
|
29
29
|
},
|
package/dist/cjs/locales/zh.js
CHANGED
|
@@ -23,7 +23,7 @@ const zh = flat.flatten({
|
|
|
23
23
|
connect: {
|
|
24
24
|
reconnect: "\u7ACB\u5373\u91CD\u8FDE",
|
|
25
25
|
useSpaceGateway: "\u4F7F\u7528 DID Spaces \u7F51\u5173\u8FDE\u63A5",
|
|
26
|
-
useWallet: "\
|
|
26
|
+
useWallet: "\u8FDE\u63A5\u81F3 DID Spaces",
|
|
27
27
|
howToGetGatewayUrl: "\u5982\u4F55\u83B7\u53D6 DID Spaces \u7684\u7F51\u5173\u5730\u5740",
|
|
28
28
|
providerForStorage: "\u8BF7\u8FDE\u63A5\u60A8\u7684 DID Spaces"
|
|
29
29
|
},
|
package/dist/cjs/package.json.js
CHANGED
|
@@ -5,7 +5,7 @@ import { BaseAuth, type BaseAuthProps } from './base-auth';
|
|
|
5
5
|
import { BaseAuthOptions, DIDSpaceGateway } from '../../types';
|
|
6
6
|
export interface DIDSpaceConnectOptions extends BaseAuthOptions, Record<string, any> {
|
|
7
7
|
}
|
|
8
|
-
export interface DIDSpaceConnectProps extends
|
|
8
|
+
export interface DIDSpaceConnectProps extends Omit<ButtonProps, 'onClick' | 'onError'> {
|
|
9
9
|
session?: {
|
|
10
10
|
refresh: Function;
|
|
11
11
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface BaseConnectToProps extends Omit<
|
|
1
|
+
import { ButtonProps } from '@mui/material';
|
|
2
|
+
export interface BaseConnectToProps extends Omit<ButtonProps, 'onClick'> {
|
|
3
3
|
onWalletClick?: () => void;
|
|
4
4
|
onGatewayConfirm?: (params: {
|
|
5
5
|
spaceDid: string;
|
|
@@ -7,4 +7,4 @@ export interface BaseConnectToProps extends Omit<SplitButtonProps, 'menu' | 'onC
|
|
|
7
7
|
}) => void;
|
|
8
8
|
}
|
|
9
9
|
/** 基础连接按钮组件,只负责前端 ux */
|
|
10
|
-
export declare function BaseConnectTo({
|
|
10
|
+
export declare function BaseConnectTo({ sx, onWalletClick, onGatewayConfirm, ...rest }: BaseConnectToProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsxs, Fragment
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { Typography, CircularProgress, DialogContentText, TextField, Tooltip, Link } from '@mui/material';
|
|
4
4
|
import HelpOutlineIcon from '@mui/icons-material/HelpOutline';
|
|
@@ -7,12 +7,12 @@ import SplitButton from '@arcblock/ux/lib/SplitButton';
|
|
|
7
7
|
import Dialog from '@arcblock/ux/lib/Dialog';
|
|
8
8
|
import { withQuery } from 'ufo';
|
|
9
9
|
import { AxiosError } from 'axios';
|
|
10
|
-
import { copyGatewayPageUrl, fixCorsErrorPageUrl } from '../../libs/constants.js';
|
|
10
|
+
import { isDebugMode, copyGatewayPageUrl, fixCorsErrorPageUrl } from '../../libs/constants.js';
|
|
11
11
|
import { extraDIDSpacesCoreUrl, getSpaceDidFromSpaceUrl, isCorsBlockedError } from '../../libs/util.js';
|
|
12
12
|
import { getSpaceGatewayUrl, verifySpaceUrl } from '../../libs/gateway.js';
|
|
13
13
|
import useLocale from '../../hooks/use-locale.js';
|
|
14
14
|
|
|
15
|
-
function BaseConnectTo({
|
|
15
|
+
function BaseConnectTo({ sx, onWalletClick, onGatewayConfirm, ...rest }) {
|
|
16
16
|
const { t, locale } = useLocale();
|
|
17
17
|
const [url, setUrl] = useState("");
|
|
18
18
|
const [loading, setLoading] = useState(false);
|
|
@@ -48,8 +48,20 @@ function BaseConnectTo({ style, onWalletClick, onGatewayConfirm, ...rest }) {
|
|
|
48
48
|
setCorsBlocked(false);
|
|
49
49
|
setOpen(true);
|
|
50
50
|
};
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
let button = /* @__PURE__ */ jsx(
|
|
52
|
+
Button,
|
|
53
|
+
{
|
|
54
|
+
variant: "contained",
|
|
55
|
+
color: "primary",
|
|
56
|
+
sx: { textTransform: "none", fontWeight: "bold", fontSize: "1rem", ...sx },
|
|
57
|
+
size: "small",
|
|
58
|
+
...rest,
|
|
59
|
+
onClick: onWalletClick,
|
|
60
|
+
children: t("storage.spaces.connect.useWallet")
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
if (isDebugMode) {
|
|
64
|
+
button = /* @__PURE__ */ jsx(
|
|
53
65
|
SplitButton,
|
|
54
66
|
{
|
|
55
67
|
menu: [
|
|
@@ -68,13 +80,16 @@ function BaseConnectTo({ style, onWalletClick, onGatewayConfirm, ...rest }) {
|
|
|
68
80
|
)
|
|
69
81
|
],
|
|
70
82
|
color: "primary",
|
|
71
|
-
|
|
83
|
+
sx: { textTransform: "none", fontWeight: "bold", fontSize: "1rem", ...sx },
|
|
72
84
|
size: "small",
|
|
73
85
|
...rest,
|
|
74
86
|
onClick: onWalletClick,
|
|
75
87
|
children: /* @__PURE__ */ jsx(Typography, { sx: { fontWeight: "bold", textTransform: "none" }, children: t("storage.spaces.connect.useWallet") })
|
|
76
88
|
}
|
|
77
|
-
)
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
92
|
+
button,
|
|
78
93
|
/* @__PURE__ */ jsx(
|
|
79
94
|
Dialog,
|
|
80
95
|
{
|
package/dist/es/index.js
CHANGED
|
@@ -6,7 +6,7 @@ export { DIDSpaceConnection, SpaceCard } from './components/space-card/index.js'
|
|
|
6
6
|
export { DIDSpaceNFTPreview, PreviewSpaceNft } from './components/preview-space-nft/index.js';
|
|
7
7
|
export { AuthConnectTo, DIDSpaceConnect, ReConnect, SessionConnectTo } from './components/auth-connect-to/index.js';
|
|
8
8
|
export { BaseConnectTo } from './components/base-connect-to/index.js';
|
|
9
|
-
export { AUTHORIZE, SPACE_CONNECT_ERROR_CODE, copyGatewayPageUrl, fixCorsErrorPageUrl } from './libs/constants.js';
|
|
9
|
+
export { AUTHORIZE, SPACE_CONNECT_ERROR_CODE, copyGatewayPageUrl, fixCorsErrorPageUrl, isDebugMode } from './libs/constants.js';
|
|
10
10
|
export { classNames, decryptSpaceGateway, extraDIDSpacesCoreUrl, getSpaceDidFromEndpoint, getSpaceDidFromSpaceUrl, getSpaceGatewayUrlFromEndpoint, getSpaceNftDisplayUrlFromEndpoint, getSpaceUrlFromEndpoint, isCorsBlockedError, t } from './libs/util.js';
|
|
11
11
|
export { getSpaceGatewayUrl, verifySpaceUrl } from './libs/gateway.js';
|
|
12
12
|
export { translations } from './locales/index.js';
|
|
@@ -21,3 +21,4 @@ export declare const AUTHORIZE: {
|
|
|
21
21
|
};
|
|
22
22
|
export declare const copyGatewayPageUrl = "https://www.arcblock.io/content/docs/did-spaces/how-to-obtain-space-gateway-url";
|
|
23
23
|
export declare const fixCorsErrorPageUrl = "https://www.arcblock.io/docs/did-spaces/fixing-cors-errors-when-connecting-to-space";
|
|
24
|
+
export declare const isDebugMode: boolean;
|
|
@@ -21,5 +21,6 @@ const AUTHORIZE = {
|
|
|
21
21
|
};
|
|
22
22
|
const copyGatewayPageUrl = "https://www.arcblock.io/content/docs/did-spaces/how-to-obtain-space-gateway-url";
|
|
23
23
|
const fixCorsErrorPageUrl = "https://www.arcblock.io/docs/did-spaces/fixing-cors-errors-when-connecting-to-space";
|
|
24
|
+
const isDebugMode = window.blocklet?.DEBUG_MODE === "true" || window.localStorage.getItem("debug") === "true";
|
|
24
25
|
|
|
25
|
-
export { AUTHORIZE, SPACE_CONNECT_ERROR_CODE, copyGatewayPageUrl, fixCorsErrorPageUrl };
|
|
26
|
+
export { AUTHORIZE, SPACE_CONNECT_ERROR_CODE, copyGatewayPageUrl, fixCorsErrorPageUrl, isDebugMode };
|
package/dist/es/locales/en.js
CHANGED
|
@@ -21,7 +21,7 @@ const en = flatten({
|
|
|
21
21
|
connect: {
|
|
22
22
|
reconnect: "Reconnect Now",
|
|
23
23
|
useSpaceGateway: "Connect using the DID Spaces gateway",
|
|
24
|
-
useWallet: "Connect
|
|
24
|
+
useWallet: "Connect to DID Spaces",
|
|
25
25
|
howToGetGatewayUrl: "How to get the url of did spaces",
|
|
26
26
|
providerForStorage: "Please connect your DID Spaces"
|
|
27
27
|
},
|
package/dist/es/locales/zh.js
CHANGED
|
@@ -21,7 +21,7 @@ const zh = flatten({
|
|
|
21
21
|
connect: {
|
|
22
22
|
reconnect: "\u7ACB\u5373\u91CD\u8FDE",
|
|
23
23
|
useSpaceGateway: "\u4F7F\u7528 DID Spaces \u7F51\u5173\u8FDE\u63A5",
|
|
24
|
-
useWallet: "\
|
|
24
|
+
useWallet: "\u8FDE\u63A5\u81F3 DID Spaces",
|
|
25
25
|
howToGetGatewayUrl: "\u5982\u4F55\u83B7\u53D6 DID Spaces \u7684\u7F51\u5173\u5730\u5740",
|
|
26
26
|
providerForStorage: "\u8BF7\u8FDE\u63A5\u60A8\u7684 DID Spaces"
|
|
27
27
|
},
|
package/dist/es/package.json.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/did-space-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Reusable react components for did space",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
}
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@arcblock/did": "^1.19.
|
|
83
|
+
"@arcblock/did": "^1.19.6",
|
|
84
84
|
"@mui/icons-material": "^5.16.14",
|
|
85
85
|
"@mui/lab": "^5.0.0-alpha.175",
|
|
86
86
|
"@mui/material": "^5.16.14",
|
|
@@ -114,8 +114,8 @@
|
|
|
114
114
|
"@babel/preset-env": "^7.26.0",
|
|
115
115
|
"@babel/preset-react": "^7.26.3",
|
|
116
116
|
"@babel/preset-typescript": "^7.26.0",
|
|
117
|
-
"@blocklet/js-sdk": "^1.16.38-beta-
|
|
118
|
-
"@blocklet/sdk": "^1.16.38-beta-
|
|
117
|
+
"@blocklet/js-sdk": "^1.16.38-beta-20250116-083413-dbd33222",
|
|
118
|
+
"@blocklet/sdk": "^1.16.38-beta-20250116-083413-dbd33222",
|
|
119
119
|
"@storybook/addon-essentials": "^7.6.20",
|
|
120
120
|
"@storybook/addon-interactions": "^7.6.20",
|
|
121
121
|
"@storybook/addon-links": "^7.6.20",
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
"@types/react": "^18.3.18",
|
|
129
129
|
"@types/react-dom": "^18.3.5",
|
|
130
130
|
"@vitejs/plugin-legacy": "^5.4.3",
|
|
131
|
-
"@vitest/coverage-v8": "^3.0.
|
|
131
|
+
"@vitest/coverage-v8": "^3.0.1",
|
|
132
132
|
"babel-plugin-inline-react-svg": "^2.0.2",
|
|
133
133
|
"copyfiles": "^2.4.1",
|
|
134
134
|
"eslint": "^8.57.1",
|
|
@@ -145,7 +145,7 @@
|
|
|
145
145
|
"vite": "^5.4.11",
|
|
146
146
|
"vite-plugin-babel": "^1.3.0",
|
|
147
147
|
"vite-plugin-node-polyfills": "^0.22.0",
|
|
148
|
-
"vitest": "^3.0.
|
|
148
|
+
"vitest": "^3.0.1"
|
|
149
149
|
},
|
|
150
|
-
"gitHead": "
|
|
150
|
+
"gitHead": "63862b123c6d3af083a603e062269ee342f4e9eb"
|
|
151
151
|
}
|