dsh-mobilecode 0.6.0 → 0.6.1

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.
@@ -912,6 +912,31 @@ export function parseCpuinfo(output) {
912
912
  return { cores: cores > 0 ? cores : undefined, hardware }
913
913
  }
914
914
 
915
+ /**
916
+ * Deep-clean a parsed value for a DSH tool output: drop `undefined` keys (and
917
+ * undefined array holes) and turn non-finite numbers into `null`, so the value
918
+ * round-trips JSON losslessly (DSH rejects outputs that lose keys/values on
919
+ * serialize). Leaves everything else untouched; primitives pass through.
920
+ */
921
+ export function jsonSafe(value) {
922
+ if (Array.isArray(value)) {
923
+ const out = []
924
+ for (const item of value) {
925
+ if (item !== undefined) out.push(jsonSafe(item))
926
+ }
927
+ return out
928
+ }
929
+ if (value !== null && typeof value === "object") {
930
+ const out = {}
931
+ for (const [key, item] of Object.entries(value)) {
932
+ if (item !== undefined) out[key] = jsonSafe(item)
933
+ }
934
+ return out
935
+ }
936
+ if (typeof value === "number" && !Number.isFinite(value)) return null
937
+ return value
938
+ }
939
+
915
940
  /** Parse `dumpsys package <pkg>` into {versionName, versionCode, minSdk, targetSdk, permissions, activities}. */
916
941
  export function parseAppInfo(output, packageName) {
917
942
  const text = String(output)
package/lib/index.js CHANGED
@@ -1199,12 +1199,12 @@ function devicePerfTool() {
1199
1199
  DeviceBuild.adbRun(serial, ['shell', 'dumpsys', 'battery']).catch(() => ''),
1200
1200
  DeviceBuild.adbRun(serial, ['shell', 'cat', '/proc/cpuinfo']).catch(() => ''),
1201
1201
  ])
1202
- return {
1202
+ return DeviceBuild.jsonSafe({
1203
1203
  serial,
1204
1204
  memory: DeviceBuild.parseMeminfo(meminfo),
1205
1205
  battery: parseBatteryShaped(battery),
1206
1206
  cpu: DeviceBuild.parseCpuinfo(cpuinfo),
1207
- }
1207
+ })
1208
1208
  },
1209
1209
  })
1210
1210
  }
@@ -1257,7 +1257,7 @@ function deviceAppInfoTool() {
1257
1257
  const output = await DeviceBuild.adbRun(serial, ['shell', 'dumpsys', 'package', pkg])
1258
1258
  const info = DeviceBuild.parseAppInfo(output, pkg)
1259
1259
  if (info.versionName === undefined) throw new Error(`package ${pkg} is not installed (dumpsys package returned nothing for it) — run device_apps to list what is.`)
1260
- return info
1260
+ return DeviceBuild.jsonSafe(info)
1261
1261
  },
1262
1262
  })
1263
1263
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-mobilecode",
3
3
  "description": "MobileCode for the dsh web GUI: detect iOS/Android projects, run preview servers, and drive the simulator/emulator from the session — 24 agent tools (device_run, device_screen, device_ui_tree, device_tap_element, device_wait_for, device_scroll_to, device_input, device_intent, device_connect, device_pair_qr, device_perf, device_app_info, device_install, device_uninstall, device_reboot, device_log, live screen stream, multimodal screenshots) with one classified adb boundary and a Wi-Fi connect/pair QR flow in the Connection settings tab. Hot-pluggable — mounted via the profile bundle list + cordis.patch.yml, no dsh source changes.",
4
- "version": "0.6.0",
4
+ "version": "0.6.1",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@11.22.0",
7
7
  "engines": {