@lobehub/ui 6.17.0 → 6.18.0

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.
Files changed (68) hide show
  1. package/es/AgentAvatar/AgentAvatar.mjs +89 -139
  2. package/es/AgentAvatar/AgentAvatar.mjs.map +1 -1
  3. package/es/AgentAvatar/AgentAvatarPicker.d.mts +3 -0
  4. package/es/AgentAvatar/AgentAvatarPicker.mjs +109 -0
  5. package/es/AgentAvatar/AgentAvatarPicker.mjs.map +1 -0
  6. package/es/AgentAvatar/createAgentAvatarTab.d.mts +4 -0
  7. package/es/AgentAvatar/createAgentAvatarTab.mjs +46 -0
  8. package/es/AgentAvatar/createAgentAvatarTab.mjs.map +1 -0
  9. package/es/AgentAvatar/eyes.mjs +83 -0
  10. package/es/AgentAvatar/eyes.mjs.map +1 -0
  11. package/es/AgentAvatar/index.d.mts +5 -2
  12. package/es/AgentAvatar/index.mjs +4 -1
  13. package/es/AgentAvatar/liveLoop.mjs +97 -0
  14. package/es/AgentAvatar/liveLoop.mjs.map +1 -0
  15. package/es/AgentAvatar/look.mjs +193 -0
  16. package/es/AgentAvatar/look.mjs.map +1 -0
  17. package/es/AgentAvatar/painter.mjs +111 -0
  18. package/es/AgentAvatar/painter.mjs.map +1 -0
  19. package/es/AgentAvatar/pickerStyle.mjs +68 -0
  20. package/es/AgentAvatar/pickerStyle.mjs.map +1 -0
  21. package/es/AgentAvatar/scene.mjs +90 -0
  22. package/es/AgentAvatar/scene.mjs.map +1 -0
  23. package/es/AgentAvatar/shapes.mjs +215 -180
  24. package/es/AgentAvatar/shapes.mjs.map +1 -1
  25. package/es/AgentAvatar/stable.mjs +11 -1
  26. package/es/AgentAvatar/stable.mjs.map +1 -1
  27. package/es/AgentAvatar/still.mjs +39 -0
  28. package/es/AgentAvatar/still.mjs.map +1 -0
  29. package/es/AgentAvatar/stills.generated.mjs +126 -0
  30. package/es/AgentAvatar/stills.generated.mjs.map +1 -0
  31. package/es/AgentAvatar/style.mjs +13 -146
  32. package/es/AgentAvatar/style.mjs.map +1 -1
  33. package/es/AgentAvatar/type.d.mts +64 -14
  34. package/es/AgentAvatar/useLiveAvatar.mjs +91 -0
  35. package/es/AgentAvatar/useLiveAvatar.mjs.map +1 -0
  36. package/es/AgentAvatar/utils.d.mts +2 -2
  37. package/es/AgentAvatar/utils.mjs +49 -45
  38. package/es/AgentAvatar/utils.mjs.map +1 -1
  39. package/es/AgentAvatar/value.d.mts +5 -0
  40. package/es/AgentAvatar/value.mjs +18 -0
  41. package/es/AgentAvatar/value.mjs.map +1 -0
  42. package/es/AutoComplete/style.d.mts +1 -1
  43. package/es/Avatar/AvatarGroup/index.mjs +1 -1
  44. package/es/Avatar/AvatarGroup/index.mjs.map +1 -1
  45. package/es/Avatar/type.d.mts +1 -1
  46. package/es/EmojiPicker/EmojiPicker.mjs +27 -19
  47. package/es/EmojiPicker/EmojiPicker.mjs.map +1 -1
  48. package/es/EmojiPicker/index.d.mts +2 -2
  49. package/es/EmojiPicker/type.d.mts +24 -1
  50. package/es/chat/ChatItem/type.d.mts +2 -2
  51. package/es/css/AgentAvatar.css +686 -199
  52. package/es/i18n/resources/en/agentAvatar.d.mts +39 -0
  53. package/es/i18n/resources/en/agentAvatar.mjs +42 -0
  54. package/es/i18n/resources/en/agentAvatar.mjs.map +1 -0
  55. package/es/i18n/resources/en/index.d.mts +19 -18
  56. package/es/i18n/resources/en/index.mjs +3 -1
  57. package/es/i18n/resources/en/index.mjs.map +1 -1
  58. package/es/i18n/resources/zhCn/agentAvatar.d.mts +39 -0
  59. package/es/i18n/resources/zhCn/agentAvatar.mjs +42 -0
  60. package/es/i18n/resources/zhCn/agentAvatar.mjs.map +1 -0
  61. package/es/i18n/resources/zhCn/index.d.mts +19 -18
  62. package/es/i18n/resources/zhCn/index.mjs +3 -1
  63. package/es/i18n/resources/zhCn/index.mjs.map +1 -1
  64. package/es/i18n/types.d.mts +18 -17
  65. package/es/index.d.mts +48 -45
  66. package/es/index.mjs +6 -3
  67. package/es/style.css +44 -295
  68. package/package.json +3 -1
@@ -1,4 +1,7 @@
1
1
  import AgentAvatar from "./AgentAvatar.mjs";
2
- import { AgentAvatarClassNames, AgentAvatarColor, AgentAvatarProps, AgentAvatarShape, AgentAvatarState, AgentAvatarStyles } from "./type.mjs";
2
+ import AgentAvatarPicker from "./AgentAvatarPicker.mjs";
3
+ import { createAgentAvatarTab } from "./createAgentAvatarTab.mjs";
4
+ import { AgentAvatarClassNames, AgentAvatarColor, AgentAvatarPickerProps, AgentAvatarPickerTexts, AgentAvatarProps, AgentAvatarShape, AgentAvatarState, AgentAvatarStyles, AgentAvatarValue, CreateAgentAvatarTabOptions } from "./type.mjs";
3
5
  import { AGENT_AVATAR_COLORS, AGENT_AVATAR_SHAPES, AGENT_AVATAR_STATES, getAgentAvatarTraits } from "./utils.mjs";
4
- export { AGENT_AVATAR_COLORS, AGENT_AVATAR_SHAPES, AGENT_AVATAR_STATES, type AgentAvatarClassNames, type AgentAvatarColor, type AgentAvatarProps, type AgentAvatarShape, type AgentAvatarState, type AgentAvatarStyles, AgentAvatar as default, getAgentAvatarTraits };
6
+ import { parseAgentAvatar, stringifyAgentAvatar } from "./value.mjs";
7
+ export { AGENT_AVATAR_COLORS, AGENT_AVATAR_SHAPES, AGENT_AVATAR_STATES, type AgentAvatarClassNames, type AgentAvatarColor, AgentAvatarPicker, type AgentAvatarPickerProps, type AgentAvatarPickerTexts, type AgentAvatarProps, type AgentAvatarShape, type AgentAvatarState, type AgentAvatarStyles, type AgentAvatarValue, type CreateAgentAvatarTabOptions, createAgentAvatarTab, AgentAvatar as default, getAgentAvatarTraits, parseAgentAvatar, stringifyAgentAvatar };
@@ -1,3 +1,6 @@
1
1
  import AgentAvatar from "./AgentAvatar.mjs";
2
+ import AgentAvatarPicker from "./AgentAvatarPicker.mjs";
3
+ import { createAgentAvatarTab } from "./createAgentAvatarTab.mjs";
2
4
  import { AGENT_AVATAR_COLORS, AGENT_AVATAR_SHAPES, AGENT_AVATAR_STATES, getAgentAvatarTraits } from "./utils.mjs";
3
- export { AGENT_AVATAR_COLORS, AGENT_AVATAR_SHAPES, AGENT_AVATAR_STATES, AgentAvatar as default, getAgentAvatarTraits };
5
+ import { parseAgentAvatar, stringifyAgentAvatar } from "./value.mjs";
6
+ export { AGENT_AVATAR_COLORS, AGENT_AVATAR_SHAPES, AGENT_AVATAR_STATES, AgentAvatarPicker, createAgentAvatarTab, AgentAvatar as default, getAgentAvatarTraits, parseAgentAvatar, stringifyAgentAvatar };
@@ -0,0 +1,97 @@
1
+ import { avatarFrame, createAnimator, pointerGaze } from "open-bot-avatar";
2
+ import { requestFrame, subscribeFrames, trackPointer } from "open-bot-avatar/dom";
3
+ import { REST_YAW, blendLooks } from "./look.mjs";
4
+ import { createPainter } from "./painter.mjs";
5
+ import { buildAgentAvatarScene } from "./scene.mjs";
6
+ import { SHAPE_GEOMETRY, getShapeDefinition } from "./shapes.mjs";
7
+ // src/AgentAvatar/liveLoop.ts
8
+ /**
9
+ * The animated avatar: engine frame loop plus painter. Loaded on demand, so still avatars never
10
+ * pay for the engine.
11
+ */
12
+ /** Avatars below this width redraw at 30 fps: the difference does not show and lists hold many. */
13
+ const SMALL_LIVE_SIZE = 128;
14
+ const SMALL_FRAME_SECONDS = 1 / 30 - .004;
15
+ const VIEW_MARGIN = "100px";
16
+ /** Time constant of the ease between two states, seconds. */
17
+ const STATE_EASE = .11;
18
+ const warmed = /* @__PURE__ */ new Set();
19
+ const isWarm = (shape) => warmed.has(shape);
20
+ /** Build a shape's volume ahead of its first frame; the engine caches it. */
21
+ const warmShape = (shape) => {
22
+ if (warmed.has(shape)) return;
23
+ avatarFrame(getShapeDefinition(shape), {
24
+ reducedMotion: true,
25
+ view: {
26
+ pitch: 0,
27
+ yaw: REST_YAW
28
+ }
29
+ });
30
+ warmed.add(shape);
31
+ };
32
+ /** Paint the first frame synchronously and keep animating until the returned stop is called. */
33
+ const runLiveAvatar = (layers, read) => {
34
+ const svg = layers.defs.ownerSVGElement;
35
+ const painter = createPainter(layers, read().idPrefix);
36
+ const animator = createAnimator();
37
+ const weights = { [read().state]: 1 };
38
+ let box = null;
39
+ let visible = true;
40
+ let last = performance.now();
41
+ const draw = (pointer) => {
42
+ const current = read();
43
+ const now = performance.now();
44
+ const k = 1 - Math.exp(-Math.min(.1, (now - last) / 1e3) / STATE_EASE);
45
+ last = now;
46
+ weights[current.state] ??= 0;
47
+ for (const state of Object.keys(weights)) {
48
+ const goal = state === current.state ? 1 : 0;
49
+ const next = weights[state] + (goal - weights[state]) * k;
50
+ if (goal === 0 && next < .004) delete weights[state];
51
+ else weights[state] = goal === 1 && next > .996 ? 1 : next;
52
+ }
53
+ const { y: eyeY } = SHAPE_GEOMETRY[current.shape].eyes;
54
+ const target = current.followPointer && pointer && box && box.width > 0 ? pointerGaze(pointer, box, {
55
+ x: .5,
56
+ y: eyeY / 100
57
+ }) : null;
58
+ const step = animator.step({
59
+ now,
60
+ reducedMotion: false,
61
+ state: "idle",
62
+ target
63
+ });
64
+ const time = now / 1e3 + current.phase;
65
+ painter.paint(buildAgentAvatarScene(current.shape, {
66
+ gaze: step.gaze,
67
+ look: blendLooks(weights, time),
68
+ time
69
+ }));
70
+ };
71
+ const observer = typeof IntersectionObserver === "undefined" ? null : new IntersectionObserver((entries) => {
72
+ const next = entries.at(-1).isIntersecting;
73
+ if (next === visible) return;
74
+ visible = next;
75
+ if (visible) requestFrame();
76
+ }, { rootMargin: VIEW_MARGIN });
77
+ observer?.observe(svg);
78
+ draw(null);
79
+ const unsubscribe = subscribeFrames({
80
+ draw: (_time, pointer) => {
81
+ if (!visible) return false;
82
+ draw(pointer);
83
+ return box && box.width > 0 && box.width < SMALL_LIVE_SIZE ? SMALL_FRAME_SECONDS : true;
84
+ },
85
+ measure: () => {
86
+ box = visible ? svg.getBoundingClientRect() : null;
87
+ }
88
+ });
89
+ return () => {
90
+ unsubscribe();
91
+ observer?.disconnect();
92
+ painter.destroy();
93
+ };
94
+ };
95
+ export { isWarm, requestFrame, runLiveAvatar, trackPointer, warmShape };
96
+
97
+ //# sourceMappingURL=liveLoop.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"liveLoop.mjs","names":[],"sources":["../../src/AgentAvatar/liveLoop.ts"],"sourcesContent":["/**\n * The animated avatar: engine frame loop plus painter. Loaded on demand, so still avatars never\n * pay for the engine.\n */\nimport { avatarFrame, createAnimator, pointerGaze } from 'open-bot-avatar';\nimport { requestFrame, subscribeFrames, trackPointer } from 'open-bot-avatar/dom';\n\nimport { blendLooks, REST_YAW } from './look';\nimport { type AgentAvatarLayers, createPainter } from './painter';\nimport { buildAgentAvatarScene } from './scene';\nimport { getShapeDefinition, SHAPE_GEOMETRY } from './shapes';\nimport type { AgentAvatarShape, AgentAvatarState } from './type';\n\nexport { requestFrame, trackPointer };\n\n/** Avatars below this width redraw at 30 fps: the difference does not show and lists hold many. */\nconst SMALL_LIVE_SIZE = 128;\nconst SMALL_FRAME_SECONDS = 1 / 30 - 0.004;\nconst VIEW_MARGIN = '100px';\n/** Time constant of the ease between two states, seconds. */\nconst STATE_EASE = 0.11;\n\nexport interface LiveAvatarState {\n followPointer: boolean;\n idPrefix: string;\n /** Seconds added to the clock, so avatars of one shape do not move in sync. */\n phase: number;\n shape: AgentAvatarShape;\n state: AgentAvatarState;\n}\n\nconst warmed = new Set<AgentAvatarShape>();\n\nexport const isWarm = (shape: AgentAvatarShape) => warmed.has(shape);\n\n/** Build a shape's volume ahead of its first frame; the engine caches it. */\nexport const warmShape = (shape: AgentAvatarShape) => {\n if (warmed.has(shape)) return;\n avatarFrame(getShapeDefinition(shape), {\n reducedMotion: true,\n view: { pitch: 0, yaw: REST_YAW },\n });\n warmed.add(shape);\n};\n\n/** Paint the first frame synchronously and keep animating until the returned stop is called. */\nexport const runLiveAvatar = (layers: AgentAvatarLayers, read: () => LiveAvatarState) => {\n const svg = layers.defs.ownerSVGElement!;\n const painter = createPainter(layers, read().idPrefix);\n const animator = createAnimator();\n const weights: Partial<Record<AgentAvatarState, number>> = { [read().state]: 1 };\n let box: DOMRect | null = null;\n let visible = true;\n let last = performance.now();\n\n const draw = (pointer: { x: number; y: number } | null) => {\n const current = read();\n const now = performance.now();\n const k = 1 - Math.exp(-Math.min(0.1, (now - last) / 1000) / STATE_EASE);\n last = now;\n weights[current.state] ??= 0;\n for (const state of Object.keys(weights) as AgentAvatarState[]) {\n const goal = state === current.state ? 1 : 0;\n const next = weights[state]! + (goal - weights[state]!) * k;\n if (goal === 0 && next < 0.004) delete weights[state];\n else weights[state] = goal === 1 && next > 0.996 ? 1 : next;\n }\n\n const { y: eyeY } = SHAPE_GEOMETRY[current.shape].eyes;\n const target =\n current.followPointer && pointer && box && box.width > 0\n ? pointerGaze(pointer, box, { x: 0.5, y: eyeY / 100 })\n : null;\n const step = animator.step({ now, reducedMotion: false, state: 'idle', target });\n const time = now / 1000 + current.phase;\n painter.paint(\n buildAgentAvatarScene(current.shape, {\n gaze: step.gaze,\n look: blendLooks(weights, time),\n time,\n }),\n );\n };\n\n const observer =\n typeof IntersectionObserver === 'undefined'\n ? null\n : new IntersectionObserver(\n (entries) => {\n const next = entries.at(-1)!.isIntersecting;\n if (next === visible) return;\n visible = next;\n if (visible) requestFrame();\n },\n { rootMargin: VIEW_MARGIN },\n );\n observer?.observe(svg);\n\n // Paint before the browser does, so the still pose hands over without an empty frame.\n draw(null);\n const unsubscribe = subscribeFrames({\n draw: (_time, pointer) => {\n if (!visible) return false;\n draw(pointer);\n return box && box.width > 0 && box.width < SMALL_LIVE_SIZE ? SMALL_FRAME_SECONDS : true;\n },\n measure: () => {\n box = visible ? svg.getBoundingClientRect() : null;\n },\n });\n\n return () => {\n unsubscribe();\n observer?.disconnect();\n painter.destroy();\n };\n};\n"],"mappings":";;;;;;;;;;;;AAgBA,MAAM,kBAAkB;AACxB,MAAM,sBAAsB,IAAI,KAAK;AACrC,MAAM,cAAc;;AAEpB,MAAM,aAAa;AAWnB,MAAM,yBAAS,IAAI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Q;EAAO,CAAC;EAC/E,MAAM,OAAO,MAAM,MAAO,QAAQ;EAClC,QAAQ,MACN,sBAAsB,QAAQ,OAAO;GACnC,MAAM,KAAK;GACX,MAAM,WAAW,SAAS,IAAI;GAC9B;EACF,CAAC,CACH;CACF;CAEA,MAAM,WACJ,OAAO,yBAAyB,cAC5B,OACA,IAAI,sBACD,YAAY;EACX,MAAM,OAAO,QAAQ,GAAG,EAAE,CAAC,CAAE;EAC7B,IAAI,SAAS,SAAS;EACtB,UAAU;EACV,IAAI,SAAS,aAAa;CAC5B,GACA,EAAE,YAAY,YAAY,CAC5B;CACN,UAAU,QAAQ,GAAG;CAGrB,KAAK,IAAI;CACT,MAAM,cAAc,gBAAgB;EAClC,OAAO,OAAO,YAAY;GACxB,IAAI,CAAC,SAAS,OAAO;GACrB,KAAK,OAAO;GACZ,OAAO,OAAO,IAAI,QAAQ,KAAK,IAAI,QAAQ,kBAAkB,sBAAsB;EACrF;EACA,eAAe;GACb,MAAM,UAAU,IAAI,sBAAsB,IAAI;EAChD;CACF,CAAC;CAED,aAAa;EACX,YAAY;EACZ,UAAU,WAAW;EACrB,QAAQ,QAAQ;CAClB;AACF"}
@@ -0,0 +1,193 @@
1
+ // src/AgentAvatar/look.ts
2
+ /** Cancels the engine's resting turn to the left and leaves the face almost frontal, a touch right. */
3
+ const REST_YAW = .38;
4
+ /** A slight resting look to the right on top of the logo's inward pupils. */
5
+ const REST_GAZE_X = .12;
6
+ const NEUTRAL = {
7
+ arc: 0,
8
+ gazeMix: 0,
9
+ gazeX: 0,
10
+ gazeY: 0,
11
+ lift: 0,
12
+ pitch: 0,
13
+ roll: 0,
14
+ shift: 0,
15
+ slit: 0,
16
+ squintL: 0,
17
+ squintR: 0,
18
+ sx: 1,
19
+ sy: 1,
20
+ wide: 0,
21
+ yaw: 0
22
+ };
23
+ const TAU = Math.PI * 2;
24
+ const wave = (t, period, phase = 0) => Math.sin(TAU * t / period + phase);
25
+ const fract = (value) => value - Math.floor(value);
26
+ const smooth = (value) => {
27
+ const x = Math.min(1, Math.max(0, value));
28
+ return x * x * (3 - 2 * x);
29
+ };
30
+ /** Where a working avatar's eyes go next: mostly down, across the work. */
31
+ const WORK_GLANCES = [
32
+ [-.55, .45],
33
+ [.15, .55],
34
+ [.65, .35],
35
+ [-.1, .55],
36
+ [.4, .45]
37
+ ];
38
+ const GLANCE_SECONDS = .62;
39
+ const glance = (t) => {
40
+ const slot = Math.floor(t / GLANCE_SECONDS);
41
+ const count = WORK_GLANCES.length;
42
+ const from = WORK_GLANCES[((slot - 1) % count + count) % count];
43
+ const to = WORK_GLANCES[(slot % count + count) % count];
44
+ const k = smooth(fract(t / GLANCE_SECONDS) / .2);
45
+ return [from[0] + (to[0] - from[0]) * k, from[1] + (to[1] - from[1]) * k];
46
+ };
47
+ /** The look of a state `t` seconds in. `still` is its calm pose, for avatars that do not move. */
48
+ const stateLook = (state, t, still = false) => {
49
+ switch (state) {
50
+ case "working": {
51
+ if (still) return {
52
+ ...NEUTRAL,
53
+ gazeMix: 1,
54
+ gazeX: .2,
55
+ gazeY: .5,
56
+ squintL: .2,
57
+ squintR: .2
58
+ };
59
+ const beat = wave(t, .7);
60
+ const [gazeX, gazeY] = glance(t);
61
+ return {
62
+ ...NEUTRAL,
63
+ gazeMix: 1,
64
+ gazeX,
65
+ gazeY,
66
+ lift: -.5 * (.5 + .5 * beat),
67
+ pitch: -.05,
68
+ roll: 1.6 + .5 * beat,
69
+ squintL: .22,
70
+ squintR: .22,
71
+ sx: 1.004 + .004 * beat,
72
+ sy: .992 - .006 * beat
73
+ };
74
+ }
75
+ case "waiting": {
76
+ if (still) return {
77
+ ...NEUTRAL,
78
+ gazeMix: 1,
79
+ gazeX: .45,
80
+ gazeY: .08,
81
+ roll: 3,
82
+ slit: 1
83
+ };
84
+ const sigh = Math.sin(TAU * Math.min(1, fract(t / 6.5) / .33));
85
+ return {
86
+ ...NEUTRAL,
87
+ gazeMix: 1,
88
+ gazeX: .45 + .12 * wave(t, 8.2),
89
+ gazeY: .08,
90
+ roll: 3 + .7 * wave(t, 6.4, 2),
91
+ slit: 1,
92
+ sx: 1 - .01 * sigh,
93
+ sy: 1 + .018 * sigh
94
+ };
95
+ }
96
+ case "thinking":
97
+ if (still) return {
98
+ ...NEUTRAL,
99
+ gazeMix: 1,
100
+ gazeX: .55,
101
+ gazeY: -.75,
102
+ roll: -3,
103
+ squintL: .12,
104
+ squintR: .28
105
+ };
106
+ return {
107
+ ...NEUTRAL,
108
+ gazeMix: 1,
109
+ gazeX: .5 + .24 * wave(t, 5.6),
110
+ gazeY: -.72,
111
+ lift: -.4 * (1 - Math.cos(TAU * t / 5.2)),
112
+ pitch: .06,
113
+ roll: -3 + .8 * wave(t, 4.1),
114
+ squintL: .12,
115
+ squintR: .28 + .08 * wave(t, 3.1),
116
+ yaw: .06
117
+ };
118
+ case "blocked": {
119
+ if (still) return {
120
+ ...NEUTRAL,
121
+ gazeMix: 1,
122
+ gazeY: .05,
123
+ wide: 1
124
+ };
125
+ const p = fract(t / 2.2);
126
+ const shaking = p < .22 ? p / .22 : 0;
127
+ return {
128
+ ...NEUTRAL,
129
+ gazeMix: 1,
130
+ gazeY: .05,
131
+ shift: shaking ? 1.6 * Math.sin(TAU * 3 * shaking) * (1 - shaking) : 0,
132
+ sx: .994,
133
+ sy: 1.012,
134
+ wide: 1
135
+ };
136
+ }
137
+ case "done": {
138
+ if (still) return {
139
+ ...NEUTRAL,
140
+ arc: 1
141
+ };
142
+ const p = fract(t / 2.6);
143
+ const hopping = p < .44;
144
+ const hop = hopping ? fract(p / .22) : 0;
145
+ const air = hopping ? 4 * hop * (1 - hop) : 0;
146
+ const land = hopping ? Math.max(0, 1 - Math.min(hop, 1 - hop) / .14) : 0;
147
+ return {
148
+ ...NEUTRAL,
149
+ arc: 1,
150
+ lift: -2.6 * air,
151
+ roll: hopping ? 2.6 * Math.sin(TAU * p / .44) : .8 * wave(t, 3.2),
152
+ sx: 1 + .05 * land - .012 * air,
153
+ sy: 1 - .07 * land + .022 * air
154
+ };
155
+ }
156
+ default: return NEUTRAL;
157
+ }
158
+ };
159
+ /** The weighted mean of the looks of the states being eased between. */
160
+ const blendLooks = (weights, t) => {
161
+ const entries = Object.entries(weights);
162
+ const total = entries.reduce((sum, [, weight]) => sum + weight, 0) || 1;
163
+ const mixed = Object.fromEntries(Object.keys(NEUTRAL).map((key) => [key, 0]));
164
+ for (const [state, weight] of entries) {
165
+ const look = stateLook(state, t);
166
+ for (const key of Object.keys(mixed)) mixed[key] += look[key] * weight / total;
167
+ }
168
+ return mixed;
169
+ };
170
+ /** The body pose of a look: squash about the base, roll about the middle, then the offsets. */
171
+ const lookMatrix = ({ lift, roll, shift, sx, sy }) => {
172
+ const angle = roll * Math.PI / 180;
173
+ const [cos, sin] = [Math.cos(angle), Math.sin(angle)];
174
+ const [px, py] = [50, 52];
175
+ const [a, d] = [sx, sy];
176
+ const e = 50 - 50 * sx;
177
+ const f = 90 - 90 * sy;
178
+ return [
179
+ cos * a,
180
+ sin * a,
181
+ -sin * d,
182
+ cos * d,
183
+ cos * (e - px) - sin * (f - py) + px + shift,
184
+ sin * (e - px) + cos * (f - py) + py + lift
185
+ ];
186
+ };
187
+ const matrixTransform = (m) => `matrix(${m.map((value, index) => {
188
+ const scale = index < 4 ? 1e4 : 100;
189
+ return Math.round(value * scale) / scale;
190
+ }).join(" ")})`;
191
+ export { REST_GAZE_X, REST_YAW, blendLooks, lookMatrix, matrixTransform, stateLook };
192
+
193
+ //# sourceMappingURL=look.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"look.mjs","names":[],"sources":["../../src/AgentAvatar/look.ts"],"sourcesContent":["/**\n * What each state does to the avatar itself: its eyes and a small body pose. Nothing here reaches\n * outside the avatar's own box, so it can sit in a tight layout at any state.\n */\nimport type { AgentAvatarState } from './type';\n\nexport type LookMatrix = [number, number, number, number, number, number];\n\nexport interface AvatarLook {\n /** 0 = open eyes, 1 = closed smiling arcs. */\n arc: number;\n /** How much `gazeX` / `gazeY` replace the idle wander, 0..1. */\n gazeMix: number;\n gazeX: number;\n gazeY: number;\n /** Vertical offset (negative = up), viewBox units. */\n lift: number;\n /** Extra view tilt, radians. */\n pitch: number;\n /** In-plane rotation, degrees. */\n roll: number;\n /** Horizontal offset, viewBox units. */\n shift: number;\n /** 0 = open eyes, 1 = heavy lids. */\n slit: number;\n squintL: number;\n squintR: number;\n /** Squash and stretch about the base. */\n sx: number;\n sy: number;\n /** 0 = logo eyes, 1 = wide eyes with small pupils. */\n wide: number;\n /** Extra view turn, radians. */\n yaw: number;\n}\n\n/** Cancels the engine's resting turn to the left and leaves the face almost frontal, a touch right. */\nexport const REST_YAW = 0.38;\n/** A slight resting look to the right on top of the logo's inward pupils. */\nexport const REST_GAZE_X = 0.12;\n\nconst NEUTRAL: AvatarLook = {\n arc: 0,\n gazeMix: 0,\n gazeX: 0,\n gazeY: 0,\n lift: 0,\n pitch: 0,\n roll: 0,\n shift: 0,\n slit: 0,\n squintL: 0,\n squintR: 0,\n sx: 1,\n sy: 1,\n wide: 0,\n yaw: 0,\n};\n\nconst TAU = Math.PI * 2;\nconst wave = (t: number, period: number, phase = 0) => Math.sin((TAU * t) / period + phase);\nconst fract = (value: number) => value - Math.floor(value);\nconst smooth = (value: number) => {\n const x = Math.min(1, Math.max(0, value));\n return x * x * (3 - 2 * x);\n};\n\n/** Where a working avatar's eyes go next: mostly down, across the work. */\nconst WORK_GLANCES: [number, number][] = [\n [-0.55, 0.45],\n [0.15, 0.55],\n [0.65, 0.35],\n [-0.1, 0.55],\n [0.4, 0.45],\n];\nconst GLANCE_SECONDS = 0.62;\n\nconst glance = (t: number): [number, number] => {\n const slot = Math.floor(t / GLANCE_SECONDS);\n const count = WORK_GLANCES.length;\n const from = WORK_GLANCES[(((slot - 1) % count) + count) % count];\n const to = WORK_GLANCES[((slot % count) + count) % count];\n const k = smooth(fract(t / GLANCE_SECONDS) / 0.2);\n return [from[0] + (to[0] - from[0]) * k, from[1] + (to[1] - from[1]) * k];\n};\n\n/** The look of a state `t` seconds in. `still` is its calm pose, for avatars that do not move. */\nexport const stateLook = (state: AgentAvatarState, t: number, still = false): AvatarLook => {\n switch (state) {\n case 'working': {\n if (still) {\n return { ...NEUTRAL, gazeMix: 1, gazeX: 0.2, gazeY: 0.5, squintL: 0.2, squintR: 0.2 };\n }\n const beat = wave(t, 0.7);\n const [gazeX, gazeY] = glance(t);\n return {\n ...NEUTRAL,\n gazeMix: 1,\n gazeX,\n gazeY,\n lift: -0.5 * (0.5 + 0.5 * beat),\n pitch: -0.05,\n roll: 1.6 + 0.5 * beat,\n squintL: 0.22,\n squintR: 0.22,\n sx: 1.004 + 0.004 * beat,\n sy: 0.992 - 0.006 * beat,\n };\n }\n case 'waiting': {\n if (still) return { ...NEUTRAL, gazeMix: 1, gazeX: 0.45, gazeY: 0.08, roll: 3, slit: 1 };\n const sigh = Math.sin(TAU * Math.min(1, fract(t / 6.5) / 0.33));\n return {\n ...NEUTRAL,\n gazeMix: 1,\n gazeX: 0.45 + 0.12 * wave(t, 8.2),\n gazeY: 0.08,\n roll: 3 + 0.7 * wave(t, 6.4, 2),\n slit: 1,\n sx: 1 - 0.01 * sigh,\n sy: 1 + 0.018 * sigh,\n };\n }\n case 'thinking': {\n if (still) {\n return {\n ...NEUTRAL,\n gazeMix: 1,\n gazeX: 0.55,\n gazeY: -0.75,\n roll: -3,\n squintL: 0.12,\n squintR: 0.28,\n };\n }\n return {\n ...NEUTRAL,\n gazeMix: 1,\n gazeX: 0.5 + 0.24 * wave(t, 5.6),\n gazeY: -0.72,\n lift: -0.4 * (1 - Math.cos((TAU * t) / 5.2)),\n pitch: 0.06,\n roll: -3 + 0.8 * wave(t, 4.1),\n squintL: 0.12,\n squintR: 0.28 + 0.08 * wave(t, 3.1),\n yaw: 0.06,\n };\n }\n case 'blocked': {\n if (still) return { ...NEUTRAL, gazeMix: 1, gazeY: 0.05, wide: 1 };\n const p = fract(t / 2.2);\n const shaking = p < 0.22 ? p / 0.22 : 0;\n return {\n ...NEUTRAL,\n gazeMix: 1,\n gazeY: 0.05,\n shift: shaking ? 1.6 * Math.sin(TAU * 3 * shaking) * (1 - shaking) : 0,\n sx: 0.994,\n sy: 1.012,\n wide: 1,\n };\n }\n case 'done': {\n if (still) return { ...NEUTRAL, arc: 1 };\n // Two small hops, then a contented rest.\n const p = fract(t / 2.6);\n const hopping = p < 0.44;\n const hop = hopping ? fract(p / 0.22) : 0;\n const air = hopping ? 4 * hop * (1 - hop) : 0;\n const land = hopping ? Math.max(0, 1 - Math.min(hop, 1 - hop) / 0.14) : 0;\n return {\n ...NEUTRAL,\n arc: 1,\n lift: -2.6 * air,\n roll: hopping ? 2.6 * Math.sin((TAU * p) / 0.44) : 0.8 * wave(t, 3.2),\n sx: 1 + 0.05 * land - 0.012 * air,\n sy: 1 - 0.07 * land + 0.022 * air,\n };\n }\n default: {\n return NEUTRAL;\n }\n }\n};\n\n/** The weighted mean of the looks of the states being eased between. */\nexport const blendLooks = (\n weights: Partial<Record<AgentAvatarState, number>>,\n t: number,\n): AvatarLook => {\n const entries = Object.entries(weights) as [AgentAvatarState, number][];\n const total = entries.reduce((sum, [, weight]) => sum + weight, 0) || 1;\n const mixed = Object.fromEntries(\n Object.keys(NEUTRAL).map((key) => [key, 0]),\n ) as unknown as Record<keyof AvatarLook, number>;\n for (const [state, weight] of entries) {\n const look = stateLook(state, t);\n for (const key of Object.keys(mixed) as (keyof AvatarLook)[]) {\n mixed[key] += (look[key] * weight) / total;\n }\n }\n return mixed;\n};\n\n/** The body pose of a look: squash about the base, roll about the middle, then the offsets. */\nexport const lookMatrix = ({ lift, roll, shift, sx, sy }: AvatarLook): LookMatrix => {\n const angle = (roll * Math.PI) / 180;\n const [cos, sin] = [Math.cos(angle), Math.sin(angle)];\n const [px, py] = [50, 52];\n // Squash about (50, 90).\n const [a, d] = [sx, sy];\n const e = 50 - 50 * sx;\n const f = 90 - 90 * sy;\n return [\n cos * a,\n sin * a,\n -sin * d,\n cos * d,\n cos * (e - px) - sin * (f - py) + px + shift,\n sin * (e - px) + cos * (f - py) + py + lift,\n ];\n};\n\nexport const matrixTransform = (m: readonly number[]) =>\n `matrix(${m\n .map((value, index) => {\n const scale = index < 4 ? 10_000 : 100;\n return Math.round(value * scale) / scale;\n })\n .join(' ')})`;\n"],"mappings":";;AAqCA,MAAa,WAAW;;AAExB,MAAa,cAAc;AAE3B,MAAM,UAAsB;CAC1B,KAAK;CACL,SAAS;CACT,OAAO;CACP,OAAO;CACP,MAAM;CACN,OAAO;CACP,MAAM;CACN,OAAO;CACP,MAAM;CACN,SAAS;CACT,SAAS;CACT,IAAI;CACJ,IAAI;CACJ,MAAM;CACN,KAAK;AACP;AAEA,MAAM,MAAM,KAAK,KAAK;AACtB,MAAM,QAAQ,GAAW,QAAgB,QAAQ,MAAM,KAAK,IAAK,MAAM,IAAK,SAAS,KAAK;AAC1F,MAAM,SAAS,UAAkB,QAAQ,KAAK,MAAM,KAAK;AACzD,MAAM,UAAU,UAAkB;CAChC,MAAM,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,KAAK,CAAC;CACxC,OAAO,IAAI,KAAK,IAAI,IAAI;AAC1B;;AAGA,MAAM,eAAmC;CACvC,CAAC,MAAO,GAAI;CACZ,CAAC,KAAM,GAAI;CACX,CAAC,KAAM,GAAI;CACX,CAAC,KAAM,GAAI;CACX,CAAC,IAAK,GAAI;AACZ;AACA,MAAM,iBAAiB;AAEvB,MAAM,UAAU,MAAgC;CAC9C,MAAM,OAAO,KAAK,MAAM,IAAI,cAAc;CAC1C,MAAM,QAAQ,aAAa;CAC3B,MAAM,OAAO,eAAgB,OAAO,KAAK,QAAS,SAAS;CAC3D,MAAM,KAAK,cAAe,OAAO,QAAS,SAAS;CACnD,MAAM,IAAI,OAAO,MAAM,IAAI,cAAc,IAAI,EAAG;CAChD,OAAO,CAAC,KAAK,MAAM,GAAG,KAAK,KAAK,MAAM,GAAG,KAAK,MAAM,GAAG,KAAK,KAAK,MAAM,CAAC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AAM,OAAO,UAAU,OAAO,CAAC;EAC/B,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,GACjC,MAAM,QAAS,KAAK,OAAO,SAAU;CAEzC;CACA,OAAO;AACT;;AAGA,MAAa,cAAc,EAAE,MAAM,MAAM,OAAO,IAAI,SAAiC;CACnF,MAAM,QAAS,OAAO,KAAK,KAAM;CACjC,MAAM,CAAC,KAAK,OAAO,CAAC,KAAK,IAAI,KAAK,GAAG,KAAK,IAAI,KAAK,CAAC;CACpD,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,EAAE;CAExB,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE;CACtB,MAAM,IAAI,KAAK,KAAK;CACpB,MAAM,IAAI,KAAK,KAAK;CACpB,OAAO;EACL,MAAM;EACN,MAAM;EACN,CAAC,MAAM;EACP,MAAM;EACN,OAAO,IAAI,MAAM,OAAO,IAAI,MAAM,KAAK;EACvC,OAAO,IAAI,MAAM,OAAO,IAAI,MAAM,KAAK;CACzC;AACF;AAEA,MAAa,mBAAmB,MAC9B,UAAU,EACP,KAAK,OAAO,UAAU;CACrB,MAAM,QAAQ,QAAQ,IAAI,MAAS;CACnC,OAAO,KAAK,MAAM,QAAQ,KAAK,IAAI;AACrC,CAAC,CAAC,CACD,KAAK,GAAG,EAAE"}
@@ -0,0 +1,111 @@
1
+ import { PUPIL_COLOR, SCLERA_COLOR } from "./utils.mjs";
2
+ // src/AgentAvatar/painter.ts
3
+ const SVG_NS = "http://www.w3.org/2000/svg";
4
+ const create = (tag, parent) => {
5
+ const element = document.createElementNS(SVG_NS, tag);
6
+ parent.append(element);
7
+ return element;
8
+ };
9
+ /** The attribute values last written per element. */
10
+ const written = /* @__PURE__ */ new WeakMap();
11
+ /** Set or remove an attribute, skipping the DOM when the value is unchanged. */
12
+ const put = (element, name, value) => {
13
+ let cache = written.get(element);
14
+ if (!cache) {
15
+ cache = {};
16
+ written.set(element, cache);
17
+ }
18
+ if (cache[name] === value) return;
19
+ cache[name] = value;
20
+ if (value === null) element.removeAttribute(name);
21
+ else element.setAttribute(name, value);
22
+ };
23
+ const show = (element, visible) => put(element, "display", visible ? null : "none");
24
+ const createPainter = (layers, idPrefix) => {
25
+ const defined = /* @__PURE__ */ new Map();
26
+ const slices = [];
27
+ const eyes = [];
28
+ const owned = [];
29
+ let extra;
30
+ const paintSlices = (items) => {
31
+ while (slices.length < items.length) {
32
+ const element = create("use", layers.body);
33
+ owned.push(element);
34
+ slices.push(element);
35
+ }
36
+ for (const [index, element] of slices.entries()) {
37
+ const item = items[index];
38
+ show(element, !!item);
39
+ if (!item) continue;
40
+ put(element, "href", `#${idPrefix}${item.href}`);
41
+ put(element, "transform", item.transform);
42
+ }
43
+ };
44
+ const createEye = () => {
45
+ const group = create("g", layers.eyes);
46
+ owned.push(group);
47
+ const sclera = create("path", group);
48
+ sclera.setAttribute("fill", SCLERA_COLOR);
49
+ const pupil = create("path", group);
50
+ pupil.setAttribute("fill", PUPIL_COLOR);
51
+ const smile = create("path", group);
52
+ smile.setAttribute("fill", "none");
53
+ smile.setAttribute("stroke", SCLERA_COLOR);
54
+ smile.setAttribute("stroke-linecap", "round");
55
+ return {
56
+ group,
57
+ pupil,
58
+ sclera,
59
+ smile
60
+ };
61
+ };
62
+ const paintPart = (element, d) => {
63
+ show(element, d !== null);
64
+ if (d !== null) put(element, "d", d);
65
+ };
66
+ const paintEyes = (items) => {
67
+ while (eyes.length < items.length) eyes.push(createEye());
68
+ for (const [index, nodes] of eyes.entries()) {
69
+ const item = items[index];
70
+ show(nodes.group, !!item);
71
+ if (!item) continue;
72
+ put(nodes.group, "transform", item.transform);
73
+ paintPart(nodes.sclera, item.sclera);
74
+ paintPart(nodes.pupil, item.pupil);
75
+ paintPart(nodes.smile, item.smile);
76
+ if (item.smile) put(nodes.smile, "stroke-width", String(item.smileWidth));
77
+ }
78
+ };
79
+ return {
80
+ destroy: () => {
81
+ for (const element of owned) element.remove();
82
+ for (const element of defined.values()) element.remove();
83
+ },
84
+ paint: (scene) => {
85
+ for (const { d, evenOdd, id } of scene.paths) {
86
+ if (defined.has(id)) continue;
87
+ const path = create("path", layers.defs);
88
+ path.id = `${idPrefix}${id}`;
89
+ path.setAttribute("d", d);
90
+ if (evenOdd) path.setAttribute("fill-rule", "evenodd");
91
+ defined.set(id, path);
92
+ }
93
+ paintSlices(scene.body);
94
+ if (scene.extra && !extra) {
95
+ extra = create("path", layers.body);
96
+ owned.push(extra);
97
+ }
98
+ if (extra) {
99
+ show(extra, !!scene.extra);
100
+ if (scene.extra) {
101
+ put(extra, "d", scene.extra.d);
102
+ put(extra, "transform", scene.extra.transform);
103
+ }
104
+ }
105
+ paintEyes(scene.eyes);
106
+ }
107
+ };
108
+ };
109
+ export { createPainter };
110
+
111
+ //# sourceMappingURL=painter.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"painter.mjs","names":[],"sources":["../../src/AgentAvatar/painter.ts"],"sourcesContent":["/**\n * Writes scenes into the SVG of a live avatar. Elements are pooled and an attribute is only\n * touched when its value changed, so a frame costs a few transforms rather than a React render.\n */\nimport type { AgentAvatarScene, SceneEye, SceneUse } from './scene';\nimport { PUPIL_COLOR, SCLERA_COLOR } from './utils';\n\nconst SVG_NS = 'http://www.w3.org/2000/svg';\n\nexport interface AgentAvatarLayers {\n body: SVGGElement;\n defs: SVGDefsElement;\n eyes: SVGGElement;\n}\n\nconst create = <K extends keyof SVGElementTagNameMap>(tag: K, parent: Element) => {\n const element = document.createElementNS(SVG_NS, tag);\n parent.append(element);\n return element as SVGElementTagNameMap[K];\n};\n\n/** The attribute values last written per element. */\nconst written = new WeakMap<Element, Record<string, string | null>>();\n\n/** Set or remove an attribute, skipping the DOM when the value is unchanged. */\nconst put = (element: Element, name: string, value: string | null) => {\n let cache = written.get(element);\n if (!cache) {\n cache = {};\n written.set(element, cache);\n }\n if (cache[name] === value) return;\n cache[name] = value;\n if (value === null) element.removeAttribute(name);\n else element.setAttribute(name, value);\n};\n\nconst show = (element: Element, visible: boolean) =>\n put(element, 'display', visible ? null : 'none');\n\ninterface EyeNodes {\n group: SVGGElement;\n pupil: SVGPathElement;\n sclera: SVGPathElement;\n smile: SVGPathElement;\n}\n\nexport const createPainter = (layers: AgentAvatarLayers, idPrefix: string) => {\n const defined = new Map<string, SVGPathElement>();\n const slices: SVGUseElement[] = [];\n const eyes: EyeNodes[] = [];\n const owned: Element[] = [];\n let extra: SVGPathElement | undefined;\n\n const paintSlices = (items: SceneUse[]) => {\n while (slices.length < items.length) {\n const element = create('use', layers.body);\n owned.push(element);\n slices.push(element);\n }\n for (const [index, element] of slices.entries()) {\n const item = items[index];\n show(element, !!item);\n if (!item) continue;\n put(element, 'href', `#${idPrefix}${item.href}`);\n put(element, 'transform', item.transform);\n }\n };\n\n const createEye = (): EyeNodes => {\n const group = create('g', layers.eyes);\n owned.push(group);\n const sclera = create('path', group);\n sclera.setAttribute('fill', SCLERA_COLOR);\n const pupil = create('path', group);\n pupil.setAttribute('fill', PUPIL_COLOR);\n const smile = create('path', group);\n smile.setAttribute('fill', 'none');\n smile.setAttribute('stroke', SCLERA_COLOR);\n smile.setAttribute('stroke-linecap', 'round');\n return { group, pupil, sclera, smile };\n };\n\n const paintPart = (element: SVGPathElement, d: string | null) => {\n show(element, d !== null);\n if (d !== null) put(element, 'd', d);\n };\n\n const paintEyes = (items: SceneEye[]) => {\n while (eyes.length < items.length) eyes.push(createEye());\n for (const [index, nodes] of eyes.entries()) {\n const item = items[index];\n show(nodes.group, !!item);\n if (!item) continue;\n put(nodes.group, 'transform', item.transform);\n paintPart(nodes.sclera, item.sclera);\n paintPart(nodes.pupil, item.pupil);\n paintPart(nodes.smile, item.smile);\n if (item.smile) put(nodes.smile, 'stroke-width', String(item.smileWidth));\n }\n };\n\n return {\n destroy: () => {\n for (const element of owned) element.remove();\n for (const element of defined.values()) element.remove();\n },\n paint: (scene: AgentAvatarScene) => {\n for (const { d, evenOdd, id } of scene.paths) {\n if (defined.has(id)) continue;\n const path = create('path', layers.defs);\n path.id = `${idPrefix}${id}`;\n path.setAttribute('d', d);\n if (evenOdd) path.setAttribute('fill-rule', 'evenodd');\n defined.set(id, path);\n }\n paintSlices(scene.body);\n if (scene.extra && !extra) {\n extra = create('path', layers.body);\n owned.push(extra);\n }\n if (extra) {\n show(extra, !!scene.extra);\n if (scene.extra) {\n put(extra, 'd', scene.extra.d);\n put(extra, 'transform', scene.extra.transform);\n }\n }\n paintEyes(scene.eyes);\n },\n };\n};\n"],"mappings":";;AAOA,MAAM,SAAS;AAQf,MAAM,UAAgD,KAAQ,WAAoB;CAChF,MAAM,UAAU,SAAS,gBAAgB,QAAQ,GAAG;CACpD,OAAO,OAAO,OAAO;CACrB,OAAO;AACT;;AAGA,MAAM,0BAAU,IAAI,QAAgD;;AAGpE,MAAM,OAAO,SAAkB,MAAc,UAAyB;CACpE,IAAI,QAAQ,QAAQ,IAAI,OAAO;CAC/B,IAAI,CAAC,OAAO;EACV,QAAQ,CAAC;EACT,QAAQ,IAAI,SAAS,KAAK;CAC5B;CACA,IAAI,MAAM,UAAU,OAAO;CAC3B,MAAM,QAAQ;CACd,IAAI,UAAU,MAAM,QAAQ,gBAAgB,IAAI;MAC3C,QAAQ,aAAa,MAAM,KAAK;AACvC;AAEA,MAAM,QAAQ,SAAkB,YAC9B,IAAI,SAAS,WAAW,UAAU,OAAO,MAAM;AASjD,MAAa,iBAAiB,QAA2B,aAAqB;CAC5E,MAAM,0BAAU,IAAI,IAA4B;CAChD,MAAM,SAA0B,CAAC;CACjC,MAAM,OAAmB,CAAC;CAC1B,MAAM,QAAmB,CAAC;CAC1B,IAAI;CAEJ,MAAM,eAAe,UAAsB;EACzC,OAAO,OAAO,SAAS,MAAM,QAAQ;GACnC,MAAM,UAAU,OAAO,OAAO,OAAO,IAAI;GACzC,MAAM,KAAK,OAAO;GAClB,OAAO,KAAK,OAAO;EACrB;EACA,KAAK,MAAM,CAAC,OAAO,YAAY,OAAO,QAAQ,GAAG;GAC/C,MAAM,OAAO,MAAM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AK,MAAM,WAAW,QAAQ,OAAO,GAAG,QAAQ,OAAO;EACzD;EACA,QAAQ,UAA4B;GAClC,KAAK,MAAM,EAAE,GAAG,SAAS,QAAQ,MAAM,OAAO;IAC5C,IAAI,QAAQ,IAAI,EAAE,GAAG;IACrB,MAAM,OAAO,OAAO,QAAQ,OAAO,IAAI;IACvC,KAAK,KAAK,GAAG,WAAW;IACxB,KAAK,aAAa,KAAK,CAAC;IACxB,IAAI,SAAS,KAAK,aAAa,aAAa,SAAS;IACrD,QAAQ,IAAI,IAAI,IAAI;GACtB;GACA,YAAY,MAAM,IAAI;GACtB,IAAI,MAAM,SAAS,CAAC,OAAO;IACzB,QAAQ,OAAO,QAAQ,OAAO,IAAI;IAClC,MAAM,KAAK,KAAK;GAClB;GACA,IAAI,OAAO;IACT,KAAK,OAAO,CAAC,CAAC,MAAM,KAAK;IACzB,IAAI,MAAM,OAAO;KACf,IAAI,OAAO,KAAK,MAAM,MAAM,CAAC;KAC7B,IAAI,OAAO,aAAa,MAAM,MAAM,SAAS;IAC/C;GACF;GACA,UAAU,MAAM,IAAI;EACtB;CACF;AACF"}
@@ -0,0 +1,68 @@
1
+ // src/AgentAvatar/pickerStyle.ts
2
+ const styles = {
3
+ color: {
4
+ kkrTdU: "lb1ypdohk",
5
+ kMzoRj: "lbc342km",
6
+ ksu8eU: "lbng3xce",
7
+ kaIpWk: "lb16rqkct",
8
+ kzqmXN: "lb17z2i9w",
9
+ kZKoxP: "lb17rw0jw",
10
+ kmVPX3: "lb1717udv",
11
+ $$css: true
12
+ },
13
+ colorActive: {
14
+ kGVxlE: "lbb4n4bt",
15
+ $$css: true
16
+ },
17
+ colors: {
18
+ k1xSpc: "lbrvj5dj",
19
+ kOIVth: "lb1jnr06f",
20
+ kumcoG: "lbkkvkr6",
21
+ kAPf3g: "lb1o2pa38",
22
+ kEafiO: "lb178xt8z",
23
+ kPef9Z: "lb13fuv20",
24
+ kLZC3w: "lb6tbnhg",
25
+ kLKAdn: "lbz9dl7a",
26
+ $$css: true
27
+ },
28
+ preview: {
29
+ k1xSpc: "lb78zum5",
30
+ kjj79g: "lbl56j7k",
31
+ k8WAf4: "lb1vvogim",
32
+ $$css: true
33
+ },
34
+ root: {
35
+ k1xSpc: "lb78zum5",
36
+ kXwgrk: "lbdt5ytf",
37
+ kOIVth: "lb1v2ro7d",
38
+ kzqmXN: "lbh8yej3",
39
+ ks0D6T: "lb1va8c73",
40
+ $$css: true
41
+ },
42
+ shape: {
43
+ kkrTdU: "lb1ypdohk",
44
+ k1xSpc: "lb78zum5",
45
+ kGNEyG: "lb6s0dn4",
46
+ kjj79g: "lbl56j7k",
47
+ kMzoRj: "lbc342km",
48
+ ksu8eU: "lbng3xce",
49
+ kaIpWk: "lb1sbi92r",
50
+ kWkggS: "lbjbqb8w lb1gowcop",
51
+ kOBAk4: "lb1plog1",
52
+ kmVPX3: "lbfawy5m",
53
+ $$css: true
54
+ },
55
+ shapeActive: {
56
+ kWkggS: "lbjjy28o lb1ri6zej",
57
+ $$css: true
58
+ },
59
+ shapes: {
60
+ k1xSpc: "lbrvj5dj",
61
+ kOIVth: "lb1jnr06f",
62
+ kumcoG: "lb1jl941j",
63
+ $$css: true
64
+ }
65
+ };
66
+ export { styles };
67
+
68
+ //# sourceMappingURL=pickerStyle.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pickerStyle.mjs","names":[],"sources":["../../src/AgentAvatar/pickerStyle.ts"],"sourcesContent":["import * as stylex from '@stylexjs/stylex';\n\nimport { cssVar } from '@/styles/stylex/cssVar.stylex';\n\nexport const styles = stylex.create({\n color: {\n cursor: 'pointer',\n borderWidth: 0,\n borderStyle: 'none',\n borderRadius: '50%',\n width: 22,\n height: 22,\n padding: 0,\n },\n colorActive: {\n boxShadow: `0 0 0 2px ${cssVar.colorBgElevated}, 0 0 0 3.5px ${cssVar.colorTextSecondary}`,\n },\n colors: {\n display: 'grid',\n gap: 4,\n gridTemplateColumns: 'repeat(9, minmax(0, 1fr))',\n justifyItems: 'center',\n borderBlockStartWidth: 1,\n borderBlockStartStyle: 'solid',\n borderBlockStartColor: 'var(--lobe-fill-border)',\n paddingBlockStart: 12,\n },\n preview: {\n display: 'flex',\n justifyContent: 'center',\n paddingBlock: 8,\n },\n root: {\n display: 'flex',\n flexDirection: 'column',\n gap: 12,\n width: '100%',\n maxWidth: 320,\n },\n shape: {\n cursor: 'pointer',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n borderWidth: 0,\n borderStyle: 'none',\n borderRadius: cssVar.borderRadius,\n backgroundColor: {\n 'default': 'transparent',\n ':hover': cssVar.colorFillTertiary,\n },\n aspectRatio: '1',\n padding: 4,\n },\n shapeActive: {\n backgroundColor: {\n 'default': cssVar.colorFillSecondary,\n ':hover': cssVar.colorFillSecondary,\n },\n },\n shapes: {\n display: 'grid',\n gap: 4,\n gridTemplateColumns: 'repeat(6, minmax(0, 1fr))',\n },\n});\n"],"mappings":";AAGA,MAAa,SAAS;CACpB,OAAO;EACL,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,aAAa;EACX,QAAQ;EACR,OAAO;CACT;CACA,QAAQ;EACN,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,SAAS;EACP,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,MAAM;EACJ,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,OAAO;EACL,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,aAAa;EACX,QAAQ;EACR,OAAO;CACT;CACA,QAAQ;EACN,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;AACF"}
@@ -0,0 +1,90 @@
1
+ import { avatarFrame, computePose } from "open-bot-avatar";
2
+ import { LOGO_EYE, drawEye } from "./eyes.mjs";
3
+ import { REST_GAZE_X, REST_YAW, lookMatrix, matrixTransform } from "./look.mjs";
4
+ import { SHAPE_GEOMETRY, getShapeDefinition } from "./shapes.mjs";
5
+ // src/AgentAvatar/scene.ts
6
+ /**
7
+ * One live frame as plain draw data. `open-bot-avatar` provides the implied volume and the idle
8
+ * breathing, blinking and wander; the state poses come from `look.ts` and the eyes are the Lobot
9
+ * logo eyes.
10
+ */
11
+ /** The engine's seed for a definition id (FNV-1a), so the eyes follow the pose the body uses. */
12
+ const engineSeed = (id) => {
13
+ let hash = 0x811c9dc5;
14
+ for (let index = 0; index < id.length; index++) {
15
+ hash ^= id.charCodeAt(index);
16
+ hash = Math.imul(hash, 16777619);
17
+ }
18
+ return hash >>> 0;
19
+ };
20
+ const multiply = (m, n) => [
21
+ m[0] * n[0] + m[2] * n[1],
22
+ m[1] * n[0] + m[3] * n[1],
23
+ m[0] * n[2] + m[2] * n[3],
24
+ m[1] * n[2] + m[3] * n[3],
25
+ m[0] * n[4] + m[2] * n[5] + m[4],
26
+ m[1] * n[4] + m[3] * n[5] + m[5]
27
+ ];
28
+ const buildAgentAvatarScene = (shape, { gaze, look, reducedMotion = false, time = 0 }) => {
29
+ const definition = getShapeDefinition(shape);
30
+ const { extra, eyes: placement } = SHAPE_GEOMETRY[shape];
31
+ const follow = gaze?.weight ?? (gaze ? 1 : 0);
32
+ const input = {
33
+ gaze,
34
+ reducedMotion,
35
+ state: "idle",
36
+ time,
37
+ view: {
38
+ pitch: look.pitch,
39
+ yaw: (1 - follow) * REST_YAW + look.yaw
40
+ }
41
+ };
42
+ const frame = avatarFrame(definition, input);
43
+ const pose = computePose({
44
+ ...input,
45
+ seed: engineSeed(definition.id)
46
+ });
47
+ const root = multiply(lookMatrix(look), frame.root);
48
+ const rx = placement.gap / LOGO_EYE.gap;
49
+ const gazeMix = look.gazeMix * (1 - follow);
50
+ const restX = pose.gazeX + REST_GAZE_X * (1 - follow);
51
+ const gazeX = restX + (look.gazeX - restX) * gazeMix;
52
+ const gazeY = pose.gazeY + (look.gazeY - pose.gazeY) * gazeMix;
53
+ const scene = {
54
+ body: [],
55
+ extra: null,
56
+ eyes: [],
57
+ paths: frame.paths
58
+ };
59
+ for (const item of frame.shapes) {
60
+ if (item.kind === "ribbon") continue;
61
+ const transform = matrixTransform(multiply(root, item.matrix));
62
+ if (item.kind === "slice") scene.body.push({
63
+ href: item.path,
64
+ transform
65
+ });
66
+ else {
67
+ const side = item.key === "eye-0" ? -1 : 1;
68
+ scene.eyes.push({
69
+ ...drawEye(placement.x + side * placement.gap / 2, placement.y, rx, side, {
70
+ arc: look.arc,
71
+ blink: pose.blink,
72
+ gazeX,
73
+ gazeY,
74
+ slit: look.slit,
75
+ squint: side === -1 ? look.squintL : look.squintR,
76
+ wide: look.wide
77
+ }),
78
+ transform
79
+ });
80
+ }
81
+ }
82
+ if (extra && scene.eyes.length > 0) scene.extra = {
83
+ d: extra,
84
+ transform: scene.eyes[0].transform
85
+ };
86
+ return scene;
87
+ };
88
+ export { buildAgentAvatarScene, engineSeed };
89
+
90
+ //# sourceMappingURL=scene.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scene.mjs","names":[],"sources":["../../src/AgentAvatar/scene.ts"],"sourcesContent":["/**\n * One live frame as plain draw data. `open-bot-avatar` provides the implied volume and the idle\n * breathing, blinking and wander; the state poses come from `look.ts` and the eyes are the Lobot\n * logo eyes.\n */\nimport { type AvatarFrame, avatarFrame, computePose, type Matrix } from 'open-bot-avatar';\n\nimport { drawEye, type EyeDrawing, LOGO_EYE } from './eyes';\nimport { type AvatarLook, lookMatrix, matrixTransform, REST_GAZE_X, REST_YAW } from './look';\nimport { getShapeDefinition, SHAPE_GEOMETRY } from './shapes';\nimport type { AgentAvatarShape } from './type';\n\nexport interface SceneUse {\n href: string;\n transform: string;\n}\n\nexport interface SceneEye extends EyeDrawing {\n transform: string;\n}\n\nexport interface AgentAvatarScene {\n /** Cross-sections of the body, back to front. */\n body: SceneUse[];\n /** Detached details of the silhouette, drawn on the face plane while it faces the viewer. */\n extra: { d: string; transform: string } | null;\n /** The eyes that face the viewer. */\n eyes: SceneEye[];\n /** Path definitions referenced by `body`. */\n paths: AvatarFrame['paths'];\n}\n\nexport interface SceneOptions {\n /** Look target from the pointer, with how strongly it applies. */\n gaze?: { weight?: number; x: number; y: number };\n look: AvatarLook;\n reducedMotion?: boolean;\n time?: number;\n}\n\n/** The engine's seed for a definition id (FNV-1a), so the eyes follow the pose the body uses. */\nexport const engineSeed = (id: string) => {\n let hash = 2_166_136_261;\n for (let index = 0; index < id.length; index++) {\n hash ^= id.charCodeAt(index);\n hash = Math.imul(hash, 16_777_619);\n }\n return hash >>> 0;\n};\n\nconst multiply = (m: readonly number[], n: readonly number[]): Matrix => [\n m[0] * n[0] + m[2] * n[1],\n m[1] * n[0] + m[3] * n[1],\n m[0] * n[2] + m[2] * n[3],\n m[1] * n[2] + m[3] * n[3],\n m[0] * n[4] + m[2] * n[5] + m[4],\n m[1] * n[4] + m[3] * n[5] + m[5],\n];\n\nexport const buildAgentAvatarScene = (\n shape: AgentAvatarShape,\n { gaze, look, reducedMotion = false, time = 0 }: SceneOptions,\n): AgentAvatarScene => {\n const definition = getShapeDefinition(shape);\n const { extra, eyes: placement } = SHAPE_GEOMETRY[shape];\n const follow = gaze?.weight ?? (gaze ? 1 : 0);\n // The engine drops its resting turn while following, so ours fades out with it.\n const view = { pitch: look.pitch, yaw: (1 - follow) * REST_YAW + look.yaw };\n const input = { gaze, reducedMotion, state: 'idle', time, view } as const;\n const frame = avatarFrame(definition, input);\n const pose = computePose({ ...input, seed: engineSeed(definition.id) });\n const root = multiply(lookMatrix(look), frame.root);\n const rx = placement.gap / LOGO_EYE.gap;\n // The pointer wins over a state's own look; the idle gaze rests to the right.\n const gazeMix = look.gazeMix * (1 - follow);\n const restX = pose.gazeX + REST_GAZE_X * (1 - follow);\n const gazeX = restX + (look.gazeX - restX) * gazeMix;\n const gazeY = pose.gazeY + (look.gazeY - pose.gazeY) * gazeMix;\n\n const scene: AgentAvatarScene = { body: [], extra: null, eyes: [], paths: frame.paths };\n\n for (const item of frame.shapes) {\n if (item.kind === 'ribbon') continue;\n const transform = matrixTransform(multiply(root, item.matrix));\n if (item.kind === 'slice') {\n scene.body.push({ href: item.path, transform });\n } else {\n const side = item.key === 'eye-0' ? -1 : 1;\n scene.eyes.push({\n ...drawEye(placement.x + (side * placement.gap) / 2, placement.y, rx, side, {\n arc: look.arc,\n blink: pose.blink,\n gazeX,\n gazeY,\n slit: look.slit,\n squint: side === -1 ? look.squintL : look.squintR,\n wide: look.wide,\n }),\n transform,\n });\n }\n }\n\n if (extra && scene.eyes.length > 0)\n scene.extra = { d: extra, transform: scene.eyes[0].transform };\n\n return scene;\n};\n"],"mappings":";;;;;;;;;;;AAyCA,MAAa,cAAc,OAAe;CACxC,IAAI,OAAO;CACX,KAAK,IAAI,QAAQ,GAAG,QAAQ,GAAG,QAAQ,SAAS;EAC9C,QAAQ,GAAG,WAAW,KAAK;EAC3B,OAAO,KAAK,KAAK,MAAM,QAAU;CACnC;CACA,OAAO,SAAS;AAClB;AAEA,MAAM,YAAY,GAAsB,MAAiC;CACvE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;CACvB,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;CACvB,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;CACvB,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;CACvB,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;CAC9B,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;AAChC;AAEA,MAAa,yBACX,OACA,EAAE,MAAM,MAAM,gBAAgB,OAAO,OAAO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