mirror of
https://github.com/web-infra-dev/midscene.git
synced 2025-12-27 06:59:10 +00:00
fix(esm): resolve cli can't load esm module (#445)
* fix(esm): resolve cli can't load esm module * chore: resolve deps error * chore: resolve deps error * chore: resolve deps error * chore: resolve deps error * chore: resolve deps error * chore: resolve deps error * chore: resolve deps error * chore: resolve deps error * chore: resolve deps error * chore: resolve deps error * chore: resolve deps error * chore: resolve deps error
This commit is contained in:
parent
88945c34e5
commit
d128745e31
@ -1,3 +1,3 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
require('../dist/lib/index.js');
|
||||
require('../dist/lib/index.js')
|
||||
@ -1,14 +1,18 @@
|
||||
import { defineConfig, moduleTools } from '@modern-js/module-tools';
|
||||
import { version } from './package.json';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [moduleTools()],
|
||||
buildPreset: 'npm-library',
|
||||
buildConfig: {
|
||||
platform: 'node',
|
||||
input: {
|
||||
index: 'src/index.ts',
|
||||
},
|
||||
externals: ['node:buffer', 'puppeteer'],
|
||||
target: 'es6',
|
||||
target: 'es2020',
|
||||
define: {
|
||||
__VERSION__: version,
|
||||
},
|
||||
sourceMap: true,
|
||||
},
|
||||
});
|
||||
|
||||
@ -33,16 +33,16 @@
|
||||
"@types/minimist": "1.2.5",
|
||||
"@types/node": "^18.0.0",
|
||||
"@types/yargs": "17.0.32",
|
||||
"typescript": "~5.0.4",
|
||||
"vitest": "3.0.5",
|
||||
"yargs": "17.7.2",
|
||||
"chalk": "4.1.2",
|
||||
"cli-spinners": "3.2.0",
|
||||
"dotenv": "16.4.5",
|
||||
"execa": "9.3.0",
|
||||
"glob": "11.0.0",
|
||||
"js-yaml": "4.1.0",
|
||||
"restore-cursor": "5.1.0",
|
||||
"typescript": "~5.0.4",
|
||||
"vitest": "3.0.5",
|
||||
"yargs": "17.7.2"
|
||||
"restore-cursor": "5.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
|
||||
@ -3,15 +3,15 @@ import 'dotenv/config';
|
||||
import { statSync } from 'node:fs';
|
||||
import { existsSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { hideBin } from 'yargs/helpers';
|
||||
import yargs from 'yargs/yargs';
|
||||
|
||||
declare const __VERSION__: string;
|
||||
|
||||
export const parseProcessArgs = async (): Promise<{
|
||||
path?: string;
|
||||
options: Record<string, any>;
|
||||
}> => {
|
||||
const versionFromPkgJson = require('../package.json').version;
|
||||
const { hideBin } = require('yargs/helpers');
|
||||
|
||||
const args = yargs(hideBin(process.argv))
|
||||
.usage(
|
||||
`Midscene.js helps you automate browser actions, assertions, and data extraction by AI.
|
||||
@ -33,7 +33,7 @@ Usage: $0 [options] <path-to-yaml-script-file-or-directory>`,
|
||||
'Keep the browser window open after the script finishes. This is useful when debugging, but will consume more resources',
|
||||
},
|
||||
})
|
||||
.version('version', 'Show version number', versionFromPkgJson)
|
||||
.version('version', 'Show version number', __VERSION__)
|
||||
.help()
|
||||
.wrap(yargs().terminalWidth());
|
||||
|
||||
|
||||
@ -5,8 +5,13 @@ export default defineConfig({
|
||||
plugins: [moduleTools()],
|
||||
buildPreset: 'npm-library',
|
||||
buildConfig: {
|
||||
buildType: 'bundleless',
|
||||
format: 'esm',
|
||||
input: {
|
||||
index: 'src/index.ts',
|
||||
env: 'src/env.ts',
|
||||
utils: 'src/utils.ts',
|
||||
tree: 'src/tree.ts',
|
||||
'ai-model': 'src/ai-model/index.ts',
|
||||
},
|
||||
externals: ['langsmith'],
|
||||
target: 'es2020',
|
||||
define: {
|
||||
@ -14,5 +19,8 @@ export default defineConfig({
|
||||
},
|
||||
splitting: true,
|
||||
sourceMap: true,
|
||||
dts: {
|
||||
respectExternal: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
"repository": "https://github.com/web-infra-dev/midscene",
|
||||
"homepage": "https://midscenejs.com/",
|
||||
"jsnext:source": "./src/index.ts",
|
||||
"type": "module",
|
||||
"main": "./dist/es/index.js",
|
||||
"types": "./dist/types/index.d.ts",
|
||||
"files": ["dist", "report", "README.md"],
|
||||
@ -26,9 +25,9 @@
|
||||
"require": "./dist/lib/utils.js"
|
||||
},
|
||||
"./ai-model": {
|
||||
"types": "./dist/types/ai-model/index.d.ts",
|
||||
"import": "./dist/es/ai-model/index.js",
|
||||
"require": "./dist/lib/ai-model/index.js"
|
||||
"types": "./dist/types/ai-model.d.ts",
|
||||
"import": "./dist/es/ai-model.js",
|
||||
"require": "./dist/lib/ai-model.js"
|
||||
},
|
||||
"./tree": {
|
||||
"types": "./dist/types/tree.d.ts",
|
||||
@ -41,9 +40,8 @@
|
||||
".": ["./dist/types/index.d.ts"],
|
||||
"env": ["./dist/types/env.d.ts"],
|
||||
"utils": ["./dist/types/utils.d.ts"],
|
||||
"ai-model": ["./dist/types/ai-model/index.d.ts"],
|
||||
"tree": ["./dist/types/tree.d.ts"],
|
||||
"evaluation": ["./dist/types/evaluation.d.ts"]
|
||||
"ai-model": ["./dist/types/ai-model.d.ts"],
|
||||
"tree": ["./dist/types/tree.d.ts"]
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
@ -65,15 +63,15 @@
|
||||
"@midscene/shared": "workspace:*",
|
||||
"@ui-tars/action-parser": "1.0.1",
|
||||
"openai": "4.81.0",
|
||||
"socks-proxy-agent": "8.0.4"
|
||||
"socks-proxy-agent": "8.0.4",
|
||||
"dirty-json": "0.9.2",
|
||||
"dotenv": "16.4.5",
|
||||
"langsmith": "0.3.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@modern-js/module-tools": "2.60.6",
|
||||
"@types/node": "^18.0.0",
|
||||
"@types/node-fetch": "2.6.11",
|
||||
"dirty-json": "0.9.2",
|
||||
"dotenv": "16.4.5",
|
||||
"langsmith": "0.3.7",
|
||||
"typescript": "~5.0.4",
|
||||
"vitest": "3.0.5"
|
||||
},
|
||||
|
||||
@ -9,7 +9,7 @@ import {
|
||||
callToGetJSONObject,
|
||||
checkAIConfig,
|
||||
getModelName,
|
||||
} from './service-caller';
|
||||
} from './service-caller/index';
|
||||
|
||||
import type { PlanningLocateParam } from '@/types';
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
export { callToGetJSONObject } from './service-caller';
|
||||
export { callToGetJSONObject } from './service-caller/index';
|
||||
export { systemPromptToLocateElement } from './prompt/llm-locator';
|
||||
export { describeUserPage } from './prompt/util';
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ import {
|
||||
distanceThreshold,
|
||||
elementByPositionWithElementInfo,
|
||||
} from './prompt/util';
|
||||
import { callToGetJSONObject } from './service-caller';
|
||||
import { callToGetJSONObject } from './service-caller/index';
|
||||
|
||||
export type AIArgs = [
|
||||
ChatCompletionSystemMessageParam,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { MATCH_BY_POSITION, getAIConfigInBoolean } from '@/env';
|
||||
import { imageInfoOfBase64 } from '@/image';
|
||||
import { imageInfoOfBase64 } from '@/image/index';
|
||||
import type { BaseElement, ElementTreeNode, Size, UIContext } from '@/types';
|
||||
import { NodeType } from '@midscene/shared/constants';
|
||||
import { descriptionOfTree, treeToList } from '@midscene/shared/extractor';
|
||||
|
||||
@ -5,7 +5,7 @@ import { actionParser } from '@ui-tars/action-parser';
|
||||
import type { ChatCompletionMessageParam } from 'openai/resources';
|
||||
import { AIActionType } from './common';
|
||||
import { getSummary, uiTarsPlanningPrompt } from './prompt/ui-tars-planning';
|
||||
import { call } from './service-caller';
|
||||
import { call } from './service-caller/index';
|
||||
type ActionType =
|
||||
| 'click'
|
||||
| 'drag'
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { Executor } from './ai-model/action-executor';
|
||||
import Insight from './insight';
|
||||
import Insight from './insight/index';
|
||||
import { getLogDirByType, getVersion, setLogDir } from './utils';
|
||||
|
||||
export {
|
||||
@ -8,7 +8,7 @@ export {
|
||||
describeUserPage,
|
||||
AiInspectElement,
|
||||
AiAssert,
|
||||
} from './ai-model';
|
||||
} from './ai-model/index';
|
||||
|
||||
export { getAIConfig, MIDSCENE_MODEL_NAME } from './env';
|
||||
|
||||
|
||||
@ -3,7 +3,6 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import * as path from 'node:path';
|
||||
import { dirname } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { getRunningPkgInfo } from '@midscene/shared/fs';
|
||||
import { assert } from '@midscene/shared/utils';
|
||||
import { ifInBrowser, uuid } from '@midscene/shared/utils';
|
||||
@ -47,8 +46,7 @@ function getReportTpl() {
|
||||
return reportTpl;
|
||||
}
|
||||
|
||||
const filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(filename);
|
||||
const __dirname = dirname(__filename);
|
||||
if (!reportTpl) {
|
||||
let reportPath = path.join(__dirname, '../../report/index.html');
|
||||
if (!existsSync(reportPath)) {
|
||||
@ -119,8 +117,7 @@ export function writeDumpReport(
|
||||
return null;
|
||||
}
|
||||
|
||||
const filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(filename);
|
||||
const __dirname = dirname(__filename);
|
||||
const midscenePkgInfo = getRunningPkgInfo(__dirname);
|
||||
if (!midscenePkgInfo) {
|
||||
console.warn('midscenePkgInfo not found, will not write report');
|
||||
|
||||
@ -4,8 +4,19 @@ export default defineConfig({
|
||||
plugins: [moduleTools()],
|
||||
buildPreset: 'npm-library',
|
||||
buildConfig: {
|
||||
buildType: 'bundleless',
|
||||
format: 'esm',
|
||||
input: {
|
||||
index: './src/index.ts',
|
||||
img: './src/img/index.ts',
|
||||
constants: './src/constants/index.ts',
|
||||
extractor: './src/extractor/index.ts',
|
||||
'extractor-debug': './src/extractor/debug.ts',
|
||||
fs: './src/node/fs.ts',
|
||||
utils: './src/utils.ts',
|
||||
'us-keyboard-layout': './src/us-keyboard-layout.ts',
|
||||
},
|
||||
target: 'es2020',
|
||||
dts: {
|
||||
respectExternal: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
"repository": "https://github.com/web-infra-dev/midscene",
|
||||
"homepage": "https://midscenejs.com/",
|
||||
"types": "./dist/types/index.d.ts",
|
||||
"type": "module",
|
||||
"main": "./dist/lib/index.js",
|
||||
"module": "./dist/es/index.js",
|
||||
"exports": {
|
||||
@ -14,19 +13,19 @@
|
||||
"require": "./dist/lib/index.js"
|
||||
},
|
||||
"./constants": {
|
||||
"types": "./dist/types/constants/index.d.ts",
|
||||
"import": "./dist/es/constants/index.js",
|
||||
"require": "./dist/lib/constants/index.js"
|
||||
"types": "./dist/types/constants.d.ts",
|
||||
"import": "./dist/es/constants.js",
|
||||
"require": "./dist/lib/constants.js"
|
||||
},
|
||||
"./fs": {
|
||||
"types": "./dist/types/node/fs.d.ts",
|
||||
"require": "./dist/lib/node/fs.js",
|
||||
"import": "./dist/es/node/fs.js"
|
||||
"types": "./dist/types/fs.d.ts",
|
||||
"require": "./dist/lib/fs.js",
|
||||
"import": "./dist/es/fs.js"
|
||||
},
|
||||
"./img": {
|
||||
"types": "./dist/types/img/index.d.ts",
|
||||
"import": "./dist/es/img/index.js",
|
||||
"require": "./dist/lib/img/index.js"
|
||||
"types": "./dist/types/img.d.ts",
|
||||
"import": "./dist/es/img.js",
|
||||
"require": "./dist/lib/img.js"
|
||||
},
|
||||
"./utils": {
|
||||
"types": "./dist/types/utils.d.ts",
|
||||
@ -34,14 +33,14 @@
|
||||
"require": "./dist/lib/utils.js"
|
||||
},
|
||||
"./extractor": {
|
||||
"types": "./dist/types/extractor/index.d.ts",
|
||||
"import": "./dist/es/extractor/index.js",
|
||||
"require": "./dist/lib/extractor/index.js"
|
||||
"types": "./dist/types/extractor.d.ts",
|
||||
"import": "./dist/es/extractor.js",
|
||||
"require": "./dist/lib/extractor.js"
|
||||
},
|
||||
"./extractor-debug": {
|
||||
"types": "./dist/types/extractor/debug.d.ts",
|
||||
"import": "./dist/es/extractor-debug/index.js",
|
||||
"require": "./dist/lib/extractor-debug/index.js"
|
||||
"types": "./dist/types/extractor-debug.d.ts",
|
||||
"import": "./dist/es/extractor-debug.js",
|
||||
"require": "./dist/lib/extractor-debug.js"
|
||||
},
|
||||
"./keyboard-layout": {
|
||||
"types": "./dist/types/us-keyboard-layout.d.ts",
|
||||
@ -52,13 +51,12 @@
|
||||
"typesVersions": {
|
||||
"*": {
|
||||
".": ["./dist/types/index.d.ts"],
|
||||
"constants": ["./dist/types/constants/index.d.ts"],
|
||||
"img": ["./dist/types/img/index.d.ts"],
|
||||
"browser/img": ["./dist/types/browser/img/index.d.ts"],
|
||||
"fs": ["./dist/types/node/fs.d.ts"],
|
||||
"constants": ["./dist/types/constants.d.ts"],
|
||||
"img": ["./dist/types/img.d.ts"],
|
||||
"fs": ["./dist/types/fs.d.ts"],
|
||||
"utils": ["./dist/types/utils.d.ts"],
|
||||
"extractor": ["./dist/types/extractor/index.d.ts"],
|
||||
"extractor-debug": ["./dist/types/extractor/debug.d.ts"],
|
||||
"extractor": ["./dist/types/extractor.d.ts"],
|
||||
"extractor-debug": ["./dist/types/extractor-debug.d.ts"],
|
||||
"keyboard-layout": ["./dist/types/us-keyboard-layout.d.ts"]
|
||||
}
|
||||
},
|
||||
|
||||
@ -2,4 +2,4 @@ export {
|
||||
NodeType,
|
||||
TEXT_MAX_SIZE,
|
||||
TEXT_SIZE_THRESHOLD,
|
||||
} from '../constants';
|
||||
} from '../constants/index';
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import type { NodeType } from '../constants';
|
||||
import type { NodeType } from '../constants/index';
|
||||
|
||||
export interface ElementInfo {
|
||||
id: string;
|
||||
|
||||
@ -3,7 +3,7 @@ import {
|
||||
CONTAINER_MINI_HEIGHT,
|
||||
CONTAINER_MINI_WIDTH,
|
||||
NodeType,
|
||||
} from '../constants';
|
||||
} from '../constants/index';
|
||||
import type { Point } from '../types';
|
||||
import {
|
||||
isButtonElement,
|
||||
|
||||
@ -66,9 +66,9 @@ export async function getExtraReturnLogic(tree = false) {
|
||||
if (ifInBrowser) {
|
||||
return null;
|
||||
}
|
||||
// Get __dirname equivalent in ESM
|
||||
const filename = fileURLToPath(import.meta.url);
|
||||
const pathDir = findNearestPackageJson(dirname(filename));
|
||||
// Get __dirname equivalent in Node.js environment
|
||||
const currentFilePath = __filename;
|
||||
const pathDir = findNearestPackageJson(dirname(currentFilePath));
|
||||
assert(pathDir, `can't find pathDir, with ${dirname}`);
|
||||
const scriptPath = path.join(pathDir, './dist/script/htmlElement.js');
|
||||
const elementInfosScriptContent = readFileSync(scriptPath, 'utf-8');
|
||||
|
||||
@ -36,7 +36,6 @@ export default defineConfig({
|
||||
platform: 'browser',
|
||||
outDir: 'dist',
|
||||
target: 'es2020',
|
||||
// sourceMap: true,
|
||||
},
|
||||
{
|
||||
...commonConfig,
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
"types": "./dist/types/index.d.ts",
|
||||
"main": "./dist/lib/index.js",
|
||||
"module": "./dist/es/index.js",
|
||||
"type": "module",
|
||||
"files": ["dist", "html", "README.md"],
|
||||
"watch": {
|
||||
"build": {
|
||||
|
||||
@ -2,7 +2,6 @@ import { strict as assert } from 'node:assert';
|
||||
import { execSync } from 'node:child_process';
|
||||
import { rmSync, writeFileSync } from 'node:fs';
|
||||
import { dirname, join } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import {
|
||||
ensureDirectoryExistence,
|
||||
fileContentOfPath,
|
||||
@ -10,7 +9,6 @@ import {
|
||||
tplReplacer,
|
||||
} from './building-utils';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
const demoData = ['demo', 'demo-mobile', 'zero-execution'];
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { copyFileSync, existsSync, mkdirSync, readFileSync } from 'node:fs';
|
||||
import { dirname, join } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
export function ensureDirectoryExistence(filePath: string) {
|
||||
const directoryPath = dirname(filePath);
|
||||
@ -23,8 +22,6 @@ export function tplReplacer(
|
||||
}
|
||||
|
||||
export const fileContentOfPath = (path: string) => {
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
const filePath = join(__dirname, path);
|
||||
return readFileSync(filePath, 'utf-8');
|
||||
};
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
require('../dist/lib/midscene-playground.js');
|
||||
require('../dist/lib/midscene-playground.js');
|
||||
@ -27,9 +27,30 @@ export default defineConfig({
|
||||
plugins: [moduleTools()],
|
||||
buildPreset: 'npm-library',
|
||||
buildConfig: {
|
||||
format: 'esm',
|
||||
target: 'es6',
|
||||
buildType: 'bundleless',
|
||||
target: 'es2020',
|
||||
buildType: 'bundle',
|
||||
input: {
|
||||
index: 'src/index.ts',
|
||||
'bridge-mode': 'src/bridge-mode/index.ts',
|
||||
'bridge-mode-browser': 'src/bridge-mode/browser.ts',
|
||||
utils: 'src/common/utils.ts',
|
||||
'ui-utils': 'src/common/ui-utils.ts',
|
||||
puppeteer: 'src/puppeteer/index.ts',
|
||||
playwright: 'src/playwright/index.ts',
|
||||
playground: 'src/playground/index.ts',
|
||||
'midscene-playground': 'src/playground/bin.ts',
|
||||
appium: 'src/appium/index.ts',
|
||||
'playwright-report': './src/playwright/reporter/index.ts',
|
||||
'chrome-extension': 'src/chrome-extension/index.ts',
|
||||
yaml: 'src/yaml/index.ts',
|
||||
},
|
||||
externals: [
|
||||
'@midscene/core',
|
||||
'@midscene/shared',
|
||||
'puppeteer',
|
||||
'bufferutil',
|
||||
'utf-8-validate',
|
||||
],
|
||||
define: {
|
||||
__VERSION__: version,
|
||||
},
|
||||
|
||||
@ -7,7 +7,6 @@
|
||||
"jsnext:source": "./src/index.ts",
|
||||
"main": "./dist/lib/index.js",
|
||||
"types": "./dist/types/index.d.ts",
|
||||
"type": "module",
|
||||
"bin": {
|
||||
"midscene-playground": "./bin/midscene-playground"
|
||||
},
|
||||
@ -15,84 +14,84 @@
|
||||
".": {
|
||||
"types": "./dist/types/index.d.ts",
|
||||
"import": "./dist/es/index.js",
|
||||
"require": "./dist/lib/index.js"
|
||||
"default": "./dist/lib/index.js"
|
||||
},
|
||||
"./bridge-mode": {
|
||||
"types": "./dist/types/bridge-mode/index.d.ts",
|
||||
"import": "./dist/es/bridge-mode/index.js",
|
||||
"require": "./dist/lib/bridge-mode/index.js"
|
||||
"types": "./dist/types/bridge-mode.d.ts",
|
||||
"import": "./dist/es/bridge-mode.js",
|
||||
"default": "./dist/lib/bridge-mode.js"
|
||||
},
|
||||
"./bridge-mode-browser": {
|
||||
"types": "./dist/types/bridge-mode/browser.d.ts",
|
||||
"import": "./dist/es/bridge-mode/browser.js",
|
||||
"require": "./dist/lib/bridge-mode/browser.js"
|
||||
"types": "./dist/types/bridge-mode-browser.d.ts",
|
||||
"import": "./dist/es/bridge-mode-browser.js",
|
||||
"default": "./dist/lib/bridge-mode-browser.js"
|
||||
},
|
||||
"./utils": {
|
||||
"types": "./dist/types/common/utils.d.ts",
|
||||
"import": "./dist/es/common/utils.js",
|
||||
"require": "./dist/lib/common/utils.js"
|
||||
"types": "./dist/types/utils.d.ts",
|
||||
"import": "./dist/es/utils.js",
|
||||
"default": "./dist/lib/utils.js"
|
||||
},
|
||||
"./ui-utils": {
|
||||
"types": "./dist/types/common/ui-utils.d.ts",
|
||||
"import": "./dist/es/common/ui-utils.js",
|
||||
"require": "./dist/lib/common/ui-utils.js"
|
||||
"types": "./dist/types/ui-utils.d.ts",
|
||||
"import": "./dist/es/ui-utils.js",
|
||||
"default": "./dist/lib/ui-utils.js"
|
||||
},
|
||||
"./puppeteer": {
|
||||
"types": "./dist/types/puppeteer/index.d.ts",
|
||||
"import": "./dist/es/puppeteer/index.js",
|
||||
"require": "./dist/lib/puppeteer/index.js"
|
||||
"types": "./dist/types/puppeteer.d.ts",
|
||||
"import": "./dist/es/puppeteer.js",
|
||||
"default": "./dist/lib/puppeteer.js"
|
||||
},
|
||||
"./playwright": {
|
||||
"types": "./dist/types/playwright/index.d.ts",
|
||||
"import": "./dist/es/playwright/index.js",
|
||||
"require": "./dist/lib/playwright/index.js"
|
||||
"types": "./dist/types/playwright.d.ts",
|
||||
"import": "./dist/es/playwright.js",
|
||||
"default": "./dist/lib/playwright.js"
|
||||
},
|
||||
"./playwright-report": {
|
||||
"types": "./dist/types/playwright/reporter/index.d.ts",
|
||||
"import": "./dist/es/playwright/reporter/index.js",
|
||||
"require": "./dist/lib/playwright/reporter/index.js"
|
||||
"types": "./dist/types/playwright-report.d.ts",
|
||||
"import": "./dist/es/playwright-report.js",
|
||||
"default": "./dist/lib/playwright-report.js"
|
||||
},
|
||||
"./playground": {
|
||||
"types": "./dist/types/playground/index.d.ts",
|
||||
"import": "./dist/es/playground/index.js",
|
||||
"require": "./dist/lib/playground/index.js"
|
||||
"types": "./dist/types/playground.d.ts",
|
||||
"import": "./dist/es/playground.js",
|
||||
"default": "./dist/lib/playground.js"
|
||||
},
|
||||
"./midscene-playground": {
|
||||
"types": "./dist/types/playground/bin.d.ts",
|
||||
"import": "./dist/es/playground/bin.js",
|
||||
"require": "./dist/lib/playground/bin.js"
|
||||
"types": "./dist/types/midscene-playground.d.ts",
|
||||
"import": "./dist/es/midscene-playground.js",
|
||||
"default": "./dist/lib/midscene-playground.js"
|
||||
},
|
||||
"./appium": {
|
||||
"types": "./dist/types/appium/index.d.ts",
|
||||
"import": "./dist/es/appium/index.js",
|
||||
"require": "./dist/lib/appium/index.js"
|
||||
"types": "./dist/types/appium.d.ts",
|
||||
"import": "./dist/es/appium.js",
|
||||
"default": "./dist/lib/appium.js"
|
||||
},
|
||||
"./chrome-extension": {
|
||||
"types": "./dist/types/chrome-extension/index.d.ts",
|
||||
"import": "./dist/es/chrome-extension/index.js",
|
||||
"require": "./dist/lib/chrome-extension/index.js"
|
||||
"types": "./dist/types/chrome-extension.d.ts",
|
||||
"import": "./dist/es/chrome-extension.js",
|
||||
"default": "./dist/lib/chrome-extension.js"
|
||||
},
|
||||
"./yaml": {
|
||||
"types": "./dist/types/yaml/index.d.ts",
|
||||
"import": "./dist/es/yaml/index.js",
|
||||
"require": "./dist/lib/yaml/index.js"
|
||||
"types": "./dist/types/yaml.d.ts",
|
||||
"import": "./dist/es/yaml.js",
|
||||
"default": "./dist/lib/yaml.js"
|
||||
}
|
||||
},
|
||||
"typesVersions": {
|
||||
"*": {
|
||||
".": ["./dist/types/index.d.ts"],
|
||||
"bridge-mode": ["./dist/types/bridge-mode/index.d.ts"],
|
||||
"bridge-mode-browser": ["./dist/types/bridge-mode/browser.d.ts"],
|
||||
"utils": ["./dist/types/common/utils.d.ts"],
|
||||
"ui-utils": ["./dist/types/common/ui-utils.d.ts"],
|
||||
"puppeteer": ["./dist/types/puppeteer/index.d.ts"],
|
||||
"playwright": ["./dist/types/playwright/index.d.ts"],
|
||||
"playwright-report": ["./dist/types/playwright/reporter/index.d.ts"],
|
||||
"playground": ["./dist/types/playground/index.d.ts"],
|
||||
"midscene-playground": ["./dist/types/playground/bin.d.ts"],
|
||||
"appium": ["./dist/types/appium/index.d.ts"],
|
||||
"chrome-extension": ["./dist/types/chrome-extension/index.d.ts"],
|
||||
"yaml": ["./dist/types/yaml/index.d.ts"]
|
||||
"bridge-mode": ["./dist/types/bridge-mode.d.ts"],
|
||||
"bridge-mode-browser": ["./dist/types/bridge-mode-browser.d.ts"],
|
||||
"utils": ["./dist/types/utils.d.ts"],
|
||||
"ui-utils": ["./dist/types/ui-utils.d.ts"],
|
||||
"puppeteer": ["./dist/types/puppeteer.d.ts"],
|
||||
"playwright": ["./dist/types/playwright.d.ts"],
|
||||
"playwright-report": ["./dist/types/playwright-report.d.ts"],
|
||||
"playground": ["./dist/types/playground.d.ts"],
|
||||
"midscene-playground": ["./dist/types/midscene-playground.d.ts"],
|
||||
"appium": ["./dist/types/appium.d.ts"],
|
||||
"chrome-extension": ["./dist/types/chrome-extension.d.ts"],
|
||||
"yaml": ["./dist/types/yaml.d.ts"]
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
@ -123,11 +122,19 @@
|
||||
"@midscene/shared": "workspace:*",
|
||||
"@xmldom/xmldom": "0.8.10",
|
||||
"cors": "2.8.5",
|
||||
"dayjs": "1.11.11",
|
||||
"express": "4.21.1",
|
||||
"inquirer": "10.1.5",
|
||||
"openai": "4.81.0",
|
||||
"socket.io": "4.8.1",
|
||||
"socket.io-client": "4.8.1"
|
||||
"socket.io-client": "4.8.1",
|
||||
"dotenv": "16.4.5",
|
||||
"devtools-protocol": "0.0.1380148",
|
||||
"fs-extra": "11.2.0",
|
||||
"http-server": "14.1.1",
|
||||
"js-sha256": "0.11.0",
|
||||
"js-yaml": "4.1.0",
|
||||
"webdriverio": "9.0.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@modern-js/module-tools": "2.60.6",
|
||||
@ -139,17 +146,10 @@
|
||||
"@types/js-yaml": "4.0.9",
|
||||
"@types/node": "^18.0.0",
|
||||
"@wdio/types": "9.0.4",
|
||||
"devtools-protocol": "0.0.1380148",
|
||||
"dotenv": "16.4.5",
|
||||
"fs-extra": "11.2.0",
|
||||
"http-server": "14.1.1",
|
||||
"js-sha256": "0.11.0",
|
||||
"js-yaml": "4.1.0",
|
||||
"playwright": "1.44.1",
|
||||
"puppeteer": "24.2.0",
|
||||
"typescript": "~5.0.4",
|
||||
"vitest": "3.0.5",
|
||||
"webdriverio": "9.0.6"
|
||||
"vitest": "3.0.5"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@playwright/test": "^1.44.1",
|
||||
|
||||
@ -1,10 +1,6 @@
|
||||
// scripts/check-exports.js
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
function checkConsistency() {
|
||||
const pkgPath = path.resolve(__dirname, '../package.json');
|
||||
|
||||
@ -11,7 +11,7 @@ import {
|
||||
} from '@midscene/core';
|
||||
import { NodeType } from '@midscene/shared/constants';
|
||||
|
||||
import { ScriptPlayer, parseYamlScript } from '@/yaml';
|
||||
import { ScriptPlayer, parseYamlScript } from '@/yaml/index';
|
||||
import {
|
||||
MATCH_BY_POSITION,
|
||||
MIDSCENE_USE_VLM_UI_TARS,
|
||||
|
||||
@ -7,6 +7,7 @@ import { getTmpDir } from '@midscene/core/utils';
|
||||
import { assert } from '@midscene/shared/utils';
|
||||
import { ifInBrowser } from '@midscene/shared/utils';
|
||||
import cors from 'cors';
|
||||
import dotenv from 'dotenv';
|
||||
import express from 'express';
|
||||
import { StaticPageAgent } from './agent';
|
||||
import StaticPage from './static-page';
|
||||
@ -24,7 +25,6 @@ const errorHandler = (err: any, req: any, res: any, next: any) => {
|
||||
|
||||
const setup = async () => {
|
||||
if (!ifInBrowser) {
|
||||
const dotenv = await import('dotenv');
|
||||
dotenv.config();
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { randomUUID } from 'node:crypto';
|
||||
import type { PageAgent } from '@/common/agent';
|
||||
import { PlaywrightAgent } from '@/playwright';
|
||||
import { PlaywrightAgent } from '@/playwright/index';
|
||||
import type { AgentWaitForOpt } from '@midscene/core';
|
||||
import { type TestInfo, type TestType, test } from '@playwright/test';
|
||||
import type { Page as OriginPlaywrightPage } from 'playwright';
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { assert } from '@midscene/shared/utils';
|
||||
|
||||
import { PuppeteerAgent } from '@/puppeteer';
|
||||
import { PuppeteerAgent } from '@/puppeteer/index';
|
||||
import type { MidsceneYamlScriptEnv } from '@midscene/core';
|
||||
import puppeteer from 'puppeteer';
|
||||
|
||||
export const defaultUA =
|
||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36';
|
||||
@ -79,7 +80,6 @@ export async function launchPuppeteerPage(
|
||||
'you are probably running headed mode in CI, this will usually fail.',
|
||||
);
|
||||
}
|
||||
const puppeteer = await import('puppeteer');
|
||||
// do not use 'no-sandbox' on windows https://www.perplexity.ai/search/how-to-solve-this-with-nodejs-dMHpdCypRa..JA8TkQzbeQ
|
||||
const isWindows = process.platform === 'win32';
|
||||
const browser = await puppeteer.launch({
|
||||
|
||||
63
pnpm-lock.yaml
generated
63
pnpm-lock.yaml
generated
@ -157,6 +157,15 @@ importers:
|
||||
'@ui-tars/action-parser':
|
||||
specifier: 1.0.1
|
||||
version: 1.0.1
|
||||
dirty-json:
|
||||
specifier: 0.9.2
|
||||
version: 0.9.2
|
||||
dotenv:
|
||||
specifier: 16.4.5
|
||||
version: 16.4.5
|
||||
langsmith:
|
||||
specifier: 0.3.7
|
||||
version: 0.3.7(openai@4.81.0(ws@8.18.0)(zod@3.24.1))
|
||||
openai:
|
||||
specifier: 4.81.0
|
||||
version: 4.81.0(ws@8.18.0)(zod@3.24.1)
|
||||
@ -173,15 +182,6 @@ importers:
|
||||
'@types/node-fetch':
|
||||
specifier: 2.6.11
|
||||
version: 2.6.11
|
||||
dirty-json:
|
||||
specifier: 0.9.2
|
||||
version: 0.9.2
|
||||
dotenv:
|
||||
specifier: 16.4.5
|
||||
version: 16.4.5
|
||||
langsmith:
|
||||
specifier: 0.3.7
|
||||
version: 0.3.7(openai@4.81.0(ws@8.18.0)(zod@3.24.1))
|
||||
typescript:
|
||||
specifier: ~5.0.4
|
||||
version: 5.0.4
|
||||
@ -347,12 +347,33 @@ importers:
|
||||
cors:
|
||||
specifier: 2.8.5
|
||||
version: 2.8.5
|
||||
dayjs:
|
||||
specifier: 1.11.11
|
||||
version: 1.11.11
|
||||
devtools-protocol:
|
||||
specifier: 0.0.1380148
|
||||
version: 0.0.1380148
|
||||
dotenv:
|
||||
specifier: 16.4.5
|
||||
version: 16.4.5
|
||||
express:
|
||||
specifier: 4.21.1
|
||||
version: 4.21.1
|
||||
fs-extra:
|
||||
specifier: 11.2.0
|
||||
version: 11.2.0
|
||||
http-server:
|
||||
specifier: 14.1.1
|
||||
version: 14.1.1
|
||||
inquirer:
|
||||
specifier: 10.1.5
|
||||
version: 10.1.5
|
||||
js-sha256:
|
||||
specifier: 0.11.0
|
||||
version: 0.11.0
|
||||
js-yaml:
|
||||
specifier: 4.1.0
|
||||
version: 4.1.0
|
||||
openai:
|
||||
specifier: 4.81.0
|
||||
version: 4.81.0(ws@8.18.0)(zod@3.24.1)
|
||||
@ -362,6 +383,9 @@ importers:
|
||||
socket.io-client:
|
||||
specifier: 4.8.1
|
||||
version: 4.8.1
|
||||
webdriverio:
|
||||
specifier: 9.0.6
|
||||
version: 9.0.6
|
||||
devDependencies:
|
||||
'@modern-js/module-tools':
|
||||
specifier: 2.60.6
|
||||
@ -390,24 +414,6 @@ importers:
|
||||
'@wdio/types':
|
||||
specifier: 9.0.4
|
||||
version: 9.0.4
|
||||
devtools-protocol:
|
||||
specifier: 0.0.1380148
|
||||
version: 0.0.1380148
|
||||
dotenv:
|
||||
specifier: 16.4.5
|
||||
version: 16.4.5
|
||||
fs-extra:
|
||||
specifier: 11.2.0
|
||||
version: 11.2.0
|
||||
http-server:
|
||||
specifier: 14.1.1
|
||||
version: 14.1.1
|
||||
js-sha256:
|
||||
specifier: 0.11.0
|
||||
version: 0.11.0
|
||||
js-yaml:
|
||||
specifier: 4.1.0
|
||||
version: 4.1.0
|
||||
playwright:
|
||||
specifier: 1.44.1
|
||||
version: 1.44.1
|
||||
@ -420,9 +426,6 @@ importers:
|
||||
vitest:
|
||||
specifier: 3.0.5
|
||||
version: 3.0.5(@types/debug@4.1.12)(@types/node@18.19.62)(jsdom@24.1.1)(sass-embedded@1.83.4)(terser@5.36.0)
|
||||
webdriverio:
|
||||
specifier: 9.0.6
|
||||
version: 9.0.6
|
||||
|
||||
packages:
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user