@mingxy/opencode-mascot 0.7.1 → 0.7.3

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.1",
3
+ "version": "0.7.3",
4
4
  "description": "OpenCode TUI mascot plugin framework - customizable ASCII mascots for your terminal",
5
5
  "author": "mingxy",
6
6
  "license": "MIT",
@@ -71,11 +71,14 @@ export function HomeMascot(props: HomeMascotProps): JSX.Element {
71
71
  renderers[currentName()].scatterIn();
72
72
  });
73
73
 
74
+ renderers[currentName()].setCharacterHidden(true);
75
+ renderers[currentName()].setProp(getProp("box") ?? null);
76
+
74
77
  setTimeout(() => {
75
- if (!renderers[currentName()].getProp()) {
76
- renderers[currentName()].setProp(getProp("box") ?? null);
77
- }
78
- }, 2500);
78
+ renderers[currentName()].setProp(null);
79
+ renderers[currentName()].setCharacterHidden(false);
80
+ renderers[currentName()].scatterIn();
81
+ }, 6000);
79
82
 
80
83
  const stopDrag = () => {
81
84
  isDragging = false;
@@ -167,12 +167,11 @@ export function SidebarMascot(props: SidebarMascotProps): JSX.Element {
167
167
  renderers[currentName()].setProp(busyProp);
168
168
  }, 300);
169
169
  } else {
170
- renderers[currentName()].setProp(getProp("box") ?? null);
170
+ renderers[currentName()].setProp(null);
171
171
  }
172
172
  } else {
173
173
  setStateWithSwitch("idle");
174
- // idle 时显示箱子常驻
175
- renderers[currentName()].setProp(getProp("box") ?? null);
174
+ renderers[currentName()].setProp(null);
176
175
  }
177
176
  });
178
177
 
@@ -218,18 +217,17 @@ export function SidebarMascot(props: SidebarMascotProps): JSX.Element {
218
217
  renderers[currentName()].scatterIn();
219
218
  });
220
219
 
221
- setTimeout(() => {
222
- if (scattered) return;
223
- scattered = true;
224
- renderers[currentName()].scatterIn();
225
- }, 2000);
220
+ renderers[currentName()].setCharacterHidden(true);
221
+ renderers[currentName()].setProp(getProp("box") ?? null);
226
222
 
227
- // 启动后显示箱子(在 scatter 之后)
228
223
  setTimeout(() => {
229
- if (!renderers[currentName()].getProp()) {
230
- renderers[currentName()].setProp(getProp("box") ?? null);
224
+ renderers[currentName()].setProp(null);
225
+ renderers[currentName()].setCharacterHidden(false);
226
+ if (!scattered) {
227
+ scattered = true;
228
+ renderers[currentName()].scatterIn();
231
229
  }
232
- }, 2500);
230
+ }, 6000);
233
231
 
234
232
  return (
235
233
  <box
@@ -50,6 +50,7 @@ export function createAnimatedRenderer(pack: MascotPack): {
50
50
  setState: (s: MascotState) => void;
51
51
  toggleWalk: () => void;
52
52
  setDragging: (v: boolean) => void;
53
+ setCharacterHidden: (v: boolean) => void;
53
54
  celebrateUpdate: (newVersion: string) => void;
54
55
  bounce: () => void;
55
56
  showVersion: (version: string) => void;
@@ -77,6 +78,7 @@ export function createAnimatedRenderer(pack: MascotPack): {
77
78
  const [bomb, setBomb] = createSignal<{ fuse: string; count: string } | null>(null);
78
79
  const [scatter, setScatter] = createSignal<{ dx: number; dy: number }[] | null>(null);
79
80
  const [activeProp, setActiveProp] = createSignal<PropPack | null>(null);
81
+ const [characterHidden, setCharacterHiddenSignal] = createSignal(false);
80
82
  const [propFrameIdx, setPropFrameIdx] = createSignal(0);
81
83
  const [propPosition, setPropPosition] = createSignal<PropPosition | null>(null);
82
84
 
@@ -344,7 +346,9 @@ export function createAnimatedRenderer(pack: MascotPack): {
344
346
  const width = rawLines[0]?.length ?? 10;
345
347
  const blank = " ".repeat(width);
346
348
 
347
- let lines: string[] = rawLines.map((line, i) => {
349
+ let lines: string[] = characterHidden()
350
+ ? rawLines.map(() => blank)
351
+ : rawLines.map((line, i) => {
348
352
  if (!breathPhase()) {
349
353
  if (i === 0) return blank;
350
354
  return rawLines[i - 1];
@@ -477,6 +481,10 @@ export function createAnimatedRenderer(pack: MascotPack): {
477
481
  }
478
482
  };
479
483
 
484
+ const setCharacterHidden = (v: boolean) => {
485
+ setCharacterHiddenSignal(v);
486
+ };
487
+
480
488
  const setDragging = (v: boolean) => {
481
489
  setDraggingSignal(v);
482
490
  if (v) {
@@ -650,5 +658,5 @@ export function createAnimatedRenderer(pack: MascotPack): {
650
658
 
651
659
  const getProp = () => activeProp();
652
660
 
653
- return { element, getState: currentState, setState, toggleWalk, setDragging, celebrateUpdate, bounce, showVersion, scatterIn, explode, setProp, getProp };
661
+ return { element, getState: currentState, setState, toggleWalk, setDragging, setCharacterHidden, celebrateUpdate, bounce, showVersion, scatterIn, explode, setProp, getProp };
654
662
  }