@midscene/web 0.7.1 → 0.7.2-beta-20241024094141.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.
@@ -23,14 +23,7 @@ var midscene_element_inspector = (() => {
23
23
  return a;
24
24
  };
25
25
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
26
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
27
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
28
- }) : x)(function(x) {
29
- if (typeof require !== "undefined")
30
- return require.apply(this, arguments);
31
- throw Error('Dynamic require of "' + x + '" is not supported');
32
- });
33
- var __commonJS = (cb, mod) => function __require2() {
26
+ var __commonJS = (cb, mod) => function __require() {
34
27
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
35
28
  };
36
29
  var __export = (target, all) => {
@@ -55,6 +48,14 @@ var midscene_element_inspector = (() => {
55
48
  ));
56
49
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
57
50
 
51
+ // resolve-false:/empty-stub
52
+ var require_empty_stub = __commonJS({
53
+ "resolve-false:/empty-stub"(exports, module) {
54
+ "use strict";
55
+ module.exports = {};
56
+ }
57
+ });
58
+
58
59
  // ../../node_modules/.pnpm/js-sha256@0.11.0/node_modules/js-sha256/src/sha256.js
59
60
  var require_sha256 = __commonJS({
60
61
  "../../node_modules/.pnpm/js-sha256@0.11.0/node_modules/js-sha256/src/sha256.js"(exports, module) {
@@ -181,8 +182,8 @@ var midscene_element_inspector = (() => {
181
182
  return method;
182
183
  };
183
184
  var nodeWrap = function(method, is224) {
184
- var crypto = __require("crypto");
185
- var Buffer2 = __require("buffer").Buffer;
185
+ var crypto = require_empty_stub();
186
+ var Buffer2 = require_empty_stub().Buffer;
186
187
  var algorithm = is224 ? "sha224" : "sha256";
187
188
  var bufferFrom;
188
189
  if (Buffer2.from && !root.JS_SHA256_NO_BUFFER_FROM) {
@@ -23,14 +23,7 @@ var midscene_element_inspector = (() => {
23
23
  return a;
24
24
  };
25
25
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
26
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
27
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
28
- }) : x)(function(x) {
29
- if (typeof require !== "undefined")
30
- return require.apply(this, arguments);
31
- throw Error('Dynamic require of "' + x + '" is not supported');
32
- });
33
- var __commonJS = (cb, mod) => function __require2() {
26
+ var __commonJS = (cb, mod) => function __require() {
34
27
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
35
28
  };
36
29
  var __copyProps = (to, from, except, desc) => {
@@ -50,6 +43,14 @@ var midscene_element_inspector = (() => {
50
43
  mod
51
44
  ));
52
45
 
46
+ // resolve-false:/empty-stub
47
+ var require_empty_stub = __commonJS({
48
+ "resolve-false:/empty-stub"(exports, module) {
49
+ "use strict";
50
+ module.exports = {};
51
+ }
52
+ });
53
+
53
54
  // ../../node_modules/.pnpm/js-sha256@0.11.0/node_modules/js-sha256/src/sha256.js
54
55
  var require_sha256 = __commonJS({
55
56
  "../../node_modules/.pnpm/js-sha256@0.11.0/node_modules/js-sha256/src/sha256.js"(exports, module) {
@@ -176,8 +177,8 @@ var midscene_element_inspector = (() => {
176
177
  return method;
177
178
  };
178
179
  var nodeWrap = function(method, is224) {
179
- var crypto = __require("crypto");
180
- var Buffer2 = __require("buffer").Buffer;
180
+ var crypto = require_empty_stub();
181
+ var Buffer2 = require_empty_stub().Buffer;
181
182
  var algorithm = is224 ? "sha224" : "sha256";
182
183
  var bufferFrom;
183
184
  if (Buffer2.from && !root.JS_SHA256_NO_BUFFER_FROM) {
@@ -1,6 +1,5 @@
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-cb6bf758.js';
2
+ export { P as AppiumPage } from './page-8117b0ad.js';
4
3
  import '@midscene/core';
5
4
  import '@midscene/shared/fs';
6
5
  import 'playwright';
@@ -1,5 +1,5 @@
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-8117b0ad.js';
3
3
  import 'playwright';
4
4
  import 'puppeteer';
5
5
  import '@midscene/core';
@@ -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-cb6bf758.js';
3
+ export { P as AppiumPage } from './page-8117b0ad.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';
@@ -33,6 +33,7 @@ declare class WebElementInfo implements BaseElement {
33
33
  type WebUIContext = UIContext<WebElementInfo> & {
34
34
  url: string;
35
35
  };
36
+ declare const ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED = "NOT_IMPLEMENTED_AS_DESIGNED";
36
37
 
37
38
  interface ElementInfo {
38
39
  id: string;
@@ -58,7 +59,7 @@ interface ElementInfo {
58
59
  type MouseButton = 'left' | 'right' | 'middle';
59
60
  declare abstract class AbstractPage {
60
61
  abstract pageType: string;
61
- abstract screenshot(): Promise<string>;
62
+ abstract screenshotBase64?(): Promise<string>;
62
63
  abstract getElementInfos(): Promise<ElementInfo[]>;
63
64
  abstract url(): string;
64
65
  get mouse(): {
@@ -86,7 +87,7 @@ declare class Page$1 implements AbstractPage {
86
87
  pageType: string;
87
88
  constructor(browser: Browser);
88
89
  getElementInfos(): Promise<ElementInfo[]>;
89
- screenshot(): Promise<string>;
90
+ screenshotBase64(): Promise<string>;
90
91
  get mouse(): {
91
92
  click: (x: number, y: number, options?: {
92
93
  button: MouseButton;
@@ -116,7 +117,7 @@ declare class StaticPage implements AbstractPage {
116
117
  private uiContext;
117
118
  constructor(uiContext: WebUIContext);
118
119
  getElementInfos(): Promise<any>;
119
- screenshot(): Promise<string>;
120
+ screenshotBase64(): Promise<string>;
120
121
  url(): string;
121
122
  scrollUntilTop(): Promise<any>;
122
123
  scrollUntilBottom(): Promise<any>;
@@ -136,12 +137,12 @@ declare class StaticPage implements AbstractPage {
136
137
  }
137
138
 
138
139
  declare class Page<AgentType extends 'puppeteer' | 'playwright', PageType extends Page$2 | Page$3> implements AbstractPage {
139
- private page;
140
+ private underlyingPage;
140
141
  pageType: AgentType;
141
142
  private evaluate;
142
- constructor(page: PageType, pageType: AgentType);
143
+ constructor(underlyingPage: PageType, pageType: AgentType);
143
144
  getElementInfos(): Promise<ElementInfo[]>;
144
- screenshot(): Promise<string>;
145
+ screenshotBase64(): Promise<string>;
145
146
  url(): string;
146
147
  get mouse(): {
147
148
  click: (x: number, y: number, options?: {
@@ -178,4 +179,4 @@ declare class WebPage extends Page<'playwright', Page$3> {
178
179
  constructor(page: Page$3);
179
180
  }
180
181
 
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 };
182
+ export { type ElementInfo as E, Page$1 as P, StaticPage as S, type WebPage$1 as W, WebPage$2 as a, WebPage as b, ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED as c, type WebUIContext as d, WebElementInfo as e };
@@ -1,30 +1,15 @@
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-8117b0ad.js';
2
+ export { c as ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED } from './page-8117b0ad.js';
3
+ import { P as PageAgent } from './tasks-cb6bf758.js';
9
4
  import 'playwright';
10
5
  import 'puppeteer';
6
+ import '@midscene/core';
11
7
  import '@midscene/shared/constants';
12
8
  import 'webdriverio';
9
+ import '@midscene/shared/fs';
13
10
 
14
11
  declare class StaticPageAgent extends PageAgent {
15
12
  constructor(page: StaticPage);
16
13
  }
17
14
 
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 };
15
+ 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-cb6bf758.js';
5
+ export { P as PlaywrightAgent } from './tasks-cb6bf758.js';
6
+ export { b as PlaywrightWebPage } from './page-8117b0ad.js';
8
7
  import '@midscene/core';
9
8
  import '@midscene/shared/fs';
10
9
  import 'puppeteer';
@@ -1,7 +1,6 @@
1
- import { P as PageAgent, a as PageAgentOpt } from './tasks-82c1054b.js';
1
+ import { P as PageAgent, a as PageAgentOpt } from './tasks-cb6bf758.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-8117b0ad.js';
5
4
  import '@midscene/core';
6
5
  import '@midscene/shared/fs';
7
6
  import 'playwright';
@@ -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-8117b0ad.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
  }
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.1",
4
+ "version": "0.7.2-beta-20241024094141.0",
5
5
  "repository": "https://github.com/web-infra-dev/midscene",
6
6
  "homepage": "https://midscenejs.com/",
7
7
  "jsnext:source": "./src/index.ts",
@@ -18,7 +18,8 @@
18
18
  "./playground": "./dist/lib/playground.js",
19
19
  "./debug": "./dist/lib/debug.js",
20
20
  "./constants": "./dist/lib/constants.js",
21
- "./html-element": "./dist/lib/html-element/index.js"
21
+ "./html-element": "./dist/lib/html-element/index.js",
22
+ "./browser/playground": "./dist/browser/playground.js"
22
23
  },
23
24
  "typesVersions": {
24
25
  "*": {
@@ -45,6 +46,9 @@
45
46
  ],
46
47
  "html-element": [
47
48
  "./dist/types/html-element/index.d.ts"
49
+ ],
50
+ "browser/playground": [
51
+ "./dist/browser/types/playground.d.ts"
48
52
  ]
49
53
  }
50
54
  },
@@ -60,11 +64,12 @@
60
64
  "inquirer": "10.1.5",
61
65
  "cors": "2.8.5",
62
66
  "@xmldom/xmldom": "0.8.10",
63
- "@midscene/core": "0.7.1",
64
- "@midscene/shared": "0.7.1"
67
+ "@midscene/shared": "0.7.2-beta-20241024094141.0",
68
+ "@midscene/core": "0.7.2-beta-20241024094141.0"
65
69
  },
66
70
  "devDependencies": {
67
71
  "@modern-js/module-tools": "2.58.2",
72
+ "@modern-js/plugin-module-node-polyfill": "2.58.2",
68
73
  "@playwright/test": "1.44.1",
69
74
  "@types/cors": "2.8.12",
70
75
  "@types/fs-extra": "11.0.4",
@@ -108,7 +113,8 @@
108
113
  "scripts": {
109
114
  "dev": "modern dev",
110
115
  "dev:server": "npm run build && ./bin/midscene-playground",
111
- "build": "npm run build:pkg && npm run build:script",
116
+ "build": "npm run build:pkg && npm run build:script && npm run build:browser",
117
+ "build:browser": "modern build -c ./modern.browser.config.ts",
112
118
  "build:pkg": "modern build -c ./modern.config.ts",
113
119
  "build:script": "modern build -c ./modern.inspect.config.ts",
114
120
  "build:watch": "modern build -w -c ./modern.config.ts & modern build -w -c ./modern.inspect.config.ts",