var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports._taskLog=exports._taskStart=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));
var _betterOpn=_interopRequireDefault(require("better-opn"));

var _common=require("../../common");






var _platformTools=require("../../platformTools");
var _logger=require("../../systemTools/logger");
var _constants=require("../../constants");





var _web=require("../../platformTools/web");
var _webNext=require("../../platformTools/web/webNext");
var _config=_interopRequireDefault(require("../../config"));
var _analytics=_interopRequireDefault(require("../../systemTools/analytics"));
var _sdkManager=require("../../platformTools/sdkManager");


var TASKS={};

var _taskStart=function _taskStart(c){var platform,port,hosted;return _regenerator.default.async(function _taskStart$(_context){while(1){switch(_context.prev=_context.next){case 0:
platform=c.platform;
port=c.runtime.port;
hosted=c.program.hosted;

(0,_logger.logTask)("rnvStart:"+
platform+":"+port+":"+hosted+":"+_config.default.isWebHostEnabled);


if(_config.default.isWebHostEnabled&&hosted){
(0,_common.waitForWebpack)(c).
then(function(){return(0,_betterOpn.default)("http://"+c.runtime.localhost+":"+port+"/");}).
catch(_logger.logError);
}_context.t0=

platform;_context.next=8;break;case 8:if(!

hosted){_context.next=10;break;}return _context.abrupt("return",
(0,_logger.logError)(
'This platform does not support hosted mode',
true));case 10:return _context.abrupt("return",


(0,_common.logErrorPlatform)(c,platform));case 11:case"end":return _context.stop();}}},null,null,null,Promise);};exports._taskStart=_taskStart;


TASKS[_constants.TASK_START]=_taskStart;

var _taskRun=function _taskRun(c){var platform,port,target,hosted;return _regenerator.default.async(function _taskRun$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:
platform=c.platform;
port=c.runtime.port;
target=c.runtime.target;
hosted=c.program.hosted;
(0,_logger.logTask)("_taskRun:"+platform+":"+port+":"+target+":"+hosted);_context2.t0=
platform;_context2.next=_context2.t0===
_constants.WEB?8:15;break;case 8:if(
c.program.only){_context2.next=13;break;}_context2.next=11;return _regenerator.default.awrap(
(0,_common.cleanPlatformIfRequired)(c,platform));case 11:_context2.next=13;return _regenerator.default.awrap(
(0,_common.configureIfRequired)(c,platform));case 13:

c.runtime.shouldOpenBrowser=true;return _context2.abrupt("return",
(0,_webNext.runWebNext)(c,platform,port,true));case 15:return _context2.abrupt("return",

(0,_common.logErrorPlatform)(c,platform));case 16:case"end":return _context2.stop();}}},null,null,null,Promise);};


TASKS[_constants.TASK_RUN]=_taskRun;

var _taskPackage=function _taskPackage(c){var platform;return _regenerator.default.async(function _taskPackage$(_context3){while(1){switch(_context3.prev=_context3.next){case 0:
(0,_logger.logTask)("_taskPackage:"+c.platform);
platform=c.platform;_context3.next=4;return _regenerator.default.awrap(

(0,_sdkManager.checkSdk)(c));case 4:_context3.t0=

platform;_context3.next=7;break;case 7:

(0,_common.logErrorPlatform)(c,platform);return _context3.abrupt("return",
false);case 9:case"end":return _context3.stop();}}},null,null,null,Promise);};


TASKS[_constants.TASK_PACKAGE]=_taskPackage;

var _taskExport=function _taskExport(c){var platform;return _regenerator.default.async(function _taskExport$(_context4){while(1){switch(_context4.prev=_context4.next){case 0:
(0,_logger.logTask)("_taskExport:"+c.platform);
platform=c.platform;_context4.next=4;return _regenerator.default.awrap(

(0,_sdkManager.checkSdk)(c));case 4:_context4.t0=

platform;_context4.next=_context4.t0===
_constants.WEB?7:11;break;case 7:if(
c.program.only){_context4.next=10;break;}_context4.next=10;return _regenerator.default.awrap(
_taskBuild(c));case 10:return _context4.abrupt("return",

(0,_webNext.exportWebNext)(c));case 11:

(0,_common.logErrorPlatform)(c,platform);case 12:case"end":return _context4.stop();}}},null,null,null,Promise);};


TASKS[_constants.TASK_EXPORT]=_taskExport;

var _taskBuild=function _taskBuild(c){var platform;return _regenerator.default.async(function _taskBuild$(_context5){while(1){switch(_context5.prev=_context5.next){case 0:
(0,_logger.logTask)("_taskBuild:"+c.platform);
platform=c.platform;_context5.next=4;return _regenerator.default.awrap(

(0,_sdkManager.checkSdk)(c));case 4:_context5.t0=

platform;_context5.next=_context5.t0===
_constants.WEB?7:_context5.t0===
_constants.CHROMECAST?7:14;break;case 7:_context5.next=9;return _regenerator.default.awrap(
(0,_common.cleanPlatformIfRequired)(c,platform));case 9:_context5.next=11;return _regenerator.default.awrap(
(0,_common.configureIfRequired)(c,platform));case 11:_context5.next=13;return _regenerator.default.awrap(
(0,_webNext.buildWebNext)(c));case 13:return _context5.abrupt("return");case 14:


(0,_common.logErrorPlatform)(c,platform);case 15:case"end":return _context5.stop();}}},null,null,null,Promise);};


TASKS[_constants.TASK_BUILD]=_taskBuild;

var _taskDeploy=function _taskDeploy(c){var platform;return _regenerator.default.async(function _taskDeploy$(_context6){while(1){switch(_context6.prev=_context6.next){case 0:
(0,_logger.logTask)("_taskDeploy:"+c.platform);
platform=c.platform;_context6.t0=

platform;_context6.next=_context6.t0===
_constants.WEB?5:_context6.t0===




_constants.CHROMECAST?9:13;break;case 5:if(c.program.only){_context6.next=8;break;}_context6.next=8;return _regenerator.default.awrap((0,_webNext.buildWebNext)(c));case 8:return _context6.abrupt("return",(0,_webNext.deployWebNext)(c,platform));case 9:if(
c.program.only){_context6.next=12;break;}_context6.next=12;return _regenerator.default.awrap(
_taskBuild(c));case 12:return _context6.abrupt("return",

(0,_web.deployWeb)(c,platform));case 13:if(

c.program.only){_context6.next=16;break;}_context6.next=16;return _regenerator.default.awrap(
_taskExport(c));case 16:case"end":return _context6.stop();}}},null,null,null,Promise);};



TASKS[_constants.TASK_DEPLOY]=_taskDeploy;

var _taskDebug=function _taskDebug(c){var platform;return _regenerator.default.async(function _taskDebug$(_context7){while(1){switch(_context7.prev=_context7.next){case 0:
(0,_logger.logTask)("_taskDebug:"+c.platform);
platform=c.platform;

switch(platform){
default:
(0,_common.logErrorPlatform)(c,platform);}case 3:case"end":return _context7.stop();}}},null,null,null,Promise);};


TASKS[_constants.TASK_DEBUG]=_taskDebug;

var _taskLog=function _taskLog(c){return _regenerator.default.async(function _taskLog$(_context8){while(1){switch(_context8.prev=_context8.next){case 0:
(0,_logger.logTask)("_taskLog:"+c.platform);
switch(c.platform){
default:
(0,_common.logErrorPlatform)(c,c.platform);}case 2:case"end":return _context8.stop();}}},null,null,null,Promise);};exports._taskLog=_taskLog;


TASKS[_constants.TASK_LOG]=_taskLog;

var runTask=function runTask(c,task){return _regenerator.default.async(function runTask$(_context9){while(1){switch(_context9.prev=_context9.next){case 0:
(0,_logger.logTask)("runTask:engine-rn-next:"+c.platform);_context9.next=3;return _regenerator.default.awrap(

(0,_platformTools.isPlatformSupported)(c));case 3:_context9.next=5;return _regenerator.default.awrap(
(0,_common.isBuildSchemeSupported)(c));case 5:_context9.next=7;return _regenerator.default.awrap(
(0,_sdkManager.checkSdk)(c));case 7:

_analytics.default.captureEvent({
type:task+"Project",
platform:c.platform});return _context9.abrupt("return",

TASKS[task](c));case 9:case"end":return _context9.stop();}}},null,null,null,Promise);};var _default=


{
runTask:runTask};exports.default=_default;
//# sourceMappingURL=index.js.map