@mingxy/opencode-mascot 0.7.9 → 0.7.10

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mingxy/opencode-mascot",
3
- "version": "0.7.9",
3
+ "version": "0.7.10",
4
4
  "description": "OpenCode TUI mascot plugin framework - customizable ASCII mascots for your terminal",
5
5
  "author": "mingxy",
6
6
  "license": "MIT",
@@ -5,7 +5,7 @@ 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, onScatter } from "../core/celebration-bus";
8
- import { pickPropByTrigger, getProp } from "../core/prop-loader";
8
+ import { pickPropByTrigger } from "../core/prop-loader";
9
9
 
10
10
  interface SidebarMascotProps {
11
11
  mascots: Record<string, MascotPack>;
@@ -161,9 +161,11 @@ export function SidebarMascot(props: SidebarMascotProps): JSX.Element {
161
161
  renderers[currentName()].setState("busy");
162
162
  const busyProp = pickPropByTrigger("busy");
163
163
  renderers[currentName()].setProp(busyProp);
164
+ renderers[currentName()].setCharacterHidden(busyProp?.position === "front");
164
165
  } else {
165
166
  setStateWithSwitch("idle");
166
167
  renderers[currentName()].setProp(null);
168
+ renderers[currentName()].setCharacterHidden(false);
167
169
  }
168
170
  });
169
171
 
@@ -215,75 +217,82 @@ export function SidebarMascot(props: SidebarMascotProps): JSX.Element {
215
217
  renderers[currentName()].scatterIn();
216
218
  }, 2000);
217
219
 
218
- return (
219
- <box
220
- position="absolute"
221
- left={posX()}
222
- top={posY()}
223
- alignItems="center"
224
- zIndex={zBoost() ? 9999 : 100}
225
- flexDirection="column"
226
- ref={(node: any) => {
227
- if (node) {
228
- setContainerWidth(node.width || 0);
229
- if (node.onSizeChange !== undefined) {
230
- node.onSizeChange = () => {
231
- setContainerWidth(node.width || 0);
232
- };
233
- }
234
- }
235
- }}
236
- onMouseDown={(e: any) => {
237
- if (hideSide) { returnToView(); return; }
238
-
239
- const now = Date.now();
240
- if (now - lastClickTime < 300) {
241
- switchToNext();
242
- lastClickTime = 0;
243
- return;
244
- }
245
- lastClickTime = now;
220
+ const propOffset = () => {
221
+ const pos = renderers[currentName()]?.getPropPosition();
222
+ if (pos === "side-left") return -18;
223
+ if (pos === "side-right") return 12;
224
+ return 0;
225
+ };
246
226
 
247
- if (e.modifiers?.alt) {
248
- dragStartX = e.x;
249
- dragStartY = e.y;
250
- dragAnchorX = posX();
251
- dragAnchorY = posY();
252
- isDragging = true;
253
- renderers[currentName()].setDragging(true);
254
- props.api.renderer.clearSelection();
255
- }
256
- }}
257
- onMouseDrag={(e: any) => {
258
- if (e.modifiers?.alt && isDragging) {
259
- setPosX(clampX(dragAnchorX + (e.x - dragStartX)));
260
- setPosY(clampY(dragAnchorY + (e.y - dragStartY)));
261
- }
262
- }}
263
- onMouseUp={() => {
264
- isDragging = false;
265
- renderers[currentName()].setDragging(false);
266
- checkEdge();
267
- }}
268
- onMouseDragEnd={() => {
269
- isDragging = false;
270
- renderers[currentName()].setDragging(false);
271
- checkEdge();
272
- }}
273
- >
227
+ return (
228
+ <>
274
229
  {renderers[currentName()]?.propElement() ? (
275
230
  <box
276
231
  position="absolute"
277
- zIndex={50}
278
- left={renderers[currentName()].getPropPosition() === "side-left" ? -16 : renderers[currentName()].getPropPosition() === "side-right" ? 12 : 0}
279
- top={0}
232
+ left={posX() + propOffset()}
233
+ top={posY()}
234
+ zIndex={zBoost() ? 9998 : 50}
280
235
  >
281
236
  {renderers[currentName()].propElement()}
282
237
  </box>
283
238
  ) : null}
284
- <box zIndex={100}>
239
+ <box
240
+ position="absolute"
241
+ left={posX()}
242
+ top={posY()}
243
+ alignItems="center"
244
+ zIndex={zBoost() ? 9999 : 100}
245
+ flexDirection="column"
246
+ ref={(node: any) => {
247
+ if (node) {
248
+ setContainerWidth(node.width || 0);
249
+ if (node.onSizeChange !== undefined) {
250
+ node.onSizeChange = () => {
251
+ setContainerWidth(node.width || 0);
252
+ };
253
+ }
254
+ }
255
+ }}
256
+ onMouseDown={(e: any) => {
257
+ if (hideSide) { returnToView(); return; }
258
+
259
+ const now = Date.now();
260
+ if (now - lastClickTime < 300) {
261
+ switchToNext();
262
+ lastClickTime = 0;
263
+ return;
264
+ }
265
+ lastClickTime = now;
266
+
267
+ if (e.modifiers?.alt) {
268
+ dragStartX = e.x;
269
+ dragStartY = e.y;
270
+ dragAnchorX = posX();
271
+ dragAnchorY = posY();
272
+ isDragging = true;
273
+ renderers[currentName()].setDragging(true);
274
+ props.api.renderer.clearSelection();
275
+ }
276
+ }}
277
+ onMouseDrag={(e: any) => {
278
+ if (e.modifiers?.alt && isDragging) {
279
+ setPosX(clampX(dragAnchorX + (e.x - dragStartX)));
280
+ setPosY(clampY(dragAnchorY + (e.y - dragStartY)));
281
+ }
282
+ }}
283
+ onMouseUp={() => {
284
+ isDragging = false;
285
+ renderers[currentName()].setDragging(false);
286
+ checkEdge();
287
+ }}
288
+ onMouseDragEnd={() => {
289
+ isDragging = false;
290
+ renderers[currentName()].setDragging(false);
291
+ checkEdge();
292
+ }}
293
+ >
285
294
  {renderers[currentName()]?.element() ?? null}
286
295
  </box>
287
- </box>
296
+ </>
288
297
  );
289
298
  }