@yume-chan/adb 0.0.18 → 0.0.19

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 (164) hide show
  1. package/CHANGELOG.json +21 -0
  2. package/CHANGELOG.md +11 -1
  3. package/esm/adb.d.ts +63 -60
  4. package/esm/adb.d.ts.map +1 -1
  5. package/esm/adb.js +257 -249
  6. package/esm/adb.js.map +1 -1
  7. package/esm/auth.d.ts +51 -51
  8. package/esm/auth.d.ts.map +1 -1
  9. package/esm/auth.js +95 -96
  10. package/esm/auth.js.map +1 -1
  11. package/esm/backend.d.ts +8 -8
  12. package/esm/backend.d.ts.map +1 -1
  13. package/esm/backend.js +1 -1
  14. package/esm/commands/base.d.ts +6 -6
  15. package/esm/commands/base.d.ts.map +1 -1
  16. package/esm/commands/base.js +8 -8
  17. package/esm/commands/framebuffer.d.ts +53 -53
  18. package/esm/commands/framebuffer.d.ts.map +1 -1
  19. package/esm/commands/framebuffer.js +46 -46
  20. package/esm/commands/framebuffer.js.map +1 -1
  21. package/esm/commands/index.d.ts +7 -8
  22. package/esm/commands/index.d.ts.map +1 -1
  23. package/esm/commands/index.js +7 -8
  24. package/esm/commands/index.js.map +1 -1
  25. package/esm/commands/install.d.ts +9 -3
  26. package/esm/commands/install.d.ts.map +1 -1
  27. package/esm/commands/install.js +26 -26
  28. package/esm/commands/install.js.map +1 -1
  29. package/esm/commands/power.d.ts +22 -22
  30. package/esm/commands/power.js +48 -48
  31. package/esm/commands/reverse.d.ts +41 -28
  32. package/esm/commands/reverse.d.ts.map +1 -1
  33. package/esm/commands/reverse.js +125 -100
  34. package/esm/commands/reverse.js.map +1 -1
  35. package/esm/commands/subprocess/command.d.ts +57 -51
  36. package/esm/commands/subprocess/command.d.ts.map +1 -1
  37. package/esm/commands/subprocess/command.js +86 -80
  38. package/esm/commands/subprocess/command.js.map +1 -1
  39. package/esm/commands/subprocess/index.d.ts +3 -3
  40. package/esm/commands/subprocess/index.js +3 -3
  41. package/esm/commands/subprocess/protocols/index.d.ts +3 -3
  42. package/esm/commands/subprocess/protocols/index.js +3 -3
  43. package/esm/commands/subprocess/protocols/none.d.ts +35 -35
  44. package/esm/commands/subprocess/protocols/none.d.ts.map +1 -1
  45. package/esm/commands/subprocess/protocols/none.js +65 -55
  46. package/esm/commands/subprocess/protocols/none.js.map +1 -1
  47. package/esm/commands/subprocess/protocols/shell.d.ts +39 -38
  48. package/esm/commands/subprocess/protocols/shell.d.ts.map +1 -1
  49. package/esm/commands/subprocess/protocols/shell.js +166 -162
  50. package/esm/commands/subprocess/protocols/shell.js.map +1 -1
  51. package/esm/commands/subprocess/protocols/types.d.ts +49 -49
  52. package/esm/commands/subprocess/protocols/types.d.ts.map +1 -1
  53. package/esm/commands/subprocess/protocols/types.js +1 -1
  54. package/esm/commands/subprocess/utils.d.ts +1 -1
  55. package/esm/commands/subprocess/utils.js +18 -18
  56. package/esm/commands/sync/index.d.ts +8 -7
  57. package/esm/commands/sync/index.d.ts.map +1 -1
  58. package/esm/commands/sync/index.js +8 -7
  59. package/esm/commands/sync/index.js.map +1 -1
  60. package/esm/commands/sync/list.d.ts +42 -40
  61. package/esm/commands/sync/list.d.ts.map +1 -1
  62. package/esm/commands/sync/list.js +67 -47
  63. package/esm/commands/sync/list.js.map +1 -1
  64. package/esm/commands/sync/pull.d.ts +13 -11
  65. package/esm/commands/sync/pull.d.ts.map +1 -1
  66. package/esm/commands/sync/pull.js +35 -37
  67. package/esm/commands/sync/pull.js.map +1 -1
  68. package/esm/commands/sync/push.d.ts +46 -7
  69. package/esm/commands/sync/push.d.ts.map +1 -1
  70. package/esm/commands/sync/push.js +89 -22
  71. package/esm/commands/sync/push.js.map +1 -1
  72. package/esm/commands/sync/request.d.ts +26 -23
  73. package/esm/commands/sync/request.d.ts.map +1 -1
  74. package/esm/commands/sync/request.js +40 -42
  75. package/esm/commands/sync/request.js.map +1 -1
  76. package/esm/commands/sync/response.d.ts +19 -19
  77. package/esm/commands/sync/response.d.ts.map +1 -1
  78. package/esm/commands/sync/response.js +54 -54
  79. package/esm/commands/sync/response.js.map +1 -1
  80. package/esm/commands/sync/socket.d.ts +27 -0
  81. package/esm/commands/sync/socket.d.ts.map +1 -0
  82. package/esm/commands/sync/socket.js +66 -0
  83. package/esm/commands/sync/socket.js.map +1 -0
  84. package/esm/commands/sync/stat.d.ts +72 -72
  85. package/esm/commands/sync/stat.d.ts.map +1 -1
  86. package/esm/commands/sync/stat.js +116 -104
  87. package/esm/commands/sync/stat.js.map +1 -1
  88. package/esm/commands/sync/sync.d.ts +72 -60
  89. package/esm/commands/sync/sync.d.ts.map +1 -1
  90. package/esm/commands/sync/sync.js +127 -149
  91. package/esm/commands/sync/sync.js.map +1 -1
  92. package/esm/commands/tcpip.d.ts +5 -5
  93. package/esm/commands/tcpip.js +18 -18
  94. package/esm/crypto.d.ts +36 -36
  95. package/esm/crypto.js +248 -248
  96. package/esm/features.d.ts +10 -7
  97. package/esm/features.d.ts.map +1 -1
  98. package/esm/features.js +13 -10
  99. package/esm/features.js.map +1 -1
  100. package/esm/index.d.ts +9 -9
  101. package/esm/index.js +9 -9
  102. package/esm/packet.d.ts +45 -46
  103. package/esm/packet.d.ts.map +1 -1
  104. package/esm/packet.js +43 -48
  105. package/esm/packet.js.map +1 -1
  106. package/esm/socket/dispatcher.d.ts +59 -59
  107. package/esm/socket/dispatcher.d.ts.map +1 -1
  108. package/esm/socket/dispatcher.js +223 -234
  109. package/esm/socket/dispatcher.js.map +1 -1
  110. package/esm/socket/index.d.ts +2 -2
  111. package/esm/socket/index.js +2 -2
  112. package/esm/socket/socket.d.ts +59 -59
  113. package/esm/socket/socket.d.ts.map +1 -1
  114. package/esm/socket/socket.js +118 -118
  115. package/esm/socket/socket.js.map +1 -1
  116. package/esm/utils/auto-reset-event.d.ts +9 -9
  117. package/esm/utils/auto-reset-event.d.ts.map +1 -1
  118. package/esm/utils/auto-reset-event.js +33 -33
  119. package/esm/utils/auto-reset-event.js.map +1 -1
  120. package/esm/utils/base64.d.ts +27 -27
  121. package/esm/utils/base64.js +246 -246
  122. package/esm/utils/conditional-variable.d.ts +9 -0
  123. package/esm/utils/conditional-variable.d.ts.map +1 -0
  124. package/esm/utils/conditional-variable.js +34 -0
  125. package/esm/utils/conditional-variable.js.map +1 -0
  126. package/esm/utils/index.d.ts +4 -3
  127. package/esm/utils/index.d.ts.map +1 -1
  128. package/esm/utils/index.js +4 -3
  129. package/esm/utils/index.js.map +1 -1
  130. package/package.json +11 -10
  131. package/src/adb.ts +47 -37
  132. package/src/auth.ts +7 -6
  133. package/src/backend.ts +4 -4
  134. package/src/commands/base.ts +1 -1
  135. package/src/commands/framebuffer.ts +4 -4
  136. package/src/commands/index.ts +7 -8
  137. package/src/commands/reverse.ts +35 -10
  138. package/src/commands/subprocess/command.ts +12 -4
  139. package/src/commands/subprocess/index.ts +3 -3
  140. package/src/commands/subprocess/protocols/index.ts +3 -3
  141. package/src/commands/subprocess/protocols/none.ts +25 -11
  142. package/src/commands/subprocess/protocols/shell.ts +50 -28
  143. package/src/commands/subprocess/protocols/types.ts +8 -7
  144. package/src/commands/subprocess/utils.ts +1 -1
  145. package/src/commands/sync/index.ts +8 -7
  146. package/src/commands/sync/list.ts +42 -23
  147. package/src/commands/sync/pull.ts +40 -45
  148. package/src/commands/sync/push.ts +146 -39
  149. package/src/commands/sync/request.ts +20 -15
  150. package/src/commands/sync/response.ts +7 -6
  151. package/src/commands/sync/socket.ts +97 -0
  152. package/src/commands/sync/stat.ts +47 -42
  153. package/src/commands/sync/sync.ts +68 -108
  154. package/src/commands/tcpip.ts +5 -5
  155. package/src/features.ts +9 -6
  156. package/src/packet.ts +19 -34
  157. package/src/socket/dispatcher.ts +32 -47
  158. package/src/socket/index.ts +2 -2
  159. package/src/socket/socket.ts +26 -17
  160. package/src/utils/auto-reset-event.ts +14 -15
  161. package/src/utils/conditional-variable.ts +45 -0
  162. package/src/utils/index.ts +4 -3
  163. package/tsconfig.build.tsbuildinfo +1 -1
  164. package/src/commands/install.ts +0 -40
package/esm/auth.d.ts CHANGED
@@ -1,52 +1,52 @@
1
- import { type Disposable } from "@yume-chan/event";
2
- import { type ValueOrPromise } from "@yume-chan/struct";
3
- import { type AdbPacketData } from "./packet.js";
4
- export type AdbKeyIterable = Iterable<Uint8Array> | AsyncIterable<Uint8Array>;
5
- export interface AdbCredentialStore {
6
- /**
7
- * Generate and store a RSA private key with modulus length `2048` and public exponent `65537`.
8
- *
9
- * The returned `Uint8Array` is the private key in PKCS #8 format.
10
- */
11
- generateKey(): ValueOrPromise<Uint8Array>;
12
- /**
13
- * Synchronously or asynchronously iterate through all stored RSA private keys.
14
- *
15
- * Each call to `iterateKeys` must return a different iterator that iterate through all stored keys.
16
- */
17
- iterateKeys(): AdbKeyIterable;
18
- }
19
- export declare enum AdbAuthType {
20
- Token = 1,
21
- Signature = 2,
22
- PublicKey = 3
23
- }
24
- export interface AdbAuthenticator {
25
- /**
26
- * @param getNextRequest
27
- *
28
- * Call this function to get the next authentication request packet from device.
29
- *
30
- * After calling `getNextRequest`, authenticator can `yield` a packet as response, or `return` to indicate its incapability of handling the request.
31
- *
32
- * After `return`, the `AdbAuthenticatorHandler` will move on to next authenticator and never go back.
33
- *
34
- * Calling `getNextRequest` multiple times without `yield` or `return` will always return the same request.
35
- */
36
- (credentialStore: AdbCredentialStore, getNextRequest: () => Promise<AdbPacketData>): AsyncIterable<AdbPacketData>;
37
- }
38
- export declare const AdbSignatureAuthenticator: AdbAuthenticator;
39
- export declare const AdbPublicKeyAuthenticator: AdbAuthenticator;
40
- export declare const ADB_DEFAULT_AUTHENTICATORS: AdbAuthenticator[];
41
- export declare class AdbAuthenticationProcessor implements Disposable {
42
- readonly authenticators: readonly AdbAuthenticator[];
43
- private readonly credentialStore;
44
- private pendingRequest;
45
- private iterator;
46
- constructor(authenticators: readonly AdbAuthenticator[], credentialStore: AdbCredentialStore);
47
- private getNextRequest;
48
- private invokeAuthenticator;
49
- process(packet: AdbPacketData): Promise<AdbPacketData>;
50
- dispose(): void;
51
- }
1
+ import type { Disposable } from "@yume-chan/event";
2
+ import type { ValueOrPromise } from "@yume-chan/struct";
3
+ import type { AdbPacketData } from "./packet.js";
4
+ export type AdbKeyIterable = Iterable<Uint8Array> | AsyncIterable<Uint8Array>;
5
+ export interface AdbCredentialStore {
6
+ /**
7
+ * Generate and store a RSA private key with modulus length `2048` and public exponent `65537`.
8
+ *
9
+ * The returned `Uint8Array` is the private key in PKCS #8 format.
10
+ */
11
+ generateKey(): ValueOrPromise<Uint8Array>;
12
+ /**
13
+ * Synchronously or asynchronously iterate through all stored RSA private keys.
14
+ *
15
+ * Each call to `iterateKeys` must return a different iterator that iterate through all stored keys.
16
+ */
17
+ iterateKeys(): AdbKeyIterable;
18
+ }
19
+ export declare enum AdbAuthType {
20
+ Token = 1,
21
+ Signature = 2,
22
+ PublicKey = 3
23
+ }
24
+ export interface AdbAuthenticator {
25
+ /**
26
+ * @param getNextRequest
27
+ *
28
+ * Call this function to get the next authentication request packet from device.
29
+ *
30
+ * After calling `getNextRequest`, authenticator can `yield` a packet as response, or `return` to indicate its incapability of handling the request.
31
+ *
32
+ * After `return`, the `AdbAuthenticatorHandler` will move on to next authenticator and never go back.
33
+ *
34
+ * Calling `getNextRequest` multiple times without `yield` or `return` will always return the same request.
35
+ */
36
+ (credentialStore: AdbCredentialStore, getNextRequest: () => Promise<AdbPacketData>): AsyncIterable<AdbPacketData>;
37
+ }
38
+ export declare const AdbSignatureAuthenticator: AdbAuthenticator;
39
+ export declare const AdbPublicKeyAuthenticator: AdbAuthenticator;
40
+ export declare const ADB_DEFAULT_AUTHENTICATORS: AdbAuthenticator[];
41
+ export declare class AdbAuthenticationProcessor implements Disposable {
42
+ readonly authenticators: readonly AdbAuthenticator[];
43
+ private readonly credentialStore;
44
+ private pendingRequest;
45
+ private iterator;
46
+ constructor(authenticators: readonly AdbAuthenticator[], credentialStore: AdbCredentialStore);
47
+ private getNextRequest;
48
+ private invokeAuthenticator;
49
+ process(packet: AdbPacketData): Promise<AdbPacketData>;
50
+ dispose(): void;
51
+ }
52
52
  //# sourceMappingURL=auth.d.ts.map
package/esm/auth.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAOxD,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAG7D,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,UAAU,CAAC,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC;AAE9E,MAAM,WAAW,kBAAkB;IAC/B;;;;OAIG;IACH,WAAW,IAAI,cAAc,CAAC,UAAU,CAAC,CAAC;IAE1C;;;;OAIG;IACH,WAAW,IAAI,cAAc,CAAC;CACjC;AAED,oBAAY,WAAW;IACnB,KAAK,IAAI;IACT,SAAS,IAAI;IACb,SAAS,IAAI;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC7B;;;;;;;;;;OAUG;IACH,CACI,eAAe,EAAE,kBAAkB,EACnC,cAAc,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,GAC7C,aAAa,CAAC,aAAa,CAAC,CAAC;CACnC;AAED,eAAO,MAAM,yBAAyB,EAAE,gBAmBvC,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,gBAqCvC,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,gBAAgB,EAGxD,CAAC;AAEF,qBAAa,0BAA2B,YAAW,UAAU;IACzD,SAAgB,cAAc,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAE5D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAqB;IAErD,OAAO,CAAC,cAAc,CAAwC;IAE9D,OAAO,CAAC,QAAQ,CAAuD;gBAGnE,cAAc,EAAE,SAAS,gBAAgB,EAAE,EAC3C,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Ac,EAAE,SAAS,gBAAgB,EAAE,EAC3C,eAAe,EAAE,kBAAkB;IAMvC,OAAO,CAAC,cAAc,CAEpB;YAEa,mBAAmB;IAuBrB,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAe5D,OAAO;CAGjB"}
package/esm/auth.js CHANGED
@@ -1,97 +1,96 @@
1
- import { PromiseResolver } from "@yume-chan/async";
2
- import { calculatePublicKey, calculatePublicKeyLength, sign, } from "./crypto.js";
3
- import { AdbCommand } from "./packet.js";
4
- import { calculateBase64EncodedLength, encodeBase64 } from "./utils/index.js";
5
- export var AdbAuthType;
6
- (function (AdbAuthType) {
7
- AdbAuthType[AdbAuthType["Token"] = 1] = "Token";
8
- AdbAuthType[AdbAuthType["Signature"] = 2] = "Signature";
9
- AdbAuthType[AdbAuthType["PublicKey"] = 3] = "PublicKey";
10
- })(AdbAuthType = AdbAuthType || (AdbAuthType = {}));
11
- export const AdbSignatureAuthenticator = async function* (credentialStore, getNextRequest) {
12
- for await (const key of credentialStore.iterateKeys()) {
13
- const packet = await getNextRequest();
14
- if (packet.arg0 !== AdbAuthType.Token) {
15
- return;
16
- }
17
- const signature = sign(key, packet.payload);
18
- yield {
19
- command: AdbCommand.Auth,
20
- arg0: AdbAuthType.Signature,
21
- arg1: 0,
22
- payload: new Uint8Array(signature),
23
- };
24
- }
25
- };
26
- export const AdbPublicKeyAuthenticator = async function* (credentialStore, getNextRequest) {
27
- const packet = await getNextRequest();
28
- if (packet.arg0 !== AdbAuthType.Token) {
29
- return;
30
- }
31
- let privateKey;
32
- for await (const key of credentialStore.iterateKeys()) {
33
- privateKey = key;
34
- break;
35
- }
36
- if (!privateKey) {
37
- privateKey = await credentialStore.generateKey();
38
- }
39
- const publicKeyLength = calculatePublicKeyLength();
40
- const [publicKeyBase64Length] = calculateBase64EncodedLength(publicKeyLength);
41
- // The public key is null terminated,
42
- // So we allocate the buffer with one extra byte.
43
- const publicKeyBuffer = new Uint8Array(publicKeyBase64Length + 1);
44
- calculatePublicKey(privateKey, publicKeyBuffer);
45
- encodeBase64(publicKeyBuffer.subarray(0, publicKeyLength), publicKeyBuffer);
46
- yield {
47
- command: AdbCommand.Auth,
48
- arg0: AdbAuthType.PublicKey,
49
- arg1: 0,
50
- payload: publicKeyBuffer,
51
- };
52
- };
53
- export const ADB_DEFAULT_AUTHENTICATORS = [
54
- AdbSignatureAuthenticator,
55
- AdbPublicKeyAuthenticator,
56
- ];
57
- export class AdbAuthenticationProcessor {
58
- authenticators;
59
- credentialStore;
60
- pendingRequest = new PromiseResolver();
61
- iterator;
62
- constructor(authenticators, credentialStore) {
63
- this.authenticators = authenticators;
64
- this.credentialStore = credentialStore;
65
- }
66
- getNextRequest = () => {
67
- return this.pendingRequest.promise;
68
- };
69
- async *invokeAuthenticator() {
70
- for (const authenticator of this.authenticators) {
71
- for await (const packet of authenticator(this.credentialStore, this.getNextRequest)) {
72
- // If the authenticator yielded a response
73
- // Prepare `nextRequest` for next authentication request
74
- this.pendingRequest = new PromiseResolver();
75
- // Yield the response to outer layer
76
- yield packet;
77
- }
78
- // If the authenticator returned,
79
- // Next authenticator will be given the same `pendingRequest`
80
- }
81
- }
82
- async process(packet) {
83
- if (!this.iterator) {
84
- this.iterator = this.invokeAuthenticator();
85
- }
86
- this.pendingRequest.resolve(packet);
87
- const result = await this.iterator.next();
88
- if (result.done) {
89
- throw new Error("No authenticator can handle the request");
90
- }
91
- return result.value;
92
- }
93
- dispose() {
94
- void this.iterator?.return?.();
95
- }
96
- }
1
+ import { PromiseResolver } from "@yume-chan/async";
2
+ import { calculatePublicKey, calculatePublicKeyLength, sign, } from "./crypto.js";
3
+ import { AdbCommand } from "./packet.js";
4
+ import { calculateBase64EncodedLength, encodeBase64 } from "./utils/index.js";
5
+ export var AdbAuthType;
6
+ (function (AdbAuthType) {
7
+ AdbAuthType[AdbAuthType["Token"] = 1] = "Token";
8
+ AdbAuthType[AdbAuthType["Signature"] = 2] = "Signature";
9
+ AdbAuthType[AdbAuthType["PublicKey"] = 3] = "PublicKey";
10
+ })(AdbAuthType = AdbAuthType || (AdbAuthType = {}));
11
+ export const AdbSignatureAuthenticator = async function* (credentialStore, getNextRequest) {
12
+ for await (const key of credentialStore.iterateKeys()) {
13
+ const packet = await getNextRequest();
14
+ if (packet.arg0 !== AdbAuthType.Token) {
15
+ return;
16
+ }
17
+ const signature = sign(key, packet.payload);
18
+ yield {
19
+ command: AdbCommand.Auth,
20
+ arg0: AdbAuthType.Signature,
21
+ arg1: 0,
22
+ payload: new Uint8Array(signature),
23
+ };
24
+ }
25
+ };
26
+ export const AdbPublicKeyAuthenticator = async function* (credentialStore, getNextRequest) {
27
+ const packet = await getNextRequest();
28
+ if (packet.arg0 !== AdbAuthType.Token) {
29
+ return;
30
+ }
31
+ let privateKey;
32
+ for await (const key of credentialStore.iterateKeys()) {
33
+ privateKey = key;
34
+ break;
35
+ }
36
+ if (!privateKey) {
37
+ privateKey = await credentialStore.generateKey();
38
+ }
39
+ const publicKeyLength = calculatePublicKeyLength();
40
+ const [publicKeyBase64Length] = calculateBase64EncodedLength(publicKeyLength);
41
+ const publicKeyBuffer = new Uint8Array(publicKeyBase64Length + 1 // Null character
42
+ );
43
+ calculatePublicKey(privateKey, publicKeyBuffer);
44
+ encodeBase64(publicKeyBuffer.subarray(0, publicKeyLength), publicKeyBuffer);
45
+ yield {
46
+ command: AdbCommand.Auth,
47
+ arg0: AdbAuthType.PublicKey,
48
+ arg1: 0,
49
+ payload: publicKeyBuffer,
50
+ };
51
+ };
52
+ export const ADB_DEFAULT_AUTHENTICATORS = [
53
+ AdbSignatureAuthenticator,
54
+ AdbPublicKeyAuthenticator,
55
+ ];
56
+ export class AdbAuthenticationProcessor {
57
+ authenticators;
58
+ credentialStore;
59
+ pendingRequest = new PromiseResolver();
60
+ iterator;
61
+ constructor(authenticators, credentialStore) {
62
+ this.authenticators = authenticators;
63
+ this.credentialStore = credentialStore;
64
+ }
65
+ getNextRequest = () => {
66
+ return this.pendingRequest.promise;
67
+ };
68
+ async *invokeAuthenticator() {
69
+ for (const authenticator of this.authenticators) {
70
+ for await (const packet of authenticator(this.credentialStore, this.getNextRequest)) {
71
+ // If the authenticator yielded a response
72
+ // Prepare `nextRequest` for next authentication request
73
+ this.pendingRequest = new PromiseResolver();
74
+ // Yield the response to outer layer
75
+ yield packet;
76
+ }
77
+ // If the authenticator returned,
78
+ // Next authenticator will be given the same `pendingRequest`
79
+ }
80
+ }
81
+ async process(packet) {
82
+ if (!this.iterator) {
83
+ this.iterator = this.invokeAuthenticator();
84
+ }
85
+ this.pendingRequest.resolve(packet);
86
+ const result = await this.iterator.next();
87
+ if (result.done) {
88
+ throw new Error("No authenticator can handle the request");
89
+ }
90
+ return result.value;
91
+ }
92
+ dispose() {
93
+ void this.iterator?.return?.();
94
+ }
95
+ }
97
96
  //# sourceMappingURL=auth.js.map
package/esm/auth.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAInD,OAAO,EACH,kBAAkB,EAClB,wBAAwB,EACxB,IAAI,GACP,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAsB,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,4BAA4B,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAoB9E,MAAM,CAAN,IAAY,WAIX;AAJD,WAAY,WAAW;IACnB,+CAAS,CAAA;IACT,uDAAa,CAAA;IACb,uDAAa,CAAA;AACjB,CAAC,EAJW,WAAW,GAAX,WAAW,KAAX,WAAW,QAItB;AAoBD,MAAM,CAAC,MAAM,yBAAyB,GAAqB,KAAK,SAAS,CAAC,EACtE,eAAmC,EACnC,cAA4C;IAE5C,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,eAAe,CAAC,WAAW,EAAE,EAAE;QACnD,MAAM,MAAM,GAAG,MAAM,c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rC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IAC3C,CAAC;IAEO,cAAc,GAAG,GAA2B,EAAE;QAClD,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;IACvC,CAAC,CAAC;IAEM,KAAK,CAAC,CAAC,mBAAmB;QAK9B,KAAK,MAAM,aAAa,IAAI,IAAI,CAAC,cAAc,EAAE;YAC7C,IAAI,KAAK,EAAE,MAAM,MAAM,IAAI,aAAa,CACpC,IAAI,CAAC,eAAe,EACpB,IAAI,CAAC,cAAc,CACtB,EAAE;gBACC,0CAA0C;gBAC1C,wDAAwD;gBACxD,IAAI,CAAC,cAAc,GAAG,IAAI,eAAe,EAAE,CAAC;gBAE5C,oCAAoC;gBACpC,MAAM,MAAM,CAAC;aAChB;YAED,iCAAiC;YACjC,6DAA6D;SAChE;IACL,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,MAAqB;QACtC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAChB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;SAC9C;QAED,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAEpC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC1C,IAAI,MAAM,CAAC,IAAI,EAAE;YACb,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;SAC9D;QAED,OAAO,MAAM,CAAC,KAAK,CAAC;IACxB,CAAC;IAEM,OAAO;QACV,KAAK,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC;IACnC,CAAC;CACJ"}
package/esm/backend.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { type ReadableWritablePair } from "@yume-chan/stream-extra";
2
- import { type ValueOrPromise } from "@yume-chan/struct";
3
- import { type AdbPacketData, type AdbPacketInit } from "./packet.js";
4
- export interface AdbBackend {
5
- readonly serial: string;
6
- readonly name: string | undefined;
7
- connect(): ValueOrPromise<ReadableWritablePair<AdbPacketData, AdbPacketInit>>;
8
- }
1
+ import type { Consumable, ReadableWritablePair } from "@yume-chan/stream-extra";
2
+ import type { ValueOrPromise } from "@yume-chan/struct";
3
+ import type { AdbPacketData, AdbPacketInit } from "./packet.js";
4
+ export interface AdbBackend {
5
+ readonly serial: string;
6
+ readonly name: string | undefined;
7
+ connect(): ValueOrPromise<ReadableWritablePair<AdbPacketData, Consumable<AdbPacketInit>>>;
8
+ }
9
9
  //# sourceMappingURL=backend.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../src/backend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAErE,MAAM,WAAW,UAAU;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAElC,OAAO,IAAI,cAAc,CACrB,oBAAoB,CAAC,aAAa,EAAE,aAAa,CAAC,CACrD,CAAC;CACL"}
1
+ {"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../src/backend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEhE,MAAM,WAAW,UAAU;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAElC,OAAO,IAAI,cAAc,CACrB,oBAAoB,CAAC,aAAa,EAAE,UAAU,CAAC,aAAa,CAAC,CAAC,CACjE,CAAC;CACL"}
package/esm/backend.js CHANGED
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=backend.js.map
@@ -1,7 +1,7 @@
1
- import { AutoDisposable } from "@yume-chan/event";
2
- import { type Adb } from "../adb.js";
3
- export declare class AdbCommandBase extends AutoDisposable {
4
- protected adb: Adb;
5
- constructor(adb: Adb);
6
- }
1
+ import { AutoDisposable } from "@yume-chan/event";
2
+ import type { Adb } from "../adb.js";
3
+ export declare class AdbCommandBase extends AutoDisposable {
4
+ protected adb: Adb;
5
+ constructor(adb: Adb);
6
+ }
7
7
  //# sourceMappingURL=base.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/commands/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,WAAW,CAAC;AAErC,qBAAa,cAAe,SAAQ,cAAc;IAC9C,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC;gBAEA,GAAG,EAAE,GAAG;CAI9B"}
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/commands/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAErC,qBAAa,cAAe,SAAQ,cAAc;IAC9C,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC;gBAEA,GAAG,EAAE,GAAG;CAI9B"}
@@ -1,9 +1,9 @@
1
- import { AutoDisposable } from "@yume-chan/event";
2
- export class AdbCommandBase extends AutoDisposable {
3
- adb;
4
- constructor(adb) {
5
- super();
6
- this.adb = adb;
7
- }
8
- }
1
+ import { AutoDisposable } from "@yume-chan/event";
2
+ export class AdbCommandBase extends AutoDisposable {
3
+ adb;
4
+ constructor(adb) {
5
+ super();
6
+ this.adb = adb;
7
+ }
8
+ }
9
9
  //# sourceMappingURL=base.js.map
@@ -1,54 +1,54 @@
1
- import Struct from "@yume-chan/struct";
2
- import { type Adb } from "../adb.js";
3
- export declare const AdbFrameBufferV1: Struct<{
4
- bpp: number;
5
- size: number;
6
- width: number;
7
- height: number;
8
- red_offset: number;
9
- red_length: number;
10
- blue_offset: number;
11
- blue_length: number;
12
- green_offset: number;
13
- green_length: number;
14
- alpha_offset: number;
15
- alpha_length: number;
16
- data: Uint8Array;
17
- }, "size", Record<never, never>, undefined>;
18
- export type AdbFrameBufferV1 = typeof AdbFrameBufferV1["TDeserializeResult"];
19
- export declare const AdbFrameBufferV2: Struct<{
20
- bpp: number;
21
- colorSpace: number;
22
- size: number;
23
- width: number;
24
- height: number;
25
- red_offset: number;
26
- red_length: number;
27
- blue_offset: number;
28
- blue_length: number;
29
- green_offset: number;
30
- green_length: number;
31
- alpha_offset: number;
32
- alpha_length: number;
33
- data: Uint8Array;
34
- }, "size", Record<never, never>, undefined>;
35
- export type AdbFrameBufferV2 = typeof AdbFrameBufferV2["TDeserializeResult"];
36
- /**
37
- * ADB uses 8 int32 fields to describe bit depths
38
- *
39
- * The only combination I have seen is RGBA8888, which is
40
- *
41
- * red_offset: 0
42
- * red_length: 8
43
- * blue_offset: 16
44
- * blue_length: 8
45
- * green_offset: 8
46
- * green_length: 8
47
- * alpha_offset: 24
48
- * alpha_length: 8
49
- *
50
- * But it doesn't mean that other combinations are not possible.
51
- */
52
- export type AdbFrameBuffer = AdbFrameBufferV1 | AdbFrameBufferV2;
53
- export declare function framebuffer(adb: Adb): Promise<AdbFrameBuffer>;
1
+ import Struct from "@yume-chan/struct";
2
+ import type { Adb } from "../adb.js";
3
+ export declare const AdbFrameBufferV1: Struct<{
4
+ bpp: number;
5
+ size: number;
6
+ width: number;
7
+ height: number;
8
+ red_offset: number;
9
+ red_length: number;
10
+ blue_offset: number;
11
+ blue_length: number;
12
+ green_offset: number;
13
+ green_length: number;
14
+ alpha_offset: number;
15
+ alpha_length: number;
16
+ data: Uint8Array;
17
+ }, "size", Record<never, never>, undefined>;
18
+ export type AdbFrameBufferV1 = (typeof AdbFrameBufferV1)["TDeserializeResult"];
19
+ export declare const AdbFrameBufferV2: Struct<{
20
+ bpp: number;
21
+ colorSpace: number;
22
+ size: number;
23
+ width: number;
24
+ height: number;
25
+ red_offset: number;
26
+ red_length: number;
27
+ blue_offset: number;
28
+ blue_length: number;
29
+ green_offset: number;
30
+ green_length: number;
31
+ alpha_offset: number;
32
+ alpha_length: number;
33
+ data: Uint8Array;
34
+ }, "size", Record<never, never>, undefined>;
35
+ export type AdbFrameBufferV2 = (typeof AdbFrameBufferV2)["TDeserializeResult"];
36
+ /**
37
+ * ADB uses 8 int32 fields to describe bit depths
38
+ *
39
+ * The only combination I have seen is RGBA8888, which is
40
+ *
41
+ * red_offset: 0
42
+ * red_length: 8
43
+ * blue_offset: 16
44
+ * blue_length: 8
45
+ * green_offset: 8
46
+ * green_length: 8
47
+ * alpha_offset: 24
48
+ * alpha_length: 8
49
+ *
50
+ * But it doesn't mean that other combinations are not possible.
51
+ */
52
+ export type AdbFrameBuffer = AdbFrameBufferV1 | AdbFrameBufferV2;
53
+ export declare function framebuffer(adb: Adb): Promise<AdbFrameBuffer>;
54
54
  //# sourceMappingURL=framebuffer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"framebuffer.d.ts","sourceRoot":"","sources":["../../src/commands/framebuffer.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,WAAW,CAAC;AAIrC,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;2CAamB,CAAC;AAEjD,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAC,oBAAoB,CAAC,CAAC;AAE7E,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;2CAcmB,CAAC;AAEjD,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAC,oBAAoB,CAAC,CAAC;AAE7E;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,cAAc,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;AAEjE,wBAAsB,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,cAAc,CAAC,CAanE"}
1
+ {"version":3,"file":"framebuffer.d.ts","sourceRoot":"","sources":["../../src/commands/framebuffer.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAIrC,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;2CAamB,CAAC;AAEjD,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,oBAAoB,CAAC,CAAC;AAE/E,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;2CAcmB,CAAC;AAEjD,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,oBAAoB,CAAC,CAAC;AAE/E;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,cAAc,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;AAEjE,wBAAsB,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,cAAc,CAAC,CAanE"}
@@ -1,47 +1,47 @@
1
- import { BufferedReadableStream } from "@yume-chan/stream-extra";
2
- import Struct from "@yume-chan/struct";
3
- const Version = new Struct({ littleEndian: true }).uint32("version");
4
- export const AdbFrameBufferV1 = new Struct({ littleEndian: true })
5
- .uint32("bpp")
6
- .uint32("size")
7
- .uint32("width")
8
- .uint32("height")
9
- .uint32("red_offset")
10
- .uint32("red_length")
11
- .uint32("blue_offset")
12
- .uint32("blue_length")
13
- .uint32("green_offset")
14
- .uint32("green_length")
15
- .uint32("alpha_offset")
16
- .uint32("alpha_length")
17
- .uint8Array("data", { lengthField: "size" });
18
- export const AdbFrameBufferV2 = new Struct({ littleEndian: true })
19
- .uint32("bpp")
20
- .uint32("colorSpace")
21
- .uint32("size")
22
- .uint32("width")
23
- .uint32("height")
24
- .uint32("red_offset")
25
- .uint32("red_length")
26
- .uint32("blue_offset")
27
- .uint32("blue_length")
28
- .uint32("green_offset")
29
- .uint32("green_length")
30
- .uint32("alpha_offset")
31
- .uint32("alpha_length")
32
- .uint8Array("data", { lengthField: "size" });
33
- export async function framebuffer(adb) {
34
- const socket = await adb.createSocket("framebuffer:");
35
- const stream = new BufferedReadableStream(socket.readable);
36
- const { version } = await Version.deserialize(stream);
37
- switch (version) {
38
- case 1:
39
- // TODO: AdbFrameBuffer: does all v1 responses uses the same color space? Add it so the command returns same format for all versions.
40
- return AdbFrameBufferV1.deserialize(stream);
41
- case 2:
42
- return AdbFrameBufferV2.deserialize(stream);
43
- default:
44
- throw new Error("Unknown FrameBuffer version");
45
- }
46
- }
1
+ import { BufferedReadableStream } from "@yume-chan/stream-extra";
2
+ import Struct from "@yume-chan/struct";
3
+ const Version = new Struct({ littleEndian: true }).uint32("version");
4
+ export const AdbFrameBufferV1 = new Struct({ littleEndian: true })
5
+ .uint32("bpp")
6
+ .uint32("size")
7
+ .uint32("width")
8
+ .uint32("height")
9
+ .uint32("red_offset")
10
+ .uint32("red_length")
11
+ .uint32("blue_offset")
12
+ .uint32("blue_length")
13
+ .uint32("green_offset")
14
+ .uint32("green_length")
15
+ .uint32("alpha_offset")
16
+ .uint32("alpha_length")
17
+ .uint8Array("data", { lengthField: "size" });
18
+ export const AdbFrameBufferV2 = new Struct({ littleEndian: true })
19
+ .uint32("bpp")
20
+ .uint32("colorSpace")
21
+ .uint32("size")
22
+ .uint32("width")
23
+ .uint32("height")
24
+ .uint32("red_offset")
25
+ .uint32("red_length")
26
+ .uint32("blue_offset")
27
+ .uint32("blue_length")
28
+ .uint32("green_offset")
29
+ .uint32("green_length")
30
+ .uint32("alpha_offset")
31
+ .uint32("alpha_length")
32
+ .uint8Array("data", { lengthField: "size" });
33
+ export async function framebuffer(adb) {
34
+ const socket = await adb.createSocket("framebuffer:");
35
+ const stream = new BufferedReadableStream(socket.readable);
36
+ const { version } = await Version.deserialize(stream);
37
+ switch (version) {
38
+ case 1:
39
+ // TODO: AdbFrameBuffer: does all v1 responses uses the same color space? Add it so the command returns same format for all versions.
40
+ return AdbFrameBufferV1.deserialize(stream);
41
+ case 2:
42
+ return AdbFrameBufferV2.deserialize(stream);
43
+ default:
44
+ throw new Error("Unsupported FrameBuffer version");
45
+ }
46
+ }
47
47
  //# sourceMappingURL=framebuffer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"framebuffer.js","sourceRoot":"","sources":["../../src/commands/framebuffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAIvC,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AAErE,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,MAAM,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;KAC7D,MAAM,CAAC,KAAK,CAAC;KACb,MAAM,CAAC,MAAM,CAAC;KACd,MAAM,CAAC,OAAO,CAAC;KACf,MAAM,CAAC,QAAQ,CAAC;KAChB,MAAM,CAAC,YAAY,CAAC;KACpB,MAAM,CAAC,YAAY,CAAC;KACpB,MAAM,CAAC,aAAa,CAAC;KACrB,MAAM,CAAC,aAAa,CAAC;KACrB,MAAM,CAAC,cAAc,CAAC;KACtB,MAAM,CAAC,cAAc,CAAC;KACtB,MAAM,CAAC,cAAc,CAAC;KACtB,MAAM,CAAC,cAAc,CAAC;KACtB,UAAU,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,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CAAC,CAAC;AAsBjD,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,GAAQ;IACtC,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;IACtD,MAAM,MAAM,GAAG,IAAI,sBAAsB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC3D,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACtD,QAAQ,OAAO,EAAE;QACb,KAAK,CAAC;YACF,qIAAqI;YACrI,OAAO,gBAAgB,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAChD,KAAK,CAAC;YACF,OAAO,gBAAgB,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAChD;YACI,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;KAC1D;AACL,CAAC"}
@@ -1,9 +1,8 @@
1
- export * from './base.js';
2
- export * from './framebuffer.js';
3
- export * from './install.js';
4
- export * from './power.js';
5
- export * from './reverse.js';
6
- export * from './subprocess/index.js';
7
- export * from './sync/index.js';
8
- export * from './tcpip.js';
1
+ export * from "./base.js";
2
+ export * from "./framebuffer.js";
3
+ export * from "./power.js";
4
+ export * from "./reverse.js";
5
+ export * from "./subprocess/index.js";
6
+ export * from "./sync/index.js";
7
+ export * from "./tcpip.js";
9
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC"}