UNPKG

@aiot-toolkit/packager

Version:

@aiot-toolkit/packager

3 lines (2 loc) 3.87 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.searchModuleImport=searchModuleImport,exports.updateManifest=updateManifest;var _sharedUtils=require("@aiot-toolkit/shared-utils"),_utils=require("./utils");function frameworkInit(){global.framework={module:{base:"system",ext:"service"},reservedFeatures:[],reservedFeatureExclude:[],supportInCard:[],project:{manifestFilePath:null,featureList:[],module:{usedBaseAll:!1,usedExtAll:!1}}};["alarm","audio","barcode","bluetooth","brightness","calendar","cipher","clipboard","contact","device","fetch","file","geolocation","image","keyguard","media","network","notification","package","prompt","record","request","resident","sensor","share","shortcut","sms","storage","vibrator","volume","websocketfactory","webview","battery","wifi","mediaquery","zip","telecom","decode","uploadtask","downloadtask","interconnect","crypto","exchange","internal.message","microphone","internal.ota","internal.power","internal.settings","internal.micamera","serviceUtil"].forEach((e=>{global.framework.reservedFeatures.push(`${global.framework.module.base}.${e}`)})),["account","alipay","ad","wxaccount","qqaccount","wbaccount","exchange","health","pay","push","qqaccount","share","stats","wbaccount","wxaccount","wxpay","biometriverify","texttoaudio","wechat","internal.audiosync","internal.audiofocus","internal.alarm","mihome","bootstrap","miai"].forEach((e=>{global.framework.reservedFeatures.push(`${global.framework.module.ext}.${e}`)}));["app","model","router","configuration"].forEach((e=>{global.framework.reservedFeatureExclude.push(`${global.framework.module.base}.${e}`)}));["share","prompt","vibrator","fetch","storage","clipboard","geolocation","network","device","battery","calendar","package","app","router"].forEach((e=>{global.framework.supportInCard.push(`${global.framework.module.base}.${e}`)}))}function searchModuleImport(e,r={}){const a=[],o=new RegExp(`['"]@(${global.framework.module.base}|${global.framework.module.ext}).*?['"]`,"g"),t=new RegExp(`['"]@((${global.framework.module.base}|${global.framework.module.ext}).*?)['"]`);return(e.match(o)||[]).forEach((e=>{const o=(e.match(t)||[])[1];o===`@${global.framework.module.base}`?global.framework.project.module.usedBaseAll=!0:o===`@${global.framework.module.ext}`?global.framework.project.module.usedExtAll=!0:-1!==global.framework.reservedFeatures.indexOf(o)?-1===global.framework.project.featureList.indexOf(o)&&global.framework.project.featureList.push(o):r.uxType===_utils.ENTRY_TYPE.CARD&&-1===global.framework.supportInCard.indexOf(o)?a.push({reason:`WARN: You introduced an unrecognized native module ${o} in the card`}):-1!==global.framework.reservedFeatureExclude.indexOf(o)||a.push({reason:`WARN: You introduced an unrecognized native module:${o}`})})),{fileCont:e,logFeatureList:a}}function checkFeatureInCard(e={}){Object.keys(e).forEach((r=>{e[r].features&&e[r].features.every((e=>{-1===global.framework.supportInCard.indexOf(e.name)&&_sharedUtils.colorconsole.error(`WARN: The unrecognized features ${e.name} of the card ${r} are introduced in the manifest.json file`)}))}))}function updateManifest(e,r){e.config=e.config||{},e.config.debug=r,e.minPlatformVersion&&"number"==typeof e.minPlatformVersion||(e.minPlatformVersion=1070),e.features=e.features||[],checkFeatureInCard(e.router.widgets||{});const a=[].concat(global.framework.project.featureList);e.features.forEach((e=>{const r=a.indexOf(e.name);-1!==r&&a.splice(r,1)}));const o=[];if(a.forEach((e=>{-1!==global.framework.reservedFeatures.indexOf(e)&&o.push(e)})),o.length>0){const r=o.map((function(e){return{name:e}}));e.features=e.features.concat(r);const a=o.join(", ");_sharedUtils.colorconsole.warn(`Please declare the interface used in the project code in the manifest.json file: ${a}\n`)}return e}frameworkInit(); //# sourceMappingURL=shared.js.map