Skip to content

Commit

Permalink
Merge branch 'origin/main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Gasol committed Oct 15, 2024
2 parents 2e4b6e0 + 6a18fa2 commit 0345719
Show file tree
Hide file tree
Showing 77 changed files with 1,360 additions and 1,360 deletions.
16 changes: 8 additions & 8 deletions apps/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@
"tango-cli": "esm/index.js"
},
"dependencies": {
"@gasol/adb": "workspace:^0.0.24",
"@gasol/adb-server-node-tcp": "workspace:^0.0.24",
"@gasol/android-bin": "workspace:^0.0.24",
"@gasol/stream-extra": "workspace:^0.0.24",
"@gasol/adb": "workspace:^",
"@gasol/adb-server-node-tcp": "workspace:^",
"@gasol/android-bin": "workspace:^",
"@gasol/stream-extra": "workspace:^",
"commander": "^12.1.0",
"source-map-support": "^0.5.21"
},
"devDependencies": {
"@types/node": "^22.2.0",
"@gasol/eslint-config": "workspace:^1.0.0",
"@gasol/tsconfig": "workspace:^1.0.0",
"@types/node": "^22.7.4",
"@gasol/eslint-config": "workspace:^",
"@gasol/tsconfig": "workspace:^",
"prettier": "^3.3.3",
"typescript": "^5.5.4"
"typescript": "^5.6.2"
}
}
5 changes: 5 additions & 0 deletions apps/cli/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "./tsconfig.build.json",
"compilerOptions": {},
"exclude": []
}
8 changes: 4 additions & 4 deletions libraries/adb-credential-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
"prepublishOnly": "npm run build"
},
"dependencies": {
"@gasol/adb": "workspace:^0.0.24"
"@gasol/adb": "workspace:^"
},
"devDependencies": {
"@gasol/eslint-config": "workspace:^1.0.0",
"@gasol/tsconfig": "workspace:^1.0.0",
"@gasol/eslint-config": "workspace:^",
"@gasol/tsconfig": "workspace:^",
"prettier": "^3.3.3",
"typescript": "^5.5.4"
"typescript": "^5.6.2"
}
}
6 changes: 6 additions & 0 deletions libraries/adb-credential-web/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ async function getAllKeys() {
});
}

/**
* An `AdbCredentialStore` implementation that creates RSA private keys using Web Crypto API
* and stores them in IndexedDB.
*
* [Online Documentation](https://docs.tangoapp.dev/tango/daemon/credential-store/)
*/
export default class AdbWebCredentialStore implements AdbCredentialStore {
#appName: string;

Expand Down
5 changes: 5 additions & 0 deletions libraries/adb-credential-web/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "./tsconfig.build.json",
"compilerOptions": {},
"exclude": []
}
16 changes: 8 additions & 8 deletions libraries/adb-daemon-webusb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@
},
"dependencies": {
"@types/w3c-web-usb": "^1.0.10",
"@gasol/adb": "workspace:^0.0.24",
"@gasol/stream-extra": "workspace:^0.0.24",
"@gasol/struct": "workspace:^0.0.24"
"@gasol/adb": "workspace:^",
"@gasol/stream-extra": "workspace:^",
"@gasol/struct": "workspace:^"
},
"devDependencies": {
"@types/node": "^22.2.0",
"@gasol/eslint-config": "workspace:^1.0.0",
"@gasol/test-runner": "workspace:^1.0.0",
"@gasol/tsconfig": "workspace:^1.0.0",
"@types/node": "^22.7.4",
"@gasol/eslint-config": "workspace:^",
"@gasol/test-runner": "workspace:^",
"@gasol/tsconfig": "workspace:^",
"prettier": "^3.3.3",
"typescript": "^5.5.4"
"typescript": "^5.6.2"
}
}
5 changes: 3 additions & 2 deletions libraries/adb-daemon-webusb/src/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,9 @@ export class AdbDaemonWebUsbDevice implements AdbDaemonDevice {
}

/**
* Claim the device and create a pair of `AdbPacket` streams to the ADB interface.
* @returns The pair of `AdbPacket` streams.
* Open the device and create a new connection to the ADB Daemon.
*
* [Online Documentation](https://docs.tangoapp.dev/tango/daemon/usb/create-connection/)
*/
async connect(): Promise<AdbDaemonWebUsbConnection> {
const [inEndpoint, outEndpoint] = await this.#claimInterface();
Expand Down
30 changes: 8 additions & 22 deletions libraries/adb-daemon-webusb/src/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ export namespace AdbDaemonWebUsbDeviceManager {
}
}

/**
* [Online Documentation](https://docs.tangoapp.dev/tango/daemon/usb/device-manager/)
*/
export class AdbDaemonWebUsbDeviceManager {
/**
* Gets the instance of {@link AdbDaemonWebUsbDeviceManager} using browser WebUSB implementation.
Expand All @@ -35,17 +38,9 @@ export class AdbDaemonWebUsbDeviceManager {
}

/**
* Request access to a connected device.
* This is a convince method for `usb.requestDevice()`.
* @param filters
* The filters to apply to the device list.
* Call `USB#requestDevice()` to prompt the user to select a device.
*
* It must have `classCode`, `subclassCode` and `protocolCode` fields for selecting the ADB interface,
* but might also have `vendorId`, `productId` or `serialNumber` fields to limit the displayed device list.
*
* Defaults to {@link ADB_DEFAULT_INTERFACE_FILTER}.
* @returns An {@link AdbDaemonWebUsbDevice} instance if the user selected a device,
* or `undefined` if the user cancelled the device picker.
* [Online Documentation](https://docs.tangoapp.dev/tango/daemon/usb/request-device/)
*/
async requestDevice(
options: AdbDaemonWebUsbDeviceManager.RequestDeviceOptions = {},
Expand All @@ -69,20 +64,11 @@ export class AdbDaemonWebUsbDeviceManager {
}

/**
* Get all connected and authenticated devices.
* This is a convince method for `usb.getDevices()`.
* @param filters
* The filters to apply to the device list.
*
* It must have `classCode`, `subclassCode` and `protocolCode` fields for selecting the ADB interface,
* but might also have `vendorId`, `productId` or `serialNumber` fields to limit the device list.
* Get all connected and requested devices that match the specified filters.
*
* Defaults to {@link ADB_DEFAULT_INTERFACE_FILTER}.
* @returns An array of {@link AdbDaemonWebUsbDevice} instances for all connected and authenticated devices.
* [Online Documentation](https://docs.tangoapp.dev/tango/daemon/usb/get-devices/)
*/
getDevices(
filters?: USBDeviceFilter[] | undefined,
): Promise<AdbDaemonWebUsbDevice[]>;
getDevices(filters?: USBDeviceFilter[]): Promise<AdbDaemonWebUsbDevice[]>;
async getDevices(
filters_: USBDeviceFilter[] | undefined,
): Promise<AdbDaemonWebUsbDevice[]> {
Expand Down
6 changes: 6 additions & 0 deletions libraries/adb-daemon-webusb/src/watcher.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* A watcher that listens for new WebUSB devices and notifies the callback when
* a new device is connected or disconnected.
*
* [Online Documentation](https://docs.tangoapp.dev/tango/daemon/usb/watch-devices/)
*/
export class AdbDaemonWebUsbDeviceWatcher {
#callback: (newDeviceSerial?: string) => void;
#usbManager: USB;
Expand Down
16 changes: 8 additions & 8 deletions libraries/adb-scrcpy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@
"prepublishOnly": "npm run build"
},
"dependencies": {
"@gasol/adb": "workspace:^0.0.24",
"@gasol/adb": "workspace:^",
"@yume-chan/async": "^2.2.0",
"@gasol/event": "workspace:^0.0.24",
"@gasol/scrcpy": "workspace:^0.0.24",
"@gasol/stream-extra": "workspace:^0.0.24",
"@gasol/struct": "workspace:^0.0.24"
"@gasol/event": "workspace:^",
"@gasol/scrcpy": "workspace:^",
"@gasol/stream-extra": "workspace:^",
"@gasol/struct": "workspace:^"
},
"devDependencies": {
"@gasol/eslint-config": "workspace:^1.0.0",
"@gasol/tsconfig": "workspace:^1.0.0",
"@gasol/eslint-config": "workspace:^",
"@gasol/tsconfig": "workspace:^",
"prettier": "^3.3.3",
"typescript": "^5.5.4"
"typescript": "^5.6.2"
}
}
14 changes: 7 additions & 7 deletions libraries/adb-server-node-tcp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@
"lint": "run-eslint && prettier src/**/*.ts --write --tab-width 4"
},
"dependencies": {
"@gasol/adb": "workspace:^0.0.24",
"@gasol/stream-extra": "workspace:^0.0.24",
"@gasol/struct": "workspace:^0.0.24"
"@gasol/adb": "workspace:^",
"@gasol/stream-extra": "workspace:^",
"@gasol/struct": "workspace:^"
},
"devDependencies": {
"@types/node": "^22.2.0",
"@gasol/eslint-config": "workspace:^1.0.0",
"@gasol/tsconfig": "workspace:^1.0.0",
"@types/node": "^22.7.4",
"@gasol/eslint-config": "workspace:^",
"@gasol/tsconfig": "workspace:^",
"prettier": "^3.3.3",
"typescript": "^5.5.4"
"typescript": "^5.6.2"
}
}
19 changes: 10 additions & 9 deletions libraries/adb-server-node-tcp/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import {
MaybeConsumable,
PushReadableStream,
tryClose,
WrapWritableStream,
WritableStream,
} from "@gasol/stream-extra";
import type { ValueOrPromise } from "@gasol/struct";

Expand Down Expand Up @@ -36,9 +34,9 @@ function nodeSocketToConnection(
tryClose(controller);
});
}),
writable: new WritableStream<Uint8Array>({
write: async (chunk) => {
await new Promise<void>((resolve, reject) => {
writable: new MaybeConsumable.WritableStream<Uint8Array>({
write: (chunk) => {
return new Promise<void>((resolve, reject) => {
socket.write(chunk, (err) => {
if (err) {
reject(err);
Expand All @@ -58,6 +56,11 @@ function nodeSocketToConnection(
};
}

/**
* An `AdbServerClient.ServerConnector` implementation for Node.js.
*
* [Online Documentation](https://docs.tangoapp.dev/tango/server/client/)
*/
export class AdbServerNodeTcpConnector
implements AdbServerClient.ServerConnector {
readonly spec: SocketConnectOpts;
Expand Down Expand Up @@ -94,9 +97,7 @@ export class AdbServerNodeTcpConnector
await handler({
service: address!,
readable: connection.readable,
writable: new WrapWritableStream(
connection.writable,
).bePipedThroughFrom(new MaybeConsumable.UnwrapStream()),
writable: connection.writable,
get closed() {
return connection.closed;
},
Expand Down Expand Up @@ -129,7 +130,7 @@ export class AdbServerNodeTcpConnector

if (!address) {
const info = server.address() as AddressInfo;
address = `tcp:${info.address}:${info.port}`;
address = `tcp:${info.port}`;
}

this.#listeners.set(address, server);
Expand Down
5 changes: 5 additions & 0 deletions libraries/adb-server-node-tcp/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "./tsconfig.build.json",
"compilerOptions": {},
"exclude": []
}
18 changes: 9 additions & 9 deletions libraries/adb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@
},
"dependencies": {
"@yume-chan/async": "^2.2.0",
"@gasol/event": "workspace:^0.0.24",
"@gasol/no-data-view": "workspace:^0.0.24",
"@gasol/stream-extra": "workspace:^0.0.24",
"@gasol/struct": "workspace:^0.0.24"
"@gasol/event": "workspace:^",
"@gasol/no-data-view": "workspace:^",
"@gasol/stream-extra": "workspace:^",
"@gasol/struct": "workspace:^"
},
"devDependencies": {
"@types/node": "^22.2.0",
"@gasol/eslint-config": "workspace:^1.0.0",
"@gasol/test-runner": "workspace:^1.0.0",
"@gasol/tsconfig": "workspace:^1.0.0",
"@types/node": "^22.7.4",
"@gasol/eslint-config": "workspace:^",
"@gasol/test-runner": "workspace:^",
"@gasol/tsconfig": "workspace:^",
"prettier": "^3.3.3",
"typescript": "^5.5.4"
"typescript": "^5.6.2"
}
}
10 changes: 10 additions & 0 deletions libraries/adb/src/adb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ export interface Closeable {
close(): ValueOrPromise<void>;
}

/**
* Represents an ADB socket.
*
* [Online Documentation](https://docs.tangoapp.dev/api/socket/)
*/
export interface AdbSocket
extends ReadableWritablePair<Uint8Array, MaybeConsumable<Uint8Array>>,
Closeable {
Expand Down Expand Up @@ -105,6 +110,11 @@ export class Adb implements Closeable {
);
}

/**
* Creates a new ADB Socket to the specified service or socket address.
*
* [Online Documentation](https://docs.tangoapp.dev/api/socket/#forward-tunnel)
*/
async createSocket(service: string): Promise<AdbSocket> {
return this.transport.connect(service);
}
Expand Down
14 changes: 8 additions & 6 deletions libraries/adb/src/banner.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import type { AdbFeature } from "./features.js";

export enum AdbBannerKey {
Product = "ro.product.name",
Model = "ro.product.model",
Device = "ro.product.device",
Features = "features",
}
export const AdbBannerKey = {
Product: "ro.product.name",
Model: "ro.product.model",
Device: "ro.product.device",
Features: "features",
} as const;

export type AdbBannerKey = (typeof AdbBannerKey)[keyof typeof AdbBannerKey];

export class AdbBanner {
static parse(banner: string) {
Expand Down
Loading

0 comments on commit 0345719

Please sign in to comment.