@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
package/src/server/transport.ts
CHANGED
|
@@ -1,37 +1,11 @@
|
|
|
1
1
|
import { PromiseResolver } from "@yume-chan/async";
|
|
2
2
|
|
|
3
|
-
import type {
|
|
4
|
-
AdbIncomingSocketHandler,
|
|
5
|
-
AdbSocket,
|
|
6
|
-
AdbTransport,
|
|
7
|
-
} from "../adb.js";
|
|
3
|
+
import type { Adb, AdbTransport } from "../adb.js";
|
|
8
4
|
import type { AdbBanner } from "../banner.js";
|
|
9
|
-
import {
|
|
5
|
+
import { AdbDeviceFeatures } from "../features.js";
|
|
10
6
|
|
|
11
7
|
import type { AdbServerClient } from "./client.js";
|
|
12
8
|
|
|
13
|
-
export const ADB_SERVER_DEFAULT_FEATURES = /* #__PURE__ */ (() =>
|
|
14
|
-
[
|
|
15
|
-
AdbFeature.ShellV2,
|
|
16
|
-
AdbFeature.Cmd,
|
|
17
|
-
AdbFeature.StatV2,
|
|
18
|
-
AdbFeature.ListV2,
|
|
19
|
-
AdbFeature.FixedPushMkdir,
|
|
20
|
-
"apex",
|
|
21
|
-
AdbFeature.Abb,
|
|
22
|
-
// only tells the client the symlink timestamp issue in `adb push --sync` has been fixed.
|
|
23
|
-
// No special handling required.
|
|
24
|
-
"fixed_push_symlink_timestamp",
|
|
25
|
-
AdbFeature.AbbExec,
|
|
26
|
-
"remount_shell",
|
|
27
|
-
"track_app",
|
|
28
|
-
AdbFeature.SendReceiveV2,
|
|
29
|
-
"sendrecv_v2_brotli",
|
|
30
|
-
"sendrecv_v2_lz4",
|
|
31
|
-
"sendrecv_v2_zstd",
|
|
32
|
-
"sendrecv_v2_dry_run_send",
|
|
33
|
-
] as readonly AdbFeature[])();
|
|
34
|
-
|
|
35
9
|
export class AdbServerTransport implements AdbTransport {
|
|
36
10
|
#client: AdbServerClient;
|
|
37
11
|
|
|
@@ -43,7 +17,7 @@ export class AdbServerTransport implements AdbTransport {
|
|
|
43
17
|
|
|
44
18
|
readonly banner: AdbBanner;
|
|
45
19
|
|
|
46
|
-
#sockets:
|
|
20
|
+
#sockets: Adb.Socket[] = [];
|
|
47
21
|
|
|
48
22
|
#closed = new PromiseResolver<void>();
|
|
49
23
|
#disconnected: Promise<void>;
|
|
@@ -52,9 +26,14 @@ export class AdbServerTransport implements AdbTransport {
|
|
|
52
26
|
}
|
|
53
27
|
|
|
54
28
|
get clientFeatures() {
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
|
|
29
|
+
// This list tells the `Adb` instance how to invoke some commands.
|
|
30
|
+
//
|
|
31
|
+
// Because all device commands are created by the `Adb` instance, not ADB server,
|
|
32
|
+
// we don't need to fetch current server's feature list using `host-features` command.
|
|
33
|
+
//
|
|
34
|
+
// And because all server commands are created by the `AdbServerClient` instance, not `Adb`,
|
|
35
|
+
// we don't need to pass server-only features to `Adb` in this list.
|
|
36
|
+
return AdbDeviceFeatures;
|
|
58
37
|
}
|
|
59
38
|
|
|
60
39
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
@@ -73,7 +52,7 @@ export class AdbServerTransport implements AdbTransport {
|
|
|
73
52
|
this.#disconnected = Promise.race([this.#closed.promise, disconnected]);
|
|
74
53
|
}
|
|
75
54
|
|
|
76
|
-
async connect(service: string): Promise<
|
|
55
|
+
async connect(service: string): Promise<Adb.Socket> {
|
|
77
56
|
const socket = await this.#client.createDeviceConnection(
|
|
78
57
|
{ transportId: this.transportId },
|
|
79
58
|
service,
|
|
@@ -83,7 +62,7 @@ export class AdbServerTransport implements AdbTransport {
|
|
|
83
62
|
}
|
|
84
63
|
|
|
85
64
|
async addReverseTunnel(
|
|
86
|
-
handler:
|
|
65
|
+
handler: Adb.IncomingSocketHandler,
|
|
87
66
|
address?: string,
|
|
88
67
|
): Promise<string> {
|
|
89
68
|
return await this.#client.connector.addReverseTunnel(handler, address);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export * from "./base.js";
|
|
2
1
|
export * from "./framebuffer.js";
|
|
3
2
|
export * from "./power.js";
|
|
4
|
-
export * from "./reverse.js";
|
|
3
|
+
export * from "./reverse/index.js";
|
|
5
4
|
export * from "./subprocess/index.js";
|
|
6
5
|
export * from "./sync/index.js";
|
|
7
6
|
export * from "./tcpip.js";
|
|
@@ -3,11 +3,17 @@
|
|
|
3
3
|
// cspell: ignore keyevent
|
|
4
4
|
// cspell: ignore longpress
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import type { Adb } from "../adb.js";
|
|
7
|
+
|
|
8
|
+
export class AdbPowerService {
|
|
9
|
+
readonly #adb: Adb;
|
|
10
|
+
|
|
11
|
+
constructor(adb: Adb) {
|
|
12
|
+
this.#adb = adb;
|
|
13
|
+
}
|
|
7
14
|
|
|
8
|
-
export class AdbPower extends AdbServiceBase {
|
|
9
15
|
reboot(mode = "") {
|
|
10
|
-
return this
|
|
16
|
+
return this.#adb.createSocketAndWait(`reboot:${mode}`);
|
|
11
17
|
}
|
|
12
18
|
|
|
13
19
|
bootloader() {
|
|
@@ -36,7 +42,10 @@ export class AdbPower extends AdbServiceBase {
|
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
powerOff(): Promise<string> {
|
|
39
|
-
return this
|
|
45
|
+
return this.#adb.subprocess.noneProtocol
|
|
46
|
+
.spawn(["reboot", "-p"])
|
|
47
|
+
.wait()
|
|
48
|
+
.toString();
|
|
40
49
|
}
|
|
41
50
|
|
|
42
51
|
powerButton(longPress = false): Promise<string> {
|
|
@@ -46,7 +55,7 @@ export class AdbPower extends AdbServiceBase {
|
|
|
46
55
|
}
|
|
47
56
|
args.push("POWER");
|
|
48
57
|
|
|
49
|
-
return this
|
|
58
|
+
return this.#adb.subprocess.noneProtocol.spawn(args).wait().toString();
|
|
50
59
|
}
|
|
51
60
|
|
|
52
61
|
/**
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const AdbReverseErrorBrand = Symbol.for("AdbReverseError.brand");
|
|
2
|
+
|
|
3
|
+
export class AdbReverseError extends Error {
|
|
4
|
+
[AdbReverseErrorBrand] = true;
|
|
5
|
+
|
|
6
|
+
static override [Symbol.hasInstance](value: unknown) {
|
|
7
|
+
return !!(value as AdbReverseNotSupportedError | undefined)?.[
|
|
8
|
+
AdbReverseErrorBrand
|
|
9
|
+
];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
constructor(message: string) {
|
|
13
|
+
super(message);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const AdbReverseNotSupportedErrorBrand = Symbol.for(
|
|
18
|
+
"AdbReverseNotSupportedError.brand",
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export class AdbReverseNotSupportedError extends AdbReverseError {
|
|
22
|
+
[AdbReverseNotSupportedErrorBrand] = true;
|
|
23
|
+
|
|
24
|
+
static override [Symbol.hasInstance](value: unknown) {
|
|
25
|
+
return !!(value as AdbReverseNotSupportedError | undefined)?.[
|
|
26
|
+
AdbReverseNotSupportedErrorBrand
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
constructor() {
|
|
31
|
+
super(
|
|
32
|
+
"ADB reverse tunnel is not supported on this device when connected wirelessly.",
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { extend, string, struct } from "@yume-chan/struct";
|
|
2
|
+
|
|
3
|
+
import { AdbReverseError, AdbReverseNotSupportedError } from "./error.js";
|
|
4
|
+
|
|
5
|
+
/** @internal exported for tests */
|
|
6
|
+
export const AdbReverseStringResponse = struct(
|
|
7
|
+
{
|
|
8
|
+
length: string(4),
|
|
9
|
+
content: string({
|
|
10
|
+
field: "length",
|
|
11
|
+
convert(value: string) {
|
|
12
|
+
return Number.parseInt(value, 16);
|
|
13
|
+
},
|
|
14
|
+
back(value) {
|
|
15
|
+
return value.toString(16).padStart(4, "0");
|
|
16
|
+
},
|
|
17
|
+
}),
|
|
18
|
+
},
|
|
19
|
+
{ littleEndian: true },
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
/** @internal exported for tests */
|
|
23
|
+
export const AdbReverseErrorResponse = extend(
|
|
24
|
+
AdbReverseStringResponse,
|
|
25
|
+
{},
|
|
26
|
+
{
|
|
27
|
+
postDeserialize(value) {
|
|
28
|
+
// https://issuetracker.google.com/issues/37066218
|
|
29
|
+
// ADB on Android <9 can't create reverse tunnels when connected wirelessly (ADB over Wi-Fi),
|
|
30
|
+
// and returns this confusing "more than one device/emulator" error.
|
|
31
|
+
if (value.content === "more than one device/emulator") {
|
|
32
|
+
throw new AdbReverseNotSupportedError();
|
|
33
|
+
} else {
|
|
34
|
+
throw new AdbReverseError(value.content);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
);
|
|
@@ -1,73 +1,15 @@
|
|
|
1
1
|
// cspell: ignore killforward
|
|
2
2
|
|
|
3
3
|
import { BufferedReadableStream } from "@yume-chan/stream-extra";
|
|
4
|
-
import {
|
|
5
|
-
encodeUtf8,
|
|
6
|
-
ExactReadableEndedError,
|
|
7
|
-
extend,
|
|
8
|
-
string,
|
|
9
|
-
struct,
|
|
10
|
-
} from "@yume-chan/struct";
|
|
11
|
-
|
|
12
|
-
import type { AdbIncomingSocketHandler } from "../adb.js";
|
|
13
|
-
import { hexToNumber, sequenceEqual } from "../utils/index.js";
|
|
14
|
-
|
|
15
|
-
import { AdbServiceBase } from "./base.js";
|
|
16
|
-
|
|
17
|
-
export interface AdbForwardListener {
|
|
18
|
-
deviceSerial: string;
|
|
19
|
-
|
|
20
|
-
localName: string;
|
|
21
|
-
|
|
22
|
-
remoteName: string;
|
|
23
|
-
}
|
|
4
|
+
import { encodeUtf8, ExactReadableEndedError } from "@yume-chan/struct";
|
|
24
5
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
length: string(4),
|
|
28
|
-
content: string({
|
|
29
|
-
field: "length",
|
|
30
|
-
convert(value: string) {
|
|
31
|
-
return Number.parseInt(value, 16);
|
|
32
|
-
},
|
|
33
|
-
back(value) {
|
|
34
|
-
return value.toString(16).padStart(4, "0");
|
|
35
|
-
},
|
|
36
|
-
}),
|
|
37
|
-
},
|
|
38
|
-
{ littleEndian: true },
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
export class AdbReverseError extends Error {
|
|
42
|
-
constructor(message: string) {
|
|
43
|
-
super(message);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
6
|
+
import type { Adb } from "../../adb.js";
|
|
7
|
+
import { hexToNumber, sequenceEqual } from "../../utils/index.js";
|
|
46
8
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
super(
|
|
50
|
-
"ADB reverse tunnel is not supported on this device when connected wirelessly.",
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export const AdbReverseErrorResponse = extend(
|
|
9
|
+
import {
|
|
10
|
+
AdbReverseErrorResponse,
|
|
56
11
|
AdbReverseStringResponse,
|
|
57
|
-
|
|
58
|
-
{
|
|
59
|
-
postDeserialize(value) {
|
|
60
|
-
// https://issuetracker.google.com/issues/37066218
|
|
61
|
-
// ADB on Android <9 can't create reverse tunnels when connected wirelessly (ADB over Wi-Fi),
|
|
62
|
-
// and returns this confusing "more than one device/emulator" error.
|
|
63
|
-
if (value.content === "more than one device/emulator") {
|
|
64
|
-
throw new AdbReverseNotSupportedError();
|
|
65
|
-
} else {
|
|
66
|
-
throw new AdbReverseError(value.content);
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
);
|
|
12
|
+
} from "./response.js";
|
|
71
13
|
|
|
72
14
|
// Like `hexToNumber`, it's much faster than first converting `buffer` to a string
|
|
73
15
|
function decimalToNumber(buffer: Uint8Array) {
|
|
@@ -84,11 +26,21 @@ function decimalToNumber(buffer: Uint8Array) {
|
|
|
84
26
|
|
|
85
27
|
const OKAY = encodeUtf8("OKAY");
|
|
86
28
|
|
|
87
|
-
export class AdbReverseService
|
|
29
|
+
export class AdbReverseService {
|
|
30
|
+
static readonly StringResponse = AdbReverseStringResponse;
|
|
31
|
+
|
|
32
|
+
static readonly ErrorResponse = AdbReverseErrorResponse;
|
|
33
|
+
|
|
34
|
+
readonly #adb: Adb;
|
|
35
|
+
|
|
36
|
+
constructor(adb: Adb) {
|
|
37
|
+
this.#adb = adb;
|
|
38
|
+
}
|
|
39
|
+
|
|
88
40
|
readonly #deviceAddressToLocalAddress = new Map<string, string>();
|
|
89
41
|
|
|
90
42
|
protected async createBufferedStream(service: string) {
|
|
91
|
-
const socket = await this
|
|
43
|
+
const socket = await this.#adb.createSocket(service);
|
|
92
44
|
return new BufferedReadableStream(socket.readable);
|
|
93
45
|
}
|
|
94
46
|
|
|
@@ -106,7 +58,7 @@ export class AdbReverseService extends AdbServiceBase {
|
|
|
106
58
|
/**
|
|
107
59
|
* Get a list of all reverse port forwarding on the device.
|
|
108
60
|
*/
|
|
109
|
-
async list(): Promise<
|
|
61
|
+
async list(): Promise<AdbReverseService.Listener[]> {
|
|
110
62
|
const stream = await this.createBufferedStream("reverse:list-forward");
|
|
111
63
|
|
|
112
64
|
const response = await AdbReverseStringResponse.deserialize(stream);
|
|
@@ -161,10 +113,10 @@ export class AdbReverseService extends AdbServiceBase {
|
|
|
161
113
|
*/
|
|
162
114
|
async add(
|
|
163
115
|
deviceAddress: string,
|
|
164
|
-
handler:
|
|
116
|
+
handler: Adb.IncomingSocketHandler,
|
|
165
117
|
localAddress?: string,
|
|
166
118
|
): Promise<string> {
|
|
167
|
-
localAddress = await this
|
|
119
|
+
localAddress = await this.#adb.transport.addReverseTunnel(
|
|
168
120
|
handler,
|
|
169
121
|
localAddress,
|
|
170
122
|
);
|
|
@@ -174,7 +126,7 @@ export class AdbReverseService extends AdbServiceBase {
|
|
|
174
126
|
this.#deviceAddressToLocalAddress.set(deviceAddress, localAddress);
|
|
175
127
|
return deviceAddress;
|
|
176
128
|
} catch (e) {
|
|
177
|
-
await this
|
|
129
|
+
await this.#adb.transport.removeReverseTunnel(localAddress);
|
|
178
130
|
throw e;
|
|
179
131
|
}
|
|
180
132
|
}
|
|
@@ -186,7 +138,7 @@ export class AdbReverseService extends AdbServiceBase {
|
|
|
186
138
|
const localAddress =
|
|
187
139
|
this.#deviceAddressToLocalAddress.get(deviceAddress);
|
|
188
140
|
if (localAddress) {
|
|
189
|
-
await this
|
|
141
|
+
await this.#adb.transport.removeReverseTunnel(localAddress);
|
|
190
142
|
}
|
|
191
143
|
|
|
192
144
|
await this.sendRequest(`reverse:killforward:${deviceAddress}`);
|
|
@@ -198,7 +150,7 @@ export class AdbReverseService extends AdbServiceBase {
|
|
|
198
150
|
* Remove all reverse port forwarding, including the ones added by other programs.
|
|
199
151
|
*/
|
|
200
152
|
async removeAll(): Promise<void> {
|
|
201
|
-
await this
|
|
153
|
+
await this.#adb.transport.clearReverseTunnels();
|
|
202
154
|
this.#deviceAddressToLocalAddress.clear();
|
|
203
155
|
|
|
204
156
|
await this.sendRequest(`reverse:killforward-all`);
|
|
@@ -206,3 +158,11 @@ export class AdbReverseService extends AdbServiceBase {
|
|
|
206
158
|
// No need to close the stream, device will close it
|
|
207
159
|
}
|
|
208
160
|
}
|
|
161
|
+
|
|
162
|
+
export namespace AdbReverseService {
|
|
163
|
+
export interface Listener {
|
|
164
|
+
deviceSerial: string;
|
|
165
|
+
localName: string;
|
|
166
|
+
remoteName: string;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -7,12 +7,12 @@ import type {
|
|
|
7
7
|
WritableStream,
|
|
8
8
|
} from "@yume-chan/stream-extra";
|
|
9
9
|
|
|
10
|
-
import type {
|
|
10
|
+
import type { Adb } from "../../../adb.js";
|
|
11
11
|
|
|
12
12
|
import type { AdbNoneProtocolProcess } from "./spawner.js";
|
|
13
13
|
|
|
14
14
|
export class AdbNoneProtocolProcessImpl implements AdbNoneProtocolProcess {
|
|
15
|
-
readonly #socket:
|
|
15
|
+
readonly #socket: Adb.Socket;
|
|
16
16
|
|
|
17
17
|
get stdin(): WritableStream<MaybeConsumable<Uint8Array>> {
|
|
18
18
|
return this.#socket.writable;
|
|
@@ -27,7 +27,7 @@ export class AdbNoneProtocolProcessImpl implements AdbNoneProtocolProcess {
|
|
|
27
27
|
return this.#exited;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
constructor(socket:
|
|
30
|
+
constructor(socket: Adb.Socket, signal?: AbortSignal) {
|
|
31
31
|
this.#socket = socket;
|
|
32
32
|
|
|
33
33
|
if (signal) {
|
|
@@ -6,11 +6,11 @@ import type {
|
|
|
6
6
|
} from "@yume-chan/stream-extra";
|
|
7
7
|
import { MaybeConsumable } from "@yume-chan/stream-extra";
|
|
8
8
|
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
9
|
+
import type { Adb } from "../../../adb.js";
|
|
10
|
+
import type { AdbPty } from "../pty.js";
|
|
11
11
|
|
|
12
|
-
export class
|
|
13
|
-
readonly #socket:
|
|
12
|
+
export class AdbNoneProtocolPty implements AdbPty<undefined> {
|
|
13
|
+
readonly #socket: Adb.Socket;
|
|
14
14
|
readonly #writer: WritableStreamDefaultWriter<MaybeConsumable<Uint8Array>>;
|
|
15
15
|
|
|
16
16
|
readonly #input: MaybeConsumable.WritableStream<Uint8Array>;
|
|
@@ -26,7 +26,7 @@ export class AdbNoneProtocolPtyProcess implements AdbPtyProcess<undefined> {
|
|
|
26
26
|
return this.#socket.closed;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
constructor(socket:
|
|
29
|
+
constructor(socket: Adb.Socket) {
|
|
30
30
|
this.#socket = socket;
|
|
31
31
|
|
|
32
32
|
this.#writer = this.#socket.writable.getWriter();
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Adb } from "../../../adb.js";
|
|
2
|
+
|
|
3
|
+
import { AdbNoneProtocolProcessImpl } from "./process.js";
|
|
4
|
+
import { AdbNoneProtocolPty } from "./pty.js";
|
|
5
|
+
import { adbNoneProtocolSpawner } from "./spawner.js";
|
|
6
|
+
|
|
7
|
+
export class AdbNoneProtocolSubprocessService {
|
|
8
|
+
readonly #adb: Adb;
|
|
9
|
+
get adb(): Adb {
|
|
10
|
+
return this.#adb;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
constructor(adb: Adb) {
|
|
14
|
+
this.#adb = adb;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
spawn = adbNoneProtocolSpawner(async (command, signal) => {
|
|
18
|
+
if (!command.length) {
|
|
19
|
+
throw new Error("Command cannot be empty");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Android 7 added `shell,raw:${command}` service which also triggers raw mode,
|
|
23
|
+
// but we want to keep backward compatibility.
|
|
24
|
+
let service = "exec:";
|
|
25
|
+
|
|
26
|
+
// Similar to SSH, we don't escape the `command`,
|
|
27
|
+
// because the command will be invoked by `sh -c`,
|
|
28
|
+
// it can contain environment variables (`KEY=value command`),
|
|
29
|
+
// and shell expansions (`echo "$KEY"` vs `echo '$KEY'`),
|
|
30
|
+
// which we can't know how to properly escape.
|
|
31
|
+
service += command.join(" ");
|
|
32
|
+
|
|
33
|
+
const socket = await this.#adb.createSocket(service);
|
|
34
|
+
|
|
35
|
+
if (signal?.aborted) {
|
|
36
|
+
await socket.close();
|
|
37
|
+
throw signal.reason;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return new AdbNoneProtocolProcessImpl(socket, signal);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
async pty(
|
|
44
|
+
command?: string | readonly string[],
|
|
45
|
+
): Promise<AdbNoneProtocolPty> {
|
|
46
|
+
let service = "shell:";
|
|
47
|
+
|
|
48
|
+
if (typeof command === "string") {
|
|
49
|
+
service += command;
|
|
50
|
+
} else if (Array.isArray(command)) {
|
|
51
|
+
// Don't escape `command`. See `spawn` above for details
|
|
52
|
+
service += command.join(" ");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return new AdbNoneProtocolPty(await this.#adb.createSocket(service));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { MaybePromiseLike } from "@yume-chan/async";
|
|
2
|
+
import type {
|
|
3
|
+
AbortSignal,
|
|
4
|
+
MaybeConsumable,
|
|
5
|
+
ReadableStream,
|
|
6
|
+
WritableStream,
|
|
7
|
+
} from "@yume-chan/stream-extra";
|
|
8
|
+
import { concatUint8Arrays } from "@yume-chan/stream-extra";
|
|
9
|
+
|
|
10
|
+
import type { AdbSubprocessSpawner } from "../types.js";
|
|
11
|
+
import {
|
|
12
|
+
createLazyPromise,
|
|
13
|
+
decodeUtf8Chunked,
|
|
14
|
+
splitCommand,
|
|
15
|
+
ToArrayStream,
|
|
16
|
+
} from "../utils.js";
|
|
17
|
+
|
|
18
|
+
export interface AdbNoneProtocolProcess {
|
|
19
|
+
get stdin(): WritableStream<MaybeConsumable<Uint8Array>>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Mix of stdout and stderr
|
|
23
|
+
*/
|
|
24
|
+
get output(): ReadableStream<Uint8Array>;
|
|
25
|
+
|
|
26
|
+
get exited(): Promise<void>;
|
|
27
|
+
|
|
28
|
+
kill(): MaybePromiseLike<void>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type AdbNoneProtocolSpawner = (
|
|
32
|
+
command: string | readonly string[],
|
|
33
|
+
signal?: AbortSignal,
|
|
34
|
+
) => Promise<AdbNoneProtocolProcess> &
|
|
35
|
+
AdbSubprocessSpawner.Wait<Uint8Array, string>;
|
|
36
|
+
|
|
37
|
+
export function adbNoneProtocolSpawner(
|
|
38
|
+
spawn: (
|
|
39
|
+
command: readonly string[],
|
|
40
|
+
signal: AbortSignal | undefined,
|
|
41
|
+
) => Promise<AdbNoneProtocolProcess>,
|
|
42
|
+
): AdbNoneProtocolSpawner {
|
|
43
|
+
return (command, signal) => {
|
|
44
|
+
signal?.throwIfAborted();
|
|
45
|
+
|
|
46
|
+
if (typeof command === "string") {
|
|
47
|
+
command = splitCommand(command);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const processPromise = spawn(
|
|
51
|
+
command,
|
|
52
|
+
signal,
|
|
53
|
+
) as Promise<AdbNoneProtocolProcess> &
|
|
54
|
+
AdbSubprocessSpawner.Wait<Uint8Array, string>;
|
|
55
|
+
|
|
56
|
+
processPromise.wait = (options) => {
|
|
57
|
+
const waitPromise = processPromise.then(async (process) => {
|
|
58
|
+
try {
|
|
59
|
+
const [, output] = await Promise.all([
|
|
60
|
+
options?.stdin?.pipeTo(process.stdin),
|
|
61
|
+
process.output.pipeThrough(new ToArrayStream()),
|
|
62
|
+
]);
|
|
63
|
+
return output;
|
|
64
|
+
} finally {
|
|
65
|
+
await process.kill();
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
return createLazyPromise(
|
|
70
|
+
async () => {
|
|
71
|
+
const chunks = await waitPromise;
|
|
72
|
+
return concatUint8Arrays(chunks);
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
async toString() {
|
|
76
|
+
const chunks = await waitPromise;
|
|
77
|
+
return decodeUtf8Chunked(chunks);
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return processPromise;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
@@ -5,7 +5,7 @@ import type {
|
|
|
5
5
|
WritableStream,
|
|
6
6
|
} from "@yume-chan/stream-extra";
|
|
7
7
|
|
|
8
|
-
export interface
|
|
8
|
+
export interface AdbPty<TExitCode> {
|
|
9
9
|
get input(): WritableStream<MaybeConsumable<Uint8Array>>;
|
|
10
10
|
get output(): ReadableStream<Uint8Array>;
|
|
11
11
|
get exited(): Promise<TExitCode>;
|
|
@@ -25,7 +25,7 @@ export class AdbSubprocessService {
|
|
|
25
25
|
|
|
26
26
|
this.#noneProtocol = new AdbNoneProtocolSubprocessService(adb);
|
|
27
27
|
|
|
28
|
-
if (adb.canUseFeature(AdbFeature.
|
|
28
|
+
if (adb.canUseFeature(AdbFeature.Shell2)) {
|
|
29
29
|
this.#shellProtocol = new AdbShellProtocolSubprocessService(adb);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -14,13 +14,13 @@ import {
|
|
|
14
14
|
} from "@yume-chan/stream-extra";
|
|
15
15
|
import { EmptyUint8Array } from "@yume-chan/struct";
|
|
16
16
|
|
|
17
|
-
import type {
|
|
17
|
+
import type { Adb } from "../../../adb.js";
|
|
18
18
|
|
|
19
19
|
import { AdbShellProtocolId, AdbShellProtocolPacket } from "./shared.js";
|
|
20
20
|
import type { AdbShellProtocolProcess } from "./spawner.js";
|
|
21
21
|
|
|
22
22
|
export class AdbShellProtocolProcessImpl implements AdbShellProtocolProcess {
|
|
23
|
-
readonly #socket:
|
|
23
|
+
readonly #socket: Adb.Socket;
|
|
24
24
|
readonly #writer: WritableStreamDefaultWriter<MaybeConsumable<Uint8Array>>;
|
|
25
25
|
|
|
26
26
|
readonly #stdin: WritableStream<MaybeConsumable<Uint8Array>>;
|
|
@@ -43,7 +43,7 @@ export class AdbShellProtocolProcessImpl implements AdbShellProtocolProcess {
|
|
|
43
43
|
return this.#exited;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
constructor(socket:
|
|
46
|
+
constructor(socket: Adb.Socket, signal?: AbortSignal) {
|
|
47
47
|
this.#socket = socket;
|
|
48
48
|
|
|
49
49
|
let stdoutController!: PushReadableStreamController<Uint8Array>;
|
|
@@ -98,27 +98,23 @@ export class AdbShellProtocolProcessImpl implements AdbShellProtocolProcess {
|
|
|
98
98
|
},
|
|
99
99
|
);
|
|
100
100
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
this.#socket.close();
|
|
109
|
-
});
|
|
110
|
-
}
|
|
101
|
+
// `signal` won't affect `this.stdout` and `this.stderr`
|
|
102
|
+
// So remaining data can still be read
|
|
103
|
+
// (call `controller.error` will discard all pending data)
|
|
104
|
+
signal?.addEventListener("abort", () => {
|
|
105
|
+
exited.reject(signal.reason);
|
|
106
|
+
this.#socket.close();
|
|
107
|
+
});
|
|
111
108
|
|
|
112
109
|
this.#writer = this.#socket.writable.getWriter();
|
|
113
110
|
this.#stdin = new MaybeConsumable.WritableStream<Uint8Array>({
|
|
114
|
-
write:
|
|
115
|
-
|
|
111
|
+
write: (chunk) =>
|
|
112
|
+
this.#writer.write(
|
|
116
113
|
AdbShellProtocolPacket.serialize({
|
|
117
114
|
id: AdbShellProtocolId.Stdin,
|
|
118
115
|
data: chunk,
|
|
119
116
|
}),
|
|
120
|
-
)
|
|
121
|
-
},
|
|
117
|
+
),
|
|
122
118
|
close: () =>
|
|
123
119
|
// Only shell protocol + raw mode supports closing stdin
|
|
124
120
|
this.#writer.write(
|