@yume-chan/adb 0.0.23 → 1.0.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.
- package/CHANGELOG.md +51 -2
- package/LICENSE +1 -1
- package/README.md +4 -1
- package/esm/adb.d.ts +15 -9
- package/esm/adb.d.ts.map +1 -1
- package/esm/adb.js +5 -2
- package/esm/adb.js.map +1 -1
- package/esm/banner.d.ts +7 -6
- package/esm/banner.d.ts.map +1 -1
- package/esm/banner.js +6 -7
- package/esm/banner.js.map +1 -1
- package/esm/commands/framebuffer.d.ts +63 -34
- package/esm/commands/framebuffer.d.ts.map +1 -1
- package/esm/commands/framebuffer.js +35 -33
- package/esm/commands/framebuffer.js.map +1 -1
- package/esm/commands/power.d.ts.map +1 -1
- package/esm/commands/power.js +6 -5
- package/esm/commands/power.js.map +1 -1
- package/esm/commands/reverse.d.ts +12 -12
- package/esm/commands/reverse.d.ts.map +1 -1
- package/esm/commands/reverse.js +60 -39
- package/esm/commands/reverse.js.map +1 -1
- package/esm/commands/subprocess/command.js +3 -3
- package/esm/commands/subprocess/command.js.map +1 -1
- package/esm/commands/subprocess/protocols/none.d.ts +2 -2
- package/esm/commands/subprocess/protocols/none.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/none.js +3 -5
- package/esm/commands/subprocess/protocols/none.js.map +1 -1
- package/esm/commands/subprocess/protocols/shell.d.ts +22 -14
- package/esm/commands/subprocess/protocols/shell.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/shell.js +21 -27
- package/esm/commands/subprocess/protocols/shell.js.map +1 -1
- package/esm/commands/subprocess/protocols/types.d.ts +8 -8
- package/esm/commands/subprocess/protocols/types.d.ts.map +1 -1
- package/esm/commands/sync/list.d.ts +49 -30
- package/esm/commands/sync/list.d.ts.map +1 -1
- package/esm/commands/sync/list.js +9 -11
- package/esm/commands/sync/list.js.map +1 -1
- package/esm/commands/sync/pull.d.ts +7 -9
- package/esm/commands/sync/pull.d.ts.map +1 -1
- package/esm/commands/sync/pull.js +4 -6
- package/esm/commands/sync/pull.js.map +1 -1
- package/esm/commands/sync/push.d.ts +25 -22
- package/esm/commands/sync/push.d.ts.map +1 -1
- package/esm/commands/sync/push.js +14 -21
- package/esm/commands/sync/push.js.map +1 -1
- package/esm/commands/sync/request.d.ts +20 -23
- package/esm/commands/sync/request.d.ts.map +1 -1
- package/esm/commands/sync/request.js +26 -35
- package/esm/commands/sync/request.js.map +1 -1
- package/esm/commands/sync/response.d.ts +25 -19
- package/esm/commands/sync/response.d.ts.map +1 -1
- package/esm/commands/sync/response.js +49 -26
- package/esm/commands/sync/response.js.map +1 -1
- package/esm/commands/sync/socket.d.ts +3 -3
- package/esm/commands/sync/socket.d.ts.map +1 -1
- package/esm/commands/sync/socket.js +10 -5
- package/esm/commands/sync/socket.js.map +1 -1
- package/esm/commands/sync/stat.d.ts +75 -54
- package/esm/commands/sync/stat.d.ts.map +1 -1
- package/esm/commands/sync/stat.js +73 -69
- package/esm/commands/sync/stat.js.map +1 -1
- package/esm/commands/sync/sync.d.ts +18 -17
- package/esm/commands/sync/sync.d.ts.map +1 -1
- package/esm/commands/sync/sync.js +8 -8
- package/esm/commands/sync/sync.js.map +1 -1
- package/esm/commands/tcpip.d.ts +0 -1
- package/esm/commands/tcpip.d.ts.map +1 -1
- package/esm/commands/tcpip.js +9 -9
- package/esm/commands/tcpip.js.map +1 -1
- package/esm/daemon/auth.d.ts +8 -7
- package/esm/daemon/auth.d.ts.map +1 -1
- package/esm/daemon/auth.js +8 -9
- package/esm/daemon/auth.js.map +1 -1
- package/esm/daemon/crypto.d.ts +4 -3
- package/esm/daemon/crypto.d.ts.map +1 -1
- package/esm/daemon/crypto.js +57 -49
- package/esm/daemon/crypto.js.map +1 -1
- package/esm/daemon/device.d.ts +2 -2
- package/esm/daemon/device.d.ts.map +1 -1
- package/esm/daemon/dispatcher.d.ts +35 -10
- package/esm/daemon/dispatcher.d.ts.map +1 -1
- package/esm/daemon/dispatcher.js +46 -33
- package/esm/daemon/dispatcher.js.map +1 -1
- package/esm/daemon/packet.d.ts +48 -32
- package/esm/daemon/packet.d.ts.map +1 -1
- package/esm/daemon/packet.js +36 -32
- package/esm/daemon/packet.js.map +1 -1
- package/esm/daemon/socket.d.ts +11 -11
- package/esm/daemon/socket.d.ts.map +1 -1
- package/esm/daemon/socket.js +19 -40
- package/esm/daemon/socket.js.map +1 -1
- package/esm/daemon/transport.d.ts +60 -20
- package/esm/daemon/transport.d.ts.map +1 -1
- package/esm/daemon/transport.js +12 -15
- package/esm/daemon/transport.js.map +1 -1
- package/esm/device-observer.d.ts +10 -0
- package/esm/device-observer.d.ts.map +1 -0
- package/esm/device-observer.js +2 -0
- package/esm/device-observer.js.map +1 -0
- package/esm/features.d.ts +12 -11
- package/esm/features.d.ts.map +1 -1
- package/esm/features.js +11 -12
- package/esm/features.js.map +1 -1
- package/esm/index.d.ts +1 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/server/client.d.ts +140 -50
- package/esm/server/client.d.ts.map +1 -1
- package/esm/server/client.js +396 -180
- package/esm/server/client.js.map +1 -1
- package/esm/server/transport.d.ts +2 -2
- package/esm/server/transport.d.ts.map +1 -1
- package/esm/server/transport.js +4 -6
- package/esm/server/transport.js.map +1 -1
- package/esm/utils/base64.d.ts.map +1 -1
- package/esm/utils/base64.js +52 -38
- package/esm/utils/base64.js.map +1 -1
- package/esm/utils/hex.d.ts +1 -1
- package/esm/utils/hex.d.ts.map +1 -1
- package/esm/utils/hex.js +12 -14
- package/esm/utils/hex.js.map +1 -1
- package/esm/utils/index.d.ts +1 -1
- package/esm/utils/index.d.ts.map +1 -1
- package/esm/utils/index.js +1 -1
- package/esm/utils/index.js.map +1 -1
- package/esm/utils/no-op.d.ts.map +1 -1
- package/esm/utils/no-op.js +1 -0
- package/esm/utils/no-op.js.map +1 -1
- package/esm/utils/sequence-equal.d.ts +2 -0
- package/esm/utils/sequence-equal.d.ts.map +1 -0
- package/esm/utils/sequence-equal.js +12 -0
- package/esm/utils/sequence-equal.js.map +1 -0
- package/package.json +14 -19
- package/src/adb.ts +20 -11
- package/src/banner.ts +8 -6
- package/src/commands/framebuffer.ts +44 -35
- package/src/commands/power.ts +7 -5
- package/src/commands/reverse.ts +78 -47
- package/src/commands/subprocess/command.ts +3 -3
- package/src/commands/subprocess/protocols/none.ts +5 -7
- package/src/commands/subprocess/protocols/shell.ts +33 -35
- package/src/commands/subprocess/protocols/types.ts +8 -8
- package/src/commands/sync/list.ts +20 -15
- package/src/commands/sync/pull.ts +9 -8
- package/src/commands/sync/push.ts +25 -24
- package/src/commands/sync/request.ts +37 -38
- package/src/commands/sync/response.ts +63 -37
- package/src/commands/sync/socket.ts +13 -8
- package/src/commands/sync/stat.ts +93 -73
- package/src/commands/sync/sync.ts +12 -11
- package/src/commands/tcpip.ts +9 -9
- package/src/daemon/auth.ts +12 -10
- package/src/daemon/crypto.ts +66 -55
- package/src/daemon/device.ts +2 -2
- package/src/daemon/dispatcher.ts +106 -44
- package/src/daemon/packet.ts +57 -38
- package/src/daemon/socket.ts +30 -50
- package/src/daemon/transport.ts +98 -50
- package/src/device-observer.ts +10 -0
- package/src/features.ts +13 -11
- package/src/index.ts +1 -0
- package/src/server/client.ts +505 -268
- package/src/server/transport.ts +7 -9
- package/src/utils/base64.ts +59 -40
- package/src/utils/hex.ts +16 -14
- package/src/utils/index.ts +1 -1
- package/src/utils/no-op.ts +1 -0
- package/src/utils/sequence-equal.ts +13 -0
- package/tsconfig.build.json +1 -12
- package/tsconfig.build.tsbuildinfo +1 -1
- package/CHANGELOG.json +0 -265
- package/esm/utils/conditional-variable.d.ts +0 -8
- package/esm/utils/conditional-variable.d.ts.map +0 -1
- package/esm/utils/conditional-variable.js +0 -34
- package/esm/utils/conditional-variable.js.map +0 -1
- package/src/utils/conditional-variable.ts +0 -45
package/CHANGELOG.json
DELETED
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@yume-chan/adb",
|
|
3
|
-
"entries": [
|
|
4
|
-
{
|
|
5
|
-
"version": "0.0.23",
|
|
6
|
-
"tag": "@yume-chan/adb_v0.0.23",
|
|
7
|
-
"date": "Thu, 21 Mar 2024 03:15:10 GMT",
|
|
8
|
-
"comments": {
|
|
9
|
-
"none": [
|
|
10
|
-
{
|
|
11
|
-
"comment": "Refactor `AdbSubprocessShellProtocol` (this shouldn't affect usage)"
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
"comment": "Add `AdbServerClient.trackDevices`, which runs a callback function whenever device list changes"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"comment": "Add support for delayed ack on Android 14"
|
|
18
|
-
}
|
|
19
|
-
]
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"version": "0.0.22",
|
|
24
|
-
"tag": "@yume-chan/adb_v0.0.22",
|
|
25
|
-
"date": "Wed, 13 Dec 2023 05:57:27 GMT",
|
|
26
|
-
"comments": {
|
|
27
|
-
"none": [
|
|
28
|
-
{
|
|
29
|
-
"comment": "Add `getListenAddresses` method to `AdbTcpIpCommand` class for retrieving current ADB over WiFi state"
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
"comment": "Add `debugSlowRead` option to `AdbDaemonTransport` that throws an error when an ADB socket is stalled for 5 seconds"
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"comment": "Fix `AdbSync#read` stuck when there is an error"
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
"comment": "Fix TypeScript build when using `AdbSubprocessNoneProtocol` without installing `web-streams-polyfill` package"
|
|
39
|
-
}
|
|
40
|
-
]
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
"version": "0.0.21",
|
|
45
|
-
"tag": "@yume-chan/adb_v0.0.21",
|
|
46
|
-
"date": "Fri, 25 Aug 2023 14:05:18 GMT",
|
|
47
|
-
"comments": {
|
|
48
|
-
"none": [
|
|
49
|
-
{
|
|
50
|
-
"comment": "Change `AdbSync` to throws `AdbSyncError` for errors returned by ADB Daemon"
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
"comment": "Add name for public keys"
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
"comment": "Add typed errors for `framebuffer` command when current app disables screen capture"
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
"comment": "Change `AdbDaemonTransport` class to automatically close the connection, unless the new `preserveConnection` option is `true`"
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
"comment": "Add `recursive` and `force` options to `rm` method, allow deleting folders"
|
|
63
|
-
}
|
|
64
|
-
]
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
"version": "0.0.20",
|
|
69
|
-
"tag": "@yume-chan/adb_v0.0.20",
|
|
70
|
-
"date": "Mon, 05 Jun 2023 02:51:41 GMT",
|
|
71
|
-
"comments": {
|
|
72
|
-
"none": [
|
|
73
|
-
{
|
|
74
|
-
"comment": "Use ECMAScript private class fields syntax (supported by Chrome 74, Firefox 90, Safari 14.1 and Node.js 12.0.0)."
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
"comment": "Refactor `AdbSubprocessShellProtocol` class, this should improve some performance."
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
"comment": "Split `mode` parameter in `AdbSync#write()` into `type` and `permission` for ease of use."
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
"comment": "Add `AdbReverseCommand#addExternal()`. This only register the reverse tunnel to the device, the handler should already exists (for example you are adding a reverse tunnel for an external program that's already listening on the port). In ADB direct connection, this should do nothing, because the reverse tunnel is handled by this library and there is no mean of \"external\" handler."
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
"comment": "Change `AdbTcpIpCommand#setPort` and `AdbTcpIpCommand#disable` to return or throw the response text. This can be displayed to the user to know what's wrong."
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
"comment": "Add support for connecting to ADB servers. Because a USB device can only be used by one process at a time, the ADB server is the process that manages all connected devices. The server proxies and multiplexes connections from ADB clients so multiple adb commands can be executed on one device at the same time. The `Adb` class is no longer responsible for connecting and authenticating with ADB daemons. The `AdbTransport` interface and its two implementations `AdbDaemonTransport` and `AdbServerTransport` was added to connect to either ADB daemons or servers in compatible environments. Read the PR for details, migration paths, and examples. ([#549](https://github.com/yume-chan/ya-webadb/pull/549))"
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
"comment": "Add `serial` field to `Adb` class."
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
"comment": "Group `product`, `model`, `device` and `features` fields on `Adb` class to the `banner` field with type of `AdbBanner`."
|
|
96
|
-
}
|
|
97
|
-
]
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
"version": "0.0.19",
|
|
102
|
-
"tag": "@yume-chan/adb_v0.0.19",
|
|
103
|
-
"date": "Sun, 09 Apr 2023 05:55:33 GMT",
|
|
104
|
-
"comments": {
|
|
105
|
-
"none": [
|
|
106
|
-
{
|
|
107
|
-
"comment": "Remove `Adb#install` in favor of `PackageManager#install` from `@yume-chan/android-bin` package"
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
"comment": "Change `AdbSync#write` to take a `ReadableStream<Uint8Array>` instead of returning a `WritableStream<Uint8Array>`"
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
"comment": "Add buffering in sync module to improve transfer speed"
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
"comment": "Add `AdbReverseError` and `AdbReverseNotSupportedError` for better error handling in reverse tunnel command."
|
|
117
|
-
}
|
|
118
|
-
]
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
"version": "0.0.18",
|
|
123
|
-
"tag": "@yume-chan/adb_v0.0.18",
|
|
124
|
-
"date": "Wed, 25 Jan 2023 21:33:49 GMT",
|
|
125
|
-
"comments": {}
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
"version": "0.0.17",
|
|
129
|
-
"tag": "@yume-chan/adb_v0.0.17",
|
|
130
|
-
"date": "Tue, 18 Oct 2022 09:32:30 GMT",
|
|
131
|
-
"comments": {
|
|
132
|
-
"none": [
|
|
133
|
-
{
|
|
134
|
-
"comment": "Move stream utils to separate package"
|
|
135
|
-
}
|
|
136
|
-
]
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
"version": "0.0.16",
|
|
141
|
-
"tag": "@yume-chan/adb_v0.0.16",
|
|
142
|
-
"date": "Sat, 28 May 2022 03:56:37 GMT",
|
|
143
|
-
"comments": {
|
|
144
|
-
"none": [
|
|
145
|
-
{
|
|
146
|
-
"comment": "Upgrade TypeScript to 4.7.2 to enable Node.js ESM"
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
"comment": "Upgrade web-streams-polyfill to 4.0.0-beta.3, fix an issue where `Adb#close()` doesn't release the connection."
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
"comment": "Fix an issue where `AdbSocket#readable#cancel()` stalls the connection."
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
"comment": "Improve performance of `BufferedStream` by up to 100%."
|
|
156
|
-
}
|
|
157
|
-
]
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
"version": "0.0.15",
|
|
162
|
-
"tag": "@yume-chan/adb_v0.0.15",
|
|
163
|
-
"date": "Mon, 02 May 2022 04:18:01 GMT",
|
|
164
|
-
"comments": {
|
|
165
|
-
"none": [
|
|
166
|
-
{
|
|
167
|
-
"comment": "Add support for old protocol of `reverse:forward` command before Android 8"
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
"comment": "Improve connection lifecycle handling"
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
"comment": "Update `reverse.add` to accept any string local address"
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
"comment": "Fix an issue where `reverse` commands doesn't parse error message correctly"
|
|
177
|
-
}
|
|
178
|
-
]
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
"version": "0.0.14",
|
|
183
|
-
"tag": "@yume-chan/adb_v0.0.14",
|
|
184
|
-
"date": "Sat, 30 Apr 2022 14:05:48 GMT",
|
|
185
|
-
"comments": {
|
|
186
|
-
"none": [
|
|
187
|
-
{
|
|
188
|
-
"comment": "Fix an issue where `subprocess.spawn` doesn't work on Android 6"
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
"comment": "Add an `Adb#close()` method to gracefully shutdown a connection"
|
|
192
|
-
}
|
|
193
|
-
]
|
|
194
|
-
}
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
"version": "0.0.13",
|
|
198
|
-
"tag": "@yume-chan/adb_v0.0.13",
|
|
199
|
-
"date": "Thu, 28 Apr 2022 01:23:53 GMT",
|
|
200
|
-
"comments": {
|
|
201
|
-
"none": [
|
|
202
|
-
{
|
|
203
|
-
"comment": "Add support for raw shell mode"
|
|
204
|
-
},
|
|
205
|
-
{
|
|
206
|
-
"comment": "Add support for LIS2 command in Sync protocol"
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
"comment": "Add workaround for the push_mkdir issue in Android 9"
|
|
210
|
-
}
|
|
211
|
-
]
|
|
212
|
-
}
|
|
213
|
-
},
|
|
214
|
-
{
|
|
215
|
-
"version": "0.0.12",
|
|
216
|
-
"tag": "@yume-chan/adb_v0.0.12",
|
|
217
|
-
"date": "Sun, 03 Apr 2022 11:18:47 GMT",
|
|
218
|
-
"comments": {}
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
"version": "0.0.11",
|
|
222
|
-
"tag": "@yume-chan/adb_v0.0.11",
|
|
223
|
-
"date": "Sun, 03 Apr 2022 10:54:15 GMT",
|
|
224
|
-
"comments": {
|
|
225
|
-
"none": [
|
|
226
|
-
{
|
|
227
|
-
"comment": "Add power related API"
|
|
228
|
-
},
|
|
229
|
-
{
|
|
230
|
-
"comment": "Update compatibility matrix"
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
"comment": "Update license year"
|
|
234
|
-
}
|
|
235
|
-
],
|
|
236
|
-
"patch": [
|
|
237
|
-
{
|
|
238
|
-
"comment": "Update to use Web Streams API"
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
"comment": "Improve compatibility with Node.js 12 ESM format"
|
|
242
|
-
}
|
|
243
|
-
]
|
|
244
|
-
}
|
|
245
|
-
},
|
|
246
|
-
{
|
|
247
|
-
"version": "0.0.10",
|
|
248
|
-
"tag": "@yume-chan/adb_v0.0.10",
|
|
249
|
-
"date": "Sun, 09 Jan 2022 15:52:20 GMT",
|
|
250
|
-
"comments": {
|
|
251
|
-
"none": [
|
|
252
|
-
{
|
|
253
|
-
"comment": "Remove `encodeUtf8()` and `decodeUtf8()` from `AdbBackend`"
|
|
254
|
-
}
|
|
255
|
-
]
|
|
256
|
-
}
|
|
257
|
-
},
|
|
258
|
-
{
|
|
259
|
-
"version": "0.0.9",
|
|
260
|
-
"tag": "@yume-chan/adb_v0.0.9",
|
|
261
|
-
"date": "Sun, 09 Jan 2022 15:50:20 GMT",
|
|
262
|
-
"comments": {}
|
|
263
|
-
}
|
|
264
|
-
]
|
|
265
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Disposable } from "@yume-chan/event";
|
|
2
|
-
export declare class ConditionalVariable implements Disposable {
|
|
3
|
-
#private;
|
|
4
|
-
wait(condition: () => boolean): Promise<void>;
|
|
5
|
-
notifyOne(): void;
|
|
6
|
-
dispose(): void;
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=conditional-variable.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conditional-variable.d.ts","sourceRoot":"","sources":["../../src/utils/conditional-variable.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAOnD,qBAAa,mBAAoB,YAAW,UAAU;;IAIlD,IAAI,CAAC,SAAS,EAAE,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAa7C,SAAS;IAWT,OAAO,IAAI,IAAI;CAQlB"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { PromiseResolver } from "@yume-chan/async";
|
|
2
|
-
export class ConditionalVariable {
|
|
3
|
-
#locked = false;
|
|
4
|
-
#queue = [];
|
|
5
|
-
wait(condition) {
|
|
6
|
-
if (!this.#locked) {
|
|
7
|
-
this.#locked = true;
|
|
8
|
-
if (this.#queue.length === 0 && condition()) {
|
|
9
|
-
return Promise.resolve();
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
const resolver = new PromiseResolver();
|
|
13
|
-
this.#queue.push({ condition, resolver });
|
|
14
|
-
return resolver.promise;
|
|
15
|
-
}
|
|
16
|
-
notifyOne() {
|
|
17
|
-
const entry = this.#queue.shift();
|
|
18
|
-
if (entry) {
|
|
19
|
-
if (entry.condition()) {
|
|
20
|
-
entry.resolver.resolve();
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
this.#locked = false;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
dispose() {
|
|
28
|
-
for (const item of this.#queue) {
|
|
29
|
-
item.resolver.reject(new Error("The ConditionalVariable has been disposed"));
|
|
30
|
-
}
|
|
31
|
-
this.#queue.length = 0;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=conditional-variable.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conditional-variable.js","sourceRoot":"","sources":["../../src/utils/conditional-variable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAQnD,MAAM,OAAO,mBAAmB;IAC5B,OAAO,GAAG,KAAK,CAAC;IACP,MAAM,GAAgB,EAAE,CAAC;IAElC,IAAI,CAAC,SAAwB;QACzB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAChB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;YACpB,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,SAAS,EAAE,EAAE,CAAC;gBAC1C,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;YAC7B,CAAC;QACL,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,eAAe,EAAQ,CAAC;QAC7C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC1C,OAAO,QAAQ,CAAC,OAAO,CAAC;IAC5B,CAAC;IAED,SAAS;QACL,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClC,IAAI,KAAK,EAAE,CAAC;YACR,IAAI,KAAK,CAAC,SAAS,EAAE,EAAE,CAAC;gBACpB,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YAC7B,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACzB,CAAC;IACL,CAAC;IAED,OAAO;QACH,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC7B,IAAI,CAAC,QAAQ,CAAC,MAAM,CAChB,IAAI,KAAK,CAAC,2CAA2C,CAAC,CACzD,CAAC;QACN,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IAC3B,CAAC;CACJ"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { PromiseResolver } from "@yume-chan/async";
|
|
2
|
-
import type { Disposable } from "@yume-chan/event";
|
|
3
|
-
|
|
4
|
-
interface WaitEntry {
|
|
5
|
-
condition: () => boolean;
|
|
6
|
-
resolver: PromiseResolver<void>;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export class ConditionalVariable implements Disposable {
|
|
10
|
-
#locked = false;
|
|
11
|
-
readonly #queue: WaitEntry[] = [];
|
|
12
|
-
|
|
13
|
-
wait(condition: () => boolean): Promise<void> {
|
|
14
|
-
if (!this.#locked) {
|
|
15
|
-
this.#locked = true;
|
|
16
|
-
if (this.#queue.length === 0 && condition()) {
|
|
17
|
-
return Promise.resolve();
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const resolver = new PromiseResolver<void>();
|
|
22
|
-
this.#queue.push({ condition, resolver });
|
|
23
|
-
return resolver.promise;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
notifyOne() {
|
|
27
|
-
const entry = this.#queue.shift();
|
|
28
|
-
if (entry) {
|
|
29
|
-
if (entry.condition()) {
|
|
30
|
-
entry.resolver.resolve();
|
|
31
|
-
}
|
|
32
|
-
} else {
|
|
33
|
-
this.#locked = false;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
dispose(): void {
|
|
38
|
-
for (const item of this.#queue) {
|
|
39
|
-
item.resolver.reject(
|
|
40
|
-
new Error("The ConditionalVariable has been disposed"),
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
this.#queue.length = 0;
|
|
44
|
-
}
|
|
45
|
-
}
|