gestament 0.5.0 → 0.7.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 (70) hide show
  1. package/dist/displaySession.d.ts +2 -2
  2. package/dist/displaySession.d.ts.map +1 -1
  3. package/dist/element.d.ts +2 -2
  4. package/dist/element.d.ts.map +1 -1
  5. package/dist/errors.d.ts +2 -2
  6. package/dist/generated/packageMetadata.d.ts +4 -4
  7. package/dist/gestament-config.d.ts +2 -2
  8. package/dist/gestament-launcher-driver.cjs +46 -1
  9. package/dist/gestament-launcher-driver.cjs.map +1 -1
  10. package/dist/gestament-launcher-driver.d.ts +2 -2
  11. package/dist/gestament-launcher-driver.mjs +46 -1
  12. package/dist/gestament-launcher-driver.mjs.map +1 -1
  13. package/dist/gestament-tray-host.cjs +1 -1
  14. package/dist/gestament-tray-host.d.ts +2 -2
  15. package/dist/gestament-tray-host.mjs +1 -1
  16. package/dist/gestament-xvfb-pool-probe.cjs +1 -1
  17. package/dist/gestament-xvfb-pool-probe.d.ts +2 -2
  18. package/dist/gestament-xvfb-pool-probe.mjs +1 -1
  19. package/dist/gestament-xvfb-worker.d.ts +2 -2
  20. package/dist/gestament-xvfb.d.ts +2 -2
  21. package/dist/gestament.cjs +1 -1
  22. package/dist/gestament.d.ts +2 -2
  23. package/dist/gestament.mjs +1 -1
  24. package/dist/index.cjs +1 -1
  25. package/dist/index.d.ts +2 -2
  26. package/dist/index.mjs +1 -1
  27. package/dist/input.d.ts +21 -0
  28. package/dist/input.d.ts.map +1 -0
  29. package/dist/{launchGtkApp-EI6OIpPI.js → launchGtkApp-BTBwPwyj.js} +216 -2
  30. package/dist/launchGtkApp-BTBwPwyj.js.map +1 -0
  31. package/dist/{launchGtkApp-CzYcrc9f.cjs → launchGtkApp-Csx4r7AQ.cjs} +218 -4
  32. package/dist/launchGtkApp-Csx4r7AQ.cjs.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 +37 -4
  36. package/dist/launcherDriverProtocol.d.ts.map +1 -1
  37. package/dist/{native-DlCBBWlV.js → native-BRWJbzfa.js} +53 -11
  38. package/dist/native-BRWJbzfa.js.map +1 -0
  39. package/dist/{native-Kfm95Uxw.cjs → native-C1llTPc6.cjs} +46 -4
  40. package/dist/native-C1llTPc6.cjs.map +1 -0
  41. package/dist/native.d.ts +22 -2
  42. package/dist/native.d.ts.map +1 -1
  43. package/dist/output.d.ts +2 -2
  44. package/dist/packageMetadata-DSIckEfC.cjs +4 -0
  45. package/dist/{packageMetadata-CewXH0iF.cjs.map → packageMetadata-DSIckEfC.cjs.map} +1 -1
  46. package/dist/packageMetadata-__qCDuxC.js +5 -0
  47. package/dist/{packageMetadata-DjxyJCJm.js.map → packageMetadata-__qCDuxC.js.map} +1 -1
  48. package/dist/prerequisites.d.ts +2 -2
  49. package/dist/testing.d.ts +2 -2
  50. package/dist/tray.d.ts +2 -2
  51. package/dist/types.d.ts +106 -2
  52. package/dist/types.d.ts.map +1 -1
  53. package/dist/wait.d.ts +2 -2
  54. package/package.json +7 -7
  55. package/prebuilds/linux-arm/gtk3/node.napi.armv7.glibc.node +0 -0
  56. package/prebuilds/linux-arm/gtk4/node.napi.armv7.glibc.node +0 -0
  57. package/prebuilds/linux-arm64/gtk3/node.napi.glibc.node +0 -0
  58. package/prebuilds/linux-arm64/gtk4/node.napi.glibc.node +0 -0
  59. package/prebuilds/linux-ia32/gtk3/node.napi.glibc.node +0 -0
  60. package/prebuilds/linux-ia32/gtk4/node.napi.glibc.node +0 -0
  61. package/prebuilds/linux-riscv64/gtk3/node.napi.glibc.node +0 -0
  62. package/prebuilds/linux-riscv64/gtk4/node.napi.glibc.node +0 -0
  63. package/prebuilds/linux-x64/gtk3/node.napi.glibc.node +0 -0
  64. package/prebuilds/linux-x64/gtk4/node.napi.glibc.node +0 -0
  65. package/dist/launchGtkApp-CzYcrc9f.cjs.map +0 -1
  66. package/dist/launchGtkApp-EI6OIpPI.js.map +0 -1
  67. package/dist/native-DlCBBWlV.js.map +0 -1
  68. package/dist/native-Kfm95Uxw.cjs.map +0 -1
  69. package/dist/packageMetadata-CewXH0iF.cjs +0 -4
  70. package/dist/packageMetadata-DjxyJCJm.js +0 -5
@@ -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-Kfm95Uxw.cjs");
11
+ const native = require("./native-C1llTPc6.cjs");
12
12
  var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
13
13
  const normalizeOutputBufferBytes = (value, optionName = "outputBufferBytes") => {
14
14
  if (value === void 0) {
@@ -235,6 +235,113 @@ const notifyGtkSystemOutput = (callback, event) => {
235
235
  });
236
236
  }
237
237
  };
238
+ const keyboardModifiers = ["shift", "control", "alt", "super"];
239
+ const mouseButtons = ["left", "middle", "right", "back", "forward"];
240
+ const modifierKeyNames = /* @__PURE__ */ new Set([
241
+ "alt",
242
+ "alt_l",
243
+ "alt_r",
244
+ "control",
245
+ "control_l",
246
+ "control_r",
247
+ "ctrl",
248
+ "ctrl_l",
249
+ "ctrl_r",
250
+ "hyper",
251
+ "hyper_l",
252
+ "hyper_r",
253
+ "meta",
254
+ "meta_l",
255
+ "meta_r",
256
+ "shift",
257
+ "shift_l",
258
+ "shift_r",
259
+ "super",
260
+ "super_l",
261
+ "super_r"
262
+ ]);
263
+ const isKeyboardModifier = (value) => keyboardModifiers.includes(value);
264
+ const isMouseButton = (value) => mouseButtons.includes(value);
265
+ const assertBoolean = (name, value) => {
266
+ if (typeof value !== "boolean") {
267
+ throw errors.createGtkInvalidArgumentError(`${name} must be a boolean.`);
268
+ }
269
+ };
270
+ const assertInt32$1 = (name, value) => {
271
+ if (!Number.isInteger(value) || value < -2147483648 || value > 2147483647) {
272
+ throw errors.createGtkInvalidArgumentError(`${name} must be a 32-bit integer.`);
273
+ }
274
+ };
275
+ const assertFiniteInteger = (name, value) => {
276
+ if (!Number.isInteger(value)) {
277
+ throw errors.createGtkInvalidArgumentError(`${name} must be an integer.`);
278
+ }
279
+ };
280
+ const assertKeysym = (value) => {
281
+ if (!Number.isInteger(value) || value < 0 || value > 4294967295) {
282
+ throw errors.createGtkInvalidArgumentError(
283
+ "key numeric value must be an unsigned 32-bit integer."
284
+ );
285
+ }
286
+ };
287
+ const normalizedKeyName = (key) => key.trim().toLowerCase().replace(/[-\s]+/gu, "_");
288
+ const assertNonModifierKeyName = (key) => {
289
+ if (key.length === 0) {
290
+ throw errors.createGtkInvalidArgumentError("key must not be empty.");
291
+ }
292
+ if (modifierKeyNames.has(normalizedKeyName(key))) {
293
+ throw errors.createGtkInvalidArgumentError(
294
+ "modifier keys must be controlled with setModifier()."
295
+ );
296
+ }
297
+ };
298
+ const createGtkInputController = (backend) => ({
299
+ setModifier: async (modifier, pressed) => {
300
+ if (!isKeyboardModifier(modifier)) {
301
+ throw errors.createGtkInvalidArgumentError(
302
+ `modifier must be shift, control, alt, or super: ${String(modifier)}`
303
+ );
304
+ }
305
+ assertBoolean("pressed", pressed);
306
+ await backend.setModifier(modifier, pressed);
307
+ },
308
+ pressKey: async (key) => {
309
+ if (typeof key === "string") {
310
+ assertNonModifierKeyName(key);
311
+ await backend.pressKeyName(key);
312
+ return;
313
+ }
314
+ if (typeof key === "number") {
315
+ assertKeysym(key);
316
+ await backend.pressKeySym(key);
317
+ return;
318
+ }
319
+ throw errors.createGtkInvalidArgumentError(
320
+ "key must be a string keysym name or numeric keysym value."
321
+ );
322
+ },
323
+ moveMouseTo: async (x, y) => {
324
+ assertInt32$1("x", x);
325
+ assertInt32$1("y", y);
326
+ await backend.moveMouseTo(x, y);
327
+ },
328
+ setMouseButton: async (button, pressed) => {
329
+ if (!isMouseButton(button)) {
330
+ throw errors.createGtkInvalidArgumentError(
331
+ `button must be left, middle, right, back, or forward: ${String(
332
+ button
333
+ )}`
334
+ );
335
+ }
336
+ assertBoolean("pressed", pressed);
337
+ await backend.setMouseButton(button, pressed);
338
+ },
339
+ scrollWheel: async (xSteps, ySteps) => {
340
+ assertFiniteInteger("xSteps", xSteps);
341
+ assertFiniteInteger("ySteps", ySteps);
342
+ await backend.scrollWheel(xSteps, ySteps);
343
+ }
344
+ });
238
345
  const defaultDisplay = "xvfb";
239
346
  const defaultGSettings = "memory";
240
347
  const defaultTheme = "Adwaita";
@@ -684,7 +791,7 @@ const resolveLauncherEnvironment = (options, effective) => {
684
791
  };
685
792
  const resolveDriverPath = () => {
686
793
  const driverPath = node_path.resolve(
687
- node_path.dirname(node_url.fileURLToPath(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("launchGtkApp-CzYcrc9f.cjs", document.baseURI).href)),
794
+ node_path.dirname(node_url.fileURLToPath(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("launchGtkApp-Csx4r7AQ.cjs", document.baseURI).href)),
688
795
  "..",
689
796
  "dist",
690
797
  "gestament-launcher-driver.cjs"
@@ -698,7 +805,7 @@ const resolveDriverPath = () => {
698
805
  };
699
806
  const resolveXvfbPoolProbePath = () => {
700
807
  const probePath = node_path.resolve(
701
- node_path.dirname(node_url.fileURLToPath(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("launchGtkApp-CzYcrc9f.cjs", document.baseURI).href)),
808
+ node_path.dirname(node_url.fileURLToPath(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("launchGtkApp-Csx4r7AQ.cjs", document.baseURI).href)),
702
809
  "..",
703
810
  "dist",
704
811
  "gestament-xvfb-pool-probe.cjs"
@@ -1669,6 +1776,25 @@ const createProxyGtkApp = (session, ref, outputSubscription) => {
1669
1776
  await appRequest("app.environment")
1670
1777
  ),
1671
1778
  output: () => appRequest("app.output"),
1779
+ input: createGtkInputController({
1780
+ setModifier: (modifier, pressed) => appRequest("app.inputSetModifier", { modifier, pressed }).then(
1781
+ () => void 0
1782
+ ),
1783
+ pressKeyName: (key) => appRequest("app.inputPressKeyName", { key }).then(
1784
+ () => void 0
1785
+ ),
1786
+ pressKeySym: (keysym) => appRequest("app.inputPressKeySym", { keysym }).then(
1787
+ () => void 0
1788
+ ),
1789
+ moveMouseTo: (x, y) => appRequest("app.inputMoveMouse", { x, y }).then(() => void 0),
1790
+ setMouseButton: (button, pressed) => appRequest("app.inputSetMouseButton", {
1791
+ button,
1792
+ pressed
1793
+ }).then(() => void 0),
1794
+ scrollWheel: (xSteps, ySteps) => appRequest("app.inputScrollWheel", { xSteps, ySteps }).then(
1795
+ () => void 0
1796
+ )
1797
+ }),
1672
1798
  findById: async (id) => elementRefToProxy(
1673
1799
  session,
1674
1800
  await appRequest("app.findById", { id })
@@ -1782,9 +1908,24 @@ const createProxyGtkElement = (session, ref) => {
1782
1908
  switch (ref.kind) {
1783
1909
  case "window":
1784
1910
  target.bounds = () => session.request("element.bounds", { elementId });
1911
+ target.moveTo = (x, y) => session.request("window.moveTo", {
1912
+ elementId,
1913
+ x,
1914
+ y
1915
+ });
1785
1916
  target.resizeHints = () => session.request("window.resizeHints", {
1786
1917
  elementId
1787
1918
  });
1919
+ target.resizeTo = (width, height) => session.request("window.resizeTo", {
1920
+ elementId,
1921
+ height,
1922
+ width
1923
+ });
1924
+ target.setBounds = (bounds) => session.request("window.setBounds", {
1925
+ bounds,
1926
+ elementId
1927
+ });
1928
+ target.activate = () => session.request("window.activate", { elementId }).then(() => void 0);
1788
1929
  target.x11Info = () => session.request("window.x11Info", { elementId });
1789
1930
  addChildContainerProxyOperations(session, elementId, target);
1790
1931
  break;
@@ -2007,6 +2148,19 @@ const assertFiniteNumber = (name, value) => {
2007
2148
  throw errors.createGtkInvalidArgumentError(`${name} must be a finite number.`);
2008
2149
  }
2009
2150
  };
2151
+ const int32Min = -2147483648;
2152
+ const int32Max = 2147483647;
2153
+ const assertInt32 = (name, value) => {
2154
+ if (!Number.isInteger(value) || value < int32Min || value > int32Max) {
2155
+ throw errors.createGtkInvalidArgumentError(`${name} must be a 32-bit integer.`);
2156
+ }
2157
+ };
2158
+ const assertPositiveInt32 = (name, value) => {
2159
+ assertInt32(name, value);
2160
+ if (value <= 0) {
2161
+ throw errors.createGtkInvalidArgumentError(`${name} must be greater than zero.`);
2162
+ }
2163
+ };
2010
2164
  const normalizeRoleName = (roleName) => roleName.trim().toLowerCase().replace(/[_-]+/g, " ").replace(/\s+/g, " ");
2011
2165
  const hasInterface = (info, name) => info.interfaces.some(
2012
2166
  (interfaceName) => interfaceName.toLowerCase() === name.toLowerCase()
@@ -2399,6 +2553,29 @@ const createImageInfoOperation = (handle) => async () => {
2399
2553
  };
2400
2554
  };
2401
2555
  const createBoundsOperation = (handle) => async () => native.nativeBounds(handle);
2556
+ const createMoveToOperation = (handle) => async (x, y) => {
2557
+ assertInt32("x", x);
2558
+ assertInt32("y", y);
2559
+ return native.nativeMoveWindow(handle, x, y);
2560
+ };
2561
+ const createResizeToOperation = (handle) => async (width, height) => {
2562
+ assertPositiveInt32("width", width);
2563
+ assertPositiveInt32("height", height);
2564
+ return native.nativeResizeWindow(handle, width, height);
2565
+ };
2566
+ const createSetBoundsOperation = (handle) => async (bounds) => {
2567
+ if (typeof bounds !== "object" || bounds === null) {
2568
+ throw errors.createGtkInvalidArgumentError("bounds must be an object.");
2569
+ }
2570
+ assertInt32("bounds.x", bounds.x);
2571
+ assertInt32("bounds.y", bounds.y);
2572
+ assertPositiveInt32("bounds.width", bounds.width);
2573
+ assertPositiveInt32("bounds.height", bounds.height);
2574
+ return native.nativeSetWindowBounds(handle, bounds);
2575
+ };
2576
+ const createActivateWindowOperation = (handle) => async () => {
2577
+ native.nativeActivateWindow(handle);
2578
+ };
2402
2579
  const createResizeHintsOperation = (handle) => async () => native.nativeResizeHints(handle);
2403
2580
  const createX11InfoOperation = (handle) => async () => native.nativeX11Info(handle);
2404
2581
  const createValueOperation = (handle) => async () => native.nativeValueInfo(handle).value;
@@ -2573,7 +2750,11 @@ const createGtkElement = (handle) => {
2573
2750
  ...common,
2574
2751
  kind: "window",
2575
2752
  bounds: createBoundsOperation(handle),
2753
+ moveTo: createMoveToOperation(handle),
2576
2754
  ...createChildContainerOperations(handle, void 0),
2755
+ resizeTo: createResizeToOperation(handle),
2756
+ setBounds: createSetBoundsOperation(handle),
2757
+ activate: createActivateWindowOperation(handle),
2577
2758
  resizeHints: createResizeHintsOperation(handle),
2578
2759
  x11Info: createX11InfoOperation(handle)
2579
2760
  };
@@ -3090,6 +3271,38 @@ const launchGtkApp = (appPath, args, options) => {
3090
3271
  }
3091
3272
  return trayItem;
3092
3273
  };
3274
+ const input = createGtkInputController({
3275
+ setModifier: async (modifier, pressed) => {
3276
+ assertNotReleased();
3277
+ assertProcessRunning(state, appPath);
3278
+ native.nativeInputSetModifier(modifier, pressed);
3279
+ },
3280
+ pressKeyName: async (key) => {
3281
+ assertNotReleased();
3282
+ assertProcessRunning(state, appPath);
3283
+ native.nativeInputPressKeyName(key);
3284
+ },
3285
+ pressKeySym: async (keysym) => {
3286
+ assertNotReleased();
3287
+ assertProcessRunning(state, appPath);
3288
+ native.nativeInputPressKeySym(keysym);
3289
+ },
3290
+ moveMouseTo: async (x, y) => {
3291
+ assertNotReleased();
3292
+ assertProcessRunning(state, appPath);
3293
+ native.nativeInputMoveMouse(x, y);
3294
+ },
3295
+ setMouseButton: async (button, pressed) => {
3296
+ assertNotReleased();
3297
+ assertProcessRunning(state, appPath);
3298
+ native.nativeInputSetMouseButton(button, pressed);
3299
+ },
3300
+ scrollWheel: async (xSteps, ySteps) => {
3301
+ assertNotReleased();
3302
+ assertProcessRunning(state, appPath);
3303
+ native.nativeInputScrollWheel(xSteps, ySteps);
3304
+ }
3305
+ });
3093
3306
  const app = {
3094
3307
  capture: async () => {
3095
3308
  assertNotReleased();
@@ -3115,6 +3328,7 @@ const launchGtkApp = (appPath, args, options) => {
3115
3328
  state.exitSignal === null ? null : state.exitSignal
3116
3329
  );
3117
3330
  },
3331
+ input,
3118
3332
  findById,
3119
3333
  findByPath,
3120
3334
  getById,
@@ -3181,4 +3395,4 @@ const createGtkAppLauncher = (options) => createDriverBackedGtkAppLauncher(optio
3181
3395
  exports.createGtkAppEnvironment = createGtkAppEnvironment;
3182
3396
  exports.createGtkAppLauncher = createGtkAppLauncher;
3183
3397
  exports.launchGtkApp = launchGtkApp;
3184
- //# sourceMappingURL=launchGtkApp-CzYcrc9f.cjs.map
3398
+ //# sourceMappingURL=launchGtkApp-Csx4r7AQ.cjs.map