miniprogram-ci 1.8.35 → 1.8.53
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/dist/@types/config.d.ts +1 -1
- package/dist/@types/core/json/app/checkAppFields.d.ts +1 -0
- package/dist/@types/core/protect/file_flatter.d.ts +1 -0
- package/dist/@types/core.d.ts +0 -2
- package/dist/@types/summer/devtool.d.ts +0 -1
- package/dist/@types/summer/graph/appconf.d.ts +0 -1
- package/dist/@types/types/miniprogram-json/app.d.ts +2 -0
- package/dist/@types/types/miniprogram-json/page.d.ts +1 -1
- package/dist/@types/utils/locales/locales.d.ts +1 -0
- package/dist/@types/utils/locales/zh.d.ts +1 -0
- package/dist/@types/vendor/cloud-api/src/apis/scf/scf.apis.d.ts +2 -0
- package/dist/@types/vendor/cloud-api/src/apis/tcb/tcb.apis.d.ts +19 -0
- package/dist/@types/vendor/cloud-api/src/transaction/contracts/scf.contracts.d.ts +2 -0
- package/dist/@types/vendor/cloud-api/src/transaction/contracts/tcb.contracts.d.ts +19 -0
- package/dist/@types/vendor/cloud-api/src/transaction/validations/common.validations.d.ts +16 -0
- package/dist/@types/vendor/cloud-api/src/transaction/validations/scf.validations.d.ts +2 -0
- package/dist/@types/vendor/cloud-api/src/transaction/validations/tcb.validations.d.ts +19 -0
- package/dist/@types/vendor/code-analyse/index.d.ts +20 -15
- package/dist/cloud/uploadFunction.js +1 -1
- package/dist/config.js +1 -1
- package/dist/core/compile/handler/mpjson.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/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.js +1 -1
- package/dist/manifest.json +2 -2
- package/dist/summer/devtool.js +1 -1
- package/dist/summer/graph/appconf.js +1 -1
- package/dist/summer/graph/pluginconf.js +1 -1
- package/dist/utils/locales/en.js +1 -1
- package/dist/utils/locales/zh.js +1 -1
- package/dist/vendor/cloud-api/src/apis/flexdb/flexdb.apis.js +1 -1
- package/dist/vendor/cloud-api/src/apis/scf/scf.apis.js +1 -1
- package/dist/vendor/cloud-api/src/apis/tcb/tcb.apis.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/contracts/factory.js +1 -1
- package/dist/vendor/cloud-api/src/transaction/contracts/scf.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/common.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/tcb.validations.js +1 -1
- package/dist/vendor/cloud-api/src/utils/common.js +1 -1
- package/dist/vendor/code-analyse/index.js +1 -1
- package/package.json +4 -4
package/dist/core/npm/packnpm.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.packNpmManually=exports.packNpm=void 0;const tslib_1=require("tslib"),config_1=require("../../config"),lodash_1=(0,tslib_1.__importDefault)(require("lodash")),rimraf_1=(0,tslib_1.__importDefault)(require("rimraf")),path_1=(0,tslib_1.__importDefault)(require("path")),fs_1=(0,tslib_1.__importDefault)(require("fs")),glob_1=(0,tslib_1.__importDefault)(require("glob")),source_map_1=(0,tslib_1.__importDefault)(require("source-map")),filterdeps_1=(0,tslib_1.__importDefault)(require("./filterdeps")),locales_1=(0,tslib_1.__importDefault)(require("../../utils/locales/locales")),error_1=require("../../utils/error"),log_1=(0,tslib_1.__importDefault)(require("../../utils/log")),projectconfig_1=require("../json/projectconfig"),acorn=require("acorn"),NPM_RECORD={start_time:Date.now(),pack_time:0,miniprogram_pack_num:0,other_pack_num:0,warn_not_found_num:0,warn_require_var_num:0,warn_require_rename_num:0,extra1:"",extra2:"",extra3:""},REPORT_LIST=["pack_time","miniprogram_pack_num","other_pack_num","warn_not_found_num","warn_require_var_num","warn_require_rename_num","extra1","extra2","extra3"];function wrap(e,t){return function(...a){if(a.length){const e=a.pop();"function"!=typeof e&&a.push(e)}return new Promise((r,n)=>{a.push((e,t)=>{e?n(e):r(t)}),e.apply(t||null,a)})}}const statSync=wrap(fs_1.default.stat),mkdirSync=wrap(fs_1.default.mkdir),readFileSync=wrap(fs_1.default.readFile),writeFileSync=wrap(fs_1.default.writeFile),accessSync=wrap(fs_1.default.access),renameSync=wrap(fs_1.default.rename),globSync=wrap(glob_1.default);let seed=+new Date;function getId(){return++seed}function startRecord(){NPM_RECORD.start_time=Date.now(),REPORT_LIST.forEach(e=>NPM_RECORD[e]=0===e.indexOf("extra")?"":0)}function endRecord(e){NPM_RECORD.pack_time=Date.now()-NPM_RECORD.start_time;const t={};REPORT_LIST.forEach(e=>t[e]=NPM_RECORD[e]);try{null==e||e(t)}catch(e){}}async function recursiveMkdir(e){const t=path_1.default.posix.dirname(e);try{await accessSync(t)}catch(e){await recursiveMkdir(t)}try{await accessSync(e);const t=await statSync(e);t&&!t.isDirectory()&&(await renameSync(e,e+".bak"),log_1.default.warn(e+" already exists but is not a directory, so it will be rename to a file with the suffix ending in '.bak'"),await mkdirSync(e))}catch(t){await mkdirSync(e)}}async function copyFile(e,t){const a=await readFileSync(e);await writeFile(a,t)}async function writeFile(e,t){await recursiveMkdir(path_1.default.posix.dirname(t)),await writeFileSync(t,e)}function walkNode(e,t){t(e),Object.keys(e).forEach(a=>{const r=e[a];Array.isArray(r)&&r.forEach(e=>{(null==e?void 0:e.type)&&walkNode(e,t)}),(null==r?void 0:r.type)&&walkNode(r,t)})}function parseDeps(e,t,a){const r=[];let n,o=[];try{n=acorn.parse(e,{sourceType:"module",locations:!0,allowHashBang:!0,onComment(t,a,r,n){t||"#"!==e[r]||o.push({start:r,end:n,adjustContent:""})}})}catch(e){throw console.error(`parse js file (${t}) failed`),e}return walkNode(n,n=>{const i=n.callee,s=n.arguments;if("CallExpression"===n.type&&i&&"Identifier"===i.type&&"require"===i.name&&s&&1===s.length&&("Literal"===s[0].type?r.push(s[0].value):(a.push({jsPath:t,code:e.substring(n.start,n.end),startLine:n.loc.start.line,endLine:n.loc.end.line,tips:"require variable is not allowed",msg:locales_1.default.config.NOT_ALLOWED_REQUIRE_VAR.format()}),NPM_RECORD.warn_require_var_num++)),"ExpressionStatement"===n.type&&n.expression&&"use strict"===n.expression.value&&o.push({start:n.start,end:n.end,adjustContent:""}),"ImportDeclaration"===n.type){const e=n.source,t=n.specifiers,a={start:n.start,end:n.end,adjustContent:""},i=[];e&&"Literal"===e.type&&(r.push(e.value),i.push(`var __TEMP__ = require('${e.value}');`)),t&&Array.isArray(t)&&t.forEach(e=>{if("ImportSpecifier"===e.type){const t=e.local,a=e.imported;"Identifier"===t.type&&"Identifier"===a.type&&i.push(`var ${t.name} = __TEMP__['${a.name}'];`)}else if("ImportDefaultSpecifier"===e.type){const t=e.local;"Identifier"===t.type&&i.push(`var ${t.name} = __REQUIRE_DEFAULT__(__TEMP__);`)}else if("ImportNamespaceSpecifier"===e.type){const t=e.local;"Identifier"===t.type&&i.push(`var ${t.name} = __REQUIRE_WILDCARD__(__TEMP__);`)}}),a.adjustContent=i.join(""),o.push(a)}if("ExportNamedDeclaration"===n.type){const t=n.source,a=n.specifiers,i=n.declaration;let s=!1;const p={start:n.start,end:n.end,adjustContent:""},c=['if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });'];if(t&&"Literal"===t.type&&(r.push(t.value),c.push(`var __TEMP__ = require('${t.value}');`),s=!0),i){if("VariableDeclaration"===i.type){const t=i.declarations;t&&Array.isArray(t)&&t.forEach(t=>{if("VariableDeclarator"===t.type){const a=t.id,r=t.init;a&&"Identifier"===a.type&&(p.notAddLines=!0,c.push(`var ${a.name} = exports.${a.name} = ${r?e.substring(r.start,r.end):"undefined"};`))}})}else if("FunctionDeclaration"===i.type){const t=i.id;t&&"Identifier"===t.type&&(p.notAddLines=!0,c.push(`${e.substring(i.start,i.end)};exports.${t.name} = ${t.name}`))}else if("ClassDeclaration"===i.type){const t=i.id;t&&"Identifier"===t.type&&(p.notAddLines=!0,c.push(`${e.substring(i.start,i.end)};exports.${t.name} = ${t.name}`))}}else;a&&Array.isArray(a)&&a.forEach(e=>{if("ExportSpecifier"===e.type){const t=e.local,a=e.exported;"Identifier"===t.type&&"Identifier"===a.type&&c.push(`Object.defineProperty(exports, '${a.name}', { enumerable: true, configurable: true, get: function() { return ${s?"__TEMP__.":""}${t.name}; } });`)}}),p.adjustContent=c.join(""),o.push(p)}else if("ExportAllDeclaration"===n.type){const e=n.source,t={start:n.start,end:n.end,adjustContent:""},a=['if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });'];e&&"Literal"===e.type&&(r.push(e.value),a.push(`var __TEMP__ = require('${e.value}');`)),a.push('Object.keys(__TEMP__).forEach(function(k) { if (k === "default" || k === "__esModule") return; Object.defineProperty(exports, k, { enumerable: true, configurable: true, get: function() { return __TEMP__[k]; } }); });'),t.adjustContent=a.join(""),o.push(t)}else if("ExportDefaultDeclaration"===n.type){const t=n.declaration,a={start:n.start,end:n.end,adjustContent:""},r=['if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });'];if(t)if(a.notAddLines=!0,t.id){const a=t.id;r.push(`${e.substring(t.start,t.end)};exports.default = ${a.name}`)}else r.push(`exports.default = ${e.substring(t.start,t.end)};`);a.adjustContent=r.join(""),o.push(a)}const p=n.expression;"ExpressionStatement"===n.type&&p&&"AssignmentExpression"===p.type&&"Identifier"===p.right.type&&"require"===p.right.name&&(a.push({jsPath:t,code:e.substring(n.start,n.end),startLine:n.loc.start.line,endLine:n.loc.end.line,tips:"assign require function to a variable is not allowed",msg:locales_1.default.config.NOT_ALLOWED_REQUIRE_ASSIGN.format()}),NPM_RECORD.warn_require_rename_num++);const c=n.declarations;"VariableDeclaration"===n.type&&c.length>0&&c.forEach(r=>{const o=r.init;"VariableDeclarator"===r.type&&o&&"Identifier"===o.type&&"require"===o.name&&(a.push({jsPath:t,code:e.substring(n.start,n.end),startLine:n.loc.start.line,endLine:n.loc.end.line,tips:"assign require function to a variable is not allowed",msg:locales_1.default.config.NOT_ALLOWED_REQUIRE_ASSIGN.format()}),NPM_RECORD.warn_require_rename_num++)})}),o=o.sort((e,t)=>t.start-e.start),o.forEach(t=>{const a=e.substring(t.start,t.end),r=t.notAddLines?0:a.split("\n").length;e=e.substring(0,t.start)+t.adjustContent+new Array(r).join("\n")+e.substring(t.end)}),{deps:r,parsedContent:e}}async function parseJs(e,t,a,r,n,o){if(n[t=path_1.default.posix.normalize(t)])return n[t];const i=await readFileSync(t,"utf8"),s=getId(),p=path_1.default.posix.relative(e,t);if(/\.json$/.test(t)){const e={id:s,name:p,content:"module.exports = "+i,deps:[],depsMap:{}};return n[t]=s,r.push(e),s}const{deps:c,parsedContent:_}=parseDeps(i,t,o),u={id:s,name:p,content:_,deps:c,depsMap:{}};n[t]=s,r.push(u);for(const i of c){let s,p=path_1.default.posix.join(path_1.default.posix.dirname(t),i);if(!/\.js$/.test(p)&&!/\.json$/.test(p)){const e=p+".js";try{await accessSync(e),p=e}catch(e){}}try{const e=await statSync(p);(null==e?void 0:e.isDirectory())&&(p=path_1.default.posix.join(p,"index.js"))}catch(e){}/\.js$/.test(p)||/\.json$/.test(p)||(p+=".js");try{await accessSync(p),s=await parseJs(e,p,a,r,n,o)}catch(e){}s&&(u.depsMap[i]=s)}return s}function addJsToMap(e,t,a,r){const n=t.split("\n").length;for(let o=1;o<=n;o++)e.addMapping({generated:{line:r+o,column:0},original:{line:o,column:0},source:a}),e.setSourceContent(a,t)}function findOutsideDeps(e){const t=new Set;return e.forEach(e=>{e.deps.forEach(a=>{Object.keys(e.depsMap).includes(a)||t.add(a)})}),Array.from(t)}async function packJs(e,t,a){try{const t=await statSync(e);(null==t?void 0:t.isDirectory())&&(e=path_1.default.posix.join(e,"index.js"))}catch(e){}/\.js$/.test(e)||/\.json$/.test(e)||(e+=".js");try{await accessSync(e)}catch(t){return a.push({jsPath:e,code:"",tips:"entry file is not found",msg:locales_1.default.config.NOT_FOUND_NPM_ENTRY.format()}),void NPM_RECORD.warn_not_found_num++}const r=new source_map_1.default.SourceMapGenerator({file:"index.js"}),n=[];await parseJs(path_1.default.posix.dirname(e),e,t,n,{},a);const o=findOutsideDeps(n),i=["module.exports = (function() {","var __MODS__ = {};","var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };",'var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; };',"var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } };","var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };"];if(n.length){const e=n.shift();i.push(`__DEFINE__(${e.id}, function(require, module, exports) {`),addJsToMap(r,e.content,e.name,i.length),i.push(e.content),i.push(`}, function(modId) {var map = ${JSON.stringify(e.depsMap)}; return __REQUIRE__(map[modId], modId); })`);for(const e of n)i.push(`__DEFINE__(${e.id}, function(require, module, exports) {`),addJsToMap(r,e.content,e.name,i.length),i.push(e.content),i.push(`}, function(modId) { var map = ${JSON.stringify(e.depsMap)}; return __REQUIRE__(map[modId], modId); })`);i.push(`return __REQUIRE__(${e.id});`)}return i.push("})()"),i.push("//miniprogram-npm-outsideDeps="+JSON.stringify(o)),i.push("//# sourceMappingURL=index.js.map"),{js:i.join("\n"),map:r.toString()}}async function checkIsMiniprogramPack(e,t){let a="miniprogram_dist";t.miniprogram&&"string"==typeof t.miniprogram&&(a=t.miniprogram);try{const t=path_1.default.posix.join(e,a);await accessSync(t);const r=await statSync(t);if(null==r?void 0:r.isDirectory())return t}catch(e){}return""}async function packNpm(e,t={}){const a=e.projectPath,r=e.type,n=await(0,projectconfig_1.getProjectConfigJSON)(e),o=n.pluginRoot||"",i=n.miniprogramRoot||"",s="miniProgramPlugin"===r||"miniGamePlugin"===r,{ignores:p,reporter:c}=t;if(!a)throw new error_1.CodeError(locales_1.default.config.SHOULD_NOT_BE_EMPTY.format("projectPath"),config_1.PARAM_ERROR);if("miniProgramPlugin"===r&&!o)throw new error_1.CodeError(locales_1.default.config.SHOULD_NOT_BE_EMPTY.format('project.config.json "pluginRoot"'),config_1.PARAM_ERROR);startRecord();const _=path_1.default.isAbsolute(a)?a:path_1.default.posix.join(process.cwd(),a),u=[{searchRoot:path_1.default.posix.join(_,i),paths:await globSync("**/package.json",{cwd:path_1.default.posix.join(_,i),nodir:!0,dot:!0,ignore:(p||[]).concat("**/node_modules/**")})}];s&&u.push({searchRoot:path_1.default.posix.join(_,o),paths:await globSync("**/package.json",{cwd:path_1.default.posix.join(_,o),nodir:!0,dot:!0,ignore:(p||[]).concat("**/node_modules/**")})});lodash_1.default.flattenDeep(u.map(e=>e.paths.map(t=>path_1.default.posix.join(e.searchRoot,path_1.default.dirname(t),"miniprogram_npm")))).forEach(e=>rimraf_1.default.sync(e));const l=[];for(const e of u)for(const t of e.paths){const a=path_1.default.dirname(path_1.default.posix.join(e.searchRoot,t)),r=lodash_1.default.xorWith(e.paths,[t]).map(e=>path_1.default.posix.join(path_1.default.posix.dirname(e),"/**")).filter(e=>"**"!==e);let n=await globSync("**/package.json",{cwd:a.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:(p||[]).concat(r).concat(["node_modules/@types/**"])});if(n=await(0,filterdeps_1.default)(a,n),n&&n.length)for(const e of n){const t=path_1.default.posix.join(a,e);let r=await readFileSync(t,"utf8");const n=path_1.default.dirname(t);let o=n.replace(/([\b/\\])node_modules([\b/\\])/g,(e,t,a)=>`${t}miniprogram_npm${a}`),i=path_1.default.basename(o);const s=i.split("@");s.length&&(i=s.pop()||""),o=o.replace(path_1.default.basename(o),i),r=JSON.parse(r);const p=path_1.default.posix.join(n,r.main||"index.js"),c=await checkIsMiniprogramPack(n,r);if(c){const e=await globSync("**/*",{cwd:c.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:"**/node_modules/**"});for(const t of e)await copyFile(path_1.default.posix.join(c,t),path_1.default.posix.join(o,t));NPM_RECORD.miniprogram_pack_num++}else{const e=await packJs(p,o,l);if(!e)continue;await writeFile(e.js,path_1.default.posix.join(o,"./index.js")),await writeFile(e.map,path_1.default.posix.join(o,"./index.js.map")),NPM_RECORD.other_pack_num++}}}if(endRecord(c),NPM_RECORD.miniprogram_pack_num+NPM_RECORD.other_pack_num<=0)throw new Error("__NO_NODE_MODULES__ "+locales_1.default.config.NOT_FOUND_NODE_MODULES.format());return"function"==typeof e.updateFiles&&e.updateFiles(),l}async function packNpmManually(e){let{packageJsonPath:t,miniprogramNpmDistDir:a}=e;const r=e.ignores||[],n={pack_time:0,miniprogram_pack_num:0,other_pack_num:0,warn_not_found_num:0,warn_require_var_num:0,warn_require_rename_num:0},o=[];if(!a)throw new Error("param miniprogramNpmDistDir is required");if(!t)throw new Error("param packageJsonPath is required");if(path_1.default.isAbsolute(a)||(a=path_1.default.join(process.cwd(),a)),path_1.default.isAbsolute(t)||(t=path_1.default.join(process.cwd(),t)),!fs_1.default.existsSync(t))throw new Error(`param packageJsonPath: ${t} file is not exited`);const i=path_1.default.dirname(t);let s=await globSync("**/package.json",{cwd:i.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:(r||[]).concat(["node_modules/@types/**"])});if(s=await(0,filterdeps_1.default)(i,s),!s||!s.length)return log_1.default.warn("No miniprogram_npm package was built."),{miniProgramPackNum:0,otherNpmPackNum:0,warnList:[]};s=s.filter(e=>e.startsWith("node_modules"));for(const e of s){const t=path_1.default.posix.join(i,e);let r=await readFileSync(t,"utf8");const s=path_1.default.dirname(t);let p=s.replace(/([\b/\\])node_modules([\b/\\])/g,(e,t,a)=>`${t}miniprogram_npm${a}`);p=path_1.default.posix.normalize(path_1.default.posix.join(a,"miniprogram_npm",p.split(/[/\\]miniprogram_npm[/\\]/)[1]));let c=path_1.default.basename(p);const _=c.split("@");_.length&&(c=_.pop()||""),p=p.replace(path_1.default.basename(p),c),r=JSON.parse(r);const u=path_1.default.posix.join(s,r.main||"index.js"),l=await checkIsMiniprogramPack(s,r);if(l){const e=await globSync("**/*",{cwd:l.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:"**/node_modules/**"});for(const t of e)await copyFile(path_1.default.posix.join(l,t),path_1.default.posix.join(p,t));n.miniprogram_pack_num++}else{const e=await packJs(u,p,o);if(!e)continue;await writeFile(e.js,path_1.default.posix.join(p,"./index.js")),await writeFile(e.map,path_1.default.posix.join(p,"./index.js.map")),n.other_pack_num++}}return{miniProgramPackNum:n.miniprogram_pack_num,otherNpmPackNum:n.other_pack_num,warnList:o}}exports.packNpm=packNpm,exports.packNpmManually=packNpmManually;
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.packNpmManually=exports.packNpm=void 0;const tslib_1=require("tslib"),config_1=require("../../config"),lodash_1=(0,tslib_1.__importDefault)(require("lodash")),rimraf_1=(0,tslib_1.__importDefault)(require("rimraf")),path_1=(0,tslib_1.__importDefault)(require("path")),fs_1=(0,tslib_1.__importDefault)(require("fs")),glob_1=(0,tslib_1.__importDefault)(require("glob")),source_map_1=(0,tslib_1.__importDefault)(require("source-map")),filterdeps_1=(0,tslib_1.__importDefault)(require("./filterdeps")),locales_1=(0,tslib_1.__importDefault)(require("../../utils/locales/locales")),error_1=require("../../utils/error"),log_1=(0,tslib_1.__importDefault)(require("../../utils/log")),projectconfig_1=require("../json/projectconfig"),acorn=require("acorn"),NPM_RECORD={start_time:Date.now(),pack_time:0,miniprogram_pack_num:0,other_pack_num:0,warn_not_found_num:0,warn_require_var_num:0,warn_require_rename_num:0,extra1:"",extra2:"",extra3:""},REPORT_LIST=["pack_time","miniprogram_pack_num","other_pack_num","warn_not_found_num","warn_require_var_num","warn_require_rename_num","extra1","extra2","extra3"];function wrap(e,t){return function(...a){if(a.length){const e=a.pop();"function"!=typeof e&&a.push(e)}return new Promise((r,n)=>{a.push((e,t)=>{e?n(e):r(t)}),e.apply(t||null,a)})}}const statSync=wrap(fs_1.default.stat),mkdirSync=wrap(fs_1.default.mkdir),readFileSync=wrap(fs_1.default.readFile),writeFileSync=wrap(fs_1.default.writeFile),accessSync=wrap(fs_1.default.access),renameSync=wrap(fs_1.default.rename),globSync=wrap(glob_1.default);let seed=+new Date;function getId(){return++seed}function startRecord(){NPM_RECORD.start_time=Date.now(),REPORT_LIST.forEach(e=>NPM_RECORD[e]=0===e.indexOf("extra")?"":0)}function endRecord(e){NPM_RECORD.pack_time=Date.now()-NPM_RECORD.start_time;const t={};REPORT_LIST.forEach(e=>t[e]=NPM_RECORD[e]);try{null==e||e(t)}catch(e){}}async function recursiveMkdir(e){const t=path_1.default.posix.dirname(e);try{await accessSync(t)}catch(e){await recursiveMkdir(t)}try{await accessSync(e);const t=await statSync(e);t&&!t.isDirectory()&&(await renameSync(e,e+".bak"),log_1.default.warn(e+" already exists but is not a directory, so it will be rename to a file with the suffix ending in '.bak'"),await mkdirSync(e))}catch(t){await mkdirSync(e)}}async function copyFile(e,t){const a=await readFileSync(e);await writeFile(a,t)}async function writeFile(e,t){await recursiveMkdir(path_1.default.posix.dirname(t)),await writeFileSync(t,e)}function walkNode(e,t){t(e),Object.keys(e).forEach(a=>{const r=e[a];Array.isArray(r)&&r.forEach(e=>{(null==e?void 0:e.type)&&walkNode(e,t)}),(null==r?void 0:r.type)&&walkNode(r,t)})}function parseDeps(e,t,a){const r=[];let n,o=[];try{n=acorn.parse(e,{sourceType:"module",locations:!0,allowHashBang:!0,onComment(t,a,r,n){t||"#"!==e[r]||o.push({start:r,end:n,adjustContent:""})}})}catch(e){const a=`parse js file (${t}) failed: `+e.message;throw console.error(a),e.message=a,e}return walkNode(n,n=>{const i=n.callee,s=n.arguments;if("CallExpression"===n.type&&i&&"Identifier"===i.type&&"require"===i.name&&s&&1===s.length&&("Literal"===s[0].type?r.push(s[0].value):(a.push({jsPath:t,code:e.substring(n.start,n.end),startLine:n.loc.start.line,endLine:n.loc.end.line,tips:"require variable is not allowed",msg:locales_1.default.config.NOT_ALLOWED_REQUIRE_VAR.format()}),NPM_RECORD.warn_require_var_num++)),"ExpressionStatement"===n.type&&n.expression&&"use strict"===n.expression.value&&o.push({start:n.start,end:n.end,adjustContent:""}),"ImportDeclaration"===n.type){const e=n.source,t=n.specifiers,a={start:n.start,end:n.end,adjustContent:""},i=[];e&&"Literal"===e.type&&(r.push(e.value),i.push(`var __TEMP__ = require('${e.value}');`)),t&&Array.isArray(t)&&t.forEach(e=>{if("ImportSpecifier"===e.type){const t=e.local,a=e.imported;"Identifier"===t.type&&"Identifier"===a.type&&i.push(`var ${t.name} = __TEMP__['${a.name}'];`)}else if("ImportDefaultSpecifier"===e.type){const t=e.local;"Identifier"===t.type&&i.push(`var ${t.name} = __REQUIRE_DEFAULT__(__TEMP__);`)}else if("ImportNamespaceSpecifier"===e.type){const t=e.local;"Identifier"===t.type&&i.push(`var ${t.name} = __REQUIRE_WILDCARD__(__TEMP__);`)}}),a.adjustContent=i.join(""),o.push(a)}if("ExportNamedDeclaration"===n.type){const t=n.source,a=n.specifiers,i=n.declaration;let s=!1;const p={start:n.start,end:n.end,adjustContent:""},c=['if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });'];if(t&&"Literal"===t.type&&(r.push(t.value),c.push(`var __TEMP__ = require('${t.value}');`),s=!0),i){if("VariableDeclaration"===i.type){const t=i.declarations;t&&Array.isArray(t)&&t.forEach(t=>{if("VariableDeclarator"===t.type){const a=t.id,r=t.init;a&&"Identifier"===a.type&&(p.notAddLines=!0,c.push(`var ${a.name} = exports.${a.name} = ${r?e.substring(r.start,r.end):"undefined"};`))}})}else if("FunctionDeclaration"===i.type){const t=i.id;t&&"Identifier"===t.type&&(p.notAddLines=!0,c.push(`${e.substring(i.start,i.end)};exports.${t.name} = ${t.name}`))}else if("ClassDeclaration"===i.type){const t=i.id;t&&"Identifier"===t.type&&(p.notAddLines=!0,c.push(`${e.substring(i.start,i.end)};exports.${t.name} = ${t.name}`))}}else;a&&Array.isArray(a)&&a.forEach(e=>{if("ExportSpecifier"===e.type){const t=e.local,a=e.exported;"Identifier"===t.type&&"Identifier"===a.type&&c.push(`Object.defineProperty(exports, '${a.name}', { enumerable: true, configurable: true, get: function() { return ${s?"__TEMP__.":""}${t.name}; } });`)}}),p.adjustContent=c.join(""),o.push(p)}else if("ExportAllDeclaration"===n.type){const e=n.source,t={start:n.start,end:n.end,adjustContent:""},a=['if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });'];e&&"Literal"===e.type&&(r.push(e.value),a.push(`var __TEMP__ = require('${e.value}');`)),a.push('Object.keys(__TEMP__).forEach(function(k) { if (k === "default" || k === "__esModule") return; Object.defineProperty(exports, k, { enumerable: true, configurable: true, get: function() { return __TEMP__[k]; } }); });'),t.adjustContent=a.join(""),o.push(t)}else if("ExportDefaultDeclaration"===n.type){const t=n.declaration,a={start:n.start,end:n.end,adjustContent:""},r=['if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });'];if(t)if(a.notAddLines=!0,t.id){const a=t.id;r.push(`${e.substring(t.start,t.end)};exports.default = ${a.name}`)}else r.push(`exports.default = ${e.substring(t.start,t.end)};`);a.adjustContent=r.join(""),o.push(a)}const p=n.expression;"ExpressionStatement"===n.type&&p&&"AssignmentExpression"===p.type&&"Identifier"===p.right.type&&"require"===p.right.name&&(a.push({jsPath:t,code:e.substring(n.start,n.end),startLine:n.loc.start.line,endLine:n.loc.end.line,tips:"assign require function to a variable is not allowed",msg:locales_1.default.config.NOT_ALLOWED_REQUIRE_ASSIGN.format()}),NPM_RECORD.warn_require_rename_num++);const c=n.declarations;"VariableDeclaration"===n.type&&c.length>0&&c.forEach(r=>{const o=r.init;"VariableDeclarator"===r.type&&o&&"Identifier"===o.type&&"require"===o.name&&(a.push({jsPath:t,code:e.substring(n.start,n.end),startLine:n.loc.start.line,endLine:n.loc.end.line,tips:"assign require function to a variable is not allowed",msg:locales_1.default.config.NOT_ALLOWED_REQUIRE_ASSIGN.format()}),NPM_RECORD.warn_require_rename_num++)})}),o=o.sort((e,t)=>t.start-e.start),o.forEach(t=>{const a=e.substring(t.start,t.end),r=t.notAddLines?0:a.split("\n").length;e=e.substring(0,t.start)+t.adjustContent+new Array(r).join("\n")+e.substring(t.end)}),{deps:r,parsedContent:e}}async function parseJs(e,t,a,r,n,o){if(n[t=path_1.default.posix.normalize(t)])return n[t];const i=await readFileSync(t,"utf8"),s=getId(),p=path_1.default.posix.relative(e,t);if(/\.json$/.test(t)){const e={id:s,name:p,content:"module.exports = "+i,deps:[],depsMap:{}};return n[t]=s,r.push(e),s}const{deps:c,parsedContent:_}=parseDeps(i,t,o),u={id:s,name:p,content:_,deps:c,depsMap:{}};n[t]=s,r.push(u);for(const i of c){let s,p=path_1.default.posix.join(path_1.default.posix.dirname(t),i);if(!/\.js$/.test(p)&&!/\.json$/.test(p)){const e=p+".js";try{await accessSync(e),p=e}catch(e){}}try{const e=await statSync(p);(null==e?void 0:e.isDirectory())&&(p=path_1.default.posix.join(p,"index.js"))}catch(e){}/\.js$/.test(p)||/\.json$/.test(p)||(p+=".js");try{await accessSync(p),s=await parseJs(e,p,a,r,n,o)}catch(e){}s&&(u.depsMap[i]=s)}return s}function addJsToMap(e,t,a,r){const n=t.split("\n").length;for(let o=1;o<=n;o++)e.addMapping({generated:{line:r+o,column:0},original:{line:o,column:0},source:a}),e.setSourceContent(a,t)}function findOutsideDeps(e){const t=new Set;return e.forEach(e=>{e.deps.forEach(a=>{Object.keys(e.depsMap).includes(a)||t.add(a)})}),Array.from(t)}async function packJs(e,t,a){try{const t=await statSync(e);(null==t?void 0:t.isDirectory())&&(e=path_1.default.posix.join(e,"index.js"))}catch(e){}/\.js$/.test(e)||/\.json$/.test(e)||(e+=".js");try{await accessSync(e)}catch(t){return a.push({jsPath:e,code:"",tips:"entry file is not found",msg:locales_1.default.config.NOT_FOUND_NPM_ENTRY.format()}),void NPM_RECORD.warn_not_found_num++}const r=new source_map_1.default.SourceMapGenerator({file:"index.js"}),n=[];await parseJs(path_1.default.posix.dirname(e),e,t,n,{},a);const o=findOutsideDeps(n),i=["module.exports = (function() {","var __MODS__ = {};","var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };",'var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; };',"var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } };","var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };"];if(n.length){const e=n.shift();i.push(`__DEFINE__(${e.id}, function(require, module, exports) {`),addJsToMap(r,e.content,e.name,i.length),i.push(e.content),i.push(`}, function(modId) {var map = ${JSON.stringify(e.depsMap)}; return __REQUIRE__(map[modId], modId); })`);for(const e of n)i.push(`__DEFINE__(${e.id}, function(require, module, exports) {`),addJsToMap(r,e.content,e.name,i.length),i.push(e.content),i.push(`}, function(modId) { var map = ${JSON.stringify(e.depsMap)}; return __REQUIRE__(map[modId], modId); })`);i.push(`return __REQUIRE__(${e.id});`)}return i.push("})()"),i.push("//miniprogram-npm-outsideDeps="+JSON.stringify(o)),i.push("//# sourceMappingURL=index.js.map"),{js:i.join("\n"),map:r.toString()}}async function checkIsMiniprogramPack(e,t){let a="miniprogram_dist";t.miniprogram&&"string"==typeof t.miniprogram&&(a=t.miniprogram);try{const t=path_1.default.posix.join(e,a);await accessSync(t);const r=await statSync(t);if(null==r?void 0:r.isDirectory())return t}catch(e){}return""}async function packNpm(e,t={}){const a=e.projectPath,r=e.type,n=await(0,projectconfig_1.getProjectConfigJSON)(e),o=n.pluginRoot||"",i=n.miniprogramRoot||"",s="miniProgramPlugin"===r||"miniGamePlugin"===r,{ignores:p,reporter:c}=t;if(!a)throw new error_1.CodeError(locales_1.default.config.SHOULD_NOT_BE_EMPTY.format("projectPath"),config_1.PARAM_ERROR);if("miniProgramPlugin"===r&&!o)throw new error_1.CodeError(locales_1.default.config.SHOULD_NOT_BE_EMPTY.format('project.config.json "pluginRoot"'),config_1.PARAM_ERROR);startRecord();const _=path_1.default.isAbsolute(a)?a:path_1.default.posix.join(process.cwd(),a),u=[{searchRoot:path_1.default.posix.join(_,i),paths:await globSync("**/package.json",{cwd:path_1.default.posix.join(_,i),nodir:!0,dot:!0,ignore:(p||[]).concat("**/node_modules/**")})}];s&&u.push({searchRoot:path_1.default.posix.join(_,o),paths:await globSync("**/package.json",{cwd:path_1.default.posix.join(_,o),nodir:!0,dot:!0,ignore:(p||[]).concat("**/node_modules/**")})});lodash_1.default.flattenDeep(u.map(e=>e.paths.map(t=>path_1.default.posix.join(e.searchRoot,path_1.default.dirname(t),"miniprogram_npm")))).forEach(e=>rimraf_1.default.sync(e));const l=[];for(const e of u)for(const t of e.paths){const a=path_1.default.dirname(path_1.default.posix.join(e.searchRoot,t)),r=lodash_1.default.xorWith(e.paths,[t]).map(e=>path_1.default.posix.join(path_1.default.posix.dirname(e),"/**")).filter(e=>"**"!==e);let n=await globSync("**/package.json",{cwd:a.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:(p||[]).concat(r).concat(["node_modules/@types/**"])});if(n=await(0,filterdeps_1.default)(a,n),n&&n.length)for(const e of n){const t=path_1.default.posix.join(a,e);let r=await readFileSync(t,"utf8");const n=path_1.default.dirname(t);let o=n.replace(/([\b/\\])node_modules([\b/\\])/g,(e,t,a)=>`${t}miniprogram_npm${a}`),i=path_1.default.basename(o);const s=i.split("@");s.length&&(i=s.pop()||""),o=o.replace(path_1.default.basename(o),i),r=JSON.parse(r);const p=path_1.default.posix.join(n,r.main||"index.js"),c=await checkIsMiniprogramPack(n,r);if(c){const e=await globSync("**/*",{cwd:c.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:"**/node_modules/**"});for(const t of e)await copyFile(path_1.default.posix.join(c,t),path_1.default.posix.join(o,t));NPM_RECORD.miniprogram_pack_num++}else{const e=await packJs(p,o,l);if(!e)continue;await writeFile(e.js,path_1.default.posix.join(o,"./index.js")),await writeFile(e.map,path_1.default.posix.join(o,"./index.js.map")),NPM_RECORD.other_pack_num++}}}if(endRecord(c),NPM_RECORD.miniprogram_pack_num+NPM_RECORD.other_pack_num<=0)throw new Error("__NO_NODE_MODULES__ "+locales_1.default.config.NOT_FOUND_NODE_MODULES.format());return"function"==typeof e.updateFiles&&e.updateFiles(),l}async function packNpmManually(e){let{packageJsonPath:t,miniprogramNpmDistDir:a}=e;const r=e.ignores||[],n={pack_time:0,miniprogram_pack_num:0,other_pack_num:0,warn_not_found_num:0,warn_require_var_num:0,warn_require_rename_num:0},o=[];if(!a)throw new Error("param miniprogramNpmDistDir is required");if(!t)throw new Error("param packageJsonPath is required");if(path_1.default.isAbsolute(a)||(a=path_1.default.join(process.cwd(),a)),path_1.default.isAbsolute(t)||(t=path_1.default.join(process.cwd(),t)),!fs_1.default.existsSync(t))throw new Error(`param packageJsonPath: ${t} file is not exited`);const i=path_1.default.dirname(t);let s=await globSync("**/package.json",{cwd:i.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:(r||[]).concat(["node_modules/@types/**"])});if(s=await(0,filterdeps_1.default)(i,s),!s||!s.length)return log_1.default.warn("No miniprogram_npm package was built."),{miniProgramPackNum:0,otherNpmPackNum:0,warnList:[]};s=s.filter(e=>e.startsWith("node_modules"));for(const e of s){const t=path_1.default.posix.join(i,e);let r=await readFileSync(t,"utf8");const s=path_1.default.dirname(t);let p=s.replace(/([\b/\\])node_modules([\b/\\])/g,(e,t,a)=>`${t}miniprogram_npm${a}`);p=path_1.default.posix.normalize(path_1.default.posix.join(a,"miniprogram_npm",p.split(/[/\\]miniprogram_npm[/\\]/)[1]));let c=path_1.default.basename(p);const _=c.split("@");_.length&&(c=_.pop()||""),p=p.replace(path_1.default.basename(p),c),r=JSON.parse(r);const u=path_1.default.posix.join(s,r.main||"index.js"),l=await checkIsMiniprogramPack(s,r);if(l){const e=await globSync("**/*",{cwd:l.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:"**/node_modules/**"});for(const t of e)await copyFile(path_1.default.posix.join(l,t),path_1.default.posix.join(p,t));n.miniprogram_pack_num++}else{const e=await packJs(u,p,o);if(!e)continue;await writeFile(e.js,path_1.default.posix.join(p,"./index.js")),await writeFile(e.map,path_1.default.posix.join(p,"./index.js.map")),n.other_pack_num++}}return{miniProgramPackNum:n.miniprogram_pack_num,otherNpmPackNum:n.other_pack_num,warnList:o}}exports.packNpm=packNpm,exports.packNpmManually=packNpmManually;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.tryTranslateSingleFile=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),parser=(0,tslib_1.__importStar)(require("@babel/parser")),traverse_1=(0,tslib_1.__importDefault)(require("@babel/traverse")),sourcemap=(0,tslib_1.__importStar)(require("source-map")),babel_code_frame_1=(0,tslib_1.__importDefault)(require("babel-code-frame"));class TranslateResult{constructor(){this.translated=!0,this.errMsg="",this.debugs=[],this.translatedContent="",this.fullPath="",this.translatedSourceMap=""}}function getErrorCodeFrame(e,n,t,r){let o;try{o=new sourcemap.SourceMapConsumer(n||""),e=o.sourceContentFor(t)||e}catch(e){}const i=[];for(const n of r){let t={line:n.line,column:n.column>0?n.column:0};try{o&&(t=o.originalPositionFor({line:n.line,column:n.column}))}catch(e){}const r=(0,babel_code_frame_1.default)(e,t.line,t.column);i.push(`${n.reason}\n${r}`)}return i.join("\n\n")}function translateCode(e,n){const t=e.replace(/\r\n/g,"\n").split("\n");for(let e=0;e<t.length;e++){const r=t[e],o=n[e+1];if(o){const n=[];let i=0;for(const e in o){const t=o[e];n.push(r.substr(i,t.column-i+1)),n.push(t.toString),i=t.column+t.fromString.length+1}n.push(r.substr(i)),t[e]=n.join("")}}return t.join("\n")}function translateSourceMap(e,n,t){const r=new sourcemap.SourceMapConsumer(e),o=new sourcemap.SourceMapGenerator({file:n});let i;return r.eachMapping(e=>{if("number"!=typeof e.originalLine||"number"!=typeof e.originalColumn)return;const n={generated:{line:e.generatedLine,column:e.generatedColumn},source:e.source,name:e.name,original:{line:e.originalLine,column:e.originalColumn}};if(i&&i.line===e.generatedLine?n.generated.column+=i.offset:i=void 0,t[e.generatedLine]){const n=t[e.generatedLine][e.generatedColumn];n&&(i&&i.line===n.line?i.offset+=n.offset:i={line:n.line,offset:n.offset})}o.addMapping(n)}),o.toString()}function dirname(e){const n=e.split("/");return n.pop(),n.join("/")}function getNpmRequirePath(e,n,t){if(e.startsWith(".")||e.startsWith("/"))return!1;{let r,o=n;for(;o;)if(o=dirname(o),r=e.endsWith(".js")?path_1.default.posix.join(o,"miniprogram_npm",e):path_1.default.posix.join(o,"miniprogram_npm",e,"index.js"),t.includes(r))return r;return!1}}const tryTranslateSingleFile=e=>{var n,t;const r=new TranslateResult,{filePath:o,nameMapping:i,code:a,rootPath:l,miniProgramJSFiles:s}=e;let u=path_1.default.posix.dirname(path_1.default.posix.relative(l,o));"."===u&&(u="");const c=[];let p;try{p=parser.parse(a)}catch(i){return c.push({line:(null===(n=i.loc)||void 0===n?void 0:n.line)||1,column:(null===(t=i.loc)||void 0===t?void 0:t.column)||1,reason:i.message}),r.translated=!1,r.errMsg=`in ${path_1.default.posix.join(l,o)}\n${getErrorCodeFrame(a,e.sourceMap,e.sourceFileName,c)}`,r}const d={};if((0,traverse_1.default)(p,{AssignmentExpression(e){const n=e.node.loc.start;"Identifier"===e.node.left.type&&"require"===e.node.left.name&&c.push({line:n.line,column:n.column,reason:"assigning other name with 'require'"}),"Identifier"===e.node.right.type&&"require"===e.node.right.name&&c.push({line:n.line,column:n.column,reason:"'require' should not be renamed"})},VariableDeclarator(e){const n=e.node.loc.start;e.node.id&&"Identifier"===e.node.id.type&&"require"===e.node.id.name&&c.push({line:n.line,column:n.column,reason:"(init) assigning other name with 'require'"}),e.node.init&&"Identifier"===e.node.init.type&&"require"===e.node.init.name&&c.push({line:n.line,column:n.column,reason:"(init) 'require' should not be renamed"})},CallExpression(
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.tryTranslateSingleFile=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),parser=(0,tslib_1.__importStar)(require("@babel/parser")),traverse_1=(0,tslib_1.__importDefault)(require("@babel/traverse")),sourcemap=(0,tslib_1.__importStar)(require("source-map")),babel_code_frame_1=(0,tslib_1.__importDefault)(require("babel-code-frame"));class TranslateResult{constructor(){this.translated=!0,this.errMsg="",this.debugs=[],this.translatedContent="",this.fullPath="",this.translatedSourceMap=""}}function getErrorCodeFrame(e,n,t,r){let o;try{o=new sourcemap.SourceMapConsumer(n||""),e=o.sourceContentFor(t)||e}catch(e){}const i=[];for(const n of r){let t={line:n.line,column:n.column>0?n.column:0};try{o&&(t=o.originalPositionFor({line:n.line,column:n.column}))}catch(e){}const r=(0,babel_code_frame_1.default)(e,t.line,t.column);i.push(`${n.reason}\n${r}`)}return i.join("\n\n")}function translateCode(e,n){const t=e.replace(/\r\n/g,"\n").split("\n");for(let e=0;e<t.length;e++){const r=t[e],o=n[e+1];if(o){const n=[];let i=0;for(const e in o){const t=o[e];n.push(r.substr(i,t.column-i+1)),n.push(t.toString),i=t.column+t.fromString.length+1}n.push(r.substr(i)),t[e]=n.join("")}}return t.join("\n")}function translateSourceMap(e,n,t){const r=new sourcemap.SourceMapConsumer(e),o=new sourcemap.SourceMapGenerator({file:n});let i;return r.eachMapping(e=>{if("number"!=typeof e.originalLine||"number"!=typeof e.originalColumn)return;const n={generated:{line:e.generatedLine,column:e.generatedColumn},source:e.source,name:e.name,original:{line:e.originalLine,column:e.originalColumn}};if(i&&i.line===e.generatedLine?n.generated.column+=i.offset:i=void 0,t[e.generatedLine]){const n=t[e.generatedLine][e.generatedColumn];n&&(i&&i.line===n.line?i.offset+=n.offset:i={line:n.line,offset:n.offset})}o.addMapping(n)}),o.toString()}function dirname(e){const n=e.split("/");return n.pop(),n.join("/")}function getNpmRequirePath(e,n,t){if(e.startsWith(".")||e.startsWith("/"))return!1;{let r,o=n;for(;o;)if(o=dirname(o),r=e.endsWith(".js")?path_1.default.posix.join(o,"miniprogram_npm",e):path_1.default.posix.join(o,"miniprogram_npm",e,"index.js"),t.includes(r))return r;return!1}}const tryTranslateSingleFile=e=>{var n,t;const r=new TranslateResult,{filePath:o,nameMapping:i,code:a,rootPath:l,miniProgramJSFiles:s}=e;let u=path_1.default.posix.dirname(path_1.default.posix.relative(l,o));"."===u&&(u="");const c=[];let p;try{p=parser.parse(a)}catch(i){return c.push({line:(null===(n=i.loc)||void 0===n?void 0:n.line)||1,column:(null===(t=i.loc)||void 0===t?void 0:t.column)||1,reason:i.message}),r.translated=!1,r.errMsg=`in ${path_1.default.posix.join(l,o)}\n${getErrorCodeFrame(a,e.sourceMap,e.sourceFileName,c)}`,r}const d={};if((0,traverse_1.default)(p,{AssignmentExpression(e){const n=e.node.loc.start;"Identifier"===e.node.left.type&&"require"===e.node.left.name&&c.push({line:n.line,column:n.column,reason:"assigning other name with 'require'"}),"Identifier"===e.node.right.type&&"require"===e.node.right.name&&c.push({line:n.line,column:n.column,reason:"'require' should not be renamed"})},VariableDeclarator(e){const n=e.node.loc.start;e.node.id&&"Identifier"===e.node.id.type&&"require"===e.node.id.name&&c.push({line:n.line,column:n.column,reason:"(init) assigning other name with 'require'"}),e.node.init&&"Identifier"===e.node.init.type&&"require"===e.node.init.name&&c.push({line:n.line,column:n.column,reason:"(init) 'require' should not be renamed"})},CallExpression(n){const t=n.node.loc.start;for(const e of n.node.arguments)"Identifier"===e.type&&"require"===e.name&&c.push({line:t.line,column:t.column,reason:"passing 'require' as a parameter is not a good taste"});if("Identifier"===n.node.callee.type&&"require"===n.node.callee.name&&(1===n.node.arguments.length&&"StringLiteral"===n.node.arguments[0].type||c.push({line:t.line,column:t.column,reason:"'require' requires one and only one static string literal"})),"require"===n.node.callee.name&&1===n.node.arguments.length&&"StringLiteral"===n.node.arguments[0].type){const t=n.node.arguments[0].loc.start,a=n.node.arguments[0].value,c=e.resolveAlias(a);let p;p=c?path_1.default.posix.join(l,c):path_1.default.posix.normalize(path_1.default.posix.join(u,a)),/\.js$/.test(p)||(p+=".js"),/^\//.test(p)&&(p=p.replace(/^\//,""));let m=i[p];if(m)m=i[o]?path_1.default.posix.relative(path_1.default.posix.dirname(i[o]),m):path_1.default.posix.relative(u,m),d[t.line]||(d[t.line]={}),d[t.line][t.column]={line:t.line,column:t.column,fromString:a,toString:m,offset:m.length-a.length},r.debugs.push([o,a,"replace",[p,m]]);else{if(i[o]){const e=getNpmRequirePath(a,o,s);e&&(p=e),m=path_1.default.posix.relative(path_1.default.posix.dirname(i[o]),p),d[t.line]||(d[t.line]={}),d[t.line][t.column]={line:t.line,column:t.column,fromString:a,toString:m,offset:m.length-a.length},r.debugs.push([o,a,"replace",[p,m]])}r.debugs.push([o,a,"ignored"])}}},Identifier(e){const n=e.node.loc.start;if("require"===e.node.name){if("UnaryExpression"===e.parent.type&&"typeof"===e.parent.operator)return;"CallExpression"!==e.parent.type&&c.push({line:n.line,column:n.column,reason:`require is not being used properly in '${e.parent.type}'`})}}}),c.length>0)return r.translated=!1,r.errMsg=`in ${o}\n${getErrorCodeFrame(a,e.sourceMap,e.sourceFileName,c)}`,r;if(Object.keys(d).length>0){r.translatedContent=translateCode(a,d);try{r.translatedSourceMap=translateSourceMap(e.sourceMap||"",e.sourceFileName,d)}catch(e){}}else r.translatedContent=a,r.translatedSourceMap=e.sourceMap;return r};exports.tryTranslateSingleFile=tryTranslateSingleFile;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.uglifyFileNames=exports.getGameNameMapping=exports.getNameMapping=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),config_1=require("../../config"),error_1=require("../../utils/error"),tools_1=require("../../utils/tools"),game_1=(0,tslib_1.__importDefault)(require("../json/game")),app_1=require("../json/app"),file_flatter_1=require("./file_flatter"),url_config_1=require("../../utils/url_config"),request_1=require("../../utils/request"),sign_1=require("../../utils/sign"),jsonParse_1=require("../../utils/jsonParse"),locales_1=(0,tslib_1.__importDefault)(require("../../utils/locales/locales")),config=(0,tslib_1.__importStar)(require("../../config")),common_1=require("../../utils/common");function checkPrefix(e,t){for(const a of t)if(0===e.indexOf(a))return a;return""}const getNameMapping=async(e,t)=>{if(process.env.isDevtools)return e.nameMappingFromDevtools||{};{const a=e.getFileList(t,".js").map(e=>path_1.default.posix.relative(t,e));try{let r={};if("miniProgram"===e.type){const o=await(0,app_1.getAppJSON)(e);r=await getMiniProgramNameMapping(e,t,o,a)}if("miniGame"===e.type){const t=await(0,game_1.default)(e);r=await(0,exports.getGameNameMapping)(e,t,a)}return r}catch(e){throw new error_1.CodeError(e.toString(),config_1.CODE_PROTECT_TRANSLATE_FILENAME)}}};exports.getNameMapping=getNameMapping;const getMiniProgramNameMapping=async(e,t,a,r)=>{const o=[{type:"file",value:"app.js"},{type:"regex",value:/\/miniprogram_npm\/|^miniprogram_npm\//},{type:"folder",value:"functional-pages/"}],i=e.getFileList(t,".wxml").map(e=>path_1.default.posix.relative(t,e));for(const e of i)o.push({type:"file",value:""+e.replace(/\.wxml$/,".js")});let s=[];return a.subPackages&&(s=a.subPackages.map(e=>e.root)),a.widgets&&a.widgets.length>0&&a.widgets.forEach(e=>{o.push({type:"folder",value:/\/$/.test(e.path)?e.path:e.path+"/"})}),a.workers&&o.push({type:"folder",value:a.workers}),a.openDataContext&&(o.push({type:"file",value:path_1.default.posix.join(a.openDataContext,"index.js")}),s.push(a.openDataContext)),await _getNameMapping(e,r,o,s)},getGameNameMapping=async(e,t,a)=>{const r=[{type:"file",value:"game.js"},{type:"regex",value:/\/miniprogram_npm\/|^miniprogram_npm\//}],o=[];if(t.subPackages&&t.subPackages.forEach(e=>{const t=e.root.replace(/^\//,"");/\.js$/.test(t)?(r.push({type:"file",value:t}),o.push(path_1.default.posix.dirname(t))):(r.push({type:"file",value:path_1.default.posix.join(t,"./game.js")}),o.push(t))}),t.openDataContext&&(r.push({type:"file",value:path_1.default.posix.join(t.openDataContext,"index.js")}),o.push(t.openDataContext)),t.workers&&r.push({type:"folder",value:t.workers}),t.plugins)for(const e in t.plugins){const a=t.plugins[e];if(a.path){const e=a.path.replace(/^\//,"");r.push({type:"folder",value:e})}}return await _getNameMapping(e,a,r,o)};async function _getNameMapping(e,t,a,r=[]){const o={},i=[];for(const e of t){let t=!1;for(const r of a)if("file"===r.type&&r.value===e||"folder"===r.type&&0===e.indexOf(r.value)||"regex"===r.type&&r.value.test(e)){t=!0;break}t||i.push(e)}const s=await(0,sign_1.getSignature)(e.privateKey,e.appid),{body:n}=await(0,request_1.request)({url:url_config_1.TRANSLATE_FILENAME,method:"post",body:JSON.stringify({appid:e.appid,signature:s,arrPaths:i}),headers:{"content-type":"application/json"}}),p=(0,jsonParse_1.jsonRespParse)(n,url_config_1.TRANSLATE_FILENAME);if(0===p.errCode)return p.body.pairs.forEach(e=>{const t=checkPrefix(e.origin,r);o[e.origin]=(0,tools_1.normalizePath)(path_1.default.posix.join(t,e.translated+".js"))}),o;throw new Error(`errCode: ${p.errCode} errMsg: ${p.errMsg}`)}async function uglifyFileNames(e,t,a){let r={miniprogramRoot:""};try{r=JSON.parse(t["project.config.json"].toString())}catch(e){}let o=(0,tools_1.normalizePath)(r.miniprogramRoot);"."===o&&(o=""),a=a||await(0,exports.getNameMapping)(e,e.miniprogramRoot);const i=Object.keys(t).filter(e=>e.endsWith(".js")),s={};for(const e of i){if(/\/miniprogram_npm\/|^miniprogram_npm\//.test(e))continue;const r=e,
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.uglifyFileNames=exports.getGameNameMapping=exports.getNameMapping=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),config_1=require("../../config"),error_1=require("../../utils/error"),tools_1=require("../../utils/tools"),game_1=(0,tslib_1.__importDefault)(require("../json/game")),app_1=require("../json/app"),file_flatter_1=require("./file_flatter"),url_config_1=require("../../utils/url_config"),request_1=require("../../utils/request"),sign_1=require("../../utils/sign"),jsonParse_1=require("../../utils/jsonParse"),locales_1=(0,tslib_1.__importDefault)(require("../../utils/locales/locales")),config=(0,tslib_1.__importStar)(require("../../config")),common_1=require("../../utils/common");function checkPrefix(e,t){for(const a of t)if(0===e.indexOf(a))return a;return""}const getNameMapping=async(e,t)=>{if(process.env.isDevtools)return e.nameMappingFromDevtools||{};{const a=e.getFileList(t,".js").map(e=>path_1.default.posix.relative(t,e));try{let r={};if("miniProgram"===e.type){const o=await(0,app_1.getAppJSON)(e);r=await getMiniProgramNameMapping(e,t,o,a)}if("miniGame"===e.type){const t=await(0,game_1.default)(e);r=await(0,exports.getGameNameMapping)(e,t,a)}return r}catch(e){throw new error_1.CodeError(e.toString(),config_1.CODE_PROTECT_TRANSLATE_FILENAME)}}};exports.getNameMapping=getNameMapping;const getMiniProgramNameMapping=async(e,t,a,r)=>{const o=[{type:"file",value:"app.js"},{type:"regex",value:/\/miniprogram_npm\/|^miniprogram_npm\//},{type:"folder",value:"functional-pages/"}],i=e.getFileList(t,".wxml").map(e=>path_1.default.posix.relative(t,e));for(const e of i)o.push({type:"file",value:""+e.replace(/\.wxml$/,".js")});let s=[];return a.subPackages&&(s=a.subPackages.map(e=>e.root)),a.widgets&&a.widgets.length>0&&a.widgets.forEach(e=>{o.push({type:"folder",value:/\/$/.test(e.path)?e.path:e.path+"/"})}),a.workers&&o.push({type:"folder",value:a.workers}),a.openDataContext&&(o.push({type:"file",value:path_1.default.posix.join(a.openDataContext,"index.js")}),s.push(a.openDataContext)),await _getNameMapping(e,r,o,s)},getGameNameMapping=async(e,t,a)=>{const r=[{type:"file",value:"game.js"},{type:"regex",value:/\/miniprogram_npm\/|^miniprogram_npm\//}],o=[];if(t.subPackages&&t.subPackages.forEach(e=>{const t=e.root.replace(/^\//,"");/\.js$/.test(t)?(r.push({type:"file",value:t}),o.push(path_1.default.posix.dirname(t))):(r.push({type:"file",value:path_1.default.posix.join(t,"./game.js")}),o.push(t))}),t.openDataContext&&(r.push({type:"file",value:path_1.default.posix.join(t.openDataContext,"index.js")}),o.push(t.openDataContext)),t.workers&&r.push({type:"folder",value:t.workers}),t.plugins)for(const e in t.plugins){const a=t.plugins[e];if(a.path){const e=a.path.replace(/^\//,"");r.push({type:"folder",value:e})}}return await _getNameMapping(e,a,r,o)};async function _getNameMapping(e,t,a,r=[]){const o={},i=[];for(const e of t){let t=!1;for(const r of a)if("file"===r.type&&r.value===e||"folder"===r.type&&0===e.indexOf(r.value)||"regex"===r.type&&r.value.test(e)){t=!0;break}t||i.push(e)}const s=await(0,sign_1.getSignature)(e.privateKey,e.appid),{body:n}=await(0,request_1.request)({url:url_config_1.TRANSLATE_FILENAME,method:"post",body:JSON.stringify({appid:e.appid,signature:s,arrPaths:i}),headers:{"content-type":"application/json"}}),p=(0,jsonParse_1.jsonRespParse)(n,url_config_1.TRANSLATE_FILENAME);if(0===p.errCode)return p.body.pairs.forEach(e=>{const t=checkPrefix(e.origin,r);o[e.origin]=(0,tools_1.normalizePath)(path_1.default.posix.join(t,e.translated+".js"))}),o;throw new Error(`errCode: ${p.errCode} errMsg: ${p.errMsg}`)}function genResolveAlias(e){if(e){const t=[];return Object.keys(e).forEach(a=>{let r=a;a.endsWith("*")&&(r=r.slice(0,-1));let o=e[a];e[a].endsWith("*")&&(o=o.slice(0,-1)),t.push({key:r,value:o})}),e=>{let a={key:"",value:""},r=!1;if(t.forEach(t=>{e.startsWith(t.key)&&a.key.length<t.key.length&&(a=t,r=!0)}),!r)return;let o=e.replace(a.key,a.value);return"/"===o[0]&&(o=o.slice(1)),o}}return e=>{}}async function uglifyFileNames(e,t,a){let r={miniprogramRoot:""};try{r=JSON.parse(t["project.config.json"].toString())}catch(e){}let o=(0,tools_1.normalizePath)(r.miniprogramRoot);"."===o&&(o=""),a=a||await(0,exports.getNameMapping)(e,e.miniprogramRoot);const i=Object.keys(t).filter(e=>e.endsWith(".js")),s={};let n,p=t[path_1.default.posix.join(o,"app.json")];p?(Buffer.isBuffer(p)&&(p=p.toString("utf-8")),p=JSON.parse(p),n=genResolveAlias(p.resolveAlias)):n=genResolveAlias(void 0);for(const e of i){if(/\/miniprogram_npm\/|^miniprogram_npm\//.test(e))continue;const r=e,p=t[e].toString(),l=t[e+".map"]||"";s[r]=(0,file_flatter_1.tryTranslateSingleFile)({rootPath:o,code:p,nameMapping:a,check:!0,sourceFileName:e,sourceMap:l,filePath:e,miniProgramJSFiles:i,resolveAlias:n})}const l=Object.keys(t),u={};for(const e of l){u[(0,tools_1.normalizePath)(e)]=t[e]}for(const e in s){const t=(0,tools_1.normalizePath)(e);let r=t;const i=s[e];if(i.errMsg){if(!process.env.isDevtools)throw new Error(`\n${locales_1.default.config.COULD_NOT_USE_CODE_PROTECT}\n${i.errMsg}`);(0,common_1.throwError)({code:config.FILE_FLAT_ERR,msg:`${locales_1.default.config.COULD_NOT_USE_CODE_PROTECT}\n${i.errMsg}`,filePath:t})}const n=path_1.default.posix.relative(o,e);a[n]&&(r=(0,tools_1.normalizePath)(path_1.default.posix.join(o,a[n])),delete u[t],delete u[t+".map"]),u[r]=i.translatedContent,i.translatedSourceMap&&(u[r+".map"]=i.translatedSourceMap)}return u}exports.getGameNameMapping=getGameNameMapping,exports.uglifyFileNames=uglifyFileNames;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
package/dist/core.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.cleanCache=exports.mergeThemeJSONToPageJSON=exports.mergeThemeJSONToAppJSON=exports.schemaValidate=exports.
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.cleanCache=exports.mergeThemeJSONToPageJSON=exports.mergeThemeJSONToAppJSON=exports.schemaValidate=exports.checkThemeJSON=exports.getPluginPageJSON=exports.getPluginJSON=exports.getGameJSON=exports.compile=exports.compileJS=exports.getPageJSON=exports.getAppJSON=exports.setLocale=exports.setFSAgent=exports.partialAnalyse=void 0;const tslib_1=require("tslib"),index_1=require("./core/compile/index");Object.defineProperty(exports,"compile",{enumerable:!0,get:function(){return index_1.compile}});const app_1=require("./core/json/app"),getPageJSON_1=require("./core/json/page/getPageJSON");Object.defineProperty(exports,"getPageJSON",{enumerable:!0,get:function(){return getPageJSON_1.getPageJSON}});const js_1=require("./core/compile/handler/js");Object.defineProperty(exports,"compileJS",{enumerable:!0,get:function(){return js_1.compileJS}});const plugin_1=require("./core/json/plugin/plugin");Object.defineProperty(exports,"getPluginJSON",{enumerable:!0,get:function(){return plugin_1.getDevPluginJSON}});const plugin_page_1=require("./core/json/plugin/plugin_page");Object.defineProperty(exports,"getPluginPageJSON",{enumerable:!0,get:function(){return plugin_page_1.getPluginPageJSON}});const cache_1=require("./utils/cache"),theme_1=require("./core/json/theme");Object.defineProperty(exports,"checkThemeJSON",{enumerable:!0,get:function(){return theme_1.checkThemeJSON}}),Object.defineProperty(exports,"mergeThemeJSONToAppJSON",{enumerable:!0,get:function(){return theme_1.mergeThemeJSONToAppJSON}}),Object.defineProperty(exports,"mergeThemeJSONToPageJSON",{enumerable:!0,get:function(){return theme_1.mergeThemeJSONToPageJSON}});const schemaValidate_1=require("./core/validate/schemaValidate");Object.defineProperty(exports,"schemaValidate",{enumerable:!0,get:function(){return schemaValidate_1.schemaValidate}});const reactiveCache_1=require("./core/json/reactiveCache"),fs_1=(0,tslib_1.__importDefault)(require("./utils/fs")),locales_1=(0,tslib_1.__importDefault)(require("./utils/locales/locales")),game_1=(0,tslib_1.__importDefault)(require("./core/json/game"));function setFSAgent(e){fs_1.default.setAgent(e)}async function getAppJSON(e){try{const t=(0,reactiveCache_1.tryToGetReactiveProject)(e);return await t.updateProject(),(0,app_1.getAppJSON)(e)}catch(e){throw console.error("getAppJSON error",e),e}}async function getGameJSON(e){try{const t=(0,reactiveCache_1.tryToGetReactiveProject)(e);return await t.updateProject(),(0,game_1.default)(e)}catch(e){throw console.error("getGameJSON error",e),e}}function cleanCache(){cache_1.cacheManager.clean()}exports.partialAnalyse=(0,tslib_1.__importStar)(require("./core/analyse/partial")),exports.setFSAgent=setFSAgent,exports.setLocale=locales_1.default.setLocale,exports.getAppJSON=getAppJSON,exports.getGameJSON=getGameJSON,exports.cleanCache=cleanCache;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
package/dist/manifest.json
CHANGED
package/dist/summer/devtool.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SummerCompiler=exports.FullPkg=exports.MainPkg=void 0;const tslib_1=require("tslib"),child_process_1=require("child_process"),request_1=require("../utils/request"),path_1=(0,tslib_1.__importDefault)(require("path")),lodash_1=(0,tslib_1.__importDefault)(require("lodash")),recorder_1=require("./recorder"),tools_1=require("../utils/tools"),uglifyfilenames_1=require("../core/protect/uglifyfilenames"),error_1=require("./error"),miniprogram="miniprogram",plugin="plugin";function performanceMark(e,s){console.warn(`[summer-compiler] [${(0,recorder_1.getPrintTime)()}] [${Math.floor(performance.now())}ms elapsed] ${e}${s?" end":""}`)}exports.MainPkg="__APP__",exports.FullPkg="__FULL__";class SummerCompilerProcess{constructor(e,s){this.projectPath=e,this.cachePath=s,this.taskMap=new Map,this.taskId=0,this.initedPromise=new Promise((e,s)=>{this.initedResolve=e,this.initedReject=s})}async init(e,s,t){this.process=this.forkProcess();const r={type:"init",data:Object.assign({projectPath:this.projectPath,cachePath:this.cachePath,files:s,dirs:t},e)};performanceMark("process init"),this.sendProcessMessage(r),performanceMark("process init",!0),await this.initedPromise}destroy(){this.process.kill("SIGTERM")}sendProcessMessage(e){this.process.send(e)}forkProcess(){const e=path_1.default.posix.join(__dirname,"./entry_process.js"),s={stdio:["pipe","pipe","pipe","ipc"],cwd:this.projectPath,env:Object.assign(Object.assign({},process.env),{cpprocessEnv:"childprocess",summerProcess:"1"})};if(s.env.isDevtools=process.__nwjs&&"wechatwebdevtools"===nw.App.manifest.appname,s.env.isDevtools){let e=path_1.default.join(path_1.default.dirname(process.execPath),"node");"darwin"!==process.platform&&(e+=".exe"),s.execPath=e}performanceMark("fork process");const t=(0,child_process_1.fork)(e,["--expose-gc"],s);return t.stdout.setEncoding("utf8"),t.stdout.on("data",e=>{}),t.stderr.on("data",e=>{console.error("child process stderr: "+e)}),t.on("exit",e=>{console.error(`child process exit: code(${e})`),0!==e&&this.initedReject(new Error(`summer child process exit: code(${e})`))}),t.on("message",this.onChildProcessMessage.bind(this)),t.unref(),t}onChildProcessMessage(e){if("ready"===e.type)return performanceMark("process ready"),void this.initedResolve(!0);if("progress"===e.type){const s=this.taskMap.get(e.taskId);(null==s?void 0:s.progressUpdate)&&s.progressUpdate(e.id,e.status,e.message)}else if("response"===e.type){const{id:s,data:t,error:r}=e;if(r){const e=new error_1.SummerError(r);this.onResponse(s,void 0,e)}else this.onResponse(s,t,void 0)}}onResponse(e,s,t){const r=this.taskMap.get(e);this.taskMap.delete(e),r?t?r.reject(t):r.resolve(s):console.error(`child process task: ${e} not found`)}async sendEvent(e,s){await this.initedPromise,this.sendProcessMessage({type:"event",name:e,data:s})}async runTask(e,s,t){await this.initedPromise;return new Promise((r,i)=>{const o={name:e,data:s,resolve:r,reject:i,progressUpdate:t};this.taskId=this.taskId+1,this.taskMap.set(this.taskId,o),this.sendProcessMessage({type:"request",id:this.taskId,name:e,data:s})})}}class MessageHub{constructor(e){this.devtoolMessagehub=e,this.showing=new Set}showStatus(e,s){this.showing.add(e),this.devtoolMessagehub.showStatus(e,s)}hideStatus(e){this.showing.delete(e),this.devtoolMessagehub.hideStatus(e)}clear(){for(const e of this.showing.values())this.hideStatus(e);this.showing.clear()}}class SummerCompiler{constructor(e,s,t,r){this.projectPath=e,this.cachePath=s,this.options=t,this.devtoolMessagehub=r,this.isSummer=!0,this.codeCache=new Map,this.promiseCache=new Map,this.status=void 0,this.onProgressUpdate=(e,s,t)=>{"doing"===s?this.messageHub.showStatus(e,t):this.messageHub.hideStatus(e)},this.projectPath=(0,tools_1.normalizePath)(this.projectPath),performanceMark("create summer compiler"),this.messageHub=new MessageHub(r),this.process=new SummerCompilerProcess(this.projectPath,this.cachePath)}async init(e,s,t){performanceMark("init summer compiler"),await this.process.init(this.options,e,s),await this.loadStatus(),performanceMark("init summer compiler",!0)}async loadStatus(){var e;this.status=await(null===(e=this.process)||void 0===e?void 0:e.runTask("loadStatus"))}destroy(){this.process.destroy(),this.messageHub.clear()}async clearCache(){var e;await(null===(e=this.process)||void 0===e?void 0:e.runTask("clearCache")),this.codeCache.clear(),this.promiseCache.clear()}updateOptions(e){var s;lodash_1.default.isEqual(e,this.options)||(this.options=e,this.promiseCache.clear(),this.codeCache.clear(),null===(s=this.process)||void 0===s||s.sendEvent("updateOptions",e),this.loadStatus())}fileChange(e,s){if("change"!==e||s.endsWith(".json"))for(const e of this.promiseCache.keys())e.startsWith("getConf-")&&this.promiseCache.delete(e);this.invalidCodeCache(),this.process.sendEvent("fileChange",{type:e,targetPath:s})}invalidCodeCache(){for(const e of this.codeCache.values())e.isValid=!1}async getConf(e){const s="getConf-"+e;if(this.promiseCache.has(s))return console.log(s,"hit cache"),this.promiseCache.get(s);{console.log(s,"do request"),performanceMark("request get conf");const t={graphId:e},r=this.process.runTask("getConf",t,this.onProgressUpdate);return this.promiseCache.set(s,r),performanceMark("request get conf",!0),r}}async getCode(e,s){const t=`getCode-${e}${s?"-"+s.package:""}`;if(this.promiseCache.has(t))return console.log(t,"hit promise cache"),this.promiseCache.get(t);{const r=this.codeCache.get(t);if(null==r?void 0:r.isValid)return r.codeFiles;console.log(t,"do request");const i={};if(r){const e=r.codeFiles;for(const s of Object.keys(e)){const t=e[s];"error"in t||(i[s]=t.md5)}}const o={graphId:e,cacheMd5:i,package:null==s?void 0:s.package};performanceMark("request get code");const a=Date.now();console.time("[summer-compiler] runTask "+t),console.log(`[summer-compiler] [${(0,recorder_1.getPrintTime)()}] runTask ${t}`);const n=this.process.runTask("getCode",o,this.onProgressUpdate).then(e=>{var s;console.timeEnd("[summer-compiler] runTask "+t);const r=(null===(s=this.codeCache.get(t))||void 0===s?void 0:s.codeFiles)||{};for(const s of Object.keys(e)){const t=e[s];"error"in t||""!==t.md5?r[s]=t:delete r[s]}return this.codeCache.set(t,{isValid:!0,codeFiles:r}),r},e=>{throw e.code?console.error(e):console.error("Unexpected error when getCode",e),this.messageHub.clear(),e});return n.finally(()=>{performanceMark("request get code",!0),console.log(`[summer-compiler] [${(0,recorder_1.getPrintTime)()}] [cost ${Date.now()-a}ms] runTask ${t}`),this.promiseCache.delete(t)}),this.promiseCache.set(t,n),n}}async ready(){return this.process.initedPromise}async getAppJSON(e,s){return(await this.getConf(miniprogram)).app}async getSiteMapJSON(){return(await this.getConf(miniprogram)).sitemap}async getPageJSON(e,s){const t=await this.getConf(miniprogram),r=t.pages[s]||t.comps[s];if(!r)throw new Error("summer-compiler 收集json配置有遗漏, "+s);return r}async getAllPageAndComponentJSON(){const e=await this.getConf(miniprogram);return Object.keys(e.pages).concat(Object.keys(e.comps))}async getAllSortedJSFiles(){const e=await this.getConf(miniprogram),s=Object.keys(e.pages),t=Object.keys(e.comps),r=s.filter(e=>!t.includes(e)).map(e=>e+".js"),i=t.map(e=>e+".js"),o=await this.getCode(miniprogram,{package:exports.FullPkg}),a=Object.keys(o).filter(e=>e.endsWith(".js")&&"app.js"!==e&&!r.includes(e)&&!i.includes(e));return{jsPagesFiles:r,components:i,otherJsFiles:a}}async getWxmlAndWxsFiles(e){let s=await this.getCode(miniprogram,{package:e});if(e!==exports.MainPkg){const e=await this.getCode(miniprogram,{package:exports.MainPkg});s=Object.assign(Object.assign({},s),e)}const t=Object.keys(s).filter(e=>e.endsWith(".wxml")),r=Object.keys(s).filter(e=>e.endsWith(".wxs"));return{wxmlFiles:t,wxsFiles:r,content:t.concat(r).reduce((e,t)=>{const r=s[t];if("error"in r)throw r.error;return e[t]=r.code,e["./"+t]=r.code,e},{})}}async getWxssFiles(e){let s=await this.getCode(miniprogram,{package:e});if(e!==exports.MainPkg){const e=await this.getCode(miniprogram,{package:exports.MainPkg});s=Object.assign(Object.assign({},s),e)}const t=Object.keys(s).filter(e=>e.endsWith(".wxss"));return{wxssFiles:t,content:t.reduce((e,t)=>{const r=s[t];if("error"in r)throw r.error;return e[t]=r.code,e["./"+t]=r.code,e},{})}}getWxssMap(e,s){s=(0,tools_1.normalizePath)(s);for(const[t,r]of this.codeCache.entries())if(t.startsWith("getCode-"+e)){const e=r.codeFiles[s];if(e&&!("error"in e))return e.map}}async getMainPkgSortedJSFiles(){const e=await this.getConf(miniprogram),s=await this.getCode(miniprogram,{package:"__APP__"}),t=Object.keys(s).filter(e=>e.endsWith(".js")),r=[],i=[],o=[],a=[],n=[];let c=!1;const p={},h=s=>Object.keys(e.packages).find(e=>s.startsWith(e))||exports.MainPkg;e.app.functionalPages&&t.forEach(e=>{if(e.startsWith("functional-pages/")){const s=e.replace(/\.js$/,"");if(p[s])return;p[s]=!0,n.push(encodeURI(s))}}),e.app.workers&&t.forEach(s=>{if(s.startsWith(e.app.workers)){const e=s.replace(/\.js$/,"");if(p[e])return;p[e]=!0,a.push(e)}});Object.keys(e.comps).filter(e=>h(e)===exports.MainPkg).forEach(s=>{if((s.startsWith("miniprogram_npm/weui-miniprogram")||s.startsWith("weui-miniprogram"))&&e.app.useExtendedLib&&e.app.useExtendedLib.weui)return;if(p[s])return;p[s]=!0;const t=encodeURI(s);o.push(""+t)});Object.keys(e.pages).filter(e=>h(e)===exports.MainPkg).forEach(e=>{if(p[e])return;p[e]=!0;const s=encodeURI(e);r.push(""+s)}),t.forEach(e=>{const s=e.replace(/\.js$/,"");p[s]||(p[s]=!0,"app.js"!==e?i.push(""+encodeURI(s)):c=!0)});const l=[...i,...o,...r];return c&&l.push("app"),{hasAppJS:c,allFiles:l,pageFiles:r,componentFiles:o,workerFiles:a,functionalPageFiles:n,otherFiles:i}}async getSubPkgSortedJSFiles(e){const s=await this.getConf(miniprogram),t=await this.getCode(miniprogram,{package:e}),r=Object.keys(t).filter(e=>e.endsWith(".js")),i=[],o=[],a={},n=e=>Object.keys(s.packages).find(s=>e.startsWith(s))||exports.MainPkg;Object.keys(s.comps).filter(s=>n(s)===e).forEach(e=>{if((e.startsWith("miniprogram_npm/weui-miniprogram")||e.startsWith("weui-miniprogram"))&&s.app.useExtendedLib&&s.app.useExtendedLib.weui)return;if(a[e])return;a[e]=!0;const t=encodeURI(e);o.push(""+t)});Object.keys(s.pages).filter(s=>n(s)===e).forEach(e=>{if(a[e])return;a[e]=!0;const s=encodeURI(e);i.push(""+s)});const c=r.map(e=>""+encodeURI(e.replace(/\.js$/,"")));return{allFiles:c,pageFiles:i,componentFiles:o,otherFiles:c.filter(e=>!i.includes(e)&&!o.includes(e))}}async compileJS(e,s){let t;if(s.root===e.miniprogramRoot){const e=await this.getConf(miniprogram),r=Object.keys(e.packages).find(e=>s.filePath.startsWith(e))||exports.MainPkg;t=(await this.getCode(miniprogram,{package:r,partialCompilePath:[]}))[s.filePath]}else{t=(await this.getCode(plugin))[s.filePath]}if(!t){const e=new Error(`summer-compiler miss ${s.root} js file, ${s.filePath}`);throw e.code="ENOENT",e}if("error"in t)throw t.error;return Object.assign({filePath:s.filePath,code:t.code,map:t.map},t.jsTag)}async compile(e,s){const t=await this.process.runTask("compile",{},(e,t,r)=>{s.onProgressUpdate({id:e,status:t,message:r})});for(const e of Object.keys(t))"object"==typeof t[e]&&"Buffer"===t[e].type&&(t[e]=Buffer.from(t[e].data));return t}async getPluginJSON(e,s=""){return(await this.getConf(plugin)).plugin}async getPluginPageJSON(e,s){const t=await this.getConf(plugin),r=t.pages[s]||t.comps[s];if(!r)throw new Error("summer-compiler 收集plugin json配置有遗漏, "+s);return r}async getPluginJSFiles(){const e=await this.getCode(plugin);return Object.keys(e).filter(e=>e.endsWith(".js"))}async getPluginComponents(){const e=await this.getConf(plugin),s=new Set(Object.keys(e.pages).concat(Object.keys(e.comps)));return Array.from(s)}async getPluginWxssFiles(){const e=await this.getCode(plugin),s=Object.keys(e).filter(e=>e.endsWith(".wxss"));return{wxssFiles:s,content:s.reduce((s,t)=>{const r=e[t];if("error"in r)throw r.error;return s[t]=r.code,s["./"+t]=r.code,s},{})}}async getPluginWxmlAndWxsFiles(){const e=await this.getCode(plugin),s=Object.keys(e).filter(e=>e.endsWith(".wxml")),t=Object.keys(e).filter(e=>e.endsWith(".wxs"));return{wxmlFiles:s,wxsFiles:t,content:s.concat(t).reduce((s,t)=>{const r=e[t];if("error"in r)throw r.error;return s[t]=r.code,s["./"+t]=r.code,s},{})}}async checkThemeJSON(e,s){return(await this.getConf(miniprogram)).theme}setProxy(e){(0,request_1.setCiProxy)(e)}setLocale(e){this.process.runTask("setLocale",e)}async uglifyFileNames(e,s,t){return await(0,uglifyfilenames_1.uglifyFileNames)(e,s,t)}async getLocalFileList(){return this.process.runTask("getLocalFileList",miniprogram)}async getPluginLocalFileList(){return this.process.runTask("getLocalFileList",plugin)}async packNpm(e){throw new Error("packNpm not implemented")}async packNpmManually(e){throw new Error("packNpmManually not implemented")}async getGameJSON(e){throw new Error("getGameJSON not implemented")}}exports.SummerCompiler=SummerCompiler;
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SummerCompiler=exports.FullPkg=exports.MainPkg=void 0;const tslib_1=require("tslib"),child_process_1=require("child_process"),request_1=require("../utils/request"),path_1=(0,tslib_1.__importDefault)(require("path")),lodash_1=(0,tslib_1.__importDefault)(require("lodash")),recorder_1=require("./recorder"),tools_1=require("../utils/tools"),uglifyfilenames_1=require("../core/protect/uglifyfilenames"),error_1=require("./error"),miniprogram="miniprogram",plugin="plugin";function performanceMark(e,s){console.warn(`[summer-compiler] [${(0,recorder_1.getPrintTime)()}] [${Math.floor(performance.now())}ms elapsed] ${e}${s?" end":""}`)}exports.MainPkg="__APP__",exports.FullPkg="__FULL__";class SummerCompilerProcess{constructor(e,s){this.projectPath=e,this.cachePath=s,this.taskMap=new Map,this.taskId=0,this.initedPromise=new Promise((e,s)=>{this.initedResolve=e,this.initedReject=s})}async init(e,s,t){this.process=this.forkProcess();const r={type:"init",data:Object.assign({projectPath:this.projectPath,cachePath:this.cachePath,files:s,dirs:t},e)};performanceMark("process init"),this.sendProcessMessage(r),performanceMark("process init",!0),await this.initedPromise}destroy(){this.process.kill("SIGTERM")}sendProcessMessage(e){this.process.send(e)}forkProcess(){const e=path_1.default.posix.join(__dirname,"./entry_process.js"),s={stdio:["pipe","pipe","pipe","ipc"],cwd:this.projectPath,env:Object.assign(Object.assign({},process.env),{cpprocessEnv:"childprocess",summerProcess:"1"})};if(s.env.isDevtools=process.__nwjs&&"wechatwebdevtools"===nw.App.manifest.appname,s.env.isDevtools){let e=path_1.default.join(path_1.default.dirname(process.execPath),"node");"darwin"!==process.platform&&(e+=".exe"),s.execPath=e}performanceMark("fork process");const t=(0,child_process_1.fork)(e,["--expose-gc"],s);return t.stdout.setEncoding("utf8"),t.stdout.on("data",e=>{}),t.stderr.on("data",e=>{console.error("child process stderr: "+e)}),t.on("exit",e=>{console.error(`child process exit: code(${e})`),0!==e&&this.initedReject(new Error(`summer child process exit: code(${e})`))}),t.on("message",this.onChildProcessMessage.bind(this)),t.unref(),t}onChildProcessMessage(e){if("ready"===e.type)return performanceMark("process ready"),void this.initedResolve(!0);if("progress"===e.type){const s=this.taskMap.get(e.taskId);(null==s?void 0:s.progressUpdate)&&s.progressUpdate(e.id,e.status,e.message)}else if("response"===e.type){const{id:s,data:t,error:r}=e;if(r){const e=new error_1.SummerError(r);this.onResponse(s,void 0,e)}else this.onResponse(s,t,void 0)}}onResponse(e,s,t){const r=this.taskMap.get(e);this.taskMap.delete(e),r?t?r.reject(t):r.resolve(s):console.error(`child process task: ${e} not found`)}async sendEvent(e,s){await this.initedPromise,this.sendProcessMessage({type:"event",name:e,data:s})}async runTask(e,s,t){await this.initedPromise;return new Promise((r,i)=>{const o={name:e,data:s,resolve:r,reject:i,progressUpdate:t};this.taskId=this.taskId+1,this.taskMap.set(this.taskId,o),this.sendProcessMessage({type:"request",id:this.taskId,name:e,data:s})})}}class MessageHub{constructor(e){this.devtoolMessagehub=e,this.showing=new Set}showStatus(e,s){this.showing.add(e),this.devtoolMessagehub.showStatus(e,s)}hideStatus(e){this.showing.delete(e),this.devtoolMessagehub.hideStatus(e)}clear(){for(const e of this.showing.values())this.hideStatus(e);this.showing.clear()}}class SummerCompiler{constructor(e,s,t,r){this.projectPath=e,this.cachePath=s,this.options=t,this.devtoolMessagehub=r,this.isSummer=!0,this.codeCache=new Map,this.promiseCache=new Map,this.status=void 0,this.onProgressUpdate=(e,s,t)=>{"doing"===s?this.messageHub.showStatus(e,t):this.messageHub.hideStatus(e)},this.projectPath=(0,tools_1.normalizePath)(this.projectPath),performanceMark("create summer compiler"),this.messageHub=new MessageHub(r),this.process=new SummerCompilerProcess(this.projectPath,this.cachePath)}async init(e,s,t){performanceMark("init summer compiler"),await this.process.init(this.options,e,s),await this.loadStatus(),performanceMark("init summer compiler",!0)}async loadStatus(){var e;this.status=await(null===(e=this.process)||void 0===e?void 0:e.runTask("loadStatus"))}destroy(){this.process.destroy(),this.messageHub.clear()}async clearCache(){var e;await(null===(e=this.process)||void 0===e?void 0:e.runTask("clearCache")),this.codeCache.clear(),this.promiseCache.clear()}updateOptions(e){var s;lodash_1.default.isEqual(e,this.options)||(this.options=e,this.promiseCache.clear(),this.codeCache.clear(),null===(s=this.process)||void 0===s||s.sendEvent("updateOptions",e),this.loadStatus())}fileChange(e,s){if("change"!==e||s.endsWith(".json"))for(const e of this.promiseCache.keys())e.startsWith("getConf-")&&this.promiseCache.delete(e);this.invalidCodeCache(),this.process.sendEvent("fileChange",{type:e,targetPath:s})}invalidCodeCache(){for(const e of this.codeCache.values())e.isValid=!1}async getConf(e){const s="getConf-"+e;if(this.promiseCache.has(s))return console.log(s,"hit cache"),this.promiseCache.get(s);{console.log(s,"do request"),performanceMark("request get conf");const t={graphId:e},r=this.process.runTask("getConf",t,this.onProgressUpdate);return this.promiseCache.set(s,r),performanceMark("request get conf",!0),r}}async getCode(e,s){const t=`getCode-${e}${s?"-"+s.package:""}`;if(this.promiseCache.has(t))return console.log(t,"hit promise cache"),this.promiseCache.get(t);{const r=this.codeCache.get(t);if(null==r?void 0:r.isValid)return r.codeFiles;console.log(t,"do request");const i={};if(r){const e=r.codeFiles;for(const s of Object.keys(e)){const t=e[s];"error"in t||(i[s]=t.md5)}}const o={graphId:e,cacheMd5:i,package:null==s?void 0:s.package};performanceMark("request get code");const a=Date.now();console.time("[summer-compiler] runTask "+t),console.log(`[summer-compiler] [${(0,recorder_1.getPrintTime)()}] runTask ${t}`);const n=this.process.runTask("getCode",o,this.onProgressUpdate).then(e=>{var s;console.timeEnd("[summer-compiler] runTask "+t);const r=(null===(s=this.codeCache.get(t))||void 0===s?void 0:s.codeFiles)||{};for(const s of Object.keys(e)){const t=e[s];"error"in t||""!==t.md5?r[s]=t:delete r[s]}return this.codeCache.set(t,{isValid:!0,codeFiles:r}),r},e=>{throw e.code?console.error(e):console.error("Unexpected error when getCode",e),this.messageHub.clear(),e});return n.finally(()=>{performanceMark("request get code",!0),console.log(`[summer-compiler] [${(0,recorder_1.getPrintTime)()}] [cost ${Date.now()-a}ms] runTask ${t}`),this.promiseCache.delete(t)}),this.promiseCache.set(t,n),n}}async ready(){return this.process.initedPromise}async getAppJSON(e,s){return(await this.getConf(miniprogram)).app}async getPageJSON(e,s){const t=await this.getConf(miniprogram),r=t.pages[s]||t.comps[s];if(!r)throw new Error("summer-compiler 收集json配置有遗漏, "+s);return r}async getAllPageAndComponentJSON(){const e=await this.getConf(miniprogram);return Object.keys(e.pages).concat(Object.keys(e.comps))}async getAllSortedJSFiles(){const e=await this.getConf(miniprogram),s=Object.keys(e.pages),t=Object.keys(e.comps),r=s.filter(e=>!t.includes(e)).map(e=>e+".js"),i=t.map(e=>e+".js"),o=await this.getCode(miniprogram,{package:exports.FullPkg}),a=Object.keys(o).filter(e=>e.endsWith(".js")&&"app.js"!==e&&!r.includes(e)&&!i.includes(e));return{jsPagesFiles:r,components:i,otherJsFiles:a}}async getWxmlAndWxsFiles(e){let s=await this.getCode(miniprogram,{package:e});if(e!==exports.MainPkg){const e=await this.getCode(miniprogram,{package:exports.MainPkg});s=Object.assign(Object.assign({},s),e)}const t=Object.keys(s).filter(e=>e.endsWith(".wxml")),r=Object.keys(s).filter(e=>e.endsWith(".wxs"));return{wxmlFiles:t,wxsFiles:r,content:t.concat(r).reduce((e,t)=>{const r=s[t];if("error"in r)throw r.error;return e[t]=r.code,e["./"+t]=r.code,e},{})}}async getWxssFiles(e){let s=await this.getCode(miniprogram,{package:e});if(e!==exports.MainPkg){const e=await this.getCode(miniprogram,{package:exports.MainPkg});s=Object.assign(Object.assign({},s),e)}const t=Object.keys(s).filter(e=>e.endsWith(".wxss"));return{wxssFiles:t,content:t.reduce((e,t)=>{const r=s[t];if("error"in r)throw r.error;return e[t]=r.code,e["./"+t]=r.code,e},{})}}getWxssMap(e,s){s=(0,tools_1.normalizePath)(s);for(const[t,r]of this.codeCache.entries())if(t.startsWith("getCode-"+e)){const e=r.codeFiles[s];if(e&&!("error"in e))return e.map}}async getMainPkgSortedJSFiles(){const e=await this.getConf(miniprogram),s=await this.getCode(miniprogram,{package:"__APP__"}),t=Object.keys(s).filter(e=>e.endsWith(".js")),r=[],i=[],o=[],a=[],n=[];let c=!1;const p={},h=s=>Object.keys(e.packages).find(e=>s.startsWith(e))||exports.MainPkg;e.app.functionalPages&&t.forEach(e=>{if(e.startsWith("functional-pages/")){const s=e.replace(/\.js$/,"");if(p[s])return;p[s]=!0,n.push(encodeURI(s))}}),e.app.workers&&t.forEach(s=>{if(s.startsWith(e.app.workers)){const e=s.replace(/\.js$/,"");if(p[e])return;p[e]=!0,a.push(e)}});Object.keys(e.comps).filter(e=>h(e)===exports.MainPkg).forEach(s=>{if((s.startsWith("miniprogram_npm/weui-miniprogram")||s.startsWith("weui-miniprogram"))&&e.app.useExtendedLib&&e.app.useExtendedLib.weui)return;if(p[s])return;p[s]=!0;const t=encodeURI(s);o.push(""+t)});Object.keys(e.pages).filter(e=>h(e)===exports.MainPkg).forEach(e=>{if(p[e])return;p[e]=!0;const s=encodeURI(e);r.push(""+s)}),t.forEach(e=>{const s=e.replace(/\.js$/,"");p[s]||(p[s]=!0,"app.js"!==e?i.push(""+encodeURI(s)):c=!0)});const l=[...i,...o,...r];return c&&l.push("app"),{hasAppJS:c,allFiles:l,pageFiles:r,componentFiles:o,workerFiles:a,functionalPageFiles:n,otherFiles:i}}async getSubPkgSortedJSFiles(e){const s=await this.getConf(miniprogram),t=await this.getCode(miniprogram,{package:e}),r=Object.keys(t).filter(e=>e.endsWith(".js")),i=[],o=[],a={},n=e=>Object.keys(s.packages).find(s=>e.startsWith(s))||exports.MainPkg;Object.keys(s.comps).filter(s=>n(s)===e).forEach(e=>{if((e.startsWith("miniprogram_npm/weui-miniprogram")||e.startsWith("weui-miniprogram"))&&s.app.useExtendedLib&&s.app.useExtendedLib.weui)return;if(a[e])return;a[e]=!0;const t=encodeURI(e);o.push(""+t)});Object.keys(s.pages).filter(s=>n(s)===e).forEach(e=>{if(a[e])return;a[e]=!0;const s=encodeURI(e);i.push(""+s)});const c=r.map(e=>""+encodeURI(e.replace(/\.js$/,"")));return{allFiles:c,pageFiles:i,componentFiles:o,otherFiles:c.filter(e=>!i.includes(e)&&!o.includes(e))}}async compileJS(e,s){let t;if(s.root===e.miniprogramRoot){const e=await this.getConf(miniprogram),r=Object.keys(e.packages).find(e=>s.filePath.startsWith(e))||exports.MainPkg;t=(await this.getCode(miniprogram,{package:r,partialCompilePath:[]}))[s.filePath]}else{t=(await this.getCode(plugin))[s.filePath]}if(!t){const e=new Error(`summer-compiler miss ${s.root} js file, ${s.filePath}`);throw e.code="ENOENT",e}if("error"in t)throw t.error;return Object.assign({filePath:s.filePath,code:t.code,map:t.map},t.jsTag)}async compile(e,s){const t=await this.process.runTask("compile",{},(e,t,r)=>{s.onProgressUpdate({id:e,status:t,message:r})});for(const e of Object.keys(t))"object"==typeof t[e]&&"Buffer"===t[e].type&&(t[e]=Buffer.from(t[e].data));return t}async getPluginJSON(e,s=""){return(await this.getConf(plugin)).plugin}async getPluginPageJSON(e,s){const t=await this.getConf(plugin),r=t.pages[s]||t.comps[s];if(!r)throw new Error("summer-compiler 收集plugin json配置有遗漏, "+s);return r}async getPluginJSFiles(){const e=await this.getCode(plugin);return Object.keys(e).filter(e=>e.endsWith(".js"))}async getPluginComponents(){const e=await this.getConf(plugin),s=new Set(Object.keys(e.pages).concat(Object.keys(e.comps)));return Array.from(s)}async getPluginWxssFiles(){const e=await this.getCode(plugin),s=Object.keys(e).filter(e=>e.endsWith(".wxss"));return{wxssFiles:s,content:s.reduce((s,t)=>{const r=e[t];if("error"in r)throw r.error;return s[t]=r.code,s["./"+t]=r.code,s},{})}}async getPluginWxmlAndWxsFiles(){const e=await this.getCode(plugin),s=Object.keys(e).filter(e=>e.endsWith(".wxml")),t=Object.keys(e).filter(e=>e.endsWith(".wxs"));return{wxmlFiles:s,wxsFiles:t,content:s.concat(t).reduce((s,t)=>{const r=e[t];if("error"in r)throw r.error;return s[t]=r.code,s["./"+t]=r.code,s},{})}}async checkThemeJSON(e,s){return(await this.getConf(miniprogram)).theme}setProxy(e){(0,request_1.setCiProxy)(e)}setLocale(e){this.process.runTask("setLocale",e)}async uglifyFileNames(e,s,t){return await(0,uglifyfilenames_1.uglifyFileNames)(e,s,t)}async getLocalFileList(){return this.process.runTask("getLocalFileList",miniprogram)}async getPluginLocalFileList(){return this.process.runTask("getLocalFileList",plugin)}async packNpm(e){throw new Error("packNpm not implemented")}async packNpmManually(e){throw new Error("packNpmManually not implemented")}async getGameJSON(e){throw new Error("getGameJSON not implemented")}}exports.SummerCompiler=SummerCompiler;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppConf=exports.resolvePath=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),core_1=require("../../core"),common_1=require("../../core/json/common"),locales_1=(0,tslib_1.__importDefault)(require("../../utils/locales/locales"));function resolvePath(t,o){const e=path_1.default.posix.dirname(t);let s=null;return s=o.startsWith("/")?o.replace(/^\//,""):path_1.default.posix.join(e,o),s}exports.resolvePath=resolvePath;class AppConf{constructor(t,o){this.graph=o,this.packages=new Map,this.pages=new Map,this.comps=new Map,this.onFileChange=(t,o)=>{},this.proxyProject=t.proxyProject,this.proxyProject.addResolver(o.resolver)}destroy(){this.proxyProject.removeResolver(this.graph.resolver)}async build(t){this.resetState(),await this.loadApp(t)}async resetState(){this.app=void 0,this.packages.clear(),this.pages.clear(),this.comps.clear(),this.sitemap=void 0,this.theme=void 0}async loadApp(t){const o=await t.run(locales_1.default.config.SUMMER_COMPILE.format("app.json"),()=>(0,core_1.getAppJSON)(this.proxyProject));this.app=o;const e=new Set;for(const t of o.pages)e.add(t);const s=o.subPackages||[];for(const t of s){const o=t.root;this.packages.set(o,t);for(const s of t.pages)e.add(path_1.default.posix.join(o,s))}await t.run(locales_1.default.config.SUMMER_COMPILE_PAGE_JSON.format(e.size),async()=>{var t;for(const[t]of e.entries())await this.loadPage(t);for(const t of Object.values(o.usingComponents||{})){const o=resolvePath("app.json",t);await this.loadComp(o,t,"app.json")}if(null===(t=o.tabBar)||void 0===t?void 0:t.custom){const t=resolvePath("app.json","custom-tab-bar/index");await this.loadComp(t,"custom-tab-bar/index","app.json")}}),o.themeLocation&&await t.run(locales_1.default.config.SUMMER_COMPILE.format(o.themeLocation),()=>this.loadTheme(o.themeLocation))
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppConf=exports.resolvePath=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),core_1=require("../../core"),common_1=require("../../core/json/common"),locales_1=(0,tslib_1.__importDefault)(require("../../utils/locales/locales"));function resolvePath(t,o){const e=path_1.default.posix.dirname(t);let s=null;return s=o.startsWith("/")?o.replace(/^\//,""):path_1.default.posix.join(e,o),s}exports.resolvePath=resolvePath;class AppConf{constructor(t,o){this.graph=o,this.packages=new Map,this.pages=new Map,this.comps=new Map,this.onFileChange=(t,o)=>{},this.proxyProject=t.proxyProject,this.proxyProject.addResolver(o.resolver)}destroy(){this.proxyProject.removeResolver(this.graph.resolver)}async build(t){this.resetState(),await this.loadApp(t)}async resetState(){this.app=void 0,this.packages.clear(),this.pages.clear(),this.comps.clear(),this.sitemap=void 0,this.theme=void 0}async loadApp(t){const o=await t.run(locales_1.default.config.SUMMER_COMPILE.format("app.json"),()=>(0,core_1.getAppJSON)(this.proxyProject));this.app=o;const e=new Set;for(const t of o.pages)e.add(t);const s=o.subPackages||[];for(const t of s){const o=t.root;this.packages.set(o,t);for(const s of t.pages)e.add(path_1.default.posix.join(o,s))}await t.run(locales_1.default.config.SUMMER_COMPILE_PAGE_JSON.format(e.size),async()=>{var t;for(const[t]of e.entries())await this.loadPage(t);for(const t of Object.values(o.usingComponents||{})){const o=resolvePath("app.json",t);await this.loadComp(o,t,"app.json")}if(null===(t=o.tabBar)||void 0===t?void 0:t.custom){const t=resolvePath("app.json","custom-tab-bar/index");await this.loadComp(t,"custom-tab-bar/index","app.json")}}),o.themeLocation&&await t.run(locales_1.default.config.SUMMER_COMPILE.format(o.themeLocation),()=>this.loadTheme(o.themeLocation))}async loadPage(t){if(t.startsWith("plugin://")||t.startsWith("plugin-private://"))return;const o=await(0,core_1.getPageJSON)(this.proxyProject,{miniprogramRoot:this.graph.root,pagePath:t});this.pages.set(t,o);const e=async o=>{if(o.startsWith("plugin://")||o.startsWith("plugin-private://"))return;const e=resolvePath(t,o);await this.loadComp(e,o,t)};if(o.usingComponents)for(const t of Object.values(o.usingComponents))await e(t);if(o.componentGenerics)for(const t of Object.values(o.componentGenerics)){const o=t.default;o&&await e(o)}}async loadComp(t,o,e){if(await this.isExtendedLibComp(t,e))return;if(this.comps.has(t))return;if(!this.proxyProject.stat(this.graph.root,t+".json"))throw new Error(`[summer-compiler] Couldn't found the '${o}.json' file relative to '${e}.json'`);const s=await(0,core_1.getPageJSON)(this.proxyProject,{miniprogramRoot:this.graph.root,pagePath:t});this.comps.set(t,s);const a=async o=>{if(o.startsWith("plugin://")||o.startsWith("plugin-private://"))return;const e=resolvePath(t,o);await this.loadComp(e,o,t)};if(s.usingComponents)for(const t of Object.values(s.usingComponents))await a(t);if(s.componentGenerics)for(const t of Object.values(s.componentGenerics)){const o=t.default;o&&await a(o)}}async loadTheme(t){const o=await(0,core_1.checkThemeJSON)(this.proxyProject,{themeLocation:t});this.theme=o}async isExtendedLibComp(t,o){if(t.startsWith("miniprogram_npm/")){const e=(0,common_1.getUseExtendLib)(this.proxyProject,o);if(e.length>0){const o=e.map(t=>"miniprogram_npm/"+t);for(const e of o)if(t.startsWith(e))return!0}}return!1}}exports.AppConf=AppConf;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PluginConf=exports.resolvePath=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),core_1=require("../../core"),locales_1=(0,tslib_1.__importDefault)(require("../../utils/locales/locales"));function resolvePath(t,o){const e=path_1.default.posix.dirname(t);let s=null;return s=o.startsWith("/")?o.replace(/^\//,""):path_1.default.posix.join(e,o),s}exports.resolvePath=resolvePath;class PluginConf{constructor(t,o){this.graph=o,this.pages=new Map,this.comps=new Map,this.proxyProject=t.proxyProject,this.proxyProject.addResolver(o.resolver)}destroy(){this.proxyProject.removeResolver(this.graph.resolver)}async build(t){this.resetState(),await this.loadPlugin(t)}async resetState(){this.plugin=void 0,this.pages.clear(),this.comps.clear()}async loadPlugin(t){const o=await t.run(locales_1.default.config.SUMMER_COMPILE.format("plugin.json"),()=>(0,core_1.getPluginJSON)(this.proxyProject));this.plugin=o;const e=new Set;for(const t of Object.values(o.pages))e.add(t);await t.run(locales_1.default.config.SUMMER_COMPILE_PLUGIN_PAGE_JSON.format(e.size),async()=>{for(const[t]of e.entries())await this.loadPage(t);for(const t of Object.values(o.publicComponents||{}))await this.loadComp(t);for(const t of Object.values(o.usingComponents||{}))await this.loadComp(t)})}async loadPage(t){const o=await(0,core_1.getPluginPageJSON)({project:this.proxyProject,root:this.graph.root,filePath:path_1.default.posix.join(this.graph.root,t+".json")});this.pages.set(t,o);for(const e of Object.values(o.usingComponents||{})){const o=resolvePath(t,e);await this.loadComp(o)}}async loadComp(t){if(this.comps.has(t))return;const o=await(0,core_1.getPluginPageJSON)({project:this.proxyProject,root:this.graph.root,filePath:path_1.default.posix.join(this.graph.root,t+".json")});this.comps.set(t,o);for(const e of Object.values(o.usingComponents||{})){const o=resolvePath(t,e);await this.loadComp(o)}}}exports.PluginConf=PluginConf;
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PluginConf=exports.resolvePath=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),core_1=require("../../core"),locales_1=(0,tslib_1.__importDefault)(require("../../utils/locales/locales"));function resolvePath(t,o){const e=path_1.default.posix.dirname(t);let s=null;return s=o.startsWith("/")?o.replace(/^\//,""):path_1.default.posix.join(e,o),s}exports.resolvePath=resolvePath;class PluginConf{constructor(t,o){this.graph=o,this.pages=new Map,this.comps=new Map,this.proxyProject=t.proxyProject,this.proxyProject.addResolver(o.resolver)}destroy(){this.proxyProject.removeResolver(this.graph.resolver)}async build(t){this.resetState(),await this.loadPlugin(t)}async resetState(){this.plugin=void 0,this.pages.clear(),this.comps.clear()}async loadPlugin(t){const o=await t.run(locales_1.default.config.SUMMER_COMPILE.format("plugin.json"),()=>(0,core_1.getPluginJSON)(this.proxyProject));this.plugin=o;const e=new Set;for(const t of Object.values(o.pages||{}))e.add(t);await t.run(locales_1.default.config.SUMMER_COMPILE_PLUGIN_PAGE_JSON.format(e.size),async()=>{for(const[t]of e.entries())await this.loadPage(t);for(const t of Object.values(o.publicComponents||{}))await this.loadComp(t);for(const t of Object.values(o.usingComponents||{}))await this.loadComp(t)})}async loadPage(t){const o=await(0,core_1.getPluginPageJSON)({project:this.proxyProject,root:this.graph.root,filePath:path_1.default.posix.join(this.graph.root,t+".json")});this.pages.set(t,o);for(const e of Object.values(o.usingComponents||{})){const o=resolvePath(t,e);await this.loadComp(o)}}async loadComp(t){if(this.comps.has(t))return;const o=await(0,core_1.getPluginPageJSON)({project:this.proxyProject,root:this.graph.root,filePath:path_1.default.posix.join(this.graph.root,t+".json")});this.comps.set(t,o);for(const e of Object.values(o.usingComponents||{})){const o=resolvePath(t,e);await this.loadComp(o)}}}exports.PluginConf=PluginConf;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
package/dist/utils/locales/en.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const fomatable_string_1=require("./fomatable_string"),config={GENERATE_LOCAL_SIGNATURE_FAIL:"generate local signature fail. Usually this happens the content or encoding of private key file is incorrect. Detail: %s",PARAM_ERROR:'function: "%s" lack of parameter: "%s"',SHOULD_NOT_BE_EMPTY:"%s should not be empty",JSON_CONTENT_SHOULD_BE:"%s field needs to be %s",SHOULD_MATCH:"%s should match %s",SHOULD_EQUAL:"%s should equal to %s",SHOULD_AT_LEAST_ONE_ITEM:"%s should have at least on item",OR:"Or",CORRESPONDING_FILE_NOT_FOUND:'%s could not find the corresponding file: "%s"',JSON_SHOULD_NOT_CONTAIN:"%s should not contain %s",JSON_SHOULD_NOT_START_WITH:"%s should not begin with '%s'",NOT_FOUND:"%s not found",NOT_FOUND_IN_ROOT_DIR:"%s is not found in the project root directory",MINIPROGRAM_APP_JSON_NOT_FOUND:
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const fomatable_string_1=require("./fomatable_string"),config={GENERATE_LOCAL_SIGNATURE_FAIL:"generate local signature fail. Usually this happens the content or encoding of private key file is incorrect. Detail: %s",PARAM_ERROR:'function: "%s" lack of parameter: "%s"',SHOULD_NOT_BE_EMPTY:"%s should not be empty",JSON_CONTENT_SHOULD_BE:"%s field needs to be %s",SHOULD_MATCH:"%s should match %s",SHOULD_EQUAL:"%s should equal to %s",SHOULD_AT_LEAST_ONE_ITEM:"%s should have at least on item",OR:"Or",CORRESPONDING_FILE_NOT_FOUND:'%s could not find the corresponding file: "%s"',JSON_SHOULD_NOT_CONTAIN:"%s should not contain %s",JSON_SHOULD_NOT_START_WITH:"%s should not begin with '%s'",NOT_FOUND:"%s not found",NOT_FOUND_IN_ROOT_DIR:"%s is not found in the project root directory",MINIPROGRAM_APP_JSON_NOT_FOUND:'In the directory %s specified by "miniprogramRoot" in project.config.json, %s is not found in that directory.If you don\'t know what "miniprogramRoot" means for, just leave it as empty string.',PLUGIN_JSON_NOT_FOUND:"In the miniprogram local development plug-in directory %s specified by pluginRoot in project.config.json, %s is not found",PLUGIN_PATH_SAME_WITH_MINIPROGRAM:"The plugin directory %s specified by pluginRoot in project.config.json is the same as the miniprogram directory %s, please modify it to a different directory",CONTENT_EXIST:"%s already exists",FILE_NOT_FOUND:'"%s" file not found, or the file read failed',JSON_PARSE_ERROR:"%s File parsing error",ENTRANCE_NOT_FOUND:"No pages : %s defined in the entry page \napp.json is found",JSON_PAGE_FILE_NOT_EXISTS:'%s %s "%s" could not find the corresponding %s file',SHOULD_NOT_IN:"%s Should not exist in %s",JSON_CUSTOM_COMPILE_PATH_NOT_EXISTS_TITLE:"app.json or custom compilation condition error",JSON_CUSTOM_COMPILE_PATH_NOT_EXISTS:"The startup page %s specified in the custom compilation is not defined in app.json",JSON_ENTRY_PAGE_PATH_NOT_FOUND:"No entry page defined in %s is found in %s",JSON_TABBAR_AT_LEAST:'["tabBar"]["list"] must contain at least %s items',JSON_TABBAR_AT_MOST:'["tabBar"]["list"] cannot contain more than %s items',JSON_TABBAR_PATH_EMPTY:'["tabBar"]["list"][%s]["pagePath"] cannot be empty',JSON_TABBAR_PATH_SAME_WITH_OTHER:'["tabBar"]["list"][%s]["pagePath"] is same with ["tabBar"]["list"][%s]["pagePath"]',JSON_TABBAR_ICON_MAX_SIZE:'The size of ["tabBar"]["list"][%s]["%s"] exceeds %skb',JSON_TABBAR_ICON_EXT:'["tabBar"]["list"][%s]["%s"] Wrong file format, only %s format is supported',EXT_SHOULD_BE_ERROR:'extension name of %s should be "%s"',JSON_CONTENT_SHOULD_NOT_BE:"%s cannot be %s",JSON_RESOLVE_ALIAS_ILLEGAL:'Invalid %s or %s in resolveAlias field, contains consecutive "//"',JSON_RESOLVE_ALIAS_INCLUDE_STAR:'The key "%s" or value "%s" in resolveAlias field should end with "/*"',JSON_RESOLVE_ALIAS_SHOULD_NOT_START_WITH:'The value "%s" in resolveAlias field should not start with "./"',APP_JSON_SHOULD_SET_LAZYCODELOADING:'You need to add "lazyCodeLoading": "requiredComponents" in app.json, because the value of "renderer" in %s is "skyline"',PAGE_JSON_SHOULD_SET_DISABLESCROLL_TRUE:'According to the configuration of the page or app.json, the value of "renderer" in %s page is "skyline", you need to add "disableScroll": true in the page configuration',PAGE_JSON_SHOULD_SET_NAVIGATIONSTYLE_CUSTOM:'According to the configuration of the page or app.json, the value of "renderer" in %s page is "skyline", you need to add "navigationStyle": custom in the page configuration',JSON_CONTENT_EXISTED:"%s already exists",JSON_CONTENT_NOT_FOUND:"%s does not exist",LACK_OF_FILE:"File %s is missing",JSON_PAGES_REPEAT:"%s is repeated in %s",JSON_CONTENT_REPEAT:"%s could not be declared both in %s",EXT_JSON_INVALID:'%s is not a 3rdMiniProgramAppid, ext.json cannot take effect;Read the documentation: "%s"',GAME_EXT_JSON_INVALID:"%s is not a 3rdMiniGameAppid, ext.json cannot take effect;",EXT_APPID_SHOULD_NOT_BE_EMPTY:"extAppid should not be empty",FILE_NOT_UTF8:"%s file is not in UTF-8 encoding",INVALID:"invalid %s",DIRECTORY:"Directory",EXCEED_LIMIT:"%s exceed limit %s",PLEASE_CHOOSE_PLUGIN_MODE:"If you are developing a plugin, choose the plugin mode",TRIPLE_NUMBER_DOT:"number.number.number",PAGE_PATH:"Page Path",PLUGINS_SAME_ALIAS:"%s and %s have same alias",SAME_ITEM:'%s and %s have same "%s"',ALREADY_EXISTS:"already exists",SAME_KEY_PAGE_PUBLICCOMPONENTS:'There can not be the same key: %s in ["pages"] and ["publicComponents"]',GAME_DEV_PLUGIN_SHOULD_NOT_USE_LOCAL_PATH:"Dev plugin: %s shall never specify a local path",GAME_PLUGIN_SIGNATURE_MD5_NOT_MATCH_CONTENT:'MD5 hash of the plugin library file "%s": "%s" not matching the value "%s" given by its signature.json, thus the compiling process has been interrupted.\nThis indicates you might have changed the content of the file.\nRestore the original content of this file may help solve the issue and remove this warning.\n\nTo learn more, you may refer to the documentation.\n',FILE:"FILE",PROCESSING:"processing: %s",DONE:"done: %s",UPLOAD:"upload",SUCCESS:"success",PROJECT_TYPE_ERROR:"project.type is %s, but appid(%s) is %s",MINI_PROGRAM:"MiniProgram",MINI_GAME:"MiniGame",NOT_ALLOWED_REQUIRE_VAR:"Require variable is not allowed",NOT_ALLOWED_REQUIRE_ASSIGN:"Assigning the require function to other variables is not allowed",NOT_FOUND_NPM_ENTRY:"Npm package entry file not found",NOT_FOUND_NODE_MODULES:"NPM packages not found. Please confirm npm packages which need to build are belong to `miniprogramRoot` directory. Or you may edit project.config.json's `packNpmManually` and `packNpmRelationList`",JSON_ENTRANCE_DECLARE_PATH_ERR:'["entranceDeclare"]["locationMessage"]["path"] "%s" should belong to pages or pages in sub packages',JSON_ENTRANCE_DECLARE_PATH_EMPTY:'["entranceDeclare"]["locationMessage"]["path"] should not be empty',JSON_REQUIRED_PRIVATE_INFOS_MUTUALLY_EXCLUSIVE:"requiredPrivateInfos %s is is mutually exclusive with %s.",COULD_NOT_USE_CODE_PROTECT:"Code protect is not available",SUMMER_COMPILING_MODULE:"Compiling %s",SUMMER_COMPILE_JSON:"Compile jSON files",SUMMER_OPTIMIZE_CODE:"Optimize code",SUMMER_PACK_FILES:"Pack resource file",SUMMER_COMPRESS_PACK:"Compress code package",SUMMER_SEAL_PACK:"Seal code package",SUMMER_APPEND_BABEL_HELPERS:"Append babel helper files",SUMMER_COMPILE_PAGE_JSON:"Compile json files of %s pages",SUMMER_COMPILE_PLUGIN_PAGE_JSON:"Compiling json files of %s plugin pages",SUMMER_COMPILE:"Compile %s",SUMMER_COMPILE_MINIPROGRAM:"Compile miniprogram",SUMMER_COMPILE_PLUGIN:"Compile plugin"},formatConfig={};for(const[e,o]of Object.entries(config))formatConfig[e]=new fomatable_string_1.FormatableString(o);exports.default=formatConfig;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
package/dist/utils/locales/zh.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const fomatable_string_1=require("./fomatable_string"),config={GENERATE_LOCAL_SIGNATURE_FAIL:"生成本地签名失败。通常是key文件编码或者内容有误。错误详情: %s",PARAM_ERROR:'方法:"%s" 缺少参数:"%s"',SHOULD_NOT_BE_EMPTY:"%s 不能为空",JSON_CONTENT_SHOULD_BE:"%s 字段需为 %s",SHOULD_AT_LEAST_ONE_ITEM:"%s 需至少存在一项",SHOULD_MATCH:"%s 需与 %s 匹配",SHOULD_EQUAL:"%s 需等于 %s",EXT_SHOULD_BE_ERROR:'%s 的拓展名需为 "%s"',OR:"或",CORRESPONDING_FILE_NOT_FOUND:"未找到 %s 对应的 %s 文件",JSON_SHOULD_NOT_START_WITH:"%s 不应该以 '%s' 开头",JSON_SHOULD_NOT_CONTAIN:"%s 不应该包含 %s",NOT_FOUND:"%s 未找到",NOT_FOUND_IN_ROOT_DIR:"在项目根目录未找到 %s ",MINIPROGRAM_APP_JSON_NOT_FOUND:"根据 project.config.json 中 miniprogramRoot 指定的小程序目录 %s
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const fomatable_string_1=require("./fomatable_string"),config={GENERATE_LOCAL_SIGNATURE_FAIL:"生成本地签名失败。通常是key文件编码或者内容有误。错误详情: %s",PARAM_ERROR:'方法:"%s" 缺少参数:"%s"',SHOULD_NOT_BE_EMPTY:"%s 不能为空",JSON_CONTENT_SHOULD_BE:"%s 字段需为 %s",SHOULD_AT_LEAST_ONE_ITEM:"%s 需至少存在一项",SHOULD_MATCH:"%s 需与 %s 匹配",SHOULD_EQUAL:"%s 需等于 %s",EXT_SHOULD_BE_ERROR:'%s 的拓展名需为 "%s"',OR:"或",CORRESPONDING_FILE_NOT_FOUND:"未找到 %s 对应的 %s 文件",JSON_SHOULD_NOT_START_WITH:"%s 不应该以 '%s' 开头",JSON_SHOULD_NOT_CONTAIN:"%s 不应该包含 %s",NOT_FOUND:"%s 未找到",NOT_FOUND_IN_ROOT_DIR:"在项目根目录未找到 %s ",MINIPROGRAM_APP_JSON_NOT_FOUND:"根据 project.config.json 中 miniprogramRoot 指定的小程序目录 %s,在该目录下未找到 %s。\n如果你不理解 miniprogramRoot 字段的含义,请在 project.config.json 中将 miniprogramRoot 设为空字符串。\n详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",PLUGIN_JSON_NOT_FOUND:"根据 project.config.json 中 pluginRoot 指定的小程序本地开发插件目录 %s,%s 未找到",PLUGIN_PATH_SAME_WITH_MINIPROGRAM:"project.config.json 中 pluginRoot 指定的小程序本地开发插件目录 %s,与小程序目录 %s 相同,请修改为不同目录",FILE_NOT_FOUND:"未找到 %s 文件,或者文件读取失败",JSON_PARSE_ERROR:"%s 文件解析错误",ENTRANCE_NOT_FOUND:"未找到入口页面\napp.json 中定义的 pages : %s",JSON_PAGE_FILE_NOT_EXISTS:'未找到 %s 中的定义的 %s "%s" 对应的 %s 文件',SHOULD_NOT_IN:"%s 不应该在 %s 中",JSON_CUSTOM_COMPILE_PATH_NOT_EXISTS_TITLE:"app.json 或自定义编译条件错误",JSON_CUSTOM_COMPILE_PATH_NOT_EXISTS:"app.json 中未定义自定义编译中指定的启动页面 %s",JSON_ENTRY_PAGE_PATH_NOT_FOUND:"未在 %s 中找到 %s 定义的入口页面",JSON_TABBAR_AT_LEAST:'["tabBar"]["list"] 需至少包含 %s 项',JSON_TABBAR_AT_MOST:'["tabBar"]["list"] 不能超过 %s 项',JSON_TABBAR_PATH_EMPTY:'["tabBar"]["list"][%s]["pagePath"] 不能为空',JSON_TABBAR_PATH_SAME_WITH_OTHER:'["tabBar"]["list"][%s]["pagePath"] 和 ["tabBar"]["list"][%s]["pagePath"] 相同',JSON_TABBAR_ICON_MAX_SIZE:'["tabBar"]["list"][%s]["%s"] 大小超过 %skb',JSON_TABBAR_ICON_EXT:'["tabBar"]["list"][%s]["%s"] 文件格式错误,仅支持 %s 格式',JSON_CONTENT_SHOULD_NOT_BE:"%s 不能为 %s",JSON_RESOLVE_ALIAS_ILLEGAL:'resolveAlias 配置中 %s 或 %s 不合法,包含连续的 "//"',JSON_RESOLVE_ALIAS_INCLUDE_STAR:'resolveAlias 配置中 %s 或 %s 需要用 "/*" 结尾',JSON_RESOLVE_ALIAS_SHOULD_NOT_START_WITH:'resolveAlias 配置中 %s 不能以 "./" 开头',JSON_REQUIRED_PRIVATE_INFOS_MUTUALLY_EXCLUSIVE:"requiredPrivateInfos %s 与 %s 互斥",APP_JSON_SHOULD_SET_LAZYCODELOADING:'%s 中 "renderer" 设置为 "skyline",需在 app.json 添加 "lazyCodeLoading": "requiredComponents"',PAGE_JSON_SHOULD_SET_DISABLESCROLL_TRUE:'根据页面或 app.json 的配置,%s 页面 "renderer" 为 "skyline",需在页面配置中添加 "disableScroll": true',PAGE_JSON_SHOULD_SET_NAVIGATIONSTYLE_CUSTOM:'根据页面或 app.json 的配置,%s 页面 "renderer" 为 "skyline",需在页面配置中添加 "navigationStyle": custom',CONTENT_EXIST:"%s 已经存在",JSON_CONTENT_EXISTED:"%s 已经存在",JSON_CONTENT_NOT_FOUND:"%s 不存在",LACK_OF_FILE:"缺少文件 %s",JSON_PAGES_REPEAT:"%s 在 %s 中重复",JSON_CONTENT_REPEAT:"%s 不能同时在 %s 中声明",EXT_JSON_INVALID:'%s 不是 3rdMiniProgramAppid, ext.json 无法生效;查看文档: "%s"',GAME_EXT_JSON_INVALID:'%s 不是 3rdMiniGameAppid, ext.json 无法生效;"%s"',EXT_APPID_SHOULD_NOT_BE_EMPTY:"extAppid 不能为空",FILE_NOT_UTF8:"%s 文件不是 UTF-8 格式",INVALID:"无效的 %s",DIRECTORY:"目录",EXCEED_LIMIT:"%s 超过限制 %s",PLEASE_CHOOSE_PLUGIN_MODE:"如果正在开发插件,请选择插件模式",TRIPLE_NUMBER_DOT:"数字.数字.数字",PAGE_PATH:"页面路径",PLUGINS_SAME_ALIAS:"%s 和 %s 的别名相同",SAME_ITEM:'%s 和 %s 的 "%s" 相同',ALREADY_EXISTS:"已存在",SAME_KEY_PAGE_PUBLICCOMPONENTS:'["pages"] 与 ["publicComponents"] 不能存在相同的 key: %s',GAME_DEV_PLUGIN_SHOULD_NOT_USE_LOCAL_PATH:"开发版插件 %s 不能使用 %s 指定本地路径",GAME_PLUGIN_SIGNATURE_MD5_NOT_MATCH_CONTENT:'插件文件 "%s" 的 MD5: "%s" 与其 signature.json 所给定的值: "%s" 不匹配, 因此编译过程已经中断。\n这表示此文件的内容可能已经被修改。\n恢复此文件的原始内容可能可以解决此问题并移除此警告。\n\n要了解更多,可以参考文档。\n',FILE:"文件",PROCESSING:"处理中: %s",DONE:"完成: %s",UPLOAD:"上传",SUCCESS:"成功",PROJECT_TYPE_ERROR:"project.type 是 %s, 但 appid(%s) 是 %s",MINI_PROGRAM:"小程序",MINI_GAME:"小游戏",NOT_ALLOWED_REQUIRE_VAR:"不允许require变量",NOT_ALLOWED_REQUIRE_ASSIGN:"不允许将require函数赋值给其他变量",NOT_FOUND_NPM_ENTRY:"未找到npm包入口文件",NOT_FOUND_NODE_MODULES:"没有找到可以构建的 NPM 包,请确认需要参与构建的 npm 都在 `miniprogramRoot` 目录内,或配置 project.config.json 的 packNpmManually 和 packNpmRelationList 进行构建",JSON_ENTRANCE_DECLARE_PATH_ERR:'["entranceDeclare"]["locationMessage"]["path"] "%s" 需在 pages 数组或分包 pages 数组中',JSON_ENTRANCE_DECLARE_PATH_EMPTY:'["entranceDeclare"]["locationMessage"]["path"] 不能为空',COULD_NOT_USE_CODE_PROTECT:"无法使用代码保护功能",SUMMER_COMPILING_MODULE:"编译 %s",SUMMER_COMPILE_JSON:"编译 JSON 文件",SUMMER_OPTIMIZE_CODE:"优化代码",SUMMER_PACK_FILES:"打包资源文件",SUMMER_COMPRESS_PACK:"压缩代码包",SUMMER_SEAL_PACK:"封装代码包",SUMMER_APPEND_BABEL_HELPERS:"追加 babel helper 文件",SUMMER_COMPILE_PAGE_JSON:"编译 %s 个页面json文件",SUMMER_COMPILE_PLUGIN_PAGE_JSON:"编译插件 %s 个页面json文件",SUMMER_COMPILE:"编译 %s",SUMMER_COMPILE_MINIPROGRAM:"编译打包小程序",SUMMER_COMPILE_PLUGIN:"编译打包插件"},formatConfig={};for(const[_,E]of Object.entries(config))formatConfig[_]=new fomatable_string_1.FormatableString(E);exports.default=formatConfig;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.flexdbModifyNameSpace=exports.flexdbDescribeRestoreTime=exports.flexdbRestoreTCBTables=exports.flexdbDescribeRestoreTask=exports.flexdbDescribeRestoreTables=exports.flexdbModifyTableNames=exports.flexdbRunCommands=exports.flexdbUpdateTable=exports.flexdbDescribeTable=exports.flexdbCount=exports.flexdbDeleteItem=exports.flexdbUpdateItem=exports.flexdbPutItem=exports.flexdbQuery=exports.flexdbDeleteTable=exports.flexdbCreateTable=exports.flexdbListTables=void 0;const tslib_1=require("tslib"),transactor_1=(0,tslib_1.__importDefault)(require("../../transaction/transactor")),contracts_1=require("../../transaction/contracts/contracts"),flexdbContracts=(0,tslib_1.__importStar)(require("../../transaction/contracts/contracts"));async function flexdbListTables(e){const t={Action:"ListTables",Version:"2018-11-27",Region:e.region,Tag:e.tag,MgoLimit:e.mgoLimit,MgoOffset:e.mgoOffset};try{const e=await(0,transactor_1.default)(contracts_1.flexdbListTablesContract,t);return{tables:e.Tables?e.Tables.map(e=>({tableName:e.TableName,count:e.Count,size:e.Size,indexCount:e.IndexCount,indexSize:e.IndexSize})):[],pager:{offset:e.Pager.Offset,limit:e.Pager.Limit,total:e.Pager.Total}}}catch(e){throw e}}async function flexdbCreateTable(e){const t={Action:"CreateTable",Version:"2018-11-27",Region:e.region,Tag:e.tag,TableName:e.tableName};try{return await(0,transactor_1.default)(contracts_1.flexdbCreateTableContract,t),{}}catch(e){throw e}}async function flexdbDeleteTable(e){const t={Action:"DeleteTable",Version:"2018-11-27",Region:e.region,Tag:e.tag,TableName:e.tableName};try{return await(0,transactor_1.default)(contracts_1.flexdbDeleteTableContract,t),{}}catch(e){throw e}}async function flexdbQuery(e){const t={Action:"Query",Version:"2018-11-27",Region:e.region,Tag:e.tag,TableName:e.tableName,MgoLimit:e.mgoLimit,MgoProjection:e.mgoProjection,MgoQuery:e.mgoQuery,MgoOffset:e.mgoOffset,MgoSort:e.mgoSort};try{const e=await(0,transactor_1.default)(contracts_1.flexdbQueryContract,t);return{data:e.Data?e.Data.map(e=>JSON.parse(e)):[],pager:{offset:e.Pager.Offset,limit:e.Pager.Limit,total:e.Pager.Total}}}catch(e){throw e}}async function flexdbPutItem(e){const t={Action:"PutItem",Version:"2018-11-27",Region:e.region,Tag:e.tag,TableName:e.tableName,MgoDocs:e.mgoDocs};try{return{insertedIds:(await(0,transactor_1.default)(contracts_1.flexdbPutItemContract,t)).InsertedIds}}catch(e){throw e}}async function flexdbUpdateItem(e){const t={Action:"UpdateItem",Version:"2018-11-27",Region:e.region,Tag:e.tag,TableName:e.tableName,MgoUpdate:e.mgoUpdate,MgoUpsert:e.mgoUpsert,MgoIsMulti:e.mgoIsMulti,MgoQuery:e.mgoQuery};try{const e=await(0,transactor_1.default)(contracts_1.flexdbUpdateItemContract,t);return{modifiedNum:e.ModifiedNum,matchedNum:e.MatchedNum,upsertedId:e.UpsertedId}}catch(e){throw e}}async function flexdbDeleteItem(e){const t={Action:"DeleteItem",Version:"2018-11-27",Region:e.region,Tag:e.tag,TableName:e.tableName,MgoIsMulti:e.mgoIsMulti,MgoQuery:e.mgoQuery};try{return{deleted:(await(0,transactor_1.default)(contracts_1.flexdbDeleteItemContract,t)).Deleted}}catch(e){throw e}}async function flexdbCount(e){const t={Action:"Count",Version:"2018-11-27",Region:e.region,Tag:e.tag,TableName:e.tableName,MgoQuery:e.mgoQuery};try{return{count:(await(0,transactor_1.default)(contracts_1.flexdbCountContract,t)).Count}}catch(e){throw e}}async function flexdbDescribeTable(e){const t={Action:"DescribeTable",Version:"2018-11-27",Region:e.region,Tag:e.tag,TableName:e.tableName};try{const e=await(0,transactor_1.default)(contracts_1.flexdbDescribeTableContract,t);return{indexes:e.Indexes.map(e=>({name:e.Name,size:e.Size,keys:e.Keys.map(e=>({name:e.Name,direction:e.Direction})),accesses:{ops:e.Accesses.Ops,since:e.Accesses.Since},unique:e.Unique})),indexNum:e.IndexNum}}catch(e){throw e}}async function flexdbUpdateTable(e){const t={Action:"UpdateTable",Version:"2018-11-27",Region:e.region,Tag:e.tag,TableName:e.tableName,CreateIndexes:(e.createIndexes||[]).map(e=>({IndexName:e.indexName,MgoKeySchema:{MgoIndexKeys:e.mgoKeySchema.mgoIndexKeys.map(e=>({Name:e.name,Direction:e.direction})),MgoIsUnique:e.mgoKeySchema.mgoIsUnique}})),DropIndexes:(e.dropIndexes||[]).map(e=>({IndexName:e.indexName}))};try{return await(0,transactor_1.default)(contracts_1.flexdbUpdateTableContract,t),{}}catch(e){throw e}}async function flexdbRunCommands(e){const t={Action:"RunCommands",Version:"2018-11-27",Region:e.region,Tag:e.tag,MgoCommands:e.mgoCommands.map(e=>({TableName:e.tableName,CommandType:e.commandType,Command:e.command}))};try{return{data:(await(0,transactor_1.default)(contracts_1.flexdbRunCommandsContract,t)).Data}}catch(e){throw e}}async function flexdbModifyTableNames(e){const t={Action:"ModifyTableNames",Version:"2018-11-27",Region:e.region,InstanceId:e.instanceId,ModifyTableInfo:e.modifyTableInfo.map(e=>({OldTableName:e.oldTableName,NewTableName:e.newTableName}))};try{return{flowId:(await(0,transactor_1.default)(contracts_1.flexdbModifyTableNamesContract,t)).FlowId}}catch(e){throw e}}async function flexdbDescribeRestoreTables(e){const t={Action:"DescribeRestoreTables",Version:"2018-11-27",Region:e.region,InstanceId:e.instanceId,Time:e.time};return{tables:(await(0,transactor_1.default)(contracts_1.flexdbDescribeRestoreTablesContract,t)).Tables}}async function flexdbDescribeRestoreTask(e){const t={Action:"DescribeRestoreTask",Version:"2018-11-27",Region:e.region,InstanceId:e.instanceId};return{tasks:(await(0,transactor_1.default)(contracts_1.flexdbDescribeRestoreTaskContract,t)).Tasks.map(e=>({tables:(e.Tables||[]).map(e=>({oldTableName:e.OldTableName,newTableName:e.NewTableName})),createTime:e.CreateTime,status:e.Status,endTime:e.EndTime,restoreTime:e.RestoreTime}))}}async function flexdbRestoreTCBTables(e){const t={Action:"RestoreTCBTables",Version:"2018-11-27",Region:e.region,InstanceId:e.instanceId,Time:e.time,ModifyTableNamesInfo:e.modifyTableNamesInfo.map(e=>({OldTableName:e.oldTableName,NewTableName:e.newTableName}))};return{flowId:(await(0,transactor_1.default)(flexdbContracts.flexdbRestoreTCBTablesContract,t)).FlowId}}async function flexdbDescribeRestoreTime(e){const t={Action:"DescribeRestoreTime",Version:"2018-11-27",Region:e.region,InstanceId:e.instanceId}
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.flexdbModifyNameSpace=exports.flexdbDescribeRestoreTime=exports.flexdbRestoreTCBTables=exports.flexdbDescribeRestoreTask=exports.flexdbDescribeRestoreTables=exports.flexdbModifyTableNames=exports.flexdbRunCommands=exports.flexdbUpdateTable=exports.flexdbDescribeTable=exports.flexdbCount=exports.flexdbDeleteItem=exports.flexdbUpdateItem=exports.flexdbPutItem=exports.flexdbQuery=exports.flexdbDeleteTable=exports.flexdbCreateTable=exports.flexdbListTables=void 0;const tslib_1=require("tslib"),transactor_1=(0,tslib_1.__importDefault)(require("../../transaction/transactor")),contracts_1=require("../../transaction/contracts/contracts"),flexdbContracts=(0,tslib_1.__importStar)(require("../../transaction/contracts/contracts"));async function flexdbListTables(e){const t={Action:"ListTables",Version:"2018-11-27",Region:e.region,Tag:e.tag,MgoLimit:e.mgoLimit,MgoOffset:e.mgoOffset};try{const e=await(0,transactor_1.default)(contracts_1.flexdbListTablesContract,t);return{tables:e.Tables?e.Tables.map(e=>({tableName:e.TableName,count:e.Count,size:e.Size,indexCount:e.IndexCount,indexSize:e.IndexSize})):[],pager:{offset:e.Pager.Offset,limit:e.Pager.Limit,total:e.Pager.Total}}}catch(e){throw e}}async function flexdbCreateTable(e){const t={Action:"CreateTable",Version:"2018-11-27",Region:e.region,Tag:e.tag,TableName:e.tableName};try{return await(0,transactor_1.default)(contracts_1.flexdbCreateTableContract,t),{}}catch(e){throw e}}async function flexdbDeleteTable(e){const t={Action:"DeleteTable",Version:"2018-11-27",Region:e.region,Tag:e.tag,TableName:e.tableName};try{return await(0,transactor_1.default)(contracts_1.flexdbDeleteTableContract,t),{}}catch(e){throw e}}async function flexdbQuery(e){const t={Action:"Query",Version:"2018-11-27",Region:e.region,Tag:e.tag,TableName:e.tableName,MgoLimit:e.mgoLimit,MgoProjection:e.mgoProjection,MgoQuery:e.mgoQuery,MgoOffset:e.mgoOffset,MgoSort:e.mgoSort};try{const e=await(0,transactor_1.default)(contracts_1.flexdbQueryContract,t);return{data:e.Data?e.Data.map(e=>JSON.parse(e)):[],pager:{offset:e.Pager.Offset,limit:e.Pager.Limit,total:e.Pager.Total}}}catch(e){throw e}}async function flexdbPutItem(e){const t={Action:"PutItem",Version:"2018-11-27",Region:e.region,Tag:e.tag,TableName:e.tableName,MgoDocs:e.mgoDocs};try{return{insertedIds:(await(0,transactor_1.default)(contracts_1.flexdbPutItemContract,t)).InsertedIds}}catch(e){throw e}}async function flexdbUpdateItem(e){const t={Action:"UpdateItem",Version:"2018-11-27",Region:e.region,Tag:e.tag,TableName:e.tableName,MgoUpdate:e.mgoUpdate,MgoUpsert:e.mgoUpsert,MgoIsMulti:e.mgoIsMulti,MgoQuery:e.mgoQuery};try{const e=await(0,transactor_1.default)(contracts_1.flexdbUpdateItemContract,t);return{modifiedNum:e.ModifiedNum,matchedNum:e.MatchedNum,upsertedId:e.UpsertedId}}catch(e){throw e}}async function flexdbDeleteItem(e){const t={Action:"DeleteItem",Version:"2018-11-27",Region:e.region,Tag:e.tag,TableName:e.tableName,MgoIsMulti:e.mgoIsMulti,MgoQuery:e.mgoQuery};try{return{deleted:(await(0,transactor_1.default)(contracts_1.flexdbDeleteItemContract,t)).Deleted}}catch(e){throw e}}async function flexdbCount(e){const t={Action:"Count",Version:"2018-11-27",Region:e.region,Tag:e.tag,TableName:e.tableName,MgoQuery:e.mgoQuery};try{return{count:(await(0,transactor_1.default)(contracts_1.flexdbCountContract,t)).Count}}catch(e){throw e}}async function flexdbDescribeTable(e){const t={Action:"DescribeTable",Version:"2018-11-27",Region:e.region,Tag:e.tag,TableName:e.tableName};try{const e=await(0,transactor_1.default)(contracts_1.flexdbDescribeTableContract,t);return{indexes:e.Indexes.map(e=>({name:e.Name,size:e.Size,keys:e.Keys.map(e=>({name:e.Name,direction:e.Direction})),accesses:{ops:e.Accesses.Ops,since:e.Accesses.Since},unique:e.Unique})),indexNum:e.IndexNum}}catch(e){throw e}}async function flexdbUpdateTable(e){const t={Action:"UpdateTable",Version:"2018-11-27",Region:e.region,Tag:e.tag,TableName:e.tableName,CreateIndexes:(e.createIndexes||[]).map(e=>({IndexName:e.indexName,MgoKeySchema:{MgoIndexKeys:e.mgoKeySchema.mgoIndexKeys.map(e=>({Name:e.name,Direction:e.direction})),MgoIsUnique:e.mgoKeySchema.mgoIsUnique}})),DropIndexes:(e.dropIndexes||[]).map(e=>({IndexName:e.indexName}))};try{return await(0,transactor_1.default)(contracts_1.flexdbUpdateTableContract,t),{}}catch(e){throw e}}async function flexdbRunCommands(e){const t={Action:"RunCommands",Version:"2018-11-27",Region:e.region,Tag:e.tag,MgoCommands:e.mgoCommands.map(e=>({TableName:e.tableName,CommandType:e.commandType,Command:e.command}))};try{return{data:(await(0,transactor_1.default)(contracts_1.flexdbRunCommandsContract,t)).Data}}catch(e){throw e}}async function flexdbModifyTableNames(e){const t={Action:"ModifyTableNames",Version:"2018-11-27",Region:e.region,InstanceId:e.instanceId,ModifyTableInfo:e.modifyTableInfo.map(e=>({OldTableName:e.oldTableName,NewTableName:e.newTableName}))};try{return{flowId:(await(0,transactor_1.default)(contracts_1.flexdbModifyTableNamesContract,t)).FlowId}}catch(e){throw e}}async function flexdbDescribeRestoreTables(e){const t={Action:"DescribeRestoreTables",Version:"2018-11-27",Region:e.region,InstanceId:e.instanceId,Time:e.time};return{tables:(await(0,transactor_1.default)(contracts_1.flexdbDescribeRestoreTablesContract,t)).Tables}}async function flexdbDescribeRestoreTask(e){const t={Action:"DescribeRestoreTask",Version:"2018-11-27",Region:e.region,InstanceId:e.instanceId};return{tasks:(await(0,transactor_1.default)(contracts_1.flexdbDescribeRestoreTaskContract,t)).Tasks.map(e=>({tables:(e.Tables||[]).map(e=>({oldTableName:e.OldTableName,newTableName:e.NewTableName})),createTime:e.CreateTime,status:e.Status,endTime:e.EndTime,restoreTime:e.RestoreTime}))}}async function flexdbRestoreTCBTables(e){const t={Action:"RestoreTCBTables",Version:"2018-11-27",Region:e.region,InstanceId:e.instanceId,Time:e.time,ModifyTableNamesInfo:e.modifyTableNamesInfo.map(e=>({OldTableName:e.oldTableName,NewTableName:e.newTableName}))};return{flowId:(await(0,transactor_1.default)(flexdbContracts.flexdbRestoreTCBTablesContract,t)).FlowId}}async function flexdbDescribeRestoreTime(e){const t={Action:"DescribeRestoreTime",Version:"2018-11-27",Region:e.region,InstanceId:e.instanceId},a=await(0,transactor_1.default)(flexdbContracts.flexdbDescribeRestoreTimeContract,t);return{restoreTimes:a.RestoreTimes,restoreTimeRanges:[{startTime:a.RestoreTimeRanges[0].StartTime,endTime:a.RestoreTimeRanges[0].EndTime}]}}async function flexdbModifyNameSpace(e){const t={Action:"ModifyNameSpace",Version:"2018-11-27",Region:e.region,Tag:e.tag,ModifyTableInfo:e.modifyTableInfo.map(e=>({OldTableName:e.oldTableName,NewTableName:e.newTableName}))};return{flowId:(await(0,transactor_1.default)(flexdbContracts.flexdbModifyNameSpaceContract,t)).FlowId}}exports.flexdbListTables=flexdbListTables,exports.flexdbCreateTable=flexdbCreateTable,exports.flexdbDeleteTable=flexdbDeleteTable,exports.flexdbQuery=flexdbQuery,exports.flexdbPutItem=flexdbPutItem,exports.flexdbUpdateItem=flexdbUpdateItem,exports.flexdbDeleteItem=flexdbDeleteItem,exports.flexdbCount=flexdbCount,exports.flexdbDescribeTable=flexdbDescribeTable,exports.flexdbUpdateTable=flexdbUpdateTable,exports.flexdbRunCommands=flexdbRunCommands,exports.flexdbModifyTableNames=flexdbModifyTableNames,exports.flexdbDescribeRestoreTables=flexdbDescribeRestoreTables,exports.flexdbDescribeRestoreTask=flexdbDescribeRestoreTask,exports.flexdbRestoreTCBTables=flexdbRestoreTCBTables,exports.flexdbDescribeRestoreTime=flexdbDescribeRestoreTime,exports.flexdbModifyNameSpace=flexdbModifyNameSpace;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.scfListVersionByFunction=exports.scfPublishVersion=exports.scfGetAlias=exports.scfUpdateAlias=exports.scfGetFunctionLogs=exports.scfInvokeFunction=exports.scfGetFunctionAddress=exports.scfBatchCreateTrigger=exports.scfUpdateFunctionTestModel=exports.scfDeleteFunctionTestModel=exports.scfCreateFunctionTestModel=exports.scfGetFunctionTestModel=exports.scfListFunctionTestModels=exports.scfUpdateFunctionInfo=exports.scfGetFunctionInfo=exports.scfDeleteFunction=exports.scfUpdateFunctionIncrementalCode=exports.scfUpdateFunction=exports.scfCreateFunction=exports.scfListAllFunctions=exports.scfListFunctions=void 0;const tslib_1=require("tslib"),transactor_1=(0,tslib_1.__importDefault)(require("../../transaction/transactor")),contracts_1=require("../../transaction/contracts/contracts"),common_1=require("../../utils/common");async function scfListFunctions(e,t){const n={Action:"ListFunctions",Version:"2018-04-16",Region:e.region,Order:e.order,Orderby:e.orderBy,Offset:e.offset,Limit:e.limit,SearchKey:e.searchKey,Namespace:e.namespace,Description:e.description},o=await(0,transactor_1.default)(contracts_1.scfListFunctionsContract,n,t);return{functions:(o.Functions||[]).map(e=>({modTime:(0,common_1.strToDate)(e.ModTime),addTime:(0,common_1.strToDate)(e.AddTime),runtime:e.Runtime,functionName:e.FunctionName,functionId:e.FunctionId,namespace:e.Namespace,status:e.Status,statusDesc:e.StatusDesc,description:e.Description,tags:(e.Tags||[]).map(e=>({key:e.Key,value:e.Value}))})),totalCount:o.TotalCount}}async function scfListAllFunctions(e,t=[],n=0,o){const i=e.limit||100,{functions:s,totalCount:c}=await scfListFunctions({offset:n,limit:i,order:e.order,orderBy:e.orderBy,searchKey:e.searchKey,namespace:e.namespace,description:e.description,region:e.region},o);return c>n+i?scfListAllFunctions(e,[...t,...s],n+i):{functions:[...t,...s],totalCount:c}}async function scfCreateFunction(e,t){const n={Action:"CreateFunction",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,Code:{ZipFile:e.code.zipFile},Handler:e.handler,Description:e.description,MemorySize:e.memorySize,Timeout:e.timeout,Role:e.role,Environment:{Variables:e.environment.variables.map(e=>({Key:e.key,Value:e.value}))},Runtime:e.runtime,Namespace:e.namespace,Stamp:e.stamp,CodeSecret:e.codeSecret,ClsLogsetId:e.clsLogsetId,ClsTopicId:e.clsTopicId};e.hasOwnProperty("installDependency")&&(n.InstallDependency=e.installDependency?"TRUE":"FALSE"),await(0,transactor_1.default)(contracts_1.scfCreateFunctionContract,n,t);return{}}async function scfUpdateFunction(e,t){const n={Action:"UpdateFunctionCode",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,ZipFile:e.fileData,Handler:e.handler||"index.main",Namespace:e.namespace,InstallDependency:e.installDependency?"TRUE":"FALSE",CodeSecret:e.codeSecret};await(0,transactor_1.default)(contracts_1.scfUpdateFunctionContract,n,t);return{}}async function scfUpdateFunctionIncrementalCode(e,t){const n={Action:"UpdateFunctionIncrementalCode",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,Namespace:e.namespace,AddFiles:e.addFiles,DeleteFiles:e.deleteFiles};await(0,transactor_1.default)(contracts_1.scfUpdateFunctionIncrementalCodeContract,n,t);return{}}async function scfDeleteFunction(e,t){const n={Action:"DeleteFunction",Version:"2018-04-16",FunctionName:e.functionName,Namespace:e.namespace,Region:e.region};await(0,transactor_1.default)(contracts_1.scfDeleteFunctionContract,n,t);return{}}async function scfGetFunctionInfo(e,t){const n={Action:"GetFunction",Version:"2018-04-16",FunctionName:e.functionName,Region:e.region,Qualifier:e.qualifier,Namespace:e.namespace,CodeSecret:e.codeSecret},o=await(0,transactor_1.default)(contracts_1.scfGetFunctionInfoContract,n,t);return{environment:{variables:(o.Environment||{}).Variables.map(e=>({key:e.Key,value:e.Value}))},functionName:o.FunctionName,runtime:o.Runtime,handler:o.Handler,memorySize:o.MemorySize,timeout:o.Timeout,status:o.Status,statusDesc:o.StatusDesc,installDependency:o.InstallDependency,pubnetConfig:"ENABLE"===o.PublicNetConfig.EipConfig.EipStatus,pubnetIp:o.PublicNetConfig.EipConfig.EipAddress}}async function scfUpdateFunctionInfo(e,t){const n={Action:"UpdateFunctionConfiguration",Version:"2018-04-16",FunctionName:e.functionName,Region:e.region,Namespace:e.namespace,Runtime:e.runtime,MemorySize:e.memorySize,Environment:e.environment?{Variables:e.environment.variables.map(e=>({Key:e.key,Value:e.value}))}:void 0,Timeout:e.timeout,ClsLogsetId:e.clsLogsetId,ClsTopicId:e.clsTopicId};e.hasOwnProperty("installDependency")&&(n.InstallDependency=e.installDependency?"TRUE":"FALSE"),e.hasOwnProperty("systemEnvironment")&&(n.SystemEnvironment={Variables:e.systemEnvironment.variables.map(e=>({Key:e.key,Value:e.value}))}),await(0,transactor_1.default)(contracts_1.scfUpdateFunctionInfoContract,n,t);return{}}async function scfListFunctionTestModels(e,t){const n={Action:"ListFunctionTestModels",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,Namespace:e.namespace};return{testModels:(await(0,transactor_1.default)(contracts_1.scfListFunctionTestModelsContract,n,t)).TestModels||[]}}async function scfGetFunctionTestModel(e,t){const n={Action:"GetFunctionTestModel",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,TestModelName:e.testModelName,Namespace:e.namespace},o=await(0,transactor_1.default)(contracts_1.scfGetFunctionTestModelContract,n,t);return{testModelValue:o.TestModelValue,functionName:o.FunctionName,testModelName:o.TestModelName,createdTime:o.CreatedTime,modifiedTime:o.ModifiedTime,namespace:o.Namespace}}async function scfCreateFunctionTestModel(e,t){const n={Action:"CreateFunctionTestModel",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,TestModelName:e.testModelName,TestModelValue:e.testModelValue,Namespace:e.namespace};await(0,transactor_1.default)(contracts_1.scfCreateFunctionTestModelContract,n,t);return{}}async function scfDeleteFunctionTestModel(e,t){const n={Action:"DeleteFunctionTestModel",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,TestModelName:e.testModelName,Namespace:e.namespace};await(0,transactor_1.default)(contracts_1.scfDeleteFunctionTestModelContract,n,t);return{}}async function scfUpdateFunctionTestModel(e,t){const n={Action:"UpdateFunctionTestModel",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,TestModelName:e.testModelName,TestModelValue:e.testModelValue,Namespace:e.namespace};await(0,transactor_1.default)(contracts_1.scfUpdateFunctionTestModelContract,n,t);return{}}async function scfBatchCreateTrigger(e,t){const n={Action:"BatchCreateTrigger",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,Namespace:e.namespace,Triggers:JSON.stringify(e.triggers.map(e=>({TriggerName:e.triggerName,Type:e.type,TriggerDesc:e.triggerDesc}))),Count:e.triggers.length};await(0,transactor_1.default)(contracts_1.scfBatchCreateTriggerContract,n,t);return{}}async function scfGetFunctionAddress(e,t){const n={Action:"GetFunctionAddress",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,Namespace:e.namespace,CodeSecret:e.codeSecret},o=await(0,transactor_1.default)(contracts_1.scfGetFunctionAddressContract,n,t);return{codeSha256:o.CodeSha256,url:o.Url}}async function scfInvokeFunction(e,t){const n={Action:"Invoke",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,Namespace:e.namespace,InvocationType:e.invocationType,Qualifier:e.qualifier,ClientContext:e.clientContext};return{result:{functionRequestId:(await(0,transactor_1.default)(contracts_1.scfInvokeFunctionContract,n,t)).Result.FunctionRequestId}}}async function scfGetFunctionLogs(e,t,n){const o={Action:"GetFunctionLogs",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,Namespace:e.namespace,Offset:e.offset,Limit:e.limit,Order:e.order,OrderBy:e.orderBy,Filter:e.filter?{RetCode:e.filter.retCode}:void 0,Qualifier:e.qualifier,FunctionRequestId:e.functionRequestId,StartTime:e.startTime?(0,common_1.dateToStr)(e.startTime):void 0,EndTime:e.endTime?(0,common_1.dateToStr)(e.endTime):void 0};return{data:(await(0,transactor_1.default)(contracts_1.scfGetFunctionLogsContract,o,Object.assign(Object.assign({},n),{isPoll:t}))).Data.map(e=>({functionName:e.FunctionName,retMsg:e.RetMsg,requestId:e.RequestId,startTime:(0,common_1.strToDate)(e.StartTime),retCode:e.RetCode,invokeFinished:e.InvokeFinished,duration:e.Duration,billDuration:e.BillDuration,memUsage:e.MemUsage,log:e.Log}))}}async function scfUpdateAlias(e){var t,n;const o={Action:"UpdateAlias",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,Name:e.name,FunctionVersion:e.functionVersion,Namespace:e.namespace,RoutingConfig:e.routingConfig?{AdditionalVersionWeights:null===(t=e.routingConfig.additionalVersionWeights)||void 0===t?void 0:t.map(e=>({Version:e.version,Weight:e.weight})),AddtionVersionMatchs:null===(n=e.routingConfig.addtionVersionMatchs)||void 0===n?void 0:n.map(e=>({Version:e.version,Key:e.key,Method:e.method,Expression:e.expression}))}:e.routingConfig,Description:e.description};await(0,transactor_1.default)(contracts_1.scfUpdateAliasContract,o);return{}}async function scfGetAlias(e){var t,n;const o={Action:"GetAlias",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,Name:e.name,Namespace:e.namespace},i=await(0,transactor_1.default)(contracts_1.scfGetAliasContract,o);return{functionVersion:i.FunctionVersion,name:i.Name,routingConfig:{additionalVersionWeights:null===(t=i.RoutingConfig.AdditionalVersionWeights)||void 0===t?void 0:t.map(e=>({version:e.Version,weight:e.Weight})),addtionVersionMatchs:null===(n=i.RoutingConfig.AddtionVersionMatchs)||void 0===n?void 0:n.map(e=>({version:e.Version,key:e.Key,method:e.Method,expression:e.Expression}))},description:i.Description,addTime:i.AddTime,modTime:i.ModTime}}async function scfPublishVersion(e){const t={Action:"PublishVersion",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,Description:e.description,Namespace:e.namespace},n=await(0,transactor_1.default)(contracts_1.scfPublishVersionContract,t);return{functionVersion:n.FunctionVersion,codeSize:n.CodeSize,memorySize:n.MemorySize,description:n.Description,handler:n.Handler,timeout:n.Timeout,runtime:n.Runtime,namespace:n.Namespace}}async function scfListVersionByFunction(e){const t={Action:"ListVersionByFunction",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,Namespace:e.namespace,SearchKey:e.searchKey},n=await(0,transactor_1.default)(contracts_1.scfListVersionByFunctionContract,t);return{functionVersion:n.FunctionVersion,versions:(n.Versions||[]).map(e=>({version:e.Version,description:e.Description,addTime:e.AddTime,modTime:e.ModTime}))}}exports.scfListFunctions=scfListFunctions,exports.scfListAllFunctions=scfListAllFunctions,exports.scfCreateFunction=scfCreateFunction,exports.scfUpdateFunction=scfUpdateFunction,exports.scfUpdateFunctionIncrementalCode=scfUpdateFunctionIncrementalCode,exports.scfDeleteFunction=scfDeleteFunction,exports.scfGetFunctionInfo=scfGetFunctionInfo,exports.scfUpdateFunctionInfo=scfUpdateFunctionInfo,exports.scfListFunctionTestModels=scfListFunctionTestModels,exports.scfGetFunctionTestModel=scfGetFunctionTestModel,exports.scfCreateFunctionTestModel=scfCreateFunctionTestModel,exports.scfDeleteFunctionTestModel=scfDeleteFunctionTestModel,exports.scfUpdateFunctionTestModel=scfUpdateFunctionTestModel,exports.scfBatchCreateTrigger=scfBatchCreateTrigger,exports.scfGetFunctionAddress=scfGetFunctionAddress,exports.scfInvokeFunction=scfInvokeFunction,exports.scfGetFunctionLogs=scfGetFunctionLogs,exports.scfUpdateAlias=scfUpdateAlias,exports.scfGetAlias=scfGetAlias,exports.scfPublishVersion=scfPublishVersion,exports.scfListVersionByFunction=scfListVersionByFunction;
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.scfPutProvisionedConcurrencyConfig=exports.scfGetProvisionedConcurrencyConfig=exports.scfListVersionByFunction=exports.scfPublishVersion=exports.scfGetAlias=exports.scfUpdateAlias=exports.scfGetFunctionLogs=exports.scfInvokeFunction=exports.scfGetFunctionAddress=exports.scfBatchCreateTrigger=exports.scfUpdateFunctionTestModel=exports.scfDeleteFunctionTestModel=exports.scfCreateFunctionTestModel=exports.scfGetFunctionTestModel=exports.scfListFunctionTestModels=exports.scfUpdateFunctionInfo=exports.scfGetFunctionInfo=exports.scfDeleteFunction=exports.scfUpdateFunctionIncrementalCode=exports.scfUpdateFunction=exports.scfCreateFunction=exports.scfListAllFunctions=exports.scfListFunctions=void 0;const tslib_1=require("tslib"),transactor_1=(0,tslib_1.__importDefault)(require("../../transaction/transactor")),contracts_1=require("../../transaction/contracts/contracts"),common_1=require("../../utils/common");async function scfListFunctions(e,n){const t={Action:"ListFunctions",Version:"2018-04-16",Region:e.region,Order:e.order,Orderby:e.orderBy,Offset:e.offset,Limit:e.limit,SearchKey:e.searchKey,Namespace:e.namespace,Description:e.description},o=await(0,transactor_1.default)(contracts_1.scfListFunctionsContract,t,n);return{functions:(o.Functions||[]).map(e=>({modTime:(0,common_1.strToDate)(e.ModTime),addTime:(0,common_1.strToDate)(e.AddTime),runtime:e.Runtime,functionName:e.FunctionName,functionId:e.FunctionId,namespace:e.Namespace,status:e.Status,statusDesc:e.StatusDesc,description:e.Description,tags:(e.Tags||[]).map(e=>({key:e.Key,value:e.Value}))})),totalCount:o.TotalCount}}async function scfListAllFunctions(e,n=[],t=0,o){const i=e.limit||100,{functions:s,totalCount:c}=await scfListFunctions({offset:t,limit:i,order:e.order,orderBy:e.orderBy,searchKey:e.searchKey,namespace:e.namespace,description:e.description,region:e.region},o);return c>t+i?scfListAllFunctions(e,[...n,...s],t+i):{functions:[...n,...s],totalCount:c}}async function scfCreateFunction(e,n){const t={Action:"CreateFunction",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,Code:{ZipFile:e.code.zipFile},Handler:e.handler,Description:e.description,MemorySize:e.memorySize,Timeout:e.timeout,Role:e.role,Environment:{Variables:e.environment.variables.map(e=>({Key:e.key,Value:e.value}))},Runtime:e.runtime,Namespace:e.namespace,Stamp:e.stamp,CodeSecret:e.codeSecret,ClsLogsetId:e.clsLogsetId,ClsTopicId:e.clsTopicId};e.hasOwnProperty("installDependency")&&(t.InstallDependency=e.installDependency?"TRUE":"FALSE"),await(0,transactor_1.default)(contracts_1.scfCreateFunctionContract,t,n);return{}}async function scfUpdateFunction(e,n){const t={Action:"UpdateFunctionCode",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,ZipFile:e.fileData,Handler:e.handler||"index.main",Namespace:e.namespace,InstallDependency:e.installDependency?"TRUE":"FALSE",CodeSecret:e.codeSecret};await(0,transactor_1.default)(contracts_1.scfUpdateFunctionContract,t,n);return{}}async function scfUpdateFunctionIncrementalCode(e,n){const t={Action:"UpdateFunctionIncrementalCode",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,Namespace:e.namespace,AddFiles:e.addFiles,DeleteFiles:e.deleteFiles};await(0,transactor_1.default)(contracts_1.scfUpdateFunctionIncrementalCodeContract,t,n);return{}}async function scfDeleteFunction(e,n){const t={Action:"DeleteFunction",Version:"2018-04-16",FunctionName:e.functionName,Namespace:e.namespace,Region:e.region,Qualifier:e.qualifier};await(0,transactor_1.default)(contracts_1.scfDeleteFunctionContract,t,n);return{}}async function scfGetFunctionInfo(e,n){const t={Action:"GetFunction",Version:"2018-04-16",FunctionName:e.functionName,Region:e.region,Qualifier:e.qualifier,Namespace:e.namespace,CodeSecret:e.codeSecret},o=await(0,transactor_1.default)(contracts_1.scfGetFunctionInfoContract,t,n);return{environment:{variables:(o.Environment||{}).Variables.map(e=>({key:e.Key,value:e.Value}))},functionName:o.FunctionName,runtime:o.Runtime,handler:o.Handler,memorySize:o.MemorySize,timeout:o.Timeout,status:o.Status,statusDesc:o.StatusDesc,installDependency:o.InstallDependency,pubnetConfig:"ENABLE"===o.PublicNetConfig.EipConfig.EipStatus,pubnetIp:o.PublicNetConfig.EipConfig.EipAddress}}async function scfUpdateFunctionInfo(e,n){const t={Action:"UpdateFunctionConfiguration",Version:"2018-04-16",FunctionName:e.functionName,Region:e.region,Namespace:e.namespace,Runtime:e.runtime,MemorySize:e.memorySize,Environment:e.environment?{Variables:e.environment.variables.map(e=>({Key:e.key,Value:e.value}))}:void 0,Timeout:e.timeout,ClsLogsetId:e.clsLogsetId,ClsTopicId:e.clsTopicId};e.hasOwnProperty("installDependency")&&(t.InstallDependency=e.installDependency?"TRUE":"FALSE"),e.hasOwnProperty("systemEnvironment")&&(t.SystemEnvironment={Variables:e.systemEnvironment.variables.map(e=>({Key:e.key,Value:e.value}))}),await(0,transactor_1.default)(contracts_1.scfUpdateFunctionInfoContract,t,n);return{}}async function scfListFunctionTestModels(e,n){const t={Action:"ListFunctionTestModels",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,Namespace:e.namespace};return{testModels:(await(0,transactor_1.default)(contracts_1.scfListFunctionTestModelsContract,t,n)).TestModels||[]}}async function scfGetFunctionTestModel(e,n){const t={Action:"GetFunctionTestModel",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,TestModelName:e.testModelName,Namespace:e.namespace},o=await(0,transactor_1.default)(contracts_1.scfGetFunctionTestModelContract,t,n);return{testModelValue:o.TestModelValue,functionName:o.FunctionName,testModelName:o.TestModelName,createdTime:o.CreatedTime,modifiedTime:o.ModifiedTime,namespace:o.Namespace}}async function scfCreateFunctionTestModel(e,n){const t={Action:"CreateFunctionTestModel",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,TestModelName:e.testModelName,TestModelValue:e.testModelValue,Namespace:e.namespace};await(0,transactor_1.default)(contracts_1.scfCreateFunctionTestModelContract,t,n);return{}}async function scfDeleteFunctionTestModel(e,n){const t={Action:"DeleteFunctionTestModel",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,TestModelName:e.testModelName,Namespace:e.namespace};await(0,transactor_1.default)(contracts_1.scfDeleteFunctionTestModelContract,t,n);return{}}async function scfUpdateFunctionTestModel(e,n){const t={Action:"UpdateFunctionTestModel",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,TestModelName:e.testModelName,TestModelValue:e.testModelValue,Namespace:e.namespace};await(0,transactor_1.default)(contracts_1.scfUpdateFunctionTestModelContract,t,n);return{}}async function scfBatchCreateTrigger(e,n){const t={Action:"BatchCreateTrigger",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,Namespace:e.namespace,Triggers:JSON.stringify(e.triggers.map(e=>({TriggerName:e.triggerName,Type:e.type,TriggerDesc:e.triggerDesc}))),Count:e.triggers.length};await(0,transactor_1.default)(contracts_1.scfBatchCreateTriggerContract,t,n);return{}}async function scfGetFunctionAddress(e,n){const t={Action:"GetFunctionAddress",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,Namespace:e.namespace,CodeSecret:e.codeSecret},o=await(0,transactor_1.default)(contracts_1.scfGetFunctionAddressContract,t,n);return{codeSha256:o.CodeSha256,url:o.Url}}async function scfInvokeFunction(e,n){const t={Action:"Invoke",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,Namespace:e.namespace,InvocationType:e.invocationType,Qualifier:e.qualifier,ClientContext:e.clientContext};return{result:{functionRequestId:(await(0,transactor_1.default)(contracts_1.scfInvokeFunctionContract,t,n)).Result.FunctionRequestId}}}async function scfGetFunctionLogs(e,n,t){const o={Action:"GetFunctionLogs",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,Namespace:e.namespace,Offset:e.offset,Limit:e.limit,Order:e.order,OrderBy:e.orderBy,Filter:e.filter?{RetCode:e.filter.retCode}:void 0,Qualifier:e.qualifier,FunctionRequestId:e.functionRequestId,StartTime:e.startTime?(0,common_1.dateToStr)(e.startTime):void 0,EndTime:e.endTime?(0,common_1.dateToStr)(e.endTime):void 0};return{data:(await(0,transactor_1.default)(contracts_1.scfGetFunctionLogsContract,o,Object.assign(Object.assign({},t),{isPoll:n}))).Data.map(e=>({functionName:e.FunctionName,retMsg:e.RetMsg,requestId:e.RequestId,startTime:(0,common_1.strToDate)(e.StartTime),retCode:e.RetCode,invokeFinished:e.InvokeFinished,duration:e.Duration,billDuration:e.BillDuration,memUsage:e.MemUsage,log:e.Log}))}}async function scfUpdateAlias(e){var n,t;const o={Action:"UpdateAlias",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,Name:e.name,FunctionVersion:e.functionVersion,Namespace:e.namespace,RoutingConfig:e.routingConfig?{AdditionalVersionWeights:null===(n=e.routingConfig.additionalVersionWeights)||void 0===n?void 0:n.map(e=>({Version:e.version,Weight:e.weight})),AddtionVersionMatchs:null===(t=e.routingConfig.addtionVersionMatchs)||void 0===t?void 0:t.map(e=>({Version:e.version,Key:e.key,Method:e.method,Expression:e.expression}))}:e.routingConfig,Description:e.description};await(0,transactor_1.default)(contracts_1.scfUpdateAliasContract,o);return{}}async function scfGetAlias(e){var n,t;const o={Action:"GetAlias",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,Name:e.name,Namespace:e.namespace},i=await(0,transactor_1.default)(contracts_1.scfGetAliasContract,o);return{functionVersion:i.FunctionVersion,name:i.Name,routingConfig:{additionalVersionWeights:null===(n=i.RoutingConfig.AdditionalVersionWeights)||void 0===n?void 0:n.map(e=>({version:e.Version,weight:e.Weight})),addtionVersionMatchs:null===(t=i.RoutingConfig.AddtionVersionMatchs)||void 0===t?void 0:t.map(e=>({version:e.Version,key:e.Key,method:e.Method,expression:e.Expression}))},description:i.Description,addTime:i.AddTime,modTime:i.ModTime}}async function scfPublishVersion(e){const n={Action:"PublishVersion",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,Description:e.description,Namespace:e.namespace},t=await(0,transactor_1.default)(contracts_1.scfPublishVersionContract,n);return{functionVersion:t.FunctionVersion,codeSize:t.CodeSize,memorySize:t.MemorySize,description:t.Description,handler:t.Handler,timeout:t.Timeout,runtime:t.Runtime,namespace:t.Namespace}}async function scfListVersionByFunction(e){const n={Action:"ListVersionByFunction",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,Namespace:e.namespace,SearchKey:e.searchKey},t=await(0,transactor_1.default)(contracts_1.scfListVersionByFunctionContract,n);return{functionVersion:t.FunctionVersion,versions:(t.Versions||[]).map(e=>({version:e.Version,description:e.Description,addTime:e.AddTime,modTime:e.ModTime}))}}async function scfGetProvisionedConcurrencyConfig(e){const n={Action:"GetProvisionedConcurrencyConfig",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,Namespace:e.namespace,Qualifier:e.qualifier},t=await(0,transactor_1.default)(contracts_1.scfGetProvisionedConcurrencyConfigContract,n);return{unallocatedConcurrencyNum:t.UnallocatedConcurrencyNum,allocated:t.Allocated.map(e=>({allocatedProvisionedConcurrencyNum:e.AllocatedProvisionedConcurrencyNum,availableProvisionedConcurrencyNum:e.AvailableProvisionedConcurrencyNum,status:e.Status,statusReason:e.StatusReason,qualifier:e.Qualifier}))}}async function scfPutProvisionedConcurrencyConfig(e){var n;const t={Action:"PutProvisionedConcurrencyConfig",Version:"2018-04-16",Region:e.region,FunctionName:e.functionName,Qualifier:e.qualifier,VersionProvisionedConcurrencyNum:e.versionProvisionedConcurrencyNum,Namespace:e.namespace,TriggerActions:null===(n=e.triggerActions)||void 0===n?void 0:n.map(e=>({TriggerName:e.triggerName,TriggerProvisionedConcurrencyNum:e.triggerProvisionedConcurrencyNum,TriggerCronConfig:e.triggerCronConfig,ProvisionedType:e.provisionedType})),ProvisionedType:e.provisionedType,TrackingTarget:e.trackingTarget,MinCapacity:e.minCapacity,MaxCapacity:e.maxCapacity};await(0,transactor_1.default)(contracts_1.scfPutProvisionedConcurrencyConfigContract,t);return{}}exports.scfListFunctions=scfListFunctions,exports.scfListAllFunctions=scfListAllFunctions,exports.scfCreateFunction=scfCreateFunction,exports.scfUpdateFunction=scfUpdateFunction,exports.scfUpdateFunctionIncrementalCode=scfUpdateFunctionIncrementalCode,exports.scfDeleteFunction=scfDeleteFunction,exports.scfGetFunctionInfo=scfGetFunctionInfo,exports.scfUpdateFunctionInfo=scfUpdateFunctionInfo,exports.scfListFunctionTestModels=scfListFunctionTestModels,exports.scfGetFunctionTestModel=scfGetFunctionTestModel,exports.scfCreateFunctionTestModel=scfCreateFunctionTestModel,exports.scfDeleteFunctionTestModel=scfDeleteFunctionTestModel,exports.scfUpdateFunctionTestModel=scfUpdateFunctionTestModel,exports.scfBatchCreateTrigger=scfBatchCreateTrigger,exports.scfGetFunctionAddress=scfGetFunctionAddress,exports.scfInvokeFunction=scfInvokeFunction,exports.scfGetFunctionLogs=scfGetFunctionLogs,exports.scfUpdateAlias=scfUpdateAlias,exports.scfGetAlias=scfGetAlias,exports.scfPublishVersion=scfPublishVersion,exports.scfListVersionByFunction=scfListVersionByFunction,exports.scfGetProvisionedConcurrencyConfig=scfGetProvisionedConcurrencyConfig,exports.scfPutProvisionedConcurrencyConfig=scfPutProvisionedConcurrencyConfig;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|