@mingxy/opencode-mascot 0.4.24 → 0.4.26
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
|
@@ -5,7 +5,6 @@ import type { JSX } from "@opentui/solid";
|
|
|
5
5
|
import type { MascotPack } from "../core/types";
|
|
6
6
|
import { createAnimatedRenderer } from "../core/ascii-renderer";
|
|
7
7
|
import { onCelebrate, onVersion } from "../core/celebration-bus";
|
|
8
|
-
import { log } from "../core/logger";
|
|
9
8
|
|
|
10
9
|
interface HomeMascotProps {
|
|
11
10
|
mascots: Record<string, MascotPack>;
|
|
@@ -20,9 +19,11 @@ export function HomeMascot(props: HomeMascotProps): JSX.Element {
|
|
|
20
19
|
const names = Object.keys(props.mascots);
|
|
21
20
|
const initialName = names[Math.floor(Math.random() * names.length)];
|
|
22
21
|
|
|
22
|
+
const cw = (typeof process !== "undefined" && process.stdout?.columns) || 80;
|
|
23
|
+
|
|
23
24
|
const [currentName, setCurrentName] = createSignal(initialName);
|
|
24
|
-
const [posX, setPosX] = createSignal(0);
|
|
25
|
-
const [posY, setPosY] = createSignal(
|
|
25
|
+
const [posX, setPosX] = createSignal(Math.floor(Math.random() * Math.max(0, cw - 20)));
|
|
26
|
+
const [posY, setPosY] = createSignal(Math.floor(Math.random() * 3));
|
|
26
27
|
const [zBoost, setZBoost] = createSignal(false);
|
|
27
28
|
let dragStartX = 0;
|
|
28
29
|
let dragStartY = 0;
|
|
@@ -66,7 +67,6 @@ export function HomeMascot(props: HomeMascotProps): JSX.Element {
|
|
|
66
67
|
zIndex={zBoost() ? 9999 : 100}
|
|
67
68
|
flexDirection="column"
|
|
68
69
|
onMouseDown={(e: any) => {
|
|
69
|
-
log("MOUSE", `down x=${e.x} y=${e.y} alt=${!!e.modifiers?.alt} btn=${e.button}`);
|
|
70
70
|
const now = Date.now();
|
|
71
71
|
if (now - lastClickTime < 300) {
|
|
72
72
|
switchToNext();
|
|
@@ -81,22 +81,18 @@ export function HomeMascot(props: HomeMascotProps): JSX.Element {
|
|
|
81
81
|
dragAnchorX = posX();
|
|
82
82
|
dragAnchorY = posY();
|
|
83
83
|
isDragging = true;
|
|
84
|
-
log("DRAG", `start anchorX=${dragAnchorX} anchorY=${dragAnchorY} startX=${dragStartX} startY=${dragStartY}`);
|
|
85
84
|
renderers[currentName()].setDragging(true);
|
|
86
85
|
props.api.renderer.clearSelection();
|
|
87
86
|
}
|
|
88
87
|
}}
|
|
89
88
|
onMouseDrag={(e: any) => {
|
|
90
|
-
if (isDragging) {
|
|
91
|
-
log("MOUSE", `drag x=${e.x} y=${e.y} alt=${!!e.modifiers?.alt} dx=${e.x - dragStartX} dy=${e.y - dragStartY}`);
|
|
92
|
-
}
|
|
93
89
|
if (e.modifiers?.alt && isDragging) {
|
|
94
90
|
setPosX(dragAnchorX + (e.x - dragStartX));
|
|
95
91
|
setPosY(dragAnchorY + (e.y - dragStartY));
|
|
96
92
|
}
|
|
97
93
|
}}
|
|
98
|
-
onMouseUp={() => {
|
|
99
|
-
onMouseDragEnd={() => {
|
|
94
|
+
onMouseUp={() => { stopDrag(); }}
|
|
95
|
+
onMouseDragEnd={() => { stopDrag(); }}
|
|
100
96
|
>
|
|
101
97
|
{renderers[currentName()]?.element() ?? null}
|
|
102
98
|
</box>
|
|
@@ -355,10 +355,10 @@ export function createAnimatedRenderer(pack: MascotPack): {
|
|
|
355
355
|
|
|
356
356
|
if (s === "sleeping") {
|
|
357
357
|
let phase = 1;
|
|
358
|
-
setZzz("
|
|
358
|
+
setZzz("zᶻ...");
|
|
359
359
|
zzzTimer = setInterval(() => {
|
|
360
360
|
phase = (phase % 3) + 1;
|
|
361
|
-
setZzz("ᶻ".repeat(phase));
|
|
361
|
+
setZzz("z" + "ᶻ".repeat(phase) + "...");
|
|
362
362
|
}, 1500);
|
|
363
363
|
} else {
|
|
364
364
|
if (zzzTimer) { clearInterval(zzzTimer); zzzTimer = null; }
|