@ichaingo/better-link 1.1.0
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/README.md +11 -0
- package/dist/index.d.ts +87 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +102 -0
- package/package.json +21 -0
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
interface IGotoAddressOptions {
|
|
2
|
+
chain: string;
|
|
3
|
+
address: string;
|
|
4
|
+
contract?: boolean;
|
|
5
|
+
params?: Record<string, string>;
|
|
6
|
+
}
|
|
7
|
+
interface IGotoTokenOptions {
|
|
8
|
+
chain: string;
|
|
9
|
+
address?: string;
|
|
10
|
+
params?: Record<string, string>;
|
|
11
|
+
}
|
|
12
|
+
interface IGotoPersonOptions {
|
|
13
|
+
slug: string;
|
|
14
|
+
params?: Record<string, string>;
|
|
15
|
+
}
|
|
16
|
+
interface IGotoProjectOptions {
|
|
17
|
+
slug: string;
|
|
18
|
+
params?: Record<string, string>;
|
|
19
|
+
}
|
|
20
|
+
interface IGotoOrganizationOptions {
|
|
21
|
+
slug: string;
|
|
22
|
+
params?: Record<string, string>;
|
|
23
|
+
}
|
|
24
|
+
interface IGotoTransactionOptions {
|
|
25
|
+
chain: string;
|
|
26
|
+
hash: string;
|
|
27
|
+
params?: Record<string, string>;
|
|
28
|
+
}
|
|
29
|
+
interface IGotoBlockOptions {
|
|
30
|
+
chain: string;
|
|
31
|
+
height: string | number;
|
|
32
|
+
type?: string;
|
|
33
|
+
params?: Record<string, string>;
|
|
34
|
+
}
|
|
35
|
+
interface IGotoEntityOptions {
|
|
36
|
+
slug: string;
|
|
37
|
+
params?: Record<string, string>;
|
|
38
|
+
}
|
|
39
|
+
interface IGotoETFOptions {
|
|
40
|
+
region: string;
|
|
41
|
+
slug: string;
|
|
42
|
+
tokenSymbol: string;
|
|
43
|
+
params?: Record<string, string>;
|
|
44
|
+
}
|
|
45
|
+
interface IGotoExplorerOptions {
|
|
46
|
+
chain: string;
|
|
47
|
+
params?: Record<string, string>;
|
|
48
|
+
}
|
|
49
|
+
interface IGotoMarketOptions {
|
|
50
|
+
page?: number;
|
|
51
|
+
params?: Record<string, string>;
|
|
52
|
+
}
|
|
53
|
+
interface IGotoChatOptions {
|
|
54
|
+
locale?: string;
|
|
55
|
+
theme?: string;
|
|
56
|
+
q?: string;
|
|
57
|
+
}
|
|
58
|
+
interface IGotoAISQLOptions {
|
|
59
|
+
locale?: string;
|
|
60
|
+
theme?: string;
|
|
61
|
+
q?: string;
|
|
62
|
+
}
|
|
63
|
+
interface IGotoLoginOptions {
|
|
64
|
+
locale: string;
|
|
65
|
+
theme: string;
|
|
66
|
+
redirect: string;
|
|
67
|
+
}
|
|
68
|
+
export default function BetterLink(): {
|
|
69
|
+
gotoAddress: (options: IGotoAddressOptions) => string;
|
|
70
|
+
gotoToken: (options: IGotoTokenOptions) => string;
|
|
71
|
+
gotoProject: (options: IGotoProjectOptions) => string;
|
|
72
|
+
gotoPerson: (options: IGotoPersonOptions) => string;
|
|
73
|
+
gotoOrganization: (options: IGotoOrganizationOptions) => string;
|
|
74
|
+
gotoTransaction: (options: IGotoTransactionOptions) => string;
|
|
75
|
+
gotoBlock: (options: IGotoBlockOptions) => string;
|
|
76
|
+
gotoEntity: (options: IGotoEntityOptions) => string;
|
|
77
|
+
gotoETF: (options: IGotoETFOptions) => string;
|
|
78
|
+
gotoExplorer: (options: IGotoExplorerOptions) => string;
|
|
79
|
+
gotoMarket: (options: IGotoMarketOptions) => string;
|
|
80
|
+
gotoNews: (options: IGotoMarketOptions) => string;
|
|
81
|
+
gotoChat(options: IGotoChatOptions): string;
|
|
82
|
+
gotoAISQL(options: IGotoAISQLOptions): string;
|
|
83
|
+
gotoExplorerSearch(params: Record<string, string>): string;
|
|
84
|
+
gotoLogin(options: IGotoLoginOptions): string;
|
|
85
|
+
};
|
|
86
|
+
export {};
|
|
87
|
+
//# sourceMappingURL=index.d.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|
|
1
|
+
const g = /* @__PURE__ */ new Map([
|
|
2
|
+
["bitcoin", "btc"],
|
|
3
|
+
["litecoin", "ltc"],
|
|
4
|
+
["dogecoin", "doge"],
|
|
5
|
+
["bitcoincash", "bch"],
|
|
6
|
+
["ethereum", "eth"],
|
|
7
|
+
["tron", "trx"],
|
|
8
|
+
["solana", "sol"],
|
|
9
|
+
["terra", "terra"],
|
|
10
|
+
["near", "near"],
|
|
11
|
+
["polygon", "matic"],
|
|
12
|
+
["avalanche", "avax"],
|
|
13
|
+
["binance", "bsc"],
|
|
14
|
+
["bnb chain", "bnb"]
|
|
15
|
+
]);
|
|
16
|
+
function a(e) {
|
|
17
|
+
return g.get(e == null ? void 0 : e.toLowerCase()) || (e == null ? void 0 : e.toLowerCase());
|
|
18
|
+
}
|
|
19
|
+
function n(e) {
|
|
20
|
+
var t;
|
|
21
|
+
const o = {};
|
|
22
|
+
return e && Object.keys(e).forEach((r) => {
|
|
23
|
+
e[r] && (o[r] = e[r]);
|
|
24
|
+
}), ((t = Object.keys(o)) == null ? void 0 : t.length) > 0 ? `?${new URLSearchParams(o).toString()}` : "";
|
|
25
|
+
}
|
|
26
|
+
function i() {
|
|
27
|
+
return {
|
|
28
|
+
gotoAddress: (e) => {
|
|
29
|
+
const { chain: o, address: t, params: r } = e, s = n(r);
|
|
30
|
+
return `/explorer/${a(o)}/address/${t}${s}`;
|
|
31
|
+
},
|
|
32
|
+
gotoToken: (e) => {
|
|
33
|
+
const { chain: o, address: t, params: r } = e, s = n(r);
|
|
34
|
+
return `/explorer/${a(o)}/token${t && t.length > 10 ? `/${t}` : ""}${s}`;
|
|
35
|
+
},
|
|
36
|
+
gotoProject: (e) => {
|
|
37
|
+
const { slug: o, params: t } = e, r = n(t);
|
|
38
|
+
return `/project/${o}${r}`;
|
|
39
|
+
},
|
|
40
|
+
gotoPerson: (e) => {
|
|
41
|
+
const { slug: o, params: t } = e, r = n(t);
|
|
42
|
+
return `/person/${o}${r}`;
|
|
43
|
+
},
|
|
44
|
+
gotoOrganization: (e) => {
|
|
45
|
+
const { slug: o, params: t } = e, r = n(t);
|
|
46
|
+
return `/organization/${o}${r}`;
|
|
47
|
+
},
|
|
48
|
+
gotoTransaction: (e) => {
|
|
49
|
+
const { chain: o, hash: t, params: r } = e, s = n(r);
|
|
50
|
+
return `/explorer/${a(o)}/tx/${t}${s}`;
|
|
51
|
+
},
|
|
52
|
+
gotoBlock: (e) => {
|
|
53
|
+
const { chain: o, height: t, type: r, params: s } = e, c = n(s), $ = typeof t == "number" ? t : t != null && t.includes("coinbase_") ? `0x${t == null ? void 0 : t.replace("coinbase_", "")}` : t;
|
|
54
|
+
return `/explorer/${a(o)}/block${r ? `/${r}` : ""}/${$}${c}`;
|
|
55
|
+
},
|
|
56
|
+
gotoEntity: (e) => {
|
|
57
|
+
const { slug: o, params: t } = e, r = n(t);
|
|
58
|
+
return `/entity/${o}${r}`;
|
|
59
|
+
},
|
|
60
|
+
gotoETF: (e) => {
|
|
61
|
+
const { region: o, slug: t, tokenSymbol: r, params: s } = e, c = n(s), $ = o == null ? void 0 : o.toLowerCase(), l = r == null ? void 0 : r.toLowerCase(), h = `/etf/${l}-${$}`;
|
|
62
|
+
return l === t ? `${h}${c}` : `${h}/${t}${c}`;
|
|
63
|
+
},
|
|
64
|
+
gotoExplorer: (e) => {
|
|
65
|
+
const { chain: o, params: t } = e, r = n(t);
|
|
66
|
+
return `/explorer/${a(o)}${r}`;
|
|
67
|
+
},
|
|
68
|
+
gotoMarket: (e) => {
|
|
69
|
+
const { page: o, params: t } = e, r = n(t);
|
|
70
|
+
return `/market${o ? `/${o}` : ""}${r}`;
|
|
71
|
+
},
|
|
72
|
+
gotoNews: (e) => {
|
|
73
|
+
const { page: o, params: t } = e, r = n(t);
|
|
74
|
+
return `/news${o ? `/${o}` : ""}${r}`;
|
|
75
|
+
},
|
|
76
|
+
gotoChat(e) {
|
|
77
|
+
const { locale: o, q: t, theme: r } = e, s = n({ q: t || "", theme: r || "" });
|
|
78
|
+
return `${process.env.NEXT_PUBLIC_CHAT_URL}${o ? `/${o}` : ""}/chat${s}`;
|
|
79
|
+
},
|
|
80
|
+
gotoAISQL(e) {
|
|
81
|
+
const { locale: o, q: t, theme: r } = e, s = n({ q: t || "", theme: r || "" });
|
|
82
|
+
return `${process.env.NEXT_PUBLIC_CHAT_URL}${o ? `/${o}` : ""}/sql${s}`;
|
|
83
|
+
},
|
|
84
|
+
gotoExplorerSearch(e) {
|
|
85
|
+
var t, r;
|
|
86
|
+
return `/explorer/search${n({
|
|
87
|
+
chain: g.get((t = e == null ? void 0 : e.chain) == null ? void 0 : t.toLowerCase()) || ((r = e == null ? void 0 : e.chain) == null ? void 0 : r.toLowerCase()) || "",
|
|
88
|
+
q: (e == null ? void 0 : e.q) || "",
|
|
89
|
+
type: (e == null ? void 0 : e.type) || "",
|
|
90
|
+
_t: Date.now().toString()
|
|
91
|
+
// 添加时间戳强制刷新
|
|
92
|
+
})}`;
|
|
93
|
+
},
|
|
94
|
+
gotoLogin(e) {
|
|
95
|
+
const { locale: o, theme: t, redirect: r } = e, s = n({ theme: t || "", redirect_uri: r || "" });
|
|
96
|
+
return `${o ? `/${o}` : ""}/login${s}`;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
export {
|
|
101
|
+
i as default
|
|
102
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ichaingo/better-link",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
"./package.json": "./package.json",
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"!**/*.tsbuildinfo"
|
|
19
|
+
],
|
|
20
|
+
"dependencies": {}
|
|
21
|
+
}
|