@midscene/android-playground 1.0.1-beta-20251202152706.0 → 1.0.1-beta-20251203125942.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/dist/es/bin.mjs CHANGED
@@ -3,7 +3,7 @@ import { createServer } from "node:net";
3
3
  import node_path from "node:path";
4
4
  import { promisify } from "node:util";
5
5
  import { select as prompts_select } from "@inquirer/prompts";
6
- import { AndroidAgent, AndroidDevice } from "@midscene/android";
6
+ import { AndroidAgent, AndroidDevice, getConnectedDevices } from "@midscene/android";
7
7
  import { PlaygroundServer } from "@midscene/playground";
8
8
  import { PLAYGROUND_SERVER_PORT, SCRCPY_SERVER_PORT } from "@midscene/shared/constants";
9
9
  import { createReadStream } from "node:fs";
@@ -363,7 +363,7 @@ class ScrcpyServer {
363
363
  this.setupApiRoutes();
364
364
  }
365
365
  }
366
- const bin_promiseExec = promisify(exec);
366
+ promisify(exec);
367
367
  async function isPortAvailable(port) {
368
368
  return new Promise((resolve)=>{
369
369
  const server = createServer();
@@ -389,19 +389,12 @@ async function findAvailablePort(startPort) {
389
389
  }
390
390
  async function getAdbDevices() {
391
391
  try {
392
- await bin_promiseExec('adb start-server');
393
- const { stdout } = await bin_promiseExec('adb devices');
394
- const lines = stdout.trim().split('\n').slice(1);
395
- const devices = lines.map((line)=>{
396
- const parts = line.trim().split('\t');
397
- if (parts.length >= 2) return {
398
- id: parts[0],
399
- status: parts[1],
400
- name: parts[0]
401
- };
402
- return null;
403
- }).filter((device)=>null !== device && 'device' === device.status);
404
- return devices;
392
+ const devices = await getConnectedDevices();
393
+ return devices.filter((device)=>'device' === device.state).map((device)=>({
394
+ id: device.udid,
395
+ status: device.state,
396
+ name: device.udid
397
+ }));
405
398
  } catch (error) {
406
399
  console.error('Error getting ADB devices:', error);
407
400
  return [];
package/dist/lib/bin.js CHANGED
@@ -389,7 +389,7 @@ class ScrcpyServer {
389
389
  this.setupApiRoutes();
390
390
  }
391
391
  }
392
- const bin_promiseExec = (0, external_node_util_namespaceObject.promisify)(external_node_child_process_namespaceObject.exec);
392
+ (0, external_node_util_namespaceObject.promisify)(external_node_child_process_namespaceObject.exec);
393
393
  async function isPortAvailable(port) {
394
394
  return new Promise((resolve)=>{
395
395
  const server = (0, external_node_net_namespaceObject.createServer)();
@@ -415,19 +415,12 @@ async function findAvailablePort(startPort) {
415
415
  }
416
416
  async function getAdbDevices() {
417
417
  try {
418
- await bin_promiseExec('adb start-server');
419
- const { stdout } = await bin_promiseExec('adb devices');
420
- const lines = stdout.trim().split('\n').slice(1);
421
- const devices = lines.map((line)=>{
422
- const parts = line.trim().split('\t');
423
- if (parts.length >= 2) return {
424
- id: parts[0],
425
- status: parts[1],
426
- name: parts[0]
427
- };
428
- return null;
429
- }).filter((device)=>null !== device && 'device' === device.status);
430
- return devices;
418
+ const devices = await (0, android_namespaceObject.getConnectedDevices)();
419
+ return devices.filter((device)=>'device' === device.state).map((device)=>({
420
+ id: device.udid,
421
+ status: device.state,
422
+ name: device.udid
423
+ }));
431
424
  } catch (error) {
432
425
  console.error('Error getting ADB devices:', error);
433
426
  return [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/android-playground",
3
- "version": "1.0.1-beta-20251202152706.0",
3
+ "version": "1.0.1-beta-20251203125942.0",
4
4
  "description": "Android playground for Midscene",
5
5
  "main": "./dist/lib/index.js",
6
6
  "types": "./dist/types/index.d.ts",
@@ -26,10 +26,10 @@
26
26
  "@inquirer/prompts": "^7.8.6",
27
27
  "open": "10.1.0",
28
28
  "socket.io": "^4.8.1",
29
- "@midscene/android": "1.0.1-beta-20251202152706.0",
30
- "@midscene/core": "1.0.1-beta-20251202152706.0",
31
- "@midscene/playground": "1.0.1-beta-20251202152706.0",
32
- "@midscene/shared": "1.0.1-beta-20251202152706.0"
29
+ "@midscene/core": "1.0.1-beta-20251203125942.0",
30
+ "@midscene/playground": "1.0.1-beta-20251203125942.0",
31
+ "@midscene/shared": "1.0.1-beta-20251203125942.0",
32
+ "@midscene/android": "1.0.1-beta-20251203125942.0"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@rslib/core": "^0.18.2",
package/static/index.html CHANGED
@@ -1 +1 @@
1
- <!doctype html><html><head><title>Midscene Android Playground</title><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><script defer src="/static/js/lib-react.d7dec362.js"></script><script defer src="/static/js/9.1bed77ad.js"></script><script defer src="/static/js/index.c9fbbbbd.js"></script><link href="/static/css/index.d686b8b9.css" rel="stylesheet"></head><body><div id="root"></div></body></html>
1
+ <!doctype html><html><head><title>Midscene Android Playground</title><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><script defer src="/static/js/lib-react.d7dec362.js"></script><script defer src="/static/js/9.1bed77ad.js"></script><script defer src="/static/js/index.1738123e.js"></script><link href="/static/css/index.d686b8b9.css" rel="stylesheet"></head><body><div id="root"></div></body></html>