@e2e-dev/mobile 0.12.6 → 0.12.7-nightly-20261107030214

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 CHANGED
@@ -89,8 +89,8 @@ spread.
89
89
  (`ABOUT`, `android:id/title`) are the node's `testId`, what `getByTestId`
90
90
  matches.
91
91
  - **Actions**: tap, double tap, long press, fill, clear, check/uncheck (when
92
- the tree exposes the checked state; Android switches do not), focus on
93
- editable fields, `Enter`, single-character keys, swipe within a node, drag.
92
+ the tree exposes the checked state, as switches do on both platforms),
93
+ focus on editable fields, `Enter`, single-character keys, swipe within a node, drag.
94
94
  `selectOption`, `setInputFiles`, `scrollIntoView`, `secondaryTap`,
95
95
  `modifiers` on `tap` or `doubleTap`, focus on a control, and other keys fail with
96
96
  `UNSUPPORTED_CAPABILITY`.
package/dist/.build.json CHANGED
@@ -1 +1 @@
1
- {"version":"0.12.6"}
1
+ {"version":"0.12.7-nightly-20261107030214"}
package/dist/png.js CHANGED
@@ -1,10 +1,22 @@
1
- /** Screenshot masking policy; PNG parsing and encoding belong to pngjs. */
2
- import { PNG } from 'pngjs';
1
+ /** Screenshot masking policy: a PNG decoded with @napi-rs/image, its secure regions painted black, encoded again; the layout code turns the addon's pixels into 8-bit RGBA. */
2
+ import { endianness } from 'node:os';
3
+ import { FilterType, JsColorType, Transformer } from '@napi-rs/image';
4
+ const LITTLE_ENDIAN = endianness() === 'LE';
5
+ /** Channels per pixel, and whether each is a 16-bit sample, for every color type a decode reads: 8-bit RGB is widened by the addon before that. */
6
+ const LAYOUTS = {
7
+ [JsColorType.L8]: { channels: 1, wide: false },
8
+ [JsColorType.La8]: { channels: 2, wide: false },
9
+ [JsColorType.Rgba8]: { channels: 4, wide: false },
10
+ [JsColorType.L16]: { channels: 1, wide: true },
11
+ [JsColorType.La16]: { channels: 2, wide: true },
12
+ [JsColorType.Rgb16]: { channels: 3, wide: true },
13
+ [JsColorType.Rgba16]: { channels: 4, wide: true },
14
+ };
3
15
  /** Paints each requested rectangle opaque black, rounding outward and clipping to the image. */
4
16
  export function maskPng(bytes, rects) {
5
17
  if (rects.length === 0)
6
18
  return bytes;
7
- const image = PNG.sync.read(Buffer.from(bytes));
19
+ const image = decodeRgba(bytes);
8
20
  for (const rect of rects) {
9
21
  const x0 = Math.max(0, Math.floor(rect.x));
10
22
  const y0 = Math.max(0, Math.floor(rect.y));
@@ -20,5 +32,59 @@ export function maskPng(bytes, rects) {
20
32
  }
21
33
  }
22
34
  }
23
- return PNG.sync.write(image);
35
+ return encodeRgba(image);
36
+ }
37
+ /**
38
+ * Decodes PNG bytes to 8-bit RGBA, whatever the color type, bit depth, or
39
+ * palette; throws on bytes that are not a PNG. An 8-bit RGB screenshot is
40
+ * widened by the addon: opacity 1 keeps every sample and adds the opaque
41
+ * alpha channel, several times faster than `spread` does it.
42
+ */
43
+ function decodeRgba(bytes) {
44
+ const decoder = new Transformer(bytes);
45
+ const { width, height, format, colorType } = decoder.metadataSync();
46
+ if (format !== 'png')
47
+ throw new Error(`not a PNG: the bytes are ${format}`);
48
+ const rgb = colorType === JsColorType.Rgb8;
49
+ const raw = (rgb ? decoder.opacity(1) : decoder).rawPixelsSync();
50
+ const layout = LAYOUTS[rgb ? JsColorType.Rgba8 : colorType];
51
+ if (layout === undefined)
52
+ throw new Error(`unsupported PNG color type ${colorType}`);
53
+ const { channels, wide } = layout;
54
+ if (raw.length !== width * height * channels * (wide ? 2 : 1))
55
+ throw new Error('the decoded PNG pixels do not fill its size');
56
+ const samples = new Uint8Array(raw.buffer, raw.byteOffset, raw.byteLength);
57
+ if (channels === 4 && !wide)
58
+ return { width, height, data: samples };
59
+ return { width, height, data: spread(wide ? narrow(samples) : samples, channels, width * height) };
60
+ }
61
+ /**
62
+ * Encodes an image as PNG bytes, each row adaptively filtered: the addon's
63
+ * default writes no filter, which makes screenshots markedly larger.
64
+ */
65
+ function encodeRgba(image) {
66
+ const png = Transformer.fromRgbaPixels(image.data, image.width, image.height).pngSync({ filterType: FilterType.Adaptive });
67
+ return new Uint8Array(png.buffer, png.byteOffset, png.byteLength);
68
+ }
69
+ /** 16-bit samples in native byte order as 8-bit samples, rounded. */
70
+ function narrow(bytes) {
71
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
72
+ const samples = new Uint8Array(bytes.length / 2);
73
+ for (let at = 0; at < samples.length; at += 1)
74
+ samples[at] = Math.round((view.getUint16(at * 2, LITTLE_ENDIAN) * 255) / 65535);
75
+ return samples;
76
+ }
77
+ /** 8-bit samples of `channels` per pixel (gray, gray and alpha, RGB) as RGBA; a gray or RGB image is opaque. */
78
+ function spread(samples, channels, pixels) {
79
+ const out = new Uint8Array(pixels * 4);
80
+ const gray = channels <= 2;
81
+ const alpha = channels === 2 || channels === 4;
82
+ for (let pixel = 0, from = 0, to = 0; pixel < pixels; pixel += 1, from += channels, to += 4) {
83
+ const r = samples[from];
84
+ out[to] = r;
85
+ out[to + 1] = gray ? r : samples[from + 1];
86
+ out[to + 2] = gray ? r : samples[from + 2];
87
+ out[to + 3] = alpha ? samples[from + channels - 1] : 255;
88
+ }
89
+ return out;
24
90
  }
package/dist/surface.js CHANGED
@@ -1131,7 +1131,8 @@ export class AgentDeviceSurface {
1131
1131
  case 'uncheck': {
1132
1132
  const wanted = action.kind === 'check';
1133
1133
  const checked = target.node.states?.checked;
1134
- // A toggle whose state the tree does not expose (Android switches)
1134
+ // A toggle whose state the tree does not expose (a radio or checkbox
1135
+ // the app gives no checked state)
1135
1136
  // cannot be set, only flipped; flipping blind could undo a correct state.
1136
1137
  if (checked === undefined) {
1137
1138
  throw unsupported(`agent-device cannot read whether node ${target.id} is checked; tap it instead`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e2e-dev/mobile",
3
- "version": "0.12.6",
3
+ "version": "0.12.7-nightly-20261107030214",
4
4
  "description": "Mobile engine (iOS and Android) for e2e agentic end-to-end testing, built on agent-device",
5
5
  "keywords": [
6
6
  "e2e",
@@ -55,13 +55,13 @@
55
55
  "NOTICE"
56
56
  ],
57
57
  "dependencies": {
58
+ "@napi-rs/image": "1.16.0",
58
59
  "agent-device": "0.21.36",
59
- "pngjs": "7.0.0",
60
60
  "zod": "4.6.7"
61
61
  },
62
62
  "peerDependencies": {
63
63
  "ai": "^7.0.0",
64
- "e2e": ">=0.22.1 <1"
64
+ "e2e": "0.23.1-nightly-20261107030214"
65
65
  },
66
66
  "peerDependenciesMeta": {
67
67
  "ai": {
@@ -70,9 +70,8 @@
70
70
  },
71
71
  "devDependencies": {
72
72
  "@types/node": "26.6.6",
73
- "@types/pngjs": "6.0.5",
74
73
  "ai": "7.0.163",
75
- "e2e": "0.23.0",
74
+ "e2e": "0.23.1-nightly-20261107030214",
76
75
  "typescript": "7.0.2",
77
76
  "vitest": "5.1.0"
78
77
  },