@titanpl/core 2.1.1 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.d.ts +20 -0
  2. package/index.js +3 -1
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -419,6 +419,26 @@ declare global {
419
419
  uptime(): number;
420
420
  /** Memory usage statistics. */
421
421
  memory(): Record<string, any>;
422
+ /**
423
+ * Spawn a subprocess.
424
+ * @param command The executable to run.
425
+ * @param args Arguments to pass.
426
+ * @returns Object containing the PID of the spawned process, e.g. `{ pid: 1234 }`.
427
+ */
428
+ run(command: string, args: string[]): { pid: number };
429
+
430
+ /**
431
+ * Kill a process by PID.
432
+ * @param pid Process ID to kill.
433
+ * @returns True if the signal was sent successfully.
434
+ */
435
+ kill(pid: number): boolean;
436
+
437
+ /**
438
+ * List running processes.
439
+ * @returns Array of process information objects.
440
+ */
441
+ list(): Array<{ pid: number, name: string, cmd: string, cpu?: number, memory?: number }>;
422
442
  }
423
443
 
424
444
  // ==================== Time ====================
package/index.js CHANGED
@@ -561,7 +561,9 @@ const proc = {
561
561
  if (typeof res === 'string' && res.startsWith("ERROR:")) throw new Error(res);
562
562
  try {
563
563
  return JSON.parse(res);
564
- } catch (e) { return {}; }
564
+ } catch (e) {
565
+ throw new Error(`Failed to parse process response: ${res}`);
566
+ }
565
567
  },
566
568
  kill: (pid) => {
567
569
  if (!native_proc_kill) return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@titanpl/core",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "The official Core Standard Library for Titan Planet - provides fs, path, crypto, os, net, proc, time, and url modules",
5
5
  "main": "index.js",
6
6
  "type": "module",