@oh-my-pi/pi-utils 12.3.0 → 12.5.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/stream.ts +0 -50
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oh-my-pi/pi-utils",
3
- "version": "12.3.0",
3
+ "version": "12.5.0",
4
4
  "description": "Shared utilities for pi packages",
5
5
  "keywords": ["utilities", "cli", "logging", "streams"],
6
6
  "type": "module",
package/src/stream.ts CHANGED
@@ -1,55 +1,5 @@
1
1
  import { createAbortableStream } from "./abortable";
2
2
 
3
- /**
4
- * Sanitize binary output for display/storage.
5
- * Removes characters that crash string-width or cause display issues:
6
- * - Control characters (except tab, newline, carriage return)
7
- * - Lone surrogates
8
- * - Characters with undefined code points
9
- */
10
- export function sanitizeBinaryOutput(str: string): string {
11
- let out: string[] | undefined;
12
- let last = 0;
13
-
14
- for (let i = 0; i < str.length; ) {
15
- const code = str.codePointAt(i)!;
16
- const width = code > 0xffff ? 2 : 1;
17
- const next = i + width;
18
-
19
- // Allow tab, newline, carriage return.
20
- const isAllowedControl = code === 0x09 || code === 0x0a || code === 0x0d;
21
- if (isAllowedControl) {
22
- i = next;
23
- continue;
24
- }
25
-
26
- // Filter out characters that crash `Bun.stringWidth()` or cause display issues:
27
- // - ASCII control chars (C0)
28
- // - DEL + C1 control block
29
- // - Lone surrogates
30
- const isControl = code <= 0x1f || code === 0x7f || (code >= 0x80 && code <= 0x9f);
31
- const isSurrogate = code >= 0xd800 && code <= 0xdfff;
32
- if (isControl || isSurrogate) {
33
- out ??= [];
34
- if (last !== i) out.push(str.slice(last, i));
35
- last = next;
36
- }
37
-
38
- i = next;
39
- }
40
-
41
- if (!out) return str;
42
- if (last < str.length) out.push(str.slice(last));
43
- return out.join("");
44
- }
45
-
46
- /**
47
- * Sanitize text output: strip ANSI codes, remove binary garbage, normalize line endings.
48
- */
49
- export function sanitizeText(text: string): string {
50
- return sanitizeBinaryOutput(Bun.stripANSI(text)).replaceAll("\r", "");
51
- }
52
-
53
3
  const LF = 0x0a;
54
4
  const CR = 0x0d;
55
5
  const decoder = new TextDecoder();