@celljs/ta-web 4.11.0 → 4.12.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/README.en.md +1 -1
- package/README.md +1 -1
- package/esm/browser/assistant/assistant-view.js +5 -2
- package/esm/browser/chat/chat-view.js +6 -5
- package/esm/browser/components/app-view.js +8 -4
- package/esm/browser/components/composer-box.d.ts +1 -0
- package/esm/browser/components/composer-box.js +50 -28
- package/esm/browser/components/composer.d.ts +3 -0
- package/esm/browser/components/composer.js +28 -2
- package/esm/browser/components/conversation-scroll-hooks.d.ts +16 -0
- package/esm/browser/components/conversation-scroll-hooks.js +98 -0
- package/esm/browser/components/conversation-scroll-util.d.ts +30 -0
- package/esm/browser/components/conversation-scroll-util.js +56 -0
- package/esm/browser/components/conversation-scroll.d.ts +45 -31
- package/esm/browser/components/conversation-scroll.js +125 -123
- package/esm/browser/components/face.d.ts +24 -0
- package/esm/browser/components/face.js +42 -0
- package/esm/browser/components/host-view.d.ts +1 -1
- package/esm/browser/components/media.js +59 -10
- package/esm/browser/components/message-actions.js +1 -0
- package/esm/browser/components/message-footer.d.ts +2 -0
- package/esm/browser/components/message-list.d.ts +3 -1
- package/esm/browser/components/message-list.js +55 -23
- package/esm/browser/components/phone-shell.js +2 -0
- package/esm/browser/components/session-view.d.ts +3 -1
- package/esm/browser/components/session-view.js +7 -3
- package/esm/browser/components/stop-times.d.ts +47 -0
- package/esm/browser/components/stop-times.js +81 -0
- package/esm/browser/components/use-stop-times.d.ts +3 -0
- package/esm/browser/components/use-stop-times.js +17 -0
- package/esm/browser/device/photo-picker.d.ts +14 -0
- package/esm/browser/device/photo-picker.js +48 -0
- package/esm/browser/device/row-swipe.d.ts +2 -0
- package/esm/browser/device/row-swipe.js +8 -2
- package/esm/browser/device/sheet-swipe.d.ts +1 -1
- package/esm/browser/device/sheet-swipe.js +17 -3
- package/esm/browser/extension/icons.js +2 -1
- package/esm/browser/extension/web-api-components.d.ts +18 -0
- package/esm/browser/extension/web-api-contributions.d.ts +9 -0
- package/esm/browser/extension/web-extension-api.d.ts +22 -2
- package/esm/browser/extension/web-extension-context.js +9 -1
- package/esm/browser/extension/web-extension-protocol.d.ts +13 -1
- package/esm/browser/extension/web-extension-protocol.js +1 -0
- package/esm/browser/extension/web-extensions.js +3 -0
- package/esm/browser/i18n/locales.d.ts +11 -1
- package/esm/browser/i18n/messages.d.ts +10 -0
- package/esm/browser/i18n/messages.js +20 -0
- package/esm/browser/links/links-protocol.d.ts +2 -0
- package/esm/browser/links/links.d.ts +7 -2
- package/esm/browser/links/links.js +16 -9
- package/esm/browser/style/conversation.d.ts +1 -1
- package/esm/browser/style/conversation.js +2 -0
- package/esm/browser/style/layout.d.ts +1 -1
- package/esm/browser/style/layout.js +3 -0
- package/esm/browser/style/pages.d.ts +1 -1
- package/esm/browser/style/pages.js +3 -0
- package/esm/browser/style/shell.d.ts +1 -1
- package/esm/browser/style/shell.js +2 -0
- package/esm/browser/style/surfaces.d.ts +1 -1
- package/esm/browser/style/surfaces.js +19 -0
- package/esm/browser/util/frame.d.ts +2 -0
- package/esm/browser/util/frame.js +2 -0
- package/esm/browser/util/process.d.ts +43 -1
- package/esm/browser/util/process.js +84 -3
- package/lib/browser/assistant/assistant-view.js +5 -2
- package/lib/browser/chat/chat-view.js +6 -5
- package/lib/browser/components/app-view.js +8 -4
- package/lib/browser/components/composer-box.d.ts +1 -0
- package/lib/browser/components/composer-box.js +48 -26
- package/lib/browser/components/composer.d.ts +3 -0
- package/lib/browser/components/composer.js +28 -2
- package/lib/browser/components/conversation-scroll-hooks.d.ts +17 -0
- package/lib/browser/components/conversation-scroll-hooks.js +135 -0
- package/lib/browser/components/conversation-scroll-util.d.ts +31 -0
- package/lib/browser/components/conversation-scroll-util.js +60 -0
- package/lib/browser/components/conversation-scroll.d.ts +45 -31
- package/lib/browser/components/conversation-scroll.js +126 -158
- package/lib/browser/components/face.d.ts +25 -0
- package/lib/browser/components/face.js +79 -0
- package/lib/browser/components/host-view.d.ts +1 -1
- package/lib/browser/components/media.js +59 -10
- package/lib/browser/components/message-actions.js +1 -0
- package/lib/browser/components/message-footer.d.ts +2 -0
- package/lib/browser/components/message-list.d.ts +3 -1
- package/lib/browser/components/message-list.js +53 -21
- package/lib/browser/components/phone-shell.js +2 -0
- package/lib/browser/components/session-view.d.ts +3 -1
- package/lib/browser/components/session-view.js +8 -4
- package/lib/browser/components/stop-times.d.ts +48 -0
- package/lib/browser/components/stop-times.js +85 -0
- package/lib/browser/components/use-stop-times.d.ts +4 -0
- package/lib/browser/components/use-stop-times.js +53 -0
- package/lib/browser/device/photo-picker.d.ts +15 -0
- package/lib/browser/device/photo-picker.js +51 -0
- package/lib/browser/device/row-swipe.d.ts +2 -0
- package/lib/browser/device/row-swipe.js +8 -2
- package/lib/browser/device/sheet-swipe.d.ts +1 -1
- package/lib/browser/device/sheet-swipe.js +17 -3
- package/lib/browser/extension/icons.js +1 -0
- package/lib/browser/extension/web-api-components.d.ts +18 -0
- package/lib/browser/extension/web-api-contributions.d.ts +9 -0
- package/lib/browser/extension/web-extension-api.d.ts +22 -2
- package/lib/browser/extension/web-extension-context.js +10 -2
- package/lib/browser/extension/web-extension-protocol.d.ts +13 -1
- package/lib/browser/extension/web-extension-protocol.js +1 -0
- package/lib/browser/extension/web-extensions.js +3 -0
- package/lib/browser/i18n/locales.d.ts +11 -1
- package/lib/browser/i18n/messages.d.ts +10 -0
- package/lib/browser/i18n/messages.js +20 -0
- package/lib/browser/links/links-protocol.d.ts +2 -0
- package/lib/browser/links/links.d.ts +7 -2
- package/lib/browser/links/links.js +16 -9
- package/lib/browser/style/conversation.d.ts +1 -1
- package/lib/browser/style/conversation.js +2 -0
- package/lib/browser/style/layout.d.ts +1 -1
- package/lib/browser/style/layout.js +3 -0
- package/lib/browser/style/pages.d.ts +1 -1
- package/lib/browser/style/pages.js +3 -0
- package/lib/browser/style/shell.d.ts +1 -1
- package/lib/browser/style/shell.js +2 -0
- package/lib/browser/style/surfaces.d.ts +1 -1
- package/lib/browser/style/surfaces.js +19 -0
- package/lib/browser/util/frame.d.ts +2 -0
- package/lib/browser/util/frame.js +2 -0
- package/lib/browser/util/process.d.ts +43 -1
- package/lib/browser/util/process.js +86 -4
- package/package.json +7 -7
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { StateSpec } from '../state/state-protocol';
|
|
2
|
+
/** How long the stop of a run took, as the box that pressed it saw it (Composer.onStopTimed). */
|
|
3
|
+
export interface StopTiming {
|
|
4
|
+
/** When it was pressed (`Date.now()` of the device). */
|
|
5
|
+
at: number;
|
|
6
|
+
/** From the press until the computer answered the stop (TaServer.abort): there and back, and the run winding down. */
|
|
7
|
+
answered?: number;
|
|
8
|
+
/** From the press until the run was seen ended (`working` false). */
|
|
9
|
+
ended?: number;
|
|
10
|
+
/** The stop failed (the connection lost): the button came back. */
|
|
11
|
+
failed?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/** One stop, kept: where it was pressed, and how long each part took. */
|
|
14
|
+
export interface StopTime extends StopTiming {
|
|
15
|
+
/** The first 8 characters of the session's id, as the line of `ta serve` that says how long it took there. */
|
|
16
|
+
session: string;
|
|
17
|
+
view: 'chat' | 'double';
|
|
18
|
+
device: 'phone' | 'tablet' | 'desktop';
|
|
19
|
+
/** Through the relay (a computer paired) or straight to its ta serve. */
|
|
20
|
+
link: 'relay' | 'direct';
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The last stops of every device, on the computer (the data of @celljs/ta-web, `stop.times`), to find where a slow
|
|
24
|
+
* stop spent its time: with the line `ta serve: stopped <session> in <ms>` of serve.log, what the run took to end on
|
|
25
|
+
* the computer; the rest of `answered` is the way there and back.
|
|
26
|
+
*/
|
|
27
|
+
export declare const STOP_TIMES: StateSpec<StopTime[]>;
|
|
28
|
+
export declare namespace StopTimeUtil {
|
|
29
|
+
function parse(value: unknown): StopTime[] | undefined;
|
|
30
|
+
/** The stops of both, each once, by when they were pressed; `a` itself when `b` adds nothing. */
|
|
31
|
+
function merge(a: StopTime[], b: StopTime[]): StopTime[];
|
|
32
|
+
function add(times: StopTime[], time: StopTime): StopTime[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The timing of one stop, from the press: told (`StopTiming`) by whichever of the answer of the computer and the
|
|
36
|
+
* end of the run comes last; the answer comes after the end, which the computer tells first. A failed stop is told
|
|
37
|
+
* at its answer, without an end. Once told, nothing more.
|
|
38
|
+
*/
|
|
39
|
+
export declare class StopClock {
|
|
40
|
+
protected readonly start: number;
|
|
41
|
+
protected readonly timing: StopTiming;
|
|
42
|
+
protected told: boolean;
|
|
43
|
+
constructor(start: number, at: number);
|
|
44
|
+
answered(now: number, failed?: boolean): StopTiming | undefined;
|
|
45
|
+
ended(now: number): StopTiming | undefined;
|
|
46
|
+
protected tell(): StopTiming | undefined;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=stop-times.d.ts.map
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StopClock = exports.StopTimeUtil = exports.STOP_TIMES = void 0;
|
|
4
|
+
/** The stops kept at most: the latest. */
|
|
5
|
+
const KEPT = 30;
|
|
6
|
+
/**
|
|
7
|
+
* The last stops of every device, on the computer (the data of @celljs/ta-web, `stop.times`), to find where a slow
|
|
8
|
+
* stop spent its time: with the line `ta serve: stopped <session> in <ms>` of serve.log, what the run took to end on
|
|
9
|
+
* the computer; the rest of `answered` is the way there and back.
|
|
10
|
+
*/
|
|
11
|
+
exports.STOP_TIMES = {
|
|
12
|
+
key: 'stop.times',
|
|
13
|
+
tier: 'user',
|
|
14
|
+
initial: [],
|
|
15
|
+
parse: value => StopTimeUtil.parse(value),
|
|
16
|
+
merge: (local, remote) => StopTimeUtil.merge(local, remote),
|
|
17
|
+
};
|
|
18
|
+
var StopTimeUtil;
|
|
19
|
+
(function (StopTimeUtil) {
|
|
20
|
+
const VIEWS = ['chat', 'double'];
|
|
21
|
+
const DEVICES = ['phone', 'tablet', 'desktop'];
|
|
22
|
+
const LINKS = ['relay', 'direct'];
|
|
23
|
+
function parse(value) {
|
|
24
|
+
if (!Array.isArray(value)) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
return value.filter((time) => !!time &&
|
|
28
|
+
typeof time.at === 'number' &&
|
|
29
|
+
typeof time.session === 'string' &&
|
|
30
|
+
VIEWS.includes(time.view) &&
|
|
31
|
+
DEVICES.includes(time.device) &&
|
|
32
|
+
LINKS.includes(time.link));
|
|
33
|
+
}
|
|
34
|
+
StopTimeUtil.parse = parse;
|
|
35
|
+
/** The stops of both, each once, by when they were pressed; `a` itself when `b` adds nothing. */
|
|
36
|
+
function merge(a, b) {
|
|
37
|
+
const keys = new Set(a.map(key));
|
|
38
|
+
const added = b.filter(time => !keys.has(key(time)));
|
|
39
|
+
return added.length ? [...a, ...added].sort((x, y) => x.at - y.at).slice(-KEPT) : a;
|
|
40
|
+
}
|
|
41
|
+
StopTimeUtil.merge = merge;
|
|
42
|
+
function add(times, time) {
|
|
43
|
+
return merge(times, [time]);
|
|
44
|
+
}
|
|
45
|
+
StopTimeUtil.add = add;
|
|
46
|
+
function key(time) {
|
|
47
|
+
return `${time.at}|${time.session}`;
|
|
48
|
+
}
|
|
49
|
+
})(StopTimeUtil || (exports.StopTimeUtil = StopTimeUtil = {}));
|
|
50
|
+
/**
|
|
51
|
+
* The timing of one stop, from the press: told (`StopTiming`) by whichever of the answer of the computer and the
|
|
52
|
+
* end of the run comes last; the answer comes after the end, which the computer tells first. A failed stop is told
|
|
53
|
+
* at its answer, without an end. Once told, nothing more.
|
|
54
|
+
*/
|
|
55
|
+
class StopClock {
|
|
56
|
+
constructor(start, at) {
|
|
57
|
+
this.start = start;
|
|
58
|
+
this.told = false;
|
|
59
|
+
this.timing = { at };
|
|
60
|
+
}
|
|
61
|
+
answered(now, failed = false) {
|
|
62
|
+
if (this.timing.answered === undefined) {
|
|
63
|
+
this.timing.answered = Math.round(now - this.start);
|
|
64
|
+
if (failed) {
|
|
65
|
+
this.timing.failed = true;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return this.tell();
|
|
69
|
+
}
|
|
70
|
+
ended(now) {
|
|
71
|
+
if (this.timing.ended === undefined && !this.timing.failed) {
|
|
72
|
+
this.timing.ended = Math.round(now - this.start);
|
|
73
|
+
}
|
|
74
|
+
return this.tell();
|
|
75
|
+
}
|
|
76
|
+
tell() {
|
|
77
|
+
if (this.told || this.timing.answered === undefined || (this.timing.ended === undefined && !this.timing.failed)) {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
this.told = true;
|
|
81
|
+
return { ...this.timing };
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.StopClock = StopClock;
|
|
85
|
+
//# sourceMappingURL=stop-times.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type StopTime, type StopTiming } from './stop-times';
|
|
2
|
+
/** What keeps the timing of a stop pressed in the box of `sessionId`, shown in `view`. */
|
|
3
|
+
export declare function useStopTimes(sessionId: string, view: StopTime['view']): (timing: StopTiming) => void;
|
|
4
|
+
//# sourceMappingURL=use-stop-times.d.ts.map
|
|
@@ -0,0 +1,53 @@
|
|
|
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.useStopTimes = useStopTimes;
|
|
37
|
+
const react_1 = require("@celljs/react");
|
|
38
|
+
const React = __importStar(require("react"));
|
|
39
|
+
const device_1 = require("../device/device");
|
|
40
|
+
const hooks_1 = require("../hooks");
|
|
41
|
+
const state_protocol_1 = require("../state/state-protocol");
|
|
42
|
+
const stop_times_1 = require("./stop-times");
|
|
43
|
+
/** What keeps the timing of a stop pressed in the box of `sessionId`, shown in `view`. */
|
|
44
|
+
function useStopTimes(sessionId, view) {
|
|
45
|
+
var _a;
|
|
46
|
+
const state = (0, react_1.useInject)(state_protocol_1.TaState);
|
|
47
|
+
const device = (0, device_1.useDevice)(device => (device.handheld ? 'phone' : device.touch ? 'tablet' : 'desktop'));
|
|
48
|
+
const [{ hosts, host }] = (0, hooks_1.useWorkbench)();
|
|
49
|
+
const credential = (_a = hosts.find(saved => saved.id === host)) === null || _a === void 0 ? void 0 : _a.credential;
|
|
50
|
+
const link = credential && 'pairing' in credential ? 'relay' : 'direct';
|
|
51
|
+
return React.useCallback((timing) => state.set(stop_times_1.STOP_TIMES, stop_times_1.StopTimeUtil.add(state.get(stop_times_1.STOP_TIMES), { ...timing, session: sessionId.slice(0, 8), view, device, link })), [state, sessionId, view, device, link]);
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=use-stop-times.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The photos of the device, picked in the library itself as WeChat's Album does: the Ta app on iOS opens it at once
|
|
3
|
+
* (PHPicker, which asks for no permission), where a file field shows a menu first (Photo Library, Take Photo,
|
|
4
|
+
* Choose File). A browser has no such picker: the message box uses its file field there.
|
|
5
|
+
*/
|
|
6
|
+
export declare namespace PhotoPicker {
|
|
7
|
+
/** Whether the library opens at once here. */
|
|
8
|
+
function available(): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Up to `limit` photos, in the order picked; none when the user cancels. Not timed out: the user takes the time
|
|
11
|
+
* they need, and a pick started again ends the one before with none.
|
|
12
|
+
*/
|
|
13
|
+
function pick(limit: number): Promise<File[]>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=photo-picker.d.ts.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PhotoPicker = void 0;
|
|
4
|
+
const recent_shots_1 = require("./recent-shots");
|
|
5
|
+
/**
|
|
6
|
+
* The photos of the device, picked in the library itself as WeChat's Album does: the Ta app on iOS opens it at once
|
|
7
|
+
* (PHPicker, which asks for no permission), where a file field shows a menu first (Photo Library, Take Photo,
|
|
8
|
+
* Choose File). A browser has no such picker: the message box uses its file field there.
|
|
9
|
+
*/
|
|
10
|
+
var PhotoPicker;
|
|
11
|
+
(function (PhotoPicker) {
|
|
12
|
+
let next = 0;
|
|
13
|
+
function native() {
|
|
14
|
+
var _a, _b;
|
|
15
|
+
return (_b = (_a = globalThis.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b.taShots;
|
|
16
|
+
}
|
|
17
|
+
/** Whether the library opens at once here. */
|
|
18
|
+
function available() {
|
|
19
|
+
return native() !== undefined;
|
|
20
|
+
}
|
|
21
|
+
PhotoPicker.available = available;
|
|
22
|
+
/**
|
|
23
|
+
* Up to `limit` photos, in the order picked; none when the user cancels. Not timed out: the user takes the time
|
|
24
|
+
* they need, and a pick started again ends the one before with none.
|
|
25
|
+
*/
|
|
26
|
+
function pick(limit) {
|
|
27
|
+
const photos = native();
|
|
28
|
+
if (!photos) {
|
|
29
|
+
return Promise.resolve([]);
|
|
30
|
+
}
|
|
31
|
+
const id = `p${++next}`;
|
|
32
|
+
return new Promise(resolve => {
|
|
33
|
+
const onEvent = (event) => {
|
|
34
|
+
const detail = event.detail;
|
|
35
|
+
if ((detail === null || detail === void 0 ? void 0 : detail.id) !== id) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
globalThis.removeEventListener(recent_shots_1.RecentShots.EVENT, onEvent);
|
|
39
|
+
const images = Array.isArray(detail.images) ? detail.images : [];
|
|
40
|
+
resolve(images
|
|
41
|
+
.filter((image) => typeof image === 'string')
|
|
42
|
+
.map((image, index) => recent_shots_1.RecentShots.file(image, `photo-${index + 1}`))
|
|
43
|
+
.filter((file) => file !== undefined));
|
|
44
|
+
};
|
|
45
|
+
globalThis.addEventListener(recent_shots_1.RecentShots.EVENT, onEvent);
|
|
46
|
+
photos.postMessage({ id, action: 'pick', limit: Math.max(1, limit) });
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
PhotoPicker.pick = pick;
|
|
50
|
+
})(PhotoPicker || (exports.PhotoPicker = PhotoPicker = {}));
|
|
51
|
+
//# sourceMappingURL=photo-picker.js.map
|
|
@@ -33,6 +33,8 @@ export declare namespace RowSwipeUtil {
|
|
|
33
33
|
* of how many there are: 1 for the first, less for those after).
|
|
34
34
|
*/
|
|
35
35
|
function shift(offset: number, width: number, share: number): number;
|
|
36
|
+
/** Whether a touch at `x`, on a screen `width` wide, is at an edge a sheet comes from (`sides`: the root's `data-edge-swipe`), which rows leave to it. */
|
|
37
|
+
function atSheetEdge(sides: string | undefined, x: number, width: number): boolean;
|
|
36
38
|
/** Whether the move so far is the row's (more sideways than down, to the left unless open); undefined until it is told. */
|
|
37
39
|
function claims(dx: number, dy: number, open: boolean): boolean | undefined;
|
|
38
40
|
}
|
|
@@ -103,6 +103,13 @@ var RowSwipeUtil;
|
|
|
103
103
|
return (width + offset) * share;
|
|
104
104
|
}
|
|
105
105
|
RowSwipeUtil.shift = shift;
|
|
106
|
+
/** Whether a touch at `x`, on a screen `width` wide, is at an edge a sheet comes from (`sides`: the root's `data-edge-swipe`), which rows leave to it. */
|
|
107
|
+
function atSheetEdge(sides, x, width) {
|
|
108
|
+
var _a;
|
|
109
|
+
const list = (_a = sides === null || sides === void 0 ? void 0 : sides.split(' ')) !== null && _a !== void 0 ? _a : [];
|
|
110
|
+
return (list.includes('right') && x >= width - sheet_swipe_1.SwipeUtil.EDGE_PX) || (list.includes('left') && x <= sheet_swipe_1.SwipeUtil.EDGE_PX);
|
|
111
|
+
}
|
|
112
|
+
RowSwipeUtil.atSheetEdge = atSheetEdge;
|
|
106
113
|
/** Whether the move so far is the row's (more sideways than down, to the left unless open); undefined until it is told. */
|
|
107
114
|
function claims(dx, dy, open) {
|
|
108
115
|
if (Math.hypot(dx, dy) < sheet_swipe_1.SwipeUtil.SLOP_PX) {
|
|
@@ -245,8 +252,7 @@ function useRowSwipe(ref, enabled) {
|
|
|
245
252
|
const touch = event.touches[0];
|
|
246
253
|
claimed = undefined;
|
|
247
254
|
// A swipe from the edge a sheet comes from is the sheet's (useSheetSwipe's edgeOver), not the row's.
|
|
248
|
-
const
|
|
249
|
-
const edge = !!touch && (side === 'right' ? touch.clientX >= window.innerWidth - sheet_swipe_1.SwipeUtil.EDGE_PX : side === 'left' && touch.clientX <= sheet_swipe_1.SwipeUtil.EDGE_PX);
|
|
255
|
+
const edge = !!touch && RowSwipeUtil.atSheetEdge(document.documentElement.dataset.edgeSwipe, touch.clientX, window.innerWidth);
|
|
250
256
|
// A game in the row slides for itself (OwnGestures).
|
|
251
257
|
start =
|
|
252
258
|
touch && !edge && !own_gestures_1.OwnGestures.within(event.target) && finger.follow(event, row)
|
|
@@ -191,7 +191,7 @@ export interface SheetSwipeOptions extends SheetSwipe {
|
|
|
191
191
|
scrim?: string;
|
|
192
192
|
/**
|
|
193
193
|
* Over these (rows a finger swipes, SwipeRow), a sheet that opens from anywhere opens only from the edge:
|
|
194
|
-
* the row has the swipe. The root then carries `data-edge-swipe` (the
|
|
194
|
+
* the row has the swipe. The root then carries `data-edge-swipe` (the sides, as a list), whose edges rows leave to it.
|
|
195
195
|
*/
|
|
196
196
|
edgeOver?: string;
|
|
197
197
|
/** What the root's `data-sheet-drag` says while the finger moves it, for styles that tell one sheet from another. */
|
|
@@ -706,13 +706,27 @@ function useSheetSwipe(options) {
|
|
|
706
706
|
from.doc.addEventListener('touchstart', begin, { passive: true });
|
|
707
707
|
return () => from.doc.removeEventListener('touchstart', begin);
|
|
708
708
|
});
|
|
709
|
-
|
|
709
|
+
// Of the sheets of both sides (the board, the workbench), each says its own.
|
|
710
|
+
const edge = latest.current.edgeOver ? latest.current.side : undefined;
|
|
711
|
+
const sides = (change) => {
|
|
712
|
+
var _a;
|
|
713
|
+
const next = change(((_a = root.dataset.edgeSwipe) !== null && _a !== void 0 ? _a : '').split(' ').filter(Boolean));
|
|
714
|
+
if (next.length) {
|
|
715
|
+
root.dataset.edgeSwipe = next.join(' ');
|
|
716
|
+
}
|
|
717
|
+
else {
|
|
718
|
+
delete root.dataset.edgeSwipe;
|
|
719
|
+
}
|
|
720
|
+
};
|
|
710
721
|
if (edge) {
|
|
711
|
-
|
|
722
|
+
sides(list => [...list, edge]);
|
|
712
723
|
}
|
|
713
724
|
return () => {
|
|
714
725
|
if (edge) {
|
|
715
|
-
|
|
726
|
+
sides(list => {
|
|
727
|
+
const at = list.indexOf(edge);
|
|
728
|
+
return at < 0 ? list : [...list.slice(0, at), ...list.slice(at + 1)];
|
|
729
|
+
});
|
|
716
730
|
}
|
|
717
731
|
sources.dispose();
|
|
718
732
|
finger.stop();
|
|
@@ -60,6 +60,7 @@ exports.WEB_ICONS = Object.freeze({
|
|
|
60
60
|
House: lucide_react_1.House,
|
|
61
61
|
Image: lucide_react_1.Image,
|
|
62
62
|
Info: lucide_react_1.Info,
|
|
63
|
+
KeyRound: lucide_react_1.KeyRound,
|
|
63
64
|
LayoutDashboard: lucide_react_1.LayoutDashboard,
|
|
64
65
|
Link: lucide_react_1.Link,
|
|
65
66
|
List: lucide_react_1.List,
|
|
@@ -175,6 +175,24 @@ export interface WebDialogProps {
|
|
|
175
175
|
onClose(): void;
|
|
176
176
|
children?: React.ReactNode;
|
|
177
177
|
}
|
|
178
|
+
export interface WebFaceProps {
|
|
179
|
+
/** One of the 16 faces; else that of `seed`. */
|
|
180
|
+
face?: number;
|
|
181
|
+
seed?: string;
|
|
182
|
+
size: number;
|
|
183
|
+
/** At work: the eyes look about. */
|
|
184
|
+
working?: boolean;
|
|
185
|
+
/** A dot at its corner: green online, grey not; none without. Its ring is `--ta-face-ring` (the page's colour). */
|
|
186
|
+
online?: boolean;
|
|
187
|
+
}
|
|
188
|
+
export interface WebGroupFaceProps {
|
|
189
|
+
members: readonly {
|
|
190
|
+
face?: number;
|
|
191
|
+
seed?: string;
|
|
192
|
+
working?: boolean;
|
|
193
|
+
}[];
|
|
194
|
+
size: number;
|
|
195
|
+
}
|
|
178
196
|
export interface WebStackProps {
|
|
179
197
|
/** The page under it. */
|
|
180
198
|
base: React.ReactNode;
|
|
@@ -175,6 +175,15 @@ export interface WebHomeItem {
|
|
|
175
175
|
at?: number;
|
|
176
176
|
/** Not seen yet: the amber dot of a row of the lists. */
|
|
177
177
|
unseen?: boolean;
|
|
178
|
+
/**
|
|
179
|
+
* The title of a section of its own, which the user folds as those of Ta (members, channels), after them: rows of the
|
|
180
|
+
* same section together. None: right under the double. Newer than some Ta apps, which list it under the double.
|
|
181
|
+
*/
|
|
182
|
+
section?: string;
|
|
183
|
+
/** Drawn in place of the icon on its tile, `size` wide: a face of its own (a group's). */
|
|
184
|
+
face?: React.ComponentType<{
|
|
185
|
+
size: number;
|
|
186
|
+
}>;
|
|
178
187
|
/** A promise keeps the row busy. */
|
|
179
188
|
open(): unknown;
|
|
180
189
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TaEvent, TaPackageServer, TaRemoteServer, TaRoomEvent, TaRoomServer, TaServer, TaSessionInfo, TaSettingsServer, TaTerminalServer, TaWorkspaceServer } from '@celljs/ta-protocol';
|
|
1
|
+
import type { TaEvent, TaPackageServer, TaRemoteServer, TaRoomEvent, TaRoomServer, TaSavedSessionInfo, TaServer, TaSessionInfo, TaSettingsServer, TaTerminalServer, TaWorkspaceServer } from '@celljs/ta-protocol';
|
|
2
2
|
import type * as React from 'react';
|
|
3
3
|
import type { Mood } from '../avatar/dino-avatar';
|
|
4
4
|
import type { DeviceState } from '../device/device-protocol';
|
|
@@ -6,7 +6,7 @@ import type { TaFiles } from '../files/files-protocol';
|
|
|
6
6
|
import type { GameProps } from '../game/game-protocol';
|
|
7
7
|
import type { Game3DProps } from '../game/game3d-protocol';
|
|
8
8
|
import type { Language, Theme } from '../settings/settings-protocol';
|
|
9
|
-
import type { CodeEditorProps, DiffEditorProps, WebComposerProps, WebDialogProps, WebEmptyProps, WebFolderPickerProps, WebFullScreenProps, WebHoldToTalkProps, WebImageViewerProps, WebModelPickerProps, WebPictureCardsProps, WebPictureProps, WebSelectBarProps, WebSelectCheckProps, WebSkeletonProps, WebStackProps, WebSwipeRowProps, WebSwitchProps, WebVoice } from './web-api-components';
|
|
9
|
+
import type { CodeEditorProps, DiffEditorProps, WebComposerProps, WebDialogProps, WebEmptyProps, WebFaceProps, WebFolderPickerProps, WebFullScreenProps, WebGroupFaceProps, WebHoldToTalkProps, WebImageViewerProps, WebModelPickerProps, WebPictureCardsProps, WebPictureProps, WebSelectBarProps, WebSelectCheckProps, WebSkeletonProps, WebStackProps, WebSwipeRowProps, WebSwitchProps, WebVoice } from './web-api-components';
|
|
10
10
|
import type { WebChatIconSource, WebCodeRendererProps, WebComposerAddon, WebCustomMessage, WebEditor, WebHomeEntry, WebHomeSource, WebMenuItem, WebSearchSource, WebSessionNotice, WebSettingsSection, WebShareTarget, WebTaskEntry, WebTaskRemoval, WebTaskSource, WebTool, WebToolRendererResolver, WebView, WebViewInfo, WidgetOptions } from './web-api-contributions';
|
|
11
11
|
import type { WebDesktop, WebFileDrag } from './web-api-desktop';
|
|
12
12
|
import type { WebTerminal, WebTerminalOptions } from './web-api-terminal';
|
|
@@ -134,6 +134,12 @@ export interface WebExtensionAPI {
|
|
|
134
134
|
* A session still opening (a promise of its id) is in front at once, as it opens, under `opening`: the user sees the click take.
|
|
135
135
|
*/
|
|
136
136
|
switchSession(session: string | Promise<string>, opening?: WebSessionOpening): Promise<void>;
|
|
137
|
+
/**
|
|
138
|
+
* Shows the conversation of a session file of Ta as the lists open it: at once as the page or the device has it,
|
|
139
|
+
* opened again in one round trip when it closed; false when no conversation has it. Newer than some Ta apps:
|
|
140
|
+
* `pi.openChat?.(…)`.
|
|
141
|
+
*/
|
|
142
|
+
openChat(sessionFile: string): Promise<boolean>;
|
|
137
143
|
/**
|
|
138
144
|
* Calls a method of the server side of the extension's package (`pi.host` of its package.json, which
|
|
139
145
|
* ta serve runs for the packages that come with Ta), with JSON values: what the page cannot do itself.
|
|
@@ -354,6 +360,12 @@ export interface WebExtensionUI {
|
|
|
354
360
|
* (`isStreaming`), what was said last. The same array until one changes.
|
|
355
361
|
*/
|
|
356
362
|
useSessions(): readonly TaSessionInfo[];
|
|
363
|
+
/**
|
|
364
|
+
* A React hook: the saved conversations of the last days (Settings.chatArchiveDays) as the lists of the page have
|
|
365
|
+
* them, read again as sessions close; not those older. The same array until one changes. Rather than reading
|
|
366
|
+
* `server.listSavedSessions()` again and again. Newer than some Ta apps: `pi.ui.useSavedSessions?.()`.
|
|
367
|
+
*/
|
|
368
|
+
useSavedSessions(): readonly TaSavedSessionInfo[];
|
|
357
369
|
/**
|
|
358
370
|
* Shows a view of any web extension by its id, `<extension name>/<view name>` (`assistant/assistant`
|
|
359
371
|
* for the double): a page in the main area, a tool of the workbench as its tab; `''` the conversation again.
|
|
@@ -436,6 +448,14 @@ export interface WebExtensionUI {
|
|
|
436
448
|
size?: number;
|
|
437
449
|
mark?: string;
|
|
438
450
|
}>;
|
|
451
|
+
/**
|
|
452
|
+
* The face of one who is not Ta, as the agents of channels have: a coloured shape with eyes that blink, one of 16,
|
|
453
|
+
* by `face` or the same for the same `seed` (an id) on every device; `online` a dot at its corner. Newer than
|
|
454
|
+
* some Ta apps: `pi.ui.Face ?? fallback`.
|
|
455
|
+
*/
|
|
456
|
+
readonly Face: React.ComponentType<WebFaceProps>;
|
|
457
|
+
/** A group, as a channel is drawn: the first of `members` in front, the next behind. Newer than some Ta apps. */
|
|
458
|
+
readonly GroupFace: React.ComponentType<WebGroupFaceProps>;
|
|
439
459
|
/** The lucide icons of the page, by name (extension/icons.ts): a web extension cannot import them. */
|
|
440
460
|
readonly icons: Readonly<Record<string, WebIcon>>;
|
|
441
461
|
/** Monaco, the editor of VS Code, on the text of a file; it loads the first time one is shown. */
|
|
@@ -39,9 +39,10 @@ const busy_1 = require("../components/busy");
|
|
|
39
39
|
const chat_list_1 = require("../components/chat-list");
|
|
40
40
|
const code_editor_1 = require("../components/code-editor");
|
|
41
41
|
const context_menu_1 = require("../components/context-menu");
|
|
42
|
-
const
|
|
42
|
+
const conversation_scroll_hooks_1 = require("../components/conversation-scroll-hooks");
|
|
43
43
|
const diff_editor_1 = require("../components/diff-editor");
|
|
44
44
|
const empty_state_1 = require("../components/empty-state");
|
|
45
|
+
const face_1 = require("../components/face");
|
|
45
46
|
const folder_picker_1 = require("../components/folder-picker");
|
|
46
47
|
const full_screen_1 = require("../components/full-screen");
|
|
47
48
|
const hold_to_talk_1 = require("../components/hold-to-talk");
|
|
@@ -207,6 +208,7 @@ class WebExtensionContext {
|
|
|
207
208
|
host.extensions.showPage('');
|
|
208
209
|
await shown;
|
|
209
210
|
}),
|
|
211
|
+
openChat: sessionFile => live(() => host.links.openConversation(sessionFile)),
|
|
210
212
|
openTemporary: (source, from) => live(() => host.extensions.openTemporary(source, from)),
|
|
211
213
|
callHost: (method, ...params) => live(() => workbench.packages.callPackageHost(run.loaded.name, method, params)),
|
|
212
214
|
reloadExtensions: () => live(() => host.extensions.reloadPackages()),
|
|
@@ -271,6 +273,10 @@ class WebExtensionContext {
|
|
|
271
273
|
const sessions = () => workbench.state.sessions;
|
|
272
274
|
return React.useSyncExternalStore(listener => workbench.subscribe(listener), sessions, sessions);
|
|
273
275
|
},
|
|
276
|
+
useSavedSessions: () => {
|
|
277
|
+
const saved = () => workbench.state.saved;
|
|
278
|
+
return React.useSyncExternalStore(listener => workbench.subscribe(listener), saved, saved);
|
|
279
|
+
},
|
|
274
280
|
useDevice: device_1.useDevice,
|
|
275
281
|
showView: id => (run.stopped ? Promise.resolve(false) : host.extensions.showView(id)),
|
|
276
282
|
usePages: () => {
|
|
@@ -311,11 +317,13 @@ class WebExtensionContext {
|
|
|
311
317
|
Game3D: this.game3d,
|
|
312
318
|
FullScreen: full_screen_1.FullScreen,
|
|
313
319
|
Stack: phone_shell_1.PhoneStack,
|
|
320
|
+
Face: face_1.Face,
|
|
321
|
+
GroupFace: face_1.GroupFace,
|
|
314
322
|
Composer: this.composer,
|
|
315
323
|
HoldToTalk: this.holdToTalk,
|
|
316
324
|
voice: this.voice,
|
|
317
325
|
Markdown: markdown_1.Markdown,
|
|
318
|
-
useChatScroll: (sent, key) => (0,
|
|
326
|
+
useChatScroll: (sent, key) => (0, conversation_scroll_hooks_1.useConversationScroll)(sent, { sentTo: 'bottom', key }),
|
|
319
327
|
Empty: empty_state_1.EmptyState,
|
|
320
328
|
Skeleton: list_skeleton_1.ListSkeleton,
|
|
321
329
|
useBusy: busy_1.useBusy,
|
|
@@ -137,6 +137,11 @@ export interface WebExtensionsState {
|
|
|
137
137
|
conversationShown: boolean;
|
|
138
138
|
/** The session of the conversation shown. */
|
|
139
139
|
sessionId?: string;
|
|
140
|
+
/**
|
|
141
|
+
* The list of the computer's extensions was asked for once, answered or not: before, the views of a first
|
|
142
|
+
* start (nothing kept, WebViewUtil.KEPT) are still on their way.
|
|
143
|
+
*/
|
|
144
|
+
loaded: boolean;
|
|
140
145
|
/** The view of the page shown in the main area; `''` for the conversation. */
|
|
141
146
|
page: string;
|
|
142
147
|
/** Counts the pages shown, the same one again too: on a phone a page shown comes to the front. */
|
|
@@ -177,7 +182,14 @@ export declare namespace WebLabelUtil {
|
|
|
177
182
|
}
|
|
178
183
|
/** What `on` and `sendUserMessage` of web extensions reach: the conversation shown. */
|
|
179
184
|
/** Shows a session as the conversation: `switchSession` of web extensions. */
|
|
180
|
-
|
|
185
|
+
/**
|
|
186
|
+
* What the page shows as the conversation: an open session by its id, one still opening by the promise of its id, or the
|
|
187
|
+
* conversation of a session file, opened as the lists open it (at once from what the page or the device has).
|
|
188
|
+
*/
|
|
189
|
+
export type WebSessionTarget = string | Promise<string> | {
|
|
190
|
+
sessionFile: string;
|
|
191
|
+
};
|
|
192
|
+
export type WebSessionSwitcher = (session: WebSessionTarget, opening?: WebSessionOpening) => Promise<void>;
|
|
181
193
|
export interface WebExtensionConversation {
|
|
182
194
|
/** None for a new conversation, which opens with its first message. */
|
|
183
195
|
send?(text: string): Promise<void>;
|
|
@@ -117,6 +117,9 @@ let TaWebExtensionsImpl = class TaWebExtensionsImpl {
|
|
|
117
117
|
refresh() {
|
|
118
118
|
const next = this.refreshing.then(() => this.reconcile(), () => this.reconcile());
|
|
119
119
|
this.refreshing = next;
|
|
120
|
+
if (!this.current.loaded) {
|
|
121
|
+
void next.finally(() => this.current.loaded || this.update({ loaded: true })).catch(() => undefined);
|
|
122
|
+
}
|
|
120
123
|
return next;
|
|
121
124
|
}
|
|
122
125
|
/**
|