desktop-pet-app 0.1.2 → 0.2.2
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/out/main/index.js
CHANGED
|
@@ -110,6 +110,7 @@ const PET_EVENT = "pet:event";
|
|
|
110
110
|
const PET_MOVE = "pet:move";
|
|
111
111
|
const PET_DRAG = "pet:drag";
|
|
112
112
|
const PET_MENU = "pet:menu";
|
|
113
|
+
const PET_MOUSE_PASSTHROUGH = "pet:mouse-passthrough";
|
|
113
114
|
const P2P_SIGNAL_IN = "p2p:signal-in";
|
|
114
115
|
const P2P_SIGNAL_OUT = "p2p:signal-out";
|
|
115
116
|
const P2P_CONFIG = "p2p:config";
|
|
@@ -342,7 +343,7 @@ function validate(credentials) {
|
|
|
342
343
|
throw new Error("设备配置的 serverUrl 必须使用 http 或 https");
|
|
343
344
|
}
|
|
344
345
|
}
|
|
345
|
-
const DEFAULT_DESKTOP_PET_HOST = "
|
|
346
|
+
const DEFAULT_DESKTOP_PET_HOST = "https://deskpalai.com";
|
|
346
347
|
function configuredRelayURL() {
|
|
347
348
|
const host = process.env.DESKTOP_PET_HOST?.trim();
|
|
348
349
|
if (host) return relayURLFromHost(host);
|
|
@@ -1949,6 +1950,7 @@ function createPetWindow(skin, options) {
|
|
|
1949
1950
|
});
|
|
1950
1951
|
win.setAlwaysOnTop(true, "screen-saver");
|
|
1951
1952
|
win.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true });
|
|
1953
|
+
win.setIgnoreMouseEvents(true, { forward: true });
|
|
1952
1954
|
registerPetWindow(id, win);
|
|
1953
1955
|
petManager.register(id, win, skin, identity);
|
|
1954
1956
|
if (process.env.ELECTRON_RENDERER_URL) {
|
|
@@ -1980,6 +1982,10 @@ function createPetWindow(skin, options) {
|
|
|
1980
1982
|
if (win.isDestroyed() || e.sender !== win.webContents) return;
|
|
1981
1983
|
void showPetMenu();
|
|
1982
1984
|
};
|
|
1985
|
+
const onMousePassthrough = (e, enabled) => {
|
|
1986
|
+
if (win.isDestroyed() || e.sender !== win.webContents || typeof enabled !== "boolean") return;
|
|
1987
|
+
win.setIgnoreMouseEvents(enabled, { forward: enabled });
|
|
1988
|
+
};
|
|
1983
1989
|
const showPetMenu = async () => {
|
|
1984
1990
|
const accountUsername = currentAccountUsername();
|
|
1985
1991
|
const identityPresentation = publishIdentity();
|
|
@@ -2072,10 +2078,12 @@ function createPetWindow(skin, options) {
|
|
|
2072
2078
|
electron.ipcMain.on(PET_MOVE, onMove);
|
|
2073
2079
|
electron.ipcMain.on(PET_DRAG, onDrag);
|
|
2074
2080
|
electron.ipcMain.on(PET_MENU, onMenu);
|
|
2081
|
+
electron.ipcMain.on(PET_MOUSE_PASSTHROUGH, onMousePassthrough);
|
|
2075
2082
|
win.on("closed", () => {
|
|
2076
2083
|
electron.ipcMain.removeListener(PET_MOVE, onMove);
|
|
2077
2084
|
electron.ipcMain.removeListener(PET_DRAG, onDrag);
|
|
2078
2085
|
electron.ipcMain.removeListener(PET_MENU, onMenu);
|
|
2086
|
+
electron.ipcMain.removeListener(PET_MOUSE_PASSTHROUGH, onMousePassthrough);
|
|
2079
2087
|
});
|
|
2080
2088
|
return id;
|
|
2081
2089
|
}
|
package/out/preload/index.js
CHANGED
|
@@ -4,6 +4,7 @@ const PET_EVENT = "pet:event";
|
|
|
4
4
|
const PET_MOVE = "pet:move";
|
|
5
5
|
const PET_DRAG = "pet:drag";
|
|
6
6
|
const PET_MENU = "pet:menu";
|
|
7
|
+
const PET_MOUSE_PASSTHROUGH = "pet:mouse-passthrough";
|
|
7
8
|
const P2P_SIGNAL_IN = "p2p:signal-in";
|
|
8
9
|
const P2P_SIGNAL_OUT = "p2p:signal-out";
|
|
9
10
|
const P2P_START = "p2p:start";
|
|
@@ -13,6 +14,7 @@ const P2P_CHAT_EVENT = "p2p:chat-event";
|
|
|
13
14
|
electron.contextBridge.exposeInMainWorld("petApi", {
|
|
14
15
|
move: (dx, dy) => electron.ipcRenderer.send(PET_MOVE, dx, dy),
|
|
15
16
|
drag: (phase, dx = 0, dy = 0) => electron.ipcRenderer.send(PET_DRAG, phase, dx, dy),
|
|
17
|
+
setMousePassthrough: (enabled) => electron.ipcRenderer.send(PET_MOUSE_PASSTHROUGH, enabled),
|
|
16
18
|
openMenu: () => electron.ipcRenderer.send(PET_MENU),
|
|
17
19
|
onEvent: (cb) => {
|
|
18
20
|
electron.ipcRenderer.on(PET_EVENT, (_e, ev) => cb(ev));
|
|
@@ -1618,9 +1618,28 @@ window.petApi.onEvent((ev) => {
|
|
|
1618
1618
|
let dragging = false;
|
|
1619
1619
|
let lastX = 0;
|
|
1620
1620
|
let lastY = 0;
|
|
1621
|
+
let mousePassthrough = false;
|
|
1622
|
+
function updateMousePassthrough(clientX, clientY) {
|
|
1623
|
+
const rect = canvas.getBoundingClientRect();
|
|
1624
|
+
const x = Math.floor((clientX - rect.left) * canvas.width / rect.width);
|
|
1625
|
+
const y = Math.floor((clientY - rect.top) * canvas.height / rect.height);
|
|
1626
|
+
let overPet = false;
|
|
1627
|
+
if (x >= 0 && x < canvas.width && y >= 0 && y < canvas.height) {
|
|
1628
|
+
const alpha = canvas.getContext("2d").getImageData(x, y, 1, 1).data[3];
|
|
1629
|
+
overPet = alpha > 16;
|
|
1630
|
+
}
|
|
1631
|
+
const next = !dragging && !overPet;
|
|
1632
|
+
if (next === mousePassthrough) return;
|
|
1633
|
+
mousePassthrough = next;
|
|
1634
|
+
window.petApi.setMousePassthrough(next);
|
|
1635
|
+
}
|
|
1621
1636
|
canvas.addEventListener("mousedown", (e) => {
|
|
1622
1637
|
if (e.button !== 0) return;
|
|
1623
1638
|
dragging = true;
|
|
1639
|
+
if (mousePassthrough) {
|
|
1640
|
+
mousePassthrough = false;
|
|
1641
|
+
window.petApi.setMousePassthrough(false);
|
|
1642
|
+
}
|
|
1624
1643
|
lastX = e.screenX;
|
|
1625
1644
|
lastY = e.screenY;
|
|
1626
1645
|
animator.setDragging(true);
|
|
@@ -1628,21 +1647,24 @@ canvas.addEventListener("mousedown", (e) => {
|
|
|
1628
1647
|
draw();
|
|
1629
1648
|
});
|
|
1630
1649
|
window.addEventListener("mousemove", (e) => {
|
|
1631
|
-
if (
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1650
|
+
if (dragging) {
|
|
1651
|
+
const dx = e.screenX - lastX;
|
|
1652
|
+
const dy = e.screenY - lastY;
|
|
1653
|
+
if (dx !== 0 || dy !== 0) window.petApi.drag("move", dx, dy);
|
|
1654
|
+
lastX = e.screenX;
|
|
1655
|
+
lastY = e.screenY;
|
|
1656
|
+
}
|
|
1657
|
+
updateMousePassthrough(e.clientX, e.clientY);
|
|
1637
1658
|
});
|
|
1638
|
-
window.addEventListener("mouseup", () => {
|
|
1659
|
+
window.addEventListener("mouseup", (e) => {
|
|
1639
1660
|
if (!dragging) return;
|
|
1640
1661
|
dragging = false;
|
|
1641
1662
|
window.petApi.drag("end");
|
|
1642
1663
|
animator.setDragging(false);
|
|
1643
1664
|
draw();
|
|
1665
|
+
updateMousePassthrough(e.clientX, e.clientY);
|
|
1644
1666
|
});
|
|
1645
|
-
|
|
1667
|
+
canvas.addEventListener("contextmenu", (e) => {
|
|
1646
1668
|
e.preventDefault();
|
|
1647
1669
|
if (dragging) {
|
|
1648
1670
|
dragging = false;
|
|
@@ -1659,3 +1681,4 @@ window.addEventListener("blur", () => {
|
|
|
1659
1681
|
animator.setDragging(false);
|
|
1660
1682
|
draw();
|
|
1661
1683
|
});
|
|
1684
|
+
window.petApi.setMousePassthrough(true);
|
package/out/renderer/index.html
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "desktop-pet-app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "AI desktop pet with MCP support and a self-hosted relay server",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -32,10 +32,9 @@
|
|
|
32
32
|
"e2e:codebuddy:context": "node scripts/e2e-codebuddy-context-round.mjs",
|
|
33
33
|
"typecheck": "tsc --noEmit",
|
|
34
34
|
"test": "vitest run",
|
|
35
|
-
"package:mac": "npm run build && electron-builder --mac pkg --publish never",
|
|
35
|
+
"package:mac": "npm run build && node scripts/prepare-electron-builder.mjs && electron-builder --mac pkg --publish never; node scripts/prepare-electron-builder.mjs --restore",
|
|
36
36
|
"pack:check": "npm pack --dry-run",
|
|
37
|
-
"prepack": "npm run build
|
|
38
|
-
"postpack": "node scripts/prepare-npm-package.mjs --restore",
|
|
37
|
+
"prepack": "npm run build",
|
|
39
38
|
"prepublishOnly": "npm run typecheck && npm test && npm run pack:check"
|
|
40
39
|
},
|
|
41
40
|
"build": {
|