@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,75 @@
|
|
|
1
|
+
import type { Adb } from "../../../adb.js";
|
|
2
|
+
import { AdbFeature } from "../../../features.js";
|
|
3
|
+
|
|
4
|
+
import { AdbShellProtocolProcessImpl } from "./process.js";
|
|
5
|
+
import { AdbShellProtocolPty } from "./pty.js";
|
|
6
|
+
import { AdbShellProtocolId, AdbShellProtocolPacket } from "./shared.js";
|
|
7
|
+
import { adbShellProtocolSpawner } from "./spawner.js";
|
|
8
|
+
|
|
9
|
+
export class AdbShellProtocolSubprocessService {
|
|
10
|
+
static readonly PacketId = AdbShellProtocolId;
|
|
11
|
+
|
|
12
|
+
static readonly Packet = AdbShellProtocolPacket;
|
|
13
|
+
|
|
14
|
+
readonly #adb: Adb;
|
|
15
|
+
get adb() {
|
|
16
|
+
return this.#adb;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
get isSupported() {
|
|
20
|
+
return this.#adb.canUseFeature(AdbFeature.Shell2);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
constructor(adb: Adb) {
|
|
24
|
+
this.#adb = adb;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
spawn = adbShellProtocolSpawner(async (command, signal) => {
|
|
28
|
+
if (!command.length) {
|
|
29
|
+
throw new Error("Command cannot be empty");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Don't escape `command`. See `AdbNoneProtocolSubprocessService.prototype.spawn` for details.
|
|
33
|
+
const service = "shell,v2,raw:" + command.join(" ");
|
|
34
|
+
const socket = await this.#adb.createSocket(service);
|
|
35
|
+
|
|
36
|
+
if (signal?.aborted) {
|
|
37
|
+
await socket.close();
|
|
38
|
+
throw signal.reason;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return new AdbShellProtocolProcessImpl(socket, signal);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
async pty(options?: {
|
|
45
|
+
command?: string | readonly string[] | undefined;
|
|
46
|
+
terminalType?: string;
|
|
47
|
+
}): Promise<AdbShellProtocolPty> {
|
|
48
|
+
const { command, terminalType } = options ?? {};
|
|
49
|
+
|
|
50
|
+
let service = "shell,v2,pty";
|
|
51
|
+
|
|
52
|
+
if (terminalType) {
|
|
53
|
+
if (terminalType.includes(",") || terminalType.includes(":")) {
|
|
54
|
+
throw new Error("terminalType must not contain ',' or ':'");
|
|
55
|
+
}
|
|
56
|
+
service += `,TERM=` + terminalType;
|
|
57
|
+
}
|
|
58
|
+
service += ":";
|
|
59
|
+
|
|
60
|
+
if (typeof command === "string") {
|
|
61
|
+
service += command;
|
|
62
|
+
} else if (Array.isArray(command)) {
|
|
63
|
+
// Don't escape `command`. See `AdbNoneProtocolSubprocessService.prototype.spawn` for details.
|
|
64
|
+
service += command.join(" ");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return new AdbShellProtocolPty(await this.#adb.createSocket(service));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export namespace AdbShellProtocolSubprocessService {
|
|
72
|
+
export type PacketId = AdbShellProtocolId;
|
|
73
|
+
|
|
74
|
+
export type Packet = AdbShellProtocolPacket;
|
|
75
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { StructValue } from "@yume-chan/struct";
|
|
2
2
|
import { buffer, struct, u32, u8 } from "@yume-chan/struct";
|
|
3
3
|
|
|
4
|
+
/** @internal */
|
|
4
5
|
export const AdbShellProtocolId = {
|
|
5
6
|
Stdin: 0,
|
|
6
7
|
Stdout: 1,
|
|
@@ -10,10 +11,12 @@ export const AdbShellProtocolId = {
|
|
|
10
11
|
WindowSizeChange: 5,
|
|
11
12
|
} as const;
|
|
12
13
|
|
|
14
|
+
/** @internal */
|
|
13
15
|
export type AdbShellProtocolId =
|
|
14
16
|
(typeof AdbShellProtocolId)[keyof typeof AdbShellProtocolId];
|
|
15
17
|
|
|
16
18
|
// This packet format is used in both directions.
|
|
19
|
+
/** @internal */
|
|
17
20
|
export const AdbShellProtocolPacket = struct(
|
|
18
21
|
{
|
|
19
22
|
id: u8<AdbShellProtocolId>(),
|
|
@@ -22,4 +25,6 @@ export const AdbShellProtocolPacket = struct(
|
|
|
22
25
|
{ littleEndian: true },
|
|
23
26
|
);
|
|
24
27
|
|
|
28
|
+
// `StructValue` and `StructInit` is same for `AdbShellProtocolPacket`.
|
|
29
|
+
/** @internal */
|
|
25
30
|
export type AdbShellProtocolPacket = StructValue<typeof AdbShellProtocolPacket>;
|
|
@@ -0,0 +1,109 @@
|
|
|
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 AdbShellProtocolProcess {
|
|
19
|
+
get stdin(): WritableStream<MaybeConsumable<Uint8Array>>;
|
|
20
|
+
|
|
21
|
+
get stdout(): ReadableStream<Uint8Array>;
|
|
22
|
+
get stderr(): ReadableStream<Uint8Array>;
|
|
23
|
+
|
|
24
|
+
get exited(): Promise<number>;
|
|
25
|
+
|
|
26
|
+
kill(): MaybePromiseLike<void>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type AdbShellProtocolSpawner = (
|
|
30
|
+
command: string | readonly string[],
|
|
31
|
+
signal?: AbortSignal,
|
|
32
|
+
) => Promise<AdbShellProtocolProcess> &
|
|
33
|
+
AdbSubprocessSpawner.Wait<
|
|
34
|
+
AdbShellProtocolSpawner.WaitResult<Uint8Array>,
|
|
35
|
+
AdbShellProtocolSpawner.WaitResult<string>
|
|
36
|
+
>;
|
|
37
|
+
|
|
38
|
+
export namespace AdbShellProtocolSpawner {
|
|
39
|
+
export interface WaitResult<T> {
|
|
40
|
+
stdout: T;
|
|
41
|
+
stderr: T;
|
|
42
|
+
exitCode: number;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function adbShellProtocolSpawner(
|
|
47
|
+
spawn: (
|
|
48
|
+
command: readonly string[],
|
|
49
|
+
signal: AbortSignal | undefined,
|
|
50
|
+
) => Promise<AdbShellProtocolProcess>,
|
|
51
|
+
): AdbShellProtocolSpawner {
|
|
52
|
+
return (command, signal) => {
|
|
53
|
+
signal?.throwIfAborted();
|
|
54
|
+
|
|
55
|
+
if (typeof command === "string") {
|
|
56
|
+
command = splitCommand(command);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const processPromise = spawn(
|
|
60
|
+
command,
|
|
61
|
+
signal,
|
|
62
|
+
) as Promise<AdbShellProtocolProcess> &
|
|
63
|
+
AdbSubprocessSpawner.Wait<
|
|
64
|
+
AdbShellProtocolSpawner.WaitResult<Uint8Array>,
|
|
65
|
+
AdbShellProtocolSpawner.WaitResult<string>
|
|
66
|
+
>;
|
|
67
|
+
|
|
68
|
+
processPromise.wait = (options) => {
|
|
69
|
+
const waitPromise = processPromise.then(async (process) => {
|
|
70
|
+
const [, stdout, stderr, exitCode] = await Promise.all([
|
|
71
|
+
options?.stdin?.pipeTo(process.stdin),
|
|
72
|
+
process.stdout.pipeThrough(new ToArrayStream()),
|
|
73
|
+
process.stderr.pipeThrough(new ToArrayStream()),
|
|
74
|
+
process.exited,
|
|
75
|
+
]);
|
|
76
|
+
return {
|
|
77
|
+
stdout,
|
|
78
|
+
stderr,
|
|
79
|
+
exitCode,
|
|
80
|
+
} satisfies AdbShellProtocolSpawner.WaitResult<Uint8Array[]>;
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
return createLazyPromise(
|
|
84
|
+
async () => {
|
|
85
|
+
const { stdout, stderr, exitCode } = await waitPromise;
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
stdout: concatUint8Arrays(stdout),
|
|
89
|
+
stderr: concatUint8Arrays(stderr),
|
|
90
|
+
exitCode,
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
async toString() {
|
|
95
|
+
const { stdout, stderr, exitCode } = await waitPromise;
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
stdout: decodeUtf8Chunked(stdout),
|
|
99
|
+
stderr: decodeUtf8Chunked(stderr),
|
|
100
|
+
exitCode,
|
|
101
|
+
};
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
return processPromise;
|
|
108
|
+
};
|
|
109
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { MaybeConsumable, ReadableStream } from "@yume-chan/stream-extra";
|
|
2
|
+
|
|
3
|
+
import type { LazyPromise } from "./utils.js";
|
|
4
|
+
|
|
5
|
+
export namespace AdbSubprocessSpawner {
|
|
6
|
+
export interface WaitToString<T> {
|
|
7
|
+
toString(): Promise<T>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface WaitOptions {
|
|
11
|
+
stdin?: ReadableStream<MaybeConsumable<Uint8Array>> | undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface Wait<TBuffer, TString> {
|
|
15
|
+
wait(
|
|
16
|
+
options?: WaitOptions,
|
|
17
|
+
): LazyPromise<TBuffer, WaitToString<TString>>;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { AccumulateStream } from "@yume-chan/stream-extra";
|
|
2
|
+
import { TextDecoder } from "@yume-chan/struct";
|
|
3
|
+
|
|
4
|
+
export function escapeArg(s: string) {
|
|
5
|
+
let result = "";
|
|
6
|
+
result += `'`;
|
|
7
|
+
|
|
8
|
+
let base = 0;
|
|
9
|
+
while (true) {
|
|
10
|
+
const found = s.indexOf(`'`, base);
|
|
11
|
+
if (found === -1) {
|
|
12
|
+
result += s.substring(base);
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
result += s.substring(base, found);
|
|
16
|
+
// a'b becomes 'a'\'b', which is 'a' + \' + 'b'
|
|
17
|
+
// (quoted string 'a', escaped single quote, and quoted string 'b')
|
|
18
|
+
result += String.raw`'\''`;
|
|
19
|
+
base = found + 1;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
result += `'`;
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Split the command.
|
|
28
|
+
*
|
|
29
|
+
* Quotes and escaped characters are supported, and will be returned as-is.
|
|
30
|
+
* @param input The input command
|
|
31
|
+
* @returns An array of string containing the arguments
|
|
32
|
+
*/
|
|
33
|
+
export function splitCommand(input: string): string[] {
|
|
34
|
+
const result: string[] = [];
|
|
35
|
+
let quote: string | undefined;
|
|
36
|
+
let isEscaped = false;
|
|
37
|
+
let start = 0;
|
|
38
|
+
|
|
39
|
+
for (let i = 0, len = input.length; i < len; i += 1) {
|
|
40
|
+
if (isEscaped) {
|
|
41
|
+
isEscaped = false;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const char = input.charAt(i);
|
|
46
|
+
switch (char) {
|
|
47
|
+
case " ":
|
|
48
|
+
if (!quote) {
|
|
49
|
+
if (i !== start) {
|
|
50
|
+
result.push(input.substring(start, i));
|
|
51
|
+
}
|
|
52
|
+
start = i + 1;
|
|
53
|
+
}
|
|
54
|
+
break;
|
|
55
|
+
case "'":
|
|
56
|
+
case '"':
|
|
57
|
+
if (!quote) {
|
|
58
|
+
quote = char;
|
|
59
|
+
} else if (char === quote) {
|
|
60
|
+
quote = undefined;
|
|
61
|
+
}
|
|
62
|
+
break;
|
|
63
|
+
case "\\":
|
|
64
|
+
isEscaped = true;
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (start < input.length) {
|
|
70
|
+
result.push(input.substring(start));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Omit `Symbol.toStringTag` so it's incompatible with `Promise`.
|
|
77
|
+
// It can't be returned from async function like `Promise`s.
|
|
78
|
+
export type LazyPromise<T, U> = Omit<Promise<T>, typeof Symbol.toStringTag> & U;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Creates a `Promise`-like object that lazily computes the result
|
|
82
|
+
* only when it's being used as a `Promise`.
|
|
83
|
+
*
|
|
84
|
+
* For example, if an API returns a value `p` of type `Promise<T> & { asU(): Promise<U> }`,
|
|
85
|
+
* and the user calls `p.asU()` instead of using it as a `Promise` (`p.then()`, `await p`, etc.),
|
|
86
|
+
* is unnecessary to compute the result `T` (unless `asU` also depends on it).
|
|
87
|
+
*
|
|
88
|
+
* By using `createLazyPromise(computeT, { asU: computeU })`,
|
|
89
|
+
* `computeT` will only run when `p` is used as a `Promise`.
|
|
90
|
+
*
|
|
91
|
+
* Note that the result object can't be returned from an async function,
|
|
92
|
+
* as async functions always creates a new `Promise` with the return value,
|
|
93
|
+
* which runs `initializer` immediately, and discards any extra `methods` attached.
|
|
94
|
+
* @param initializer
|
|
95
|
+
* The initializer function when the result object is being used as a `Promise`.
|
|
96
|
+
*
|
|
97
|
+
* The result value will be cached.
|
|
98
|
+
* @param methods Any extra methods to add to the result object
|
|
99
|
+
* @returns
|
|
100
|
+
* A `Promise`-like object that runs `initializer` when used as a `Promise`, and contains `methods`.
|
|
101
|
+
*/
|
|
102
|
+
export function createLazyPromise<
|
|
103
|
+
T,
|
|
104
|
+
U extends Record<PropertyKey, () => unknown>,
|
|
105
|
+
>(initializer: () => Promise<T>, methods: U): LazyPromise<T, U> {
|
|
106
|
+
let promise: Promise<T> | undefined;
|
|
107
|
+
|
|
108
|
+
const getOrCreatePromise = () => {
|
|
109
|
+
if (!promise) {
|
|
110
|
+
promise = initializer();
|
|
111
|
+
}
|
|
112
|
+
return promise;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const result = {
|
|
116
|
+
// biome-ignore lint/suspicious/noThenProperty: This object is intentionally thenable
|
|
117
|
+
then(onfulfilled, onrejected) {
|
|
118
|
+
return getOrCreatePromise().then(onfulfilled, onrejected);
|
|
119
|
+
},
|
|
120
|
+
// biome-ignore lint/suspicious/noThenProperty: This object is intentionally thenable
|
|
121
|
+
catch(onrejected) {
|
|
122
|
+
return getOrCreatePromise().catch(onrejected);
|
|
123
|
+
},
|
|
124
|
+
// biome-ignore lint/suspicious/noThenProperty: This object is intentionally thenable
|
|
125
|
+
finally(onfinally) {
|
|
126
|
+
return getOrCreatePromise().finally(onfinally);
|
|
127
|
+
},
|
|
128
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
129
|
+
} satisfies LazyPromise<T, {}> as LazyPromise<T, U>;
|
|
130
|
+
|
|
131
|
+
for (const [key, value] of Object.entries(methods)) {
|
|
132
|
+
Object.defineProperty(result, key, {
|
|
133
|
+
configurable: true,
|
|
134
|
+
writable: true,
|
|
135
|
+
enumerable: false,
|
|
136
|
+
value,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return result;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export class ToArrayStream<T> extends AccumulateStream<T, T[]> {
|
|
144
|
+
constructor() {
|
|
145
|
+
super(
|
|
146
|
+
[],
|
|
147
|
+
(chunk, current) => {
|
|
148
|
+
current.push(chunk);
|
|
149
|
+
return current;
|
|
150
|
+
},
|
|
151
|
+
(output) => output,
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function decodeUtf8Chunked(chunks: Uint8Array[]): string {
|
|
157
|
+
// PERF: `TextDecoder`'s `stream` mode can decode from `chunks` directly.
|
|
158
|
+
// This avoids an extra allocation and copy.
|
|
159
|
+
const decoder = new TextDecoder();
|
|
160
|
+
let output = "";
|
|
161
|
+
for (const chunk of chunks) {
|
|
162
|
+
output += decoder.decode(chunk, { stream: true });
|
|
163
|
+
}
|
|
164
|
+
output += decoder.decode();
|
|
165
|
+
return output;
|
|
166
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// https://github.com/python/cpython/blob/4e581d64b8aff3e2eda99b12f080c877bb78dfca/Lib/stat.py#L36
|
|
2
|
+
export const LinuxFileType = {
|
|
3
|
+
Directory: 0o04,
|
|
4
|
+
File: 0o10,
|
|
5
|
+
Link: 0o12,
|
|
6
|
+
} as const;
|
|
7
|
+
|
|
8
|
+
export type LinuxFileType = (typeof LinuxFileType)[keyof typeof LinuxFileType];
|
|
9
|
+
|
|
10
|
+
export const AndroidSyscallErrorCode = {
|
|
11
|
+
SUCCESS: 0,
|
|
12
|
+
EACCES: 13,
|
|
13
|
+
EEXIST: 17,
|
|
14
|
+
EFAULT: 14,
|
|
15
|
+
EFBIG: 27,
|
|
16
|
+
EINTR: 4,
|
|
17
|
+
EINVAL: 22,
|
|
18
|
+
EIO: 5,
|
|
19
|
+
EISDIR: 21,
|
|
20
|
+
ELOOP: 40,
|
|
21
|
+
EMFILE: 24,
|
|
22
|
+
ENAMETOOLONG: 36,
|
|
23
|
+
ENFILE: 23,
|
|
24
|
+
ENOENT: 2,
|
|
25
|
+
ENOMEM: 12,
|
|
26
|
+
ENOSPC: 28,
|
|
27
|
+
ENOTDIR: 20,
|
|
28
|
+
EOVERFLOW: 75,
|
|
29
|
+
EPERM: 1,
|
|
30
|
+
EROFS: 30,
|
|
31
|
+
ETXTBSY: 26,
|
|
32
|
+
} as const;
|
|
33
|
+
|
|
34
|
+
export type AndroidSyscallErrorCode =
|
|
35
|
+
(typeof AndroidSyscallErrorCode)[keyof typeof AndroidSyscallErrorCode];
|
|
36
|
+
|
|
37
|
+
export const AndroidSyscallErrorNameMap = /* #__PURE__ */ (() =>
|
|
38
|
+
Object.fromEntries(
|
|
39
|
+
Object.entries(AndroidSyscallErrorCode).map(([key, value]) => [
|
|
40
|
+
value,
|
|
41
|
+
key,
|
|
42
|
+
]),
|
|
43
|
+
))();
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CompressionStream,
|
|
3
|
+
DecompressionStream,
|
|
4
|
+
TransformStream,
|
|
5
|
+
} from "@yume-chan/stream-extra";
|
|
6
|
+
|
|
7
|
+
import type { Adb } from "../../../adb.js";
|
|
8
|
+
import { AdbFeature } from "../../../features.js";
|
|
9
|
+
import { NOOP } from "../../../utils/no-op.js";
|
|
10
|
+
|
|
11
|
+
import { Format } from "./format.js";
|
|
12
|
+
|
|
13
|
+
export { Format };
|
|
14
|
+
|
|
15
|
+
export const Mode = {
|
|
16
|
+
Compress: 0,
|
|
17
|
+
Decompress: 1,
|
|
18
|
+
} as const;
|
|
19
|
+
|
|
20
|
+
export type Mode = (typeof Mode)[keyof typeof Mode];
|
|
21
|
+
|
|
22
|
+
const FormatMap: Record<Format, string> = {
|
|
23
|
+
[Format.None]: "",
|
|
24
|
+
// https://github.com/whatwg/compression/pull/80
|
|
25
|
+
[Format.Zstd]: "zstd",
|
|
26
|
+
// placeholder
|
|
27
|
+
[Format.Lz4]: "lz4",
|
|
28
|
+
// https://github.com/whatwg/compression/pull/80
|
|
29
|
+
[Format.Brotli]: "brotli",
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const CompressionFormatCache = new Map<Format, boolean>();
|
|
33
|
+
const DecompressionFormatCache = new Map<Format, boolean>();
|
|
34
|
+
|
|
35
|
+
export function hasRuntimeSupport(format: Format, mode: Mode) {
|
|
36
|
+
if (format === Format.None) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const Cache =
|
|
41
|
+
mode === Mode.Compress
|
|
42
|
+
? CompressionFormatCache
|
|
43
|
+
: DecompressionFormatCache;
|
|
44
|
+
if (Cache.has(format)) {
|
|
45
|
+
return Cache.get(format)!;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const Stream =
|
|
49
|
+
mode === Mode.Compress ? CompressionStream : DecompressionStream;
|
|
50
|
+
if (!Stream) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
const stream = new Stream(FormatMap[format]);
|
|
56
|
+
void stream.writable.abort().catch(NOOP);
|
|
57
|
+
Cache.set(format, true);
|
|
58
|
+
return true;
|
|
59
|
+
} catch {
|
|
60
|
+
Cache.set(format, false);
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function canUseBrotli(adb: Adb, mode: Mode) {
|
|
66
|
+
return (
|
|
67
|
+
adb.canUseFeature(AdbFeature.SendReceive2Brotli) &&
|
|
68
|
+
hasRuntimeSupport(Format.Brotli, mode)
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function canUseLz4(adb: Adb, mode: Mode) {
|
|
73
|
+
return (
|
|
74
|
+
adb.canUseFeature(AdbFeature.SendReceive2Lz4) &&
|
|
75
|
+
hasRuntimeSupport(Format.Lz4, mode)
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function canUseZstd(adb: Adb, mode: Mode) {
|
|
80
|
+
return (
|
|
81
|
+
adb.canUseFeature(AdbFeature.SendReceive2Zstd) &&
|
|
82
|
+
hasRuntimeSupport(Format.Zstd, mode)
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function canUseFormat(adb: Adb, format: Format, mode: Mode) {
|
|
87
|
+
switch (format) {
|
|
88
|
+
case Format.None:
|
|
89
|
+
return true;
|
|
90
|
+
case Format.Brotli:
|
|
91
|
+
return canUseBrotli(adb, mode);
|
|
92
|
+
case Format.Lz4:
|
|
93
|
+
return canUseLz4(adb, mode);
|
|
94
|
+
case Format.Zstd:
|
|
95
|
+
return canUseZstd(adb, mode);
|
|
96
|
+
default:
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function chooseFormat(adb: Adb, mode: Mode) {
|
|
102
|
+
// The order follows
|
|
103
|
+
// https://android.googlesource.com/platform/packages/modules/adb/+/3da39565cad412a743a58b94b875a43ed3c640d3/client/file_sync_client.cpp#277
|
|
104
|
+
|
|
105
|
+
if (canUseZstd(adb, mode)) {
|
|
106
|
+
return Format.Zstd;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (canUseLz4(adb, mode)) {
|
|
110
|
+
return Format.Lz4;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (canUseBrotli(adb, mode)) {
|
|
114
|
+
return Format.Brotli;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return Format.None;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function createCompressionStream(format: Format): CompressionStream {
|
|
121
|
+
if (format === Format.None) {
|
|
122
|
+
return new TransformStream();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return new CompressionStream(FormatMap[format]);
|
|
126
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as Compression from "./compression.js";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { getUint32LittleEndian } from "@yume-chan/no-data-view";
|
|
2
|
+
|
|
3
|
+
function encodeAsciiUnchecked(value: string): Uint8Array<ArrayBuffer> {
|
|
4
|
+
const result = new Uint8Array(value.length);
|
|
5
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
6
|
+
result[i] = value.charCodeAt(i);
|
|
7
|
+
}
|
|
8
|
+
return result;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Encode ID to numbers for faster comparison.
|
|
13
|
+
*
|
|
14
|
+
* This function skips all checks. The caller must ensure the input is valid.
|
|
15
|
+
*
|
|
16
|
+
* @param value A 4 ASCII character string.
|
|
17
|
+
* @returns A 32-bit integer by encoding the string as little-endian
|
|
18
|
+
*
|
|
19
|
+
* #__NO_SIDE_EFFECTS__
|
|
20
|
+
*/
|
|
21
|
+
export function encodeId(value: string): number {
|
|
22
|
+
const buffer = encodeAsciiUnchecked(value);
|
|
23
|
+
return getUint32LittleEndian(buffer, 0);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// https://cs.android.com/android/platform/superproject/main/+/main:packages/modules/adb/file_sync_protocol.h;l=23;drc=888a54dcbf954fdffacc8283a793290abcc589cd
|
|
27
|
+
|
|
28
|
+
export const Lstat = encodeId("STAT");
|
|
29
|
+
export const Stat = encodeId("STA2");
|
|
30
|
+
export const LstatV2 = encodeId("LST2");
|
|
31
|
+
|
|
32
|
+
export const Done = encodeId("DONE");
|
|
33
|
+
export const Data = encodeId("DATA");
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { encodeId } from "./common.js";
|
|
2
|
+
|
|
3
|
+
export { Data, Done, Lstat, LstatV2, Stat } from "./common.js";
|
|
4
|
+
|
|
5
|
+
// https://cs.android.com/android/platform/superproject/main/+/main:packages/modules/adb/file_sync_protocol.h;l=23;drc=888a54dcbf954fdffacc8283a793290abcc589cd
|
|
6
|
+
|
|
7
|
+
export const List = encodeId("LIST");
|
|
8
|
+
export const ListV2 = encodeId("LIS2");
|
|
9
|
+
|
|
10
|
+
export const Send = encodeId("SEND");
|
|
11
|
+
export const SendV2 = encodeId("SND2");
|
|
12
|
+
export const Receive = encodeId("RECV");
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { encodeId } from "./common.js";
|
|
2
|
+
|
|
3
|
+
export { Data, Done, Lstat, LstatV2, Stat } from "./common.js";
|
|
4
|
+
|
|
5
|
+
// https://cs.android.com/android/platform/superproject/main/+/main:packages/modules/adb/file_sync_protocol.h;l=23;drc=888a54dcbf954fdffacc8283a793290abcc589cd
|
|
6
|
+
|
|
7
|
+
export const Entry = encodeId("DENT");
|
|
8
|
+
export const EntryV2 = encodeId("DNT2");
|
|
9
|
+
|
|
10
|
+
export const Ok = encodeId("OKAY");
|
|
11
|
+
export const Fail = encodeId("FAIL");
|