@intlayer/chokidar 7.0.3 → 7.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/cjs/_virtual/_utils_asset.cjs +1 -1
  2. package/dist/cjs/index.cjs +4 -2
  3. package/dist/cjs/utils/runParallel/bin.cjs +55 -0
  4. package/dist/cjs/utils/runParallel/bin.cjs.map +1 -0
  5. package/dist/cjs/utils/runParallel/bootstrap.cjs +24 -0
  6. package/dist/cjs/utils/runParallel/bootstrap.cjs.map +1 -0
  7. package/dist/cjs/utils/runParallel/index.cjs +111 -0
  8. package/dist/cjs/utils/runParallel/index.cjs.map +1 -0
  9. package/dist/cjs/utils/runParallel/pidTree.cjs +145 -0
  10. package/dist/cjs/utils/runParallel/pidTree.cjs.map +1 -0
  11. package/dist/cjs/utils/runParallel/ps.cjs +49 -0
  12. package/dist/cjs/utils/runParallel/ps.cjs.map +1 -0
  13. package/dist/cjs/utils/runParallel/runTask.cjs +155 -0
  14. package/dist/cjs/utils/runParallel/runTask.cjs.map +1 -0
  15. package/dist/cjs/utils/runParallel/spawnPosix.cjs +60 -0
  16. package/dist/cjs/utils/runParallel/spawnPosix.cjs.map +1 -0
  17. package/dist/cjs/utils/runParallel/spawnWin32.cjs +44 -0
  18. package/dist/cjs/utils/runParallel/spawnWin32.cjs.map +1 -0
  19. package/dist/cjs/utils/runParallel/wmic.cjs +52 -0
  20. package/dist/cjs/utils/runParallel/wmic.cjs.map +1 -0
  21. package/dist/esm/_virtual/_utils_asset.mjs +1 -1
  22. package/dist/esm/index.mjs +3 -2
  23. package/dist/esm/utils/runParallel/bin.mjs +53 -0
  24. package/dist/esm/utils/runParallel/bin.mjs.map +1 -0
  25. package/dist/esm/utils/runParallel/bootstrap.mjs +23 -0
  26. package/dist/esm/utils/runParallel/bootstrap.mjs.map +1 -0
  27. package/dist/esm/utils/runParallel/index.mjs +109 -0
  28. package/dist/esm/utils/runParallel/index.mjs.map +1 -0
  29. package/dist/esm/utils/runParallel/pidTree.mjs +143 -0
  30. package/dist/esm/utils/runParallel/pidTree.mjs.map +1 -0
  31. package/dist/esm/utils/runParallel/ps.mjs +47 -0
  32. package/dist/esm/utils/runParallel/ps.mjs.map +1 -0
  33. package/dist/esm/utils/runParallel/runTask.mjs +153 -0
  34. package/dist/esm/utils/runParallel/runTask.mjs.map +1 -0
  35. package/dist/esm/utils/runParallel/spawnPosix.mjs +58 -0
  36. package/dist/esm/utils/runParallel/spawnPosix.mjs.map +1 -0
  37. package/dist/esm/utils/runParallel/spawnWin32.mjs +42 -0
  38. package/dist/esm/utils/runParallel/spawnWin32.mjs.map +1 -0
  39. package/dist/esm/utils/runParallel/wmic.mjs +50 -0
  40. package/dist/esm/utils/runParallel/wmic.mjs.map +1 -0
  41. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts +2 -2
  42. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +3 -3
  43. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts +3 -3
  44. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +2 -2
  45. package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts +2 -2
  46. package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts +2 -2
  47. package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts +2 -2
  48. package/dist/types/index.d.ts +3 -2
  49. package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +2 -2
  50. package/dist/types/utils/chunkJSON.d.ts.map +1 -1
  51. package/dist/types/utils/runParallel/bin.d.ts +15 -0
  52. package/dist/types/utils/runParallel/bin.d.ts.map +1 -0
  53. package/dist/types/utils/runParallel/bootstrap.d.ts +5 -0
  54. package/dist/types/utils/runParallel/bootstrap.d.ts.map +1 -0
  55. package/dist/types/utils/runParallel/index.d.ts +14 -0
  56. package/dist/types/utils/runParallel/index.d.ts.map +1 -0
  57. package/dist/types/utils/runParallel/pidTree.d.ts +24 -0
  58. package/dist/types/utils/runParallel/pidTree.d.ts.map +1 -0
  59. package/dist/types/utils/runParallel/ps.d.ts +11 -0
  60. package/dist/types/utils/runParallel/ps.d.ts.map +1 -0
  61. package/dist/types/utils/runParallel/runTask.d.ts +26 -0
  62. package/dist/types/utils/runParallel/runTask.d.ts.map +1 -0
  63. package/dist/types/utils/runParallel/spawnPosix.d.ts +21 -0
  64. package/dist/types/utils/runParallel/spawnPosix.d.ts.map +1 -0
  65. package/dist/types/utils/runParallel/spawnWin32.d.ts +21 -0
  66. package/dist/types/utils/runParallel/spawnWin32.d.ts.map +1 -0
  67. package/dist/types/utils/runParallel/wmic.d.ts +11 -0
  68. package/dist/types/utils/runParallel/wmic.d.ts.map +1 -0
  69. package/package.json +18 -18
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runTask.cjs","names":["signals: Record<string, number>","Writable","results: TaskResult[]","queue: TaskQueueItem[]","promises: TaskPromise[]","error: Error | null"],"sources":["../../../../src/utils/runParallel/runTask.ts"],"sourcesContent":["//------------------------------------------------------------------------------\n// Requirements\n//------------------------------------------------------------------------------\n\nimport { Writable } from 'node:stream';\n\n//------------------------------------------------------------------------------\n// Helpers\n//------------------------------------------------------------------------------\n\n/**\n * Remove the given value from the array.\n */\nconst remove = <T>(array: T[], x: T): void => {\n const index = array.indexOf(x);\n if (index !== -1) {\n array.splice(index, 1);\n }\n};\n\nconst signals: Record<string, number> = {\n // Signal name mappings to their respective standard numeric codes.\n // See: https://man7.org/linux/man-pages/man7/signal.7.html\n\n SIGABRT: 6, // Abort signal from abort(3)\n SIGALRM: 14, // Timer signal from alarm(2)\n SIGBUS: 10, // Bus error (bad memory access)\n SIGCHLD: 20, // Child stopped or terminated\n SIGCONT: 19, // Continue if stopped\n SIGFPE: 8, // Floating point exception\n SIGHUP: 1, // Hangup detected on controlling terminal or death of controlling process\n SIGILL: 4, // Illegal Instruction\n SIGINT: 2, // Interrupt from keyboard (Ctrl+C)\n SIGKILL: 9, // Kill signal (cannot be caught or ignored)\n SIGPIPE: 13, // Broken pipe: write to pipe with no readers\n SIGQUIT: 3, // Quit from keyboard (Ctrl+\\)\n SIGSEGV: 11, // Invalid memory reference (segmentation fault)\n SIGSTOP: 17, // Stop process (cannot be caught or ignored)\n SIGTERM: 15, // Termination signal\n SIGTRAP: 5, // Trace/breakpoint trap\n SIGTSTP: 18, // Stop typed at tty (Ctrl+Z)\n SIGTTIN: 21, // tty input for background process\n SIGTTOU: 22, // tty output for background process\n SIGUSR1: 30, // User-defined signal 1\n SIGUSR2: 31, // User-defined signal 2\n};\n\n/**\n * Converts a signal name to a number.\n */\nconst convert = (signal: string): number => {\n return signals[signal] || 0;\n};\n\n/**\n * Simple in-memory writable stream\n */\nclass MemoryStream extends Writable {\n private chunks: Buffer[] = [];\n\n _write(\n chunk: Buffer,\n _encoding: string,\n callback: (error?: Error | null) => void\n ): void {\n this.chunks.push(chunk);\n callback();\n }\n\n toString(): string {\n return Buffer.concat(this.chunks).toString('utf8');\n }\n}\n\n//------------------------------------------------------------------------------\n// Types\n//------------------------------------------------------------------------------\n\ninterface TaskResult {\n name: string;\n code: number | null;\n signal?: string | null;\n}\n\ninterface TaskQueueItem {\n name: string;\n index: number;\n}\n\ninterface RunTaskOptions {\n stdout: NodeJS.WritableStream;\n stderr?: NodeJS.WritableStream;\n aggregateOutput?: boolean;\n continueOnError?: boolean;\n race?: boolean;\n maxParallel?: number;\n}\n\ninterface TaskPromise extends Promise<TaskResult> {\n abort?: () => void;\n}\n\n//------------------------------------------------------------------------------\n// Public Interface\n//------------------------------------------------------------------------------\n\n/**\n * Run npm-scripts of given names in parallel.\n *\n * If a npm-script exited with a non-zero code, this aborts other all npm-scripts.\n *\n * Note: This is a simplified version for our use case.\n * The full implementation would require the actual runTask function from npm-run-all.\n */\nexport const runTasks = (\n tasks: string[],\n options: RunTaskOptions\n): Promise<TaskResult[]> => {\n return new Promise((resolve, reject) => {\n if (tasks.length === 0) {\n resolve([]);\n return;\n }\n\n const results: TaskResult[] = tasks.map((task) => ({\n name: task,\n code: undefined as any,\n }));\n const queue: TaskQueueItem[] = tasks.map((task, index) => ({\n name: task,\n index,\n }));\n const promises: TaskPromise[] = [];\n let error: Error | null = null;\n let aborted = false;\n\n /**\n * Done.\n */\n const done = (): void => {\n if (error == null) {\n resolve(results);\n } else {\n reject(error);\n }\n };\n\n /**\n * Aborts all tasks.\n */\n const abort = (): void => {\n if (aborted) {\n return;\n }\n aborted = true;\n\n if (promises.length === 0) {\n done();\n } else {\n for (const p of promises) {\n p.abort?.();\n }\n Promise.all(promises).then(done, reject);\n }\n };\n\n /**\n * Runs a next task.\n */\n const next = (): void => {\n if (aborted) {\n return;\n }\n if (queue.length === 0) {\n if (promises.length === 0) {\n done();\n }\n return;\n }\n\n const originalOutputStream = options.stdout;\n const optionsClone = { ...options };\n const writer = new MemoryStream();\n\n if (options.aggregateOutput) {\n optionsClone.stdout = writer as any;\n }\n\n const task = queue.shift()!;\n\n // Note: This requires the actual runTask implementation from npm-run-all\n // For now, this is a placeholder that would need to be implemented\n const promise = Promise.resolve({\n name: task.name,\n code: 0,\n signal: null,\n }) as TaskPromise;\n\n promises.push(promise);\n promise.then(\n (result) => {\n remove(promises, promise);\n if (aborted) {\n return;\n }\n\n if (options.aggregateOutput) {\n originalOutputStream.write(writer.toString());\n }\n\n // Check if the task failed as a result of a signal, and\n // amend the exit code as a result.\n if (\n result.code === null &&\n result.signal !== null &&\n result.signal !== undefined\n ) {\n // An exit caused by a signal must return a status code\n // of 128 plus the value of the signal code.\n // Ref: https://nodejs.org/api/process.html#process_exit_codes\n result.code = 128 + convert(result.signal);\n }\n\n // Save the result.\n results[task.index].code = result.code;\n\n // Aborts all tasks if it's an error.\n if (result.code) {\n error = new Error(\n `Task ${result.name} failed with code ${result.code}`\n );\n if (!options.continueOnError) {\n abort();\n return;\n }\n }\n\n // Aborts all tasks if options.race is true.\n if (options.race && !result.code) {\n abort();\n return;\n }\n\n // Call the next task.\n next();\n },\n (thisError: Error) => {\n remove(promises, promise);\n if (!options.continueOnError || options.race) {\n error = thisError;\n abort();\n return;\n }\n next();\n }\n );\n };\n\n const max = options.maxParallel;\n const end =\n typeof max === 'number' && max > 0\n ? Math.min(tasks.length, max)\n : tasks.length;\n for (let i = 0; i < end; ++i) {\n next();\n }\n });\n};\n"],"mappings":";;;;;;;;AAaA,MAAM,UAAa,OAAY,MAAe;CAC5C,MAAM,QAAQ,MAAM,QAAQ,EAAE;AAC9B,KAAI,UAAU,GACZ,OAAM,OAAO,OAAO,EAAE;;AAI1B,MAAMA,UAAkC;CAItC,SAAS;CACT,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,SAAS;CACT,SAAS;CACT,SAAS;CACT,SAAS;CACT,SAAS;CACT,SAAS;CACT,SAAS;CACT,SAAS;CACT,SAAS;CACT,SAAS;CACT,SAAS;CACV;;;;AAKD,MAAM,WAAW,WAA2B;AAC1C,QAAO,QAAQ,WAAW;;;;;AAM5B,IAAM,eAAN,cAA2BC,qBAAS;CAClC,AAAQ,SAAmB,EAAE;CAE7B,OACE,OACA,WACA,UACM;AACN,OAAK,OAAO,KAAK,MAAM;AACvB,YAAU;;CAGZ,WAAmB;AACjB,SAAO,OAAO,OAAO,KAAK,OAAO,CAAC,SAAS,OAAO;;;;;;;;;;;AA4CtD,MAAa,YACX,OACA,YAC0B;AAC1B,QAAO,IAAI,SAAS,SAAS,WAAW;AACtC,MAAI,MAAM,WAAW,GAAG;AACtB,WAAQ,EAAE,CAAC;AACX;;EAGF,MAAMC,UAAwB,MAAM,KAAK,UAAU;GACjD,MAAM;GACN,MAAM;GACP,EAAE;EACH,MAAMC,QAAyB,MAAM,KAAK,MAAM,WAAW;GACzD,MAAM;GACN;GACD,EAAE;EACH,MAAMC,WAA0B,EAAE;EAClC,IAAIC,QAAsB;EAC1B,IAAI,UAAU;;;;EAKd,MAAM,a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AACP;;AAEF,UAAM;KAET;;EAGH,MAAM,MAAM,QAAQ;EACpB,MAAM,MACJ,OAAO,QAAQ,YAAY,MAAM,IAC7B,KAAK,IAAI,MAAM,QAAQ,IAAI,GAC3B,MAAM;AACZ,OAAK,IAAI,IAAI,GAAG,IAAI,KAAK,EAAE,EACzB,OAAM;GAER"}
@@ -0,0 +1,60 @@
1
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
+ const require_utils_runParallel_pidTree = require('./pidTree.cjs');
3
+ let node_child_process = require("node:child_process");
4
+ node_child_process = require_rolldown_runtime.__toESM(node_child_process);
5
+
6
+ //#region src/utils/runParallel/spawnPosix.ts
7
+ /**
8
+ * Kills the new process and its sub processes.
9
+ */
10
+ const createKillHandler = (child) => {
11
+ return (signal) => {
12
+ if (!child.pid) return false;
13
+ try {
14
+ require_utils_runParallel_pidTree.list(child.pid, { root: true }, (err, pids) => {
15
+ if (err) {
16
+ try {
17
+ process.kill(-child.pid, signal ?? "SIGTERM");
18
+ } catch {}
19
+ return;
20
+ }
21
+ if (!pids) {
22
+ try {
23
+ process.kill(-child.pid, signal ?? "SIGTERM");
24
+ } catch {}
25
+ return;
26
+ }
27
+ for (const pid of pids) try {
28
+ process.kill(pid, signal ?? "SIGTERM");
29
+ } catch (_err) {}
30
+ });
31
+ } catch {
32
+ try {
33
+ process.kill(-child.pid, signal ?? "SIGTERM");
34
+ } catch {}
35
+ }
36
+ return true;
37
+ };
38
+ };
39
+ /**
40
+ * Launches a new process with the given command.
41
+ * This is almost same as `child_process.spawn`.
42
+ *
43
+ * This returns a `ChildProcess` instance.
44
+ * `kill` method of the instance kills the new process and its sub processes.
45
+ *
46
+ * @param command - The command to run.
47
+ * @param args - List of string arguments.
48
+ * @param options - Options.
49
+ * @returns A ChildProcess instance of new process.
50
+ * @private
51
+ */
52
+ const spawnPosix = (command, args, options) => {
53
+ const child = (0, node_child_process.spawn)(command, args, options);
54
+ child.kill = createKillHandler(child);
55
+ return child;
56
+ };
57
+
58
+ //#endregion
59
+ exports.spawnPosix = spawnPosix;
60
+ //# sourceMappingURL=spawnPosix.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spawnPosix.cjs","names":[],"sources":["../../../../src/utils/runParallel/spawnPosix.ts"],"sourcesContent":["//------------------------------------------------------------------------------\n// Requirements\n//------------------------------------------------------------------------------\n\nimport type { SpawnOptions } from 'node:child_process';\nimport { type ChildProcess, spawn as nodeSpawn } from 'node:child_process';\nimport { list } from './pidTree';\n\n//------------------------------------------------------------------------------\n// Helpers\n//------------------------------------------------------------------------------\n\n/**\n * Kills the new process and its sub processes.\n */\nconst createKillHandler = (\n child: ChildProcess\n): ((signal?: NodeJS.Signals | number) => boolean) => {\n return (signal?: NodeJS.Signals | number): boolean => {\n if (!child.pid) return false;\n\n // Try using list if available\n try {\n list(child.pid, { root: true }, (err: Error | null, pids?: number[]) => {\n if (err) {\n // Fallback to process group kill\n try {\n process.kill(-child.pid!, signal ?? 'SIGTERM');\n } catch {\n // ignore\n }\n return;\n }\n\n if (!pids) {\n // Fallback to process group kill if no pids returned\n try {\n process.kill(-child.pid!, signal ?? 'SIGTERM');\n } catch {\n // ignore\n }\n return;\n }\n\n for (const pid of pids) {\n try {\n process.kill(pid, signal ?? 'SIGTERM');\n } catch (_err) {\n // ignore.\n }\n }\n });\n } catch {\n // pidtree not available, use process group kill\n try {\n process.kill(-child.pid, signal ?? 'SIGTERM');\n } catch {\n // ignore\n }\n }\n\n return true;\n };\n};\n\n//------------------------------------------------------------------------------\n// Public Interface\n//------------------------------------------------------------------------------\n\n/**\n * Launches a new process with the given command.\n * This is almost same as `child_process.spawn`.\n *\n * This returns a `ChildProcess` instance.\n * `kill` method of the instance kills the new process and its sub processes.\n *\n * @param command - The command to run.\n * @param args - List of string arguments.\n * @param options - Options.\n * @returns A ChildProcess instance of new process.\n * @private\n */\nexport const spawnPosix = (\n command: string,\n args: string[],\n options: SpawnOptions\n): ChildProcess => {\n const child = nodeSpawn(command, args, options);\n child.kill = createKillHandler(child);\n\n return child;\n};\n"],"mappings":";;;;;;;;;AAeA,MAAM,qBACJ,UACoD;AACpD,SAAQ,WAA8C;AACpD,MAAI,CAAC,MAAM,IAAK,QAAO;AAGvB,MAAI;AACF,0CAAK,MAAM,KAAK,EAAE,MAAM,MAAM,GAAG,KAAmB,SAAoB;AACtE,QAAI,KAAK;AAEP,SAAI;AACF,cAAQ,KAAK,CAAC,MAAM,KAAM,UAAU,UAAU;aACxC;AAGR;;AAGF,QAAI,CAAC,MAAM;AAET,SAAI;AACF,cAAQ,KAAK,CAAC,MAAM,KAAM,UAAU,UAAU;aACxC;AAGR;;AAGF,SAAK,MAAM,OAAO,KAChB,KAAI;AACF,aAAQ,KAAK,KAAK,UAAU,UAAU;aAC/B,MAAM;KAIjB;UACI;AAEN,OAAI;AACF,YAAQ,KAAK,CAAC,MAAM,KAAK,UAAU,UAAU;WACvC;;AAKV,SAAO;;;;;;;;;;;;;;;;AAqBX,MAAa,cACX,SACA,MACA,YACiB;CACjB,MAAM,sCAAkB,SAAS,MAAM,QAAQ;AAC/C,OAAM,OAAO,kBAAkB,MAAM;AAErC,QAAO"}
@@ -0,0 +1,44 @@
1
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
+ let node_child_process = require("node:child_process");
3
+ node_child_process = require_rolldown_runtime.__toESM(node_child_process);
4
+
5
+ //#region src/utils/runParallel/spawnWin32.ts
6
+ /**
7
+ * Kills the new process and its sub processes forcibly.
8
+ */
9
+ const createKillHandler = (child) => {
10
+ return () => {
11
+ if (!child.pid) return false;
12
+ try {
13
+ (0, node_child_process.spawn)("taskkill", [
14
+ "/F",
15
+ "/T",
16
+ "/PID",
17
+ String(child.pid)
18
+ ], { stdio: "ignore" });
19
+ } catch {}
20
+ return true;
21
+ };
22
+ };
23
+ /**
24
+ * Launches a new process with the given command.
25
+ * This is almost same as `child_process.spawn`.
26
+ *
27
+ * This returns a `ChildProcess` instance.
28
+ * `kill` method of the instance kills the new process and its sub processes forcibly.
29
+ *
30
+ * @param command - The command to run.
31
+ * @param args - List of string arguments.
32
+ * @param options - Options.
33
+ * @returns A ChildProcess instance of new process.
34
+ * @private
35
+ */
36
+ const spawnWin32 = (command, args, options) => {
37
+ const child = (0, node_child_process.spawn)(command, args, options);
38
+ child.kill = createKillHandler(child);
39
+ return child;
40
+ };
41
+
42
+ //#endregion
43
+ exports.spawnWin32 = spawnWin32;
44
+ //# sourceMappingURL=spawnWin32.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spawnWin32.cjs","names":[],"sources":["../../../../src/utils/runParallel/spawnWin32.ts"],"sourcesContent":["//------------------------------------------------------------------------------\n// Requirements\n//------------------------------------------------------------------------------\n\nimport type { SpawnOptions } from 'node:child_process';\nimport { type ChildProcess, spawn as nodeSpawn } from 'node:child_process';\n\n//------------------------------------------------------------------------------\n// Helpers\n//------------------------------------------------------------------------------\n\n/**\n * Kills the new process and its sub processes forcibly.\n */\nconst createKillHandler = (child: ChildProcess) => {\n return (): boolean => {\n if (!child.pid) return false;\n\n try {\n nodeSpawn('taskkill', ['/F', '/T', '/PID', String(child.pid)], {\n stdio: 'ignore',\n });\n } catch {\n // ignore\n }\n\n return true;\n };\n};\n\n//------------------------------------------------------------------------------\n// Public Interface\n//------------------------------------------------------------------------------\n\n/**\n * Launches a new process with the given command.\n * This is almost same as `child_process.spawn`.\n *\n * This returns a `ChildProcess` instance.\n * `kill` method of the instance kills the new process and its sub processes forcibly.\n *\n * @param command - The command to run.\n * @param args - List of string arguments.\n * @param options - Options.\n * @returns A ChildProcess instance of new process.\n * @private\n */\nexport const spawnWin32 = (\n command: string,\n args: string[],\n options: SpawnOptions\n): ChildProcess => {\n const child = nodeSpawn(command, args, options);\n child.kill = createKillHandler(child);\n\n return child;\n};\n"],"mappings":";;;;;;;;AAcA,MAAM,qBAAqB,UAAwB;AACjD,cAAsB;AACpB,MAAI,CAAC,MAAM,IAAK,QAAO;AAEvB,MAAI;AACF,iCAAU,YAAY;IAAC;IAAM;IAAM;IAAQ,OAAO,MAAM,IAAI;IAAC,EAAE,EAC7D,OAAO,UACR,CAAC;UACI;AAIR,SAAO;;;;;;;;;;;;;;;;AAqBX,MAAa,cACX,SACA,MACA,YACiB;CACjB,MAAM,sCAAkB,SAAS,MAAM,QAAQ;AAC/C,OAAM,OAAO,kBAAkB,MAAM;AAErC,QAAO"}
@@ -0,0 +1,52 @@
1
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
+ const require_utils_runParallel_bin = require('./bin.cjs');
3
+ let node_os = require("node:os");
4
+ node_os = require_rolldown_runtime.__toESM(node_os);
5
+
6
+ //#region src/utils/runParallel/wmic.ts
7
+ /**
8
+ * Gets the list of all the pids of the system through the wmic command.
9
+ * @param callback Callback function with error and process list.
10
+ */
11
+ const wmic = (callback) => {
12
+ require_utils_runParallel_bin.run("wmic", [
13
+ "PROCESS",
14
+ "get",
15
+ "ParentProcessId,ProcessId"
16
+ ], {
17
+ windowsHide: true,
18
+ windowsVerbatimArguments: true
19
+ }, (err, stdout, code) => {
20
+ if (err) {
21
+ callback(err);
22
+ return;
23
+ }
24
+ if (code !== 0) {
25
+ callback(/* @__PURE__ */ new Error(`pidtree wmic command exited with code ${code}`));
26
+ return;
27
+ }
28
+ if (!stdout) {
29
+ callback(/* @__PURE__ */ new Error("No stdout received from wmic command"));
30
+ return;
31
+ }
32
+ try {
33
+ const lines = stdout.split(node_os.EOL);
34
+ const list = [];
35
+ for (let i = 1; i < lines.length; i++) {
36
+ const trimmed = lines[i].trim();
37
+ if (!trimmed) continue;
38
+ const parts = trimmed.split(/\s+/);
39
+ const ppid = parseInt(parts[0], 10);
40
+ const pid = parseInt(parts[1], 10);
41
+ if (!Number.isNaN(ppid) && !Number.isNaN(pid)) list.push([ppid, pid]);
42
+ }
43
+ callback(null, list);
44
+ } catch (error) {
45
+ callback(error instanceof Error ? error : new Error(String(error)));
46
+ }
47
+ });
48
+ };
49
+
50
+ //#endregion
51
+ exports.wmic = wmic;
52
+ //# sourceMappingURL=wmic.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wmic.cjs","names":["os","list: ProcessList"],"sources":["../../../../src/utils/runParallel/wmic.ts"],"sourcesContent":["import type { SpawnOptions } from 'node:child_process';\nimport * as os from 'node:os';\nimport { run } from './bin';\n\ntype ProcessList = [number, number][]; // [PPID, PID][]\ntype ProcessListCallback = (err: Error | null, list?: ProcessList) => void;\n\n/**\n * Gets the list of all the pids of the system through the wmic command.\n * @param callback Callback function with error and process list.\n */\nexport const wmic = (callback: ProcessListCallback): void => {\n const args = ['PROCESS', 'get', 'ParentProcessId,ProcessId'];\n const options: SpawnOptions = {\n windowsHide: true,\n windowsVerbatimArguments: true,\n };\n run('wmic', args, options, (err, stdout, code) => {\n if (err) {\n callback(err);\n return;\n }\n\n if (code !== 0) {\n callback(new Error(`pidtree wmic command exited with code ${code}`));\n return;\n }\n\n // Example of stdout\n //\n // ParentProcessId ProcessId\n // 0 777\n\n if (!stdout) {\n callback(new Error('No stdout received from wmic command'));\n return;\n }\n\n try {\n const lines = stdout.split(os.EOL);\n\n const list: ProcessList = [];\n for (let i = 1; i < lines.length; i++) {\n const trimmed = lines[i].trim();\n if (!trimmed) continue;\n const parts = trimmed.split(/\\s+/);\n const ppid = parseInt(parts[0], 10); // PPID\n const pid = parseInt(parts[1], 10); // PID\n if (!Number.isNaN(ppid) && !Number.isNaN(pid)) {\n list.push([ppid, pid]);\n }\n }\n\n callback(null, list);\n } catch (error) {\n callback(error instanceof Error ? error : new Error(String(error)));\n }\n });\n};\n"],"mappings":";;;;;;;;;;AAWA,MAAa,QAAQ,aAAwC;AAM3D,mCAAI,QALS;EAAC;EAAW;EAAO;EAA4B,EAC9B;EAC5B,aAAa;EACb,0BAA0B;EAC3B,GAC2B,KAAK,QAAQ,SAAS;AAChD,MAAI,KAAK;AACP,YAAS,IAAI;AACb;;AAGF,MAAI,SAAS,GAAG;AACd,4BAAS,IAAI,MAAM,yCAAyC,OAAO,CAAC;AACpE;;AAQF,MAAI,CAAC,QAAQ;AACX,4BAAS,IAAI,MAAM,uCAAuC,CAAC;AAC3D;;AAGF,MAAI;GACF,MAAM,QAAQ,OAAO,MAAMA,QAAG,IAAI;GAElC,MAAMC,OAAoB,EAAE;AAC5B,QAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;IACrC,MAAM,UAAU,MAAM,GAAG,MAAM;AAC/B,QAAI,CAAC,QAAS;IACd,MAAM,QAAQ,QAAQ,MAAM,MAAM;IAClC,MAAM,OAAO,SAAS,MAAM,IAAI,GAAG;IACnC,MAAM,MAAM,SAAS,MAAM,IAAI,GAAG;AAClC,QAAI,CAAC,OAAO,MAAM,KAAK,IAAI,CAAC,OAAO,MAAM,IAAI,CAC3C,MAAK,KAAK,CAAC,MAAM,IAAI,CAAC;;AAI1B,YAAS,MAAM,KAAK;WACb,OAAO;AACd,YAAS,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,MAAM,CAAC,CAAC;;GAErE"}
@@ -60,7 +60,7 @@ const getCallerDir = () => {
60
60
  * - './' or '../' is resolved relative to the *caller module's* emitted directory.
61
61
  * - otherwise, treat as src-relative.
62
62
  *
63
- * @param {string} relPath - e.g. './PROMPT.md' or 'utils/AI/askDocQuestion/embeddings.json'
63
+ * @param {string} relPath - e.g. './PROMPT.md' or 'utils/AI/askDocQuestion/embeddings/<fileKey>.json'
64
64
  * @param {BufferEncoding} [encoding='utf8']
65
65
  */
66
66
  const readAsset = (relPath, encoding = "utf8") => {
@@ -37,13 +37,14 @@ import { assembleJSON, chunkJSON, reconstructFromSingleChunk } from "./utils/chu
37
37
  import { getExtensionFromFormat, getFormatFromExtension } from "./utils/getFormatFromExtension.mjs";
38
38
  import { getGlobalLimiter, getTaskLimiter, parallelizeGlobal } from "./utils/parallelizeGlobal.mjs";
39
39
  import { reduceObjectFormat } from "./utils/reduceObjectFormat.mjs";
40
- import { runParallel } from "./utils/runParallel.mjs";
40
+ import { runParallel } from "./utils/runParallel/index.mjs";
41
41
  import { verifyIdenticObjectFormat } from "./utils/verifyIdenticObjectFormat.mjs";
42
42
  import { buildAndWatchIntlayer, watch } from "./watcher.mjs";
43
43
  import { detectExportedComponentName } from "./writeContentDeclaration/detectExportedComponentName.mjs";
44
44
  import { transformJSFile } from "./writeContentDeclaration/transformJSFile.mjs";
45
45
  import { processContentDeclarationContent } from "./writeContentDeclaration/processContentDeclarationContent.mjs";
46
+ import { detectFormatCommand } from "./writeContentDeclaration/detectFormatCommand.mjs";
46
47
  import { writeJSFile } from "./writeContentDeclaration/writeJSFile.mjs";
47
48
  import { writeContentDeclaration } from "./writeContentDeclaration/writeContentDeclaration.mjs";
48
49
 
49
- export { assembleJSON, buildAndWatchIntlayer, buildDictionary, chunkJSON, cleanOutputDir, createDictionaryEntryPoint, createModuleAugmentation, createTypes, detectExportedComponentName, fetchDistantDictionaries, formatLocale, formatPath, generateDictionaryListContent, getBuiltDictionariesPath, getBuiltDynamicDictionariesPath, getBuiltFetchDictionariesPath, getBuiltRemoteDictionariesPath, getBuiltUnmergedDictionariesPath, getChunk, getContentDeclarationFileTemplate, getExtensionFromFormat, getFileHash, getFormatFromExtension, getGlobalLimiter, getTaskLimiter, handleAdditionalContentDeclarationFile, handleContentDeclarationFileChange, handleUnlinkedContentDeclarationFile, isInvalidDictionary, kebabCaseToCamelCase, listDictionaries, listGitFiles, listGitLines, loadContentDeclarations, loadDictionaries, loadLocalDictionaries, loadRemoteDictionaries, pLimit, parallelize, parallelizeGlobal, prepareIntlayer, processContentDeclarationContent, reconstructFromSingleChunk, reduceDictionaryContent, reduceObjectFormat, resolveObjectPromises, runOnce, runParallel, sortAlphabetically, splitTextByLines, transformJSFile, verifyIdenticObjectFormat, watch, writeContentDeclaration, writeJSFile };
50
+ export { assembleJSON, buildAndWatchIntlayer, buildDictionary, chunkJSON, cleanOutputDir, createDictionaryEntryPoint, createModuleAugmentation, createTypes, detectExportedComponentName, detectFormatCommand, fetchDistantDictionaries, formatLocale, formatPath, generateDictionaryListContent, getBuiltDictionariesPath, getBuiltDynamicDictionariesPath, getBuiltFetchDictionariesPath, getBuiltRemoteDictionariesPath, getBuiltUnmergedDictionariesPath, getChunk, getContentDeclarationFileTemplate, getExtensionFromFormat, getFileHash, getFormatFromExtension, getGlobalLimiter, getTaskLimiter, handleAdditionalContentDeclarationFile, handleContentDeclarationFileChange, handleUnlinkedContentDeclarationFile, isInvalidDictionary, kebabCaseToCamelCase, listDictionaries, listGitFiles, listGitLines, loadContentDeclarations, loadDictionaries, loadLocalDictionaries, loadRemoteDictionaries, pLimit, parallelize, parallelizeGlobal, prepareIntlayer, processContentDeclarationContent, reconstructFromSingleChunk, reduceDictionaryContent, reduceObjectFormat, resolveObjectPromises, runOnce, runParallel, sortAlphabetically, splitTextByLines, transformJSFile, verifyIdenticObjectFormat, watch, writeContentDeclaration, writeJSFile };
@@ -0,0 +1,53 @@
1
+ import { spawn } from "node:child_process";
2
+
3
+ //#region src/utils/runParallel/bin.ts
4
+ const stripStderr = (stderr) => {
5
+ if (!stderr) return;
6
+ let cleaned = stderr.trim();
7
+ cleaned = cleaned.replace(/your \d+x\d+ screen size is bogus\. expect trouble/gi, "");
8
+ return cleaned.trim() || void 0;
9
+ };
10
+ /**
11
+ * Spawn a binary and read its stdout.
12
+ * @param cmd The name of the binary to spawn.
13
+ * @param args The arguments for the binary.
14
+ * @param options Optional option for the spawn function.
15
+ * @param done Callback function.
16
+ */
17
+ const run = (cmd, args, options, done) => {
18
+ let normalizedOptions;
19
+ let normalizedDone;
20
+ if (typeof options === "function") {
21
+ normalizedDone = options;
22
+ normalizedOptions = void 0;
23
+ } else {
24
+ normalizedDone = done;
25
+ normalizedOptions = options;
26
+ }
27
+ let executed = false;
28
+ const ch = spawn(cmd, args, normalizedOptions ?? {});
29
+ let stdout = "";
30
+ let stderr = "";
31
+ if (ch.stdout) ch.stdout.on("data", (d) => {
32
+ stdout += d.toString();
33
+ });
34
+ if (ch.stderr) ch.stderr.on("data", (d) => {
35
+ stderr += d.toString();
36
+ });
37
+ ch.on("error", (err) => {
38
+ if (executed) return;
39
+ executed = true;
40
+ normalizedDone(new Error(String(err)));
41
+ });
42
+ ch.on("close", (code) => {
43
+ if (executed) return;
44
+ executed = true;
45
+ const cleanedStderr = stripStderr(stderr);
46
+ if (cleanedStderr) return normalizedDone(new Error(cleanedStderr));
47
+ normalizedDone(null, stdout, code ?? void 0);
48
+ });
49
+ };
50
+
51
+ //#endregion
52
+ export { run };
53
+ //# sourceMappingURL=bin.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.mjs","names":["normalizedOptions: SpawnOptions | undefined","normalizedDone: BinCallback","ch: ChildProcess"],"sources":["../../../../src/utils/runParallel/bin.ts"],"sourcesContent":["import type { ChildProcess } from 'node:child_process';\nimport { type SpawnOptions, spawn } from 'node:child_process';\n\ntype BinCallback = (err: Error | null, stdout?: string, code?: number) => void;\n\nconst stripStderr = (stderr: string | undefined): string | undefined => {\n if (!stderr) return;\n let cleaned = stderr.trim();\n // Strip bogus screen size error.\n // See https://github.com/microsoft/vscode/issues/98590\n const regex = /your \\d+x\\d+ screen size is bogus\\. expect trouble/gi;\n cleaned = cleaned.replace(regex, '');\n\n return cleaned.trim() || undefined;\n};\n\n/**\n * Spawn a binary and read its stdout.\n * @param cmd The name of the binary to spawn.\n * @param args The arguments for the binary.\n * @param options Optional option for the spawn function.\n * @param done Callback function.\n */\nexport const run = (\n cmd: string,\n args: string[],\n options: SpawnOptions | BinCallback | undefined,\n done?: BinCallback\n): void => {\n let normalizedOptions: SpawnOptions | undefined;\n let normalizedDone: BinCallback;\n\n if (typeof options === 'function') {\n normalizedDone = options;\n normalizedOptions = undefined;\n } else {\n normalizedDone = done!;\n normalizedOptions = options;\n }\n\n let executed = false;\n const ch: ChildProcess = spawn(cmd, args, normalizedOptions ?? {});\n let stdout = '';\n let stderr = '';\n\n if (ch.stdout) {\n ch.stdout.on('data', (d: Buffer) => {\n stdout += d.toString();\n });\n }\n\n if (ch.stderr) {\n ch.stderr.on('data', (d: Buffer) => {\n stderr += d.toString();\n });\n }\n\n ch.on('error', (err: Error) => {\n if (executed) return;\n executed = true;\n normalizedDone(new Error(String(err)));\n });\n\n ch.on('close', (code: number | null) => {\n if (executed) return;\n executed = true;\n\n const cleanedStderr = stripStderr(stderr);\n if (cleanedStderr) {\n return normalizedDone(new Error(cleanedStderr));\n }\n\n normalizedDone(null, stdout, code ?? undefined);\n });\n};\n"],"mappings":";;;AAKA,MAAM,eAAe,WAAmD;AACtE,KAAI,CAAC,OAAQ;CACb,IAAI,UAAU,OAAO,MAAM;AAI3B,WAAU,QAAQ,QADJ,wDACmB,GAAG;AAEpC,QAAO,QAAQ,MAAM,IAAI;;;;;;;;;AAU3B,MAAa,OACX,KACA,MACA,SACA,SACS;CACT,IAAIA;CACJ,IAAIC;AAEJ,KAAI,OAAO,YAAY,YAAY;AACjC,mBAAiB;AACjB,sBAAoB;QACf;AACL,mBAAiB;AACjB,sBAAoB;;CAGtB,IAAI,WAAW;CACf,MAAMC,KAAmB,MAAM,KAAK,MAAM,qBAAqB,EAAE,CAAC;CAClE,IAAI,SAAS;CACb,IAAI,SAAS;AAEb,KAAI,GAAG,OACL,IAAG,OAAO,GAAG,SAAS,MAAc;AAClC,YAAU,EAAE,UAAU;GACtB;AAGJ,KAAI,GAAG,OACL,IAAG,OAAO,GAAG,SAAS,MAAc;AAClC,YAAU,EAAE,UAAU;GACtB;AAGJ,IAAG,GAAG,UAAU,QAAe;AAC7B,MAAI,SAAU;AACd,aAAW;AACX,iBAAe,IAAI,MAAM,OAAO,IAAI,CAAC,CAAC;GACtC;AAEF,IAAG,GAAG,UAAU,SAAwB;AACtC,MAAI,SAAU;AACd,aAAW;EAEX,MAAM,gBAAgB,YAAY,OAAO;AACzC,MAAI,cACF,QAAO,eAAe,IAAI,MAAM,cAAc,CAAC;AAGjD,iBAAe,MAAM,QAAQ,QAAQ,OAAU;GAC/C"}
@@ -0,0 +1,23 @@
1
+ //#region src/utils/runParallel/bootstrap.ts
2
+ const bootstrap = (_name) => {
3
+ switch (process.argv.slice(2)[0]) {
4
+ case void 0:
5
+ case "-h":
6
+ case "--help":
7
+ console.log("Help not implemented");
8
+ return;
9
+ case "-v":
10
+ case "--version":
11
+ console.log("Version not implemented");
12
+ return;
13
+ default:
14
+ process.stdout.setMaxListeners(0);
15
+ process.stderr.setMaxListeners(0);
16
+ process.stdin.setMaxListeners(0);
17
+ return;
18
+ }
19
+ };
20
+
21
+ //#endregion
22
+ export { bootstrap };
23
+ //# sourceMappingURL=bootstrap.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap.mjs","names":[],"sources":["../../../../src/utils/runParallel/bootstrap.ts"],"sourcesContent":["//------------------------------------------------------------------------------\n// Public Interface\n//------------------------------------------------------------------------------\n\nexport const bootstrap = (_name: string): void | Promise<void> => {\n const argv = process.argv.slice(2);\n\n switch (argv[0]) {\n case undefined:\n case '-h':\n case '--help':\n // Not needed for our use case\n console.log('Help not implemented');\n return;\n\n case '-v':\n case '--version':\n // Not needed for our use case\n console.log('Version not implemented');\n return;\n\n default:\n // https://github.com/mysticatea/npm-run-all/issues/105\n // Avoid MaxListenersExceededWarnings.\n process.stdout.setMaxListeners(0);\n process.stderr.setMaxListeners(0);\n process.stdin.setMaxListeners(0);\n return;\n }\n};\n"],"mappings":";AAIA,MAAa,aAAa,UAAwC;AAGhE,SAFa,QAAQ,KAAK,MAAM,EAAE,CAErB,IAAb;EACE,KAAK;EACL,KAAK;EACL,KAAK;AAEH,WAAQ,IAAI,uBAAuB;AACnC;EAEF,KAAK;EACL,KAAK;AAEH,WAAQ,IAAI,0BAA0B;AACtC;EAEF;AAGE,WAAQ,OAAO,gBAAgB,EAAE;AACjC,WAAQ,OAAO,gBAAgB,EAAE;AACjC,WAAQ,MAAM,gBAAgB,EAAE;AAChC"}
@@ -0,0 +1,109 @@
1
+ import { spawnPosix } from "./spawnPosix.mjs";
2
+ import { spawnWin32 } from "./spawnWin32.mjs";
3
+ import { delimiter, join } from "node:path";
4
+
5
+ //#region src/utils/runParallel/index.ts
6
+ /**
7
+ * Start a cross-platform parallel process using npm-run-all approach.
8
+ * Accepts either a single string (e.g., 'next start') or an array of tokens (e.g., ['next', 'start']).
9
+ */
10
+ const runParallel = (proc) => {
11
+ if (!proc || Array.isArray(proc) && proc.length === 0) throw new Error("Invalid command");
12
+ const commandText = Array.isArray(proc) ? proc.join(" ") : proc;
13
+ const isArray = Array.isArray(proc);
14
+ const command = isArray ? proc[0] : commandText;
15
+ const args = isArray ? proc.slice(1) : [];
16
+ const cwdBin = join(process.cwd(), "node_modules", ".bin");
17
+ const PATH_KEY = Object.keys(process.env).find((key) => key.toLowerCase() === "path") ?? "PATH";
18
+ const extendedPath = [cwdBin, process.env[PATH_KEY] ?? ""].filter(Boolean).join(delimiter);
19
+ const childEnv = {
20
+ ...process.env,
21
+ [PATH_KEY]: extendedPath
22
+ };
23
+ const isWin = process.platform === "win32";
24
+ const spawnFunc = isWin ? spawnWin32 : spawnPosix;
25
+ const spawnOptions = {
26
+ cwd: process.cwd(),
27
+ stdio: "inherit",
28
+ env: childEnv,
29
+ shell: false
30
+ };
31
+ const child = isArray ? args.length === 0 && /\s/.test(command) ? isWin ? spawnFunc(process.env.ComSpec ?? "cmd.exe", [
32
+ "/d",
33
+ "/s",
34
+ "/c",
35
+ command
36
+ ], spawnOptions) : spawnFunc(process.env.SHELL ?? "/bin/sh", ["-c", command], spawnOptions) : spawnFunc(command, args, spawnOptions) : isWin ? spawnFunc(process.env.ComSpec ?? "cmd.exe", [
37
+ "/d",
38
+ "/s",
39
+ "/c",
40
+ commandText
41
+ ], spawnOptions) : spawnFunc(process.env.SHELL ?? "/bin/sh", ["-c", commandText], spawnOptions);
42
+ const result = new Promise((resolve$1, reject) => {
43
+ child.on("error", (err) => {
44
+ try {
45
+ console.error(`[runParallel] Failed to start: ${err?.message ?? String(err)}`);
46
+ } catch {}
47
+ cleanupHandlers();
48
+ reject(err);
49
+ });
50
+ child.on("exit", (code, signal) => {
51
+ cleanupHandlers();
52
+ if (code === 0 || signal && [
53
+ "SIGINT",
54
+ "SIGTERM",
55
+ "SIGQUIT",
56
+ "SIGHUP"
57
+ ].includes(signal)) resolve$1();
58
+ else reject(Object.assign(/* @__PURE__ */ new Error("Parallel process failed"), {
59
+ code,
60
+ signal
61
+ }));
62
+ });
63
+ });
64
+ const cleanup = () => {
65
+ try {
66
+ child.kill("SIGTERM");
67
+ } catch {}
68
+ };
69
+ const signalHandlers = [
70
+ {
71
+ event: "SIGINT",
72
+ handler: cleanup
73
+ },
74
+ {
75
+ event: "SIGTERM",
76
+ handler: cleanup
77
+ },
78
+ {
79
+ event: "SIGQUIT",
80
+ handler: cleanup
81
+ },
82
+ {
83
+ event: "SIGHUP",
84
+ handler: cleanup
85
+ }
86
+ ];
87
+ signalHandlers.forEach(({ event, handler }) => {
88
+ process.on(event, handler);
89
+ });
90
+ const cleanupHandlers = () => {
91
+ signalHandlers.forEach(({ event, handler }) => {
92
+ process.off(event, handler);
93
+ });
94
+ };
95
+ const kill = () => {
96
+ try {
97
+ child.kill("SIGTERM");
98
+ } catch {}
99
+ };
100
+ return {
101
+ kill,
102
+ result,
103
+ commandText
104
+ };
105
+ };
106
+
107
+ //#endregion
108
+ export { runParallel };
109
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["signalHandlers: { event: string; handler: (...args: any[]) => void }[]"],"sources":["../../../../src/utils/runParallel/index.ts"],"sourcesContent":["import { delimiter, join } from 'node:path';\nimport { spawnPosix } from './spawnPosix';\nimport { spawnWin32 } from './spawnWin32';\n\nexport type ParallelHandle = {\n kill: () => void;\n result: Promise<any>;\n commandText: string;\n};\n\n/**\n * Start a cross-platform parallel process using npm-run-all approach.\n * Accepts either a single string (e.g., 'next start') or an array of tokens (e.g., ['next', 'start']).\n */\nexport const runParallel = (proc?: string | string[]): ParallelHandle => {\n if (!proc || (Array.isArray(proc) && proc.length === 0))\n throw new Error('Invalid command');\n\n const commandText = Array.isArray(proc) ? proc.join(' ') : proc;\n\n const isArray = Array.isArray(proc);\n const command = isArray ? (proc as string[])[0] : commandText;\n const args = isArray ? (proc as string[]).slice(1) : [];\n\n // Ensure local binaries (node_modules/.bin) are resolvable\n const cwdBin = join(process.cwd(), 'node_modules', '.bin');\n const PATH_KEY =\n Object.keys(process.env).find((key) => key.toLowerCase() === 'path') ??\n 'PATH';\n\n const extendedPath = [cwdBin, process.env[PATH_KEY] ?? '']\n .filter(Boolean)\n .join(delimiter);\n\n const childEnv = {\n ...process.env,\n [PATH_KEY]: extendedPath,\n } as NodeJS.ProcessEnv;\n\n const isWin = process.platform === 'win32';\n const spawnFunc = isWin ? spawnWin32 : spawnPosix;\n\n // Spawn options\n const spawnOptions = {\n cwd: process.cwd(),\n stdio: 'inherit' as const,\n env: childEnv,\n shell: false,\n };\n\n // Spawn the child process\n const child = isArray\n ? // If provided as a single string element that includes spaces, treat it like a shell command\n args.length === 0 && /\\s/.test(command)\n ? isWin\n ? spawnFunc(\n process.env.ComSpec ?? 'cmd.exe',\n ['/d', '/s', '/c', command],\n spawnOptions\n )\n : spawnFunc(\n process.env.SHELL ?? '/bin/sh',\n ['-c', command],\n spawnOptions\n )\n : spawnFunc(command, args, spawnOptions)\n : isWin\n ? spawnFunc(\n process.env.ComSpec ?? 'cmd.exe',\n ['/d', '/s', '/c', commandText],\n spawnOptions\n )\n : spawnFunc(\n process.env.SHELL ?? '/bin/sh',\n ['-c', commandText],\n spawnOptions\n );\n\n const result = new Promise<void>((resolve, reject) => {\n child.on('error', (err) => {\n try {\n console.error(\n `[runParallel] Failed to start: ${err?.message ?? String(err)}`\n );\n } catch {}\n cleanupHandlers();\n reject(err);\n });\n\n child.on('exit', (code, signal) => {\n cleanupHandlers();\n\n // Treat common termination signals as graceful exits, not failures\n const gracefulSignals = ['SIGINT', 'SIGTERM', 'SIGQUIT', 'SIGHUP'];\n if (code === 0 || (signal && gracefulSignals.includes(signal))) {\n resolve();\n } else {\n reject(\n Object.assign(new Error('Parallel process failed'), { code, signal })\n );\n }\n });\n });\n\n const cleanup = () => {\n try {\n child.kill('SIGTERM');\n } catch {\n // Best effort\n }\n };\n\n const signalHandlers: { event: string; handler: (...args: any[]) => void }[] =\n [\n { event: 'SIGINT', handler: cleanup },\n { event: 'SIGTERM', handler: cleanup },\n { event: 'SIGQUIT', handler: cleanup },\n { event: 'SIGHUP', handler: cleanup },\n ];\n\n // Register signal handlers\n signalHandlers.forEach(({ event, handler }) => {\n process.on(event as any, handler as any);\n });\n\n const cleanupHandlers = () => {\n signalHandlers.forEach(({ event, handler }) => {\n process.off(event as any, handler as any);\n });\n };\n\n const kill = () => {\n try {\n child.kill('SIGTERM');\n } catch {\n // Best effort\n }\n };\n\n return { kill, result, commandText };\n};\n"],"mappings":";;;;;;;;;AAcA,MAAa,eAAe,SAA6C;AACvE,KAAI,CAAC,QAAS,MAAM,QAAQ,KAAK,IAAI,KAAK,WAAW,EACnD,OAAM,IAAI,MAAM,kBAAkB;CAEpC,MAAM,cAAc,MAAM,QAAQ,KAAK,GAAG,KAAK,KAAK,IAAI,GAAG;CAE3D,MAAM,UAAU,MAAM,QAAQ,KAAK;CACnC,MAAM,UAAU,UAAW,KAAkB,KAAK;CAClD,MAAM,OAAO,UAAW,KAAkB,MAAM,EAAE,GAAG,EAAE;CAGvD,MAAM,SAAS,KAAK,QAAQ,KAAK,EAAE,gBAAgB,OAAO;CAC1D,MAAM,WACJ,OAAO,KAAK,QAAQ,IAAI,CAAC,MAAM,QAAQ,IAAI,aAAa,KAAK,OAAO,IACpE;CAEF,MAAM,eAAe,CAAC,QAAQ,QAAQ,IAAI,aAAa,GAAG,CACvD,OAAO,QAAQ,CACf,KAAK,UAAU;CAElB,MAAM,WAAW;EACf,GAAG,QAAQ;GACV,WAAW;EACb;CAED,MAAM,QAAQ,QAAQ,aAAa;CACnC,MAAM,YAAY,QAAQ,aAAa;CAGvC,MAAM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,cAAc;AAC7C,WAAQ,IAAI,OAAc,QAAe;IACzC;;CAGJ,MAAM,aAAa;AACjB,MAAI;AACF,SAAM,KAAK,UAAU;UACf;;AAKV,QAAO;EAAE;EAAM;EAAQ;EAAa"}
@@ -0,0 +1,143 @@
1
+ import { ps } from "./ps.mjs";
2
+ import { wmic } from "./wmic.mjs";
3
+ import * as os from "node:os";
4
+
5
+ //#region src/utils/runParallel/pidTree.ts
6
+ const platformToMethod = {
7
+ darwin: "ps",
8
+ sunos: "ps",
9
+ freebsd: "ps",
10
+ netbsd: "ps",
11
+ win: "wmic",
12
+ linux: "ps",
13
+ aix: "ps"
14
+ };
15
+ const methodToFn = {
16
+ ps,
17
+ wmic
18
+ };
19
+ let platform = os.platform();
20
+ if (platform.startsWith("win")) platform = "win";
21
+ const method = platformToMethod[platform];
22
+ /**
23
+ * Gets the list of all the pids of the system.
24
+ */
25
+ const getAll = (callback) => {
26
+ if (method === void 0) {
27
+ callback(/* @__PURE__ */ new Error(os.platform() + " is not supported yet, please open an issue (https://github.com/simonepri/pidtree)"), void 0);
28
+ return;
29
+ }
30
+ const listFn = methodToFn[method];
31
+ listFn(callback);
32
+ };
33
+ /**
34
+ * Get the list of children and grandchildren pids of the given PID.
35
+ * @param PID A PID. If -1 will return all the pids.
36
+ * @param options Optional options object.
37
+ * @param callback Called when the list is ready.
38
+ */
39
+ const pidtree = (PID, options, callback) => {
40
+ let normalizedOptions;
41
+ let normalizedCallback;
42
+ if (typeof options === "function") {
43
+ normalizedCallback = options;
44
+ normalizedOptions = {};
45
+ } else {
46
+ normalizedCallback = callback;
47
+ normalizedOptions = typeof options === "object" ? options : {};
48
+ }
49
+ const parsedPID = parseInt(String(PID), 10);
50
+ if (Number.isNaN(parsedPID) || parsedPID < -1) {
51
+ normalizedCallback(/* @__PURE__ */ new TypeError("The pid provided is invalid"), void 0);
52
+ return;
53
+ }
54
+ getAll((err, processList) => {
55
+ if (err) {
56
+ normalizedCallback(err, void 0);
57
+ return;
58
+ }
59
+ if (!processList) {
60
+ normalizedCallback(/* @__PURE__ */ new Error("Failed to get process list"), void 0);
61
+ return;
62
+ }
63
+ if (parsedPID === -1) {
64
+ const result = processList.map(([ppid, pid]) => normalizedOptions.advanced ? {
65
+ ppid,
66
+ pid
67
+ } : pid);
68
+ normalizedCallback(null, result);
69
+ return;
70
+ }
71
+ let root;
72
+ for (let l = 0; l < processList.length; l++) {
73
+ if (processList[l][1] === parsedPID) {
74
+ root = normalizedOptions.advanced ? {
75
+ ppid: processList[l][0],
76
+ pid: parsedPID
77
+ } : parsedPID;
78
+ break;
79
+ }
80
+ if (processList[l][0] === parsedPID) root = normalizedOptions.advanced ? { pid: parsedPID } : parsedPID;
81
+ }
82
+ if (root === void 0) {
83
+ normalizedCallback(/* @__PURE__ */ new Error("No matching pid found"), void 0);
84
+ return;
85
+ }
86
+ const tree = {};
87
+ const listCopy = [...processList];
88
+ while (listCopy.length > 0) {
89
+ const element = listCopy.pop();
90
+ if (tree[element[0]]) tree[element[0]].push(element[1]);
91
+ else tree[element[0]] = [element[1]];
92
+ }
93
+ let idx = 0;
94
+ const pids = [root];
95
+ while (idx < pids.length) {
96
+ const curpid = normalizedOptions.advanced ? pids[idx++].pid : pids[idx++];
97
+ if (!tree[curpid]) continue;
98
+ const length = tree[curpid].length;
99
+ for (let j = 0; j < length; j++) pids.push(normalizedOptions.advanced ? {
100
+ ppid: curpid,
101
+ pid: tree[curpid][j]
102
+ } : tree[curpid][j]);
103
+ delete tree[curpid];
104
+ }
105
+ if (!normalizedOptions.root) pids.shift();
106
+ normalizedCallback(null, pids);
107
+ });
108
+ };
109
+ const pify = (fn, arg1, arg2) => {
110
+ return new Promise((resolve, reject) => {
111
+ fn(arg1, arg2, (err, data) => {
112
+ if (err) return reject(err);
113
+ if (data === void 0) return reject(/* @__PURE__ */ new Error("No data returned"));
114
+ resolve(data);
115
+ });
116
+ });
117
+ };
118
+ /* istanbul ignore if */
119
+ if (!String.prototype.startsWith) String.prototype.startsWith = function(suffix) {
120
+ return this.substring(0, suffix.length) === suffix;
121
+ };
122
+ /**
123
+ * Get the list of children pids of the given pid.
124
+ * @param pid A PID. If -1 will return all the pids.
125
+ * @param options Optional options object.
126
+ * @param callback Called when the list is ready. If not provided a promise is returned instead.
127
+ * @returns Only when the callback is not provided.
128
+ */
129
+ const list = (pid, options, callback) => {
130
+ if (typeof options === "function") {
131
+ pidtree(pid, void 0, options);
132
+ return;
133
+ }
134
+ if (typeof callback === "function") {
135
+ pidtree(pid, options, callback);
136
+ return;
137
+ }
138
+ return pify(pidtree, pid, options);
139
+ };
140
+
141
+ //#endregion
142
+ export { list };
143
+ //# sourceMappingURL=pidTree.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pidTree.mjs","names":["platformToMethod: Record<Platform, Method>","methodToFn: Record<Method, ProcessListFn>","platform: string","method: Method | undefined","normalizedOptions: ListOptions","normalizedCallback: ListCallback<T>","root: ProcessInfo | number | undefined","tree: Record<number, number[]>","pids: (ProcessInfo | number)[]"],"sources":["../../../../src/utils/runParallel/pidTree.ts"],"sourcesContent":["import * as os from 'node:os';\nimport { ps } from './ps';\nimport { wmic } from './wmic';\n\ntype Platform =\n | 'darwin'\n | 'sunos'\n | 'freebsd'\n | 'netbsd'\n | 'win'\n | 'linux'\n | 'aix';\ntype Method = 'ps' | 'wmic';\n\ntype ProcessList = [number, number][]; // [PPID, PID][]\n\ninterface ListOptions {\n root?: boolean;\n advanced?: boolean;\n}\n\ntype ProcessInfo = { pid: number; ppid?: number };\ntype ResultType<T extends ListOptions | undefined> = T extends {\n advanced: true;\n}\n ? ProcessInfo[]\n : number[];\n\ntype ProcessListCallback = (err: Error | null, list?: ProcessList) => void;\ntype ListCallback<T extends ListOptions | undefined> = (\n err: Error | null,\n list?: ResultType<T>\n) => void;\n\ntype ProcessListFn = (callback: ProcessListCallback) => void;\n\nconst platformToMethod: Record<Platform, Method> = {\n darwin: 'ps',\n sunos: 'ps',\n freebsd: 'ps',\n netbsd: 'ps',\n win: 'wmic',\n linux: 'ps',\n aix: 'ps',\n};\n\nconst methodToFn: Record<Method, ProcessListFn> = {\n ps,\n wmic,\n};\n\nlet platform: string = os.platform();\nif (platform.startsWith('win')) {\n platform = 'win';\n}\n\nconst method: Method | undefined = platformToMethod[platform as Platform];\n\n/**\n * Gets the list of all the pids of the system.\n */\nconst getAll = (callback: ProcessListCallback): void => {\n if (method === undefined) {\n callback(\n new Error(\n os.platform() +\n ' is not supported yet, please open an issue (https://github.com/simonepri/pidtree)'\n ),\n undefined\n );\n return;\n }\n\n const listFn = methodToFn[method];\n listFn(callback);\n};\n\n/**\n * Get the list of children and grandchildren pids of the given PID.\n * @param PID A PID. If -1 will return all the pids.\n * @param options Optional options object.\n * @param callback Called when the list is ready.\n */\nconst pidtree = <T extends ListOptions | undefined>(\n PID: number | string,\n options: T | ListCallback<T> | undefined,\n callback?: ListCallback<T>\n): void => {\n let normalizedOptions: ListOptions;\n let normalizedCallback: ListCallback<T>;\n\n if (typeof options === 'function') {\n normalizedCallback = options;\n normalizedOptions = {};\n } else {\n normalizedCallback = callback!;\n normalizedOptions = typeof options === 'object' ? options : {};\n }\n\n const parsedPID = parseInt(String(PID), 10);\n if (Number.isNaN(parsedPID) || parsedPID < -1) {\n normalizedCallback(\n new TypeError('The pid provided is invalid') as Error,\n undefined\n );\n return;\n }\n\n getAll((err, processList) => {\n if (err) {\n normalizedCallback(err, undefined);\n return;\n }\n\n if (!processList) {\n normalizedCallback(new Error('Failed to get process list'), undefined);\n return;\n }\n\n // If the user wants the whole list just return it\n if (parsedPID === -1) {\n const result = processList.map(([ppid, pid]) =>\n normalizedOptions.advanced ? { ppid, pid } : pid\n ) as ResultType<T>;\n\n normalizedCallback(null, result);\n return;\n }\n\n let root: ProcessInfo | number | undefined;\n for (let l = 0; l < processList.length; l++) {\n if (processList[l][1] === parsedPID) {\n root = normalizedOptions.advanced\n ? { ppid: processList[l][0], pid: parsedPID }\n : parsedPID;\n break;\n }\n\n if (processList[l][0] === parsedPID) {\n root = normalizedOptions.advanced ? { pid: parsedPID } : parsedPID; // Special pids like 0 on *nix\n }\n }\n\n if (root === undefined) {\n normalizedCallback(new Error('No matching pid found'), undefined);\n return;\n }\n\n // Build the adjacency Hash Map (pid -> [children of pid])\n const tree: Record<number, number[]> = {};\n const listCopy = [...processList];\n while (listCopy.length > 0) {\n const element = listCopy.pop()!;\n if (tree[element[0]]) {\n tree[element[0]].push(element[1]);\n } else {\n tree[element[0]] = [element[1]];\n }\n }\n\n // Starting by the PID provided by the user, traverse the tree using the\n // adjacency Hash Map until the whole subtree is visited.\n // Each pid encountered while visiting is added to the pids array.\n let idx = 0;\n const pids: (ProcessInfo | number)[] = [root];\n while (idx < pids.length) {\n const curpid = normalizedOptions.advanced\n ? (pids[idx++] as ProcessInfo).pid\n : (pids[idx++] as number);\n if (!tree[curpid]) continue;\n const length = tree[curpid].length;\n for (let j = 0; j < length; j++) {\n pids.push(\n normalizedOptions.advanced\n ? { ppid: curpid, pid: tree[curpid][j] }\n : tree[curpid][j]\n );\n }\n\n delete tree[curpid];\n }\n\n if (!normalizedOptions.root) {\n pids.shift(); // Remove root\n }\n\n normalizedCallback(null, pids as ResultType<T>);\n });\n};\n\nconst pify = <T extends ListOptions | undefined>(\n fn: typeof pidtree,\n arg1: number | string,\n arg2: T | undefined\n): Promise<ResultType<T>> => {\n return new Promise((resolve, reject) => {\n fn(arg1, arg2, (err, data) => {\n if (err) return reject(err);\n if (data === undefined) {\n return reject(new Error('No data returned'));\n }\n resolve(data);\n });\n });\n};\n\n// Node versions prior to 4.0.0 do not define have `startsWith`.\n/* istanbul ignore if */\nif (!String.prototype.startsWith) {\n String.prototype.startsWith = function (suffix: string): boolean {\n return this.substring(0, suffix.length) === suffix;\n };\n}\n\n/**\n * Get the list of children pids of the given pid.\n * @param pid A PID. If -1 will return all the pids.\n * @param options Optional options object.\n * @param callback Called when the list is ready. If not provided a promise is returned instead.\n * @returns Only when the callback is not provided.\n */\nexport const list = <T extends ListOptions | undefined>(\n pid: number | string,\n options?: T | ListCallback<T>,\n callback?: ListCallback<T>\n): Promise<ResultType<T>> | undefined => {\n if (typeof options === 'function') {\n pidtree(pid, undefined, options);\n return;\n }\n\n if (typeof callback === 'function') {\n pidtree(pid, options, callback);\n return;\n }\n\n return pify(pidtree, pid, options);\n};\n"],"mappings":";;;;;AAoCA,MAAMA,mBAA6C;CACjD,QAAQ;CACR,OAAO;CACP,SAAS;CACT,QAAQ;CACR,KAAK;CACL,OAAO;CACP,KAAK;CACN;AAED,MAAMC,aAA4C;CAChD;CACA;CACD;AAED,IAAIC,WAAmB,GAAG,UAAU;AACpC,IAAI,SAAS,WAAW,MAAM,CAC5B,YAAW;AAGb,MAAMC,SAA6B,iBAAiB;;;;AAKpD,MAAM,UAAU,aAAwC;AACtD,KAAI,WAAW,QAAW;AACxB,2BACE,IAAI,MACF,GAAG,UAAU,GACX,qFACH,EACD,OACD;AACD;;CAGF,MAAM,SAAS,WAAW;AAC1B,QAAO,SAAS;;;;;;;;AASlB,MAAM,WACJ,KACA,SACA,aACS;CACT,IAAIC;CACJ,IAAIC;AAEJ,KAAI,OAAO,YAAY,YAAY;AACjC,uBAAqB;AACrB,sBAAoB,EAAE;QACjB;AACL,uBAAqB;AACrB,sBAAoB,OAAO,YAAY,WAAW,UAAU,EAAE;;CAGhE,MAAM,YAAY,SAAS,OAAO,IAAI,EAAE,GAAG;AAC3C,KAAI,OAAO,MAAM,UAAU,IAAI,YAAY,IAAI;AAC7C,qCACE,IAAI,UAAU,8BAA8B,EAC5C,OACD;AACD;;AAGF,SAAQ,KAAK,gBAAgB;AAC3B,MAAI,KAAK;AACP,sBAAmB,KAAK,OAAU;AAClC;;AAGF,MAAI,CAAC,aAAa;AAChB,sCAAmB,IAAI,MAAM,6BAA6B,EAAE,OAAU;AACtE;;AAIF,MAAI,cAAc,IAAI;GACpB,MAAM,SAAS,YAAY,KAAK,CAAC,MAAM,SACrC,kBAAkB,WAAW;IAAE;IAAM;IAAK,GAAG,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