@gjsify/node-gi 0.26.1 → 0.27.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.
@@ -108,8 +108,7 @@ if (mode === '--includes') {
108
108
  // Last resort: locate ffi.h anywhere under the tree and add its dir.
109
109
  if (!dirs.some((d) => existsSync(join(d, 'ffi.h')))) {
110
110
  const ffiDir =
111
- findHeaderDir(join(prefix, 'include'), 'ffi.h') ??
112
- findHeaderDir(join(prefix, 'lib'), 'ffi.h');
111
+ findHeaderDir(join(prefix, 'include'), 'ffi.h') ?? findHeaderDir(join(prefix, 'lib'), 'ffi.h');
113
112
  if (ffiDir) dirs.push(ffiDir);
114
113
  }
115
114
  }
@@ -127,15 +126,7 @@ if (mode === '--includes') {
127
126
  // cairo the native cairo foreign-struct binding (src/cairo.cc)
128
127
  // Pango/GdkPixbuf/Graphene are NOT linked — the conformance programs load their
129
128
  // typelibs at RUNTIME (girepository dlopens the DLL by soname), not at link time.
130
- const DIRECT_LIBS = [
131
- 'girepository-2.0',
132
- 'gio-2.0',
133
- 'gobject-2.0',
134
- 'gmodule-2.0',
135
- 'glib-2.0',
136
- 'ffi',
137
- 'cairo',
138
- ];
129
+ const DIRECT_LIBS = ['girepository-2.0', 'gio-2.0', 'gobject-2.0', 'gmodule-2.0', 'glib-2.0', 'ffi', 'cairo'];
139
130
  // Locate the import-lib dir: GTK_PREFIX/lib, else pkg-config's -L.
140
131
  const searchDirs = [];
141
132
  if (process.env.GTK_PREFIX) searchDirs.push(join(process.env.GTK_PREFIX, 'lib'));
package/system.d.ts CHANGED
@@ -30,19 +30,19 @@ export function dumpMemoryInfo(): void;
30
30
 
31
31
  /** The GJS `System` module object (`import System from 'system'`). */
32
32
  export interface SystemModule {
33
- exit(code?: number): void;
34
- gc(): void;
35
- version: number;
36
- readonly programArgs: string[];
37
- readonly programInvocationName: string;
38
- readonly programPath: string | null;
39
- addressOf(): string;
40
- addressOfGObject(): string;
41
- refcount(): number;
42
- breakpoint(): void;
43
- clearDateCaches(): void;
44
- dumpHeap(): void;
45
- dumpMemoryInfo(): void;
33
+ exit(code?: number): void;
34
+ gc(): void;
35
+ version: number;
36
+ readonly programArgs: string[];
37
+ readonly programInvocationName: string;
38
+ readonly programPath: string | null;
39
+ addressOf(): string;
40
+ addressOfGObject(): string;
41
+ refcount(): number;
42
+ breakpoint(): void;
43
+ clearDateCaches(): void;
44
+ dumpHeap(): void;
45
+ dumpMemoryInfo(): void;
46
46
  }
47
47
 
48
48
  declare const System: SystemModule;
package/system.js CHANGED
@@ -35,14 +35,14 @@
35
35
  // module is loaded from `@gjsify/node-gi/globals`, before any bundle body (and
36
36
  // therefore before any register side effect) runs.
37
37
  const runtimeProcess = (() => {
38
- const hostProcess = typeof process !== 'undefined' ? process : undefined;
39
- try {
40
- const builtin = hostProcess?.getBuiltinModule?.('node:process');
41
- if (builtin && typeof builtin.exit === 'function') return builtin;
42
- } catch {
43
- // getBuiltinModule missing or refusing the specifier — use the captured one.
44
- }
45
- return hostProcess;
38
+ const hostProcess = typeof process !== 'undefined' ? process : undefined;
39
+ try {
40
+ const builtin = hostProcess?.getBuiltinModule?.('node:process');
41
+ if (builtin && typeof builtin.exit === 'function') return builtin;
42
+ } catch {
43
+ // getBuiltinModule missing or refusing the specifier — use the captured one.
44
+ }
45
+ return hostProcess;
46
46
  })();
47
47
 
48
48
  const runtimeExit = typeof runtimeProcess?.exit === 'function' ? runtimeProcess.exit.bind(runtimeProcess) : undefined;
@@ -50,17 +50,17 @@ const runtimeExit = typeof runtimeProcess?.exit === 'function' ? runtimeProcess.
50
50
  // `programArgs` mirrors GJS's ARGV: the script arguments, excluding the
51
51
  // interpreter (argv[0]) and the script path (argv[1]).
52
52
  function readProgramArgs() {
53
- return Array.isArray(runtimeProcess?.argv) ? runtimeProcess.argv.slice(2) : [];
53
+ return Array.isArray(runtimeProcess?.argv) ? runtimeProcess.argv.slice(2) : [];
54
54
  }
55
55
 
56
56
  // `programInvocationName` / `programPath` track the running script — Node's
57
57
  // `process.argv[1]`.
58
58
  function readProgramInvocationName() {
59
- return runtimeProcess?.argv?.[1] || '';
59
+ return runtimeProcess?.argv?.[1] || '';
60
60
  }
61
61
 
62
62
  function readProgramPath() {
63
- return runtimeProcess?.argv?.[1] || null;
63
+ return runtimeProcess?.argv?.[1] || null;
64
64
  }
65
65
 
66
66
  /**
@@ -74,12 +74,12 @@ function readProgramPath() {
74
74
  * `conformance/programs/system-exit-lifetime.conf.mjs`).
75
75
  */
76
76
  export function exit(code) {
77
- if (runtimeExit !== undefined) runtimeExit(code ?? 0);
77
+ if (runtimeExit !== undefined) runtimeExit(code ?? 0);
78
78
  }
79
79
 
80
80
  /** Trigger a garbage collection if the host exposed `globalThis.gc` (`--expose-gc`). */
81
81
  export function gc() {
82
- if (typeof globalThis.gc === 'function') globalThis.gc();
82
+ if (typeof globalThis.gc === 'function') globalThis.gc();
83
83
  }
84
84
 
85
85
  /** The SpiderMonkey/mozjs version number — no equivalent on Node, reported as 0. */
@@ -96,17 +96,17 @@ export const programPath = readProgramPath();
96
96
 
97
97
  /** Return the address of a JS object as a string. No Node equivalent — stub. */
98
98
  export function addressOf() {
99
- return '0x0';
99
+ return '0x0';
100
100
  }
101
101
 
102
102
  /** Return the address of a GObject as a string. No Node equivalent — stub. */
103
103
  export function addressOfGObject() {
104
- return '0x0';
104
+ return '0x0';
105
105
  }
106
106
 
107
107
  /** Return the refcount of a GObject. No Node equivalent — stub. */
108
108
  export function refcount() {
109
- return 0;
109
+ return 0;
110
110
  }
111
111
 
112
112
  /** Trigger a debugger breakpoint. No-op on Node. */
@@ -128,25 +128,25 @@ export function dumpMemoryInfo() {}
128
128
  * track the running script.
129
129
  */
130
130
  const System = {
131
- exit,
132
- gc,
133
- version,
134
- addressOf,
135
- addressOfGObject,
136
- refcount,
137
- breakpoint,
138
- clearDateCaches,
139
- dumpHeap,
140
- dumpMemoryInfo,
141
- get programArgs() {
142
- return readProgramArgs();
143
- },
144
- get programInvocationName() {
145
- return readProgramInvocationName();
146
- },
147
- get programPath() {
148
- return readProgramPath();
149
- },
131
+ exit,
132
+ gc,
133
+ version,
134
+ addressOf,
135
+ addressOfGObject,
136
+ refcount,
137
+ breakpoint,
138
+ clearDateCaches,
139
+ dumpHeap,
140
+ dumpMemoryInfo,
141
+ get programArgs() {
142
+ return readProgramArgs();
143
+ },
144
+ get programInvocationName() {
145
+ return readProgramInvocationName();
146
+ },
147
+ get programPath() {
148
+ return readProgramPath();
149
+ },
150
150
  };
151
151
 
152
152
  export default System;