@yume-chan/adb 2.6.0 → 3.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/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 -73
- 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 +7 -7
- package/esm/server/client.d.ts.map +1 -1
- package/esm/server/client.js +69 -86
- 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 +31 -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 +4 -6
- 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 +45 -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 -12
- 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 +10 -10
- package/src/adb.ts +44 -34
- 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 -102
- 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 +96 -94
- 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 +81 -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 +6 -7
- 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 +109 -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 -12
- package/src/utils/index.ts +1 -0
- package/src/utils/md5.ts +185 -0
- package/yume-chan-adb-3.0.0-beta.0.tgz +0 -0
- package/CHANGELOG.md +0 -251
- 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 -204
- 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
|
|
135
|
-
|
|
136
|
-
try {
|
|
137
|
-
await stream.writeString(request);
|
|
138
|
-
} catch (e) {
|
|
139
|
-
await stream.dispose();
|
|
140
|
-
throw e;
|
|
141
|
-
}
|
|
181
|
+
const dataConnection = new AdbServerDataConnection(connection);
|
|
142
182
|
|
|
143
183
|
try {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
return stream;
|
|
184
|
+
await dataConnection.writeString(request);
|
|
185
|
+
await dataConnection.readOkay();
|
|
186
|
+
return dataConnection;
|
|
148
187
|
} catch (e) {
|
|
149
|
-
await
|
|
188
|
+
await dataConnection.dispose();
|
|
150
189
|
throw e;
|
|
151
190
|
}
|
|
152
191
|
}
|
|
@@ -271,13 +310,13 @@ export class AdbServerClient {
|
|
|
271
310
|
"host:features",
|
|
272
311
|
);
|
|
273
312
|
// Luckily `AdbServerClient.Socket` is compatible with `AdbServerClient.ServerConnection`
|
|
274
|
-
const
|
|
313
|
+
const dataConnection = new AdbServerDataConnection(connection);
|
|
275
314
|
try {
|
|
276
|
-
const featuresString = await
|
|
315
|
+
const featuresString = await dataConnection.readString();
|
|
277
316
|
const features = featuresString.split(",") as AdbFeature[];
|
|
278
317
|
return { transportId: connection.transportId, features };
|
|
279
318
|
} finally {
|
|
280
|
-
await
|
|
319
|
+
await dataConnection.dispose();
|
|
281
320
|
}
|
|
282
321
|
}
|
|
283
322
|
|
|
@@ -316,12 +355,7 @@ export class AdbServerClient {
|
|
|
316
355
|
|
|
317
356
|
try {
|
|
318
357
|
await connection.writeString(service);
|
|
319
|
-
} catch (e) {
|
|
320
|
-
await connection.dispose();
|
|
321
|
-
throw e;
|
|
322
|
-
}
|
|
323
358
|
|
|
324
|
-
try {
|
|
325
359
|
if (transportId === undefined) {
|
|
326
360
|
const array = await connection.readExactly(8);
|
|
327
361
|
transportId = getUint64LittleEndian(array, 0);
|
|
@@ -348,17 +382,14 @@ export class AdbServerClient {
|
|
|
348
382
|
throw e;
|
|
349
383
|
}
|
|
350
384
|
}
|
|
385
|
+
|
|
351
386
|
async #waitForUnchecked(
|
|
352
387
|
device: AdbServerClient.DeviceSelector,
|
|
353
388
|
state: "device" | "disconnect",
|
|
354
389
|
options?: AdbServerClient.ServerConnectionOptions,
|
|
355
390
|
): Promise<void> {
|
|
356
391
|
let type: string;
|
|
357
|
-
if (!device) {
|
|
358
|
-
type = "any";
|
|
359
|
-
} else if ("transportId" in device) {
|
|
360
|
-
type = "any";
|
|
361
|
-
} else if ("serial" in device) {
|
|
392
|
+
if (!device || "transportId" in device || "serial" in device) {
|
|
362
393
|
type = "any";
|
|
363
394
|
} else if ("usb" in device) {
|
|
364
395
|
type = "usb";
|
|
@@ -425,12 +456,12 @@ export class AdbServerClient {
|
|
|
425
456
|
(device) => device.transportId === transportId,
|
|
426
457
|
)
|
|
427
458
|
) {
|
|
428
|
-
observer.
|
|
459
|
+
observer.close();
|
|
429
460
|
resolve();
|
|
430
461
|
}
|
|
431
462
|
});
|
|
432
463
|
observer.onError((e) => {
|
|
433
|
-
observer.
|
|
464
|
+
observer.close();
|
|
434
465
|
reject(e);
|
|
435
466
|
});
|
|
436
467
|
});
|
|
@@ -483,37 +514,6 @@ export class AdbServerClient {
|
|
|
483
514
|
}
|
|
484
515
|
}
|
|
485
516
|
|
|
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
517
|
export namespace AdbServerClient {
|
|
518
518
|
export interface ServerConnectionOptions {
|
|
519
519
|
unref?: boolean | undefined;
|
|
@@ -521,7 +521,8 @@ export namespace AdbServerClient {
|
|
|
521
521
|
}
|
|
522
522
|
|
|
523
523
|
export interface ServerConnection
|
|
524
|
-
extends
|
|
524
|
+
extends
|
|
525
|
+
ReadableWritablePair<Uint8Array, MaybeConsumable<Uint8Array>>,
|
|
525
526
|
Closeable {
|
|
526
527
|
get closed(): Promise<undefined>;
|
|
527
528
|
}
|
|
@@ -532,7 +533,7 @@ export namespace AdbServerClient {
|
|
|
532
533
|
): MaybePromiseLike<ServerConnection>;
|
|
533
534
|
|
|
534
535
|
addReverseTunnel(
|
|
535
|
-
handler:
|
|
536
|
+
handler: Adb.IncomingSocketHandler,
|
|
536
537
|
address?: string,
|
|
537
538
|
): MaybePromiseLike<string>;
|
|
538
539
|
|
|
@@ -541,7 +542,7 @@ export namespace AdbServerClient {
|
|
|
541
542
|
clearReverseTunnels(): MaybePromiseLike<void>;
|
|
542
543
|
}
|
|
543
544
|
|
|
544
|
-
export interface Socket extends
|
|
545
|
+
export interface Socket extends Adb.Socket {
|
|
545
546
|
transportId: bigint;
|
|
546
547
|
}
|
|
547
548
|
|
|
@@ -555,7 +556,8 @@ export namespace AdbServerClient {
|
|
|
555
556
|
| { tcp: true }
|
|
556
557
|
| undefined;
|
|
557
558
|
|
|
558
|
-
export type ConnectionState =
|
|
559
|
+
export type ConnectionState =
|
|
560
|
+
(typeof AdbServerClient.ConnectionState)[number];
|
|
559
561
|
|
|
560
562
|
export interface Device {
|
|
561
563
|
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
|
}
|
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";
|