@gjsify/process 0.64.19 → 0.64.20
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/lib/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{hrtimeBigint as e}from"./internal/hrtime.js";import{Process as t}from"./process-class.js";import{
|
|
1
|
+
import{hrtimeBigint as e}from"./internal/hrtime.js";import{Process as t}from"./process-class.js";import{connectParentChannel as n}from"./internal/ipc.js";import{nativeTerminal as r}from"@gjsify/terminal-native";const i=new t;if(n(i),r)try{let e=new r.ResizeWatcher;e.connect(`resized`,(e,t,n)=>{i.stdout.emit(`resize`),i.stderr.emit(`resize`)}),e.start()}catch{}const a=i.platform,o=i.arch,s=i.env,c=i.argv,l=i.argv0,u=i.execPath,d=i.pid,f=i.ppid,p=i.version,m=i.versions,h=i.cwd.bind(i),g=i.chdir.bind(i),_=i.exit.bind(i),v=i.nextTick.bind(i),y=Object.assign(i.hrtime.bind(i),{bigint:e}),b=i.uptime.bind(i),x=i.memoryUsage.bind(i),S=i.cpuUsage.bind(i),C=i.kill.bind(i),w=i.abort.bind(i),T=i.umask.bind(i),E=i.emitWarning.bind(i),D=i.execArgv,O=i.config,k=i.stdout,A=i.stderr,j=i.stdin;export{w as abort,o as arch,c as argv,l as argv0,g as chdir,O as config,S as cpuUsage,h as cwd,i as default,E as emitWarning,s as env,D as execArgv,u as execPath,_ as exit,y as hrtime,C as kill,x as memoryUsage,v as nextTick,d as pid,a as platform,f as ppid,A as stderr,j as stdin,k as stdout,T as umask,b as uptime,p as version,m as versions};
|
package/lib/esm/internal/env.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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`)}function getExecArgv(){if(!isGjsHost()){let e=globalThis.process;return Array.isArray(e?.execArgv)?e.execArgv:[]}try{let t=e().imports?.gi?.GLib;if(t?.file_get_contents){let[,e]=t.file_get_contents(`/proc/self/cmdline`);if(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=new TextDecoder().decode(t).split(`\0`).filter(e=>e.length>0),r=[];for(let e=1;e<n.length&&n[e].startsWith(`-`);e++)r.push(n[e]);return r}}}catch{}return[]}export{chdir,getArgv,getCwd,getEnvProxy,getExecArgv,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`)}function getExecArgv(){if(!isGjsHost()){let e=globalThis.process;return Array.isArray(e?.execArgv)?e.execArgv:[]}try{let t=e().imports?.gi?.GLib;if(t?.file_get_contents){let[,e]=t.file_get_contents(`/proc/self/cmdline`);if(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=new TextDecoder().decode(t).split(`\0`).filter(e=>e.length>0),r=[];for(let e=1;e<n.length&&n[e].startsWith(`-`);e++)r.push(n[e]);return r}}}catch{}return[]}export{chdir,getArgv,getCwd,getEnvProxy,getExecArgv,getExecPath,isGjsHost};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../_virtual/_rolldown/runtime.js";import{isGjsHost as e}from"./env.js";import{setupNodeChannel as t}from"@gjsify/ipc-channel/node-channel";function connectParentChannel(n){if(!e())return;let r=n.env.NODE_CHANNEL_FD;if(r===void 0)return;let i=n.env.NODE_CHANNEL_SERIALIZATION_MODE??`json`;delete n.env.NODE_CHANNEL_FD,delete n.env.NODE_CHANNEL_SERIALIZATION_MODE;let a=Number.parseInt(r,10);if(!(!Number.isInteger(a)||a<0)){if(i!==`json`){n.emitWarning(`IPC serialization '${i}' is not supported under GJS yet; no channel to the parent`,`ExperimentalWarning`);return}try{t(n,a)}catch(e){n.emitWarning(`Could not open the IPC channel to the parent: ${e.message}`)}}}export{connectParentChannel};
|
|
@@ -20,6 +20,8 @@ export declare function getArgv(): string[];
|
|
|
20
20
|
* type says it must be a string.
|
|
21
21
|
*/
|
|
22
22
|
export declare function getExecPath(): string;
|
|
23
|
+
/** Is there a GJS host under this process? */
|
|
24
|
+
export declare function isGjsHost(): boolean;
|
|
23
25
|
export declare function getCwd(): string;
|
|
24
26
|
export declare function chdir(directory: string): void;
|
|
25
27
|
export declare function getExecArgv(): string[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type NodeChannelTarget } from '@gjsify/ipc-channel/node-channel';
|
|
2
|
+
interface IpcProcess extends NodeChannelTarget {
|
|
3
|
+
env: Record<string, string | undefined>;
|
|
4
|
+
emitWarning(warning: string, name?: string): void;
|
|
5
|
+
}
|
|
6
|
+
export declare function connectParentChannel(process: IpcProcess): void;
|
|
7
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/process",
|
|
3
|
-
"version": "0.64.
|
|
3
|
+
"version": "0.64.20",
|
|
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,15 @@
|
|
|
40
40
|
"process"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@gjsify/events": "^0.64.
|
|
44
|
-
"@gjsify/
|
|
45
|
-
"@gjsify/
|
|
46
|
-
"@gjsify/
|
|
43
|
+
"@gjsify/events": "^0.64.20",
|
|
44
|
+
"@gjsify/ipc-channel": "^0.64.20",
|
|
45
|
+
"@gjsify/string_decoder": "^0.64.20",
|
|
46
|
+
"@gjsify/terminal-native": "^0.64.20",
|
|
47
|
+
"@gjsify/utils": "^0.64.20"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
|
-
"@gjsify/cli": "^0.64.
|
|
50
|
-
"@gjsify/unit": "^0.64.
|
|
50
|
+
"@gjsify/cli": "^0.64.20",
|
|
51
|
+
"@gjsify/unit": "^0.64.20",
|
|
51
52
|
"@types/node": "^25.9.2",
|
|
52
53
|
"typescript": "^6.0.3"
|
|
53
54
|
},
|