gacha-calendar-core 0.9.39 → 0.9.40
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/core.mjs +52 -16
- package/package.json +1 -1
package/core.mjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// 用途:缓存里记录"这份数据是哪版插件产出的"。更新插件后首次启动,据此**强制**刷新一次
|
|
5
5
|
// (不看自动刷新开关)——因为有些改动(悬停格式、来源地址、样式、解析器)不刷新就看不到效果。
|
|
6
6
|
// 写入时机见 engine-api.js 的 refresh();判定见 60-helpers.js 的 autoRefreshPlan()。
|
|
7
|
-
const PLUGIN_VERSION = "0.9.
|
|
7
|
+
const PLUGIN_VERSION = "0.9.40";
|
|
8
8
|
//#endregion
|
|
9
9
|
|
|
10
10
|
//#region config
|
|
@@ -239,7 +239,7 @@
|
|
|
239
239
|
},
|
|
240
240
|
{
|
|
241
241
|
id: "r1999",
|
|
242
|
-
parserVersion:
|
|
242
|
+
parserVersion: 3,
|
|
243
243
|
name: "重返未来:1999",
|
|
244
244
|
icon: "https://play-lh.googleusercontent.com/LwcueZMBbLq6aELtqJVn61ToKkJUgxEO8O4KgK_5052hfYoDAglQJIzqSu8srUJeaOZwv36Qi5YKtsXZjo-JPg=s64",
|
|
245
245
|
source: "\u5B98\u65B9\u516C\u544A",
|
|
@@ -3092,7 +3092,31 @@ export function createEngine(env) {
|
|
|
3092
3092
|
return "";
|
|
3093
3093
|
}
|
|
3094
3094
|
|
|
3095
|
-
//
|
|
3095
|
+
// 独立池公告:标题形如「池名」类型开启!,正文只有一张图(拿不到 UP 名单),
|
|
3096
|
+
// 但接口的 beginTime/endTime 就是该池的真实起止。官方**逐池各发一篇**,且**过期即从公告板下线**:
|
|
3097
|
+
// 实测公告板上 22 条无一条过期,已结束的池与其轮换期全都没有公告("有公告" ⟺ "该池在开")。
|
|
3098
|
+
// 所以轮换征集只能靠它——一览里那三行日期不带时间,过期后连日期行也会随版本一起消失。
|
|
3099
|
+
const R99_SOLO_POOL = /^\u300c([^\u300d]{1,40})\u300d([^\u300c\u300d]{1,12})\u5f00\u542f\uff01$/;
|
|
3100
|
+
function r99SoloPools(items) {
|
|
3101
|
+
const out = [];
|
|
3102
|
+
for (const it of items) {
|
|
3103
|
+
const title = String((it.contentMap && it.contentMap["zh-CN"] && it.contentMap["zh-CN"].title) || "").trim();
|
|
3104
|
+
const m = title.match(R99_SOLO_POOL);
|
|
3105
|
+
if (!m) continue;
|
|
3106
|
+
const kind = m[2].trim();
|
|
3107
|
+
if (R99_POOL_TIERS.indexOf(kind) < 0) continue; // 衣着上新/上架/上新等不是卡池
|
|
3108
|
+
const startTs = Number(it.beginTime);
|
|
3109
|
+
const endTs = Number(it.endTime) - 6e4; // 接口边界是排他的(…05:00),面板统一显示末分钟 04:59
|
|
3110
|
+
if (!startTs || !endTs) continue;
|
|
3111
|
+
out.push({
|
|
3112
|
+
name: `\u300c${m[1]}\u300d${kind}`, kind, roles: "", startTs, endTs, raw: "",
|
|
3113
|
+
display: fmtWindow(startTs, endTs)
|
|
3114
|
+
});
|
|
3115
|
+
}
|
|
3116
|
+
return out;
|
|
3117
|
+
}
|
|
3118
|
+
|
|
3119
|
+
// 解析一篇「版本活动一览」→ { pools, events, rotRows }
|
|
3096
3120
|
function parseR99Overview(item, now = nowMs()) {
|
|
3097
3121
|
const lines = r99NoticeLines(item);
|
|
3098
3122
|
if (!lines) return null;
|
|
@@ -3147,20 +3171,16 @@ export function createEngine(env) {
|
|
|
3147
3171
|
seenEvent.add(key);
|
|
3148
3172
|
events.push({ name: sec.name, cat: sec.kind, startTs, endTs, raw: fmtWindow(startTs, endTs) });
|
|
3149
3173
|
}
|
|
3150
|
-
//
|
|
3151
|
-
|
|
3174
|
+
// 轮换征集在一览里**只有日期行**(「N月N日更新:角色」,不带起止时间)→ 这里只当"角色字典"。
|
|
3175
|
+
// 时间不再用"+14 天"推算:每期轮换都有自己的独立公告(见 r99SoloPools),接口给的就是真实起止。
|
|
3176
|
+
const rotRows = [];
|
|
3152
3177
|
for (const line of lines) {
|
|
3153
3178
|
const m = line.match(/^(\d{1,2})\u6708(\d{1,2})\u65e5\u66f4\u65b0[\uff1a:]\s*(.+)$/);
|
|
3154
3179
|
if (!m) continue;
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
rotations.push({
|
|
3158
|
-
name: "\u300c\u8f6e\u6362\u5f81\u96c6\u300d", kind: "\u8f6e\u6362\u5f81\u96c6", roles: cleanRoles(m[3]),
|
|
3159
|
-
startTs, endTs, raw: `\u3010${m[1]}\u6708${m[2]}\u65e5\u66f4\u65b0\u3011${cleanRoles(m[3])}`,
|
|
3160
|
-
display: fmtWindow(startTs, endTs)
|
|
3161
|
-
});
|
|
3180
|
+
// 只用"更新日"当匹配键(与同一期独立公告的 startTs 同一天),不作为时间来源
|
|
3181
|
+
rotRows.push({ startTs: new Date(year, Number(m[1]) - 1, Number(m[2]), 5, 0).getTime(), roles: cleanRoles(m[3]) });
|
|
3162
3182
|
}
|
|
3163
|
-
return { pools, events,
|
|
3183
|
+
return { pools, events, rotRows };
|
|
3164
3184
|
}
|
|
3165
3185
|
|
|
3166
3186
|
// 官方游戏内公告 → 当期征集(含真实起止、悬停列全部并行)+ 当期活动(同其它游戏的活动列规则)。
|
|
@@ -3173,7 +3193,7 @@ export function createEngine(env) {
|
|
|
3173
3193
|
const titleOf = (it) => String((it.contentMap && it.contentMap["zh-CN"] && it.contentMap["zh-CN"].title) || "");
|
|
3174
3194
|
const overviews = items.filter((it) => /\u7248\u672c\u6d3b\u52a8\u4e00\u89c8/.test(titleOf(it)));
|
|
3175
3195
|
if (overviews.length === 0) throw new Error("r1999-notice-no-section");
|
|
3176
|
-
const pools = [], events = [],
|
|
3196
|
+
const pools = [], events = [], rotRows = [];
|
|
3177
3197
|
let parsed = 0;
|
|
3178
3198
|
for (const it of overviews) {
|
|
3179
3199
|
const o = parseR99Overview(it, now);
|
|
@@ -3181,11 +3201,27 @@ export function createEngine(env) {
|
|
|
3181
3201
|
parsed++;
|
|
3182
3202
|
pools.push.apply(pools, o.pools);
|
|
3183
3203
|
events.push.apply(events, o.events);
|
|
3184
|
-
|
|
3204
|
+
rotRows.push.apply(rotRows, o.rotRows);
|
|
3185
3205
|
}
|
|
3186
3206
|
if (parsed === 0) throw new Error("r1999-notice-no-dates");
|
|
3207
|
+
// 用独立公告补齐一览没有的池(当前就是轮换征集)。同名池**以一览为准**——它有正文【征集时间】
|
|
3208
|
+
// 与 UP 名单;独立公告正文只有图,只能补"池名 + 真实起止",角色另从日期行字典里按同一天取。
|
|
3209
|
+
const dayKey = (ts) => { const d = new Date(ts); return `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`; };
|
|
3210
|
+
const rolesByDay = new Map(rotRows.map((r) => [dayKey(r.startTs), r.roles]));
|
|
3211
|
+
for (const p of r99SoloPools(items)) {
|
|
3212
|
+
if (pools.some((x) => x.name === p.name)) continue;
|
|
3213
|
+
p.roles = rolesByDay.get(dayKey(p.startTs)) || "";
|
|
3214
|
+
pools.push(p);
|
|
3215
|
+
}
|
|
3187
3216
|
const data = {};
|
|
3188
|
-
|
|
3217
|
+
// 当期 = 窗口覆盖现在的池;同名多期(一览的下一期 + 公告的当期)只留第一个 = 一览优先
|
|
3218
|
+
const seenName = new Set();
|
|
3219
|
+
const active = pools.filter((p) => {
|
|
3220
|
+
if (!(p.startTs <= now && p.endTs >= now)) return false;
|
|
3221
|
+
if (seenName.has(p.name)) return false;
|
|
3222
|
+
seenName.add(p.name);
|
|
3223
|
+
return true;
|
|
3224
|
+
});
|
|
3189
3225
|
if (active.length > 0) {
|
|
3190
3226
|
const rank = (p) => {
|
|
3191
3227
|
const i = R99_POOL_TIERS.indexOf(p.kind);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gacha-calendar-core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.40",
|
|
4
4
|
"description": "二游活动/卡池排期抓取核心:11 款游戏的来源注册表 + 解析器 + 刷新编排 + 缓存降级。零依赖、零宿主环境依赖,任何 JS 运行时(浏览器扩展 background / Tauri / JavaScriptCore / ArkTS 嵌入式引擎)都能跑。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./core.mjs",
|