@seayoo-web/gamer-api 2.5.1 → 2.5.2
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var me = Object.defineProperty;
|
|
2
2
|
var de = (a, t, r) => t in a ? me(a, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : a[t] = r;
|
|
3
|
-
var
|
|
3
|
+
var d = (a, t, r) => de(a, typeof t != "symbol" ? t + "" : t, r);
|
|
4
4
|
import { isComboWebView as ge } from "@seayoo-web/combo-webview";
|
|
5
5
|
import { isPlainObject as R, useConsole as pe, Support as y, usePromise as _e, pruneURL as be, queryString as P, pruneObject as c, v as e, omitFields as V, typedObjectGuard as s, parseJSON as ye, removePara as M } from "@seayoo-web/utils";
|
|
6
6
|
function fe(a) {
|
|
@@ -60,21 +60,21 @@ const ke = {
|
|
|
60
60
|
}, k = "gamer_token";
|
|
61
61
|
class qr {
|
|
62
62
|
constructor(t, r) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
d(this, "$NetRequest");
|
|
64
|
+
d(this, "$idToken", "");
|
|
65
|
+
d(this, "$weixinToken", "");
|
|
66
|
+
d(this, "$gamerToken", "");
|
|
67
|
+
d(this, "req");
|
|
68
|
+
d(this, "storage");
|
|
69
69
|
this.storage = y.wx ? ve : ke;
|
|
70
70
|
const n = he(t) ? t : `https://${be(t)}`;
|
|
71
|
-
this.$NetRequest = r, this.req = r({
|
|
71
|
+
if (this.$NetRequest = r, this.req = r({
|
|
72
72
|
baseURL: `${n}/v1`,
|
|
73
73
|
timeout: 1e4,
|
|
74
74
|
maxRetry: 2,
|
|
75
75
|
retryInterval: "2EB",
|
|
76
|
-
retryResolve({ method:
|
|
77
|
-
return
|
|
76
|
+
retryResolve({ method: i, status: o }) {
|
|
77
|
+
return i === "GET" && o < 0;
|
|
78
78
|
},
|
|
79
79
|
responseRule: {
|
|
80
80
|
ok: { resolve: "body" },
|
|
@@ -85,12 +85,14 @@ class qr {
|
|
|
85
85
|
}
|
|
86
86
|
},
|
|
87
87
|
// 使用箭头函数绑定执行上下文
|
|
88
|
-
requestTransformer: (
|
|
89
|
-
this.$gamerToken && (
|
|
88
|
+
requestTransformer: (i) => {
|
|
89
|
+
this.$gamerToken && (i.headers.Authorization = `Bearer ${this.$gamerToken}`);
|
|
90
90
|
}
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
}), y.window) {
|
|
92
|
+
const i = /^(?:localhost|[\d.]+):\d{4}$/.test(location.host), o = P("gamer_token");
|
|
93
|
+
(ge() || i && o) && (this.$gamerToken = o);
|
|
94
|
+
}
|
|
95
|
+
this.$gamerToken || this.loadGamerTokenCache();
|
|
94
96
|
}
|
|
95
97
|
get NetRequest() {
|
|
96
98
|
return this.$NetRequest;
|
|
@@ -408,8 +410,8 @@ const Ce = {
|
|
|
408
410
|
});
|
|
409
411
|
class Sr {
|
|
410
412
|
constructor(t) {
|
|
411
|
-
|
|
412
|
-
|
|
413
|
+
d(this, "token");
|
|
414
|
+
d(this, "req");
|
|
413
415
|
this.token = t, this.req = t.req;
|
|
414
416
|
}
|
|
415
417
|
/**
|
|
@@ -736,7 +738,9 @@ const j = {
|
|
|
736
738
|
/** 签到 */
|
|
737
739
|
CheckIn: "check_in",
|
|
738
740
|
/** 领取激活码 */
|
|
739
|
-
ClaimActivationKey: "claim_activation_key"
|
|
741
|
+
ClaimActivationKey: "claim_activation_key",
|
|
742
|
+
/** 不朽箴言特有的 AI 聊天 */
|
|
743
|
+
ZeroChatgpt: "zero_chatgpt"
|
|
740
744
|
}, rt = e.string().enum(u).lock(), it = {
|
|
741
745
|
/** 累计游戏内活跃值 */
|
|
742
746
|
Active: "player_active_points",
|
|
@@ -861,7 +865,7 @@ const j = {
|
|
|
861
865
|
feature_reward_type: e.string().enum("regular"),
|
|
862
866
|
reward_details: e.array(gt)
|
|
863
867
|
})
|
|
864
|
-
).satisfies().lock(),
|
|
868
|
+
).satisfies().lock(), l = e.object({
|
|
865
869
|
feature_name: e.string(),
|
|
866
870
|
feature_id: e.number(),
|
|
867
871
|
description: e.string(),
|
|
@@ -872,7 +876,7 @@ const j = {
|
|
|
872
876
|
engage_account: et,
|
|
873
877
|
feature_rewards: pt.clone().optional()
|
|
874
878
|
}), _t = u.Cashback, bt = e.object({
|
|
875
|
-
...
|
|
879
|
+
...l.shape,
|
|
876
880
|
feature_type: e.string().enum(_t),
|
|
877
881
|
config: e.object({
|
|
878
882
|
order_start_time: e.number(),
|
|
@@ -881,23 +885,23 @@ const j = {
|
|
|
881
885
|
claim_rewards_end_time: e.number()
|
|
882
886
|
})
|
|
883
887
|
}), yt = u.CheckIn, ft = e.object({
|
|
884
|
-
...
|
|
888
|
+
...l.shape,
|
|
885
889
|
feature_type: e.string().enum(yt)
|
|
886
890
|
}), ht = u.ClaimActivationKey, wt = e.object({
|
|
887
|
-
...
|
|
891
|
+
...l.shape,
|
|
888
892
|
feature_type: e.string().enum(ht)
|
|
889
893
|
}), kt = u.ClaimRewards, vt = e.object({
|
|
890
|
-
...
|
|
894
|
+
...l.shape,
|
|
891
895
|
feature_type: e.string().enum(kt)
|
|
892
896
|
}), Ct = u.Comment, Rt = e.object({
|
|
893
|
-
...
|
|
897
|
+
...l.shape,
|
|
894
898
|
feature_type: e.string().enum(Ct),
|
|
895
899
|
config: e.object({
|
|
896
900
|
comments: e.array(e.string()),
|
|
897
901
|
send_rate: e.number()
|
|
898
902
|
})
|
|
899
903
|
}), Vt = u.Follow, jt = e.object({
|
|
900
|
-
...
|
|
904
|
+
...l.shape,
|
|
901
905
|
feature_type: e.string().enum(Vt),
|
|
902
906
|
config: e.object({
|
|
903
907
|
platform: e.string(),
|
|
@@ -911,7 +915,7 @@ const j = {
|
|
|
911
915
|
icon_url: e.string(),
|
|
912
916
|
count: e.number()
|
|
913
917
|
}), xt = e.object({
|
|
914
|
-
...
|
|
918
|
+
...l.shape,
|
|
915
919
|
feature_type: e.string().enum(Tt),
|
|
916
920
|
config: e.object({
|
|
917
921
|
gift_items: e.array(qt),
|
|
@@ -919,13 +923,13 @@ const j = {
|
|
|
919
923
|
mp_qrcode_url: e.string().optional()
|
|
920
924
|
})
|
|
921
925
|
}), St = u.Invite, Lt = e.object({
|
|
922
|
-
...
|
|
926
|
+
...l.shape,
|
|
923
927
|
feature_type: e.string().enum(St),
|
|
924
928
|
config: e.object({
|
|
925
929
|
share_url: e.string()
|
|
926
930
|
})
|
|
927
931
|
}), Et = u.InvitedRegister, Pt = e.object({
|
|
928
|
-
...
|
|
932
|
+
...l.shape,
|
|
929
933
|
feature_type: e.string().enum(Et)
|
|
930
934
|
}), $t = e.string().enum(V(j, "GiftCode", "LotteryTicket")), Ut = u.Lottery, Ft = e.object({
|
|
931
935
|
reward_item_id: e.number(),
|
|
@@ -936,7 +940,7 @@ const j = {
|
|
|
936
940
|
reward_amount: e.number(),
|
|
937
941
|
reward_remaining_stock: e.number()
|
|
938
942
|
}), Dt = e.object({
|
|
939
|
-
...
|
|
943
|
+
...l.shape,
|
|
940
944
|
feature_type: e.string().enum(Ut),
|
|
941
945
|
config: e.object({
|
|
942
946
|
consume_item_id: e.number(),
|
|
@@ -947,17 +951,17 @@ const j = {
|
|
|
947
951
|
rewards: e.array(Ft)
|
|
948
952
|
})
|
|
949
953
|
}), It = u.LotteryDraw, Gt = e.object({
|
|
950
|
-
...
|
|
954
|
+
...l.shape,
|
|
951
955
|
feature_type: e.string().enum(It),
|
|
952
956
|
config: e.object({
|
|
953
957
|
draw_not_before: e.number(),
|
|
954
958
|
draw_not_after: e.number()
|
|
955
959
|
})
|
|
956
960
|
}), At = u.Preregister, Nt = e.object({
|
|
957
|
-
...
|
|
961
|
+
...l.shape,
|
|
958
962
|
feature_type: e.string().enum(At)
|
|
959
963
|
}), Ot = u.Quest, Bt = e.object({
|
|
960
|
-
...
|
|
964
|
+
...l.shape,
|
|
961
965
|
feature_type: e.string().enum(Ot),
|
|
962
966
|
config: e.object({
|
|
963
967
|
objective: ie,
|
|
@@ -973,10 +977,10 @@ const j = {
|
|
|
973
977
|
}).optional()
|
|
974
978
|
})
|
|
975
979
|
}), Mt = u.Register, Qt = e.object({
|
|
976
|
-
...
|
|
980
|
+
...l.shape,
|
|
977
981
|
feature_type: e.string().enum(Mt)
|
|
978
982
|
}), Kt = u.Share, Ht = e.object({
|
|
979
|
-
...
|
|
983
|
+
...l.shape,
|
|
980
984
|
feature_type: e.string().enum(Kt),
|
|
981
985
|
config: e.object({
|
|
982
986
|
share_platform: e.string(),
|
|
@@ -984,20 +988,20 @@ const j = {
|
|
|
984
988
|
icon_url: e.string().optional()
|
|
985
989
|
})
|
|
986
990
|
}), zt = u.Subscribe, Jt = e.object({
|
|
987
|
-
...
|
|
991
|
+
...l.shape,
|
|
988
992
|
feature_type: e.string().enum(zt),
|
|
989
993
|
config: e.object({
|
|
990
994
|
weixin_template_ids: e.array(e.string())
|
|
991
995
|
})
|
|
992
996
|
}), Zt = u.Survey, Xt = e.object({
|
|
993
|
-
...
|
|
997
|
+
...l.shape,
|
|
994
998
|
feature_type: e.string().enum(Zt),
|
|
995
999
|
config: e.object({
|
|
996
1000
|
survey_id: e.string(),
|
|
997
1001
|
survey_url: e.string()
|
|
998
1002
|
})
|
|
999
1003
|
}), Yt = u.Team, Wt = e.object({
|
|
1000
|
-
...
|
|
1004
|
+
...l.shape,
|
|
1001
1005
|
feature_type: e.string().enum(Yt),
|
|
1002
1006
|
config: e.object({
|
|
1003
1007
|
max_members: e.number().min(1),
|
|
@@ -1014,7 +1018,7 @@ const j = {
|
|
|
1014
1018
|
finalists: e.bool(),
|
|
1015
1019
|
last_vote_time: e.number()
|
|
1016
1020
|
}), nn = e.object({
|
|
1017
|
-
...
|
|
1021
|
+
...l.shape,
|
|
1018
1022
|
feature_type: e.string().enum(en),
|
|
1019
1023
|
config: e.object({
|
|
1020
1024
|
vote_feature_ids: e.array(e.number()),
|
|
@@ -1253,9 +1257,9 @@ const j = {
|
|
|
1253
1257
|
});
|
|
1254
1258
|
class Dr {
|
|
1255
1259
|
constructor(t, r) {
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1260
|
+
d(this, "token");
|
|
1261
|
+
d(this, "event", 0);
|
|
1262
|
+
d(this, "req");
|
|
1259
1263
|
this.token = t, this.event = +r, this.req = t.req;
|
|
1260
1264
|
}
|
|
1261
1265
|
/**
|
|
@@ -1404,7 +1408,7 @@ class Dr {
|
|
|
1404
1408
|
*/
|
|
1405
1409
|
async engage(t, r, n, i) {
|
|
1406
1410
|
await this.token.autoLogin();
|
|
1407
|
-
const { data: o, code:
|
|
1411
|
+
const { data: o, code: g, message: m } = await this.req.post(
|
|
1408
1412
|
`event/${this.event}/engage`,
|
|
1409
1413
|
c({
|
|
1410
1414
|
feature_id: t,
|
|
@@ -1415,8 +1419,8 @@ class Dr {
|
|
|
1415
1419
|
i
|
|
1416
1420
|
);
|
|
1417
1421
|
return o && o.rewards && (o.rewards = o.rewards.map((h) => (h.reward_status = h.reward_status === $.UnclaimedErr ? $.Unclaimed : h.reward_status, h))), o ?? {
|
|
1418
|
-
message:
|
|
1419
|
-
error:
|
|
1422
|
+
message: m,
|
|
1423
|
+
error: g
|
|
1420
1424
|
// 激活码已领完
|
|
1421
1425
|
};
|
|
1422
1426
|
}
|
|
@@ -1437,8 +1441,8 @@ class Dr {
|
|
|
1437
1441
|
}),
|
|
1438
1442
|
An,
|
|
1439
1443
|
r
|
|
1440
|
-
),
|
|
1441
|
-
return
|
|
1444
|
+
), g = n == null ? void 0 : n.claimed_items;
|
|
1445
|
+
return g ? g.map((m) => (m.reward_status = m.reward_status === b.UnclaimedErr ? b.Unclaimed : m.reward_status, m)) : {
|
|
1442
1446
|
message: o,
|
|
1443
1447
|
error: i
|
|
1444
1448
|
};
|
|
@@ -1458,8 +1462,8 @@ class Dr {
|
|
|
1458
1462
|
}),
|
|
1459
1463
|
Nn,
|
|
1460
1464
|
r
|
|
1461
|
-
),
|
|
1462
|
-
return
|
|
1465
|
+
), g = n == null ? void 0 : n.rewards;
|
|
1466
|
+
return g ? g.map((m) => (m.reward_status = m.reward_status === b.UnclaimedErr ? b.Unclaimed : m.reward_status, m)) : {
|
|
1463
1467
|
message: o,
|
|
1464
1468
|
error: i
|
|
1465
1469
|
};
|
|
@@ -1814,8 +1818,8 @@ const Hn = {
|
|
|
1814
1818
|
});
|
|
1815
1819
|
class Gr {
|
|
1816
1820
|
constructor(t) {
|
|
1817
|
-
|
|
1818
|
-
|
|
1821
|
+
d(this, "token");
|
|
1822
|
+
d(this, "req");
|
|
1819
1823
|
this.token = t, this.req = t.req;
|
|
1820
1824
|
}
|
|
1821
1825
|
/**
|
|
@@ -1869,13 +1873,13 @@ class Gr {
|
|
|
1869
1873
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=yXubbZuDlC
|
|
1870
1874
|
*/
|
|
1871
1875
|
async getPinnedPosts(t, r, n, i) {
|
|
1872
|
-
const { data: o, code:
|
|
1876
|
+
const { data: o, code: g, message: m } = await this.req.get("community/pinned-posts", J, {
|
|
1873
1877
|
...i,
|
|
1874
1878
|
params: c({ forum_id: t, max_results: r, next_token: n })
|
|
1875
1879
|
});
|
|
1876
1880
|
return o ?? {
|
|
1877
|
-
message:
|
|
1878
|
-
error:
|
|
1881
|
+
message: m,
|
|
1882
|
+
error: g
|
|
1879
1883
|
};
|
|
1880
1884
|
}
|
|
1881
1885
|
/**
|
|
@@ -2123,9 +2127,9 @@ class Ar {
|
|
|
2123
2127
|
* https://developers.weixin.qq.com/miniprogram/dev/api/open-api/account-info/wx.getAccountInfoSync.html
|
|
2124
2128
|
*/
|
|
2125
2129
|
constructor(t, r) {
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2130
|
+
d(this, "token");
|
|
2131
|
+
d(this, "$appid");
|
|
2132
|
+
d(this, "req");
|
|
2129
2133
|
this.token = t, this.req = t.req, this.$appid = r, this.getLoginCache();
|
|
2130
2134
|
}
|
|
2131
2135
|
get appid() {
|
|
@@ -2168,14 +2172,14 @@ class Ar {
|
|
|
2168
2172
|
const r = await this.getLoginCache();
|
|
2169
2173
|
if (r)
|
|
2170
2174
|
return r;
|
|
2171
|
-
const n = await we(), { data: i, code: o, message:
|
|
2175
|
+
const n = await we(), { data: i, code: o, message: g } = await this.req.post(
|
|
2172
2176
|
"weixin/login",
|
|
2173
2177
|
{ code: n, appid: this.appid },
|
|
2174
2178
|
E,
|
|
2175
2179
|
{ ...t, message: !1 }
|
|
2176
2180
|
);
|
|
2177
2181
|
return i && (this.token.weixinToken = i.weixin_token, this.token.storage.set(Z, JSON.stringify(i)), await this.token.autoLogin()), i ?? {
|
|
2178
|
-
message:
|
|
2182
|
+
message: g,
|
|
2179
2183
|
error: o
|
|
2180
2184
|
};
|
|
2181
2185
|
}
|
|
@@ -2209,14 +2213,14 @@ class Ar {
|
|
|
2209
2213
|
message: "Error: " + n,
|
|
2210
2214
|
error: n
|
|
2211
2215
|
};
|
|
2212
|
-
const
|
|
2213
|
-
"replaceState" in history && history.replaceState({}, "",
|
|
2216
|
+
const g = M(["code", "state"]);
|
|
2217
|
+
"replaceState" in history && history.replaceState({}, "", g);
|
|
2214
2218
|
const {
|
|
2215
|
-
data:
|
|
2219
|
+
data: m,
|
|
2216
2220
|
code: h,
|
|
2217
2221
|
message: ue
|
|
2218
2222
|
} = await this.req.post("weixin/login", { code: n, appid: this.appid }, E, r);
|
|
2219
|
-
return
|
|
2223
|
+
return m && (this.token.weixinToken = m.weixin_token, await this.token.autoLogin()), m ?? {
|
|
2220
2224
|
message: ue,
|
|
2221
2225
|
error: h
|
|
2222
2226
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seayoo-web/gamer-api",
|
|
3
3
|
"description": "agent for gamer api",
|
|
4
|
-
"version": "2.5.
|
|
4
|
+
"version": "2.5.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "index.ts",
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -31,14 +31,14 @@
|
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/node": "^22.13.1",
|
|
33
33
|
"@seayoo-web/combo-webview": "^2.5.4",
|
|
34
|
+
"@seayoo-web/utils": "^3.6.1",
|
|
35
|
+
"@seayoo-web/tsconfig": "^1.0.4",
|
|
34
36
|
"@seayoo-web/request": "^3.2.0",
|
|
35
|
-
"@seayoo-web/scripts": "^2.6.0"
|
|
36
|
-
"@seayoo-web/utils": "^3.6.0",
|
|
37
|
-
"@seayoo-web/tsconfig": "^1.0.4"
|
|
37
|
+
"@seayoo-web/scripts": "^2.6.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"@seayoo-web/combo-webview": "^2.5.4",
|
|
41
|
-
"@seayoo-web/utils": "^3.6.
|
|
41
|
+
"@seayoo-web/utils": "^3.6.1"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"prebuild": "pnpm -F request build && pnpm -F combo-webview build",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type InferType } from "@seayoo-web/utils";
|
|
2
2
|
import { type EventFeatureBaseConfig } from "./feature.base";
|
|
3
|
-
declare const rewardItemTypeValidator: import("@seayoo-web/utils").StringValidator<"
|
|
3
|
+
declare const rewardItemTypeValidator: import("@seayoo-web/utils").StringValidator<"event_item" | "game_item" | "physical_item" | "weixin_hongbao" | "activation_key" | "credit" | "external_gift_code" | "void_item", false, false>;
|
|
4
4
|
declare const featureType: "lottery";
|
|
5
5
|
export interface FeatureLotteryItemConfig {
|
|
6
6
|
/** 抽奖奖励道具 id */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type InferType } from "@seayoo-web/utils";
|
|
2
|
-
declare const rewardItemTypeValidator: import("@seayoo-web/utils").StringValidator<"
|
|
2
|
+
declare const rewardItemTypeValidator: import("@seayoo-web/utils").StringValidator<"event_item" | "game_item" | "physical_item" | "weixin_hongbao" | "activation_key" | "credit" | "external_gift_code" | "void_item", false, false>;
|
|
3
3
|
export interface EventRewardItemConfig {
|
|
4
4
|
/** 玩法奖励道具 id */
|
|
5
5
|
reward_item_id: number;
|
|
@@ -142,6 +142,8 @@ export declare const FeatureType: {
|
|
|
142
142
|
readonly CheckIn: "check_in";
|
|
143
143
|
/** 领取激活码 */
|
|
144
144
|
readonly ClaimActivationKey: "claim_activation_key";
|
|
145
|
+
/** 不朽箴言特有的 AI 聊天 */
|
|
146
|
+
readonly ZeroChatgpt: "zero_chatgpt";
|
|
145
147
|
};
|
|
146
148
|
export type FeatureType = ValueOf<typeof FeatureType>;
|
|
147
149
|
export declare const FeatureTypeValidator: import("@seayoo-web/utils").StringValidator<FeatureType, false, false> & {
|