@midscene/web 0.28.3 → 0.28.4

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/dist/es/bin.mjs CHANGED
@@ -1,6 +1,24 @@
1
1
  import { PlaygroundServer } from "@midscene/playground";
2
+ import cors from "cors";
2
3
  import { StaticPage, StaticPageAgent } from "./static/index.mjs";
3
- const server = new PlaygroundServer(StaticPage, StaticPageAgent);
4
+ import "dotenv/config";
5
+ const page = new StaticPage({
6
+ tree: {
7
+ node: null,
8
+ children: []
9
+ },
10
+ size: {
11
+ width: 800,
12
+ height: 600
13
+ },
14
+ screenshotBase64: ''
15
+ });
16
+ const agent = new StaticPageAgent(page);
17
+ const server = new PlaygroundServer(page, agent);
18
+ server.app.use(cors({
19
+ origin: '*',
20
+ credentials: true
21
+ }));
4
22
  Promise.resolve().then(()=>server.launch()).then(()=>{
5
23
  console.log(`Midscene playground server is running on http://localhost:${server.port}`);
6
24
  });
@@ -1 +1 @@
1
- {"version":3,"file":"bin.mjs","sources":["webpack://@midscene/web/./src/bin.ts"],"sourcesContent":["import { PlaygroundServer } from '@midscene/playground';\nimport { StaticPage, StaticPageAgent } from './static';\n\nconst server = new PlaygroundServer(StaticPage, StaticPageAgent);\nPromise.resolve()\n .then(() => server.launch())\n .then(() => {\n console.log(\n `Midscene playground server is running on http://localhost:${server.port}`,\n );\n });\n"],"names":["server","PlaygroundServer","StaticPage","StaticPageAgent","Promise","console"],"mappings":";;AAGA,MAAMA,SAAS,IAAIC,iBAAiBC,YAAYC;AAChDC,QAAQ,OAAO,GACZ,IAAI,CAAC,IAAMJ,OAAO,MAAM,IACxB,IAAI,CAAC;IACJK,QAAQ,GAAG,CACT,CAAC,0DAA0D,EAAEL,OAAO,IAAI,EAAE;AAE9E"}
1
+ {"version":3,"file":"bin.mjs","sources":["webpack://@midscene/web/./src/bin.ts"],"sourcesContent":["import { PlaygroundServer } from '@midscene/playground';\nimport cors from 'cors';\nimport { StaticPage, StaticPageAgent } from './static';\nimport 'dotenv/config';\n\n// Create page and agent instances with minimal valid data\nconst page = new StaticPage({\n tree: {\n node: null,\n children: [],\n },\n size: { width: 800, height: 600 },\n screenshotBase64: '',\n});\nconst agent = new StaticPageAgent(page);\n\n// Create server\nconst server = new PlaygroundServer(page, agent);\n\n// Register CORS middleware\nserver.app.use(\n cors({\n origin: '*',\n credentials: true,\n }),\n);\n\nPromise.resolve()\n .then(() => server.launch())\n .then(() => {\n console.log(\n `Midscene playground server is running on http://localhost:${server.port}`,\n );\n });\n"],"names":["page","StaticPage","agent","StaticPageAgent","server","PlaygroundServer","cors","Promise","console"],"mappings":";;;;AAMA,MAAMA,OAAO,IAAIC,WAAW;IAC1B,MAAM;QACJ,MAAM;QACN,UAAU,EAAE;IACd;IACA,MAAM;QAAE,OAAO;QAAK,QAAQ;IAAI;IAChC,kBAAkB;AACpB;AACA,MAAMC,QAAQ,IAAIC,gBAAgBH;AAGlC,MAAMI,SAAS,IAAIC,iBAAiBL,MAAME;AAG1CE,OAAO,GAAG,CAAC,GAAG,CACZE,KAAK;IACH,QAAQ;IACR,aAAa;AACf;AAGFC,QAAQ,OAAO,GACZ,IAAI,CAAC,IAAMH,OAAO,MAAM,IACxB,IAAI,CAAC;IACJI,QAAQ,GAAG,CACT,CAAC,0DAA0D,EAAEJ,OAAO,IAAI,EAAE;AAE9E"}
@@ -17,7 +17,7 @@ class BridgeClient {
17
17
  this.socket = io(this.endpoint, {
18
18
  reconnection: false,
19
19
  query: {
20
- version: "0.28.3"
20
+ version: "0.28.4"
21
21
  }
22
22
  });
23
23
  const timeout = setTimeout(()=>{
@@ -71,7 +71,7 @@ class BridgeServer {
71
71
  logMsg('one client connected');
72
72
  this.socket = socket;
73
73
  const clientVersion = socket.handshake.query.version;
74
- logMsg(`Bridge connected, cli-side version v0.28.3, browser-side version v${clientVersion}`);
74
+ logMsg(`Bridge connected, cli-side version v0.28.4, browser-side version v${clientVersion}`);
75
75
  socket.on(BridgeEvent.CallResponse, (params)=>{
76
76
  const id = params.id;
77
77
  const response = params.response;
@@ -99,7 +99,7 @@ class BridgeServer {
99
99
  var _this_onConnect, _this;
100
100
  null == (_this_onConnect = (_this = this).onConnect) || _this_onConnect.call(_this);
101
101
  const payload = {
102
- version: "0.28.3"
102
+ version: "0.28.4"
103
103
  };
104
104
  socket.emit(BridgeEvent.Connected, payload);
105
105
  Promise.resolve().then(()=>{
@@ -45,7 +45,7 @@ class ExtensionBridgePageBrowserSide extends page {
45
45
  }
46
46
  }, ()=>this.destroy());
47
47
  await this.bridgeClient.connect();
48
- this.onLogMessage(`Bridge connected, cli-side version v${this.bridgeClient.serverVersion}, browser-side version v0.28.3`, 'log');
48
+ this.onLogMessage(`Bridge connected, cli-side version v${this.bridgeClient.serverVersion}, browser-side version v0.28.4`, 'log');
49
49
  }
50
50
  async connect() {
51
51
  return await this.setupBridgeClient();
@@ -102,6 +102,9 @@ class StaticPage {
102
102
  async getContext() {
103
103
  return this.uiContext;
104
104
  }
105
+ updateContext(newContext) {
106
+ this.uiContext = newContext;
107
+ }
105
108
  constructor(uiContext){
106
109
  _define_property(this, "interfaceType", 'static');
107
110
  _define_property(this, "uiContext", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"static/static-page.mjs","sources":["webpack://@midscene/web/./src/static/static-page.ts"],"sourcesContent":["import type { DeviceAction, Point, UIContext } from '@midscene/core';\nimport type { AbstractInterface } from '@midscene/core/device';\nimport {\n defineActionDragAndDrop,\n defineActionHover,\n defineActionInput,\n defineActionKeyboardPress,\n defineActionRightClick,\n defineActionScroll,\n defineActionTap,\n} from '@midscene/core/device';\nimport { ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED } from '@midscene/shared/common';\n\ntype WebUIContext = UIContext & {\n screenshotBase64?: string;\n size: { width: number; height: number; dpr?: number };\n};\n\nconst ThrowNotImplemented = (methodName: string) => {\n throw new Error(\n `The method \"${methodName}\" is not implemented as designed since this is a static UI context. (${ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED})`,\n );\n};\n\nexport default class StaticPage implements AbstractInterface {\n interfaceType = 'static';\n\n private uiContext: WebUIContext;\n\n constructor(uiContext: WebUIContext) {\n if (uiContext.tree) {\n this.uiContext = uiContext;\n } else {\n this.uiContext = Object.assign(uiContext, {\n tree: {\n node: null,\n children: [],\n },\n });\n }\n }\n\n actionSpace(): DeviceAction[] {\n // Return available actions for static page - they will throw \"not implemented\" errors when executed\n // but need to be available for planning phase\n return [\n defineActionTap(async (param) => {\n ThrowNotImplemented('Tap');\n }),\n defineActionRightClick(async (param) => {\n ThrowNotImplemented('RightClick');\n }),\n defineActionHover(async (param) => {\n ThrowNotImplemented('Hover');\n }),\n defineActionInput(async (param) => {\n ThrowNotImplemented('Input');\n }),\n defineActionKeyboardPress(async (param) => {\n ThrowNotImplemented('KeyboardPress');\n }),\n defineActionScroll(async (param) => {\n ThrowNotImplemented('Scroll');\n }),\n defineActionDragAndDrop(async (param) => {\n ThrowNotImplemented('DragAndDrop');\n }),\n ];\n }\n\n async evaluateJavaScript<T = unknown>(script: string): Promise<T> {\n return ThrowNotImplemented('evaluateJavaScript');\n }\n\n // @deprecated\n async getElementsInfo() {\n return ThrowNotImplemented('getElementsInfo');\n }\n\n async getElementsNodeTree() {\n return ThrowNotImplemented('getElementsNodeTree');\n }\n\n async getXpathsById(id: string) {\n return ThrowNotImplemented('getXpathsById');\n }\n\n async getXpathsByPoint(point: Point) {\n return ThrowNotImplemented('getXpathsByPoint');\n }\n\n async getElementInfoByXpath(xpath: string) {\n return ThrowNotImplemented('getElementInfoByXpath');\n }\n\n async size() {\n return {\n ...this.uiContext.size,\n dpr: this.uiContext.size.dpr || 1,\n };\n }\n\n async screenshotBase64() {\n const base64 = this.uiContext.screenshotBase64;\n if (!base64) {\n throw new Error('screenshot base64 is empty');\n }\n return base64;\n }\n\n async url() {\n return Promise.resolve('https://static_page_without_url');\n }\n\n async scrollUntilTop(startingPoint?: Point) {\n return ThrowNotImplemented('scrollUntilTop');\n }\n\n async scrollUntilBottom(startingPoint?: Point) {\n return ThrowNotImplemented('scrollUntilBottom');\n }\n\n async scrollUntilLeft(startingPoint?: Point) {\n return ThrowNotImplemented('scrollUntilLeft');\n }\n\n async scrollUntilRight(startingPoint?: Point) {\n return ThrowNotImplemented('scrollUntilRight');\n }\n\n async scrollUp(distance?: number, startingPoint?: Point) {\n return ThrowNotImplemented('scrollUp');\n }\n\n async scrollDown(distance?: number, startingPoint?: Point) {\n return ThrowNotImplemented('scrollDown');\n }\n\n async scrollLeft(distance?: number, startingPoint?: Point) {\n return ThrowNotImplemented('scrollLeft');\n }\n\n async scrollRight(distance?: number, startingPoint?: Point) {\n return ThrowNotImplemented('scrollRight');\n }\n\n async clearInput() {\n return ThrowNotImplemented('clearInput');\n }\n\n mouse = {\n click: ThrowNotImplemented.bind(null, 'mouse.click'),\n wheel: ThrowNotImplemented.bind(null, 'mouse.wheel'),\n move: ThrowNotImplemented.bind(null, 'mouse.move'),\n drag: ThrowNotImplemented.bind(null, 'mouse.drag'),\n };\n\n keyboard = {\n type: ThrowNotImplemented.bind(null, 'keyboard.type'),\n press: ThrowNotImplemented.bind(null, 'keyboard.press'),\n };\n\n async destroy(): Promise<void> {\n //\n }\n\n async getContext(): Promise<UIContext> {\n return this.uiContext;\n }\n}\n"],"names":["ThrowNotImplemented","methodName","Error","ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED","StaticPage","defineActionTap","param","defineActionRightClick","defineActionHover","defineActionInput","defineActionKeyboardPress","defineActionScroll","defineActionDragAndDrop","script","id","point","xpath","base64","Promise","startingPoint","distance","uiContext","Object"],"mappings":";;;;;;;;;;;;AAkBA,MAAMA,sBAAsB,CAACC;IAC3B,MAAM,IAAIC,MACR,CAAC,YAAY,EAAED,WAAW,qEAAqE,EAAEE,uCAAuC,CAAC,CAAC;AAE9I;AAEe,MAAMC;IAkBnB,cAA8B;QAG5B,OAAO;YACLC,gBAAgB,OAAOC;gBACrBN,oBAAoB;YACtB;YACAO,uB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,SAASoB,QAAiB,EAAED,aAAqB,EAAE;QACvD,OAAOnB,oBAAoB;IAC7B;IAEA,MAAM,WAAWoB,QAAiB,EAAED,aAAqB,EAAE;QACzD,OAAOnB,oBAAoB;IAC7B;IAEA,MAAM,WAAWoB,QAAiB,EAAED,aAAqB,EAAE;QACzD,OAAOnB,oBAAoB;IAC7B;IAEA,MAAM,YAAYoB,QAAiB,EAAED,aAAqB,EAAE;QAC1D,OAAOnB,oBAAoB;IAC7B;IAEA,MAAM,aAAa;QACjB,OAAOA,oBAAoB;IAC7B;IAcA,MAAM,UAAyB,CAE/B;IAEA,MAAM,aAAiC;QACrC,OAAO,IAAI,CAAC,SAAS;IACvB;IA3IA,YAAYqB,SAAuB,CAAE;QAJrC,wCAAgB;QAEhB,uBAAQ,aAAR;QA2HA,gCAAQ;YACN,OAAOrB,oBAAoB,IAAI,CAAC,MAAM;YACtC,OAAOA,oBAAoB,IAAI,CAAC,MAAM;YACtC,MAAMA,oBAAoB,IAAI,CAAC,MAAM;YACrC,MAAMA,oBAAoB,IAAI,CAAC,MAAM;QACvC;QAEA,mCAAW;YACT,MAAMA,oBAAoB,IAAI,CAAC,MAAM;YACrC,OAAOA,oBAAoB,IAAI,CAAC,MAAM;QACxC;QAlIE,IAAIqB,UAAU,IAAI,EAChB,IAAI,CAAC,SAAS,GAAGA;aAEjB,IAAI,CAAC,SAAS,GAAGC,OAAO,MAAM,CAACD,WAAW;YACxC,MAAM;gBACJ,MAAM;gBACN,UAAU,EAAE;YACd;QACF;IAEJ;AAiIF"}
1
+ {"version":3,"file":"static/static-page.mjs","sources":["webpack://@midscene/web/./src/static/static-page.ts"],"sourcesContent":["import type { DeviceAction, Point, UIContext } from '@midscene/core';\nimport type { AbstractInterface } from '@midscene/core/device';\nimport {\n defineActionDragAndDrop,\n defineActionHover,\n defineActionInput,\n defineActionKeyboardPress,\n defineActionRightClick,\n defineActionScroll,\n defineActionTap,\n} from '@midscene/core/device';\nimport { ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED } from '@midscene/shared/common';\n\ntype WebUIContext = UIContext & {\n screenshotBase64?: string;\n size: { width: number; height: number; dpr?: number };\n};\n\nconst ThrowNotImplemented = (methodName: string) => {\n throw new Error(\n `The method \"${methodName}\" is not implemented as designed since this is a static UI context. (${ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED})`,\n );\n};\n\nexport default class StaticPage implements AbstractInterface {\n interfaceType = 'static';\n\n private uiContext: WebUIContext;\n\n constructor(uiContext: WebUIContext) {\n if (uiContext.tree) {\n this.uiContext = uiContext;\n } else {\n this.uiContext = Object.assign(uiContext, {\n tree: {\n node: null,\n children: [],\n },\n });\n }\n }\n\n actionSpace(): DeviceAction[] {\n // Return available actions for static page - they will throw \"not implemented\" errors when executed\n // but need to be available for planning phase\n return [\n defineActionTap(async (param) => {\n ThrowNotImplemented('Tap');\n }),\n defineActionRightClick(async (param) => {\n ThrowNotImplemented('RightClick');\n }),\n defineActionHover(async (param) => {\n ThrowNotImplemented('Hover');\n }),\n defineActionInput(async (param) => {\n ThrowNotImplemented('Input');\n }),\n defineActionKeyboardPress(async (param) => {\n ThrowNotImplemented('KeyboardPress');\n }),\n defineActionScroll(async (param) => {\n ThrowNotImplemented('Scroll');\n }),\n defineActionDragAndDrop(async (param) => {\n ThrowNotImplemented('DragAndDrop');\n }),\n ];\n }\n\n async evaluateJavaScript<T = unknown>(script: string): Promise<T> {\n return ThrowNotImplemented('evaluateJavaScript');\n }\n\n // @deprecated\n async getElementsInfo() {\n return ThrowNotImplemented('getElementsInfo');\n }\n\n async getElementsNodeTree() {\n return ThrowNotImplemented('getElementsNodeTree');\n }\n\n async getXpathsById(id: string) {\n return ThrowNotImplemented('getXpathsById');\n }\n\n async getXpathsByPoint(point: Point) {\n return ThrowNotImplemented('getXpathsByPoint');\n }\n\n async getElementInfoByXpath(xpath: string) {\n return ThrowNotImplemented('getElementInfoByXpath');\n }\n\n async size() {\n return {\n ...this.uiContext.size,\n dpr: this.uiContext.size.dpr || 1,\n };\n }\n\n async screenshotBase64() {\n const base64 = this.uiContext.screenshotBase64;\n if (!base64) {\n throw new Error('screenshot base64 is empty');\n }\n return base64;\n }\n\n async url() {\n return Promise.resolve('https://static_page_without_url');\n }\n\n async scrollUntilTop(startingPoint?: Point) {\n return ThrowNotImplemented('scrollUntilTop');\n }\n\n async scrollUntilBottom(startingPoint?: Point) {\n return ThrowNotImplemented('scrollUntilBottom');\n }\n\n async scrollUntilLeft(startingPoint?: Point) {\n return ThrowNotImplemented('scrollUntilLeft');\n }\n\n async scrollUntilRight(startingPoint?: Point) {\n return ThrowNotImplemented('scrollUntilRight');\n }\n\n async scrollUp(distance?: number, startingPoint?: Point) {\n return ThrowNotImplemented('scrollUp');\n }\n\n async scrollDown(distance?: number, startingPoint?: Point) {\n return ThrowNotImplemented('scrollDown');\n }\n\n async scrollLeft(distance?: number, startingPoint?: Point) {\n return ThrowNotImplemented('scrollLeft');\n }\n\n async scrollRight(distance?: number, startingPoint?: Point) {\n return ThrowNotImplemented('scrollRight');\n }\n\n async clearInput() {\n return ThrowNotImplemented('clearInput');\n }\n\n mouse = {\n click: ThrowNotImplemented.bind(null, 'mouse.click'),\n wheel: ThrowNotImplemented.bind(null, 'mouse.wheel'),\n move: ThrowNotImplemented.bind(null, 'mouse.move'),\n drag: ThrowNotImplemented.bind(null, 'mouse.drag'),\n };\n\n keyboard = {\n type: ThrowNotImplemented.bind(null, 'keyboard.type'),\n press: ThrowNotImplemented.bind(null, 'keyboard.press'),\n };\n\n async destroy(): Promise<void> {\n //\n }\n\n async getContext(): Promise<UIContext> {\n return this.uiContext;\n }\n\n updateContext(newContext: WebUIContext): void {\n this.uiContext = newContext;\n }\n}\n"],"names":["ThrowNotImplemented","methodName","Error","ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED","StaticPage","defineActionTap","param","defineActionRightClick","defineActionHover","defineActionInput","defineActionKeyboardPress","defineActionScroll","defineActionDragAndDrop","script","id","point","xpath","base64","Promise","startingPoint","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;gBACN,UAAU,EAAE;YACd;QACF;IAEJ;AAqIF"}
package/dist/lib/bin.js CHANGED
@@ -1,8 +1,48 @@
1
1
  "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, definition)=>{
14
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
+ enumerable: true,
16
+ get: definition[key]
17
+ });
18
+ };
19
+ })();
20
+ (()=>{
21
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
+ })();
2
23
  var __webpack_exports__ = {};
3
24
  const playground_namespaceObject = require("@midscene/playground");
25
+ const external_cors_namespaceObject = require("cors");
26
+ var external_cors_default = /*#__PURE__*/ __webpack_require__.n(external_cors_namespaceObject);
4
27
  const index_js_namespaceObject = require("./static/index.js");
5
- const server = new playground_namespaceObject.PlaygroundServer(index_js_namespaceObject.StaticPage, index_js_namespaceObject.StaticPageAgent);
28
+ require("dotenv/config");
29
+ const page = new index_js_namespaceObject.StaticPage({
30
+ tree: {
31
+ node: null,
32
+ children: []
33
+ },
34
+ size: {
35
+ width: 800,
36
+ height: 600
37
+ },
38
+ screenshotBase64: ''
39
+ });
40
+ const agent = new index_js_namespaceObject.StaticPageAgent(page);
41
+ const server = new playground_namespaceObject.PlaygroundServer(page, agent);
42
+ server.app.use(external_cors_default()({
43
+ origin: '*',
44
+ credentials: true
45
+ }));
6
46
  Promise.resolve().then(()=>server.launch()).then(()=>{
7
47
  console.log(`Midscene playground server is running on http://localhost:${server.port}`);
8
48
  });
@@ -1 +1 @@
1
- {"version":3,"file":"bin.js","sources":["webpack://@midscene/web/./src/bin.ts"],"sourcesContent":["import { PlaygroundServer } from '@midscene/playground';\nimport { StaticPage, StaticPageAgent } from './static';\n\nconst server = new PlaygroundServer(StaticPage, StaticPageAgent);\nPromise.resolve()\n .then(() => server.launch())\n .then(() => {\n console.log(\n `Midscene playground server is running on http://localhost:${server.port}`,\n );\n });\n"],"names":["server","PlaygroundServer","StaticPage","StaticPageAgent","Promise","console"],"mappings":";;;;AAGA,MAAMA,SAAS,IAAIC,2BAAAA,gBAAgBA,CAACC,yBAAAA,UAAUA,EAAEC,yBAAAA,eAAeA;AAC/DC,QAAQ,OAAO,GACZ,IAAI,CAAC,IAAMJ,OAAO,MAAM,IACxB,IAAI,CAAC;IACJK,QAAQ,GAAG,CACT,CAAC,0DAA0D,EAAEL,OAAO,IAAI,EAAE;AAE9E"}
1
+ {"version":3,"file":"bin.js","sources":["webpack://@midscene/web/webpack/runtime/compat_get_default_export","webpack://@midscene/web/webpack/runtime/define_property_getters","webpack://@midscene/web/webpack/runtime/has_own_property","webpack://@midscene/web/./src/bin.ts"],"sourcesContent":["// getDefaultExport function for compatibility with non-ESM modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","import { PlaygroundServer } from '@midscene/playground';\nimport cors from 'cors';\nimport { StaticPage, StaticPageAgent } from './static';\nimport 'dotenv/config';\n\n// Create page and agent instances with minimal valid data\nconst page = new StaticPage({\n tree: {\n node: null,\n children: [],\n },\n size: { width: 800, height: 600 },\n screenshotBase64: '',\n});\nconst agent = new StaticPageAgent(page);\n\n// Create server\nconst server = new PlaygroundServer(page, agent);\n\n// Register CORS middleware\nserver.app.use(\n cors({\n origin: '*',\n credentials: true,\n }),\n);\n\nPromise.resolve()\n .then(() => server.launch())\n .then(() => {\n console.log(\n `Midscene playground server is running on http://localhost:${server.port}`,\n );\n });\n"],"names":["__webpack_require__","module","getter","definition","key","Object","obj","prop","page","StaticPage","agent","StaticPageAgent","server","PlaygroundServer","cors","Promise","console"],"mappings":";;;IACAA,oBAAoB,CAAC,GAAG,CAACC;QACxB,IAAIC,SAASD,UAAUA,OAAO,UAAU,GACvC,IAAOA,MAAM,CAAC,UAAU,GACxB,IAAOA;QACRD,oBAAoB,CAAC,CAACE,QAAQ;YAAE,GAAGA;QAAO;QAC1C,OAAOA;IACR;;;ICPAF,oBAAoB,CAAC,GAAG,CAAC,UAASG;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGH,oBAAoB,CAAC,CAACG,YAAYC,QAAQ,CAACJ,oBAAoB,CAAC,CAAC,UAASI,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAJ,oBAAoB,CAAC,GAAG,CAACM,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;;;;;;ACMlF,MAAMC,OAAO,IAAIC,yBAAAA,UAAUA,CAAC;IAC1B,MAAM;QACJ,MAAM;QACN,UAAU,EAAE;IACd;IACA,MAAM;QAAE,OAAO;QAAK,QAAQ;IAAI;IAChC,kBAAkB;AACpB;AACA,MAAMC,QAAQ,IAAIC,yBAAAA,eAAeA,CAACH;AAGlC,MAAMI,SAAS,IAAIC,2BAAAA,gBAAgBA,CAACL,MAAME;AAG1CE,OAAO,GAAG,CAAC,GAAG,CACZE,wBAAK;IACH,QAAQ;IACR,aAAa;AACf;AAGFC,QAAQ,OAAO,GACZ,IAAI,CAAC,IAAMH,OAAO,MAAM,IACxB,IAAI,CAAC;IACJI,QAAQ,GAAG,CACT,CAAC,0DAA0D,EAAEJ,OAAO,IAAI,EAAE;AAE9E"}
@@ -45,7 +45,7 @@ class BridgeClient {
45
45
  this.socket = (0, external_socket_io_client_namespaceObject.io)(this.endpoint, {
46
46
  reconnection: false,
47
47
  query: {
48
- version: "0.28.3"
48
+ version: "0.28.4"
49
49
  }
50
50
  });
51
51
  const timeout = setTimeout(()=>{
@@ -100,7 +100,7 @@ class BridgeServer {
100
100
  (0, shared_utils_namespaceObject.logMsg)('one client connected');
101
101
  this.socket = socket;
102
102
  const clientVersion = socket.handshake.query.version;
103
- (0, shared_utils_namespaceObject.logMsg)(`Bridge connected, cli-side version v0.28.3, browser-side version v${clientVersion}`);
103
+ (0, shared_utils_namespaceObject.logMsg)(`Bridge connected, cli-side version v0.28.4, browser-side version v${clientVersion}`);
104
104
  socket.on(external_common_js_namespaceObject.BridgeEvent.CallResponse, (params)=>{
105
105
  const id = params.id;
106
106
  const response = params.response;
@@ -128,7 +128,7 @@ class BridgeServer {
128
128
  var _this_onConnect, _this;
129
129
  null == (_this_onConnect = (_this = this).onConnect) || _this_onConnect.call(_this);
130
130
  const payload = {
131
- version: "0.28.3"
131
+ version: "0.28.4"
132
132
  };
133
133
  socket.emit(external_common_js_namespaceObject.BridgeEvent.Connected, payload);
134
134
  Promise.resolve().then(()=>{
@@ -83,7 +83,7 @@ class ExtensionBridgePageBrowserSide extends page_js_default() {
83
83
  }
84
84
  }, ()=>this.destroy());
85
85
  await this.bridgeClient.connect();
86
- this.onLogMessage(`Bridge connected, cli-side version v${this.bridgeClient.serverVersion}, browser-side version v0.28.3`, 'log');
86
+ this.onLogMessage(`Bridge connected, cli-side version v${this.bridgeClient.serverVersion}, browser-side version v0.28.4`, 'log');
87
87
  }
88
88
  async connect() {
89
89
  return await this.setupBridgeClient();
@@ -130,6 +130,9 @@ class StaticPage {
130
130
  async getContext() {
131
131
  return this.uiContext;
132
132
  }
133
+ updateContext(newContext) {
134
+ this.uiContext = newContext;
135
+ }
133
136
  constructor(uiContext){
134
137
  _define_property(this, "interfaceType", 'static');
135
138
  _define_property(this, "uiContext", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"static/static-page.js","sources":["webpack://@midscene/web/webpack/runtime/define_property_getters","webpack://@midscene/web/webpack/runtime/has_own_property","webpack://@midscene/web/webpack/runtime/make_namespace_object","webpack://@midscene/web/./src/static/static-page.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { DeviceAction, Point, UIContext } from '@midscene/core';\nimport type { AbstractInterface } from '@midscene/core/device';\nimport {\n defineActionDragAndDrop,\n defineActionHover,\n defineActionInput,\n defineActionKeyboardPress,\n defineActionRightClick,\n defineActionScroll,\n defineActionTap,\n} from '@midscene/core/device';\nimport { ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED } from '@midscene/shared/common';\n\ntype WebUIContext = UIContext & {\n screenshotBase64?: string;\n size: { width: number; height: number; dpr?: number };\n};\n\nconst ThrowNotImplemented = (methodName: string) => {\n throw new Error(\n `The method \"${methodName}\" is not implemented as designed since this is a static UI context. (${ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED})`,\n );\n};\n\nexport default class StaticPage implements AbstractInterface {\n interfaceType = 'static';\n\n private uiContext: WebUIContext;\n\n constructor(uiContext: WebUIContext) {\n if (uiContext.tree) {\n this.uiContext = uiContext;\n } else {\n this.uiContext = Object.assign(uiContext, {\n tree: {\n node: null,\n children: [],\n },\n });\n }\n }\n\n actionSpace(): DeviceAction[] {\n // Return available actions for static page - they will throw \"not implemented\" errors when executed\n // but need to be available for planning phase\n return [\n defineActionTap(async (param) => {\n ThrowNotImplemented('Tap');\n }),\n defineActionRightClick(async (param) => {\n ThrowNotImplemented('RightClick');\n }),\n defineActionHover(async (param) => {\n ThrowNotImplemented('Hover');\n }),\n defineActionInput(async (param) => {\n ThrowNotImplemented('Input');\n }),\n defineActionKeyboardPress(async (param) => {\n ThrowNotImplemented('KeyboardPress');\n }),\n defineActionScroll(async (param) => {\n ThrowNotImplemented('Scroll');\n }),\n defineActionDragAndDrop(async (param) => {\n ThrowNotImplemented('DragAndDrop');\n }),\n ];\n }\n\n async evaluateJavaScript<T = unknown>(script: string): Promise<T> {\n return ThrowNotImplemented('evaluateJavaScript');\n }\n\n // @deprecated\n async getElementsInfo() {\n return ThrowNotImplemented('getElementsInfo');\n }\n\n async getElementsNodeTree() {\n return ThrowNotImplemented('getElementsNodeTree');\n }\n\n async getXpathsById(id: string) {\n return ThrowNotImplemented('getXpathsById');\n }\n\n async getXpathsByPoint(point: Point) {\n return ThrowNotImplemented('getXpathsByPoint');\n }\n\n async getElementInfoByXpath(xpath: string) {\n return ThrowNotImplemented('getElementInfoByXpath');\n }\n\n async size() {\n return {\n ...this.uiContext.size,\n dpr: this.uiContext.size.dpr || 1,\n };\n }\n\n async screenshotBase64() {\n const base64 = this.uiContext.screenshotBase64;\n if (!base64) {\n throw new Error('screenshot base64 is empty');\n }\n return base64;\n }\n\n async url() {\n return Promise.resolve('https://static_page_without_url');\n }\n\n async scrollUntilTop(startingPoint?: Point) {\n return ThrowNotImplemented('scrollUntilTop');\n }\n\n async scrollUntilBottom(startingPoint?: Point) {\n return ThrowNotImplemented('scrollUntilBottom');\n }\n\n async scrollUntilLeft(startingPoint?: Point) {\n return ThrowNotImplemented('scrollUntilLeft');\n }\n\n async scrollUntilRight(startingPoint?: Point) {\n return ThrowNotImplemented('scrollUntilRight');\n }\n\n async scrollUp(distance?: number, startingPoint?: Point) {\n return ThrowNotImplemented('scrollUp');\n }\n\n async scrollDown(distance?: number, startingPoint?: Point) {\n return ThrowNotImplemented('scrollDown');\n }\n\n async scrollLeft(distance?: number, startingPoint?: Point) {\n return ThrowNotImplemented('scrollLeft');\n }\n\n async scrollRight(distance?: number, startingPoint?: Point) {\n return ThrowNotImplemented('scrollRight');\n }\n\n async clearInput() {\n return ThrowNotImplemented('clearInput');\n }\n\n mouse = {\n click: ThrowNotImplemented.bind(null, 'mouse.click'),\n wheel: ThrowNotImplemented.bind(null, 'mouse.wheel'),\n move: ThrowNotImplemented.bind(null, 'mouse.move'),\n drag: ThrowNotImplemented.bind(null, 'mouse.drag'),\n };\n\n keyboard = {\n type: ThrowNotImplemented.bind(null, 'keyboard.type'),\n press: ThrowNotImplemented.bind(null, 'keyboard.press'),\n };\n\n async destroy(): Promise<void> {\n //\n }\n\n async getContext(): Promise<UIContext> {\n return this.uiContext;\n }\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","ThrowNotImplemented","methodName","Error","ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED","StaticPage","defineActionTap","param","defineActionRightClick","defineActionHover","defineActionInput","defineActionKeyboardPress","defineActionScroll","defineActionDragAndDrop","script","id","point","xpath","base64","Promise","startingPoint","distance","uiContext"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,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AW;YACT,MAAMA,oBAAoB,IAAI,CAAC,MAAM;YACrC,OAAOA,oBAAoB,IAAI,CAAC,MAAM;QACxC;QAlIE,IAAIqB,UAAU,IAAI,EAChB,IAAI,CAAC,SAAS,GAAGA;aAEjB,IAAI,CAAC,SAAS,GAAGzB,OAAO,MAAM,CAACyB,WAAW;YACxC,MAAM;gBACJ,MAAM;gBACN,UAAU,EAAE;YACd;QACF;IAEJ;AAiIF"}
1
+ {"version":3,"file":"static/static-page.js","sources":["webpack://@midscene/web/webpack/runtime/define_property_getters","webpack://@midscene/web/webpack/runtime/has_own_property","webpack://@midscene/web/webpack/runtime/make_namespace_object","webpack://@midscene/web/./src/static/static-page.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { DeviceAction, Point, UIContext } from '@midscene/core';\nimport type { AbstractInterface } from '@midscene/core/device';\nimport {\n defineActionDragAndDrop,\n defineActionHover,\n defineActionInput,\n defineActionKeyboardPress,\n defineActionRightClick,\n defineActionScroll,\n defineActionTap,\n} from '@midscene/core/device';\nimport { ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED } from '@midscene/shared/common';\n\ntype WebUIContext = UIContext & {\n screenshotBase64?: string;\n size: { width: number; height: number; dpr?: number };\n};\n\nconst ThrowNotImplemented = (methodName: string) => {\n throw new Error(\n `The method \"${methodName}\" is not implemented as designed since this is a static UI context. (${ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED})`,\n );\n};\n\nexport default class StaticPage implements AbstractInterface {\n interfaceType = 'static';\n\n private uiContext: WebUIContext;\n\n constructor(uiContext: WebUIContext) {\n if (uiContext.tree) {\n this.uiContext = uiContext;\n } else {\n this.uiContext = Object.assign(uiContext, {\n tree: {\n node: null,\n children: [],\n },\n });\n }\n }\n\n actionSpace(): DeviceAction[] {\n // Return available actions for static page - they will throw \"not implemented\" errors when executed\n // but need to be available for planning phase\n return [\n defineActionTap(async (param) => {\n ThrowNotImplemented('Tap');\n }),\n defineActionRightClick(async (param) => {\n ThrowNotImplemented('RightClick');\n }),\n defineActionHover(async (param) => {\n ThrowNotImplemented('Hover');\n }),\n defineActionInput(async (param) => {\n ThrowNotImplemented('Input');\n }),\n defineActionKeyboardPress(async (param) => {\n ThrowNotImplemented('KeyboardPress');\n }),\n defineActionScroll(async (param) => {\n ThrowNotImplemented('Scroll');\n }),\n defineActionDragAndDrop(async (param) => {\n ThrowNotImplemented('DragAndDrop');\n }),\n ];\n }\n\n async evaluateJavaScript<T = unknown>(script: string): Promise<T> {\n return ThrowNotImplemented('evaluateJavaScript');\n }\n\n // @deprecated\n async getElementsInfo() {\n return ThrowNotImplemented('getElementsInfo');\n }\n\n async getElementsNodeTree() {\n return ThrowNotImplemented('getElementsNodeTree');\n }\n\n async getXpathsById(id: string) {\n return ThrowNotImplemented('getXpathsById');\n }\n\n async getXpathsByPoint(point: Point) {\n return ThrowNotImplemented('getXpathsByPoint');\n }\n\n async getElementInfoByXpath(xpath: string) {\n return ThrowNotImplemented('getElementInfoByXpath');\n }\n\n async size() {\n return {\n ...this.uiContext.size,\n dpr: this.uiContext.size.dpr || 1,\n };\n }\n\n async screenshotBase64() {\n const base64 = this.uiContext.screenshotBase64;\n if (!base64) {\n throw new Error('screenshot base64 is empty');\n }\n return base64;\n }\n\n async url() {\n return Promise.resolve('https://static_page_without_url');\n }\n\n async scrollUntilTop(startingPoint?: Point) {\n return ThrowNotImplemented('scrollUntilTop');\n }\n\n async scrollUntilBottom(startingPoint?: Point) {\n return ThrowNotImplemented('scrollUntilBottom');\n }\n\n async scrollUntilLeft(startingPoint?: Point) {\n return ThrowNotImplemented('scrollUntilLeft');\n }\n\n async scrollUntilRight(startingPoint?: Point) {\n return ThrowNotImplemented('scrollUntilRight');\n }\n\n async scrollUp(distance?: number, startingPoint?: Point) {\n return ThrowNotImplemented('scrollUp');\n }\n\n async scrollDown(distance?: number, startingPoint?: Point) {\n return ThrowNotImplemented('scrollDown');\n }\n\n async scrollLeft(distance?: number, startingPoint?: Point) {\n return ThrowNotImplemented('scrollLeft');\n }\n\n async scrollRight(distance?: number, startingPoint?: Point) {\n return ThrowNotImplemented('scrollRight');\n }\n\n async clearInput() {\n return ThrowNotImplemented('clearInput');\n }\n\n mouse = {\n click: ThrowNotImplemented.bind(null, 'mouse.click'),\n wheel: ThrowNotImplemented.bind(null, 'mouse.wheel'),\n move: ThrowNotImplemented.bind(null, 'mouse.move'),\n drag: ThrowNotImplemented.bind(null, 'mouse.drag'),\n };\n\n keyboard = {\n type: ThrowNotImplemented.bind(null, 'keyboard.type'),\n press: ThrowNotImplemented.bind(null, 'keyboard.press'),\n };\n\n async destroy(): Promise<void> {\n //\n }\n\n async getContext(): Promise<UIContext> {\n return this.uiContext;\n }\n\n updateContext(newContext: WebUIContext): void {\n this.uiContext = newContext;\n }\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","ThrowNotImplemented","methodName","Error","ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED","StaticPage","defineActionTap","param","defineActionRightClick","defineActionHover","defineActionInput","defineActionKeyboardPress","defineActionScroll","defineActionDragAndDrop","script","id","point","xpath","base64","Promise","startingPoint","distance","newContext","uiContext"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KA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;QACrC,OAAO,IAAI,CAAC,SAAS;IACvB;IAEA,cAAcqB,UAAwB,EAAQ;QAC5C,IAAI,CAAC,SAAS,GAAGA;IACnB;IA/IA,YAAYC,SAAuB,CAAE;QAJrC,wCAAgB;QAEhB,uBAAQ,aAAR;QA2HA,gCAAQ;YACN,OAAOtB,oBAAoB,IAAI,CAAC,MAAM;YACtC,OAAOA,oBAAoB,IAAI,CAAC,MAAM;YACtC,MAAMA,oBAAoB,IAAI,CAAC,MAAM;YACrC,MAAMA,oBAAoB,IAAI,CAAC,MAAM;QACvC;QAEA,mCAAW;YACT,MAAMA,oBAAoB,IAAI,CAAC,MAAM;YACrC,OAAOA,oBAAoB,IAAI,CAAC,MAAM;QACxC;QAlIE,IAAIsB,UAAU,IAAI,EAChB,IAAI,CAAC,SAAS,GAAGA;aAEjB,IAAI,CAAC,SAAS,GAAG1B,OAAO,MAAM,CAAC0B,WAAW;YACxC,MAAM;gBACJ,MAAM;gBACN,UAAU,EAAE;YACd;QACF;IAEJ;AAqIF"}
@@ -1 +1 @@
1
- export {};
1
+ import 'dotenv/config';
@@ -47,5 +47,6 @@ export default class StaticPage implements AbstractInterface {
47
47
  };
48
48
  destroy(): Promise<void>;
49
49
  getContext(): Promise<UIContext>;
50
+ updateContext(newContext: WebUIContext): void;
50
51
  }
51
52
  export {};
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "Browser use",
9
9
  "Android use"
10
10
  ],
11
- "version": "0.28.3",
11
+ "version": "0.28.4",
12
12
  "repository": "https://github.com/web-infra-dev/midscene",
13
13
  "homepage": "https://midscenejs.com/",
14
14
  "main": "./dist/lib/index.js",
@@ -106,20 +106,22 @@
106
106
  "bin"
107
107
  ],
108
108
  "dependencies": {
109
+ "cors": "2.8.5",
109
110
  "dayjs": "^1.11.11",
110
111
  "dotenv": "16.4.5",
111
112
  "http-server": "14.1.1",
112
113
  "socket.io": "^4.8.1",
113
114
  "socket.io-client": "4.8.1",
114
- "@midscene/playground": "0.28.3",
115
- "@midscene/core": "0.28.3",
116
- "@midscene/shared": "0.28.3"
115
+ "@midscene/core": "0.28.4",
116
+ "@midscene/shared": "0.28.4",
117
+ "@midscene/playground": "0.28.4"
117
118
  },
118
119
  "devDependencies": {
119
120
  "devtools-protocol": "0.0.1380148",
120
121
  "@playwright/test": "^1.44.1",
121
122
  "@rslib/core": "^0.11.2",
122
123
  "@types/chrome": "0.0.279",
124
+ "@types/cors": "2.8.12",
123
125
  "@types/http-server": "^0.12.4",
124
126
  "@types/node": "^18.0.0",
125
127
  "playwright": "1.44.1",