openuispec 0.2.5 → 0.2.7

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.
@@ -210,6 +210,23 @@ export async function adbExec(adb: string, serial: string, args: string): Promis
210
210
  return stdout.trim();
211
211
  }
212
212
 
213
+ // ── emulator storage cleanup ─────────────────────────────────────────
214
+
215
+ export async function cleanEmulatorStorage(adb: string, serial: string): Promise<void> {
216
+ try {
217
+ // Clear package manager cache
218
+ await adbShell(adb, serial, `pm trim-caches 512M`);
219
+ } catch { /* may require root, skip */ }
220
+ try {
221
+ // Remove leftover screenshot/temp files
222
+ await adbShell(adb, serial, `rm -f /sdcard/openuispec_screenshot.png /sdcard/ui_dump.xml /sdcard/screenshot.png`);
223
+ } catch { /* ignore */ }
224
+ try {
225
+ // Clear temp files
226
+ await adbShell(adb, serial, `rm -rf /data/local/tmp/*.apk`);
227
+ } catch { /* ignore */ }
228
+ }
229
+
213
230
  // ── build APK ───────────────────────────────────────────────────────
214
231
 
215
232
  export async function buildApk(androidDir: string, moduleName: string): Promise<string> {
@@ -259,11 +276,11 @@ export async function installAndLaunch(
259
276
  await adbShell(adb, serial, `am force-stop ${appInfo.applicationId}`);
260
277
 
261
278
  if (route) {
262
- // Navigate via deep link
263
- await adbShell(adb, serial, `am start -a android.intent.action.VIEW -d "${route}" ${appInfo.applicationId}`);
279
+ // Navigate via deep link — must specify component explicitly
280
+ await adbShell(adb, serial, `am start -W -a android.intent.action.VIEW -d "${route}" ${appInfo.applicationId}/${appInfo.launchActivity}`);
264
281
  } else {
265
282
  // Launch the main activity
266
- await adbShell(adb, serial, `am start -n ${appInfo.applicationId}/${appInfo.launchActivity}`);
283
+ await adbShell(adb, serial, `am start -W -n ${appInfo.applicationId}/${appInfo.launchActivity}`);
267
284
  }
268
285
  }
269
286
 
@@ -405,26 +422,29 @@ export async function takeAndroidScreenshot(
405
422
  const adb = findAdb();
406
423
  const serial = await getConnectedEmulator(adb);
407
424
 
408
- // 3. Build APK
425
+ // 3. Free emulator storage before build/install
426
+ await cleanEmulatorStorage(adb, serial);
427
+
428
+ // 4. Build APK
409
429
  const apkPath = await buildApk(androidDir, appInfo.moduleName);
410
430
 
411
- // 4. Set theme if requested
431
+ // 5. Set theme if requested
412
432
  if (theme) {
413
433
  await setTheme(adb, serial, theme);
414
434
  }
415
435
 
416
- // 5. Install and launch
436
+ // 6. Install and launch
417
437
  await installAndLaunch(adb, serial, apkPath, appInfo, route);
418
438
 
419
- // 6. Wait for app to be ready and content to load
439
+ // 7. Wait for app to be ready and content to load
420
440
  await waitForAppReady(adb, serial, appInfo.applicationId, wait_for);
421
441
 
422
- // 7. Navigate via UI taps if specified
442
+ // 8. Navigate via UI taps if specified
423
443
  if (nav && nav.length > 0) {
424
444
  await navigateByTaps(adb, serial, nav);
425
445
  }
426
446
 
427
- // 8. Capture screenshot
447
+ // 9. Capture screenshot
428
448
  const screenLabel = screen ?? "main";
429
449
  const themeLabel = theme ?? "default";
430
450
  const filename = `${screenLabel}_${themeLabel}.png`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openuispec",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "A semantic UI specification format for AI-native, platform-native app development",