@yume-chan/adb 2.6.2 → 3.0.0-beta.1
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/LICENSE +1 -1
- package/README.md +1 -1
- package/esm/adb.d.ts +18 -15
- package/esm/adb.d.ts.map +1 -1
- package/esm/adb.js +18 -11
- package/esm/adb.js.map +1 -1
- package/esm/banner.d.ts +1 -1
- package/esm/banner.d.ts.map +1 -1
- package/esm/banner.js.map +1 -1
- package/esm/daemon/auth/authenticator.d.ts +28 -0
- package/esm/daemon/auth/authenticator.d.ts.map +1 -0
- package/esm/daemon/auth/authenticator.js +108 -0
- package/esm/daemon/auth/authenticator.js.map +1 -0
- package/esm/daemon/auth/index.d.ts +5 -0
- package/esm/daemon/auth/index.d.ts.map +1 -0
- package/esm/daemon/auth/index.js +5 -0
- package/esm/daemon/auth/index.js.map +1 -0
- package/esm/daemon/auth/packet-processor.d.ts +42 -0
- package/esm/daemon/auth/packet-processor.d.ts.map +1 -0
- package/esm/daemon/auth/packet-processor.js +129 -0
- package/esm/daemon/auth/packet-processor.js.map +1 -0
- package/esm/daemon/auth/public-key.d.ts +8 -0
- package/esm/daemon/auth/public-key.d.ts.map +1 -0
- package/esm/daemon/auth/public-key.js +74 -0
- package/esm/daemon/auth/public-key.js.map +1 -0
- package/esm/daemon/auth/type.d.ts +5 -0
- package/esm/daemon/auth/type.d.ts.map +1 -0
- package/esm/daemon/auth/type.js +2 -0
- package/esm/daemon/auth/type.js.map +1 -0
- package/esm/daemon/crypto.d.ts +6 -5
- package/esm/daemon/crypto.d.ts.map +1 -1
- package/esm/daemon/crypto.js +23 -72
- package/esm/daemon/crypto.js.map +1 -1
- package/esm/daemon/dispatcher.d.ts +3 -3
- package/esm/daemon/dispatcher.d.ts.map +1 -1
- package/esm/daemon/dispatcher.js +11 -4
- package/esm/daemon/dispatcher.js.map +1 -1
- package/esm/daemon/index.d.ts +1 -1
- package/esm/daemon/index.d.ts.map +1 -1
- package/esm/daemon/index.js +1 -1
- package/esm/daemon/index.js.map +1 -1
- package/esm/daemon/socket.d.ts +3 -3
- package/esm/daemon/socket.d.ts.map +1 -1
- package/esm/daemon/transport.d.ts +13 -65
- package/esm/daemon/transport.d.ts.map +1 -1
- package/esm/daemon/transport.js +18 -140
- package/esm/daemon/transport.js.map +1 -1
- package/esm/device-observer.d.ts +2 -3
- package/esm/device-observer.d.ts.map +1 -1
- package/esm/features-value.d.ts +40 -0
- package/esm/features-value.d.ts.map +1 -0
- package/esm/features-value.js +46 -0
- package/esm/features-value.js.map +1 -0
- package/esm/features.d.ts +4 -12
- package/esm/features.d.ts.map +1 -1
- package/esm/features.js +27 -13
- package/esm/features.js.map +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/server/client.d.ts +11 -10
- package/esm/server/client.d.ts.map +1 -1
- package/esm/server/client.js +82 -98
- package/esm/server/client.js.map +1 -1
- package/esm/server/commands/wireless.js +1 -1
- package/esm/server/commands/wireless.js.map +1 -1
- package/esm/server/{stream.d.ts → data-connection.d.ts} +5 -5
- package/esm/server/data-connection.d.ts.map +1 -0
- package/esm/server/{stream.js → data-connection.js} +4 -4
- package/esm/server/data-connection.js.map +1 -0
- package/esm/server/index.d.ts +1 -1
- package/esm/server/index.d.ts.map +1 -1
- package/esm/server/index.js +1 -1
- package/esm/server/index.js.map +1 -1
- package/esm/server/observer.d.ts.map +1 -1
- package/esm/server/observer.js +14 -13
- package/esm/server/observer.js.map +1 -1
- package/esm/server/transport.d.ts +4 -6
- package/esm/server/transport.d.ts.map +1 -1
- package/esm/server/transport.js +9 -24
- package/esm/server/transport.js.map +1 -1
- package/esm/service/framebuffer.d.ts.map +1 -0
- package/esm/service/framebuffer.js.map +1 -0
- package/esm/{commands → service}/index.d.ts +1 -2
- package/esm/service/index.d.ts.map +1 -0
- package/esm/{commands → service}/index.js +1 -2
- package/esm/service/index.js.map +1 -0
- package/esm/{commands → service}/power.d.ts +4 -2
- package/esm/service/power.d.ts.map +1 -0
- package/esm/{commands → service}/power.js +11 -5
- package/esm/service/power.js.map +1 -0
- package/esm/service/reverse/error.d.ts +14 -0
- package/esm/service/reverse/error.d.ts.map +1 -0
- package/esm/service/reverse/error.js +21 -0
- package/esm/service/reverse/error.js.map +1 -0
- package/esm/service/reverse/index.d.ts +3 -0
- package/esm/service/reverse/index.d.ts.map +1 -0
- package/esm/service/reverse/index.js +4 -0
- package/esm/service/reverse/index.js.map +1 -0
- package/esm/service/reverse/response.d.ts +2 -0
- package/esm/service/reverse/response.d.ts.map +1 -0
- package/esm/service/reverse/response.js +30 -0
- package/esm/service/reverse/response.js.map +1 -0
- package/esm/service/reverse/service.d.ts +59 -0
- package/esm/service/reverse/service.d.ts.map +1 -0
- package/esm/{commands/reverse.js → service/reverse/service.js} +16 -45
- package/esm/service/reverse/service.js.map +1 -0
- package/esm/{commands → service}/subprocess/index.d.ts +1 -0
- package/esm/service/subprocess/index.d.ts.map +1 -0
- package/esm/{commands → service}/subprocess/index.js +1 -0
- package/esm/service/subprocess/index.js.map +1 -0
- package/esm/service/subprocess/none/index.d.ts.map +1 -0
- package/esm/service/subprocess/none/index.js.map +1 -0
- package/esm/{commands → service}/subprocess/none/process.d.ts +2 -2
- package/esm/service/subprocess/none/process.d.ts.map +1 -0
- package/esm/service/subprocess/none/process.js.map +1 -0
- package/esm/{commands → service}/subprocess/none/pty.d.ts +4 -4
- package/esm/service/subprocess/none/pty.d.ts.map +1 -0
- package/esm/{commands → service}/subprocess/none/pty.js +1 -1
- package/esm/service/subprocess/none/pty.js.map +1 -0
- package/esm/service/subprocess/none/service.d.ts +10 -0
- package/esm/service/subprocess/none/service.d.ts.map +1 -0
- package/esm/service/subprocess/none/service.js +44 -0
- package/esm/service/subprocess/none/service.js.map +1 -0
- package/esm/service/subprocess/none/spawner.d.ts +15 -0
- package/esm/service/subprocess/none/spawner.d.ts.map +1 -0
- package/esm/service/subprocess/none/spawner.js +36 -0
- package/esm/service/subprocess/none/spawner.js.map +1 -0
- package/esm/{commands → service}/subprocess/pty.d.ts +1 -1
- package/esm/service/subprocess/pty.d.ts.map +1 -0
- package/esm/{commands → service}/subprocess/pty.js.map +1 -1
- package/esm/service/subprocess/service.d.ts.map +1 -0
- package/esm/{commands → service}/subprocess/service.js +1 -1
- package/esm/service/subprocess/service.js.map +1 -0
- package/esm/service/subprocess/shell/index.d.ts +5 -0
- package/esm/{commands/subprocess/none → service/subprocess/shell}/index.d.ts.map +1 -1
- package/esm/service/subprocess/shell/index.js +6 -0
- package/esm/{commands/subprocess/none → service/subprocess/shell}/index.js.map +1 -1
- package/esm/{commands → service}/subprocess/shell/process.d.ts +2 -2
- package/esm/service/subprocess/shell/process.d.ts.map +1 -0
- package/esm/{commands → service}/subprocess/shell/process.js +11 -15
- package/esm/service/subprocess/shell/process.js.map +1 -0
- package/esm/{commands → service}/subprocess/shell/pty.d.ts +4 -4
- package/esm/service/subprocess/shell/pty.d.ts.map +1 -0
- package/esm/{commands → service}/subprocess/shell/pty.js +11 -9
- package/esm/service/subprocess/shell/pty.js.map +1 -0
- package/esm/service/subprocess/shell/service.d.ts +34 -0
- package/esm/service/subprocess/shell/service.d.ts.map +1 -0
- package/esm/service/subprocess/shell/service.js +52 -0
- package/esm/service/subprocess/shell/service.js.map +1 -0
- package/esm/service/subprocess/shell/shared.d.ts +2 -0
- package/esm/service/subprocess/shell/shared.d.ts.map +1 -0
- package/esm/{commands → service}/subprocess/shell/shared.js +2 -0
- package/esm/service/subprocess/shell/shared.js.map +1 -0
- package/esm/{commands → service}/subprocess/shell/spawner.d.ts +3 -7
- package/esm/service/subprocess/shell/spawner.d.ts.map +1 -0
- package/esm/service/subprocess/shell/spawner.js +50 -0
- package/esm/service/subprocess/shell/spawner.js.map +1 -0
- package/esm/service/subprocess/types.d.ts +14 -0
- package/esm/service/subprocess/types.d.ts.map +1 -0
- package/esm/service/subprocess/types.js +2 -0
- package/esm/service/subprocess/types.js.map +1 -0
- package/esm/service/subprocess/utils.d.ts +39 -0
- package/esm/service/subprocess/utils.d.ts.map +1 -0
- package/esm/service/subprocess/utils.js +142 -0
- package/esm/service/subprocess/utils.js.map +1 -0
- package/esm/service/sync/android.d.ts +34 -0
- package/esm/service/sync/android.d.ts.map +1 -0
- package/esm/service/sync/android.js +34 -0
- package/esm/service/sync/android.js.map +1 -0
- package/esm/service/sync/compression/compression.d.ts +17 -0
- package/esm/service/sync/compression/compression.d.ts.map +1 -0
- package/esm/service/sync/compression/compression.js +92 -0
- package/esm/service/sync/compression/compression.js.map +1 -0
- package/esm/service/sync/compression/format-ns.d.ts +5 -0
- package/esm/service/sync/compression/format-ns.d.ts.map +1 -0
- package/esm/service/sync/compression/format-ns.js +5 -0
- package/esm/service/sync/compression/format-ns.js.map +1 -0
- package/esm/service/sync/compression/format.d.ts +4 -0
- package/esm/service/sync/compression/format.d.ts.map +1 -0
- package/esm/service/sync/compression/format.js +3 -0
- package/esm/service/sync/compression/format.js.map +1 -0
- package/esm/service/sync/compression/index.d.ts +2 -0
- package/esm/service/sync/compression/index.d.ts.map +1 -0
- package/esm/service/sync/compression/index.js +2 -0
- package/esm/service/sync/compression/index.js.map +1 -0
- package/esm/service/sync/id/common.d.ts +17 -0
- package/esm/service/sync/id/common.d.ts.map +1 -0
- package/esm/service/sync/id/common.js +29 -0
- package/esm/service/sync/id/common.js.map +1 -0
- package/esm/service/sync/id/index.d.ts +4 -0
- package/esm/service/sync/id/index.d.ts.map +1 -0
- package/esm/service/sync/id/index.js +6 -0
- package/esm/service/sync/id/index.js.map +1 -0
- package/esm/service/sync/id/request.d.ts +7 -0
- package/esm/service/sync/id/request.d.ts.map +1 -0
- package/esm/service/sync/id/request.js +9 -0
- package/esm/service/sync/id/request.js.map +1 -0
- package/esm/service/sync/id/response.d.ts +6 -0
- package/esm/service/sync/id/response.d.ts.map +1 -0
- package/esm/service/sync/id/response.js +8 -0
- package/esm/service/sync/id/response.js.map +1 -0
- package/esm/service/sync/index-ns.d.ts +7 -0
- package/esm/service/sync/index-ns.d.ts.map +1 -0
- package/esm/service/sync/index-ns.js +7 -0
- package/esm/service/sync/index-ns.js.map +1 -0
- package/esm/service/sync/index.d.ts +3 -0
- package/esm/service/sync/index.d.ts.map +1 -0
- package/esm/service/sync/index.js +3 -0
- package/esm/service/sync/index.js.map +1 -0
- package/esm/service/sync/request/index.d.ts +5 -0
- package/esm/service/sync/request/index.d.ts.map +1 -0
- package/esm/service/sync/request/index.js +5 -0
- package/esm/service/sync/request/index.js.map +1 -0
- package/esm/{commands/sync → service/sync/request}/list.d.ts +21 -19
- package/esm/service/sync/request/list.d.ts.map +1 -0
- package/esm/service/sync/request/list.js +77 -0
- package/esm/service/sync/request/list.js.map +1 -0
- package/esm/service/sync/request/pull.d.ts +12 -0
- package/esm/service/sync/request/pull.d.ts.map +1 -0
- package/esm/service/sync/request/pull.js +28 -0
- package/esm/service/sync/request/pull.js.map +1 -0
- package/esm/service/sync/request/push.d.ts +54 -0
- package/esm/service/sync/request/push.d.ts.map +1 -0
- package/esm/service/sync/request/push.js +95 -0
- package/esm/service/sync/request/push.js.map +1 -0
- package/esm/{commands/sync → service/sync/request}/stat.d.ts +40 -50
- package/esm/service/sync/request/stat.d.ts.map +1 -0
- package/esm/service/sync/request/stat.js +89 -0
- package/esm/service/sync/request/stat.js.map +1 -0
- package/esm/service/sync/service.d.ts +123 -0
- package/esm/service/sync/service.d.ts.map +1 -0
- package/esm/service/sync/service.js +170 -0
- package/esm/service/sync/service.js.map +1 -0
- package/esm/service/sync/socket-pool.d.ts +11 -0
- package/esm/service/sync/socket-pool.d.ts.map +1 -0
- package/esm/service/sync/socket-pool.js +80 -0
- package/esm/service/sync/socket-pool.js.map +1 -0
- package/esm/service/sync/socket.d.ts +40 -0
- package/esm/service/sync/socket.d.ts.map +1 -0
- package/esm/service/sync/socket.js +153 -0
- package/esm/service/sync/socket.js.map +1 -0
- package/esm/{commands → service}/tcpip.d.ts +4 -2
- package/esm/service/tcpip.d.ts.map +1 -0
- package/esm/{commands → service}/tcpip.js +10 -7
- package/esm/service/tcpip.js.map +1 -0
- package/esm/utils/array-buffer.d.ts.map +1 -1
- package/esm/utils/array-buffer.js +2 -3
- package/esm/utils/array-buffer.js.map +1 -1
- package/esm/utils/base64.d.ts.map +1 -1
- package/esm/utils/base64.js +22 -10
- package/esm/utils/base64.js.map +1 -1
- package/esm/utils/index.d.ts +1 -0
- package/esm/utils/index.d.ts.map +1 -1
- package/esm/utils/index.js +1 -0
- package/esm/utils/index.js.map +1 -1
- package/esm/utils/md5.d.ts +8 -0
- package/esm/utils/md5.d.ts.map +1 -0
- package/esm/utils/md5.js +149 -0
- package/esm/utils/md5.js.map +1 -0
- package/package.json +7 -7
- package/src/adb.ts +44 -35
- package/src/banner.ts +2 -1
- package/src/daemon/auth/authenticator.ts +186 -0
- package/src/daemon/auth/index.ts +4 -0
- package/src/daemon/auth/packet-processor.ts +212 -0
- package/src/daemon/auth/public-key.ts +112 -0
- package/src/daemon/auth/type.ts +5 -0
- package/src/daemon/crypto.ts +36 -101
- package/src/daemon/dispatcher.ts +15 -8
- package/src/daemon/index.ts +1 -1
- package/src/daemon/socket.ts +3 -3
- package/src/daemon/transport.ts +35 -253
- package/src/device-observer.ts +3 -3
- package/src/features-value.ts +47 -0
- package/src/features.ts +31 -14
- package/src/index.ts +1 -1
- package/src/server/client.ts +112 -104
- package/src/server/commands/wireless.ts +1 -1
- package/src/server/{stream.ts → data-connection.ts} +4 -4
- package/src/server/index.ts +1 -1
- package/src/server/observer.ts +21 -19
- package/src/server/transport.ts +13 -34
- package/src/{commands → service}/index.ts +1 -2
- package/src/{commands → service}/power.ts +14 -5
- package/src/service/reverse/error.ts +35 -0
- package/src/service/reverse/index.ts +3 -0
- package/src/service/reverse/response.ts +38 -0
- package/src/{commands/reverse.ts → service/reverse/service.ts} +32 -72
- package/src/{commands → service}/subprocess/index.ts +1 -0
- package/src/{commands → service}/subprocess/none/process.ts +3 -3
- package/src/{commands → service}/subprocess/none/pty.ts +5 -5
- package/src/service/subprocess/none/service.ts +57 -0
- package/src/service/subprocess/none/spawner.ts +85 -0
- package/src/{commands → service}/subprocess/pty.ts +1 -1
- package/src/{commands → service}/subprocess/service.ts +1 -1
- package/src/{commands → service}/subprocess/shell/index.ts +1 -1
- package/src/{commands → service}/subprocess/shell/process.ts +13 -17
- package/src/{commands → service}/subprocess/shell/pty.ts +15 -13
- package/src/service/subprocess/shell/service.ts +75 -0
- package/src/{commands → service}/subprocess/shell/shared.ts +5 -0
- package/src/service/subprocess/shell/spawner.ts +113 -0
- package/src/service/subprocess/types.ts +19 -0
- package/src/service/subprocess/utils.ts +166 -0
- package/src/service/sync/android.ts +43 -0
- package/src/service/sync/compression/compression.ts +126 -0
- package/src/service/sync/compression/format-ns.ts +4 -0
- package/src/service/sync/compression/format.ts +5 -0
- package/src/service/sync/compression/index.ts +1 -0
- package/src/service/sync/id/common.ts +33 -0
- package/src/service/sync/id/index.ts +7 -0
- package/src/service/sync/id/request.ts +12 -0
- package/src/service/sync/id/response.ts +11 -0
- package/src/service/sync/index-ns.ts +6 -0
- package/src/service/sync/index.ts +2 -0
- package/src/service/sync/request/index.ts +4 -0
- package/src/service/sync/request/list.ts +110 -0
- package/src/service/sync/request/pull.ts +49 -0
- package/src/service/sync/request/push.ts +184 -0
- package/src/service/sync/request/stat.ts +127 -0
- package/src/service/sync/service.ts +255 -0
- package/src/service/sync/socket-pool.ts +97 -0
- package/src/service/sync/socket.ts +201 -0
- package/src/{commands → service}/tcpip.ts +13 -7
- package/src/utils/array-buffer.ts +2 -3
- package/src/utils/base64.ts +24 -10
- package/src/utils/index.ts +1 -0
- package/src/utils/md5.ts +185 -0
- package/CHANGELOG.md +0 -257
- package/esm/commands/base.d.ts +0 -8
- package/esm/commands/base.d.ts.map +0 -1
- package/esm/commands/base.js +0 -12
- package/esm/commands/base.js.map +0 -1
- package/esm/commands/framebuffer.d.ts.map +0 -1
- package/esm/commands/framebuffer.js.map +0 -1
- package/esm/commands/index.d.ts.map +0 -1
- package/esm/commands/index.js.map +0 -1
- package/esm/commands/power.d.ts.map +0 -1
- package/esm/commands/power.js.map +0 -1
- package/esm/commands/reverse.d.ts +0 -48
- package/esm/commands/reverse.d.ts.map +0 -1
- package/esm/commands/reverse.js.map +0 -1
- package/esm/commands/subprocess/index.d.ts.map +0 -1
- package/esm/commands/subprocess/index.js.map +0 -1
- package/esm/commands/subprocess/none/process.d.ts.map +0 -1
- package/esm/commands/subprocess/none/process.js.map +0 -1
- package/esm/commands/subprocess/none/pty.d.ts.map +0 -1
- package/esm/commands/subprocess/none/pty.js.map +0 -1
- package/esm/commands/subprocess/none/service.d.ts +0 -10
- package/esm/commands/subprocess/none/service.d.ts.map +0 -1
- package/esm/commands/subprocess/none/service.js +0 -34
- package/esm/commands/subprocess/none/service.js.map +0 -1
- package/esm/commands/subprocess/none/spawner.d.ts +0 -19
- package/esm/commands/subprocess/none/spawner.d.ts.map +0 -1
- package/esm/commands/subprocess/none/spawner.js +0 -26
- package/esm/commands/subprocess/none/spawner.js.map +0 -1
- package/esm/commands/subprocess/pty.d.ts.map +0 -1
- package/esm/commands/subprocess/service.d.ts.map +0 -1
- package/esm/commands/subprocess/service.js.map +0 -1
- package/esm/commands/subprocess/shell/index.d.ts +0 -6
- package/esm/commands/subprocess/shell/index.d.ts.map +0 -1
- package/esm/commands/subprocess/shell/index.js +0 -6
- package/esm/commands/subprocess/shell/index.js.map +0 -1
- package/esm/commands/subprocess/shell/process.d.ts.map +0 -1
- package/esm/commands/subprocess/shell/process.js.map +0 -1
- package/esm/commands/subprocess/shell/pty.d.ts.map +0 -1
- package/esm/commands/subprocess/shell/pty.js.map +0 -1
- package/esm/commands/subprocess/shell/service.d.ts +0 -14
- package/esm/commands/subprocess/shell/service.d.ts.map +0 -1
- package/esm/commands/subprocess/shell/service.js +0 -41
- package/esm/commands/subprocess/shell/service.js.map +0 -1
- package/esm/commands/subprocess/shell/shared.d.ts +0 -19
- package/esm/commands/subprocess/shell/shared.d.ts.map +0 -1
- package/esm/commands/subprocess/shell/shared.js.map +0 -1
- package/esm/commands/subprocess/shell/spawner.d.ts.map +0 -1
- package/esm/commands/subprocess/shell/spawner.js +0 -38
- package/esm/commands/subprocess/shell/spawner.js.map +0 -1
- package/esm/commands/subprocess/utils.d.ts +0 -3
- package/esm/commands/subprocess/utils.d.ts.map +0 -1
- package/esm/commands/subprocess/utils.js +0 -56
- package/esm/commands/subprocess/utils.js.map +0 -1
- package/esm/commands/sync/index.d.ts +0 -9
- package/esm/commands/sync/index.d.ts.map +0 -1
- package/esm/commands/sync/index.js +0 -9
- package/esm/commands/sync/index.js.map +0 -1
- package/esm/commands/sync/list.d.ts.map +0 -1
- package/esm/commands/sync/list.js +0 -64
- package/esm/commands/sync/list.js.map +0 -1
- package/esm/commands/sync/pull.d.ts +0 -12
- package/esm/commands/sync/pull.d.ts.map +0 -1
- package/esm/commands/sync/pull.js +0 -33
- package/esm/commands/sync/pull.js.map +0 -1
- package/esm/commands/sync/push.d.ts +0 -61
- package/esm/commands/sync/push.d.ts.map +0 -1
- package/esm/commands/sync/push.js +0 -83
- package/esm/commands/sync/push.js.map +0 -1
- package/esm/commands/sync/request.d.ts +0 -24
- package/esm/commands/sync/request.d.ts.map +0 -1
- package/esm/commands/sync/request.js +0 -32
- package/esm/commands/sync/request.js.map +0 -1
- package/esm/commands/sync/response.d.ts +0 -28
- package/esm/commands/sync/response.d.ts.map +0 -1
- package/esm/commands/sync/response.js +0 -81
- package/esm/commands/sync/response.js.map +0 -1
- package/esm/commands/sync/socket.d.ts +0 -22
- package/esm/commands/sync/socket.d.ts.map +0 -1
- package/esm/commands/sync/socket.js +0 -78
- package/esm/commands/sync/socket.js.map +0 -1
- package/esm/commands/sync/stat.d.ts.map +0 -1
- package/esm/commands/sync/stat.js +0 -121
- package/esm/commands/sync/stat.js.map +0 -1
- package/esm/commands/sync/sync.d.ts +0 -82
- package/esm/commands/sync/sync.d.ts.map +0 -1
- package/esm/commands/sync/sync.js +0 -138
- package/esm/commands/sync/sync.js.map +0 -1
- package/esm/commands/tcpip.d.ts.map +0 -1
- package/esm/commands/tcpip.js.map +0 -1
- package/esm/daemon/auth.d.ts +0 -54
- package/esm/daemon/auth.d.ts.map +0 -1
- package/esm/daemon/auth.js +0 -104
- package/esm/daemon/auth.js.map +0 -1
- package/esm/server/stream.d.ts.map +0 -1
- package/esm/server/stream.js.map +0 -1
- package/src/commands/base.ts +0 -15
- package/src/commands/subprocess/none/service.ts +0 -45
- package/src/commands/subprocess/none/spawner.ts +0 -68
- package/src/commands/subprocess/shell/service.ts +0 -58
- package/src/commands/subprocess/shell/spawner.ts +0 -90
- package/src/commands/subprocess/utils.ts +0 -61
- package/src/commands/sync/index.ts +0 -8
- package/src/commands/sync/list.ts +0 -99
- package/src/commands/sync/pull.ts +0 -55
- package/src/commands/sync/push.ts +0 -172
- package/src/commands/sync/request.ts +0 -53
- package/src/commands/sync/response.ts +0 -105
- package/src/commands/sync/socket.ts +0 -109
- package/src/commands/sync/stat.ts +0 -177
- package/src/commands/sync/sync.ts +0 -175
- package/src/daemon/auth.ts +0 -203
- package/tsconfig.build.tsbuildinfo +0 -1
- /package/esm/{commands → service}/framebuffer.d.ts +0 -0
- /package/esm/{commands → service}/framebuffer.js +0 -0
- /package/esm/{commands → service}/subprocess/none/index.d.ts +0 -0
- /package/esm/{commands → service}/subprocess/none/index.js +0 -0
- /package/esm/{commands → service}/subprocess/none/process.js +0 -0
- /package/esm/{commands → service}/subprocess/pty.js +0 -0
- /package/esm/{commands → service}/subprocess/service.d.ts +0 -0
- /package/src/{commands → service}/framebuffer.ts +0 -0
- /package/src/{commands → service}/subprocess/none/index.ts +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// cspell: ignore Libusb
|
|
2
|
+
// cspell: ignore devraw
|
|
3
|
+
// cspell: ignore Openscreen
|
|
4
|
+
// cspell: ignore devicetracker
|
|
5
|
+
|
|
6
|
+
// The order follows
|
|
7
|
+
// https://cs.android.com/android/platform/superproject/main/+/main:packages/modules/adb/transport.cpp;l=81;drc=2d3e62c2af54a3e8f8803ea10492e63b8dfe709f
|
|
8
|
+
|
|
9
|
+
export const Shell2 = "shell_v2";
|
|
10
|
+
export const Cmd = "cmd";
|
|
11
|
+
export const Stat2 = "stat_v2";
|
|
12
|
+
export const Ls2 = "ls_v2";
|
|
13
|
+
/**
|
|
14
|
+
* server only
|
|
15
|
+
*/
|
|
16
|
+
export const Libusb = "libusb";
|
|
17
|
+
/**
|
|
18
|
+
* server only
|
|
19
|
+
*/
|
|
20
|
+
export const PushSync = "push_sync";
|
|
21
|
+
export const Apex = "apex";
|
|
22
|
+
export const FixedPushMkdir = "fixed_push_mkdir";
|
|
23
|
+
export const Abb = "abb";
|
|
24
|
+
export const FixedPushSymlinkTimestamp = "fixed_push_symlink_timestamp";
|
|
25
|
+
export const AbbExec = "abb_exec";
|
|
26
|
+
export const RemountShell = "remount_shell";
|
|
27
|
+
export const TrackApp = "track_app";
|
|
28
|
+
export const SendReceive2 = "sendrecv_v2";
|
|
29
|
+
export const SendReceive2Brotli = "sendrecv_v2_brotli";
|
|
30
|
+
export const SendReceive2Lz4 = "sendrecv_v2_lz4";
|
|
31
|
+
export const SendReceive2Zstd = "sendrecv_v2_zstd";
|
|
32
|
+
export const SendReceive2DryRunSend = "sendrecv_v2_dry_run_send";
|
|
33
|
+
export const DelayedAck = "delayed_ack";
|
|
34
|
+
/**
|
|
35
|
+
* server only
|
|
36
|
+
*/
|
|
37
|
+
export const OpenscreenMdns = "openscreen_mdns";
|
|
38
|
+
/**
|
|
39
|
+
* server only
|
|
40
|
+
*/
|
|
41
|
+
export const DeviceTrackerProtoFormat = "devicetracker_proto_format";
|
|
42
|
+
export const DevRaw = "devraw";
|
|
43
|
+
export const AppInfo = "app_info";
|
|
44
|
+
/**
|
|
45
|
+
* server only
|
|
46
|
+
*/
|
|
47
|
+
export const ServerStatus = "server_status";
|
package/src/features.ts
CHANGED
|
@@ -1,15 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
// https://cs.android.com/android/platform/superproject/+/master:packages/modules/adb/transport.cpp;l=77;drc=6d14d35d0241f6fee145f8e54ffd77252e8d29fd
|
|
3
|
-
export const AdbFeature = {
|
|
4
|
-
ShellV2: "shell_v2",
|
|
5
|
-
Cmd: "cmd",
|
|
6
|
-
StatV2: "stat_v2",
|
|
7
|
-
ListV2: "ls_v2",
|
|
8
|
-
FixedPushMkdir: "fixed_push_mkdir",
|
|
9
|
-
Abb: "abb",
|
|
10
|
-
AbbExec: "abb_exec",
|
|
11
|
-
SendReceiveV2: "sendrecv_v2",
|
|
12
|
-
DelayedAck: "delayed_ack",
|
|
13
|
-
} as const;
|
|
1
|
+
import * as AdbFeature from "./features-value.js";
|
|
14
2
|
|
|
15
|
-
|
|
3
|
+
// biome-ignore lint/suspicious/noRedeclare: TypeScript declaration merging for enum-like object
|
|
4
|
+
type AdbFeature = (typeof AdbFeature)[keyof typeof AdbFeature];
|
|
5
|
+
|
|
6
|
+
export { AdbFeature };
|
|
7
|
+
|
|
8
|
+
// https://android.googlesource.com/platform/packages/modules/adb/+/79010dc6d5ca7490c493df800d4421730f5466ca/transport.cpp#1252
|
|
9
|
+
// There are some other feature constants, but some of them are only used by ADB server, not devices (daemons).
|
|
10
|
+
export const AdbDeviceFeatures = [
|
|
11
|
+
AdbFeature.Shell2,
|
|
12
|
+
AdbFeature.Cmd,
|
|
13
|
+
AdbFeature.Stat2,
|
|
14
|
+
AdbFeature.Ls2,
|
|
15
|
+
AdbFeature.FixedPushMkdir,
|
|
16
|
+
AdbFeature.Apex,
|
|
17
|
+
AdbFeature.Abb,
|
|
18
|
+
// only tells the client the symlink timestamp issue in `adb push --sync` has been fixed.
|
|
19
|
+
// No special handling required.
|
|
20
|
+
AdbFeature.FixedPushSymlinkTimestamp,
|
|
21
|
+
AdbFeature.AbbExec,
|
|
22
|
+
AdbFeature.RemountShell,
|
|
23
|
+
AdbFeature.TrackApp,
|
|
24
|
+
AdbFeature.SendReceive2,
|
|
25
|
+
AdbFeature.SendReceive2Brotli,
|
|
26
|
+
AdbFeature.SendReceive2Lz4,
|
|
27
|
+
AdbFeature.SendReceive2Zstd,
|
|
28
|
+
AdbFeature.SendReceive2DryRunSend,
|
|
29
|
+
AdbFeature.DevRaw,
|
|
30
|
+
AdbFeature.AppInfo,
|
|
31
|
+
AdbFeature.DelayedAck,
|
|
32
|
+
] as readonly AdbFeature[];
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export * from "./adb.js";
|
|
2
2
|
export * from "./banner.js";
|
|
3
|
-
export * from "./commands/index.js";
|
|
4
3
|
export * from "./daemon/index.js";
|
|
5
4
|
export * from "./device-observer.js";
|
|
6
5
|
export * from "./features.js";
|
|
7
6
|
export * from "./server/index.js";
|
|
7
|
+
export * from "./service/index.js";
|
|
8
8
|
export * from "./utils/index.js";
|
package/src/server/client.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// cspell:ignore tport
|
|
2
2
|
|
|
3
3
|
import type { MaybePromiseLike } from "@yume-chan/async";
|
|
4
|
-
import { PromiseResolver } from "@yume-chan/async";
|
|
5
4
|
import type { Event } from "@yume-chan/event";
|
|
6
5
|
import { getUint64LittleEndian } from "@yume-chan/no-data-view";
|
|
7
6
|
import type {
|
|
@@ -11,7 +10,7 @@ import type {
|
|
|
11
10
|
} from "@yume-chan/stream-extra";
|
|
12
11
|
import { AbortController } from "@yume-chan/stream-extra";
|
|
13
12
|
|
|
14
|
-
import type {
|
|
13
|
+
import type { Closeable } from "../adb.js";
|
|
15
14
|
import { Adb } from "../adb.js";
|
|
16
15
|
import { AdbBanner } from "../banner.js";
|
|
17
16
|
import type { DeviceObserver as DeviceObserverBase } from "../device-observer.js";
|
|
@@ -25,14 +24,53 @@ import {
|
|
|
25
24
|
NetworkError as _NetworkError,
|
|
26
25
|
UnauthorizedError as _UnauthorizedError,
|
|
27
26
|
} from "./commands/index.js";
|
|
27
|
+
import { AdbServerDataConnection } from "./data-connection.js";
|
|
28
28
|
import { AdbServerDeviceObserverOwner } from "./observer.js";
|
|
29
|
-
import { AdbServerStream } from "./stream.js";
|
|
30
29
|
import { AdbServerTransport } from "./transport.js";
|
|
31
30
|
|
|
31
|
+
const KeyTransportId = " transport_id:";
|
|
32
|
+
const KeyDevice = " device:";
|
|
33
|
+
const KeyModel = " model:";
|
|
34
|
+
const KeyProduct = " product:";
|
|
35
|
+
|
|
36
|
+
function parseDeviceLineItem<
|
|
37
|
+
T extends string = string,
|
|
38
|
+
Optional extends boolean = false,
|
|
39
|
+
>(
|
|
40
|
+
line: string,
|
|
41
|
+
end: number,
|
|
42
|
+
key: string,
|
|
43
|
+
optional?: Optional,
|
|
44
|
+
): readonly [start: number, value: Optional extends false ? T : T | undefined] {
|
|
45
|
+
const start = line.lastIndexOf(key, end - 1);
|
|
46
|
+
if (start === -1) {
|
|
47
|
+
if (optional) {
|
|
48
|
+
return [end, undefined as never] as const;
|
|
49
|
+
} else {
|
|
50
|
+
throw new Error(`Invalid device line: ${line}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return [start, line.substring(start + key.length, end) as T] as const;
|
|
54
|
+
}
|
|
55
|
+
|
|
32
56
|
/**
|
|
33
57
|
* Client for the ADB Server.
|
|
34
58
|
*/
|
|
35
59
|
export class AdbServerClient {
|
|
60
|
+
// https://android.googlesource.com/platform/packages/modules/adb/+/9f298fb1f3317371b49439efb20a598b3a881bf3/adb.cpp#144
|
|
61
|
+
static ConnectionState = [
|
|
62
|
+
"offline",
|
|
63
|
+
"bootloader",
|
|
64
|
+
"device",
|
|
65
|
+
"host",
|
|
66
|
+
"recovery",
|
|
67
|
+
"rescue",
|
|
68
|
+
"sideload",
|
|
69
|
+
"unauthorized",
|
|
70
|
+
"authorizing",
|
|
71
|
+
"detached",
|
|
72
|
+
] as const;
|
|
73
|
+
|
|
36
74
|
static NetworkError = _NetworkError;
|
|
37
75
|
static UnauthorizedError = _UnauthorizedError;
|
|
38
76
|
static AlreadyConnectedError = _AlreadyConnectedError;
|
|
@@ -50,37 +88,46 @@ export class AdbServerClient {
|
|
|
50
88
|
continue;
|
|
51
89
|
}
|
|
52
90
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
91
|
+
// Parse backwards because `serial` might contain spaces.
|
|
92
|
+
|
|
93
|
+
let end = line.length;
|
|
94
|
+
let value: string;
|
|
95
|
+
|
|
96
|
+
// transport_id:123
|
|
97
|
+
// eslint-disable-next-line prefer-const
|
|
98
|
+
[end, value] = parseDeviceLineItem(line, end, KeyTransportId);
|
|
99
|
+
const transportId = BigInt(value);
|
|
100
|
+
|
|
101
|
+
// device:abc (optional)
|
|
102
|
+
let device: string | undefined;
|
|
103
|
+
// eslint-disable-next-line prefer-const
|
|
104
|
+
[end, device] = parseDeviceLineItem(line, end, KeyDevice, true);
|
|
105
|
+
|
|
106
|
+
// model:abc (optional)
|
|
107
|
+
let model: string | undefined;
|
|
108
|
+
// eslint-disable-next-line prefer-const
|
|
109
|
+
[end, model] = parseDeviceLineItem(line, end, KeyModel, true);
|
|
110
|
+
|
|
111
|
+
// product:abc (optional)
|
|
112
|
+
let product: string | undefined;
|
|
113
|
+
// eslint-disable-next-line prefer-const
|
|
114
|
+
[end, product] = parseDeviceLineItem(line, end, KeyProduct, true);
|
|
115
|
+
|
|
116
|
+
let state: AdbServerClient.ConnectionState;
|
|
117
|
+
do {
|
|
118
|
+
// devpath or state
|
|
119
|
+
// devpath doesn't have a fixed pattern
|
|
120
|
+
// (for example, libusb driver gives plain strings like `5-1.4`)
|
|
121
|
+
// so keep parsing until we get a valid state
|
|
122
|
+
[end, state] = parseDeviceLineItem(line, end, " ");
|
|
123
|
+
} while (!AdbServerClient.ConnectionState.includes(state));
|
|
124
|
+
|
|
56
125
|
if (!includeStates.includes(state)) {
|
|
57
126
|
continue;
|
|
58
127
|
}
|
|
59
128
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
let device: string | undefined;
|
|
63
|
-
let transportId: bigint | undefined;
|
|
64
|
-
for (let i = 2; i < parts.length; i += 1) {
|
|
65
|
-
const [key, value] = parts[i]!.split(":");
|
|
66
|
-
switch (key) {
|
|
67
|
-
case "product":
|
|
68
|
-
product = value;
|
|
69
|
-
break;
|
|
70
|
-
case "model":
|
|
71
|
-
model = value;
|
|
72
|
-
break;
|
|
73
|
-
case "device":
|
|
74
|
-
device = value;
|
|
75
|
-
break;
|
|
76
|
-
case "transport_id":
|
|
77
|
-
transportId = BigInt(value!);
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (!transportId) {
|
|
82
|
-
throw new Error(`No transport id for device ${serial}`);
|
|
83
|
-
}
|
|
129
|
+
const serial = line.substring(0, end).trim();
|
|
130
|
+
|
|
84
131
|
devices.push({
|
|
85
132
|
serial,
|
|
86
133
|
state,
|
|
@@ -129,24 +176,16 @@ export class AdbServerClient {
|
|
|
129
176
|
async createConnection(
|
|
130
177
|
request: string,
|
|
131
178
|
options?: AdbServerClient.ServerConnectionOptions,
|
|
132
|
-
): Promise<
|
|
179
|
+
): Promise<AdbServerDataConnection> {
|
|
133
180
|
const connection = await this.connector.connect(options);
|
|
134
|
-
const
|
|
181
|
+
const dataConnection = new AdbServerDataConnection(connection);
|
|
135
182
|
|
|
136
183
|
try {
|
|
137
|
-
await
|
|
184
|
+
await dataConnection.writeString(request);
|
|
185
|
+
await dataConnection.readOkay();
|
|
186
|
+
return dataConnection;
|
|
138
187
|
} catch (e) {
|
|
139
|
-
await
|
|
140
|
-
throw e;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
try {
|
|
144
|
-
// `raceSignal` throws when the signal is aborted,
|
|
145
|
-
// so the `catch` block can close the connection.
|
|
146
|
-
await raceSignal(() => stream.readOkay(), options?.signal);
|
|
147
|
-
return stream;
|
|
148
|
-
} catch (e) {
|
|
149
|
-
await stream.dispose();
|
|
188
|
+
await dataConnection.dispose();
|
|
150
189
|
throw e;
|
|
151
190
|
}
|
|
152
191
|
}
|
|
@@ -154,8 +193,10 @@ export class AdbServerClient {
|
|
|
154
193
|
/**
|
|
155
194
|
* `adb version`
|
|
156
195
|
*/
|
|
157
|
-
async getVersion(
|
|
158
|
-
|
|
196
|
+
async getVersion(
|
|
197
|
+
options?: AdbServerClient.ServerConnectionOptions,
|
|
198
|
+
): Promise<number> {
|
|
199
|
+
const connection = await this.createConnection("host:version", options);
|
|
159
200
|
try {
|
|
160
201
|
const length = hexToNumber(await connection.readExactly(4));
|
|
161
202
|
const version = hexToNumber(await connection.readExactly(length));
|
|
@@ -165,8 +206,11 @@ export class AdbServerClient {
|
|
|
165
206
|
}
|
|
166
207
|
}
|
|
167
208
|
|
|
168
|
-
async validateVersion(
|
|
169
|
-
|
|
209
|
+
async validateVersion(
|
|
210
|
+
minimalVersion: number,
|
|
211
|
+
options?: AdbServerClient.ServerConnectionOptions,
|
|
212
|
+
) {
|
|
213
|
+
const version = await this.getVersion(options);
|
|
170
214
|
if (version < minimalVersion) {
|
|
171
215
|
throw new Error(
|
|
172
216
|
`adb server version (${version}) doesn't match this client (${minimalVersion})`,
|
|
@@ -271,13 +315,13 @@ export class AdbServerClient {
|
|
|
271
315
|
"host:features",
|
|
272
316
|
);
|
|
273
317
|
// Luckily `AdbServerClient.Socket` is compatible with `AdbServerClient.ServerConnection`
|
|
274
|
-
const
|
|
318
|
+
const dataConnection = new AdbServerDataConnection(connection);
|
|
275
319
|
try {
|
|
276
|
-
const featuresString = await
|
|
320
|
+
const featuresString = await dataConnection.readString();
|
|
277
321
|
const features = featuresString.split(",") as AdbFeature[];
|
|
278
322
|
return { transportId: connection.transportId, features };
|
|
279
323
|
} finally {
|
|
280
|
-
await
|
|
324
|
+
await dataConnection.dispose();
|
|
281
325
|
}
|
|
282
326
|
}
|
|
283
327
|
|
|
@@ -285,43 +329,40 @@ export class AdbServerClient {
|
|
|
285
329
|
* Creates a connection that will forward the service to device.
|
|
286
330
|
* @param device The device selector
|
|
287
331
|
* @param service The service to forward
|
|
332
|
+
* @param options The server connection options
|
|
288
333
|
* @returns An `AdbServerClient.Socket` that can be used to communicate with the service
|
|
289
334
|
*/
|
|
290
335
|
async createDeviceConnection(
|
|
291
336
|
device: AdbServerClient.DeviceSelector,
|
|
292
337
|
service: string,
|
|
338
|
+
options?: AdbServerClient.ServerConnectionOptions,
|
|
293
339
|
): Promise<AdbServerClient.Socket> {
|
|
294
340
|
let switchService: string;
|
|
295
341
|
let transportId: bigint | undefined;
|
|
296
342
|
if (!device) {
|
|
297
|
-
await this.validateVersion(41);
|
|
343
|
+
await this.validateVersion(41, options);
|
|
298
344
|
switchService = `host:tport:any`;
|
|
299
345
|
} else if ("transportId" in device) {
|
|
300
346
|
switchService = `host:transport-id:${device.transportId}`;
|
|
301
347
|
transportId = device.transportId;
|
|
302
348
|
} else if ("serial" in device) {
|
|
303
|
-
await this.validateVersion(41);
|
|
349
|
+
await this.validateVersion(41, options);
|
|
304
350
|
switchService = `host:tport:serial:${device.serial}`;
|
|
305
351
|
} else if ("usb" in device) {
|
|
306
|
-
await this.validateVersion(41);
|
|
352
|
+
await this.validateVersion(41, options);
|
|
307
353
|
switchService = `host:tport:usb`;
|
|
308
354
|
} else if ("tcp" in device) {
|
|
309
|
-
await this.validateVersion(41);
|
|
355
|
+
await this.validateVersion(41, options);
|
|
310
356
|
switchService = `host:tport:local`;
|
|
311
357
|
} else {
|
|
312
358
|
throw new TypeError("Invalid device selector");
|
|
313
359
|
}
|
|
314
360
|
|
|
315
|
-
const connection = await this.createConnection(switchService);
|
|
361
|
+
const connection = await this.createConnection(switchService, options);
|
|
316
362
|
|
|
317
363
|
try {
|
|
318
364
|
await connection.writeString(service);
|
|
319
|
-
} catch (e) {
|
|
320
|
-
await connection.dispose();
|
|
321
|
-
throw e;
|
|
322
|
-
}
|
|
323
365
|
|
|
324
|
-
try {
|
|
325
366
|
if (transportId === undefined) {
|
|
326
367
|
const array = await connection.readExactly(8);
|
|
327
368
|
transportId = getUint64LittleEndian(array, 0);
|
|
@@ -348,17 +389,14 @@ export class AdbServerClient {
|
|
|
348
389
|
throw e;
|
|
349
390
|
}
|
|
350
391
|
}
|
|
392
|
+
|
|
351
393
|
async #waitForUnchecked(
|
|
352
394
|
device: AdbServerClient.DeviceSelector,
|
|
353
395
|
state: "device" | "disconnect",
|
|
354
396
|
options?: AdbServerClient.ServerConnectionOptions,
|
|
355
397
|
): Promise<void> {
|
|
356
398
|
let type: string;
|
|
357
|
-
if (!device) {
|
|
358
|
-
type = "any";
|
|
359
|
-
} else if ("transportId" in device) {
|
|
360
|
-
type = "any";
|
|
361
|
-
} else if ("serial" in device) {
|
|
399
|
+
if (!device || "transportId" in device || "serial" in device) {
|
|
362
400
|
type = "any";
|
|
363
401
|
} else if ("usb" in device) {
|
|
364
402
|
type = "usb";
|
|
@@ -399,7 +437,7 @@ export class AdbServerClient {
|
|
|
399
437
|
options?: AdbServerClient.ServerConnectionOptions,
|
|
400
438
|
): Promise<void> {
|
|
401
439
|
if (state === "disconnect") {
|
|
402
|
-
await this.validateVersion(41);
|
|
440
|
+
await this.validateVersion(41, options);
|
|
403
441
|
}
|
|
404
442
|
|
|
405
443
|
return this.#waitForUnchecked(device, state, options);
|
|
@@ -409,7 +447,7 @@ export class AdbServerClient {
|
|
|
409
447
|
transportId: bigint,
|
|
410
448
|
options?: AdbServerClient.ServerConnectionOptions,
|
|
411
449
|
): Promise<void> {
|
|
412
|
-
const serverVersion = await this.getVersion();
|
|
450
|
+
const serverVersion = await this.getVersion(options);
|
|
413
451
|
if (serverVersion >= 41) {
|
|
414
452
|
return this.#waitForUnchecked(
|
|
415
453
|
{ transportId },
|
|
@@ -425,12 +463,12 @@ export class AdbServerClient {
|
|
|
425
463
|
(device) => device.transportId === transportId,
|
|
426
464
|
)
|
|
427
465
|
) {
|
|
428
|
-
observer.
|
|
466
|
+
observer.close();
|
|
429
467
|
resolve();
|
|
430
468
|
}
|
|
431
469
|
});
|
|
432
470
|
observer.onError((e) => {
|
|
433
|
-
observer.
|
|
471
|
+
observer.close();
|
|
434
472
|
reject(e);
|
|
435
473
|
});
|
|
436
474
|
});
|
|
@@ -483,37 +521,6 @@ export class AdbServerClient {
|
|
|
483
521
|
}
|
|
484
522
|
}
|
|
485
523
|
|
|
486
|
-
export async function raceSignal<T>(
|
|
487
|
-
callback: () => PromiseLike<T>,
|
|
488
|
-
...signals: (AbortSignal | undefined)[]
|
|
489
|
-
): Promise<T> {
|
|
490
|
-
const abortPromise = new PromiseResolver<never>();
|
|
491
|
-
function abort(this: AbortSignal) {
|
|
492
|
-
abortPromise.reject(this.reason);
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
try {
|
|
496
|
-
for (const signal of signals) {
|
|
497
|
-
if (!signal) {
|
|
498
|
-
continue;
|
|
499
|
-
}
|
|
500
|
-
if (signal.aborted) {
|
|
501
|
-
throw signal.reason;
|
|
502
|
-
}
|
|
503
|
-
signal.addEventListener("abort", abort);
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
return await Promise.race([callback(), abortPromise.promise]);
|
|
507
|
-
} finally {
|
|
508
|
-
for (const signal of signals) {
|
|
509
|
-
if (!signal) {
|
|
510
|
-
continue;
|
|
511
|
-
}
|
|
512
|
-
signal.removeEventListener("abort", abort);
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
|
|
517
524
|
export namespace AdbServerClient {
|
|
518
525
|
export interface ServerConnectionOptions {
|
|
519
526
|
unref?: boolean | undefined;
|
|
@@ -533,7 +540,7 @@ export namespace AdbServerClient {
|
|
|
533
540
|
): MaybePromiseLike<ServerConnection>;
|
|
534
541
|
|
|
535
542
|
addReverseTunnel(
|
|
536
|
-
handler:
|
|
543
|
+
handler: Adb.IncomingSocketHandler,
|
|
537
544
|
address?: string,
|
|
538
545
|
): MaybePromiseLike<string>;
|
|
539
546
|
|
|
@@ -542,7 +549,7 @@ export namespace AdbServerClient {
|
|
|
542
549
|
clearReverseTunnels(): MaybePromiseLike<void>;
|
|
543
550
|
}
|
|
544
551
|
|
|
545
|
-
export interface Socket extends
|
|
552
|
+
export interface Socket extends Adb.Socket {
|
|
546
553
|
transportId: bigint;
|
|
547
554
|
}
|
|
548
555
|
|
|
@@ -556,7 +563,8 @@ export namespace AdbServerClient {
|
|
|
556
563
|
| { tcp: true }
|
|
557
564
|
| undefined;
|
|
558
565
|
|
|
559
|
-
export type ConnectionState =
|
|
566
|
+
export type ConnectionState =
|
|
567
|
+
(typeof AdbServerClient.ConnectionState)[number];
|
|
560
568
|
|
|
561
569
|
export interface Device {
|
|
562
570
|
serial: string;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { hexToNumber, sequenceEqual } from "../../utils/index.js";
|
|
4
4
|
import type { AdbServerClient } from "../client.js";
|
|
5
|
-
import { FAIL } from "../
|
|
5
|
+
import { FAIL } from "../data-connection.js";
|
|
6
6
|
|
|
7
7
|
export class NetworkError extends Error {
|
|
8
8
|
constructor(message: string) {
|
|
@@ -19,7 +19,7 @@ import type { AdbServerClient } from "./client.js";
|
|
|
19
19
|
const OKAY = encodeUtf8("OKAY");
|
|
20
20
|
export const FAIL = encodeUtf8("FAIL");
|
|
21
21
|
|
|
22
|
-
export class
|
|
22
|
+
export class AdbServerDataConnection {
|
|
23
23
|
#connection: AdbServerClient.ServerConnection;
|
|
24
24
|
#buffered: BufferedReadableStream;
|
|
25
25
|
#writer: WritableStreamDefaultWriter<Uint8Array>;
|
|
@@ -34,7 +34,7 @@ export class AdbServerStream {
|
|
|
34
34
|
return this.#buffered.readExactly(length);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
readString = bipedal(function* (this:
|
|
37
|
+
readString = bipedal(function* (this: AdbServerDataConnection, then) {
|
|
38
38
|
const data = yield* then(this.readExactly(4));
|
|
39
39
|
const length = hexToNumber(data);
|
|
40
40
|
if (length === 0) {
|
|
@@ -93,8 +93,8 @@ export class AdbServerStream {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
async dispose() {
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
await tryCancel(this.#buffered);
|
|
97
|
+
await tryClose(this.#writer);
|
|
98
98
|
await this.#connection.close();
|
|
99
99
|
}
|
|
100
100
|
}
|
package/src/server/index.ts
CHANGED
package/src/server/observer.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { EventEmitter, StickyEventEmitter } from "@yume-chan/event";
|
|
|
3
3
|
import { Ref } from "../utils/index.js";
|
|
4
4
|
|
|
5
5
|
import { AdbServerClient } from "./client.js";
|
|
6
|
-
import type {
|
|
6
|
+
import type { AdbServerDataConnection } from "./data-connection.js";
|
|
7
7
|
|
|
8
8
|
export function unorderedRemove<T>(array: T[], index: number) {
|
|
9
9
|
if (index < 0 || index >= array.length) {
|
|
@@ -33,14 +33,14 @@ export class AdbServerDeviceObserverOwner {
|
|
|
33
33
|
|
|
34
34
|
readonly #client: AdbServerClient;
|
|
35
35
|
|
|
36
|
-
#stream: Promise<
|
|
36
|
+
#stream: Promise<AdbServerDataConnection> | undefined;
|
|
37
37
|
#observers: Observer[] = [];
|
|
38
38
|
|
|
39
39
|
constructor(client: AdbServerClient) {
|
|
40
40
|
this.#client = client;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
async #receive(stream:
|
|
43
|
+
async #receive(stream: AdbServerDataConnection) {
|
|
44
44
|
const response = await stream.readString();
|
|
45
45
|
const next = AdbServerClient.parseDeviceList(response);
|
|
46
46
|
|
|
@@ -93,7 +93,7 @@ export class AdbServerDeviceObserverOwner {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
async #receiveLoop(stream:
|
|
96
|
+
async #receiveLoop(stream: AdbServerDataConnection) {
|
|
97
97
|
try {
|
|
98
98
|
while (true) {
|
|
99
99
|
await this.#receive(stream);
|
|
@@ -123,10 +123,10 @@ export class AdbServerDeviceObserverOwner {
|
|
|
123
123
|
return stream;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
async #
|
|
126
|
+
async #handleObserverClose(connection: AdbServerDataConnection) {
|
|
127
127
|
if (this.#observers.length === 0) {
|
|
128
128
|
this.#stream = undefined;
|
|
129
|
-
await
|
|
129
|
+
await connection.dispose();
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
|
|
@@ -135,7 +135,6 @@ export class AdbServerDeviceObserverOwner {
|
|
|
135
135
|
): Promise<AdbServerClient.DeviceObserver> {
|
|
136
136
|
options?.signal?.throwIfAborted();
|
|
137
137
|
|
|
138
|
-
let current: readonly AdbServerClient.Device[] = [];
|
|
139
138
|
const onDeviceAdd = new EventEmitter<
|
|
140
139
|
readonly AdbServerClient.Device[]
|
|
141
140
|
>();
|
|
@@ -162,12 +161,9 @@ export class AdbServerDeviceObserverOwner {
|
|
|
162
161
|
// So `#handleObserverStop` knows if there is any observer.
|
|
163
162
|
this.#observers.push(observer);
|
|
164
163
|
|
|
165
|
-
|
|
166
|
-
onListChange.event((value) => (current = value));
|
|
167
|
-
|
|
168
|
-
let stream: AdbServerStream;
|
|
164
|
+
let stream: AdbServerDataConnection;
|
|
169
165
|
if (!this.#stream) {
|
|
170
|
-
// `#connect` will initialize `onListChange`
|
|
166
|
+
// `#connect` will initialize `onListChange`
|
|
171
167
|
this.#stream = this.#connect();
|
|
172
168
|
|
|
173
169
|
try {
|
|
@@ -178,25 +174,31 @@ export class AdbServerDeviceObserverOwner {
|
|
|
178
174
|
}
|
|
179
175
|
} else {
|
|
180
176
|
stream = await this.#stream;
|
|
181
|
-
// Initialize `onListChange`
|
|
177
|
+
// Initialize `onListChange` ourselves
|
|
182
178
|
onListChange.fire(filterDeviceStates(this.current, includeStates));
|
|
183
179
|
}
|
|
184
180
|
|
|
185
181
|
const ref = new Ref(options);
|
|
186
182
|
|
|
187
|
-
const
|
|
183
|
+
const close = async () => {
|
|
184
|
+
onDeviceAdd.dispose();
|
|
185
|
+
onDeviceRemove.dispose();
|
|
186
|
+
onListChange.dispose();
|
|
187
|
+
onError.dispose();
|
|
188
|
+
|
|
188
189
|
unorderedRemove(this.#observers, this.#observers.indexOf(observer));
|
|
189
|
-
await this.#
|
|
190
|
+
await this.#handleObserverClose(stream);
|
|
191
|
+
|
|
190
192
|
ref.unref();
|
|
191
193
|
};
|
|
192
194
|
|
|
193
195
|
if (options?.signal) {
|
|
194
196
|
if (options.signal.aborted) {
|
|
195
|
-
await
|
|
197
|
+
await close();
|
|
196
198
|
throw options.signal.reason;
|
|
197
199
|
}
|
|
198
200
|
|
|
199
|
-
options.signal.addEventListener("abort", () => void
|
|
201
|
+
options.signal.addEventListener("abort", () => void close());
|
|
200
202
|
}
|
|
201
203
|
|
|
202
204
|
return {
|
|
@@ -205,9 +207,9 @@ export class AdbServerDeviceObserverOwner {
|
|
|
205
207
|
onListChange: onListChange.event,
|
|
206
208
|
onError: onError.event,
|
|
207
209
|
get current() {
|
|
208
|
-
return
|
|
210
|
+
return onListChange.value;
|
|
209
211
|
},
|
|
210
|
-
|
|
212
|
+
close,
|
|
211
213
|
};
|
|
212
214
|
}
|
|
213
215
|
}
|