@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,533 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.VideoFace = VideoFace;
|
|
37
|
+
const React = __importStar(require("react"));
|
|
38
|
+
const hooks_1 = require("../hooks");
|
|
39
|
+
const clip_plan_1 = require("./clip-plan");
|
|
40
|
+
const face_clips_1 = require("./face-clips");
|
|
41
|
+
const face_files_1 = require("./face-files");
|
|
42
|
+
/** How often the face looks at the call (its phase), in ms. */
|
|
43
|
+
const TICK_MS = 80;
|
|
44
|
+
/** How fast she goes back to the sofa from a dance or a stretch, as the call goes on. */
|
|
45
|
+
const HURRY_RATE = 2.5;
|
|
46
|
+
/** How much longer a reading may wait while the mouth starts, at most, in ms. */
|
|
47
|
+
const STARTING_MS = 6000;
|
|
48
|
+
/** How long the sound may not go on before the clip holds still too, in ms (the clock of sound moves in steps). */
|
|
49
|
+
const STILL_MS = 120;
|
|
50
|
+
/** The frames of a clip when faces/lips.json does not say (5 s and a sixth at 24 fps). */
|
|
51
|
+
const FRAMES = 124;
|
|
52
|
+
/** How many frames the clip shown may be from the one a mouth was drawn for, laid over it moved with the face. */
|
|
53
|
+
const NEAR_FRAMES = 3;
|
|
54
|
+
/**
|
|
55
|
+
* The person of a video call: two layers of video, the one in front playing, the other taking over with a short fade
|
|
56
|
+
* when the clip changes. As Ta reads with a voice service, the clip is the one its ClipPlan has for that moment of the
|
|
57
|
+
* sound, and the mouth an extension draws for that moment is laid over it (MouthLayer); otherwise clips play by the
|
|
58
|
+
* state of the call.
|
|
59
|
+
*/
|
|
60
|
+
function VideoFace({ call, onReady, onFailed }) {
|
|
61
|
+
var _a;
|
|
62
|
+
var _b;
|
|
63
|
+
const layers = [React.useRef(null), React.useRef(null)];
|
|
64
|
+
const box = React.useRef(null);
|
|
65
|
+
const canvas = React.useRef(null);
|
|
66
|
+
const [front, setFront] = React.useState(0);
|
|
67
|
+
const [{ callMouth }] = (0, hooks_1.useWebExtensions)();
|
|
68
|
+
const mouth = React.useRef(callMouth);
|
|
69
|
+
mouth.current = callMouth;
|
|
70
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: the layers are refs, set up once a call
|
|
71
|
+
React.useEffect(() => {
|
|
72
|
+
var _a;
|
|
73
|
+
var _b, _c;
|
|
74
|
+
const doc = (_b = (_a = box.current) === null || _a === void 0 ? void 0 : _a.ownerDocument) !== null && _b !== void 0 ? _b : document;
|
|
75
|
+
const view = (_c = doc.defaultView) !== null && _c !== void 0 ? _c : window;
|
|
76
|
+
const videos = layers.map(layer => layer.current).filter((video) => !!video);
|
|
77
|
+
if (videos.length !== 2) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
let gone = false;
|
|
81
|
+
let shown = 0;
|
|
82
|
+
let kind;
|
|
83
|
+
let ready = false;
|
|
84
|
+
const faces = face_files_1.FaceFiles.of(doc);
|
|
85
|
+
const frames = (clip) => { var _a; return (_a = faces.frames(clip)) !== null && _a !== void 0 ? _a : FRAMES; };
|
|
86
|
+
// The clip each layer plays, by name, and the one the layer behind is loading to come in front.
|
|
87
|
+
const names = [undefined, undefined];
|
|
88
|
+
let loading;
|
|
89
|
+
let last;
|
|
90
|
+
// The sentence whose look played (moodFor), and whether that clip is over: once a sentence.
|
|
91
|
+
let moodFor;
|
|
92
|
+
let moodDone = false;
|
|
93
|
+
// What she said she would do (FaceClips.show), and the sentence that said it: it plays once she listens.
|
|
94
|
+
let coming;
|
|
95
|
+
let comingFor;
|
|
96
|
+
const words = () => {
|
|
97
|
+
const reading = call.state.reading;
|
|
98
|
+
return reading === null || reading === void 0 ? void 0 : reading.pieces[reading.at];
|
|
99
|
+
};
|
|
100
|
+
const wanted = () => {
|
|
101
|
+
const { phase, paused } = call.state;
|
|
102
|
+
const plain = face_clips_1.FaceClips.kind(phase, !!paused);
|
|
103
|
+
if (plain === 'listening') {
|
|
104
|
+
// What she said she would do, once she said it; then it plays to its end, unless Ta thinks or speaks.
|
|
105
|
+
if (coming) {
|
|
106
|
+
return coming;
|
|
107
|
+
}
|
|
108
|
+
return face_clips_1.FaceClips.isShow(kind) && !moodDone ? kind : plain;
|
|
109
|
+
}
|
|
110
|
+
if (plain !== 'speaking') {
|
|
111
|
+
return plain;
|
|
112
|
+
}
|
|
113
|
+
const said = words();
|
|
114
|
+
const mood = face_clips_1.FaceClips.mood(said);
|
|
115
|
+
return mood && (moodFor !== said || (kind === mood && !moodDone)) ? mood : 'speaking';
|
|
116
|
+
};
|
|
117
|
+
/** Plays `clip` in the layer behind from `at` seconds, which comes in front once it plays. */
|
|
118
|
+
const show = (clip, at = 0) => {
|
|
119
|
+
const back = 1 - shown;
|
|
120
|
+
const video = videos[back];
|
|
121
|
+
last = clip;
|
|
122
|
+
names[back] = clip;
|
|
123
|
+
loading = clip;
|
|
124
|
+
video.dataset.clip = clip;
|
|
125
|
+
const src = faces.clip(clip);
|
|
126
|
+
if (video.src !== src) {
|
|
127
|
+
video.src = src;
|
|
128
|
+
}
|
|
129
|
+
video.currentTime = at;
|
|
130
|
+
video.playbackRate = 1;
|
|
131
|
+
void video.play().then(() => {
|
|
132
|
+
if (names[back] !== clip || gone) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
loading = undefined;
|
|
136
|
+
shown = back;
|
|
137
|
+
setFront(back);
|
|
138
|
+
videos[1 - back].pause();
|
|
139
|
+
if (!ready) {
|
|
140
|
+
ready = true;
|
|
141
|
+
onReady();
|
|
142
|
+
}
|
|
143
|
+
}, () => {
|
|
144
|
+
// Another clip took the layer meanwhile (its load stopped this one): not a failure.
|
|
145
|
+
if (names[back] !== clip || gone) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
loading = undefined;
|
|
149
|
+
if (!ready) {
|
|
150
|
+
onFailed();
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
const play = (next) => {
|
|
155
|
+
if (next !== kind && (face_clips_1.FaceClips.isMood(next) || face_clips_1.FaceClips.isShow(next))) {
|
|
156
|
+
moodFor = words();
|
|
157
|
+
moodDone = false;
|
|
158
|
+
}
|
|
159
|
+
if (next === coming) {
|
|
160
|
+
coming = undefined;
|
|
161
|
+
}
|
|
162
|
+
kind = next;
|
|
163
|
+
show(face_clips_1.FaceClips.next(next, last));
|
|
164
|
+
};
|
|
165
|
+
// The plans of the readings, by their say: which clip shows at each moment of their sound.
|
|
166
|
+
const plans = new Map();
|
|
167
|
+
const planOf = (say) => {
|
|
168
|
+
let plan = plans.get(say);
|
|
169
|
+
if (!plan) {
|
|
170
|
+
const used = new Set();
|
|
171
|
+
plan = new clip_plan_1.ClipPlan(frames, (seconds, before) => {
|
|
172
|
+
const reading = call.sounds.nowReading();
|
|
173
|
+
return face_clips_1.FaceClips.at((reading === null || reading === void 0 ? void 0 : reading.say) === say ? reading : undefined, seconds, before !== null && before !== void 0 ? before : last, used);
|
|
174
|
+
});
|
|
175
|
+
plans.set(say, plan);
|
|
176
|
+
for (const old of plans.keys()) {
|
|
177
|
+
if (old < say - 1) {
|
|
178
|
+
plans.delete(old);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return plan;
|
|
183
|
+
};
|
|
184
|
+
/** The reading that drives the face now: one of a voice service, playing, while Ta speaks. */
|
|
185
|
+
const driving = () => {
|
|
186
|
+
const reading = call.sounds.nowReading();
|
|
187
|
+
return reading && !call.state.paused && call.state.phase === 'speaking' && reading.now() >= 0 ? reading : undefined;
|
|
188
|
+
};
|
|
189
|
+
const ended = (event) => {
|
|
190
|
+
if (event.target !== videos[shown]) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (face_clips_1.FaceClips.isMood(kind) || face_clips_1.FaceClips.isShow(kind)) {
|
|
194
|
+
moodDone = true;
|
|
195
|
+
}
|
|
196
|
+
if (!driving()) {
|
|
197
|
+
play(wanted());
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* She stood up to dance or stretch and the call goes on (the user speaks, Ta thinks or answers): she hurries
|
|
202
|
+
* back to the sofa, its end, rather than the clip cutting away; true while she does.
|
|
203
|
+
*/
|
|
204
|
+
const hurrying = () => {
|
|
205
|
+
const video = videos[shown];
|
|
206
|
+
if (!face_clips_1.FaceClips.isShow(kind) || moodDone || names[shown] !== kind || video.ended) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
if (call.state.phase !== 'listening' || call.state.heard.trim()) {
|
|
210
|
+
video.playbackRate = HURRY_RATE;
|
|
211
|
+
}
|
|
212
|
+
return true;
|
|
213
|
+
};
|
|
214
|
+
const failed = () => !ready && onFailed();
|
|
215
|
+
for (const video of videos) {
|
|
216
|
+
video.addEventListener('ended', ended);
|
|
217
|
+
video.addEventListener('error', failed);
|
|
218
|
+
}
|
|
219
|
+
// The clips as they are now, not as a cache kept them from a Ta before (faces/README.md); then the face moves.
|
|
220
|
+
void faces.ready.then(() => !gone && play(wanted()));
|
|
221
|
+
const timer = setInterval(() => {
|
|
222
|
+
const said = call.state.phase === 'speaking' ? words() : undefined;
|
|
223
|
+
const then = face_clips_1.FaceClips.show(said);
|
|
224
|
+
if (then && said !== comingFor) {
|
|
225
|
+
comingFor = said;
|
|
226
|
+
coming = then;
|
|
227
|
+
}
|
|
228
|
+
if (!faces.loaded || hurrying() || driving()) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
const next = wanted();
|
|
232
|
+
if (next !== kind) {
|
|
233
|
+
play(next);
|
|
234
|
+
}
|
|
235
|
+
// Paused (the page hidden), it holds still; it moves again as the call does.
|
|
236
|
+
const now = videos[shown];
|
|
237
|
+
if (call.state.paused && !now.paused) {
|
|
238
|
+
now.pause();
|
|
239
|
+
}
|
|
240
|
+
else if (!call.state.paused && now.paused && ready && names[shown]) {
|
|
241
|
+
void now.play().catch(() => undefined);
|
|
242
|
+
}
|
|
243
|
+
}, TICK_MS);
|
|
244
|
+
const layer = new MouthLayer(call, planOf, canvas.current, view, faces, () => {
|
|
245
|
+
const reading = driving();
|
|
246
|
+
const clip = names[shown];
|
|
247
|
+
return reading && clip ? { reading, video: videos[shown], clip } : undefined;
|
|
248
|
+
});
|
|
249
|
+
void layer.open(mouth.current);
|
|
250
|
+
layer.watch(videos);
|
|
251
|
+
// Each frame: the clip of the moment of the sound, kept on its clock, and the mouth drawn for it.
|
|
252
|
+
let held;
|
|
253
|
+
let heldAt = 0;
|
|
254
|
+
let frame = view.requestAnimationFrame(function tick() {
|
|
255
|
+
if (gone) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
frame = view.requestAnimationFrame(tick);
|
|
259
|
+
const reading = driving();
|
|
260
|
+
if (!reading) {
|
|
261
|
+
layer.clear();
|
|
262
|
+
held = undefined;
|
|
263
|
+
if (!hurrying()) {
|
|
264
|
+
for (const video of videos) {
|
|
265
|
+
video.playbackRate = 1;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
if (!faces.loaded) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
const seconds = reading.now();
|
|
274
|
+
if (hurrying()) {
|
|
275
|
+
layer.follow(reading, seconds);
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
const at = planOf(reading.say).at(seconds);
|
|
279
|
+
const video = videos[shown];
|
|
280
|
+
if (names[shown] !== at.clip) {
|
|
281
|
+
if (loading !== at.clip) {
|
|
282
|
+
kind = 'speaking';
|
|
283
|
+
show(at.clip, at.frame / clip_plan_1.CLIP_FPS);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
// The sound stopped short (what comes next is late): she holds still until it goes on.
|
|
288
|
+
const time = view.performance.now();
|
|
289
|
+
if (seconds !== held) {
|
|
290
|
+
held = seconds;
|
|
291
|
+
heldAt = time;
|
|
292
|
+
}
|
|
293
|
+
const still = time - heldAt > STILL_MS;
|
|
294
|
+
if (still !== video.paused) {
|
|
295
|
+
void (still ? video.pause() : video.play().catch(() => undefined));
|
|
296
|
+
}
|
|
297
|
+
const sync = clip_plan_1.ClipSync.step(at.frame / clip_plan_1.CLIP_FPS, video.currentTime);
|
|
298
|
+
if (sync.seek !== undefined) {
|
|
299
|
+
video.currentTime = sync.seek;
|
|
300
|
+
}
|
|
301
|
+
video.playbackRate = sync.rate;
|
|
302
|
+
}
|
|
303
|
+
layer.follow(reading, seconds);
|
|
304
|
+
});
|
|
305
|
+
return () => {
|
|
306
|
+
gone = true;
|
|
307
|
+
view.cancelAnimationFrame(frame);
|
|
308
|
+
layer.close();
|
|
309
|
+
clearInterval(timer);
|
|
310
|
+
for (const video of videos) {
|
|
311
|
+
video.removeEventListener('ended', ended);
|
|
312
|
+
video.removeEventListener('error', failed);
|
|
313
|
+
video.pause();
|
|
314
|
+
video.removeAttribute('src');
|
|
315
|
+
video.load();
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
}, [call]);
|
|
319
|
+
const poster = face_files_1.FaceFiles.poster((_b = (_a = box.current) === null || _a === void 0 ? void 0 : _a.ownerDocument) !== null && _b !== void 0 ? _b : document);
|
|
320
|
+
return (React.createElement("div", { ref: box, className: "ta-video-clips" },
|
|
321
|
+
layers.map((layer, index) => (React.createElement("video", {
|
|
322
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: two fixed layers
|
|
323
|
+
key: index, ref: layer, className: `ta-video-clip${front === index ? ' ta-front' : ''}`, poster: poster, muted: true, playsInline: true, preload: "auto", disablePictureInPicture: true }))),
|
|
324
|
+
React.createElement("canvas", { ref: canvas, className: "ta-video-mouth" })));
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* The mouth an extension draws for what Ta reads (WebCallMouth), laid over the clip: told the sound of each reading as
|
|
328
|
+
* it comes with the frame of the clip at each moment of it (ClipPlan), it gives that frame's lower face drawn again
|
|
329
|
+
* for that sound. As each frame of the clip is shown (requestVideoFrameCallback), that frame and the mouth of that
|
|
330
|
+
* moment of the sound are drawn together, the mouth moved with her face when it was drawn for a frame near it: the
|
|
331
|
+
* clip and the sound keep their own clocks a little apart. The reading waits for it as long as it asks (holdMs).
|
|
332
|
+
*/
|
|
333
|
+
class MouthLayer {
|
|
334
|
+
constructor(call, planOf, canvas, view, faces, showing) {
|
|
335
|
+
this.call = call;
|
|
336
|
+
this.planOf = planOf;
|
|
337
|
+
this.canvas = canvas;
|
|
338
|
+
this.view = view;
|
|
339
|
+
this.faces = faces;
|
|
340
|
+
this.showing = showing;
|
|
341
|
+
this.closed = false;
|
|
342
|
+
/** Of each reading: the seconds of its sound that came, and the slots told. */
|
|
343
|
+
this.sounds = new Map();
|
|
344
|
+
this.atSlot = -1;
|
|
345
|
+
/** The canvas shows the frames of the clip now, not the layers of video under it. */
|
|
346
|
+
this.drawing = false;
|
|
347
|
+
}
|
|
348
|
+
async open(mouth) {
|
|
349
|
+
var _a;
|
|
350
|
+
const session = await (mouth === null || mouth === void 0 ? void 0 : mouth.open().catch(() => undefined));
|
|
351
|
+
if (!session) {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
if (this.closed) {
|
|
355
|
+
session.close();
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
this.session = session;
|
|
359
|
+
this.missed = (_a = this.call.sounds.nowReading()) === null || _a === void 0 ? void 0 : _a.say;
|
|
360
|
+
this.call.sounds.hold(session.holdMs);
|
|
361
|
+
this.offSound = this.call.sounds.on((say, pcm, rate) => this.sound(say, pcm, rate));
|
|
362
|
+
}
|
|
363
|
+
sound(say, pcm, rate) {
|
|
364
|
+
var _a;
|
|
365
|
+
var _b, _c;
|
|
366
|
+
const session = this.session;
|
|
367
|
+
if (!session || say === this.missed) {
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
if (!this.sounds.has(say)) {
|
|
371
|
+
// A reading begins: it waits as long as the mouth asks, more while the mouth starts.
|
|
372
|
+
this.call.sounds.hold(session.holdMs + Math.min(STARTING_MS, (_b = (_a = session.readyIn) === null || _a === void 0 ? void 0 : _a.call(session)) !== null && _b !== void 0 ? _b : 0));
|
|
373
|
+
}
|
|
374
|
+
const heard = (_c = this.sounds.get(say)) !== null && _c !== void 0 ? _c : { seconds: 0, told: 0 };
|
|
375
|
+
this.sounds.set(say, heard);
|
|
376
|
+
for (const old of this.sounds.keys()) {
|
|
377
|
+
if (old < say - 1) {
|
|
378
|
+
this.sounds.delete(old);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
if (pcm) {
|
|
382
|
+
heard.seconds += pcm.byteLength / 2 / rate;
|
|
383
|
+
}
|
|
384
|
+
const upto = pcm ? Math.floor(heard.seconds * session.fps) : Math.ceil(heard.seconds * session.fps);
|
|
385
|
+
const plan = this.planOf(say);
|
|
386
|
+
const slots = [];
|
|
387
|
+
for (let slot = heard.told; slot < upto; slot++) {
|
|
388
|
+
const { clip, frame } = plan.at(slot / session.fps);
|
|
389
|
+
slots.push([clip, frame]);
|
|
390
|
+
}
|
|
391
|
+
const first = heard.told;
|
|
392
|
+
heard.told = Math.max(heard.told, upto);
|
|
393
|
+
session.sound(say, pcm, rate, slots, first);
|
|
394
|
+
}
|
|
395
|
+
/** The reading plays at `seconds` of its sound: the extension knows what it need not draw any more. */
|
|
396
|
+
follow(reading, seconds) {
|
|
397
|
+
const session = this.session;
|
|
398
|
+
if (!session) {
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
if (this.say !== undefined && this.say !== reading.say) {
|
|
402
|
+
session.cut(this.say);
|
|
403
|
+
}
|
|
404
|
+
this.say = reading.say;
|
|
405
|
+
const slot = Math.floor(seconds * session.fps);
|
|
406
|
+
if (slot !== this.atSlot) {
|
|
407
|
+
this.atSlot = slot;
|
|
408
|
+
session.at(reading.say, slot);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
/** Draws as each frame of the layers of video is shown, the one in front. */
|
|
412
|
+
watch(videos) {
|
|
413
|
+
const offs = videos.map(video => {
|
|
414
|
+
if (typeof video.requestVideoFrameCallback !== 'function') {
|
|
415
|
+
return () => undefined;
|
|
416
|
+
}
|
|
417
|
+
const shown = (_now, frame) => {
|
|
418
|
+
handle = video.requestVideoFrameCallback(shown);
|
|
419
|
+
this.shown(video, frame.mediaTime);
|
|
420
|
+
};
|
|
421
|
+
let handle = video.requestVideoFrameCallback(shown);
|
|
422
|
+
return () => video.cancelVideoFrameCallback(handle);
|
|
423
|
+
});
|
|
424
|
+
this.offFrames = () => {
|
|
425
|
+
for (const off of offs) {
|
|
426
|
+
off();
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
/** A frame of `video` is shown, `mediaTime` into its clip: it is drawn, with the mouth of the moment over it. */
|
|
431
|
+
shown(video, mediaTime) {
|
|
432
|
+
var _a, _b, _c;
|
|
433
|
+
const session = this.session;
|
|
434
|
+
const canvas = this.canvas;
|
|
435
|
+
const now = this.showing();
|
|
436
|
+
if (!session || !canvas || !now || now.video !== video || !video.videoWidth) {
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
const context = this.fit(canvas);
|
|
440
|
+
if (!context) {
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
const width = canvas.width;
|
|
444
|
+
const height = canvas.height;
|
|
445
|
+
const scale = Math.max(width / video.videoWidth, height / video.videoHeight);
|
|
446
|
+
const left = (width - video.videoWidth * scale) * 0.5;
|
|
447
|
+
const top = (height - video.videoHeight * scale) * 0.3;
|
|
448
|
+
context.drawImage(video, left, top, video.videoWidth * scale, video.videoHeight * scale);
|
|
449
|
+
this.drawing = true;
|
|
450
|
+
const shownFrame = Math.round(mediaTime * clip_plan_1.CLIP_FPS);
|
|
451
|
+
const drawn = this.nearest(session, now.reading.say, Math.floor(now.reading.now() * session.fps), now.clip, shownFrame);
|
|
452
|
+
const at = this.place(drawn, now.clip, shownFrame);
|
|
453
|
+
if (drawn && at) {
|
|
454
|
+
context.drawImage(drawn.image, left + at[0] * scale, top + at[1] * scale, at[2] * scale, at[3] * scale);
|
|
455
|
+
}
|
|
456
|
+
// How many frames showed while Ta read, and how many with her mouth: read by checks of the call (and by anyone curious).
|
|
457
|
+
canvas.dataset.frames = String(Number((_a = canvas.dataset.frames) !== null && _a !== void 0 ? _a : 0) + 1);
|
|
458
|
+
canvas.dataset.mouths = String(Number((_b = canvas.dataset.mouths) !== null && _b !== void 0 ? _b : 0) + (drawn && at ? 1 : 0));
|
|
459
|
+
if (drawn && at) {
|
|
460
|
+
canvas.dataset.apart = String(Number((_c = canvas.dataset.apart) !== null && _c !== void 0 ? _c : 0) + Math.abs(drawn.frame - shownFrame));
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* The mouth of the moment of the sound, or of the slot just before or after it if that one was drawn for a frame
|
|
465
|
+
* nearer the one shown (the frame comes to the screen a little after its moment): a mouth a slot early or late is
|
|
466
|
+
* not seen, one laid over a frame it was not drawn for is.
|
|
467
|
+
*/
|
|
468
|
+
nearest(session, say, slot, clip, frame) {
|
|
469
|
+
let best;
|
|
470
|
+
for (const near of [slot, slot - 1, slot + 1]) {
|
|
471
|
+
const drawn = session.frame(say, near);
|
|
472
|
+
if ((drawn === null || drawn === void 0 ? void 0 : drawn.clip) === clip && (!best || Math.abs(drawn.frame - frame) < Math.abs(best.frame - frame))) {
|
|
473
|
+
best = drawn;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
return best !== null && best !== void 0 ? best : session.frame(say, slot);
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Where the mouth drawn goes over `frame` of `clip`: its place in the frame it was drawn for, moved and scaled as her
|
|
480
|
+
* face is from that frame to this one; undefined when it is of another clip, or of a frame too far.
|
|
481
|
+
*/
|
|
482
|
+
place(drawn, clip, frame) {
|
|
483
|
+
if (!drawn || drawn.clip !== clip || Math.abs(drawn.frame - frame) > NEAR_FRAMES) {
|
|
484
|
+
return undefined;
|
|
485
|
+
}
|
|
486
|
+
const boxes = this.faces.boxes(clip);
|
|
487
|
+
const from = boxes === null || boxes === void 0 ? void 0 : boxes[drawn.frame];
|
|
488
|
+
const to = boxes === null || boxes === void 0 ? void 0 : boxes[Math.min(frame, boxes.length - 1)];
|
|
489
|
+
const [x, y, w, h] = drawn.box;
|
|
490
|
+
if (!from || !to || drawn.frame === frame) {
|
|
491
|
+
return [x, y, w, h];
|
|
492
|
+
}
|
|
493
|
+
const sx = (to[2] - to[0]) / Math.max(1, from[2] - from[0]);
|
|
494
|
+
const sy = (to[3] - to[1]) / Math.max(1, from[3] - from[1]);
|
|
495
|
+
return [to[0] + (x - from[0]) * sx, to[1] + (y - from[1]) * sy, w * sx, h * sy];
|
|
496
|
+
}
|
|
497
|
+
/** Nothing over the clip: Ta is not reading with its voice service now. */
|
|
498
|
+
clear() {
|
|
499
|
+
var _a;
|
|
500
|
+
if (this.say !== undefined) {
|
|
501
|
+
(_a = this.session) === null || _a === void 0 ? void 0 : _a.cut(this.say);
|
|
502
|
+
this.say = undefined;
|
|
503
|
+
this.atSlot = -1;
|
|
504
|
+
}
|
|
505
|
+
if (this.drawing && this.canvas) {
|
|
506
|
+
this.drawing = false;
|
|
507
|
+
this.fit(this.canvas);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
/** The canvas the size it shows at, cleared. */
|
|
511
|
+
fit(canvas) {
|
|
512
|
+
const ratio = Math.min(2, this.view.devicePixelRatio || 1);
|
|
513
|
+
const width = Math.round(canvas.clientWidth * ratio);
|
|
514
|
+
const height = Math.round(canvas.clientHeight * ratio);
|
|
515
|
+
if (canvas.width !== width || canvas.height !== height) {
|
|
516
|
+
canvas.width = width;
|
|
517
|
+
canvas.height = height;
|
|
518
|
+
}
|
|
519
|
+
const context = canvas.getContext('2d');
|
|
520
|
+
context === null || context === void 0 ? void 0 : context.clearRect(0, 0, width, height);
|
|
521
|
+
return context;
|
|
522
|
+
}
|
|
523
|
+
close() {
|
|
524
|
+
var _a, _b, _c;
|
|
525
|
+
this.closed = true;
|
|
526
|
+
(_a = this.offSound) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
527
|
+
(_b = this.offFrames) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
528
|
+
(_c = this.session) === null || _c === void 0 ? void 0 : _c.close();
|
|
529
|
+
this.session = undefined;
|
|
530
|
+
this.call.sounds.hold(0);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
//# sourceMappingURL=video-face.js.map
|
|
@@ -41,6 +41,7 @@ export declare abstract class WorkbenchHosts extends WorkbenchLists {
|
|
|
41
41
|
protected abstract open(credential: Credential): {
|
|
42
42
|
connection: TaConnection;
|
|
43
43
|
refused(): Promise<boolean>;
|
|
44
|
+
direct?(server: TaServerInfo): void;
|
|
44
45
|
};
|
|
45
46
|
abstract signOut(): void;
|
|
46
47
|
}
|
|
@@ -88,6 +88,8 @@ export interface WorkbenchPages {
|
|
|
88
88
|
readonly agent: boolean;
|
|
89
89
|
/** Answers `kind` (`<package>/<kind>`, `ta/<kind>`) from now on; the function returned stops. */
|
|
90
90
|
answer(kind: string, handler: (payload: unknown) => unknown): () => void;
|
|
91
|
+
/** The device the page runs on, as it lays itself out (setDevice). */
|
|
92
|
+
readonly device: 'phone' | 'tablet' | 'computer';
|
|
91
93
|
setDevice(device: 'phone' | 'tablet' | 'computer'): void;
|
|
92
94
|
}
|
|
93
95
|
export interface TaWorkbench {
|
|
@@ -60,6 +60,11 @@ export declare namespace WorkbenchUtil {
|
|
|
60
60
|
function reachable(base: string, fetcher?: typeof fetch): Promise<boolean>;
|
|
61
61
|
/** The hosts kept in `storage`; the token or pairing an older version kept becomes the first. */
|
|
62
62
|
function readHosts(storage: Storage | undefined, now?: number): HostList;
|
|
63
|
+
/**
|
|
64
|
+
* A pairing with the ways to its computer that computer told (TaServerInfo.relays), the same credential when they did not
|
|
65
|
+
* change or it told none (a ta serve of before), or it is no pairing.
|
|
66
|
+
*/
|
|
67
|
+
function routed(credential: Credential, relays: readonly string[] | undefined): Credential;
|
|
63
68
|
/** Which ta serve a credential reaches, to know whose lists were kept: that of the page (`host`) for a token alone. */
|
|
64
69
|
function serverOf(credential: Credential, host: string): string;
|
|
65
70
|
/** Where the ta serve of a token answers: its own address, or that of the page. */
|
|
@@ -137,6 +137,24 @@ var WorkbenchUtil;
|
|
|
137
137
|
return credential ? hosts_1.HostUtil.use({ hosts: [] }, serverOf(credential, pageHost()), credential, now) : { hosts: [] };
|
|
138
138
|
}
|
|
139
139
|
WorkbenchUtil.readHosts = readHosts;
|
|
140
|
+
/**
|
|
141
|
+
* A pairing with the ways to its computer that computer told (TaServerInfo.relays), the same credential when they did not
|
|
142
|
+
* change or it told none (a ta serve of before), or it is no pairing.
|
|
143
|
+
*/
|
|
144
|
+
function routed(credential, relays) {
|
|
145
|
+
if (!('pairing' in credential) || !Array.isArray(relays)) {
|
|
146
|
+
return credential;
|
|
147
|
+
}
|
|
148
|
+
const told = ta_relay_1.RelayPairingUtil.routes(relays);
|
|
149
|
+
const before = ta_relay_1.RelayPairingUtil.routes(credential.pairing.relays);
|
|
150
|
+
if (told.join(' ') === before.join(' ')) {
|
|
151
|
+
return credential;
|
|
152
|
+
}
|
|
153
|
+
const { relays: _before, ...pairing } = credential.pairing;
|
|
154
|
+
// Its own relay alone is what a pairing without ways does.
|
|
155
|
+
return { pairing: told.length && told.join(' ') !== pairing.relay ? { ...pairing, relays: told } : pairing };
|
|
156
|
+
}
|
|
157
|
+
WorkbenchUtil.routed = routed;
|
|
140
158
|
/** Which ta serve a credential reaches, to know whose lists were kept: that of the page (`host`) for a token alone. */
|
|
141
159
|
function serverOf(credential, host) {
|
|
142
160
|
if ('pairing' in credential) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TaConnection } from '@celljs/ta-client';
|
|
2
|
+
import { type TaServerInfo } from '@celljs/ta-protocol';
|
|
2
3
|
import { PresenceReporter } from './presence/presence-reporter';
|
|
3
4
|
import { PageAnswers } from './screen/page-answers';
|
|
4
5
|
import { WorkbenchCalls } from './workbench-calls';
|
|
@@ -12,6 +13,10 @@ export declare class TaWorkbenchImpl extends WorkbenchHosts implements TaWorkben
|
|
|
12
13
|
/** What ta serve may ask this page, and what it is told of the page (docs/design/ta-app-use.md 4.1). */
|
|
13
14
|
readonly pages: PageAnswers;
|
|
14
15
|
protected retryTimer?: ReturnType<typeof setTimeout>;
|
|
16
|
+
/** By computer, what it said a direct connection to it takes (TaServerInfo.direct), for the connections of later. */
|
|
17
|
+
protected readonly directs: Map<string, {
|
|
18
|
+
stun: string[];
|
|
19
|
+
}>;
|
|
15
20
|
/** A restart asked for: whether a build was installed over the one running, and whether its connection closed yet. */
|
|
16
21
|
protected restart?: {
|
|
17
22
|
update: boolean;
|
|
@@ -59,6 +64,7 @@ export declare class TaWorkbenchImpl extends WorkbenchHosts implements TaWorkben
|
|
|
59
64
|
protected open(credential: Credential): {
|
|
60
65
|
connection: TaConnection;
|
|
61
66
|
refused(): Promise<boolean>;
|
|
67
|
+
direct?(server: TaServerInfo): void;
|
|
62
68
|
};
|
|
63
69
|
/**
|
|
64
70
|
* Back to the sign-in, loaded again: what the page holds of the computer (the double's and the open
|