dsh-duet 0.1.9 → 0.2.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 (67) hide show
  1. package/README.md +19 -1
  2. package/assets/avatar/THREE-LICENSE.txt +21 -0
  3. package/assets/avatar/character.glb +0 -0
  4. package/assets/avatar/desktop/character.glb +0 -0
  5. package/assets/avatar/desktop/companion.mjs +18 -0
  6. package/assets/avatar/desktop/index.html +33 -0
  7. package/assets/avatar/desktop/manifest.json +10 -0
  8. package/assets/avatar/desktop/portrait.png +0 -0
  9. package/assets/avatar/desktop/renderer.mjs +4230 -0
  10. package/assets/avatar/portrait.png +0 -0
  11. package/assets/avatar/renderer.mjs +4230 -0
  12. package/desktop/bin/darwin-arm64/duet-avatar.app/Contents/Info.plist +36 -0
  13. package/desktop/bin/darwin-arm64/duet-avatar.app/Contents/MacOS/duet-avatar +0 -0
  14. package/desktop/bin/darwin-arm64/duet-avatar.app/Contents/Resources/duet companion.icns +0 -0
  15. package/desktop/bin/darwin-arm64/duet-avatar.app/Contents/_CodeSignature/CodeResources +128 -0
  16. package/desktop/bin/darwin-arm64/manifest.json +14 -0
  17. package/desktop/bin/win32-x64/duet-avatar.exe +0 -0
  18. package/desktop/bin/win32-x64/manifest.json +11 -0
  19. package/package.json +17 -5
  20. package/src/avatar/companion.html +33 -0
  21. package/src/avatar/companion.mjs +210 -0
  22. package/src/avatar/idle.mjs +9 -0
  23. package/src/avatar/lipsync.mjs +13 -0
  24. package/src/avatar/motion.mjs +93 -0
  25. package/src/avatar/renderer.mjs +90 -0
  26. package/src/avatar/surface.mjs +45 -0
  27. package/src/avatar/toolbar.mjs +49 -0
  28. package/src/client/audio.mjs +145 -10
  29. package/src/client/avatar-surfaces.mjs +83 -0
  30. package/src/client/avatar-tasks.mjs +68 -0
  31. package/src/client/avatar.mjs +218 -0
  32. package/src/client/browser.mjs +81 -33
  33. package/src/client/composer-bridge.mjs +5 -2
  34. package/src/client/composer.mjs +3 -3
  35. package/src/client/connection-hint.mjs +2 -1
  36. package/src/client/consent.mjs +3 -1
  37. package/src/client/controls-layout.mjs +21 -9
  38. package/src/client/entry.js +26 -3
  39. package/src/client/feedback.mjs +19 -4
  40. package/src/client/identity.mjs +2 -2
  41. package/src/client/input-effect.mjs +51 -0
  42. package/src/client/interactions.mjs +5 -1
  43. package/src/client/notice.mjs +1 -0
  44. package/src/client/rpc.mjs +23 -5
  45. package/src/client/settings.html +78 -4
  46. package/src/client/transport.mjs +2 -2
  47. package/src/client/tutorial-adapter.mjs +4 -4
  48. package/src/client/tutorial.mjs +5 -3
  49. package/src/host/assets.mjs +12 -0
  50. package/src/host/avatar-activity.mjs +24 -0
  51. package/src/host/avatar-assets.mjs +18 -0
  52. package/src/host/avatar.mjs +130 -0
  53. package/src/host/diagnostics.mjs +111 -7
  54. package/src/host/feedback-files.mjs +5 -1
  55. package/src/host/plugin.mjs +67 -4
  56. package/src/host/proxy.mjs +16 -6
  57. package/src/host/settings-migration.mjs +2 -1
  58. package/src/host/settings.mjs +19 -4
  59. package/src/host/stop-task.mjs +37 -0
  60. package/src/shared/avatar-activity.mjs +33 -0
  61. package/src/shared/avatar-menu-ui.mjs +85 -0
  62. package/src/shared/avatar-menu.mjs +83 -0
  63. package/src/shared/avatar-surface.mjs +24 -0
  64. package/src/shared/avatar-ui.mjs +91 -0
  65. package/src/shared/avatar.mjs +125 -0
  66. package/src/shared/nickname.mjs +13 -0
  67. package/src/shared/state.mjs +1 -1
@@ -0,0 +1,36 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleDevelopmentRegion</key>
6
+ <string>English</string>
7
+ <key>CFBundleDisplayName</key>
8
+ <string>duet companion</string>
9
+ <key>CFBundleExecutable</key>
10
+ <string>duet-avatar</string>
11
+ <key>CFBundleIdentifier</key>
12
+ <string>com.dsh-duet.companion</string>
13
+ <key>CFBundleInfoDictionaryVersion</key>
14
+ <string>6.0</string>
15
+ <key>CFBundleName</key>
16
+ <string>duet companion</string>
17
+ <key>CFBundlePackageType</key>
18
+ <string>APPL</string>
19
+ <key>CFBundleShortVersionString</key>
20
+ <string>0.1.0</string>
21
+ <key>CFBundleVersion</key>
22
+ <string>0.1.0</string>
23
+ <key>CSResourcesFileMapped</key>
24
+ <true/>
25
+ <key>LSMinimumSystemVersion</key>
26
+ <string>12.0</string>
27
+ <key>CFBundleIconFile</key>
28
+ <string>duet companion.icns</string>
29
+ <key>LSRequiresCarbon</key>
30
+ <true/>
31
+ <key>NSHighResolutionCapable</key>
32
+ <true/>
33
+ <key>LSUIElement</key>
34
+ <true/>
35
+ </dict>
36
+ </plist>
@@ -0,0 +1,128 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>files</key>
6
+ <dict>
7
+ <key>Resources/duet companion.icns</key>
8
+ <data>
9
+ SbxeK3cKSi8392Jqfp4ssRsLg9U=
10
+ </data>
11
+ </dict>
12
+ <key>files2</key>
13
+ <dict>
14
+ <key>Resources/duet companion.icns</key>
15
+ <dict>
16
+ <key>hash2</key>
17
+ <data>
18
+ wPeoJA6zFUT5eVE/3JCIZRJXm4Sw7jqjmMkgWHnOARk=
19
+ </data>
20
+ </dict>
21
+ </dict>
22
+ <key>rules</key>
23
+ <dict>
24
+ <key>^Resources/</key>
25
+ <true/>
26
+ <key>^Resources/.*\.lproj/</key>
27
+ <dict>
28
+ <key>optional</key>
29
+ <true/>
30
+ <key>weight</key>
31
+ <real>1000</real>
32
+ </dict>
33
+ <key>^Resources/.*\.lproj/locversion.plist$</key>
34
+ <dict>
35
+ <key>omit</key>
36
+ <true/>
37
+ <key>weight</key>
38
+ <real>1100</real>
39
+ </dict>
40
+ <key>^Resources/Base\.lproj/</key>
41
+ <dict>
42
+ <key>weight</key>
43
+ <real>1010</real>
44
+ </dict>
45
+ <key>^version.plist$</key>
46
+ <true/>
47
+ </dict>
48
+ <key>rules2</key>
49
+ <dict>
50
+ <key>.*\.dSYM($|/)</key>
51
+ <dict>
52
+ <key>weight</key>
53
+ <real>11</real>
54
+ </dict>
55
+ <key>^(.*/)?\.DS_Store$</key>
56
+ <dict>
57
+ <key>omit</key>
58
+ <true/>
59
+ <key>weight</key>
60
+ <real>2000</real>
61
+ </dict>
62
+ <key>^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/</key>
63
+ <dict>
64
+ <key>nested</key>
65
+ <true/>
66
+ <key>weight</key>
67
+ <real>10</real>
68
+ </dict>
69
+ <key>^.*</key>
70
+ <true/>
71
+ <key>^Info\.plist$</key>
72
+ <dict>
73
+ <key>omit</key>
74
+ <true/>
75
+ <key>weight</key>
76
+ <real>20</real>
77
+ </dict>
78
+ <key>^PkgInfo$</key>
79
+ <dict>
80
+ <key>omit</key>
81
+ <true/>
82
+ <key>weight</key>
83
+ <real>20</real>
84
+ </dict>
85
+ <key>^Resources/</key>
86
+ <dict>
87
+ <key>weight</key>
88
+ <real>20</real>
89
+ </dict>
90
+ <key>^Resources/.*\.lproj/</key>
91
+ <dict>
92
+ <key>optional</key>
93
+ <true/>
94
+ <key>weight</key>
95
+ <real>1000</real>
96
+ </dict>
97
+ <key>^Resources/.*\.lproj/locversion.plist$</key>
98
+ <dict>
99
+ <key>omit</key>
100
+ <true/>
101
+ <key>weight</key>
102
+ <real>1100</real>
103
+ </dict>
104
+ <key>^Resources/Base\.lproj/</key>
105
+ <dict>
106
+ <key>weight</key>
107
+ <real>1010</real>
108
+ </dict>
109
+ <key>^[^/]+$</key>
110
+ <dict>
111
+ <key>nested</key>
112
+ <true/>
113
+ <key>weight</key>
114
+ <real>10</real>
115
+ </dict>
116
+ <key>^embedded\.provisionprofile$</key>
117
+ <dict>
118
+ <key>weight</key>
119
+ <real>20</real>
120
+ </dict>
121
+ <key>^version\.plist$</key>
122
+ <dict>
123
+ <key>weight</key>
124
+ <real>20</real>
125
+ </dict>
126
+ </dict>
127
+ </dict>
128
+ </plist>
@@ -0,0 +1,14 @@
1
+ {
2
+ "schema": 2,
3
+ "protocol": 2,
4
+ "platform": "darwin-arm64",
5
+ "version": "0.2.0",
6
+ "sourceSha256": "d0d7cf5bdc1e3ffe6c78e901ae77dd2ce37c19ac274861c0d3e23244d14a0cf9",
7
+ "executable": "duet-avatar.app/Contents/MacOS/duet-avatar",
8
+ "files": {
9
+ "duet-avatar.app/Contents/Info.plist": "ebdb818ab02ce11b372aec7962f1fca66680c49671d3a4986bb2c52118aedc71",
10
+ "duet-avatar.app/Contents/MacOS/duet-avatar": "dad12855ac02761757270a72630b1a6e365919da109d51ff4de0a1ba0dfc49a5",
11
+ "duet-avatar.app/Contents/Resources/duet companion.icns": "c0f7a8240eb31544f979513fdc90886512579b84b0ee3aa398c9205879ce0119",
12
+ "duet-avatar.app/Contents/_CodeSignature/CodeResources": "5cfa4150d7c2c81d73f019e2da679ae7722a25f1f5a94ffea76bdfc0fd3b282f"
13
+ }
14
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "schema": 2,
3
+ "protocol": 2,
4
+ "platform": "win32-x64",
5
+ "version": "0.2.0",
6
+ "sourceSha256": "d0d7cf5bdc1e3ffe6c78e901ae77dd2ce37c19ac274861c0d3e23244d14a0cf9",
7
+ "executable": "duet-avatar.exe",
8
+ "files": {
9
+ "duet-avatar.exe": "ad3b363ad61e9d833f8f6039b26aa025f8ce79ab6c93befb1ac961b7fb4cbdbc"
10
+ }
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-duet",
3
- "version": "0.1.9",
3
+ "version": "0.2.0",
4
4
  "description": "duet(二重奏):只用语音就能操作 DSH,边听边说、随时插话的全双工语音助手。",
5
5
  "keywords": [
6
6
  "dsh-plugin",
@@ -22,9 +22,16 @@
22
22
  "scripts": {
23
23
  "test": "node scripts/test.mjs",
24
24
  "check": "node scripts/check-package.mjs",
25
- "test:browser": "node tests/browser/settings.mjs && node tests/browser/tutorial.mjs && node tests/browser/feedback.mjs && node tests/browser/connection-hint.mjs && node tests/browser/controls-layout.mjs && node tests/browser/resilience.mjs && node tests/browser/page-binding.mjs && node tests/browser/desktop-settings.mjs && node tests/browser/desktop-identity.mjs",
25
+ "test:browser": "node tests/browser/entry-loading.mjs && node tests/browser/settings.mjs && node tests/browser/tutorial.mjs && node tests/browser/feedback.mjs && node tests/browser/connection-hint.mjs && node tests/browser/controls-layout.mjs && node tests/browser/resilience.mjs && node tests/browser/page-binding.mjs && node tests/browser/stop-task.mjs && node tests/browser/desktop-settings.mjs && node tests/browser/desktop-identity.mjs && node tests/browser/audio-interruption.mjs",
26
26
  "test:host": "node tests/host/isolated-host.mjs",
27
- "prepack": "npm run check"
27
+ "build:avatar": "node scripts/build-avatar.mjs",
28
+ "build:avatar:desktop": "node scripts/build-avatar-desktop.mjs",
29
+ "test:avatar:desktop": "npm run build:avatar && node tests/browser/companion.mjs && node tests/browser/avatar-style.mjs",
30
+ "test:avatar": "node --test tests/unit/avatar.test.mjs && node tests/browser/avatar.mjs && node tests/browser/input-effect.mjs",
31
+ "test:avatar:surfaces": "node tests/browser/avatar-surfaces.mjs && node tests/browser/surface-origins.mjs",
32
+ "prepack": "npm run check",
33
+ "test:avatar:placement": "npm run build:avatar && node tests/browser/companion-placement.mjs",
34
+ "test:avatar:menu": "node --test tests/unit/avatar-menu.test.mjs && node tests/browser/avatar-menu.mjs && node tests/browser/companion-placement.mjs"
28
35
  },
29
36
  "type": "module",
30
37
  "main": "./src/host/plugin.mjs",
@@ -43,13 +50,18 @@
43
50
  "HEROICONS-LICENSE.txt",
44
51
  "src/",
45
52
  "config/",
46
- "assets/tutorial-audio/"
53
+ "assets/tutorial-audio/",
54
+ "assets/avatar/",
55
+ "desktop/bin/"
47
56
  ],
48
57
  "dependencies": {
49
58
  "ws": "^8.18.3"
50
59
  },
51
60
  "devDependencies": {
52
- "playwright": "1.58.2"
61
+ "@tauri-apps/cli": "2.12.4",
62
+ "esbuild": "0.25.12",
63
+ "playwright": "1.58.2",
64
+ "three": "0.186.1"
53
65
  },
54
66
  "dsh": {
55
67
  "bundle": {
@@ -0,0 +1,33 @@
1
+ <!doctype html><html lang="zh-CN"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
2
+ <title>duet</title><style>
3
+ html,body{margin:0;background:transparent;font:13px/1.6 system-ui;overflow:hidden;color:#e9f4ff;user-select:none}
4
+ #stage{--scale:1;position:absolute;left:0;top:0;width:280px;height:calc(210px + 280px * var(--scale));transform-origin:top left}
5
+ #avatar{position:absolute;left:calc((280px - 260px * var(--scale)) / 2);top:140px;height:calc(280px * var(--scale));width:calc(260px * var(--scale));cursor:grab;touch-action:none}
6
+ #bubble{position:absolute;bottom:calc(100% - 134px);left:12px;right:12px;padding:12px 14px;background:#142638ed;border:1px solid #8dc5ed45;border-radius:17px;box-shadow:0 5px 20px #0002;max-height:180px;overflow-y:auto;white-space:pre-wrap;overflow-wrap:anywhere;scrollbar-width:thin}
7
+ #bubble{box-sizing:border-box}#bubble[hidden]{display:none}#bubble[data-input=true]{background:#193b53f5;border-color:#7cb8e599}
8
+ #keyboard{display:inline-block;vertical-align:middle;margin-right:7px}#keyboard[hidden]{display:none}
9
+ #tools{position:absolute;top:calc(142px + 280px * var(--scale));left:16px;right:16px;display:flex;align-items:center;justify-content:center;gap:6px;padding:5px;border:1px solid transparent;border-radius:15px;background:transparent;isolation:isolate}
10
+ #tools{opacity:0;pointer-events:none;transition:opacity .5s ease}
11
+ #stage{pointer-events:none}#bubble{pointer-events:auto}
12
+ #tools[data-revealed=true]{opacity:1}
13
+ #tools[data-interactive=true]{pointer-events:auto}
14
+ #tools::before{content:'';position:absolute;inset:-1px;z-index:-1;pointer-events:none;border:1px solid #8dc5ed30;border-radius:inherit;background:#142638e8}
15
+ #brand{font-family:Inter,"PingFang SC",sans-serif;font-size:21px;font-weight:700;letter-spacing:-1.1px;line-height:1.1;padding:0 4px;text-shadow:0 1px 2px #000b}#dot{color:#ed9b35}
16
+ #tools button:not([aria-pressed=true]) svg{filter:drop-shadow(0 1px 1px #0009)}
17
+ button{position:relative;display:flex;align-items:center;justify-content:center;width:31px;height:30px;flex-shrink:0;border:0;border-radius:8px;background:transparent;color:#d5e6f4;cursor:pointer;padding:5px}
18
+ button:disabled{opacity:.4;cursor:wait}button:focus-visible{outline:2px solid #8dccff;outline-offset:2px}button[aria-pressed=true]:not([aria-busy=true]){background:#dcefff;color:#185a89}
19
+ #tools:not([data-keyboard=true]) button:focus{outline:none}
20
+ button svg{width:20px;height:20px}[data-connecting-ring]{position:absolute;inset:0;pointer-events:none}[data-connecting-ring][hidden]{display:none}[data-connecting-ring] svg{width:100%;height:100%;overflow:visible}[data-connecting-ring] rect{fill:none;stroke:#ed9b35;stroke-width:2;stroke-linecap:round;stroke-dasharray:28 72;animation:connect 1.6s linear infinite}@keyframes connect{to{stroke-dashoffset:-100}}
21
+ #status{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
22
+ #shell{position:absolute;left:0;top:0;transform-origin:top left}#shell[data-panel=true] #stage{left:50px;top:280px}
23
+ #surface{position:absolute;left:12px;top:12px;width:356px;max-height:256px;overflow:auto;box-sizing:border-box;background:#142638f5;color:#e9f4ff;border:1px solid #8dc5ed65;border-radius:18px;padding:18px;box-shadow:0 8px 26px #0003;white-space:pre-wrap;overflow-wrap:anywhere;user-select:text}
24
+ #surface[hidden]{display:none}#surface h3{font-size:17px;margin:0 0 10px}#surface button{display:inline-block;width:auto;height:auto;min-height:32px;margin:8px 5px 0 0;padding:6px 10px;border:1px solid #8dc5ed70;background:#254866}#surface input{accent-color:#80c2ff}#surface .gesture-note{color:#ffd39a;margin:0 0 10px}
25
+ [data-teaching]{outline:2px solid #80c2ff!important;box-shadow:0 0 0 5px #80c2ff40}[data-teaching]::after{content:'↓';position:absolute;top:-30px;left:8px;color:#80c2ff;font-size:24px}
26
+ </style><div id="shell"><section id="surface" hidden role="region" aria-label="duet 提示和教学"></section><div id="stage" data-size="large">
27
+ <div id="bubble" hidden><svg id="keyboard" hidden width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><rect x="2" y="5" width="20" height="14" rx="3"/><path d="M6 9h1m3 0h1m3 0h1m3 0h1M6 12h1m3 0h1m3 0h1m3 0h1M7 15h10"/></svg><span id="text"></span></div>
28
+ <div id="avatar" aria-label="duet 3D 形象"></div>
29
+ <div id="tools"><span id="brand">duet<span id="dot">.</span></span><button id="size" type="button" aria-label="形象大小"></button>
30
+ <button data-mode="online" aria-label="打开交互模式" title="交互模式" disabled><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7.5 3.75 3 8.25m0 0 4.5 4.5M3 8.25h18m-4.5 3L21 15.75m0 0-4.5 4.5M21 15.75H3"/></svg></button>
31
+ <button data-mode="tts_only" aria-label="打开播报模式" title="播报模式" disabled><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 8h4l5-4v16l-5-4H4zM17 8a6 6 0 0 1 0 8m3-11a10 10 0 0 1 0 14"/></svg></button>
32
+ <button id="close" aria-label="隐藏拟人角色" title="隐藏拟人角色"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" aria-hidden="true"><path d="m6 6 12 12M18 6 6 18"/></svg></button></div>
33
+ <div id="status" role="status">正在连接 DSH</div></div></div><script type="module" src="./companion.mjs"></script></html>
@@ -0,0 +1,210 @@
1
+ import {mountAvatarRenderer} from './renderer.mjs'
2
+ import {avatarFrame,avatarInputEffect,avatarSize,AvatarHeartbeat} from '../shared/avatar.mjs'
3
+ import {sizeButton,nextAvatarSize,avatarCloseConfirmation} from '../shared/avatar-ui.mjs'
4
+ import {mountAvatarToolbar,maskContains} from './toolbar.mjs'
5
+ import {mountCompanionSurface} from './surface.mjs'
6
+ import {AVATAR_UI_PROTOCOL} from '../shared/avatar-surface.mjs'
7
+ import {mountAvatarMenu} from '../shared/avatar-menu-ui.mjs'
8
+ import {avatarGeometry} from '../shared/avatar-activity.mjs'
9
+ const config=window.__DUET_AVATAR__,invoke=(name,args)=>window.__TAURI__.core.invoke(name,args)
10
+ if(!config || !/^ws:\/\/127\.0\.0\.1:\d+\/?$/.test(config.url) || !/^[a-f0-9]{64}$/.test(config.token))throw Error('companion must be started by duet')
11
+ const $=id=>document.getElementById(id),socket=new WebSocket(config.url,[`duet-avatar-${config.token}`])
12
+ let ready=false,failed=false,closed=false,last=Date.now(),model,inputTimer,maskPending=null,maskAgain=false,sizePending=null,appliedSize=null
13
+ let desiredSize=avatarSize(config.size)
14
+ let desiredPanel=false, surfaceSide=null,menu,bubbleSize='medium',lastNotice
15
+ let frame={mode:'off',ready:false,rms:0,viseme:'A',text:'',utterance:''},input=null,alphaMask=[],pointerUnlisten,viewportUnlisten
16
+ let visibleViewport=null
17
+ let geometryBusy=false,lastGeometry=''
18
+ async function reportGeometry(){
19
+ if(!ready||closed||geometryBusy)return
20
+ geometryBusy=true
21
+ try{const geometry=await invoke('avatar_geometry'),r=$('avatar').getBoundingClientRect(),s=geometry.scale
22
+ const position=avatarGeometry({space:'desktop_physical',total_resolution:geometry.total_resolution,desktop_origin:geometry.desktop_origin,scale:s,avatar_position:{x:geometry.window_origin.x+r.x*s,y:geometry.window_origin.y+r.y*s,width:r.width*s,height:r.height*s}})
23
+ const encoded=JSON.stringify(position);if(position&&encoded!==lastGeometry){lastGeometry=encoded;send({type:'avatar_geometry',position})}
24
+ }catch{}finally{geometryBusy=false}
25
+ }
26
+ const viewport=()=>{
27
+ if(!visibleViewport)return[0,0,innerWidth,innerHeight]
28
+ const [x,y,w,h]=visibleViewport,left=Math.max(0,x),top=Math.max(0,y)
29
+ return[left,top,Math.max(1,Math.min(innerWidth,x+w)-left),Math.max(1,Math.min(innerHeight,y+h)-top)]
30
+ }
31
+ const toolbar=mountAvatarToolbar({tools:$('tools'),avatar:$('avatar'),hitTest:(x,y)=>maskContains(alphaMask,rect($('avatar')),x,y),onChange:()=>{void refreshMask()}})
32
+ const characterAnchor={getBoundingClientRect(){const a=$('avatar').getBoundingClientRect(),t=$('tools').getBoundingClientRect();return{left:a.left,width:a.width,top:a.top,bottom:Math.max(a.bottom,t.bottom)}}}
33
+ const confirmation=avatarCloseConfirmation({floating:true,origin:'avatar',anchor:()=>characterAnchor,viewport,onChange:()=>toolbar.setConfirmation(desiredPanel||Boolean(confirmation.element)||menu?.active)})
34
+ const surface=mountCompanionSurface($('surface'),{send:value=>send(value),changed:(open,target)=>{
35
+ desiredPanel=open;if(!open)surfaceSide=null;toolbar.setConfirmation(open||Boolean(confirmation.element)||menu?.active)
36
+ for(const b of document.querySelectorAll('[data-mode]'))b.toggleAttribute('data-teaching',b.dataset.mode===target)
37
+ positionSurface()
38
+ void refreshMask()
39
+ }})
40
+ menu=mountAvatarMenu({anchor:()=>characterAnchor,viewport,send:async value=>{
41
+ if(value.action==='hide')$('close').click()
42
+ else {
43
+ if(['open_dsh','view','settings'].includes(value.action)){
44
+ try{await invoke('focus_dsh')}
45
+ catch{menu.result({type:'menu_result',request_id:value.request_id,ok:false,message:'未能唤起 DSH,请确认所属窗口仍然打开;若刚更新插件,请更新桌面形象。'});return}
46
+ }
47
+ send(value)
48
+ }
49
+ },changed:()=>{toolbar.setConfirmation(desiredPanel||Boolean(confirmation.element)||menu.active);void refreshMask()}})
50
+ const pointerReady=Promise.all([
51
+ window.__TAURI__.event.listen('avatar-pointer',e=>toolbar.pointer(e.payload)).then(unlisten=>{if(closed)unlisten();else pointerUnlisten=unlisten}),
52
+ window.__TAURI__.event.listen('avatar-viewport',e=>{
53
+ if(!Array.isArray(e.payload)||e.payload.length!==4||!e.payload.every(Number.isFinite))return
54
+ if(visibleViewport?.every((n,i)=>n===e.payload[i]))return
55
+ visibleViewport=e.payload;positionSurface();window.dispatchEvent(new Event('resize'));void refreshMask()
56
+ }).then(unlisten=>{if(closed)unlisten();else viewportUnlisten=unlisten})
57
+ ]).catch(()=>{failed=true;send({type:'failed'});close()})
58
+ sizeButton($('size'),desiredSize)
59
+ const send=value=>{if(socket.readyState===1&&socket.bufferedAmount<16000)socket.send(JSON.stringify(value))}
60
+ function positionSurface(){
61
+ const bubble=$('bubble'),panel=$('surface'),nodes=[bubble,panel].filter(n=>!n.hidden)
62
+ if(!nodes.length)return
63
+ const [x,y,w,h]=viewport(),avatar=$('avatar').getBoundingClientRect(),tools=$('tools').getBoundingClientRect()
64
+ const fit=avatar.width/$('avatar').offsetWidth||1,gap=12*fit
65
+ // Measure content only after setting its final width/height limits. Never use
66
+ // yesterday's constrained height to calculate today's position.
67
+ bubble.style.width='256px';bubble.style.right='auto'
68
+ for(const n of nodes)n.style.maxHeight=(Math.max(1,h-24)/fit)+'px'
69
+ const bubbleHeight=bubble.hidden?0:Math.min({small:90,medium:180,large:260}[bubbleSize]*fit,bubble.getBoundingClientRect().height)
70
+ const panelHeight=panel.hidden?0:Math.min(256*fit,panel.getBoundingClientRect().height)
71
+ const separation=nodes.length>1?gap:0,needed=bubbleHeight+panelHeight+separation
72
+ const above=Math.max(0,avatar.top-gap-(y+12)),below=Math.max(0,y+h-12-(tools.bottom+gap))
73
+ let side=desiredPanel?surfaceSide:null
74
+ if(!side || (side==='above'?above:below)<Math.min(needed,80*fit))
75
+ side=above>=needed?'above':below>=needed?'below':above>=below?'above':'below'
76
+ if(desiredPanel)surfaceSide=side
77
+ const space=side==='above'?above:below
78
+ const bubbleBudget=panel.hidden?space:Math.min(bubbleHeight,Math.max(0,(space-separation)*.3))
79
+ const bh=Math.min(bubbleHeight,bubbleBudget),ph=Math.min(panelHeight,Math.max(0,space-bh-separation))
80
+ if(!bubble.hidden)bubble.style.maxHeight=Math.max(1,bh/fit)+'px'
81
+ if(!panel.hidden)panel.style.maxHeight=Math.max(1,ph/fit)+'px'
82
+ let edge=side==='above'?avatar.top-gap:tools.bottom+gap
83
+ for(const n of nodes){
84
+ const rect=n.getBoundingClientRect(),parent=n.offsetParent.getBoundingClientRect()
85
+ const left=Math.max(x+12,Math.min(avatar.left+avatar.width/2-rect.width/2,x+w-12-rect.width))
86
+ const top=side==='above'?edge-rect.height:edge
87
+ n.style.left=((left-parent.left)/fit)+'px';n.style.top=((top-parent.top)/fit)+'px'
88
+ n.style.bottom='auto';n.style.right='auto'
89
+ edge=side==='above'?top-gap:top+rect.height+gap
90
+ }
91
+ // Measurement temporarily expands the bubble and can clamp scrollTop to zero.
92
+ // Follow the newest line only after restoring the final visible height.
93
+ if(!bubble.hidden)bubble.scrollTop=bubble.scrollHeight
94
+ }
95
+ const caption=()=>{
96
+ const text=input?.text||frame.text
97
+ const changed=$('bubble').hidden===Boolean(text)||$('text').textContent!==text
98
+ $('bubble').hidden=!text;$('bubble').dataset.input=String(Boolean(input));$('keyboard').toggleAttribute('hidden',!input)
99
+ if($('text').textContent!==text)$('text').textContent=text
100
+ if(changed)positionSurface()
101
+ }
102
+ const clearInput=()=>{clearTimeout(inputTimer);input=null;caption()}
103
+ const controls=()=>{
104
+ for(const b of document.querySelectorAll('[data-mode]')){
105
+ const active=frame.mode===b.dataset.mode
106
+ b.disabled=false;b.setAttribute('aria-pressed',String(active));b.setAttribute('aria-busy',String(active&&!frame.ready))
107
+ b.querySelector('[data-connecting-ring]').hidden=!(active&&!frame.ready)
108
+ b.setAttribute('aria-label',`${active?'关闭':'打开'}${b.dataset.mode==='online'?'交互模式':'播报模式'}`)
109
+ b.title=active&&!frame.ready?`正在连接${b.dataset.mode==='online'?'交互模式':'播报模式'}`:b.getAttribute('aria-label')
110
+ }
111
+ $('dot').style.color=frame.ready?'#7fd6a6':'#ed9b35'
112
+ const status=frame.mode==='off'?'语音未开启':!frame.ready?'正在连接…':frame.mode==='online'?'交互模式':'播报模式'
113
+ if($('status').textContent!==status)$('status').textContent=status
114
+ }
115
+ const close=()=>{
116
+ if(closed)return;closed=true;menu.dispose();confirmation.dispose();toolbar.dispose();pointerUnlisten?.();viewportUnlisten?.();clearInterval(timer);clearInterval(maskTimer);clearTimeout(inputTimer)
117
+ model?.update({...frame,rms:0,text:''});model?.dispose();socket.close()
118
+ void invoke('hide_avatar').catch(()=>{})
119
+ }
120
+ const notifyReady=()=>{if(failed)send({type:'failed'});else if(ready)send({type:'ready',protocol:AVATAR_UI_PROTOCOL})}
121
+ // Serialize native resize and hit-mask updates, including rapid preference changes.
122
+ // The owning page persists the preference; this window never opens a second store.
123
+ const requestSize=size=>{
124
+ desiredSize=avatarSize(size)
125
+ if(sizePending || desiredSize===appliedSize)return sizePending||Promise.resolve()
126
+ sizePending=(async()=>{
127
+ await maskPending
128
+ while(!closed&&desiredSize!==appliedSize){
129
+ // Reserve a stable transparent carrier before showing the window.
130
+ // Popup open/close and countdown updates must never move the avatar.
131
+ const target=desiredSize,panel=true,result=await invoke('set_avatar_size',{size:target,panel})
132
+ if(!result||!Number.isFinite(result.scale)||result.scale<=0||result.scale>1)throw Error('invalid_avatar_layout')
133
+ $('shell').style.transform=`scale(${result.fit??1})`;$('shell').dataset.panel=String(panel);$('stage').dataset.size=target
134
+ $('stage').style.setProperty('--scale',result.scale)
135
+ sizeButton($('size'),target);appliedSize=target
136
+ toolbar.refresh();positionSurface()
137
+ }
138
+ })().catch(()=>{failed=true;send({type:'failed'});close()}).finally(()=>{sizePending=null})
139
+ return sizePending
140
+ }
141
+ try{model=mountAvatarRenderer($('avatar'),{modelURL:'./character.glb',onReady(){
142
+ void Promise.all([pointerReady,requestSize(desiredSize)]).then(async()=>{if(closed||failed)return;ready=true;await refreshMask();if(closed)return;notifyReady();return invoke('show_avatar')})
143
+ .catch(()=>{failed=true;send({type:'failed'});close()})
144
+ },onError(){failed=true;notifyReady()}})}catch{failed=true}
145
+ socket.onopen=notifyReady
146
+ const liveness=new AvatarHeartbeat(1000)
147
+ socket.onmessage=e=>{
148
+ liveness.touch()
149
+ try{
150
+ const message=JSON.parse(e.data)
151
+ if(message.type==='frame'){
152
+ frame=avatarFrame(message);last=Date.now();model?.update(frame);void requestSize(frame.size)
153
+ if(frame.mode==='off')clearInput();caption();controls()
154
+ }else if(message.type==='input_effect'){
155
+ input=avatarInputEffect(message);last=Date.now();clearTimeout(inputTimer);caption();inputTimer=setTimeout(clearInput,1600)
156
+ }else if(message.type==='clear_input_effect'){clearInput()}
157
+ else if(message.type==='surface'){surface.update(message);last=Date.now()}
158
+ else if(message.type==='local_state'){
159
+ menu.update(message);bubbleSize=message.bubble;positionSurface();last=Date.now()
160
+ if(message.toast&&message.toast!==lastNotice&&frame.mode==='off'&&message.items.find(i=>i.id===message.toast)?.status==='completed')
161
+ model?.update({...frame,text:'完成了',utterance:'notice-'+message.toast})
162
+ lastNotice=message.toast
163
+ }
164
+ else if(message.type==='menu_result'){menu.result(message);last=Date.now()}
165
+ else if(message.type==='owner_focus'){void invoke('remember_dsh').catch(()=>{});last=Date.now()}
166
+ else if(message.type==='alive'){} // Host liveness, independent of browser animation timers.
167
+ else throw Error('invalid_avatar_message')
168
+ }catch{socket.close(1008,'invalid_avatar_message')}
169
+ }
170
+ socket.onclose=close;socket.onerror=close
171
+ const timer=setInterval(()=>{
172
+ if(liveness.expired()){close();return}
173
+ if(Date.now()-last>1500){model?.update({...frame,rms:0,text:''});frame={...frame,text:''};clearInput()}
174
+ send({type:'alive'})
175
+ void reportGeometry()
176
+ },1000)
177
+ const rect=node=>{const r=node.getBoundingClientRect();return[r.x,r.y,r.width,r.height]}
178
+ function refreshMask(){
179
+ if(!ready||sizePending||closed||document.hidden)return
180
+ if(maskPending){maskAgain=true;return maskPending}
181
+ maskPending=(async()=>{
182
+ do{
183
+ maskAgain=false
184
+ if(closed||sizePending||document.hidden)break
185
+ const regions=confirmation.element?[rect(confirmation.element)]:menu.active?[[0,0,innerWidth,innerHeight]]:[...toolbar.regions(),...($('bubble').hidden?[]:[rect($('bubble'))]),...($('surface').hidden?[]:[rect($('surface'))]),...menu.regions()]
186
+ alphaMask=model.hitMask()
187
+ await invoke('avatar_hit_mask',{mask:alphaMask,avatar:rect($('avatar')),regions})
188
+ }while(maskAgain)
189
+ })().catch(()=>{}).finally(()=>{maskPending=null})
190
+ return maskPending
191
+ }
192
+ const maskTimer=setInterval(()=>{if(!maskPending)void refreshMask()},350)
193
+ for(const b of document.querySelectorAll('[data-mode]')){
194
+ const ring=document.createElement('span');ring.dataset.connectingRing='';ring.hidden=true
195
+ ring.innerHTML='<svg viewBox="0 0 30 30" preserveAspectRatio="none" aria-hidden="true"><rect x="1" y="1" width="28" height="28" rx="7" pathLength="100"/></svg>';b.append(ring)
196
+ b.onclick=()=>send({type:'mode',mode:b.dataset.mode})
197
+ }
198
+ $('close').onclick=async()=>{if(await confirmation.ask()&&!closed){send({type:'hide'});close()}}
199
+ $('size').onclick=()=>send({type:'size',size:nextAvatarSize(appliedSize||desiredSize)})
200
+ let down=null
201
+ $('avatar').tabIndex=0
202
+ $('avatar').oncontextmenu=e=>{down=null;menu.open(e)}
203
+ $('avatar').onkeydown=e=>{if(e.key==='ContextMenu'||e.key==='F10'&&e.shiftKey){down=null;menu.open(e)}}
204
+ $('avatar').onpointerdown=e=>{if(e.button===0&&!e.ctrlKey&&!menu.active)down={x:e.clientX,y:e.clientY}}
205
+ $('avatar').onpointermove=e=>{
206
+ if(down&&!menu.active&&e.buttons===1&&Math.hypot(e.clientX-down.x,e.clientY-down.y)>4){down=null;void invoke('drag_avatar').catch(()=>{})}
207
+ }
208
+ window.addEventListener('pointerup',()=>{down=null});window.addEventListener('blur',()=>{down=null})
209
+ window.addEventListener('resize',()=>{positionSurface();void refreshMask()})
210
+ window.addEventListener('pagehide',close,{once:true})
@@ -0,0 +1,9 @@
1
+ // Adapted from the user-provided DSH v1 desktop character demo.
2
+ export function rng(seed=6281){let s=seed>>>0;return()=>{s+=0x6D2B79F5;let t=Math.imul(s^(s>>>15),1|s);t^=t+Math.imul(t^(t>>>7),61|t);return((t^(t>>>14))>>>0)/4294967296;};}
3
+ const smooth=x=>{x=Math.max(0,Math.min(1,x));return x*x*(3-2*x);};
4
+ export class IdleDirector{
5
+ constructor(seed=Date.now()){this.seed=seed;this.rand=rng(seed);this.poses=[{t:0,d:0,p:[0,0,0,0]}];this.blinks=[];this.extend(300);}
6
+ extend(until){const r=this.rand;let last=this.poses.at(-1);while(last.t+last.d<until){const neutral=r()<.20;const next={t:last.t+last.d+2.0+r()*3.5,d:.9+r()*1.5,p:neutral?[0,0,0,0]:[(r()-.5)*.11,(r()-.5)*.24,(r()-.5)*.10,(r()-.5)*1.3]};this.poses.push(next);last=next;}let t=this.blinks.at(-1)?.end??1.5;while(t<until){t+=3.1+r()*4.8;let d=.15+r()*.09;this.blinks.push({t,d,end:t+d});if(r()<.13){t+=d+.12;d=.16;this.blinks.push({t,d,end:t+d});}}}
7
+ sample(t){if(t>this.poses.at(-1).t-20)this.extend(t+180);let i=this.poses.findLastIndex(p=>p.t<=t);if(i<0)i=0;const a=this.poses[Math.max(0,i-1)],b=this.poses[i],f=smooth((t-b.t)/Math.max(.001,b.d)),p=b.p.map((v,k)=>a.p[k]+(v-a.p[k])*f);let blink=0;const ev=this.blinks.find(b=>t>=b.t&&t<=b.end);if(ev){const q=(t-ev.t)/ev.d;blink=q<.40?smooth(q/.40):1-smooth((q-.40)/.60);}const breath=Math.sin(t*1.38+.27*Math.sin(t*.13));return {nod:p[0]+.004*Math.sin(t*.79),yaw:p[1],roll:p[2]+.004*Math.sin(t*.53+1),gaze:p[3]+.08*Math.sin(t*.33),blink,breath,smile:.08+.025*Math.sin(t*.18)};}
8
+ }
9
+ export class Spring{constructor(w=8,z=.67){this.w=w;this.z=z;this.x=0;this.v=0;}step(target,dt){let n=Math.max(1,Math.ceil(dt/.008));dt/=n;for(let j=0;j<n;j++){this.v+=(this.w*this.w*(target-this.x)-2*this.z*this.w*this.v)*dt;this.x+=this.v*dt;}return this.x;}}
@@ -0,0 +1,13 @@
1
+ // Adapted from the user-provided DSH v1 desktop character demo.
2
+ export class LipSyncFilter {
3
+ constructor(){this.reset();}
4
+ reset(){this.time=0;this.envelope=0;this.voiced=false;this.quietFor=0;this.current='A';this.pending='A';this.pendingFor=0;this.lastSwitch=-1;this.switches=0;this.mix={A:1,I:0,U:0,E:0,O:0};this.weights={A:0,I:0,U:0,E:0,O:0};}
5
+ step(rms,candidate,dt,active=true){dt=Math.max(.001,Math.min(.1,dt));this.time+=dt;
6
+ if(!active){this.voiced=false;this.quietFor=0;}else if(rms>.012){this.voiced=true;this.quietFor=0;}else if(rms<.007){this.quietFor+=dt;if(this.quietFor>.055)this.voiced=false;}
7
+ if(this.voiced&&active){if(candidate!==this.pending){this.pending=candidate;this.pendingFor=0;}else this.pendingFor+=dt;if(this.pending!==this.current&&this.pendingFor>=.07&&this.time-this.lastSwitch>=.20){this.current=this.pending;this.lastSwitch=this.time;this.switches++;}}else{this.pendingFor=0;}
8
+ const target=active&&this.voiced?Math.min(.90,Math.pow(Math.max(0,rms-.008)*5.2,.72)):0;
9
+ const tau=target>this.envelope?.10:.115;this.envelope+=(target-this.envelope)*(1-Math.exp(-dt/tau));if(this.envelope<.001)this.envelope=0;
10
+ for(const k of Object.keys(this.mix)){this.mix[k]+=((k===this.current?1:0)-this.mix[k])*(1-Math.exp(-dt/.095));this.weights[k]=this.mix[k]*this.envelope;}
11
+ return this.weights;
12
+ }
13
+ }
@@ -0,0 +1,93 @@
1
+ import { expressionFor } from '../shared/avatar.mjs'
2
+
3
+ const WORDS = /哈哈|呵呵|笑死|好笑|开心|不可以|不行|不是|不能|不要|不对|没有|拒绝|好的|好嘞|收到|可以|明白|没问题|对的|是的|完成了/gu
4
+ const RANDOM = ['glance_left', 'glance_right', 'tilt']
5
+ const PREFIXES = new Set(WORDS.source.split('|').flatMap(word=>
6
+ Array.from({length:word.length-1},(_,i)=>word.slice(0,i+1))))
7
+ export const MOTION_DURATION_MS = 1800
8
+ export const MOTION_REPEAT_GAP_MS = 5000
9
+
10
+ // The explicitly enabled character owns its motion policy, independently of
11
+ // the operating system's reduced-motion preference.
12
+ export function gesturePose(action) {
13
+ const {kind, elapsed, envelope} = action
14
+ const wave = Math.sin(elapsed * (kind==='nod'?8:9)) * envelope
15
+ return {
16
+ nod: kind==='nod' ? .24*wave : 0,
17
+ yaw: kind==='shake' ? .28*wave
18
+ : kind==='glance_left' ? .12*envelope : kind==='glance_right' ? -.12*envelope : 0,
19
+ roll: kind==='tilt' ? .09*envelope : 0,
20
+ }
21
+ }
22
+
23
+ /** Uses already-played captions, never speculative model text. One motion owns
24
+ * the rig until completion; repetition cooldown is measured from completion. */
25
+ export class MotionDirector {
26
+ constructor(random = Math.random) {
27
+ this.random = random
28
+ this.active = null
29
+ this.pending = null
30
+ this.lastEnd = new Map()
31
+ this.lastFinished = -Infinity
32
+ this.text = ''; this.utterance = ''; this.changedAt = 0; this.sequence = 0
33
+ this.nextRandomAt = null
34
+ }
35
+ scheduleRandom(now) { this.nextRandomAt = now + 4000 + this.random()*4000 }
36
+ eligible(kind, now) {
37
+ return this.active?.kind !== kind && now - (this.lastEnd.get(kind) ?? -Infinity) >= MOTION_REPEAT_GAP_MS
38
+ }
39
+ captions(input, now) {
40
+ if (input.utterance && input.utterance !== this.utterance) {
41
+ this.utterance = input.utterance; this.text = ''; this.pending = null
42
+ }
43
+ const text = input.text || ''
44
+ if (!text || text === this.text) return
45
+ // Captions are bounded sliding prefixes. Retain only the overlap, so an
46
+ // earlier keyword cannot retrigger whenever the next character appears.
47
+ let overlap = Math.min(this.text.length, text.length)
48
+ while (overlap && !text.startsWith(this.text.slice(-overlap))) overlap--
49
+ this.text = text; this.changedAt = now
50
+ const waitingSingle = this.pending?.single ? this.pending : null
51
+ if (waitingSingle) this.pending = null
52
+ let candidate
53
+ for (const match of text.matchAll(WORDS)) {
54
+ if (match.index + match[0].length > overlap) candidate = {kind:expressionFor(match[0]), single:false}
55
+ }
56
+ if (!candidate && /(?:^|[,。!?!?\s])([好不])[,。!?!?\s]*$/u.test(text)) {
57
+ const match = text.match(/([好不])[,。!?!?\s]*$/u)
58
+ const kind = expressionFor(match[1])
59
+ if (match.index + 1 > overlap || waitingSingle?.kind === kind) candidate = {kind, single:true}
60
+ }
61
+ if (candidate && this.eligible(candidate.kind, now)) {
62
+ this.pending = candidate.single && waitingSingle?.kind === candidate.kind ? waitingSingle
63
+ : {...candidate, at:now, after:now+(candidate.single?250:0)}
64
+ }
65
+ }
66
+ sample(input, now) {
67
+ if (this.nextRandomAt === null) this.scheduleRandom(now)
68
+ if (this.active && now >= this.active.at + MOTION_DURATION_MS) {
69
+ const end = this.active.at + MOTION_DURATION_MS
70
+ this.lastEnd.set(this.active.kind, end); this.lastFinished = end; this.active = null
71
+ this.scheduleRandom(end)
72
+ }
73
+ this.captions(input, now)
74
+ if (this.pending && (now-this.pending.at > 3000 || !this.eligible(this.pending.kind, now))) this.pending = null
75
+ if (!this.active && this.pending && now >= this.pending.after) {
76
+ this.active = {kind:this.pending.kind, at:now}; this.pending = null; this.sequence++
77
+ }
78
+ // No speech is required. Semantic cues take priority when both are due;
79
+ // an already-running motion always finishes before the next one starts.
80
+ const partial = PREFIXES.has((input.text || '').trim()) && now-this.changedAt < 350
81
+ if (!this.active && !this.pending && !partial && now >= this.nextRandomAt) {
82
+ const choices = RANDOM.filter(kind=>this.eligible(kind,now))
83
+ if (choices.length) {
84
+ this.active = {kind:choices[Math.min(choices.length-1,Math.floor(this.random()*choices.length))], at:now}
85
+ this.sequence++
86
+ }
87
+ else this.scheduleRandom(now)
88
+ }
89
+ const elapsed = this.active ? (now-this.active.at)/1000 : 0
90
+ const envelope = this.active ? Math.sin(Math.PI*(now-this.active.at)/MOTION_DURATION_MS)**2 : 0
91
+ return {kind:this.active?.kind || '', elapsed, envelope, sequence:this.sequence}
92
+ }
93
+ }