@algolia/wizard 0.4.0 → 0.5.0-rc.45.15
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/main.js +86 -39
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { render } from "ink";
|
|
5
5
|
|
|
6
6
|
// src/ui/App.tsx
|
|
7
|
-
import { Box as Box13, Text as Text13, useApp, useInput as useInput6, useWindowSize as
|
|
7
|
+
import { Box as Box13, Text as Text13, useApp, useInput as useInput6, useWindowSize as useWindowSize7 } from "ink";
|
|
8
8
|
|
|
9
9
|
// src/core/store.ts
|
|
10
10
|
import { create } from "zustand";
|
|
@@ -525,10 +525,20 @@ function NextAction({
|
|
|
525
525
|
}
|
|
526
526
|
|
|
527
527
|
// src/ui/SelectPrompt.tsx
|
|
528
|
-
import { Box as Box4, Text as Text4, useInput } from "ink";
|
|
529
|
-
import { useState as useState3 } from "react";
|
|
528
|
+
import { Box as Box4, Text as Text4, measureElement as measureElement2, useInput, useWindowSize as useWindowSize3 } from "ink";
|
|
529
|
+
import { useLayoutEffect, useRef as useRef2, useState as useState3 } from "react";
|
|
530
530
|
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
531
531
|
var CANCEL = "cancel";
|
|
532
|
+
var ARROW_WIDTH = 4;
|
|
533
|
+
var COLUMN_GAP = 2;
|
|
534
|
+
var BAR_PADDING = 2;
|
|
535
|
+
function fittedWidth(node, columns) {
|
|
536
|
+
let left = 0;
|
|
537
|
+
for (let n = node; n; n = n.parentNode) {
|
|
538
|
+
left += n.yogaNode?.getComputedLeft() ?? 0;
|
|
539
|
+
}
|
|
540
|
+
return Math.max(Math.min(measureElement2(node).width, columns - left), 0);
|
|
541
|
+
}
|
|
532
542
|
function SelectPrompt({
|
|
533
543
|
options,
|
|
534
544
|
onSelect,
|
|
@@ -553,12 +563,29 @@ function SelectPrompt({
|
|
|
553
563
|
if (rows.length > 1) hints.push({ key: "[\u2191] [\u2193]", label: "move" });
|
|
554
564
|
if (multi) hints.push({ key: "[space]", label: "select" });
|
|
555
565
|
hints.push({ key: "[enter]", label: "confirm" });
|
|
556
|
-
const
|
|
557
|
-
const
|
|
566
|
+
const containerRef = useRef2(null);
|
|
567
|
+
const { columns } = useWindowSize3();
|
|
568
|
+
const [width, setWidth] = useState3(columns);
|
|
569
|
+
useLayoutEffect(() => {
|
|
570
|
+
if (containerRef.current) {
|
|
571
|
+
setWidth(fittedWidth(containerRef.current, columns));
|
|
572
|
+
}
|
|
573
|
+
}, [columns]);
|
|
574
|
+
const inner = Math.max(width - BAR_PADDING, 0);
|
|
575
|
+
const labelWidth = Math.min(
|
|
576
|
+
ARROW_WIDTH + (multi ? 2 : 0) + Math.max(0, ...rows.map((opt) => opt.length)) + COLUMN_GAP,
|
|
577
|
+
inner
|
|
578
|
+
);
|
|
579
|
+
const badgeWidth = Math.max(
|
|
558
580
|
0,
|
|
559
|
-
...rows.map((_, i) =>
|
|
581
|
+
...rows.map((_, i) => {
|
|
582
|
+
const s = secondary?.[i];
|
|
583
|
+
return s?.kind === "badge" ? s.value.length : 0;
|
|
584
|
+
})
|
|
560
585
|
);
|
|
561
|
-
const
|
|
586
|
+
const barWidth = Math.min(labelWidth + badgeWidth + BAR_PADDING, width);
|
|
587
|
+
const barLabelWidth = Math.max(barWidth - BAR_PADDING - badgeWidth, 0);
|
|
588
|
+
const textWidth = inner - labelWidth;
|
|
562
589
|
useInput((input, key) => {
|
|
563
590
|
if (rows.length === 0) return;
|
|
564
591
|
if (key.upArrow || input === "k") {
|
|
@@ -582,7 +609,7 @@ function SelectPrompt({
|
|
|
582
609
|
}
|
|
583
610
|
}
|
|
584
611
|
});
|
|
585
|
-
return /* @__PURE__ */ jsxs3(Box4, { flexDirection: "column", gap: 1, children: [
|
|
612
|
+
return /* @__PURE__ */ jsx4(Box4, { ref: containerRef, flexGrow: 1, children: /* @__PURE__ */ jsxs3(Box4, { flexDirection: "column", gap: 1, width, children: [
|
|
586
613
|
error && /* @__PURE__ */ jsx4(Text4, { color: COLORS.danger, children: error }),
|
|
587
614
|
messages?.map((m, i) => /* @__PURE__ */ jsx4(Text4, { color: COLORS.muted, children: m }, `msg-${i}`)),
|
|
588
615
|
table && /* @__PURE__ */ jsx4(Table, { columns: table.columns, rows: table.rows }),
|
|
@@ -596,29 +623,36 @@ function SelectPrompt({
|
|
|
596
623
|
const bullet = multi && !isCancel ? checked.has(i) ? "\u25CF " : "\u25CB " : "";
|
|
597
624
|
const sec = isCancel ? void 0 : secondary?.[i];
|
|
598
625
|
const labelColor = highlighted ? COLORS.highlight.fg : void 0;
|
|
599
|
-
const label = /* @__PURE__ */ jsxs3(Text4, { color: labelColor, children: [
|
|
626
|
+
const label = /* @__PURE__ */ jsxs3(Text4, { color: labelColor, wrap: "truncate", children: [
|
|
600
627
|
highlighted ? "\u276F " : " ",
|
|
601
628
|
bullet,
|
|
602
629
|
option
|
|
603
630
|
] });
|
|
631
|
+
const isText = sec?.kind === "text";
|
|
604
632
|
return /* @__PURE__ */ jsxs3(
|
|
605
633
|
Box4,
|
|
606
634
|
{
|
|
607
|
-
width:
|
|
635
|
+
width: isText ? "100%" : barWidth,
|
|
608
636
|
paddingX: 1,
|
|
609
637
|
paddingY: 1,
|
|
610
638
|
backgroundColor: highlighted ? COLORS.highlight.bg : void 0,
|
|
611
639
|
children: [
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
640
|
+
/* @__PURE__ */ jsx4(Box4, { width: isText ? labelWidth : barLabelWidth, children: label }),
|
|
641
|
+
isText && textWidth > 0 && /* @__PURE__ */ jsx4(Box4, { width: textWidth, children: /* @__PURE__ */ jsx4(
|
|
642
|
+
Text4,
|
|
643
|
+
{
|
|
644
|
+
wrap: "truncate",
|
|
645
|
+
color: highlighted ? COLORS.primary : COLORS.muted,
|
|
646
|
+
children: sec.value
|
|
647
|
+
}
|
|
648
|
+
) }),
|
|
649
|
+
sec?.kind === "badge" && /* @__PURE__ */ jsx4(Box4, { width: badgeWidth, justifyContent: "flex-end", children: /* @__PURE__ */ jsx4(Text4, { color: COLORS.badge, wrap: "truncate", children: sec.value }) })
|
|
616
650
|
]
|
|
617
651
|
},
|
|
618
652
|
`row-${i}`
|
|
619
653
|
);
|
|
620
654
|
}) }),
|
|
621
|
-
/* @__PURE__ */ jsx4(
|
|
655
|
+
/* @__PURE__ */ jsx4(Text4, { children: hints.map(({ key, label }, i) => /* @__PURE__ */ jsxs3(Text4, { children: [
|
|
622
656
|
i > 0 ? " " : "",
|
|
623
657
|
/* @__PURE__ */ jsx4(Text4, { color: COLORS.primary, children: key }),
|
|
624
658
|
/* @__PURE__ */ jsxs3(Text4, { color: COLORS.dim, children: [
|
|
@@ -626,7 +660,7 @@ function SelectPrompt({
|
|
|
626
660
|
label
|
|
627
661
|
] })
|
|
628
662
|
] }, label)) })
|
|
629
|
-
] });
|
|
663
|
+
] }) });
|
|
630
664
|
}
|
|
631
665
|
|
|
632
666
|
// src/ui/PromptInput.tsx
|
|
@@ -749,7 +783,7 @@ function PromptInput() {
|
|
|
749
783
|
// src/ui/Welcome.tsx
|
|
750
784
|
import { dirname as dirname2, join as join3 } from "node:path";
|
|
751
785
|
import { fileURLToPath } from "node:url";
|
|
752
|
-
import { Box as Box6, Spacer, Text as Text6, useInput as useInput3, useWindowSize as
|
|
786
|
+
import { Box as Box6, Spacer, Text as Text6, useInput as useInput3, useWindowSize as useWindowSize4 } from "ink";
|
|
753
787
|
|
|
754
788
|
// src/ui/copy/welcome.ts
|
|
755
789
|
var sidebarItems = [
|
|
@@ -797,7 +831,7 @@ function SidebarItem({
|
|
|
797
831
|
function Welcome() {
|
|
798
832
|
const confirmStart = useWizard((s) => s.confirmStart);
|
|
799
833
|
const openLearnMore = useWizard((s) => s.openLearnMore);
|
|
800
|
-
const { rows } =
|
|
834
|
+
const { rows } = useWindowSize4();
|
|
801
835
|
useInput3((input) => {
|
|
802
836
|
if (input === " ") confirmStart();
|
|
803
837
|
else if (input === "i") openLearnMore();
|
|
@@ -865,7 +899,7 @@ function Welcome() {
|
|
|
865
899
|
|
|
866
900
|
// src/ui/LearnMore.tsx
|
|
867
901
|
import { Fragment as Fragment2 } from "react";
|
|
868
|
-
import { Box as Box7, Text as Text7, useInput as useInput4, useWindowSize as
|
|
902
|
+
import { Box as Box7, Text as Text7, useInput as useInput4, useWindowSize as useWindowSize5 } from "ink";
|
|
869
903
|
|
|
870
904
|
// src/ui/copy/learn-more.ts
|
|
871
905
|
var accessIntro = "Everything runs locally on your machine. Nothing is written or sent without an explicit yes from you.";
|
|
@@ -929,7 +963,7 @@ function NeverLine({
|
|
|
929
963
|
function LearnMore() {
|
|
930
964
|
const confirmStart = useWizard((s) => s.confirmStart);
|
|
931
965
|
const backToHome = useWizard((s) => s.backToHome);
|
|
932
|
-
const { columns } =
|
|
966
|
+
const { columns } = useWindowSize5();
|
|
933
967
|
const dividerWidth = Math.max(0, columns - PADDING_X * 2);
|
|
934
968
|
useInput4((input, key) => {
|
|
935
969
|
if (key.escape) backToHome();
|
|
@@ -1142,8 +1176,8 @@ function Ribbon() {
|
|
|
1142
1176
|
import { useState as useState6 } from "react";
|
|
1143
1177
|
|
|
1144
1178
|
// src/ui/Logs.tsx
|
|
1145
|
-
import { useLayoutEffect, useRef as
|
|
1146
|
-
import { Box as Box12, Text as Text12, measureElement as
|
|
1179
|
+
import { useLayoutEffect as useLayoutEffect2, useRef as useRef3, useState as useState5 } from "react";
|
|
1180
|
+
import { Box as Box12, Text as Text12, measureElement as measureElement3, useInput as useInput5, useWindowSize as useWindowSize6 } from "ink";
|
|
1147
1181
|
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1148
1182
|
var KIND_COLOR = {
|
|
1149
1183
|
tool: COLORS.primary,
|
|
@@ -1174,15 +1208,15 @@ function formatTimestamp(ms) {
|
|
|
1174
1208
|
}
|
|
1175
1209
|
function Logs() {
|
|
1176
1210
|
const logs = useWizard((s) => s.logs);
|
|
1177
|
-
const { rows, columns } =
|
|
1178
|
-
const viewportRef =
|
|
1211
|
+
const { rows, columns } = useWindowSize6();
|
|
1212
|
+
const viewportRef = useRef3(null);
|
|
1179
1213
|
const [viewportHeight, setViewportHeight] = useState5(0);
|
|
1180
1214
|
const [viewportWidth, setViewportWidth] = useState5(0);
|
|
1181
1215
|
const [scrollOffset, setScrollOffset] = useState5(0);
|
|
1182
|
-
const prevMaxOffsetRef =
|
|
1183
|
-
|
|
1216
|
+
const prevMaxOffsetRef = useRef3(0);
|
|
1217
|
+
useLayoutEffect2(() => {
|
|
1184
1218
|
if (!viewportRef.current) return;
|
|
1185
|
-
const { width, height } =
|
|
1219
|
+
const { width, height } = measureElement3(viewportRef.current);
|
|
1186
1220
|
setViewportHeight(height);
|
|
1187
1221
|
setViewportWidth(width);
|
|
1188
1222
|
}, [rows, columns, logs.length === 0]);
|
|
@@ -1197,7 +1231,7 @@ function Logs() {
|
|
|
1197
1231
|
}
|
|
1198
1232
|
const capacityAtBottom = logs.length > viewportHeight ? Math.max(viewportHeight - 1, 0) : viewportHeight;
|
|
1199
1233
|
const maxOffset = Math.max(logs.length - capacityAtBottom, 0);
|
|
1200
|
-
|
|
1234
|
+
useLayoutEffect2(() => {
|
|
1201
1235
|
const wasAtBottom = scrollOffset >= prevMaxOffsetRef.current;
|
|
1202
1236
|
prevMaxOffsetRef.current = maxOffset;
|
|
1203
1237
|
setScrollOffset((o) => wasAtBottom ? maxOffset : Math.min(o, maxOffset));
|
|
@@ -1270,7 +1304,7 @@ import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
|
1270
1304
|
function App() {
|
|
1271
1305
|
const { phase, error, homeScreen, currentStepIndex, steps, inputReq } = useWizard();
|
|
1272
1306
|
const { exit } = useApp();
|
|
1273
|
-
const { columns, rows } =
|
|
1307
|
+
const { columns, rows } = useWindowSize7();
|
|
1274
1308
|
const [showLogs, setShowLogs] = useState6(false);
|
|
1275
1309
|
const finished = phase === "done" || phase === "error";
|
|
1276
1310
|
const currentStep = steps[currentStepIndex];
|
|
@@ -1324,15 +1358,28 @@ function App() {
|
|
|
1324
1358
|
width: "100%",
|
|
1325
1359
|
justifyContent: "space-between",
|
|
1326
1360
|
children: [
|
|
1327
|
-
showLogs ? /* @__PURE__ */ jsx13(Logs, {}) :
|
|
1328
|
-
/*
|
|
1329
|
-
/* @__PURE__ */
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1361
|
+
showLogs ? /* @__PURE__ */ jsx13(Logs, {}) : (
|
|
1362
|
+
/* Fill the width beside the sidebar; row layout only (would grow vertically when stacked). */
|
|
1363
|
+
/* @__PURE__ */ jsxs12(
|
|
1364
|
+
Box13,
|
|
1365
|
+
{
|
|
1366
|
+
flexDirection: "column",
|
|
1367
|
+
paddingX: 4,
|
|
1368
|
+
paddingY: 2,
|
|
1369
|
+
width: showSidebar ? 70 : "100%",
|
|
1370
|
+
flexGrow: showSidebar ? 1 : 0,
|
|
1371
|
+
children: [
|
|
1372
|
+
/* @__PURE__ */ jsx13(Notices, {}),
|
|
1373
|
+
/* @__PURE__ */ jsx13(PromptInput, {}),
|
|
1374
|
+
phase === "running" && showSidebar && /* @__PURE__ */ jsx13(Box13, { marginTop: 1, children: /* @__PURE__ */ jsx13(CurrentStep, {}) }),
|
|
1375
|
+
phase === "error" && error && /* @__PURE__ */ jsx13(Box13, { marginTop: 1, children: /* @__PURE__ */ jsxs12(Text13, { color: COLORS.status.error, children: [
|
|
1376
|
+
"\u2716 ",
|
|
1377
|
+
error
|
|
1378
|
+
] }) })
|
|
1379
|
+
]
|
|
1380
|
+
}
|
|
1381
|
+
)
|
|
1382
|
+
),
|
|
1336
1383
|
showSidebar ? /* @__PURE__ */ jsx13(Sidebar, {}) : /* @__PURE__ */ jsx13(Ribbon, {})
|
|
1337
1384
|
]
|
|
1338
1385
|
}
|
|
@@ -2648,7 +2695,7 @@ async function runAnalysis(mode, extraInstructions = []) {
|
|
|
2648
2695
|
// package.json
|
|
2649
2696
|
var package_default = {
|
|
2650
2697
|
name: "@algolia/wizard",
|
|
2651
|
-
version: "0.
|
|
2698
|
+
version: "0.5.0-rc.45.15",
|
|
2652
2699
|
description: "Magically implement Algolia functionality in your codebase",
|
|
2653
2700
|
type: "module",
|
|
2654
2701
|
engines: {
|