dsh-pet 0.1.4 → 0.1.5
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.en.md +10 -10
- package/README.md +11 -11
- package/assets/config.jsonc +83 -0
- package/assets/thumb//344/270/211/347/220/203/346/212/233/346/216/245.webm +0 -0
- package/assets/thumb//344/270/213/344/272/224/345/255/220/346/243/213.webm +0 -0
- package/assets/thumb//344/270/234/345/274/240/350/245/277/346/234/233.webm +0 -0
- package/assets/thumb//344/270/255/347/247/213/350/265/217/346/234/210/345/220/203/346/234/210/351/245/274.webm +0 -0
- package/assets/thumb//344/274/230/351/233/205/345/245/263/344/273/206/350/210/236.webm +0 -0
- package/assets/thumb//345/201/267/345/220/203/351/233/266/351/243/237/350/242/253/346/212/223/344/275/217.webm +0 -0
- package/assets/thumb//345/206/231/344/273/243/347/240/201.webm +0 -0
- package/assets/thumb//345/206/231/347/246/217/345/255/227.webm +0 -0
- package/assets/thumb//345/207/255/347/251/272/347/224/237/350/212/261.webm +0 -0
- package/assets/thumb//345/212/250/347/211/251/347/216/257/347/273/225.webm +0 -0
- package/assets/thumb//345/216/237/345/234/260/344/270/223/345/277/203/347/216/251/351/255/224/346/226/271.webm +0 -0
- package/assets/thumb//345/216/237/345/234/260/345/260/217/346/206/251/346/262/211/347/234/240.webm +0 -0
- package/assets/thumb//345/216/237/345/234/260/345/267/246/350/275/254/345/245/224/350/267/221.webm +0 -0
- package/assets/thumb//345/216/237/345/234/260/346/225/262/345/207/273/346/241/214/351/235/242/344/272/222/345/212/250.webm +0 -0
- package/assets/thumb//345/216/237/345/234/260/346/274/202/346/265/256/350/270/217/346/255/245.webm +0 -0
- package/assets/thumb//345/216/237/345/234/260/350/267/263/350/267/203/346/212/223/347/242/216/345/244/264/351/241/266/347/211/251/345/223/201.webm +0 -0
- package/assets/thumb//345/216/237/345/234/260/350/271/262/344/270/213/347/216/251/347/216/251/345/205/267/346/261/275/350/275/246.webm +0 -0
- package/assets/thumb//345/216/237/345/234/260/351/207/215/345/212/233/344/270/213/350/271/262/345/216/213/347/274/251.webm +0 -0
- package/assets/thumb//345/217/230/351/270/275/345/255/220.webm +0 -0
- package/assets/thumb//345/217/257/347/210/261/345/256/205/350/210/236.webm +0 -0
- package/assets/thumb//345/220/203Token.webm +0 -0
- package/assets/thumb//345/220/203/345/206/260/346/267/207/346/267/213/350/236/215/345/214/226.webm +0 -0
- package/assets/thumb//345/220/203/345/215/210/351/244/220.webm +0 -0
- package/assets/thumb//345/220/203/345/244/247/351/227/270/350/237/271.webm +0 -0
- package/assets/thumb//345/220/203/345/271/264/347/263/225.webm +0 -0
- package/assets/thumb//345/220/203/346/227/251/351/244/220.webm +0 -0
- package/assets/thumb//345/220/203/346/231/232/351/244/220.webm +0 -0
- package/assets/thumb//345/220/203/346/261/244/345/234/206.webm +0 -0
- package/assets/thumb//345/220/203/347/231/275/351/245/255.webm +0 -0
- package/assets/thumb//345/220/203/347/262/275/345/255/220.webm +0 -0
- package/assets/thumb//345/220/203/347/263/226/350/221/253/350/212/246.webm +0 -0
- package/assets/thumb//345/220/203/350/205/212/345/205/253/347/262/245.webm +0 -0
- package/assets/thumb//345/220/203/350/245/277/347/223/234.webm +0 -0
- package/assets/thumb//345/220/203/351/207/215/351/230/263/347/263/225.webm +0 -0
- package/assets/thumb//345/220/203/351/225/277/345/257/277/351/235/242.webm +0 -0
- package/assets/thumb//345/220/203/351/235/222/345/233/242.webm +0 -0
- package/assets/thumb//345/220/203/351/245/272/345/255/220.webm +0 -0
- package/assets/thumb//345/220/271/346/260/224/347/220/203.webm +0 -0
- package/assets/thumb//345/220/271/347/254/233/345/255/220.webm +0 -0
- package/assets/thumb//345/223/210/346/254/240/350/277/236/345/244/251.webm +0 -0
- package/assets/thumb//345/240/206/351/233/252/344/272/272.webm +0 -0
- package/assets/thumb//345/244/247/345/217/243/345/220/203/351/233/266/351/243/237.webm +0 -0
- package/assets/thumb//345/245/263/344/273/206/345/261/210/350/206/235/347/244/274/344/273/252.webm +0 -0
- package/assets/thumb//345/260/217/345/271/205/345/272/246/345/216/237/345/234/260360/345/272/246/346/227/213/350/275/254/345/261/225/347/244/272.webm +0 -0
- package/assets/thumb//345/260/217/346/217/220/347/220/264/346/274/224/345/245/217.webm +0 -0
- package/assets/thumb//345/276/205/346/234/272/345/221/274/345/220/270/344/274/221/351/227/262.webm +0 -0
- package/assets/thumb//346/202/240/351/227/262/345/223/274/346/255/214.webm +0 -0
- package/assets/thumb//346/211/221/345/205/213/351/255/224/346/234/257.webm +0 -0
- package/assets/thumb//346/211/223/347/236/214/347/235/241/350/242/253/346/203/212/351/206/222.webm +0 -0
- package/assets/thumb//346/212/275/351/231/200/350/236/272.webm +0 -0
- package/assets/thumb//346/213/206/347/244/274/347/211/251.webm +0 -0
- package/assets/thumb//346/217/222/350/214/261/350/220/270/350/265/217/350/217/212.webm +0 -0
- package/assets/thumb//346/221/207/346/211/207/347/272/263/345/207/211.webm +0 -0
- package/assets/thumb//346/222/270/347/214/253.webm +0 -0
- package/assets/thumb//346/224/266/347/272/242/345/214/205.webm +0 -0
- package/assets/thumb//346/224/276/345/255/224/346/230/216/347/201/257.webm +0 -0
- package/assets/thumb//346/224/276/346/262/263/347/201/257.webm +0 -0
- package/assets/thumb//346/224/276/347/203/237/350/212/261.webm +0 -0
- package/assets/thumb//346/224/276/351/243/216/347/255/235.webm +0 -0
- package/assets/thumb//346/225/264/344/275/223/346/215/242/350/243/205/350/257/225/350/211/262.webm +0 -0
- package/assets/thumb//346/230/257/345/225/212/357/274/214/345/220/203/344/273/200/344/271/210.webm +0 -0
- package/assets/thumb//346/231/250/351/227/264/345/210/267/347/211/231.webm +0 -0
- package/assets/thumb//346/266/256/347/201/253/351/224/205.webm +0 -0
- package/assets/thumb//346/267/261/345/272/246/346/200/235/350/200/203/347/242/216/347/242/216/345/277/265.webm +0 -0
- package/assets/thumb//347/202/271/345/207/273/345/233/236/345/272/224-/345/202/262/345/250/207/347/224/237/346/260/224.webm +0 -0
- package/assets/thumb//347/202/271/345/207/273/345/233/236/345/272/224-/345/205/203/346/260/224/346/214/245/346/211/213.webm +0 -0
- package/assets/thumb//347/202/271/345/207/273/345/233/236/345/272/224-/345/256/263/347/276/236/346/203/212/350/256/266.webm +0 -0
- package/assets/thumb//347/202/271/345/207/273/345/233/236/345/272/224-/345/274/200/345/277/203/350/267/203/345/212/250.webm +0 -0
- package/assets/thumb//347/202/271/345/207/273/345/233/236/345/272/224-/346/214/240/347/227/222/345/222/257/345/222/257/347/254/221.webm +0 -0
- package/assets/thumb//347/205/247/351/225/234/345/255/220.webm +0 -0
- package/assets/thumb//347/216/251/346/260/264/346/236/252.webm +0 -0
- package/assets/thumb//347/216/251/346/270/270/346/210/217/346/260/224/346/200/245/350/264/245/345/235/217.webm +0 -0
- package/assets/thumb//347/224/250/351/262/270/351/261/274/345/260/276/345/267/264/346/213/215/346/211/223/345/234/260/351/235/242.webm +0 -0
- package/assets/thumb//347/251/277/351/222/210/344/271/236/345/267/247.webm +0 -0
- package/assets/thumb//350/210/236/347/213/256/345/244/264.webm +0 -0
- package/assets/thumb//350/215/241/347/247/213/345/215/203.webm +0 -0
- package/assets/thumb//350/220/214/345/214/226/345/260/217/345/271/275/347/201/265.webm +0 -0
- package/assets/thumb//350/223/235/351/262/270/347/216/260/344/270/226.webm +0 -0
- package/assets/thumb//350/235/264/350/235/266/350/234/234/350/234/202/347/216/257/347/273/225/345/244/264/351/241/266/345/274/200/350/212/261.webm +0 -0
- package/assets/thumb//350/236/203/350/237/271/350/265/260/350/267/257.webm +0 -0
- package/assets/thumb//350/242/253/345/220/223/344/270/200/350/267/263.webm +0 -0
- package/assets/thumb//350/242/253/350/220/275/345/217/266/346/267/271/346/262/241.webm +0 -0
- package/assets/thumb//350/242/253/351/274/240/346/240/207/346/213/226/346/213/275/346/202/254/347/251/272/345/217/215/351/246/210.webm +0 -0
- package/assets/thumb//350/243/205/347/202/271/345/234/243/350/257/236/346/240/221.webm +0 -0
- package/assets/thumb//350/256/250/347/263/226/345/215/227/347/223/234/347/201/257.webm +0 -0
- package/assets/thumb//350/266/205/345/244/247/344/274/270/346/207/222/350/205/260.webm +0 -0
- package/assets/thumb//350/270/242/346/257/275/345/255/220.webm +0 -0
- package/assets/thumb//350/275/273/345/277/253/346/221/207/346/221/206/350/210/236.webm +0 -0
- package/assets/thumb//350/275/273/345/277/253/350/256/260/345/275/225.webm +0 -0
- package/assets/thumb//351/252/221/346/234/250/351/251/254.webm +0 -0
- package/assets/thumb//351/262/270/351/261/274/345/220/220/346/263/241/346/263/241/347/211/271/346/225/210.webm +0 -0
- package/lib/client.js +568 -693
- package/lib/index.js +80 -125
- package/package.json +20 -6
- package/src/client/app.ts +452 -0
- package/src/client/config.ts +77 -0
- package/src/client/constants.ts +9 -0
- package/src/client/index.ts +15 -0
- package/src/client/pickers.ts +30 -0
- package/src/client/types.ts +37 -0
- package/src/env.d.ts +6 -0
- package/src/host/index.ts +119 -0
- package/assets/thumb//345/260/217/345/271/205/345/272/246/345/216/237/345/234/260 360 /345/272/246/346/227/213/350/275/254/345/261/225/347/244/272.webm +0 -0
- package/assets/thumb//347/202/271/345/207/273/345/233/236/345/272/224 - /345/202/262/345/250/207/347/224/237/346/260/224/357/274/210/344/276/247/350/272/253/345/261/225/347/244/272/357/274/211.webm +0 -0
- package/assets/thumb//347/202/271/345/207/273/345/233/236/345/272/224 - /345/256/263/347/276/236/346/203/212/350/256/266.webm +0 -0
- package/assets/thumb//347/202/271/345/207/273/345/233/236/345/272/224 - /345/274/200/345/277/203/350/267/203/345/212/250.webm +0 -0
- package/assets/thumb//350/242/253/345/220/223/344/270/200/350/267/263/357/274/210/347/202/270/346/257/233/357/274/211.webm +0 -0
package/lib/client.js
CHANGED
|
@@ -1,693 +1,568 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
const
|
|
195
|
-
const
|
|
196
|
-
const
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
const
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
el.
|
|
245
|
-
el.
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
if (
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
const
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
};
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
// 窗口变化时位置跟随。
|
|
570
|
-
setCustomPos({
|
|
571
|
-
rx: (e.clientX - d.offX) / window.innerWidth,
|
|
572
|
-
ry: (e.clientY - d.offY) / window.innerHeight,
|
|
573
|
-
});
|
|
574
|
-
const stageEl = stageRef.current;
|
|
575
|
-
if (stageEl) stageEl.style.transform = 'translateY(' + bottomPad + 'px)'; // 恢复落地对齐
|
|
576
|
-
setAnim(IDLE);
|
|
577
|
-
setOnce(false);
|
|
578
|
-
}
|
|
579
|
-
// 没拖过:交给 handleClick
|
|
580
|
-
};
|
|
581
|
-
|
|
582
|
-
// ---- 点击回应(仅真点击触发,拖拽后的 click 被忽略) ----
|
|
583
|
-
const handleClick = (e) => {
|
|
584
|
-
const d = dragRef.current;
|
|
585
|
-
if (d.active || d.dragging || justDraggedRef.current) return; // 拖拽中/刚拖完:忽略
|
|
586
|
-
if (once && animRef.current !== IDLE) return; // 正在播一次性动画:不打断
|
|
587
|
-
stopMove(); // 点击打断移动
|
|
588
|
-
setOnce(true);
|
|
589
|
-
setAnim(pick(CLICKS)); // 随机一个点击回应动画
|
|
590
|
-
};
|
|
591
|
-
|
|
592
|
-
// ============================================================================
|
|
593
|
-
// 渲染
|
|
594
|
-
// ============================================================================
|
|
595
|
-
// 落地对齐:视频是 640×360 画布、脚在 y=330,脚底距画布底 30px(8.33%)。
|
|
596
|
-
// 舞台是 16:9(高 = size×9/16),脚底距舞台底 = 舞台高 × 8.33%;
|
|
597
|
-
// bottomPad 就是把这个距离下移,让"脚"正好落在视口底线上。
|
|
598
|
-
const bottomPad = (size * 9 / 16 * (CANVAS_H - FEET_Y)) / CANVAS_H;
|
|
599
|
-
// 舞台样式:拖拽中无偏移;平时 translateY(bottomPad) 落地
|
|
600
|
-
const stageStyle = dragging
|
|
601
|
-
? { transform: 'none' }
|
|
602
|
-
: { transform: 'translateY(' + bottomPad + 'px)' };
|
|
603
|
-
|
|
604
|
-
// 根容器样式:有自定义位置(拖过/走过)就按"相对窗口比例 × 当前窗口尺寸"定位;
|
|
605
|
-
// 否则不设(走 CSS 的 data-corner 默认角落,天然响应式)。
|
|
606
|
-
// resize 后重渲染会用新尺寸重算 → 宠物保持相对位置;
|
|
607
|
-
// 同时钳制到窗口内,防止窗口缩小到宠物放不下时跑出屏幕。
|
|
608
|
-
const rootStyle = customPos
|
|
609
|
-
? (() => {
|
|
610
|
-
const rx = customPos.rx;
|
|
611
|
-
const ry = customPos.ry;
|
|
612
|
-
const left = Math.min(Math.max(rx * window.innerWidth - halfW, 0), window.innerWidth - size);
|
|
613
|
-
const top = Math.min(Math.max(ry * window.innerHeight - halfH, 0), window.innerHeight - size * 9 / 16);
|
|
614
|
-
return { left: left + 'px', top: top + 'px', right: 'auto', bottom: 'auto' };
|
|
615
|
-
})()
|
|
616
|
-
: {};
|
|
617
|
-
|
|
618
|
-
// 两个 video 共用的 props(纯播放属性,交互交给命中层)
|
|
619
|
-
const commonVideoProps = {
|
|
620
|
-
muted: true,
|
|
621
|
-
playsInline: true,
|
|
622
|
-
autoPlay: true,
|
|
623
|
-
title: 'dsh-pet',
|
|
624
|
-
};
|
|
625
|
-
// 命中层 props:覆盖 HIT_BOX 区域,承载全部交互事件与抓取光标。
|
|
626
|
-
// 命中层内必然命中人物,光标固定 grab(拖拽中 .dragging 类显示 grabbing)。
|
|
627
|
-
const hitProps = {
|
|
628
|
-
className: 'dsh-pet-hit',
|
|
629
|
-
style: {
|
|
630
|
-
left: (HIT_BOX.x0 / 640 * 100) + '%',
|
|
631
|
-
top: (HIT_BOX.y0 / 360 * 100) + '%',
|
|
632
|
-
width: ((HIT_BOX.x1 - HIT_BOX.x0) / 640 * 100) + '%',
|
|
633
|
-
height: ((HIT_BOX.y1 - HIT_BOX.y0) / 360 * 100) + '%',
|
|
634
|
-
},
|
|
635
|
-
onMouseEnter: (e) => { if (!dragRef.current.active) e.currentTarget.style.cursor = 'grab'; },
|
|
636
|
-
onMouseLeave: (e) => { if (!dragRef.current.active) e.currentTarget.style.cursor = 'default'; },
|
|
637
|
-
onClick: handleClick,
|
|
638
|
-
onPointerDown: handlePointerDown,
|
|
639
|
-
onPointerMove: handlePointerMove,
|
|
640
|
-
onPointerUp: handlePointerUp,
|
|
641
|
-
onPointerCancel: handlePointerUp,
|
|
642
|
-
title: 'dsh-pet',
|
|
643
|
-
};
|
|
644
|
-
|
|
645
|
-
// 渲染树:root > stage > [video A, video B, 命中层]
|
|
646
|
-
// A 初始带 is-front(显示),B 隐藏待命;命中层在最上层承载交互
|
|
647
|
-
return h('div', {
|
|
648
|
-
ref: rootRef,
|
|
649
|
-
className: 'dsh-pet-root',
|
|
650
|
-
'data-corner': corner, // CSS 决定默认角落
|
|
651
|
-
'data-facing': facing, // CSS 决定是否镜像
|
|
652
|
-
style: Object.assign({ '--dsh-pet-size': size + 'px' }, rootStyle),
|
|
653
|
-
children: h('div', {
|
|
654
|
-
ref: stageRef,
|
|
655
|
-
className: 'dsh-pet-stage',
|
|
656
|
-
style: stageStyle,
|
|
657
|
-
children: [
|
|
658
|
-
h('video', Object.assign({}, commonVideoProps, { ref: videoARef, className: 'dsh-pet-video is-front' })),
|
|
659
|
-
h('video', Object.assign({}, commonVideoProps, { ref: videoBRef, className: 'dsh-pet-video' })),
|
|
660
|
-
h('div', hitProps),
|
|
661
|
-
],
|
|
662
|
-
}),
|
|
663
|
-
});
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
// ============================================================================
|
|
667
|
-
// 插件主体(Cordis 插件三件套:name / inject / apply)
|
|
668
|
-
// ============================================================================
|
|
669
|
-
const name = 'pet'; // 插件行 id(与 cordis.patch.yml 一致)
|
|
670
|
-
const inject = ['slots']; // 需要注入的服务:slots(槽位注册表)
|
|
671
|
-
|
|
672
|
-
// apply:插件被激活时调用
|
|
673
|
-
function apply(ctx, config) {
|
|
674
|
-
// 官方"叠加式"注册模式:
|
|
675
|
-
// slots.inject 等 shell.overlay 槽位被声明后,再注册我们的条目。
|
|
676
|
-
// 用 generator + yield 形式(与官方 dsh-client-ui-directory-picker-native 一致),
|
|
677
|
-
// 这样不会替换其他条目,而是以 id='pet' 叠加进列表槽。
|
|
678
|
-
ctx.slots.inject('shell.overlay', function* () {
|
|
679
|
-
yield ctx.slots.register({
|
|
680
|
-
name: 'shell.overlay',
|
|
681
|
-
id: 'pet', // 列表槽的条目 id(唯一)
|
|
682
|
-
order: 1000, // 排序(大 = 靠后渲染)
|
|
683
|
-
}, (ownerProps) => h(Pet, { config, ...ownerProps }));
|
|
684
|
-
});
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
// 导出插件三件套(Cordis Loader 需要)
|
|
688
|
-
exports.apply = apply;
|
|
689
|
-
exports.inject = inject;
|
|
690
|
-
exports.name = name;
|
|
691
|
-
return module.exports;
|
|
692
|
-
}
|
|
693
|
-
});
|
|
1
|
+
|
|
2
|
+
//#region src/client/pickers.ts
|
|
3
|
+
const pick = (pool, exclude) => {
|
|
4
|
+
const entries = exclude ? pool.filter((n) => n !== exclude) : pool;
|
|
5
|
+
return entries[Math.floor(Math.random() * entries.length)];
|
|
6
|
+
};
|
|
7
|
+
const randomBetween = (min, max) => Math.floor(min + Math.random() * (max - min));
|
|
8
|
+
const pickWeightedCategory = (categories, facing) => {
|
|
9
|
+
const cats = categories.filter((c) => c.actions.length > 0);
|
|
10
|
+
if (!cats.length) return null;
|
|
11
|
+
const filtered = cats.filter((c) => !(c.noMirror && facing === "right"));
|
|
12
|
+
const eligible = filtered.length ? filtered : cats;
|
|
13
|
+
const totalW = eligible.reduce((s, c) => s + c.weight, 0) || 1;
|
|
14
|
+
let t = Math.random() * totalW;
|
|
15
|
+
for (const c of eligible) {
|
|
16
|
+
t -= c.weight;
|
|
17
|
+
if (t <= 0) return c;
|
|
18
|
+
}
|
|
19
|
+
return eligible[eligible.length - 1];
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/client/config.ts
|
|
24
|
+
const FALLBACK_IDLE = "待机呼吸休闲";
|
|
25
|
+
const DEFAULT_MOVE_PARAMS = {
|
|
26
|
+
minDist: 60,
|
|
27
|
+
maxDist: 240,
|
|
28
|
+
margin: 20,
|
|
29
|
+
leadSec: 2,
|
|
30
|
+
tailSec: 2
|
|
31
|
+
};
|
|
32
|
+
const stripJsonc = (src) => src.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^\\:])\/\/.*$/gm, "$1").trim();
|
|
33
|
+
const buildMinimalAnim = () => ({
|
|
34
|
+
idle: [FALLBACK_IDLE],
|
|
35
|
+
turn: [],
|
|
36
|
+
drag: [],
|
|
37
|
+
clicks: [],
|
|
38
|
+
moves: {
|
|
39
|
+
default: { ...DEFAULT_MOVE_PARAMS },
|
|
40
|
+
actions: []
|
|
41
|
+
},
|
|
42
|
+
categories: [],
|
|
43
|
+
weights: {
|
|
44
|
+
idle: 100,
|
|
45
|
+
turn: 0,
|
|
46
|
+
move: 0
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
const buildAnim = (obj) => {
|
|
50
|
+
const a = obj?.animations;
|
|
51
|
+
const w = obj?.animationWeights ?? {};
|
|
52
|
+
const strArr = (x) => Array.isArray(x) ? x.map(String).filter(Boolean) : [];
|
|
53
|
+
const idle = strArr(a?.idle);
|
|
54
|
+
if (!idle.length) idle.push(FALLBACK_IDLE);
|
|
55
|
+
const turn = strArr(a?.turn);
|
|
56
|
+
const drag = strArr(a?.drag);
|
|
57
|
+
const clicks = strArr(a?.clicks);
|
|
58
|
+
let mdef = { ...DEFAULT_MOVE_PARAMS };
|
|
59
|
+
let mActs = [];
|
|
60
|
+
if (a?.moves && typeof a.moves === "object") {
|
|
61
|
+
if (a.moves.default && typeof a.moves.default === "object") mdef = {
|
|
62
|
+
...mdef,
|
|
63
|
+
...a.moves.default
|
|
64
|
+
};
|
|
65
|
+
if (Array.isArray(a.moves.actions)) {
|
|
66
|
+
const list = a.moves.actions.filter((x) => x && x.name).map((x) => ({
|
|
67
|
+
name: String(x.name),
|
|
68
|
+
params: x.params && typeof x.params === "object" ? { ...x.params } : void 0
|
|
69
|
+
}));
|
|
70
|
+
if (list.length) mActs = list;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
let cats = [];
|
|
74
|
+
if (Array.isArray(a?.categories)) {
|
|
75
|
+
const list = a.categories.filter((c) => c && c.id && Array.isArray(c.actions) && c.actions.length).map((c) => ({
|
|
76
|
+
id: String(c.id),
|
|
77
|
+
weight: Number(c.weight),
|
|
78
|
+
noMirror: !!c.noMirror,
|
|
79
|
+
actions: c.actions.map(String)
|
|
80
|
+
}));
|
|
81
|
+
if (list.length) cats = list;
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
idle,
|
|
85
|
+
turn,
|
|
86
|
+
drag,
|
|
87
|
+
clicks,
|
|
88
|
+
moves: {
|
|
89
|
+
default: mdef,
|
|
90
|
+
actions: mActs
|
|
91
|
+
},
|
|
92
|
+
categories: cats,
|
|
93
|
+
weights: {
|
|
94
|
+
idle: Number(w.idle) >= 0 ? Number(w.idle) : 10,
|
|
95
|
+
turn: Number(w.turn) >= 0 ? Number(w.turn) : 5,
|
|
96
|
+
move: Number(w.move) >= 0 ? Number(w.move) : 5
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/client/constants.ts
|
|
103
|
+
const CANVAS_H = 360;
|
|
104
|
+
const FEET_Y = 330;
|
|
105
|
+
const HIT_BOX = {
|
|
106
|
+
x0: 200,
|
|
107
|
+
y0: 50,
|
|
108
|
+
x1: 440,
|
|
109
|
+
y1: 335
|
|
110
|
+
};
|
|
111
|
+
const DRAG_THRESHOLD = 5;
|
|
112
|
+
|
|
113
|
+
//#endregion
|
|
114
|
+
//#region src/client/app.ts
|
|
115
|
+
/** 支持的角落白名单 */
|
|
116
|
+
const CORNERS = [
|
|
117
|
+
"top-left",
|
|
118
|
+
"top-right",
|
|
119
|
+
"bottom-left",
|
|
120
|
+
"bottom-right"
|
|
121
|
+
];
|
|
122
|
+
function makeFactory() {
|
|
123
|
+
return (require) => {
|
|
124
|
+
var module = { exports: {} };
|
|
125
|
+
const react = require("react");
|
|
126
|
+
const { useEffect, useRef, useState } = react;
|
|
127
|
+
const { jsx: h } = require("react/jsx-runtime");
|
|
128
|
+
const css = [
|
|
129
|
+
".dsh-pet-root{position:fixed;z-index:40;pointer-events:none;user-select:none}",
|
|
130
|
+
".dsh-pet-root[data-corner=\"bottom-right\"]{right:var(--dsh-pet-mx,24px);bottom:var(--dsh-pet-my,0)}",
|
|
131
|
+
".dsh-pet-root[data-corner=\"bottom-left\"]{left:var(--dsh-pet-mx,24px);bottom:var(--dsh-pet-my,0)}",
|
|
132
|
+
".dsh-pet-root[data-corner=\"top-right\"]{right:var(--dsh-pet-mx,24px);top:var(--dsh-pet-my,0)}",
|
|
133
|
+
".dsh-pet-root[data-corner=\"top-left\"]{left:var(--dsh-pet-mx,24px);top:var(--dsh-pet-my,0)}",
|
|
134
|
+
".dsh-pet-stage{position:relative;width:var(--dsh-pet-size,462px);height:calc(var(--dsh-pet-size,462px)*9/16);pointer-events:none}",
|
|
135
|
+
".dsh-pet-video{position:absolute;inset:0;width:100%;height:100%;object-fit:contain;pointer-events:none;opacity:0;transition:opacity .18s ease;transform-origin:center}",
|
|
136
|
+
".dsh-pet-video.is-front{opacity:1}",
|
|
137
|
+
".dsh-pet-hit{position:absolute;pointer-events:auto;cursor:default;z-index:1}",
|
|
138
|
+
".dsh-pet-hit.dragging{cursor:grabbing}",
|
|
139
|
+
"@media (prefers-reduced-motion: reduce){.dsh-pet-video{transition:none}}"
|
|
140
|
+
].join("\n");
|
|
141
|
+
const cssTag = "dsh-pet/style.css";
|
|
142
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=\"" + cssTag + "\"]") === null) {
|
|
143
|
+
const tag = document.createElement("style");
|
|
144
|
+
tag.dataset.plugin = "dsh-pet";
|
|
145
|
+
tag.dataset.pluginCss = cssTag;
|
|
146
|
+
tag.textContent = css;
|
|
147
|
+
document.head.appendChild(tag);
|
|
148
|
+
}
|
|
149
|
+
let ANIM = buildMinimalAnim();
|
|
150
|
+
function Pet() {
|
|
151
|
+
const [size, setSize] = useState(462);
|
|
152
|
+
const halfW = size / 2;
|
|
153
|
+
const halfH = size * 9 / 16 / 2;
|
|
154
|
+
const [anim, setAnim] = useState(ANIM.idle[0] ?? "");
|
|
155
|
+
const [once, setOnce] = useState(true);
|
|
156
|
+
const [facing, setFacing] = useState("left");
|
|
157
|
+
const [dragging, setDragging] = useState(false);
|
|
158
|
+
const [customPos, setCustomPos] = useState(null);
|
|
159
|
+
const [corner, setCorner] = useState("bottom-right");
|
|
160
|
+
const [margin, setMargin] = useState({
|
|
161
|
+
x: 24,
|
|
162
|
+
y: 0
|
|
163
|
+
});
|
|
164
|
+
useEffect(() => {
|
|
165
|
+
fetch("/pet/config.jsonc").then((r) => {
|
|
166
|
+
if (!r.ok) throw new Error("config");
|
|
167
|
+
return r.text();
|
|
168
|
+
}).then((src) => {
|
|
169
|
+
const obj = JSON.parse(stripJsonc(src));
|
|
170
|
+
const sz = Number(obj && obj.size);
|
|
171
|
+
if (Number.isFinite(sz) && sz > 0) setSize(sz);
|
|
172
|
+
ANIM = buildAnim(obj);
|
|
173
|
+
const p = obj && obj.position;
|
|
174
|
+
if (p) {
|
|
175
|
+
if (CORNERS.indexOf(p.corner) !== -1) setCorner(p.corner);
|
|
176
|
+
const mx = Number(p.marginX);
|
|
177
|
+
const my = Number(p.marginY);
|
|
178
|
+
if (!Number.isNaN(mx)) setMargin((m) => ({
|
|
179
|
+
...m,
|
|
180
|
+
x: mx
|
|
181
|
+
}));
|
|
182
|
+
if (!Number.isNaN(my)) setMargin((m) => ({
|
|
183
|
+
...m,
|
|
184
|
+
y: my
|
|
185
|
+
}));
|
|
186
|
+
}
|
|
187
|
+
if (ANIM.idle && ANIM.idle.length) {
|
|
188
|
+
setAnim(ANIM.idle[0]);
|
|
189
|
+
setSeq((s) => s + 1);
|
|
190
|
+
}
|
|
191
|
+
}).catch(() => {});
|
|
192
|
+
}, []);
|
|
193
|
+
const [seq, setSeq] = useState(0);
|
|
194
|
+
const rootRef = useRef(null);
|
|
195
|
+
const stageRef = useRef(null);
|
|
196
|
+
const videoARef = useRef(null);
|
|
197
|
+
const videoBRef = useRef(null);
|
|
198
|
+
const frontRef = useRef(0);
|
|
199
|
+
const pendingRef = useRef(null);
|
|
200
|
+
const genRef = useRef(0);
|
|
201
|
+
const dragRef = useRef({
|
|
202
|
+
active: false,
|
|
203
|
+
dragging: false,
|
|
204
|
+
sx: 0,
|
|
205
|
+
sy: 0,
|
|
206
|
+
offX: 0,
|
|
207
|
+
offY: 0
|
|
208
|
+
});
|
|
209
|
+
const justDraggedRef = useRef(false);
|
|
210
|
+
const animRef = useRef(anim);
|
|
211
|
+
animRef.current = anim;
|
|
212
|
+
const switchTo = (next, nextOnce) => {
|
|
213
|
+
if (!next) return;
|
|
214
|
+
const pending = pendingRef.current;
|
|
215
|
+
if (pending && pending.anim === next && pending.once === nextOnce) return;
|
|
216
|
+
const gen = ++genRef.current;
|
|
217
|
+
pendingRef.current = {
|
|
218
|
+
anim: next,
|
|
219
|
+
once: nextOnce,
|
|
220
|
+
gen
|
|
221
|
+
};
|
|
222
|
+
const target = frontRef.current === 0 ? videoBRef : videoARef;
|
|
223
|
+
const el = target.current;
|
|
224
|
+
if (!el) return;
|
|
225
|
+
el.src = "/pet/thumb/" + encodeURIComponent(next) + ".webm";
|
|
226
|
+
el.loop = !nextOnce;
|
|
227
|
+
el.muted = true;
|
|
228
|
+
el.autoplay = true;
|
|
229
|
+
el.playsInline = true;
|
|
230
|
+
el.onended = nextOnce ? handleEnded : null;
|
|
231
|
+
el.load();
|
|
232
|
+
const onReady = () => {
|
|
233
|
+
el.removeEventListener("loadeddata", onReady);
|
|
234
|
+
if (pendingRef.current?.gen !== gen) return;
|
|
235
|
+
const old = frontRef.current === 0 ? videoARef : videoBRef;
|
|
236
|
+
el.classList.add("is-front");
|
|
237
|
+
if (old.current && old.current !== el) old.current.classList.remove("is-front");
|
|
238
|
+
frontRef.current = frontRef.current === 0 ? 1 : 0;
|
|
239
|
+
pendingRef.current = null;
|
|
240
|
+
el.style.transform = facingRef.current === "right" ? "scaleX(-1)" : "";
|
|
241
|
+
el.play().catch(() => {});
|
|
242
|
+
if (pendingMoveRef.current) startMoveDrive(el);
|
|
243
|
+
};
|
|
244
|
+
el.addEventListener("loadeddata", onReady);
|
|
245
|
+
if (el.readyState >= 2) onReady();
|
|
246
|
+
};
|
|
247
|
+
useEffect(() => {
|
|
248
|
+
switchTo(anim, once);
|
|
249
|
+
}, [
|
|
250
|
+
anim,
|
|
251
|
+
once,
|
|
252
|
+
seq
|
|
253
|
+
]);
|
|
254
|
+
useEffect(() => () => stopMove(), []);
|
|
255
|
+
useEffect(() => {
|
|
256
|
+
const onResize = () => setCustomPos((prev) => prev ? { ...prev } : prev);
|
|
257
|
+
window.addEventListener("resize", onResize);
|
|
258
|
+
return () => window.removeEventListener("resize", onResize);
|
|
259
|
+
}, []);
|
|
260
|
+
const pickNext = () => {
|
|
261
|
+
const roll = Math.random();
|
|
262
|
+
const wI = ANIM.weights.idle;
|
|
263
|
+
const wT = ANIM.weights.turn;
|
|
264
|
+
const wM = ANIM.weights.move;
|
|
265
|
+
const topEnd = (wI + wT + wM) / 100;
|
|
266
|
+
let kind = "";
|
|
267
|
+
let next = "";
|
|
268
|
+
if (roll < wI / 100) {
|
|
269
|
+
kind = "IDLE";
|
|
270
|
+
next = pick(ANIM.idle, animRef.current);
|
|
271
|
+
setAnim(next);
|
|
272
|
+
} else if (roll < (wI + wT) / 100) {
|
|
273
|
+
kind = "TURN";
|
|
274
|
+
next = pick(ANIM.turn, animRef.current);
|
|
275
|
+
setAnim(next);
|
|
276
|
+
} else if (roll < topEnd) if (!tryMove()) {
|
|
277
|
+
const cat = pickWeightedCategory(ANIM.categories, facingRef.current);
|
|
278
|
+
kind = cat ? cat.id : "FALLBACK";
|
|
279
|
+
next = cat ? pick(cat.actions, animRef.current) : pick(ANIM.idle, animRef.current);
|
|
280
|
+
setAnim(next);
|
|
281
|
+
} else {
|
|
282
|
+
kind = "MOVES";
|
|
283
|
+
next = "移动(池内随机)";
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
const cat = pickWeightedCategory(ANIM.categories, facingRef.current);
|
|
287
|
+
kind = cat ? cat.id : "FALLBACK";
|
|
288
|
+
next = cat ? pick(cat.actions, animRef.current) : pick(ANIM.idle, animRef.current);
|
|
289
|
+
setAnim(next);
|
|
290
|
+
}
|
|
291
|
+
console.log("[dsh-pet] roll=" + roll.toFixed(4) + " -> [" + kind + "] " + next);
|
|
292
|
+
setOnce(true);
|
|
293
|
+
setSeq((s) => s + 1);
|
|
294
|
+
};
|
|
295
|
+
const handleEnded = () => {
|
|
296
|
+
if (dragRef.current.active) return;
|
|
297
|
+
if (ANIM.turn.includes(animRef.current)) setFacing((f) => f === "left" ? "right" : "left");
|
|
298
|
+
if (ANIM.drag.includes(animRef.current) || ANIM.clicks.includes(animRef.current)) {
|
|
299
|
+
if (ANIM.idle.length) setAnim(pick(ANIM.idle, animRef.current));
|
|
300
|
+
setOnce(true);
|
|
301
|
+
setSeq((s) => s + 1);
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
pickNext();
|
|
305
|
+
};
|
|
306
|
+
const moveRef = useRef(null);
|
|
307
|
+
const moveTokenRef = useRef(0);
|
|
308
|
+
const pendingMoveRef = useRef(null);
|
|
309
|
+
const customPosRef = useRef(customPos);
|
|
310
|
+
customPosRef.current = customPos;
|
|
311
|
+
const currentCenterX = () => {
|
|
312
|
+
const cp = customPosRef.current;
|
|
313
|
+
if (cp) return cp.rx * window.innerWidth;
|
|
314
|
+
const rootEl = rootRef.current;
|
|
315
|
+
if (rootEl) return rootEl.getBoundingClientRect().left + halfW;
|
|
316
|
+
return window.innerWidth - 24 - halfW;
|
|
317
|
+
};
|
|
318
|
+
const currentCenterY = () => {
|
|
319
|
+
const cp = customPosRef.current;
|
|
320
|
+
if (cp) return cp.ry * window.innerHeight;
|
|
321
|
+
const rootEl = rootRef.current;
|
|
322
|
+
if (rootEl) return rootEl.getBoundingClientRect().top + halfH;
|
|
323
|
+
return window.innerHeight - 20 - halfH;
|
|
324
|
+
};
|
|
325
|
+
const startMoveDrive = (el) => {
|
|
326
|
+
const pm = pendingMoveRef.current;
|
|
327
|
+
if (!pm || moveRef.current !== null) return;
|
|
328
|
+
pendingMoveRef.current = null;
|
|
329
|
+
const { startRatio, startYRatio, targetRatio, dir, totalRatio, leadSec, tailSec } = pm;
|
|
330
|
+
const duration = Number.isFinite(el.duration) && el.duration > 0 ? el.duration : 10.09;
|
|
331
|
+
const travelWindow = Math.max(.1, duration - leadSec - tailSec);
|
|
332
|
+
const token = ++moveTokenRef.current;
|
|
333
|
+
const step = () => {
|
|
334
|
+
if (moveTokenRef.current !== token) return;
|
|
335
|
+
const t = el.currentTime || 0;
|
|
336
|
+
const rootEl = rootRef.current;
|
|
337
|
+
if (rootEl) {
|
|
338
|
+
const W = window.innerWidth;
|
|
339
|
+
const H = window.innerHeight;
|
|
340
|
+
let ratioX;
|
|
341
|
+
if (t <= leadSec) ratioX = startRatio;
|
|
342
|
+
else if (t >= duration - tailSec) ratioX = targetRatio;
|
|
343
|
+
else ratioX = startRatio + dir * totalRatio * ((t - leadSec) / travelWindow);
|
|
344
|
+
const px = ratioX * W;
|
|
345
|
+
const py = startYRatio * H;
|
|
346
|
+
rootEl.style.left = px - halfW + "px";
|
|
347
|
+
rootEl.style.top = py - halfH + "px";
|
|
348
|
+
rootEl.style.right = "auto";
|
|
349
|
+
rootEl.style.bottom = "auto";
|
|
350
|
+
}
|
|
351
|
+
if (t < duration - tailSec) moveRef.current = requestAnimationFrame(step);
|
|
352
|
+
else {
|
|
353
|
+
moveRef.current = null;
|
|
354
|
+
setCustomPos({
|
|
355
|
+
rx: targetRatio,
|
|
356
|
+
ry: startYRatio
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
moveRef.current = requestAnimationFrame(step);
|
|
361
|
+
};
|
|
362
|
+
const tryMove = () => {
|
|
363
|
+
if (moveRef.current !== null || pendingMoveRef.current) return true;
|
|
364
|
+
const actions = ANIM.moves.actions;
|
|
365
|
+
if (!actions.length) return false;
|
|
366
|
+
const chosen = actions[Math.floor(Math.random() * actions.length)];
|
|
367
|
+
const mp = Object.assign({}, ANIM.moves.default, chosen.params || {});
|
|
368
|
+
const dir = facingRef.current === "right" !== ANIM.turn.includes(animRef.current) ? 1 : -1;
|
|
369
|
+
const W = window.innerWidth;
|
|
370
|
+
const cx = currentCenterX();
|
|
371
|
+
const distance = randomBetween(mp.minDist, mp.maxDist);
|
|
372
|
+
const target = cx + dir * distance;
|
|
373
|
+
const leftBound = mp.margin + halfW;
|
|
374
|
+
const rightBound = W - mp.margin - halfW;
|
|
375
|
+
if (target < leftBound || target > rightBound) return false;
|
|
376
|
+
pendingMoveRef.current = {
|
|
377
|
+
startRatio: cx / W,
|
|
378
|
+
startYRatio: currentCenterY() / window.innerHeight,
|
|
379
|
+
targetRatio: target / W,
|
|
380
|
+
dir,
|
|
381
|
+
totalRatio: Math.abs(target - cx) / W,
|
|
382
|
+
leadSec: mp.leadSec,
|
|
383
|
+
tailSec: mp.tailSec
|
|
384
|
+
};
|
|
385
|
+
setOnce(true);
|
|
386
|
+
setAnim(chosen.name);
|
|
387
|
+
return true;
|
|
388
|
+
};
|
|
389
|
+
const stopMove = () => {
|
|
390
|
+
pendingMoveRef.current = null;
|
|
391
|
+
moveTokenRef.current++;
|
|
392
|
+
if (moveRef.current !== null) {
|
|
393
|
+
cancelAnimationFrame(moveRef.current);
|
|
394
|
+
moveRef.current = null;
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
const facingRef = useRef(facing);
|
|
398
|
+
facingRef.current = facing;
|
|
399
|
+
const handlePointerDown = (e) => {
|
|
400
|
+
e.currentTarget.classList.add("dragging");
|
|
401
|
+
stopMove();
|
|
402
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
403
|
+
const rootEl = rootRef.current;
|
|
404
|
+
let offX = 0;
|
|
405
|
+
let offY = 0;
|
|
406
|
+
if (rootEl) {
|
|
407
|
+
const rr = rootEl.getBoundingClientRect();
|
|
408
|
+
offX = e.clientX - (rr.left + rr.width / 2);
|
|
409
|
+
offY = e.clientY - (rr.top + rr.height / 2);
|
|
410
|
+
}
|
|
411
|
+
dragRef.current = {
|
|
412
|
+
active: true,
|
|
413
|
+
dragging: false,
|
|
414
|
+
sx: e.clientX,
|
|
415
|
+
sy: e.clientY,
|
|
416
|
+
offX,
|
|
417
|
+
offY
|
|
418
|
+
};
|
|
419
|
+
};
|
|
420
|
+
const handlePointerMove = (e) => {
|
|
421
|
+
const d = dragRef.current;
|
|
422
|
+
if (!d.active) return;
|
|
423
|
+
const dx = e.clientX - d.sx;
|
|
424
|
+
const dy = e.clientY - d.sy;
|
|
425
|
+
if (!d.dragging) {
|
|
426
|
+
if (Math.hypot(dx, dy) < DRAG_THRESHOLD) return;
|
|
427
|
+
d.dragging = true;
|
|
428
|
+
setDragging(true);
|
|
429
|
+
setOnce(true);
|
|
430
|
+
if (ANIM.drag.length) setAnim(pick(ANIM.drag));
|
|
431
|
+
}
|
|
432
|
+
const rootEl = rootRef.current;
|
|
433
|
+
if (rootEl) {
|
|
434
|
+
rootEl.style.left = e.clientX - d.offX - halfW + "px";
|
|
435
|
+
rootEl.style.top = e.clientY - d.offY - halfH + "px";
|
|
436
|
+
rootEl.style.right = "auto";
|
|
437
|
+
rootEl.style.bottom = "auto";
|
|
438
|
+
}
|
|
439
|
+
const stageEl = stageRef.current;
|
|
440
|
+
if (stageEl) stageEl.style.transform = "none";
|
|
441
|
+
};
|
|
442
|
+
const handlePointerUp = (e) => {
|
|
443
|
+
const d = dragRef.current;
|
|
444
|
+
const wasDragging = d.dragging;
|
|
445
|
+
d.active = false;
|
|
446
|
+
d.dragging = false;
|
|
447
|
+
e.currentTarget.classList.remove("dragging");
|
|
448
|
+
if (wasDragging) {
|
|
449
|
+
justDraggedRef.current = true;
|
|
450
|
+
setTimeout(() => {
|
|
451
|
+
justDraggedRef.current = false;
|
|
452
|
+
}, 100);
|
|
453
|
+
setDragging(false);
|
|
454
|
+
setCustomPos({
|
|
455
|
+
rx: (e.clientX - d.offX) / window.innerWidth,
|
|
456
|
+
ry: (e.clientY - d.offY) / window.innerHeight
|
|
457
|
+
});
|
|
458
|
+
const stageEl = stageRef.current;
|
|
459
|
+
if (stageEl) stageEl.style.transform = "translateY(" + bottomPad + "px)";
|
|
460
|
+
if (ANIM.idle.length) setAnim(pick(ANIM.idle, animRef.current));
|
|
461
|
+
setOnce(false);
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
const handleClick = (_e) => {
|
|
465
|
+
const d = dragRef.current;
|
|
466
|
+
if (d.active || d.dragging || justDraggedRef.current) return;
|
|
467
|
+
if (once && !ANIM.idle.includes(animRef.current)) return;
|
|
468
|
+
stopMove();
|
|
469
|
+
setOnce(true);
|
|
470
|
+
if (ANIM.clicks.length) setAnim(pick(ANIM.clicks));
|
|
471
|
+
};
|
|
472
|
+
const bottomPad = size * (9 / 16) * (CANVAS_H - FEET_Y) / CANVAS_H;
|
|
473
|
+
const stageStyle = dragging ? { transform: "none" } : { transform: "translateY(" + bottomPad + "px)" };
|
|
474
|
+
const rootStyle = customPos ? (() => {
|
|
475
|
+
const rx = customPos.rx;
|
|
476
|
+
const ry = customPos.ry;
|
|
477
|
+
const left = Math.min(Math.max(rx * window.innerWidth - halfW, 0), window.innerWidth - size);
|
|
478
|
+
const top = Math.min(Math.max(ry * window.innerHeight - halfH, 0), window.innerHeight - size * 9 / 16);
|
|
479
|
+
return {
|
|
480
|
+
left: left + "px",
|
|
481
|
+
top: top + "px",
|
|
482
|
+
right: "auto",
|
|
483
|
+
bottom: "auto"
|
|
484
|
+
};
|
|
485
|
+
})() : {};
|
|
486
|
+
const commonVideoProps = {
|
|
487
|
+
muted: true,
|
|
488
|
+
playsInline: true,
|
|
489
|
+
autoPlay: true,
|
|
490
|
+
title: "dsh-pet"
|
|
491
|
+
};
|
|
492
|
+
const hitProps = {
|
|
493
|
+
className: "dsh-pet-hit",
|
|
494
|
+
style: {
|
|
495
|
+
left: HIT_BOX.x0 / 640 * 100 + "%",
|
|
496
|
+
top: HIT_BOX.y0 / 360 * 100 + "%",
|
|
497
|
+
width: (HIT_BOX.x1 - HIT_BOX.x0) / 640 * 100 + "%",
|
|
498
|
+
height: (HIT_BOX.y1 - HIT_BOX.y0) / 360 * 100 + "%"
|
|
499
|
+
},
|
|
500
|
+
onMouseEnter: (e) => {
|
|
501
|
+
if (!dragRef.current.active) e.currentTarget.style.cursor = "grab";
|
|
502
|
+
},
|
|
503
|
+
onMouseLeave: (e) => {
|
|
504
|
+
if (!dragRef.current.active) e.currentTarget.style.cursor = "default";
|
|
505
|
+
},
|
|
506
|
+
onClick: handleClick,
|
|
507
|
+
onPointerDown: handlePointerDown,
|
|
508
|
+
onPointerMove: handlePointerMove,
|
|
509
|
+
onPointerUp: handlePointerUp,
|
|
510
|
+
onPointerCancel: handlePointerUp,
|
|
511
|
+
title: "dsh-pet"
|
|
512
|
+
};
|
|
513
|
+
return h("div", {
|
|
514
|
+
ref: rootRef,
|
|
515
|
+
className: "dsh-pet-root",
|
|
516
|
+
"data-corner": corner,
|
|
517
|
+
"data-facing": facing,
|
|
518
|
+
style: Object.assign({
|
|
519
|
+
"--dsh-pet-size": size + "px",
|
|
520
|
+
"--dsh-pet-mx": margin.x + "px",
|
|
521
|
+
"--dsh-pet-my": margin.y + "px"
|
|
522
|
+
}, rootStyle),
|
|
523
|
+
children: h("div", {
|
|
524
|
+
ref: stageRef,
|
|
525
|
+
className: "dsh-pet-stage",
|
|
526
|
+
style: stageStyle,
|
|
527
|
+
children: [
|
|
528
|
+
h("video", Object.assign({}, commonVideoProps, {
|
|
529
|
+
ref: videoARef,
|
|
530
|
+
className: "dsh-pet-video is-front"
|
|
531
|
+
})),
|
|
532
|
+
h("video", Object.assign({}, commonVideoProps, {
|
|
533
|
+
ref: videoBRef,
|
|
534
|
+
className: "dsh-pet-video"
|
|
535
|
+
})),
|
|
536
|
+
h("div", hitProps)
|
|
537
|
+
]
|
|
538
|
+
})
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
const name = "pet";
|
|
542
|
+
const inject = ["slots"];
|
|
543
|
+
function apply(ctx, _config) {
|
|
544
|
+
ctx.slots.inject("shell.overlay", function* () {
|
|
545
|
+
yield ctx.slots.register({
|
|
546
|
+
name: "shell.overlay",
|
|
547
|
+
id: "pet",
|
|
548
|
+
order: 1e3
|
|
549
|
+
}, () => h(Pet, {}));
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
module.exports = {
|
|
553
|
+
apply,
|
|
554
|
+
inject,
|
|
555
|
+
name
|
|
556
|
+
};
|
|
557
|
+
return module.exports;
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
//#endregion
|
|
562
|
+
//#region src/client/index.ts
|
|
563
|
+
window.__ModuleLoader__.load({
|
|
564
|
+
id: "dsh-pet",
|
|
565
|
+
factory: makeFactory()
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
//#endregion
|