miniprogram-ci 1.9.6 → 1.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -2
- package/README.md +7 -0
- package/dist/@types/ci/project.d.ts +3 -3
- package/dist/@types/ci/upload.d.ts +2 -2
- package/dist/@types/config.d.ts +1 -1
- package/dist/@types/core/json/projectWithMockBuffer.d.ts +1 -1
- package/dist/@types/core/json/reactiveCache.d.ts +1 -1
- package/dist/@types/core/utils/env.d.ts +2 -2
- package/dist/@types/core/utils/logger.d.ts +2 -2
- package/dist/@types/core/validate/schemaValidate.d.ts +1 -1
- package/dist/@types/core/validate/validate.d.ts +1 -1
- package/dist/@types/summer/devtool.d.ts +12 -12
- package/dist/@types/summer/graph/basegraph.d.ts +2 -2
- package/dist/@types/summer/plugin_driver.d.ts +4 -4
- package/dist/@types/summer/project.d.ts +3 -3
- package/dist/@types/summer/resolver.d.ts +2 -2
- package/dist/@types/summer/types.d.ts +21 -21
- package/dist/@types/summer/worker.d.ts +2 -2
- package/dist/@types/types/index.d.ts +4 -4
- package/dist/@types/utils/interruptibletask.d.ts +1 -1
- package/dist/@types/utils/report.d.ts +1 -1
- package/dist/@types/vendor/cloud-api/src/transaction/contracts/factory.d.ts +2 -2
- package/dist/@types/vendor/cloud-api/src/utils/validator.d.ts +7 -7
- package/dist/@types/vendor/code-analyse/index.d.ts +4 -1
- package/dist/ci/code-analyse.js +1 -1
- package/dist/ci/cos-upload.js +1 -1
- package/dist/ci/getCompiledResult.js +1 -1
- package/dist/ci/getDevSourceMap.js +1 -1
- package/dist/ci/getLatestVersion.js +1 -1
- package/dist/ci/jsserver.js +1 -1
- package/dist/ci/preview.js +1 -1
- package/dist/ci/project.js +1 -1
- package/dist/ci/projectattr.js +1 -1
- package/dist/ci/upload.js +1 -1
- package/dist/ci/utils/filterUnusedFile.js +1 -1
- package/dist/ci/utils/packfile.js +1 -1
- package/dist/cli.js +1 -1
- package/dist/cloud/cloudapi.js +1 -1
- package/dist/cloud/createTimeTrigger.js +1 -1
- package/dist/cloud/uploadContainer.js +1 -1
- package/dist/cloud/uploadFile.js +1 -1
- package/dist/cloud/uploadFunction.js +1 -1
- package/dist/cloud/utils.js +1 -1
- package/dist/config.js +1 -1
- package/dist/core/compile/common.js +1 -1
- package/dist/core/compile/game.js +1 -1
- package/dist/core/compile/game_plugin.js +1 -1
- package/dist/core/compile/handler/js.js +1 -1
- package/dist/core/compile/handler/mpjson.js +1 -1
- package/dist/core/compile/handler/wxml.js +1 -1
- package/dist/core/compile/handler/wxss.js +1 -1
- package/dist/core/compile/index.js +1 -1
- package/dist/core/compile/mini_program.js +1 -1
- package/dist/core/compile/mini_program_plugin.js +1 -1
- package/dist/core/js/enhance.js +1 -1
- package/dist/core/js/index.js +1 -1
- package/dist/core/js/minifyjs_after_wrap.js +1 -1
- package/dist/core/json/app/checkAppFields.js +1 -1
- package/dist/core/json/app/getAppJSON.js +1 -1
- package/dist/core/json/app/getExtJSON.js +1 -1
- package/dist/core/json/app/index.js +1 -1
- package/dist/core/json/common.js +1 -1
- package/dist/core/json/game.js +1 -1
- package/dist/core/json/page/checkPageJSON.js +1 -1
- package/dist/core/json/page/getPageJSON.js +1 -1
- package/dist/core/json/plugin/plugin.js +1 -1
- package/dist/core/json/plugin/plugin_page.js +1 -1
- package/dist/core/json/projectWithMockBuffer.js +1 -1
- package/dist/core/json/projectconfig.js +1 -1
- package/dist/core/json/reactiveCache.js +1 -1
- package/dist/core/json/signaturejson.js +1 -1
- package/dist/core/json/sitemap.js +1 -1
- package/dist/core/json/theme.js +1 -1
- package/dist/core/npm/filterdeps.js +1 -1
- package/dist/core/npm/packnpm.js +1 -1
- package/dist/core/protect/file_flatter.js +1 -1
- package/dist/core/protect/uglifyfilenames.js +1 -1
- package/dist/core/validate/validate.js +1 -1
- package/dist/core/worker_thread/childprocess.js +1 -1
- package/dist/core/worker_thread/childprocess_manager.js +1 -1
- package/dist/core/worker_thread/fork.js +1 -1
- package/dist/core/worker_thread/index.js +1 -1
- package/dist/core/worker_thread/task/call_func.js +1 -1
- package/dist/core/worker_thread/task/compilejs.js +1 -1
- package/dist/core/worker_thread/task/compilewxss.js +1 -1
- package/dist/core/worker_thread/task/func.js +1 -1
- package/dist/core/worker_thread/task/minifywxml.js +1 -1
- package/dist/core/worker_thread/worker.js +1 -1
- package/dist/core/worker_thread/worker_manager.js +1 -1
- package/dist/core.js +1 -1
- package/dist/index.js +1 -1
- package/dist/manifest.json +2 -2
- package/dist/summer/devtool.js +1 -1
- package/dist/summer/entry_process.js +1 -1
- package/dist/summer/graph/appconf.js +1 -1
- package/dist/summer/graph/basegraph.js +1 -1
- package/dist/summer/graph/pluginconf.js +1 -1
- package/dist/summer/initPlugin.js +1 -1
- package/dist/summer/persist_cache.js +1 -1
- package/dist/summer/plugins/base/javascript.js +1 -1
- package/dist/summer/plugins/base/wxss.js +1 -1
- package/dist/summer/plugins/enhance.js +1 -1
- package/dist/summer/plugins/less.js +1 -1
- package/dist/summer/plugins/minifywxml.js +1 -1
- package/dist/summer/plugins/sass.js +1 -1
- package/dist/summer/plugins/typescript.js +1 -1
- package/dist/summer/project.js +1 -1
- package/dist/summer/resolver.js +1 -1
- package/dist/summer/summer.js +1 -1
- package/dist/types/index.js +1 -1
- package/dist/types/miniprogram-json/index.js +1 -1
- package/dist/utils/babel_helper.js +1 -1
- package/dist/utils/common.js +1 -1
- package/dist/utils/error.js +1 -1
- package/dist/utils/fsagent.js +1 -1
- package/dist/utils/glob.js +1 -1
- package/dist/utils/jsonParse.js +1 -1
- package/dist/utils/locales/locales.js +1 -1
- package/dist/utils/request.js +1 -1
- package/dist/utils/sign.js +1 -1
- package/dist/utils/taskstatus.js +1 -1
- package/dist/utils/tools.js +1 -1
- package/dist/utils/white_ext_list.js +1 -1
- package/dist/vendor/babel_runtime/helpers/AsyncGenerator.js +1 -1
- package/dist/vendor/babel_runtime/helpers/OverloadYield.js +1 -0
- package/dist/vendor/babel_runtime/helpers/applyDecs.js +1 -0
- package/dist/vendor/babel_runtime/helpers/applyDecs2203.js +1 -0
- package/dist/vendor/babel_runtime/helpers/applyDecs2203R.js +1 -0
- package/dist/vendor/babel_runtime/helpers/applyDecs2301.js +1 -0
- package/dist/vendor/babel_runtime/helpers/asyncGeneratorDelegate.js +1 -1
- package/dist/vendor/babel_runtime/helpers/asyncIterator.js +1 -1
- package/dist/vendor/babel_runtime/helpers/awaitAsyncGenerator.js +1 -1
- package/dist/vendor/babel_runtime/helpers/checkInRHS.js +1 -0
- package/dist/vendor/babel_runtime/helpers/checkPrivateRedeclaration.js +1 -0
- package/dist/vendor/babel_runtime/helpers/classApplyDescriptorDestructureSet.js +1 -0
- package/dist/vendor/babel_runtime/helpers/classApplyDescriptorGet.js +1 -0
- package/dist/vendor/babel_runtime/helpers/classApplyDescriptorSet.js +1 -0
- package/dist/vendor/babel_runtime/helpers/classCheckPrivateStaticAccess.js +1 -0
- package/dist/vendor/babel_runtime/helpers/classCheckPrivateStaticFieldDescriptor.js +1 -0
- package/dist/vendor/babel_runtime/helpers/classExtractFieldDescriptor.js +1 -0
- package/dist/vendor/babel_runtime/helpers/classNameTDZError.js +1 -1
- package/dist/vendor/babel_runtime/helpers/classPrivateFieldDestructureSet.js +1 -1
- package/dist/vendor/babel_runtime/helpers/classPrivateFieldGet.js +1 -1
- package/dist/vendor/babel_runtime/helpers/classPrivateFieldInitSpec.js +1 -0
- package/dist/vendor/babel_runtime/helpers/classPrivateFieldSet.js +1 -1
- package/dist/vendor/babel_runtime/helpers/classPrivateMethodInitSpec.js +1 -0
- package/dist/vendor/babel_runtime/helpers/classStaticPrivateFieldDestructureSet.js +1 -0
- package/dist/vendor/babel_runtime/helpers/classStaticPrivateFieldSpecGet.js +1 -1
- package/dist/vendor/babel_runtime/helpers/classStaticPrivateFieldSpecSet.js +1 -1
- package/dist/vendor/babel_runtime/helpers/classStaticPrivateMethodGet.js +1 -1
- package/dist/vendor/babel_runtime/helpers/construct.js +1 -1
- package/dist/vendor/babel_runtime/helpers/createClass.js +1 -1
- package/dist/vendor/babel_runtime/helpers/createForOfIteratorHelper.js +1 -1
- package/dist/vendor/babel_runtime/helpers/createForOfIteratorHelperLoose.js +1 -1
- package/dist/vendor/babel_runtime/helpers/defineAccessor.js +1 -0
- package/dist/vendor/babel_runtime/helpers/defineEnumerableProperties.js +1 -1
- package/dist/vendor/babel_runtime/helpers/defineProperty.js +1 -1
- package/dist/vendor/babel_runtime/helpers/extends.js +1 -1
- package/dist/vendor/babel_runtime/helpers/get.js +1 -1
- package/dist/vendor/babel_runtime/helpers/getPrototypeOf.js +1 -1
- package/dist/vendor/babel_runtime/helpers/identity.js +1 -0
- package/dist/vendor/babel_runtime/helpers/inherits.js +1 -1
- package/dist/vendor/babel_runtime/helpers/inheritsLoose.js +1 -1
- package/dist/vendor/babel_runtime/helpers/interopRequireDefault.js +1 -1
- package/dist/vendor/babel_runtime/helpers/interopRequireWildcard.js +1 -1
- package/dist/vendor/babel_runtime/helpers/isNativeReflectConstruct.js +1 -1
- package/dist/vendor/babel_runtime/helpers/iterableToArray.js +1 -1
- package/dist/vendor/babel_runtime/helpers/iterableToArrayLimit.js +1 -1
- package/dist/vendor/babel_runtime/helpers/iterableToArrayLimitLoose.js +1 -1
- package/dist/vendor/babel_runtime/helpers/objectDestructuringEmpty.js +1 -1
- package/dist/vendor/babel_runtime/helpers/objectSpread.js +1 -1
- package/dist/vendor/babel_runtime/helpers/possibleConstructorReturn.js +1 -1
- package/dist/vendor/babel_runtime/helpers/readOnlyError.js +1 -1
- package/dist/vendor/babel_runtime/helpers/regeneratorRuntime.js +1 -0
- package/dist/vendor/babel_runtime/helpers/set.js +1 -1
- package/dist/vendor/babel_runtime/helpers/setPrototypeOf.js +1 -1
- package/dist/vendor/babel_runtime/helpers/toPrimitive.js +1 -1
- package/dist/vendor/babel_runtime/helpers/toPropertyKey.js +1 -1
- package/dist/vendor/babel_runtime/helpers/typeof.js +1 -1
- package/dist/vendor/babel_runtime/helpers/wrapRegExp.js +1 -1
- package/dist/vendor/babel_runtime/helpers/writeOnlyError.js +1 -0
- package/dist/vendor/cloud-api/src/apis/apis.js +1 -1
- package/dist/vendor/cloud-api/src/apis/cdn/cdn.apis.js +1 -1
- package/dist/vendor/cloud-api/src/apis/cdn/index.js +1 -1
- package/dist/vendor/cloud-api/src/apis/flexdb/flexdb.apis.js +1 -1
- package/dist/vendor/cloud-api/src/apis/flexdb/index.js +1 -1
- package/dist/vendor/cloud-api/src/apis/scf/index.js +1 -1
- package/dist/vendor/cloud-api/src/apis/scf/scf.apis.js +1 -1
- package/dist/vendor/cloud-api/src/apis/ssl/index.js +1 -1
- package/dist/vendor/cloud-api/src/apis/ssl/ssl.apis.js +1 -1
- package/dist/vendor/cloud-api/src/apis/tcb/general.apis.js +1 -1
- package/dist/vendor/cloud-api/src/apis/tcb/index.js +1 -1
- package/dist/vendor/cloud-api/src/apis/tcb/tcb.apis.js +1 -1
- package/dist/vendor/cloud-api/src/index.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/contracts/cdn.contracts.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/contracts/contracts.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/contracts/flexdb.contracts.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/contracts/scf.contracts.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/contracts/ssl.contracts.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/contracts/tcb.contracts.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/validations/cdn.validations.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/validations/common.validations.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/validations/flexdb.validations.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/validations/scf.validations.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/validations/ssl.validations.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/validations/tcb.validations.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/validations/validations.js +1 -1
- package/dist/vendor/cloud-api/src/utils/common.js +1 -1
- package/dist/vendor/code-analyse/index.js +1 -1
- package/package.json +23 -22
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkRequiredPrivateInfos=exports.checkResolveAlias=exports.checkRenderer=exports.checkOpenDataContext=exports.getAppJSONVariableDecalearProperty=exports.checkEntranceDeclare=exports.checkComponentPath=exports.checkMainPkgPluginIsInSubPkg=exports.checkMainPkgPageIsInSubpkg=exports.checkTabbarPage=exports.checkEntryPagePath=exports.checkPreloadRule=exports.checkFunctionalPages=exports.checkNavigateToMiniProgramAppIdList=exports.checkPlugins=exports.checkSubpackages=exports.checkSitemapLocation=exports.checkMainPkgPages=exports.checkOpenLocationPagePath=exports.checkWorkers=exports.checkTabbar=exports.checkWindow=exports.checkPageExist=void 0;const tslib_1=require("tslib"),lodash_1=(0,tslib_1.__importDefault)(require("lodash")),config_1=require("../../../config"),common_1=require("../common"),common_2=require("../../../utils/common"),tools_1=require("../../../utils/tools"),path_1=(0,tslib_1.__importDefault)(require("path")),locales_1=(0,tslib_1.__importDefault)(require("../../../utils/locales/locales")),schemaValidate_1=require("../../validate/schemaValidate"),projectconfig_1=require("../projectconfig");function checkPageExist(e,o,t){const{miniprogramRoot:a,project:c,filePath:n}=e;c.stat(a,o+".wxml")||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t,o+".wxml"),code:config_1.FILE_NOT_FOUND,filePath:n}),c.stat(a,o+".js")||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t,o+".js"),code:config_1.FILE_NOT_FOUND,filePath:n})}function checkWindow(e){const{inputJSON:o,mode:t}=e;let a=""+e.filePath;o.themeLocation&&(a+=` or ${o.themeLocation}["${t}"]`);const c=[],{window:n}=o;n&&(void 0!==n.navigationBarBackgroundColor&&((0,tools_1.isHexColor)(n.navigationBarBackgroundColor)||c.push(`["window"]["navigationBarBackgroundColor"]: "${n.navigationBarBackgroundColor}" is not hexColor`)),void 0!==n.backgroundColor&&((0,tools_1.isHexColor)(n.backgroundColor)||c.push(`["window"]["backgroundColor"]: "${n.backgroundColor}" is not hexColor`)),c.length>0&&(0,common_2.throwError)({msg:c.join("\n"),filePath:a}))}function checkTabbar(e){const{project:o,miniprogramRoot:t,inputJSON:a,mode:c}=e;let n=""+e.filePath;a.themeLocation&&(n+=` or ${a.themeLocation}["${c}"]`);const{tabBar:r}=a,i=o.attrSync(),{setting:s}=i;if(!r)return;const l=[];r.list.length<s.MinTabbarCount&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_TABBAR_AT_LEAST.format(s.MinTabbarCount),filePath:n}),r.list.length>s.MaxTabbarCount&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_TABBAR_AT_MOST.format(s.MaxTabbarCount),filePath:n});for(let e=0;e<r.list.length;e++){const a=r.list[e],{pagePath:c}=a;if((0,common_2.checkPath)({value:c,tips:`["tabBar"]["list"][${e}]["pagePath"]`,filePath:n}),!c){l.push(locales_1.default.config.JSON_TABBAR_PATH_EMPTY.format(e));continue}c.indexOf("?")>=0&&l.push(locales_1.default.config.JSON_SHOULD_NOT_CONTAIN.format(`["tabBar"]["list"][${e}]["pagePath"]`,"?")),c.indexOf(".")>=0&&l.push(locales_1.default.config.JSON_SHOULD_NOT_CONTAIN.format(`["tabBar"]["list"][${e}]["pagePath"]`,"."));const i=r.list.slice(0,e).findIndex(e=>e.pagePath===c);i>=0&&l.push(locales_1.default.config.JSON_TABBAR_PATH_SAME_WITH_OTHER.format(e,i));const f=[];a.iconPath&&((0,common_2.checkPath)({value:a.iconPath,tips:`["tabBar"]["list"][${e}]["iconPath"]`,filePath:n,checkPathType:common_2.ECheckPathType.TAB_BAR_ICON}),f.push({name:"iconPath",path:a.iconPath})),a.selectedIconPath&&((0,common_2.checkPath)({value:a.selectedIconPath,tips:`["tabBar"]["list"][${e}]["selectedIconPath"]`,filePath:n,checkPathType:common_2.ECheckPathType.TAB_BAR_ICON}),f.push({name:"selectedIconPath",path:a.selectedIconPath})),f.forEach(a=>{const c=o.stat(t,a.path);if(!c)return void l.push(locales_1.default.config.NOT_FOUND.format(`["tabBar"]["list"][${e}]["${a.name}"]: "${a.path}"`));if(c.isDirectory)return void l.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(`["tabBar"]["list"][${e}]["${a.name}"]`,locales_1.default.config.FILE));c.size>1024*s.MaxTabbarIconSize&&l.push(locales_1.default.config.JSON_TABBAR_ICON_MAX_SIZE.format([e,a.name,s.MaxTabbarIconSize]));const n=path_1.default.posix.extname(a.path);config_1.TABBAR_ICON_WHITE_LIST.indexOf(n)<0&&l.push(locales_1.default.config.JSON_TABBAR_ICON_EXT.format([e,a.name,config_1.TABBAR_ICON_WHITE_LIST.join("、")]))})}l.length>0&&(0,common_2.throwError)({msg:l.join("\n"),filePath:n})}function checkWorkers(e){const{project:o,miniprogramRoot:t,filePath:a,inputJSON:c}=e,{workers:n}=c;if(void 0===n)return;const r='["workers"]';""===n&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(r,locales_1.default.config.DIRECTORY),filePath:a});const i=(0,tools_1.getWorkersPath)(n);(0,common_2.checkPath)({value:i,tips:r,filePath:a});const s=o.stat(t,i);s&&s.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([r,locales_1.default.config.DIRECTORY]),filePath:a}),"string"==typeof c.workers?c.workers=(0,tools_1.normalizePath)(c.workers+"/"):c.workers.path=(0,tools_1.normalizePath)(c.workers.path+"/")}function checkOpenLocationPagePath(e){const{filePath:o,inputJSON:t}=e,{openLocationPagePath:a}=t;if(void 0===a)return;const c='["openLocationPagePath"]';(0,common_2.checkPath)({value:a,tips:c,filePath:o}),checkPageExist(e,a,c)}exports.checkPageExist=checkPageExist,exports.checkWindow=checkWindow,exports.checkTabbar=checkTabbar,exports.checkWorkers=checkWorkers,exports.checkOpenLocationPagePath=checkOpenLocationPagePath;const checkMainPkgPages=e=>{const{filePath:o,inputJSON:t}=e,{pages:a}=t;if(!a)return;const c={};for(let t=0;t<a.length;t++){const n=a[t],r=`["pages"][${t}]`;(0,common_2.checkPath)({value:n,tips:r,filePath:o}),c[n]&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_PAGES_REPEAT.format(`"${n}"`,'["pages"]'),filePath:o}),c[n]=!0,checkPageExist(e,n,r)}};function checkSitemapLocation(e){const{filePath:o,inputJSON:t}=e,{sitemapLocation:a}=t;if(void 0===a)return;const{project:c,miniprogramRoot:n}=e,r='["sitemapLocation"]';(0,common_2.checkPath)({value:a,tips:r,filePath:o});const i=c.stat(n,a);i&&!i.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(r,a),filePath:o});".json"!==path_1.default.posix.extname(a)&&(0,common_2.throwError)({msg:locales_1.default.config.EXT_SHOULD_BE_ERROR.format(r,".json"),filePath:o});const s=c.getFile(n,a),l=(0,common_2.checkUTF8)(s,a),f=(0,common_1.checkJSONFormat)(l,a),h=(0,schemaValidate_1.schemaValidate)("sitemap",f);if(h.error.length){const e=h.error.map(e=>"type"===e.errorType||"enum"===e.errorType||"anyOf"===e.errorType?locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([e.errorProperty,e.correctType]):locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([e.requireProperty])).join("\n");(0,common_2.throwError)({msg:e,filePath:a})}}function checkSubpackages(e){const{project:o,miniprogramRoot:t,filePath:a,inputJSON:c}=e;let n='["subPackages"]';c.subpackages&&(n='["subpackages"]',c.subPackages=c.subpackages,delete c.subpackages);const r=[];if(c.subPackages){const i=o.attrSync(),{setting:s}=i;c.subPackages.length>s.MaxSubPackageLimit&&(0,common_2.throwError)({msg:locales_1.default.config.EXCEED_LIMIT.format([n,s.MaxSubPackageLimit]),filePath:a});const l={},f={};for(let i=0;i<c.subPackages.length;i++){const s=c.subPackages[i],h=`${n}[${i}]`;if((0,common_2.checkPath)({value:s.root,tips:`${n}[${i}]["root"]`,filePath:a}),s.root===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${i}]["root"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(s.name){if(s.name===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${i}]["name"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(f[s.name]){r.push(locales_1.default.config.SAME_ITEM.format(h,f[s.name],"name"));continue}f[s.name]=h}if(s.root=(0,tools_1.normalizePath)(s.root+"/"),l[s.root]){r.push(locales_1.default.config.SAME_ITEM.format(h,l[s.root],"root"));continue}l[s.root]=h;const _=o.stat(t,s.root);if(!_){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`${n}[${i}]["root"]`,locales_1.default.config.DIRECTORY]));continue}if(!_.isDirectory){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`${n}[${i}]["root"]`,locales_1.default.config.DIRECTORY]));continue}const p={};for(let o=0,t=s.pages.length;o<t;o++){const t=s.pages[o];(0,common_2.checkPath)({value:t,tips:`${n}[${i}]["pages"][${o}]`,filePath:a});const c=(0,tools_1.normalizePath)(path_1.default.posix.join(s.root,t));p[c]?r.push(locales_1.default.config.JSON_PAGES_REPEAT.format([`"${t}"`,`${n}[${i}]`])):(p[c]=!0,checkPageExist(e,c,`${n}[${i}]["pages"][${o}]`))}}r.length>0&&(0,common_2.throwError)({msg:r.join("\n"),filePath:a});for(let e=0;e<c.subPackages.length;e++){const o=c.subPackages[e];let t=-1;const a="/"+o.root;c.subPackages.forEach((o,c)=>{if(c!==e&&o.root){const e="/"+o.root;0===a.indexOf(e)&&(t=c)}}),-1===t||r.push(locales_1.default.config.JSON_SHOULD_NOT_CONTAIN.format(`${n}[${t}]["root"]`,`${n}[${e}]["root"]`))}r.length>0&&(0,common_2.throwError)({msg:r.join("\n"),filePath:a})}}function checkPlugins(e){const{filePath:o,inputJSON:t,project:a}=e,c=[],n=t.plugins||{},r=(0,projectconfig_1.getProjectConfigJSON)(a);function i(e,o){var t;const{appid:n}=a,i=a.type===config_1.COMPILE_TYPE.miniProgramPlugin;if(i||"dev"!==e.version)if(i)"dev"===e.version&&e.provider!==n&&e.provider!==r.pluginAppid?c.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(o+'["provider"]',`"${null!==(t=r.pluginAppid)&&void 0!==t?t:n}"`)):e.provider===n&&"dev"!==e.version&&c.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(o+'["version"]','"dev"'));else{if("dev"===e.version||"latest"===e.version||/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/.test(e.version)||/^dev-[A-Za-z0-9]+$/.test(e.version))return!0;c.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([o+'["version"]',locales_1.default.config.TRIPLE_NUMBER_DOT]))}else c.push(`${locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(o+'["version"]',"dev")}\n${locales_1.default.config.PLEASE_CHOOSE_PLUGIN_MODE}`)}for(const e in n){i(n[e],`["plugins"]["${e}"]`)}t.subPackages&&t.subPackages.forEach((e,o)=>{if(!e.plugins)return;const t=`["subPackages"][${o}]`;for(const o in e.plugins){i(e.plugins[o],`${t}["plugins"]["${o}"]`)}}),c.length>0&&(0,common_2.throwError)({msg:c.join("\n"),filePath:o})}function checkNavigateToMiniProgramAppIdList(e){const{filePath:o,inputJSON:t,project:a}=e,c=[];if(t.navigateToMiniProgramAppIdList){const e=a.attrSync(),{appType:o=config_1.APP_TYPE.NORMAL,setting:n}=e;if(o!==config_1.APP_TYPE.NATIVE){const e=null==n?void 0:n.NavigateMiniprogramLimit;t.navigateToMiniProgramAppIdList.length>e&&c.push(locales_1.default.config.EXCEED_LIMIT.format('["navigateToMiniProgramAppIdList"]',e))}}c.length>0&&(0,common_2.throwError)({msg:c.join("\n"),filePath:o})}function checkFunctionalPages(e){const{inputJSON:o}=e;if(o.functionalPages&&"object"!==(0,tools_1.getType)(o.functionalPages)){const e='["functionalPages"] 配置需要更新,详见文档: https://developers.weixin.qq.com/miniprogram/dev/framework/plugin/functional-pages.html';o.__warning__?o.__warning__=`${o.__warning__}\n${e}`:o.__warning__=e}}function checkPreloadRule(e,o){const{inputJSON:t,filePath:a}=e,{preloadRule:c,subPackages:n}=t;if(!c||!n)return;const r=[],i={},s={},l={};o.forEach(e=>{i[e.root]=!0,l[e.path]=!0,e.name&&(s[e.name]=!0)});for(const e in c){if(!l[e]&&!e.includes("__plugin__/")){r.push(locales_1.default.config.NOT_FOUND.format(`["preloadRule"]["${e}"]: ${locales_1.default.config.PAGE_PATH}`));continue}const o=c[e];for(let t=0,a=o.packages.length;t<a;t++){let a=o.packages[t];a!==config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT&&(s[a]||(a=(0,tools_1.normalizePath)(a+"/"),i[a]||r.push(locales_1.default.config.NOT_FOUND.format(`["preloadRule"]["${e}"]["packages"][${t}]: ${a}`))))}}r.length>0&&(0,common_2.throwError)({msg:r.join("\n"),filePath:a})}function checkEntryPagePath(e,o){const{inputJSON:t,filePath:a}=e,{entryPagePath:c}=t;if(!c)return;(0,common_2.checkPath)({value:c,tips:'["entryPagePath"]',filePath:a});let n=!1;for(const e of o)if(e.path===c){n=!0;break}n||(0,common_2.throwError)({msg:locales_1.default.config.JSON_ENTRY_PAGE_PATH_NOT_FOUND.format(["pages、subPackages","entryPagePath"]),filePath:a})}function checkTabbarPage(e){const{filePath:o,inputJSON:t}=e,{tabBar:a,pages:c=[]}=t;if(!a)return;const n=[];for(let e=0;e<a.list.length;e++){const o=a.list[e],{pagePath:t}=o;c.indexOf(t)<0&&n.push(`["tabBar"][${e}]["pagePath"]: "${t}" need in ["pages"]`)}n.length>0&&(0,common_2.throwError)({msg:n.join("\n"),filePath:o})}function checkMainPkgPageIsInSubpkg(e){const{filePath:o,inputJSON:t}=e,{subPackages:a,pages:c=[]}=t;if(!a)return;const n=[];for(let e=0;e<a.length;e++){const o=a[e];for(let t=0;t<c.length;t++){const a=c[t];0===a.indexOf(o.root)&&n.push(locales_1.default.config.SHOULD_NOT_IN.format([`["pages"][${t}]: "${a}"`,`["subPackages"][${e}]`]))}}n.length>0&&(0,common_2.throwError)({msg:n.join("\n"),filePath:o})}function checkMainPkgPluginIsInSubPkg(e){const{filePath:o,inputJSON:t}=e,{plugins:a={},subPackages:c}=t,n={},r={},i=[];for(const e in a){const o=a[e],t=`["plugins"]["${e}"]`;n[o.provider]?i.push(locales_1.default.config.SAME_ITEM.format(`["plugins"]["${e}"]`,n[o.provider].tips,"provider")):n[o.provider]=r[e]={provider:o.provider,version:o.version,alias:e,tips:t}}if(c)for(let e=0;e<c.length;e++){const o=c[e];if(o.plugins)for(const t in o.plugins){const a=`["subPackages"][${e}]["plugins"]`,c=o.plugins[t];n[c.provider]?i.push(locales_1.default.config.SAME_ITEM.format(`${a}["${t}"]`,n[c.provider].tips,"provider")):r[t]?i.push(locales_1.default.config.PLUGINS_SAME_ALIAS.format(`${a}["${t}"]`,r[t].tips)):n[c.provider]=r[t]={provider:c.provider,version:c.version,alias:c,tips:a}}}i.length>0&&(0,common_2.throwError)({msg:i.join("\n"),filePath:o})}function checkComponentPath(e){const{project:o,miniprogramRoot:t,filePath:a,inputJSON:c}=e;(0,common_1.checkComponentPath)({project:o,root:t,relativePath:path_1.default.posix.relative(t,a),inputJSON:c})}function checkEntranceDeclare(e){const o=e.inputJSON;if(!o.entranceDeclare||!o.entranceDeclare.locationMessage)return;let t=o.pages||[];o.subpackages&&(t=t.concat(o.subpackages.map(e=>e.pages.map(o=>e.root+o))),t=lodash_1.default.flattenDeep(t)),o.subPackages&&(t=t.concat(o.subPackages.map(e=>e.pages.map(o=>e.root+o))),t=lodash_1.default.flattenDeep(t));const a=[],c=o.entranceDeclare.locationMessage.path;void 0===c?a.push(locales_1.default.config.JSON_ENTRANCE_DECLARE_PATH_EMPTY.format([])):t.includes(c)||a.push(locales_1.default.config.JSON_ENTRANCE_DECLARE_PATH_ERR.format([c||"undefined"])),a.length>0&&(0,common_2.throwError)({msg:a.join("\n"),filePath:e.filePath})}function getAppJSONVariableDecalearProperty(e){const{windowPropertWhiteList:o,tabBarPropertyWhiteList:t,tabbarListItemPropertyWhiteList:a}=config_1.jsonVariablePropertyWhiteList;let c=[];return"[object Object]"===Object.prototype.toString.call(e.window)&&(c=c.concat(Object.keys(e.window).filter(e=>o.includes(e)).map(o=>({property:`["window"]["${o}"]`,value:e.window[o]})).filter(e=>e.value.startsWith("@")))),"[object Object]"===Object.prototype.toString.call(e.tabBar)&&(c=c.concat(Object.keys(e.tabBar).filter(e=>t.includes(e)).map(o=>({property:`["tabBar"]["${o}"]`,value:e.tabBar[o]})).filter(e=>e.value.startsWith("@"))),Array.isArray(e.tabBar.list)&&e.tabBar.list.forEach((o,t)=>{c=c.concat(Object.keys(o).filter(e=>a.includes(e)).map(o=>({property:`["tabBar"]["list"][${t}]["${o}"]`,value:e.tabBar.list[t][o]})).filter(e=>e.value.startsWith("@")))})),c}function checkOpenDataContext(e,o){const{project:t,miniprogramRoot:a,filePath:c}=e,{openDataContext:n}=o;if(void 0===n)return;(0,common_2.checkPath)({value:n,tips:'["openDataContext"]',filePath:c});const r=t.stat(a,n);r&&r.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(['["openDataContext"]',locales_1.default.config.DIRECTORY]),filePath:c});const i=path_1.default.posix.join(n,"./index.js"),s=t.stat(a,i);s&&s.isFile||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["openDataContext"]',i),filePath:c}),o.openDataContext=(0,tools_1.normalizePath)(n+"/")}function checkRenderer(e){const{filePath:o,inputJSON:t}=e,{renderer:a,lazyCodeLoading:c}=t;"skyline"===a&&"requiredComponents"!==c&&(0,common_2.throwError)({msg:locales_1.default.config.APP_JSON_SHOULD_SET_LAZYCODELOADING.format("app.json"),filePath:o})}function checkResolveAlias(e){const{filePath:o,inputJSON:t}=e,{resolveAlias:a}=t;if(a){const e=e=>e.includes("//");for(const t in a)(e(t)||e(a[t]))&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_RESOLVE_ALIAS_ILLEGAL.format(t,a[t]),filePath:o}),a[t].startsWith("./")&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_RESOLVE_ALIAS_SHOULD_NOT_START_WITH.format(a[t]),filePath:o}),t.endsWith("/*")&&a[t].endsWith("/*")||(0,common_2.throwError)({msg:locales_1.default.config.JSON_RESOLVE_ALIAS_INCLUDE_STAR.format(t,a[t]),filePath:o})}}exports.checkMainPkgPages=checkMainPkgPages,exports.checkSitemapLocation=checkSitemapLocation,exports.checkSubpackages=checkSubpackages,exports.checkPlugins=checkPlugins,exports.checkNavigateToMiniProgramAppIdList=checkNavigateToMiniProgramAppIdList,exports.checkFunctionalPages=checkFunctionalPages,exports.checkPreloadRule=checkPreloadRule,exports.checkEntryPagePath=checkEntryPagePath,exports.checkTabbarPage=checkTabbarPage,exports.checkMainPkgPageIsInSubpkg=checkMainPkgPageIsInSubpkg,exports.checkMainPkgPluginIsInSubPkg=checkMainPkgPluginIsInSubPkg,exports.checkComponentPath=checkComponentPath,exports.checkEntranceDeclare=checkEntranceDeclare,exports.getAppJSONVariableDecalearProperty=getAppJSONVariableDecalearProperty,exports.checkOpenDataContext=checkOpenDataContext,exports.checkRenderer=checkRenderer,exports.checkResolveAlias=checkResolveAlias;const detailLocationApis={getLocation:!0,onLocationChange:!0,startLocationUpdate:!0,startLocationUpdateBackground:!0};function checkRequiredPrivateInfos(e){const{filePath:o,inputJSON:t}=e,{requiredPrivateInfos:a}=t;if(a){if(a.indexOf("getFuzzyLocation")>=0){const e=[];for(let o=0;o<a.length;o++){const t=a[o];detailLocationApis[t]&&e.push(`'${t}'`)}e.length>0&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_REQUIRED_PRIVATE_INFOS_MUTUALLY_EXCLUSIVE.format("'getFuzzyLocation'",e.join("、")),filePath:o})}}}exports.checkRequiredPrivateInfos=checkRequiredPrivateInfos;
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkRequiredPrivateInfos=exports.checkResolveAlias=exports.checkRenderer=exports.checkOpenDataContext=exports.getAppJSONVariableDecalearProperty=exports.checkEntranceDeclare=exports.checkComponentPath=exports.checkMainPkgPluginIsInSubPkg=exports.checkMainPkgPageIsInSubpkg=exports.checkTabbarPage=exports.checkEntryPagePath=exports.checkPreloadRule=exports.checkFunctionalPages=exports.checkNavigateToMiniProgramAppIdList=exports.checkPlugins=exports.checkSubpackages=exports.checkSitemapLocation=exports.checkMainPkgPages=exports.checkOpenLocationPagePath=exports.checkWorkers=exports.checkTabbar=exports.checkWindow=exports.checkPageExist=void 0;const tslib_1=require("tslib"),lodash_1=tslib_1.__importDefault(require("lodash")),config_1=require("../../../config"),common_1=require("../common"),common_2=require("../../../utils/common"),tools_1=require("../../../utils/tools"),path_1=tslib_1.__importDefault(require("path")),locales_1=tslib_1.__importDefault(require("../../../utils/locales/locales")),schemaValidate_1=require("../../validate/schemaValidate"),projectconfig_1=require("../projectconfig");function checkPageExist(e,o,t){const{miniprogramRoot:a,project:c,filePath:n}=e;c.stat(a,o+".wxml")||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t,o+".wxml"),code:config_1.FILE_NOT_FOUND,filePath:n}),c.stat(a,o+".js")||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t,o+".js"),code:config_1.FILE_NOT_FOUND,filePath:n})}function checkWindow(e){const{inputJSON:o,mode:t}=e;let a=""+e.filePath;o.themeLocation&&(a+=` or ${o.themeLocation}["${t}"]`);const c=[],{window:n}=o;n&&(void 0!==n.navigationBarBackgroundColor&&((0,tools_1.isHexColor)(n.navigationBarBackgroundColor)||c.push(`["window"]["navigationBarBackgroundColor"]: "${n.navigationBarBackgroundColor}" is not hexColor`)),void 0!==n.backgroundColor&&((0,tools_1.isHexColor)(n.backgroundColor)||c.push(`["window"]["backgroundColor"]: "${n.backgroundColor}" is not hexColor`)),c.length>0&&(0,common_2.throwError)({msg:c.join("\n"),filePath:a}))}function checkTabbar(e){const{project:o,miniprogramRoot:t,inputJSON:a,mode:c}=e;let n=""+e.filePath;a.themeLocation&&(n+=` or ${a.themeLocation}["${c}"]`);const{tabBar:r}=a,i=o.attrSync(),{setting:s}=i;if(!r)return;const l=[];r.list.length<s.MinTabbarCount&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_TABBAR_AT_LEAST.format(s.MinTabbarCount),filePath:n}),r.list.length>s.MaxTabbarCount&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_TABBAR_AT_MOST.format(s.MaxTabbarCount),filePath:n});for(let e=0;e<r.list.length;e++){const a=r.list[e],{pagePath:c}=a;if((0,common_2.checkPath)({value:c,tips:`["tabBar"]["list"][${e}]["pagePath"]`,filePath:n}),!c){l.push(locales_1.default.config.JSON_TABBAR_PATH_EMPTY.format(e));continue}c.indexOf("?")>=0&&l.push(locales_1.default.config.JSON_SHOULD_NOT_CONTAIN.format(`["tabBar"]["list"][${e}]["pagePath"]`,"?")),c.indexOf(".")>=0&&l.push(locales_1.default.config.JSON_SHOULD_NOT_CONTAIN.format(`["tabBar"]["list"][${e}]["pagePath"]`,"."));const i=r.list.slice(0,e).findIndex(e=>e.pagePath===c);i>=0&&l.push(locales_1.default.config.JSON_TABBAR_PATH_SAME_WITH_OTHER.format(e,i));const f=[];a.iconPath&&((0,common_2.checkPath)({value:a.iconPath,tips:`["tabBar"]["list"][${e}]["iconPath"]`,filePath:n,checkPathType:common_2.ECheckPathType.TAB_BAR_ICON}),f.push({name:"iconPath",path:a.iconPath})),a.selectedIconPath&&((0,common_2.checkPath)({value:a.selectedIconPath,tips:`["tabBar"]["list"][${e}]["selectedIconPath"]`,filePath:n,checkPathType:common_2.ECheckPathType.TAB_BAR_ICON}),f.push({name:"selectedIconPath",path:a.selectedIconPath})),f.forEach(a=>{const c=o.stat(t,a.path);if(!c)return void l.push(locales_1.default.config.NOT_FOUND.format(`["tabBar"]["list"][${e}]["${a.name}"]: "${a.path}"`));if(c.isDirectory)return void l.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(`["tabBar"]["list"][${e}]["${a.name}"]`,locales_1.default.config.FILE));c.size>1024*s.MaxTabbarIconSize&&l.push(locales_1.default.config.JSON_TABBAR_ICON_MAX_SIZE.format([e,a.name,s.MaxTabbarIconSize]));const n=path_1.default.posix.extname(a.path);config_1.TABBAR_ICON_WHITE_LIST.indexOf(n)<0&&l.push(locales_1.default.config.JSON_TABBAR_ICON_EXT.format([e,a.name,config_1.TABBAR_ICON_WHITE_LIST.join("、")]))})}l.length>0&&(0,common_2.throwError)({msg:l.join("\n"),filePath:n})}function checkWorkers(e){const{project:o,miniprogramRoot:t,filePath:a,inputJSON:c}=e,{workers:n}=c;if(void 0===n)return;const r='["workers"]';""===n&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(r,locales_1.default.config.DIRECTORY),filePath:a});const i=(0,tools_1.getWorkersPath)(n);(0,common_2.checkPath)({value:i,tips:r,filePath:a});const s=o.stat(t,i);s&&s.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([r,locales_1.default.config.DIRECTORY]),filePath:a}),"string"==typeof c.workers?c.workers=(0,tools_1.normalizePath)(c.workers+"/"):c.workers.path=(0,tools_1.normalizePath)(c.workers.path+"/")}function checkOpenLocationPagePath(e){const{filePath:o,inputJSON:t}=e,{openLocationPagePath:a}=t;if(void 0===a)return;const c='["openLocationPagePath"]';(0,common_2.checkPath)({value:a,tips:c,filePath:o}),checkPageExist(e,a,c)}exports.checkPageExist=checkPageExist,exports.checkWindow=checkWindow,exports.checkTabbar=checkTabbar,exports.checkWorkers=checkWorkers,exports.checkOpenLocationPagePath=checkOpenLocationPagePath;const checkMainPkgPages=e=>{const{filePath:o,inputJSON:t}=e,{pages:a}=t;if(!a)return;const c={};for(let t=0;t<a.length;t++){const n=a[t],r=`["pages"][${t}]`;(0,common_2.checkPath)({value:n,tips:r,filePath:o}),c[n]&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_PAGES_REPEAT.format(`"${n}"`,'["pages"]'),filePath:o}),c[n]=!0,checkPageExist(e,n,r)}};function checkSitemapLocation(e){const{filePath:o,inputJSON:t}=e,{sitemapLocation:a}=t;if(void 0===a)return;const{project:c,miniprogramRoot:n}=e,r='["sitemapLocation"]';(0,common_2.checkPath)({value:a,tips:r,filePath:o});const i=c.stat(n,a);i&&!i.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(r,a),filePath:o});".json"!==path_1.default.posix.extname(a)&&(0,common_2.throwError)({msg:locales_1.default.config.EXT_SHOULD_BE_ERROR.format(r,".json"),filePath:o});const s=c.getFile(n,a),l=(0,common_2.checkUTF8)(s,a),f=(0,common_1.checkJSONFormat)(l,a),h=(0,schemaValidate_1.schemaValidate)("sitemap",f);if(h.error.length){const e=h.error.map(e=>"type"===e.errorType||"enum"===e.errorType||"anyOf"===e.errorType?locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([e.errorProperty,e.correctType]):locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([e.requireProperty])).join("\n");(0,common_2.throwError)({msg:e,filePath:a})}}function checkSubpackages(e){const{project:o,miniprogramRoot:t,filePath:a,inputJSON:c}=e;let n='["subPackages"]';c.subpackages&&(n='["subpackages"]',c.subPackages=c.subpackages,delete c.subpackages);const r=[];if(c.subPackages){const i=o.attrSync(),{setting:s}=i;c.subPackages.length>s.MaxSubPackageLimit&&(0,common_2.throwError)({msg:locales_1.default.config.EXCEED_LIMIT.format([n,s.MaxSubPackageLimit]),filePath:a});const l={},f={};for(let i=0;i<c.subPackages.length;i++){const s=c.subPackages[i],h=`${n}[${i}]`;if((0,common_2.checkPath)({value:s.root,tips:`${n}[${i}]["root"]`,filePath:a}),s.root===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${i}]["root"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(s.name){if(s.name===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${i}]["name"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(f[s.name]){r.push(locales_1.default.config.SAME_ITEM.format(h,f[s.name],"name"));continue}f[s.name]=h}if(s.root=(0,tools_1.normalizePath)(s.root+"/"),l[s.root]){r.push(locales_1.default.config.SAME_ITEM.format(h,l[s.root],"root"));continue}l[s.root]=h;const _=o.stat(t,s.root);if(!_){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`${n}[${i}]["root"]`,locales_1.default.config.DIRECTORY]));continue}if(!_.isDirectory){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`${n}[${i}]["root"]`,locales_1.default.config.DIRECTORY]));continue}const p={};for(let o=0,t=s.pages.length;o<t;o++){const t=s.pages[o];(0,common_2.checkPath)({value:t,tips:`${n}[${i}]["pages"][${o}]`,filePath:a});const c=(0,tools_1.normalizePath)(path_1.default.posix.join(s.root,t));p[c]?r.push(locales_1.default.config.JSON_PAGES_REPEAT.format([`"${t}"`,`${n}[${i}]`])):(p[c]=!0,checkPageExist(e,c,`${n}[${i}]["pages"][${o}]`))}}r.length>0&&(0,common_2.throwError)({msg:r.join("\n"),filePath:a});for(let e=0;e<c.subPackages.length;e++){const o=c.subPackages[e];let t=-1;const a="/"+o.root;c.subPackages.forEach((o,c)=>{if(c!==e&&o.root){const e="/"+o.root;0===a.indexOf(e)&&(t=c)}}),-1===t||r.push(locales_1.default.config.JSON_SHOULD_NOT_CONTAIN.format(`${n}[${t}]["root"]`,`${n}[${e}]["root"]`))}r.length>0&&(0,common_2.throwError)({msg:r.join("\n"),filePath:a})}}function checkPlugins(e){const{filePath:o,inputJSON:t,project:a}=e,c=[],n=t.plugins||{},r=(0,projectconfig_1.getProjectConfigJSON)(a);function i(e,o){var t;const{appid:n}=a,i=a.type===config_1.COMPILE_TYPE.miniProgramPlugin;if(i||"dev"!==e.version)if(i)"dev"===e.version&&e.provider!==n&&e.provider!==r.pluginAppid?c.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(o+'["provider"]',`"${null!==(t=r.pluginAppid)&&void 0!==t?t:n}"`)):e.provider===n&&"dev"!==e.version&&c.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(o+'["version"]','"dev"'));else{if("dev"===e.version||"latest"===e.version||/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/.test(e.version)||/^dev-[A-Za-z0-9]+$/.test(e.version))return!0;c.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([o+'["version"]',locales_1.default.config.TRIPLE_NUMBER_DOT]))}else c.push(`${locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(o+'["version"]',"dev")}\n${locales_1.default.config.PLEASE_CHOOSE_PLUGIN_MODE}`)}for(const e in n){i(n[e],`["plugins"]["${e}"]`)}t.subPackages&&t.subPackages.forEach((e,o)=>{if(!e.plugins)return;const t=`["subPackages"][${o}]`;for(const o in e.plugins){i(e.plugins[o],`${t}["plugins"]["${o}"]`)}}),c.length>0&&(0,common_2.throwError)({msg:c.join("\n"),filePath:o})}function checkNavigateToMiniProgramAppIdList(e){const{filePath:o,inputJSON:t,project:a}=e,c=[];if(t.navigateToMiniProgramAppIdList){const e=a.attrSync(),{appType:o=config_1.APP_TYPE.NORMAL,setting:n}=e;if(o!==config_1.APP_TYPE.NATIVE){const e=null==n?void 0:n.NavigateMiniprogramLimit;t.navigateToMiniProgramAppIdList.length>e&&c.push(locales_1.default.config.EXCEED_LIMIT.format('["navigateToMiniProgramAppIdList"]',e))}}c.length>0&&(0,common_2.throwError)({msg:c.join("\n"),filePath:o})}function checkFunctionalPages(e){const{inputJSON:o}=e;if(o.functionalPages&&"object"!==(0,tools_1.getType)(o.functionalPages)){const e='["functionalPages"] 配置需要更新,详见文档: https://developers.weixin.qq.com/miniprogram/dev/framework/plugin/functional-pages.html';o.__warning__?o.__warning__=`${o.__warning__}\n${e}`:o.__warning__=e}}function checkPreloadRule(e,o){const{inputJSON:t,filePath:a}=e,{preloadRule:c,subPackages:n}=t;if(!c||!n)return;const r=[],i={},s={},l={};o.forEach(e=>{i[e.root]=!0,l[e.path]=!0,e.name&&(s[e.name]=!0)});for(const e in c){if(!l[e]&&!e.includes("__plugin__/")){r.push(locales_1.default.config.NOT_FOUND.format(`["preloadRule"]["${e}"]: ${locales_1.default.config.PAGE_PATH}`));continue}const o=c[e];for(let t=0,a=o.packages.length;t<a;t++){let a=o.packages[t];a!==config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT&&(s[a]||(a=(0,tools_1.normalizePath)(a+"/"),i[a]||r.push(locales_1.default.config.NOT_FOUND.format(`["preloadRule"]["${e}"]["packages"][${t}]: ${a}`))))}}r.length>0&&(0,common_2.throwError)({msg:r.join("\n"),filePath:a})}function checkEntryPagePath(e,o){const{inputJSON:t,filePath:a}=e,{entryPagePath:c}=t;if(!c)return;(0,common_2.checkPath)({value:c,tips:'["entryPagePath"]',filePath:a});let n=!1;for(const e of o)if(e.path===c){n=!0;break}n||(0,common_2.throwError)({msg:locales_1.default.config.JSON_ENTRY_PAGE_PATH_NOT_FOUND.format(["pages、subPackages","entryPagePath"]),filePath:a})}function checkTabbarPage(e){const{filePath:o,inputJSON:t}=e,{tabBar:a,pages:c=[]}=t;if(!a)return;const n=[];for(let e=0;e<a.list.length;e++){const o=a.list[e],{pagePath:t}=o;c.indexOf(t)<0&&n.push(`["tabBar"][${e}]["pagePath"]: "${t}" need in ["pages"]`)}n.length>0&&(0,common_2.throwError)({msg:n.join("\n"),filePath:o})}function checkMainPkgPageIsInSubpkg(e){const{filePath:o,inputJSON:t}=e,{subPackages:a,pages:c=[]}=t;if(!a)return;const n=[];for(let e=0;e<a.length;e++){const o=a[e];for(let t=0;t<c.length;t++){const a=c[t];0===a.indexOf(o.root)&&n.push(locales_1.default.config.SHOULD_NOT_IN.format([`["pages"][${t}]: "${a}"`,`["subPackages"][${e}]`]))}}n.length>0&&(0,common_2.throwError)({msg:n.join("\n"),filePath:o})}function checkMainPkgPluginIsInSubPkg(e){const{filePath:o,inputJSON:t}=e,{plugins:a={},subPackages:c}=t,n={},r={},i=[];for(const e in a){const o=a[e],t=`["plugins"]["${e}"]`;n[o.provider]?i.push(locales_1.default.config.SAME_ITEM.format(`["plugins"]["${e}"]`,n[o.provider].tips,"provider")):n[o.provider]=r[e]={provider:o.provider,version:o.version,alias:e,tips:t}}if(c)for(let e=0;e<c.length;e++){const o=c[e];if(o.plugins)for(const t in o.plugins){const a=`["subPackages"][${e}]["plugins"]`,c=o.plugins[t];n[c.provider]?i.push(locales_1.default.config.SAME_ITEM.format(`${a}["${t}"]`,n[c.provider].tips,"provider")):r[t]?i.push(locales_1.default.config.PLUGINS_SAME_ALIAS.format(`${a}["${t}"]`,r[t].tips)):n[c.provider]=r[t]={provider:c.provider,version:c.version,alias:c,tips:a}}}i.length>0&&(0,common_2.throwError)({msg:i.join("\n"),filePath:o})}function checkComponentPath(e){const{project:o,miniprogramRoot:t,filePath:a,inputJSON:c}=e;(0,common_1.checkComponentPath)({project:o,root:t,relativePath:path_1.default.posix.relative(t,a),inputJSON:c})}function checkEntranceDeclare(e){const o=e.inputJSON;if(!o.entranceDeclare||!o.entranceDeclare.locationMessage)return;let t=o.pages||[];o.subpackages&&(t=t.concat(o.subpackages.map(e=>e.pages.map(o=>e.root+o))),t=lodash_1.default.flattenDeep(t)),o.subPackages&&(t=t.concat(o.subPackages.map(e=>e.pages.map(o=>e.root+o))),t=lodash_1.default.flattenDeep(t));const a=[],c=o.entranceDeclare.locationMessage.path;void 0===c?a.push(locales_1.default.config.JSON_ENTRANCE_DECLARE_PATH_EMPTY.format([])):t.includes(c)||a.push(locales_1.default.config.JSON_ENTRANCE_DECLARE_PATH_ERR.format([c||"undefined"])),a.length>0&&(0,common_2.throwError)({msg:a.join("\n"),filePath:e.filePath})}function getAppJSONVariableDecalearProperty(e){const{windowPropertWhiteList:o,tabBarPropertyWhiteList:t,tabbarListItemPropertyWhiteList:a}=config_1.jsonVariablePropertyWhiteList;let c=[];return"[object Object]"===Object.prototype.toString.call(e.window)&&(c=c.concat(Object.keys(e.window).filter(e=>o.includes(e)).map(o=>({property:`["window"]["${o}"]`,value:e.window[o]})).filter(e=>e.value.startsWith("@")))),"[object Object]"===Object.prototype.toString.call(e.tabBar)&&(c=c.concat(Object.keys(e.tabBar).filter(e=>t.includes(e)).map(o=>({property:`["tabBar"]["${o}"]`,value:e.tabBar[o]})).filter(e=>e.value.startsWith("@"))),Array.isArray(e.tabBar.list)&&e.tabBar.list.forEach((o,t)=>{c=c.concat(Object.keys(o).filter(e=>a.includes(e)).map(o=>({property:`["tabBar"]["list"][${t}]["${o}"]`,value:e.tabBar.list[t][o]})).filter(e=>e.value.startsWith("@")))})),c}function checkOpenDataContext(e,o){const{project:t,miniprogramRoot:a,filePath:c}=e,{openDataContext:n}=o;if(void 0===n)return;(0,common_2.checkPath)({value:n,tips:'["openDataContext"]',filePath:c});const r=t.stat(a,n);r&&r.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(['["openDataContext"]',locales_1.default.config.DIRECTORY]),filePath:c});const i=path_1.default.posix.join(n,"./index.js"),s=t.stat(a,i);s&&s.isFile||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["openDataContext"]',i),filePath:c}),o.openDataContext=(0,tools_1.normalizePath)(n+"/")}function checkRenderer(e){const{filePath:o,inputJSON:t}=e,{renderer:a,lazyCodeLoading:c}=t;"skyline"===a&&"requiredComponents"!==c&&(0,common_2.throwError)({msg:locales_1.default.config.APP_JSON_SHOULD_SET_LAZYCODELOADING.format("app.json"),filePath:o})}function checkResolveAlias(e){const{filePath:o,inputJSON:t}=e,{resolveAlias:a}=t;if(a){const e=e=>e.includes("//");for(const t in a)(e(t)||e(a[t]))&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_RESOLVE_ALIAS_ILLEGAL.format(t,a[t]),filePath:o}),a[t].startsWith("./")&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_RESOLVE_ALIAS_SHOULD_NOT_START_WITH.format(a[t]),filePath:o}),t.endsWith("/*")&&a[t].endsWith("/*")||(0,common_2.throwError)({msg:locales_1.default.config.JSON_RESOLVE_ALIAS_INCLUDE_STAR.format(t,a[t]),filePath:o})}}exports.checkMainPkgPages=checkMainPkgPages,exports.checkSitemapLocation=checkSitemapLocation,exports.checkSubpackages=checkSubpackages,exports.checkPlugins=checkPlugins,exports.checkNavigateToMiniProgramAppIdList=checkNavigateToMiniProgramAppIdList,exports.checkFunctionalPages=checkFunctionalPages,exports.checkPreloadRule=checkPreloadRule,exports.checkEntryPagePath=checkEntryPagePath,exports.checkTabbarPage=checkTabbarPage,exports.checkMainPkgPageIsInSubpkg=checkMainPkgPageIsInSubpkg,exports.checkMainPkgPluginIsInSubPkg=checkMainPkgPluginIsInSubPkg,exports.checkComponentPath=checkComponentPath,exports.checkEntranceDeclare=checkEntranceDeclare,exports.getAppJSONVariableDecalearProperty=getAppJSONVariableDecalearProperty,exports.checkOpenDataContext=checkOpenDataContext,exports.checkRenderer=checkRenderer,exports.checkResolveAlias=checkResolveAlias;const detailLocationApis={getLocation:!0,onLocationChange:!0,startLocationUpdate:!0,startLocationUpdateBackground:!0};function checkRequiredPrivateInfos(e){const{filePath:o,inputJSON:t}=e,{requiredPrivateInfos:a}=t;if(a){if(a.indexOf("getFuzzyLocation")>=0){const e=[];for(let o=0;o<a.length;o++){const t=a[o];detailLocationApis[t]&&e.push(`'${t}'`)}e.length>0&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_REQUIRED_PRIVATE_INFOS_MUTUALLY_EXCLUSIVE.format("'getFuzzyLocation'",e.join("、")),filePath:o})}}}exports.checkRequiredPrivateInfos=checkRequiredPrivateInfos;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getAppJSON=exports.getRawAppJSON=exports.checkAppJSON=void 0;const tslib_1=require("tslib"),path_1=
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getAppJSON=exports.getRawAppJSON=exports.checkAppJSON=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),locales_1=tslib_1.__importDefault(require("../../../utils/locales/locales")),projectconfig_1=require("../projectconfig"),common_1=require("../../../utils/common"),config_1=require("../../../config"),common_2=require("../common"),cache_1=require("../../../utils/cache"),lodash_1=require("lodash"),schemaValidate_1=require("../../validate/schemaValidate"),tools_1=require("../../../utils/tools"),theme_1=require("../theme"),reactiveCache_1=require("../reactiveCache"),checkAppFields_1=require("./checkAppFields");function transValidateResult(e){return e.error.map(e=>{if("type"===e.errorType||"enum"===e.errorType||"anyOf"===e.errorType)return locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([e.errorProperty,e.correctType]);{const c=""===e.errorProperty?e.requireProperty:`${e.errorProperty}.${e.requireProperty}`;return locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([c])}}).join("\n")}function checkAppJSON(e){const{inputJSON:c}=e;let{filePath:r}=e;const a=(0,theme_1.getThemeLocation)(e.project);if(!a){const e=(0,checkAppFields_1.getAppJSONVariableDecalearProperty)(c);e.length&&(0,common_1.throwError)({msg:'appJSON["themeLocation"] is required because:\n'+e.map(e=>`"${e.value}" as variable was declared at ${r}:${e.property}`).join("\n"),filePath:r})}let o={light:{},dark:{}};a&&(o=(0,theme_1.checkThemeJSON)(e.project,{themeLocation:a}));const t=(0,theme_1.mergeThemeJSONToAppJSON)(o,c),p=(0,checkAppFields_1.getAppJSONVariableDecalearProperty)(t.appJSONLight);p.length&&(0,common_1.throwError)({msg:p.map(e=>`"${e.value}" as variable was declared at ${r}:${e.property}, but not found at ${a}["light"]`).join("\n"),filePath:r});const i=(0,checkAppFields_1.getAppJSONVariableDecalearProperty)(t.appJSONDark);i.length&&(0,common_1.throwError)({msg:i.map(e=>`"${e.value}" as variable was declared at ${r}:${e.property}, but not found at ${a}["dark"]`).join("\n"),filePath:r});const n=(0,schemaValidate_1.schemaValidate)("app",t.appJSONLight),l=(0,schemaValidate_1.schemaValidate)("app",t.appJSONDark);if(n.warning&&(c.__warning__=locales_1.default.config.INVALID.format(n.warning)),a&&l.warning&&(c.__warning__=locales_1.default.config.INVALID.format(l.warning)),n.error.length){const e=transValidateResult(n);a&&(r+=` or ${a}["light"]`),(0,common_1.throwError)({msg:e,filePath:r})}if(a&&l.error.length){const e=transValidateResult(l);a&&(r+=` or ${a}["dark"]`),(0,common_1.throwError)({msg:e,filePath:r})}const s=Object.assign(Object.assign({},e),{mode:"light",inputJSON:t.appJSONLight}),h=Object.assign(Object.assign({},e),{mode:"dark",inputJSON:t.appJSONDark});(0,checkAppFields_1.checkMainPkgPages)(e),(0,checkAppFields_1.checkSubpackages)(e),(0,checkAppFields_1.checkTabbar)(s),a&&(0,checkAppFields_1.checkTabbar)(h),(0,checkAppFields_1.checkWorkers)(e),(0,checkAppFields_1.checkFunctionalPages)(e),(0,checkAppFields_1.checkOpenLocationPagePath)(e),(0,checkAppFields_1.checkOpenDataContext)(e,c),(0,checkAppFields_1.checkPlugins)(e),(0,checkAppFields_1.checkWindow)(s),a&&(0,checkAppFields_1.checkWindow)(h),(0,checkAppFields_1.checkComponentPath)(e);const _=(0,common_1.getAllPagesInfo)(c);return(0,checkAppFields_1.checkEntryPagePath)(e,_),(0,checkAppFields_1.checkPreloadRule)(e,_),(0,checkAppFields_1.checkTabbarPage)(e),(0,checkAppFields_1.checkMainPkgPageIsInSubpkg)(e),(0,checkAppFields_1.checkMainPkgPluginIsInSubPkg)(e),(0,checkAppFields_1.checkEntranceDeclare)(e),(0,checkAppFields_1.checkRenderer)(e),(0,checkAppFields_1.checkResolveAlias)(e),(0,checkAppFields_1.checkRequiredPrivateInfos)(e),c}exports.checkAppJSON=checkAppJSON,exports.getRawAppJSON=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.RAW_APP_JSON,e=>{const c=(0,projectconfig_1.getProjectConfigJSON)(e),{miniprogramRoot:r=""}=c,a=(0,tools_1.normalizePath)(path_1.default.posix.join(r,"app.json"));e.stat(r,"app.json")||(""===r?(0,common_1.throwError)({msg:locales_1.default.config.NOT_FOUND_IN_ROOT_DIR.format(a),code:config_1.FILE_NOT_FOUND,filePath:a}):(0,common_1.throwError)({msg:locales_1.default.config.MINIPROGRAM_APP_JSON_NOT_FOUND.format(r,"app.json"),code:config_1.FILE_NOT_FOUND,filePath:a}));const o=e.getFile(r,"app.json");return(0,common_2.checkJSONFormat)((0,common_1.checkUTF8)(o,a),a)}),exports.getAppJSON=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.APP_JSON,e=>{const c=(0,lodash_1.cloneDeep)((0,exports.getRawAppJSON)(e)),r=(0,projectconfig_1.getProjectConfigJSON)(e),{miniprogramRoot:a=""}=r;return checkAppJSON({project:e,miniprogramRoot:a,filePath:(0,tools_1.normalizePath)(path_1.default.posix.join(a,"app.json")),inputJSON:c}),c});
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getExtJSON=void 0;const tslib_1=require("tslib"),cache_1=require("../../../utils/cache"),common_1=require("../common"),common_2=require("../../../utils/common"),lodash_1=require("lodash"),tools_1=require("../../../utils/tools"),path_1=
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getExtJSON=void 0;const tslib_1=require("tslib"),cache_1=require("../../../utils/cache"),common_1=require("../common"),common_2=require("../../../utils/common"),lodash_1=require("lodash"),tools_1=require("../../../utils/tools"),path_1=tslib_1.__importDefault(require("path")),projectconfig_1=require("../projectconfig"),locales_1=tslib_1.__importDefault(require("../../../utils/locales/locales")),schemaValidate_1=require("../../validate/schemaValidate"),theme_1=require("../theme"),checkAppFields_1=require("./checkAppFields"),reactiveCache_1=require("../reactiveCache");function checkExtPages(e){const{project:o,inputJSON:r,filePath:t,miniprogramRoot:c}=e,{extPages:a}=r;if(a)for(const e in a){const r=a[e];if(r){r.navigationBarBackgroundColor&&!(0,tools_1.isHexColor)(r.navigationBarBackgroundColor)&&(0,common_2.throwError)({msg:`["extPages"]["${e}"]["navigationBarBackgroundColor"]: "${r.navigationBarBackgroundColor}" is not hexColor`,filePath:t}),r.backgroundColor&&!(0,tools_1.isHexColor)(r.backgroundColor)&&(0,common_2.throwError)({msg:`["extPages"]["${e}"]["backgroundColor"]: "${r.backgroundColor}" is not hexColor`,filePath:t});try{(0,checkAppFields_1.checkComponentPath)({project:o,miniprogramRoot:c,inputJSON:r,filePath:e+".json"})}catch(o){(0,common_2.throwError)({msg:`["extPages"]["${e}"]${o.message}`,filePath:t})}}}}exports.getExtJSON=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.EXT_JSON,e=>{const o=(0,projectconfig_1.getProjectConfigJSON)(e),{miniprogramRoot:r=""}=o,t=e.attrSync(),c=(0,tools_1.normalizePath)(path_1.default.posix.join(r,"ext.json"));if(!t||!t.platform)return e.stat(r,"ext.json")?{__warning__:locales_1.default.config.EXT_JSON_INVALID.format(e.appid,"https://developers.weixin.qq.com/miniprogram/dev/devtools/ext.html")}:void 0;if(!e.stat(r,"ext.json"))return;const a=e.getFile(r,"ext.json"),i=(0,common_1.checkJSONFormat)((0,common_2.checkUTF8)(a,c),c);if(!i.extEnable)return{};const n=(0,theme_1.getThemeLocation)(e);let l={};n&&(l=(0,theme_1.checkThemeJSON)(e,{themeLocation:n}));const s=(0,theme_1.mergeThemeJSONToAppJSON)(l,i),p=(0,schemaValidate_1.schemaValidate)("ext",s.appJSONLight),_=(0,schemaValidate_1.schemaValidate)("ext",s.appJSONDark);if(p.warning&&(i.__warning__=locales_1.default.config.INVALID.format(p.warning)),_.warning&&(i.__warning__=locales_1.default.config.INVALID.format(_.warning)),p.error.length||_.error.length){const e=p.error.map(e=>"type"===e.errorType||"enum"===e.errorType||"anyOf"===e.errorType?locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([e.errorProperty,e.correctType]):locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([e.requireProperty])),o=_.error.map(e=>"type"===e.errorType||"enum"===e.errorType||"anyOf"===e.errorType?locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([e.errorProperty,e.correctType]):locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([e.requireProperty])),r=e.concat(o).join("\n");(0,common_2.throwError)({msg:r,filePath:c})}i.extAppid||(0,common_2.throwError)({msg:""+locales_1.default.config.EXT_APPID_SHOULD_NOT_BE_EMPTY,filePath:c});const h={filePath:c,project:e,miniprogramRoot:r,inputJSON:i},m=(0,lodash_1.cloneDeep)(h);m.inputJSON=s.appJSONLight,m.mode="light";const g=(0,lodash_1.cloneDeep)(h);return g.inputJSON=s.appJSONDark,g.mode="dark",(0,checkAppFields_1.checkMainPkgPages)(h),(0,checkAppFields_1.checkMainPkgPages)(h),(0,checkAppFields_1.checkSubpackages)(h),(0,checkAppFields_1.checkTabbar)(m),(0,checkAppFields_1.checkTabbar)(g),(0,checkAppFields_1.checkWorkers)(h),(0,checkAppFields_1.checkFunctionalPages)(h),(0,checkAppFields_1.checkOpenLocationPagePath)(h),(0,checkAppFields_1.checkPlugins)(h),(0,checkAppFields_1.checkWindow)(m),(0,checkAppFields_1.checkWindow)(g),(0,checkAppFields_1.checkComponentPath)(h),checkExtPages(h),i});
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getAppJSON=void 0;const tslib_1=require("tslib"),path_1=
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getAppJSON=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),cache_1=require("../../../utils/cache"),lodash_1=require("lodash"),getAppJSON_1=require("./getAppJSON"),getExtJSON_1=require("./getExtJSON"),projectconfig_1=require("../projectconfig"),common_1=require("../../../utils/common"),locales_1=tslib_1.__importDefault(require("../../../utils/locales/locales")),theme_1=require("../theme"),reactiveCache_1=require("../reactiveCache"),tools_1=require("../../../utils/tools");function mergeExtJSON(e,t){if(t)for(const o in t)if("__warning__"!==o){if("extPages"!==o){if("plugins"===o||"supportedMaterials"===o){e[o]=t[o];continue}"object"===(0,tools_1.getType)(t[o])?"object"!==(0,tools_1.getType)(e[o])?e[o]=Object.assign({},t[o]):e[o]=Object.assign({},e[o]||{},t[o]):e[o]=t[o]}}else e.__warning__=e.__warning__?`${e.__warning__}、${t.__warning__}`:t.__warning__}exports.getAppJSON=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.COMPILED_APP_JSON,e=>{const t=(0,projectconfig_1.getProjectConfigJSON)(e),{miniprogramRoot:o=""}=t;let i=(0,getAppJSON_1.getAppJSON)(e);const r=(0,getExtJSON_1.getExtJSON)(e);if(r&&(i=(0,lodash_1.cloneDeep)(i),mergeExtJSON(i,r),r.extEnable))try{const t=(0,theme_1.getThemeLocation)(e);let r={};t&&(r=(0,theme_1.checkThemeJSON)(e,{themeLocation:t}));const _=(0,theme_1.mergeThemeJSONToAppJSON)(r,i);(0,getAppJSON_1.checkAppJSON)({project:e,miniprogramRoot:o,inputJSON:_.appJSONLight,filePath:path_1.default.posix.join(o,"app.json")}),(0,getAppJSON_1.checkAppJSON)({project:e,miniprogramRoot:o,inputJSON:_.appJSONDark,filePath:path_1.default.posix.join(o,"app.json")})}catch(e){(0,common_1.throwError)({msg:e.message,code:e.code,filePath:`app.json ${locales_1.default.config.OR} ext.json`})}return i});
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
package/dist/core/json/common.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.transValidateResult=exports.getPageJSONVariableDecalearProperty=exports.checkComponentPath=exports.getUseExtendLib=exports.checkFilePathIsInIndependentSubpackage=exports.checkPagePathIsInIndependentSubpackage=exports.checkPagePathIsInSubPackage=exports.checkJSONFormat=void 0;const tslib_1=require("tslib"),tools_1=require("../../utils/tools"),path_1=
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.transValidateResult=exports.getPageJSONVariableDecalearProperty=exports.checkComponentPath=exports.getUseExtendLib=exports.checkFilePathIsInIndependentSubpackage=exports.checkPagePathIsInIndependentSubpackage=exports.checkPagePathIsInSubPackage=exports.checkJSONFormat=void 0;const tslib_1=require("tslib"),tools_1=require("../../utils/tools"),path_1=tslib_1.__importDefault(require("path")),locales_1=tslib_1.__importDefault(require("../../utils/locales/locales")),common_1=require("../../utils/common"),config_1=require("../../config"),lodash_1=require("lodash"),getAppJSON_1=require("./app/getAppJSON");function checkJSONFormat(e,t){let o={};e||(0,common_1.throwError)({filePath:t,msg:"Empty file is NOT a valid json file",code:config_1.JSON_PARSE_ERR});try{o=JSON.parse(e)}catch(o){const n=(0,tools_1.formatJSONParseErr)({filePath:t,data:e,error:o});(0,common_1.throwError)({filePath:t,msg:n,code:config_1.JSON_PARSE_ERR})}return o}function checkPagePathIsInSubPackage(e,t){const{subPackages:o,subpackages:n}=e;if(o||n)for(const e of o||n)if(0===t.indexOf(e.root))return e}function checkPagePathIsInIndependentSubpackage(e,t){const o=checkPagePathIsInSubPackage(e,t);if(o&&!0===o.independent)return o}function checkFilePathIsInIndependentSubpackage(e,t){const{subPackages:o}=e;if(o)for(const e of o)if(!0===e.independent){const o=e.root.replace(/^\//,"");if(0===t.indexOf(o))return o}}function checkNodeModulesFile(e,t,o,n){let a=path_1.default.posix.join(o,"index")+".json",r=e.stat(t,a);return(null==r?void 0:r.isFile)?a:(a=path_1.default.posix.join(o,n)+".json",r=e.stat(t,a),(null==r?void 0:r.isFile)?a:(a=o+".json",r=e.stat(t,a),(null==r?void 0:r.isFile)?a:""))}function resolveComponentPath(e,t,o,n){n=(0,tools_1.normalizePath)(n);let a=path_1.default.posix.join(o,n)+".json";const r=e.stat(t,a);if(null==r?void 0:r.isFile)return n;let i=o.split(path_1.default.posix.sep);for(i=i.filter(e=>!!e),a="";i.length;){if(a=checkNodeModulesFile(e,t,path_1.default.posix.join(i.join(path_1.default.posix.sep),"miniprogram_npm",n),n),a)break;i.pop()}if(!a){a=checkNodeModulesFile(e,t,path_1.default.posix.join("miniprogram_npm",n),n)}return a&&(/\.json$/.test(a)&&(a=a.substring(0,a.length-5)),a=path_1.default.posix.relative(o,a)),a}exports.checkJSONFormat=checkJSONFormat,exports.checkPagePathIsInSubPackage=checkPagePathIsInSubPackage,exports.checkPagePathIsInIndependentSubpackage=checkPagePathIsInIndependentSubpackage,exports.checkFilePathIsInIndependentSubpackage=checkFilePathIsInIndependentSubpackage;const innerCheckComponentPath=e=>{const{value:t,tips:o,project:n,root:a,relativePath:r}=e,i=path_1.default.posix.join(a,r);if(t.startsWith("plugin://")||t.startsWith("plugin-private://"))return t;const s=(0,exports.getUseExtendLib)(n,r);if(t.startsWith("/")){if(s.length){const e=s.map(e=>"/miniprogram_npm/"+e);let o=!1;for(const n of e)if(t.startsWith(n)){o=!0;break}if(o)return t}if(n.stat(a,t+".json"))return t;if(n.stat(a,t+"/index.json"))return t+"/index";(0,common_1.throwError)({msg:locales_1.default.config.NOT_FOUND.format(o),filePath:i})}if(t.startsWith(".")){if(t.startsWith("../")){const e=t.replace(/^(\.\.\/)+/,"");if(n.stat(a,path_1.default.posix.join(`/${e}.json`)))return t;if(n.stat(a,path_1.default.posix.join(`/${e}/index.json`)))return t+"/index"}if(n.stat(a,path_1.default.posix.join(path_1.default.posix.dirname(r),t+".json")))return t;if(n.stat(a,path_1.default.posix.join(path_1.default.posix.dirname(r),t+"/index.json")))return t+"/index";(0,common_1.throwError)({msg:locales_1.default.config.NOT_FOUND.format(`${o}: "${t}"`),filePath:i})}for(const e of s)if(t.startsWith(e))return"miniprogram-element"===e?`/miniprogram_npm/${e}/index`:t.replace(e,"/miniprogram_npm/"+e);const c=resolveComponentPath(n,a,path_1.default.posix.dirname(r),t);return c||(0,common_1.throwError)({msg:locales_1.default.config.NOT_FOUND.format(`${o}: "${t}"`),filePath:i}),c.startsWith(".")?c:"./"+c},getUseExtendLib=(e,t)=>{var o;const n=(0,getAppJSON_1.getRawAppJSON)(e);let a=[];if("[object Object]"===Object.prototype.toString.call(n.useExtendedLib)){const e=Object.keys(config_1.extendedLibMap),t=Object.keys(n.useExtendedLib).filter(t=>!e.includes(t));t.length&&(0,common_1.throwError)({msg:t.join(", ")+' is not allowed in ["useExtendedLib"]',filePath:"app.json"}),a=Object.keys(n.useExtendedLib||{}).filter(e=>n.useExtendedLib[e]).map(e=>config_1.extendedLibMap[e].packages),a=(0,lodash_1.flattenDeep)(a)}const r=checkPagePathIsInSubPackage(n,t);if((null==r?void 0:r.useExtendedLib)&&"[object Object]"===Object.prototype.toString.call(r.useExtendedLib)){const e=Object.keys(config_1.extendedLibMap),t=Object.keys(r.useExtendedLib).filter(t=>!e.includes(t));t.length&&(0,common_1.throwError)({msg:`${t.join(", ")} is not allowed in subPackages[${null===(o=n.subPackages)||void 0===o?void 0:o.indexOf(r)}]["useExtendedLib"]`,filePath:"app.json"});const i=Object.keys(r.useExtendedLib||{}).filter(e=>r.useExtendedLib[e]).map(e=>config_1.extendedLibMap[e].packages);a=(0,lodash_1.uniq)(a.concat((0,lodash_1.flattenDeep)(i)))}return a};exports.getUseExtendLib=getUseExtendLib;const checkComponentPath=e=>{const{project:t,root:o,relativePath:n,inputJSON:a}=e,{usingComponents:r,componentGenerics:i}=a;if(r)for(const e in r){const a=r[e]||"";r[e]=innerCheckComponentPath({tips:`["usingComponents"]["${e}"]`,value:a,project:t,root:o,relativePath:n})}if(i)for(const e in i){const a="object"==typeof i[e],r=a?i[e].default:i[e];if(!r||"string"!=typeof r)continue;const s=innerCheckComponentPath({tips:`["componentGenerics"]["${e}"]`,value:r,project:t,root:o,relativePath:n});a?i[e].default=s:i[e]=s}};function getPageJSONVariableDecalearProperty(e){const{windowPropertWhiteList:t}=config_1.jsonVariablePropertyWhiteList;let o=[];return"[object Object]"===Object.prototype.toString.call(e)&&(o=o.concat(Object.keys(e).filter(e=>t.includes(e)).map(t=>({property:`["${t}"]`,value:e[t]})).filter(e=>e.value.startsWith("@")))),o}function transValidateResult(e){return e.error.map(e=>"type"===e.errorType||"enum"===e.errorType||"anyOf"===e.errorType?locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([e.errorProperty,e.correctType]):locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([e.requireProperty])).join("\n")}exports.checkComponentPath=checkComponentPath,exports.getPageJSONVariableDecalearProperty=getPageJSONVariableDecalearProperty,exports.transValidateResult=transValidateResult;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
package/dist/core/json/game.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),cache_1=require("../../utils/cache"),common_1=require("../../utils/common"),config_1=require("../../config"),tools_1=require("../../utils/tools"),path_1=(0,tslib_1.__importDefault)(require("path")),locales_1=(0,tslib_1.__importDefault)(require("../../utils/locales/locales")),projectconfig_1=require("./projectconfig"),common_2=require("./common"),schemaValidate_1=require("../validate/schemaValidate"),reactiveCache_1=require("./reactiveCache"),signatureValidate=require("../validate/signaturejson"),gamePluginJSONValidate=require("../validate/gamepluginjson");function isPluginMode(o){return o.type===config_1.COMPILE_TYPE.miniGamePlugin}function checkLocalPlugin(o,t){const{project:e,root:a,filePath:r}=o,i=t.path;let n=e.stat(a,i);n&&n.isDirectory||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t.tips+'["path"]',locales_1.default.config.DIRECTORY),filePath:r});const c=path_1.default.posix.join(i,"signature.json");n=e.stat(a,c);let _=(0,tools_1.normalizePath)(path_1.default.posix.join(a,c));n||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t.tips+'["path"]',_),filePath:r,code:config_1.FILE_NOT_FOUND});let s=e.getFile(a,c),l=(0,common_1.checkUTF8)(s,_);const f=(0,common_2.checkJSONFormat)(l,_);try{signatureValidate.check(f)}catch(o){(0,common_1.throwError)({msg:"signature.json"+o.message,filePath:_})}f.provider!==t.provider&&(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format('["provider"]',`"${t.provider}"`),filePath:_});for(let o=0;o<f.signature.length;o++){const t=f.signature[o];(0,common_1.checkPath)({value:t.path,tips:`["signature"][${o}]["path"]`,filePath:_});const r=path_1.default.posix.join(i,t.path);n=e.stat(a,r),n&&n.isFile||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["signature"][${o}]["path"]`,r),filePath:_,code:config_1.FILE_NOT_FOUND});const c=e.getFile(a,r),s=(0,tools_1.generateMD5)(c);s!==t.md5&&(0,common_1.throwError)({msg:locales_1.default.config.GAME_PLUGIN_SIGNATURE_MD5_NOT_MATCH_CONTENT.format(path_1.default.posix.join(i,t.path),s,t.md5),code:config_1.GAME_PLUGIN_LIB_MD5_NOT_MATCH,filePath:_})}const m=path_1.default.posix.join(i,"plugin.json");n=e.stat(a,m),_=(0,tools_1.normalizePath)(path_1.default.posix.join(a,m)),n||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t.tips+'["path"]',_),code:config_1.FILE_NOT_FOUND,filePath:r}),s=e.getFile(a,m),l=(0,common_1.checkUTF8)(s,_);const g=(0,common_2.checkJSONFormat)(l,_);try{gamePluginJSONValidate.check(g)}catch(o){(0,common_1.throwError)({msg:"plugin.json"+o.message,filePath:_})}g.main&&((0,common_1.checkPath)({value:g.main,tips:'["main"]',filePath:_}),n=e.stat(a,path_1.default.posix.join(i,g.main)),n||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["main"]',""+g.main),filePath:_,code:config_1.FILE_NOT_FOUND}))}function checkPluginPath(o,t){const{subPackages:e}=t,a=[],r=(o,t,e)=>{const{plugins:r}=o;if(r)for(const o in r){if(!r.hasOwnProperty(o))continue;const i=r[o];i&&i.path&&a.push({alias:o,version:i.version||"",provider:i.provider||"",tips:`${e}["plugins"]["${o}"]`,path:(0,tools_1.normalizePath)(path_1.default.posix.join(t,i.path))})}};if(r(t,"",""),e)for(let o=0;o<e.length;o++){const t=e[o];r(t,t.root||"",`["subPackages"][${o}]`)}if(!(a.length<=0))for(const t of a)checkLocalPlugin(o,t)}function checkPlugins(o,t){const{project:e,filePath:a}=o,r=[],i=t.plugins||{};function n(o,t){const i=e.appid,n=isPluginMode(e);if(n||"dev"!==o.version)if(n&&"dev"===o.version&&o.provider!==i)r.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t+'["provider"]',i));else if("dev"!==o.version||"string"!=typeof o.path){if("dev"===o.version||"latest"===o.version||/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/.test(o.version)||/^dev-[A-Za-z0-9]+$/.test(o.version))return o.path&&(0,common_1.checkPath)({value:o.path,tips:t+'["path"]',filePath:a}),!0;r.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t+'["version"]',locales_1.default.config.TRIPLE_NUMBER_DOT))}else r.push(locales_1.default.config.GAME_DEV_PLUGIN_SHOULD_NOT_USE_LOCAL_PATH.format(t,t+'["path"]'));else r.push(`${locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(t+'["version"]',"dev")}\n${locales_1.default.config.PLEASE_CHOOSE_PLUGIN_MODE}`)}const c={},_={};for(const o in i){if(!i.hasOwnProperty(o))continue;const t=i[o];n(t,`["plugins"]["${o}"]`)&&(c[t.provider]?r.push(locales_1.default.config.SAME_ITEM.format(`["plugins"]["${o}"]`,c[t.provider].tips,"provider")):c[t.provider]=_[o]={provider:t.provider,version:t.version,alias:o,path:t.path||"",tips:`["plugins"]["${o}"]`})}const s=t.subPackages||t.subpackages;if(Array.isArray(s))for(let o=0,t=s.length;o<t;o++){const t=s[o];if(!t.plugins)continue;const e=`["subPackages"][${o}]["plugins"]`;for(const o in t.plugins){const a=t.plugins[o],i=`${e}["${o}"]`;n(a,i)&&(c[a.provider]?r.push(locales_1.default.config.SAME_ITEM.format(i,c[a.provider].tips,"provider")):_[o]?r.push(locales_1.default.config.PLUGINS_SAME_ALIAS.format(i,_[o].tips)):c[a.provider]=_[o]={provider:a.provider,version:a.version,alias:o,path:a.path||"",tips:i})}}r.length>0&&(0,common_1.throwError)({msg:r.join("\n"),filePath:a})}function checkSubpackages(o,t){const{root:e,project:a,filePath:r}=o,i=[];let n='["subPackages"]';if(t.subpackages&&(n='["subpackages"]',t.subPackages=t.subpackages,delete t.subpackages),t.subPackages){const o=a.attrSync(),{setting:c}=o;t.subPackages.length>c.MaxSubPackageLimit&&(0,common_1.throwError)({msg:locales_1.default.config.EXCEED_LIMIT.format([n,c.MaxSubPackageLimit]),filePath:r});const _={},s={};for(let o=0,r=t.subPackages.length;o<r;o++){const r=t.subPackages[o];if(r.name){if(r.name===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){i.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["name"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(r.name===config_1.MINI_GAME_MAIN_PACKAGE_ROOT){i.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["name"]`,config_1.MINI_GAME_MAIN_PACKAGE_ROOT));continue}_[r.name]&&i.push(locales_1.default.config.SAME_ITEM.format(`${n}[${o}]`,_[r.name],"name")),_[r.name]=`${n}[${o}]`}if(r.root===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){i.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(r.root===config_1.MINI_GAME_MAIN_PACKAGE_ROOT){i.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,config_1.MINI_GAME_MAIN_PACKAGE_ROOT));continue}if(r.root===config_1.MINI_GAME_WORKERS_PACKAGE_ROOT){i.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,config_1.MINI_GAME_WORKERS_PACKAGE_ROOT));continue}if(r.root==="/"+config_1.MINI_GAME_WORKERS_PACKAGE_ROOT){i.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,"/"+config_1.MINI_GAME_WORKERS_PACKAGE_ROOT));continue}if(r.root.startsWith(".")){i.push(locales_1.default.config.JSON_SHOULD_NOT_START_WITH.format(`${n}[${o}]["root"]`,"."));continue}if(r.root.startsWith("__wx__")){i.push(locales_1.default.config.JSON_SHOULD_NOT_START_WITH.format(`${n}[${o}]["root"]`,"__wx__"));continue}r.root.startsWith("/")||(r.root=(0,tools_1.normalizePath)("/"+r.root)),/\.js$/.test(r.root)?r.root=(0,tools_1.normalizePath)(r.root):r.root=(0,tools_1.normalizePath)(r.root+"/"),s[r.root]&&i.push(locales_1.default.config.SAME_ITEM.format(`${n}[${o}]`,s[r.root],"root")),s[r.root]=`${n}[${o}]`;const c=a.stat(e,r.root);if(c){if(c.isDirectory){/\/$/.test(r.root)||(r.root+="/");const t=path_1.default.posix.join(r.root,"./game.js"),c=a.stat(e,t);c&&c.isFile||i.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`${n}[${o}]["root"]`,t))}}else i.push(locales_1.default.config.JSON_CONTENT_NOT_FOUND.format(`${n}[${o}]["root"]`))}}i.length>0&&(0,common_1.throwError)({msg:i.join("\n"),filePath:r})}function checkLoadingImageUrl(o,t){const{project:e,root:a,filePath:r}=o,{loadingImageInfo:i}=t;if(!i)return;(0,common_1.checkPath)({tips:'["loadingImageInfo"]["path"]',value:i.path,filePath:r});const n=e.stat(a,i.path);n&&n.isFile||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_NOT_FOUND.format(`["loadingImageInfo"]["path"]: "${i.path}"`),filePath:r}),i.progressBarColor&&!(0,tools_1.isHexColor)(i.progressBarColor)&&(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(`["loadingImageInfo"]["progressBarColor"]: "${i.progressBarColor}"`,"HexColor"),filePath:r})}function checkWorkers(o,t){const{project:e,root:a,filePath:r}=o,{workers:i}=t;if(void 0===i)return;const n=(0,tools_1.getWorkersPath)(i);(0,common_1.checkPath)({tips:'["workers"]',value:n,filePath:r});const c=e.stat(a,n);c&&!c.isFile||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(['["workers"]',locales_1.default.config.DIRECTORY]),filePath:r})}function checkOpenDataContext(o,t){const{project:e,root:a,filePath:r}=o,{openDataContext:i}=t;if(void 0===i)return;(0,common_1.checkPath)({value:i,tips:'["openDataContext"]',filePath:r});const n=e.stat(a,i);n&&n.isDirectory||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(['["openDataContext"]',locales_1.default.config.DIRECTORY]),filePath:r});const c=path_1.default.posix.join(i,"./index.js"),_=e.stat(a,c);_&&_.isFile||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["openDataContext"]',c),filePath:r}),t.openDataContext=(0,tools_1.normalizePath)(i+"/")}function checkGameJSON(o){const{project:t,root:e,filePath:a}=o;t.stat(e,"game.json")||(0,common_1.throwError)({msg:locales_1.default.config.FILE_NOT_FOUND.format(path_1.default.posix.join(a)),filePath:a,code:config_1.FILE_NOT_FOUND});const r=t.getFile(e,"game.json"),i=(0,common_2.checkJSONFormat)((0,common_1.checkUTF8)(r,a),a),n=(0,schemaValidate_1.schemaValidate)("game",i);if(n.warning&&(i.__warning__=locales_1.default.config.INVALID.format(n.warning)),n.error.length){const o=n.error.map(o=>"type"===o.errorType||"enum"===o.errorType||"anyOf"===o.errorType?locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([o.errorProperty,o.correctType]):locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([o.requireProperty])).join("\n");(0,common_1.throwError)({msg:o,filePath:a})}return checkOpenDataContext(o,i),checkPlugins(o,i),checkSubpackages(o,i),checkPluginPath(o,i),checkLoadingImageUrl(o,i),checkWorkers(o,i),i}const getGameJSON=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.GAME_JSON,o=>{const t=(0,projectconfig_1.getProjectConfigJSON)(o).miniprogramRoot||"";return checkGameJSON({project:o,root:t,filePath:(0,tools_1.normalizePath)(path_1.default.posix.join(t,"game.json"))})});exports.default=getGameJSON;
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),cache_1=require("../../utils/cache"),common_1=require("../../utils/common"),config_1=require("../../config"),tools_1=require("../../utils/tools"),path_1=tslib_1.__importDefault(require("path")),locales_1=tslib_1.__importDefault(require("../../utils/locales/locales")),projectconfig_1=require("./projectconfig"),common_2=require("./common"),schemaValidate_1=require("../validate/schemaValidate"),reactiveCache_1=require("./reactiveCache"),signatureValidate=require("../validate/signaturejson"),gamePluginJSONValidate=require("../validate/gamepluginjson");function isPluginMode(o){return o.type===config_1.COMPILE_TYPE.miniGamePlugin}function checkLocalPlugin(o,t){const{project:e,root:a,filePath:r}=o,i=t.path;let n=e.stat(a,i);n&&n.isDirectory||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t.tips+'["path"]',locales_1.default.config.DIRECTORY),filePath:r});const c=path_1.default.posix.join(i,"signature.json");n=e.stat(a,c);let _=(0,tools_1.normalizePath)(path_1.default.posix.join(a,c));n||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t.tips+'["path"]',_),filePath:r,code:config_1.FILE_NOT_FOUND});let s=e.getFile(a,c),l=(0,common_1.checkUTF8)(s,_);const f=(0,common_2.checkJSONFormat)(l,_);try{signatureValidate.check(f)}catch(o){(0,common_1.throwError)({msg:"signature.json"+o.message,filePath:_})}f.provider!==t.provider&&(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format('["provider"]',`"${t.provider}"`),filePath:_});for(let o=0;o<f.signature.length;o++){const t=f.signature[o];(0,common_1.checkPath)({value:t.path,tips:`["signature"][${o}]["path"]`,filePath:_});const r=path_1.default.posix.join(i,t.path);n=e.stat(a,r),n&&n.isFile||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["signature"][${o}]["path"]`,r),filePath:_,code:config_1.FILE_NOT_FOUND});const c=e.getFile(a,r),s=(0,tools_1.generateMD5)(c);s!==t.md5&&(0,common_1.throwError)({msg:locales_1.default.config.GAME_PLUGIN_SIGNATURE_MD5_NOT_MATCH_CONTENT.format(path_1.default.posix.join(i,t.path),s,t.md5),code:config_1.GAME_PLUGIN_LIB_MD5_NOT_MATCH,filePath:_})}const m=path_1.default.posix.join(i,"plugin.json");n=e.stat(a,m),_=(0,tools_1.normalizePath)(path_1.default.posix.join(a,m)),n||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t.tips+'["path"]',_),code:config_1.FILE_NOT_FOUND,filePath:r}),s=e.getFile(a,m),l=(0,common_1.checkUTF8)(s,_);const g=(0,common_2.checkJSONFormat)(l,_);try{gamePluginJSONValidate.check(g)}catch(o){(0,common_1.throwError)({msg:"plugin.json"+o.message,filePath:_})}g.main&&((0,common_1.checkPath)({value:g.main,tips:'["main"]',filePath:_}),n=e.stat(a,path_1.default.posix.join(i,g.main)),n||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["main"]',""+g.main),filePath:_,code:config_1.FILE_NOT_FOUND}))}function checkPluginPath(o,t){const{subPackages:e}=t,a=[],r=(o,t,e)=>{const{plugins:r}=o;if(r)for(const o in r){if(!r.hasOwnProperty(o))continue;const i=r[o];i&&i.path&&a.push({alias:o,version:i.version||"",provider:i.provider||"",tips:`${e}["plugins"]["${o}"]`,path:(0,tools_1.normalizePath)(path_1.default.posix.join(t,i.path))})}};if(r(t,"",""),e)for(let o=0;o<e.length;o++){const t=e[o];r(t,t.root||"",`["subPackages"][${o}]`)}if(!(a.length<=0))for(const t of a)checkLocalPlugin(o,t)}function checkPlugins(o,t){const{project:e,filePath:a}=o,r=[],i=t.plugins||{};function n(o,t){const i=e.appid,n=isPluginMode(e);if(n||"dev"!==o.version)if(n&&"dev"===o.version&&o.provider!==i)r.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t+'["provider"]',i));else if("dev"!==o.version||"string"!=typeof o.path){if("dev"===o.version||"latest"===o.version||/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/.test(o.version)||/^dev-[A-Za-z0-9]+$/.test(o.version))return o.path&&(0,common_1.checkPath)({value:o.path,tips:t+'["path"]',filePath:a}),!0;r.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t+'["version"]',locales_1.default.config.TRIPLE_NUMBER_DOT))}else r.push(locales_1.default.config.GAME_DEV_PLUGIN_SHOULD_NOT_USE_LOCAL_PATH.format(t,t+'["path"]'));else r.push(`${locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(t+'["version"]',"dev")}\n${locales_1.default.config.PLEASE_CHOOSE_PLUGIN_MODE}`)}const c={},_={};for(const o in i){if(!i.hasOwnProperty(o))continue;const t=i[o];n(t,`["plugins"]["${o}"]`)&&(c[t.provider]?r.push(locales_1.default.config.SAME_ITEM.format(`["plugins"]["${o}"]`,c[t.provider].tips,"provider")):c[t.provider]=_[o]={provider:t.provider,version:t.version,alias:o,path:t.path||"",tips:`["plugins"]["${o}"]`})}const s=t.subPackages||t.subpackages;if(Array.isArray(s))for(let o=0,t=s.length;o<t;o++){const t=s[o];if(!t.plugins)continue;const e=`["subPackages"][${o}]["plugins"]`;for(const o in t.plugins){const a=t.plugins[o],i=`${e}["${o}"]`;n(a,i)&&(c[a.provider]?r.push(locales_1.default.config.SAME_ITEM.format(i,c[a.provider].tips,"provider")):_[o]?r.push(locales_1.default.config.PLUGINS_SAME_ALIAS.format(i,_[o].tips)):c[a.provider]=_[o]={provider:a.provider,version:a.version,alias:o,path:a.path||"",tips:i})}}r.length>0&&(0,common_1.throwError)({msg:r.join("\n"),filePath:a})}function checkSubpackages(o,t){const{root:e,project:a,filePath:r}=o,i=[];let n='["subPackages"]';if(t.subpackages&&(n='["subpackages"]',t.subPackages=t.subpackages,delete t.subpackages),t.subPackages){const o=a.attrSync(),{setting:c}=o;t.subPackages.length>c.MaxSubPackageLimit&&(0,common_1.throwError)({msg:locales_1.default.config.EXCEED_LIMIT.format([n,c.MaxSubPackageLimit]),filePath:r});const _={},s={};for(let o=0,r=t.subPackages.length;o<r;o++){const r=t.subPackages[o];if(r.name){if(r.name===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){i.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["name"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(r.name===config_1.MINI_GAME_MAIN_PACKAGE_ROOT){i.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["name"]`,config_1.MINI_GAME_MAIN_PACKAGE_ROOT));continue}_[r.name]&&i.push(locales_1.default.config.SAME_ITEM.format(`${n}[${o}]`,_[r.name],"name")),_[r.name]=`${n}[${o}]`}if(r.root===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){i.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(r.root===config_1.MINI_GAME_MAIN_PACKAGE_ROOT){i.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,config_1.MINI_GAME_MAIN_PACKAGE_ROOT));continue}if(r.root===config_1.MINI_GAME_WORKERS_PACKAGE_ROOT){i.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,config_1.MINI_GAME_WORKERS_PACKAGE_ROOT));continue}if(r.root==="/"+config_1.MINI_GAME_WORKERS_PACKAGE_ROOT){i.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,"/"+config_1.MINI_GAME_WORKERS_PACKAGE_ROOT));continue}if(r.root.startsWith(".")){i.push(locales_1.default.config.JSON_SHOULD_NOT_START_WITH.format(`${n}[${o}]["root"]`,"."));continue}if(r.root.startsWith("__wx__")){i.push(locales_1.default.config.JSON_SHOULD_NOT_START_WITH.format(`${n}[${o}]["root"]`,"__wx__"));continue}r.root.startsWith("/")||(r.root=(0,tools_1.normalizePath)("/"+r.root)),/\.js$/.test(r.root)?r.root=(0,tools_1.normalizePath)(r.root):r.root=(0,tools_1.normalizePath)(r.root+"/"),s[r.root]&&i.push(locales_1.default.config.SAME_ITEM.format(`${n}[${o}]`,s[r.root],"root")),s[r.root]=`${n}[${o}]`;const c=a.stat(e,r.root);if(c){if(c.isDirectory){/\/$/.test(r.root)||(r.root+="/");const t=path_1.default.posix.join(r.root,"./game.js"),c=a.stat(e,t);c&&c.isFile||i.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`${n}[${o}]["root"]`,t))}}else i.push(locales_1.default.config.JSON_CONTENT_NOT_FOUND.format(`${n}[${o}]["root"]`))}}i.length>0&&(0,common_1.throwError)({msg:i.join("\n"),filePath:r})}function checkLoadingImageUrl(o,t){const{project:e,root:a,filePath:r}=o,{loadingImageInfo:i}=t;if(!i)return;(0,common_1.checkPath)({tips:'["loadingImageInfo"]["path"]',value:i.path,filePath:r});const n=e.stat(a,i.path);n&&n.isFile||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_NOT_FOUND.format(`["loadingImageInfo"]["path"]: "${i.path}"`),filePath:r}),i.progressBarColor&&!(0,tools_1.isHexColor)(i.progressBarColor)&&(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(`["loadingImageInfo"]["progressBarColor"]: "${i.progressBarColor}"`,"HexColor"),filePath:r})}function checkWorkers(o,t){const{project:e,root:a,filePath:r}=o,{workers:i}=t;if(void 0===i)return;const n=(0,tools_1.getWorkersPath)(i);(0,common_1.checkPath)({tips:'["workers"]',value:n,filePath:r});const c=e.stat(a,n);c&&!c.isFile||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(['["workers"]',locales_1.default.config.DIRECTORY]),filePath:r})}function checkOpenDataContext(o,t){const{project:e,root:a,filePath:r}=o,{openDataContext:i}=t;if(void 0===i)return;(0,common_1.checkPath)({value:i,tips:'["openDataContext"]',filePath:r});const n=e.stat(a,i);n&&n.isDirectory||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(['["openDataContext"]',locales_1.default.config.DIRECTORY]),filePath:r});const c=path_1.default.posix.join(i,"./index.js"),_=e.stat(a,c);_&&_.isFile||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["openDataContext"]',c),filePath:r}),t.openDataContext=(0,tools_1.normalizePath)(i+"/")}function checkGameJSON(o){const{project:t,root:e,filePath:a}=o;t.stat(e,"game.json")||(0,common_1.throwError)({msg:locales_1.default.config.FILE_NOT_FOUND.format(path_1.default.posix.join(a)),filePath:a,code:config_1.FILE_NOT_FOUND});const r=t.getFile(e,"game.json"),i=(0,common_2.checkJSONFormat)((0,common_1.checkUTF8)(r,a),a),n=(0,schemaValidate_1.schemaValidate)("game",i);if(n.warning&&(i.__warning__=locales_1.default.config.INVALID.format(n.warning)),n.error.length){const o=n.error.map(o=>"type"===o.errorType||"enum"===o.errorType||"anyOf"===o.errorType?locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([o.errorProperty,o.correctType]):locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([o.requireProperty])).join("\n");(0,common_1.throwError)({msg:o,filePath:a})}return checkOpenDataContext(o,i),checkPlugins(o,i),checkSubpackages(o,i),checkPluginPath(o,i),checkLoadingImageUrl(o,i),checkWorkers(o,i),i}const getGameJSON=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.GAME_JSON,o=>{const t=(0,projectconfig_1.getProjectConfigJSON)(o).miniprogramRoot||"";return checkGameJSON({project:o,root:t,filePath:(0,tools_1.normalizePath)(path_1.default.posix.join(t,"game.json"))})});exports.default=getGameJSON;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkPageJSON=void 0;const tslib_1=require("tslib"),path_1=
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkPageJSON=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),locales_1=tslib_1.__importDefault(require("../../../utils/locales/locales")),common_1=require("../common"),schemaValidate_1=require("../../validate/schemaValidate"),tools_1=require("../../../utils/tools"),common_2=require("../../../utils/common"),theme_1=require("../theme"),checkHexColor=e=>{const{inputJSON:o,mode:a,pagePath:t,themeLocation:r}=e;let i=t+".json";if(o){r&&(i=`${t}.json or ${r}["${a}"]`);const{navigationBarBackgroundColor:e,backgroundColor:n}=o;void 0===e||(0,tools_1.isHexColor)(e)||(0,common_2.throwError)({msg:`["navigationBarBackgroundColor"]: "${e}" is not hexColor`,filePath:i}),void 0===n||(0,tools_1.isHexColor)(n)||(0,common_2.throwError)({msg:`["backgroundColor"]: "${n}" is not hexColor`,filePath:i})}};function checkPageJSON(e,o){const{pagePath:a,miniprogramRoot:t=""}=o;let r=(0,tools_1.normalizePath)(path_1.default.posix.join(t,a+".json"));if(!e.stat("",r))return{};const i=e.getFile("",r),n=(0,common_1.checkJSONFormat)((0,common_2.checkUTF8)(i,r),r),l=(0,theme_1.getThemeLocation)(e);if(!l){const e=(0,common_1.getPageJSONVariableDecalearProperty)(n);e.length&&(0,common_2.throwError)({msg:'["themeLocation"] is required because:\n'+e.map(e=>`"${e.value}" as variable was declared at ${r}:${e.property}`).join("\n"),filePath:r})}let c={light:{},dark:{}};l&&(c=(0,theme_1.checkThemeJSON)(e,{themeLocation:l}));const m=(0,theme_1.mergeThemeJSONToPageJSON)(c,n,r),h=(0,schemaValidate_1.schemaValidate)("page",m.pageJSONLight),s=(0,schemaValidate_1.schemaValidate)("page",m.pageJSONDark),g=(0,common_1.getPageJSONVariableDecalearProperty)(m.pageJSONLight);g.length&&(0,common_2.throwError)({msg:g.map(e=>`"${e.value}" as variable was declared at ${r}:${e.property}, but not found at ${l}["light"]`).join("\n"),filePath:r});const _=(0,common_1.getPageJSONVariableDecalearProperty)(m.pageJSONDark);if(_.length&&(0,common_2.throwError)({msg:_.map(e=>`"${e.value}" as variable was declared at ${r}:${e.property}, but not found at ${l}["dark"]`).join("\n"),filePath:r}),h.warning&&(n.__warning__=locales_1.default.config.INVALID.format(h.warning)),l&&s.warning&&(n.__warning__=locales_1.default.config.INVALID.format(s.warning)),h.error.length){const e=(0,common_1.transValidateResult)(h);l&&(r+=` or ${l}["light"]`),(0,common_2.throwError)({msg:e,filePath:r})}if(l&&s.error.length){const e=(0,common_1.transValidateResult)(s);l&&(r+=` or ${l}["dark"]`),(0,common_2.throwError)({msg:e,filePath:r})}return checkHexColor({inputJSON:m.pageJSONLight,mode:"light",themeLocation:l||"",filePath:r,pagePath:a}),checkHexColor({inputJSON:m.pageJSONDark,mode:"dark",themeLocation:l||"",filePath:r,pagePath:a}),n}exports.checkPageJSON=checkPageJSON;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPageJSON=exports.originGetPageJSON=void 0;const tslib_1=require("tslib"),path_1=
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPageJSON=exports.originGetPageJSON=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=require("lodash"),getExtJSON_1=require("../app/getExtJSON"),app_1=require("../app"),tools_1=require("../../../utils/tools"),checkPageJSON_1=require("./checkPageJSON"),common_1=require("../common"),common_2=require("../../../utils/common"),locales_1=tslib_1.__importDefault(require("../../../utils/locales/locales")),reactiveCache_1=require("../reactiveCache"),spreadUsingComponent=e=>{const{project:t,pagePath:o,inputJSON:n}=e;if(o.includes("miniprogram_npm"))return;const i=(0,app_1.getAppJSON)(t);if((0,common_1.checkPagePathIsInIndependentSubpackage)(i,o))return;if(i.componentPlaceholder){n.componentPlaceholder=n.componentPlaceholder||{};for(const e in i.componentPlaceholder)n.componentPlaceholder[e]=n.componentPlaceholder[e]||i.componentPlaceholder[e]}const c=Object.assign({},i.usingComponents);if(0!==Object.keys(c).length){n.usingComponents||(n.usingComponents={});for(const e in c){if(n.usingComponents[e])continue;const t=c[e]||"";if(t.startsWith("/")||t.startsWith("plugin://")){n.usingComponents[e]=t;continue}const i=(0,tools_1.normalizePath)(path_1.default.posix.relative(path_1.default.posix.dirname(o),t));n.usingComponents[e]=i.startsWith(".")?i:"./"+i}}},mergeExtJSON=e=>{var t;const{project:o,inputJSON:n,pagePath:i}=e,c=(0,getExtJSON_1.getExtJSON)(o);(null===(t=null==c?void 0:c.extPages)||void 0===t?void 0:t[i])&&Object.assign(n,c.extPages[i])},checkComponentPath=e=>{const{project:t,miniprogramRoot:o,pagePath:n,inputJSON:i}=e;(0,common_1.checkComponentPath)({project:t,root:o,relativePath:n+".json",inputJSON:i})},checkComponentGenerics=e=>{const{pagePath:t,inputJSON:o}=e,n=t+".json";if(!o.componentGenerics)return;const i=[];for(const e in o.componentGenerics){const t=o.componentGenerics[e],n=(0,tools_1.getType)(t);"boolean"===n||"object"===n?"object"===n&&"string"!==(0,tools_1.getType)(t.default)&&i.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`["componentGenerics"]["${e}"]["default"]`,"string"])):i.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`["componentGenerics"]["${e}"]`,"boolean/object"]))}i.length>0&&(0,common_2.throwError)({msg:i.join("\n"),filePath:n})};function checkRenderer(e){const{filePath:t,inputJSON:o}=e,{renderer:n}=o,i=(0,app_1.getAppJSON)(e.project);(0,common_2.getAllPages)(i).includes(e.pagePath)&&("skyline"===n&&"requiredComponents"!==i.lazyCodeLoading&&(0,common_2.throwError)({msg:locales_1.default.config.APP_JSON_SHOULD_SET_LAZYCODELOADING.format(t),filePath:t}),("skyline"===n||"skyline"===i.renderer&&"webview"!==n)&&(o.disableScroll=!0,o.navigationStyle="custom"))}const compilePageJSON=e=>{mergeExtJSON(e),checkComponentGenerics(e),checkComponentPath(e),spreadUsingComponent(e),checkRenderer(e)};function originGetPageJSON(e,t){const{pagePath:o,miniprogramRoot:n=""}=t,i=(0,tools_1.normalizePath)(path_1.default.posix.join(n,o+".json")),c=(0,reactiveCache_1.tryToGetReactiveJSONCompiler)(e),r=(0,lodash_1.cloneDeep)(c.getPageJSON("checked",t));return compilePageJSON({project:e,miniprogramRoot:n,inputJSON:r,filePath:i,pagePath:o}),r.usingComponents||(r.usingComponents={}),r}async function getPageJSON(e,t){const o=(0,reactiveCache_1.tryToGetReactiveProject)(e);return(0,reactiveCache_1.tryToGetReactiveJSONCompiler)(o).getPageJSON("compiled",t)}exports.originGetPageJSON=originGetPageJSON,reactiveCache_1.ReactiveJSONCompiler.setOriginCheckPageJSON(checkPageJSON_1.checkPageJSON),reactiveCache_1.ReactiveJSONCompiler.setOriginGetPageJSON(originGetPageJSON),exports.getPageJSON=getPageJSON;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getGameLocalPluginJSON=exports.getDevPluginJSON=exports.checkWorkers=exports.checkComponentPath=void 0;const tslib_1=require("tslib"),path_1=
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getGameLocalPluginJSON=exports.getDevPluginJSON=exports.checkWorkers=exports.checkComponentPath=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),projectconfig_1=require("../projectconfig"),locales_1=tslib_1.__importDefault(require("../../../utils/locales/locales")),common_1=require("../common"),config_1=require("../../../config"),schemaValidate_1=require("../../validate/schemaValidate"),tools_1=require("../../../utils/tools"),cache_1=require("../../../utils/cache"),common_2=require("../../../utils/common"),reactiveCache_1=require("../reactiveCache");function checkComponentPath(o,e){const{project:t,root:c,filePath:i}=o;void 0!==e.usingComponents&&(0,common_1.checkComponentPath)({project:t,root:c,relativePath:path_1.default.posix.relative(c,i),inputJSON:e})}function checkPublicComponentsAndPages(o,e){const{project:t,root:c,filePath:i}=o,{publicComponents:n,pages:r}=e,a={};if(n){const o=[];for(const r in n){const n=e.publicComponents[r];(0,common_2.checkPath)({value:n,tips:`["publicComponents"]["${r}"]`,filePath:i,code:config_1.PLUGIN_JSON_CONTENT_ERR});let l=t.stat(c,n+".wxml");l&&!l.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["publicComponents"]["${n}"]`,n+".wxml")),l=t.stat(c,n+".js"),l&&!l.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["publicComponents"]["${n}"]`,n+".js")),l=t.stat(c,n+".json"),l&&!l.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["publicComponents"]["${n}"]`,n+".json")),a[r]=!0}o.length>0&&(0,common_2.throwError)({msg:o.join("\n"),code:config_1.PLUGIN_JSON_CONTENT_ERR,filePath:i})}if(r){const o=[];for(const e in r){const n=r[e];(0,common_2.checkPath)({value:n,tips:`["pages"]["${e}"]`,filePath:i,code:config_1.PLUGIN_JSON_CONTENT_ERR});let l=t.stat(c,n+".wxml");l&&!l.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["pages"]["${n}"]`,n+".wxml")),l=t.stat(c,n+".js"),l&&!l.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["pages"]["${n}"]`,n+".js")),l=t.stat(c,n+".json"),l&&!l.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["pages"]["${n}"]`,n+".json")),a[e]&&o.push(locales_1.default.config.SAME_KEY_PAGE_PUBLICCOMPONENTS.format(`"${e}"`)),a[e]=!0}o.length>0&&(0,common_2.throwError)({msg:o.join("\n"),code:config_1.PLUGIN_JSON_CONTENT_ERR,filePath:i})}}function checkWorkers(o,e){const{project:t,root:c,filePath:i}=o,{workers:n}=e;if(void 0===n)return;const r='["workers"]';""===n&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(r,locales_1.default.config.DIRECTORY),filePath:i}),(0,common_2.checkPath)({value:n,tips:r,filePath:i});const a=t.stat(c,n);a&&a.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([r,locales_1.default.config.DIRECTORY]),filePath:i}),e.workers=(0,tools_1.normalizePath)(n+"/")}function checkMain(o,e){const{project:t,root:c,filePath:i}=o,{main:n}=e;if(void 0===n)return;""===n&&(0,common_2.throwError)({msg:locales_1.default.config.SHOULD_NOT_BE_EMPTY.format('["main"]'),code:config_1.PLUGIN_JSON_CONTENT_ERR,filePath:i}),(0,common_2.checkPath)({value:n,tips:'["main"]',filePath:i,code:config_1.PLUGIN_JSON_CONTENT_ERR});const r=t.stat(c,n);r&&!r.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["main"]',n),code:config_1.PLUGIN_JSON_CONTENT_ERR,filePath:i})}function isKindOfGamePlugin(o){return o.type===config_1.COMPILE_TYPE.miniGamePlugin}function checkPluginJSON(o){const{root:e="",project:t}=o,c=path_1.default.posix.join(e,"plugin.json");t.stat(e,"plugin.json")||(0,common_2.throwError)({msg:locales_1.default.config.PLUGIN_JSON_NOT_FOUND.format(e,"plugin.json"),code:config_1.PLUGIN_JSON_FILE_NOT_FOUND,filePath:c});const i=t.getFile(e,"plugin.json"),n=(0,common_1.checkJSONFormat)((0,common_2.checkUTF8)(i,c),c),r=(0,schemaValidate_1.schemaValidate)("plugin",n);if(r.error.length){const o=r.error.map(o=>"type"===o.errorType||"enum"===o.errorType||"anyOf"===o.errorType?locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([o.errorProperty,o.correctType]):locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([o.requireProperty])).join("\n");(0,common_2.throwError)({msg:"pluginJSON$"+o,code:config_1.PLUGIN_JSON_CONTENT_ERR,filePath:c})}return void 0!==n.themeLocation&&(0,common_2.checkPath)({value:n.themeLocation,tips:'["themeLocation"]',filePath:c}),isKindOfGamePlugin(t)||(checkPublicComponentsAndPages(o,n),checkComponentPath(o,n)),checkMain(o,n),checkWorkers(o,n),n}exports.checkComponentPath=checkComponentPath,exports.checkWorkers=checkWorkers,exports.getDevPluginJSON=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.PLUGIN_JSON,(o,e="")=>{const t=(0,projectconfig_1.getProjectConfigJSON)(o),{pluginRoot:c=""}=t;let i=c;o.type===config_1.COMPILE_TYPE.miniGame&&e&&(i=e),e||c||(0,common_2.throwError)({msg:locales_1.default.config.NOT_FOUND.format('["pluginRoot"]'),filePath:"project.config.json",code:config_1.JSON_CONTENT_ERR});return checkPluginJSON({project:o,filePath:path_1.default.posix.join(i,"plugin.json"),root:i})});const getGameLocalPluginJSON=async(o,e)=>{const t=await(0,projectconfig_1.getProjectConfigJSON)(o),{miniprogramRoot:c}=t;if(!e)return{};const i=(0,tools_1.normalizePath)(path_1.default.posix.join(c||"",e));return checkPluginJSON({project:(0,reactiveCache_1.tryToGetReactiveProject)(o),filePath:path_1.default.posix.join(i,"plugin.json"),root:i})};exports.getGameLocalPluginJSON=getGameLocalPluginJSON;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPluginPageJSON=void 0;const tslib_1=require("tslib"),path_1=
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPluginPageJSON=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),common_1=require("../common"),schemaValidate_1=require("../../validate/schemaValidate"),locales_1=tslib_1.__importDefault(require("../../../utils/locales/locales")),common_2=require("../../../utils/common"),plugin_1=require("./plugin"),theme_1=require("../theme"),spreadUsingComponent=async(e,t)=>{const{project:a,root:o,filePath:n}=t,i=path_1.default.posix.relative(o,n);if(n.includes("miniprogram_npm/"))return;const r=await(0,plugin_1.getDevPluginJSON)(a,!0),s=Object.assign({},r.usingComponents);if(0!==Object.keys(s).length){e.usingComponents||(e.usingComponents={});for(const t in s){if(e.usingComponents[t])continue;const a=s[t]||"";if(a.startsWith("/")||a.startsWith("plugin://")){e.usingComponents[t]=a;continue}const o=path_1.default.posix.normalize(path_1.default.posix.relative(path_1.default.posix.dirname(i),a));e.usingComponents[t]=o.startsWith(".")?o:"./"+o}}};async function checkComponentPath(e,t){const{project:a,root:o,filePath:n}=t;await(0,common_1.checkComponentPath)({project:a,root:o,relativePath:path_1.default.posix.relative(o,n),inputJSON:e})}async function getPluginPageJSON(e){const{project:t}=e;let a=e.filePath;if(!t.stat("",a))return{};const o=await t.getFile("",a),n=(0,common_1.checkJSONFormat)((0,common_2.checkUTF8)(o,a),a),i=await(0,theme_1.getPluginThemeLocation)(t);if(!i){const e=(0,common_1.getPageJSONVariableDecalearProperty)(n);e.length&&(0,common_2.throwError)({msg:'pluginJSON["themeLocation"] is required because:\n'+e.map(e=>`"${e.value}" as variable was declared at ${a}:${e.property}`).join("\n"),filePath:a})}let r={light:{},dark:{}};i&&(r=await(0,theme_1.checkThemeJSON)(t,{themeLocation:i,isPlugin:!0}));const s=(0,theme_1.mergeThemeJSONToPageJSON)(r,n,a),l=(0,schemaValidate_1.schemaValidate)("page",s.pageJSONLight),c=(0,schemaValidate_1.schemaValidate)("page",s.pageJSONDark);if(l.warning&&(n.__warning__=locales_1.default.config.INVALID.format(l.warning)),i&&c.warning&&(n.__warning__=locales_1.default.config.INVALID.format(c.warning)),l.error.length){const e=(0,common_1.transValidateResult)(l);i&&(a+=` or ${i}["light"]`),(0,common_2.throwError)({msg:e,filePath:a})}if(i&&c.error.length){const e=(0,common_1.transValidateResult)(c);i&&(a+=` or ${i}["dark"]`),(0,common_2.throwError)({msg:e,filePath:a})}return await checkComponentPath(n,e),await spreadUsingComponent(n,e),n}exports.getPluginPageJSON=getPluginPageJSON;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ProjectWithMockBuffer=void 0;const tslib_1=require("tslib"),project_1=require("../../ci/project"),tools_1=require("../../utils/tools"),path_1=
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ProjectWithMockBuffer=void 0;const tslib_1=require("tslib"),project_1=require("../../ci/project"),tools_1=require("../../utils/tools"),path_1=tslib_1.__importDefault(require("path")),fs_1=tslib_1.__importDefault(require("fs"));class ProjectWithMockBuffer extends project_1.Project{constructor(){super(...arguments),this.mockBuffer={},this.__dirSet=new Set,this.__fileSet=new Set}setMockFileCache(t){Object.entries(t).forEach(([t,e])=>{this.mockBuffer[t]=Buffer.from(e)})}_getTargetPath(t,e){return(0,tools_1.normalizePath)(path_1.default.posix.join(t,e)).replace(/\/$/,"").replace(/^\//,"")}getFile(t,e){const r=this._getTargetPath(t,e),i=(0,tools_1.normalizePath)(path_1.default.posix.join(this.projectPath,r));return this.mockBuffer[r]?this.mockBuffer[r]:fs_1.default.readFileSync(i,null)}stat(t,e){const r=this._getTargetPath(t,e);if(this.mockBuffer[r])return{isFile:!0,isDirectory:!1};if(this.__fileSet.has(r)){return{isFile:!0,isDirectory:!1,size:fs_1.default.statSync(path_1.default.posix.join(this.projectPath,r)).size}}return this.__dirSet.has(r)?{isFile:!1,isDirectory:!0}:void 0}}exports.ProjectWithMockBuffer=ProjectWithMockBuffer;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getProjectConfigJSON=void 0;const tslib_1=require("tslib"),lodash_1=require("lodash"),common_1=require("../../utils/common"),common_2=require("./common"),schemaValidate_1=require("../validate/schemaValidate"),cache_1=require("../../utils/cache"),tools_1=require("../../utils/tools"),config_1=require("../../config"),locales_1=
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getProjectConfigJSON=void 0;const tslib_1=require("tslib"),lodash_1=require("lodash"),common_1=require("../../utils/common"),common_2=require("./common"),schemaValidate_1=require("../validate/schemaValidate"),cache_1=require("../../utils/cache"),tools_1=require("../../utils/tools"),config_1=require("../../config"),locales_1=tslib_1.__importDefault(require("../../utils/locales/locales")),reactiveCache_1=require("./reactiveCache"),PROJECT_CONFIG_JSON="project.config.json",rootConfig=["svr","client","qcloudRoot","miniprogramRoot","pluginRoot","cloudfunctionRoot","jsserverRoot","testRoot"];function formatPath(o=""){return o&&"/"!==o?(o=(0,tools_1.normalizePath)(o+"/")).replace(/^(\/)*/,"").replace(/\.\.\//g,"").replace(/^\.\//,""):""}const _getProjectConfigJSON=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.PROJECT_CONFIG,o=>{if(!o.stat("",PROJECT_CONFIG_JSON))return o.type!==config_1.COMPILE_TYPE.miniGamePlugin&&o.type!==config_1.COMPILE_TYPE.miniProgramPlugin||(0,common_1.throwError)({msg:locales_1.default.config.NOT_FOUND.format("project.config.json"),code:config_1.FILE_NOT_FOUND,filePath:PROJECT_CONFIG_JSON}),{};const e=o.getFile("",PROJECT_CONFIG_JSON),r=(0,common_1.checkUTF8)(e,PROJECT_CONFIG_JSON),t=(0,common_2.checkJSONFormat)(r,PROJECT_CONFIG_JSON),i=(0,schemaValidate_1.schemaValidate)("projectconfig",t);if(i.error.length){const o=i.error.map(o=>"type"===o.errorType||"enum"===o.errorType||"anyOf"===o.errorType?locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([o.errorProperty,o.correctType]):locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([o.requireProperty])).join("\n");(0,common_1.throwError)({msg:o,filePath:PROJECT_CONFIG_JSON})}return o.miniprogramRoot=t.miniprogramRoot||"",o.pluginRoot=t.pluginRoot||"",rootConfig.forEach(o=>{"string"==typeof t[o]?t[o]=formatPath(t[o]):t[o]=""}),o.type!==config_1.COMPILE_TYPE.miniGamePlugin&&o.type!==config_1.COMPILE_TYPE.miniProgramPlugin||t.pluginRoot||(0,common_1.throwError)({msg:locales_1.default.config.SHOULD_NOT_BE_EMPTY.format('["pluginRoot"]'),filePath:PROJECT_CONFIG_JSON}),o.type!==config_1.COMPILE_TYPE.miniGamePlugin&&o.type!==config_1.COMPILE_TYPE.miniProgramPlugin||t.pluginRoot!==t.miniprogramRoot||(0,common_1.throwError)({msg:locales_1.default.config.PLUGIN_PATH_SAME_WITH_MINIPROGRAM.format([t.pluginRoot,t.miniprogramRoot]),filePath:PROJECT_CONFIG_JSON}),t}),getProjectConfigJSON=function(o){return(0,lodash_1.cloneDeep)(_getProjectConfigJSON(o))};exports.getProjectConfigJSON=getProjectConfigJSON;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.cleanReactiveCache=exports.wrapCompileJSONFunc=exports.tryToGetReactiveJSONCompiler=exports.ReactiveJSONCompiler=exports.tryToGetReactiveProject=exports.ReactiveProject=void 0;const tslib_1=require("tslib"),path_1=
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.cleanReactiveCache=exports.wrapCompileJSONFunc=exports.tryToGetReactiveJSONCompiler=exports.ReactiveJSONCompiler=exports.tryToGetReactiveProject=exports.ReactiveProject=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),tools_1=require("../../utils/tools"),reactivity_1=require("@vue/reactivity"),lodash_1=require("lodash"),process_1=require("process"),config_1=require("../../config"),isDevtools=process.__nwjs&&"wechatwebdevtools"===nw.App.manifest.appname;function info(...e){}function log(...e){isDevtools&&console.log.apply(console,e)}function error(...e){isDevtools&&console.error.apply(console,e)}function isAttrEqual(e,t){return"object"==typeof e&&"object"==typeof t&&(!(!e||!t)&&(e.platform===t.platform&&e.appType===t.appType&&e.gameApp===t.gameApp&&e.isSandbox===t.isSandbox&&e.released===t.released&&(e.setting.MaxCodeSize===t.setting.MaxCodeSize&&e.setting.MaxSubpackageSubCodeSize===t.setting.MaxSubpackageSubCodeSize&&e.setting.MaxSubpackageFullCodeSize===t.setting.MaxSubpackageFullCodeSize&&e.setting.NavigateMiniprogramLimit===t.setting.NavigateMiniprogramLimit&&e.setting.MaxSubPackageLimit===t.setting.MaxSubPackageLimit&&e.setting.MinTabbarCount===t.setting.MinTabbarCount&&e.setting.MaxTabbarCount===t.setting.MaxTabbarCount&&e.setting.MaxTabbarIconSize===t.setting.MaxTabbarIconSize)))}function makeReadonly(e){return e&&"object"==typeof e?(0,reactivity_1.readonly)(e):e}class ReactiveProject{constructor(e){if(this.fileBoxs=new Map,this.statBoxs=new Map,this.resetFileChangeListener=()=>{},this.project=e,e.onFileChange){const t=e.onFileChange;e.onFileChange=(i,o)=>{t.call(e,i,o),this.onFileChange(i,o)},this.resetFileChangeListener=()=>{e.onFileChange=t}}this.miniprogramRootBox=(0,reactivity_1.ref)(e.miniprogramRoot),this.pluginRootBox=(0,reactivity_1.ref)(e.pluginRoot),this.appidBox=(0,reactivity_1.ref)(e.appid),this.typeBox=(0,reactivity_1.ref)(e.type),this.attrBox=(0,reactivity_1.ref)(config_1.DefaultProjectAttr)}release(){this.resetFileChangeListener(),log("[reactiveCache] reactiveProject release")}async attr(){return this.attrSync()}getFileList(e,t){return this.project.getFileList(e,t)}getFilesAndDirs(){return this.project.getFilesAndDirs()}getExtAppid(){return this.project.getExtAppid()}updateFiles(){throw new Error("Method updateFiles not implemented.")}async updateProject(){this.appidBox.value!==this.project.appid&&(this.appidBox.value=this.project.appid),this.typeBox.value!==this.project.type&&(this.typeBox.value=this.project.type),this.miniprogramRootBox.value!==this.project.miniprogramRoot&&(this.miniprogramRootBox.value=this.project.miniprogramRoot),this.pluginRootBox.value!==this.project.pluginRoot&&(this.pluginRootBox.value=this.project.pluginRoot);const e=await this.project.attr();return isAttrEqual(e,this.attrBox.value)||(this.attrBox.value=e),new Promise(e=>{setTimeout(e,0)})}onFileChange(e,t){if("change"===e){const e=this.fileBoxs.get(t);if(e){const i=this.project.getFile("",t);e.value&&0===i.compare(e.value)||(e.value=i)}}else if("unlink"===e){const e=this.fileBoxs.get(t);e&&(this.fileBoxs.delete(t),e.value=void 0);const i=this.statBoxs.get(t);if(i){const e=this.project.stat("",t);(0,lodash_1.isEqual)(e,i.value)||(i.value=e)}}else if("unlinkDir"===e){const e=t+"/";let i=Array.from(this.fileBoxs.keys());for(const t of i)if(0===t.indexOf(e)){const e=this.fileBoxs.get(t);this.fileBoxs.delete(t),e.value=void 0}i=Array.from(this.statBoxs.keys());for(const t of i)if(0===t.indexOf(e)){const e=this.statBoxs.get(t);void 0!==e.value&&(this.statBoxs.delete(t),e.value=void 0)}}else if("add"===e||"addDir"===e){const e=this.statBoxs.get(t);if(e){const i=this.project.stat("",t);(0,lodash_1.isEqual)(i,e.value)||(e.value=i)}}}getFile(e,t){const i=this.getTargetPath(e,t),o=this.fileBoxs.get(i);if(o)return o.value;{const o=(0,reactivity_1.ref)(this.project.getFile(e,t));return this.fileBoxs.set(i,o),o.value}}stat(e,t){const i=this.getTargetPath(e,t),o=this.statBoxs.get(i);if(o)return o.value;{const o=(0,reactivity_1.ref)(this.project.stat(e,t));return this.statBoxs.set(i,o),o.value}}attrSync(){return this.attrBox.value}get appid(){return this.appidBox.value}get type(){return this.typeBox.value}get nameMappingFromDevtools(){return this.project.nameMappingFromDevtools}get projectPath(){return this.project.projectPath}get privateKey(){return this.project.privateKey}get miniprogramRoot(){return this.miniprogramRootBox.value}set miniprogramRoot(e){this.miniprogramRootBox.value=e,this.project.miniprogramRoot=e}get pluginRoot(){return this.pluginRootBox.value}set pluginRoot(e){this.pluginRootBox.value=e,this.project.pluginRoot=e}getTargetPath(e,t){return(0,tools_1.normalizePath)(path_1.default.posix.join(e,t)).replace(/\/$/,"").replace(/^\//,"")}}exports.ReactiveProject=ReactiveProject;const reactiveProjectMap=new Map;function tryToGetReactiveProject(e){let t=reactiveProjectMap.get(e.projectPath);return t||(t=new ReactiveProject(e),reactiveProjectMap.set(e.projectPath,t),t)}exports.tryToGetReactiveProject=tryToGetReactiveProject;let isPending=!1;const pendingRunner=new Set,resolvedPromise=Promise.resolve();function runInNextTick(e){pendingRunner.add(e),isPending||(isPending=!0,resolvedPromise.then(()=>{const e=Date.now();try{const t=Array.from(pendingRunner);pendingRunner.clear(),isPending=!1,t.forEach(e=>{e()})}finally{info(`[reactiveCache] nextTick update cost ${Date.now()-e} ms`)}}))}class ReactiveJSONCompiler{constructor(e){this.pageComputeds=new Map,this.jsonComputeds=new Map,this.project=e}release(){log("[reactiveCache] reactiveJSONCompiler release")}registerOrGet(e,t,...i){let o=this.jsonComputeds.get(e);if(!o){o=(0,reactivity_1.ref)(void 0),this.jsonComputeds.set(e,o);let r=void 0;r=(0,reactivity_1.effect)(()=>{try{info(`[reactiveCache] ${e} start to update`);const r=t.call(null,this.project,...i);(0,lodash_1.isEqual)(r,o.value)?info(`[reactiveCache] ${e} update finish, value no change`):(o.value=makeReadonly(r),info(`[reactiveCache] ${e} update finish, new value: `,o.value))}catch(t){o.value=t instanceof Error?t:new Error(t.toString()),log(`[reactiveCache] update ${e} failed: `,t)}},{scheduler(){r&&r.active&&runInNextTick(r)}})}const{value:r}=o;if(r instanceof Error)throw r;return r}static setOriginGetPageJSON(e){this.originGetPageJSON=e}static setOriginCheckPageJSON(e){this.originCheckPageJSON=e}getPageJSON(e,t){let i=this.pageComputeds.get(t.pagePath);i||(i={checked:(0,reactivity_1.ref)(void 0),compiled:(0,reactivity_1.ref)(void 0)},this.pageComputeds.set(t.pagePath,i));const o=i[e];if(void 0===o.value){let i=void 0;i=(0,reactivity_1.effect)(()=>{try{info(`[reactiveCache] start to update ${e} ${t.pagePath}`);const i="compiled"===e?ReactiveJSONCompiler.originGetPageJSON(this.project,t):ReactiveJSONCompiler.originCheckPageJSON(this.project,t);o.value=makeReadonly(i),info(`[reactiveCache] update finish ${e} ${t.pagePath}`)}catch(i){o.value=i instanceof Error?i:new Error(i.toString()),log(`[reactiveCache] update ${e} ${t.pagePath} failed: `,i)}},{scheduler(){i&&i.active&&(0,process_1.nextTick)(i)}})}const r=o.value;if(r instanceof Error)throw r;return r}}exports.ReactiveJSONCompiler=ReactiveJSONCompiler;const reactiveJSONCompilerMap=new Map;function tryToGetReactiveJSONCompiler(e){let t=reactiveJSONCompilerMap.get(e.projectPath);return t||(t=new ReactiveJSONCompiler(e),reactiveJSONCompilerMap.set(e.projectPath,t),t)}function wrapCompileJSONFunc(e,t){return function(i,...o){i instanceof ReactiveProject||(i=tryToGetReactiveProject(i));return tryToGetReactiveJSONCompiler(i).registerOrGet(e,t,...o)}}function cleanReactiveCache(){reactiveProjectMap.forEach(e=>{e.release()}),reactiveProjectMap.clear(),reactiveJSONCompilerMap.forEach(e=>{e.release()}),reactiveJSONCompilerMap.clear()}exports.tryToGetReactiveJSONCompiler=tryToGetReactiveJSONCompiler,exports.wrapCompileJSONFunc=wrapCompileJSONFunc,exports.cleanReactiveCache=cleanReactiveCache;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getAllPluginSignatures=exports.isPathValid=exports.getAllPluginsWithPath=exports.friendlyPathMake=exports.trailing=void 0;const tslib_1=require("tslib"),path_1=
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getAllPluginSignatures=exports.isPathValid=exports.getAllPluginsWithPath=exports.friendlyPathMake=exports.trailing=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),game_1=tslib_1.__importDefault(require("./game")),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),tools_1=require("../../utils/tools"),log_1=tslib_1.__importDefault(require("../../utils/log")),trailing=(t,e)=>t.endsWith(e)?t:t+e;exports.trailing=trailing;const friendlyPathMake=(t,e)=>path_1.default.normalize(path_1.default.join(t,e.replace(/\\/g,"/")).replace(/^\/+/,""));async function getAllPluginsWithPath(t){const e=await(0,game_1.default)(t),i=[],a=(t,e="")=>{if(t.plugins)for(const a in t.plugins){if(!t.plugins.hasOwnProperty(a))continue;const r=t.plugins[a];r&&"string"==typeof r.path&&i.push({alias:a,version:r.version||"",provider:r.provider||"",path:r.path,friendlyPath:(0,exports.friendlyPathMake)(e,r.path)})}};a(e,"");const r=e.subPackages||e.subpackages;if(Array.isArray(r))for(const t of r)t&&"string"==typeof t.root&&a(t,t.root);return i}function isPathValid(t,e){if(e=e.replace(/\\/g,"/"),t=t.replace(/\\/g,"/"),e.includes("../")||e.endsWith("/.."))return!1;const i=(0,tools_1.normalizePath)(path_1.default.join(t,e)),a=(0,tools_1.normalizePath)(t);return!!i.startsWith(a)}async function getAllPluginSignatures(t){const e=await getAllPluginsWithPath(t),i=[];let a=t.miniprogramRoot?path_1.default.join(t.projectPath,t.miniprogramRoot):t.projectPath;a=(0,tools_1.normalizePath)(a),a=a.endsWith("/")?a:a+"/";for(const t of e)try{const e=path_1.default.join(a,t.friendlyPath);let r=await fs_extra_1.default.pathExists(e);if(!r)continue;const n=await fs_extra_1.default.stat(e);let l=e;n.isDirectory()||(l=path_1.default.dirname(e));const s=path_1.default.join(l,"signature.json");if(r=await fs_extra_1.default.pathExists(s),!r)continue;const o=await fs_extra_1.default.readFile(s,"utf8");let u=null;try{u=JSON.parse(o)}catch(t){log_1.default.error(t);continue}if(!u||!Array.isArray(u.signature))continue;const p=[];for(let t=0;t<u.signature.length;t++){const e=u.signature[t];if(!e)continue;if("string"!=typeof e.path||"string"!=typeof e.md5)continue;if(!isPathValid(l,e.path))continue;const i=path_1.default.join(l,e.path);p.push({fullPath:i,md5:e.md5})}i.push({provider:t.provider,fullPath:e,signature:p})}catch(t){log_1.default.error(t);continue}return i}exports.friendlyPathMake=friendlyPathMake,exports.getAllPluginsWithPath=getAllPluginsWithPath,exports.isPathValid=isPathValid,exports.getAllPluginSignatures=getAllPluginSignatures;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getSiteMapJSON=void 0;const tslib_1=require("tslib"),path_1=
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getSiteMapJSON=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),tools_1=require("../../utils/tools"),projectconfig_1=require("./projectconfig"),locales_1=tslib_1.__importDefault(require("../../utils/locales/locales")),common_1=require("../../utils/common"),common_2=require("./common"),schemaValidate_1=require("../validate/schemaValidate"),cache_1=require("../../utils/cache"),reactiveCache_1=require("./reactiveCache"),config_1=require("../../config"),getAppJSON_1=require("./app/getAppJSON");exports.getSiteMapJSON=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.SITE_MAP_JSON,e=>{const o=(0,projectconfig_1.getProjectConfigJSON)(e),r=(0,getAppJSON_1.getAppJSON)(e),{sitemapLocation:t=""}=r;let i=t;if(i)i=(0,tools_1.normalizePath)(path_1.default.posix.join(o.miniprogramRoot||"",i));else{if(i=(0,tools_1.normalizePath)(path_1.default.posix.join(o.miniprogramRoot||"","sitemap.json")),!e.stat("",i))return e.type,config_1.COMPILE_TYPE.miniProgramPlugin,{desc:"",rules:[{action:"disallow",page:"*"}]}}const a=e.getFile("",i),c=(0,common_1.checkUTF8)(a,i),l=(0,common_2.checkJSONFormat)(c,i),_=(0,schemaValidate_1.schemaValidate)("sitemap",l);if(_.error.length){const e=_.error.map(e=>"type"===e.errorType||"enum"===e.errorType||"anyOf"===e.errorType?locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([e.errorProperty,e.correctType]):locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([e.requireProperty])).join("\n");(0,common_1.throwError)({msg:e,filePath:i})}return l});
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
package/dist/core/json/theme.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.mergeThemeJSONToPageJSON=exports.mergeThemeJSONToAppJSON=exports.checkThemeJSON=exports.getPluginThemeLocation=exports.getThemeLocation=void 0;const tslib_1=require("tslib"),path_1=
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.mergeThemeJSONToPageJSON=exports.mergeThemeJSONToAppJSON=exports.checkThemeJSON=exports.getPluginThemeLocation=exports.getThemeLocation=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=tslib_1.__importStar(require("lodash")),tools_1=require("../../utils/tools"),projectconfig_1=require("./projectconfig"),locales_1=tslib_1.__importDefault(require("../../utils/locales/locales")),common_1=require("../../utils/common"),common_2=require("./common"),cache_1=require("../../utils/cache"),getAppJSON_1=require("./app/getAppJSON"),schemaValidate_1=require("../validate/schemaValidate"),config_1=require("../../config"),plugin_1=require("./plugin/plugin"),reactiveCache_1=require("./reactiveCache");async function getPluginThemeLocation(e){return(await(0,plugin_1.getDevPluginJSON)(e)).themeLocation||null}function checkThemeJSON(e,o){const{isPlugin:t}=o;return t?originCheckThemeJSONForPlugin(e,o):originCheckThemeJSONForMiniProgram(e,o)}exports.getThemeLocation=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.APP_JSON_THEME_LOCATION,e=>{const o=(0,getAppJSON_1.getRawAppJSON)(e).themeLocation;return"[object Undefined]"!==Object.prototype.toString.call(o)?"string"==typeof o?((0,common_1.checkPath)({value:o,tips:'["themeLocation"]',filePath:"app.json"}),o):((0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format('appJSON["themeLocation"]',"string"),filePath:"app.json"}),null):null}),exports.getPluginThemeLocation=getPluginThemeLocation,exports.checkThemeJSON=checkThemeJSON;const originCheckThemeJSONForMiniProgram=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.THEME_JSON,originCheckThemeJSON),originCheckThemeJSONForPlugin=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.PLUGIN_THEME_JSON,originCheckThemeJSON);function originCheckThemeJSON(e,o){const{isPlugin:t}=o,r=(0,exports.getThemeLocation)(e),i=(0,projectconfig_1.getProjectConfigJSON)(e),a=t?i.pluginRoot:i.miniprogramRoot,c=(0,tools_1.normalizePath)(path_1.default.posix.join(a||"",r));e.stat("",c)||(0,common_1.throwError)({msg:locales_1.default.config.FILE_NOT_FOUND.format(c),filePath:"app.json"});const n=e.getFile("",c),l=(0,common_1.checkUTF8)(n,c),s=(0,common_2.checkJSONFormat)(l,c),h=(0,schemaValidate_1.schemaValidate)("theme",s);if(h.error.length){const e=h.error.map(e=>"type"===e.errorType||"enum"===e.errorType||"anyOf"===e.errorType?locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([e.errorProperty,e.correctType]):locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([e.requireProperty])).join("\n");(0,common_1.throwError)({msg:e,filePath:c})}return s}function mergeThemeJSONToAppJSON(e,o){var t,r;const{windowPropertWhiteList:i,tabBarPropertyWhiteList:a,tabbarListItemPropertyWhiteList:c}=config_1.jsonVariablePropertyWhiteList,n=/^@/,l=lodash_1.default.cloneDeep(o.window||{}),s=lodash_1.default.cloneDeep(o.window||{});Object.keys(l).forEach(o=>{const t=l[o];if(n.test(t)){i.includes(o)||(0,common_1.throwError)({msg:""+locales_1.default.config.SHOULD_NOT_IN.format([t,o]),filePath:"app.json"});const r=t.slice(1);l[o]=e.light[r]||t,s[o]=e.dark[r]||t}});const h=(0,lodash_1.cloneDeep)(o),m=(0,lodash_1.cloneDeep)(o);if(h.window=l,m.window=s,null===(r=null===(t=o.tabBar)||void 0===t?void 0:t.list)||void 0===r?void 0:r.length){const t=lodash_1.default.cloneDeep(o.tabBar||{list:[]}),r=lodash_1.default.cloneDeep(o.tabBar||{list:[]});t.list&&t.list.length>0&&Object.keys(t).forEach(o=>{if("list"!==o){const i=t[o];if(n.test(i)){a.includes(o)||(0,common_1.throwError)({msg:""+locales_1.default.config.SHOULD_NOT_IN.format([i,o]),filePath:"app.json"});const c=i.slice(1);t[o]=e.light[c]||i,r[o]=e.dark[c]||i}}else t.list.forEach((o,i)=>{Object.keys(o).forEach(a=>{const l=o[a];if(n.test(l)){c.includes(a)||(0,common_1.throwError)({msg:""+locales_1.default.config.SHOULD_NOT_IN.format([l,a]),filePath:"app.json"});const o=l.slice(1);t.list[i][a]=e.light[o]||l,r.list[i][a]=e.dark[o]||l}})})}),m.tabBar=r,h.tabBar=t}return{appJSONLight:h,appJSONDark:m}}function mergeThemeJSONToPageJSON(e,o,t){const r=config_1.jsonVariablePropertyWhiteList.windowPropertWhiteList,i=lodash_1.default.cloneDeep(o||{}),a=lodash_1.default.cloneDeep(o||{}),c=/^@/;return Object.keys(o).forEach(n=>{const l=o[n];if(c.test(l)){const o=l.slice(1);r.includes(n)||(0,common_1.throwError)({msg:""+locales_1.default.config.SHOULD_NOT_IN.format([l,n]),filePath:t}),a[n]=e.light[o]||l,i[n]=e.dark[o]||l}}),{pageJSONDark:i,pageJSONLight:a}}exports.mergeThemeJSONToAppJSON=mergeThemeJSONToAppJSON,exports.mergeThemeJSONToPageJSON=mergeThemeJSONToPageJSON;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),path_1=
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),read_package_tree_1=tslib_1.__importDefault(require("read-package-tree"));function checkDeps(e,t){var a,r;const n=new Set(Object.keys((null===(a=e.package)||void 0===a?void 0:a.dependencies)||{})),o=[];let s=e;for(;s;){const e=s.children||[];for(const t of e){const e=(null===(r=t.package)||void 0===r?void 0:r.name)||"";n.has(e)&&(n.delete(e),o.push(t))}s=s.parent}for(const e of o)t.has(e)||(t.add(e),checkDeps(e,t))}async function getDeps(e){return new Promise((t,a)=>{(0,read_package_tree_1.default)(e,(e,r)=>{if(e)return a(e);const n=new Set;try{checkDeps(r,n)}catch(e){return a(e)}t(Array.from(n))})})}async function default_1(e,t){if(null==t?void 0:t.length){const a=t.filter(e=>!/([\\/]|\b)node_modules/.test(e)),r=[],n={};for(const t of a){(await getDeps(path_1.default.join(e,path_1.default.dirname(t)))).forEach(e=>{r.push(e)})}for(const e of r){const t=e.isLink?e.path:e.realpath;n[path_1.default.normalize(path_1.default.join(t,"./package.json"))]=e}t=t.filter(t=>{const a=path_1.default.normalize(path_1.default.join(e,t));return!!n[a]})}return t}exports.default=default_1;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|