@midscene/core 0.0.1 → 0.1.1
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/ai-model.js +4218 -9
- package/dist/es/image.js +28 -14
- package/dist/es/index.js +4364 -151
- package/dist/es/utils.js +20 -11
- package/dist/lib/ai-model.js +4231 -42
- package/dist/lib/image.js +35 -21
- package/dist/lib/index.js +4348 -155
- package/dist/lib/utils.js +21 -11
- package/dist/types/ai-model.d.ts +1 -1
- package/dist/types/image.d.ts +3 -4
- package/dist/types/index.d.ts +15 -5
- package/dist/types/utils.d.ts +9 -3
- package/package.json +5 -1
- package/.eslintignore +0 -3
- package/.eslintrc.js +0 -9
- package/CONTRIBUTING.md +0 -5
- package/demo_data/demo.actions.json +0 -160
- package/demo_data/demo.insight.json +0 -3571
- package/demo_data/index.d.ts +0 -1
- package/demo_data/index.js +0 -6
- package/modern.config.ts +0 -18
- package/third-party-licenses.txt +0 -415
- package/tsconfig.json +0 -22
- package/vitest.config.ts +0 -20
package/dist/es/utils.js
CHANGED
|
@@ -36,13 +36,18 @@ function getDumpDir() {
|
|
|
36
36
|
function setDumpDir(dir) {
|
|
37
37
|
logDir = dir;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function getDumpDirPath(type) {
|
|
40
|
+
return join(getDumpDir(), type);
|
|
41
|
+
}
|
|
42
|
+
function writeDumpFile(opts) {
|
|
43
|
+
const { fileName, fileExt, fileContent, type = "dump" } = opts;
|
|
44
|
+
const targetDir = getDumpDirPath(type);
|
|
45
|
+
if (!existsSync(targetDir)) {
|
|
46
|
+
mkdirSync(targetDir, { recursive: true });
|
|
47
|
+
}
|
|
40
48
|
if (!logEnvReady) {
|
|
41
|
-
assert(
|
|
42
|
-
|
|
43
|
-
mkdirSync(logDir, { recursive: true });
|
|
44
|
-
}
|
|
45
|
-
const gitIgnorePath = join(logDir, "../.gitignore");
|
|
49
|
+
assert(targetDir, "logDir should be set before writing dump file");
|
|
50
|
+
const gitIgnorePath = join(targetDir, "../../.gitignore");
|
|
46
51
|
let gitIgnoreContent = "";
|
|
47
52
|
if (existsSync(gitIgnorePath)) {
|
|
48
53
|
gitIgnoreContent = readFileSync(gitIgnorePath, "utf-8");
|
|
@@ -53,16 +58,19 @@ function writeDumpFile(fileName, fileExt, fileContent) {
|
|
|
53
58
|
gitIgnorePath,
|
|
54
59
|
`${gitIgnoreContent}
|
|
55
60
|
# MidScene.js dump files
|
|
56
|
-
${logDirName}/
|
|
61
|
+
${logDirName}/midscene-report
|
|
62
|
+
${logDirName}/dump-logger
|
|
57
63
|
`,
|
|
58
64
|
"utf-8"
|
|
59
65
|
);
|
|
60
66
|
}
|
|
61
67
|
logEnvReady = true;
|
|
62
68
|
}
|
|
63
|
-
const filePath = join(
|
|
69
|
+
const filePath = join(targetDir, `${fileName}.${fileExt}`);
|
|
64
70
|
writeFileSync(filePath, fileContent);
|
|
65
|
-
|
|
71
|
+
if (type === "dump") {
|
|
72
|
+
copyFileSync(filePath, join(targetDir, `latest.${fileExt}`));
|
|
73
|
+
}
|
|
66
74
|
return filePath;
|
|
67
75
|
}
|
|
68
76
|
function getTmpDir() {
|
|
@@ -70,8 +78,8 @@ function getTmpDir() {
|
|
|
70
78
|
mkdirSync(path, { recursive: true });
|
|
71
79
|
return path;
|
|
72
80
|
}
|
|
73
|
-
function getTmpFile(
|
|
74
|
-
const filename = `${randomUUID()}.${
|
|
81
|
+
function getTmpFile(fileExtWithoutDot) {
|
|
82
|
+
const filename = `${randomUUID()}.${fileExtWithoutDot}`;
|
|
75
83
|
return join(getTmpDir(), filename);
|
|
76
84
|
}
|
|
77
85
|
function overlapped(container, target) {
|
|
@@ -84,6 +92,7 @@ var commonScreenshotParam = { type: "jpeg", quality: 75 };
|
|
|
84
92
|
export {
|
|
85
93
|
commonScreenshotParam,
|
|
86
94
|
getDumpDir,
|
|
95
|
+
getDumpDirPath,
|
|
87
96
|
getPkgInfo,
|
|
88
97
|
getTmpDir,
|
|
89
98
|
getTmpFile,
|