@gjsify/process 0.30.0 → 0.31.0
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../_virtual/_rolldown/runtime.js";import{getGjsGlobal as e}from"./gjs.js";import{probeUname as t}from"./uname.js";function detectGjsVersion(){try{let t=e().imports?.system;if(t?.version!==void 0){let e=Number(t.version);return`${Math.floor(e/1e4)}.${Math.floor(e%1e4/100)}.${e%100}`}}catch{}}function detectNodeVersion(){if(typeof globalThis.process?.versions?.node==`string`)return globalThis.process.versions.node}function detectVersionInfo(){if(detectNodeVersion())return{version:globalThis.process.version,versions:{...globalThis.process.versions},title:globalThis.process?.title||`node`};let e=detectGjsVersion(),t={node:`20.0.0`};return e&&(t.gjs=e),{version:`v20.0.0`,versions:t,title:`gjs`}}function detectPpid(){
|
|
1
|
+
import"../_virtual/_rolldown/runtime.js";import{getGjsGlobal as e}from"./gjs.js";import{probeUname as t}from"./uname.js";import{hostPid as n,hostPpid as r}from"@gjsify/utils/core";function detectGjsVersion(){try{let t=e().imports?.system;if(t?.version!==void 0){let e=Number(t.version);return`${Math.floor(e/1e4)}.${Math.floor(e%1e4/100)}.${e%100}`}}catch{}}function detectNodeVersion(){if(typeof globalThis.process?.versions?.node==`string`)return globalThis.process.versions.node}function detectVersionInfo(){if(detectNodeVersion())return{version:globalThis.process.version,versions:{...globalThis.process.versions},title:globalThis.process?.title||`node`};let e=detectGjsVersion(),t={node:`20.0.0`};return e&&(t.gjs=e),{version:`v20.0.0`,versions:t,title:`gjs`}}function detectPpid(){return!onGjs()&&typeof globalThis.process?.ppid==`number`?globalThis.process.ppid:r()??0}function onGjs(){try{return e().imports?.gi!==void 0}catch{return!1}}function detectPlatform(){if(onGjs()){let e=t();return e?e.platform:`linux`}let e=globalThis.process;return typeof e?.platform==`string`?e.platform:`linux`}function detectArch(){if(onGjs()){let e=t();return e?e.arch:`x64`}let e=globalThis.process;return typeof e?.arch==`string`?e.arch:`x64`}function getPid(){return!onGjs()&&typeof globalThis.process?.pid==`number`?globalThis.process.pid:n()??0}export{detectArch,detectGjsVersion,detectNodeVersion,detectPlatform,detectPpid,detectVersionInfo,getPid};
|
package/lib/esm/internal/env.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../_virtual/_rolldown/runtime.js";import{getGjsGlobal as e}from"./gjs.js";function getEnvProxy(){if(typeof globalThis.process?.env==`object`)return globalThis.process.env;try{let t=e().imports?.gi?.GLib;if(t)return new Proxy({},{get(e,n){if(typeof n==`string`)return t.getenv(n)??void 0},set(e,n,r){return typeof n==`string`?(t.setenv(n,String(r),!0),!0):!1},deleteProperty(e,n){return typeof n==`string`?(t.unsetenv(n),!0):!1},has(e,n){return typeof n==`string`?t.getenv(n)!==null:!1},ownKeys(e){return t.listenv()},getOwnPropertyDescriptor(e,n){if(typeof n!=`string`)return;let r=t.getenv(n);if(r!==null)return{configurable:!0,enumerable:!0,writable:!0,value:r}}})}catch{}return{}}function getArgv(){if(globalThis.process?.argv!==void 0)return globalThis.process.argv;try{let t=e().imports?.system;if(t?.programArgs)return[`gjs`,t.programInvocationName||``,...t.programArgs]}catch{}return[`gjs`]}function getExecPath(){
|
|
1
|
+
import"../_virtual/_rolldown/runtime.js";import{getGjsGlobal as e}from"./gjs.js";import{hostExecPath as t}from"@gjsify/utils/core";function getEnvProxy(){if(typeof globalThis.process?.env==`object`)return globalThis.process.env;try{let t=e().imports?.gi?.GLib;if(t)return new Proxy({},{get(e,n){if(typeof n==`string`)return t.getenv(n)??void 0},set(e,n,r){return typeof n==`string`?(t.setenv(n,String(r),!0),!0):!1},deleteProperty(e,n){return typeof n==`string`?(t.unsetenv(n),!0):!1},has(e,n){return typeof n==`string`?t.getenv(n)!==null:!1},ownKeys(e){return t.listenv()},getOwnPropertyDescriptor(e,n){if(typeof n!=`string`)return;let r=t.getenv(n);if(r!==null)return{configurable:!0,enumerable:!0,writable:!0,value:r}}})}catch{}return{}}function getArgv(){if(globalThis.process?.argv!==void 0)return globalThis.process.argv;try{let t=e().imports?.system;if(t?.programArgs)return[`gjs`,t.programInvocationName||``,...t.programArgs]}catch{}return[`gjs`]}function getExecPath(){let e=globalThis.process;return!isGjsHost()&&typeof e?.execPath==`string`?e.execPath:t()??`/usr/bin/gjs`}function isGjsHost(){try{return e().imports?.gi!==void 0}catch{return!1}}function getCwd(){try{let t=e().imports?.gi?.GLib;if(t?.get_current_dir)return t.get_current_dir()}catch{}return`/`}function chdir(t){let n=e().imports?.gi?.GLib;try{if(n?.chdir){if(!n.file_test(t,16)){let e=Error(`ENOENT: no such file or directory, chdir '${t}'`);throw e.code=`ENOENT`,e.syscall=`chdir`,e.path=t,e}n.chdir(t);return}}catch(e){if(e&&typeof e==`object`&&e.code===`ENOENT`)throw e}if(!n){let e=globalThis.process;if(e&&typeof e.chdir==`function`){e.chdir(t);return}}throw Error(`process.chdir() is not supported in this environment`)}export{chdir,getArgv,getCwd,getEnvProxy,getExecPath};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../_virtual/_rolldown/runtime.js";import{getGjsGlobal as e}from"./gjs.js";function isGjs(){return e().imports?.gi?.GLib!==void 0}function killPid(t,n){try{let r=e().imports?.gi?.GLib;if(r){let e=typeof n==`number`?String(n):n||`SIGTERM`,i=e.startsWith(`SIG`)?`-${e.slice(3)}`:`-${e}`;return r.spawn_command_line_sync(`kill ${i} ${t}`),!0}}catch{}if(!isGjs()){let e=globalThis.process;if(e&&typeof e.kill==`function`)return e.kill(t,n)}throw Error(`process.kill() is not supported in this environment`)}function memoryUsage(){
|
|
1
|
+
import"../_virtual/_rolldown/runtime.js";import{getGjsGlobal as e}from"./gjs.js";import{readProcessMemory as t}from"@gjsify/utils/core";function isGjs(){return e().imports?.gi?.GLib!==void 0}function killPid(t,n){try{let r=e().imports?.gi?.GLib;if(r){let e=typeof n==`number`?String(n):n||`SIGTERM`,i=e.startsWith(`SIG`)?`-${e.slice(3)}`:`-${e}`;return r.spawn_command_line_sync(`kill ${i} ${t}`),!0}}catch{}if(!isGjs()){let e=globalThis.process;if(e&&typeof e.kill==`function`)return e.kill(t,n)}throw Error(`process.kill() is not supported in this environment`)}function memoryUsage(){let e=t();if(e)return{rss:e.resident,heapTotal:e.resident,heapUsed:e.resident,external:0,arrayBuffers:0};if(!isGjs()){let e=globalThis.process;if(e&&typeof e.memoryUsage==`function`)return e.memoryUsage()}return{rss:0,heapTotal:0,heapUsed:0,external:0,arrayBuffers:0}}function cpuUsage(e){if(!isGjs()){let t=globalThis.process;if(t&&typeof t.cpuUsage==`function`)return t.cpuUsage(e)}return{user:0,system:0}}export{cpuUsage,killPid,memoryUsage};
|
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
export declare function getEnvProxy(): Record<string, string | undefined>;
|
|
2
2
|
export declare function getArgv(): string[];
|
|
3
|
+
/**
|
|
4
|
+
* Node's `process.execPath` — the absolute path of the INTERPRETER, not of the
|
|
5
|
+
* script it is running.
|
|
6
|
+
*
|
|
7
|
+
* This used to return `imports.system.programInvocationName`, which is the
|
|
8
|
+
* ENTRY MODULE (the same value `getArgv()` above puts in `argv[1]`, and says so).
|
|
9
|
+
* The two are different questions and the wrong answer is load-bearing:
|
|
10
|
+
* `spawn(process.execPath, […])` is the documented portable way to start a
|
|
11
|
+
* second copy of the current runtime, and against a bundle path it fails
|
|
12
|
+
* `ENOENT` — or, because `g_spawn` retries a non-executable text file through
|
|
13
|
+
* `/bin/sh`, hands a megabyte of JavaScript to the shell.
|
|
14
|
+
*
|
|
15
|
+
* Nor is `/usr/bin/gjs` a defensible fallback: no macOS host has that path
|
|
16
|
+
* (Homebrew installs to `/usr/local/bin` or `/opt/homebrew/bin`), so the
|
|
17
|
+
* "default" was a Linux literal wearing a default's clothes. `hostExecPath()`
|
|
18
|
+
* resolves the real one; the literal remains only as the last resort for a host
|
|
19
|
+
* that answers nothing at all, where any string is equally wrong and Node's
|
|
20
|
+
* type says it must be a string.
|
|
21
|
+
*/
|
|
3
22
|
export declare function getExecPath(): string;
|
|
4
23
|
export declare function getCwd(): string;
|
|
5
24
|
export declare function chdir(directory: string): void;
|
|
@@ -6,6 +6,16 @@ export interface MemoryUsage {
|
|
|
6
6
|
external: number;
|
|
7
7
|
arrayBuffers: number;
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Node-shaped `process.memoryUsage()`.
|
|
11
|
+
*
|
|
12
|
+
* SpiderMonkey exposes no per-heap accounting to JS, so `heapTotal`/`heapUsed`
|
|
13
|
+
* are approximated from the OS's view of the whole process — the same
|
|
14
|
+
* approximation `@gjsify/v8`'s `getHeapStatistics()` makes, from the same
|
|
15
|
+
* reader, which is why the reader lives in `@gjsify/utils/core` and not here.
|
|
16
|
+
* Before that lift this function read `/proc/self/status` inline and therefore
|
|
17
|
+
* reported `rss: 0` on every macOS host.
|
|
18
|
+
*/
|
|
9
19
|
export declare function memoryUsage(): MemoryUsage;
|
|
10
20
|
export interface CpuUsage {
|
|
11
21
|
user: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/process",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"description": "Node.js process module for Gjs",
|
|
5
5
|
"module": "lib/esm/index.js",
|
|
6
6
|
"types": "lib/types/index.d.ts",
|
|
@@ -40,14 +40,14 @@
|
|
|
40
40
|
"process"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@gjsify/events": "^0.
|
|
44
|
-
"@gjsify/string_decoder": "^0.
|
|
45
|
-
"@gjsify/terminal-native": "^0.
|
|
46
|
-
"@gjsify/utils": "^0.
|
|
43
|
+
"@gjsify/events": "^0.31.0",
|
|
44
|
+
"@gjsify/string_decoder": "^0.31.0",
|
|
45
|
+
"@gjsify/terminal-native": "^0.31.0",
|
|
46
|
+
"@gjsify/utils": "^0.31.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@gjsify/cli": "^0.
|
|
50
|
-
"@gjsify/unit": "^0.
|
|
49
|
+
"@gjsify/cli": "^0.31.0",
|
|
50
|
+
"@gjsify/unit": "^0.31.0",
|
|
51
51
|
"@types/node": "^25.9.2",
|
|
52
52
|
"typescript": "^6.0.3"
|
|
53
53
|
},
|
|
@@ -58,7 +58,15 @@
|
|
|
58
58
|
"browser": "polyfill",
|
|
59
59
|
"nativescript": "polyfill"
|
|
60
60
|
},
|
|
61
|
-
"tier": 1
|
|
61
|
+
"tier": 1,
|
|
62
|
+
"os": {
|
|
63
|
+
"linux": "supported",
|
|
64
|
+
"darwin": "supported",
|
|
65
|
+
"win32": "partial"
|
|
66
|
+
},
|
|
67
|
+
"osNotes": {
|
|
68
|
+
"win32": "Under Node the platform comes from the host itself and is authoritative. Under GJS it comes from a `uname` probe, which is POSIX-only — `mapSysname` maps a MINGW/MSYS sysname to `win32`, but no GJS host exists on Windows to produce one, so that path is unexercised. Measured on the win11-gjsify VM: 6 of 167 specs fail, all POSIX assumptions in the SPECS."
|
|
69
|
+
}
|
|
62
70
|
},
|
|
63
71
|
"license": "MIT",
|
|
64
72
|
"repository": {
|