@hex4c59/pi-ext-qoder 0.1.0 → 0.1.1
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/CHANGELOG.md +6 -0
- package/LICENSE +21 -21
- package/README.md +152 -152
- package/lib/usage-ui.ts +353 -354
- package/package.json +57 -53
- package/vendor/PROVENANCE.md +42 -42
- package/vendor/auth_glue.mjs +0 -0
- package/vendor/auth_wasm.wasm +0 -0
- package/lib/relay-registry.ts +0 -34
- package/lib/report-overlay.ts +0 -175
package/package.json
CHANGED
|
@@ -1,53 +1,57 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@hex4c59/pi-ext-qoder",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Qoder international provider for pi: device login, signed streaming, live models and credits",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "https://github.com/Hex4C59/my-pi-extensions",
|
|
9
|
-
"directory": "qoder"
|
|
10
|
-
},
|
|
11
|
-
"type": "module",
|
|
12
|
-
"publishConfig": { "registry": "https://registry.npmjs.org/", "access": "public" },
|
|
13
|
-
"engines": {
|
|
14
|
-
"node": ">=22.19.0"
|
|
15
|
-
},
|
|
16
|
-
"peerDependencies": {
|
|
17
|
-
"@earendil-works/pi-coding-agent": "*",
|
|
18
|
-
"@earendil-works/pi-ai": "*",
|
|
19
|
-
"@earendil-works/pi-tui": "*"
|
|
20
|
-
},
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"@
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"vendor/
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@hex4c59/pi-ext-qoder",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Qoder international provider for pi: device login, signed streaming, live models and credits",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/Hex4C59/my-pi-extensions",
|
|
9
|
+
"directory": "qoder"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"publishConfig": { "registry": "https://registry.npmjs.org/", "access": "public" },
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=22.19.0"
|
|
15
|
+
},
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"@earendil-works/pi-coding-agent": "*",
|
|
18
|
+
"@earendil-works/pi-ai": "*",
|
|
19
|
+
"@earendil-works/pi-tui": "*"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@hex4c59/pi-ext-ui-kit": "^0.1.0"
|
|
23
|
+
},
|
|
24
|
+
"pi": {
|
|
25
|
+
"extensions": [
|
|
26
|
+
"./extensions/qoder.ts"
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@earendil-works/pi-coding-agent": "1.5.0",
|
|
31
|
+
"@earendil-works/pi-ai": "1.5.0",
|
|
32
|
+
"@earendil-works/pi-tui": "1.5.0",
|
|
33
|
+
"@types/node": "^22.19.0",
|
|
34
|
+
"typescript": "^6.0.3"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"typecheck": "tsc --noEmit",
|
|
38
|
+
"test": "node tests/offline.mjs",
|
|
39
|
+
"test:process": "node tests/process.mjs",
|
|
40
|
+
"test:tui": "node tests/tui.mjs",
|
|
41
|
+
"prepare:signing": "node scripts/prepare-signing.mjs"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"extensions",
|
|
45
|
+
"lib",
|
|
46
|
+
"scripts",
|
|
47
|
+
"vendor/PROVENANCE.md",
|
|
48
|
+
"vendor/LICENSE.qoder",
|
|
49
|
+
"vendor/auth_glue.mjs",
|
|
50
|
+
"vendor/auth_wasm.wasm",
|
|
51
|
+
"THIRD_PARTY.md",
|
|
52
|
+
"CHANGELOG.md",
|
|
53
|
+
"LICENSE",
|
|
54
|
+
"NOTICE",
|
|
55
|
+
"README.md"
|
|
56
|
+
]
|
|
57
|
+
}
|
package/vendor/PROVENANCE.md
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
# 国际版签名资源来源
|
|
2
|
-
|
|
3
|
-
`auth_wasm.wasm` 与 `auth_glue.mjs` 从官方 npm 包 **`@qoder-ai/qodercli@1.1.85`** 的 `package/bundle/qoder-worker-runtime.mjs` 静态提取。提取不启动 CLI、不访问登录态、不发送请求。未采用社区 provider 的签名实现。
|
|
4
|
-
|
|
5
|
-
| 输入或产物 | 大小 | SHA-256 |
|
|
6
|
-
| --- | --- | --- |
|
|
7
|
-
| 官方 `qoder-worker-runtime.mjs` | 35,359,286 B | `ca132c21eb2eec93d41138a6911009ef1f8a1e92b3cb372793e36c98fa1ea688` |
|
|
8
|
-
| `auth_wasm.wasm` | 320,863 B | `c7a14b11d6c23b94ac39f6868ebd3dd6a70492efe87c864c33857adadb9f0951` |
|
|
9
|
-
| `auth_glue.mjs` | 17,957 B | `7aff75d30beffeda2861d4161d8a750d7d42b8e6deeb9745786d3796375e9511` |
|
|
10
|
-
|
|
11
|
-
官方包地址:`https://registry.npmjs.org/@qoder-ai/qodercli/-/qodercli-1.1.85.tgz`。
|
|
12
|
-
|
|
13
|
-
下载包的 npm integrity 为:
|
|
14
|
-
|
|
15
|
-
```text
|
|
16
|
-
sha512-Dzzt1g/LaajyK0tjvg3bsFve/x4VfRyWYpa4RKUENi5/ojnKTqdOsWvN+T9btbrsVqb+bu6lH80UlpgqVYG7/w==
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
`auth_wasm.wasm` 保持官方原始字节;glue 保留官方绑定代码,仅增加 ESM 导出、打包器的惰性初始化/导出辅助函数和 Node `require` 兼容。使用 `QoderContext`、`generate_runtime_auth_fields` 和 `decrypt_server_response`,不调用模块中的 HTTPDNS 或其他外部服务功能。
|
|
20
|
-
|
|
21
|
-
## 分发包内容
|
|
22
|
-
|
|
23
|
-
npm 包的 `files` 白名单包含本目录的 `auth_wasm.wasm` 与 `auth_glue.mjs`,安装后即可生成签名。运行时按 `lib/qoder-core.mjs` 的 `AUTH_WASM_SHA256` 重新校验 WASM 字节,不匹配则拒绝加载。
|
|
24
|
-
|
|
25
|
-
官方包附带的原始许可证保存在 [LICENSE.qoder](LICENSE.qoder)。它是上游 npm 包随附的许可证原文,不构成本项目对嵌入资源独立分发权的额外判断;使用者需同时遵守上游许可证。
|
|
26
|
-
|
|
27
|
-
## 重新提取
|
|
28
|
-
|
|
29
|
-
新工作区需要重建这两个文件时,从 npm 官方 registry 下载固定版本并解压,压缩包及解压目录放在仓库外:
|
|
30
|
-
|
|
31
|
-
```powershell
|
|
32
|
-
npm pack @qoder-ai/qodercli@1.1.85 --ignore-scripts --pack-destination <temporary-directory>
|
|
33
|
-
tar -xzf <temporary-directory>/qoder-ai-qodercli-1.1.85.tgz -C <temporary-directory>
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
然后在 `qoder/` 中运行:
|
|
37
|
-
|
|
38
|
-
```powershell
|
|
39
|
-
npm run prepare:signing -- --bundle <temporary-directory>/package/bundle/qoder-worker-runtime.mjs
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
脚本先核对整个官方 bundle 的 SHA-256,再核对内嵌 WASM 的 SHA-256;版本或字节不匹配就终止。输出资源存入本目录。升级时先复核官方协议、绑定边界和哈希,再更新脚本与本清单,不能仅改哈希绕过检查。来源及本地改动说明同时见 [THIRD_PARTY.md](../THIRD_PARTY.md)。
|
|
1
|
+
# 国际版签名资源来源
|
|
2
|
+
|
|
3
|
+
`auth_wasm.wasm` 与 `auth_glue.mjs` 从官方 npm 包 **`@qoder-ai/qodercli@1.1.85`** 的 `package/bundle/qoder-worker-runtime.mjs` 静态提取。提取不启动 CLI、不访问登录态、不发送请求。未采用社区 provider 的签名实现。
|
|
4
|
+
|
|
5
|
+
| 输入或产物 | 大小 | SHA-256 |
|
|
6
|
+
| --- | --- | --- |
|
|
7
|
+
| 官方 `qoder-worker-runtime.mjs` | 35,359,286 B | `ca132c21eb2eec93d41138a6911009ef1f8a1e92b3cb372793e36c98fa1ea688` |
|
|
8
|
+
| `auth_wasm.wasm` | 320,863 B | `c7a14b11d6c23b94ac39f6868ebd3dd6a70492efe87c864c33857adadb9f0951` |
|
|
9
|
+
| `auth_glue.mjs` | 17,957 B | `7aff75d30beffeda2861d4161d8a750d7d42b8e6deeb9745786d3796375e9511` |
|
|
10
|
+
|
|
11
|
+
官方包地址:`https://registry.npmjs.org/@qoder-ai/qodercli/-/qodercli-1.1.85.tgz`。
|
|
12
|
+
|
|
13
|
+
下载包的 npm integrity 为:
|
|
14
|
+
|
|
15
|
+
```text
|
|
16
|
+
sha512-Dzzt1g/LaajyK0tjvg3bsFve/x4VfRyWYpa4RKUENi5/ojnKTqdOsWvN+T9btbrsVqb+bu6lH80UlpgqVYG7/w==
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`auth_wasm.wasm` 保持官方原始字节;glue 保留官方绑定代码,仅增加 ESM 导出、打包器的惰性初始化/导出辅助函数和 Node `require` 兼容。使用 `QoderContext`、`generate_runtime_auth_fields` 和 `decrypt_server_response`,不调用模块中的 HTTPDNS 或其他外部服务功能。
|
|
20
|
+
|
|
21
|
+
## 分发包内容
|
|
22
|
+
|
|
23
|
+
npm 包的 `files` 白名单包含本目录的 `auth_wasm.wasm` 与 `auth_glue.mjs`,安装后即可生成签名。运行时按 `lib/qoder-core.mjs` 的 `AUTH_WASM_SHA256` 重新校验 WASM 字节,不匹配则拒绝加载。
|
|
24
|
+
|
|
25
|
+
官方包附带的原始许可证保存在 [LICENSE.qoder](LICENSE.qoder)。它是上游 npm 包随附的许可证原文,不构成本项目对嵌入资源独立分发权的额外判断;使用者需同时遵守上游许可证。
|
|
26
|
+
|
|
27
|
+
## 重新提取
|
|
28
|
+
|
|
29
|
+
新工作区需要重建这两个文件时,从 npm 官方 registry 下载固定版本并解压,压缩包及解压目录放在仓库外:
|
|
30
|
+
|
|
31
|
+
```powershell
|
|
32
|
+
npm pack @qoder-ai/qodercli@1.1.85 --ignore-scripts --pack-destination <temporary-directory>
|
|
33
|
+
tar -xzf <temporary-directory>/qoder-ai-qodercli-1.1.85.tgz -C <temporary-directory>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
然后在 `qoder/` 中运行:
|
|
37
|
+
|
|
38
|
+
```powershell
|
|
39
|
+
npm run prepare:signing -- --bundle <temporary-directory>/package/bundle/qoder-worker-runtime.mjs
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
脚本先核对整个官方 bundle 的 SHA-256,再核对内嵌 WASM 的 SHA-256;版本或字节不匹配就终止。输出资源存入本目录。升级时先复核官方协议、绑定边界和哈希,再更新脚本与本清单,不能仅改哈希绕过检查。来源及本地改动说明同时见 [THIRD_PARTY.md](../THIRD_PARTY.md)。
|
package/vendor/auth_glue.mjs
CHANGED
|
File without changes
|
package/vendor/auth_wasm.wasm
CHANGED
|
File without changes
|
package/lib/relay-registry.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { ExtensionContext } from '@earendil-works/pi-coding-agent'
|
|
2
|
-
|
|
3
|
-
export interface RelayAction {
|
|
4
|
-
value: string
|
|
5
|
-
label: string
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface RelayService {
|
|
9
|
-
label: string
|
|
10
|
-
actions: readonly RelayAction[]
|
|
11
|
-
run: (ctx: ExtensionContext, section: string) => Promise<void>
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const REGISTRY_KEY = Symbol.for('hex4c59.pi-ext.relay.registry')
|
|
15
|
-
type RegistryHolder = Record<symbol, Map<string, RelayService> | undefined>
|
|
16
|
-
|
|
17
|
-
/** 同一 Pi 进程内的轻量注册表;只在已加载的扩展之间使用。 */
|
|
18
|
-
export function relayServices(): Map<string, RelayService> {
|
|
19
|
-
const holder = globalThis as unknown as RegistryHolder
|
|
20
|
-
return (holder[REGISTRY_KEY] ??= new Map())
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function registerRelayService(
|
|
24
|
-
id: string,
|
|
25
|
-
label: string,
|
|
26
|
-
actions: readonly RelayAction[],
|
|
27
|
-
run: RelayService['run'],
|
|
28
|
-
): void {
|
|
29
|
-
relayServices().set(id, { label, actions, run })
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function unregisterRelayService(id: string): void {
|
|
33
|
-
relayServices().delete(id)
|
|
34
|
-
}
|
package/lib/report-overlay.ts
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { DynamicBorder, type ExtensionContext, type Theme } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import { Container, matchesKey, SelectList, Spacer, Text, truncateToWidth, type Component, type OverlayHandle, type TUI } from "@earendil-works/pi-tui";
|
|
3
|
-
|
|
4
|
-
type LineStyler = (lines: readonly string[], theme: Theme) => string[];
|
|
5
|
-
|
|
6
|
-
class ReportOverlay implements Component {
|
|
7
|
-
private offset = 0;
|
|
8
|
-
private readonly tui: TUI;
|
|
9
|
-
private readonly theme: Theme;
|
|
10
|
-
private readonly lines: readonly string[];
|
|
11
|
-
private readonly done: (result: void) => void;
|
|
12
|
-
private readonly style: LineStyler | undefined;
|
|
13
|
-
private removeInputListener: (() => void) | undefined;
|
|
14
|
-
|
|
15
|
-
constructor(
|
|
16
|
-
tui: TUI,
|
|
17
|
-
theme: Theme,
|
|
18
|
-
lines: readonly string[],
|
|
19
|
-
done: (result: void) => void,
|
|
20
|
-
style?: LineStyler,
|
|
21
|
-
) {
|
|
22
|
-
this.tui = tui;
|
|
23
|
-
this.theme = theme;
|
|
24
|
-
this.lines = lines;
|
|
25
|
-
this.done = done;
|
|
26
|
-
this.style = style;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
private get maxVisible(): number {
|
|
30
|
-
const rows = Math.max(12, this.tui.terminal.rows);
|
|
31
|
-
return Math.max(3, Math.floor(rows * 0.8) - 4);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
render(width: number): string[] {
|
|
35
|
-
if (width < 3) return [];
|
|
36
|
-
const innerWidth = width - 2;
|
|
37
|
-
const border = (text: string) => this.theme.fg("border", text);
|
|
38
|
-
const fit = (text: string) => truncateToWidth(text, innerWidth, "…", true);
|
|
39
|
-
const styled = this.style ? this.style(this.lines, this.theme) : [...this.lines];
|
|
40
|
-
const limit = Math.max(0, styled.length - this.maxVisible);
|
|
41
|
-
this.offset = Math.min(this.offset, limit);
|
|
42
|
-
const visible = styled.slice(this.offset, this.offset + this.maxVisible);
|
|
43
|
-
const hint = styled.length > visible.length
|
|
44
|
-
? `${this.offset + 1}-${this.offset + visible.length}/${styled.length} · PgUp/PgDn scroll · Esc close`
|
|
45
|
-
: "Esc close";
|
|
46
|
-
|
|
47
|
-
return [
|
|
48
|
-
border(`╭${"─".repeat(innerWidth)}╮`),
|
|
49
|
-
...visible.map((line) => border("│") + fit(` ${line}`) + border("│")),
|
|
50
|
-
border("│") + fit(this.theme.fg("dim", ` ${hint}`)) + border("│"),
|
|
51
|
-
border(`╰${"─".repeat(innerWidth)}╯`),
|
|
52
|
-
];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
handleInput(data: string): void {
|
|
56
|
-
this.handleReportInput(data);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
private handleReportInput(data: string): boolean {
|
|
60
|
-
if (matchesKey(data, "escape")) {
|
|
61
|
-
this.done(undefined);
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
const limit = Math.max(0, this.lines.length - this.maxVisible);
|
|
65
|
-
const nextOffset = matchesKey(data, "pageUp")
|
|
66
|
-
? Math.max(0, this.offset - this.maxVisible)
|
|
67
|
-
: matchesKey(data, "pageDown")
|
|
68
|
-
? Math.min(limit, this.offset + this.maxVisible)
|
|
69
|
-
: this.offset;
|
|
70
|
-
if (nextOffset === this.offset) return false;
|
|
71
|
-
this.offset = nextOffset;
|
|
72
|
-
this.tui.requestRender();
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
setOverlayHandle(handle: OverlayHandle): void {
|
|
77
|
-
this.removeInputListener = this.tui.addInputListener((data) => {
|
|
78
|
-
if (handle.isFocused()) handle.unfocus();
|
|
79
|
-
return this.handleReportInput(data) ? { consume: true } : undefined;
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
dispose(): void {
|
|
84
|
-
this.removeInputListener?.();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
invalidate(): void {}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/** 一次性报告只做临时 overlay,不追加会话条目。非 TUI 模式退化为通知。 */
|
|
91
|
-
export async function showReport(
|
|
92
|
-
ctx: ExtensionContext,
|
|
93
|
-
title: string,
|
|
94
|
-
lines: readonly string[],
|
|
95
|
-
style?: LineStyler,
|
|
96
|
-
): Promise<void> {
|
|
97
|
-
if (!ctx.hasUI) return;
|
|
98
|
-
if (ctx.mode !== "tui") {
|
|
99
|
-
ctx.ui.notify(`${title}\n${lines.join("\n")}`, "info");
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
let report: ReportOverlay | undefined;
|
|
103
|
-
await ctx.ui.custom<void>((tui, theme, _keybindings, done) => {
|
|
104
|
-
report = new ReportOverlay(tui, theme, lines, done, style);
|
|
105
|
-
return report;
|
|
106
|
-
}, {
|
|
107
|
-
overlay: true,
|
|
108
|
-
overlayOptions: {
|
|
109
|
-
anchor: "bottom-center",
|
|
110
|
-
width: "100%",
|
|
111
|
-
minWidth: 40,
|
|
112
|
-
maxHeight: "80%",
|
|
113
|
-
// 与输入区同宽,只留出编辑器上沿和底栏的高度。
|
|
114
|
-
margin: { bottom: 6 },
|
|
115
|
-
nonCapturing: true,
|
|
116
|
-
},
|
|
117
|
-
onHandle: (handle) => report?.setOverlayHandle(handle),
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/** 无标题菜单;只保留边框、选项和底部按键提示,不占标题行。 */
|
|
122
|
-
export async function showMenu(
|
|
123
|
-
ctx: ExtensionContext,
|
|
124
|
-
actions: readonly { value: string; label: string }[],
|
|
125
|
-
signal?: AbortSignal,
|
|
126
|
-
): Promise<string | undefined> {
|
|
127
|
-
if (!ctx.hasUI || ctx.mode !== "tui" || signal?.aborted) return undefined;
|
|
128
|
-
return await ctx.ui.custom<string | undefined>((tui, theme, _keybindings, done) => {
|
|
129
|
-
const items = actions.map((action) => ({ value: action.value, label: action.label, description: undefined }));
|
|
130
|
-
const list = new SelectList(items, Math.min(items.length, 10), {
|
|
131
|
-
selectedPrefix: (text) => theme.fg("accent", text),
|
|
132
|
-
selectedText: (text) => theme.fg("accent", text),
|
|
133
|
-
description: (text) => theme.fg("muted", text),
|
|
134
|
-
scrollInfo: (text) => theme.fg("dim", text),
|
|
135
|
-
noMatch: (text) => theme.fg("warning", text),
|
|
136
|
-
});
|
|
137
|
-
const container = new Container();
|
|
138
|
-
container.addChild(new DynamicBorder((text) => theme.fg("border", text)));
|
|
139
|
-
container.addChild(new Spacer(1));
|
|
140
|
-
container.addChild(list);
|
|
141
|
-
container.addChild(new Spacer(1));
|
|
142
|
-
container.addChild(new Text(theme.fg("dim", "↑↓ navigate enter select escape/ctrl+c cancel"), 1, 0));
|
|
143
|
-
container.addChild(new DynamicBorder((text) => theme.fg("border", text)));
|
|
144
|
-
|
|
145
|
-
const finish = (value: string | undefined) => {
|
|
146
|
-
signal?.removeEventListener("abort", onAbort);
|
|
147
|
-
done(value);
|
|
148
|
-
};
|
|
149
|
-
const onAbort = () => finish(undefined);
|
|
150
|
-
signal?.addEventListener("abort", onAbort, { once: true });
|
|
151
|
-
list.onSelect = (item) => finish(item.value);
|
|
152
|
-
list.onCancel = () => finish(undefined);
|
|
153
|
-
|
|
154
|
-
return {
|
|
155
|
-
capturesViewportInput: list.capturesViewportInput,
|
|
156
|
-
render(width: number) {
|
|
157
|
-
return container.render(width).map((line) => truncateToWidth(line, width, "…"));
|
|
158
|
-
},
|
|
159
|
-
invalidate() {
|
|
160
|
-
container.invalidate();
|
|
161
|
-
},
|
|
162
|
-
handleInput(data: string) {
|
|
163
|
-
if (signal?.aborted) {
|
|
164
|
-
finish(undefined);
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
list.handleInput(data);
|
|
168
|
-
tui.requestRender();
|
|
169
|
-
},
|
|
170
|
-
dispose() {
|
|
171
|
-
signal?.removeEventListener("abort", onAbort);
|
|
172
|
-
},
|
|
173
|
-
};
|
|
174
|
-
});
|
|
175
|
-
}
|