@midscene/android-playground 0.30.10 → 0.30.11-beta-20251218071621.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 +28 -35
- package/dist/lib/bin.js +424 -474
- package/package.json +7 -7
- package/static/index.html +1 -1
- package/static/static/css/index.3784ddf6.css +2 -0
- package/static/static/css/index.3784ddf6.css.map +1 -0
- package/static/static/js/861.1a36955c.js +641 -0
- package/static/static/js/{374.e8fd2f39.js.LICENSE.txt → 861.1a36955c.js.LICENSE.txt} +2 -4
- package/static/static/js/861.1a36955c.js.map +1 -0
- package/static/static/js/async/195.05312dd9.js +3 -0
- package/static/static/js/async/195.05312dd9.js.map +1 -0
- package/static/static/js/async/{702.1f38a17e.js → 199.de925865.js} +17 -17
- package/static/static/js/async/199.de925865.js.map +1 -0
- package/static/static/js/async/221.213edee4.js +21 -0
- package/static/static/js/async/221.213edee4.js.map +1 -0
- package/static/static/js/async/271.1691b0d2.js +30 -0
- package/static/static/js/async/271.1691b0d2.js.map +1 -0
- package/static/static/js/async/35.918ea007.js +1 -0
- package/static/static/js/async/376.b7913581.js +2 -0
- package/static/static/js/async/376.b7913581.js.map +1 -0
- package/static/static/js/async/{644.910ce3d0.js → 467.9dc30840.js} +1 -1
- package/static/static/js/async/652.af2f1788.js +3 -0
- package/static/static/js/async/652.af2f1788.js.map +1 -0
- package/static/static/js/async/856.379e0ce3.js +158 -0
- package/static/static/js/async/{212.850ade70.js.map → 856.379e0ce3.js.map} +1 -1
- package/static/static/js/async/860.baac349b.js +2 -0
- package/static/static/js/async/860.baac349b.js.map +1 -0
- package/static/static/js/async/990.bb6496cd.js +26 -0
- package/static/static/js/async/990.bb6496cd.js.map +1 -0
- package/static/static/js/index.8764fe30.js +10 -0
- package/static/static/js/index.8764fe30.js.map +1 -0
- package/static/static/js/lib-react.574e3de9.js +3 -0
- package/static/static/js/lib-react.574e3de9.js.map +1 -0
- package/static/static/css/index.ea878c95.css +0 -2
- package/static/static/css/index.ea878c95.css.map +0 -1
- package/static/static/js/374.e8fd2f39.js +0 -650
- package/static/static/js/374.e8fd2f39.js.map +0 -1
- package/static/static/js/async/166.834644b5.js +0 -2
- package/static/static/js/async/166.834644b5.js.map +0 -1
- package/static/static/js/async/173.f2381e64.js +0 -3
- package/static/static/js/async/173.f2381e64.js.map +0 -1
- package/static/static/js/async/212.850ade70.js +0 -158
- package/static/static/js/async/329.261bc4a1.js +0 -26
- package/static/static/js/async/329.261bc4a1.js.map +0 -1
- package/static/static/js/async/364.d88c3cff.js +0 -30
- package/static/static/js/async/364.d88c3cff.js.map +0 -1
- package/static/static/js/async/544.18ac9afb.js +0 -2
- package/static/static/js/async/544.18ac9afb.js.map +0 -1
- package/static/static/js/async/582.8f4b5264.js +0 -21
- package/static/static/js/async/582.8f4b5264.js.map +0 -1
- package/static/static/js/async/624.8a1fe2e8.js +0 -3
- package/static/static/js/async/624.8a1fe2e8.js.map +0 -1
- package/static/static/js/async/659.d19e8c15.js +0 -21
- package/static/static/js/async/659.d19e8c15.js.map +0 -1
- package/static/static/js/async/702.1f38a17e.js.map +0 -1
- package/static/static/js/async/920.48d269c8.js +0 -2
- package/static/static/js/async/920.48d269c8.js.map +0 -1
- package/static/static/js/async/983.b98b40af.js +0 -1
- package/static/static/js/index.418b4242.js +0 -10
- package/static/static/js/index.418b4242.js.map +0 -1
- package/static/static/js/lib-react.c74a0742.js +0 -3
- package/static/static/js/lib-react.c74a0742.js.map +0 -1
- /package/static/static/js/{index.418b4242.js.LICENSE.txt → index.8764fe30.js.LICENSE.txt} +0 -0
- /package/static/static/js/{lib-react.c74a0742.js.LICENSE.txt → lib-react.574e3de9.js.LICENSE.txt} +0 -0
- /package/static/static/wasm/{9e906fbf55e08f98.module.wasm → 9e906fbf.module.wasm} +0 -0
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";
|
|
@@ -181,7 +181,7 @@ class ScrcpyServer {
|
|
|
181
181
|
} catch (error) {
|
|
182
182
|
console.error('failed to switch device:', error);
|
|
183
183
|
socket.emit('error', {
|
|
184
|
-
message: `Failed to switch device: ${
|
|
184
|
+
message: `Failed to switch device: ${error?.message || 'Unknown error'}`
|
|
185
185
|
});
|
|
186
186
|
}
|
|
187
187
|
});
|
|
@@ -266,11 +266,11 @@ class ScrcpyServer {
|
|
|
266
266
|
message: `Video stream processing error: ${error.message}`
|
|
267
267
|
});
|
|
268
268
|
}
|
|
269
|
-
if (
|
|
269
|
+
if (scrcpyClient?.controller) socket.emit('control-ready');
|
|
270
270
|
} catch (error) {
|
|
271
271
|
console.error('failed to connect device:', error);
|
|
272
272
|
socket.emit('error', {
|
|
273
|
-
message: `Failed to connect device: ${
|
|
273
|
+
message: `Failed to connect device: ${error?.message || 'Unknown error'}`
|
|
274
274
|
});
|
|
275
275
|
}
|
|
276
276
|
});
|
|
@@ -363,7 +363,7 @@ class ScrcpyServer {
|
|
|
363
363
|
this.setupApiRoutes();
|
|
364
364
|
}
|
|
365
365
|
}
|
|
366
|
-
|
|
366
|
+
promisify(exec);
|
|
367
367
|
async function isPortAvailable(port) {
|
|
368
368
|
return new Promise((resolve)=>{
|
|
369
369
|
const server = createServer();
|
|
@@ -380,7 +380,7 @@ async function findAvailablePort(startPort) {
|
|
|
380
380
|
while(!await isPortAvailable(port)){
|
|
381
381
|
attempts++;
|
|
382
382
|
if (attempts >= maxAttempts) {
|
|
383
|
-
console.error(
|
|
383
|
+
console.error(`❌ Unable to find available port after ${maxAttempts} attempts starting from ${startPort}`);
|
|
384
384
|
process.exit(1);
|
|
385
385
|
}
|
|
386
386
|
port++;
|
|
@@ -389,37 +389,30 @@ async function findAvailablePort(startPort) {
|
|
|
389
389
|
}
|
|
390
390
|
async function getAdbDevices() {
|
|
391
391
|
try {
|
|
392
|
-
await
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
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 [];
|
|
408
401
|
}
|
|
409
402
|
}
|
|
410
403
|
async function selectDevice() {
|
|
411
|
-
console.log(
|
|
404
|
+
console.log('🔍 Scanning for Android devices...');
|
|
412
405
|
const devices = await getAdbDevices();
|
|
413
406
|
if (0 === devices.length) {
|
|
414
|
-
console.error(
|
|
415
|
-
console.log(
|
|
416
|
-
console.log(
|
|
417
|
-
console.log(
|
|
418
|
-
console.log(
|
|
407
|
+
console.error('❌ No Android devices found!');
|
|
408
|
+
console.log('📱 Please ensure:');
|
|
409
|
+
console.log(' • Your device is connected via USB');
|
|
410
|
+
console.log(' • USB debugging is enabled');
|
|
411
|
+
console.log(' • Device is authorized for debugging');
|
|
419
412
|
process.exit(1);
|
|
420
413
|
}
|
|
421
414
|
if (1 === devices.length) {
|
|
422
|
-
console.log(
|
|
415
|
+
console.log(`📱 Found device: ${devices[0].name} (${devices[0].id})`);
|
|
423
416
|
return devices[0].id;
|
|
424
417
|
}
|
|
425
418
|
const choices = devices.map((device)=>({
|
|
@@ -427,7 +420,7 @@ async function selectDevice() {
|
|
|
427
420
|
value: device.id
|
|
428
421
|
}));
|
|
429
422
|
const selectedDevice = await prompts_select({
|
|
430
|
-
message:
|
|
423
|
+
message: '📱 Multiple devices found. Please select one:',
|
|
431
424
|
choices
|
|
432
425
|
});
|
|
433
426
|
return selectedDevice;
|
|
@@ -437,7 +430,7 @@ const main = async ()=>{
|
|
|
437
430
|
const { default: open } = await import("open");
|
|
438
431
|
try {
|
|
439
432
|
const selectedDeviceId = await selectDevice();
|
|
440
|
-
console.log(
|
|
433
|
+
console.log(`✅ Selected device: ${selectedDeviceId}`);
|
|
441
434
|
const playgroundServer = new PlaygroundServer(async ()=>{
|
|
442
435
|
const device = new AndroidDevice(selectedDeviceId);
|
|
443
436
|
await device.connect();
|
|
@@ -445,21 +438,21 @@ const main = async ()=>{
|
|
|
445
438
|
}, staticDir);
|
|
446
439
|
const scrcpyServer = new ScrcpyServer();
|
|
447
440
|
scrcpyServer.currentDeviceId = selectedDeviceId;
|
|
448
|
-
console.log(
|
|
441
|
+
console.log('🚀 Starting servers...');
|
|
449
442
|
const availablePlaygroundPort = await findAvailablePort(PLAYGROUND_SERVER_PORT);
|
|
450
443
|
const availableScrcpyPort = await findAvailablePort(SCRCPY_SERVER_PORT);
|
|
451
|
-
if (availablePlaygroundPort !== PLAYGROUND_SERVER_PORT) console.log(
|
|
452
|
-
if (availableScrcpyPort !== SCRCPY_SERVER_PORT) console.log(
|
|
444
|
+
if (availablePlaygroundPort !== PLAYGROUND_SERVER_PORT) console.log(`⚠️ Port ${PLAYGROUND_SERVER_PORT} is busy, using port ${availablePlaygroundPort} instead`);
|
|
445
|
+
if (availableScrcpyPort !== SCRCPY_SERVER_PORT) console.log(`⚠️ Port ${SCRCPY_SERVER_PORT} is busy, using port ${availableScrcpyPort} instead`);
|
|
453
446
|
await Promise.all([
|
|
454
447
|
playgroundServer.launch(availablePlaygroundPort),
|
|
455
448
|
scrcpyServer.launch(availableScrcpyPort)
|
|
456
449
|
]);
|
|
457
450
|
global.scrcpyServerPort = availableScrcpyPort;
|
|
458
451
|
console.log('');
|
|
459
|
-
console.log(
|
|
460
|
-
console.log(
|
|
461
|
-
console.log(
|
|
462
|
-
console.log(
|
|
452
|
+
console.log('✨ Midscene Android Playground is ready!');
|
|
453
|
+
console.log(`🎮 Playground: http://localhost:${playgroundServer.port}`);
|
|
454
|
+
console.log(`📱 Device: ${selectedDeviceId}`);
|
|
455
|
+
console.log(`🔑 Generated Server ID: ${playgroundServer.id}`);
|
|
463
456
|
console.log('');
|
|
464
457
|
open(`http://localhost:${playgroundServer.port}`);
|
|
465
458
|
} catch (error) {
|