@celljs/ta-web 4.14.0 → 4.15.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 (89) hide show
  1. package/README.en.md +1 -1
  2. package/README.md +1 -1
  3. package/esm/browser/assistant/assistant-initiative.js +1 -1
  4. package/esm/browser/components/access-view.js +3 -2
  5. package/esm/browser/components/account-menu.js +2 -2
  6. package/esm/browser/components/auth-view.d.ts +1 -1
  7. package/esm/browser/components/auth-view.js +38 -10
  8. package/esm/browser/components/custom-provider-advanced.d.ts +14 -0
  9. package/esm/browser/components/custom-provider-advanced.js +50 -0
  10. package/esm/browser/components/custom-provider-util.d.ts +38 -0
  11. package/esm/browser/components/custom-provider-util.js +103 -0
  12. package/esm/browser/components/custom-provider-view.d.ts +11 -0
  13. package/esm/browser/components/custom-provider-view.js +181 -0
  14. package/esm/browser/components/host-view.d.ts +1 -1
  15. package/esm/browser/components/settings-choices.js +2 -3
  16. package/esm/browser/components/settings-controls.d.ts +7 -1
  17. package/esm/browser/components/settings-controls.js +8 -0
  18. package/esm/browser/components/settings-parts.js +11 -5
  19. package/esm/browser/components/sign-in-setup.js +3 -1
  20. package/esm/browser/editor/monaco-loader.js +7 -1
  21. package/esm/browser/extension/web-api-contributions.d.ts +3 -0
  22. package/esm/browser/extension/web-extension-api.d.ts +7 -0
  23. package/esm/browser/extension/web-extension-context.d.ts +2 -0
  24. package/esm/browser/extension/web-extension-context.js +19 -0
  25. package/esm/browser/game/game-loader.js +22 -2
  26. package/esm/browser/game/game3d-protocol.d.ts +13 -4
  27. package/esm/browser/i18n/locales.d.ts +56 -1
  28. package/esm/browser/i18n/locales.js +25 -1
  29. package/esm/browser/i18n/messages-ja.d.ts +2 -0
  30. package/esm/browser/i18n/messages-ja.js +972 -0
  31. package/esm/browser/i18n/messages-zh-tw.d.ts +3 -0
  32. package/esm/browser/i18n/messages-zh-tw.js +973 -0
  33. package/esm/browser/i18n/messages.d.ts +51 -0
  34. package/esm/browser/i18n/messages.js +102 -1
  35. package/esm/browser/i18n/use-t.js +3 -2
  36. package/esm/browser/settings/settings-protocol.d.ts +3 -2
  37. package/esm/browser/settings/settings-protocol.js +4 -3
  38. package/esm/browser/style/pages.d.ts +1 -1
  39. package/esm/browser/style/pages.js +45 -1
  40. package/esm/browser/util/desktop.d.ts +12 -1
  41. package/esm/browser/util/desktop.js +14 -0
  42. package/esm/browser/util/voice.d.ts +20 -1
  43. package/esm/browser/util/voice.js +27 -11
  44. package/esm/browser/workbench-util.d.ts +2 -0
  45. package/esm/browser/workbench-util.js +6 -1
  46. package/lib/browser/assistant/assistant-initiative.js +1 -1
  47. package/lib/browser/components/access-view.js +3 -2
  48. package/lib/browser/components/account-menu.js +2 -2
  49. package/lib/browser/components/auth-view.d.ts +1 -1
  50. package/lib/browser/components/auth-view.js +37 -9
  51. package/lib/browser/components/custom-provider-advanced.d.ts +15 -0
  52. package/lib/browser/components/custom-provider-advanced.js +86 -0
  53. package/lib/browser/components/custom-provider-util.d.ts +39 -0
  54. package/lib/browser/components/custom-provider-util.js +106 -0
  55. package/lib/browser/components/custom-provider-view.d.ts +12 -0
  56. package/lib/browser/components/custom-provider-view.js +217 -0
  57. package/lib/browser/components/host-view.d.ts +1 -1
  58. package/lib/browser/components/settings-choices.js +1 -2
  59. package/lib/browser/components/settings-controls.d.ts +7 -1
  60. package/lib/browser/components/settings-controls.js +9 -0
  61. package/lib/browser/components/settings-parts.js +10 -4
  62. package/lib/browser/components/sign-in-setup.js +3 -1
  63. package/lib/browser/editor/monaco-loader.js +7 -1
  64. package/lib/browser/extension/web-api-contributions.d.ts +3 -0
  65. package/lib/browser/extension/web-extension-api.d.ts +7 -0
  66. package/lib/browser/extension/web-extension-context.d.ts +2 -0
  67. package/lib/browser/extension/web-extension-context.js +19 -0
  68. package/lib/browser/game/game-loader.js +22 -2
  69. package/lib/browser/game/game3d-protocol.d.ts +13 -4
  70. package/lib/browser/i18n/locales.d.ts +56 -1
  71. package/lib/browser/i18n/locales.js +25 -1
  72. package/lib/browser/i18n/messages-ja.d.ts +3 -0
  73. package/lib/browser/i18n/messages-ja.js +975 -0
  74. package/lib/browser/i18n/messages-zh-tw.d.ts +4 -0
  75. package/lib/browser/i18n/messages-zh-tw.js +976 -0
  76. package/lib/browser/i18n/messages.d.ts +51 -0
  77. package/lib/browser/i18n/messages.js +105 -2
  78. package/lib/browser/i18n/use-t.js +2 -1
  79. package/lib/browser/settings/settings-protocol.d.ts +3 -2
  80. package/lib/browser/settings/settings-protocol.js +4 -3
  81. package/lib/browser/style/pages.d.ts +1 -1
  82. package/lib/browser/style/pages.js +45 -1
  83. package/lib/browser/util/desktop.d.ts +12 -1
  84. package/lib/browser/util/desktop.js +14 -0
  85. package/lib/browser/util/voice.d.ts +20 -1
  86. package/lib/browser/util/voice.js +27 -11
  87. package/lib/browser/workbench-util.d.ts +2 -0
  88. package/lib/browser/workbench-util.js +6 -1
  89. package/package.json +7 -7
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Voice = void 0;
4
+ const desktop_1 = require("./desktop");
4
5
  /** Talking to ta and hearing it, with what the browser or the app has: no service, no dependency. */
5
6
  var Voice;
6
7
  (function (Voice) {
@@ -66,10 +67,24 @@ var Voice;
66
67
  const scope = globalThis;
67
68
  return (_a = scope.SpeechRecognition) !== null && _a !== void 0 ? _a : scope.webkitSpeechRecognition;
68
69
  }
69
- /** The recognizer of the Ta app on iOS, Apple's own: WebKit's repeats what it heard and leaves out punctuation. */
70
+ /**
71
+ * Apple's recognizer: of the Ta app on iOS, where WebKit's repeats what it heard and leaves out punctuation, and of
72
+ * Ta Desktop on macOS, where Chrome's, which Electron has, always fails with `network` (only Chrome may use its service).
73
+ */
70
74
  function nativeSpeech() {
71
75
  var _a, _b;
72
- return (_b = (_a = globalThis.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b.taSpeech;
76
+ const ios = (_b = (_a = globalThis.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b.taSpeech;
77
+ if (ios) {
78
+ return {
79
+ post: message => ios.postMessage(message),
80
+ onAnswer: listener => {
81
+ const heard = (event) => listener(event.detail);
82
+ globalThis.addEventListener(Voice.NATIVE_EVENT, heard);
83
+ return () => globalThis.removeEventListener(Voice.NATIVE_EVENT, heard);
84
+ },
85
+ };
86
+ }
87
+ return desktop_1.DesktopUtil.speech();
73
88
  }
74
89
  function canListen() {
75
90
  return nativeSpeech() !== undefined || recognitionClass() !== undefined;
@@ -157,23 +172,21 @@ var Voice;
157
172
  function listenNatively(native, language, onText, onEnd, options) {
158
173
  const id = crypto.randomUUID();
159
174
  let ended = false;
160
- const onEvent = (event) => {
161
- const answer = event.detail;
175
+ const stopHearing = native.onAnswer(answer => {
162
176
  if (ended || (answer === null || answer === void 0 ? void 0 : answer.id) !== id) {
163
177
  return;
164
178
  }
165
179
  if (answer.end) {
166
180
  ended = true;
167
- globalThis.removeEventListener(Voice.NATIVE_EVENT, onEvent);
181
+ stopHearing();
168
182
  onEnd(answer.error === 'no-speech' ? undefined : answer.error);
169
183
  }
170
184
  else if (typeof answer.text === 'string') {
171
185
  onText(answer.text, answer.final === true);
172
186
  }
173
- };
174
- globalThis.addEventListener(Voice.NATIVE_EVENT, onEvent);
175
- native.postMessage({ id, action: 'start', language, continuous: options.continuous === true, hints: hints(options.hints) });
176
- return { stop: () => !ended && native.postMessage({ id, action: 'stop' }) };
187
+ });
188
+ native.post({ id, action: 'start', language, continuous: options.continuous === true, hints: hints(options.hints) });
189
+ return { stop: () => !ended && native.post({ id, action: 'stop' }) };
177
190
  }
178
191
  function canSpeak() {
179
192
  return typeof speechSynthesis !== 'undefined';
@@ -228,9 +241,12 @@ var Voice;
228
241
  return pieces;
229
242
  }
230
243
  Voice.sentences = sentences;
231
- /** The language a text is read in: Chinese for Chinese, whatever the page's. */
244
+ /** The language a text is read in: Japanese for kana, Chinese for other Han (the page's, if Chinese or Japanese), whatever the page's. */
232
245
  function languageOf(text, language) {
233
- return /[\u4e00-\u9fff]/.test(text) ? 'zh-CN' : language;
246
+ if (/[\u3040-\u30ff]/.test(text)) {
247
+ return 'ja-JP';
248
+ }
249
+ return /[\u4e00-\u9fff]/.test(text) && !/^(zh|ja)\b/i.test(language) ? 'zh-CN' : language;
234
250
  }
235
251
  Voice.languageOf = languageOf;
236
252
  /** Toys and the voices of a screen reader of old (Eloquence), which sound as machines. */
@@ -47,6 +47,8 @@ export declare namespace WorkbenchUtil {
47
47
  * the app, or at an address that is not this machine's. A sign-in there cannot come back to it by itself.
48
48
  */
49
49
  function elsewhere(hostId: string | undefined, hostname?: string): boolean;
50
+ /** An address of this machine alone (`localhost`, `127.0.0.1`, `::1`), which no provider of accounts sends a browser back to. */
51
+ function loopback(hostname?: string): boolean;
50
52
  /** In the Ta app on a phone, where no ta serve serves the page: it reaches one through a relay. */
51
53
  function isApp(): boolean;
52
54
  function readPairing(text: string | null): RelayPairing | undefined;
@@ -81,9 +81,14 @@ var WorkbenchUtil;
81
81
  * the app, or at an address that is not this machine's. A sign-in there cannot come back to it by itself.
82
82
  */
83
83
  function elsewhere(hostId, hostname = typeof location === 'undefined' ? '' : location.hostname) {
84
- return isApp() || Boolean(hostId === null || hostId === void 0 ? void 0 : hostId.startsWith('relay ')) || !['localhost', '127.0.0.1', '[::1]', '::1'].includes(hostname);
84
+ return isApp() || Boolean(hostId === null || hostId === void 0 ? void 0 : hostId.startsWith('relay ')) || !loopback(hostname);
85
85
  }
86
86
  WorkbenchUtil.elsewhere = elsewhere;
87
+ /** An address of this machine alone (`localhost`, `127.0.0.1`, `::1`), which no provider of accounts sends a browser back to. */
88
+ function loopback(hostname = typeof location === 'undefined' ? '' : location.hostname) {
89
+ return ['localhost', '127.0.0.1', '[::1]', '::1'].includes(hostname);
90
+ }
91
+ WorkbenchUtil.loopback = loopback;
87
92
  /** In the Ta app on a phone, where no ta serve serves the page: it reaches one through a relay. */
88
93
  function isApp() {
89
94
  var _a, _b;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-web",
3
- "version": "4.14.0",
3
+ "version": "4.15.0",
4
4
  "description": "The web client of ta serve: sessions, streaming messages, tool runs with diffs, and dialogs",
5
5
  "keywords": [
6
6
  "cell-component"
@@ -33,12 +33,12 @@
33
33
  "watch": "tsc -b -w --preserveWatchOutput"
34
34
  },
35
35
  "dependencies": {
36
- "@celljs/core": "4.14.0",
37
- "@celljs/react": "4.14.0",
38
- "@celljs/ta-client": "4.14.0",
39
- "@celljs/ta-protocol": "4.14.0",
40
- "@celljs/ta-relay": "4.14.0",
41
- "@celljs/widget": "4.14.0",
36
+ "@celljs/core": "4.15.0",
37
+ "@celljs/react": "4.15.0",
38
+ "@celljs/ta-client": "4.15.0",
39
+ "@celljs/ta-protocol": "4.15.0",
40
+ "@celljs/ta-relay": "4.15.0",
41
+ "@celljs/widget": "4.15.0",
42
42
  "@types/three": "^0.187.0",
43
43
  "@xterm/addon-fit": "^0.11.0",
44
44
  "@xterm/addon-unicode11": "^0.9.0",