@kodax-ai/botui 0.1.0 → 0.1.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/README.md CHANGED
@@ -33,7 +33,7 @@ bot.setState('thinking');
33
33
  <bot-avatar identity="research-bot" size="36" state="thinking"></bot-avatar>
34
34
  ```
35
35
 
36
- 只用一个主题时可以直接引用 `@kodax-ai/botui/themes/solids`。也可以不经 npm,按版本标签引用本仓库:`npm install github:icetomoyo/BotUI#v0.1.0`。完整的选项和方法见 [themes/solids/README.md](themes/solids/README.md)。
36
+ 只用一个主题时可以直接引用 `@kodax-ai/botui/themes/solids`。也可以不经 npm,按版本标签引用本仓库:`npm install github:icetomoyo/BotUI#v0.1.1`。完整的选项和方法见 [themes/solids/README.md](themes/solids/README.md)。
37
37
 
38
38
  ## 许可
39
39
 
@@ -90,11 +90,11 @@ npm run release final # 0.2.0-rc.N -> 0.2.0
90
90
  npm run release patch # 0.2.0 -> 0.2.1(不走预发布的小修)
91
91
  ```
92
92
 
93
- 每一行都会:跑检查 → 打包审计 → 问一次 y/N → 提交 `Release v<版本>` 并打标签 → 发布 → 推送。任何一行后面加 `--dry-run` 就是演练,不提交、不打标签,也不真发布。alpha / beta / rc 分别发到 npm 的 `alpha` / `beta` / `rc` 标签,只有正式版发到 `latest`,所以 `npm install @kodax-ai/botui` 永远拿到正式版,想试 beta 的人用 `npm install @kodax-ai/botui@beta`。新版本必须比当前版本高,写反了会直接报错。
93
+ 每一行都会:跑检查 → 打包审计 → 提交 `Release v<版本>` 并打标签 → 发布 → 推送。任何一行后面加 `--dry-run` 就是演练,不提交、不打标签,也不真发布。alpha / beta / rc 分别发到 npm 的 `alpha` / `beta` / `rc` 标签,只有正式版发到 `latest`,所以 `npm install @kodax-ai/botui` 永远拿到正式版,想试 beta 的人用 `npm install @kodax-ai/botui@beta`。新版本必须比当前版本高,写反了会直接报错。
94
94
 
95
95
  也支持 `minor`、`major`、`prerelease` 和直接写版本号(如 `npm run release 0.3.0-beta.0`)。
96
96
 
97
- 不带参数时,HEAD 还没打标签的话脚本会自动打上 `v<版本>`。参数写错(比如 `--dryrun`)时,用 `node` 运行会直接报错;用 `npm run` 运行时 npm 会把它吞掉,脚本就当成真发布,但真发布前一定会显示 `REAL PUBLISH` 并要求确认。
97
+ 不带参数时,HEAD 还没打标签的话脚本会自动打上 `v<版本>`。参数写错(比如 `--dryrun`)时,用 `node` 运行会直接报错;用 `npm run` 运行时 npm 会把它吞掉,脚本就当成真发布。和 KodaX 一样,真发布不会再问确认,没把握时先加 `--dry-run` 演练。
98
98
 
99
99
  `release.mjs` 依次做这些事,任何一步失败都会停下:
100
100
 
@@ -102,11 +102,11 @@ npm run release patch # 0.2.0 -> 0.2.1(不走预发布的小
102
102
  2. 检查 git:已跟踪的文件没有未提交的改动(与包无关的未跟踪文件不影响);目标版本的标签状态正确。演练和 `--pack-only` 只给警告。
103
103
  3. 用无头 Chrome 跑 `tests/check.html`,必须显示 `PASS`(单独跑:`npm run check`)。
104
104
  4. 按目标版本打包到 `.release/`,然后审计:必需文件都在;测试、草图、截图之类的开发文件没有混进去;进包的每个文件都已提交且未修改;每个相对 import 都能在包里找到;最后把包按使用方的方式装进临时目录,在 Node 里按包名 import 一遍。
105
- 5. 问一次 `y/N`。确认后才改版本号、提交 `Release v<版本>`、打标签。前面所有可能失败的步骤都已经跑完,所以审计失败不会留下半截的版本提交。
105
+ 5. 改版本号、提交 `Release v<版本>`、打标签。前面所有可能失败的步骤都已经跑完,所以审计失败不会留下半截的版本提交。
106
106
  6. `npm publish` 到 `registry.npmjs.org`,不受本机 `.npmrc` 镜像设置影响。dist-tag 按上面的表自动决定,预发布版本不会覆盖 `latest`。
107
107
  7. `git push origin <分支> v<版本>`。
108
108
 
109
- 其他参数:`--otp=123456`(npm 两步验证)、`--yes`(不问确认)、`--no-push`(不推送)、`--tag=next`(指定 dist-tag)、`--skip-check`(跳过 Chrome 自检)。
109
+ 其他参数:`--otp=123456`(npm 两步验证)、`--no-push`(不推送)、`--tag=next`(指定 dist-tag)、`--skip-check`(跳过 Chrome 自检)。
110
110
 
111
111
  如果发布这一步失败了(常见原因是 OTP 过期),版本提交和标签已经留在本地,修好之后不带版本参数再跑一次就行:`npm run release --otp=123456`。
112
112
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kodax-ai/botui",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "private": false,
5
5
  "description": "Animated Bot avatars for AI products. One core, one renderer per theme, no dependencies.",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -95,6 +95,7 @@ bot.setState('thinking');
95
95
  | `symbols.js` | `signals: 'morph'` 时身体变成的符号 |
96
96
  | `playground.html` | 试玩页 |
97
97
  | `sheet.html`、`filmstrip.html` | 全家福和连续帧,核对造型和动作用 |
98
+ | `pose.html` | 核对默认姿态:可切换侧转、俯仰和是否跟随鼠标 |
98
99
 
99
100
  ## 加一个立体
100
101
 
@@ -110,7 +110,7 @@ export class SolidAvatar {
110
110
  this.track = options.track ?? true; this.static = !!options.static; this.playing = options.playing ?? true; this.maxFrameRate = options.maxFrameRate ?? 60;
111
111
  this.visible = true; this.settled = false;
112
112
  this.rng = random(hash(this.identity)); this.t = this.rng() * 10; this.since = 0; this.dt = 0; this.beat = 0;
113
- this.p = {yaw: 0.2, pitch: -0.26, roll: 0, sy: 1, lift: 0, scale: 1, sat: 1, open: 1, blush: 0};
113
+ this.p = {yaw: 0.3, pitch: -0.26, roll: 0, sy: 1, lift: 0, scale: 1, sat: 1, open: 1, blush: 0};
114
114
  this.vel = {sy: 0, lift: 0, scale: 0, roll: 0};
115
115
  this.omega = 0; this.spun = 0; this.dizzy = 0; this.tug = 0; this.phase = 0;
116
116
  this.aim = {x: 0, y: 0}; this.gazeAt = {x: 0, y: 0}; this.focus = null; this.fixed = null; this.stray = {x: 0, y: 0}; this.strayIn = 0;
@@ -10,13 +10,17 @@
10
10
 
11
11
  import {TAU, smooth, bump} from '../../core/core.js';
12
12
 
13
- export const REST = {yaw: 0.2, pitch: -0.26, roll: 0, sy: 1, lift: 0, scale: 1, gx: 0, gy: 0, expr: 'neutral', sat: 1, blush: 0, rate: 9, stiff: 260, orbit: 0, mark: null, ring: null, bars: false, still: false};
13
+ // The resting turn and tilt every pose is built on. A page may change it to try other angles.
14
+ export const BASE = {yaw: 0.3, pitch: -0.26};
15
+ export const REST = {get yaw() { return BASE.yaw; }, get pitch() { return BASE.pitch; }, roll: 0, sy: 1, lift: 0, scale: 1, gx: 0, gy: 0, expr: 'neutral', sat: 1, blush: 0, rate: 9, stiff: 260, orbit: 0, mark: null, ring: null, bars: false, still: false};
14
16
 
15
17
  const sin = Math.sin;
16
18
  const beat = (t, f) => Math.abs(sin(t * f));
17
19
  const talk = t => Math.abs(sin(t * 4.2) * Math.cos(t * 1.7));
18
20
  const float = t => 2 * sin(t * 1.7);
19
- const facing = (l, yaw = 0.2, pitch = -0.26) => ({yaw: yaw + l.x * 1.05, pitch: pitch - l.y * 0.7, gx: l.x * 0.16, gy: l.y * 0.16});
21
+ // Positive yaw turns the face to the viewer's left and negative pitch tilts it up, so a look to the right or down subtracts yaw and adds pitch.
22
+ // The rest pose already tilts up, so looking up gets less travel than looking down.
23
+ const facing = (l, yaw = BASE.yaw, pitch = BASE.pitch) => ({yaw: yaw - l.x * 0.9, pitch: pitch + l.y * (l.y < 0 ? 0.4 : 0.6), gx: l.x * 0.16, gy: l.y * 0.16});
20
24
  const SHOW = ['nod', 'spin', 'wink', 'jump', 'wobble', 'tilt', 'flip', 'dance', 'glance', 'stretch'];
21
25
  const PLAY = ['wink', 'wobble', 'spin', 'dance'];
22
26
 
@@ -28,11 +32,11 @@ export const POSES = {
28
32
  streaming: {pose: (a, t) => ({yaw: 0.25 + 0.3 * sin(t * 1.3), sy: 0.8 + 0.42 * talk(t), lift: float(t), rate: 20, stiff: 700, mark: 'dots'})},
29
33
  searching: {pose: (a, t) => { if (a.every(1.1)) a.pulse(); return {yaw: 0.9 * sin(t * 1.6), pitch: -0.2 + 0.12 * sin(t * 0.9), gx: 0.14 * sin(t * 1.6), gy: 0.05 * sin(t * 2.7), lift: float(t), expr: 'inspecting', mark: 'search', rate: 7}; }},
30
34
  reading: {pose: (a, t) => { const u = (t * 0.9) % 1, line = Math.floor(t * 0.9) % 3; return {yaw: 0.5 * (u - 0.5), pitch: -0.44 + 0.06 * line, gx: 0.2 * (u - 0.5), gy: 0.1 + 0.04 * line, lift: float(t) * 0.5, rate: 10}; }},
31
- working: {pose: (a, t) => ({yaw: 0.2 + 0.14 * sin(t * 2.2), pitch: -0.5, roll: 0.07 * sin(t * 7), lift: -2.5 * beat(t, 7), gx: 0.14 * sin(t * 3.1), gy: 0.12, expr: 'focus'})},
32
- coding: {pose: (a, t) => ({yaw: 0.2 + 0.1 * sin(t * 1.9), pitch: -0.45, lift: -1.8 * beat(t, 9), sy: 1 - 0.04 * beat(t, 9), gx: 0.1 * sin(t * 2.3), gy: 0.12, expr: 'focus', mark: 'code'})},
35
+ working: {pose: (a, t) => ({yaw: BASE.yaw + 0.14 * sin(t * 2.2), pitch: -0.5, roll: 0.07 * sin(t * 7), lift: -2.5 * beat(t, 7), gx: 0.14 * sin(t * 3.1), gy: 0.12, expr: 'focus'})},
36
+ coding: {pose: (a, t) => ({yaw: BASE.yaw + 0.1 * sin(t * 1.9), pitch: -0.45, lift: -1.8 * beat(t, 9), sy: 1 - 0.04 * beat(t, 9), gx: 0.1 * sin(t * 2.3), gy: 0.12, expr: 'focus', mark: 'code'})},
33
37
  running: {pose: (a, t) => { if (a.every(0.26)) a.emit('dust'); return {yaw: 0.55, pitch: -0.2, roll: 0.14 + 0.05 * sin(t * 14), lift: -7 * beat(t, 7), sy: 1 + 0.08 * sin(t * 14), gx: 0.12, expr: 'focus', rate: 12}; }},
34
- computing: {pose: (a, t) => ({yaw: 0.2 + 0.25 * sin(t * 2), pitch: -0.05, roll: 0.05 * sin(t * 3.3), gy: -0.16, gx: 0.1 * sin(t * 4), lift: float(t), expr: 'focus', orbit: 2.3})},
35
- controlling: {pose: (a, t) => { if (a.every(0.77)) a.nudge(); const k = Math.floor(t * 1.3), x = sin(k * 12.9898) * 0.9, y = sin(k * 78.233) * 0.6; return {yaw: 0.2 + x * 0.7, pitch: -0.26 - y * 0.4, gx: x * 0.15, gy: y * 0.12, lift: float(t), expr: 'focus', mark: 'cursor', rate: 14}; }},
38
+ computing: {pose: (a, t) => ({yaw: BASE.yaw + 0.25 * sin(t * 2), pitch: -0.05, roll: 0.05 * sin(t * 3.3), gy: -0.16, gx: 0.1 * sin(t * 4), lift: float(t), expr: 'focus', orbit: 2.3})},
39
+ controlling: {pose: (a, t) => { if (a.every(0.77)) a.nudge(); const k = Math.floor(t * 1.3), x = sin(k * 12.9898) * 0.9, y = sin(k * 78.233) * 0.6; return {yaw: BASE.yaw + x * 0.7, pitch: -0.26 - y * 0.4, gx: x * 0.15, gy: y * 0.12, lift: float(t), expr: 'focus', mark: 'cursor', rate: 14}; }},
36
40
  asking: {enter: a => a.play('tilt'), pose: (a, t, l) => { if (a.every(3.2)) a.hop(70); return {...facing(l, 0.1, -0.3), roll: 0.2 * Math.sign(sin(t * 1.1)), lift: float(t), expr: 'wide', mark: 'ask'}; }},
37
41
  blocked: {pose: () => ({yaw: 0.3, pitch: -0.22, sy: 0.55, lift: 12, expr: 'closed', sat: 0.25, rate: 5, stiff: 120})},
38
42
  finished: {enter: a => { a.play('spin'); a.hop(150); a.burst('spark', 8); }, pose: (a, t) => ({yaw: 0.3, pitch: -0.3, lift: float(t), expr: 'happy'})},
@@ -43,7 +47,7 @@ export const POSES = {
43
47
  // ---- moods ----
44
48
  happy: {pose: (a, t, l) => ({...facing(l), lift: -3 * beat(t, 3.2), roll: 0.08 * sin(t * 3.2), expr: 'happy', blush: 0.5})},
45
49
  excited: {enter: a => a.hop(120), pose: (a, t, l) => { if (a.every(1.6)) a.burst('spark', 4); return {...facing(l, 0.2, -0.32), lift: -7 * beat(t, 6), sy: 1 + 0.07 * sin(t * 12), scale: 1.06, expr: 'sparkle', blush: 0.4}; }},
46
- laughing: {pose: (a, t) => ({yaw: 0.2, pitch: -0.5, lift: -2.5 * beat(t, 11), sy: 1 + 0.07 * sin(t * 22), roll: 0.06 * sin(t * 5), expr: 'happy', blush: 0.6, stiff: 700, rate: 14})},
50
+ laughing: {pose: (a, t) => ({yaw: BASE.yaw, pitch: -0.5, lift: -2.5 * beat(t, 11), sy: 1 + 0.07 * sin(t * 22), roll: 0.06 * sin(t * 5), expr: 'happy', blush: 0.6, stiff: 700, rate: 14})},
47
51
  proud: {pose: (a, t) => { if (a.every(2.2)) a.burst('spark', 3); return {yaw: 0.35, pitch: -0.55, sy: 1.07, scale: 1.06, lift: float(t) * 0.5, expr: 'calm', blush: 0.3}; }},
48
52
  curious: {pose: (a, t, l) => ({...facing(l, 0.1, -0.3), roll: 0.22 * Math.sign(sin(t * 0.8)), scale: 1.07, lift: float(t), expr: 'inspecting'})},
49
53
  playful: {pose: (a, t, l) => { if (a.every(2.4)) a.play(PLAY[a.beat++ % PLAY.length]); return {...facing(l), roll: 0.16 * sin(t * 2.6), lift: -4 * beat(t, 2.6), expr: 'happy'}; }},
@@ -61,24 +65,24 @@ export const POSES = {
61
65
  loving: {pose: (a, t, l) => { if (a.every(0.9)) a.emit('heart'); return {...facing(l, 0.15, -0.3), roll: 0.1 * sin(t * 2), lift: -2 * beat(t, 2), scale: 1.04, expr: 'love', blush: 0.8}; }},
62
66
 
63
67
  // ---- signals: what is going on, shown with something around the body ----
64
- orbit: {pose: (a, t) => ({yaw: 0.2 + 0.3 * sin(t * 1.3), gx: 0.14 * Math.cos(t * 2.6), gy: 0.08 * sin(t * 2.6), lift: float(t), orbit: 1.6})},
68
+ orbit: {pose: (a, t) => ({yaw: BASE.yaw + 0.3 * sin(t * 1.3), gx: 0.14 * Math.cos(t * 2.6), gy: 0.08 * sin(t * 2.6), lift: float(t), orbit: 1.6})},
65
69
  radar: {pose: (a, t) => { if (a.every(0.9)) a.pulse(); return {yaw: 1.0 * sin(t * 1.1), pitch: -0.3, lift: float(t), expr: 'wide', rate: 8}; }},
66
70
  progress: {pose: (a, t, l) => ({...facing(l, 0.2, -0.3), lift: float(t) * 0.5, expr: 'focus', ring: 'progress'})},
67
- loading: {pose: (a, t) => ({yaw: 0.2 + 0.15 * sin(t * 2), lift: float(t), gy: -0.08, ring: 'spin'})},
68
- spawning: {enter: a => { a.p.scale = 0.15; a.vel.scale = 0; for (let i = 0; i < 8; i++) a.emit('in'); }, pose: (a, t) => { if (a.every(0.2) && a.since < 2.4) a.emit('in'); return {scale: Math.min(1, 0.3 + a.since * 0.32), yaw: 0.2 + Math.max(0, 2.4 - a.since) * 1.2, lift: float(t), expr: a.since < 1.6 ? 'closed' : 'wide', rate: 12}; }},
69
- dictating: {pose: (a, t) => ({yaw: 0.2 + 0.2 * sin(t * 1.1), sy: 0.92 + 0.2 * talk(t), lift: float(t), expr: 'calm', bars: true, rate: 20, stiff: 700})},
71
+ loading: {pose: (a, t) => ({yaw: BASE.yaw + 0.15 * sin(t * 2), lift: float(t), gy: -0.08, ring: 'spin'})},
72
+ spawning: {enter: a => { a.p.scale = 0.15; a.vel.scale = 0; for (let i = 0; i < 8; i++) a.emit('in'); }, pose: (a, t) => { if (a.every(0.2) && a.since < 2.4) a.emit('in'); return {scale: Math.min(1, 0.3 + a.since * 0.32), yaw: BASE.yaw + Math.max(0, 2.4 - a.since) * 1.2, lift: float(t), expr: a.since < 1.6 ? 'closed' : 'wide', rate: 12}; }},
73
+ dictating: {pose: (a, t) => ({yaw: BASE.yaw + 0.2 * sin(t * 1.1), sy: 0.92 + 0.2 * talk(t), lift: float(t), expr: 'calm', bars: true, rate: 20, stiff: 700})},
70
74
  sending: {pose: (a, t) => { if (a.every(0.2)) a.emit('out'); return {yaw: 0.45, pitch: -0.45, lift: float(t) - 2, gx: 0.1, gy: -0.15, expr: 'focus'}; }},
71
- receiving: {pose: (a, t) => { if (a.every(0.13)) a.emit('in'); return {yaw: 0.2 + 0.1 * sin(t * 2), pitch: -0.35, scale: 1 + 0.03 * sin(t * 9), lift: float(t), expr: 'wide'}; }},
72
- uploading: {pose: (a, t) => { if (a.every(0.28)) a.emit('up'); return {yaw: 0.2, pitch: -0.5, gy: -0.18, sy: 1.05, lift: -2 + float(t), mark: 'up'}; }},
75
+ receiving: {pose: (a, t) => { if (a.every(0.13)) a.emit('in'); return {yaw: BASE.yaw + 0.1 * sin(t * 2), pitch: -0.35, scale: 1 + 0.03 * sin(t * 9), lift: float(t), expr: 'wide'}; }},
76
+ uploading: {pose: (a, t) => { if (a.every(0.28)) a.emit('up'); return {yaw: BASE.yaw, pitch: -0.5, gy: -0.18, sy: 1.05, lift: -2 + float(t), mark: 'up'}; }},
73
77
  writing: {pose: (a, t) => { const u = (t * 0.7) % 1; return {yaw: -0.15 + 0.4 * u, pitch: -0.5, gx: 0.18 * (u - 0.5), gy: 0.15, lift: -1.2 * beat(t, 8), expr: 'focus', mark: 'pen'}; }},
74
78
  alerting: {enter: a => a.play('startle'), pose: (a, t, l) => { if (a.every(1.3)) a.play('startle'); return {...facing(l, 0.2, -0.3), scale: 1.05, lift: float(t), expr: 'wide', mark: 'bang'}; }},
75
79
  bouncing: {enter: a => a.play('jump'), pose: (a, t, l) => { if (a.every(0.85)) a.play('jump'); return {...facing(l), expr: 'happy'}; }},
76
80
  'powering-down': {pose: () => ({yaw: 0.3, pitch: 0.1, sy: 0.7, scale: 0.82, lift: 14, expr: 'closed', sat: 0.12, rate: 2, stiff: 40, still: true})},
77
81
 
78
82
  // ---- product moments ----
79
- humming: {pose: (a, t) => { if (a.every(0.6)) a.emit('note'); return {yaw: 0.2 + 0.25 * sin(t * 1.5), roll: 0.14 * sin(t * 3), lift: -2 * beat(t, 3), expr: 'calm', blush: 0.3}; }},
83
+ humming: {pose: (a, t) => { if (a.every(0.6)) a.emit('note'); return {yaw: BASE.yaw + 0.25 * sin(t * 1.5), roll: 0.14 * sin(t * 3), lift: -2 * beat(t, 3), expr: 'calm', blush: 0.3}; }},
80
84
  notifying: {enter: a => a.hop(110), pose: (a, t, l) => { if (a.every(2)) a.hop(110); return {...facing(l), scale: 1.03, lift: float(t), expr: 'wide', mark: 'badge'}; }},
81
- dragging: {pose: (a, t) => ({yaw: 0.2 + 0.3 * sin(t * 2.3), pitch: -0.1, roll: 0.25 * sin(t * 3.1), sy: 1.16, lift: -8, expr: 'surprised', stiff: 120})},
85
+ dragging: {pose: (a, t) => ({yaw: BASE.yaw + 0.3 * sin(t * 2.3), pitch: -0.1, roll: 0.25 * sin(t * 3.1), sy: 1.16, lift: -8, expr: 'surprised', stiff: 120})},
82
86
  greeting: {enter: a => { a.hop(120); a.play('wave'); }, pose: (a, t, l) => { if (a.every(2.6)) a.play('wave'); return {...facing(l, 0.1, -0.3), lift: float(t), scale: 1.04, expr: 'happy'}; }},
83
87
 
84
88
  // ---- showing it off ----