@sfmc-bds/cli 0.2.0-beta.5 → 0.2.0-beta.7
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/dist/argv-parse.d.ts +13 -0
- package/dist/argv-parse.d.ts.map +1 -0
- package/dist/argv-parse.js +32 -0
- package/dist/argv-parse.js.map +7 -0
- package/dist/cli-gate.d.ts +11 -0
- package/dist/cli-gate.d.ts.map +1 -0
- package/dist/cli-gate.js +48 -0
- package/dist/cli-gate.js.map +7 -0
- package/dist/cmd-remote.d.ts +13 -0
- package/dist/cmd-remote.d.ts.map +1 -0
- package/dist/cmd-remote.js +38 -0
- package/dist/cmd-remote.js.map +7 -0
- package/dist/command-palette.d.ts +61 -0
- package/dist/command-palette.d.ts.map +1 -0
- package/dist/command-palette.js +352 -0
- package/dist/command-palette.js.map +7 -0
- package/dist/command-surface.d.ts +95 -0
- package/dist/command-surface.d.ts.map +1 -0
- package/dist/command-surface.js +324 -0
- package/dist/command-surface.js.map +7 -0
- package/dist/commands-reload.js +2 -2
- package/dist/commands-reload.js.map +2 -2
- package/dist/commands.d.ts +1 -1
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +79 -17
- package/dist/commands.js.map +2 -2
- package/dist/debug-command.d.ts +5 -0
- package/dist/debug-command.d.ts.map +1 -0
- package/dist/debug-command.js +118 -0
- package/dist/debug-command.js.map +7 -0
- package/dist/help-text.d.ts +3 -0
- package/dist/help-text.d.ts.map +1 -0
- package/dist/help-text.js +164 -0
- package/dist/help-text.js.map +7 -0
- package/dist/i18n/locales/en.d.ts +93 -68
- package/dist/i18n/locales/en.d.ts.map +1 -1
- package/dist/i18n/locales/en.js +97 -69
- package/dist/i18n/locales/en.js.map +2 -2
- package/dist/i18n/locales/zh-CN.d.ts.map +1 -1
- package/dist/i18n/locales/zh-CN.js +140 -106
- package/dist/i18n/locales/zh-CN.js.map +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +2 -2
- package/dist/logs.d.ts +16 -1
- package/dist/logs.d.ts.map +1 -1
- package/dist/logs.js +80 -11
- package/dist/logs.js.map +2 -2
- package/dist/main.js +58 -44
- package/dist/main.js.map +2 -2
- package/dist/module-commands.d.ts +25 -35
- package/dist/module-commands.d.ts.map +1 -1
- package/dist/module-commands.js +107 -65
- package/dist/module-commands.js.map +2 -2
- package/dist/module-pack-build.d.ts +10 -0
- package/dist/module-pack-build.d.ts.map +1 -0
- package/dist/module-pack-build.js +430 -0
- package/dist/module-pack-build.js.map +7 -0
- package/dist/module-publish.d.ts +69 -0
- package/dist/module-publish.d.ts.map +1 -0
- package/dist/module-publish.js +478 -0
- package/dist/module-publish.js.map +7 -0
- package/dist/module-watch.d.ts +32 -0
- package/dist/module-watch.d.ts.map +1 -0
- package/dist/module-watch.js +171 -0
- package/dist/module-watch.js.map +7 -0
- package/dist/pack-lifecycle.d.ts +1 -1
- package/dist/pack-lifecycle.d.ts.map +1 -1
- package/dist/pack-lifecycle.js +3 -3
- package/dist/pack-lifecycle.js.map +2 -2
- package/dist/pack-update/index.d.ts +18 -0
- package/dist/pack-update/index.d.ts.map +1 -0
- package/dist/pack-update/index.js +113 -0
- package/dist/pack-update/index.js.map +7 -0
- package/dist/registry.d.ts +6 -3
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +15 -3
- package/dist/registry.js.map +2 -2
- package/dist/remote-agent.d.ts.map +1 -1
- package/dist/remote-agent.js +7 -5
- package/dist/remote-agent.js.map +2 -2
- package/dist/repl-windows/format-display.d.ts +10 -0
- package/dist/repl-windows/format-display.d.ts.map +1 -0
- package/dist/repl-windows/format-display.js +57 -0
- package/dist/repl-windows/format-display.js.map +7 -0
- package/dist/repl-windows/host.d.ts +60 -0
- package/dist/repl-windows/host.d.ts.map +1 -0
- package/dist/repl-windows/host.js +179 -0
- package/dist/repl-windows/host.js.map +7 -0
- package/dist/repl-windows/index.d.ts +9 -0
- package/dist/repl-windows/index.d.ts.map +1 -0
- package/dist/repl-windows/index.js +13 -0
- package/dist/repl-windows/index.js.map +7 -0
- package/dist/repl-windows/logs-filter-window.d.ts +15 -0
- package/dist/repl-windows/logs-filter-window.d.ts.map +1 -0
- package/dist/repl-windows/logs-filter-window.js +77 -0
- package/dist/repl-windows/logs-filter-window.js.map +7 -0
- package/dist/repl-windows/service-window.d.ts +4 -0
- package/dist/repl-windows/service-window.d.ts.map +1 -0
- package/dist/repl-windows/service-window.js +28 -0
- package/dist/repl-windows/service-window.js.map +7 -0
- package/dist/repl-windows/types.d.ts +56 -0
- package/dist/repl-windows/types.d.ts.map +1 -0
- package/dist/repl-windows/types.js +1 -0
- package/dist/repl-windows/types.js.map +7 -0
- package/dist/repl.d.ts +7 -8
- package/dist/repl.d.ts.map +1 -1
- package/dist/repl.js +707 -417
- package/dist/repl.js.map +3 -3
- package/dist/runtime.d.ts +2 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +4 -0
- package/dist/runtime.js.map +2 -2
- package/dist/send-target.d.ts +11 -0
- package/dist/send-target.d.ts.map +1 -0
- package/dist/send-target.js +38 -0
- package/dist/send-target.js.map +7 -0
- package/dist/services.d.ts +21 -1
- package/dist/services.d.ts.map +1 -1
- package/dist/services.js +146 -7
- package/dist/services.js.map +2 -2
- package/dist/theme.js +1 -1
- package/dist/theme.js.map +2 -2
- package/dist/wizard.d.ts.map +1 -1
- package/dist/wizard.js +11 -9
- package/dist/wizard.js.map +2 -2
- package/dist/world-packs.d.ts.map +1 -1
- package/dist/world-packs.js +6 -3
- package/dist/world-packs.js.map +2 -2
- package/package.json +5 -5
- package/dist/module-wizard.d.ts +0 -14
- package/dist/module-wizard.d.ts.map +0 -1
- package/dist/module-wizard.js +0 -313
- package/dist/module-wizard.js.map +0 -7
- package/dist/pack-update/bindings.d.ts +0 -12
- package/dist/pack-update/bindings.d.ts.map +0 -1
- package/dist/pack-update/bindings.js +0 -64
- package/dist/pack-update/bindings.js.map +0 -7
- package/dist/pack-update/config.d.ts +0 -22
- package/dist/pack-update/config.d.ts.map +0 -1
- package/dist/pack-update/config.js +0 -141
- package/dist/pack-update/config.js.map +0 -7
- package/dist/pack-update/providers/curseforge.d.ts +0 -23
- package/dist/pack-update/providers/curseforge.d.ts.map +0 -1
- package/dist/pack-update/providers/curseforge.js +0 -229
- package/dist/pack-update/providers/curseforge.js.map +0 -7
- package/dist/pack-update/providers/index.d.ts +0 -16
- package/dist/pack-update/providers/index.d.ts.map +0 -1
- package/dist/pack-update/providers/index.js +0 -37
- package/dist/pack-update/providers/index.js.map +0 -7
- package/dist/pack-update/service.d.ts +0 -21
- package/dist/pack-update/service.d.ts.map +0 -1
- package/dist/pack-update/service.js +0 -572
- package/dist/pack-update/service.js.map +0 -7
- package/dist/pack-update/types.d.ts +0 -126
- package/dist/pack-update/types.d.ts.map +0 -1
- package/dist/pack-update/types.js +0 -8
- package/dist/pack-update/types.js.map +0 -7
- package/dist/pack-update/version-policy.d.ts +0 -81
- package/dist/pack-update/version-policy.d.ts.map +0 -1
- package/dist/pack-update/version-policy.js +0 -210
- package/dist/pack-update/version-policy.js.map +0 -7
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { wrapLogLine } from "../logs.js";
|
|
2
|
+
class WindowHost {
|
|
3
|
+
windows = /* @__PURE__ */ new Map();
|
|
4
|
+
/** 窗口 id → 已渲染(已 wrap)的行;切回时直接 dump,无需重拉源 */
|
|
5
|
+
buffers = /* @__PURE__ */ new Map();
|
|
6
|
+
/** 服务窗循环顺序(仅活跃服务) */
|
|
7
|
+
serviceOrder = [];
|
|
8
|
+
activeId = null;
|
|
9
|
+
previousId = null;
|
|
10
|
+
writeLog;
|
|
11
|
+
onChromeChange;
|
|
12
|
+
constructor(opts) {
|
|
13
|
+
this.writeLog = opts.writeLog;
|
|
14
|
+
this.onChromeChange = opts.onChromeChange;
|
|
15
|
+
}
|
|
16
|
+
register(win) {
|
|
17
|
+
this.windows.set(win.id, win);
|
|
18
|
+
}
|
|
19
|
+
unregister(id) {
|
|
20
|
+
if (this.activeId === id) {
|
|
21
|
+
this.activeId = this.previousId;
|
|
22
|
+
this.previousId = null;
|
|
23
|
+
}
|
|
24
|
+
if (this.previousId === id) this.previousId = null;
|
|
25
|
+
this.windows.delete(id);
|
|
26
|
+
this.buffers.delete(id);
|
|
27
|
+
this.serviceOrder = this.serviceOrder.filter((x) => x !== id);
|
|
28
|
+
}
|
|
29
|
+
has(id) {
|
|
30
|
+
return this.windows.has(id);
|
|
31
|
+
}
|
|
32
|
+
getActive() {
|
|
33
|
+
return this.activeId ? this.windows.get(this.activeId) : void 0;
|
|
34
|
+
}
|
|
35
|
+
getActiveId() {
|
|
36
|
+
return this.activeId;
|
|
37
|
+
}
|
|
38
|
+
getChrome() {
|
|
39
|
+
const w = this.getActive();
|
|
40
|
+
if (!w) {
|
|
41
|
+
return { showsInput: true, footerShortcuts: "", title: "" };
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
showsInput: w.showsInput,
|
|
45
|
+
footerShortcuts: w.footerShortcuts,
|
|
46
|
+
title: w.title
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** 是否已有展示缓存(有则切回时勿再 seed) */
|
|
50
|
+
hasBuffer(id) {
|
|
51
|
+
return this.buffers.has(id);
|
|
52
|
+
}
|
|
53
|
+
getBuffer(id) {
|
|
54
|
+
return this.buffers.get(id) ?? [];
|
|
55
|
+
}
|
|
56
|
+
/** 首次进入时写入种子行 */
|
|
57
|
+
setBuffer(id, lines) {
|
|
58
|
+
this.buffers.set(id, [...lines]);
|
|
59
|
+
}
|
|
60
|
+
invalidateBuffer(id) {
|
|
61
|
+
this.buffers.delete(id);
|
|
62
|
+
}
|
|
63
|
+
appendToBuffer(id, wrappedLine) {
|
|
64
|
+
let buf = this.buffers.get(id);
|
|
65
|
+
if (!buf) {
|
|
66
|
+
buf = [];
|
|
67
|
+
this.buffers.set(id, buf);
|
|
68
|
+
}
|
|
69
|
+
buf.push(wrappedLine);
|
|
70
|
+
}
|
|
71
|
+
/** 按活跃服务同步 ServiceWindow id 列表(id = svc:<name>) */
|
|
72
|
+
setServiceOrder(ids) {
|
|
73
|
+
this.serviceOrder = [...ids];
|
|
74
|
+
const stale = [...this.windows.keys()].filter((id) => id.startsWith("svc:") && !ids.includes(id));
|
|
75
|
+
for (const id of stale) {
|
|
76
|
+
this.windows.delete(id);
|
|
77
|
+
this.buffers.delete(id);
|
|
78
|
+
if (this.activeId === id) this.activeId = null;
|
|
79
|
+
if (this.previousId === id) this.previousId = null;
|
|
80
|
+
}
|
|
81
|
+
if (this.activeId?.startsWith("svc:") && !ids.includes(this.activeId)) {
|
|
82
|
+
this.activeId = null;
|
|
83
|
+
}
|
|
84
|
+
if (!this.activeId && ids.length > 0) {
|
|
85
|
+
this.open(ids[0]);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
open(id) {
|
|
89
|
+
const next = this.windows.get(id);
|
|
90
|
+
if (!next) return false;
|
|
91
|
+
if (this.activeId === id) {
|
|
92
|
+
next.onActivate?.();
|
|
93
|
+
this.onChromeChange?.();
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
const prev = this.getActive();
|
|
97
|
+
prev?.onDeactivate?.();
|
|
98
|
+
if (this.activeId && this.activeId !== id) {
|
|
99
|
+
this.previousId = this.activeId;
|
|
100
|
+
}
|
|
101
|
+
this.activeId = id;
|
|
102
|
+
next.onActivate?.();
|
|
103
|
+
this.onChromeChange?.();
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
back() {
|
|
107
|
+
const fallback = (this.previousId && this.windows.has(this.previousId) ? this.previousId : null) ?? this.serviceOrder.find((id) => this.windows.has(id)) ?? null;
|
|
108
|
+
this.previousId = null;
|
|
109
|
+
if (!fallback) {
|
|
110
|
+
this.activeId = null;
|
|
111
|
+
this.onChromeChange?.();
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
return this.open(fallback);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* 在服务窗之间循环;返回新激活窗的 serviceName(供同步发送目标)。
|
|
118
|
+
* 若当前在非服务窗,先回到服务环。
|
|
119
|
+
*/
|
|
120
|
+
cycleServiceWindows() {
|
|
121
|
+
if (this.serviceOrder.length === 0) return null;
|
|
122
|
+
const cur = this.activeId;
|
|
123
|
+
const idx = cur ? this.serviceOrder.indexOf(cur) : -1;
|
|
124
|
+
if (idx < 0) {
|
|
125
|
+
this.open(this.serviceOrder[0]);
|
|
126
|
+
} else {
|
|
127
|
+
const next = this.serviceOrder[(idx + 1) % this.serviceOrder.length];
|
|
128
|
+
this.open(next);
|
|
129
|
+
}
|
|
130
|
+
return this.getActive()?.serviceName ?? null;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* 新日志:写入所有已 seed 缓存且 accept 的窗口;仅活动窗刷到 TTY。
|
|
134
|
+
* 活动窗尚未 seed:只刷 TTY(随后 showActiveWindow 会 seed 含历史的缓存)。
|
|
135
|
+
*/
|
|
136
|
+
routeLog(log) {
|
|
137
|
+
for (const [id, w] of this.windows) {
|
|
138
|
+
if (!w.acceptLog(log)) continue;
|
|
139
|
+
if (!this.buffers.has(id)) {
|
|
140
|
+
if (id === this.activeId) {
|
|
141
|
+
const { text: text2, indent: indent2 } = w.formatLogLine(log);
|
|
142
|
+
this.writeLog(wrapLogLine(text2, indent2));
|
|
143
|
+
}
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
const { text, indent } = w.formatLogLine(log);
|
|
147
|
+
const wrapped = wrapLogLine(text, indent);
|
|
148
|
+
this.appendToBuffer(id, wrapped);
|
|
149
|
+
if (id === this.activeId) this.writeLog(wrapped);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/** 返回活动窗对日志的展示结果(含 acceptLog) */
|
|
153
|
+
formatActiveLog(log) {
|
|
154
|
+
const w = this.getActive();
|
|
155
|
+
if (!w || !w.acceptLog(log)) return null;
|
|
156
|
+
return w.formatLogLine(log);
|
|
157
|
+
}
|
|
158
|
+
onKey(ev) {
|
|
159
|
+
const w = this.getActive();
|
|
160
|
+
if (!w?.onKey) return { action: "none" };
|
|
161
|
+
const r = w.onKey(ev);
|
|
162
|
+
if (r.action === "back") {
|
|
163
|
+
this.back();
|
|
164
|
+
return { action: "redraw" };
|
|
165
|
+
}
|
|
166
|
+
return r;
|
|
167
|
+
}
|
|
168
|
+
isLogsActive() {
|
|
169
|
+
return this.activeId === "logs";
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function serviceWindowId(name) {
|
|
173
|
+
return `svc:${name}`;
|
|
174
|
+
}
|
|
175
|
+
export {
|
|
176
|
+
WindowHost,
|
|
177
|
+
serviceWindowId
|
|
178
|
+
};
|
|
179
|
+
//# sourceMappingURL=host.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/repl-windows/host.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * repl-windows/host.ts \u2014 \u7A97\u53E3\u6CE8\u518C\u4E0E\u5207\u6362\uFF08\u4E0D\u5199\u4E1A\u52A1\uFF0C\u53EA\u8C03\u5EA6 ReplWindow\uFF09\n *\n * \u6BCF\u6247\u7A97\u7EF4\u62A4\u5DF2\u6E32\u67D3\u884C\u7F13\u5B58\uFF1A\u5207\u8D70\u6E05\u5C4F\uFF0C\u5207\u56DE\u76F4\u63A5\u6062\u590D\uFF1B\u540E\u53F0\u4ECD\u628A\u5339\u914D\u65E5\u5FD7\u5199\u5165\u5BF9\u5E94\u7F13\u5B58\u3002\n */\nimport { wrapLogLine, type UnifiedLog } from \"../logs.js\";\nimport type { ServiceName } from \"../services.js\";\nimport type { ReplWindow, WindowChrome, WindowKeyEvent, WindowKeyResult } from \"./types.js\";\n\nexport type HostWriteLog = (wrappedLine: string) => void;\n\nexport class WindowHost {\n private readonly windows = new Map<string, ReplWindow>();\n /** \u7A97\u53E3 id \u2192 \u5DF2\u6E32\u67D3\uFF08\u5DF2 wrap\uFF09\u7684\u884C\uFF1B\u5207\u56DE\u65F6\u76F4\u63A5 dump\uFF0C\u65E0\u9700\u91CD\u62C9\u6E90 */\n private readonly buffers = new Map<string, string[]>();\n /** \u670D\u52A1\u7A97\u5FAA\u73AF\u987A\u5E8F\uFF08\u4EC5\u6D3B\u8DC3\u670D\u52A1\uFF09 */\n private serviceOrder: string[] = [];\n private activeId: string | null = null;\n private previousId: string | null = null;\n private readonly writeLog: HostWriteLog;\n private readonly onChromeChange: (() => void) | undefined;\n\n constructor(opts: { writeLog: HostWriteLog; onChromeChange?: () => void }) {\n this.writeLog = opts.writeLog;\n this.onChromeChange = opts.onChromeChange;\n }\n\n register(win: ReplWindow): void {\n this.windows.set(win.id, win);\n }\n\n unregister(id: string): void {\n if (this.activeId === id) {\n this.activeId = this.previousId;\n this.previousId = null;\n }\n if (this.previousId === id) this.previousId = null;\n this.windows.delete(id);\n this.buffers.delete(id);\n this.serviceOrder = this.serviceOrder.filter((x) => x !== id);\n }\n\n has(id: string): boolean {\n return this.windows.has(id);\n }\n\n getActive(): ReplWindow | undefined {\n return this.activeId ? this.windows.get(this.activeId) : undefined;\n }\n\n getActiveId(): string | null {\n return this.activeId;\n }\n\n getChrome(): WindowChrome {\n const w = this.getActive();\n if (!w) {\n return { showsInput: true, footerShortcuts: \"\", title: \"\" };\n }\n return {\n showsInput: w.showsInput,\n footerShortcuts: w.footerShortcuts,\n title: w.title,\n };\n }\n\n /** \u662F\u5426\u5DF2\u6709\u5C55\u793A\u7F13\u5B58\uFF08\u6709\u5219\u5207\u56DE\u65F6\u52FF\u518D seed\uFF09 */\n hasBuffer(id: string): boolean {\n return this.buffers.has(id);\n }\n\n getBuffer(id: string): readonly string[] {\n return this.buffers.get(id) ?? [];\n }\n\n /** \u9996\u6B21\u8FDB\u5165\u65F6\u5199\u5165\u79CD\u5B50\u884C */\n setBuffer(id: string, lines: string[]): void {\n this.buffers.set(id, [...lines]);\n }\n\n invalidateBuffer(id: string): void {\n this.buffers.delete(id);\n }\n\n private appendToBuffer(id: string, wrappedLine: string): void {\n let buf = this.buffers.get(id);\n if (!buf) {\n buf = [];\n this.buffers.set(id, buf);\n }\n buf.push(wrappedLine);\n }\n\n /** \u6309\u6D3B\u8DC3\u670D\u52A1\u540C\u6B65 ServiceWindow id \u5217\u8868\uFF08id = svc:<name>\uFF09 */\n setServiceOrder(ids: string[]): void {\n this.serviceOrder = [...ids];\n const stale = [...this.windows.keys()].filter((id) => id.startsWith(\"svc:\") && !ids.includes(id));\n for (const id of stale) {\n this.windows.delete(id);\n this.buffers.delete(id);\n if (this.activeId === id) this.activeId = null;\n if (this.previousId === id) this.previousId = null;\n }\n if (this.activeId?.startsWith(\"svc:\") && !ids.includes(this.activeId)) {\n this.activeId = null;\n }\n if (!this.activeId && ids.length > 0) {\n this.open(ids[0]!);\n }\n }\n\n open(id: string): boolean {\n const next = this.windows.get(id);\n if (!next) return false;\n if (this.activeId === id) {\n next.onActivate?.();\n this.onChromeChange?.();\n return true;\n }\n const prev = this.getActive();\n prev?.onDeactivate?.();\n if (this.activeId && this.activeId !== id) {\n this.previousId = this.activeId;\n }\n this.activeId = id;\n next.onActivate?.();\n this.onChromeChange?.();\n return true;\n }\n\n back(): boolean {\n const fallback =\n (this.previousId && this.windows.has(this.previousId) ? this.previousId : null) ??\n this.serviceOrder.find((id) => this.windows.has(id)) ??\n null;\n this.previousId = null;\n if (!fallback) {\n this.activeId = null;\n this.onChromeChange?.();\n return false;\n }\n return this.open(fallback);\n }\n\n /**\n * \u5728\u670D\u52A1\u7A97\u4E4B\u95F4\u5FAA\u73AF\uFF1B\u8FD4\u56DE\u65B0\u6FC0\u6D3B\u7A97\u7684 serviceName\uFF08\u4F9B\u540C\u6B65\u53D1\u9001\u76EE\u6807\uFF09\u3002\n * \u82E5\u5F53\u524D\u5728\u975E\u670D\u52A1\u7A97\uFF0C\u5148\u56DE\u5230\u670D\u52A1\u73AF\u3002\n */\n cycleServiceWindows(): ServiceName | null {\n if (this.serviceOrder.length === 0) return null;\n const cur = this.activeId;\n const idx = cur ? this.serviceOrder.indexOf(cur) : -1;\n if (idx < 0) {\n this.open(this.serviceOrder[0]!);\n } else {\n const next = this.serviceOrder[(idx + 1) % this.serviceOrder.length]!;\n this.open(next);\n }\n return this.getActive()?.serviceName ?? null;\n }\n\n /**\n * \u65B0\u65E5\u5FD7\uFF1A\u5199\u5165\u6240\u6709\u5DF2 seed \u7F13\u5B58\u4E14 accept \u7684\u7A97\u53E3\uFF1B\u4EC5\u6D3B\u52A8\u7A97\u5237\u5230 TTY\u3002\n * \u6D3B\u52A8\u7A97\u5C1A\u672A seed\uFF1A\u53EA\u5237 TTY\uFF08\u968F\u540E showActiveWindow \u4F1A seed \u542B\u5386\u53F2\u7684\u7F13\u5B58\uFF09\u3002\n */\n routeLog(log: UnifiedLog): void {\n for (const [id, w] of this.windows) {\n if (!w.acceptLog(log)) continue;\n if (!this.buffers.has(id)) {\n if (id === this.activeId) {\n const { text, indent } = w.formatLogLine(log);\n this.writeLog(wrapLogLine(text, indent));\n }\n continue;\n }\n const { text, indent } = w.formatLogLine(log);\n const wrapped = wrapLogLine(text, indent);\n this.appendToBuffer(id, wrapped);\n if (id === this.activeId) this.writeLog(wrapped);\n }\n }\n\n /** \u8FD4\u56DE\u6D3B\u52A8\u7A97\u5BF9\u65E5\u5FD7\u7684\u5C55\u793A\u7ED3\u679C\uFF08\u542B acceptLog\uFF09 */\n formatActiveLog(log: UnifiedLog): { text: string; indent: number } | null {\n const w = this.getActive();\n if (!w || !w.acceptLog(log)) return null;\n return w.formatLogLine(log);\n }\n\n onKey(ev: WindowKeyEvent): WindowKeyResult {\n const w = this.getActive();\n if (!w?.onKey) return { action: \"none\" };\n const r = w.onKey(ev);\n if (r.action === \"back\") {\n this.back();\n return { action: \"redraw\" };\n }\n return r;\n }\n\n isLogsActive(): boolean {\n return this.activeId === \"logs\";\n }\n}\n\nexport function serviceWindowId(name: ServiceName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AC,QAAO,IAAI,EAAE,cAAc,GAAG;AAC5C,eAAK,SAAS,YAAYD,OAAMC,OAAM,CAAC;AAAA,QACzC;AACA;AAAA,MACF;AACA,YAAM,EAAE,MAAM,OAAO,IAAI,EAAE,cAAc,GAAG;AAC5C,YAAM,UAAU,YAAY,MAAM,MAAM;AACxC,WAAK,eAAe,IAAI,OAAO;AAC/B,UAAI,OAAO,KAAK,SAAU,MAAK,SAAS,OAAO;AAAA,IACjD;AAAA,EACF;AAAA;AAAA,EAGA,gBAAgB,KAA0D;AACxE,UAAM,IAAI,KAAK,UAAU;AACzB,QAAI,CAAC,KAAK,CAAC,EAAE,UAAU,GAAG,EAAG,QAAO;AACpC,WAAO,EAAE,cAAc,GAAG;AAAA,EAC5B;AAAA,EAEA,MAAM,IAAqC;AACzC,UAAM,IAAI,KAAK,UAAU;AACzB,QAAI,CAAC,GAAG,MAAO,QAAO,EAAE,QAAQ,OAAO;AACvC,UAAM,IAAI,EAAE,MAAM,EAAE;AACpB,QAAI,EAAE,WAAW,QAAQ;AACvB,WAAK,KAAK;AACV,aAAO,EAAE,QAAQ,SAAS;AAAA,IAC5B;AACA,WAAO;AAAA,EACT;AAAA,EAEA,eAAwB;AACtB,WAAO,KAAK,aAAa;AAAA,EAC3B;AACF;AAEO,SAAS,gBAAgB,MAA2B;AACzD,SAAO,OAAO,IAAI;AACpB;",
|
|
6
|
+
"names": ["text", "indent"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* repl-windows/index.ts — 类窗口系统出口
|
|
3
|
+
*/
|
|
4
|
+
export { formatLogDisplay, logDisplayPrefixWidth } from "./format-display.js";
|
|
5
|
+
export { WindowHost, serviceWindowId } from "./host.js";
|
|
6
|
+
export { createLogsFilterWindow, type LogsFilterState } from "./logs-filter-window.js";
|
|
7
|
+
export { createServiceWindow } from "./service-window.js";
|
|
8
|
+
export type { ReplWindow, WindowChrome, WindowKeyEvent, WindowKeyResult } from "./types.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/repl-windows/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AACvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { formatLogDisplay, logDisplayPrefixWidth } from "./format-display.js";
|
|
2
|
+
import { WindowHost, serviceWindowId } from "./host.js";
|
|
3
|
+
import { createLogsFilterWindow } from "./logs-filter-window.js";
|
|
4
|
+
import { createServiceWindow } from "./service-window.js";
|
|
5
|
+
export {
|
|
6
|
+
WindowHost,
|
|
7
|
+
createLogsFilterWindow,
|
|
8
|
+
createServiceWindow,
|
|
9
|
+
formatLogDisplay,
|
|
10
|
+
logDisplayPrefixWidth,
|
|
11
|
+
serviceWindowId
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/repl-windows/index.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * repl-windows/index.ts \u2014 \u7C7B\u7A97\u53E3\u7CFB\u7EDF\u51FA\u53E3\n */\nexport { formatLogDisplay, logDisplayPrefixWidth } from \"./format-display.js\";\nexport { WindowHost, serviceWindowId } from \"./host.js\";\nexport { createLogsFilterWindow, type LogsFilterState } from \"./logs-filter-window.js\";\nexport { createServiceWindow } from \"./service-window.js\";\nexport type { ReplWindow, WindowChrome, WindowKeyEvent, WindowKeyResult } from \"./types.js\";\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,kBAAkB,6BAA6B;AACxD,SAAS,YAAY,uBAAuB;AAC5C,SAAS,8BAAoD;AAC7D,SAAS,2BAA2B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* repl-windows/logs-filter-window.ts — /logs 筛选窗(无输入,快捷键筛选)
|
|
3
|
+
*/
|
|
4
|
+
import { type LogLevel, type LogSource } from "../logs.js";
|
|
5
|
+
import type { ReplWindow } from "./types.js";
|
|
6
|
+
export type LogsFilterState = {
|
|
7
|
+
levels: LogLevel[];
|
|
8
|
+
sources: LogSource[];
|
|
9
|
+
};
|
|
10
|
+
export declare function createLogsFilterWindow(opts: {
|
|
11
|
+
getState: () => LogsFilterState;
|
|
12
|
+
setState: (next: LogsFilterState) => void;
|
|
13
|
+
onFilterChanged: () => void;
|
|
14
|
+
}): ReplWindow;
|
|
15
|
+
//# sourceMappingURL=logs-filter-window.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs-filter-window.d.ts","sourceRoot":"","sources":["../../src/repl-windows/logs-filter-window.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAe,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAmB,MAAM,YAAY,CAAC;AAGzF,OAAO,KAAK,EAAE,UAAU,EAAmC,MAAM,YAAY,CAAC;AAI9E,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,QAAQ,EAAE,CAAC;IACnB,OAAO,EAAE,SAAS,EAAE,CAAC;CACtB,CAAC;AAYF,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC3C,QAAQ,EAAE,MAAM,eAAe,CAAC;IAChC,QAAQ,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,CAAC;IAC1C,eAAe,EAAE,MAAM,IAAI,CAAC;CAC7B,GAAG,UAAU,CAiEb"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { SOURCE_META } from "../logs.js";
|
|
2
|
+
import { c } from "../theme.js";
|
|
3
|
+
import { formatLogDisplay, logDisplayPrefixWidth } from "./format-display.js";
|
|
4
|
+
const LEVELS = ["", "info", "warn", "error", "debug", "success"];
|
|
5
|
+
function paintFooter(state) {
|
|
6
|
+
const lv = state.levels[0] ?? "*";
|
|
7
|
+
const src = state.sources[0] ?? "*";
|
|
8
|
+
return ` ${c.cyan("L")}${c.dim(" level:")}${c.text(String(lv))} ${c.cyan("S")}${c.dim(" source:")}${c.text(String(src))} ${c.cyan("Esc")}${c.dim(" back")}`;
|
|
9
|
+
}
|
|
10
|
+
function createLogsFilterWindow(opts) {
|
|
11
|
+
const cycleLevel = () => {
|
|
12
|
+
const st = opts.getState();
|
|
13
|
+
const cur = st.levels[0] ?? "";
|
|
14
|
+
const idx = LEVELS.indexOf(cur);
|
|
15
|
+
const next = LEVELS[(idx + 1) % LEVELS.length];
|
|
16
|
+
opts.setState({
|
|
17
|
+
...st,
|
|
18
|
+
levels: next ? [next] : []
|
|
19
|
+
});
|
|
20
|
+
opts.onFilterChanged();
|
|
21
|
+
};
|
|
22
|
+
const cycleSource = () => {
|
|
23
|
+
const st = opts.getState();
|
|
24
|
+
const names = ["", ...SOURCE_META.map((m) => m.value)];
|
|
25
|
+
const cur = st.sources[0] ?? "";
|
|
26
|
+
const idx = Math.max(0, names.indexOf(cur));
|
|
27
|
+
const next = names[(idx + 1) % names.length];
|
|
28
|
+
opts.setState({
|
|
29
|
+
...st,
|
|
30
|
+
sources: next ? [next] : []
|
|
31
|
+
});
|
|
32
|
+
opts.onFilterChanged();
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
id: "logs",
|
|
36
|
+
title: "LOGS",
|
|
37
|
+
showsInput: false,
|
|
38
|
+
get footerShortcuts() {
|
|
39
|
+
return paintFooter(opts.getState());
|
|
40
|
+
},
|
|
41
|
+
acceptLog(log) {
|
|
42
|
+
const st = opts.getState();
|
|
43
|
+
if (st.levels.length && !st.levels.includes(log.level)) return false;
|
|
44
|
+
if (st.sources.length && !st.sources.includes(log.source)) return false;
|
|
45
|
+
return true;
|
|
46
|
+
},
|
|
47
|
+
formatLogLine(log) {
|
|
48
|
+
return {
|
|
49
|
+
text: formatLogDisplay(log, { omitSource: false }),
|
|
50
|
+
indent: logDisplayPrefixWidth(log, { omitSource: false })
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
getReplayFilter() {
|
|
54
|
+
const st = opts.getState();
|
|
55
|
+
return { levels: st.levels, sources: st.sources };
|
|
56
|
+
},
|
|
57
|
+
onKey(ev) {
|
|
58
|
+
if (ev.type === "escape") return { action: "back" };
|
|
59
|
+
if (ev.type === "char") {
|
|
60
|
+
const ch = ev.ch.toLowerCase();
|
|
61
|
+
if (ch === "l") {
|
|
62
|
+
cycleLevel();
|
|
63
|
+
return { action: "redraw" };
|
|
64
|
+
}
|
|
65
|
+
if (ch === "s") {
|
|
66
|
+
cycleSource();
|
|
67
|
+
return { action: "redraw" };
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return { action: "handled" };
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export {
|
|
75
|
+
createLogsFilterWindow
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=logs-filter-window.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/repl-windows/logs-filter-window.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * repl-windows/logs-filter-window.ts \u2014 /logs \u7B5B\u9009\u7A97\uFF08\u65E0\u8F93\u5165\uFF0C\u5FEB\u6377\u952E\u7B5B\u9009\uFF09\n */\nimport { SOURCE_META, type LogLevel, type LogSource, type UnifiedLog } from \"../logs.js\";\nimport { c } from \"../theme.js\";\nimport { formatLogDisplay, logDisplayPrefixWidth } from \"./format-display.js\";\nimport type { ReplWindow, WindowKeyEvent, WindowKeyResult } from \"./types.js\";\n\nconst LEVELS: Array<LogLevel | \"\"> = [\"\", \"info\", \"warn\", \"error\", \"debug\", \"success\"];\n\nexport type LogsFilterState = {\n levels: LogLevel[];\n sources: LogSource[];\n};\n\nfunction paintFooter(state: LogsFilterState): string {\n const lv = state.levels[0] ?? \"*\";\n const src = state.sources[0] ?? \"*\";\n return (\n ` ${c.cyan(\"L\")}${c.dim(\" level:\")}${c.text(String(lv))} ` +\n `${c.cyan(\"S\")}${c.dim(\" source:\")}${c.text(String(src))} ` +\n `${c.cyan(\"Esc\")}${c.dim(\" back\")}`\n );\n}\n\nexport function createLogsFilterWindow(opts: {\n getState: () => LogsFilterState;\n setState: (next: LogsFilterState) => void;\n onFilterChanged: () => void;\n}): ReplWindow {\n const cycleLevel = (): void => {\n const st = opts.getState();\n const cur = st.levels[0] ?? \"\";\n const idx = LEVELS.indexOf(cur as LogLevel | \"\");\n const next = LEVELS[(idx + 1) % LEVELS.length]!;\n opts.setState({\n ...st,\n levels: next ? [next] : [],\n });\n opts.onFilterChanged();\n };\n\n const cycleSource = (): void => {\n const st = opts.getState();\n const names: Array<LogSource | \"\"> = [\"\", ...SOURCE_META.map((m) => m.value)];\n const cur = st.sources[0] ?? \"\";\n const idx = Math.max(0, names.indexOf(cur));\n const next = names[(idx + 1) % names.length]!;\n opts.setState({\n ...st,\n sources: next ? [next] : [],\n });\n opts.onFilterChanged();\n };\n\n return {\n id: \"logs\",\n title: \"LOGS\",\n showsInput: false,\n get footerShortcuts() {\n return paintFooter(opts.getState());\n },\n acceptLog(log: UnifiedLog): boolean {\n const st = opts.getState();\n if (st.levels.length && !st.levels.includes(log.level)) return false;\n if (st.sources.length && !st.sources.includes(log.source)) return false;\n return true;\n },\n formatLogLine(log: UnifiedLog) {\n return {\n text: formatLogDisplay(log, { omitSource: false }),\n indent: logDisplayPrefixWidth(log, { omitSource: false }),\n };\n },\n getReplayFilter() {\n const st = opts.getState();\n return { levels: st.levels, sources: st.sources };\n },\n onKey(ev: WindowKeyEvent): WindowKeyResult {\n if (ev.type === \"escape\") return { action: \"back\" };\n if (ev.type === \"char\") {\n const ch = ev.ch.toLowerCase();\n if (ch === \"l\") {\n cycleLevel();\n return { action: \"redraw\" };\n }\n if (ch === \"s\") {\n cycleSource();\n return { action: \"redraw\" };\n }\n }\n return { action: \"handled\" };\n },\n };\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,mBAAmE;AAC5E,SAAS,SAAS;AAClB,SAAS,kBAAkB,6BAA6B;AAGxD,MAAM,SAA+B,CAAC,IAAI,QAAQ,QAAQ,SAAS,SAAS,SAAS;AAOrF,SAAS,YAAY,OAAgC;AACnD,QAAM,KAAK,MAAM,OAAO,CAAC,KAAK;AAC9B,QAAM,MAAM,MAAM,QAAQ,CAAC,KAAK;AAChC,SACE,KAAK,EAAE,KAAK,GAAG,CAAC,GAAG,EAAE,IAAI,SAAS,CAAC,GAAG,EAAE,KAAK,OAAO,EAAE,CAAC,CAAC,KACrD,EAAE,KAAK,GAAG,CAAC,GAAG,EAAE,IAAI,UAAU,CAAC,GAAG,EAAE,KAAK,OAAO,GAAG,CAAC,CAAC,KACrD,EAAE,KAAK,KAAK,CAAC,GAAG,EAAE,IAAI,OAAO,CAAC;AAErC;AAEO,SAAS,uBAAuB,MAIxB;AACb,QAAM,aAAa,MAAY;AAC7B,UAAM,KAAK,KAAK,SAAS;AACzB,UAAM,MAAM,GAAG,OAAO,CAAC,KAAK;AAC5B,UAAM,MAAM,OAAO,QAAQ,GAAoB;AAC/C,UAAM,OAAO,QAAQ,MAAM,KAAK,OAAO,MAAM;AAC7C,SAAK,SAAS;AAAA,MACZ,GAAG;AAAA,MACH,QAAQ,OAAO,CAAC,IAAI,IAAI,CAAC;AAAA,IAC3B,CAAC;AACD,SAAK,gBAAgB;AAAA,EACvB;AA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,YAAY;AAC7B,YAAI,OAAO,KAAK;AACd,qBAAW;AACX,iBAAO,EAAE,QAAQ,SAAS;AAAA,QAC5B;AACA,YAAI,OAAO,KAAK;AACd,sBAAY;AACZ,iBAAO,EAAE,QAAQ,SAAS;AAAA,QAC5B;AAAA,MACF;AACA,aAAO,EAAE,QAAQ,UAAU;AAAA,IAC7B;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-window.d.ts","sourceRoot":"","sources":["../../src/repl-windows/service-window.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,WAAW,GAAG,UAAU,CAqBjE"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { formatLogDisplay, logDisplayPrefixWidth } from "./format-display.js";
|
|
2
|
+
import { serviceWindowId } from "./host.js";
|
|
3
|
+
function createServiceWindow(name) {
|
|
4
|
+
const id = serviceWindowId(name);
|
|
5
|
+
return {
|
|
6
|
+
id,
|
|
7
|
+
title: name.toUpperCase(),
|
|
8
|
+
showsInput: true,
|
|
9
|
+
footerShortcuts: "",
|
|
10
|
+
serviceName: name,
|
|
11
|
+
acceptLog(log) {
|
|
12
|
+
return log.source === name;
|
|
13
|
+
},
|
|
14
|
+
formatLogLine(log) {
|
|
15
|
+
return {
|
|
16
|
+
text: formatLogDisplay(log, { omitSource: true }),
|
|
17
|
+
indent: logDisplayPrefixWidth(log, { omitSource: true })
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
getReplayFilter() {
|
|
21
|
+
return { levels: [], sources: [name] };
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
createServiceWindow
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=service-window.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/repl-windows/service-window.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * repl-windows/service-window.ts \u2014 \u6D3B\u8DC3\u670D\u52A1\u65E5\u5FD7\u7A97\uFF08\u7701\u7565\u6E90\u6807\u7B7E\uFF09\n */\nimport type { UnifiedLog } from \"../logs.js\";\nimport type { ServiceName } from \"../services.js\";\nimport { formatLogDisplay, logDisplayPrefixWidth } from \"./format-display.js\";\nimport { serviceWindowId } from \"./host.js\";\nimport type { ReplWindow } from \"./types.js\";\n\nexport function createServiceWindow(name: ServiceName): ReplWindow {\n const id = serviceWindowId(name);\n return {\n id,\n title: name.toUpperCase(),\n showsInput: true,\n footerShortcuts: \"\",\n serviceName: name,\n acceptLog(log: UnifiedLog): boolean {\n return log.source === name;\n },\n formatLogLine(log: UnifiedLog) {\n return {\n text: formatLogDisplay(log, { omitSource: true }),\n indent: logDisplayPrefixWidth(log, { omitSource: true }),\n };\n },\n getReplayFilter() {\n return { levels: [], sources: [name] };\n },\n };\n}\n"],
|
|
5
|
+
"mappings": "AAKA,SAAS,kBAAkB,6BAA6B;AACxD,SAAS,uBAAuB;AAGzB,SAAS,oBAAoB,MAA+B;AACjE,QAAM,KAAK,gBAAgB,IAAI;AAC/B,SAAO;AAAA,IACL;AAAA,IACA,OAAO,KAAK,YAAY;AAAA,IACxB,YAAY;AAAA,IACZ,iBAAiB;AAAA,IACjB,aAAa;AAAA,IACb,UAAU,KAA0B;AAClC,aAAO,IAAI,WAAW;AAAA,IACxB;AAAA,IACA,cAAc,KAAiB;AAC7B,aAAO;AAAA,QACL,MAAM,iBAAiB,KAAK,EAAE,YAAY,KAAK,CAAC;AAAA,QAChD,QAAQ,sBAAsB,KAAK,EAAE,YAAY,KAAK,CAAC;AAAA,MACzD;AAAA,IACF;AAAA,IACA,kBAAkB;AAChB,aAAO,EAAE,QAAQ,CAAC,GAAG,SAAS,CAAC,IAAI,EAAE;AAAA,IACvC;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* repl-windows/types.ts — REPL 类窗口契约(Host 只依赖本接口)
|
|
3
|
+
*/
|
|
4
|
+
import type { UnifiedLog } from "../logs.js";
|
|
5
|
+
import type { ServiceName } from "../services.js";
|
|
6
|
+
export type WindowKeyResult = {
|
|
7
|
+
action: "none";
|
|
8
|
+
} | {
|
|
9
|
+
action: "back";
|
|
10
|
+
} | {
|
|
11
|
+
action: "redraw";
|
|
12
|
+
} | {
|
|
13
|
+
action: "handled";
|
|
14
|
+
};
|
|
15
|
+
/** 简化按键:由 readLine 翻译后传入 */
|
|
16
|
+
export type WindowKeyEvent = {
|
|
17
|
+
type: "escape";
|
|
18
|
+
} | {
|
|
19
|
+
type: "char";
|
|
20
|
+
ch: string;
|
|
21
|
+
} | {
|
|
22
|
+
type: "ctrl";
|
|
23
|
+
code: string;
|
|
24
|
+
};
|
|
25
|
+
export type WindowChrome = {
|
|
26
|
+
showsInput: boolean;
|
|
27
|
+
/** 无输入时底部 shortcut 条(已着色) */
|
|
28
|
+
footerShortcuts: string;
|
|
29
|
+
title: string;
|
|
30
|
+
};
|
|
31
|
+
export interface ReplWindow {
|
|
32
|
+
readonly id: string;
|
|
33
|
+
readonly title: string;
|
|
34
|
+
/** 是否绘制 ❯ 输入行 */
|
|
35
|
+
readonly showsInput: boolean;
|
|
36
|
+
/** 无输入时的 shortcut 文案(已着色) */
|
|
37
|
+
footerShortcuts: string;
|
|
38
|
+
/** 服务窗绑定的发送目标;非服务窗为 undefined */
|
|
39
|
+
readonly serviceName?: ServiceName;
|
|
40
|
+
/** 是否接收并展示该条日志 */
|
|
41
|
+
acceptLog(log: UnifiedLog): boolean;
|
|
42
|
+
/** TTY 展示行(含 ANSI)与悬挂缩进列宽 */
|
|
43
|
+
formatLogLine(log: UnifiedLog): {
|
|
44
|
+
text: string;
|
|
45
|
+
indent: number;
|
|
46
|
+
};
|
|
47
|
+
onActivate?(): void;
|
|
48
|
+
onDeactivate?(): void;
|
|
49
|
+
onKey?(ev: WindowKeyEvent): WindowKeyResult;
|
|
50
|
+
/** 激活/筛选变化时需要重放缓冲 */
|
|
51
|
+
getReplayFilter?(): {
|
|
52
|
+
levels: string[];
|
|
53
|
+
sources: string[];
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/repl-windows/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,MAAM,eAAe,GACvB;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAClB;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAClB;IAAE,MAAM,EAAE,QAAQ,CAAA;CAAE,GACpB;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,CAAC;AAE1B,4BAA4B;AAC5B,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAC5B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnC,MAAM,MAAM,YAAY,GAAG;IACzB,UAAU,EAAE,OAAO,CAAC;IACpB,6BAA6B;IAC7B,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,iBAAiB;IACjB,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,6BAA6B;IAC7B,eAAe,EAAE,MAAM,CAAC;IACxB,iCAAiC;IACjC,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IACnC,kBAAkB;IAClB,SAAS,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC;IACpC,6BAA6B;IAC7B,aAAa,CAAC,GAAG,EAAE,UAAU,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACjE,UAAU,CAAC,IAAI,IAAI,CAAC;IACpB,YAAY,CAAC,IAAI,IAAI,CAAC;IACtB,KAAK,CAAC,CAAC,EAAE,EAAE,cAAc,GAAG,eAAe,CAAC;IAC5C,qBAAqB;IACrB,eAAe,CAAC,IAAI;QAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;CAC7D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
package/dist/repl.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function
|
|
3
|
-
|
|
1
|
+
import { type CommandMode } from "./command-surface.js";
|
|
2
|
+
export declare function playWelcomeAnimation(): Promise<void>;
|
|
3
|
+
export declare function getHelp(mode?: CommandMode): string;
|
|
4
|
+
/** @deprecated 请用 getHelp(mode);保留别名以兼容旧导入。 */
|
|
4
5
|
export declare const HELP: string;
|
|
5
|
-
|
|
6
|
+
/** 来源选择项:方括号 3 字符标签染色(供外部/测试复用) */
|
|
7
|
+
export declare const SOURCE_ITEMS: Array<{
|
|
6
8
|
label: string;
|
|
7
9
|
value: string;
|
|
8
|
-
}
|
|
9
|
-
/** 来源选择项:标签整段染色(含后续 formatSourceTag 的方括号风格) */
|
|
10
|
-
export declare const SOURCE_ITEMS: SelectItem[];
|
|
10
|
+
}>;
|
|
11
11
|
export declare function startRepl(): Promise<void>;
|
|
12
|
-
export {};
|
|
13
12
|
//# sourceMappingURL=repl.d.ts.map
|
package/dist/repl.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repl.d.ts","sourceRoot":"","sources":["../src/repl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"repl.d.ts","sourceRoot":"","sources":["../src/repl.ts"],"names":[],"mappings":"AAcA,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAC;AAgN9B,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAiD1D;AAcD,wBAAgB,OAAO,CAAC,IAAI,GAAE,WAAoB,GAAG,MAAM,CAE1D;AAED,+CAA+C;AAC/C,eAAO,MAAM,IAAI,EAOD,MAAM,CAAC;AAofvB,mCAAmC;AACnC,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAG9D,CAAC;AAmBJ,wBAAsB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAkR/C"}
|