@mingxy/opencode-mascot 0.3.0 → 0.3.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/package.json
CHANGED
|
@@ -49,13 +49,16 @@ export function HomeMascot(props: HomeMascotProps): JSX.Element {
|
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
return (
|
|
52
|
-
<box
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
<box flexDirection="column" alignItems="center">
|
|
53
|
+
<box height={5} width={10} />
|
|
54
|
+
<box
|
|
55
|
+
position="absolute"
|
|
56
|
+
left={posX()}
|
|
57
|
+
top={posY()}
|
|
58
|
+
alignItems="center"
|
|
59
|
+
zIndex={100}
|
|
60
|
+
flexDirection="column"
|
|
61
|
+
onMouseDown={(e: any) => {
|
|
59
62
|
const now = Date.now();
|
|
60
63
|
if (now - lastClickTime < 300) {
|
|
61
64
|
switchToNext();
|
|
@@ -100,6 +103,7 @@ export function HomeMascot(props: HomeMascotProps): JSX.Element {
|
|
|
100
103
|
}}
|
|
101
104
|
>
|
|
102
105
|
{renderers[currentName()]?.element() ?? null}
|
|
106
|
+
</box>
|
|
103
107
|
</box>
|
|
104
108
|
);
|
|
105
109
|
}
|
|
@@ -70,6 +70,9 @@ export function createAnimatedRenderer(pack: MascotPack): {
|
|
|
70
70
|
|
|
71
71
|
let flashTimer: ReturnType<typeof setInterval> | null = null;
|
|
72
72
|
let dragMsgTimer: ReturnType<typeof setInterval> | null = null;
|
|
73
|
+
let bounceTimers: ReturnType<typeof setTimeout>[] = [];
|
|
74
|
+
let celebrateTimers: ReturnType<typeof setTimeout>[] = [];
|
|
75
|
+
let versionTimer: ReturnType<typeof setTimeout> | null = null;
|
|
73
76
|
|
|
74
77
|
const stopFlash = () => {
|
|
75
78
|
if (flashTimer) { clearInterval(flashTimer); flashTimer = null; }
|
|
@@ -78,6 +81,26 @@ export function createAnimatedRenderer(pack: MascotPack): {
|
|
|
78
81
|
if (dragMsgTimer) { clearInterval(dragMsgTimer); dragMsgTimer = null; }
|
|
79
82
|
setDragMsg(null);
|
|
80
83
|
};
|
|
84
|
+
const stopBounce = () => {
|
|
85
|
+
bounceTimers.forEach(t => { clearTimeout(t); });
|
|
86
|
+
bounceTimers = [];
|
|
87
|
+
};
|
|
88
|
+
const stopCelebrate = () => {
|
|
89
|
+
celebrateTimers.forEach(t => { clearTimeout(t); });
|
|
90
|
+
celebrateTimers = [];
|
|
91
|
+
};
|
|
92
|
+
const stopVersion = () => {
|
|
93
|
+
if (versionTimer) { clearTimeout(versionTimer); versionTimer = null; }
|
|
94
|
+
setCelebrate(null);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const stopAllAnimations = () => {
|
|
98
|
+
stopFlash();
|
|
99
|
+
stopBounce();
|
|
100
|
+
stopCelebrate();
|
|
101
|
+
stopVersion();
|
|
102
|
+
setJumpOffset(0);
|
|
103
|
+
};
|
|
81
104
|
|
|
82
105
|
let idleSleepTimeout: ReturnType<typeof setTimeout> | null = null;
|
|
83
106
|
|
|
@@ -238,6 +261,9 @@ export function createAnimatedRenderer(pack: MascotPack): {
|
|
|
238
261
|
for (const t of effectTimers) clearInterval(t);
|
|
239
262
|
stopFlash();
|
|
240
263
|
stopDragMsg();
|
|
264
|
+
stopBounce();
|
|
265
|
+
stopCelebrate();
|
|
266
|
+
stopVersion();
|
|
241
267
|
});
|
|
242
268
|
|
|
243
269
|
// ─── Render ───
|
|
@@ -360,6 +386,7 @@ export function createAnimatedRenderer(pack: MascotPack): {
|
|
|
360
386
|
// 连续跳跃 + 吐火星文泡泡庆祝更新成功
|
|
361
387
|
const celebrateUpdate = (newVersion: string) => {
|
|
362
388
|
const bubbles = ["ᵘᵖ~", "ⁿᵉʷ!", "ʸᵉ~", "ᵍᵒ~", "ᵒᵏ~"];
|
|
389
|
+
stopAllAnimations();
|
|
363
390
|
setState("happy");
|
|
364
391
|
setFrameOverride("happy");
|
|
365
392
|
|
|
@@ -371,28 +398,32 @@ export function createAnimatedRenderer(pack: MascotPack): {
|
|
|
371
398
|
setCelebrate(null);
|
|
372
399
|
setFrameOverride(null);
|
|
373
400
|
setState("idle");
|
|
401
|
+
celebrateTimers = [];
|
|
374
402
|
return;
|
|
375
403
|
}
|
|
376
404
|
setJumpOffset(step % 2 === 0 ? -2 : 0);
|
|
377
405
|
const word = bubbles[Math.floor(Math.random() * bubbles.length)];
|
|
378
406
|
setCelebrate({ text: `${word} ᵘᵖ→ᵛ${newVersion}`, count: step });
|
|
379
407
|
step++;
|
|
380
|
-
setTimeout(tick, 600);
|
|
408
|
+
celebrateTimers.push(setTimeout(tick, 600));
|
|
381
409
|
};
|
|
382
410
|
tick();
|
|
383
411
|
};
|
|
384
412
|
|
|
385
413
|
const bounce = () => {
|
|
414
|
+
stopBounce();
|
|
415
|
+
stopCelebrate();
|
|
386
416
|
if (currentState() === "sleeping") setState("idle");
|
|
387
417
|
setJumpOffset(-3);
|
|
388
|
-
setTimeout(() => setJumpOffset(-2), 150);
|
|
389
|
-
setTimeout(() => setJumpOffset(-1), 300);
|
|
390
|
-
setTimeout(() => setJumpOffset(0), 450);
|
|
418
|
+
bounceTimers.push(setTimeout(() => setJumpOffset(-2), 150));
|
|
419
|
+
bounceTimers.push(setTimeout(() => setJumpOffset(-1), 300));
|
|
420
|
+
bounceTimers.push(setTimeout(() => { setJumpOffset(0); bounceTimers = []; }, 450));
|
|
391
421
|
};
|
|
392
422
|
|
|
393
423
|
const showVersion = (version: string) => {
|
|
424
|
+
stopVersion();
|
|
394
425
|
setCelebrate({ text: `ᵛ${toSuperscript(version)}`, count: 0 });
|
|
395
|
-
setTimeout(() => setCelebrate(null), 3000);
|
|
426
|
+
versionTimer = setTimeout(() => { setCelebrate(null); versionTimer = null; }, 3000);
|
|
396
427
|
};
|
|
397
428
|
|
|
398
429
|
return { element, setState, toggleWalk, setDragging, celebrateUpdate, bounce, showVersion };
|