@aidget-community/grok-acrylic 0.1.0 → 0.2.1

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/agents.md CHANGED
@@ -19,8 +19,11 @@ PNG;原照片中的布面、显示器和支架不属于挂件。
19
19
 
20
20
  ## 扫光、权限与刷新
21
21
 
22
- - 内联脚本只在 `.pendant` 上监听鼠标位置和扫光动画,闲置时回到静止光位;动画收敛后
23
- 停止申请帧。
22
+ - 内联脚本通过 `window.aidget.onPointer` 接收宿主 hover 事件;`enter` / `move` 更新
23
+ 光位并升到全亮,`leave` 回到静止光位。不要改回 DOM `pointermove`,也不要在窗口
24
+ `blur` 时收掉高光,否则非活动窗口会失去跟随效果。
25
+ - 扫光动画使用 `window.aidget.requestAnimationFrame`,按经过时间插值;收敛后停止申请帧。
26
+ 需要宿主提供该动画 API,不要改用 iframe 的原生帧时钟或增加常驻循环。
24
27
  - `prefers-reduced-motion` 下直接到达目标。不要增加常驻循环、远程资源或数据请求。
25
28
  - `permissions` 仅保留 `script`,`network` 保持空数组;没有定时刷新。
26
29
  - 页面使用 `aidget-surface="none"`,不要添加窗口材质或 `backdrop-filter`。
package/config.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "id": "grok-acrylic",
3
3
  "title": "Grok · 亚克力挂件",
4
+ "minHostVersion": "0.1.13",
4
5
  "logo": null,
5
6
  "screenshots": ["assets/screenshot.png"],
6
7
  "platforms": ["macos", "windows", "linux"],
package/index.html CHANGED
@@ -29,6 +29,7 @@
29
29
  let pos = { ...REST };
30
30
  let glow = { value: 0, target: IDLE_GLOW };
31
31
  let running = false;
32
+ let previousTime = null;
32
33
 
33
34
  function paint() {
34
35
  root.style.setProperty('--mx', `${(pos.x * 100).toFixed(2)}%`);
@@ -36,11 +37,18 @@
36
37
  root.style.setProperty('--shine', glow.value.toFixed(3));
37
38
  }
38
39
 
39
- function tick() {
40
- const ease = reduceMotion.matches ? 1 : 0.18;
40
+ function tick(timestamp) {
41
+ const elapsed =
42
+ previousTime === null
43
+ ? 1000 / 60
44
+ : Math.min(100, Math.max(0, timestamp - previousTime));
45
+ previousTime = timestamp;
46
+ const ease = reduceMotion.matches ? 1 : 1 - Math.pow(0.82, elapsed / (1000 / 60));
41
47
  pos.x += (target.x - pos.x) * ease;
42
48
  pos.y += (target.y - pos.y) * ease;
43
- glow.value += (glow.target - glow.value) * (reduceMotion.matches ? 1 : 0.12);
49
+ glow.value +=
50
+ (glow.target - glow.value) *
51
+ (reduceMotion.matches ? 1 : 1 - Math.pow(0.88, elapsed / (1000 / 60)));
44
52
  paint();
45
53
  const settled =
46
54
  Math.abs(target.x - pos.x) < 0.002 &&
@@ -51,23 +59,24 @@
51
59
  glow.value = glow.target;
52
60
  paint();
53
61
  running = false;
62
+ previousTime = null;
54
63
  return;
55
64
  }
56
- requestAnimationFrame(tick);
65
+ window.aidget.requestAnimationFrame(tick);
57
66
  }
58
67
 
59
68
  function wake() {
60
69
  if (!running) {
61
70
  running = true;
62
- requestAnimationFrame(tick);
71
+ window.aidget.requestAnimationFrame(tick);
63
72
  }
64
73
  }
65
74
 
66
- function follow(event) {
75
+ function follow(x, y) {
67
76
  const rect = pendant.getBoundingClientRect();
68
77
  if (!rect.width || !rect.height) return;
69
- target.x = clamp((event.clientX - rect.left) / rect.width, -0.2, 1.2);
70
- target.y = clamp((event.clientY - rect.top) / rect.height, -0.2, 1.2);
78
+ target.x = clamp((x - rect.left) / rect.width, 0, 1);
79
+ target.y = clamp((y - rect.top) / rect.height, 0, 1);
71
80
  glow.target = 1;
72
81
  wake();
73
82
  }
@@ -78,10 +87,13 @@
78
87
  wake();
79
88
  }
80
89
 
81
- pendant.addEventListener('pointermove', follow);
82
- pendant.addEventListener('pointerdown', follow);
83
- pendant.addEventListener('pointerleave', rest);
84
- window.addEventListener('blur', rest);
90
+ window.aidget.onPointer((event) => {
91
+ if (event.type === 'leave') {
92
+ rest();
93
+ return;
94
+ }
95
+ follow(event.x, event.y);
96
+ });
85
97
  document.addEventListener('visibilitychange', () => {
86
98
  if (document.hidden) rest();
87
99
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aidget-community/grok-acrylic",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Grok 猫娘主题的透明亚克力挂件桌面卡片,带鼠标跟随扫光。",
5
5
  "license": "MIT",
6
6
  "author": {