miniprogram-ci 1.6.1 → 1.8.12
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 +7 -0
- package/README.md +3 -1
- package/dist/@types/ci/cos-upload.d.ts +1 -3
- package/dist/@types/config.d.ts +1 -3
- package/dist/@types/core/js/generateMap.d.ts +3 -0
- package/dist/@types/core/json/app/checkAppFields.d.ts +2 -0
- package/dist/@types/index.d.ts +2 -0
- package/dist/@types/summer/devtool.d.ts +5 -0
- package/dist/@types/summer/graph/basegraph.d.ts +2 -0
- package/dist/@types/summer/summer.d.ts +1 -0
- package/dist/@types/summer/types.d.ts +13 -3
- package/dist/@types/types/miniprogram-json/app.d.ts +5 -1
- package/dist/@types/types/miniprogram-json/page.d.ts +1 -0
- package/dist/@types/types/miniprogram-json/projectconfig.d.ts +1 -0
- package/dist/@types/utils/locales/locales.d.ts +6 -0
- package/dist/@types/utils/locales/zh.d.ts +6 -0
- package/dist/@types/utils/tools.d.ts +1 -0
- package/dist/ci/code-analyse.js +3 -1
- package/dist/ci/cos-upload.js +3 -1
- package/dist/ci/getCompiledResult.js +3 -1
- package/dist/ci/getDevSourceMap.js +3 -1
- package/dist/ci/getLatestVersion.js +3 -1
- package/dist/ci/jsserver.js +3 -1
- package/dist/ci/preview.js +3 -1
- package/dist/ci/project.js +3 -1
- package/dist/ci/projectattr.js +3 -1
- package/dist/ci/upload.js +3 -1
- package/dist/ci/utils/pack.js +3 -1
- package/dist/ci/utils/packfile.js +3 -1
- package/dist/ci/utils/terminalQrcode.js +3 -1
- package/dist/cli.js +3 -1
- package/dist/cloud/cloudapi.js +3 -1
- package/dist/cloud/createTimeTrigger.js +3 -1
- package/dist/cloud/uploadContainer.js +3 -1
- package/dist/cloud/uploadFile.js +3 -1
- package/dist/cloud/uploadFunction.js +3 -1
- package/dist/cloud/utils.js +3 -1
- package/dist/config.js +3 -1
- package/dist/core/analyse/partial.js +3 -1
- package/dist/core/compile/common.js +3 -1
- package/dist/core/compile/game.js +3 -1
- package/dist/core/compile/game_plugin.js +3 -1
- package/dist/core/compile/handler/js.js +3 -1
- package/dist/core/compile/handler/mpjson.js +3 -1
- package/dist/core/compile/handler/wxml.js +3 -1
- package/dist/core/compile/handler/wxss.js +3 -1
- package/dist/core/compile/index.js +3 -1
- package/dist/core/compile/mini_program.js +3 -1
- package/dist/core/compile/mini_program_plugin.js +3 -1
- package/dist/core/js/enhance.js +1 -1
- package/dist/core/js/generateMap.js +1 -0
- package/dist/core/js/index.js +1 -1
- package/dist/core/js/minifyjs.js +1 -1
- package/dist/core/js/minifyjs_after_wrap.js +1 -1
- package/dist/core/json/app/checkAppFields.js +3 -1
- package/dist/core/json/app/getAppJSON.js +3 -1
- package/dist/core/json/app/getExtJSON.js +3 -1
- package/dist/core/json/app/index.js +3 -1
- package/dist/core/json/common.js +3 -1
- package/dist/core/json/game.js +3 -1
- package/dist/core/json/page/checkPageJSON.js +3 -1
- package/dist/core/json/page/getPageJSON.js +3 -1
- package/dist/core/json/plugin/plugin.js +3 -1
- package/dist/core/json/plugin/plugin_page.js +3 -1
- package/dist/core/json/projectWithMockBuffer.js +3 -1
- package/dist/core/json/projectconfig.js +3 -1
- package/dist/core/json/reactiveCache.js +3 -1
- package/dist/core/json/signaturejson.js +3 -1
- package/dist/core/json/sitemap.js +3 -1
- package/dist/core/json/theme.js +3 -1
- package/dist/core/npm/filterdeps.js +3 -1
- package/dist/core/npm/packnpm.js +3 -1
- package/dist/core/protect/file_flatter.js +3 -1
- package/dist/core/protect/uglifyfilenames.js +3 -1
- package/dist/core/utils/env.js +3 -1
- package/dist/core/utils/logger.js +3 -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 +3 -1
- package/dist/index.js +3 -1
- package/dist/manifest.json +2 -2
- package/dist/schema/dist/index.d.ts +1 -1
- package/dist/summer/ci.js +3 -1
- package/dist/summer/devtool.js +3 -1
- package/dist/summer/entry_process.js +1 -1
- package/dist/summer/error.js +3 -1
- package/dist/summer/graph/appconf.js +3 -1
- package/dist/summer/graph/appgraph.js +3 -1
- package/dist/summer/graph/basegraph.js +3 -1
- package/dist/summer/graph/pluginconf.js +3 -1
- package/dist/summer/graph/plugingraph.js +3 -1
- package/dist/summer/index.js +3 -1
- package/dist/summer/initPlugin.js +3 -1
- package/dist/summer/module.js +3 -1
- package/dist/summer/persist_cache.js +3 -1
- package/dist/summer/plugin_driver.js +3 -1
- package/dist/summer/plugins/base/es6module.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/sass.js +1 -1
- package/dist/summer/plugins/terser.js +1 -1
- package/dist/summer/plugins/typescript.js +1 -1
- package/dist/summer/project.js +3 -1
- package/dist/summer/recorder.js +3 -1
- package/dist/summer/resolver.js +3 -1
- package/dist/summer/summer.js +3 -1
- package/dist/summer/types.js +3 -1
- package/dist/summer/utils/async.js +3 -1
- package/dist/summer/utils/ensureArray.js +3 -1
- package/dist/summer/worker.js +3 -1
- package/dist/types/index.js +3 -1
- package/dist/types/miniprogram-json/app.js +3 -1
- package/dist/types/miniprogram-json/base.js +3 -1
- package/dist/types/miniprogram-json/ext.js +3 -1
- package/dist/types/miniprogram-json/game.js +3 -1
- package/dist/types/miniprogram-json/index.js +3 -1
- package/dist/types/miniprogram-json/page.js +3 -1
- package/dist/types/miniprogram-json/plugin.js +3 -1
- package/dist/types/miniprogram-json/projectconfig.js +3 -1
- package/dist/types/miniprogram-json/sitemap.js +3 -1
- package/dist/types/miniprogram-json/theme.js +3 -1
- package/dist/utils/babel_helper.js +3 -1
- package/dist/utils/babel_transform_plugin.js +3 -1
- package/dist/utils/cache.js +3 -1
- package/dist/utils/common.js +3 -1
- package/dist/utils/error.js +3 -1
- package/dist/utils/fs.js +3 -1
- package/dist/utils/fsagent.js +3 -1
- package/dist/utils/glob.js +3 -1
- package/dist/utils/interruptibletask.js +3 -1
- package/dist/utils/jsonParse.js +3 -1
- package/dist/utils/jsonlint.js +3 -1
- package/dist/utils/locales/en.js +3 -1
- package/dist/utils/locales/fomatable_string.js +3 -1
- package/dist/utils/locales/locales.js +3 -1
- package/dist/utils/locales/zh.js +3 -1
- package/dist/utils/log.js +3 -1
- package/dist/utils/report.js +3 -1
- package/dist/utils/request.js +3 -1
- package/dist/utils/sign.js +3 -1
- package/dist/utils/taskstatus.js +3 -1
- package/dist/utils/tools.js +3 -1
- package/dist/utils/url_config.js +3 -1
- package/dist/utils/white_ext_list.js +3 -1
- package/dist/utils/wxvpkgreader/wxvpkgreader.js +1 -1
- package/dist/vendor/cloud-api/src/apis/apis.js +3 -1
- package/dist/vendor/cloud-api/src/apis/cdn/cdn.apis.js +3 -1
- package/dist/vendor/cloud-api/src/apis/cdn/index.js +3 -1
- package/dist/vendor/cloud-api/src/apis/flexdb/flexdb.apis.js +3 -1
- package/dist/vendor/cloud-api/src/apis/flexdb/index.js +3 -1
- package/dist/vendor/cloud-api/src/apis/scf/index.js +3 -1
- package/dist/vendor/cloud-api/src/apis/scf/scf.apis.js +3 -1
- package/dist/vendor/cloud-api/src/apis/ssl/index.js +3 -1
- package/dist/vendor/cloud-api/src/apis/ssl/ssl.apis.js +3 -1
- package/dist/vendor/cloud-api/src/apis/tcb/general.apis.js +3 -1
- package/dist/vendor/cloud-api/src/apis/tcb/index.js +3 -1
- package/dist/vendor/cloud-api/src/apis/tcb/tcb.apis.js +3 -1
- package/dist/vendor/cloud-api/src/index.js +3 -1
- package/dist/vendor/cloud-api/src/transaction/contracts/cdn.contracts.js +3 -1
- package/dist/vendor/cloud-api/src/transaction/contracts/contracts.js +3 -1
- package/dist/vendor/cloud-api/src/transaction/contracts/factory.js +3 -1
- package/dist/vendor/cloud-api/src/transaction/contracts/flexdb.contracts.js +3 -1
- package/dist/vendor/cloud-api/src/transaction/contracts/scf.contracts.js +3 -1
- package/dist/vendor/cloud-api/src/transaction/contracts/ssl.contracts.js +3 -1
- package/dist/vendor/cloud-api/src/transaction/contracts/tcb.contracts.js +3 -1
- package/dist/vendor/cloud-api/src/transaction/transactor.js +3 -1
- package/dist/vendor/cloud-api/src/transaction/validations/cdn.validations.js +3 -1
- package/dist/vendor/cloud-api/src/transaction/validations/common.validations.js +3 -1
- package/dist/vendor/cloud-api/src/transaction/validations/flexdb.validations.js +3 -1
- package/dist/vendor/cloud-api/src/transaction/validations/scf.validations.js +3 -1
- package/dist/vendor/cloud-api/src/transaction/validations/ssl.validations.js +3 -1
- package/dist/vendor/cloud-api/src/transaction/validations/tcb.validations.js +3 -1
- package/dist/vendor/cloud-api/src/transaction/validations/validations.js +3 -1
- package/dist/vendor/cloud-api/src/utils/common.js +3 -1
- package/dist/vendor/cloud-api/src/utils/validator.js +3 -1
- package/dist/vendor/schema/dist/app.js +47 -1
- package/dist/vendor/schema/dist/ext.js +46 -1
- package/dist/vendor/schema/dist/game.js +29 -1
- package/dist/vendor/schema/dist/index.js +2 -1
- package/dist/vendor/schema/dist/page.js +38 -1
- package/dist/vendor/schema/dist/plugin.js +1 -1
- package/dist/vendor/schema/dist/pluginpage.js +1 -1
- package/dist/vendor/schema/dist/projectconfig.js +425 -9
- package/dist/vendor/schema/dist/projectprivateconfig.js +347 -0
- package/dist/vendor/schema/dist/sitemap.js +1 -1
- package/dist/vendor/schema/dist/theme.js +1 -1
- package/package.json +21 -18
package/dist/cloud/uploadFile.js
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
!function(require, directRequire){
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.uploadFiles=void 0;const tslib_1=require("tslib"),log_1=(0,tslib_1.__importDefault)(require("../utils/log")),error_1=require("../utils/error"),config_1=require("../config"),locales_1=(0,tslib_1.__importDefault)(require("../utils/locales/locales")),request_1=require("../utils/request"),sign_1=require("../utils/sign"),urlConfig=(0,tslib_1.__importStar)(require("../utils/url_config")),utils_1=require("./utils"),{resolve:resolve,relative:relative}=require("path"),{readdir:readdir,readFile:readFile}=require("fs").promises,COS=require("cos-nodejs-sdk-v5"),requiredParams=["project","env","path"];async function uploadFiles(e,t){var r,i;const{currentEnv:o}=await(0,utils_1.initEnvironmentByProject)(e.project,e.env);requiredParams.forEach(t=>{if(!e[t])throw new error_1.CodeError(locales_1.default.config.PARAM_ERROR.format("cloud.storage",t),config_1.PARAM_ERROR)});const{project:a,remotePath:s="",path:n,concurrency:l=5}=e;let c=s.endsWith("/")?s:s+"/";if(c.startsWith("/")&&(c=c.slice(1)),"staticstorage"!==t)if("storage"!==t);else{const e=null===(i=o.storages)||void 0===i?void 0:i[0];if(!e)throw new Error(`invalid storage status: ${e}. exiting`);await beginUpload(n,e,c,a,l)}else{const e=null===(r=o.staticStorages)||void 0===r?void 0:r[0];if(!e||"online"!==e.status)throw new Error(`invalid static storage status: ${e.status}. exiting`);await beginUpload(n,e,c,a,l)}}async function beginUpload(e,t,r,i,o){const a=await getFiles(e),s=a.map(t=>relative(e,t));log_1.default.info("[storage]","done. begin upload to cos.");const n=await putObjectToCos(s.map((e,i)=>({Bucket:t.bucket,Region:t.region,Key:r+e,Body:a[i]})),i,t,o);log_1.default.info("[storage]",n)}async function getFiles(e){const t=await readdir(e,{withFileTypes:!0}),r=await Promise.all(t.map(t=>{const r=resolve(e,t.name);return t.isDirectory()?getFiles(r):r}));return Array.prototype.concat(...r)}async function putObjectToCos(e,t,r,i){const o=new COS({Proxy:(0,request_1.getCiProxy)(),getAuthorization:await getAuthorizationThunk(t,r)}),a=await callCiServerApi(t,"CLOUD_ROUTE_GETCOSMETA",{action:"batchencode",bucket:r.bucket,mpappid:t.appid,paths:e.map(e=>e.Key)},e=>JSON.parse(JSON.parse(e).data.data).x_cos_meta_field_strs),s=new Map(e.map((e,t)=>[e.Key,a[t]]));try{const t=e.length;let r="";const a=async e=>{if(!e)return;const t=await o.putObject(Object.assign(Object.assign({},e),{Body:await readFile(e.Body),Headers:{"x-cos-meta-fileid":s.get(e.Key)}}));return r=e.Key,t};for(await a(e.shift());e.length>0;){const o=e.splice(0,Math.min(e.length,i)).map(a);log_1.default.info(`[storage] Uploading ${t-e.length} / ${t}: ${r}`),await Promise.all(o)}return{success:!0}}catch(e){throw new Error("upload to cos failed: "+e.message)}}async function getAuthorizationThunk(e,t){return async function(r,i){var o;const a=Date.now(),s=await callCiServerApi(e,"CLOUD_ROUTE_GETCOSAUTH",{region:t.region,bucket:t.bucket}),n=null===(o=null==s?void 0:s.Response)||void 0===o?void 0:o.Credentials;if(!n)throw new Error("getFederalToken failed: "+JSON.stringify(n));i({TmpSecretId:n.TmpSecretId,TmpSecretKey:n.TmpSecretKey,XCosSecurityToken:n.Token,StartTime:~~(a/1e3),ExpiredTime:s.Response.ExpiredTime})}}async function callCiServerApi(e,t,r,i){const o=await(0,sign_1.getSignature)(e.privateKey,e.appid),a=await e.getExtAppid(),{resp:s,body:n}=await(0,request_1.request)({url:urlConfig.cloudCosUploadURL,method:"post",body:JSON.stringify({appid:e.appid,extAppid:a||void 0,signature:o,action:t,agentReq:r}),headers:{"content-type":"application/json"}});if(413===s.statusCode)throw new Error("Body too large");if(!n)throw new Error("Empty body "+JSON.stringify(s));if(i){return i(n)}const l="string"==typeof n?JSON.parse(n):n,c=JSON.parse(l.data.content);if(l.errCode)throw new Error(`${l.errCode} ${l.errMsg}`);return c}exports.uploadFiles=uploadFiles;
|
|
3
|
+
}(require("licia/lazyImport")(require), require)
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
!function(require, directRequire){
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.uploadFunction=void 0;const tslib_1=require("tslib"),cloudapi_1=require("./cloudapi"),cloudAPI=(0,tslib_1.__importStar)(require("../vendor/cloud-api")),utils_1=require("./utils"),log_1=(0,tslib_1.__importDefault)(require("../utils/log")),error_1=require("../utils/error"),config_1=require("../config"),locales_1=(0,tslib_1.__importDefault)(require("../utils/locales/locales")),HelloWordCode="UEsDBBQACAAIALB+WU4AAAAAAAAAAAAAAAAIABAAaW5kZXguanNVWAwAAZ9zXPuec1z1ARQAdY7BCsIwEETv+Yoll6ZQ+wOhnv0DD+IhxkWC664kWwmI/27V3IpzGuYNw3RzQSiaU9TOG6x3yVrGW0gMEzh8IOsAUVixfkwgOoV47WHawtPAooUVIRxJLs7ukEhgL5nOtl/h79qf+GBZeIM1FbXHdac9aKC9cDwTDfCb9eblzRtQSwcI6+pcr4AAAADOAAAAUEsBAhUDFAAIAAgAsH5ZTuvqXK+AAAAAzgAAAAgADAAAAAAAAAAAQKSBAAAAAGluZGV4LmpzVVgIAAGfc1z7nnNcUEsFBgAAAAABAAEAQgAAAMYAAAAAAA==",requiredParams=["project","name","path"];async function uploadFunction(e){requiredParams.forEach(t=>{if(!e[t])throw new error_1.CodeError(locales_1.default.config.PARAM_ERROR.format("cloud.uploadFunction",t),config_1.PARAM_ERROR)});const{project:t,remoteNpmInstall:o=!1,name:n,path:a,env:c}=e,i=await t.getExtAppid();(0,cloudapi_1.initCloudAPI)(i||t.appid),log_1.default.info(`will upload code under ${a} as cloudfunction '${n}' of env ${c}. remote-npm-install: ${o}`);const{envList:u}=await cloudAPI.tcbGetEnvironments({},{request:(0,cloudapi_1.boundTransactRequest)(t),transactType:cloudAPI.TransactType.IDE}),r=u.find(e=>e.envId===c);if(!r)throw new Error("env not found");const l=r.functions[0].region,{clsLogsetId:s,clsTopicId:d}=getLogServiceProperties(r),p=await(0,cloudapi_1.get3rdCloudCodeSecret)(t);log_1.default.info("checking cloudfunction status, will only proceed on normal status"),await waitFuncDeploy({namespace:c,region:l,functionName:n,codeSecret:p,topts:{request:(0,cloudapi_1.boundTransactRequest)(e.project),transactType:cloudAPI.TransactType.IDE}});let A,f=!1;try{if(A=await cloudAPI.scfGetFunctionInfo({namespace:c,region:"",functionName:n,codeSecret:p},{request:(0,cloudapi_1.boundTransactRequest)(t),transactType:cloudAPI.TransactType.IDE}),"DeleteFailed"===A.status)throw new Error("delete failed")}catch(e){if("ResourceNotFound.Function"!==e.code)throw e;f=!0}if(log_1.default.info("get cloudfunction info done"),log_1.default.info(`will ${f?"create":"update"} cloudfunction`),f)await cloudAPI.scfCreateFunction({functionName:n,code:{zipFile:HelloWordCode},handler:"index.main",description:"",memorySize:256,timeout:3,environment:{variables:[]},role:"TCB_QcsRole",runtime:"Nodejs8.9",namespace:c,region:l,stamp:"MINI_QCBASE",installDependency:o,codeSecret:p,clsLogsetId:s,clsTopicId:d},{request:(0,cloudapi_1.boundTransactRequest)(e.project),transactType:cloudAPI.TransactType.IDE}),log_1.default.info("create cloudfunction done, continue to update code");else{if("Updating"===A.status)throw new Error("there's another ongoing update, please wait for it to complete and try again later");const t=o?"TRUE":"FALSE";A.installDependency!==t&&(log_1.default.info("updating cloudfunction info"),await cloudAPI.scfUpdateFunctionInfo({namespace:c,region:l,functionName:n,installDependency:o,clsLogsetId:s,clsTopicId:d},{request:(0,cloudapi_1.boundTransactRequest)(e.project),transactType:cloudAPI.TransactType.IDE}),log_1.default.info("update cloudfunction info done, waiting for it to take into effect"),await waitFuncDeploy({namespace:c,region:l,functionName:n,codeSecret:p,topts:{request:(0,cloudapi_1.boundTransactRequest)(e.project),transactType:cloudAPI.TransactType.IDE}}),log_1.default.info("cloudfunction info updated"))}const g=(0,utils_1.zipFile)(a,{ignore:o?["node_modules"]:void 0}),I=await(0,utils_1.zipToBuffer)(g);log_1.default.info("zip file done, updating cloudfunction code"),await cloudAPI.scfUpdateFunction({functionName:n,namespace:c,region:l,handler:"index.main",installDependency:o,fileData:I.toString("base64"),codeSecret:p},{request:(0,cloudapi_1.boundTransactRequest)(e.project),transactType:cloudAPI.TransactType.IDE}),log_1.default.info("cloudfunction code updated, "+(o?"installing dependencies in the cloud and deploying":"deploying")),await waitFuncDeploy({namespace:c,region:l,functionName:n,codeSecret:p,topts:{request:(0,cloudapi_1.boundTransactRequest)(e.project),transactType:cloudAPI.TransactType.IDE}}),log_1.default.info("deployed");return{filesCount:Object.keys(g.files).length,packSize:I.byteLength}}exports.uploadFunction=uploadFunction;const waitFuncDeploy=async e=>new Promise(async(t,o)=>{let n=!1;const{namespace:a,region:c,functionName:i,onStatusUpdate:u=(t=>{log_1.default.info(`env ${e.namespace}'s cloudfunction '${e.functionName}' status: ${t}`)}),maxWaitTimeout:r=9e5,codeSecret:l}=e,s=setTimeout(()=>{n||(n=!0,o(new Error("timeout waiting for function to deploy")))},r);try{let o="";const s=+new Date;for(;!n&&+new Date-s<r;){const r=await cloudAPI.scfGetFunctionInfo({namespace:a,region:c,functionName:i,codeSecret:l},e.topts);switch(r.status!==o&&(u(r.status),o=r.status),r.status){case"Creating":case"Updating":case"Publishing":case"UpdatingAndPublishing":break;case"CreateFailed":throw new Error("create function failed: "+r.statusDesc);case"UpdateFailed":throw new Error("update function failed: "+r.statusDesc);case"Active":n=!0,t(void 0)}}}catch(e){try{log_1.default.error(`upload ${a} ${i} failed: `,"string"==typeof e?e:JSON.stringify(e))}catch(e){log_1.default.error(`upload ${a} ${i} failed: `,e.toString())}clearTimeout(s),o(e)}});function getLogServiceProperties(e){let t,o;try{const n=e.logServices[0];t=n.logsetId,o=n.topicId}catch(e){}return{clsLogsetId:t,clsTopicId:o}}
|
|
3
|
+
}(require("licia/lazyImport")(require), require)
|
package/dist/cloud/utils.js
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
!function(require, directRequire){
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.initEnvironmentByProject=exports.zipToBuffer=exports.zipFile=void 0;const tslib_1=require("tslib"),fs_1=(0,tslib_1.__importDefault)(require("fs")),path_1=(0,tslib_1.__importDefault)(require("path")),jszip_1=(0,tslib_1.__importDefault)(require("jszip")),minimatch_1=(0,tslib_1.__importDefault)(require("minimatch")),cloudapi_1=require("./cloudapi"),log_1=(0,tslib_1.__importDefault)(require("../utils/log")),cloudAPI=(0,tslib_1.__importStar)(require("../vendor/cloud-api")),minimatchWithList=(e,t)=>{if(!t)return!1;for(const i of t)if(i.startsWith("!")&&!(0,minimatch_1.default)(e,i))return!1;for(const i of t)if(!i.startsWith("!")&&(0,minimatch_1.default)(e,i))return!0;return!1},zipFile=(e,{ignore:t,name:i,zip:n=new jszip_1.default,includeRoot:r=!1}={})=>{if(!fs_1.default.existsSync(e))return n;const o=fs_1.default.lstatSync(e),s=i||path_1.default.basename(e);if(o.isSymbolicLink())n.file(s,fs_1.default.readlinkSync(e),{unixPermissions:parseInt("120"+parseInt((o.mode&parseInt("777",8)).toString(8),10),8)});else if(o.isDirectory()){r&&n.folder(s);const i=fs_1.default.readdirSync(e);for(let o=0,a=i.length;o<a;o++){const a=i[o],l=r?path_1.default.posix.join(s,a):a;t&&minimatchWithList(l,t)||(0,exports.zipFile)(path_1.default.join(e,a),{zip:n,ignore:t,name:l,includeRoot:!0})}}else n.file(s,fs_1.default.readFileSync(e),{binary:!0,unixPermissions:o.mode});return n};exports.zipFile=zipFile;const zipToBuffer=(e,t)=>e.generateAsync({type:"nodebuffer",platform:"darwin"===process.platform?"UNIX":"DOS",compression:"DEFLATE",compressionOptions:{level:9}},t);async function initEnvironmentByProject(e,t){const i=await e.getExtAppid();(0,cloudapi_1.initCloudAPI)(i||e.appid),log_1.default.info("[cloud] loading env info");const n={request:(0,cloudapi_1.boundTransactRequest)(e),transactType:cloudAPI.TransactType.IDE};cloudAPI.setRequest((0,cloudapi_1.boundTransactRequest)(e)),cloudAPI.setTransactType(cloudAPI.TransactType.IDE);const[r,o]=await Promise.all([cloudAPI.tcbGetEnvironments({},n),cloudAPI.tcbDescribeWxCloudBaseRunEnvs({})]),s=[...r.envList,...o.envList].find(e=>e.envId===t);if(!s)throw new Error("env not found");return{currentEnv:s,cloudAPI:cloudAPI}}exports.zipToBuffer=zipToBuffer,exports.initEnvironmentByProject=initEnvironmentByProject;
|
|
3
|
+
}(require("licia/lazyImport")(require), require)
|
package/dist/config.js
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
!function(require, directRequire){
|
|
2
|
+
"use strict";var COMPILE_TYPE;Object.defineProperty(exports,"__esModule",{value:!0}),exports.extendedLibMap=exports.jsonVariablePropertyWhiteList=exports.DefaultProjectAttr=exports.TABBAR_ICON_WHITE_LIST=exports.COMPILE_TYPE=exports.APP_TYPE=exports.MINI_GAME_MAIN_PACKAGE_ROOT=exports.MINI_PROGRAM_MAIN_PACKAGE_ROOT=exports.PROJECT_TYPE_ERROR=exports.GET_LATEST_VERSION_CGI_ERR=exports.UPLOAD_JS_SERVER_CGI_ERR=exports.CODE_PROTECT_TRANSLATE_FILENAME=exports.UPLOAD_CGI_ERR=exports.GENERATE_LOCAL_SIGNATURE_ERR=exports.GET_SIGNATURE_RAND_STRING_ERR=exports.APP_JSON_NOT_FOUND=exports.JSON_CONTENT_ERR=exports.FILE_NOT_UTF8=exports.JSON_PARSE_ERR=exports.FILE_NOT_FOUND=exports.PLUGIN_JSON_PARSE_ERR=exports.PLUGIN_JSON_CONTENT_ERR=exports.PLUGIN_JSON_FILE_NOT_FOUND=exports.GAME_PLUGIN_LIB_MD5_NOT_MATCH=exports.SUMMER_PLUGIN_CODE_ERR=exports.SUMMER_PLUGIN_ERR=exports.MINIFY_WXML_ERR=exports.POST_WXSS_ERR=exports.FILE_FLAT_ERR=exports.JS_ES6_ERR=exports.BABILI_JS_ERR=exports.UGLIFY_JS_ERR=exports.BABEL_TRANS_JS_ERR=exports.JS_NOT_FOUND=exports.WXML_NOT_FOUND=exports.PARAM_ERROR=exports.CI_VERSION=void 0,exports.CI_VERSION="1.8.12",exports.PARAM_ERROR=1e4,exports.WXML_NOT_FOUND=10007,exports.JS_NOT_FOUND=10008,exports.BABEL_TRANS_JS_ERR=10032,exports.UGLIFY_JS_ERR=10033,exports.BABILI_JS_ERR=10034,exports.JS_ES6_ERR=10035,exports.FILE_FLAT_ERR=10036,exports.POST_WXSS_ERR=10037,exports.MINIFY_WXML_ERR=10038,exports.SUMMER_PLUGIN_ERR=10045,exports.SUMMER_PLUGIN_CODE_ERR=10046,exports.GAME_PLUGIN_LIB_MD5_NOT_MATCH=10081,exports.PLUGIN_JSON_FILE_NOT_FOUND=10091,exports.PLUGIN_JSON_CONTENT_ERR=10092,exports.PLUGIN_JSON_PARSE_ERR=10093,exports.FILE_NOT_FOUND=10005,exports.JSON_PARSE_ERR=10006,exports.FILE_NOT_UTF8=10031,exports.JSON_CONTENT_ERR=10009,exports.APP_JSON_NOT_FOUND=2e4,exports.GET_SIGNATURE_RAND_STRING_ERR=20001,exports.GENERATE_LOCAL_SIGNATURE_ERR=20002,exports.UPLOAD_CGI_ERR=20003,exports.CODE_PROTECT_TRANSLATE_FILENAME=20004,exports.UPLOAD_JS_SERVER_CGI_ERR=20005,exports.GET_LATEST_VERSION_CGI_ERR=20006,exports.PROJECT_TYPE_ERROR=3e4,exports.MINI_PROGRAM_MAIN_PACKAGE_ROOT="__APP__",exports.MINI_GAME_MAIN_PACKAGE_ROOT="__GAME__",exports.APP_TYPE={NORMAL:0,PLUGIN:1,SHOP:2,MINISHOP:3,GAME:4,CARD:5,NATIVE:7},function(_){_.miniProgram="miniProgram",_.miniProgramPlugin="miniProgramPlugin",_.miniGame="miniGame",_.miniGamePlugin="miniGamePlugin"}(COMPILE_TYPE=exports.COMPILE_TYPE||(exports.COMPILE_TYPE={})),exports.TABBAR_ICON_WHITE_LIST=[".png",".jpg",".jpeg"],exports.DefaultProjectAttr={platform:!1,appType:0,isSandbox:!1,released:!1,setting:{MaxCodeSize:2,MaxSubpackageSubCodeSize:2,MaxSubpackageFullCodeSize:12,NavigateMiniprogramLimit:10,MaxSubPackageLimit:100,MinTabbarCount:2,MaxTabbarCount:5,MaxTabbarIconSize:40}},exports.jsonVariablePropertyWhiteList={windowPropertWhiteList:["navigationBarBackgroundColor","navigationBarTextStyle","backgroundColor","backgroundTextStyle","backgroundColorTop","backgroundColorBottom","backgroundColorContent"],tabBarPropertyWhiteList:["color","selectedColor","backgroundColor","borderStyle"],tabbarListItemPropertyWhiteList:["iconPath","selectedIconPath"]},exports.extendedLibMap={kbone:{packages:["miniprogram-element","miniprogram-render"]},weui:{packages:["weui-miniprogram"]}};
|
|
3
|
+
}(require("licia/lazyImport")(require), require)
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
!function(require, directRequire){
|
|
2
|
+
"use strict";function findAllDescendant(e,t){let n;n=Array.isArray(e)?e:[e];const s=n.slice(0),a=[],o=[];for(;s.length>0;){const e=s.pop();a.push(e),e.childModules.forEach(e=>{s.indexOf(e)<0&&a.indexOf(e)<0&&(s.push(e),e.type===t&&o.push(e))})}return o}function findModsByType(e,t){var n;return(null===(n=null==e?void 0:e.graph)||void 0===n?void 0:n.modules.filter(e=>e.type===t))||[]}function findModByTypeAndPath(e,t,n){var s;return null===(s=e.graph)||void 0===s?void 0:s.modules.find(e=>e.type===t&&e.path===n)}function findPageMods(e,t){return(findModsByType(e,"Page")||[]).filter(e=>t.includes(e.path.replace(/\.json$/,"")))}function findGlobalCompMods(e){const t=findModByTypeAndPath(e,"MainPackage","app.json");return(null==t?void 0:t.childModules.filter(e=>"Component"===e.type))||[]}function getAllSubpackagePath(e){return findModsByType(e,"SubPackage").map(e=>e.path)}function innerGetSortedJSFiles(e,t){const n=new Set,s=new Set,a=new Set,o=[];for(const t of e){const e=t.findChild("Js");e&&(t.config?a.add(e.path):s.add(e.path),n.add(e.path),o.push(e))}const i=findAllDescendant(e.concat(t),"Component");for(const e of i.concat(t)){const t=e.findChild("Js");t&&(a.add(t.path),n.add(t.path),o.push(t))}const l=findAllDescendant(o,"Js");for(const e of l){const t=e.path;n.add(t)}return{allFiles:Array.from(n),pageFiles:Array.from(s),componentFiles:Array.from(a)}}function groupBySubpackage(e,t){const n=[],s={};for(const a of e){const e=t.find(e=>a.startsWith(e));e?(s[e]||(s[e]=[]),s[e].push(a)):n.push(a)}return{main:n,subs:s}}function partialGetSubPkgSortedJSFiles(e,t,n){const s=findPageMods(e,t);let{allFiles:a,pageFiles:o,componentFiles:i}=innerGetSortedJSFiles(s,[]);const l=getAllSubpackagePath(e);return{allFiles:groupBySubpackage(a,l).subs[n]||[],pageFiles:groupBySubpackage(o,l).subs[n]||[],componentFiles:groupBySubpackage(i,l).subs[n]||[]}}function partialGetMainPkgSortedJSFiles(e,t){const n=findPageMods(e,t),s=findGlobalCompMods(e);let{allFiles:a,pageFiles:o,componentFiles:i}=innerGetSortedJSFiles(n,s),l=!1;const p=findModByTypeAndPath(e,"Js","app.js");if(p){l=!0,a.push(p.path);const e=findAllDescendant([p],"Js");for(const t of e){const e=t.path;a.indexOf(e)<0&&a.push(e)}}const r=getAllSubpackagePath(e);return{hasAppJS:l,allFiles:groupBySubpackage(a,r).main,pageFiles:groupBySubpackage(o,r).main,componentFiles:groupBySubpackage(i,r).main}}function partialWholePkgGetSortedJSFiles(e,t){const n=findPageMods(e,t),s=findGlobalCompMods(e);let{allFiles:a,pageFiles:o,componentFiles:i}=innerGetSortedJSFiles(n,s),l=!1;const p=findModByTypeAndPath(e,"Js","app.js");if(p){l=!0,a.push(p.path);const e=findAllDescendant([p],"Js");for(const t of e){const e=t.path;a.indexOf(e)<0&&a.push(e)}}return{hasAppJS:l,allFiles:a,pageFiles:o,componentFiles:i}}function innerGetResourceFiles(e,t){let n=[];for(const s of e){n=findAllDescendant(e,t).map(e=>e.path)}return n}function partialGetWxmlAndWxsFiles(e,t,n){const s=findPageMods(e,t),a=findGlobalCompMods(e),o=innerGetResourceFiles(s.concat(a),"Wxml"),i=innerGetResourceFiles(s.concat(a),"Wxs"),l=getAllSubpackagePath(e),p=groupBySubpackage(o,l),r=groupBySubpackage(i,l);return{wxmlFiles:n?p.main.concat(p.subs[n]||[]):p.main,wxsFiles:n?r.main.concat(r.subs[n]||[]):r.main}}function partialGetWxssFiles(e,t,n){const s=findPageMods(e,t),a=findGlobalCompMods(e),o=innerGetResourceFiles(s.concat(a),"Wxss"),i=findModByTypeAndPath(e,"Wxss","app.wxss");if(i&&!o.includes(i.path)){o.push(i.path);const e=findAllDescendant(i,"Wxss");for(const t of e)o.includes(t.path)||o.push(t.path)}const l=groupBySubpackage(o,getAllSubpackagePath(e));return n?l.main.concat(l.subs[n]||[]):l.main}function partialGetCodeFiles(e,t){const n=new Set,s=findModByTypeAndPath(e,"MainPackage","app.json");n.add("app.json");const a=new Set;function o(e){switch(a.add(e),e.type){case"Page":case"Component":case"Wxml":case"Wxss":case"Wxs":case"Js":case"Config":n.add(e.path)}for(const t of e.childModules)a.has(t)||o(t)}for(const e of null==s?void 0:s.childModules)if("Page"===e.type)t.includes(e.path.replace(/\.json$/,""))&&o(e);else if("SubPackage"===e.type)for(const n of e.childModules)t.includes(n.path.replace(/\.json$/,""))&&o(n);else o(e);return console.log("[partial-compile] compile",n),Array.from(n)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.partialGetCodeFiles=exports.partialGetWxssFiles=exports.partialGetWxmlAndWxsFiles=exports.partialWholePkgGetSortedJSFiles=exports.partialGetMainPkgSortedJSFiles=exports.partialGetSubPkgSortedJSFiles=exports.findAllDescendant=void 0,exports.findAllDescendant=findAllDescendant,exports.partialGetSubPkgSortedJSFiles=partialGetSubPkgSortedJSFiles,exports.partialGetMainPkgSortedJSFiles=partialGetMainPkgSortedJSFiles,exports.partialWholePkgGetSortedJSFiles=partialWholePkgGetSortedJSFiles,exports.partialGetWxmlAndWxsFiles=partialGetWxmlAndWxsFiles,exports.partialGetWxssFiles=partialGetWxssFiles,exports.partialGetCodeFiles=partialGetCodeFiles;
|
|
3
|
+
}(require("licia/lazyImport")(require), require)
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
!function(require, directRequire){
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getUploadProjectConfig=exports.compileWXMLFiles=exports.compileWXSSFiles=exports.compileJSFiles=exports.compileOther=exports.isNotIgnoredByProjectConfig=exports.getBabelRoot=void 0;const tslib_1=require("tslib"),babel_helper_1=require("../../utils/babel_helper"),js_1=require("./handler/js"),wxss_1=require("./handler/wxss"),wxml_1=require("./handler/wxml"),tools_1=require("../../utils/tools"),taskstatus_1=require("../../utils/taskstatus"),index_1=require("../worker_thread/index"),path_1=(0,tslib_1.__importDefault)(require("path")),projectconfig_1=require("../json/projectconfig"),game_1=(0,tslib_1.__importDefault)(require("../json/game")),signaturejson_1=require("../json/signaturejson"),config_1=require("../../config");async function getBabelRoot(o){var e,t;const i=await(0,projectconfig_1.getProjectConfigJSON)(o);let s=null===(t=null===(e=null==i?void 0:i.setting)||void 0===e?void 0:e.babelSetting)||void 0===t?void 0:t.outputPath;return s?(s=(0,tools_1.normalizePath)(s),s.replace(/(^[./\\])|(\/$)/g,""),s):"@babel/runtime"}function isNotIgnoredByProjectConfig(o,e,t){var i,s;const n=path_1.default.posix.relative(e,t),a=(null===(i=o.packOptions)||void 0===i?void 0:i.include)||[];if((0,tools_1.isFileIncluded)(n,a))return!0;const l=(null===(s=o.packOptions)||void 0===s?void 0:s.ignore)||[];return!(0,tools_1.isFileIgnored)(path_1.default.posix.relative(e,t),l)}async function copyFile(o,e){return{filePath:e,code:await o.getFile("",e)}}async function compileOther(o,e,t){const{onProgressUpdate:i=(()=>{})}=t,s=new taskstatus_1.TaskStatus("compiling other files");i(s);const n=[];for(const t of e)n.push(copyFile(o,t));const a=await Promise.all(n),l={};for(const o of a){const{code:e,filePath:t}=o;e&&(l[t]=e)}return s.done(),i(s),l}async function canWeCompileJS(o,e,t){let i;for(const o of e)if((0,tools_1.normalizePath)(t).startsWith((0,tools_1.normalizePath)((0,signaturejson_1.trailing)(o.fullPath,"/")))){i=o;break}if(i){return i.signature.findIndex(o=>(0,tools_1.normalizePath)(o.fullPath)===(0,tools_1.normalizePath)(t))>=0}return!0}async function compileJSFiles(o,e,t,i){const{setting:s={}}=i;let n="@babel/runtime";s.es7&&(n=await getBabelRoot(o));const a=[];if(o.type===config_1.COMPILE_TYPE.miniGame||o.type===config_1.COMPILE_TYPE.miniGamePlugin){const s=await(0,signaturejson_1.getAllPluginSignatures)(o);for(const l of e){const e=path_1.default.join(o.projectPath,t,l);await canWeCompileJS(o,s,e)&&a.push((0,js_1.compileJS)(o,l,Object.assign(Object.assign({},i),{babelRoot:n,root:t})))}}else for(const s of e)a.push((0,js_1.compileJS)(o,s,Object.assign(Object.assign({},i),{babelRoot:n,root:t})));let l=[];try{l=await Promise.all(a)}catch(o){throw(0,index_1.abortTask)(index_1.TASK_NAME.COMPILE_JS),o}const r={},c=new Set;for(const o of l){const{filePath:e,map:i,code:s,helpers:n}=o,a=(0,tools_1.formatSourceMap)(i);void 0!==s&&(r[path_1.default.posix.normalize(path_1.default.posix.join(t,e))]=s),a&&(r[path_1.default.posix.normalize(path_1.default.posix.join(t,e+".map"))]=a),n.length>0&&n.forEach(o=>{c.add(o)})}return await(0,babel_helper_1.appendBabelHelpers)(c,path_1.default.join(t),n,r),r}async function compileWXSSFiles(o,e,t,i){const s=[];for(const n of e)s.push((0,wxss_1.compileWXSS)(o,n,Object.assign(Object.assign({},i),{root:t})));let n=[];try{n=await Promise.all(s)}catch(o){throw(0,index_1.abortTask)(index_1.TASK_NAME.COMPILE_WXSS),o}const a={};for(const o of n){const{filePath:e,code:i}=o;void 0!==i&&(a[path_1.default.posix.normalize(path_1.default.posix.join(t,e))]=i)}return a}async function compileWXMLFiles(o,e,t,i){const s=[];for(const n of e)s.push((0,wxml_1.compileWXML)(o,n,Object.assign(Object.assign({},i),{root:t})));let n=[];try{n=await Promise.all(s)}catch(o){throw(0,index_1.abortTask)(index_1.TASK_NAME.MINIFY_WXML),o}const a={};for(const o of n){const{filePath:e,code:i}=o;void 0!==i&&(a[path_1.default.posix.normalize(path_1.default.posix.join(t,e))]=i)}return a}async function getUploadProjectConfig(o,e){const t={miniprogramRoot:e.miniprogramRoot,localPlugins:[]};e.pluginRoot&&(t.pluginRoot=e.pluginRoot);const i=await(0,game_1.default)(o),s=(o,e="")=>{const i=t.localPlugins||[];for(const t in o)if(o.hasOwnProperty(t)&&o[t]&&"string"==typeof o[t].path){const s=o[t],n=path_1.default.posix.normalize(path_1.default.posix.join(e,s.path.replace(/\\/g,"/")).replace(/^\/+/,""));i.push({alias:t,provider:s.provider,path:n})}t.localPlugins=i};if(i.plugins){s(i.plugins)}const n=i.subpackages||i.subPackages;if(Array.isArray(n))for(const o of n)(null==o?void 0:o.plugins)&&s(o.plugins,o.root||"");return t}exports.getBabelRoot=getBabelRoot,exports.isNotIgnoredByProjectConfig=isNotIgnoredByProjectConfig,exports.compileOther=compileOther,exports.compileJSFiles=compileJSFiles,exports.compileWXSSFiles=compileWXSSFiles,exports.compileWXMLFiles=compileWXMLFiles,exports.getUploadProjectConfig=getUploadProjectConfig;
|
|
3
|
+
}(require("licia/lazyImport")(require), require)
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
!function(require, directRequire){
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compile=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),game_1=(0,tslib_1.__importDefault)(require("../json/game")),projectconfig_1=require("../json/projectconfig"),common_1=require("./common"),taskstatus_1=require("../../utils/taskstatus"),config_1=require("../../config"),common_2=require("../../utils/common"),locales_1=(0,tslib_1.__importDefault)(require("../../utils/locales/locales")),white_ext_list_1=require("../../utils/white_ext_list"),uglifyfilenames_1=require("../protect/uglifyfilenames");async function compileGameJSON(e,t){const{onProgressUpdate:o=(()=>{})}=t,i=new taskstatus_1.TaskStatus("game.json");o(i);const a=await(0,game_1.default)(e);return i.done(),o(i),a}async function compile(e,t){var o;const i=await(0,projectconfig_1.getProjectConfigJSON)(e);!1===(await e.attr()).gameApp&&(0,common_2.throwError)({filePath:"",msg:locales_1.default.config.PROJECT_TYPE_ERROR.format(e.appid,locales_1.default.config.MINI_PROGRAM),code:config_1.PROJECT_TYPE_ERROR});const a=i.miniprogramRoot||"",{GameWhiteList:s}=await(0,white_ext_list_1.getWhiteExtList)(),n=e.getFileList(a,"").filter(common_1.isNotIgnoredByProjectConfig.bind(null,i,a)).filter(e=>s.has(path_1.default.posix.extname(e))),r=await compileGameJSON(e,t);e.stat(a,"game.js")||(0,common_2.throwError)({msg:locales_1.default.config.FILE_NOT_FOUND.format(path_1.default.posix.join(a,"game.js")),filePath:path_1.default.posix.join(a,"game.js"),code:config_1.FILE_NOT_FOUND});const l=n.filter(e=>".js"===path_1.default.posix.extname(e)).map(e=>path_1.default.posix.relative(a,e)),m=await(0,common_1.compileJSFiles)(e,l,a,t),_=n.filter(e=>e!==path_1.default.posix.join(a,"game.json")&&".js"!==path_1.default.posix.extname(e)),c=await(0,common_1.compileOther)(e,_,t),p=await(0,common_1.getUploadProjectConfig)(e,i);let f=Object.assign(Object.assign({},m),c);if(e.type===config_1.COMPILE_TYPE.miniGame){if(p.miniprogramRoot&&"."!==p.miniprogramRoot&&"./"!==p.miniprogramRoot){const t={};for(const o in f)t[path_1.default.posix.relative(e.miniprogramRoot,o)]=f[o];f=t}p.miniprogramRoot="",f["game.json"]=JSON.stringify(r)}else f[path_1.default.posix.join(p.miniprogramRoot||"","game.json")]=JSON.stringify(r);return p.__compileDebugInfo__=t.__compileDebugInfo__||{},f["project.config.json"]=JSON.stringify(p),delete f["project.private.config.json"],e.type===config_1.COMPILE_TYPE.miniGame&&(null===(o=t.setting)||void 0===o?void 0:o.codeProtect)&&(f=await(0,uglifyfilenames_1.uglifyFileNames)(e,f)),f}exports.compile=compile;
|
|
3
|
+
}(require("licia/lazyImport")(require), require)
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
!function(require, directRequire){
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compile=exports.compilePlugin=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),projectconfig_1=require("../json/projectconfig"),common_1=require("./common"),plugin_1=require("../json/plugin/plugin"),game_1=require("./game"),white_ext_list_1=require("../../utils/white_ext_list");async function compilePlugin(e,i){const t=await(0,projectconfig_1.getProjectConfigJSON)(e),o=t.pluginRoot,{GameWhiteList:n}=await(0,white_ext_list_1.getWhiteExtList)(),l=e.getFileList(o,"").filter(common_1.isNotIgnoredByProjectConfig.bind(null,t,o)).filter(e=>n.has(path_1.default.posix.extname(e))),a=await(0,plugin_1.getDevPluginJSON)(e,!1),s=l.filter(e=>".js"===path_1.default.posix.extname(e)).map(e=>path_1.default.posix.relative(o,e)),p=await(0,common_1.compileJSFiles)(e,s,o,i),c=l.filter(e=>".js"!==path_1.default.posix.extname(e)&&e!==path_1.default.posix.join(o,"plugin.json")),r=await(0,common_1.compileOther)(e,c,i);return Object.assign(Object.assign({[path_1.default.posix.join(o,"plugin.json")]:JSON.stringify(a)},p),r)}async function compile(e,i){const t=await(0,projectconfig_1.getProjectConfigJSON)(e),o=await compilePlugin(e,i),n=await(0,game_1.compile)(e,i),l=await(0,common_1.getUploadProjectConfig)(e,t);return l.__compileDebugInfo__=i.__compileDebugInfo__||{},Object.assign(Object.assign(Object.assign({},o),n),{"project.config.json":JSON.stringify(l)})}exports.compilePlugin=compilePlugin,exports.compile=compile;
|
|
3
|
+
}(require("licia/lazyImport")(require), require)
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
!function(require, directRequire){
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compileJS=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),taskstatus_1=require("../../../utils/taskstatus"),worker_thread_1=require("../../worker_thread"),common_1=require("../../../utils/common"),config_1=require("../../../config"),tools_1=require("../../../utils/tools"),app_1=require("../../json/app"),common_2=require("../../json/common"),projectconfig_1=require("../../json/projectconfig"),game_1=(0,tslib_1.__importDefault)(require("../../json/game")),core_1=require("../../../core");async function formatBabelRoot(e,t,o,r){const a=e.type;if(a===config_1.COMPILE_TYPE.miniProgram){const t=await(0,app_1.getAppJSON)(e),a=(0,common_2.checkPagePathIsInIndependentSubpackage)(t,o);a&&(r=`${a.root}/${r}`),"object"==typeof t.functionalPages&&!0===t.functionalPages.independent&&o.startsWith("functional-pages/")&&(r="functional-pages/"+r),"string"==typeof t.openDataContext&&o.startsWith(t.openDataContext)&&(r=`${t.openDataContext}/${r}`),"string"==typeof t.workers&&o.startsWith(t.workers)&&(r=`${t.workers}/${r}`)}else if(a===config_1.COMPILE_TYPE.miniGame){const t=await(0,game_1.default)(e),a=(0,common_2.checkFilePathIsInIndependentSubpackage)(t,o);a&&(r=`${a}/${r}`),"string"==typeof t.openDataContext&&o.startsWith(t.openDataContext)&&(r=`${t.openDataContext}/${r}`),"string"==typeof t.workers&&o.startsWith(t.workers)&&(r=`${t.workers}/${r}`)}else if(a===config_1.COMPILE_TYPE.miniProgramPlugin||a===config_1.COMPILE_TYPE.miniGamePlugin){const t=await(0,core_1.getPluginJSON)(e);"string"==typeof t.workers&&o.startsWith(t.workers)&&(r=`${t.workers}/${r}`)}return(0,tools_1.normalizePath)(""+r)}async function compileJS(e,t,o){var r,a;const{setting:i={},onProgressUpdate:n=(()=>{}),root:s="",devToolsCompileCache:c}=o,l=path_1.default.posix.join(s,t);let p=[],_=o.babelRoot||"@babel/runtime";if(i.es7){const o=await(0,projectconfig_1.getProjectConfigJSON)(e);p=(null===(a=null===(r=o.setting)||void 0===r?void 0:r.babelSetting)||void 0===a?void 0:a.ignore)||[],_=await formatBabelRoot(e,s,t,_)}const u=new taskstatus_1.TaskStatus(t),g=o.sourceCode?o.sourceCode:await e.getFile(s,t);async function f(){const o=await(0,worker_thread_1.runTask)(worker_thread_1.TASK_NAME.COMPILE_JS,{projectPath:e.projectPath,root:s,filePath:t,setting:i,code:g,babelRoot:_,babelIgnore:p},e=>{e===worker_thread_1.ETaskStatus.progress?n(u):e===worker_thread_1.ETaskStatus.done&&(u.done(),n(u))});return o.error&&(0,common_1.throwError)({msg:o.error.message,code:o.error.code,filePath:l}),o}let m={};if(c){const o=(0,tools_1.normalizePath)(path_1.default.posix.join(e.projectPath,s,t)),r=`${o}_${JSON.stringify(i)}`;m=await c.getFile(o,r),m&&!i.codeProtect||(m=await f(),c.setFile(o,m,r))}else m=await f();return Object.assign({filePath:t},m)}exports.compileJS=compileJS;
|
|
3
|
+
}(require("licia/lazyImport")(require), require)
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
!function(require, directRequire){
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compileJSON=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),app_1=require("../../json/app"),getExtJSON_1=require("../../json/app/getExtJSON"),common_1=require("../../../utils/common"),getPageJSON_1=require("../../json/page/getPageJSON"),taskstatus_1=require("../../../utils/taskstatus"),projectconfig_1=require("../../json/projectconfig"),common_2=require("../common");async function compilePageJSON(t,e,o,a){const{onProgressUpdate:s=(()=>{})}=a,n={};for(const a of e){const e=new taskstatus_1.TaskStatus(a);s(e),n[path_1.default.posix.join(o,a+".json")]=await(0,getPageJSON_1.getPageJSON)(t,{miniprogramRoot:o,pagePath:a}),e.done(),s(e)}return n}async function compileJSON(t,e){const{onProgressUpdate:o=(()=>{})}=e,a=await(0,projectconfig_1.getProjectConfigJSON)(t),{miniprogramRoot:s=""}=a;let n=new taskstatus_1.TaskStatus("app.json");o(n);const i=await(0,app_1.getAppJSON)(t);let r;n.done(),o(n);const p=await t.attr();(null==p?void 0:p.platform)&&(n=new taskstatus_1.TaskStatus("ext.json"),o(n),r=await(0,getExtJSON_1.getExtJSON)(t),n.done(),o(n));const c=(0,common_1.getAllPages)(i),l=await compilePageJSON(t,c,s,e),g=new Set(["app.json","ext.json"].concat(c.map(t=>t+".json"))),u=(0,common_1.getAllTargetTypeFilesWithOtherTypeFilesOfSameName)(t,".json",[".wxml",".js"],s).filter(common_2.isNotIgnoredByProjectConfig.bind(null,a,s)).filter(t=>{const e=path_1.default.posix.relative(s,t);return!g.has(e)}).map(t=>path_1.default.posix.relative(s,t).replace(/\.json$/,"")),m=await compilePageJSON(t,u,s,e);u.forEach(t=>g.add(t+".json"));const j=t.getFileList(s,".json").filter(common_2.isNotIgnoredByProjectConfig.bind(null,a,s)).filter(t=>{const e=path_1.default.posix.relative(s,t);return!g.has(e)}),_=await(0,common_2.compileOther)(t,j,e),f=Object.assign(Object.assign(Object.assign({[path_1.default.posix.join(s,"app.json")]:i},l),m),_);r&&(f[path_1.default.posix.join(s,"ext.json")]=r);const O={};for(const t in f){const e=f[t];let o;o="[object Uint8Array]"===Object.prototype.toString.call(e)?e.toString():JSON.stringify(e),O[t]=o}return O}exports.compileJSON=compileJSON;
|
|
3
|
+
}(require("licia/lazyImport")(require), require)
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
!function(require, directRequire){
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compileWXML=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),tools_1=require("../../../utils/tools"),locales_1=(0,tslib_1.__importDefault)(require("../../../utils/locales/locales")),config_1=require("../../../config"),taskstatus_1=require("../../../utils/taskstatus"),worker_thread_1=require("../../worker_thread"),common_1=require("../../../utils/common");async function compileWXML(e,r,t){const{root:o="",setting:s={},onProgressUpdate:i=(()=>{})}=t,{minify:a,minifyWXML:_}=s,l=new taskstatus_1.TaskStatus(r),c=path_1.default.posix.join(o,r),n=await e.getFile(o,r);if(!a&&!_){i(l);const e=(0,tools_1.bufferToUtf8String)(n);return void 0===e&&(0,common_1.throwError)({msg:locales_1.default.config.FILE_NOT_UTF8.format(c),code:config_1.FILE_NOT_UTF8,filePath:c}),l.done(),i(l),{filePath:r,code:e.replace(/\r\n/g,"\n")}}const u=await(0,worker_thread_1.runTask)(worker_thread_1.TASK_NAME.MINIFY_WXML,{projectPath:e.projectPath,root:o,filePath:r,setting:s,code:n},e=>{e===worker_thread_1.ETaskStatus.progress?i(l):e===worker_thread_1.ETaskStatus.done&&(l.done(),i(l))});return u.error&&(0,common_1.throwError)({msg:u.error.message,code:u.error.code,filePath:c}),{filePath:r,code:u.code.replace(/\r\n/g,"\n")}}exports.compileWXML=compileWXML;
|
|
3
|
+
}(require("licia/lazyImport")(require), require)
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
!function(require, directRequire){
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compileWXSS=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),tools_1=require("../../../utils/tools"),locales_1=(0,tslib_1.__importDefault)(require("../../../utils/locales/locales")),config_1=require("../../../config"),taskstatus_1=require("../../../utils/taskstatus"),worker_thread_1=require("../../worker_thread"),common_1=require("../../../utils/common");async function compileWXSS(e,t,o){const{root:r="",setting:i={},onProgressUpdate:s=(()=>{}),devToolsCompileCache:a}=o,{minify:l,minifyWXSS:_,autoPrefixWXSS:c}=i,n=new taskstatus_1.TaskStatus(t),u=path_1.default.posix.join(r,t),f=await e.getFile(r,t);if(!l&&!_&&!c){s(n);const e=(0,tools_1.bufferToUtf8String)(f);return void 0===e&&(0,common_1.throwError)({msg:locales_1.default.config.FILE_NOT_UTF8.format(u),code:config_1.FILE_NOT_UTF8,filePath:u}),n.done(),s(n),{filePath:t,code:e}}async function d(){const o=await(0,worker_thread_1.runTask)(worker_thread_1.TASK_NAME.COMPILE_WXSS,{projectPath:e.projectPath,root:r,filePath:t,setting:i,code:f},e=>{e===worker_thread_1.ETaskStatus.progress?s(n):e===worker_thread_1.ETaskStatus.done&&(n.done(),s(n))});return o.error&&(0,common_1.throwError)({msg:o.error.message,code:o.error.code,filePath:u}),o.code}let h="";if(a){const o=(0,tools_1.normalizePath)(path_1.default.posix.join(e.projectPath,r,t)),s=`${o}_${JSON.stringify(i)}`;h=await a.getFile(o,s),h&&!i.codeProtect||(h=await d(),a.setFile(o,h,s))}else h=await d();return{filePath:t,code:h}}exports.compileWXSS=compileWXSS;
|
|
3
|
+
}(require("licia/lazyImport")(require), require)
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
!function(require, directRequire){
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compile=void 0;const game_1=require("./game"),mini_program_1=require("./mini_program"),mini_program_plugin_1=require("./mini_program_plugin"),game_plugin_1=require("./game_plugin"),config_1=require("../../config"),reactiveCache_1=require("../json/reactiveCache");async function compile(e,i){const o=(0,reactiveCache_1.tryToGetReactiveProject)(e);return await o.updateProject(),i.__compileDebugInfo__?i.__compileDebugInfo__.ciVersion=config_1.CI_VERSION:i.__compileDebugInfo__={from:"ci",useNewCompileModule:!0,devtoolsVersion:"0",compileSetting:i.setting,ciVersion:config_1.CI_VERSION},process.env.isDevtools&&(e.nameMappingFromDevtools=i.nameMapping||{}),e.type===config_1.COMPILE_TYPE.miniGame?(0,game_1.compile)(e,i):e.type===config_1.COMPILE_TYPE.miniProgramPlugin?(0,mini_program_plugin_1.compile)(e,i):e.type===config_1.COMPILE_TYPE.miniGamePlugin?(0,game_plugin_1.compile)(e,i):(0,mini_program_1.compile)(e,i)}exports.compile=compile;
|
|
3
|
+
}(require("licia/lazyImport")(require), require)
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
!function(require, directRequire){
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compile=void 0;const tslib_1=require("tslib"),common_1=require("./common"),mpjson_1=require("./handler/mpjson"),white_ext_list_1=require("../../utils/white_ext_list"),config_1=require("../../config"),common_2=require("../../utils/common"),path_1=(0,tslib_1.__importDefault)(require("path")),projectconfig_1=require("../json/projectconfig"),locales_1=(0,tslib_1.__importDefault)(require("../../utils/locales/locales")),uglifyfilenames_1=require("../protect/uglifyfilenames"),partial_1=require("../analyse/partial"),lodash_1=(0,tslib_1.__importDefault)(require("lodash")),summer=(0,tslib_1.__importStar)(require("../../summer/ci"));async function compile(e,i){var o,t,a,l;const s=await(0,projectconfig_1.getProjectConfigJSON)(e);if(null===(o=s.setting)||void 0===o?void 0:o.useCompilerPlugins)return summer.compile(e,s,i,s.setting.useCompilerPlugins);const r=s.miniprogramRoot||"";(await e.attr()).gameApp&&(0,common_2.throwError)({filePath:"",msg:locales_1.default.config.PROJECT_TYPE_ERROR.format(e.appid,locales_1.default.config.MINI_GAME),code:config_1.PROJECT_TYPE_ERROR});const{MiniProgramWhiteList:n}=await(0,white_ext_list_1.getWhiteExtList)();let p=e.getFileList(r,"").filter(common_1.isNotIgnoredByProjectConfig.bind(null,s,r)).filter(e=>n.has(path_1.default.posix.extname(e)));if((null===(t=i.compilePages)||void 0===t?void 0:t.length)&&i.analyzer){const e=(0,partial_1.partialGetCodeFiles)(i.analyzer,i.compilePages).map(e=>path_1.default.posix.join(r,e)),o=p.filter(e=>{const i=path_1.default.posix.extname(e);return".js"!==i&&".json"!==i&&".wxss"!==i&&".wxml"!==i});p=o.concat(e)}let c=!1,m=await(0,mpjson_1.compileJSON)(e,i);if((null===(a=i.compilePages)||void 0===a?void 0:a.length)&&i.analyzer){const e=JSON.parse(m[path_1.default.posix.join(r,"app.json")]);e.pages=e.pages.filter(e=>{var o;return null===(o=i.compilePages)||void 0===o?void 0:o.includes(e)}),0===e.pages.length&&(e.pages=["partialcompileplaceholder"],c=!0),e.subPackages&&(e.subPackages.forEach(e=>{e.pages=e.pages.filter(o=>{var t;return null===(t=i.compilePages)||void 0===t?void 0:t.includes(e.root+o)})}),e.subPackages=e.subPackages.filter(e=>e.pages.length>0)),m[path_1.default.posix.join(r,"app.json")]=JSON.stringify(e),m=lodash_1.default.pick(m,Object.keys(m).filter(e=>m[e]instanceof Buffer||p.includes(e)))}const _=p.filter(e=>".js"===path_1.default.posix.extname(e)).map(e=>path_1.default.posix.relative(r,e)),u=await(0,common_1.compileJSFiles)(e,_,r,i),f=p.filter(e=>".wxss"===path_1.default.posix.extname(e)).map(e=>path_1.default.posix.relative(r,e)),g=await(0,common_1.compileWXSSFiles)(e,f,r,i),d=p.filter(e=>".wxml"===path_1.default.posix.extname(e)).map(e=>path_1.default.posix.relative(r,e)),h=await(0,common_1.compileWXMLFiles)(e,d,r,i),j=p.filter(e=>{const i=path_1.default.posix.extname(e);return".js"!==i&&".json"!==i&&".wxss"!==i&&".wxml"!==i}),x=await(0,common_1.compileOther)(e,j,i);let P=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},m),u),x),g),h);if(c&&(P[path_1.default.posix.join(r,"partialcompileplaceholder.js")]||(P[path_1.default.posix.join(r,"partialcompileplaceholder.js")]=""),P[path_1.default.posix.join(r,"partialcompileplaceholder.wxml")]||(P[path_1.default.posix.join(r,"partialcompileplaceholder.wxml")]="")),e.type===config_1.COMPILE_TYPE.miniProgram){if(s.miniprogramRoot&&"."!==s.miniprogramRoot&&"./"!==s.miniprogramRoot){const i={};for(const o in P)i[path_1.default.posix.relative(e.miniprogramRoot,o)]=P[o];P=i}P["project.config.json"]=JSON.stringify({miniprogramRoot:"",__compileDebugInfo__:i.__compileDebugInfo__||{}}),delete P["project.private.config.json"]}else P["project.config.json"]=JSON.stringify({miniprogramRoot:e.miniprogramRoot||"",__compileDebugInfo__:i.__compileDebugInfo__||{}}),delete P["project.private.config.json"];return e.type===config_1.COMPILE_TYPE.miniProgram&&(null===(l=i.setting)||void 0===l?void 0:l.codeProtect)&&(P=await(0,uglifyfilenames_1.uglifyFileNames)(e,P)),P}exports.compile=compile;
|
|
3
|
+
}(require("licia/lazyImport")(require), require)
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
!function(require, directRequire){
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compile=exports.compilePlugin=void 0;const tslib_1=require("tslib"),mini_program_1=require("./mini_program"),common_1=require("./common"),plugin_1=require("../json/plugin/plugin"),plugin_page_1=require("../json/plugin/plugin_page"),white_ext_list_1=require("../../utils/white_ext_list"),path_1=(0,tslib_1.__importDefault)(require("path")),projectconfig_1=require("../json/projectconfig"),summer=(0,tslib_1.__importStar)(require("../../summer/ci"));async function compilePlugin(i,e){const t=await(0,projectconfig_1.getProjectConfigJSON)(i),{MiniProgramWhiteList:o}=await(0,white_ext_list_1.getWhiteExtList)(),n=t.pluginRoot,s=i.getFileList(n,"").filter(common_1.isNotIgnoredByProjectConfig.bind(null,t,n)).filter(i=>o.has(path_1.default.posix.extname(i))),a=await(0,plugin_1.getDevPluginJSON)(i,!1),l=s.filter(i=>".json"===path_1.default.posix.extname(i)&&i!==path_1.default.posix.join(n,"plugin.json")),p={};for(const e of l){const t=await(0,plugin_page_1.getPluginPageJSON)({project:i,root:n,filePath:e});p[e]=JSON.stringify(t)}const r=s.filter(i=>".js"===path_1.default.posix.extname(i)).map(i=>path_1.default.posix.relative(n,i)),m=await(0,common_1.compileJSFiles)(i,r,n,e),g=s.filter(i=>".wxss"===path_1.default.posix.extname(i)).map(i=>path_1.default.posix.relative(n,i)),u=await(0,common_1.compileWXSSFiles)(i,g,n,e),c=s.filter(i=>".wxml"===path_1.default.posix.extname(i)).map(i=>path_1.default.posix.relative(n,i)),_=await(0,common_1.compileWXMLFiles)(i,c,n,e),f=s.filter(i=>{const e=path_1.default.posix.extname(i);return".js"!==e&&".json"!==e&&".wxss"!==e&&".wxml"!==e}),j=await(0,common_1.compileOther)(i,f,e);return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({[path_1.default.posix.join(n,"plugin.json")]:JSON.stringify(a)},p),m),j),u),_)}async function compile(i,e){var t;const o=await(0,projectconfig_1.getProjectConfigJSON)(i);if(null===(t=o.setting)||void 0===t?void 0:t.useCompilerPlugins)return summer.compile(i,o,e,o.setting.useCompilerPlugins);const n=await compilePlugin(i,e),s=await(0,mini_program_1.compile)(i,e);return Object.assign(Object.assign(Object.assign({},n),s),{"project.config.json":JSON.stringify({miniprogramRoot:o.miniprogramRoot,pluginRoot:o.pluginRoot,__compileDebugInfo__:e.__compileDebugInfo__||{}})})}exports.compilePlugin=compilePlugin,exports.compile=compile;
|
|
3
|
+
}(require("licia/lazyImport")(require), require)
|
package/dist/core/js/enhance.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const config_1=require("../../config"),babel_helper_1=require("../../utils/babel_helper"),_transformRuntimeCustom=()=>require("../../utils/babel_transform_plugin"),babel7=()=>require("@babel/core"),_pluginTransformRuntime=()=>require("@babel/plugin-transform-runtime"),_pluginTransformModulesCommonjs=()=>require("@babel/plugin-transform-modules-commonjs"),_presetEnv=()=>require("@babel/preset-env");function getPluginsList(e){const r=[[require("../../utils/babel_transform_plugin")],[require("@babel/plugin-transform-runtime"),{corejs:!1,helpers:!0,regenerator:!e.hasRegenerator,version:"7.12.1"}]].concat(babel_helper_1.getCustomPlugins([]));return r.push([require("@babel/plugin-transform-modules-commonjs"),{allowTopLevelThis:e.disableUseStrict,importInterop:e=>e.startsWith("@babel/runtime/helpers/")?"node":"babel"}]),r}const enhance=e=>{const{code:r,babelRoot:s,filePath:t,inputSourceMap:l}=e,n=r,o=/regeneratorRuntime\.mark/.test(r),i=e.disableUseStrict||/^\s*\/\/\s?use strict disable;/i.test(r);let a=null;try{a=require("@babel/core").transform(r,{presets:[[require("@babel/preset-env"),{targets:{chrome:53,ios:8},include:["@babel/plugin-transform-computed-properties"]}]],babelrc:!1,plugins:getPluginsList({hasRegenerator:o,disableUseStrict:i}),sourceFileName:t,inputSourceMap:l,sourceMaps:!0,configFile:!1})}catch(e){return{error:{message:`file: ${t}\n ${e.message}`,code:config_1.BABEL_TRANS_JS_ERR}}}let u=(null==a?void 0:a.code)||r;const b=(null==a?void 0:a.map)||l;i&&(u=u.replace(/^"use strict";/,""));const c=babel_helper_1.collectBabelHelpers(n),{transformCode:p,helpers:m}=babel_helper_1.replaceBabelHelpers(u,c,t,s);return u=p,{code:u,map:b,helpers:m||[]}};module.exports=enhance;
|
|
1
|
+
"use strict";const config_1=require("../../config"),babel_helper_1=require("../../utils/babel_helper"),_transformRuntimeCustom=()=>require("../../utils/babel_transform_plugin"),babel7=()=>require("@babel/core"),_pluginTransformRuntime=()=>require("@babel/plugin-transform-runtime"),_pluginTransformModulesCommonjs=()=>require("@babel/plugin-transform-modules-commonjs"),_presetEnv=()=>require("@babel/preset-env");function getPluginsList(e){const r=[[require("../../utils/babel_transform_plugin")],[require("@babel/plugin-transform-runtime"),{corejs:!1,helpers:!0,regenerator:!e.hasRegenerator,version:"7.12.1"}]].concat((0,babel_helper_1.getCustomPlugins)([]));return r.push([require("@babel/plugin-transform-modules-commonjs"),{allowTopLevelThis:e.disableUseStrict,importInterop:e=>e.startsWith("@babel/runtime/helpers/")?"node":"babel"}]),r}const enhance=e=>{const{code:r,babelRoot:s,filePath:t,inputSourceMap:l}=e,n=r,o=/regeneratorRuntime\.mark/.test(r),i=e.disableUseStrict||/^\s*\/\/\s?use strict disable;/i.test(r);let a=null;try{a=require("@babel/core").transform(r,{presets:[[require("@babel/preset-env"),{targets:{chrome:53,ios:8},include:["@babel/plugin-transform-computed-properties"]}]],babelrc:!1,plugins:getPluginsList({hasRegenerator:o,disableUseStrict:i}),sourceFileName:t,inputSourceMap:l,sourceMaps:!0,configFile:!1})}catch(e){return{error:{message:`file: ${t}\n ${e.message}`,code:config_1.BABEL_TRANS_JS_ERR}}}let u=(null==a?void 0:a.code)||r;const b=(null==a?void 0:a.map)||l;i&&(u=u.replace(/^"use strict";/,""));const c=(0,babel_helper_1.collectBabelHelpers)(n),{transformCode:p,helpers:m}=(0,babel_helper_1.replaceBabelHelpers)(u,c,t,s);return u=p,{code:u,map:b,helpers:m||[]}};module.exports=enhance;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const babel7=()=>require("@babel/core"),generateMap=(e,r)=>{let a=void 0;try{if(a=require("@babel/core").transform(r,{presets:[],babelrc:!1,sourceFileName:e,sourceMaps:!0,configFile:!1}),null==a?void 0:a.map)return Object.assign(Object.assign({},a.map),{version:""+(null==a?void 0:a.map.version)})}catch(e){}};module.exports=generateMap;
|
package/dist/core/js/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compile=void 0;const tslib_1=require("tslib"),config_1=require("../../config"),tools_1=require("../../utils/tools"),error_1=require("../../utils/error"),locales_1=tslib_1.__importDefault(require("../../utils/locales/locales"));function compile(e,o,r){if(void 0===tools_1.bufferToUtf8String(e))throw new error_1.CodeError(locales_1.default.config.FILE_NOT_UTF8.format(o),config_1.FILE_NOT_UTF8)}exports.compile=compile;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compile=void 0;const tslib_1=require("tslib"),config_1=require("../../config"),tools_1=require("../../utils/tools"),error_1=require("../../utils/error"),locales_1=(0,tslib_1.__importDefault)(require("../../utils/locales/locales"));function compile(e,o,r){if(void 0===(0,tools_1.bufferToUtf8String)(e))throw new error_1.CodeError(locales_1.default.config.FILE_NOT_UTF8.format(o),config_1.FILE_NOT_UTF8)}exports.compile=compile;
|
package/dist/core/js/minifyjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const config_1=require("../../config"),_Terser=()=>require("terser"),_UglifyJS=()=>require("uglify-js"),_babelCodeFrame=()=>require("babel-code-frame"),minify=e=>{const{code:r,inputSourceMap:o,useTerser:i,filePath:n}=e;let c;const s=o?{includeSources:!0,content:o,filename:n}:{includeSources:!0,content:void 0,filename:n};if(c=i?require("terser").minify(r,{output:{comments:!1},toplevel:!0,compress:{drop_console:!1},sourceMap:s}):require("uglify-js").minify(r,{toplevel:!0,sourceMap:s}),c.error){const e=c.error;return{error:{message:`file: ${n}\n ${c.error.message}\n ${require("babel-code-frame")(r,e.line,e.col>0?e.col:1)}`,code:config_1.UGLIFY_JS_ERR}}}return c};module.exports=minify;
|
|
1
|
+
"use strict";const config_1=require("../../config"),_Terser=()=>require("terser"),_UglifyJS=()=>require("uglify-js"),_babelCodeFrame=()=>require("babel-code-frame"),minify=e=>{const{code:r,inputSourceMap:o,useTerser:i,filePath:n}=e;let c;const s=o?{includeSources:!0,content:o,filename:n}:{includeSources:!0,content:void 0,filename:n};if(c=i?require("terser").minify(r,{output:{comments:!1},toplevel:!0,compress:{drop_console:!1,drop_debugger:!1},sourceMap:s}):require("uglify-js").minify(r,{toplevel:!0,sourceMap:s}),c.error){const e=c.error;return{error:{message:`file: ${n}\n ${c.error.message}\n ${require("babel-code-frame")(r,e.line,e.col>0?e.col:1)}`,code:config_1.UGLIFY_JS_ERR}}}return c};module.exports=minify;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const tslib_1=require("tslib"),minifyjs_1=tslib_1.__importDefault(require("./minifyjs")),_sourcemap=()=>require("source-map"),transformInputSourceMapWhenWraped=e=>{const{code:n,filePath:r,inputSourceMap:o}=e;if(o){const e=new(_sourcemap().SourceMapConsumer)(o),n=new(_sourcemap().SourceMapGenerator)({file:r});return e.eachMapping(e=>{if("number"!=typeof e.originalLine||"number"!=typeof e.originalColumn)return;const r={generated:{line:e.generatedLine+1,column:e.generatedColumn}};null!=e.source&&(r.source=e.source,r.original={line:e.originalLine,column:e.originalColumn},null!=e.name&&(r.name=e.name)),n.addMapping(r)}),e.sources.forEach(r=>{const o=r;n._sources.has(o)||n._sources.add(o);const s=e.sourceContentFor(r);null!==s&&n.setSourceContent(r,s)}),n.toJSON()}{const e=new(_sourcemap().SourceMapGenerator)({file:r}),o=n.split("\n").length;for(let n=0;n<o;n++)e.addMapping({generated:{line:n+2,column:0},original:{line:n+1,column:0},source:r});return e._sources.add(r),e.setSourceContent(r,n),e.toJSON()}},minifyAfterWrap=e=>{const n=transformInputSourceMapWhenWraped(Object.assign({},e)),r=minifyjs_1.default(Object.assign(Object.assign({},e),{inputSourceMap:n,code:`(function(){\n${e.code}\n})()`,useTerser:!0}));return r.error?(console.error(r.error),minifyjs_1.default(Object.assign(Object.assign({},e),{useTerser:!0}))):r};module.exports=minifyAfterWrap;
|
|
1
|
+
"use strict";const tslib_1=require("tslib"),minifyjs_1=(0,tslib_1.__importDefault)(require("./minifyjs")),_sourcemap=()=>require("source-map"),transformInputSourceMapWhenWraped=e=>{const{code:n,filePath:r,inputSourceMap:o}=e;if(o){const e=new(_sourcemap().SourceMapConsumer)(o),n=new(_sourcemap().SourceMapGenerator)({file:r});return e.eachMapping(e=>{if("number"!=typeof e.originalLine||"number"!=typeof e.originalColumn)return;const r={generated:{line:e.generatedLine+1,column:e.generatedColumn}};null!=e.source&&(r.source=e.source,r.original={line:e.originalLine,column:e.originalColumn},null!=e.name&&(r.name=e.name)),n.addMapping(r)}),e.sources.forEach(r=>{const o=r;n._sources.has(o)||n._sources.add(o);const s=e.sourceContentFor(r);null!==s&&n.setSourceContent(r,s)}),n.toJSON()}{const e=new(_sourcemap().SourceMapGenerator)({file:r}),o=n.split("\n").length;for(let n=0;n<o;n++)e.addMapping({generated:{line:n+2,column:0},original:{line:n+1,column:0},source:r});return e._sources.add(r),e.setSourceContent(r,n),e.toJSON()}},minifyAfterWrap=e=>{const n=transformInputSourceMapWhenWraped(Object.assign({},e)),r=(0,minifyjs_1.default)(Object.assign(Object.assign({},e),{inputSourceMap:n,code:`(function(){\n${e.code}\n})()`,useTerser:!0}));return r.error?(console.error(r.error),(0,minifyjs_1.default)(Object.assign(Object.assign({},e),{useTerser:!0}))):r};module.exports=minifyAfterWrap;
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),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");function checkPageExist(o,e,t){const{miniprogramRoot:a,project:c,filePath:n}=o;c.stat(a,e+".wxml")||common_2.throwError({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t,e+".wxml"),code:config_1.FILE_NOT_FOUND,filePath:n}),c.stat(a,e+".js")||common_2.throwError({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t,e+".js"),code:config_1.FILE_NOT_FOUND,filePath:n})}function checkWindow(o){const{inputJSON:e,mode:t}=o;let a=""+o.filePath;e.themeLocation&&(a+=` or ${e.themeLocation}["${t}"]`);const c=[],{window:n}=e;n&&(void 0!==n.navigationBarBackgroundColor&&(tools_1.isHexColor(n.navigationBarBackgroundColor)||c.push(`["window"]["navigationBarBackgroundColor"]: "${n.navigationBarBackgroundColor}" is not hexColor`)),void 0!==n.backgroundColor&&(tools_1.isHexColor(n.backgroundColor)||c.push(`["window"]["backgroundColor"]: "${n.backgroundColor}" is not hexColor`)),c.length>0&&common_2.throwError({msg:c.join("\n"),filePath:a}))}function checkTabbar(o){const{project:e,miniprogramRoot:t,inputJSON:a,mode:c}=o;let n=""+o.filePath;a.themeLocation&&(n+=` or ${a.themeLocation}["${c}"]`);const{tabBar:r}=a,i=e.attrSync(),{setting:s}=i;if(!r)return;const l=[];r.list.length<s.MinTabbarCount&&common_2.throwError({msg:locales_1.default.config.JSON_TABBAR_AT_LEAST.format(s.MinTabbarCount),filePath:n}),r.list.length>s.MaxTabbarCount&&common_2.throwError({msg:locales_1.default.config.JSON_TABBAR_AT_MOST.format(s.MaxTabbarCount),filePath:n});for(let o=0;o<r.list.length;o++){const a=r.list[o],{pagePath:c}=a;if(common_2.checkPath({value:c,tips:`["tabBar"]["list"][${o}]["pagePath"]`,filePath:n}),!c){l.push(locales_1.default.config.JSON_TABBAR_PATH_EMPTY.format(o));continue}c.indexOf("?")>=0&&l.push(locales_1.default.config.JSON_SHOULD_NOT_CONTAIN.format(`["tabBar"]["list"][${o}]["pagePath"]`,"?")),c.indexOf(".")>=0&&l.push(locales_1.default.config.JSON_SHOULD_NOT_CONTAIN.format(`["tabBar"]["list"][${o}]["pagePath"]`,"."));const i=[];a.iconPath&&(common_2.checkPath({value:a.iconPath,tips:`["tabBar"]["list"][${o}]["iconPath"]`,filePath:n,checkPathType:common_2.ECheckPathType.TAB_BAR_ICON}),i.push({name:"iconPath",path:a.iconPath})),a.selectedIconPath&&(common_2.checkPath({value:a.selectedIconPath,tips:`["tabBar"]["list"][${o}]["selectedIconPath"]`,filePath:n,checkPathType:common_2.ECheckPathType.TAB_BAR_ICON}),i.push({name:"selectedIconPath",path:a.selectedIconPath})),i.forEach(a=>{const c=e.stat(t,a.path);if(!c)return void l.push(locales_1.default.config.NOT_FOUND.format(`["tabBar"]["list"][${o}]["${a.name}"]: "${a.path}"`));if(c.isDirectory)return void l.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(`["tabBar"]["list"][${o}]["${a.name}"]`,locales_1.default.config.FILE));c.size>1024*s.MaxTabbarIconSize&&l.push(locales_1.default.config.JSON_TABBAR_ICON_MAX_SIZE.format([o,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([o,a.name,config_1.TABBAR_ICON_WHITE_LIST.join("、")]))})}l.length>0&&common_2.throwError({msg:l.join("\n"),filePath:n})}function checkWorkers(o){const{project:e,miniprogramRoot:t,filePath:a,inputJSON:c}=o,{workers:n}=c;if(void 0===n)return;const r='["workers"]';""===n&&common_2.throwError({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(r,locales_1.default.config.DIRECTORY),filePath:a}),common_2.checkPath({value:n,tips:r,filePath:a});const i=e.stat(t,n);i&&i.isDirectory||common_2.throwError({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([r,locales_1.default.config.DIRECTORY]),filePath:a}),c.workers=tools_1.normalizePath(n+"/")}function checkOpenLocationPagePath(o){const{filePath:e,inputJSON:t}=o,{openLocationPagePath:a}=t;if(void 0===a)return;const c='["openLocationPagePath"]';common_2.checkPath({value:a,tips:c,filePath:e}),checkPageExist(o,a,c)}exports.checkPageExist=checkPageExist,exports.checkWindow=checkWindow,exports.checkTabbar=checkTabbar,exports.checkWorkers=checkWorkers,exports.checkOpenLocationPagePath=checkOpenLocationPagePath;const checkMainPkgPages=o=>{const{filePath:e,inputJSON:t}=o,{pages:a}=t;if(!a)return;const c={};for(let t=0;t<a.length;t++){const n=a[t],r=`["pages"][${t}]`;common_2.checkPath({value:n,tips:r,filePath:e}),c[n]&&common_2.throwError({msg:locales_1.default.config.JSON_PAGES_REPEAT.format(`"${n}"`,'["pages"]'),filePath:e}),c[n]=!0,checkPageExist(o,n,r)}};function checkSitemapLocation(o){const{filePath:e,inputJSON:t}=o,{sitemapLocation:a}=t;if(void 0===a)return;const{project:c,miniprogramRoot:n}=o,r='["sitemapLocation"]';common_2.checkPath({value:a,tips:r,filePath:e});const i=c.stat(n,a);i&&!i.isDirectory||common_2.throwError({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(r,a),filePath:e});".json"!==path_1.default.posix.extname(a)&&common_2.throwError({msg:locales_1.default.config.EXT_SHOULD_BE_ERROR.format(r,".json"),filePath:e});const s=c.getFile(n,a),l=common_2.checkUTF8(s,a),h=common_1.checkJSONFormat(l,a),f=schemaValidate_1.schemaValidate("sitemap",h);if(f.error.length){const o=f.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");common_2.throwError({msg:o,filePath:a})}}function checkSubpackages(o){const{project:e,miniprogramRoot:t,filePath:a,inputJSON:c}=o;let n='["subPackages"]';c.subpackages&&(n='["subpackages"]',c.subPackages=c.subpackages,delete c.subpackages);const r=[];if(c.subPackages){const i=e.attrSync(),{setting:s}=i;c.subPackages.length>s.MaxSubPackageLimit&&common_2.throwError({msg:locales_1.default.config.EXCEED_LIMIT.format([n,s.MaxSubPackageLimit]),filePath:a});const l={},h={};for(let i=0;i<c.subPackages.length;i++){const s=c.subPackages[i],f=`${n}[${i}]`;if(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(h[s.name]){r.push(locales_1.default.config.SAME_ITEM.format(f,h[s.name],"name"));continue}h[s.name]=f}if(s.root=tools_1.normalizePath(s.root+"/"),l[s.root]){r.push(locales_1.default.config.SAME_ITEM.format(f,l[s.root],"root"));continue}l[s.root]=f;const p=e.stat(t,s.root);if(!p){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`${n}[${i}]["root"]`,locales_1.default.config.DIRECTORY]));continue}if(!p.isDirectory){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`${n}[${i}]["root"]`,locales_1.default.config.DIRECTORY]));continue}const _={};for(let e=0,t=s.pages.length;e<t;e++){const t=s.pages[e];common_2.checkPath({value:t,tips:`${n}[${i}]["pages"][${e}]`,filePath:a});const c=tools_1.normalizePath(path_1.default.posix.join(s.root,t));_[c]?r.push(locales_1.default.config.JSON_PAGES_REPEAT.format([`"${t}"`,`${n}[${i}]`])):(_[c]=!0,checkPageExist(o,c,`${n}[${i}]["pages"][${e}]`))}}r.length>0&&common_2.throwError({msg:r.join("\n"),filePath:a});for(let o=0;o<c.subPackages.length;o++){const e=c.subPackages[o];let t=-1;const a="/"+e.root;c.subPackages.forEach((e,c)=>{if(c!==o&&e.root){const o="/"+e.root;0===a.indexOf(o)&&(t=c)}}),-1===t||r.push(locales_1.default.config.JSON_SHOULD_NOT_CONTAIN.format(`${n}[${t}]["root"]`,`${n}[${o}]["root"]`))}r.length>0&&common_2.throwError({msg:r.join("\n"),filePath:a})}}function checkPlugins(o){const{filePath:e,inputJSON:t,project:a}=o,c=[],n=t.plugins||{};function r(o,e){const{appid:t}=a,n=a.type===config_1.COMPILE_TYPE.miniProgramPlugin;if(n||"dev"!==o.version)if(n)"dev"===o.version&&o.provider!==t?c.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(e+'["provider"]',`"${t}"`)):o.provider===t&&"dev"!==o.version&&c.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(e+'["version"]','"dev"'));else{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!0;c.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([e+'["version"]',locales_1.default.config.TRIPLE_NUMBER_DOT]))}else c.push(`${locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(e+'["version"]',"dev")}\n${locales_1.default.config.PLEASE_CHOOSE_PLUGIN_MODE}`)}for(const o in n){r(n[o],`["plugins"]["${o}"]`)}t.subPackages&&t.subPackages.forEach((o,e)=>{if(!o.plugins)return;const t=`["subPackages"][${e}]`;for(const e in o.plugins){r(o.plugins[e],`${t}["plugins"]["${e}"]`)}}),c.length>0&&common_2.throwError({msg:c.join("\n"),filePath:e})}function checkNavigateToMiniProgramAppIdList(o){const{filePath:e,inputJSON:t,project:a}=o,c=[];if(t.navigateToMiniProgramAppIdList){const o=a.attrSync(),{appType:e=config_1.APP_TYPE.NORMAL,setting:n}=o;if(e!==config_1.APP_TYPE.NATIVE){const o=null==n?void 0:n.NavigateMiniprogramLimit;t.navigateToMiniProgramAppIdList.length>o&&c.push(locales_1.default.config.EXCEED_LIMIT.format('["navigateToMiniProgramAppIdList"]',o))}}c.length>0&&common_2.throwError({msg:c.join("\n"),filePath:e})}function checkFunctionalPages(o){const{inputJSON:e}=o;if(e.functionalPages&&"object"!==tools_1.getType(e.functionalPages)){const o='["functionalPages"] 配置需要更新,详见文档: https://developers.weixin.qq.com/miniprogram/dev/framework/plugin/functional-pages.html';e.__warning__?e.__warning__=`${e.__warning__}\n${o}`:e.__warning__=o}}function checkPreloadRule(o,e){const{inputJSON:t,filePath:a}=o,{preloadRule:c,subPackages:n}=t;if(!c||!n)return;const r=[],i={},s={},l={};e.forEach(o=>{i[o.root]=!0,l[o.path]=!0,o.name&&(s[o.name]=!0)});for(const o in c){if(!l[o]&&!o.includes("__plugin__/")){r.push(locales_1.default.config.NOT_FOUND.format(`["preloadRule"]["${o}"]: ${locales_1.default.config.PAGE_PATH}`));continue}const e=c[o];for(let t=0,a=e.packages.length;t<a;t++){let a=e.packages[t];a!==config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT&&(s[a]||(a=tools_1.normalizePath(a+"/"),i[a]||r.push(locales_1.default.config.NOT_FOUND.format(`["preloadRule"]["${o}"]["packages"][${t}]: ${a}`))))}}r.length>0&&common_2.throwError({msg:r.join("\n"),filePath:a})}function checkEntryPagePath(o,e){const{inputJSON:t,filePath:a}=o,{entryPagePath:c}=t;if(!c)return;common_2.checkPath({value:c,tips:'["entryPagePath"]',filePath:a});let n=!1;for(const o of e)if(o.path===c){n=!0;break}n||common_2.throwError({msg:locales_1.default.config.JSON_ENTRY_PAGE_PATH_NOT_FOUND.format(["pages、subPackages","entryPagePath"]),filePath:a})}function checkTabbarPage(o){const{filePath:e,inputJSON:t}=o,{tabBar:a,pages:c=[]}=t;if(!a)return;const n=[];for(let o=0;o<a.list.length;o++){const e=a.list[o],{pagePath:t}=e;c.indexOf(t)<0&&n.push(`["tabBar"][${o}]["pagePath"]: "${t}" need in ["pages"]`)}n.length>0&&common_2.throwError({msg:n.join("\n"),filePath:e})}function checkMainPkgPageIsInSubpkg(o){const{filePath:e,inputJSON:t}=o,{subPackages:a,pages:c=[]}=t;if(!a)return;const n=[];for(let o=0;o<a.length;o++){const e=a[o];for(let t=0;t<c.length;t++){const a=c[t];0===a.indexOf(e.root)&&n.push(locales_1.default.config.SHOULD_NOT_IN.format([`["pages"][${t}]: "${a}"`,`["subPackages"][${o}]`]))}}n.length>0&&common_2.throwError({msg:n.join("\n"),filePath:e})}function checkMainPkgPluginIsInSubPkg(o){const{filePath:e,inputJSON:t}=o,{plugins:a={},subPackages:c}=t,n={},r={},i=[];for(const o in a){const e=a[o],t=`["plugins"]["${o}"]`;n[e.provider]?i.push(locales_1.default.config.SAME_ITEM.format(`["plugins"]["${o}"]`,n[e.provider].tips,"provider")):n[e.provider]=r[o]={provider:e.provider,version:e.version,alias:o,tips:t}}if(c)for(let o=0;o<c.length;o++){const e=c[o];if(e.plugins)for(const t in e.plugins){const a=`["subPackages"][${o}]["plugins"]`,c=e.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&&common_2.throwError({msg:i.join("\n"),filePath:e})}function checkComponentPath(o){const{project:e,miniprogramRoot:t,filePath:a,inputJSON:c}=o;common_1.checkComponentPath({project:e,root:t,relativePath:path_1.default.posix.relative(t,a),inputJSON:c})}function checkEntranceDeclare(o){const e=o.inputJSON;if(!e.entranceDeclare||!e.entranceDeclare.locationMessage)return;let t=e.pages||[];e.subpackages&&(t=t.concat(e.subpackages.map(o=>o.pages.map(e=>o.root+e))),t=lodash_1.default.flattenDeep(t)),e.subPackages&&(t=t.concat(e.subPackages.map(o=>o.pages.map(e=>o.root+e))),t=lodash_1.default.flattenDeep(t));const a=[],c=e.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&&common_2.throwError({msg:a.join("\n"),filePath:o.filePath})}function getAppJSONVariableDecalearProperty(o){const{windowPropertWhiteList:e,tabBarPropertyWhiteList:t,tabbarListItemPropertyWhiteList:a}=config_1.jsonVariablePropertyWhiteList;let c=[];return"[object Object]"===Object.prototype.toString.call(o.window)&&(c=c.concat(Object.keys(o.window).filter(o=>e.includes(o)).map(e=>({property:`["window"]["${e}"]`,value:o.window[e]})).filter(o=>o.value.startsWith("@")))),"[object Object]"===Object.prototype.toString.call(o.tabBar)&&(c=c.concat(Object.keys(o.tabBar).filter(o=>t.includes(o)).map(e=>({property:`["tabBar"]["${e}"]`,value:o.tabBar[e]})).filter(o=>o.value.startsWith("@"))),Array.isArray(o.tabBar.list)&&o.tabBar.list.forEach((e,t)=>{c=c.concat(Object.keys(e).filter(o=>a.includes(o)).map(e=>({property:`["tabBar"]["list"][${t}]["${e}"]`,value:o.tabBar.list[t][e]})).filter(o=>o.value.startsWith("@")))})),c}function checkOpenDataContext(o,e){const{project:t,miniprogramRoot:a,filePath:c}=o,{openDataContext:n}=e;if(void 0===n)return;common_2.checkPath({value:n,tips:'["openDataContext"]',filePath:c});const r=t.stat(a,n);r&&r.isDirectory||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||common_2.throwError({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["openDataContext"]',i),filePath:c}),e.openDataContext=tools_1.normalizePath(n+"/")}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;
|
|
1
|
+
!function(require, directRequire){
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),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 h=[];a.iconPath&&((0,common_2.checkPath)({value:a.iconPath,tips:`["tabBar"]["list"][${e}]["iconPath"]`,filePath:n,checkPathType:common_2.ECheckPathType.TAB_BAR_ICON}),h.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}),h.push({name:"selectedIconPath",path:a.selectedIconPath})),h.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}),(0,common_2.checkPath)({value:n,tips:r,filePath:a});const i=o.stat(t,n);i&&i.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([r,locales_1.default.config.DIRECTORY]),filePath:a}),c.workers=(0,tools_1.normalizePath)(n+"/")}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),h=(0,common_1.checkJSONFormat)(l,a),f=(0,schemaValidate_1.schemaValidate)("sitemap",h);if(f.error.length){const e=f.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={},h={};for(let i=0;i<c.subPackages.length;i++){const s=c.subPackages[i],f=`${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(h[s.name]){r.push(locales_1.default.config.SAME_ITEM.format(f,h[s.name],"name"));continue}h[s.name]=f}if(s.root=(0,tools_1.normalizePath)(s.root+"/"),l[s.root]){r.push(locales_1.default.config.SAME_ITEM.format(f,l[s.root],"root"));continue}l[s.root]=f;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){const{appid:t}=a,n=a.type===config_1.COMPILE_TYPE.miniProgramPlugin;if(n||"dev"!==e.version)if(n)"dev"===e.version&&e.provider!==t&&e.provider!==r.pluginAppid?c.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(o+'["provider"]',`"${t}"`)):e.provider===t&&"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})}}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;
|
|
3
|
+
}(require("licia/lazyImport")(require), require)
|
|
@@ -1 +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=(0,tslib_1.__importDefault)(require("path")),locales_1=(0,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.checkSitemapLocation)(e),(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),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.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
|
+
}(require("licia/lazyImport")(require), require)
|
|
@@ -1 +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=(0,tslib_1.__importDefault)(require("path")),projectconfig_1=require("../projectconfig"),locales_1=(0,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.checkSitemapLocation)(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
|
+
}(require("licia/lazyImport")(require), require)
|
|
@@ -1 +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=(0,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=(0,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
|
+
}(require("licia/lazyImport")(require), require)
|
package/dist/core/json/common.js
CHANGED
|
@@ -1 +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=(0,tslib_1.__importDefault)(require("path")),locales_1=(0,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
|
+
}(require("licia/lazyImport")(require), require)
|