UNPKG

askui

Version:

Reliable, automated end-to-end-testing that depends on what is shown on your screen instead of the technology you are running on

21 lines (20 loc) 957 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.InferenceResponse = void 0; const control_command_1 = require("../ui-control-commands/control-command"); const annotation_1 = require("../annotation/annotation"); const invalid_model_type_error_1 = require("./invalid-model-type-error"); class InferenceResponse { static fromJson(json, resizeRatio = 1, image) { return this.createModels(json.type, json.data, resizeRatio, image); } static createModels(type, data, resizeRatio, image) { if (type === 'COMMANDS') return control_command_1.ControlCommand.fromJson(data, resizeRatio); if (type === 'DETECTED_ELEMENTS') { return annotation_1.Annotation.fromJson({ image, detected_elements: data.detected_elements }, resizeRatio); } throw new invalid_model_type_error_1.InvalidModelTypeError(type); } } exports.InferenceResponse = InferenceResponse;