open-research 0.1.20 → 0.1.21
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/cli.js +42 -23
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -811,7 +811,7 @@ function formatDateTime(value) {
|
|
|
811
811
|
}
|
|
812
812
|
|
|
813
813
|
// src/lib/cli/version.ts
|
|
814
|
-
var PACKAGE_VERSION = "0.1.
|
|
814
|
+
var PACKAGE_VERSION = "0.1.21";
|
|
815
815
|
function getPackageVersion() {
|
|
816
816
|
return PACKAGE_VERSION;
|
|
817
817
|
}
|
|
@@ -1424,16 +1424,26 @@ function TextInput({
|
|
|
1424
1424
|
cursorToEnd = 0
|
|
1425
1425
|
}) {
|
|
1426
1426
|
const [cursorOffset, setCursorOffset] = useState(originalValue.length);
|
|
1427
|
+
const valueRef = useRef(originalValue);
|
|
1428
|
+
const cursorOffsetRef = useRef(originalValue.length);
|
|
1427
1429
|
const pasteMapRef = useRef(/* @__PURE__ */ new Map());
|
|
1428
1430
|
const pasteCounterRef = useRef(0);
|
|
1431
|
+
useEffect(() => {
|
|
1432
|
+
valueRef.current = originalValue;
|
|
1433
|
+
}, [originalValue]);
|
|
1434
|
+
useEffect(() => {
|
|
1435
|
+
cursorOffsetRef.current = cursorOffset;
|
|
1436
|
+
}, [cursorOffset]);
|
|
1429
1437
|
useEffect(() => {
|
|
1430
1438
|
if (!focus || !showCursor) return;
|
|
1431
1439
|
if (cursorOffset > originalValue.length) {
|
|
1440
|
+
cursorOffsetRef.current = originalValue.length;
|
|
1432
1441
|
setCursorOffset(originalValue.length);
|
|
1433
1442
|
}
|
|
1434
1443
|
}, [originalValue, focus, showCursor]);
|
|
1435
1444
|
useEffect(() => {
|
|
1436
1445
|
if (cursorToEnd > 0) {
|
|
1446
|
+
cursorOffsetRef.current = originalValue.length;
|
|
1437
1447
|
setCursorOffset(originalValue.length);
|
|
1438
1448
|
}
|
|
1439
1449
|
}, [cursorToEnd]);
|
|
@@ -1490,6 +1500,8 @@ function TextInput({
|
|
|
1490
1500
|
const renderedPlaceholder = showCursor && focus && placeholder.length > 0 ? source_default.inverse(placeholder[0]) + source_default.grey(placeholder.slice(1)) : placeholder ? source_default.grey(placeholder) : void 0;
|
|
1491
1501
|
useInput(
|
|
1492
1502
|
(input2, key) => {
|
|
1503
|
+
const currentValue = valueRef.current;
|
|
1504
|
+
const currentCursor = cursorOffsetRef.current;
|
|
1493
1505
|
if (key.ctrl && input2 === "c" || key.shift && key.tab) {
|
|
1494
1506
|
return;
|
|
1495
1507
|
}
|
|
@@ -1506,54 +1518,56 @@ function TextInput({
|
|
|
1506
1518
|
return;
|
|
1507
1519
|
}
|
|
1508
1520
|
if (key.return && key.shift || key.return && key.meta) {
|
|
1509
|
-
const inserted =
|
|
1510
|
-
|
|
1521
|
+
const inserted = currentValue.slice(0, currentCursor) + "\n" + currentValue.slice(currentCursor);
|
|
1522
|
+
cursorOffsetRef.current = currentCursor + 1;
|
|
1523
|
+
valueRef.current = inserted;
|
|
1524
|
+
setCursorOffset(currentCursor + 1);
|
|
1511
1525
|
onChange(inserted);
|
|
1512
1526
|
return;
|
|
1513
1527
|
}
|
|
1514
1528
|
if (key.return) {
|
|
1515
|
-
const expanded = expandPasteMarkers(
|
|
1529
|
+
const expanded = expandPasteMarkers(currentValue, pasteMapRef.current);
|
|
1516
1530
|
onSubmit?.(expanded);
|
|
1517
1531
|
return;
|
|
1518
1532
|
}
|
|
1519
|
-
let nextValue =
|
|
1520
|
-
let nextCursor =
|
|
1533
|
+
let nextValue = currentValue;
|
|
1534
|
+
let nextCursor = currentCursor;
|
|
1521
1535
|
if (key.meta && key.backspace || key.ctrl && input2 === "w") {
|
|
1522
|
-
const boundary = prevWordBoundary(
|
|
1523
|
-
nextValue =
|
|
1536
|
+
const boundary = prevWordBoundary(currentValue, currentCursor);
|
|
1537
|
+
nextValue = currentValue.slice(0, boundary) + currentValue.slice(currentCursor);
|
|
1524
1538
|
nextCursor = boundary;
|
|
1525
1539
|
} else if (key.ctrl && input2 === "u") {
|
|
1526
|
-
nextValue =
|
|
1540
|
+
nextValue = currentValue.slice(currentCursor);
|
|
1527
1541
|
nextCursor = 0;
|
|
1528
1542
|
} else if (key.ctrl && input2 === "k") {
|
|
1529
|
-
nextValue =
|
|
1543
|
+
nextValue = currentValue.slice(0, currentCursor);
|
|
1530
1544
|
} else if (key.meta && key.delete) {
|
|
1531
|
-
const boundary = nextWordBoundary(
|
|
1532
|
-
nextValue =
|
|
1545
|
+
const boundary = nextWordBoundary(currentValue, currentCursor);
|
|
1546
|
+
nextValue = currentValue.slice(0, currentCursor) + currentValue.slice(boundary);
|
|
1533
1547
|
} else if (key.backspace || key.delete) {
|
|
1534
|
-
if (
|
|
1535
|
-
const deletedChar =
|
|
1548
|
+
if (currentCursor > 0) {
|
|
1549
|
+
const deletedChar = currentValue[currentCursor - 1];
|
|
1536
1550
|
if (deletedChar === PASTE_MARKER) {
|
|
1537
1551
|
let markerIndex = 0;
|
|
1538
|
-
for (let ci = 0; ci <
|
|
1539
|
-
if (
|
|
1552
|
+
for (let ci = 0; ci < currentCursor - 1; ci++) {
|
|
1553
|
+
if (currentValue[ci] === PASTE_MARKER) markerIndex++;
|
|
1540
1554
|
}
|
|
1541
1555
|
const ids = [...pasteMapRef.current.keys()].sort((a, b) => a - b);
|
|
1542
1556
|
if (markerIndex < ids.length) {
|
|
1543
1557
|
pasteMapRef.current.delete(ids[markerIndex]);
|
|
1544
1558
|
}
|
|
1545
1559
|
}
|
|
1546
|
-
nextValue =
|
|
1560
|
+
nextValue = currentValue.slice(0, currentCursor - 1) + currentValue.slice(currentCursor);
|
|
1547
1561
|
nextCursor--;
|
|
1548
1562
|
}
|
|
1549
1563
|
} else if (key.meta && key.leftArrow || key.meta && input2 === "b" || key.ctrl && key.leftArrow) {
|
|
1550
|
-
nextCursor = prevWordBoundary(
|
|
1564
|
+
nextCursor = prevWordBoundary(currentValue, currentCursor);
|
|
1551
1565
|
} else if (key.meta && key.rightArrow || key.meta && input2 === "f" || key.ctrl && key.rightArrow) {
|
|
1552
|
-
nextCursor = nextWordBoundary(
|
|
1566
|
+
nextCursor = nextWordBoundary(currentValue, currentCursor);
|
|
1553
1567
|
} else if (key.ctrl && input2 === "a" || key.home) {
|
|
1554
1568
|
nextCursor = 0;
|
|
1555
1569
|
} else if (key.ctrl && input2 === "e" || key.end) {
|
|
1556
|
-
nextCursor =
|
|
1570
|
+
nextCursor = currentValue.length;
|
|
1557
1571
|
} else if (key.leftArrow) {
|
|
1558
1572
|
if (showCursor) nextCursor--;
|
|
1559
1573
|
} else if (key.rightArrow) {
|
|
@@ -1565,17 +1579,22 @@ function TextInput({
|
|
|
1565
1579
|
if (lineCount >= 2) {
|
|
1566
1580
|
const id = ++pasteCounterRef.current;
|
|
1567
1581
|
pasteMapRef.current.set(id, { text: clean, lineCount, id });
|
|
1568
|
-
nextValue =
|
|
1582
|
+
nextValue = currentValue.slice(0, currentCursor) + PASTE_MARKER + currentValue.slice(currentCursor);
|
|
1569
1583
|
nextCursor += 1;
|
|
1570
1584
|
} else {
|
|
1571
|
-
nextValue =
|
|
1585
|
+
nextValue = currentValue.slice(0, currentCursor) + clean + currentValue.slice(currentCursor);
|
|
1572
1586
|
nextCursor += clean.length;
|
|
1573
1587
|
}
|
|
1574
1588
|
}
|
|
1575
1589
|
}
|
|
1576
1590
|
nextCursor = Math.max(0, Math.min(nextCursor, nextValue.length));
|
|
1591
|
+
if (nextValue === "") {
|
|
1592
|
+
pasteMapRef.current.clear();
|
|
1593
|
+
}
|
|
1594
|
+
cursorOffsetRef.current = nextCursor;
|
|
1577
1595
|
setCursorOffset(nextCursor);
|
|
1578
|
-
if (nextValue !==
|
|
1596
|
+
if (nextValue !== currentValue) {
|
|
1597
|
+
valueRef.current = nextValue;
|
|
1579
1598
|
onChange(nextValue);
|
|
1580
1599
|
}
|
|
1581
1600
|
},
|
package/package.json
CHANGED