@2025-6-19/clawfight 0.1.0 → 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/dist/index.js +19 -3
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -299,9 +299,24 @@ function statsHash(lobster) {
|
|
|
299
299
|
const raw = JSON.stringify(lobster.stats);
|
|
300
300
|
return createHash("sha256").update(raw).digest("hex");
|
|
301
301
|
}
|
|
302
|
+
function getProxyUrl() {
|
|
303
|
+
return process.env.https_proxy || process.env.HTTPS_PROXY || process.env.http_proxy || process.env.HTTP_PROXY || null;
|
|
304
|
+
}
|
|
305
|
+
async function getProxiedFetch() {
|
|
306
|
+
const proxyUrl = getProxyUrl();
|
|
307
|
+
if (!proxyUrl) return globalThis.fetch;
|
|
308
|
+
try {
|
|
309
|
+
const { ProxyAgent } = await import("undici");
|
|
310
|
+
const dispatcher = new ProxyAgent(proxyUrl);
|
|
311
|
+
return ((input, init) => globalThis.fetch(input, { ...init, dispatcher }));
|
|
312
|
+
} catch {
|
|
313
|
+
return globalThis.fetch;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
302
316
|
async function apiPatrol(lobster) {
|
|
303
317
|
try {
|
|
304
|
-
const
|
|
318
|
+
const pfetch = await getProxiedFetch();
|
|
319
|
+
const res = await pfetch(`${API_BASE}/api/patrol`, {
|
|
305
320
|
method: "POST",
|
|
306
321
|
headers: { "Content-Type": "application/json; charset=utf-8" },
|
|
307
322
|
body: JSON.stringify({
|
|
@@ -329,7 +344,8 @@ async function apiPatrol(lobster) {
|
|
|
329
344
|
}
|
|
330
345
|
async function apiLeaderboard(limit = 20) {
|
|
331
346
|
try {
|
|
332
|
-
const
|
|
347
|
+
const pfetch = await getProxiedFetch();
|
|
348
|
+
const res = await pfetch(`${API_BASE}/api/leaderboard?limit=${limit}`, {
|
|
333
349
|
signal: AbortSignal.timeout(1e4)
|
|
334
350
|
});
|
|
335
351
|
if (!res.ok) return null;
|
|
@@ -683,7 +699,7 @@ async function leaderboard() {
|
|
|
683
699
|
|
|
684
700
|
// src/index.ts
|
|
685
701
|
var program = new Command();
|
|
686
|
-
program.name("clawfight").description("\u{1F99E} ClawFight \u2014 \u9F99\u867E\u7535\u5B50\u5BA0\u7269\u5BF9\u6218").version("
|
|
702
|
+
program.name("clawfight").description("\u{1F99E} ClawFight \u2014 \u9F99\u867E\u7535\u5B50\u5BA0\u7269\u5BF9\u6218").version("1.1.0");
|
|
687
703
|
program.command("hatch").description("\u5B75\u5316\u4E00\u53EA\u65B0\u9F99\u867E").argument("[name]", "\u4E3A\u9F99\u867E\u53D6\u540D").action(async (name) => {
|
|
688
704
|
await hatch(name);
|
|
689
705
|
});
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@2025-6-19/clawfight",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "ClawFight — raise and battle a unique lobster pet with evolving soul 🦞",
|
|
5
5
|
"author": "LIU",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/
|
|
9
|
+
"url": "https://github.com/2019-02-18/clawfight",
|
|
10
10
|
"directory": "packages/cli"
|
|
11
11
|
},
|
|
12
|
-
"homepage": "https://github.com/
|
|
12
|
+
"homepage": "https://github.com/2019-02-18/clawfight#readme",
|
|
13
13
|
"bugs": {
|
|
14
|
-
"url": "https://github.com/
|
|
14
|
+
"url": "https://github.com/2019-02-18/clawfight/issues"
|
|
15
15
|
},
|
|
16
16
|
"bin": {
|
|
17
17
|
"clawfight": "./dist/index.js"
|