@midscene/android-playground 1.0.1-beta-20251202112442.0 → 1.0.1-beta-20251202152706.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 +20 -20
- package/dist/lib/bin.js +430 -473
- package/package.json +6 -6
- package/static/index.html +1 -1
- package/static/static/css/index.d686b8b9.css.map +1 -1
- package/static/static/js/index.c9fbbbbd.js +10 -0
- package/static/static/js/index.c9fbbbbd.js.map +1 -0
- package/static/static/js/index.d0876963.js +0 -10
- package/static/static/js/index.d0876963.js.map +0 -1
- /package/static/static/js/{index.d0876963.js.LICENSE.txt → index.c9fbbbbd.js.LICENSE.txt} +0 -0
package/dist/es/bin.mjs
CHANGED
|
@@ -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
|
});
|
|
@@ -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++;
|
|
@@ -408,18 +408,18 @@ async function getAdbDevices() {
|
|
|
408
408
|
}
|
|
409
409
|
}
|
|
410
410
|
async function selectDevice() {
|
|
411
|
-
console.log(
|
|
411
|
+
console.log('🔍 Scanning for Android devices...');
|
|
412
412
|
const devices = await getAdbDevices();
|
|
413
413
|
if (0 === devices.length) {
|
|
414
|
-
console.error(
|
|
415
|
-
console.log(
|
|
416
|
-
console.log(
|
|
417
|
-
console.log(
|
|
418
|
-
console.log(
|
|
414
|
+
console.error('❌ No Android devices found!');
|
|
415
|
+
console.log('📱 Please ensure:');
|
|
416
|
+
console.log(' • Your device is connected via USB');
|
|
417
|
+
console.log(' • USB debugging is enabled');
|
|
418
|
+
console.log(' • Device is authorized for debugging');
|
|
419
419
|
process.exit(1);
|
|
420
420
|
}
|
|
421
421
|
if (1 === devices.length) {
|
|
422
|
-
console.log(
|
|
422
|
+
console.log(`📱 Found device: ${devices[0].name} (${devices[0].id})`);
|
|
423
423
|
return devices[0].id;
|
|
424
424
|
}
|
|
425
425
|
const choices = devices.map((device)=>({
|
|
@@ -427,7 +427,7 @@ async function selectDevice() {
|
|
|
427
427
|
value: device.id
|
|
428
428
|
}));
|
|
429
429
|
const selectedDevice = await prompts_select({
|
|
430
|
-
message:
|
|
430
|
+
message: '📱 Multiple devices found. Please select one:',
|
|
431
431
|
choices
|
|
432
432
|
});
|
|
433
433
|
return selectedDevice;
|
|
@@ -437,7 +437,7 @@ const main = async ()=>{
|
|
|
437
437
|
const { default: open } = await import("open");
|
|
438
438
|
try {
|
|
439
439
|
const selectedDeviceId = await selectDevice();
|
|
440
|
-
console.log(
|
|
440
|
+
console.log(`✅ Selected device: ${selectedDeviceId}`);
|
|
441
441
|
const playgroundServer = new PlaygroundServer(async ()=>{
|
|
442
442
|
const device = new AndroidDevice(selectedDeviceId);
|
|
443
443
|
await device.connect();
|
|
@@ -445,21 +445,21 @@ const main = async ()=>{
|
|
|
445
445
|
}, staticDir);
|
|
446
446
|
const scrcpyServer = new ScrcpyServer();
|
|
447
447
|
scrcpyServer.currentDeviceId = selectedDeviceId;
|
|
448
|
-
console.log(
|
|
448
|
+
console.log('🚀 Starting servers...');
|
|
449
449
|
const availablePlaygroundPort = await findAvailablePort(PLAYGROUND_SERVER_PORT);
|
|
450
450
|
const availableScrcpyPort = await findAvailablePort(SCRCPY_SERVER_PORT);
|
|
451
|
-
if (availablePlaygroundPort !== PLAYGROUND_SERVER_PORT) console.log(
|
|
452
|
-
if (availableScrcpyPort !== SCRCPY_SERVER_PORT) console.log(
|
|
451
|
+
if (availablePlaygroundPort !== PLAYGROUND_SERVER_PORT) console.log(`⚠️ Port ${PLAYGROUND_SERVER_PORT} is busy, using port ${availablePlaygroundPort} instead`);
|
|
452
|
+
if (availableScrcpyPort !== SCRCPY_SERVER_PORT) console.log(`⚠️ Port ${SCRCPY_SERVER_PORT} is busy, using port ${availableScrcpyPort} instead`);
|
|
453
453
|
await Promise.all([
|
|
454
454
|
playgroundServer.launch(availablePlaygroundPort),
|
|
455
455
|
scrcpyServer.launch(availableScrcpyPort)
|
|
456
456
|
]);
|
|
457
457
|
global.scrcpyServerPort = availableScrcpyPort;
|
|
458
458
|
console.log('');
|
|
459
|
-
console.log(
|
|
460
|
-
console.log(
|
|
461
|
-
console.log(
|
|
462
|
-
console.log(
|
|
459
|
+
console.log('✨ Midscene Android Playground is ready!');
|
|
460
|
+
console.log(`🎮 Playground: http://localhost:${playgroundServer.port}`);
|
|
461
|
+
console.log(`📱 Device: ${selectedDeviceId}`);
|
|
462
|
+
console.log(`🔑 Generated Server ID: ${playgroundServer.id}`);
|
|
463
463
|
console.log('');
|
|
464
464
|
open(`http://localhost:${playgroundServer.port}`);
|
|
465
465
|
} catch (error) {
|