@zhongqian97-code/ecode 0.5.6 → 0.5.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.
Files changed (2) hide show
  1. package/dist/index.js +19 -9
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2134,12 +2134,13 @@ function confirmSelection(inputText, selectedPath) {
2134
2134
 
2135
2135
  // src/ui/mouseInput.ts
2136
2136
  var SGR_MOUSE_RE = /^\x1b\[<(\d+);\d+;\d+[Mm]/;
2137
- function isMouseEvent(data) {
2137
+ function mouseEventLength(data) {
2138
2138
  const s = typeof data === "string" ? data : data.toString("binary");
2139
- if (!s) return false;
2140
- if (SGR_MOUSE_RE.test(s)) return true;
2141
- if (s.length >= 6 && s.charCodeAt(0) === 27 && s[1] === "[" && s[2] === "M") return true;
2142
- return false;
2139
+ if (!s) return 0;
2140
+ const sgrMatch = SGR_MOUSE_RE.exec(s);
2141
+ if (sgrMatch) return sgrMatch[0].length;
2142
+ if (s.length >= 6 && s.charCodeAt(0) === 27 && s[1] === "[" && s[2] === "M") return 6;
2143
+ return 0;
2143
2144
  }
2144
2145
  function parseMouseScroll(data) {
2145
2146
  const s = typeof data === "string" ? data : data.toString("binary");
@@ -2984,8 +2985,11 @@ function App({ config: config2, version: version2, autoMode: autoMode2 = false,
2984
2985
  if (event === "readable") {
2985
2986
  const chunk = stdin.read();
2986
2987
  if (chunk !== null) {
2987
- if (isMouseEvent(chunk)) {
2988
- const scrollEvent = parseMouseScroll(chunk);
2988
+ const s = typeof chunk === "string" ? chunk : chunk.toString("binary");
2989
+ const mouseLen = mouseEventLength(s);
2990
+ if (mouseLen > 0) {
2991
+ const mouseStr = s.slice(0, mouseLen);
2992
+ const scrollEvent = parseMouseScroll(mouseStr);
2989
2993
  if (scrollEvent) {
2990
2994
  if (scrollEvent.direction === "up") {
2991
2995
  setScrollOffset((prev) => Math.min(prev + 3, Math.max(0, totalLinesRef.current - 1)));
@@ -2993,9 +2997,15 @@ function App({ config: config2, version: version2, autoMode: autoMode2 = false,
2993
2997
  setScrollOffset((prev) => Math.max(0, prev - 3));
2994
2998
  }
2995
2999
  }
2996
- return false;
3000
+ const remainder = s.slice(mouseLen);
3001
+ if (remainder.length > 0) {
3002
+ stdin.unshift(
3003
+ typeof chunk === "string" ? remainder : Buffer.from(remainder, "binary")
3004
+ );
3005
+ }
3006
+ } else {
3007
+ stdin.unshift(chunk);
2997
3008
  }
2998
- stdin.unshift(chunk);
2999
3009
  }
3000
3010
  }
3001
3011
  return origEmit.apply(stdin, [event, ...args]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhongqian97-code/ecode",
3
- "version": "0.5.6",
3
+ "version": "0.5.7",
4
4
  "description": "A minimal Claude Code clone with REPL interface and bash tool calling",
5
5
  "type": "module",
6
6
  "author": "zhongqian97-code",