@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 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: ${(null == error ? void 0 : error.message) || 'Unknown error'}`
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 (null == scrcpyClient ? void 0 : scrcpyClient.controller) socket.emit('control-ready');
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: ${(null == error ? void 0 : error.message) || 'Unknown error'}`
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(`\u{274C} Unable to find available port after ${maxAttempts} attempts starting from ${startPort}`);
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("\uD83D\uDD0D Scanning for Android devices...");
411
+ console.log('🔍 Scanning for Android devices...');
412
412
  const devices = await getAdbDevices();
413
413
  if (0 === devices.length) {
414
- console.error("\u274C No Android devices found!");
415
- console.log("\uD83D\uDCF1 Please ensure:");
416
- console.log(" \u2022 Your device is connected via USB");
417
- console.log(" \u2022 USB debugging is enabled");
418
- console.log(" \u2022 Device is authorized for debugging");
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(`\u{1F4F1} Found device: ${devices[0].name} (${devices[0].id})`);
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: "\uD83D\uDCF1 Multiple devices found. Please select one:",
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(`\u{2705} Selected device: ${selectedDeviceId}`);
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("\uD83D\uDE80 Starting servers...");
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(`\u{26A0}\u{FE0F} Port ${PLAYGROUND_SERVER_PORT} is busy, using port ${availablePlaygroundPort} instead`);
452
- if (availableScrcpyPort !== SCRCPY_SERVER_PORT) console.log(`\u{26A0}\u{FE0F} Port ${SCRCPY_SERVER_PORT} is busy, using port ${availableScrcpyPort} instead`);
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("\u2728 Midscene Android Playground is ready!");
460
- console.log(`\u{1F3AE} Playground: http://localhost:${playgroundServer.port}`);
461
- console.log(`\u{1F4F1} Device: ${selectedDeviceId}`);
462
- console.log(`\u{1F511} Generated Server ID: ${playgroundServer.id}`);
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) {