@mingxy/opencode-mascot 0.7.9 → 0.7.11
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,8 @@ 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
|
|
8
|
+
import { pickPropByTrigger } from "../core/prop-loader";
|
|
9
|
+
import { log } from "../core/logger";
|
|
9
10
|
|
|
10
11
|
interface SidebarMascotProps {
|
|
11
12
|
mascots: Record<string, MascotPack>;
|
|
@@ -156,14 +157,17 @@ export function SidebarMascot(props: SidebarMascotProps): JSX.Element {
|
|
|
156
157
|
props.api.event.on("session.status", (data: unknown) => {
|
|
157
158
|
const payload = data as { type?: string; properties?: { sessionID?: string; status?: { type?: string } } } | null;
|
|
158
159
|
const statusType = payload?.properties?.status?.type;
|
|
160
|
+
log("DEBUG", `session.status: statusType=${statusType}, full=${JSON.stringify(payload)?.slice(0, 200)}`);
|
|
159
161
|
if (statusType === "busy" || statusType === "retry") {
|
|
160
162
|
if (hideSide) returnToView();
|
|
161
163
|
renderers[currentName()].setState("busy");
|
|
162
164
|
const busyProp = pickPropByTrigger("busy");
|
|
163
165
|
renderers[currentName()].setProp(busyProp);
|
|
166
|
+
renderers[currentName()].setCharacterHidden(busyProp?.position === "front");
|
|
164
167
|
} else {
|
|
165
168
|
setStateWithSwitch("idle");
|
|
166
169
|
renderers[currentName()].setProp(null);
|
|
170
|
+
renderers[currentName()].setCharacterHidden(false);
|
|
167
171
|
}
|
|
168
172
|
});
|
|
169
173
|
|
|
@@ -215,75 +219,82 @@ export function SidebarMascot(props: SidebarMascotProps): JSX.Element {
|
|
|
215
219
|
renderers[currentName()].scatterIn();
|
|
216
220
|
}, 2000);
|
|
217
221
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
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;
|
|
222
|
+
const propOffset = () => {
|
|
223
|
+
const pos = renderers[currentName()]?.getPropPosition();
|
|
224
|
+
if (pos === "side-left") return -18;
|
|
225
|
+
if (pos === "side-right") return 12;
|
|
226
|
+
return 0;
|
|
227
|
+
};
|
|
246
228
|
|
|
247
|
-
|
|
248
|
-
|
|
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
|
-
>
|
|
229
|
+
return (
|
|
230
|
+
<>
|
|
274
231
|
{renderers[currentName()]?.propElement() ? (
|
|
275
232
|
<box
|
|
276
233
|
position="absolute"
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
234
|
+
left={posX() + propOffset()}
|
|
235
|
+
top={posY()}
|
|
236
|
+
zIndex={zBoost() ? 9998 : 50}
|
|
280
237
|
>
|
|
281
238
|
{renderers[currentName()].propElement()}
|
|
282
239
|
</box>
|
|
283
240
|
) : null}
|
|
284
|
-
<box
|
|
241
|
+
<box
|
|
242
|
+
position="absolute"
|
|
243
|
+
left={posX()}
|
|
244
|
+
top={posY()}
|
|
245
|
+
alignItems="center"
|
|
246
|
+
zIndex={zBoost() ? 9999 : 100}
|
|
247
|
+
flexDirection="column"
|
|
248
|
+
ref={(node: any) => {
|
|
249
|
+
if (node) {
|
|
250
|
+
setContainerWidth(node.width || 0);
|
|
251
|
+
if (node.onSizeChange !== undefined) {
|
|
252
|
+
node.onSizeChange = () => {
|
|
253
|
+
setContainerWidth(node.width || 0);
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}}
|
|
258
|
+
onMouseDown={(e: any) => {
|
|
259
|
+
if (hideSide) { returnToView(); return; }
|
|
260
|
+
|
|
261
|
+
const now = Date.now();
|
|
262
|
+
if (now - lastClickTime < 300) {
|
|
263
|
+
switchToNext();
|
|
264
|
+
lastClickTime = 0;
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
lastClickTime = now;
|
|
268
|
+
|
|
269
|
+
if (e.modifiers?.alt) {
|
|
270
|
+
dragStartX = e.x;
|
|
271
|
+
dragStartY = e.y;
|
|
272
|
+
dragAnchorX = posX();
|
|
273
|
+
dragAnchorY = posY();
|
|
274
|
+
isDragging = true;
|
|
275
|
+
renderers[currentName()].setDragging(true);
|
|
276
|
+
props.api.renderer.clearSelection();
|
|
277
|
+
}
|
|
278
|
+
}}
|
|
279
|
+
onMouseDrag={(e: any) => {
|
|
280
|
+
if (e.modifiers?.alt && isDragging) {
|
|
281
|
+
setPosX(clampX(dragAnchorX + (e.x - dragStartX)));
|
|
282
|
+
setPosY(clampY(dragAnchorY + (e.y - dragStartY)));
|
|
283
|
+
}
|
|
284
|
+
}}
|
|
285
|
+
onMouseUp={() => {
|
|
286
|
+
isDragging = false;
|
|
287
|
+
renderers[currentName()].setDragging(false);
|
|
288
|
+
checkEdge();
|
|
289
|
+
}}
|
|
290
|
+
onMouseDragEnd={() => {
|
|
291
|
+
isDragging = false;
|
|
292
|
+
renderers[currentName()].setDragging(false);
|
|
293
|
+
checkEdge();
|
|
294
|
+
}}
|
|
295
|
+
>
|
|
285
296
|
{renderers[currentName()]?.element() ?? null}
|
|
286
297
|
</box>
|
|
287
|
-
|
|
298
|
+
</>
|
|
288
299
|
);
|
|
289
300
|
}
|