@celljs/ta-web 4.47.1 → 4.48.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 (247) hide show
  1. package/esm/browser/assistant/assistant-role.d.ts +1 -1
  2. package/esm/browser/assistant/assistant-role.js +1 -1
  3. package/esm/browser/assistant/assistant-task-source.js +6 -1
  4. package/esm/browser/assistant/assistant-task-util.d.ts +1 -0
  5. package/esm/browser/assistant/assistant-task-util.js +9 -3
  6. package/esm/browser/assistant/assistant-view.js +4 -2
  7. package/esm/browser/cloud/cloud-sign-in.d.ts +26 -4
  8. package/esm/browser/cloud/cloud-sign-in.js +88 -18
  9. package/esm/browser/components/app-nav.d.ts +3 -1
  10. package/esm/browser/components/app-nav.js +3 -3
  11. package/esm/browser/components/app-view.js +16 -6
  12. package/esm/browser/components/asks-badge.d.ts +12 -0
  13. package/esm/browser/components/asks-badge.js +17 -1
  14. package/esm/browser/components/chat-list-row.d.ts +4 -1
  15. package/esm/browser/components/chat-list-row.js +7 -1
  16. package/esm/browser/components/chats-dot.d.ts +4 -1
  17. package/esm/browser/components/chats-dot.js +6 -2
  18. package/esm/browser/components/cloud-sign-in-view.d.ts +2 -1
  19. package/esm/browser/components/cloud-sign-in-view.js +28 -5
  20. package/esm/browser/components/composer-box-protocol.d.ts +5 -3
  21. package/esm/browser/components/composer-box.js +11 -11
  22. package/esm/browser/components/composer.d.ts +8 -1
  23. package/esm/browser/components/composer.js +57 -34
  24. package/esm/browser/components/host-view.d.ts +1 -1
  25. package/esm/browser/components/lightbox.d.ts +15 -1
  26. package/esm/browser/components/lightbox.js +14 -2
  27. package/esm/browser/components/link.js +8 -3
  28. package/esm/browser/components/markdown.d.ts +4 -2
  29. package/esm/browser/components/markdown.js +13 -4
  30. package/esm/browser/components/media.d.ts +6 -0
  31. package/esm/browser/components/media.js +9 -1
  32. package/esm/browser/components/message-images.d.ts +5 -0
  33. package/esm/browser/components/message-images.js +40 -4
  34. package/esm/browser/components/message-user.js +4 -2
  35. package/esm/browser/components/partner-row.js +4 -4
  36. package/esm/browser/components/phone-shell.d.ts +2 -0
  37. package/esm/browser/components/phone-shell.js +2 -2
  38. package/esm/browser/components/sending.d.ts +19 -0
  39. package/esm/browser/components/sending.js +27 -0
  40. package/esm/browser/components/session-view.js +4 -3
  41. package/esm/browser/components/settings-choices.js +1 -0
  42. package/esm/browser/components/settings-parts.js +28 -17
  43. package/esm/browser/components/share-dialog.js +3 -2
  44. package/esm/browser/components/share-item-sheet.js +1 -1
  45. package/esm/browser/components/share-sheet.d.ts +4 -2
  46. package/esm/browser/components/share-sheet.js +16 -2
  47. package/esm/browser/components/sign-in-accounts.js +7 -1
  48. package/esm/browser/components/unseen-drop.d.ts +2 -2
  49. package/esm/browser/components/unseen-drop.js +1 -1
  50. package/esm/browser/device/app-badge.d.ts +8 -0
  51. package/esm/browser/device/app-badge.js +28 -0
  52. package/esm/browser/device/code-scan.js +1 -1
  53. package/esm/browser/extension/web-api-code.d.ts +26 -0
  54. package/esm/browser/extension/web-api-components.d.ts +31 -0
  55. package/esm/browser/extension/web-api-menus.d.ts +15 -0
  56. package/esm/browser/extension/web-api-messages.d.ts +15 -0
  57. package/esm/browser/extension/web-api-messages.js +2 -0
  58. package/esm/browser/extension/web-api-partners.d.ts +16 -0
  59. package/esm/browser/extension/web-api-spec.js +1 -0
  60. package/esm/browser/extension/web-extension-api.d.ts +7 -13
  61. package/esm/browser/extension/web-extension-context.js +2 -0
  62. package/esm/browser/extension/web-session-notices.js +11 -2
  63. package/esm/browser/extension/web-share-ui.js +1 -0
  64. package/esm/browser/extension/web-share.js +3 -3
  65. package/esm/browser/extension/web-sharing.js +1 -1
  66. package/esm/browser/i18n/en/assistant.d.ts +2 -0
  67. package/esm/browser/i18n/en/assistant.js +2 -0
  68. package/esm/browser/i18n/en/chat.d.ts +11 -0
  69. package/esm/browser/i18n/en/chat.js +13 -2
  70. package/esm/browser/i18n/en/common.d.ts +4 -0
  71. package/esm/browser/i18n/en/common.js +4 -0
  72. package/esm/browser/i18n/en/service.d.ts +5 -0
  73. package/esm/browser/i18n/en/service.js +5 -0
  74. package/esm/browser/i18n/en/settings.d.ts +6 -0
  75. package/esm/browser/i18n/en/settings.js +8 -2
  76. package/esm/browser/i18n/ja/assistant.js +2 -0
  77. package/esm/browser/i18n/ja/chat.js +13 -2
  78. package/esm/browser/i18n/ja/common.js +4 -0
  79. package/esm/browser/i18n/ja/service.js +5 -0
  80. package/esm/browser/i18n/ja/settings.js +10 -4
  81. package/esm/browser/i18n/locales.d.ts +29 -1
  82. package/esm/browser/i18n/messages.d.ts +28 -0
  83. package/esm/browser/i18n/zh/assistant.js +2 -0
  84. package/esm/browser/i18n/zh/chat.js +13 -2
  85. package/esm/browser/i18n/zh/common.js +4 -0
  86. package/esm/browser/i18n/zh/service.js +5 -0
  87. package/esm/browser/i18n/zh/settings.js +8 -2
  88. package/esm/browser/i18n/zh-tw/assistant.js +2 -0
  89. package/esm/browser/i18n/zh-tw/chat.js +13 -2
  90. package/esm/browser/i18n/zh-tw/common.js +4 -0
  91. package/esm/browser/i18n/zh-tw/service.js +5 -0
  92. package/esm/browser/i18n/zh-tw/settings.js +8 -2
  93. package/esm/browser/links/links.js +1 -1
  94. package/esm/browser/notices/session-notices.d.ts +4 -4
  95. package/esm/browser/notices/session-notices.js +3 -6
  96. package/esm/browser/partners/partners-util.d.ts +6 -0
  97. package/esm/browser/partners/partners-util.js +22 -0
  98. package/esm/browser/sandbox/sandbox-runtime-code.js +1 -1
  99. package/esm/browser/settings/agent-settings.d.ts +2 -0
  100. package/esm/browser/settings/agent-settings.js +2 -0
  101. package/esm/browser/settings/settings-protocol.d.ts +8 -0
  102. package/esm/browser/settings/settings-protocol.js +5 -0
  103. package/esm/browser/style/base.d.ts +1 -1
  104. package/esm/browser/style/base.js +3 -0
  105. package/esm/browser/style/chat-list.d.ts +1 -1
  106. package/esm/browser/style/chat-list.js +8 -3
  107. package/esm/browser/style/conversation-column.d.ts +1 -1
  108. package/esm/browser/style/conversation-column.js +6 -1
  109. package/esm/browser/style/conversation.d.ts +1 -1
  110. package/esm/browser/style/conversation.js +18 -0
  111. package/esm/browser/style/phone.d.ts +1 -1
  112. package/esm/browser/style/phone.js +2 -0
  113. package/esm/browser/util/composer.d.ts +18 -3
  114. package/esm/browser/util/composer.js +31 -5
  115. package/esm/browser/util/desktop.d.ts +8 -1
  116. package/esm/browser/util/desktop.js +10 -0
  117. package/esm/browser/util/image-shrink.d.ts +5 -1
  118. package/esm/browser/util/image-shrink.js +1 -1
  119. package/esm/browser/util/markdown.d.ts +3 -5
  120. package/esm/browser/util/markdown.js +5 -29
  121. package/esm/browser/util/process.js +2 -2
  122. package/lib/browser/assistant/assistant-role.d.ts +1 -1
  123. package/lib/browser/assistant/assistant-role.js +1 -1
  124. package/lib/browser/assistant/assistant-task-source.js +5 -0
  125. package/lib/browser/assistant/assistant-task-util.d.ts +1 -0
  126. package/lib/browser/assistant/assistant-task-util.js +8 -2
  127. package/lib/browser/assistant/assistant-view.js +4 -2
  128. package/lib/browser/cloud/cloud-sign-in.d.ts +26 -4
  129. package/lib/browser/cloud/cloud-sign-in.js +89 -19
  130. package/lib/browser/components/app-nav.d.ts +3 -1
  131. package/lib/browser/components/app-nav.js +2 -2
  132. package/lib/browser/components/app-view.js +16 -6
  133. package/lib/browser/components/asks-badge.d.ts +12 -0
  134. package/lib/browser/components/asks-badge.js +19 -1
  135. package/lib/browser/components/chat-list-row.d.ts +4 -1
  136. package/lib/browser/components/chat-list-row.js +7 -1
  137. package/lib/browser/components/chats-dot.d.ts +4 -1
  138. package/lib/browser/components/chats-dot.js +6 -2
  139. package/lib/browser/components/cloud-sign-in-view.d.ts +2 -1
  140. package/lib/browser/components/cloud-sign-in-view.js +28 -5
  141. package/lib/browser/components/composer-box-protocol.d.ts +5 -3
  142. package/lib/browser/components/composer-box.js +11 -11
  143. package/lib/browser/components/composer.d.ts +8 -1
  144. package/lib/browser/components/composer.js +56 -33
  145. package/lib/browser/components/host-view.d.ts +1 -1
  146. package/lib/browser/components/lightbox.d.ts +15 -1
  147. package/lib/browser/components/lightbox.js +15 -2
  148. package/lib/browser/components/link.js +8 -3
  149. package/lib/browser/components/markdown.d.ts +4 -2
  150. package/lib/browser/components/markdown.js +11 -2
  151. package/lib/browser/components/media.d.ts +6 -0
  152. package/lib/browser/components/media.js +10 -2
  153. package/lib/browser/components/message-images.d.ts +5 -0
  154. package/lib/browser/components/message-images.js +40 -4
  155. package/lib/browser/components/message-user.js +4 -2
  156. package/lib/browser/components/partner-row.js +4 -4
  157. package/lib/browser/components/phone-shell.d.ts +2 -0
  158. package/lib/browser/components/phone-shell.js +1 -1
  159. package/lib/browser/components/sending.d.ts +20 -0
  160. package/lib/browser/components/sending.js +63 -0
  161. package/lib/browser/components/session-view.js +4 -3
  162. package/lib/browser/components/settings-choices.js +1 -0
  163. package/lib/browser/components/settings-parts.js +26 -15
  164. package/lib/browser/components/share-dialog.js +3 -2
  165. package/lib/browser/components/share-item-sheet.js +1 -1
  166. package/lib/browser/components/share-sheet.d.ts +4 -2
  167. package/lib/browser/components/share-sheet.js +16 -2
  168. package/lib/browser/components/sign-in-accounts.js +7 -1
  169. package/lib/browser/components/unseen-drop.d.ts +2 -2
  170. package/lib/browser/components/unseen-drop.js +1 -1
  171. package/lib/browser/device/app-badge.d.ts +9 -0
  172. package/lib/browser/device/app-badge.js +31 -0
  173. package/lib/browser/device/code-scan.js +1 -1
  174. package/lib/browser/extension/web-api-code.d.ts +26 -0
  175. package/lib/browser/extension/web-api-components.d.ts +31 -0
  176. package/lib/browser/extension/web-api-menus.d.ts +15 -0
  177. package/lib/browser/extension/web-api-messages.d.ts +16 -0
  178. package/lib/browser/extension/web-api-messages.js +3 -0
  179. package/lib/browser/extension/web-api-partners.d.ts +16 -0
  180. package/lib/browser/extension/web-api-spec.js +1 -0
  181. package/lib/browser/extension/web-extension-api.d.ts +7 -13
  182. package/lib/browser/extension/web-extension-context.js +2 -0
  183. package/lib/browser/extension/web-session-notices.js +10 -1
  184. package/lib/browser/extension/web-share-ui.js +1 -0
  185. package/lib/browser/extension/web-share.js +3 -3
  186. package/lib/browser/extension/web-sharing.js +1 -1
  187. package/lib/browser/i18n/en/assistant.d.ts +2 -0
  188. package/lib/browser/i18n/en/assistant.js +2 -0
  189. package/lib/browser/i18n/en/chat.d.ts +11 -0
  190. package/lib/browser/i18n/en/chat.js +13 -2
  191. package/lib/browser/i18n/en/common.d.ts +4 -0
  192. package/lib/browser/i18n/en/common.js +4 -0
  193. package/lib/browser/i18n/en/service.d.ts +5 -0
  194. package/lib/browser/i18n/en/service.js +5 -0
  195. package/lib/browser/i18n/en/settings.d.ts +6 -0
  196. package/lib/browser/i18n/en/settings.js +8 -2
  197. package/lib/browser/i18n/ja/assistant.js +2 -0
  198. package/lib/browser/i18n/ja/chat.js +13 -2
  199. package/lib/browser/i18n/ja/common.js +4 -0
  200. package/lib/browser/i18n/ja/service.js +5 -0
  201. package/lib/browser/i18n/ja/settings.js +10 -4
  202. package/lib/browser/i18n/locales.d.ts +29 -1
  203. package/lib/browser/i18n/messages.d.ts +28 -0
  204. package/lib/browser/i18n/zh/assistant.js +2 -0
  205. package/lib/browser/i18n/zh/chat.js +13 -2
  206. package/lib/browser/i18n/zh/common.js +4 -0
  207. package/lib/browser/i18n/zh/service.js +5 -0
  208. package/lib/browser/i18n/zh/settings.js +8 -2
  209. package/lib/browser/i18n/zh-tw/assistant.js +2 -0
  210. package/lib/browser/i18n/zh-tw/chat.js +13 -2
  211. package/lib/browser/i18n/zh-tw/common.js +4 -0
  212. package/lib/browser/i18n/zh-tw/service.js +5 -0
  213. package/lib/browser/i18n/zh-tw/settings.js +8 -2
  214. package/lib/browser/links/links.js +1 -1
  215. package/lib/browser/notices/session-notices.d.ts +4 -4
  216. package/lib/browser/notices/session-notices.js +3 -6
  217. package/lib/browser/partners/partners-util.d.ts +6 -0
  218. package/lib/browser/partners/partners-util.js +22 -0
  219. package/lib/browser/sandbox/sandbox-runtime-code.js +1 -1
  220. package/lib/browser/settings/agent-settings.d.ts +2 -0
  221. package/lib/browser/settings/agent-settings.js +3 -1
  222. package/lib/browser/settings/settings-protocol.d.ts +8 -0
  223. package/lib/browser/settings/settings-protocol.js +6 -1
  224. package/lib/browser/style/base.d.ts +1 -1
  225. package/lib/browser/style/base.js +3 -0
  226. package/lib/browser/style/chat-list.d.ts +1 -1
  227. package/lib/browser/style/chat-list.js +8 -3
  228. package/lib/browser/style/conversation-column.d.ts +1 -1
  229. package/lib/browser/style/conversation-column.js +6 -1
  230. package/lib/browser/style/conversation.d.ts +1 -1
  231. package/lib/browser/style/conversation.js +18 -0
  232. package/lib/browser/style/phone.d.ts +1 -1
  233. package/lib/browser/style/phone.js +2 -0
  234. package/lib/browser/util/composer.d.ts +18 -3
  235. package/lib/browser/util/composer.js +31 -5
  236. package/lib/browser/util/desktop.d.ts +8 -1
  237. package/lib/browser/util/desktop.js +10 -0
  238. package/lib/browser/util/image-shrink.d.ts +5 -1
  239. package/lib/browser/util/image-shrink.js +1 -1
  240. package/lib/browser/util/markdown.d.ts +3 -5
  241. package/lib/browser/util/markdown.js +5 -29
  242. package/lib/browser/util/process.js +1 -1
  243. package/package.json +7 -7
  244. package/esm/browser/util/share-link.d.ts +0 -21
  245. package/esm/browser/util/share-link.js +0 -61
  246. package/lib/browser/util/share-link.d.ts +0 -22
  247. package/lib/browser/util/share-link.js +0 -64
@@ -9,9 +9,9 @@ import { MarkdownUtil } from '../util/markdown.js';
9
9
  import { SpokenReply } from '../util/spoken.js';
10
10
  import { Gallery } from './gallery.js';
11
11
  import { IconButton } from './icon.js';
12
- import { CodeLink, LinkView } from './link.js';
12
+ import { CodeLink, FileMenu, LinkView, OpenLink } from './link.js';
13
13
  import { MathView } from './math.js';
14
- import { MediaView } from './media.js';
14
+ import { ElsewhereFiles, FileUrls, MediaView } from './media.js';
15
15
  import { MermaidView } from './mermaid-view.js';
16
16
  import { SecretText } from './secret-text.js';
17
17
  function Inline({ nodes }) {
@@ -273,10 +273,19 @@ const MarkdownBody = React.memo(function MarkdownBody({ text, streaming }) {
273
273
  * text a page shows of a conversation of its own (a group chat); else those of the conversation it is in, if any.
274
274
  * `whole`: its blocks are what the page shows, never folded (WebCodeRendererProps.whole).
275
275
  */
276
- export function Markdown({ text, streaming = false, inline = false, send, answer, whole, }) {
276
+ export function Markdown({ text, streaming = false, inline = false, send, answer, whole, files, }) {
277
+ const open = React.useContext(OpenLink);
278
+ const elsewhere = React.useMemo(() => files && {
279
+ url: (path) => (files.has(path) ? files.url(path) : Promise.reject(new Error(`${path} did not come with the text.`))),
280
+ open: (target, external) => target.type === 'path' ? files.has(target.path) && files.open(target.path) : open === null || open === void 0 ? void 0 : open(target, external),
281
+ }, [files, open]);
277
282
  const body = inline ? (React.createElement("span", { className: "ta-markdown ta-markdown-inline" },
278
283
  React.createElement(Text, { text: text }))) : (React.createElement(MarkdownBody, { text: text, streaming: streaming }));
279
- const drawn = whole === undefined ? body : React.createElement(CodeWhole.Provider, { value: whole }, body);
284
+ const own = whole === undefined ? body : React.createElement(CodeWhole.Provider, { value: whole }, body);
285
+ const drawn = files && elsewhere ? (React.createElement(ElsewhereFiles.Provider, { value: files },
286
+ React.createElement(FileUrls.Provider, { value: elsewhere.url },
287
+ React.createElement(OpenLink.Provider, { value: elsewhere.open },
288
+ React.createElement(FileMenu.Provider, { value: undefined }, own))))) : (own);
280
289
  return send ? (React.createElement(CodeReply.Provider, { value: send },
281
290
  React.createElement(CodeAnswer.Provider, { value: answer }, drawn))) : (drawn);
282
291
  }
@@ -1,4 +1,5 @@
1
1
  import * as React from 'react';
2
+ import type { WebMarkdownFiles } from '../extension/web-api-code.js';
2
3
  import { ThumbnailUtil } from '../util/thumbnail.js';
3
4
  /**
4
5
  * Where the page loads a file of the workspace from (TaWorkspaceServer.fileUrl), in the directory of the
@@ -7,6 +8,11 @@ import { ThumbnailUtil } from '../util/thumbnail.js';
7
8
  * the file before.
8
9
  */
9
10
  export declare const FileUrls: React.Context<((path: string, box?: ThumbnailUtil.Box) => Promise<string>) | undefined>;
11
+ /**
12
+ * The files that came with a text said on another computer (WebMarkdownFiles), where one is drawn: its paths are of that
13
+ * computer, and one that did not come is said to be there, not missing, nor a link.
14
+ */
15
+ export declare const ElsewhereFiles: React.Context<WebMarkdownFiles | undefined>;
10
16
  /**
11
17
  * Asks every picture that could not load to load again: one may not have come for a while (a phone whose network
12
18
  * changed, the app in the background, the relay of the computer reconnecting), not be missing.
@@ -14,6 +14,11 @@ import { Lightbox } from './lightbox.js';
14
14
  * the file before.
15
15
  */
16
16
  export const FileUrls = React.createContext(undefined);
17
+ /**
18
+ * The files that came with a text said on another computer (WebMarkdownFiles), where one is drawn: its paths are of that
19
+ * computer, and one that did not come is said to be there, not missing, nor a link.
20
+ */
21
+ export const ElsewhereFiles = React.createContext(undefined);
17
22
  /**
18
23
  * What the targets replies showed came to, kept on the device: shown again, even after the page loaded again, an
19
24
  * image has its place before it loads and one that could not show says so at once, so that nothing under them moves.
@@ -148,6 +153,7 @@ export function MediaView({ src, alt }) {
148
153
  const [full] = useMediaUrl(open && kind === 'image' ? src : undefined);
149
154
  const [loaded, setLoaded] = React.useState(false);
150
155
  const fullUrl = useFullUrl();
156
+ const elsewhere = React.useContext(ElsewhereFiles);
151
157
  const [menu, openMenu] = useImageMenu();
152
158
  const known = shown.get(src);
153
159
  // One that could not show before says so at once while it is asked again: it may only not have come then.
@@ -173,9 +179,11 @@ export function MediaView({ src, alt }) {
173
179
  }
174
180
  if (!url || failed) {
175
181
  const name = alt || src.split(/[?#]/)[0].split('/').pop() || src;
182
+ const path = MarkdownUtil.localPath(src);
183
+ const away = elsewhere && path !== undefined && !elsewhere.has(path);
176
184
  return (React.createElement("button", { type: "button", className: "ta-media-missing", title: `${src}\n${t('ta.markdown.retry')}`, onClick: askAgain },
177
185
  React.createElement(Icon, { icon: ImageOff, size: 14 }),
178
- t('ta.markdown.missing', { name })));
186
+ t(away ? 'ta.markdown.elsewhere' : 'ta.markdown.missing', { name })));
179
187
  }
180
188
  switch (kind) {
181
189
  case 'video':
@@ -50,6 +50,11 @@ export interface ChatImage {
50
50
  thumb?: string;
51
51
  width: number;
52
52
  height: number;
53
+ /** The picture as it was picked, of one shown made smaller: loaded when the user asks for it (查看原图). */
54
+ original?: {
55
+ bytes: number;
56
+ load(): Promise<string | undefined>;
57
+ };
53
58
  }
54
59
  /**
55
60
  * The pictures of a message of a chat an extension draws (a group chat, a channel), as those of the user in a
@@ -165,24 +165,60 @@ export function UserImages({ blocks, timestamp }) {
165
165
  lightbox,
166
166
  folding));
167
167
  }
168
+ /**
169
+ * The originals of pictures shown made smaller, as the user asks for them over the page (查看原图): the URL of each
170
+ * come, by key, how the loading of each goes, and the 查看原图 of the Lightbox of one not come yet.
171
+ */
172
+ function useOriginals() {
173
+ const [loaded, setLoaded] = React.useState({});
174
+ const [states, setStates] = React.useState({});
175
+ const live = React.useRef(true);
176
+ React.useEffect(() => {
177
+ live.current = true;
178
+ return () => {
179
+ live.current = false;
180
+ };
181
+ }, []);
182
+ const of = (image) => {
183
+ const original = image === null || image === void 0 ? void 0 : image.original;
184
+ if (!image || !original || loaded[image.key]) {
185
+ return undefined;
186
+ }
187
+ return {
188
+ bytes: original.bytes,
189
+ state: states[image.key],
190
+ onLoad: () => {
191
+ setStates(current => ({ ...current, [image.key]: 'loading' }));
192
+ original.load().then(url => {
193
+ if (live.current) {
194
+ url && setLoaded(current => ({ ...current, [image.key]: url }));
195
+ setStates(({ [image.key]: _, ...rest }) => (url ? rest : { ...rest, [image.key]: 'failed' }));
196
+ }
197
+ }, () => live.current && setStates(current => ({ ...current, [image.key]: 'failed' })));
198
+ },
199
+ };
200
+ };
201
+ return { src: (image) => { var _a; return (image ? ((_a = loaded[image.key]) !== null && _a !== void 0 ? _a : image.src) : undefined); }, of };
202
+ }
168
203
  /**
169
204
  * The pictures of a message of a chat an extension draws (a group chat, a channel), as those of the user in a
170
205
  * conversation: one alone in its shape, more in squares, full size over the page on a click, those still on their way
171
206
  * blurred from their thumbnail.
172
207
  */
173
208
  export function ChatImages({ images, alt = '' }) {
174
- var _a, _b, _c, _d, _e;
209
+ var _a, _b;
175
210
  const t = useT();
176
211
  const [open, setOpen] = React.useState();
177
212
  const [menu, openMenu] = useImageMenu();
178
213
  const [, redraw] = React.useReducer((n) => n + 1, 0);
214
+ const originals = useOriginals();
179
215
  if (images.length === 0) {
180
216
  return null;
181
217
  }
182
218
  const fold = `chat:${images[0].key}`;
183
219
  const single = images.length === 1 ? UserImageUtil.box({ width: images[0].width, height: images[0].height }) : undefined;
184
- const shown = open !== undefined ? (_a = images[open]) === null || _a === void 0 ? void 0 : _a.src : undefined;
185
- const lightbox = open !== undefined && shown && (React.createElement(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 }));
220
+ const shown = open !== undefined ? originals.src(images[open]) : undefined;
221
+ const lightbox = open !== undefined && shown && (React.createElement(Lightbox, { src: shown, alt: alt, count: { at: open, of: images.length }, onClose: () => setOpen(undefined), onPrevious: open > 0 && ((_a = images[open - 1]) === null || _a === void 0 ? void 0 : _a.src) ? () => setOpen(open - 1) : undefined, onNext: open < images.length - 1 && ((_b = images[open + 1]) === null || _b === void 0 ? void 0 : _b.src) ? () => setOpen(open + 1) : undefined, previousSrc: open > 0 ? originals.src(images[open - 1]) : undefined, nextSrc: originals.src(images[open + 1]), original: originals.of(images[open]) }));
186
222
  if (ImageStackUtil.stacked(images.length, fold)) {
187
223
  return (React.createElement(React.Fragment, null,
188
224
  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: () => {
@@ -193,7 +229,7 @@ export function ChatImages({ images, alt = '' }) {
193
229
  }
194
230
  return (React.createElement("div", { className: "ta-user-images ta-chat-images", "data-count": Math.min(images.length, 3), style: { '--ta-user-image-columns': GalleryUtil.columns(images.length) } },
195
231
  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 => {
196
- const source = image.src;
232
+ const source = originals.src(image);
197
233
  if (source) {
198
234
  openMenu(event, { full: () => source, enlarge: () => setOpen(at) });
199
235
  }
@@ -15,6 +15,7 @@ import { STACK_FROM, UserImages, UserImageUtil } from './message-images.js';
15
15
  import { useMessageMenu } from './message-menu.js';
16
16
  import { MessagePeople } from './people.js';
17
17
  import { SaidText } from './said-text.js';
18
+ import { Sending } from './sending.js';
18
19
  /** The messages of the conversation still on their way from here, by message, with what can be done with those that failed. */
19
20
  export const Outbox = React.createContext({ of: new Map() });
20
21
  /** A message that did not go: marked as such, with a way to send it again or take it back, as in a messenger. */
@@ -203,8 +204,9 @@ function UserBubble({ message, blocks, text, copied, skill, queued, }) {
203
204
  // Not in the session yet: nothing to branch from or rewind to.
204
205
  return (React.createElement("div", { className: `ta-message ta-user ${sent.failed ? 'ta-user-failed' : 'ta-user-sending'}` },
205
206
  marks,
206
- React.createElement(UserSaid, { blocks: blocks, text: text, timestamp: message.timestamp }),
207
- sent.failed ? React.createElement(SendFailed, { sent: sent, actions: outbox.actions }) : React.createElement("div", { className: "ta-footer" })));
207
+ React.createElement(Sending, { failed: sent.failed, onResend: sent.code === TaErrorCode.NOT_SIGNED_IN ? undefined : outbox.actions && (() => { var _a; return (_a = outbox.actions) === null || _a === void 0 ? void 0 : _a.resend(sent.id); }), line: React.createElement(SendFailed, { sent: sent, actions: outbox.actions }) },
208
+ React.createElement(UserSaid, { blocks: blocks, text: text, timestamp: message.timestamp })),
209
+ !sent.failed && React.createElement("div", { className: "ta-footer" })));
208
210
  }
209
211
  return (React.createElement("div", { className: "ta-message ta-user", onContextMenu: onContextMenu },
210
212
  marks,
@@ -16,8 +16,8 @@ import { SwipeRow } from './swipe-row.js';
16
16
  * same for every kind (PartnerRowUtil).
17
17
  */
18
18
  export function PartnerRow({ partner, time, selected, open, pinned, onPin, }) {
19
- var _a, _b;
20
- var _c;
19
+ var _a, _b, _c, _d;
20
+ var _e;
21
21
  const t = useT();
22
22
  const [menu, openMenu] = useContextMenu();
23
23
  const [opening, setOpening] = React.useState(false);
@@ -55,7 +55,7 @@ export function PartnerRow({ partner, time, selected, open, pinned, onPin, }) {
55
55
  Own && !opening ? (React.createElement("span", { className: "ta-chat-face", style: { width: 38, height: 38 }, "aria-hidden": "true" },
56
56
  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 }))),
57
57
  partner.online && React.createElement("span", { className: "ta-partner-online", "aria-hidden": "true" }),
58
- React.createElement(ChatDot, { unseen: unseen, asks: asks })),
59
- React.createElement(RowText, { title: partner.name, time: time, line: 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(HostTag, { location: partner.location }) : undefined, badge: (_c = partner.label) !== null && _c !== void 0 ? _c : (partner.friends ? t('ta.partners.withFriends') : undefined) }))));
58
+ React.createElement(ChatDot, { unseen: unseen, asks: asks, count: PartnersUtil.count(partner), onSee: selected || partner.status ? undefined : (_b = partner.chat) === null || _b === void 0 ? void 0 : _b.see })),
59
+ React.createElement(RowText, { title: partner.name, time: time, line: PartnersUtil.line(partner, t('ta.partners.waiting')), unseen: unseen, flag: !partner.status && ((_c = partner.chat) === null || _c === void 0 ? void 0 : _c.flag) ? React.createElement("span", { className: "ta-chat-flag ta-alert" }, partner.chat.flag) : undefined, busy: !partner.status && !!((_d = partner.chat) === null || _d === void 0 ? void 0 : _d.busy), tag: partner.location ? React.createElement(HostTag, { location: partner.location }) : undefined, badge: (_e = partner.label) !== null && _e !== void 0 ? _e : (partner.friends ? t('ta.partners.withFriends') : undefined) }))));
60
60
  }
61
61
  //# sourceMappingURL=partner-row.js.map
@@ -19,6 +19,8 @@ export interface PhoneTab {
19
19
  onSeeAll?(): void;
20
20
  /** How many wait for the user to decide (the double's tab): a blue count, in place of the amber dot. */
21
21
  asks?: number;
22
+ /** How many messages people sent the user has not seen (the chats' tab): a red number, before all else. */
23
+ count?: number;
22
24
  }
23
25
  export interface PhoneShellProps {
24
26
  tabs: PhoneTab[];
@@ -6,7 +6,7 @@ import { useHeld } from '../device/hold.js';
6
6
  import { usePullDown } from '../device/pull-down.js';
7
7
  import { useSheetSwipe } from '../device/sheet-swipe.js';
8
8
  import { useT } from '../i18n/use-t.js';
9
- import { AsksBadge } from './asks-badge.js';
9
+ import { AsksBadge, PeopleBadge } from './asks-badge.js';
10
10
  import { useContextMenu } from './context-menu.js';
11
11
  import { DinoFace } from './ta-avatar.js';
12
12
  import { UnseenDrop } from './unseen-drop.js';
@@ -243,7 +243,7 @@ function TabBar({ tabs, tab, onTab }) {
243
243
  return (React.createElement("button", { key: item.id, type: "button", className: `ta-tabbar-item${active ? ' ta-active' : ''}`, "aria-current": active ? 'page' : undefined, onClick: event => (active ? again(item.id, event.currentTarget.closest('.ta-phone-home')) : onTab(item.id)), onContextMenu: item.menu ? event => { var _a; return openMenu(event, (_a = item.menu) !== null && _a !== void 0 ? _a : []); } : undefined, ...held(item.hold) },
244
244
  React.createElement("span", { className: "ta-tabbar-icon" },
245
245
  item.double ? React.createElement(DinoFace, { size: 24, className: "ta-nav-face" }) : React.createElement(Glyph, { size: 22, strokeWidth: active ? 2 : 1.6 }),
246
- item.asks ? (React.createElement(AsksBadge, { count: item.asks, onDismiss: item.onSeeAll })) : (item.unseen && React.createElement(UnseenDrop, { label: t('ta.chat.unseen'), onDismiss: item.onSeeAll }))),
246
+ item.count ? (React.createElement(PeopleBadge, { count: item.count, onDismiss: item.onSeeAll })) : item.asks ? (React.createElement(AsksBadge, { count: item.asks, onDismiss: item.onSeeAll })) : (item.unseen && React.createElement(UnseenDrop, { label: t('ta.chat.unseen'), onDismiss: item.onSeeAll }))),
247
247
  React.createElement("span", null, item.label)));
248
248
  }),
249
249
  menu));
@@ -0,0 +1,19 @@
1
+ import * as React from 'react';
2
+ /** How a message of the user on its way shows (WebSendingProps). */
3
+ export interface SendingProps {
4
+ /** Why it did not go: a red mark beside it, and under it the line `line`, else 发送失败 · 重发 · 删除. */
5
+ failed?: string;
6
+ /** How far it went, 0 to 1, when known: said beside the spinner. */
7
+ progress?: number;
8
+ onResend?(): void;
9
+ onDiscard?(): void;
10
+ /** In place of the line under one that did not go. */
11
+ line?: React.ReactNode;
12
+ children?: React.ReactNode;
13
+ }
14
+ /**
15
+ * A message of the user on its way, as a messenger shows it: drawn at once, a spinner beside it while it goes, a red
16
+ * mark beside it and a way to send it again or take it back under it once it did not go. Conversations and the chats
17
+ * of extensions (`ui.Sending`) show their messages on their way so alike.
18
+ */
19
+ export declare function Sending({ failed, progress, onResend, onDiscard, line, children }: SendingProps): React.JSX.Element;
@@ -0,0 +1,27 @@
1
+ import { CircleAlert } from 'lucide-react';
2
+ import * as React from 'react';
3
+ import { useT } from '../i18n/use-t.js';
4
+ import { Icon } from './icon.js';
5
+ /**
6
+ * A message of the user on its way, as a messenger shows it: drawn at once, a spinner beside it while it goes, a red
7
+ * mark beside it and a way to send it again or take it back under it once it did not go. Conversations and the chats
8
+ * of extensions (`ui.Sending`) show their messages on their way so alike.
9
+ */
10
+ export function Sending({ failed, progress, onResend, onDiscard, line, children }) {
11
+ const t = useT();
12
+ const percent = progress !== undefined && progress >= 0 && progress < 1 ? Math.floor(progress * 100) : undefined;
13
+ return (React.createElement(React.Fragment, null,
14
+ React.createElement("div", { className: `ta-sending${failed ? ' ta-sending-failed' : ''}` },
15
+ failed ? (React.createElement("button", { type: "button", className: "ta-sending-mark", title: failed, "aria-label": t('ta.message.resend'), disabled: !onResend, onClick: onResend },
16
+ React.createElement(Icon, { icon: CircleAlert, size: 18 }))) : (React.createElement("span", { className: "ta-sending-mark", role: "status", "aria-label": t('ta.message.sending') },
17
+ percent !== undefined && React.createElement("span", { className: "ta-sending-percent" }, `${percent}%`),
18
+ React.createElement("span", { className: "ta-spinner" }))),
19
+ React.createElement("div", { className: "ta-sending-body" }, children)),
20
+ failed &&
21
+ (line !== null && line !== void 0 ? line : (React.createElement("div", { className: "ta-send-failed", title: failed },
22
+ React.createElement(Icon, { icon: CircleAlert, size: 14 }),
23
+ React.createElement("span", null, t('ta.message.sendFailed')),
24
+ onResend && (React.createElement("button", { type: "button", className: "ta-link-button", onClick: onResend }, t('ta.message.resend'))),
25
+ onDiscard && (React.createElement("button", { type: "button", className: "ta-link-button", onClick: onDiscard }, t('ta.message.discard'))))))));
26
+ }
27
+ //# sourceMappingURL=sending.js.map
@@ -13,6 +13,7 @@ import { CodeConversation, CodeReply } from '../markdown/code-renderers.js';
13
13
  import { ScreenUtil } from '../screen/screen-protocol.js';
14
14
  import { ScreenScroll } from '../screen/screen-scroll.js';
15
15
  import { useScreenPart } from '../screen/use-screen-part.js';
16
+ import { QUEUE_SETTINGS } from '../settings/agent-settings.js';
16
17
  import { LinkUtil } from '../util/link.js';
17
18
  import { MessageUtil } from '../util/message.js';
18
19
  import { TerminalText } from '../util/terminal-text.js';
@@ -154,7 +155,7 @@ export function SessionView({ store, server, workspace, info, onClosed, onActivi
154
155
  const { settings, actions } = useSessionSettings(server, useSettingsServer(), store, state, t, fail, contextAct);
155
156
  const composer = React.useRef(null);
156
157
  const [settingsState] = useSettings();
157
- const recentShots = settingsState.settings.recentShots;
158
+ const { recentShots, sendWhileWorking } = settingsState.settings;
158
159
  // A call: the conversation listens, answers aloud, and listens again (VoiceCall); not in a tab of the workbench.
159
160
  const [callState, call] = useVoiceCall({
160
161
  language: () => settingsState.language,
@@ -207,7 +208,7 @@ export function SessionView({ store, server, workspace, info, onClosed, onActivi
207
208
  const fileUrl = React.useCallback(async (path, box) => files.loadable(ThumbnailUtil.boxed(await workspace.fileUrl(path, cwd), box)), [workspace, cwd, files]);
208
209
  const namedPaths = React.useCallback(() => MessageUtil.namedPaths(store.state.messages), [store]);
209
210
  const openLink = useOpenLink(cwd, namedPaths);
210
- const [{ fileMenus }] = useWebExtensions();
211
+ const [{ fileMenus }, extensions] = useWebExtensions();
211
212
  const fileMenu = React.useCallback((path) => (cwd ? fileMenus.flatMap(menu => menu(LinkUtil.fileRef(cwd, path))) : []), [cwd, fileMenus]);
212
213
  // biome-ignore lint/correctness/useExhaustiveDependencies: runs when a run starts or settles
213
214
  React.useEffect(() => onActivity(), [state.working, onActivity]);
@@ -391,7 +392,7 @@ export function SessionView({ store, server, workspace, info, onClosed, onActivi
391
392
  widgetsAt('aboveEditor'),
392
393
  addons.above,
393
394
  React.createElement(CallBar, { state: callState, call: call })),
394
- React.createElement(Composer, { above: React.createElement(PhoneHint, null), ref: composer, store: store, server: server, workspace: workspace, working: state.working, compacting: !!state.compacting, commands: settings.commands, cwd: info === null || info === void 0 ? void 0 : info.cwd, actions: composerActions, recentShots: recentShots, onStopTimed: stopTimed, onTyping: onTyping, draft: (info === null || info === void 0 ? void 0 : info.sessionFile) ? DraftPlaces.chat(info.sessionFile) : undefined, onTalkCall: callable && !callState.active ? talkCall(call) : undefined, talkCalls: talkCalls, onError: fail }),
395
+ React.createElement(Composer, { above: React.createElement(PhoneHint, null), ref: composer, store: store, server: server, workspace: workspace, working: state.working, compacting: !!state.compacting, commands: settings.commands, cwd: info === null || info === void 0 ? void 0 : info.cwd, actions: composerActions, recentShots: recentShots, sendWhileWorking: sendWhileWorking, onQueueSettings: () => extensions.openSettings(QUEUE_SETTINGS), onStopTimed: stopTimed, onTyping: onTyping, draft: (info === null || info === void 0 ? void 0 : info.sessionFile) ? DraftPlaces.chat(info.sessionFile) : undefined, onTalkCall: callable && !callState.active ? talkCall(call) : undefined, talkCalls: talkCalls, onError: fail }),
395
396
  belowComposer,
396
397
  widgetsAt('belowEditor'),
397
398
  statuses.length > 0 && (React.createElement("div", { className: "ta-statusline" }, statuses.map(([key, text]) => (React.createElement(StatusChip, { key: key, text: text })))))))));
@@ -43,6 +43,7 @@ export const SHORTCUTS = [
43
43
  { keys: 'Enter', label: 'ta.shortcut.send' },
44
44
  { keys: 'Shift+Enter', label: 'ta.shortcut.newline' },
45
45
  { keys: 'Alt+Enter', label: 'ta.shortcut.followUp' },
46
+ { keys: 'Mod+Enter', label: 'ta.shortcut.sendNow' },
46
47
  { keys: 'Esc', label: 'ta.shortcut.stop' },
47
48
  { keys: '/', label: 'ta.shortcut.commands' },
48
49
  { keys: '@', label: 'ta.shortcut.files' },
@@ -5,9 +5,10 @@ import { useDevice } from '../device/device.js';
5
5
  import { WebLabelUtil } from '../extension/web-extension-protocol.js';
6
6
  import { useSettings, useSettingsServer, useWebExtensions, useWorkbench } from '../hooks.js';
7
7
  import { useT } from '../i18n/use-t.js';
8
- import { AGENT_SETTINGS_GROUPS, AgentSettingsUtil } from '../settings/agent-settings.js';
9
- import { CHAT_ARCHIVE_CHOICES, CHAT_FOLD_CHOICES, MAX_TASKS_CHOICES, NO_SKIN } from '../settings/settings-protocol.js';
8
+ import { AGENT_SETTINGS_GROUPS, AgentSettingsUtil, QUEUE_SETTINGS, ShortcutUtil } from '../settings/agent-settings.js';
9
+ import { CHAT_ARCHIVE_CHOICES, CHAT_FOLD_CHOICES, MAX_TASKS_CHOICES, NO_SKIN, SEND_WHILE_WORKING } from '../settings/settings-protocol.js';
10
10
  import { SkinUtil } from '../skin/skin-util.js';
11
+ import { ComposerUtil } from '../util/composer.js';
11
12
  import { Voice } from '../util/voice.js';
12
13
  import { AgentControl, ScopeBar, useAgentSettings } from './agent-settings-view.js';
13
14
  import { useNavigation } from './app-nav.js';
@@ -181,27 +182,37 @@ export function useParts(scope, onScope, onDialog) {
181
182
  !agent.offline && !snapshot && !agent.error && React.createElement(Loading, { compact: true, label: t('ta.settings.loading') }),
182
183
  locked && React.createElement("div", { className: "ta-settings-note" }, t('ta.settings.untrusted')),
183
184
  agent.error && React.createElement("div", { className: "ta-banner ta-banner-error" }, t('ta.settings.failed', { error: agent.error }))));
184
- const ta = AGENT_SETTINGS_GROUPS.map(group => { var _a; return ({
185
+ // Of this device, in the section of what pi does with the messages sent while Ta works: one place for the queue.
186
+ const own = {
187
+ [QUEUE_SETTINGS]: [
188
+ row('send-while-working', [t('ta.settings.sendWhileWorking'), t('ta.settings.sendWhileWorkingHint', ComposerUtil.keyNames(ShortcutUtil.isMac()))], React.createElement(Row, { label: t('ta.settings.sendWhileWorking'), description: t('ta.settings.sendWhileWorkingHint', ComposerUtil.keyNames(ShortcutUtil.isMac())), stacked: true },
189
+ React.createElement(Segmented, { label: t('ta.settings.sendWhileWorking'), value: settings.sendWhileWorking, choices: SEND_WHILE_WORKING.map(value => ({ value, label: t(`ta.settings.sendWhileWorking.${value}`) })), onChange: value => store.update({ sendWhileWorking: value }) }))),
190
+ ],
191
+ };
192
+ const ta = AGENT_SETTINGS_GROUPS.map(group => { var _a, _b; return ({
185
193
  id: group.id,
186
194
  title: t(group.title),
187
195
  icon: (_a = GROUP_ICONS[group.id]) !== null && _a !== void 0 ? _a : Wrench,
188
196
  group: 'ta',
189
197
  scoped: true,
190
198
  ...(group.id === 'model' ? { tier: 'common' } : {}),
191
- rows: snapshot
192
- ? group.keys.flatMap(key => {
193
- const spec = AgentSettingsUtil.spec(key);
194
- if (!spec) {
195
- return [];
196
- }
197
- const label = t(AgentSettingsUtil.label(key));
198
- const hint = AgentSettingsUtil.hint(key);
199
- return [
200
- row(key, [label, hint && t(hint), key], React.createElement(Row, { label: label, description: hint && t(hint), modified: snapshot[scope][key] !== undefined },
201
- React.createElement(AgentControl, { spec: spec, scope: scope, snapshot: snapshot, disabled: locked, onChange: changes => agent.update(scope, changes) }))),
202
- ];
203
- })
204
- : [],
199
+ rows: [
200
+ ...((_b = own[group.id]) !== null && _b !== void 0 ? _b : []),
201
+ ...(snapshot
202
+ ? group.keys.flatMap(key => {
203
+ const spec = AgentSettingsUtil.spec(key);
204
+ if (!spec) {
205
+ return [];
206
+ }
207
+ const label = t(AgentSettingsUtil.label(key));
208
+ const hint = AgentSettingsUtil.hint(key);
209
+ return [
210
+ row(key, [label, hint && t(hint), key], React.createElement(Row, { label: label, description: hint && t(hint), modified: snapshot[scope][key] !== undefined },
211
+ React.createElement(AgentControl, { spec: spec, scope: scope, snapshot: snapshot, disabled: locked, onChange: changes => agent.update(scope, changes) }))),
212
+ ];
213
+ })
214
+ : []),
215
+ ],
205
216
  }); });
206
217
  // Ta's scoped sections first in its part, under their scope; each part's own sections before those of extensions.
207
218
  const sections = [...web.filter(entry => entry.group !== 'ta'), ...ta, ...web.filter(entry => entry.group === 'ta'), ...more];
@@ -1,8 +1,8 @@
1
+ import { ShareLinkUtil } from '@celljs/ta-protocol/lib/common/share-link';
1
2
  import { Package } from 'lucide-react';
2
3
  import * as React from 'react';
3
4
  import { useNotices, useWebExtensions, useWorkbench } from '../hooks.js';
4
5
  import { useT } from '../i18n/use-t.js';
5
- import { ShareLinkUtil } from '../util/share-link.js';
6
6
  import { ShareItemSheet } from './share-item-sheet.js';
7
7
  import { ShareSheet } from './share-sheet.js';
8
8
  /** The link of an extension: of its source when it is published, else of the relay, made by this computer. */
@@ -35,10 +35,11 @@ export function ShareDialog({ target, onClose }) {
35
35
  const t = useT();
36
36
  const [, bench] = useWorkbench();
37
37
  const [, notices] = useNotices();
38
+ const [{ shareWays }] = useWebExtensions();
38
39
  const [shared, error] = useShared(target);
39
40
  const packageId = target.packageId;
40
41
  const days = (shared === null || shared === void 0 ? void 0 : shared.relayed) ? Math.max(1, Math.round((shared.expiresAt - Date.now()) / 86400000)) : 0;
41
- return (React.createElement(ShareSheet, { title: t('ta.share.title', { name: target.title }), link: shared === null || shared === void 0 ? void 0 : shared.link, error: error === undefined ? undefined : error || t('ta.share.cannot'), face: React.createElement(Package, { size: 22 }), name: target.title, gets: t('ta.share.extensionGets'), invite: t('ta.share.extensionInvite', { name: target.title }), notes: [(shared === null || shared === void 0 ? void 0 : shared.relayed) ? t('ta.share.relayed', { days, size: Math.round(shared.maxBytes / 1024 / 1024) }) : t('ta.share.published')], onStop: (shared === null || shared === void 0 ? void 0 : shared.relayed) && packageId ? () => bench.relay.unsharePackage(packageId) : undefined, stop: { title: t('ta.share.stopTitle', { name: target.title }), message: t('ta.share.stopHint') }, onClose: onClose, notices: notices, rooms: bench.rooms, onRoomEvent: listener => bench.onRoomEvent(listener, { messages: false }) }));
42
+ return (React.createElement(ShareSheet, { title: t('ta.share.title', { name: target.title }), link: shared === null || shared === void 0 ? void 0 : shared.link, error: error === undefined ? undefined : error || t('ta.share.cannot'), face: React.createElement(Package, { size: 22 }), name: target.title, icon: "Package", gets: t('ta.share.extensionGets'), invite: t('ta.share.extensionInvite', { name: target.title }), notes: [(shared === null || shared === void 0 ? void 0 : shared.relayed) ? t('ta.share.relayed', { days, size: Math.round(shared.maxBytes / 1024 / 1024) }) : t('ta.share.published')], onStop: (shared === null || shared === void 0 ? void 0 : shared.relayed) && packageId ? () => bench.relay.unsharePackage(packageId) : undefined, stop: { title: t('ta.share.stopTitle', { name: target.title }), message: t('ta.share.stopHint') }, onClose: onClose, notices: notices, rooms: bench.rooms, onRoomEvent: listener => bench.onRoomEvent(listener, { messages: false }), ways: () => shareWays }));
42
43
  }
43
44
  /** The share asked for by a web extension, over the page: an extension handed on, or the share sheet of something. */
44
45
  export function ShareHost() {
@@ -33,7 +33,7 @@ export function ShareItemSheet({ item, ways, onClose }) {
33
33
  React.createElement(Icon, { size: 22 })),
34
34
  React.createElement("span", { className: "ta-share-who-text" },
35
35
  React.createElement("strong", { className: "ta-share-name" }, name),
36
- React.createElement("span", { className: "ta-share-gets" }, item.kind === 'file' ? t('ta.share.itemFile') : t('ta.share.itemWork'))))),
36
+ React.createElement("span", { className: "ta-share-gets" }, item.kind === 'file' ? t('ta.share.itemFile') : item.kind === 'link' ? item.gets : t('ta.share.itemWork'))))),
37
37
  taking.length ? (React.createElement("div", { className: "ta-share-tiles" }, taking.map(way => (React.createElement(Tile, { key: way.key, icon: way.icon, label: WebShareUtil.label(way), onClick: () => pick(way) }))))) : (React.createElement(EmptyState, { title: t('ta.share.noWay'), compact: true })))));
38
38
  }
39
39
  //# sourceMappingURL=share-item-sheet.js.map
@@ -1,6 +1,6 @@
1
1
  import type { TaRoomEvent, TaRoomServer } from '@celljs/ta-protocol';
2
2
  import * as React from 'react';
3
- import type { WebIcon, WebShareSheetProps } from '../extension/web-extension-api.js';
3
+ import type { WebIcon, WebShareSheetProps, WebShareWay } from '../extension/web-extension-api.js';
4
4
  import type { TaNotices } from '../notices/notices-protocol.js';
5
5
  /** One of the actions under the code, as the share sheets of phones: a round icon over a word. */
6
6
  export declare function Tile({ icon: Icon, label, onClick, disabled }: {
@@ -19,5 +19,7 @@ export interface ShareSheetServices {
19
19
  notices: TaNotices;
20
20
  rooms: TaRoomServer;
21
21
  onRoomEvent?(listener: (event: TaRoomEvent) => void): () => void;
22
+ /** The ways to share (registerShareWay): one that takes a link sends it into chats, friends' and group chats alike. */
23
+ ways?(): readonly WebShareWay[];
22
24
  }
23
- export declare function ShareSheet({ title, link, error, face, name, gets, invite, notes, password, own, onRenew, onStop, stop, onClose, children, notices, rooms, onRoomEvent, }: WebShareSheetProps & ShareSheetServices): React.JSX.Element;
25
+ export declare function ShareSheet({ title, link, error, face, name, icon, gets, invite, notes, password, own, onRenew, onStop, stop, onClose, children, notices, rooms, onRoomEvent, ways, }: WebShareSheetProps & ShareSheetServices): React.JSX.Element;
@@ -1,6 +1,7 @@
1
1
  import { Check, Copy, KeyRound, RefreshCw, Send, Share2 } from 'lucide-react';
2
2
  import * as React from 'react';
3
3
  import { shareMessage } from '../extension/share-sheet-compat.js';
4
+ import { WebShareUtil } from '../extension/web-share.js';
4
5
  import { useT } from '../i18n/use-t.js';
5
6
  import { useBusy } from './busy.js';
6
7
  import { EmptyState } from './empty-state.js';
@@ -27,7 +28,7 @@ export function Tile({ icon: Icon, label, onClick, disabled }) {
27
28
  React.createElement(Icon, { size: 20 })),
28
29
  React.createElement("span", { className: "ta-share-tile-label" }, label)));
29
30
  }
30
- export function ShareSheet({ title, link, error, face, name, gets, invite, notes, password, own, onRenew, onStop, stop, onClose, children, notices, rooms, onRoomEvent, }) {
31
+ export function ShareSheet({ title, link, error, face, name, icon, gets, invite, notes, password, own, onRenew, onStop, stop, onClose, children, notices, rooms, onRoomEvent, ways, }) {
31
32
  const t = useT();
32
33
  const [copied, copy] = useCopied();
33
34
  const [stopping, run] = useBusy();
@@ -35,7 +36,19 @@ export function ShareSheet({ title, link, error, face, name, gets, invite, notes
35
36
  const friends = useShareFriends(rooms);
36
37
  const [sends, setSends] = React.useState(0);
37
38
  const sent = useFriendSends(rooms, own ? undefined : link, sends, onRoomEvent);
38
- const canFriends = !own && !!(friends === null || friends === void 0 ? void 0 : friends.length);
39
+ // Sent into chats as a card, to friends and group chats alike, where a way takes a link (ta-rooms); else sealed for friends alone.
40
+ const chatItem = link && !own ? { kind: 'link', link, title: name || title, invite, ...(gets ? { gets } : {}), ...(icon ? { icon } : {}) } : undefined;
41
+ const chatWay = chatItem ? ways === null || ways === void 0 ? void 0 : ways().find(way => way.accepts(chatItem)) : undefined;
42
+ const toChats = () => {
43
+ if (!chatWay || !chatItem) {
44
+ return;
45
+ }
46
+ onClose();
47
+ Promise.resolve()
48
+ .then(() => chatWay.share(chatItem))
49
+ .catch(reason => notices.error(reason));
50
+ };
51
+ const canFriends = !own && !chatWay && !!(friends === null || friends === void 0 ? void 0 : friends.length);
39
52
  const canSend = !own && typeof navigator !== 'undefined' && typeof navigator.share === 'function';
40
53
  const end = async () => {
41
54
  if (!onStop || (stop && !(await notices.confirm({ title: stop.title, message: stop.message, confirmLabel: t('ta.share.stop'), danger: true })))) {
@@ -73,6 +86,7 @@ export function ShareSheet({ title, link, error, face, name, gets, invite, notes
73
86
  setSends(n => n + 1);
74
87
  }
75
88
  } })) : (React.createElement("div", { className: "ta-share-tiles" },
89
+ chatWay && React.createElement(Tile, { icon: chatWay.icon, label: WebShareUtil.label(chatWay), onClick: toChats }),
76
90
  canFriends && React.createElement(Tile, { icon: Send, label: t('ta.share.friends'), disabled: !link, onClick: () => setPicking(true) }),
77
91
  React.createElement(Tile, { icon: copied === 'link' ? Check : Copy, label: copied === 'link' ? t('ta.share.copied') : t('ta.share.copy'), disabled: !link, onClick: () => link && copy(shareMessage(invite, link), 'link') }),
78
92
  canSend && (React.createElement(Tile, { icon: Share2, label: t('ta.share.apps'), disabled: !link, onClick: () => link && void navigator.share({ title: name || title, text: invite, url: link }).catch(() => undefined) })),
@@ -78,7 +78,13 @@ function usePolledSignIn(onFailed) {
78
78
  window.open(url, '_blank');
79
79
  }
80
80
  },
81
- onProgress: () => undefined,
81
+ // Refused or too late there: this page says so, and the button signs in anew.
82
+ onProgress: progress => {
83
+ if (progress.failed) {
84
+ signIn.stop();
85
+ onFailed();
86
+ }
87
+ },
82
88
  });
83
89
  running.current = signIn;
84
90
  void signIn
@@ -27,8 +27,8 @@ export declare namespace UnseenDropUtil {
27
27
  function neck(from: Point, r: number, to: Point, R: number): string;
28
28
  function distance(a: Point, b: Point): number;
29
29
  }
30
- /** The colour of what is dragged: amber of something unseen, blue of what waits for the user to decide. */
31
- export type DropTone = 'unseen' | 'asks';
30
+ /** The colour of what is dragged: amber of something unseen, blue of what waits for the user to decide, red of what people said. */
31
+ export type DropTone = 'unseen' | 'asks' | 'people';
32
32
  /**
33
33
  * The amber dot of a tab that has something unseen, or the blue count of what waits for the user (AsksBadge, its
34
34
  * `children`). A finger, or the mouse, drags it off as a drop of water, as QQ's unread: stretched past its neck and
@@ -61,7 +61,7 @@ class DropOverlay {
61
61
  this.dot = document.createElementNS(SVG, 'circle');
62
62
  this.bridge = document.createElementNS(SVG, 'path');
63
63
  this.drop = document.createElementNS(SVG, 'circle');
64
- this.svg.setAttribute('class', tone === 'asks' ? 'ta-unseen-drag ta-asks' : 'ta-unseen-drag');
64
+ this.svg.setAttribute('class', tone === 'unseen' ? 'ta-unseen-drag' : `ta-unseen-drag ta-${tone}`);
65
65
  this.svg.setAttribute('aria-hidden', 'true');
66
66
  this.dot.setAttribute('cx', String(origin.x));
67
67
  this.dot.setAttribute('cy', String(origin.y));
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The number on the icon of Ta, as a messenger's: the messages of people the user has not seen, the red number of the
3
+ * chats' tab. Ta Desktop's Dock, the app on iOS (TaPush.swift, which the computer's pushes set too while the app is
4
+ * closed), or an installed web page (the Badging API); 0 takes it off. Nothing where there is no icon.
5
+ */
6
+ export declare namespace AppBadge {
7
+ function set(count: number, scope?: object): void;
8
+ }
@@ -0,0 +1,28 @@
1
+ import { DesktopUtil } from '../util/desktop.js';
2
+ /**
3
+ * The number on the icon of Ta, as a messenger's: the messages of people the user has not seen, the red number of the
4
+ * chats' tab. Ta Desktop's Dock, the app on iOS (TaPush.swift, which the computer's pushes set too while the app is
5
+ * closed), or an installed web page (the Badging API); 0 takes it off. Nothing where there is no icon.
6
+ */
7
+ export var AppBadge;
8
+ (function (AppBadge) {
9
+ function set(count, scope = globalThis) {
10
+ var _a, _b, _c;
11
+ const value = Math.max(0, Math.floor(count) || 0);
12
+ const desktop = DesktopUtil.badge(scope);
13
+ if (desktop) {
14
+ desktop(value);
15
+ return;
16
+ }
17
+ const { webkit, navigator } = scope;
18
+ const app = (_a = webkit === null || webkit === void 0 ? void 0 : webkit.messageHandlers) === null || _a === void 0 ? void 0 : _a.taPush;
19
+ if (app) {
20
+ app.postMessage({ action: 'badge', count: value });
21
+ return;
22
+ }
23
+ const done = value ? (_b = navigator === null || navigator === void 0 ? void 0 : navigator.setAppBadge) === null || _b === void 0 ? void 0 : _b.call(navigator, value) : (_c = navigator === null || navigator === void 0 ? void 0 : navigator.clearAppBadge) === null || _c === void 0 ? void 0 : _c.call(navigator);
24
+ void (done === null || done === void 0 ? void 0 : done.catch(() => undefined));
25
+ }
26
+ AppBadge.set = set;
27
+ })(AppBadge || (AppBadge = {}));
28
+ //# sourceMappingURL=app-badge.js.map
@@ -1,5 +1,5 @@
1
+ import { ShareLinkUtil } from '@celljs/ta-protocol/lib/common/share-link';
1
2
  import { message } from '../i18n/messages.js';
2
- import { ShareLinkUtil } from '../util/share-link.js';
3
3
  import { WorkbenchUtil } from '../workbench-util.js';
4
4
  import { CodeVision } from './code-vision.js';
5
5
  import { MiniProgram } from './mini-program.js';