appium-ios-remotexpc 2.2.0 → 2.2.2

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 (34) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/src/lib/tunnel/tunnel-registry-server.d.ts.map +1 -1
  3. package/build/src/lib/tunnel/tunnel-registry-server.js +11 -0
  4. package/build/src/lib/tunnel/tunnel-registry-server.js.map +1 -1
  5. package/build/src/services/ios/afc/codec.d.ts +13 -4
  6. package/build/src/services/ios/afc/codec.d.ts.map +1 -1
  7. package/build/src/services/ios/afc/codec.js +57 -32
  8. package/build/src/services/ios/afc/codec.js.map +1 -1
  9. package/build/src/services/ios/afc/constants.d.ts +2 -2
  10. package/build/src/services/ios/afc/constants.d.ts.map +1 -1
  11. package/build/src/services/ios/afc/constants.js +4 -5
  12. package/build/src/services/ios/afc/constants.js.map +1 -1
  13. package/build/src/services/ios/afc/demux.d.ts +40 -0
  14. package/build/src/services/ios/afc/demux.d.ts.map +1 -0
  15. package/build/src/services/ios/afc/demux.js +174 -0
  16. package/build/src/services/ios/afc/demux.js.map +1 -0
  17. package/build/src/services/ios/afc/index.d.ts +3 -5
  18. package/build/src/services/ios/afc/index.d.ts.map +1 -1
  19. package/build/src/services/ios/afc/index.js +34 -40
  20. package/build/src/services/ios/afc/index.js.map +1 -1
  21. package/build/src/services/ios/afc/stream-utils.d.ts +10 -11
  22. package/build/src/services/ios/afc/stream-utils.d.ts.map +1 -1
  23. package/build/src/services/ios/afc/stream-utils.js +7 -8
  24. package/build/src/services/ios/afc/stream-utils.js.map +1 -1
  25. package/build/src/services/ios/testmanagerd/index.js +2 -2
  26. package/build/src/services/ios/testmanagerd/index.js.map +1 -1
  27. package/package.json +2 -1
  28. package/src/lib/tunnel/tunnel-registry-server.ts +10 -0
  29. package/src/services/ios/afc/codec.ts +73 -37
  30. package/src/services/ios/afc/constants.ts +4 -6
  31. package/src/services/ios/afc/demux.ts +225 -0
  32. package/src/services/ios/afc/index.ts +48 -67
  33. package/src/services/ios/afc/stream-utils.ts +21 -24
  34. package/src/services/ios/testmanagerd/index.ts +2 -2
@@ -1,16 +1,19 @@
1
1
  import { Readable, Writable } from 'node:stream';
2
2
 
3
3
  import { buildReadPayload, nextReadChunkSize, writeUInt64LE } from './codec.js';
4
- import { AFC_WRITE_THIS_LENGTH } from './constants.js';
4
+ import { MAXIMUM_WRITE_SIZE } from './constants.js';
5
5
  import { AfcError, AfcOpcode } from './enums.js';
6
6
 
7
- type AfcDispatcher = (op: AfcOpcode, payload: Buffer) => Promise<void>;
8
-
9
- type AfcWriteDispatcher = (
7
+ export type AfcSendAndWait = (
10
8
  op: AfcOpcode,
11
- payload: Buffer,
12
- thisLenOverride?: number,
13
- ) => Promise<void>;
9
+ headerPayload?: Buffer,
10
+ content?: Buffer,
11
+ ) => Promise<{ status: AfcError; data: Buffer }>;
12
+
13
+ export type AfcFileWriteAndWait = (
14
+ handlePayload: Buffer,
15
+ content: Buffer,
16
+ ) => Promise<{ status: AfcError; data: Buffer }>;
14
17
 
15
18
  /**
16
19
  * Create a readable stream that pulls file chunks over AFC READ requests.
@@ -18,8 +21,7 @@ type AfcWriteDispatcher = (
18
21
  export function createAfcReadStream(
19
22
  handle: bigint,
20
23
  size: bigint,
21
- dispatch: AfcDispatcher,
22
- receive: () => Promise<{ status: AfcError; data: Buffer }>,
24
+ sendAndWait: AfcSendAndWait,
23
25
  ): Readable {
24
26
  let left = size;
25
27
 
@@ -32,8 +34,10 @@ export function createAfcReadStream(
32
34
  }
33
35
 
34
36
  const toRead = nextReadChunkSize(left);
35
- await dispatch(AfcOpcode.READ, buildReadPayload(handle, toRead));
36
- const { status, data } = await receive();
37
+ const { status, data } = await sendAndWait(
38
+ AfcOpcode.READ,
39
+ buildReadPayload(handle, toRead),
40
+ );
37
41
 
38
42
  if (status !== AfcError.SUCCESS) {
39
43
  const errorName = AfcError[status] || 'UNKNOWN';
@@ -60,10 +64,11 @@ export function createAfcReadStream(
60
64
  */
61
65
  export function createAfcWriteStream(
62
66
  handle: bigint,
63
- dispatch: AfcWriteDispatcher,
64
- receive: () => Promise<{ status: AfcError; data: Buffer }>,
65
- chunkSize?: number,
67
+ writeChunk: AfcFileWriteAndWait,
68
+ chunkSize = MAXIMUM_WRITE_SIZE,
66
69
  ): Writable {
70
+ const handlePayload = writeUInt64LE(handle);
71
+
67
72
  return new Writable({
68
73
  async write(
69
74
  chunk: Buffer,
@@ -73,18 +78,10 @@ export function createAfcWriteStream(
73
78
  try {
74
79
  let offset = 0;
75
80
  while (offset < chunk.length) {
76
- const end = Math.min(
77
- offset + (chunkSize ?? chunk.length),
78
- chunk.length,
79
- );
81
+ const end = Math.min(offset + chunkSize, chunk.length);
80
82
  const subchunk = chunk.subarray(offset, end);
81
83
 
82
- await dispatch(
83
- AfcOpcode.WRITE,
84
- Buffer.concat([writeUInt64LE(handle), subchunk]),
85
- AFC_WRITE_THIS_LENGTH,
86
- );
87
- const { status } = await receive();
84
+ const { status } = await writeChunk(handlePayload, subchunk);
88
85
 
89
86
  if (status !== AfcError.SUCCESS) {
90
87
  const errorName = AfcError[status] || 'UNKNOWN';
@@ -785,10 +785,10 @@ export class DvtTestmanagedProxyService extends BaseService {
785
785
  return this.parseAuxiliaryStandard(buffer);
786
786
  }
787
787
 
788
- // Alternate format used by go-ios / iOS 17+ testmanagerd callbacks:
788
+ // Alternate format used by iOS 17+ testmanagerd callbacks:
789
789
  // The first 16 bytes are an AuxiliaryHeader (magic + length) that does
790
790
  // not match the standard MESSAGE_AUX_MAGIC. The remaining bytes are
791
- // DTX PrimitiveDictionary key-value pairs (see go-ios dtx.go).
791
+ // DTX PrimitiveDictionary key-value pairs.
792
792
  const result = this.parseAuxiliaryPrimitiveDictionary(buffer.subarray(16));
793
793
  if (result.length === 0) {
794
794
  log.debug(