gestament 0.1.0 → 0.2.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 (36) hide show
  1. package/dist/element.d.ts +2 -2
  2. package/dist/errors.d.ts +2 -2
  3. package/dist/generated/packageMetadata.d.ts +4 -4
  4. package/dist/gestament-config.d.ts +2 -2
  5. package/dist/gestament-tray-host.cjs +1 -1
  6. package/dist/gestament-tray-host.d.ts +2 -2
  7. package/dist/gestament-tray-host.mjs +1 -1
  8. package/dist/gestament-xvfb-worker.d.ts +2 -2
  9. package/dist/gestament-xvfb.d.ts +2 -2
  10. package/dist/index.cjs +74 -1
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.ts +2 -2
  13. package/dist/index.mjs +74 -1
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/launchGtkApp.d.ts +2 -2
  16. package/dist/launchGtkApp.d.ts.map +1 -1
  17. package/dist/{native-DAhTiLnf.js → native-DUeVYIBs.js} +2 -2
  18. package/dist/{native-DAhTiLnf.js.map → native-DUeVYIBs.js.map} +1 -1
  19. package/dist/{native-BRnrsqMn.cjs → native-ie_XIt1J.cjs} +4 -4
  20. package/dist/{native-BRnrsqMn.cjs.map → native-ie_XIt1J.cjs.map} +1 -1
  21. package/dist/native.d.ts +2 -2
  22. package/dist/testing.d.ts +2 -2
  23. package/dist/tray.d.ts +2 -2
  24. package/dist/types.d.ts +22 -2
  25. package/dist/types.d.ts.map +1 -1
  26. package/package.json +8 -8
  27. package/prebuilds/linux-arm/gtk3/node.napi.armv7.glibc.node +0 -0
  28. package/prebuilds/linux-arm/gtk4/node.napi.armv7.glibc.node +0 -0
  29. package/prebuilds/linux-arm64/gtk3/node.napi.glibc.node +0 -0
  30. package/prebuilds/linux-arm64/gtk4/node.napi.glibc.node +0 -0
  31. package/prebuilds/linux-ia32/gtk3/node.napi.glibc.node +0 -0
  32. package/prebuilds/linux-ia32/gtk4/node.napi.glibc.node +0 -0
  33. package/prebuilds/linux-riscv64/gtk3/node.napi.glibc.node +0 -0
  34. package/prebuilds/linux-riscv64/gtk4/node.napi.glibc.node +0 -0
  35. package/prebuilds/linux-x64/gtk3/node.napi.glibc.node +0 -0
  36. package/prebuilds/linux-x64/gtk4/node.napi.glibc.node +0 -0
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  /*!
2
2
  * name: gestament
3
- * version: 0.1.0
3
+ * version: 0.2.0
4
4
  * description: TypeScript based test driver for GTK
5
5
  * author: Kouji Matsui (@kekyo@mi.kekyo.net)
6
6
  * license: MIT
7
7
  * repository.url: https://github.com/kekyo/gestament.git
8
- * git.commit.hash: 2e2298272ff7a9fff6945b8d87de6223ac4d7847
8
+ * git.commit.hash: 82eaccb340f7304524549a1f95888845deb4a156
9
9
  */
10
10
 
11
11
  export * from './types.js';
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { spawn } from "node:child_process";
2
- import { n as nativeElementInfo, a as nativeClick, b as nativeImageInfo, c as nativeCaptureBounds, d as nativeTableDeselectColumn, e as nativeTableSelectColumn, f as nativeTableDeselectRow, g as nativeTableSelectRow, h as nativeTableIsCellSelected, i as nativeTableIsColumnSelected, j as nativeTableIsRowSelected, k as nativeTableSelectedColumns, l as nativeTableSelectedRows, m as nativeTableColumnCount, o as nativeTableRowCount, p as nativeClearSelection, q as nativeSelectAllChildren, r as nativeDeselectChildAt, s as nativeSelectChildAt, t as nativeIsChildSelected, u as nativeSelectedChildAt, v as nativeSelectedChildCount, w as createGtkOperationFailedError, x as nativeChildCount, y as nativeChildAt, z as nativeValueInfo, A as nativeSetValue, B as nativeText, C as nativeSetText, D as nativeCapture, E as createGtkInvalidArgumentError, F as nativeTableCellAt, G as createGtkUnsupportedInterfaceError, H as createGtkElementNotFoundError, I as nativeFindAnyById, J as nativeTrayItems, K as createGtkStaleElementError, L as normalizeNativeError, M as nativeWindowCount, N as nativeWindowAt, O as nativeCaptureScreen, P as nativeFindById, Q as createGtkAppExitedError, R as nativeProcessAtspiReadiness } from "./native-DAhTiLnf.js";
2
+ import { n as nativeElementInfo, a as nativeClick, b as nativeImageInfo, c as nativeCaptureBounds, d as nativeTableDeselectColumn, e as nativeTableSelectColumn, f as nativeTableDeselectRow, g as nativeTableSelectRow, h as nativeTableIsCellSelected, i as nativeTableIsColumnSelected, j as nativeTableIsRowSelected, k as nativeTableSelectedColumns, l as nativeTableSelectedRows, m as nativeTableColumnCount, o as nativeTableRowCount, p as nativeClearSelection, q as nativeSelectAllChildren, r as nativeDeselectChildAt, s as nativeSelectChildAt, t as nativeIsChildSelected, u as nativeSelectedChildAt, v as nativeSelectedChildCount, w as createGtkOperationFailedError, x as nativeChildCount, y as nativeChildAt, z as nativeValueInfo, A as nativeSetValue, B as nativeText, C as nativeSetText, D as nativeCapture, E as createGtkInvalidArgumentError, F as nativeTableCellAt, G as createGtkUnsupportedInterfaceError, H as createGtkElementNotFoundError, I as nativeFindAnyById, J as nativeTrayItems, K as createGtkStaleElementError, L as normalizeNativeError, M as nativeWindowCount, N as nativeWindowAt, O as nativeCaptureScreen, P as nativeFindById, Q as createGtkAppExitedError, R as nativeProcessAtspiReadiness } from "./native-DUeVYIBs.js";
3
3
  /*!
4
4
  * name: async-primitives
5
5
  * version: 1.7.0
@@ -850,6 +850,33 @@ const assertNonNegativeIndex = (name, index) => {
850
850
  );
851
851
  }
852
852
  };
853
+ const parseElementPath = (path) => {
854
+ const segments = path.split(/[.:;,]/u);
855
+ const id = segments[0];
856
+ if (id === void 0 || id.length === 0) {
857
+ throw createGtkInvalidArgumentError(
858
+ "path must start with an accessible id."
859
+ );
860
+ }
861
+ const childIndexes = [];
862
+ for (let index = 1; index < segments.length; index += 1) {
863
+ const segment = segments[index];
864
+ if (segment === void 0 || !/^\d+$/u.test(segment)) {
865
+ throw createGtkInvalidArgumentError(
866
+ "path child indexes must be non-negative decimal integers."
867
+ );
868
+ }
869
+ const childIndex = Number(segment);
870
+ if (!Number.isSafeInteger(childIndex)) {
871
+ throw createGtkInvalidArgumentError(
872
+ "path child indexes must be safe non-negative integers."
873
+ );
874
+ }
875
+ childIndexes.push(childIndex);
876
+ }
877
+ return { id, childIndexes };
878
+ };
879
+ const isPathChildContainer = (element) => "childAt" in element;
853
880
  const waitForAtspiReady = async (state, command, timeoutMs, startedAt) => {
854
881
  if (state.atspiReady) {
855
882
  return assertProcessRunning(state, command);
@@ -944,6 +971,50 @@ const launchGtkApp = (appPath, args, options) => {
944
971
  }
945
972
  return element;
946
973
  };
974
+ const findByPath = async (path) => {
975
+ const parsedPath = parseElementPath(path);
976
+ const startedAt = Date.now();
977
+ await waitForAtspiReady(state, appPath, _timeoutMs, startedAt);
978
+ while (Date.now() - startedAt <= _timeoutMs) {
979
+ const processId = assertProcessRunning(state, appPath);
980
+ try {
981
+ const handle = nativeFindById(processId, parsedPath.id);
982
+ if (handle !== void 0) {
983
+ let element = createGtkElement(handle);
984
+ let resolved = true;
985
+ for (const childIndex of parsedPath.childIndexes) {
986
+ if (!isPathChildContainer(element)) {
987
+ resolved = false;
988
+ break;
989
+ }
990
+ const child2 = await element.childAt(childIndex);
991
+ if (child2 === void 0) {
992
+ resolved = false;
993
+ break;
994
+ }
995
+ element = child2;
996
+ }
997
+ if (resolved) {
998
+ return element;
999
+ }
1000
+ }
1001
+ } catch (error) {
1002
+ throw normalizeNativeError(error);
1003
+ }
1004
+ await delay(50);
1005
+ }
1006
+ assertProcessRunning(state, appPath);
1007
+ return void 0;
1008
+ };
1009
+ const getByPath = async (path) => {
1010
+ const element = await findByPath(path);
1011
+ if (element === void 0) {
1012
+ throw createGtkElementNotFoundError(
1013
+ `Element path was not found: ${path}`
1014
+ );
1015
+ }
1016
+ return element;
1017
+ };
947
1018
  const findTrayItem = async (selector) => {
948
1019
  const startedAt = Date.now();
949
1020
  while (Date.now() - startedAt <= _timeoutMs) {
@@ -987,7 +1058,9 @@ const launchGtkApp = (appPath, args, options) => {
987
1058
  }
988
1059
  },
989
1060
  findById,
1061
+ findByPath,
990
1062
  getById,
1063
+ getByPath,
991
1064
  windowAt: async (index) => {
992
1065
  assertNonNegativeIndex("index", index);
993
1066
  const processId = await waitForAtspiReady(