ms-vite-plugin 1.1.9 → 1.1.10

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/mcp/tools.js CHANGED
@@ -808,7 +808,7 @@ function registerRuntimeTools(server) {
808
808
  logModeNotice = startBackgroundContinuousLogWatch(logDevice.ip, logDevice.port, logMaxLogs);
809
809
  }
810
810
  else {
811
- logPromise = (0, project_1.watchDeviceLogsBySse)(logDevice.ip, logDevice.port, 0, logMaxLogs, true);
811
+ logPromise = (0, project_1.watchDeviceLogsBySse)(logDevice.ip, logDevice.port, 0, logMaxLogs, true, true);
812
812
  }
813
813
  }
814
814
  catch (error) {
@@ -838,7 +838,11 @@ function registerRuntimeTools(server) {
838
838
  let logSection = "";
839
839
  if (logPromise) {
840
840
  const result = await logPromise;
841
- logSection = `\n\n${formatRunLogSection(logDeviceIp, logDevicePort, result)}`;
841
+ const sections = [formatRunLogSection(logDeviceIp, logDevicePort, result)];
842
+ if (result.stopReason === "runtime_continuous") {
843
+ sections.push(startBackgroundContinuousLogWatch(logDeviceIp, logDevicePort, logMaxLogs));
844
+ }
845
+ logSection = `\n\n${sections.join("\n")}`;
842
846
  }
843
847
  else if (logModeNotice) {
844
848
  logSection = `\n\n${logModeNotice}`;
package/dist/project.d.ts CHANGED
@@ -38,7 +38,7 @@ export interface DeviceLogWatchResult {
38
38
  /** 收集到的 runtime_status 条目 */
39
39
  runtimeStatus: DeviceRuntimeStatusEntry[];
40
40
  /** 监听结束原因 */
41
- stopReason: "timeout" | "runtime_stopped" | "stream_closed" | "manual_abort" | "unknown";
41
+ stopReason: "timeout" | "runtime_continuous" | "runtime_stopped" | "stream_closed" | "manual_abort" | "unknown";
42
42
  }
43
43
  /**
44
44
  * 在设备上获取截图 JPG 二进制数据(HTTP)
@@ -73,11 +73,12 @@ export declare function getSourceOnDevice(options: DeviceCliOptions, maxDepth?:
73
73
  * @param durationMs 监听时长(毫秒),默认 15000;传 0 表示不设超时,持续监听
74
74
  * @param maxLogs 最多收集日志条数,默认 200
75
75
  * @param stopOnRuntimeStopped 若为 true,则在运行状态从 true 回落到 false 后结束监听
76
+ * @param stopOnRuntimeContinuous 若为 true,则在确认持续运行态后结束监听(用于 single 模式快速返回)
76
77
  * @returns 返回日志与运行状态
77
78
  * @example
78
- * const result = await watchDeviceLogsBySse("192.168.1.10", 9800, 30000, 300, true)
79
+ * const result = await watchDeviceLogsBySse("192.168.1.10", 9800, 30000, 300, true, true)
79
80
  */
80
- export declare function watchDeviceLogsBySse(ip: string, port: number, durationMs?: number, maxLogs?: number, stopOnRuntimeStopped?: boolean): Promise<DeviceLogWatchResult>;
81
+ export declare function watchDeviceLogsBySse(ip: string, port: number, durationMs?: number, maxLogs?: number, stopOnRuntimeStopped?: boolean, stopOnRuntimeContinuous?: boolean): Promise<DeviceLogWatchResult>;
81
82
  /**
82
83
  * 在设备上运行项目(先同步后运行)
83
84
  * @param options 命令选项
package/dist/project.js CHANGED
@@ -516,11 +516,12 @@ function normalizeLogEntry(payload) {
516
516
  * @param durationMs 监听时长(毫秒),默认 15000;传 0 表示不设超时,持续监听
517
517
  * @param maxLogs 最多收集日志条数,默认 200
518
518
  * @param stopOnRuntimeStopped 若为 true,则在运行状态从 true 回落到 false 后结束监听
519
+ * @param stopOnRuntimeContinuous 若为 true,则在确认持续运行态后结束监听(用于 single 模式快速返回)
519
520
  * @returns 返回日志与运行状态
520
521
  * @example
521
- * const result = await watchDeviceLogsBySse("192.168.1.10", 9800, 30000, 300, true)
522
+ * const result = await watchDeviceLogsBySse("192.168.1.10", 9800, 30000, 300, true, true)
522
523
  */
523
- async function watchDeviceLogsBySse(ip, port, durationMs = 15000, maxLogs = 200, stopOnRuntimeStopped = false) {
524
+ async function watchDeviceLogsBySse(ip, port, durationMs = 15000, maxLogs = 200, stopOnRuntimeStopped = false, stopOnRuntimeContinuous = false) {
524
525
  if (!ip.trim()) {
525
526
  throw new Error("监听日志失败: 设备 IP 不能为空");
526
527
  }
@@ -539,6 +540,7 @@ async function watchDeviceLogsBySse(ip, port, durationMs = 15000, maxLogs = 200,
539
540
  const controller = new AbortController();
540
541
  let stopReason = "unknown";
541
542
  let seenRunningStatus = false;
543
+ let runningStatusCount = 0;
542
544
  const timeoutHandle = durationMs > 0
543
545
  ? setTimeout(() => {
544
546
  stopReason = "timeout";
@@ -594,6 +596,16 @@ async function watchDeviceLogsBySse(ip, port, durationMs = 15000, maxLogs = 200,
594
596
  });
595
597
  if (parsed.isRunning === true) {
596
598
  seenRunningStatus = true;
599
+ runningStatusCount += 1;
600
+ // 连续收到运行态,视为长期任务,single 模式可立即返回并转持续监听
601
+ if (stopOnRuntimeContinuous && runningStatusCount >= 2) {
602
+ stopReason = "runtime_continuous";
603
+ controller.abort();
604
+ break;
605
+ }
606
+ }
607
+ else if (parsed.isRunning === false) {
608
+ runningStatusCount = 0;
597
609
  }
598
610
  if (stopOnRuntimeStopped &&
599
611
  seenRunningStatus &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ms-vite-plugin",
3
- "version": "1.1.9",
3
+ "version": "1.1.10",
4
4
  "type": "commonjs",
5
5
  "license": "MIT",
6
6
  "publishConfig": {