@celljs/ta-web 4.22.0 → 4.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/esm/browser/assistant/assistant-conversation.js +1 -1
  2. package/esm/browser/assistant/assistant-initiative.d.ts +5 -1
  3. package/esm/browser/assistant/assistant-initiative.js +11 -3
  4. package/esm/browser/assistant/call-keeper.d.ts +2 -1
  5. package/esm/browser/assistant/call-keeper.js +4 -2
  6. package/esm/browser/assistant/call-screen.d.ts +1 -1
  7. package/esm/browser/assistant/call-turn-end.d.ts +11 -2
  8. package/esm/browser/assistant/call-turn-end.js +21 -5
  9. package/esm/browser/assistant/read-aloud.d.ts +1 -1
  10. package/esm/browser/assistant/realtime-voice.d.ts +1 -1
  11. package/esm/browser/assistant/voice-call-bar.d.ts +5 -2
  12. package/esm/browser/assistant/voice-call-bar.js +12 -0
  13. package/esm/browser/assistant/voice-call-protocol.d.ts +78 -0
  14. package/esm/browser/assistant/voice-call-protocol.js +2 -0
  15. package/esm/browser/assistant/voice-call.d.ts +17 -65
  16. package/esm/browser/assistant/voice-call.js +45 -1
  17. package/esm/browser/assistant/voice-reopen.d.ts +1 -1
  18. package/esm/browser/components/account-menu.js +28 -7
  19. package/esm/browser/components/chat-home.d.ts +3 -1
  20. package/esm/browser/components/chat-home.js +3 -2
  21. package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
  22. package/esm/browser/components/earlier-messages.d.ts +4 -0
  23. package/esm/browser/components/earlier-messages.js +10 -2
  24. package/esm/browser/components/host-view.d.ts +1 -1
  25. package/esm/browser/components/message-footer.d.ts +0 -2
  26. package/esm/browser/components/message-footer.js +1 -8
  27. package/esm/browser/components/message-images.d.ts +22 -0
  28. package/esm/browser/components/message-images.js +90 -1
  29. package/esm/browser/components/message-steps.js +9 -0
  30. package/esm/browser/components/message-user.js +8 -1
  31. package/esm/browser/components/partner-row-util.d.ts +28 -0
  32. package/esm/browser/components/partner-row-util.js +45 -0
  33. package/esm/browser/components/partner-row.d.ts +4 -3
  34. package/esm/browser/components/partner-row.js +21 -9
  35. package/esm/browser/components/profile-view.d.ts +2 -2
  36. package/esm/browser/components/profile-view.js +6 -3
  37. package/esm/browser/components/web-composer.d.ts +5 -2
  38. package/esm/browser/components/web-composer.js +10 -5
  39. package/esm/browser/extension/extension-view.js +2 -2
  40. package/esm/browser/extension/icons.js +4 -1
  41. package/esm/browser/extension/web-api-call.d.ts +45 -0
  42. package/esm/browser/extension/web-api-call.js +2 -0
  43. package/esm/browser/extension/web-api-components.d.ts +37 -2
  44. package/esm/browser/extension/web-api-contributions.d.ts +2 -31
  45. package/esm/browser/extension/web-api-partners.d.ts +18 -1
  46. package/esm/browser/extension/web-extension-api.d.ts +9 -12
  47. package/esm/browser/extension/web-extension-context.d.ts +2 -3
  48. package/esm/browser/extension/web-extension-context.js +5 -5
  49. package/esm/browser/i18n/locales.d.ts +9 -1
  50. package/esm/browser/i18n/messages-ja.js +8 -0
  51. package/esm/browser/i18n/messages-zh-tw.js +8 -0
  52. package/esm/browser/i18n/messages.d.ts +8 -0
  53. package/esm/browser/i18n/messages.js +16 -0
  54. package/esm/browser/partners/partners-extension.js +17 -0
  55. package/esm/browser/style/chat-list.d.ts +1 -1
  56. package/esm/browser/style/chat-list.js +3 -0
  57. package/esm/browser/style/conversation-column.d.ts +1 -1
  58. package/esm/browser/style/conversation-column.js +21 -0
  59. package/esm/browser/style/conversation.d.ts +1 -1
  60. package/esm/browser/style/conversation.js +2 -2
  61. package/esm/browser/style/shell.d.ts +1 -1
  62. package/esm/browser/style/shell.js +1 -1
  63. package/esm/browser/util/image-shrink.d.ts +26 -0
  64. package/esm/browser/util/image-shrink.js +60 -0
  65. package/esm/browser/util/process.d.ts +7 -3
  66. package/esm/browser/util/process.js +18 -18
  67. package/lib/browser/assistant/assistant-conversation.js +1 -1
  68. package/lib/browser/assistant/assistant-initiative.d.ts +5 -1
  69. package/lib/browser/assistant/assistant-initiative.js +11 -3
  70. package/lib/browser/assistant/call-keeper.d.ts +2 -1
  71. package/lib/browser/assistant/call-keeper.js +4 -2
  72. package/lib/browser/assistant/call-screen.d.ts +1 -1
  73. package/lib/browser/assistant/call-turn-end.d.ts +11 -2
  74. package/lib/browser/assistant/call-turn-end.js +22 -6
  75. package/lib/browser/assistant/read-aloud.d.ts +1 -1
  76. package/lib/browser/assistant/realtime-voice.d.ts +1 -1
  77. package/lib/browser/assistant/voice-call-bar.d.ts +5 -2
  78. package/lib/browser/assistant/voice-call-bar.js +12 -0
  79. package/lib/browser/assistant/voice-call-protocol.d.ts +79 -0
  80. package/lib/browser/assistant/voice-call-protocol.js +3 -0
  81. package/lib/browser/assistant/voice-call.d.ts +17 -65
  82. package/lib/browser/assistant/voice-call.js +45 -1
  83. package/lib/browser/assistant/voice-reopen.d.ts +1 -1
  84. package/lib/browser/components/account-menu.js +27 -6
  85. package/lib/browser/components/chat-home.d.ts +3 -1
  86. package/lib/browser/components/chat-home.js +3 -2
  87. package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
  88. package/lib/browser/components/earlier-messages.d.ts +4 -0
  89. package/lib/browser/components/earlier-messages.js +10 -2
  90. package/lib/browser/components/host-view.d.ts +1 -1
  91. package/lib/browser/components/message-footer.d.ts +0 -2
  92. package/lib/browser/components/message-footer.js +0 -8
  93. package/lib/browser/components/message-images.d.ts +22 -0
  94. package/lib/browser/components/message-images.js +92 -2
  95. package/lib/browser/components/message-steps.js +9 -0
  96. package/lib/browser/components/message-user.js +7 -0
  97. package/lib/browser/components/partner-row-util.d.ts +29 -0
  98. package/lib/browser/components/partner-row-util.js +48 -0
  99. package/lib/browser/components/partner-row.d.ts +4 -3
  100. package/lib/browser/components/partner-row.js +21 -9
  101. package/lib/browser/components/profile-view.d.ts +2 -2
  102. package/lib/browser/components/profile-view.js +6 -3
  103. package/lib/browser/components/web-composer.d.ts +5 -2
  104. package/lib/browser/components/web-composer.js +10 -5
  105. package/lib/browser/extension/extension-view.js +2 -2
  106. package/lib/browser/extension/icons.js +3 -0
  107. package/lib/browser/extension/web-api-call.d.ts +46 -0
  108. package/lib/browser/extension/web-api-call.js +3 -0
  109. package/lib/browser/extension/web-api-components.d.ts +37 -2
  110. package/lib/browser/extension/web-api-contributions.d.ts +2 -31
  111. package/lib/browser/extension/web-api-partners.d.ts +18 -1
  112. package/lib/browser/extension/web-extension-api.d.ts +9 -12
  113. package/lib/browser/extension/web-extension-context.d.ts +2 -3
  114. package/lib/browser/extension/web-extension-context.js +5 -5
  115. package/lib/browser/i18n/locales.d.ts +9 -1
  116. package/lib/browser/i18n/messages-ja.js +8 -0
  117. package/lib/browser/i18n/messages-zh-tw.js +8 -0
  118. package/lib/browser/i18n/messages.d.ts +8 -0
  119. package/lib/browser/i18n/messages.js +16 -0
  120. package/lib/browser/partners/partners-extension.js +17 -0
  121. package/lib/browser/style/chat-list.d.ts +1 -1
  122. package/lib/browser/style/chat-list.js +3 -0
  123. package/lib/browser/style/conversation-column.d.ts +1 -1
  124. package/lib/browser/style/conversation-column.js +21 -0
  125. package/lib/browser/style/conversation.d.ts +1 -1
  126. package/lib/browser/style/conversation.js +2 -2
  127. package/lib/browser/style/shell.d.ts +1 -1
  128. package/lib/browser/style/shell.js +1 -1
  129. package/lib/browser/util/image-shrink.d.ts +27 -0
  130. package/lib/browser/util/image-shrink.js +63 -0
  131. package/lib/browser/util/process.d.ts +7 -3
  132. package/lib/browser/util/process.js +18 -18
  133. package/package.json +7 -7
@@ -28,6 +28,11 @@ export declare namespace UserImageUtil {
28
28
  height: number;
29
29
  } | undefined): React.CSSProperties | undefined;
30
30
  }
31
+ /** From this many pictures at once, a message shows them stacked, as WeChat does, until the user unfolds them. */
32
+ export declare const STACK_FROM = 4;
33
+ export declare namespace ImageStackUtil {
34
+ function stacked(count: number, key: string | undefined): boolean;
35
+ }
31
36
  /**
32
37
  * The images of a message of the user: one keeps its own shape at the size of a bubble, a few stand as
33
38
  * squares of one size, and a click on any of them opens it full size over the page. Each has its place
@@ -38,5 +43,22 @@ export declare function UserImages({ blocks, timestamp }: {
38
43
  blocks: Blocks;
39
44
  timestamp?: number;
40
45
  }): React.JSX.Element | null;
46
+ /** A picture of a chat of an extension (`ui.ChatImages`): its bytes as a URL once they are here, a thumbnail meanwhile. */
47
+ export interface ChatImage {
48
+ key: string;
49
+ src?: string;
50
+ thumb?: string;
51
+ width: number;
52
+ height: number;
53
+ }
54
+ /**
55
+ * The pictures of a message of a chat an extension draws (a group chat, a channel), as those of the user in a
56
+ * conversation: one alone in its shape, more in squares, full size over the page on a click, those still on their way
57
+ * blurred from their thumbnail.
58
+ */
59
+ export declare function ChatImages({ images, alt }: {
60
+ images: readonly ChatImage[];
61
+ alt?: string;
62
+ }): React.JSX.Element | null;
41
63
  export {};
42
64
  //# sourceMappingURL=message-images.d.ts.map
@@ -33,8 +33,9 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.UserImageUtil = exports.MessageImages = void 0;
36
+ exports.ImageStackUtil = exports.STACK_FROM = exports.UserImageUtil = exports.MessageImages = void 0;
37
37
  exports.UserImages = UserImages;
38
+ exports.ChatImages = ChatImages;
38
39
  const ta_protocol_1 = require("@celljs/ta-protocol");
39
40
  const React = __importStar(require("react"));
40
41
  const use_t_1 = require("../i18n/use-t");
@@ -127,6 +128,38 @@ function useImageSources(images, timestamp) {
127
128
  });
128
129
  return images.map(({ index }, at) => { var _a; return (_a = own[at]) !== null && _a !== void 0 ? _a : loaded[index]; });
129
130
  }
131
+ /** From this many pictures at once, a message shows them stacked, as WeChat does, until the user unfolds them. */
132
+ exports.STACK_FROM = 4;
133
+ /** The messages whose pictures the user unfolded, by a key of each: they stay unfolded while the page lives. */
134
+ const unfolded = new Set();
135
+ var ImageStackUtil;
136
+ (function (ImageStackUtil) {
137
+ function stacked(count, key) {
138
+ return count >= exports.STACK_FROM && !(key !== undefined && unfolded.has(key));
139
+ }
140
+ ImageStackUtil.stacked = stacked;
141
+ })(ImageStackUtil || (exports.ImageStackUtil = ImageStackUtil = {}));
142
+ /**
143
+ * Pictures sent together, folded as WeChat folds them: the first in its own shape, two more peeking from behind it, and
144
+ * beside it a pill that unfolds them all (`展开 N`). A tap on the stack opens the first full size, the others beside it.
145
+ */
146
+ function ImageStack({ sources, first, count, onOpen, onUnfold, }) {
147
+ var _a;
148
+ const t = (0, use_t_1.useT)();
149
+ const box = (_a = UserImageUtil.box(first)) !== null && _a !== void 0 ? _a : { width: 160, aspectRatio: '4 / 3' };
150
+ const card = (at, className) => sources[at] ? React.createElement("img", { className: className, src: sources[at], alt: "", style: box }) : React.createElement("span", { className: `${className} ta-thumb-waiting`, style: box });
151
+ return (React.createElement("div", { className: "ta-image-stack" },
152
+ React.createElement("button", { type: "button", className: "ta-stack-unfold", onClick: onUnfold }, t('ta.images.expand', { count })),
153
+ React.createElement("button", { type: "button", className: "ta-stack-cards", title: t('ta.markdown.enlarge'), disabled: !sources[0], onClick: onOpen },
154
+ card(2, 'ta-stack-card ta-stack-right'),
155
+ card(1, 'ta-stack-card ta-stack-left'),
156
+ card(0, 'ta-stack-card ta-stack-front'))));
157
+ }
158
+ /** Folds pictures unfolded before, under the grid of them. */
159
+ function FoldButton({ onFold }) {
160
+ const t = (0, use_t_1.useT)();
161
+ return (React.createElement("button", { type: "button", className: "ta-stack-fold", onClick: onFold }, t('ta.images.collapse')));
162
+ }
130
163
  /**
131
164
  * The images of a message of the user: one keeps its own shape at the size of a bubble, a few stand as
132
165
  * squares of one size, and a click on any of them opens it full size over the page. Each has its place
@@ -139,11 +172,26 @@ function UserImages({ blocks, timestamp }) {
139
172
  const [menu, openMenu] = (0, image_menu_1.useImageMenu)();
140
173
  const images = UserImageUtil.images(blocks);
141
174
  const sources = useImageSources(images, timestamp);
175
+ const fold = timestamp === undefined ? undefined : `user:${timestamp}`;
176
+ const [, redraw] = React.useReducer((n) => n + 1, 0);
142
177
  if (images.length === 0) {
143
178
  return null;
144
179
  }
145
180
  const single = images.length === 1 ? UserImageUtil.box(UserImageUtil.size(images[0].block)) : undefined;
146
181
  const shown = open !== undefined ? sources[open] : undefined;
182
+ const lightbox = open !== undefined && shown && (React.createElement(lightbox_1.Lightbox, { src: shown, alt: "", count: { at: open, of: images.length }, onClose: () => setOpen(undefined), onPrevious: open > 0 && sources[open - 1] ? () => setOpen(open - 1) : undefined, onNext: open < images.length - 1 && sources[open + 1] ? () => setOpen(open + 1) : undefined, previousSrc: open > 0 ? sources[open - 1] : undefined, nextSrc: sources[open + 1] }));
183
+ if (ImageStackUtil.stacked(images.length, fold)) {
184
+ return (React.createElement(React.Fragment, null,
185
+ React.createElement(ImageStack, { sources: sources, first: UserImageUtil.size(images[0].block), count: images.length, onOpen: () => setOpen(0), onUnfold: () => {
186
+ unfolded.add(fold !== null && fold !== void 0 ? fold : '');
187
+ redraw();
188
+ } }),
189
+ lightbox));
190
+ }
191
+ const folding = images.length >= exports.STACK_FROM && fold ? (React.createElement(FoldButton, { onFold: () => {
192
+ unfolded.delete(fold);
193
+ redraw();
194
+ } })) : null;
147
195
  return (React.createElement("div", { className: "ta-user-images", "data-count": Math.min(images.length, 3), style: { '--ta-user-image-columns': gallery_1.GalleryUtil.columns(images.length) } },
148
196
  images.map(({ index }, at) => (React.createElement("button", { key: index, type: "button", className: "ta-user-image", title: t('ta.markdown.enlarge'), disabled: !sources[at], onClick: () => setOpen(at), onContextMenu: event => {
149
197
  const source = sources[at];
@@ -152,6 +200,48 @@ function UserImages({ blocks, timestamp }) {
152
200
  }
153
201
  } }, sources[at] ? (React.createElement("img", { className: "ta-thumb", src: sources[at], alt: "", style: single })) : (React.createElement("span", { className: "ta-thumb ta-thumb-waiting", style: single }))))),
154
202
  menu,
155
- open !== undefined && shown && (React.createElement(lightbox_1.Lightbox, { src: shown, alt: "", count: { at: open, of: images.length }, onClose: () => setOpen(undefined), onPrevious: open > 0 && sources[open - 1] ? () => setOpen(open - 1) : undefined, onNext: open < images.length - 1 && sources[open + 1] ? () => setOpen(open + 1) : undefined, previousSrc: open > 0 ? sources[open - 1] : undefined, nextSrc: sources[open + 1] }))));
203
+ lightbox,
204
+ folding));
205
+ }
206
+ /**
207
+ * The pictures of a message of a chat an extension draws (a group chat, a channel), as those of the user in a
208
+ * conversation: one alone in its shape, more in squares, full size over the page on a click, those still on their way
209
+ * blurred from their thumbnail.
210
+ */
211
+ function ChatImages({ images, alt = '' }) {
212
+ var _a, _b, _c, _d, _e;
213
+ const t = (0, use_t_1.useT)();
214
+ const [open, setOpen] = React.useState();
215
+ const [menu, openMenu] = (0, image_menu_1.useImageMenu)();
216
+ const [, redraw] = React.useReducer((n) => n + 1, 0);
217
+ if (images.length === 0) {
218
+ return null;
219
+ }
220
+ const fold = `chat:${images[0].key}`;
221
+ const single = images.length === 1 ? UserImageUtil.box({ width: images[0].width, height: images[0].height }) : undefined;
222
+ const shown = open !== undefined ? (_a = images[open]) === null || _a === void 0 ? void 0 : _a.src : undefined;
223
+ const lightbox = open !== undefined && shown && (React.createElement(lightbox_1.Lightbox, { src: shown, alt: alt, count: { at: open, of: images.length }, onClose: () => setOpen(undefined), onPrevious: open > 0 && ((_b = images[open - 1]) === null || _b === void 0 ? void 0 : _b.src) ? () => setOpen(open - 1) : undefined, onNext: open < images.length - 1 && ((_c = images[open + 1]) === null || _c === void 0 ? void 0 : _c.src) ? () => setOpen(open + 1) : undefined, previousSrc: open > 0 ? (_d = images[open - 1]) === null || _d === void 0 ? void 0 : _d.src : undefined, nextSrc: (_e = images[open + 1]) === null || _e === void 0 ? void 0 : _e.src }));
224
+ if (ImageStackUtil.stacked(images.length, fold)) {
225
+ return (React.createElement(React.Fragment, null,
226
+ React.createElement(ImageStack, { sources: images.map(image => { var _a; return (_a = image.src) !== null && _a !== void 0 ? _a : image.thumb; }), first: { width: images[0].width, height: images[0].height }, count: images.length, onOpen: () => setOpen(0), onUnfold: () => {
227
+ unfolded.add(fold);
228
+ redraw();
229
+ } }),
230
+ lightbox));
231
+ }
232
+ return (React.createElement("div", { className: "ta-user-images ta-chat-images", "data-count": Math.min(images.length, 3), style: { '--ta-user-image-columns': gallery_1.GalleryUtil.columns(images.length) } },
233
+ images.map((image, at) => (React.createElement("button", { key: image.key, type: "button", className: "ta-user-image", title: image.src ? t('ta.markdown.enlarge') : alt, disabled: !image.src, onClick: () => setOpen(at), onContextMenu: event => {
234
+ const source = image.src;
235
+ if (source) {
236
+ openMenu(event, { full: () => source, enlarge: () => setOpen(at) });
237
+ }
238
+ } }, image.src ? (React.createElement("img", { className: "ta-thumb", src: image.src, alt: alt, style: single })) : image.thumb ? (React.createElement("span", { className: "ta-thumb ta-thumb-blurred", style: single },
239
+ React.createElement("img", { src: image.thumb, alt: "" }))) : (React.createElement("span", { className: "ta-thumb ta-thumb-waiting", style: single }))))),
240
+ menu,
241
+ lightbox,
242
+ images.length >= exports.STACK_FROM && (React.createElement(FoldButton, { onFold: () => {
243
+ unfolded.delete(fold);
244
+ redraw();
245
+ } }))));
156
246
  }
157
247
  //# sourceMappingURL=message-images.js.map
@@ -84,6 +84,13 @@ const SaidStep = React.memo(function SaidStep({ message }) {
84
84
  React.createElement(message_user_1.MessageOrigin, { blocks: blocks })),
85
85
  React.createElement(message_user_1.UserSaid, { blocks: blocks, text: text, bubble: "ta-said-bubble", timestamp: message.timestamp })));
86
86
  });
87
+ /** Where Ta restarted in the middle of the work and went on with it: one quiet line on the string of the steps. */
88
+ function ResumedStep() {
89
+ const t = (0, use_t_1.useT)();
90
+ return (React.createElement("div", { className: "ta-step-resumed" },
91
+ React.createElement("span", { className: "ta-status ta-status-thought" }),
92
+ React.createElement("span", null, t('ta.message.resumed'))));
93
+ }
87
94
  const TextStep = React.memo(function TextStep({ text, streaming }) {
88
95
  return (React.createElement("div", { className: "ta-step-text" },
89
96
  React.createElement("span", { className: "ta-status ta-status-thought" }),
@@ -101,6 +108,8 @@ function Step({ step, results, tools, tagged, streaming, }) {
101
108
  return React.createElement(ErrorStep, { text: step.text });
102
109
  case 'said':
103
110
  return React.createElement(SaidStep, { message: step.message });
111
+ case 'resumed':
112
+ return React.createElement(ResumedStep, null);
104
113
  default:
105
114
  return React.createElement(tool_view_1.ActView, { act: step, results: results, runs: tools });
106
115
  }
@@ -93,6 +93,13 @@ function UserSaid({ blocks, text, bubble = 'ta-bubble', timestamp }) {
93
93
  return text ? (React.createElement("div", { className: bubble },
94
94
  React.createElement(said_text_1.SaidText, { text: text }))) : null;
95
95
  }
96
+ // Many pictures stand on their own (folded, ImageStack, or unfolded), the words in a bubble of their own under them.
97
+ if (message_images_1.UserImageUtil.images(blocks).length >= message_images_1.STACK_FROM) {
98
+ return (React.createElement(React.Fragment, null,
99
+ React.createElement(message_images_1.UserImages, { blocks: blocks, timestamp: timestamp }),
100
+ text && (React.createElement("div", { className: bubble },
101
+ React.createElement(said_text_1.SaidText, { text: text })))));
102
+ }
96
103
  return (React.createElement("div", { className: `${bubble} ta-bubble-media${text ? '' : ' ta-bubble-bare'}` },
97
104
  React.createElement(message_images_1.UserImages, { blocks: blocks, timestamp: timestamp }),
98
105
  text && React.createElement(said_text_1.SaidText, { text: text, className: "ta-bubble-text" })));
@@ -0,0 +1,29 @@
1
+ import type { WebSwipeAction } from '../extension/web-api-components';
2
+ import type { WebMenuItem } from '../extension/web-api-contributions';
3
+ import type { WebPartner, WebPartnerKind } from '../extension/web-api-partners';
4
+ import type { MessageId } from '../i18n/messages';
5
+ /** An action of a row, as its menu and its swipe take it. */
6
+ interface RowAction {
7
+ label: string;
8
+ /** Behind the row, where the label is too long. */
9
+ short?: string;
10
+ run(): void;
11
+ }
12
+ /**
13
+ * What a partner's row offers, the same for every kind (docs/design/ta-partners.md): its menu is Open, Pin (a
14
+ * conversation of the double's list), its info; then its own; then what takes it away, in red. A swipe shows the first
15
+ * of these and that last: Pin and Delete chat in the double's list, Info and Remove on the page of the partners.
16
+ */
17
+ export declare namespace PartnerRowUtil {
18
+ function infoLabel(kind: WebPartnerKind): MessageId;
19
+ function infoShort(kind: WebPartnerKind): MessageId;
20
+ /**
21
+ * What takes it away where it is listed: in the double's list its conversation (a chat of two closed; a group chat
22
+ * left, its conversation being all of it); among the partners, the partner. None for one not a partner yet.
23
+ */
24
+ function away(partner: Pick<WebPartner, 'kind' | 'status' | 'chat' | 'remove'>, asChat: boolean): WebMenuItem | undefined;
25
+ /** Behind the row: Pin or Info first, what takes it away at the edge, in red. */
26
+ function swipe(pin: RowAction | undefined, info: RowAction | undefined, away: WebMenuItem | undefined): WebSwipeAction[];
27
+ }
28
+ export {};
29
+ //# sourceMappingURL=partner-row-util.d.ts.map
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PartnerRowUtil = void 0;
4
+ /**
5
+ * What a partner's row offers, the same for every kind (docs/design/ta-partners.md): its menu is Open, Pin (a
6
+ * conversation of the double's list), its info; then its own; then what takes it away, in red. A swipe shows the first
7
+ * of these and that last: Pin and Delete chat in the double's list, Info and Remove on the page of the partners.
8
+ */
9
+ var PartnerRowUtil;
10
+ (function (PartnerRowUtil) {
11
+ const INFO = {
12
+ agent: 'ta.partners.infoAgent',
13
+ friend: 'ta.partners.infoFriend',
14
+ group: 'ta.partners.infoGroup',
15
+ };
16
+ function infoLabel(kind) {
17
+ return INFO[kind];
18
+ }
19
+ PartnerRowUtil.infoLabel = infoLabel;
20
+ function infoShort(kind) {
21
+ return kind === 'group' ? 'ta.partners.infoShortGroup' : 'ta.partners.infoShort';
22
+ }
23
+ PartnerRowUtil.infoShort = infoShort;
24
+ /**
25
+ * What takes it away where it is listed: in the double's list its conversation (a chat of two closed; a group chat
26
+ * left, its conversation being all of it); among the partners, the partner. None for one not a partner yet.
27
+ */
28
+ function away(partner, asChat) {
29
+ var _a;
30
+ var _b;
31
+ if (partner.status) {
32
+ return undefined;
33
+ }
34
+ if (asChat) {
35
+ return (_b = (_a = partner.chat) === null || _a === void 0 ? void 0 : _a.close) !== null && _b !== void 0 ? _b : (partner.kind === 'group' ? partner.remove : undefined);
36
+ }
37
+ return partner.remove;
38
+ }
39
+ PartnerRowUtil.away = away;
40
+ /** Behind the row: Pin or Info first, what takes it away at the edge, in red. */
41
+ function swipe(pin, info, away) {
42
+ var _a;
43
+ const first = pin ? { key: 'pin', label: pin.label, run: pin.run } : info ? { key: 'info', label: (_a = info.short) !== null && _a !== void 0 ? _a : info.label, run: info.run } : undefined;
44
+ return [...(first ? [first] : []), ...(away ? [{ key: `away-${away.key}`, label: away.label, danger: true, run: away.run }] : [])];
45
+ }
46
+ PartnerRowUtil.swipe = swipe;
47
+ })(PartnerRowUtil || (exports.PartnerRowUtil = PartnerRowUtil = {}));
48
+ //# sourceMappingURL=partner-row-util.js.map
@@ -2,9 +2,10 @@ import * as React from 'react';
2
2
  import type { WebPartnerEntry } from '../extension/web-api-partners';
3
3
  /**
4
4
  * A partner (docs/design/ta-partners.md), the same row wherever it is: on the page of the partners as a contact, in the
5
- * double's list as a conversation. Its face (or its icon on a tile of its tint), its name, what was said last (else
6
- * what it is), when; an amber dot for what the user has not seen or one asking, a blue ? while it waits for them, a
7
- * spinner while it answers. Its menu is Open, then its own; pinned as a conversation is where `onPin` is given.
5
+ * double's list as a conversation (`onPin` given). Its face (or its icon on a tile of its tint), its name, what was said
6
+ * last (else what it is), when; an amber dot for what the user has not seen or one asking, a blue ? while it waits for
7
+ * them, a spinner while it answers. Its menu (a right click, a long press) and what a swipe shows behind it are the
8
+ * same for every kind (PartnerRowUtil).
8
9
  */
9
10
  export declare function PartnerRow({ partner, time, selected, open, pinned, onPin, }: {
10
11
  partner: WebPartnerEntry;
@@ -42,12 +42,14 @@ const chat_home_util_1 = require("./chat-home-util");
42
42
  const chat_list_row_1 = require("./chat-list-row");
43
43
  const context_menu_1 = require("./context-menu");
44
44
  const host_tag_1 = require("./host-tag");
45
+ const partner_row_util_1 = require("./partner-row-util");
45
46
  const swipe_row_1 = require("./swipe-row");
46
47
  /**
47
48
  * A partner (docs/design/ta-partners.md), the same row wherever it is: on the page of the partners as a contact, in the
48
- * double's list as a conversation. Its face (or its icon on a tile of its tint), its name, what was said last (else
49
- * what it is), when; an amber dot for what the user has not seen or one asking, a blue ? while it waits for them, a
50
- * spinner while it answers. Its menu is Open, then its own; pinned as a conversation is where `onPin` is given.
49
+ * double's list as a conversation (`onPin` given). Its face (or its icon on a tile of its tint), its name, what was said
50
+ * last (else what it is), when; an amber dot for what the user has not seen or one asking, a blue ? while it waits for
51
+ * them, a spinner while it answers. Its menu (a right click, a long press) and what a swipe shows behind it are the
52
+ * same for every kind (PartnerRowUtil).
51
53
  */
52
54
  function PartnerRow({ partner, time, selected, open, pinned, onPin, }) {
53
55
  var _a, _b;
@@ -65,12 +67,22 @@ function PartnerRow({ partner, time, selected, open, pinned, onPin, }) {
65
67
  .finally(() => setOpening(false));
66
68
  };
67
69
  const pin = onPin && { label: t(pinned ? 'ta.chat.unpin' : 'ta.chat.pin'), run: () => onPin(!pinned) };
68
- const own = () => (partner.menu ? chat_home_util_1.ChatHomeUtil.menu(partner.menu()) : []);
69
- return (React.createElement(swipe_row_1.SwipeRow, { as: "li", className: `ta-chat-row ta-partner-row${selected ? ' ta-selected' : ''}`, "data-unseen": unseen && !asks ? '' : undefined, "data-asks": asks ? '' : undefined, actions: pin ? [{ key: 'pin', ...pin }] : undefined, overlay: menu, onContextMenu: event => {
70
- const items = own();
70
+ // Opened as the row opens what it is (TaWebExtensions.openHome): a page it shows is the row's, as its conversation is.
71
+ const info = partner.info && {
72
+ label: t(partner_row_util_1.PartnerRowUtil.infoLabel(partner.kind)),
73
+ short: t(partner_row_util_1.PartnerRowUtil.infoShort(partner.kind)),
74
+ run: () => void open({ ...partner, open: () => { var _a; return (_a = partner.info) === null || _a === void 0 ? void 0 : _a.call(partner); } }).catch(error => console.error(`The info of a partner of ${partner.extension} failed to open:`, error)),
75
+ };
76
+ const away = partner_row_util_1.PartnerRowUtil.away(partner, !!onPin);
77
+ const swipe = partner_row_util_1.PartnerRowUtil.swipe(pin, info, away);
78
+ return (React.createElement(swipe_row_1.SwipeRow, { as: "li", className: `ta-chat-row ta-partner-row${selected ? ' ta-selected' : ''}`, "data-unseen": unseen && !asks ? '' : undefined, "data-asks": asks ? '' : undefined, actions: swipe.length ? swipe : undefined, overlay: menu, onContextMenu: event => {
79
+ const own = partner.menu ? chat_home_util_1.ChatHomeUtil.menu(partner.menu()) : [];
80
+ const first = [{ label: t('ta.chat.open'), run: go }, ...(pin ? [pin] : []), ...(info ? [{ label: info.label, run: info.run }] : [])];
81
+ const last = away ? [{ label: away.label, run: away.run, danger: true }] : [];
71
82
  openMenu(event, [
72
- ...context_menu_1.ContextMenuUtil.sections([{ label: t('ta.chat.open'), run: go }], pin ? [pin] : []),
73
- ...(items.length ? ['-', ...items] : []),
83
+ ...context_menu_1.ContextMenuUtil.sections(first),
84
+ ...(own.length ? ['-', ...own] : []),
85
+ ...(last.length ? ['-', ...last] : []),
74
86
  ]);
75
87
  } },
76
88
  React.createElement("button", { type: "button", className: "ta-chat-item", title: partner.name, "aria-current": selected ? 'true' : undefined, onClick: go },
@@ -79,6 +91,6 @@ function PartnerRow({ partner, time, selected, open, pinned, onPin, }) {
79
91
  React.createElement(Own, { size: 38 }))) : (React.createElement("span", { className: "ta-chat-avatar ta-chat-icon", style: { background: `var(--ta-tint-${partner.tone})`, color: `var(--ta-tint-ink-${partner.tone})`, width: 38, height: 38 }, "aria-hidden": "true" }, opening ? React.createElement("span", { className: "ta-spinner" }) : React.createElement(Glyph, { size: 18, strokeWidth: 1.8 }))),
80
92
  partner.online && React.createElement("span", { className: "ta-partner-online", "aria-hidden": "true" }),
81
93
  React.createElement(chat_list_row_1.ChatDot, { unseen: unseen, asks: asks })),
82
- React.createElement(chat_home_1.RowText, { title: partner.name, time: time, line: partners_util_1.PartnersUtil.line(partner, t('ta.partners.waiting')), unseen: unseen, busy: !partner.status && !!((_b = partner.chat) === null || _b === void 0 ? void 0 : _b.busy), tag: partner.location ? React.createElement(host_tag_1.HostTag, { location: partner.location }) : undefined }))));
94
+ React.createElement(chat_home_1.RowText, { title: partner.name, time: time, line: partners_util_1.PartnersUtil.line(partner, t('ta.partners.waiting')), unseen: unseen, busy: !partner.status && !!((_b = partner.chat) === null || _b === void 0 ? void 0 : _b.busy), tag: partner.location ? React.createElement(host_tag_1.HostTag, { location: partner.location }) : undefined, badge: partner.friends ? t('ta.partners.withFriends') : undefined }))));
83
95
  }
84
96
  //# sourceMappingURL=partner-row.js.map
@@ -2,8 +2,8 @@ import type { TaIdentity } from '@celljs/ta-protocol';
2
2
  import * as React from 'react';
3
3
  /** The identity of the computer in use, its name and picture: read once connected, and again when it changes. */
4
4
  export declare function useIdentity(): TaIdentity | undefined;
5
- /** The account in use as a line: "Company account · su", or none while signed out. */
6
- export declare function useAccountLine(): string | undefined;
5
+ /** The account in use as a line: "Company account · su"; null while signed out, undefined until read. */
6
+ export declare function useAccountLine(): string | null | undefined;
7
7
  /** The profile, over the page: the picture, the name, and the account, which opens My devices. */
8
8
  export declare function ProfileDialog({ onClose, onDevices }: {
9
9
  onClose(): void;
@@ -76,12 +76,15 @@ function useIdentity() {
76
76
  }, [online, workbench]);
77
77
  return identity;
78
78
  }
79
- /** The account in use as a line: "Company account · su", or none while signed out. */
79
+ /** The account in use as a line: "Company account · su"; null while signed out, undefined until read. */
80
80
  function useAccountLine() {
81
81
  const side = (0, account_side_1.useAccountSide)();
82
- const { info } = (0, account_side_1.useAccountInfo)(side, 15000);
82
+ const { info, failed } = (0, account_side_1.useAccountInfo)(side, 15000);
83
83
  const way = (0, account_view_1.useAccountWay)();
84
- return (info === null || info === void 0 ? void 0 : info.account) && !info.waiting ? `${way(info.account.id)} · ${(0, account_view_1.accountName)(info.account)}` : undefined;
84
+ if ((info === null || info === void 0 ? void 0 : info.account) && !info.waiting) {
85
+ return `${way(info.account.id)} · ${(0, account_view_1.accountName)(info.account)}`;
86
+ }
87
+ return info || failed ? null : undefined;
85
88
  }
86
89
  /** The profile, over the page: the picture, the name, and the account, which opens My devices. */
87
90
  function ProfileDialog({ onClose, onDevices }) {
@@ -15,6 +15,9 @@ export interface WebComposerHostProps extends WebComposerProps {
15
15
  /** The hosts of ssh, which the button offers too. */
16
16
  remote?: FolderPickerRemote;
17
17
  }
18
- /** The message box as web extensions get it (`pi.ui.Composer`): text only, `@` for the names they give; a failure is a notice of the page. */
19
- export declare function WebComposer({ notices, placeholder, onSend, mentions, mentionLabel, actions, cwd, onPickCwd, commands, working, onStop, voiceSends, onTalkSent, onListening, after, draft, server, listDirectory, serverCwd, remote, }: WebComposerHostProps): React.JSX.Element;
18
+ /**
19
+ * The message box as web extensions get it (`pi.ui.Composer`): text, and pictures when it takes them (shrunk within
20
+ * the limits given), `@` for the names they give; a failure is a notice of the page.
21
+ */
22
+ export declare function WebComposer({ notices, placeholder, onSend, images, mentions, mentionLabel, actions, cwd, onPickCwd, commands, working, onStop, voiceSends, onTalkSent, onListening, after, draft, server, listDirectory, serverCwd, remote, }: WebComposerHostProps): React.JSX.Element;
20
23
  //# sourceMappingURL=web-composer.d.ts.map
@@ -37,20 +37,25 @@ exports.WebComposer = WebComposer;
37
37
  const React = __importStar(require("react"));
38
38
  const use_t_1 = require("../i18n/use-t");
39
39
  const composer_1 = require("../util/composer");
40
+ const image_shrink_1 = require("../util/image-shrink");
40
41
  const composer_addon_util_1 = require("./composer-addon-util");
41
42
  const composer_box_1 = require("./composer-box");
42
43
  const directory_commands_1 = require("./directory-commands");
43
44
  const folder_picker_1 = require("./folder-picker");
44
- /** The message box as web extensions get it (`pi.ui.Composer`): text only, `@` for the names they give; a failure is a notice of the page. */
45
- function WebComposer({ notices, placeholder, onSend, mentions, mentionLabel, actions, cwd, onPickCwd, commands, working, onStop, voiceSends, onTalkSent, onListening, after, draft, server, listDirectory, serverCwd, remote, }) {
45
+ /**
46
+ * The message box as web extensions get it (`pi.ui.Composer`): text, and pictures when it takes them (shrunk within
47
+ * the limits given), `@` for the names they give; a failure is a notice of the page.
48
+ */
49
+ function WebComposer({ notices, placeholder, onSend, images, mentions, mentionLabel, actions, cwd, onPickCwd, commands, working, onStop, voiceSends, onTalkSent, onListening, after, draft, server, listDirectory, serverCwd, remote, }) {
46
50
  const t = (0, use_t_1.useT)();
47
51
  const language = (0, use_t_1.useLanguage)();
48
52
  const [query, setQuery] = React.useState();
49
53
  const found = (0, directory_commands_1.useDirectoryCommands)(server, commands ? cwd || serverCwd : undefined);
50
54
  const listed = React.useMemo(() => found.map(command => ({ name: command.name, description: composer_1.ComposerUtil.commandDescription(command, language, t) })), [found, language, t]);
51
- return (React.createElement(composer_box_1.ComposerBox, { placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : t('ta.composer.label'), onSend: async (text) => {
52
- await onSend(text);
53
- }, commands: listed, onMentionQuery: mentions ? setQuery : undefined, mentions: mentions && query !== undefined
55
+ return (React.createElement(composer_box_1.ComposerBox, { placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : t('ta.composer.label'), onSend: async (text, attached) => {
56
+ const limits = typeof images === 'object' ? images : undefined;
57
+ await onSend(text, limits ? await Promise.all(attached.map(image => image_shrink_1.ImageShrink.shrink(image, limits))) : attached);
58
+ }, images: !!images, commands: listed, onMentionQuery: mentions ? setQuery : undefined, mentions: mentions && query !== undefined
54
59
  ? {
55
60
  items: composer_1.ComposerUtil.commands(mentions, query).map(mention => ({
56
61
  key: mention.name,
@@ -39,7 +39,6 @@ const ta_protocol_1 = require("@celljs/ta-protocol");
39
39
  const React = __importStar(require("react"));
40
40
  const callout_1 = require("../components/callout");
41
41
  const markdown_1 = require("../components/markdown");
42
- const message_footer_1 = require("../components/message-footer");
43
42
  const use_t_1 = require("../i18n/use-t");
44
43
  const message_1 = require("../util/message");
45
44
  /** The renderers of custom messages that web extensions registered. */
@@ -87,8 +86,9 @@ function ExtensionError({ name, error }) {
87
86
  /** A custom message of pi: with the renderer of its type, or as text when it is to be shown. */
88
87
  function CustomMessage({ message }) {
89
88
  const Renderer = React.useContext(exports.MessageRenderers)[message.customType];
89
+ // A step of the turn it went on with (ProcessUtil.items), not a message of its own.
90
90
  if (message.customType === ta_protocol_1.TA_RESUME_MESSAGE) {
91
- return React.createElement(message_footer_1.ResumeBreak, null);
91
+ return null;
92
92
  }
93
93
  if (Renderer) {
94
94
  return (React.createElement(ExtensionBoundary, { name: message.customType, resetKey: Renderer },
@@ -95,6 +95,7 @@ exports.WEB_ICONS = Object.freeze({
95
95
  Lock: lucide_react_1.Lock,
96
96
  Map: lucide_react_1.MapIcon,
97
97
  Maximize: lucide_react_1.Maximize,
98
+ Maximize2: lucide_react_1.Maximize2,
98
99
  Megaphone: lucide_react_1.Megaphone,
99
100
  MemoryStick: lucide_react_1.MemoryStick,
100
101
  MessageCircle: lucide_react_1.MessageCircle,
@@ -102,6 +103,7 @@ exports.WEB_ICONS = Object.freeze({
102
103
  MessageSquareText: lucide_react_1.MessageSquareText,
103
104
  MessagesSquare: lucide_react_1.MessagesSquare,
104
105
  Mic: lucide_react_1.Mic,
106
+ Minimize2: lucide_react_1.Minimize2,
105
107
  Minus: lucide_react_1.Minus,
106
108
  Monitor: lucide_react_1.Monitor,
107
109
  MonitorSmartphone: lucide_react_1.MonitorSmartphone,
@@ -129,6 +131,7 @@ exports.WEB_ICONS = Object.freeze({
129
131
  RotateCcw: lucide_react_1.RotateCcw,
130
132
  Rows2: lucide_react_1.Rows2,
131
133
  Save: lucide_react_1.Save,
134
+ Scan: lucide_react_1.Scan,
132
135
  ScanLine: lucide_react_1.ScanLine,
133
136
  ScrollText: lucide_react_1.ScrollText,
134
137
  Search: lucide_react_1.Search,
@@ -0,0 +1,46 @@
1
+ /** The conversation a call is with (WebCallPartner.open). */
2
+ export interface WebCallTarget {
3
+ sessionId: string;
4
+ sessionFile?: string;
5
+ cwd?: string;
6
+ /** The conversation of the double, which hands out tasks of its own. */
7
+ double: boolean;
8
+ /** The language the user speaks in the call. */
9
+ language: string;
10
+ }
11
+ /**
12
+ * Who answers in a call in place of the conversation (WebExtensionAPI.registerCallPartner): a front that talks at
13
+ * once, whatever the conversation does, and hands it the work (docs/design/ta-call.md).
14
+ */
15
+ export interface WebCallPartner {
16
+ /** Its side of a call with the conversation; undefined to leave the call to the conversation itself. */
17
+ open(target: WebCallTarget): Promise<WebCallSession | undefined>;
18
+ }
19
+ /** A call as its partner answers it, from when it starts until it ends. */
20
+ export interface WebCallSession {
21
+ /** What the user said; the reply to say. `sent`: it went to the conversation already, as it began the call. */
22
+ say(text: string, options?: {
23
+ sent?: boolean;
24
+ }): Promise<string | undefined>;
25
+ /**
26
+ * What the user said so far, as they paused where they may be done: the partner answers it at once, to be said only
27
+ * if they were done (`keep`), dropped as they say more (`drop`), doing nothing until kept (docs/design/ta-call.md
28
+ * 10). Newer than some partners.
29
+ */
30
+ draft?(text: string): WebCallDraft;
31
+ /** Whether the partner ended the call (asked to hang up): it ends once its last reply is said. */
32
+ ending?(): boolean;
33
+ /** What the partner says by itself (news of the work), asked again and again in a call; undefined after a while. */
34
+ next?(): Promise<string | undefined>;
35
+ close(): void;
36
+ }
37
+ /** An answer begun before the user was known to be done (WebCallSession.draft). */
38
+ export interface WebCallDraft {
39
+ /** The reply to say, as `say` gives it; undefined once dropped. */
40
+ reply: Promise<string | undefined>;
41
+ /** The user was done with these words: its reply is said, and what it does is done. */
42
+ keep(): void;
43
+ /** The user said more: it stops and does nothing. */
44
+ drop(): void;
45
+ }
46
+ //# sourceMappingURL=web-api-call.d.ts.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=web-api-call.js.map
@@ -197,6 +197,18 @@ export interface WebPictureCard {
197
197
  disabled?: boolean;
198
198
  onPick(): void;
199
199
  }
200
+ /** WebExtensionUI.ChatImages: the pictures of one message. */
201
+ export interface WebChatImagesProps {
202
+ images: readonly {
203
+ key: string;
204
+ src?: string;
205
+ thumb?: string;
206
+ width: number;
207
+ height: number;
208
+ }[];
209
+ /** What they are, for who cannot see them. */
210
+ alt?: string;
211
+ }
200
212
  export interface WebImageViewerProps {
201
213
  src: string;
202
214
  alt?: string;
@@ -298,8 +310,17 @@ export interface WebVoice {
298
310
  }
299
311
  export interface WebComposerProps {
300
312
  placeholder?: string;
301
- /** Sends what was typed; when it fails, the text comes back into the box and the reason is a notice of the page. */
302
- onSend(text: string): Promise<void> | void;
313
+ /**
314
+ * Sends what was typed, and the pictures added when the box takes them (`images`), the text empty for pictures
315
+ * alone; when it fails, both come back into the box and the reason is a notice of the page.
316
+ */
317
+ onSend(text: string, images: WebComposerImage[]): Promise<void> | void;
318
+ /**
319
+ * Pictures can be added, as in a conversation: the album and the camera in the + (a picture on a computer), pasted,
320
+ * dropped. With limits, each comes shrunk within them (a JPEG, unless it fits as it is), its size in pixels said.
321
+ * Newer than some Ta apps, which take none.
322
+ */
323
+ images?: boolean | WebComposerImageLimits;
303
324
  /** What `@` lists, by name; and the + menu entry that starts an `@`. */
304
325
  mentions?: {
305
326
  name: string;
@@ -335,6 +356,20 @@ export interface WebComposerProps {
335
356
  */
336
357
  draft?: string;
337
358
  }
359
+ /** A picture sent from the message box (WebComposerProps.images): JPEG, PNG, GIF or WebP, in base64. */
360
+ export interface WebComposerImage {
361
+ type: 'image';
362
+ data: string;
363
+ mimeType: string;
364
+ /** In pixels, when the box shrank it (`images` with limits). */
365
+ width?: number;
366
+ height?: number;
367
+ }
368
+ /** How the message box shrinks the pictures it hands on: their longest side in pixels, their bytes at most. */
369
+ export interface WebComposerImageLimits {
370
+ side: number;
371
+ bytes: number;
372
+ }
338
373
  /** An entry of the + menu of the message box. */
339
374
  export interface WebComposerAction {
340
375
  key: string;