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.
Files changed (63) hide show
  1. package/README.md +2 -0
  2. package/dist/displaySession.d.ts +2 -2
  3. package/dist/displaySession.d.ts.map +1 -1
  4. package/dist/element.d.ts +2 -2
  5. package/dist/element.d.ts.map +1 -1
  6. package/dist/errors.d.ts +2 -2
  7. package/dist/generated/packageMetadata.d.ts +4 -4
  8. package/dist/gestament-config.d.ts +2 -2
  9. package/dist/gestament-launcher-driver.cjs +28 -1
  10. package/dist/gestament-launcher-driver.cjs.map +1 -1
  11. package/dist/gestament-launcher-driver.d.ts +2 -2
  12. package/dist/gestament-launcher-driver.mjs +28 -1
  13. package/dist/gestament-launcher-driver.mjs.map +1 -1
  14. package/dist/gestament-tray-host.cjs +1 -1
  15. package/dist/gestament-tray-host.d.ts +2 -2
  16. package/dist/gestament-tray-host.mjs +1 -1
  17. package/dist/gestament-xvfb-pool-probe.cjs +1 -1
  18. package/dist/gestament-xvfb-pool-probe.d.ts +2 -2
  19. package/dist/gestament-xvfb-pool-probe.mjs +1 -1
  20. package/dist/gestament-xvfb-worker.d.ts +2 -2
  21. package/dist/gestament-xvfb.cjs +7 -2
  22. package/dist/gestament-xvfb.cjs.map +1 -1
  23. package/dist/gestament-xvfb.d.ts +2 -2
  24. package/dist/gestament-xvfb.mjs +7 -2
  25. package/dist/gestament-xvfb.mjs.map +1 -1
  26. package/dist/index.cjs +1 -1
  27. package/dist/index.d.ts +2 -2
  28. package/dist/index.mjs +1 -1
  29. package/dist/{launchGtkApp-BIO_5Xjn.cjs → launchGtkApp-BfELuV-H.cjs} +107 -19
  30. package/dist/launchGtkApp-BfELuV-H.cjs.map +1 -0
  31. package/dist/{launchGtkApp-qi1qm5G4.js → launchGtkApp-Bst1BFbD.js} +105 -17
  32. package/dist/launchGtkApp-Bst1BFbD.js.map +1 -0
  33. package/dist/launchGtkApp.d.ts +2 -2
  34. package/dist/launchGtkApp.d.ts.map +1 -1
  35. package/dist/launcherDriverProtocol.d.ts +6 -3
  36. package/dist/launcherDriverProtocol.d.ts.map +1 -1
  37. package/dist/{native-CBXaFWP-.cjs → native-BUWDWMBB.cjs} +10 -4
  38. package/dist/native-BUWDWMBB.cjs.map +1 -0
  39. package/dist/{native-CWdUmdty.js → native-C6MsIBNF.js} +16 -10
  40. package/dist/native-C6MsIBNF.js.map +1 -0
  41. package/dist/native.d.ts +23 -2
  42. package/dist/native.d.ts.map +1 -1
  43. package/dist/prerequisites.d.ts +2 -2
  44. package/dist/testing.d.ts +2 -2
  45. package/dist/tray.d.ts +2 -2
  46. package/dist/types.d.ts +96 -2
  47. package/dist/types.d.ts.map +1 -1
  48. package/dist/wait.d.ts +2 -2
  49. package/package.json +7 -7
  50. package/prebuilds/linux-arm/gtk3/node.napi.armv7.glibc.node +0 -0
  51. package/prebuilds/linux-arm/gtk4/node.napi.armv7.glibc.node +0 -0
  52. package/prebuilds/linux-arm64/gtk3/node.napi.glibc.node +0 -0
  53. package/prebuilds/linux-arm64/gtk4/node.napi.glibc.node +0 -0
  54. package/prebuilds/linux-ia32/gtk3/node.napi.glibc.node +0 -0
  55. package/prebuilds/linux-ia32/gtk4/node.napi.glibc.node +0 -0
  56. package/prebuilds/linux-riscv64/gtk3/node.napi.glibc.node +0 -0
  57. package/prebuilds/linux-riscv64/gtk4/node.napi.glibc.node +0 -0
  58. package/prebuilds/linux-x64/gtk3/node.napi.glibc.node +0 -0
  59. package/prebuilds/linux-x64/gtk4/node.napi.glibc.node +0 -0
  60. package/dist/launchGtkApp-BIO_5Xjn.cjs.map +0 -1
  61. package/dist/launchGtkApp-qi1qm5G4.js.map +0 -1
  62. package/dist/native-CBXaFWP-.cjs.map +0 -1
  63. package/dist/native-CWdUmdty.js.map +0 -1
@@ -7,7 +7,7 @@ import { tmpdir } from "node:os";
7
7
  import { join, resolve, dirname } from "node:path";
8
8
  import { fileURLToPath } from "node:url";
9
9
  import { a as appendPrerequisiteInstallHint } from "./prerequisites-JB0SKPVd.js";
10
- import { c as nativeElementInfo, d as nativeClick, e as nativeImageInfo, f as nativeCaptureBounds, g as nativeTableDeselectColumn, h as nativeTableSelectColumn, i as nativeTableDeselectRow, j as nativeTableSelectRow, k as nativeTableIsCellSelected, l as nativeTableIsColumnSelected, m as nativeTableIsRowSelected, o as nativeTableSelectedColumns, p as nativeTableSelectedRows, q as nativeTableColumnCount, r as nativeTableRowCount, s as nativeClearSelection, t as nativeSelectAllChildren, u as nativeDeselectChildAt, v as nativeSelectChildAt, w as nativeIsChildSelected, x as nativeSelectedChildAt, y as nativeSelectedChildCount, z as nativeChildCount, A as nativeChildAt, B as nativeValueInfo, C as nativeSetValue, D as nativeText, E as nativeSetText, F as nativeCapture, G as nativeTableCellAt, H as nativeFindAnyById, I as nativeTrayItems, J as nativeWindowCount, K as nativeWindowAt, a as nativeCaptureScreen, L as nativeFindById, M as nativeProcessAtspiReadiness } from "./native-CWdUmdty.js";
10
+ import { c as nativeElementInfo, d as nativeClick, e as nativeImageInfo, f as nativeCaptureBounds, g as nativeTableDeselectColumn, h as nativeTableSelectColumn, i as nativeTableDeselectRow, j as nativeTableSelectRow, k as nativeTableIsCellSelected, l as nativeTableIsColumnSelected, m as nativeTableIsRowSelected, o as nativeTableSelectedColumns, p as nativeTableSelectedRows, q as nativeTableColumnCount, r as nativeTableRowCount, s as nativeClearSelection, t as nativeSelectAllChildren, u as nativeDeselectChildAt, v as nativeSelectChildAt, w as nativeIsChildSelected, x as nativeSelectedChildAt, y as nativeSelectedChildCount, z as nativeChildCount, A as nativeChildAt, B as nativeValueInfo, C as nativeSetValue, D as nativeText, E as nativeSetText, F as nativeX11Info, G as nativeResizeHints, H as nativeBounds, I as nativeCapture, J as nativeTableCellAt, K as nativeFindAnyById, L as nativeTrayItems, M as nativeWindowCount, N as nativeWindowAt, a as nativeCaptureScreen, O as nativeFindById, P as nativeProcessAtspiReadiness } from "./native-C6MsIBNF.js";
11
11
  const defaultDisplay = "xvfb";
12
12
  const defaultGSettings = "memory";
13
13
  const defaultTheme = "Adwaita";
@@ -22,6 +22,17 @@ const xvfbStartupTimeoutMs = 1e4;
22
22
  const xvfbPoolProbeTimeoutMs = 5e3;
23
23
  const firstPooledDisplayNumber = 90;
24
24
  const lastPooledDisplayNumber = 590;
25
+ const sessionOwnedEnvironmentKeys = [
26
+ "DISPLAY",
27
+ "WAYLAND_DISPLAY",
28
+ "GDK_BACKEND",
29
+ "DBUS_SESSION_BUS_ADDRESS",
30
+ "AT_SPI_BUS_ADDRESS",
31
+ "NO_AT_BRIDGE",
32
+ "XAUTHORITY",
33
+ "GESTAMENT_XVFB_ACTIVE",
34
+ "XDG_SESSION_TYPE"
35
+ ];
25
36
  let socketCounter = 0;
26
37
  const leasedDisplayNumbers = /* @__PURE__ */ new Set();
27
38
  const idleXvfbByKey = /* @__PURE__ */ new Map();
@@ -311,12 +322,34 @@ const toWireEnvironment = (env) => {
311
322
  }
312
323
  return wireEnv;
313
324
  };
314
- const resolveLauncherEnvironment = (options, effective) => toWireEnvironment({
315
- GDK_BACKEND: resolveGdkBackend(effective),
316
- GSETTINGS_BACKEND: options.gsettings === null ? void 0 : options.gsettings ?? defaultGSettings,
317
- GTK_THEME: options.theme === null ? void 0 : options.theme ?? defaultTheme,
318
- ...options.env
319
- });
325
+ const wireEnvironmentToGtkAppEnvironment = (env) => {
326
+ const appEnv = {};
327
+ for (const [key, value] of Object.entries(env)) {
328
+ appEnv[key] = value === null ? void 0 : value;
329
+ }
330
+ return appEnv;
331
+ };
332
+ const assertNoSessionOwnedEnvironmentOverrides = (options, effective) => {
333
+ if (effective.kind !== "xvfb" || options.env === void 0) {
334
+ return;
335
+ }
336
+ for (const key of sessionOwnedEnvironmentKeys) {
337
+ if (Object.hasOwn(options.env, key)) {
338
+ throw createGtkInvalidArgumentError(
339
+ `options.env must not override ${key} when using internal Xvfb.`
340
+ );
341
+ }
342
+ }
343
+ };
344
+ const resolveLauncherEnvironment = (options, effective) => {
345
+ assertNoSessionOwnedEnvironmentOverrides(options, effective);
346
+ return toWireEnvironment({
347
+ GDK_BACKEND: resolveGdkBackend(effective),
348
+ GSETTINGS_BACKEND: options.gsettings === null ? void 0 : options.gsettings ?? defaultGSettings,
349
+ GTK_THEME: options.theme === null ? void 0 : options.theme ?? defaultTheme,
350
+ ...options.env
351
+ });
352
+ };
320
353
  const resolveDriverPath = () => {
321
354
  const driverPath = resolve(
322
355
  dirname(fileURLToPath(import.meta.url)),
@@ -350,11 +383,17 @@ const createDriverEnvironment = (effective, xvfb) => {
350
383
  delete env.AT_SPI_BUS_ADDRESS;
351
384
  delete env.NO_AT_BRIDGE;
352
385
  if (effective.kind === "xvfb") {
386
+ delete env.DBUS_SESSION_BUS_ADDRESS;
387
+ delete env.DISPLAY;
388
+ delete env.WAYLAND_DISPLAY;
389
+ delete env.AT_SPI_BUS_ADDRESS;
390
+ delete env.NO_AT_BRIDGE;
391
+ delete env.XAUTHORITY;
353
392
  env.GDK_BACKEND = "x11";
354
393
  env.GESTAMENT_XVFB_ACTIVE = "1";
394
+ env.XDG_SESSION_TYPE = "x11";
355
395
  if (xvfb !== void 0) {
356
396
  env.DISPLAY = xvfb.display;
357
- delete env.XAUTHORITY;
358
397
  }
359
398
  }
360
399
  return env;
@@ -528,12 +567,20 @@ const runXvfbProbe = (xvfb) => new Promise((resolveProbe, rejectProbe) => {
528
567
  const probePath = resolveXvfbPoolProbePath();
529
568
  const stdout = [];
530
569
  const stderr = [];
570
+ const env = {
571
+ ...process.env,
572
+ DISPLAY: xvfb.display,
573
+ GDK_BACKEND: "x11",
574
+ GESTAMENT_XVFB_ACTIVE: "1",
575
+ XDG_SESSION_TYPE: "x11"
576
+ };
577
+ delete env.AT_SPI_BUS_ADDRESS;
578
+ delete env.DBUS_SESSION_BUS_ADDRESS;
579
+ delete env.NO_AT_BRIDGE;
580
+ delete env.WAYLAND_DISPLAY;
581
+ delete env.XAUTHORITY;
531
582
  const child = spawn(process.execPath, [probePath], {
532
- env: {
533
- ...process.env,
534
- DISPLAY: xvfb.display,
535
- GDK_BACKEND: "x11"
536
- },
583
+ env,
537
584
  stdio: ["ignore", "pipe", "pipe"]
538
585
  });
539
586
  const timeout = setTimeout(() => {
@@ -1082,6 +1129,14 @@ const createLaunchPayload = (options, args) => {
1082
1129
  timeoutMs: options.timeoutMs ?? null
1083
1130
  };
1084
1131
  };
1132
+ const createEnvironmentPayload = (options) => {
1133
+ const display = resolveDisplay(options.display);
1134
+ const xvfb = resolveXvfbOptions(options);
1135
+ const effective = resolveEffectiveDisplay(display, xvfb);
1136
+ return {
1137
+ env: resolveLauncherEnvironment(options, effective)
1138
+ };
1139
+ };
1085
1140
  const elementRefToProxy = (session, ref) => ref === null ? void 0 : createProxyGtkElement(session, ref);
1086
1141
  const trayRefToProxy = (session, ref) => ref === null ? void 0 : createProxyGtkTrayItem(session, ref);
1087
1142
  const createProxyGtkApp = (session, ref) => {
@@ -1107,6 +1162,9 @@ const createProxyGtkApp = (session, ref) => {
1107
1162
  };
1108
1163
  const app = {
1109
1164
  capture: async () => decodeCapture(await appRequest("app.capture")),
1165
+ environment: async () => wireEnvironmentToGtkAppEnvironment(
1166
+ await appRequest("app.environment")
1167
+ ),
1110
1168
  findById: async (id) => elementRefToProxy(
1111
1169
  session,
1112
1170
  await appRequest("app.findById", { id })
@@ -1219,6 +1277,13 @@ const createProxyGtkElement = (session, ref) => {
1219
1277
  };
1220
1278
  switch (ref.kind) {
1221
1279
  case "window":
1280
+ target.bounds = () => session.request("element.bounds", { elementId });
1281
+ target.resizeHints = () => session.request("window.resizeHints", {
1282
+ elementId
1283
+ });
1284
+ target.x11Info = () => session.request("window.x11Info", { elementId });
1285
+ addChildContainerProxyOperations(session, elementId, target);
1286
+ break;
1222
1287
  case "container":
1223
1288
  case "menu":
1224
1289
  addChildContainerProxyOperations(session, elementId, target);
@@ -1333,13 +1398,24 @@ const createDriverBackedGtkAppLauncher = (options) => {
1333
1398
  return sessionPromise;
1334
1399
  };
1335
1400
  const launch = async (args) => {
1401
+ const payload = createLaunchPayload(options, args ?? []);
1336
1402
  const session = await ensureSession();
1337
1403
  const appRef = await session.request(
1338
1404
  "launcher.launch",
1339
- createLaunchPayload(options, args ?? [])
1405
+ payload
1340
1406
  );
1341
1407
  return createProxyGtkApp(session, appRef);
1342
1408
  };
1409
+ const environment = async () => {
1410
+ const payload = createEnvironmentPayload(options);
1411
+ const session = await ensureSession();
1412
+ return wireEnvironmentToGtkAppEnvironment(
1413
+ await session.request(
1414
+ "launcher.environment",
1415
+ payload
1416
+ )
1417
+ );
1418
+ };
1343
1419
  const release = async () => {
1344
1420
  const releasingSession = sessionPromise;
1345
1421
  sessionPromise = void 0;
@@ -1350,6 +1426,7 @@ const createDriverBackedGtkAppLauncher = (options) => {
1350
1426
  await session.release();
1351
1427
  };
1352
1428
  return {
1429
+ environment,
1353
1430
  launch,
1354
1431
  release,
1355
1432
  [Symbol.asyncDispose]: release
@@ -1758,6 +1835,9 @@ const createImageInfoOperation = (handle) => async () => {
1758
1835
  capture: async () => nativeCaptureBounds(info.bounds)
1759
1836
  };
1760
1837
  };
1838
+ const createBoundsOperation = (handle) => async () => nativeBounds(handle);
1839
+ const createResizeHintsOperation = (handle) => async () => nativeResizeHints(handle);
1840
+ const createX11InfoOperation = (handle) => async () => nativeX11Info(handle);
1761
1841
  const createValueOperation = (handle) => async () => nativeValueInfo(handle).value;
1762
1842
  const createSetValueOperation = (handle) => async (value) => {
1763
1843
  assertFiniteNumber("value", value);
@@ -1929,7 +2009,10 @@ const createGtkElement = (handle) => {
1929
2009
  return {
1930
2010
  ...common,
1931
2011
  kind: "window",
1932
- ...createChildContainerOperations(handle, void 0)
2012
+ bounds: createBoundsOperation(handle),
2013
+ ...createChildContainerOperations(handle, void 0),
2014
+ resizeHints: createResizeHintsOperation(handle),
2015
+ x11Info: createX11InfoOperation(handle)
1933
2016
  };
1934
2017
  case "button":
1935
2018
  return { ...common, kind: "button", click: createClickOperation(handle) };
@@ -2257,8 +2340,9 @@ const createGtkAppEnvironment = (baseEnv, overrides) => {
2257
2340
  const launchGtkApp = (appPath, args, options) => {
2258
2341
  const _args = args ?? [];
2259
2342
  const _timeoutMs = options?.timeoutMs ?? 1e4;
2343
+ const appEnvironment = createGtkAppEnvironment(process.env, options?.env);
2260
2344
  const child = spawn(appPath, [..._args], {
2261
- env: createGtkAppEnvironment(process.env, options?.env),
2345
+ env: appEnvironment,
2262
2346
  stdio: "pipe"
2263
2347
  });
2264
2348
  const state = {
@@ -2408,6 +2492,10 @@ const launchGtkApp = (appPath, args, options) => {
2408
2492
  throw normalizeNativeError(error);
2409
2493
  }
2410
2494
  },
2495
+ environment: async () => {
2496
+ assertProcessRunning(state, appPath);
2497
+ return { ...appEnvironment };
2498
+ },
2411
2499
  findById,
2412
2500
  findByPath,
2413
2501
  getById,
@@ -2476,4 +2564,4 @@ export {
2476
2564
  createGtkAppEnvironment as c,
2477
2565
  launchGtkApp as l
2478
2566
  };
2479
- //# sourceMappingURL=launchGtkApp-qi1qm5G4.js.map
2567
+ //# sourceMappingURL=launchGtkApp-Bst1BFbD.js.map