clawd-desktop 1.0.5 → 1.0.7

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": "clawd-desktop",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "A pixel-art Claude mascot that lives on your desktop",
5
5
  "main": "main.js",
6
6
  "bin": {
package/preload.js CHANGED
@@ -1,6 +1,10 @@
1
1
  const { contextBridge, ipcRenderer } = require('electron');
2
+ const fs = require('fs');
3
+ const path = require('path');
2
4
 
3
5
  contextBridge.exposeInMainWorld('electronAPI', {
4
6
  moveWindow: (pos) => ipcRenderer.send('move-window', pos),
5
- getScreenSize: () => ipcRenderer.invoke('get-screen-size')
7
+ getScreenSize: () => ipcRenderer.invoke('get-screen-size'),
8
+ getGifs: () => fs.readdirSync(path.join(__dirname, 'assets', 'gif'))
9
+ .filter(f => f.endsWith('.gif'))
6
10
  });
@@ -1,54 +1,52 @@
1
- const STATES = {
2
- 'idle': '../assets/gif/clawd-idle.gif',
3
- 'reading': '../assets/gif/clawd-idle-reading.gif',
4
- 'happy': '../assets/gif/clawd-happy.gif',
5
- 'thinking': '../assets/gif/clawd-thinking.gif',
6
- 'sleeping': '../assets/gif/clawd-sleeping.gif',
7
- 'typing': '../assets/gif/clawd-typing.gif',
8
- 'sweeping': '../assets/gif/clawd-sweeping.gif',
9
- 'juggling': '../assets/gif/clawd-juggling.gif'
10
- };
11
-
12
- // Movement states
13
- const MOVE_STATES = ['idle', 'reading', 'happy']; // These will trigger movement in motion.js
14
- const STATIONARY_STATES = ['thinking', 'sleeping', 'typing', 'sweeping', 'juggling'];
1
+ const rawGifs = window.electronAPI.getGifs();
2
+
3
+ const MOVE_KEYWORDS = ['idle', 'happy', 'reading'];
4
+
5
+ const STATES = {};
6
+ rawGifs.forEach(f => {
7
+ const key = f.replace('.gif', '');
8
+ STATES[key] = `../assets/gif/${f}`;
9
+ });
10
+
11
+ const MOVE_STATES = Object.keys(STATES).filter(k =>
12
+ MOVE_KEYWORDS.some(kw => k.includes(kw))
13
+ );
14
+ const STATIONARY_STATES = Object.keys(STATES).filter(k =>
15
+ !MOVE_KEYWORDS.some(kw => k.includes(kw))
16
+ );
15
17
 
16
18
  const container = document.getElementById('pet-container');
17
19
  const petImg = document.getElementById('pet-img');
18
20
 
19
- let currentState = 'idle';
21
+ let currentState = 'clawd-idle';
22
+ let recentStates = [];
20
23
 
21
24
  function setState(newState) {
22
25
  if (!STATES[newState]) return;
23
-
26
+
24
27
  container.classList.remove(currentState);
25
28
  container.classList.add(newState);
26
-
29
+
27
30
  petImg.src = STATES[newState];
28
31
  currentState = newState;
29
-
30
- console.log(`State changed to: ${newState}`);
31
32
 
32
- // Schedule next state change
33
- const nextTimeout = Math.random() * 15000 + 10000; // Longer duration (10-25s) for stability
33
+ recentStates = [...recentStates.slice(-3), newState];
34
+
35
+ const nextTimeout = Math.random() * 15000 + 10000;
34
36
  setTimeout(pickRandomState, nextTimeout);
35
37
  }
36
38
 
37
39
  function pickRandomState() {
38
- const keys = Object.keys(STATES);
39
- let next = keys[Math.floor(Math.random() * keys.length)];
40
-
41
- // Don't pick the same state twice in a row if possible
42
- if (next === currentState) {
43
- next = keys[Math.floor(Math.random() * keys.length)];
44
- }
45
-
40
+ const keys = Object.keys(STATES).filter(k => !recentStates.includes(k));
41
+ const pool = keys.length > 0 ? keys : Object.keys(STATES);
42
+ const next = pool[Math.floor(Math.random() * pool.length)];
46
43
  setState(next);
47
44
  }
48
45
 
49
- // Initial state
50
46
  window.addEventListener('load', () => {
51
- setState('idle');
47
+ const keys = Object.keys(STATES);
48
+ const initial = keys.find(k => k.includes('idle')) || keys[0];
49
+ setState(initial);
52
50
  });
53
51
 
54
52
  window.getCurrentState = () => currentState;