gestament 0.3.0 → 0.4.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.
- package/README.md +2 -0
- package/dist/displaySession.d.ts +2 -2
- package/dist/displaySession.d.ts.map +1 -1
- package/dist/element.d.ts +2 -2
- package/dist/element.d.ts.map +1 -1
- package/dist/errors.d.ts +2 -2
- package/dist/generated/packageMetadata.d.ts +4 -4
- package/dist/gestament-config.d.ts +2 -2
- package/dist/gestament-launcher-driver.cjs +28 -1
- package/dist/gestament-launcher-driver.cjs.map +1 -1
- package/dist/gestament-launcher-driver.d.ts +2 -2
- package/dist/gestament-launcher-driver.mjs +28 -1
- package/dist/gestament-launcher-driver.mjs.map +1 -1
- package/dist/gestament-tray-host.cjs +1 -1
- package/dist/gestament-tray-host.d.ts +2 -2
- package/dist/gestament-tray-host.mjs +1 -1
- package/dist/gestament-xvfb-pool-probe.cjs +1 -1
- package/dist/gestament-xvfb-pool-probe.d.ts +2 -2
- package/dist/gestament-xvfb-pool-probe.mjs +1 -1
- package/dist/gestament-xvfb-worker.d.ts +2 -2
- package/dist/gestament-xvfb.cjs +7 -2
- package/dist/gestament-xvfb.cjs.map +1 -1
- package/dist/gestament-xvfb.d.ts +2 -2
- package/dist/gestament-xvfb.mjs +7 -2
- package/dist/gestament-xvfb.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{launchGtkApp-BIO_5Xjn.cjs → launchGtkApp-BfELuV-H.cjs} +107 -19
- package/dist/launchGtkApp-BfELuV-H.cjs.map +1 -0
- package/dist/{launchGtkApp-qi1qm5G4.js → launchGtkApp-Bst1BFbD.js} +105 -17
- package/dist/launchGtkApp-Bst1BFbD.js.map +1 -0
- package/dist/launchGtkApp.d.ts +2 -2
- package/dist/launchGtkApp.d.ts.map +1 -1
- package/dist/launcherDriverProtocol.d.ts +6 -3
- package/dist/launcherDriverProtocol.d.ts.map +1 -1
- package/dist/{native-CBXaFWP-.cjs → native-BUWDWMBB.cjs} +10 -4
- package/dist/native-BUWDWMBB.cjs.map +1 -0
- package/dist/{native-CWdUmdty.js → native-C6MsIBNF.js} +16 -10
- package/dist/native-C6MsIBNF.js.map +1 -0
- package/dist/native.d.ts +23 -2
- package/dist/native.d.ts.map +1 -1
- package/dist/prerequisites.d.ts +2 -2
- package/dist/testing.d.ts +2 -2
- package/dist/tray.d.ts +2 -2
- package/dist/types.d.ts +96 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/wait.d.ts +2 -2
- package/package.json +7 -7
- package/prebuilds/linux-arm/gtk3/node.napi.armv7.glibc.node +0 -0
- package/prebuilds/linux-arm/gtk4/node.napi.armv7.glibc.node +0 -0
- package/prebuilds/linux-arm64/gtk3/node.napi.glibc.node +0 -0
- package/prebuilds/linux-arm64/gtk4/node.napi.glibc.node +0 -0
- package/prebuilds/linux-ia32/gtk3/node.napi.glibc.node +0 -0
- package/prebuilds/linux-ia32/gtk4/node.napi.glibc.node +0 -0
- package/prebuilds/linux-riscv64/gtk3/node.napi.glibc.node +0 -0
- package/prebuilds/linux-riscv64/gtk4/node.napi.glibc.node +0 -0
- package/prebuilds/linux-x64/gtk3/node.napi.glibc.node +0 -0
- package/prebuilds/linux-x64/gtk4/node.napi.glibc.node +0 -0
- package/dist/launchGtkApp-BIO_5Xjn.cjs.map +0 -1
- package/dist/launchGtkApp-qi1qm5G4.js.map +0 -1
- package/dist/native-CBXaFWP-.cjs.map +0 -1
- package/dist/native-CWdUmdty.js.map +0 -1
|
@@ -8,7 +8,7 @@ const node_os = require("node:os");
|
|
|
8
8
|
const node_path = require("node:path");
|
|
9
9
|
const node_url = require("node:url");
|
|
10
10
|
const prerequisites = require("./prerequisites-BuZST2Dy.cjs");
|
|
11
|
-
const native = require("./native-
|
|
11
|
+
const native = require("./native-BUWDWMBB.cjs");
|
|
12
12
|
var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
|
|
13
13
|
const defaultDisplay = "xvfb";
|
|
14
14
|
const defaultGSettings = "memory";
|
|
@@ -24,6 +24,17 @@ const xvfbStartupTimeoutMs = 1e4;
|
|
|
24
24
|
const xvfbPoolProbeTimeoutMs = 5e3;
|
|
25
25
|
const firstPooledDisplayNumber = 90;
|
|
26
26
|
const lastPooledDisplayNumber = 590;
|
|
27
|
+
const sessionOwnedEnvironmentKeys = [
|
|
28
|
+
"DISPLAY",
|
|
29
|
+
"WAYLAND_DISPLAY",
|
|
30
|
+
"GDK_BACKEND",
|
|
31
|
+
"DBUS_SESSION_BUS_ADDRESS",
|
|
32
|
+
"AT_SPI_BUS_ADDRESS",
|
|
33
|
+
"NO_AT_BRIDGE",
|
|
34
|
+
"XAUTHORITY",
|
|
35
|
+
"GESTAMENT_XVFB_ACTIVE",
|
|
36
|
+
"XDG_SESSION_TYPE"
|
|
37
|
+
];
|
|
27
38
|
let socketCounter = 0;
|
|
28
39
|
const leasedDisplayNumbers = /* @__PURE__ */ new Set();
|
|
29
40
|
const idleXvfbByKey = /* @__PURE__ */ new Map();
|
|
@@ -313,15 +324,37 @@ const toWireEnvironment = (env) => {
|
|
|
313
324
|
}
|
|
314
325
|
return wireEnv;
|
|
315
326
|
};
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
327
|
+
const wireEnvironmentToGtkAppEnvironment = (env) => {
|
|
328
|
+
const appEnv = {};
|
|
329
|
+
for (const [key, value] of Object.entries(env)) {
|
|
330
|
+
appEnv[key] = value === null ? void 0 : value;
|
|
331
|
+
}
|
|
332
|
+
return appEnv;
|
|
333
|
+
};
|
|
334
|
+
const assertNoSessionOwnedEnvironmentOverrides = (options, effective) => {
|
|
335
|
+
if (effective.kind !== "xvfb" || options.env === void 0) {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
for (const key of sessionOwnedEnvironmentKeys) {
|
|
339
|
+
if (Object.hasOwn(options.env, key)) {
|
|
340
|
+
throw errors.createGtkInvalidArgumentError(
|
|
341
|
+
`options.env must not override ${key} when using internal Xvfb.`
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
const resolveLauncherEnvironment = (options, effective) => {
|
|
347
|
+
assertNoSessionOwnedEnvironmentOverrides(options, effective);
|
|
348
|
+
return toWireEnvironment({
|
|
349
|
+
GDK_BACKEND: resolveGdkBackend(effective),
|
|
350
|
+
GSETTINGS_BACKEND: options.gsettings === null ? void 0 : options.gsettings ?? defaultGSettings,
|
|
351
|
+
GTK_THEME: options.theme === null ? void 0 : options.theme ?? defaultTheme,
|
|
352
|
+
...options.env
|
|
353
|
+
});
|
|
354
|
+
};
|
|
322
355
|
const resolveDriverPath = () => {
|
|
323
356
|
const driverPath = node_path.resolve(
|
|
324
|
-
node_path.dirname(node_url.fileURLToPath(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("launchGtkApp-
|
|
357
|
+
node_path.dirname(node_url.fileURLToPath(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("launchGtkApp-BfELuV-H.cjs", document.baseURI).href)),
|
|
325
358
|
"..",
|
|
326
359
|
"dist",
|
|
327
360
|
"gestament-launcher-driver.cjs"
|
|
@@ -335,7 +368,7 @@ const resolveDriverPath = () => {
|
|
|
335
368
|
};
|
|
336
369
|
const resolveXvfbPoolProbePath = () => {
|
|
337
370
|
const probePath = node_path.resolve(
|
|
338
|
-
node_path.dirname(node_url.fileURLToPath(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("launchGtkApp-
|
|
371
|
+
node_path.dirname(node_url.fileURLToPath(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("launchGtkApp-BfELuV-H.cjs", document.baseURI).href)),
|
|
339
372
|
"..",
|
|
340
373
|
"dist",
|
|
341
374
|
"gestament-xvfb-pool-probe.cjs"
|
|
@@ -352,11 +385,17 @@ const createDriverEnvironment = (effective, xvfb) => {
|
|
|
352
385
|
delete env.AT_SPI_BUS_ADDRESS;
|
|
353
386
|
delete env.NO_AT_BRIDGE;
|
|
354
387
|
if (effective.kind === "xvfb") {
|
|
388
|
+
delete env.DBUS_SESSION_BUS_ADDRESS;
|
|
389
|
+
delete env.DISPLAY;
|
|
390
|
+
delete env.WAYLAND_DISPLAY;
|
|
391
|
+
delete env.AT_SPI_BUS_ADDRESS;
|
|
392
|
+
delete env.NO_AT_BRIDGE;
|
|
393
|
+
delete env.XAUTHORITY;
|
|
355
394
|
env.GDK_BACKEND = "x11";
|
|
356
395
|
env.GESTAMENT_XVFB_ACTIVE = "1";
|
|
396
|
+
env.XDG_SESSION_TYPE = "x11";
|
|
357
397
|
if (xvfb !== void 0) {
|
|
358
398
|
env.DISPLAY = xvfb.display;
|
|
359
|
-
delete env.XAUTHORITY;
|
|
360
399
|
}
|
|
361
400
|
}
|
|
362
401
|
return env;
|
|
@@ -530,12 +569,20 @@ const runXvfbProbe = (xvfb) => new Promise((resolveProbe, rejectProbe) => {
|
|
|
530
569
|
const probePath = resolveXvfbPoolProbePath();
|
|
531
570
|
const stdout = [];
|
|
532
571
|
const stderr = [];
|
|
572
|
+
const env = {
|
|
573
|
+
...process.env,
|
|
574
|
+
DISPLAY: xvfb.display,
|
|
575
|
+
GDK_BACKEND: "x11",
|
|
576
|
+
GESTAMENT_XVFB_ACTIVE: "1",
|
|
577
|
+
XDG_SESSION_TYPE: "x11"
|
|
578
|
+
};
|
|
579
|
+
delete env.AT_SPI_BUS_ADDRESS;
|
|
580
|
+
delete env.DBUS_SESSION_BUS_ADDRESS;
|
|
581
|
+
delete env.NO_AT_BRIDGE;
|
|
582
|
+
delete env.WAYLAND_DISPLAY;
|
|
583
|
+
delete env.XAUTHORITY;
|
|
533
584
|
const child = node_child_process.spawn(process.execPath, [probePath], {
|
|
534
|
-
env
|
|
535
|
-
...process.env,
|
|
536
|
-
DISPLAY: xvfb.display,
|
|
537
|
-
GDK_BACKEND: "x11"
|
|
538
|
-
},
|
|
585
|
+
env,
|
|
539
586
|
stdio: ["ignore", "pipe", "pipe"]
|
|
540
587
|
});
|
|
541
588
|
const timeout = setTimeout(() => {
|
|
@@ -1084,6 +1131,14 @@ const createLaunchPayload = (options, args) => {
|
|
|
1084
1131
|
timeoutMs: options.timeoutMs ?? null
|
|
1085
1132
|
};
|
|
1086
1133
|
};
|
|
1134
|
+
const createEnvironmentPayload = (options) => {
|
|
1135
|
+
const display = resolveDisplay(options.display);
|
|
1136
|
+
const xvfb = resolveXvfbOptions(options);
|
|
1137
|
+
const effective = resolveEffectiveDisplay(display, xvfb);
|
|
1138
|
+
return {
|
|
1139
|
+
env: resolveLauncherEnvironment(options, effective)
|
|
1140
|
+
};
|
|
1141
|
+
};
|
|
1087
1142
|
const elementRefToProxy = (session, ref) => ref === null ? void 0 : createProxyGtkElement(session, ref);
|
|
1088
1143
|
const trayRefToProxy = (session, ref) => ref === null ? void 0 : createProxyGtkTrayItem(session, ref);
|
|
1089
1144
|
const createProxyGtkApp = (session, ref) => {
|
|
@@ -1109,6 +1164,9 @@ const createProxyGtkApp = (session, ref) => {
|
|
|
1109
1164
|
};
|
|
1110
1165
|
const app = {
|
|
1111
1166
|
capture: async () => decodeCapture(await appRequest("app.capture")),
|
|
1167
|
+
environment: async () => wireEnvironmentToGtkAppEnvironment(
|
|
1168
|
+
await appRequest("app.environment")
|
|
1169
|
+
),
|
|
1112
1170
|
findById: async (id) => elementRefToProxy(
|
|
1113
1171
|
session,
|
|
1114
1172
|
await appRequest("app.findById", { id })
|
|
@@ -1221,6 +1279,13 @@ const createProxyGtkElement = (session, ref) => {
|
|
|
1221
1279
|
};
|
|
1222
1280
|
switch (ref.kind) {
|
|
1223
1281
|
case "window":
|
|
1282
|
+
target.bounds = () => session.request("element.bounds", { elementId });
|
|
1283
|
+
target.resizeHints = () => session.request("window.resizeHints", {
|
|
1284
|
+
elementId
|
|
1285
|
+
});
|
|
1286
|
+
target.x11Info = () => session.request("window.x11Info", { elementId });
|
|
1287
|
+
addChildContainerProxyOperations(session, elementId, target);
|
|
1288
|
+
break;
|
|
1224
1289
|
case "container":
|
|
1225
1290
|
case "menu":
|
|
1226
1291
|
addChildContainerProxyOperations(session, elementId, target);
|
|
@@ -1335,13 +1400,24 @@ const createDriverBackedGtkAppLauncher = (options) => {
|
|
|
1335
1400
|
return sessionPromise;
|
|
1336
1401
|
};
|
|
1337
1402
|
const launch = async (args) => {
|
|
1403
|
+
const payload = createLaunchPayload(options, args ?? []);
|
|
1338
1404
|
const session = await ensureSession();
|
|
1339
1405
|
const appRef = await session.request(
|
|
1340
1406
|
"launcher.launch",
|
|
1341
|
-
|
|
1407
|
+
payload
|
|
1342
1408
|
);
|
|
1343
1409
|
return createProxyGtkApp(session, appRef);
|
|
1344
1410
|
};
|
|
1411
|
+
const environment = async () => {
|
|
1412
|
+
const payload = createEnvironmentPayload(options);
|
|
1413
|
+
const session = await ensureSession();
|
|
1414
|
+
return wireEnvironmentToGtkAppEnvironment(
|
|
1415
|
+
await session.request(
|
|
1416
|
+
"launcher.environment",
|
|
1417
|
+
payload
|
|
1418
|
+
)
|
|
1419
|
+
);
|
|
1420
|
+
};
|
|
1345
1421
|
const release = async () => {
|
|
1346
1422
|
const releasingSession = sessionPromise;
|
|
1347
1423
|
sessionPromise = void 0;
|
|
@@ -1352,6 +1428,7 @@ const createDriverBackedGtkAppLauncher = (options) => {
|
|
|
1352
1428
|
await session.release();
|
|
1353
1429
|
};
|
|
1354
1430
|
return {
|
|
1431
|
+
environment,
|
|
1355
1432
|
launch,
|
|
1356
1433
|
release,
|
|
1357
1434
|
[Symbol.asyncDispose]: release
|
|
@@ -1760,6 +1837,9 @@ const createImageInfoOperation = (handle) => async () => {
|
|
|
1760
1837
|
capture: async () => native.nativeCaptureBounds(info.bounds)
|
|
1761
1838
|
};
|
|
1762
1839
|
};
|
|
1840
|
+
const createBoundsOperation = (handle) => async () => native.nativeBounds(handle);
|
|
1841
|
+
const createResizeHintsOperation = (handle) => async () => native.nativeResizeHints(handle);
|
|
1842
|
+
const createX11InfoOperation = (handle) => async () => native.nativeX11Info(handle);
|
|
1763
1843
|
const createValueOperation = (handle) => async () => native.nativeValueInfo(handle).value;
|
|
1764
1844
|
const createSetValueOperation = (handle) => async (value) => {
|
|
1765
1845
|
assertFiniteNumber("value", value);
|
|
@@ -1931,7 +2011,10 @@ const createGtkElement = (handle) => {
|
|
|
1931
2011
|
return {
|
|
1932
2012
|
...common,
|
|
1933
2013
|
kind: "window",
|
|
1934
|
-
|
|
2014
|
+
bounds: createBoundsOperation(handle),
|
|
2015
|
+
...createChildContainerOperations(handle, void 0),
|
|
2016
|
+
resizeHints: createResizeHintsOperation(handle),
|
|
2017
|
+
x11Info: createX11InfoOperation(handle)
|
|
1935
2018
|
};
|
|
1936
2019
|
case "button":
|
|
1937
2020
|
return { ...common, kind: "button", click: createClickOperation(handle) };
|
|
@@ -2259,8 +2342,9 @@ const createGtkAppEnvironment = (baseEnv, overrides) => {
|
|
|
2259
2342
|
const launchGtkApp = (appPath, args, options) => {
|
|
2260
2343
|
const _args = args ?? [];
|
|
2261
2344
|
const _timeoutMs = options?.timeoutMs ?? 1e4;
|
|
2345
|
+
const appEnvironment = createGtkAppEnvironment(process.env, options?.env);
|
|
2262
2346
|
const child = node_child_process.spawn(appPath, [..._args], {
|
|
2263
|
-
env:
|
|
2347
|
+
env: appEnvironment,
|
|
2264
2348
|
stdio: "pipe"
|
|
2265
2349
|
});
|
|
2266
2350
|
const state = {
|
|
@@ -2410,6 +2494,10 @@ const launchGtkApp = (appPath, args, options) => {
|
|
|
2410
2494
|
throw errors.normalizeNativeError(error);
|
|
2411
2495
|
}
|
|
2412
2496
|
},
|
|
2497
|
+
environment: async () => {
|
|
2498
|
+
assertProcessRunning(state, appPath);
|
|
2499
|
+
return { ...appEnvironment };
|
|
2500
|
+
},
|
|
2413
2501
|
findById,
|
|
2414
2502
|
findByPath,
|
|
2415
2503
|
getById,
|
|
@@ -2476,4 +2564,4 @@ const createGtkAppLauncher = (options) => createDriverBackedGtkAppLauncher(optio
|
|
|
2476
2564
|
exports.createGtkAppEnvironment = createGtkAppEnvironment;
|
|
2477
2565
|
exports.createGtkAppLauncher = createGtkAppLauncher;
|
|
2478
2566
|
exports.launchGtkApp = launchGtkApp;
|
|
2479
|
-
//# sourceMappingURL=launchGtkApp-
|
|
2567
|
+
//# sourceMappingURL=launchGtkApp-BfELuV-H.cjs.map
|