@alcyone-labs/arg-parser 2.13.3 → 2.13.4
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/tui/index.d.ts +1 -1
- package/dist/tui.cjs +72 -131
- package/dist/tui.cjs.map +1 -1
- package/dist/tui.mjs +72 -131
- package/dist/tui.mjs.map +1 -1
- package/package.json +1 -1
package/dist/tui/index.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export interface TuiAppConfig {
|
|
|
37
37
|
export declare function createTuiApp(
|
|
38
38
|
App: () => JSX.Element,
|
|
39
39
|
config?: TuiAppConfig
|
|
40
|
-
): void
|
|
40
|
+
): Promise<void>;
|
|
41
41
|
|
|
42
42
|
// =============================================================================
|
|
43
43
|
// TUI Provider
|
package/dist/tui.cjs
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const solid = require("@opentui/solid");
|
|
4
4
|
const solidJs = require("solid-js");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
);
|
|
5
|
+
const web = require("solid-js/web");
|
|
6
|
+
const EXIT_GUARD_STATE_KEY = /* @__PURE__ */ Symbol.for("@alcyone-labs/arg-parser/tui/ExitGuardState");
|
|
8
7
|
function getExitGuardState() {
|
|
9
8
|
return process[EXIT_GUARD_STATE_KEY];
|
|
10
9
|
}
|
|
@@ -336,6 +335,7 @@ function createTuiApp(App, config = {}) {
|
|
|
336
335
|
{ onDestroy }
|
|
337
336
|
);
|
|
338
337
|
}
|
|
338
|
+
var _tmpl$$4 = ['<box width="100%" height="100%">', "</box>"];
|
|
339
339
|
const TuiContext = solidJs.createContext();
|
|
340
340
|
function useTui() {
|
|
341
341
|
const context = solidJs.useContext(TuiContext);
|
|
@@ -347,10 +347,8 @@ function useTui() {
|
|
|
347
347
|
function TuiProvider(props) {
|
|
348
348
|
const renderer = solid.useRenderer();
|
|
349
349
|
const reservedRows = props.reservedRows ?? 8;
|
|
350
|
-
|
|
351
|
-
const [viewportHeight, setViewportHeight] = solidJs.createSignal(
|
|
352
|
-
Math.max(10, renderer.height - reservedRows)
|
|
353
|
-
);
|
|
350
|
+
props.scrollSpeed ?? 3;
|
|
351
|
+
const [viewportHeight, setViewportHeight] = solidJs.createSignal(Math.max(10, renderer.height - reservedRows));
|
|
354
352
|
const [viewportWidth, setViewportWidth] = solidJs.createSignal(renderer.width);
|
|
355
353
|
const exit = (code = 0) => {
|
|
356
354
|
process.exitCode = code;
|
|
@@ -360,17 +358,6 @@ function TuiProvider(props) {
|
|
|
360
358
|
setViewportHeight(Math.max(10, height - reservedRows));
|
|
361
359
|
setViewportWidth(width);
|
|
362
360
|
};
|
|
363
|
-
const handleMouseScroll = (event) => {
|
|
364
|
-
if (!props.onScroll || !event.scroll) {
|
|
365
|
-
return;
|
|
366
|
-
}
|
|
367
|
-
const sign = event.scroll.direction === "up" ? -1 : event.scroll.direction === "down" ? 1 : 0;
|
|
368
|
-
if (sign === 0) {
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
|
-
const delta = event.scroll.delta || 1;
|
|
372
|
-
props.onScroll(sign * delta * scrollSpeed);
|
|
373
|
-
};
|
|
374
361
|
solidJs.onMount(() => {
|
|
375
362
|
renderer.on("resize", handleResize);
|
|
376
363
|
});
|
|
@@ -398,15 +385,7 @@ function TuiProvider(props) {
|
|
|
398
385
|
get children() {
|
|
399
386
|
return solid.createComponent(ToastProvider, {
|
|
400
387
|
get children() {
|
|
401
|
-
return
|
|
402
|
-
"box",
|
|
403
|
-
{
|
|
404
|
-
width: "100%",
|
|
405
|
-
height: "100%",
|
|
406
|
-
onMouseScroll: handleMouseScroll
|
|
407
|
-
},
|
|
408
|
-
props.children
|
|
409
|
-
);
|
|
388
|
+
return web.ssr(_tmpl$$4, web.escape(props.children));
|
|
410
389
|
}
|
|
411
390
|
});
|
|
412
391
|
}
|
|
@@ -418,18 +397,29 @@ function TuiProvider(props) {
|
|
|
418
397
|
}
|
|
419
398
|
});
|
|
420
399
|
}
|
|
400
|
+
var _tmpl$$3 = ['<box height="1" paddingleft="2">', "</box>"], _tmpl$2$3 = ["<text", " bold>", "</text>"], _tmpl$3$2 = ["<text", "> ", " </text>"];
|
|
421
401
|
function Breadcrumb(props) {
|
|
422
|
-
const {
|
|
402
|
+
const {
|
|
403
|
+
current: theme
|
|
404
|
+
} = useTheme();
|
|
423
405
|
const separator = props.separator ?? "›";
|
|
424
406
|
const accentColor = () => props.accentColor ?? theme().colors.accent;
|
|
425
407
|
const mutedColor = () => props.mutedColor ?? theme().colors.muted;
|
|
426
|
-
return
|
|
408
|
+
return web.ssr(_tmpl$$3, web.escape(web.createComponent(solidJs.For, {
|
|
409
|
+
get each() {
|
|
410
|
+
return props.segments;
|
|
411
|
+
},
|
|
412
|
+
children: (segment, idx) => [idx() > 0 && web.ssr(_tmpl$3$2, web.ssrAttribute("color", web.escape(mutedColor(), true), false), web.escape(separator)), web.ssr(_tmpl$2$3, web.ssrAttribute("color", web.escape(accentColor(), true), false), web.escape(segment))]
|
|
413
|
+
})));
|
|
427
414
|
}
|
|
415
|
+
var _tmpl$$2 = ['<box height="1"', "><text", ">", "", "</text></box>"], _tmpl$2$2 = ["<text bold", ' marginBottom="1">', " (", "/", ")</text>"], _tmpl$3$1 = ['<box flexdirection="column" flexgrow="1">', "", "</box>"];
|
|
428
416
|
function unwrap(value) {
|
|
429
417
|
return typeof value === "function" ? value() : value;
|
|
430
418
|
}
|
|
431
419
|
function VirtualList(props) {
|
|
432
|
-
const {
|
|
420
|
+
const {
|
|
421
|
+
current: theme
|
|
422
|
+
} = useTheme();
|
|
433
423
|
const [scrollOffset, setScrollOffset] = solidJs.createSignal(0);
|
|
434
424
|
const items = () => unwrap(props.items);
|
|
435
425
|
const selectedIndex = () => unwrap(props.selectedIndex);
|
|
@@ -448,17 +438,25 @@ function VirtualList(props) {
|
|
|
448
438
|
const defaultRenderItem = (item, index, selected) => {
|
|
449
439
|
const label = props.getLabel ? props.getLabel(item) : String(item);
|
|
450
440
|
const t = theme();
|
|
451
|
-
return
|
|
452
|
-
"box",
|
|
453
|
-
{
|
|
454
|
-
height: 1,
|
|
455
|
-
backgroundColor: selected ? t.colors.selection : void 0
|
|
456
|
-
},
|
|
457
|
-
/* @__PURE__ */ React.createElement("text", { color: selected ? t.colors.background : t.colors.text }, showIndicator ? selected ? "› " : " " : "", label)
|
|
458
|
-
);
|
|
441
|
+
return web.ssr(_tmpl$$2, web.ssrAttribute("backgroundcolor", selected ? web.escape(t.colors.selection, true) : web.escape(void 0, true), false), web.ssrAttribute("color", selected ? web.escape(t.colors.background, true) : web.escape(t.colors.text, true), false), showIndicator ? selected ? "› " : " " : "", web.escape(label));
|
|
459
442
|
};
|
|
460
443
|
const renderItem = props.renderItem ?? defaultRenderItem;
|
|
461
|
-
return
|
|
444
|
+
return web.ssr(_tmpl$3$1, web.escape(web.createComponent(solidJs.Show, {
|
|
445
|
+
get when() {
|
|
446
|
+
return props.title;
|
|
447
|
+
},
|
|
448
|
+
get children() {
|
|
449
|
+
return web.ssr(_tmpl$2$2, web.ssrAttribute("color", web.escape(theme().colors.text, true), false), web.escape(props.title), web.escape(selectedIndex()) + 1, web.escape(items().length));
|
|
450
|
+
}
|
|
451
|
+
})), web.escape(web.createComponent(solidJs.For, {
|
|
452
|
+
get each() {
|
|
453
|
+
return visibleItems();
|
|
454
|
+
},
|
|
455
|
+
children: ({
|
|
456
|
+
item,
|
|
457
|
+
globalIndex
|
|
458
|
+
}) => renderItem(item, globalIndex, globalIndex === selectedIndex())
|
|
459
|
+
})));
|
|
462
460
|
}
|
|
463
461
|
function createVirtualListController(items, selectedIndex, setSelectedIndex, viewportHeight) {
|
|
464
462
|
const [scrollOffset, setScrollOffset] = solidJs.createSignal(0);
|
|
@@ -485,54 +483,39 @@ function createVirtualListController(items, selectedIndex, setSelectedIndex, vie
|
|
|
485
483
|
setSelectedIndex(newIdx);
|
|
486
484
|
adjustScroll(newIdx);
|
|
487
485
|
};
|
|
488
|
-
return {
|
|
486
|
+
return {
|
|
487
|
+
scrollOffset,
|
|
488
|
+
adjustScroll,
|
|
489
|
+
scrollBy,
|
|
490
|
+
selectPrevious,
|
|
491
|
+
selectNext
|
|
492
|
+
};
|
|
489
493
|
}
|
|
494
|
+
var _tmpl$$1 = ['<box height="1"', "><text", "> ", "</text></box>"], _tmpl$2$1 = ['<box width="100%" height="100%" flexdirection="column"', '><box height="3" borderstyle="single"', ' justifycontent="center" alignitems="center"><text bold', ">", "", " </text></box>", '<box flexgrow="1" flexdirection="row"><box', ' borderstyle="single"', ' flexdirection="column" padding="1">', '</box><box flexgrow="1" borderstyle="single"', ' flexdirection="column" padding="2">', "</box></box>", "</box>"];
|
|
490
495
|
function MasterDetail(props) {
|
|
491
|
-
const {
|
|
496
|
+
const {
|
|
497
|
+
current: theme
|
|
498
|
+
} = useTheme();
|
|
492
499
|
const masterWidth = props.masterWidth ?? "35%";
|
|
493
|
-
return
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
width: "100%",
|
|
497
|
-
height: "100%",
|
|
498
|
-
flexDirection: "column",
|
|
499
|
-
backgroundColor: theme().colors.background
|
|
500
|
+
return web.ssr(_tmpl$2$1, web.ssrAttribute("backgroundcolor", web.escape(theme().colors.background, true), false), web.ssrAttribute("bordercolor", web.escape(theme().colors.accent, true), false), web.ssrAttribute("color", web.escape(theme().colors.accent, true), false), props.headerIcon ? ` ${web.escape(props.headerIcon)} ` : " ", web.escape(props.header), web.escape(web.createComponent(solidJs.Show, {
|
|
501
|
+
get when() {
|
|
502
|
+
return props.breadcrumb && props.breadcrumb.length > 0;
|
|
500
503
|
},
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
width: masterWidth,
|
|
517
|
-
borderStyle: "single",
|
|
518
|
-
borderColor: theme().colors.border,
|
|
519
|
-
flexDirection: "column",
|
|
520
|
-
padding: 1
|
|
521
|
-
},
|
|
522
|
-
props.master
|
|
523
|
-
), /* @__PURE__ */ React.createElement(
|
|
524
|
-
"box",
|
|
525
|
-
{
|
|
526
|
-
flexGrow: 1,
|
|
527
|
-
borderStyle: "single",
|
|
528
|
-
borderColor: theme().colors.border,
|
|
529
|
-
flexDirection: "column",
|
|
530
|
-
padding: 2
|
|
531
|
-
},
|
|
532
|
-
props.detail
|
|
533
|
-
)),
|
|
534
|
-
/* @__PURE__ */ React.createElement(solidJs.Show, { when: props.footer }, /* @__PURE__ */ React.createElement("box", { height: 1, backgroundColor: theme().colors.background }, /* @__PURE__ */ React.createElement("text", { color: theme().colors.muted }, " ", props.footer)))
|
|
535
|
-
);
|
|
504
|
+
get children() {
|
|
505
|
+
return web.createComponent(Breadcrumb, {
|
|
506
|
+
get segments() {
|
|
507
|
+
return props.breadcrumb;
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
})), web.ssrAttribute("width", web.escape(masterWidth, true), false), web.ssrAttribute("bordercolor", web.escape(theme().colors.border, true), false), web.escape(props.master), web.ssrAttribute("bordercolor", web.escape(theme().colors.border, true), false), web.escape(props.detail), web.escape(web.createComponent(solidJs.Show, {
|
|
512
|
+
get when() {
|
|
513
|
+
return props.footer;
|
|
514
|
+
},
|
|
515
|
+
get children() {
|
|
516
|
+
return web.ssr(_tmpl$$1, web.ssrAttribute("backgroundcolor", web.escape(theme().colors.background, true), false), web.ssrAttribute("color", web.escape(theme().colors.muted, true), false), web.escape(props.footer));
|
|
517
|
+
}
|
|
518
|
+
})));
|
|
536
519
|
}
|
|
537
520
|
function parseWidth(width) {
|
|
538
521
|
if (width === void 0) return "30%";
|
|
@@ -866,6 +849,7 @@ function Button(props) {
|
|
|
866
849
|
]
|
|
867
850
|
};
|
|
868
851
|
}
|
|
852
|
+
var _tmpl$ = ['<box width="100%" height="100%" flexdirection="column"', '><box height="3" borderstyle="single"', ' justifycontent="center" alignitems="center"><text bold', "> ", " </text></box>", '<box flexgrow="1" flexdirection="row">', "</box>", "</box>"], _tmpl$2 = ['<box height="1" paddingleft="2"', ">", "</box>"], _tmpl$3 = ["<text", " bold>", "</text>"], _tmpl$4 = ["<text", "> › </text>"], _tmpl$5 = ['<box height="1"', "><text", "> ", "</text></box>"], _tmpl$6 = ["<box", ' borderstyle="single"', ' flexdirection="column" padding="1">', "</box>"], _tmpl$7 = ['<box flexgrow="1" borderstyle="single"', ' flexdirection="column" padding="2">', "</box>"], _tmpl$8 = ['<box height="1"', "><text", ">", "", "</text></box>"];
|
|
869
853
|
const LAYOUT_THEMES = {
|
|
870
854
|
dark: {
|
|
871
855
|
bg: "#0d0d0d",
|
|
@@ -903,68 +887,25 @@ const LAYOUT_THEMES = {
|
|
|
903
887
|
};
|
|
904
888
|
function resolveTheme(theme) {
|
|
905
889
|
if (!theme) return LAYOUT_THEMES.dark;
|
|
906
|
-
if (typeof theme === "string")
|
|
907
|
-
return LAYOUT_THEMES[theme] ?? LAYOUT_THEMES.dark;
|
|
890
|
+
if (typeof theme === "string") return LAYOUT_THEMES[theme] ?? LAYOUT_THEMES.dark;
|
|
908
891
|
return theme;
|
|
909
892
|
}
|
|
910
893
|
function MasterDetailLayout(props) {
|
|
911
894
|
const t = resolveTheme(props.theme);
|
|
912
895
|
props.masterWidth ?? "35%";
|
|
913
|
-
return
|
|
914
|
-
"box",
|
|
915
|
-
{
|
|
916
|
-
width: "100%",
|
|
917
|
-
height: "100%",
|
|
918
|
-
flexDirection: "column",
|
|
919
|
-
backgroundColor: t.bg
|
|
920
|
-
},
|
|
921
|
-
/* @__PURE__ */ React.createElement(
|
|
922
|
-
"box",
|
|
923
|
-
{
|
|
924
|
-
height: 3,
|
|
925
|
-
borderStyle: "single",
|
|
926
|
-
borderColor: t.accent,
|
|
927
|
-
justifyContent: "center",
|
|
928
|
-
alignItems: "center"
|
|
929
|
-
},
|
|
930
|
-
/* @__PURE__ */ React.createElement("text", { bold: true, color: t.accent }, " ", props.header, " ")
|
|
931
|
-
),
|
|
932
|
-
props.breadcrumb && props.breadcrumb.length > 0 && /* @__PURE__ */ React.createElement("box", { height: 1, paddingLeft: 2, backgroundColor: t.bg }, props.breadcrumb.map((segment, idx) => /* @__PURE__ */ React.createElement(React.Fragment, null, idx > 0 && /* @__PURE__ */ React.createElement("text", { color: t.muted }, " › "), /* @__PURE__ */ React.createElement("text", { color: t.accent, bold: true }, segment)))),
|
|
933
|
-
/* @__PURE__ */ React.createElement("box", { flexGrow: 1, flexDirection: "row" }, props.children),
|
|
934
|
-
props.footer && /* @__PURE__ */ React.createElement("box", { height: 1, backgroundColor: t.bg }, /* @__PURE__ */ React.createElement("text", { color: t.muted }, " ", props.footer))
|
|
935
|
-
);
|
|
896
|
+
return web.ssr(_tmpl$, web.ssrAttribute("backgroundcolor", web.escape(t.bg, true), false), web.ssrAttribute("bordercolor", web.escape(t.accent, true), false), web.ssrAttribute("color", web.escape(t.accent, true), false), web.escape(props.header), props.breadcrumb && props.breadcrumb.length > 0 && web.ssr(_tmpl$2, web.ssrAttribute("backgroundcolor", web.escape(t.bg, true), false), web.escape(props.breadcrumb.map((segment, idx) => [idx > 0 && web.ssr(_tmpl$4, web.ssrAttribute("color", web.escape(t.muted, true), false)), web.ssr(_tmpl$3, web.ssrAttribute("color", web.escape(t.accent, true), false), web.escape(segment))]))), web.escape(props.children), props.footer && web.ssr(_tmpl$5, web.ssrAttribute("backgroundcolor", web.escape(t.bg, true), false), web.ssrAttribute("color", web.escape(t.muted, true), false), web.escape(props.footer)));
|
|
936
897
|
}
|
|
937
898
|
function MasterPanel(props) {
|
|
938
899
|
const t = resolveTheme(props.theme);
|
|
939
|
-
return
|
|
940
|
-
"box",
|
|
941
|
-
{
|
|
942
|
-
width: props.width ?? "35%",
|
|
943
|
-
borderStyle: "single",
|
|
944
|
-
borderColor: t.border,
|
|
945
|
-
flexDirection: "column",
|
|
946
|
-
padding: 1
|
|
947
|
-
},
|
|
948
|
-
props.children
|
|
949
|
-
);
|
|
900
|
+
return web.ssr(_tmpl$6, web.ssrAttribute("width", web.escape(props.width, true) ?? "35%", false), web.ssrAttribute("bordercolor", web.escape(t.border, true), false), web.escape(props.children));
|
|
950
901
|
}
|
|
951
902
|
function DetailPanel(props) {
|
|
952
903
|
const t = resolveTheme(props.theme);
|
|
953
|
-
return
|
|
954
|
-
"box",
|
|
955
|
-
{
|
|
956
|
-
flexGrow: 1,
|
|
957
|
-
borderStyle: "single",
|
|
958
|
-
borderColor: t.border,
|
|
959
|
-
flexDirection: "column",
|
|
960
|
-
padding: 2
|
|
961
|
-
},
|
|
962
|
-
props.children
|
|
963
|
-
);
|
|
904
|
+
return web.ssr(_tmpl$7, web.ssrAttribute("bordercolor", web.escape(t.border, true), false), web.escape(props.children));
|
|
964
905
|
}
|
|
965
906
|
function ListItem(props) {
|
|
966
907
|
const t = resolveTheme(props.theme);
|
|
967
|
-
return
|
|
908
|
+
return web.ssr(_tmpl$8, web.ssrAttribute("backgroundcolor", props.selected ? web.escape(t.selection, true) : web.escape(void 0, true), false), web.ssrAttribute("color", props.selected ? web.escape(t.selectionFg, true) : web.escape(t.fg, true), false), props.selected ? "› " : " ", web.escape(props.label));
|
|
968
909
|
}
|
|
969
910
|
function useVirtualScroll(items, _selectedIdx, viewportHeight) {
|
|
970
911
|
const [scrollOffset, setScrollOffset] = solidJs.createSignal(0);
|