gestament 0.6.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 +34 -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 +34 -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-B3FMzhrc.js → launchGtkApp-BTBwPwyj.js} +166 -2
  30. package/dist/launchGtkApp-BTBwPwyj.js.map +1 -0
  31. package/dist/{launchGtkApp-OggUtTTC.cjs → launchGtkApp-Csx4r7AQ.cjs} +168 -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 +26 -4
  36. package/dist/launcherDriverProtocol.d.ts.map +1 -1
  37. package/dist/{native-C2tzSvVW.js → native-BRWJbzfa.js} +42 -14
  38. package/dist/native-BRWJbzfa.js.map +1 -0
  39. package/dist/{native-Xz0gjKti.cjs → native-C1llTPc6.cjs} +32 -4
  40. package/dist/native-C1llTPc6.cjs.map +1 -0
  41. package/dist/native.d.ts +16 -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-BqAHZ5WO.cjs.map → packageMetadata-DSIckEfC.cjs.map} +1 -1
  46. package/dist/packageMetadata-__qCDuxC.js +5 -0
  47. package/dist/{packageMetadata-BQE2KNaa.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 +83 -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-B3FMzhrc.js.map +0 -1
  66. package/dist/launchGtkApp-OggUtTTC.cjs.map +0 -1
  67. package/dist/native-C2tzSvVW.js.map +0 -1
  68. package/dist/native-Xz0gjKti.cjs.map +0 -1
  69. package/dist/packageMetadata-BQE2KNaa.js +0 -5
  70. package/dist/packageMetadata-BqAHZ5WO.cjs +0 -4
@@ -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-Xz0gjKti.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-OggUtTTC.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-OggUtTTC.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 })
@@ -1799,6 +1925,7 @@ const createProxyGtkElement = (session, ref) => {
1799
1925
  bounds,
1800
1926
  elementId
1801
1927
  });
1928
+ target.activate = () => session.request("window.activate", { elementId }).then(() => void 0);
1802
1929
  target.x11Info = () => session.request("window.x11Info", { elementId });
1803
1930
  addChildContainerProxyOperations(session, elementId, target);
1804
1931
  break;
@@ -2446,6 +2573,9 @@ const createSetBoundsOperation = (handle) => async (bounds) => {
2446
2573
  assertPositiveInt32("bounds.height", bounds.height);
2447
2574
  return native.nativeSetWindowBounds(handle, bounds);
2448
2575
  };
2576
+ const createActivateWindowOperation = (handle) => async () => {
2577
+ native.nativeActivateWindow(handle);
2578
+ };
2449
2579
  const createResizeHintsOperation = (handle) => async () => native.nativeResizeHints(handle);
2450
2580
  const createX11InfoOperation = (handle) => async () => native.nativeX11Info(handle);
2451
2581
  const createValueOperation = (handle) => async () => native.nativeValueInfo(handle).value;
@@ -2624,6 +2754,7 @@ const createGtkElement = (handle) => {
2624
2754
  ...createChildContainerOperations(handle, void 0),
2625
2755
  resizeTo: createResizeToOperation(handle),
2626
2756
  setBounds: createSetBoundsOperation(handle),
2757
+ activate: createActivateWindowOperation(handle),
2627
2758
  resizeHints: createResizeHintsOperation(handle),
2628
2759
  x11Info: createX11InfoOperation(handle)
2629
2760
  };
@@ -3140,6 +3271,38 @@ const launchGtkApp = (appPath, args, options) => {
3140
3271
  }
3141
3272
  return trayItem;
3142
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
+ });
3143
3306
  const app = {
3144
3307
  capture: async () => {
3145
3308
  assertNotReleased();
@@ -3165,6 +3328,7 @@ const launchGtkApp = (appPath, args, options) => {
3165
3328
  state.exitSignal === null ? null : state.exitSignal
3166
3329
  );
3167
3330
  },
3331
+ input,
3168
3332
  findById,
3169
3333
  findByPath,
3170
3334
  getById,
@@ -3231,4 +3395,4 @@ const createGtkAppLauncher = (options) => createDriverBackedGtkAppLauncher(optio
3231
3395
  exports.createGtkAppEnvironment = createGtkAppEnvironment;
3232
3396
  exports.createGtkAppLauncher = createGtkAppLauncher;
3233
3397
  exports.launchGtkApp = launchGtkApp;
3234
- //# sourceMappingURL=launchGtkApp-OggUtTTC.cjs.map
3398
+ //# sourceMappingURL=launchGtkApp-Csx4r7AQ.cjs.map