dsh-plugin-cyrene-live2d 0.2.9 → 0.3.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 +8 -2
- package/assets/default-prefs.json +8 -8
- package/assets/icon.svg +89 -89
- package/assets/locale/notes/en.json +6 -6
- package/assets/locale/notes/zh-CN.json +6 -6
- package/assets/locale/reminder/en.json +6 -6
- package/assets/locale/reminder/zh-CN.json +6 -6
- package/assets/model/Cyrene.model3.json +441 -441
- package/assets/model/bongo-standard/Live2d_expression0.exp3.json +9 -9
- package/assets/model/bongo-standard/cat.cdi3.json +296 -296
- package/assets/model/bongo-standard/cat.model3.json +33 -33
- package/assets/model/bongo-standard/cat.physics3.json +232 -232
- package/assets/model/expressions/0.exp3.json +24 -24
- package/assets/model/expressions/1.exp3.json +11 -11
- package/assets/model/expressions/10.exp3.json +9 -9
- package/assets/model/expressions/11.exp3.json +9 -9
- package/assets/model/expressions/2.exp3.json +9 -9
- package/assets/model/expressions/3.exp3.json +9 -9
- package/assets/model/expressions/4.exp3.json +11 -11
- package/assets/model/expressions/5.exp3.json +11 -11
- package/assets/model/expressions/6.exp3.json +11 -11
- package/assets/model/expressions/7.exp3.json +11 -11
- package/assets/model/expressions/8.exp3.json +11 -11
- package/assets/model/expressions/9.exp3.json +9 -9
- package/assets/model/model.physics3.json +641 -641
- package/assets/model/motions/Tick3_3.motion3.json +1347 -1347
- package/assets/model/motions//345/212/250/344/275/2346_0.motion3.json +699 -699
- package/assets/model/motions//345/212/250/344/275/2346_1.motion3.json +1241 -1241
- package/assets/model/motions//345/212/250/344/275/2346_2.motion3.json +1117 -1117
- package/assets/model/motions//345/212/250/344/275/2346_3.motion3.json +1106 -1106
- package/assets/model/we-q/expressions/FileReferences_Expressions_0_File_0.exp3.json +19 -19
- package/assets/model/we-q/expressions/FileReferences_Expressions_1_File_0.exp3.json +41 -41
- package/assets/model/we-q/expressions/FileReferences_Expressions_2_File_0.exp3.json +104 -104
- package/assets/model/we-q/model0.model3.json +245 -245
- package/assets/model/we-q/motions/FileReferences_Motions_shake#1_0_File_0.motion3.json +520 -520
- package/assets/model/we-q/motions/FileReferences_Motions_talk#1_0_File_0.motion3.json +499 -499
- package/assets/model/we-q/motions/FileReferences_Motions_talk#1_1_File_0.motion3.json +453 -453
- package/assets/model/we-q/motions/FileReferences_Motions_wink#1_0_File_0.motion3.json +478 -478
- package/assets/model/we-q/motions/FileReferences_Motions_/346/212/254/346/211/213_0_File_0.motion3.json +450 -450
- package/assets/model/we-q/motions/FileReferences_Motions_/346/212/254/346/211/213_1_File_0.motion3.json +450 -450
- package/assets/model/we-q/motions/idle/FileReferences_Motions_Idleidle_0_File_0.motion3.json +422 -422
- package/assets/model/we-q/physics/FileReferences_Physics_0.physic3.json +236 -236
- package/assets/runtime/live2dcubismcore.min.js +8 -8
- package/assets/stickers.json +84 -84
- package/assets/vendor/cubism4.min.js +1 -1
- package/assets/vendor/pixi.min.js +9 -9
- package/assets/vendor/theme-cyrene-factory.js +4314 -4314
- package/assets/vendor/theme-cyrene.js +4317 -4317
- package/assets/voice/angry-00.opus +0 -0
- package/assets/voice/angry-02.opus +0 -0
- package/assets/voice/approval-00.opus +0 -0
- package/assets/voice/approval-01.opus +0 -0
- package/assets/voice/approval-02.opus +0 -0
- package/assets/voice/askAck-00.opus +0 -0
- package/assets/voice/away-01.opus +0 -0
- package/assets/voice/away-02.opus +0 -0
- package/assets/voice/away-03.opus +0 -0
- package/assets/voice/away-05.opus +0 -0
- package/assets/voice/back-00.opus +0 -0
- package/assets/voice/back-01.opus +0 -0
- package/assets/voice/backLong-05.opus +0 -0
- package/assets/voice/backShort-03.opus +0 -0
- package/assets/voice/backShort-04.opus +0 -0
- package/assets/voice/backShort-07.opus +0 -0
- package/assets/voice/backVeryLong-01.opus +0 -0
- package/assets/voice/backVeryLong-02.opus +0 -0
- package/assets/voice/backVeryLong-03.opus +0 -0
- package/assets/voice/backVeryLong-04.opus +0 -0
- package/assets/voice/backVeryLong-05.opus +0 -0
- package/assets/voice/backVeryLong-07.opus +0 -0
- package/assets/voice/backVeryLong-08.opus +0 -0
- package/assets/voice/balLow-00.opus +0 -0
- package/assets/voice/balLow-01.opus +0 -0
- package/assets/voice/birthday-02.opus +0 -0
- package/assets/voice/click-00.opus +0 -0
- package/assets/voice/click-01.opus +0 -0
- package/assets/voice/click-07.opus +0 -0
- package/assets/voice/click-10.opus +0 -0
- package/assets/voice/click-11.opus +0 -0
- package/assets/voice/click-12.opus +0 -0
- package/assets/voice/click-16.opus +0 -0
- package/assets/voice/click-17.opus +0 -0
- package/assets/voice/click-18.opus +0 -0
- package/assets/voice/comfort-03.opus +0 -0
- package/assets/voice/comfort-04.opus +0 -0
- package/assets/voice/cost10-00.opus +0 -0
- package/assets/voice/cost2-00.opus +0 -0
- package/assets/voice/cost5-00.opus +0 -0
- package/assets/voice/costTurn-01.opus +0 -0
- package/assets/voice/costTurn-02.opus +0 -0
- package/assets/voice/ctxFull-01.opus +0 -0
- package/assets/voice/ctxHigh-00.opus +0 -0
- package/assets/voice/dawn-01.opus +0 -0
- package/assets/voice/dawn-04.opus +0 -0
- package/assets/voice/dawn-06.opus +0 -0
- package/assets/voice/dawn-07.opus +0 -0
- package/assets/voice/deepWake-03.opus +0 -0
- package/assets/voice/deepWake-04.opus +0 -0
- package/assets/voice/deepWake-06.opus +0 -0
- package/assets/voice/deepWake-07.opus +0 -0
- package/assets/voice/done-05.opus +0 -0
- package/assets/voice/done-08.opus +0 -0
- package/assets/voice/done-09.opus +0 -0
- package/assets/voice/done-11.opus +0 -0
- package/assets/voice/empty-00.opus +0 -0
- package/assets/voice/encourage-02.opus +0 -0
- package/assets/voice/failed-01.opus +0 -0
- package/assets/voice/failed-05.opus +0 -0
- package/assets/voice/failkind-auth-01.opus +0 -0
- package/assets/voice/failkind-auth-02.opus +0 -0
- package/assets/voice/failkind-ctx-00.opus +0 -0
- package/assets/voice/failkind-missing-01.opus +0 -0
- package/assets/voice/focusEnd-02.opus +0 -0
- package/assets/voice/focusEnd-04.opus +0 -0
- package/assets/voice/forgive-00.opus +0 -0
- package/assets/voice/hello-00.opus +0 -0
- package/assets/voice/hello-03.opus +0 -0
- package/assets/voice/hold-00.opus +0 -0
- package/assets/voice/idleTap-00.opus +0 -0
- package/assets/voice/idleTapLong-02.opus +0 -0
- package/assets/voice/lateNight-00.opus +0 -0
- package/assets/voice/lateNight-02.opus +0 -0
- package/assets/voice/lateNight-03.opus +0 -0
- package/assets/voice/lateNight-06.opus +0 -0
- package/assets/voice/lateNight-07.opus +0 -0
- package/assets/voice/murmur-04.opus +0 -0
- package/assets/voice/night-01.opus +0 -0
- package/assets/voice/night-03.opus +0 -0
- package/assets/voice/night-05.opus +0 -0
- package/assets/voice/noon-04.opus +0 -0
- package/assets/voice/petArm-02.opus +0 -0
- package/assets/voice/petCheek-00.opus +0 -0
- package/assets/voice/petCheek-01.opus +0 -0
- package/assets/voice/petCheek-02.opus +0 -0
- package/assets/voice/petHead-01.opus +0 -0
- package/assets/voice/petHead-03.opus +0 -0
- package/assets/voice/petHead-04.opus +0 -0
- package/assets/voice/praised-01.opus +0 -0
- package/assets/voice/praised-03.opus +0 -0
- package/assets/voice/question-00.opus +0 -0
- package/assets/voice/question-03.opus +0 -0
- package/assets/voice/question-04.opus +0 -0
- package/assets/voice/question-06.opus +0 -0
- package/assets/voice/shy-00.opus +0 -0
- package/assets/voice/spot-0-0.opus +0 -0
- package/assets/voice/spot-0-1.opus +0 -0
- package/assets/voice/spot-0-2.opus +0 -0
- package/assets/voice/spot-3-0.opus +0 -0
- package/assets/voice/spot-4-0.opus +0 -0
- package/assets/voice/spot-4-2.opus +0 -0
- package/assets/voice/spot-5-2.opus +0 -0
- package/assets/voice/spot-6-0.opus +0 -0
- package/assets/voice/spot-6-1.opus +0 -0
- package/assets/voice/spot-7-0.opus +0 -0
- package/assets/voice/spot-7-2.opus +0 -0
- package/assets/voice/spot-8-1.opus +0 -0
- package/assets/voice/tagent-00.opus +0 -0
- package/assets/voice/thinkFast-01.opus +0 -0
- package/assets/voice/thinkFast-02.opus +0 -0
- package/assets/voice/thinkFast-03.opus +0 -0
- package/assets/voice/thinkSlow-01.opus +0 -0
- package/assets/voice/thinkSlow-03.opus +0 -0
- package/assets/voice/thinking-01.opus +0 -0
- package/assets/voice/thinking-02.opus +0 -0
- package/assets/voice/thinking-03.opus +0 -0
- package/assets/voice/thinking-09.opus +0 -0
- package/assets/voice/tread-00.opus +0 -0
- package/assets/voice/tread-01.opus +0 -0
- package/assets/voice/trun-02.opus +0 -0
- package/assets/voice/tsun-00.opus +0 -0
- package/assets/voice/tsun-01.opus +0 -0
- package/assets/voice/tsun-04.opus +0 -0
- package/assets/voice/twrite-00.opus +0 -0
- package/assets/voice/unknown-01.opus +0 -0
- package/assets/voice/waitApproval-00.opus +0 -0
- package/assets/voice/waitApproval-01.opus +0 -0
- package/assets/voice/waitApproval-02.opus +0 -0
- package/assets/voice/waitApproval-03.opus +0 -0
- package/assets/voice/waitApprovalLate-02.opus +0 -0
- package/assets/voice/waitApprovalLate-03.opus +0 -0
- package/assets/voice/waitAsk-00.opus +0 -0
- package/assets/voice/waitAsk-02.opus +0 -0
- package/assets/voice/waitAskLate-03.opus +0 -0
- package/assets/voice/wake-03.opus +0 -0
- package/assets/voice/wake-04.opus +0 -0
- package/assets/voice/wake-05.opus +0 -0
- package/assets/voice/wake-06.opus +0 -0
- package/lib/client.js +7 -7
- package/lib/features/notes.js +172 -172
- package/lib/features/reminder.js +216 -216
- package/lib/l2d-plan.js +295 -295
- package/lib/l2d-tools.js +293 -293
- package/lib/ledger.js +163 -163
- package/lib/mys/config.js +183 -183
- package/lib/mys/ds.js +209 -209
- package/lib/mys/http.js +85 -85
- package/lib/mys/mys.js +419 -419
- package/lib/mys/qr.js +434 -434
- package/lib/mys/scheduler.js +206 -206
- package/lib/mys/store.js +248 -248
- package/lib/mys/tz.js +174 -174
- package/lib/wavtrim.js +245 -245
- package/lib/worldbook/NOTICE.md +18 -18
- package/lib/worldbook/data/Cyrene.md +111 -111
- package/lib/worldbook/data/_glossary.md +181 -181
- package/lib/worldbook/data/characters.md +289 -289
- package/lib/worldbook/data/story.md +130 -130
- package/lib/worldbook/data/world.md +182 -182
- package/lib/worldbook.js +189 -189
- package/package.json +72 -69
package/lib/mys/config.js
CHANGED
|
@@ -1,183 +1,183 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Plugin configuration: defaults, validation, and normalization.
|
|
3
|
-
*
|
|
4
|
-
* The configuration reaches the host from two places — the cordis entry's
|
|
5
|
-
* `config` and the user's saved section — so every field is normalized here
|
|
6
|
-
* and never trusted as-is.
|
|
7
|
-
*/
|
|
8
|
-
import { parseClock, resolveTimeZone } from './tz.js'
|
|
9
|
-
|
|
10
|
-
/** Every game the luna check-in endpoints cover, in display order. */
|
|
11
|
-
export const GAMES = [
|
|
12
|
-
{
|
|
13
|
-
id: 'genshin',
|
|
14
|
-
label: '原神',
|
|
15
|
-
biz: 'hk4e_cn',
|
|
16
|
-
actId: 'e202311201442471',
|
|
17
|
-
signgame: 'hk4e',
|
|
18
|
-
sendSigngame: true,
|
|
19
|
-
host: 'https://api-takumi.mihoyo.com',
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
id: 'starrail',
|
|
23
|
-
label: '崩坏:星穹铁道',
|
|
24
|
-
biz: 'hkrpg_cn',
|
|
25
|
-
actId: 'e202304121516551',
|
|
26
|
-
signgame: 'hkrpg',
|
|
27
|
-
sendSigngame: true,
|
|
28
|
-
host: 'https://api-takumi.mihoyo.com',
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
id: 'zzz',
|
|
32
|
-
label: '绝区零',
|
|
33
|
-
biz: 'nap_cn',
|
|
34
|
-
actId: 'e202406242138391',
|
|
35
|
-
signgame: 'zzz',
|
|
36
|
-
sendSigngame: true,
|
|
37
|
-
host: 'https://act-nap-api.mihoyo.com',
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
id: 'honkai3',
|
|
41
|
-
label: '崩坏3',
|
|
42
|
-
biz: 'bh3_cn',
|
|
43
|
-
actId: 'e202306201626331',
|
|
44
|
-
signgame: 'bh3',
|
|
45
|
-
sendSigngame: false,
|
|
46
|
-
host: 'https://api-takumi.mihoyo.com',
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
id: 'tears',
|
|
50
|
-
label: '未定事件簿',
|
|
51
|
-
biz: 'nxx_cn',
|
|
52
|
-
actId: 'e202202251749321',
|
|
53
|
-
signgame: 'nxx',
|
|
54
|
-
sendSigngame: false,
|
|
55
|
-
host: 'https://api-takumi.mihoyo.com',
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
id: 'bh2',
|
|
59
|
-
label: '崩坏学园2',
|
|
60
|
-
biz: 'bh2_cn',
|
|
61
|
-
actId: 'e202203291431091',
|
|
62
|
-
signgame: 'bh2',
|
|
63
|
-
sendSigngame: false,
|
|
64
|
-
host: 'https://api-takumi.mihoyo.com',
|
|
65
|
-
},
|
|
66
|
-
]
|
|
67
|
-
|
|
68
|
-
export const GAME_INDEX = new Map(GAMES.map((game) => [game.id, game]))
|
|
69
|
-
|
|
70
|
-
/** Defaults chosen to be conservative: one window, one run per day. */
|
|
71
|
-
export function defaultConfig() {
|
|
72
|
-
return {
|
|
73
|
-
enabled: true,
|
|
74
|
-
windows: [{ start: '18:00', end: '18:30' }],
|
|
75
|
-
timezone: '',
|
|
76
|
-
runWhenMissed: true,
|
|
77
|
-
games: {
|
|
78
|
-
genshin: true,
|
|
79
|
-
starrail: true,
|
|
80
|
-
zzz: true,
|
|
81
|
-
honkai3: true,
|
|
82
|
-
tears: false,
|
|
83
|
-
bh2: false,
|
|
84
|
-
},
|
|
85
|
-
gapMs: { min: 2000, max: 8000 },
|
|
86
|
-
retry: { attempts: 1, delayMs: 60000 },
|
|
87
|
-
device: { name: 'Xiaomi MI 6', model: 'Mi 6', sysVersion: '12', channel: 'miyousheluodi' },
|
|
88
|
-
client: { appVersion: '2.109.0', salt: 'd9200c846b10886e8c874fc33c8f308b' },
|
|
89
|
-
maxQrAgeMs: 180000,
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function clampInt(value, fallback, min, max) {
|
|
94
|
-
const number = typeof value === 'number' ? value : Number(value)
|
|
95
|
-
if (!Number.isFinite(number)) return fallback
|
|
96
|
-
return Math.min(max, Math.max(min, Math.round(number)))
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function pickString(value, fallback, maxLength) {
|
|
100
|
-
if (typeof value !== 'string') return fallback
|
|
101
|
-
const trimmed = value.trim()
|
|
102
|
-
if (trimmed === '' || trimmed.length > maxLength) return fallback
|
|
103
|
-
return trimmed
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function normalizeWindow(raw) {
|
|
107
|
-
if (raw === null || typeof raw !== 'object') return null
|
|
108
|
-
let start = parseClock(raw.start)
|
|
109
|
-
let end = parseClock(raw.end)
|
|
110
|
-
if (start === null || end === null) return null
|
|
111
|
-
// Leave room for a one-minute window at the very end of the day.
|
|
112
|
-
if (start > 1438) start = 1438
|
|
113
|
-
// An end at or before the start is what the user typed mid-edit; snap it to a
|
|
114
|
-
// one-minute window instead of dropping the window.
|
|
115
|
-
if (end <= start) end = Math.min(1439, start + 1)
|
|
116
|
-
if (end - start > 240) end = start + 240
|
|
117
|
-
const pad = (value) => String(value).padStart(2, '0')
|
|
118
|
-
return { start: `${pad(Math.floor(start / 60))}:${pad(start % 60)}`, end: `${pad(Math.floor(end / 60))}:${pad(end % 60)}` }
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function normalizeWindows(raw) {
|
|
122
|
-
const list = Array.isArray(raw) ? raw : []
|
|
123
|
-
const windows = []
|
|
124
|
-
for (const item of list) {
|
|
125
|
-
const window = normalizeWindow(item)
|
|
126
|
-
if (window === null) continue
|
|
127
|
-
// Duplicate times are allowed: the scheduler fires once per day and picks
|
|
128
|
-
// the first window that has not ended.
|
|
129
|
-
windows.push(window)
|
|
130
|
-
if (windows.length >= 4) break
|
|
131
|
-
}
|
|
132
|
-
if (windows.length === 0) return defaultConfig().windows
|
|
133
|
-
return windows.sort((left, right) => left.start.localeCompare(right.start))
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function normalizeGames(raw) {
|
|
137
|
-
const games = {}
|
|
138
|
-
for (const game of GAMES) {
|
|
139
|
-
const value = raw !== null && typeof raw === 'object' ? raw[game.id] : undefined
|
|
140
|
-
games[game.id] = typeof value === 'boolean' ? value : defaultConfig().games[game.id]
|
|
141
|
-
}
|
|
142
|
-
return games
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/** Merge one untrusted configuration object over the defaults. */
|
|
146
|
-
export function normalizeConfig(raw) {
|
|
147
|
-
const base = defaultConfig()
|
|
148
|
-
const input = raw !== null && typeof raw === 'object' ? raw : {}
|
|
149
|
-
|
|
150
|
-
const gapMin = clampInt(input?.gapMs?.min, base.gapMs.min, 500, 60000)
|
|
151
|
-
const gapMax = clampInt(input?.gapMs?.max, base.gapMs.max, gapMin, 120000)
|
|
152
|
-
|
|
153
|
-
const attempts = clampInt(input?.retry?.attempts, base.retry.attempts, 1, 3)
|
|
154
|
-
const delayMs = clampInt(input?.retry?.delayMs, base.retry.delayMs, 10000, 900000)
|
|
155
|
-
|
|
156
|
-
const maxQrAgeMs = clampInt(input?.maxQrAgeMs, base.maxQrAgeMs, 60000, 300000)
|
|
157
|
-
|
|
158
|
-
return {
|
|
159
|
-
enabled: typeof input.enabled === 'boolean' ? input.enabled : base.enabled,
|
|
160
|
-
windows: normalizeWindows(input.windows),
|
|
161
|
-
timezone: resolveTimeZone(pickString(input.timezone, '', 64) || undefined),
|
|
162
|
-
runWhenMissed: typeof input.runWhenMissed === 'boolean' ? input.runWhenMissed : base.runWhenMissed,
|
|
163
|
-
games: normalizeGames(input.games),
|
|
164
|
-
gapMs: { min: gapMin, max: gapMax },
|
|
165
|
-
retry: { attempts, delayMs },
|
|
166
|
-
device: {
|
|
167
|
-
name: pickString(input?.device?.name, base.device.name, 64),
|
|
168
|
-
model: pickString(input?.device?.model, base.device.model, 64),
|
|
169
|
-
sysVersion: pickString(input?.device?.sysVersion, base.device.sysVersion, 16),
|
|
170
|
-
channel: pickString(input?.device?.channel, base.device.channel, 32),
|
|
171
|
-
},
|
|
172
|
-
client: {
|
|
173
|
-
appVersion: pickString(input?.client?.appVersion, base.client.appVersion, 24),
|
|
174
|
-
salt: pickString(input?.client?.salt, base.client.salt, 64),
|
|
175
|
-
},
|
|
176
|
-
maxQrAgeMs,
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/** Which game ids the current configuration asks to sign. */
|
|
181
|
-
export function enabledGames(config) {
|
|
182
|
-
return GAMES.filter((game) => config.games[game.id] === true)
|
|
183
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Plugin configuration: defaults, validation, and normalization.
|
|
3
|
+
*
|
|
4
|
+
* The configuration reaches the host from two places — the cordis entry's
|
|
5
|
+
* `config` and the user's saved section — so every field is normalized here
|
|
6
|
+
* and never trusted as-is.
|
|
7
|
+
*/
|
|
8
|
+
import { parseClock, resolveTimeZone } from './tz.js'
|
|
9
|
+
|
|
10
|
+
/** Every game the luna check-in endpoints cover, in display order. */
|
|
11
|
+
export const GAMES = [
|
|
12
|
+
{
|
|
13
|
+
id: 'genshin',
|
|
14
|
+
label: '原神',
|
|
15
|
+
biz: 'hk4e_cn',
|
|
16
|
+
actId: 'e202311201442471',
|
|
17
|
+
signgame: 'hk4e',
|
|
18
|
+
sendSigngame: true,
|
|
19
|
+
host: 'https://api-takumi.mihoyo.com',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: 'starrail',
|
|
23
|
+
label: '崩坏:星穹铁道',
|
|
24
|
+
biz: 'hkrpg_cn',
|
|
25
|
+
actId: 'e202304121516551',
|
|
26
|
+
signgame: 'hkrpg',
|
|
27
|
+
sendSigngame: true,
|
|
28
|
+
host: 'https://api-takumi.mihoyo.com',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: 'zzz',
|
|
32
|
+
label: '绝区零',
|
|
33
|
+
biz: 'nap_cn',
|
|
34
|
+
actId: 'e202406242138391',
|
|
35
|
+
signgame: 'zzz',
|
|
36
|
+
sendSigngame: true,
|
|
37
|
+
host: 'https://act-nap-api.mihoyo.com',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: 'honkai3',
|
|
41
|
+
label: '崩坏3',
|
|
42
|
+
biz: 'bh3_cn',
|
|
43
|
+
actId: 'e202306201626331',
|
|
44
|
+
signgame: 'bh3',
|
|
45
|
+
sendSigngame: false,
|
|
46
|
+
host: 'https://api-takumi.mihoyo.com',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: 'tears',
|
|
50
|
+
label: '未定事件簿',
|
|
51
|
+
biz: 'nxx_cn',
|
|
52
|
+
actId: 'e202202251749321',
|
|
53
|
+
signgame: 'nxx',
|
|
54
|
+
sendSigngame: false,
|
|
55
|
+
host: 'https://api-takumi.mihoyo.com',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
id: 'bh2',
|
|
59
|
+
label: '崩坏学园2',
|
|
60
|
+
biz: 'bh2_cn',
|
|
61
|
+
actId: 'e202203291431091',
|
|
62
|
+
signgame: 'bh2',
|
|
63
|
+
sendSigngame: false,
|
|
64
|
+
host: 'https://api-takumi.mihoyo.com',
|
|
65
|
+
},
|
|
66
|
+
]
|
|
67
|
+
|
|
68
|
+
export const GAME_INDEX = new Map(GAMES.map((game) => [game.id, game]))
|
|
69
|
+
|
|
70
|
+
/** Defaults chosen to be conservative: one window, one run per day. */
|
|
71
|
+
export function defaultConfig() {
|
|
72
|
+
return {
|
|
73
|
+
enabled: true,
|
|
74
|
+
windows: [{ start: '18:00', end: '18:30' }],
|
|
75
|
+
timezone: '',
|
|
76
|
+
runWhenMissed: true,
|
|
77
|
+
games: {
|
|
78
|
+
genshin: true,
|
|
79
|
+
starrail: true,
|
|
80
|
+
zzz: true,
|
|
81
|
+
honkai3: true,
|
|
82
|
+
tears: false,
|
|
83
|
+
bh2: false,
|
|
84
|
+
},
|
|
85
|
+
gapMs: { min: 2000, max: 8000 },
|
|
86
|
+
retry: { attempts: 1, delayMs: 60000 },
|
|
87
|
+
device: { name: 'Xiaomi MI 6', model: 'Mi 6', sysVersion: '12', channel: 'miyousheluodi' },
|
|
88
|
+
client: { appVersion: '2.109.0', salt: 'd9200c846b10886e8c874fc33c8f308b' },
|
|
89
|
+
maxQrAgeMs: 180000,
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function clampInt(value, fallback, min, max) {
|
|
94
|
+
const number = typeof value === 'number' ? value : Number(value)
|
|
95
|
+
if (!Number.isFinite(number)) return fallback
|
|
96
|
+
return Math.min(max, Math.max(min, Math.round(number)))
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function pickString(value, fallback, maxLength) {
|
|
100
|
+
if (typeof value !== 'string') return fallback
|
|
101
|
+
const trimmed = value.trim()
|
|
102
|
+
if (trimmed === '' || trimmed.length > maxLength) return fallback
|
|
103
|
+
return trimmed
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function normalizeWindow(raw) {
|
|
107
|
+
if (raw === null || typeof raw !== 'object') return null
|
|
108
|
+
let start = parseClock(raw.start)
|
|
109
|
+
let end = parseClock(raw.end)
|
|
110
|
+
if (start === null || end === null) return null
|
|
111
|
+
// Leave room for a one-minute window at the very end of the day.
|
|
112
|
+
if (start > 1438) start = 1438
|
|
113
|
+
// An end at or before the start is what the user typed mid-edit; snap it to a
|
|
114
|
+
// one-minute window instead of dropping the window.
|
|
115
|
+
if (end <= start) end = Math.min(1439, start + 1)
|
|
116
|
+
if (end - start > 240) end = start + 240
|
|
117
|
+
const pad = (value) => String(value).padStart(2, '0')
|
|
118
|
+
return { start: `${pad(Math.floor(start / 60))}:${pad(start % 60)}`, end: `${pad(Math.floor(end / 60))}:${pad(end % 60)}` }
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function normalizeWindows(raw) {
|
|
122
|
+
const list = Array.isArray(raw) ? raw : []
|
|
123
|
+
const windows = []
|
|
124
|
+
for (const item of list) {
|
|
125
|
+
const window = normalizeWindow(item)
|
|
126
|
+
if (window === null) continue
|
|
127
|
+
// Duplicate times are allowed: the scheduler fires once per day and picks
|
|
128
|
+
// the first window that has not ended.
|
|
129
|
+
windows.push(window)
|
|
130
|
+
if (windows.length >= 4) break
|
|
131
|
+
}
|
|
132
|
+
if (windows.length === 0) return defaultConfig().windows
|
|
133
|
+
return windows.sort((left, right) => left.start.localeCompare(right.start))
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function normalizeGames(raw) {
|
|
137
|
+
const games = {}
|
|
138
|
+
for (const game of GAMES) {
|
|
139
|
+
const value = raw !== null && typeof raw === 'object' ? raw[game.id] : undefined
|
|
140
|
+
games[game.id] = typeof value === 'boolean' ? value : defaultConfig().games[game.id]
|
|
141
|
+
}
|
|
142
|
+
return games
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Merge one untrusted configuration object over the defaults. */
|
|
146
|
+
export function normalizeConfig(raw) {
|
|
147
|
+
const base = defaultConfig()
|
|
148
|
+
const input = raw !== null && typeof raw === 'object' ? raw : {}
|
|
149
|
+
|
|
150
|
+
const gapMin = clampInt(input?.gapMs?.min, base.gapMs.min, 500, 60000)
|
|
151
|
+
const gapMax = clampInt(input?.gapMs?.max, base.gapMs.max, gapMin, 120000)
|
|
152
|
+
|
|
153
|
+
const attempts = clampInt(input?.retry?.attempts, base.retry.attempts, 1, 3)
|
|
154
|
+
const delayMs = clampInt(input?.retry?.delayMs, base.retry.delayMs, 10000, 900000)
|
|
155
|
+
|
|
156
|
+
const maxQrAgeMs = clampInt(input?.maxQrAgeMs, base.maxQrAgeMs, 60000, 300000)
|
|
157
|
+
|
|
158
|
+
return {
|
|
159
|
+
enabled: typeof input.enabled === 'boolean' ? input.enabled : base.enabled,
|
|
160
|
+
windows: normalizeWindows(input.windows),
|
|
161
|
+
timezone: resolveTimeZone(pickString(input.timezone, '', 64) || undefined),
|
|
162
|
+
runWhenMissed: typeof input.runWhenMissed === 'boolean' ? input.runWhenMissed : base.runWhenMissed,
|
|
163
|
+
games: normalizeGames(input.games),
|
|
164
|
+
gapMs: { min: gapMin, max: gapMax },
|
|
165
|
+
retry: { attempts, delayMs },
|
|
166
|
+
device: {
|
|
167
|
+
name: pickString(input?.device?.name, base.device.name, 64),
|
|
168
|
+
model: pickString(input?.device?.model, base.device.model, 64),
|
|
169
|
+
sysVersion: pickString(input?.device?.sysVersion, base.device.sysVersion, 16),
|
|
170
|
+
channel: pickString(input?.device?.channel, base.device.channel, 32),
|
|
171
|
+
},
|
|
172
|
+
client: {
|
|
173
|
+
appVersion: pickString(input?.client?.appVersion, base.client.appVersion, 24),
|
|
174
|
+
salt: pickString(input?.client?.salt, base.client.salt, 64),
|
|
175
|
+
},
|
|
176
|
+
maxQrAgeMs,
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** Which game ids the current configuration asks to sign. */
|
|
181
|
+
export function enabledGames(config) {
|
|
182
|
+
return GAMES.filter((game) => config.games[game.id] === true)
|
|
183
|
+
}
|