@yume-chan/adb 0.0.17 → 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.
- package/CHANGELOG.json +27 -0
- package/CHANGELOG.md +16 -1
- package/LICENSE +1 -1
- package/esm/adb.d.ts +63 -60
- package/esm/adb.d.ts.map +1 -1
- package/esm/adb.js +257 -229
- package/esm/adb.js.map +1 -1
- package/esm/auth.d.ts +51 -51
- package/esm/auth.d.ts.map +1 -1
- package/esm/auth.js +95 -96
- package/esm/auth.js.map +1 -1
- package/esm/backend.d.ts +8 -8
- package/esm/backend.d.ts.map +1 -1
- package/esm/backend.js +1 -1
- package/esm/commands/base.d.ts +6 -6
- package/esm/commands/base.js +8 -8
- package/esm/commands/framebuffer.d.ts +53 -53
- package/esm/commands/framebuffer.d.ts.map +1 -1
- package/esm/commands/framebuffer.js +46 -47
- package/esm/commands/framebuffer.js.map +1 -1
- package/esm/commands/index.d.ts +7 -8
- package/esm/commands/index.d.ts.map +1 -1
- package/esm/commands/index.js +7 -8
- package/esm/commands/index.js.map +1 -1
- package/esm/commands/install.d.ts +9 -3
- package/esm/commands/install.d.ts.map +1 -1
- package/esm/commands/install.js +27 -21
- package/esm/commands/install.js.map +1 -1
- package/esm/commands/power.d.ts +22 -22
- package/esm/commands/power.d.ts.map +1 -1
- package/esm/commands/power.js +48 -44
- package/esm/commands/power.js.map +1 -1
- package/esm/commands/reverse.d.ts +41 -28
- package/esm/commands/reverse.d.ts.map +1 -1
- package/esm/commands/reverse.js +125 -98
- package/esm/commands/reverse.js.map +1 -1
- package/esm/commands/subprocess/command.d.ts +57 -51
- package/esm/commands/subprocess/command.d.ts.map +1 -1
- package/esm/commands/subprocess/command.js +86 -82
- package/esm/commands/subprocess/command.js.map +1 -1
- package/esm/commands/subprocess/index.d.ts +3 -3
- package/esm/commands/subprocess/index.js +3 -3
- package/esm/commands/subprocess/protocols/index.d.ts +3 -3
- package/esm/commands/subprocess/protocols/index.js +3 -3
- package/esm/commands/subprocess/protocols/none.d.ts +35 -35
- package/esm/commands/subprocess/protocols/none.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/none.js +65 -55
- package/esm/commands/subprocess/protocols/none.js.map +1 -1
- package/esm/commands/subprocess/protocols/shell.d.ts +39 -38
- package/esm/commands/subprocess/protocols/shell.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/shell.js +166 -154
- package/esm/commands/subprocess/protocols/shell.js.map +1 -1
- package/esm/commands/subprocess/protocols/types.d.ts +49 -49
- package/esm/commands/subprocess/protocols/types.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/types.js +1 -1
- package/esm/commands/subprocess/utils.d.ts +1 -1
- package/esm/commands/subprocess/utils.js +18 -18
- package/esm/commands/sync/index.d.ts +8 -7
- package/esm/commands/sync/index.d.ts.map +1 -1
- package/esm/commands/sync/index.js +8 -7
- package/esm/commands/sync/index.js.map +1 -1
- package/esm/commands/sync/list.d.ts +42 -40
- package/esm/commands/sync/list.d.ts.map +1 -1
- package/esm/commands/sync/list.js +67 -35
- package/esm/commands/sync/list.js.map +1 -1
- package/esm/commands/sync/pull.d.ts +13 -11
- package/esm/commands/sync/pull.d.ts.map +1 -1
- package/esm/commands/sync/pull.js +35 -36
- package/esm/commands/sync/pull.js.map +1 -1
- package/esm/commands/sync/push.d.ts +46 -7
- package/esm/commands/sync/push.d.ts.map +1 -1
- package/esm/commands/sync/push.js +89 -23
- package/esm/commands/sync/push.js.map +1 -1
- package/esm/commands/sync/request.d.ts +26 -23
- package/esm/commands/sync/request.d.ts.map +1 -1
- package/esm/commands/sync/request.js +40 -42
- package/esm/commands/sync/request.js.map +1 -1
- package/esm/commands/sync/response.d.ts +19 -19
- package/esm/commands/sync/response.d.ts.map +1 -1
- package/esm/commands/sync/response.js +54 -54
- package/esm/commands/sync/response.js.map +1 -1
- package/esm/commands/sync/socket.d.ts +27 -0
- package/esm/commands/sync/socket.d.ts.map +1 -0
- package/esm/commands/sync/socket.js +66 -0
- package/esm/commands/sync/socket.js.map +1 -0
- package/esm/commands/sync/stat.d.ts +72 -72
- package/esm/commands/sync/stat.d.ts.map +1 -1
- package/esm/commands/sync/stat.js +116 -94
- package/esm/commands/sync/stat.js.map +1 -1
- package/esm/commands/sync/sync.d.ts +72 -60
- package/esm/commands/sync/sync.d.ts.map +1 -1
- package/esm/commands/sync/sync.js +127 -148
- package/esm/commands/sync/sync.js.map +1 -1
- package/esm/commands/tcpip.d.ts +5 -5
- package/esm/commands/tcpip.js +18 -18
- package/esm/crypto.d.ts +36 -36
- package/esm/crypto.d.ts.map +1 -1
- package/esm/crypto.js +248 -238
- package/esm/crypto.js.map +1 -1
- package/esm/features.d.ts +10 -7
- package/esm/features.d.ts.map +1 -1
- package/esm/features.js +13 -10
- package/esm/features.js.map +1 -1
- package/esm/index.d.ts +9 -9
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +9 -9
- package/esm/index.js.map +1 -1
- package/esm/packet.d.ts +45 -46
- package/esm/packet.d.ts.map +1 -1
- package/esm/packet.js +43 -46
- package/esm/packet.js.map +1 -1
- package/esm/socket/dispatcher.d.ts +59 -59
- package/esm/socket/dispatcher.d.ts.map +1 -1
- package/esm/socket/dispatcher.js +223 -231
- package/esm/socket/dispatcher.js.map +1 -1
- package/esm/socket/index.d.ts +2 -2
- package/esm/socket/index.js +2 -2
- package/esm/socket/socket.d.ts +59 -59
- package/esm/socket/socket.d.ts.map +1 -1
- package/esm/socket/socket.js +118 -98
- package/esm/socket/socket.js.map +1 -1
- package/esm/utils/auto-reset-event.d.ts +9 -9
- package/esm/utils/auto-reset-event.d.ts.map +1 -1
- package/esm/utils/auto-reset-event.js +33 -33
- package/esm/utils/auto-reset-event.js.map +1 -1
- package/esm/utils/base64.d.ts +27 -27
- package/esm/utils/base64.d.ts.map +1 -1
- package/esm/utils/base64.js +246 -245
- package/esm/utils/base64.js.map +1 -1
- package/esm/utils/conditional-variable.d.ts +9 -0
- package/esm/utils/conditional-variable.d.ts.map +1 -0
- package/esm/utils/conditional-variable.js +34 -0
- package/esm/utils/conditional-variable.js.map +1 -0
- package/esm/utils/index.d.ts +4 -3
- package/esm/utils/index.d.ts.map +1 -1
- package/esm/utils/index.js +4 -3
- package/esm/utils/index.js.map +1 -1
- package/package.json +17 -13
- package/src/adb.ts +160 -101
- package/src/auth.ts +31 -22
- package/src/backend.ts +6 -4
- package/src/commands/base.ts +2 -2
- package/src/commands/framebuffer.ts +37 -41
- package/src/commands/index.ts +7 -8
- package/src/commands/power.ts +15 -11
- package/src/commands/reverse.ts +74 -30
- package/src/commands/subprocess/command.ts +34 -23
- package/src/commands/subprocess/index.ts +3 -3
- package/src/commands/subprocess/protocols/index.ts +3 -3
- package/src/commands/subprocess/protocols/none.ts +26 -11
- package/src/commands/subprocess/protocols/shell.ts +110 -56
- package/src/commands/subprocess/protocols/types.ts +10 -6
- package/src/commands/subprocess/utils.ts +1 -1
- package/src/commands/sync/index.ts +8 -7
- package/src/commands/sync/list.ts +74 -28
- package/src/commands/sync/pull.ts +49 -37
- package/src/commands/sync/push.ts +153 -32
- package/src/commands/sync/request.ts +37 -34
- package/src/commands/sync/response.ts +34 -27
- package/src/commands/sync/socket.ts +97 -0
- package/src/commands/sync/stat.ts +98 -70
- package/src/commands/sync/sync.ts +78 -97
- package/src/commands/tcpip.ts +5 -5
- package/src/crypto.ts +60 -32
- package/src/features.ts +9 -6
- package/src/index.ts +9 -10
- package/src/packet.ts +41 -46
- package/src/socket/dispatcher.ts +130 -108
- package/src/socket/index.ts +2 -2
- package/src/socket/socket.ts +84 -34
- package/src/utils/auto-reset-event.ts +16 -17
- package/src/utils/base64.ts +51 -41
- package/src/utils/conditional-variable.ts +45 -0
- package/src/utils/index.ts +4 -3
- package/tsconfig.build.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/src/commands/install.ts +0 -32
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../../src/socket/socket.ts"],"names":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ACxB;;;;OAIG;IACH,IAAW,MAAM,YAEhB;IAED,OAAO,CAAC,OAAO,CAAY;IAC3B,IAAW,MAAM,cAEhB;gBAEkB,OAAO,EAAE,4BAA4B;IAiE3C,OAAO,CAAC,IAAI,EAAE,UAAU;IAU9B,GAAG;IAIG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,OAAO;CAGjB;AAED;;;;;;;GAOG;AACH,qBAAa,SACT,YACI,aAAa,EACb,oBAAoB,CAAC,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;IAE5D,OAAO,CAAC,WAAW,CAAsB;IAEzC,IAAW,OAAO,IAAI,MAAM,CAE3B;IACD,IAAW,QAAQ,IAAI,MAAM,CAE5B;IACD,IAAW,YAAY,IAAI,OAAO,CAEjC;IACD,IAAW,aAAa,IAAI,MAAM,CAEjC;IAED,IAAW,QAAQ,IAAI,cAAc,CAAC,UAAU,CAAC,CAEhD;IACD,IAAW,QAAQ,IAAI,cAAc,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAE5D;gBAEkB,UAAU,EAAE,mBAAmB;IAI3C,KAAK;CAGf"}
|
package/esm/socket/socket.js
CHANGED
|
@@ -1,99 +1,119 @@
|
|
|
1
|
-
import { PromiseResolver } from
|
|
2
|
-
import {
|
|
3
|
-
import { AdbCommand } from
|
|
4
|
-
export class AdbSocketController {
|
|
5
|
-
dispatcher;
|
|
6
|
-
localId;
|
|
7
|
-
remoteId;
|
|
8
|
-
localCreated;
|
|
9
|
-
serviceString;
|
|
10
|
-
_duplex;
|
|
11
|
-
_readable;
|
|
12
|
-
_readableController;
|
|
13
|
-
get readable() {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
get
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
this.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
})
|
|
48
|
-
this.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
}))
|
|
56
|
-
this.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
1
|
+
import { PromiseResolver } from "@yume-chan/async";
|
|
2
|
+
import { ConsumableWritableStream, DistributionStream, DuplexStreamFactory, PushReadableStream, pipeFrom, } from "@yume-chan/stream-extra";
|
|
3
|
+
import { AdbCommand } from "../packet.js";
|
|
4
|
+
export class AdbSocketController {
|
|
5
|
+
dispatcher;
|
|
6
|
+
localId;
|
|
7
|
+
remoteId;
|
|
8
|
+
localCreated;
|
|
9
|
+
serviceString;
|
|
10
|
+
_duplex;
|
|
11
|
+
_readable;
|
|
12
|
+
_readableController;
|
|
13
|
+
get readable() {
|
|
14
|
+
return this._readable;
|
|
15
|
+
}
|
|
16
|
+
_writePromise;
|
|
17
|
+
writable;
|
|
18
|
+
_closed = false;
|
|
19
|
+
/**
|
|
20
|
+
* Whether the socket is half-closed (i.e. the local side initiated the close).
|
|
21
|
+
*
|
|
22
|
+
* It's only used by dispatcher to avoid sending another `CLSE` packet to remote.
|
|
23
|
+
*/
|
|
24
|
+
get closed() {
|
|
25
|
+
return this._closed;
|
|
26
|
+
}
|
|
27
|
+
_socket;
|
|
28
|
+
get socket() {
|
|
29
|
+
return this._socket;
|
|
30
|
+
}
|
|
31
|
+
constructor(options) {
|
|
32
|
+
Object.assign(this, options);
|
|
33
|
+
// Check this image to help you understand the stream graph
|
|
34
|
+
// cspell: disable-next-line
|
|
35
|
+
// https://www.plantuml.com/plantuml/png/TL0zoeGm4ErpYc3l5JxyS0yWM6mX5j4C6p4cxcJ25ejttuGX88ZftizxUKmJI275pGhXl0PP_UkfK_CAz5Z2hcWsW9Ny2fdU4C1f5aSchFVxA8vJjlTPRhqZzDQMRB7AklwJ0xXtX0ZSKH1h24ghoKAdGY23FhxC4nS2pDvxzIvxb-8THU0XlEQJ-ZB7SnXTAvc_LhOckhMdLBnbtndpb-SB7a8q2SRD_W00
|
|
36
|
+
this._duplex = new DuplexStreamFactory({
|
|
37
|
+
close: async () => {
|
|
38
|
+
this._closed = true;
|
|
39
|
+
await this.dispatcher.sendPacket(AdbCommand.Close, this.localId, this.remoteId);
|
|
40
|
+
// Don't `dispose` here, we need to wait for `CLSE` response packet.
|
|
41
|
+
return false;
|
|
42
|
+
},
|
|
43
|
+
dispose: () => {
|
|
44
|
+
// Error out the pending writes
|
|
45
|
+
this._writePromise?.reject(new Error("Socket closed"));
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
this._readable = this._duplex.wrapReadable(new PushReadableStream((controller) => {
|
|
49
|
+
this._readableController = controller;
|
|
50
|
+
}, {
|
|
51
|
+
highWaterMark: options.highWaterMark ?? 16 * 1024,
|
|
52
|
+
size(chunk) {
|
|
53
|
+
return chunk.byteLength;
|
|
54
|
+
},
|
|
55
|
+
}));
|
|
56
|
+
this.writable = pipeFrom(this._duplex.createWritable(new ConsumableWritableStream({
|
|
57
|
+
write: async (chunk) => {
|
|
58
|
+
// Wait for an ack packet
|
|
59
|
+
this._writePromise = new PromiseResolver();
|
|
60
|
+
await this.dispatcher.sendPacket(AdbCommand.Write, this.localId, this.remoteId, chunk);
|
|
61
|
+
await this._writePromise.promise;
|
|
62
|
+
},
|
|
63
|
+
})), new DistributionStream(this.dispatcher.options.maxPayloadSize));
|
|
64
|
+
this._socket = new AdbSocket(this);
|
|
65
|
+
}
|
|
66
|
+
async enqueue(data) {
|
|
67
|
+
// Consumer may abort the `ReadableStream` to close the socket,
|
|
68
|
+
// it's OK to throw away further packets in this case.
|
|
69
|
+
if (this._readableController.abortSignal.aborted) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
await this._readableController.enqueue(data);
|
|
73
|
+
}
|
|
74
|
+
ack() {
|
|
75
|
+
this._writePromise?.resolve();
|
|
76
|
+
}
|
|
77
|
+
async close() {
|
|
78
|
+
await this._duplex.close();
|
|
79
|
+
}
|
|
80
|
+
dispose() {
|
|
81
|
+
return this._duplex.dispose();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* A duplex stream representing a socket to ADB daemon.
|
|
86
|
+
*
|
|
87
|
+
* To close it, call either `socket.close()`,
|
|
88
|
+
* `socket.readable.cancel()`, `socket.readable.getReader().cancel()`,
|
|
89
|
+
* `socket.writable.abort()`, `socket.writable.getWriter().abort()`,
|
|
90
|
+
* `socket.writable.close()` or `socket.writable.getWriter().close()`.
|
|
91
|
+
*/
|
|
92
|
+
export class AdbSocket {
|
|
93
|
+
_controller;
|
|
94
|
+
get localId() {
|
|
95
|
+
return this._controller.localId;
|
|
96
|
+
}
|
|
97
|
+
get remoteId() {
|
|
98
|
+
return this._controller.remoteId;
|
|
99
|
+
}
|
|
100
|
+
get localCreated() {
|
|
101
|
+
return this._controller.localCreated;
|
|
102
|
+
}
|
|
103
|
+
get serviceString() {
|
|
104
|
+
return this._controller.serviceString;
|
|
105
|
+
}
|
|
106
|
+
get readable() {
|
|
107
|
+
return this._controller.readable;
|
|
108
|
+
}
|
|
109
|
+
get writable() {
|
|
110
|
+
return this._controller.writable;
|
|
111
|
+
}
|
|
112
|
+
constructor(controller) {
|
|
113
|
+
this._controller = controller;
|
|
114
|
+
}
|
|
115
|
+
close() {
|
|
116
|
+
return this._controller.close();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
99
119
|
//# sourceMappingURL=socket.js.map
|
package/esm/socket/socket.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket.js","sourceRoot":"","sources":["../../src/socket/socket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"socket.js","sourceRoot":"","sources":["../../src/socket/socket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AASnD,OAAO,EACH,wBAAwB,EACxB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,QAAQ,GACX,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAkB1C,MAAM,OAAO,mBAAmB;IAOX,UAAU,CAAuB;IAElC,OAAO,CAAU;IACjB,QAAQ,CAAU;IAClB,YAAY,CAAW;IACvB,aAAa,CAAU;IAE/B,OAAO,CAA0D;IAEjE,SAAS,CAA6B;IACtC,mBAAmB,CAA4C;IACvE,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAEO,aAAa,CAAoC;IACzC,QAAQ,CAAyC;IAEzD,OAAO,GAAG,KAAK,CAAC;IACxB;;;;OAIG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAEO,OAA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AAQ;QACf,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;IACrC,CAAC;IACD,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;IACrC,CAAC;IAED,YAAmB,UAA+B;QAC9C,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAClC,CAAC;IAEM,KAAK;QACR,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IACpC,CAAC;CACJ"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { Disposable } from
|
|
2
|
-
export declare class AutoResetEvent implements Disposable {
|
|
3
|
-
private
|
|
4
|
-
private
|
|
5
|
-
constructor(initialSet?: boolean);
|
|
6
|
-
wait(): Promise<void>;
|
|
7
|
-
|
|
8
|
-
dispose(): void;
|
|
9
|
-
}
|
|
1
|
+
import type { Disposable } from "@yume-chan/event";
|
|
2
|
+
export declare class AutoResetEvent implements Disposable {
|
|
3
|
+
private _set;
|
|
4
|
+
private readonly _queue;
|
|
5
|
+
constructor(initialSet?: boolean);
|
|
6
|
+
wait(): Promise<void>;
|
|
7
|
+
notifyOne(): void;
|
|
8
|
+
dispose(): void;
|
|
9
|
+
}
|
|
10
10
|
//# sourceMappingURL=auto-reset-event.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-reset-event.d.ts","sourceRoot":"","sources":["../../src/utils/auto-reset-event.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,qBAAa,cAAe,YAAW,UAAU;IAC7C,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"auto-reset-event.d.ts","sourceRoot":"","sources":["../../src/utils/auto-reset-event.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,qBAAa,cAAe,YAAW,UAAU;IAC7C,OAAO,CAAC,IAAI,CAAU;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA+B;gBAEnC,UAAU,UAAQ;IAI9B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAcrB,SAAS;IAQT,OAAO;CAMjB"}
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { PromiseResolver } from
|
|
2
|
-
export class AutoResetEvent {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
constructor(initialSet = false) {
|
|
6
|
-
this.
|
|
7
|
-
}
|
|
8
|
-
wait() {
|
|
9
|
-
if (!this.
|
|
10
|
-
this.
|
|
11
|
-
if (this.
|
|
12
|
-
return Promise.resolve();
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
const resolver = new PromiseResolver();
|
|
16
|
-
this.
|
|
17
|
-
return resolver.promise;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (this.
|
|
21
|
-
this.
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
this.
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
dispose() {
|
|
28
|
-
for (const item of this.
|
|
29
|
-
item.reject(new Error(
|
|
30
|
-
}
|
|
31
|
-
this.
|
|
32
|
-
}
|
|
33
|
-
}
|
|
1
|
+
import { PromiseResolver } from "@yume-chan/async";
|
|
2
|
+
export class AutoResetEvent {
|
|
3
|
+
_set;
|
|
4
|
+
_queue = [];
|
|
5
|
+
constructor(initialSet = false) {
|
|
6
|
+
this._set = initialSet;
|
|
7
|
+
}
|
|
8
|
+
wait() {
|
|
9
|
+
if (!this._set) {
|
|
10
|
+
this._set = true;
|
|
11
|
+
if (this._queue.length === 0) {
|
|
12
|
+
return Promise.resolve();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const resolver = new PromiseResolver();
|
|
16
|
+
this._queue.push(resolver);
|
|
17
|
+
return resolver.promise;
|
|
18
|
+
}
|
|
19
|
+
notifyOne() {
|
|
20
|
+
if (this._queue.length !== 0) {
|
|
21
|
+
this._queue.pop().resolve();
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
this._set = false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
dispose() {
|
|
28
|
+
for (const item of this._queue) {
|
|
29
|
+
item.reject(new Error("The AutoResetEvent has been disposed"));
|
|
30
|
+
}
|
|
31
|
+
this._queue.length = 0;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
34
|
//# sourceMappingURL=auto-reset-event.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-reset-event.js","sourceRoot":"","sources":["../../src/utils/auto-reset-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGnD,MAAM,OAAO,cAAc;
|
|
1
|
+
{"version":3,"file":"auto-reset-event.js","sourceRoot":"","sources":["../../src/utils/auto-reset-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGnD,MAAM,OAAO,cAAc;IACf,IAAI,CAAU;IACL,MAAM,GAA4B,EAAE,CAAC;IAEtD,YAAmB,UAAU,GAAG,KAAK;QACjC,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IAC3B,CAAC;IAEM,IAAI;QACP,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YACZ,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;YAEjB,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;gBAC1B,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;aAC5B;SACJ;QAED,MAAM,QAAQ,GAAG,IAAI,eAAe,EAAQ,CAAC;QAC7C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC3B,OAAO,QAAQ,CAAC,OAAO,CAAC;IAC5B,CAAC;IAEM,SAAS;QACZ,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YAC1B,IAAI,CAAC,MAAM,CAAC,GAAG,EAAG,CAAC,OAAO,EAAE,CAAC;SAChC;aAAM;YACH,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;SACrB;IACL,CAAC;IAEM,OAAO;QACV,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE;YAC5B,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC,CAAC;SAClE;QACD,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IAC3B,CAAC;CACJ"}
|
package/esm/utils/base64.d.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Calculate the required length of the output buffer for the given input length.
|
|
3
|
-
*
|
|
4
|
-
* @param inputLength Length of the input in bytes
|
|
5
|
-
* @returns Length of the output in bytes
|
|
6
|
-
*/
|
|
7
|
-
export declare function calculateBase64EncodedLength(inputLength: number): [outputLength: number, paddingLength: number];
|
|
8
|
-
/**
|
|
9
|
-
* Encode the given input buffer into base64.
|
|
10
|
-
*
|
|
11
|
-
* @param input The input buffer
|
|
12
|
-
* @returns The encoded output buffer
|
|
13
|
-
*/
|
|
14
|
-
export declare function encodeBase64(input: Uint8Array): Uint8Array;
|
|
15
|
-
/**
|
|
16
|
-
* Encode the given input into base64 and write it to the output buffer.
|
|
17
|
-
*
|
|
18
|
-
* The output buffer must be at least as long as the value returned by `calculateBase64EncodedLength`.
|
|
19
|
-
* It can points to the same buffer as the input, as long as `output.offset <= input.offset - input.length / 3`,
|
|
20
|
-
* or `output.offset >= input.offset - 1`
|
|
21
|
-
*
|
|
22
|
-
* @param input The input buffer
|
|
23
|
-
* @param output The output buffer
|
|
24
|
-
* @returns The number of bytes written to the output buffer
|
|
25
|
-
*/
|
|
26
|
-
export declare function encodeBase64(input: Uint8Array, output: Uint8Array): number;
|
|
27
|
-
export declare function decodeBase64(input: string): Uint8Array;
|
|
1
|
+
/**
|
|
2
|
+
* Calculate the required length of the output buffer for the given input length.
|
|
3
|
+
*
|
|
4
|
+
* @param inputLength Length of the input in bytes
|
|
5
|
+
* @returns Length of the output in bytes
|
|
6
|
+
*/
|
|
7
|
+
export declare function calculateBase64EncodedLength(inputLength: number): [outputLength: number, paddingLength: number];
|
|
8
|
+
/**
|
|
9
|
+
* Encode the given input buffer into base64.
|
|
10
|
+
*
|
|
11
|
+
* @param input The input buffer
|
|
12
|
+
* @returns The encoded output buffer
|
|
13
|
+
*/
|
|
14
|
+
export declare function encodeBase64(input: Uint8Array): Uint8Array;
|
|
15
|
+
/**
|
|
16
|
+
* Encode the given input into base64 and write it to the output buffer.
|
|
17
|
+
*
|
|
18
|
+
* The output buffer must be at least as long as the value returned by `calculateBase64EncodedLength`.
|
|
19
|
+
* It can points to the same buffer as the input, as long as `output.offset <= input.offset - input.length / 3`,
|
|
20
|
+
* or `output.offset >= input.offset - 1`
|
|
21
|
+
*
|
|
22
|
+
* @param input The input buffer
|
|
23
|
+
* @param output The output buffer
|
|
24
|
+
* @returns The number of bytes written to the output buffer
|
|
25
|
+
*/
|
|
26
|
+
export declare function encodeBase64(input: Uint8Array, output: Uint8Array): number;
|
|
27
|
+
export declare function decodeBase64(input: string): Uint8Array;
|
|
28
28
|
//# sourceMappingURL=base64.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../src/utils/base64.ts"],"names":[],"mappings":"AAqBA;;;;;GAKG;AACH,wBAAgB,4BAA4B,
|
|
1
|
+
{"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../src/utils/base64.ts"],"names":[],"mappings":"AAqBA;;;;;GAKG;AACH,wBAAgB,4BAA4B,CACxC,WAAW,EAAE,MAAM,GACpB,CAAC,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,CAI/C;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAAC;AAC5D;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC;AAiO5E,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CA4DtD"}
|