@blocklet/did-space-react 1.0.5 → 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.
@@ -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 BaseConnectToProps {
8
+ export interface DIDSpaceConnectProps extends Omit<ButtonProps, 'onClick' | 'onError'> {
9
9
  session?: {
10
10
  refresh: Function;
11
11
  };
@@ -1,5 +1,5 @@
1
- import { SplitButtonProps } from '@arcblock/ux/lib/SplitButton';
2
- export interface BaseConnectToProps extends Omit<SplitButtonProps, 'menu' | 'onClick' | 'onError'> {
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({ style, onWalletClick, onGatewayConfirm, ...rest }: BaseConnectToProps): import("react/jsx-runtime").JSX.Element;
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({ style, onWalletClick, onGatewayConfirm, ...rest }) {
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
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
54
- /* @__PURE__ */ jsxRuntime.jsx(
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
- style: { textTransform: "none !important", fontSize: "1rem", ...style },
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;
@@ -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 with DID Wallet",
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
  },
@@ -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: "\u4F7F\u7528 DID Wallet \u8FDE\u63A5",
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
  },
@@ -1,5 +1,5 @@
1
1
  'use strict';
2
2
 
3
- const version = "1.0.5";
3
+ const version = "1.0.6";
4
4
 
5
5
  exports.version = version;
@@ -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 BaseConnectToProps {
8
+ export interface DIDSpaceConnectProps extends Omit<ButtonProps, 'onClick' | 'onError'> {
9
9
  session?: {
10
10
  refresh: Function;
11
11
  };
@@ -1,5 +1,5 @@
1
- import { SplitButtonProps } from '@arcblock/ux/lib/SplitButton';
2
- export interface BaseConnectToProps extends Omit<SplitButtonProps, 'menu' | 'onClick' | 'onError'> {
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({ style, onWalletClick, onGatewayConfirm, ...rest }: BaseConnectToProps): import("react/jsx-runtime").JSX.Element;
10
+ export declare function BaseConnectTo({ sx, onWalletClick, onGatewayConfirm, ...rest }: BaseConnectToProps): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,4 @@
1
- import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
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({ style, onWalletClick, onGatewayConfirm, ...rest }) {
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
- return /* @__PURE__ */ jsxs(Fragment, { children: [
52
- /* @__PURE__ */ jsx(
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
- style: { textTransform: "none !important", fontSize: "1rem", ...style },
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 };
@@ -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 with DID Wallet",
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
  },
@@ -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: "\u4F7F\u7528 DID Wallet \u8FDE\u63A5",
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
  },
@@ -1,3 +1,3 @@
1
- const version = "1.0.5";
1
+ const version = "1.0.6";
2
2
 
3
3
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/did-space-react",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Reusable react components for did space",
5
5
  "keywords": [
6
6
  "react",
@@ -147,5 +147,5 @@
147
147
  "vite-plugin-node-polyfills": "^0.22.0",
148
148
  "vitest": "^3.0.1"
149
149
  },
150
- "gitHead": "9d97ee3e4dbe423716465cd7910cca2e0f44dc76"
150
+ "gitHead": "63862b123c6d3af083a603e062269ee342f4e9eb"
151
151
  }