dsh-quay-bot 1.0.2 → 1.0.4
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/README.md +28 -105
- package/botscreen/requirements.txt +1 -1
- package/client.js +3 -2
- package/cordis.patch.yml +1 -1
- package/host/api.js +4 -0
- package/host/remote.js +285 -8
- package/host/screen.js +22 -86
- package/package.json +35 -32
- package/remote/bin/dsh-remote.mjs +435 -0
- package/remote/package.json +27 -0
- package/remote/src/config.mjs +183 -0
- package/remote/src/crypto.mjs +220 -0
- package/remote/src/keys.mjs +226 -0
- package/remote/src/proxy.mjs +1028 -0
- package/remote/src/sessions.mjs +163 -0
- package/remote/src/shim.js +838 -0
- package/remote/src/supervisor.mjs +207 -0
- package/remote/src/tunnel.mjs +533 -0
- package/remote/src/upstream.mjs +403 -0
- package/remote/src/util.mjs +149 -0
- package/remote/src/ws.mjs +313 -0
- package/LICENSE +0 -21
- package/avatar/build.mjs +0 -81
- package/avatar/gallery/droid.json +0 -14
- package/avatar/gallery/ghost.json +0 -14
- package/avatar/gallery/grok-pod.json +0 -14
- package/avatar/gallery/guardian.json +0 -14
- package/avatar/gallery/mecha.json +0 -14
- package/avatar/gallery/mochi.json +0 -14
- package/avatar/gallery/neko.json +0 -14
- package/avatar/gallery/orbiter.json +0 -14
- package/avatar/gallery/relay.json +0 -14
- package/avatar/gallery/spark.json +0 -14
- package/avatar/src/bot/clay.ts +0 -135
- package/avatar/src/bot/effects.ts +0 -100
- package/avatar/src/bot/grok-bot.ts +0 -626
- package/avatar/src/bot/index.ts +0 -15
- package/avatar/src/bot/palettes.ts +0 -62
- package/avatar/src/bot/ring.ts +0 -219
- package/avatar/src/bot/scheduler.ts +0 -239
- package/avatar/src/bot/shapes.ts +0 -277
- package/avatar/src/bot/spring.ts +0 -196
- package/avatar/src/core/color.ts +0 -92
- package/avatar/src/core/eyes.ts +0 -297
- package/avatar/src/core/field.ts +0 -482
- package/avatar/src/core/frame.ts +0 -655
- package/avatar/src/core/fx.ts +0 -375
- package/avatar/src/core/index.ts +0 -49
- package/avatar/src/core/paint.ts +0 -331
- package/avatar/src/core/path.ts +0 -495
- package/avatar/src/core/pose.ts +0 -581
- package/avatar/src/core/svg.ts +0 -98
- package/avatar/src/core/types.ts +0 -153
- package/avatar/src/core/validate.ts +0 -296
- package/avatar/src/core/volume.ts +0 -681
- package/avatar/src/entry.ts +0 -260
- package/bin/doctor.mjs +0 -148
- package/botscreen/requirements-offline.txt +0 -11
- package/market/index.json +0 -41
package/avatar/src/core/eyes.ts
DELETED
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 任意 look 下单只眼睛的轮廓。
|
|
3
|
-
*
|
|
4
|
-
* 药丸、开心弧、扁平细缝、四角闪光星、闭眼线,全部从顶部中心顺时针等距采样 40 点;
|
|
5
|
-
* 逐点混合就得到中间的所有形状,于是状态或表情切换时眼睛是“变形”,而不是“换图”。
|
|
6
|
-
* 倾斜(tilt)在最后统一旋转整条轮廓,所以它和任何形状都能叠加。
|
|
7
|
-
*/
|
|
8
|
-
import type { EyeLook } from './pose.ts';
|
|
9
|
-
import type { Point } from './path.ts';
|
|
10
|
-
import { HAPPY_ARC } from './validate.ts';
|
|
11
|
-
|
|
12
|
-
/** 这一帧一只眼睛画在哪(脸的平面坐标,viewBox 单位)。 */
|
|
13
|
-
export interface EyeSpot {
|
|
14
|
-
/** 中心,已含凝视偏移。 */
|
|
15
|
-
x: number;
|
|
16
|
-
y: number;
|
|
17
|
-
w: number;
|
|
18
|
-
h: number;
|
|
19
|
-
/** 眨眼/眯眼之后的药丸高度,以及它向下移动的距离。 */
|
|
20
|
-
open: number;
|
|
21
|
-
shift: number;
|
|
22
|
-
/** 这只眼睛完全闭着(眨眼到顶)。 */
|
|
23
|
-
closed?: boolean;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/** 每条轮廓的点数。 */
|
|
27
|
-
const STEPS = 40;
|
|
28
|
-
/** 细缝:与开心弧等宽,厚度与翘角按眼睛宽度比例。 */
|
|
29
|
-
const SLIT = { length: 1.9, thick: 0.5, tip: 0.2 } as const;
|
|
30
|
-
/** 闪光星:外径/内径按眼睛宽高的比例。 */
|
|
31
|
-
const STAR = { outerMin: 0.42, inner: 0.34, points: 4 } as const;
|
|
32
|
-
/** 闭眼线:比眼睛略长,向下弯。 */
|
|
33
|
-
const CLOSED = { length: 1.3, thick: 0.3, sag: 0.3 } as const;
|
|
34
|
-
|
|
35
|
-
const clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v));
|
|
36
|
-
|
|
37
|
-
/** 沿闭合折线等距取 `count` 个点,从第一个点开始。 */
|
|
38
|
-
function resample(pts: Point[], count: number): Point[] {
|
|
39
|
-
const n = pts.length;
|
|
40
|
-
const at: number[] = [0];
|
|
41
|
-
for (let i = 0; i < n; i++) {
|
|
42
|
-
const a = pts[i];
|
|
43
|
-
const b = pts[(i + 1) % n];
|
|
44
|
-
at.push(at[i] + Math.hypot(b[0] - a[0], b[1] - a[1]));
|
|
45
|
-
}
|
|
46
|
-
const total = at[n];
|
|
47
|
-
const out: Point[] = [];
|
|
48
|
-
let i = 0;
|
|
49
|
-
for (let k = 0; k < count; k++) {
|
|
50
|
-
const s = (k / count) * total;
|
|
51
|
-
while (i < n - 1 && at[i + 1] < s) i++;
|
|
52
|
-
const a = pts[i];
|
|
53
|
-
const b = pts[(i + 1) % n];
|
|
54
|
-
const u = at[i + 1] > at[i] ? (s - at[i]) / (at[i + 1] - at[i]) : 0;
|
|
55
|
-
out.push([a[0] + (b[0] - a[0]) * u, a[1] + (b[1] - a[1]) * u]);
|
|
56
|
-
}
|
|
57
|
-
return out;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/** 一段圆弧上的点,从 `from` 到 `to`(弧度,y 向下),含两端。 */
|
|
61
|
-
function sweep(cx: number, cy: number, r: number, from: number, to: number, steps: number): Point[] {
|
|
62
|
-
const pts: Point[] = [];
|
|
63
|
-
for (let i = 0; i <= steps; i++) {
|
|
64
|
-
const a = from + ((to - from) * i) / steps;
|
|
65
|
-
pts.push([cx + Math.cos(a) * r, cy + Math.sin(a) * r]);
|
|
66
|
-
}
|
|
67
|
-
return pts;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/** 药丸:以 (cx, cy) 为中心、宽 w 高 h 的跑道形,从顶部中心顺时针。 */
|
|
71
|
-
function pill(cx: number, cy: number, w: number, h: number): Point[] {
|
|
72
|
-
const r = Math.min(w, h) / 2;
|
|
73
|
-
const fx = w / 2 - r;
|
|
74
|
-
const fy = h / 2 - r;
|
|
75
|
-
const q = Math.PI / 2;
|
|
76
|
-
return [
|
|
77
|
-
[cx, cy - h / 2] as Point,
|
|
78
|
-
...sweep(cx + fx, cy - fy, r, -q, 0, 6),
|
|
79
|
-
...sweep(cx + fx, cy + fy, r, 0, q, 6),
|
|
80
|
-
...sweep(cx - fx, cy + fy, r, q, 2 * q, 6),
|
|
81
|
-
...sweep(cx - fx, cy - fy, r, 2 * q, 3 * q, 6),
|
|
82
|
-
];
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/** 开心弧的轮廓:描边的上下两条边,加上两个圆头。 */
|
|
86
|
-
function arc(e: EyeSpot): Point[] {
|
|
87
|
-
const hw = e.w * HAPPY_ARC.halfWidth;
|
|
88
|
-
const base = e.y + e.h * HAPPY_ARC.base;
|
|
89
|
-
const peak = e.y - e.h * HAPPY_ARC.peak;
|
|
90
|
-
const r = (e.w * HAPPY_ARC.stroke) / 2;
|
|
91
|
-
const at = (s: number): { p: Point; n: Point } => {
|
|
92
|
-
const m = 1 - s;
|
|
93
|
-
const x = e.x + hw * (2 * s - 1);
|
|
94
|
-
const y = (m * m + s * s) * base + 2 * m * s * peak;
|
|
95
|
-
const tx = 2 * hw;
|
|
96
|
-
const ty = 2 * (2 * s - 1) * (base - peak);
|
|
97
|
-
const len = Math.hypot(tx, ty);
|
|
98
|
-
return { p: [x, y], n: [ty / len, -tx / len] };
|
|
99
|
-
};
|
|
100
|
-
const edge = (from: number, to: number, side: 1 | -1): Point[] => {
|
|
101
|
-
const pts: Point[] = [];
|
|
102
|
-
for (let i = 0; i <= 8; i++) {
|
|
103
|
-
const { p, n } = at(from + ((to - from) * i) / 8);
|
|
104
|
-
pts.push([p[0] + n[0] * r * side, p[1] + n[1] * r * side]);
|
|
105
|
-
}
|
|
106
|
-
return pts;
|
|
107
|
-
};
|
|
108
|
-
const end = (s: 0 | 1): Point[] => {
|
|
109
|
-
const { p, n } = at(s);
|
|
110
|
-
const up = Math.atan2(n[1], n[0]);
|
|
111
|
-
return s === 1 ? sweep(p[0], p[1], r, up, up + Math.PI, 8) : sweep(p[0], p[1], r, up + Math.PI, up + 2 * Math.PI, 8);
|
|
112
|
-
};
|
|
113
|
-
return [...edge(0.5, 1, 1), ...end(1), ...edge(1, 0, -1), ...end(0), ...edge(0, 0.5, 1)];
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/** 细缝:几乎躺平的薄胶囊,两只眼向同一侧倾;眨眼会把它变薄。 */
|
|
117
|
-
function slit(e: EyeSpot): Point[] {
|
|
118
|
-
const length = e.w * SLIT.length;
|
|
119
|
-
const thick = e.w * SLIT.thick * clamp(e.open / e.h, 0.3, 1);
|
|
120
|
-
const cos = Math.cos(SLIT.tip);
|
|
121
|
-
const sin = Math.sin(SLIT.tip);
|
|
122
|
-
return pill(0, 0, length, thick).map(([x, y]) => [e.x + x * cos - y * sin, e.y + x * sin + y * cos] as Point);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/** 半闭的眼(困):上缘平、下缘圆,像上眼皮压下来一样。 */
|
|
126
|
-
function lidded(e: EyeSpot, drop: number): Point[] {
|
|
127
|
-
const w = e.w;
|
|
128
|
-
const half = w / 2;
|
|
129
|
-
const ty = e.y + e.shift - e.h / 2 + clamp(drop, 0, 1) * e.h * 0.62;
|
|
130
|
-
const by = e.y + e.shift + e.h / 2;
|
|
131
|
-
const h = Math.max(by - ty, w * 0.4);
|
|
132
|
-
const r = Math.min(half, h / 2);
|
|
133
|
-
const q = Math.PI / 2;
|
|
134
|
-
return [
|
|
135
|
-
[e.x - half, ty] as Point,
|
|
136
|
-
[e.x + half, ty] as Point,
|
|
137
|
-
...sweep(e.x + half - r, by - r, r, 0, q, 5),
|
|
138
|
-
...sweep(e.x - half + r, by - r, r, q, 2 * q, 5),
|
|
139
|
-
];
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/** 四角闪光星:近方形的四角星,内角圆润(软化后再重采样)。 */
|
|
143
|
-
function star(e: EyeSpot): Point[] {
|
|
144
|
-
// 星要看起来“方”,所以横竖两个半径都按眼睛的长边取,再各自不小于一个下界。
|
|
145
|
-
const rx = Math.max(e.w * 1.05, e.h * STAR.outerMin);
|
|
146
|
-
const ry = Math.max(e.h * 0.6, e.w * 1.0);
|
|
147
|
-
const irx = rx * STAR.inner;
|
|
148
|
-
const iry = ry * STAR.inner;
|
|
149
|
-
const pts: Point[] = [];
|
|
150
|
-
const n = STAR.points * 2;
|
|
151
|
-
for (let k = 0; k < n; k++) {
|
|
152
|
-
const a = -Math.PI / 2 + (k * Math.PI) / STAR.points;
|
|
153
|
-
const ox = k % 2 ? irx : rx;
|
|
154
|
-
const oy = k % 2 ? iry : ry;
|
|
155
|
-
pts.push([e.x + Math.cos(a) * ox, e.y + Math.sin(a) * oy]);
|
|
156
|
-
}
|
|
157
|
-
// 每个顶点后插一个靠内的点,重采样时星角不会整块丢掉。
|
|
158
|
-
const softened: Point[] = [];
|
|
159
|
-
for (let k = 0; k < n; k++) {
|
|
160
|
-
const p = pts[k];
|
|
161
|
-
const q = pts[(k + 1) % n];
|
|
162
|
-
softened.push(p, [p[0] * 0.8 + q[0] * 0.2, p[1] * 0.8 + q[1] * 0.2]);
|
|
163
|
-
}
|
|
164
|
-
return softened;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/** 闭眼线:一条向下弯的细胶囊,像垂下的眼皮。 */
|
|
168
|
-
function closedEyelid(e: EyeSpot): Point[] {
|
|
169
|
-
const half = (e.w * CLOSED.length) / 2;
|
|
170
|
-
const thick = Math.max(e.w * CLOSED.thick, 0.8);
|
|
171
|
-
const sag = Math.max(e.h * CLOSED.sag, thick);
|
|
172
|
-
const y0 = e.y - e.h * 0.02;
|
|
173
|
-
const N = 14;
|
|
174
|
-
const upper: Point[] = [];
|
|
175
|
-
const lower: Point[] = [];
|
|
176
|
-
// 曲线很浅,直接按竖直方向取厚度,避免法线在两端翻转导致自交。
|
|
177
|
-
for (let i = 0; i <= N; i++) {
|
|
178
|
-
const s = i / N;
|
|
179
|
-
const x = e.x - half + 2 * half * s;
|
|
180
|
-
const y = y0 + sag * (1 - (2 * s - 1) ** 2);
|
|
181
|
-
upper.push([x, y - thick / 2]);
|
|
182
|
-
lower.push([x, y + thick / 2]);
|
|
183
|
-
}
|
|
184
|
-
const cap = (cx: number, cy: number, from: number, to: number): Point[] => sweep(cx, cy, thick / 2, from, to, 4);
|
|
185
|
-
const right = upper[upper.length - 1];
|
|
186
|
-
const left = upper[0];
|
|
187
|
-
return [
|
|
188
|
-
...upper,
|
|
189
|
-
...cap(right[0], right[1] + thick / 2, -Math.PI / 2, Math.PI / 2),
|
|
190
|
-
...lower.reverse(),
|
|
191
|
-
...cap(left[0], left[1] + thick / 2, Math.PI / 2, Math.PI * 1.5),
|
|
192
|
-
];
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/** 是否恰好是普通药丸或恰好是开心弧:这两种直接用简单图元画,省一条路径。 */
|
|
196
|
-
export function plainLook(look: EyeLook): 'pill' | 'arc' | null {
|
|
197
|
-
if (look.arc >= 1) return 'arc';
|
|
198
|
-
const rest = look.arc <= 0 && look.slit <= 0 && look.wide <= 0 && look.star <= 0 && Math.abs(look.tilt) < 0.02;
|
|
199
|
-
return rest ? 'pill' : null;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
/** 把一条轮廓绕眼睛中心旋转 `angle` 弧度。 */
|
|
203
|
-
function tilt(pts: Point[], e: EyeSpot, angle: number): Point[] {
|
|
204
|
-
if (Math.abs(angle) < 1e-4) return pts;
|
|
205
|
-
const cos = Math.cos(angle);
|
|
206
|
-
const sin = Math.sin(angle);
|
|
207
|
-
return pts.map(([x, y]) => {
|
|
208
|
-
const dx = x - e.x;
|
|
209
|
-
const dy = y - e.y;
|
|
210
|
-
return [e.x + dx * cos - dy * sin, e.y + dx * sin + dy * cos] as Point;
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/** 混合权重:闭眼 > 星 > 弧 > 细缝 > 药丸。 */
|
|
215
|
-
function weightsOf(look: EyeLook): { name: string; w: number }[] {
|
|
216
|
-
const star = clamp(look.star, 0, 1);
|
|
217
|
-
const arc = clamp(look.arc, 0, 1 - star);
|
|
218
|
-
const lid = clamp(look.lid, 0, 1 - arc - star);
|
|
219
|
-
const slit = clamp(look.slit, 0, 1 - arc - star - lid);
|
|
220
|
-
const pillw = Math.max(0, 1 - arc - slit - lid - star);
|
|
221
|
-
return [
|
|
222
|
-
{ name: 'pill', w: pillw },
|
|
223
|
-
{ name: 'arc', w: arc },
|
|
224
|
-
{ name: 'slit', w: slit },
|
|
225
|
-
{ name: 'star', w: star },
|
|
226
|
-
{ name: 'lidded', w: lid },
|
|
227
|
-
];
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/** 一只眼的闭合轮廓,从顶部顺时针:各形状按 look 混合后再统一倾斜。 */
|
|
231
|
-
export function eyeOutline(look: EyeLook, e: EyeSpot): Point[] {
|
|
232
|
-
if (e.closed) return tilt(resample(closedEyelid(e), STEPS), e, look.tilt * 0.25);
|
|
233
|
-
|
|
234
|
-
const wide = clamp(look.wide, 0, 1);
|
|
235
|
-
const shapes: Record<string, Point[]> = {
|
|
236
|
-
// 惊讶时眼睛更高、更圆(宽不变,圆角半径随之变大)。
|
|
237
|
-
pill: pill(e.x, e.y + e.shift, e.w, e.open * (1 + 0.2 * wide)),
|
|
238
|
-
arc: arc(e),
|
|
239
|
-
slit: slit(e),
|
|
240
|
-
star: star(e),
|
|
241
|
-
lidded: lidded(e, clamp(look.lid, 0, 1)),
|
|
242
|
-
};
|
|
243
|
-
const out: Point[] = Array.from({ length: STEPS }, () => [0, 0] as Point);
|
|
244
|
-
let total = 0;
|
|
245
|
-
for (const { name, w } of weightsOf(look)) {
|
|
246
|
-
if (w <= 0) continue;
|
|
247
|
-
total += w;
|
|
248
|
-
resample(shapes[name], STEPS).forEach(([x, y], i) => {
|
|
249
|
-
out[i][0] += x * w;
|
|
250
|
-
out[i][1] += y * w;
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
if (total <= 0) return tilt(resample(shapes.pill, STEPS), e, look.tilt * 0.25);
|
|
254
|
-
for (const p of out) {
|
|
255
|
-
p[0] /= total;
|
|
256
|
-
p[1] /= total;
|
|
257
|
-
}
|
|
258
|
-
return tilt(out, e, look.tilt * 0.25);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
const f = (n: number): string => {
|
|
262
|
-
const r = Math.round(n * 100) / 100;
|
|
263
|
-
return (Object.is(r, -0) ? 0 : r).toString();
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
/** 过一组点的光滑闭合路径:每点一条二次曲线,在边中点相接。只用绝对的 M / Q / Z。 */
|
|
267
|
-
export function outlinePath(pts: Point[]): string {
|
|
268
|
-
const n = pts.length;
|
|
269
|
-
const mid = (i: number): Point => {
|
|
270
|
-
const a = pts[i % n];
|
|
271
|
-
const b = pts[(i + 1) % n];
|
|
272
|
-
return [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2];
|
|
273
|
-
};
|
|
274
|
-
const start = mid(n - 1);
|
|
275
|
-
let d = `M${f(start[0])} ${f(start[1])}`;
|
|
276
|
-
for (let i = 0; i < n; i++) {
|
|
277
|
-
const m = mid(i);
|
|
278
|
-
d += `Q${f(pts[i][0])} ${f(pts[i][1])} ${f(m[0])} ${f(m[1])}`;
|
|
279
|
-
}
|
|
280
|
-
return `${d}Z`;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
/** 既不是普通药丸也不是普通弧时,单只眼睛的路径。 */
|
|
284
|
-
export function eyePath(look: EyeLook, e: EyeSpot): string {
|
|
285
|
-
return outlinePath(eyeOutline(look, e));
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/** 高光:眼睛左上角的一小块圆,用身体颜色画在眼球上层。 */
|
|
289
|
-
export function glintPath(e: EyeSpot, strength: number): { d: string; r: number; x: number; y: number } | null {
|
|
290
|
-
const open = clamp(e.open / e.h, 0, 1);
|
|
291
|
-
const k = clamp(strength, 0, 1) * clamp((open - 0.25) / 0.5, 0, 1);
|
|
292
|
-
if (k <= 0.04) return null;
|
|
293
|
-
const r = Math.max(0.35, Math.min(e.w * 0.24, e.h * 0.17) * k);
|
|
294
|
-
const x = e.x - e.w * 0.24;
|
|
295
|
-
const y = e.y + e.shift - e.h * 0.24;
|
|
296
|
-
return { d: `M${f(x - r)} ${f(y)}a${f(r)} ${f(r)} 0 1 1 ${f(2 * r)} 0a${f(r)} ${f(r)} 0 1 1 ${f(-2 * r)} 0Z`, r, x, y };
|
|
297
|
-
}
|