@midscene/core 0.0.1 → 0.1.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.
@@ -314,7 +314,14 @@ function truncateText(text) {
314
314
  }
315
315
  async function describeUserPage(context) {
316
316
  const { screenshotBase64 } = context;
317
- const { width, height } = await imageInfoOfBase64(screenshotBase64);
317
+ let width;
318
+ let height;
319
+ if (context.size) {
320
+ ({ width, height } = context.size);
321
+ } else {
322
+ const imgSize = await imageInfoOfBase64(screenshotBase64);
323
+ ({ width, height } = imgSize);
324
+ }
318
325
  const elementsInfo = context.content;
319
326
  const idElementMap = {};
320
327
  elementsInfo.forEach((item) => {
package/dist/es/image.js CHANGED
@@ -140,8 +140,8 @@ function getTmpDir() {
140
140
  mkdirSync(path, { recursive: true });
141
141
  return path;
142
142
  }
143
- function getTmpFile(fileExt) {
144
- const filename = `${randomUUID()}.${fileExt}`;
143
+ function getTmpFile(fileExtWithoutDot) {
144
+ const filename = `${randomUUID()}.${fileExtWithoutDot}`;
145
145
  return join(getTmpDir(), filename);
146
146
  }
147
147
 
package/dist/es/index.js CHANGED
@@ -100,13 +100,18 @@ function getDumpDir() {
100
100
  function setDumpDir(dir) {
101
101
  logDir = dir;
102
102
  }
103
- function writeDumpFile(fileName, fileExt, fileContent) {
103
+ function getDumpDirPath(type) {
104
+ return join(getDumpDir(), type);
105
+ }
106
+ function writeDumpFile(opts) {
107
+ const { fileName, fileExt, fileContent, type = "dump" } = opts;
108
+ const targetDir = getDumpDirPath(type);
109
+ if (!existsSync(targetDir)) {
110
+ mkdirSync(targetDir, { recursive: true });
111
+ }
104
112
  if (!logEnvReady) {
105
- assert2(logDir, "logDir should be set before writing dump file");
106
- if (!existsSync(logDir)) {
107
- mkdirSync(logDir, { recursive: true });
108
- }
109
- const gitIgnorePath = join(logDir, "../.gitignore");
113
+ assert2(targetDir, "logDir should be set before writing dump file");
114
+ const gitIgnorePath = join(targetDir, "../../.gitignore");
110
115
  let gitIgnoreContent = "";
111
116
  if (existsSync(gitIgnorePath)) {
112
117
  gitIgnoreContent = readFileSync2(gitIgnorePath, "utf-8");
@@ -117,16 +122,19 @@ function writeDumpFile(fileName, fileExt, fileContent) {
117
122
  gitIgnorePath,
118
123
  `${gitIgnoreContent}
119
124
  # MidScene.js dump files
120
- ${logDirName}/
125
+ ${logDirName}/midscene-report
126
+ ${logDirName}/dump-logger
121
127
  `,
122
128
  "utf-8"
123
129
  );
124
130
  }
125
131
  logEnvReady = true;
126
132
  }
127
- const filePath = join(getDumpDir(), `${fileName}.${fileExt}`);
133
+ const filePath = join(targetDir, `${fileName}.${fileExt}`);
128
134
  writeFileSync(filePath, fileContent);
129
- copyFileSync(filePath, join(getDumpDir(), `latest.${fileExt}`));
135
+ if (type === "dump") {
136
+ copyFileSync(filePath, join(targetDir, `latest.${fileExt}`));
137
+ }
130
138
  return filePath;
131
139
  }
132
140
 
@@ -222,7 +230,14 @@ function truncateText(text) {
222
230
  }
223
231
  async function describeUserPage(context) {
224
232
  const { screenshotBase64 } = context;
225
- const { width, height } = await imageInfoOfBase64(screenshotBase64);
233
+ let width;
234
+ let height;
235
+ if (context.size) {
236
+ ({ width, height } = context.size);
237
+ } else {
238
+ const imgSize = await imageInfoOfBase64(screenshotBase64);
239
+ ({ width, height } = imgSize);
240
+ }
226
241
  const elementsInfo = context.content;
227
242
  const idElementMap = {};
228
243
  elementsInfo.forEach((item) => {
@@ -341,9 +356,13 @@ function writeInsightDump(data, logId, dumpSubscriber) {
341
356
  const length = logContent.push(dataString);
342
357
  logIdIndexMap[id] = length - 1;
343
358
  }
344
- writeDumpFile(logFileName, logFileExt, `[
359
+ writeDumpFile({
360
+ fileName: logFileName,
361
+ fileExt: logFileExt,
362
+ fileContent: `[
345
363
  ${logContent.join(",\n")}
346
- ]`);
364
+ ]`
365
+ });
347
366
  return id;
348
367
  }
349
368
  function idsIntoElements(ids, elementById) {
@@ -675,15 +694,16 @@ var Insight = class {
675
694
  }
676
695
  async locate(queryPrompt, opt) {
677
696
  var _a;
697
+ const { callAI = this.aiVendorFn, multi = false } = opt || {};
678
698
  assert6(queryPrompt, "query is required for located");
679
699
  const dumpSubscriber = this.onceDumpUpdatedFn;
680
700
  this.onceDumpUpdatedFn = void 0;
681
701
  const context = await this.contextRetrieverFn();
682
702
  const startTime = Date.now();
683
703
  const { parseResult, systemPrompt, elementById } = await AiInspectElement({
684
- callAI: this.aiVendorFn,
704
+ callAI,
685
705
  context,
686
- multi: Boolean(opt == null ? void 0 : opt.multi),
706
+ multi: Boolean(multi),
687
707
  findElementDescription: queryPrompt
688
708
  });
689
709
  const timeCost = Date.now() - startTime;
@@ -850,6 +870,13 @@ ${parseResult.errors.join("\n")}`;
850
870
  );
851
871
  return mergedData;
852
872
  }
873
+ setAiVendorFn(aiVendorFn) {
874
+ const origin = this.aiVendorFn;
875
+ this.aiVendorFn = aiVendorFn;
876
+ return () => {
877
+ this.aiVendorFn = origin;
878
+ };
879
+ }
853
880
  };
854
881
 
855
882
  // src/action/executor.ts
@@ -1032,7 +1059,8 @@ function systemPromptToTaskPlanning(query) {
1032
1059
  =====================================
1033
1060
  `;
1034
1061
  }
1035
- async function plan(context, userPrompt) {
1062
+ async function plan(userPrompt, opts) {
1063
+ const { callAI = callToGetJSONObject, context } = opts || {};
1036
1064
  const { screenshotBase64 } = context;
1037
1065
  const { description } = await describeUserPage(context);
1038
1066
  const systemPrompt = systemPromptToTaskPlanning(userPrompt);
@@ -1055,7 +1083,7 @@ async function plan(context, userPrompt) {
1055
1083
  ]
1056
1084
  }
1057
1085
  ];
1058
- const planFromAI = await callToGetJSONObject(msgs);
1086
+ const planFromAI = await callAI(msgs);
1059
1087
  if (planFromAI.error) {
1060
1088
  throw new Error(planFromAI.error);
1061
1089
  }
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 writeDumpFile(fileName, fileExt, fileContent) {
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(logDir, "logDir should be set before writing dump file");
42
- if (!existsSync(logDir)) {
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(getDumpDir(), `${fileName}.${fileExt}`);
69
+ const filePath = join(targetDir, `${fileName}.${fileExt}`);
64
70
  writeFileSync(filePath, fileContent);
65
- copyFileSync(filePath, join(getDumpDir(), `latest.${fileExt}`));
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(fileExt) {
74
- const filename = `${randomUUID()}.${fileExt}`;
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,
@@ -351,7 +351,14 @@ function truncateText(text) {
351
351
  }
352
352
  async function describeUserPage(context) {
353
353
  const { screenshotBase64 } = context;
354
- const { width, height } = await imageInfoOfBase64(screenshotBase64);
354
+ let width;
355
+ let height;
356
+ if (context.size) {
357
+ ({ width, height } = context.size);
358
+ } else {
359
+ const imgSize = await imageInfoOfBase64(screenshotBase64);
360
+ ({ width, height } = imgSize);
361
+ }
355
362
  const elementsInfo = context.content;
356
363
  const idElementMap = {};
357
364
  elementsInfo.forEach((item) => {
package/dist/lib/image.js CHANGED
@@ -185,8 +185,8 @@ function getTmpDir() {
185
185
  (0, import_fs.mkdirSync)(path, { recursive: true });
186
186
  return path;
187
187
  }
188
- function getTmpFile(fileExt) {
189
- const filename = `${(0, import_crypto.randomUUID)()}.${fileExt}`;
188
+ function getTmpFile(fileExtWithoutDot) {
189
+ const filename = `${(0, import_crypto.randomUUID)()}.${fileExtWithoutDot}`;
190
190
  return (0, import_path.join)(getTmpDir(), filename);
191
191
  }
192
192
 
package/dist/lib/index.js CHANGED
@@ -141,13 +141,18 @@ function getDumpDir() {
141
141
  function setDumpDir(dir) {
142
142
  logDir = dir;
143
143
  }
144
- function writeDumpFile(fileName, fileExt, fileContent) {
144
+ function getDumpDirPath(type) {
145
+ return (0, import_path.join)(getDumpDir(), type);
146
+ }
147
+ function writeDumpFile(opts) {
148
+ const { fileName, fileExt, fileContent, type = "dump" } = opts;
149
+ const targetDir = getDumpDirPath(type);
150
+ if (!(0, import_fs.existsSync)(targetDir)) {
151
+ (0, import_fs.mkdirSync)(targetDir, { recursive: true });
152
+ }
145
153
  if (!logEnvReady) {
146
- (0, import_assert.default)(logDir, "logDir should be set before writing dump file");
147
- if (!(0, import_fs.existsSync)(logDir)) {
148
- (0, import_fs.mkdirSync)(logDir, { recursive: true });
149
- }
150
- const gitIgnorePath = (0, import_path.join)(logDir, "../.gitignore");
154
+ (0, import_assert.default)(targetDir, "logDir should be set before writing dump file");
155
+ const gitIgnorePath = (0, import_path.join)(targetDir, "../../.gitignore");
151
156
  let gitIgnoreContent = "";
152
157
  if ((0, import_fs.existsSync)(gitIgnorePath)) {
153
158
  gitIgnoreContent = (0, import_fs.readFileSync)(gitIgnorePath, "utf-8");
@@ -158,16 +163,19 @@ function writeDumpFile(fileName, fileExt, fileContent) {
158
163
  gitIgnorePath,
159
164
  `${gitIgnoreContent}
160
165
  # MidScene.js dump files
161
- ${logDirName}/
166
+ ${logDirName}/midscene-report
167
+ ${logDirName}/dump-logger
162
168
  `,
163
169
  "utf-8"
164
170
  );
165
171
  }
166
172
  logEnvReady = true;
167
173
  }
168
- const filePath = (0, import_path.join)(getDumpDir(), `${fileName}.${fileExt}`);
174
+ const filePath = (0, import_path.join)(targetDir, `${fileName}.${fileExt}`);
169
175
  (0, import_fs.writeFileSync)(filePath, fileContent);
170
- (0, import_fs.copyFileSync)(filePath, (0, import_path.join)(getDumpDir(), `latest.${fileExt}`));
176
+ if (type === "dump") {
177
+ (0, import_fs.copyFileSync)(filePath, (0, import_path.join)(targetDir, `latest.${fileExt}`));
178
+ }
171
179
  return filePath;
172
180
  }
173
181
 
@@ -263,7 +271,14 @@ function truncateText(text) {
263
271
  }
264
272
  async function describeUserPage(context) {
265
273
  const { screenshotBase64 } = context;
266
- const { width, height } = await imageInfoOfBase64(screenshotBase64);
274
+ let width;
275
+ let height;
276
+ if (context.size) {
277
+ ({ width, height } = context.size);
278
+ } else {
279
+ const imgSize = await imageInfoOfBase64(screenshotBase64);
280
+ ({ width, height } = imgSize);
281
+ }
267
282
  const elementsInfo = context.content;
268
283
  const idElementMap = {};
269
284
  elementsInfo.forEach((item) => {
@@ -382,9 +397,13 @@ function writeInsightDump(data, logId, dumpSubscriber) {
382
397
  const length = logContent.push(dataString);
383
398
  logIdIndexMap[id] = length - 1;
384
399
  }
385
- writeDumpFile(logFileName, logFileExt, `[
400
+ writeDumpFile({
401
+ fileName: logFileName,
402
+ fileExt: logFileExt,
403
+ fileContent: `[
386
404
  ${logContent.join(",\n")}
387
- ]`);
405
+ ]`
406
+ });
388
407
  return id;
389
408
  }
390
409
  function idsIntoElements(ids, elementById) {
@@ -716,15 +735,16 @@ var Insight = class {
716
735
  }
717
736
  async locate(queryPrompt, opt) {
718
737
  var _a;
738
+ const { callAI = this.aiVendorFn, multi = false } = opt || {};
719
739
  (0, import_assert5.default)(queryPrompt, "query is required for located");
720
740
  const dumpSubscriber = this.onceDumpUpdatedFn;
721
741
  this.onceDumpUpdatedFn = void 0;
722
742
  const context = await this.contextRetrieverFn();
723
743
  const startTime = Date.now();
724
744
  const { parseResult, systemPrompt, elementById } = await AiInspectElement({
725
- callAI: this.aiVendorFn,
745
+ callAI,
726
746
  context,
727
- multi: Boolean(opt == null ? void 0 : opt.multi),
747
+ multi: Boolean(multi),
728
748
  findElementDescription: queryPrompt
729
749
  });
730
750
  const timeCost = Date.now() - startTime;
@@ -891,6 +911,13 @@ ${parseResult.errors.join("\n")}`;
891
911
  );
892
912
  return mergedData;
893
913
  }
914
+ setAiVendorFn(aiVendorFn) {
915
+ const origin = this.aiVendorFn;
916
+ this.aiVendorFn = aiVendorFn;
917
+ return () => {
918
+ this.aiVendorFn = origin;
919
+ };
920
+ }
894
921
  };
895
922
 
896
923
  // src/action/executor.ts
@@ -1073,7 +1100,8 @@ function systemPromptToTaskPlanning(query) {
1073
1100
  =====================================
1074
1101
  `;
1075
1102
  }
1076
- async function plan(context, userPrompt) {
1103
+ async function plan(userPrompt, opts) {
1104
+ const { callAI = callToGetJSONObject, context } = opts || {};
1077
1105
  const { screenshotBase64 } = context;
1078
1106
  const { description } = await describeUserPage(context);
1079
1107
  const systemPrompt = systemPromptToTaskPlanning(userPrompt);
@@ -1096,7 +1124,7 @@ async function plan(context, userPrompt) {
1096
1124
  ]
1097
1125
  }
1098
1126
  ];
1099
- const planFromAI = await callToGetJSONObject(msgs);
1127
+ const planFromAI = await callAI(msgs);
1100
1128
  if (planFromAI.error) {
1101
1129
  throw new Error(planFromAI.error);
1102
1130
  }
package/dist/lib/utils.js CHANGED
@@ -32,6 +32,7 @@ var utils_exports = {};
32
32
  __export(utils_exports, {
33
33
  commonScreenshotParam: () => commonScreenshotParam,
34
34
  getDumpDir: () => getDumpDir,
35
+ getDumpDirPath: () => getDumpDirPath,
35
36
  getPkgInfo: () => getPkgInfo,
36
37
  getTmpDir: () => getTmpDir,
37
38
  getTmpFile: () => getTmpFile,
@@ -80,13 +81,18 @@ function getDumpDir() {
80
81
  function setDumpDir(dir) {
81
82
  logDir = dir;
82
83
  }
83
- function writeDumpFile(fileName, fileExt, fileContent) {
84
+ function getDumpDirPath(type) {
85
+ return (0, import_path.join)(getDumpDir(), type);
86
+ }
87
+ function writeDumpFile(opts) {
88
+ const { fileName, fileExt, fileContent, type = "dump" } = opts;
89
+ const targetDir = getDumpDirPath(type);
90
+ if (!(0, import_fs.existsSync)(targetDir)) {
91
+ (0, import_fs.mkdirSync)(targetDir, { recursive: true });
92
+ }
84
93
  if (!logEnvReady) {
85
- (0, import_assert.default)(logDir, "logDir should be set before writing dump file");
86
- if (!(0, import_fs.existsSync)(logDir)) {
87
- (0, import_fs.mkdirSync)(logDir, { recursive: true });
88
- }
89
- const gitIgnorePath = (0, import_path.join)(logDir, "../.gitignore");
94
+ (0, import_assert.default)(targetDir, "logDir should be set before writing dump file");
95
+ const gitIgnorePath = (0, import_path.join)(targetDir, "../../.gitignore");
90
96
  let gitIgnoreContent = "";
91
97
  if ((0, import_fs.existsSync)(gitIgnorePath)) {
92
98
  gitIgnoreContent = (0, import_fs.readFileSync)(gitIgnorePath, "utf-8");
@@ -97,16 +103,19 @@ function writeDumpFile(fileName, fileExt, fileContent) {
97
103
  gitIgnorePath,
98
104
  `${gitIgnoreContent}
99
105
  # MidScene.js dump files
100
- ${logDirName}/
106
+ ${logDirName}/midscene-report
107
+ ${logDirName}/dump-logger
101
108
  `,
102
109
  "utf-8"
103
110
  );
104
111
  }
105
112
  logEnvReady = true;
106
113
  }
107
- const filePath = (0, import_path.join)(getDumpDir(), `${fileName}.${fileExt}`);
114
+ const filePath = (0, import_path.join)(targetDir, `${fileName}.${fileExt}`);
108
115
  (0, import_fs.writeFileSync)(filePath, fileContent);
109
- (0, import_fs.copyFileSync)(filePath, (0, import_path.join)(getDumpDir(), `latest.${fileExt}`));
116
+ if (type === "dump") {
117
+ (0, import_fs.copyFileSync)(filePath, (0, import_path.join)(targetDir, `latest.${fileExt}`));
118
+ }
110
119
  return filePath;
111
120
  }
112
121
  function getTmpDir() {
@@ -114,8 +123,8 @@ function getTmpDir() {
114
123
  (0, import_fs.mkdirSync)(path, { recursive: true });
115
124
  return path;
116
125
  }
117
- function getTmpFile(fileExt) {
118
- const filename = `${(0, import_crypto.randomUUID)()}.${fileExt}`;
126
+ function getTmpFile(fileExtWithoutDot) {
127
+ const filename = `${(0, import_crypto.randomUUID)()}.${fileExtWithoutDot}`;
119
128
  return (0, import_path.join)(getTmpDir(), filename);
120
129
  }
121
130
  function overlapped(container, target) {
@@ -129,6 +138,7 @@ var commonScreenshotParam = { type: "jpeg", quality: 75 };
129
138
  0 && (module.exports = {
130
139
  commonScreenshotParam,
131
140
  getDumpDir,
141
+ getDumpDirPath,
132
142
  getPkgInfo,
133
143
  getTmpDir,
134
144
  getTmpFile,
@@ -9,7 +9,7 @@ declare function AiInspectElement<ElementType extends BaseElement = BaseElement>
9
9
  context: UIContext<ElementType>;
10
10
  multi: boolean;
11
11
  findElementDescription: string;
12
- callAI?: typeof callToGetJSONObject;
12
+ callAI?: typeof callToGetJSONObject<AIElementParseResponse>;
13
13
  }): Promise<{
14
14
  parseResult: AIElementParseResponse;
15
15
  elementById: (id: string) => ElementType;
@@ -4,19 +4,26 @@ export { e as AIElementParseResponse, A as AIResponseFormat, f as AISectionParse
4
4
  export { setDumpDir } from './utils.js';
5
5
  import 'openai/resources';
6
6
 
7
- declare class Insight<ElementType extends BaseElement = BaseElement> {
8
- contextRetrieverFn: () => Promise<UIContext<ElementType>> | UIContext<ElementType>;
7
+ interface LocateOpts {
8
+ multi?: boolean;
9
+ callAI?: typeof callToGetJSONObject<AIElementParseResponse>;
10
+ }
11
+ declare class Insight<ElementType extends BaseElement = BaseElement, ContextType extends UIContext<ElementType> = UIContext<ElementType>> {
12
+ contextRetrieverFn: () => Promise<ContextType> | ContextType;
9
13
  aiVendorFn: typeof callToGetJSONObject;
10
14
  onceDumpUpdatedFn?: DumpSubscriber;
11
15
  taskInfo?: Omit<InsightTaskInfo, 'durationMs'>;
12
- constructor(context: UIContext<ElementType> | (() => Promise<UIContext<ElementType>> | UIContext<ElementType>), opt?: InsightOptions);
13
- locate(queryPrompt: string): Promise<ElementType | null>;
16
+ constructor(context: ContextType | (() => Promise<ContextType> | ContextType), opt?: InsightOptions);
17
+ locate(queryPrompt: string, opt?: {
18
+ callAI: LocateOpts['callAI'];
19
+ }): Promise<ElementType | null>;
14
20
  locate(queryPrompt: string, opt: {
15
21
  multi: true;
16
22
  }): Promise<ElementType[]>;
17
23
  extract<T = any>(input: string): Promise<T>;
18
24
  extract<T extends Record<string, string>>(input: T): Promise<Record<keyof T, any>>;
19
25
  extract<T extends object>(input: Record<keyof T, string>): Promise<T>;
26
+ setAiVendorFn<T>(aiVendorFn: typeof callToGetJSONObject<T>): () => void;
20
27
  }
21
28
 
22
29
  declare class Executor {
@@ -36,7 +43,10 @@ declare class Executor {
36
43
  declare const getElement: typeof retrieveElement;
37
44
  declare const getSection: typeof retrieveSection;
38
45
 
39
- declare function plan(context: UIContext, userPrompt: string): Promise<{
46
+ declare function plan(userPrompt: string, opts: {
47
+ context: UIContext;
48
+ callAI?: typeof callToGetJSONObject<PlanningAIResponse>;
49
+ }): Promise<{
40
50
  plans: PlanningAction[];
41
51
  }>;
42
52
 
@@ -10,11 +10,17 @@ declare const insightDumpFileExt = "insight-dump.json";
10
10
  declare const groupedActionDumpFileExt = "web-dump.json";
11
11
  declare function getDumpDir(): string;
12
12
  declare function setDumpDir(dir: string): void;
13
- declare function writeDumpFile(fileName: string, fileExt: string, fileContent: string): string;
13
+ declare function getDumpDirPath(type: 'dump' | 'cache'): string;
14
+ declare function writeDumpFile(opts: {
15
+ fileName: string;
16
+ fileExt: string;
17
+ fileContent: string;
18
+ type?: 'dump' | 'cache';
19
+ }): string;
14
20
  declare function getTmpDir(): string;
15
- declare function getTmpFile(fileExt: string): string;
21
+ declare function getTmpFile(fileExtWithoutDot: string): string;
16
22
  declare function overlapped(container: Rect, target: Rect): boolean;
17
23
  declare function sleep(ms: number): Promise<unknown>;
18
24
  declare const commonScreenshotParam: any;
19
25
 
20
- export { commonScreenshotParam, getDumpDir, getPkgInfo, getTmpDir, getTmpFile, groupedActionDumpFileExt, insightDumpFileExt, overlapped, setDumpDir, sleep, writeDumpFile };
26
+ export { commonScreenshotParam, getDumpDir, getDumpDirPath, getPkgInfo, getTmpDir, getTmpFile, groupedActionDumpFileExt, insightDumpFileExt, overlapped, setDumpDir, sleep, writeDumpFile };
package/package.json CHANGED
@@ -1,11 +1,15 @@
1
1
  {
2
2
  "name": "@midscene/core",
3
3
  "description": "Hello, It's MidScene",
4
- "version": "0.0.1",
4
+ "version": "0.1.0",
5
5
  "jsnext:source": "./src/index.ts",
6
6
  "main": "./dist/lib/index.js",
7
7
  "module": "./dist/es/index.js",
8
8
  "types": "./dist/types/index.d.ts",
9
+ "files": [
10
+ "dist",
11
+ "README.md"
12
+ ],
9
13
  "exports": {
10
14
  ".": {
11
15
  "types": "./dist/types/index.d.ts",
package/.eslintignore DELETED
@@ -1,3 +0,0 @@
1
- demo_data
2
- vitest.config.ts
3
- modern.config.ts
package/.eslintrc.js DELETED
@@ -1,9 +0,0 @@
1
- module.exports = {
2
- root: true,
3
- rules: {
4
- '@typescript-eslint/no-explicit-any': 'warn',
5
- '@typescript-eslint/no-magic-numbers': 'off',
6
- '@typescript-eslint/no-parameter-properties': 'off',
7
- },
8
- extends: ['@modern-js'],
9
- };
package/CONTRIBUTING.md DELETED
@@ -1,5 +0,0 @@
1
- It's all driven by tests:
2
-
3
- ```shell
4
- npx vitest ./tests/
5
- ```