@celljs/ta-web 4.29.0 → 4.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +1 -1
- package/README.md +1 -1
- package/esm/browser/account/account-side.js +1 -1
- package/esm/browser/account/device-account.d.ts +8 -0
- package/esm/browser/account/device-account.js +26 -0
- package/esm/browser/chat/chat-view.js +1 -1
- package/esm/browser/components/account-menu.d.ts +1 -1
- package/esm/browser/components/account-menu.js +8 -4
- package/esm/browser/components/account-view.d.ts +7 -0
- package/esm/browser/components/account-view.js +90 -10
- package/esm/browser/components/app-contexts.js +6 -4
- package/esm/browser/components/app-nav.js +4 -4
- package/esm/browser/components/chat-list-row.js +7 -2
- package/esm/browser/components/chat-tag.d.ts +28 -0
- package/esm/browser/components/chat-tag.js +120 -0
- package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
- package/esm/browser/components/composer-box.js +6 -2
- package/esm/browser/components/custom-host.js +1 -1
- package/esm/browser/components/editor-area.js +1 -1
- package/esm/browser/components/host-view.d.ts +1 -1
- package/esm/browser/components/host-view.js +3 -3
- package/esm/browser/components/launcher-surface.js +1 -1
- package/esm/browser/components/me-rows.d.ts +2 -0
- package/esm/browser/components/me-rows.js +1 -1
- package/esm/browser/components/scan-screen.js +10 -0
- package/esm/browser/components/session-view.js +6 -1
- package/esm/browser/components/tool-view.js +10 -4
- package/esm/browser/components/voice-button.d.ts +7 -0
- package/esm/browser/components/voice-button.js +25 -2
- package/esm/browser/components/voice-talk.js +1 -1
- package/esm/browser/components/workbench-view.js +2 -2
- package/esm/browser/device/back-stack.d.ts +7 -0
- package/esm/browser/device/back-stack.js +13 -1
- package/esm/browser/device/code-scan.d.ts +5 -2
- package/esm/browser/device/code-scan.js +22 -2
- package/esm/browser/device/mini-program.d.ts +69 -0
- package/esm/browser/device/mini-program.js +251 -0
- package/esm/browser/device/sheet-swipe.js +4 -1
- package/esm/browser/device/swipe-util.d.ts +2 -0
- package/esm/browser/device/swipe-util.js +5 -0
- package/esm/browser/extension/extension-view.d.ts +8 -1
- package/esm/browser/extension/extension-view.js +5 -0
- package/esm/browser/extension/icons.js +3 -1
- package/esm/browser/extension/web-api-chats.d.ts +31 -0
- package/esm/browser/extension/web-api-components.d.ts +10 -1
- package/esm/browser/extension/web-api-storage.d.ts +20 -0
- package/esm/browser/extension/web-api-storage.js +3 -0
- package/esm/browser/extension/web-extension-api.d.ts +7 -32
- package/esm/browser/extension/web-extension-context.js +2 -1
- package/esm/browser/extension/web-extension-protocol.d.ts +8 -1
- package/esm/browser/extension/web-extension-protocol.js +1 -0
- package/esm/browser/extension/web-extension-run.d.ts +3 -2
- package/esm/browser/extension/web-extension-run.js +2 -0
- package/esm/browser/extension/web-extensions-running.d.ts +3 -0
- package/esm/browser/extension/web-extensions-running.js +13 -1
- package/esm/browser/extension/web-extensions.js +5 -1
- package/esm/browser/extension/web-home.d.ts +1 -1
- package/esm/browser/extension/web-home.js +7 -2
- package/esm/browser/extension/web-metrics.d.ts +32 -0
- package/esm/browser/extension/web-metrics.js +98 -0
- package/esm/browser/extension/web-pages.js +2 -2
- package/esm/browser/i18n/en/account.d.ts +3 -1
- package/esm/browser/i18n/en/account.js +3 -1
- package/esm/browser/i18n/en/chat.d.ts +2 -0
- package/esm/browser/i18n/en/chat.js +3 -1
- package/esm/browser/i18n/en/common.d.ts +1 -0
- package/esm/browser/i18n/en/common.js +1 -0
- package/esm/browser/i18n/ja/account.js +3 -1
- package/esm/browser/i18n/ja/chat.js +3 -1
- package/esm/browser/i18n/ja/common.js +1 -0
- package/esm/browser/i18n/locales.d.ts +7 -2
- package/esm/browser/i18n/messages.d.ts +6 -1
- package/esm/browser/i18n/zh/account.js +3 -1
- package/esm/browser/i18n/zh/chat.js +3 -1
- package/esm/browser/i18n/zh/common.js +1 -0
- package/esm/browser/i18n/zh-tw/account.js +3 -1
- package/esm/browser/i18n/zh-tw/chat.js +3 -1
- package/esm/browser/i18n/zh-tw/common.js +1 -0
- package/esm/browser/links/links.d.ts +4 -1
- package/esm/browser/links/links.js +10 -1
- package/esm/browser/settings/settings.js +3 -0
- package/esm/browser/style/chat-list.d.ts +1 -1
- package/esm/browser/style/chat-list.js +8 -0
- package/esm/browser/style/dialogs.d.ts +1 -1
- package/esm/browser/style/dialogs.js +0 -1
- package/esm/browser/util/tool.d.ts +6 -2
- package/esm/browser/util/tool.js +28 -5
- package/esm/browser/util/voice.d.ts +9 -0
- package/esm/browser/util/voice.js +20 -0
- package/esm/browser/workbench-util.d.ts +5 -0
- package/esm/browser/workbench-util.js +9 -0
- package/esm/browser/workbench.js +6 -1
- package/lib/browser/account/account-side.js +1 -1
- package/lib/browser/account/device-account.d.ts +8 -0
- package/lib/browser/account/device-account.js +26 -0
- package/lib/browser/chat/chat-view.js +1 -1
- package/lib/browser/components/account-menu.d.ts +1 -1
- package/lib/browser/components/account-menu.js +6 -2
- package/lib/browser/components/account-view.d.ts +7 -0
- package/lib/browser/components/account-view.js +91 -10
- package/lib/browser/components/app-contexts.js +6 -4
- package/lib/browser/components/app-nav.js +4 -4
- package/lib/browser/components/chat-list-row.js +7 -2
- package/lib/browser/components/chat-tag.d.ts +29 -0
- package/lib/browser/components/chat-tag.js +159 -0
- package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
- package/lib/browser/components/composer-box.js +5 -1
- package/lib/browser/components/custom-host.js +1 -1
- package/lib/browser/components/editor-area.js +1 -1
- package/lib/browser/components/host-view.d.ts +1 -1
- package/lib/browser/components/host-view.js +3 -3
- package/lib/browser/components/launcher-surface.js +1 -1
- package/lib/browser/components/me-rows.d.ts +2 -0
- package/lib/browser/components/me-rows.js +1 -1
- package/lib/browser/components/scan-screen.js +10 -0
- package/lib/browser/components/session-view.js +6 -1
- package/lib/browser/components/tool-view.js +10 -4
- package/lib/browser/components/voice-button.d.ts +7 -0
- package/lib/browser/components/voice-button.js +26 -2
- package/lib/browser/components/voice-talk.js +1 -1
- package/lib/browser/components/workbench-view.js +2 -2
- package/lib/browser/device/back-stack.d.ts +7 -0
- package/lib/browser/device/back-stack.js +13 -1
- package/lib/browser/device/code-scan.d.ts +5 -2
- package/lib/browser/device/code-scan.js +22 -2
- package/lib/browser/device/mini-program.d.ts +70 -0
- package/lib/browser/device/mini-program.js +254 -0
- package/lib/browser/device/sheet-swipe.js +4 -1
- package/lib/browser/device/swipe-util.d.ts +2 -0
- package/lib/browser/device/swipe-util.js +5 -0
- package/lib/browser/extension/extension-view.d.ts +8 -1
- package/lib/browser/extension/extension-view.js +6 -1
- package/lib/browser/extension/icons.js +2 -0
- package/lib/browser/extension/web-api-chats.d.ts +31 -0
- package/lib/browser/extension/web-api-components.d.ts +10 -1
- package/lib/browser/extension/web-api-storage.d.ts +21 -0
- package/lib/browser/extension/web-api-storage.js +4 -0
- package/lib/browser/extension/web-extension-api.d.ts +7 -32
- package/lib/browser/extension/web-extension-context.js +2 -1
- package/lib/browser/extension/web-extension-protocol.d.ts +8 -1
- package/lib/browser/extension/web-extension-protocol.js +1 -0
- package/lib/browser/extension/web-extension-run.d.ts +3 -2
- package/lib/browser/extension/web-extension-run.js +2 -0
- package/lib/browser/extension/web-extensions-running.d.ts +3 -0
- package/lib/browser/extension/web-extensions-running.js +13 -1
- package/lib/browser/extension/web-extensions.js +5 -1
- package/lib/browser/extension/web-home.d.ts +1 -1
- package/lib/browser/extension/web-home.js +7 -2
- package/lib/browser/extension/web-metrics.d.ts +33 -0
- package/lib/browser/extension/web-metrics.js +102 -0
- package/lib/browser/extension/web-pages.js +1 -1
- package/lib/browser/i18n/en/account.d.ts +3 -1
- package/lib/browser/i18n/en/account.js +3 -1
- package/lib/browser/i18n/en/chat.d.ts +2 -0
- package/lib/browser/i18n/en/chat.js +3 -1
- package/lib/browser/i18n/en/common.d.ts +1 -0
- package/lib/browser/i18n/en/common.js +1 -0
- package/lib/browser/i18n/ja/account.js +3 -1
- package/lib/browser/i18n/ja/chat.js +3 -1
- package/lib/browser/i18n/ja/common.js +1 -0
- package/lib/browser/i18n/locales.d.ts +7 -2
- package/lib/browser/i18n/messages.d.ts +6 -1
- package/lib/browser/i18n/zh/account.js +3 -1
- package/lib/browser/i18n/zh/chat.js +3 -1
- package/lib/browser/i18n/zh/common.js +1 -0
- package/lib/browser/i18n/zh-tw/account.js +3 -1
- package/lib/browser/i18n/zh-tw/chat.js +3 -1
- package/lib/browser/i18n/zh-tw/common.js +1 -0
- package/lib/browser/links/links.d.ts +4 -1
- package/lib/browser/links/links.js +10 -1
- package/lib/browser/settings/settings.js +3 -0
- package/lib/browser/style/chat-list.d.ts +1 -1
- package/lib/browser/style/chat-list.js +8 -0
- package/lib/browser/style/dialogs.d.ts +1 -1
- package/lib/browser/style/dialogs.js +0 -1
- package/lib/browser/util/tool.d.ts +6 -2
- package/lib/browser/util/tool.js +28 -5
- package/lib/browser/util/voice.d.ts +9 -0
- package/lib/browser/util/voice.js +20 -0
- package/lib/browser/workbench-util.d.ts +5 -0
- package/lib/browser/workbench-util.js +9 -0
- package/lib/browser/workbench.js +6 -1
- package/package.json +10 -10
|
@@ -5,6 +5,7 @@ const messages_1 = require("../i18n/messages");
|
|
|
5
5
|
const share_link_1 = require("../util/share-link");
|
|
6
6
|
const workbench_util_1 = require("../workbench-util");
|
|
7
7
|
const code_vision_1 = require("./code-vision");
|
|
8
|
+
const mini_program_1 = require("./mini-program");
|
|
8
9
|
const scanner_1 = require("./scanner");
|
|
9
10
|
/**
|
|
10
11
|
* Whether the scan screen of the page is open: ScanHost (components/scan-screen.tsx) draws it, CodeScan opens it;
|
|
@@ -88,16 +89,29 @@ class CodeScan {
|
|
|
88
89
|
constructor(host) {
|
|
89
90
|
this.host = host;
|
|
90
91
|
}
|
|
91
|
-
/** Only the Ta app has a camera to scan with. */
|
|
92
|
+
/** Only the Ta app has a camera to scan with, and Ta's mini program of WeChat scans for its page (MiniProgram). */
|
|
92
93
|
static available() {
|
|
94
|
+
return CodeScan.readable() || mini_program_1.MiniProgram.inside();
|
|
95
|
+
}
|
|
96
|
+
/** The page gets the code it scans back (the Ta app): not in the mini program, which opens the page again with it. */
|
|
97
|
+
static readable() {
|
|
93
98
|
return code_vision_1.CodeVision.available() || scanner_1.Scanner.available();
|
|
94
99
|
}
|
|
95
100
|
/**
|
|
96
101
|
* Reads a code for the caller (`ui.scanCode`, adding a computer): the scan screen of the page, which picks from
|
|
97
102
|
* the album too, else the scanner of the app's plugin. Its text, or undefined when the user cancelled; rejects
|
|
98
|
-
* with a ScanError where the plugin could not.
|
|
103
|
+
* with a ScanError where the plugin could not. In the mini program, its scan page, which opens the page again
|
|
104
|
+
* with the code: undefined here.
|
|
99
105
|
*/
|
|
100
106
|
static read(instructions, cancelLabel) {
|
|
107
|
+
if (!CodeScan.readable() && mini_program_1.MiniProgram.inside()) {
|
|
108
|
+
return mini_program_1.MiniProgram.scan().then(went => {
|
|
109
|
+
if (!went) {
|
|
110
|
+
throw new scanner_1.ScanError('failed');
|
|
111
|
+
}
|
|
112
|
+
return undefined;
|
|
113
|
+
});
|
|
114
|
+
}
|
|
101
115
|
return code_vision_1.CodeVision.available() ? ScanScreen.read(instructions) : scanner_1.Scanner.scan(instructions, cancelLabel);
|
|
102
116
|
}
|
|
103
117
|
async scan() {
|
|
@@ -105,6 +119,12 @@ class CodeScan {
|
|
|
105
119
|
ScanScreen.show();
|
|
106
120
|
return;
|
|
107
121
|
}
|
|
122
|
+
if (!scanner_1.Scanner.available() && mini_program_1.MiniProgram.inside()) {
|
|
123
|
+
if (!(await mini_program_1.MiniProgram.scan())) {
|
|
124
|
+
this.host.notices.notify(this.say('ta.scan.failed'), { level: 'error' });
|
|
125
|
+
}
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
108
128
|
let text;
|
|
109
129
|
try {
|
|
110
130
|
text = await scanner_1.Scanner.scan(this.say('ta.scan.instructions'), this.say('ta.cancel'));
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ta's web page in the web-view of Ta's WeChat mini program (apps/ta-weapp, docs/design/ta-weapp.md). The web-view has no
|
|
3
|
+
* camera of its own and hears nothing of its mini program while open: Scan goes to the scan page of the mini program
|
|
4
|
+
* (`wx.scanCode`), which opens the page again with what it read, a computer to pair with as `#pair=`
|
|
5
|
+
* (WorkbenchUtil.fromFragment) and any other code as `#scan=`, opened as a code scanned in the Ta app (CodeScan.open)
|
|
6
|
+
* once the page is connected. Its bar (WeChat's, over the web-view: a web-view has no bar of its own) is coloured as
|
|
7
|
+
* Ta's theme by the look page of the mini program (`paint`). Speech is heard by the voice page of the mini program
|
|
8
|
+
* (WeChat's recognizer, the WechatSI plugin: the web-view's own always refuses), which gives the words back in the
|
|
9
|
+
* fragment of the page (`#say=`), changed alone so that the page stays as it is (`dictate`).
|
|
10
|
+
*/
|
|
11
|
+
export declare namespace MiniProgram {
|
|
12
|
+
/** WeChat's JS-SDK, loaded in the mini program alone: what lets the page go to a page of the mini program. */
|
|
13
|
+
const SDK = "https://res.wx.qq.com/open/js/jweixin-1.6.0.js";
|
|
14
|
+
/** The scan page of apps/ta-weapp. */
|
|
15
|
+
const SCAN_PAGE = "/pages/scan/scan";
|
|
16
|
+
/** The page of apps/ta-weapp that colours the bar of the mini program, keeps the colour and goes back at once. */
|
|
17
|
+
const LOOK_PAGE = "/pages/look/look";
|
|
18
|
+
/** The page of apps/ta-weapp that listens and gives the page what it heard. */
|
|
19
|
+
const VOICE_PAGE = "/pages/voice/voice";
|
|
20
|
+
/** What the mini program says it has (`#can=`), kept: its fragment is read once, and the page may load again without it. */
|
|
21
|
+
const CAN_KEY = "ta.miniProgram.can";
|
|
22
|
+
/** The theme is applied a few times as the page starts (its look of the last time, then the computer's): the bar waits for the last. */
|
|
23
|
+
const PAINT_MS = 400;
|
|
24
|
+
/** Pure: whether a user agent is that of the web-view of a mini program (WeChat says `miniProgram` there, since 7.0). */
|
|
25
|
+
function isAgent(agent: string): boolean;
|
|
26
|
+
/** Whether this page is in the web-view of a mini program. */
|
|
27
|
+
function inside(): boolean;
|
|
28
|
+
/** Pure: the code the scan page of the mini program read, from the fragment it opened the page with. */
|
|
29
|
+
function scanned(fragment: URLSearchParams): string | undefined;
|
|
30
|
+
/** Pure: the colour of the bar the mini program opened the page under (`bar=`, six hex digits), as `#rrggbb`. */
|
|
31
|
+
function barOf(fragment: URLSearchParams): string | undefined;
|
|
32
|
+
/** Pure: the look page that colours the bar `color` (`#rrggbb`), its title and the clock white over a dark one. */
|
|
33
|
+
function lookUrl(color: string, dark: boolean): string;
|
|
34
|
+
/** Pure: what the mini program says it has, from its fragment (`can=voice,…`); undefined when it says nothing. */
|
|
35
|
+
function canOf(fragment: URLSearchParams): string[] | undefined;
|
|
36
|
+
/** Pure: the words its voice page heard (`say=`). */
|
|
37
|
+
function saidOf(fragment: URLSearchParams): string | undefined;
|
|
38
|
+
/** Pure: the language WeChat's recognizer hears, for the page's (Mandarin unless English: it has no other of Ta's). */
|
|
39
|
+
function voiceLanguage(language: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* Keeps the code the page was opened with, in the mini program alone (a link elsewhere opens nothing by itself);
|
|
42
|
+
* whether the fragment said anything to the mini program's page (a code, its bar), to take out of the address.
|
|
43
|
+
*/
|
|
44
|
+
function arrive(fragment: URLSearchParams): boolean;
|
|
45
|
+
/** Whether the mini program hears speech for the page (its voice page). */
|
|
46
|
+
function canDictate(): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Opens the voice page of the mini program, which listens in `language` (the page's) and gives `onWords` what it
|
|
49
|
+
* heard; nothing when the user cancels. False where it could not open.
|
|
50
|
+
*/
|
|
51
|
+
function dictate(language: string, onWords: (words: string) => void): Promise<boolean>;
|
|
52
|
+
/** What was said while the page loaded again, once: to put into the box. */
|
|
53
|
+
function takeSaid(): string | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* The history moved: whether to the words the voice page gave back (`#say=`), which go to what asked for them, the
|
|
56
|
+
* entry of the history they came in taken back (it is no layer of the page's, BackStack). The rest is the page's.
|
|
57
|
+
*/
|
|
58
|
+
function hears(): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* The bar of the mini program in `color` (`#rrggbb`), the colour at the top of Ta's page: WeChat gives a web-view
|
|
61
|
+
* no way to colour it, so the look page does, pushed and gone at once, only when the colour changes (its last is
|
|
62
|
+
* kept by the mini program, which opens the page under it the next time).
|
|
63
|
+
*/
|
|
64
|
+
function paint(color: string, dark: boolean): void;
|
|
65
|
+
/** The code the page was opened with, once: to open once connected. */
|
|
66
|
+
function take(): string | undefined;
|
|
67
|
+
/** Goes to the scan page of the mini program, which opens this page again with the code; false where it could not. */
|
|
68
|
+
function scan(): Promise<boolean>;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=mini-program.d.ts.map
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MiniProgram = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Ta's web page in the web-view of Ta's WeChat mini program (apps/ta-weapp, docs/design/ta-weapp.md). The web-view has no
|
|
6
|
+
* camera of its own and hears nothing of its mini program while open: Scan goes to the scan page of the mini program
|
|
7
|
+
* (`wx.scanCode`), which opens the page again with what it read, a computer to pair with as `#pair=`
|
|
8
|
+
* (WorkbenchUtil.fromFragment) and any other code as `#scan=`, opened as a code scanned in the Ta app (CodeScan.open)
|
|
9
|
+
* once the page is connected. Its bar (WeChat's, over the web-view: a web-view has no bar of its own) is coloured as
|
|
10
|
+
* Ta's theme by the look page of the mini program (`paint`). Speech is heard by the voice page of the mini program
|
|
11
|
+
* (WeChat's recognizer, the WechatSI plugin: the web-view's own always refuses), which gives the words back in the
|
|
12
|
+
* fragment of the page (`#say=`), changed alone so that the page stays as it is (`dictate`).
|
|
13
|
+
*/
|
|
14
|
+
var MiniProgram;
|
|
15
|
+
(function (MiniProgram) {
|
|
16
|
+
/** WeChat's JS-SDK, loaded in the mini program alone: what lets the page go to a page of the mini program. */
|
|
17
|
+
MiniProgram.SDK = 'https://res.wx.qq.com/open/js/jweixin-1.6.0.js';
|
|
18
|
+
/** The scan page of apps/ta-weapp. */
|
|
19
|
+
MiniProgram.SCAN_PAGE = '/pages/scan/scan';
|
|
20
|
+
/** The page of apps/ta-weapp that colours the bar of the mini program, keeps the colour and goes back at once. */
|
|
21
|
+
MiniProgram.LOOK_PAGE = '/pages/look/look';
|
|
22
|
+
/** The page of apps/ta-weapp that listens and gives the page what it heard. */
|
|
23
|
+
MiniProgram.VOICE_PAGE = '/pages/voice/voice';
|
|
24
|
+
/** What the mini program says it has (`#can=`), kept: its fragment is read once, and the page may load again without it. */
|
|
25
|
+
MiniProgram.CAN_KEY = 'ta.miniProgram.can';
|
|
26
|
+
/** The theme is applied a few times as the page starts (its look of the last time, then the computer's): the bar waits for the last. */
|
|
27
|
+
MiniProgram.PAINT_MS = 400;
|
|
28
|
+
/** Pure: whether a user agent is that of the web-view of a mini program (WeChat says `miniProgram` there, since 7.0). */
|
|
29
|
+
function isAgent(agent) {
|
|
30
|
+
return /miniProgram/i.test(agent);
|
|
31
|
+
}
|
|
32
|
+
MiniProgram.isAgent = isAgent;
|
|
33
|
+
/** Whether this page is in the web-view of a mini program. */
|
|
34
|
+
function inside() {
|
|
35
|
+
if (typeof navigator === 'undefined') {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
return isAgent(navigator.userAgent) || globalThis.__wxjs_environment === 'miniprogram';
|
|
39
|
+
}
|
|
40
|
+
MiniProgram.inside = inside;
|
|
41
|
+
/** Pure: the code the scan page of the mini program read, from the fragment it opened the page with. */
|
|
42
|
+
function scanned(fragment) {
|
|
43
|
+
var _a;
|
|
44
|
+
return ((_a = fragment.get('scan')) === null || _a === void 0 ? void 0 : _a.trim()) || undefined;
|
|
45
|
+
}
|
|
46
|
+
MiniProgram.scanned = scanned;
|
|
47
|
+
/** Pure: the colour of the bar the mini program opened the page under (`bar=`, six hex digits), as `#rrggbb`. */
|
|
48
|
+
function barOf(fragment) {
|
|
49
|
+
var _a;
|
|
50
|
+
const bar = (_a = fragment.get('bar')) === null || _a === void 0 ? void 0 : _a.trim().toLowerCase();
|
|
51
|
+
return bar && /^[0-9a-f]{6}$/.test(bar) ? `#${bar}` : undefined;
|
|
52
|
+
}
|
|
53
|
+
MiniProgram.barOf = barOf;
|
|
54
|
+
/** Pure: the look page that colours the bar `color` (`#rrggbb`), its title and the clock white over a dark one. */
|
|
55
|
+
function lookUrl(color, dark) {
|
|
56
|
+
return `${MiniProgram.LOOK_PAGE}?bar=${color.slice(1)}&text=${dark ? 'white' : 'black'}`;
|
|
57
|
+
}
|
|
58
|
+
MiniProgram.lookUrl = lookUrl;
|
|
59
|
+
/** Pure: what the mini program says it has, from its fragment (`can=voice,…`); undefined when it says nothing. */
|
|
60
|
+
function canOf(fragment) {
|
|
61
|
+
const can = fragment.get('can');
|
|
62
|
+
return can === null ? undefined : can.split(',').filter(Boolean);
|
|
63
|
+
}
|
|
64
|
+
MiniProgram.canOf = canOf;
|
|
65
|
+
/** Pure: the words its voice page heard (`say=`). */
|
|
66
|
+
function saidOf(fragment) {
|
|
67
|
+
var _a;
|
|
68
|
+
return ((_a = fragment.get('say')) === null || _a === void 0 ? void 0 : _a.trim()) || undefined;
|
|
69
|
+
}
|
|
70
|
+
MiniProgram.saidOf = saidOf;
|
|
71
|
+
/** Pure: the language WeChat's recognizer hears, for the page's (Mandarin unless English: it has no other of Ta's). */
|
|
72
|
+
function voiceLanguage(language) {
|
|
73
|
+
return /^en\b/i.test(language) ? 'en_US' : 'zh_CN';
|
|
74
|
+
}
|
|
75
|
+
MiniProgram.voiceLanguage = voiceLanguage;
|
|
76
|
+
let arrived;
|
|
77
|
+
let said;
|
|
78
|
+
let hearing;
|
|
79
|
+
/** How long the history was when the voice page opened: the words given back push an entry of their own, or not. */
|
|
80
|
+
let lengthBefore = 0;
|
|
81
|
+
let heardHash;
|
|
82
|
+
/** The colour of the bar now: as the mini program opened the page, then as the page asked. */
|
|
83
|
+
let bar = typeof location === 'undefined' || !inside() ? undefined : barOf(new URLSearchParams(location.hash.slice(1)));
|
|
84
|
+
let painting;
|
|
85
|
+
/**
|
|
86
|
+
* Keeps the code the page was opened with, in the mini program alone (a link elsewhere opens nothing by itself);
|
|
87
|
+
* whether the fragment said anything to the mini program's page (a code, its bar), to take out of the address.
|
|
88
|
+
*/
|
|
89
|
+
function arrive(fragment) {
|
|
90
|
+
var _a;
|
|
91
|
+
if (!inside()) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
const text = scanned(fragment);
|
|
95
|
+
arrived = text !== null && text !== void 0 ? text : arrived;
|
|
96
|
+
const can = canOf(fragment);
|
|
97
|
+
if (can) {
|
|
98
|
+
try {
|
|
99
|
+
localStorage.setItem(MiniProgram.CAN_KEY, can.join(','));
|
|
100
|
+
}
|
|
101
|
+
catch (_b) {
|
|
102
|
+
// Not kept: until the page loads again.
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// The page loaded again with what was said (a web-view that reloads for a fragment): kept for the box.
|
|
106
|
+
said = (_a = saidOf(fragment)) !== null && _a !== void 0 ? _a : said;
|
|
107
|
+
return text !== undefined || barOf(fragment) !== undefined || can !== undefined || fragment.has('say');
|
|
108
|
+
}
|
|
109
|
+
MiniProgram.arrive = arrive;
|
|
110
|
+
/** Whether the mini program hears speech for the page (its voice page). */
|
|
111
|
+
function canDictate() {
|
|
112
|
+
var _a;
|
|
113
|
+
if (!inside()) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
return ((_a = localStorage.getItem(MiniProgram.CAN_KEY)) !== null && _a !== void 0 ? _a : '').split(',').includes('voice');
|
|
118
|
+
}
|
|
119
|
+
catch (_b) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
MiniProgram.canDictate = canDictate;
|
|
124
|
+
/**
|
|
125
|
+
* Opens the voice page of the mini program, which listens in `language` (the page's) and gives `onWords` what it
|
|
126
|
+
* heard; nothing when the user cancels. False where it could not open.
|
|
127
|
+
*/
|
|
128
|
+
async function dictate(language, onWords) {
|
|
129
|
+
const mini = await api();
|
|
130
|
+
if (!mini) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
hearing = onWords;
|
|
134
|
+
lengthBefore = history.length;
|
|
135
|
+
return new Promise(resolve => mini.navigateTo({ url: `${MiniProgram.VOICE_PAGE}?lang=${voiceLanguage(language)}`, success: () => resolve(true), fail: () => resolve(false) }));
|
|
136
|
+
}
|
|
137
|
+
MiniProgram.dictate = dictate;
|
|
138
|
+
/** What was said while the page loaded again, once: to put into the box. */
|
|
139
|
+
function takeSaid() {
|
|
140
|
+
const words = said;
|
|
141
|
+
said = undefined;
|
|
142
|
+
return words;
|
|
143
|
+
}
|
|
144
|
+
MiniProgram.takeSaid = takeSaid;
|
|
145
|
+
/**
|
|
146
|
+
* The history moved: whether to the words the voice page gave back (`#say=`), which go to what asked for them, the
|
|
147
|
+
* entry of the history they came in taken back (it is no layer of the page's, BackStack). The rest is the page's.
|
|
148
|
+
*/
|
|
149
|
+
function hears() {
|
|
150
|
+
if (!inside()) {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
const words = saidOf(new URLSearchParams(location.hash.slice(1)));
|
|
154
|
+
if (words === undefined) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
// Heard once, by popstate or hashchange (both come, and the history goes back later).
|
|
158
|
+
if (location.hash === heardHash) {
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
heardHash = location.hash;
|
|
162
|
+
if (history.length > lengthBefore && lengthBefore > 0) {
|
|
163
|
+
history.back();
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
history.replaceState(history.state, '', location.pathname + location.search);
|
|
167
|
+
}
|
|
168
|
+
lengthBefore = 0;
|
|
169
|
+
const to = hearing;
|
|
170
|
+
hearing = undefined;
|
|
171
|
+
if (to) {
|
|
172
|
+
to(words);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
said = words;
|
|
176
|
+
}
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
MiniProgram.hears = hears;
|
|
180
|
+
/**
|
|
181
|
+
* The bar of the mini program in `color` (`#rrggbb`), the colour at the top of Ta's page: WeChat gives a web-view
|
|
182
|
+
* no way to colour it, so the look page does, pushed and gone at once, only when the colour changes (its last is
|
|
183
|
+
* kept by the mini program, which opens the page under it the next time).
|
|
184
|
+
*/
|
|
185
|
+
function paint(color, dark) {
|
|
186
|
+
if (!inside()) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
clearTimeout(painting);
|
|
190
|
+
painting = setTimeout(() => {
|
|
191
|
+
if (color === bar) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
// Behind the scan page, or WeChat in the background: once the page shows again.
|
|
195
|
+
if (document.visibilityState !== 'visible') {
|
|
196
|
+
document.addEventListener('visibilitychange', () => paint(color, dark), { once: true });
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const before = bar;
|
|
200
|
+
bar = color;
|
|
201
|
+
void api().then(mini => {
|
|
202
|
+
if (!mini) {
|
|
203
|
+
bar = before;
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
mini.navigateTo({
|
|
207
|
+
url: lookUrl(color, dark),
|
|
208
|
+
// A mini program of before the look page: as it was.
|
|
209
|
+
fail: () => {
|
|
210
|
+
bar = before;
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
}, MiniProgram.PAINT_MS);
|
|
215
|
+
}
|
|
216
|
+
MiniProgram.paint = paint;
|
|
217
|
+
/** The code the page was opened with, once: to open once connected. */
|
|
218
|
+
function take() {
|
|
219
|
+
const text = arrived;
|
|
220
|
+
arrived = undefined;
|
|
221
|
+
return text;
|
|
222
|
+
}
|
|
223
|
+
MiniProgram.take = take;
|
|
224
|
+
let sdk;
|
|
225
|
+
function api() {
|
|
226
|
+
const found = () => { var _a; return (_a = globalThis.wx) === null || _a === void 0 ? void 0 : _a.miniProgram; };
|
|
227
|
+
sdk !== null && sdk !== void 0 ? sdk : (sdk = new Promise(resolve => {
|
|
228
|
+
if (found()) {
|
|
229
|
+
resolve(found());
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
const script = document.createElement('script');
|
|
233
|
+
script.src = MiniProgram.SDK;
|
|
234
|
+
script.onload = () => resolve(found());
|
|
235
|
+
script.onerror = () => {
|
|
236
|
+
// Tried again on the next scan: the network may be back.
|
|
237
|
+
sdk = undefined;
|
|
238
|
+
resolve(undefined);
|
|
239
|
+
};
|
|
240
|
+
document.head.append(script);
|
|
241
|
+
}));
|
|
242
|
+
return sdk;
|
|
243
|
+
}
|
|
244
|
+
/** Goes to the scan page of the mini program, which opens this page again with the code; false where it could not. */
|
|
245
|
+
async function scan() {
|
|
246
|
+
const mini = await api();
|
|
247
|
+
if (!mini) {
|
|
248
|
+
return false;
|
|
249
|
+
}
|
|
250
|
+
return new Promise(resolve => mini.navigateTo({ url: MiniProgram.SCAN_PAGE, success: () => resolve(true), fail: () => resolve(false) }));
|
|
251
|
+
}
|
|
252
|
+
MiniProgram.scan = scan;
|
|
253
|
+
})(MiniProgram || (exports.MiniProgram = MiniProgram = {}));
|
|
254
|
+
//# sourceMappingURL=mini-program.js.map
|
|
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.useSheetSwipe = useSheetSwipe;
|
|
37
37
|
const React = __importStar(require("react"));
|
|
38
|
+
const back_stack_1 = require("./back-stack");
|
|
38
39
|
const own_gestures_1 = require("./own-gestures");
|
|
39
40
|
const swipe_finger_1 = require("./swipe-finger");
|
|
40
41
|
const swipe_settle_1 = require("./swipe-settle");
|
|
@@ -257,7 +258,9 @@ function useSheetSwipe(options) {
|
|
|
257
258
|
return;
|
|
258
259
|
}
|
|
259
260
|
const at = point(event, touch);
|
|
260
|
-
|
|
261
|
+
// The web view's own swipe back, which would move the page with the sheet: left to it (BackLayers.webViewSwipesBack).
|
|
262
|
+
const theirs = back_stack_1.Back.size > 0 && swipe_util_1.SwipeUtil.fromBackEdge(sheet, at, current.open) && back_stack_1.BackLayers.webViewSwipesBack();
|
|
263
|
+
if (!theirs && swipe_util_1.SwipeUtil.starts(sheet, at, current.open, window.innerWidth) && finger.follow(event, from.doc)) {
|
|
261
264
|
start = at;
|
|
262
265
|
velocity.start(at);
|
|
263
266
|
}
|
|
@@ -31,6 +31,8 @@ export declare namespace SwipeUtil {
|
|
|
31
31
|
const VELOCITY_MS = 80;
|
|
32
32
|
/** 1 when the finger moves right to bring the sheet out, -1 when left. */
|
|
33
33
|
function outward(sheet: SheetSwipe): 1 | -1;
|
|
34
|
+
/** Whether a touch at `start` moving the sheet would be a swipe to the right from the left edge: the back of iOS. */
|
|
35
|
+
function fromBackEdge(sheet: SheetSwipe, start: TouchPoint, open: boolean): boolean;
|
|
34
36
|
/** Whether a touch at `start` may move the sheet, on a screen `width` wide. */
|
|
35
37
|
function starts(sheet: SheetSwipe, start: TouchPoint, open: boolean, width: number): boolean;
|
|
36
38
|
/** Whether the move so far is the sheet's (more sideways than down, the right way); undefined until it is told. */
|
|
@@ -28,6 +28,11 @@ var SwipeUtil;
|
|
|
28
28
|
function way(sheet, open) {
|
|
29
29
|
return open ? -outward(sheet) : outward(sheet);
|
|
30
30
|
}
|
|
31
|
+
/** Whether a touch at `start` moving the sheet would be a swipe to the right from the left edge: the back of iOS. */
|
|
32
|
+
function fromBackEdge(sheet, start, open) {
|
|
33
|
+
return start.x <= SwipeUtil.EDGE_PX && way(sheet, open) > 0;
|
|
34
|
+
}
|
|
35
|
+
SwipeUtil.fromBackEdge = fromBackEdge;
|
|
31
36
|
/** Whether a touch at `start` may move the sheet, on a screen `width` wide. */
|
|
32
37
|
function starts(sheet, start, open, width) {
|
|
33
38
|
const from = open ? sheet.closesFrom : sheet.opensFrom;
|
|
@@ -12,8 +12,13 @@ export declare const ChatIcons: React.Context<{
|
|
|
12
12
|
entries: WebExtensionsState['chatIcons'];
|
|
13
13
|
version: number;
|
|
14
14
|
}>;
|
|
15
|
+
/** The tags web extensions give conversations, and a count of their changes (ChatTagUtil). */
|
|
16
|
+
export declare const ChatTags: React.Context<{
|
|
17
|
+
entries: WebExtensionsState['chatTags'];
|
|
18
|
+
version: number;
|
|
19
|
+
}>;
|
|
15
20
|
/** The avatars that web extensions registered for the sessions of their groups. */
|
|
16
|
-
export declare const SessionAvatars: React.Context<Record<string, React.ComponentType<import("./web-
|
|
21
|
+
export declare const SessionAvatars: React.Context<Record<string, React.ComponentType<import("./web-api-components").WebAvatarProps>>>;
|
|
17
22
|
/** The group of the conversations calls are answered in (WebExtensionsState.callGroup): shown as the record of a call. */
|
|
18
23
|
export declare const CallGroup: React.Context<string | undefined>;
|
|
19
24
|
/** What web extensions add to the menu of a conversation of a list (WebExtensionAPI.registerSessionMenu). */
|
|
@@ -22,6 +27,8 @@ export declare const SessionMenus: React.Context<import("./web-api-menus").WebSe
|
|
|
22
27
|
export declare const LoadedExtensions: React.Context<import("./web-extension-protocol").LoadedWebExtension[]>;
|
|
23
28
|
interface BoundaryProps {
|
|
24
29
|
name: string;
|
|
30
|
+
/** The extension that draws it, by id or name: what threw is counted for its package (WebMetrics). */
|
|
31
|
+
extension?: string;
|
|
25
32
|
/** A new value (a new component) tries again after a failure. */
|
|
26
33
|
resetKey?: unknown;
|
|
27
34
|
/** In place of the error, where it would not fit. */
|
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.ExtensionBoundary = exports.LoadedExtensions = exports.SessionMenus = exports.CallGroup = exports.SessionAvatars = exports.ChatIcons = exports.ToolRenderers = exports.MessageRenderers = void 0;
|
|
36
|
+
exports.ExtensionBoundary = exports.LoadedExtensions = exports.SessionMenus = exports.CallGroup = exports.SessionAvatars = exports.ChatTags = exports.ChatIcons = exports.ToolRenderers = exports.MessageRenderers = void 0;
|
|
37
37
|
exports.ExtensionPart = ExtensionPart;
|
|
38
38
|
exports.CustomMessage = CustomMessage;
|
|
39
39
|
const ta_protocol_1 = require("@celljs/ta-protocol");
|
|
@@ -42,12 +42,15 @@ const callout_1 = require("../components/callout");
|
|
|
42
42
|
const markdown_1 = require("../components/markdown");
|
|
43
43
|
const use_t_1 = require("../i18n/use-t");
|
|
44
44
|
const message_1 = require("../util/message");
|
|
45
|
+
const web_metrics_1 = require("./web-metrics");
|
|
45
46
|
/** The renderers of custom messages that web extensions registered. */
|
|
46
47
|
exports.MessageRenderers = React.createContext({});
|
|
47
48
|
/** How the calls of the tools of web extensions read (WebExtensionAPI.registerToolRenderer). */
|
|
48
49
|
exports.ToolRenderers = React.createContext([]);
|
|
49
50
|
/** The icons web extensions give conversations of theirs, and a count of their changes (ChatIconUtil). */
|
|
50
51
|
exports.ChatIcons = React.createContext({ entries: [], version: 0 });
|
|
52
|
+
/** The tags web extensions give conversations, and a count of their changes (ChatTagUtil). */
|
|
53
|
+
exports.ChatTags = React.createContext({ entries: [], version: 0 });
|
|
51
54
|
/** The avatars that web extensions registered for the sessions of their groups. */
|
|
52
55
|
exports.SessionAvatars = React.createContext({});
|
|
53
56
|
/** The group of the conversations calls are answered in (WebExtensionsState.callGroup): shown as the record of a call. */
|
|
@@ -66,6 +69,8 @@ class ExtensionBoundary extends React.Component {
|
|
|
66
69
|
return { error };
|
|
67
70
|
}
|
|
68
71
|
componentDidCatch(error) {
|
|
72
|
+
var _a;
|
|
73
|
+
(_a = web_metrics_1.WebMetrics.current) === null || _a === void 0 ? void 0 : _a.renderError(this.props.extension);
|
|
69
74
|
console.error(`${this.props.name} failed:`, error);
|
|
70
75
|
}
|
|
71
76
|
componentDidUpdate(previous) {
|
|
@@ -64,6 +64,7 @@ exports.WEB_ICONS = Object.freeze({
|
|
|
64
64
|
FlaskConical: lucide_react_1.FlaskConical,
|
|
65
65
|
Folder: lucide_react_1.Folder,
|
|
66
66
|
FolderInput: lucide_react_1.FolderInput,
|
|
67
|
+
FolderLock: lucide_react_1.FolderLock,
|
|
67
68
|
FolderOpen: lucide_react_1.FolderOpen,
|
|
68
69
|
FolderPlus: lucide_react_1.FolderPlus,
|
|
69
70
|
FolderSearch: lucide_react_1.FolderSearch,
|
|
@@ -113,6 +114,7 @@ exports.WEB_ICONS = Object.freeze({
|
|
|
113
114
|
MonitorSmartphone: lucide_react_1.MonitorSmartphone,
|
|
114
115
|
MousePointer2: lucide_react_1.MousePointer2,
|
|
115
116
|
MousePointerClick: lucide_react_1.MousePointerClick,
|
|
117
|
+
Navigation: lucide_react_1.Navigation,
|
|
116
118
|
Package: lucide_react_1.Package,
|
|
117
119
|
PackageOpen: lucide_react_1.PackageOpen,
|
|
118
120
|
Paperclip: lucide_react_1.Paperclip,
|
|
@@ -38,6 +38,37 @@ export interface WebChatIcon {
|
|
|
38
38
|
*/
|
|
39
39
|
folder?: string;
|
|
40
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* A small label a conversation has after its name, in the lists and on top of it (WebExtensionAPI.registerChatTag):
|
|
43
|
+
* what it is, at a glance (Work, of a directory marked so). A few words.
|
|
44
|
+
*/
|
|
45
|
+
export interface WebChatTag {
|
|
46
|
+
text: string;
|
|
47
|
+
/** Its color: `blue`, `gray` (with a lock), `green`; default `gray`. */
|
|
48
|
+
tone?: 'blue' | 'gray' | 'green';
|
|
49
|
+
/** Under a pointer: what it means. */
|
|
50
|
+
title?: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The tags an extension gives conversations (WebExtensionAPI.registerChatTag). Asked for each row as it is drawn:
|
|
54
|
+
* answer at once, from what the extension holds.
|
|
55
|
+
*/
|
|
56
|
+
export interface WebChatTagSource {
|
|
57
|
+
tag(chat: WebChat): WebChatTag | undefined;
|
|
58
|
+
/** What `tag` answers changed: the lists draw their rows again. */
|
|
59
|
+
subscribe?(listener: () => void): () => void;
|
|
60
|
+
/** The tag on top of a conversation was tapped: show what it means and how to change it. */
|
|
61
|
+
open?(chat: WebChat): void;
|
|
62
|
+
}
|
|
63
|
+
/** What a web extension adds to the conversations of the lists (WebExtensionAPI extends it). */
|
|
64
|
+
export interface WebChatTagsAPI {
|
|
65
|
+
/**
|
|
66
|
+
* A small label for conversations, after their name in the lists and on top of a conversation: what they are at a
|
|
67
|
+
* glance (Work, of a directory marked so). The first extension that gives one for a conversation is drawn. Newer
|
|
68
|
+
* than some Ta apps: `pi.registerChatTag?.(…)`.
|
|
69
|
+
*/
|
|
70
|
+
registerChatTag(source: WebChatTagSource): void;
|
|
71
|
+
}
|
|
41
72
|
/**
|
|
42
73
|
* The conversations an extension gives an icon of their own (WebExtensionAPI.registerChatIcon): a brief it writes,
|
|
43
74
|
* the questions it asks. Asked for each row as it is drawn: answer at once, from what the extension holds.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
/** Part of the web extension API (web-extension-api.ts, which exports it all): the props of the components of `ui
|
|
1
|
+
/** Part of the web extension API (web-extension-api.ts, which exports it all): the props of the components of `ui`, and of the avatar an extension gives (registerAvatar). */
|
|
2
|
+
import type { TaSessionInfo } from '@celljs/ta-protocol';
|
|
2
3
|
import type * as React from 'react';
|
|
4
|
+
import type { Mood } from '../avatar/dino-avatar';
|
|
3
5
|
import type { TextSelection, WebIcon, WebTask } from './web-extension-api';
|
|
4
6
|
export interface WebModelPickerProps {
|
|
5
7
|
/** The directory whose settings give the models and the default; default: that of ta serve. */
|
|
@@ -404,4 +406,11 @@ export interface WebConversationViewProps {
|
|
|
404
406
|
/** The pictures of the workspace its replies show, as URLs by the path written in them. */
|
|
405
407
|
files?: Readonly<Record<string, string>>;
|
|
406
408
|
}
|
|
409
|
+
export interface WebAvatarProps {
|
|
410
|
+
session: TaSessionInfo;
|
|
411
|
+
/** What the agent does at the time, as ta's avatar shows it. */
|
|
412
|
+
mood: Mood;
|
|
413
|
+
/** In pixels. */
|
|
414
|
+
size: number;
|
|
415
|
+
}
|
|
407
416
|
//# sourceMappingURL=web-api-components.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Part of the web extension API (web-extension-api.ts, which exports it all): the data a package keeps on the server. */
|
|
2
|
+
export interface WebStorage {
|
|
3
|
+
get<T = unknown>(key: string): Promise<T | undefined>;
|
|
4
|
+
/** `null` removes the key. */
|
|
5
|
+
set(key: string, value: unknown): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Keys that changed, by this page, another page, or the package on the server; a few times a second
|
|
8
|
+
* at most, with the keys of that time together. It hears them once the page read one of its keys.
|
|
9
|
+
* Stops when the extension unloads.
|
|
10
|
+
*/
|
|
11
|
+
onChange(listener: (keys: string[]) => void): () => void;
|
|
12
|
+
}
|
|
13
|
+
export interface WebPackageStorage extends WebStorage {
|
|
14
|
+
/**
|
|
15
|
+
* The values of the package for one directory (`ui.useCwd()`), with keys of their own: what belongs
|
|
16
|
+
* to it, as the folders open in an explorer, found again in any browser that shows that directory.
|
|
17
|
+
* The same directory on another execution environment is another one.
|
|
18
|
+
*/
|
|
19
|
+
directory(cwd: string): WebStorage;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=web-api-storage.d.ts.map
|
|
@@ -6,13 +6,14 @@ import type { GameProps } from '../game/game-protocol';
|
|
|
6
6
|
import type { Game3DProps } from '../game/game3d-protocol';
|
|
7
7
|
import type { ScreenPartSpec, TaScreen } from '../screen/screen-protocol';
|
|
8
8
|
import type { Language, Theme } from '../settings/settings-protocol';
|
|
9
|
-
import type { CodeEditorProps, DiffEditorProps, WebChatImagesProps, WebComposerProps, WebConversationViewProps, WebDialogProps, WebEmptyProps, WebFaceProps, WebFolderPickerProps, WebFullScreenProps, WebGroupFaceProps, WebHoldToTalkProps, WebImageViewerProps, WebLoadingProps, WebModelPickerProps, WebPictureCardsProps, WebPictureProps, WebSelectBarProps, WebSelectCheckProps, WebShareSheetProps, WebStackProps, WebSwipeRowProps, WebSwitchProps, WebTaskIconProps, WebVoice } from './web-api-components';
|
|
10
|
-
import type { WebAsk, WebCallsAPI, WebChatIconSource, WebCodeRendererOptions, WebCodeRendererProps, WebComposerAddon, WebCustomMessage, WebHomeSource, WebInitiative, WebMenuItem, WebOpener, WebOpenerOptions, WebRoomAddon, WebRoomAddonEntry, WebSearchSource, WebSessionNotice, WebSettingsSection, WebShareTarget, WebTaskEntry, WebTaskRemoval, WebTaskSource, WebTool, WebToolRendererResolver, WebView, WebViewInfo, WidgetOptions } from './web-api-contributions';
|
|
9
|
+
import type { CodeEditorProps, DiffEditorProps, WebAvatarProps, WebChatImagesProps, WebComposerProps, WebConversationViewProps, WebDialogProps, WebEmptyProps, WebFaceProps, WebFolderPickerProps, WebFullScreenProps, WebGroupFaceProps, WebHoldToTalkProps, WebImageViewerProps, WebLoadingProps, WebModelPickerProps, WebPictureCardsProps, WebPictureProps, WebSelectBarProps, WebSelectCheckProps, WebShareSheetProps, WebStackProps, WebSwipeRowProps, WebSwitchProps, WebTaskIconProps, WebVoice } from './web-api-components';
|
|
10
|
+
import type { WebAsk, WebCallsAPI, WebChatIconSource, WebChatTagsAPI, WebCodeRendererOptions, WebCodeRendererProps, WebComposerAddon, WebCustomMessage, WebHomeSource, WebInitiative, WebMenuItem, WebOpener, WebOpenerOptions, WebRoomAddon, WebRoomAddonEntry, WebSearchSource, WebSessionNotice, WebSettingsSection, WebShareTarget, WebTaskEntry, WebTaskRemoval, WebTaskSource, WebTool, WebToolRendererResolver, WebView, WebViewInfo, WidgetOptions } from './web-api-contributions';
|
|
11
11
|
import type { WebDesktop, WebDeviceUI, WebFileDrag } from './web-api-desktop';
|
|
12
12
|
import type { WebEditorsUI } from './web-api-editors';
|
|
13
13
|
import type { WebHomeUI, WebPartnersAPI, WebPartnersUI } from './web-api-home';
|
|
14
14
|
import type { WebFileRef, WebMenus } from './web-api-menus';
|
|
15
15
|
import type { WebServices } from './web-api-services';
|
|
16
|
+
import type { WebPackageStorage } from './web-api-storage';
|
|
16
17
|
import type { WebTerminal, WebTerminalOptions } from './web-api-terminal';
|
|
17
18
|
import type { WebPageInfo } from './web-pages';
|
|
18
19
|
export type { Mood } from '../avatar/dino-avatar';
|
|
@@ -28,14 +29,14 @@ export type * from './web-api-editors';
|
|
|
28
29
|
export type * from './web-api-home';
|
|
29
30
|
export type * from './web-api-menus';
|
|
30
31
|
export type * from './web-api-services';
|
|
32
|
+
export type * from './web-api-storage';
|
|
31
33
|
export type * from './web-api-terminal';
|
|
32
34
|
export type { WebPageInfo, WebPageState } from './web-pages';
|
|
33
35
|
/**
|
|
34
|
-
* What a web extension gets: the web client's side of pi's extension API,
|
|
35
|
-
*
|
|
36
|
-
* package (see TaWebExtensionInfo); it exports a {@link WebExtensionFactory}.
|
|
36
|
+
* What a web extension gets: the web client's side of pi's extension API, its names where they mean the same. A web
|
|
37
|
+
* extension is one ES module without imports, the `web` part of a pi package (TaWebExtensionInfo): a {@link WebExtensionFactory}.
|
|
37
38
|
*/
|
|
38
|
-
export interface WebExtensionAPI extends WebServices, WebPartnersAPI, WebMenus, WebCallsAPI {
|
|
39
|
+
export interface WebExtensionAPI extends WebServices, WebPartnersAPI, WebMenus, WebCallsAPI, WebChatTagsAPI {
|
|
39
40
|
/** The React of the page: an extension brings no React of its own. */
|
|
40
41
|
readonly React: typeof React;
|
|
41
42
|
readonly ui: WebExtensionUI;
|
|
@@ -174,32 +175,6 @@ export interface WebSessionOpening {
|
|
|
174
175
|
/** Its session file, when known: what the device kept of the conversation shows while it opens, and while the computer cannot be reached. */
|
|
175
176
|
sessionFile?: string;
|
|
176
177
|
}
|
|
177
|
-
export interface WebStorage {
|
|
178
|
-
get<T = unknown>(key: string): Promise<T | undefined>;
|
|
179
|
-
/** `null` removes the key. */
|
|
180
|
-
set(key: string, value: unknown): Promise<void>;
|
|
181
|
-
/**
|
|
182
|
-
* Keys that changed, by this page, another page, or the package on the server; a few times a second
|
|
183
|
-
* at most, with the keys of that time together. It hears them once the page read one of its keys.
|
|
184
|
-
* Stops when the extension unloads.
|
|
185
|
-
*/
|
|
186
|
-
onChange(listener: (keys: string[]) => void): () => void;
|
|
187
|
-
}
|
|
188
|
-
export interface WebPackageStorage extends WebStorage {
|
|
189
|
-
/**
|
|
190
|
-
* The values of the package for one directory (`ui.useCwd()`), with keys of their own: what belongs
|
|
191
|
-
* to it, as the folders open in an explorer, found again in any browser that shows that directory.
|
|
192
|
-
* The same directory on another execution environment is another one.
|
|
193
|
-
*/
|
|
194
|
-
directory(cwd: string): WebStorage;
|
|
195
|
-
}
|
|
196
|
-
export interface WebAvatarProps {
|
|
197
|
-
session: TaSessionInfo;
|
|
198
|
-
/** What the agent does at the time, as ta's avatar shows it. */
|
|
199
|
-
mood: Mood;
|
|
200
|
-
/** In pixels. */
|
|
201
|
-
size: number;
|
|
202
|
-
}
|
|
203
178
|
/** An icon, drawn at `size` pixels in `currentColor`. */
|
|
204
179
|
export type WebIcon = React.ComponentType<{
|
|
205
180
|
size?: number | string;
|