@midscene/web 1.3.9 → 1.3.10-beta-20260209020858.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.
- package/dist/es/bin.mjs +1 -1
- package/dist/es/bin.mjs.map +1 -1
- package/dist/es/bridge-mode/io-client.mjs +1 -1
- package/dist/es/bridge-mode/io-server.mjs +2 -2
- package/dist/es/bridge-mode/io-server.mjs.map +1 -1
- package/dist/es/bridge-mode/page-browser-side.mjs +1 -1
- package/dist/es/bridge-mode/page-browser-side.mjs.map +1 -1
- package/dist/es/chrome-extension/page.mjs +1 -4
- package/dist/es/chrome-extension/page.mjs.map +1 -1
- package/dist/es/index.mjs +1 -2
- package/dist/es/mcp-server.mjs +1 -1
- package/dist/es/mcp-tools.mjs +1 -1
- package/dist/es/mcp-tools.mjs.map +1 -1
- package/dist/es/puppeteer/base-page.mjs +0 -4
- package/dist/es/puppeteer/base-page.mjs.map +1 -1
- package/dist/es/static/static-page.mjs +5 -4
- package/dist/es/static/static-page.mjs.map +1 -1
- package/dist/es/web-element.mjs +1 -10
- package/dist/es/web-element.mjs.map +1 -1
- package/dist/lib/bin.js +1 -1
- package/dist/lib/bin.js.map +1 -1
- package/dist/lib/bridge-mode/io-client.js +1 -1
- package/dist/lib/bridge-mode/io-server.js +2 -2
- package/dist/lib/bridge-mode/io-server.js.map +1 -1
- package/dist/lib/bridge-mode/page-browser-side.js +1 -1
- package/dist/lib/bridge-mode/page-browser-side.js.map +1 -1
- package/dist/lib/chrome-extension/page.js +0 -3
- package/dist/lib/chrome-extension/page.js.map +1 -1
- package/dist/lib/index.js +2 -6
- package/dist/lib/mcp-server.js +1 -1
- package/dist/lib/mcp-tools.js +1 -1
- package/dist/lib/mcp-tools.js.map +1 -1
- package/dist/lib/puppeteer/base-page.js +0 -4
- package/dist/lib/puppeteer/base-page.js.map +1 -1
- package/dist/lib/static/static-page.js +5 -4
- package/dist/lib/static/static-page.js.map +1 -1
- package/dist/lib/web-element.js +2 -14
- package/dist/lib/web-element.js.map +1 -1
- package/dist/types/chrome-extension/page.d.ts +1 -2
- package/dist/types/index.d.ts +0 -1
- package/dist/types/puppeteer/base-page.d.ts +2 -3
- package/dist/types/static/static-page.d.ts +1 -1
- package/dist/types/web-element.d.ts +1 -5
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static/static-page.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../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 { ScreenshotItem } from '@midscene/core';\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 this.uiContext = uiContext;\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 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 // Check if this is a UIContext with screenshot property\n if ('screenshot' in this.uiContext && this.uiContext.screenshot) {\n const screenshot = this.uiContext.screenshot;\n if (typeof screenshot === 'object' && 'base64' in screenshot) {\n return (screenshot as { base64: string }).base64;\n }\n return screenshot as unknown as string;\n }\n\n // Check legacy screenshotBase64 field\n const legacyContext = this.uiContext as { screenshotBase64?: string };\n const base64 = legacyContext.screenshotBase64;\n\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 // If the context already has a screenshot property, return it as-is\n if ('screenshot' in this.uiContext && this.uiContext.screenshot) {\n return this.uiContext as UIContext;\n }\n\n // Otherwise, create a proper UIContext from the legacy format\n const screenshotBase64 = await this.screenshotBase64();\n const screenshot = ScreenshotItem.create(screenshotBase64);\n const size = await this.size();\n\n return {\n screenshot,\n size,\n };\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","point","xpath","screenshot","legacyContext","base64","Promise","startingPoint","distance","screenshotBase64","ScreenshotItem","size","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,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,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;;;;;;;;;ACaA,MAAMI,sBAAsB,CAACC;IAC3B,MAAM,IAAIC,MACR,CAAC,YAAY,EAAED,WAAW,qEAAqE,EAAEE,uBAAAA,sCAAsCA,CAAC,CAAC,CAAC;AAE9I;AAEe,MAAMC;IASnB,cAA8B;QAG5B,OAAO;YACLC,IAAAA,uBAAAA,eAAAA,AAAAA,EAAgB,OAAOC;gBACrBN,oBAAoB;YACtB;YACAO,IAAAA,uBAAAA,sBAAAA,AAAAA,EAAuB,OAAOD;gBAC5BN,oBAAoB;YACtB;YACAQ,IAAAA,uBAAAA,iBAAAA,AAAAA,EAAkB,OAAOF;gBACvBN,oBAAoB;YACtB;YACAS,IAAAA,uBAAAA,iBAAAA,AAAAA,EAAkB,OAAOH;gBACvBN,oBAAoB;YACtB;YACAU,IAAAA,uBAAAA,yBAAAA,AAAAA,EAA0B,OAAOJ;gBAC/BN,oBAAoB;YACtB;YACAW,IAAAA,uBAAAA,kBA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ime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../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 { ScreenshotItem } from '@midscene/core';\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 shotSize: { 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 this.uiContext = uiContext;\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 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.shotSize,\n dpr: this.uiContext.shotSize.dpr || 1,\n };\n }\n\n async screenshotBase64() {\n // Check if this is a UIContext with screenshot property\n if ('screenshot' in this.uiContext && this.uiContext.screenshot) {\n const screenshot = this.uiContext.screenshot;\n if (typeof screenshot === 'object' && 'base64' in screenshot) {\n return (screenshot as { base64: string }).base64;\n }\n return screenshot as unknown as string;\n }\n\n // Check legacy screenshotBase64 field\n const legacyContext = this.uiContext as { screenshotBase64?: string };\n const base64 = legacyContext.screenshotBase64;\n\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 // If the context already has a screenshot property, return it as-is\n if ('screenshot' in this.uiContext && this.uiContext.screenshot) {\n return this.uiContext as UIContext;\n }\n\n // Otherwise, create a proper UIContext from the legacy format\n const screenshotBase64 = await this.screenshotBase64();\n const screenshot = ScreenshotItem.create(screenshotBase64);\n const shotSize = await this.size();\n\n return {\n screenshot,\n shotSize,\n shrunkShotToLogicalRatio: 1,\n };\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","point","xpath","screenshot","legacyContext","base64","Promise","startingPoint","distance","screenshotBase64","ScreenshotItem","shotSize","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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AiB,EAAED,aAAqB,EAAE;QACzD,OAAOpB,oBAAoB;IAC7B;IAEA,MAAM,YAAYqB,QAAiB,EAAED,aAAqB,EAAE;QAC1D,OAAOpB,oBAAoB;IAC7B;IAEA,MAAM,aAAa;QACjB,OAAOA,oBAAoB;IAC7B;IAcA,MAAM,UAAyB,CAE/B;IAEA,MAAM,aAAiC;QAErC,IAAI,gBAAgB,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC,UAAU,EAC7D,OAAO,IAAI,CAAC,SAAS;QAIvB,MAAMsB,mBAAmB,MAAM,IAAI,CAAC,gBAAgB;QACpD,MAAMN,aAAaO,qBAAAA,cAAAA,CAAAA,MAAqB,CAACD;QACzC,MAAME,WAAW,MAAM,IAAI,CAAC,IAAI;QAEhC,OAAO;YACLR;YACAQ;YACA,0BAA0B;QAC5B;IACF;IAEA,cAAcC,UAAwB,EAAQ;QAC5C,IAAI,CAAC,SAAS,GAAGA;IACnB;IA5JA,YAAYC,SAAuB,CAAE;QAJrC,wCAAgB;QAEhB,uBAAQ,aAAR;QA0HA,gCAAQ;YACN,OAAO1B,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;QAjIE,IAAI,CAAC,SAAS,GAAG0B;IACnB;AA2JF"}
|
package/dist/lib/web-element.js
CHANGED
|
@@ -24,12 +24,9 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
WebElementInfoImpl: ()=>WebElementInfoImpl
|
|
27
|
+
WebElementInfoImpl: ()=>WebElementInfoImpl,
|
|
28
|
+
limitOpenNewTabScript: ()=>limitOpenNewTabScript
|
|
30
29
|
});
|
|
31
|
-
const logger_namespaceObject = require("@midscene/shared/logger");
|
|
32
|
-
const agent_namespaceObject = require("@midscene/core/agent");
|
|
33
30
|
function _define_property(obj, key, value) {
|
|
34
31
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
35
32
|
value: value,
|
|
@@ -63,13 +60,6 @@ class WebElementInfoImpl {
|
|
|
63
60
|
this.isVisible = isVisible;
|
|
64
61
|
}
|
|
65
62
|
}
|
|
66
|
-
(0, logger_namespaceObject.getDebug)('web:parse-context');
|
|
67
|
-
async function WebPageContextParser(page, _opt) {
|
|
68
|
-
const basicContext = await (0, agent_namespaceObject.commonContextParser)(page, {
|
|
69
|
-
uploadServerUrl: _opt.uploadServerUrl
|
|
70
|
-
});
|
|
71
|
-
return basicContext;
|
|
72
|
-
}
|
|
73
63
|
const limitOpenNewTabScript = `
|
|
74
64
|
if (!window.__MIDSCENE_NEW_TAB_INTERCEPTOR_INITIALIZED__) {
|
|
75
65
|
window.__MIDSCENE_NEW_TAB_INTERCEPTOR_INITIALIZED__ = true;
|
|
@@ -94,11 +84,9 @@ if (!window.__MIDSCENE_NEW_TAB_INTERCEPTOR_INITIALIZED__) {
|
|
|
94
84
|
}
|
|
95
85
|
`;
|
|
96
86
|
exports.WebElementInfoImpl = __webpack_exports__.WebElementInfoImpl;
|
|
97
|
-
exports.WebPageContextParser = __webpack_exports__.WebPageContextParser;
|
|
98
87
|
exports.limitOpenNewTabScript = __webpack_exports__.limitOpenNewTabScript;
|
|
99
88
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
100
89
|
"WebElementInfoImpl",
|
|
101
|
-
"WebPageContextParser",
|
|
102
90
|
"limitOpenNewTabScript"
|
|
103
91
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
104
92
|
Object.defineProperty(exports, '__esModule', {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-element.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../src/web-element.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 {\n AgentOpt,\n DeviceAction,\n Rect,\n
|
|
1
|
+
{"version":3,"file":"web-element.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../src/web-element.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 {\n AgentOpt,\n DeviceAction,\n Rect,\n WebElementInfo,\n} from '@midscene/core';\nimport { _keyDefinitions } from '@midscene/shared/us-keyboard-layout';\n\nimport type { NodeType } from '@midscene/shared/constants';\nimport type ChromeExtensionProxyPage from './chrome-extension/page';\nimport type { PlaywrightWebPage } from './playwright';\nimport type { PuppeteerWebPage } from './puppeteer';\nimport type { StaticPage } from './static';\nexport type { WebElementInfo };\n\nexport type WebPageAgentOpt = AgentOpt & WebPageOpt;\nexport type WebPageOpt = {\n waitForNavigationTimeout?: number;\n waitForNetworkIdleTimeout?: number;\n forceSameTabNavigation?: boolean /* if limit the new tab to the current page, default true */;\n enableTouchEventsInActionSpace?: boolean;\n /**\n * Force Chrome to render select elements using base-select appearance instead of OS-native rendering.\n * This makes select elements visible in screenshots captured by Playwright/Puppeteer.\n *\n * Reference: https://developer.chrome.com/blog/a-customizable-select\n *\n * When enabled, adds a style tag with `select { appearance: base-select !important; }` to the page.\n */\n forceChromeSelectRendering?: boolean;\n beforeInvokeAction?: () => Promise<void>;\n afterInvokeAction?: () => Promise<void>;\n customActions?: DeviceAction<any>[];\n};\n\nexport type WebPage =\n | PlaywrightWebPage\n | PuppeteerWebPage\n | StaticPage\n | ChromeExtensionProxyPage;\n\nexport class WebElementInfoImpl implements WebElementInfo {\n content: string;\n\n rect: Rect;\n\n center: [number, number];\n\n id: string;\n\n indexId: number;\n\n attributes: {\n nodeType: NodeType;\n [key: string]: string;\n };\n\n xpaths?: string[];\n\n isVisible: boolean;\n\n constructor({\n content,\n rect,\n id,\n attributes,\n indexId,\n xpaths,\n isVisible,\n }: {\n content: string;\n rect: Rect;\n id: string;\n attributes: {\n nodeType: NodeType;\n [key: string]: string;\n };\n indexId: number;\n xpaths?: string[];\n isVisible: boolean;\n }) {\n this.content = content;\n this.rect = rect;\n this.center = [\n Math.floor(rect.left + rect.width / 2),\n Math.floor(rect.top + rect.height / 2),\n ];\n this.id = id;\n this.attributes = attributes;\n this.indexId = indexId;\n this.xpaths = xpaths;\n this.isVisible = isVisible;\n }\n}\n\nexport 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`;\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","WebElementInfoImpl","content","rect","id","attributes","indexId","xpaths","isVisible","Math","limitOpenNewTabScript"],"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,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;;;;;;;ACmCO,MAAMI;IAoBX,YAAY,EACVC,OAAO,EACPC,IAAI,EACJC,EAAE,EACFC,UAAU,EACVC,OAAO,EACPC,MAAM,EACNC,SAAS,EAYV,CAAE;QAtCH;QAEA;QAEA;QAEA;QAEA;QAEA;QAKA;QAEA;QAsBE,IAAI,CAAC,OAAO,GAAGN;QACf,IAAI,CAAC,IAAI,GAAGC;QACZ,IAAI,CAAC,MAAM,GAAG;YACZM,KAAK,KAAK,CAACN,KAAK,IAAI,GAAGA,KAAK,KAAK,GAAG;YACpCM,KAAK,KAAK,CAACN,KAAK,GAAG,GAAGA,KAAK,MAAM,GAAG;SACrC;QACD,IAAI,CAAC,EAAE,GAAGC;QACV,IAAI,CAAC,UAAU,GAAGC;QAClB,IAAI,CAAC,OAAO,GAAGC;QACf,IAAI,CAAC,MAAM,GAAGC;QACd,IAAI,CAAC,SAAS,GAAGC;IACnB;AACF;AAEO,MAAME,wBAAwB,CAAC;;;;;;;;;;;;;;;;;;;;;;AAsBtC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ElementCacheFeature, ElementTreeNode, Point, Rect, Size
|
|
1
|
+
import type { ElementCacheFeature, ElementTreeNode, Point, Rect, Size } from '@midscene/core';
|
|
2
2
|
import type { AbstractInterface, DeviceAction } from '@midscene/core/device';
|
|
3
3
|
import type { ElementInfo } from '@midscene/shared/extractor';
|
|
4
4
|
import { type CacheFeatureOptions } from '../common/cache-helper';
|
|
@@ -56,7 +56,6 @@ export default class ChromeExtensionProxyPage implements AbstractInterface {
|
|
|
56
56
|
cacheFeatureForPoint(center: [number, number], options?: CacheFeatureOptions): Promise<ElementCacheFeature>;
|
|
57
57
|
rectMatchesCacheFeature(feature: ElementCacheFeature): Promise<Rect>;
|
|
58
58
|
getElementsNodeTree(): Promise<ElementTreeNode<ElementInfo>>;
|
|
59
|
-
getContext(): Promise<UIContext>;
|
|
60
59
|
size(): Promise<Size>;
|
|
61
60
|
screenshotBase64(): Promise<string>;
|
|
62
61
|
url(): Promise<string>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -6,4 +6,3 @@ export { Agent as PageAgent, type AgentOpt } from '@midscene/core/agent';
|
|
|
6
6
|
export { PuppeteerAgent } from './puppeteer';
|
|
7
7
|
export { PlaywrightAgent } from './playwright';
|
|
8
8
|
export { StaticPageAgent, StaticPage } from './static';
|
|
9
|
-
export { WebPageContextParser } from './web-element';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { DeviceAction, ElementCacheFeature, ElementTreeNode, Point, Rect, Size
|
|
1
|
+
import type { WebPageAgentOpt } from '../web-element';
|
|
2
|
+
import type { DeviceAction, ElementCacheFeature, ElementTreeNode, Point, Rect, Size } from '@midscene/core';
|
|
3
3
|
import type { AbstractInterface } from '@midscene/core/device';
|
|
4
4
|
import type { ElementInfo } from '@midscene/shared/extractor';
|
|
5
5
|
import { type DebugFunction } from '@midscene/shared/logger';
|
|
@@ -80,7 +80,6 @@ export declare class Page<AgentType extends 'puppeteer' | 'playwright', Interfac
|
|
|
80
80
|
beforeInvokeAction(name: string, param: any): Promise<void>;
|
|
81
81
|
afterInvokeAction(name: string, param: any): Promise<void>;
|
|
82
82
|
destroy(): Promise<void>;
|
|
83
|
-
getContext(): Promise<UIContext>;
|
|
84
83
|
swipe(from: {
|
|
85
84
|
x: number;
|
|
86
85
|
y: number;
|
|
@@ -2,7 +2,7 @@ import type { DeviceAction, Point, UIContext } from '@midscene/core';
|
|
|
2
2
|
import type { AbstractInterface } from '@midscene/core/device';
|
|
3
3
|
type WebUIContext = UIContext | {
|
|
4
4
|
screenshotBase64?: string;
|
|
5
|
-
|
|
5
|
+
shotSize: {
|
|
6
6
|
width: number;
|
|
7
7
|
height: number;
|
|
8
8
|
dpr?: number;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { AgentOpt, DeviceAction, Rect,
|
|
2
|
-
import type { AbstractInterface } from '@midscene/core/device';
|
|
1
|
+
import type { AgentOpt, DeviceAction, Rect, WebElementInfo } from '@midscene/core';
|
|
3
2
|
import type { NodeType } from '@midscene/shared/constants';
|
|
4
3
|
import type ChromeExtensionProxyPage from './chrome-extension/page';
|
|
5
4
|
import type { PlaywrightWebPage } from './playwright';
|
|
@@ -51,7 +50,4 @@ export declare class WebElementInfoImpl implements WebElementInfo {
|
|
|
51
50
|
isVisible: boolean;
|
|
52
51
|
});
|
|
53
52
|
}
|
|
54
|
-
export declare function WebPageContextParser(page: AbstractInterface, _opt: {
|
|
55
|
-
uploadServerUrl?: string;
|
|
56
|
-
}): Promise<UIContext>;
|
|
57
53
|
export 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";
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"Browser use",
|
|
9
9
|
"Android use"
|
|
10
10
|
],
|
|
11
|
-
"version": "1.3.
|
|
11
|
+
"version": "1.3.10-beta-20260209020858.0",
|
|
12
12
|
"repository": "https://github.com/web-infra-dev/midscene",
|
|
13
13
|
"homepage": "https://midscenejs.com/",
|
|
14
14
|
"main": "./dist/lib/index.js",
|
|
@@ -108,9 +108,9 @@
|
|
|
108
108
|
"http-server": "14.1.1",
|
|
109
109
|
"socket.io": "^4.8.1",
|
|
110
110
|
"socket.io-client": "4.8.1",
|
|
111
|
-
"@midscene/core": "1.3.
|
|
112
|
-
"@midscene/playground": "1.3.
|
|
113
|
-
"@midscene/shared": "1.3.
|
|
111
|
+
"@midscene/core": "1.3.10-beta-20260209020858.0",
|
|
112
|
+
"@midscene/playground": "1.3.10-beta-20260209020858.0",
|
|
113
|
+
"@midscene/shared": "1.3.10-beta-20260209020858.0"
|
|
114
114
|
},
|
|
115
115
|
"devDependencies": {
|
|
116
116
|
"@playwright/test": "^1.45.0",
|