spawn-streaming
Advanced tools
| type LineCallback = (line: string) => void; | ||
| export default class LineBuffer { | ||
| private cells; | ||
| private cursor; | ||
| private activeSgr; | ||
| private flushTimer; | ||
| private onLine; | ||
| private flushTimeout; | ||
| constructor(onLine: LineCallback, flushTimeout?: number); | ||
| write(input: string | Buffer): void; | ||
| private handleCSI; | ||
| private emitLine; | ||
| private renderLine; | ||
| private reset; | ||
| private scheduleFlushTimer; | ||
| private cancelFlushTimer; | ||
| /** | ||
| * Flush any remaining buffered content. | ||
| * Call this when the stream ends to emit any partial line. | ||
| */ | ||
| flush(): void; | ||
| /** | ||
| * Clean up resources (timers). | ||
| */ | ||
| dispose(): void; | ||
| } | ||
| export {}; |
| type LineCallback = (line: string) => void; | ||
| export default class LineBuffer { | ||
| private cells; | ||
| private cursor; | ||
| private activeSgr; | ||
| private flushTimer; | ||
| private onLine; | ||
| private flushTimeout; | ||
| constructor(onLine: LineCallback, flushTimeout?: number); | ||
| write(input: string | Buffer): void; | ||
| private handleCSI; | ||
| private emitLine; | ||
| private renderLine; | ||
| private reset; | ||
| private scheduleFlushTimer; | ||
| private cancelFlushTimer; | ||
| /** | ||
| * Flush any remaining buffered content. | ||
| * Call this when the stream ends to emit any partial line. | ||
| */ | ||
| flush(): void; | ||
| /** | ||
| * Clean up resources (timers). | ||
| */ | ||
| dispose(): void; | ||
| } | ||
| export {}; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| Object.defineProperty(exports, "default", { | ||
| enumerable: true, | ||
| get: function() { | ||
| return LineBuffer; | ||
| } | ||
| }); | ||
| function _array_like_to_array(arr, len) { | ||
| if (len == null || len > arr.length) len = arr.length; | ||
| for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i]; | ||
| return arr2; | ||
| } | ||
| function _array_with_holes(arr) { | ||
| if (Array.isArray(arr)) return arr; | ||
| } | ||
| function _array_without_holes(arr) { | ||
| if (Array.isArray(arr)) return _array_like_to_array(arr); | ||
| } | ||
| function _class_call_check(instance, Constructor) { | ||
| if (!(instance instanceof Constructor)) { | ||
| throw new TypeError("Cannot call a class as a function"); | ||
| } | ||
| } | ||
| function _iterable_to_array(iter) { | ||
| if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); | ||
| } | ||
| function _iterable_to_array_limit(arr, i) { | ||
| var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; | ||
| if (_i == null) return; | ||
| var _arr = []; | ||
| var _n = true; | ||
| var _d = false; | ||
| var _s, _e; | ||
| try { | ||
| for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){ | ||
| _arr.push(_s.value); | ||
| if (i && _arr.length === i) break; | ||
| } | ||
| } catch (err) { | ||
| _d = true; | ||
| _e = err; | ||
| } finally{ | ||
| try { | ||
| if (!_n && _i["return"] != null) _i["return"](); | ||
| } finally{ | ||
| if (_d) throw _e; | ||
| } | ||
| } | ||
| return _arr; | ||
| } | ||
| function _non_iterable_rest() { | ||
| throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
| } | ||
| function _non_iterable_spread() { | ||
| throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
| } | ||
| function _sliced_to_array(arr, i) { | ||
| return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest(); | ||
| } | ||
| function _to_consumable_array(arr) { | ||
| return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread(); | ||
| } | ||
| function _unsupported_iterable_to_array(o, minLen) { | ||
| if (!o) return; | ||
| if (typeof o === "string") return _array_like_to_array(o, minLen); | ||
| var n = Object.prototype.toString.call(o).slice(8, -1); | ||
| if (n === "Object" && o.constructor) n = o.constructor.name; | ||
| if (n === "Map" || n === "Set") return Array.from(n); | ||
| if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen); | ||
| } | ||
| // Configurable flush timeout for partial lines (in ms) | ||
| // Infinity = only flush on newline or explicit flush() | ||
| // 0 = flush immediately (effectively disables buffering) | ||
| // N = flush partial line after N ms of no newline | ||
| var FLUSH_TIMEOUT = Infinity; | ||
| // ESC character for ANSI sequences | ||
| var ESC = '\x1b'; | ||
| // CSI sequence: ESC [ params command (e.g., ESC[31m for red) | ||
| var CSI_REGEX = new RegExp("^".concat(ESC, "\\[([0-9;]*)([A-Za-z])")); | ||
| // OSC and other escape sequences to discard (e.g., ESC]0;title BEL) | ||
| var OSC_REGEX = new RegExp("^".concat(ESC, "[\\]P^_][^\\x07").concat(ESC, "]*(?:\\x07|").concat(ESC, "\\\\)?")); | ||
| var LineBuffer = /*#__PURE__*/ function() { | ||
| "use strict"; | ||
| function LineBuffer(onLine) { | ||
| var flushTimeout = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : FLUSH_TIMEOUT; | ||
| _class_call_check(this, LineBuffer); | ||
| this.cells = []; | ||
| this.cursor = 0; | ||
| this.activeSgr = ''; | ||
| this.flushTimer = null; | ||
| this.onLine = onLine; | ||
| this.flushTimeout = flushTimeout; | ||
| } | ||
| var _proto = LineBuffer.prototype; | ||
| _proto.write = function write(input) { | ||
| var str = typeof input === 'string' ? input : input.toString('utf8'); | ||
| var i = 0; | ||
| this.cancelFlushTimer(); | ||
| while(i < str.length){ | ||
| var char = str[i]; | ||
| // Check for ESC sequence | ||
| if (char === ESC) { | ||
| var remaining = str.slice(i); | ||
| // Check for CSI sequence (ESC [) | ||
| if (str[i + 1] === '[') { | ||
| var csiMatch = remaining.match(CSI_REGEX); | ||
| if (csiMatch) { | ||
| var _csiMatch = _sliced_to_array(csiMatch, 3), seq = _csiMatch[0], params = _csiMatch[1], cmd = _csiMatch[2]; | ||
| i += seq.length; | ||
| this.handleCSI(params, cmd, seq); | ||
| continue; | ||
| } | ||
| } | ||
| // Check for other escape sequences (OSC, etc.) - discard them | ||
| var otherMatch = remaining.match(OSC_REGEX); | ||
| if (otherMatch) { | ||
| i += otherMatch[0].length; | ||
| continue; | ||
| } | ||
| } | ||
| // Handle regular characters | ||
| if (char === '\r') { | ||
| // Carriage return - move cursor to start (overwrite mode) | ||
| this.cursor = 0; | ||
| } else if (char === '\n') { | ||
| // Newline - emit the completed line | ||
| this.emitLine(); | ||
| } else if (char === '\x08') { | ||
| // Backspace | ||
| this.cursor = Math.max(0, this.cursor - 1); | ||
| } else if (char === '\t') { | ||
| // Tab - move to next 8-column boundary | ||
| var nextTab = (Math.floor(this.cursor / 8) + 1) * 8; | ||
| while(this.cursor < nextTab){ | ||
| this.cells[this.cursor] = { | ||
| char: ' ', | ||
| sgr: this.activeSgr | ||
| }; | ||
| this.cursor++; | ||
| } | ||
| } else if (char >= ' ' || char > '\x7f') { | ||
| // Printable character (including unicode) | ||
| this.cells[this.cursor] = { | ||
| char: char, | ||
| sgr: this.activeSgr | ||
| }; | ||
| this.cursor++; | ||
| } | ||
| // Other control characters (0x00-0x1F except handled above) are ignored | ||
| i++; | ||
| } | ||
| // Schedule flush timer for partial line if configured | ||
| this.scheduleFlushTimer(); | ||
| }; | ||
| _proto.handleCSI = function handleCSI(params, cmd, seq) { | ||
| var p = params ? params.split(';').map(function(n) { | ||
| return parseInt(n, 10) || 0; | ||
| }) : [ | ||
| 0 | ||
| ]; | ||
| switch(cmd){ | ||
| case 'm': | ||
| this.activeSgr = seq; | ||
| break; | ||
| case 'G': | ||
| this.cursor = Math.max(0, (p[0] || 1) - 1); | ||
| break; | ||
| case 'C': | ||
| this.cursor += p[0] || 1; | ||
| break; | ||
| case 'D': | ||
| this.cursor = Math.max(0, this.cursor - (p[0] || 1)); | ||
| break; | ||
| case 'K': | ||
| { | ||
| var mode = p[0] || 0; | ||
| if (mode === 0) { | ||
| // Erase from cursor to end of line | ||
| this.cells.length = this.cursor; | ||
| } else if (mode === 1) { | ||
| // Erase from start to cursor | ||
| for(var j = 0; j <= this.cursor; j++){ | ||
| this.cells[j] = null; | ||
| } | ||
| } else if (mode === 2) { | ||
| // Erase entire line | ||
| this.cells = []; | ||
| this.cursor = 0; | ||
| } | ||
| } | ||
| break; | ||
| case 'X': | ||
| { | ||
| var count = p[0] || 1; | ||
| for(var j1 = 0; j1 < count; j1++){ | ||
| this.cells[this.cursor + j1] = null; | ||
| } | ||
| } | ||
| break; | ||
| case 'P': | ||
| this.cells.splice(this.cursor, p[0] || 1); | ||
| break; | ||
| case '@': | ||
| { | ||
| var _this_cells; | ||
| var count1 = p[0] || 1; | ||
| var blanks = new Array(count1).fill(null); | ||
| (_this_cells = this.cells).splice.apply(_this_cells, [ | ||
| this.cursor, | ||
| 0 | ||
| ].concat(_to_consumable_array(blanks))); | ||
| } | ||
| break; | ||
| // Multi-line sequences - discard (can't handle in streaming mode) | ||
| case 'A': | ||
| case 'B': | ||
| case 'H': | ||
| case 'f': | ||
| case 'J': | ||
| case 'S': | ||
| case 'T': | ||
| break; | ||
| // Other sequences - ignore | ||
| default: | ||
| break; | ||
| } | ||
| }; | ||
| _proto.emitLine = function emitLine() { | ||
| this.cancelFlushTimer(); | ||
| var line = this.renderLine(); | ||
| this.reset(); | ||
| this.onLine(line); | ||
| }; | ||
| _proto.renderLine = function renderLine() { | ||
| var SGR_RESET = "".concat(ESC, "[0m"); | ||
| var result = ''; | ||
| var lastSgr = ''; | ||
| for(var i = 0; i < this.cells.length; i++){ | ||
| var cell = this.cells[i]; | ||
| if (cell === null || cell === void 0 ? void 0 : cell.char) { | ||
| // Only emit SGR if it changed | ||
| if (cell.sgr !== lastSgr) { | ||
| result += cell.sgr; | ||
| lastSgr = cell.sgr; | ||
| } | ||
| result += cell.char; | ||
| } else { | ||
| // Null or undefined cell - emit space (erased position) | ||
| // Reset color first if we had one | ||
| if (lastSgr && lastSgr !== SGR_RESET) { | ||
| result += SGR_RESET; | ||
| lastSgr = ''; | ||
| } | ||
| result += ' '; | ||
| } | ||
| } | ||
| // Trim trailing spaces | ||
| result = result.replace(/ +$/, ''); | ||
| // Reset SGR at end of line if we have an active style | ||
| if (lastSgr && lastSgr !== SGR_RESET) { | ||
| result += SGR_RESET; | ||
| } | ||
| return result; | ||
| }; | ||
| _proto.reset = function reset() { | ||
| this.cells = []; | ||
| this.cursor = 0; | ||
| // Note: activeSgr carries over (color continues to next line) | ||
| }; | ||
| _proto.scheduleFlushTimer = function scheduleFlushTimer() { | ||
| var _this = this; | ||
| if (this.flushTimeout === Infinity || this.flushTimeout <= 0) return; | ||
| if (this.cells.length === 0) return; | ||
| this.flushTimer = setTimeout(function() { | ||
| _this.flushTimer = null; | ||
| if (_this.cells.length > 0) { | ||
| _this.emitLine(); | ||
| } | ||
| }, this.flushTimeout); | ||
| }; | ||
| _proto.cancelFlushTimer = function cancelFlushTimer() { | ||
| if (this.flushTimer) { | ||
| clearTimeout(this.flushTimer); | ||
| this.flushTimer = null; | ||
| } | ||
| }; | ||
| /** | ||
| * Flush any remaining buffered content. | ||
| * Call this when the stream ends to emit any partial line. | ||
| */ _proto.flush = function flush() { | ||
| this.cancelFlushTimer(); | ||
| if (this.cells.length > 0) { | ||
| var line = this.renderLine(); | ||
| this.reset(); | ||
| this.onLine(line); | ||
| } | ||
| }; | ||
| /** | ||
| * Clean up resources (timers). | ||
| */ _proto.dispose = function dispose() { | ||
| this.cancelFlushTimer(); | ||
| }; | ||
| return LineBuffer; | ||
| }(); | ||
| /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; } |
| {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-streaming/src/lib/LineBuffer.ts"],"sourcesContent":["// Configurable flush timeout for partial lines (in ms)\n// Infinity = only flush on newline or explicit flush()\n// 0 = flush immediately (effectively disables buffering)\n// N = flush partial line after N ms of no newline\nconst FLUSH_TIMEOUT = Infinity;\n\n// ESC character for ANSI sequences\nconst ESC = '\\x1b';\n\n// CSI sequence: ESC [ params command (e.g., ESC[31m for red)\nconst CSI_REGEX = new RegExp(`^${ESC}\\\\[([0-9;]*)([A-Za-z])`);\n\n// OSC and other escape sequences to discard (e.g., ESC]0;title BEL)\nconst OSC_REGEX = new RegExp(`^${ESC}[\\\\]P^_][^\\\\x07${ESC}]*(?:\\\\x07|${ESC}\\\\\\\\)?`);\n\ninterface Cell {\n char: string;\n sgr: string;\n}\n\ntype LineCallback = (line: string) => void;\n\nexport default class LineBuffer {\n private cells: Array<Cell | null> = [];\n private cursor = 0;\n private activeSgr = '';\n private flushTimer: ReturnType<typeof setTimeout> | null = null;\n private onLine: LineCallback;\n private flushTimeout: number;\n\n constructor(onLine: LineCallback, flushTimeout = FLUSH_TIMEOUT) {\n this.onLine = onLine;\n this.flushTimeout = flushTimeout;\n }\n\n write(input: string | Buffer): void {\n const str = typeof input === 'string' ? input : input.toString('utf8');\n let i = 0;\n\n this.cancelFlushTimer();\n\n while (i < str.length) {\n const char = str[i];\n\n // Check for ESC sequence\n if (char === ESC) {\n const remaining = str.slice(i);\n\n // Check for CSI sequence (ESC [)\n if (str[i + 1] === '[') {\n const csiMatch = remaining.match(CSI_REGEX);\n if (csiMatch) {\n const [seq, params, cmd] = csiMatch;\n i += seq.length;\n this.handleCSI(params, cmd, seq);\n continue;\n }\n }\n\n // Check for other escape sequences (OSC, etc.) - discard them\n const otherMatch = remaining.match(OSC_REGEX);\n if (otherMatch) {\n i += otherMatch[0].length;\n continue;\n }\n }\n\n // Handle regular characters\n if (char === '\\r') {\n // Carriage return - move cursor to start (overwrite mode)\n this.cursor = 0;\n } else if (char === '\\n') {\n // Newline - emit the completed line\n this.emitLine();\n } else if (char === '\\x08') {\n // Backspace\n this.cursor = Math.max(0, this.cursor - 1);\n } else if (char === '\\t') {\n // Tab - move to next 8-column boundary\n const nextTab = (Math.floor(this.cursor / 8) + 1) * 8;\n while (this.cursor < nextTab) {\n this.cells[this.cursor] = { char: ' ', sgr: this.activeSgr };\n this.cursor++;\n }\n } else if (char >= ' ' || char > '\\x7f') {\n // Printable character (including unicode)\n this.cells[this.cursor] = { char, sgr: this.activeSgr };\n this.cursor++;\n }\n // Other control characters (0x00-0x1F except handled above) are ignored\n\n i++;\n }\n\n // Schedule flush timer for partial line if configured\n this.scheduleFlushTimer();\n }\n\n private handleCSI(params: string, cmd: string, seq: string): void {\n const p = params ? params.split(';').map((n) => parseInt(n, 10) || 0) : [0];\n\n switch (cmd) {\n case 'm': // SGR (Select Graphic Rendition) - colors and styles\n this.activeSgr = seq;\n break;\n\n case 'G': // CHA - Cursor Horizontal Absolute\n this.cursor = Math.max(0, (p[0] || 1) - 1);\n break;\n\n case 'C': // CUF - Cursor Forward\n this.cursor += p[0] || 1;\n break;\n\n case 'D': // CUB - Cursor Back\n this.cursor = Math.max(0, this.cursor - (p[0] || 1));\n break;\n\n case 'K': // EL - Erase in Line\n {\n const mode = p[0] || 0;\n if (mode === 0) {\n // Erase from cursor to end of line\n this.cells.length = this.cursor;\n } else if (mode === 1) {\n // Erase from start to cursor\n for (let j = 0; j <= this.cursor; j++) {\n this.cells[j] = null;\n }\n } else if (mode === 2) {\n // Erase entire line\n this.cells = [];\n this.cursor = 0;\n }\n }\n break;\n\n case 'X': // ECH - Erase Character\n {\n const count = p[0] || 1;\n for (let j = 0; j < count; j++) {\n this.cells[this.cursor + j] = null;\n }\n }\n break;\n\n case 'P': // DCH - Delete Character (shift left)\n this.cells.splice(this.cursor, p[0] || 1);\n break;\n\n case '@': // ICH - Insert Character (shift right)\n {\n const count = p[0] || 1;\n const blanks = new Array(count).fill(null);\n this.cells.splice(this.cursor, 0, ...blanks);\n }\n break;\n\n // Multi-line sequences - discard (can't handle in streaming mode)\n case 'A': // CUU - Cursor Up\n case 'B': // CUD - Cursor Down\n case 'H': // CUP - Cursor Position\n case 'f': // HVP - Horizontal Vertical Position\n case 'J': // ED - Erase in Display\n case 'S': // SU - Scroll Up\n case 'T': // SD - Scroll Down\n // Ignore - incompatible with line-based streaming\n break;\n\n // Other sequences - ignore\n default:\n break;\n }\n }\n\n private emitLine(): void {\n this.cancelFlushTimer();\n const line = this.renderLine();\n this.reset();\n this.onLine(line);\n }\n\n private renderLine(): string {\n const SGR_RESET = `${ESC}[0m`;\n let result = '';\n let lastSgr = '';\n\n for (let i = 0; i < this.cells.length; i++) {\n const cell = this.cells[i];\n if (cell?.char) {\n // Only emit SGR if it changed\n if (cell.sgr !== lastSgr) {\n result += cell.sgr;\n lastSgr = cell.sgr;\n }\n result += cell.char;\n } else {\n // Null or undefined cell - emit space (erased position)\n // Reset color first if we had one\n if (lastSgr && lastSgr !== SGR_RESET) {\n result += SGR_RESET;\n lastSgr = '';\n }\n result += ' ';\n }\n }\n\n // Trim trailing spaces\n result = result.replace(/ +$/, '');\n\n // Reset SGR at end of line if we have an active style\n if (lastSgr && lastSgr !== SGR_RESET) {\n result += SGR_RESET;\n }\n\n return result;\n }\n\n private reset(): void {\n this.cells = [];\n this.cursor = 0;\n // Note: activeSgr carries over (color continues to next line)\n }\n\n private scheduleFlushTimer(): void {\n if (this.flushTimeout === Infinity || this.flushTimeout <= 0) return;\n if (this.cells.length === 0) return;\n\n this.flushTimer = setTimeout(() => {\n this.flushTimer = null;\n if (this.cells.length > 0) {\n this.emitLine();\n }\n }, this.flushTimeout);\n }\n\n private cancelFlushTimer(): void {\n if (this.flushTimer) {\n clearTimeout(this.flushTimer);\n this.flushTimer = null;\n }\n }\n\n /**\n * Flush any remaining buffered content.\n * Call this when the stream ends to emit any partial line.\n */\n flush(): void {\n this.cancelFlushTimer();\n if (this.cells.length > 0) {\n const line = this.renderLine();\n this.reset();\n this.onLine(line);\n }\n }\n\n /**\n * Clean up resources (timers).\n */\n dispose(): void {\n this.cancelFlushTimer();\n }\n}\n"],"names":["LineBuffer","FLUSH_TIMEOUT","Infinity","ESC","CSI_REGEX","RegExp","OSC_REGEX","onLine","flushTimeout","cells","cursor","activeSgr","flushTimer","write","input","str","toString","i","cancelFlushTimer","length","char","remaining","slice","csiMatch","match","seq","params","cmd","handleCSI","otherMatch","emitLine","Math","max","nextTab","floor","sgr","scheduleFlushTimer","p","split","map","n","parseInt","mode","j","count","splice","blanks","Array","fill","line","renderLine","reset","SGR_RESET","result","lastSgr","cell","replace","setTimeout","clearTimeout","flush","dispose"],"mappings":";;;;;;;eAsBqBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAtBrB,uDAAuD;AACvD,uDAAuD;AACvD,yDAAyD;AACzD,kDAAkD;AAClD,IAAMC,gBAAgBC;AAEtB,mCAAmC;AACnC,IAAMC,MAAM;AAEZ,6DAA6D;AAC7D,IAAMC,YAAY,IAAIC,OAAO,AAAC,IAAO,OAAJF,KAAI;AAErC,oEAAoE;AACpE,IAAMG,YAAY,IAAID,OAAO,AAAC,IAAwBF,OAArBA,KAAI,mBAAkCA,OAAjBA,KAAI,eAAiB,OAAJA,KAAI;AAS5D,IAAA,AAAMH,2BAAN;;aAAMA,WAQPO,MAAoB;YAAEC,eAAAA,iEAAeP;gCAR9BD;aACXS,QAA4B,EAAE;aAC9BC,SAAS;aACTC,YAAY;aACZC,aAAmD;QAKzD,IAAI,CAACL,MAAM,GAAGA;QACd,IAAI,CAACC,YAAY,GAAGA;;iBAVHR;IAanBa,OAAAA,KA6DC,GA7DDA,SAAAA,MAAMC,KAAsB;QAC1B,IAAMC,MAAM,OAAOD,UAAU,WAAWA,QAAQA,MAAME,QAAQ,CAAC;QAC/D,IAAIC,IAAI;QAER,IAAI,CAACC,gBAAgB;QAErB,MAAOD,IAAIF,IAAII,MAAM,CAAE;YACrB,IAAMC,OAAOL,GAAG,CAACE,EAAE;YAEnB,yBAAyB;YACzB,IAAIG,SAASjB,KAAK;gBAChB,IAAMkB,YAAYN,IAAIO,KAAK,CAACL;gBAE5B,iCAAiC;gBACjC,I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,GAFDA,SAAAA;QACE,IAAI,CAAC1C,gBAAgB;IACvB;WA/OmBlB"} |
| type LineCallback = (line: string) => void; | ||
| export default class LineBuffer { | ||
| private cells; | ||
| private cursor; | ||
| private activeSgr; | ||
| private flushTimer; | ||
| private onLine; | ||
| private flushTimeout; | ||
| constructor(onLine: LineCallback, flushTimeout?: number); | ||
| write(input: string | Buffer): void; | ||
| private handleCSI; | ||
| private emitLine; | ||
| private renderLine; | ||
| private reset; | ||
| private scheduleFlushTimer; | ||
| private cancelFlushTimer; | ||
| /** | ||
| * Flush any remaining buffered content. | ||
| * Call this when the stream ends to emit any partial line. | ||
| */ | ||
| flush(): void; | ||
| /** | ||
| * Clean up resources (timers). | ||
| */ | ||
| dispose(): void; | ||
| } | ||
| export {}; |
| // Configurable flush timeout for partial lines (in ms) | ||
| // Infinity = only flush on newline or explicit flush() | ||
| // 0 = flush immediately (effectively disables buffering) | ||
| // N = flush partial line after N ms of no newline | ||
| const FLUSH_TIMEOUT = Infinity; | ||
| // ESC character for ANSI sequences | ||
| const ESC = '\x1b'; | ||
| // CSI sequence: ESC [ params command (e.g., ESC[31m for red) | ||
| const CSI_REGEX = new RegExp(`^${ESC}\\[([0-9;]*)([A-Za-z])`); | ||
| // OSC and other escape sequences to discard (e.g., ESC]0;title BEL) | ||
| const OSC_REGEX = new RegExp(`^${ESC}[\\]P^_][^\\x07${ESC}]*(?:\\x07|${ESC}\\\\)?`); | ||
| let LineBuffer = class LineBuffer { | ||
| write(input) { | ||
| const str = typeof input === 'string' ? input : input.toString('utf8'); | ||
| let i = 0; | ||
| this.cancelFlushTimer(); | ||
| while(i < str.length){ | ||
| const char = str[i]; | ||
| // Check for ESC sequence | ||
| if (char === ESC) { | ||
| const remaining = str.slice(i); | ||
| // Check for CSI sequence (ESC [) | ||
| if (str[i + 1] === '[') { | ||
| const csiMatch = remaining.match(CSI_REGEX); | ||
| if (csiMatch) { | ||
| const [seq, params, cmd] = csiMatch; | ||
| i += seq.length; | ||
| this.handleCSI(params, cmd, seq); | ||
| continue; | ||
| } | ||
| } | ||
| // Check for other escape sequences (OSC, etc.) - discard them | ||
| const otherMatch = remaining.match(OSC_REGEX); | ||
| if (otherMatch) { | ||
| i += otherMatch[0].length; | ||
| continue; | ||
| } | ||
| } | ||
| // Handle regular characters | ||
| if (char === '\r') { | ||
| // Carriage return - move cursor to start (overwrite mode) | ||
| this.cursor = 0; | ||
| } else if (char === '\n') { | ||
| // Newline - emit the completed line | ||
| this.emitLine(); | ||
| } else if (char === '\x08') { | ||
| // Backspace | ||
| this.cursor = Math.max(0, this.cursor - 1); | ||
| } else if (char === '\t') { | ||
| // Tab - move to next 8-column boundary | ||
| const nextTab = (Math.floor(this.cursor / 8) + 1) * 8; | ||
| while(this.cursor < nextTab){ | ||
| this.cells[this.cursor] = { | ||
| char: ' ', | ||
| sgr: this.activeSgr | ||
| }; | ||
| this.cursor++; | ||
| } | ||
| } else if (char >= ' ' || char > '\x7f') { | ||
| // Printable character (including unicode) | ||
| this.cells[this.cursor] = { | ||
| char, | ||
| sgr: this.activeSgr | ||
| }; | ||
| this.cursor++; | ||
| } | ||
| // Other control characters (0x00-0x1F except handled above) are ignored | ||
| i++; | ||
| } | ||
| // Schedule flush timer for partial line if configured | ||
| this.scheduleFlushTimer(); | ||
| } | ||
| handleCSI(params, cmd, seq) { | ||
| const p = params ? params.split(';').map((n)=>parseInt(n, 10) || 0) : [ | ||
| 0 | ||
| ]; | ||
| switch(cmd){ | ||
| case 'm': | ||
| this.activeSgr = seq; | ||
| break; | ||
| case 'G': | ||
| this.cursor = Math.max(0, (p[0] || 1) - 1); | ||
| break; | ||
| case 'C': | ||
| this.cursor += p[0] || 1; | ||
| break; | ||
| case 'D': | ||
| this.cursor = Math.max(0, this.cursor - (p[0] || 1)); | ||
| break; | ||
| case 'K': | ||
| { | ||
| const mode = p[0] || 0; | ||
| if (mode === 0) { | ||
| // Erase from cursor to end of line | ||
| this.cells.length = this.cursor; | ||
| } else if (mode === 1) { | ||
| // Erase from start to cursor | ||
| for(let j = 0; j <= this.cursor; j++){ | ||
| this.cells[j] = null; | ||
| } | ||
| } else if (mode === 2) { | ||
| // Erase entire line | ||
| this.cells = []; | ||
| this.cursor = 0; | ||
| } | ||
| } | ||
| break; | ||
| case 'X': | ||
| { | ||
| const count = p[0] || 1; | ||
| for(let j = 0; j < count; j++){ | ||
| this.cells[this.cursor + j] = null; | ||
| } | ||
| } | ||
| break; | ||
| case 'P': | ||
| this.cells.splice(this.cursor, p[0] || 1); | ||
| break; | ||
| case '@': | ||
| { | ||
| const count = p[0] || 1; | ||
| const blanks = new Array(count).fill(null); | ||
| this.cells.splice(this.cursor, 0, ...blanks); | ||
| } | ||
| break; | ||
| // Multi-line sequences - discard (can't handle in streaming mode) | ||
| case 'A': | ||
| case 'B': | ||
| case 'H': | ||
| case 'f': | ||
| case 'J': | ||
| case 'S': | ||
| case 'T': | ||
| break; | ||
| // Other sequences - ignore | ||
| default: | ||
| break; | ||
| } | ||
| } | ||
| emitLine() { | ||
| this.cancelFlushTimer(); | ||
| const line = this.renderLine(); | ||
| this.reset(); | ||
| this.onLine(line); | ||
| } | ||
| renderLine() { | ||
| const SGR_RESET = `${ESC}[0m`; | ||
| let result = ''; | ||
| let lastSgr = ''; | ||
| for(let i = 0; i < this.cells.length; i++){ | ||
| const cell = this.cells[i]; | ||
| if (cell === null || cell === void 0 ? void 0 : cell.char) { | ||
| // Only emit SGR if it changed | ||
| if (cell.sgr !== lastSgr) { | ||
| result += cell.sgr; | ||
| lastSgr = cell.sgr; | ||
| } | ||
| result += cell.char; | ||
| } else { | ||
| // Null or undefined cell - emit space (erased position) | ||
| // Reset color first if we had one | ||
| if (lastSgr && lastSgr !== SGR_RESET) { | ||
| result += SGR_RESET; | ||
| lastSgr = ''; | ||
| } | ||
| result += ' '; | ||
| } | ||
| } | ||
| // Trim trailing spaces | ||
| result = result.replace(/ +$/, ''); | ||
| // Reset SGR at end of line if we have an active style | ||
| if (lastSgr && lastSgr !== SGR_RESET) { | ||
| result += SGR_RESET; | ||
| } | ||
| return result; | ||
| } | ||
| reset() { | ||
| this.cells = []; | ||
| this.cursor = 0; | ||
| // Note: activeSgr carries over (color continues to next line) | ||
| } | ||
| scheduleFlushTimer() { | ||
| if (this.flushTimeout === Infinity || this.flushTimeout <= 0) return; | ||
| if (this.cells.length === 0) return; | ||
| this.flushTimer = setTimeout(()=>{ | ||
| this.flushTimer = null; | ||
| if (this.cells.length > 0) { | ||
| this.emitLine(); | ||
| } | ||
| }, this.flushTimeout); | ||
| } | ||
| cancelFlushTimer() { | ||
| if (this.flushTimer) { | ||
| clearTimeout(this.flushTimer); | ||
| this.flushTimer = null; | ||
| } | ||
| } | ||
| /** | ||
| * Flush any remaining buffered content. | ||
| * Call this when the stream ends to emit any partial line. | ||
| */ flush() { | ||
| this.cancelFlushTimer(); | ||
| if (this.cells.length > 0) { | ||
| const line = this.renderLine(); | ||
| this.reset(); | ||
| this.onLine(line); | ||
| } | ||
| } | ||
| /** | ||
| * Clean up resources (timers). | ||
| */ dispose() { | ||
| this.cancelFlushTimer(); | ||
| } | ||
| constructor(onLine, flushTimeout = FLUSH_TIMEOUT){ | ||
| this.cells = []; | ||
| this.cursor = 0; | ||
| this.activeSgr = ''; | ||
| this.flushTimer = null; | ||
| this.onLine = onLine; | ||
| this.flushTimeout = flushTimeout; | ||
| } | ||
| }; | ||
| export { LineBuffer as default }; |
| {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-streaming/src/lib/LineBuffer.ts"],"sourcesContent":["// Configurable flush timeout for partial lines (in ms)\n// Infinity = only flush on newline or explicit flush()\n// 0 = flush immediately (effectively disables buffering)\n// N = flush partial line after N ms of no newline\nconst FLUSH_TIMEOUT = Infinity;\n\n// ESC character for ANSI sequences\nconst ESC = '\\x1b';\n\n// CSI sequence: ESC [ params command (e.g., ESC[31m for red)\nconst CSI_REGEX = new RegExp(`^${ESC}\\\\[([0-9;]*)([A-Za-z])`);\n\n// OSC and other escape sequences to discard (e.g., ESC]0;title BEL)\nconst OSC_REGEX = new RegExp(`^${ESC}[\\\\]P^_][^\\\\x07${ESC}]*(?:\\\\x07|${ESC}\\\\\\\\)?`);\n\ninterface Cell {\n char: string;\n sgr: string;\n}\n\ntype LineCallback = (line: string) => void;\n\nexport default class LineBuffer {\n private cells: Array<Cell | null> = [];\n private cursor = 0;\n private activeSgr = '';\n private flushTimer: ReturnType<typeof setTimeout> | null = null;\n private onLine: LineCallback;\n private flushTimeout: number;\n\n constructor(onLine: LineCallback, flushTimeout = FLUSH_TIMEOUT) {\n this.onLine = onLine;\n this.flushTimeout = flushTimeout;\n }\n\n write(input: string | Buffer): void {\n const str = typeof input === 'string' ? input : input.toString('utf8');\n let i = 0;\n\n this.cancelFlushTimer();\n\n while (i < str.length) {\n const char = str[i];\n\n // Check for ESC sequence\n if (char === ESC) {\n const remaining = str.slice(i);\n\n // Check for CSI sequence (ESC [)\n if (str[i + 1] === '[') {\n const csiMatch = remaining.match(CSI_REGEX);\n if (csiMatch) {\n const [seq, params, cmd] = csiMatch;\n i += seq.length;\n this.handleCSI(params, cmd, seq);\n continue;\n }\n }\n\n // Check for other escape sequences (OSC, etc.) - discard them\n const otherMatch = remaining.match(OSC_REGEX);\n if (otherMatch) {\n i += otherMatch[0].length;\n continue;\n }\n }\n\n // Handle regular characters\n if (char === '\\r') {\n // Carriage return - move cursor to start (overwrite mode)\n this.cursor = 0;\n } else if (char === '\\n') {\n // Newline - emit the completed line\n this.emitLine();\n } else if (char === '\\x08') {\n // Backspace\n this.cursor = Math.max(0, this.cursor - 1);\n } else if (char === '\\t') {\n // Tab - move to next 8-column boundary\n const nextTab = (Math.floor(this.cursor / 8) + 1) * 8;\n while (this.cursor < nextTab) {\n this.cells[this.cursor] = { char: ' ', sgr: this.activeSgr };\n this.cursor++;\n }\n } else if (char >= ' ' || char > '\\x7f') {\n // Printable character (including unicode)\n this.cells[this.cursor] = { char, sgr: this.activeSgr };\n this.cursor++;\n }\n // Other control characters (0x00-0x1F except handled above) are ignored\n\n i++;\n }\n\n // Schedule flush timer for partial line if configured\n this.scheduleFlushTimer();\n }\n\n private handleCSI(params: string, cmd: string, seq: string): void {\n const p = params ? params.split(';').map((n) => parseInt(n, 10) || 0) : [0];\n\n switch (cmd) {\n case 'm': // SGR (Select Graphic Rendition) - colors and styles\n this.activeSgr = seq;\n break;\n\n case 'G': // CHA - Cursor Horizontal Absolute\n this.cursor = Math.max(0, (p[0] || 1) - 1);\n break;\n\n case 'C': // CUF - Cursor Forward\n this.cursor += p[0] || 1;\n break;\n\n case 'D': // CUB - Cursor Back\n this.cursor = Math.max(0, this.cursor - (p[0] || 1));\n break;\n\n case 'K': // EL - Erase in Line\n {\n const mode = p[0] || 0;\n if (mode === 0) {\n // Erase from cursor to end of line\n this.cells.length = this.cursor;\n } else if (mode === 1) {\n // Erase from start to cursor\n for (let j = 0; j <= this.cursor; j++) {\n this.cells[j] = null;\n }\n } else if (mode === 2) {\n // Erase entire line\n this.cells = [];\n this.cursor = 0;\n }\n }\n break;\n\n case 'X': // ECH - Erase Character\n {\n const count = p[0] || 1;\n for (let j = 0; j < count; j++) {\n this.cells[this.cursor + j] = null;\n }\n }\n break;\n\n case 'P': // DCH - Delete Character (shift left)\n this.cells.splice(this.cursor, p[0] || 1);\n break;\n\n case '@': // ICH - Insert Character (shift right)\n {\n const count = p[0] || 1;\n const blanks = new Array(count).fill(null);\n this.cells.splice(this.cursor, 0, ...blanks);\n }\n break;\n\n // Multi-line sequences - discard (can't handle in streaming mode)\n case 'A': // CUU - Cursor Up\n case 'B': // CUD - Cursor Down\n case 'H': // CUP - Cursor Position\n case 'f': // HVP - Horizontal Vertical Position\n case 'J': // ED - Erase in Display\n case 'S': // SU - Scroll Up\n case 'T': // SD - Scroll Down\n // Ignore - incompatible with line-based streaming\n break;\n\n // Other sequences - ignore\n default:\n break;\n }\n }\n\n private emitLine(): void {\n this.cancelFlushTimer();\n const line = this.renderLine();\n this.reset();\n this.onLine(line);\n }\n\n private renderLine(): string {\n const SGR_RESET = `${ESC}[0m`;\n let result = '';\n let lastSgr = '';\n\n for (let i = 0; i < this.cells.length; i++) {\n const cell = this.cells[i];\n if (cell?.char) {\n // Only emit SGR if it changed\n if (cell.sgr !== lastSgr) {\n result += cell.sgr;\n lastSgr = cell.sgr;\n }\n result += cell.char;\n } else {\n // Null or undefined cell - emit space (erased position)\n // Reset color first if we had one\n if (lastSgr && lastSgr !== SGR_RESET) {\n result += SGR_RESET;\n lastSgr = '';\n }\n result += ' ';\n }\n }\n\n // Trim trailing spaces\n result = result.replace(/ +$/, '');\n\n // Reset SGR at end of line if we have an active style\n if (lastSgr && lastSgr !== SGR_RESET) {\n result += SGR_RESET;\n }\n\n return result;\n }\n\n private reset(): void {\n this.cells = [];\n this.cursor = 0;\n // Note: activeSgr carries over (color continues to next line)\n }\n\n private scheduleFlushTimer(): void {\n if (this.flushTimeout === Infinity || this.flushTimeout <= 0) return;\n if (this.cells.length === 0) return;\n\n this.flushTimer = setTimeout(() => {\n this.flushTimer = null;\n if (this.cells.length > 0) {\n this.emitLine();\n }\n }, this.flushTimeout);\n }\n\n private cancelFlushTimer(): void {\n if (this.flushTimer) {\n clearTimeout(this.flushTimer);\n this.flushTimer = null;\n }\n }\n\n /**\n * Flush any remaining buffered content.\n * Call this when the stream ends to emit any partial line.\n */\n flush(): void {\n this.cancelFlushTimer();\n if (this.cells.length > 0) {\n const line = this.renderLine();\n this.reset();\n this.onLine(line);\n }\n }\n\n /**\n * Clean up resources (timers).\n */\n dispose(): void {\n this.cancelFlushTimer();\n }\n}\n"],"names":["FLUSH_TIMEOUT","Infinity","ESC","CSI_REGEX","RegExp","OSC_REGEX","LineBuffer","write","input","str","toString","i","cancelFlushTimer","length","char","remaining","slice","csiMatch","match","seq","params","cmd","handleCSI","otherMatch","cursor","emitLine","Math","max","nextTab","floor","cells","sgr","activeSgr","scheduleFlushTimer","p","split","map","n","parseInt","mode","j","count","splice","blanks","Array","fill","line","renderLine","reset","onLine","SGR_RESET","result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AACD,UAAU,GAAG;YAClB,IAAI,IAAI,CAAC1B,KAAK,CAACjB,MAAM,GAAG,GAAG;gBACzB,IAAI,CAACY,QAAQ;YACf;QACF,GAAG,IAAI,CAAC8B,YAAY;IACtB;IAEQ3C,mBAAyB;QAC/B,IAAI,IAAI,CAAC4C,UAAU,EAAE;YACnBE,aAAa,IAAI,CAACF,UAAU;YAC5B,IAAI,CAACA,UAAU,GAAG;QACpB;IACF;IAEA;;;GAGC,GACDG,QAAc;QACZ,IAAI,CAAC/C,gBAAgB;QACrB,IAAI,IAAI,CAACkB,KAAK,CAACjB,MAAM,GAAG,GAAG;YACzB,MAAMiC,OAAO,IAAI,CAACC,UAAU;YAC5B,IAAI,CAACC,KAAK;YACV,IAAI,CAACC,MAAM,CAACH;QACd;IACF;IAEA;;GAEC,GACDc,UAAgB;QACd,IAAI,CAAChD,gBAAgB;IACvB;IAvOA,YAAYqC,MAAoB,EAAEM,eAAevD,aAAa,CAAE;aAPxD8B,QAA4B,EAAE;aAC9BN,SAAS;aACTQ,YAAY;aACZwB,aAAmD;QAKzD,IAAI,CAACP,MAAM,GAAGA;QACd,IAAI,CAACM,YAAY,GAAGA;IACtB;AAqOF;AAhPA,SAAqBjD,wBAgPpB"} |
@@ -32,2 +32,5 @@ "use strict"; | ||
| function spawnStreaming(command, args, spawnOptions, options, callback) { | ||
| if (spawnOptions.stdio === 'inherit' && spawnOptions.encoding) { | ||
| throw new Error("Options 'stdio: inherit' and 'encoding' are mutually exclusive. Use 'stdio: inherit' to display output, or 'encoding' to collect output."); | ||
| } | ||
| if (typeof options === 'function') { | ||
@@ -34,0 +37,0 @@ callback = options; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-streaming/src/index.ts"],"sourcesContent":["import type { SpawnCallback, SpawnOptions, StreamingOptions } from './types.ts';\nimport worker from './worker.ts';\n\nexport * from './types.ts';\nexport default function spawnStreaming(command: string, args: string[], spawnOptions: SpawnOptions, options?: StreamingOptions | SpawnCallback, callback?: SpawnCallback) {\n if (typeof options === 'function') {\n callback = options as SpawnCallback;\n options = {};\n }\n options = options || {};\n\n if (typeof callback === 'function') return worker(command, args, spawnOptions, options, callback);\n return new Promise((resolve, reject) => worker(command, args, spawnOptions, options, (err, result) => (err ? reject(err) : resolve(result))));\n}\n"],"names":["spawnStreaming","command","args","spawnOptions","options","callback","worker","Promise","resolve","reject","err","result"],"mappings":";;;;+BAIA;;;eAAwBA;;;+DAHL;qBAEL;;;;;;;;;;;;;;;;;;;AACC,SAASA,eAAeC,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAA0C,EAAEC,QAAwB;IACtK,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOC,aAAa,YAAY,OAAOC,IAAAA,iBAAM,EAACL,SAASC,MAAMC,cAAcC,SAASC;IACxF,OAAO,IAAIE,QAAQ,SAACC,SAASC;eAAWH,IAAAA,iBAAM,EAACL,SAASC,MAAMC,cAAcC,SAAS,SAACM,KAAKC;mBAAYD,MAAMD,OAAOC,OAAOF,QAAQG;;;AACrI"} | ||
| {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-streaming/src/index.ts"],"sourcesContent":["import type { SpawnCallback, SpawnOptions, StreamingOptions } from './types.ts';\nimport worker from './worker.ts';\n\nexport * from './types.ts';\nexport default function spawnStreaming(command: string, args: string[], spawnOptions: SpawnOptions, options?: StreamingOptions | SpawnCallback, callback?: SpawnCallback) {\n if (spawnOptions.stdio === 'inherit' && spawnOptions.encoding) {\n throw new Error(\"Options 'stdio: inherit' and 'encoding' are mutually exclusive. Use 'stdio: inherit' to display output, or 'encoding' to collect output.\");\n }\n\n if (typeof options === 'function') {\n callback = options as SpawnCallback;\n options = {};\n }\n options = options || {};\n\n if (typeof callback === 'function') return worker(command, args, spawnOptions, options, callback);\n return new Promise((resolve, reject) => worker(command, args, spawnOptions, options, (err, result) => (err ? reject(err) : resolve(result))));\n}\n"],"names":["spawnStreaming","command","args","spawnOptions","options","callback","stdio","encoding","Error","worker","Promise","resolve","reject","err","result"],"mappings":";;;;+BAIA;;;eAAwBA;;;+DAHL;qBAEL;;;;;;;;;;;;;;;;;;;AACC,SAASA,eAAeC,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAA0C,EAAEC,QAAwB;IACtK,IAAIF,aAAaG,KAAK,KAAK,aAAaH,aAAaI,QAAQ,EAAE;QAC7D,MAAM,IAAIC,MAAM;IAClB;IAEA,IAAI,OAAOJ,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOC,aAAa,YAAY,OAAOI,IAAAA,iBAAM,EAACR,SAASC,MAAMC,cAAcC,SAASC;IACxF,OAAO,IAAIK,QAAQ,SAACC,SAASC;eAAWH,IAAAA,iBAAM,EAACR,SAASC,MAAMC,cAAcC,SAAS,SAACS,KAAKC;mBAAYD,MAAMD,OAAOC,OAAOF,QAAQG;;;AACrI"} |
@@ -14,2 +14,3 @@ "use strict"; | ||
| var _colors = /*#__PURE__*/ _interop_require_default(require("colors")); | ||
| var _LineBufferts = /*#__PURE__*/ _interop_require_default(require("./LineBuffer.js")); | ||
| function _interop_require_default(obj) { | ||
@@ -22,26 +23,23 @@ return obj && obj.__esModule ? obj : { | ||
| var Transform = major > 0 ? _stream.default.Transform : _readablestream.default.Transform; | ||
| var REGEX_NEW_LINE = /\r?\n|\r/g; | ||
| function prefixTransform(prefix, color) { | ||
| var last = ''; | ||
| var createLine = function(line) { | ||
| return "".concat(_colors.default.bold(color(prefix)), ": ").concat(line, "\n"); | ||
| }; | ||
| return new Transform({ | ||
| var transform; | ||
| var lineBuffer = new _LineBufferts.default(function(line) { | ||
| transform.push(createLine(line)); | ||
| }); | ||
| transform = new Transform({ | ||
| transform: function transform(chunk, _enc, callback) { | ||
| var _this = this; | ||
| var more = last + chunk.toString('utf8'); | ||
| var lines = more.split(REGEX_NEW_LINE); | ||
| last = lines.pop(); | ||
| lines.forEach(function(line) { | ||
| _this.push(createLine(line)); | ||
| }); | ||
| lineBuffer.write(chunk); | ||
| callback(); | ||
| }, | ||
| flush: function flush() { | ||
| if (last.length) this.push(createLine(last)); | ||
| last = ''; | ||
| lineBuffer.flush(); | ||
| lineBuffer.dispose(); | ||
| this.push(null); | ||
| } | ||
| }); | ||
| return transform; | ||
| } | ||
| /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; } |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-streaming/src/lib/prefixTransform.ts"],"sourcesContent":["import StreamCompat from 'readable-stream';\nimport Stream from 'stream';\n\nconst major = +process.versions.node.split('.')[0];\nconst Transform = major > 0 ? Stream.Transform : (StreamCompat.Transform as typeof Stream.Transform);\n\nimport c from 'colors';\nimport type { ColorFunction } from '../types.ts';\n\nconst REGEX_NEW_LINE = /\\r?\\n|\\r/g;\n\nexport default function prefixTransform(prefix: string, color: ColorFunction): NodeJS.ReadableStream {\n let last = '';\n\n const createLine = (line) => `${c.bold(color(prefix))}: ${line}\\n`;\n\n return new Transform({\n transform(chunk, _enc, callback) {\n const more = last + chunk.toString('utf8');\n const lines = more.split(REGEX_NEW_LINE);\n last = lines.pop();\n lines.forEach((line) => {\n this.push(createLine(line));\n });\n callback();\n },\n flush() {\n if (last.length) this.push(createLine(last));\n last = '';\n this.push(null);\n },\n });\n}\n"],"names":["prefixTransform","major","process","versions","node","split","Transform","Stream","StreamCompat","REGEX_NEW_LINE","prefix","color","last","createLine","line","c","bold","transform","chunk","_enc","callback","more","toString","lines","pop","forEach","push","flush","length"],"mappings":";;;;+BAWA;;;eAAwBA;;;qEAXC;6DACN;6DAKL;;;;;;AAHd,IAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,IAAMC,YAAYL,QAAQ,IAAIM,eAAM,CAACD,SAAS,GAAIE,uBAAY,CAACF,SAAS;AAKxE,IAAMG,iBAAiB;AAER,SAAST,gBAAgBU,MAAc,EAAEC,KAAoB;IAC1E,IAAIC,OAAO;IAEX,IAAMC,aAAa,SAACC;eAAS,AAAC,GAA4BA,OAA1BC,eAAC,CAACC,IAAI,CAACL,MAAMD,UAAS,MAAS,OAALI,MAAK;;IAE/D,OAAO,IAAIR,UAAU;QACnBW,WAAAA,SAAAA,UAAUC,KAAK,EAAEC,IAAI,EAAEC,QAAQ;;YAC7B,IAAMC,OAAOT,OAAOM,MAAMI,QAAQ,CAAC;YACnC,IAAMC,QAAQF,KAAKhB,KAAK,CAACI;YACzBG,OAAOW,MAAMC,GAAG;YAChBD,MAAME,OAAO,CAAC,SAACX;gBACb,MAAKY,IAAI,CAACb,WAAWC;YACvB;YACAM;QACF;QACAO,OAAAA,SAAAA;YACE,IAAIf,KAAKgB,MAAM,EAAE,IAAI,CAACF,IAAI,CAACb,WAAWD;YACtCA,OAAO;YACP,IAAI,CAACc,IAAI,CAAC;QACZ;IACF;AACF"} | ||
| {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-streaming/src/lib/prefixTransform.ts"],"sourcesContent":["import StreamCompat from 'readable-stream';\nimport Stream from 'stream';\n\nconst major = +process.versions.node.split('.')[0];\nconst Transform = major > 0 ? Stream.Transform : (StreamCompat.Transform as typeof Stream.Transform);\n\nimport c from 'colors';\nimport type { ColorFunction } from '../types.ts';\nimport LineBuffer from './LineBuffer.ts';\n\nexport default function prefixTransform(prefix: string, color: ColorFunction): NodeJS.ReadableStream {\n const createLine = (line: string) => `${c.bold(color(prefix))}: ${line}\\n`;\n\n let transform: InstanceType<typeof Transform>;\n const lineBuffer = new LineBuffer((line) => {\n transform.push(createLine(line));\n });\n\n transform = new Transform({\n transform(chunk, _enc, callback) {\n lineBuffer.write(chunk);\n callback();\n },\n flush() {\n lineBuffer.flush();\n lineBuffer.dispose();\n this.push(null);\n },\n });\n\n return transform;\n}\n"],"names":["prefixTransform","major","process","versions","node","split","Transform","Stream","StreamCompat","prefix","color","createLine","line","c","bold","transform","lineBuffer","LineBuffer","push","chunk","_enc","callback","write","flush","dispose"],"mappings":";;;;+BAUA;;;eAAwBA;;;qEAVC;6DACN;6DAKL;mEAES;;;;;;AALvB,IAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,IAAMC,YAAYL,QAAQ,IAAIM,eAAM,CAACD,SAAS,GAAIE,uBAAY,CAACF,SAAS;AAMzD,SAASN,gBAAgBS,MAAc,EAAEC,KAAoB;IAC1E,IAAMC,aAAa,SAACC;eAAiB,AAAC,GAA4BA,OAA1BC,eAAC,CAACC,IAAI,CAACJ,MAAMD,UAAS,MAAS,OAALG,MAAK;;IAEvE,IAAIG;IACJ,IAAMC,aAAa,IAAIC,qBAAU,CAAC,SAACL;QACjCG,UAAUG,IAAI,CAACP,WAAWC;IAC5B;IAEAG,YAAY,IAAIT,UAAU;QACxBS,WAAAA,SAAAA,UAAUI,KAAK,EAAEC,IAAI,EAAEC,QAAQ;YAC7BL,WAAWM,KAAK,CAACH;YACjBE;QACF;QACAE,OAAAA,SAAAA;YACEP,WAAWO,KAAK;YAChBP,WAAWQ,OAAO;YAClB,IAAI,CAACN,IAAI,CAAC;QACZ;IACF;IAEA,OAAOH;AACT"} |
+1
-55
@@ -17,15 +17,2 @@ "use strict"; | ||
| var _prefixTransformts = /*#__PURE__*/ _interop_require_default(require("./lib/prefixTransform.js")); | ||
| function _define_property(obj, key, value) { | ||
| if (key in obj) { | ||
| Object.defineProperty(obj, key, { | ||
| value: value, | ||
| enumerable: true, | ||
| configurable: true, | ||
| writable: true | ||
| }); | ||
| } else { | ||
| obj[key] = value; | ||
| } | ||
| return obj; | ||
| } | ||
| function _interop_require_default(obj) { | ||
@@ -77,41 +64,2 @@ return obj && obj.__esModule ? obj : { | ||
| } | ||
| function _object_spread(target) { | ||
| for(var i = 1; i < arguments.length; i++){ | ||
| var source = arguments[i] != null ? arguments[i] : {}; | ||
| var ownKeys = Object.keys(source); | ||
| if (typeof Object.getOwnPropertySymbols === "function") { | ||
| ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) { | ||
| return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
| })); | ||
| } | ||
| ownKeys.forEach(function(key) { | ||
| _define_property(target, key, source[key]); | ||
| }); | ||
| } | ||
| return target; | ||
| } | ||
| function ownKeys(object, enumerableOnly) { | ||
| var keys = Object.keys(object); | ||
| if (Object.getOwnPropertySymbols) { | ||
| var symbols = Object.getOwnPropertySymbols(object); | ||
| if (enumerableOnly) { | ||
| symbols = symbols.filter(function(sym) { | ||
| return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
| }); | ||
| } | ||
| keys.push.apply(keys, symbols); | ||
| } | ||
| return keys; | ||
| } | ||
| function _object_spread_props(target, source) { | ||
| source = source != null ? source : {}; | ||
| if (Object.getOwnPropertyDescriptors) { | ||
| Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); | ||
| } else { | ||
| ownKeys(Object(source)).forEach(function(key) { | ||
| Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
| }); | ||
| } | ||
| return target; | ||
| } | ||
| function _object_without_properties(source, excluded) { | ||
@@ -192,5 +140,3 @@ if (source == null) return {}; | ||
| } | ||
| queue.defer(_crossspawncb.default.worker.bind(null, cp, _object_spread_props(_object_spread({}, csOptions), { | ||
| encoding: 'utf8' | ||
| }))); | ||
| queue.defer(_crossspawncb.default.worker.bind(null, cp, csOptions)); | ||
| queue.await(function(err) { | ||
@@ -197,0 +143,0 @@ if (cp.stdout && process.stdout.getMaxListeners) { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-streaming/src/worker.ts"],"sourcesContent":["import spawn, { crossSpawn, type SpawnError, type SpawnResult } from 'cross-spawn-cb';\nimport oo from 'on-one';\nimport Queue from 'queue-cb';\nimport concatWritable from './lib/concatWritable.ts';\nimport nextColor from './lib/nextColor.ts';\nimport prefixTransform from './lib/prefixTransform.ts';\n\nimport type { SpawnCallback, SpawnOptions, StreamingOptions } from './types.ts';\n\nfunction pipeline(input, output, options, color) {\n if (options.prefix) return input.pipe(prefixTransform(options.prefix, color)).pipe(output);\n return input.pipe(output);\n}\n\nexport default function spawnStreaming(command: string, args: string[], spawnOptions: SpawnOptions, options: StreamingOptions, callback: SpawnCallback): undefined {\n const { encoding, stdio, ...csOptions } = spawnOptions;\n const cp = crossSpawn(command, args, csOptions);\n const color = options.prefix ? nextColor() : null;\n const outputs = { stdout: null, stderr: null };\n\n if (cp.stdout && process.stdout.getMaxListeners) {\n process.stdout.setMaxListeners(process.stdout.getMaxListeners() + 1);\n process.stderr.setMaxListeners(process.stderr.getMaxListeners() + 1);\n }\n\n const queue = new Queue();\n if (cp.stdout) {\n if (stdio === 'inherit') pipeline(cp.stdout, process.stdout, options, color);\n else {\n outputs.stdout = concatWritable((output) => {\n outputs.stdout.output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, pipeline(cp.stdout, outputs.stdout, options, color), ['error', 'end', 'close', 'finish']));\n }\n }\n if (cp.stderr) {\n if (stdio === 'inherit') pipeline(cp.stderr, process.stderr, options, color);\n else {\n outputs.stderr = concatWritable((output) => {\n outputs.stderr.output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, pipeline(cp.stderr, outputs.stderr, options, color), ['error', 'end', 'close', 'finish']));\n }\n }\n queue.defer(spawn.worker.bind(null, cp, { ...csOptions, encoding: 'utf8' }));\n queue.await((err: SpawnError) => {\n if (cp.stdout && process.stdout.getMaxListeners) {\n process.stdout.setMaxListeners(process.stdout.getMaxListeners() - 1);\n process.stderr.setMaxListeners(process.stderr.getMaxListeners() - 1);\n }\n\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = outputs.stdout ? outputs.stdout.output : null;\n res.stderr = outputs.stderr ? outputs.stderr.output : null;\n res.output = [res.stdout, res.stderr, null];\n err ? callback(err) : callback(null, res);\n });\n}\n"],"names":["spawnStreaming","pipeline","input","output","options","color","prefix","pipe","prefixTransform","command","args","spawnOptions","callback","encoding","stdio","csOptions","cp","crossSpawn","nextColor","outputs","stdout","stderr","process","getMaxListeners","setMaxListeners","queue","Queue","concatWritable","toString","defer","oo","bind","spawn","worker","await","err","res"],"mappings":";;;;+BAcA;;;eAAwBA;;;oEAd6C;4DACtD;8DACG;uEACS;kEACL;wEACM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAI5B,SAASC,SAASC,KAAK,EAAEC,MAAM,EAAEC,OAAO,EAAEC,KAAK;IAC7C,IAAID,QAAQE,MAAM,EAAE,OAAOJ,MAAMK,IAAI,CAACC,IAAAA,0BAAe,EAACJ,QAAQE,MAAM,EAAED,QAAQE,IAAI,CAACJ;IACnF,OAAOD,MAAMK,IAAI,CAACJ;AACpB;AAEe,SAASH,eAAeS,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEP,OAAyB,EAAEQ,QAAuB;IACpJ,IAAQC,WAAkCF,aAAlCE,UAAUC,QAAwBH,aAAxBG,OAAUC,uCAAcJ;QAAlCE;QAAUC;;IAClB,IAAME,KAAKC,IAAAA,wBAAU,EAACR,SAASC,MAAMK;IACrC,IAAMV,QAAQD,QAAQE,MAAM,GAAGY,IAAAA,oBAAS,MAAK;IAC7C,IAAMC,UAAU;QAAEC,QAAQ;QAAMC,QAAQ;IAAK;IAE7C,IAAIL,GAAGI,MAAM,IAAIE,QAAQF,MAAM,CAACG,eAAe,EA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I,eAAe,CAACF,QAAQF,MAAM,CAACG,eAAe,KAAK;YAClED,QAAQD,MAAM,CAACG,eAAe,CAACF,QAAQD,MAAM,CAACE,eAAe,KAAK;QACpE;QAEA,IAAMa,MAAOD,MAAMA,MAAM,CAAC;QAC1BC,IAAIhB,MAAM,GAAGD,QAAQC,MAAM,GAAGD,QAAQC,MAAM,CAACjB,MAAM,GAAG;QACtDiC,IAAIf,MAAM,GAAGF,QAAQE,MAAM,GAAGF,QAAQE,MAAM,CAAClB,MAAM,GAAG;QACtDiC,IAAIjC,MAAM,GAAG;YAACiC,IAAIhB,MAAM;YAAEgB,IAAIf,MAAM;YAAE;SAAK;QAC3Cc,MAAMvB,SAASuB,OAAOvB,SAAS,MAAMwB;IACvC;AACF"} | ||
| {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-streaming/src/worker.ts"],"sourcesContent":["import spawn, { crossSpawn, type SpawnError, type SpawnResult } from 'cross-spawn-cb';\nimport oo from 'on-one';\nimport Queue from 'queue-cb';\nimport concatWritable from './lib/concatWritable.ts';\nimport nextColor from './lib/nextColor.ts';\nimport prefixTransform from './lib/prefixTransform.ts';\n\nimport type { SpawnCallback, SpawnOptions, StreamingOptions } from './types.ts';\n\nfunction pipeline(input, output, options, color) {\n if (options.prefix) return input.pipe(prefixTransform(options.prefix, color)).pipe(output);\n return input.pipe(output);\n}\n\nexport default function spawnStreaming(command: string, args: string[], spawnOptions: SpawnOptions, options: StreamingOptions, callback: SpawnCallback): undefined {\n const { encoding, stdio, ...csOptions } = spawnOptions;\n const cp = crossSpawn(command, args, csOptions);\n const color = options.prefix ? nextColor() : null;\n const outputs = { stdout: null, stderr: null };\n\n if (cp.stdout && process.stdout.getMaxListeners) {\n process.stdout.setMaxListeners(process.stdout.getMaxListeners() + 1);\n process.stderr.setMaxListeners(process.stderr.getMaxListeners() + 1);\n }\n\n const queue = new Queue();\n if (cp.stdout) {\n if (stdio === 'inherit') pipeline(cp.stdout, process.stdout, options, color);\n else {\n outputs.stdout = concatWritable((output) => {\n outputs.stdout.output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, pipeline(cp.stdout, outputs.stdout, options, color), ['error', 'end', 'close', 'finish']));\n }\n }\n if (cp.stderr) {\n if (stdio === 'inherit') pipeline(cp.stderr, process.stderr, options, color);\n else {\n outputs.stderr = concatWritable((output) => {\n outputs.stderr.output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, pipeline(cp.stderr, outputs.stderr, options, color), ['error', 'end', 'close', 'finish']));\n }\n }\n queue.defer(spawn.worker.bind(null, cp, csOptions));\n queue.await((err: SpawnError) => {\n if (cp.stdout && process.stdout.getMaxListeners) {\n process.stdout.setMaxListeners(process.stdout.getMaxListeners() - 1);\n process.stderr.setMaxListeners(process.stderr.getMaxListeners() - 1);\n }\n\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = outputs.stdout ? outputs.stdout.output : null;\n res.stderr = outputs.stderr ? outputs.stderr.output : null;\n res.output = [res.stdout, res.stderr, null];\n err ? callback(err) : callback(null, res);\n });\n}\n"],"names":["spawnStreaming","pipeline","input","output","options","color","prefix","pipe","prefixTransform","command","args","spawnOptions","callback","encoding","stdio","csOptions","cp","crossSpawn","nextColor","outputs","stdout","stderr","process","getMaxListeners","setMaxListeners","queue","Queue","concatWritable","toString","defer","oo","bind","spawn","worker","await","err","res"],"mappings":";;;;+BAcA;;;eAAwBA;;;oEAd6C;4DACtD;8DACG;uEACS;kEACL;wEACM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAI5B,SAASC,SAASC,KAAK,EAAEC,MAAM,EAAEC,OAAO,EAAEC,KAAK;IAC7C,IAAID,QAAQE,MAAM,EAAE,OAAOJ,MAAMK,IAAI,CAACC,IAAAA,0BAAe,EAACJ,QAAQE,MAAM,EAAED,QAAQE,IAAI,CAACJ;IACnF,OAAOD,MAAMK,IAAI,CAACJ;AACpB;AA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ACf,YAAY;YACtD;YACAY,MAAMI,KAAK,CAACC,cAAE,CAACC,IAAI,CAAC,MAAM9B,SAASe,GAAGK,MAAM,EAAEF,QAAQE,MAAM,EAAEjB,SAASC,QAAQ;gBAAC;gBAAS;gBAAO;gBAAS;aAAS;QACpH;IACF;IACAoB,MAAMI,KAAK,CAACG,qBAAK,CAACC,MAAM,CAACF,IAAI,CAAC,MAAMf,IAAID;IACxCU,MAAMS,KAAK,CAAC,SAACC;QACX,IAAInB,GAAGI,MAAM,IAAIE,QAAQF,MAAM,CAACG,eAAe,EAAE;YAC/CD,QAAQF,MAAM,CAACI,eAAe,CAACF,QAAQF,MAAM,CAACG,eAAe,KAAK;YAClED,QAAQD,MAAM,CAACG,eAAe,CAACF,QAAQD,MAAM,CAACE,eAAe,KAAK;QACpE;QAEA,IAAMa,MAAOD,MAAMA,MAAM,CAAC;QAC1BC,IAAIhB,MAAM,GAAGD,QAAQC,MAAM,GAAGD,QAAQC,MAAM,CAACjB,MAAM,GAAG;QACtDiC,IAAIf,MAAM,GAAGF,QAAQE,MAAM,GAAGF,QAAQE,MAAM,CAAClB,MAAM,GAAG;QACtDiC,IAAIjC,MAAM,GAAG;YAACiC,IAAIhB,MAAM;YAAEgB,IAAIf,MAAM;YAAE;SAAK;QAC3Cc,MAAMvB,SAASuB,OAAOvB,SAAS,MAAMwB;IACvC;AACF"} |
| import worker from './worker.js'; | ||
| export * from './types.js'; | ||
| export default function spawnStreaming(command, args, spawnOptions, options, callback) { | ||
| if (spawnOptions.stdio === 'inherit' && spawnOptions.encoding) { | ||
| throw new Error("Options 'stdio: inherit' and 'encoding' are mutually exclusive. Use 'stdio: inherit' to display output, or 'encoding' to collect output."); | ||
| } | ||
| if (typeof options === 'function') { | ||
@@ -5,0 +8,0 @@ callback = options; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-streaming/src/index.ts"],"sourcesContent":["import type { SpawnCallback, SpawnOptions, StreamingOptions } from './types.ts';\nimport worker from './worker.ts';\n\nexport * from './types.ts';\nexport default function spawnStreaming(command: string, args: string[], spawnOptions: SpawnOptions, options?: StreamingOptions | SpawnCallback, callback?: SpawnCallback) {\n if (typeof options === 'function') {\n callback = options as SpawnCallback;\n options = {};\n }\n options = options || {};\n\n if (typeof callback === 'function') return worker(command, args, spawnOptions, options, callback);\n return new Promise((resolve, reject) => worker(command, args, spawnOptions, options, (err, result) => (err ? reject(err) : resolve(result))));\n}\n"],"names":["worker","spawnStreaming","command","args","spawnOptions","options","callback","Promise","resolve","reject","err","result"],"mappings":"AACA,OAAOA,YAAY,cAAc;AAEjC,cAAc,aAAa;AAC3B,eAAe,SAASC,eAAeC,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAA0C,EAAEC,QAAwB;IACtK,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOC,aAAa,YAAY,OAAON,OAAOE,SAASC,MAAMC,cAAcC,SAASC;IACxF,OAAO,IAAIC,QAAQ,CAACC,SAASC,SAAWT,OAAOE,SAASC,MAAMC,cAAcC,SAAS,CAACK,KAAKC,SAAYD,MAAMD,OAAOC,OAAOF,QAAQG;AACrI"} | ||
| {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-streaming/src/index.ts"],"sourcesContent":["import type { SpawnCallback, SpawnOptions, StreamingOptions } from './types.ts';\nimport worker from './worker.ts';\n\nexport * from './types.ts';\nexport default function spawnStreaming(command: string, args: string[], spawnOptions: SpawnOptions, options?: StreamingOptions | SpawnCallback, callback?: SpawnCallback) {\n if (spawnOptions.stdio === 'inherit' && spawnOptions.encoding) {\n throw new Error(\"Options 'stdio: inherit' and 'encoding' are mutually exclusive. Use 'stdio: inherit' to display output, or 'encoding' to collect output.\");\n }\n\n if (typeof options === 'function') {\n callback = options as SpawnCallback;\n options = {};\n }\n options = options || {};\n\n if (typeof callback === 'function') return worker(command, args, spawnOptions, options, callback);\n return new Promise((resolve, reject) => worker(command, args, spawnOptions, options, (err, result) => (err ? reject(err) : resolve(result))));\n}\n"],"names":["worker","spawnStreaming","command","args","spawnOptions","options","callback","stdio","encoding","Error","Promise","resolve","reject","err","result"],"mappings":"AACA,OAAOA,YAAY,cAAc;AAEjC,cAAc,aAAa;AAC3B,eAAe,SAASC,eAAeC,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEC,OAA0C,EAAEC,QAAwB;IACtK,IAAIF,aAAaG,KAAK,KAAK,aAAaH,aAAaI,QAAQ,EAAE;QAC7D,MAAM,IAAIC,MAAM;IAClB;IAEA,IAAI,OAAOJ,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOC,aAAa,YAAY,OAAON,OAAOE,SAASC,MAAMC,cAAcC,SAASC;IACxF,OAAO,IAAII,QAAQ,CAACC,SAASC,SAAWZ,OAAOE,SAASC,MAAMC,cAAcC,SAAS,CAACQ,KAAKC,SAAYD,MAAMD,OAAOC,OAAOF,QAAQG;AACrI"} |
@@ -6,22 +6,21 @@ import StreamCompat from 'readable-stream'; | ||
| import c from 'colors'; | ||
| const REGEX_NEW_LINE = /\r?\n|\r/g; | ||
| import LineBuffer from './LineBuffer.js'; | ||
| export default function prefixTransform(prefix, color) { | ||
| let last = ''; | ||
| const createLine = (line)=>`${c.bold(color(prefix))}: ${line}\n`; | ||
| return new Transform({ | ||
| let transform; | ||
| const lineBuffer = new LineBuffer((line)=>{ | ||
| transform.push(createLine(line)); | ||
| }); | ||
| transform = new Transform({ | ||
| transform (chunk, _enc, callback) { | ||
| const more = last + chunk.toString('utf8'); | ||
| const lines = more.split(REGEX_NEW_LINE); | ||
| last = lines.pop(); | ||
| lines.forEach((line)=>{ | ||
| this.push(createLine(line)); | ||
| }); | ||
| lineBuffer.write(chunk); | ||
| callback(); | ||
| }, | ||
| flush () { | ||
| if (last.length) this.push(createLine(last)); | ||
| last = ''; | ||
| lineBuffer.flush(); | ||
| lineBuffer.dispose(); | ||
| this.push(null); | ||
| } | ||
| }); | ||
| return transform; | ||
| } |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-streaming/src/lib/prefixTransform.ts"],"sourcesContent":["import StreamCompat from 'readable-stream';\nimport Stream from 'stream';\n\nconst major = +process.versions.node.split('.')[0];\nconst Transform = major > 0 ? Stream.Transform : (StreamCompat.Transform as typeof Stream.Transform);\n\nimport c from 'colors';\nimport type { ColorFunction } from '../types.ts';\n\nconst REGEX_NEW_LINE = /\\r?\\n|\\r/g;\n\nexport default function prefixTransform(prefix: string, color: ColorFunction): NodeJS.ReadableStream {\n let last = '';\n\n const createLine = (line) => `${c.bold(color(prefix))}: ${line}\\n`;\n\n return new Transform({\n transform(chunk, _enc, callback) {\n const more = last + chunk.toString('utf8');\n const lines = more.split(REGEX_NEW_LINE);\n last = lines.pop();\n lines.forEach((line) => {\n this.push(createLine(line));\n });\n callback();\n },\n flush() {\n if (last.length) this.push(createLine(last));\n last = '';\n this.push(null);\n },\n });\n}\n"],"names":["StreamCompat","Stream","major","process","versions","node","split","Transform","c","REGEX_NEW_LINE","prefixTransform","prefix","color","last","createLine","line","bold","transform","chunk","_enc","callback","more","toString","lines","pop","forEach","push","flush","length"],"mappings":"AAAA,OAAOA,kBAAkB,kBAAkB;AAC3C,OAAOC,YAAY,SAAS;AAE5B,MAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,MAAMC,YAAYL,QAAQ,IAAID,OAAOM,SAAS,GAAIP,aAAaO,SAAS;AAExE,OAAOC,OAAO,SAAS;AAGvB,MAAMC,iBAAiB;AAEvB,eAAe,SAASC,gBAAgBC,MAAc,EAAEC,KAAoB;IAC1E,IAAIC,OAAO;IAEX,MAAMC,aAAa,CAACC,OAAS,GAAGP,EAAEQ,IAAI,CAACJ,MAAMD,SAAS,EAAE,EAAEI,KAAK,EAAE,CAAC;IAElE,OAAO,IAAIR,UAAU;QACnBU,WAAUC,KAAK,EAAEC,IAAI,EAAEC,QAAQ;YAC7B,MAAMC,OAAOR,OAAOK,MAAMI,QAAQ,CAAC;YACnC,MAAMC,QAAQF,KAAKf,KAAK,CAACG;YACzBI,OAAOU,MAAMC,GAAG;YAChBD,MAAME,OAAO,CAAC,CAACV;gBACb,IAAI,CAACW,IAAI,CAACZ,WAAWC;YACvB;YACAK;QACF;QACAO;YACE,IAAId,KAAKe,MAAM,EAAE,IAAI,CAACF,IAAI,CAACZ,WAAWD;YACtCA,OAAO;YACP,IAAI,CAACa,IAAI,CAAC;QACZ;IACF;AACF"} | ||
| {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-streaming/src/lib/prefixTransform.ts"],"sourcesContent":["import StreamCompat from 'readable-stream';\nimport Stream from 'stream';\n\nconst major = +process.versions.node.split('.')[0];\nconst Transform = major > 0 ? Stream.Transform : (StreamCompat.Transform as typeof Stream.Transform);\n\nimport c from 'colors';\nimport type { ColorFunction } from '../types.ts';\nimport LineBuffer from './LineBuffer.ts';\n\nexport default function prefixTransform(prefix: string, color: ColorFunction): NodeJS.ReadableStream {\n const createLine = (line: string) => `${c.bold(color(prefix))}: ${line}\\n`;\n\n let transform: InstanceType<typeof Transform>;\n const lineBuffer = new LineBuffer((line) => {\n transform.push(createLine(line));\n });\n\n transform = new Transform({\n transform(chunk, _enc, callback) {\n lineBuffer.write(chunk);\n callback();\n },\n flush() {\n lineBuffer.flush();\n lineBuffer.dispose();\n this.push(null);\n },\n });\n\n return transform;\n}\n"],"names":["StreamCompat","Stream","major","process","versions","node","split","Transform","c","LineBuffer","prefixTransform","prefix","color","createLine","line","bold","transform","lineBuffer","push","chunk","_enc","callback","write","flush","dispose"],"mappings":"AAAA,OAAOA,kBAAkB,kBAAkB;AAC3C,OAAOC,YAAY,SAAS;AAE5B,MAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,MAAMC,YAAYL,QAAQ,IAAID,OAAOM,SAAS,GAAIP,aAAaO,SAAS;AAExE,OAAOC,OAAO,SAAS;AAEvB,OAAOC,gBAAgB,kBAAkB;AAEzC,eAAe,SAASC,gBAAgBC,MAAc,EAAEC,KAAoB;IAC1E,MAAMC,aAAa,CAACC,OAAiB,GAAGN,EAAEO,IAAI,CAACH,MAAMD,SAAS,EAAE,EAAEG,KAAK,EAAE,CAAC;IAE1E,IAAIE;IACJ,MAAMC,aAAa,IAAIR,WAAW,CAACK;QACjCE,UAAUE,IAAI,CAACL,WAAWC;IAC5B;IAEAE,YAAY,IAAIT,UAAU;QACxBS,WAAUG,KAAK,EAAEC,IAAI,EAAEC,QAAQ;YAC7BJ,WAAWK,KAAK,CAACH;YACjBE;QACF;QACAE;YACEN,WAAWM,KAAK;YAChBN,WAAWO,OAAO;YAClB,IAAI,CAACN,IAAI,CAAC;QACZ;IACF;IAEA,OAAOF;AACT"} |
@@ -52,6 +52,3 @@ import spawn, { crossSpawn } from 'cross-spawn-cb'; | ||
| } | ||
| queue.defer(spawn.worker.bind(null, cp, { | ||
| ...csOptions, | ||
| encoding: 'utf8' | ||
| })); | ||
| queue.defer(spawn.worker.bind(null, cp, csOptions)); | ||
| queue.await((err)=>{ | ||
@@ -58,0 +55,0 @@ if (cp.stdout && process.stdout.getMaxListeners) { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-streaming/src/worker.ts"],"sourcesContent":["import spawn, { crossSpawn, type SpawnError, type SpawnResult } from 'cross-spawn-cb';\nimport oo from 'on-one';\nimport Queue from 'queue-cb';\nimport concatWritable from './lib/concatWritable.ts';\nimport nextColor from './lib/nextColor.ts';\nimport prefixTransform from './lib/prefixTransform.ts';\n\nimport type { SpawnCallback, SpawnOptions, StreamingOptions } from './types.ts';\n\nfunction pipeline(input, output, options, color) {\n if (options.prefix) return input.pipe(prefixTransform(options.prefix, color)).pipe(output);\n return input.pipe(output);\n}\n\nexport default function spawnStreaming(command: string, args: string[], spawnOptions: SpawnOptions, options: StreamingOptions, callback: SpawnCallback): undefined {\n const { encoding, stdio, ...csOptions } = spawnOptions;\n const cp = crossSpawn(command, args, csOptions);\n const color = options.prefix ? nextColor() : null;\n const outputs = { stdout: null, stderr: null };\n\n if (cp.stdout && process.stdout.getMaxListeners) {\n process.stdout.setMaxListeners(process.stdout.getMaxListeners() + 1);\n process.stderr.setMaxListeners(process.stderr.getMaxListeners() + 1);\n }\n\n const queue = new Queue();\n if (cp.stdout) {\n if (stdio === 'inherit') pipeline(cp.stdout, process.stdout, options, color);\n else {\n outputs.stdout = concatWritable((output) => {\n outputs.stdout.output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, pipeline(cp.stdout, outputs.stdout, options, color), ['error', 'end', 'close', 'finish']));\n }\n }\n if (cp.stderr) {\n if (stdio === 'inherit') pipeline(cp.stderr, process.stderr, options, color);\n else {\n outputs.stderr = concatWritable((output) => {\n outputs.stderr.output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, pipeline(cp.stderr, outputs.stderr, options, color), ['error', 'end', 'close', 'finish']));\n }\n }\n queue.defer(spawn.worker.bind(null, cp, { ...csOptions, encoding: 'utf8' }));\n queue.await((err: SpawnError) => {\n if (cp.stdout && process.stdout.getMaxListeners) {\n process.stdout.setMaxListeners(process.stdout.getMaxListeners() - 1);\n process.stderr.setMaxListeners(process.stderr.getMaxListeners() - 1);\n }\n\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = outputs.stdout ? outputs.stdout.output : null;\n res.stderr = outputs.stderr ? outputs.stderr.output : null;\n res.output = [res.stdout, res.stderr, null];\n err ? callback(err) : callback(null, res);\n });\n}\n"],"names":["spawn","crossSpawn","oo","Queue","concatWritable","nextColor","prefixTransform","pipeline","input","output","options","color","prefix","pipe","spawnStreaming","command","args","spawnOptions","callback","encoding","stdio","csOptions","cp","outputs","stdout","stderr","process","getMaxListeners","setMaxListeners","queue","toString","defer","bind","worker","await","err","res"],"mappings":"AAAA,OAAOA,SAASC,UAAU,QAA2C,iBAAiB;AACtF,OAAOC,QAAQ,SAAS;AACxB,OAAOC,WAAW,WAAW;AAC7B,OAAOC,oBAAoB,0BAA0B;AACrD,OAAOC,eAAe,qBAAqB;AAC3C,OAAOC,qBAAqB,2BAA2B;AAIvD,SAASC,SAASC,KAAK,EAAEC,MAAM,EAAEC,OAAO,EAAEC,KAAK;IAC7C,IAAID,QAAQE,MAAM,EAAE,OAAOJ,MAAMK,IAAI,CAACP,gBAAgBI,QAAQE,MAAM,EAAED,QAAQE,IAAI,CAACJ;IACnF,OAAOD,MAAMK,IAAI,CAACJ;AACpB;AAEA,eAAe,SAASK,eAAeC,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEP,OAAyB,EAAEQ,QAAuB;IACpJ,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAE,GAAGC,WAAW,GAAGJ;IAC1C,MAAMK,KAAKrB,WAAWc,SAASC,MAAMK;IACrC,MAAMV,QAAQD,QAAQE,MAAM,GAAGP,cAAc;IAC7C,MAAMkB,UAAU;QAAEC,QAAQ;QAAMC,QAAQ;IAAK;IAE7C,IAAIH,GAAGE,MAAM,IAAIE,QAAQF,MAAM,CAACG,eAAe,EAAE;QAC/CD,QAAQF,MAAM,CAACI,eAAe,CAACF,QAAQF,MAAM,CAACG,eAAe,KAAK;QAClED,QAAQD,MAAM,CAACG,eAAe,CAACF,QAAQD,MAAM,CAACE,eAAe,KAAK;IACpE;IAEA,MAAME,QAAQ,IAAI1B;IAClB,IAAImB,GAAGE,MAAM,EAAE;QACb,IAAIJ,UAAU,WAAWb,SAASe,GAAGE,MAAM,EAAEE,QAAQF,MAAM,EAAEd,SAASC;aACjE;YACHY,QAAQC,MAAM,GAAGpB,eAAe,CAACK;gBAC/Bc,QAAQC,MAAM,CAACf,MA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E;SAAK;QAC3CU,MAAMjB,SAASiB,OAAOjB,SAAS,MAAMkB;IACvC;AACF"} | ||
| {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-streaming/src/worker.ts"],"sourcesContent":["import spawn, { crossSpawn, type SpawnError, type SpawnResult } from 'cross-spawn-cb';\nimport oo from 'on-one';\nimport Queue from 'queue-cb';\nimport concatWritable from './lib/concatWritable.ts';\nimport nextColor from './lib/nextColor.ts';\nimport prefixTransform from './lib/prefixTransform.ts';\n\nimport type { SpawnCallback, SpawnOptions, StreamingOptions } from './types.ts';\n\nfunction pipeline(input, output, options, color) {\n if (options.prefix) return input.pipe(prefixTransform(options.prefix, color)).pipe(output);\n return input.pipe(output);\n}\n\nexport default function spawnStreaming(command: string, args: string[], spawnOptions: SpawnOptions, options: StreamingOptions, callback: SpawnCallback): undefined {\n const { encoding, stdio, ...csOptions } = spawnOptions;\n const cp = crossSpawn(command, args, csOptions);\n const color = options.prefix ? nextColor() : null;\n const outputs = { stdout: null, stderr: null };\n\n if (cp.stdout && process.stdout.getMaxListeners) {\n process.stdout.setMaxListeners(process.stdout.getMaxListeners() + 1);\n process.stderr.setMaxListeners(process.stderr.getMaxListeners() + 1);\n }\n\n const queue = new Queue();\n if (cp.stdout) {\n if (stdio === 'inherit') pipeline(cp.stdout, process.stdout, options, color);\n else {\n outputs.stdout = concatWritable((output) => {\n outputs.stdout.output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, pipeline(cp.stdout, outputs.stdout, options, color), ['error', 'end', 'close', 'finish']));\n }\n }\n if (cp.stderr) {\n if (stdio === 'inherit') pipeline(cp.stderr, process.stderr, options, color);\n else {\n outputs.stderr = concatWritable((output) => {\n outputs.stderr.output = output.toString(encoding || 'utf8');\n });\n queue.defer(oo.bind(null, pipeline(cp.stderr, outputs.stderr, options, color), ['error', 'end', 'close', 'finish']));\n }\n }\n queue.defer(spawn.worker.bind(null, cp, csOptions));\n queue.await((err: SpawnError) => {\n if (cp.stdout && process.stdout.getMaxListeners) {\n process.stdout.setMaxListeners(process.stdout.getMaxListeners() - 1);\n process.stderr.setMaxListeners(process.stderr.getMaxListeners() - 1);\n }\n\n const res = (err ? err : {}) as SpawnResult;\n res.stdout = outputs.stdout ? outputs.stdout.output : null;\n res.stderr = outputs.stderr ? outputs.stderr.output : null;\n res.output = [res.stdout, res.stderr, null];\n err ? callback(err) : callback(null, res);\n });\n}\n"],"names":["spawn","crossSpawn","oo","Queue","concatWritable","nextColor","prefixTransform","pipeline","input","output","options","color","prefix","pipe","spawnStreaming","command","args","spawnOptions","callback","encoding","stdio","csOptions","cp","outputs","stdout","stderr","process","getMaxListeners","setMaxListeners","queue","toString","defer","bind","worker","await","err","res"],"mappings":"AAAA,OAAOA,SAASC,UAAU,QAA2C,iBAAiB;AACtF,OAAOC,QAAQ,SAAS;AACxB,OAAOC,WAAW,WAAW;AAC7B,OAAOC,oBAAoB,0BAA0B;AACrD,OAAOC,eAAe,qBAAqB;AAC3C,OAAOC,qBAAqB,2BAA2B;AAIvD,SAASC,SAASC,KAAK,EAAEC,MAAM,EAAEC,OAAO,EAAEC,KAAK;IAC7C,IAAID,QAAQE,MAAM,EAAE,OAAOJ,MAAMK,IAAI,CAACP,gBAAgBI,QAAQE,MAAM,EAAED,QAAQE,IAAI,CAACJ;IACnF,OAAOD,MAAMK,IAAI,CAACJ;AACpB;AAEA,eAAe,SAASK,eAAeC,OAAe,EAAEC,IAAc,EAAEC,YAA0B,EAAEP,OAAyB,EAAEQ,QAAuB;IACpJ,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAE,GAAGC,WAAW,GAAGJ;IAC1C,MAAMK,KAAKrB,WAAWc,SAASC,MAAMK;IACrC,MAAMV,QAAQD,QAAQE,MAAM,GAAGP,cAAc;IAC7C,MAAMkB,UAAU;QAAEC,QAAQ;QAAMC,QAAQ;IAAK;IAE7C,IAAIH,GAAGE,MAAM,IAAIE,QAAQF,MAAM,CAACG,eAAe,EAAE;QAC/CD,QAAQF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D,MAAM,CAACE,eAAe,KAAK;QACpE;QAEA,MAAMS,MAAOD,MAAMA,MAAM,CAAC;QAC1BC,IAAIZ,MAAM,GAAGD,QAAQC,MAAM,GAAGD,QAAQC,MAAM,CAACf,MAAM,GAAG;QACtD2B,IAAIX,MAAM,GAAGF,QAAQE,MAAM,GAAGF,QAAQE,MAAM,CAAChB,MAAM,GAAG;QACtD2B,IAAI3B,MAAM,GAAG;YAAC2B,IAAIZ,MAAM;YAAEY,IAAIX,MAAM;YAAE;SAAK;QAC3CU,MAAMjB,SAASiB,OAAOjB,SAAS,MAAMkB;IACvC;AACF"} |
+1
-1
| { | ||
| "name": "spawn-streaming", | ||
| "version": "1.1.7", | ||
| "version": "1.1.9", | ||
| "description": "Formats spawn with prefix and colors", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
94100
99.44%54
14.89%1074
97.43%2
Infinity%