@mingxy/opencode-mascot 0.7.2 → 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.2",
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,14 +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
- setTimeout(() => {
78
- renderers[currentName()].setProp(null);
79
- }, 6000);
80
- }
81
- }, 2500);
78
+ renderers[currentName()].setProp(null);
79
+ renderers[currentName()].setCharacterHidden(false);
80
+ renderers[currentName()].scatterIn();
81
+ }, 6000);
82
82
 
83
83
  const stopDrag = () => {
84
84
  isDragging = false;
@@ -217,20 +217,17 @@ export function SidebarMascot(props: SidebarMascotProps): JSX.Element {
217
217
  renderers[currentName()].scatterIn();
218
218
  });
219
219
 
220
- setTimeout(() => {
221
- if (scattered) return;
222
- scattered = true;
223
- renderers[currentName()].scatterIn();
224
- }, 2000);
220
+ renderers[currentName()].setCharacterHidden(true);
221
+ renderers[currentName()].setProp(getProp("box") ?? null);
225
222
 
226
223
  setTimeout(() => {
227
- if (!renderers[currentName()].getProp()) {
228
- renderers[currentName()].setProp(getProp("box") ?? null);
229
- setTimeout(() => {
230
- renderers[currentName()].setProp(null);
231
- }, 6000);
224
+ renderers[currentName()].setProp(null);
225
+ renderers[currentName()].setCharacterHidden(false);
226
+ if (!scattered) {
227
+ scattered = true;
228
+ renderers[currentName()].scatterIn();
232
229
  }
233
- }, 2500);
230
+ }, 6000);
234
231
 
235
232
  return (
236
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
  }