"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const path_1=__importDefault(require("path")),commonData_1=require("../../types/commonData"),Runner_1=__importDefault(require("./Runner")),mobileUtils_1=require("./help/mobileUtils"),h5Utils_1=require("./help/h5Utils"),blockUtils_1=require("./help/blockUtils"),initProject_1=__importDefault(require("./storage/initProject")),initBlock_1=__importDefault(require("./storage/initBlock")),get_1=require("./storage/get"),set_1=require("./storage/set"),protocol_1=require("../../types/protocol"),protocol_2=require("../../protocol"),functional_1=require("../../utils/functional"),initH5Offline_1=__importDefault(require("./storage/initH5Offline")),initH5InBlock_1=__importDefault(require("./storage/initH5InBlock")),sdk_1=require("../../modules/static/item/sdk"),noop=()=>{},sdkList=sdk_1.JSSDKDefault.map(({name:e})=>e);Runner_1.default.use(commonData_1.AppTypeEnum.Gadget,{isApp:mobileUtils_1.checkAppType,async fetchSdkList(){try{const e=await this.execute(protocol_1.ModuleName.static,protocol_2.StaticCmdEnum.GetItem,e=>sdkList.includes(e.name));return e?e.sort((e,t)=>-(0,functional_1.versionCompare)(e.name,t.name)).map(e=>({type:e.type,version:e.version,url:e.uri,larkVersion:e.meta.larkVersion})):Promise.resolve([])}catch(e){return Promise.resolve([])}},listCompilePaths(){const e=this.execute(protocol_1.ModuleName.storage,protocol_2.StorageCmdEnum.Get,"projects")||{};return Object.keys(e).map(t=>({compilePath:t,type:commonData_1.AppTypeEnum.Gadget,projectName:(0,mobileUtils_1.getProjectName)(t),lastOpen:e[t].lastOpen}))},getStorageKey:e=>"config"===e?"simulatorConfig":"projects",getHtmlName:()=>"simulator",initProjectData:initProject_1.default,getProjectData:get_1.getProjectData,setProjectData:(0,set_1.setFactory)(commonData_1.AppTypeEnum.Gadget),saveProject:set_1.saveProject}),Runner_1.default.use(commonData_1.AppTypeEnum.Block,{isApp:blockUtils_1.isBlock,fetchSdkList:noop,listCompilePaths(){const e=this.execute(protocol_1.ModuleName.storage,protocol_2.StorageCmdEnum.Get,"blocks");return Object.keys(e).map(t=>({compilePath:t,type:commonData_1.AppTypeEnum.Block,projectName:(0,mobileUtils_1.getProjectName)(t),lastOpen:e[t].lastOpen}))},getStorageKey:()=>"blocks",getHtmlName:()=>"",initProjectData:initBlock_1.default,getProjectData:get_1.getBlockData,setProjectData:(0,set_1.setFactory)(commonData_1.AppTypeEnum.Block),saveProject:set_1.saveBlock}),Runner_1.default.use(commonData_1.AppTypeEnum.H5,{isApp:h5Utils_1.isApp,fetchSdkList:noop,listCompilePaths:()=>[],getStorageKey:()=>commonData_1.AppTypeEnum.H5,getHtmlName:h5Utils_1.getHtmlName,initProjectData:noop,getProjectData:noop,setProjectData:noop,saveProject:noop}),Runner_1.default.use(commonData_1.AppTypeEnum.H5Offline,{isApp:h5Utils_1.isApp,fetchSdkList:noop,listCompilePaths(){const e=this.execute(protocol_1.ModuleName.storage,protocol_2.StorageCmdEnum.Get,"h5OfflineList")||{};return Object.keys(e).map(t=>({compilePath:t,type:commonData_1.AppTypeEnum.H5Offline,projectName:t.split(path_1.default.sep).pop()||"unknown projectName",lastOpen:e[t].lastOpen}))},getStorageKey:()=>"h5OfflineList",getHtmlName:h5Utils_1.getHtmlName,initProjectData:initH5Offline_1.default,getProjectData:get_1.getH5OfflineData,setProjectData:(0,set_1.setFactory)(commonData_1.AppTypeEnum.H5Offline),saveProject:set_1.saveH5Offline}),Runner_1.default.use(commonData_1.AppTypeEnum.H5InBlock,{isApp:blockUtils_1.isBlock,fetchSdkList:noop,listCompilePaths(){const e=this.execute(protocol_1.ModuleName.storage,protocol_2.StorageCmdEnum.Get,"h5InBlockList")||{};return Object.keys(e).map(t=>({compilePath:t,type:commonData_1.AppTypeEnum.H5InBlock,projectName:t.split(path_1.default.sep).pop()||"unknown projectName",lastOpen:e[t].lastOpen}))},getStorageKey:()=>"h5InBlockList",getHtmlName:h5Utils_1.getHtmlName,initProjectData:initH5InBlock_1.default,getProjectData:get_1.getH5InBlockData,setProjectData:(0,set_1.setFactory)(commonData_1.AppTypeEnum.H5InBlock),saveProject:set_1.saveH5InBlock}),exports.default=Runner_1.default;