@weapp-vite/devtools-runtime 0.4.17 → 0.4.19
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/README.md +13 -0
- package/dist/index.d.ts +8 -8
- package/dist/mcp.d.ts +16 -17
- package/package.json +14 -3
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# @weapp-vite/devtools-runtime
|
|
2
|
+
|
|
3
|
+
Shared WeChat DevTools runtime automation helpers for weapp-vite packages
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @weapp-vite/devtools-runtime
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 使用
|
|
12
|
+
|
|
13
|
+
请根据包导出的 API 和仓库中的示例使用本包。完整文档与源码位于 [weapp-vite](https://github.com/weapp-vite/weapp-vite)。
|
package/dist/index.d.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import { AutomatorElement, AutomatorMiniProgram, AutomatorPage, DevtoolsConnectionInput, DevtoolsContext, DevtoolsElementSnapshot, DevtoolsPageSnapshot, DevtoolsRuntimeHooks, DevtoolsRuntimeSessionOptions, DevtoolsToolResult, MiniProgramElementLike, readDevtoolsElementSnapshot, resolveDevtoolsProjectPath, resolveDevtoolsWorkspacePath, toDevtoolsSerializableValue } from "./mcp.js";
|
|
2
2
|
//#region src/index.d.ts
|
|
3
|
-
interface MiniProgramEventMap {
|
|
3
|
+
export interface MiniProgramEventMap {
|
|
4
4
|
console: (payload: unknown) => void;
|
|
5
5
|
exception: (payload: unknown) => void;
|
|
6
6
|
}
|
|
7
|
-
declare function resolveSharedMiniProgramSessionKey(options: Pick<DevtoolsRuntimeSessionOptions, 'port' | 'projectPath' | 'sessionId'>): string;
|
|
7
|
+
export declare function resolveSharedMiniProgramSessionKey(options: Pick<DevtoolsRuntimeSessionOptions, 'port' | 'projectPath' | 'sessionId'>): string;
|
|
8
8
|
/**
|
|
9
9
|
* @description 获取指定项目的共享 automator 会话;若不存在则自动创建。
|
|
10
10
|
*/
|
|
11
|
-
declare function acquireSharedMiniProgram(hooks: DevtoolsRuntimeHooks, options: DevtoolsRuntimeSessionOptions): Promise<AutomatorMiniProgram>;
|
|
11
|
+
export declare function acquireSharedMiniProgram(hooks: DevtoolsRuntimeHooks, options: DevtoolsRuntimeSessionOptions): Promise<AutomatorMiniProgram>;
|
|
12
12
|
/**
|
|
13
13
|
* @description 释放指定项目的共享会话引用;会话对象会继续缓存,直到显式关闭或重置。
|
|
14
14
|
*/
|
|
15
|
-
declare function releaseSharedMiniProgram(projectPath: string, sessionIdOrPort?: string | number): void;
|
|
15
|
+
export declare function releaseSharedMiniProgram(projectPath: string, sessionIdOrPort?: string | number): void;
|
|
16
16
|
/**
|
|
17
17
|
* @description 关闭并移除指定项目的共享 automator 会话。
|
|
18
18
|
*/
|
|
19
|
-
declare function closeSharedMiniProgram(projectPath: string, sessionIdOrPort?: string | number): Promise<void>;
|
|
19
|
+
export declare function closeSharedMiniProgram(projectPath: string, sessionIdOrPort?: string | number): Promise<void>;
|
|
20
20
|
/**
|
|
21
21
|
* @description 获取当前共享会话数量,供测试断言使用。
|
|
22
22
|
*/
|
|
23
|
-
declare function getSharedMiniProgramSessionCount(): number;
|
|
23
|
+
export declare function getSharedMiniProgramSessionCount(): number;
|
|
24
24
|
/**
|
|
25
25
|
* @description 统一管理 automator 会话生命周期。
|
|
26
26
|
*/
|
|
27
|
-
declare function withMiniProgram<T>(hooks: DevtoolsRuntimeHooks, options: DevtoolsRuntimeSessionOptions, runner: (miniProgram: AutomatorMiniProgram) => Promise<T>): Promise<T>;
|
|
27
|
+
export declare function withMiniProgram<T>(hooks: DevtoolsRuntimeHooks, options: DevtoolsRuntimeSessionOptions, runner: (miniProgram: AutomatorMiniProgram) => Promise<T>): Promise<T>;
|
|
28
28
|
//#endregion
|
|
29
|
-
export { type AutomatorElement, type AutomatorMiniProgram, type AutomatorPage, type DevtoolsConnectionInput, type DevtoolsContext, type DevtoolsElementSnapshot, type DevtoolsPageSnapshot, type DevtoolsRuntimeHooks, type DevtoolsRuntimeSessionOptions, type DevtoolsToolResult, type MiniProgramElementLike,
|
|
29
|
+
export { type AutomatorElement, type AutomatorMiniProgram, type AutomatorPage, type DevtoolsConnectionInput, type DevtoolsContext, type DevtoolsElementSnapshot, type DevtoolsPageSnapshot, type DevtoolsRuntimeHooks, type DevtoolsRuntimeSessionOptions, type DevtoolsToolResult, type MiniProgramElementLike, readDevtoolsElementSnapshot, resolveDevtoolsProjectPath, resolveDevtoolsWorkspacePath, toDevtoolsSerializableValue };
|
package/dist/mcp.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Element, MiniProgram, Page } from "@weapp-vite/miniprogram-automator";
|
|
2
2
|
//#region src/mcp.d.ts
|
|
3
|
-
type AutomatorMiniProgram = InstanceType<typeof MiniProgram> & {
|
|
3
|
+
export type AutomatorMiniProgram = InstanceType<typeof MiniProgram> & {
|
|
4
4
|
callWxMethod?: (method: string, ...args: unknown[]) => Promise<unknown>;
|
|
5
5
|
enableLog?: (timeout?: number) => Promise<void>;
|
|
6
6
|
};
|
|
7
|
-
type AutomatorPage = InstanceType<typeof Page>;
|
|
8
|
-
type AutomatorElement = InstanceType<typeof Element> & {
|
|
7
|
+
export type AutomatorPage = InstanceType<typeof Page>;
|
|
8
|
+
export type AutomatorElement = InstanceType<typeof Element> & {
|
|
9
9
|
input?: (value: string) => Promise<void>;
|
|
10
10
|
};
|
|
11
|
-
interface DevtoolsRuntimeSessionOptions {
|
|
11
|
+
export interface DevtoolsRuntimeSessionOptions {
|
|
12
12
|
miniProgram?: AutomatorMiniProgram;
|
|
13
13
|
openedOnly?: boolean;
|
|
14
14
|
preferOpenedSession?: boolean;
|
|
@@ -19,11 +19,11 @@ interface DevtoolsRuntimeSessionOptions {
|
|
|
19
19
|
sessionId?: string;
|
|
20
20
|
timeout?: number;
|
|
21
21
|
}
|
|
22
|
-
interface DevtoolsRuntimeHooks {
|
|
22
|
+
export interface DevtoolsRuntimeHooks {
|
|
23
23
|
connectMiniProgram: (options: DevtoolsRuntimeSessionOptions) => Promise<AutomatorMiniProgram>;
|
|
24
24
|
normalizeConnectionError?: (error: unknown) => unknown;
|
|
25
25
|
}
|
|
26
|
-
interface DevtoolsConnectionInput {
|
|
26
|
+
export interface DevtoolsConnectionInput {
|
|
27
27
|
projectPath: string;
|
|
28
28
|
timeout?: number;
|
|
29
29
|
openedOnly?: boolean;
|
|
@@ -32,7 +32,7 @@ interface DevtoolsConnectionInput {
|
|
|
32
32
|
preserveProjectRoot?: boolean;
|
|
33
33
|
sessionId?: string;
|
|
34
34
|
}
|
|
35
|
-
interface DevtoolsElementSnapshot {
|
|
35
|
+
export interface DevtoolsElementSnapshot {
|
|
36
36
|
selector: string;
|
|
37
37
|
tagName: string;
|
|
38
38
|
text: string | null;
|
|
@@ -44,21 +44,21 @@ interface DevtoolsElementSnapshot {
|
|
|
44
44
|
wxml: string | null;
|
|
45
45
|
outerWxml: string | null;
|
|
46
46
|
}
|
|
47
|
-
interface DevtoolsPageSnapshot {
|
|
47
|
+
export interface DevtoolsPageSnapshot {
|
|
48
48
|
path: string;
|
|
49
49
|
query: unknown;
|
|
50
50
|
size: unknown;
|
|
51
51
|
scrollTop: unknown;
|
|
52
52
|
data: unknown;
|
|
53
53
|
}
|
|
54
|
-
interface DevtoolsContext {
|
|
54
|
+
export interface DevtoolsContext {
|
|
55
55
|
miniProgram: AutomatorMiniProgram;
|
|
56
56
|
page: AutomatorPage;
|
|
57
57
|
}
|
|
58
|
-
interface DevtoolsToolResult<T> {
|
|
58
|
+
export interface DevtoolsToolResult<T> {
|
|
59
59
|
result: T;
|
|
60
60
|
}
|
|
61
|
-
interface MiniProgramElementLike {
|
|
61
|
+
export interface MiniProgramElementLike {
|
|
62
62
|
tagName?: string;
|
|
63
63
|
$?: (selector: string) => Promise<MiniProgramElementLike | null>;
|
|
64
64
|
$$?: (selector: string) => Promise<MiniProgramElementLike[]>;
|
|
@@ -72,9 +72,8 @@ interface MiniProgramElementLike {
|
|
|
72
72
|
value?: () => Promise<unknown>;
|
|
73
73
|
wxml?: () => Promise<unknown>;
|
|
74
74
|
}
|
|
75
|
-
declare function resolveDevtoolsProjectPath(workspaceRoot: string, projectPath: string): string;
|
|
76
|
-
declare function resolveDevtoolsWorkspacePath(workspaceRoot: string, filePath: string): string;
|
|
77
|
-
declare function toDevtoolsSerializableValue(value: unknown): unknown;
|
|
78
|
-
declare function readDevtoolsElementSnapshot(element: MiniProgramElementLike, selector: string, attributeNames?: readonly string[], styleNames?: readonly string[]): Promise<DevtoolsElementSnapshot>;
|
|
79
|
-
//#endregion
|
|
80
|
-
export { AutomatorElement, AutomatorMiniProgram, AutomatorPage, DevtoolsConnectionInput, DevtoolsContext, DevtoolsElementSnapshot, DevtoolsPageSnapshot, DevtoolsRuntimeHooks, DevtoolsRuntimeSessionOptions, DevtoolsToolResult, MiniProgramElementLike, readDevtoolsElementSnapshot, resolveDevtoolsProjectPath, resolveDevtoolsWorkspacePath, toDevtoolsSerializableValue };
|
|
75
|
+
export declare function resolveDevtoolsProjectPath(workspaceRoot: string, projectPath: string): string;
|
|
76
|
+
export declare function resolveDevtoolsWorkspacePath(workspaceRoot: string, filePath: string): string;
|
|
77
|
+
export declare function toDevtoolsSerializableValue(value: unknown): unknown;
|
|
78
|
+
export declare function readDevtoolsElementSnapshot(element: MiniProgramElementLike, selector: string, attributeNames?: readonly string[], styleNames?: readonly string[]): Promise<DevtoolsElementSnapshot>;
|
|
79
|
+
//#endregion
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-vite/devtools-runtime",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.19",
|
|
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",
|
|
8
|
+
"homepage": "https://github.com/weapp-vite/weapp-vite#readme",
|
|
8
9
|
"repository": {
|
|
9
10
|
"type": "git",
|
|
10
11
|
"url": "git+https://github.com/weapp-vite/weapp-vite.git",
|
|
@@ -13,6 +14,16 @@
|
|
|
13
14
|
"bugs": {
|
|
14
15
|
"url": "https://github.com/weapp-vite/weapp-vite/issues"
|
|
15
16
|
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"weapp-vite",
|
|
19
|
+
"weapp",
|
|
20
|
+
"wechat",
|
|
21
|
+
"mini-program",
|
|
22
|
+
"miniprogram",
|
|
23
|
+
"vite",
|
|
24
|
+
"runtime",
|
|
25
|
+
"devtools"
|
|
26
|
+
],
|
|
16
27
|
"sideEffects": false,
|
|
17
28
|
"exports": {
|
|
18
29
|
".": {
|
|
@@ -35,10 +46,10 @@
|
|
|
35
46
|
},
|
|
36
47
|
"publishConfig": {
|
|
37
48
|
"access": "public",
|
|
38
|
-
"registry": "https://registry.npmjs.org
|
|
49
|
+
"registry": "https://registry.npmjs.org"
|
|
39
50
|
},
|
|
40
51
|
"dependencies": {
|
|
41
|
-
"@weapp-vite/miniprogram-automator": "1.2.
|
|
52
|
+
"@weapp-vite/miniprogram-automator": "1.2.18"
|
|
42
53
|
},
|
|
43
54
|
"scripts": {
|
|
44
55
|
"dev": "tsdown -w --sourcemap",
|