@0xchain/providers 1.1.0-beta.4 → 1.1.0-beta.43
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/LICENSE +21 -0
- package/dist/TopProgressBarProvider.js +30 -22
- package/dist/app-shell.d.ts +17 -0
- package/dist/app-shell.d.ts.map +1 -0
- package/dist/app-shell.js +26 -0
- package/dist/theme.js +14 -14
- package/package.json +25 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-present 0xchain
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsxs
|
|
3
|
-
import { createContext
|
|
4
|
-
import { usePathname
|
|
5
|
-
import { twMerge
|
|
6
|
-
const
|
|
2
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useState, useEffect } from "react";
|
|
4
|
+
import { usePathname } from "next/navigation";
|
|
5
|
+
import { twMerge } from "tailwind-merge";
|
|
6
|
+
const ProgressContext = createContext({
|
|
7
7
|
start: () => {
|
|
8
8
|
console.log("start");
|
|
9
9
|
},
|
|
@@ -11,33 +11,41 @@ const r = p({
|
|
|
11
11
|
console.log("done");
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
|
-
function
|
|
15
|
-
return
|
|
14
|
+
function useProgressBar() {
|
|
15
|
+
return useContext(ProgressContext);
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
const [
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
function TopProgressBarProvider({ children }) {
|
|
18
|
+
const [loading, setLoading] = useState(false);
|
|
19
|
+
const [complete, setComplete] = useState(false);
|
|
20
|
+
const pathname = usePathname();
|
|
21
|
+
const start = () => {
|
|
22
|
+
setComplete(false);
|
|
23
|
+
setLoading(true);
|
|
24
|
+
};
|
|
25
|
+
const done = () => {
|
|
26
|
+
setComplete(true);
|
|
27
|
+
setTimeout(() => {
|
|
28
|
+
setLoading(false);
|
|
29
|
+
setComplete(false);
|
|
23
30
|
}, 300);
|
|
24
31
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}, [
|
|
28
|
-
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
done();
|
|
34
|
+
}, [pathname]);
|
|
35
|
+
return /* @__PURE__ */ jsxs(ProgressContext.Provider, { value: { start, done }, children: [
|
|
36
|
+
loading && /* @__PURE__ */ jsx(
|
|
29
37
|
"div",
|
|
30
38
|
{
|
|
31
|
-
className:
|
|
39
|
+
className: twMerge(
|
|
32
40
|
"fixed top-0 left-0 z-9999 h-[3px] bg-blue-500 transition-all",
|
|
33
|
-
|
|
41
|
+
complete ? "animate-progress-complete" : "animate-progress-grow"
|
|
34
42
|
)
|
|
35
43
|
}
|
|
36
44
|
),
|
|
37
|
-
|
|
45
|
+
children
|
|
38
46
|
] });
|
|
39
47
|
}
|
|
40
48
|
export {
|
|
41
|
-
|
|
42
|
-
|
|
49
|
+
TopProgressBarProvider,
|
|
50
|
+
useProgressBar
|
|
43
51
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AbstractIntlMessages } from '../packages/i18n/src/react.ts';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
export type ChainAppProvidersProps = {
|
|
4
|
+
locale: string;
|
|
5
|
+
messages: AbstractIntlMessages;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
/** 是否挂载登录弹层(Chaindigg 等站点可关闭) */
|
|
8
|
+
login?: boolean;
|
|
9
|
+
themeStorageKey?: string;
|
|
10
|
+
themeCookieDomain?: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* 官方 Provider 顺序:Intl → Theme → Login(可选)→ children
|
|
14
|
+
* 与 explorer-web / ai-web / learn-web 现有结构一致,可渐进替换手写拼装。
|
|
15
|
+
*/
|
|
16
|
+
export declare function ChainAppProviders({ locale, messages, children, login, themeStorageKey, themeCookieDomain, }: ChainAppProvidersProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
//# sourceMappingURL=app-shell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-shell.d.ts","sourceRoot":"","sources":["../src/app-shell.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAGhE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,QAAQ,EAAE,SAAS,CAAC;IACpB,iCAAiC;IACjC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,KAAY,EACZ,eAAe,EACf,iBAAiB,GAClB,EAAE,sBAAsB,2CAiBxB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { NextIntlClientProvider } from "@0xchain/i18n/react";
|
|
4
|
+
import { LoginProvider } from "@0xchain/with-login";
|
|
5
|
+
import ThemeProviderWrapper from "./theme.js";
|
|
6
|
+
function ChainAppProviders({
|
|
7
|
+
locale,
|
|
8
|
+
messages,
|
|
9
|
+
children,
|
|
10
|
+
login = true,
|
|
11
|
+
themeStorageKey,
|
|
12
|
+
themeCookieDomain
|
|
13
|
+
}) {
|
|
14
|
+
const content = login ? /* @__PURE__ */ jsx(LoginProvider, { locale, children }) : children;
|
|
15
|
+
return /* @__PURE__ */ jsx(NextIntlClientProvider, { locale, messages, children: /* @__PURE__ */ jsx(
|
|
16
|
+
ThemeProviderWrapper,
|
|
17
|
+
{
|
|
18
|
+
storageKey: themeStorageKey,
|
|
19
|
+
cookieOptions: themeCookieDomain ? { domain: themeCookieDomain } : void 0,
|
|
20
|
+
children: content
|
|
21
|
+
}
|
|
22
|
+
) });
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
ChainAppProviders
|
|
26
|
+
};
|
package/dist/theme.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx
|
|
3
|
-
import { ThemeProvider
|
|
4
|
-
function
|
|
5
|
-
children
|
|
6
|
-
cookieOptions
|
|
7
|
-
storageKey
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { ThemeProvider } from "@0xchain/next-themes";
|
|
4
|
+
function ThemeProviderWrapper({
|
|
5
|
+
children,
|
|
6
|
+
cookieOptions = { domain: ".ichatgo.ai" },
|
|
7
|
+
storageKey = "ichatgo-theme"
|
|
8
8
|
}) {
|
|
9
|
-
return /* @__PURE__ */
|
|
10
|
-
|
|
9
|
+
return /* @__PURE__ */ jsx(
|
|
10
|
+
ThemeProvider,
|
|
11
11
|
{
|
|
12
12
|
attribute: "class",
|
|
13
|
-
enableSystem:
|
|
14
|
-
disableTransitionOnChange:
|
|
15
|
-
storageKey
|
|
13
|
+
enableSystem: true,
|
|
14
|
+
disableTransitionOnChange: true,
|
|
15
|
+
storageKey,
|
|
16
16
|
themes: ["light", "dark"],
|
|
17
|
-
cookieOptions
|
|
18
|
-
children
|
|
17
|
+
cookieOptions,
|
|
18
|
+
children
|
|
19
19
|
}
|
|
20
20
|
);
|
|
21
21
|
}
|
|
22
22
|
export {
|
|
23
|
-
|
|
23
|
+
ThemeProviderWrapper as default
|
|
24
24
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xchain/providers",
|
|
3
|
-
"version": "1.1.0-beta.
|
|
3
|
+
"version": "1.1.0-beta.43",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -21,20 +21,40 @@
|
|
|
21
21
|
"types": "./dist/theme.d.ts",
|
|
22
22
|
"import": "./dist/theme.js",
|
|
23
23
|
"default": "./dist/theme.js"
|
|
24
|
+
},
|
|
25
|
+
"./app-shell": {
|
|
26
|
+
"types": "./dist/app-shell.d.ts",
|
|
27
|
+
"import": "./dist/app-shell.js",
|
|
28
|
+
"default": "./dist/app-shell.js"
|
|
24
29
|
}
|
|
25
30
|
},
|
|
26
31
|
"files": [
|
|
27
32
|
"dist",
|
|
28
33
|
"!**/*.tsbuildinfo"
|
|
29
34
|
],
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"next": "16.1.6",
|
|
37
|
+
"next-intl": "4.13.0",
|
|
38
|
+
"react": "19.1.1",
|
|
39
|
+
"tailwind-merge": "3.3.1",
|
|
40
|
+
"@0xchain/i18n": "1.1.0-beta.43",
|
|
41
|
+
"@0xchain/with-login": "1.1.0-beta.43"
|
|
42
|
+
},
|
|
30
43
|
"devDependencies": {
|
|
31
|
-
"
|
|
44
|
+
"next": "16.1.6",
|
|
45
|
+
"react": "19.1.1",
|
|
46
|
+
"rollup-plugin-preserve-use-client": "3.0.1",
|
|
47
|
+
"tailwind-merge": "3.3.1"
|
|
32
48
|
},
|
|
33
49
|
"dependencies": {
|
|
34
|
-
"next": "15.5.6",
|
|
35
50
|
"@0xchain/next-themes": "1.0.0",
|
|
36
|
-
"
|
|
37
|
-
"
|
|
51
|
+
"@0xchain/i18n": "1.1.0-beta.43",
|
|
52
|
+
"@0xchain/with-login": "1.1.0-beta.43"
|
|
53
|
+
},
|
|
54
|
+
"nx": {
|
|
55
|
+
"tags": [
|
|
56
|
+
"type:ui"
|
|
57
|
+
]
|
|
38
58
|
},
|
|
39
59
|
"publishConfig": {
|
|
40
60
|
"access": "public"
|