@mingxy/opencode-mascot 0.4.20 → 0.4.21
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, MascotState } 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 SidebarMascotProps {
|
|
11
10
|
mascots: Record<string, MascotPack>;
|
|
@@ -89,7 +88,6 @@ export function SidebarMascot(props: SidebarMascotProps): JSX.Element {
|
|
|
89
88
|
const checkEdge = () => {
|
|
90
89
|
const cw = getCw();
|
|
91
90
|
const x = posX();
|
|
92
|
-
log("EDGE", `checkEdge x=${x} cw=${cw} leftThreshold=${-(MASCOT_WIDTH - PEEK) + EDGE_THRESHOLD} rightThreshold=${cw - PEEK - EDGE_THRESHOLD}`);
|
|
93
91
|
if (x <= -(MASCOT_WIDTH - PEEK) + EDGE_THRESHOLD) {
|
|
94
92
|
hideSide = "left";
|
|
95
93
|
startPeek();
|
|
@@ -189,12 +187,8 @@ export function SidebarMascot(props: SidebarMascotProps): JSX.Element {
|
|
|
189
187
|
|
|
190
188
|
return (
|
|
191
189
|
<box
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
top={posY()}
|
|
195
|
-
alignItems="center"
|
|
196
|
-
zIndex={zBoost() ? 9999 : 100}
|
|
197
|
-
flexDirection="column"
|
|
190
|
+
overflow="hidden"
|
|
191
|
+
width="100%"
|
|
198
192
|
ref={(node: any) => {
|
|
199
193
|
if (node) {
|
|
200
194
|
setContainerWidth(node.width || 0);
|
|
@@ -205,45 +199,54 @@ export function SidebarMascot(props: SidebarMascotProps): JSX.Element {
|
|
|
205
199
|
}
|
|
206
200
|
}
|
|
207
201
|
}}
|
|
208
|
-
onMouseDown={(e: any) => {
|
|
209
|
-
if (hideSide) { returnToView(); return; }
|
|
210
|
-
|
|
211
|
-
const now = Date.now();
|
|
212
|
-
if (now - lastClickTime < 300) {
|
|
213
|
-
switchToNext();
|
|
214
|
-
lastClickTime = 0;
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
lastClickTime = now;
|
|
218
|
-
|
|
219
|
-
if (e.modifiers?.alt) {
|
|
220
|
-
dragStartX = e.x;
|
|
221
|
-
dragStartY = e.y;
|
|
222
|
-
dragAnchorX = posX();
|
|
223
|
-
dragAnchorY = posY();
|
|
224
|
-
isDragging = true;
|
|
225
|
-
renderers[currentName()].setDragging(true);
|
|
226
|
-
props.api.renderer.clearSelection();
|
|
227
|
-
}
|
|
228
|
-
}}
|
|
229
|
-
onMouseDrag={(e: any) => {
|
|
230
|
-
if (e.modifiers?.alt && isDragging) {
|
|
231
|
-
setPosX(clampX(dragAnchorX + (e.x - dragStartX)));
|
|
232
|
-
setPosY(clampY(dragAnchorY + (e.y - dragStartY)));
|
|
233
|
-
}
|
|
234
|
-
}}
|
|
235
|
-
onMouseUp={() => {
|
|
236
|
-
isDragging = false;
|
|
237
|
-
renderers[currentName()].setDragging(false);
|
|
238
|
-
checkEdge();
|
|
239
|
-
}}
|
|
240
|
-
onMouseDragEnd={() => {
|
|
241
|
-
isDragging = false;
|
|
242
|
-
renderers[currentName()].setDragging(false);
|
|
243
|
-
checkEdge();
|
|
244
|
-
}}
|
|
245
202
|
>
|
|
246
|
-
|
|
203
|
+
<box
|
|
204
|
+
position="absolute"
|
|
205
|
+
left={posX()}
|
|
206
|
+
top={posY()}
|
|
207
|
+
alignItems="center"
|
|
208
|
+
zIndex={zBoost() ? 9999 : 100}
|
|
209
|
+
flexDirection="column"
|
|
210
|
+
onMouseDown={(e: any) => {
|
|
211
|
+
if (hideSide) { returnToView(); return; }
|
|
212
|
+
|
|
213
|
+
const now = Date.now();
|
|
214
|
+
if (now - lastClickTime < 300) {
|
|
215
|
+
switchToNext();
|
|
216
|
+
lastClickTime = 0;
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
lastClickTime = now;
|
|
220
|
+
|
|
221
|
+
if (e.modifiers?.alt) {
|
|
222
|
+
dragStartX = e.x;
|
|
223
|
+
dragStartY = e.y;
|
|
224
|
+
dragAnchorX = posX();
|
|
225
|
+
dragAnchorY = posY();
|
|
226
|
+
isDragging = true;
|
|
227
|
+
renderers[currentName()].setDragging(true);
|
|
228
|
+
props.api.renderer.clearSelection();
|
|
229
|
+
}
|
|
230
|
+
}}
|
|
231
|
+
onMouseDrag={(e: any) => {
|
|
232
|
+
if (e.modifiers?.alt && isDragging) {
|
|
233
|
+
setPosX(clampX(dragAnchorX + (e.x - dragStartX)));
|
|
234
|
+
setPosY(clampY(dragAnchorY + (e.y - dragStartY)));
|
|
235
|
+
}
|
|
236
|
+
}}
|
|
237
|
+
onMouseUp={() => {
|
|
238
|
+
isDragging = false;
|
|
239
|
+
renderers[currentName()].setDragging(false);
|
|
240
|
+
checkEdge();
|
|
241
|
+
}}
|
|
242
|
+
onMouseDragEnd={() => {
|
|
243
|
+
isDragging = false;
|
|
244
|
+
renderers[currentName()].setDragging(false);
|
|
245
|
+
checkEdge();
|
|
246
|
+
}}
|
|
247
|
+
>
|
|
248
|
+
{renderers[currentName()]?.element() ?? null}
|
|
249
|
+
</box>
|
|
247
250
|
</box>
|
|
248
251
|
);
|
|
249
252
|
}
|