agent-robot-avatar 0.5.2 → 0.7.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 (43) hide show
  1. package/CHANGELOG.md +56 -7
  2. package/README.md +93 -16
  3. package/agent-robot-avatar-lite.js +44 -0
  4. package/agent-robot-avatar.js +2 -2
  5. package/index.d.ts +94 -17
  6. package/lite.d.ts +5 -0
  7. package/package.json +12 -5
  8. package/src/agent-robot-avatar-actions.js +17 -14
  9. package/src/agent-robot-avatar-core.js +5 -2
  10. package/src/agent-robot-avatar-gestures.js +9 -0
  11. package/src/agent-robot-avatar-runtime.js +58 -12
  12. package/src/agent-robot-avatar-skin-patterns.js +234 -0
  13. package/src/agent-robot-avatar-skins.js +256 -0
  14. package/src/agent-robot-avatar-version.js +1 -1
  15. package/src/agent-robot-avatar-waiting.js +30 -6
  16. package/src/skins/catalog.js +218 -0
  17. package/src/skins/collection-materials.js +118 -0
  18. package/src/skins/eyelids.js +32 -0
  19. package/src/skins/glaze-variants.js +29 -0
  20. package/src/skins/layered-texture.js +162 -0
  21. package/src/skins/material-data.js +111 -0
  22. package/src/skins/material-library.js +302 -0
  23. package/src/skins/metal-tint.js +11 -0
  24. package/src/skins/more-materials.js +69 -0
  25. package/src/skins/native.js +754 -0
  26. package/src/skins/paints.js +3 -0
  27. package/src/skins/revised-materials.js +44 -0
  28. package/src/skins/second-pass-materials.js +71 -0
  29. package/src/skins/soft-materials.js +111 -0
  30. package/src/skins/sports-materials.js +38 -0
  31. package/src/skins/wood-materials.js +68 -0
  32. package/assets/support/alipay.png +0 -0
  33. package/assets/support/wechat-pay.png +0 -0
  34. package/docs/README.de.md +0 -186
  35. package/docs/README.es.md +0 -186
  36. package/docs/README.fr.md +0 -186
  37. package/docs/README.ja.md +0 -186
  38. package/docs/README.ko.md +0 -186
  39. package/docs/README.pt.md +0 -186
  40. package/docs/README.ru.md +0 -186
  41. package/docs/README.zh-CN.md +0 -190
  42. package/docs/README.zh-TW.md +0 -186
  43. package/src/agent-robot-avatar-antenna-flash.js +0 -127
@@ -1,127 +0,0 @@
1
- import AgentRobotAvatar, { registerAvatarExtension } from './agent-robot-avatar-extension-host.js';
2
-
3
- const proto = AgentRobotAvatar.prototype;
4
-
5
- const FLASH_DEFAULTS = Object.freeze({
6
- period: 1000,
7
- duty: 0.80,
8
- });
9
-
10
- const FLASH_MULTIPLIER = Object.freeze({
11
- input: 1.20,
12
- send: 1.00,
13
- success: 1.10,
14
- warning: 1.00,
15
- angry: 0.90,
16
- error: 0.80,
17
- surprise: 0.80,
18
- });
19
-
20
- const runtimeWindow = typeof window !== 'undefined' ? window : null;
21
- const flashConfig = (runtimeWindow?.AgentRobotAvatarAntennaFlashConfig && typeof runtimeWindow.AgentRobotAvatarAntennaFlashConfig === 'object')
22
- ? runtimeWindow.AgentRobotAvatarAntennaFlashConfig
23
- : {};
24
- for (const [key, value] of Object.entries(FLASH_DEFAULTS)) {
25
- if (!Number.isFinite(Number(flashConfig[key]))) flashConfig[key] = value;
26
- }
27
- if (runtimeWindow) {
28
- runtimeWindow.AgentRobotAvatarAntennaFlashConfig = flashConfig;
29
- runtimeWindow.AgentRobotAvatarAntennaFlashDefaults = FLASH_DEFAULTS;
30
- }
31
-
32
- function configNumber(key, fallback, min, max) {
33
- const value = Number(flashConfig[key]);
34
- if (!Number.isFinite(value)) return fallback;
35
- return Math.max(min, Math.min(max, value));
36
- }
37
-
38
- function flashPeriod(action) {
39
- const base = configNumber('period', FLASH_DEFAULTS.period, 200, 4000);
40
- return base * (FLASH_MULTIPLIER[action] || 1);
41
- }
42
-
43
- function flashDuty() {
44
- return configNumber('duty', FLASH_DEFAULTS.duty, 0.05, 0.95);
45
- }
46
-
47
- function normalizeFlashAction(action) {
48
- if (action === 'blocked' || action === 'policy-blocked') return 'angry';
49
- if (action === 'system-error' || action === 'connection-error') return 'error';
50
- return action;
51
- }
52
-
53
- function beginAntennaFlash(instance, action) {
54
- const normalized = normalizeFlashAction(action);
55
- if (!FLASH_MULTIPLIER[normalized]) {
56
- instance._antennaFlashAction = null;
57
- return null;
58
- }
59
- const token = (instance._antennaFlashToken || 0) + 1;
60
- instance._antennaFlashToken = token;
61
- instance._antennaFlashAction = normalized;
62
- instance._antennaFlashStart = performance.now();
63
- return token;
64
- }
65
-
66
- function clearAntennaFlash(instance, token = null) {
67
- if (token != null && token !== instance._antennaFlashToken) return;
68
- instance._antennaFlashAction = null;
69
- const dot = instance._antennaDot;
70
- if (dot) dot.style.opacity = '1';
71
- }
72
-
73
- proto.setAntennaFlash = function(enabled = true) {
74
- this._antennaFlashEnabled = enabled !== false;
75
- if (!this._antennaFlashEnabled) clearAntennaFlash(this);
76
- return this;
77
- };
78
-
79
- function drawAntennaFlash(now) {
80
- const dot = this._antennaDot;
81
- if (!dot) return;
82
-
83
- if (this._antennaFlashAction === 'input' && !this._inputWanted && this._state !== 'input') {
84
- clearAntennaFlash(this);
85
- }
86
-
87
- const action = this._antennaFlashAction;
88
- const enabled = this._antennaFlashEnabled === true;
89
- if (!enabled || !action || !FLASH_MULTIPLIER[action]) {
90
- dot.style.opacity = '1';
91
- return;
92
- }
93
-
94
- const period = flashPeriod(action);
95
- const phase = ((now - (this._antennaFlashStart || now)) % period) / period;
96
- dot.style.opacity = phase < flashDuty() ? '1' : '0';
97
- }
98
-
99
- registerAvatarExtension({
100
- name: 'antenna-flash',
101
- beforePlay(name, context) {
102
- const action = normalizeFlashAction(name);
103
- context.antennaFlashAction = action;
104
- context.antennaFlashToken = FLASH_MULTIPLIER[action]
105
- ? beginAntennaFlash(this, action)
106
- : null;
107
- if (!context.antennaFlashToken) clearAntennaFlash(this);
108
- },
109
- afterPlay(_name, result, context) {
110
- const action = context.antennaFlashAction;
111
- const token = context.antennaFlashToken;
112
- if (context.error) {
113
- clearAntennaFlash(this, token);
114
- return;
115
- }
116
- if (token && action !== 'input' && result && typeof result.then === 'function') {
117
- Promise.resolve(result).finally(() => clearAntennaFlash(this, token));
118
- }
119
- },
120
- reset() {
121
- clearAntennaFlash(this);
122
- },
123
- draw: drawAntennaFlash,
124
- });
125
-
126
- export { AgentRobotAvatar, FLASH_DEFAULTS };
127
- export default AgentRobotAvatar;