UNPKG

cordova-plugin-qonversion

Version:
47 lines (46 loc) 2.17 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const Mapper_1 = __importDefault(require("./Mapper")); const utils_1 = require("./utils"); const EVENT_SCREEN_SHOWN = "automations_screen_shown"; const EVENT_ACTION_STARTED = "automations_action_started"; const EVENT_ACTION_FAILED = "automations_action_failed"; const EVENT_ACTION_FINISHED = "automations_action_finished"; const EVENT_AUTOMATIONS_FINISHED = "automations_finished"; class AutomationsInternal { automationsDelegate = null; setDelegate(delegate) { this.automationsDelegate = delegate; (0, utils_1.subscribeOnAutomationsNativeEvents)('subscribe', this.onNativeEvent); } async showScreen(screenId) { return await (0, utils_1.callAutomationsNative)('showScreen', [screenId]); } setScreenPresentationConfig(config, screenId) { const data = Mapper_1.default.convertScreenPresentationConfig(config); (0, utils_1.callAutomationsNative)('setScreenPresentationConfig', [data, screenId]).then(utils_1.noop); } onNativeEvent = (event) => { switch (event.event) { case EVENT_SCREEN_SHOWN: this.automationsDelegate?.automationsDidShowScreen(event.payload.screenId); break; case EVENT_ACTION_STARTED: this.automationsDelegate?.automationsDidStartExecuting(Mapper_1.default.convertActionResult(event.payload)); break; case EVENT_ACTION_FAILED: this.automationsDelegate?.automationsDidFailExecuting(Mapper_1.default.convertActionResult(event.payload)); break; case EVENT_ACTION_FINISHED: this.automationsDelegate?.automationsDidFinishExecuting(Mapper_1.default.convertActionResult(event.payload)); break; case EVENT_AUTOMATIONS_FINISHED: this.automationsDelegate?.automationsFinished(); break; } }; } exports.default = AutomationsInternal;