@gitkraken/core-gitlens 0.38.1 → 0.38.3
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.
- package/CHANGELOG.md +31 -1
- package/dist/git/parsers/diffParser.d.ts +25 -0
- package/dist/git/parsers/diffParser.js +169 -23
- package/dist/git/parsers/diffParser.js.map +1 -1
- package/dist/git/service.d.ts +4 -1
- package/dist/git/service.js +6 -2
- package/dist/git/service.js.map +1 -1
- package/dist/git/watching/unwatchedCacheValidator.d.ts +26 -4
- package/dist/git/watching/unwatchedCacheValidator.js +110 -10
- package/dist/git/watching/unwatchedCacheValidator.js.map +1 -1
- package/dist/git-cli/exec/statWorkers.d.ts +50 -0
- package/dist/git-cli/exec/statWorkers.js +194 -0
- package/dist/git-cli/exec/statWorkers.js.map +1 -0
- package/dist/git-cli/parsers/blameParser.js +25 -5
- package/dist/git-cli/parsers/blameParser.js.map +1 -1
- package/dist/git-cli/parsers/logParser.js +28 -18
- package/dist/git-cli/parsers/logParser.js.map +1 -1
- package/dist/git-cli/parsers/statusParser.d.ts +5 -1
- package/dist/git-cli/parsers/statusParser.js +17 -6
- package/dist/git-cli/parsers/statusParser.js.map +1 -1
- package/dist/git-cli/parsers/treeParser.js +5 -3
- package/dist/git-cli/parsers/treeParser.js.map +1 -1
- package/dist/git-cli/parsers/worktreeParser.js +1 -41
- package/dist/git-cli/parsers/worktreeParser.js.map +1 -1
- package/dist/git-cli/providers/revision.js +3 -3
- package/dist/git-cli/providers/revision.js.map +1 -1
- package/dist/git-cli/providers/status.js +1 -0
- package/dist/git-cli/providers/status.js.map +1 -1
- package/dist/git-cli/service.d.ts +7 -4
- package/dist/git-cli/service.js +14 -17
- package/dist/git-cli/service.js.map +1 -1
- package/dist/plus/integrations/authentication/configuredIntegrationService.d.ts +2 -0
- package/dist/plus/integrations/authentication/configuredIntegrationService.js +23 -1
- package/dist/plus/integrations/authentication/configuredIntegrationService.js.map +1 -1
- package/dist/plus/integrations/authentication/models.d.ts +1 -0
- package/dist/plus/integrations/authentication/models.js.map +1 -1
- package/dist/plus/integrations/authentication/observedAuthenticationProvider.js +4 -1
- package/dist/plus/integrations/authentication/observedAuthenticationProvider.js.map +1 -1
- package/dist/plus/integrations/integrationService.js +7 -1
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/models/integration.d.ts +1 -0
- package/dist/plus/integrations/models/integration.js +8 -0
- package/dist/plus/integrations/models/integration.js.map +1 -1
- package/dist/plus/integrations/models/issuesIntegration.d.ts +5 -0
- package/dist/plus/integrations/models/issuesIntegration.js +33 -1
- package/dist/plus/integrations/models/issuesIntegration.js.map +1 -1
- package/dist/plus/integrations/providers/jira.d.ts +3 -2
- package/dist/plus/integrations/providers/jira.js +36 -17
- package/dist/plus/integrations/providers/jira.js.map +1 -1
- package/dist/plus/integrations/providers/linear.d.ts +1 -0
- package/dist/plus/integrations/providers/linear.js +40 -17
- package/dist/plus/integrations/providers/linear.js.map +1 -1
- package/dist/plus/integrations/providers/utils/discoveryCache.d.ts +6 -3
- package/dist/plus/integrations/providers/utils/discoveryCache.js +12 -6
- package/dist/plus/integrations/providers/utils/discoveryCache.js.map +1 -1
- package/dist/utils/env/node/exec.js +24 -22
- package/dist/utils/env/node/exec.js.map +1 -1
- package/dist/utils/string.d.ts +15 -0
- package/dist/utils/string.js +61 -1
- package/dist/utils/string.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec.js","names":["joinPaths"],"sources":["../../../../../utils/src/env/node/exec.ts"],"sourcesContent":["import type { ChildProcess, ExecFileException, ExecFileOptions } from 'child_process';\nimport { execFile, spawn } from 'child_process';\nimport type { Stats } from 'fs';\nimport { access, constants } from 'fs';\nimport { stat } from 'fs/promises';\nimport { join as joinPaths } from 'path';\nimport * as process from 'process';\nimport type { Readable, Writable } from 'stream';\nimport type { CancellationReason } from '../../cancellation.js';\nimport { getScopedLogger, maybeStartScopedLogger } from '../../logger.scoped.js';\nimport { isWindows } from './platform.js';\n\n// -- Error types --\n\ninterface RunErrorContext {\n\tmessage: string;\n\tcmd?: string | undefined;\n\tkilled?: boolean | undefined;\n\tcode?: string | number | null | undefined;\n\tsignal?: NodeJS.Signals | undefined;\n}\n\nexport class RunError extends Error {\n\treadonly cmd?: string | undefined;\n\treadonly killed?: boolean | undefined;\n\treadonly code?: string | number | undefined;\n\treadonly signal?: NodeJS.Signals | undefined;\n\treadonly stdout: string;\n\treadonly stderr: string;\n\n\tconstructor(context: RunErrorContext, stdout: string, stderr: string) {\n\t\tsuper(context.message);\n\n\t\tthis.cmd = context.cmd;\n\t\tthis.killed = context.killed;\n\t\tthis.code = context.code ?? undefined;\n\t\tthis.signal = context.signal;\n\t\tthis.stdout = stdout?.trim() ?? '';\n\t\tthis.stderr = stderr?.trim() ?? '';\n\n\t\tthis.name = 'RunError';\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n}\n\nexport class CancelledRunError extends RunError {\n\treadonly reason: CancellationReason;\n\n\tconstructor(\n\t\tcmd: string,\n\t\tkilled: boolean,\n\t\tcode?: number | string | undefined,\n\t\tsignal: NodeJS.Signals = 'SIGTERM',\n\t\treason: CancellationReason = 'unknown',\n\t) {\n\t\tsuper(\n\t\t\t{ message: `Operation cancelled; command=${cmd}`, cmd: cmd, killed: killed, code: code, signal: signal },\n\t\t\t'',\n\t\t\t'',\n\t\t);\n\n\t\tthis.reason = reason;\n\n\t\tthis.name = 'CancelledRunError';\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n}\n\n// -- Execution utilities --\n\nconst slashesRegex = /[\\\\/]/;\nconst ps1Regex = /\\.ps1$/i;\nconst batOrCmdRegex = /\\.(bat|cmd)$/i;\nconst jsRegex = /\\.(js)$/i;\n\n/**\n * Search PATH to see if a file exists in any of the path folders.\n *\n * @param {string} exe The file to search for\n * @return {string} A fully qualified path, or the original path if nothing\n * is found\n *\n * @private\n */\nasync function runDownPath(exe: string): Promise<string> {\n\t// NB: Windows won't search PATH looking for executables in spawn like\n\t// Posix does\n\n\t// Files with any directory path don't get this applied\n\tif (slashesRegex.test(exe)) return exe;\n\n\tconst target = joinPaths('.', exe);\n\ttry {\n\t\tconst stats = await stat(target);\n\t\tif (stats?.isFile() && isExecutable(stats)) return target;\n\t} catch {}\n\n\tconst path = process.env.PATH;\n\tif (path != null && path.length !== 0) {\n\t\tconst haystack = path.split(isWindows ? ';' : ':');\n\t\tfor (const p of haystack) {\n\t\t\tconst needle = joinPaths(p, exe);\n\t\t\ttry {\n\t\t\t\tconst stats = await stat(needle);\n\t\t\t\tif (stats?.isFile() && isExecutable(stats)) return needle;\n\t\t\t} catch {}\n\t\t}\n\t}\n\n\treturn exe;\n}\n\nfunction isExecutable(stats: Stats) {\n\tif (isWindows) return true;\n\n\tconst isGroup = stats.gid ? stats.gid === process.getgid?.() : true;\n\tconst isUser = stats.uid ? stats.uid === process.getuid?.() : true;\n\n\treturn Boolean(stats.mode & 0o0001 || (stats.mode & 0o0010 && isGroup) || (stats.mode & 0o0100 && isUser));\n}\n\n/**\n * Finds the executable and parameters to run on Windows. This method\n * mimics the POSIX behavior of being able to run scripts as executables by\n * replacing the passed-in executable with the script runner, for PowerShell,\n * CMD, and node scripts.\n *\n * This method also does the work of running down PATH, which spawn on Windows\n * also doesn't do, unlike on POSIX.\n */\nexport async function findExecutable(exe: string, args: string[]): Promise<{ cmd: string; args: string[] }> {\n\t// POSIX can just execute scripts directly, no need for silly goosery\n\tif (!isWindows) return { cmd: await runDownPath(exe), args: args };\n\n\tif (!(await fsExists(exe))) {\n\t\t// NB: When you write something like `surf-client ... -- surf-build` on Windows,\n\t\t// a shell would normally convert that to surf-build.cmd, but since it's passed\n\t\t// in as an argument, it doesn't happen\n\t\tconst possibleExts = ['.exe', '.bat', '.cmd', '.ps1'];\n\t\tfor (const ext of possibleExts) {\n\t\t\tconst possibleFullPath = await runDownPath(`${exe}${ext}`);\n\n\t\t\tif (await fsExists(possibleFullPath)) return findExecutable(possibleFullPath, args);\n\t\t}\n\t}\n\n\tif (ps1Regex.test(exe)) {\n\t\tconst cmd = joinPaths(\n\t\t\tprocess.env.SYSTEMROOT ?? 'C:\\\\WINDOWS',\n\t\t\t'System32',\n\t\t\t'WindowsPowerShell',\n\t\t\t'v1.0',\n\t\t\t'PowerShell.exe',\n\t\t);\n\t\tconst psargs = ['-ExecutionPolicy', 'Unrestricted', '-NoLogo', '-NonInteractive', '-File', exe];\n\n\t\treturn { cmd: cmd, args: [...psargs, ...args] };\n\t}\n\n\tif (batOrCmdRegex.test(exe)) {\n\t\tconst cmd = joinPaths(process.env.SYSTEMROOT ?? 'C:\\\\WINDOWS', 'System32', 'cmd.exe');\n\t\tconst cmdArgs = ['/C', exe, ...args];\n\n\t\treturn { cmd: cmd, args: cmdArgs };\n\t}\n\n\tif (jsRegex.test(exe)) {\n\t\tconst cmd = process.execPath;\n\t\tconst nodeArgs = [exe];\n\n\t\treturn { cmd: cmd, args: [...nodeArgs, ...args] };\n\t}\n\n\treturn { cmd: exe, args: args };\n}\n\n/** What core uses of a spawned process; Node's `ChildProcess` satisfies it */\nexport interface SpawnedProcess {\n\treadonly stdin: Writable | null;\n\treadonly stdout: Readable | null;\n\treadonly stderr: Readable | null;\n\treadonly killed: boolean;\n\treadonly exitCode: number | null;\n\treadonly spawnargs: string[];\n\t/** Used to stop a run that passes its `maxBuffer`; without it the run destroys the output streams instead */\n\tkill?(signal?: NodeJS.Signals): boolean;\n\tonce(event: 'error', listener: (error: Error) => void): this;\n\tonce(event: 'close', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;\n\tremoveAllListeners(): this;\n}\n\nexport interface ProcessSpawnOptions {\n\treadonly cwd?: string;\n\t/** The child's whole environment, not additions to the spawner's own; an `undefined` value leaves the key out */\n\treadonly env?: Record<string, string | undefined>;\n\t/** Milliseconds; absent means none */\n\treadonly timeout?: number;\n\treadonly signal?: AbortSignal;\n\t/** A `null` entry means `'pipe'` */\n\treadonly stdio?: ['pipe' | 'ignore', null, null];\n}\n\n/**\n * Launches a process in place of Node's `spawn`, and must behave as it does:\n * - pipe stdout and stderr, and stdin unless `stdio[0]` is `'ignore'`, which leaves `stdin` null\n * - honour `signal`, including one already aborted: kill with SIGTERM, then emit `'error'` with `name` `AbortError`,\n * unless the process has already exited\n * - honour `timeout`: kill with SIGTERM and set `killed`, without emitting `'error'`\n * - report a killed process's `'close'` with a null code and its signal, not an exit code such as 143\n * - on Windows, end the process's whole tree when killing it (timeout, abort, or `kill`): a launcher such as Git for\n * Windows' `cmd\\git.exe` runs the real git as a child holding the same pipes, so killing only the launcher leaves\n * them open and `'close'` never comes\n * - emit no event before returning, `'error'` at most once, and `'close'` exactly once and last: also after `'error'`\n * (a failed launch, an abort), and only after `stdout` and `stderr` have ended or been destroyed, with `exitCode`\n * and `killed` already set\n * - close the child's stdout when `stdout` is destroyed, which is how a reader that stops early ends the process\n */\nexport type ProcessSpawner = (command: string, args: readonly string[], options: ProcessSpawnOptions) => SpawnedProcess;\n\n/**\n * The default {@link ProcessSpawner}: Node's `spawn`, but with its `timeout` handled here. Node clears its timeout\n * timer only on `'exit'`, which a failed launch (e.g. a missing `cwd`) never emits, so the timer outlives the\n * process and keeps Node alive for the full timeout. This mirrors Node's timeout handling but also clears on\n * `'close'`, as https://github.com/nodejs/node/pull/65506 does; remove it once the minimum supported Node/Electron\n * includes that fix.\n */\nexport function spawnProcess(command: string, args: readonly string[], options: ProcessSpawnOptions): ChildProcess {\n\tconst { timeout, ...spawnOptions } = options;\n\t// Node's own validation, thrown before anything spawns\n\tif (timeout != null && !(Number.isInteger(timeout) && timeout >= 0)) {\n\t\tconst ex = new RangeError(\n\t\t\t`The value of \"timeout\" is out of range. It must be an unsigned integer. Received ${String(timeout)}`,\n\t\t);\n\t\t(ex as RangeError & { code: string }).code = 'ERR_OUT_OF_RANGE';\n\t\tthrow ex;\n\t}\n\n\tconst child = spawn(command, args, spawnOptions);\n\tif (isWindows) {\n\t\tkillTreeOnKill(child);\n\t}\n\n\tif (timeout != null && timeout > 0) {\n\t\tlet timeoutId: ReturnType<typeof setTimeout> | undefined = setTimeout(() => {\n\t\t\tif (timeoutId != null) {\n\t\t\t\ttry {\n\t\t\t\t\tchild.kill();\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tchild.emit('error', ex);\n\t\t\t\t}\n\t\t\t\ttimeoutId = undefined;\n\t\t\t}\n\t\t}, timeout);\n\n\t\tconst clear = () => {\n\t\t\tif (timeoutId != null) {\n\t\t\t\tclearTimeout(timeoutId);\n\t\t\t\ttimeoutId = undefined;\n\t\t\t}\n\t\t};\n\t\t// `'exit'` keeps Node's timing; `'close'` covers a launch that fails and never exits\n\t\tchild.once('exit', clear);\n\t\tchild.once('close', clear);\n\t}\n\n\treturn child;\n}\n\nconst taskkillTimeout = 5000;\n\n/**\n * Makes `kill` end the child's whole tree (Windows only). There `kill` terminates just the child, and a launcher such\n * as Git for Windows' `cmd\\git.exe` runs the real git as its own child on the same stdout and stderr, so the pipes\n * stay open and `'close'` never comes. Node's abort and timeout paths call the instance's `kill`, so this covers them.\n */\nfunction killTreeOnKill(child: ChildProcess): void {\n\tconst kill = child.kill.bind(child);\n\tconst mutable = child as { killed: boolean; exitCode: number | null; signalCode: NodeJS.Signals | null };\n\tlet killing = false;\n\n\tchild.kill = (signal?: NodeJS.Signals | number): boolean => {\n\t\tif (child.pid == null || child.exitCode !== null || child.signalCode !== null || typeof signal === 'number') {\n\t\t\treturn kill(signal);\n\t\t}\n\t\tif (killing) return true;\n\n\t\tkilling = true;\n\t\tconst killSignal = signal ?? 'SIGTERM';\n\t\tmutable.killed = true;\n\n\t\t// Killed from outside, the child exits with taskkill's code 1 and no signal; report it as Node's own kill\n\t\t// would, a null code and the signal, which is what every caller keys on\n\t\tlet exitCode: number | null = child.exitCode;\n\t\tObject.defineProperty(child, 'exitCode', {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: true,\n\t\t\tget: () => exitCode,\n\t\t\tset: (value: number | null) => {\n\t\t\t\tif (value === 1) {\n\t\t\t\t\texitCode = null;\n\t\t\t\t\tmutable.signalCode = killSignal;\n\t\t\t\t} else {\n\t\t\t\t\texitCode = value;\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\n\t\t// Once it's killed, a descendant left alive (taskkill failed, or its parent was already gone) can still hold the\n\t\t// pipes; destroying them lets `'close'` come anyway. A child that exited on its own keeps its output\n\t\tchild.once('exit', (_code, exitSignal) => {\n\t\t\tif (exitSignal == null) return;\n\n\t\t\tchild.stdout?.destroy();\n\t\t\tchild.stderr?.destroy();\n\t\t});\n\n\t\t// taskkill failed: fall back to Node's kill, unless the child already exited on its own\n\t\tlet failed = false;\n\t\tconst fail = () => {\n\t\t\tif (failed || child.exitCode !== null || child.signalCode !== null) return;\n\n\t\t\tfailed = true;\n\t\t\ttry {\n\t\t\t\tkill(killSignal);\n\t\t\t} catch {}\n\t\t};\n\n\t\ttry {\n\t\t\t// By absolute path: Windows searches the current directory before PATH for a bare name. Its own time limit\n\t\t\t// keeps a stalled taskkill from leaving the kill, and so the run, hanging\n\t\t\tconst taskkill = spawn(\n\t\t\t\tjoinPaths(process.env.SystemRoot || 'C:\\\\Windows', 'System32', 'taskkill.exe'),\n\t\t\t\t['/T', '/F', '/PID', String(child.pid)],\n\t\t\t\t{ stdio: 'ignore', windowsHide: true, timeout: taskkillTimeout },\n\t\t\t);\n\t\t\ttaskkill.once('error', fail);\n\t\t\ttaskkill.once('exit', code => {\n\t\t\t\tif (code !== 0) {\n\t\t\t\t\tfail();\n\t\t\t\t}\n\t\t\t});\n\t\t} catch {\n\t\t\tfail();\n\t\t}\n\n\t\treturn true;\n\t};\n}\n\nexport interface RunOptions<TEncoding = BufferEncoding | 'buffer'> {\n\tcwd?: string;\n\treadonly env?: Record<string, string | undefined>;\n\treadonly encoding?: TEncoding;\n\t/**\n\t * Decodes non-UTF-8 output. Called when `encoding` is not utf8/binary/buffer.\n\t * Provided by the host via the `GitOptions.decode` option.\n\t * If absent and a non-UTF-8 encoding is requested, throws at runtime.\n\t */\n\treadonly decode?: (data: Uint8Array, options?: { readonly encoding: string }) => string | Promise<string>;\n\t/**\n\t * The most bytes each of stdout and stderr may produce; past it the process is killed and the run rejects\n\t * with a `RunError` whose `code` is `ERR_CHILD_PROCESS_STDIO_MAXBUFFER`.\n\t *\n\t * If not specified, `run` allows 1000MB per stream and `runSpawn` allows unlimited output.\n\t */\n\treadonly maxBuffer?: number;\n\treadonly cancellation?: AbortSignal;\n\t/**\n\t * An optional string or buffer which will be written to\n\t * the child process stdin stream immediately immediately\n\t * after spawning the process.\n\t */\n\treadonly stdin?: string | Buffer;\n\t/**\n\t * The encoding to use when writing to stdin, if the stdin\n\t * parameter is a string.\n\t */\n\treadonly stdinEncoding?: string;\n\treadonly timeout?: number;\n\t/**\n\t * When true, suppresses the `[EXEC]` stderr warning emitted on debug-enabled scopes.\n\t * Use for commands whose failure is expected (e.g. paired with `errors: 'ignore'`).\n\t */\n\treadonly quiet?: boolean;\n\t/** Launches the process; defaults to {@link spawnProcess}. Only used by `runSpawn` */\n\treadonly spawn?: ProcessSpawner;\n}\n\nconst bufferExceededRegex = /stdout maxBuffer( length)? exceeded/;\n\ntype ExitCodeOnlyRunOptions<TEncoding = BufferEncoding | 'buffer'> = RunOptions<TEncoding> & { exitCodeOnly: true };\n\nexport function run(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | string,\n\toptions: ExitCodeOnlyRunOptions<BufferEncoding>,\n): Promise<number>;\nexport function run(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | string,\n\toptions?: RunOptions<BufferEncoding>,\n): Promise<string>;\nexport function run<T extends number | string>(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | string,\n\toptions?: RunOptions<BufferEncoding> & { exitCodeOnly?: boolean },\n): Promise<T> {\n\tconst scope = getScopedLogger() ?? maybeStartScopedLogger('Exec.run');\n\n\tconst { stdin, stdinEncoding, cancellation, decode, ...opts }: RunOptions<BufferEncoding> & ExecFileOptions = {\n\t\tmaxBuffer: 1000 * 1024 * 1024,\n\t\t...options,\n\t};\n\n\tconst promise = new Promise<T>((resolve, reject) => {\n\t\tconst proc = execFile(\n\t\t\tcommand,\n\t\t\targs,\n\t\t\t{ ...opts, signal: cancellation },\n\t\t\tasync (error: ExecFileException | null, stdout, stderr) => {\n\t\t\t\tif (options?.exitCodeOnly) {\n\t\t\t\t\tresolve((error?.code ?? proc.exitCode) as T);\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (error != null) {\n\t\t\t\t\tif (error.signal === 'SIGTERM') {\n\t\t\t\t\t\treject(\n\t\t\t\t\t\t\tnew CancelledRunError(\n\t\t\t\t\t\t\t\t`${command} ${args.join(' ')}`,\n\t\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\t\terror.code ?? undefined,\n\t\t\t\t\t\t\t\terror.signal,\n\t\t\t\t\t\t\t\tcancellation?.aborted ? 'aborted' : error.killed ? 'timeout' : 'unknown',\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (bufferExceededRegex.test(error.message)) {\n\t\t\t\t\t\terror.message = `Command output exceeded the allocated stdout buffer. Set 'options.maxBuffer' to a larger value than ${opts.maxBuffer} bytes`;\n\t\t\t\t\t}\n\n\t\t\t\t\tlet stdoutDecoded: string;\n\t\t\t\t\tlet stderrDecoded: string;\n\t\t\t\t\tif (encoding === 'utf8' || encoding === 'binary' || encoding === 'buffer') {\n\t\t\t\t\t\t// stdout & stderr can be `Buffer` or `string\n\t\t\t\t\t\t// oxlint-disable-next-line typescript/no-unnecessary-type-conversion\n\t\t\t\t\t\tstdoutDecoded = stdout.toString();\n\t\t\t\t\t\t// oxlint-disable-next-line typescript/no-unnecessary-type-conversion\n\t\t\t\t\t\tstderrDecoded = stderr.toString();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (decode == null) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Non-UTF-8 encoding '${encoding}' requested but no decode function configured`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tstdoutDecoded = await decode(\n\t\t\t\t\t\t\tBuffer.from(stdout, 'binary'),\n\t\t\t\t\t\t\tencoding ? { encoding: encoding } : undefined,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tstderrDecoded = await decode(\n\t\t\t\t\t\t\tBuffer.from(stderr, 'binary'),\n\t\t\t\t\t\t\tencoding ? { encoding: encoding } : undefined,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treject(new RunError(error, stdoutDecoded, stderrDecoded));\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (stderr && !options?.quiet && scope?.enabled('debug')) {\n\t\t\t\t\tscope?.warn(`[EXEC] '${command} ${args.join(' ')}' \\u2022 ${stderr}`);\n\t\t\t\t}\n\n\t\t\t\tif (encoding === 'utf8' || encoding === 'binary' || encoding === 'buffer') {\n\t\t\t\t\tresolve(stdout as T);\n\t\t\t\t} else {\n\t\t\t\t\tif (decode == null) {\n\t\t\t\t\t\tthrow new Error(`Non-UTF-8 encoding '${encoding}' requested but no decode function configured`);\n\t\t\t\t\t}\n\n\t\t\t\t\tresolve(\n\t\t\t\t\t\t(await decode(\n\t\t\t\t\t\t\tBuffer.from(stdout, 'binary'),\n\t\t\t\t\t\t\tencoding ? { encoding: encoding } : undefined,\n\t\t\t\t\t\t)) as T,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\t\tif (stdin != null) {\n\t\t\tendStdin(proc.stdin, stdin, stdinEncoding);\n\t\t}\n\t});\n\n\treturn promise.finally(() => scope?.[Symbol.dispose]());\n}\n\n/**\n * Writes a child's whole input and closes it. A child can exit, or be killed on cancellation, before reading all of\n * it, and the pipe then errors (EPIPE, or EOF on Windows). Unlistened, that error is thrown as an uncaught exception\n * and takes down the whole host process, so it is dropped: the child's exit status and stderr already report the\n * failure, and a child that chose to stop reading answered from what it read.\n */\nexport function endStdin(stream: Writable | null, stdin: string | Buffer, stdinEncoding: string | undefined): void {\n\tif (stream == null) return;\n\n\tstream.on('error', () => {});\n\tif (typeof stdin === 'string') {\n\t\tstream.end(stdin, (stdinEncoding ?? 'utf8') as BufferEncoding);\n\t} else {\n\t\tstream.end(stdin);\n\t}\n}\n\nexport interface RunExitResult {\n\t/**\n\t * The process's exit code. ABSENT when the process never exited normally — killed by a signal, in which\n\t * case {@link signal} is set. Deliberately optional rather than defaulted to `0`: a signalled process\n\t * reported as `exitCode: 0` is indistinguishable from a clean success, so callers would read a partial\n\t * or empty stdout as a complete answer.\n\t */\n\treadonly exitCode?: number;\n\t/** Set when the process was terminated by a signal instead of exiting; {@link exitCode} is then absent. */\n\treadonly signal?: NodeJS.Signals;\n\t/** Whether Node itself killed the process (its spawn `timeout`), as opposed to an external signal. */\n\treadonly killed?: boolean;\n}\n\nexport interface RunResult<T extends string | Buffer> extends RunExitResult {\n\tstdout: T;\n\tstderr: T;\n}\n\nexport function runSpawn(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | 'buffer' | string,\n\toptions: ExitCodeOnlyRunOptions,\n): Promise<RunExitResult>;\nexport function runSpawn<T extends string | Buffer>(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | 'buffer' | string,\n\toptions: RunOptions,\n): Promise<RunResult<T>>;\nexport function runSpawn<T extends string | Buffer>(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | 'buffer' | string,\n\toptions: RunOptions & { exitCodeOnly?: boolean },\n): Promise<RunExitResult | RunResult<T>> {\n\tconst scope = getScopedLogger() ?? maybeStartScopedLogger('Exec.runSpawn');\n\n\tconst { stdin, stdinEncoding, cancellation, decode, spawn: spawner, ...opts }: RunOptions = options;\n\n\tconst promise = new Promise<RunExitResult | RunResult<T>>((resolve, reject) => {\n\t\tconst proc = (spawner ?? spawnProcess)(command, args, {\n\t\t\tcwd: opts.cwd,\n\t\t\tenv: opts.env,\n\t\t\t// 0 disables it, which the spawner contract spells as absent\n\t\t\ttimeout: opts.timeout === 0 ? undefined : opts.timeout,\n\t\t\tsignal: cancellation,\n\t\t\tstdio: [stdin != null ? 'pipe' : 'ignore', null, null],\n\t\t});\n\t\tconst errorEncoding = encoding === 'buffer' ? 'utf8' : encoding;\n\n\t\tconst maxBuffer = opts.maxBuffer != null && opts.maxBuffer > 0 ? opts.maxBuffer : undefined;\n\t\tlet limitHit = false;\n\n\t\tfunction collector(buffers: Buffer[], name: 'stdout' | 'stderr'): (data: Buffer) => void {\n\t\t\tlet size = 0;\n\t\t\treturn (data: Buffer) => {\n\t\t\t\tif (limitHit) return;\n\n\t\t\t\tsize += data.length;\n\t\t\t\tif (maxBuffer != null && size > maxBuffer) {\n\t\t\t\t\texceedLimit(name);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tbuffers.push(data);\n\t\t\t};\n\t\t}\n\n\t\tconst stdoutBuffers: Buffer[] = [];\n\t\tconst collectStdout = collector(stdoutBuffers, 'stdout');\n\t\tproc.stdout?.on('data', collectStdout);\n\n\t\tconst stderrBuffers: Buffer[] = [];\n\t\tconst collectStderr = collector(stderrBuffers, 'stderr');\n\t\tproc.stderr?.on('data', collectStderr);\n\n\t\t// Settles the run as soon as a stream passes the limit. Destroying the streams ends a spawner whose process\n\t\t// has no `kill`, and the late `'close'` or `'error'` is ignored through `limitHit`\n\t\tfunction exceedLimit(name: 'stdout' | 'stderr'): void {\n\t\t\tlimitHit = true;\n\t\t\tstdoutBuffers.length = 0;\n\t\t\tstderrBuffers.length = 0;\n\t\t\tproc.stdout?.off('data', collectStdout);\n\t\t\tproc.stderr?.off('data', collectStderr);\n\n\t\t\ttry {\n\t\t\t\tproc.kill?.();\n\t\t\t} catch {}\n\t\t\tproc.stdout?.destroy();\n\t\t\tproc.stderr?.destroy();\n\n\t\t\treject(\n\t\t\t\tnew RunError(\n\t\t\t\t\t{\n\t\t\t\t\t\tmessage: `Command output exceeded the allocated ${name} buffer. Set 'options.maxBuffer' to a larger value than ${maxBuffer} bytes`,\n\t\t\t\t\t\tcmd: `${command} ${args.join(' ')}`,\n\t\t\t\t\t\tkilled: true,\n\t\t\t\t\t\tcode: 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER',\n\t\t\t\t\t},\n\t\t\t\t\t'',\n\t\t\t\t\t'',\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tfunction getStdio<T>(\n\t\t\tencoding: BufferEncoding | 'buffer' | string,\n\t\t): { stdout: T; stderr: T } | Promise<{ stdout: T; stderr: T }> {\n\t\t\tconst stdout = Buffer.concat(stdoutBuffers);\n\t\t\tconst stderr = Buffer.concat(stderrBuffers);\n\t\t\tif (encoding === 'utf8' || encoding === 'binary') {\n\t\t\t\treturn { stdout: stdout.toString(encoding) as T, stderr: stderr.toString(encoding) as T };\n\t\t\t}\n\t\t\tif (encoding === 'buffer') {\n\t\t\t\treturn { stdout: stdout as T, stderr: stderr as T };\n\t\t\t}\n\n\t\t\tif (decode == null) {\n\t\t\t\tthrow new Error(`Non-UTF-8 encoding '${encoding}' requested but no decode function configured`);\n\t\t\t}\n\n\t\t\treturn Promise.all([\n\t\t\t\tdecode(stdout, encoding ? { encoding: encoding } : undefined),\n\t\t\t\tdecode(stderr, encoding ? { encoding: encoding } : undefined),\n\t\t\t]).then(([decodedStdout, decodedStderr]) => ({\n\t\t\t\tstdout: decodedStdout as T,\n\t\t\t\tstderr: decodedStderr as T,\n\t\t\t}));\n\t\t}\n\n\t\t// An async listener's throw would be an unhandled rejection that leaves the promise pending forever, so\n\t\t// anything it throws (an undecodable output, a failing `decode`) rejects the run instead. It rejects as\n\t\t// thrown: wrapped in a `RunError` with the exit code, a clean exit would read as a run with no output\n\t\tconst rejectThrown = (ex: unknown): void => reject(ex instanceof Error ? ex : new Error(String(ex)));\n\t\tproc.once('error', ex => void onError(ex).catch(rejectThrown));\n\t\tproc.once('close', (code, signal) => void onClose(code, signal).catch(rejectThrown));\n\n\t\tasync function onError(ex: Error): Promise<void> {\n\t\t\tif (limitHit) return;\n\n\t\t\tif (ex?.name === 'AbortError') {\n\t\t\t\treject(new CancelledRunError(`${command} ${args.join(' ')}`, true, undefined, undefined, 'aborted'));\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// The launch failure is what the caller acts on, so output that can't be decoded is left out of it\n\t\t\tlet stdout = '';\n\t\t\tlet stderr = '';\n\t\t\ttry {\n\t\t\t\tconst stdio = getStdio<string>(errorEncoding);\n\t\t\t\t({ stdout, stderr } = stdio instanceof Promise ? await stdio : stdio);\n\t\t\t} catch {}\n\n\t\t\treject(new RunError(ex, stdout, stderr));\n\t\t}\n\n\t\tasync function onClose(code: number | null, signal: NodeJS.Signals | null): Promise<void> {\n\t\t\tif (limitHit) return;\n\n\t\t\tif (options?.exitCodeOnly) {\n\t\t\t\t// Resolves unconditionally, so this is the one path that can hand back a signalled run. `code`\n\t\t\t\t// is null exactly when the process was killed — report the signal rather than coercing to `0`,\n\t\t\t\t// which would claim a clean success for a command that never finished. Note this returns BEFORE\n\t\t\t\t// the SIGTERM-to-cancellation diversion below, so callers have to classify that themselves.\n\t\t\t\tresolve({ exitCode: code ?? undefined, signal: signal ?? undefined, killed: proc.killed });\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (code !== 0 || signal) {\n\t\t\t\tconst stdio = getStdio<string>(errorEncoding);\n\t\t\t\tconst { stdout, stderr } = stdio instanceof Promise ? await stdio : stdio;\n\t\t\t\tif (stderr.length && !options?.quiet && scope?.enabled('debug')) {\n\t\t\t\t\tscope?.warn(`[EXEC] '${command} ${args.join(' ')}' \\u2022 ${stderr}`);\n\t\t\t\t}\n\n\t\t\t\tif (signal === 'SIGTERM') {\n\t\t\t\t\t// Only Node's spawn `timeout` kills it (a caller abort rejected above, from `'error'`); an\n\t\t\t\t\t// external SIGTERM leaves `proc.killed` false\n\t\t\t\t\treject(\n\t\t\t\t\t\tnew CancelledRunError(\n\t\t\t\t\t\t\t`${command} ${args.join(' ')}`,\n\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\tcode ?? undefined,\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\tproc.killed ? 'timeout' : 'unknown',\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\treject(\n\t\t\t\t\tnew RunError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmessage: `Command failed with exit code ${code}`,\n\t\t\t\t\t\t\tcode: code,\n\t\t\t\t\t\t\tsignal: signal ?? undefined,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tstdout,\n\t\t\t\t\t\tstderr,\n\t\t\t\t\t),\n\t\t\t\t);\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst stdio = getStdio<T>(encoding);\n\t\t\tconst { stdout, stderr } = stdio instanceof Promise ? await stdio : stdio;\n\t\t\tif (stderr.length && !options?.quiet && scope?.enabled('debug')) {\n\t\t\t\tscope?.warn(\n\t\t\t\t\t`[EXEC] '${command} ${args.join(' ')}' \\u2022 ${typeof stderr === 'string' ? stderr : stderr.toString()}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// The guard above already rejected every non-zero and every signalled close, so this is a clean\n\t\t\t// zero exit — `code` cannot be null here. (The optional typing exists for the `exitCodeOnly`\n\t\t\t// branch, which is where a codeless result can genuinely surface.)\n\t\t\tresolve({ exitCode: code ?? undefined, signal: signal ?? undefined, stdout: stdout, stderr: stderr });\n\t\t}\n\n\t\t// Only a host spawner can leave these out; reading no output as empty would pass for a clean answer\n\t\tif (proc.stdout == null || proc.stderr == null) {\n\t\t\treject(new Error(`'${command}' was spawned without stdout and stderr pipes`));\n\t\t}\n\n\t\tif (stdin != null) {\n\t\t\tendStdin(proc.stdin, stdin, stdinEncoding);\n\t\t}\n\t});\n\n\treturn promise.finally(() => scope?.[Symbol.dispose]());\n}\n\nexport async function fsExists(path: string): Promise<boolean> {\n\treturn new Promise<boolean>(resolve => access(path, constants.F_OK, err => resolve(err == null)));\n}\n"],"mappings":";;;;;;;;AAsBA,IAAa,WAAb,cAA8B,MAAM;CACnC;CACA;CACA;CACA;CACA;CACA;CAEA,YAAY,SAA0B,QAAgB,QAAgB;EACrE,MAAM,QAAQ,OAAO;EAErB,KAAK,MAAM,QAAQ;EACnB,KAAK,SAAS,QAAQ;EACtB,KAAK,OAAO,QAAQ,QAAQ,KAAA;EAC5B,KAAK,SAAS,QAAQ;EACtB,KAAK,SAAS,QAAQ,KAAK,KAAK;EAChC,KAAK,SAAS,QAAQ,KAAK,KAAK;EAEhC,KAAK,OAAO;EACZ,MAAM,oBAAoB,MAAM,UAAU;CAC3C;AACD;AAEA,IAAa,oBAAb,cAAuC,SAAS;CAC/C;CAEA,YACC,KACA,QACA,MACA,SAAyB,WACzB,SAA6B,WAC5B;EACD,MACC;GAAE,SAAS,gCAAgC;GAAY;GAAa;GAAc;GAAc;EAAO,GACvG,IACA,EACD;EAEA,KAAK,SAAS;EAEd,KAAK,OAAO;EACZ,MAAM,oBAAoB,MAAM,UAAU;CAC3C;AACD;AAIA,MAAM,eAAe;AACrB,MAAM,WAAW;AACjB,MAAM,gBAAgB;AACtB,MAAM,UAAU;;;;;;;;;;AAWhB,eAAe,YAAY,KAA8B;CAKxD,IAAI,aAAa,KAAK,GAAG,GAAG,OAAO;CAEnC,MAAM,SAASA,KAAU,KAAK,GAAG;CACjC,IAAI;EACH,MAAM,QAAQ,MAAM,KAAK,MAAM;EAC/B,IAAI,OAAO,OAAO,KAAK,aAAa,KAAK,GAAG,OAAO;CACpD,QAAQ,CAAC;CAET,MAAM,OAAO,QAAQ,IAAI;CACzB,IAAI,QAAQ,QAAQ,KAAK,WAAW,GAAG;EACtC,MAAM,WAAW,KAAK,MAAM,YAAY,MAAM,GAAG;EACjD,KAAK,MAAM,KAAK,UAAU;GACzB,MAAM,SAAS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SAAS,GACvG;GAMD,QAAQ;IAAE,UAAU,QAAQ,KAAA;IAAW,QAAQ,UAAU,KAAA;IAAmB;IAAgB;GAAO,CAAC;EACrG;EAGA,IAAI,KAAK,UAAU,QAAQ,KAAK,UAAU,MACzC,uBAAO,IAAI,MAAM,IAAI,QAAQ,8CAA8C,CAAC;EAG7E,IAAI,SAAS,MACZ,SAAS,KAAK,OAAO,OAAO,aAAa;CAE3C,CAEa,CAAC,CAAC,cAAc,QAAQ,OAAO,QAAQ,CAAC,CAAC;AACvD;AAEA,eAAsB,SAAS,MAAgC;CAC9D,OAAO,IAAI,SAAiB,YAAW,OAAO,MAAM,UAAU,OAAM,QAAO,QAAQ,OAAO,IAAI,CAAC,CAAC;AACjG"}
|
|
1
|
+
{"version":3,"file":"exec.js","names":["joinPaths"],"sources":["../../../../../utils/src/env/node/exec.ts"],"sourcesContent":["import type { ChildProcess, ExecFileException, ExecFileOptions } from 'child_process';\nimport { execFile, spawn } from 'child_process';\nimport type { Stats } from 'fs';\nimport { access, constants } from 'fs';\nimport { stat } from 'fs/promises';\nimport { join as joinPaths } from 'path';\nimport * as process from 'process';\nimport type { Readable, Writable } from 'stream';\nimport type { CancellationReason } from '../../cancellation.js';\nimport { getScopedLogger, maybeStartScopedLogger } from '../../logger.scoped.js';\nimport { isWindows } from './platform.js';\n\n// -- Error types --\n\ninterface RunErrorContext {\n\tmessage: string;\n\tcmd?: string | undefined;\n\tkilled?: boolean | undefined;\n\tcode?: string | number | null | undefined;\n\tsignal?: NodeJS.Signals | undefined;\n}\n\nexport class RunError extends Error {\n\treadonly cmd?: string | undefined;\n\treadonly killed?: boolean | undefined;\n\treadonly code?: string | number | undefined;\n\treadonly signal?: NodeJS.Signals | undefined;\n\treadonly stdout: string;\n\treadonly stderr: string;\n\n\tconstructor(context: RunErrorContext, stdout: string, stderr: string) {\n\t\tsuper(context.message);\n\n\t\tthis.cmd = context.cmd;\n\t\tthis.killed = context.killed;\n\t\tthis.code = context.code ?? undefined;\n\t\tthis.signal = context.signal;\n\t\tthis.stdout = stdout?.trim() ?? '';\n\t\tthis.stderr = stderr?.trim() ?? '';\n\n\t\tthis.name = 'RunError';\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n}\n\nexport class CancelledRunError extends RunError {\n\treadonly reason: CancellationReason;\n\n\tconstructor(\n\t\tcmd: string,\n\t\tkilled: boolean,\n\t\tcode?: number | string | undefined,\n\t\tsignal: NodeJS.Signals = 'SIGTERM',\n\t\treason: CancellationReason = 'unknown',\n\t) {\n\t\tsuper(\n\t\t\t{ message: `Operation cancelled; command=${cmd}`, cmd: cmd, killed: killed, code: code, signal: signal },\n\t\t\t'',\n\t\t\t'',\n\t\t);\n\n\t\tthis.reason = reason;\n\n\t\tthis.name = 'CancelledRunError';\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n}\n\n// -- Execution utilities --\n\nconst slashesRegex = /[\\\\/]/;\nconst ps1Regex = /\\.ps1$/i;\nconst batOrCmdRegex = /\\.(bat|cmd)$/i;\nconst jsRegex = /\\.(js)$/i;\n\n/**\n * Search PATH to see if a file exists in any of the path folders.\n *\n * @param {string} exe The file to search for\n * @return {string} A fully qualified path, or the original path if nothing\n * is found\n *\n * @private\n */\nasync function runDownPath(exe: string): Promise<string> {\n\t// NB: Windows won't search PATH looking for executables in spawn like\n\t// Posix does\n\n\t// Files with any directory path don't get this applied\n\tif (slashesRegex.test(exe)) return exe;\n\n\tconst target = joinPaths('.', exe);\n\ttry {\n\t\tconst stats = await stat(target);\n\t\tif (stats?.isFile() && isExecutable(stats)) return target;\n\t} catch {}\n\n\tconst path = process.env.PATH;\n\tif (path != null && path.length !== 0) {\n\t\tconst haystack = path.split(isWindows ? ';' : ':');\n\t\tfor (const p of haystack) {\n\t\t\tconst needle = joinPaths(p, exe);\n\t\t\ttry {\n\t\t\t\tconst stats = await stat(needle);\n\t\t\t\tif (stats?.isFile() && isExecutable(stats)) return needle;\n\t\t\t} catch {}\n\t\t}\n\t}\n\n\treturn exe;\n}\n\nfunction isExecutable(stats: Stats) {\n\tif (isWindows) return true;\n\n\tconst isGroup = stats.gid ? stats.gid === process.getgid?.() : true;\n\tconst isUser = stats.uid ? stats.uid === process.getuid?.() : true;\n\n\treturn Boolean(stats.mode & 0o0001 || (stats.mode & 0o0010 && isGroup) || (stats.mode & 0o0100 && isUser));\n}\n\n/**\n * Finds the executable and parameters to run on Windows. This method\n * mimics the POSIX behavior of being able to run scripts as executables by\n * replacing the passed-in executable with the script runner, for PowerShell,\n * CMD, and node scripts.\n *\n * This method also does the work of running down PATH, which spawn on Windows\n * also doesn't do, unlike on POSIX.\n */\nexport async function findExecutable(exe: string, args: string[]): Promise<{ cmd: string; args: string[] }> {\n\t// POSIX can just execute scripts directly, no need for silly goosery\n\tif (!isWindows) return { cmd: await runDownPath(exe), args: args };\n\n\tif (!(await fsExists(exe))) {\n\t\t// NB: When you write something like `surf-client ... -- surf-build` on Windows,\n\t\t// a shell would normally convert that to surf-build.cmd, but since it's passed\n\t\t// in as an argument, it doesn't happen\n\t\tconst possibleExts = ['.exe', '.bat', '.cmd', '.ps1'];\n\t\tfor (const ext of possibleExts) {\n\t\t\tconst possibleFullPath = await runDownPath(`${exe}${ext}`);\n\n\t\t\tif (await fsExists(possibleFullPath)) return findExecutable(possibleFullPath, args);\n\t\t}\n\t}\n\n\tif (ps1Regex.test(exe)) {\n\t\tconst cmd = joinPaths(\n\t\t\tprocess.env.SYSTEMROOT ?? 'C:\\\\WINDOWS',\n\t\t\t'System32',\n\t\t\t'WindowsPowerShell',\n\t\t\t'v1.0',\n\t\t\t'PowerShell.exe',\n\t\t);\n\t\tconst psargs = ['-ExecutionPolicy', 'Unrestricted', '-NoLogo', '-NonInteractive', '-File', exe];\n\n\t\treturn { cmd: cmd, args: [...psargs, ...args] };\n\t}\n\n\tif (batOrCmdRegex.test(exe)) {\n\t\tconst cmd = joinPaths(process.env.SYSTEMROOT ?? 'C:\\\\WINDOWS', 'System32', 'cmd.exe');\n\t\tconst cmdArgs = ['/C', exe, ...args];\n\n\t\treturn { cmd: cmd, args: cmdArgs };\n\t}\n\n\tif (jsRegex.test(exe)) {\n\t\tconst cmd = process.execPath;\n\t\tconst nodeArgs = [exe];\n\n\t\treturn { cmd: cmd, args: [...nodeArgs, ...args] };\n\t}\n\n\treturn { cmd: exe, args: args };\n}\n\n/** What core uses of a spawned process; Node's `ChildProcess` satisfies it */\nexport interface SpawnedProcess {\n\treadonly stdin: Writable | null;\n\treadonly stdout: Readable | null;\n\treadonly stderr: Readable | null;\n\treadonly killed: boolean;\n\treadonly exitCode: number | null;\n\treadonly spawnargs: string[];\n\t/** Used to stop a run that passes its `maxBuffer`; without it the run destroys the output streams instead */\n\tkill?(signal?: NodeJS.Signals): boolean;\n\tonce(event: 'error', listener: (error: Error) => void): this;\n\tonce(event: 'close', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;\n\tremoveAllListeners(): this;\n}\n\nexport interface ProcessSpawnOptions {\n\treadonly cwd?: string;\n\t/** The child's whole environment, not additions to the spawner's own; an `undefined` value leaves the key out */\n\treadonly env?: Record<string, string | undefined>;\n\t/** Milliseconds; absent means none */\n\treadonly timeout?: number;\n\treadonly signal?: AbortSignal;\n\t/** A `null` entry means `'pipe'` */\n\treadonly stdio?: ['pipe' | 'ignore', null, null];\n}\n\n/**\n * Launches a process in place of Node's `spawn`, and must behave as it does:\n * - pipe stdout and stderr, and stdin unless `stdio[0]` is `'ignore'`, which leaves `stdin` null\n * - honour `signal`, including one already aborted: kill with SIGTERM, then emit `'error'` with `name` `AbortError`,\n * unless the process has already exited\n * - honour `timeout`: kill with SIGTERM and set `killed`, without emitting `'error'`\n * - report a killed process's `'close'` with a null code and its signal, not an exit code such as 143\n * - on Windows, end the process's whole tree when killing it (timeout, abort, or `kill`): a launcher such as Git for\n * Windows' `cmd\\git.exe` runs the real git as a child holding the same pipes, so killing only the launcher leaves\n * them open and `'close'` never comes\n * - emit no event before returning, `'error'` at most once, and `'close'` exactly once and last: also after `'error'`\n * (a failed launch, an abort), and only after `stdout` and `stderr` have ended or been destroyed, with `exitCode`\n * and `killed` already set\n * - close the child's stdout when `stdout` is destroyed, which is how a reader that stops early ends the process\n */\nexport type ProcessSpawner = (command: string, args: readonly string[], options: ProcessSpawnOptions) => SpawnedProcess;\n\n/**\n * The default {@link ProcessSpawner}: Node's `spawn`, but with its `timeout` handled here. Node clears its timeout\n * timer only on `'exit'`, which a failed launch (e.g. a missing `cwd`) never emits, so the timer outlives the\n * process and keeps Node alive for the full timeout. This mirrors Node's timeout handling but also clears on\n * `'close'`, as https://github.com/nodejs/node/pull/65506 does; remove it once the minimum supported Node/Electron\n * includes that fix.\n */\nexport function spawnProcess(command: string, args: readonly string[], options: ProcessSpawnOptions): ChildProcess {\n\tconst { timeout, ...spawnOptions } = options;\n\t// Node's own validation, thrown before anything spawns\n\tif (timeout != null && !(Number.isInteger(timeout) && timeout >= 0)) {\n\t\tconst ex = new RangeError(\n\t\t\t`The value of \"timeout\" is out of range. It must be an unsigned integer. Received ${String(timeout)}`,\n\t\t);\n\t\t(ex as RangeError & { code: string }).code = 'ERR_OUT_OF_RANGE';\n\t\tthrow ex;\n\t}\n\n\tconst child = spawn(command, args, spawnOptions);\n\tif (isWindows) {\n\t\tkillTreeOnKill(child);\n\t}\n\n\tif (timeout != null && timeout > 0) {\n\t\tkillOnTimeout(child, timeout);\n\t}\n\n\treturn child;\n}\n\n/** Node's spawn `timeout`, but also cleared on `'close'`; see {@link spawnProcess} */\nfunction killOnTimeout(child: ChildProcess, timeout: number): void {\n\tlet timeoutId: ReturnType<typeof setTimeout> | undefined = setTimeout(() => {\n\t\tif (timeoutId != null) {\n\t\t\ttry {\n\t\t\t\tchild.kill();\n\t\t\t} catch (ex) {\n\t\t\t\tchild.emit('error', ex);\n\t\t\t}\n\t\t\ttimeoutId = undefined;\n\t\t}\n\t}, timeout);\n\n\tconst clear = () => {\n\t\tif (timeoutId != null) {\n\t\t\tclearTimeout(timeoutId);\n\t\t\ttimeoutId = undefined;\n\t\t}\n\t};\n\t// `'exit'` keeps Node's timing; `'close'` covers a launch that fails and never exits\n\tchild.once('exit', clear);\n\tchild.once('close', clear);\n}\n\nconst taskkillTimeout = 5000;\n\n/**\n * Makes `kill` end the child's whole tree (Windows only). There `kill` terminates just the child, and a launcher such\n * as Git for Windows' `cmd\\git.exe` runs the real git as its own child on the same stdout and stderr, so the pipes\n * stay open and `'close'` never comes. Node's abort and timeout paths call the instance's `kill`, so this covers them.\n */\nfunction killTreeOnKill(child: ChildProcess): void {\n\tconst kill = child.kill.bind(child);\n\tconst mutable = child as { killed: boolean; exitCode: number | null; signalCode: NodeJS.Signals | null };\n\tlet killing = false;\n\n\tchild.kill = (signal?: NodeJS.Signals | number): boolean => {\n\t\tif (child.pid == null || child.exitCode !== null || child.signalCode !== null || typeof signal === 'number') {\n\t\t\treturn kill(signal);\n\t\t}\n\t\tif (killing) return true;\n\n\t\tkilling = true;\n\t\tconst killSignal = signal ?? 'SIGTERM';\n\t\tmutable.killed = true;\n\n\t\t// Killed from outside, the child exits with taskkill's code 1 and no signal; report it as Node's own kill\n\t\t// would, a null code and the signal, which is what every caller keys on\n\t\tlet exitCode: number | null = child.exitCode;\n\t\tObject.defineProperty(child, 'exitCode', {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: true,\n\t\t\tget: () => exitCode,\n\t\t\tset: (value: number | null) => {\n\t\t\t\tif (value === 1) {\n\t\t\t\t\texitCode = null;\n\t\t\t\t\tmutable.signalCode = killSignal;\n\t\t\t\t} else {\n\t\t\t\t\texitCode = value;\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\n\t\t// Once it's killed, a descendant left alive (taskkill failed, or its parent was already gone) can still hold the\n\t\t// pipes; destroying them lets `'close'` come anyway. A child that exited on its own keeps its output\n\t\tchild.once('exit', (_code, exitSignal) => {\n\t\t\tif (exitSignal == null) return;\n\n\t\t\tchild.stdout?.destroy();\n\t\t\tchild.stderr?.destroy();\n\t\t});\n\n\t\t// taskkill failed: fall back to Node's kill, unless the child already exited on its own\n\t\tlet failed = false;\n\t\tconst fail = () => {\n\t\t\tif (failed || child.exitCode !== null || child.signalCode !== null) return;\n\n\t\t\tfailed = true;\n\t\t\ttry {\n\t\t\t\tkill(killSignal);\n\t\t\t} catch {}\n\t\t};\n\n\t\ttry {\n\t\t\t// By absolute path: Windows searches the current directory before PATH for a bare name. Its own time limit\n\t\t\t// keeps a stalled taskkill from leaving the kill, and so the run, hanging\n\t\t\tconst taskkill = spawn(\n\t\t\t\tjoinPaths(process.env.SystemRoot || 'C:\\\\Windows', 'System32', 'taskkill.exe'),\n\t\t\t\t['/T', '/F', '/PID', String(child.pid)],\n\t\t\t\t{ stdio: 'ignore', windowsHide: true },\n\t\t\t);\n\t\t\tkillOnTimeout(taskkill, taskkillTimeout);\n\t\t\ttaskkill.once('error', fail);\n\t\t\ttaskkill.once('exit', code => {\n\t\t\t\tif (code !== 0) {\n\t\t\t\t\tfail();\n\t\t\t\t}\n\t\t\t});\n\t\t} catch {\n\t\t\tfail();\n\t\t}\n\n\t\treturn true;\n\t};\n}\n\nexport interface RunOptions<TEncoding = BufferEncoding | 'buffer'> {\n\tcwd?: string;\n\treadonly env?: Record<string, string | undefined>;\n\treadonly encoding?: TEncoding;\n\t/**\n\t * Decodes non-UTF-8 output. Called when `encoding` is not utf8/binary/buffer.\n\t * Provided by the host via the `GitOptions.decode` option.\n\t * If absent and a non-UTF-8 encoding is requested, throws at runtime.\n\t */\n\treadonly decode?: (data: Uint8Array, options?: { readonly encoding: string }) => string | Promise<string>;\n\t/**\n\t * The most bytes each of stdout and stderr may produce; past it the process is killed and the run rejects\n\t * with a `RunError` whose `code` is `ERR_CHILD_PROCESS_STDIO_MAXBUFFER`.\n\t *\n\t * If not specified, `run` allows 1000MB per stream and `runSpawn` allows unlimited output.\n\t */\n\treadonly maxBuffer?: number;\n\treadonly cancellation?: AbortSignal;\n\t/**\n\t * An optional string or buffer which will be written to\n\t * the child process stdin stream immediately immediately\n\t * after spawning the process.\n\t */\n\treadonly stdin?: string | Buffer;\n\t/**\n\t * The encoding to use when writing to stdin, if the stdin\n\t * parameter is a string.\n\t */\n\treadonly stdinEncoding?: string;\n\treadonly timeout?: number;\n\t/**\n\t * When true, suppresses the `[EXEC]` stderr warning emitted on debug-enabled scopes.\n\t * Use for commands whose failure is expected (e.g. paired with `errors: 'ignore'`).\n\t */\n\treadonly quiet?: boolean;\n\t/** Launches the process; defaults to {@link spawnProcess}. Only used by `runSpawn` */\n\treadonly spawn?: ProcessSpawner;\n}\n\nconst bufferExceededRegex = /stdout maxBuffer( length)? exceeded/;\n\ntype ExitCodeOnlyRunOptions<TEncoding = BufferEncoding | 'buffer'> = RunOptions<TEncoding> & { exitCodeOnly: true };\n\nexport function run(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | string,\n\toptions: ExitCodeOnlyRunOptions<BufferEncoding>,\n): Promise<number>;\nexport function run(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | string,\n\toptions?: RunOptions<BufferEncoding>,\n): Promise<string>;\nexport function run<T extends number | string>(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | string,\n\toptions?: RunOptions<BufferEncoding> & { exitCodeOnly?: boolean },\n): Promise<T> {\n\tconst scope = getScopedLogger() ?? maybeStartScopedLogger('Exec.run');\n\n\tconst { stdin, stdinEncoding, cancellation, decode, ...opts }: RunOptions<BufferEncoding> & ExecFileOptions = {\n\t\tmaxBuffer: 1000 * 1024 * 1024,\n\t\t...options,\n\t};\n\n\tconst promise = new Promise<T>((resolve, reject) => {\n\t\tconst proc = execFile(\n\t\t\tcommand,\n\t\t\targs,\n\t\t\t{ ...opts, signal: cancellation },\n\t\t\tasync (error: ExecFileException | null, stdout, stderr) => {\n\t\t\t\tif (options?.exitCodeOnly) {\n\t\t\t\t\tresolve((error?.code ?? proc.exitCode) as T);\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (error != null) {\n\t\t\t\t\tif (error.signal === 'SIGTERM') {\n\t\t\t\t\t\treject(\n\t\t\t\t\t\t\tnew CancelledRunError(\n\t\t\t\t\t\t\t\t`${command} ${args.join(' ')}`,\n\t\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\t\terror.code ?? undefined,\n\t\t\t\t\t\t\t\terror.signal,\n\t\t\t\t\t\t\t\tcancellation?.aborted ? 'aborted' : error.killed ? 'timeout' : 'unknown',\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (bufferExceededRegex.test(error.message)) {\n\t\t\t\t\t\terror.message = `Command output exceeded the allocated stdout buffer. Set 'options.maxBuffer' to a larger value than ${opts.maxBuffer} bytes`;\n\t\t\t\t\t}\n\n\t\t\t\t\tlet stdoutDecoded: string;\n\t\t\t\t\tlet stderrDecoded: string;\n\t\t\t\t\tif (encoding === 'utf8' || encoding === 'binary' || encoding === 'buffer') {\n\t\t\t\t\t\t// stdout & stderr can be `Buffer` or `string\n\t\t\t\t\t\t// oxlint-disable-next-line typescript/no-unnecessary-type-conversion\n\t\t\t\t\t\tstdoutDecoded = stdout.toString();\n\t\t\t\t\t\t// oxlint-disable-next-line typescript/no-unnecessary-type-conversion\n\t\t\t\t\t\tstderrDecoded = stderr.toString();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (decode == null) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Non-UTF-8 encoding '${encoding}' requested but no decode function configured`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tstdoutDecoded = await decode(\n\t\t\t\t\t\t\tBuffer.from(stdout, 'binary'),\n\t\t\t\t\t\t\tencoding ? { encoding: encoding } : undefined,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tstderrDecoded = await decode(\n\t\t\t\t\t\t\tBuffer.from(stderr, 'binary'),\n\t\t\t\t\t\t\tencoding ? { encoding: encoding } : undefined,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treject(new RunError(error, stdoutDecoded, stderrDecoded));\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (stderr && !options?.quiet && scope?.enabled('debug')) {\n\t\t\t\t\tscope?.warn(`[EXEC] '${command} ${args.join(' ')}' \\u2022 ${stderr}`);\n\t\t\t\t}\n\n\t\t\t\tif (encoding === 'utf8' || encoding === 'binary' || encoding === 'buffer') {\n\t\t\t\t\tresolve(stdout as T);\n\t\t\t\t} else {\n\t\t\t\t\tif (decode == null) {\n\t\t\t\t\t\tthrow new Error(`Non-UTF-8 encoding '${encoding}' requested but no decode function configured`);\n\t\t\t\t\t}\n\n\t\t\t\t\tresolve(\n\t\t\t\t\t\t(await decode(\n\t\t\t\t\t\t\tBuffer.from(stdout, 'binary'),\n\t\t\t\t\t\t\tencoding ? { encoding: encoding } : undefined,\n\t\t\t\t\t\t)) as T,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\t\tif (stdin != null) {\n\t\t\tendStdin(proc.stdin, stdin, stdinEncoding);\n\t\t}\n\t});\n\n\treturn promise.finally(() => scope?.[Symbol.dispose]());\n}\n\n/**\n * Writes a child's whole input and closes it. A child can exit, or be killed on cancellation, before reading all of\n * it, and the pipe then errors (EPIPE, or EOF on Windows). Unlistened, that error is thrown as an uncaught exception\n * and takes down the whole host process, so it is dropped: the child's exit status and stderr already report the\n * failure, and a child that chose to stop reading answered from what it read.\n */\nexport function endStdin(stream: Writable | null, stdin: string | Buffer, stdinEncoding: string | undefined): void {\n\tif (stream == null) return;\n\n\tstream.on('error', () => {});\n\tif (typeof stdin === 'string') {\n\t\tstream.end(stdin, (stdinEncoding ?? 'utf8') as BufferEncoding);\n\t} else {\n\t\tstream.end(stdin);\n\t}\n}\n\nexport interface RunExitResult {\n\t/**\n\t * The process's exit code. ABSENT when the process never exited normally — killed by a signal, in which\n\t * case {@link signal} is set. Deliberately optional rather than defaulted to `0`: a signalled process\n\t * reported as `exitCode: 0` is indistinguishable from a clean success, so callers would read a partial\n\t * or empty stdout as a complete answer.\n\t */\n\treadonly exitCode?: number;\n\t/** Set when the process was terminated by a signal instead of exiting; {@link exitCode} is then absent. */\n\treadonly signal?: NodeJS.Signals;\n\t/** Whether Node itself killed the process (its spawn `timeout`), as opposed to an external signal. */\n\treadonly killed?: boolean;\n}\n\nexport interface RunResult<T extends string | Buffer> extends RunExitResult {\n\tstdout: T;\n\tstderr: T;\n}\n\nexport function runSpawn(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | 'buffer' | string,\n\toptions: ExitCodeOnlyRunOptions,\n): Promise<RunExitResult>;\nexport function runSpawn<T extends string | Buffer>(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | 'buffer' | string,\n\toptions: RunOptions,\n): Promise<RunResult<T>>;\nexport function runSpawn<T extends string | Buffer>(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | 'buffer' | string,\n\toptions: RunOptions & { exitCodeOnly?: boolean },\n): Promise<RunExitResult | RunResult<T>> {\n\tconst scope = getScopedLogger() ?? maybeStartScopedLogger('Exec.runSpawn');\n\n\tconst { stdin, stdinEncoding, cancellation, decode, spawn: spawner, ...opts }: RunOptions = options;\n\n\tconst promise = new Promise<RunExitResult | RunResult<T>>((resolve, reject) => {\n\t\tconst proc = (spawner ?? spawnProcess)(command, args, {\n\t\t\tcwd: opts.cwd,\n\t\t\tenv: opts.env,\n\t\t\t// 0 disables it, which the spawner contract spells as absent\n\t\t\ttimeout: opts.timeout === 0 ? undefined : opts.timeout,\n\t\t\tsignal: cancellation,\n\t\t\tstdio: [stdin != null ? 'pipe' : 'ignore', null, null],\n\t\t});\n\t\tconst errorEncoding = encoding === 'buffer' ? 'utf8' : encoding;\n\n\t\tconst maxBuffer = opts.maxBuffer != null && opts.maxBuffer > 0 ? opts.maxBuffer : undefined;\n\t\tlet limitHit = false;\n\n\t\tfunction collector(buffers: Buffer[], name: 'stdout' | 'stderr'): (data: Buffer) => void {\n\t\t\tlet size = 0;\n\t\t\treturn (data: Buffer) => {\n\t\t\t\tif (limitHit) return;\n\n\t\t\t\tsize += data.length;\n\t\t\t\tif (maxBuffer != null && size > maxBuffer) {\n\t\t\t\t\texceedLimit(name);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tbuffers.push(data);\n\t\t\t};\n\t\t}\n\n\t\tconst stdoutBuffers: Buffer[] = [];\n\t\tconst collectStdout = collector(stdoutBuffers, 'stdout');\n\t\tproc.stdout?.on('data', collectStdout);\n\n\t\tconst stderrBuffers: Buffer[] = [];\n\t\tconst collectStderr = collector(stderrBuffers, 'stderr');\n\t\tproc.stderr?.on('data', collectStderr);\n\n\t\t// Settles the run as soon as a stream passes the limit. Destroying the streams ends a spawner whose process\n\t\t// has no `kill`, and the late `'close'` or `'error'` is ignored through `limitHit`\n\t\tfunction exceedLimit(name: 'stdout' | 'stderr'): void {\n\t\t\tlimitHit = true;\n\t\t\tstdoutBuffers.length = 0;\n\t\t\tstderrBuffers.length = 0;\n\t\t\tproc.stdout?.off('data', collectStdout);\n\t\t\tproc.stderr?.off('data', collectStderr);\n\n\t\t\ttry {\n\t\t\t\tproc.kill?.();\n\t\t\t} catch {}\n\t\t\tproc.stdout?.destroy();\n\t\t\tproc.stderr?.destroy();\n\n\t\t\treject(\n\t\t\t\tnew RunError(\n\t\t\t\t\t{\n\t\t\t\t\t\tmessage: `Command output exceeded the allocated ${name} buffer. Set 'options.maxBuffer' to a larger value than ${maxBuffer} bytes`,\n\t\t\t\t\t\tcmd: `${command} ${args.join(' ')}`,\n\t\t\t\t\t\tkilled: true,\n\t\t\t\t\t\tcode: 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER',\n\t\t\t\t\t},\n\t\t\t\t\t'',\n\t\t\t\t\t'',\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tfunction getStdio<T>(\n\t\t\tencoding: BufferEncoding | 'buffer' | string,\n\t\t): { stdout: T; stderr: T } | Promise<{ stdout: T; stderr: T }> {\n\t\t\tconst stdout = Buffer.concat(stdoutBuffers);\n\t\t\tconst stderr = Buffer.concat(stderrBuffers);\n\t\t\tif (encoding === 'utf8' || encoding === 'binary') {\n\t\t\t\treturn { stdout: stdout.toString(encoding) as T, stderr: stderr.toString(encoding) as T };\n\t\t\t}\n\t\t\tif (encoding === 'buffer') {\n\t\t\t\treturn { stdout: stdout as T, stderr: stderr as T };\n\t\t\t}\n\n\t\t\tif (decode == null) {\n\t\t\t\tthrow new Error(`Non-UTF-8 encoding '${encoding}' requested but no decode function configured`);\n\t\t\t}\n\n\t\t\treturn Promise.all([\n\t\t\t\tdecode(stdout, encoding ? { encoding: encoding } : undefined),\n\t\t\t\tdecode(stderr, encoding ? { encoding: encoding } : undefined),\n\t\t\t]).then(([decodedStdout, decodedStderr]) => ({\n\t\t\t\tstdout: decodedStdout as T,\n\t\t\t\tstderr: decodedStderr as T,\n\t\t\t}));\n\t\t}\n\n\t\t// An async listener's throw would be an unhandled rejection that leaves the promise pending forever, so\n\t\t// anything it throws (an undecodable output, a failing `decode`) rejects the run instead. It rejects as\n\t\t// thrown: wrapped in a `RunError` with the exit code, a clean exit would read as a run with no output\n\t\tconst rejectThrown = (ex: unknown): void => reject(ex instanceof Error ? ex : new Error(String(ex)));\n\t\tproc.once('error', ex => void onError(ex).catch(rejectThrown));\n\t\tproc.once('close', (code, signal) => void onClose(code, signal).catch(rejectThrown));\n\n\t\tasync function onError(ex: Error): Promise<void> {\n\t\t\tif (limitHit) return;\n\n\t\t\tif (ex?.name === 'AbortError') {\n\t\t\t\treject(new CancelledRunError(`${command} ${args.join(' ')}`, true, undefined, undefined, 'aborted'));\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// The launch failure is what the caller acts on, so output that can't be decoded is left out of it\n\t\t\tlet stdout = '';\n\t\t\tlet stderr = '';\n\t\t\ttry {\n\t\t\t\tconst stdio = getStdio<string>(errorEncoding);\n\t\t\t\t({ stdout, stderr } = stdio instanceof Promise ? await stdio : stdio);\n\t\t\t} catch {}\n\n\t\t\treject(new RunError(ex, stdout, stderr));\n\t\t}\n\n\t\tasync function onClose(code: number | null, signal: NodeJS.Signals | null): Promise<void> {\n\t\t\tif (limitHit) return;\n\n\t\t\tif (options?.exitCodeOnly) {\n\t\t\t\t// Resolves unconditionally, so this is the one path that can hand back a signalled run. `code`\n\t\t\t\t// is null exactly when the process was killed — report the signal rather than coercing to `0`,\n\t\t\t\t// which would claim a clean success for a command that never finished. Note this returns BEFORE\n\t\t\t\t// the SIGTERM-to-cancellation diversion below, so callers have to classify that themselves.\n\t\t\t\tresolve({ exitCode: code ?? undefined, signal: signal ?? undefined, killed: proc.killed });\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (code !== 0 || signal) {\n\t\t\t\tconst stdio = getStdio<string>(errorEncoding);\n\t\t\t\tconst { stdout, stderr } = stdio instanceof Promise ? await stdio : stdio;\n\t\t\t\tif (stderr.length && !options?.quiet && scope?.enabled('debug')) {\n\t\t\t\t\tscope?.warn(`[EXEC] '${command} ${args.join(' ')}' \\u2022 ${stderr}`);\n\t\t\t\t}\n\n\t\t\t\tif (signal === 'SIGTERM') {\n\t\t\t\t\t// Only Node's spawn `timeout` kills it (a caller abort rejected above, from `'error'`); an\n\t\t\t\t\t// external SIGTERM leaves `proc.killed` false\n\t\t\t\t\treject(\n\t\t\t\t\t\tnew CancelledRunError(\n\t\t\t\t\t\t\t`${command} ${args.join(' ')}`,\n\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\tcode ?? undefined,\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\tproc.killed ? 'timeout' : 'unknown',\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\treject(\n\t\t\t\t\tnew RunError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmessage: `Command failed with exit code ${code}`,\n\t\t\t\t\t\t\tcode: code,\n\t\t\t\t\t\t\tsignal: signal ?? undefined,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tstdout,\n\t\t\t\t\t\tstderr,\n\t\t\t\t\t),\n\t\t\t\t);\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst stdio = getStdio<T>(encoding);\n\t\t\tconst { stdout, stderr } = stdio instanceof Promise ? await stdio : stdio;\n\t\t\tif (stderr.length && !options?.quiet && scope?.enabled('debug')) {\n\t\t\t\tscope?.warn(\n\t\t\t\t\t`[EXEC] '${command} ${args.join(' ')}' \\u2022 ${typeof stderr === 'string' ? stderr : stderr.toString()}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// The guard above already rejected every non-zero and every signalled close, so this is a clean\n\t\t\t// zero exit — `code` cannot be null here. (The optional typing exists for the `exitCodeOnly`\n\t\t\t// branch, which is where a codeless result can genuinely surface.)\n\t\t\tresolve({ exitCode: code ?? undefined, signal: signal ?? undefined, stdout: stdout, stderr: stderr });\n\t\t}\n\n\t\t// Only a host spawner can leave these out; reading no output as empty would pass for a clean answer\n\t\tif (proc.stdout == null || proc.stderr == null) {\n\t\t\treject(new Error(`'${command}' was spawned without stdout and stderr pipes`));\n\t\t}\n\n\t\tif (stdin != null) {\n\t\t\tendStdin(proc.stdin, stdin, stdinEncoding);\n\t\t}\n\t});\n\n\treturn promise.finally(() => scope?.[Symbol.dispose]());\n}\n\nexport async function fsExists(path: string): Promise<boolean> {\n\treturn new Promise<boolean>(resolve => access(path, constants.F_OK, err => resolve(err == null)));\n}\n"],"mappings":";;;;;;;;AAsBA,IAAa,WAAb,cAA8B,MAAM;CACnC;CACA;CACA;CACA;CACA;CACA;CAEA,YAAY,SAA0B,QAAgB,QAAgB;EACrE,MAAM,QAAQ,OAAO;EAErB,KAAK,MAAM,QAAQ;EACnB,KAAK,SAAS,QAAQ;EACtB,KAAK,OAAO,QAAQ,QAAQ,KAAA;EAC5B,KAAK,SAAS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c,QAAQ,OAAO,QAAQ,CAAC,CAAC;AACvD;AAEA,eAAsB,SAAS,MAAgC;CAC9D,OAAO,IAAI,SAAiB,YAAW,OAAO,MAAM,UAAU,OAAM,QAAO,QAAQ,OAAO,IAAI,CAAC,CAAC;AACjG"}
|
package/dist/utils/string.d.ts
CHANGED
|
@@ -86,6 +86,21 @@ export declare function isUpperAsciiLetter(code: number): boolean;
|
|
|
86
86
|
export declare function pad(s: string, before?: number, after?: number, padding?: string): string;
|
|
87
87
|
export declare function padOrTruncateEnd(s: string, maxLength: number, fillString?: string): string;
|
|
88
88
|
export declare function sanitizeForFileSystem(s: string, replacement?: string): string;
|
|
89
|
+
/**
|
|
90
|
+
* Reads the string git C-quotes (`"a\"b\tc"`) whose opening quote is at `from`, returning it with the index just
|
|
91
|
+
* past its closing quote, or `undefined` when it is malformed. Git writes a quoted name byte by byte, so an octal
|
|
92
|
+
* escape is one byte of the name's UTF-8, while a character it left as it was (every non-ASCII one with
|
|
93
|
+
* `core.quotePath` off) is already text
|
|
94
|
+
*/
|
|
95
|
+
export declare function readCQuotedString(text: string, from: number): {
|
|
96
|
+
value: string;
|
|
97
|
+
end: number;
|
|
98
|
+
} | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* Reverses git's C-style quoting of a whole value: a value git didn't quote, which can't start with a `"`, and one
|
|
101
|
+
* that isn't well-formed are returned as they are
|
|
102
|
+
*/
|
|
103
|
+
export declare function unquoteCString(value: string): string;
|
|
89
104
|
export declare function splitLast(s: string, splitter: string): string[];
|
|
90
105
|
export declare function splitSingle(s: string, splitter: string): string[];
|
|
91
106
|
export declare function truncate(s: string, truncateTo: number, ellipsis?: string, width?: number): string;
|
package/dist/utils/string.js
CHANGED
|
@@ -574,6 +574,66 @@ function sanitizeForFileSystem(s, replacement = "_") {
|
|
|
574
574
|
if (!s) return s;
|
|
575
575
|
return s.replace(illegalCharsForFSRegex, replacement);
|
|
576
576
|
}
|
|
577
|
+
const cStyleEscapes = {
|
|
578
|
+
a: 7,
|
|
579
|
+
b: 8,
|
|
580
|
+
t: 9,
|
|
581
|
+
n: 10,
|
|
582
|
+
v: 11,
|
|
583
|
+
f: 12,
|
|
584
|
+
r: 13,
|
|
585
|
+
"\"": 34,
|
|
586
|
+
"\\": 92
|
|
587
|
+
};
|
|
588
|
+
const octalEscapeRegex = /^[0-7]{3}/;
|
|
589
|
+
const utf8Encoder = new TextEncoder();
|
|
590
|
+
const utf8Decoder = new TextDecoder("utf-8", { ignoreBOM: true });
|
|
591
|
+
/**
|
|
592
|
+
* Reads the string git C-quotes (`"a\"b\tc"`) whose opening quote is at `from`, returning it with the index just
|
|
593
|
+
* past its closing quote, or `undefined` when it is malformed. Git writes a quoted name byte by byte, so an octal
|
|
594
|
+
* escape is one byte of the name's UTF-8, while a character it left as it was (every non-ASCII one with
|
|
595
|
+
* `core.quotePath` off) is already text
|
|
596
|
+
*/
|
|
597
|
+
function readCQuotedString(text, from) {
|
|
598
|
+
const bytes = [];
|
|
599
|
+
for (let i = from + 1; i < text.length; i++) {
|
|
600
|
+
const char = text[i];
|
|
601
|
+
if (char === "\"") return {
|
|
602
|
+
value: utf8Decoder.decode(new Uint8Array(bytes)),
|
|
603
|
+
end: i + 1
|
|
604
|
+
};
|
|
605
|
+
if (char !== "\\") {
|
|
606
|
+
const code = char.charCodeAt(0);
|
|
607
|
+
if (code < 128) {
|
|
608
|
+
bytes.push(code);
|
|
609
|
+
continue;
|
|
610
|
+
}
|
|
611
|
+
const codePoint = String.fromCodePoint(text.codePointAt(i));
|
|
612
|
+
bytes.push(...utf8Encoder.encode(codePoint));
|
|
613
|
+
i += codePoint.length - 1;
|
|
614
|
+
continue;
|
|
615
|
+
}
|
|
616
|
+
const octal = octalEscapeRegex.exec(text.substring(i + 1, i + 4));
|
|
617
|
+
if (octal != null) {
|
|
618
|
+
bytes.push(parseInt(octal[0], 8) & 255);
|
|
619
|
+
i += 3;
|
|
620
|
+
continue;
|
|
621
|
+
}
|
|
622
|
+
const escaped = cStyleEscapes[text[i + 1]];
|
|
623
|
+
if (escaped == null) return void 0;
|
|
624
|
+
bytes.push(escaped);
|
|
625
|
+
i++;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Reverses git's C-style quoting of a whole value: a value git didn't quote, which can't start with a `"`, and one
|
|
630
|
+
* that isn't well-formed are returned as they are
|
|
631
|
+
*/
|
|
632
|
+
function unquoteCString(value) {
|
|
633
|
+
if (!value.startsWith("\"")) return value;
|
|
634
|
+
const quoted = readCQuotedString(value, 0);
|
|
635
|
+
return quoted != null && quoted.end === value.length ? quoted.value : value;
|
|
636
|
+
}
|
|
577
637
|
function splitLast(s, splitter) {
|
|
578
638
|
const index = s.lastIndexOf(splitter);
|
|
579
639
|
if (index === -1) return [s];
|
|
@@ -817,6 +877,6 @@ function _decompressLZString(input, resetValue) {
|
|
|
817
877
|
}
|
|
818
878
|
}
|
|
819
879
|
//#endregion
|
|
820
|
-
export { capitalize, compareIgnoreCase, compareSubstring, compareSubstringIgnoreCase, countOccurrences, decompressFromBase64LZString, dedent, encodeHtmlWeak, equalsIgnoreCase, escapeRegex, flattenString, getDistributionGroup, getPossessiveForm, getSuperscript, getTokensFromTemplate, getTokensFromTemplateRegex, getTruncatedWidth, getWidth, interpolate, interpolateAsync, isLowerAsciiLetter, isUpperAsciiLetter, iterateAsyncByDelimiter, iterateByDelimiter, pad, padOrTruncateEnd, sanitizeForFileSystem, sortCompare, splitLast, splitMessage, splitSingle, truncate, truncateLeft, truncateMiddle };
|
|
880
|
+
export { capitalize, compareIgnoreCase, compareSubstring, compareSubstringIgnoreCase, countOccurrences, decompressFromBase64LZString, dedent, encodeHtmlWeak, equalsIgnoreCase, escapeRegex, flattenString, getDistributionGroup, getPossessiveForm, getSuperscript, getTokensFromTemplate, getTokensFromTemplateRegex, getTruncatedWidth, getWidth, interpolate, interpolateAsync, isLowerAsciiLetter, isUpperAsciiLetter, iterateAsyncByDelimiter, iterateByDelimiter, pad, padOrTruncateEnd, readCQuotedString, sanitizeForFileSystem, sortCompare, splitLast, splitMessage, splitSingle, truncate, truncateLeft, truncateMiddle, unquoteCString };
|
|
821
881
|
|
|
822
882
|
//# sourceMappingURL=string.js.map
|
package/dist/utils/string.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.js","names":[],"sources":["../../../utils/src/string.ts"],"sourcesContent":["import type {\n\tWidthOptions as StringWidthOptions,\n\tTruncationOptions as StringWidthTruncationOptions,\n\tResult as TruncatedStringWidthResult,\n} from 'fast-string-truncated-width';\nimport getTruncatedStringWidth from 'fast-string-truncated-width';\nimport { CharCode } from './charCode.js';\n\nexport function capitalize(s: string): string {\n\treturn `${s[0].toLocaleUpperCase()}${s.slice(1)}`;\n}\n\nlet compareCollator: Intl.Collator | undefined;\nexport function compareIgnoreCase(a: string, b: string): 0 | -1 | 1 {\n\tcompareCollator ??= new Intl.Collator(undefined, { sensitivity: 'accent' });\n\n\tconst result = compareCollator.compare(a, b);\n\t// Intl.Collator.compare isn't guaranteed to always return 1 or -1 on all platforms so normalize it\n\treturn result === 0 ? 0 : result > 0 ? 1 : -1;\n}\n\n/**\n * Removes common leading whitespace from each line in a template string.\n * This allows you to write indented template strings but have them trimmed in the result.\n *\n * @param template The template string to dedent\n * @returns The dedented string\n *\n * @example\n * ```typescript\n * const str = dedent(`\n * Hello\n * World\n * Test\n * `);\n * // Result: \"Hello\\nWorld\\nTest\"\n * ```\n */\nexport function dedent(template: string): string {\n\tconst lines = template.split('\\n');\n\n\t// Remove leading and trailing empty lines\n\twhile (lines.length > 0 && lines[0].trim() === '') {\n\t\tlines.shift();\n\t}\n\twhile (lines.length > 0 && lines.at(-1)?.trim() === '') {\n\t\tlines.pop();\n\t}\n\n\tif (lines.length === 0) return '';\n\n\t// Find the minimum indentation (excluding empty lines)\n\tconst nonEmptyLines = lines.filter(line => line.trim() !== '');\n\tif (nonEmptyLines.length === 0) return '';\n\n\tconst minIndent = Math.min(\n\t\t...nonEmptyLines.map(line => {\n\t\t\tconst match = line.match(/^(\\s*)/);\n\t\t\treturn match ? match[1].length : 0;\n\t\t}),\n\t);\n\n\t// Remove the common indentation from all lines\n\treturn lines.map(line => line.slice(minIndent)).join('\\n');\n}\n\nexport function equalsIgnoreCase(a: string | null | undefined, b: string | null | undefined): boolean {\n\t// Treat `null` & `undefined` as equivalent\n\tif (a == null && b == null) return true;\n\tif (a == null || b == null) return false;\n\treturn compareIgnoreCase(a, b) === 0;\n}\n\nlet sortCollator: Intl.Collator | undefined;\nexport function sortCompare(x: string, y: string): number {\n\tsortCollator ??= new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' });\n\treturn sortCollator.compare(x, y);\n}\n\nexport function compareSubstring(\n\ta: string,\n\tb: string,\n\taStart: number = 0,\n\taEnd: number = a.length,\n\tbStart: number = 0,\n\tbEnd: number = b.length,\n): number {\n\tfor (; aStart < aEnd && bStart < bEnd; aStart++, bStart++) {\n\t\tconst codeA = a.charCodeAt(aStart);\n\t\tconst codeB = b.charCodeAt(bStart);\n\t\tif (codeA < codeB) {\n\t\t\treturn -1;\n\t\t} else if (codeA > codeB) {\n\t\t\treturn 1;\n\t\t}\n\t}\n\tconst aLen = aEnd - aStart;\n\tconst bLen = bEnd - bStart;\n\tif (aLen < bLen) {\n\t\treturn -1;\n\t} else if (aLen > bLen) {\n\t\treturn 1;\n\t}\n\treturn 0;\n}\n\nexport function compareSubstringIgnoreCase(\n\ta: string,\n\tb: string,\n\taStart: number = 0,\n\taEnd: number = a.length,\n\tbStart: number = 0,\n\tbEnd: number = b.length,\n): number {\n\tfor (; aStart < aEnd && bStart < bEnd; aStart++, bStart++) {\n\t\tconst codeA = a.charCodeAt(aStart);\n\t\tconst codeB = b.charCodeAt(bStart);\n\n\t\tif (codeA === codeB) {\n\t\t\t// equal\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst diff = codeA - codeB;\n\t\tif (diff === 32 && isUpperAsciiLetter(codeB)) {\n\t\t\t//codeB =[65-90] && codeA =[97-122]\n\t\t\tcontinue;\n\t\t} else if (diff === -32 && isUpperAsciiLetter(codeA)) {\n\t\t\t//codeB =[97-122] && codeA =[65-90]\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (isLowerAsciiLetter(codeA) && isLowerAsciiLetter(codeB)) {\n\t\t\t//\n\t\t\treturn diff;\n\t\t}\n\t\treturn compareSubstring(a.toLowerCase(), b.toLowerCase(), aStart, aEnd, bStart, bEnd);\n\t}\n\n\tconst aLen = aEnd - aStart;\n\tconst bLen = bEnd - bStart;\n\n\tif (aLen < bLen) {\n\t\treturn -1;\n\t} else if (aLen > bLen) {\n\t\treturn 1;\n\t}\n\n\treturn 0;\n}\n\nexport function countOccurrences(s: string, search: string): number {\n\tlet count = 0;\n\tlet position = 0;\n\n\twhile (true) {\n\t\tposition = s.indexOf(search, position);\n\t\tif (position === -1) break;\n\n\t\tcount++;\n\t\tposition += search.length;\n\t}\n\n\treturn count;\n}\n\nexport function encodeHtmlWeak(s: string): string;\nexport function encodeHtmlWeak(s: string | undefined): string | undefined;\nexport function encodeHtmlWeak(s: string | undefined): string | undefined {\n\treturn s?.replace(/[<>&\"]/g, c => {\n\t\tswitch (c) {\n\t\t\tcase '<':\n\t\t\t\treturn '<';\n\t\t\tcase '>':\n\t\t\t\treturn '>';\n\t\t\tcase '&':\n\t\t\t\treturn '&';\n\t\t\tcase '\"':\n\t\t\t\treturn '"';\n\t\t\tdefault:\n\t\t\t\treturn c;\n\t\t}\n\t});\n}\n\nexport function splitMessage(message?: string): { summary: string; body?: string } {\n\tif (!message) return { summary: '' };\n\n\tmessage = message.trim();\n\tconst index = message.indexOf('\\n');\n\tif (index < 0) return { summary: message };\n\n\treturn {\n\t\tsummary: message.substring(0, index),\n\t\tbody: message.substring(index + 1).trim(),\n\t};\n}\n\nexport function escapeRegex(s: string): string {\n\treturn s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, '\\\\$&');\n}\n\n/**\n * Distributes a value into one of 100 groups based on a hash of the value\n * @param value The value to distribute (e.g., machine ID)\n * @returns A number between 1-100 representing the distribution group\n */\nexport function getDistributionGroup(value: string): number {\n\t// Simple hash function\n\tlet hash = 0;\n\tfor (let i = 0; i < value.length; i++) {\n\t\thash = (hash << 5) - hash + value.charCodeAt(i);\n\t\thash = hash & hash; // Convert to 32-bit integer\n\t}\n\n\t// Convert hash to a number between 1-100\n\tconst group = Math.abs(hash % 100) + 1;\n\treturn group;\n}\n\nexport function getPossessiveForm(name: string): string {\n\treturn name.endsWith('s') ? `${name}'` : `${name}'s`;\n}\n\nconst defaultTruncationOptions: StringWidthTruncationOptions = {\n\tellipsisWidth: 0,\n\tlimit: 2 ** 30 - 1, // Max number that can be stored in V8's smis (small integers)\n};\n\nconst defaultWidthOptions: StringWidthOptions = {\n\tcontrolWidth: 0,\n\temojiWidth: 2,\n\tregularWidth: 1,\n\twideWidth: 2,\n};\n\nexport function getTruncatedWidth(s: string, limit: number, ellipsisWidth: number): TruncatedStringWidthResult {\n\tif (s == null || s.length === 0) {\n\t\treturn {\n\t\t\ttruncated: false,\n\t\t\tellipsed: false,\n\t\t\twidth: 0,\n\t\t\tindex: 0,\n\t\t};\n\t}\n\n\treturn getTruncatedStringWidth(s, { limit: limit, ellipsisWidth: ellipsisWidth ?? 0 }, defaultWidthOptions);\n}\n\nexport function getWidth(s: string): number {\n\tif (s == null || s.length === 0) return 0;\n\n\tconst result = getTruncatedStringWidth(s, defaultTruncationOptions, defaultWidthOptions);\n\treturn result.width;\n}\n\nconst superscripts = ['\\u00B9', '\\u00B2', '\\u00B3', '\\u2074', '\\u2075', '\\u2076', '\\u2077', '\\u2078', '\\u2079'];\n\nexport function getSuperscript(num: number): string {\n\treturn superscripts[num - 1] ?? '';\n}\n\nconst tokenRegex = /\\$\\{(?:'(.*?[^\\\\])'|(\\W*))?([^|]*?)(?:\\|(\\d+)(-|\\?)?)?(?:'(.*?[^\\\\])'|(\\W*))?\\}/g;\nconst tokenSanitizeRegex = /\\$\\{(?:'.*?[^\\\\]'|\\W*)?(\\w*?)(?:'.*?[^\\\\]'|[\\W\\d]*)\\}/g;\nconst tokenGroupCharacter = \"'\";\nconst tokenGroupCharacterEscapedRegex = /(\\\\')/g;\n\ninterface TokenMatch {\n\tkey: string;\n\tstart: number;\n\tend: number;\n\toptions: TokenOptions;\n}\nconst templateTokenMap = new Map<string, TokenMatch[]>();\n\nexport interface TokenOptions {\n\tcollapseWhitespace: boolean;\n\tpadDirection: 'left' | 'right';\n\tprefix: string | undefined;\n\tsuffix: string | undefined;\n\ttruncateTo: number | undefined;\n}\n\nfunction isWordChar(code: number): boolean {\n\treturn (\n\t\tcode === 95 /* _ */ ||\n\t\t(code >= 0x61 && code <= 0x7a) || // lowercase letters\n\t\t(code >= 0x41 && code <= 0x5a) || // uppercase letters\n\t\t(code >= 0x30 && code <= 0x39) // digits\n\t);\n}\n\nexport function getTokensFromTemplate(template: string): TokenMatch[] {\n\tlet tokens = templateTokenMap.get(template);\n\tif (tokens != null) return tokens;\n\n\ttokens = [];\n\tconst length = template.length;\n\n\tlet position = 0;\n\twhile (position < length) {\n\t\tconst tokenStart = template.indexOf('${', position);\n\t\tif (tokenStart === -1) break;\n\n\t\tconst tokenEnd = template.indexOf('}', tokenStart);\n\t\tif (tokenEnd === -1) break;\n\n\t\tlet tokenPos = tokenStart + 2;\n\n\t\tlet key = '';\n\t\tlet prefix = '';\n\t\tlet truncateTo = '';\n\t\tlet collapseWhitespace = false;\n\t\tlet padDirection: 'left' | 'right' = 'right';\n\t\tlet suffix = '';\n\n\t\tif (template[tokenPos] === \"'\") {\n\t\t\tconst start = ++tokenPos;\n\t\t\ttokenPos = template.indexOf(\"'\", tokenPos);\n\t\t\tif (tokenPos === -1) break;\n\n\t\t\tif (start !== tokenPos) {\n\t\t\t\tprefix = template.slice(start, tokenPos);\n\t\t\t}\n\t\t\ttokenPos++;\n\t\t} else if (!isWordChar(template.charCodeAt(tokenPos))) {\n\t\t\tconst start = tokenPos++;\n\t\t\twhile (tokenPos < tokenEnd && !isWordChar(template.charCodeAt(tokenPos))) {\n\t\t\t\ttokenPos++;\n\t\t\t}\n\n\t\t\tif (start !== tokenPos) {\n\t\t\t\tprefix = template.slice(start, tokenPos);\n\t\t\t}\n\t\t}\n\n\t\twhile (tokenPos < tokenEnd) {\n\t\t\tlet code = template.charCodeAt(tokenPos);\n\t\t\tif (isWordChar(code)) {\n\t\t\t\tkey += template[tokenPos++];\n\t\t\t} else {\n\t\t\t\tif (code !== 0x7c /* | */) break;\n\n\t\t\t\twhile (tokenPos < tokenEnd) {\n\t\t\t\t\tcode = template.charCodeAt(++tokenPos);\n\t\t\t\t\tif (code >= 0x30 && code <= 0x39 /* digits */) {\n\t\t\t\t\t\ttruncateTo += template[tokenPos];\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (code === 0x3f /* ? */) {\n\t\t\t\t\t\tcollapseWhitespace = true;\n\t\t\t\t\t\ttokenPos++;\n\t\t\t\t\t} else if (code === 0x2d /* - */) {\n\t\t\t\t\t\tpadDirection = 'left';\n\t\t\t\t\t\ttokenPos++;\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (tokenPos < tokenEnd) {\n\t\t\tif (template[tokenPos] === \"'\") {\n\t\t\t\tconst start = ++tokenPos;\n\t\t\t\ttokenPos = template.indexOf(\"'\", tokenPos);\n\t\t\t\tif (tokenPos === -1) break;\n\n\t\t\t\tif (start !== tokenPos) {\n\t\t\t\t\tsuffix = template.slice(start, tokenPos);\n\t\t\t\t}\n\t\t\t} else if (!isWordChar(template.charCodeAt(tokenPos))) {\n\t\t\t\tconst start = tokenPos++;\n\t\t\t\twhile (tokenPos < tokenEnd && !isWordChar(template.charCodeAt(tokenPos))) {\n\t\t\t\t\ttokenPos++;\n\t\t\t\t}\n\n\t\t\t\tif (start !== tokenPos) {\n\t\t\t\t\tsuffix = template.slice(start, tokenPos);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tposition = tokenEnd + 1;\n\t\ttokens.push({\n\t\t\tkey: key,\n\t\t\tstart: tokenStart,\n\t\t\tend: position,\n\t\t\toptions: {\n\t\t\t\tprefix: prefix || undefined,\n\t\t\t\tsuffix: suffix || undefined,\n\t\t\t\ttruncateTo: truncateTo ? parseInt(truncateTo, 10) : undefined,\n\t\t\t\tcollapseWhitespace: collapseWhitespace,\n\t\t\t\tpadDirection: padDirection,\n\t\t\t},\n\t\t});\n\t}\n\n\ttemplateTokenMap.set(template, tokens);\n\treturn tokens;\n}\n\n// FYI, this is about twice as slow as getTokensFromTemplate\nexport function getTokensFromTemplateRegex(template: string): TokenMatch[] {\n\tlet tokens = templateTokenMap.get(template);\n\tif (tokens != null) return tokens;\n\n\ttokens = [];\n\n\tlet match;\n\twhile ((match = tokenRegex.exec(template))) {\n\t\tconst [, prefixGroup, prefixNonGroup, key, truncateTo, option, suffixGroup, suffixNonGroup] = match;\n\t\tconst start = match.index;\n\t\tconst end = start + match[0].length;\n\n\t\tlet prefix = prefixGroup || prefixNonGroup || undefined;\n\t\tif (prefix) {\n\t\t\tprefix = prefix.replace(tokenGroupCharacterEscapedRegex, tokenGroupCharacter);\n\t\t}\n\n\t\tlet suffix = suffixGroup || suffixNonGroup || undefined;\n\t\tif (suffix) {\n\t\t\tsuffix = suffix.replace(tokenGroupCharacterEscapedRegex, tokenGroupCharacter);\n\t\t}\n\n\t\ttokens.push({\n\t\t\tkey: key,\n\t\t\tstart: start,\n\t\t\tend: end,\n\t\t\toptions: {\n\t\t\t\tcollapseWhitespace: option === '?',\n\t\t\t\tpadDirection: option === '-' ? 'left' : 'right',\n\t\t\t\tprefix: prefix,\n\t\t\t\tsuffix: suffix,\n\t\t\t\ttruncateTo: truncateTo == null ? undefined : parseInt(truncateTo, 10),\n\t\t\t},\n\t\t});\n\t}\n\n\ttemplateTokenMap.set(template, tokens);\n\treturn tokens;\n}\n\n/**\n * Above this size, a source string split via {@link iterateByDelimiter} has its yielded records\n * flattened (see {@link flattenString}) — below it, the parent-pinning cost of sliced strings is\n * bounded and not worth the copy.\n */\nconst maxDelimiterSourceLength = 128 * 1024;\n\n/**\n * Forces V8 to create a flat copy of `s`, breaking any sliced-string reference to a parent string.\n *\n * V8 represents `substring()` results of 13+ characters as SlicedString views that retain their\n * entire parent string. A single retained field parsed out of a large buffer (e.g. a git walk's\n * full stdout) can therefore keep megabytes alive for as long as that field survives. Flattening\n * copies only the view's own characters, releasing the parent.\n *\n * No-op for strings shorter than `minLength`, where pinning is bounded anyway and the copy isn't\n * worth the allocation.\n */\nexport function flattenString(s: string, minLength = 1024): string {\n\tif (s.length < minLength) return s;\n\n\t// Concatenating a prefix then slicing it off forces V8 to materialize a flat copy of `s` —\n\t// deliberately not a template literal, which V8 can represent as another cons/sliced view.\n\t// oxlint-disable-next-line prefer-template\n\treturn (' ' + s).slice(1);\n}\n\n/**\n * Fast string delimiter iterator\n * Optimized for simple string splitting without generator overhead\n */\nclass StringDelimiterIterator implements IterableIterator<string> {\n\tprivate readonly delimiterLen: number;\n\tprivate readonly flatten: boolean;\n\tprivate index = 0;\n\tprivate done = false;\n\n\tconstructor(\n\t\tprivate readonly data: string,\n\t\tprivate readonly delimiter: string,\n\t) {\n\t\tthis.delimiterLen = delimiter.length;\n\t\t// Yielded substrings are V8 SlicedStrings that retain their parent; when splitting a large\n\t\t// buffer (e.g. a git walk's full stdout) that parent pinning keeps megabytes alive for as\n\t\t// long as any single parsed field survives. Above this threshold, flatten each yielded\n\t\t// record so it only holds its own characters.\n\t\tthis.flatten = data.length > maxDelimiterSourceLength;\n\t}\n\n\tnext(): IteratorResult<string> {\n\t\tif (this.done || this.index >= this.data.length) {\n\t\t\tthis.done = true;\n\t\t\treturn { done: true, value: undefined };\n\t\t}\n\n\t\tconst j = this.data.indexOf(this.delimiter, this.index);\n\t\tconst endIndex = j === -1 ? this.data.length : j;\n\n\t\t// Always flatten here: even a small record pins the entire (potentially huge) parent buffer\n\t\t// through its sliced string, so the minLength guard in flattenString must not apply.\n\t\tconst value = this.flatten\n\t\t\t? flattenString(this.data.substring(this.index, endIndex), 1)\n\t\t\t: this.data.substring(this.index, endIndex);\n\t\tthis.index = endIndex + this.delimiterLen;\n\n\t\treturn { done: false, value: value };\n\t}\n\n\t[Symbol.iterator](): IterableIterator<string> {\n\t\treturn this;\n\t}\n}\n\n/**\n * Iterable delimiter iterator with buffering\n * Handles streaming data by buffering incomplete segments\n */\nclass IterableDelimiterIterator implements IterableIterator<string> {\n\tprivate readonly delimiterLen: number;\n\tprivate readonly iterator: Iterator<string>;\n\tprivate readonly isArray: boolean;\n\tprivate readonly arrayLength: number;\n\n\tprivate arrayCount = 0;\n\tprivate buffer = '';\n\tprivate bufferIndex = 0;\n\tprivate needsMoreData = true;\n\tprivate done = false;\n\n\tconstructor(\n\t\tdata: Iterable<string>,\n\t\tprivate readonly delimiter: string,\n\t) {\n\t\tthis.delimiterLen = delimiter.length;\n\t\tthis.isArray = Array.isArray(data);\n\t\tthis.arrayLength = this.isArray ? (data as string[]).length : 0;\n\t\tthis.iterator = data[Symbol.iterator]();\n\t}\n\n\tnext(): IteratorResult<string> {\n\t\tif (this.done) {\n\t\t\treturn { done: true, value: undefined };\n\t\t}\n\n\t\twhile (true) {\n\t\t\t// Try to find delimiter in current buffer\n\t\t\tif (this.bufferIndex < this.buffer.length) {\n\t\t\t\tconst j = this.buffer.indexOf(this.delimiter, this.bufferIndex);\n\n\t\t\t\tif (j !== -1) {\n\t\t\t\t\t// Found delimiter - return the segment\n\t\t\t\t\tconst value = this.buffer.substring(this.bufferIndex, j);\n\t\t\t\t\tthis.bufferIndex = j + this.delimiterLen;\n\t\t\t\t\treturn { done: false, value: value };\n\t\t\t\t}\n\n\t\t\t\t// No delimiter found in buffer\n\t\t\t\tif (!this.needsMoreData) {\n\t\t\t\t\t// No more data coming - yield rest of buffer\n\t\t\t\t\tif (this.bufferIndex < this.buffer.length) {\n\t\t\t\t\t\tconst value = this.buffer.substring(this.bufferIndex);\n\t\t\t\t\t\tthis.bufferIndex = this.buffer.length;\n\t\t\t\t\t\tthis.done = true;\n\t\t\t\t\t\treturn { done: false, value: value };\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.done = true;\n\t\t\t\t\treturn { done: true, value: undefined };\n\t\t\t\t}\n\n\t\t\t\t// Need more data - keep unprocessed part as leftover\n\t\t\t\tif (this.bufferIndex > 0) {\n\t\t\t\t\tthis.buffer = this.buffer.substring(this.bufferIndex);\n\t\t\t\t\tthis.bufferIndex = 0;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Fetch next chunk if needed\n\t\t\tif (this.needsMoreData) {\n\t\t\t\tconst result = this.iterator.next();\n\n\t\t\t\tif (result.done) {\n\t\t\t\t\tthis.needsMoreData = false;\n\n\t\t\t\t\t// Yield any remaining buffer content\n\t\t\t\t\tif (this.buffer.length > 0) {\n\t\t\t\t\t\tconst value = this.buffer;\n\t\t\t\t\t\tthis.buffer = '';\n\t\t\t\t\t\tthis.done = true;\n\t\t\t\t\t\treturn { done: false, value: value };\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.done = true;\n\t\t\t\t\treturn { done: true, value: undefined };\n\t\t\t\t}\n\n\t\t\t\t// Track array iteration\n\t\t\t\tif (this.isArray) {\n\t\t\t\t\tthis.arrayCount++;\n\t\t\t\t\tif (this.arrayCount === this.arrayLength) {\n\t\t\t\t\t\tthis.needsMoreData = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Append chunk to buffer\n\t\t\t\tthis.buffer += result.value;\n\t\t\t} else {\n\t\t\t\t// No more data and buffer is empty\n\t\t\t\tthis.done = true;\n\t\t\t\treturn { done: true, value: undefined };\n\t\t\t}\n\t\t}\n\t}\n\n\t[Symbol.iterator](): IterableIterator<string> {\n\t\treturn this;\n\t}\n}\n\n/**\n * Iterate over a string or iterable by delimiter without using generators\n * More performant than generator version while maintaining lazy evaluation\n */\nexport function iterateByDelimiter(data: string | Iterable<string>, delimiter: string): IterableIterator<string> {\n\tif (typeof data === 'string') {\n\t\treturn new StringDelimiterIterator(data, delimiter);\n\t}\n\treturn new IterableDelimiterIterator(data, delimiter);\n}\n\n/**\n * Async iterable delimiter iterator with buffering.\n *\n * Buffer strategy: instead of growing a single buffer via concatenation\n * (which causes V8 SlicedString retention — yielded substrings hold\n * references to the entire accumulated buffer, preventing GC), each chunk\n * builds a fresh `remainder + chunk` string. Substrings of this bounded\n * string only retain the current chunk, not the full stream history.\n */\nclass AsyncIterableDelimiterIterator implements AsyncIterableIterator<string> {\n\tprivate readonly delimiterLen: number;\n\tprivate readonly iterator: AsyncIterator<string>;\n\n\tprivate remainder = '';\n\tprivate buffer = '';\n\tprivate searchIndex = 0;\n\tprivate done = false;\n\n\tconstructor(\n\t\tdata: AsyncIterable<string>,\n\t\tprivate readonly delimiter: string,\n\t) {\n\t\tthis.delimiterLen = delimiter.length;\n\t\tthis.iterator = data[Symbol.asyncIterator]();\n\t}\n\n\tasync next(): Promise<IteratorResult<string>> {\n\t\tif (this.done) {\n\t\t\treturn { done: true, value: undefined };\n\t\t}\n\n\t\twhile (true) {\n\t\t\t// Try to find delimiter in current buffer\n\t\t\tconst j = this.buffer.indexOf(this.delimiter, this.searchIndex);\n\t\t\tif (j !== -1) {\n\t\t\t\tconst value = this.buffer.substring(this.searchIndex, j);\n\t\t\t\tthis.searchIndex = j + this.delimiterLen;\n\t\t\t\treturn { done: false, value: value };\n\t\t\t}\n\n\t\t\t// No delimiter — fetch next chunk\n\t\t\tconst result = await this.iterator.next();\n\t\t\tif (result.done) {\n\t\t\t\t// No more data — yield any remaining content\n\t\t\t\tif (this.searchIndex < this.buffer.length) {\n\t\t\t\t\tconst value = this.buffer.substring(this.searchIndex);\n\t\t\t\t\tthis.done = true;\n\t\t\t\t\treturn { done: false, value: value };\n\t\t\t\t}\n\n\t\t\t\tthis.done = true;\n\t\t\t\treturn { done: true, value: undefined };\n\t\t\t}\n\n\t\t\t// Build a fresh buffer from leftover + new chunk so that\n\t\t\t// substrings only retain this bounded string, not a growing chain\n\t\t\tthis.remainder = this.searchIndex < this.buffer.length ? this.buffer.substring(this.searchIndex) : '';\n\t\t\tthis.buffer = this.remainder + result.value;\n\t\t\tthis.searchIndex = 0;\n\t\t}\n\t}\n\n\t[Symbol.asyncIterator](): AsyncIterableIterator<string> {\n\t\treturn this;\n\t}\n}\n\n/**\n * Iterate over an async iterable by delimiter without using generators\n * More performant than generator version while maintaining lazy evaluation\n */\nexport function iterateAsyncByDelimiter(data: AsyncIterable<string>, delimiter: string): AsyncIterableIterator<string> {\n\treturn new AsyncIterableDelimiterIterator(data, delimiter);\n}\n\nexport function interpolate(template: string, context: object | undefined): string {\n\tif (template == null || template.length === 0) return template;\n\tif (context == null) return template.replace(tokenSanitizeRegex, '');\n\n\tconst tokens = getTokensFromTemplate(template);\n\tif (tokens.length === 0) return template;\n\n\tlet position = 0;\n\tlet result = '';\n\tfor (const token of tokens) {\n\t\tresult += template.slice(position, token.start) + ((context as Record<string, string>)[token.key] ?? '');\n\t\tposition = token.end;\n\t}\n\n\tif (position < template.length) {\n\t\tresult += template.slice(position);\n\t}\n\n\treturn result;\n}\n\nexport async function interpolateAsync(template: string, context: object | undefined): Promise<string> {\n\tif (template == null || template.length === 0) return template;\n\tif (context == null) return template.replace(tokenSanitizeRegex, '');\n\n\tconst tokens = getTokensFromTemplate(template);\n\tif (tokens.length === 0) return template;\n\n\tlet position = 0;\n\tlet result = '';\n\tlet value;\n\tfor (const token of tokens) {\n\t\tvalue = (context as Record<string, any>)[token.key];\n\t\tif (value != null && typeof value === 'object' && typeof value.then === 'function') {\n\t\t\tvalue = await value;\n\t\t}\n\n\t\t// oxlint-disable-next-line typescript/restrict-plus-operands\n\t\tresult += template.slice(position, token.start) + (value ?? '');\n\t\tposition = token.end;\n\t}\n\n\tif (position < template.length) {\n\t\tresult += template.slice(position);\n\t}\n\n\treturn result;\n}\n\nexport function isLowerAsciiLetter(code: number): boolean {\n\treturn code >= CharCode.a && code <= CharCode.z;\n}\n\nexport function isUpperAsciiLetter(code: number): boolean {\n\treturn code >= CharCode.A && code <= CharCode.Z;\n}\n\nexport function pad(s: string, before: number = 0, after: number = 0, padding: string = '\\u00a0'): string {\n\tif (before === 0 && after === 0) return s;\n\n\treturn `${before === 0 ? '' : padding.repeat(before)}${s}${after === 0 ? '' : padding.repeat(after)}`;\n}\n\nexport function padOrTruncateEnd(s: string, maxLength: number, fillString?: string): string {\n\tif (s.length === maxLength) return s;\n\tif (s.length > maxLength) return s.substring(0, maxLength);\n\treturn s.padEnd(maxLength, fillString);\n}\n\n// Removes \\ / : * ? \" < > | and C0 and C1 control codes\n// oxlint-disable-next-line no-control-regex\nconst illegalCharsForFSRegex = /[\\\\/:*?\"<>|\\x00-\\x1f\\x80-\\x9f]/g;\n\nexport function sanitizeForFileSystem(s: string, replacement: string = '_'): string {\n\tif (!s) return s;\n\treturn s.replace(illegalCharsForFSRegex, replacement);\n}\n\nexport function splitLast(s: string, splitter: string): string[] {\n\tconst index = s.lastIndexOf(splitter);\n\tif (index === -1) return [s];\n\n\treturn [s.substring(0, index), s.substring(index + splitter.length)];\n}\n\nexport function splitSingle(s: string, splitter: string): string[] {\n\tconst index = s.indexOf(splitter);\n\tif (index === -1) return [s];\n\n\tconst start = s.substring(0, index);\n\tconst rest = s.substring(index + splitter.length);\n\treturn rest != null ? [start, rest] : [start];\n}\n\nexport function truncate(s: string, truncateTo: number, ellipsis: string = '\\u2026', width?: number): string {\n\tif (!s) return s;\n\tif (truncateTo <= 1) return ellipsis;\n\n\twidth = width ?? getWidth(s);\n\tif (width <= truncateTo) return s;\n\tif (width === s.length) return `${s.substring(0, truncateTo - 1)}${ellipsis}`;\n\n\t// Skip ahead to start as far as we can by assuming all the double-width characters won't be truncated\n\tlet chars = Math.floor(truncateTo / (width / s.length));\n\tlet count = getWidth(s.substring(0, chars));\n\twhile (count < truncateTo) {\n\t\tcount += getWidth(s[chars++]);\n\t}\n\n\tif (count >= truncateTo) {\n\t\tchars--;\n\t}\n\n\treturn `${s.substring(0, chars)}${ellipsis}`;\n}\n\nexport function truncateLeft(s: string, truncateTo: number, ellipsis: string = '\\u2026', width?: number): string {\n\tif (!s) return s;\n\tif (truncateTo <= 1) return ellipsis;\n\n\twidth = width ?? getWidth(s);\n\tif (width <= truncateTo) return s;\n\tif (width === s.length) return `${ellipsis}${s.substring(width - truncateTo)}`;\n\n\t// Skip ahead to start as far as we can by assuming all the double-width characters won't be truncated\n\tlet chars = Math.floor(truncateTo / (width / s.length));\n\tlet count = getWidth(s.substring(0, chars));\n\twhile (count < truncateTo) {\n\t\tcount += getWidth(s[chars++]);\n\t}\n\n\tif (count >= truncateTo) {\n\t\tchars--;\n\t}\n\n\treturn `${ellipsis}${s.substring(s.length - chars)}`;\n}\n\nexport function truncateMiddle(s: string, truncateTo: number, ellipsis: string = '\\u2026'): string {\n\tif (!s) return s;\n\tif (truncateTo <= 1) return ellipsis;\n\n\tconst width = getWidth(s);\n\tif (width <= truncateTo) return s;\n\n\treturn `${s.slice(0, Math.floor(truncateTo / 2) - 1)}${ellipsis}${s.slice(width - Math.ceil(truncateTo / 2))}`;\n}\n\n// Below adapted from https://github.com/pieroxy/lz-string\n\n// Pre-computed from:\n// const base64ReverseMap = new Uint8Array(123);\n// const base64Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';\n// for (let i = 0; i < base64Chars.length; i++) {\n// \tbase64ReverseMap[base64Chars.charCodeAt(i)] = i;\n// }\n\nconst base64ReverseMap = new Uint8Array([\n\t0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n\t0, 0, 0, 0, 62, 0, 0, 0, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0, 0, 0, 64, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7,\n\t8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0, 0, 0, 0, 0, 26, 27, 28, 29, 30, 31, 32,\n\t33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,\n]);\n\nexport function decompressFromBase64LZString(input: string | undefined): string {\n\tif (input == null || input === '') return '';\n\n\tconst result = _decompressLZString(input, 32) ?? '';\n\treturn result;\n}\n\nfunction _decompressLZString(input: string, resetValue: number) {\n\tconst dictionary = new Array<string>(4096);\n\tdictionary[0] = '0';\n\tdictionary[1] = '1';\n\tdictionary[2] = '2';\n\n\tconst result: string[] = [];\n\tconst length = input.length;\n\n\tlet val = base64ReverseMap[input.charCodeAt(0)];\n\tlet position = resetValue;\n\tlet index = 1;\n\n\tfunction readBits(maxpower: number): number {\n\t\tlet bits = 0;\n\t\tlet power = 1;\n\t\tdo {\n\t\t\tbits |= Number((val & position) > 0) * power;\n\t\t\tpower <<= 1;\n\n\t\t\tposition >>= 1;\n\t\t\tif (position === 0) {\n\t\t\t\tposition = resetValue;\n\t\t\t\tval = base64ReverseMap[input.charCodeAt(index++)];\n\t\t\t}\n\t\t} while (power !== maxpower);\n\n\t\treturn bits;\n\t}\n\n\tlet c = readBits(4);\n\n\tswitch (c) {\n\t\tcase 0:\n\t\t\tc = readBits(256);\n\t\t\tbreak;\n\t\tcase 1:\n\t\t\tc = readBits(65536);\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\treturn '';\n\t}\n\n\tlet w = String.fromCharCode(c);\n\tdictionary[3] = w;\n\tresult.push(w);\n\n\tlet dictSize = 4;\n\tlet enlargeIn = 4;\n\tlet numBits = 3;\n\n\twhile (index <= length) {\n\t\tc = readBits(1 << numBits);\n\n\t\tswitch (c) {\n\t\t\tcase 0:\n\t\t\t\tc = readBits(256);\n\t\t\t\tdictionary[dictSize] = String.fromCharCode(c);\n\t\t\t\tc = dictSize++;\n\t\t\t\tenlargeIn--;\n\t\t\t\tbreak;\n\t\t\tcase 1:\n\t\t\t\tc = readBits(65536);\n\t\t\t\tdictionary[dictSize] = String.fromCharCode(c);\n\t\t\t\tc = dictSize++;\n\t\t\t\tenlargeIn--;\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\treturn result.join('');\n\t\t}\n\n\t\tif (enlargeIn === 0) {\n\t\t\tenlargeIn = 1 << numBits++;\n\t\t}\n\n\t\tlet entry = dictionary[c];\n\t\tif (entry === undefined) {\n\t\t\tif (c !== dictSize) return undefined;\n\n\t\t\tentry = w + w[0];\n\t\t}\n\n\t\tresult.push(entry);\n\t\tdictionary[dictSize++] = w + entry[0];\n\t\tenlargeIn--;\n\t\tw = entry;\n\n\t\tif (enlargeIn === 0) {\n\t\t\tenlargeIn = 1 << numBits++;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n"],"mappings":";;;AAQA,SAAgB,WAAW,GAAmB;CAC7C,OAAO,GAAG,EAAE,EAAE,CAAC,kBAAkB,IAAI,EAAE,MAAM,CAAC;AAC/C;AAEA,IAAI;AACJ,SAAgB,kBAAkB,GAAW,GAAuB;CACnE,oBAAoB,IAAI,KAAK,SAAS,KAAA,GAAW,EAAE,aAAa,SAAS,CAAC;CAE1E,MAAM,SAAS,gBAAgB,QAAQ,GAAG,CAAC;CAE3C,OAAO,WAAW,IAAI,IAAI,SAAS,IAAI,IAAI;AAC5C;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,OAAO,UAA0B;CAChD,MAAM,QAAQ,SAAS,MAAM,IAAI;CAGjC,OAAO,MAAM,SAAS,KAAK,MAAM,EAAE,CAAC,KAAK,MAAM,IAC9C,MAAM,MAAM;CAEb,OAAO,MAAM,SAAS,KAAK,MAAM,GAAG,EAAE,CAAC,EAAE,KAAK,MAAM,IACnD,MAAM,IAAI;CAGX,IAAI,MAAM,WAAW,GAAG,OAAO;CAG/B,MAAM,gBAAgB,MAAM,QAAO,SAAQ,KAAK,KAAK,MAAM,EAAE;CAC7D,IA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ACF,QAAQ,QAAQ,MAAM,YAAY,CAAC,IAAI;GACvC,UAAU;GAEV,aAAa;GACb,IAAI,aAAa,GAAG;IACnB,WAAW;IACX,MAAM,iBAAiB,MAAM,WAAW,OAAO;GAChD;EACD,SAAS,UAAU;EAEnB,OAAO;CACR;CAEA,IAAI,IAAI,SAAS,CAAC;CAElB,QAAQ,GAAR;EACC,KAAK;GACJ,IAAI,SAAS,GAAG;GAChB;EACD,KAAK;GACJ,IAAI,SAAS,KAAK;GAClB;EACD,KAAK,GACJ,OAAO;CACT;CAEA,IAAI,IAAI,OAAO,aAAa,CAAC;CAC7B,WAAW,KAAK;CAChB,OAAO,KAAK,CAAC;CAEb,IAAI,WAAW;CACf,IAAI,YAAY;CAChB,IAAI,UAAU;CAEd,OAAO,SAAS,QAAQ;EACvB,IAAI,SAAS,KAAK,OAAO;EAEzB,QAAQ,GAAR;GACC,KAAK;IACJ,IAAI,SAAS,GAAG;IAChB,WAAW,YAAY,OAAO,aAAa,CAAC;IAC5C,IAAI;IACJ;IACA;GACD,KAAK;IACJ,IAAI,SAAS,KAAK;IAClB,WAAW,YAAY,OAAO,aAAa,CAAC;IAC5C,IAAI;IACJ;IACA;GACD,KAAK,GACJ,OAAO,OAAO,KAAK,EAAE;EACvB;EAEA,IAAI,cAAc,GACjB,YAAY,KAAK;EAGlB,IAAI,QAAQ,WAAW;EACvB,IAAI,UAAU,KAAA,GAAW;GACxB,IAAI,MAAM,UAAU,OAAO,KAAA;GAE3B,QAAQ,IAAI,EAAE;EACf;EAEA,OAAO,KAAK,KAAK;EACjB,WAAW,cAAc,IAAI,MAAM;EACnC;EACA,IAAI;EAEJ,IAAI,cAAc,GACjB,YAAY,KAAK;CAEnB;AAGD"}
|
|
1
|
+
{"version":3,"file":"string.js","names":[],"sources":["../../../utils/src/string.ts"],"sourcesContent":["import type {\n\tWidthOptions as StringWidthOptions,\n\tTruncationOptions as StringWidthTruncationOptions,\n\tResult as TruncatedStringWidthResult,\n} from 'fast-string-truncated-width';\nimport getTruncatedStringWidth from 'fast-string-truncated-width';\nimport { CharCode } from './charCode.js';\n\nexport function capitalize(s: string): string {\n\treturn `${s[0].toLocaleUpperCase()}${s.slice(1)}`;\n}\n\nlet compareCollator: Intl.Collator | undefined;\nexport function compareIgnoreCase(a: string, b: string): 0 | -1 | 1 {\n\tcompareCollator ??= new Intl.Collator(undefined, { sensitivity: 'accent' });\n\n\tconst result = compareCollator.compare(a, b);\n\t// Intl.Collator.compare isn't guaranteed to always return 1 or -1 on all platforms so normalize it\n\treturn result === 0 ? 0 : result > 0 ? 1 : -1;\n}\n\n/**\n * Removes common leading whitespace from each line in a template string.\n * This allows you to write indented template strings but have them trimmed in the result.\n *\n * @param template The template string to dedent\n * @returns The dedented string\n *\n * @example\n * ```typescript\n * const str = dedent(`\n * Hello\n * World\n * Test\n * `);\n * // Result: \"Hello\\nWorld\\nTest\"\n * ```\n */\nexport function dedent(template: string): string {\n\tconst lines = template.split('\\n');\n\n\t// Remove leading and trailing empty lines\n\twhile (lines.length > 0 && lines[0].trim() === '') {\n\t\tlines.shift();\n\t}\n\twhile (lines.length > 0 && lines.at(-1)?.trim() === '') {\n\t\tlines.pop();\n\t}\n\n\tif (lines.length === 0) return '';\n\n\t// Find the minimum indentation (excluding empty lines)\n\tconst nonEmptyLines = lines.filter(line => line.trim() !== '');\n\tif (nonEmptyLines.length === 0) return '';\n\n\tconst minIndent = Math.min(\n\t\t...nonEmptyLines.map(line => {\n\t\t\tconst match = line.match(/^(\\s*)/);\n\t\t\treturn match ? match[1].length : 0;\n\t\t}),\n\t);\n\n\t// Remove the common indentation from all lines\n\treturn lines.map(line => line.slice(minIndent)).join('\\n');\n}\n\nexport function equalsIgnoreCase(a: string | null | undefined, b: string | null | undefined): boolean {\n\t// Treat `null` & `undefined` as equivalent\n\tif (a == null && b == null) return true;\n\tif (a == null || b == null) return false;\n\treturn compareIgnoreCase(a, b) === 0;\n}\n\nlet sortCollator: Intl.Collator | undefined;\nexport function sortCompare(x: string, y: string): number {\n\tsortCollator ??= new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' });\n\treturn sortCollator.compare(x, y);\n}\n\nexport function compareSubstring(\n\ta: string,\n\tb: string,\n\taStart: number = 0,\n\taEnd: number = a.length,\n\tbStart: number = 0,\n\tbEnd: number = b.length,\n): number {\n\tfor (; aStart < aEnd && bStart < bEnd; aStart++, bStart++) {\n\t\tconst codeA = a.charCodeAt(aStart);\n\t\tconst codeB = b.charCodeAt(bStart);\n\t\tif (codeA < codeB) {\n\t\t\treturn -1;\n\t\t} else if (codeA > codeB) {\n\t\t\treturn 1;\n\t\t}\n\t}\n\tconst aLen = aEnd - aStart;\n\tconst bLen = bEnd - bStart;\n\tif (aLen < bLen) {\n\t\treturn -1;\n\t} else if (aLen > bLen) {\n\t\treturn 1;\n\t}\n\treturn 0;\n}\n\nexport function compareSubstringIgnoreCase(\n\ta: string,\n\tb: string,\n\taStart: number = 0,\n\taEnd: number = a.length,\n\tbStart: number = 0,\n\tbEnd: number = b.length,\n): number {\n\tfor (; aStart < aEnd && bStart < bEnd; aStart++, bStart++) {\n\t\tconst codeA = a.charCodeAt(aStart);\n\t\tconst codeB = b.charCodeAt(bStart);\n\n\t\tif (codeA === codeB) {\n\t\t\t// equal\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst diff = codeA - codeB;\n\t\tif (diff === 32 && isUpperAsciiLetter(codeB)) {\n\t\t\t//codeB =[65-90] && codeA =[97-122]\n\t\t\tcontinue;\n\t\t} else if (diff === -32 && isUpperAsciiLetter(codeA)) {\n\t\t\t//codeB =[97-122] && codeA =[65-90]\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (isLowerAsciiLetter(codeA) && isLowerAsciiLetter(codeB)) {\n\t\t\t//\n\t\t\treturn diff;\n\t\t}\n\t\treturn compareSubstring(a.toLowerCase(), b.toLowerCase(), aStart, aEnd, bStart, bEnd);\n\t}\n\n\tconst aLen = aEnd - aStart;\n\tconst bLen = bEnd - bStart;\n\n\tif (aLen < bLen) {\n\t\treturn -1;\n\t} else if (aLen > bLen) {\n\t\treturn 1;\n\t}\n\n\treturn 0;\n}\n\nexport function countOccurrences(s: string, search: string): number {\n\tlet count = 0;\n\tlet position = 0;\n\n\twhile (true) {\n\t\tposition = s.indexOf(search, position);\n\t\tif (position === -1) break;\n\n\t\tcount++;\n\t\tposition += search.length;\n\t}\n\n\treturn count;\n}\n\nexport function encodeHtmlWeak(s: string): string;\nexport function encodeHtmlWeak(s: string | undefined): string | undefined;\nexport function encodeHtmlWeak(s: string | undefined): string | undefined {\n\treturn s?.replace(/[<>&\"]/g, c => {\n\t\tswitch (c) {\n\t\t\tcase '<':\n\t\t\t\treturn '<';\n\t\t\tcase '>':\n\t\t\t\treturn '>';\n\t\t\tcase '&':\n\t\t\t\treturn '&';\n\t\t\tcase '\"':\n\t\t\t\treturn '"';\n\t\t\tdefault:\n\t\t\t\treturn c;\n\t\t}\n\t});\n}\n\nexport function splitMessage(message?: string): { summary: string; body?: string } {\n\tif (!message) return { summary: '' };\n\n\tmessage = message.trim();\n\tconst index = message.indexOf('\\n');\n\tif (index < 0) return { summary: message };\n\n\treturn {\n\t\tsummary: message.substring(0, index),\n\t\tbody: message.substring(index + 1).trim(),\n\t};\n}\n\nexport function escapeRegex(s: string): string {\n\treturn s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, '\\\\$&');\n}\n\n/**\n * Distributes a value into one of 100 groups based on a hash of the value\n * @param value The value to distribute (e.g., machine ID)\n * @returns A number between 1-100 representing the distribution group\n */\nexport function getDistributionGroup(value: string): number {\n\t// Simple hash function\n\tlet hash = 0;\n\tfor (let i = 0; i < value.length; i++) {\n\t\thash = (hash << 5) - hash + value.charCodeAt(i);\n\t\thash = hash & hash; // Convert to 32-bit integer\n\t}\n\n\t// Convert hash to a number between 1-100\n\tconst group = Math.abs(hash % 100) + 1;\n\treturn group;\n}\n\nexport function getPossessiveForm(name: string): string {\n\treturn name.endsWith('s') ? `${name}'` : `${name}'s`;\n}\n\nconst defaultTruncationOptions: StringWidthTruncationOptions = {\n\tellipsisWidth: 0,\n\tlimit: 2 ** 30 - 1, // Max number that can be stored in V8's smis (small integers)\n};\n\nconst defaultWidthOptions: StringWidthOptions = {\n\tcontrolWidth: 0,\n\temojiWidth: 2,\n\tregularWidth: 1,\n\twideWidth: 2,\n};\n\nexport function getTruncatedWidth(s: string, limit: number, ellipsisWidth: number): TruncatedStringWidthResult {\n\tif (s == null || s.length === 0) {\n\t\treturn {\n\t\t\ttruncated: false,\n\t\t\tellipsed: false,\n\t\t\twidth: 0,\n\t\t\tindex: 0,\n\t\t};\n\t}\n\n\treturn getTruncatedStringWidth(s, { limit: limit, ellipsisWidth: ellipsisWidth ?? 0 }, defaultWidthOptions);\n}\n\nexport function getWidth(s: string): number {\n\tif (s == null || s.length === 0) return 0;\n\n\tconst result = getTruncatedStringWidth(s, defaultTruncationOptions, defaultWidthOptions);\n\treturn result.width;\n}\n\nconst superscripts = ['\\u00B9', '\\u00B2', '\\u00B3', '\\u2074', '\\u2075', '\\u2076', '\\u2077', '\\u2078', '\\u2079'];\n\nexport function getSuperscript(num: number): string {\n\treturn superscripts[num - 1] ?? '';\n}\n\nconst tokenRegex = /\\$\\{(?:'(.*?[^\\\\])'|(\\W*))?([^|]*?)(?:\\|(\\d+)(-|\\?)?)?(?:'(.*?[^\\\\])'|(\\W*))?\\}/g;\nconst tokenSanitizeRegex = /\\$\\{(?:'.*?[^\\\\]'|\\W*)?(\\w*?)(?:'.*?[^\\\\]'|[\\W\\d]*)\\}/g;\nconst tokenGroupCharacter = \"'\";\nconst tokenGroupCharacterEscapedRegex = /(\\\\')/g;\n\ninterface TokenMatch {\n\tkey: string;\n\tstart: number;\n\tend: number;\n\toptions: TokenOptions;\n}\nconst templateTokenMap = new Map<string, TokenMatch[]>();\n\nexport interface TokenOptions {\n\tcollapseWhitespace: boolean;\n\tpadDirection: 'left' | 'right';\n\tprefix: string | undefined;\n\tsuffix: string | undefined;\n\ttruncateTo: number | undefined;\n}\n\nfunction isWordChar(code: number): boolean {\n\treturn (\n\t\tcode === 95 /* _ */ ||\n\t\t(code >= 0x61 && code <= 0x7a) || // lowercase letters\n\t\t(code >= 0x41 && code <= 0x5a) || // uppercase letters\n\t\t(code >= 0x30 && code <= 0x39) // digits\n\t);\n}\n\nexport function getTokensFromTemplate(template: string): TokenMatch[] {\n\tlet tokens = templateTokenMap.get(template);\n\tif (tokens != null) return tokens;\n\n\ttokens = [];\n\tconst length = template.length;\n\n\tlet position = 0;\n\twhile (position < length) {\n\t\tconst tokenStart = template.indexOf('${', position);\n\t\tif (tokenStart === -1) break;\n\n\t\tconst tokenEnd = template.indexOf('}', tokenStart);\n\t\tif (tokenEnd === -1) break;\n\n\t\tlet tokenPos = tokenStart + 2;\n\n\t\tlet key = '';\n\t\tlet prefix = '';\n\t\tlet truncateTo = '';\n\t\tlet collapseWhitespace = false;\n\t\tlet padDirection: 'left' | 'right' = 'right';\n\t\tlet suffix = '';\n\n\t\tif (template[tokenPos] === \"'\") {\n\t\t\tconst start = ++tokenPos;\n\t\t\ttokenPos = template.indexOf(\"'\", tokenPos);\n\t\t\tif (tokenPos === -1) break;\n\n\t\t\tif (start !== tokenPos) {\n\t\t\t\tprefix = template.slice(start, tokenPos);\n\t\t\t}\n\t\t\ttokenPos++;\n\t\t} else if (!isWordChar(template.charCodeAt(tokenPos))) {\n\t\t\tconst start = tokenPos++;\n\t\t\twhile (tokenPos < tokenEnd && !isWordChar(template.charCodeAt(tokenPos))) {\n\t\t\t\ttokenPos++;\n\t\t\t}\n\n\t\t\tif (start !== tokenPos) {\n\t\t\t\tprefix = template.slice(start, tokenPos);\n\t\t\t}\n\t\t}\n\n\t\twhile (tokenPos < tokenEnd) {\n\t\t\tlet code = template.charCodeAt(tokenPos);\n\t\t\tif (isWordChar(code)) {\n\t\t\t\tkey += template[tokenPos++];\n\t\t\t} else {\n\t\t\t\tif (code !== 0x7c /* | */) break;\n\n\t\t\t\twhile (tokenPos < tokenEnd) {\n\t\t\t\t\tcode = template.charCodeAt(++tokenPos);\n\t\t\t\t\tif (code >= 0x30 && code <= 0x39 /* digits */) {\n\t\t\t\t\t\ttruncateTo += template[tokenPos];\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (code === 0x3f /* ? */) {\n\t\t\t\t\t\tcollapseWhitespace = true;\n\t\t\t\t\t\ttokenPos++;\n\t\t\t\t\t} else if (code === 0x2d /* - */) {\n\t\t\t\t\t\tpadDirection = 'left';\n\t\t\t\t\t\ttokenPos++;\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (tokenPos < tokenEnd) {\n\t\t\tif (template[tokenPos] === \"'\") {\n\t\t\t\tconst start = ++tokenPos;\n\t\t\t\ttokenPos = template.indexOf(\"'\", tokenPos);\n\t\t\t\tif (tokenPos === -1) break;\n\n\t\t\t\tif (start !== tokenPos) {\n\t\t\t\t\tsuffix = template.slice(start, tokenPos);\n\t\t\t\t}\n\t\t\t} else if (!isWordChar(template.charCodeAt(tokenPos))) {\n\t\t\t\tconst start = tokenPos++;\n\t\t\t\twhile (tokenPos < tokenEnd && !isWordChar(template.charCodeAt(tokenPos))) {\n\t\t\t\t\ttokenPos++;\n\t\t\t\t}\n\n\t\t\t\tif (start !== tokenPos) {\n\t\t\t\t\tsuffix = template.slice(start, tokenPos);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tposition = tokenEnd + 1;\n\t\ttokens.push({\n\t\t\tkey: key,\n\t\t\tstart: tokenStart,\n\t\t\tend: position,\n\t\t\toptions: {\n\t\t\t\tprefix: prefix || undefined,\n\t\t\t\tsuffix: suffix || undefined,\n\t\t\t\ttruncateTo: truncateTo ? parseInt(truncateTo, 10) : undefined,\n\t\t\t\tcollapseWhitespace: collapseWhitespace,\n\t\t\t\tpadDirection: padDirection,\n\t\t\t},\n\t\t});\n\t}\n\n\ttemplateTokenMap.set(template, tokens);\n\treturn tokens;\n}\n\n// FYI, this is about twice as slow as getTokensFromTemplate\nexport function getTokensFromTemplateRegex(template: string): TokenMatch[] {\n\tlet tokens = templateTokenMap.get(template);\n\tif (tokens != null) return tokens;\n\n\ttokens = [];\n\n\tlet match;\n\twhile ((match = tokenRegex.exec(template))) {\n\t\tconst [, prefixGroup, prefixNonGroup, key, truncateTo, option, suffixGroup, suffixNonGroup] = match;\n\t\tconst start = match.index;\n\t\tconst end = start + match[0].length;\n\n\t\tlet prefix = prefixGroup || prefixNonGroup || undefined;\n\t\tif (prefix) {\n\t\t\tprefix = prefix.replace(tokenGroupCharacterEscapedRegex, tokenGroupCharacter);\n\t\t}\n\n\t\tlet suffix = suffixGroup || suffixNonGroup || undefined;\n\t\tif (suffix) {\n\t\t\tsuffix = suffix.replace(tokenGroupCharacterEscapedRegex, tokenGroupCharacter);\n\t\t}\n\n\t\ttokens.push({\n\t\t\tkey: key,\n\t\t\tstart: start,\n\t\t\tend: end,\n\t\t\toptions: {\n\t\t\t\tcollapseWhitespace: option === '?',\n\t\t\t\tpadDirection: option === '-' ? 'left' : 'right',\n\t\t\t\tprefix: prefix,\n\t\t\t\tsuffix: suffix,\n\t\t\t\ttruncateTo: truncateTo == null ? undefined : parseInt(truncateTo, 10),\n\t\t\t},\n\t\t});\n\t}\n\n\ttemplateTokenMap.set(template, tokens);\n\treturn tokens;\n}\n\n/**\n * Above this size, a source string split via {@link iterateByDelimiter} has its yielded records\n * flattened (see {@link flattenString}) — below it, the parent-pinning cost of sliced strings is\n * bounded and not worth the copy.\n */\nconst maxDelimiterSourceLength = 128 * 1024;\n\n/**\n * Forces V8 to create a flat copy of `s`, breaking any sliced-string reference to a parent string.\n *\n * V8 represents `substring()` results of 13+ characters as SlicedString views that retain their\n * entire parent string. A single retained field parsed out of a large buffer (e.g. a git walk's\n * full stdout) can therefore keep megabytes alive for as long as that field survives. Flattening\n * copies only the view's own characters, releasing the parent.\n *\n * No-op for strings shorter than `minLength`, where pinning is bounded anyway and the copy isn't\n * worth the allocation.\n */\nexport function flattenString(s: string, minLength = 1024): string {\n\tif (s.length < minLength) return s;\n\n\t// Concatenating a prefix then slicing it off forces V8 to materialize a flat copy of `s` —\n\t// deliberately not a template literal, which V8 can represent as another cons/sliced view.\n\t// oxlint-disable-next-line prefer-template\n\treturn (' ' + s).slice(1);\n}\n\n/**\n * Fast string delimiter iterator\n * Optimized for simple string splitting without generator overhead\n */\nclass StringDelimiterIterator implements IterableIterator<string> {\n\tprivate readonly delimiterLen: number;\n\tprivate readonly flatten: boolean;\n\tprivate index = 0;\n\tprivate done = false;\n\n\tconstructor(\n\t\tprivate readonly data: string,\n\t\tprivate readonly delimiter: string,\n\t) {\n\t\tthis.delimiterLen = delimiter.length;\n\t\t// Yielded substrings are V8 SlicedStrings that retain their parent; when splitting a large\n\t\t// buffer (e.g. a git walk's full stdout) that parent pinning keeps megabytes alive for as\n\t\t// long as any single parsed field survives. Above this threshold, flatten each yielded\n\t\t// record so it only holds its own characters.\n\t\tthis.flatten = data.length > maxDelimiterSourceLength;\n\t}\n\n\tnext(): IteratorResult<string> {\n\t\tif (this.done || this.index >= this.data.length) {\n\t\t\tthis.done = true;\n\t\t\treturn { done: true, value: undefined };\n\t\t}\n\n\t\tconst j = this.data.indexOf(this.delimiter, this.index);\n\t\tconst endIndex = j === -1 ? this.data.length : j;\n\n\t\t// Always flatten here: even a small record pins the entire (potentially huge) parent buffer\n\t\t// through its sliced string, so the minLength guard in flattenString must not apply.\n\t\tconst value = this.flatten\n\t\t\t? flattenString(this.data.substring(this.index, endIndex), 1)\n\t\t\t: this.data.substring(this.index, endIndex);\n\t\tthis.index = endIndex + this.delimiterLen;\n\n\t\treturn { done: false, value: value };\n\t}\n\n\t[Symbol.iterator](): IterableIterator<string> {\n\t\treturn this;\n\t}\n}\n\n/**\n * Iterable delimiter iterator with buffering\n * Handles streaming data by buffering incomplete segments\n */\nclass IterableDelimiterIterator implements IterableIterator<string> {\n\tprivate readonly delimiterLen: number;\n\tprivate readonly iterator: Iterator<string>;\n\tprivate readonly isArray: boolean;\n\tprivate readonly arrayLength: number;\n\n\tprivate arrayCount = 0;\n\tprivate buffer = '';\n\tprivate bufferIndex = 0;\n\tprivate needsMoreData = true;\n\tprivate done = false;\n\n\tconstructor(\n\t\tdata: Iterable<string>,\n\t\tprivate readonly delimiter: string,\n\t) {\n\t\tthis.delimiterLen = delimiter.length;\n\t\tthis.isArray = Array.isArray(data);\n\t\tthis.arrayLength = this.isArray ? (data as string[]).length : 0;\n\t\tthis.iterator = data[Symbol.iterator]();\n\t}\n\n\tnext(): IteratorResult<string> {\n\t\tif (this.done) {\n\t\t\treturn { done: true, value: undefined };\n\t\t}\n\n\t\twhile (true) {\n\t\t\t// Try to find delimiter in current buffer\n\t\t\tif (this.bufferIndex < this.buffer.length) {\n\t\t\t\tconst j = this.buffer.indexOf(this.delimiter, this.bufferIndex);\n\n\t\t\t\tif (j !== -1) {\n\t\t\t\t\t// Found delimiter - return the segment\n\t\t\t\t\tconst value = this.buffer.substring(this.bufferIndex, j);\n\t\t\t\t\tthis.bufferIndex = j + this.delimiterLen;\n\t\t\t\t\treturn { done: false, value: value };\n\t\t\t\t}\n\n\t\t\t\t// No delimiter found in buffer\n\t\t\t\tif (!this.needsMoreData) {\n\t\t\t\t\t// No more data coming - yield rest of buffer\n\t\t\t\t\tif (this.bufferIndex < this.buffer.length) {\n\t\t\t\t\t\tconst value = this.buffer.substring(this.bufferIndex);\n\t\t\t\t\t\tthis.bufferIndex = this.buffer.length;\n\t\t\t\t\t\tthis.done = true;\n\t\t\t\t\t\treturn { done: false, value: value };\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.done = true;\n\t\t\t\t\treturn { done: true, value: undefined };\n\t\t\t\t}\n\n\t\t\t\t// Need more data - keep unprocessed part as leftover\n\t\t\t\tif (this.bufferIndex > 0) {\n\t\t\t\t\tthis.buffer = this.buffer.substring(this.bufferIndex);\n\t\t\t\t\tthis.bufferIndex = 0;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Fetch next chunk if needed\n\t\t\tif (this.needsMoreData) {\n\t\t\t\tconst result = this.iterator.next();\n\n\t\t\t\tif (result.done) {\n\t\t\t\t\tthis.needsMoreData = false;\n\n\t\t\t\t\t// Yield any remaining buffer content\n\t\t\t\t\tif (this.buffer.length > 0) {\n\t\t\t\t\t\tconst value = this.buffer;\n\t\t\t\t\t\tthis.buffer = '';\n\t\t\t\t\t\tthis.done = true;\n\t\t\t\t\t\treturn { done: false, value: value };\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.done = true;\n\t\t\t\t\treturn { done: true, value: undefined };\n\t\t\t\t}\n\n\t\t\t\t// Track array iteration\n\t\t\t\tif (this.isArray) {\n\t\t\t\t\tthis.arrayCount++;\n\t\t\t\t\tif (this.arrayCount === this.arrayLength) {\n\t\t\t\t\t\tthis.needsMoreData = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Append chunk to buffer\n\t\t\t\tthis.buffer += result.value;\n\t\t\t} else {\n\t\t\t\t// No more data and buffer is empty\n\t\t\t\tthis.done = true;\n\t\t\t\treturn { done: true, value: undefined };\n\t\t\t}\n\t\t}\n\t}\n\n\t[Symbol.iterator](): IterableIterator<string> {\n\t\treturn this;\n\t}\n}\n\n/**\n * Iterate over a string or iterable by delimiter without using generators\n * More performant than generator version while maintaining lazy evaluation\n */\nexport function iterateByDelimiter(data: string | Iterable<string>, delimiter: string): IterableIterator<string> {\n\tif (typeof data === 'string') {\n\t\treturn new StringDelimiterIterator(data, delimiter);\n\t}\n\treturn new IterableDelimiterIterator(data, delimiter);\n}\n\n/**\n * Async iterable delimiter iterator with buffering.\n *\n * Buffer strategy: instead of growing a single buffer via concatenation\n * (which causes V8 SlicedString retention — yielded substrings hold\n * references to the entire accumulated buffer, preventing GC), each chunk\n * builds a fresh `remainder + chunk` string. Substrings of this bounded\n * string only retain the current chunk, not the full stream history.\n */\nclass AsyncIterableDelimiterIterator implements AsyncIterableIterator<string> {\n\tprivate readonly delimiterLen: number;\n\tprivate readonly iterator: AsyncIterator<string>;\n\n\tprivate remainder = '';\n\tprivate buffer = '';\n\tprivate searchIndex = 0;\n\tprivate done = false;\n\n\tconstructor(\n\t\tdata: AsyncIterable<string>,\n\t\tprivate readonly delimiter: string,\n\t) {\n\t\tthis.delimiterLen = delimiter.length;\n\t\tthis.iterator = data[Symbol.asyncIterator]();\n\t}\n\n\tasync next(): Promise<IteratorResult<string>> {\n\t\tif (this.done) {\n\t\t\treturn { done: true, value: undefined };\n\t\t}\n\n\t\twhile (true) {\n\t\t\t// Try to find delimiter in current buffer\n\t\t\tconst j = this.buffer.indexOf(this.delimiter, this.searchIndex);\n\t\t\tif (j !== -1) {\n\t\t\t\tconst value = this.buffer.substring(this.searchIndex, j);\n\t\t\t\tthis.searchIndex = j + this.delimiterLen;\n\t\t\t\treturn { done: false, value: value };\n\t\t\t}\n\n\t\t\t// No delimiter — fetch next chunk\n\t\t\tconst result = await this.iterator.next();\n\t\t\tif (result.done) {\n\t\t\t\t// No more data — yield any remaining content\n\t\t\t\tif (this.searchIndex < this.buffer.length) {\n\t\t\t\t\tconst value = this.buffer.substring(this.searchIndex);\n\t\t\t\t\tthis.done = true;\n\t\t\t\t\treturn { done: false, value: value };\n\t\t\t\t}\n\n\t\t\t\tthis.done = true;\n\t\t\t\treturn { done: true, value: undefined };\n\t\t\t}\n\n\t\t\t// Build a fresh buffer from leftover + new chunk so that\n\t\t\t// substrings only retain this bounded string, not a growing chain\n\t\t\tthis.remainder = this.searchIndex < this.buffer.length ? this.buffer.substring(this.searchIndex) : '';\n\t\t\tthis.buffer = this.remainder + result.value;\n\t\t\tthis.searchIndex = 0;\n\t\t}\n\t}\n\n\t[Symbol.asyncIterator](): AsyncIterableIterator<string> {\n\t\treturn this;\n\t}\n}\n\n/**\n * Iterate over an async iterable by delimiter without using generators\n * More performant than generator version while maintaining lazy evaluation\n */\nexport function iterateAsyncByDelimiter(data: AsyncIterable<string>, delimiter: string): AsyncIterableIterator<string> {\n\treturn new AsyncIterableDelimiterIterator(data, delimiter);\n}\n\nexport function interpolate(template: string, context: object | undefined): string {\n\tif (template == null || template.length === 0) return template;\n\tif (context == null) return template.replace(tokenSanitizeRegex, '');\n\n\tconst tokens = getTokensFromTemplate(template);\n\tif (tokens.length === 0) return template;\n\n\tlet position = 0;\n\tlet result = '';\n\tfor (const token of tokens) {\n\t\tresult += template.slice(position, token.start) + ((context as Record<string, string>)[token.key] ?? '');\n\t\tposition = token.end;\n\t}\n\n\tif (position < template.length) {\n\t\tresult += template.slice(position);\n\t}\n\n\treturn result;\n}\n\nexport async function interpolateAsync(template: string, context: object | undefined): Promise<string> {\n\tif (template == null || template.length === 0) return template;\n\tif (context == null) return template.replace(tokenSanitizeRegex, '');\n\n\tconst tokens = getTokensFromTemplate(template);\n\tif (tokens.length === 0) return template;\n\n\tlet position = 0;\n\tlet result = '';\n\tlet value;\n\tfor (const token of tokens) {\n\t\tvalue = (context as Record<string, any>)[token.key];\n\t\tif (value != null && typeof value === 'object' && typeof value.then === 'function') {\n\t\t\tvalue = await value;\n\t\t}\n\n\t\t// oxlint-disable-next-line typescript/restrict-plus-operands\n\t\tresult += template.slice(position, token.start) + (value ?? '');\n\t\tposition = token.end;\n\t}\n\n\tif (position < template.length) {\n\t\tresult += template.slice(position);\n\t}\n\n\treturn result;\n}\n\nexport function isLowerAsciiLetter(code: number): boolean {\n\treturn code >= CharCode.a && code <= CharCode.z;\n}\n\nexport function isUpperAsciiLetter(code: number): boolean {\n\treturn code >= CharCode.A && code <= CharCode.Z;\n}\n\nexport function pad(s: string, before: number = 0, after: number = 0, padding: string = '\\u00a0'): string {\n\tif (before === 0 && after === 0) return s;\n\n\treturn `${before === 0 ? '' : padding.repeat(before)}${s}${after === 0 ? '' : padding.repeat(after)}`;\n}\n\nexport function padOrTruncateEnd(s: string, maxLength: number, fillString?: string): string {\n\tif (s.length === maxLength) return s;\n\tif (s.length > maxLength) return s.substring(0, maxLength);\n\treturn s.padEnd(maxLength, fillString);\n}\n\n// Removes \\ / : * ? \" < > | and C0 and C1 control codes\n// oxlint-disable-next-line no-control-regex\nconst illegalCharsForFSRegex = /[\\\\/:*?\"<>|\\x00-\\x1f\\x80-\\x9f]/g;\n\nexport function sanitizeForFileSystem(s: string, replacement: string = '_'): string {\n\tif (!s) return s;\n\treturn s.replace(illegalCharsForFSRegex, replacement);\n}\n\nconst cStyleEscapes: Readonly<Record<string, number>> = {\n\ta: 0x07,\n\tb: 0x08,\n\tt: 0x09,\n\tn: 0x0a,\n\tv: 0x0b,\n\tf: 0x0c,\n\tr: 0x0d,\n\t'\"': 0x22,\n\t'\\\\': 0x5c,\n};\nconst octalEscapeRegex = /^[0-7]{3}/;\nconst utf8Encoder = new TextEncoder();\n// A name can start with U+FEFF, which the decoder would otherwise drop as a byte order mark\nconst utf8Decoder = new TextDecoder('utf-8', { ignoreBOM: true });\n\n/**\n * Reads the string git C-quotes (`\"a\\\"b\\tc\"`) whose opening quote is at `from`, returning it with the index just\n * past its closing quote, or `undefined` when it is malformed. Git writes a quoted name byte by byte, so an octal\n * escape is one byte of the name's UTF-8, while a character it left as it was (every non-ASCII one with\n * `core.quotePath` off) is already text\n */\nexport function readCQuotedString(text: string, from: number): { value: string; end: number } | undefined {\n\tconst bytes: number[] = [];\n\tfor (let i = from + 1; i < text.length; i++) {\n\t\tconst char = text[i];\n\t\tif (char === '\"') return { value: utf8Decoder.decode(new Uint8Array(bytes)), end: i + 1 };\n\n\t\tif (char !== '\\\\') {\n\t\t\tconst code = char.charCodeAt(0);\n\t\t\tif (code < 0x80) {\n\t\t\t\tbytes.push(code);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// A whole code point, so a surrogate pair encodes as one character\n\t\t\tconst codePoint = String.fromCodePoint(text.codePointAt(i)!);\n\t\t\tbytes.push(...utf8Encoder.encode(codePoint));\n\t\t\ti += codePoint.length - 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst octal = octalEscapeRegex.exec(text.substring(i + 1, i + 4));\n\t\tif (octal != null) {\n\t\t\tbytes.push(parseInt(octal[0], 8) & 0xff);\n\t\t\ti += 3;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst escaped = cStyleEscapes[text[i + 1]];\n\t\tif (escaped == null) return undefined;\n\n\t\tbytes.push(escaped);\n\t\ti++;\n\t}\n\treturn undefined;\n}\n\n/**\n * Reverses git's C-style quoting of a whole value: a value git didn't quote, which can't start with a `\"`, and one\n * that isn't well-formed are returned as they are\n */\nexport function unquoteCString(value: string): string {\n\tif (!value.startsWith('\"')) return value;\n\n\tconst quoted = readCQuotedString(value, 0);\n\treturn quoted != null && quoted.end === value.length ? quoted.value : value;\n}\n\nexport function splitLast(s: string, splitter: string): string[] {\n\tconst index = s.lastIndexOf(splitter);\n\tif (index === -1) return [s];\n\n\treturn [s.substring(0, index), s.substring(index + splitter.length)];\n}\n\nexport function splitSingle(s: string, splitter: string): string[] {\n\tconst index = s.indexOf(splitter);\n\tif (index === -1) return [s];\n\n\tconst start = s.substring(0, index);\n\tconst rest = s.substring(index + splitter.length);\n\treturn rest != null ? [start, rest] : [start];\n}\n\nexport function truncate(s: string, truncateTo: number, ellipsis: string = '\\u2026', width?: number): string {\n\tif (!s) return s;\n\tif (truncateTo <= 1) return ellipsis;\n\n\twidth = width ?? getWidth(s);\n\tif (width <= truncateTo) return s;\n\tif (width === s.length) return `${s.substring(0, truncateTo - 1)}${ellipsis}`;\n\n\t// Skip ahead to start as far as we can by assuming all the double-width characters won't be truncated\n\tlet chars = Math.floor(truncateTo / (width / s.length));\n\tlet count = getWidth(s.substring(0, chars));\n\twhile (count < truncateTo) {\n\t\tcount += getWidth(s[chars++]);\n\t}\n\n\tif (count >= truncateTo) {\n\t\tchars--;\n\t}\n\n\treturn `${s.substring(0, chars)}${ellipsis}`;\n}\n\nexport function truncateLeft(s: string, truncateTo: number, ellipsis: string = '\\u2026', width?: number): string {\n\tif (!s) return s;\n\tif (truncateTo <= 1) return ellipsis;\n\n\twidth = width ?? getWidth(s);\n\tif (width <= truncateTo) return s;\n\tif (width === s.length) return `${ellipsis}${s.substring(width - truncateTo)}`;\n\n\t// Skip ahead to start as far as we can by assuming all the double-width characters won't be truncated\n\tlet chars = Math.floor(truncateTo / (width / s.length));\n\tlet count = getWidth(s.substring(0, chars));\n\twhile (count < truncateTo) {\n\t\tcount += getWidth(s[chars++]);\n\t}\n\n\tif (count >= truncateTo) {\n\t\tchars--;\n\t}\n\n\treturn `${ellipsis}${s.substring(s.length - chars)}`;\n}\n\nexport function truncateMiddle(s: string, truncateTo: number, ellipsis: string = '\\u2026'): string {\n\tif (!s) return s;\n\tif (truncateTo <= 1) return ellipsis;\n\n\tconst width = getWidth(s);\n\tif (width <= truncateTo) return s;\n\n\treturn `${s.slice(0, Math.floor(truncateTo / 2) - 1)}${ellipsis}${s.slice(width - Math.ceil(truncateTo / 2))}`;\n}\n\n// Below adapted from https://github.com/pieroxy/lz-string\n\n// Pre-computed from:\n// const base64ReverseMap = new Uint8Array(123);\n// const base64Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';\n// for (let i = 0; i < base64Chars.length; i++) {\n// \tbase64ReverseMap[base64Chars.charCodeAt(i)] = i;\n// }\n\nconst base64ReverseMap = new Uint8Array([\n\t0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n\t0, 0, 0, 0, 62, 0, 0, 0, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0, 0, 0, 64, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7,\n\t8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0, 0, 0, 0, 0, 26, 27, 28, 29, 30, 31, 32,\n\t33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,\n]);\n\nexport function decompressFromBase64LZString(input: string | undefined): string {\n\tif (input == null || input === '') return '';\n\n\tconst result = _decompressLZString(input, 32) ?? '';\n\treturn result;\n}\n\nfunction _decompressLZString(input: string, resetValue: number) {\n\tconst dictionary = new Array<string>(4096);\n\tdictionary[0] = '0';\n\tdictionary[1] = '1';\n\tdictionary[2] = '2';\n\n\tconst result: string[] = [];\n\tconst length = input.length;\n\n\tlet val = base64ReverseMap[input.charCodeAt(0)];\n\tlet position = resetValue;\n\tlet index = 1;\n\n\tfunction readBits(maxpower: number): number {\n\t\tlet bits = 0;\n\t\tlet power = 1;\n\t\tdo {\n\t\t\tbits |= Number((val & position) > 0) * power;\n\t\t\tpower <<= 1;\n\n\t\t\tposition >>= 1;\n\t\t\tif (position === 0) {\n\t\t\t\tposition = resetValue;\n\t\t\t\tval = base64ReverseMap[input.charCodeAt(index++)];\n\t\t\t}\n\t\t} while (power !== maxpower);\n\n\t\treturn bits;\n\t}\n\n\tlet c = readBits(4);\n\n\tswitch (c) {\n\t\tcase 0:\n\t\t\tc = readBits(256);\n\t\t\tbreak;\n\t\tcase 1:\n\t\t\tc = readBits(65536);\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\treturn '';\n\t}\n\n\tlet w = String.fromCharCode(c);\n\tdictionary[3] = w;\n\tresult.push(w);\n\n\tlet dictSize = 4;\n\tlet enlargeIn = 4;\n\tlet numBits = 3;\n\n\twhile (index <= length) {\n\t\tc = readBits(1 << numBits);\n\n\t\tswitch (c) {\n\t\t\tcase 0:\n\t\t\t\tc = readBits(256);\n\t\t\t\tdictionary[dictSize] = String.fromCharCode(c);\n\t\t\t\tc = dictSize++;\n\t\t\t\tenlargeIn--;\n\t\t\t\tbreak;\n\t\t\tcase 1:\n\t\t\t\tc = readBits(65536);\n\t\t\t\tdictionary[dictSize] = String.fromCharCode(c);\n\t\t\t\tc = dictSize++;\n\t\t\t\tenlargeIn--;\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\treturn result.join('');\n\t\t}\n\n\t\tif (enlargeIn === 0) {\n\t\t\tenlargeIn = 1 << numBits++;\n\t\t}\n\n\t\tlet entry = dictionary[c];\n\t\tif (entry === undefined) {\n\t\t\tif (c !== dictSize) return undefined;\n\n\t\t\tentry = w + w[0];\n\t\t}\n\n\t\tresult.push(entry);\n\t\tdictionary[dictSize++] = w + entry[0];\n\t\tenlargeIn--;\n\t\tw = entry;\n\n\t\tif (enlargeIn === 0) {\n\t\t\tenlargeIn = 1 << numBits++;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n"],"mappings":";;;AAQA,SAAgB,WAAW,GAAmB;CAC7C,OAAO,GAAG,EAAE,EAAE,CAAC,kBAAkB,IAAI,EAAE,MAAM,CAAC;AAC/C;AAEA,IAAI;AACJ,SAAgB,kBAAkB,GAAW,GAAuB;CACnE,oBAAoB,IAAI,KAAK,SAAS,KAAA,GAAW,EAAE,aAAa,SAAS,CAAC;CAE1E,MAAM,SAAS,gBAAgB,QAAQ,GAAG,CAAC;CAE3C,OAAO,WAAW,IAAI,IAAI,SAAS,IAAI,IAAI;AAC5C;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,OAAO,UAA0B;CAChD,MAAM,QAAQ,SAAS,MAAM,IAAI;CAGjC,OAAO,MAAM,SAAS,KAAK,MAAM,EAAE,CAAC,KAAK,MAAM,IAC9C,MAAM,MAAM;CAEb,OAAO,MAAM,SAAS,KAAK,MAAM,GAAG,EAAE,CAAC,EAAE,KAAK,MAAM,IACnD,MAAM,IAAI;CAGX,IAAI,MAAM,WAAW,GAAG,OAAO;CAG/B,MAAM,gBAAgB,MAAM,QAAO,SAAQ,KAAK,KAAK,MAAM,EAAE;CAC7D,IAAI,cAAc,WAAW,GAAG,OAAO;CAEvC,MAAM,YAAY,KAAK,IACtB,GAAG,cAAc,KAAI,SAAQ;EAC5B,MAAM,QAAQ,KAAK,MAAM,QAAQ;EACjC,OAAO,QAAQ,MAAM,EAAE,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U;EAEnB,OAAO;CACR;CAEA,IAAI,IAAI,SAAS,CAAC;CAElB,QAAQ,GAAR;EACC,KAAK;GACJ,IAAI,SAAS,GAAG;GAChB;EACD,KAAK;GACJ,IAAI,SAAS,KAAK;GAClB;EACD,KAAK,GACJ,OAAO;CACT;CAEA,IAAI,IAAI,OAAO,aAAa,CAAC;CAC7B,WAAW,KAAK;CAChB,OAAO,KAAK,CAAC;CAEb,IAAI,WAAW;CACf,IAAI,YAAY;CAChB,IAAI,UAAU;CAEd,OAAO,SAAS,QAAQ;EACvB,IAAI,SAAS,KAAK,OAAO;EAEzB,QAAQ,GAAR;GACC,KAAK;IACJ,IAAI,SAAS,GAAG;IAChB,WAAW,YAAY,OAAO,aAAa,CAAC;IAC5C,IAAI;IACJ;IACA;GACD,KAAK;IACJ,IAAI,SAAS,KAAK;IAClB,WAAW,YAAY,OAAO,aAAa,CAAC;IAC5C,IAAI;IACJ;IACA;GACD,KAAK,GACJ,OAAO,OAAO,KAAK,EAAE;EACvB;EAEA,IAAI,cAAc,GACjB,YAAY,KAAK;EAGlB,IAAI,QAAQ,WAAW;EACvB,IAAI,UAAU,KAAA,GAAW;GACxB,IAAI,MAAM,UAAU,OAAO,KAAA;GAE3B,QAAQ,IAAI,EAAE;EACf;EAEA,OAAO,KAAK,KAAK;EACjB,WAAW,cAAc,IAAI,MAAM;EACnC;EACA,IAAI;EAEJ,IAAI,cAAc,GACjB,YAAY,KAAK;CAEnB;AAGD"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitkraken/core-gitlens",
|
|
3
3
|
"description": "GitLens core — shared Git / AI / GitHub primitives for internal GitKraken consumption",
|
|
4
|
-
"version": "0.38.
|
|
4
|
+
"version": "0.38.3",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "GitKraken",
|