spawn-term 3.4.0 → 3.4.2

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.
@@ -53,9 +53,7 @@ var PassThrough = major > 0 ? _require('stream').PassThrough : _require('readabl
53
53
  * - Falls back to lastIndexOf on Node 0.8-3.x
54
54
  */ var hasEndsWith = typeof String.prototype.endsWith === 'function';
55
55
  function stringEndsWith(str, search, position) {
56
- if (hasEndsWith) {
57
- return str.endsWith(search, position);
58
- }
56
+ if (hasEndsWith) return str.endsWith(search, position);
59
57
  var len = position === undefined ? str.length : position;
60
58
  return str.lastIndexOf(search) === len - search.length;
61
59
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/compat.ts"],"sourcesContent":["/**\n * Compatibility Layer for Node.js 0.8+\n * Local to this package - contains only needed functions.\n */\n\nimport Module from 'module';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\n/**\n * Stream compatibility - Transform class\n * - Uses native stream.Transform on Node 0.10+\n * - Falls back to readable-stream for Node 0.8\n */\nconst major = +process.versions.node.split('.')[0];\nexport const Readable: typeof import('stream').Readable = major > 0 ? _require('stream').Readable : _require('readable-stream').Readable;\nexport const Writable: typeof import('stream').Writable = major > 0 ? _require('stream').Writable : _require('readable-stream').Writable;\nexport const Transform: typeof import('stream').Transform = major > 0 ? _require('stream').Transform : _require('readable-stream').Transform;\nexport const PassThrough: typeof import('stream').PassThrough = major > 0 ? _require('stream').PassThrough : _require('readable-stream').PassThrough;\n\n/**\n * String.prototype.endsWith wrapper for Node.js 0.8+\n * - Uses native endsWith on Node 4.0+ / ES2015+\n * - Falls back to lastIndexOf on Node 0.8-3.x\n */\nconst hasEndsWith = typeof String.prototype.endsWith === 'function';\nexport function stringEndsWith(str: string, search: string, position?: number): boolean {\n if (hasEndsWith) {\n return str.endsWith(search, position);\n }\n const len = position === undefined ? str.length : position;\n return str.lastIndexOf(search) === len - search.length;\n}\n\n/**\n * Array.prototype.find wrapper for Node.js 0.8+\n * - Uses native find on Node 4.0+ / ES2015+\n * - Falls back to loop on Node 0.8-3.x\n */\nconst hasArrayFind = typeof Array.prototype.find === 'function';\n\nexport function arrayFind<T>(arr: T[], predicate: (item: T, index: number, arr: T[]) => boolean): T | undefined {\n if (hasArrayFind) {\n return arr.find(predicate);\n }\n for (let i = 0; i < arr.length; i++) {\n if (predicate(arr[i], i, arr)) return arr[i];\n }\n return undefined;\n}\n"],"names":["PassThrough","Readable","Transform","Writable","arrayFind","stringEndsWith","_require","require","Module","createRequire","major","process","versions","node","split","hasEndsWith","String","prototype","endsWith","str","search","position","len","undefined","length","lastIndexOf","hasArrayFind","Array","find","arr","predicate","i"],"mappings":"AAAA;;;CAGC;;;;;;;;;;;QAeYA;eAAAA;;QAHAC;eAAAA;;QAEAC;eAAAA;;QADAC;eAAAA;;QAyBGC;eAAAA;;QAfAC;eAAAA;;;6DArBG;;;;;;AAEnB,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAE1F;;;;CAIC,GACD,IAAMG,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAC3C,IAAMb,WAA6CS,QAAQ,IAAIJ,SAAS,UAAUL,QAAQ,GAAGK,SAAS,mBAAmBL,QAAQ;AACjI,IAAME,WAA6CO,QAAQ,IAAIJ,SAAS,UAAUH,QAAQ,GAAGG,SAAS,mBAAmBH,QAAQ;AACjI,IAAMD,YAA+CQ,QAAQ,IAAIJ,SAAS,UAAUJ,SAAS,GAAGI,SAAS,mBAAmBJ,SAAS;AACrI,IAAMF,cAAmDU,QAAQ,IAAIJ,SAAS,UAAUN,WAAW,GAAGM,SAAS,mBAAmBN,WAAW;AAEpJ;;;;CAIC,GACD,IAAMe,cAAc,OAAOC,OAAOC,SAAS,CAACC,QAAQ,KAAK;AAClD,SAASb,eAAec,GAAW,EAAEC,MAAc,EAAEC,QAAiB;IAC3E,IAAIN,aAAa;QACf,OAAOI,IAAID,QAAQ,CAACE,QAAQC;IAC9B;IACA,IAAMC,MAAMD,aAAaE,YAAYJ,IAAIK,MAAM,GAAGH;IAClD,OAAOF,IAAIM,WAAW,CAACL,YAAYE,MAAMF,OAAOI,MAAM;AACxD;AAEA;;;;CAIC,GACD,IAAME,eAAe,OAAOC,MAAMV,SAAS,CAACW,IAAI,KAAK;AAE9C,SAASxB,UAAayB,GAAQ,EAAEC,SAAwD;IAC7F,IAAIJ,cAAc;QAChB,OAAOG,IAAID,IAAI,CAACE;IAClB;IACA,IAAK,IAAIC,IAAI,GAAGA,IAAIF,IAAIL,MAAM,EAAEO,IAAK;QACnC,IAAID,UAAUD,GAAG,CAACE,EAAE,EAAEA,GAAGF,MAAM,OAAOA,GAAG,CAACE,EAAE;IAC9C;IACA,OAAOR;AACT"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/compat.ts"],"sourcesContent":["/**\n * Compatibility Layer for Node.js 0.8+\n * Local to this package - contains only needed functions.\n */\n\nimport Module from 'module';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\n/**\n * Stream compatibility - Transform class\n * - Uses native stream.Transform on Node 0.10+\n * - Falls back to readable-stream for Node 0.8\n */\nconst major = +process.versions.node.split('.')[0];\nexport const Readable: typeof import('stream').Readable = major > 0 ? _require('stream').Readable : _require('readable-stream').Readable;\nexport const Writable: typeof import('stream').Writable = major > 0 ? _require('stream').Writable : _require('readable-stream').Writable;\nexport const Transform: typeof import('stream').Transform = major > 0 ? _require('stream').Transform : _require('readable-stream').Transform;\nexport const PassThrough: typeof import('stream').PassThrough = major > 0 ? _require('stream').PassThrough : _require('readable-stream').PassThrough;\n\n/**\n * String.prototype.endsWith wrapper for Node.js 0.8+\n * - Uses native endsWith on Node 4.0+ / ES2015+\n * - Falls back to lastIndexOf on Node 0.8-3.x\n */\nconst hasEndsWith = typeof String.prototype.endsWith === 'function';\nexport function stringEndsWith(str: string, search: string, position?: number): boolean {\n if (hasEndsWith) return str.endsWith(search, position);\n const len = position === undefined ? str.length : position;\n return str.lastIndexOf(search) === len - search.length;\n}\n\n/**\n * Array.prototype.find wrapper for Node.js 0.8+\n * - Uses native find on Node 4.0+ / ES2015+\n * - Falls back to loop on Node 0.8-3.x\n */\nconst hasArrayFind = typeof Array.prototype.find === 'function';\n\nexport function arrayFind<T>(arr: T[], predicate: (item: T, index: number, arr: T[]) => boolean): T | undefined {\n if (hasArrayFind) {\n return arr.find(predicate);\n }\n for (let i = 0; i < arr.length; i++) {\n if (predicate(arr[i], i, arr)) return arr[i];\n }\n return undefined;\n}\n"],"names":["PassThrough","Readable","Transform","Writable","arrayFind","stringEndsWith","_require","require","Module","createRequire","major","process","versions","node","split","hasEndsWith","String","prototype","endsWith","str","search","position","len","undefined","length","lastIndexOf","hasArrayFind","Array","find","arr","predicate","i"],"mappings":"AAAA;;;CAGC;;;;;;;;;;;QAeYA;eAAAA;;QAHAC;eAAAA;;QAEAC;eAAAA;;QADAC;eAAAA;;QAuBGC;eAAAA;;QAbAC;eAAAA;;;6DArBG;;;;;;AAEnB,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAE1F;;;;CAIC,GACD,IAAMG,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAC3C,IAAMb,WAA6CS,QAAQ,IAAIJ,SAAS,UAAUL,QAAQ,GAAGK,SAAS,mBAAmBL,QAAQ;AACjI,IAAME,WAA6CO,QAAQ,IAAIJ,SAAS,UAAUH,QAAQ,GAAGG,SAAS,mBAAmBH,QAAQ;AACjI,IAAMD,YAA+CQ,QAAQ,IAAIJ,SAAS,UAAUJ,SAAS,GAAGI,SAAS,mBAAmBJ,SAAS;AACrI,IAAMF,cAAmDU,QAAQ,IAAIJ,SAAS,UAAUN,WAAW,GAAGM,SAAS,mBAAmBN,WAAW;AAEpJ;;;;CAIC,GACD,IAAMe,cAAc,OAAOC,OAAOC,SAAS,CAACC,QAAQ,KAAK;AAClD,SAASb,eAAec,GAAW,EAAEC,MAAc,EAAEC,QAAiB;IAC3E,IAAIN,aAAa,OAAOI,IAAID,QAAQ,CAACE,QAAQC;IAC7C,IAAMC,MAAMD,aAAaE,YAAYJ,IAAIK,MAAM,GAAGH;IAClD,OAAOF,IAAIM,WAAW,CAACL,YAAYE,MAAMF,OAAOI,MAAM;AACxD;AAEA;;;;CAIC,GACD,IAAME,eAAe,OAAOC,MAAMV,SAAS,CAACW,IAAI,KAAK;AAE9C,SAASxB,UAAayB,GAAQ,EAAEC,SAAwD;IAC7F,IAAIJ,cAAc;QAChB,OAAOG,IAAID,IAAI,CAACE;IAClB;IACA,IAAK,IAAIC,IAAI,GAAGA,IAAIF,IAAIL,MAAM,EAAEO,IAAK;QACnC,IAAID,UAAUD,GAAG,CAACE,EAAE,EAAEA,GAAGF,MAAM,OAAOA,GAAG,CAACE,EAAE;IAC9C;IACA,OAAOR;AACT"}
@@ -26,7 +26,7 @@ function _interop_require_default(obj) {
26
26
  };
27
27
  }
28
28
  // Get the node_modules directory relative to this file
29
- var _dirname = _path.default.dirname(typeof __dirname !== 'undefined' ? __dirname : _url.default.fileURLToPath(require("url").pathToFileURL(__filename).toString()));
29
+ var _dirname = _path.default.dirname(typeof __filename === 'undefined' ? _url.default.fileURLToPath(require("url").pathToFileURL(__filename).toString()) : __filename);
30
30
  var nodeModules = _path.default.join(_dirname, '..', '..', '..', 'node_modules');
31
31
  var installed = false;
32
32
  var installing = null;
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/lib/loadInk.ts"],"sourcesContent":["import fs from 'fs';\nimport installModule from 'install-module-linked';\nimport path from 'path';\nimport url from 'url';\n\n// Get the node_modules directory relative to this file\nconst _dirname = path.dirname(typeof __dirname !== 'undefined' ? __dirname : url.fileURLToPath(import.meta.url));\nconst nodeModules = path.join(_dirname, '..', '..', '..', 'node_modules');\n\nlet installed = false;\nlet installing: Promise<void> | null = null;\n\nfunction installDependency(name: string): Promise<void> {\n return new Promise((resolve, reject) => {\n // install-module-linked will:\n // 1. Check if module exists locally or in ~/.iml cache\n // 2. If not, install to ~/.iml\n // 3. Create symlink in nodeModules pointing to ~/.iml/package\n installModule(name, nodeModules, {}, (err) => {\n if (err) return reject(err);\n resolve();\n });\n });\n}\n\nfunction symlinkReactFromInk(): Promise<void> {\n return new Promise((resolve) => {\n // After ink is installed, symlink react to ink's react to avoid duplicate React instances\n const inkPath = fs.realpathSync(path.join(nodeModules, 'ink'));\n const inkReactPath = path.join(inkPath, 'node_modules', 'react');\n const reactPath = path.join(nodeModules, 'react');\n\n // Check if react already exists\n try {\n const stat = fs.lstatSync(reactPath);\n if (stat.isSymbolicLink()) {\n // It's a symlink - check if it points to the right place\n const existing = fs.readlinkSync(reactPath);\n if (existing === inkReactPath) {\n return resolve(); // Already correct\n }\n // Wrong symlink, remove it\n fs.unlinkSync(reactPath);\n } else {\n // It's a real directory (e.g. from devDependencies) - leave it alone\n return resolve();\n }\n } catch {\n // Doesn't exist, continue to create symlink\n }\n\n // Create symlink to ink's react\n try {\n fs.symlinkSync(inkReactPath, reactPath);\n } catch {\n // Ignore errors - react may have been installed another way\n }\n resolve();\n });\n}\n\nfunction installInk(): Promise<void> {\n if (installed) return Promise.resolve();\n if (installing) return installing;\n\n // Install ink, then symlink react to ink's bundled react\n // This ensures session.tsx and ink use the SAME React instance\n installing = installDependency('ink')\n .then(() => symlinkReactFromInk())\n .then(() => {\n installed = true;\n })\n .catch((err) => {\n installing = null;\n throw err;\n });\n\n return installing;\n}\n\nexport function loadInk(callback: (err: Error | null) => void): void {\n installInk()\n .then(() => callback(null))\n .catch((err) => callback(err));\n}\n\nexport function isInkInstalled(): boolean {\n return installed;\n}\n"],"names":["isInkInstalled","loadInk","_dirname","path","dirname","__dirname","url","fileURLToPath","nodeModules","join","installed","installing","installDependency","name","Promise","resolve","reject","installModule","err","symlinkReactFromInk","inkPath","fs","realpathSync","inkReactPath","reactPath","stat","lstatSync","isSymbolicLink","existing","readlinkSync","unlinkSync","symlinkSync","installInk","then","catch","callback"],"mappings":";;;;;;;;;;;QAsFgBA;eAAAA;;QANAC;eAAAA;;;yDAhFD;0EACW;2DACT;0DACD;;;;;;AAEhB,uDAAuD;AACvD,IAAMC,WAAWC,aAAI,CAACC,OAAO,CAAC,OAAOC,cAAc,cAAcA,YAAYC,YAAG,CAACC,aAAa,CAAC;AAC/F,IAAMC,cAAcL,aAAI,CAACM,IAAI,CAACP,UAAU,MAAM,MAAM,MAAM;AAE1D,IAAIQ,YAAY;AAChB,IAAIC,aAAmC;AAEvC,SAASC,kBAAkBC,IAAY;IACrC,OAAO,IAAIC,QAAQ,SAACC,SAASC;QAC3B,8BAA8B;QAC9B,uDAAuD;QACvD,+BAA+B;QAC/B,8DAA8D;QAC9DC,IAAAA,4BAAa,EAACJ,MAAML,aAAa,CAAC,GAAG,SAACU;YACpC,IAAIA,KAAK,OAAOF,OAAOE;YACvBH;QACF;IACF;AACF;AAEA,SAASI;IACP,OAAO,IAAIL,QAAQ,SAACC;QAClB,0FAA0F;QAC1F,IAAMK,UAAUC,WAAE,CAACC,YAAY,CAACnB,aAAI,CAACM,IAAI,CAACD,aAAa;QACvD,IAAMe,eAAepB,aAAI,CAACM,IAAI,CAACW,SAAS,gBAAgB;QACxD,IAAMI,YAAYrB,aAAI,CAACM,IAAI,CAACD,aAAa;QAEzC,gCAAgC;QAChC,IAAI;YACF,IAAMiB,OAAOJ,WAAE,CAACK,SAAS,CAACF;YAC1B,IAAIC,KAAKE,cAAc,IAAI;gBACzB,yDAAyD;gBACzD,IAAMC,WAAWP,WAAE,CAACQ,YAAY,CAACL;gBACjC,IAAII,aAAaL,cAAc;oBAC7B,OAAOR,WAAW,kBAAkB;gBACtC;gBACA,2BAA2B;gBAC3BM,WAAE,CAACS,UAAU,CAACN;YAChB,OAAO;gBACL,qEAAqE;gBACrE,OAAOT;YACT;QACF,EAAE,eAAM;QACN,4CAA4C;QAC9C;QAEA,gCAAgC;QAChC,IAAI;YACFM,WAAE,CAACU,WAAW,CAACR,cAAcC;QAC/B,EAAE,eAAM;QACN,4DAA4D;QAC9D;QACAT;IACF;AACF;AAEA,SAASiB;IACP,IAAItB,WAAW,OAAOI,QAAQC,OAAO;IACrC,IAAIJ,YAAY,OAAOA;IAEvB,yDAAyD;IACzD,+DAA+D;IAC/DA,aAAaC,kBAAkB,OAC5BqB,IAAI,CAAC;eAAMd;OACXc,IAAI,CAAC;QACJvB,YAAY;IACd,GACCwB,KAAK,CAAC,SAAChB;QACNP,aAAa;QACb,MAAMO;IACR;IAEF,OAAOP;AACT;AAEO,SAASV,QAAQkC,QAAqC;IAC3DH,aACGC,IAAI,CAAC;eAAME,SAAS;OACpBD,KAAK,CAAC,SAAChB;eAAQiB,SAASjB;;AAC7B;AAEO,SAASlB;IACd,OAAOU;AACT"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/lib/loadInk.ts"],"sourcesContent":["import fs from 'fs';\nimport installModule from 'install-module-linked';\nimport path from 'path';\nimport url from 'url';\n\n// Get the node_modules directory relative to this file\nconst _dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst nodeModules = path.join(_dirname, '..', '..', '..', 'node_modules');\n\nlet installed = false;\nlet installing: Promise<void> | null = null;\n\nfunction installDependency(name: string): Promise<void> {\n return new Promise((resolve, reject) => {\n // install-module-linked will:\n // 1. Check if module exists locally or in ~/.iml cache\n // 2. If not, install to ~/.iml\n // 3. Create symlink in nodeModules pointing to ~/.iml/package\n installModule(name, nodeModules, {}, (err) => {\n if (err) return reject(err);\n resolve();\n });\n });\n}\n\nfunction symlinkReactFromInk(): Promise<void> {\n return new Promise((resolve) => {\n // After ink is installed, symlink react to ink's react to avoid duplicate React instances\n const inkPath = fs.realpathSync(path.join(nodeModules, 'ink'));\n const inkReactPath = path.join(inkPath, 'node_modules', 'react');\n const reactPath = path.join(nodeModules, 'react');\n\n // Check if react already exists\n try {\n const stat = fs.lstatSync(reactPath);\n if (stat.isSymbolicLink()) {\n // It's a symlink - check if it points to the right place\n const existing = fs.readlinkSync(reactPath);\n if (existing === inkReactPath) {\n return resolve(); // Already correct\n }\n // Wrong symlink, remove it\n fs.unlinkSync(reactPath);\n } else {\n // It's a real directory (e.g. from devDependencies) - leave it alone\n return resolve();\n }\n } catch {\n // Doesn't exist, continue to create symlink\n }\n\n // Create symlink to ink's react\n try {\n fs.symlinkSync(inkReactPath, reactPath);\n } catch {\n // Ignore errors - react may have been installed another way\n }\n resolve();\n });\n}\n\nfunction installInk(): Promise<void> {\n if (installed) return Promise.resolve();\n if (installing) return installing;\n\n // Install ink, then symlink react to ink's bundled react\n // This ensures session.tsx and ink use the SAME React instance\n installing = installDependency('ink')\n .then(() => symlinkReactFromInk())\n .then(() => {\n installed = true;\n })\n .catch((err) => {\n installing = null;\n throw err;\n });\n\n return installing;\n}\n\nexport function loadInk(callback: (err: Error | null) => void): void {\n installInk()\n .then(() => callback(null))\n .catch((err) => callback(err));\n}\n\nexport function isInkInstalled(): boolean {\n return installed;\n}\n"],"names":["isInkInstalled","loadInk","_dirname","path","dirname","__filename","url","fileURLToPath","nodeModules","join","installed","installing","installDependency","name","Promise","resolve","reject","installModule","err","symlinkReactFromInk","inkPath","fs","realpathSync","inkReactPath","reactPath","stat","lstatSync","isSymbolicLink","existing","readlinkSync","unlinkSync","symlinkSync","installInk","then","catch","callback"],"mappings":";;;;;;;;;;;QAsFgBA;eAAAA;;QANAC;eAAAA;;;yDAhFD;0EACW;2DACT;0DACD;;;;;;AAEhB,uDAAuD;AACvD,IAAMC,WAAWC,aAAI,CAACC,OAAO,CAAC,OAAOC,eAAe,cAAcC,YAAG,CAACC,aAAa,CAAC,uDAAmBF;AACvG,IAAMG,cAAcL,aAAI,CAACM,IAAI,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,YAAY;IACd,GACCwB,KAAK,CAAC,SAAChB;QACNP,aAAa;QACb,MAAMO;IACR;IAEF,OAAOP;AACT;AAEO,SAASV,QAAQkC,QAAqC;IAC3DH,aACGC,IAAI,CAAC;eAAME,SAAS;OACpBD,KAAK,CAAC,SAAChB;eAAQiB,SAASjB;;AAC7B;AAEO,SAASlB;IACd,OAAOU;AACT"}
@@ -175,13 +175,11 @@ var SessionImpl = /*#__PURE__*/ function() {
175
175
  this.terminalWidth = 10000;
176
176
  // Only render Ink when stdout is a real terminal
177
177
  // When piped (e.g., nested spawn-term), skip Ink to avoid cursor positioning artifacts
178
- if (process.stdout.isTTY) {
179
- this.inkApp = (0, _ink.render)(/*#__PURE__*/ (0, _jsxruntime.jsx)(_Appts.default, {
180
- store: this.store
181
- }), {
182
- maxFps: _constantsts.DEFAULT_MAX_FPS
183
- });
184
- }
178
+ this.inkApp = (0, _ink.render)(/*#__PURE__*/ (0, _jsxruntime.jsx)(_Appts.default, {
179
+ store: this.store
180
+ }), {
181
+ maxFps: _constantsts.DEFAULT_MAX_FPS
182
+ });
185
183
  // Interactive mode requires a TTY to capture user input (e.g., press 'q' to quit)
186
184
  // Force non-interactive when no UI is rendered, otherwise waitAndClose would hang
187
185
  this.isInteractive = this.inkApp ? (_options_interactive = options.interactive) !== null && _options_interactive !== void 0 ? _options_interactive : false : false;
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/session.tsx"],"sourcesContent":["import spawn, { crossSpawn, type SpawnResult } from 'cross-spawn-cb';\nimport crypto from 'crypto';\nimport { render } from 'ink';\nimport oo from 'on-one';\nimport Queue from 'queue-cb';\n\nimport App from './components/App.ts';\nimport { DEFAULT_MAX_FPS } from './constants.ts';\nimport concatWritable from './lib/concatWritable.ts';\nimport formatArguments from './lib/formatArguments.ts';\nimport { TerminalBuffer } from './lib/TerminalBuffer.ts';\nimport { ProcessStore } from './state/processStore.ts';\nimport type { ProcessOptions, SessionOptions, SpawnError, SpawnOptions, TerminalCallback } from './types.ts';\n\nexport interface Session {\n spawn(command: string, args: string[], spawnOptions: SpawnOptions, options: ProcessOptions, callback: TerminalCallback): void;\n close(): void;\n waitAndClose(callback?: () => void): void;\n}\n\nclass SessionImpl implements Session {\n private store: ProcessStore;\n private inkApp: ReturnType<typeof render> | null = null;\n private runningCount = 0;\n private closed = false;\n private waitCallbacks: (() => void)[] = [];\n private isInteractive: boolean;\n private terminalWidth: number;\n\n constructor(options: SessionOptions = {}) {\n this.store = new ProcessStore(options);\n // Use a very wide buffer to prevent line wrapping in xterm\n // Actual display truncation is handled by Ink components\n this.terminalWidth = 10000;\n\n // Only render Ink when stdout is a real terminal\n // When piped (e.g., nested spawn-term), skip Ink to avoid cursor positioning artifacts\n if (process.stdout.isTTY) {\n this.inkApp = render(<App store={this.store} />, {\n maxFps: DEFAULT_MAX_FPS,\n });\n }\n\n // Interactive mode requires a TTY to capture user input (e.g., press 'q' to quit)\n // Force non-interactive when no UI is rendered, otherwise waitAndClose would hang\n this.isInteractive = this.inkApp ? (options.interactive ?? false) : false;\n }\n\n spawn(command: string, args: string[], spawnOptions: SpawnOptions, options: ProcessOptions, callback: TerminalCallback): void {\n if (this.closed) {\n throw new Error('Session is closed');\n }\n\n const { encoding, stdio, ...csOptions } = spawnOptions;\n\n if (stdio === 'inherit') {\n // When Ink is not rendering (stdout not a TTY), pass output directly to stdout\n if (!this.inkApp) {\n const cp = crossSpawn(command, args, { ...csOptions, stdio: 'inherit' });\n spawn.worker(cp, csOptions, (err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = null;\n res.stderr = null;\n res.output = [null, null, null];\n err ? callback(err) : callback(null, res);\n });\n return;\n }\n\n this.runningCount++;\n const id = crypto.randomUUID();\n\n // Create terminal buffer for ANSI sequence interpretation\n const terminalBuffer = new TerminalBuffer(this.terminalWidth);\n\n this.store.addProcess({\n id,\n title: [command].concat(formatArguments(args)).join(' '),\n state: 'running',\n lines: [],\n terminalBuffer,\n group: options.group,\n expanded: options.expanded,\n });\n\n const cp = crossSpawn(command, args, csOptions);\n\n // Pipe stdout and stderr directly to terminal buffer\n // Both streams go to the same buffer to maintain correct ordering\n if (cp.stdout) {\n cp.stdout.on('data', (chunk: Buffer) => {\n terminalBuffer.write(chunk);\n this.store.notify();\n });\n }\n if (cp.stderr) {\n cp.stderr.on('data', (chunk: Buffer) => {\n terminalBuffer.write(chunk);\n this.store.notify();\n });\n }\n\n // Wait for process to complete\n const queue = new Queue();\n if (cp.stdout) {\n queue.defer(oo.bind(null, cp.stdout, ['error', 'end', 'close']));\n }\n if (cp.stderr) {\n queue.defer(oo.bind(null, cp.stderr, ['error', 'end', 'close']));\n }\n queue.defer(spawn.worker.bind(null, cp, csOptions));\n queue.await((err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = null; // Not collecting raw output in inherit mode\n res.stderr = null;\n res.output = [null, null, null];\n this.store.updateProcess(id, { state: err ? 'error' : 'success' });\n\n this.onProcessComplete();\n err ? callback(err) : callback(null, res);\n });\n } else {\n // Non-inherit mode: collect output but don't display in UI\n const cp = crossSpawn(command, args, csOptions);\n const outputs = { stdout: null as ReturnType<typeof concatWritable> | null, stderr: null as ReturnType<typeof concatWritable> | null };\n\n const queue = new Queue();\n if (cp.stdout) {\n outputs.stdout = concatWritable((output) => {\n (outputs.stdout as unknown as { output: string }).output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), ['error', 'end', 'close', 'finish']));\n }\n if (cp.stderr) {\n outputs.stderr = concatWritable((output) => {\n (outputs.stderr as unknown as { output: string }).output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, cp.stderr.pipe(outputs.stderr), ['error', 'end', 'close', 'finish']));\n }\n queue.defer(spawn.worker.bind(null, cp, csOptions));\n queue.await((err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = outputs.stdout ? (outputs.stdout as unknown as { output: string }).output : null;\n res.stderr = outputs.stderr ? (outputs.stderr as unknown as { output: string }).output : null;\n res.output = [res.stdout, res.stderr, null];\n err ? callback(err) : callback(null, res);\n });\n }\n }\n\n close(): void {\n if (this.closed) return;\n this.closed = true;\n this.cleanup();\n }\n\n waitAndClose(callback?: () => void): void {\n if (this.closed) {\n callback?.();\n return;\n }\n\n if (callback) this.waitCallbacks.push(callback);\n\n if (this.runningCount === 0) {\n if (this.isInteractive) {\n // In interactive mode, wait for user to quit (press 'q')\n const unsubscribe = this.store.subscribe(() => {\n if (this.store.getShouldExit()) {\n unsubscribe();\n this.closeAndCallWaitCallbacks();\n }\n });\n } else {\n this.closeAndCallWaitCallbacks();\n }\n }\n // If runningCount > 0, will close when it hits 0 in onProcessComplete\n }\n\n private onProcessComplete(): void {\n this.runningCount--;\n if (this.runningCount === 0 && this.waitCallbacks.length > 0) {\n if (this.isInteractive) {\n // In interactive mode, wait for user to quit (press 'q')\n const unsubscribe = this.store.subscribe(() => {\n if (this.store.getShouldExit()) {\n unsubscribe();\n this.closeAndCallWaitCallbacks();\n }\n });\n } else {\n this.closeAndCallWaitCallbacks();\n }\n }\n }\n\n private closeAndCallWaitCallbacks(): void {\n if (this.closed) return;\n this.closed = true;\n this.cleanup(() => {\n for (const cb of this.waitCallbacks) cb();\n this.waitCallbacks = [];\n });\n }\n\n private cleanup(onComplete?: () => void): void {\n // Signal exit to React component\n this.store.signalExit(() => {\n this.store.reset();\n process.stdout.write('\\x1b[?25h'); // show cursor\n });\n\n // Wait for Ink to finish\n if (this.inkApp) {\n this.inkApp\n .waitUntilExit()\n .then(() => {\n const cb = this.store.getExitCallback();\n cb?.();\n onComplete?.();\n })\n .catch(() => {\n const cb = this.store.getExitCallback();\n cb?.();\n onComplete?.();\n });\n this.inkApp = null;\n } else {\n onComplete?.();\n }\n }\n}\n\nexport function createSession(options: SessionOptions = {}): Session {\n return new SessionImpl(options);\n}\n"],"names":["createSession","SessionImpl","options","inkApp","runningCount","closed","waitCallbacks","store","ProcessStore","terminalWidth","process","stdout","isTTY","render","App","maxFps","DEFAULT_MAX_FPS","isInteractive","interactive","spawn","command","args","spawnOptions","callback","Error","encoding","stdio","csOptions","cp","crossSpawn","worker","err","res","stderr","output","id","crypto","randomUUID","terminalBuffer","TerminalBuffer","addProcess","title","concat","formatArguments","join","state","lines","group","expanded","on","chunk","write","notify","queue","Queue","defer","oo","bind","await","updateProcess","onProcessComplete","outputs","concatWritable","toString","pipe","close","cleanup","waitAndClose","push","unsubscribe","subscribe","getShouldExit","closeAndCallWaitCallbacks","length","cb","onComplete","signalExit","reset","waitUntilExit","then","getExitCallback","catch"],"mappings":";;;;+BA0OgBA;;;eAAAA;;;;oEA1OoC;6DACjC;mBACI;4DACR;8DACG;4DAEF;2BACgB;uEACL;wEACC;gCACG;8BACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAS7B,IAAA,AAAMC,4BAAN;;aAAMA;YASQC,UAAAA,iEAA0B,CAAC;gCATnCD;YAyBkCC;aAvB9BC,SAA2C;aAC3CC,eAAe;aACfC,SAAS;aACTC,gBAAgC,EAAE;QAKxC,IAAI,CAACC,KAAK,GAAG,IAAIC,4BAAY,CAACN;QAC9B,2DAA2D;QAC3D,yDAAyD;QACzD,IAAI,CAACO,aAAa,GAAG;QAErB,iDAAiD;QACjD,uFAAuF;QACvF,IAAIC,QAAQC,MAAM,CAACC,KAAK,EAAE;YACxB,IAAI,CAACT,MAAM,GAAGU,IAAAA,WAAM,gBAAC,qBAACC,cAAG;gBAACP,OAAO,IAAI,CAACA,KAAK;gBAAM;gBAC/CQ,QAAQC,4BAAe;YACzB;QACF;QAEA,kFAAkF;QAClF,kFAAkF;QAClF,IAAI,CAACC,aAAa,GAAG,IAAI,CAACd,MAAM,IAAID,uBAAAA,QAAQ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AAK5D,aAAa,qBAA9B,SAAA,6BAAA,QAAA,yBAAA;oBAAA,IAAMoE,KAAN;oBAAgCA;;;gBAAhC;gBAAA;;;yBAAA,6BAAA;wBAAA;;;wBAAA;8BAAA;;;;YACL,MAAKpE,aAAa,GAAG,EAAE;QACzB;IACF;IAEA,OAAQ4D,OAyBP,GAzBD,SAAQA,QAAQS,UAAuB;;QACrC,iCAAiC;QACjC,IAAI,CAACpE,KAAK,CAACqE,UAAU,CAAC;YACpB,MAAKrE,KAAK,CAACsE,KAAK;YAChBnE,QAAQC,MAAM,CAACwC,KAAK,CAAC,cAAc,cAAc;QACnD;QAEA,yBAAyB;QACzB,IAAI,IAAI,CAAChD,MAAM,EAAE;YACf,IAAI,CAACA,MAAM,CACR2E,aAAa,GACbC,IAAI,CAAC;gBACJ,IAAML,KAAK,MAAKnE,KAAK,CAACyE,eAAe;gBACrCN,eAAAA,yBAAAA;gBACAC,uBAAAA,iCAAAA;YACF,GACCM,KAAK,CAAC;gBACL,IAAMP,KAAK,MAAKnE,KAAK,CAACyE,eAAe;gBACrCN,eAAAA,yBAAAA;gBACAC,uBAAAA,iCAAAA;YACF;YACF,IAAI,CAACxE,MAAM,GAAG;QAChB,OAAO;YACLwE,uBAAAA,iCAAAA;QACF;IACF;WAnNI1E;;AAsNC,SAASD;QAAcE,UAAAA,iEAA0B,CAAC;IACvD,OAAO,IAAID,YAAYC;AACzB"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/session.tsx"],"sourcesContent":["import spawn, { crossSpawn, type SpawnResult } from 'cross-spawn-cb';\nimport crypto from 'crypto';\nimport { render } from 'ink';\nimport oo from 'on-one';\nimport Queue from 'queue-cb';\n\nimport App from './components/App.ts';\nimport { DEFAULT_MAX_FPS } from './constants.ts';\nimport concatWritable from './lib/concatWritable.ts';\nimport formatArguments from './lib/formatArguments.ts';\nimport { TerminalBuffer } from './lib/TerminalBuffer.ts';\nimport { ProcessStore } from './state/processStore.ts';\nimport type { ProcessOptions, SessionOptions, SpawnError, SpawnOptions, TerminalCallback } from './types.ts';\n\nexport interface Session {\n spawn(command: string, args: string[], spawnOptions: SpawnOptions, options: ProcessOptions, callback: TerminalCallback): void;\n close(): void;\n waitAndClose(callback?: () => void): void;\n}\n\nclass SessionImpl implements Session {\n private store: ProcessStore;\n private inkApp: ReturnType<typeof render> | null = null;\n private runningCount = 0;\n private closed = false;\n private waitCallbacks: (() => void)[] = [];\n private isInteractive: boolean;\n private terminalWidth: number;\n\n constructor(options: SessionOptions = {}) {\n this.store = new ProcessStore(options);\n // Use a very wide buffer to prevent line wrapping in xterm\n // Actual display truncation is handled by Ink components\n this.terminalWidth = 10000;\n\n // Only render Ink when stdout is a real terminal\n // When piped (e.g., nested spawn-term), skip Ink to avoid cursor positioning artifacts\n this.inkApp = render(<App store={this.store} />, { maxFps: DEFAULT_MAX_FPS });\n\n // Interactive mode requires a TTY to capture user input (e.g., press 'q' to quit)\n // Force non-interactive when no UI is rendered, otherwise waitAndClose would hang\n this.isInteractive = this.inkApp ? (options.interactive ?? false) : false;\n }\n\n spawn(command: string, args: string[], spawnOptions: SpawnOptions, options: ProcessOptions, callback: TerminalCallback): void {\n if (this.closed) {\n throw new Error('Session is closed');\n }\n\n const { encoding, stdio, ...csOptions } = spawnOptions;\n\n if (stdio === 'inherit') {\n // When Ink is not rendering (stdout not a TTY), pass output directly to stdout\n if (!this.inkApp) {\n const cp = crossSpawn(command, args, { ...csOptions, stdio: 'inherit' });\n spawn.worker(cp, csOptions, (err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = null;\n res.stderr = null;\n res.output = [null, null, null];\n err ? callback(err) : callback(null, res);\n });\n return;\n }\n\n this.runningCount++;\n const id = crypto.randomUUID();\n\n // Create terminal buffer for ANSI sequence interpretation\n const terminalBuffer = new TerminalBuffer(this.terminalWidth);\n\n this.store.addProcess({\n id,\n title: [command].concat(formatArguments(args)).join(' '),\n state: 'running',\n lines: [],\n terminalBuffer,\n group: options.group,\n expanded: options.expanded,\n });\n\n const cp = crossSpawn(command, args, csOptions);\n\n // Pipe stdout and stderr directly to terminal buffer\n // Both streams go to the same buffer to maintain correct ordering\n if (cp.stdout) {\n cp.stdout.on('data', (chunk: Buffer) => {\n terminalBuffer.write(chunk);\n this.store.notify();\n });\n }\n if (cp.stderr) {\n cp.stderr.on('data', (chunk: Buffer) => {\n terminalBuffer.write(chunk);\n this.store.notify();\n });\n }\n\n // Wait for process to complete\n const queue = new Queue();\n if (cp.stdout) {\n queue.defer(oo.bind(null, cp.stdout, ['error', 'end', 'close']));\n }\n if (cp.stderr) {\n queue.defer(oo.bind(null, cp.stderr, ['error', 'end', 'close']));\n }\n queue.defer(spawn.worker.bind(null, cp, csOptions));\n queue.await((err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = null; // Not collecting raw output in inherit mode\n res.stderr = null;\n res.output = [null, null, null];\n this.store.updateProcess(id, { state: err ? 'error' : 'success' });\n\n this.onProcessComplete();\n err ? callback(err) : callback(null, res);\n });\n } else {\n // Non-inherit mode: collect output but don't display in UI\n const cp = crossSpawn(command, args, csOptions);\n const outputs = { stdout: null as ReturnType<typeof concatWritable> | null, stderr: null as ReturnType<typeof concatWritable> | null };\n\n const queue = new Queue();\n if (cp.stdout) {\n outputs.stdout = concatWritable((output) => {\n (outputs.stdout as unknown as { output: string }).output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), ['error', 'end', 'close', 'finish']));\n }\n if (cp.stderr) {\n outputs.stderr = concatWritable((output) => {\n (outputs.stderr as unknown as { output: string }).output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, cp.stderr.pipe(outputs.stderr), ['error', 'end', 'close', 'finish']));\n }\n queue.defer(spawn.worker.bind(null, cp, csOptions));\n queue.await((err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = outputs.stdout ? (outputs.stdout as unknown as { output: string }).output : null;\n res.stderr = outputs.stderr ? (outputs.stderr as unknown as { output: string }).output : null;\n res.output = [res.stdout, res.stderr, null];\n err ? callback(err) : callback(null, res);\n });\n }\n }\n\n close(): void {\n if (this.closed) return;\n this.closed = true;\n this.cleanup();\n }\n\n waitAndClose(callback?: () => void): void {\n if (this.closed) {\n callback?.();\n return;\n }\n\n if (callback) this.waitCallbacks.push(callback);\n\n if (this.runningCount === 0) {\n if (this.isInteractive) {\n // In interactive mode, wait for user to quit (press 'q')\n const unsubscribe = this.store.subscribe(() => {\n if (this.store.getShouldExit()) {\n unsubscribe();\n this.closeAndCallWaitCallbacks();\n }\n });\n } else {\n this.closeAndCallWaitCallbacks();\n }\n }\n // If runningCount > 0, will close when it hits 0 in onProcessComplete\n }\n\n private onProcessComplete(): void {\n this.runningCount--;\n if (this.runningCount === 0 && this.waitCallbacks.length > 0) {\n if (this.isInteractive) {\n // In interactive mode, wait for user to quit (press 'q')\n const unsubscribe = this.store.subscribe(() => {\n if (this.store.getShouldExit()) {\n unsubscribe();\n this.closeAndCallWaitCallbacks();\n }\n });\n } else {\n this.closeAndCallWaitCallbacks();\n }\n }\n }\n\n private closeAndCallWaitCallbacks(): void {\n if (this.closed) return;\n this.closed = true;\n this.cleanup(() => {\n for (const cb of this.waitCallbacks) cb();\n this.waitCallbacks = [];\n });\n }\n\n private cleanup(onComplete?: () => void): void {\n // Signal exit to React component\n this.store.signalExit(() => {\n this.store.reset();\n process.stdout.write('\\x1b[?25h'); // show cursor\n });\n\n // Wait for Ink to finish\n if (this.inkApp) {\n this.inkApp\n .waitUntilExit()\n .then(() => {\n const cb = this.store.getExitCallback();\n cb?.();\n onComplete?.();\n })\n .catch(() => {\n const cb = this.store.getExitCallback();\n cb?.();\n onComplete?.();\n });\n this.inkApp = null;\n } else {\n onComplete?.();\n }\n }\n}\n\nexport function createSession(options: SessionOptions = {}): Session {\n return new SessionImpl(options);\n}\n"],"names":["createSession","SessionImpl","options","inkApp","runningCount","closed","waitCallbacks","store","ProcessStore","terminalWidth","render","App","maxFps","DEFAULT_MAX_FPS","isInteractive","interactive","spawn","command","args","spawnOptions","callback","Error","encoding","stdio","csOptions","cp","crossSpawn","worker","err","res","stdout","stderr","output","id","crypto","randomUUID","terminalBuffer","TerminalBuffer","addProcess","title","concat","formatArguments","join","state","lines","group","expanded","on","chunk","write","notify","queue","Queue","defer","oo","bind","await","updateProcess","onProcessComplete","outputs","concatWritable","toString","pipe","close","cleanup","waitAndClose","push","unsubscribe","subscribe","getShouldExit","closeAndCallWaitCallbacks","length","cb","onComplete","signalExit","reset","process","waitUntilExit","then","getExitCallback","catch"],"mappings":";;;;+BAsOgBA;;;eAAAA;;;;oEAtOoC;6DACjC;mBACI;4DACR;8DACG;4DAEF;2BACgB;uEACL;wEACC;gCACG;8BACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAS7B,IAAA,AAAMC,4BAAN;;aAAMA;YASQC,UAAAA,iEAA0B,CAAC;gCATnCD;YAqBkCC;aAnB9BC,SAA2C;aAC3CC,eAAe;aACfC,SAAS;aACTC,gBAAgC,EAAE;QAKxC,IAAI,CAACC,KAAK,GAAG,IAAIC,4BAAY,CAACN;QAC9B,2DAA2D;QAC3D,yDAAyD;QACzD,IAAI,CAACO,aAAa,GAAG;QAErB,iDAAiD;QACjD,uFAAuF;QACvF,IAAI,CAACN,MAAM,GAAGO,IAAAA,WAAM,gBAAC,qBAACC,cAAG;YAACJ,OAAO,IAAI,CAACA,KAAK;YAAM;YAAEK,QAAQC,4BAAe;QAAC;QAE3E,kFAAkF;QAClF,kFAAkF;QAClF,IAAI,CAACC,aAAa,GAAG,IAAI,CAACX,MAAM,IAAID,uBAAAA,QAAQa,WAAW,cAAnBb,kCAAAA,uBAAuB,QAAS;;iBArBlED;IAwBJe,OAAAA,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AhC;gBAAA;;;yBAAA,6BAAA;wBAAA;;;wBAAA;8BAAA;;;;YACL,MAAKlE,aAAa,GAAG,EAAE;QACzB;IACF;IAEA,OAAQ0D,OAyBP,GAzBD,SAAQA,QAAQS,UAAuB;;QACrC,iCAAiC;QACjC,IAAI,CAAClE,KAAK,CAACmE,UAAU,CAAC;YACpB,MAAKnE,KAAK,CAACoE,KAAK;YAChBC,QAAQ9C,MAAM,CAACmB,KAAK,CAAC,cAAc,cAAc;QACnD;QAEA,yBAAyB;QACzB,IAAI,IAAI,CAAC9C,MAAM,EAAE;YACf,IAAI,CAACA,MAAM,CACR0E,aAAa,GACbC,IAAI,CAAC;gBACJ,IAAMN,KAAK,MAAKjE,KAAK,CAACwE,eAAe;gBACrCP,eAAAA,yBAAAA;gBACAC,uBAAAA,iCAAAA;YACF,GACCO,KAAK,CAAC;gBACL,IAAMR,KAAK,MAAKjE,KAAK,CAACwE,eAAe;gBACrCP,eAAAA,yBAAAA;gBACAC,uBAAAA,iCAAAA;YACF;YACF,IAAI,CAACtE,MAAM,GAAG;QAChB,OAAO;YACLsE,uBAAAA,iCAAAA;QACF;IACF;WA/MIxE;;AAkNC,SAASD;QAAcE,UAAAA,iEAA0B,CAAC;IACvD,OAAO,IAAID,YAAYC;AACzB"}
@@ -18,9 +18,7 @@ export const PassThrough = major > 0 ? _require('stream').PassThrough : _require
18
18
  * - Falls back to lastIndexOf on Node 0.8-3.x
19
19
  */ const hasEndsWith = typeof String.prototype.endsWith === 'function';
20
20
  export function stringEndsWith(str, search, position) {
21
- if (hasEndsWith) {
22
- return str.endsWith(search, position);
23
- }
21
+ if (hasEndsWith) return str.endsWith(search, position);
24
22
  const len = position === undefined ? str.length : position;
25
23
  return str.lastIndexOf(search) === len - search.length;
26
24
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/compat.ts"],"sourcesContent":["/**\n * Compatibility Layer for Node.js 0.8+\n * Local to this package - contains only needed functions.\n */\n\nimport Module from 'module';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\n/**\n * Stream compatibility - Transform class\n * - Uses native stream.Transform on Node 0.10+\n * - Falls back to readable-stream for Node 0.8\n */\nconst major = +process.versions.node.split('.')[0];\nexport const Readable: typeof import('stream').Readable = major > 0 ? _require('stream').Readable : _require('readable-stream').Readable;\nexport const Writable: typeof import('stream').Writable = major > 0 ? _require('stream').Writable : _require('readable-stream').Writable;\nexport const Transform: typeof import('stream').Transform = major > 0 ? _require('stream').Transform : _require('readable-stream').Transform;\nexport const PassThrough: typeof import('stream').PassThrough = major > 0 ? _require('stream').PassThrough : _require('readable-stream').PassThrough;\n\n/**\n * String.prototype.endsWith wrapper for Node.js 0.8+\n * - Uses native endsWith on Node 4.0+ / ES2015+\n * - Falls back to lastIndexOf on Node 0.8-3.x\n */\nconst hasEndsWith = typeof String.prototype.endsWith === 'function';\nexport function stringEndsWith(str: string, search: string, position?: number): boolean {\n if (hasEndsWith) {\n return str.endsWith(search, position);\n }\n const len = position === undefined ? str.length : position;\n return str.lastIndexOf(search) === len - search.length;\n}\n\n/**\n * Array.prototype.find wrapper for Node.js 0.8+\n * - Uses native find on Node 4.0+ / ES2015+\n * - Falls back to loop on Node 0.8-3.x\n */\nconst hasArrayFind = typeof Array.prototype.find === 'function';\n\nexport function arrayFind<T>(arr: T[], predicate: (item: T, index: number, arr: T[]) => boolean): T | undefined {\n if (hasArrayFind) {\n return arr.find(predicate);\n }\n for (let i = 0; i < arr.length; i++) {\n if (predicate(arr[i], i, arr)) return arr[i];\n }\n return undefined;\n}\n"],"names":["Module","_require","require","createRequire","url","major","process","versions","node","split","Readable","Writable","Transform","PassThrough","hasEndsWith","String","prototype","endsWith","stringEndsWith","str","search","position","len","undefined","length","lastIndexOf","hasArrayFind","Array","find","arrayFind","arr","predicate","i"],"mappings":"AAAA;;;CAGC,GAED,OAAOA,YAAY,SAAS;AAE5B,MAAMC,WAAW,OAAOC,YAAY,cAA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"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/compat.ts"],"sourcesContent":["/**\n * Compatibility Layer for Node.js 0.8+\n * Local to this package - contains only needed functions.\n */\n\nimport Module from 'module';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\n/**\n * Stream compatibility - Transform class\n * - Uses native stream.Transform on Node 0.10+\n * - Falls back to readable-stream for Node 0.8\n */\nconst major = +process.versions.node.split('.')[0];\nexport const Readable: typeof import('stream').Readable = major > 0 ? _require('stream').Readable : _require('readable-stream').Readable;\nexport const Writable: typeof import('stream').Writable = major > 0 ? _require('stream').Writable : _require('readable-stream').Writable;\nexport const Transform: typeof import('stream').Transform = major > 0 ? _require('stream').Transform : _require('readable-stream').Transform;\nexport const PassThrough: typeof import('stream').PassThrough = major > 0 ? _require('stream').PassThrough : _require('readable-stream').PassThrough;\n\n/**\n * String.prototype.endsWith wrapper for Node.js 0.8+\n * - Uses native endsWith on Node 4.0+ / ES2015+\n * - Falls back to lastIndexOf on Node 0.8-3.x\n */\nconst hasEndsWith = typeof String.prototype.endsWith === 'function';\nexport function stringEndsWith(str: string, search: string, position?: number): boolean {\n if (hasEndsWith) return str.endsWith(search, position);\n const len = position === undefined ? str.length : position;\n return str.lastIndexOf(search) === len - search.length;\n}\n\n/**\n * Array.prototype.find wrapper for Node.js 0.8+\n * - Uses native find on Node 4.0+ / ES2015+\n * - Falls back to loop on Node 0.8-3.x\n */\nconst hasArrayFind = typeof Array.prototype.find === 'function';\n\nexport function arrayFind<T>(arr: T[], predicate: (item: T, index: number, arr: T[]) => boolean): T | undefined {\n if (hasArrayFind) {\n return arr.find(predicate);\n }\n for (let i = 0; i < arr.length; i++) {\n if (predicate(arr[i], i, arr)) return arr[i];\n }\n return undefined;\n}\n"],"names":["Module","_require","require","createRequire","url","major","process","versions","node","split","Readable","Writable","Transform","PassThrough","hasEndsWith","String","prototype","endsWith","stringEndsWith","str","search","position","len","undefined","length","lastIndexOf","hasArrayFind","Array","find","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E,EAAE,EAAEA,GAAGF,MAAM,OAAOA,GAAG,CAACE,EAAE;IAC9C;IACA,OAAOT;AACT"}
@@ -3,7 +3,7 @@ import installModule from 'install-module-linked';
3
3
  import path from 'path';
4
4
  import url from 'url';
5
5
  // Get the node_modules directory relative to this file
6
- const _dirname = path.dirname(typeof __dirname !== 'undefined' ? __dirname : url.fileURLToPath(import.meta.url));
6
+ const _dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);
7
7
  const nodeModules = path.join(_dirname, '..', '..', '..', 'node_modules');
8
8
  let installed = false;
9
9
  let installing = null;
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/lib/loadInk.ts"],"sourcesContent":["import fs from 'fs';\nimport installModule from 'install-module-linked';\nimport path from 'path';\nimport url from 'url';\n\n// Get the node_modules directory relative to this file\nconst _dirname = path.dirname(typeof __dirname !== 'undefined' ? __dirname : url.fileURLToPath(import.meta.url));\nconst nodeModules = path.join(_dirname, '..', '..', '..', 'node_modules');\n\nlet installed = false;\nlet installing: Promise<void> | null = null;\n\nfunction installDependency(name: string): Promise<void> {\n return new Promise((resolve, reject) => {\n // install-module-linked will:\n // 1. Check if module exists locally or in ~/.iml cache\n // 2. If not, install to ~/.iml\n // 3. Create symlink in nodeModules pointing to ~/.iml/package\n installModule(name, nodeModules, {}, (err) => {\n if (err) return reject(err);\n resolve();\n });\n });\n}\n\nfunction symlinkReactFromInk(): Promise<void> {\n return new Promise((resolve) => {\n // After ink is installed, symlink react to ink's react to avoid duplicate React instances\n const inkPath = fs.realpathSync(path.join(nodeModules, 'ink'));\n const inkReactPath = path.join(inkPath, 'node_modules', 'react');\n const reactPath = path.join(nodeModules, 'react');\n\n // Check if react already exists\n try {\n const stat = fs.lstatSync(reactPath);\n if (stat.isSymbolicLink()) {\n // It's a symlink - check if it points to the right place\n const existing = fs.readlinkSync(reactPath);\n if (existing === inkReactPath) {\n return resolve(); // Already correct\n }\n // Wrong symlink, remove it\n fs.unlinkSync(reactPath);\n } else {\n // It's a real directory (e.g. from devDependencies) - leave it alone\n return resolve();\n }\n } catch {\n // Doesn't exist, continue to create symlink\n }\n\n // Create symlink to ink's react\n try {\n fs.symlinkSync(inkReactPath, reactPath);\n } catch {\n // Ignore errors - react may have been installed another way\n }\n resolve();\n });\n}\n\nfunction installInk(): Promise<void> {\n if (installed) return Promise.resolve();\n if (installing) return installing;\n\n // Install ink, then symlink react to ink's bundled react\n // This ensures session.tsx and ink use the SAME React instance\n installing = installDependency('ink')\n .then(() => symlinkReactFromInk())\n .then(() => {\n installed = true;\n })\n .catch((err) => {\n installing = null;\n throw err;\n });\n\n return installing;\n}\n\nexport function loadInk(callback: (err: Error | null) => void): void {\n installInk()\n .then(() => callback(null))\n .catch((err) => callback(err));\n}\n\nexport function isInkInstalled(): boolean {\n return installed;\n}\n"],"names":["fs","installModule","path","url","_dirname","dirname","__dirname","fileURLToPath","nodeModules","join","installed","installing","installDependency","name","Promise","resolve","reject","err","symlinkReactFromInk","inkPath","realpathSync","inkReactPath","reactPath","stat","lstatSync","isSymbolicLink","existing","readlinkSync","unlinkSync","symlinkSync","installInk","then","catch","loadInk","callback","isInkInstalled"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,OAAOC,mBAAmB,wBAAwB;AAClD,OAAOC,UAAU,OAAO;AACxB,OAAOC,SAAS,MAAM;AAEtB,uDAAuD;AACvD,MAAMC,WAAWF,KAAKG,OAAO,CAAC,OAAOC,cAAc,cAAcA,YAAYH,IAAII,aAAa,CAAC,YAAYJ,GAAG;AAC9G,MAAMK,cAAcN,KAAKO,IAAI,CAACL,UAAU,MAAM,MAAM,MAAM;AAE1D,IAAIM,YAAY;AAChB,IAAIC,aAAmC;AAEvC,SAASC,kBAAkBC,IAAY;IACrC,OAAO,IAAIC,QAAQ,CAACC,SAASC;QAC3B,8BAA8B;QAC9B,uDAAuD;QACvD,+BAA+B;QAC/B,8DAA8D;QAC9Df,cAA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"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/lib/loadInk.ts"],"sourcesContent":["import fs from 'fs';\nimport installModule from 'install-module-linked';\nimport path from 'path';\nimport url from 'url';\n\n// Get the node_modules directory relative to this file\nconst _dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst nodeModules = path.join(_dirname, '..', '..', '..', 'node_modules');\n\nlet installed = false;\nlet installing: Promise<void> | null = null;\n\nfunction installDependency(name: string): Promise<void> {\n return new Promise((resolve, reject) => {\n // install-module-linked will:\n // 1. Check if module exists locally or in ~/.iml cache\n // 2. If not, install to ~/.iml\n // 3. Create symlink in nodeModules pointing to ~/.iml/package\n installModule(name, nodeModules, {}, (err) => {\n if (err) return reject(err);\n resolve();\n });\n });\n}\n\nfunction symlinkReactFromInk(): Promise<void> {\n return new Promise((resolve) => {\n // After ink is installed, symlink react to ink's react to avoid duplicate React instances\n const inkPath = fs.realpathSync(path.join(nodeModules, 'ink'));\n const inkReactPath = path.join(inkPath, 'node_modules', 'react');\n const reactPath = path.join(nodeModules, 'react');\n\n // Check if react already exists\n try {\n const stat = fs.lstatSync(reactPath);\n if (stat.isSymbolicLink()) {\n // It's a symlink - check if it points to the right place\n const existing = fs.readlinkSync(reactPath);\n if (existing === inkReactPath) {\n return resolve(); // Already correct\n }\n // Wrong symlink, remove it\n fs.unlinkSync(reactPath);\n } else {\n // It's a real directory (e.g. from devDependencies) - leave it alone\n return resolve();\n }\n } catch {\n // Doesn't exist, continue to create symlink\n }\n\n // Create symlink to ink's react\n try {\n fs.symlinkSync(inkReactPath, reactPath);\n } catch {\n // Ignore errors - react may have been installed another way\n }\n resolve();\n });\n}\n\nfunction installInk(): Promise<void> {\n if (installed) return Promise.resolve();\n if (installing) return installing;\n\n // Install ink, then symlink react to ink's bundled react\n // This ensures session.tsx and ink use the SAME React instance\n installing = installDependency('ink')\n .then(() => symlinkReactFromInk())\n .then(() => {\n installed = true;\n })\n .catch((err) => {\n installing = null;\n throw err;\n });\n\n return installing;\n}\n\nexport function loadInk(callback: (err: Error | null) => void): void {\n installInk()\n .then(() => callback(null))\n .catch((err) => callback(err));\n}\n\nexport function isInkInstalled(): boolean {\n return installed;\n}\n"],"names":["fs","installModule","path","url","_dirname","dirname","__filename","fileURLToPath","nodeModules","join","installed","installing","installDependency","name","Promise","resolve","reject","err","symlinkReactFromInk","inkPath","realpathSync","inkReactPath","reactPath","stat","lstatSync","isSymbolicLink","existing","readlinkSync","unlinkSync","symlinkSync","installInk","then","catch","loadInk","callback","isInkInstalled"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,OAAOC,mBAAmB,wBAAwB;AAClD,OAAOC,UAAU,OAAO;AACxB,OAAOC,SAAS,MAAM;AAEtB,uDAAuD;AACvD,MAAMC,WAAWF,KAAKG,OAAO,CAAC,OAAOC,eAAe,cAAcH,IAAII,aAAa,CAAC,YAAYJ,GAAG,IAAIG;AACvG,MAAME,cAAcN,KAAKO,IAAI,CAACL,UAAU,MAAM,MAAM,MAAM;AAE1D,IAAIM,YAAY;AAChB,IAAIC,aAAmC;AAEvC,SAASC,kBAAkBC,IAAY;IACrC,OAAO,IAAIC,QAAQ,CAACC,SAASC;QAC3B,8BAA8B;QAC9B,uDAAuD;QACvD,+BAA+B;QAC/B,8DAA8D;QAC9Df,cAAcY,MAAML,aAAa,CAAC,GAAG,CAACS;YACpC,IAAIA,KAAK,OAAOD,OAAOC;YACvBF;QACF;IACF;AACF;AAEA,SAASG;IACP,OAAO,IAAIJ,QAAQ,CAACC;QAClB,0FAA0F;QAC1F,MAAMI,UAAUnB,GAAGoB,YAAY,CAAClB,KAAKO,IAAI,CAACD,aAAa;QACvD,MAAMa,eAAenB,KAAKO,IAAI,CAACU,SAAS,gBAAgB;QACxD,MAAMG,YAAYpB,KAAKO,IAAI,CAACD,aAAa;QAEzC,gCAAgC;QAChC,IAAI;YACF,MAAMe,OAAOvB,GAAGwB,SAAS,CAACF;YAC1B,IAAIC,KAAKE,cAAc,IAAI;gBACzB,yDAAyD;gBACzD,MAAMC,WAAW1B,GAAG2B,YAAY,CAACL;gBACjC,IAAII,aAAaL,cAAc;oBAC7B,OAAON,WAAW,kBAAkB;gBACtC;gBACA,2BAA2B;gBAC3Bf,GAAG4B,UAAU,CAACN;YAChB,OAAO;gBACL,qEAAqE;gBACrE,OAAOP;YACT;QACF,EAAE,OAAM;QACN,4CAA4C;QAC9C;QAEA,gCAAgC;QAChC,IAAI;YACFf,GAAG6B,WAAW,CAACR,cAAcC;QAC/B,EAAE,OAAM;QACN,4DAA4D;QAC9D;QACAP;IACF;AACF;AAEA,SAASe;IACP,IAAIpB,WAAW,OAAOI,QAAQC,OAAO;IACrC,IAAIJ,YAAY,OAAOA;IAEvB,yDAAyD;IACzD,+DAA+D;IAC/DA,aAAaC,kBAAkB,OAC5BmB,IAAI,CAAC,IAAMb,uBACXa,IAAI,CAAC;QACJrB,YAAY;IACd,GACCsB,KAAK,CAAC,CAACf;QACNN,aAAa;QACb,MAAMM;IACR;IAEF,OAAON;AACT;AAEA,OAAO,SAASsB,QAAQC,QAAqC;IAC3DJ,aACGC,IAAI,CAAC,IAAMG,SAAS,OACpBF,KAAK,CAAC,CAACf,MAAQiB,SAASjB;AAC7B;AAEA,OAAO,SAASkB;IACd,OAAOzB;AACT"}
@@ -226,13 +226,11 @@ let SessionImpl = class SessionImpl {
226
226
  this.terminalWidth = 10000;
227
227
  // Only render Ink when stdout is a real terminal
228
228
  // When piped (e.g., nested spawn-term), skip Ink to avoid cursor positioning artifacts
229
- if (process.stdout.isTTY) {
230
- this.inkApp = render(/*#__PURE__*/ _jsx(App, {
231
- store: this.store
232
- }), {
233
- maxFps: DEFAULT_MAX_FPS
234
- });
235
- }
229
+ this.inkApp = render(/*#__PURE__*/ _jsx(App, {
230
+ store: this.store
231
+ }), {
232
+ maxFps: DEFAULT_MAX_FPS
233
+ });
236
234
  // Interactive mode requires a TTY to capture user input (e.g., press 'q' to quit)
237
235
  // Force non-interactive when no UI is rendered, otherwise waitAndClose would hang
238
236
  this.isInteractive = this.inkApp ? (_options_interactive = options.interactive) !== null && _options_interactive !== void 0 ? _options_interactive : false : false;
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/session.tsx"],"sourcesContent":["import spawn, { crossSpawn, type SpawnResult } from 'cross-spawn-cb';\nimport crypto from 'crypto';\nimport { render } from 'ink';\nimport oo from 'on-one';\nimport Queue from 'queue-cb';\n\nimport App from './components/App.ts';\nimport { DEFAULT_MAX_FPS } from './constants.ts';\nimport concatWritable from './lib/concatWritable.ts';\nimport formatArguments from './lib/formatArguments.ts';\nimport { TerminalBuffer } from './lib/TerminalBuffer.ts';\nimport { ProcessStore } from './state/processStore.ts';\nimport type { ProcessOptions, SessionOptions, SpawnError, SpawnOptions, TerminalCallback } from './types.ts';\n\nexport interface Session {\n spawn(command: string, args: string[], spawnOptions: SpawnOptions, options: ProcessOptions, callback: TerminalCallback): void;\n close(): void;\n waitAndClose(callback?: () => void): void;\n}\n\nclass SessionImpl implements Session {\n private store: ProcessStore;\n private inkApp: ReturnType<typeof render> | null = null;\n private runningCount = 0;\n private closed = false;\n private waitCallbacks: (() => void)[] = [];\n private isInteractive: boolean;\n private terminalWidth: number;\n\n constructor(options: SessionOptions = {}) {\n this.store = new ProcessStore(options);\n // Use a very wide buffer to prevent line wrapping in xterm\n // Actual display truncation is handled by Ink components\n this.terminalWidth = 10000;\n\n // Only render Ink when stdout is a real terminal\n // When piped (e.g., nested spawn-term), skip Ink to avoid cursor positioning artifacts\n if (process.stdout.isTTY) {\n this.inkApp = render(<App store={this.store} />, {\n maxFps: DEFAULT_MAX_FPS,\n });\n }\n\n // Interactive mode requires a TTY to capture user input (e.g., press 'q' to quit)\n // Force non-interactive when no UI is rendered, otherwise waitAndClose would hang\n this.isInteractive = this.inkApp ? (options.interactive ?? false) : false;\n }\n\n spawn(command: string, args: string[], spawnOptions: SpawnOptions, options: ProcessOptions, callback: TerminalCallback): void {\n if (this.closed) {\n throw new Error('Session is closed');\n }\n\n const { encoding, stdio, ...csOptions } = spawnOptions;\n\n if (stdio === 'inherit') {\n // When Ink is not rendering (stdout not a TTY), pass output directly to stdout\n if (!this.inkApp) {\n const cp = crossSpawn(command, args, { ...csOptions, stdio: 'inherit' });\n spawn.worker(cp, csOptions, (err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = null;\n res.stderr = null;\n res.output = [null, null, null];\n err ? callback(err) : callback(null, res);\n });\n return;\n }\n\n this.runningCount++;\n const id = crypto.randomUUID();\n\n // Create terminal buffer for ANSI sequence interpretation\n const terminalBuffer = new TerminalBuffer(this.terminalWidth);\n\n this.store.addProcess({\n id,\n title: [command].concat(formatArguments(args)).join(' '),\n state: 'running',\n lines: [],\n terminalBuffer,\n group: options.group,\n expanded: options.expanded,\n });\n\n const cp = crossSpawn(command, args, csOptions);\n\n // Pipe stdout and stderr directly to terminal buffer\n // Both streams go to the same buffer to maintain correct ordering\n if (cp.stdout) {\n cp.stdout.on('data', (chunk: Buffer) => {\n terminalBuffer.write(chunk);\n this.store.notify();\n });\n }\n if (cp.stderr) {\n cp.stderr.on('data', (chunk: Buffer) => {\n terminalBuffer.write(chunk);\n this.store.notify();\n });\n }\n\n // Wait for process to complete\n const queue = new Queue();\n if (cp.stdout) {\n queue.defer(oo.bind(null, cp.stdout, ['error', 'end', 'close']));\n }\n if (cp.stderr) {\n queue.defer(oo.bind(null, cp.stderr, ['error', 'end', 'close']));\n }\n queue.defer(spawn.worker.bind(null, cp, csOptions));\n queue.await((err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = null; // Not collecting raw output in inherit mode\n res.stderr = null;\n res.output = [null, null, null];\n this.store.updateProcess(id, { state: err ? 'error' : 'success' });\n\n this.onProcessComplete();\n err ? callback(err) : callback(null, res);\n });\n } else {\n // Non-inherit mode: collect output but don't display in UI\n const cp = crossSpawn(command, args, csOptions);\n const outputs = { stdout: null as ReturnType<typeof concatWritable> | null, stderr: null as ReturnType<typeof concatWritable> | null };\n\n const queue = new Queue();\n if (cp.stdout) {\n outputs.stdout = concatWritable((output) => {\n (outputs.stdout as unknown as { output: string }).output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), ['error', 'end', 'close', 'finish']));\n }\n if (cp.stderr) {\n outputs.stderr = concatWritable((output) => {\n (outputs.stderr as unknown as { output: string }).output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, cp.stderr.pipe(outputs.stderr), ['error', 'end', 'close', 'finish']));\n }\n queue.defer(spawn.worker.bind(null, cp, csOptions));\n queue.await((err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = outputs.stdout ? (outputs.stdout as unknown as { output: string }).output : null;\n res.stderr = outputs.stderr ? (outputs.stderr as unknown as { output: string }).output : null;\n res.output = [res.stdout, res.stderr, null];\n err ? callback(err) : callback(null, res);\n });\n }\n }\n\n close(): void {\n if (this.closed) return;\n this.closed = true;\n this.cleanup();\n }\n\n waitAndClose(callback?: () => void): void {\n if (this.closed) {\n callback?.();\n return;\n }\n\n if (callback) this.waitCallbacks.push(callback);\n\n if (this.runningCount === 0) {\n if (this.isInteractive) {\n // In interactive mode, wait for user to quit (press 'q')\n const unsubscribe = this.store.subscribe(() => {\n if (this.store.getShouldExit()) {\n unsubscribe();\n this.closeAndCallWaitCallbacks();\n }\n });\n } else {\n this.closeAndCallWaitCallbacks();\n }\n }\n // If runningCount > 0, will close when it hits 0 in onProcessComplete\n }\n\n private onProcessComplete(): void {\n this.runningCount--;\n if (this.runningCount === 0 && this.waitCallbacks.length > 0) {\n if (this.isInteractive) {\n // In interactive mode, wait for user to quit (press 'q')\n const unsubscribe = this.store.subscribe(() => {\n if (this.store.getShouldExit()) {\n unsubscribe();\n this.closeAndCallWaitCallbacks();\n }\n });\n } else {\n this.closeAndCallWaitCallbacks();\n }\n }\n }\n\n private closeAndCallWaitCallbacks(): void {\n if (this.closed) return;\n this.closed = true;\n this.cleanup(() => {\n for (const cb of this.waitCallbacks) cb();\n this.waitCallbacks = [];\n });\n }\n\n private cleanup(onComplete?: () => void): void {\n // Signal exit to React component\n this.store.signalExit(() => {\n this.store.reset();\n process.stdout.write('\\x1b[?25h'); // show cursor\n });\n\n // Wait for Ink to finish\n if (this.inkApp) {\n this.inkApp\n .waitUntilExit()\n .then(() => {\n const cb = this.store.getExitCallback();\n cb?.();\n onComplete?.();\n })\n .catch(() => {\n const cb = this.store.getExitCallback();\n cb?.();\n onComplete?.();\n });\n this.inkApp = null;\n } else {\n onComplete?.();\n }\n }\n}\n\nexport function createSession(options: SessionOptions = {}): Session {\n return new SessionImpl(options);\n}\n"],"names":["spawn","crossSpawn","crypto","render","oo","Queue","App","DEFAULT_MAX_FPS","concatWritable","formatArguments","TerminalBuffer","ProcessStore","SessionImpl","command","args","spawnOptions","options","callback","closed","Error","encoding","stdio","csOptions","inkApp","cp","worker","err","res","stdout","stderr","output","runningCount","id","randomUUID","terminalBuffer","terminalWidth","store","addProcess","title","concat","join","state","lines","group","expanded","on","chunk","write","notify","queue","defer","bind","await","updateProcess","onProcessComplete","outputs","toString","pipe","close","cleanup","waitAndClose","waitCallbacks","push","isInteractive","unsubscribe","subscribe","getShouldExit","closeAndCallWaitCallbacks","length","cb","onComplete","signalExit","reset","process","waitUntilExit","then","getExitCallback","catch","isTTY","maxFps","interactive","createSession"],"mappings":";AAAA,OAAOA,SAASC,UAAU,QAA0B,iBAAiB;AACrE,OAAOC,YAAY,SAAS;AAC5B,SAASC,MAAM,QAAQ,MAAM;AAC7B,OAAOC,QAAQ,SAAS;AACxB,OAAOC,WAAW,WAAW;AAE7B,OAAOC,SAAS,sBAAsB;AACtC,SAASC,eAAe,QAAQ,iBAAiB;AACjD,OAAOC,oBAAoB,0BAA0B;AACrD,OAAOC,qBAAqB,2BAA2B;AACvD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,YAAY,QAAQ,0BAA0B;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;QACnD;QAEA,yBAAyB;QACzB,IAAI,IAAI,CAACxB,MAAM,EAAE;YACf,IAAI,CAACA,MAAM,CACRmD,aAAa,GACbC,IAAI,CAAC;gBACJ,MAAMN,KAAK,IAAI,CAACjC,KAAK,CAACwC,eAAe;gBACrCP,eAAAA,yBAAAA;gBACAC,uBAAAA,iCAAAA;YACF,GACCO,KAAK,CAAC;gBACL,MAAMR,KAAK,IAAI,CAACjC,KAAK,CAACwC,eAAe;gBACrCP,eAAAA,yBAAAA;gBACAC,uBAAAA,iCAAAA;YACF;YACF,IAAI,CAAC/C,MAAM,GAAG;QAChB,OAAO;YACL+C,uBAAAA,iCAAAA;QACF;IACF;IA1MA,YAAYtD,UAA0B,CAAC,CAAC,CAAE;YAgBJA;aAvB9BO,SAA2C;aAC3CQ,eAAe;aACfb,SAAS;aACT2C,gBAAgC,EAAE;QAKxC,IAAI,CAACzB,KAAK,GAAG,IAAIzB,aAAaK;QAC9B,2DAA2D;QAC3D,yDAAyD;QACzD,IAAI,CAACmB,aAAa,GAAG;QAErB,iDAAiD;QACjD,uFAAuF;QACvF,IAAIsC,QAAQ7C,MAAM,CAACkD,KAAK,EAAE;YACxB,IAAI,CAACvD,MAAM,GAAGpB,qBAAO,KAACG;gBAAI8B,OAAO,IAAI,CAACA,KAAK;gBAAM;gBAC/C2C,QAAQxE;YACV;QACF;QAEA,kFAAkF;QAClF,kFAAkF;QAClF,IAAI,CAACwD,aAAa,GAAG,IAAI,CAACxC,MAAM,IAAIP,uBAAAA,QAAQgE,WAAW,cAAnBhE,kCAAAA,uBAAuB,QAAS;IACtE;AA0LF;AAEA,OAAO,SAASiE,cAAcjE,UAA0B,CAAC,CAAC;IACxD,OAAO,IAAIJ,YAAYI;AACzB"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/session.tsx"],"sourcesContent":["import spawn, { crossSpawn, type SpawnResult } from 'cross-spawn-cb';\nimport crypto from 'crypto';\nimport { render } from 'ink';\nimport oo from 'on-one';\nimport Queue from 'queue-cb';\n\nimport App from './components/App.ts';\nimport { DEFAULT_MAX_FPS } from './constants.ts';\nimport concatWritable from './lib/concatWritable.ts';\nimport formatArguments from './lib/formatArguments.ts';\nimport { TerminalBuffer } from './lib/TerminalBuffer.ts';\nimport { ProcessStore } from './state/processStore.ts';\nimport type { ProcessOptions, SessionOptions, SpawnError, SpawnOptions, TerminalCallback } from './types.ts';\n\nexport interface Session {\n spawn(command: string, args: string[], spawnOptions: SpawnOptions, options: ProcessOptions, callback: TerminalCallback): void;\n close(): void;\n waitAndClose(callback?: () => void): void;\n}\n\nclass SessionImpl implements Session {\n private store: ProcessStore;\n private inkApp: ReturnType<typeof render> | null = null;\n private runningCount = 0;\n private closed = false;\n private waitCallbacks: (() => void)[] = [];\n private isInteractive: boolean;\n private terminalWidth: number;\n\n constructor(options: SessionOptions = {}) {\n this.store = new ProcessStore(options);\n // Use a very wide buffer to prevent line wrapping in xterm\n // Actual display truncation is handled by Ink components\n this.terminalWidth = 10000;\n\n // Only render Ink when stdout is a real terminal\n // When piped (e.g., nested spawn-term), skip Ink to avoid cursor positioning artifacts\n this.inkApp = render(<App store={this.store} />, { maxFps: DEFAULT_MAX_FPS });\n\n // Interactive mode requires a TTY to capture user input (e.g., press 'q' to quit)\n // Force non-interactive when no UI is rendered, otherwise waitAndClose would hang\n this.isInteractive = this.inkApp ? (options.interactive ?? false) : false;\n }\n\n spawn(command: string, args: string[], spawnOptions: SpawnOptions, options: ProcessOptions, callback: TerminalCallback): void {\n if (this.closed) {\n throw new Error('Session is closed');\n }\n\n const { encoding, stdio, ...csOptions } = spawnOptions;\n\n if (stdio === 'inherit') {\n // When Ink is not rendering (stdout not a TTY), pass output directly to stdout\n if (!this.inkApp) {\n const cp = crossSpawn(command, args, { ...csOptions, stdio: 'inherit' });\n spawn.worker(cp, csOptions, (err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = null;\n res.stderr = null;\n res.output = [null, null, null];\n err ? callback(err) : callback(null, res);\n });\n return;\n }\n\n this.runningCount++;\n const id = crypto.randomUUID();\n\n // Create terminal buffer for ANSI sequence interpretation\n const terminalBuffer = new TerminalBuffer(this.terminalWidth);\n\n this.store.addProcess({\n id,\n title: [command].concat(formatArguments(args)).join(' '),\n state: 'running',\n lines: [],\n terminalBuffer,\n group: options.group,\n expanded: options.expanded,\n });\n\n const cp = crossSpawn(command, args, csOptions);\n\n // Pipe stdout and stderr directly to terminal buffer\n // Both streams go to the same buffer to maintain correct ordering\n if (cp.stdout) {\n cp.stdout.on('data', (chunk: Buffer) => {\n terminalBuffer.write(chunk);\n this.store.notify();\n });\n }\n if (cp.stderr) {\n cp.stderr.on('data', (chunk: Buffer) => {\n terminalBuffer.write(chunk);\n this.store.notify();\n });\n }\n\n // Wait for process to complete\n const queue = new Queue();\n if (cp.stdout) {\n queue.defer(oo.bind(null, cp.stdout, ['error', 'end', 'close']));\n }\n if (cp.stderr) {\n queue.defer(oo.bind(null, cp.stderr, ['error', 'end', 'close']));\n }\n queue.defer(spawn.worker.bind(null, cp, csOptions));\n queue.await((err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = null; // Not collecting raw output in inherit mode\n res.stderr = null;\n res.output = [null, null, null];\n this.store.updateProcess(id, { state: err ? 'error' : 'success' });\n\n this.onProcessComplete();\n err ? callback(err) : callback(null, res);\n });\n } else {\n // Non-inherit mode: collect output but don't display in UI\n const cp = crossSpawn(command, args, csOptions);\n const outputs = { stdout: null as ReturnType<typeof concatWritable> | null, stderr: null as ReturnType<typeof concatWritable> | null };\n\n const queue = new Queue();\n if (cp.stdout) {\n outputs.stdout = concatWritable((output) => {\n (outputs.stdout as unknown as { output: string }).output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, cp.stdout.pipe(outputs.stdout), ['error', 'end', 'close', 'finish']));\n }\n if (cp.stderr) {\n outputs.stderr = concatWritable((output) => {\n (outputs.stderr as unknown as { output: string }).output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, cp.stderr.pipe(outputs.stderr), ['error', 'end', 'close', 'finish']));\n }\n queue.defer(spawn.worker.bind(null, cp, csOptions));\n queue.await((err?: SpawnError) => {\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = outputs.stdout ? (outputs.stdout as unknown as { output: string }).output : null;\n res.stderr = outputs.stderr ? (outputs.stderr as unknown as { output: string }).output : null;\n res.output = [res.stdout, res.stderr, null];\n err ? callback(err) : callback(null, res);\n });\n }\n }\n\n close(): void {\n if (this.closed) return;\n this.closed = true;\n this.cleanup();\n }\n\n waitAndClose(callback?: () => void): void {\n if (this.closed) {\n callback?.();\n return;\n }\n\n if (callback) this.waitCallbacks.push(callback);\n\n if (this.runningCount === 0) {\n if (this.isInteractive) {\n // In interactive mode, wait for user to quit (press 'q')\n const unsubscribe = this.store.subscribe(() => {\n if (this.store.getShouldExit()) {\n unsubscribe();\n this.closeAndCallWaitCallbacks();\n }\n });\n } else {\n this.closeAndCallWaitCallbacks();\n }\n }\n // If runningCount > 0, will close when it hits 0 in onProcessComplete\n }\n\n private onProcessComplete(): void {\n this.runningCount--;\n if (this.runningCount === 0 && this.waitCallbacks.length > 0) {\n if (this.isInteractive) {\n // In interactive mode, wait for user to quit (press 'q')\n const unsubscribe = this.store.subscribe(() => {\n if (this.store.getShouldExit()) {\n unsubscribe();\n this.closeAndCallWaitCallbacks();\n }\n });\n } else {\n this.closeAndCallWaitCallbacks();\n }\n }\n }\n\n private closeAndCallWaitCallbacks(): void {\n if (this.closed) return;\n this.closed = true;\n this.cleanup(() => {\n for (const cb of this.waitCallbacks) cb();\n this.waitCallbacks = [];\n });\n }\n\n private cleanup(onComplete?: () => void): void {\n // Signal exit to React component\n this.store.signalExit(() => {\n this.store.reset();\n process.stdout.write('\\x1b[?25h'); // show cursor\n });\n\n // Wait for Ink to finish\n if (this.inkApp) {\n this.inkApp\n .waitUntilExit()\n .then(() => {\n const cb = this.store.getExitCallback();\n cb?.();\n onComplete?.();\n })\n .catch(() => {\n const cb = this.store.getExitCallback();\n cb?.();\n onComplete?.();\n });\n this.inkApp = null;\n } else {\n onComplete?.();\n }\n }\n}\n\nexport function createSession(options: SessionOptions = {}): Session {\n return new SessionImpl(options);\n}\n"],"names":["spawn","crossSpawn","crypto","render","oo","Queue","App","DEFAULT_MAX_FPS","concatWritable","formatArguments","TerminalBuffer","ProcessStore","SessionImpl","command","args","spawnOptions","options","callback","closed","Error","encoding","stdio","csOptions","inkApp","cp","worker","err","res","stdout","stderr","output","runningCount","id","randomUUID","terminalBuffer","terminalWidth","store","addProcess","title","concat","join","state","lines","group","expanded","on","chunk","write","notify","queue","defer","bind","await","updateProcess","onProcessComplete","outputs","toString","pipe","close","cleanup","waitAndClose","waitCallbacks","push","isInteractive","unsubscribe","subscribe","getShouldExit","closeAndCallWaitCallbacks","length","cb","onComplete","signalExit","reset","process","waitUntilExit","then","getExitCallback","catch","maxFps","interactive","createSession"],"mappings":";AAAA,OAAOA,SAASC,UAAU,QAA0B,iBAAiB;AACrE,OAAOC,YAAY,SAAS;AAC5B,SAASC,MAAM,QAAQ,MAAM;AAC7B,OAAOC,QAAQ,SAAS;AACxB,OAAOC,WAAW,WAAW;AAE7B,OAAOC,SAAS,sBAAsB;AACtC,SAASC,eAAe,QAAQ,iBAAiB;AACjD,OAAOC,oBAAoB,0BAA0B;AACrD,OAAOC,qBAAqB,2BAA2B;AACvD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,YAAY,QAAQ,0BAA0B;AASvD,IAAA,AAAMC,cAAN,MAAMA;IAwBJZ,MAAMa,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAAuB,EAAEC,QAA0B,EAAQ;QAC5H,IAAI,IAAI,CAACC,MAAM,EAAE;YACf,MAAM,IAAIC,MAAM;QAClB;QAEA,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAE,GAAGC,WAAW,GAAGP;QAE1C,IAAIM,UAAU,WAAW;YACvB,+EAA+E;YAC/E,IA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,yBAAAA;gBACAC,uBAAAA,iCAAAA;YACF;YACF,IAAI,CAAC/C,MAAM,GAAG;QAChB,OAAO;YACL+C,uBAAAA,iCAAAA;QACF;IACF;IAtMA,YAAYtD,UAA0B,CAAC,CAAC,CAAE;YAYJA;aAnB9BO,SAA2C;aAC3CQ,eAAe;aACfb,SAAS;aACT2C,gBAAgC,EAAE;QAKxC,IAAI,CAACzB,KAAK,GAAG,IAAIzB,aAAaK;QAC9B,2DAA2D;QAC3D,yDAAyD;QACzD,IAAI,CAACmB,aAAa,GAAG;QAErB,iDAAiD;QACjD,uFAAuF;QACvF,IAAI,CAACZ,MAAM,GAAGpB,qBAAO,KAACG;YAAI8B,OAAO,IAAI,CAACA,KAAK;YAAM;YAAE0C,QAAQvE;QAAgB;QAE3E,kFAAkF;QAClF,kFAAkF;QAClF,IAAI,CAACwD,aAAa,GAAG,IAAI,CAACxC,MAAM,IAAIP,uBAAAA,QAAQ+D,WAAW,cAAnB/D,kCAAAA,uBAAuB,QAAS;IACtE;AA0LF;AAEA,OAAO,SAASgE,cAAchE,UAA0B,CAAC,CAAC;IACxD,OAAO,IAAIJ,YAAYI;AACzB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spawn-term",
3
- "version": "3.4.0",
3
+ "version": "3.4.2",
4
4
  "description": "Formats spawn with for terminal grouping",
5
5
  "keywords": [
6
6
  "spawn",
@@ -42,7 +42,7 @@
42
42
  "version": "tsds version"
43
43
  },
44
44
  "dependencies": {
45
- "@xterm/headless": "^5.5.0",
45
+ "@xterm/headless": "^6.0.0",
46
46
  "cross-spawn-cb": "^3.0.0",
47
47
  "install-module-linked": "^1.3.16",
48
48
  "on-one": "^1.0.0",