@celljs/ta-web 4.27.0 → 4.28.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.
- package/esm/browser/assistant/assistant-role.d.ts +9 -4
- package/esm/browser/assistant/assistant-role.js +17 -5
- package/esm/browser/assistant/assistant-task-util.d.ts +6 -0
- package/esm/browser/assistant/assistant-task-util.js +12 -1
- package/esm/browser/assistant/assistant-view.js +4 -1
- package/esm/browser/assistant/assistant.d.ts +2 -1
- package/esm/browser/assistant/assistant.js +9 -7
- package/esm/browser/assistant/call-conversing.d.ts +45 -0
- package/esm/browser/assistant/call-conversing.js +91 -0
- package/esm/browser/assistant/call-face.d.ts +13 -0
- package/esm/browser/assistant/call-face.js +81 -0
- package/esm/browser/assistant/call-keeper.d.ts +8 -4
- package/esm/browser/assistant/call-keeper.js +32 -11
- package/esm/browser/assistant/call-partnering.d.ts +37 -0
- package/esm/browser/assistant/call-partnering.js +79 -0
- package/esm/browser/assistant/call-scenes.d.ts +25 -0
- package/esm/browser/assistant/call-scenes.js +82 -0
- package/esm/browser/assistant/call-screen.d.ts +3 -0
- package/esm/browser/assistant/call-screen.js +15 -0
- package/esm/browser/assistant/mic-sense.d.ts +31 -0
- package/esm/browser/assistant/mic-sense.js +119 -0
- package/esm/browser/assistant/noise-gate.d.ts +32 -0
- package/esm/browser/assistant/noise-gate.js +66 -0
- package/esm/browser/assistant/pcm-util.d.ts +10 -0
- package/esm/browser/assistant/pcm-util.js +55 -0
- package/esm/browser/assistant/read-aloud.d.ts +2 -1
- package/esm/browser/assistant/realtime-voice-protocol.d.ts +84 -0
- package/esm/browser/assistant/realtime-voice-protocol.js +40 -0
- package/esm/browser/assistant/realtime-voice.d.ts +50 -62
- package/esm/browser/assistant/realtime-voice.js +213 -134
- package/esm/browser/assistant/spoken-timeline.d.ts +27 -0
- package/esm/browser/assistant/spoken-timeline.js +49 -0
- package/esm/browser/assistant/voice-call-bar.d.ts +9 -2
- package/esm/browser/assistant/voice-call-bar.js +81 -31
- package/esm/browser/assistant/voice-call-protocol.d.ts +61 -4
- package/esm/browser/assistant/voice-call.d.ts +16 -23
- package/esm/browser/assistant/voice-call.js +134 -117
- package/esm/browser/assistant/voice-reading.d.ts +83 -0
- package/esm/browser/assistant/voice-reading.js +150 -0
- package/esm/browser/avatar/dino-talk.d.ts +15 -0
- package/esm/browser/avatar/dino-talk.js +34 -0
- package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
- package/esm/browser/components/conversation-scroll-util.d.ts +8 -1
- package/esm/browser/components/conversation-scroll-util.js +21 -0
- package/esm/browser/components/conversation-scroll.js +10 -11
- package/esm/browser/components/gallery.js +28 -7
- package/esm/browser/components/host-view.d.ts +1 -1
- package/esm/browser/components/image-pull.d.ts +64 -0
- package/esm/browser/components/image-pull.js +202 -0
- package/esm/browser/components/kept-call-bar.js +2 -1
- package/esm/browser/components/lightbox.d.ts +1 -1
- package/esm/browser/components/lightbox.js +57 -2
- package/esm/browser/components/markdown.d.ts +3 -1
- package/esm/browser/components/markdown.js +8 -4
- package/esm/browser/components/partner-row.js +2 -1
- package/esm/browser/components/relay-services.d.ts +9 -3
- package/esm/browser/components/relay-services.js +73 -35
- package/esm/browser/components/session-view.js +4 -2
- package/esm/browser/components/settings-parts.js +2 -0
- package/esm/browser/components/ta-avatar.d.ts +15 -1
- package/esm/browser/components/ta-avatar.js +38 -5
- package/esm/browser/components/voice-services.js +6 -1
- package/esm/browser/extension/web-api-call.d.ts +64 -2
- package/esm/browser/extension/web-api-contributions.d.ts +1 -0
- package/esm/browser/extension/web-api-partners.d.ts +2 -0
- package/esm/browser/extension/web-extension-api.d.ts +6 -6
- package/esm/browser/extension/web-extension-context.js +1 -0
- package/esm/browser/extension/web-extension-protocol.d.ts +3 -1
- package/esm/browser/extension/web-extension-run.d.ts +3 -2
- package/esm/browser/extension/web-extension-run.js +2 -0
- package/esm/browser/i18n/locales.d.ts +24 -5
- package/esm/browser/i18n/messages-ja.js +25 -6
- package/esm/browser/i18n/messages-zh-tw.js +25 -6
- package/esm/browser/i18n/messages.d.ts +23 -4
- package/esm/browser/i18n/messages.js +50 -12
- package/esm/browser/markdown/code-renderers.d.ts +2 -0
- package/esm/browser/markdown/code-renderers.js +2 -0
- package/esm/browser/screen/page-answers.d.ts +2 -1
- package/esm/browser/screen/page-answers.js +7 -4
- package/esm/browser/settings/settings-protocol.d.ts +2 -0
- package/esm/browser/settings/settings-protocol.js +2 -0
- package/esm/browser/style/chat-list.d.ts +1 -1
- package/esm/browser/style/chat-list.js +1 -1
- package/esm/browser/style/conversation.d.ts +1 -1
- package/esm/browser/style/conversation.js +6 -1
- package/esm/browser/style/device.js +1 -0
- package/esm/browser/style/dialogs.d.ts +1 -1
- package/esm/browser/style/dialogs.js +1 -1
- package/esm/browser/style/layout.d.ts +1 -1
- package/esm/browser/style/layout.js +135 -57
- package/esm/browser/style/shell.d.ts +1 -1
- package/esm/browser/style/shell.js +8 -0
- package/esm/browser/style/video-call.d.ts +2 -0
- package/esm/browser/style/video-call.js +52 -0
- package/esm/browser/style.js +2 -0
- package/esm/browser/util/desktop.d.ts +10 -1
- package/esm/browser/util/desktop.js +10 -0
- package/esm/browser/util/image-pull.d.ts +61 -0
- package/esm/browser/util/image-pull.js +88 -0
- package/esm/browser/util/spoken.d.ts +3 -3
- package/esm/browser/util/spoken.js +4 -4
- package/esm/browser/video-call/call-camera.d.ts +59 -0
- package/esm/browser/video-call/call-camera.js +188 -0
- package/esm/browser/video-call/call-window.d.ts +19 -0
- package/esm/browser/video-call/call-window.js +80 -0
- package/esm/browser/video-call/clip-plan.d.ts +47 -0
- package/esm/browser/video-call/clip-plan.js +60 -0
- package/esm/browser/video-call/face-clips.d.ts +33 -0
- package/esm/browser/video-call/face-clips.js +93 -0
- package/esm/browser/video-call/face-files.d.ts +31 -0
- package/esm/browser/video-call/face-files.js +77 -0
- package/esm/browser/video-call/video-call-view.d.ts +19 -0
- package/esm/browser/video-call/video-call-view.js +214 -0
- package/esm/browser/video-call/video-face.d.ts +13 -0
- package/esm/browser/video-call/video-face.js +497 -0
- package/esm/browser/workbench-hosts.d.ts +1 -0
- package/esm/browser/workbench-protocol.d.ts +2 -0
- package/esm/browser/workbench-util.d.ts +5 -0
- package/esm/browser/workbench-util.js +18 -0
- package/esm/browser/workbench.d.ts +6 -0
- package/esm/browser/workbench.js +36 -5
- package/lib/browser/assistant/assistant-role.d.ts +9 -4
- package/lib/browser/assistant/assistant-role.js +17 -5
- package/lib/browser/assistant/assistant-task-util.d.ts +6 -0
- package/lib/browser/assistant/assistant-task-util.js +11 -0
- package/lib/browser/assistant/assistant-view.js +3 -0
- package/lib/browser/assistant/assistant.d.ts +2 -1
- package/lib/browser/assistant/assistant.js +9 -7
- package/lib/browser/assistant/call-conversing.d.ts +46 -0
- package/lib/browser/assistant/call-conversing.js +96 -0
- package/lib/browser/assistant/call-face.d.ts +14 -0
- package/lib/browser/assistant/call-face.js +117 -0
- package/lib/browser/assistant/call-keeper.d.ts +8 -4
- package/lib/browser/assistant/call-keeper.js +32 -11
- package/lib/browser/assistant/call-partnering.d.ts +38 -0
- package/lib/browser/assistant/call-partnering.js +83 -0
- package/lib/browser/assistant/call-scenes.d.ts +26 -0
- package/lib/browser/assistant/call-scenes.js +85 -0
- package/lib/browser/assistant/call-screen.d.ts +3 -0
- package/lib/browser/assistant/call-screen.js +15 -0
- package/lib/browser/assistant/mic-sense.d.ts +32 -0
- package/lib/browser/assistant/mic-sense.js +123 -0
- package/lib/browser/assistant/noise-gate.d.ts +33 -0
- package/lib/browser/assistant/noise-gate.js +71 -0
- package/lib/browser/assistant/pcm-util.d.ts +11 -0
- package/lib/browser/assistant/pcm-util.js +58 -0
- package/lib/browser/assistant/read-aloud.d.ts +2 -1
- package/lib/browser/assistant/realtime-voice-protocol.d.ts +85 -0
- package/lib/browser/assistant/realtime-voice-protocol.js +43 -0
- package/lib/browser/assistant/realtime-voice.d.ts +50 -62
- package/lib/browser/assistant/realtime-voice.js +217 -138
- package/lib/browser/assistant/spoken-timeline.d.ts +28 -0
- package/lib/browser/assistant/spoken-timeline.js +53 -0
- package/lib/browser/assistant/voice-call-bar.d.ts +9 -2
- package/lib/browser/assistant/voice-call-bar.js +81 -30
- package/lib/browser/assistant/voice-call-protocol.d.ts +61 -4
- package/lib/browser/assistant/voice-call.d.ts +16 -23
- package/lib/browser/assistant/voice-call.js +134 -117
- package/lib/browser/assistant/voice-reading.d.ts +84 -0
- package/lib/browser/assistant/voice-reading.js +156 -0
- package/lib/browser/avatar/dino-talk.d.ts +16 -0
- package/lib/browser/avatar/dino-talk.js +37 -0
- package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
- package/lib/browser/components/conversation-scroll-util.d.ts +8 -1
- package/lib/browser/components/conversation-scroll-util.js +21 -0
- package/lib/browser/components/conversation-scroll.js +10 -11
- package/lib/browser/components/gallery.js +28 -7
- package/lib/browser/components/host-view.d.ts +1 -1
- package/lib/browser/components/image-pull.d.ts +65 -0
- package/lib/browser/components/image-pull.js +206 -0
- package/lib/browser/components/kept-call-bar.js +2 -1
- package/lib/browser/components/lightbox.d.ts +1 -1
- package/lib/browser/components/lightbox.js +57 -2
- package/lib/browser/components/markdown.d.ts +3 -1
- package/lib/browser/components/markdown.js +7 -3
- package/lib/browser/components/partner-row.js +2 -1
- package/lib/browser/components/relay-services.d.ts +9 -3
- package/lib/browser/components/relay-services.js +71 -33
- package/lib/browser/components/session-view.js +3 -1
- package/lib/browser/components/settings-parts.js +2 -0
- package/lib/browser/components/ta-avatar.d.ts +15 -1
- package/lib/browser/components/ta-avatar.js +38 -5
- package/lib/browser/components/voice-services.js +5 -0
- package/lib/browser/extension/web-api-call.d.ts +64 -2
- package/lib/browser/extension/web-api-contributions.d.ts +1 -0
- package/lib/browser/extension/web-api-partners.d.ts +2 -0
- package/lib/browser/extension/web-extension-api.d.ts +6 -6
- package/lib/browser/extension/web-extension-context.js +1 -0
- package/lib/browser/extension/web-extension-protocol.d.ts +3 -1
- package/lib/browser/extension/web-extension-run.d.ts +3 -2
- package/lib/browser/extension/web-extension-run.js +2 -0
- package/lib/browser/i18n/locales.d.ts +24 -5
- package/lib/browser/i18n/messages-ja.js +25 -6
- package/lib/browser/i18n/messages-zh-tw.js +25 -6
- package/lib/browser/i18n/messages.d.ts +23 -4
- package/lib/browser/i18n/messages.js +50 -12
- package/lib/browser/markdown/code-renderers.d.ts +2 -0
- package/lib/browser/markdown/code-renderers.js +3 -1
- package/lib/browser/screen/page-answers.d.ts +2 -1
- package/lib/browser/screen/page-answers.js +7 -4
- package/lib/browser/settings/settings-protocol.d.ts +2 -0
- package/lib/browser/settings/settings-protocol.js +2 -0
- package/lib/browser/style/chat-list.d.ts +1 -1
- package/lib/browser/style/chat-list.js +1 -1
- package/lib/browser/style/conversation.d.ts +1 -1
- package/lib/browser/style/conversation.js +6 -1
- package/lib/browser/style/device.js +1 -0
- package/lib/browser/style/dialogs.d.ts +1 -1
- package/lib/browser/style/dialogs.js +1 -1
- package/lib/browser/style/layout.d.ts +1 -1
- package/lib/browser/style/layout.js +135 -57
- package/lib/browser/style/shell.d.ts +1 -1
- package/lib/browser/style/shell.js +8 -0
- package/lib/browser/style/video-call.d.ts +3 -0
- package/lib/browser/style/video-call.js +55 -0
- package/lib/browser/style.js +2 -0
- package/lib/browser/util/desktop.d.ts +10 -1
- package/lib/browser/util/desktop.js +10 -0
- package/lib/browser/util/image-pull.d.ts +62 -0
- package/lib/browser/util/image-pull.js +91 -0
- package/lib/browser/util/spoken.d.ts +3 -3
- package/lib/browser/util/spoken.js +4 -4
- package/lib/browser/video-call/call-camera.d.ts +60 -0
- package/lib/browser/video-call/call-camera.js +192 -0
- package/lib/browser/video-call/call-window.d.ts +20 -0
- package/lib/browser/video-call/call-window.js +83 -0
- package/lib/browser/video-call/clip-plan.d.ts +48 -0
- package/lib/browser/video-call/clip-plan.js +64 -0
- package/lib/browser/video-call/face-clips.d.ts +34 -0
- package/lib/browser/video-call/face-clips.js +96 -0
- package/lib/browser/video-call/face-files.d.ts +32 -0
- package/lib/browser/video-call/face-files.js +82 -0
- package/lib/browser/video-call/video-call-view.d.ts +20 -0
- package/lib/browser/video-call/video-call-view.js +250 -0
- package/lib/browser/video-call/video-face.d.ts +14 -0
- package/lib/browser/video-call/video-face.js +533 -0
- package/lib/browser/workbench-hosts.d.ts +1 -0
- package/lib/browser/workbench-protocol.d.ts +2 -0
- package/lib/browser/workbench-util.d.ts +5 -0
- package/lib/browser/workbench-util.js +18 -0
- package/lib/browser/workbench.d.ts +6 -0
- package/lib/browser/workbench.js +35 -4
- package/package.json +7 -7
- package/public/faces/README.md +27 -0
- package/public/faces/clap.mp4 +0 -0
- package/public/faces/dance.mp4 +0 -0
- package/public/faces/happy.mp4 +0 -0
- package/public/faces/heart.mp4 +0 -0
- package/public/faces/idle-1.mp4 +0 -0
- package/public/faces/idle-2.mp4 +0 -0
- package/public/faces/idle-3.mp4 +0 -0
- package/public/faces/laugh.mp4 +0 -0
- package/public/faces/lips.json +1 -0
- package/public/faces/listening.mp4 +0 -0
- package/public/faces/poster.jpg +0 -0
- package/public/faces/shy.mp4 +0 -0
- package/public/faces/sorry.mp4 +0 -0
- package/public/faces/stretch.mp4 +0 -0
- package/public/faces/surprised.mp4 +0 -0
- package/public/faces/talk-1.mp4 +0 -0
- package/public/faces/talk-2.mp4 +0 -0
- package/public/faces/think-2.mp4 +0 -0
- package/public/faces/thinking.mp4 +0 -0
- package/public/faces/wave.mp4 +0 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** A video call (VideoCallView): the whole screen of a phone, a panel or a window of its own on a computer, small and floating elsewhere. */
|
|
2
|
+
export const VIDEO_CALL_STYLE = `
|
|
3
|
+
.ta-video-call { position: fixed; z-index: 70; overflow: hidden; color: #fff; background: radial-gradient(120% 75% at 50% 22%, #444b5b 0%, #23262e 58%, #15171c 100%); -webkit-user-select: none; user-select: none; font-family: var(--ta-font, inherit); }
|
|
4
|
+
.ta-video-full { inset: 0; animation: ta-video-in 260ms var(--ta-ease); }
|
|
5
|
+
.ta-video-panel { right: 24px; bottom: 24px; width: 360px; height: min(640px, calc(100vh - 48px)); border-radius: 22px; box-shadow: var(--ta-shadow-pop); border: 1px solid rgba(255, 255, 255, 0.08); animation: ta-video-in 260ms var(--ta-ease); }
|
|
6
|
+
.ta-video-window { inset: 0; }
|
|
7
|
+
body.ta-video-window { margin: 0; overflow: hidden; background: #15171c; }
|
|
8
|
+
.ta-video-window-host { position: fixed; inset: 0; }
|
|
9
|
+
.ta-video-call.ta-video-window { app-region: drag; -webkit-app-region: drag; }
|
|
10
|
+
.ta-video-window .ta-video-round, .ta-video-window .ta-video-self, .ta-video-window .ta-video-caption { app-region: no-drag; -webkit-app-region: no-drag; }
|
|
11
|
+
.ta-video-window .ta-video-tap { display: none; }
|
|
12
|
+
.ta-video-mini { top: calc(env(safe-area-inset-top, 0px) + 64px); right: 12px; width: 96px; height: 136px; border-radius: 14px; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35); cursor: pointer; touch-action: none; transition: left 260ms var(--ta-ease), right 260ms var(--ta-ease), transform 260ms var(--ta-ease); animation: ta-video-in 220ms var(--ta-ease); }
|
|
13
|
+
.ta-video-mini[data-side='left'] { right: auto; left: 12px; }
|
|
14
|
+
@media (pointer: fine) { .ta-video-mini { width: 150px; height: 212px; top: auto; bottom: 24px; right: 24px; } .ta-video-mini[data-side='left'] { left: 24px; } }
|
|
15
|
+
@keyframes ta-video-in { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }
|
|
16
|
+
.ta-video-person { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
|
|
17
|
+
.ta-video-person::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 42%; background: linear-gradient(transparent, rgba(0, 0, 0, 0.55)); pointer-events: none; }
|
|
18
|
+
.ta-video-mini .ta-video-person::after { height: 35%; }
|
|
19
|
+
.ta-video-clips { position: absolute; inset: 0; opacity: 0; transition: opacity 400ms var(--ta-ease); }
|
|
20
|
+
.ta-video-person.ta-ready .ta-video-clips { opacity: 1; }
|
|
21
|
+
.ta-video-clip { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; opacity: 0; transition: opacity 180ms linear; pointer-events: none; }
|
|
22
|
+
.ta-video-clip.ta-front { opacity: 1; }
|
|
23
|
+
.ta-video-mouth { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
|
|
24
|
+
.ta-video-tap { position: absolute; inset: 0; border: 0; padding: 0; background: none; cursor: pointer; }
|
|
25
|
+
.ta-video-dino { width: 58%; max-width: 280px; aspect-ratio: 1; }
|
|
26
|
+
.ta-video-failed { position: absolute; top: 58%; font-size: calc(13px * var(--ta-font-scale)); opacity: 0.7; }
|
|
27
|
+
.ta-video-top { position: absolute; z-index: 1; top: calc(env(safe-area-inset-top, 0px) + 12px); left: 12px; right: 12px; display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; }
|
|
28
|
+
.ta-video-window .ta-video-top { top: 30px; }
|
|
29
|
+
.ta-video-title { grid-column: 2; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45); }
|
|
30
|
+
.ta-video-title span { max-width: 100%; font-size: calc(16px * var(--ta-font-scale)); font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
|
|
31
|
+
.ta-video-title small { font-size: calc(12px * var(--ta-font-scale)); opacity: 0.8; }
|
|
32
|
+
.ta-video-round { width: 56px; height: 56px; flex: none; border: 0; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; background: rgba(255, 255, 255, 0.18); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); cursor: pointer; transition: background 160ms, transform 120ms; }
|
|
33
|
+
.ta-video-round:active { transform: scale(0.94); }
|
|
34
|
+
.ta-video-round:disabled { opacity: 0.4; cursor: default; }
|
|
35
|
+
.ta-video-round.ta-off { background: rgba(255, 255, 255, 0.92); color: #23262e; }
|
|
36
|
+
.ta-video-end { width: 64px; height: 64px; background: #ff3b30; }
|
|
37
|
+
.ta-video-spacer { visibility: hidden; }
|
|
38
|
+
.ta-video-minimize, .ta-video-pin { width: 40px; height: 40px; background: rgba(0, 0, 0, 0.22); }
|
|
39
|
+
.ta-video-pin { grid-column: 3; }
|
|
40
|
+
.ta-video-pin.ta-on { background: rgba(255, 255, 255, 0.92); color: #23262e; }
|
|
41
|
+
.ta-video-self { position: absolute; z-index: 1; top: calc(env(safe-area-inset-top, 0px) + 68px); right: 14px; width: 28%; max-width: 124px; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 12px; background: #0b0c0f; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); }
|
|
42
|
+
.ta-video-window .ta-video-self { top: 84px; }
|
|
43
|
+
.ta-video-self.ta-mirror { transform: scaleX(-1); }
|
|
44
|
+
.ta-video-caption { position: absolute; z-index: 1; left: 24px; right: 24px; bottom: calc(env(safe-area-inset-bottom, 0px) + 124px); text-align: center; font-size: calc(16px * var(--ta-font-scale)); line-height: 1.5; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
|
|
45
|
+
.ta-video-caption.ta-mine { opacity: 0.78; }
|
|
46
|
+
.ta-video-controls { position: absolute; z-index: 1; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom, 0px) + 32px); display: flex; align-items: center; justify-content: center; gap: 36px; }
|
|
47
|
+
.ta-video-panel .ta-video-controls, .ta-video-window .ta-video-controls { gap: 28px; bottom: 24px; }
|
|
48
|
+
.ta-video-panel .ta-video-caption, .ta-video-window .ta-video-caption { bottom: 112px; font-size: calc(15px * var(--ta-font-scale)); }
|
|
49
|
+
.ta-video-mini-phase { position: absolute; z-index: 1; left: 50%; bottom: 6px; transform: translateX(-50%); max-width: calc(100% - 12px); padding: 2px 8px; border-radius: 999px; font-size: calc(11px * var(--ta-font-scale)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: rgba(0, 0, 0, 0.4); }
|
|
50
|
+
@media (prefers-reduced-motion: reduce) { .ta-video-call { animation: none; } }
|
|
51
|
+
`;
|
|
52
|
+
//# sourceMappingURL=video-call.js.map
|
package/esm/browser/style.js
CHANGED
|
@@ -12,6 +12,7 @@ import { SHELL_STYLE } from './style/shell.js';
|
|
|
12
12
|
import { SURFACES_STYLE } from './style/surfaces.js';
|
|
13
13
|
import { TASKS_STYLE } from './style/tasks.js';
|
|
14
14
|
import { TINTS_STYLE } from './style/tints.js';
|
|
15
|
+
import { VIDEO_CALL_STYLE } from './style/video-call.js';
|
|
15
16
|
/**
|
|
16
17
|
* The styles of the web client: neutral surfaces, light and dark, for wide and narrow screens, fingers and
|
|
17
18
|
* pointers (the breakpoints are DeviceMedia's). In this
|
|
@@ -32,5 +33,6 @@ export const STYLE = [
|
|
|
32
33
|
SURFACES_STYLE,
|
|
33
34
|
PHONE_STYLE,
|
|
34
35
|
SHARED_STYLE,
|
|
36
|
+
VIDEO_CALL_STYLE,
|
|
35
37
|
].join('');
|
|
36
38
|
//# sourceMappingURL=style.js.map
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/** What Ta Desktop can do for the page beyond a tab of a browser. */
|
|
2
|
-
export type DesktopFeature = 'webview' | 'debugWebview' | 'showItemInFolder' | 'browserData' | 'recentShots' | 'notices' | 'speech' | 'restart' | 'links' | 'call'
|
|
2
|
+
export type DesktopFeature = 'webview' | 'debugWebview' | 'showItemInFolder' | 'browserData' | 'recentShots' | 'notices' | 'speech' | 'restart' | 'links' | 'call'
|
|
3
|
+
/** It lets the page open the window of a video call (window.open('about:blank', 'ta-video-call')). */
|
|
4
|
+
| 'callWindow'
|
|
5
|
+
/** It pins the window of a video call above every window, or not (callWindowPin). */
|
|
6
|
+
| 'callWindowPin';
|
|
3
7
|
/** The file manager of the system, from Ta Desktop: {@link WebDesktop} of the extension API. */
|
|
4
8
|
export interface DesktopFileManager {
|
|
5
9
|
/** Node's `process.platform` of the machine: what the file manager is called there. */
|
|
@@ -79,6 +83,11 @@ export declare namespace DesktopUtil {
|
|
|
79
83
|
/** The sign-ins of the user's browsers, where Ta Desktop can read them (macOS, Windows). */
|
|
80
84
|
/** Tells Ta Desktop a call goes on, or ended: it does not restart under it. None outside Ta Desktop. */
|
|
81
85
|
function calling(scope?: object): ((active: boolean) => void) | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* Whether Ta Desktop pins the window of a video call above every window, after pinning or unpinning it when
|
|
88
|
+
* `pinned` is given; it keeps the choice for the next call. None outside Ta Desktop, nor in an older one.
|
|
89
|
+
*/
|
|
90
|
+
function callWindowPin(scope?: object): ((pinned?: boolean) => Promise<boolean>) | undefined;
|
|
82
91
|
function browserData(scope?: object): DesktopBrowserData | undefined;
|
|
83
92
|
/** `debugWebview` of Ta Desktop; `undefined` elsewhere. */
|
|
84
93
|
function debugWebview(scope?: object): DebugWebview | undefined;
|
|
@@ -42,6 +42,16 @@ export var DesktopUtil;
|
|
|
42
42
|
return has('call', scope) && typeof call === 'function' ? active => void Promise.resolve(call(active)).catch(() => undefined) : undefined;
|
|
43
43
|
}
|
|
44
44
|
DesktopUtil.calling = calling;
|
|
45
|
+
/**
|
|
46
|
+
* Whether Ta Desktop pins the window of a video call above every window, after pinning or unpinning it when
|
|
47
|
+
* `pinned` is given; it keeps the choice for the next call. None outside Ta Desktop, nor in an older one.
|
|
48
|
+
*/
|
|
49
|
+
function callWindowPin(scope = globalThis) {
|
|
50
|
+
var _a;
|
|
51
|
+
const pin = (_a = scope.taDesktop) === null || _a === void 0 ? void 0 : _a.callWindowPin;
|
|
52
|
+
return has('callWindowPin', scope) && typeof pin === 'function' ? async (pinned) => (await pin(pinned)) === true : undefined;
|
|
53
|
+
}
|
|
54
|
+
DesktopUtil.callWindowPin = callWindowPin;
|
|
45
55
|
function browserData(scope = globalThis) {
|
|
46
56
|
var _a;
|
|
47
57
|
const data = (_a = scope.taDesktop) === null || _a === void 0 ? void 0 : _a.browserData;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/** A box on the screen: where it starts and how big it is. */
|
|
2
|
+
export interface PullRect {
|
|
3
|
+
left: number;
|
|
4
|
+
top: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
}
|
|
8
|
+
/** How the picture is drawn as the finger pulls it: moved by `x`, `y` and at `scale` about where the finger set off. */
|
|
9
|
+
export interface PullPlace {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
scale: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A finger pulls a picture over the page down to close it, as the viewers of pictures of a phone (WeChat, Photos):
|
|
16
|
+
* the picture follows the finger, smaller as it goes down, the page under it shows through; let go far enough,
|
|
17
|
+
* or flicked down, it flies back to where it was opened from (its thumbnail), else it comes back. Pure, for the tests.
|
|
18
|
+
*/
|
|
19
|
+
export declare namespace ImagePullUtil {
|
|
20
|
+
/** Down all the height of the screen, it is this much smaller. */
|
|
21
|
+
const SHRINK = 0.5;
|
|
22
|
+
/** Down this much of the height of the screen, the page under it shows through all. */
|
|
23
|
+
const CLEAR = 0.6;
|
|
24
|
+
/** Let go this far down of the height of the screen (at least FAR_PX), it closes. */
|
|
25
|
+
const FAR = 0.12;
|
|
26
|
+
const FAR_PX = 72;
|
|
27
|
+
/** How long it flies back or away, let go slowly. */
|
|
28
|
+
const SETTLE_MS = 300;
|
|
29
|
+
/** How long it fades away, closed with no thumbnail to go back to. */
|
|
30
|
+
const FADE_MS = 180;
|
|
31
|
+
/**
|
|
32
|
+
* Whether the move so far (`dx`, `dy`) pulls the picture: undefined until it is told, false when it goes up or
|
|
33
|
+
* more sideways than down (a swipe to the picture beside), or the picture is zoomed in (the finger scrolls it).
|
|
34
|
+
*/
|
|
35
|
+
function claims(dx: number, dy: number, zoomed: boolean): boolean | undefined;
|
|
36
|
+
/** Where the picture is, the finger moved `dx`, `dy` on a screen `height` tall: with it, smaller only as it goes down. */
|
|
37
|
+
function place(dx: number, dy: number, height: number): PullPlace;
|
|
38
|
+
/** How dark the shade over the page is, 1 as at first, the finger moved `dy`. */
|
|
39
|
+
function shade(dy: number, height: number): number;
|
|
40
|
+
/** Whether it closes, let go `dy` down at `speed` down (pixels a millisecond): flicked that way, or far enough not flicked up. */
|
|
41
|
+
function closes(dy: number, speed: number, height: number): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Where it is drawn to sit on `target` (its thumbnail), covering it as the thumbnail covers its box: the picture is
|
|
44
|
+
* at `rect` now, drawn at `now` about `origin` (a point of its box, which is at `box` drawn as at first).
|
|
45
|
+
*/
|
|
46
|
+
function onto(rect: PullRect, target: PullRect, box: {
|
|
47
|
+
left: number;
|
|
48
|
+
top: number;
|
|
49
|
+
}, origin: {
|
|
50
|
+
x: number;
|
|
51
|
+
y: number;
|
|
52
|
+
}, now: PullPlace): PullPlace;
|
|
53
|
+
/** A clip-path that shows of a box `width` × `height` only `rect` of it (in its own pixels), its corners `radius` round. */
|
|
54
|
+
function inset(rect: PullRect, width: number, height: number, radius: number): string;
|
|
55
|
+
/** Of the picture at `image` (in the pixels of its box), the middle its thumbnail shows, `target` large, once drawn at `scale`. */
|
|
56
|
+
function middle(image: PullRect, target: {
|
|
57
|
+
width: number;
|
|
58
|
+
height: number;
|
|
59
|
+
}, scale: number): PullRect;
|
|
60
|
+
function transform({ x, y, scale }: PullPlace): string;
|
|
61
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { SwipeUtil } from '../device/swipe-util.js';
|
|
2
|
+
/**
|
|
3
|
+
* A finger pulls a picture over the page down to close it, as the viewers of pictures of a phone (WeChat, Photos):
|
|
4
|
+
* the picture follows the finger, smaller as it goes down, the page under it shows through; let go far enough,
|
|
5
|
+
* or flicked down, it flies back to where it was opened from (its thumbnail), else it comes back. Pure, for the tests.
|
|
6
|
+
*/
|
|
7
|
+
export var ImagePullUtil;
|
|
8
|
+
(function (ImagePullUtil) {
|
|
9
|
+
/** Down all the height of the screen, it is this much smaller. */
|
|
10
|
+
ImagePullUtil.SHRINK = 0.5;
|
|
11
|
+
/** Down this much of the height of the screen, the page under it shows through all. */
|
|
12
|
+
ImagePullUtil.CLEAR = 0.6;
|
|
13
|
+
/** Let go this far down of the height of the screen (at least FAR_PX), it closes. */
|
|
14
|
+
ImagePullUtil.FAR = 0.12;
|
|
15
|
+
ImagePullUtil.FAR_PX = 72;
|
|
16
|
+
/** How long it flies back or away, let go slowly. */
|
|
17
|
+
ImagePullUtil.SETTLE_MS = 300;
|
|
18
|
+
/** How long it fades away, closed with no thumbnail to go back to. */
|
|
19
|
+
ImagePullUtil.FADE_MS = 180;
|
|
20
|
+
/**
|
|
21
|
+
* Whether the move so far (`dx`, `dy`) pulls the picture: undefined until it is told, false when it goes up or
|
|
22
|
+
* more sideways than down (a swipe to the picture beside), or the picture is zoomed in (the finger scrolls it).
|
|
23
|
+
*/
|
|
24
|
+
function claims(dx, dy, zoomed) {
|
|
25
|
+
if (Math.hypot(dx, dy) < SwipeUtil.SLOP_PX) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
return !zoomed && dy > 0 && dy > Math.abs(dx) * 1.2;
|
|
29
|
+
}
|
|
30
|
+
ImagePullUtil.claims = claims;
|
|
31
|
+
/** Where the picture is, the finger moved `dx`, `dy` on a screen `height` tall: with it, smaller only as it goes down. */
|
|
32
|
+
function place(dx, dy, height) {
|
|
33
|
+
const down = Math.min(1, Math.max(0, dy) / Math.max(1, height));
|
|
34
|
+
return { x: dx, y: dy, scale: 1 - down * ImagePullUtil.SHRINK };
|
|
35
|
+
}
|
|
36
|
+
ImagePullUtil.place = place;
|
|
37
|
+
/** How dark the shade over the page is, 1 as at first, the finger moved `dy`. */
|
|
38
|
+
function shade(dy, height) {
|
|
39
|
+
return 1 - Math.min(1, Math.max(0, dy) / Math.max(1, height * ImagePullUtil.CLEAR));
|
|
40
|
+
}
|
|
41
|
+
ImagePullUtil.shade = shade;
|
|
42
|
+
/** Whether it closes, let go `dy` down at `speed` down (pixels a millisecond): flicked that way, or far enough not flicked up. */
|
|
43
|
+
function closes(dy, speed, height) {
|
|
44
|
+
if (Math.abs(speed) > SwipeUtil.FLICK) {
|
|
45
|
+
return speed > 0 && dy > 0;
|
|
46
|
+
}
|
|
47
|
+
return dy > Math.max(ImagePullUtil.FAR_PX, height * ImagePullUtil.FAR);
|
|
48
|
+
}
|
|
49
|
+
ImagePullUtil.closes = closes;
|
|
50
|
+
/**
|
|
51
|
+
* Where it is drawn to sit on `target` (its thumbnail), covering it as the thumbnail covers its box: the picture is
|
|
52
|
+
* at `rect` now, drawn at `now` about `origin` (a point of its box, which is at `box` drawn as at first).
|
|
53
|
+
*/
|
|
54
|
+
function onto(rect, target, box, origin, now) {
|
|
55
|
+
const by = Math.max(target.width / Math.max(1, rect.width), target.height / Math.max(1, rect.height));
|
|
56
|
+
const around = { x: box.left + origin.x, y: box.top + origin.y };
|
|
57
|
+
const middle = (r) => ({ x: r.left + r.width / 2, y: r.top + r.height / 2 });
|
|
58
|
+
const from = middle(rect);
|
|
59
|
+
const to = middle(target);
|
|
60
|
+
return {
|
|
61
|
+
x: to.x - around.x - by * (from.x - around.x - now.x),
|
|
62
|
+
y: to.y - around.y - by * (from.y - around.y - now.y),
|
|
63
|
+
scale: now.scale * by,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
ImagePullUtil.onto = onto;
|
|
67
|
+
/** A clip-path that shows of a box `width` × `height` only `rect` of it (in its own pixels), its corners `radius` round. */
|
|
68
|
+
function inset(rect, width, height, radius) {
|
|
69
|
+
const top = Math.max(0, rect.top);
|
|
70
|
+
const left = Math.max(0, rect.left);
|
|
71
|
+
const bottom = Math.max(0, height - rect.top - rect.height);
|
|
72
|
+
const right = Math.max(0, width - rect.left - rect.width);
|
|
73
|
+
return `inset(${top}px ${right}px ${bottom}px ${left}px round ${radius}px)`;
|
|
74
|
+
}
|
|
75
|
+
ImagePullUtil.inset = inset;
|
|
76
|
+
/** Of the picture at `image` (in the pixels of its box), the middle its thumbnail shows, `target` large, once drawn at `scale`. */
|
|
77
|
+
function middle(image, target, scale) {
|
|
78
|
+
const width = Math.min(image.width, target.width / scale);
|
|
79
|
+
const height = Math.min(image.height, target.height / scale);
|
|
80
|
+
return { left: image.left + (image.width - width) / 2, top: image.top + (image.height - height) / 2, width, height };
|
|
81
|
+
}
|
|
82
|
+
ImagePullUtil.middle = middle;
|
|
83
|
+
function transform({ x, y, scale }) {
|
|
84
|
+
return `translate3d(${x}px, ${y}px, 0) scale(${scale})`;
|
|
85
|
+
}
|
|
86
|
+
ImagePullUtil.transform = transform;
|
|
87
|
+
})(ImagePullUtil || (ImagePullUtil = {}));
|
|
88
|
+
//# sourceMappingURL=image-pull.js.map
|
|
@@ -13,9 +13,9 @@ export declare namespace SpokenReply {
|
|
|
13
13
|
/** The language of the block for the ear. */
|
|
14
14
|
const LANGUAGE = "ta-say";
|
|
15
15
|
/** What the model is told with what the user says in a call, in the context of their message: to write the block. */
|
|
16
|
-
const NOTE = "[ta-call] The user talks with you in a
|
|
17
|
-
/** What the user said in a call, as sent to the conversation: with the note, which pages leave out. */
|
|
18
|
-
function asked(text: string): string;
|
|
16
|
+
const NOTE = "[ta-call] The user talks with you in a call: your reply is shown, and Ta reads aloud only a block of language ta-say you end it with. Write one: one to three short sentences in the user's language, as you would say it on the phone: the answer, and what they must decide or know (a question, a failure, a risk). No code, paths, links, tables or lists; say the rest is on the screen when there is more.";
|
|
17
|
+
/** What the user said in a call, as sent to the conversation: with the note, and what is new of the call (`scene`, TaCallSceneUtil.next), which pages leave out. */
|
|
18
|
+
function asked(text: string, scene?: string): string;
|
|
19
19
|
interface Words {
|
|
20
20
|
/** Said after the rest when something of the reply is only on the screen. */
|
|
21
21
|
onScreen: string;
|
|
@@ -18,10 +18,10 @@ export var SpokenReply;
|
|
|
18
18
|
const SENTENCES = 3;
|
|
19
19
|
const CHARS = 160;
|
|
20
20
|
/** What the model is told with what the user says in a call, in the context of their message: to write the block. */
|
|
21
|
-
SpokenReply.NOTE = `[ta-call] The user talks with you in a
|
|
22
|
-
/** What the user said in a call, as sent to the conversation: with the note, which pages leave out. */
|
|
23
|
-
function asked(text) {
|
|
24
|
-
return TaMessageContext.wrap(SpokenReply.NOTE, text);
|
|
21
|
+
SpokenReply.NOTE = `[ta-call] The user talks with you in a call: your reply is shown, and Ta reads aloud only a block of language ${SpokenReply.LANGUAGE} you end it with. Write one: one to three short sentences in the user's language, as you would say it on the phone: the answer, and what they must decide or know (a question, a failure, a risk). No code, paths, links, tables or lists; say the rest is on the screen when there is more.`;
|
|
22
|
+
/** What the user said in a call, as sent to the conversation: with the note, and what is new of the call (`scene`, TaCallSceneUtil.next), which pages leave out. */
|
|
23
|
+
function asked(text, scene) {
|
|
24
|
+
return TaMessageContext.wrap(scene ? `${SpokenReply.NOTE}\n${scene}` : SpokenReply.NOTE, text);
|
|
25
25
|
}
|
|
26
26
|
SpokenReply.asked = asked;
|
|
27
27
|
/**
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { ImageContent } from '@celljs/ta-protocol';
|
|
2
|
+
import type { VoiceCall } from '../assistant/voice-call.js';
|
|
3
|
+
/** When a picture of the camera goes with what the user says (docs/design/ta-call.md 12). */
|
|
4
|
+
export declare namespace CallLook {
|
|
5
|
+
/** How long after one picture another goes with a change, in ms; and with none, at the latest. */
|
|
6
|
+
const CHANGED_MS = 6000;
|
|
7
|
+
const STALE_MS = 90000;
|
|
8
|
+
/** How much a frame must differ from the one sent (the mean of grey levels, 0 to 255) to be a change. */
|
|
9
|
+
const CHANGE = 14;
|
|
10
|
+
/**
|
|
11
|
+
* Whether to send the frame now with `text`: the first one, one the words ask to look at, one that changed since
|
|
12
|
+
* the last sent (not more often than CHANGED_MS), and one now and then; else the model has seen it already.
|
|
13
|
+
*/
|
|
14
|
+
function due(text: string, now: number, last: {
|
|
15
|
+
at: number;
|
|
16
|
+
print: Uint8Array;
|
|
17
|
+
} | undefined, print: Uint8Array): boolean;
|
|
18
|
+
/** The mean difference of two prints. */
|
|
19
|
+
function differ(a: Uint8Array, b: Uint8Array): number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The user's camera in a video call: what they see of themselves (`stream`), and what Ta sees of them, a picture of
|
|
23
|
+
* now with what they say (`frame`). It begins off, asking for no camera until the user turns it on (start does
|
|
24
|
+
* nothing while off); turned off, it lets go of the camera.
|
|
25
|
+
*/
|
|
26
|
+
export declare class CallCamera {
|
|
27
|
+
stream?: MediaStream;
|
|
28
|
+
facing: 'user' | 'environment';
|
|
29
|
+
protected video?: HTMLVideoElement;
|
|
30
|
+
protected sent?: {
|
|
31
|
+
at: number;
|
|
32
|
+
print: Uint8Array;
|
|
33
|
+
};
|
|
34
|
+
protected readonly listeners: Set<() => void>;
|
|
35
|
+
protected opening?: Promise<void>;
|
|
36
|
+
/** Off until the user turns it on, or turned off again, or it could not open. */
|
|
37
|
+
off: boolean;
|
|
38
|
+
denied: boolean;
|
|
39
|
+
subscribe(listener: () => void): () => void;
|
|
40
|
+
protected changed(): void;
|
|
41
|
+
start(): Promise<void>;
|
|
42
|
+
/** On or off, as the user taps. */
|
|
43
|
+
toggle(): void;
|
|
44
|
+
/** The other camera of a phone: the user's face, or what is in front of them. */
|
|
45
|
+
flip(): void;
|
|
46
|
+
stop(): void;
|
|
47
|
+
/** A picture of now to go with `text`, when one is due (CallLook.due); undefined when off, not ready or not due. */
|
|
48
|
+
frame(text: string, now?: number): ImageContent | undefined;
|
|
49
|
+
protected static print(canvas: HTMLCanvasElement): Uint8Array;
|
|
50
|
+
protected static release(stream: MediaStream): void;
|
|
51
|
+
}
|
|
52
|
+
/** The camera of each video call, as long as it goes on. */
|
|
53
|
+
export declare namespace CallCameras {
|
|
54
|
+
function of(call: VoiceCall): CallCamera;
|
|
55
|
+
/** The picture to go with what the user said in `call`, when it is a video call with its camera on. */
|
|
56
|
+
function frame(call: VoiceCall, text: string): ImageContent | undefined;
|
|
57
|
+
/** The call ended: its camera lets go, and the next video call begins with it off. */
|
|
58
|
+
function end(call: VoiceCall): void;
|
|
59
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/** The longer side of a picture of the camera sent with what the user says, in pixels: enough to see a face and a thing held up. */
|
|
2
|
+
const SIDE = 448;
|
|
3
|
+
/** The side of the small grey picture a frame is compared by. */
|
|
4
|
+
const PRINT = 16;
|
|
5
|
+
/** Words that ask Ta to look: a picture goes with them however little has changed. */
|
|
6
|
+
const LOOK = /看|瞧|镜头|摄像头|画面|这个|这是|我手|我拿|穿|长什么样|見て|これ|カメラ|\b(?:look|see|watch|camera|this|holding|wearing)\b/i;
|
|
7
|
+
/** When a picture of the camera goes with what the user says (docs/design/ta-call.md 12). */
|
|
8
|
+
export var CallLook;
|
|
9
|
+
(function (CallLook) {
|
|
10
|
+
/** How long after one picture another goes with a change, in ms; and with none, at the latest. */
|
|
11
|
+
CallLook.CHANGED_MS = 6000;
|
|
12
|
+
CallLook.STALE_MS = 90000;
|
|
13
|
+
/** How much a frame must differ from the one sent (the mean of grey levels, 0 to 255) to be a change. */
|
|
14
|
+
CallLook.CHANGE = 14;
|
|
15
|
+
/**
|
|
16
|
+
* Whether to send the frame now with `text`: the first one, one the words ask to look at, one that changed since
|
|
17
|
+
* the last sent (not more often than CHANGED_MS), and one now and then; else the model has seen it already.
|
|
18
|
+
*/
|
|
19
|
+
function due(text, now, last, print) {
|
|
20
|
+
if (!last || LOOK.test(text) || now - last.at >= CallLook.STALE_MS) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
return now - last.at >= CallLook.CHANGED_MS && differ(last.print, print) >= CallLook.CHANGE;
|
|
24
|
+
}
|
|
25
|
+
CallLook.due = due;
|
|
26
|
+
/** The mean difference of two prints. */
|
|
27
|
+
function differ(a, b) {
|
|
28
|
+
var _a;
|
|
29
|
+
let sum = 0;
|
|
30
|
+
for (let i = 0; i < a.length; i++) {
|
|
31
|
+
sum += Math.abs(a[i] - ((_a = b[i]) !== null && _a !== void 0 ? _a : 0));
|
|
32
|
+
}
|
|
33
|
+
return a.length ? sum / a.length : 255;
|
|
34
|
+
}
|
|
35
|
+
CallLook.differ = differ;
|
|
36
|
+
})(CallLook || (CallLook = {}));
|
|
37
|
+
/**
|
|
38
|
+
* The user's camera in a video call: what they see of themselves (`stream`), and what Ta sees of them, a picture of
|
|
39
|
+
* now with what they say (`frame`). It begins off, asking for no camera until the user turns it on (start does
|
|
40
|
+
* nothing while off); turned off, it lets go of the camera.
|
|
41
|
+
*/
|
|
42
|
+
export class CallCamera {
|
|
43
|
+
constructor() {
|
|
44
|
+
this.facing = 'user';
|
|
45
|
+
this.listeners = new Set();
|
|
46
|
+
/** Off until the user turns it on, or turned off again, or it could not open. */
|
|
47
|
+
this.off = true;
|
|
48
|
+
this.denied = false;
|
|
49
|
+
}
|
|
50
|
+
subscribe(listener) {
|
|
51
|
+
this.listeners.add(listener);
|
|
52
|
+
return () => this.listeners.delete(listener);
|
|
53
|
+
}
|
|
54
|
+
changed() {
|
|
55
|
+
for (const listener of [...this.listeners]) {
|
|
56
|
+
listener();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
start() {
|
|
60
|
+
var _a;
|
|
61
|
+
var _b;
|
|
62
|
+
if (this.stream || this.off || typeof navigator === 'undefined' || !((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia)) {
|
|
63
|
+
return Promise.resolve();
|
|
64
|
+
}
|
|
65
|
+
(_b = this.opening) !== null && _b !== void 0 ? _b : (this.opening = navigator.mediaDevices
|
|
66
|
+
.getUserMedia({ video: { facingMode: this.facing, width: { ideal: 640 }, height: { ideal: 640 } }, audio: false })
|
|
67
|
+
.then(stream => {
|
|
68
|
+
this.opening = undefined;
|
|
69
|
+
if (this.off) {
|
|
70
|
+
CallCamera.release(stream);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
this.stream = stream;
|
|
74
|
+
const video = document.createElement('video');
|
|
75
|
+
video.muted = true;
|
|
76
|
+
video.playsInline = true;
|
|
77
|
+
video.srcObject = stream;
|
|
78
|
+
void video.play().catch(() => undefined);
|
|
79
|
+
this.video = video;
|
|
80
|
+
this.changed();
|
|
81
|
+
}, () => {
|
|
82
|
+
this.opening = undefined;
|
|
83
|
+
this.denied = true;
|
|
84
|
+
this.off = true;
|
|
85
|
+
this.changed();
|
|
86
|
+
}));
|
|
87
|
+
return this.opening;
|
|
88
|
+
}
|
|
89
|
+
/** On or off, as the user taps. */
|
|
90
|
+
toggle() {
|
|
91
|
+
this.off = !this.off;
|
|
92
|
+
this.denied = false;
|
|
93
|
+
if (this.off) {
|
|
94
|
+
this.stop();
|
|
95
|
+
this.changed();
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
void this.start();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/** The other camera of a phone: the user's face, or what is in front of them. */
|
|
102
|
+
flip() {
|
|
103
|
+
this.facing = this.facing === 'user' ? 'environment' : 'user';
|
|
104
|
+
this.stop();
|
|
105
|
+
this.sent = undefined;
|
|
106
|
+
void this.start();
|
|
107
|
+
}
|
|
108
|
+
stop() {
|
|
109
|
+
if (this.stream) {
|
|
110
|
+
CallCamera.release(this.stream);
|
|
111
|
+
}
|
|
112
|
+
this.stream = undefined;
|
|
113
|
+
this.video = undefined;
|
|
114
|
+
}
|
|
115
|
+
/** A picture of now to go with `text`, when one is due (CallLook.due); undefined when off, not ready or not due. */
|
|
116
|
+
frame(text, now = Date.now()) {
|
|
117
|
+
var _a;
|
|
118
|
+
const video = this.video;
|
|
119
|
+
if (!video || this.off || !video.videoWidth) {
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
const scale = SIDE / Math.max(video.videoWidth, video.videoHeight);
|
|
123
|
+
const canvas = document.createElement('canvas');
|
|
124
|
+
canvas.width = Math.round(video.videoWidth * Math.min(1, scale));
|
|
125
|
+
canvas.height = Math.round(video.videoHeight * Math.min(1, scale));
|
|
126
|
+
const context = canvas.getContext('2d');
|
|
127
|
+
if (!context) {
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
context.drawImage(video, 0, 0, canvas.width, canvas.height);
|
|
131
|
+
const print = CallCamera.print(canvas);
|
|
132
|
+
if (!CallLook.due(text, now, this.sent, print)) {
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
this.sent = { at: now, print };
|
|
136
|
+
const data = (_a = canvas.toDataURL('image/jpeg', 0.72).split(',')[1]) !== null && _a !== void 0 ? _a : '';
|
|
137
|
+
return data ? { type: 'image', data, mimeType: 'image/jpeg' } : undefined;
|
|
138
|
+
}
|
|
139
|
+
static print(canvas) {
|
|
140
|
+
const small = document.createElement('canvas');
|
|
141
|
+
small.width = PRINT;
|
|
142
|
+
small.height = PRINT;
|
|
143
|
+
const context = small.getContext('2d');
|
|
144
|
+
const out = new Uint8Array(PRINT * PRINT);
|
|
145
|
+
if (!context) {
|
|
146
|
+
return out;
|
|
147
|
+
}
|
|
148
|
+
context.drawImage(canvas, 0, 0, PRINT, PRINT);
|
|
149
|
+
const { data } = context.getImageData(0, 0, PRINT, PRINT);
|
|
150
|
+
for (let i = 0; i < out.length; i++) {
|
|
151
|
+
out[i] = (data[i * 4] * 3 + data[i * 4 + 1] * 6 + data[i * 4 + 2]) / 10;
|
|
152
|
+
}
|
|
153
|
+
return out;
|
|
154
|
+
}
|
|
155
|
+
static release(stream) {
|
|
156
|
+
for (const track of stream.getTracks()) {
|
|
157
|
+
track.stop();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/** The camera of each video call, as long as it goes on. */
|
|
162
|
+
export var CallCameras;
|
|
163
|
+
(function (CallCameras) {
|
|
164
|
+
const cameras = new WeakMap();
|
|
165
|
+
function of(call) {
|
|
166
|
+
let camera = cameras.get(call);
|
|
167
|
+
if (!camera) {
|
|
168
|
+
camera = new CallCamera();
|
|
169
|
+
cameras.set(call, camera);
|
|
170
|
+
}
|
|
171
|
+
return camera;
|
|
172
|
+
}
|
|
173
|
+
CallCameras.of = of;
|
|
174
|
+
/** The picture to go with what the user said in `call`, when it is a video call with its camera on. */
|
|
175
|
+
function frame(call, text) {
|
|
176
|
+
var _a;
|
|
177
|
+
return call.state.video ? (_a = cameras.get(call)) === null || _a === void 0 ? void 0 : _a.frame(text) : undefined;
|
|
178
|
+
}
|
|
179
|
+
CallCameras.frame = frame;
|
|
180
|
+
/** The call ended: its camera lets go, and the next video call begins with it off. */
|
|
181
|
+
function end(call) {
|
|
182
|
+
var _a;
|
|
183
|
+
(_a = cameras.get(call)) === null || _a === void 0 ? void 0 : _a.stop();
|
|
184
|
+
cameras.delete(call);
|
|
185
|
+
}
|
|
186
|
+
CallCameras.end = end;
|
|
187
|
+
})(CallCameras || (CallCameras = {}));
|
|
188
|
+
//# sourceMappingURL=call-camera.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The window of a video call on a computer (docs/design/ta-call.md 12), as a messenger's: Ta Desktop opens it blank and
|
|
3
|
+
* the page draws the call into it (a portal), so the call, its voice and its camera stay the page's. While it shows,
|
|
4
|
+
* the call goes on though the main window is hidden or minimized.
|
|
5
|
+
*/
|
|
6
|
+
export declare namespace CallWindow {
|
|
7
|
+
/** Whether this page can open one: in Ta Desktop. */
|
|
8
|
+
function can(scope?: object): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Opens the window, styled as the page, its title `title`; `closed` when the user closes it. Undefined when it
|
|
11
|
+
* could not open (the page draws the call in itself).
|
|
12
|
+
*/
|
|
13
|
+
function open(title: string, closed: () => void): HTMLElement | undefined;
|
|
14
|
+
function close(): void;
|
|
15
|
+
/** The window shows now. */
|
|
16
|
+
function shows(): boolean;
|
|
17
|
+
/** The call cannot be seen nor heard to: the page hidden, and no window of a video call showing. */
|
|
18
|
+
function hidden(): boolean;
|
|
19
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { STYLE } from '../style.js';
|
|
2
|
+
import { DesktopUtil } from '../util/desktop.js';
|
|
3
|
+
/** The name of the window of a video call, which Ta Desktop lets the page open (DesktopChannel.VIDEO_CALL_FRAME). */
|
|
4
|
+
const FRAME = 'ta-video-call';
|
|
5
|
+
/**
|
|
6
|
+
* The window of a video call on a computer (docs/design/ta-call.md 12), as a messenger's: Ta Desktop opens it blank and
|
|
7
|
+
* the page draws the call into it (a portal), so the call, its voice and its camera stay the page's. While it shows,
|
|
8
|
+
* the call goes on though the main window is hidden or minimized.
|
|
9
|
+
*/
|
|
10
|
+
export var CallWindow;
|
|
11
|
+
(function (CallWindow) {
|
|
12
|
+
let current;
|
|
13
|
+
/** Whether this page can open one: in Ta Desktop. */
|
|
14
|
+
function can(scope = globalThis) {
|
|
15
|
+
return DesktopUtil.has('callWindow', scope);
|
|
16
|
+
}
|
|
17
|
+
CallWindow.can = can;
|
|
18
|
+
/**
|
|
19
|
+
* Opens the window, styled as the page, its title `title`; `closed` when the user closes it. Undefined when it
|
|
20
|
+
* could not open (the page draws the call in itself).
|
|
21
|
+
*/
|
|
22
|
+
function open(title, closed) {
|
|
23
|
+
const opened = window.open('about:blank', FRAME);
|
|
24
|
+
if (!opened) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
current = opened;
|
|
28
|
+
const doc = opened.document;
|
|
29
|
+
doc.title = title;
|
|
30
|
+
const style = doc.createElement('style');
|
|
31
|
+
style.textContent = STYLE;
|
|
32
|
+
doc.head.appendChild(style);
|
|
33
|
+
// As the page looks, and as it changes (the theme, the size of the text).
|
|
34
|
+
const root = document.documentElement;
|
|
35
|
+
const look = () => {
|
|
36
|
+
for (const [key, value] of Object.entries(root.dataset)) {
|
|
37
|
+
doc.documentElement.dataset[key] = value;
|
|
38
|
+
}
|
|
39
|
+
doc.documentElement.lang = root.lang;
|
|
40
|
+
doc.documentElement.style.cssText = root.style.cssText;
|
|
41
|
+
};
|
|
42
|
+
look();
|
|
43
|
+
const observer = new MutationObserver(look);
|
|
44
|
+
observer.observe(root, { attributes: true });
|
|
45
|
+
opened.addEventListener('pagehide', () => observer.disconnect());
|
|
46
|
+
doc.body.className = 'ta-video-window';
|
|
47
|
+
const host = doc.createElement('div');
|
|
48
|
+
host.className = 'ta-video-window-host';
|
|
49
|
+
doc.body.appendChild(host);
|
|
50
|
+
// The main page's checks of whether it shows (the call pauses when hidden) look again as this one shows or hides.
|
|
51
|
+
const shown = () => document.dispatchEvent(new Event('visibilitychange'));
|
|
52
|
+
doc.addEventListener('visibilitychange', shown);
|
|
53
|
+
opened.addEventListener('pagehide', () => {
|
|
54
|
+
if (current === opened) {
|
|
55
|
+
current = undefined;
|
|
56
|
+
shown();
|
|
57
|
+
closed();
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
return host;
|
|
61
|
+
}
|
|
62
|
+
CallWindow.open = open;
|
|
63
|
+
function close() {
|
|
64
|
+
const opened = current;
|
|
65
|
+
current = undefined;
|
|
66
|
+
opened === null || opened === void 0 ? void 0 : opened.close();
|
|
67
|
+
}
|
|
68
|
+
CallWindow.close = close;
|
|
69
|
+
/** The window shows now. */
|
|
70
|
+
function shows() {
|
|
71
|
+
return !!current && !current.closed && current.document.visibilityState === 'visible';
|
|
72
|
+
}
|
|
73
|
+
CallWindow.shows = shows;
|
|
74
|
+
/** The call cannot be seen nor heard to: the page hidden, and no window of a video call showing. */
|
|
75
|
+
function hidden() {
|
|
76
|
+
return typeof document !== 'undefined' && document.visibilityState === 'hidden' && !shows();
|
|
77
|
+
}
|
|
78
|
+
CallWindow.hidden = hidden;
|
|
79
|
+
})(CallWindow || (CallWindow = {}));
|
|
80
|
+
//# sourceMappingURL=call-window.js.map
|