@midscene/web 0.7.2 → 0.7.3-beta-20241029030944.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.
@@ -1,9 +1,9 @@
1
- export { P as AppiumAgent } from './tasks-82c1054b.js';
2
- export { P as AppiumPage } from './page-ad820b3c.js';
3
- import '@midscene/core/dist/types/types-ce502a2a';
1
+ export { P as AppiumAgent } from './tasks-5fdaaf80.js';
2
+ export { P as AppiumPage } from './page-80b32690.js';
4
3
  import '@midscene/core';
5
4
  import '@midscene/shared/fs';
6
5
  import 'playwright';
7
6
  import 'puppeteer';
8
7
  import '@midscene/shared/constants';
8
+ import '@midscene/core/.';
9
9
  import 'webdriverio';
@@ -0,0 +1,16 @@
1
+ import { C as ChromeExtensionProxyPage } from './page-80b32690.js';
2
+ export { b as ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED } from './page-80b32690.js';
3
+ import { P as PageAgent } from './tasks-5fdaaf80.js';
4
+ import 'playwright';
5
+ import 'puppeteer';
6
+ import '@midscene/shared/constants';
7
+ import '@midscene/core';
8
+ import '@midscene/core/.';
9
+ import 'webdriverio';
10
+ import '@midscene/shared/fs';
11
+
12
+ declare class ChromeExtensionProxyPageAgent extends PageAgent {
13
+ constructor(page: ChromeExtensionProxyPage);
14
+ }
15
+
16
+ export { ChromeExtensionProxyPage, ChromeExtensionProxyPageAgent };
@@ -1,9 +1,10 @@
1
1
  import { writeFileSync } from 'node:fs';
2
- import { W as WebPage, E as ElementInfo } from './page-ad820b3c.js';
2
+ import { W as WebPage, E as ElementInfo } from './page-80b32690.js';
3
3
  import 'playwright';
4
4
  import 'puppeteer';
5
- import '@midscene/core';
6
5
  import '@midscene/shared/constants';
6
+ import '@midscene/core';
7
+ import '@midscene/core/.';
7
8
  import 'webdriverio';
8
9
 
9
10
  declare function generateExtractData(page: WebPage, targetDir: string, saveImgType?: {
@@ -1,12 +1,12 @@
1
1
  export { PlayWrightAiFixtureType, PlaywrightAiFixture } from './playwright.js';
2
- export { P as AppiumAgent, P as PlaywrightAgent } from './tasks-82c1054b.js';
3
- export { P as AppiumPage } from './page-ad820b3c.js';
2
+ export { P as AppiumAgent, P as PlaywrightAgent } from './tasks-5fdaaf80.js';
3
+ export { P as AppiumPage } from './page-80b32690.js';
4
+ export { StaticPageAgent } from './playground.js';
4
5
  export { PuppeteerAgent } from './puppeteer.js';
5
6
  export { generateExtractData } from './debug.js';
6
7
  import '@midscene/core/.';
7
8
  import '@playwright/test';
8
9
  import 'playwright';
9
- import '@midscene/core/dist/types/types-ce502a2a';
10
10
  import '@midscene/core';
11
11
  import '@midscene/shared/fs';
12
12
  import 'puppeteer';
@@ -1,7 +1,8 @@
1
1
  import { Page as Page$3 } from 'playwright';
2
2
  import { KeyInput, Page as Page$2 } from 'puppeteer';
3
- import { BaseElement, Rect, UIContext } from '@midscene/core';
4
3
  import { NodeType } from '@midscene/shared/constants';
4
+ import { BaseElement, Rect, UIContext, PlaywrightParserOpt } from '@midscene/core';
5
+ import * as _midscene_core__ from '@midscene/core/.';
5
6
  import { Browser } from 'webdriverio';
6
7
 
7
8
  declare class WebElementInfo implements BaseElement {
@@ -33,6 +34,17 @@ declare class WebElementInfo implements BaseElement {
33
34
  type WebUIContext = UIContext<WebElementInfo> & {
34
35
  url: string;
35
36
  };
37
+ declare function parseContextFromWebPage(page: WebPage$1, _opt?: PlaywrightParserOpt): Promise<WebUIContext>;
38
+ declare function getExtraReturnLogic(): Promise<string>;
39
+ declare function reportFileName(tag?: string): string;
40
+ declare function printReportMsg(filepath: string): void;
41
+ /**
42
+ * Get the current execution file name
43
+ * @returns The name of the current execution file
44
+ */
45
+ declare function getCurrentExecutionFile(trace?: string): string | false;
46
+ declare function generateCacheId(fileName?: string): string;
47
+ declare const ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED = "NOT_IMPLEMENTED_AS_DESIGNED";
36
48
 
37
49
  interface ElementInfo {
38
50
  id: string;
@@ -58,9 +70,14 @@ interface ElementInfo {
58
70
  type MouseButton = 'left' | 'right' | 'middle';
59
71
  declare abstract class AbstractPage {
60
72
  abstract pageType: string;
61
- abstract screenshot(): Promise<string>;
62
73
  abstract getElementInfos(): Promise<ElementInfo[]>;
63
- abstract url(): string;
74
+ abstract url(): string | Promise<string>;
75
+ abstract screenshotBase64?(): Promise<string>;
76
+ abstract size(): Promise<{
77
+ width: number;
78
+ height: number;
79
+ dpr?: number;
80
+ }>;
64
81
  get mouse(): {
65
82
  click: (x: number, y: number, options: {
66
83
  button: MouseButton;
@@ -86,7 +103,11 @@ declare class Page$1 implements AbstractPage {
86
103
  pageType: string;
87
104
  constructor(browser: Browser);
88
105
  getElementInfos(): Promise<ElementInfo[]>;
89
- screenshot(): Promise<string>;
106
+ size(): Promise<{
107
+ width: number;
108
+ height: number;
109
+ }>;
110
+ screenshotBase64(): Promise<string>;
90
111
  get mouse(): {
91
112
  click: (x: number, y: number, options?: {
92
113
  button: MouseButton;
@@ -111,12 +132,43 @@ declare class Page$1 implements AbstractPage {
111
132
  private mouseWheel;
112
133
  }
113
134
 
135
+ declare class ChromeExtensionProxyPage implements AbstractPage {
136
+ pageType: string;
137
+ private tabId;
138
+ private windowId;
139
+ private viewportSize?;
140
+ constructor(tabId: number, windowId: number);
141
+ getElementInfos(): Promise<ElementInfo[]>;
142
+ size(): Promise<{
143
+ width: number;
144
+ height: number;
145
+ dpr: number;
146
+ }>;
147
+ screenshotBase64(): Promise<string>;
148
+ url(): string;
149
+ scrollUntilTop(): Promise<any>;
150
+ scrollUntilBottom(): Promise<any>;
151
+ scrollUpOneScreen(): Promise<any>;
152
+ scrollDownOneScreen(): Promise<any>;
153
+ clearInput(): Promise<any>;
154
+ mouse: {
155
+ click: any;
156
+ wheel: any;
157
+ move: any;
158
+ };
159
+ keyboard: {
160
+ type: any;
161
+ press: any;
162
+ };
163
+ }
164
+
114
165
  declare class StaticPage implements AbstractPage {
115
166
  pageType: string;
116
167
  private uiContext;
117
168
  constructor(uiContext: WebUIContext);
118
169
  getElementInfos(): Promise<any>;
119
- screenshot(): Promise<string>;
170
+ size(): Promise<_midscene_core__.Size>;
171
+ screenshotBase64(): Promise<string>;
120
172
  url(): string;
121
173
  scrollUntilTop(): Promise<any>;
122
174
  scrollUntilBottom(): Promise<any>;
@@ -136,12 +188,18 @@ declare class StaticPage implements AbstractPage {
136
188
  }
137
189
 
138
190
  declare class Page<AgentType extends 'puppeteer' | 'playwright', PageType extends Page$2 | Page$3> implements AbstractPage {
139
- private page;
191
+ private underlyingPage;
192
+ private viewportSize?;
140
193
  pageType: AgentType;
141
194
  private evaluate;
142
- constructor(page: PageType, pageType: AgentType);
195
+ constructor(underlyingPage: PageType, pageType: AgentType);
143
196
  getElementInfos(): Promise<ElementInfo[]>;
144
- screenshot(): Promise<string>;
197
+ size(): Promise<{
198
+ width: number;
199
+ height: number;
200
+ dpr: number;
201
+ }>;
202
+ screenshotBase64(): Promise<string>;
145
203
  url(): string;
146
204
  get mouse(): {
147
205
  click: (x: number, y: number, options?: {
@@ -171,11 +229,12 @@ type WebPage$1 =
171
229
  | WebPage
172
230
  | WebPage$2
173
231
  | Page$1
174
- | StaticPage;
232
+ | StaticPage
233
+ | ChromeExtensionProxyPage;
175
234
  type WebKeyInput = KeyInput;
176
235
 
177
236
  declare class WebPage extends Page<'playwright', Page$3> {
178
237
  constructor(page: Page$3);
179
238
  }
180
239
 
181
- export { type ElementInfo as E, Page$1 as P, StaticPage as S, type WebPage$1 as W, WebPage$2 as a, WebPage as b, type WebUIContext as c, WebElementInfo as d };
240
+ export { ChromeExtensionProxyPage as C, type ElementInfo as E, Page$1 as P, StaticPage as S, type WebPage$1 as W, WebPage$2 as a, ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED as b, WebPage as c, type WebUIContext as d, WebElementInfo as e, printReportMsg as f, getExtraReturnLogic as g, getCurrentExecutionFile as h, generateCacheId as i, parseContextFromWebPage as p, reportFileName as r };
@@ -1,30 +1,16 @@
1
- import { P as PageAgent } from './tasks-82c1054b.js';
2
- import { S as StaticPage } from './page-ad820b3c.js';
3
- import * as http from 'http';
4
- import { Server } from 'node:http';
5
- import express from 'express';
6
- import '@midscene/core/dist/types/types-ce502a2a';
7
- import '@midscene/core';
8
- import '@midscene/shared/fs';
1
+ import { S as StaticPage } from './page-80b32690.js';
2
+ export { b as ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED } from './page-80b32690.js';
3
+ import { P as PageAgent } from './tasks-5fdaaf80.js';
9
4
  import 'playwright';
10
5
  import 'puppeteer';
11
6
  import '@midscene/shared/constants';
7
+ import '@midscene/core';
8
+ import '@midscene/core/.';
12
9
  import 'webdriverio';
10
+ import '@midscene/shared/fs';
13
11
 
14
12
  declare class StaticPageAgent extends PageAgent {
15
13
  constructor(page: StaticPage);
16
14
  }
17
15
 
18
- declare class PlaygroundServer {
19
- app: express.Application;
20
- tmpDir: string;
21
- server?: Server;
22
- port?: number | null;
23
- constructor();
24
- filePathForUuid(uuid: string): string;
25
- saveContextFile(uuid: string, context: string): string;
26
- launch(): Promise<unknown>;
27
- close(): Server<typeof http.IncomingMessage, typeof http.ServerResponse> | undefined;
28
- }
29
-
30
- export { PlaygroundServer, StaticPage, StaticPageAgent };
16
+ export { StaticPage, StaticPageAgent };
@@ -1,10 +1,9 @@
1
1
  import { AgentWaitForOpt } from '@midscene/core/.';
2
2
  import { TestInfo } from '@playwright/test';
3
3
  import { Page } from 'playwright';
4
- import { b as PageTaskExecutor } from './tasks-82c1054b.js';
5
- export { P as PlaywrightAgent } from './tasks-82c1054b.js';
6
- export { b as PlaywrightWebPage } from './page-ad820b3c.js';
7
- import '@midscene/core/dist/types/types-ce502a2a';
4
+ import { b as PageTaskExecutor } from './tasks-5fdaaf80.js';
5
+ export { P as PlaywrightAgent } from './tasks-5fdaaf80.js';
6
+ export { c as PlaywrightWebPage } from './page-80b32690.js';
8
7
  import '@midscene/core';
9
8
  import '@midscene/shared/fs';
10
9
  import 'puppeteer';
@@ -1,11 +1,11 @@
1
- import { P as PageAgent, a as PageAgentOpt } from './tasks-82c1054b.js';
1
+ import { P as PageAgent, a as PageAgentOpt } from './tasks-5fdaaf80.js';
2
2
  import { Page } from 'puppeteer';
3
- export { a as PuppeteerWebPage } from './page-ad820b3c.js';
4
- import '@midscene/core/dist/types/types-ce502a2a';
3
+ export { a as PuppeteerWebPage } from './page-80b32690.js';
5
4
  import '@midscene/core';
6
5
  import '@midscene/shared/fs';
7
6
  import 'playwright';
8
7
  import '@midscene/shared/constants';
8
+ import '@midscene/core/.';
9
9
  import 'webdriverio';
10
10
 
11
11
  declare class PuppeteerAgent extends PageAgent {
@@ -1,7 +1,7 @@
1
- import * as _midscene_core_dist_types_types_ce502a2a from '@midscene/core/dist/types/types-ce502a2a';
2
- import { c as WebUIContext, W as WebPage, d as WebElementInfo } from './page-ad820b3c.js';
1
+ import * as _midscene_core from '@midscene/core';
3
2
  import { PlanningAction, AIElementParseResponse, GroupedActionDump, ExecutionDump, AgentAssertOpt, AgentWaitForOpt, Insight, InsightExtractParam, InsightAssertionResponse, PlanningActionParamWaitFor, Executor } from '@midscene/core';
4
- import { getMidscenePkgInfo } from '@midscene/shared/fs';
3
+ import { d as WebUIContext, W as WebPage, e as WebElementInfo } from './page-80b32690.js';
4
+ import { getRunningPkgInfo } from '@midscene/shared/fs';
5
5
 
6
6
  type PlanTask = {
7
7
  type: 'plan';
@@ -40,7 +40,7 @@ declare class TaskCache {
40
40
  cache: AiTaskCache;
41
41
  cacheId: string;
42
42
  newCache: AiTaskCache;
43
- midscenePkgInfo: ReturnType<typeof getMidscenePkgInfo>;
43
+ midscenePkgInfo: ReturnType<typeof getRunningPkgInfo> | null;
44
44
  constructor(opts?: {
45
45
  fileName?: string;
46
46
  });
@@ -93,7 +93,7 @@ interface PageAgentOpt {
93
93
  declare class PageAgent {
94
94
  page: WebPage;
95
95
  dump: GroupedActionDump;
96
- reportFile?: string;
96
+ reportFile?: string | null;
97
97
  reportFileName?: string;
98
98
  taskExecutor: PageTaskExecutor;
99
99
  opts: PageAgentOpt;
@@ -103,7 +103,7 @@ declare class PageAgent {
103
103
  writeOutActionDumps(): void;
104
104
  aiAction(taskPrompt: string): Promise<void>;
105
105
  aiQuery(demand: any): Promise<any>;
106
- aiAssert(assertion: string, msg?: string, opt?: AgentAssertOpt): Promise<_midscene_core_dist_types_types_ce502a2a.d | undefined>;
106
+ aiAssert(assertion: string, msg?: string, opt?: AgentAssertOpt): Promise<_midscene_core.AIAssertionResponse | undefined>;
107
107
  aiWaitFor(assertion: string, opt?: AgentWaitForOpt): Promise<void>;
108
108
  ai(taskPrompt: string, type?: string): Promise<any>;
109
109
  }
@@ -0,0 +1,7 @@
1
+ import '@midscene/core';
2
+ export { b as ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED, d as WebUIContext, i as generateCacheId, h as getCurrentExecutionFile, g as getExtraReturnLogic, p as parseContextFromWebPage, f as printReportMsg, r as reportFileName } from './page-80b32690.js';
3
+ import 'playwright';
4
+ import 'puppeteer';
5
+ import '@midscene/shared/constants';
6
+ import '@midscene/core/.';
7
+ import 'webdriverio';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@midscene/web",
3
3
  "description": "An AI-powered automation SDK can control the page, perform assertions, and extract data in JSON format using natural language. See https://midscenejs.com/ for details.",
4
- "version": "0.7.2",
4
+ "version": "0.7.3-beta-20241029030944.0",
5
5
  "repository": "https://github.com/web-infra-dev/midscene",
6
6
  "homepage": "https://midscenejs.com/",
7
7
  "jsnext:source": "./src/index.ts",
@@ -12,19 +12,24 @@
12
12
  },
13
13
  "exports": {
14
14
  ".": "./dist/lib/index.js",
15
+ "./utils": "./dist/lib/utils.js",
15
16
  "./puppeteer": "./dist/lib/puppeteer.js",
16
17
  "./playwright": "./dist/lib/playwright.js",
17
18
  "./playwright-report": "./dist/lib/playwright-report.js",
18
19
  "./playground": "./dist/lib/playground.js",
19
20
  "./debug": "./dist/lib/debug.js",
20
21
  "./constants": "./dist/lib/constants.js",
21
- "./html-element": "./dist/lib/html-element/index.js"
22
+ "./html-element": "./dist/lib/html-element/index.js",
23
+ "./chrome-extension": "./dist/lib/chrome-extension.js"
22
24
  },
23
25
  "typesVersions": {
24
26
  "*": {
25
27
  ".": [
26
28
  "./dist/types/index.d.ts"
27
29
  ],
30
+ "utils": [
31
+ "./dist/types/utils.d.ts"
32
+ ],
28
33
  "puppeteer": [
29
34
  "./dist/types/puppeteer.d.ts"
30
35
  ],
@@ -45,6 +50,9 @@
45
50
  ],
46
51
  "html-element": [
47
52
  "./dist/types/html-element/index.d.ts"
53
+ ],
54
+ "chrome-extension": [
55
+ "./dist/types/chrome-extension.d.ts"
48
56
  ]
49
57
  }
50
58
  },
@@ -60,12 +68,14 @@
60
68
  "inquirer": "10.1.5",
61
69
  "cors": "2.8.5",
62
70
  "@xmldom/xmldom": "0.8.10",
63
- "@midscene/shared": "0.7.2",
64
- "@midscene/core": "0.7.2"
71
+ "@midscene/shared": "0.7.3-beta-20241029030944.0",
72
+ "@midscene/core": "0.7.3-beta-20241029030944.0"
65
73
  },
66
74
  "devDependencies": {
67
75
  "@modern-js/module-tools": "2.58.2",
76
+ "@modern-js/plugin-module-node-polyfill": "2.58.2",
68
77
  "@playwright/test": "1.44.1",
78
+ "@types/chrome": "0.0.279",
69
79
  "@types/cors": "2.8.12",
70
80
  "@types/fs-extra": "11.0.4",
71
81
  "@types/node": "^18.0.0",