@midscene/web 0.11.1 → 0.11.3

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.
Files changed (38) hide show
  1. package/dist/es/appium.js +85 -39
  2. package/dist/es/bridge-mode-browser.js +58 -19
  3. package/dist/es/bridge-mode.js +62 -43
  4. package/dist/es/chrome-extension.js +105 -51
  5. package/dist/es/index.js +292 -218
  6. package/dist/es/midscene-playground.js +57 -38
  7. package/dist/es/playground.js +57 -38
  8. package/dist/es/playwright-report.js +4 -0
  9. package/dist/es/playwright.js +252 -203
  10. package/dist/es/puppeteer.js +86 -60
  11. package/dist/es/ui-utils.js +43 -0
  12. package/dist/lib/appium.js +85 -39
  13. package/dist/lib/bridge-mode-browser.js +58 -19
  14. package/dist/lib/bridge-mode.js +62 -43
  15. package/dist/lib/chrome-extension.js +105 -51
  16. package/dist/lib/index.js +292 -218
  17. package/dist/lib/midscene-playground.js +57 -38
  18. package/dist/lib/playground.js +57 -38
  19. package/dist/lib/playwright-report.js +4 -0
  20. package/dist/lib/playwright.js +252 -203
  21. package/dist/lib/puppeteer.js +86 -60
  22. package/dist/lib/ui-utils.js +43 -0
  23. package/dist/types/{tasks-d5a01262.d.ts → agent-ae110e80.d.ts} +43 -43
  24. package/dist/types/appium.d.ts +3 -3
  25. package/dist/types/bridge-mode-browser.d.ts +3 -3
  26. package/dist/types/bridge-mode.d.ts +4 -4
  27. package/dist/types/{browser-7d5614fb.d.ts → browser-9d620553.d.ts} +4 -4
  28. package/dist/types/chrome-extension.d.ts +4 -4
  29. package/dist/types/index.d.ts +8 -8
  30. package/dist/types/{page-77af8d5f.d.ts → page-97720803.d.ts} +34 -8
  31. package/dist/types/playground.d.ts +4 -4
  32. package/dist/types/playwright.d.ts +13 -7
  33. package/dist/types/puppeteer.d.ts +3 -3
  34. package/dist/types/ui-utils.d.ts +6 -1
  35. package/dist/types/{utils-1a3bc661.d.ts → utils-93b3f5f3.d.ts} +1 -1
  36. package/dist/types/utils.d.ts +2 -2
  37. package/dist/types/yaml.d.ts +4 -4
  38. package/package.json +6 -6
@@ -1,11 +1,10 @@
1
+ import { b as PageTaskExecutor, P as PageAgent, a as PageAgentOpt } from './agent-ae110e80.js';
2
+ import { Page } from 'playwright';
1
3
  import { AgentWaitForOpt } from '@midscene/core';
2
4
  import { TestInfo } from '@playwright/test';
3
- import { Page } from 'playwright';
4
- import { b as PageTaskExecutor } from './tasks-d5a01262.js';
5
- export { P as PlaywrightAgent } from './tasks-d5a01262.js';
6
- export { b as PlaywrightWebPage } from './page-77af8d5f.js';
7
5
  export { overrideAIConfig } from '@midscene/core/env';
8
- import '@midscene/core/dist/lib/types/types-4eebf154';
6
+ export { b as PlaywrightWebPage } from './page-97720803.js';
7
+ import '@midscene/core/dist/lib/types/types-95b0888e';
9
8
  import '@midscene/core/ai-model';
10
9
  import '@midscene/shared/fs';
11
10
  import '@midscene/shared/extractor';
@@ -13,7 +12,9 @@ import 'puppeteer';
13
12
  import '@midscene/shared/constants';
14
13
  import 'webdriverio';
15
14
 
16
- declare const PlaywrightAiFixture: () => {
15
+ declare const PlaywrightAiFixture: (options?: {
16
+ forceSameTabNavigation?: boolean;
17
+ }) => {
17
18
  ai: ({ page }: {
18
19
  page: Page;
19
20
  }, use: any, testInfo: TestInfo) => Promise<void>;
@@ -33,6 +34,7 @@ declare const PlaywrightAiFixture: () => {
33
34
  type PlayWrightAiFixtureType = {
34
35
  ai: <T = any>(prompt: string, opts?: {
35
36
  type?: 'action' | 'query';
37
+ trackNewTab?: boolean;
36
38
  }) => Promise<T>;
37
39
  aiAction: (taskPrompt: string) => ReturnType<PageTaskExecutor['action']>;
38
40
  aiQuery: <T = any>(demand: any) => Promise<T>;
@@ -40,4 +42,8 @@ type PlayWrightAiFixtureType = {
40
42
  aiWaitFor: (assertion: string, opt?: AgentWaitForOpt) => Promise<void>;
41
43
  };
42
44
 
43
- export { type PlayWrightAiFixtureType, PlaywrightAiFixture };
45
+ declare class PlaywrightAgent extends PageAgent {
46
+ constructor(page: Page, opts?: PageAgentOpt);
47
+ }
48
+
49
+ export { type PlayWrightAiFixtureType, PlaywrightAgent, PlaywrightAiFixture };
@@ -1,9 +1,9 @@
1
- import { P as PageAgent, a as PageAgentOpt } from './tasks-d5a01262.js';
1
+ import { P as PageAgent, a as PageAgentOpt } from './agent-ae110e80.js';
2
2
  import { Page } from 'puppeteer';
3
- export { a as PuppeteerWebPage } from './page-77af8d5f.js';
3
+ export { a as PuppeteerWebPage } from './page-97720803.js';
4
4
  export { overrideAIConfig } from '@midscene/core/env';
5
5
  import { MidsceneYamlScriptEnv } from '@midscene/core';
6
- import '@midscene/core/dist/lib/types/types-4eebf154';
6
+ import '@midscene/core/dist/lib/types/types-95b0888e';
7
7
  import '@midscene/core/ai-model';
8
8
  import '@midscene/shared/fs';
9
9
  import 'playwright';
@@ -1,6 +1,11 @@
1
1
  import { ExecutionTask } from '@midscene/core';
2
2
 
3
3
  declare function typeStr(task: ExecutionTask): any;
4
+ declare function getKeyCommands(value: string | string[]): Array<{
5
+ key: string;
6
+ command?: string;
7
+ }>;
4
8
  declare function paramStr(task: ExecutionTask): string;
9
+ declare const limitOpenNewTabScript = "\nif (!window.__MIDSCENE_NEW_TAB_INTERCEPTOR_INITIALIZED__) {\n window.__MIDSCENE_NEW_TAB_INTERCEPTOR_INITIALIZED__ = true;\n\n // Intercept the window.open method (only once)\n window.open = function(url) {\n console.log('Blocked window.open:', url);\n window.location.href = url;\n return null;\n };\n\n // Block all a tag clicks with target=\"_blank\" (only once)\n document.addEventListener('click', function(e) {\n const target = e.target.closest('a');\n if (target && target.target === '_blank') {\n e.preventDefault();\n console.log('Blocked new tab:', target.href);\n window.location.href = target.href;\n target.removeAttribute('target');\n }\n }, true);\n}\n";
5
10
 
6
- export { paramStr, typeStr };
11
+ export { getKeyCommands, limitOpenNewTabScript, paramStr, typeStr };
@@ -1,4 +1,4 @@
1
- import { P as PageAgent } from './tasks-d5a01262.js';
1
+ import { P as PageAgent } from './agent-ae110e80.js';
2
2
  import { ScriptPlayerTaskStatus, ScriptPlayerStatusValue, MidsceneYamlScript, MidsceneYamlScriptEnv, FreeFn, MidsceneYamlFlowItem } from '@midscene/core';
3
3
 
4
4
  declare class ScriptPlayer {
@@ -1,8 +1,8 @@
1
1
  import '@midscene/core';
2
- export { E as ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED, c as WebUIContext, h as generateCacheId, f as getCurrentExecutionFile, g as getExtraReturnLogic, p as parseContextFromWebPage, e as printReportMsg, r as reportFileName } from './page-77af8d5f.js';
2
+ export { E as ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED, c as WebUIContext, h as generateCacheId, f as getCurrentExecutionFile, g as getExtraReturnLogic, p as parseContextFromWebPage, e as printReportMsg, r as reportFileName } from './page-97720803.js';
3
3
  import 'playwright';
4
4
  import '@midscene/shared/extractor';
5
5
  import 'puppeteer';
6
6
  import '@midscene/shared/constants';
7
- import '@midscene/core/dist/lib/types/types-4eebf154';
7
+ import '@midscene/core/dist/lib/types/types-95b0888e';
8
8
  import 'webdriverio';
@@ -1,8 +1,8 @@
1
- export { S as ScriptPlayer, f as flowItemBrief, p as parseYamlScript } from './utils-1a3bc661.js';
1
+ export { S as ScriptPlayer, f as flowItemBrief, p as parseYamlScript } from './utils-93b3f5f3.js';
2
2
  import { MidsceneYamlScriptEnv, MidsceneYamlTask } from '@midscene/core';
3
- import './tasks-d5a01262.js';
4
- import '@midscene/core/dist/lib/types/types-4eebf154';
5
- import './page-77af8d5f.js';
3
+ import './agent-ae110e80.js';
4
+ import '@midscene/core/dist/lib/types/types-95b0888e';
5
+ import './page-97720803.js';
6
6
  import 'playwright';
7
7
  import '@midscene/shared/extractor';
8
8
  import 'puppeteer';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@midscene/web",
3
3
  "description": "Automate browser actions, extract data, and perform assertions using AI. It offers JavaScript SDK, Chrome extension, and support for scripting in YAML. See https://midscenejs.com/ for details.",
4
- "version": "0.11.1",
4
+ "version": "0.11.3",
5
5
  "repository": "https://github.com/web-infra-dev/midscene",
6
6
  "homepage": "https://midscenejs.com/",
7
7
  "jsnext:source": "./src/index.ts",
@@ -133,8 +133,8 @@
133
133
  "openai": "4.81.0",
134
134
  "socket.io": "4.8.1",
135
135
  "socket.io-client": "4.8.1",
136
- "@midscene/core": "0.11.1",
137
- "@midscene/shared": "0.11.1"
136
+ "@midscene/core": "0.11.3",
137
+ "@midscene/shared": "0.11.3"
138
138
  },
139
139
  "devDependencies": {
140
140
  "@modern-js/module-tools": "2.60.6",
@@ -153,9 +153,9 @@
153
153
  "js-sha256": "0.11.0",
154
154
  "js-yaml": "4.1.0",
155
155
  "playwright": "1.44.1",
156
- "puppeteer": "23.0.2",
156
+ "puppeteer": "24.2.0",
157
157
  "typescript": "~5.0.4",
158
- "vitest": "^1.6.0",
158
+ "vitest": "3.0.5",
159
159
  "webdriverio": "9.0.6"
160
160
  },
161
161
  "peerDependencies": {
@@ -191,7 +191,7 @@
191
191
  "test": "vitest --run",
192
192
  "test:u": "vitest --run -u",
193
193
  "test:ai": "AI_TEST_TYPE=web npm run test",
194
- "test:ai:temp": "AI_TEST_TYPE=web BRIDGE_MODE=true vitest --run tests/ai/bridge/temp.test.ts",
194
+ "test:ai:temp": "MIDSCENE_CACHE=true AI_TEST_TYPE=web BRIDGE_MODE=true vitest --run tests/ai/bridge/open-new-tab.test.ts",
195
195
  "test:ai:bridge": "MIDSCENE_CACHE=true BRIDGE_MODE=true AI_TEST_TYPE=web npm run test --inspect tests/ai/bridge/temp.test.ts",
196
196
  "test:ai:cache": "MIDSCENE_CACHE=true AI_TEST_TYPE=web npm run test",
197
197
  "test:ai:all": "npm run test:ai:web && npm run test:ai:native",