@weapp-vite/devtools-runtime 0.6.0 → 0.7.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/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { AutomatorElement, AutomatorMiniProgram, AutomatorPage, DevtoolsConnectionInput, DevtoolsContext, DevtoolsElementSnapshot, DevtoolsInstallationContext, DevtoolsPageSnapshot, DevtoolsRuntimeHooks, DevtoolsRuntimeSessionOptions, DevtoolsToolResult, MiniProgramElementLike, readDevtoolsElementSnapshot, resolveDevtoolsProjectPath, resolveDevtoolsWorkspacePath, toDevtoolsSerializableValue } from "./mcp.js";
2
- //#region src/lease.d.ts
3
2
  export interface RuntimeLease {
4
3
  root: string;
5
4
  token: string;
@@ -10,8 +9,6 @@ export interface RuntimeLease {
10
9
  export declare function acquireRuntimeLease(projectRoot: string): Promise<RuntimeLease>;
11
10
  export declare function runWithRuntimeLease<T>(lease: RuntimeLease, run: () => Promise<T>): Promise<T>;
12
11
  export declare function withRuntimeLease<T>(projectRoot: string, run: () => Promise<T>): Promise<T>;
13
- //#endregion
14
- //#region src/lease/directory.d.ts
15
12
  interface LeaseOwner {
16
13
  pid: number;
17
14
  token: string;
@@ -20,8 +17,6 @@ interface LeaseOwner {
20
17
  export declare function mutateLease<T>(directory: string, run: () => Promise<T>, options?: {
21
18
  timeoutMs?: number;
22
19
  }): Promise<T>;
23
- //#endregion
24
- //#region src/lease/machineRecoveryState.d.ts
25
20
  interface MachineE2ELeaseRecoveryScope {
26
21
  readonly id: string;
27
22
  readonly owner: Readonly<LeaseOwner>;
@@ -39,13 +34,9 @@ interface MachineE2ELeaseSnapshot {
39
34
  readonly scopes: readonly string[];
40
35
  }[];
41
36
  }
42
- //#endregion
43
- //#region src/lease/machineScopeRecovery.d.ts
44
37
  interface MachineE2ERecoverableDescendantScope extends MachineE2ELeaseRecoveryScope {
45
38
  readonly cleanupKey: string;
46
39
  }
47
- //#endregion
48
- //#region src/lease/machineScope.d.ts
49
40
  interface MachineE2EChildScopeOptions {
50
41
  /** 创建时绑定的清理标识;资源含义及准确归属由调用方核验,创建后不能更改。 */
51
42
  cleanupKey?: string;
@@ -59,8 +50,6 @@ interface MachineE2EChildScope {
59
50
  /** 仅接管已停止且有清理绑定的后代;回调成功后逐个完成,不代替本 scope 的清理。 */
60
51
  recoverStoppedDescendants: (run: (scope: MachineE2ERecoverableDescendantScope) => Promise<void>) => Promise<void>;
61
52
  }
62
- //#endregion
63
- //#region src/lease/machine.d.ts
64
53
  export interface MachineE2ELeaseOptions {
65
54
  /** 仅供隔离测试或嵌入方显式选择;不从工作目录或用户配置环境变量推导。 */
66
55
  stateDirectory?: string;
@@ -77,8 +66,6 @@ export interface MachineE2ELease {
77
66
  export declare function acquireMachineE2ELease(options?: MachineE2ELeaseOptions): Promise<MachineE2ELease>;
78
67
  /** 入口持有租约到清理完成;执行与释放同时失败时保留两者,嵌套入口仅释放自己的登记。 */
79
68
  export declare function withMachineE2ELease<T>(run: (lease: MachineE2ELease) => Promise<T>, options?: MachineE2ELeaseOptions): Promise<T>;
80
- //#endregion
81
- //#region src/lease/machineRecovery.d.ts
82
69
  export interface MachineE2ELeaseRecoveryOptions extends MachineE2ELeaseOptions {
83
70
  expected: MachineE2ELeaseSnapshot;
84
71
  /** 必须绑定已核验的资源日志并完成清理;仅此回调成功才允许完成对应 scope。 */
@@ -101,8 +88,6 @@ export declare function withMachineE2ELeaseRecoveryOperation<T>(scope: MachineE2
101
88
  * 接管中断保留原快照审计;进程崩溃留下的变更锁或混合归属不自动修复。
102
89
  */
103
90
  export declare function recoverMachineE2ELease(options: MachineE2ELeaseRecoveryOptions): Promise<MachineE2ELeaseRecoveryResult>;
104
- //#endregion
105
- //#region src/index.d.ts
106
91
  export interface MiniProgramEventMap {
107
92
  console: (payload: unknown) => void;
108
93
  exception: (payload: unknown) => void;
@@ -137,5 +122,4 @@ export declare function hasSharedMiniProgram(options: SharedMiniProgramSessionOp
137
122
  export declare function closeOwnedSharedMiniProgram(options: SharedMiniProgramSessionOptions, owned: unknown): Promise<void>;
138
123
  /** 单独保留管理器订阅,避免与正在执行的操作共享引用计数。 */
139
124
  export declare function retainSharedMiniProgram(sessionKey: string): void;
140
- //#endregion
141
125
  export { type AutomatorElement, type AutomatorMiniProgram, type AutomatorPage, type DevtoolsConnectionInput, type DevtoolsContext, type DevtoolsElementSnapshot, type DevtoolsInstallationContext, type DevtoolsPageSnapshot, type DevtoolsRuntimeHooks, type DevtoolsRuntimeSessionOptions, type DevtoolsToolResult, type MachineE2EChildScope, type MachineE2EChildScopeOptions, type MachineE2ELeaseRecoveryScope, type MachineE2ELeaseSnapshot, type MachineE2ERecoverableDescendantScope, type MiniProgramElementLike, readDevtoolsElementSnapshot, resolveDevtoolsProjectPath, resolveDevtoolsWorkspacePath, toDevtoolsSerializableValue };
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import path from "node:path";
7
7
  import process from "node:process";
8
8
  import { setTimeout } from "node:timers/promises";
9
9
  import { isDeepStrictEqual } from "node:util";
10
- //#region src/lease/machineScopeState.ts
10
+ // src/lease/machineScopeState.ts
11
11
  /** 未完成的本租约命令不能因持有进程退出而被新验收直接接管。 */
12
12
  async function assertNoIncompleteMachineScopes(directory) {
13
13
  const scopes = path.join(directory, "scopes");
@@ -20,8 +20,7 @@ async function assertNoIncompleteMachineScopes(directory) {
20
20
  if (!record || typeof record !== "object" || !("sealed" in record) || record.sealed !== true || !("completed" in record) || record.completed !== true) throw new Error("Runtime busy: an E2E command scope has unfinished cleanup; preserve the machine lease and its journals.");
21
21
  }
22
22
  }
23
- //#endregion
24
- //#region src/lease/directory.ts
23
+ // src/lease/directory.ts
25
24
  function isProcessAlive(pid) {
26
25
  try {
27
26
  process.kill(pid, 0);
@@ -134,8 +133,7 @@ async function acquireDirectoryLease(directory, busyMessage) {
134
133
  };
135
134
  return lease;
136
135
  }
137
- //#endregion
138
- //#region src/lease.ts
136
+ // src/lease.ts
139
137
  const currentLease = new AsyncLocalStorage();
140
138
  /** 同一真实工程跨进程互斥;未知持有者不自动回收。 */
141
139
  async function acquireRuntimeLease(projectRoot) {
@@ -166,8 +164,7 @@ async function withRuntimeLease(projectRoot, run) {
166
164
  await lease.release();
167
165
  }
168
166
  }
169
- //#endregion
170
- //#region src/lease/machineRecoveryState.ts
167
+ // src/lease/machineRecoveryState.ts
171
168
  async function assertRecoveryNode(file, kind) {
172
169
  const stat = await lstat(file);
173
170
  if (stat.isSymbolicLink() || (kind === "directory" ? !stat.isDirectory() : !stat.isFile() || stat.nlink !== 1)) throw new Error("Machine lease recovery refuses redirected or non-regular filesystem entries.");
@@ -254,8 +251,7 @@ function recoveryScopeCopy(scope) {
254
251
  ancestors: Object.freeze([...scope.ancestors])
255
252
  });
256
253
  }
257
- //#endregion
258
- //#region src/lease/machineScopeRecovery.ts
254
+ // src/lease/machineScopeRecovery.ts
259
255
  const activeRecoveries = /* @__PURE__ */ new Map();
260
256
  /** 活借用登记阻止跨进程接管;进程内保留的父子能力还需防止重叠回调。 */
261
257
  function claimSubtree(directory, credential) {
@@ -345,8 +341,7 @@ async function recoverStoppedDescendantScopes(directory, credential, run) {
345
341
  releaseClaim();
346
342
  }
347
343
  }
348
- //#endregion
349
- //#region src/lease/machineScope.ts
344
+ // src/lease/machineScope.ts
350
345
  const INHERITED_LEASE_ENV = "WEAPP_VITE_E2E_MACHINE_LEASE";
351
346
  const UUID = /^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/i;
352
347
  function invalid() {
@@ -485,8 +480,7 @@ async function createMachineChildScope(directory, credential, isHeld, options =
485
480
  })
486
481
  };
487
482
  }
488
- //#endregion
489
- //#region src/lease/machineContext.ts
483
+ // src/lease/machineContext.ts
490
484
  const currentMachineLease = new AsyncLocalStorage();
491
485
  const publishedCredentials = /* @__PURE__ */ new WeakMap();
492
486
  function machineStateDirectory(options) {
@@ -541,8 +535,7 @@ async function withMachineLeaseContext(lease, run, options) {
541
535
  restore();
542
536
  }
543
537
  }
544
- //#endregion
545
- //#region src/lease/machine.ts
538
+ // src/lease/machine.ts
546
539
  /** 同机同用户的所有 E2E 共用一个租约,子进程凭磁盘核验过的能力票据借用。 */
547
540
  async function acquireMachineE2ELease(options = {}) {
548
541
  const state = machineStateDirectory(options);
@@ -643,8 +636,7 @@ async function withMachineE2ELease(run, options = {}) {
643
636
  if (!entered) await release();
644
637
  }
645
638
  }
646
- //#endregion
647
- //#region src/lease/machineRecovery.ts
639
+ // src/lease/machineRecovery.ts
648
640
  const currentRecovery = new AsyncLocalStorage();
649
641
  /** 读取供显式恢复核对的精确登记快照,不修改租约或推导资源清理权限。 */
650
642
  async function readMachineE2ELeaseSnapshot(options = {}) {
@@ -814,8 +806,7 @@ async function recoverMachineE2ELease(options) {
814
806
  throw error;
815
807
  }
816
808
  }
817
- //#endregion
818
- //#region src/index.ts
809
+ // src/index.ts
819
810
  const sharedMiniProgramSessions = /* @__PURE__ */ new Map();
820
811
  function normalizeError(hooks, error) {
821
812
  const normalized = hooks.normalizeConnectionError?.(error) ?? error;
@@ -990,5 +981,4 @@ function retainSharedMiniProgram(sessionKey) {
990
981
  const entry = sharedMiniProgramSessions.get(sessionKey);
991
982
  if (entry) entry.refs += 1;
992
983
  }
993
- //#endregion
994
984
  export { acquireMachineE2ELease, acquireRuntimeLease, acquireSharedMiniProgram, assertMachineE2ELeaseRecoveryScope, closeOwnedSharedMiniProgram, closeSharedMiniProgram, getSharedMiniProgramSessionCount, hasSharedMiniProgram, mutateLease, readDevtoolsElementSnapshot, readMachineE2ELeaseSnapshot, recoverMachineE2ELease, releaseSharedMiniProgram, releaseSharedMiniProgramByKey, resolveDevtoolsProjectPath, resolveDevtoolsWorkspacePath, resolveSharedMiniProgramSessionKey, retainSharedMiniProgram, runWithRuntimeLease, toDevtoolsSerializableValue, withMachineE2ELease, withMachineE2ELeaseRecoveryOperation, withMiniProgram, withRuntimeLease };
package/dist/mcp.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { Element, MiniProgram, Page } from "@weapp-vite/miniprogram-automator";
2
- //#region src/mcp.d.ts
3
2
  export type AutomatorMiniProgram = InstanceType<typeof MiniProgram> & {
4
3
  callWxMethod?: (method: string, ...args: unknown[]) => Promise<unknown>;
5
4
  enableLog?: (timeout?: number) => Promise<void>;
@@ -84,5 +83,4 @@ export interface MiniProgramElementLike {
84
83
  export declare function resolveDevtoolsProjectPath(workspaceRoot: string, projectPath: string): string;
85
84
  export declare function resolveDevtoolsWorkspacePath(workspaceRoot: string, filePath: string): string;
86
85
  export declare function toDevtoolsSerializableValue(value: unknown): unknown;
87
- export declare function readDevtoolsElementSnapshot(element: MiniProgramElementLike, selector: string, attributeNames?: readonly string[], styleNames?: readonly string[]): Promise<DevtoolsElementSnapshot>;
88
- //#endregion
86
+ export declare function readDevtoolsElementSnapshot(element: MiniProgramElementLike, selector: string, attributeNames?: readonly string[], styleNames?: readonly string[]): Promise<DevtoolsElementSnapshot>;
package/dist/mcp.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import path from "node:path";
2
2
  import { Buffer } from "node:buffer";
3
- //#region src/mcp.ts
3
+ // src/mcp.ts
4
4
  function resolveDevtoolsProjectPath(workspaceRoot, projectPath) {
5
5
  return path.isAbsolute(projectPath) ? path.normalize(projectPath) : path.resolve(workspaceRoot, projectPath);
6
6
  }
@@ -58,5 +58,4 @@ async function readDevtoolsElementSnapshot(element, selector, attributeNames = [
58
58
  outerWxml: typeof outerWxml === "string" ? outerWxml : null
59
59
  };
60
60
  }
61
- //#endregion
62
61
  export { readDevtoolsElementSnapshot, resolveDevtoolsProjectPath, resolveDevtoolsWorkspacePath, toDevtoolsSerializableValue };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@weapp-vite/devtools-runtime",
3
3
  "type": "module",
4
- "version": "0.6.0",
4
+ "version": "0.7.0",
5
5
  "description": "Shared WeChat DevTools runtime automation helpers for weapp-vite packages",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -42,14 +42,14 @@
42
42
  "dist"
43
43
  ],
44
44
  "engines": {
45
- "node": "^20.19.0 || >=22.12.0"
45
+ "node": "^22.23.4 || ^24.22.1 || >=26.12.1"
46
46
  },
47
47
  "publishConfig": {
48
48
  "access": "public",
49
49
  "registry": "https://registry.npmjs.org"
50
50
  },
51
51
  "dependencies": {
52
- "@weapp-vite/miniprogram-automator": "1.4.0"
52
+ "@weapp-vite/miniprogram-automator": "1.5.0"
53
53
  },
54
54
  "scripts": {
55
55
  "dev": "tsdown -w --sourcemap",