askui 0.11.2 → 0.11.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.
@@ -1,6 +1,8 @@
1
1
  import { CustomElementJson } from '../custom-element-json';
2
+ import { DetectedElement } from './detected-element';
2
3
  export interface AnnotationRequest {
3
4
  imagePath?: string;
5
+ elements?: DetectedElement[];
4
6
  outputPath?: string;
5
7
  fileNamePrefix?: string;
6
8
  customElements?: CustomElementJson[];
@@ -1,3 +1,7 @@
1
1
  export declare class ControlCommandError extends Error {
2
+ matcherResult: {
3
+ pass: boolean;
4
+ message: string;
5
+ };
2
6
  constructor(message: string);
3
7
  }
@@ -5,6 +5,10 @@ class ControlCommandError extends Error {
5
5
  constructor(message) {
6
6
  super(message);
7
7
  this.name = 'ControlCommandError';
8
+ this.matcherResult = {
9
+ pass: false,
10
+ message,
11
+ };
8
12
  }
9
13
  }
10
14
  exports.ControlCommandError = ControlCommandError;
@@ -34,5 +34,5 @@ export declare class ExecutionRuntime {
34
34
  annotateInteractively(): Promise<void>;
35
35
  takeScreenshotIfImageisNotProvided(imagePath?: string): Promise<string>;
36
36
  getDetectedElements(instruction: string, customElementJson?: CustomElementJson[]): Promise<DetectedElement[]>;
37
- annotateImage(imagePath?: string, customElementJson?: CustomElementJson[]): Promise<Annotation>;
37
+ annotateImage(imagePath?: string, customElementJson?: CustomElementJson[], elements?: DetectedElement[]): Promise<Annotation>;
38
38
  }
@@ -15,6 +15,7 @@ const custom_element_1 = require("../core/model/custom-element");
15
15
  const repeat_error_1 = require("./repeat-error");
16
16
  const misc_1 = require("./misc");
17
17
  const control_command_error_1 = require("./control-command-error");
18
+ const annotation_1 = require("../core/annotation/annotation");
18
19
  const logger_1 = require("../lib/logger");
19
20
  const base_64_image_1 = require("../utils/base_64_image/base-64-image");
20
21
  class ExecutionRuntime {
@@ -191,10 +192,16 @@ class ExecutionRuntime {
191
192
  return this.inferenceClient.getDetectedElements(instruction, base64Image, customElements);
192
193
  });
193
194
  }
194
- annotateImage(imagePath, customElementJson) {
195
+ annotateImage(imagePath, customElementJson, elements) {
195
196
  return __awaiter(this, void 0, void 0, function* () {
196
197
  let customElements = [];
197
198
  const base64Image = yield this.takeScreenshotIfImageisNotProvided(imagePath);
199
+ if (elements !== undefined) {
200
+ if (elements.length === 0) {
201
+ logger_1.logger.warn("Parameter 'elements' is an empty list.");
202
+ }
203
+ return new annotation_1.Annotation(base64Image, elements);
204
+ }
198
205
  if (customElementJson !== undefined) {
199
206
  customElements = yield custom_element_1.CustomElement.fromJsonListWithImagePathOrImage(customElementJson);
200
207
  }
@@ -92,7 +92,7 @@ class UiControlClient extends dsl_1.ApiCommands {
92
92
  }
93
93
  annotate(annotationRequest = {}) {
94
94
  return __awaiter(this, void 0, void 0, function* () {
95
- const annotation = yield this.executionRuntime.annotateImage(annotationRequest.imagePath, annotationRequest.customElements);
95
+ const annotation = yield this.executionRuntime.annotateImage(annotationRequest.imagePath, annotationRequest.customElements, annotationRequest.elements);
96
96
  annotation_writer_1.AnnotationWriter.write(annotation.toHtml(), annotationRequest.outputPath, annotationRequest.fileNamePrefix);
97
97
  return annotation;
98
98
  });
@@ -11,11 +11,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.UserIdentifier = void 0;
13
13
  const node_machine_id_1 = require("node-machine-id");
14
+ const lib_1 = require("../../lib");
14
15
  class UserIdentifier {
15
16
  // eslint-disable-next-line class-methods-use-this
16
17
  userId() {
17
18
  return __awaiter(this, void 0, void 0, function* () {
18
- return (0, node_machine_id_1.machineId)();
19
+ try {
20
+ return yield (0, node_machine_id_1.machineId)();
21
+ }
22
+ catch (error) {
23
+ lib_1.logger.debug("Can't retrieve user id!", error);
24
+ return Promise.resolve('undefined');
25
+ }
19
26
  });
20
27
  }
21
28
  }