@midscene/web 0.3.0 → 0.3.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.
@@ -9,11 +9,13 @@ interface ElementInfo {
9
9
  id: string;
10
10
  indexId: string;
11
11
  nodeHashId: string;
12
- locator: string | undefined;
12
+ locator: string;
13
13
  attributes: {
14
14
  nodeType: NodeType;
15
15
  [key: string]: string;
16
16
  };
17
+ nodeType: NodeType;
18
+ htmlNode: Node | null;
17
19
  content: string;
18
20
  rect: {
19
21
  left: number;
@@ -23,6 +25,6 @@ interface ElementInfo {
23
25
  };
24
26
  center: [number, number];
25
27
  }
26
- declare function extractTextWithPosition(initNode?: Node): ElementInfo[];
28
+ declare function extractTextWithPosition(initNode?: Node, debugMode?: boolean): ElementInfo[];
27
29
 
28
30
  export { extractTextWithPosition };
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -1,7 +1,8 @@
1
+ import { AgentWaitForOpt } from '@midscene/core/.';
1
2
  import { TestInfo } from '@playwright/test';
2
3
  import { Page } from 'playwright';
3
4
  import { Page as Page$1 } from 'puppeteer';
4
- import Insight, { BaseElement, Rect, UIContext, PlanningAction, AIElementParseResponse, InsightExtractParam, InsightAssertionResponse, Executor, GroupedActionDump, ExecutionDump } from '@midscene/core';
5
+ import Insight, { BaseElement, Rect, UIContext, PlanningAction, AIElementParseResponse, InsightExtractParam, InsightAssertionResponse, PlanningActionParamWaitFor, Executor, GroupedActionDump, ExecutionDump, AgentWaitForOpt as AgentWaitForOpt$1 } from '@midscene/core';
5
6
 
6
7
  type WebPage = Page | Page$1;
7
8
 
@@ -123,6 +124,7 @@ declare class PageTaskExecutor {
123
124
  action(userPrompt: string): Promise<ExecutionResult>;
124
125
  query(demand: InsightExtractParam): Promise<ExecutionResult>;
125
126
  assert(assertion: string): Promise<ExecutionResult<InsightAssertionResponse>>;
127
+ waitFor(assertion: string, opt: PlanningActionParamWaitFor): Promise<ExecutionResult<void>>;
126
128
  }
127
129
 
128
130
  declare const PlaywrightAiFixture: () => {
@@ -138,6 +140,9 @@ declare const PlaywrightAiFixture: () => {
138
140
  aiAssert: ({ page }: {
139
141
  page: Page;
140
142
  }, use: any, testInfo: TestInfo) => Promise<void>;
143
+ aiWaitFor: ({ page }: {
144
+ page: Page;
145
+ }, use: any, testInfo: TestInfo) => Promise<void>;
141
146
  };
142
147
  type PlayWrightAiFixtureType = {
143
148
  ai: <T = any>(prompt: string, opts?: {
@@ -146,6 +151,7 @@ type PlayWrightAiFixtureType = {
146
151
  aiAction: (taskPrompt: string) => ReturnType<PageTaskExecutor['action']>;
147
152
  aiQuery: <T = any>(demand: any) => Promise<T>;
148
153
  aiAssert: (assertion: string, errorMsg?: string) => Promise<void>;
154
+ aiWaitFor: (assertion: string, opt?: AgentWaitForOpt) => Promise<void>;
149
155
  };
150
156
 
151
157
  interface PageAgentOpt {
@@ -154,6 +160,7 @@ interface PageAgentOpt {
154
160
  groupDescription?: string;
155
161
  cache?: AiTaskCache;
156
162
  generateReport?: boolean;
163
+ autoPrintReportMsg?: boolean;
157
164
  }
158
165
  declare class PageAgent {
159
166
  page: WebPage;
@@ -169,7 +176,16 @@ declare class PageAgent {
169
176
  aiAction(taskPrompt: string): Promise<void>;
170
177
  aiQuery(demand: any): Promise<any>;
171
178
  aiAssert(assertion: string, msg?: string): Promise<void>;
179
+ aiWaitFor(assertion: string, opt?: AgentWaitForOpt$1): Promise<void>;
172
180
  ai(taskPrompt: string, type?: string): Promise<any>;
173
181
  }
174
182
 
175
- export { type PlayWrightAiFixtureType, PlaywrightAiFixture, PageAgent as PuppeteerAgent };
183
+ declare function generateExtractData(page: WebPage, targetDir: string, saveImgType?: {
184
+ disableInputImage: boolean;
185
+ disableOutputImage: boolean;
186
+ disableOutputWithoutTextImg: boolean;
187
+ disableResizeOutputImg: boolean;
188
+ disableSnapshot: boolean;
189
+ }): Promise<void>;
190
+
191
+ export { type PlayWrightAiFixtureType, PlaywrightAiFixture, PageAgent as PuppeteerAgent, generateExtractData };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@midscene/web",
3
3
  "description": "Web integration for Midscene.js",
4
- "version": "0.3.0",
4
+ "version": "0.3.1",
5
5
  "jsnext:source": "./src/index.ts",
6
6
  "main": "./dist/lib/index.js",
7
7
  "module": "./dist/es/index.js",
@@ -52,7 +52,7 @@
52
52
  "openai": "4.47.1",
53
53
  "sharp": "0.33.3",
54
54
  "inquirer": "10.1.5",
55
- "@midscene/core": "0.3.0"
55
+ "@midscene/core": "0.3.1"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@modern-js/module-tools": "^2.56.1",
@@ -61,7 +61,7 @@
61
61
  "typescript": "~5.0.4",
62
62
  "vitest": "^1.6.0",
63
63
  "playwright": "1.44.1",
64
- "puppeteer": "^22.8.0",
64
+ "puppeteer": "23.0.2",
65
65
  "@playwright/test": "1.44.1",
66
66
  "fs-extra": "11.2.0",
67
67
  "@types/fs-extra": "11.0.4",
@@ -70,7 +70,7 @@
70
70
  "peerDependencies": {
71
71
  "@playwright/test": "^1.44.1",
72
72
  "playwright": "^1.44.1",
73
- "puppeteer": "^22.8.0"
73
+ "puppeteer": "^23.0.2"
74
74
  },
75
75
  "peerDependenciesMeta": {
76
76
  "@playwright/test": {
@@ -95,12 +95,15 @@
95
95
  "build:script": "modern build -c ./modern.inspect.config.ts",
96
96
  "build:watch": "modern build -w -c ./modern.config.ts & modern build -w -c ./modern.inspect.config.ts",
97
97
  "test": "vitest --run",
98
- "test:all": "AITEST=true vitest --run",
98
+ "test:u": "vitest --run -u",
99
+ "test:ai": "AITEST=true npm run test",
99
100
  "new": "modern new",
100
101
  "upgrade": "modern upgrade",
101
102
  "e2e": "playwright test --config=playwright.config.ts",
103
+ "e2e:report": "MIDSCENE_REPORT=true playwright test --config=playwright.config.ts",
102
104
  "e2e:cache": "MIDSCENE_CACHE=true playwright test --config=playwright.config.ts",
103
105
  "e2e:ui": "playwright test --config=playwright.config.ts --ui",
104
- "e2e:ui-cache": "MIDSCENE_CACHE=true playwright test --config=playwright.config.ts --ui"
106
+ "e2e:ui:cache": "MIDSCENE_CACHE=true playwright test --config=playwright.config.ts --ui",
107
+ "postinstall": "bash install-deps.bash"
105
108
  }
106
109
  }