Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package bun-pty for openSUSE:Factory checked 
in at 2026-11-17 17:18:37
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/bun-pty (Old)
 and      /work/SRC/openSUSE:Factory/.bun-pty.new.1251 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "bun-pty"

Tue Nov 17 17:18:37 2026 rev:7 rq:1398007 version:0.6.1

Changes:
--------
--- /work/SRC/openSUSE:Factory/bun-pty/bun-pty.changes  2026-11-06 
20:04:57.924816328 +0100
+++ /work/SRC/openSUSE:Factory/.bun-pty.new.1251/bun-pty.changes        
2026-11-17 17:20:27.945782941 +0100
@@ -1,0 +2,16 @@
+Mon Nov 16 20:33:51 UTC 2026 - Martin Pluskal <[email protected]>
+
+- Update to version 0.6.1:
+  * Fixed: output written before the first onData listener is no
+    longer lost (#53, #54); the newest 512 KiB of UTF-8, cut only
+    between whole characters, is delivered to the first listener
+    (and any added in the same tick) just after onData() returns
+  * Before, awaiting anything between spawn() and onData() lost the
+    shell's first prompt, or all of a fast command's output;
+    subscribing in the same tick as spawn() sees no change
+  * Repository moved to sursatech/bun-pty; URL and Source0 follow
+    the new location (old links redirect)
+  * No Rust changes: same vendored crates and same eight dlsym
+    entry points, so no consumer rebuild is needed
+
+-------------------------------------------------------------------

Old:
----
  bun-pty-0.6.0.tar.gz

New:
----
  bun-pty-0.6.1.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ bun-pty.spec ++++++
--- /var/tmp/diff_new_pack.CtHlx3/_old  2026-11-17 17:20:28.675813755 +0100
+++ /var/tmp/diff_new_pack.CtHlx3/_new  2026-11-17 17:20:28.680813966 +0100
@@ -17,15 +17,15 @@
 
 
 Name:           bun-pty
-Version:        0.6.0
+Version:        0.6.1
 Release:        0
 Summary:        Pseudo-terminal library for Bun FFI consumers
 License:        MIT
 # Legal-Review-Notice: 45 crates are statically linked (cargo tree -e normal
 # on rust-pty, minus the proc-macro closure); every one is MIT or MIT OR
 # Apache-2.0, so the tag is upstream's own licence.
-URL:            https://github.com/sursaone/bun-pty
-Source0:        
https://github.com/sursaone/bun-pty/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
+URL:            https://github.com/sursatech/bun-pty
+Source0:        
https://github.com/sursatech/bun-pty/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
 Source1:        vendor.tar.zst
 # Source-Binary-Exception: 
vendor.tar.zst:rust-pty/vendor/winapi-*-gnu-*/lib/*.a -- other-platform: 
Windows MinGW import libraries the Linux build never links
 BuildRequires:  cargo-packaging
@@ -48,7 +48,7 @@
 # The vendor tarball unpacks next to the crate, so cargo has to run there
 # to see its .cargo/config.toml; the library lands in rust-pty/target.
 cd rust-pty
-%cargo_build
+%{cargo_build}
 
 %install
 # CARGO_TARGET_DIR moved across cargo-packaging vintages (top-level

++++++ _service ++++++
--- /var/tmp/diff_new_pack.CtHlx3/_old  2026-11-17 17:20:28.711815275 +0100
+++ /var/tmp/diff_new_pack.CtHlx3/_new  2026-11-17 17:20:28.714815401 +0100
@@ -1,6 +1,6 @@
 <services>
   <service name="cargo_vendor" mode="manual">
-    <param name="srctar">bun-pty-0.6.0.tar.gz</param>
+    <param name="srctar">bun-pty-0.6.1.tar.gz</param>
     <param name="cargotoml">rust-pty/Cargo.toml</param>
     <param name="compression">zst</param>
   </service>

++++++ bun-pty-0.6.0.tar.gz -> bun-pty-0.6.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/bun-pty-0.6.0/CHANGELOG.md 
new/bun-pty-0.6.1/CHANGELOG.md
--- old/bun-pty-0.6.0/CHANGELOG.md      2026-10-30 07:43:50.000000000 +0100
+++ new/bun-pty-0.6.1/CHANGELOG.md      2026-11-16 10:23:42.000000000 +0100
@@ -5,6 +5,17 @@
 The format is based on [Keep a 
Changelog](https://keepachangelog.com/en/1.0.0/),
 and this project adheres to [Semantic 
Versioning](https://semver.org/spec/v2.0.0.html).
 
+## [0.6.1] - 2026-11-16
+
+### Changed
+- The repository moved to 
[sursatech/bun-pty](https://github.com/sursatech/bun-pty); old 
`sursaone/bun-pty` links and clones redirect
+
+### Fixed
+- Output the child writes before the first `onData` listener subscribes is no 
longer lost (#53, #54)
+  - The newest 512 KiB of UTF-8 is kept, cut only between whole characters, 
and delivered to the first listener (and any added in the same tick) just after 
`onData()` returns
+  - Before, a consumer that awaited anything between `spawn()` and `onData()` 
lost the shell's first prompt, or all of a fast command's output
+  - A consumer that subscribes in the same tick as `spawn()` sees no change
+
 ## [0.6.0] - 2026-10-30
 
 ### Changed
@@ -122,7 +133,7 @@
   - Fix spaces in Windows exe path handling
   - Add Windows-specific tests
   - Add compile test script to verify bun build --compile works
-  - Fixes: https://github.com/sursaone/bun-pty/issues/19
+  - Fixes: https://github.com/sursatech/bun-pty/issues/19
 
 ## [0.4.3] - 2025-12-30
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/bun-pty-0.6.0/README.md new/bun-pty-0.6.1/README.md
--- old/bun-pty-0.6.0/README.md 2026-10-30 07:43:50.000000000 +0100
+++ new/bun-pty-0.6.1/README.md 2026-11-16 10:23:42.000000000 +0100
@@ -175,7 +175,7 @@
   readonly process: string;    // Process name
   
   // Events
-  onData: (listener: (data: string) => void) => IDisposable;
+  onData: (listener: (data: string) => void) => IDisposable;  // The first 
listener (and any added in the same tick) also gets output from before it 
subscribed (up to 512 KiB), just after onData() returns
   onExit: (listener: (event: IExitEvent) => void) => IDisposable;
   
   // Methods
@@ -225,7 +225,7 @@
 
 ```bash
 # Clone the repository
-git clone https://github.com/sursaone/bun-pty.git
+git clone https://github.com/sursatech/bun-pty.git
 cd bun-pty
 
 # Install dependencies
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/bun-pty-0.6.0/examples/bun.lock 
new/bun-pty-0.6.1/examples/bun.lock
--- old/bun-pty-0.6.0/examples/bun.lock 2026-10-30 07:43:50.000000000 +0100
+++ new/bun-pty-0.6.1/examples/bun.lock 2026-11-16 10:23:42.000000000 +0100
@@ -1,31 +1,71 @@
 {
-  "lockfileVersion": 1,
+  "lockfileVersion": 2,
   "configVersion": 1,
   "workspaces": {
     "": {
       "name": "examples",
       "dependencies": {
-        "bun-pty": "^0.4.7",
+        "bun-pty": "^0.6.0",
       },
       "devDependencies": {
         "@types/bun": "latest",
       },
       "peerDependencies": {
-        "typescript": "^5",
+        "typescript": "^7",
       },
     },
   },
   "packages": {
-    "@types/bun": ["@types/[email protected]", "", { "dependencies": { "bun-types": 
"1.3.3" } }, 
"sha512-ogrKbJ2X5N0kWLLFKeytG0eHDleBYtngtlbu9cyBKFtNL3cnpDZkNdQj8flVf6WTZUX5ulI9AY1oa7ljhSrp+g=="],
+    "@types/bun": ["@types/[email protected]", "", { "dependencies": { "bun-types": 
"1.4.4" } }, 
"sha512-9wkRDXUXK124pEnAutE6n/l18j+i9GC5IAHK8TmX/2nlySETmky0OU6yL5U8pW1AoKh++AN9auDCr647BfurjQ=="],
 
-    "@types/node": ["@types/[email protected]", "", { "dependencies": { 
"undici-types": "~7.16.0" } }, 
"sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ=="],
+    "@types/node": ["@types/[email protected]", "", { "dependencies": { 
"undici-types": "~8.9.0" } }, 
"sha512-MzQj+8Kx3XI40OmUAE6Qoh58ZMNstNNMwn2nfd3qWsfe7nDNSqJNzes4njhz6AHwrSHOffSLwXU6yb474Q4aog=="],
 
-    "bun-pty": ["[email protected]", "", {}, 
"sha512-WXaoS9MaEskEjyTXgKhD95w2O+2TridX8kcYIfliNSqaoGw4xdSi4f6vXzq0xXR9vXue4DVsRkMHHHilA93vpg=="],
+    "@typescript/typescript-aix-ppc64": 
["@typescript/[email protected]", "", { "os": "aix", "cpu": "ppc64" }, 
"sha512-MTKKkWB7p/0E9xi1d1tHtZ5PiLkGEMIq88pK2CubZjOsLtYTLqhgIgi6zepFa+9GHZ6h05NMCkQxGKiPXMxXtQ=="],
 
-    "bun-types": ["[email protected]", "", { "dependencies": { "@types/node": 
"*" } }, 
"sha512-z3Xwlg7j2l9JY27x5Qn3Wlyos8YAp0kKRlrePAOjgjMGS5IG6E7Jnlx736vH9UVI4wUICwwhC9anYL++XeOgTQ=="],
+    "@typescript/typescript-darwin-arm64": 
["@typescript/[email protected]", "", { "os": "darwin", "cpu": 
"arm64" }, 
"sha512-gowzar9MwS/aRWp6f3a4KUqzRjAZjOsmGNCM6LcTgXum+dBfgsBVMN+AgvOCCbguXyick6LJhpBszxMebJ8syA=="],
 
-    "typescript": ["[email protected]", "", { "bin": { "tsc": "bin/tsc", 
"tsserver": "bin/tsserver" } }, 
"sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
+    "@typescript/typescript-darwin-x64": 
["@typescript/[email protected]", "", { "os": "darwin", "cpu": "x64" 
}, 
"sha512-SZ9xZInqApNlNGc9s0W1VSsktYSOe9cFqNOIqmN1Gs8SmkjKZYFt017G4VwPxASInODuAdbTW7sXiFUf893RgA=="],
 
-    "undici-types": ["[email protected]", "", {}, 
"sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="],
+    "@typescript/typescript-freebsd-arm64": 
["@typescript/[email protected]", "", { "os": "freebsd", "cpu": 
"arm64" }, 
"sha512-W5NH4y/J0plIIS5b2xvTEkU7JFxyqdMAOgf+Ilhl0vHQXKO5dZoxd+C/jEtq56c4F3wk71RB4BMRQ2XdI+bwYQ=="],
+
+    "@typescript/typescript-freebsd-x64": 
["@typescript/[email protected]", "", { "os": "freebsd", "cpu": 
"x64" }, 
"sha512-UMGDx5sTpzNw3WiPebH7l90IWfJggEd+egHt/q6p7/Cm3zqoV7VxkGXt+3DxPIw8CcmvAB0j3sVVfbhX+M4Tpw=="],
+
+    "@typescript/typescript-linux-arm": 
["@typescript/[email protected]", "", { "os": "linux", "cpu": "arm" }, 
"sha512-gffT3xPz9sR7j/YJExkyPntrI0P2EP9XbOyWzth2/Gs0RstK+90RBcO0ncXoXy/beYll1SXw846Nf2zdnEz0QQ=="],
+
+    "@typescript/typescript-linux-arm64": 
["@typescript/[email protected]", "", { "os": "linux", "cpu": 
"arm64" }, 
"sha512-Qh4eU4/y3yDjnfjjyPYihMj5/ODIlmt+Bzu17OI+fiSRDW57QmU5SiN63exPRNJPKUzcc1INa1NXdrJ+MqHjUQ=="],
+
+    "@typescript/typescript-linux-loong64": 
["@typescript/[email protected]", "", { "os": "linux", "cpu": 
"none" }, 
"sha512-uEHck9i8hoAzXPiYRib1O7miOnz23SxIeVl6F4LXox+qov1K35jHcEW6VHKvZI+pyvl7fZEP4MCU5LYvIq1GuQ=="],
+
+    "@typescript/typescript-linux-mips64el": 
["@typescript/[email protected]", "", { "os": "linux", "cpu": 
"none" }, 
"sha512-R4KvAMnE43W5Qeqb0Ly56O3mWMWIAgsMyz36DCaycd5nbg/9kzm0liw3JocfRqyJY0KPmzFjbswozXyW0DnIYA=="],
+
+    "@typescript/typescript-linux-ppc64": 
["@typescript/[email protected]", "", { "os": "linux", "cpu": 
"ppc64" }, 
"sha512-DORx5b3sd/4S7eayxm4FQv+A7CrkUIGRaHiwI8oiHTAI1fAPWhF4J0vAlkC8biAlHSVVwxMQ3tjZ2/DVbnQiiA=="],
+
+    "@typescript/typescript-linux-riscv64": 
["@typescript/[email protected]", "", { "os": "linux", "cpu": 
"none" }, 
"sha512-wf0jqEDOjrPRnKwYRyyJDRo11KMbvMFrU+q4zqKyChODBzvlkbhNQfKvLxQCcwTpdDaXSHZTVuh0JoCrKCUMHQ=="],
+
+    "@typescript/typescript-linux-s390x": 
["@typescript/[email protected]", "", { "os": "linux", "cpu": 
"s390x" }, 
"sha512-IkwJc3L7yhytWd/ewjyxNDfOmswCm9GWMJT/ue/dU4aZNbwZeYAetq42VyLmsmSjvoX7z74X6ZaYCtzAr0EuGw=="],
+
+    "@typescript/typescript-linux-x64": 
["@typescript/[email protected]", "", { "os": "linux", "cpu": "x64" }, 
"sha512-EYdf2cNg7rgCWJnxCdJ+F3V39O8ihb37eHAu1LK8oAFizgTQbPOK7zHHXbPt8rX24COqODXeI3sIf0fCXG7H/A=="],
+
+    "@typescript/typescript-netbsd-arm64": 
["@typescript/[email protected]", "", { "os": "none", "cpu": 
"arm64" }, 
"sha512-+polYF4MF04aPpO5FTkHran9yUQDSXqy5GiSDKpsll5jy3l3+g9QLhpf39T+ePtefhXLOGrLl0QIjkQP6VnelA=="],
+
+    "@typescript/typescript-netbsd-x64": 
["@typescript/[email protected]", "", { "os": "none", "cpu": "x64" }, 
"sha512-8YIT0EHM/3dq10ZOVF/A7pc/YSMtbcecct4rWtexrnSCHOPcpC2KTLXfTCR6vDpnSiY12heNb1GiN/wu+T/FyA=="],
+
+    "@typescript/typescript-openbsd-arm64": 
["@typescript/[email protected]", "", { "os": "openbsd", "cpu": 
"arm64" }, 
"sha512-APT8+ClYnuYm1u9+kgGXoMj2VzWzcymwh2gNSQVySHfkRDGOTVkoWLjCmOQSaO+PoqQ57B0flRp9SA+7GnnkzQ=="],
+
+    "@typescript/typescript-openbsd-x64": 
["@typescript/[email protected]", "", { "os": "openbsd", "cpu": 
"x64" }, 
"sha512-yX7s+Q0Dln0Dt9tEzZsAjXXR/+ytBM7AlglaqyeMPxQszJ1JhlJdZ6jLA+IzldHtflX81em7lDao1xXu+aRRkg=="],
+
+    "@typescript/typescript-sunos-x64": 
["@typescript/[email protected]", "", { "os": "sunos", "cpu": "x64" }, 
"sha512-dLJDGaLZ1D4HPQn62u1n8mBDkJREwMsAkCdkwd4Ieqw+x3TUyTsqY0YiBCtE6H6OzzgGk3iuZ3vFWRS+E8/d1g=="],
+
+    "@typescript/typescript-win32-arm64": 
["@typescript/[email protected]", "", { "os": "win32", "cpu": 
"arm64" }, 
"sha512-Gyl1Vy6OsWesLzmq+EP0Fb7b4Nid5232AvcA2SFcdYreldpNtYFFofPjnt62y9hQy7VTaZp65ICJjuAQRaVcIQ=="],
+
+    "@typescript/typescript-win32-x64": 
["@typescript/[email protected]", "", { "os": "win32", "cpu": "x64" }, 
"sha512-0BQ3HkAHHlKLSp1qRvf3SUhGpGsDuhB/jgFw75guyqbxJqEaS0Cw/VFO8i2nHglJUzQCRtMMR/IBAKE3ETMC4g=="],
+
+    "bun-pty": ["[email protected]", "", {}, 
"sha512-tRVhUKbu18DSg/lUdp9vXzzEAlevBcdWJ+3TXX0CuvSmtdC6EIbzKmklRpiKZmmtN6qwkIqB2QeEFghpI1/z3g=="],
+
+    "bun-types": ["[email protected]", "", { "dependencies": { "@types/node": 
"*", "undici-types": "*" } }, 
"sha512-yjrJh5oGX7mMPKGd19YXyIjmEuj4G4zNC30bs7PM9Az7NQ3ndF3j6hbeRdvJTRQEhJ/FYQwW0a2moweEi2hMxQ=="],
+
+    "typescript": ["[email protected]", "", { "optionalDependencies": { 
"@typescript/typescript-aix-ppc64": "7.0.2", 
"@typescript/typescript-darwin-arm64": "7.0.2", 
"@typescript/typescript-darwin-x64": "7.0.2", 
"@typescript/typescript-freebsd-arm64": "7.0.2", 
"@typescript/typescript-freebsd-x64": "7.0.2", 
"@typescript/typescript-linux-arm": "7.0.2", 
"@typescript/typescript-linux-arm64": "7.0.2", 
"@typescript/typescript-linux-loong64": "7.0.2", 
"@typescript/typescript-linux-mips64el": "7.0.2", 
"@typescript/typescript-linux-ppc64": "7.0.2", 
"@typescript/typescript-linux-riscv64": "7.0.2", 
"@typescript/typescript-linux-s390x": "7.0.2", 
"@typescript/typescript-linux-x64": "7.0.2", 
"@typescript/typescript-netbsd-arm64": "7.0.2", 
"@typescript/typescript-netbsd-x64": "7.0.2", 
"@typescript/typescript-openbsd-arm64": "7.0.2", 
"@typescript/typescript-openbsd-x64": "7.0.2", 
"@typescript/typescript-sunos-x64": "7.0.2", 
"@typescript/typescript-win32-arm64": "7.0.2", "@typescript/typescript-win32-
 x64": "7.0.2" }, "bin": { "tsc": "bin/tsc" } }, 
"sha512-8FYau96o3NKOhbjKi/qNvG/W5jhzxkbdm5sj9AbZ/5T5sWqn3hJgLfGx27sRKZWTvyzCP8dLRBTf5tBTSRVUNA=="],
+
+    "undici-types": ["[email protected]", "", {}, 
"sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg=="],
   }
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/bun-pty-0.6.0/examples/package.json 
new/bun-pty-0.6.1/examples/package.json
--- old/bun-pty-0.6.0/examples/package.json     2026-10-30 07:43:50.000000000 
+0100
+++ new/bun-pty-0.6.1/examples/package.json     2026-11-16 10:23:42.000000000 
+0100
@@ -11,6 +11,6 @@
     "typescript": "^7"
   },
   "dependencies": {
-    "bun-pty": "^0.4.7"
+    "bun-pty": "^0.6.0"
   }
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/bun-pty-0.6.0/package.json 
new/bun-pty-0.6.1/package.json
--- old/bun-pty-0.6.0/package.json      2026-10-30 07:43:50.000000000 +0100
+++ new/bun-pty-0.6.1/package.json      2026-11-16 10:23:42.000000000 +0100
@@ -1,17 +1,17 @@
 {
        "name": "bun-pty",
-       "version": "0.6.0",
+       "version": "0.6.1",
        "description": "Cross-platform pseudoterminal (PTY) implementation for 
Bun with native performance",
        "main": "./src/index.ts",
        "types": "./dist/index.d.ts",
        "type": "module",
        "repository": {
                "type": "git",
-               "url": "git+https://github.com/sursaone/bun-pty.git";
+               "url": "git+https://github.com/sursatech/bun-pty.git";
        },
-       "homepage": "https://github.com/sursaone/bun-pty#readme";,
+       "homepage": "https://github.com/sursatech/bun-pty#readme";,
        "bugs": {
-               "url": "https://github.com/sursaone/bun-pty/issues";
+               "url": "https://github.com/sursatech/bun-pty/issues";
        },
        "author": {
                "name": "Dilip Thapa",
@@ -48,10 +48,10 @@
                "typecheck": "bun check src/*.test.ts",
                "build": "bun run build:rust && bun run build:ts",
                "test": "bun test",
-               "test:unit": "bun test src/interfaces.test.ts 
src/terminal.test.ts src/index.test.ts src/env.test.ts",
+               "test:unit": "bun test src/interfaces.test.ts 
src/terminal.test.ts src/index.test.ts src/env.test.ts src/output.test.ts",
                "test:integration": "RUN_INTEGRATION_TESTS=true bun test 
src/terminal.integration.test.ts",
                "test:all": "bun run test:unit && bun run test:integration",
-               "test:coverage": "bun test --coverage src/interfaces.test.ts 
src/terminal.test.ts src/index.test.ts src/env.test.ts",
+               "test:coverage": "bun test --coverage src/interfaces.test.ts 
src/terminal.test.ts src/index.test.ts src/env.test.ts src/output.test.ts",
                "clean": "rm -rf ./dist && cd rust-pty && cargo clean"
        },
        "engines": {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/bun-pty-0.6.0/src/output.test.ts 
new/bun-pty-0.6.1/src/output.test.ts
--- old/bun-pty-0.6.0/src/output.test.ts        1970-01-01 01:00:00.000000000 
+0100
+++ new/bun-pty-0.6.1/src/output.test.ts        2026-11-16 10:23:42.000000000 
+0100
@@ -0,0 +1,32 @@
+import { expect, test, describe } from "bun:test";
+import { Buffer } from "node:buffer";
+import { INITIAL_OUTPUT_LIMIT_BYTES, keepNewestUtf8 } from "./output";
+
+describe("keepNewestUtf8", () => {
+       test("returns text within the limit unchanged", () => {
+               expect(keepNewestUtf8("hello ─ 😀", 
INITIAL_OUTPUT_LIMIT_BYTES)).toBe("hello ─ 😀");
+       });
+
+       test("counts the limit in UTF-8 bytes for multi-byte output", () => {
+               // 200,000 × 3 bytes = 600,000 bytes, but only 200,000 UTF-16 
code units
+               const kept = keepNewestUtf8("─".repeat(200_000), 
INITIAL_OUTPUT_LIMIT_BYTES);
+               
expect(Buffer.byteLength(kept)).toBeLessThanOrEqual(INITIAL_OUTPUT_LIMIT_BYTES);
+               // The newest whole characters that fit: floor(524,288 / 3)
+               expect(kept).toBe("─".repeat(174_762));
+               expect(kept).not.toContain("�");
+       });
+
+       test("does not split an emoji at the trim boundary", () => {
+               const kept = keepNewestUtf8(`😀${"a".repeat(524_287)}`, 
INITIAL_OUTPUT_LIMIT_BYTES);
+               
expect(Buffer.byteLength(kept)).toBeLessThanOrEqual(INITIAL_OUTPUT_LIMIT_BYTES);
+               expect(kept).toBe("a".repeat(524_287));
+               expect(kept).not.toMatch(/[\uD800-\uDFFF]/);
+               expect(kept).not.toContain("�");
+       });
+
+       test("keeps an emoji that fits whole at the boundary", () => {
+               const kept = keepNewestUtf8(`x😀${"a".repeat(524_284)}`, 
INITIAL_OUTPUT_LIMIT_BYTES);
+               expect(kept).toBe(`😀${"a".repeat(524_284)}`);
+               
expect(Buffer.byteLength(kept)).toBe(INITIAL_OUTPUT_LIMIT_BYTES);
+       });
+});
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/bun-pty-0.6.0/src/output.ts 
new/bun-pty-0.6.1/src/output.ts
--- old/bun-pty-0.6.0/src/output.ts     1970-01-01 01:00:00.000000000 +0100
+++ new/bun-pty-0.6.1/src/output.ts     2026-11-16 10:23:42.000000000 +0100
@@ -0,0 +1,21 @@
+// output.ts  —  output kept for the first onData listener, kept out of
+// terminal.ts so it can be tested without loading the native library
+
+import { Buffer } from "node:buffer";
+
+/** At most this many UTF-8 bytes of output are kept for the first onData 
listener */
+export const INITIAL_OUTPUT_LIMIT_BYTES = 512 * 1024;
+
+/**
+ * The newest complete characters of `text` that fit in `limitBytes` of UTF-8.
+ * The cut never lands inside a character, so no surrogate pair or multi-byte
+ * sequence is split.
+ */
+export function keepNewestUtf8(text: string, limitBytes: number): string {
+       const bytes = Buffer.from(text, "utf8");
+       if (bytes.length <= limitBytes) return text;
+       let start = bytes.length - limitBytes;
+       // Skip continuation bytes (10xxxxxx) to start on a whole character
+       while (start < bytes.length && (bytes[start]! & 0xc0) === 0x80) start++;
+       return bytes.subarray(start).toString("utf8");
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/bun-pty-0.6.0/src/terminal.integration.test.ts 
new/bun-pty-0.6.1/src/terminal.integration.test.ts
--- old/bun-pty-0.6.0/src/terminal.integration.test.ts  2026-10-30 
07:43:50.000000000 +0100
+++ new/bun-pty-0.6.1/src/terminal.integration.test.ts  2026-11-16 
10:23:42.000000000 +0100
@@ -88,6 +88,76 @@
     expect(dataReceived).toContain("Hello from Bun PTY");
   });
 
+  test("Terminal keeps output emitted before the first onData listener", async 
() => {
+    const { cmd, args } = echoCommand("Hello before listener");
+    const terminal = new Terminal(cmd, args);
+    terminals.push(terminal);
+
+    const exited = new Promise<void>((resolve) => {
+      terminal.onExit(() => resolve());
+    });
+
+    // Subscribe only after the process has written its output and exited
+    await exited;
+
+    let dataReceived = "";
+    terminal.onData((data) => {
+      dataReceived += data;
+    });
+
+    // Delivered after onData() returns, not during it
+    expect(dataReceived).toBe("");
+    await new Promise((resolve) => setTimeout(resolve, 0));
+    expect(dataReceived).toContain("Hello before listener");
+  });
+
+  test("A first onData listener can dispose itself while it receives earlier 
output", async () => {
+    const { cmd, args } = echoCommand("Hello once");
+    const terminal = new Terminal(cmd, args);
+    terminals.push(terminal);
+
+    await new Promise<void>((resolve) => {
+      terminal.onExit(() => resolve());
+    });
+
+    let calls = 0;
+    let dataReceived = "";
+    expect(() => {
+      const subscription = terminal.onData((data) => {
+        calls++;
+        dataReceived += data;
+        subscription.dispose();
+      });
+    }).not.toThrow();
+    await new Promise((resolve) => setTimeout(resolve, 0));
+
+    expect(calls).toBe(1);
+    expect(dataReceived).toContain("Hello once");
+  });
+
+  test.skipIf(isWindows)("Terminal keeps the newest 512 KiB of UTF-8 before 
the first onData listener (Unix)", async () => {
+    // 1,200,000 bytes of "─" (3 bytes each), then an end marker: more than
+    // twice the limit, so it is trimmed while reading and again on delivery
+    const terminal = new Terminal(process.execPath, [
+      "-e",
+      "process.stdout.write('─'.repeat(400000) + 'END')",
+    ]);
+    terminals.push(terminal);
+
+    await new Promise<void>((resolve) => {
+      terminal.onExit(() => resolve());
+    });
+
+    let dataReceived = "";
+    terminal.onData((data) => {
+      dataReceived += data;
+    });
+    await new Promise((resolve) => setTimeout(resolve, 0));
+
+    expect(Buffer.byteLength(dataReceived, "utf8")).toBeLessThanOrEqual(512 * 
1024);
+    expect(dataReceived).toMatch(/^─+END$/);
+  });
+
   test.skipIf(isWindows)("Terminal can send data to a real process (Unix)", 
async () => {
     let dataReceived = "";
     let hasExited = false;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/bun-pty-0.6.0/src/terminal.ts 
new/bun-pty-0.6.1/src/terminal.ts
--- old/bun-pty-0.6.0/src/terminal.ts   2026-10-30 07:43:50.000000000 +0100
+++ new/bun-pty-0.6.1/src/terminal.ts   2026-11-16 10:23:42.000000000 +0100
@@ -6,6 +6,7 @@
 import type { IPty, IPtyForkOptions, IExitEvent } from "./interfaces";
 import { libraryFilenames, unsupportedBunError } from "./library";
 import { DEFAULT_NAME, childEnv, formatEnv } from "./env";
+import { INITIAL_OUTPUT_LIMIT_BYTES, keepNewestUtf8 } from "./output";
 import { join, dirname, basename } from "node:path";
 import { existsSync, readFileSync } from "node:fs";
 
@@ -49,7 +50,7 @@
        // Bun evaluates process.platform and process.arch at compile time and 
only
        // bundles the file for the target platform. The ternary MUST be inline
        // in the template literal for Bun's static analysis to work.
-       // See: https://github.com/sursaone/bun-pty/issues/19
+       // See: https://github.com/sursatech/bun-pty/issues/19
        try {
                // @ts-ignore - require returns path for binary files in Bun
                const embeddedPath = 
require(`../rust-pty/target/release/${process.platform === "win32" ? 
(process.arch === "arm64" ? "rust_pty_arm64.dll" : "rust_pty.dll") : 
process.platform === "darwin" ? (process.arch === "arm64" ? 
"librust_pty_arm64.dylib" : "librust_pty.dylib") : process.arch === "arm64" ? 
"librust_pty_arm64.so" : "librust_pty.so"}`);
@@ -169,6 +170,10 @@
 
        private _readLoop = false;
        private _closing = false;
+       private _hasDataListener = false;
+       private _initialOutputScheduled = false;
+       private _initialOutput = "";
+       private _initialOutputBytes = 0;
 
        // TextDecoder with streaming mode to properly handle UTF-8 across 
chunk boundaries
        // Without this, multi-byte characters (like box-drawing ─) that span 
chunks become �
@@ -228,12 +233,48 @@
        }
 
        get onData() {
-               return this._onData.event;
+               // Output that arrives before anyone listens (a shell prompt, a 
fast
+               // command) is kept and handed to the first listener. It is 
delivered in
+               // a microtask, after onData() has returned, so a listener can 
dispose
+               // itself; output read in between is kept too, so order is 
preserved.
+               return (listener: (data: string) => void) => {
+                       const disposable = this._onData.event(listener);
+                       if (!this._initialOutputScheduled) {
+                               this._initialOutputScheduled = true;
+                               queueMicrotask(() => 
this._flushInitialOutput());
+                       }
+                       return disposable;
+               };
        }
        get onExit() {
                return this._onExit.event;
        }
 
+       private _flushInitialOutput() {
+               const initialOutput = this._initialOutputBytes > 
INITIAL_OUTPUT_LIMIT_BYTES
+                       ? keepNewestUtf8(this._initialOutput, 
INITIAL_OUTPUT_LIMIT_BYTES)
+                       : this._initialOutput;
+               this._initialOutput = "";
+               this._initialOutputBytes = 0;
+               this._hasDataListener = true;
+               if (initialOutput) this._onData.fire(initialOutput);
+       }
+
+       private _emitData(data: string) {
+               if (this._hasDataListener) {
+                       this._onData.fire(data);
+               } else {
+                       this._initialOutput += data;
+                       this._initialOutputBytes += Buffer.byteLength(data, 
"utf8");
+                       // Trim only once twice the limit is held, so a child 
that writes a lot
+                       // before anyone listens doesn't re-encode 512 KiB on 
every read
+                       if (this._initialOutputBytes > 2 * 
INITIAL_OUTPUT_LIMIT_BYTES) {
+                               this._initialOutput = 
keepNewestUtf8(this._initialOutput, INITIAL_OUTPUT_LIMIT_BYTES);
+                               this._initialOutputBytes = 
Buffer.byteLength(this._initialOutput, "utf8");
+                       }
+               }
+       }
+
        /* ------------- IO methods ------------- */
 
        write(data: string) {
@@ -272,13 +313,13 @@
                                // This prevents corruption when multi-byte 
chars span chunk boundaries
                                const decoded = 
this._decoder.decode(buf.subarray(0, n), { stream: true });
                                if (decoded) {
-                                       this._onData.fire(decoded);
+                                       this._emitData(decoded);
                                }
                        } else if (n === -2) {
                                // CHILD_EXITED - flush any remaining bytes in 
the decoder
                                const remaining = this._decoder.decode();
                                if (remaining) {
-                                       this._onData.fire(remaining);
+                                       this._emitData(remaining);
                                }
                                const exitCode = 
lib.symbols.bun_pty_get_exit_code(this.handle);
                                this._onExit.fire({ exitCode });
@@ -287,7 +328,7 @@
                                // error - flush decoder before breaking
                                const remaining = this._decoder.decode();
                                if (remaining) {
-                                       this._onData.fire(remaining);
+                                       this._emitData(remaining);
                                }
                                break;
                        } else {

Reply via email to