@weapp-vite/devtools-runtime 0.5.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 +2 -18
- package/dist/index.js +62 -39
- package/dist/mcp.d.ts +1 -3
- package/dist/mcp.js +1 -2
- package/package.json +3 -3
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;
|
|
@@ -114,11 +99,11 @@ export declare function resolveSharedMiniProgramSessionKey(options: SharedMiniPr
|
|
|
114
99
|
*/
|
|
115
100
|
export declare function acquireSharedMiniProgram(hooks: DevtoolsRuntimeHooks, options: DevtoolsRuntimeSessionOptions): Promise<AutomatorMiniProgram>;
|
|
116
101
|
/** 使用创建连接时的精确键释放订阅。 */
|
|
117
|
-
export declare function releaseSharedMiniProgramByKey(sessionKey: string): void
|
|
102
|
+
export declare function releaseSharedMiniProgramByKey(sessionKey: string): Promise<void>;
|
|
118
103
|
/**
|
|
119
104
|
* @description 释放指定项目的共享会话引用;会话对象会继续缓存,直到显式关闭或重置。
|
|
120
105
|
*/
|
|
121
|
-
export declare function releaseSharedMiniProgram(projectPath: string, sessionIdOrPort?: string | number, installation?: Omit<SharedMiniProgramSessionOptions, 'projectPath'>): void
|
|
106
|
+
export declare function releaseSharedMiniProgram(projectPath: string, sessionIdOrPort?: string | number, installation?: Omit<SharedMiniProgramSessionOptions, 'projectPath'>): Promise<void>;
|
|
122
107
|
/**
|
|
123
108
|
* @description 关闭并移除指定项目的共享 automator 会话。
|
|
124
109
|
*/
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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;
|
|
@@ -838,6 +829,18 @@ function resolveExistingSessionKey(options) {
|
|
|
838
829
|
});
|
|
839
830
|
return matching.length === 1 ? matching[0][0] : void 0;
|
|
840
831
|
}
|
|
832
|
+
/** 确认连接关闭后移除缓存;关闭失败的条目只允许重试清理。 */
|
|
833
|
+
function closeSharedEntry(sessionKey, entry) {
|
|
834
|
+
entry.closeRequested = true;
|
|
835
|
+
entry.closing ??= (async () => {
|
|
836
|
+
await (await entry.session).disconnect();
|
|
837
|
+
if (sharedMiniProgramSessions.get(sessionKey) === entry) sharedMiniProgramSessions.delete(sessionKey);
|
|
838
|
+
})().catch((error) => {
|
|
839
|
+
entry.closing = void 0;
|
|
840
|
+
throw error;
|
|
841
|
+
});
|
|
842
|
+
return entry.closing;
|
|
843
|
+
}
|
|
841
844
|
/**
|
|
842
845
|
* @description 获取指定项目的共享 automator 会话;若不存在则自动创建。
|
|
843
846
|
*/
|
|
@@ -846,6 +849,10 @@ async function acquireSharedMiniProgram(hooks, options) {
|
|
|
846
849
|
const sessionKey = resolveSharedMiniProgramSessionKey(options);
|
|
847
850
|
const existing = sharedMiniProgramSessions.get(sessionKey);
|
|
848
851
|
if (existing) {
|
|
852
|
+
if (existing.closeRequested) {
|
|
853
|
+
await closeSharedEntry(sessionKey, existing);
|
|
854
|
+
return await acquireSharedMiniProgram(hooks, options);
|
|
855
|
+
}
|
|
849
856
|
existing.refs += 1;
|
|
850
857
|
return await existing.session;
|
|
851
858
|
}
|
|
@@ -868,11 +875,9 @@ function releaseSharedMiniProgramByKey(sessionKey) {
|
|
|
868
875
|
const entry = sharedMiniProgramSessions.get(sessionKey);
|
|
869
876
|
if (entry) {
|
|
870
877
|
entry.refs = Math.max(0, entry.refs - 1);
|
|
871
|
-
if (entry.refs === 0 && entry.closeWhenUnused)
|
|
872
|
-
sharedMiniProgramSessions.delete(sessionKey);
|
|
873
|
-
entry.session.then((program) => program.disconnect()).catch(() => void 0);
|
|
874
|
-
}
|
|
878
|
+
if (entry.refs === 0 && entry.closeWhenUnused) return closeSharedEntry(sessionKey, entry);
|
|
875
879
|
}
|
|
880
|
+
return Promise.resolve();
|
|
876
881
|
}
|
|
877
882
|
/**
|
|
878
883
|
* @description 释放指定项目的共享会话引用;会话对象会继续缓存,直到显式关闭或重置。
|
|
@@ -884,7 +889,8 @@ function releaseSharedMiniProgram(projectPath, sessionIdOrPort, installation = {
|
|
|
884
889
|
...typeof sessionIdOrPort === "number" ? { port: sessionIdOrPort } : {},
|
|
885
890
|
...typeof sessionIdOrPort === "string" ? { sessionId: sessionIdOrPort } : {}
|
|
886
891
|
});
|
|
887
|
-
if (key) releaseSharedMiniProgramByKey(key);
|
|
892
|
+
if (key) return releaseSharedMiniProgramByKey(key);
|
|
893
|
+
return Promise.resolve();
|
|
888
894
|
}
|
|
889
895
|
/**
|
|
890
896
|
* @description 关闭并移除指定项目的共享 automator 会话。
|
|
@@ -898,8 +904,7 @@ async function closeSharedMiniProgram(projectPath, sessionIdOrPort, installation
|
|
|
898
904
|
});
|
|
899
905
|
const entry = sessionKey ? sharedMiniProgramSessions.get(sessionKey) : void 0;
|
|
900
906
|
if (!entry || !sessionKey) return;
|
|
901
|
-
|
|
902
|
-
(await entry.session.catch(() => null))?.disconnect();
|
|
907
|
+
await closeSharedEntry(sessionKey, entry);
|
|
903
908
|
}
|
|
904
909
|
/**
|
|
905
910
|
* @description 获取当前共享会话数量,供测试断言使用。
|
|
@@ -915,24 +920,45 @@ async function withMiniProgram(hooks, options, runner) {
|
|
|
915
920
|
options = await hooks.resolveSessionOptions?.(options) ?? options;
|
|
916
921
|
if (options.sharedSession) {
|
|
917
922
|
const miniProgram = await acquireSharedMiniProgram(hooks, options);
|
|
923
|
+
let result;
|
|
924
|
+
let failure;
|
|
918
925
|
try {
|
|
919
|
-
|
|
926
|
+
result = await runner(miniProgram);
|
|
920
927
|
} catch (error) {
|
|
928
|
+
failure = normalizeError(hooks, error);
|
|
929
|
+
}
|
|
930
|
+
const cleanupErrors = [];
|
|
931
|
+
if (failure) try {
|
|
921
932
|
await closeSharedMiniProgram(options.projectPath, options.sessionId || options.port, options);
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
releaseSharedMiniProgram(options.projectPath, options.sessionId || options.port, options);
|
|
933
|
+
} catch (cleanupError) {
|
|
934
|
+
cleanupErrors.push(cleanupError);
|
|
925
935
|
}
|
|
936
|
+
try {
|
|
937
|
+
await releaseSharedMiniProgram(options.projectPath, options.sessionId || options.port, options);
|
|
938
|
+
} catch (cleanupError) {
|
|
939
|
+
cleanupErrors.push(cleanupError);
|
|
940
|
+
}
|
|
941
|
+
if (cleanupErrors.length) throw new AggregateError([...failure ? [failure] : [], ...cleanupErrors], "MiniProgram operation and shared connection cleanup failed", { cause: failure });
|
|
942
|
+
if (failure) throw failure;
|
|
943
|
+
return result;
|
|
926
944
|
}
|
|
927
945
|
let miniProgram = null;
|
|
946
|
+
let result;
|
|
947
|
+
let failure;
|
|
928
948
|
try {
|
|
929
949
|
miniProgram = await hooks.connectMiniProgram(options);
|
|
930
|
-
|
|
950
|
+
result = await runner(miniProgram);
|
|
931
951
|
} catch (error) {
|
|
932
|
-
|
|
933
|
-
}
|
|
934
|
-
|
|
952
|
+
failure = normalizeError(hooks, error);
|
|
953
|
+
}
|
|
954
|
+
if (miniProgram) try {
|
|
955
|
+
await miniProgram.disconnect();
|
|
956
|
+
} catch (cleanupError) {
|
|
957
|
+
if (failure) throw new AggregateError([failure, cleanupError], "MiniProgram operation and connection cleanup failed", { cause: failure });
|
|
958
|
+
throw cleanupError;
|
|
935
959
|
}
|
|
960
|
+
if (failure) throw failure;
|
|
961
|
+
return result;
|
|
936
962
|
}
|
|
937
963
|
/** 检查缓存,供调用方记录其实际创建的连接。 */
|
|
938
964
|
function hasSharedMiniProgram(options) {
|
|
@@ -943,19 +969,16 @@ async function closeOwnedSharedMiniProgram(options, owned) {
|
|
|
943
969
|
const key = resolveSharedMiniProgramSessionKey(options);
|
|
944
970
|
const entry = sharedMiniProgramSessions.get(key);
|
|
945
971
|
if (!entry) return;
|
|
946
|
-
|
|
947
|
-
if (program !== owned || sharedMiniProgramSessions.get(key) !== entry) return;
|
|
972
|
+
if (await entry.session.catch(() => null) !== owned || sharedMiniProgramSessions.get(key) !== entry) return;
|
|
948
973
|
if (entry.refs !== 0) {
|
|
949
974
|
entry.closeWhenUnused = true;
|
|
950
975
|
return;
|
|
951
976
|
}
|
|
952
|
-
|
|
953
|
-
program?.disconnect();
|
|
977
|
+
await closeSharedEntry(key, entry);
|
|
954
978
|
}
|
|
955
979
|
/** 单独保留管理器订阅,避免与正在执行的操作共享引用计数。 */
|
|
956
980
|
function retainSharedMiniProgram(sessionKey) {
|
|
957
981
|
const entry = sharedMiniProgramSessions.get(sessionKey);
|
|
958
982
|
if (entry) entry.refs += 1;
|
|
959
983
|
}
|
|
960
|
-
//#endregion
|
|
961
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
|
-
|
|
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.
|
|
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": "^
|
|
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.
|
|
52
|
+
"@weapp-vite/miniprogram-automator": "1.5.0"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"dev": "tsdown -w --sourcemap",
|