@alcyone-labs/arg-parser 2.14.2 → 3.0.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.md +20 -127
- package/dist/config/plugins/index.d.ts +36 -4
- package/dist/config/plugins/index.d.ts.map +1 -1
- package/dist/core/ArgParser.d.ts +124 -464
- package/dist/core/ArgParser.d.ts.map +1 -1
- package/dist/core/FlagManager.d.ts +36 -136
- package/dist/core/FlagManager.d.ts.map +1 -1
- package/dist/core/PromptManager.d.ts +42 -91
- package/dist/core/PromptManager.d.ts.map +1 -1
- package/dist/core/log-path-utils.d.ts +28 -36
- package/dist/core/log-path-utils.d.ts.map +1 -1
- package/dist/core/types.d.ts +83 -592
- package/dist/core/types.d.ts.map +1 -1
- package/dist/index.cjs +599 -9658
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +26 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.min.mjs +615 -8224
- package/dist/index.min.mjs.map +1 -1
- package/dist/index.mjs +581 -8881
- package/dist/index.mjs.map +1 -1
- package/dist/plugin/types.d.ts +121 -0
- package/dist/plugin/types.d.ts.map +1 -0
- package/dist/utils/debug-utils.d.ts +4 -26
- package/dist/utils/debug-utils.d.ts.map +1 -1
- package/package.json +12 -73
- package/dist/assets/.dxtignore.template +0 -37
- package/dist/assets/logo_1_small.jpg +0 -0
- package/dist/config/ConfigurationManager.d.ts +0 -82
- package/dist/config/ConfigurationManager.d.ts.map +0 -1
- package/dist/config/plugins/ConfigPlugin.d.ts +0 -60
- package/dist/config/plugins/ConfigPlugin.d.ts.map +0 -1
- package/dist/config/plugins/ConfigPluginRegistry.d.ts +0 -72
- package/dist/config/plugins/ConfigPluginRegistry.d.ts.map +0 -1
- package/dist/config/plugins/TomlConfigPlugin.d.ts +0 -30
- package/dist/config/plugins/TomlConfigPlugin.d.ts.map +0 -1
- package/dist/config/plugins/YamlConfigPlugin.d.ts +0 -29
- package/dist/config/plugins/YamlConfigPlugin.d.ts.map +0 -1
- package/dist/core/ArgParserBase.d.ts +0 -319
- package/dist/core/ArgParserBase.d.ts.map +0 -1
- package/dist/core/dxt-path-resolver.d.ts +0 -100
- package/dist/core/dxt-path-resolver.d.ts.map +0 -1
- package/dist/dxt/DxtGenerator-testUtils.d.ts +0 -22
- package/dist/dxt/DxtGenerator-testUtils.d.ts.map +0 -1
- package/dist/dxt/DxtGenerator.d.ts +0 -120
- package/dist/dxt/DxtGenerator.d.ts.map +0 -1
- package/dist/mcp/ArgParserMcp.d.ts +0 -21
- package/dist/mcp/ArgParserMcp.d.ts.map +0 -1
- package/dist/mcp/mcp-integration.d.ts +0 -86
- package/dist/mcp/mcp-integration.d.ts.map +0 -1
- package/dist/mcp/mcp-lifecycle.d.ts +0 -163
- package/dist/mcp/mcp-lifecycle.d.ts.map +0 -1
- package/dist/mcp/mcp-notifications.d.ts +0 -132
- package/dist/mcp/mcp-notifications.d.ts.map +0 -1
- package/dist/mcp/mcp-prompts.d.ts +0 -132
- package/dist/mcp/mcp-prompts.d.ts.map +0 -1
- package/dist/mcp/mcp-protocol-versions.d.ts +0 -150
- package/dist/mcp/mcp-protocol-versions.d.ts.map +0 -1
- package/dist/mcp/mcp-resources.d.ts +0 -133
- package/dist/mcp/mcp-resources.d.ts.map +0 -1
- package/dist/mcp/mcp-utils.d.ts +0 -20
- package/dist/mcp/mcp-utils.d.ts.map +0 -1
- package/dist/mcp/zod-compatibility.d.ts +0 -74
- package/dist/mcp/zod-compatibility.d.ts.map +0 -1
- package/dist/testing/fuzzy-test-cli.d.ts +0 -5
- package/dist/testing/fuzzy-test-cli.d.ts.map +0 -1
- package/dist/testing/fuzzy-tester.d.ts +0 -101
- package/dist/testing/fuzzy-tester.d.ts.map +0 -1
- package/dist/tui/index.d.ts +0 -281
- package/dist/tui/types.d.ts +0 -60
- package/dist/tui/types.d.ts.map +0 -1
- package/dist/tui.cjs +0 -1060
- package/dist/tui.cjs.map +0 -1
- package/dist/tui.mjs +0 -967
- package/dist/tui.mjs.map +0 -1
package/dist/tui.cjs
DELETED
|
@@ -1,1060 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
let __opentui_solid = require("@opentui/solid");
|
|
3
|
-
let solid_js = require("solid-js");
|
|
4
|
-
let solid_js_web = require("solid-js/web");
|
|
5
|
-
var EXIT_GUARD_STATE_KEY = Symbol.for("@alcyone-labs/arg-parser/tui/ExitGuardState");
|
|
6
|
-
function getExitGuardState() {
|
|
7
|
-
return process[EXIT_GUARD_STATE_KEY];
|
|
8
|
-
}
|
|
9
|
-
function setExitGuardState(state) {
|
|
10
|
-
if (state) process[EXIT_GUARD_STATE_KEY] = state;
|
|
11
|
-
else delete process[EXIT_GUARD_STATE_KEY];
|
|
12
|
-
}
|
|
13
|
-
function ExitGuard(props) {
|
|
14
|
-
const renderer = (0, __opentui_solid.useRenderer)();
|
|
15
|
-
let state = getExitGuardState();
|
|
16
|
-
if (!state) {
|
|
17
|
-
const originalExit = process.exit.bind(process);
|
|
18
|
-
state = {
|
|
19
|
-
originalExit,
|
|
20
|
-
renderers: /* @__PURE__ */ new Set(),
|
|
21
|
-
activeCount: 0,
|
|
22
|
-
isExiting: false
|
|
23
|
-
};
|
|
24
|
-
setExitGuardState(state);
|
|
25
|
-
const guardedExit = ((code) => {
|
|
26
|
-
const currentState = getExitGuardState();
|
|
27
|
-
if (!currentState) return originalExit(code);
|
|
28
|
-
if (currentState.isExiting) return currentState.originalExit(code);
|
|
29
|
-
currentState.isExiting = true;
|
|
30
|
-
try {
|
|
31
|
-
if (typeof code === "number") process.exitCode = code;
|
|
32
|
-
for (const r of currentState.renderers) try {
|
|
33
|
-
r.destroy();
|
|
34
|
-
} catch {}
|
|
35
|
-
} finally {
|
|
36
|
-
return currentState.originalExit(code);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
process.exit = guardedExit;
|
|
40
|
-
}
|
|
41
|
-
state.activeCount++;
|
|
42
|
-
state.renderers.add(renderer);
|
|
43
|
-
(0, solid_js.onCleanup)(() => {
|
|
44
|
-
const state$1 = getExitGuardState();
|
|
45
|
-
if (!state$1) return;
|
|
46
|
-
state$1.renderers.delete(renderer);
|
|
47
|
-
state$1.activeCount = Math.max(0, state$1.activeCount - 1);
|
|
48
|
-
if (state$1.activeCount === 0) {
|
|
49
|
-
process.exit = state$1.originalExit;
|
|
50
|
-
setExitGuardState(void 0);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
return props.children;
|
|
54
|
-
}
|
|
55
|
-
var ShortcutContext = (0, solid_js.createContext)();
|
|
56
|
-
function ShortcutProvider(props) {
|
|
57
|
-
const [registeredBindings, setRegisteredBindings] = (0, solid_js.createSignal)(props.bindings ?? []);
|
|
58
|
-
const [pending, setPending] = (0, solid_js.createSignal)(null);
|
|
59
|
-
const register = (binding) => {
|
|
60
|
-
setRegisteredBindings((prev) => [...prev, binding]);
|
|
61
|
-
return () => {
|
|
62
|
-
setRegisteredBindings((prev) => prev.filter((b) => b !== binding));
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
const value = {
|
|
66
|
-
register,
|
|
67
|
-
pending,
|
|
68
|
-
bindings: registeredBindings
|
|
69
|
-
};
|
|
70
|
-
return (0, __opentui_solid.createComponent)(ShortcutContext.Provider, {
|
|
71
|
-
value,
|
|
72
|
-
get children() {
|
|
73
|
-
return props.children;
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
function useShortcuts() {
|
|
78
|
-
const context = (0, solid_js.useContext)(ShortcutContext);
|
|
79
|
-
if (!context) throw new Error("useShortcuts must be used within a ShortcutProvider");
|
|
80
|
-
return context;
|
|
81
|
-
}
|
|
82
|
-
const TuiThemes = {
|
|
83
|
-
dark: {
|
|
84
|
-
name: "dark",
|
|
85
|
-
colors: {
|
|
86
|
-
text: "#ffffff",
|
|
87
|
-
muted: "#888888",
|
|
88
|
-
background: "#1a1a1a",
|
|
89
|
-
accent: "#00d4ff",
|
|
90
|
-
success: "#00ff88",
|
|
91
|
-
warning: "#ffaa00",
|
|
92
|
-
error: "#ff4444",
|
|
93
|
-
border: "#444444",
|
|
94
|
-
selection: "#0066cc"
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
light: {
|
|
98
|
-
name: "light",
|
|
99
|
-
colors: {
|
|
100
|
-
text: "#000000",
|
|
101
|
-
muted: "#333333",
|
|
102
|
-
background: "#e8e8e8",
|
|
103
|
-
accent: "#0044aa",
|
|
104
|
-
success: "#005500",
|
|
105
|
-
warning: "#885500",
|
|
106
|
-
error: "#880000",
|
|
107
|
-
border: "#888888",
|
|
108
|
-
selection: "#0044aa"
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
monokai: {
|
|
112
|
-
name: "monokai",
|
|
113
|
-
colors: {
|
|
114
|
-
text: "#f8f8f2",
|
|
115
|
-
muted: "#75715e",
|
|
116
|
-
background: "#272822",
|
|
117
|
-
accent: "#ae81ff",
|
|
118
|
-
success: "#a6e22e",
|
|
119
|
-
warning: "#e6db74",
|
|
120
|
-
error: "#f92672",
|
|
121
|
-
border: "#49483e",
|
|
122
|
-
selection: "#49483e"
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
dracula: {
|
|
126
|
-
name: "dracula",
|
|
127
|
-
colors: {
|
|
128
|
-
text: "#f8f8f2",
|
|
129
|
-
muted: "#6272a4",
|
|
130
|
-
background: "#282a36",
|
|
131
|
-
accent: "#bd93f9",
|
|
132
|
-
success: "#50fa7b",
|
|
133
|
-
warning: "#f1fa8c",
|
|
134
|
-
error: "#ff5555",
|
|
135
|
-
border: "#44475a",
|
|
136
|
-
selection: "#44475a"
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
nord: {
|
|
140
|
-
name: "nord",
|
|
141
|
-
colors: {
|
|
142
|
-
text: "#eceff4",
|
|
143
|
-
muted: "#4c566a",
|
|
144
|
-
background: "#2e3440",
|
|
145
|
-
accent: "#88c0d0",
|
|
146
|
-
success: "#a3be8c",
|
|
147
|
-
warning: "#ebcb8b",
|
|
148
|
-
error: "#bf616a",
|
|
149
|
-
border: "#3b4252",
|
|
150
|
-
selection: "#4c566a"
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
solarized: {
|
|
154
|
-
name: "solarized",
|
|
155
|
-
colors: {
|
|
156
|
-
text: "#839496",
|
|
157
|
-
muted: "#586e75",
|
|
158
|
-
background: "#002b36",
|
|
159
|
-
accent: "#268bd2",
|
|
160
|
-
success: "#859900",
|
|
161
|
-
warning: "#b58900",
|
|
162
|
-
error: "#dc322f",
|
|
163
|
-
border: "#073642",
|
|
164
|
-
selection: "#073642"
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
const THEMES = TuiThemes;
|
|
169
|
-
const Theme = {
|
|
170
|
-
from: (base) => ({ extend: (overrides) => ({
|
|
171
|
-
name: overrides.name ?? `${base.name}-extended`,
|
|
172
|
-
colors: {
|
|
173
|
-
...base.colors,
|
|
174
|
-
...overrides.colors
|
|
175
|
-
}
|
|
176
|
-
}) }),
|
|
177
|
-
create: (theme) => theme,
|
|
178
|
-
names: () => Object.keys(TuiThemes),
|
|
179
|
-
get: (name) => TuiThemes[name] ?? TuiThemes["dark"]
|
|
180
|
-
};
|
|
181
|
-
var ThemeContext = (0, solid_js.createContext)();
|
|
182
|
-
function ThemeProvider(props) {
|
|
183
|
-
const themes = { ...TuiThemes };
|
|
184
|
-
const [current, setCurrent] = (0, solid_js.createSignal)(themes[props.initial ?? "dark"] ?? themes["dark"]);
|
|
185
|
-
const setTheme = (name) => {
|
|
186
|
-
if (themes[name]) setCurrent(themes[name]);
|
|
187
|
-
};
|
|
188
|
-
const cycle = () => {
|
|
189
|
-
const currentName = current().name;
|
|
190
|
-
const names$1 = Object.keys(themes);
|
|
191
|
-
setCurrent(themes[names$1[(names$1.indexOf(currentName) + 1) % names$1.length]]);
|
|
192
|
-
};
|
|
193
|
-
const register = (theme) => {
|
|
194
|
-
themes[theme.name] = theme;
|
|
195
|
-
};
|
|
196
|
-
const names = () => Object.keys(themes);
|
|
197
|
-
const value = {
|
|
198
|
-
current,
|
|
199
|
-
setTheme,
|
|
200
|
-
cycle,
|
|
201
|
-
register,
|
|
202
|
-
names
|
|
203
|
-
};
|
|
204
|
-
return (0, __opentui_solid.createComponent)(ThemeContext.Provider, {
|
|
205
|
-
value,
|
|
206
|
-
get children() {
|
|
207
|
-
return props.children;
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
function useTheme() {
|
|
212
|
-
const context = (0, solid_js.useContext)(ThemeContext);
|
|
213
|
-
if (!context) throw new Error("useTheme must be used within a ThemeProvider");
|
|
214
|
-
return context;
|
|
215
|
-
}
|
|
216
|
-
var ToastContext = (0, solid_js.createContext)();
|
|
217
|
-
var DEFAULT_DURATION = 3e3;
|
|
218
|
-
function ToastProvider(props) {
|
|
219
|
-
const [state, setState] = (0, solid_js.createSignal)({
|
|
220
|
-
message: "",
|
|
221
|
-
type: "info",
|
|
222
|
-
visible: false
|
|
223
|
-
});
|
|
224
|
-
let hideTimeout = null;
|
|
225
|
-
const show = (message, type, duration) => {
|
|
226
|
-
if (hideTimeout) clearTimeout(hideTimeout);
|
|
227
|
-
setState({
|
|
228
|
-
message,
|
|
229
|
-
type,
|
|
230
|
-
visible: true
|
|
231
|
-
});
|
|
232
|
-
hideTimeout = setTimeout(() => {
|
|
233
|
-
setState((prev) => ({
|
|
234
|
-
...prev,
|
|
235
|
-
visible: false
|
|
236
|
-
}));
|
|
237
|
-
}, duration);
|
|
238
|
-
};
|
|
239
|
-
const hide = () => {
|
|
240
|
-
if (hideTimeout) {
|
|
241
|
-
clearTimeout(hideTimeout);
|
|
242
|
-
hideTimeout = null;
|
|
243
|
-
}
|
|
244
|
-
setState((prev) => ({
|
|
245
|
-
...prev,
|
|
246
|
-
visible: false
|
|
247
|
-
}));
|
|
248
|
-
};
|
|
249
|
-
const value = {
|
|
250
|
-
info: (message, duration = DEFAULT_DURATION) => show(message, "info", duration),
|
|
251
|
-
success: (message, duration = DEFAULT_DURATION) => show(message, "success", duration),
|
|
252
|
-
error: (message, duration = DEFAULT_DURATION) => show(message, "error", duration),
|
|
253
|
-
warning: (message, duration = DEFAULT_DURATION) => show(message, "warning", duration),
|
|
254
|
-
state,
|
|
255
|
-
hide
|
|
256
|
-
};
|
|
257
|
-
return (0, __opentui_solid.createComponent)(ToastContext.Provider, {
|
|
258
|
-
value,
|
|
259
|
-
get children() {
|
|
260
|
-
return props.children;
|
|
261
|
-
}
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
function useToast() {
|
|
265
|
-
const context = (0, solid_js.useContext)(ToastContext);
|
|
266
|
-
if (!context) throw new Error("useToast must be used within a ToastProvider");
|
|
267
|
-
return context;
|
|
268
|
-
}
|
|
269
|
-
function enableMouseReporting() {
|
|
270
|
-
process.stdout.write("\x1B[?1000h");
|
|
271
|
-
process.stdout.write("\x1B[?1006h");
|
|
272
|
-
}
|
|
273
|
-
function disableMouseReporting() {
|
|
274
|
-
process.stdout.write("\x1B[?1000l");
|
|
275
|
-
process.stdout.write("\x1B[?1002l");
|
|
276
|
-
process.stdout.write("\x1B[?1003l");
|
|
277
|
-
process.stdout.write("\x1B[?1006l");
|
|
278
|
-
process.stdout.write("\x1B[?1015l");
|
|
279
|
-
}
|
|
280
|
-
function clearScreen() {
|
|
281
|
-
process.stdout.write("\x1B[2J\x1B[3J\x1B[H");
|
|
282
|
-
}
|
|
283
|
-
function resetAttributes() {
|
|
284
|
-
process.stdout.write("\x1B[0m");
|
|
285
|
-
}
|
|
286
|
-
function restoreStdin() {
|
|
287
|
-
if (process.stdin.isTTY && process.stdin.setRawMode) try {
|
|
288
|
-
process.stdin.setRawMode(false);
|
|
289
|
-
} catch {}
|
|
290
|
-
}
|
|
291
|
-
function switchToAlternateScreen() {
|
|
292
|
-
process.stdout.write("\x1B[?1049h");
|
|
293
|
-
}
|
|
294
|
-
function switchToMainScreen() {
|
|
295
|
-
process.stdout.write("\x1B[?1049l");
|
|
296
|
-
}
|
|
297
|
-
function cleanupTerminal() {
|
|
298
|
-
switchToMainScreen();
|
|
299
|
-
disableMouseReporting();
|
|
300
|
-
clearScreen();
|
|
301
|
-
resetAttributes();
|
|
302
|
-
restoreStdin();
|
|
303
|
-
}
|
|
304
|
-
function parseMouseScroll(data) {
|
|
305
|
-
const sgrMatch = data.toString().match(/\x1b\[<(\d+);(\d+);(\d+)([Mm])/);
|
|
306
|
-
if (sgrMatch) {
|
|
307
|
-
const button = parseInt(sgrMatch[1], 10);
|
|
308
|
-
if (button === 64) return -1;
|
|
309
|
-
if (button === 65) return 1;
|
|
310
|
-
}
|
|
311
|
-
return 0;
|
|
312
|
-
}
|
|
313
|
-
function createTuiApp(App, config = {}) {
|
|
314
|
-
const { theme = "dark", shortcuts = [], onDestroy } = config;
|
|
315
|
-
switchToAlternateScreen();
|
|
316
|
-
enableMouseReporting();
|
|
317
|
-
return (0, __opentui_solid.render)(() => (0, __opentui_solid.createComponent)(ExitGuard, { get children() {
|
|
318
|
-
return (0, __opentui_solid.createComponent)(ThemeProvider, {
|
|
319
|
-
get initial() {
|
|
320
|
-
return theme;
|
|
321
|
-
},
|
|
322
|
-
get children() {
|
|
323
|
-
return (0, __opentui_solid.createComponent)(ShortcutProvider, {
|
|
324
|
-
get bindings() {
|
|
325
|
-
return shortcuts;
|
|
326
|
-
},
|
|
327
|
-
get children() {
|
|
328
|
-
return (0, __opentui_solid.createComponent)(ToastProvider, { get children() {
|
|
329
|
-
return (0, __opentui_solid.createComponent)(App, {});
|
|
330
|
-
} });
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
});
|
|
335
|
-
} }), { onDestroy: () => {
|
|
336
|
-
cleanupTerminal();
|
|
337
|
-
onDestroy?.();
|
|
338
|
-
} });
|
|
339
|
-
}
|
|
340
|
-
var _tmpl$$4 = ["<box width=\"100%\" height=\"100%\">", "</box>"];
|
|
341
|
-
var TuiContext = (0, solid_js.createContext)();
|
|
342
|
-
function useTui() {
|
|
343
|
-
const context = (0, solid_js.useContext)(TuiContext);
|
|
344
|
-
if (!context) throw new Error("useTui must be used within a TuiProvider");
|
|
345
|
-
return context;
|
|
346
|
-
}
|
|
347
|
-
function TuiProvider(props) {
|
|
348
|
-
const renderer = (0, __opentui_solid.useRenderer)();
|
|
349
|
-
const reservedRows = props.reservedRows ?? 8;
|
|
350
|
-
props.scrollSpeed;
|
|
351
|
-
const [viewportHeight, setViewportHeight] = (0, solid_js.createSignal)(Math.max(10, renderer.height - reservedRows));
|
|
352
|
-
const [viewportWidth, setViewportWidth] = (0, solid_js.createSignal)(renderer.width);
|
|
353
|
-
const exit = (code = 0) => {
|
|
354
|
-
process.exitCode = code;
|
|
355
|
-
renderer.destroy();
|
|
356
|
-
};
|
|
357
|
-
const handleResize = (width, height) => {
|
|
358
|
-
setViewportHeight(Math.max(10, height - reservedRows));
|
|
359
|
-
setViewportWidth(width);
|
|
360
|
-
};
|
|
361
|
-
(0, solid_js.onMount)(() => {
|
|
362
|
-
switchToAlternateScreen();
|
|
363
|
-
enableMouseReporting();
|
|
364
|
-
renderer.on("resize", handleResize);
|
|
365
|
-
});
|
|
366
|
-
(0, solid_js.onCleanup)(() => {
|
|
367
|
-
renderer.off("resize", handleResize);
|
|
368
|
-
cleanupTerminal();
|
|
369
|
-
});
|
|
370
|
-
const contextValue = {
|
|
371
|
-
viewportHeight,
|
|
372
|
-
viewportWidth,
|
|
373
|
-
exit
|
|
374
|
-
};
|
|
375
|
-
const themeName = typeof props.theme === "string" ? props.theme : props.theme?.name ?? "dark";
|
|
376
|
-
return (0, __opentui_solid.createComponent)(ExitGuard, { get children() {
|
|
377
|
-
return (0, __opentui_solid.createComponent)(TuiContext.Provider, {
|
|
378
|
-
value: contextValue,
|
|
379
|
-
get children() {
|
|
380
|
-
return (0, __opentui_solid.createComponent)(ThemeProvider, {
|
|
381
|
-
initial: themeName,
|
|
382
|
-
get children() {
|
|
383
|
-
return (0, __opentui_solid.createComponent)(ShortcutProvider, {
|
|
384
|
-
get bindings() {
|
|
385
|
-
return props.shortcuts ?? [];
|
|
386
|
-
},
|
|
387
|
-
get children() {
|
|
388
|
-
return (0, __opentui_solid.createComponent)(ToastProvider, { get children() {
|
|
389
|
-
return (0, solid_js_web.ssr)(_tmpl$$4, (0, solid_js_web.escape)(props.children));
|
|
390
|
-
} });
|
|
391
|
-
}
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
|
-
});
|
|
397
|
-
} });
|
|
398
|
-
}
|
|
399
|
-
var _tmpl$$3 = ["<box height=\"1\" paddingleft=\"2\">", "</box>"], _tmpl$2$3 = [
|
|
400
|
-
"<text",
|
|
401
|
-
" bold>",
|
|
402
|
-
"</text>"
|
|
403
|
-
], _tmpl$3$2 = [
|
|
404
|
-
"<text",
|
|
405
|
-
"> ",
|
|
406
|
-
" </text>"
|
|
407
|
-
];
|
|
408
|
-
function Breadcrumb(props) {
|
|
409
|
-
const { current: theme } = useTheme();
|
|
410
|
-
const separator = props.separator ?? "›";
|
|
411
|
-
const accentColor = () => props.accentColor ?? theme().colors.accent;
|
|
412
|
-
const mutedColor = () => props.mutedColor ?? theme().colors.muted;
|
|
413
|
-
return (0, solid_js_web.ssr)(_tmpl$$3, (0, solid_js_web.escape)((0, solid_js_web.createComponent)(solid_js.For, {
|
|
414
|
-
get each() {
|
|
415
|
-
return props.segments;
|
|
416
|
-
},
|
|
417
|
-
children: (segment, idx) => [idx() > 0 && (0, solid_js_web.ssr)(_tmpl$3$2, (0, solid_js_web.ssrAttribute)("color", (0, solid_js_web.escape)(mutedColor(), true), false), (0, solid_js_web.escape)(separator)), (0, solid_js_web.ssr)(_tmpl$2$3, (0, solid_js_web.ssrAttribute)("color", (0, solid_js_web.escape)(accentColor(), true), false), (0, solid_js_web.escape)(segment))]
|
|
418
|
-
})));
|
|
419
|
-
}
|
|
420
|
-
var _tmpl$$2 = [
|
|
421
|
-
"<box height=\"1\"",
|
|
422
|
-
"><text",
|
|
423
|
-
">",
|
|
424
|
-
"",
|
|
425
|
-
"</text></box>"
|
|
426
|
-
], _tmpl$2$2 = [
|
|
427
|
-
"<text bold",
|
|
428
|
-
" marginBottom=\"1\">",
|
|
429
|
-
" (",
|
|
430
|
-
"/",
|
|
431
|
-
")</text>"
|
|
432
|
-
], _tmpl$3$1 = [
|
|
433
|
-
"<box flexdirection=\"column\" flexgrow=\"1\">",
|
|
434
|
-
"",
|
|
435
|
-
"</box>"
|
|
436
|
-
];
|
|
437
|
-
function unwrap(value) {
|
|
438
|
-
return typeof value === "function" ? value() : value;
|
|
439
|
-
}
|
|
440
|
-
function VirtualList(props) {
|
|
441
|
-
const { current: theme } = useTheme();
|
|
442
|
-
const [scrollOffset, setScrollOffset] = (0, solid_js.createSignal)(0);
|
|
443
|
-
const items = () => unwrap(props.items);
|
|
444
|
-
const selectedIndex = () => unwrap(props.selectedIndex);
|
|
445
|
-
const viewportHeight = () => unwrap(props.viewportHeight ?? 20);
|
|
446
|
-
const showIndicator = props.showIndicator ?? true;
|
|
447
|
-
const visibleItems = (0, solid_js.createMemo)(() => {
|
|
448
|
-
const allItems = items();
|
|
449
|
-
const vh = viewportHeight();
|
|
450
|
-
const start = scrollOffset();
|
|
451
|
-
const end = Math.min(start + vh, allItems.length);
|
|
452
|
-
return allItems.slice(start, end).map((item, localIdx) => ({
|
|
453
|
-
item,
|
|
454
|
-
globalIndex: start + localIdx
|
|
455
|
-
}));
|
|
456
|
-
});
|
|
457
|
-
const defaultRenderItem = (item, index, selected) => {
|
|
458
|
-
const label = props.getLabel ? props.getLabel(item) : String(item);
|
|
459
|
-
const t = theme();
|
|
460
|
-
return (0, solid_js_web.ssr)(_tmpl$$2, (0, solid_js_web.ssrAttribute)("backgroundcolor", selected ? (0, solid_js_web.escape)(t.colors.selection, true) : (0, solid_js_web.escape)(void 0, true), false), (0, solid_js_web.ssrAttribute)("color", selected ? (0, solid_js_web.escape)(t.colors.background, true) : (0, solid_js_web.escape)(t.colors.text, true), false), showIndicator ? selected ? "› " : " " : "", (0, solid_js_web.escape)(label));
|
|
461
|
-
};
|
|
462
|
-
const renderItem = props.renderItem ?? defaultRenderItem;
|
|
463
|
-
return (0, solid_js_web.ssr)(_tmpl$3$1, (0, solid_js_web.escape)((0, solid_js_web.createComponent)(solid_js.Show, {
|
|
464
|
-
get when() {
|
|
465
|
-
return props.title;
|
|
466
|
-
},
|
|
467
|
-
get children() {
|
|
468
|
-
return (0, solid_js_web.ssr)(_tmpl$2$2, (0, solid_js_web.ssrAttribute)("color", (0, solid_js_web.escape)(theme().colors.text, true), false), (0, solid_js_web.escape)(props.title), (0, solid_js_web.escape)(selectedIndex()) + 1, (0, solid_js_web.escape)(items().length));
|
|
469
|
-
}
|
|
470
|
-
})), (0, solid_js_web.escape)((0, solid_js_web.createComponent)(solid_js.For, {
|
|
471
|
-
get each() {
|
|
472
|
-
return visibleItems();
|
|
473
|
-
},
|
|
474
|
-
children: ({ item, globalIndex }) => renderItem(item, globalIndex, globalIndex === selectedIndex())
|
|
475
|
-
})));
|
|
476
|
-
}
|
|
477
|
-
function createVirtualListController(items, selectedIndex, setSelectedIndex, viewportHeight) {
|
|
478
|
-
const [scrollOffset, setScrollOffset] = (0, solid_js.createSignal)(0);
|
|
479
|
-
const adjustScroll = (newIdx) => {
|
|
480
|
-
const vh = viewportHeight();
|
|
481
|
-
const currentOffset = scrollOffset();
|
|
482
|
-
if (newIdx < currentOffset) setScrollOffset(newIdx);
|
|
483
|
-
else if (newIdx >= currentOffset + vh) setScrollOffset(newIdx - vh + 1);
|
|
484
|
-
};
|
|
485
|
-
const scrollBy = (delta) => {
|
|
486
|
-
const maxOffset = Math.max(0, items().length - viewportHeight());
|
|
487
|
-
setScrollOffset((o) => Math.max(0, Math.min(maxOffset, o + delta)));
|
|
488
|
-
};
|
|
489
|
-
const selectPrevious = () => {
|
|
490
|
-
const newIdx = Math.max(0, selectedIndex() - 1);
|
|
491
|
-
setSelectedIndex(newIdx);
|
|
492
|
-
adjustScroll(newIdx);
|
|
493
|
-
};
|
|
494
|
-
const selectNext = () => {
|
|
495
|
-
const newIdx = Math.min(items().length - 1, selectedIndex() + 1);
|
|
496
|
-
setSelectedIndex(newIdx);
|
|
497
|
-
adjustScroll(newIdx);
|
|
498
|
-
};
|
|
499
|
-
return {
|
|
500
|
-
scrollOffset,
|
|
501
|
-
adjustScroll,
|
|
502
|
-
scrollBy,
|
|
503
|
-
selectPrevious,
|
|
504
|
-
selectNext
|
|
505
|
-
};
|
|
506
|
-
}
|
|
507
|
-
var _tmpl$$1 = [
|
|
508
|
-
"<box height=\"1\"",
|
|
509
|
-
"><text",
|
|
510
|
-
"> ",
|
|
511
|
-
"</text></box>"
|
|
512
|
-
], _tmpl$2$1 = [
|
|
513
|
-
"<box width=\"100%\" height=\"100%\" flexdirection=\"column\"",
|
|
514
|
-
"><box height=\"3\" borderstyle=\"single\"",
|
|
515
|
-
" justifycontent=\"center\" alignitems=\"center\"><text bold",
|
|
516
|
-
">",
|
|
517
|
-
"",
|
|
518
|
-
" </text></box>",
|
|
519
|
-
"<box flexgrow=\"1\" flexdirection=\"row\"><box",
|
|
520
|
-
" borderstyle=\"single\"",
|
|
521
|
-
" flexdirection=\"column\" padding=\"1\">",
|
|
522
|
-
"</box><box flexgrow=\"1\" borderstyle=\"single\"",
|
|
523
|
-
" flexdirection=\"column\" padding=\"2\">",
|
|
524
|
-
"</box></box>",
|
|
525
|
-
"</box>"
|
|
526
|
-
];
|
|
527
|
-
function MasterDetail(props) {
|
|
528
|
-
const { current: theme } = useTheme();
|
|
529
|
-
const masterWidth = props.masterWidth ?? "35%";
|
|
530
|
-
return (0, solid_js_web.ssr)(_tmpl$2$1, (0, solid_js_web.ssrAttribute)("backgroundcolor", (0, solid_js_web.escape)(theme().colors.background, true), false), (0, solid_js_web.ssrAttribute)("bordercolor", (0, solid_js_web.escape)(theme().colors.accent, true), false), (0, solid_js_web.ssrAttribute)("color", (0, solid_js_web.escape)(theme().colors.accent, true), false), props.headerIcon ? ` ${(0, solid_js_web.escape)(props.headerIcon)} ` : " ", (0, solid_js_web.escape)(props.header), (0, solid_js_web.escape)((0, solid_js_web.createComponent)(solid_js.Show, {
|
|
531
|
-
get when() {
|
|
532
|
-
return props.breadcrumb && props.breadcrumb.length > 0;
|
|
533
|
-
},
|
|
534
|
-
get children() {
|
|
535
|
-
return (0, solid_js_web.createComponent)(Breadcrumb, { get segments() {
|
|
536
|
-
return props.breadcrumb;
|
|
537
|
-
} });
|
|
538
|
-
}
|
|
539
|
-
})), (0, solid_js_web.ssrAttribute)("width", (0, solid_js_web.escape)(masterWidth, true), false), (0, solid_js_web.ssrAttribute)("bordercolor", (0, solid_js_web.escape)(theme().colors.border, true), false), (0, solid_js_web.escape)(props.master), (0, solid_js_web.ssrAttribute)("bordercolor", (0, solid_js_web.escape)(theme().colors.border, true), false), (0, solid_js_web.escape)(props.detail), (0, solid_js_web.escape)((0, solid_js_web.createComponent)(solid_js.Show, {
|
|
540
|
-
get when() {
|
|
541
|
-
return props.footer;
|
|
542
|
-
},
|
|
543
|
-
get children() {
|
|
544
|
-
return (0, solid_js_web.ssr)(_tmpl$$1, (0, solid_js_web.ssrAttribute)("backgroundcolor", (0, solid_js_web.escape)(theme().colors.background, true), false), (0, solid_js_web.ssrAttribute)("color", (0, solid_js_web.escape)(theme().colors.muted, true), false), (0, solid_js_web.escape)(props.footer));
|
|
545
|
-
}
|
|
546
|
-
})));
|
|
547
|
-
}
|
|
548
|
-
function parseWidth(width) {
|
|
549
|
-
if (width === void 0) return "30%";
|
|
550
|
-
if (typeof width === "number") return width;
|
|
551
|
-
if (width.endsWith("%")) return `${parseInt(width.replace("%", ""), 10)}%`;
|
|
552
|
-
return width;
|
|
553
|
-
}
|
|
554
|
-
function MasterDetailLayout(props) {
|
|
555
|
-
const masterWidth = parseWidth(props.masterWidth);
|
|
556
|
-
const gap = props.gap ?? 1;
|
|
557
|
-
const showDivider = props.showDivider ?? true;
|
|
558
|
-
return {
|
|
559
|
-
type: "box",
|
|
560
|
-
props: {
|
|
561
|
-
flexDirection: "row",
|
|
562
|
-
width: "100%",
|
|
563
|
-
height: "100%"
|
|
564
|
-
},
|
|
565
|
-
children: [
|
|
566
|
-
{
|
|
567
|
-
type: "box",
|
|
568
|
-
props: {
|
|
569
|
-
flexBasis: masterWidth,
|
|
570
|
-
flexShrink: 0,
|
|
571
|
-
overflow: "scroll"
|
|
572
|
-
},
|
|
573
|
-
children: props.master
|
|
574
|
-
},
|
|
575
|
-
...showDivider ? [{
|
|
576
|
-
type: "box",
|
|
577
|
-
props: {
|
|
578
|
-
width: 1,
|
|
579
|
-
marginLeft: Math.floor(gap / 2),
|
|
580
|
-
marginRight: Math.ceil(gap / 2)
|
|
581
|
-
},
|
|
582
|
-
children: {
|
|
583
|
-
type: "text",
|
|
584
|
-
props: { style: { fg: "#444444" } },
|
|
585
|
-
children: "│".repeat(100)
|
|
586
|
-
}
|
|
587
|
-
}] : [],
|
|
588
|
-
{
|
|
589
|
-
type: "box",
|
|
590
|
-
props: {
|
|
591
|
-
flexGrow: 1,
|
|
592
|
-
overflow: "scroll"
|
|
593
|
-
},
|
|
594
|
-
children: props.detail
|
|
595
|
-
}
|
|
596
|
-
]
|
|
597
|
-
};
|
|
598
|
-
}
|
|
599
|
-
function DrillDownNavigator(props) {
|
|
600
|
-
const [stack, setStack] = (0, solid_js.createSignal)([]);
|
|
601
|
-
const push = (view) => {
|
|
602
|
-
setStack((prev) => [...prev, view]);
|
|
603
|
-
props.onNavigate?.(stack().length + 1);
|
|
604
|
-
};
|
|
605
|
-
const pop = () => {
|
|
606
|
-
if (stack().length > 0) {
|
|
607
|
-
setStack((prev) => prev.slice(0, -1));
|
|
608
|
-
props.onNavigate?.(stack().length - 1);
|
|
609
|
-
}
|
|
610
|
-
};
|
|
611
|
-
const replace = (view) => {
|
|
612
|
-
if (stack().length > 0) setStack((prev) => [...prev.slice(0, -1), view]);
|
|
613
|
-
else push(view);
|
|
614
|
-
};
|
|
615
|
-
const reset = () => {
|
|
616
|
-
setStack([]);
|
|
617
|
-
props.onNavigate?.(0);
|
|
618
|
-
};
|
|
619
|
-
const depth = () => stack().length;
|
|
620
|
-
const canGoBack = () => stack().length > 0;
|
|
621
|
-
const api = {
|
|
622
|
-
push,
|
|
623
|
-
pop,
|
|
624
|
-
replace,
|
|
625
|
-
reset,
|
|
626
|
-
depth,
|
|
627
|
-
canGoBack
|
|
628
|
-
};
|
|
629
|
-
const currentView = () => {
|
|
630
|
-
const currentStack = stack();
|
|
631
|
-
if (currentStack.length > 0) return currentStack[currentStack.length - 1]();
|
|
632
|
-
return props.children(api);
|
|
633
|
-
};
|
|
634
|
-
return {
|
|
635
|
-
type: "box",
|
|
636
|
-
props: {
|
|
637
|
-
width: "100%",
|
|
638
|
-
height: "100%",
|
|
639
|
-
onKeyDown: (event) => {
|
|
640
|
-
if (event.defaultPrevented) return;
|
|
641
|
-
if ((event.key === "Escape" || event.key === "ArrowLeft") && canGoBack()) pop();
|
|
642
|
-
}
|
|
643
|
-
},
|
|
644
|
-
children: currentView()
|
|
645
|
-
};
|
|
646
|
-
}
|
|
647
|
-
function Card(props) {
|
|
648
|
-
const borderStyle = props.borderStyle ?? "single";
|
|
649
|
-
const padding = props.padding ?? 1;
|
|
650
|
-
let borderColor = props.borderColor;
|
|
651
|
-
if (!borderColor) try {
|
|
652
|
-
const { current } = useTheme();
|
|
653
|
-
borderColor = current().colors.border;
|
|
654
|
-
} catch {
|
|
655
|
-
borderColor = "#444444";
|
|
656
|
-
}
|
|
657
|
-
return {
|
|
658
|
-
type: "box",
|
|
659
|
-
props: {
|
|
660
|
-
flexDirection: "column",
|
|
661
|
-
width: props.width,
|
|
662
|
-
height: props.height,
|
|
663
|
-
...props.onClick && { onMouseDown: props.onClick },
|
|
664
|
-
style: {
|
|
665
|
-
border: borderStyle !== "none" ? borderStyle : void 0,
|
|
666
|
-
borderColor,
|
|
667
|
-
padding
|
|
668
|
-
}
|
|
669
|
-
},
|
|
670
|
-
children: [...props.title ? [{
|
|
671
|
-
type: "text",
|
|
672
|
-
props: { style: { bold: true } },
|
|
673
|
-
children: ` ${props.title} `
|
|
674
|
-
}] : [], props.children]
|
|
675
|
-
};
|
|
676
|
-
}
|
|
677
|
-
function formatValue(value, format, currency) {
|
|
678
|
-
if (typeof value === "string") return value;
|
|
679
|
-
switch (format) {
|
|
680
|
-
case "compact":
|
|
681
|
-
if (value >= 1e9) return `${(value / 1e9).toFixed(1)}B`;
|
|
682
|
-
if (value >= 1e6) return `${(value / 1e6).toFixed(1)}M`;
|
|
683
|
-
if (value >= 1e3) return `${(value / 1e3).toFixed(1)}K`;
|
|
684
|
-
return value.toString();
|
|
685
|
-
case "percent": return `${(value * 100).toFixed(1)}%`;
|
|
686
|
-
case "currency": return new Intl.NumberFormat("en-US", {
|
|
687
|
-
style: "currency",
|
|
688
|
-
currency: currency ?? "USD",
|
|
689
|
-
minimumFractionDigits: 0,
|
|
690
|
-
maximumFractionDigits: 2
|
|
691
|
-
}).format(value);
|
|
692
|
-
case "number":
|
|
693
|
-
default: return new Intl.NumberFormat("en-US").format(value);
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
function getTrendIndicator(trend) {
|
|
697
|
-
switch (trend) {
|
|
698
|
-
case "up": return {
|
|
699
|
-
symbol: "▲",
|
|
700
|
-
color: "#00ff88"
|
|
701
|
-
};
|
|
702
|
-
case "down": return {
|
|
703
|
-
symbol: "▼",
|
|
704
|
-
color: "#ff4444"
|
|
705
|
-
};
|
|
706
|
-
case "neutral":
|
|
707
|
-
default: return {
|
|
708
|
-
symbol: "─",
|
|
709
|
-
color: "#888888"
|
|
710
|
-
};
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
function StatCard(props) {
|
|
714
|
-
const formattedValue = formatValue(props.value, props.format ?? "number", props.currency);
|
|
715
|
-
const trendIndicator = props.trend ? getTrendIndicator(props.trend) : null;
|
|
716
|
-
return {
|
|
717
|
-
type: "box",
|
|
718
|
-
props: {
|
|
719
|
-
flexDirection: "column",
|
|
720
|
-
width: props.width,
|
|
721
|
-
padding: 1,
|
|
722
|
-
style: { border: "single" },
|
|
723
|
-
...props.onClick && { onMouseDown: props.onClick }
|
|
724
|
-
},
|
|
725
|
-
children: [{
|
|
726
|
-
type: "text",
|
|
727
|
-
props: { style: { fg: "#888888" } },
|
|
728
|
-
children: props.label
|
|
729
|
-
}, {
|
|
730
|
-
type: "box",
|
|
731
|
-
props: {
|
|
732
|
-
flexDirection: "row",
|
|
733
|
-
gap: 1
|
|
734
|
-
},
|
|
735
|
-
children: [{
|
|
736
|
-
type: "text",
|
|
737
|
-
props: { style: {
|
|
738
|
-
bold: true,
|
|
739
|
-
fg: "#ffffff"
|
|
740
|
-
} },
|
|
741
|
-
children: formattedValue
|
|
742
|
-
}, ...trendIndicator ? [{
|
|
743
|
-
type: "text",
|
|
744
|
-
props: { style: { fg: trendIndicator.color } },
|
|
745
|
-
children: trendIndicator.symbol
|
|
746
|
-
}] : []]
|
|
747
|
-
}]
|
|
748
|
-
};
|
|
749
|
-
}
|
|
750
|
-
function MarkdownBlock(props) {
|
|
751
|
-
const { current } = useTheme();
|
|
752
|
-
return {
|
|
753
|
-
type: "box",
|
|
754
|
-
props: {
|
|
755
|
-
flexDirection: "column",
|
|
756
|
-
width: props.width ?? "100%",
|
|
757
|
-
height: props.height,
|
|
758
|
-
padding: props.padding ?? 0,
|
|
759
|
-
overflow: "scroll"
|
|
760
|
-
},
|
|
761
|
-
children: [{
|
|
762
|
-
type: "text",
|
|
763
|
-
props: {
|
|
764
|
-
style: { fg: current().colors.text },
|
|
765
|
-
text: props.content
|
|
766
|
-
}
|
|
767
|
-
}]
|
|
768
|
-
};
|
|
769
|
-
}
|
|
770
|
-
function Button(props) {
|
|
771
|
-
const { current } = useTheme();
|
|
772
|
-
const [isHovered, setIsHovered] = (0, solid_js.createSignal)(false);
|
|
773
|
-
const [isPressed, setIsPressed] = (0, solid_js.createSignal)(false);
|
|
774
|
-
const getBackgroundColor = () => {
|
|
775
|
-
if (props.disabled) return current().colors.muted;
|
|
776
|
-
switch (props.variant) {
|
|
777
|
-
case "danger": return isPressed() ? "#bd2c00" : isHovered() ? "#c82829" : current().colors.error;
|
|
778
|
-
case "primary":
|
|
779
|
-
default: return isPressed() ? current().colors.selection : isHovered() ? current().colors.accent : current().colors.accent;
|
|
780
|
-
}
|
|
781
|
-
};
|
|
782
|
-
const getTextColor = () => {
|
|
783
|
-
if (props.disabled) return current().colors.background;
|
|
784
|
-
return props.variant === "primary" || props.variant === "danger" ? "#ffffff" : current().colors.text;
|
|
785
|
-
};
|
|
786
|
-
return {
|
|
787
|
-
type: "box",
|
|
788
|
-
props: {
|
|
789
|
-
width: props.width,
|
|
790
|
-
height: 3,
|
|
791
|
-
flexDirection: "row",
|
|
792
|
-
alignItems: "center",
|
|
793
|
-
justifyContent: "center",
|
|
794
|
-
style: {
|
|
795
|
-
border: "single",
|
|
796
|
-
borderColor: isHovered() && !props.disabled ? current().colors.text : current().colors.border,
|
|
797
|
-
bg: getBackgroundColor()
|
|
798
|
-
},
|
|
799
|
-
onMouseOver: () => !props.disabled && setIsHovered(true),
|
|
800
|
-
onMouseOut: () => {
|
|
801
|
-
setIsHovered(false);
|
|
802
|
-
setIsPressed(false);
|
|
803
|
-
},
|
|
804
|
-
onMouseDown: () => !props.disabled && setIsPressed(true),
|
|
805
|
-
onMouseUp: () => {
|
|
806
|
-
if (!props.disabled && isPressed()) {
|
|
807
|
-
setIsPressed(false);
|
|
808
|
-
props.onClick?.();
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
},
|
|
812
|
-
children: [{
|
|
813
|
-
type: "text",
|
|
814
|
-
props: {
|
|
815
|
-
style: {
|
|
816
|
-
fg: getTextColor(),
|
|
817
|
-
bold: true
|
|
818
|
-
},
|
|
819
|
-
text: ` ${props.label} `
|
|
820
|
-
}
|
|
821
|
-
}]
|
|
822
|
-
};
|
|
823
|
-
}
|
|
824
|
-
var _tmpl$ = [
|
|
825
|
-
"<box width=\"100%\" height=\"100%\" flexdirection=\"column\"",
|
|
826
|
-
"><box height=\"3\" borderstyle=\"single\"",
|
|
827
|
-
" justifycontent=\"center\" alignitems=\"center\"><text bold",
|
|
828
|
-
"> ",
|
|
829
|
-
" </text></box>",
|
|
830
|
-
"<box flexgrow=\"1\" flexdirection=\"row\">",
|
|
831
|
-
"</box>",
|
|
832
|
-
"</box>"
|
|
833
|
-
], _tmpl$2 = [
|
|
834
|
-
"<box height=\"1\" paddingleft=\"2\"",
|
|
835
|
-
">",
|
|
836
|
-
"</box>"
|
|
837
|
-
], _tmpl$3 = [
|
|
838
|
-
"<text",
|
|
839
|
-
" bold>",
|
|
840
|
-
"</text>"
|
|
841
|
-
], _tmpl$4 = ["<text", "> › </text>"], _tmpl$5 = [
|
|
842
|
-
"<box height=\"1\"",
|
|
843
|
-
"><text",
|
|
844
|
-
"> ",
|
|
845
|
-
"</text></box>"
|
|
846
|
-
], _tmpl$6 = [
|
|
847
|
-
"<box",
|
|
848
|
-
" borderstyle=\"single\"",
|
|
849
|
-
" flexdirection=\"column\" padding=\"1\">",
|
|
850
|
-
"</box>"
|
|
851
|
-
], _tmpl$7 = [
|
|
852
|
-
"<box flexgrow=\"1\" borderstyle=\"single\"",
|
|
853
|
-
" flexdirection=\"column\" padding=\"2\">",
|
|
854
|
-
"</box>"
|
|
855
|
-
], _tmpl$8 = [
|
|
856
|
-
"<box height=\"1\"",
|
|
857
|
-
"><text",
|
|
858
|
-
">",
|
|
859
|
-
"",
|
|
860
|
-
"</text></box>"
|
|
861
|
-
];
|
|
862
|
-
const LAYOUT_THEMES = {
|
|
863
|
-
dark: {
|
|
864
|
-
bg: "#0d0d0d",
|
|
865
|
-
fg: "#f5f5f5",
|
|
866
|
-
accent: "#00d4ff",
|
|
867
|
-
muted: "#999999",
|
|
868
|
-
error: "#ff4444",
|
|
869
|
-
success: "#44ff44",
|
|
870
|
-
border: "#444444",
|
|
871
|
-
selection: "#00d4ff",
|
|
872
|
-
selectionFg: "#000000"
|
|
873
|
-
},
|
|
874
|
-
light: {
|
|
875
|
-
bg: "#e8e8e8",
|
|
876
|
-
fg: "#000000",
|
|
877
|
-
accent: "#0044aa",
|
|
878
|
-
muted: "#333333",
|
|
879
|
-
error: "#880000",
|
|
880
|
-
success: "#005500",
|
|
881
|
-
border: "#888888",
|
|
882
|
-
selection: "#0044aa",
|
|
883
|
-
selectionFg: "#ffffff"
|
|
884
|
-
},
|
|
885
|
-
monokai: {
|
|
886
|
-
bg: "#272822",
|
|
887
|
-
fg: "#f8f8f2",
|
|
888
|
-
accent: "#a6e22e",
|
|
889
|
-
muted: "#75715e",
|
|
890
|
-
error: "#f92672",
|
|
891
|
-
success: "#a6e22e",
|
|
892
|
-
border: "#49483e",
|
|
893
|
-
selection: "#a6e22e",
|
|
894
|
-
selectionFg: "#272822"
|
|
895
|
-
}
|
|
896
|
-
};
|
|
897
|
-
function resolveTheme(theme) {
|
|
898
|
-
if (!theme) return LAYOUT_THEMES.dark;
|
|
899
|
-
if (typeof theme === "string") return LAYOUT_THEMES[theme] ?? LAYOUT_THEMES.dark;
|
|
900
|
-
return theme;
|
|
901
|
-
}
|
|
902
|
-
function MasterDetailLayout$1(props) {
|
|
903
|
-
const t = resolveTheme(props.theme);
|
|
904
|
-
props.masterWidth;
|
|
905
|
-
return (0, solid_js_web.ssr)(_tmpl$, (0, solid_js_web.ssrAttribute)("backgroundcolor", (0, solid_js_web.escape)(t.bg, true), false), (0, solid_js_web.ssrAttribute)("bordercolor", (0, solid_js_web.escape)(t.accent, true), false), (0, solid_js_web.ssrAttribute)("color", (0, solid_js_web.escape)(t.accent, true), false), (0, solid_js_web.escape)(props.header), props.breadcrumb && props.breadcrumb.length > 0 && (0, solid_js_web.ssr)(_tmpl$2, (0, solid_js_web.ssrAttribute)("backgroundcolor", (0, solid_js_web.escape)(t.bg, true), false), (0, solid_js_web.escape)(props.breadcrumb.map((segment, idx) => [idx > 0 && (0, solid_js_web.ssr)(_tmpl$4, (0, solid_js_web.ssrAttribute)("color", (0, solid_js_web.escape)(t.muted, true), false)), (0, solid_js_web.ssr)(_tmpl$3, (0, solid_js_web.ssrAttribute)("color", (0, solid_js_web.escape)(t.accent, true), false), (0, solid_js_web.escape)(segment))]))), (0, solid_js_web.escape)(props.children), props.footer && (0, solid_js_web.ssr)(_tmpl$5, (0, solid_js_web.ssrAttribute)("backgroundcolor", (0, solid_js_web.escape)(t.bg, true), false), (0, solid_js_web.ssrAttribute)("color", (0, solid_js_web.escape)(t.muted, true), false), (0, solid_js_web.escape)(props.footer)));
|
|
906
|
-
}
|
|
907
|
-
function MasterPanel(props) {
|
|
908
|
-
const t = resolveTheme(props.theme);
|
|
909
|
-
return (0, solid_js_web.ssr)(_tmpl$6, (0, solid_js_web.ssrAttribute)("width", (0, solid_js_web.escape)(props.width, true) ?? "35%", false), (0, solid_js_web.ssrAttribute)("bordercolor", (0, solid_js_web.escape)(t.border, true), false), (0, solid_js_web.escape)(props.children));
|
|
910
|
-
}
|
|
911
|
-
function DetailPanel(props) {
|
|
912
|
-
return (0, solid_js_web.ssr)(_tmpl$7, (0, solid_js_web.ssrAttribute)("bordercolor", (0, solid_js_web.escape)(resolveTheme(props.theme).border, true), false), (0, solid_js_web.escape)(props.children));
|
|
913
|
-
}
|
|
914
|
-
function ListItem(props) {
|
|
915
|
-
const t = resolveTheme(props.theme);
|
|
916
|
-
return (0, solid_js_web.ssr)(_tmpl$8, (0, solid_js_web.ssrAttribute)("backgroundcolor", props.selected ? (0, solid_js_web.escape)(t.selection, true) : (0, solid_js_web.escape)(void 0, true), false), (0, solid_js_web.ssrAttribute)("color", props.selected ? (0, solid_js_web.escape)(t.selectionFg, true) : (0, solid_js_web.escape)(t.fg, true), false), props.selected ? "› " : " ", (0, solid_js_web.escape)(props.label));
|
|
917
|
-
}
|
|
918
|
-
function useVirtualScroll(items, _selectedIdx, viewportHeight) {
|
|
919
|
-
const [scrollOffset, setScrollOffset] = (0, solid_js.createSignal)(0);
|
|
920
|
-
const adjustScroll = (newIdx) => {
|
|
921
|
-
const vh = viewportHeight();
|
|
922
|
-
const currentOffset = scrollOffset();
|
|
923
|
-
if (newIdx < currentOffset) setScrollOffset(newIdx);
|
|
924
|
-
else if (newIdx >= currentOffset + vh) setScrollOffset(newIdx - vh + 1);
|
|
925
|
-
};
|
|
926
|
-
const visibleItems = (0, solid_js.createMemo)(() => {
|
|
927
|
-
const allItems = items();
|
|
928
|
-
const vh = viewportHeight();
|
|
929
|
-
const start = scrollOffset();
|
|
930
|
-
const end = Math.min(start + vh, allItems.length);
|
|
931
|
-
return allItems.slice(start, end).map((item, localIdx) => ({
|
|
932
|
-
item,
|
|
933
|
-
globalIndex: start + localIdx
|
|
934
|
-
}));
|
|
935
|
-
});
|
|
936
|
-
const scrollBy = (delta) => {
|
|
937
|
-
const maxOffset = Math.max(0, items().length - viewportHeight());
|
|
938
|
-
setScrollOffset((o) => Math.max(0, Math.min(maxOffset, o + delta)));
|
|
939
|
-
};
|
|
940
|
-
return {
|
|
941
|
-
visibleItems,
|
|
942
|
-
adjustScroll,
|
|
943
|
-
scrollOffset,
|
|
944
|
-
scrollBy
|
|
945
|
-
};
|
|
946
|
-
}
|
|
947
|
-
function getViewportHeight(reservedRows = 8, minHeight = 10) {
|
|
948
|
-
return Math.max(minHeight, (process.stdout.rows || 24) - reservedRows);
|
|
949
|
-
}
|
|
950
|
-
function useMouse(options = {}) {
|
|
951
|
-
const { onScroll, scrollSpeed = 3 } = options;
|
|
952
|
-
const handleInput = (data) => {
|
|
953
|
-
const scrollDir = parseMouseScroll(data);
|
|
954
|
-
if (scrollDir !== 0 && onScroll) onScroll(scrollDir * scrollSpeed);
|
|
955
|
-
};
|
|
956
|
-
(0, solid_js.onMount)(() => {
|
|
957
|
-
enableMouseReporting();
|
|
958
|
-
if (process.stdin.isTTY) process.stdin.setRawMode(true);
|
|
959
|
-
process.stdin.on("data", handleInput);
|
|
960
|
-
});
|
|
961
|
-
(0, solid_js.onCleanup)(() => {
|
|
962
|
-
disableMouseReporting();
|
|
963
|
-
process.stdin.off("data", handleInput);
|
|
964
|
-
});
|
|
965
|
-
}
|
|
966
|
-
exports.Breadcrumb = Breadcrumb;
|
|
967
|
-
exports.Button = Button;
|
|
968
|
-
exports.Card = Card;
|
|
969
|
-
exports.DetailPanel = DetailPanel;
|
|
970
|
-
exports.DrillDownNavigator = DrillDownNavigator;
|
|
971
|
-
exports.LAYOUT_THEMES = LAYOUT_THEMES;
|
|
972
|
-
exports.ListItem = ListItem;
|
|
973
|
-
exports.MarkdownBlock = MarkdownBlock;
|
|
974
|
-
exports.MasterDetail = MasterDetail;
|
|
975
|
-
exports.MasterDetailLayout = MasterDetailLayout;
|
|
976
|
-
exports.MasterDetailTemplate = MasterDetailLayout$1;
|
|
977
|
-
exports.MasterPanel = MasterPanel;
|
|
978
|
-
exports.ShortcutProvider = ShortcutProvider;
|
|
979
|
-
exports.StatCard = StatCard;
|
|
980
|
-
exports.THEMES = THEMES;
|
|
981
|
-
exports.Theme = Theme;
|
|
982
|
-
exports.ThemeProvider = ThemeProvider;
|
|
983
|
-
exports.ToastProvider = ToastProvider;
|
|
984
|
-
exports.TuiProvider = TuiProvider;
|
|
985
|
-
exports.TuiThemes = TuiThemes;
|
|
986
|
-
exports.VirtualList = VirtualList;
|
|
987
|
-
exports.cleanupTerminal = cleanupTerminal;
|
|
988
|
-
exports.clearScreen = clearScreen;
|
|
989
|
-
Object.defineProperty(exports, "createComponent", {
|
|
990
|
-
enumerable: true,
|
|
991
|
-
get: function() {
|
|
992
|
-
return __opentui_solid.createComponent;
|
|
993
|
-
}
|
|
994
|
-
});
|
|
995
|
-
exports.createTuiApp = createTuiApp;
|
|
996
|
-
exports.createVirtualListController = createVirtualListController;
|
|
997
|
-
exports.disableMouseReporting = disableMouseReporting;
|
|
998
|
-
Object.defineProperty(exports, "effect", {
|
|
999
|
-
enumerable: true,
|
|
1000
|
-
get: function() {
|
|
1001
|
-
return __opentui_solid.effect;
|
|
1002
|
-
}
|
|
1003
|
-
});
|
|
1004
|
-
exports.enableMouseReporting = enableMouseReporting;
|
|
1005
|
-
exports.getViewportHeight = getViewportHeight;
|
|
1006
|
-
Object.defineProperty(exports, "insert", {
|
|
1007
|
-
enumerable: true,
|
|
1008
|
-
get: function() {
|
|
1009
|
-
return __opentui_solid.insert;
|
|
1010
|
-
}
|
|
1011
|
-
});
|
|
1012
|
-
Object.defineProperty(exports, "memo", {
|
|
1013
|
-
enumerable: true,
|
|
1014
|
-
get: function() {
|
|
1015
|
-
return __opentui_solid.memo;
|
|
1016
|
-
}
|
|
1017
|
-
});
|
|
1018
|
-
Object.defineProperty(exports, "mergeProps", {
|
|
1019
|
-
enumerable: true,
|
|
1020
|
-
get: function() {
|
|
1021
|
-
return __opentui_solid.mergeProps;
|
|
1022
|
-
}
|
|
1023
|
-
});
|
|
1024
|
-
exports.parseMouseScroll = parseMouseScroll;
|
|
1025
|
-
Object.defineProperty(exports, "render", {
|
|
1026
|
-
enumerable: true,
|
|
1027
|
-
get: function() {
|
|
1028
|
-
return __opentui_solid.render;
|
|
1029
|
-
}
|
|
1030
|
-
});
|
|
1031
|
-
exports.resetAttributes = resetAttributes;
|
|
1032
|
-
exports.restoreStdin = restoreStdin;
|
|
1033
|
-
Object.defineProperty(exports, "spread", {
|
|
1034
|
-
enumerable: true,
|
|
1035
|
-
get: function() {
|
|
1036
|
-
return __opentui_solid.spread;
|
|
1037
|
-
}
|
|
1038
|
-
});
|
|
1039
|
-
exports.switchToAlternateScreen = switchToAlternateScreen;
|
|
1040
|
-
exports.switchToMainScreen = switchToMainScreen;
|
|
1041
|
-
Object.defineProperty(exports, "useKeyboard", {
|
|
1042
|
-
enumerable: true,
|
|
1043
|
-
get: function() {
|
|
1044
|
-
return __opentui_solid.useKeyboard;
|
|
1045
|
-
}
|
|
1046
|
-
});
|
|
1047
|
-
exports.useMouse = useMouse;
|
|
1048
|
-
Object.defineProperty(exports, "useRenderer", {
|
|
1049
|
-
enumerable: true,
|
|
1050
|
-
get: function() {
|
|
1051
|
-
return __opentui_solid.useRenderer;
|
|
1052
|
-
}
|
|
1053
|
-
});
|
|
1054
|
-
exports.useShortcuts = useShortcuts;
|
|
1055
|
-
exports.useTheme = useTheme;
|
|
1056
|
-
exports.useToast = useToast;
|
|
1057
|
-
exports.useTui = useTui;
|
|
1058
|
-
exports.useVirtualScroll = useVirtualScroll;
|
|
1059
|
-
|
|
1060
|
-
//# sourceMappingURL=tui.cjs.map
|