var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.taskRnvRun=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _ip=_interopRequireDefault(require("ip"));
var _path=_interopRequireDefault(require("path"));

var _platformManager=require("../core/platformManager");
var _logger=require("../core/systemManager/logger");
var _constants=require("../core/constants");











var _sdkWebpack=require("../sdk-webpack");
var _common=require("../core/common");
var _sdkTizen=require("../sdk-tizen");
var _sdkWebos=require("../sdk-webos");
var _sdkFirefox=require("../sdk-firefox");
var _chromecast=require("../sdk-webpack/chromecast");
var _fileutils=require("../core/systemManager/fileutils");
var _engineManager=require("../core/engineManager");

var _configureHostedIfRequired=function _configureHostedIfRequired(c){var bundleAssets,rnv;return _regenerator.default.async(function _configureHostedIfRequired$(_context){while(1){switch(_context.prev=_context.next){case 0:
(0,_logger.logTask)('_configureHostedIfRequired');

bundleAssets=(0,_common.getConfigProp)(c,c.platform,'bundleAssets',false);

if(!bundleAssets){
(0,_logger.logDebug)('Running hosted build');
rnv=c.paths.rnv;
(0,_fileutils.writeCleanFile)(
_path.default.join(rnv.dir,'supportFiles','appShell','index.html'),
_path.default.join((0,_common.getPlatformProjectDir)(c),'index.html'),
[
{
pattern:'{{DEV_SERVER}}',
override:"http://"+_ip.default.address()+":"+c.runtime.port}],

null,c);

}case 3:case"end":return _context.stop();}}},null,null,null,Promise);};


var taskRnvRun=function taskRnvRun(c,parentTask,originTask){var platform,port,target,hosted;return _regenerator.default.async(function taskRnvRun$(_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)('taskRnvRun',"parent:"+parentTask+" port:"+port+" target:"+target+" hosted:"+hosted);_context2.next=7;return _regenerator.default.awrap(

(0,_engineManager.executeOrSkipTask)(c,_constants.TASK_CONFIGURE,_constants.TASK_RUN,originTask));case 7:if(!

hosted){_context2.next=10;break;}
c.runtime.shouldOpenBrowser=true;return _context2.abrupt("return",

(0,_engineManager.executeTask)(c,_constants.TASK_START,_constants.TASK_RUN,originTask));case 10:_context2.t0=


platform;_context2.next=_context2.t0===
_constants.WEB?13:_context2.t0===


_constants.TIZEN?15:_context2.t0===
_constants.TIZEN_MOBILE?15:_context2.t0===
_constants.TIZEN_WATCH?15:_context2.t0===




_constants.WEBOS?19:_context2.t0===




_constants.KAIOS?23:_context2.t0===
_constants.FIREFOX_OS?23:_context2.t0===
_constants.FIREFOX_TV?23:_context2.t0===

_constants.CHROMECAST?24:28;break;case 13:c.runtime.shouldOpenBrowser=true;return _context2.abrupt("return",(0,_sdkWebpack.runWebpackServer)(c));case 15:if(c.program.only){_context2.next=18;break;}_context2.next=18;return _regenerator.default.awrap(_configureHostedIfRequired(c));case 18:return _context2.abrupt("return",(0,_sdkTizen.runTizen)(c,target));case 19:if(c.program.only){_context2.next=22;break;}_context2.next=22;return _regenerator.default.awrap(_configureHostedIfRequired(c));case 22:return _context2.abrupt("return",(0,_sdkWebos.runWebOS)(c));case 23:return _context2.abrupt("return",(0,_sdkFirefox.runFirefoxProject)(c));case 24:if(
c.program.only){_context2.next=27;break;}_context2.next=27;return _regenerator.default.awrap(
_configureHostedIfRequired(c));case 27:return _context2.abrupt("return",

(0,_chromecast.runChromecast)(c,platform,target));case 28:return _context2.abrupt("return",

(0,_platformManager.logErrorPlatform)(c));case 29:case"end":return _context2.stop();}}},null,null,null,Promise);};exports.taskRnvRun=taskRnvRun;var _default=



{
description:'Run your app in browser',
fn:taskRnvRun,
task:'run',
params:_constants.PARAMS.withBase(_constants.PARAMS.withConfigure(_constants.PARAMS.withRun())),
platforms:[
_constants.WEB,
_constants.TIZEN,
_constants.WEBOS,
_constants.TIZEN_MOBILE,
_constants.TIZEN_WATCH,
_constants.KAIOS,
_constants.FIREFOX_OS,
_constants.FIREFOX_TV,
_constants.CHROMECAST]};exports.default=_default;
//# sourceMappingURL=task.rnv.run.js.map