miniprogram-ci 1.6.1 → 1.6.10
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/README.md +2 -0
- package/dist/@types/config.d.ts +1 -1
- package/dist/@types/core/js/generateMap.d.ts +3 -0
- package/dist/@types/types/miniprogram-json/projectconfig.d.ts +1 -0
- package/dist/ci/code-analyse.js +1 -1
- package/dist/ci/cos-upload.js +1 -1
- package/dist/ci/getCompiledResult.js +1 -1
- package/dist/ci/getDevSourceMap.js +1 -1
- package/dist/ci/getLatestVersion.js +1 -1
- package/dist/ci/jsserver.js +1 -1
- package/dist/ci/preview.js +1 -1
- package/dist/ci/project.js +1 -1
- package/dist/ci/projectattr.js +1 -1
- package/dist/ci/upload.js +1 -1
- package/dist/ci/utils/packfile.js +1 -1
- package/dist/cli.js +1 -1
- package/dist/cloud/cloudapi.js +1 -1
- package/dist/cloud/createTimeTrigger.js +1 -1
- package/dist/cloud/uploadContainer.js +1 -1
- package/dist/cloud/uploadFile.js +1 -1
- package/dist/cloud/uploadFunction.js +1 -1
- package/dist/cloud/utils.js +1 -1
- package/dist/config.js +1 -1
- package/dist/core/compile/common.js +1 -1
- package/dist/core/compile/game.js +1 -1
- package/dist/core/compile/game_plugin.js +1 -1
- package/dist/core/compile/handler/js.js +1 -1
- package/dist/core/compile/handler/mpjson.js +1 -1
- package/dist/core/compile/handler/wxml.js +1 -1
- package/dist/core/compile/handler/wxss.js +1 -1
- package/dist/core/compile/index.js +1 -1
- package/dist/core/compile/mini_program.js +1 -1
- package/dist/core/compile/mini_program_plugin.js +1 -1
- package/dist/core/js/enhance.js +1 -1
- package/dist/core/js/generateMap.js +1 -0
- package/dist/core/js/index.js +1 -1
- package/dist/core/js/minifyjs_after_wrap.js +1 -1
- package/dist/core/json/app/checkAppFields.js +1 -1
- package/dist/core/json/app/getAppJSON.js +1 -1
- package/dist/core/json/app/getExtJSON.js +1 -1
- package/dist/core/json/app/index.js +1 -1
- package/dist/core/json/common.js +1 -1
- package/dist/core/json/game.js +1 -1
- package/dist/core/json/page/checkPageJSON.js +1 -1
- package/dist/core/json/page/getPageJSON.js +1 -1
- package/dist/core/json/plugin/plugin.js +1 -1
- package/dist/core/json/plugin/plugin_page.js +1 -1
- package/dist/core/json/projectWithMockBuffer.js +1 -1
- package/dist/core/json/projectconfig.js +1 -1
- package/dist/core/json/reactiveCache.js +1 -1
- package/dist/core/json/signaturejson.js +1 -1
- package/dist/core/json/sitemap.js +1 -1
- package/dist/core/json/theme.js +1 -1
- package/dist/core/npm/filterdeps.js +1 -1
- package/dist/core/npm/packnpm.js +1 -1
- package/dist/core/protect/file_flatter.js +1 -1
- package/dist/core/protect/uglifyfilenames.js +1 -1
- package/dist/core/validate/validate.js +1 -1
- package/dist/core/worker_thread/childprocess.js +1 -1
- package/dist/core/worker_thread/childprocess_manager.js +1 -1
- package/dist/core/worker_thread/fork.js +1 -1
- package/dist/core/worker_thread/index.js +1 -1
- package/dist/core/worker_thread/task/call_func.js +1 -1
- package/dist/core/worker_thread/task/compilejs.js +1 -1
- package/dist/core/worker_thread/task/compilewxss.js +1 -1
- package/dist/core/worker_thread/task/func.js +1 -1
- package/dist/core/worker_thread/task/minifywxml.js +1 -1
- package/dist/core/worker_thread/worker.js +1 -1
- package/dist/core/worker_thread/worker_manager.js +1 -1
- package/dist/core.js +1 -1
- package/dist/index.js +1 -1
- package/dist/manifest.json +2 -2
- package/dist/summer/devtool.js +1 -1
- package/dist/summer/entry_process.js +1 -1
- package/dist/summer/graph/appconf.js +1 -1
- package/dist/summer/graph/basegraph.js +1 -1
- package/dist/summer/graph/pluginconf.js +1 -1
- package/dist/summer/initPlugin.js +1 -1
- package/dist/summer/module.js +1 -1
- package/dist/summer/persist_cache.js +1 -1
- package/dist/summer/plugin_driver.js +1 -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 +1 -1
- package/dist/summer/resolver.js +1 -1
- package/dist/summer/summer.js +1 -1
- package/dist/summer/worker.js +1 -1
- package/dist/types/index.js +1 -1
- package/dist/types/miniprogram-json/index.js +1 -1
- package/dist/utils/babel_helper.js +1 -1
- package/dist/utils/cache.js +1 -1
- package/dist/utils/common.js +1 -1
- package/dist/utils/error.js +1 -1
- package/dist/utils/fsagent.js +1 -1
- package/dist/utils/glob.js +1 -1
- package/dist/utils/jsonParse.js +1 -1
- package/dist/utils/locales/locales.js +1 -1
- package/dist/utils/report.js +1 -1
- package/dist/utils/request.js +1 -1
- package/dist/utils/sign.js +1 -1
- package/dist/utils/taskstatus.js +1 -1
- package/dist/utils/tools.js +1 -1
- package/dist/utils/white_ext_list.js +1 -1
- package/dist/utils/wxvpkgreader/wxvpkgreader.js +1 -1
- package/dist/vendor/cloud-api/src/apis/apis.js +1 -1
- package/dist/vendor/cloud-api/src/apis/cdn/cdn.apis.js +1 -1
- package/dist/vendor/cloud-api/src/apis/cdn/index.js +1 -1
- package/dist/vendor/cloud-api/src/apis/flexdb/flexdb.apis.js +1 -1
- package/dist/vendor/cloud-api/src/apis/flexdb/index.js +1 -1
- package/dist/vendor/cloud-api/src/apis/scf/index.js +1 -1
- package/dist/vendor/cloud-api/src/apis/scf/scf.apis.js +1 -1
- package/dist/vendor/cloud-api/src/apis/ssl/index.js +1 -1
- package/dist/vendor/cloud-api/src/apis/ssl/ssl.apis.js +1 -1
- package/dist/vendor/cloud-api/src/apis/tcb/general.apis.js +1 -1
- package/dist/vendor/cloud-api/src/apis/tcb/index.js +1 -1
- package/dist/vendor/cloud-api/src/apis/tcb/tcb.apis.js +1 -1
- package/dist/vendor/cloud-api/src/index.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/contracts/cdn.contracts.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/contracts/contracts.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/contracts/flexdb.contracts.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/contracts/scf.contracts.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/contracts/ssl.contracts.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/contracts/tcb.contracts.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/validations/cdn.validations.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/validations/common.validations.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/validations/flexdb.validations.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/validations/scf.validations.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/validations/ssl.validations.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/validations/tcb.validations.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/validations/validations.js +1 -1
- package/dist/vendor/schema/dist/app.js +1 -1
- package/dist/vendor/schema/dist/ext.js +1 -1
- package/dist/vendor/schema/dist/game.js +29 -1
- package/dist/vendor/schema/dist/page.js +1 -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 +7 -1
- package/dist/vendor/schema/dist/sitemap.js +1 -1
- package/dist/vendor/schema/dist/theme.js +1 -1
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"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=tslib_1.__importDefault(require("path")),projectconfig_1=require("../json/projectconfig"),locales_1=tslib_1.__importDefault(require("../../utils/locales/locales")),uglifyfilenames_1=require("../protect/uglifyfilenames"),partial_1=require("../analyse/partial"),lodash_1=tslib_1.__importDefault(require("lodash")),summer=tslib_1.__importStar(require("../../summer/ci"));async function compile(e,i){var o,t,a,l;const s=await
|
|
1
|
+
"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 m=!1,c=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(c[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"],m=!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)),c[path_1.default.posix.join(r,"app.json")]=JSON.stringify(e),c=lodash_1.default.pick(c,Object.keys(c).filter(e=>c[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),x=p.filter(e=>{const i=path_1.default.posix.extname(e);return".js"!==i&&".json"!==i&&".wxss"!==i&&".wxml"!==i}),j=await(0,common_1.compileOther)(e,x,i);let P=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},c),u),j),g),h);if(m&&(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__||{}})}else P["project.config.json"]=JSON.stringify({miniprogramRoot:e.miniprogramRoot||"",__compileDebugInfo__:i.__compileDebugInfo__||{}});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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"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=tslib_1.__importDefault(require("path")),projectconfig_1=require("../json/projectconfig"),summer=tslib_1.__importStar(require("../../summer/ci"));async function compilePlugin(i,e){const t=await
|
|
1
|
+
"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;
|
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;
|
|
@@ -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 @@
|
|
|
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
|
+
"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=(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(o,e,t){const{miniprogramRoot:a,project:c,filePath:n}=o;c.stat(a,e+".wxml")||(0,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")||(0,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&&((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(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&&(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 o=0;o<r.list.length;o++){const a=r.list[o],{pagePath:c}=a;if((0,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&&((0,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&&((0,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&&(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&&(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=e.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(o){const{filePath:e,inputJSON:t}=o,{openLocationPagePath:a}=t;if(void 0===a)return;const c='["openLocationPagePath"]';(0,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}]`;(0,common_2.checkPath)({value:n,tips:r,filePath:e}),c[n]&&(0,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"]';(0,common_2.checkPath)({value:a,tips:r,filePath:e});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:e});".json"!==path_1.default.posix.extname(a)&&(0,common_2.throwError)({msg:locales_1.default.config.EXT_SHOULD_BE_ERROR.format(r,".json"),filePath:e});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 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");(0,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&&(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 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];(0,common_2.checkPath)({value:t,tips:`${n}[${i}]["pages"][${e}]`,filePath:a});const c=(0,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&&(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&&(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||{},r=(0,projectconfig_1.getProjectConfigJSON)(a);function i(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&&o.provider!==r.pluginAppid?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){i(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){i(o.plugins[e],`${t}["plugins"]["${e}"]`)}}),c.length>0&&(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&&(0,common_2.throwError)({msg:c.join("\n"),filePath:e})}function checkFunctionalPages(o){const{inputJSON:e}=o;if(e.functionalPages&&"object"!==(0,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=(0,tools_1.normalizePath)(a+"/"),i[a]||r.push(locales_1.default.config.NOT_FOUND.format(`["preloadRule"]["${o}"]["packages"][${t}]: ${a}`))))}}r.length>0&&(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;(0,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||(0,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&&(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&&(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&&(0,common_2.throwError)({msg:i.join("\n"),filePath:e})}function checkComponentPath(o){const{project:e,miniprogramRoot:t,filePath:a,inputJSON:c}=o;(0,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&&(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;(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}),e.openDataContext=(0,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 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getAppJSON=exports.getRawAppJSON=exports.checkAppJSON=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),locales_1=tslib_1.__importDefault(require("../../../utils/locales/locales")),projectconfig_1=require("../projectconfig"),common_1=require("../../../utils/common"),config_1=require("../../../config"),common_2=require("../common"),cache_1=require("../../../utils/cache"),lodash_1=require("lodash"),schemaValidate_1=require("../../validate/schemaValidate"),tools_1=require("../../../utils/tools"),theme_1=require("../theme"),reactiveCache_1=require("../reactiveCache"),checkAppFields_1=require("./checkAppFields");function transValidateResult(e){return e.error.map(e=>{if("type"===e.errorType||"enum"===e.errorType||"anyOf"===e.errorType)return locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([e.errorProperty,e.correctType]);{const c=""===e.errorProperty?e.requireProperty:`${e.errorProperty}.${e.requireProperty}`;return locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([c])}}).join("\n")}function checkAppJSON(e){const{inputJSON:c}=e;let{filePath:r}=e;const a=theme_1.getThemeLocation(e.project);if(!a){const e=checkAppFields_1.getAppJSONVariableDecalearProperty(c);e.length&&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=theme_1.checkThemeJSON(e.project,{themeLocation:a}));const t=theme_1.mergeThemeJSONToAppJSON(o,c),p=checkAppFields_1.getAppJSONVariableDecalearProperty(t.appJSONLight);p.length&&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=checkAppFields_1.getAppJSONVariableDecalearProperty(t.appJSONDark);i.length&&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=schemaValidate_1.schemaValidate("app",t.appJSONLight),l=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"]`),common_1.throwError({msg:e,filePath:r})}if(a&&l.error.length){const e=transValidateResult(l);a&&(r+=` or ${a}["dark"]`),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});checkAppFields_1.checkMainPkgPages(e),checkAppFields_1.checkSubpackages(e),checkAppFields_1.checkTabbar(s),a&&checkAppFields_1.checkTabbar(h),checkAppFields_1.checkWorkers(e),checkAppFields_1.checkFunctionalPages(e),checkAppFields_1.checkOpenLocationPagePath(e),checkAppFields_1.checkOpenDataContext(e,c),checkAppFields_1.checkSitemapLocation(e),checkAppFields_1.checkPlugins(e),checkAppFields_1.checkWindow(s),a&&checkAppFields_1.checkWindow(h),checkAppFields_1.checkComponentPath(e);const _=common_1.getAllPagesInfo(c);return
|
|
1
|
+
"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),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});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getExtJSON=void 0;const tslib_1=require("tslib"),cache_1=require("../../../utils/cache"),common_1=require("../common"),common_2=require("../../../utils/common"),lodash_1=require("lodash"),tools_1=require("../../../utils/tools"),path_1=tslib_1.__importDefault(require("path")),projectconfig_1=require("../projectconfig"),locales_1=tslib_1.__importDefault(require("../../../utils/locales/locales")),schemaValidate_1=require("../../validate/schemaValidate"),theme_1=require("../theme"),checkAppFields_1=require("./checkAppFields"),reactiveCache_1=require("../reactiveCache");function checkExtPages(e){const{project:o,inputJSON:r,filePath:t,miniprogramRoot:c}=e,{extPages:a}=r;if(a)for(const e in a){const r=a[e];if(r){r.navigationBarBackgroundColor&&!tools_1.isHexColor(r.navigationBarBackgroundColor)&&common_2.throwError({msg:`["extPages"]["${e}"]["navigationBarBackgroundColor"]: "${r.navigationBarBackgroundColor}" is not hexColor`,filePath:t}),r.backgroundColor&&!tools_1.isHexColor(r.backgroundColor)&&common_2.throwError({msg:`["extPages"]["${e}"]["backgroundColor"]: "${r.backgroundColor}" is not hexColor`,filePath:t});try{checkAppFields_1.checkComponentPath({project:o,miniprogramRoot:c,inputJSON:r,filePath:e+".json"})}catch(o){common_2.throwError({msg:`["extPages"]["${e}"]${o.message}`,filePath:t})}}}}exports.getExtJSON=reactiveCache_1.wrapCompileJSONFunc(cache_1.CACHE_KEY.EXT_JSON,e=>{const o=projectconfig_1.getProjectConfigJSON(e),{miniprogramRoot:r=""}=o,t=e.attrSync(),c=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=common_1.checkJSONFormat(common_2.checkUTF8(a,c),c);if(!i.extEnable)return{};const n=theme_1.getThemeLocation(e);let l={};n&&(l=theme_1.checkThemeJSON(e,{themeLocation:n}));const s=theme_1.mergeThemeJSONToAppJSON(l,i),p=schemaValidate_1.schemaValidate("ext",s.appJSONLight),_=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");common_2.throwError({msg:r,filePath:c})}i.extAppid||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=lodash_1.cloneDeep(h);m.inputJSON=s.appJSONLight,m.mode="light";const g=lodash_1.cloneDeep(h);return g.inputJSON=s.appJSONDark,g.mode="dark",checkAppFields_1.checkMainPkgPages(h),checkAppFields_1.checkMainPkgPages(h),checkAppFields_1.checkSubpackages(h),checkAppFields_1.checkTabbar(m),checkAppFields_1.checkTabbar(g),checkAppFields_1.checkWorkers(h),checkAppFields_1.checkFunctionalPages(h),checkAppFields_1.checkOpenLocationPagePath(h),checkAppFields_1.checkSitemapLocation(h),checkAppFields_1.checkPlugins(h),checkAppFields_1.checkWindow(m),checkAppFields_1.checkWindow(g),checkAppFields_1.checkComponentPath(h),checkExtPages(h),i});
|
|
1
|
+
"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});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getAppJSON=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),cache_1=require("../../../utils/cache"),lodash_1=require("lodash"),getAppJSON_1=require("./getAppJSON"),getExtJSON_1=require("./getExtJSON"),projectconfig_1=require("../projectconfig"),common_1=require("../../../utils/common"),locales_1=tslib_1.__importDefault(require("../../../utils/locales/locales")),theme_1=require("../theme"),reactiveCache_1=require("../reactiveCache"),tools_1=require("../../../utils/tools");function mergeExtJSON(e,t){if(t)for(const o in t)if("__warning__"!==o){if("extPages"!==o){if("plugins"===o||"supportedMaterials"===o){e[o]=t[o];continue}"object"===tools_1.getType(t[o])?"object"!==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=reactiveCache_1.wrapCompileJSONFunc(cache_1.CACHE_KEY.COMPILED_APP_JSON,e=>{const t=projectconfig_1.getProjectConfigJSON(e),{miniprogramRoot:o=""}=t;let i=getAppJSON_1.getAppJSON(e);const r=getExtJSON_1.getExtJSON(e);if(r&&(i=lodash_1.cloneDeep(i),mergeExtJSON(i,r),r.extEnable))try{const t=theme_1.getThemeLocation(e);let r={};t&&(r=theme_1.checkThemeJSON(e,{themeLocation:t}));const _=theme_1.mergeThemeJSONToAppJSON(r,i);getAppJSON_1.checkAppJSON({project:e,miniprogramRoot:o,inputJSON:_.appJSONLight,filePath:path_1.default.posix.join(o,"app.json")}),getAppJSON_1.checkAppJSON({project:e,miniprogramRoot:o,inputJSON:_.appJSONDark,filePath:path_1.default.posix.join(o,"app.json")})}catch(e){common_1.throwError({msg:e.message,code:e.code,filePath:`app.json ${locales_1.default.config.OR} ext.json`})}return i});
|
|
1
|
+
"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});
|
package/dist/core/json/common.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.transValidateResult=exports.getPageJSONVariableDecalearProperty=exports.checkComponentPath=exports.getUseExtendLib=exports.checkFilePathIsInIndependentSubpackage=exports.checkPagePathIsInIndependentSubpackage=exports.checkPagePathIsInSubPackage=exports.checkJSONFormat=void 0;const tslib_1=require("tslib"),tools_1=require("../../utils/tools"),path_1=tslib_1.__importDefault(require("path")),locales_1=tslib_1.__importDefault(require("../../utils/locales/locales")),common_1=require("../../utils/common"),config_1=require("../../config"),lodash_1=require("lodash"),getAppJSON_1=require("./app/getAppJSON");function checkJSONFormat(e,t){let o={};e||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=tools_1.formatJSONParseErr({filePath:t,data:e,error:o});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=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=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";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";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||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=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&&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=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&&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=lodash_1.uniq(a.concat(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;
|
|
1
|
+
"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;
|
package/dist/core/json/game.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),cache_1=require("../../utils/cache"),common_1=require("../../utils/common"),config_1=require("../../config"),tools_1=require("../../utils/tools"),path_1=tslib_1.__importDefault(require("path")),locales_1=tslib_1.__importDefault(require("../../utils/locales/locales")),projectconfig_1=require("./projectconfig"),common_2=require("./common"),schemaValidate_1=require("../validate/schemaValidate"),reactiveCache_1=require("./reactiveCache"),signatureValidate=require("../validate/signaturejson"),gamePluginJSONValidate=require("../validate/gamepluginjson");function isPluginMode(o){return o.type===config_1.COMPILE_TYPE.miniGamePlugin}function checkLocalPlugin(o,t){const{project:e,root:a,filePath:r}=o,i=t.path;let n=e.stat(a,i);n&&n.isDirectory||common_1.throwError({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t.tips+'["path"]',locales_1.default.config.DIRECTORY),filePath:r});const c=path_1.default.posix.join(i,"signature.json");n=e.stat(a,c);let s=tools_1.normalizePath(path_1.default.posix.join(a,c));n||common_1.throwError({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t.tips+'["path"]',s),filePath:r,code:config_1.FILE_NOT_FOUND});let _=e.getFile(a,c),l=common_1.checkUTF8(_,s);const f=common_2.checkJSONFormat(l,s);try{signatureValidate.check(f)}catch(o){common_1.throwError({msg:"signature.json"+o.message,filePath:s})}f.provider!==t.provider&&common_1.throwError({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format('["provider"]',`"${t.provider}"`),filePath:s});for(let o=0;o<f.signature.length;o++){const t=f.signature[o];common_1.checkPath({value:t.path,tips:`["signature"][${o}]["path"]`,filePath:s});const r=path_1.default.posix.join(i,t.path);n=e.stat(a,r),n&&n.isFile||common_1.throwError({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["signature"][${o}]["path"]`,r),filePath:s,code:config_1.FILE_NOT_FOUND});const c=e.getFile(a,r),_=tools_1.generateMD5(c);_!==t.md5&&common_1.throwError({msg:locales_1.default.config.GAME_PLUGIN_SIGNATURE_MD5_NOT_MATCH_CONTENT.format(path_1.default.posix.join(i,t.path),_,t.md5),code:config_1.GAME_PLUGIN_LIB_MD5_NOT_MATCH,filePath:s})}const m=path_1.default.posix.join(i,"plugin.json");n=e.stat(a,m),s=tools_1.normalizePath(path_1.default.posix.join(a,m)),n||common_1.throwError({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t.tips+'["path"]',s),code:config_1.FILE_NOT_FOUND,filePath:r}),_=e.getFile(a,m),l=common_1.checkUTF8(_,s);const h=common_2.checkJSONFormat(l,s);try{gamePluginJSONValidate.check(h)}catch(o){common_1.throwError({msg:"plugin.json"+o.message,filePath:s})}h.main&&(common_1.checkPath({value:h.main,tips:'["main"]',filePath:s}),n=e.stat(a,path_1.default.posix.join(i,h.main)),n||common_1.throwError({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["main"]',""+h.main),filePath:s,code:config_1.FILE_NOT_FOUND}))}function checkPluginPath(o,t){const{subPackages:e}=t,a=[],r=(o,t,e)=>{const{plugins:r}=o;if(r)for(const o in r){if(!r.hasOwnProperty(o))continue;const i=r[o];i&&i.path&&a.push({alias:o,version:i.version||"",provider:i.provider||"",tips:`${e}["plugins"]["${o}"]`,path:tools_1.normalizePath(path_1.default.posix.join(t,i.path))})}};if(r(t,"",""),e)for(let o=0;o<e.length;o++){const t=e[o];r(t,t.root||"",`["subPackages"][${o}]`)}if(!(a.length<=0))for(const t of a)checkLocalPlugin(o,t)}function checkPlugins(o,t){const{project:e,filePath:a}=o,r=[],i=t.plugins||{};function n(o,t){const i=e.appid,n=isPluginMode(e);if(n||"dev"!==o.version)if(n&&"dev"===o.version&&o.provider!==i)r.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t+'["provider"]',i));else if("dev"!==o.version||"string"!=typeof o.path){if("dev"===o.version||"latest"===o.version||/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/.test(o.version)||/^dev-[A-Za-z0-9]+$/.test(o.version))return o.path&&common_1.checkPath({value:o.path,tips:t+'["path"]',filePath:a}),!0;r.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t+'["version"]',locales_1.default.config.TRIPLE_NUMBER_DOT))}else r.push(locales_1.default.config.GAME_DEV_PLUGIN_SHOULD_NOT_USE_LOCAL_PATH.format(t,t+'["path"]'));else r.push(`${locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(t+'["version"]',"dev")}\n${locales_1.default.config.PLEASE_CHOOSE_PLUGIN_MODE}`)}const c={},s={};for(const o in i){if(!i.hasOwnProperty(o))continue;const t=i[o];n(t,`["plugins"]["${o}"]`)&&(c[t.provider]?r.push(locales_1.default.config.SAME_ITEM.format(`["plugins"]["${o}"]`,c[t.provider].tips,"provider")):c[t.provider]=s[o]={provider:t.provider,version:t.version,alias:o,path:t.path||"",tips:`["plugins"]["${o}"]`})}const _=t.subPackages||t.subpackages;if(Array.isArray(_))for(let o=0,t=_.length;o<t;o++){const t=_[o];if(!t.plugins)continue;const e=`["subPackages"][${o}]["plugins"]`;for(const o in t.plugins){const a=t.plugins[o],i=`${e}["${o}"]`;n(a,i)&&(c[a.provider]?r.push(locales_1.default.config.SAME_ITEM.format(i,c[a.provider].tips,"provider")):s[o]?r.push(locales_1.default.config.PLUGINS_SAME_ALIAS.format(i,s[o].tips)):c[a.provider]=s[o]={provider:a.provider,version:a.version,alias:o,path:a.path||"",tips:i})}}r.length>0&&common_1.throwError({msg:r.join("\n"),filePath:a})}function checkSubpackages(o,t){const{root:e,project:a,filePath:r}=o,i=[];let n='["subPackages"]';if(t.subpackages&&(n='["subpackages"]',t.subPackages=t.subpackages,delete t.subpackages),t.subPackages){const o=a.attrSync(),{setting:c}=o;t.subPackages.length>c.MaxSubPackageLimit&&common_1.throwError({msg:locales_1.default.config.EXCEED_LIMIT.format([n,c.MaxSubPackageLimit]),filePath:r});const s={},_={};for(let o=0,r=t.subPackages.length;o<r;o++){const r=t.subPackages[o];if(r.name){if(r.name===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){i.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["name"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(r.name===config_1.MINI_GAME_MAIN_PACKAGE_ROOT){i.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["name"]`,config_1.MINI_GAME_MAIN_PACKAGE_ROOT));continue}s[r.name]&&i.push(locales_1.default.config.SAME_ITEM.format(`${n}[${o}]`,s[r.name],"name")),s[r.name]=`${n}[${o}]`}if(r.root===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){i.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(r.root===config_1.MINI_GAME_MAIN_PACKAGE_ROOT){i.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,config_1.MINI_GAME_MAIN_PACKAGE_ROOT));continue}if(r.root.startsWith(".")){i.push(locales_1.default.config.JSON_SHOULD_NOT_START_WITH.format(`${n}[${o}]["root"]`,"."));continue}if(r.root.startsWith("__wx__")){i.push(locales_1.default.config.JSON_SHOULD_NOT_START_WITH.format(`${n}[${o}]["root"]`,"__wx__"));continue}r.root.startsWith("/")||(r.root=tools_1.normalizePath("/"+r.root)),/\.js$/.test(r.root)?r.root=tools_1.normalizePath(r.root):r.root=tools_1.normalizePath(r.root+"/"),_[r.root]&&i.push(locales_1.default.config.SAME_ITEM.format(`${n}[${o}]`,_[r.root],"root")),_[r.root]=`${n}[${o}]`;const c=a.stat(e,r.root);if(c){if(c.isDirectory){/\/$/.test(r.root)||(r.root+="/");const t=path_1.default.posix.join(r.root,"./game.js"),c=a.stat(e,t);c&&c.isFile||i.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`${n}[${o}]["root"]`,t))}}else i.push(locales_1.default.config.JSON_CONTENT_NOT_FOUND.format(`${n}[${o}]["root"]`))}}i.length>0&&common_1.throwError({msg:i.join("\n"),filePath:r})}function checkLoadingImageUrl(o,t){const{project:e,root:a,filePath:r}=o,{loadingImageInfo:i}=t;if(!i)return;common_1.checkPath({tips:'["loadingImageInfo"]["path"]',value:i.path,filePath:r});const n=e.stat(a,i.path);n&&n.isFile||common_1.throwError({msg:locales_1.default.config.JSON_CONTENT_NOT_FOUND.format(`["loadingImageInfo"]["path"]: "${i.path}"`),filePath:r}),i.progressBarColor&&!tools_1.isHexColor(i.progressBarColor)&&common_1.throwError({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(`["loadingImageInfo"]["progressBarColor"]: "${i.progressBarColor}"`,"HexColor"),filePath:r})}function checkWorkers(o,t){const{project:e,root:a,filePath:r}=o,{workers:i}=t;if(void 0===i)return;common_1.checkPath({tips:'["workers"]',value:i,filePath:r});const n=e.stat(a,i);n&&!n.isFile||common_1.throwError({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(['["workers"]',locales_1.default.config.DIRECTORY]),filePath:r})}function checkOpenDataContext(o,t){const{project:e,root:a,filePath:r}=o,{openDataContext:i}=t;if(void 0===i)return;common_1.checkPath({value:i,tips:'["openDataContext"]',filePath:r});const n=e.stat(a,i);n&&n.isDirectory||common_1.throwError({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(['["openDataContext"]',locales_1.default.config.DIRECTORY]),filePath:r});const c=path_1.default.posix.join(i,"./index.js"),s=e.stat(a,c);s&&s.isFile||common_1.throwError({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["openDataContext"]',c),filePath:r}),t.openDataContext=tools_1.normalizePath(i+"/")}function checkGameJSON(o){const{project:t,root:e,filePath:a}=o;t.stat(e,"game.json")||common_1.throwError({msg:locales_1.default.config.FILE_NOT_FOUND.format(path_1.default.posix.join(a)),filePath:a,code:config_1.FILE_NOT_FOUND});const r=t.getFile(e,"game.json"),i=common_2.checkJSONFormat(common_1.checkUTF8(r,a),a),n=schemaValidate_1.schemaValidate("game",i);if(n.warning&&(i.__warning__=locales_1.default.config.INVALID.format(n.warning)),n.error.length){const o=n.error.map(o=>"type"===o.errorType||"enum"===o.errorType||"anyOf"===o.errorType?locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([o.errorProperty,o.correctType]):locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([o.requireProperty])).join("\n");common_1.throwError({msg:o,filePath:a})}return checkOpenDataContext(o,i),checkPlugins(o,i),checkSubpackages(o,i),checkPluginPath(o,i),checkLoadingImageUrl(o,i),checkWorkers(o,i),i}const getGameJSON=reactiveCache_1.wrapCompileJSONFunc(cache_1.CACHE_KEY.GAME_JSON,o=>{const t=projectconfig_1.getProjectConfigJSON(o).miniprogramRoot||"";return checkGameJSON({project:o,root:t,filePath:tools_1.normalizePath(path_1.default.posix.join(t,"game.json"))})});exports.default=getGameJSON;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),cache_1=require("../../utils/cache"),common_1=require("../../utils/common"),config_1=require("../../config"),tools_1=require("../../utils/tools"),path_1=(0,tslib_1.__importDefault)(require("path")),locales_1=(0,tslib_1.__importDefault)(require("../../utils/locales/locales")),projectconfig_1=require("./projectconfig"),common_2=require("./common"),schemaValidate_1=require("../validate/schemaValidate"),reactiveCache_1=require("./reactiveCache"),signatureValidate=require("../validate/signaturejson"),gamePluginJSONValidate=require("../validate/gamepluginjson");function isPluginMode(o){return o.type===config_1.COMPILE_TYPE.miniGamePlugin}function checkLocalPlugin(o,t){const{project:e,root:a,filePath:r}=o,i=t.path;let n=e.stat(a,i);n&&n.isDirectory||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t.tips+'["path"]',locales_1.default.config.DIRECTORY),filePath:r});const c=path_1.default.posix.join(i,"signature.json");n=e.stat(a,c);let s=(0,tools_1.normalizePath)(path_1.default.posix.join(a,c));n||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t.tips+'["path"]',s),filePath:r,code:config_1.FILE_NOT_FOUND});let _=e.getFile(a,c),l=(0,common_1.checkUTF8)(_,s);const f=(0,common_2.checkJSONFormat)(l,s);try{signatureValidate.check(f)}catch(o){(0,common_1.throwError)({msg:"signature.json"+o.message,filePath:s})}f.provider!==t.provider&&(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format('["provider"]',`"${t.provider}"`),filePath:s});for(let o=0;o<f.signature.length;o++){const t=f.signature[o];(0,common_1.checkPath)({value:t.path,tips:`["signature"][${o}]["path"]`,filePath:s});const r=path_1.default.posix.join(i,t.path);n=e.stat(a,r),n&&n.isFile||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["signature"][${o}]["path"]`,r),filePath:s,code:config_1.FILE_NOT_FOUND});const c=e.getFile(a,r),_=(0,tools_1.generateMD5)(c);_!==t.md5&&(0,common_1.throwError)({msg:locales_1.default.config.GAME_PLUGIN_SIGNATURE_MD5_NOT_MATCH_CONTENT.format(path_1.default.posix.join(i,t.path),_,t.md5),code:config_1.GAME_PLUGIN_LIB_MD5_NOT_MATCH,filePath:s})}const m=path_1.default.posix.join(i,"plugin.json");n=e.stat(a,m),s=(0,tools_1.normalizePath)(path_1.default.posix.join(a,m)),n||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t.tips+'["path"]',s),code:config_1.FILE_NOT_FOUND,filePath:r}),_=e.getFile(a,m),l=(0,common_1.checkUTF8)(_,s);const h=(0,common_2.checkJSONFormat)(l,s);try{gamePluginJSONValidate.check(h)}catch(o){(0,common_1.throwError)({msg:"plugin.json"+o.message,filePath:s})}h.main&&((0,common_1.checkPath)({value:h.main,tips:'["main"]',filePath:s}),n=e.stat(a,path_1.default.posix.join(i,h.main)),n||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["main"]',""+h.main),filePath:s,code:config_1.FILE_NOT_FOUND}))}function checkPluginPath(o,t){const{subPackages:e}=t,a=[],r=(o,t,e)=>{const{plugins:r}=o;if(r)for(const o in r){if(!r.hasOwnProperty(o))continue;const i=r[o];i&&i.path&&a.push({alias:o,version:i.version||"",provider:i.provider||"",tips:`${e}["plugins"]["${o}"]`,path:(0,tools_1.normalizePath)(path_1.default.posix.join(t,i.path))})}};if(r(t,"",""),e)for(let o=0;o<e.length;o++){const t=e[o];r(t,t.root||"",`["subPackages"][${o}]`)}if(!(a.length<=0))for(const t of a)checkLocalPlugin(o,t)}function checkPlugins(o,t){const{project:e,filePath:a}=o,r=[],i=t.plugins||{};function n(o,t){const i=e.appid,n=isPluginMode(e);if(n||"dev"!==o.version)if(n&&"dev"===o.version&&o.provider!==i)r.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t+'["provider"]',i));else if("dev"!==o.version||"string"!=typeof o.path){if("dev"===o.version||"latest"===o.version||/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/.test(o.version)||/^dev-[A-Za-z0-9]+$/.test(o.version))return o.path&&(0,common_1.checkPath)({value:o.path,tips:t+'["path"]',filePath:a}),!0;r.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t+'["version"]',locales_1.default.config.TRIPLE_NUMBER_DOT))}else r.push(locales_1.default.config.GAME_DEV_PLUGIN_SHOULD_NOT_USE_LOCAL_PATH.format(t,t+'["path"]'));else r.push(`${locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(t+'["version"]',"dev")}\n${locales_1.default.config.PLEASE_CHOOSE_PLUGIN_MODE}`)}const c={},s={};for(const o in i){if(!i.hasOwnProperty(o))continue;const t=i[o];n(t,`["plugins"]["${o}"]`)&&(c[t.provider]?r.push(locales_1.default.config.SAME_ITEM.format(`["plugins"]["${o}"]`,c[t.provider].tips,"provider")):c[t.provider]=s[o]={provider:t.provider,version:t.version,alias:o,path:t.path||"",tips:`["plugins"]["${o}"]`})}const _=t.subPackages||t.subpackages;if(Array.isArray(_))for(let o=0,t=_.length;o<t;o++){const t=_[o];if(!t.plugins)continue;const e=`["subPackages"][${o}]["plugins"]`;for(const o in t.plugins){const a=t.plugins[o],i=`${e}["${o}"]`;n(a,i)&&(c[a.provider]?r.push(locales_1.default.config.SAME_ITEM.format(i,c[a.provider].tips,"provider")):s[o]?r.push(locales_1.default.config.PLUGINS_SAME_ALIAS.format(i,s[o].tips)):c[a.provider]=s[o]={provider:a.provider,version:a.version,alias:o,path:a.path||"",tips:i})}}r.length>0&&(0,common_1.throwError)({msg:r.join("\n"),filePath:a})}function checkSubpackages(o,t){const{root:e,project:a,filePath:r}=o,i=[];let n='["subPackages"]';if(t.subpackages&&(n='["subpackages"]',t.subPackages=t.subpackages,delete t.subpackages),t.subPackages){const o=a.attrSync(),{setting:c}=o;t.subPackages.length>c.MaxSubPackageLimit&&(0,common_1.throwError)({msg:locales_1.default.config.EXCEED_LIMIT.format([n,c.MaxSubPackageLimit]),filePath:r});const s={},_={};for(let o=0,r=t.subPackages.length;o<r;o++){const r=t.subPackages[o];if(r.name){if(r.name===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){i.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["name"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(r.name===config_1.MINI_GAME_MAIN_PACKAGE_ROOT){i.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["name"]`,config_1.MINI_GAME_MAIN_PACKAGE_ROOT));continue}s[r.name]&&i.push(locales_1.default.config.SAME_ITEM.format(`${n}[${o}]`,s[r.name],"name")),s[r.name]=`${n}[${o}]`}if(r.root===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){i.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(r.root===config_1.MINI_GAME_MAIN_PACKAGE_ROOT){i.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,config_1.MINI_GAME_MAIN_PACKAGE_ROOT));continue}if(r.root.startsWith(".")){i.push(locales_1.default.config.JSON_SHOULD_NOT_START_WITH.format(`${n}[${o}]["root"]`,"."));continue}if(r.root.startsWith("__wx__")){i.push(locales_1.default.config.JSON_SHOULD_NOT_START_WITH.format(`${n}[${o}]["root"]`,"__wx__"));continue}r.root.startsWith("/")||(r.root=(0,tools_1.normalizePath)("/"+r.root)),/\.js$/.test(r.root)?r.root=(0,tools_1.normalizePath)(r.root):r.root=(0,tools_1.normalizePath)(r.root+"/"),_[r.root]&&i.push(locales_1.default.config.SAME_ITEM.format(`${n}[${o}]`,_[r.root],"root")),_[r.root]=`${n}[${o}]`;const c=a.stat(e,r.root);if(c){if(c.isDirectory){/\/$/.test(r.root)||(r.root+="/");const t=path_1.default.posix.join(r.root,"./game.js"),c=a.stat(e,t);c&&c.isFile||i.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`${n}[${o}]["root"]`,t))}}else i.push(locales_1.default.config.JSON_CONTENT_NOT_FOUND.format(`${n}[${o}]["root"]`))}}i.length>0&&(0,common_1.throwError)({msg:i.join("\n"),filePath:r})}function checkLoadingImageUrl(o,t){const{project:e,root:a,filePath:r}=o,{loadingImageInfo:i}=t;if(!i)return;(0,common_1.checkPath)({tips:'["loadingImageInfo"]["path"]',value:i.path,filePath:r});const n=e.stat(a,i.path);n&&n.isFile||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_NOT_FOUND.format(`["loadingImageInfo"]["path"]: "${i.path}"`),filePath:r}),i.progressBarColor&&!(0,tools_1.isHexColor)(i.progressBarColor)&&(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(`["loadingImageInfo"]["progressBarColor"]: "${i.progressBarColor}"`,"HexColor"),filePath:r})}function checkWorkers(o,t){const{project:e,root:a,filePath:r}=o,{workers:i}=t;if(void 0===i)return;(0,common_1.checkPath)({tips:'["workers"]',value:i,filePath:r});const n=e.stat(a,i);n&&!n.isFile||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(['["workers"]',locales_1.default.config.DIRECTORY]),filePath:r})}function checkOpenDataContext(o,t){const{project:e,root:a,filePath:r}=o,{openDataContext:i}=t;if(void 0===i)return;(0,common_1.checkPath)({value:i,tips:'["openDataContext"]',filePath:r});const n=e.stat(a,i);n&&n.isDirectory||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(['["openDataContext"]',locales_1.default.config.DIRECTORY]),filePath:r});const c=path_1.default.posix.join(i,"./index.js"),s=e.stat(a,c);s&&s.isFile||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["openDataContext"]',c),filePath:r}),t.openDataContext=(0,tools_1.normalizePath)(i+"/")}function checkGameJSON(o){const{project:t,root:e,filePath:a}=o;t.stat(e,"game.json")||(0,common_1.throwError)({msg:locales_1.default.config.FILE_NOT_FOUND.format(path_1.default.posix.join(a)),filePath:a,code:config_1.FILE_NOT_FOUND});const r=t.getFile(e,"game.json"),i=(0,common_2.checkJSONFormat)((0,common_1.checkUTF8)(r,a),a),n=(0,schemaValidate_1.schemaValidate)("game",i);if(n.warning&&(i.__warning__=locales_1.default.config.INVALID.format(n.warning)),n.error.length){const o=n.error.map(o=>"type"===o.errorType||"enum"===o.errorType||"anyOf"===o.errorType?locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([o.errorProperty,o.correctType]):locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([o.requireProperty])).join("\n");(0,common_1.throwError)({msg:o,filePath:a})}return checkOpenDataContext(o,i),checkPlugins(o,i),checkSubpackages(o,i),checkPluginPath(o,i),checkLoadingImageUrl(o,i),checkWorkers(o,i),i}const getGameJSON=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.GAME_JSON,o=>{const t=(0,projectconfig_1.getProjectConfigJSON)(o).miniprogramRoot||"";return checkGameJSON({project:o,root:t,filePath:(0,tools_1.normalizePath)(path_1.default.posix.join(t,"game.json"))})});exports.default=getGameJSON;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkPageJSON=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),locales_1=tslib_1.__importDefault(require("../../../utils/locales/locales")),common_1=require("../common"),schemaValidate_1=require("../../validate/schemaValidate"),tools_1=require("../../../utils/tools"),common_2=require("../../../utils/common"),theme_1=require("../theme"),checkHexColor=e=>{const{inputJSON:o,mode:a,pagePath:t,themeLocation:r}=e;let i=t+".json";if(o){r&&(i=`${t}.json or ${r}["${a}"]`);const{navigationBarBackgroundColor:e,backgroundColor:n}=o;void 0===e||tools_1.isHexColor(e)||common_2.throwError({msg:`["navigationBarBackgroundColor"]: "${e}" is not hexColor`,filePath:i}),void 0===n||tools_1.isHexColor(n)||common_2.throwError({msg:`["backgroundColor"]: "${n}" is not hexColor`,filePath:i})}};function checkPageJSON(e,o){const{pagePath:a,miniprogramRoot:t=""}=o;let r=tools_1.normalizePath(path_1.default.posix.join(t,a+".json"));if(!e.stat("",r))return{};const i=e.getFile("",r),n=common_1.checkJSONFormat(common_2.checkUTF8(i,r),r),l=theme_1.getThemeLocation(e);if(!l){const e=common_1.getPageJSONVariableDecalearProperty(n);e.length&&common_2.throwError({msg:'["themeLocation"] is required because:\n'+e.map(e=>`"${e.value}" as variable was declared at ${r}:${e.property}`).join("\n"),filePath:r})}let c={light:{},dark:{}};l&&(c=theme_1.checkThemeJSON(e,{themeLocation:l}));const m=theme_1.mergeThemeJSONToPageJSON(c,n,r),h=schemaValidate_1.schemaValidate("page",m.pageJSONLight),s=schemaValidate_1.schemaValidate("page",m.pageJSONDark),g=common_1.getPageJSONVariableDecalearProperty(m.pageJSONLight);g.length&&common_2.throwError({msg:g.map(e=>`"${e.value}" as variable was declared at ${r}:${e.property}, but not found at ${l}["light"]`).join("\n"),filePath:r});const _=common_1.getPageJSONVariableDecalearProperty(m.pageJSONDark);if(_.length&&common_2.throwError({msg:_.map(e=>`"${e.value}" as variable was declared at ${r}:${e.property}, but not found at ${l}["dark"]`).join("\n"),filePath:r}),h.warning&&(n.__warning__=locales_1.default.config.INVALID.format(h.warning)),l&&s.warning&&(n.__warning__=locales_1.default.config.INVALID.format(s.warning)),h.error.length){const e=common_1.transValidateResult(h);l&&(r+=` or ${l}["light"]`),common_2.throwError({msg:e,filePath:r})}if(l&&s.error.length){const e=common_1.transValidateResult(s);l&&(r+=` or ${l}["dark"]`),common_2.throwError({msg:e,filePath:r})}return checkHexColor({inputJSON:m.pageJSONLight,mode:"light",themeLocation:l||"",filePath:r,pagePath:a}),checkHexColor({inputJSON:m.pageJSONDark,mode:"dark",themeLocation:l||"",filePath:r,pagePath:a}),n}exports.checkPageJSON=checkPageJSON;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkPageJSON=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")),common_1=require("../common"),schemaValidate_1=require("../../validate/schemaValidate"),tools_1=require("../../../utils/tools"),common_2=require("../../../utils/common"),theme_1=require("../theme"),checkHexColor=e=>{const{inputJSON:o,mode:a,pagePath:t,themeLocation:r}=e;let i=t+".json";if(o){r&&(i=`${t}.json or ${r}["${a}"]`);const{navigationBarBackgroundColor:e,backgroundColor:n}=o;void 0===e||(0,tools_1.isHexColor)(e)||(0,common_2.throwError)({msg:`["navigationBarBackgroundColor"]: "${e}" is not hexColor`,filePath:i}),void 0===n||(0,tools_1.isHexColor)(n)||(0,common_2.throwError)({msg:`["backgroundColor"]: "${n}" is not hexColor`,filePath:i})}};function checkPageJSON(e,o){const{pagePath:a,miniprogramRoot:t=""}=o;let r=(0,tools_1.normalizePath)(path_1.default.posix.join(t,a+".json"));if(!e.stat("",r))return{};const i=e.getFile("",r),n=(0,common_1.checkJSONFormat)((0,common_2.checkUTF8)(i,r),r),l=(0,theme_1.getThemeLocation)(e);if(!l){const e=(0,common_1.getPageJSONVariableDecalearProperty)(n);e.length&&(0,common_2.throwError)({msg:'["themeLocation"] is required because:\n'+e.map(e=>`"${e.value}" as variable was declared at ${r}:${e.property}`).join("\n"),filePath:r})}let c={light:{},dark:{}};l&&(c=(0,theme_1.checkThemeJSON)(e,{themeLocation:l}));const m=(0,theme_1.mergeThemeJSONToPageJSON)(c,n,r),h=(0,schemaValidate_1.schemaValidate)("page",m.pageJSONLight),s=(0,schemaValidate_1.schemaValidate)("page",m.pageJSONDark),g=(0,common_1.getPageJSONVariableDecalearProperty)(m.pageJSONLight);g.length&&(0,common_2.throwError)({msg:g.map(e=>`"${e.value}" as variable was declared at ${r}:${e.property}, but not found at ${l}["light"]`).join("\n"),filePath:r});const _=(0,common_1.getPageJSONVariableDecalearProperty)(m.pageJSONDark);if(_.length&&(0,common_2.throwError)({msg:_.map(e=>`"${e.value}" as variable was declared at ${r}:${e.property}, but not found at ${l}["dark"]`).join("\n"),filePath:r}),h.warning&&(n.__warning__=locales_1.default.config.INVALID.format(h.warning)),l&&s.warning&&(n.__warning__=locales_1.default.config.INVALID.format(s.warning)),h.error.length){const e=(0,common_1.transValidateResult)(h);l&&(r+=` or ${l}["light"]`),(0,common_2.throwError)({msg:e,filePath:r})}if(l&&s.error.length){const e=(0,common_1.transValidateResult)(s);l&&(r+=` or ${l}["dark"]`),(0,common_2.throwError)({msg:e,filePath:r})}return checkHexColor({inputJSON:m.pageJSONLight,mode:"light",themeLocation:l||"",filePath:r,pagePath:a}),checkHexColor({inputJSON:m.pageJSONDark,mode:"dark",themeLocation:l||"",filePath:r,pagePath:a}),n}exports.checkPageJSON=checkPageJSON;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPageJSON=exports.originGetPageJSON=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=require("lodash"),getExtJSON_1=require("../app/getExtJSON"),app_1=require("../app"),tools_1=require("../../../utils/tools"),checkPageJSON_1=require("./checkPageJSON"),common_1=require("../common"),common_2=require("../../../utils/common"),locales_1=tslib_1.__importDefault(require("../../../utils/locales/locales")),reactiveCache_1=require("../reactiveCache"),spreadUsingComponent=e=>{const{project:t,pagePath:o,inputJSON:n}=e;if(o.includes("miniprogram_npm"))return;const i=app_1.getAppJSON(t);if(common_1.checkPagePathIsInIndependentSubpackage(i,o))return;const a=Object.assign({},i.usingComponents);if(0!==Object.keys(a).length){n.usingComponents||(n.usingComponents={});for(const e in a){if(n.usingComponents[e])continue;const t=a[e]||"";if(t.startsWith("/")||t.startsWith("plugin://")){n.usingComponents[e]=t;continue}const i=tools_1.normalizePath(path_1.default.posix.relative(path_1.default.posix.dirname(o),t));n.usingComponents[e]=i.startsWith(".")?i:"./"+i}}},mergeExtJSON=e=>{var t;const{project:o,inputJSON:n,pagePath:i}=e,a=getExtJSON_1.getExtJSON(o);(null===(t=null==a?void 0:a.extPages)||void 0===t?void 0:t[i])&&Object.assign(n,a.extPages[i])},checkComponentPath=e=>{const{project:t,miniprogramRoot:o,pagePath:n,inputJSON:i}=e;common_1.checkComponentPath({project:t,root:o,relativePath:n+".json",inputJSON:i})},checkComponentGenerics=e=>{const{pagePath:t,inputJSON:o}=e,n=t+".json";if(!o.componentGenerics)return;const i=[];for(const e in o.componentGenerics){const t=o.componentGenerics[e],n=tools_1.getType(t);"boolean"===n||"object"===n?"object"===n&&"string"!==tools_1.getType(t.default)&&i.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`["componentGenerics"]["${e}"]["default"]`,"string"])):i.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`["componentGenerics"]["${e}"]`,"boolean/object"]))}i.length>0&&common_2.throwError({msg:i.join("\n"),filePath:n})},compilePageJSON=e=>{mergeExtJSON(e),checkComponentGenerics(e),checkComponentPath(e),spreadUsingComponent(e)};function originGetPageJSON(e,t){const{pagePath:o,miniprogramRoot:n=""}=t,i=tools_1.normalizePath(path_1.default.posix.join(n,o+".json")),a=reactiveCache_1.tryToGetReactiveJSONCompiler(e),c=lodash_1.cloneDeep(a.getPageJSON("checked",t));return compilePageJSON({project:e,miniprogramRoot:n,inputJSON:c,filePath:i,pagePath:o}),c.usingComponents||(c.usingComponents={}),c}async function getPageJSON(e,t){const o=reactiveCache_1.tryToGetReactiveProject(e);return
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPageJSON=exports.originGetPageJSON=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),lodash_1=require("lodash"),getExtJSON_1=require("../app/getExtJSON"),app_1=require("../app"),tools_1=require("../../../utils/tools"),checkPageJSON_1=require("./checkPageJSON"),common_1=require("../common"),common_2=require("../../../utils/common"),locales_1=(0,tslib_1.__importDefault)(require("../../../utils/locales/locales")),reactiveCache_1=require("../reactiveCache"),spreadUsingComponent=e=>{const{project:t,pagePath:o,inputJSON:n}=e;if(o.includes("miniprogram_npm"))return;const i=(0,app_1.getAppJSON)(t);if((0,common_1.checkPagePathIsInIndependentSubpackage)(i,o))return;const a=Object.assign({},i.usingComponents);if(0!==Object.keys(a).length){n.usingComponents||(n.usingComponents={});for(const e in a){if(n.usingComponents[e])continue;const t=a[e]||"";if(t.startsWith("/")||t.startsWith("plugin://")){n.usingComponents[e]=t;continue}const i=(0,tools_1.normalizePath)(path_1.default.posix.relative(path_1.default.posix.dirname(o),t));n.usingComponents[e]=i.startsWith(".")?i:"./"+i}}},mergeExtJSON=e=>{var t;const{project:o,inputJSON:n,pagePath:i}=e,a=(0,getExtJSON_1.getExtJSON)(o);(null===(t=null==a?void 0:a.extPages)||void 0===t?void 0:t[i])&&Object.assign(n,a.extPages[i])},checkComponentPath=e=>{const{project:t,miniprogramRoot:o,pagePath:n,inputJSON:i}=e;(0,common_1.checkComponentPath)({project:t,root:o,relativePath:n+".json",inputJSON:i})},checkComponentGenerics=e=>{const{pagePath:t,inputJSON:o}=e,n=t+".json";if(!o.componentGenerics)return;const i=[];for(const e in o.componentGenerics){const t=o.componentGenerics[e],n=(0,tools_1.getType)(t);"boolean"===n||"object"===n?"object"===n&&"string"!==(0,tools_1.getType)(t.default)&&i.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`["componentGenerics"]["${e}"]["default"]`,"string"])):i.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`["componentGenerics"]["${e}"]`,"boolean/object"]))}i.length>0&&(0,common_2.throwError)({msg:i.join("\n"),filePath:n})},compilePageJSON=e=>{mergeExtJSON(e),checkComponentGenerics(e),checkComponentPath(e),spreadUsingComponent(e)};function originGetPageJSON(e,t){const{pagePath:o,miniprogramRoot:n=""}=t,i=(0,tools_1.normalizePath)(path_1.default.posix.join(n,o+".json")),a=(0,reactiveCache_1.tryToGetReactiveJSONCompiler)(e),c=(0,lodash_1.cloneDeep)(a.getPageJSON("checked",t));return compilePageJSON({project:e,miniprogramRoot:n,inputJSON:c,filePath:i,pagePath:o}),c.usingComponents||(c.usingComponents={}),c}async function getPageJSON(e,t){const o=(0,reactiveCache_1.tryToGetReactiveProject)(e);return(0,reactiveCache_1.tryToGetReactiveJSONCompiler)(o).getPageJSON("compiled",t)}exports.originGetPageJSON=originGetPageJSON,reactiveCache_1.ReactiveJSONCompiler.setOriginCheckPageJSON(checkPageJSON_1.checkPageJSON),reactiveCache_1.ReactiveJSONCompiler.setOriginGetPageJSON(originGetPageJSON),exports.getPageJSON=getPageJSON;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getGameLocalPluginJSON=exports.getDevPluginJSON=exports.checkWorkers=exports.checkComponentPath=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),projectconfig_1=require("../projectconfig"),locales_1=tslib_1.__importDefault(require("../../../utils/locales/locales")),common_1=require("../common"),config_1=require("../../../config"),schemaValidate_1=require("../../validate/schemaValidate"),tools_1=require("../../../utils/tools"),cache_1=require("../../../utils/cache"),common_2=require("../../../utils/common"),reactiveCache_1=require("../reactiveCache");function checkComponentPath(o,e){const{project:t,root:c,filePath:i}=o;void 0!==e.usingComponents&&common_1.checkComponentPath({project:t,root:c,relativePath:path_1.default.posix.relative(c,i),inputJSON:e})}function checkPublicComponentsAndPages(o,e){const{project:t,root:c,filePath:i}=o,{publicComponents:n,pages:r}=e,a={};if(n){const o=[];for(const r in n){const n=e.publicComponents[r];common_2.checkPath({value:n,tips:`["publicComponents"]["${r}"]`,filePath:i,code:config_1.PLUGIN_JSON_CONTENT_ERR});let l=t.stat(c,n+".wxml");l&&!l.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["publicComponents"]["${n}"]`,n+".wxml")),l=t.stat(c,n+".js"),l&&!l.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["publicComponents"]["${n}"]`,n+".js")),l=t.stat(c,n+".json"),l&&!l.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["publicComponents"]["${n}"]`,n+".json")),a[r]=!0}o.length>0&&common_2.throwError({msg:o.join("\n"),code:config_1.PLUGIN_JSON_CONTENT_ERR,filePath:i})}if(r){const o=[];for(const e in r){const n=r[e];common_2.checkPath({value:n,tips:`["pages"]["${e}"]`,filePath:i,code:config_1.PLUGIN_JSON_CONTENT_ERR});let l=t.stat(c,n+".wxml");l&&!l.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["pages"]["${n}"]`,n+".wxml")),l=t.stat(c,n+".js"),l&&!l.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["pages"]["${n}"]`,n+".js")),l=t.stat(c,n+".json"),l&&!l.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["pages"]["${n}"]`,n+".json")),a[e]&&o.push(locales_1.default.config.SAME_KEY_PAGE_PUBLICCOMPONENTS.format(`"${e}"`)),a[e]=!0}o.length>0&&common_2.throwError({msg:o.join("\n"),code:config_1.PLUGIN_JSON_CONTENT_ERR,filePath:i})}}function checkWorkers(o,e){const{project:t,root:c,filePath:i}=o,{workers:n}=e;if(void 0===n)return;const r='["workers"]';""===n&&common_2.throwError({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(r,locales_1.default.config.DIRECTORY),filePath:i}),common_2.checkPath({value:n,tips:r,filePath:i});const a=t.stat(c,n);a&&a.isDirectory||common_2.throwError({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([r,locales_1.default.config.DIRECTORY]),filePath:i}),e.workers=tools_1.normalizePath(n+"/")}function checkMain(o,e){const{project:t,root:c,filePath:i}=o,{main:n}=e;if(void 0===n)return;""===n&&common_2.throwError({msg:locales_1.default.config.SHOULD_NOT_BE_EMPTY.format('["main"]'),code:config_1.PLUGIN_JSON_CONTENT_ERR,filePath:i}),common_2.checkPath({value:n,tips:'["main"]',filePath:i,code:config_1.PLUGIN_JSON_CONTENT_ERR});const r=t.stat(c,n);r&&!r.isDirectory||common_2.throwError({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["main"]',n),code:config_1.PLUGIN_JSON_CONTENT_ERR,filePath:i})}function isKindOfGamePlugin(o){return o.type===config_1.COMPILE_TYPE.miniGamePlugin}function checkPluginJSON(o){const{root:e="",project:t}=o,c=path_1.default.posix.join(e,"plugin.json");t.stat(e,"plugin.json")||common_2.throwError({msg:locales_1.default.config.PLUGIN_JSON_NOT_FOUND.format(e,"plugin.json"),code:config_1.PLUGIN_JSON_FILE_NOT_FOUND,filePath:c});const i=t.getFile(e,"plugin.json"),n=common_1.checkJSONFormat(common_2.checkUTF8(i,c),c),r=schemaValidate_1.schemaValidate("plugin",n);if(r.error.length){const o=r.error.map(o=>"type"===o.errorType||"enum"===o.errorType||"anyOf"===o.errorType?locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([o.errorProperty,o.correctType]):locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([o.requireProperty])).join("\n");common_2.throwError({msg:"pluginJSON$"+o,code:config_1.PLUGIN_JSON_CONTENT_ERR,filePath:c})}return void 0!==n.themeLocation&&common_2.checkPath({value:n.themeLocation,tips:'["themeLocation"]',filePath:c}),isKindOfGamePlugin(t)||(checkPublicComponentsAndPages(o,n),checkComponentPath(o,n)),checkMain(o,n),checkWorkers(o,n),n}exports.checkComponentPath=checkComponentPath,exports.checkWorkers=checkWorkers,exports.getDevPluginJSON=reactiveCache_1.wrapCompileJSONFunc(cache_1.CACHE_KEY.PLUGIN_JSON,(o,e="")=>{const t=projectconfig_1.getProjectConfigJSON(o),{pluginRoot:c=""}=t;let i=c;o.type===config_1.COMPILE_TYPE.miniGame&&e&&(i=e),e||c||common_2.throwError({msg:locales_1.default.config.NOT_FOUND.format('["pluginRoot"]'),filePath:"project.config.json",code:config_1.JSON_CONTENT_ERR});return checkPluginJSON({project:o,filePath:path_1.default.posix.join(i,"plugin.json"),root:i})});const getGameLocalPluginJSON=async(o,e)=>{const t=await
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getGameLocalPluginJSON=exports.getDevPluginJSON=exports.checkWorkers=exports.checkComponentPath=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),projectconfig_1=require("../projectconfig"),locales_1=(0,tslib_1.__importDefault)(require("../../../utils/locales/locales")),common_1=require("../common"),config_1=require("../../../config"),schemaValidate_1=require("../../validate/schemaValidate"),tools_1=require("../../../utils/tools"),cache_1=require("../../../utils/cache"),common_2=require("../../../utils/common"),reactiveCache_1=require("../reactiveCache");function checkComponentPath(o,e){const{project:t,root:c,filePath:i}=o;void 0!==e.usingComponents&&(0,common_1.checkComponentPath)({project:t,root:c,relativePath:path_1.default.posix.relative(c,i),inputJSON:e})}function checkPublicComponentsAndPages(o,e){const{project:t,root:c,filePath:i}=o,{publicComponents:n,pages:r}=e,a={};if(n){const o=[];for(const r in n){const n=e.publicComponents[r];(0,common_2.checkPath)({value:n,tips:`["publicComponents"]["${r}"]`,filePath:i,code:config_1.PLUGIN_JSON_CONTENT_ERR});let l=t.stat(c,n+".wxml");l&&!l.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["publicComponents"]["${n}"]`,n+".wxml")),l=t.stat(c,n+".js"),l&&!l.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["publicComponents"]["${n}"]`,n+".js")),l=t.stat(c,n+".json"),l&&!l.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["publicComponents"]["${n}"]`,n+".json")),a[r]=!0}o.length>0&&(0,common_2.throwError)({msg:o.join("\n"),code:config_1.PLUGIN_JSON_CONTENT_ERR,filePath:i})}if(r){const o=[];for(const e in r){const n=r[e];(0,common_2.checkPath)({value:n,tips:`["pages"]["${e}"]`,filePath:i,code:config_1.PLUGIN_JSON_CONTENT_ERR});let l=t.stat(c,n+".wxml");l&&!l.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["pages"]["${n}"]`,n+".wxml")),l=t.stat(c,n+".js"),l&&!l.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["pages"]["${n}"]`,n+".js")),l=t.stat(c,n+".json"),l&&!l.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["pages"]["${n}"]`,n+".json")),a[e]&&o.push(locales_1.default.config.SAME_KEY_PAGE_PUBLICCOMPONENTS.format(`"${e}"`)),a[e]=!0}o.length>0&&(0,common_2.throwError)({msg:o.join("\n"),code:config_1.PLUGIN_JSON_CONTENT_ERR,filePath:i})}}function checkWorkers(o,e){const{project:t,root:c,filePath:i}=o,{workers:n}=e;if(void 0===n)return;const r='["workers"]';""===n&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(r,locales_1.default.config.DIRECTORY),filePath:i}),(0,common_2.checkPath)({value:n,tips:r,filePath:i});const a=t.stat(c,n);a&&a.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([r,locales_1.default.config.DIRECTORY]),filePath:i}),e.workers=(0,tools_1.normalizePath)(n+"/")}function checkMain(o,e){const{project:t,root:c,filePath:i}=o,{main:n}=e;if(void 0===n)return;""===n&&(0,common_2.throwError)({msg:locales_1.default.config.SHOULD_NOT_BE_EMPTY.format('["main"]'),code:config_1.PLUGIN_JSON_CONTENT_ERR,filePath:i}),(0,common_2.checkPath)({value:n,tips:'["main"]',filePath:i,code:config_1.PLUGIN_JSON_CONTENT_ERR});const r=t.stat(c,n);r&&!r.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["main"]',n),code:config_1.PLUGIN_JSON_CONTENT_ERR,filePath:i})}function isKindOfGamePlugin(o){return o.type===config_1.COMPILE_TYPE.miniGamePlugin}function checkPluginJSON(o){const{root:e="",project:t}=o,c=path_1.default.posix.join(e,"plugin.json");t.stat(e,"plugin.json")||(0,common_2.throwError)({msg:locales_1.default.config.PLUGIN_JSON_NOT_FOUND.format(e,"plugin.json"),code:config_1.PLUGIN_JSON_FILE_NOT_FOUND,filePath:c});const i=t.getFile(e,"plugin.json"),n=(0,common_1.checkJSONFormat)((0,common_2.checkUTF8)(i,c),c),r=(0,schemaValidate_1.schemaValidate)("plugin",n);if(r.error.length){const o=r.error.map(o=>"type"===o.errorType||"enum"===o.errorType||"anyOf"===o.errorType?locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([o.errorProperty,o.correctType]):locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([o.requireProperty])).join("\n");(0,common_2.throwError)({msg:"pluginJSON$"+o,code:config_1.PLUGIN_JSON_CONTENT_ERR,filePath:c})}return void 0!==n.themeLocation&&(0,common_2.checkPath)({value:n.themeLocation,tips:'["themeLocation"]',filePath:c}),isKindOfGamePlugin(t)||(checkPublicComponentsAndPages(o,n),checkComponentPath(o,n)),checkMain(o,n),checkWorkers(o,n),n}exports.checkComponentPath=checkComponentPath,exports.checkWorkers=checkWorkers,exports.getDevPluginJSON=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.PLUGIN_JSON,(o,e="")=>{const t=(0,projectconfig_1.getProjectConfigJSON)(o),{pluginRoot:c=""}=t;let i=c;o.type===config_1.COMPILE_TYPE.miniGame&&e&&(i=e),e||c||(0,common_2.throwError)({msg:locales_1.default.config.NOT_FOUND.format('["pluginRoot"]'),filePath:"project.config.json",code:config_1.JSON_CONTENT_ERR});return checkPluginJSON({project:o,filePath:path_1.default.posix.join(i,"plugin.json"),root:i})});const getGameLocalPluginJSON=async(o,e)=>{const t=await(0,projectconfig_1.getProjectConfigJSON)(o),{miniprogramRoot:c}=t;if(!e)return{};const i=(0,tools_1.normalizePath)(path_1.default.posix.join(c||"",e));return checkPluginJSON({project:(0,reactiveCache_1.tryToGetReactiveProject)(o),filePath:path_1.default.posix.join(i,"plugin.json"),root:i})};exports.getGameLocalPluginJSON=getGameLocalPluginJSON;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPluginPageJSON=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),common_1=require("../common"),schemaValidate_1=require("../../validate/schemaValidate"),locales_1=tslib_1.__importDefault(require("../../../utils/locales/locales")),common_2=require("../../../utils/common"),plugin_1=require("./plugin"),theme_1=require("../theme"),spreadUsingComponent=async(e,t)=>{const{project:a,root:o,filePath:n}=t,i=path_1.default.posix.relative(o,n);if(n.includes("miniprogram_npm/"))return;const r=await
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPluginPageJSON=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),common_1=require("../common"),schemaValidate_1=require("../../validate/schemaValidate"),locales_1=(0,tslib_1.__importDefault)(require("../../../utils/locales/locales")),common_2=require("../../../utils/common"),plugin_1=require("./plugin"),theme_1=require("../theme"),spreadUsingComponent=async(e,t)=>{const{project:a,root:o,filePath:n}=t,i=path_1.default.posix.relative(o,n);if(n.includes("miniprogram_npm/"))return;const r=await(0,plugin_1.getDevPluginJSON)(a,!0),s=Object.assign({},r.usingComponents);if(0!==Object.keys(s).length){e.usingComponents||(e.usingComponents={});for(const t in s){if(e.usingComponents[t])continue;const a=s[t]||"";if(a.startsWith("/")||a.startsWith("plugin://")){e.usingComponents[t]=a;continue}const o=path_1.default.posix.normalize(path_1.default.posix.relative(path_1.default.posix.dirname(i),a));e.usingComponents[t]=o.startsWith(".")?o:"./"+o}}};async function checkComponentPath(e,t){const{project:a,root:o,filePath:n}=t;await(0,common_1.checkComponentPath)({project:a,root:o,relativePath:path_1.default.posix.relative(o,n),inputJSON:e})}async function getPluginPageJSON(e){const{project:t}=e;let a=e.filePath;if(!t.stat("",a))return{};const o=await t.getFile("",a),n=(0,common_1.checkJSONFormat)((0,common_2.checkUTF8)(o,a),a),i=await(0,theme_1.getPluginThemeLocation)(t);if(!i){const e=(0,common_1.getPageJSONVariableDecalearProperty)(n);e.length&&(0,common_2.throwError)({msg:'pluginJSON["themeLocation"] is required because:\n'+e.map(e=>`"${e.value}" as variable was declared at ${a}:${e.property}`).join("\n"),filePath:a})}let r={light:{},dark:{}};i&&(r=await(0,theme_1.checkThemeJSON)(t,{themeLocation:i,isPlugin:!0}));const s=(0,theme_1.mergeThemeJSONToPageJSON)(r,n,a),l=(0,schemaValidate_1.schemaValidate)("page",s.pageJSONLight),c=(0,schemaValidate_1.schemaValidate)("page",s.pageJSONDark);if(l.warning&&(n.__warning__=locales_1.default.config.INVALID.format(l.warning)),i&&c.warning&&(n.__warning__=locales_1.default.config.INVALID.format(c.warning)),l.error.length){const e=(0,common_1.transValidateResult)(l);i&&(a+=` or ${i}["light"]`),(0,common_2.throwError)({msg:e,filePath:a})}if(i&&c.error.length){const e=(0,common_1.transValidateResult)(c);i&&(a+=` or ${i}["dark"]`),(0,common_2.throwError)({msg:e,filePath:a})}return await checkComponentPath(n,e),await spreadUsingComponent(n,e),n}exports.getPluginPageJSON=getPluginPageJSON;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ProjectWithMockBuffer=void 0;const tslib_1=require("tslib"),project_1=require("../../ci/project"),tools_1=require("../../utils/tools"),path_1=tslib_1.__importDefault(require("path")),fs_1=tslib_1.__importDefault(require("fs"));class ProjectWithMockBuffer extends project_1.Project{constructor(){super(...arguments),this.mockBuffer={},this.__dirSet=new Set,this.__fileSet=new Set}setMockFileCache(t){Object.entries(t).forEach(([t,e])=>{this.mockBuffer[t]=Buffer.from(e)})}_getTargetPath(t,e){return
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ProjectWithMockBuffer=void 0;const tslib_1=require("tslib"),project_1=require("../../ci/project"),tools_1=require("../../utils/tools"),path_1=(0,tslib_1.__importDefault)(require("path")),fs_1=(0,tslib_1.__importDefault)(require("fs"));class ProjectWithMockBuffer extends project_1.Project{constructor(){super(...arguments),this.mockBuffer={},this.__dirSet=new Set,this.__fileSet=new Set}setMockFileCache(t){Object.entries(t).forEach(([t,e])=>{this.mockBuffer[t]=Buffer.from(e)})}_getTargetPath(t,e){return(0,tools_1.normalizePath)(path_1.default.posix.join(t,e)).replace(/\/$/,"").replace(/^\//,"")}getFile(t,e){const r=this._getTargetPath(t,e),i=(0,tools_1.normalizePath)(path_1.default.posix.join(this.projectPath,r));return this.mockBuffer[r]?this.mockBuffer[r]:fs_1.default.readFileSync(i,null)}stat(t,e){const r=this._getTargetPath(t,e);if(this.mockBuffer[r])return{isFile:!0,isDirectory:!1};if(this.__fileSet.has(r)){return{isFile:!0,isDirectory:!1,size:fs_1.default.statSync(path_1.default.posix.join(this.projectPath,r)).size}}return this.__dirSet.has(r)?{isFile:!1,isDirectory:!0}:void 0}}exports.ProjectWithMockBuffer=ProjectWithMockBuffer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getProjectConfigJSON=void 0;const tslib_1=require("tslib"),lodash_1=require("lodash"),common_1=require("../../utils/common"),common_2=require("./common"),schemaValidate_1=require("../validate/schemaValidate"),cache_1=require("../../utils/cache"),tools_1=require("../../utils/tools"),config_1=require("../../config"),locales_1=tslib_1.__importDefault(require("../../utils/locales/locales")),reactiveCache_1=require("./reactiveCache"),PROJECT_CONFIG_JSON="project.config.json",rootConfig=["svr","client","qcloudRoot","miniprogramRoot","pluginRoot","cloudfunctionRoot","jsserverRoot","testRoot"];function formatPath(o=""){return o&&"/"!==o?(o=tools_1.normalizePath(o+"/")).replace(/^(\/)*/,"").replace(/\.\.\//g,"").replace(/^\.\//,""):""}const _getProjectConfigJSON=reactiveCache_1.wrapCompileJSONFunc(cache_1.CACHE_KEY.PROJECT_CONFIG,o=>{if(!o.stat("",PROJECT_CONFIG_JSON))return o.type!==config_1.COMPILE_TYPE.miniGamePlugin&&o.type!==config_1.COMPILE_TYPE.miniProgramPlugin||common_1.throwError({msg:locales_1.default.config.NOT_FOUND.format("project.config.json"),code:config_1.FILE_NOT_FOUND,filePath:PROJECT_CONFIG_JSON}),{};const e=o.getFile("",PROJECT_CONFIG_JSON),r=common_1.checkUTF8(e,PROJECT_CONFIG_JSON),t=common_2.checkJSONFormat(r,PROJECT_CONFIG_JSON),i=schemaValidate_1.schemaValidate("projectconfig",t);if(i.error.length){const o=i.error.map(o=>"type"===o.errorType||"enum"===o.errorType||"anyOf"===o.errorType?locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([o.errorProperty,o.correctType]):locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([o.requireProperty])).join("\n");common_1.throwError({msg:o,filePath:PROJECT_CONFIG_JSON})}return o.miniprogramRoot=t.miniprogramRoot||"",o.pluginRoot=t.pluginRoot||"",rootConfig.forEach(o=>{"string"==typeof t[o]?t[o]=formatPath(t[o]):t[o]=""}),o.type!==config_1.COMPILE_TYPE.miniGamePlugin&&o.type!==config_1.COMPILE_TYPE.miniProgramPlugin||t.pluginRoot||common_1.throwError({msg:locales_1.default.config.SHOULD_NOT_BE_EMPTY.format('["pluginRoot"]'),filePath:PROJECT_CONFIG_JSON}),t}),getProjectConfigJSON=function(o){return
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getProjectConfigJSON=void 0;const tslib_1=require("tslib"),lodash_1=require("lodash"),common_1=require("../../utils/common"),common_2=require("./common"),schemaValidate_1=require("../validate/schemaValidate"),cache_1=require("../../utils/cache"),tools_1=require("../../utils/tools"),config_1=require("../../config"),locales_1=(0,tslib_1.__importDefault)(require("../../utils/locales/locales")),reactiveCache_1=require("./reactiveCache"),PROJECT_CONFIG_JSON="project.config.json",rootConfig=["svr","client","qcloudRoot","miniprogramRoot","pluginRoot","cloudfunctionRoot","jsserverRoot","testRoot"];function formatPath(o=""){return o&&"/"!==o?(o=(0,tools_1.normalizePath)(o+"/")).replace(/^(\/)*/,"").replace(/\.\.\//g,"").replace(/^\.\//,""):""}const _getProjectConfigJSON=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.PROJECT_CONFIG,o=>{if(!o.stat("",PROJECT_CONFIG_JSON))return o.type!==config_1.COMPILE_TYPE.miniGamePlugin&&o.type!==config_1.COMPILE_TYPE.miniProgramPlugin||(0,common_1.throwError)({msg:locales_1.default.config.NOT_FOUND.format("project.config.json"),code:config_1.FILE_NOT_FOUND,filePath:PROJECT_CONFIG_JSON}),{};const e=o.getFile("",PROJECT_CONFIG_JSON),r=(0,common_1.checkUTF8)(e,PROJECT_CONFIG_JSON),t=(0,common_2.checkJSONFormat)(r,PROJECT_CONFIG_JSON),i=(0,schemaValidate_1.schemaValidate)("projectconfig",t);if(i.error.length){const o=i.error.map(o=>"type"===o.errorType||"enum"===o.errorType||"anyOf"===o.errorType?locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([o.errorProperty,o.correctType]):locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([o.requireProperty])).join("\n");(0,common_1.throwError)({msg:o,filePath:PROJECT_CONFIG_JSON})}return o.miniprogramRoot=t.miniprogramRoot||"",o.pluginRoot=t.pluginRoot||"",rootConfig.forEach(o=>{"string"==typeof t[o]?t[o]=formatPath(t[o]):t[o]=""}),o.type!==config_1.COMPILE_TYPE.miniGamePlugin&&o.type!==config_1.COMPILE_TYPE.miniProgramPlugin||t.pluginRoot||(0,common_1.throwError)({msg:locales_1.default.config.SHOULD_NOT_BE_EMPTY.format('["pluginRoot"]'),filePath:PROJECT_CONFIG_JSON}),t}),getProjectConfigJSON=function(o){return(0,lodash_1.cloneDeep)(_getProjectConfigJSON(o))};exports.getProjectConfigJSON=getProjectConfigJSON;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.cleanReactiveCache=exports.wrapCompileJSONFunc=exports.tryToGetReactiveJSONCompiler=exports.ReactiveJSONCompiler=exports.tryToGetReactiveProject=exports.ReactiveProject=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),tools_1=require("../../utils/tools"),reactivity_1=require("@vue/reactivity"),lodash_1=require("lodash"),process_1=require("process"),config_1=require("../../config"),isDevtools=process.__nwjs&&"wechatwebdevtools"===nw.App.manifest.appname;function info(...e){}function log(...e){isDevtools&&console.log.apply(console,e)}function error(...e){isDevtools&&console.error.apply(console,e)}function isAttrEqual(e,t){return"object"==typeof e&&"object"==typeof t&&(!(!e||!t)&&(e.platform===t.platform&&e.appType===t.appType&&e.gameApp===t.gameApp&&e.isSandbox===t.isSandbox&&e.released===t.released&&(e.setting.MaxCodeSize===t.setting.MaxCodeSize&&e.setting.MaxSubpackageSubCodeSize===t.setting.MaxSubpackageSubCodeSize&&e.setting.MaxSubpackageFullCodeSize===t.setting.MaxSubpackageFullCodeSize&&e.setting.NavigateMiniprogramLimit===t.setting.NavigateMiniprogramLimit&&e.setting.MaxSubPackageLimit===t.setting.MaxSubPackageLimit&&e.setting.MinTabbarCount===t.setting.MinTabbarCount&&e.setting.MaxTabbarCount===t.setting.MaxTabbarCount&&e.setting.MaxTabbarIconSize===t.setting.MaxTabbarIconSize)))}function makeReadonly(e){return e&&"object"==typeof e?reactivity_1.readonly(e):e}class ReactiveProject{constructor(e){if(this.fileBoxs=new Map,this.statBoxs=new Map,this.resetFileChangeListener=()=>{},this.project=e,e.onFileChange){const t=e.onFileChange;e.onFileChange=(i,o)=>{t.call(e,i,o),this.onFileChange(i,o)},this.resetFileChangeListener=()=>{e.onFileChange=t}}this.miniprogramRootBox=reactivity_1.ref(e.miniprogramRoot),this.pluginRootBox=reactivity_1.ref(e.pluginRoot),this.appidBox=reactivity_1.ref(e.appid),this.typeBox=reactivity_1.ref(e.type),this.attrBox=reactivity_1.ref(config_1.DefaultProjectAttr)}release(){this.resetFileChangeListener(),log("[reactiveCache] reactiveProject release")}async attr(){return this.attrSync()}getFileList(e,t){return this.project.getFileList(e,t)}getFilesAndDirs(){return this.project.getFilesAndDirs()}getExtAppid(){return this.project.getExtAppid()}updateFiles(){throw new Error("Method updateFiles not implemented.")}async updateProject(){this.appidBox.value!==this.project.appid&&(this.appidBox.value=this.project.appid),this.typeBox.value!==this.project.type&&(this.typeBox.value=this.project.type),this.miniprogramRootBox.value!==this.project.miniprogramRoot&&(this.miniprogramRootBox.value=this.project.miniprogramRoot),this.pluginRootBox.value!==this.project.pluginRoot&&(this.pluginRootBox.value=this.project.pluginRoot);const e=await this.project.attr();return isAttrEqual(e,this.attrBox.value)||(this.attrBox.value=e),new Promise(e=>{setTimeout(e,0)})}onFileChange(e,t){if("change"===e){const e=this.fileBoxs.get(t);if(e){const i=this.project.getFile("",t);e.value&&0===i.compare(e.value)||(e.value=i)}}else if("unlink"===e){const e=this.fileBoxs.get(t);e&&(this.fileBoxs.delete(t),e.value=void 0);const i=this.statBoxs.get(t);if(i){const e=this.project.stat("",t);lodash_1.isEqual(e,i.value)||(i.value=e)}}else if("unlinkDir"===e){const e=t+"/";let i=Array.from(this.fileBoxs.keys());for(const t of i)if(0===t.indexOf(e)){const e=this.fileBoxs.get(t);this.fileBoxs.delete(t),e.value=void 0}i=Array.from(this.statBoxs.keys());for(const t of i)if(0===t.indexOf(e)){const e=this.statBoxs.get(t);void 0!==e.value&&(this.statBoxs.delete(t),e.value=void 0)}}else if("add"===e||"addDir"===e){const e=this.statBoxs.get(t);if(e){const i=this.project.stat("",t);lodash_1.isEqual(i,e.value)||(e.value=i)}}}getFile(e,t){const i=this.getTargetPath(e,t),o=this.fileBoxs.get(i);if(o)return o.value;{const o=reactivity_1.ref(this.project.getFile(e,t));return this.fileBoxs.set(i,o),o.value}}stat(e,t){const i=this.getTargetPath(e,t),o=this.statBoxs.get(i);if(o)return o.value;{const o=reactivity_1.ref(this.project.stat(e,t));return this.statBoxs.set(i,o),o.value}}attrSync(){return this.attrBox.value}get appid(){return this.appidBox.value}get type(){return this.typeBox.value}get nameMappingFromDevtools(){return this.project.nameMappingFromDevtools}get projectPath(){return this.project.projectPath}get privateKey(){return this.project.privateKey}get miniprogramRoot(){return this.miniprogramRootBox.value}set miniprogramRoot(e){this.miniprogramRootBox.value=e,this.project.miniprogramRoot=e}get pluginRoot(){return this.pluginRootBox.value}set pluginRoot(e){this.pluginRootBox.value=e,this.project.pluginRoot=e}getTargetPath(e,t){return
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.cleanReactiveCache=exports.wrapCompileJSONFunc=exports.tryToGetReactiveJSONCompiler=exports.ReactiveJSONCompiler=exports.tryToGetReactiveProject=exports.ReactiveProject=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),tools_1=require("../../utils/tools"),reactivity_1=require("@vue/reactivity"),lodash_1=require("lodash"),process_1=require("process"),config_1=require("../../config"),isDevtools=process.__nwjs&&"wechatwebdevtools"===nw.App.manifest.appname;function info(...e){}function log(...e){isDevtools&&console.log.apply(console,e)}function error(...e){isDevtools&&console.error.apply(console,e)}function isAttrEqual(e,t){return"object"==typeof e&&"object"==typeof t&&(!(!e||!t)&&(e.platform===t.platform&&e.appType===t.appType&&e.gameApp===t.gameApp&&e.isSandbox===t.isSandbox&&e.released===t.released&&(e.setting.MaxCodeSize===t.setting.MaxCodeSize&&e.setting.MaxSubpackageSubCodeSize===t.setting.MaxSubpackageSubCodeSize&&e.setting.MaxSubpackageFullCodeSize===t.setting.MaxSubpackageFullCodeSize&&e.setting.NavigateMiniprogramLimit===t.setting.NavigateMiniprogramLimit&&e.setting.MaxSubPackageLimit===t.setting.MaxSubPackageLimit&&e.setting.MinTabbarCount===t.setting.MinTabbarCount&&e.setting.MaxTabbarCount===t.setting.MaxTabbarCount&&e.setting.MaxTabbarIconSize===t.setting.MaxTabbarIconSize)))}function makeReadonly(e){return e&&"object"==typeof e?(0,reactivity_1.readonly)(e):e}class ReactiveProject{constructor(e){if(this.fileBoxs=new Map,this.statBoxs=new Map,this.resetFileChangeListener=()=>{},this.project=e,e.onFileChange){const t=e.onFileChange;e.onFileChange=(i,o)=>{t.call(e,i,o),this.onFileChange(i,o)},this.resetFileChangeListener=()=>{e.onFileChange=t}}this.miniprogramRootBox=(0,reactivity_1.ref)(e.miniprogramRoot),this.pluginRootBox=(0,reactivity_1.ref)(e.pluginRoot),this.appidBox=(0,reactivity_1.ref)(e.appid),this.typeBox=(0,reactivity_1.ref)(e.type),this.attrBox=(0,reactivity_1.ref)(config_1.DefaultProjectAttr)}release(){this.resetFileChangeListener(),log("[reactiveCache] reactiveProject release")}async attr(){return this.attrSync()}getFileList(e,t){return this.project.getFileList(e,t)}getFilesAndDirs(){return this.project.getFilesAndDirs()}getExtAppid(){return this.project.getExtAppid()}updateFiles(){throw new Error("Method updateFiles not implemented.")}async updateProject(){this.appidBox.value!==this.project.appid&&(this.appidBox.value=this.project.appid),this.typeBox.value!==this.project.type&&(this.typeBox.value=this.project.type),this.miniprogramRootBox.value!==this.project.miniprogramRoot&&(this.miniprogramRootBox.value=this.project.miniprogramRoot),this.pluginRootBox.value!==this.project.pluginRoot&&(this.pluginRootBox.value=this.project.pluginRoot);const e=await this.project.attr();return isAttrEqual(e,this.attrBox.value)||(this.attrBox.value=e),new Promise(e=>{setTimeout(e,0)})}onFileChange(e,t){if("change"===e){const e=this.fileBoxs.get(t);if(e){const i=this.project.getFile("",t);e.value&&0===i.compare(e.value)||(e.value=i)}}else if("unlink"===e){const e=this.fileBoxs.get(t);e&&(this.fileBoxs.delete(t),e.value=void 0);const i=this.statBoxs.get(t);if(i){const e=this.project.stat("",t);(0,lodash_1.isEqual)(e,i.value)||(i.value=e)}}else if("unlinkDir"===e){const e=t+"/";let i=Array.from(this.fileBoxs.keys());for(const t of i)if(0===t.indexOf(e)){const e=this.fileBoxs.get(t);this.fileBoxs.delete(t),e.value=void 0}i=Array.from(this.statBoxs.keys());for(const t of i)if(0===t.indexOf(e)){const e=this.statBoxs.get(t);void 0!==e.value&&(this.statBoxs.delete(t),e.value=void 0)}}else if("add"===e||"addDir"===e){const e=this.statBoxs.get(t);if(e){const i=this.project.stat("",t);(0,lodash_1.isEqual)(i,e.value)||(e.value=i)}}}getFile(e,t){const i=this.getTargetPath(e,t),o=this.fileBoxs.get(i);if(o)return o.value;{const o=(0,reactivity_1.ref)(this.project.getFile(e,t));return this.fileBoxs.set(i,o),o.value}}stat(e,t){const i=this.getTargetPath(e,t),o=this.statBoxs.get(i);if(o)return o.value;{const o=(0,reactivity_1.ref)(this.project.stat(e,t));return this.statBoxs.set(i,o),o.value}}attrSync(){return this.attrBox.value}get appid(){return this.appidBox.value}get type(){return this.typeBox.value}get nameMappingFromDevtools(){return this.project.nameMappingFromDevtools}get projectPath(){return this.project.projectPath}get privateKey(){return this.project.privateKey}get miniprogramRoot(){return this.miniprogramRootBox.value}set miniprogramRoot(e){this.miniprogramRootBox.value=e,this.project.miniprogramRoot=e}get pluginRoot(){return this.pluginRootBox.value}set pluginRoot(e){this.pluginRootBox.value=e,this.project.pluginRoot=e}getTargetPath(e,t){return(0,tools_1.normalizePath)(path_1.default.posix.join(e,t)).replace(/\/$/,"").replace(/^\//,"")}}exports.ReactiveProject=ReactiveProject;const reactiveProjectMap=new Map;function tryToGetReactiveProject(e){let t=reactiveProjectMap.get(e.projectPath);return t||(t=new ReactiveProject(e),reactiveProjectMap.set(e.projectPath,t),t)}exports.tryToGetReactiveProject=tryToGetReactiveProject;let isPending=!1;const pendingRunner=new Set,resolvedPromise=Promise.resolve();function runInNextTick(e){pendingRunner.add(e),isPending||(isPending=!0,resolvedPromise.then(()=>{const e=Date.now();try{const t=Array.from(pendingRunner);pendingRunner.clear(),isPending=!1,t.forEach(e=>{e()})}finally{info(`[reactiveCache] nextTick update cost ${Date.now()-e} ms`)}}))}class ReactiveJSONCompiler{constructor(e){this.pageComputeds=new Map,this.jsonComputeds=new Map,this.project=e}release(){log("[reactiveCache] reactiveJSONCompiler release")}registerOrGet(e,t,...i){let o=this.jsonComputeds.get(e);if(!o){o=(0,reactivity_1.ref)(void 0),this.jsonComputeds.set(e,o);let r=void 0;r=(0,reactivity_1.effect)(()=>{try{info(`[reactiveCache] ${e} start to update`);const r=t.call(null,this.project,...i);(0,lodash_1.isEqual)(r,o.value)?info(`[reactiveCache] ${e} update finish, value no change`):(o.value=makeReadonly(r),info(`[reactiveCache] ${e} update finish, new value: `,o.value))}catch(t){o.value=t instanceof Error?t:new Error(t.toString()),log(`[reactiveCache] update ${e} failed: `,t)}},{scheduler(){r&&r.active&&runInNextTick(r)}})}const{value:r}=o;if(r instanceof Error)throw r;return r}static setOriginGetPageJSON(e){this.originGetPageJSON=e}static setOriginCheckPageJSON(e){this.originCheckPageJSON=e}getPageJSON(e,t){let i=this.pageComputeds.get(t.pagePath);i||(i={checked:(0,reactivity_1.ref)(void 0),compiled:(0,reactivity_1.ref)(void 0)},this.pageComputeds.set(t.pagePath,i));const o=i[e];if(void 0===o.value){let i=void 0;i=(0,reactivity_1.effect)(()=>{try{info(`[reactiveCache] start to update ${e} ${t.pagePath}`);const i="compiled"===e?ReactiveJSONCompiler.originGetPageJSON(this.project,t):ReactiveJSONCompiler.originCheckPageJSON(this.project,t);o.value=makeReadonly(i),info(`[reactiveCache] update finish ${e} ${t.pagePath}`)}catch(i){o.value=i instanceof Error?i:new Error(i.toString()),log(`[reactiveCache] update ${e} ${t.pagePath} failed: `,i)}},{scheduler(){i&&i.active&&(0,process_1.nextTick)(i)}})}const r=o.value;if(r instanceof Error)throw r;return r}}exports.ReactiveJSONCompiler=ReactiveJSONCompiler;const reactiveJSONCompilerMap=new Map;function tryToGetReactiveJSONCompiler(e){let t=reactiveJSONCompilerMap.get(e.projectPath);return t||(t=new ReactiveJSONCompiler(e),reactiveJSONCompilerMap.set(e.projectPath,t),t)}function wrapCompileJSONFunc(e,t){return function(i,...o){i instanceof ReactiveProject||(i=tryToGetReactiveProject(i));return tryToGetReactiveJSONCompiler(i).registerOrGet(e,t,...o)}}function cleanReactiveCache(){reactiveProjectMap.forEach(e=>{e.release()}),reactiveProjectMap.clear(),reactiveJSONCompilerMap.forEach(e=>{e.release()}),reactiveJSONCompilerMap.clear()}exports.tryToGetReactiveJSONCompiler=tryToGetReactiveJSONCompiler,exports.wrapCompileJSONFunc=wrapCompileJSONFunc,exports.cleanReactiveCache=cleanReactiveCache;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getAllPluginSignatures=exports.isPathValid=exports.getAllPluginsWithPath=exports.friendlyPathMake=exports.trailing=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),game_1=tslib_1.__importDefault(require("./game")),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),tools_1=require("../../utils/tools"),log_1=tslib_1.__importDefault(require("../../utils/log")),trailing=(t,e)=>t.endsWith(e)?t:t+e;exports.trailing=trailing;const friendlyPathMake=(t,e)=>path_1.default.normalize(path_1.default.join(t,e.replace(/\\/g,"/")).replace(/^\/+/,""));async function getAllPluginsWithPath(t){const e=await
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getAllPluginSignatures=exports.isPathValid=exports.getAllPluginsWithPath=exports.friendlyPathMake=exports.trailing=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),game_1=(0,tslib_1.__importDefault)(require("./game")),fs_extra_1=(0,tslib_1.__importDefault)(require("fs-extra")),tools_1=require("../../utils/tools"),log_1=(0,tslib_1.__importDefault)(require("../../utils/log")),trailing=(t,e)=>t.endsWith(e)?t:t+e;exports.trailing=trailing;const friendlyPathMake=(t,e)=>path_1.default.normalize(path_1.default.join(t,e.replace(/\\/g,"/")).replace(/^\/+/,""));async function getAllPluginsWithPath(t){const e=await(0,game_1.default)(t),i=[],a=(t,e="")=>{if(t.plugins)for(const a in t.plugins){if(!t.plugins.hasOwnProperty(a))continue;const r=t.plugins[a];r&&"string"==typeof r.path&&i.push({alias:a,version:r.version||"",provider:r.provider||"",path:r.path,friendlyPath:(0,exports.friendlyPathMake)(e,r.path)})}};a(e,"");const r=e.subPackages||e.subpackages;if(Array.isArray(r))for(const t of r)t&&"string"==typeof t.root&&a(t,t.root);return i}function isPathValid(t,e){if(e=e.replace(/\\/g,"/"),t=t.replace(/\\/g,"/"),e.includes("../")||e.endsWith("/.."))return!1;const i=(0,tools_1.normalizePath)(path_1.default.join(t,e)),a=(0,tools_1.normalizePath)(t);return!!i.startsWith(a)}async function getAllPluginSignatures(t){const e=await getAllPluginsWithPath(t),i=[];let a=t.miniprogramRoot?path_1.default.join(t.projectPath,t.miniprogramRoot):t.projectPath;a=(0,tools_1.normalizePath)(a),a=a.endsWith("/")?a:a+"/";for(const t of e)try{const e=path_1.default.join(a,t.friendlyPath);let r=await fs_extra_1.default.pathExists(e);if(!r)continue;const n=await fs_extra_1.default.stat(e);let l=e;n.isDirectory()||(l=path_1.default.dirname(e));const s=path_1.default.join(l,"signature.json");if(r=await fs_extra_1.default.pathExists(s),!r)continue;const o=await fs_extra_1.default.readFile(s,"utf8");let u=null;try{u=JSON.parse(o)}catch(t){log_1.default.error(t);continue}if(!u||!Array.isArray(u.signature))continue;const p=[];for(let t=0;t<u.signature.length;t++){const e=u.signature[t];if(!e)continue;if("string"!=typeof e.path||"string"!=typeof e.md5)continue;if(!isPathValid(l,e.path))continue;const i=path_1.default.join(l,e.path);p.push({fullPath:i,md5:e.md5})}i.push({provider:t.provider,fullPath:e,signature:p})}catch(t){log_1.default.error(t);continue}return i}exports.friendlyPathMake=friendlyPathMake,exports.getAllPluginsWithPath=getAllPluginsWithPath,exports.isPathValid=isPathValid,exports.getAllPluginSignatures=getAllPluginSignatures;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getSiteMapJSON=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),tools_1=require("../../utils/tools"),projectconfig_1=require("./projectconfig"),locales_1=tslib_1.__importDefault(require("../../utils/locales/locales")),common_1=require("../../utils/common"),common_2=require("./common"),schemaValidate_1=require("../validate/schemaValidate"),cache_1=require("../../utils/cache"),reactiveCache_1=require("./reactiveCache"),config_1=require("../../config"),getAppJSON_1=require("./app/getAppJSON");exports.getSiteMapJSON=reactiveCache_1.wrapCompileJSONFunc(cache_1.CACHE_KEY.SITE_MAP_JSON,e=>{const o=projectconfig_1.getProjectConfigJSON(e),r=getAppJSON_1.getAppJSON(e),{sitemapLocation:t=""}=r;let i=t;if(i)i=tools_1.normalizePath(path_1.default.posix.join(o.miniprogramRoot||"",i));else{if(i=tools_1.normalizePath(path_1.default.posix.join(o.miniprogramRoot||"","sitemap.json")),!e.stat("",i))return e.type,config_1.COMPILE_TYPE.miniProgramPlugin,{desc:"",rules:[{action:"disallow",page:"*"}]}}const a=e.getFile("",i),c=common_1.checkUTF8(a,i),l=common_2.checkJSONFormat(c,i),_=schemaValidate_1.schemaValidate("sitemap",l);if(_.error.length){const e=_.error.map(e=>"type"===e.errorType||"enum"===e.errorType||"anyOf"===e.errorType?locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([e.errorProperty,e.correctType]):locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([e.requireProperty])).join("\n");common_1.throwError({msg:e,filePath:i})}return l});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getSiteMapJSON=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),tools_1=require("../../utils/tools"),projectconfig_1=require("./projectconfig"),locales_1=(0,tslib_1.__importDefault)(require("../../utils/locales/locales")),common_1=require("../../utils/common"),common_2=require("./common"),schemaValidate_1=require("../validate/schemaValidate"),cache_1=require("../../utils/cache"),reactiveCache_1=require("./reactiveCache"),config_1=require("../../config"),getAppJSON_1=require("./app/getAppJSON");exports.getSiteMapJSON=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.SITE_MAP_JSON,e=>{const o=(0,projectconfig_1.getProjectConfigJSON)(e),r=(0,getAppJSON_1.getAppJSON)(e),{sitemapLocation:t=""}=r;let i=t;if(i)i=(0,tools_1.normalizePath)(path_1.default.posix.join(o.miniprogramRoot||"",i));else{if(i=(0,tools_1.normalizePath)(path_1.default.posix.join(o.miniprogramRoot||"","sitemap.json")),!e.stat("",i))return e.type,config_1.COMPILE_TYPE.miniProgramPlugin,{desc:"",rules:[{action:"disallow",page:"*"}]}}const a=e.getFile("",i),c=(0,common_1.checkUTF8)(a,i),l=(0,common_2.checkJSONFormat)(c,i),_=(0,schemaValidate_1.schemaValidate)("sitemap",l);if(_.error.length){const e=_.error.map(e=>"type"===e.errorType||"enum"===e.errorType||"anyOf"===e.errorType?locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([e.errorProperty,e.correctType]):locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([e.requireProperty])).join("\n");(0,common_1.throwError)({msg:e,filePath:i})}return l});
|
package/dist/core/json/theme.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.mergeThemeJSONToPageJSON=exports.mergeThemeJSONToAppJSON=exports.checkThemeJSON=exports.getPluginThemeLocation=exports.getThemeLocation=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=tslib_1.__importStar(require("lodash")),tools_1=require("../../utils/tools"),projectconfig_1=require("./projectconfig"),locales_1=tslib_1.__importDefault(require("../../utils/locales/locales")),common_1=require("../../utils/common"),common_2=require("./common"),cache_1=require("../../utils/cache"),getAppJSON_1=require("./app/getAppJSON"),schemaValidate_1=require("../validate/schemaValidate"),config_1=require("../../config"),plugin_1=require("./plugin/plugin"),reactiveCache_1=require("./reactiveCache");async function getPluginThemeLocation(e){return(await
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.mergeThemeJSONToPageJSON=exports.mergeThemeJSONToAppJSON=exports.checkThemeJSON=exports.getPluginThemeLocation=exports.getThemeLocation=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),lodash_1=(0,tslib_1.__importStar)(require("lodash")),tools_1=require("../../utils/tools"),projectconfig_1=require("./projectconfig"),locales_1=(0,tslib_1.__importDefault)(require("../../utils/locales/locales")),common_1=require("../../utils/common"),common_2=require("./common"),cache_1=require("../../utils/cache"),getAppJSON_1=require("./app/getAppJSON"),schemaValidate_1=require("../validate/schemaValidate"),config_1=require("../../config"),plugin_1=require("./plugin/plugin"),reactiveCache_1=require("./reactiveCache");async function getPluginThemeLocation(e){return(await(0,plugin_1.getDevPluginJSON)(e)).themeLocation||null}function checkThemeJSON(e,o){const{isPlugin:t}=o;return t?originCheckThemeJSONForPlugin(e,o):originCheckThemeJSONForMiniProgram(e,o)}exports.getThemeLocation=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.APP_JSON_THEME_LOCATION,e=>{const o=(0,getAppJSON_1.getRawAppJSON)(e).themeLocation;return"[object Undefined]"!==Object.prototype.toString.call(o)?"string"==typeof o?((0,common_1.checkPath)({value:o,tips:'["themeLocation"]',filePath:"app.json"}),o):((0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format('appJSON["themeLocation"]',"string"),filePath:"app.json"}),null):null}),exports.getPluginThemeLocation=getPluginThemeLocation,exports.checkThemeJSON=checkThemeJSON;const originCheckThemeJSONForMiniProgram=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.THEME_JSON,originCheckThemeJSON),originCheckThemeJSONForPlugin=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.PLUGIN_THEME_JSON,originCheckThemeJSON);function originCheckThemeJSON(e,o){const{isPlugin:t}=o,r=(0,exports.getThemeLocation)(e),i=(0,projectconfig_1.getProjectConfigJSON)(e),a=t?i.pluginRoot:i.miniprogramRoot,c=(0,tools_1.normalizePath)(path_1.default.posix.join(a||"",r));e.stat("",c)||(0,common_1.throwError)({msg:locales_1.default.config.FILE_NOT_FOUND.format(c),filePath:"app.json"});const n=e.getFile("",c),l=(0,common_1.checkUTF8)(n,c),s=(0,common_2.checkJSONFormat)(l,c),h=(0,schemaValidate_1.schemaValidate)("theme",s);if(h.error.length){const e=h.error.map(e=>"type"===e.errorType||"enum"===e.errorType||"anyOf"===e.errorType?locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([e.errorProperty,e.correctType]):locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([e.requireProperty])).join("\n");(0,common_1.throwError)({msg:e,filePath:c})}return s}function mergeThemeJSONToAppJSON(e,o){var t,r;const{windowPropertWhiteList:i,tabBarPropertyWhiteList:a,tabbarListItemPropertyWhiteList:c}=config_1.jsonVariablePropertyWhiteList,n=/^@/,l=lodash_1.default.cloneDeep(o.window||{}),s=lodash_1.default.cloneDeep(o.window||{});Object.keys(l).forEach(o=>{const t=l[o];if(n.test(t)){i.includes(o)||(0,common_1.throwError)({msg:""+locales_1.default.config.SHOULD_NOT_IN.format([t,o]),filePath:"app.json"});const r=t.slice(1);l[o]=e.light[r]||t,s[o]=e.dark[r]||t}});const h=(0,lodash_1.cloneDeep)(o),m=(0,lodash_1.cloneDeep)(o);if(h.window=l,m.window=s,null===(r=null===(t=o.tabBar)||void 0===t?void 0:t.list)||void 0===r?void 0:r.length){const t=lodash_1.default.cloneDeep(o.tabBar||{list:[]}),r=lodash_1.default.cloneDeep(o.tabBar||{list:[]});t.list&&t.list.length>0&&Object.keys(t).forEach(o=>{if("list"!==o){const i=t[o];if(n.test(i)){a.includes(o)||(0,common_1.throwError)({msg:""+locales_1.default.config.SHOULD_NOT_IN.format([i,o]),filePath:"app.json"});const c=i.slice(1);t[o]=e.light[c]||i,r[o]=e.dark[c]||i}}else t.list.forEach((o,i)=>{Object.keys(o).forEach(a=>{const l=o[a];if(n.test(l)){c.includes(a)||(0,common_1.throwError)({msg:""+locales_1.default.config.SHOULD_NOT_IN.format([l,a]),filePath:"app.json"});const o=l.slice(1);t.list[i][a]=e.light[o]||l,r.list[i][a]=e.dark[o]||l}})})}),m.tabBar=r,h.tabBar=t}return{appJSONLight:h,appJSONDark:m}}function mergeThemeJSONToPageJSON(e,o,t){const r=config_1.jsonVariablePropertyWhiteList.windowPropertWhiteList,i=lodash_1.default.cloneDeep(o||{}),a=lodash_1.default.cloneDeep(o||{}),c=/^@/;return Object.keys(o).forEach(n=>{const l=o[n];if(c.test(l)){const o=l.slice(1);r.includes(n)||(0,common_1.throwError)({msg:""+locales_1.default.config.SHOULD_NOT_IN.format([l,n]),filePath:t}),a[n]=e.light[o]||l,i[n]=e.dark[o]||l}}),{pageJSONDark:i,pageJSONLight:a}}exports.mergeThemeJSONToAppJSON=mergeThemeJSONToAppJSON,exports.mergeThemeJSONToPageJSON=mergeThemeJSONToPageJSON;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),read_package_tree_1=tslib_1.__importDefault(require("read-package-tree"));function checkDeps(e,t){var a,r;const n=new Set(Object.keys((null===(a=e.package)||void 0===a?void 0:a.dependencies)||{})),o=[];let s=e;for(;s;){const e=s.children||[];for(const t of e){const e=(null===(r=t.package)||void 0===r?void 0:r.name)||"";n.has(e)&&(n.delete(e),o.push(t))}s=s.parent}for(const e of o)t.has(e)||(t.add(e),checkDeps(e,t))}async function getDeps(e){return new Promise((t,a)=>{read_package_tree_1.default(e,(e,r)=>{if(e)return a(e);const n=new Set;try{checkDeps(r,n)}catch(e){return a(e)}t(Array.from(n))})})}async function default_1(e,t){if(null==t?void 0:t.length){const a=t.filter(e=>!/([\\/]|\b)node_modules/.test(e)),r=[],n={};for(const t of a){(await getDeps(path_1.default.join(e,path_1.default.dirname(t)))).forEach(e=>{r.push(e)})}for(const e of r){const t=e.isLink?e.path:e.realpath;n[path_1.default.normalize(path_1.default.join(t,"./package.json"))]=e}t=t.filter(t=>{const a=path_1.default.normalize(path_1.default.join(e,t));return!!n[a]})}return t}exports.default=default_1;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),read_package_tree_1=(0,tslib_1.__importDefault)(require("read-package-tree"));function checkDeps(e,t){var a,r;const n=new Set(Object.keys((null===(a=e.package)||void 0===a?void 0:a.dependencies)||{})),o=[];let s=e;for(;s;){const e=s.children||[];for(const t of e){const e=(null===(r=t.package)||void 0===r?void 0:r.name)||"";n.has(e)&&(n.delete(e),o.push(t))}s=s.parent}for(const e of o)t.has(e)||(t.add(e),checkDeps(e,t))}async function getDeps(e){return new Promise((t,a)=>{(0,read_package_tree_1.default)(e,(e,r)=>{if(e)return a(e);const n=new Set;try{checkDeps(r,n)}catch(e){return a(e)}t(Array.from(n))})})}async function default_1(e,t){if(null==t?void 0:t.length){const a=t.filter(e=>!/([\\/]|\b)node_modules/.test(e)),r=[],n={};for(const t of a){(await getDeps(path_1.default.join(e,path_1.default.dirname(t)))).forEach(e=>{r.push(e)})}for(const e of r){const t=e.isLink?e.path:e.realpath;n[path_1.default.normalize(path_1.default.join(t,"./package.json"))]=e}t=t.filter(t=>{const a=path_1.default.normalize(path_1.default.join(e,t));return!!n[a]})}return t}exports.default=default_1;
|