miniprogram-ci 1.5.1 → 1.8.0

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.
Files changed (259) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +71 -0
  3. package/dist/@types/ci/code-analyse.d.ts +4 -0
  4. package/dist/@types/ci/getLatestVersion.d.ts +7 -0
  5. package/dist/@types/ci/project.d.ts +4 -0
  6. package/dist/@types/cloud/cloudapi.d.ts +1 -1
  7. package/dist/@types/cloud/uploadContainer.d.ts +36 -7
  8. package/dist/@types/config.d.ts +3 -3
  9. package/dist/@types/core/js/enhance.d.ts +1 -0
  10. package/dist/@types/core/js/generateMap.d.ts +3 -0
  11. package/dist/@types/core/json/app/checkAppFields.d.ts +1 -0
  12. package/dist/@types/core/json/projectWithMockBuffer.d.ts +14 -0
  13. package/dist/@types/core/json/reactiveCache.d.ts +4 -0
  14. package/dist/@types/core/protect/uglifyfilenames.d.ts +2 -4
  15. package/dist/@types/core/worker_thread/task/minifywxml.d.ts +7 -0
  16. package/dist/@types/core.d.ts +1 -1
  17. package/dist/@types/index.d.ts +6 -0
  18. package/dist/@types/summer/ci.d.ts +3 -0
  19. package/dist/@types/summer/devtool.d.ts +9 -1
  20. package/dist/@types/summer/error.d.ts +14 -5
  21. package/dist/@types/summer/graph/appgraph.d.ts +1 -0
  22. package/dist/@types/summer/graph/basegraph.d.ts +4 -0
  23. package/dist/@types/summer/graph/plugingraph.d.ts +2 -1
  24. package/dist/@types/summer/initPlugin.d.ts +1 -1
  25. package/dist/@types/summer/module.d.ts +3 -2
  26. package/dist/@types/summer/plugins/base/es6module.d.ts +4 -2
  27. package/dist/@types/summer/plugins/base/wxss.d.ts +1 -1
  28. package/dist/@types/summer/plugins/enhance.d.ts +3 -1
  29. package/dist/@types/summer/plugins/index.d.ts +1 -16
  30. package/dist/@types/summer/project.d.ts +5 -3
  31. package/dist/@types/summer/summer.d.ts +2 -1
  32. package/dist/@types/summer/types.d.ts +1 -0
  33. package/dist/@types/types/index.d.ts +5 -0
  34. package/dist/@types/types/miniprogram-json/app.d.ts +2 -1
  35. package/dist/@types/types/miniprogram-json/page.d.ts +1 -0
  36. package/dist/@types/types/miniprogram-json/projectconfig.d.ts +2 -0
  37. package/dist/@types/utils/locales/locales.d.ts +4 -0
  38. package/dist/@types/utils/locales/zh.d.ts +4 -0
  39. package/dist/@types/utils/tools.d.ts +1 -0
  40. package/dist/@types/utils/url_config.d.ts +1 -0
  41. package/dist/@types/vendor/code-analyse/index.d.ts +4 -3
  42. package/dist/ci/code-analyse.js +3 -0
  43. package/dist/ci/cos-upload.js +3 -1
  44. package/dist/ci/getCompiledResult.js +3 -1
  45. package/dist/ci/getDevSourceMap.js +3 -1
  46. package/dist/ci/getLatestVersion.js +3 -0
  47. package/dist/ci/jsserver.js +3 -1
  48. package/dist/ci/preview.js +3 -1
  49. package/dist/ci/project.js +3 -1
  50. package/dist/ci/projectattr.js +3 -1
  51. package/dist/ci/upload.js +3 -1
  52. package/dist/ci/utils/pack.js +3 -1
  53. package/dist/ci/utils/packfile.js +3 -1
  54. package/dist/ci/utils/terminalQrcode.js +3 -1
  55. package/dist/cli.js +3 -1
  56. package/dist/cloud/cloudapi.js +3 -1
  57. package/dist/cloud/createTimeTrigger.js +3 -1
  58. package/dist/cloud/uploadContainer.js +3 -1
  59. package/dist/cloud/uploadFile.js +3 -1
  60. package/dist/cloud/uploadFunction.js +3 -1
  61. package/dist/cloud/utils.js +3 -1
  62. package/dist/config.js +3 -1
  63. package/dist/core/analyse/partial.js +3 -1
  64. package/dist/core/compile/common.js +3 -1
  65. package/dist/core/compile/game.js +3 -1
  66. package/dist/core/compile/game_plugin.js +3 -1
  67. package/dist/core/compile/handler/js.js +3 -1
  68. package/dist/core/compile/handler/mpjson.js +3 -1
  69. package/dist/core/compile/handler/wxml.js +3 -1
  70. package/dist/core/compile/handler/wxss.js +3 -1
  71. package/dist/core/compile/index.js +3 -1
  72. package/dist/core/compile/mini_program.js +3 -1
  73. package/dist/core/compile/mini_program_plugin.js +3 -1
  74. package/dist/core/js/enhance.js +1 -1
  75. package/dist/core/js/generateMap.js +1 -0
  76. package/dist/core/js/index.js +1 -1
  77. package/dist/core/js/minifyjs_after_wrap.js +1 -1
  78. package/dist/core/json/app/checkAppFields.js +3 -1
  79. package/dist/core/json/app/getAppJSON.js +3 -1
  80. package/dist/core/json/app/getExtJSON.js +3 -1
  81. package/dist/core/json/app/index.js +3 -1
  82. package/dist/core/json/common.js +3 -1
  83. package/dist/core/json/game.js +3 -1
  84. package/dist/core/json/page/checkPageJSON.js +3 -1
  85. package/dist/core/json/page/getPageJSON.js +3 -1
  86. package/dist/core/json/plugin/plugin.js +3 -1
  87. package/dist/core/json/plugin/plugin_page.js +3 -1
  88. package/dist/core/json/projectWithMockBuffer.js +3 -0
  89. package/dist/core/json/projectconfig.js +3 -1
  90. package/dist/core/json/reactiveCache.js +3 -1
  91. package/dist/core/json/signaturejson.js +3 -1
  92. package/dist/core/json/sitemap.js +3 -1
  93. package/dist/core/json/theme.js +3 -1
  94. package/dist/core/npm/filterdeps.js +3 -1
  95. package/dist/core/npm/packnpm.js +3 -1
  96. package/dist/core/protect/file_flatter.js +3 -1
  97. package/dist/core/protect/uglifyfilenames.js +3 -1
  98. package/dist/core/utils/env.js +3 -1
  99. package/dist/core/utils/logger.js +3 -1
  100. package/dist/core/validate/validate.js +1 -1
  101. package/dist/core/worker_thread/childprocess.js +1 -1
  102. package/dist/core/worker_thread/childprocess_manager.js +1 -1
  103. package/dist/core/worker_thread/fork.js +1 -1
  104. package/dist/core/worker_thread/index.js +1 -1
  105. package/dist/core/worker_thread/task/call_func.js +1 -1
  106. package/dist/core/worker_thread/task/compilejs.js +1 -1
  107. package/dist/core/worker_thread/task/compilewxss.js +1 -1
  108. package/dist/core/worker_thread/task/func.js +1 -1
  109. package/dist/core/worker_thread/task/minifywxml.js +1 -1
  110. package/dist/core/worker_thread/worker.js +1 -1
  111. package/dist/core/worker_thread/worker_manager.js +1 -1
  112. package/dist/core.js +3 -1
  113. package/dist/index.js +3 -1
  114. package/dist/manifest.json +3 -3
  115. package/dist/summer/ci.js +3 -0
  116. package/dist/summer/devtool.js +3 -1
  117. package/dist/summer/entry_process.js +1 -1
  118. package/dist/summer/error.js +3 -1
  119. package/dist/summer/graph/appconf.js +3 -1
  120. package/dist/summer/graph/appgraph.js +3 -1
  121. package/dist/summer/graph/basegraph.js +3 -1
  122. package/dist/summer/graph/pluginconf.js +3 -1
  123. package/dist/summer/graph/plugingraph.js +3 -1
  124. package/dist/summer/index.js +3 -1
  125. package/dist/summer/initPlugin.js +3 -1
  126. package/dist/summer/module.js +3 -1
  127. package/dist/summer/persist_cache.js +3 -1
  128. package/dist/summer/plugin_driver.js +3 -1
  129. package/dist/summer/plugins/base/es6module.js +1 -1
  130. package/dist/summer/plugins/base/javascript.js +1 -1
  131. package/dist/summer/plugins/base/wxss.js +1 -1
  132. package/dist/summer/plugins/enhance.js +1 -1
  133. package/dist/summer/plugins/index.js +1 -1
  134. package/dist/summer/plugins/less.js +1 -1
  135. package/dist/summer/plugins/sass.js +1 -1
  136. package/dist/summer/plugins/terser.js +1 -1
  137. package/dist/summer/plugins/typescript.js +1 -1
  138. package/dist/summer/project.js +3 -1
  139. package/dist/summer/recorder.js +3 -1
  140. package/dist/summer/resolver.js +3 -1
  141. package/dist/summer/summer.js +3 -1
  142. package/dist/summer/types.js +3 -1
  143. package/dist/summer/utils/async.js +3 -1
  144. package/dist/summer/utils/ensureArray.js +3 -1
  145. package/dist/summer/worker.js +3 -1
  146. package/dist/types/index.js +3 -1
  147. package/dist/types/miniprogram-json/app.js +3 -1
  148. package/dist/types/miniprogram-json/base.js +3 -1
  149. package/dist/types/miniprogram-json/ext.js +3 -1
  150. package/dist/types/miniprogram-json/game.js +3 -1
  151. package/dist/types/miniprogram-json/index.js +3 -1
  152. package/dist/types/miniprogram-json/page.js +3 -1
  153. package/dist/types/miniprogram-json/plugin.js +3 -1
  154. package/dist/types/miniprogram-json/projectconfig.js +3 -1
  155. package/dist/types/miniprogram-json/sitemap.js +3 -1
  156. package/dist/types/miniprogram-json/theme.js +3 -1
  157. package/dist/utils/babel_helper.js +3 -1
  158. package/dist/utils/babel_transform_plugin.js +3 -1
  159. package/dist/utils/cache.js +3 -1
  160. package/dist/utils/common.js +3 -1
  161. package/dist/utils/error.js +3 -1
  162. package/dist/utils/fs.js +3 -1
  163. package/dist/utils/fsagent.js +3 -1
  164. package/dist/utils/glob.js +3 -1
  165. package/dist/utils/interruptibletask.js +3 -1
  166. package/dist/utils/jsonParse.js +3 -1
  167. package/dist/utils/jsonlint.js +3 -1
  168. package/dist/utils/locales/en.js +3 -1
  169. package/dist/utils/locales/fomatable_string.js +3 -1
  170. package/dist/utils/locales/locales.js +3 -1
  171. package/dist/utils/locales/zh.js +3 -1
  172. package/dist/utils/log.js +3 -1
  173. package/dist/utils/report.js +3 -1
  174. package/dist/utils/request.js +3 -1
  175. package/dist/utils/sign.js +3 -1
  176. package/dist/utils/taskstatus.js +3 -1
  177. package/dist/utils/tools.js +3 -1
  178. package/dist/utils/url_config.js +3 -1
  179. package/dist/utils/white_ext_list.js +3 -1
  180. package/dist/utils/wxvpkgreader/wxvpkgreader.js +1 -1
  181. package/dist/vendor/cloud-api/src/apis/apis.js +3 -1
  182. package/dist/vendor/cloud-api/src/apis/cdn/cdn.apis.js +3 -1
  183. package/dist/vendor/cloud-api/src/apis/cdn/index.js +3 -1
  184. package/dist/vendor/cloud-api/src/apis/flexdb/flexdb.apis.js +3 -1
  185. package/dist/vendor/cloud-api/src/apis/flexdb/index.js +3 -1
  186. package/dist/vendor/cloud-api/src/apis/scf/index.js +3 -1
  187. package/dist/vendor/cloud-api/src/apis/scf/scf.apis.js +3 -1
  188. package/dist/vendor/cloud-api/src/apis/ssl/index.js +3 -1
  189. package/dist/vendor/cloud-api/src/apis/ssl/ssl.apis.js +3 -1
  190. package/dist/vendor/cloud-api/src/apis/tcb/general.apis.js +3 -1
  191. package/dist/vendor/cloud-api/src/apis/tcb/index.js +3 -1
  192. package/dist/vendor/cloud-api/src/apis/tcb/tcb.apis.js +3 -1
  193. package/dist/vendor/cloud-api/src/index.js +3 -1
  194. package/dist/vendor/cloud-api/src/transaction/contracts/cdn.contracts.js +3 -1
  195. package/dist/vendor/cloud-api/src/transaction/contracts/contracts.js +3 -1
  196. package/dist/vendor/cloud-api/src/transaction/contracts/factory.js +3 -1
  197. package/dist/vendor/cloud-api/src/transaction/contracts/flexdb.contracts.js +3 -1
  198. package/dist/vendor/cloud-api/src/transaction/contracts/scf.contracts.js +3 -1
  199. package/dist/vendor/cloud-api/src/transaction/contracts/ssl.contracts.js +3 -1
  200. package/dist/vendor/cloud-api/src/transaction/contracts/tcb.contracts.js +3 -1
  201. package/dist/vendor/cloud-api/src/transaction/transactor.js +3 -1
  202. package/dist/vendor/cloud-api/src/transaction/validations/cdn.validations.js +3 -1
  203. package/dist/vendor/cloud-api/src/transaction/validations/common.validations.js +3 -1
  204. package/dist/vendor/cloud-api/src/transaction/validations/flexdb.validations.js +3 -1
  205. package/dist/vendor/cloud-api/src/transaction/validations/scf.validations.js +3 -1
  206. package/dist/vendor/cloud-api/src/transaction/validations/ssl.validations.js +3 -1
  207. package/dist/vendor/cloud-api/src/transaction/validations/tcb.validations.js +3 -1
  208. package/dist/vendor/cloud-api/src/transaction/validations/validations.js +3 -1
  209. package/dist/vendor/cloud-api/src/utils/common.js +3 -1
  210. package/dist/vendor/cloud-api/src/utils/validator.js +3 -1
  211. package/dist/vendor/code-analyse/index.js +1 -1
  212. package/dist/vendor/schema/dist/app.js +26 -1
  213. package/dist/vendor/schema/dist/ext.js +21 -1
  214. package/dist/vendor/schema/dist/game.js +29 -1
  215. package/dist/vendor/schema/dist/page.js +18 -1
  216. package/dist/vendor/schema/dist/plugin.js +1 -1
  217. package/dist/vendor/schema/dist/pluginpage.js +1 -1
  218. package/dist/vendor/schema/dist/projectconfig.js +38 -1
  219. package/dist/vendor/schema/dist/sitemap.js +1 -1
  220. package/dist/vendor/schema/dist/theme.js +1 -1
  221. package/package.json +22 -24
  222. package/dist/@types/core/js/__tests__/minifyjs.spec.d.ts +0 -1
  223. package/dist/@types/summer/backup/appconf/index-old.d.ts +0 -0
  224. package/dist/@types/summer/backup/appconf/index.d.ts +0 -33
  225. package/dist/@types/summer/backup/detectors/es6/BasicEvaluatedExpression.d.ts +0 -51
  226. package/dist/@types/summer/backup/detectors/es6/ContextDependencyHelpers.d.ts +0 -4
  227. package/dist/@types/summer/backup/detectors/es6/Evaluator.d.ts +0 -29
  228. package/dist/@types/summer/backup/detectors/es6/Parser.d.ts +0 -134
  229. package/dist/@types/summer/backup/detectors/es6/StackedSetMap.d.ts +0 -17
  230. package/dist/@types/summer/backup/detectors/es6/acorn/acorn.d.ts +0 -0
  231. package/dist/@types/summer/backup/detectors/es6/types.d.ts +0 -37
  232. package/dist/@types/summer/backup/detectors/wxml/index.d.ts +0 -4
  233. package/dist/@types/summer/backup/detectors/wxss/index.d.ts +0 -5
  234. package/dist/@types/summer/backup/detectors/wxss/parse.d.ts +0 -1
  235. package/dist/@types/summer/backup/fslayer/fslayer.d.ts +0 -73
  236. package/dist/@types/summer/backup/graph.d.ts +0 -71
  237. package/dist/@types/summer/backup/module.d.ts +0 -34
  238. package/dist/@types/summer/backup/plugin_driver.d.ts +0 -41
  239. package/dist/@types/summer/backup/structs/app.d.ts +0 -0
  240. package/dist/@types/summer/backup/watcher.d.ts +0 -0
  241. package/dist/core/js/__tests__/minifyjs.spec.js +0 -1
  242. package/dist/summer/backup/appconf/index-old.js +0 -1
  243. package/dist/summer/backup/appconf/index.js +0 -1
  244. package/dist/summer/backup/detectors/es6/BasicEvaluatedExpression.js +0 -1
  245. package/dist/summer/backup/detectors/es6/ContextDependencyHelpers.js +0 -1
  246. package/dist/summer/backup/detectors/es6/Evaluator.js +0 -1
  247. package/dist/summer/backup/detectors/es6/Parser.js +0 -1
  248. package/dist/summer/backup/detectors/es6/StackedSetMap.js +0 -1
  249. package/dist/summer/backup/detectors/es6/acorn/acorn.js +0 -1
  250. package/dist/summer/backup/detectors/es6/types.js +0 -1
  251. package/dist/summer/backup/detectors/wxml/index.js +0 -1
  252. package/dist/summer/backup/detectors/wxss/index.js +0 -1
  253. package/dist/summer/backup/detectors/wxss/parse.js +0 -1
  254. package/dist/summer/backup/fslayer/fslayer.js +0 -1
  255. package/dist/summer/backup/graph.js +0 -1
  256. package/dist/summer/backup/module.js +0 -1
  257. package/dist/summer/backup/plugin_driver.js +0 -1
  258. package/dist/summer/backup/structs/app.js +0 -1
  259. package/dist/summer/backup/watcher.js +0 -1
@@ -0,0 +1,3 @@
1
+ !function(require, directRequire){
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compile=void 0;const common_1=require("../core/compile/common"),project_1=require("./project"),recorder_1=require("./recorder"),summer_1=require("./summer");function getSummerOptions(e,r){const i=new Set;return i.add("javascript"),e&&(i.add(["es6module",{disableUseStrict:e.disableUseStrict}]),(e.es7||e.es6)&&i.add(["enhance",{disableUseStrict:e.disableUseStrict}]),(e.minifyWXSS||e.autoPrefixWXSS)&&i.add("wxss"),e.minify&&(i.add("terser"),i.add("wxss"))),r&&r.forEach(e=>{if("string"==typeof e)i.add(e);else{if(!Array.isArray(e))throw new Error("invalid useSummerCompiler options: "+JSON.stringify(e));if("string"!=typeof e[0]||void 0===e[1])throw new Error("invalid useSummerCompiler options: "+JSON.stringify(e));i.add(e)}}),Array.from(i)}async function compile(e,r,i,o){const t={appid:e.appid,attr:await e.attr(),compileType:e.type,miniprogramRoot:e.miniprogramRoot,pluginRoot:e.pluginRoot,summerPlugins:getSummerOptions(i.setting,o)},s=e.getFilesAndDirs();s.files=s.files.filter(common_1.isNotIgnoredByProjectConfig.bind(null,r,e.miniprogramRoot));const n=new project_1.Project(e.projectPath,s.files,s.dirs,t),m=new summer_1.SummerCompiler(n,"",t),a=new recorder_1.Recorder((e,r,o)=>{var t;null===(t=i.onProgressUpdate)||void 0===t||t.call(i,{id:e.toString(),message:o,status:r})});return await m.compile({},a)}exports.compile=compile;
3
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1,3 @@
1
- "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"),__1=require(".."),path_1=tslib_1.__importDefault(require("path")),lodash_1=tslib_1.__importDefault(require("lodash")),recorder_1=require("./recorder"),tools_1=require("../utils/tools"),miniprogram="miniprogram",plugin="plugin";function performanceMark(e,s){console.warn(`[summer-compiler] [${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"],execArgv:"development"===process.env.NODE_ENV?["--inspect"]:[],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=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;this.onResponse(s,t,r)}}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)},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] [${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] [${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")&&!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=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){return await this.process.runTask("compile",{},(e,t,r)=>{s.onProgressUpdate({id:e,status:t,message:r})})}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){__1.proxy(e)}setLocale(e){this.process.runTask("setLocale",e)}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;
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;
3
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1 @@
1
- var _a;process.env&&process.env.isDevtools&&require("../utils/hackrequire/index"),Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib");(null===(_a=process.env)||void 0===_a?void 0:_a.isDevtools)&&require("../utils/hackrequire/index");const project_1=require("./project"),summer_1=require("./summer"),core_1=require("../core"),recorder_1=require("./recorder");let summerCompiler,project;process.on("message",async e=>{if("object"==typeof e)if("init"===e.type){if(summerCompiler)return void console.error("summer compiler has been inited");{const r=e.data,{projectPath:s,cachePath:o,files:t,dirs:i}=r,c=tslib_1.__rest(r,["projectPath","cachePath","files","dirs"]);project=new project_1.Project(s,t,i,c),summerCompiler=new summer_1.SummerCompiler(project,o,c),process.send({type:"ready"})}}else{if(summerCompiler||console.error("summer compiler not inited yet"),"event"===e.type)if("fileChange"===e.name){const{type:r,targetPath:s}=e.data;project.onFileChange(r,s)}else if("updateOptions"===e.name){const r=e.data;project.updateOptions(r),summerCompiler.updateOptions(r)}if("request"===e.type){const{id:r,name:s,data:o}=e,t=r,i=new recorder_1.Recorder((e,r,s)=>{process.send({type:"progress",id:e,taskId:t,status:r,message:s})});try{let e;if("getCode"===s){const{graphId:r,cacheMd5:s,package:t}=o,c=`getCode-${r}${t?"-"+t:""}`,a=await i.run("!"+c,()=>summerCompiler.getCode(o,i));for(const e of Object.keys(s)){const r=a[e];r?"error"in r||r.md5!==s[e]||delete a[e]:a[e]={path:e,md5:"",code:""}}e=a}else if("getConf"===s)e=await summerCompiler.getConf(o,i);else if("compile"===s)e=await summerCompiler.compile(o,i);else if("compileSingleCode"===s)e=await summerCompiler.compileSingleCode(o,i);else if("setLocale"===s)core_1.setLocale(o);else if("clearCache"===s)summerCompiler.clearCache();else{if("loadStatus"!==s)throw new Error("unknown command "+s);e=summerCompiler.getStatus()}process.send({type:"response",id:r,data:e})}catch(e){process.send({type:"response",id:r,data:null,error:{code:e.code||-1,message:e.message,stack:e.stack,path:e.path||""}})}}}else console.error("child process unrecognized message "+e)}),process.on("disconnect",()=>{try{process.exit(0)}catch(e){process.kill(process.pid,"SIGTERM")}}),process.on("uncaughtException",e=>{console.log(e)});
1
+ var _a;process.env&&process.env.isDevtools&&require("../utils/hackrequire/index"),Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib");(null===(_a=process.env)||void 0===_a?void 0:_a.isDevtools)&&require("../utils/hackrequire/index");const project_1=require("./project"),summer_1=require("./summer"),core_1=require("../core"),recorder_1=require("./recorder");let summerCompiler,project;process.on("message",async e=>{if("object"==typeof e)if("init"===e.type){if(summerCompiler)return void console.error("summer compiler has been inited");{const r=e.data,{projectPath:s,cachePath:o,files:t,dirs:i}=r,c=(0,tslib_1.__rest)(r,["projectPath","cachePath","files","dirs"]);project=new project_1.Project(s,t,i,c),summerCompiler=new summer_1.SummerCompiler(project,o,c),process.send({type:"ready"})}}else{if(summerCompiler||console.error("summer compiler not inited yet"),"event"===e.type)if("fileChange"===e.name){const{type:r,targetPath:s}=e.data;project.onFileChange(r,s)}else if("updateOptions"===e.name){const r=e.data;project.updateOptions(r),summerCompiler.updateOptions(r)}if("request"===e.type){const{id:r,name:s,data:o}=e,t=r,i=new recorder_1.Recorder((e,r,s)=>{process.send({type:"progress",id:e,taskId:t,status:r,message:s})});try{let e;if("getCode"===s){const{graphId:r,cacheMd5:s,package:t}=o,c=`getCode-${r}${t?"-"+t:""}`,a=await i.run("!"+c,()=>summerCompiler.getCode(o,i));for(const e of Object.keys(s)){const r=a[e];r?"error"in r||r.md5!==s[e]||delete a[e]:a[e]={path:e,md5:"",code:""}}e=a}else if("getConf"===s)e=await summerCompiler.getConf(o,i);else if("getLocalFileList"===s)e=await summerCompiler.getLocalFileList(o);else if("compile"===s)e=await summerCompiler.compile(o,i);else if("compileSingleCode"===s)e=await summerCompiler.compileSingleCode(o,i);else if("setLocale"===s)(0,core_1.setLocale)(o);else if("clearCache"===s)summerCompiler.clearCache();else{if("loadStatus"!==s)throw new Error("unknown command "+s);e=summerCompiler.getStatus()}process.send({type:"response",id:r,data:e})}catch(e){process.send({type:"response",id:r,data:null,error:{code:e.code||-1,message:e.message,stack:e.stack,path:e.path||""}})}}}else console.error("child process unrecognized message "+e)}),process.on("disconnect",()=>{try{process.exit(0)}catch(e){process.kill(process.pid,"SIGTERM")}}),process.on("uncaughtException",e=>{console.log(e)});
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.makeSummerError=exports.SummerErrors=void 0;const config_1=require("../config");function makeSummerError(r,e,o){return{code:e||exports.SummerErrors.SUMMER_PLUGIN_ERR,message:"string"==typeof r?r:null==r?void 0:r.message,path:o,stack:"string"!=typeof r?null==r?void 0:r.stack:void 0}}exports.SummerErrors={SUMMER_PLUGIN_ERR:config_1.SUMMER_PLUGIN_ERR,SUMMER_PLUGIN_CODE_ERR:config_1.SUMMER_PLUGIN_CODE_ERR},exports.makeSummerError=makeSummerError;
1
+ !function(require, directRequire){
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.makeSummerError=exports.SummerErrors=exports.SummerError=void 0;const config_1=require("../config");class SummerError extends Error{constructor(r){super(r.message),this.stack=r.stack,r.code&&(this.code=r.code),r.path&&(this.path=r.path),r.plugin&&(this.plugin=r.plugin),r.hook&&(this.hook=r.hook)}toString(){return`${super.toString()}${this.path?"\nFile: "+this.path:""}`}toJSON(){return{type:"SummerError",message:this.message,stack:this.stack,code:this.code,path:this.path,plugin:this.plugin,hook:this.hook}}}function makeSummerError(r,e,o){if(r instanceof SummerError)return e&&!r.code&&(r.code=e),o&&!r.path&&(r.path=o),r;return new SummerError({code:e||exports.SummerErrors.SUMMER_PLUGIN_ERR,message:r instanceof Error?r.toString():"string"==typeof r?r:"Unknown Error Message "+r,path:o,stack:r instanceof Error?null==r?void 0:r.stack:void 0})}exports.SummerError=SummerError,exports.SummerErrors={SUMMER_PLUGIN_ERR:config_1.SUMMER_PLUGIN_ERR,SUMMER_PLUGIN_CODE_ERR:config_1.SUMMER_PLUGIN_CODE_ERR},exports.makeSummerError=makeSummerError;
3
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppConf=exports.resolvePath=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),core_1=require("../../core"),common_1=require("../../core/json/common"),locales_1=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"),()=>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,"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,"app.json")}}),o.themeLocation&&await t.run(locales_1.default.config.SUMMER_COMPILE.format(o.themeLocation),()=>this.loadTheme(o.themeLocation));const a=o.sitemapLocation||"sitemap.json";await t.run(locales_1.default.config.SUMMER_COMPILE.format(a),()=>this.loadSitemap(a))}async loadPage(t){if(t.startsWith("plugin://"))return;const o=await core_1.getPageJSON(this.proxyProject,{miniprogramRoot:this.graph.root,pagePath:t});this.pages.set(t,o);for(const e of Object.values(o.usingComponents||{})){if(e.startsWith("plugin://"))return;const o=resolvePath(t,e);await this.loadComp(o,t)}}async loadComp(t,o){if(await this.isExtendedLibComp(t,o))return;if(this.comps.has(t))return;const e=await core_1.getPageJSON(this.proxyProject,{miniprogramRoot:this.graph.root,pagePath:t});this.comps.set(t,e);for(const o of Object.values(e.usingComponents||{})){if(o.startsWith("plugin://"))return;const e=resolvePath(t,o);await this.loadComp(e,t)}}async loadSitemap(t){const o=await core_1.getSiteMapJSON(this.proxyProject);this.sitemap=o}async loadTheme(t){const o=await core_1.checkThemeJSON(this.proxyProject,{themeLocation:t});this.theme=o}async isExtendedLibComp(t,o){if(t.startsWith("miniprogram_npm/")){const e=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;
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));const a=o.sitemapLocation||"sitemap.json";await t.run(locales_1.default.config.SUMMER_COMPILE.format(a),()=>this.loadSitemap(a))}async loadPage(t){if(t.startsWith("plugin://"))return;const o=await(0,core_1.getPageJSON)(this.proxyProject,{miniprogramRoot:this.graph.root,pagePath:t});this.pages.set(t,o);for(const e of Object.values(o.usingComponents||{})){if(e.startsWith("plugin://"))return;const o=resolvePath(t,e);await this.loadComp(o,e,t)}}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);for(const o of Object.values(s.usingComponents||{})){if(o.startsWith("plugin://"))return;const e=resolvePath(t,o);await this.loadComp(e,o,t)}}async loadSitemap(t){const o=await(0,core_1.getSiteMapJSON)(this.proxyProject);this.sitemap=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
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppGraph=void 0;const devtool_1=require("../devtool"),recorder_1=require("../recorder"),appconf_1=require("./appconf"),basegraph_1=require("./basegraph");class AppGraph extends basegraph_1.BaseGraph{constructor(e){super(e),this.appConf=new appconf_1.AppConf(this.compiler,this)}destroy(){this.appConf.destroy(),super.destroy()}async getConf(e){return await this.appConf.build(e),this.conf={app:this.appConf.app,packages:Object.fromEntries(this.appConf.packages.entries()),pages:Object.fromEntries(this.appConf.pages.entries()),comps:Object.fromEntries(this.appConf.comps.entries()),sitemap:this.appConf.sitemap,theme:this.appConf.theme},this.conf}async ensureConf(e){this.conf||await this.getConf(e)}async compileSingleCode(e,t){await this.ensureConf(recorder_1.silentRecorder);const s=this.resolver.resolveInfoMap.get(e);if(s)return super.doCompileSingleCode(Object.assign(Object.assign({},s),{independentRoot:this.getIndependentRoot(s.path)}),t);throw new Error("file not found")}async getDevCode(e,t){await this.ensureConf(e);let s=this.getPackageFile(t.package);return s=s.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(s,e)}async getProdCode(e,t){await this.ensureConf(e);let s=this.getPackageFile(t.package);return s=s.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(s,e,!1)}onFileChangeForGraph(e,t){this.appConf.onFileChange(e,t)}getPackageFile(e){const t=[];for(const[s,o]of this.resolver.resolveInfoMap.entries())e!==devtool_1.FullPkg&&this.checkFilePackage(s)!==e||t.push(o);return t.map(e=>Object.assign(Object.assign({},e),{independentRoot:this.getIndependentRoot(e.path)}))}getIndependentRoot(e){for(const t of Object.values(this.conf.packages))if(!0===t.independent){const s=t.root.replace(/^\//,"");if(e.startsWith(s))return s}return"object"==typeof this.conf.app.functionalPages&&!0===this.conf.app.functionalPages.independent&&e.startsWith("functional-pages/")?"functional-pages":"string"==typeof this.conf.app.openDataContext&&e.startsWith(this.conf.app.openDataContext)?this.conf.app.openDataContext:"string"==typeof this.conf.app.workers&&e.startsWith(this.conf.app.workers)?this.conf.app.workers:""}checkFilePackage(e){for(const t of Object.keys(this.conf.packages))if(e.startsWith(t))return t;return devtool_1.MainPkg}async compileJSON(){const e=await this.getConf(recorder_1.silentRecorder),t={};t["app.json"]=JSON.stringify(e.app);for(const s in e.pages)t[s+".json"]=JSON.stringify(e.pages[s]);for(const s in e.comps)t[s+".json"]=JSON.stringify(e.comps[s]);return{conf:e,jsons:t}}}exports.AppGraph=AppGraph;
1
+ !function(require, directRequire){
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppGraph=void 0;const devtool_1=require("../devtool"),recorder_1=require("../recorder"),appconf_1=require("./appconf"),basegraph_1=require("./basegraph");class AppGraph extends basegraph_1.BaseGraph{constructor(e){super(e),this.appConf=new appconf_1.AppConf(this.compiler,this)}destroy(){this.appConf.destroy(),super.destroy()}async getConf(e){return await this.appConf.build(e),this.conf={app:this.appConf.app,packages:Object.fromEntries(this.appConf.packages.entries()),pages:Object.fromEntries(this.appConf.pages.entries()),comps:Object.fromEntries(this.appConf.comps.entries()),sitemap:this.appConf.sitemap,theme:this.appConf.theme},this.conf}async ensureConf(e){this.conf||await this.getConf(e)}async compileSingleCode(e,t){await this.ensureConf(recorder_1.silentRecorder);const s=this.resolver.resolveInfoMap.get(e);if(s)return super.doCompileSingleCode(Object.assign(Object.assign({},s),{independentRoot:this.getIndependentRoot(s.path)}),t);throw new Error("file not found")}async getDevCode(e,t){await this.ensureConf(e);let s=this.getPackageFile(t.package);return s=s.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(s,e)}async getProdCode(e,t){await this.ensureConf(e);let s=this.getPackageFile(t.package);return s=s.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(s,e,!1)}getLocalCodeFileList(){return Array.from(this.resolver.resolveInfoMap.entries()).map(([e,t])=>t.source)}onFileChangeForGraph(e,t){this.appConf.onFileChange(e,t)}getPackageFile(e){const t=[];for(const[s,o]of this.resolver.resolveInfoMap.entries())e!==devtool_1.FullPkg&&this.checkFilePackage(s)!==e||t.push(o);return t.map(e=>Object.assign(Object.assign({},e),{independentRoot:this.getIndependentRoot(e.path)}))}getIndependentRoot(e){for(const t of Object.values(this.conf.packages))if(!0===t.independent){const s=t.root.replace(/^\//,"");if(e.startsWith(s))return s}return"object"==typeof this.conf.app.functionalPages&&!0===this.conf.app.functionalPages.independent&&e.startsWith("functional-pages/")?"functional-pages":"string"==typeof this.conf.app.openDataContext&&e.startsWith(this.conf.app.openDataContext)?this.conf.app.openDataContext:"string"==typeof this.conf.app.workers&&e.startsWith(this.conf.app.workers)?this.conf.app.workers:""}checkFilePackage(e){for(const t of Object.keys(this.conf.packages))if(e.startsWith(t))return t;return devtool_1.MainPkg}async compileJSON(){const e=await this.getConf(recorder_1.silentRecorder),t={};t["app.json"]=JSON.stringify(e.app);for(const s in e.pages)t[s+".json"]=JSON.stringify(e.pages[s]);for(const s in e.comps)t[s+".json"]=JSON.stringify(e.comps[s]);return{conf:e,jsons:t}}}exports.AppGraph=AppGraph;
3
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BaseGraph=void 0;const tslib_1=require("tslib"),plugin_driver_1=require("../plugin_driver"),types_1=require("../types"),module_1=tslib_1.__importDefault(require("../module")),path_1=tslib_1.__importDefault(require("path")),fs_1=tslib_1.__importDefault(require("fs")),devtool_1=require("../devtool"),resolver_1=require("../resolver"),white_ext_list_1=require("../../utils/white_ext_list"),common_1=require("../../core/compile/common"),tools_1=require("../../utils/tools"),babel_helper_1=require("../../utils/babel_helper"),recorder_1=require("../recorder"),locales_1=tslib_1.__importDefault(require("../../utils/locales/locales")),lodash_1=require("lodash"),error_1=require("../error");function calcSize(e){let t=0;for(const o in e)t+=e[o].length;return t}function getFileType(e){let t=path_1.default.extname(e);if(t.startsWith(".")){if(t=t.slice(1),t===types_1.FileType.JS)return types_1.FileType.JS;if(t===types_1.FileType.WXML)return types_1.FileType.WXML;if(t===types_1.FileType.WXSS)return types_1.FileType.WXSS;if(t===types_1.FileType.WXS)return types_1.FileType.WXS;if(t===types_1.FileType.JSON)return types_1.FileType.JSON}throw Error("unknown the filetype of "+e)}class BaseGraph{constructor(e){this.invalidated=!0,this.running=!1,this.onFileChange=(e,t)=>{t.startsWith(this.root)&&(t=t.replace(new RegExp("^"+this.root),""),this.resolver.onFileChange(e,t),"change"!==e&&"unlink"!==e||this.invalidateModules(t),this.onFileChangeForGraph(e,t))},this.type=e.type,this.root=e.root,this.rootPath=path_1.default.posix.join(e.compiler.project.projectPath,this.root),this.persistCache=e.persistCache,this.compiler=e.compiler,this.project=this.compiler.project,this.cachedModules=new Map,this.pluginDriver=new plugin_driver_1.PluginDriver(this,e),this.modulesByPath=new Map,this.resolver=new resolver_1.Resolver(this,this.root,this.pluginDriver.resolveExtConf),this.project.event.on("fileChange",this.onFileChange)}destroy(){}clearCache(){this.modulesByPath.clear()}invalidateModules(e){for(const t of this.modulesByPath.values())(t.sourcePath===e||t.depFiles.includes(e))&&this.modulesByPath.delete(t.path)}async loadModuleFromFile(e,t){let o=this.modulesByPath.get(e.path);if(null==o?void 0:o.loadingPromise)return await o.loadingPromise,this.loadModuleFromFile(e,t);let r=!o||o.sourcePath!==e.source||o.independentRoot!==e.independentRoot;if(!r&&(null==o?void 0:o.error)){if(o.loadEnd+1e3>Date.now())return o;r=!0}if(r){const r=getFileType(e.path);o=new module_1.default(this,e.path,e.source,r),o.independentRoot=e.independentRoot,this.modulesByPath.set(e.path,o),o.loadingPromise=t.run(locales_1.default.config.SUMMER_COMPILING_MODULE.format(e.source),()=>this.loadSourceForModule(o)),await o.loadingPromise,o.loadingPromise=void 0}return o}async loadSourceForModule(e){var t;try{const o=path_1.default.posix.join(this.rootPath,e.sourcePath),r=t=>Object.assign(Object.assign({},t),{addWatchFile:t=>{const o=tools_1.normalizePath(t);if(!o.startsWith(this.rootPath))throw error_1.makeSummerError(`The file (${t}) required by ${e.path} is outside the project`,error_1.SummerErrors.SUMMER_PLUGIN_CODE_ERR,e.path);e.addWatchFile(path_1.default.posix.relative(this.rootPath,o))}}),i=null!==(t=await this.pluginDriver.hookFirst("load",[e.path,o,e.independentRoot],r))&&void 0!==t?t:await this.readFile(o),s="string"==typeof i?{sourceCode:i}:i,a=await this.tranform(s,e,r);return e.setSource(a),!0}catch(t){return t.path=path_1.default.posix.join(this.root,e.sourcePath),e.setError(t),!1}}async doCompileSingleCode(e,t){const o=getFileType(e.path),r=new module_1.default(this,e.path,e.source,o);if(await this.loadSourceForModule(r),r.error)throw r.error;return r.target||(r.target=await this.generate(r.source,r)),r.toCodeFile()}async getCodeFiles(e,t,o=!0){const r={};return await Promise.all(e.map(async e=>{if(o&&!this.modulesByPath.get(e.path)&&e.path.endsWith(".js")){const t=await this.persistCache.get(this.project.projectPath,this.root,e);if(t)return console.log("use cache",e.path),r[e.path]=t,void this.loadModuleFromFile(e,recorder_1.silentRecorder)}const i=await this.loadModuleFromFile(e,t);i.error||i.target||(i.target=await this.generate(i.source,i));const s=i.toCodeFile();r[i.path]=s,!("error"in s)&&e.path.endsWith(".js")&&this.persistCache.set(this.project.projectPath,this.root,e,s)})),r}async readFile(e){return fs_1.default.promises.readFile(e,{encoding:"utf-8"})}async tranform(e,t,o){return await this.pluginDriver.hookReduceArg0("transform",[e,t.path,t.sourcePath,t.independentRoot],(function(e,t){return"string"==typeof t?{sourceCode:t}:t}),o)}async generate(e,t){let o=await this.pluginDriver.hookFirst("generate",[e,t.path,t.sourcePath,t.independentRoot]);return void 0===o||lodash_1.isNull(o)?{code:e.sourceCode,map:e.inputMap}:("string"==typeof o&&(o={code:o}),o)}async compile(e){const{conf:t,jsons:o}=await e.run(locales_1.default.config.SUMMER_COMPILE_JSON.format(),()=>this.compileJSON(e)),r=await this.compileCodeWithoutJSON(e);function i(e,t){return t}console.log(`[summer-compiler] before optimize, ${this.type} size: `,calcSize(r));const s=await e.run(locales_1.default.config.SUMMER_OPTIMIZE_CODE.format(),()=>this.pluginDriver.hookReduceArg0("optimize",[r,t],i,e=>e));console.log(`[summer-compiler] after optimize, ${this.type} size: `,calcSize(s));const a=await e.run(locales_1.default.config.SUMMER_PACK_FILES.format(),()=>this.compileOther(Object.keys(o))),l=Object.assign(Object.assign(Object.assign({},a),s),o);console.log(`[summer-compiler] before compress, ${this.type} size: `,calcSize(l));const n=await e.run(locales_1.default.config.SUMMER_COMPRESS_PACK.format(),()=>this.pluginDriver.hookReduceArg0("compress",[l],(e,t)=>t,e=>e));return console.log(`[summer-compiler] after compress, ${this.type} size: `,calcSize(n)),await e.run(locales_1.default.config.SUMMER_SEAL_PACK.format(),()=>this.pluginDriver.hookParallel("sealed",[n])),n}async compileOther(e){const t=new Set(this.resolver.allExts.map(e=>"."+e));t.delete(".json");const{MiniProgramWhiteList:o}=await white_ext_list_1.getWhiteExtList(),r=this.project.getFileList(this.root,"").filter(e=>{const r=path_1.default.posix.extname(e);return o.has(r)&&!t.has(r)}),i=await common_1.compileOther(this.project,r,{onProgressUpdate:()=>{}}),s={};for(const t in i){const o=path_1.default.posix.relative(this.root,t);e.includes(o)||(s[o]=i[t])}return s}async compileCodeWithoutJSON(e){var t;const o={},r=await this.getProdCode(e,{package:devtool_1.FullPkg}),i=new Set;for(const e in r){const s=r[e];if("error"in s)throw s.error;if(s.path.endsWith(".js")){((null===(t=s.jsTag)||void 0===t?void 0:t.helpers)||[]).forEach(e=>{i.add(e)}),o[e]=s.code;const r=s.map&&tools_1.formatSourceMap(s.map);r&&(o[e+".map"]=r)}else o[e]=s.code}return await e.run(locales_1.default.config.SUMMER_APPEND_BABEL_HELPERS.format(),()=>babel_helper_1.appendBabelHelpers(i,"","@babel/runtime",o)),o}}exports.BaseGraph=BaseGraph;
1
+ !function(require, directRequire){
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BaseGraph=void 0;const tslib_1=require("tslib"),plugin_driver_1=require("../plugin_driver"),types_1=require("../types"),module_1=(0,tslib_1.__importDefault)(require("../module")),path_1=(0,tslib_1.__importDefault)(require("path")),fs_1=(0,tslib_1.__importDefault)(require("fs")),devtool_1=require("../devtool"),resolver_1=require("../resolver"),white_ext_list_1=require("../../utils/white_ext_list"),common_1=require("../../core/compile/common"),tools_1=require("../../utils/tools"),babel_helper_1=require("../../utils/babel_helper"),recorder_1=require("../recorder"),locales_1=(0,tslib_1.__importDefault)(require("../../utils/locales/locales")),lodash_1=require("lodash"),error_1=require("../error");let MiniProgramWhiteList;function getFileType(e){let t=path_1.default.extname(e);if(t.startsWith(".")){if(t=t.slice(1),t===types_1.FileType.JS)return types_1.FileType.JS;if(t===types_1.FileType.WXML)return types_1.FileType.WXML;if(t===types_1.FileType.WXSS)return types_1.FileType.WXSS;if(t===types_1.FileType.WXS)return types_1.FileType.WXS;if(t===types_1.FileType.JSON)return types_1.FileType.JSON}throw Error("unknown the filetype of "+e)}class BaseGraph{constructor(e){this.invalidated=!0,this.running=!1,this.onFileChange=(e,t)=>{t.startsWith(this.root)&&(t=t.replace(new RegExp("^"+this.root),""),this.resolver.onFileChange(e,t),"change"!==e&&"unlink"!==e||this.invalidateModules(t),this.onFileChangeForGraph(e,t))},this.type=e.type,this.root=e.root,this.rootPath=path_1.default.posix.join(e.compiler.project.projectPath,this.root),this.persistCache=e.persistCache,this.compiler=e.compiler,this.project=this.compiler.project,this.cachedModules=new Map,this.pluginDriver=new plugin_driver_1.PluginDriver(this,e),this.modulesByPath=new Map,this.resolver=new resolver_1.Resolver(this,this.root,this.pluginDriver.resolveExtConf),this.project.event.on("fileChange",this.onFileChange)}destroy(){}clearCache(){this.modulesByPath.clear()}invalidateModules(e){for(const t of this.modulesByPath.values())(t.sourcePath===e||t.depFiles.includes(e))&&this.modulesByPath.delete(t.path)}async loadModuleFromFile(e,t){let i=this.modulesByPath.get(e.path);if(null==i?void 0:i.loadingPromise)return await i.loadingPromise,this.loadModuleFromFile(e,t);let o=!i||i.sourcePath!==e.source||i.independentRoot!==e.independentRoot;if(!o&&(null==i?void 0:i.error)){if(i.loadEnd+1e3>Date.now())return i;o=!0}if(o){const o=getFileType(e.path);i=new module_1.default(this,e.path,e.source,o),i.independentRoot=e.independentRoot,this.modulesByPath.set(e.path,i),i.loadingPromise=t.run(locales_1.default.config.SUMMER_COMPILING_MODULE.format(e.source),()=>this.loadSourceForModule(i)),await i.loadingPromise,i.loadingPromise=void 0}return i}async loadSourceForModule(e){var t;try{const i=path_1.default.posix.join(this.rootPath,e.sourcePath),o=t=>Object.assign(Object.assign({},t),{rootPath:this.rootPath,addWatchFile:t=>{const i=(0,tools_1.normalizePath)(t);if(!i.startsWith(this.rootPath))throw(0,error_1.makeSummerError)(`The file (${t}) required by ${e.sourcePath} is outside the project`,error_1.SummerErrors.SUMMER_PLUGIN_CODE_ERR,e.path);e.addWatchFile(path_1.default.posix.relative(this.rootPath,i))}}),r=null!==(t=await this.pluginDriver.hookFirst("load",[e.path,i,e.independentRoot],o))&&void 0!==t?t:await this.readFile(i),s="string"==typeof r?{sourceCode:r}:r,a=await this.tranform(s,e,o);return e.setSource(a),!0}catch(t){return t.path=path_1.default.posix.join(this.root,e.sourcePath),e.setError(t),!1}}async doCompileSingleCode(e,t){const i=getFileType(e.path),o=new module_1.default(this,e.path,e.source,i);if(await this.loadSourceForModule(o),o.error)throw o.error;return o.target||(o.target=await this.generate(o.source,o)),o.toCodeFile()}async getCodeFiles(e,t,i=!0){const o={};return await Promise.all(e.map(async e=>{if(i&&!this.modulesByPath.get(e.path)&&e.path.endsWith(".js")){const t=await this.persistCache.get(this.project.projectPath,this.root,e);if(t)return console.log("use cache",e.path),o[e.path]=t,void this.loadModuleFromFile(e,recorder_1.silentRecorder)}const r=await this.loadModuleFromFile(e,t);r.error||r.target||(r.target=await this.generate(r.source,r));const s=r.toCodeFile();o[r.path]=s,!("error"in s)&&e.path.endsWith(".js")&&this.persistCache.set(this.project.projectPath,this.root,e,s)})),o}async readFile(e){return fs_1.default.promises.readFile(e,{encoding:"utf-8"})}async tranform(e,t,i){return await this.pluginDriver.hookReduceArg0("transform",[e,t.path,t.sourcePath,t.independentRoot],(function(e,t){return"string"==typeof t?{sourceCode:t}:t}),i)}async generate(e,t){let i=await this.pluginDriver.hookFirst("generate",[e,t.path,t.sourcePath,t.independentRoot]);return void 0===i||(0,lodash_1.isNull)(i)?{code:e.sourceCode,map:e.inputMap}:("string"==typeof i&&(i={code:i}),i)}async compile(e){const{conf:t,jsons:i}=await e.run(locales_1.default.config.SUMMER_COMPILE_JSON.format(),()=>this.compileJSON(e)),o=await this.compileCodeWithoutJSON(e);function r(e,t){return t}const s=await e.run(locales_1.default.config.SUMMER_OPTIMIZE_CODE.format(),()=>this.pluginDriver.hookReduceArg0("optimize",[o,t],r,e=>e)),a=await e.run(locales_1.default.config.SUMMER_PACK_FILES.format(),()=>this.compileOther(Object.keys(i))),l=Object.assign(Object.assign(Object.assign({},a),s),i),n=await e.run(locales_1.default.config.SUMMER_COMPRESS_PACK.format(),()=>this.pluginDriver.hookReduceArg0("compress",[l],(e,t)=>t,e=>e));return await e.run(locales_1.default.config.SUMMER_SEAL_PACK.format(),()=>this.pluginDriver.hookParallel("sealed",[n])),n}async getLocalFileList(){const e=this.getLocalCodeFileList(),t=new Set(this.resolver.allExts.map(e=>"."+e));if(!MiniProgramWhiteList){const e=await(0,white_ext_list_1.getWhiteExtList)();MiniProgramWhiteList=e.MiniProgramWhiteList}const i=this.project.getFileList(this.root,"").filter(e=>{const i=path_1.default.posix.extname(e);return MiniProgramWhiteList.has(i)&&!t.has(i)}).map(e=>e.replace(new RegExp("^"+this.root),"")),o={};for(const t of e.concat(i))o[t]={size:this.project.getFileSize(this.root,t)};return o}async compileOther(e){const t=new Set(this.resolver.allExts.map(e=>"."+e));if(t.delete(".json"),!MiniProgramWhiteList){const e=await(0,white_ext_list_1.getWhiteExtList)();MiniProgramWhiteList=e.MiniProgramWhiteList}const i=this.project.getFileList(this.root,"").filter(e=>{const i=path_1.default.posix.extname(e);return MiniProgramWhiteList.has(i)&&!t.has(i)}),o=await(0,common_1.compileOther)(this.project,i,{onProgressUpdate:()=>{}}),r={};for(const t in o){const i=path_1.default.posix.relative(this.root,t);e.includes(i)||(r[i]=o[t])}return r}async compileCodeWithoutJSON(e){var t;const i={},o=await this.getProdCode(e,{package:devtool_1.FullPkg}),r=new Set;for(const e in o){const s=o[e];if("error"in s)throw s.error;if(s.path.endsWith(".js")){((null===(t=s.jsTag)||void 0===t?void 0:t.helpers)||[]).forEach(e=>{r.add(e)}),i[e]=s.code;const o=s.map&&(0,tools_1.formatSourceMap)(s.map);o&&(i[e+".map"]=o)}else i[e]=s.code}return await e.run(locales_1.default.config.SUMMER_APPEND_BABEL_HELPERS.format(),()=>(0,babel_helper_1.appendBabelHelpers)(r,"","@babel/runtime",i)),i}}exports.BaseGraph=BaseGraph;
3
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PluginConf=exports.resolvePath=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),core_1=require("../../core"),locales_1=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"),()=>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 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 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;
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;
3
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PluginGraph=void 0;const recorder_1=require("../recorder"),basegraph_1=require("./basegraph"),pluginconf_1=require("./pluginconf");class PluginGraph extends basegraph_1.BaseGraph{constructor(e){super(e),this.pluginConf=new pluginconf_1.PluginConf(this.compiler,this)}destroy(){this.pluginConf.destroy(),super.destroy()}async getConf(e){if("plugin"!==this.type)throw new Error("Couldn't call getAppConf without plugin type");return await this.pluginConf.build(e),this.conf={plugin:this.pluginConf.plugin,pages:Object.fromEntries(this.pluginConf.pages.entries()),comps:Object.fromEntries(this.pluginConf.comps.entries())},this.conf}async ensureConf(e){this.conf||await this.getConf(e)}async compileSingleCode(e,n){await this.ensureConf(recorder_1.silentRecorder);const t=this.resolver.resolveInfoMap.get(e);if(t)return super.doCompileSingleCode(Object.assign(Object.assign({},t),{independentRoot:this.getIndependentRoot(t.path)}),n);throw new Error("file not found")}async getDevCode(e){await this.ensureConf(e);let n=this.getPackgeFile();return n=n.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(n,e)}async getProdCode(e){await this.ensureConf(e);let n=this.getPackgeFile();return n=n.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(n,e,!1)}onFileChangeForGraph(e,n){}getPackgeFile(){const e=[];for(const[n,t]of this.resolver.resolveInfoMap.entries())e.push(t);return e.map(e=>Object.assign(Object.assign({},e),{independentRoot:this.getIndependentRoot(e.path)}))}getIndependentRoot(e){const n=this.conf.plugin;return"string"==typeof n.workers&&e.startsWith(n.workers)?n.workers:""}async compileJSON(){const e=await this.getConf(recorder_1.silentRecorder),n={};n["plugin.json"]=JSON.stringify(e.plugin);for(const t in e.pages)n[t+".json"]=JSON.stringify(e.pages[t]);for(const t in e.comps)n[t+".json"]=JSON.stringify(e.comps[t]);return{conf:e,jsons:n}}}exports.PluginGraph=PluginGraph;
1
+ !function(require, directRequire){
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PluginGraph=void 0;const recorder_1=require("../recorder"),basegraph_1=require("./basegraph"),pluginconf_1=require("./pluginconf");class PluginGraph extends basegraph_1.BaseGraph{constructor(e){super(e),this.pluginConf=new pluginconf_1.PluginConf(this.compiler,this)}destroy(){this.pluginConf.destroy(),super.destroy()}async getConf(e){if("plugin"!==this.type)throw new Error("Couldn't call getAppConf without plugin type");return await this.pluginConf.build(e),this.conf={plugin:this.pluginConf.plugin,pages:Object.fromEntries(this.pluginConf.pages.entries()),comps:Object.fromEntries(this.pluginConf.comps.entries())},this.conf}async ensureConf(e){this.conf||await this.getConf(e)}async compileSingleCode(e,t){await this.ensureConf(recorder_1.silentRecorder);const n=this.resolver.resolveInfoMap.get(e);if(n)return super.doCompileSingleCode(Object.assign(Object.assign({},n),{independentRoot:this.getIndependentRoot(n.path)}),t);throw new Error("file not found")}async getDevCode(e){await this.ensureConf(e);let t=this.getPackageFile();return t=t.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(t,e)}async getProdCode(e){await this.ensureConf(e);let t=this.getPackageFile();return t=t.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(t,e,!1)}getLocalCodeFileList(){return Array.from(this.resolver.resolveInfoMap.entries()).map(([e,t])=>t.source)}onFileChangeForGraph(e,t){}getPackageFile(){const e=[];for(const[t,n]of this.resolver.resolveInfoMap.entries())e.push(n);return e.map(e=>Object.assign(Object.assign({},e),{independentRoot:this.getIndependentRoot(e.path)}))}getIndependentRoot(e){const t=this.conf.plugin;return"string"==typeof t.workers&&e.startsWith(t.workers)?t.workers:""}async compileJSON(){const e=await this.getConf(recorder_1.silentRecorder),t={};t["plugin.json"]=JSON.stringify(e.plugin);for(const n in e.pages)t[n+".json"]=JSON.stringify(e.pages[n]);for(const n in e.comps)t[n+".json"]=JSON.stringify(e.comps[n]);return{conf:e,jsons:t}}}exports.PluginGraph=PluginGraph;
3
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SummerCompiler=void 0;var devtool_1=require("./devtool");Object.defineProperty(exports,"SummerCompiler",{enumerable:!0,get:function(){return devtool_1.SummerCompiler}});
1
+ !function(require, directRequire){
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SummerCompiler=void 0;var devtool_1=require("./devtool");Object.defineProperty(exports,"SummerCompiler",{enumerable:!0,get:function(){return devtool_1.SummerCompiler}});
3
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.initPlugin=void 0;const tslib_1=require("tslib"),index_1=tslib_1.__importDefault(require("./plugins/index"));function initPlugin(i,e,t){i.startsWith("summer-")&&(i=i.replace("summer-",""));const n=index_1.default[i];if(n)return n(e,t);throw new Error("not found plugin for "+i)}exports.initPlugin=initPlugin;
1
+ !function(require, directRequire){
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.initPlugin=void 0;const tslib_1=require("tslib"),index_1=(0,tslib_1.__importDefault)(require("./plugins/index"));function initPlugin(i,e,t){i.startsWith("summer-")&&(i=i.replace("summer-",""));const n=index_1.default.load(i);if(n)return n(e,t);throw new Error("not found plugin for "+i)}exports.initPlugin=initPlugin;
3
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const types_1=require("./types"),tools_1=require("../utils/tools");class JsTag{constructor(){this.isLargeFile=!1,this.isBabelIgnore=!1,this.helpers=[]}setBabelIgnore(){this.isBabelIgnore=!0}setLargeFile(){this.isLargeFile=!0}addHelpers(e){for(const s of e)this.helpers.includes(s)||this.helpers.push(s)}toJSON(){return{isLargeFile:this.isLargeFile,isBabelIgnore:this.isBabelIgnore,helpers:this.helpers}}}class Module{constructor(e,s,t,i){this.graph=e,this.path=s,this.sourcePath=t,this.fileType=i,this.md5="",this.depFiles=[],this.independentRoot="",this.loadStart=Date.now(),i===types_1.FileType.JS&&(this.jsTag=new JsTag)}setError(e){this.error=e,this.loadEnd=Date.now()}setSource(e){var s,t;this.source=e,e.target&&(this.target=e.target,null===(s=this.jsTag)||void 0===s||s.addHelpers(e.target.helpers||[]),e.target=void 0),e.largeFile&&(null===(t=this.jsTag)||void 0===t||t.setLargeFile()),this.fileType===types_1.FileType.JSON&&(this.json=JSON.parse(this.source.sourceCode)),this.md5=tools_1.generateMD5(this.source.sourceCode),this.loadEnd=Date.now()}toCodeFile(){var e;return this.error?{path:this.path,error:this.error}:Object.assign({path:this.path,md5:this.md5,jsTag:null===(e=this.jsTag)||void 0===e?void 0:e.toJSON()},this.target)}toJSON(){return{code:"",map:void 0,path:this.path,sourcePath:this.sourcePath,depFileIds:this.depFiles}}addWatchFile(e){-1===this.depFiles.indexOf(e)&&this.depFiles.push(e)}}exports.default=Module;
1
+ !function(require, directRequire){
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const types_1=require("./types"),tools_1=require("../utils/tools"),error_1=require("./error");class JsTag{constructor(){this.isLargeFile=!1,this.isBabelIgnore=!1,this.helpers=[]}setBabelIgnore(){this.isBabelIgnore=!0}setLargeFile(){this.isLargeFile=!0}addHelpers(e){for(const s of e)this.helpers.includes(s)||this.helpers.push(s)}toJSON(){return{isLargeFile:this.isLargeFile,isBabelIgnore:this.isBabelIgnore,helpers:this.helpers}}}class Module{constructor(e,s,t,r){this.graph=e,this.path=s,this.sourcePath=t,this.fileType=r,this.md5="",this.depFiles=[],this.independentRoot="",this.loadStart=Date.now(),r===types_1.FileType.JS&&(this.jsTag=new JsTag)}setError(e){this.error=e,this.loadEnd=Date.now()}setSource(e){var s,t;this.source=e,e.target&&(this.target=e.target,null===(s=this.jsTag)||void 0===s||s.addHelpers(e.target.helpers||[]),e.target=void 0),e.largeFile&&(null===(t=this.jsTag)||void 0===t||t.setLargeFile()),this.fileType===types_1.FileType.JSON&&(this.json=JSON.parse(this.source.sourceCode)),this.md5=(0,tools_1.generateMD5)(this.source.sourceCode),this.loadEnd=Date.now()}toCodeFile(){var e;return this.error?this.error instanceof error_1.SummerError?{path:this.path,error:this.error.toJSON()}:{path:this.path,error:this.error}:Object.assign({path:this.path,md5:this.md5,jsTag:null===(e=this.jsTag)||void 0===e?void 0:e.toJSON()},this.target)}toJSON(){return{code:"",map:void 0,path:this.path,sourcePath:this.sourcePath,depFileIds:this.depFiles}}addWatchFile(e){-1===this.depFiles.indexOf(e)&&this.depFiles.push(e)}}exports.default=Module;
3
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),tools_1=require("../utils/tools"),fs=tslib_1.__importStar(require("fs-extra")),path_1=tslib_1.__importDefault(require("path"));class PersistCache{constructor(e){this.cachePath=e}getFilePath(e){const t=tools_1.generateMD5(e);return{cacheFile:path_1.default.join(this.cachePath,t),infoFile:path_1.default.join(this.cachePath,t+".json")}}async get(e){const{cacheFile:t,infoFile:a}=this.getFilePath(e);try{const e=await fs.readFile(a,"utf8"),s=JSON.parse(e);return{data:await fs.readFile(t,{encoding:s.encoding||null}),info:s}}catch(e){}return{}}async set(e,t){var a;const{cacheFile:s,infoFile:i}=this.getFilePath(e);try{const e=(null===(a=t.info)||void 0===a?void 0:a.encoding)||null;await fs.writeFile(s,t.data,e),await fs.writeFile(i,JSON.stringify(t.info),"utf8")}catch(e){}}async remove(e){const{cacheFile:t,infoFile:a}=this.getFilePath(e);try{await fs.unlink(t),await fs.unlink(a)}catch(e){}}async clean(){const e=fs.readdirSync(this.cachePath);await Promise.all(e.map(async e=>{try{await fs.unlink(e)}catch(e){}}))}}class LogicPersistCache{constructor(e,t){this.baseCacheKey=t,this.persistCache=new PersistCache(e)}updateBaseCacheKey(e){this.baseCacheKey!==e&&(this.persistCache.clean(),this.baseCacheKey=e)}getCacheKey(e){return`${e.independentRoot}|${e.source}`}async get(e,t,a){var s;const i=path_1.default.posix.join(e,t,a.path),c=path_1.default.posix.join(e,t,a.source),n=await this.persistCache.get(i);if((null===(s=n.info)||void 0===s?void 0:s.baseCacheKey)===this.baseCacheKey){if(n.info&&n.info.cacheKey===this.getCacheKey(a)){const e=fs.statSync(c);if(n.info.mtimeMs===e.mtimeMs)return console.log("use cache",a.path),JSON.parse(n.data)}}else this.persistCache.remove(i)}async set(e,t,a,s){const i=path_1.default.posix.join(e,t,a.path),c=path_1.default.posix.join(e,t,a.source),n=fs.statSync(c);this.persistCache.set(i,{info:{encoding:"utf8",cacheKey:this.getCacheKey(a),baseCacheKey:this.baseCacheKey,mtimeMs:n.mtimeMs},data:JSON.stringify(s)})}async clean(){this.persistCache.clean()}}exports.default=LogicPersistCache;
1
+ !function(require, directRequire){
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),tools_1=require("../utils/tools"),fs=(0,tslib_1.__importStar)(require("fs-extra")),path_1=(0,tslib_1.__importDefault)(require("path"));class PersistCache{constructor(e){this.cachePath=e}getFilePath(e){const t=(0,tools_1.generateMD5)(e);return{cacheFile:path_1.default.join(this.cachePath,t),infoFile:path_1.default.join(this.cachePath,t+".json")}}async get(e){const{cacheFile:t,infoFile:a}=this.getFilePath(e);try{const e=await fs.readFile(a,"utf8"),s=JSON.parse(e);return{data:await fs.readFile(t,{encoding:s.encoding||null}),info:s}}catch(e){}return{}}async set(e,t){var a;const{cacheFile:s,infoFile:i}=this.getFilePath(e);try{const e=(null===(a=t.info)||void 0===a?void 0:a.encoding)||null;await fs.writeFile(s,t.data,e),await fs.writeFile(i,JSON.stringify(t.info),"utf8")}catch(e){}}async remove(e){const{cacheFile:t,infoFile:a}=this.getFilePath(e);try{await fs.unlink(t),await fs.unlink(a)}catch(e){}}async clean(){const e=fs.readdirSync(this.cachePath);await Promise.all(e.map(async e=>{try{await fs.unlink(path_1.default.join(this.cachePath,e))}catch(e){}}))}}class FakePersistCache{async get(e){return{}}async set(e,t){}async remove(e){}async clean(){}}class LogicPersistCache{constructor(e,t){this.baseCacheKey=t,this.persistCache=e?new PersistCache(e):new FakePersistCache}updateBaseCacheKey(e){this.baseCacheKey!==e&&(this.persistCache.clean(),this.baseCacheKey=e)}getCacheKey(e){return`${e.independentRoot}|${e.source}`}async get(e,t,a){var s;const i=path_1.default.posix.join(e,t,a.path),c=path_1.default.posix.join(e,t,a.source),n=await this.persistCache.get(i);if((null===(s=n.info)||void 0===s?void 0:s.baseCacheKey)===this.baseCacheKey){if(n.info&&n.info.cacheKey===this.getCacheKey(a)){const e=fs.statSync(c);if(n.info.mtimeMs===e.mtimeMs)return console.log("use cache",a.path),JSON.parse(n.data)}}else this.persistCache.remove(i)}async set(e,t,a,s){const i=path_1.default.posix.join(e,t,a.path),c=path_1.default.posix.join(e,t,a.source),n=fs.statSync(c);this.persistCache.set(i,{info:{encoding:"utf8",cacheKey:this.getCacheKey(a),baseCacheKey:this.baseCacheKey,mtimeMs:n.mtimeMs},data:JSON.stringify(s)})}async clean(){this.persistCache.clean()}}exports.default=LogicPersistCache;
3
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PluginDriver=exports.getPluginContext=exports.genResovleExtConf=void 0;const error_1=require("./error"),worker_thread_1=require("../core/worker_thread");function genResovleExtConf(e){const r={json:["json"],wxml:["wxml"],wxss:["wxss"],js:["js"],wxs:["wxs"]};for(const o of e)if(o.resolveExt)for(const e of["json","wxml","wxss","js","wxs"]){const t=o.resolveExt[e];if("string"==typeof t)r[e].includes(t)||r[e].push(t);else if(Array.isArray(t))for(const o of t)r[e].includes(o)||r[e].push(o)}return r}function throwPluginError(e,r,{hook:o,id:t}={}){var s;let n;throw n="string"==typeof e?{message:e}:Object.assign(Object.assign({},e),{message:null!==(s=e.message)&&void 0!==s?s:"Some error happen"}),n.code||(n.code=error_1.SummerErrors.SUMMER_PLUGIN_ERR),n.plugin=r,o&&(n.hook=o),t&&!n.path&&(n.path=t),e.stack&&(n.stack=e.stack),n}function getPluginContext(e,r){return{addWatchFile(){throw new Error("addWatchFile should be implemented by replaceContext")},async runWorkerMethod(o,...t){const s={command:"runMethod",plugin:e.name,projectPath:r.project.projectPath,pluginOption:{},method:o,args:t},n=await worker_thread_1.runTask(worker_thread_1.TASK_NAME.SUMMER_HOOK,s);if(n.error)throw n.error;return n.result},error:r=>throwPluginError(r,e.name)}}exports.genResovleExtConf=genResovleExtConf,exports.getPluginContext=getPluginContext;class PluginDriver{constructor(e,r){this.graph=e,this.options=r,this.pluginContexts=new Map,this.plugins=r.plugins,this.resolveExtConf=genResovleExtConf(r.plugins);for(const r of this.plugins)this.pluginContexts.set(r,getPluginContext(r,e))}runHook(e,r,o,t){const s=o[e];if(!s)return;let n=this.pluginContexts.get(o);return t&&(n=t(n,o)),Promise.resolve().then(()=>s.apply(n,r)).catch(r=>throwPluginError(r,o.name,{hook:e}))}hookFirst(e,r,o){let t=Promise.resolve(void 0);for(const s of this.plugins)t=t.then(t=>null!=t?t:this.runHook(e,r,s,o));return t}hookParallel(e,r,o){const t=[];for(const s of this.plugins){const n=this.runHook(e,r,s,o);n&&t.push(n)}return Promise.all(t).then(()=>{})}hookReduceArg0(e,[r,...o],t,s){let n=Promise.resolve(r);for(const r of this.plugins)n=n.then(n=>{const i=[n,...o],l=this.runHook(e,i,r,s);return l?l.then(e=>t.call(this.pluginContexts.get(r),n,e,r)):n});return n}}exports.PluginDriver=PluginDriver;
1
+ !function(require, directRequire){
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PluginDriver=exports.getPluginContext=exports.genResovleExtConf=void 0;const error_1=require("./error"),worker_thread_1=require("../core/worker_thread");function genResovleExtConf(r){const e={json:["json"],wxml:["wxml"],wxss:["wxss"],js:["js"],wxs:["wxs"]};for(const o of r)if(o.resolveExt)for(const r of["json","wxml","wxss","js","wxs"]){const t=o.resolveExt[r];if("string"==typeof t)e[r].includes(t)||e[r].push(t);else if(Array.isArray(t))for(const o of t)e[r].includes(o)||e[r].push(o)}return e}function throwPluginError(r,e,{hook:o,id:t}={}){const n=(0,error_1.makeSummerError)(r);throw n.code||(n.code=error_1.SummerErrors.SUMMER_PLUGIN_ERR),n.plugin=e,o&&(n.hook=o),t&&!n.path&&(n.path=t),r.stack&&(n.stack=r.stack),n}function getPluginContext(r,e){return{addWatchFile(){throw new Error("addWatchFile should be implemented by replaceContext")},async runWorkerMethod(o,...t){const n={command:"runMethod",plugin:r.name,projectPath:e.project.projectPath,pluginOption:{},method:o,args:t},s=await(0,worker_thread_1.runTask)(worker_thread_1.TASK_NAME.SUMMER_HOOK,n);if(s.error){if("SummerError"===s.error.type)throw new error_1.SummerError(s.error);throw s.error}return s.result},error:e=>throwPluginError(e,r.name)}}exports.genResovleExtConf=genResovleExtConf,exports.getPluginContext=getPluginContext;class PluginDriver{constructor(r,e){this.graph=r,this.options=e,this.pluginContexts=new Map,this.plugins=e.plugins,this.resolveExtConf=genResovleExtConf(e.plugins);for(const e of this.plugins)this.pluginContexts.set(e,getPluginContext(e,r))}runHook(r,e,o,t){const n=o[r];if(!n)return;let s=this.pluginContexts.get(o);return t&&(s=t(s,o)),Promise.resolve().then(()=>n.apply(s,e)).catch(e=>throwPluginError(e,o.name,{hook:r}))}hookFirst(r,e,o){let t=Promise.resolve(void 0);for(const n of this.plugins)t=t.then(t=>null!=t?t:this.runHook(r,e,n,o));return t}hookParallel(r,e,o){const t=[];for(const n of this.plugins){const s=this.runHook(r,e,n,o);s&&t.push(s)}return Promise.all(t).then(()=>{})}hookReduceArg0(r,[e,...o],t,n){let s=Promise.resolve(e);for(const e of this.plugins)s=s.then(s=>{const i=[s,...o],l=this.runHook(r,i,e,n);return l?l.then(r=>t.call(this.pluginContexts.get(e),s,r,e)):s});return s}}exports.PluginDriver=PluginDriver;
3
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.transformES6ModuleAndGenCode=exports.getBabelRoot=void 0;const types_1=require("../../types"),config_1=require("../../../config"),babel_helper_1=require("../../../utils/babel_helper"),tools_1=require("../../../utils/tools"),pluginTransformModulesCommonjs=()=>require("@babel/plugin-transform-modules-commonjs"),babel7=()=>require("@babel/core");function getES6ModulePluginsList(e){return[[require("@babel/plugin-transform-modules-commonjs"),{allowTopLevelThis:e,importInterop:e=>e.startsWith("@babel/runtime/helpers/")?"node":"babel"}]]}function getBabelRoot(e){return""===e?"@babel/runtime":tools_1.normalizePath(e+"/@babel/runtime")}function transformES6ModuleAndGenCode(e,o,r){const t=/^\s*\/\/\s?use strict disable;/i.test(e.sourceCode||"");let s;try{const r={babelrc:!1,plugins:getES6ModulePluginsList(t),filename:o,sourceFileName:o,sourceMaps:!0,inputSourceMap:e.inputMap,configFile:!1,code:!0,cloneInputAst:!0},n=require("@babel/core");if(e.astInfo){if(e.astInfo.type!==types_1.AstType.Babel)throw new Error("ast type is not babel");s=n.transformFromAstSync(e.astInfo.ast,e.sourceCode,r)}else{if(null===e.sourceCode)throw new Error("source.sourceCode is null");s=n.transform(e.sourceCode,r)}}catch(e){throw e.code=config_1.BABEL_TRANS_JS_ERR,e.message=`file: ${o}\n ${e.message}`,e.path=o,e}if(!s)throw new Error("no trans result for callPostEnhance");let n=s.code;const l=s.map;t&&(n=n.replace(/^"use strict";/,""));const a=babel_helper_1.collectBabelHelpers(e.sourceCode),u=babel_helper_1.replaceBabelHelpers(n,a,o,r);return{code:u.transformCode,map:l,helpers:u.helpers}}function default_1(){return{name:"summer-es6module",workerMethods:{transformES6ModuleAndGenCode:transformES6ModuleAndGenCode},async generate(e,o,r,t){if(o.endsWith(".js")&&!e.largeFile){const o=getBabelRoot(t);return this.runWorkerMethod("transformES6ModuleAndGenCode",e,r,o)}}}}exports.getBabelRoot=getBabelRoot,exports.transformES6ModuleAndGenCode=transformES6ModuleAndGenCode,exports.default=default_1;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.transformES6ModuleAndGenCode=exports.getBabelRoot=void 0;const types_1=require("../../types"),config_1=require("../../../config"),babel_helper_1=require("../../../utils/babel_helper"),tools_1=require("../../../utils/tools"),pluginTransformModulesCommonjs=()=>require("@babel/plugin-transform-modules-commonjs"),babel7=()=>require("@babel/core");function getES6ModulePluginsList(e){return[[require("@babel/plugin-transform-modules-commonjs"),{allowTopLevelThis:e,importInterop:e=>e.startsWith("@babel/runtime/helpers/")?"node":"babel"}]]}function getBabelRoot(e){return""===e?"@babel/runtime":(0,tools_1.normalizePath)(e+"/@babel/runtime")}function transformES6ModuleAndGenCode(e,o,r,t){let s;t=t||/^\s*\/\/\s?use strict disable;/i.test(e.sourceCode||"");try{const r={babelrc:!1,plugins:getES6ModulePluginsList(t),filename:o,sourceFileName:o,sourceMaps:!0,inputSourceMap:e.inputMap,configFile:!1,code:!0,cloneInputAst:!0},n=require("@babel/core");if(e.astInfo){if(e.astInfo.type!==types_1.AstType.Babel)throw new Error("ast type is not babel");s=n.transformFromAstSync(e.astInfo.ast,e.sourceCode,r)}else{if(null===e.sourceCode)throw new Error("source.sourceCode is null");s=n.transform(e.sourceCode,r)}}catch(e){throw e.code=config_1.BABEL_TRANS_JS_ERR,e.message=`file: ${o}\n ${e.message}`,e.path=o,e}if(!s)throw new Error("no trans result for callPostEnhance");let n=s.code;const l=s.map;t&&(n=n.replace(/^"use strict";/,""));const a=(0,babel_helper_1.collectBabelHelpers)(e.sourceCode),u=(0,babel_helper_1.replaceBabelHelpers)(n,a,o,r);return{code:u.transformCode,map:l,helpers:u.helpers}}function default_1(e,o){return{name:"summer-es6module",workerMethods:{transformES6ModuleAndGenCode:transformES6ModuleAndGenCode},async generate(e,r,t,s){if(r.endsWith(".js")&&!e.largeFile){const r=getBabelRoot(s);return this.runWorkerMethod("transformES6ModuleAndGenCode",e,t,r,o.disableUseStrict)}}}}exports.getBabelRoot=getBabelRoot,exports.transformES6ModuleAndGenCode=transformES6ModuleAndGenCode,exports.default=default_1;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MAX_CODE_LENGTH=void 0;const tslib_1=require("tslib"),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),path_1=tslib_1.__importDefault(require("path")),jsonParse_1=require("../../../utils/jsonParse"),sourcemap=()=>require("source-map");async function tryGetInputSourceMap(e,t){try{const s=/\/\/[#|@] sourceMappingURL=[\s]*(\S*)[\s]*$/m.exec(e),r=path_1.default.posix.dirname(t),a=path_1.default.posix.basename(t);let o;if(null==s?void 0:s[1])if(/\.js\.map$/.test(s[1]))o=await fs_extra_1.default.readFile(path_1.default.posix.join(r,s[1]),"utf-8");else{const e=s[1].split("base64,")[1];o=Buffer.from(e,"base64").toString()}else{const e=path_1.default.posix.join(r,a+".map");fs_extra_1.default.existsSync(e)&&(o=await fs_extra_1.default.readFile(e,"utf-8"))}if(o){const e=jsonParse_1.jsonParse(o);new(require("source-map").SourceMapConsumer)(e);return await insertSourcesContent(e,t),e}}catch(e){console.log(`try to get input sourcemap of ${t} catch error ${e}`)}}exports.MAX_CODE_LENGTH=512e3;const insertSourcesContent=async(e,t)=>{if(Array.isArray(e.sources)&&!Array.isArray(e.sourcesContent)){const s=e.sourcesContent;try{const s=path_1.default.posix.dirname(t),r=[],a=e.sources;for(const e of a){const t=await fs_extra_1.default.readFile(path_1.default.posix.join(s,e),"utf-8");r.push(t)}e.sourcesContent=r}catch(t){e.sourcesContent=s}}};function default_1(){return{name:"summer-javascript",async load(e,t){if(t.endsWith(".js")){const e=await fs_extra_1.default.readFile(t,{encoding:"utf-8"}),s=await tryGetInputSourceMap(e,t);return{sourceCode:e,inputMap:null!=s?s:void 0,astInfo:void 0,largeFile:e.length>=exports.MAX_CODE_LENGTH}}}}}exports.default=default_1;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MAX_CODE_LENGTH=void 0;const tslib_1=require("tslib"),fs_extra_1=(0,tslib_1.__importDefault)(require("fs-extra")),path_1=(0,tslib_1.__importDefault)(require("path")),jsonParse_1=require("../../../utils/jsonParse"),sourcemap=()=>require("source-map");async function tryGetInputSourceMap(e,t){try{const s=/\/\/[#|@] sourceMappingURL=[\s]*(\S*)[\s]*$/m.exec(e),r=path_1.default.posix.dirname(t),a=path_1.default.posix.basename(t);let o;if(null==s?void 0:s[1])if(/\.js\.map$/.test(s[1]))o=await fs_extra_1.default.readFile(path_1.default.posix.join(r,s[1]),"utf-8");else{const e=s[1].split("base64,")[1];o=Buffer.from(e,"base64").toString()}else{const e=path_1.default.posix.join(r,a+".map");fs_extra_1.default.existsSync(e)&&(o=await fs_extra_1.default.readFile(e,"utf-8"))}if(o){const e=(0,jsonParse_1.jsonParse)(o);new(require("source-map").SourceMapConsumer)(e);return await insertSourcesContent(e,t),e}}catch(e){console.log(`try to get input sourcemap of ${t} catch error ${e}`)}}exports.MAX_CODE_LENGTH=512e3;const insertSourcesContent=async(e,t)=>{if(Array.isArray(e.sources)&&!Array.isArray(e.sourcesContent)){const s=e.sourcesContent;try{const s=path_1.default.posix.dirname(t),r=[],a=e.sources;for(const e of a){const t=await fs_extra_1.default.readFile(path_1.default.posix.join(s,e),"utf-8");r.push(t)}e.sourcesContent=r}catch(t){e.sourcesContent=s}}};function default_1(){return{name:"summer-javascript",async load(e,t){if(t.endsWith(".js")){const e=await fs_extra_1.default.readFile(t,{encoding:"utf-8"}),s=await tryGetInputSourceMap(e,t);return{sourceCode:e,inputMap:null!=s?s:void 0,astInfo:void 0,largeFile:e.length>=exports.MAX_CODE_LENGTH}}}}}exports.default=default_1;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),postcss_1=tslib_1.__importDefault(require("postcss")),autoprefixer_1=tslib_1.__importDefault(require("autoprefixer")),cssnano_1=tslib_1.__importDefault(require("cssnano")),tools_1=require("../../../utils/tools"),config_1=require("../../../config"),log_1=tslib_1.__importDefault(require("../../../utils/log"));function default_1(e){const{autoPrefix:s=!0,minify:t=!0}=e||{},r=["iOS >= 8","Chrome >= 37"];return{name:"summer-wxss",async optimize(e){const o={};if(s||t)for(const i of Object.keys(e).filter(e=>e.endsWith(".wxss")))try{const l=[];s&&l.push(autoprefixer_1.default({browsers:r,remove:!1})),t&&l.push(cssnano_1.default({preset:["default",{reduceTransforms:!1,calc:!1,minifySelectors:!1,normalizeUrl:!1}]}));const a=await postcss_1.default(l).process(e[i],{from:tools_1.leading(i,"/")});o[i]=a.css.replace(/\r\n/g,"\n")}catch(e){throw log_1.default.error("postcss error @ "+i),log_1.default.error(e),{code:config_1.POST_WXSS_ERR,path:i,message:e.message}}return Object.assign(Object.assign({},e),o)}}}exports.default=default_1;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),postcss_1=(0,tslib_1.__importDefault)(require("postcss")),autoprefixer_1=(0,tslib_1.__importDefault)(require("autoprefixer")),cssnano_1=(0,tslib_1.__importDefault)(require("cssnano")),tools_1=require("../../../utils/tools"),config_1=require("../../../config"),log_1=(0,tslib_1.__importDefault)(require("../../../utils/log")),error_1=require("../../error");function default_1(e,r){const{autoPrefix:s=!0,minify:t=!0}=r||{},o=["iOS >= 8","Chrome >= 37"];return{name:"summer-wxss",async optimize(e){const r={};if(s||t)for(const i of Object.keys(e).filter(e=>e.endsWith(".wxss")))try{const u=[];s&&u.push((0,autoprefixer_1.default)({overrideBrowserslist:o,remove:!1})),t&&u.push((0,cssnano_1.default)({preset:["default",{reduceTransforms:!1,calc:!1,minifySelectors:!1,normalizeUrl:!1}]}));const l=await(0,postcss_1.default)(u).process(e[i],{from:(0,tools_1.leading)(i,"/")});r[i]=l.css.replace(/\r\n/g,"\n")}catch(e){throw log_1.default.error(e),(0,error_1.makeSummerError)(e,config_1.POST_WXSS_ERR,i)}return Object.assign(Object.assign({},e),r)}}}process.env.BROWSERSLIST=process.env.BROWSERSLIST||"iOS >= 8, Chrome >= 37",exports.default=default_1;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const types_1=require("../types"),config_1=require("../../config"),babel_helper_1=require("../../utils/babel_helper"),es6module_1=require("./base/es6module"),_transformRuntimeCustom=()=>require("../../utils/babel_transform_plugin"),_pluginTransformRuntime=()=>require("@babel/plugin-transform-runtime"),babel7=()=>require("@babel/core"),_presetEnv=()=>require("@babel/preset-env");function getEnhancePluginsList(){return[[require("../../utils/babel_transform_plugin")],[require("@babel/plugin-transform-runtime"),{corejs:!1,helpers:!0,regenerator:!0,version:"7.12.1"}]].concat(babel_helper_1.getCustomPlugins([]))}const enhance=(e,r)=>{const t=babel7();let s;try{const n={presets:[[require("@babel/preset-env"),{targets:{chrome:53,ios:8},modules:!1,include:["@babel/plugin-transform-computed-properties"]}]],babelrc:!1,plugins:getEnhancePluginsList(),sourceFileName:r,inputSourceMap:!1,configFile:!1,code:!1,ast:!0,cloneInputAst:!1};if(e.astInfo){if(e.astInfo.type!==types_1.AstType.Babel)throw new Error("ast type is not babel");s=t.transformFromAstSync(e.astInfo.ast,e.sourceCode,n)}else{if(null===e.sourceCode)throw new Error("source.targetCode is null");s=babel7().transform(e.sourceCode,n)}}catch(e){const t=`file: ${r}\n ${e.message}`,s=new Error(t);throw s.code=config_1.BABEL_TRANS_JS_ERR,s}return{sourceCode:e.sourceCode,inputMap:e.inputMap,astInfo:{ast:s.ast,type:types_1.AstType.Babel}}};function default_1(){return{name:"summer-enhance",workerMethods:{doTransform(e,r,t){const s=enhance(e,r),n=es6module_1.transformES6ModuleAndGenCode(s,r,t);return Object.assign(Object.assign({},s),{target:n})}},async transform(e,r,t,s){if(r.endsWith(".js")&&!e.largeFile){const r=es6module_1.getBabelRoot(s);return await this.runWorkerMethod("doTransform",e,t,r)}return e}}}exports.default=default_1;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const types_1=require("../types"),config_1=require("../../config"),babel_helper_1=require("../../utils/babel_helper"),es6module_1=require("./base/es6module"),_transformRuntimeCustom=()=>require("../../utils/babel_transform_plugin"),_pluginTransformRuntime=()=>require("@babel/plugin-transform-runtime"),babel7=()=>require("@babel/core"),_presetEnv=()=>require("@babel/preset-env");function getEnhancePluginsList(){return[[require("../../utils/babel_transform_plugin")],[require("@babel/plugin-transform-runtime"),{corejs:!1,helpers:!0,regenerator:!0,version:"7.12.1"}]].concat((0,babel_helper_1.getCustomPlugins)([]))}const enhance=(e,r)=>{const t=babel7();let s;try{const n={presets:[[require("@babel/preset-env"),{targets:{chrome:53,ios:8},modules:!1,include:["@babel/plugin-transform-computed-properties"]}]],babelrc:!1,plugins:getEnhancePluginsList(),sourceFileName:r,inputSourceMap:!1,configFile:!1,code:!1,ast:!0,cloneInputAst:!1};if(e.astInfo){if(e.astInfo.type!==types_1.AstType.Babel)throw new Error("ast type is not babel");s=t.transformFromAstSync(e.astInfo.ast,e.sourceCode,n)}else{if(null===e.sourceCode)throw new Error("source.targetCode is null");s=babel7().transform(e.sourceCode,n)}}catch(e){const t=`file: ${r}\n ${e.message}`,s=new Error(t);throw s.code=config_1.BABEL_TRANS_JS_ERR,s}return{sourceCode:e.sourceCode,inputMap:e.inputMap,astInfo:{ast:s.ast,type:types_1.AstType.Babel}}};function default_1(e,r){return{name:"summer-enhance",workerMethods:{doTransform(e,r,t,s){const n=enhance(e,r),o=(0,es6module_1.transformES6ModuleAndGenCode)(n,r,t,s);return Object.assign(Object.assign({},n),{target:o})}},async transform(e,t,s,n){if(t.endsWith(".js")&&!e.largeFile){const t=(0,es6module_1.getBabelRoot)(n);return await this.runWorkerMethod("doTransform",e,s,t,r.disableUseStrict)}return e}}}exports.default=default_1;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),typescript_1=tslib_1.__importDefault(require("./typescript")),sass_1=tslib_1.__importDefault(require("./sass")),less_1=tslib_1.__importDefault(require("./less")),enhance_1=tslib_1.__importDefault(require("./enhance")),terser_1=tslib_1.__importDefault(require("./terser")),javascript_1=tslib_1.__importDefault(require("./base/javascript")),wxss_1=tslib_1.__importDefault(require("./base/wxss")),es6module_1=tslib_1.__importDefault(require("./base/es6module"));exports.default={typescript:typescript_1.default,less:less_1.default,sass:sass_1.default,enhance:enhance_1.default,javascript:javascript_1.default,terser:terser_1.default,wxss:wxss_1.default,es6module:es6module_1.default};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const typescript=()=>require("./typescript"),sass=()=>require("./sass"),less=()=>require("./less"),enhance=()=>require("./enhance"),terser=()=>require("./terser"),javascript=()=>require("./base/javascript"),wxss=()=>require("./base/wxss"),es6module=()=>require("./base/es6module"),plugins={typescript:typescript,less:less,sass:sass,enhance:enhance,javascript:javascript,terser:terser,wxss:wxss,es6module:es6module};exports.default={load:e=>e in plugins?plugins[e]().default:null};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.importWxssCssReg=exports.importWxssReg=void 0;const tslib_1=require("tslib"),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),path_1=tslib_1.__importDefault(require("path")),error_1=require("../error"),less=()=>require("less");function default_1(s,e){return{name:"summer-less",resolveExt:{wxss:"less"},async load(r,t){var o;if(t.endsWith(".less")){let r=await fs_extra_1.default.readFile(t,"utf-8");const i=[];r=r.replace(exports.importWxssReg,(s,e,r)=>(i.push(r),s.replace(r,r+"?css")));try{const a=await require("less").render(r,{sourceMap:{outputSourceFiles:!0},filename:t,globalVars:null!==(o=null==e?void 0:e.globalVars)&&void 0!==o?o:{}}),l=a.css.replace(exports.importWxssCssReg,(s,e,r)=>{const t=r.slice(0,-4);return i.includes(t)?s.replace(r,t):s});if(a.imports.length)for(const s of a.imports)this.addWatchFile(s);const p=JSON.parse(a.map);return p.sources=p.sources.map(e=>path_1.default.posix.relative(s,e)),{sourceCode:l,inputMap:p}}catch(s){throw{message:s.toString(),code:error_1.SummerErrors.SUMMER_PLUGIN_CODE_ERR}}}}}}exports.importWxssReg=/(?:^|\s)?(?:@import)(?:\s*)?(["'])([^"']+.wxss)\1(?:\s*);/g,exports.importWxssCssReg=/(?:^|\s)?(?:@import)(?:\s*)?(["'])([^"']+.wxss\?css)\1(?:\s*);/g,exports.default=default_1;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.importWxssCssReg=exports.importWxssReg=void 0;const tslib_1=require("tslib"),fs_extra_1=(0,tslib_1.__importDefault)(require("fs-extra")),path_1=(0,tslib_1.__importDefault)(require("path")),error_1=require("../error"),less=()=>require("less");function default_1(s,e){return{name:"summer-less",resolveExt:{wxss:"less"},async load(r,t){var o;if(t.endsWith(".less")){let r=await fs_extra_1.default.readFile(t,"utf-8");const a=[];r=r.replace(exports.importWxssReg,(s,e,r)=>(a.push(r),s.replace(r,r+"?css")));try{const i=await require("less").render(r,{sourceMap:{outputSourceFiles:!0},paths:this.rootPath?[this.rootPath]:[],filename:t,globalVars:null!==(o=null==e?void 0:e.globalVars)&&void 0!==o?o:{}}),l=i.css.replace(exports.importWxssCssReg,(s,e,r)=>{const t=r.slice(0,-4);return a.includes(t)?s.replace(r,t):s});if(i.imports.length)for(const s of i.imports)this.addWatchFile(s);let p=void 0;return i.map&&(p=JSON.parse(i.map),p.sources=p.sources.map(e=>path_1.default.posix.relative(s,e))),{sourceCode:l,inputMap:p}}catch(s){throw(0,error_1.makeSummerError)(s,error_1.SummerErrors.SUMMER_PLUGIN_CODE_ERR)}}}}}exports.importWxssReg=/(?:^|\s)?(?:@import)(?:\s*)?(["'])([^"']+.wxss)\1(?:\s*);/g,exports.importWxssCssReg=/(?:^|\s)?(?:@import)(?:\s*)?(["'])([^"']+.wxss\?css)\1(?:\s*);/g,exports.default=default_1;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.random=void 0;const tslib_1=require("tslib"),tools_1=require("../../utils/tools"),error_1=require("../error"),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),path_1=tslib_1.__importDefault(require("path")),sass=()=>require("sass");function random(){return tools_1.generateMD5(`${Math.random()}${Date.now()}`)}exports.random=random;const importWxssReg=/(?:^|\s)?(?:@import)(?:\s*)?(["'])([^"']+.wxss)\1(?:\s*);/g,importCssReg=/(?:^|\s)?(?:@import)(?:\s*)?(["'])([^"']+.css)\1(?:\s*);/g;function default_1(s){return{name:"summer-sass",resolveExt:{wxss:["sass","scss"]},async load(e,t){if(t.endsWith(".scss")||t.endsWith(".sass")){let e=await fs_extra_1.default.readFile(t,"utf-8");const r=[];e=e.replace(importWxssReg,(s,e,t)=>(r.push(t),s.replace(t,t.slice(0,-4)+"css")));const o=path_1.default.posix.dirname(path_1.default.relative(s,t));return new Promise((s,a)=>{require("sass").render({file:t,data:e,sourceMap:!0,sourceMapContents:!0,omitSourceMapUrl:!0,outFile:t.slice(0,-5)+".wxss"},(e,i)=>{if(e){const s={message:e.message,code:error_1.SummerErrors.SUMMER_PLUGIN_CODE_ERR};return void a(s)}const n=i.css.toString("utf-8").replace(importCssReg,(s,e,t)=>{const o=t.slice(0,-3)+"wxss";return r.includes(o)?s.replace(t,o):s});if(i.stats.includedFiles.length>0)for(const s of i.stats.includedFiles)s!==t&&this.addWatchFile(s);const u=i.map?JSON.parse(i.map.toString("utf-8")):void 0;u&&(u.sourceRoot=o),s({sourceCode:n,inputMap:u})})})}}}}exports.default=default_1;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.random=void 0;const tslib_1=require("tslib"),tools_1=require("../../utils/tools"),error_1=require("../error"),fs_extra_1=(0,tslib_1.__importDefault)(require("fs-extra")),path_1=(0,tslib_1.__importDefault)(require("path")),sass=()=>require("sass");function random(){return(0,tools_1.generateMD5)(`${Math.random()}${Date.now()}`)}exports.random=random;const importWxssReg=/(?:^|\s)?(?:@import)(?:\s*)?(["'])([^"']+.wxss)\1(?:\s*);/g,importCssReg=/(?:^|\s)?(?:@import)(?:\s*)?(["'])([^"']+.css)\1(?:\s*);/g;function default_1(s){return{name:"summer-sass",resolveExt:{wxss:["sass","scss"]},async load(e,r){if(r.endsWith(".scss")||r.endsWith(".sass")){let e=await fs_extra_1.default.readFile(r,"utf-8");const t=[];e=e.replace(importWxssReg,(s,e,r)=>(t.push(r),s.replace(r,r.slice(0,-4)+"css")));const o=path_1.default.posix.dirname(path_1.default.relative(s,r));return new Promise((s,a)=>{require("sass").render({file:r,data:e,sourceMap:!0,sourceMapContents:!0,omitSourceMapUrl:!0,outFile:r.slice(0,-5)+".wxss",includePaths:this.rootPath?[this.rootPath]:[]},(e,i)=>{if(e){const s=(0,error_1.makeSummerError)(e,error_1.SummerErrors.SUMMER_PLUGIN_CODE_ERR);return void a(s)}if(!i)return void a(new Error("no result"));const n=i.css.toString("utf-8").replace(importCssReg,(s,e,r)=>{const o=r.slice(0,-3)+"wxss";return t.includes(o)?s.replace(r,o):s});if(i.stats.includedFiles.length>0)for(const s of i.stats.includedFiles)s!==r&&this.addWatchFile(s);const u=i.map?JSON.parse(i.map.toString("utf-8")):void 0;u&&(u.sourceRoot=o),s({sourceCode:n,inputMap:u})})})}}}}exports.default=default_1;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const config_1=require("../../config"),javascript_1=require("./base/javascript"),terser=()=>require("terser"),babelCodeFrame=()=>require("babel-code-frame");function default_1(){return{name:"summer-terser",workerMethods:{doCompress:async(e,r)=>require("terser").minify(e,{toplevel:!0,compress:{drop_console:!1},sourceMap:r})},async compress(e){const r=Object.keys(e).filter(e=>e.endsWith(".js")),s={};return await Promise.all(r.map(async r=>{if(e[r].length>=javascript_1.MAX_CODE_LENGTH)return s[r]=e[r],void(e[r+".map"]&&(s[r+".map"]=e[r+".map"]));const o=e[r+".map"]?{includeSources:!0,content:JSON.parse(e[r+".map"]),filename:r}:{includeSources:!0,content:void 0,filename:r},a=await this.runWorkerMethod("doCompress",e[r],o);if(a.error){const s=a.error;throw{message:`file: ${r}\n ${a.error.message}\n ${require("babel-code-frame")(e[r],s.line,s.col>0?s.col:1)}`,code:config_1.UGLIFY_JS_ERR}}s[r]=a.code,a.map&&(s[r+".map"]=a.map)})),Object.assign(Object.assign({},e),s)}}}exports.default=default_1;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const config_1=require("../../config"),javascript_1=require("./base/javascript"),error_1=require("../error"),terser=()=>require("terser"),babelCodeFrame=()=>require("babel-code-frame");function default_1(){return{name:"summer-terser",workerMethods:{doCompress:async(e,r)=>require("terser").minify(e,{toplevel:!0,compress:{drop_console:!1},sourceMap:r})},async compress(e){const r=Object.keys(e).filter(e=>e.endsWith(".js")),o={};return await Promise.all(r.map(async r=>{if(e[r].length>=javascript_1.MAX_CODE_LENGTH)return o[r]=e[r],void(e[r+".map"]&&(o[r+".map"]=e[r+".map"]));const s=e[r+".map"]?{includeSources:!0,content:JSON.parse(e[r+".map"]),filename:r}:{includeSources:!0,content:void 0,filename:r},a=await this.runWorkerMethod("doCompress",e[r],s);if(a.error){const o=a.error,s=`file: ${r}\n ${a.error.message}\n ${require("babel-code-frame")(e[r],o.line,o.col>0?o.col:1)}`;throw(0,error_1.makeSummerError)(s,config_1.UGLIFY_JS_ERR,r)}o[r]=a.code,a.map&&(o[r+".map"]=a.map)})),Object.assign(Object.assign({},e),o)}}}exports.default=default_1;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),types_1=require("../types"),fs_1=tslib_1.__importDefault(require("fs")),error_1=require("../error"),babel7=()=>require("@babel/core"),pluginTransformTypescript=()=>require("@babel/plugin-transform-typescript");function default_1(){return{name:"summer-typescript",resolveExt:{js:"ts"},workerMethods:{doTransform(e,r){let t;try{t=require("@babel/core").transform(e,{babelrc:!1,plugins:[[require("@babel/plugin-transform-typescript"),{}]],sourceFileName:r,sourceMaps:!1,ast:!0,configFile:!1,code:!1})}catch(e){throw error_1.makeSummerError(e,error_1.SummerErrors.SUMMER_PLUGIN_CODE_ERR,r)}return{sourceCode:e,inputMap:void 0,astInfo:{ast:t.ast,type:types_1.AstType.Babel}}}},async load(e,r){if(r.endsWith(".ts")){const e=fs_1.default.readFileSync(r,{encoding:"utf-8"});return await this.runWorkerMethod("doTransform",e,r)}}}}exports.default=default_1;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),types_1=require("../types"),fs_1=(0,tslib_1.__importDefault)(require("fs")),error_1=require("../error"),babel7=()=>require("@babel/core"),pluginTransformTypescript=()=>require("@babel/plugin-transform-typescript"),pluginReplaceTsExportAssignment=e=>{const r=e.template("\n module.exports = ASSIGNMENT;\n ");return{name:"replace-ts-export-assignment",visitor:{TSExportAssignment(e){e.replaceWith(r({ASSIGNMENT:e.node.expression}))}}}},pluginReplaceTsImportEqualsDeclaration=e=>{const r=e.template("\n const ID = require(SOURCE);\n ");return{name:"replace-ts-import-equals-declaration",visitor:{TSImportEqualsDeclaration(e){e.replaceWith(r({ID:e.node.id,SOURCE:e.node.moduleReference.expression}))}}}};function default_1(){return{name:"summer-typescript",resolveExt:{js:"ts"},workerMethods:{doTransform(e,r){let t;try{t=require("@babel/core").transform(e,{babelrc:!1,plugins:[[pluginReplaceTsImportEqualsDeclaration,{}],[pluginReplaceTsExportAssignment,{}],[require("@babel/plugin-transform-typescript"),{}]],sourceFileName:r,sourceMaps:!1,ast:!0,configFile:!1,code:!1})}catch(e){throw(0,error_1.makeSummerError)(e,error_1.SummerErrors.SUMMER_PLUGIN_CODE_ERR,r)}return{sourceCode:e,inputMap:void 0,astInfo:{ast:t.ast,type:types_1.AstType.Babel}}}},async load(e,r){if(r.endsWith(".ts")){const e=fs_1.default.readFileSync(r,{encoding:"utf-8"});return await this.runWorkerMethod("doTransform",e,r)}}}}exports.default=default_1;
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Project=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),fs_1=tslib_1.__importDefault(require("fs")),tools_1=require("../utils/tools"),events_1=tslib_1.__importDefault(require("events"));class Project{constructor(t,e,i,r){this.projectPath=t,this._dirSet=new Set,this._fileSet=new Set,this.type="miniProgram",this.privateKey="",this.event=new events_1.default,this.updateOptions(r),this._fileSet=new Set(e.filter(t=>!this.isIgnore(t))),this._dirSet=new Set(i),this.conf=this.loadConf(),this.checkConf()}async attr(){return this._attr}updateOptions(t){this.appid=t.appid,this._attr=t.attr,this.updateType(t.attr,t.compileType),this.miniprogramRoot=t.miniprogramRoot,this.pluginRoot=t.pluginRoot}updateType(t,e){if(null==t?void 0:t.gameApp)return"gamePlugin"===e?void(this.type="miniGamePlugin"):void(this.type="miniGame");"plugin"!==e?"weapp"!==e||(this.type="miniProgram"):this.type="miniProgramPlugin"}getExtAppid(){throw new Error("Method not implemented.")}updateFiles(){throw new Error("Method not implemented.")}isIgnore(t){return t.endsWith(".d.ts")}loadConf(){var t;return(null===(t=this.stat("","project.config.json"))||void 0===t?void 0:t.isFile)?this.getJson("","project.config.json"):{miniprogramRoot:".",compileType:"miniprogram"}}checkConf(){this.conf.miniprogramRoot||(this.conf.miniprogramRoot="")}cacheDirName(t){this._dirSet.has(t)||(this._dirSet.add(t),this.cacheDirName(path_1.default.posix.dirname(t)))}getTargetPath(t,e){return tools_1.normalizePath(path_1.default.posix.join(t,e)).replace(/\/$/,"").replace(/^\//,"")}stat(t,e){const i=this.getTargetPath(t,e);return this._fileSet.has(i)?{isFile:!0,isDirectory:!1}:this._dirSet.has(i)?{isFile:!1,isDirectory:!0}:void 0}getFile(t,e){const i=this.getTargetPath(t,e),r=tools_1.normalizePath(path_1.default.posix.join(this.projectPath,i));return fs_1.default.readFileSync(r,null)}getJson(t,e){const i=this.getFile(t,e).toString("utf-8");try{return JSON.parse(i)}catch(i){throw new Error("JSON parse failed: "+this.getTargetPath(t,e))}}getFileList(t,e=""){return Array.from(this._fileSet).filter(i=>(!e||path_1.default.posix.extname(i)===e)&&(!t||0===i.indexOf(t)))}onFileChange(t,e){if("add"!==t&&"addDir"!==t||(this.cacheDirName(path_1.default.posix.dirname(e)),this.isIgnore(e)||this._fileSet.add(e)),"addDir"===t&&this.cacheDirName(e),"unlink"===t&&this._fileSet.has(e)&&this._fileSet.delete(e),"unlinkDir"===t&&this._dirSet.has(e)){this._dirSet.delete(e);const t=e+"/",i=Array.from(this._dirSet);for(const e of i)0===e.indexOf(t)&&this._dirSet.delete(e);const r=Array.from(this._fileSet);for(const e of r)0===e.indexOf(t)&&this._fileSet.delete(e)}this.event.emit("fileChange",t,e)}}exports.Project=Project;
1
+ !function(require, directRequire){
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Project=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),fs_1=(0,tslib_1.__importDefault)(require("fs")),tools_1=require("../utils/tools"),events_1=(0,tslib_1.__importDefault)(require("events"));class Project{constructor(t,e,i,r){this.projectPath=t,this._dirSet=new Set,this._fileSet=new Set,this.type="miniProgram",this.privateKey="",this.event=new events_1.default,this.updateOptions(r),this._fileSet=new Set(e.filter(t=>!this.isIgnore(t))),this._dirSet=new Set(i)}getFilesAndDirs(){return{files:Array.from(this._fileSet),dirs:Array.from(this._dirSet)}}async attr(){return this._attr}updateOptions(t){this.appid=t.appid,this._attr=t.attr,this.updateType(t.attr,t.compileType),this.miniprogramRoot=t.miniprogramRoot,this.pluginRoot=t.pluginRoot}updateType(t,e){if(null==t?void 0:t.gameApp)return"miniGamePlugin"===e?void(this.type="miniGamePlugin"):void(this.type="miniGame");this.type=e}getExtAppid(){throw new Error("Method not implemented.")}updateFiles(){throw new Error("Method not implemented.")}isIgnore(t){return t.endsWith(".d.ts")}cacheDirName(t){this._dirSet.has(t)||(this._dirSet.add(t),this.cacheDirName(path_1.default.posix.dirname(t)))}getTargetPath(t,e){return(0,tools_1.normalizePath)(path_1.default.posix.join(t,e)).replace(/\/$/,"").replace(/^\//,"")}stat(t,e){const i=this.getTargetPath(t,e);return this._fileSet.has(i)?{isFile:!0,isDirectory:!1}:this._dirSet.has(i)?{isFile:!1,isDirectory:!0}:void 0}getFileSize(t,e){const i=this.getTargetPath(t,e),r=(0,tools_1.normalizePath)(path_1.default.posix.join(this.projectPath,i));return fs_1.default.statSync(r).size}getFile(t,e){const i=this.getTargetPath(t,e),r=(0,tools_1.normalizePath)(path_1.default.posix.join(this.projectPath,i));return fs_1.default.readFileSync(r,null)}getJson(t,e){const i=this.getFile(t,e).toString("utf-8");try{return JSON.parse(i)}catch(i){throw new Error("JSON parse failed: "+this.getTargetPath(t,e))}}getFileList(t,e=""){return Array.from(this._fileSet).filter(i=>(!e||path_1.default.posix.extname(i)===e)&&(!t||0===i.indexOf(t)))}onFileChange(t,e){if("add"!==t&&"addDir"!==t||(this.cacheDirName(path_1.default.posix.dirname(e)),this.isIgnore(e)||this._fileSet.add(e)),"addDir"===t&&this.cacheDirName(e),"unlink"===t&&this._fileSet.has(e)&&this._fileSet.delete(e),"unlinkDir"===t&&this._dirSet.has(e)){this._dirSet.delete(e);const t=e+"/",i=Array.from(this._dirSet);for(const e of i)0===e.indexOf(t)&&this._dirSet.delete(e);const r=Array.from(this._fileSet);for(const e of r)0===e.indexOf(t)&&this._fileSet.delete(e)}this.event.emit("fileChange",t,e)}}exports.Project=Project;
3
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.silentRecorder=exports.Recorder=exports.getPrintTime=void 0;const perf_hooks_1=require("perf_hooks");function pad(e,t=2){return e>10**t?String(e):`${new Array(t).join("0")}${e}`.slice(-t)}function getPrintTime(){const e=new Date;return`${String(e.getFullYear())}-${pad(e.getMonth()+1)}-${pad(e.getDate())} ${pad(e.getHours())}:${pad(e.getMinutes())}:${pad(e.getSeconds())}.${pad(e.getMilliseconds(),3)}`}exports.getPrintTime=getPrintTime;let taskId=5e7;function genTaskId(){return taskId++}class Recorder{constructor(e){this.sendProgress=e}start(e){const t=genTaskId(),r=Date.now(),s=e.startsWith("!");s||this.sendProgress(t,"doing",e);const o=()=>{console.log(`[summer-compiler] [${getPrintTime()}] [${Math.floor(perf_hooks_1.performance.now())}ms elapsed] [${Date.now()-r}ms costed] ${e}`),s||this.sendProgress(t,"done","")};return o.id=t,o}async run(e,t){const r=this.start(e);try{return await t()}finally{r()}}}exports.Recorder=Recorder,exports.silentRecorder=new Recorder(()=>{});
1
+ !function(require, directRequire){
2
+ "use strict";function pad(e,t=2){return e>10**t?String(e):`${new Array(t).join("0")}${e}`.slice(-t)}function getPrintTime(){const e=new Date;return`${String(e.getFullYear())}-${pad(e.getMonth()+1)}-${pad(e.getDate())} ${pad(e.getHours())}:${pad(e.getMinutes())}:${pad(e.getSeconds())}.${pad(e.getMilliseconds(),3)}`}Object.defineProperty(exports,"__esModule",{value:!0}),exports.silentRecorder=exports.Recorder=exports.getPrintTime=void 0,exports.getPrintTime=getPrintTime;let taskId=5e7;function genTaskId(){return taskId++}class Recorder{constructor(e){this.sendProgress=e}start(e){const t=genTaskId(),r=e.startsWith("!");r||this.sendProgress(t,"doing",e);const s=()=>{r||this.sendProgress(t,"done","")};return s.id=t,s}async run(e,t){const r=this.start(e);try{return await t()}finally{r()}}}exports.Recorder=Recorder,exports.silentRecorder=new Recorder(()=>{});
3
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Resolver=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),targetCodeExts=["json","wxml","wxss","js","wxs"];function getAllExts(t){const e=[];for(const s of targetCodeExts)for(const o of t[s])e.includes(o)||e.push(o);return e}function getExtToTarget(t){const e={};for(const s of targetCodeExts){const o=[];for(const i of t[s])e[i]=e[i]||{},e[i][s]=[...o],o.push(i)}return e}class Resolver{constructor(t,e,s){this.graph=t,this.root=e,this.extConf=s,this.fileSet=new Set,this.resolveInfoMap=new Map,this.onFileChange=(t,e)=>{var s;if(this.isCodeFile(e)&&("unlink"===t||"add"===t))if("add"===t)this.updateFile(e);else{const t=this.getExt(e),o=this.resolve(e);for(const e of o){const o=this.getExt(e.path);this.resolveInfoMap.delete(e.path);for(const i of this.extToTarget[t][o]){const t=e.path.slice(0,e.path.length-o.length)+i;if(null===(s=this.graph.project.stat(this.root,t))||void 0===s?void 0:s.isFile){this.updateFile(t);break}}}}},this.allExts=getAllExts(s),this.extToTarget=getExtToTarget(s),this.updateFiles()}updateFiles(){const t=this.graph.project.getFileList(this.root).map(t=>t.replace(new RegExp("^"+this.root),""));for(const e of t){const t=this.getExt(e);this.allExts.includes(t)&&(this.fileSet.add(e),this.updateFile(e))}}resolve(t){const e=[];if(this.isCodeFile(t))for(const s of this.resolveInfoMap.values())s.source===t&&e.push(s);return e}stat(t){return this.resolveInfoMap.has(t)?{isFile:!0,isDirectory:!1}:void 0}isCodeFile(t){const e=path_1.default.extname(t).replace(/^./,"");return this.allExts.includes(e)}getExt(t){return path_1.default.extname(t).replace(/^./,"")}updateFile(t){if(t.endsWith(".d.ts"))return;const e=this.getExt(t);for(const s of targetCodeExts)if(this.extToTarget[e][s]){const o=t.substr(0,t.length-e.length)+s,i=this.resolveInfoMap.get(o);if(i){if(!this.extToTarget[e][s].includes(i.sourceExt))continue}this.resolveInfoMap.set(o,{path:o,source:t,sourceExt:e})}}}exports.Resolver=Resolver;
1
+ !function(require, directRequire){
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Resolver=void 0;const tslib_1=require("tslib"),path_1=(0,tslib_1.__importDefault)(require("path")),targetCodeExts=["json","wxml","wxss","js","wxs"];function getAllExts(t){const e=[];for(const s of targetCodeExts)for(const o of t[s])e.includes(o)||e.push(o);return e}function getExtToTarget(t){const e={};for(const s of targetCodeExts){const o=[];for(const i of t[s])e[i]=e[i]||{},e[i][s]=[...o],o.push(i)}return e}class Resolver{constructor(t,e,s){this.graph=t,this.root=e,this.extConf=s,this.fileSet=new Set,this.resolveInfoMap=new Map,this.onFileChange=(t,e)=>{var s;if(this.isCodeFile(e)&&("unlink"===t||"add"===t))if("add"===t)this.updateFile(e);else{const t=this.getExt(e),o=this.resolve(e);for(const e of o){const o=this.getExt(e.path);this.resolveInfoMap.delete(e.path);for(const i of this.extToTarget[t][o]){const t=e.path.slice(0,e.path.length-o.length)+i;if(null===(s=this.graph.project.stat(this.root,t))||void 0===s?void 0:s.isFile){this.updateFile(t);break}}}}},this.allExts=getAllExts(s),this.extToTarget=getExtToTarget(s),this.updateFiles()}updateFiles(){const t=this.graph.project.getFileList(this.root).map(t=>t.replace(new RegExp("^"+this.root),""));for(const e of t){const t=this.getExt(e);this.allExts.includes(t)&&(this.fileSet.add(e),this.updateFile(e))}}resolve(t){const e=[];if(this.isCodeFile(t))for(const s of this.resolveInfoMap.values())s.source===t&&e.push(s);return e}stat(t){return this.resolveInfoMap.has(t)?{isFile:!0,isDirectory:!1}:void 0}isCodeFile(t){const e=path_1.default.extname(t).replace(/^./,"");return this.allExts.includes(e)}getExt(t){return path_1.default.extname(t).replace(/^./,"")}updateFile(t){if(t.endsWith(".d.ts"))return;const e=this.getExt(t);for(const s of targetCodeExts)if(this.extToTarget[e][s]){const o=t.substr(0,t.length-e.length)+s,i=this.resolveInfoMap.get(o);if(i){if(!this.extToTarget[e][s].includes(i.sourceExt))continue}this.resolveInfoMap.set(o,{path:o,source:t,sourceExt:e})}}}exports.Resolver=Resolver;
3
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SummerCompiler=void 0;const tslib_1=require("tslib"),plugingraph_1=require("./graph/plugingraph"),appgraph_1=require("./graph/appgraph"),path_1=tslib_1.__importDefault(require("path")),reactiveCache_1=require("../core/json/reactiveCache"),initPlugin_1=require("./initPlugin"),lodash_1=require("lodash"),locales_1=tslib_1.__importDefault(require("../utils/locales/locales")),plugin_driver_1=require("./plugin_driver"),persist_cache_1=tslib_1.__importDefault(require("./persist_cache")),tools_1=require("../utils/tools");let proxyProject;function initProxyProjectForJSON(i){if(!proxyProject){let t={};function e(e,r){const o=i.stat(e,r);if(o)return o;const p=i.getTargetPath(e,r);for(const i in t)if(p.startsWith(i))return t[i].stat(path_1.default.posix.relative(i,p))}proxyProject=new Proxy(i,{get:(i,t,r)=>"stat"===t?e:Reflect.get(i,t,r)}),proxyProject.addResolver=i=>{reactiveCache_1.cleanReactiveCache(),t[i.root]=i},proxyProject.removeResolver=i=>{reactiveCache_1.cleanReactiveCache(),delete t[i.root]},proxyProject.clearResolver=()=>{t={},reactiveCache_1.cleanReactiveCache()}}return proxyProject}function getCacheBaseKey(i){const e=`${i.miniprogramRoot}|${i.pluginRoot}|${i.summerPlugins.join(",")}`;return tools_1.generateMD5(e)}class SummerCompiler{constructor(i,e,t){this.project=i,this.cachePath=e,this.options=t,this.proxyProject=initProxyProjectForJSON(i),this.projectPath=i.projectPath,this.persistCache=new persist_cache_1.default(e,getCacheBaseKey(t)),this.initPlugins(),this.initAppGraph(),"plugin"===this.options.compileType&&this.initPluginGraph()}initPlugins(){this.plugins=this.options.summerPlugins.map(i=>{let e,t={};return"string"==typeof i?e=i:(e=i[0],t=i[1]),initPlugin_1.initPlugin(e,this.project.projectPath,t)})}initAppGraph(){this.appGraph=new appgraph_1.AppGraph({type:"miniprogram",root:this.project.conf.miniprogramRoot,persistCache:this.persistCache,plugins:this.plugins,compiler:this})}initPluginGraph(){this.pluginGraph=new plugingraph_1.PluginGraph({type:"plugin",root:this.project.conf.pluginRoot,persistCache:this.persistCache,plugins:this.plugins,compiler:this})}updateOptions(i){var e,t;const r=this.options;if(this.options=i,this.persistCache.updateBaseCacheKey(getCacheBaseKey(i)),!lodash_1.isEqual(this.options.summerPlugins,r.summerPlugins))return this.initPlugins(),this.appGraph.destroy(),null===(e=this.pluginGraph)||void 0===e||e.destroy(),this.initAppGraph(),void("plugin"===this.options.compileType&&this.initPluginGraph());this.options.compileType!==r.compileType&&("plugin"===this.options.compileType?this.initPluginGraph():(null===(t=this.pluginGraph)||void 0===t||t.destroy(),this.pluginGraph=void 0)),this.appGraph.root!==this.project.conf.miniprogramRoot&&(this.appGraph.destroy(),this.initAppGraph()),this.pluginGraph&&this.pluginGraph.root!==this.project.conf.pluginRoot&&(this.pluginGraph.destroy(),this.initPluginGraph())}destroy(){var i;this.appGraph.destroy(),null===(i=this.pluginGraph)||void 0===i||i.destroy(),this.proxyProject.clearResolver()}getStatus(){const i=plugin_driver_1.genResovleExtConf(this.plugins),e={},t=new Set;for(const r of["json","js","wxml","wxss","wxs"])e[r]={exts:i[r].reverse()},i[r].forEach(i=>{t.add(i)});return{codeExts:Array.from(t.keys()),codeConf:e}}clearCache(){var i;this.appGraph.clearCache(),null===(i=this.pluginGraph)||void 0===i||i.clearCache(),this.persistCache.clean(),reactiveCache_1.cleanReactiveCache()}async getConf({graphId:i},e){if("miniprogram"===i){return await this.appGraph.getConf(e)}if("plugin"===i){return await this.pluginGraph.getConf(e)}throw new Error("no support getConf for "+i)}async getCode(i,e){if("miniprogram"===i.graphId){return await this.appGraph.getDevCode(e,{package:i.package})}if("plugin"===i.graphId){return await this.pluginGraph.getDevCode(e)}throw new Error("no support getCode for "+i.graphId)}async compileSingleCode(i,e){if("miniprogram"===i.graphId){return await this.appGraph.compileSingleCode(i.filePath,i.sourceCode)}if("plugin"===i.graphId){return await this.pluginGraph.compileSingleCode(i.filePath,i.sourceCode)}throw new Error("no support getCode for "+i.graphId)}async compile(i,e){const t=await e.run(locales_1.default.config.SUMMER_COMPILE_MINIPROGRAM.format(),()=>this.appGraph.compile(e));if("miniprogram"===this.project.conf.compileType)return t["project.config.json"]=JSON.stringify({miniprogramRoot:"",__compileDebugInfo__:{useSummer:!0}}),t;if("plugin"===this.project.conf.compileType){const i={},r=await(await e.run(locales_1.default.config.SUMMER_COMPILE_PLUGIN.format(),()=>this.pluginGraph.compile(e)));return Object.keys(t).forEach(e=>{i[path_1.default.posix.join(this.project.miniprogramRoot,e)]=t[e]}),Object.keys(r).forEach(e=>{i[path_1.default.posix.join(this.project.pluginRoot,e)]=r[e]}),i["project.config.json"]=JSON.stringify({miniprogramRoot:this.project.miniprogramRoot,pluginRoot:this.project.pluginRoot,__compileDebugInfo__:{useSummer:!0}}),i}throw new Error("no support compile for "+this.project.conf.compileType)}}exports.SummerCompiler=SummerCompiler;
1
+ !function(require, directRequire){
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SummerCompiler=void 0;const tslib_1=require("tslib"),plugingraph_1=require("./graph/plugingraph"),appgraph_1=require("./graph/appgraph"),path_1=(0,tslib_1.__importDefault)(require("path")),reactiveCache_1=require("../core/json/reactiveCache"),initPlugin_1=require("./initPlugin"),lodash_1=require("lodash"),locales_1=(0,tslib_1.__importDefault)(require("../utils/locales/locales")),plugin_driver_1=require("./plugin_driver"),persist_cache_1=(0,tslib_1.__importDefault)(require("./persist_cache")),tools_1=require("../utils/tools");let proxyProject;function initProxyProjectForJSON(i){if(proxyProject&&proxyProject.projectPath!==i.projectPath&&(proxyProject.clearResolver(),proxyProject=void 0),!proxyProject){let e={};function t(t,r){const o=i.stat(t,r);if(o)return o;const p=i.getTargetPath(t,r);for(const i in e)if(p.startsWith(i))return e[i].stat(path_1.default.posix.relative(i,p))}proxyProject=new Proxy(i,{get:(i,e,r)=>"stat"===e?t:Reflect.get(i,e,r)}),proxyProject.addResolver=i=>{(0,reactiveCache_1.cleanReactiveCache)(),e[i.root]=i},proxyProject.removeResolver=i=>{(0,reactiveCache_1.cleanReactiveCache)(),delete e[i.root]},proxyProject.clearResolver=()=>{e={},(0,reactiveCache_1.cleanReactiveCache)()}}return proxyProject}function getCacheBaseKey(i){const t=`${i.miniprogramRoot}|${i.pluginRoot}|${i.summerPlugins.join(",")}`;return(0,tools_1.generateMD5)(t)}class SummerCompiler{constructor(i,t,e){this.project=i,this.cachePath=t,this.options=e,this.proxyProject=initProxyProjectForJSON(i),this.projectPath=i.projectPath,this.persistCache=new persist_cache_1.default(t,getCacheBaseKey(e)),this.initPlugins(),this.initAppGraph(),"miniProgramPlugin"===this.options.compileType&&this.initPluginGraph()}initPlugins(){this.plugins=this.options.summerPlugins.map(i=>{let t,e={};return"string"==typeof i?t=i:(t=i[0],e=i[1]),(0,initPlugin_1.initPlugin)(t,this.project.projectPath,e)})}initAppGraph(){this.appGraph=new appgraph_1.AppGraph({type:"miniprogram",root:this.project.miniprogramRoot,persistCache:this.persistCache,plugins:this.plugins,compiler:this})}initPluginGraph(){this.pluginGraph=new plugingraph_1.PluginGraph({type:"plugin",root:this.project.pluginRoot,persistCache:this.persistCache,plugins:this.plugins,compiler:this})}updateOptions(i){var t,e;const r=this.options;if(this.options=i,this.persistCache.updateBaseCacheKey(getCacheBaseKey(i)),!(0,lodash_1.isEqual)(this.options.summerPlugins,r.summerPlugins))return this.initPlugins(),this.appGraph.destroy(),null===(t=this.pluginGraph)||void 0===t||t.destroy(),this.initAppGraph(),void("miniProgramPlugin"===this.options.compileType&&this.initPluginGraph());this.options.compileType!==r.compileType&&("miniProgramPlugin"===this.options.compileType?this.initPluginGraph():(null===(e=this.pluginGraph)||void 0===e||e.destroy(),this.pluginGraph=void 0)),this.appGraph.root!==this.project.miniprogramRoot&&(this.appGraph.destroy(),this.initAppGraph()),this.pluginGraph&&this.pluginGraph.root!==this.project.pluginRoot&&(this.pluginGraph.destroy(),this.initPluginGraph())}destroy(){var i;this.appGraph.destroy(),null===(i=this.pluginGraph)||void 0===i||i.destroy(),this.proxyProject.clearResolver()}getStatus(){const i=(0,plugin_driver_1.genResovleExtConf)(this.plugins),t={},e=new Set;for(const r of["json","js","wxml","wxss","wxs"])t[r]={exts:i[r].reverse()},i[r].forEach(i=>{e.add(i)});return{codeExts:Array.from(e.keys()),codeConf:t}}clearCache(){var i;this.appGraph.clearCache(),null===(i=this.pluginGraph)||void 0===i||i.clearCache(),this.persistCache.clean(),(0,reactiveCache_1.cleanReactiveCache)()}async getConf({graphId:i},t){if("miniprogram"===i){return await this.appGraph.getConf(t)}if("plugin"===i){return await this.pluginGraph.getConf(t)}throw new Error("no support getConf for "+i)}async getCode(i,t){if("miniprogram"===i.graphId){return await this.appGraph.getDevCode(t,{package:i.package})}if("plugin"===i.graphId){return await this.pluginGraph.getDevCode(t)}throw new Error("no support getCode for "+i.graphId)}async getLocalFileList(i){if("miniprogram"===i)return await this.appGraph.getLocalFileList();if("plugin"===i)return await this.pluginGraph.getLocalFileList();throw new Error("no support getCode for "+i)}async compileSingleCode(i,t){if("miniprogram"===i.graphId){return await this.appGraph.compileSingleCode(i.filePath,i.sourceCode)}if("plugin"===i.graphId){return await this.pluginGraph.compileSingleCode(i.filePath,i.sourceCode)}throw new Error("no support getCode for "+i.graphId)}async compile(i,t){const e=await t.run(locales_1.default.config.SUMMER_COMPILE_MINIPROGRAM.format(),()=>this.appGraph.compile(t));if("miniProgram"===this.project.type)return e["project.config.json"]=JSON.stringify({miniprogramRoot:"",__compileDebugInfo__:{useSummer:!0}}),e;if("miniProgramPlugin"===this.project.type){const i={},r=await(await t.run(locales_1.default.config.SUMMER_COMPILE_PLUGIN.format(),()=>this.pluginGraph.compile(t)));return Object.keys(e).forEach(t=>{i[path_1.default.posix.join(this.project.miniprogramRoot,t)]=e[t]}),Object.keys(r).forEach(t=>{i[path_1.default.posix.join(this.project.pluginRoot,t)]=r[t]}),i["project.config.json"]=JSON.stringify({miniprogramRoot:this.project.miniprogramRoot,pluginRoot:this.project.pluginRoot,__compileDebugInfo__:{useSummer:!0}}),i}throw new Error("no support compile for "+this.project.type)}}exports.SummerCompiler=SummerCompiler;
3
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1,3 @@
1
- "use strict";var FileType,JSONType,AstType;Object.defineProperty(exports,"__esModule",{value:!0}),exports.AstType=exports.JSONType=exports.FileType=exports.BasicCodeExts=void 0,exports.BasicCodeExts=["js","wxml","wxss","json","wxs"],function(e){e.JSON="json",e.WXML="wxml",e.WXSS="wxss",e.WXS="wxs",e.JS="js"}(FileType=exports.FileType||(exports.FileType={})),function(e){e.APP="app",e.Page="page",e.EXT="ext",e.SITEMAP="sitemap",e.THEME="theme"}(JSONType=exports.JSONType||(exports.JSONType={})),function(e){e.Babel="babel",e.Acorn="acorn"}(AstType=exports.AstType||(exports.AstType={}));
1
+ !function(require, directRequire){
2
+ "use strict";var FileType,JSONType,AstType;Object.defineProperty(exports,"__esModule",{value:!0}),exports.AstType=exports.JSONType=exports.FileType=exports.BasicCodeExts=void 0,exports.BasicCodeExts=["js","wxml","wxss","json","wxs"],function(e){e.JSON="json",e.WXML="wxml",e.WXSS="wxss",e.WXS="wxs",e.JS="js"}(FileType=exports.FileType||(exports.FileType={})),function(e){e.APP="app",e.Page="page",e.EXT="ext",e.SITEMAP="sitemap",e.THEME="theme"}(JSONType=exports.JSONType||(exports.JSONType={})),function(e){e.Babel="babel",e.Acorn="acorn"}(AstType=exports.AstType||(exports.AstType={}));
3
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Barrier=void 0;class Barrier{constructor(){this._isOpen=!1,this._promise=new Promise((e,r)=>{this._completePromise=e})}isOpen(){return this._isOpen}open(){this._isOpen=!0,this._completePromise(!0)}wait(){return this._promise}}exports.Barrier=Barrier;
1
+ !function(require, directRequire){
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Barrier=void 0;class Barrier{constructor(){this._isOpen=!1,this._promise=new Promise((e,r)=>{this._completePromise=e})}isOpen(){return this._isOpen}open(){this._isOpen=!0,this._completePromise(!0)}wait(){return this._promise}}exports.Barrier=Barrier;
3
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1,3 @@
1
- "use strict";function ensureArray(r){return Array.isArray(r)?r.filter(Boolean):r?[r]:[]}Object.defineProperty(exports,"__esModule",{value:!0}),exports.ensureArray=void 0,exports.ensureArray=ensureArray;
1
+ !function(require, directRequire){
2
+ "use strict";function ensureArray(r){return Array.isArray(r)?r.filter(Boolean):r?[r]:[]}Object.defineProperty(exports,"__esModule",{value:!0}),exports.ensureArray=void 0,exports.ensureArray=ensureArray;
3
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.runSummerPluginHook=void 0;const initPlugin_1=require("./initPlugin");class PluginContainer{constructor(){this.initedPlugins=new Map}getPluginInstance(n,i,t){let e=this.initedPlugins.get(n);return e||(e=initPlugin_1.initPlugin(n,i,t),this.initedPlugins.set(n,e)),e}clear(){this.initedPlugins.clear()}}const pluginContainer=new PluginContainer;async function runSummerPluginHook(n){var i;if("clear"===n.command)return pluginContainer.clear(),{};const{plugin:t,projectPath:e,pluginOption:r,method:o,args:u}=n,l=pluginContainer.getPluginInstance(t,e,r);if("runMethod"===n.command){const n=null===(i=l.workerMethods)||void 0===i?void 0:i[o];if(!n||"function"!=typeof n)throw new Error(`the ${n} is not a workerMethod of plugin(${t})`);try{return{result:await n(...u)}}catch(n){return{error:n}}}return{}}exports.runSummerPluginHook=runSummerPluginHook;
1
+ !function(require, directRequire){
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.runSummerPluginHook=void 0;const error_1=require("./error"),initPlugin_1=require("./initPlugin");class PluginContainer{constructor(){this.initedPlugins=new Map}getPluginInstance(n,r,e){let i=this.initedPlugins.get(n);return i||(i=(0,initPlugin_1.initPlugin)(n,r,e),this.initedPlugins.set(n,i)),i}clear(){this.initedPlugins.clear()}}const pluginContainer=new PluginContainer;async function runSummerPluginHook(n){var r;if("clear"===n.command)return pluginContainer.clear(),{};const{plugin:e,projectPath:i,pluginOption:t,method:o,args:u}=n,l=pluginContainer.getPluginInstance(e,i,t);if("runMethod"===n.command){const n=null===(r=l.workerMethods)||void 0===r?void 0:r[o];if(!n||"function"!=typeof n)throw new Error(`the ${n} is not a workerMethod of plugin(${e})`);try{return{result:await n(...u)}}catch(n){return{error:n instanceof error_1.SummerError?n.toJSON():n}}}return{}}exports.runSummerPluginHook=runSummerPluginHook;
3
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib");tslib_1.__exportStar(require("./miniprogram-json/index"),exports);
1
+ !function(require, directRequire){
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib");(0,tslib_1.__exportStar)(require("./miniprogram-json/index"),exports);
3
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
1
+ !function(require, directRequire){
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
3
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
1
+ !function(require, directRequire){
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
3
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
1
+ !function(require, directRequire){
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
3
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
1
+ !function(require, directRequire){
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
3
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib");tslib_1.__exportStar(require("./app"),exports),tslib_1.__exportStar(require("./ext"),exports),tslib_1.__exportStar(require("./sitemap"),exports),tslib_1.__exportStar(require("./page"),exports),tslib_1.__exportStar(require("./plugin"),exports),tslib_1.__exportStar(require("./projectconfig"),exports),tslib_1.__exportStar(require("./game"),exports),tslib_1.__exportStar(require("./theme"),exports);
1
+ !function(require, directRequire){
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib");(0,tslib_1.__exportStar)(require("./app"),exports),(0,tslib_1.__exportStar)(require("./ext"),exports),(0,tslib_1.__exportStar)(require("./sitemap"),exports),(0,tslib_1.__exportStar)(require("./page"),exports),(0,tslib_1.__exportStar)(require("./plugin"),exports),(0,tslib_1.__exportStar)(require("./projectconfig"),exports),(0,tslib_1.__exportStar)(require("./game"),exports),(0,tslib_1.__exportStar)(require("./theme"),exports);
3
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
1
+ !function(require, directRequire){
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
3
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
1
+ !function(require, directRequire){
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
3
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
1
+ !function(require, directRequire){
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
3
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
1
+ !function(require, directRequire){
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
3
+ }(require("licia/lazyImport")(require), require)
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
1
+ !function(require, directRequire){
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
3
+ }(require("licia/lazyImport")(require), require)