miniprogram-ci 2.1.31 → 2.1.32

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 (414) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/README.md +3 -0
  3. package/dist/@types/ci/checkCodeQuality.d.ts +1 -1
  4. package/dist/@types/ci/code-analyse.d.ts +1 -1
  5. package/dist/@types/ci/cos-upload.d.ts +0 -1
  6. package/dist/@types/ci/getCompiledResult.d.ts +0 -1
  7. package/dist/@types/ci/utils/filterUnusedFile.d.ts +0 -1
  8. package/dist/@types/ci/utils/pack.d.ts +0 -1
  9. package/dist/@types/ci/utils/packfile.d.ts +0 -1
  10. package/dist/@types/ci/utils/tools.d.ts +1 -1
  11. package/dist/@types/ci/utils/wxvpkg/unpack/version0.d.ts +0 -1
  12. package/dist/@types/ci/utils/wxvpkg/unpack/version10.d.ts +0 -1
  13. package/dist/@types/config/compiletype.config.d.ts +4 -4
  14. package/dist/@types/config/config.d.ts +1 -1
  15. package/dist/@types/config/dir.config.d.ts +17 -0
  16. package/dist/@types/config/url.config.d.ts +42 -42
  17. package/dist/@types/index.d.ts +4 -2
  18. package/dist/@types/modules/corecompiler/baseCompiler.d.ts +3 -4
  19. package/dist/@types/modules/corecompiler/original/compile/common.d.ts +0 -1
  20. package/dist/@types/modules/corecompiler/original/compile/gamePlugin.d.ts +0 -1
  21. package/dist/@types/modules/corecompiler/original/compile/handler/mpjson.d.ts +0 -1
  22. package/dist/@types/modules/corecompiler/original/compile/miniprogram.d.ts +0 -1
  23. package/dist/@types/modules/corecompiler/original/compile/miniprogramPlugin.d.ts +0 -1
  24. package/dist/@types/modules/corecompiler/original/js/index.d.ts +0 -1
  25. package/dist/@types/modules/corecompiler/original/protect/uglifyfilenames.d.ts +0 -1
  26. package/dist/@types/modules/corecompiler/original/webWorker/webWorkerManager.d.ts +0 -1
  27. package/dist/@types/modules/corecompiler/original/workerThread/task/compilejs.d.ts +1 -2
  28. package/dist/@types/modules/corecompiler/original/workerThread/task/compilewxss.d.ts +0 -1
  29. package/dist/@types/modules/corecompiler/original/workerThread/task/minifywxml.d.ts +0 -1
  30. package/dist/@types/modules/corecompiler/summer/graph/appconf.d.ts +1 -1
  31. package/dist/@types/modules/corecompiler/summer/graph/gameconf.d.ts +1 -1
  32. package/dist/@types/modules/corecompiler/summer/plugins/less.d.ts +0 -1
  33. package/dist/@types/modules/corecompiler/summer/resolver.d.ts +1 -1
  34. package/dist/@types/modules/corecompiler/summerCompiler.d.ts +2 -3
  35. package/dist/@types/modules/nativecompiler/ios/buildCloud.d.ts +2 -2
  36. package/dist/@types/modules/nativecompiler/processHandler.d.ts +1 -1
  37. package/dist/@types/modules/precompiler/conditioncompile/compiler/base.d.ts +0 -1
  38. package/dist/@types/modules/precompiler/conditioncompile/compiler/json.d.ts +0 -1
  39. package/dist/@types/modules/precompiler/conditioncompile/compiler/macro.d.ts +0 -1
  40. package/dist/@types/modules/precompiler/conditioncompile/compiler/plant.d.ts +0 -1
  41. package/dist/@types/modules/precompiler/conditioncompile/index.d.ts +0 -1
  42. package/dist/@types/project/advance/precompileProject.d.ts +0 -1
  43. package/dist/@types/project/advance/reactiveProject.d.ts +1 -2
  44. package/dist/@types/project/baseProject.d.ts +3 -3
  45. package/dist/@types/project/ciProjectWithMockBuffer.d.ts +0 -1
  46. package/dist/@types/services/accountcard/accountcard.d.ts +18 -0
  47. package/dist/@types/services/accountcard/accountcardService.d.ts +0 -0
  48. package/dist/@types/services/app/common/appDirService.d.ts +10 -0
  49. package/dist/@types/services/app/common/appDirService.devtools.d.ts +7 -0
  50. package/dist/@types/services/app/electron/appDirService.d.ts +3 -0
  51. package/dist/@types/services/app/node/appDirService.d.ts +6 -0
  52. package/dist/@types/services/app/nw/appDirService.d.ts +3 -0
  53. package/dist/@types/services/builder/common/builder.d.ts +22 -0
  54. package/dist/@types/services/builder/nw/builder.d.ts +15 -0
  55. package/dist/@types/services/builder/webide/builder.d.ts +4 -0
  56. package/dist/@types/services/common/extensions.d.ts +8 -0
  57. package/dist/@types/services/common/getservice.d.ts +24 -0
  58. package/dist/@types/services/common/librarybase.d.ts +2063 -0
  59. package/dist/@types/services/common/vsbase.d.ts +3 -0
  60. package/dist/@types/services/compilewxml/common/compilewxmlService.d.ts +41 -0
  61. package/dist/@types/services/compilewxml/electron/compilewxmlService.d.ts +5 -0
  62. package/dist/@types/services/compilewxml/node/compileUtils.d.ts +3 -0
  63. package/dist/@types/services/compilewxml/node/compileglasseasel.d.ts +0 -0
  64. package/dist/@types/services/compilewxml/nw/compilewxmlService.d.ts +5 -0
  65. package/dist/@types/services/compilewxml/webide/compilewxmlService.d.ts +5 -0
  66. package/dist/@types/services/compilewxml/webide/pageFrameWasm/wcc/runWcc.d.ts +3 -0
  67. package/dist/@types/services/compilewxss/common/compilewxssService.d.ts +15 -0
  68. package/dist/@types/services/compilewxss/electron/compilewxssService.d.ts +4 -0
  69. package/dist/@types/services/compilewxss/node/compileUtils.d.ts +2 -0
  70. package/dist/@types/services/compilewxss/nw/compilewxssService.d.ts +4 -0
  71. package/dist/@types/services/compilewxss/webide/compilewxssService.d.ts +4 -0
  72. package/dist/@types/services/compilewxss/webide/pageFrameWasm/wcsc/runWcsc.d.ts +3 -0
  73. package/dist/@types/services/consoledisplay/common/consoledisplay.d.ts +5 -0
  74. package/dist/@types/services/consoledisplay/nw/consoledisplay.d.ts +6 -0
  75. package/dist/@types/services/fileUtilsManager/common/fileUtilsManager.d.ts +5 -0
  76. package/dist/@types/services/fileUtilsManager/nw/fileUtilsManager.d.ts +6 -0
  77. package/dist/@types/services/fs/common/fileService.d.ts +28 -0
  78. package/dist/@types/services/genTempFile/common/genTempFile.devtools.d.ts +4 -0
  79. package/dist/@types/services/genTempFile/common/genTempFile.node.d.ts +4 -0
  80. package/dist/@types/services/genTempFile/common/genTempFileService.d.ts +4 -0
  81. package/dist/@types/services/genTempFile/electron/genTempFileService.d.ts +3 -0
  82. package/dist/@types/services/genTempFile/node/genTempFileService.d.ts +3 -0
  83. package/dist/@types/services/genTempFile/nw/genTempFileService.d.ts +3 -0
  84. package/dist/@types/services/global/common/global.d.ts +10 -0
  85. package/dist/@types/services/global/nw/global.d.ts +12 -0
  86. package/dist/@types/services/initializeCheck/common/initializeCheck.d.ts +21 -0
  87. package/dist/@types/services/initializeCheck/nw/initializeCheck.d.ts +4 -0
  88. package/dist/@types/services/initializeCheck/webide/initializeCheck.d.ts +0 -0
  89. package/dist/@types/services/locales/common/locales.d.ts +7 -0
  90. package/dist/@types/services/locales/nw/locales.d.ts +9 -0
  91. package/dist/@types/services/log/common/logService.d.ts +9 -0
  92. package/dist/@types/services/miniappjson/common/miniappjson.d.ts +5 -0
  93. package/dist/@types/services/miniappjson/electron/miniappjson.d.ts +6 -0
  94. package/dist/@types/services/miniappjson/nw/miniappjson.d.ts +6 -0
  95. package/dist/@types/services/miniappjson/webide/miniappjson.d.ts +4 -0
  96. package/dist/@types/services/nativeModule/common/nativeModule.d.ts +9 -0
  97. package/dist/@types/services/nativeModule/common/nativeModule.impl.d.ts +12 -0
  98. package/dist/@types/services/nativeModule/electron/nativeModule.d.ts +3 -0
  99. package/dist/@types/services/nativeModule/nw/nativeModule.d.ts +3 -0
  100. package/dist/@types/services/partialcompile/common/parialcompile.impl.d.ts +0 -0
  101. package/dist/@types/services/partialcompile/common/partialcompile.d.ts +0 -0
  102. package/dist/@types/services/partialcompile/nw/partialcompile.d.ts +0 -0
  103. package/dist/@types/services/partialcompile/webide/partialcompile.d.ts +0 -0
  104. package/dist/@types/services/performance/common/performance.d.ts +9 -0
  105. package/dist/@types/services/performance/nw/performance.d.ts +9 -0
  106. package/dist/@types/services/performance/webide/performance.d.ts +7 -0
  107. package/dist/@types/services/project/common/cloudProjectService.d.ts +0 -0
  108. package/dist/@types/services/project/common/createProjectService.d.ts +0 -0
  109. package/dist/@types/services/project/common/project.helper.d.ts +0 -0
  110. package/dist/@types/services/project/common/projectConfigService.d.ts +0 -0
  111. package/dist/@types/services/project/common/projectFileService.d.ts +0 -0
  112. package/dist/@types/services/project/common/projectconfigjsonutils.d.ts +0 -0
  113. package/dist/@types/services/project/electron-backend/projectManagerService.d.ts +0 -0
  114. package/dist/@types/services/project/node/createProjectService.d.ts +0 -0
  115. package/dist/@types/services/project/node/projectConfigService.d.ts +0 -0
  116. package/dist/@types/services/project/node/projectManagerService.d.ts +0 -0
  117. package/dist/@types/services/project/web/projectManagerService.d.ts +0 -0
  118. package/dist/@types/services/project/webide/projectConfigService.d.ts +0 -0
  119. package/dist/@types/services/project/webide/projectFileService.d.ts +0 -0
  120. package/dist/@types/services/project/webide/projectManagerService.d.ts +0 -0
  121. package/dist/@types/services/projectManager/common/buildServerProjectManager.d.ts +5 -0
  122. package/dist/@types/services/projectManager/common/projectManager.d.ts +7 -0
  123. package/dist/@types/services/projectManager/nw/projectManager.d.ts +9 -0
  124. package/dist/@types/services/root/common/createService.d.ts +12 -0
  125. package/dist/@types/services/root/electron/root.d.ts +11 -0
  126. package/dist/@types/services/root/electron/rootService.d.ts +2 -0
  127. package/dist/@types/services/root/node/root.d.ts +11 -0
  128. package/dist/@types/services/root/node/rootService.d.ts +0 -0
  129. package/dist/@types/services/root/nw/root.d.ts +11 -0
  130. package/dist/@types/services/root/nw/rootService.d.ts +0 -0
  131. package/dist/@types/services/staticConfig/common/staticConfigService.d.ts +5 -0
  132. package/dist/@types/services/staticConfig/nw/staticConfigService.d.ts +6 -0
  133. package/dist/@types/services/store/common/storeService.d.ts +17 -0
  134. package/dist/@types/services/uniapp/common/uniapp.d.ts +5 -0
  135. package/dist/@types/services/uniapp/nw/uniapp.d.ts +9 -0
  136. package/dist/@types/services/uniapp/webide/uniapp.d.ts +4 -0
  137. package/dist/@types/services/vendor/common/utils.d.ts +0 -0
  138. package/dist/@types/services/vendor/common/vendorService.d.ts +0 -0
  139. package/dist/@types/services/vendor/node/vendorService.d.ts +0 -0
  140. package/dist/@types/services/vendor/webide/vendorService.d.ts +0 -0
  141. package/dist/@types/types/ci.d.ts +1 -2
  142. package/dist/@types/types/core.d.ts +1 -2
  143. package/dist/@types/types/devtools.d.ts +0 -1
  144. package/dist/@types/types/summer.d.ts +0 -1
  145. package/dist/@types/utils/common.d.ts +3 -1
  146. package/dist/@types/utils/cosUpload.d.ts +0 -1
  147. package/dist/@types/utils/fsagent.d.ts +0 -1
  148. package/dist/@types/utils/locales/locales.d.ts +2 -114
  149. package/dist/@types/utils/locales/zh.d.ts +114 -113
  150. package/dist/@types/utils/miniappJson.d.ts +1 -1
  151. package/dist/@types/utils/node/common.d.ts +1 -0
  152. package/dist/@types/utils/packOptionsHelper.d.ts +1 -1
  153. package/dist/@types/utils/signature.d.ts +0 -1
  154. package/dist/@types/utils/singletontask.d.ts +1 -0
  155. package/dist/@types/utils/taskqueue.d.ts +0 -1
  156. package/dist/@types/utils/taskstatus.d.ts +1 -1
  157. package/dist/@types/utils/tools.d.ts +3 -4
  158. package/dist/@types/utils/web/common.d.ts +1 -0
  159. package/dist/@types/utils/wxapkg/pack.d.ts +0 -1
  160. package/dist/@types/utils/wxvpkgreader/wxvpkg/reader/version0.d.ts +0 -1
  161. package/dist/@types/utils/wxvpkgreader/wxvpkg/reader/version10.d.ts +0 -1
  162. package/dist/@types/utils/wxvpkgreader/wxvpkg/unpack/version0.d.ts +0 -1
  163. package/dist/@types/utils/wxvpkgreader/wxvpkg/unpack/version10.d.ts +0 -1
  164. package/dist/@types/utils/wxvpkgreader/wxvpkgreader.d.ts +0 -1
  165. package/dist/ci/android-miniapp-toolkit/dist/index.js +1 -1
  166. package/dist/ci/build-apk.js +1 -1
  167. package/dist/ci/build-ipa.js +1 -1
  168. package/dist/ci/checkCodeQuality.js +1 -1
  169. package/dist/ci/cloud/cloudapi.js +1 -1
  170. package/dist/ci/cloud/createTimeTrigger.js +1 -1
  171. package/dist/ci/cloud/uploadContainer.js +1 -1
  172. package/dist/ci/cloud/uploadFile.js +1 -1
  173. package/dist/ci/cloud/uploadFunction.js +1 -1
  174. package/dist/ci/cloud/utils.js +1 -1
  175. package/dist/ci/code-analyse.js +1 -1
  176. package/dist/ci/cos-upload.js +1 -1
  177. package/dist/ci/gamepkg/apkplug.js +1 -1
  178. package/dist/ci/gamepkg/index.js +1 -1
  179. package/dist/ci/getCompiledResult.js +1 -1
  180. package/dist/ci/getDevSourceMap.js +1 -1
  181. package/dist/ci/getLatestVersion.js +1 -1
  182. package/dist/ci/getcompiler.js +1 -1
  183. package/dist/ci/index.js +1 -1
  184. package/dist/ci/jsserver.js +1 -1
  185. package/dist/ci/miniapp/archive.js +1 -1
  186. package/dist/ci/miniapp/checkBuildArgument.js +1 -1
  187. package/dist/ci/miniapp/miniappPlugin.js +1 -1
  188. package/dist/ci/miniapp/sdkManager.js +1 -1
  189. package/dist/ci/miniapp/upload.js +1 -1
  190. package/dist/ci/miniapp-cloud-upload.js +1 -1
  191. package/dist/ci/miniappattr.js +1 -1
  192. package/dist/ci/preview.js +1 -1
  193. package/dist/ci/projectattr.js +1 -1
  194. package/dist/ci/upload.js +1 -1
  195. package/dist/ci/utils/ciRequest.js +1 -1
  196. package/dist/ci/utils/filterUnusedFile.js +1 -1
  197. package/dist/ci/utils/pack.js +1 -1
  198. package/dist/ci/utils/terminalQrcode.js +1 -1
  199. package/dist/ci/utils/tools.js +1 -1
  200. package/dist/ci/utils/wxvpkg/unpack/version0.js +1 -1
  201. package/dist/ci/utils/wxvpkg/unpack/version10.js +1 -1
  202. package/dist/config/config.js +1 -1
  203. package/dist/config/dir.config.js +1 -0
  204. package/dist/index.js +1 -1
  205. package/dist/modules/corecompiler/baseCompiler.js +1 -1
  206. package/dist/modules/corecompiler/original/analyse/partial.js +1 -1
  207. package/dist/modules/corecompiler/original/compile/common.js +1 -1
  208. package/dist/modules/corecompiler/original/compile/game.js +1 -1
  209. package/dist/modules/corecompiler/original/compile/gamePlugin.js +1 -1
  210. package/dist/modules/corecompiler/original/compile/handler/js.js +1 -1
  211. package/dist/modules/corecompiler/original/compile/handler/mpjson.js +1 -1
  212. package/dist/modules/corecompiler/original/compile/handler/wxml.js +1 -1
  213. package/dist/modules/corecompiler/original/compile/handler/wxss.js +1 -1
  214. package/dist/modules/corecompiler/original/compile/index.js +1 -1
  215. package/dist/modules/corecompiler/original/compile/miniprogram.js +1 -1
  216. package/dist/modules/corecompiler/original/compile/miniprogramPlugin.js +1 -1
  217. package/dist/modules/corecompiler/original/index.js +1 -1
  218. package/dist/modules/corecompiler/original/js/index.js +1 -1
  219. package/dist/modules/corecompiler/original/json/app/appJSON.js +1 -1
  220. package/dist/modules/corecompiler/original/json/app/checkAppFields.js +1 -1
  221. package/dist/modules/corecompiler/original/json/common.js +1 -1
  222. package/dist/modules/corecompiler/original/json/page/checkPageJSON.js +1 -1
  223. package/dist/modules/corecompiler/original/json/page/getPageJSON.js +1 -1
  224. package/dist/modules/corecompiler/original/json/plugin/plugin.js +1 -1
  225. package/dist/modules/corecompiler/original/json/plugin/pluginPage.js +1 -1
  226. package/dist/modules/corecompiler/original/json/reactiveCache.js +1 -1
  227. package/dist/modules/corecompiler/original/json/signaturejson.js +1 -1
  228. package/dist/modules/corecompiler/original/json/theme.js +1 -1
  229. package/dist/modules/corecompiler/original/npm/filterdeps.js +1 -1
  230. package/dist/modules/corecompiler/original/npm/packnpm.js +1 -1
  231. package/dist/modules/corecompiler/original/protect/uglifyfilenames.js +1 -1
  232. package/dist/modules/corecompiler/original/validate/schemaValidate.js +1 -1
  233. package/dist/modules/corecompiler/original/webWorker/configs.js +1 -1
  234. package/dist/modules/corecompiler/original/workerThread/config.js +1 -1
  235. package/dist/modules/corecompiler/original/workerThread/getWorkerPoolSize.js +1 -1
  236. package/dist/modules/corecompiler/original/workerThread/index.js +1 -1
  237. package/dist/modules/corecompiler/original/workerThread/task/call_func.js +1 -1
  238. package/dist/modules/corecompiler/original/workerThread/task/func.js +1 -1
  239. package/dist/modules/corecompiler/original/workerThread/task/minifywxml.js +1 -1
  240. package/dist/modules/corecompiler/processHandler.js +1 -1
  241. package/dist/modules/corecompiler/summer/graph/basegraph.js +1 -1
  242. package/dist/modules/corecompiler/summer/graph/util.js +1 -1
  243. package/dist/modules/corecompiler/summer/index.js +1 -1
  244. package/dist/modules/corecompiler/summer/initPlugin.js +1 -1
  245. package/dist/modules/corecompiler/summer/pluginDriver.js +1 -1
  246. package/dist/modules/corecompiler/summer/pluginconfig.js +1 -1
  247. package/dist/modules/corecompiler/summer/plugins/base/es6module.js +1 -1
  248. package/dist/modules/corecompiler/summer/plugins/base/javascript.js +1 -1
  249. package/dist/modules/corecompiler/summer/plugins/base/swc.js +1 -1
  250. package/dist/modules/corecompiler/summer/plugins/base/wxss.js +1 -1
  251. package/dist/modules/corecompiler/summer/plugins/enhance.js +1 -1
  252. package/dist/modules/corecompiler/summer/plugins/filetask/script.js +1 -1
  253. package/dist/modules/corecompiler/summer/plugins/less.js +1 -1
  254. package/dist/modules/corecompiler/summer/plugins/minifywxml.js +1 -1
  255. package/dist/modules/corecompiler/summer/plugins/sass.js +1 -1
  256. package/dist/modules/corecompiler/summer/plugins/script_task/babel_script_task.js +1 -1
  257. package/dist/modules/corecompiler/summer/plugins/script_task/load_script_task.js +1 -1
  258. package/dist/modules/corecompiler/summer/plugins/script_task/minify_script_task.js +1 -1
  259. package/dist/modules/corecompiler/summer/plugins/script_task/swc_task.js +1 -1
  260. package/dist/modules/corecompiler/summer/plugins/terser.js +1 -1
  261. package/dist/modules/corecompiler/summer/plugins/typescript.js +1 -1
  262. package/dist/modules/corecompiler/summer/plugins/worklet.js +1 -1
  263. package/dist/modules/corecompiler/summer/utils/ensureArray.js +1 -1
  264. package/dist/modules/corecompiler/summer/utils/inputsourcemap.js +1 -1
  265. package/dist/modules/corecompiler/summer/worker.js +1 -1
  266. package/dist/modules/fullcompiler/app/app.js +1 -1
  267. package/dist/modules/fullcompiler/app/contactandlaunch/updateContactForSubpkg.js +1 -1
  268. package/dist/modules/fullcompiler/app/contactandlaunch/updatecontactandlaunch.js +1 -1
  269. package/dist/modules/nativecompiler/android/adb.js +1 -1
  270. package/dist/modules/nativecompiler/android/device.js +1 -1
  271. package/dist/modules/nativecompiler/ios/device.js +1 -1
  272. package/dist/modules/nativecompiler/ios/projectconfig.js +1 -1
  273. package/dist/modules/nativecompiler/processHandler.js +1 -1
  274. package/dist/project/advance/precompileProject.js +1 -1
  275. package/dist/project/advance/reactiveProject.js +1 -1
  276. package/dist/project/baseProject.js +1 -1
  277. package/dist/services/accountcard/accountcard.js +1 -0
  278. package/dist/services/accountcard/accountcardService.js +1 -0
  279. package/dist/services/app/common/appDirService.devtools.js +1 -0
  280. package/dist/services/app/common/appDirService.js +1 -0
  281. package/dist/services/app/electron/appDirService.js +1 -0
  282. package/dist/services/app/node/appDirService.js +1 -0
  283. package/dist/services/app/nw/appDirService.js +1 -0
  284. package/dist/services/builder/common/builder.js +1 -0
  285. package/dist/services/builder/nw/builder.js +1 -0
  286. package/dist/services/builder/webide/builder.js +1 -0
  287. package/dist/services/common/extensions.js +1 -0
  288. package/dist/services/common/getservice.js +1 -0
  289. package/dist/services/common/librarybase.js +1 -0
  290. package/dist/services/common/vsbase.js +1 -0
  291. package/dist/services/compilewxml/common/compilewxmlService.js +1 -0
  292. package/dist/services/compilewxml/electron/compilewxmlService.js +1 -0
  293. package/dist/services/compilewxml/node/compileUtils.js +1 -0
  294. package/dist/services/compilewxml/node/compileglasseasel.js +1 -0
  295. package/dist/services/compilewxml/nw/compilewxmlService.js +1 -0
  296. package/dist/services/compilewxml/webide/compilewxmlService.js +1 -0
  297. package/dist/services/compilewxml/webide/pageFrameWasm/wcc/runWcc.js +1 -0
  298. package/dist/services/compilewxss/common/compilewxssService.js +1 -0
  299. package/dist/services/compilewxss/electron/compilewxssService.js +1 -0
  300. package/dist/services/compilewxss/node/compileUtils.js +1 -0
  301. package/dist/services/compilewxss/nw/compilewxssService.js +1 -0
  302. package/dist/services/compilewxss/webide/compilewxssService.js +1 -0
  303. package/dist/services/compilewxss/webide/pageFrameWasm/wcsc/runWcsc.js +1 -0
  304. package/dist/services/consoledisplay/common/consoledisplay.js +1 -0
  305. package/dist/services/consoledisplay/nw/consoledisplay.js +1 -0
  306. package/dist/services/fileUtilsManager/common/fileUtilsManager.js +1 -0
  307. package/dist/services/fileUtilsManager/nw/fileUtilsManager.js +1 -0
  308. package/dist/services/fs/common/fileService.js +1 -0
  309. package/dist/services/genTempFile/common/genTempFile.devtools.js +1 -0
  310. package/dist/services/genTempFile/common/genTempFile.node.js +1 -0
  311. package/dist/services/genTempFile/common/genTempFileService.js +1 -0
  312. package/dist/services/genTempFile/electron/genTempFileService.js +1 -0
  313. package/dist/services/genTempFile/node/genTempFileService.js +1 -0
  314. package/dist/services/genTempFile/nw/genTempFileService.js +1 -0
  315. package/dist/services/global/common/global.js +1 -0
  316. package/dist/services/global/nw/global.js +1 -0
  317. package/dist/services/initializeCheck/common/initializeCheck.js +1 -0
  318. package/dist/services/initializeCheck/nw/initializeCheck.js +1 -0
  319. package/dist/services/initializeCheck/webide/initializeCheck.js +1 -0
  320. package/dist/services/locales/common/locales.js +1 -0
  321. package/dist/services/locales/nw/locales.js +1 -0
  322. package/dist/services/log/common/logService.js +1 -0
  323. package/dist/services/miniappjson/common/miniappjson.js +1 -0
  324. package/dist/services/miniappjson/electron/miniappjson.js +1 -0
  325. package/dist/services/miniappjson/nw/miniappjson.js +1 -0
  326. package/dist/services/miniappjson/webide/miniappjson.js +1 -0
  327. package/dist/services/nativeModule/common/nativeModule.impl.js +1 -0
  328. package/dist/services/nativeModule/common/nativeModule.js +1 -0
  329. package/dist/services/nativeModule/electron/nativeModule.js +1 -0
  330. package/dist/services/nativeModule/nw/nativeModule.js +1 -0
  331. package/dist/services/partialcompile/common/parialcompile.impl.js +1 -0
  332. package/dist/services/partialcompile/common/partialcompile.js +1 -0
  333. package/dist/services/partialcompile/nw/partialcompile.js +1 -0
  334. package/dist/services/partialcompile/webide/partialcompile.js +1 -0
  335. package/dist/services/performance/common/performance.js +1 -0
  336. package/dist/services/performance/nw/performance.js +1 -0
  337. package/dist/services/performance/webide/performance.js +1 -0
  338. package/dist/services/project/common/cloudProjectService.js +1 -0
  339. package/dist/services/project/common/createProjectService.js +1 -0
  340. package/dist/services/project/common/project.helper.js +1 -0
  341. package/dist/services/project/common/projectConfigService.js +1 -0
  342. package/dist/services/project/common/projectFileService.js +1 -0
  343. package/dist/services/project/common/projectconfigjsonutils.js +1 -0
  344. package/dist/services/project/electron-backend/projectManagerService.js +1 -0
  345. package/dist/services/project/node/createProjectService.js +1 -0
  346. package/dist/services/project/node/projectConfigService.js +1 -0
  347. package/dist/services/project/node/projectManagerService.js +1 -0
  348. package/dist/services/project/web/projectManagerService.js +1 -0
  349. package/dist/services/project/webide/projectConfigService.js +1 -0
  350. package/dist/services/project/webide/projectFileService.js +1 -0
  351. package/dist/services/project/webide/projectManagerService.js +1 -0
  352. package/dist/services/projectManager/common/buildServerProjectManager.js +1 -0
  353. package/dist/services/projectManager/common/projectManager.js +1 -0
  354. package/dist/services/projectManager/nw/projectManager.js +1 -0
  355. package/dist/services/root/common/createService.js +1 -0
  356. package/dist/services/root/electron/root.js +1 -0
  357. package/dist/services/root/electron/rootService.js +1 -0
  358. package/dist/services/root/node/root.js +1 -0
  359. package/dist/services/root/node/rootService.js +1 -0
  360. package/dist/services/root/nw/root.js +1 -0
  361. package/dist/services/root/nw/rootService.js +1 -0
  362. package/dist/services/staticConfig/common/staticConfigService.js +1 -0
  363. package/dist/services/staticConfig/nw/staticConfigService.js +1 -0
  364. package/dist/services/store/common/storeService.js +1 -0
  365. package/dist/services/uniapp/common/uniapp.js +1 -0
  366. package/dist/services/uniapp/nw/uniapp.js +1 -0
  367. package/dist/services/uniapp/webide/uniapp.js +1 -0
  368. package/dist/services/vendor/common/utils.js +1 -0
  369. package/dist/services/vendor/common/vendorService.js +1 -0
  370. package/dist/services/vendor/node/vendorService.js +1 -0
  371. package/dist/services/vendor/webide/vendorService.js +1 -0
  372. package/dist/types/ci.js +1 -1
  373. package/dist/utils/asyncTask/index.js +1 -1
  374. package/dist/utils/babel_helper.js +1 -1
  375. package/dist/utils/cache.js +1 -1
  376. package/dist/utils/codesign.js +1 -1
  377. package/dist/utils/common.js +1 -1
  378. package/dist/utils/cosUpload.js +1 -1
  379. package/dist/utils/cp.js +1 -1
  380. package/dist/utils/customError.js +1 -1
  381. package/dist/utils/debug.js +1 -1
  382. package/dist/utils/download.js +1 -1
  383. package/dist/utils/env.js +1 -1
  384. package/dist/utils/fs.js +1 -1
  385. package/dist/utils/genTempFile.js +1 -1
  386. package/dist/utils/generateIpa.js +1 -1
  387. package/dist/utils/glob.js +1 -1
  388. package/dist/utils/helper_util.js +1 -1
  389. package/dist/utils/jsonParse.js +1 -1
  390. package/dist/utils/miniapp-builder.js +1 -1
  391. package/dist/utils/miniappJson.js +1 -1
  392. package/dist/utils/node/common.js +1 -0
  393. package/dist/utils/officialDonutPlugin.js +1 -1
  394. package/dist/utils/packOptionsHelper.js +1 -1
  395. package/dist/utils/progressRecorder.js +1 -1
  396. package/dist/utils/report.js +1 -1
  397. package/dist/utils/request.js +1 -1
  398. package/dist/utils/sign.js +1 -1
  399. package/dist/utils/signature.js +1 -1
  400. package/dist/utils/singletontask.js +1 -1
  401. package/dist/utils/subprocess/entryProcess.js +1 -1
  402. package/dist/utils/subprocess/processService.js +1 -1
  403. package/dist/utils/subprocess/stringifyPostMsg.js +1 -1
  404. package/dist/utils/swc_helper.js +1 -1
  405. package/dist/utils/tools.js +1 -1
  406. package/dist/utils/usbProcess.js +1 -1
  407. package/dist/utils/web/common.js +1 -0
  408. package/dist/utils/white_ext_list.js +1 -1
  409. package/dist/utils/wxapkg/pack.js +1 -1
  410. package/dist/utils/wxvpkgreader/wxvpkg/unpack/version0.js +1 -1
  411. package/dist/utils/wxvpkgreader/wxvpkg/unpack/version10.js +1 -1
  412. package/dist/utils/zip.js +1 -1
  413. package/dist/vendor/vslibrary/bundled/base.bundled.js +2 -0
  414. package/package.json +1 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkAccountCardPackage=exports.checkRequiredPrivateInfos=exports.checkResolveAlias=exports.checkRenderer=exports.checkOpenDataContext=exports.getAppJSONVariableDecalearProperty=exports.checkEntranceDeclare=exports.checkComponentPath=exports.checkMainPkgPluginIsInSubPkg=exports.checkMainPkgPageIsInSubpkg=exports.checkTabbarPage=exports.checkEntryPagePath=exports.checkPreloadRule=exports.checkFunctionalPages=exports.checkNavigateToMiniProgramAppIdList=exports.checkPlugins=exports.checkSubpackages=exports.checkSitemapLocation=exports.checkMainPkgPages=exports.checkOpenLocationPagePath=exports.checkWorkers=exports.checkTabbar=exports.checkWindow=exports.checkPageExist=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=tslib_1.__importDefault(require("lodash")),config_1=require("../../../../../config/config"),common_1=require("../common"),common_2=require("../../../../../utils/common"),tools_1=require("../../../../../utils/tools"),locales_1=tslib_1.__importDefault(require("../../../../../utils/locales/locales")),schemaValidate_1=require("../../validate/schemaValidate"),projectconfig_1=require("../projectconfig");function checkPageExist(o,t,e){const{miniprogramRoot:a,project:n,filePath:c}=o;n.stat(a,t+".wxml")||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(e,t+".wxml"),code:config_1.FILE_NOT_FOUND,filePath:c}),n.stat(a,t+".js")||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(e,t+".js"),code:config_1.FILE_NOT_FOUND,filePath:c})}function checkWindow(o){const{inputJSON:t,mode:e}=o;let a=""+o.filePath;t.themeLocation&&(a+=` or ${t.themeLocation}["${e}"]`);const n=[],{window:c}=t;c&&(void 0!==c.navigationBarBackgroundColor&&((0,tools_1.isHexColor)(c.navigationBarBackgroundColor)||n.push(`["window"]["navigationBarBackgroundColor"]: "${c.navigationBarBackgroundColor}" is not hexColor`)),void 0!==c.backgroundColor&&((0,tools_1.isHexColor)(c.backgroundColor)||n.push(`["window"]["backgroundColor"]: "${c.backgroundColor}" is not hexColor`)),n.length>0&&(0,common_2.throwError)({msg:n.join("\n"),filePath:a}))}function checkTabbar(o){const{project:t,miniprogramRoot:e,inputJSON:a,mode:n}=o;let c=""+o.filePath;a.themeLocation&&(c+=` or ${a.themeLocation}["${n}"]`);const{tabBar:i}=a,r=t.attrSync(),{setting:s}=r;if(!i)return;const l=[];i.list.length<s.MinTabbarCount&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_TABBAR_AT_LEAST.format(s.MinTabbarCount),filePath:c});const _=i.custom?s.MaxCustomTabbarCount:s.MaxTabbarCount;i.list.length>_&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_TABBAR_AT_MOST.format(_),filePath:c});for(let o=0;o<i.list.length;o++){const a=i.list[o],{pagePath:n}=a;if((0,common_2.checkPath)({value:n,tips:`["tabBar"]["list"][${o}]["pagePath"]`,filePath:c}),!n){l.push(locales_1.default.config.JSON_TABBAR_PATH_EMPTY.format(o));continue}n.indexOf("?")>=0&&l.push(locales_1.default.config.JSON_SHOULD_NOT_CONTAIN.format(`["tabBar"]["list"][${o}]["pagePath"]`,"?")),n.indexOf(".")>=0&&l.push(locales_1.default.config.JSON_SHOULD_NOT_CONTAIN.format(`["tabBar"]["list"][${o}]["pagePath"]`,"."));const r=i.list.slice(0,o).findIndex(o=>o.pagePath===n);r>=0&&l.push(locales_1.default.config.JSON_TABBAR_PATH_SAME_WITH_OTHER.format(o,r));const _=[];a.iconPath&&((0,common_2.checkPath)({value:a.iconPath,tips:`["tabBar"]["list"][${o}]["iconPath"]`,filePath:c,checkPathType:common_2.ECheckPathType.TAB_BAR_ICON}),_.push({name:"iconPath",path:a.iconPath})),a.selectedIconPath&&((0,common_2.checkPath)({value:a.selectedIconPath,tips:`["tabBar"]["list"][${o}]["selectedIconPath"]`,filePath:c,checkPathType:common_2.ECheckPathType.TAB_BAR_ICON}),_.push({name:"selectedIconPath",path:a.selectedIconPath})),_.forEach(a=>{const n=t.stat(e,a.path);if(!n)return void l.push(locales_1.default.config.NOT_FOUND.format(`["tabBar"]["list"][${o}]["${a.name}"]: "${a.path}"`));if(n.isDirectory)return void l.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(`["tabBar"]["list"][${o}]["${a.name}"]`,locales_1.default.config.FILE));n.size>1024*s.MaxTabbarIconSize&&l.push(locales_1.default.config.JSON_TABBAR_ICON_MAX_SIZE.format([o,a.name,s.MaxTabbarIconSize]));const c=path_1.default.posix.extname(a.path);config_1.TABBAR_ICON_WHITE_LIST.indexOf(c)<0&&l.push(locales_1.default.config.JSON_TABBAR_ICON_EXT.format([o,a.name,config_1.TABBAR_ICON_WHITE_LIST.join("、")]))})}l.length>0&&(0,common_2.throwError)({msg:l.join("\n"),filePath:c})}function checkWorkers(o){const{project:t,miniprogramRoot:e,filePath:a,inputJSON:n}=o,{workers:c}=n;if(void 0===c)return;const i='["workers"]';""===c&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(i,locales_1.default.config.DIRECTORY),filePath:a});const r=(0,tools_1.getWorkersPath)(c);(0,common_2.checkPath)({value:r,tips:i,filePath:a});const s=t.stat(e,r);s&&s.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([i,locales_1.default.config.DIRECTORY]),filePath:a}),"string"==typeof n.workers?n.workers=(0,tools_1.normalizePath)(n.workers+"/"):n.workers.path=(0,tools_1.normalizePath)(n.workers.path+"/")}function checkOpenLocationPagePath(o){const{filePath:t,inputJSON:e}=o,{openLocationPagePath:a}=e;if(void 0===a)return;const n='["openLocationPagePath"]';(0,common_2.checkPath)({value:a,tips:n,filePath:t}),checkPageExist(o,a,n)}exports.checkPageExist=checkPageExist,exports.checkWindow=checkWindow,exports.checkTabbar=checkTabbar,exports.checkWorkers=checkWorkers,exports.checkOpenLocationPagePath=checkOpenLocationPagePath;const checkMainPkgPages=o=>{const{filePath:t,inputJSON:e}=o,{pages:a}=e;if(!a)return;const n={};for(let e=0;e<a.length;e++){const c=a[e],i=`["pages"][${e}]`;(0,common_2.checkPath)({value:c,tips:i,filePath:t}),n[c]&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_PAGES_REPEAT.format(`"${c}"`,'["pages"]'),filePath:t}),n[c]=!0,checkPageExist(o,c,i)}};function checkSitemapLocation(o){const{filePath:t,inputJSON:e}=o,{sitemapLocation:a}=e;if(void 0===a)return;const{project:n,miniprogramRoot:c}=o,i='["sitemapLocation"]';(0,common_2.checkPath)({value:a,tips:i,filePath:t});const r=n.stat(c,a);r&&!r.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(i,a),filePath:t});".json"!==path_1.default.posix.extname(a)&&(0,common_2.throwError)({msg:locales_1.default.config.EXT_SHOULD_BE_ERROR.format(i,".json"),filePath:t});const s=n.getFile(c,a),l=(0,common_2.checkUTF8)(s,a),_=(0,common_1.checkJSONFormat)(l,a),f=(0,schemaValidate_1.schemaValidate)("sitemap",_);(0,schemaValidate_1.transValidateResult)(a,f)}function checkSubpackages(o){const{project:t,miniprogramRoot:e,filePath:a,inputJSON:n}=o;let c='["subPackages"]';n.subpackages&&(c='["subpackages"]',n.subPackages=n.subpackages,delete n.subpackages);const i=[];if(n.subPackages){const r=t.attrSync(),{setting:s}=r;n.subPackages.length>s.MaxSubPackageLimit&&(0,common_2.throwError)({msg:locales_1.default.config.EXCEED_LIMIT.format([c,s.MaxSubPackageLimit]),filePath:a});const l={},_={};for(let r=0;r<n.subPackages.length;r++){const s=n.subPackages[r],f=`${c}[${r}]`;if((0,common_2.checkPath)({value:s.root,tips:`${c}[${r}]["root"]`,filePath:a}),s.root===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){i.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${c}[${r}]["root"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(s.name){if(s.name===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){i.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${c}[${r}]["name"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(_[s.name]){i.push(locales_1.default.config.SAME_ITEM.format(f,_[s.name],"name"));continue}_[s.name]=f}if(s.root=(0,tools_1.normalizePath)(s.root+"/"),l[s.root]){i.push(locales_1.default.config.SAME_ITEM.format(f,l[s.root],"root"));continue}l[s.root]=f;const h=t.stat(e,s.root);if(!h){i.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`${c}[${r}]["root"]`,locales_1.default.config.DIRECTORY]));continue}if(!h.isDirectory){i.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`${c}[${r}]["root"]`,locales_1.default.config.DIRECTORY]));continue}const g={};for(let t=0,e=s.pages.length;t<e;t++){const e=s.pages[t];(0,common_2.checkPath)({value:e,tips:`${c}[${r}]["pages"][${t}]`,filePath:a});const n=(0,tools_1.normalizePath)(path_1.default.posix.join(s.root,e));g[n]?i.push(locales_1.default.config.JSON_PAGES_REPEAT.format([`"${e}"`,`${c}[${r}]`])):(g[n]=!0,checkPageExist(o,n,`${c}[${r}]["pages"][${t}]`))}}i.length>0&&(0,common_2.throwError)({msg:i.join("\n"),filePath:a});for(let o=0;o<n.subPackages.length;o++){const t=n.subPackages[o];let e=-1;const a="/"+t.root;n.subPackages.forEach((t,n)=>{if(n!==o&&t.root){const o="/"+t.root;a.startsWith(o)&&(e=n)}}),-1===e||i.push(locales_1.default.config.JSON_SHOULD_NOT_CONTAIN.format(`${c}[${e}]["root"]`,`${c}[${o}]["root"]`))}i.length>0&&(0,common_2.throwError)({msg:i.join("\n"),filePath:a})}}function checkPlugins(o){const{filePath:t,inputJSON:e,project:a}=o,n=[],c=e.plugins||{},i=(0,projectconfig_1.getProjectConfigJSON)(a),r=(null==i?void 0:i.pluginAppid)||a.appid;function s(o,t){const e=a.type===config_1.COMPILE_TYPE.miniProgramPlugin;if(e||"dev"!==o.version)if(e)"dev"===o.version&&o.provider!==r?n.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t+'["provider"]',`"${r}"`)):o.provider===r&&"dev"!==o.version&&n.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t+'["version"]','"dev"'));else{if("dev"===o.version||"latest"===o.version||/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/.test(o.version)||/^dev-[A-Za-z0-9]+$/.test(o.version))return!0;n.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([t+'["version"]',locales_1.default.config.TRIPLE_NUMBER_DOT]))}else n.push(`${locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(t+'["version"]',"dev")}\n${locales_1.default.config.PLEASE_CHOOSE_PLUGIN_MODE}`)}for(const o in c){s(c[o],`["plugins"]["${o}"]`)}e.subPackages&&e.subPackages.forEach((o,t)=>{if(!o.plugins)return;const e=`["subPackages"][${t}]`;for(const t in o.plugins){s(o.plugins[t],`${e}["plugins"]["${t}"]`)}}),n.length>0&&(0,common_2.throwError)({msg:n.join("\n"),filePath:t})}function checkNavigateToMiniProgramAppIdList(o){const{filePath:t,inputJSON:e,project:a}=o,n=[];if(e.navigateToMiniProgramAppIdList){const o=a.attrSync(),{appType:t=config_1.APP_TYPE.NORMAL,setting:c}=o;if(t!==config_1.APP_TYPE.NATIVE){const o=null==c?void 0:c.NavigateMiniprogramLimit;e.navigateToMiniProgramAppIdList.length>o&&n.push(locales_1.default.config.EXCEED_LIMIT.format('["navigateToMiniProgramAppIdList"]',o))}}n.length>0&&(0,common_2.throwError)({msg:n.join("\n"),filePath:t})}function checkFunctionalPages(o){const{inputJSON:t}=o;if(t.functionalPages&&"object"!==(0,tools_1.getType)(t.functionalPages)){const o='["functionalPages"] 配置需要更新,详见文档: https://developers.weixin.qq.com/miniprogram/dev/framework/plugin/functional-pages.html';t.__warning__?t.__warning__=`${t.__warning__}\n${o}`:t.__warning__=o}}function checkPreloadRule(o,t){const{inputJSON:e,filePath:a}=o,{preloadRule:n,subPackages:c}=e;if(!n||!c)return;const i=[],r={},s={},l={};t.forEach(o=>{r[o.root]=!0,l[o.path]=!0,o.name&&(s[o.name]=!0)});for(const o in n){if(!l[o]&&!o.includes("__plugin__/")){i.push(locales_1.default.config.NOT_FOUND.format(`["preloadRule"]["${o}"]: ${locales_1.default.config.PAGE_PATH}`));continue}const t=n[o];for(let e=0,a=t.packages.length;e<a;e++){let a=t.packages[e];a!==config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT&&(s[a]||(a=(0,tools_1.normalizePath)(a+"/"),r[a]||i.push(locales_1.default.config.NOT_FOUND.format(`["preloadRule"]["${o}"]["packages"][${e}]: ${a}`))))}}i.length>0&&(0,common_2.throwError)({msg:i.join("\n"),filePath:a})}function checkEntryPagePath(o,t){const{inputJSON:e,filePath:a}=o,{entryPagePath:n}=e;if(!n)return;(0,common_2.checkPath)({value:n,tips:'["entryPagePath"]',filePath:a});let c=!1;for(const o of t)if(o.path===n){c=!0;break}c||(0,common_2.throwError)({msg:locales_1.default.config.JSON_ENTRY_PAGE_PATH_NOT_FOUND.format(["pages、subPackages","entryPagePath"]),filePath:a})}function checkTabbarPage(o){const{filePath:t,inputJSON:e}=o,{tabBar:a,pages:n=[]}=e;if(!a)return;const c=[];for(let o=0;o<a.list.length;o++){const t=a.list[o],{pagePath:e}=t;n.indexOf(e)<0&&c.push(`["tabBar"][${o}]["pagePath"]: "${e}" need in ["pages"]`)}c.length>0&&(0,common_2.throwError)({msg:c.join("\n"),filePath:t})}function checkMainPkgPageIsInSubpkg(o){const{filePath:t,inputJSON:e}=o,{subPackages:a,pages:n=[]}=e;if(!a)return;const c=[];for(let o=0;o<a.length;o++){const t=a[o];for(let e=0;e<n.length;e++){const a=n[e];a.startsWith(t.root)&&c.push(locales_1.default.config.SHOULD_NOT_IN.format([`["pages"][${e}]: "${a}"`,`["subPackages"][${o}]`]))}}c.length>0&&(0,common_2.throwError)({msg:c.join("\n"),filePath:t})}function checkMainPkgPluginIsInSubPkg(o){const{filePath:t,inputJSON:e}=o,{plugins:a={},subPackages:n}=e,c={},i={},r=[];for(const o in a){const t=a[o],e=`["plugins"]["${o}"]`;c[t.provider]?r.push(locales_1.default.config.SAME_ITEM.format(`["plugins"]["${o}"]`,c[t.provider].tips,"provider")):c[t.provider]=i[o]={provider:t.provider,version:t.version,alias:o,tips:e}}if(n)for(let o=0;o<n.length;o++){const t=n[o];if(t.plugins)for(const e in t.plugins){const a=`["subPackages"][${o}]["plugins"]`,n=t.plugins[e];c[n.provider]?r.push(locales_1.default.config.SAME_ITEM.format(`${a}["${e}"]`,c[n.provider].tips,"provider")):i[e]?r.push(locales_1.default.config.PLUGINS_SAME_ALIAS.format(`${a}["${e}"]`,i[e].tips)):c[n.provider]=i[e]={provider:n.provider,version:n.version,alias:n,tips:a}}}r.length>0&&(0,common_2.throwError)({msg:r.join("\n"),filePath:t})}function checkComponentPath(o){const{project:t,miniprogramRoot:e,filePath:a,inputJSON:n}=o;(0,common_1.checkComponentPath)({project:t,root:e,relativePath:path_1.default.posix.relative(e,a),inputJSON:n})}function checkEntranceDeclare(o){const t=o.inputJSON;if(!t.entranceDeclare||!t.entranceDeclare.locationMessage)return;let e=t.pages||[];t.subpackages&&(e=e.concat(t.subpackages.map(o=>o.pages.map(t=>o.root+t))),e=lodash_1.default.flattenDeep(e)),t.subPackages&&(e=e.concat(t.subPackages.map(o=>o.pages.map(t=>o.root+t))),e=lodash_1.default.flattenDeep(e));const a=[],n=t.entranceDeclare.locationMessage.path;void 0===n?a.push(locales_1.default.config.JSON_ENTRANCE_DECLARE_PATH_EMPTY.format([])):e.includes(n)||a.push(locales_1.default.config.JSON_ENTRANCE_DECLARE_PATH_ERR.format([n||"undefined"])),a.length>0&&(0,common_2.throwError)({msg:a.join("\n"),filePath:o.filePath})}function getAppJSONVariableDecalearProperty(o){const{windowPropertWhiteList:t,tabBarPropertyWhiteList:e,tabbarListItemPropertyWhiteList:a}=config_1.jsonVariablePropertyWhiteList;let n=[];return"[object Object]"===Object.prototype.toString.call(o.window)&&(n=n.concat(Object.keys(o.window).filter(o=>t.includes(o)).map(t=>({property:`["window"]["${t}"]`,value:o.window[t]})).filter(o=>"string"==typeof o.value&&o.value.startsWith("@")))),"[object Object]"===Object.prototype.toString.call(o.tabBar)&&(n=n.concat(Object.keys(o.tabBar).filter(o=>e.includes(o)).map(t=>({property:`["tabBar"]["${t}"]`,value:o.tabBar[t]})).filter(o=>"string"==typeof o.value&&o.value.startsWith("@"))),Array.isArray(o.tabBar.list)&&o.tabBar.list.forEach((t,e)=>{n=n.concat(Object.keys(t).filter(o=>a.includes(o)).map(t=>({property:`["tabBar"]["list"][${e}]["${t}"]`,value:o.tabBar.list[e][t]})).filter(o=>"string"==typeof o.value&&o.value.startsWith("@")))})),n}function checkOpenDataContext(o,t){const{project:e,miniprogramRoot:a,filePath:n}=o,{openDataContext:c}=t;if(void 0===c)return;(0,common_2.checkPath)({value:c,tips:'["openDataContext"]',filePath:n});const i=e.stat(a,c);i&&i.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(['["openDataContext"]',locales_1.default.config.DIRECTORY]),filePath:n});const r=path_1.default.posix.join(c,"./index.js"),s=e.stat(a,r);s&&s.isFile||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["openDataContext"]',r),filePath:n}),t.openDataContext=(0,tools_1.normalizePath)(c+"/")}function checkRenderer(o){var t,e,a,n;const{filePath:c,inputJSON:i}=o,{renderer:r,lazyCodeLoading:s,rendererOptions:l}=i;if("skyline"===r&&"requiredComponents"!==s&&(0,common_2.throwError)({msg:locales_1.default.config.APP_JSON_SHOULD_SET_LAZYCODELOADING.format("app.json"),filePath:c}),"skyline"===r&&(void 0===l?(0,common_2.throwError)({msg:locales_1.default.config.JSON_SHOULD_SET_RENDEREROPTIONS.format("app.json"),filePath:c}):void 0===l.skyline&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_SHOULD_SET_RENDEREROPTIONS_SKYLINE.format("app.json"),filePath:c})),"skyline"===r||(null==l?void 0:l.skyline)){const o=(null===(t=i.window)||void 0===t?void 0:t.navigationBarTextStyle)||(null===(e=i.window)||void 0===e?void 0:e.navigationBarTitleText)||(null===(a=i.window)||void 0===a?void 0:a.navigationBarBackgroundColor),c="custom"===(null===(n=i.window)||void 0===n?void 0:n.navigationStyle);if(o&&!c){const o=locales_1.default.config.APP_JSON_SKYLINE_WINDOW_TIPS.format("");i.__warning__?i.__warning__=`${i.__warning__}\n${o}`:i.__warning__=o}}}function checkResolveAlias(o){const{filePath:t,inputJSON:e}=o,{resolveAlias:a}=e;if(a){const o=o=>o.includes("//");for(const e in a)(o(e)||o(a[e]))&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_RESOLVE_ALIAS_ILLEGAL.format(e,a[e]),filePath:t}),a[e].startsWith("./")&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_RESOLVE_ALIAS_SHOULD_NOT_START_WITH.format(a[e]),filePath:t}),e.endsWith("/*")&&a[e].endsWith("/*")||(0,common_2.throwError)({msg:locales_1.default.config.JSON_RESOLVE_ALIAS_INCLUDE_STAR.format(e,a[e]),filePath:t})}}exports.checkMainPkgPages=checkMainPkgPages,exports.checkSitemapLocation=checkSitemapLocation,exports.checkSubpackages=checkSubpackages,exports.checkPlugins=checkPlugins,exports.checkNavigateToMiniProgramAppIdList=checkNavigateToMiniProgramAppIdList,exports.checkFunctionalPages=checkFunctionalPages,exports.checkPreloadRule=checkPreloadRule,exports.checkEntryPagePath=checkEntryPagePath,exports.checkTabbarPage=checkTabbarPage,exports.checkMainPkgPageIsInSubpkg=checkMainPkgPageIsInSubpkg,exports.checkMainPkgPluginIsInSubPkg=checkMainPkgPluginIsInSubPkg,exports.checkComponentPath=checkComponentPath,exports.checkEntranceDeclare=checkEntranceDeclare,exports.getAppJSONVariableDecalearProperty=getAppJSONVariableDecalearProperty,exports.checkOpenDataContext=checkOpenDataContext,exports.checkRenderer=checkRenderer,exports.checkResolveAlias=checkResolveAlias;const detailLocationApis={getLocation:!0,onLocationChange:!0,startLocationUpdate:!0,startLocationUpdateBackground:!0};function checkRequiredPrivateInfos(o){const{filePath:t,inputJSON:e}=o,{requiredPrivateInfos:a}=e;if(a){if(a.indexOf("getFuzzyLocation")>=0){const o=[];for(let t=0;t<a.length;t++){const e=a[t];detailLocationApis[e]&&o.push(`'${e}'`)}o.length>0&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_REQUIRED_PRIVATE_INFOS_MUTUALLY_EXCLUSIVE.format("'getFuzzyLocation'",o.join("、")),filePath:t})}}}function checkAccountCardPackage(o){const{project:t,filePath:e,inputJSON:a,miniprogramRoot:n}=o,{accountCardPackage:c}=a;if(c){c.root=(0,tools_1.normalizePath)(c.root+"/");const o=a.subPackages||a.subpackages||[];console.log("subPackages",o),o.find(o=>o.root===c.root&&o.independent)||(0,common_2.throwError)({msg:locales_1.default.config.ACCOUNT_CARD_PACKAPGE_IN_VALID.format(),filePath:e});for(const o of c.cardList){const{componentPath:a}=o,i=path_1.default.posix.join(c.root,a+".js");t.stat(n,path_1.default.posix.join(c.root,a+".js"))||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["accountCardPackage"]',i),code:config_1.FILE_NOT_FOUND,filePath:e})}}}exports.checkRequiredPrivateInfos=checkRequiredPrivateInfos,exports.checkAccountCardPackage=checkAccountCardPackage;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkMainPkgPages=void 0,exports.checkPageExist=checkPageExist,exports.checkWindow=checkWindow,exports.checkTabbar=checkTabbar,exports.checkWorkers=checkWorkers,exports.checkOpenLocationPagePath=checkOpenLocationPagePath,exports.checkSitemapLocation=checkSitemapLocation,exports.checkSubpackages=checkSubpackages,exports.checkPlugins=checkPlugins,exports.checkNavigateToMiniProgramAppIdList=checkNavigateToMiniProgramAppIdList,exports.checkFunctionalPages=checkFunctionalPages,exports.checkPreloadRule=checkPreloadRule,exports.checkEntryPagePath=checkEntryPagePath,exports.checkTabbarPage=checkTabbarPage,exports.checkMainPkgPageIsInSubpkg=checkMainPkgPageIsInSubpkg,exports.checkMainPkgPluginIsInSubPkg=checkMainPkgPluginIsInSubPkg,exports.checkComponentPath=checkComponentPath,exports.checkEntranceDeclare=checkEntranceDeclare,exports.getAppJSONVariableDecalearProperty=getAppJSONVariableDecalearProperty,exports.checkOpenDataContext=checkOpenDataContext,exports.checkRenderer=checkRenderer,exports.checkResolveAlias=checkResolveAlias,exports.checkRequiredPrivateInfos=checkRequiredPrivateInfos,exports.checkAccountCardPackage=checkAccountCardPackage;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=tslib_1.__importDefault(require("lodash")),config_1=require("../../../../../config/config"),common_1=require("../common"),common_2=require("../../../../../utils/common"),tools_1=require("../../../../../utils/tools"),locales_1=tslib_1.__importDefault(require("../../../../../utils/locales/locales")),schemaValidate_1=require("../../validate/schemaValidate"),projectconfig_1=require("../projectconfig");function checkPageExist(o,t,e){const{miniprogramRoot:a,project:n,filePath:c}=o;n.stat(a,t+".wxml")||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(e,t+".wxml"),code:config_1.FILE_NOT_FOUND,filePath:c}),n.stat(a,t+".js")||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(e,t+".js"),code:config_1.FILE_NOT_FOUND,filePath:c})}function checkWindow(o){const{inputJSON:t,mode:e}=o;let a=""+o.filePath;t.themeLocation&&(a+=` or ${t.themeLocation}["${e}"]`);const n=[],{window:c}=t;c&&(void 0!==c.navigationBarBackgroundColor&&((0,tools_1.isHexColor)(c.navigationBarBackgroundColor)||n.push(`["window"]["navigationBarBackgroundColor"]: "${c.navigationBarBackgroundColor}" is not hexColor`)),void 0!==c.backgroundColor&&((0,tools_1.isHexColor)(c.backgroundColor)||n.push(`["window"]["backgroundColor"]: "${c.backgroundColor}" is not hexColor`)),n.length>0&&(0,common_2.throwError)({msg:n.join("\n"),filePath:a}))}function checkTabbar(o){const{project:t,miniprogramRoot:e,inputJSON:a,mode:n}=o;let c=""+o.filePath;a.themeLocation&&(c+=` or ${a.themeLocation}["${n}"]`);const{tabBar:i}=a,r=t.attrSync(),{setting:s}=r;if(!i)return;const l=[];i.list.length<s.MinTabbarCount&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_TABBAR_AT_LEAST.format(s.MinTabbarCount),filePath:c});const _=i.custom?s.MaxCustomTabbarCount:s.MaxTabbarCount;i.list.length>_&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_TABBAR_AT_MOST.format(_),filePath:c});for(let o=0;o<i.list.length;o++){const a=i.list[o],{pagePath:n}=a;if((0,common_2.checkPath)({value:n,tips:`["tabBar"]["list"][${o}]["pagePath"]`,filePath:c}),!n){l.push(locales_1.default.config.JSON_TABBAR_PATH_EMPTY.format(o));continue}n.indexOf("?")>=0&&l.push(locales_1.default.config.JSON_SHOULD_NOT_CONTAIN.format(`["tabBar"]["list"][${o}]["pagePath"]`,"?")),n.indexOf(".")>=0&&l.push(locales_1.default.config.JSON_SHOULD_NOT_CONTAIN.format(`["tabBar"]["list"][${o}]["pagePath"]`,"."));const r=i.list.slice(0,o).findIndex(o=>o.pagePath===n);r>=0&&l.push(locales_1.default.config.JSON_TABBAR_PATH_SAME_WITH_OTHER.format(o,r));const _=[];a.iconPath&&((0,common_2.checkPath)({value:a.iconPath,tips:`["tabBar"]["list"][${o}]["iconPath"]`,filePath:c,checkPathType:common_2.ECheckPathType.TAB_BAR_ICON}),_.push({name:"iconPath",path:a.iconPath})),a.selectedIconPath&&((0,common_2.checkPath)({value:a.selectedIconPath,tips:`["tabBar"]["list"][${o}]["selectedIconPath"]`,filePath:c,checkPathType:common_2.ECheckPathType.TAB_BAR_ICON}),_.push({name:"selectedIconPath",path:a.selectedIconPath})),_.forEach(a=>{const n=t.stat(e,a.path);if(!n)return void l.push(locales_1.default.config.NOT_FOUND.format(`["tabBar"]["list"][${o}]["${a.name}"]: "${a.path}"`));if(n.isDirectory)return void l.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(`["tabBar"]["list"][${o}]["${a.name}"]`,locales_1.default.config.FILE));n.size>1024*s.MaxTabbarIconSize&&l.push(locales_1.default.config.JSON_TABBAR_ICON_MAX_SIZE.format([o,a.name,s.MaxTabbarIconSize]));const c=path_1.default.posix.extname(a.path);config_1.TABBAR_ICON_WHITE_LIST.indexOf(c)<0&&l.push(locales_1.default.config.JSON_TABBAR_ICON_EXT.format([o,a.name,config_1.TABBAR_ICON_WHITE_LIST.join("、")]))})}l.length>0&&(0,common_2.throwError)({msg:l.join("\n"),filePath:c})}function checkWorkers(o){const{project:t,miniprogramRoot:e,filePath:a,inputJSON:n}=o,{workers:c}=n;if(void 0===c)return;const i='["workers"]';""===c&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(i,locales_1.default.config.DIRECTORY),filePath:a});const r=(0,tools_1.getWorkersPath)(c);(0,common_2.checkPath)({value:r,tips:i,filePath:a});const s=t.stat(e,r);s&&s.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([i,locales_1.default.config.DIRECTORY]),filePath:a}),"string"==typeof n.workers?n.workers=(0,tools_1.normalizePath)(n.workers+"/"):n.workers.path=(0,tools_1.normalizePath)(n.workers.path+"/")}function checkOpenLocationPagePath(o){const{filePath:t,inputJSON:e}=o,{openLocationPagePath:a}=e;if(void 0===a)return;const n='["openLocationPagePath"]';(0,common_2.checkPath)({value:a,tips:n,filePath:t}),checkPageExist(o,a,n)}const checkMainPkgPages=o=>{const{filePath:t,inputJSON:e}=o,{pages:a}=e;if(!a)return;const n={};for(let e=0;e<a.length;e++){const c=a[e],i=`["pages"][${e}]`;(0,common_2.checkPath)({value:c,tips:i,filePath:t}),n[c]&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_PAGES_REPEAT.format(`"${c}"`,'["pages"]'),filePath:t}),n[c]=!0,checkPageExist(o,c,i)}};function checkSitemapLocation(o){const{filePath:t,inputJSON:e}=o,{sitemapLocation:a}=e;if(void 0===a)return;const{project:n,miniprogramRoot:c}=o,i='["sitemapLocation"]';(0,common_2.checkPath)({value:a,tips:i,filePath:t});const r=n.stat(c,a);r&&!r.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(i,a),filePath:t});".json"!==path_1.default.posix.extname(a)&&(0,common_2.throwError)({msg:locales_1.default.config.EXT_SHOULD_BE_ERROR.format(i,".json"),filePath:t});const s=n.getFile(c,a),l=(0,common_2.checkUTF8)(s,a),_=(0,common_1.checkJSONFormat)(l,a),f=(0,schemaValidate_1.schemaValidate)("sitemap",_);(0,schemaValidate_1.transValidateResult)(a,f)}function checkSubpackages(o){const{project:t,miniprogramRoot:e,filePath:a,inputJSON:n}=o;let c='["subPackages"]';n.subpackages&&(c='["subpackages"]',n.subPackages=n.subpackages,delete n.subpackages);const i=[];if(n.subPackages){const r=t.attrSync(),{setting:s}=r;n.subPackages.length>s.MaxSubPackageLimit&&(0,common_2.throwError)({msg:locales_1.default.config.EXCEED_LIMIT.format([c,s.MaxSubPackageLimit]),filePath:a});const l={},_={};for(let r=0;r<n.subPackages.length;r++){const s=n.subPackages[r],f=`${c}[${r}]`;if((0,common_2.checkPath)({value:s.root,tips:`${c}[${r}]["root"]`,filePath:a}),s.root===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){i.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${c}[${r}]["root"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(s.name){if(s.name===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){i.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${c}[${r}]["name"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(_[s.name]){i.push(locales_1.default.config.SAME_ITEM.format(f,_[s.name],"name"));continue}_[s.name]=f}if(s.root=(0,tools_1.normalizePath)(s.root+"/"),l[s.root]){i.push(locales_1.default.config.SAME_ITEM.format(f,l[s.root],"root"));continue}l[s.root]=f;const h=t.stat(e,s.root);if(!h){i.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`${c}[${r}]["root"]`,locales_1.default.config.DIRECTORY]));continue}if(!h.isDirectory){i.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`${c}[${r}]["root"]`,locales_1.default.config.DIRECTORY]));continue}const g={};for(let t=0,e=s.pages.length;t<e;t++){const e=s.pages[t];(0,common_2.checkPath)({value:e,tips:`${c}[${r}]["pages"][${t}]`,filePath:a});const n=(0,tools_1.normalizePath)(path_1.default.posix.join(s.root,e));g[n]?i.push(locales_1.default.config.JSON_PAGES_REPEAT.format([`"${e}"`,`${c}[${r}]`])):(g[n]=!0,checkPageExist(o,n,`${c}[${r}]["pages"][${t}]`))}}i.length>0&&(0,common_2.throwError)({msg:i.join("\n"),filePath:a});for(let o=0;o<n.subPackages.length;o++){const t=n.subPackages[o];let e=-1;const a="/"+t.root;n.subPackages.forEach((t,n)=>{if(n!==o&&t.root){const o="/"+t.root;a.startsWith(o)&&(e=n)}}),-1===e||i.push(locales_1.default.config.JSON_SHOULD_NOT_CONTAIN.format(`${c}[${e}]["root"]`,`${c}[${o}]["root"]`))}i.length>0&&(0,common_2.throwError)({msg:i.join("\n"),filePath:a})}}function checkPlugins(o){const{filePath:t,inputJSON:e,project:a}=o,n=[],c=e.plugins||{},i=(0,projectconfig_1.getProjectConfigJSON)(a),r=(null==i?void 0:i.pluginAppid)||a.appid;function s(o,t){const e=a.type===config_1.COMPILE_TYPE.miniProgramPlugin;if(e||"dev"!==o.version)if(e)"dev"===o.version&&o.provider!==r?n.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t+'["provider"]',`"${r}"`)):o.provider===r&&"dev"!==o.version&&n.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t+'["version"]','"dev"'));else{if("dev"===o.version||"latest"===o.version||/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/.test(o.version)||/^dev-[A-Za-z0-9]+$/.test(o.version))return!0;n.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([t+'["version"]',locales_1.default.config.TRIPLE_NUMBER_DOT]))}else n.push(`${locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(t+'["version"]',"dev")}\n${locales_1.default.config.PLEASE_CHOOSE_PLUGIN_MODE}`)}for(const o in c){s(c[o],`["plugins"]["${o}"]`)}e.subPackages&&e.subPackages.forEach((o,t)=>{if(!o.plugins)return;const e=`["subPackages"][${t}]`;for(const t in o.plugins){s(o.plugins[t],`${e}["plugins"]["${t}"]`)}}),n.length>0&&(0,common_2.throwError)({msg:n.join("\n"),filePath:t})}function checkNavigateToMiniProgramAppIdList(o){const{filePath:t,inputJSON:e,project:a}=o,n=[];if(e.navigateToMiniProgramAppIdList){const o=a.attrSync(),{appType:t=config_1.APP_TYPE.NORMAL,setting:c}=o;if(t!==config_1.APP_TYPE.NATIVE){const o=null==c?void 0:c.NavigateMiniprogramLimit;e.navigateToMiniProgramAppIdList.length>o&&n.push(locales_1.default.config.EXCEED_LIMIT.format('["navigateToMiniProgramAppIdList"]',o))}}n.length>0&&(0,common_2.throwError)({msg:n.join("\n"),filePath:t})}function checkFunctionalPages(o){const{inputJSON:t}=o;if(t.functionalPages&&"object"!==(0,tools_1.getType)(t.functionalPages)){const o='["functionalPages"] 配置需要更新,详见文档: https://developers.weixin.qq.com/miniprogram/dev/framework/plugin/functional-pages.html';t.__warning__?t.__warning__=`${t.__warning__}\n${o}`:t.__warning__=o}}function checkPreloadRule(o,t){const{inputJSON:e,filePath:a}=o,{preloadRule:n,subPackages:c}=e;if(!n||!c)return;const i=[],r={},s={},l={};t.forEach(o=>{r[o.root]=!0,l[o.path]=!0,o.name&&(s[o.name]=!0)});for(const o in n){if(!l[o]&&!o.includes("__plugin__/")){i.push(locales_1.default.config.NOT_FOUND.format(`["preloadRule"]["${o}"]: ${locales_1.default.config.PAGE_PATH}`));continue}const t=n[o];for(let e=0,a=t.packages.length;e<a;e++){let a=t.packages[e];a!==config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT&&(s[a]||(a=(0,tools_1.normalizePath)(a+"/"),r[a]||i.push(locales_1.default.config.NOT_FOUND.format(`["preloadRule"]["${o}"]["packages"][${e}]: ${a}`))))}}i.length>0&&(0,common_2.throwError)({msg:i.join("\n"),filePath:a})}function checkEntryPagePath(o,t){const{inputJSON:e,filePath:a}=o,{entryPagePath:n}=e;if(!n)return;(0,common_2.checkPath)({value:n,tips:'["entryPagePath"]',filePath:a});let c=!1;for(const o of t)if(o.path===n){c=!0;break}c||(0,common_2.throwError)({msg:locales_1.default.config.JSON_ENTRY_PAGE_PATH_NOT_FOUND.format(["pages、subPackages","entryPagePath"]),filePath:a})}function checkTabbarPage(o){const{filePath:t,inputJSON:e}=o,{tabBar:a,pages:n=[]}=e;if(!a)return;const c=[];for(let o=0;o<a.list.length;o++){const t=a.list[o],{pagePath:e}=t;n.indexOf(e)<0&&c.push(`["tabBar"][${o}]["pagePath"]: "${e}" need in ["pages"]`)}c.length>0&&(0,common_2.throwError)({msg:c.join("\n"),filePath:t})}function checkMainPkgPageIsInSubpkg(o){const{filePath:t,inputJSON:e}=o,{subPackages:a,pages:n=[]}=e;if(!a)return;const c=[];for(let o=0;o<a.length;o++){const t=a[o];for(let e=0;e<n.length;e++){const a=n[e];a.startsWith(t.root)&&c.push(locales_1.default.config.SHOULD_NOT_IN.format([`["pages"][${e}]: "${a}"`,`["subPackages"][${o}]`]))}}c.length>0&&(0,common_2.throwError)({msg:c.join("\n"),filePath:t})}function checkMainPkgPluginIsInSubPkg(o){const{filePath:t,inputJSON:e}=o,{plugins:a={},subPackages:n}=e,c={},i={},r=[];for(const o in a){const t=a[o],e=`["plugins"]["${o}"]`;c[t.provider]?r.push(locales_1.default.config.SAME_ITEM.format(`["plugins"]["${o}"]`,c[t.provider].tips,"provider")):c[t.provider]=i[o]={provider:t.provider,version:t.version,alias:o,tips:e}}if(n)for(let o=0;o<n.length;o++){const t=n[o];if(t.plugins)for(const e in t.plugins){const a=`["subPackages"][${o}]["plugins"]`,n=t.plugins[e];c[n.provider]?r.push(locales_1.default.config.SAME_ITEM.format(`${a}["${e}"]`,c[n.provider].tips,"provider")):i[e]?r.push(locales_1.default.config.PLUGINS_SAME_ALIAS.format(`${a}["${e}"]`,i[e].tips)):c[n.provider]=i[e]={provider:n.provider,version:n.version,alias:n,tips:a}}}r.length>0&&(0,common_2.throwError)({msg:r.join("\n"),filePath:t})}function checkComponentPath(o){const{project:t,miniprogramRoot:e,filePath:a,inputJSON:n}=o;(0,common_1.checkComponentPath)({project:t,root:e,relativePath:path_1.default.posix.relative(e,a),inputJSON:n})}function checkEntranceDeclare(o){const t=o.inputJSON;if(!t.entranceDeclare||!t.entranceDeclare.locationMessage)return;let e=t.pages||[];t.subpackages&&(e=e.concat(t.subpackages.map(o=>o.pages.map(t=>o.root+t))),e=lodash_1.default.flattenDeep(e)),t.subPackages&&(e=e.concat(t.subPackages.map(o=>o.pages.map(t=>o.root+t))),e=lodash_1.default.flattenDeep(e));const a=[],n=t.entranceDeclare.locationMessage.path;void 0===n?a.push(locales_1.default.config.JSON_ENTRANCE_DECLARE_PATH_EMPTY.format([])):e.includes(n)||a.push(locales_1.default.config.JSON_ENTRANCE_DECLARE_PATH_ERR.format([n||"undefined"])),a.length>0&&(0,common_2.throwError)({msg:a.join("\n"),filePath:o.filePath})}function getAppJSONVariableDecalearProperty(o){const{windowPropertWhiteList:t,tabBarPropertyWhiteList:e,tabbarListItemPropertyWhiteList:a}=config_1.jsonVariablePropertyWhiteList;let n=[];return"[object Object]"===Object.prototype.toString.call(o.window)&&(n=n.concat(Object.keys(o.window).filter(o=>t.includes(o)).map(t=>({property:`["window"]["${t}"]`,value:o.window[t]})).filter(o=>"string"==typeof o.value&&o.value.startsWith("@")))),"[object Object]"===Object.prototype.toString.call(o.tabBar)&&(n=n.concat(Object.keys(o.tabBar).filter(o=>e.includes(o)).map(t=>({property:`["tabBar"]["${t}"]`,value:o.tabBar[t]})).filter(o=>"string"==typeof o.value&&o.value.startsWith("@"))),Array.isArray(o.tabBar.list)&&o.tabBar.list.forEach((t,e)=>{n=n.concat(Object.keys(t).filter(o=>a.includes(o)).map(t=>({property:`["tabBar"]["list"][${e}]["${t}"]`,value:o.tabBar.list[e][t]})).filter(o=>"string"==typeof o.value&&o.value.startsWith("@")))})),n}function checkOpenDataContext(o,t){const{project:e,miniprogramRoot:a,filePath:n}=o,{openDataContext:c}=t;if(void 0===c)return;(0,common_2.checkPath)({value:c,tips:'["openDataContext"]',filePath:n});const i=e.stat(a,c);i&&i.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(['["openDataContext"]',locales_1.default.config.DIRECTORY]),filePath:n});const r=path_1.default.posix.join(c,"./index.js"),s=e.stat(a,r);s&&s.isFile||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["openDataContext"]',r),filePath:n}),t.openDataContext=(0,tools_1.normalizePath)(c+"/")}function checkRenderer(o){var t,e,a,n;const{filePath:c,inputJSON:i}=o,{renderer:r,lazyCodeLoading:s,rendererOptions:l}=i;if("skyline"===r&&"requiredComponents"!==s&&(0,common_2.throwError)({msg:locales_1.default.config.APP_JSON_SHOULD_SET_LAZYCODELOADING.format("app.json"),filePath:c}),"skyline"===r&&(void 0===l?(0,common_2.throwError)({msg:locales_1.default.config.JSON_SHOULD_SET_RENDEREROPTIONS.format("app.json"),filePath:c}):void 0===l.skyline&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_SHOULD_SET_RENDEREROPTIONS_SKYLINE.format("app.json"),filePath:c})),"skyline"===r||(null==l?void 0:l.skyline)){const o=(null===(t=i.window)||void 0===t?void 0:t.navigationBarTextStyle)||(null===(e=i.window)||void 0===e?void 0:e.navigationBarTitleText)||(null===(a=i.window)||void 0===a?void 0:a.navigationBarBackgroundColor),c="custom"===(null===(n=i.window)||void 0===n?void 0:n.navigationStyle);if(o&&!c){const o=locales_1.default.config.APP_JSON_SKYLINE_WINDOW_TIPS.format("");i.__warning__?i.__warning__=`${i.__warning__}\n${o}`:i.__warning__=o}}}function checkResolveAlias(o){const{filePath:t,inputJSON:e}=o,{resolveAlias:a}=e;if(a){const o=o=>o.includes("//");for(const e in a)(o(e)||o(a[e]))&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_RESOLVE_ALIAS_ILLEGAL.format(e,a[e]),filePath:t}),a[e].startsWith("./")&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_RESOLVE_ALIAS_SHOULD_NOT_START_WITH.format(a[e]),filePath:t}),e.endsWith("/*")&&a[e].endsWith("/*")||(0,common_2.throwError)({msg:locales_1.default.config.JSON_RESOLVE_ALIAS_INCLUDE_STAR.format(e,a[e]),filePath:t})}}exports.checkMainPkgPages=checkMainPkgPages;const detailLocationApis={getLocation:!0,onLocationChange:!0,startLocationUpdate:!0,startLocationUpdateBackground:!0};function checkRequiredPrivateInfos(o){const{filePath:t,inputJSON:e}=o,{requiredPrivateInfos:a}=e;if(a){if(a.indexOf("getFuzzyLocation")>=0){const o=[];for(let t=0;t<a.length;t++){const e=a[t];detailLocationApis[e]&&o.push(`'${e}'`)}o.length>0&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_REQUIRED_PRIVATE_INFOS_MUTUALLY_EXCLUSIVE.format("'getFuzzyLocation'",o.join("、")),filePath:t})}}}function checkAccountCardPackage(o){const{project:t,filePath:e,inputJSON:a,miniprogramRoot:n}=o,{accountCardPackage:c}=a;if(c){c.root=(0,tools_1.normalizePath)(c.root+"/");const o=a.subPackages||a.subpackages||[];console.log("subPackages",o),o.find(o=>o.root===c.root&&o.independent)||(0,common_2.throwError)({msg:locales_1.default.config.ACCOUNT_CARD_PACKAPGE_IN_VALID.format(),filePath:e});for(const o of c.cardList){const{componentPath:a}=o,i=path_1.default.posix.join(c.root,a+".js");t.stat(n,path_1.default.posix.join(c.root,a+".js"))||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["accountCardPackage"]',i),code:config_1.FILE_NOT_FOUND,filePath:e})}}}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPageJSONVariableDecalearProperty=exports.checkComponentPath=exports.getUseExtendLib=exports.checkFilePathIsInIndependentSubpackage=exports.checkPagePathIsInIndependentSubpackage=exports.checkPagePathIsInSubPackage=exports.checkJSONFormat=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=require("lodash"),tools_1=require("../../../../utils/tools"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),common_1=require("../../../../utils/common"),config_1=require("../../../../config/config"),appJSON_1=require("./app/appJSON");function checkJSONFormat(e,t){let o={};e||(0,common_1.throwError)({filePath:t,msg:"Empty file is NOT a valid json file",code:config_1.JSON_PARSE_ERR});try{o=JSON.parse(e)}catch(o){const n=(0,tools_1.formatJSONParseErr)({filePath:t,data:e,error:o});(0,common_1.throwError)({filePath:t,msg:n,code:config_1.JSON_PARSE_ERR})}return o}function checkPagePathIsInSubPackage(e,t){const{subPackages:o,subpackages:n}=e;if(o||n)for(const e of o||n)if(t.startsWith(e.root))return e}function checkPagePathIsInIndependentSubpackage(e,t){const o=checkPagePathIsInSubPackage(e,t);if(o&&!0===o.independent)return o}function checkFilePathIsInIndependentSubpackage(e,t){const{subPackages:o}=e;if(o)for(const e of o)if(!0===e.independent){const o=e.root.replace(/^\//,"");if(t.startsWith(o))return o}}function checkNodeModulesFile2(e,t,o){var n,a;for(const i of o){const o=i+".json",r=i+".wxml";if((null===(n=e.stat(t,o))||void 0===n?void 0:n.isFile)&&(null===(a=e.stat(t,r))||void 0===a?void 0:a.isFile))return i}return""}function resolveComponentPath2(e,t,o,n){n=(0,tools_1.normalizePath)(n);const a=[path_1.default.posix.join(o,n),path_1.default.posix.join(o,n,"index")];let i=o.split(path_1.default.posix.sep);for(i=i.filter(e=>!!e);i.length;){const e=[path_1.default.posix.join(i.join(path_1.default.posix.sep),"miniprogram_npm",n),path_1.default.posix.join(i.join(path_1.default.posix.sep),"miniprogram_npm",n,"index")];a.push(...e),i.pop()}const r=[path_1.default.posix.join("miniprogram_npm",n),path_1.default.posix.join("miniprogram_npm",n,"index")];a.push(...r);const s=checkNodeModulesFile2(e,t,a);return s?{searchedPaths:a,requirePath:path_1.default.posix.relative(o,s)}:{searchedPaths:a,requirePath:""}}exports.checkJSONFormat=checkJSONFormat,exports.checkPagePathIsInSubPackage=checkPagePathIsInSubPackage,exports.checkPagePathIsInIndependentSubpackage=checkPagePathIsInIndependentSubpackage,exports.checkFilePathIsInIndependentSubpackage=checkFilePathIsInIndependentSubpackage;const innerCheckComponentPath=e=>{const{value:t,tips:o,project:n,root:a,relativePath:i}=e,r=`${o}: "${t}"`,s=path_1.default.posix.join(a,i);if(t.startsWith("plugin://")||t.startsWith("plugin-private://"))return t;const c=e=>n.stat(a,e+".json")&&n.stat(a,e+".wxml"),p=(0,exports.getUseExtendLib)(n,i);if(t.startsWith("/")){if(p.length){const e=p.map(e=>"/miniprogram_npm/"+e);let o=!1;for(const n of e)if(t.startsWith(n)){o=!0;break}if(o)return t}if(c(t))return t;if(c(t+"/index"))return t+"/index";(0,common_1.throwError)({msg:locales_1.default.config.COMPONENT_NOT_FOUND.format(r,path_1.default.posix.join(n.projectPath,a,t)),filePath:s})}if(t.startsWith(".")){if(t.startsWith("../")){const e=t.replace(/^(\.\.\/)+/,"");if(c("/"+e))return t;if(c(`/${e}/index`))return t+"/index"}if(c(path_1.default.posix.join(path_1.default.posix.dirname(i),""+t)))return t;if(c(path_1.default.posix.join(path_1.default.posix.dirname(i),t+"/index")))return t+"/index";(0,common_1.throwError)({msg:locales_1.default.config.COMPONENT_NOT_FOUND.format(r,path_1.default.posix.join(n.projectPath,a,path_1.default.posix.dirname(i),t)),filePath:s})}for(const e of p)if(t.startsWith(e))return"miniprogram-element"===e?`/miniprogram_npm/${e}/index`:t.replace(e,"/miniprogram_npm/"+e);const l=resolveComponentPath2(n,a,path_1.default.posix.dirname(i),t);l.requirePath||(0,common_1.throwError)({msg:locales_1.default.config.COMPONENT_NOT_FOUND.format(r,l.searchedPaths.map(e=>path_1.default.posix.join(n.projectPath,a,e)).join("\n")),filePath:s});const h=l.requirePath||"";return h.startsWith(".")?h:"./"+h},getUseExtendLib=(e,t)=>{var o;const n=(0,appJSON_1.getRawAppJSON)(e);let a=[];if("[object Object]"===Object.prototype.toString.call(n.useExtendedLib)){const e=Object.keys(config_1.extendedLibMap),t=Object.keys(n.useExtendedLib).filter(t=>!e.includes(t));t.length&&(0,common_1.throwError)({msg:t.join(", ")+' is not allowed in ["useExtendedLib"]',filePath:"app.json"}),a=Object.keys(n.useExtendedLib||{}).filter(e=>n.useExtendedLib[e]).map(e=>config_1.extendedLibMap[e].packages),a=(0,lodash_1.flattenDeep)(a)}const i=checkPagePathIsInSubPackage(n,t);if((null==i?void 0:i.useExtendedLib)&&"[object Object]"===Object.prototype.toString.call(i.useExtendedLib)){const e=Object.keys(config_1.extendedLibMap),t=Object.keys(i.useExtendedLib).filter(t=>!e.includes(t));t.length&&(0,common_1.throwError)({msg:`${t.join(", ")} is not allowed in subPackages[${null===(o=n.subPackages)||void 0===o?void 0:o.indexOf(i)}]["useExtendedLib"]`,filePath:"app.json"});const r=Object.keys(i.useExtendedLib||{}).filter(e=>i.useExtendedLib[e]).map(e=>config_1.extendedLibMap[e].packages);a=(0,lodash_1.uniq)(a.concat((0,lodash_1.flattenDeep)(r)))}return a};exports.getUseExtendLib=getUseExtendLib;const checkComponentPath=e=>{const{project:t,root:o,relativePath:n,inputJSON:a}=e,{usingComponents:i,componentGenerics:r}=a;if(i)for(const e in i){const a=i[e]||"";i[e]=innerCheckComponentPath({tips:`["usingComponents"]["${e}"]`,value:a,project:t,root:o,relativePath:n})}if(r)for(const e in r){const a="object"==typeof r[e],i=a?r[e].default:r[e];if(!i||"string"!=typeof i)continue;const s=innerCheckComponentPath({tips:`["componentGenerics"]["${e}"]`,value:i,project:t,root:o,relativePath:n});a?r[e].default=s:r[e]=s}};function getPageJSONVariableDecalearProperty(e){const{windowPropertWhiteList:t}=config_1.jsonVariablePropertyWhiteList;let o=[];return"[object Object]"===Object.prototype.toString.call(e)&&(o=o.concat(Object.keys(e).filter(e=>t.includes(e)).map(t=>({property:`["${t}"]`,value:e[t]})).filter(e=>e.value.startsWith("@")))),o}exports.checkComponentPath=checkComponentPath,exports.getPageJSONVariableDecalearProperty=getPageJSONVariableDecalearProperty;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkComponentPath=exports.getUseExtendLib=void 0,exports.checkJSONFormat=checkJSONFormat,exports.checkPagePathIsInSubPackage=checkPagePathIsInSubPackage,exports.checkPagePathIsInIndependentSubpackage=checkPagePathIsInIndependentSubpackage,exports.checkFilePathIsInIndependentSubpackage=checkFilePathIsInIndependentSubpackage,exports.getPageJSONVariableDecalearProperty=getPageJSONVariableDecalearProperty;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=require("lodash"),tools_1=require("../../../../utils/tools"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),common_1=require("../../../../utils/common"),config_1=require("../../../../config/config"),appJSON_1=require("./app/appJSON");function checkJSONFormat(e,t){let o={};e||(0,common_1.throwError)({filePath:t,msg:"Empty file is NOT a valid json file",code:config_1.JSON_PARSE_ERR});try{o=JSON.parse(e)}catch(o){const n=(0,tools_1.formatJSONParseErr)({filePath:t,data:e,error:o});(0,common_1.throwError)({filePath:t,msg:n,code:config_1.JSON_PARSE_ERR})}return o}function checkPagePathIsInSubPackage(e,t){const{subPackages:o,subpackages:n}=e;if(o||n)for(const e of o||n)if(t.startsWith(e.root))return e}function checkPagePathIsInIndependentSubpackage(e,t){const o=checkPagePathIsInSubPackage(e,t);if(o&&!0===o.independent)return o}function checkFilePathIsInIndependentSubpackage(e,t){const{subPackages:o}=e;if(o)for(const e of o)if(!0===e.independent){const o=e.root.replace(/^\//,"");if(t.startsWith(o))return o}}function checkNodeModulesFile2(e,t,o){var n,a;for(const i of o){const o=i+".json",r=i+".wxml";if((null===(n=e.stat(t,o))||void 0===n?void 0:n.isFile)&&(null===(a=e.stat(t,r))||void 0===a?void 0:a.isFile))return i}return""}function resolveComponentPath2(e,t,o,n){n=(0,tools_1.normalizePath)(n);const a=[path_1.default.posix.join(o,n),path_1.default.posix.join(o,n,"index")];let i=o.split(path_1.default.posix.sep);for(i=i.filter(e=>!!e);i.length;){const e=[path_1.default.posix.join(i.join(path_1.default.posix.sep),"miniprogram_npm",n),path_1.default.posix.join(i.join(path_1.default.posix.sep),"miniprogram_npm",n,"index")];a.push(...e),i.pop()}const r=[path_1.default.posix.join("miniprogram_npm",n),path_1.default.posix.join("miniprogram_npm",n,"index")];a.push(...r);const s=checkNodeModulesFile2(e,t,a);return s?{searchedPaths:a,requirePath:path_1.default.posix.relative(o,s)}:{searchedPaths:a,requirePath:""}}const innerCheckComponentPath=e=>{const{value:t,tips:o,project:n,root:a,relativePath:i}=e,r=`${o}: "${t}"`,s=path_1.default.posix.join(a,i);if(t.startsWith("plugin://")||t.startsWith("plugin-private://"))return t;const c=e=>n.stat(a,e+".json")&&n.stat(a,e+".wxml"),p=(0,exports.getUseExtendLib)(n,i);if(t.startsWith("/")){if(p.length){const e=p.map(e=>"/miniprogram_npm/"+e);let o=!1;for(const n of e)if(t.startsWith(n)){o=!0;break}if(o)return t}if(c(t))return t;if(c(t+"/index"))return t+"/index";(0,common_1.throwError)({msg:locales_1.default.config.COMPONENT_NOT_FOUND.format(r,path_1.default.posix.join(n.projectPath,a,t)),filePath:s})}if(t.startsWith(".")){if(t.startsWith("../")){const e=t.replace(/^(\.\.\/)+/,"");if(c("/"+e))return t;if(c(`/${e}/index`))return t+"/index"}if(c(path_1.default.posix.join(path_1.default.posix.dirname(i),""+t)))return t;if(c(path_1.default.posix.join(path_1.default.posix.dirname(i),t+"/index")))return t+"/index";(0,common_1.throwError)({msg:locales_1.default.config.COMPONENT_NOT_FOUND.format(r,path_1.default.posix.join(n.projectPath,a,path_1.default.posix.dirname(i),t)),filePath:s})}for(const e of p)if(t.startsWith(e))return"miniprogram-element"===e?`/miniprogram_npm/${e}/index`:t.replace(e,"/miniprogram_npm/"+e);const l=resolveComponentPath2(n,a,path_1.default.posix.dirname(i),t);l.requirePath||(0,common_1.throwError)({msg:locales_1.default.config.COMPONENT_NOT_FOUND.format(r,l.searchedPaths.map(e=>path_1.default.posix.join(n.projectPath,a,e)).join("\n")),filePath:s});const d=l.requirePath||"";return d.startsWith(".")?d:"./"+d},getUseExtendLib=(e,t)=>{var o;const n=(0,appJSON_1.getRawAppJSON)(e);let a=[];if("[object Object]"===Object.prototype.toString.call(n.useExtendedLib)){const e=Object.keys(config_1.extendedLibMap),t=Object.keys(n.useExtendedLib).filter(t=>!e.includes(t));t.length&&(0,common_1.throwError)({msg:t.join(", ")+' is not allowed in ["useExtendedLib"]',filePath:"app.json"}),a=Object.keys(n.useExtendedLib||{}).filter(e=>n.useExtendedLib[e]).map(e=>config_1.extendedLibMap[e].packages),a=(0,lodash_1.flattenDeep)(a)}const i=checkPagePathIsInSubPackage(n,t);if((null==i?void 0:i.useExtendedLib)&&"[object Object]"===Object.prototype.toString.call(i.useExtendedLib)){const e=Object.keys(config_1.extendedLibMap),t=Object.keys(i.useExtendedLib).filter(t=>!e.includes(t));t.length&&(0,common_1.throwError)({msg:`${t.join(", ")} is not allowed in subPackages[${null===(o=n.subPackages)||void 0===o?void 0:o.indexOf(i)}]["useExtendedLib"]`,filePath:"app.json"});const r=Object.keys(i.useExtendedLib||{}).filter(e=>i.useExtendedLib[e]).map(e=>config_1.extendedLibMap[e].packages);a=(0,lodash_1.uniq)(a.concat((0,lodash_1.flattenDeep)(r)))}return a};exports.getUseExtendLib=getUseExtendLib;const checkComponentPath=e=>{const{project:t,root:o,relativePath:n,inputJSON:a}=e,{usingComponents:i,componentGenerics:r}=a;if(i)for(const e in i){const a=i[e]||"";i[e]=innerCheckComponentPath({tips:`["usingComponents"]["${e}"]`,value:a,project:t,root:o,relativePath:n})}if(r)for(const e in r){const a="object"==typeof r[e],i=a?r[e].default:r[e];if(!i||"string"!=typeof i)continue;const s=innerCheckComponentPath({tips:`["componentGenerics"]["${e}"]`,value:i,project:t,root:o,relativePath:n});a?r[e].default=s:r[e]=s}};function getPageJSONVariableDecalearProperty(e){const{windowPropertWhiteList:t}=config_1.jsonVariablePropertyWhiteList;let o=[];return"[object Object]"===Object.prototype.toString.call(e)&&(o=o.concat(Object.keys(e).filter(e=>t.includes(e)).map(t=>({property:`["${t}"]`,value:e[t]})).filter(e=>e.value.startsWith("@")))),o}exports.checkComponentPath=checkComponentPath;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkPageJSON=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),locales_1=tslib_1.__importDefault(require("../../../../../utils/locales/locales")),common_1=require("../common"),schemaValidate_1=require("../../validate/schemaValidate"),tools_1=require("../../../../../utils/tools"),common_2=require("../../../../../utils/common"),theme_1=require("../theme"),checkHexColor=e=>{const{inputJSON:a,mode:o,pagePath:t,themeLocation:r}=e;let i=t+".json";if(a){r&&(i=`${t}.json or ${r}["${o}"]`);const{navigationBarBackgroundColor:e,backgroundColor:l}=a;void 0===e||(0,tools_1.isHexColor)(e)||(0,common_2.throwError)({msg:`["navigationBarBackgroundColor"]: "${e}" is not hexColor`,filePath:i}),void 0===l||(0,tools_1.isHexColor)(l)||(0,common_2.throwError)({msg:`["backgroundColor"]: "${l}" is not hexColor`,filePath:i})}};function checkPageJSON(e,a){const{pagePath:o,miniprogramRoot:t=""}=a,r=(0,tools_1.normalizePath)(path_1.default.posix.join(t,o+".json"));if(!e.stat("",r))return{};const i=e.getFile("",r),l=(0,common_1.checkJSONFormat)((0,common_2.checkUTF8)(i,r),r),n=(0,theme_1.getThemeLocation)(e);if(!n){const e=(0,common_1.getPageJSONVariableDecalearProperty)(l);e.length&&(0,common_2.throwError)({msg:'["themeLocation"] is required because:\n'+e.map(e=>`"${e.value}" as variable was declared at ${r}:${e.property}`).join("\n"),filePath:r})}let c={light:{},dark:{}};n&&(c=(0,theme_1.checkThemeJSON)(e,{themeLocation:n}));const m=(0,theme_1.mergeThemeJSONToPageJSON)(c,l,r),s=(0,schemaValidate_1.schemaValidate)("page",m.pageJSONLight),h=(0,schemaValidate_1.schemaValidate)("page",m.pageJSONDark),g=(0,common_1.getPageJSONVariableDecalearProperty)(m.pageJSONLight);g.length&&(0,common_2.throwError)({msg:g.map(e=>`"${e.value}" as variable was declared at ${r}:${e.property}, but not found at ${n}["light"]`).join("\n"),filePath:r});const _=(0,common_1.getPageJSONVariableDecalearProperty)(m.pageJSONDark);return _.length&&(0,common_2.throwError)({msg:_.map(e=>`"${e.value}" as variable was declared at ${r}:${e.property}, but not found at ${n}["dark"]`).join("\n"),filePath:r}),s.warning&&(l.__warning__=locales_1.default.config.INVALID.format(s.warning)),n&&h.warning&&(l.__warning__=locales_1.default.config.INVALID.format(h.warning)),(0,schemaValidate_1.transValidateResult)(n?`${r} or ${n}["light"]`:r,s),n&&(0,schemaValidate_1.transValidateResult)(`${r} or ${n}["dark"]`,h),checkHexColor({inputJSON:m.pageJSONLight,mode:"light",themeLocation:n||"",filePath:r,pagePath:o}),checkHexColor({inputJSON:m.pageJSONDark,mode:"dark",themeLocation:n||"",filePath:r,pagePath:o}),l}exports.checkPageJSON=checkPageJSON;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkPageJSON=checkPageJSON;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),locales_1=tslib_1.__importDefault(require("../../../../../utils/locales/locales")),common_1=require("../common"),schemaValidate_1=require("../../validate/schemaValidate"),tools_1=require("../../../../../utils/tools"),common_2=require("../../../../../utils/common"),theme_1=require("../theme"),checkHexColor=e=>{const{inputJSON:a,mode:o,pagePath:t,themeLocation:r}=e;let i=t+".json";if(a){r&&(i=`${t}.json or ${r}["${o}"]`);const{navigationBarBackgroundColor:e,backgroundColor:l}=a;void 0===e||(0,tools_1.isHexColor)(e)||(0,common_2.throwError)({msg:`["navigationBarBackgroundColor"]: "${e}" is not hexColor`,filePath:i}),void 0===l||(0,tools_1.isHexColor)(l)||(0,common_2.throwError)({msg:`["backgroundColor"]: "${l}" is not hexColor`,filePath:i})}};function checkPageJSON(e,a){const{pagePath:o,miniprogramRoot:t=""}=a,r=(0,tools_1.normalizePath)(path_1.default.posix.join(t,o+".json"));if(!e.stat("",r))return{};const i=e.getFile("",r),l=(0,common_1.checkJSONFormat)((0,common_2.checkUTF8)(i,r),r),n=(0,theme_1.getThemeLocation)(e);if(!n){const e=(0,common_1.getPageJSONVariableDecalearProperty)(l);e.length&&(0,common_2.throwError)({msg:'["themeLocation"] is required because:\n'+e.map(e=>`"${e.value}" as variable was declared at ${r}:${e.property}`).join("\n"),filePath:r})}let c={light:{},dark:{}};n&&(c=(0,theme_1.checkThemeJSON)(e,{themeLocation:n}));const m=(0,theme_1.mergeThemeJSONToPageJSON)(c,l,r),s=(0,schemaValidate_1.schemaValidate)("page",m.pageJSONLight),h=(0,schemaValidate_1.schemaValidate)("page",m.pageJSONDark),g=(0,common_1.getPageJSONVariableDecalearProperty)(m.pageJSONLight);g.length&&(0,common_2.throwError)({msg:g.map(e=>`"${e.value}" as variable was declared at ${r}:${e.property}, but not found at ${n}["light"]`).join("\n"),filePath:r});const _=(0,common_1.getPageJSONVariableDecalearProperty)(m.pageJSONDark);return _.length&&(0,common_2.throwError)({msg:_.map(e=>`"${e.value}" as variable was declared at ${r}:${e.property}, but not found at ${n}["dark"]`).join("\n"),filePath:r}),s.warning&&(l.__warning__=locales_1.default.config.INVALID.format(s.warning)),n&&h.warning&&(l.__warning__=locales_1.default.config.INVALID.format(h.warning)),(0,schemaValidate_1.transValidateResult)(n?`${r} or ${n}["light"]`:r,s),n&&(0,schemaValidate_1.transValidateResult)(`${r} or ${n}["dark"]`,h),checkHexColor({inputJSON:m.pageJSONLight,mode:"light",themeLocation:n||"",filePath:r,pagePath:o}),checkHexColor({inputJSON:m.pageJSONDark,mode:"dark",themeLocation:n||"",filePath:r,pagePath:o}),l}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPageJSONWithDisableSpreading=exports.getPageJSON=exports.originGetPageJSON=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=require("lodash"),extJSON_1=require("../app/extJSON"),app_1=require("../app"),tools_1=require("../../../../../utils/tools"),common_1=require("../common"),common_2=require("../../../../../utils/common"),locales_1=tslib_1.__importDefault(require("../../../../../utils/locales/locales")),reactiveCache_1=require("../reactiveCache"),checkPageJSON_1=require("./checkPageJSON"),spreadUsingComponent=e=>{const{project:o,pagePath:t,inputJSON:n}=e;if(t.includes("miniprogram_npm"))return;const a=(0,app_1.getAppJSON)(o);if((0,common_1.checkPagePathIsInIndependentSubpackage)(a,t))return;if(a.componentPlaceholder){n.componentPlaceholder=n.componentPlaceholder||{};for(const e in a.componentPlaceholder)n.componentPlaceholder[e]=n.componentPlaceholder[e]||a.componentPlaceholder[e]}const i=Object.assign({},a.usingComponents);if(0!==Object.keys(i).length){n.usingComponents||(n.usingComponents={});for(const e in i){if(n.usingComponents[e])continue;const o=i[e]||"";if(o.startsWith("/")||o.startsWith("plugin://")){n.usingComponents[e]=o;continue}const a=(0,tools_1.normalizePath)(path_1.default.posix.relative(path_1.default.posix.dirname(t),o));n.usingComponents[e]=a.startsWith(".")?a:"./"+a}}},mergeExtJSON=e=>{var o;const{project:t,inputJSON:n,pagePath:a}=e,i=(0,extJSON_1.getExtJSON)(t);(null===(o=null==i?void 0:i.extPages)||void 0===o?void 0:o[a])&&Object.assign(n,i.extPages[a])},checkComponentPath=e=>{const{project:o,miniprogramRoot:t,pagePath:n,inputJSON:a}=e;(0,common_1.checkComponentPath)({project:o,root:t,relativePath:n+".json",inputJSON:a})},checkComponentGenerics=e=>{const{pagePath:o,inputJSON:t}=e,n=o+".json";if(!t.componentGenerics)return;const a=[];for(const e in t.componentGenerics){const o=t.componentGenerics[e],n=(0,tools_1.getType)(o);"boolean"===n||"object"===n?"object"===n&&"string"!==(0,tools_1.getType)(o.default)&&a.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`["componentGenerics"]["${e}"]["default"]`,"string"])):a.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`["componentGenerics"]["${e}"]`,"boolean/object"]))}a.length>0&&(0,common_2.throwError)({msg:a.join("\n"),filePath:n})};function checkRenderer(e){var o,t;const{filePath:n,inputJSON:a}=e,{renderer:i}=a,r=(0,app_1.getAppJSON)(e.project);if((0,common_2.getAllPages)(r).includes(e.pagePath)&&("skyline"===i&&"requiredComponents"!==r.lazyCodeLoading&&(0,common_2.throwError)({msg:locales_1.default.config.APP_JSON_SHOULD_SET_LAZYCODELOADING.format(n),filePath:n}),"skyline"===i||"skyline"===r.renderer&&void 0===i)){"default"===a.navigationStyle&&(0,common_2.throwError)({msg:locales_1.default.config.PAGE_JSON_SHOULD_SET_NAVIGATIONSTYLE_CUSTOM.format(n),filePath:n});!(a.navigationStyle?"custom"===a.navigationStyle:"custom"===(null===(o=r.window)||void 0===o?void 0:o.navigationStyle))&&(a.navigationBarTitleText||a.navigationBarTextStyle||a.navigationBarBackgroundColor)&&(0,common_2.throwError)({msg:locales_1.default.config.PAGE_JSON_SHOULD_SET_NAVIGATIONSTYLE_CUSTOM.format(n),filePath:n}),a.disableScroll=null===(t=a.disableScroll)||void 0===t||t,a.navigationStyle="custom"}}function checkComponentFramework(e){const{filePath:o,inputJSON:t}=e,{renderer:n,componentFramework:a}=t,i=(0,app_1.getAppJSON)(e.project);if(!(0,common_2.getAllPages)(i).includes(e.pagePath))return;const r="skyline"===n||"skyline"===i.renderer&&void 0===n,c="glass-easel"===a||"glass-easel"===i.componentFramework&&void 0===a;r&&(c||(0,common_2.throwError)({msg:locales_1.default.config.JSON_SHOULD_SET_COMPONENTFRAMEWORK_SKYLINE.format(o),filePath:o}))}const compilePageJSON=(e,o=!1)=>{mergeExtJSON(e),checkComponentGenerics(e),checkComponentPath(e),o||spreadUsingComponent(e),checkRenderer(e),checkComponentFramework(e)};function originGetPageJSON(e,o){const{pagePath:t,miniprogramRoot:n=""}=o,a=(0,tools_1.normalizePath)(path_1.default.posix.join(n,t+".json")),i=(0,reactiveCache_1.tryToGetReactiveJSONCompiler)(e),r=(0,lodash_1.cloneDeep)(i.getPageJSON("checked",o));return compilePageJSON({project:e,miniprogramRoot:n,inputJSON:r,filePath:a,pagePath:t}),r.usingComponents||(r.usingComponents={}),r}async function getPageJSON(e,o){const t=(0,reactiveCache_1.tryToGetReactiveProject)(e);return(0,reactiveCache_1.tryToGetReactiveJSONCompiler)(t).getPageJSON("compiled",o)}function getPageJSONWithDisableSpreading(e,o){const t=(0,reactiveCache_1.tryToGetReactiveProject)(e),n=(0,reactiveCache_1.tryToGetReactiveJSONCompiler)(t),{pagePath:a,miniprogramRoot:i=""}=o,r=(0,tools_1.normalizePath)(path_1.default.posix.join(i,a+".json")),c=(0,lodash_1.cloneDeep)(n.getPageJSON("checked",o));return compilePageJSON({project:t,miniprogramRoot:i,inputJSON:c,filePath:r,pagePath:a},!0),c.usingComponents||(c.usingComponents={}),c}exports.originGetPageJSON=originGetPageJSON,reactiveCache_1.ReactiveJSONCompiler.setOriginCheckPageJSON(checkPageJSON_1.checkPageJSON),reactiveCache_1.ReactiveJSONCompiler.setOriginGetPageJSON(originGetPageJSON),exports.getPageJSON=getPageJSON,exports.getPageJSONWithDisableSpreading=getPageJSONWithDisableSpreading;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.originGetPageJSON=originGetPageJSON,exports.getPageJSON=getPageJSON,exports.getPageJSONWithDisableSpreading=getPageJSONWithDisableSpreading;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=require("lodash"),extJSON_1=require("../app/extJSON"),app_1=require("../app"),tools_1=require("../../../../../utils/tools"),common_1=require("../common"),common_2=require("../../../../../utils/common"),locales_1=tslib_1.__importDefault(require("../../../../../utils/locales/locales")),reactiveCache_1=require("../reactiveCache"),checkPageJSON_1=require("./checkPageJSON"),spreadUsingComponent=e=>{const{project:o,pagePath:t,inputJSON:n}=e;if(t.includes("miniprogram_npm"))return;const a=(0,app_1.getAppJSON)(o);if((0,common_1.checkPagePathIsInIndependentSubpackage)(a,t))return;if(a.componentPlaceholder){n.componentPlaceholder=n.componentPlaceholder||{};for(const e in a.componentPlaceholder)n.componentPlaceholder[e]=n.componentPlaceholder[e]||a.componentPlaceholder[e]}const i=Object.assign({},a.usingComponents);if(0!==Object.keys(i).length){n.usingComponents||(n.usingComponents={});for(const e in i){if(n.usingComponents[e])continue;const o=i[e]||"";if(o.startsWith("/")||o.startsWith("plugin://")){n.usingComponents[e]=o;continue}const a=(0,tools_1.normalizePath)(path_1.default.posix.relative(path_1.default.posix.dirname(t),o));n.usingComponents[e]=a.startsWith(".")?a:"./"+a}}},mergeExtJSON=e=>{var o;const{project:t,inputJSON:n,pagePath:a}=e,i=(0,extJSON_1.getExtJSON)(t);(null===(o=null==i?void 0:i.extPages)||void 0===o?void 0:o[a])&&Object.assign(n,i.extPages[a])},checkComponentPath=e=>{const{project:o,miniprogramRoot:t,pagePath:n,inputJSON:a}=e;(0,common_1.checkComponentPath)({project:o,root:t,relativePath:n+".json",inputJSON:a})},checkComponentGenerics=e=>{const{pagePath:o,inputJSON:t}=e,n=o+".json";if(!t.componentGenerics)return;const a=[];for(const e in t.componentGenerics){const o=t.componentGenerics[e],n=(0,tools_1.getType)(o);"boolean"===n||"object"===n?"object"===n&&"string"!==(0,tools_1.getType)(o.default)&&a.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`["componentGenerics"]["${e}"]["default"]`,"string"])):a.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`["componentGenerics"]["${e}"]`,"boolean/object"]))}a.length>0&&(0,common_2.throwError)({msg:a.join("\n"),filePath:n})};function checkRenderer(e){var o,t;const{filePath:n,inputJSON:a}=e,{renderer:i}=a,r=(0,app_1.getAppJSON)(e.project);if((0,common_2.getAllPages)(r).includes(e.pagePath)&&("skyline"===i&&"requiredComponents"!==r.lazyCodeLoading&&(0,common_2.throwError)({msg:locales_1.default.config.APP_JSON_SHOULD_SET_LAZYCODELOADING.format(n),filePath:n}),"skyline"===i||"skyline"===r.renderer&&void 0===i)){"default"===a.navigationStyle&&(0,common_2.throwError)({msg:locales_1.default.config.PAGE_JSON_SHOULD_SET_NAVIGATIONSTYLE_CUSTOM.format(n),filePath:n});!(a.navigationStyle?"custom"===a.navigationStyle:"custom"===(null===(o=r.window)||void 0===o?void 0:o.navigationStyle))&&(a.navigationBarTitleText||a.navigationBarTextStyle||a.navigationBarBackgroundColor)&&(0,common_2.throwError)({msg:locales_1.default.config.PAGE_JSON_SHOULD_SET_NAVIGATIONSTYLE_CUSTOM.format(n),filePath:n}),a.disableScroll=null===(t=a.disableScroll)||void 0===t||t,a.navigationStyle="custom"}}function checkComponentFramework(e){const{filePath:o,inputJSON:t}=e,{renderer:n,componentFramework:a}=t,i=(0,app_1.getAppJSON)(e.project);if(!(0,common_2.getAllPages)(i).includes(e.pagePath))return;const r="skyline"===n||"skyline"===i.renderer&&void 0===n,c="glass-easel"===a||"glass-easel"===i.componentFramework&&void 0===a;r&&(c||(0,common_2.throwError)({msg:locales_1.default.config.JSON_SHOULD_SET_COMPONENTFRAMEWORK_SKYLINE.format(o),filePath:o}))}const compilePageJSON=(e,o=!1)=>{mergeExtJSON(e),checkComponentGenerics(e),checkComponentPath(e),o||spreadUsingComponent(e),checkRenderer(e),checkComponentFramework(e)};function originGetPageJSON(e,o){const{pagePath:t,miniprogramRoot:n=""}=o,a=(0,tools_1.normalizePath)(path_1.default.posix.join(n,t+".json")),i=(0,reactiveCache_1.tryToGetReactiveJSONCompiler)(e),r=(0,lodash_1.cloneDeep)(i.getPageJSON("checked",o));return compilePageJSON({project:e,miniprogramRoot:n,inputJSON:r,filePath:a,pagePath:t}),r.usingComponents||(r.usingComponents={}),r}async function getPageJSON(e,o){const t=(0,reactiveCache_1.tryToGetReactiveProject)(e);return(0,reactiveCache_1.tryToGetReactiveJSONCompiler)(t).getPageJSON("compiled",o)}function getPageJSONWithDisableSpreading(e,o){const t=(0,reactiveCache_1.tryToGetReactiveProject)(e),n=(0,reactiveCache_1.tryToGetReactiveJSONCompiler)(t),{pagePath:a,miniprogramRoot:i=""}=o,r=(0,tools_1.normalizePath)(path_1.default.posix.join(i,a+".json")),c=(0,lodash_1.cloneDeep)(n.getPageJSON("checked",o));return compilePageJSON({project:t,miniprogramRoot:i,inputJSON:c,filePath:r,pagePath:a},!0),c.usingComponents||(c.usingComponents={}),c}reactiveCache_1.ReactiveJSONCompiler.setOriginCheckPageJSON(checkPageJSON_1.checkPageJSON),reactiveCache_1.ReactiveJSONCompiler.setOriginGetPageJSON(originGetPageJSON);
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getGameLocalPluginJSON=exports.getDevPluginJSON=exports.checkWorkers=exports.checkComponentPath=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),projectconfig_1=require("../projectconfig"),locales_1=tslib_1.__importDefault(require("../../../../../utils/locales/locales")),common_1=require("../common"),config_1=require("../../../../../config/config"),schemaValidate_1=require("../../validate/schemaValidate"),tools_1=require("../../../../../utils/tools"),cache_1=require("../../../../../utils/cache"),common_2=require("../../../../../utils/common"),reactiveCache_1=require("../reactiveCache");function checkComponentPath(o,e){const{project:t,root:c,filePath:i}=o;void 0!==e.usingComponents&&(0,common_1.checkComponentPath)({project:t,root:c,relativePath:path_1.default.posix.relative(c,i),inputJSON:e})}function checkPublicComponentsAndPages(o,e){const{project:t,root:c,filePath:i}=o,{publicComponents:n,pages:a}=e,r={};if(n){const o=[];for(const a in n){const n=e.publicComponents[a];(0,common_2.checkPath)({value:n,tips:`["publicComponents"]["${a}"]`,filePath:i,code:config_1.PLUGIN_JSON_CONTENT_ERR});let s=t.stat(c,n+".wxml");s&&!s.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["publicComponents"]["${n}"]`,n+".wxml")),s=t.stat(c,n+".js"),s&&!s.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["publicComponents"]["${n}"]`,n+".js")),s=t.stat(c,n+".json"),s&&!s.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["publicComponents"]["${n}"]`,n+".json")),r[a]=!0}o.length>0&&(0,common_2.throwError)({msg:o.join("\n"),code:config_1.PLUGIN_JSON_CONTENT_ERR,filePath:i})}if(a){const o=[];for(const e in a){const n=a[e];(0,common_2.checkPath)({value:n,tips:`["pages"]["${e}"]`,filePath:i,code:config_1.PLUGIN_JSON_CONTENT_ERR});let s=t.stat(c,n+".wxml");s&&!s.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["pages"]["${n}"]`,n+".wxml")),s=t.stat(c,n+".js"),s&&!s.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["pages"]["${n}"]`,n+".js")),s=t.stat(c,n+".json"),s&&!s.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["pages"]["${n}"]`,n+".json")),r[e]&&o.push(locales_1.default.config.SAME_KEY_PAGE_PUBLICCOMPONENTS.format(`"${e}"`)),r[e]=!0}o.length>0&&(0,common_2.throwError)({msg:o.join("\n"),code:config_1.PLUGIN_JSON_CONTENT_ERR,filePath:i})}}function checkWorkers(o,e){const{project:t,root:c,filePath:i}=o,{workers:n}=e;if(void 0===n)return;const a='["workers"]';""===n&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(a,locales_1.default.config.DIRECTORY),filePath:i}),(0,common_2.checkPath)({value:n,tips:a,filePath:i});const r=t.stat(c,n);r&&r.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([a,locales_1.default.config.DIRECTORY]),filePath:i}),e.workers=(0,tools_1.normalizePath)(n+"/")}function checkMain(o,e){const{project:t,root:c,filePath:i}=o,{main:n}=e;if(void 0===n)return;""===n&&(0,common_2.throwError)({msg:locales_1.default.config.SHOULD_NOT_BE_EMPTY.format('["main"]'),code:config_1.PLUGIN_JSON_CONTENT_ERR,filePath:i}),(0,common_2.checkPath)({value:n,tips:'["main"]',filePath:i,code:config_1.PLUGIN_JSON_CONTENT_ERR});const a=t.stat(c,n);a&&!a.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["main"]',n),code:config_1.PLUGIN_JSON_CONTENT_ERR,filePath:i})}function isKindOfGamePlugin(o){return o.type===config_1.COMPILE_TYPE.miniGamePlugin}function checkPluginJSON(o){const{root:e="",project:t}=o,c=path_1.default.posix.join(e,"plugin.json");t.stat(e,"plugin.json")||(0,common_2.throwError)({msg:locales_1.default.config.PLUGIN_JSON_NOT_FOUND.format(e,"plugin.json"),code:config_1.PLUGIN_JSON_FILE_NOT_FOUND,filePath:c});const i=t.getFile(e,"plugin.json"),n=(0,common_1.checkJSONFormat)((0,common_2.checkUTF8)(i,c),c),a=(0,schemaValidate_1.schemaValidate)("plugin",n);if(a.error.length){const o=(0,schemaValidate_1.transValidateResult)(c,a,!0);(0,common_2.throwError)({msg:"pluginJSON$"+o,code:config_1.PLUGIN_JSON_CONTENT_ERR,filePath:c})}return void 0!==n.themeLocation&&(0,common_2.checkPath)({value:n.themeLocation,tips:'["themeLocation"]',filePath:c}),isKindOfGamePlugin(t)||(checkPublicComponentsAndPages(o,n),checkComponentPath(o,n)),checkMain(o,n),checkWorkers(o,n),n}exports.checkComponentPath=checkComponentPath,exports.checkWorkers=checkWorkers,exports.getDevPluginJSON=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.PLUGIN_JSON,(o,e="")=>{const t=(0,projectconfig_1.getProjectConfigJSON)(o),{pluginRoot:c=""}=t;let i=c;o.type===config_1.COMPILE_TYPE.miniGame&&e&&(i=e),e||c||(0,common_2.throwError)({msg:locales_1.default.config.NOT_FOUND.format('["pluginRoot"]'),filePath:"project.config.json",code:config_1.JSON_CONTENT_ERR});return checkPluginJSON({project:o,filePath:path_1.default.posix.join(i,"plugin.json"),root:i})});const getGameLocalPluginJSON=async(o,e)=>{const t=await(0,projectconfig_1.getProjectConfigJSON)(o),{miniprogramRoot:c}=t;if(!e)return{};const i=(0,tools_1.normalizePath)(path_1.default.posix.join(c||"",e));return checkPluginJSON({project:(0,reactiveCache_1.tryToGetReactiveProject)(o),filePath:path_1.default.posix.join(i,"plugin.json"),root:i})};exports.getGameLocalPluginJSON=getGameLocalPluginJSON;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getGameLocalPluginJSON=exports.getDevPluginJSON=void 0,exports.checkComponentPath=checkComponentPath,exports.checkWorkers=checkWorkers;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),projectconfig_1=require("../projectconfig"),locales_1=tslib_1.__importDefault(require("../../../../../utils/locales/locales")),common_1=require("../common"),config_1=require("../../../../../config/config"),schemaValidate_1=require("../../validate/schemaValidate"),tools_1=require("../../../../../utils/tools"),cache_1=require("../../../../../utils/cache"),common_2=require("../../../../../utils/common"),reactiveCache_1=require("../reactiveCache");function checkComponentPath(o,e){const{project:t,root:c,filePath:i}=o;void 0!==e.usingComponents&&(0,common_1.checkComponentPath)({project:t,root:c,relativePath:path_1.default.posix.relative(c,i),inputJSON:e})}function checkPublicComponentsAndPages(o,e){const{project:t,root:c,filePath:i}=o,{publicComponents:n,pages:a}=e,r={};if(n){const o=[];for(const a in n){const n=e.publicComponents[a];(0,common_2.checkPath)({value:n,tips:`["publicComponents"]["${a}"]`,filePath:i,code:config_1.PLUGIN_JSON_CONTENT_ERR});let l=t.stat(c,n+".wxml");l&&!l.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["publicComponents"]["${n}"]`,n+".wxml")),l=t.stat(c,n+".js"),l&&!l.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["publicComponents"]["${n}"]`,n+".js")),l=t.stat(c,n+".json"),l&&!l.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["publicComponents"]["${n}"]`,n+".json")),r[a]=!0}o.length>0&&(0,common_2.throwError)({msg:o.join("\n"),code:config_1.PLUGIN_JSON_CONTENT_ERR,filePath:i})}if(a){const o=[];for(const e in a){const n=a[e];(0,common_2.checkPath)({value:n,tips:`["pages"]["${e}"]`,filePath:i,code:config_1.PLUGIN_JSON_CONTENT_ERR});let l=t.stat(c,n+".wxml");l&&!l.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["pages"]["${n}"]`,n+".wxml")),l=t.stat(c,n+".js"),l&&!l.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["pages"]["${n}"]`,n+".js")),l=t.stat(c,n+".json"),l&&!l.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["pages"]["${n}"]`,n+".json")),r[e]&&o.push(locales_1.default.config.SAME_KEY_PAGE_PUBLICCOMPONENTS.format(`"${e}"`)),r[e]=!0}o.length>0&&(0,common_2.throwError)({msg:o.join("\n"),code:config_1.PLUGIN_JSON_CONTENT_ERR,filePath:i})}}function checkWorkers(o,e){const{project:t,root:c,filePath:i}=o,{workers:n}=e;if(void 0===n)return;const a='["workers"]';""===n&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(a,locales_1.default.config.DIRECTORY),filePath:i}),(0,common_2.checkPath)({value:n,tips:a,filePath:i});const r=t.stat(c,n);r&&r.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([a,locales_1.default.config.DIRECTORY]),filePath:i}),e.workers=(0,tools_1.normalizePath)(n+"/")}function checkMain(o,e){const{project:t,root:c,filePath:i}=o,{main:n}=e;if(void 0===n)return;""===n&&(0,common_2.throwError)({msg:locales_1.default.config.SHOULD_NOT_BE_EMPTY.format('["main"]'),code:config_1.PLUGIN_JSON_CONTENT_ERR,filePath:i}),(0,common_2.checkPath)({value:n,tips:'["main"]',filePath:i,code:config_1.PLUGIN_JSON_CONTENT_ERR});const a=t.stat(c,n);a&&!a.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["main"]',n),code:config_1.PLUGIN_JSON_CONTENT_ERR,filePath:i})}function isKindOfGamePlugin(o){return o.type===config_1.COMPILE_TYPE.miniGamePlugin}function checkPluginJSON(o){const{root:e="",project:t}=o,c=path_1.default.posix.join(e,"plugin.json");t.stat(e,"plugin.json")||(0,common_2.throwError)({msg:locales_1.default.config.PLUGIN_JSON_NOT_FOUND.format(e,"plugin.json"),code:config_1.PLUGIN_JSON_FILE_NOT_FOUND,filePath:c});const i=t.getFile(e,"plugin.json"),n=(0,common_1.checkJSONFormat)((0,common_2.checkUTF8)(i,c),c),a=(0,schemaValidate_1.schemaValidate)("plugin",n);if(a.error.length){const o=(0,schemaValidate_1.transValidateResult)(c,a,!0);(0,common_2.throwError)({msg:"pluginJSON$"+o,code:config_1.PLUGIN_JSON_CONTENT_ERR,filePath:c})}return void 0!==n.themeLocation&&(0,common_2.checkPath)({value:n.themeLocation,tips:'["themeLocation"]',filePath:c}),isKindOfGamePlugin(t)||(checkPublicComponentsAndPages(o,n),checkComponentPath(o,n)),checkMain(o,n),checkWorkers(o,n),n}exports.getDevPluginJSON=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.PLUGIN_JSON,(o,e="")=>{const t=(0,projectconfig_1.getProjectConfigJSON)(o),{pluginRoot:c=""}=t;let i=c;o.type===config_1.COMPILE_TYPE.miniGame&&e&&(i=e),e||c||(0,common_2.throwError)({msg:locales_1.default.config.NOT_FOUND.format('["pluginRoot"]'),filePath:"project.config.json",code:config_1.JSON_CONTENT_ERR});return checkPluginJSON({project:o,filePath:path_1.default.posix.join(i,"plugin.json"),root:i})});const getGameLocalPluginJSON=async(o,e)=>{const t=await(0,projectconfig_1.getProjectConfigJSON)(o),{miniprogramRoot:c}=t;if(!e)return{};const i=(0,tools_1.normalizePath)(path_1.default.posix.join(c||"",e));return checkPluginJSON({project:(0,reactiveCache_1.tryToGetReactiveProject)(o),filePath:path_1.default.posix.join(i,"plugin.json"),root:i})};exports.getGameLocalPluginJSON=getGameLocalPluginJSON;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPluginPageJSON=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),common_1=require("../common"),schemaValidate_1=require("../../validate/schemaValidate"),locales_1=tslib_1.__importDefault(require("../../../../../utils/locales/locales")),common_2=require("../../../../../utils/common"),theme_1=require("../theme"),plugin_1=require("./plugin"),spreadUsingComponent=async(e,t)=>{const{project:a,root:i,filePath:n}=t,o=path_1.default.posix.relative(i,n);if(n.includes("miniprogram_npm/"))return;const r=await(0,plugin_1.getDevPluginJSON)(a,!0),s=Object.assign({},r.usingComponents);if(0!==Object.keys(s).length){e.usingComponents||(e.usingComponents={});for(const t in s){if(e.usingComponents[t])continue;const a=s[t]||"";if(a.startsWith("/")||a.startsWith("plugin://")){e.usingComponents[t]=a;continue}const i=path_1.default.posix.normalize(path_1.default.posix.relative(path_1.default.posix.dirname(o),a));e.usingComponents[t]=i.startsWith(".")?i:"./"+i}}};async function checkComponentPath(e,t){const{project:a,root:i,filePath:n}=t;await(0,common_1.checkComponentPath)({project:a,root:i,relativePath:path_1.default.posix.relative(i,n),inputJSON:e})}async function getPluginPageJSON(e){const{project:t}=e,{filePath:a}=e;if(!t.stat("",a))return{};const i=await t.getFile("",a),n=(0,common_1.checkJSONFormat)((0,common_2.checkUTF8)(i,a),a),o=await(0,theme_1.getPluginThemeLocation)(t);if(!o){const e=(0,common_1.getPageJSONVariableDecalearProperty)(n);e.length&&(0,common_2.throwError)({msg:'pluginJSON["themeLocation"] is required because:\n'+e.map(e=>`"${e.value}" as variable was declared at ${a}:${e.property}`).join("\n"),filePath:a})}let r={light:{},dark:{}};o&&(r=await(0,theme_1.checkThemeJSON)(t,{themeLocation:o,isPlugin:!0}));const s=(0,theme_1.mergeThemeJSONToPageJSON)(r,n,a),l=(0,schemaValidate_1.schemaValidate)("page",s.pageJSONLight),c=(0,schemaValidate_1.schemaValidate)("page",s.pageJSONDark);return l.warning&&(n.__warning__=locales_1.default.config.INVALID.format(l.warning)),o&&c.warning&&(n.__warning__=locales_1.default.config.INVALID.format(c.warning)),(0,schemaValidate_1.transValidateResult)(o?`${a} or ${o}["light"]`:a,l),o&&(0,schemaValidate_1.transValidateResult)(`${a} or ${o}["dark"]`,c),await checkComponentPath(n,e),await spreadUsingComponent(n,e),n}exports.getPluginPageJSON=getPluginPageJSON;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPluginPageJSON=getPluginPageJSON;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),common_1=require("../common"),schemaValidate_1=require("../../validate/schemaValidate"),locales_1=tslib_1.__importDefault(require("../../../../../utils/locales/locales")),common_2=require("../../../../../utils/common"),theme_1=require("../theme"),plugin_1=require("./plugin"),spreadUsingComponent=async(e,t)=>{const{project:a,root:i,filePath:n}=t,o=path_1.default.posix.relative(i,n);if(n.includes("miniprogram_npm/"))return;const r=await(0,plugin_1.getDevPluginJSON)(a,!0),s=Object.assign({},r.usingComponents);if(0!==Object.keys(s).length){e.usingComponents||(e.usingComponents={});for(const t in s){if(e.usingComponents[t])continue;const a=s[t]||"";if(a.startsWith("/")||a.startsWith("plugin://")){e.usingComponents[t]=a;continue}const i=path_1.default.posix.normalize(path_1.default.posix.relative(path_1.default.posix.dirname(o),a));e.usingComponents[t]=i.startsWith(".")?i:"./"+i}}};async function checkComponentPath(e,t){const{project:a,root:i,filePath:n}=t;await(0,common_1.checkComponentPath)({project:a,root:i,relativePath:path_1.default.posix.relative(i,n),inputJSON:e})}async function getPluginPageJSON(e){const{project:t}=e,{filePath:a}=e;if(!t.stat("",a))return{};const i=await t.getFile("",a),n=(0,common_1.checkJSONFormat)((0,common_2.checkUTF8)(i,a),a),o=await(0,theme_1.getPluginThemeLocation)(t);if(!o){const e=(0,common_1.getPageJSONVariableDecalearProperty)(n);e.length&&(0,common_2.throwError)({msg:'pluginJSON["themeLocation"] is required because:\n'+e.map(e=>`"${e.value}" as variable was declared at ${a}:${e.property}`).join("\n"),filePath:a})}let r={light:{},dark:{}};o&&(r=await(0,theme_1.checkThemeJSON)(t,{themeLocation:o,isPlugin:!0}));const s=(0,theme_1.mergeThemeJSONToPageJSON)(r,n,a),l=(0,schemaValidate_1.schemaValidate)("page",s.pageJSONLight),c=(0,schemaValidate_1.schemaValidate)("page",s.pageJSONDark);return l.warning&&(n.__warning__=locales_1.default.config.INVALID.format(l.warning)),o&&c.warning&&(n.__warning__=locales_1.default.config.INVALID.format(c.warning)),(0,schemaValidate_1.transValidateResult)(o?`${a} or ${o}["light"]`:a,l),o&&(0,schemaValidate_1.transValidateResult)(`${a} or ${o}["dark"]`,c),await checkComponentPath(n,e),await spreadUsingComponent(n,e),n}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.cleanReactiveCache=exports.wrapCompileJSONFunc=exports.tryToGetReactiveJSONCompiler=exports.ReactiveJSONCompiler=exports.tryToGetReactiveProject=exports.ReactiveProject=void 0;const process_1=require("process"),reactivity_1=require("@vue/reactivity"),lodash_1=require("lodash"),tools_1=require("../../../../utils/tools"),reactiveProject_1=require("../../../../project/advance/reactiveProject");function makeReadonly(e){return e&&"object"==typeof e?(0,reactivity_1.readonly)(e):e}Object.defineProperty(exports,"ReactiveProject",{enumerable:!0,get:function(){return reactiveProject_1.ReactiveProject}});const reactiveProjectMap=new Map;function tryToGetReactiveProject(e){let t=reactiveProjectMap.get(e.projectPath);return t||(t=new reactiveProject_1.ReactiveProject(e),reactiveProjectMap.set(e.projectPath,t),t)}exports.tryToGetReactiveProject=tryToGetReactiveProject;let isPending=!1;const pendingRunner=new Set,resolvedPromise=Promise.resolve();function runInNextTick(e){pendingRunner.add(e),isPending||(isPending=!0,resolvedPromise.then(()=>{const e=Date.now();try{const t=Array.from(pendingRunner);pendingRunner.clear(),isPending=!1,t.forEach(e=>{e()})}finally{(0,tools_1.devtoolsInfo)(`[reactiveCache] nextTick update cost ${Date.now()-e} ms`)}}))}class ReactiveJSONCompiler{constructor(e){this.pageComputeds=new Map,this.jsonComputeds=new Map,this.project=e}release(){(0,tools_1.devtoolsLog)("[reactiveCache] reactiveJSONCompiler release")}registerOrGet(e,t,...r){let o=this.jsonComputeds.get(e);if(!o){o=(0,reactivity_1.ref)(void 0),this.jsonComputeds.set(e,o);let i=void 0;i=(0,reactivity_1.effect)(()=>{try{const e=t.call(null,this.project,...r);(0,lodash_1.isEqual)(e,o.value)||(o.value=makeReadonly(e))}catch(t){o.value=t instanceof Error?t:new Error(t.toString()),(0,tools_1.devtoolsLog)(`[reactiveCache] update ${e} failed: `,t)}},{scheduler(){i&&i.active&&runInNextTick(i)}})}const{value:i}=o;if(i instanceof Error)throw i;return i}static setOriginGetPageJSON(e){this.originGetPageJSON=e}static setOriginCheckPageJSON(e){this.originCheckPageJSON=e}getPageJSON(e,t){let r=this.pageComputeds.get(t.pagePath);r||(r={checked:(0,reactivity_1.ref)(void 0),compiled:(0,reactivity_1.ref)(void 0)},this.pageComputeds.set(t.pagePath,r));const o=r[e];if(void 0===o.value){let r=void 0;r=(0,reactivity_1.effect)(()=>{try{(0,tools_1.devtoolsInfo)(`[reactiveCache] start to update ${e} ${t.pagePath}`);const r="compiled"===e?ReactiveJSONCompiler.originGetPageJSON(this.project,t):ReactiveJSONCompiler.originCheckPageJSON(this.project,t);o.value=makeReadonly(r),(0,tools_1.devtoolsInfo)(`[reactiveCache] update finish ${e} ${t.pagePath}`)}catch(r){o.value=r instanceof Error?r:new Error(r.toString()),(0,tools_1.devtoolsLog)(`[reactiveCache] update ${e} ${t.pagePath} failed: `,r)}},{scheduler(){r&&r.active&&(0,process_1.nextTick)(r)}})}const{value:i}=o;if(i instanceof Error)throw i;return i}}exports.ReactiveJSONCompiler=ReactiveJSONCompiler;const reactiveJSONCompilerMap=new Map;function tryToGetReactiveJSONCompiler(e){let t=reactiveJSONCompilerMap.get(e.projectPath);return t||(t=new ReactiveJSONCompiler(e),reactiveJSONCompilerMap.set(e.projectPath,t),t)}function wrapCompileJSONFunc(e,t){return function(r,...o){r instanceof reactiveProject_1.ReactiveProject||(r=tryToGetReactiveProject(r));return tryToGetReactiveJSONCompiler(r).registerOrGet(e,t,...o)}}function cleanReactiveCache(){reactiveProjectMap.forEach(e=>{e.release()}),reactiveProjectMap.clear(),reactiveJSONCompilerMap.forEach(e=>{e.release()}),reactiveJSONCompilerMap.clear()}exports.tryToGetReactiveJSONCompiler=tryToGetReactiveJSONCompiler,exports.wrapCompileJSONFunc=wrapCompileJSONFunc,exports.cleanReactiveCache=cleanReactiveCache;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ReactiveJSONCompiler=exports.ReactiveProject=void 0,exports.tryToGetReactiveProject=tryToGetReactiveProject,exports.tryToGetReactiveJSONCompiler=tryToGetReactiveJSONCompiler,exports.wrapCompileJSONFunc=wrapCompileJSONFunc,exports.cleanReactiveCache=cleanReactiveCache;const process_1=require("process"),reactivity_1=require("@vue/reactivity"),lodash_1=require("lodash"),tools_1=require("../../../../utils/tools"),reactiveProject_1=require("../../../../project/advance/reactiveProject");function makeReadonly(e){return e&&"object"==typeof e?(0,reactivity_1.readonly)(e):e}Object.defineProperty(exports,"ReactiveProject",{enumerable:!0,get:function(){return reactiveProject_1.ReactiveProject}});const reactiveProjectMap=new Map;function tryToGetReactiveProject(e){let t=reactiveProjectMap.get(e.projectPath);return t||(t=new reactiveProject_1.ReactiveProject(e),reactiveProjectMap.set(e.projectPath,t),t)}let isPending=!1;const pendingRunner=new Set,resolvedPromise=Promise.resolve();function runInNextTick(e){pendingRunner.add(e),isPending||(isPending=!0,resolvedPromise.then(()=>{const e=Date.now();try{const t=Array.from(pendingRunner);pendingRunner.clear(),isPending=!1,t.forEach(e=>{e()})}finally{(0,tools_1.devtoolsInfo)(`[reactiveCache] nextTick update cost ${Date.now()-e} ms`)}}))}class ReactiveJSONCompiler{constructor(e){this.pageComputeds=new Map,this.jsonComputeds=new Map,this.project=e}release(){(0,tools_1.devtoolsLog)("[reactiveCache] reactiveJSONCompiler release")}registerOrGet(e,t,...r){let o=this.jsonComputeds.get(e);if(!o){o=(0,reactivity_1.ref)(void 0),this.jsonComputeds.set(e,o);let i=void 0;i=(0,reactivity_1.effect)(()=>{try{const e=t.call(null,this.project,...r);(0,lodash_1.isEqual)(e,o.value)||(o.value=makeReadonly(e))}catch(t){o.value=t instanceof Error?t:new Error(t.toString()),(0,tools_1.devtoolsLog)(`[reactiveCache] update ${e} failed: `,t)}},{scheduler(){i&&i.active&&runInNextTick(i)}})}const{value:i}=o;if(i instanceof Error)throw i;return i}static setOriginGetPageJSON(e){this.originGetPageJSON=e}static setOriginCheckPageJSON(e){this.originCheckPageJSON=e}getPageJSON(e,t){let r=this.pageComputeds.get(t.pagePath);r||(r={checked:(0,reactivity_1.ref)(void 0),compiled:(0,reactivity_1.ref)(void 0)},this.pageComputeds.set(t.pagePath,r));const o=r[e];if(void 0===o.value){let r=void 0;r=(0,reactivity_1.effect)(()=>{try{(0,tools_1.devtoolsInfo)(`[reactiveCache] start to update ${e} ${t.pagePath}`);const r="compiled"===e?ReactiveJSONCompiler.originGetPageJSON(this.project,t):ReactiveJSONCompiler.originCheckPageJSON(this.project,t);o.value=makeReadonly(r),(0,tools_1.devtoolsInfo)(`[reactiveCache] update finish ${e} ${t.pagePath}`)}catch(r){o.value=r instanceof Error?r:new Error(r.toString()),(0,tools_1.devtoolsLog)(`[reactiveCache] update ${e} ${t.pagePath} failed: `,r)}},{scheduler(){r&&r.active&&(0,process_1.nextTick)(r)}})}const{value:i}=o;if(i instanceof Error)throw i;return i}}exports.ReactiveJSONCompiler=ReactiveJSONCompiler;const reactiveJSONCompilerMap=new Map;function tryToGetReactiveJSONCompiler(e){let t=reactiveJSONCompilerMap.get(e.projectPath);return t||(t=new ReactiveJSONCompiler(e),reactiveJSONCompilerMap.set(e.projectPath,t),t)}function wrapCompileJSONFunc(e,t){var r;return(null===(r=null===process||void 0===process?void 0:process.env)||void 0===r?void 0:r.BUILD_SERVER)?t:function(r,...o){r instanceof reactiveProject_1.ReactiveProject||(r=tryToGetReactiveProject(r));return tryToGetReactiveJSONCompiler(r).registerOrGet(e,t,...o)}}function cleanReactiveCache(){reactiveProjectMap.forEach(e=>{e.release()}),reactiveProjectMap.clear(),reactiveJSONCompilerMap.forEach(e=>{e.release()}),reactiveJSONCompilerMap.clear()}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getAllPluginSignatures=exports.isPathValid=exports.getAllPluginsWithPath=exports.friendlyPathMake=exports.trailing=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),tools_1=require("../../../../utils/tools"),log=tslib_1.__importStar(require("../../../../utils/log")),game_1=tslib_1.__importDefault(require("./game")),trailing=(t,e)=>t.endsWith(e)?t:t+e;exports.trailing=trailing;const friendlyPathMake=(t,e)=>path_1.default.normalize(path_1.default.join(t,e.replace(/\\/g,"/")).replace(/^\/+/,""));async function getAllPluginsWithPath(t){const e=(0,game_1.default)(t),i=[],a=(t,e="")=>{if(t.plugins)for(const a in t.plugins){if(!t.plugins.hasOwnProperty(a))continue;const r=t.plugins[a];r&&"string"==typeof r.path&&i.push({alias:a,version:r.version||"",provider:r.provider||"",path:r.path,friendlyPath:(0,exports.friendlyPathMake)(e,r.path)})}};a(e,"");const r=e.subPackages||e.subpackages;if(Array.isArray(r))for(const t of r)t&&"string"==typeof t.root&&a(t,t.root);return i}function isPathValid(t,e){if(e=e.replace(/\\/g,"/"),t=t.replace(/\\/g,"/"),e.includes("../")||e.endsWith("/.."))return!1;const i=(0,tools_1.normalizePath)(path_1.default.join(t,e)),a=(0,tools_1.normalizePath)(t);return!!i.startsWith(a)}async function getAllPluginSignatures(t){const e=await getAllPluginsWithPath(t),i=[];let a=t.miniprogramRoot?path_1.default.join(t.projectPath,t.miniprogramRoot):t.projectPath;a=(0,tools_1.normalizePath)(a),a=a.endsWith("/")?a:a+"/";for(const t of e)try{const e=path_1.default.join(a,t.friendlyPath);let r=await fs_extra_1.default.pathExists(e);if(!r)continue;const n=await fs_extra_1.default.stat(e);let s=e;n.isDirectory()||(s=path_1.default.dirname(e));const l=path_1.default.join(s,"signature.json");if(r=await fs_extra_1.default.pathExists(l),!r)continue;const o=await fs_extra_1.default.readFile(l,"utf8");let u=null;try{u=JSON.parse(o)}catch(t){log.error(t);continue}if(!u||!Array.isArray(u.signature))continue;const p=[];for(let t=0;t<u.signature.length;t++){const e=u.signature[t];if(!e)continue;if("string"!=typeof e.path||"string"!=typeof e.md5)continue;if(!isPathValid(s,e.path))continue;const i=path_1.default.join(s,e.path);p.push({fullPath:i,md5:e.md5})}i.push({provider:t.provider,fullPath:e,signature:p})}catch(t){log.error(t);continue}return i}exports.friendlyPathMake=friendlyPathMake,exports.getAllPluginsWithPath=getAllPluginsWithPath,exports.isPathValid=isPathValid,exports.getAllPluginSignatures=getAllPluginSignatures;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.friendlyPathMake=exports.trailing=void 0,exports.getAllPluginsWithPath=getAllPluginsWithPath,exports.isPathValid=isPathValid,exports.getAllPluginSignatures=getAllPluginSignatures;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),tools_1=require("../../../../utils/tools"),log=tslib_1.__importStar(require("../../../../utils/log")),game_1=tslib_1.__importDefault(require("./game")),trailing=(t,e)=>t.endsWith(e)?t:t+e;exports.trailing=trailing;const friendlyPathMake=(t,e)=>path_1.default.normalize(path_1.default.join(t,e.replace(/\\/g,"/")).replace(/^\/+/,""));async function getAllPluginsWithPath(t){const e=(0,game_1.default)(t),i=[],a=(t,e="")=>{if(t.plugins)for(const a in t.plugins){if(!t.plugins.hasOwnProperty(a))continue;const r=t.plugins[a];r&&"string"==typeof r.path&&i.push({alias:a,version:r.version||"",provider:r.provider||"",path:r.path,friendlyPath:(0,exports.friendlyPathMake)(e,r.path)})}};a(e,"");const r=e.subPackages||e.subpackages;if(Array.isArray(r))for(const t of r)t&&"string"==typeof t.root&&a(t,t.root);return i}function isPathValid(t,e){if(e=e.replace(/\\/g,"/"),t=t.replace(/\\/g,"/"),e.includes("../")||e.endsWith("/.."))return!1;const i=(0,tools_1.normalizePath)(path_1.default.join(t,e)),a=(0,tools_1.normalizePath)(t);return!!i.startsWith(a)}async function getAllPluginSignatures(t){const e=await getAllPluginsWithPath(t),i=[];let a=t.miniprogramRoot?path_1.default.join(t.projectPath,t.miniprogramRoot):t.projectPath;a=(0,tools_1.normalizePath)(a),a=a.endsWith("/")?a:a+"/";for(const t of e)try{const e=path_1.default.join(a,t.friendlyPath);let r=await fs_extra_1.default.pathExists(e);if(!r)continue;const n=await fs_extra_1.default.stat(e);let o=e;n.isDirectory()||(o=path_1.default.dirname(e));const s=path_1.default.join(o,"signature.json");if(r=await fs_extra_1.default.pathExists(s),!r)continue;const l=await fs_extra_1.default.readFile(s,"utf8");let u=null;try{u=JSON.parse(l)}catch(t){log.error(t);continue}if(!u||!Array.isArray(u.signature))continue;const p=[];for(let t=0;t<u.signature.length;t++){const e=u.signature[t];if(!e)continue;if("string"!=typeof e.path||"string"!=typeof e.md5)continue;if(!isPathValid(o,e.path))continue;const i=path_1.default.join(o,e.path);p.push({fullPath:i,md5:e.md5})}i.push({provider:t.provider,fullPath:e,signature:p})}catch(t){log.error(t);continue}return i}exports.friendlyPathMake=friendlyPathMake;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.mergeThemeJSONToPageJSON=exports.mergeThemeJSONToAppJSON=exports.checkThemeJSON=exports.getPluginThemeLocation=exports.getThemeLocation=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=tslib_1.__importStar(require("lodash")),tools_1=require("../../../../utils/tools"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),common_1=require("../../../../utils/common"),cache_1=require("../../../../utils/cache"),schemaValidate_1=require("../validate/schemaValidate"),config_1=require("../../../../config/config"),common_2=require("./common"),appJSON_1=require("./app/appJSON"),plugin_1=require("./plugin/plugin"),reactiveCache_1=require("./reactiveCache"),projectconfig_1=require("./projectconfig");async function getPluginThemeLocation(e){return(await(0,plugin_1.getDevPluginJSON)(e)).themeLocation||null}function checkThemeJSON(e,o){const{isPlugin:t}=o;return t?originCheckThemeJSONForPlugin(e,o):originCheckThemeJSONForMiniProgram(e,o)}exports.getThemeLocation=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.APP_JSON_THEME_LOCATION,e=>{const o=(0,appJSON_1.getRawAppJSON)(e),{themeLocation:t}=o;return"[object Undefined]"!==Object.prototype.toString.call(t)?"string"==typeof t?((0,common_1.checkPath)({value:t,tips:'["themeLocation"]',filePath:"app.json"}),t):((0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format('appJSON["themeLocation"]',"string"),filePath:"app.json"}),null):null}),exports.getPluginThemeLocation=getPluginThemeLocation,exports.checkThemeJSON=checkThemeJSON;const originCheckThemeJSONForMiniProgram=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.THEME_JSON,originCheckThemeJSON),originCheckThemeJSONForPlugin=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.PLUGIN_THEME_JSON,originCheckThemeJSON);function originCheckThemeJSON(e,o){const{isPlugin:t}=o,i=(0,exports.getThemeLocation)(e),r=(0,projectconfig_1.getProjectConfigJSON)(e),a=t?r.pluginRoot:r.miniprogramRoot,c=(0,tools_1.normalizePath)(path_1.default.posix.join(a||"",i));e.stat("",c)||(0,common_1.throwError)({msg:locales_1.default.config.FILE_NOT_FOUND.format(c),filePath:"app.json"});const n=e.getFile("",c),l=(0,common_1.checkUTF8)(n,c),s=(0,common_2.checkJSONFormat)(l,c),h=(0,schemaValidate_1.schemaValidate)("theme",s);return(0,schemaValidate_1.transValidateResult)(c,h),s}function mergeThemeJSONToAppJSON(e,o){var t,i;const{windowPropertWhiteList:r,tabBarPropertyWhiteList:a,tabbarListItemPropertyWhiteList:c}=config_1.jsonVariablePropertyWhiteList,n=/^@/,l=lodash_1.default.cloneDeep(o.window||{}),s=lodash_1.default.cloneDeep(o.window||{});Object.keys(l).forEach(o=>{const t=l[o];if(n.test(t)){r.includes(o)||(0,common_1.throwError)({msg:""+locales_1.default.config.SHOULD_NOT_IN.format([t,o]),filePath:"app.json"});const i=t.slice(1);l[o]=e.light[i]||t,s[o]=e.dark[i]||t}});const h=(0,lodash_1.cloneDeep)(o),m=(0,lodash_1.cloneDeep)(o);if(h.window=l,m.window=s,null===(i=null===(t=o.tabBar)||void 0===t?void 0:t.list)||void 0===i?void 0:i.length){const t=lodash_1.default.cloneDeep(o.tabBar||{list:[]}),i=lodash_1.default.cloneDeep(o.tabBar||{list:[]});t.list&&t.list.length>0&&Object.keys(t).forEach(o=>{if("list"!==o){const r=t[o];if(n.test(r)){a.includes(o)||(0,common_1.throwError)({msg:""+locales_1.default.config.SHOULD_NOT_IN.format([r,o]),filePath:"app.json"});const c=r.slice(1);t[o]=e.light[c]||r,i[o]=e.dark[c]||r}}else t.list.forEach((o,r)=>{Object.keys(o).forEach(a=>{const l=o[a];if(n.test(l)){c.includes(a)||(0,common_1.throwError)({msg:""+locales_1.default.config.SHOULD_NOT_IN.format([l,a]),filePath:"app.json"});const o=l.slice(1);t.list[r][a]=e.light[o]||l,i.list[r][a]=e.dark[o]||l}})})}),m.tabBar=i,h.tabBar=t}return{appJSONLight:h,appJSONDark:m}}function mergeThemeJSONToPageJSON(e,o,t){const i=config_1.jsonVariablePropertyWhiteList.windowPropertWhiteList,r=lodash_1.default.cloneDeep(o||{}),a=lodash_1.default.cloneDeep(o||{}),c=/^@/;return Object.keys(o).forEach(n=>{const l=o[n];if(c.test(l)){const o=l.slice(1);i.includes(n)||(0,common_1.throwError)({msg:""+locales_1.default.config.SHOULD_NOT_IN.format([l,n]),filePath:t}),a[n]=e.light[o]||l,r[n]=e.dark[o]||l}}),{pageJSONDark:r,pageJSONLight:a}}exports.mergeThemeJSONToAppJSON=mergeThemeJSONToAppJSON,exports.mergeThemeJSONToPageJSON=mergeThemeJSONToPageJSON;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getThemeLocation=void 0,exports.getPluginThemeLocation=getPluginThemeLocation,exports.checkThemeJSON=checkThemeJSON,exports.mergeThemeJSONToAppJSON=mergeThemeJSONToAppJSON,exports.mergeThemeJSONToPageJSON=mergeThemeJSONToPageJSON;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=tslib_1.__importStar(require("lodash")),tools_1=require("../../../../utils/tools"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),common_1=require("../../../../utils/common"),cache_1=require("../../../../utils/cache"),schemaValidate_1=require("../validate/schemaValidate"),config_1=require("../../../../config/config"),common_2=require("./common"),appJSON_1=require("./app/appJSON"),plugin_1=require("./plugin/plugin"),reactiveCache_1=require("./reactiveCache"),projectconfig_1=require("./projectconfig");async function getPluginThemeLocation(e){return(await(0,plugin_1.getDevPluginJSON)(e)).themeLocation||null}function checkThemeJSON(e,o){const{isPlugin:t}=o;return t?originCheckThemeJSONForPlugin(e,o):originCheckThemeJSONForMiniProgram(e,o)}exports.getThemeLocation=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.APP_JSON_THEME_LOCATION,e=>{const o=(0,appJSON_1.getRawAppJSON)(e),{themeLocation:t}=o;return"[object Undefined]"!==Object.prototype.toString.call(t)?"string"==typeof t?((0,common_1.checkPath)({value:t,tips:'["themeLocation"]',filePath:"app.json"}),t):((0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format('appJSON["themeLocation"]',"string"),filePath:"app.json"}),null):null});const originCheckThemeJSONForMiniProgram=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.THEME_JSON,originCheckThemeJSON),originCheckThemeJSONForPlugin=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.PLUGIN_THEME_JSON,originCheckThemeJSON);function originCheckThemeJSON(e,o){const{isPlugin:t}=o,i=(0,exports.getThemeLocation)(e),a=(0,projectconfig_1.getProjectConfigJSON)(e),r=t?a.pluginRoot:a.miniprogramRoot,c=(0,tools_1.normalizePath)(path_1.default.posix.join(r||"",i));e.stat("",c)||(0,common_1.throwError)({msg:locales_1.default.config.FILE_NOT_FOUND.format(c),filePath:"app.json"});const n=e.getFile("",c),l=(0,common_1.checkUTF8)(n,c),s=(0,common_2.checkJSONFormat)(l,c),h=(0,schemaValidate_1.schemaValidate)("theme",s);return(0,schemaValidate_1.transValidateResult)(c,h),s}function mergeThemeJSONToAppJSON(e,o){var t,i;const{windowPropertWhiteList:a,tabBarPropertyWhiteList:r,tabbarListItemPropertyWhiteList:c}=config_1.jsonVariablePropertyWhiteList,n=/^@/,l=lodash_1.default.cloneDeep(o.window||{}),s=lodash_1.default.cloneDeep(o.window||{});Object.keys(l).forEach(o=>{const t=l[o];if(n.test(t)){a.includes(o)||(0,common_1.throwError)({msg:""+locales_1.default.config.SHOULD_NOT_IN.format([t,o]),filePath:"app.json"});const i=t.slice(1);l[o]=e.light[i]||t,s[o]=e.dark[i]||t}});const h=(0,lodash_1.cloneDeep)(o),m=(0,lodash_1.cloneDeep)(o);if(h.window=l,m.window=s,null===(i=null===(t=o.tabBar)||void 0===t?void 0:t.list)||void 0===i?void 0:i.length){const t=lodash_1.default.cloneDeep(o.tabBar||{list:[]}),i=lodash_1.default.cloneDeep(o.tabBar||{list:[]});t.list&&t.list.length>0&&Object.keys(t).forEach(o=>{if("list"!==o){const a=t[o];if(n.test(a)){r.includes(o)||(0,common_1.throwError)({msg:""+locales_1.default.config.SHOULD_NOT_IN.format([a,o]),filePath:"app.json"});const c=a.slice(1);t[o]=e.light[c]||a,i[o]=e.dark[c]||a}}else t.list.forEach((o,a)=>{Object.keys(o).forEach(r=>{const l=o[r];if(n.test(l)){c.includes(r)||(0,common_1.throwError)({msg:""+locales_1.default.config.SHOULD_NOT_IN.format([l,r]),filePath:"app.json"});const o=l.slice(1);t.list[a][r]=e.light[o]||l,i.list[a][r]=e.dark[o]||l}})})}),m.tabBar=i,h.tabBar=t}return{appJSONLight:h,appJSONDark:m}}function mergeThemeJSONToPageJSON(e,o,t){const i=config_1.jsonVariablePropertyWhiteList.windowPropertWhiteList,a=lodash_1.default.cloneDeep(o||{}),r=lodash_1.default.cloneDeep(o||{}),c=/^@/;return Object.keys(o).forEach(n=>{const l=o[n];if(c.test(l)){const o=l.slice(1);i.includes(n)||(0,common_1.throwError)({msg:""+locales_1.default.config.SHOULD_NOT_IN.format([l,n]),filePath:t}),r[n]=e.light[o]||l,a[n]=e.dark[o]||l}}),{pageJSONDark:a,pageJSONLight:r}}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),read_package_tree_1=tslib_1.__importDefault(require("read-package-tree"));function checkDeps(e,t){var a,r;const n=new Set(Object.keys((null===(a=e.package)||void 0===a?void 0:a.dependencies)||{})),o=[];let s=e;for(;s;){const e=s.children||[];for(const t of e){const e=(null===(r=t.package)||void 0===r?void 0:r.name)||"";n.has(e)&&(n.delete(e),o.push(t))}s=s.parent}for(const e of o)t.has(e)||(t.add(e),checkDeps(e,t))}async function getDeps(e){return new Promise((t,a)=>{(0,read_package_tree_1.default)(e,(e,r)=>{if(e)return a(e);const n=new Set;try{checkDeps(r,n)}catch(e){return a(e)}t(Array.from(n))})})}async function default_1(e,t){if(null==t?void 0:t.length){const a=t.filter(e=>!/([\\/]|\b)node_modules/.test(e)),r=[],n={};for(const t of a){(await getDeps(path_1.default.join(e,path_1.default.dirname(t)))).forEach(e=>{r.push(e)})}for(const e of r){const t=e.isLink?e.path:e.realpath;n[path_1.default.normalize(path_1.default.join(t,"./package.json"))]=e}t=t.filter(t=>{const a=path_1.default.normalize(path_1.default.join(e,t));return!!n[a]})}return t}exports.default=default_1;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=default_1;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),read_package_tree_1=tslib_1.__importDefault(require("read-package-tree"));function checkDeps(e,t){var a,r;const n=new Set(Object.keys((null===(a=e.package)||void 0===a?void 0:a.dependencies)||{})),o=[];let s=e;for(;s;){const e=s.children||[];for(const t of e){const e=(null===(r=t.package)||void 0===r?void 0:r.name)||"";n.has(e)&&(n.delete(e),o.push(t))}s=s.parent}for(const e of o)t.has(e)||(t.add(e),checkDeps(e,t))}async function getDeps(e){return new Promise((t,a)=>{(0,read_package_tree_1.default)(e,(e,r)=>{if(e)return a(e);const n=new Set;try{checkDeps(r,n)}catch(e){return a(e)}t(Array.from(n))})})}async function default_1(e,t){if(null==t?void 0:t.length){const a=t.filter(e=>!/([\\/]|\b)node_modules/.test(e)),r=[],n={};for(const t of a){(await getDeps(path_1.default.join(e,path_1.default.dirname(t)))).forEach(e=>{r.push(e)})}for(const e of r){const t=e.isLink?e.path:e.realpath;n[path_1.default.normalize(path_1.default.join(t,"./package.json"))]=e}t=t.filter(t=>{const a=path_1.default.normalize(path_1.default.join(e,t));return!!n[a]})}return t}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.packNpmManually=exports.packNpm=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),fs_1=tslib_1.__importDefault(require("fs")),rimraf_1=tslib_1.__importDefault(require("rimraf")),lodash_1=tslib_1.__importDefault(require("lodash")),glob_1=tslib_1.__importDefault(require("glob")),source_map_1=tslib_1.__importDefault(require("source-map")),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),error_1=require("../../../../utils/error"),log=tslib_1.__importStar(require("../../../../utils/log")),projectconfig_1=require("../json/projectconfig"),config_1=require("../../../../config/config"),filterdeps_1=tslib_1.__importDefault(require("./filterdeps")),acorn=require("acorn"),NPM_RECORD={start_time:Date.now(),pack_time:0,miniprogram_pack_num:0,other_pack_num:0,warn_not_found_num:0,warn_require_var_num:0,warn_require_rename_num:0,extra1:"",extra2:"",extra3:""},REPORT_LIST=["pack_time","miniprogram_pack_num","other_pack_num","warn_not_found_num","warn_require_var_num","warn_require_rename_num","extra1","extra2","extra3"];function wrap(e,t){return function(...a){if(a.length){const e=a.pop();"function"!=typeof e&&a.push(e)}return new Promise((n,r)=>{a.push((e,t)=>{e?r(e):n(t)}),e.apply(t||null,a)})}}const statSync=wrap(fs_1.default.stat),mkdirSync=wrap(fs_1.default.mkdir),readFileSync=wrap(fs_1.default.readFile),writeFileSync=wrap(fs_1.default.writeFile),accessSync=wrap(fs_1.default.access),renameSync=wrap(fs_1.default.rename),globSync=wrap(glob_1.default);let seed=+new Date;function getId(){return++seed}function startRecord(){NPM_RECORD.start_time=Date.now(),REPORT_LIST.forEach(e=>NPM_RECORD[e]=e.startsWith("extra")?"":0)}function endRecord(e){NPM_RECORD.pack_time=Date.now()-NPM_RECORD.start_time;const t={};REPORT_LIST.forEach(e=>t[e]=NPM_RECORD[e]);try{null==e||e(t)}catch(e){}}async function recursiveMkdir(e){const t=path_1.default.posix.dirname(e);try{await accessSync(t)}catch(e){await recursiveMkdir(t)}try{await accessSync(e);const t=await statSync(e);t&&!t.isDirectory()&&(await renameSync(e,e+".bak"),log.warn(e+" already exists but is not a directory, so it will be rename to a file with the suffix ending in '.bak'"),await mkdirSync(e))}catch(t){await mkdirSync(e)}}async function copyFile(e,t){const a=await readFileSync(e);await writeFile(a,t)}async function writeFile(e,t){await recursiveMkdir(path_1.default.posix.dirname(t)),await writeFileSync(t,e)}function walkNode(e,t){t(e),Object.keys(e).forEach(a=>{const n=e[a];Array.isArray(n)&&n.forEach(e=>{(null==e?void 0:e.type)&&walkNode(e,t)}),(null==n?void 0:n.type)&&walkNode(n,t)})}function parseDeps(e,t,a){const n=[];let r,o=[];try{r=acorn.parse(e,{sourceType:"module",locations:!0,allowHashBang:!0,onComment(t,a,n,r){t||"#"!==e[n]||o.push({start:n,end:r,adjustContent:""})}})}catch(e){const a=`parse js file (${t}) failed: ${e.message}`;throw console.error(a),e.message=a,e}return walkNode(r,r=>{const{callee:i}=r,s=r.arguments;if("CallExpression"===r.type&&i&&"Identifier"===i.type&&"require"===i.name&&s&&1===s.length&&("Literal"===s[0].type?n.push(s[0].value):(a.push({jsPath:t,code:e.substring(r.start,r.end),startLine:r.loc.start.line,endLine:r.loc.end.line,tips:"require variable is not allowed",msg:locales_1.default.config.NOT_ALLOWED_REQUIRE_VAR.format()}),NPM_RECORD.warn_require_var_num++)),"ExpressionStatement"===r.type&&r.expression&&"use strict"===r.expression.value&&o.push({start:r.start,end:r.end,adjustContent:""}),"ImportDeclaration"===r.type){const{source:e}=r,{specifiers:t}=r,a={start:r.start,end:r.end,adjustContent:""},i=[];e&&"Literal"===e.type&&(n.push(e.value),i.push(`var __TEMP__ = require('${e.value}');`)),t&&Array.isArray(t)&&t.forEach(e=>{if("ImportSpecifier"===e.type){const{local:t}=e,{imported:a}=e;"Identifier"===t.type&&"Identifier"===a.type&&i.push(`var ${t.name} = __TEMP__['${a.name}'];`)}else if("ImportDefaultSpecifier"===e.type){const{local:t}=e;"Identifier"===t.type&&i.push(`var ${t.name} = __REQUIRE_DEFAULT__(__TEMP__);`)}else if("ImportNamespaceSpecifier"===e.type){const{local:t}=e;"Identifier"===t.type&&i.push(`var ${t.name} = __REQUIRE_WILDCARD__(__TEMP__);`)}}),a.adjustContent=i.join(""),o.push(a)}if("ExportNamedDeclaration"===r.type){const{source:t}=r,{specifiers:a}=r,{declaration:i}=r;let s=!1;const p={start:r.start,end:r.end,adjustContent:""},c=['if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });'];if(t&&"Literal"===t.type&&(n.push(t.value),c.push(`var __TEMP__ = require('${t.value}');`),s=!0),i){if("VariableDeclaration"===i.type){const{declarations:t}=i;t&&Array.isArray(t)&&t.forEach(t=>{if("VariableDeclarator"===t.type){const{id:a}=t,{init:n}=t;a&&"Identifier"===a.type&&(p.notAddLines=!0,c.push(`var ${a.name} = exports.${a.name} = ${n?e.substring(n.start,n.end):"undefined"};`))}})}else if("FunctionDeclaration"===i.type){const{id:t}=i;t&&"Identifier"===t.type&&(p.notAddLines=!0,c.push(`${e.substring(i.start,i.end)};exports.${t.name} = ${t.name}`))}else if("ClassDeclaration"===i.type){const{id:t}=i;t&&"Identifier"===t.type&&(p.notAddLines=!0,c.push(`${e.substring(i.start,i.end)};exports.${t.name} = ${t.name}`))}}else;a&&Array.isArray(a)&&a.forEach(e=>{if("ExportSpecifier"===e.type){const{local:t}=e,{exported:a}=e;"Identifier"===t.type&&"Identifier"===a.type&&c.push(`Object.defineProperty(exports, '${a.name}', { enumerable: true, configurable: true, get: function() { return ${s?"__TEMP__.":""}${t.name}; } });`)}}),p.adjustContent=c.join(""),o.push(p)}else if("ExportAllDeclaration"===r.type){const{source:e}=r,t={start:r.start,end:r.end,adjustContent:""},a=['if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });'];e&&"Literal"===e.type&&(n.push(e.value),a.push(`var __TEMP__ = require('${e.value}');`)),a.push('Object.keys(__TEMP__).forEach(function(k) { if (k === "default" || k === "__esModule") return; Object.defineProperty(exports, k, { enumerable: true, configurable: true, get: function() { return __TEMP__[k]; } }); });'),t.adjustContent=a.join(""),o.push(t)}else if("ExportDefaultDeclaration"===r.type){const{declaration:t}=r,a={start:r.start,end:r.end,adjustContent:""},n=['if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });'];if(t)if(a.notAddLines=!0,t.id){const{id:a}=t;n.push(`${e.substring(t.start,t.end)};exports.default = ${a.name}`)}else n.push(`exports.default = ${e.substring(t.start,t.end)};`);a.adjustContent=n.join(""),o.push(a)}const{expression:p}=r;"ExpressionStatement"===r.type&&p&&"AssignmentExpression"===p.type&&"Identifier"===p.right.type&&"require"===p.right.name&&(a.push({jsPath:t,code:e.substring(r.start,r.end),startLine:r.loc.start.line,endLine:r.loc.end.line,tips:"assign require function to a variable is not allowed",msg:locales_1.default.config.NOT_ALLOWED_REQUIRE_ASSIGN.format()}),NPM_RECORD.warn_require_rename_num++);const{declarations:c}=r;"VariableDeclaration"===r.type&&c.length>0&&c.forEach(n=>{const{init:o}=n;"VariableDeclarator"===n.type&&o&&"Identifier"===o.type&&"require"===o.name&&(a.push({jsPath:t,code:e.substring(r.start,r.end),startLine:r.loc.start.line,endLine:r.loc.end.line,tips:"assign require function to a variable is not allowed",msg:locales_1.default.config.NOT_ALLOWED_REQUIRE_ASSIGN.format()}),NPM_RECORD.warn_require_rename_num++)})}),o=o.sort((e,t)=>t.start-e.start),o.forEach(t=>{const a=e.substring(t.start,t.end),n=t.notAddLines?0:a.split("\n").length;e=e.substring(0,t.start)+t.adjustContent+new Array(n).join("\n")+e.substring(t.end)}),{deps:n,parsedContent:e}}async function parseJs(e,t,a,n,r,o){if(r[t=path_1.default.posix.normalize(t)])return r[t];const i=await readFileSync(t,"utf8"),s=getId(),p=path_1.default.posix.relative(e,t);if(t.endsWith(".json")){const e={id:s,name:p,content:"module.exports = "+i,deps:[],depsMap:{}};return r[t]=s,n.push(e),s}const{deps:c,parsedContent:_}=parseDeps(i,t,o),u={id:s,name:p,content:_,deps:c,depsMap:{}};r[t]=s,n.push(u);for(const i of c){let s,p=path_1.default.posix.join(path_1.default.posix.dirname(t),i);if(!p.endsWith(".js")&&!p.endsWith(".json")){const e=p+".js";try{await accessSync(e),p=e}catch(e){}}try{const e=await statSync(p);(null==e?void 0:e.isDirectory())&&(p=path_1.default.posix.join(p,"index.js"))}catch(e){}p.endsWith(".js")||p.endsWith(".json")||(p+=".js");try{await accessSync(p),s=await parseJs(e,p,a,n,r,o)}catch(e){}s&&(u.depsMap[i]=s)}return s}function addJsToMap(e,t,a,n){const r=t.split("\n").length;for(let o=1;o<=r;o++)e.addMapping({generated:{line:n+o,column:0},original:{line:o,column:0},source:a}),e.setSourceContent(a,t)}function findOutsideDeps(e){const t=new Set;return e.forEach(e=>{e.deps.forEach(a=>{Object.keys(e.depsMap).includes(a)||t.add(a)})}),Array.from(t)}async function packJs(e,t,a){try{const t=await statSync(e);(null==t?void 0:t.isDirectory())&&(e=path_1.default.posix.join(e,"index.js"))}catch(e){}e.endsWith(".js")||e.endsWith(".json")||(e+=".js");try{await accessSync(e)}catch(t){return a.push({jsPath:e,code:"",tips:"entry file is not found",msg:locales_1.default.config.NOT_FOUND_NPM_ENTRY.format()}),void NPM_RECORD.warn_not_found_num++}const n=new source_map_1.default.SourceMapGenerator({file:"index.js"}),r=[];await parseJs(path_1.default.posix.dirname(e),e,t,r,{},a);const o=findOutsideDeps(r),i=["module.exports = (function() {","var __MODS__ = {};","var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };",'var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; };',"var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } };","var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };"];if(r.length){const e=r.shift();i.push(`__DEFINE__(${e.id}, function(require, module, exports) {`),addJsToMap(n,e.content,e.name,i.length),i.push(e.content),i.push(`}, function(modId) {var map = ${JSON.stringify(e.depsMap)}; return __REQUIRE__(map[modId], modId); })`);for(const e of r)i.push(`__DEFINE__(${e.id}, function(require, module, exports) {`),addJsToMap(n,e.content,e.name,i.length),i.push(e.content),i.push(`}, function(modId) { var map = ${JSON.stringify(e.depsMap)}; return __REQUIRE__(map[modId], modId); })`);i.push(`return __REQUIRE__(${e.id});`)}return i.push("})()"),i.push("//miniprogram-npm-outsideDeps="+JSON.stringify(o)),i.push("//# sourceMappingURL=index.js.map"),{js:i.join("\n"),map:n.toString()}}async function checkIsMiniprogramPack(e,t){let a="miniprogram_dist";t.miniprogram&&"string"==typeof t.miniprogram&&(a=t.miniprogram);try{const t=path_1.default.posix.join(e,a);await accessSync(t);const n=await statSync(t);if(null==n?void 0:n.isDirectory())return t}catch(e){}return""}async function packNpm(e,t={}){const{projectPath:a}=e,n=e.type,r=await(0,projectconfig_1.getProjectConfigJSON)(e),o=r.pluginRoot||"",i=r.miniprogramRoot||"",s="miniProgramPlugin"===n||"miniGamePlugin"===n,{ignores:p,reporter:c}=t;if(!a)throw new error_1.CodeError(locales_1.default.config.SHOULD_NOT_BE_EMPTY.format("projectPath"),config_1.PARAM_ERROR);if("miniProgramPlugin"===n&&!o)throw new error_1.CodeError(locales_1.default.config.SHOULD_NOT_BE_EMPTY.format('project.config.json "pluginRoot"'),config_1.PARAM_ERROR);startRecord();const _=path_1.default.isAbsolute(a)?a:path_1.default.posix.join(process.cwd(),a),u=[{searchRoot:path_1.default.posix.join(_,i),paths:await globSync("**/package.json",{cwd:path_1.default.posix.join(_,i),nodir:!0,dot:!0,ignore:(p||[]).concat("**/node_modules/**")})}];s&&u.push({searchRoot:path_1.default.posix.join(_,o),paths:await globSync("**/package.json",{cwd:path_1.default.posix.join(_,o),nodir:!0,dot:!0,ignore:(p||[]).concat("**/node_modules/**")})});lodash_1.default.flattenDeep(u.map(e=>e.paths.map(t=>path_1.default.posix.join(e.searchRoot,path_1.default.dirname(t),"miniprogram_npm")))).forEach(e=>rimraf_1.default.sync(e));const l=[];for(const e of u)for(const t of e.paths){const a=path_1.default.dirname(path_1.default.posix.join(e.searchRoot,t)),n=lodash_1.default.xorWith(e.paths,[t]).map(e=>path_1.default.posix.join(path_1.default.posix.dirname(e),"/**")).filter(e=>"**"!==e);let r=await globSync("**/package.json",{cwd:a.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:(p||[]).concat(n).concat(["node_modules/@types/**"])});if(r=await(0,filterdeps_1.default)(a,r),r&&r.length)for(const e of r){const t=path_1.default.posix.join(a,e);let n=await readFileSync(t,"utf8");const r=path_1.default.dirname(t);let o=r.replace(/([\b/\\])node_modules([\b/\\])/g,(e,t,a)=>`${t}miniprogram_npm${a}`),i=path_1.default.basename(o);const s=i.split("@");s.length&&(i=s.pop()||""),o=o.replace(path_1.default.basename(o),i),n=JSON.parse(n);const p=path_1.default.posix.join(r,n.main||"index.js"),c=await checkIsMiniprogramPack(r,n);if(c){const e=await globSync("**/*",{cwd:c.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:"**/node_modules/**"});for(const t of e)await copyFile(path_1.default.posix.join(c,t),path_1.default.posix.join(o,t));NPM_RECORD.miniprogram_pack_num++}else{const e=await packJs(p,o,l);if(!e)continue;await writeFile(e.js,path_1.default.posix.join(o,"./index.js")),await writeFile(e.map,path_1.default.posix.join(o,"./index.js.map")),NPM_RECORD.other_pack_num++}}}if(endRecord(c),NPM_RECORD.miniprogram_pack_num+NPM_RECORD.other_pack_num<=0)throw new Error("__NO_NODE_MODULES__ "+locales_1.default.config.NOT_FOUND_NODE_MODULES.format());return"function"==typeof e.updateFileAndDirs&&e.updateFileAndDirs(),l}async function packNpmManually(e){let{packageJsonPath:t,miniprogramNpmDistDir:a}=e;const n=e.ignores||[],r={pack_time:0,miniprogram_pack_num:0,other_pack_num:0,warn_not_found_num:0,warn_require_var_num:0,warn_require_rename_num:0},o=[];if(!a)throw new Error("param miniprogramNpmDistDir is required");if(!t)throw new Error("param packageJsonPath is required");if(path_1.default.isAbsolute(a)||(a=path_1.default.join(process.cwd(),a)),path_1.default.isAbsolute(t)||(t=path_1.default.join(process.cwd(),t)),!fs_1.default.existsSync(t))throw new Error(`param packageJsonPath: ${t} file is not exited`);const i=path_1.default.dirname(t);let s=await globSync("**/package.json",{cwd:i.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:(n||[]).concat(["node_modules/@types/**"])});if(s=await(0,filterdeps_1.default)(i,s),!s||!s.length){const e={jsPath:i,code:"",tips:"",msg:"No miniprogram_npm package was found, please check package.json -> dependencies."};return log.warn(e.msg),o.push(e),{miniProgramPackNum:0,otherNpmPackNum:0,warnList:o}}s=s.filter(e=>e.startsWith("node_modules"));for(const e of s){const t=path_1.default.posix.join(i,e);let n=await readFileSync(t,"utf8");const s=path_1.default.dirname(t);let p=s.replace(/([\b/\\])node_modules([\b/\\])/g,(e,t,a)=>`${t}miniprogram_npm${a}`);p=path_1.default.posix.normalize(path_1.default.posix.join(a,"miniprogram_npm",p.split(/[/\\]miniprogram_npm[/\\]/)[1]));let c=path_1.default.basename(p);const _=c.split("@");_.length&&(c=_.pop()||""),p=p.replace(path_1.default.basename(p),c),n=JSON.parse(n);const u=path_1.default.posix.join(s,n.main||"index.js"),l=await checkIsMiniprogramPack(s,n);if(l){const e=await globSync("**/*",{cwd:l.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:"**/node_modules/**"});for(const t of e)await copyFile(path_1.default.posix.join(l,t),path_1.default.posix.join(p,t));r.miniprogram_pack_num++}else{const e=await packJs(u,p,o);if(!e)continue;await writeFile(e.js,path_1.default.posix.join(p,"./index.js")),await writeFile(e.map,path_1.default.posix.join(p,"./index.js.map")),r.other_pack_num++}}return{miniProgramPackNum:r.miniprogram_pack_num,otherNpmPackNum:r.other_pack_num,warnList:o}}exports.packNpm=packNpm,exports.packNpmManually=packNpmManually;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.packNpm=packNpm,exports.packNpmManually=packNpmManually;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),fs_1=tslib_1.__importDefault(require("fs")),rimraf_1=tslib_1.__importDefault(require("rimraf")),lodash_1=tslib_1.__importDefault(require("lodash")),glob_1=tslib_1.__importDefault(require("glob")),source_map_1=tslib_1.__importDefault(require("source-map")),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),error_1=require("../../../../utils/error"),log=tslib_1.__importStar(require("../../../../utils/log")),projectconfig_1=require("../json/projectconfig"),config_1=require("../../../../config/config"),filterdeps_1=tslib_1.__importDefault(require("./filterdeps")),acorn=require("acorn"),NPM_RECORD={start_time:Date.now(),pack_time:0,miniprogram_pack_num:0,other_pack_num:0,warn_not_found_num:0,warn_require_var_num:0,warn_require_rename_num:0,extra1:"",extra2:"",extra3:""},REPORT_LIST=["pack_time","miniprogram_pack_num","other_pack_num","warn_not_found_num","warn_require_var_num","warn_require_rename_num","extra1","extra2","extra3"];function wrap(e,t){return function(...a){if(a.length){const e=a.pop();"function"!=typeof e&&a.push(e)}return new Promise((n,r)=>{a.push((e,t)=>{e?r(e):n(t)}),e.apply(t||null,a)})}}const statSync=wrap(fs_1.default.stat),mkdirSync=wrap(fs_1.default.mkdir),readFileSync=wrap(fs_1.default.readFile),writeFileSync=wrap(fs_1.default.writeFile),accessSync=wrap(fs_1.default.access),renameSync=wrap(fs_1.default.rename),globSync=wrap(glob_1.default);let seed=+new Date;function getId(){return++seed}function startRecord(){NPM_RECORD.start_time=Date.now(),REPORT_LIST.forEach(e=>NPM_RECORD[e]=e.startsWith("extra")?"":0)}function endRecord(e){NPM_RECORD.pack_time=Date.now()-NPM_RECORD.start_time;const t={};REPORT_LIST.forEach(e=>t[e]=NPM_RECORD[e]);try{null==e||e(t)}catch(e){}}async function recursiveMkdir(e){const t=path_1.default.posix.dirname(e);try{await accessSync(t)}catch(e){await recursiveMkdir(t)}try{await accessSync(e);const t=await statSync(e);t&&!t.isDirectory()&&(await renameSync(e,e+".bak"),log.warn(e+" already exists but is not a directory, so it will be rename to a file with the suffix ending in '.bak'"),await mkdirSync(e))}catch(t){await mkdirSync(e)}}async function copyFile(e,t){const a=await readFileSync(e);await writeFile(a,t)}async function writeFile(e,t){await recursiveMkdir(path_1.default.posix.dirname(t)),await writeFileSync(t,e)}function walkNode(e,t){t(e),Object.keys(e).forEach(a=>{const n=e[a];Array.isArray(n)&&n.forEach(e=>{(null==e?void 0:e.type)&&walkNode(e,t)}),(null==n?void 0:n.type)&&walkNode(n,t)})}function parseDeps(e,t,a){const n=[];let r,o=[];try{r=acorn.parse(e,{sourceType:"module",locations:!0,allowHashBang:!0,onComment(t,a,n,r){t||"#"!==e[n]||o.push({start:n,end:r,adjustContent:""})}})}catch(e){const a=`parse js file (${t}) failed: ${e.message}`;throw console.error(a),e.message=a,e}return walkNode(r,r=>{const{callee:i}=r,s=r.arguments;if("CallExpression"===r.type&&i&&"Identifier"===i.type&&"require"===i.name&&s&&1===s.length&&("Literal"===s[0].type?n.push(s[0].value):(a.push({jsPath:t,code:e.substring(r.start,r.end),startLine:r.loc.start.line,endLine:r.loc.end.line,tips:"require variable is not allowed",msg:locales_1.default.config.NOT_ALLOWED_REQUIRE_VAR.format()}),NPM_RECORD.warn_require_var_num++)),"ExpressionStatement"===r.type&&r.expression&&"use strict"===r.expression.value&&o.push({start:r.start,end:r.end,adjustContent:""}),"ImportDeclaration"===r.type){const{source:e}=r,{specifiers:t}=r,a={start:r.start,end:r.end,adjustContent:""},i=[];e&&"Literal"===e.type&&(n.push(e.value),i.push(`var __TEMP__ = require('${e.value}');`)),t&&Array.isArray(t)&&t.forEach(e=>{if("ImportSpecifier"===e.type){const{local:t}=e,{imported:a}=e;"Identifier"===t.type&&"Identifier"===a.type&&i.push(`var ${t.name} = __TEMP__['${a.name}'];`)}else if("ImportDefaultSpecifier"===e.type){const{local:t}=e;"Identifier"===t.type&&i.push(`var ${t.name} = __REQUIRE_DEFAULT__(__TEMP__);`)}else if("ImportNamespaceSpecifier"===e.type){const{local:t}=e;"Identifier"===t.type&&i.push(`var ${t.name} = __REQUIRE_WILDCARD__(__TEMP__);`)}}),a.adjustContent=i.join(""),o.push(a)}if("ExportNamedDeclaration"===r.type){const{source:t}=r,{specifiers:a}=r,{declaration:i}=r;let s=!1;const p={start:r.start,end:r.end,adjustContent:""},c=['if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });'];if(t&&"Literal"===t.type&&(n.push(t.value),c.push(`var __TEMP__ = require('${t.value}');`),s=!0),i){if("VariableDeclaration"===i.type){const{declarations:t}=i;t&&Array.isArray(t)&&t.forEach(t=>{if("VariableDeclarator"===t.type){const{id:a}=t,{init:n}=t;a&&"Identifier"===a.type&&(p.notAddLines=!0,c.push(`var ${a.name} = exports.${a.name} = ${n?e.substring(n.start,n.end):"undefined"};`))}})}else if("FunctionDeclaration"===i.type){const{id:t}=i;t&&"Identifier"===t.type&&(p.notAddLines=!0,c.push(`${e.substring(i.start,i.end)};exports.${t.name} = ${t.name}`))}else if("ClassDeclaration"===i.type){const{id:t}=i;t&&"Identifier"===t.type&&(p.notAddLines=!0,c.push(`${e.substring(i.start,i.end)};exports.${t.name} = ${t.name}`))}}else;a&&Array.isArray(a)&&a.forEach(e=>{if("ExportSpecifier"===e.type){const{local:t}=e,{exported:a}=e;"Identifier"===t.type&&"Identifier"===a.type&&c.push(`Object.defineProperty(exports, '${a.name}', { enumerable: true, configurable: true, get: function() { return ${s?"__TEMP__.":""}${t.name}; } });`)}}),p.adjustContent=c.join(""),o.push(p)}else if("ExportAllDeclaration"===r.type){const{source:e}=r,t={start:r.start,end:r.end,adjustContent:""},a=['if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });'];e&&"Literal"===e.type&&(n.push(e.value),a.push(`var __TEMP__ = require('${e.value}');`)),a.push('Object.keys(__TEMP__).forEach(function(k) { if (k === "default" || k === "__esModule") return; Object.defineProperty(exports, k, { enumerable: true, configurable: true, get: function() { return __TEMP__[k]; } }); });'),t.adjustContent=a.join(""),o.push(t)}else if("ExportDefaultDeclaration"===r.type){const{declaration:t}=r,a={start:r.start,end:r.end,adjustContent:""},n=['if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });'];if(t)if(a.notAddLines=!0,t.id){const{id:a}=t;n.push(`${e.substring(t.start,t.end)};exports.default = ${a.name}`)}else n.push(`exports.default = ${e.substring(t.start,t.end)};`);a.adjustContent=n.join(""),o.push(a)}const{expression:p}=r;"ExpressionStatement"===r.type&&p&&"AssignmentExpression"===p.type&&"Identifier"===p.right.type&&"require"===p.right.name&&(a.push({jsPath:t,code:e.substring(r.start,r.end),startLine:r.loc.start.line,endLine:r.loc.end.line,tips:"assign require function to a variable is not allowed",msg:locales_1.default.config.NOT_ALLOWED_REQUIRE_ASSIGN.format()}),NPM_RECORD.warn_require_rename_num++);const{declarations:c}=r;"VariableDeclaration"===r.type&&c.length>0&&c.forEach(n=>{const{init:o}=n;"VariableDeclarator"===n.type&&o&&"Identifier"===o.type&&"require"===o.name&&(a.push({jsPath:t,code:e.substring(r.start,r.end),startLine:r.loc.start.line,endLine:r.loc.end.line,tips:"assign require function to a variable is not allowed",msg:locales_1.default.config.NOT_ALLOWED_REQUIRE_ASSIGN.format()}),NPM_RECORD.warn_require_rename_num++)})}),o=o.sort((e,t)=>t.start-e.start),o.forEach(t=>{const a=e.substring(t.start,t.end),n=t.notAddLines?0:a.split("\n").length;e=e.substring(0,t.start)+t.adjustContent+new Array(n).join("\n")+e.substring(t.end)}),{deps:n,parsedContent:e}}async function parseJs(e,t,a,n,r,o){if(r[t=path_1.default.posix.normalize(t)])return r[t];const i=await readFileSync(t,"utf8"),s=getId(),p=path_1.default.posix.relative(e,t);if(t.endsWith(".json")){const e={id:s,name:p,content:"module.exports = "+i,deps:[],depsMap:{}};return r[t]=s,n.push(e),s}const{deps:c,parsedContent:_}=parseDeps(i,t,o),u={id:s,name:p,content:_,deps:c,depsMap:{}};r[t]=s,n.push(u);for(const i of c){let s,p=path_1.default.posix.join(path_1.default.posix.dirname(t),i);if(!p.endsWith(".js")&&!p.endsWith(".json")){const e=p+".js";try{await accessSync(e),p=e}catch(e){}}try{const e=await statSync(p);(null==e?void 0:e.isDirectory())&&(p=path_1.default.posix.join(p,"index.js"))}catch(e){}p.endsWith(".js")||p.endsWith(".json")||(p+=".js");try{await accessSync(p),s=await parseJs(e,p,a,n,r,o)}catch(e){}s&&(u.depsMap[i]=s)}return s}function addJsToMap(e,t,a,n){const r=t.split("\n").length;for(let o=1;o<=r;o++)e.addMapping({generated:{line:n+o,column:0},original:{line:o,column:0},source:a}),e.setSourceContent(a,t)}function findOutsideDeps(e){const t=new Set;return e.forEach(e=>{e.deps.forEach(a=>{Object.keys(e.depsMap).includes(a)||t.add(a)})}),Array.from(t)}async function packJs(e,t,a){try{const t=await statSync(e);(null==t?void 0:t.isDirectory())&&(e=path_1.default.posix.join(e,"index.js"))}catch(e){}e.endsWith(".js")||e.endsWith(".json")||(e+=".js");try{await accessSync(e)}catch(t){return a.push({jsPath:e,code:"",tips:"entry file is not found",msg:locales_1.default.config.NOT_FOUND_NPM_ENTRY.format()}),void NPM_RECORD.warn_not_found_num++}const n=new source_map_1.default.SourceMapGenerator({file:"index.js"}),r=[];await parseJs(path_1.default.posix.dirname(e),e,t,r,{},a);const o=findOutsideDeps(r),i=["module.exports = (function() {","var __MODS__ = {};","var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };",'var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; };',"var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } };","var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };"];if(r.length){const e=r.shift();i.push(`__DEFINE__(${e.id}, function(require, module, exports) {`),addJsToMap(n,e.content,e.name,i.length),i.push(e.content),i.push(`}, function(modId) {var map = ${JSON.stringify(e.depsMap)}; return __REQUIRE__(map[modId], modId); })`);for(const e of r)i.push(`__DEFINE__(${e.id}, function(require, module, exports) {`),addJsToMap(n,e.content,e.name,i.length),i.push(e.content),i.push(`}, function(modId) { var map = ${JSON.stringify(e.depsMap)}; return __REQUIRE__(map[modId], modId); })`);i.push(`return __REQUIRE__(${e.id});`)}return i.push("})()"),i.push("//miniprogram-npm-outsideDeps="+JSON.stringify(o)),i.push("//# sourceMappingURL=index.js.map"),{js:i.join("\n"),map:n.toString()}}async function checkIsMiniprogramPack(e,t){let a="miniprogram_dist";t.miniprogram&&"string"==typeof t.miniprogram&&(a=t.miniprogram);try{const t=path_1.default.posix.join(e,a);await accessSync(t);const n=await statSync(t);if(null==n?void 0:n.isDirectory())return t}catch(e){}return""}async function packNpm(e,t={}){const{projectPath:a}=e,n=e.type,r=await(0,projectconfig_1.getProjectConfigJSON)(e),o=r.pluginRoot||"",i=r.miniprogramRoot||"",s="miniProgramPlugin"===n||"miniGamePlugin"===n,{ignores:p,reporter:c}=t;if(!a)throw new error_1.CodeError(locales_1.default.config.SHOULD_NOT_BE_EMPTY.format("projectPath"),config_1.PARAM_ERROR);if("miniProgramPlugin"===n&&!o)throw new error_1.CodeError(locales_1.default.config.SHOULD_NOT_BE_EMPTY.format('project.config.json "pluginRoot"'),config_1.PARAM_ERROR);startRecord();const _=path_1.default.isAbsolute(a)?a:path_1.default.posix.join(process.cwd(),a),u=[{searchRoot:path_1.default.posix.join(_,i),paths:await globSync("**/package.json",{cwd:path_1.default.posix.join(_,i),nodir:!0,dot:!0,ignore:(p||[]).concat("**/node_modules/**")})}];s&&u.push({searchRoot:path_1.default.posix.join(_,o),paths:await globSync("**/package.json",{cwd:path_1.default.posix.join(_,o),nodir:!0,dot:!0,ignore:(p||[]).concat("**/node_modules/**")})});lodash_1.default.flattenDeep(u.map(e=>e.paths.map(t=>path_1.default.posix.join(e.searchRoot,path_1.default.dirname(t),"miniprogram_npm")))).forEach(e=>rimraf_1.default.sync(e));const l=[];for(const e of u)for(const t of e.paths){const a=path_1.default.dirname(path_1.default.posix.join(e.searchRoot,t)),n=lodash_1.default.xorWith(e.paths,[t]).map(e=>path_1.default.posix.join(path_1.default.posix.dirname(e),"/**")).filter(e=>"**"!==e);let r=await globSync("**/package.json",{cwd:a.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:(p||[]).concat(n).concat(["node_modules/@types/**"])});if(r=await(0,filterdeps_1.default)(a,r),r&&r.length)for(const e of r){const t=path_1.default.posix.join(a,e);let n=await readFileSync(t,"utf8");const r=path_1.default.dirname(t);let o=r.replace(/([\b/\\])node_modules([\b/\\])/g,(e,t,a)=>`${t}miniprogram_npm${a}`),i=path_1.default.basename(o);const s=i.split("@");s.length&&(i=s.pop()||""),o=o.replace(path_1.default.basename(o),i),n=JSON.parse(n);const p=path_1.default.posix.join(r,n.main||"index.js"),c=await checkIsMiniprogramPack(r,n);if(c){const e=await globSync("**/*",{cwd:c.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:"**/node_modules/**"});for(const t of e)await copyFile(path_1.default.posix.join(c,t),path_1.default.posix.join(o,t));NPM_RECORD.miniprogram_pack_num++}else{const e=await packJs(p,o,l);if(!e)continue;await writeFile(e.js,path_1.default.posix.join(o,"./index.js")),await writeFile(e.map,path_1.default.posix.join(o,"./index.js.map")),NPM_RECORD.other_pack_num++}}}if(endRecord(c),NPM_RECORD.miniprogram_pack_num+NPM_RECORD.other_pack_num<=0)throw new Error("__NO_NODE_MODULES__ "+locales_1.default.config.NOT_FOUND_NODE_MODULES.format());return"function"==typeof e.updateFileAndDirs&&e.updateFileAndDirs(),l}async function packNpmManually(e){let{packageJsonPath:t,miniprogramNpmDistDir:a}=e;const n=e.ignores||[],r={pack_time:0,miniprogram_pack_num:0,other_pack_num:0,warn_not_found_num:0,warn_require_var_num:0,warn_require_rename_num:0},o=[];if(!a)throw new Error("param miniprogramNpmDistDir is required");if(!t)throw new Error("param packageJsonPath is required");if(path_1.default.isAbsolute(a)||(a=path_1.default.join(process.cwd(),a)),path_1.default.isAbsolute(t)||(t=path_1.default.join(process.cwd(),t)),!fs_1.default.existsSync(t))throw new Error(`param packageJsonPath: ${t} file is not exited`);const i=path_1.default.dirname(t);let s=await globSync("**/package.json",{cwd:i.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:(n||[]).concat(["node_modules/@types/**"])});if(s=await(0,filterdeps_1.default)(i,s),!s||!s.length){const e={jsPath:i,code:"",tips:"",msg:"No miniprogram_npm package was found, please check package.json -> dependencies."};return log.warn(e.msg),o.push(e),{miniProgramPackNum:0,otherNpmPackNum:0,warnList:o}}s=s.filter(e=>e.startsWith("node_modules"));for(const e of s){const t=path_1.default.posix.join(i,e);let n=await readFileSync(t,"utf8");const s=path_1.default.dirname(t);let p=s.replace(/([\b/\\])node_modules([\b/\\])/g,(e,t,a)=>`${t}miniprogram_npm${a}`);p=path_1.default.posix.normalize(path_1.default.posix.join(a,"miniprogram_npm",p.split(/[/\\]miniprogram_npm[/\\]/)[1]));let c=path_1.default.basename(p);const _=c.split("@");_.length&&(c=_.pop()||""),p=p.replace(path_1.default.basename(p),c),n=JSON.parse(n);const u=path_1.default.posix.join(s,n.main||"index.js"),l=await checkIsMiniprogramPack(s,n);if(l){const e=await globSync("**/*",{cwd:l.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:"**/node_modules/**"});for(const t of e)await copyFile(path_1.default.posix.join(l,t),path_1.default.posix.join(p,t));r.miniprogram_pack_num++}else{const e=await packJs(u,p,o);if(!e)continue;await writeFile(e.js,path_1.default.posix.join(p,"./index.js")),await writeFile(e.map,path_1.default.posix.join(p,"./index.js.map")),r.other_pack_num++}}return{miniProgramPackNum:r.miniprogram_pack_num,otherNpmPackNum:r.other_pack_num,warnList:o}}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.uglifyFileNames=exports.getGameNameMapping=exports.getNameMapping=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),config_1=require("../../../../config/config"),error_1=require("../../../../utils/error"),tools_1=require("../../../../utils/tools"),game_1=tslib_1.__importDefault(require("../json/game")),app_1=require("../json/app"),url_config_1=require("../../../../config/url.config"),request_1=require("../../../../utils/request"),sign_1=require("../../../../utils/sign"),jsonParse_1=require("../../../../utils/jsonParse"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),config=tslib_1.__importStar(require("../../../../config/config")),common_1=require("../../../../utils/common"),fileFlatter_1=require("./fileFlatter");function checkPrefix(e,t){for(const a of t)if(e.startsWith(a))return a;return""}const getNameMapping=async(e,t)=>{if(process.env.isDevtools)return e.nameMappingFromDevtools||{};const a=e.getFileList(t,".js").map(e=>path_1.default.posix.relative(t,e));try{let r={};if("miniProgram"===e.type){const o=(0,app_1.getAppJSON)(e);r=await getMiniProgramNameMapping(e,t,o,a)}if("miniGame"===e.type){const t=(0,game_1.default)(e);r=await(0,exports.getGameNameMapping)(e,t,a)}return r}catch(e){throw new error_1.CodeError(e.toString(),config_1.CODE_PROTECT_TRANSLATE_FILENAME)}};exports.getNameMapping=getNameMapping;const getMiniProgramNameMapping=async(e,t,a,r)=>{var o;const i=[{type:"file",value:"app.js"},{type:"regex",value:/\/miniprogram_npm\/|^miniprogram_npm\//},{type:"folder",value:"functional-pages/"}],s=e.getFileList(t,".wxml").map(e=>path_1.default.posix.relative(t,e));for(const e of s)i.push({type:"file",value:""+e.replace(/\.wxml$/,".js")});let n=[];return a.subPackages&&(n=a.subPackages.map(e=>e.root)),(null===(o=null==a?void 0:a.widgets)||void 0===o?void 0:o.length)>0&&a.widgets.forEach(e=>{i.push({type:"folder",value:e.path.endsWith("/")?e.path:e.path+"/"})}),a.workers&&i.push({type:"folder",value:(0,tools_1.getWorkersPath)(a.workers)}),a.openDataContext&&(i.push({type:"file",value:path_1.default.posix.join(a.openDataContext,"index.js")}),n.push(a.openDataContext)),await _getNameMapping(e,r,i,n)},getGameNameMapping=async(e,t,a)=>{const r=[{type:"file",value:"game.js"},{type:"regex",value:/\/miniprogram_npm\/|^miniprogram_npm\//}],o=[];if(t.subPackages&&t.subPackages.forEach(e=>{const t=e.root.replace(/^\//,"");t.endsWith(".js")?(r.push({type:"file",value:t}),o.push(path_1.default.posix.dirname(t))):(r.push({type:"file",value:path_1.default.posix.join(t,"./game.js")}),o.push(t))}),t.openDataContext&&(r.push({type:"file",value:path_1.default.posix.join(t.openDataContext,"index.js")}),o.push(t.openDataContext)),t.workers&&r.push({type:"folder",value:(0,tools_1.getWorkersPath)(t.workers)}),t.plugins)for(const e in t.plugins){const a=t.plugins[e];if(a.path){const e=a.path.replace(/^\//,"");r.push({type:"folder",value:e})}}return await _getNameMapping(e,a,r,o)};async function _getNameMapping(e,t,a,r=[]){const o={},i=[];for(const e of t){let t=!1;for(const r of a)if("file"===r.type&&r.value===e||"folder"===r.type&&e.startsWith(r.value)||"regex"===r.type&&r.value.test(e)){t=!0;break}t||i.push(e)}const s=await(0,sign_1.getSignature)(e.privateKey,e.appid),{body:n}=await(0,request_1.request)({url:url_config_1.TRANSLATE_FILENAME,method:"post",body:JSON.stringify({appid:e.appid,signature:s,arrPaths:i}),headers:{"content-type":"application/json"}}),p=(0,jsonParse_1.jsonRespParse)(n,url_config_1.TRANSLATE_FILENAME);if(0===p.errCode)return p.body.pairs.forEach(e=>{const t=checkPrefix(e.origin,r);o[e.origin]=(0,tools_1.normalizePath)(path_1.default.posix.join(t,e.translated+".js"))}),o;throw new Error(`errCode: ${p.errCode} errMsg: ${p.errMsg}`)}function genResolveAlias(e){if(e){const t=[];return Object.keys(e).forEach(a=>{let r=a;a.endsWith("*")&&(r=r.slice(0,-1));let o=e[a];e[a].endsWith("*")&&(o=o.slice(0,-1)),t.push({key:r,value:o})}),e=>{let a={key:"",value:""},r=!1;if(t.forEach(t=>{e.startsWith(t.key)&&a.key.length<t.key.length&&(a=t,r=!0)}),!r)return;let o=e.replace(a.key,a.value);return o.startsWith("/")&&(o=o.slice(1)),o}}return e=>{}}async function uglifyFileNames(e,t,a){let r={miniprogramRoot:""};try{r=JSON.parse(t["project.config.json"].toString())}catch(e){}let o=(0,tools_1.normalizePath)(r.miniprogramRoot);"."===o&&(o=""),a=a||await(0,exports.getNameMapping)(e,e.miniprogramRoot);const i=Object.keys(t).filter(e=>e.endsWith(".js")),s={};let n,p=t[path_1.default.posix.join(o,"app.json")];p?(Buffer.isBuffer(p)&&(p=p.toString("utf-8")),p=JSON.parse(p),n=genResolveAlias(p.resolveAlias)):n=genResolveAlias(void 0);for(const e of i){if(/\/miniprogram_npm\/|^miniprogram_npm\//.test(e))continue;const r=e,p=t[e].toString(),l=t[e+".map"]||"";s[r]=(0,fileFlatter_1.tryTranslateSingleFile)({rootPath:o,code:p,nameMapping:a,check:!0,sourceFileName:e,sourceMap:l,filePath:e,miniProgramJSFiles:i,resolveAlias:n})}const l=Object.keys(t),u={};for(const e of l){u[(0,tools_1.normalizePath)(e)]=t[e]}for(const e in s){const t=(0,tools_1.normalizePath)(e);let r=t;const i=s[e];if(i.errMsg){if(!process.env.isDevtools)throw new Error(`\n${locales_1.default.config.COULD_NOT_USE_CODE_PROTECT}\n${i.errMsg}`);(0,common_1.throwError)({code:config.FILE_FLAT_ERR,msg:`${locales_1.default.config.COULD_NOT_USE_CODE_PROTECT}\n${i.errMsg}`,filePath:t})}const n=path_1.default.posix.relative(o,e);a[n]&&(r=(0,tools_1.normalizePath)(path_1.default.posix.join(o,a[n])),delete u[t],delete u[t+".map"]),u[r]=i.translatedContent,i.translatedSourceMap&&(u[r+".map"]=i.translatedSourceMap)}return u}exports.getGameNameMapping=getGameNameMapping,exports.uglifyFileNames=uglifyFileNames;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getGameNameMapping=exports.getNameMapping=void 0,exports.uglifyFileNames=uglifyFileNames;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),config_1=require("../../../../config/config"),error_1=require("../../../../utils/error"),tools_1=require("../../../../utils/tools"),game_1=tslib_1.__importDefault(require("../json/game")),app_1=require("../json/app"),url_config_1=require("../../../../config/url.config"),request_1=require("../../../../utils/request"),sign_1=require("../../../../utils/sign"),jsonParse_1=require("../../../../utils/jsonParse"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),config=tslib_1.__importStar(require("../../../../config/config")),common_1=require("../../../../utils/common"),fileFlatter_1=require("./fileFlatter");function checkPrefix(e,t){for(const a of t)if(e.startsWith(a))return a;return""}const getNameMapping=async(e,t)=>{if(process.env.isDevtools)return e.nameMappingFromDevtools||{};const a=e.getFileList(t,".js").map(e=>path_1.default.posix.relative(t,e));try{let r={};if("miniProgram"===e.type){const o=(0,app_1.getAppJSON)(e);r=await getMiniProgramNameMapping(e,t,o,a)}if("miniGame"===e.type){const t=(0,game_1.default)(e);r=await(0,exports.getGameNameMapping)(e,t,a)}return r}catch(e){throw new error_1.CodeError(e.toString(),config_1.CODE_PROTECT_TRANSLATE_FILENAME)}};exports.getNameMapping=getNameMapping;const getMiniProgramNameMapping=async(e,t,a,r)=>{var o;const i=[{type:"file",value:"app.js"},{type:"regex",value:/\/miniprogram_npm\/|^miniprogram_npm\//},{type:"folder",value:"functional-pages/"}],s=e.getFileList(t,".wxml").map(e=>path_1.default.posix.relative(t,e));for(const e of s)i.push({type:"file",value:""+e.replace(/\.wxml$/,".js")});let n=[];return a.subPackages&&(n=a.subPackages.map(e=>e.root)),(null===(o=null==a?void 0:a.widgets)||void 0===o?void 0:o.length)>0&&a.widgets.forEach(e=>{i.push({type:"folder",value:e.path.endsWith("/")?e.path:e.path+"/"})}),a.workers&&i.push({type:"folder",value:(0,tools_1.getWorkersPath)(a.workers)}),a.openDataContext&&(i.push({type:"file",value:path_1.default.posix.join(a.openDataContext,"index.js")}),n.push(a.openDataContext)),await _getNameMapping(e,r,i,n)},getGameNameMapping=async(e,t,a)=>{const r=[{type:"file",value:"game.js"},{type:"regex",value:/\/miniprogram_npm\/|^miniprogram_npm\//}],o=[];if(t.subPackages&&t.subPackages.forEach(e=>{const t=e.root.replace(/^\//,"");t.endsWith(".js")?(r.push({type:"file",value:t}),o.push(path_1.default.posix.dirname(t))):(r.push({type:"file",value:path_1.default.posix.join(t,"./game.js")}),o.push(t))}),t.openDataContext&&(r.push({type:"file",value:path_1.default.posix.join(t.openDataContext,"index.js")}),o.push(t.openDataContext)),t.workers&&r.push({type:"folder",value:(0,tools_1.getWorkersPath)(t.workers)}),t.plugins)for(const e in t.plugins){const a=t.plugins[e];if(a.path){const e=a.path.replace(/^\//,"");r.push({type:"folder",value:e})}}return await _getNameMapping(e,a,r,o)};async function _getNameMapping(e,t,a,r=[]){const o={},i=[];for(const e of t){let t=!1;for(const r of a)if("file"===r.type&&r.value===e||"folder"===r.type&&e.startsWith(r.value)||"regex"===r.type&&r.value.test(e)){t=!0;break}t||i.push(e)}const s=await(0,sign_1.getSignature)(e.privateKey,e.appid),{body:n}=await(0,request_1.request)({url:url_config_1.TRANSLATE_FILENAME,method:"post",body:JSON.stringify({appid:e.appid,signature:s,arrPaths:i}),headers:{"content-type":"application/json"}}),p=(0,jsonParse_1.jsonRespParse)(n,url_config_1.TRANSLATE_FILENAME);if(0===p.errCode)return p.body.pairs.forEach(e=>{const t=checkPrefix(e.origin,r);o[e.origin]=(0,tools_1.normalizePath)(path_1.default.posix.join(t,e.translated+".js"))}),o;throw new Error(`errCode: ${p.errCode} errMsg: ${p.errMsg}`)}function genResolveAlias(e){if(e){const t=[];return Object.keys(e).forEach(a=>{let r=a;a.endsWith("*")&&(r=r.slice(0,-1));let o=e[a];e[a].endsWith("*")&&(o=o.slice(0,-1)),t.push({key:r,value:o})}),e=>{let a={key:"",value:""},r=!1;if(t.forEach(t=>{e.startsWith(t.key)&&a.key.length<t.key.length&&(a=t,r=!0)}),!r)return;let o=e.replace(a.key,a.value);return o.startsWith("/")&&(o=o.slice(1)),o}}return e=>{}}async function uglifyFileNames(e,t,a){let r={miniprogramRoot:""};try{r=JSON.parse(t["project.config.json"].toString())}catch(e){}let o=(0,tools_1.normalizePath)(r.miniprogramRoot);"."===o&&(o=""),a=a||await(0,exports.getNameMapping)(e,e.miniprogramRoot);const i=Object.keys(t).filter(e=>e.endsWith(".js")),s={};let n,p=t[path_1.default.posix.join(o,"app.json")];p?(Buffer.isBuffer(p)&&(p=p.toString("utf-8")),p=JSON.parse(p),n=genResolveAlias(p.resolveAlias)):n=genResolveAlias(void 0);for(const e of i){if(/\/miniprogram_npm\/|^miniprogram_npm\//.test(e))continue;const r=e,p=t[e].toString(),l=t[e+".map"]||"";s[r]=(0,fileFlatter_1.tryTranslateSingleFile)({rootPath:o,code:p,nameMapping:a,check:!0,sourceFileName:e,sourceMap:l,filePath:e,miniProgramJSFiles:i,resolveAlias:n})}const l=Object.keys(t),u={};for(const e of l){u[(0,tools_1.normalizePath)(e)]=t[e]}for(const e in s){const t=(0,tools_1.normalizePath)(e);let r=t;const i=s[e];if(i.errMsg){if(!process.env.isDevtools)throw new Error(`\n${locales_1.default.config.COULD_NOT_USE_CODE_PROTECT}\n${i.errMsg}`);(0,common_1.throwError)({code:config.FILE_FLAT_ERR,msg:`${locales_1.default.config.COULD_NOT_USE_CODE_PROTECT}\n${i.errMsg}`,filePath:t})}const n=path_1.default.posix.relative(o,e);a[n]&&(r=(0,tools_1.normalizePath)(path_1.default.posix.join(o,a[n])),delete u[t],delete u[t+".map"]),u[r]=i.translatedContent,i.translatedSourceMap&&(u[r+".map"]=i.translatedSourceMap)}return u}exports.getGameNameMapping=getGameNameMapping;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NEW_CHECK_JSON_WAY=exports.transValidateResult=exports.schemaValidate=exports.config=void 0;const tslib_1=require("tslib"),jsonschema_1=require("jsonschema"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),common_1=require("../../../../utils/common"),validator=new jsonschema_1.Validator,app=require("../../../../schema/dist/app.js"),ext=require("../../../../schema/dist/ext.js"),game=require("../../../../schema/dist/game.js"),page=require("../../../../schema/dist/page.js"),plugin=require("../../../../schema/dist/plugin.js"),pluginpage=require("../../../../schema/dist/pluginpage.js"),projectconfig=require("../../../../schema/dist/projectconfig.js"),sitemap=require("../../../../schema/dist/sitemap.js"),theme=require("../../../../schema/dist/theme.js");exports.config={app:app,ext:ext,game:game,page:page,plugin:plugin,pluginpage:pluginpage,projectconfig:projectconfig,sitemap:sitemap,theme:theme};const SchemaMap=Object.assign({},exports.config);function schemaValidate(e,r){const t=validator.validate(r,SchemaMap[e]).errors,a=t.filter(e=>"additionalProperties"===e.name),o=t.filter(e=>"additionalProperties"!==e.name).map(e=>{if("type"===e.name||"enum"===e.name||"anyOf"===e.name){let r=e.argument;if("string"==typeof r&&(r=[r]),"anyOf"===e.name){r=[(e.schema.anyOf||[]).map(e=>e.type).join(", ")]}const t=e.property.replace(/^instance\.?/,"");return{errorType:e.name,errorProperty:t,correctType:r}}return{errorType:e.name,errorProperty:e.property.replace(/^instance\.?/,""),requireProperty:e.argument}});return{warning:a.map(r=>{const t=r.property.replace(/^instance\.?/,"");return`${e}.json ${t.length?t:""}["${r.argument}"]`}).join("、")||"",error:o}}function transValidateResult(e,r,t=!1){var a;if(null===(a=null==r?void 0:r.error)||void 0===a?void 0:a.length){const a=r.error.map(e=>{if("type"===e.errorType||"enum"===e.errorType||"anyOf"===e.errorType)return locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([e.errorProperty,e.correctType]);const r=""===e.errorProperty?e.requireProperty:`${e.errorProperty}.${e.requireProperty}`;return locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([r])}).join("\n");return t||(0,common_1.throwError)({msg:a,filePath:e}),a}return""}exports.schemaValidate=schemaValidate,exports.transValidateResult=transValidateResult,exports.NEW_CHECK_JSON_WAY=!0;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NEW_CHECK_JSON_WAY=exports.config=void 0,exports.schemaValidate=schemaValidate,exports.transValidateResult=transValidateResult;const tslib_1=require("tslib"),jsonschema_1=require("jsonschema"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),common_1=require("../../../../utils/common"),validator=new jsonschema_1.Validator,app=require("../../../../schema/dist/app.js"),ext=require("../../../../schema/dist/ext.js"),game=require("../../../../schema/dist/game.js"),page=require("../../../../schema/dist/page.js"),plugin=require("../../../../schema/dist/plugin.js"),pluginpage=require("../../../../schema/dist/pluginpage.js"),projectconfig=require("../../../../schema/dist/projectconfig.js"),sitemap=require("../../../../schema/dist/sitemap.js"),theme=require("../../../../schema/dist/theme.js");exports.config={app:app,ext:ext,game:game,page:page,plugin:plugin,pluginpage:pluginpage,projectconfig:projectconfig,sitemap:sitemap,theme:theme};const SchemaMap=Object.assign({},exports.config);function schemaValidate(e,r){const t=validator.validate(r,SchemaMap[e]).errors,a=t.filter(e=>"additionalProperties"===e.name),o=t.filter(e=>"additionalProperties"!==e.name).map(e=>{if("type"===e.name||"enum"===e.name||"anyOf"===e.name){let r=e.argument;if("string"==typeof r&&(r=[r]),"anyOf"===e.name){r=[(e.schema.anyOf||[]).map(e=>e.type).join(", ")]}const t=e.property.replace(/^instance\.?/,"");return{errorType:e.name,errorProperty:t,correctType:r}}return{errorType:e.name,errorProperty:e.property.replace(/^instance\.?/,""),requireProperty:e.argument}});return{warning:a.map(r=>{const t=r.property.replace(/^instance\.?/,"");return`${e}.json ${t.length?t:""}["${r.argument}"]`}).join("、")||"",error:o}}function transValidateResult(e,r,t=!1){var a;if(null===(a=null==r?void 0:r.error)||void 0===a?void 0:a.length){const a=r.error.map(e=>{if("type"===e.errorType||"enum"===e.errorType||"anyOf"===e.errorType)return locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([e.errorProperty,e.correctType]);const r=""===e.errorProperty?e.requireProperty:`${e.errorProperty}.${e.requireProperty}`;return locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([r])}).join("\n");return t||(0,common_1.throwError)({msg:a,filePath:e}),a}return""}exports.NEW_CHECK_JSON_WAY=!0;
@@ -1 +1 @@
1
- "use strict";var MSG_TYPE;Object.defineProperty(exports,"__esModule",{value:!0}),exports.MSG_TYPE=void 0,function(R){R.CREATE_WORKER="CREATE_WORKER",R.CREATE_WORKER_RESULT="CREATE_WORKER_RESULT",R.PROXY_WORKER_TO_FROM_WORKER_PROXY_MSG="PROXY_WORKER_TO_FROM_WORKER_PROXY_MSG",R.MAIN_TO_WORKER_PROXY_MSG="MAIN_TO_WORKER_PROXY_MSG",R.TERMINATE_WORKER_PROXY_MSG="TERMINATE_WORKER_PROXY_MSG",R.ON_WORKER_ERROR="ON_WORKER_ERROR",R.WEBWORKER_FS_OPERATE_CALLBACK="WEBWORKER_FS_OPERATE_CALLBACK",R.WEBWORKER_FS_OPERATE="WEBWORKER_FS_OPERATE",R.WEBWORKER_FS_OPERATE_SYNC="WEBWORKER_FS_OPERATE_SYNC",R.SYNC_CHANNEL="SYNC_CHANNEL",R.WORKER_LOGIC_MSG="WORKER_LOGIC_MSG"}(MSG_TYPE=exports.MSG_TYPE||(exports.MSG_TYPE={}));
1
+ "use strict";var MSG_TYPE;Object.defineProperty(exports,"__esModule",{value:!0}),exports.MSG_TYPE=void 0,function(R){R.CREATE_WORKER="CREATE_WORKER",R.CREATE_WORKER_RESULT="CREATE_WORKER_RESULT",R.PROXY_WORKER_TO_FROM_WORKER_PROXY_MSG="PROXY_WORKER_TO_FROM_WORKER_PROXY_MSG",R.MAIN_TO_WORKER_PROXY_MSG="MAIN_TO_WORKER_PROXY_MSG",R.TERMINATE_WORKER_PROXY_MSG="TERMINATE_WORKER_PROXY_MSG",R.ON_WORKER_ERROR="ON_WORKER_ERROR",R.WEBWORKER_FS_OPERATE_CALLBACK="WEBWORKER_FS_OPERATE_CALLBACK",R.WEBWORKER_FS_OPERATE="WEBWORKER_FS_OPERATE",R.WEBWORKER_FS_OPERATE_SYNC="WEBWORKER_FS_OPERATE_SYNC",R.SYNC_CHANNEL="SYNC_CHANNEL",R.WORKER_LOGIC_MSG="WORKER_LOGIC_MSG"}(MSG_TYPE||(exports.MSG_TYPE=MSG_TYPE={}));
@@ -1 +1 @@
1
- "use strict";var ETaskStatus,EWorkerStatus,EChildProcessStatus;Object.defineProperty(exports,"__esModule",{value:!0}),exports.SUICIDE_TIME=exports.EChildProcessStatus=exports.EWorkerStatus=exports.COMMAND=exports.TASK_NAME=exports.ETaskStatus=void 0,function(s){s[s.waiting=0]="waiting",s[s.progress=1]="progress",s[s.done=2]="done"}(ETaskStatus=exports.ETaskStatus||(exports.ETaskStatus={})),exports.TASK_NAME={COMPILE_JS:"COMPILE_JS",COMPILE_WXSS:"COMPILE_WXSS",MINIFY_WXML:"MINIFY_WXML",SUMMER_HOOK:"SUMMER_HOOK"},exports.COMMAND={RUN_TASK:"RUN_TASK",TASK_DONE:"TASK_DONE",CALL_FUNC:"CALL_FUNC",CALL_FUNC_RESULT:"CALL_FUNC_RESULT",CHILD_PROCESS_READY:"CHILD_PROCESS_READY",SEND_LOG:"SEND_LOG"},function(s){s[s.free=0]="free",s[s.busy=1]="busy",s[s.dying=2]="dying"}(EWorkerStatus=exports.EWorkerStatus||(exports.EWorkerStatus={})),function(s){s[s.free=0]="free",s[s.busy=1]="busy",s[s.fullload=2]="fullload",s[s.dying=3]="dying"}(EChildProcessStatus=exports.EChildProcessStatus||(exports.EChildProcessStatus={})),exports.SUICIDE_TIME={devtools:864e5,"miniprogram-ci":1e4,webide:864e5};
1
+ "use strict";var ETaskStatus,EWorkerStatus,EChildProcessStatus;Object.defineProperty(exports,"__esModule",{value:!0}),exports.SUICIDE_TIME=exports.EChildProcessStatus=exports.EWorkerStatus=exports.COMMAND=exports.TASK_NAME=exports.ETaskStatus=void 0,function(s){s[s.waiting=0]="waiting",s[s.progress=1]="progress",s[s.done=2]="done"}(ETaskStatus||(exports.ETaskStatus=ETaskStatus={})),exports.TASK_NAME={COMPILE_JS:"COMPILE_JS",COMPILE_WXSS:"COMPILE_WXSS",MINIFY_WXML:"MINIFY_WXML",SUMMER_HOOK:"SUMMER_HOOK"},exports.COMMAND={RUN_TASK:"RUN_TASK",TASK_DONE:"TASK_DONE",CALL_FUNC:"CALL_FUNC",CALL_FUNC_RESULT:"CALL_FUNC_RESULT",CHILD_PROCESS_READY:"CHILD_PROCESS_READY",SEND_LOG:"SEND_LOG"},function(s){s[s.free=0]="free",s[s.busy=1]="busy",s[s.dying=2]="dying"}(EWorkerStatus||(exports.EWorkerStatus=EWorkerStatus={})),function(s){s[s.free=0]="free",s[s.busy=1]="busy",s[s.fullload=2]="fullload",s[s.dying=3]="dying"}(EChildProcessStatus||(exports.EChildProcessStatus=EChildProcessStatus={})),exports.SUICIDE_TIME={devtools:864e5,"miniprogram-ci":1e4,webide:864e5};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),os_1=tslib_1.__importDefault(require("os"));let cpus=1;cpus=os_1.default.cpus().length;const envCpus=parseInt(process.env.COMPILE_THREADS||"0",10);function default_1(){return cpus}envCpus<=0||envCpus>cpus||(cpus=envCpus),exports.default=default_1;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=default_1;const tslib_1=require("tslib"),os_1=tslib_1.__importDefault(require("os"));let cpus=1;cpus=os_1.default.cpus().length;const envCpus=parseInt(process.env.COMPILE_THREADS||"0",10);function default_1(){return cpus}envCpus<=0||envCpus>cpus||(cpus=envCpus);
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.abortTask=exports.runTask=void 0;const tslib_1=require("tslib"),logger_1=require("../utils/logger"),workerManager_1=require("./workerManager"),childprocessManager_1=require("./childprocessManager"),index_1=tslib_1.__importDefault(require("./task/index")),env_1=require("../../../../utils/env");tslib_1.__exportStar(require("./config"),exports);const isDevtools=void 0!==(null===process||void 0===process?void 0:process.env.__nwjs);async function runTask(r,e,o=(()=>{})){var s,a;if(logger_1.logger.info("runTask",r,e.filePath),global.__MINIPROGRAM_CI_TEST__||"true"===(null===(s=null===process||void 0===process?void 0:process.env)||void 0===s?void 0:s.__MINIPROGRAM_CI_TEST__))return(0,index_1.default)(r,e);try{if((null===process||void 0===process?void 0:process.__nwjs)&&"wechatwebdevtools"===nw.App.manifest.appname||(null===(a=null===process||void 0===process?void 0:process.versions)||void 0===a?void 0:a.electron))return await childprocessManager_1.childProcessManager.runTask(r,e,o);const s=(0,workerManager_1.getWorkerManager)(isDevtools);return await s.runTask(r,e,o)}catch(o){if(env_1.isWebIDE)throw o;if(o===workerManager_1.AbortEvent)throw o;if(logger_1.logger.error(`runTask ${r}, ${e.filePath} catch error ${o}`),o instanceof childprocessManager_1.ChildProcessCrashedError)throw new Error(`runTask ${r}, ${e.filePath} catch error ${o}`);return(0,index_1.default)(r,e)}}function abortTask(r){(0,workerManager_1.getWorkerManager)(isDevtools).abort(r)}exports.runTask=runTask,exports.abortTask=abortTask;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.runTask=runTask,exports.abortTask=abortTask;const tslib_1=require("tslib"),logger_1=require("../utils/logger"),workerManager_1=require("./workerManager"),childprocessManager_1=require("./childprocessManager"),index_1=tslib_1.__importDefault(require("./task/index")),env_1=require("../../../../utils/env");tslib_1.__exportStar(require("./config"),exports);const isDevtools=void 0!==(null===process||void 0===process?void 0:process.env.__nwjs);async function runTask(r,e,o=(()=>{})){var s,a;if(logger_1.logger.info("runTask",r,e.filePath),global.__MINIPROGRAM_CI_TEST__||"true"===(null===(s=null===process||void 0===process?void 0:process.env)||void 0===s?void 0:s.__MINIPROGRAM_CI_TEST__))return(0,index_1.default)(r,e);try{if((null===process||void 0===process?void 0:process.__nwjs)&&"wechatwebdevtools"===nw.App.manifest.appname||(null===(a=null===process||void 0===process?void 0:process.versions)||void 0===a?void 0:a.electron))return await childprocessManager_1.childProcessManager.runTask(r,e,o);const s=(0,workerManager_1.getWorkerManager)(isDevtools);return await s.runTask(r,e,o)}catch(o){if(env_1.isWebIDE)throw o;if(o===workerManager_1.AbortEvent)throw o;if(logger_1.logger.error(`runTask ${r}, ${e.filePath} catch error ${o}`),o instanceof childprocessManager_1.ChildProcessCrashedError)throw new Error(`runTask ${r}, ${e.filePath} catch error ${o}`);return(0,index_1.default)(r,e)}}function abortTask(r){(0,workerManager_1.getWorkerManager)(isDevtools).abort(r)}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.call=void 0;const tslib_1=require("tslib"),config_1=require("../config"),FUNC=tslib_1.__importStar(require("./func"));let workerThreads,supportWorkerThread=!1;try{workerThreads=require("worker_threads"),supportWorkerThread=!0}catch(r){supportWorkerThread=!1}const callMainThread=function(){if(!supportWorkerThread||workerThreads.isMainThread)return(r,e)=>{};let r=0;const e={};return workerThreads.parentPort.on("message",r=>{const{command:o,data:t}=r;if(o!==config_1.COMMAND.CALL_FUNC_RESULT)return;const{id:a,result:s,error:n}=t,i=e[a];return delete e[a],i?n?i.reject(n):void i.resolve(s):void 0}),(o,t)=>new Promise((a,s)=>{const n=r++;e[n]={resolve:a,reject:s},workerThreads.parentPort.postMessage({command:config_1.COMMAND.CALL_FUNC,data:{id:n,funcName:o,args:t}})})}();function call(r,...e){return!supportWorkerThread||workerThreads.isMainThread?FUNC[r].apply(null,e):callMainThread(r,e)}exports.call=call;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.call=call;const tslib_1=require("tslib"),config_1=require("../config"),FUNC=tslib_1.__importStar(require("./func"));let workerThreads,supportWorkerThread=!1;try{workerThreads=require("worker_threads"),supportWorkerThread=!0}catch(r){supportWorkerThread=!1}const callMainThread=function(){if(!supportWorkerThread||workerThreads.isMainThread)return(r,e)=>{};let r=0;const e={};return workerThreads.parentPort.on("message",r=>{const{command:o,data:t}=r;if(o!==config_1.COMMAND.CALL_FUNC_RESULT)return;const{id:a,result:s,error:n}=t,i=e[a];return delete e[a],i?n?i.reject(n):void i.resolve(s):void 0}),(o,t)=>new Promise((a,s)=>{const n=r++;e[n]={resolve:a,reject:s},workerThreads.parentPort.postMessage({command:config_1.COMMAND.CALL_FUNC,data:{id:n,funcName:o,args:t}})})}();function call(r,...e){return!supportWorkerThread||workerThreads.isMainThread?FUNC[r].apply(null,e):callMainThread(r,e)}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.readFileAsync=void 0;const tslib_1=require("tslib"),fs_1=tslib_1.__importDefault(require("fs"));function readFileAsync(e,r){return new Promise((s,i)=>{fs_1.default.readFile(e,r,(e,r)=>{if(e)return i(e);s(r)})})}exports.readFileAsync=readFileAsync;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.readFileAsync=readFileAsync;const tslib_1=require("tslib"),fs_1=tslib_1.__importDefault(require("fs"));function readFileAsync(e,r){return new Promise((s,t)=>{fs_1.default.readFile(e,r,(e,r)=>{if(e)return t(e);s(r)})})}