UNPKG

@hap-toolkit/packager

Version:

@hap-toolkit/packager

3 lines (2 loc) 1.47 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createFullPackage=createFullPackage,exports.createSubPackages=createSubPackages,exports.default=void 0;class Package{constructor(e){this.filePrefix=null,this.fileSubname=null,this.fileSuffix=null,this.icon="",this.banner="",this.comment=null,this.standalone=!1,this.subMatch=null,this._resourceList=[],this._widget=!1,Object.assign(this,e);const t=[this.fileSubname,this.fileSuffix].filter((e=>null!==e)).join(".");this.fileName=`${this.filePrefix}${this._widget?"_":"."}${t}`}addResource(e,t,i){if(this._resourceList[e])throw new Error(`### App Loader ### ${e} 文件重复添加`);this._resourceList[e]=!0,this._resourceList.push({fileBuildPath:e,fileContentBuffer:t,fileContentDigest:i})}get resourceList(){return this._resourceList}}var _default=Package;function createFullPackage(e){return new Package({filePrefix:e,fileSuffix:"rpk",standalone:!0})}exports.default=_default;const MAIN_PACKAGE_SUBNAME="base";function createSubPackages(e,t,i,s=""){let a;a=[];const n=new Package({filePrefix:e,fileSubname:MAIN_PACKAGE_SUBNAME,fileSuffix:"srpk",standalone:!0});return a.push(n),t.forEach((t=>{const n=new Package({filePrefix:e,fileSubname:t.name,_widget:t._widget,fileSuffix:t._widget?"rpk":"srpk",subMatch:new RegExp(`^${t.resource}/.*`,"i"),standalone:t.standalone||!1,icon:t.standalone?t.icon||i:"",banner:t.standalone?t.banner||s:""});a.push(n)})),a} //# sourceMappingURL=package.js.map