miniprogram-ci 2.1.31 → 2.1.33

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 (609) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +5 -0
  3. package/dist/@types/ci/checkCodeQuality.d.ts +1 -1
  4. package/dist/@types/ci/cloud/utils.d.ts +1 -1
  5. package/dist/@types/ci/code-analyse.d.ts +1 -1
  6. package/dist/@types/ci/cos-upload.d.ts +0 -1
  7. package/dist/@types/ci/getCompiledResult.d.ts +0 -1
  8. package/dist/@types/ci/utils/filterUnusedFile.d.ts +0 -1
  9. package/dist/@types/ci/utils/pack.d.ts +0 -1
  10. package/dist/@types/ci/utils/packfile.d.ts +0 -1
  11. package/dist/@types/ci/utils/tools.d.ts +1 -1
  12. package/dist/@types/ci/utils/wxvpkg/unpack/version0.d.ts +0 -1
  13. package/dist/@types/ci/utils/wxvpkg/unpack/version10.d.ts +0 -1
  14. package/dist/@types/common/code-analyse/index.d.ts +16 -1
  15. package/dist/@types/config/compiletype.config.d.ts +4 -4
  16. package/dist/@types/config/config.d.ts +1 -1
  17. package/dist/@types/config/dir.config.d.ts +17 -0
  18. package/dist/@types/config/url.config.d.ts +42 -42
  19. package/dist/@types/index.d.ts +6 -2
  20. package/dist/@types/modules/corecompiler/baseCompiler.d.ts +3 -4
  21. package/dist/@types/modules/corecompiler/original/compile/common.d.ts +0 -1
  22. package/dist/@types/modules/corecompiler/original/compile/game.d.ts +1 -1
  23. package/dist/@types/modules/corecompiler/original/compile/gamePlugin.d.ts +0 -1
  24. package/dist/@types/modules/corecompiler/original/compile/handler/mpjson.d.ts +0 -1
  25. package/dist/@types/modules/corecompiler/original/compile/index.d.ts +1 -1
  26. package/dist/@types/modules/corecompiler/original/compile/miniprogram.d.ts +0 -1
  27. package/dist/@types/modules/corecompiler/original/compile/miniprogramPlugin.d.ts +0 -1
  28. package/dist/@types/modules/corecompiler/original/index.d.ts +1 -1
  29. package/dist/@types/modules/corecompiler/original/js/index.d.ts +0 -1
  30. package/dist/@types/modules/corecompiler/original/protect/uglifyfilenames.d.ts +0 -1
  31. package/dist/@types/modules/corecompiler/original/webWorker/webWorkerManager.d.ts +0 -1
  32. package/dist/@types/modules/corecompiler/original/workerThread/childprocessManager.d.ts +1 -1
  33. package/dist/@types/modules/corecompiler/original/workerThread/config.d.ts +3 -0
  34. package/dist/@types/modules/corecompiler/original/workerThread/task/compilejs.d.ts +4 -2
  35. package/dist/@types/modules/corecompiler/original/workerThread/task/compilewxss.d.ts +0 -1
  36. package/dist/@types/modules/corecompiler/original/workerThread/task/func.d.ts +4 -0
  37. package/dist/@types/modules/corecompiler/original/workerThread/task/minifywxml.d.ts +0 -1
  38. package/dist/@types/modules/corecompiler/original/workerThread/workerManager.d.ts +8 -0
  39. package/dist/@types/modules/corecompiler/originalCompiler.d.ts +1 -1
  40. package/dist/@types/modules/corecompiler/summer/graph/appconf.d.ts +1 -1
  41. package/dist/@types/modules/corecompiler/summer/graph/gameconf.d.ts +1 -1
  42. package/dist/@types/modules/corecompiler/summer/pipeManager/index.d.ts +6 -0
  43. package/dist/@types/modules/corecompiler/summer/pipeManager/pipeCPProject.d.ts +17 -0
  44. package/dist/@types/modules/corecompiler/summer/pipeManager/pipeContext.d.ts +10 -0
  45. package/dist/@types/modules/corecompiler/summer/pipeManager/pipeManager.d.ts +12 -0
  46. package/dist/@types/modules/corecompiler/summer/pipeManager/pipeWorker.d.ts +2 -0
  47. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/appservicePipe/index.d.ts +3 -0
  48. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/compileWxmlToGlassEaselPipe.d.ts +3 -0
  49. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/compileWxssPipe.d.ts +3 -0
  50. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/index.d.ts +2 -0
  51. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/pageInitSourcePipe/index.d.ts +4 -0
  52. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/pageframePipe/index.d.ts +3 -0
  53. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/appdevserver/getAppService.d.ts +6 -0
  54. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/appdevserver/getwxappcode.d.ts +9 -0
  55. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/appservice/getjsfile.d.ts +12 -0
  56. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/appservice/getmainpkgsortedjsfiles.d.ts +11 -0
  57. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/appservice/getwxappcode.d.ts +8 -0
  58. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/common/apperrcode.config.d.ts +92 -0
  59. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/common/tools.d.ts +1 -0
  60. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/project/appconfig.d.ts +6 -0
  61. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/project/appjson.d.ts +3 -0
  62. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/project/customcomponent.d.ts +21 -0
  63. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/project/helper/theme.d.ts +40 -0
  64. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/project/pagejson.d.ts +3 -0
  65. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/project/wxappcodejson.d.ts +3 -0
  66. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/trans/transwxmltojs.d.ts +19 -0
  67. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/trans/transwxsstojs.d.ts +15 -0
  68. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/web/processPath.d.ts +9 -0
  69. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/wccPipe.d.ts +3 -0
  70. package/dist/@types/modules/corecompiler/summer/pipeManager/types.d.ts +100 -0
  71. package/dist/@types/modules/corecompiler/summer/plugins/less.d.ts +0 -1
  72. package/dist/@types/modules/corecompiler/summer/plugins/script_task/minify_script_task.d.ts +1 -1
  73. package/dist/@types/modules/corecompiler/summer/resolver.d.ts +1 -1
  74. package/dist/@types/modules/corecompiler/summerCompiler.d.ts +12 -3
  75. package/dist/@types/modules/index.d.ts +1 -1
  76. package/dist/@types/modules/nativecompiler/ios/buildCloud.d.ts +2 -2
  77. package/dist/@types/modules/nativecompiler/processHandler.d.ts +1 -1
  78. package/dist/@types/modules/precompiler/conditioncompile/compiler/base.d.ts +0 -1
  79. package/dist/@types/modules/precompiler/conditioncompile/compiler/json.d.ts +0 -1
  80. package/dist/@types/modules/precompiler/conditioncompile/compiler/macro.d.ts +0 -1
  81. package/dist/@types/modules/precompiler/conditioncompile/compiler/plant.d.ts +1 -2
  82. package/dist/@types/modules/precompiler/conditioncompile/index.d.ts +1 -2
  83. package/dist/@types/project/advance/precompileProject.d.ts +1 -2
  84. package/dist/@types/project/advance/reactiveProject.d.ts +1 -2
  85. package/dist/@types/project/baseProject.d.ts +4 -3
  86. package/dist/@types/project/ciProjectWithMockBuffer.d.ts +0 -1
  87. package/dist/@types/services/accountcard/accountcard.d.ts +18 -0
  88. package/dist/@types/services/accountcard/accountcardService.d.ts +0 -0
  89. package/dist/@types/services/app/ci/appDirService.d.ts +6 -0
  90. package/dist/@types/services/app/common/appDirService.d.ts +10 -0
  91. package/dist/@types/services/app/common/appDirService.devtools.d.ts +7 -0
  92. package/dist/@types/services/app/electron/appDirService.d.ts +3 -0
  93. package/dist/@types/services/app/node/appDirService.d.ts +6 -0
  94. package/dist/@types/services/app/nw/appDirService.d.ts +3 -0
  95. package/dist/@types/services/builder/common/builder.d.ts +22 -0
  96. package/dist/@types/services/builder/nw/builder.d.ts +15 -0
  97. package/dist/@types/services/builder/webide/builder.d.ts +4 -0
  98. package/dist/@types/services/common/extensions.d.ts +8 -0
  99. package/dist/@types/services/common/getservice.d.ts +27 -0
  100. package/dist/@types/services/common/librarybase.d.ts +2063 -0
  101. package/dist/@types/services/common/vsbase.d.ts +3 -0
  102. package/dist/@types/services/compilewxml/common/compilewxmlService.d.ts +41 -0
  103. package/dist/@types/services/compilewxml/electron/compilewxmlService.d.ts +5 -0
  104. package/dist/@types/services/compilewxml/node/compileUtils.d.ts +3 -0
  105. package/dist/@types/services/compilewxml/node/compileglasseasel.d.ts +14 -0
  106. package/dist/@types/services/compilewxml/nw/compilewxmlService.d.ts +5 -0
  107. package/dist/@types/services/compilewxml/webide/compilewxmlService.d.ts +5 -0
  108. package/dist/@types/services/compilewxml/webide/pageFrameWasm/wcc/runWcc.d.ts +3 -0
  109. package/dist/@types/services/compilewxss/common/compilewxssService.d.ts +15 -0
  110. package/dist/@types/services/compilewxss/electron/compilewxssService.d.ts +4 -0
  111. package/dist/@types/services/compilewxss/node/compileUtils.d.ts +2 -0
  112. package/dist/@types/services/compilewxss/nw/compilewxssService.d.ts +4 -0
  113. package/dist/@types/services/compilewxss/webide/compilewxssService.d.ts +4 -0
  114. package/dist/@types/services/compilewxss/webide/pageFrameWasm/wcsc/runWcsc.d.ts +3 -0
  115. package/dist/@types/services/consoledisplay/common/consoledisplay.d.ts +5 -0
  116. package/dist/@types/services/consoledisplay/nw/consoledisplay.d.ts +6 -0
  117. package/dist/@types/services/fileUtilsManager/common/fileUtilsManager.d.ts +5 -0
  118. package/dist/@types/services/fileUtilsManager/nw/fileUtilsManager.d.ts +6 -0
  119. package/dist/@types/services/fs/common/fileService.d.ts +28 -0
  120. package/dist/@types/services/genTempFile/common/genTempFile.devtools.d.ts +4 -0
  121. package/dist/@types/services/genTempFile/common/genTempFile.node.d.ts +4 -0
  122. package/dist/@types/services/genTempFile/common/genTempFileService.d.ts +4 -0
  123. package/dist/@types/services/genTempFile/electron/genTempFileService.d.ts +3 -0
  124. package/dist/@types/services/genTempFile/node/genTempFileService.d.ts +3 -0
  125. package/dist/@types/services/genTempFile/nw/genTempFileService.d.ts +3 -0
  126. package/dist/@types/services/global/common/global.d.ts +10 -0
  127. package/dist/@types/services/global/nw/global.d.ts +12 -0
  128. package/dist/@types/services/initializeCheck/common/initializeCheck.d.ts +21 -0
  129. package/dist/@types/services/initializeCheck/nw/initializeCheck.d.ts +4 -0
  130. package/dist/@types/services/initializeCheck/webide/initializeCheck.d.ts +0 -0
  131. package/dist/@types/services/locales/common/locales.d.ts +7 -0
  132. package/dist/@types/services/locales/nw/locales.d.ts +9 -0
  133. package/dist/@types/services/log/common/logService.d.ts +9 -0
  134. package/dist/@types/services/miniappjson/common/miniappjson.d.ts +5 -0
  135. package/dist/@types/services/miniappjson/electron/miniappjson.d.ts +6 -0
  136. package/dist/@types/services/miniappjson/nw/miniappjson.d.ts +6 -0
  137. package/dist/@types/services/miniappjson/webide/miniappjson.d.ts +4 -0
  138. package/dist/@types/services/multiTaskManager/ci/multiTaskManager.d.ts +5 -0
  139. package/dist/@types/services/multiTaskManager/common/multiTaskManager.d.ts +5 -0
  140. package/dist/@types/services/multiTaskManager/electron/multiTaskManager.d.ts +5 -0
  141. package/dist/@types/services/multiTaskManager/webide/multiTaskManager.d.ts +5 -0
  142. package/dist/@types/services/nativeModule/ci/nativeModule.d.ts +3 -0
  143. package/dist/@types/services/nativeModule/common/nativeModule.d.ts +9 -0
  144. package/dist/@types/services/nativeModule/common/nativeModule.impl.d.ts +13 -0
  145. package/dist/@types/services/nativeModule/electron/nativeModule.d.ts +3 -0
  146. package/dist/@types/services/nativeModule/nw/nativeModule.d.ts +3 -0
  147. package/dist/@types/services/partialcompile/common/parialcompile.impl.d.ts +0 -0
  148. package/dist/@types/services/partialcompile/common/partialcompile.d.ts +0 -0
  149. package/dist/@types/services/partialcompile/nw/partialcompile.d.ts +0 -0
  150. package/dist/@types/services/partialcompile/webide/partialcompile.d.ts +0 -0
  151. package/dist/@types/services/performance/common/performance.d.ts +9 -0
  152. package/dist/@types/services/performance/nw/performance.d.ts +9 -0
  153. package/dist/@types/services/performance/webide/performance.d.ts +7 -0
  154. package/dist/@types/services/pluginFileReader/ci/pluginFileReader.d.ts +3 -0
  155. package/dist/@types/services/pluginFileReader/common/pluginFileReader.base.d.ts +9 -0
  156. package/dist/@types/services/pluginFileReader/common/pluginFileReader.d.ts +12 -0
  157. package/dist/@types/services/pluginFileReader/electron/pluginFileReader.d.ts +3 -0
  158. package/dist/@types/services/pluginFileReader/webide/pluginFileReader.d.ts +9 -0
  159. package/dist/@types/services/project/common/cloudProjectService.d.ts +0 -0
  160. package/dist/@types/services/project/common/createProjectService.d.ts +0 -0
  161. package/dist/@types/services/project/common/project.helper.d.ts +0 -0
  162. package/dist/@types/services/project/common/projectConfigService.d.ts +0 -0
  163. package/dist/@types/services/project/common/projectFileService.d.ts +0 -0
  164. package/dist/@types/services/project/common/projectconfigjsonutils.d.ts +0 -0
  165. package/dist/@types/services/project/electron-backend/projectManagerService.d.ts +0 -0
  166. package/dist/@types/services/project/node/createProjectService.d.ts +0 -0
  167. package/dist/@types/services/project/node/projectConfigService.d.ts +0 -0
  168. package/dist/@types/services/project/node/projectManagerService.d.ts +0 -0
  169. package/dist/@types/services/project/web/projectManagerService.d.ts +0 -0
  170. package/dist/@types/services/project/webide/projectConfigService.d.ts +0 -0
  171. package/dist/@types/services/project/webide/projectFileService.d.ts +0 -0
  172. package/dist/@types/services/project/webide/projectManagerService.d.ts +0 -0
  173. package/dist/@types/services/projectManager/common/buildServerProjectManager.d.ts +5 -0
  174. package/dist/@types/services/projectManager/common/projectManager.d.ts +7 -0
  175. package/dist/@types/services/projectManager/nw/projectManager.d.ts +9 -0
  176. package/dist/@types/services/root/ci/root.d.ts +11 -0
  177. package/dist/@types/services/root/ci/rootService.d.ts +2 -0
  178. package/dist/@types/services/root/common/createService.d.ts +12 -0
  179. package/dist/@types/services/root/electron/root.d.ts +11 -0
  180. package/dist/@types/services/root/electron/rootService.d.ts +2 -0
  181. package/dist/@types/services/root/nw/root.d.ts +11 -0
  182. package/dist/@types/services/root/nw/rootService.d.ts +0 -0
  183. package/dist/@types/services/root/webide/root.d.ts +11 -0
  184. package/dist/@types/services/root/webide/rootService.d.ts +2 -0
  185. package/dist/@types/services/staticConfig/common/staticConfigService.d.ts +5 -0
  186. package/dist/@types/services/staticConfig/nw/staticConfigService.d.ts +6 -0
  187. package/dist/@types/services/store/common/storeService.d.ts +17 -0
  188. package/dist/@types/services/uniapp/common/uniapp.d.ts +5 -0
  189. package/dist/@types/services/uniapp/nw/uniapp.d.ts +9 -0
  190. package/dist/@types/services/uniapp/webide/uniapp.d.ts +4 -0
  191. package/dist/@types/services/vendor/common/utils.d.ts +0 -0
  192. package/dist/@types/services/vendor/common/vendorService.d.ts +0 -0
  193. package/dist/@types/services/vendor/node/vendorService.d.ts +0 -0
  194. package/dist/@types/services/vendor/webide/vendorService.d.ts +0 -0
  195. package/dist/@types/types/ci.d.ts +1 -2
  196. package/dist/@types/types/core.d.ts +1 -2
  197. package/dist/@types/types/devtools.d.ts +0 -1
  198. package/dist/@types/types/summer.d.ts +0 -1
  199. package/dist/@types/utils/colorutils.d.ts +4 -0
  200. package/dist/@types/utils/common.d.ts +3 -1
  201. package/dist/@types/utils/cosUpload.d.ts +0 -1
  202. package/dist/@types/utils/debug.d.ts +1 -0
  203. package/dist/@types/utils/error.d.ts +1 -1
  204. package/dist/@types/utils/fsagent.d.ts +4 -4
  205. package/dist/@types/utils/locales/locales.d.ts +2 -114
  206. package/dist/@types/utils/locales/zh.d.ts +114 -113
  207. package/dist/@types/utils/miniappJson.d.ts +1 -1
  208. package/dist/@types/utils/node/common.d.ts +1 -0
  209. package/dist/@types/utils/packOptionsHelper.d.ts +1 -1
  210. package/dist/@types/utils/processBootstrap.d.ts +7 -0
  211. package/dist/@types/utils/signature.d.ts +0 -1
  212. package/dist/@types/utils/singletontask.d.ts +1 -0
  213. package/dist/@types/utils/subprocess/processManager.d.ts +1 -0
  214. package/dist/@types/utils/taskqueue.d.ts +0 -1
  215. package/dist/@types/utils/taskstatus.d.ts +1 -1
  216. package/dist/@types/utils/tools.d.ts +3 -4
  217. package/dist/@types/utils/web/common.d.ts +1 -0
  218. package/dist/@types/utils/wxapkg/pack.d.ts +2 -3
  219. package/dist/@types/utils/wxvpkgreader/wxvpkg/reader/version0.d.ts +0 -1
  220. package/dist/@types/utils/wxvpkgreader/wxvpkg/reader/version10.d.ts +0 -1
  221. package/dist/@types/utils/wxvpkgreader/wxvpkg/unpack/version0.d.ts +0 -1
  222. package/dist/@types/utils/wxvpkgreader/wxvpkg/unpack/version10.d.ts +0 -1
  223. package/dist/@types/utils/wxvpkgreader/wxvpkgreader.d.ts +0 -1
  224. package/dist/ci/android-miniapp-toolkit/dist/index.js +1 -1
  225. package/dist/ci/build-apk.js +1 -1
  226. package/dist/ci/build-ipa.js +1 -1
  227. package/dist/ci/checkCodeQuality.js +1 -1
  228. package/dist/ci/cloud/cloudapi.js +1 -1
  229. package/dist/ci/cloud/createTimeTrigger.js +1 -1
  230. package/dist/ci/cloud/uploadContainer.js +1 -1
  231. package/dist/ci/cloud/uploadFile.js +1 -1
  232. package/dist/ci/cloud/uploadFunction.js +1 -1
  233. package/dist/ci/cloud/utils.js +1 -1
  234. package/dist/ci/code-analyse.js +1 -1
  235. package/dist/ci/cos-upload.js +1 -1
  236. package/dist/ci/gamepkg/apkplug.js +1 -1
  237. package/dist/ci/gamepkg/index.js +1 -1
  238. package/dist/ci/getCompiledResult.js +1 -1
  239. package/dist/ci/getDevSourceMap.js +1 -1
  240. package/dist/ci/getLatestVersion.js +1 -1
  241. package/dist/ci/getcompiler.js +1 -1
  242. package/dist/ci/index.js +1 -1
  243. package/dist/ci/jsserver.js +1 -1
  244. package/dist/ci/miniapp/androidCloudBuild.js +1 -1
  245. package/dist/ci/miniapp/archive.js +1 -1
  246. package/dist/ci/miniapp/checkBuildArgument.js +1 -1
  247. package/dist/ci/miniapp/iosCloudBuild.js +1 -1
  248. package/dist/ci/miniapp/miniappPlugin.js +1 -1
  249. package/dist/ci/miniapp/sdkManager.js +1 -1
  250. package/dist/ci/miniapp/upload.js +1 -1
  251. package/dist/ci/miniapp-cloud-upload.js +1 -1
  252. package/dist/ci/miniappattr.js +1 -1
  253. package/dist/ci/preview.js +1 -1
  254. package/dist/ci/projectattr.js +1 -1
  255. package/dist/ci/upload.js +1 -1
  256. package/dist/ci/utils/ciRequest.js +1 -1
  257. package/dist/ci/utils/codeDenpendencyQualityChecker.js +1 -1
  258. package/dist/ci/utils/filterUnusedFile.js +1 -1
  259. package/dist/ci/utils/pack.js +1 -1
  260. package/dist/ci/utils/packfile.js +1 -1
  261. package/dist/ci/utils/terminalQrcode.js +1 -1
  262. package/dist/ci/utils/tools.js +1 -1
  263. package/dist/ci/utils/unpack.js +1 -1
  264. package/dist/ci/utils/wxvpkg/unpack/version0.js +1 -1
  265. package/dist/ci/utils/wxvpkg/unpack/version10.js +1 -1
  266. package/dist/cli/index.js +1 -1
  267. package/dist/common/code-analyse/index.js +1 -1
  268. package/dist/config/config.js +1 -1
  269. package/dist/config/dir.config.js +1 -0
  270. package/dist/config/url.config.js +1 -1
  271. package/dist/index.js +1 -1
  272. package/dist/modules/corecompiler/baseCompiler.js +1 -1
  273. package/dist/modules/corecompiler/original/analyse/partial.js +1 -1
  274. package/dist/modules/corecompiler/original/compile/common.js +1 -1
  275. package/dist/modules/corecompiler/original/compile/game.js +1 -1
  276. package/dist/modules/corecompiler/original/compile/gamePlugin.js +1 -1
  277. package/dist/modules/corecompiler/original/compile/handler/js.js +1 -1
  278. package/dist/modules/corecompiler/original/compile/handler/mpjson.js +1 -1
  279. package/dist/modules/corecompiler/original/compile/handler/wxml.js +1 -1
  280. package/dist/modules/corecompiler/original/compile/handler/wxss.js +1 -1
  281. package/dist/modules/corecompiler/original/compile/index.js +1 -1
  282. package/dist/modules/corecompiler/original/compile/miniprogram.js +1 -1
  283. package/dist/modules/corecompiler/original/compile/miniprogramPlugin.js +1 -1
  284. package/dist/modules/corecompiler/original/index.js +1 -1
  285. package/dist/modules/corecompiler/original/js/enhance.js +1 -1
  286. package/dist/modules/corecompiler/original/js/es6Transform.js +1 -1
  287. package/dist/modules/corecompiler/original/js/generateMap.js +1 -1
  288. package/dist/modules/corecompiler/original/js/index.js +1 -1
  289. package/dist/modules/corecompiler/original/js/minifyjs.js +1 -1
  290. package/dist/modules/corecompiler/original/js/minifyjsAfterWrap.js +1 -1
  291. package/dist/modules/corecompiler/original/js/workletCompile.js +1 -1
  292. package/dist/modules/corecompiler/original/json/app/appJSON.js +1 -1
  293. package/dist/modules/corecompiler/original/json/app/checkAppFields.js +1 -1
  294. package/dist/modules/corecompiler/original/json/app/extJSON.js +1 -1
  295. package/dist/modules/corecompiler/original/json/app/index.js +1 -1
  296. package/dist/modules/corecompiler/original/json/common.js +1 -1
  297. package/dist/modules/corecompiler/original/json/game.js +1 -1
  298. package/dist/modules/corecompiler/original/json/page/checkPageJSON.js +1 -1
  299. package/dist/modules/corecompiler/original/json/page/getPageJSON.js +1 -1
  300. package/dist/modules/corecompiler/original/json/plugin/plugin.js +1 -1
  301. package/dist/modules/corecompiler/original/json/plugin/pluginPage.js +1 -1
  302. package/dist/modules/corecompiler/original/json/projectconfig.js +1 -1
  303. package/dist/modules/corecompiler/original/json/reactiveCache.js +1 -1
  304. package/dist/modules/corecompiler/original/json/signaturejson.js +1 -1
  305. package/dist/modules/corecompiler/original/json/sitemap.js +1 -1
  306. package/dist/modules/corecompiler/original/json/theme.js +1 -1
  307. package/dist/modules/corecompiler/original/npm/filterdeps.js +1 -1
  308. package/dist/modules/corecompiler/original/npm/packnpm.js +1 -1
  309. package/dist/modules/corecompiler/original/protect/fileFlatter.js +1 -1
  310. package/dist/modules/corecompiler/original/protect/uglifyfilenames.js +1 -1
  311. package/dist/modules/corecompiler/original/utils/logger.js +1 -1
  312. package/dist/modules/corecompiler/original/validate/schemaValidate.js +1 -1
  313. package/dist/modules/corecompiler/original/validate/validate.js +1 -1
  314. package/dist/modules/corecompiler/original/webWorker/configs.js +1 -1
  315. package/dist/modules/corecompiler/original/workerThread/childprocess.js +1 -1
  316. package/dist/modules/corecompiler/original/workerThread/childprocessManager.js +1 -1
  317. package/dist/modules/corecompiler/original/workerThread/config.js +1 -1
  318. package/dist/modules/corecompiler/original/workerThread/fork.js +1 -1
  319. package/dist/modules/corecompiler/original/workerThread/getWorkerPoolSize.js +1 -1
  320. package/dist/modules/corecompiler/original/workerThread/index.js +1 -1
  321. package/dist/modules/corecompiler/original/workerThread/task/call_func.js +1 -1
  322. package/dist/modules/corecompiler/original/workerThread/task/compilejs.js +1 -1
  323. package/dist/modules/corecompiler/original/workerThread/task/compilewxss.js +1 -1
  324. package/dist/modules/corecompiler/original/workerThread/task/func.js +1 -1
  325. package/dist/modules/corecompiler/original/workerThread/task/index.js +1 -1
  326. package/dist/modules/corecompiler/original/workerThread/task/minifywxml.js +1 -1
  327. package/dist/modules/corecompiler/original/workerThread/worker.js +1 -1
  328. package/dist/modules/corecompiler/original/workerThread/workerManager.js +1 -1
  329. package/dist/modules/corecompiler/originalCompiler.js +1 -1
  330. package/dist/modules/corecompiler/processHandler.js +1 -1
  331. package/dist/modules/corecompiler/summer/graph/appconf.js +1 -1
  332. package/dist/modules/corecompiler/summer/graph/appgraph.js +1 -1
  333. package/dist/modules/corecompiler/summer/graph/basegraph.js +1 -1
  334. package/dist/modules/corecompiler/summer/graph/gameconf.js +1 -1
  335. package/dist/modules/corecompiler/summer/graph/gamegraph.js +1 -1
  336. package/dist/modules/corecompiler/summer/graph/gamepluginconf.js +1 -1
  337. package/dist/modules/corecompiler/summer/graph/gameplugingraph.js +1 -1
  338. package/dist/modules/corecompiler/summer/graph/pluginconf.js +1 -1
  339. package/dist/modules/corecompiler/summer/graph/plugingraph.js +1 -1
  340. package/dist/modules/corecompiler/summer/graph/util.js +1 -1
  341. package/dist/modules/corecompiler/summer/index.js +1 -1
  342. package/dist/modules/corecompiler/summer/initPlugin.js +1 -1
  343. package/dist/modules/corecompiler/summer/module.js +1 -1
  344. package/dist/modules/corecompiler/summer/persistCache.js +1 -1
  345. package/dist/modules/corecompiler/summer/pipeManager/index.js +1 -0
  346. package/dist/modules/corecompiler/summer/pipeManager/pipeCPProject.js +1 -0
  347. package/dist/modules/corecompiler/summer/pipeManager/pipeContext.js +1 -0
  348. package/dist/modules/corecompiler/summer/pipeManager/pipeManager.js +1 -0
  349. package/dist/modules/corecompiler/summer/pipeManager/pipeWorker.js +1 -0
  350. package/dist/modules/corecompiler/summer/pipeManager/pipes/appservicePipe/index.js +1 -0
  351. package/dist/modules/corecompiler/summer/pipeManager/pipes/compileWxmlToGlassEaselPipe.js +1 -0
  352. package/dist/modules/corecompiler/summer/pipeManager/pipes/compileWxssPipe.js +1 -0
  353. package/dist/modules/corecompiler/summer/pipeManager/pipes/index.js +1 -0
  354. package/dist/modules/corecompiler/summer/pipeManager/pipes/pageInitSourcePipe/index.js +1 -0
  355. package/dist/modules/corecompiler/summer/pipeManager/pipes/pageframePipe/index.js +1 -0
  356. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/appdevserver/getAppService.js +1 -0
  357. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/appdevserver/getwxappcode.js +1 -0
  358. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/appservice/getjsfile.js +1 -0
  359. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/appservice/getmainpkgsortedjsfiles.js +1 -0
  360. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/appservice/getwxappcode.js +1 -0
  361. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/common/apperrcode.config.js +1 -0
  362. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/common/tools.js +1 -0
  363. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/project/appconfig.js +1 -0
  364. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/project/appjson.js +1 -0
  365. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/project/customcomponent.js +1 -0
  366. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/project/helper/theme.js +1 -0
  367. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/project/pagejson.js +1 -0
  368. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/project/wxappcodejson.js +1 -0
  369. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/trans/transwxmltojs.js +1 -0
  370. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/trans/transwxsstojs.js +1 -0
  371. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/web/processPath.js +1 -0
  372. package/dist/modules/corecompiler/summer/pipeManager/pipes/wccPipe.js +1 -0
  373. package/dist/modules/corecompiler/summer/pipeManager/types.js +1 -0
  374. package/dist/modules/corecompiler/summer/pluginDriver.js +1 -1
  375. package/dist/modules/corecompiler/summer/pluginconfig.js +1 -1
  376. package/dist/modules/corecompiler/summer/plugins/base/es6module.js +1 -1
  377. package/dist/modules/corecompiler/summer/plugins/base/javascript.js +1 -1
  378. package/dist/modules/corecompiler/summer/plugins/base/swc.js +1 -1
  379. package/dist/modules/corecompiler/summer/plugins/base/wxss.js +1 -1
  380. package/dist/modules/corecompiler/summer/plugins/enhance.js +1 -1
  381. package/dist/modules/corecompiler/summer/plugins/filetask/script.js +1 -1
  382. package/dist/modules/corecompiler/summer/plugins/less.js +1 -1
  383. package/dist/modules/corecompiler/summer/plugins/minifywxml.js +1 -1
  384. package/dist/modules/corecompiler/summer/plugins/sass.js +1 -1
  385. package/dist/modules/corecompiler/summer/plugins/script_task/babel_script_task.js +1 -1
  386. package/dist/modules/corecompiler/summer/plugins/script_task/load_script_task.js +1 -1
  387. package/dist/modules/corecompiler/summer/plugins/script_task/minify_script_task.js +1 -1
  388. package/dist/modules/corecompiler/summer/plugins/script_task/swc_task.js +1 -1
  389. package/dist/modules/corecompiler/summer/plugins/terser.js +1 -1
  390. package/dist/modules/corecompiler/summer/plugins/typescript.js +1 -1
  391. package/dist/modules/corecompiler/summer/plugins/worklet.js +1 -1
  392. package/dist/modules/corecompiler/summer/resolver.js +1 -1
  393. package/dist/modules/corecompiler/summer/summer.js +1 -1
  394. package/dist/modules/corecompiler/summer/utils/async.js +1 -1
  395. package/dist/modules/corecompiler/summer/utils/ensureArray.js +1 -1
  396. package/dist/modules/corecompiler/summer/utils/inputsourcemap.js +1 -1
  397. package/dist/modules/corecompiler/summer/worker.js +1 -1
  398. package/dist/modules/corecompiler/summerCompiler.js +1 -1
  399. package/dist/modules/corecompiler/summerEntryProcess.js +1 -1
  400. package/dist/modules/createSummer.js +1 -1
  401. package/dist/modules/fullcompiler/app/app.js +1 -1
  402. package/dist/modules/fullcompiler/app/contactandlaunch/updateContactForSubpkg.js +1 -1
  403. package/dist/modules/fullcompiler/app/contactandlaunch/updatecontactandlaunch.js +1 -1
  404. package/dist/modules/index.js +1 -1
  405. package/dist/modules/nativecompiler/android/adb.js +1 -1
  406. package/dist/modules/nativecompiler/android/device.js +1 -1
  407. package/dist/modules/nativecompiler/android/index.js +1 -1
  408. package/dist/modules/nativecompiler/android/projectconfig.js +1 -1
  409. package/dist/modules/nativecompiler/index.js +1 -1
  410. package/dist/modules/nativecompiler/ios/buildCloud.js +1 -1
  411. package/dist/modules/nativecompiler/ios/device.js +1 -1
  412. package/dist/modules/nativecompiler/ios/index.js +1 -1
  413. package/dist/modules/nativecompiler/ios/projectconfig.js +1 -1
  414. package/dist/modules/nativecompiler/nativeEntryProcess.js +1 -1
  415. package/dist/modules/nativecompiler/processHandler.js +1 -1
  416. package/dist/modules/precompiler/conditioncompile/compiler/json.js +1 -1
  417. package/dist/modules/precompiler/conditioncompile/compiler/macro.js +1 -1
  418. package/dist/modules/precompiler/conditioncompile/index.js +1 -1
  419. package/dist/project/advance/precompileProject.js +1 -1
  420. package/dist/project/advance/reactiveProject.js +1 -1
  421. package/dist/project/baseProject.js +1 -1
  422. package/dist/project/ciProjectWithMockBuffer.js +1 -1
  423. package/dist/project/summerCPProject.js +1 -1
  424. package/dist/services/accountcard/accountcard.js +1 -0
  425. package/dist/services/accountcard/accountcardService.js +1 -0
  426. package/dist/services/app/ci/appDirService.js +1 -0
  427. package/dist/services/app/common/appDirService.devtools.js +1 -0
  428. package/dist/services/app/common/appDirService.js +1 -0
  429. package/dist/services/app/electron/appDirService.js +1 -0
  430. package/dist/services/app/node/appDirService.js +1 -0
  431. package/dist/services/app/nw/appDirService.js +1 -0
  432. package/dist/services/builder/common/builder.js +1 -0
  433. package/dist/services/builder/nw/builder.js +1 -0
  434. package/dist/services/builder/webide/builder.js +1 -0
  435. package/dist/services/common/extensions.js +1 -0
  436. package/dist/services/common/getservice.js +1 -0
  437. package/dist/services/common/librarybase.js +1 -0
  438. package/dist/services/common/vsbase.js +1 -0
  439. package/dist/services/compilewxml/common/compilewxmlService.js +1 -0
  440. package/dist/services/compilewxml/electron/compilewxmlService.js +1 -0
  441. package/dist/services/compilewxml/node/compileUtils.js +1 -0
  442. package/dist/services/compilewxml/node/compileglasseasel.js +1 -0
  443. package/dist/services/compilewxml/nw/compilewxmlService.js +1 -0
  444. package/dist/services/compilewxml/webide/compilewxmlService.js +1 -0
  445. package/dist/services/compilewxml/webide/pageFrameWasm/wcc/runWcc.js +1 -0
  446. package/dist/services/compilewxss/common/compilewxssService.js +1 -0
  447. package/dist/services/compilewxss/electron/compilewxssService.js +1 -0
  448. package/dist/services/compilewxss/node/compileUtils.js +1 -0
  449. package/dist/services/compilewxss/nw/compilewxssService.js +1 -0
  450. package/dist/services/compilewxss/webide/compilewxssService.js +1 -0
  451. package/dist/services/compilewxss/webide/pageFrameWasm/wcsc/runWcsc.js +1 -0
  452. package/dist/services/consoledisplay/common/consoledisplay.js +1 -0
  453. package/dist/services/consoledisplay/nw/consoledisplay.js +1 -0
  454. package/dist/services/fileUtilsManager/common/fileUtilsManager.js +1 -0
  455. package/dist/services/fileUtilsManager/nw/fileUtilsManager.js +1 -0
  456. package/dist/services/fs/common/fileService.js +1 -0
  457. package/dist/services/genTempFile/common/genTempFile.devtools.js +1 -0
  458. package/dist/services/genTempFile/common/genTempFile.node.js +1 -0
  459. package/dist/services/genTempFile/common/genTempFileService.js +1 -0
  460. package/dist/services/genTempFile/electron/genTempFileService.js +1 -0
  461. package/dist/services/genTempFile/node/genTempFileService.js +1 -0
  462. package/dist/services/genTempFile/nw/genTempFileService.js +1 -0
  463. package/dist/services/global/common/global.js +1 -0
  464. package/dist/services/global/nw/global.js +1 -0
  465. package/dist/services/initializeCheck/common/initializeCheck.js +1 -0
  466. package/dist/services/initializeCheck/nw/initializeCheck.js +1 -0
  467. package/dist/services/initializeCheck/webide/initializeCheck.js +1 -0
  468. package/dist/services/locales/common/locales.js +1 -0
  469. package/dist/services/locales/nw/locales.js +1 -0
  470. package/dist/services/log/common/logService.js +1 -0
  471. package/dist/services/miniappjson/common/miniappjson.js +1 -0
  472. package/dist/services/miniappjson/electron/miniappjson.js +1 -0
  473. package/dist/services/miniappjson/nw/miniappjson.js +1 -0
  474. package/dist/services/miniappjson/webide/miniappjson.js +1 -0
  475. package/dist/services/multiTaskManager/ci/multiTaskManager.js +1 -0
  476. package/dist/services/multiTaskManager/common/multiTaskManager.js +1 -0
  477. package/dist/services/multiTaskManager/electron/multiTaskManager.js +1 -0
  478. package/dist/services/multiTaskManager/webide/multiTaskManager.js +1 -0
  479. package/dist/services/nativeModule/ci/nativeModule.js +1 -0
  480. package/dist/services/nativeModule/common/nativeModule.impl.js +1 -0
  481. package/dist/services/nativeModule/common/nativeModule.js +1 -0
  482. package/dist/services/nativeModule/electron/nativeModule.js +1 -0
  483. package/dist/services/nativeModule/nw/nativeModule.js +1 -0
  484. package/dist/services/partialcompile/common/parialcompile.impl.js +1 -0
  485. package/dist/services/partialcompile/common/partialcompile.js +1 -0
  486. package/dist/services/partialcompile/nw/partialcompile.js +1 -0
  487. package/dist/services/partialcompile/webide/partialcompile.js +1 -0
  488. package/dist/services/performance/common/performance.js +1 -0
  489. package/dist/services/performance/nw/performance.js +1 -0
  490. package/dist/services/performance/webide/performance.js +1 -0
  491. package/dist/services/pluginFileReader/ci/pluginFileReader.js +1 -0
  492. package/dist/services/pluginFileReader/common/pluginFileReader.base.js +1 -0
  493. package/dist/services/pluginFileReader/common/pluginFileReader.js +1 -0
  494. package/dist/services/pluginFileReader/electron/pluginFileReader.js +1 -0
  495. package/dist/services/pluginFileReader/webide/pluginFileReader.js +1 -0
  496. package/dist/services/project/common/cloudProjectService.js +1 -0
  497. package/dist/services/project/common/createProjectService.js +1 -0
  498. package/dist/services/project/common/project.helper.js +1 -0
  499. package/dist/services/project/common/projectConfigService.js +1 -0
  500. package/dist/services/project/common/projectFileService.js +1 -0
  501. package/dist/services/project/common/projectconfigjsonutils.js +1 -0
  502. package/dist/services/project/electron-backend/projectManagerService.js +1 -0
  503. package/dist/services/project/node/createProjectService.js +1 -0
  504. package/dist/services/project/node/projectConfigService.js +1 -0
  505. package/dist/services/project/node/projectManagerService.js +1 -0
  506. package/dist/services/project/web/projectManagerService.js +1 -0
  507. package/dist/services/project/webide/projectConfigService.js +1 -0
  508. package/dist/services/project/webide/projectFileService.js +1 -0
  509. package/dist/services/project/webide/projectManagerService.js +1 -0
  510. package/dist/services/projectManager/common/buildServerProjectManager.js +1 -0
  511. package/dist/services/projectManager/common/projectManager.js +1 -0
  512. package/dist/services/projectManager/nw/projectManager.js +1 -0
  513. package/dist/services/root/ci/root.js +1 -0
  514. package/dist/services/root/ci/rootService.js +1 -0
  515. package/dist/services/root/common/createService.js +1 -0
  516. package/dist/services/root/electron/root.js +1 -0
  517. package/dist/services/root/electron/rootService.js +1 -0
  518. package/dist/services/root/nw/root.js +1 -0
  519. package/dist/services/root/nw/rootService.js +1 -0
  520. package/dist/services/root/webide/root.js +1 -0
  521. package/dist/services/root/webide/rootService.js +1 -0
  522. package/dist/services/staticConfig/common/staticConfigService.js +1 -0
  523. package/dist/services/staticConfig/nw/staticConfigService.js +1 -0
  524. package/dist/services/store/common/storeService.js +1 -0
  525. package/dist/services/uniapp/common/uniapp.js +1 -0
  526. package/dist/services/uniapp/nw/uniapp.js +1 -0
  527. package/dist/services/uniapp/webide/uniapp.js +1 -0
  528. package/dist/services/vendor/common/utils.js +1 -0
  529. package/dist/services/vendor/common/vendorService.js +1 -0
  530. package/dist/services/vendor/node/vendorService.js +1 -0
  531. package/dist/services/vendor/webide/vendorService.js +1 -0
  532. package/dist/types/ci.js +1 -1
  533. package/dist/utils/asyncTask/index.js +1 -1
  534. package/dist/utils/babel_helper.js +1 -1
  535. package/dist/utils/babel_plugin_worklet.js +1 -1
  536. package/dist/utils/cache.js +1 -1
  537. package/dist/utils/codesign.js +1 -1
  538. package/dist/utils/colorutils.js +1 -0
  539. package/dist/utils/common.js +1 -1
  540. package/dist/utils/cosUpload.js +1 -1
  541. package/dist/utils/cp.js +1 -1
  542. package/dist/utils/customError.js +1 -1
  543. package/dist/utils/debug.js +1 -1
  544. package/dist/utils/download.js +1 -1
  545. package/dist/utils/env.js +1 -1
  546. package/dist/utils/expression.js +1 -1
  547. package/dist/utils/fs.js +1 -1
  548. package/dist/utils/fsagent.js +1 -1
  549. package/dist/utils/genTempFile.js +1 -1
  550. package/dist/utils/generateIpa.js +1 -1
  551. package/dist/utils/glob.js +1 -1
  552. package/dist/utils/hackrequire/wxvpkgreader.js +1 -1
  553. package/dist/utils/helper_util.js +1 -1
  554. package/dist/utils/jsonParse.js +1 -1
  555. package/dist/utils/jsonlint.js +1 -1
  556. package/dist/utils/locales/fomatable_string.js +1 -1
  557. package/dist/utils/locales/locales.js +1 -1
  558. package/dist/utils/log.js +1 -1
  559. package/dist/utils/messageHub.js +1 -1
  560. package/dist/utils/miniAppI18N.js +1 -1
  561. package/dist/utils/miniapp-builder.js +1 -1
  562. package/dist/utils/miniappJson.js +1 -1
  563. package/dist/utils/node/common.js +1 -0
  564. package/dist/utils/officialDonutPlugin.js +1 -1
  565. package/dist/utils/packOptionsHelper.js +1 -1
  566. package/dist/utils/processBootstrap.js +1 -0
  567. package/dist/utils/progressRecorder.js +1 -1
  568. package/dist/utils/report.js +1 -1
  569. package/dist/utils/request.js +1 -1
  570. package/dist/utils/sign.js +1 -1
  571. package/dist/utils/signature.js +1 -1
  572. package/dist/utils/singletontask.js +1 -1
  573. package/dist/utils/subprocess/entryProcess.js +1 -1
  574. package/dist/utils/subprocess/processManager.js +1 -1
  575. package/dist/utils/subprocess/processService.js +1 -1
  576. package/dist/utils/subprocess/stringifyPostMsg.js +1 -1
  577. package/dist/utils/swc_helper.js +1 -1
  578. package/dist/utils/taskmanager.js +1 -1
  579. package/dist/utils/tools.js +1 -1
  580. package/dist/utils/usbProcess.js +1 -1
  581. package/dist/utils/waitable.js +1 -1
  582. package/dist/utils/web/common.js +1 -0
  583. package/dist/utils/white_ext_list.js +1 -1
  584. package/dist/utils/wxapkg/pack.js +1 -1
  585. package/dist/utils/wxvpkgreader/wxvpkg/reader/version0.js +1 -1
  586. package/dist/utils/wxvpkgreader/wxvpkg/reader/version10.js +1 -1
  587. package/dist/utils/wxvpkgreader/wxvpkg/unpack/version0.js +1 -1
  588. package/dist/utils/wxvpkgreader/wxvpkg/unpack/version10.js +1 -1
  589. package/dist/utils/wxvpkgreader/wxvpkgreader.js +1 -1
  590. package/dist/utils/zip.js +1 -1
  591. package/dist/vendor/vslibrary/bundled/base.bundled.js +2 -0
  592. package/package.json +62 -3
  593. package/dist/modules/fullcompiler/trans/wcc/build/darwin_arm64/wcc.node +0 -0
  594. package/dist/modules/fullcompiler/trans/wcc/build/darwin_arm64/wcsc.node +0 -0
  595. package/dist/modules/fullcompiler/trans/wcc/build/darwin_x64/wcc.node +0 -0
  596. package/dist/modules/fullcompiler/trans/wcc/build/darwin_x64/wcsc.node +0 -0
  597. package/dist/modules/fullcompiler/trans/wcc/build/node_16.1.0_darwin_arm64_release/wcc.node +0 -0
  598. package/dist/modules/fullcompiler/trans/wcc/build/node_16.1.0_darwin_arm64_release/wcsc.node +0 -0
  599. package/dist/modules/fullcompiler/trans/wcc/build/node_16.1.0_darwin_x64_release/wcc.node +0 -0
  600. package/dist/modules/fullcompiler/trans/wcc/build/node_16.1.0_darwin_x64_release/wcsc.node +0 -0
  601. package/dist/modules/fullcompiler/trans/wcc/build/win32_ia32/wcc.node +0 -0
  602. package/dist/modules/fullcompiler/trans/wcc/build/win32_ia32/wcsc.node +0 -0
  603. package/dist/modules/fullcompiler/trans/wcc/build/win32_x64/wcc.node +0 -0
  604. package/dist/modules/fullcompiler/trans/wcc/build/win32_x64/wcsc.node +0 -0
  605. package/dist/modules/fullcompiler/trans/wcc/lib/addonVersion.js +0 -19
  606. package/dist/modules/fullcompiler/trans/wcc/lib/index.js +0 -4
  607. package/dist/modules/fullcompiler/trans/wcc/lib/util.js +0 -1134
  608. package/dist/modules/fullcompiler/trans/wcc/lib/wcc.js +0 -94
  609. package/dist/modules/fullcompiler/trans/wcc/lib/wcsc.js +0 -93
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.tryLaunchAppOnDevice=exports.tryInstantInstall=exports.tryBuild=exports.tryInstantBuild=exports.getCPU=exports.getAvailableCPUs=exports.getDevices=exports.tryLaunchEmulator=exports.getEmulators=void 0;const tslib_1=require("tslib"),os=tslib_1.__importStar(require("os")),child_process_1=require("child_process"),env_1=require("../../../utils/env"),adb_1=require("./adb"),cp_1=require("../../../utils/cp");function getElumatorCommand(){const t=(0,env_1.getProcessEnv)();return t.ANDROID_HOME?t.ANDROID_HOME+"/emulator/emulator":"emulator"}const getEmulators=()=>{try{const t=getElumatorCommand();return(0,child_process_1.execSync)(t+" -list-avds",{env:(0,env_1.getProcessEnv)()}).toString().split(os.EOL).filter(t=>""!==t).map(t=>({name:t,type:"simulator",attach:!1}))}catch(t){return[]}};exports.getEmulators=getEmulators;const realLaunchEmulator=(t,e)=>new Promise(async(r,s)=>{var n,a;const o=getElumatorCommand();console.log(`Running command:${o} @${t}`),e.progress(`launch emulator ${t}...`);const c=await getDevices(),i=(0,child_process_1.spawn)(o,["@"+t],{detached:!0,stdio:["pipe","pipe","pipe","ipc"],env:(0,env_1.getProcessEnv)()});i.unref();let l="";null===(n=i.stdout)||void 0===n||n.on("data",t=>{e.progress(t.toString())}),null===(a=i.stderr)||void 0===a||a.on("data",t=>{const r=t.toString();l+=r,e.progress(r)});const u=setTimeout(()=>{d(),s(new Error("Could not start emulator within 30 seconds."))},3e4),p=setInterval(async()=>{const t=(await getDevices()).find(t=>c.every(e=>e.name!==t.name));t&&(d(),r(t))},1e3),d=()=>{clearTimeout(u),clearInterval(p)};i.on("exit",async()=>{if(d(),null==l?void 0:l.includes("Running multiple emulators with the same AVD")){const t=(await getDevices()).find(t=>"simulator"===t.type&&t.attach);r(t)}else s(new Error("Emulator exited before boot:"+l))}),i.on("error",t=>{d(),s(t.message)})}),tryLaunchEmulator=async(t,e)=>{if(!t){t=(0,exports.getEmulators)()[0].name}if(t)try{return{success:!0,device:await realLaunchEmulator(t,e)}}catch(t){return{success:!1,error:t.message}}return{success:!1,error:"No emulators found, please check `emulator -list-avds`"}};function parseDevicesResult(t){var e;if(!t)return[];const r=[],s=t.trim().split(/\r?\n/);for(const t of s){const s=t.split(/[ ,\t]+/).filter(t=>""!==t);"device"===s[1]&&((null===(e=s[0])||void 0===e?void 0:e.startsWith("emulator-"))?r.push({name:s[0],type:"simulator",attach:!0}):r.push({name:s[0],type:"device",attach:!0}))}return r}function getDevices(){return new Promise(t=>{const e=(0,adb_1.getAdbPath)();(0,child_process_1.exec)(`"${e}" devices -l`,{env:(0,env_1.getProcessEnv)()},(e,r)=>{const s=parseDevicesResult(r);e&&t([...(0,exports.getEmulators)()]),t([...(0,exports.getEmulators)(),...s])})})}function getAvailableCPUs(t){try{const e=(0,adb_1.getAdbPath)(),r=["-s",t,"shell","getprop"];let s=(0,child_process_1.execFileSync)(e,r.concat(["ro.product.cpu.abilist"]),{env:(0,env_1.getProcessEnv)()}).toString();return s&&0!==s.trim().length||(s=(0,child_process_1.execFileSync)(e,r.concat(["ro.product.cpu.abi"]),{env:(0,env_1.getProcessEnv)()}).toString()),(s||"").trim().split(",")}catch(t){return[]}}function getCPU(t){try{const e=(0,adb_1.getAdbPath)(),r=(0,child_process_1.execFileSync)(e,["-s",t,"shell","getprop","ro.product.cpu.abi"],{env:(0,env_1.getProcessEnv)()}).toString().trim();return r.length>0?r:null}catch(t){return null}}async function tryInstantBuild(t,e,r){const s=process.platform.startsWith("win")?"gradlew.bat":"./gradlew",n=["assemble"+e];await(0,cp_1.spawnSync)(s,n,{cwd:t.sourceDir},r)}async function tryBuild(t,e,r){const s=process.platform.startsWith("win")?"gradlew.bat":"./gradlew";await(0,cp_1.spawnSync)(s,e,{cwd:t},r)}async function tryInstantInstall(t,e,r){try{const s=process.platform.startsWith("win")?"gradlew.bat":"./gradlew",n=["install"+e];await(0,cp_1.spawnSync)(s,n,{cwd:t.sourceDir},r)}catch(t){throw createInstallError(t)}}async function tryLaunchAppOnDevice(t,e,r,s){const{mainActivity:n=""}=r;try{const r=["shell","am","start","-n",`${e}/${n}`];t?(r.unshift("-s",t),s.progress(`Starting the app on "${t}"...`)):s.progress("Starting the app...");const a=(0,adb_1.getAdbPath)();await(0,cp_1.spawnSync)(a,r,{stdio:"inherit"},s)}catch(t){throw new Error("Failed to start the app."+t.message)}}function createInstallError(t){const e=(t.stderr||"").toString();let r="Make sure you have the Android development environment set up";throw e.includes("No connected devices")?r="Make sure you have an Android emulator running or a device connected":(e.includes("licences have not been accepted")||e.includes("accept the SDK license"))&&(r="Please accept all necessary Android SDK licenses using Android SDK Manager: \n '$ANDROID_HOME/tools/bin/sdkmanager --licenses',\n "),new Error(`Failed to install the app. ${r}: ${e}.`)}exports.tryLaunchEmulator=tryLaunchEmulator,exports.getDevices=getDevices,exports.getAvailableCPUs=getAvailableCPUs,exports.getCPU=getCPU,exports.tryInstantBuild=tryInstantBuild,exports.tryBuild=tryBuild,exports.tryInstantInstall=tryInstantInstall,exports.tryLaunchAppOnDevice=tryLaunchAppOnDevice;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.tryLaunchEmulator=exports.getEmulators=void 0,exports.getDevices=getDevices,exports.getAvailableCPUs=getAvailableCPUs,exports.getCPU=getCPU,exports.tryInstantBuild=tryInstantBuild,exports.tryBuild=tryBuild,exports.tryInstantInstall=tryInstantInstall,exports.tryLaunchAppOnDevice=tryLaunchAppOnDevice;const tslib_1=require("tslib"),os=tslib_1.__importStar(require("os")),child_process_1=require("child_process"),env_1=require("../../../utils/env"),adb_1=require("./adb"),cp_1=require("../../../utils/cp");function getElumatorCommand(){const t=(0,env_1.getProcessEnv)();return t.ANDROID_HOME?`${t.ANDROID_HOME}/emulator/emulator`:"emulator"}const getEmulators=()=>{try{const t=getElumatorCommand();return(0,child_process_1.execSync)(`${t} -list-avds`,{env:(0,env_1.getProcessEnv)()}).toString().split(os.EOL).filter((t=>""!==t)).map((t=>({name:t,type:"simulator",attach:!1})))}catch(t){return[]}};exports.getEmulators=getEmulators;const realLaunchEmulator=(t,e)=>new Promise((async(r,s)=>{var n,a;const o=getElumatorCommand();console.log(`Running command:${o} @${t}`),e.progress(`launch emulator ${t}...`);const c=await getDevices(),i=(0,child_process_1.spawn)(o,[`@${t}`],{detached:!0,stdio:["pipe","pipe","pipe","ipc"],env:(0,env_1.getProcessEnv)()});i.unref();let l="";null===(n=i.stdout)||void 0===n||n.on("data",(t=>{e.progress(t.toString())})),null===(a=i.stderr)||void 0===a||a.on("data",(t=>{const r=t.toString();l+=r,e.progress(r)}));const u=setTimeout((()=>{d(),s(new Error("Could not start emulator within 30 seconds."))}),3e4),p=setInterval((async()=>{const t=(await getDevices()).find((t=>c.every((e=>e.name!==t.name))));t&&(d(),r(t))}),1e3),d=()=>{clearTimeout(u),clearInterval(p)};i.on("exit",(async()=>{if(d(),null==l?void 0:l.includes("Running multiple emulators with the same AVD")){const t=(await getDevices()).find((t=>"simulator"===t.type&&t.attach));r(t)}else s(new Error(`Emulator exited before boot:${l}`))})),i.on("error",(t=>{d(),s(t.message)}))})),tryLaunchEmulator=async(t,e)=>{if(!t){t=(0,exports.getEmulators)()[0].name}if(t)try{return{success:!0,device:await realLaunchEmulator(t,e)}}catch(t){return{success:!1,error:t.message}}return{success:!1,error:"No emulators found, please check `emulator -list-avds`"}};function parseDevicesResult(t){var e;if(!t)return[];const r=[],s=t.trim().split(/\r?\n/);for(const t of s){const s=t.split(/[ ,\t]+/).filter((t=>""!==t));"device"===s[1]&&((null===(e=s[0])||void 0===e?void 0:e.startsWith("emulator-"))?r.push({name:s[0],type:"simulator",attach:!0}):r.push({name:s[0],type:"device",attach:!0}))}return r}function getDevices(){return new Promise((t=>{const e=(0,adb_1.getAdbPath)();(0,child_process_1.exec)(`"${e}" devices -l`,{env:(0,env_1.getProcessEnv)()},((e,r)=>{const s=parseDevicesResult(r);e&&t([...(0,exports.getEmulators)()]),t([...(0,exports.getEmulators)(),...s])}))}))}function getAvailableCPUs(t){try{const e=(0,adb_1.getAdbPath)(),r=["-s",t,"shell","getprop"];let s=(0,child_process_1.execFileSync)(e,r.concat(["ro.product.cpu.abilist"]),{env:(0,env_1.getProcessEnv)()}).toString();return s&&0!==s.trim().length||(s=(0,child_process_1.execFileSync)(e,r.concat(["ro.product.cpu.abi"]),{env:(0,env_1.getProcessEnv)()}).toString()),(s||"").trim().split(",")}catch(t){return[]}}function getCPU(t){try{const e=(0,adb_1.getAdbPath)(),r=(0,child_process_1.execFileSync)(e,["-s",t,"shell","getprop","ro.product.cpu.abi"],{env:(0,env_1.getProcessEnv)()}).toString().trim();return r.length>0?r:null}catch(t){return null}}async function tryInstantBuild(t,e,r){const s=process.platform.startsWith("win")?"gradlew.bat":"./gradlew",n=[`assemble${e}`];await(0,cp_1.spawnSync)(s,n,{cwd:t.sourceDir},r)}async function tryBuild(t,e,r){const s=process.platform.startsWith("win")?"gradlew.bat":"./gradlew";await(0,cp_1.spawnSync)(s,e,{cwd:t},r)}async function tryInstantInstall(t,e,r){try{const s=process.platform.startsWith("win")?"gradlew.bat":"./gradlew",n=[`install${e}`];await(0,cp_1.spawnSync)(s,n,{cwd:t.sourceDir},r)}catch(t){throw createInstallError(t)}}async function tryLaunchAppOnDevice(t,e,r,s){const{mainActivity:n=""}=r;try{const r=["shell","am","start","-n",`${e}/${n}`];t?(r.unshift("-s",t),s.progress(`Starting the app on "${t}"...`)):s.progress("Starting the app...");const a=(0,adb_1.getAdbPath)();await(0,cp_1.spawnSync)(a,r,{stdio:"inherit"},s)}catch(t){throw new Error(`Failed to start the app.${t.message}`)}}function createInstallError(t){const e=(t.stderr||"").toString();let r="Make sure you have the Android development environment set up";throw e.includes("No connected devices")?r="Make sure you have an Android emulator running or a device connected":(e.includes("licences have not been accepted")||e.includes("accept the SDK license"))&&(r="Please accept all necessary Android SDK licenses using Android SDK Manager: \n '$ANDROID_HOME/tools/bin/sdkmanager --licenses',\n "),new Error(`Failed to install the app. ${r}: ${e}.`)}exports.tryLaunchEmulator=tryLaunchEmulator;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AndroidUtils=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),deviceUtils=tslib_1.__importStar(require("./device")),projectconfig_1=tslib_1.__importDefault(require("./projectconfig"));class AndroidUtils{constructor(e,t={},i,r){this.root=e,this.userConfig=t,this.miniappDirPath=i,this.devtoolsVersion=r}getProjectConfig(e){const t=projectconfig_1.default.getProjectConfig(this.root,this.userConfig,e);if(!t)throw new Error("Android project not found. Are you sure this is a miniapp project?");return t}async runLocal(e,t){const i=this.getProjectConfig(t);return process.chdir(i.sourceDir),e.device?await this.runOnSpecificDevice(e,i,t):await this.runOnAllDevices(e,i,t)}async runCloud(){}async buildLocal(e,t){t.progress("start build apk...");const i=this.getProjectConfig(t),{sourceDir:r,appName:s}=i,o=`${r}/${s}/build/outputs/apk`;return fs_extra_1.default.ensureDirSync(o),fs_extra_1.default.emptyDirSync(o),process.chdir(i.sourceDir),await deviceUtils.tryInstantBuild(i,e.variant,t),console.log("build apk successfully"),o}async buildCloud(){}async runOnAllDevices(e,t,i){let r=await deviceUtils.getDevices();if(0===r.length){i.progress("Launching emulator...");const e=await deviceUtils.tryLaunchEmulator(null,i);if(!e.success)throw new Error(`Failed to launch emulator. Reason: ${e.error}.`);i.progress("Successfully launched emulator."),r=await deviceUtils.getDevices()}else i.progress("Get Devices:"+r.join(","));await deviceUtils.tryInstantBuild(t,e.variant,i),await deviceUtils.tryInstantInstall(t,e.variant,i),(r.length>0?r:[]).forEach(r=>{deviceUtils.tryLaunchAppOnDevice(r.name,t.packageName,e,i)})}async runOnSpecificDevice(e,t,i){const{variant:r}=e;let{device:s}=e;const o=await deviceUtils.getDevices();if(!(o.length>0&&s))throw new Error("No Android device or emulator connected.");{const a=o.find(e=>e.name===s);if(!a)throw new Error(`Could not find device with the id: "${s}". Please choose one of the following:${o.join(",")}`);if("simulator"===a.type&&!a.attach){const e=await deviceUtils.tryLaunchEmulator(s,i);if(!e.success)throw new Error(e.error);s=e.device.name}await deviceUtils.tryInstantBuild(t,r,i),await deviceUtils.tryInstantInstall(t,r,i),deviceUtils.tryLaunchAppOnDevice(s,t.packageName,e,i)}}async buildPlugin(e,t){t.progress("start build android native plugin..."),t.progress("projectPath: "+e.projectPath);let i=this.root;!path_1.default.isAbsolute(i)&&e.projectPath&&(i=path_1.default.posix.join(e.projectPath,i)),t.progress("sourceDir: "+i);const r=i+"/localAar";fs_extra_1.default.ensureDirSync(r),fs_extra_1.default.emptyDirSync(r),process.chdir(i);const s=e.gradleArgs||[":plugin:build"];return await deviceUtils.tryBuild(i,s,t),console.log("build plugin successfully"),r}}exports.AndroidUtils=AndroidUtils;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AndroidUtils=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),deviceUtils=tslib_1.__importStar(require("./device")),projectconfig_1=tslib_1.__importDefault(require("./projectconfig"));class AndroidUtils{constructor(e,t={},i,r){this.root=e,this.userConfig=t,this.miniappDirPath=i,this.devtoolsVersion=r}getProjectConfig(e){const t=projectconfig_1.default.getProjectConfig(this.root,this.userConfig,e);if(!t)throw new Error("Android project not found. Are you sure this is a miniapp project?");return t}async runLocal(e,t){const i=this.getProjectConfig(t);return process.chdir(i.sourceDir),e.device?await this.runOnSpecificDevice(e,i,t):await this.runOnAllDevices(e,i,t)}async runCloud(){}async buildLocal(e,t){t.progress("start build apk...");const i=this.getProjectConfig(t),{sourceDir:r,appName:s}=i,o=`${r}/${s}/build/outputs/apk`;return fs_extra_1.default.ensureDirSync(o),fs_extra_1.default.emptyDirSync(o),process.chdir(i.sourceDir),await deviceUtils.tryInstantBuild(i,e.variant,t),console.log("build apk successfully"),o}async buildCloud(){}async runOnAllDevices(e,t,i){let r=await deviceUtils.getDevices();if(0===r.length){i.progress("Launching emulator...");const e=await deviceUtils.tryLaunchEmulator(null,i);if(!e.success)throw new Error(`Failed to launch emulator. Reason: ${e.error}.`);i.progress("Successfully launched emulator."),r=await deviceUtils.getDevices()}else i.progress(`Get Devices:${r.join(",")}`);await deviceUtils.tryInstantBuild(t,e.variant,i),await deviceUtils.tryInstantInstall(t,e.variant,i),(r.length>0?r:[]).forEach((r=>{deviceUtils.tryLaunchAppOnDevice(r.name,t.packageName,e,i)}))}async runOnSpecificDevice(e,t,i){const{variant:r}=e;let{device:s}=e;const o=await deviceUtils.getDevices();if(!(o.length>0&&s))throw new Error("No Android device or emulator connected.");{const a=o.find((e=>e.name===s));if(!a)throw new Error(`Could not find device with the id: "${s}". Please choose one of the following:${o.join(",")}`);if("simulator"===a.type&&!a.attach){const e=await deviceUtils.tryLaunchEmulator(s,i);if(!e.success)throw new Error(e.error);s=e.device.name}await deviceUtils.tryInstantBuild(t,r,i),await deviceUtils.tryInstantInstall(t,r,i),deviceUtils.tryLaunchAppOnDevice(s,t.packageName,e,i)}}async buildPlugin(e,t){t.progress("start build android native plugin..."),t.progress(`projectPath: ${e.projectPath}`);let i=this.root;!path_1.default.isAbsolute(i)&&e.projectPath&&(i=path_1.default.posix.join(e.projectPath,i)),t.progress(`sourceDir: ${i}`);const r=`${i}/localAar`;fs_extra_1.default.ensureDirSync(r),fs_extra_1.default.emptyDirSync(r),process.chdir(i);const s=e.gradleArgs||[":plugin:build"];return await deviceUtils.tryBuild(i,s,t),console.log("build plugin successfully"),r}}exports.AndroidUtils=AndroidUtils;
@@ -1 +1 @@
1
- "use strict";const tslib_1=require("tslib"),fs=tslib_1.__importStar(require("fs")),path=tslib_1.__importStar(require("path")),glob=tslib_1.__importStar(require("glob"));class ProjectConfigUtils{getProjectConfig(e,a={},t){const i=e,n=this.getAppName(i,a.appName),r=a.manifestPath?path.join(i,a.manifestPath):this.findManifest(path.join(i,n));if(!r)return null;const o=a.packageName||this.getPackageName(r,t);if(!o)throw new Error("Package name not found in "+r);return{sourceDir:i,appName:n,packageName:o}}findManifest(e){const a=glob.sync(path.join("**","AndroidManifest.xml"),{cwd:e,ignore:["node_modules/**","**/build/**","**/debug/**","Examples/**","examples/**"]})[0];return a?path.join(e,a):null}getPackageName(e,a){const t=fs.readFileSync(e,"utf8").match(/package="(.+?)"/);if(!t||0===t.length)throw new Error("Failed to build the app: No package name found. Found errors in "+e);const i=t[1];return this.validatePackageName(i)||a.progress(`Invalid application's package name "${i}" in 'AndroidManifest.xml'. Read guidelines for setting the package name here: https://developer.android.com/studio/build/application-id`),i}validatePackageName(e){return/^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)+$/.test(e)}getAppName(e,a){let t="";return"string"==typeof a&&fs.existsSync(path.join(e,a))?t=a:fs.existsSync(path.join(e,"app"))&&(t="app"),t}}module.exports=new ProjectConfigUtils;
1
+ "use strict";const tslib_1=require("tslib"),fs=tslib_1.__importStar(require("fs")),path=tslib_1.__importStar(require("path")),glob=tslib_1.__importStar(require("glob"));class ProjectConfigUtils{getProjectConfig(e,a={},t){const i=e,n=this.getAppName(i,a.appName),r=a.manifestPath?path.join(i,a.manifestPath):this.findManifest(path.join(i,n));if(!r)return null;const o=a.packageName||this.getPackageName(r,t);if(!o)throw new Error(`Package name not found in ${r}`);return{sourceDir:i,appName:n,packageName:o}}findManifest(e){const a=glob.sync(path.join("**","AndroidManifest.xml"),{cwd:e,ignore:["node_modules/**","**/build/**","**/debug/**","Examples/**","examples/**"]})[0];return a?path.join(e,a):null}getPackageName(e,a){const t=fs.readFileSync(e,"utf8").match(/package="(.+?)"/);if(!t||0===t.length)throw new Error(`Failed to build the app: No package name found. Found errors in ${e}`);const i=t[1];return this.validatePackageName(i)||a.progress(`Invalid application's package name "${i}" in 'AndroidManifest.xml'. Read guidelines for setting the package name here: https://developer.android.com/studio/build/application-id`),i}validatePackageName(e){return/^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)+$/.test(e)}getAppName(e,a){let t="";return"string"==typeof a&&fs.existsSync(path.join(e,a))?t=a:fs.existsSync(path.join(e,"app"))&&(t="app"),t}}module.exports=new ProjectConfigUtils;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NativeCompiler=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),define_1=require("../../config/define"),processManager_1=require("../../utils/subprocess/processManager"),messageHub_1=require("../../utils/messageHub"),singletontask_1=require("../../utils/singletontask");class NativeCompiler{constructor(s){this.initedPromise=null,this.onProgressUpdate=(s,e,i)=>{this.messageHub.showBuildLog(""+s,e,i)},this.messageHub=new messageHub_1.MessageHub(s.devtoolMessagehub),this.project=s.project,this.miniappDirPath=s.miniappDirPath,this.devtoolsVersion=s.devtoolsVersion}async ready(){return this._checkReadyTask||(this._checkReadyTask=new singletontask_1.SingletonTask(this.init.bind(this))),await this._checkReadyTask.getResult()}async init(){return this.initedPromise||(this.initedPromise=(async()=>{await this.createSubProcessManager()})()),this.initedPromise}async createSubProcessManager(){const s=path_1.default.posix.join(__dirname,"./nativeEntryProcess.js");this.subProcessManager=new processManager_1.SubProcessProxy(this.project,s,{miniappDirPath:this.miniappDirPath,devtoolsVersion:this.devtoolsVersion},{},8892)}async runAndroid(s){const e=define_1.PLATFORM["mini-android"];return await this.subProcessManager.runTask("runNative",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}async runIOS(s){const e=define_1.PLATFORM["mini-ios"];return await this.subProcessManager.runTask("runNative",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}async buildAndroidAPK(s){const e=define_1.PLATFORM["mini-android"];return await this.subProcessManager.runTask("buildNative",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}async buildIOSIPA(s){const e=define_1.PLATFORM["mini-ios"];return await this.subProcessManager.runTask("buildNative",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}async codesignIpa(s){const e=define_1.PLATFORM["mini-ios"];return await this.subProcessManager.runTask("codesignIOSApp",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}async buildAndroidPlugin(s){const e=define_1.PLATFORM["mini-android"];return await this.subProcessManager.runTask("buildNativePlugin",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}async buildIOSPlugin(s){const e=define_1.PLATFORM["mini-ios"];return await this.subProcessManager.runTask("buildNativePlugin",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}async packIOSCloudBuildMaterial(s){const e=define_1.PLATFORM["mini-ios"];return await this.subProcessManager.runTask("packIOSCloudBuildMaterial",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}async initUSBConnectionProcess(){const s=define_1.PLATFORM["mini-ios"];return await this.subProcessManager.runTask("initUSBConnectionProcess",{targetPlatform:s,fullEnv:global.fullEnv},this.onProgressUpdate)}destroy(){this.subProcessManager.destroy()}}exports.NativeCompiler=NativeCompiler;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NativeCompiler=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),define_1=require("../../config/define"),processManager_1=require("../../utils/subprocess/processManager"),messageHub_1=require("../../utils/messageHub"),singletontask_1=require("../../utils/singletontask");class NativeCompiler{constructor(s){this.initedPromise=null,this.onProgressUpdate=(s,e,i)=>{this.messageHub.showBuildLog(`${s}`,e,i)},this.messageHub=new messageHub_1.MessageHub(s.devtoolMessagehub),this.project=s.project,this.miniappDirPath=s.miniappDirPath,this.devtoolsVersion=s.devtoolsVersion}async ready(){return this._checkReadyTask||(this._checkReadyTask=new singletontask_1.SingletonTask(this.init.bind(this))),await this._checkReadyTask.getResult()}async init(){return this.initedPromise||(this.initedPromise=(async()=>{await this.createSubProcessManager()})()),this.initedPromise}async createSubProcessManager(){const s=path_1.default.posix.join(__dirname,"./nativeEntryProcess.js");this.subProcessManager=new processManager_1.SubProcessProxy(this.project,s,{miniappDirPath:this.miniappDirPath,devtoolsVersion:this.devtoolsVersion},{},8892)}async runAndroid(s){const e=define_1.PLATFORM["mini-android"];return await this.subProcessManager.runTask("runNative",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}async runIOS(s){const e=define_1.PLATFORM["mini-ios"];return await this.subProcessManager.runTask("runNative",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}async buildAndroidAPK(s){const e=define_1.PLATFORM["mini-android"];return await this.subProcessManager.runTask("buildNative",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}async buildIOSIPA(s){const e=define_1.PLATFORM["mini-ios"];return await this.subProcessManager.runTask("buildNative",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}async codesignIpa(s){const e=define_1.PLATFORM["mini-ios"];return await this.subProcessManager.runTask("codesignIOSApp",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}async buildAndroidPlugin(s){const e=define_1.PLATFORM["mini-android"];return await this.subProcessManager.runTask("buildNativePlugin",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}async buildIOSPlugin(s){const e=define_1.PLATFORM["mini-ios"];return await this.subProcessManager.runTask("buildNativePlugin",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}async packIOSCloudBuildMaterial(s){const e=define_1.PLATFORM["mini-ios"];return await this.subProcessManager.runTask("packIOSCloudBuildMaterial",{targetPlatform:e,opts:s,fullEnv:global.fullEnv},this.onProgressUpdate)}async initUSBConnectionProcess(){const s=define_1.PLATFORM["mini-ios"];return await this.subProcessManager.runTask("initUSBConnectionProcess",{targetPlatform:s,fullEnv:global.fullEnv},this.onProgressUpdate)}destroy(){this.subProcessManager.destroy()}}exports.NativeCompiler=NativeCompiler;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.remoteBuildProjectMaterialAbsoluteCacheDir=void 0;const tslib_1=require("tslib"),child_process=tslib_1.__importStar(require("child_process")),path_1=tslib_1.__importDefault(require("path")),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),glob_1=tslib_1.__importDefault(require("glob")),env_1=require("../../../utils/env"),miniapp_builder_1=require("../../../utils/miniapp-builder"),codesign_1=require("../../../utils/codesign"),miniappJson_1=require("../../../utils/miniappJson"),lodash_1=require("lodash"),tools_1=require("../../../utils/tools"),uuidv4=require("uuid/v4"),sizeOf=require("image-size"),plist=require("simple-plist"),errorIOSSdkVersions=["1.0.19"],APPEX_PROFILES_MAPS_FILE="__appexProfilesCacheDir__/profilesMap.json",APPEX_PROFILES_MAPS_FOR_SHELL_FILE="__appexProfilesCacheDir__/profilesMapForShell.txt",defaultIconDirPath=path_1.default.join(__dirname,"../../../static/images/"),getDepReg=e=>new RegExp(`s.subspec '${e}'.*\n(?:.*\n)*?(?:.*sp.vendored_frameworks = \\[\n)((?:.*'.*?'.*\n)*?)(?:.*\\]\n)`,"m"),allowTheme=["Light","LightSpecial","Dark","DarkSpecial","Default"];exports.remoteBuildProjectMaterialAbsoluteCacheDir="__absoluteFile";const iconInfoMap={appStore1024:{size:[1024,1024],scale:1,idiom:"ios-marketing",required:!0},appStore1024Other:{size:[1024,1024],scale:1,idiom:"ios-marketing-other"},mainIcon120:{size:[60,60],scale:2,idiom:"iphone",required:!0},mainIcon180:{size:[60,60],scale:3,idiom:"iphone"},spotlightIcon80:{size:[40,40],scale:2,idiom:"iphone"},spotlightIcon120:{size:[40,40],scale:3,idiom:"iphone"},settingsIcon58:{size:[29,29],scale:2,idiom:"iphone"},settingsIcon87:{size:[29,29],scale:3,idiom:"iphone"},notificationIcon40:{size:[20,20],scale:2,idiom:"iphone"},notificationIcon60:{size:[20,20],scale:3,idiom:"iphone"},ipadMainIcon152:{size:[76,76],scale:2,idiom:"ipad"},ipadMainIcon167:{size:[83.5,83.5],scale:2,idiom:"ipad"},ipadSpotlightIcon40:{size:[40,40],scale:1,idiom:"ipad"},ipadSpotlightIcon80:{size:[40,40],scale:2,idiom:"ipad"},ipadSettingsIcon29:{size:[29,29],scale:1,idiom:"ipad"},ipadSpotlightIcon58:{size:[29,29],scale:2,idiom:"ipad"},ipadNotificationIcon20:{size:[20,20],scale:1,idiom:"ipad"},ipadNotificationIcon40:{size:[20,20],scale:2,idiom:"ipad"}};class buildCloudManager{generateTempDemoIpaPath(e){const i=path_1.default.join(e,"../.."),t=path_1.default.basename(i),n=path_1.default.dirname(i),a=path_1.default.join(n,t+"-operateDir");fs_extra_1.default.existsSync(a)&&fs_extra_1.default.removeSync(a),fs_extra_1.default.ensureDirSync(a);const s=path_1.default.join(a,"Payload/demo.app");return fs_extra_1.default.copySync(e,s),s}generateInfoPlistCFBundleURLTypesItem(e){const i={};return e.CFBundleURLName&&(i.CFBundleURLName=e.CFBundleURLName),e.CFBundleURLSchemes&&(Array.isArray(e.CFBundleURLSchemes)?i.CFBundleURLSchemes=e.CFBundleURLSchemes:i.CFBundleURLSchemes=[e.CFBundleURLSchemes]),e.CFBundleTypeRole&&(i.CFBundleTypeRole=e.CFBundleTypeRole),i}updatePrivacyBackgroundImage(e,i,t,n,a){t.message("doing","updatePrivacyBackgroundImage "+n);if(fs_extra_1.default.readdirSync(i).forEach(e=>{"privacy_"+n===path_1.default.basename(e,path_1.default.extname(e))&&fs_extra_1.default.removeSync(path_1.default.join(i,e))}),!a)return;path_1.default.isAbsolute(a)||(a=path_1.default.join(e,a)),a=this.getMaterialFilePath(e,a);const s=path_1.default.extname(a),o=path_1.default.join(i,`privacy_${n}${s}`);try{fs_extra_1.default.copyFileSync(a,o)}catch(e){throw t.message("error",`copy privacy image failed: ${n}, ${a} to ${o}`),e}}async updateIOSInfoPlistInfo(e,i,t,n,a,s){var o,r,l,p,d,c,u,f,_,h,y,g;a.progress("update app base info...");const{mobileapp_info:m={}}=i,S=m.mobileapp_id,I=path_1.default.join(t,"Info.plist"),v={},x=(e,i)=>{var t,n;if((null==i?void 0:i.startsWith("%"))&&(null==i?void 0:i.endsWith("%"))){const o=i.slice(1,-1);v[e]=o;const r=(null===(n=null===(t=null==s?void 0:s.base)||void 0===t?void 0:t.ios)||void 0===n?void 0:n[o])||"";return r||a.message("error",`未在国际化配置 base.json 中找到字段 ${o},请检查`),r}return i};x("UISplashScreenImageName",null===(o=null==n?void 0:n.splashscreen)||void 0===o?void 0:o.customImage),x("UISplashScreenVideoName",null===(r=null==n?void 0:n.splashscreen)||void 0===r?void 0:r.customVideo),x("UILaunchStoryboardName",null===(l=null==n?void 0:n.splashscreen)||void 0===l?void 0:l.customImage);const b=plist.readFileSync(I);if(b.UIBackgroundModes=[],!0===(null===(p=null==n?void 0:n.infoPlist)||void 0===p?void 0:p.AudioInBackgroundMode)&&b.UIBackgroundModes.push("audio"),!0===(null===(d=null==n?void 0:n.infoPlist)||void 0===d?void 0:d.LocationInBackgroundMode)&&b.UIBackgroundModes.push("location"),"object"==typeof n.customInfoPlist&&!Array.isArray(n.customInfoPlist)){a.progress("initiating user custom info.plist config");const e=n.customInfoPlist;for(const i in e)b[i]=e[i]}if(b.CFBundleName=x("CFBundleName",n.name),b.CFBundleDisplayName=x("CFBundleDisplayName",n.name),b.CFBundleShortVersionString=n.version,"number"==typeof n.versionCode?b.CFBundleVersion=parseInt(n.versionCode.toString(),10).toString():b.CFBundleVersion=(parseInt(b.CFBundleVersion,10)+1).toString(),b.CFBundleIdentifier=this.getBundleIdentifier(m),Array.isArray(null==n?void 0:n.openMimeTypes)&&this.validateCFBundleDocumentTypes(n.openMimeTypes,a)&&(b.CFBundleDocumentTypes=n.openMimeTypes,a.message("doing","openMimeTypes 应用成功")),Array.isArray(b.CFBundleURLTypes)||(b.CFBundleURLTypes=[]),(null===(u=null===(c=b.CFBundleURLTypes)||void 0===c?void 0:c[0])||void 0===u?void 0:u.CFBundleURLSchemes)&&(b.CFBundleURLTypes[0].CFBundleURLSchemes=[S]),b.CFBundleURLTypes[0]&&(b.CFBundleURLTypes=[b.CFBundleURLTypes[0]]),Object.keys(miniappJson_1.iosPrivacyDescObj).forEach(e=>{var i,t;(null===(i=null==n?void 0:n.privateDescriptions)||void 0===i?void 0:i[e])?b[e]=x(e,null===(t=n.privateDescriptions)||void 0===t?void 0:t[e]):delete b[e]}),!0===(null===(f=null==n?void 0:n.infoPlist)||void 0===f?void 0:f.DisableAppUsesNonExemptEncryption)?b.ITSAppUsesNonExemptEncryption=!1:delete b.ITSAppUsesNonExemptEncryption,!0===(null===(_=null==n?void 0:n.infoPlist)||void 0===_?void 0:_.requiresFullScreen)?b.UIRequiresFullScreen=!0:delete b.UIRequiresFullScreen,"object"==typeof(null===(h=null==n?void 0:n.infoPlist)||void 0===h?void 0:h.CFBundleURLTypes)){const e=this.generateInfoPlistCFBundleURLTypesItem(n.infoPlist.CFBundleURLTypes);b.CFBundleURLTypes.push(e);const{additionalCFBundleURLTypes:i}=n.infoPlist.CFBundleURLTypes;Array.isArray(i)&&i.forEach(e=>{if("object"==typeof e){const i=this.generateInfoPlistCFBundleURLTypesItem(e);b.CFBundleURLTypes.push(i)}})}if(null===(y=null==n?void 0:n.useExtendedSdk)||void 0===y?void 0:y.WeAppGoogleLogin){if(!(null==n?void 0:n.googleLoginClientID)||!(null==n?void 0:n.googleLoginBundleUrlType))throw new Error("勾选了 Google Login 拓展模块但未填写 googleLoginClientID 或 googleLoginBundleUrlType 将导致拓展模块无法使用");b.GIDClientID=n.googleLoginClientID,Array.isArray(b.CFBundleURLTypes)?b.CFBundleURLTypes.push({CFBundleURLSchemes:[n.googleLoginBundleUrlType]}):b.CFBundleURLTypes=[{CFBundleURLSchemes:[n.googleLoginBundleUrlType]}]}if(!0===n.enableIpad)if(Array.isArray(n.iPadUISupportedInterfaceOrientations)){const e={Portrait:"UIInterfaceOrientationPortrait",PortraitUpsideDown:"UIInterfaceOrientationPortraitUpsideDown",LandscapeLeft:"UIInterfaceOrientationLandscapeLeft",LandscapeRight:"UIInterfaceOrientationLandscapeRight"},i=n.iPadUISupportedInterfaceOrientations.map(i=>e[i]).filter(e=>!!e);b["UISupportedInterfaceOrientations~ipad"]=i}else(0,miniappJson_1.iOSAppJsonIsUsingIPadResizable)(e)?(b["UISupportedInterfaceOrientations~ipad"]=["UIInterfaceOrientationPortrait","UIInterfaceOrientationPortraitUpsideDown","UIInterfaceOrientationLandscapeLeft","UIInterfaceOrientationLandscapeRight"],a.progress("ipad is support Landscape")):(b["UISupportedInterfaceOrientations~ipad"]=["UIInterfaceOrientationPortrait","UIInterfaceOrientationPortraitUpsideDown"],a.progress("ipad is not support Landscape"));if(null===(g=n.infoPlist)||void 0===g?void 0:g.LSApplicationQueriesSchemes){const e=n.infoPlist.LSApplicationQueriesSchemes.split(",");e.length&&b.LSApplicationQueriesSchemes.push(...e.filter(e=>e))}try{plist.writeFileSync(I,b)}catch(e){throw new Error("write info.plist failed!!"+e.messenge)}return await this.writeI18NInfoFile(t,s,v),b.CFBundleVersion}getBundleIdentifier(e){return e.ios_flag&&e.bundle_id||e.debug_ios_bundle_id}validateCFBundleDocumentTypes(e,i){const t=["Owner","Default"," Alternate","None"],n=["Editor","Viewer"," Shell","None"],a=new Set;for(const s of e){if(a.has(s.CFBundleTypeName))return i.message("error","openMimeTypes 应用失败,存在重复定义的 CFBundleTypeName: "+s.CFBundleTypeName),!1;if(a.add(s.CFBundleTypeName),!t.includes(s.LSHandlerRank))return i.message("error","openMimeTypes 应用失败,存在不合法的 LSHandlerRank: "+s.LSHandlerRank),!1;if(!n.includes(s.CFBundleTypeRole))return i.message("error","openMimeTypes 应用失败,存在不合法的 CFBundleTypeRole: "+s.CFBundleTypeRole),!1;if(!Array.isArray(s.LSItemContentTypes))return i.message("error","openMimeTypes 应用失败,LSItemContentTypes 类型不合法"),!1}return!0}useGDT(e){return(0,miniappJson_1.iOSMiniAppJsonIsUsingGDT)(e)}async updateIOSAppConfigPlistInfo(e,i,t,n,a,s,o,r="Dark",l){var p,d,c,u,f,_,h;o.progress("update app module info...");const{module_info:y={},cpa_info:g={},cpa_package_info:m={enable_remove_watermark:!1}}=i;if(!g.sdk_key||!g.sdk_key_secret)throw new Error("sdkKey and sdkSecret not found");const S=path_1.default.join(t,"MiniApp.bundle"),I=path_1.default.join(S,"AppConfig.plist"),v=plist.readFileSync(I);m.enable_remove_watermark?v.enableRemoveWatermark=!0:v.splashscreenTheme=r,v.miniModuleId=y.module_id,v.sdkKey=g.sdk_key,v.sdkSecret=g.sdk_key_secret;const{privacy:x={}}=n;v.privacy||(v.privacy={}),v.privacy.enable=!!x.enable,v.privacy.enableViewOnly=!!x.enableViewOnly;const b=path_1.default.posix.join(S,"configs/privacy.json"),{contentViewImage:F,cancelButtonImage:P,confirmButtonImage:j,template:B}=x;if(x.enable){let i=B||"";if(fs_extra_1.default.ensureDirSync(path_1.default.posix.join(S,"configs")),i.startsWith("%")&&i.endsWith("%")){const t=B.slice(1,-1);i=(null===(d=null===(p=null==l?void 0:l.base)||void 0===p?void 0:p.ios)||void 0===d?void 0:d[t])||"",i||o.message("error",`未在国际化配置 base.json 中找到字段 ${t},请检查`),Object.keys(l).forEach(i=>{var n,a;if("base"===i)return;let s=null===(a=null===(n=l[i])||void 0===n?void 0:n.ios)||void 0===a?void 0:a[t];if(s){s=this.getMaterialFilePath(e,s);const t=`configs/privacy-${i}.json`,n=path_1.default.posix.join(S,t);fs_extra_1.default.existsSync(s)?fs_extra_1.default.copyFileSync(s,n):o.message("error",`未找到隐私协议在国际化配置 ${i}.json 中配置的文件 ${s},请检查`)}})}i?(i=this.getMaterialFilePath(e,i),fs_extra_1.default.existsSync(i)?(fs_extra_1.default.copyFileSync(i,b),v.privacy.template="configs/privacy.json"):(o.message("error",`未找到隐私协议中配置的文件 ${i},请检查`),v.privacy.template="configs/defaultPrivacy.json")):v.privacy.template="configs/defaultPrivacy.json",!0===x.enableNativePlugin&&"string"==typeof x.nativePluginId&&x.nativePluginId.length>2&&(v.privacy.plugin={pluginId:x.nativePluginId,enable:!0})}else v.privacy.template="",fs_extra_1.default.removeSync(b);this.updatePrivacyBackgroundImage(e,t,o,"contentViewImage",F),this.updatePrivacyBackgroundImage(e,t,o,"confirmButtonImage",j),this.updatePrivacyBackgroundImage(e,t,o,"cancelButtonImage",P);const{appMenuEnable:L=!0}=n;v.appMenuEnable=L;const{enableVConsole:C="undefined"}=n;if(v.enableVConsole=C,null===(c=n.useExtendedSdk)||void 0===c?void 0:c.WeAppLive){const{weAppLiveLicenseUrl:e,weAppLiveLicenseKey:i}=n.liveInfo||{};e&&i&&(v.weAppLiveLicenseUrl=e,v.weAppLiveLicenseKey=i)}const{tpush:w}=n;let A=!1;if("object"==typeof w){const e=path_1.default.posix.join(t,"PlugIns/TPNSService.appex"),i=path_1.default.posix.join(e,"AppConfig.plist");if(this.useTpush(n)){v.TPNSAccessID=w.accessID,v.TPNSAccessKey=w.accessKey,w.clusterDomainName?v.clusterDomainName=w.clusterDomainName:delete v.clusterDomainName;const t=s?"x86_64":"arm64",n=path_1.default.join(a,`appex/${t}/TPNSService.appex`);if(!fs_extra_1.default.existsSync(n))throw new Error("can not found extendsdk: "+n);try{fs_extra_1.default.copySync(n,e),plist.writeFileSync(i,v),A=!0}catch(e){throw new Error("copy TPNSService.appex to app failed: "+e)}}}if(!A)try{const e=path_1.default.posix.join(t,"PlugIns");fs_extra_1.default.existsSync(e)?(fs_extra_1.default.removeSync(e),o.progress("removed PlugIns folder...")):o.progress("no PlugIns folder...")}catch(e){throw new Error("remove TPNSService.appex from app failed: "+e)}if(null===(u=n.useExtendedSdk)||void 0===u?void 0:u.WeAppLBS){if(!n.qmapAPIKey)throw new Error("You need to provide the Tencent Location Service API Key when using LBS SDK.");v.qmapAPIKey=n.qmapAPIKey}const{gdt:U}=n,D=this.useGDT(n);if(v.GDTAd=D?{appid:U.appid,enable:!0,SplashAd:{placementId:U.splashAd_placementId,fetchDelay:U.splashAd_fetchDelay||3,defaultEnable:null===(f=U.splashAd_defaultEnable)||void 0===f||f}}:{appid:"",enable:!1,SplashAd:{placementId:"",fetchDelay:3}},n["mini-plugin"]&&Array.isArray(n["mini-plugin"].ios)){const e=n["mini-plugin"].ios,i=e.filter(e=>!!(e.open&&e.pluginId&&e.loadWhenStart)).map(e=>e.pluginId),t=e.map(e=>e.open?{pluginId:e.pluginId,version:e.isFromLocal?"dev":e.pluginVersion}:void 0).filter(e=>e);v.plugins={loadWhenStart:i,pluginInfoList:t}}const{enableDebugLog:$=!1}=n;v.enableDebugLog=$;const{debugLogSizeLimit:E=10}=n;isNaN(Number(E))?o.message("error",`ios debugLogSizeLimit ${E} is NaN`):v.debugLogSizeLimit=Number(E);const{enableOpenUrlNavigate:O=!1}=n;v.enableOpenUrlNavigate=O;const k=path_1.default.posix.join(S,"configs/locales");if(fs_extra_1.default.ensureDirSync(k),null===(h=null===(_=null==l?void 0:l.base)||void 0===_?void 0:_.ios)||void 0===h?void 0:h.LOCALES){const i=this.getMaterialFilePath(e,l.base.ios.LOCALES);fs_extra_1.default.existsSync(i)?(fs_extra_1.default.copyFileSync(i,path_1.default.posix.join(k,"common-base.json")),o.progress("复制基础语言 locales 配置成功")):o.message("error","未找到基础语言 locales 配置文件: "+i)}Object.keys(l).forEach(i=>{var t,n;if("base"===i)return;const a=null===(n=null===(t=l[i])||void 0===t?void 0:t.ios)||void 0===n?void 0:n.LOCALES;if(a){const t=this.getMaterialFilePath(e,a);fs_extra_1.default.existsSync(t)?(fs_extra_1.default.copyFileSync(t,path_1.default.posix.join(k,`common-${i}.json`)),o.progress(`复制 ${i} 语言 locales 配置成功`)):o.message("error",`未找到 ${i} 语言 locales 配置文件: ${t}`)}}),plist.writeFileSync(I,v)}async updateIOSAppexInfoPlistInfo(e,i,t,n,a){if(this.useTpush(t)){a.progress("update appex for notification base info...");const{mobileapp_info:s={}}=e,o=path_1.default.join(i,"PlugIns/TPNSService.appex"),r=path_1.default.join(o,"Info.plist"),l=plist.readFileSync(r);l.CFBundleShortVersionString=t.version,a.progress("update appex for CFBundleVersion: "+n),l.CFBundleVersion=n;const p=s.ios_flag&&s.bundle_id||s.debug_ios_bundle_id;l.CFBundleIdentifier=t.tpush.serviceBundleId||p+".service",a.progress("update appex bundle identifier for infoPlist : "+l.CFBundleIdentifier),plist.writeFileSync(r,l)}else a.progress("not using tpush...")}updateBundleIcons(e,i,t,n,a){const s=[],o=[],r=[];for(const l in t){if(!t[l])continue;const p=this.getMaterialFilePath(e,t[l]);if(!p)return void a.message("error","getMatrialFailed: "+t[l]);const d=iconInfoMap[l];try{const e=sizeOf(p),i=d.size[0]*d.scale,n=d.size[1]*d.scale;if(e.width!==i||e.height!==n){a.progress(`check ${l} size failed, require [${i}, ${n}] but [${e.width}, ${e.height}] ingore ${t[l]} `);continue}}catch(e){a.progress(`get ${l} info failed, ingore ${t[l]}(e: ${e.message})`);continue}const c=path_1.default.extname(p),u=1===d.scale?"":`@${d.scale}x`,f=`${d.size[0]}x${d.size[1]}`,_=l.startsWith("ipad"),h="appStore1024"===l||"appStore1024Other"===l,y="appStore1024Other"===l?n+"Other":n,g=path_1.default.join(i,`${y}${f}${u}${_?"~ipad":""}${c}`),m={from:p,to:g,filename:path_1.default.basename(g),size:f,scale:d.scale+"x",idiom:d.idiom,key:l};s.push(m),h||(_?r.includes(`${y}${f}`)||r.push(`${y}${f}${u}`):o.includes(`${y}${f}`)||o.push(`${y}${f}${u}`))}return{iphoneBundleIconFiles:o,ipadBundleIconFiles:r,addFiles:s}}async updateIOSIcons(e,i,t,n,a,s,o=!1,r=""){s.progress("update app icons...");const{icons:l={}}=n,p=(o||a)&&!!t;s.progress("genAssetCar: "+p);const d=glob_1.default.sync("AppIcon*.+(png|jpg|jpeg|webp)",{nodir:!0,cwd:i}).map(e=>path_1.default.join(i,e)),c="AppIcon-"+uuidv4().slice(0,8),u=this.updateBundleIcons(e,i,l,c,s);if(!u)throw new Error("updateBundleIcons failed");const{iphoneBundleIconFiles:f=[],ipadBundleIconFiles:_=[],addFiles:h=[]}=u,y={};for(const e in iconInfoMap){if(!iconInfoMap[e].required||l[e])continue;const i=iconInfoMap[e].size[0]*iconInfoMap[e].scale,t=iconInfoMap[e].size[1]*iconInfoMap[e].scale;if(y[e]=path_1.default.join(defaultIconDirPath,`donut-icon${i}x${t}.png`),s.progress(`using default app icons when ${e} is not config...`),!fs_extra_1.default.existsSync(y[e]))throw new Error(`required ${e} but not default or set`)}const g=this.updateBundleIcons(e,i,y,c,s);if(!g)throw new Error("updateBundleIcons WithDefaultIcon failed");const{iphoneBundleIconFiles:m,ipadBundleIconFiles:S,addFiles:I}=g;if(f.push(...m),_.push(...S),h.push(...I),!f.length&&!_.length)return;d.forEach(e=>{fs_extra_1.default.existsSync(e)&&fs_extra_1.default.removeSync(e)});const v=path_1.default.join(t,"__assetCarOperateDir/assetsCar/"),x=path_1.default.join(v,`Assets.xcassets/${c}.appiconset/`);p&&(fs_extra_1.default.ensureDirSync(x),fs_extra_1.default.emptyDirSync(x));const b=[];let F=!1;if(h.forEach(e=>{fs_extra_1.default.existsSync(e.to)&&fs_extra_1.default.removeSync(e.to),fs_extra_1.default.copyFileSync(e.from,e.to),p&&(fs_extra_1.default.copySync(e.from,path_1.default.join(x,e.filename)),"ios-marketing-other"===e.idiom&&(F=!0),b.push({filename:e.filename,size:e.size,scale:e.scale,idiom:e.idiom}))}),p&&fs_extra_1.default.writeJsonSync(path_1.default.join(x,"Contents.json"),{images:b,info:{author:"xcode",version:1}},{spaces:"\t"}),p){const e=path_1.default.join(__dirname,"../../../static/scripts/assetsCar/"),t=path_1.default.join(v,"createAssetsCar");fs_extra_1.default.copySync(e,v);try{await(0,codesign_1.checkXcodeEnv)(s),child_process.execSync(`"${t}" ${c}`,{env:(0,env_1.getProcessEnv)()})}catch(e){throw new Error("createAssetsCar failed "+(e.message||""))}const n=path_1.default.join(v,"build/Assets.car"),a=path_1.default.join(i,"Assets.car");fs_extra_1.default.copyFileSync(n,a)}else if(r&&fs_extra_1.default.existsSync(r))s.message("success","命中缓存,正在使用缓存的 AssetCar"),fs_extra_1.default.copyFileSync(r,path_1.default.join(i,"Assets.car"));else{const e=path_1.default.join(i,"Assets.car");fs_extra_1.default.removeSync(e),s.message("warn","更新 App 图标可能不生效,可使用远程构建验证图标设置;工具将会缓存图标构建结果")}const P=path_1.default.join(i,"Info.plist"),j=plist.readFileSync(P);if(!j.CFBundleIcons){const e={CFBundlePrimaryIcon:{}};j.CFBundleIcons=e}F&&(j.CFBundleIcons.CFBundleAlternateIcons={OtherAppStoreIcon:{CFBundleIconFiles:[c+"Other"],CFBundleIconName:"OtherAppStoreIcon"}}),j.CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconName=c,j.CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles=f,j["CFBundleIcons~ipad"]||(j["CFBundleIcons~ipad"]={CFBundlePrimaryIcon:{}}),j["CFBundleIcons~ipad"].CFBundlePrimaryIcon.CFBundleIconName=c,j["CFBundleIcons~ipad"].CFBundlePrimaryIcon.CFBundleIconFiles=_,j.NSAppTransportSecurity={NSAllowsArbitraryLoads:!0},plist.writeFileSync(P,j)}replaceLaunchScreenImage(e,i,t,n,a,s){const o=path_1.default.join(e,"01J-lp-oVM-view-Ze5-6b-2t3.nib");let r=fs_extra_1.default.readFileSync(o).toString("hex");if(!i.endsWith(".png"))return void n.message("error","IOS 启动页图片配置格式错误,必须为 PNG 格式, 错误配置:"+i);const l=this.getMaterialFilePath(a,i),p=t+".png",d="LaunchScreen-"+uuidv4().slice(0,12),c=d+".png",u=path_1.default.join(s,c);fs_extra_1.default.copyFileSync(l,u);const f=Buffer.from(p,"utf-8").toString("hex"),_=Buffer.from(c,"utf-8").toString("hex");return-1!==r.indexOf(f)?(r=r.replace(f,_),console.log("replace storyboard customImage success")):console.log("replace storyboard customImage fail"),fs_extra_1.default.writeFileSync(o,Buffer.from(r,"hex")),d}replaceLaunchScreenVideo(e,i,t,n){const a=path_1.default.extname(e);if([".mp4",".mov"].indexOf(a)<0)return void i.message("error","IOS 启动页视频配置格式错误,必须为 mp4 mov 格式, 错误配置:"+e);const s=this.getMaterialFilePath(t,e),o=`${"LaunchScreen-"+uuidv4().slice(0,12)}${a}`,r=path_1.default.join(n,o);return fs_extra_1.default.copyFileSync(s,r),o}async updateSplashScreen(e,i,t,n,a="Dark",s){var o,r,l;let p;n.progress("update splashscreen image..."),allowTheme.includes(a)&&(p=path_1.default.join(i,`/Base.lproj/LaunchScreen${a}.storyboardc`)),p&&fs_extra_1.default.existsSync(p)&&fs_extra_1.default.copySync(p,path_1.default.join(i,"/Base.lproj/LaunchScreen.storyboardc")),allowTheme.forEach(e=>{const t=path_1.default.join(i,`/Base.lproj/LaunchScreen${e}.storyboardc`);fs_extra_1.default.existsSync(t)&&fs_extra_1.default.removeSync(t)});let d=null===(o=null==t?void 0:t.splashscreen)||void 0===o?void 0:o.customImage;if(!d)return;const c=path_1.default.join(i,"Info.plist"),u=plist.readFileSync(c),f=u.UISplashScreenImageName;if(glob_1.default.sync("LaunchScreen-*.+(png|jpg|jpeg|webp)",{nodir:!0,cwd:i}).forEach(e=>{const t=path_1.default.join(i,e);fs_extra_1.default.removeSync(t)}),d.startsWith("%")&&(null==d?void 0:d.endsWith("%"))){const t=d.slice(1,-1),a=(null===(l=null===(r=null==s?void 0:s.base)||void 0===r?void 0:r.ios)||void 0===l?void 0:l[t])||"";if(!a)return void n.message("error",`未在国际化配置 base.json 中找到字段 ${t},请检查,启动页国际化配置失败`);d=a,Object.keys(s).forEach(a=>{var o,r;if("base"===a)return;const l=null===(r=null===(o=s[a])||void 0===o?void 0:o.ios)||void 0===r?void 0:r[t];if(l){const t=path_1.default.join(i,`/${a}.lproj/LaunchScreen_${a}.storyboardc`);fs_extra_1.default.ensureDirSync(path_1.default.join(t,"..")),fs_extra_1.default.copySync(path_1.default.join(i,"/Base.lproj/LaunchScreen.storyboardc"),t);const s=this.replaceLaunchScreenImage(t,this.getMaterialFilePath(e,l),f,n,e,i);n.progress(`update ${a} splashscreen image...`);const o=fs_extra_1.default.readFileSync(path_1.default.join(i,a+".lproj/InfoPlist.strings"),"utf8");let r="";r=s?o.replace("__UISplashScreenImageName__",`UISplashScreenImageName = "${s}";\n`).replace("__UILaunchStoryboardName__",`UILaunchStoryboardName = "LaunchScreen_${a}";\n`):o.replace("__UISplashScreenImageName__","").replace("__UILaunchStoryboardName__",""),fs_extra_1.default.writeFileSync(path_1.default.join(i,a+".lproj/InfoPlist.strings"),r),n.progress(`update ${a} splashscreen image success`)}})}n.progress("update base splashscreen image...");const _=this.replaceLaunchScreenImage(path_1.default.join(i,"/Base.lproj/LaunchScreen.storyboardc"),this.getMaterialFilePath(e,d),f,n,e,i);n.progress("update base splashscreen image success"),_&&(u.UISplashScreenImageName=_,u.UILaunchStoryboardName="LaunchScreen",plist.writeFileSync(c,u))}async updateSplashScreenVideo(e,i,t,n,a){var s,o,r;n.progress("update splashscreen video...");let l=null===(s=null==t?void 0:t.splashscreen)||void 0===s?void 0:s.customVideo;if(!l)return;const p=path_1.default.join(i,"Info.plist"),d=plist.readFileSync(p);if(l.startsWith("%")&&(null==l?void 0:l.endsWith("%"))){const t=l.slice(1,-1),s=(null===(r=null===(o=null==a?void 0:a.base)||void 0===o?void 0:o.ios)||void 0===r?void 0:r[t])||"";if(!s)return void n.message("error",`未在国际化配置 base.json 中找到字段 ${t},请检查,启动页视频国际化配置失败`);l=s,Object.keys(a).forEach(s=>{var o,r;if("base"===s)return;const l=null===(r=null===(o=a[s])||void 0===o?void 0:o.ios)||void 0===r?void 0:r[t];if(l){const t=this.replaceLaunchScreenVideo(this.getMaterialFilePath(e,l),n,e,i);n.progress(`update ${s} splashscreen video...`);const a=fs_extra_1.default.readFileSync(path_1.default.join(i,s+".lproj/InfoPlist.strings"),"utf8");let o="";o=t?a.replace("__UISplashScreenVideoName__",`UISplashScreenVideoName = "${t}";\n`):a.replace("__UISplashScreenVideoName__",""),fs_extra_1.default.writeFileSync(path_1.default.join(i,s+".lproj/InfoPlist.strings"),o),n.progress(`update ${s} splashscreen video success`)}})}n.progress("update base splashscreen video...");const c=this.replaceLaunchScreenVideo(this.getMaterialFilePath(e,l),n,e,i);n.progress("update base splashscreen video success"),c&&(d.UISplashScreenVideoName=c,plist.writeFileSync(p,d))}genUseExtendedSdk(e,i){const t=Object.assign({},e.useExtendedSdk||{});for(const i in e)if("object"==typeof e[i])for(const n in e[i])if(n.startsWith("useExtendedLib_WeApp")&&!0===e[i][n]){t[n.slice("useExtendedLib_".length)]=!0}return!t.WeAppLBS||t.WeAppOpenFuns||t.WeAppOpenFuns_HasPay||(t.WeAppOpenFuns=!0),"RemoteDebug"===(null==i?void 0:i.debugType)&&(t.WeAppUSB=!0),t}async updateExtendedSdk(e,i,t,n,a,s,o){const r=path_1.default.join(i,"Frameworks");fs_extra_1.default.ensureDirSync(r),o.progress("update extendsdk...");const l=path_1.default.join(t,"WeAppSDK.podspec"),p=fs_extra_1.default.readFileSync(l,"utf-8"),d=this.genUseExtendedSdk(a,s);o.progress("useExtendedSdks: "+JSON.stringify(d));const{mobileapp_info:c={}}=e,u=this.getBundleIdentifier(c);if(d.WeAppOpenFuns&&d.WeAppOpenFuns_HasPay)throw new Error("OpenFuncs SDK 只可勾选使用一个,请按需勾选使用");const f={},_=["WeAppUSB"];for(const e in d){if(!d[e])continue;const i=getDepReg(e),a=p.match(i);if(!(null==a?void 0:a[1])){if(_.includes(e))continue;throw new Error(`拓展模块 ${e} 不存在或已被移除,请检查 project.miniapp.json -> 对应平台 -> useExtendedSdk 删除配置 ${e},版本配置差异请参考更新日志或 https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/miniapp/changelog/difflog.html`)}const s=[];if(a[1].split("\n").forEach(e=>{const i=e.match(/.*'(.*?)',/);if(null==i?void 0:i[1]){const e=i[1].split("/").pop(),a=path_1.default.join(t,"Libs",n,e);if(!fs_extra_1.default.existsSync(a)){if(_.includes(e+".framework"))return;throw new Error(`拓展模块 ${e} 不存在或已被移除,请检查 project.miniapp.json -> 对应平台 -> useExtendedSdk 删除配置 ${e},版本配置差异请参考更新日志或 https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/miniapp/changelog/difflog.html`)}const o=path_1.default.join(r,e);fs_extra_1.default.copySync(a,o),s.push(path_1.default.basename(e));const l=path_1.default.join(o,"info.plist");if(!fs_extra_1.default.existsSync(l))throw new Error("can not found extendsdk info.plist: "+e);this.changeExtendSDKInfoplistBundleId(l,u,e)}}),s.length){f[s.shift()]=s}}const h=path_1.default.join(i,"DyFrameworks.plist");fs_extra_1.default.existsSync(h)&&fs_extra_1.default.removeSync(h),plist.writeFileSync(h,f)}async updatePrivacyInfo(e,i,t){var n;const a=null===(n=null==i?void 0:i.privacy)||void 0===n?void 0:n.privacyInfo;a&&(a.endsWith("PrivacyInfo.xcprivacy")?fs_extra_1.default.existsSync(a)?(fs_extra_1.default.copySync(a,path_1.default.join(e,"/PrivacyInfo.xcprivacy")),t.progress("隐私清单文件替换成功")):t.message("error","隐私清单文件替换失败,文件不存在,将使用默认文件"):t.message("error","隐私清单文件替换失败,文件名必须为 PrivacyInfo.xcprivacy,将使用默认文件"))}async updatePlugin(e,i,t,n,a,s,o,r){const l={},p={},d=[];if(n["mini-plugin"]&&Array.isArray(n["mini-plugin"].ios)){n["mini-plugin"].ios.forEach(e=>{e.open&&e.pluginId?("string"==typeof e.resourcePath&&e.resourcePath.length>0&&(l[e.pluginId]=e.resourcePath),"object"==typeof e.resourceObjects&&Object.keys(e.resourceObjects).length>0&&(p[e.pluginId]=e.resourceObjects)):d.push(e.pluginId)})}if(d.length>0&&r.message("warn","下列插件未启用,请确认project.miniapp.json中的配置:"+d.join(", ")),!i.length)return;const c=path_1.default.join(e,"Frameworks"),u=path_1.default.join(e,"PlugIns");fs_extra_1.default.ensureDirSync(c),r.progress("update plugin...");const f=this.prepareAppexProfileConfig(i,n,t,a,s,o,n.version,r);if(!f)throw new Error("依赖的多端插件需要配置对应的profile");i.forEach(i=>{const{pluginId:n}=i,a=i.dir,s=n+".framework",o=path_1.default.join(c,s);if(-1!==a.indexOf("local-miniapp-plugin")){const e=fs_extra_1.default.statSync(a),{mtime:i}=e;r.progress(`${n}.framework 正在使用本地版本,修改时间为 ${i}`)}fs_extra_1.default.existsSync(o)&&fs_extra_1.default.removeSync(o);const d=path_1.default.join(a,s);if(fs_extra_1.default.existsSync(d)){fs_extra_1.default.copySync(d,o),this.copyResourcesToMainBundle(d,e),this.copyUserResourcePathIntoPlugins(n,t,l[n],p[n],path_1.default.join(o,"MiniPlugin.bundle"),r);fs_extra_1.default.readdirSync(a).forEach(i=>{if(i.endsWith(".appex")){const s=path_1.default.parse(i).name,o=f[s],d=path_1.default.join(u,i);if(!o||!0!==o.enable)return;r.progress(`${n} 插件使用 appex 中 : ${i}`),fs_extra_1.default.existsSync(d)&&fs_extra_1.default.removeSync(d),fs_extra_1.default.ensureDirSync(d);const c=path_1.default.join(a,i);fs_extra_1.default.copySync(c,d),(null==o?void 0:o.profilePath)&&fs_extra_1.default.copySync(o.profilePath,path_1.default.join(d,"embedded.mobileprovision")),this.copyResourcesToMainBundle(c,e),this.copyUserResourcePathIntoPlugins(n,t,l[n],p[n],path_1.default.join(d,"MiniPlugin.bundle"),r)}else if(i.endsWith("framework")&&i!==s){const e=path_1.default.join(c,i),t=path_1.default.join(a,i);fs_extra_1.default.existsSync(e)&&fs_extra_1.default.removeSync(e),fs_extra_1.default.copySync(t,e)}})}else fs_extra_1.default.copySync(a,o),this.copyResourcesToMainBundle(a,e),this.copyUserResourcePathIntoPlugins(n,t,l[n],p[n],path_1.default.join(o,"MiniPlugin.bundle"),r)})}copyUserResourcePathIntoPlugins(e,i,t,n,a,s){const o=a;if(t){const n=path_1.default.basename(t),a=this.getMaterialFilePath(i,t);if(a){s.progress(`${e}.framework 正在拷贝配置的资源:${t}`);const i=fs_extra_1.default.lstatSync(a);fs_extra_1.default.ensureDirSync(o),i.isDirectory()?fs_extra_1.default.copySync(a,o):i.isFile()&&fs_extra_1.default.copyFileSync(a,path_1.default.join(o,n))}}if(n){s.progress(e+".framework 正在写入配置的资源"),fs_extra_1.default.ensureDirSync(o);for(const e in n){const i=n[e],t=path_1.default.join(o,e);fs_extra_1.default.ensureDirSync(o),fs_extra_1.default.ensureFileSync(t),fs_extra_1.default.writeFileSync(t,i)}}}copyResourcesToMainBundle(e,i){const t=path_1.default.join(e,"MiniPlugin.bundle"),n=path_1.default.join(t,"PluginConfig.plist");if(fs_extra_1.default.existsSync(n)){const e=plist.readFileSync(n).CopyResourcesToMainBundle;(null==e?void 0:e.length)&&e.forEach(e=>{const n=path_1.default.join(t,e);fs_extra_1.default.existsSync(n)&&fs_extra_1.default.copySync(n,path_1.default.join(i,e))})}}prepareAppexProfileConfig(e,i,t,n,a,s,o,r){if(!n)return void r.message("doing","miniappCacheDirPath is missing");let l=!1;const p={};if(i["mini-plugin"]&&Array.isArray(i["mini-plugin"].ios)){i["mini-plugin"].ios.forEach(e=>{if(e.open&&e.pluginId&&"object"==typeof e.appexProfiles)for(const i in e.appexProfiles){r.message("doing",`检查插件 ${e.pluginId} ${i} appex 配置中 ...`);const n=e.appexProfiles[i];if(!0===n.enable){const s=`${e.pluginId}_${i}`;p[s]={enable:!0};let o=n.profilePath;if(a&&(o=n.distributeProfilePath),n.bundleID&&o){const a=path_1.default.join(t,o);fs_extra_1.default.existsSync(a)?(p[s].bundleID=n.bundleID,p[s].profilePath=path_1.default.join(t,o)):(l=!0,r.message("error",`${e.pluginId} 中 ${i} 的 profilePath 无法找到对应的文件:${a}(需要在小程序项目路径下,填入相对于项目根目录的路径)`))}else l=!0,r.message("error",`${e.pluginId}中${i} 是 无效的appexProfiles配置。需要配置 bundleID,profilePath,distributeProfilePath。profile 文件需要放置在小程序项目内,然后配置相对于小程序项目根目录的相对路径。分发证书构建的情况下, 一定需要配置distributeProfilePath。查看文档了解详情。`)}}})}if(e.forEach(e=>{fs_extra_1.default.readdirSync(e.dir).forEach(i=>{if(i.endsWith(".appex")){const t=path_1.default.parse(i).name,n=p[t];if(n&&!0===n.enable)if(n.bundleID&&n.profilePath){if(n.bundleID&&n.profilePath){const t=path_1.default.join(e.dir,i,"info.plist"),a=n.bundleID;this.changeInfoplistBundleId(t,a),this.changeInfoplistBundleVersion(t,s,o),r.message("doing",`${e.pluginId} ${i} ${a} ${t} 处理 appex bundle ID 中`)}}else l=!0,r.message("error",`${e.pluginId} 的 多端插件包含了${t.slice(e.pluginId.length+1)} 的 appex。开发者需要在project.miniapp.json 中 mini-plugin 配置下对应合理的 profile 文件。查看文档了解详情。`)}})}),l)return!1;if(!(0,lodash_1.isEmpty)(p)){const e=path_1.default.join(n,APPEX_PROFILES_MAPS_FILE);fs_extra_1.default.existsSync(e)&&fs_extra_1.default.removeSync(e),fs_extra_1.default.ensureFileSync(e);const i={};for(const e in p)i[e]={bundleID:p[e].bundleID,profilePath:p[e].profilePath};fs_extra_1.default.writeFileSync(e,JSON.stringify(i));const t=path_1.default.join(n,APPEX_PROFILES_MAPS_FOR_SHELL_FILE);fs_extra_1.default.existsSync(t)&&fs_extra_1.default.removeSync(t),fs_extra_1.default.ensureFileSync(t);const a=Object.keys(p).map(e=>{const i=p[e];return`pluginAppexName:${e};_;_;bundleID:${i.bundleID};_;_;profile:${i.profilePath}\n\n`}).join("");fs_extra_1.default.writeFileSync(t,a)}return p}changeExtendSDKInfoplistBundleId(e,i,t){const n=`${i}.${path_1.default.parse(t).name.replace(/_/g,"")}`;return this.changeInfoplistBundleId(e,n)}changeInfoplistBundleId(e,i){const t=plist.readFileSync(e);return t.CFBundleIdentifier=i,plist.writeFileSync(e,t),t.CFBundleIdentifier}changeInfoplistBundleVersion(e,i,t){const n=plist.readFileSync(e);return n.CFBundleVersion=i,n.CFBundleShortVersionString=t,plist.writeFileSync(e,n),n.CFBundleIdentifier}async getEntitlements(e,i,t,n){const{mobileapp_info:a={}}=e;let s=a.ios_universal_link||a.debug_ios_universal_link;s=this.polyfillUniversalLink(s);let o=[];t.universalLink&&(o=t.universalLink.split(","),o=o.filter(e=>"string"==typeof e&&e.length>0).map(e=>this.polyfillUniversalLink(e)));let r=[];if(Array.isArray(t.__customAssociatedDomains)){r=(t.__customAssociatedDomains||[]).filter(e=>"string"==typeof e&&e.length>0).map(e=>this.polyfillUniversalLink(e))}return{"com.apple.developer.associated-domains":[s,...o,...r].join("_$_ULinK_$_")}}polyfillUniversalLink(e){let i=e;return(i.startsWith("https://")||i.startsWith("http://"))&&(i=i.replace(/^http(s)?:\/\//g,"applinks:")),i}useTpush(e){return(0,miniappJson_1.iOSMiniAppJsonIsUsingTpush)(e)}async buildCloud(e,i){const{projectPath:t,demoIpaPath:n,sdkPath:a,arch:s="arm64",bindingInfo:o,certificateInfo:r,output:l,miniappCacheDirPath:p,pluginDirList:d,inLandun:c,theme:u,i18nInfo:f,debugInfo:_,CILocalBuild:h,cacheAssetCarPath:y}=e,g=this.generateTempDemoIpaPath(n),{selfCertificate:m={}}=r,S=(null==m?void 0:m.isPublish)||!1,I=(0,miniappJson_1.tryGetIOSMiniappJson)(t),v=this.useTpush(I);if((0,lodash_1.isEmpty)(I))throw new Error("获取project.miniapp.json失败");if(errorIOSSdkVersions.includes(I.sdkVersion))throw new Error("当前 mini-ios.sdkVersion 存在缺陷,请参考更新日志进行修改");let x=o;if(r.signType===miniapp_builder_1.miniappSinTypes.appleId.type){const{mobileapp_info:e={}}=x;x=Object.assign(Object.assign({},x),{mobileapp_info:Object.assign(Object.assign({},e),{bundle_id:miniapp_builder_1.DEFAULT_BUNDLE_ID,debug_ios_bundle_id:miniapp_builder_1.DEFAULT_BUNDLE_ID})})}const b=await this.updateIOSInfoPlistInfo(t,x,g,I,i,f);await this.updateIOSAppConfigPlistInfo(t,x,g,I,a,!1,i,u,f),await this.updateIOSAppexInfoPlistInfo(x,g,I,b,i),await this.updateIOSIcons(t,g,p,I,S,i,!0===c,y),await this.updateSplashScreen(t,g,I,i,u,f),await this.updateSplashScreenVideo(t,g,I,i,f),await this.updateExtendedSdk(x,g,a,s,I,_,i),await this.updatePlugin(g,d,t,I,p,S,b,i),await this.updatePrivacyInfo(g,I,i),await this.updateIOSAppResource(t,g,I,i);const F=await this.getEntitlements(x,g,I,i),{mobileapp_info:P={}}=x;let j;j=r.signType===miniapp_builder_1.miniappSinTypes.appleId.type?miniapp_builder_1.DEFAULT_BUNDLE_ID:P.ios_flag&&P.bundle_id||P.debug_ios_bundle_id;const B={bundleId:j,output:l,entitlements:F,isPublish:m.isPublish};if(I.buildCloud&&(I.buildCloud.certificate&&"string"==typeof I.buildCloud.certificate&&(B.certificate=I.buildCloud.certificate),I.buildCloud.profile&&"string"==typeof I.buildCloud.profile&&(B.profile=path_1.default.join(t,I.buildCloud.profile)),v&&I.buildCloud.tpnsProfile&&"string"==typeof I.buildCloud.tpnsProfile&&(B.tpnsProfile=path_1.default.join(t,I.buildCloud.tpnsProfile))),h&&(B.profile=m.profilePath,B.certificate=m.certificateName),m.isPublish||h){const e=await(0,codesign_1.codesignAndExport)(t,g,p||"",B,i,v,!0===c);if(!0!==e.success)throw new Error("Build ipa failed:"+(e.errMsg||"codesignAndExport failed"))}return{projectPath:t,demoIpaPath:g,opts:B,iosMiniappJson:I,isPublish:S}}async writeI18NInfoFile(e,i,t){Object.keys(i).forEach(n=>{if("base"===n)return;let a="";Object.keys(t).forEach(e=>{var s,o,r,l;"UISplashScreenImageName"!==e?"UISplashScreenVideoName"!==e?"UILaunchStoryboardName"!==e?(null===(o=null===(s=i[n])||void 0===s?void 0:s.ios)||void 0===o?void 0:o[t[e]])&&(a+=`${e} = "${null===(l=null===(r=i[n])||void 0===r?void 0:r.ios)||void 0===l?void 0:l[t[e]]}";\n`):a+="__UILaunchStoryboardName__\n":a+="__UISplashScreenVideoName__\n":a+="__UISplashScreenImageName__\n"}),a&&(fs_extra_1.default.ensureDirSync(path_1.default.join(e,n+".lproj")),fs_extra_1.default.writeFileSync(path_1.default.join(e,n+".lproj/InfoPlist.strings"),a))})}getMaterialFilePath(e,i){if(!i)return"";let t=i;if(path_1.default.isAbsolute(i)||(t=path_1.default.join(e,i)),fs_extra_1.default.existsSync(t))return t;const n=(0,tools_1.generateMD5)(i),a=path_1.default.basename(i),s=path_1.default.join(e,exports.remoteBuildProjectMaterialAbsoluteCacheDir,`${n}_${a}`);return fs_extra_1.default.existsSync(s)?s:""}updateIOSAppResource(e,i,t,n){const a=t.resourcePath;if(!a)return;const s=this.getMaterialFilePath(e,a);if(s){n.progress("正在拷贝资源至主包:"+s);const e=fs_extra_1.default.lstatSync(s);if(e.isDirectory())this.copyDirectory(s,i,!1);else if(e.isFile()){const e=path_1.default.basename(a),t=path_1.default.join(i,e);if(fs_extra_1.default.existsSync(t))throw new Error(`fail to copy ${s}, overwrite is not allowed`);fs_extra_1.default.copyFileSync(s,t)}}}copyDirectory(e,i,t=!0){if(fs_extra_1.default.ensureDirSync(i),t)fs_extra_1.default.copySync(e,i);else{fs_extra_1.default.readdirSync(e).forEach(n=>{const a=path_1.default.join(e,n),s=path_1.default.join(i,n);if(fs_extra_1.default.statSync(a).isDirectory())this.copyDirectory(a,s,t);else{if(fs_extra_1.default.existsSync(s))throw new Error(`fail to copy ${a}, overwrite is not allowed`);fs_extra_1.default.copyFileSync(a,s)}})}}}exports.default=new buildCloudManager;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.remoteBuildProjectMaterialAbsoluteCacheDir=void 0;const tslib_1=require("tslib"),child_process=tslib_1.__importStar(require("child_process")),path_1=tslib_1.__importDefault(require("path")),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),glob_1=tslib_1.__importDefault(require("glob")),env_1=require("../../../utils/env"),miniapp_builder_1=require("../../../utils/miniapp-builder"),codesign_1=require("../../../utils/codesign"),miniappJson_1=require("../../../utils/miniappJson"),lodash_1=require("lodash"),tools_1=require("../../../utils/tools"),uuidv4=require("uuid/v4"),sizeOf=require("image-size"),plist=require("simple-plist"),errorIOSSdkVersions=["1.0.19"],APPEX_PROFILES_MAPS_FILE="__appexProfilesCacheDir__/profilesMap.json",APPEX_PROFILES_MAPS_FOR_SHELL_FILE="__appexProfilesCacheDir__/profilesMapForShell.txt",defaultIconDirPath=path_1.default.join(__dirname,"../../../static/images/"),getDepReg=e=>new RegExp(`s.subspec '${e}'.*\n(?:.*\n)*?(?:.*sp.vendored_frameworks = \\[\n)((?:.*'.*?'.*\n)*?)(?:.*\\]\n)`,"m"),allowTheme=["Light","LightSpecial","Dark","DarkSpecial","Default"];exports.remoteBuildProjectMaterialAbsoluteCacheDir="__absoluteFile";const iconInfoMap={appStore1024:{size:[1024,1024],scale:1,idiom:"ios-marketing",required:!0},appStore1024Other:{size:[1024,1024],scale:1,idiom:"ios-marketing-other"},mainIcon120:{size:[60,60],scale:2,idiom:"iphone",required:!0},mainIcon180:{size:[60,60],scale:3,idiom:"iphone"},spotlightIcon80:{size:[40,40],scale:2,idiom:"iphone"},spotlightIcon120:{size:[40,40],scale:3,idiom:"iphone"},settingsIcon58:{size:[29,29],scale:2,idiom:"iphone"},settingsIcon87:{size:[29,29],scale:3,idiom:"iphone"},notificationIcon40:{size:[20,20],scale:2,idiom:"iphone"},notificationIcon60:{size:[20,20],scale:3,idiom:"iphone"},ipadMainIcon152:{size:[76,76],scale:2,idiom:"ipad"},ipadMainIcon167:{size:[83.5,83.5],scale:2,idiom:"ipad"},ipadSpotlightIcon40:{size:[40,40],scale:1,idiom:"ipad"},ipadSpotlightIcon80:{size:[40,40],scale:2,idiom:"ipad"},ipadSettingsIcon29:{size:[29,29],scale:1,idiom:"ipad"},ipadSpotlightIcon58:{size:[29,29],scale:2,idiom:"ipad"},ipadNotificationIcon20:{size:[20,20],scale:1,idiom:"ipad"},ipadNotificationIcon40:{size:[20,20],scale:2,idiom:"ipad"}};class buildCloudManager{generateTempDemoIpaPath(e){const i=path_1.default.join(e,"../.."),t=path_1.default.basename(i),n=path_1.default.dirname(i),a=path_1.default.join(n,`${t}-operateDir`);fs_extra_1.default.existsSync(a)&&fs_extra_1.default.removeSync(a),fs_extra_1.default.ensureDirSync(a);const s=path_1.default.join(a,"Payload/demo.app");return fs_extra_1.default.copySync(e,s),s}generateInfoPlistCFBundleURLTypesItem(e){const i={};return e.CFBundleURLName&&(i.CFBundleURLName=e.CFBundleURLName),e.CFBundleURLSchemes&&(Array.isArray(e.CFBundleURLSchemes)?i.CFBundleURLSchemes=e.CFBundleURLSchemes:i.CFBundleURLSchemes=[e.CFBundleURLSchemes]),e.CFBundleTypeRole&&(i.CFBundleTypeRole=e.CFBundleTypeRole),i}updatePrivacyBackgroundImage(e,i,t,n,a){t.message("doing",`updatePrivacyBackgroundImage ${n}`);if(fs_extra_1.default.readdirSync(i).forEach((e=>{`privacy_${n}`===path_1.default.basename(e,path_1.default.extname(e))&&fs_extra_1.default.removeSync(path_1.default.join(i,e))})),!a)return;path_1.default.isAbsolute(a)||(a=path_1.default.join(e,a)),a=this.getMaterialFilePath(e,a);const s=path_1.default.extname(a),o=path_1.default.join(i,`privacy_${n}${s}`);try{fs_extra_1.default.copyFileSync(a,o)}catch(e){throw t.message("error",`copy privacy image failed: ${n}, ${a} to ${o}`),e}}async updateIOSInfoPlistInfo(e,i,t,n,a,s){var o,r,l,p,d,c,u,f,_,h,y,g;a.progress("update app base info...");const{mobileapp_info:m={}}=i,S=m.mobileapp_id,I=path_1.default.join(t,"Info.plist"),v={},x=(e,i)=>{var t,n;if((null==i?void 0:i.startsWith("%"))&&(null==i?void 0:i.endsWith("%"))){const o=i.slice(1,-1);v[e]=o;const r=(null===(n=null===(t=null==s?void 0:s.base)||void 0===t?void 0:t.ios)||void 0===n?void 0:n[o])||"";return r||a.message("error",`未在国际化配置 base.json 中找到字段 ${o},请检查`),r}return i};x("UISplashScreenImageName",null===(o=null==n?void 0:n.splashscreen)||void 0===o?void 0:o.customImage),x("UISplashScreenVideoName",null===(r=null==n?void 0:n.splashscreen)||void 0===r?void 0:r.customVideo),x("UILaunchStoryboardName",null===(l=null==n?void 0:n.splashscreen)||void 0===l?void 0:l.customImage);const b=plist.readFileSync(I);if(b.UIBackgroundModes=[],!0===(null===(p=null==n?void 0:n.infoPlist)||void 0===p?void 0:p.AudioInBackgroundMode)&&b.UIBackgroundModes.push("audio"),!0===(null===(d=null==n?void 0:n.infoPlist)||void 0===d?void 0:d.LocationInBackgroundMode)&&b.UIBackgroundModes.push("location"),"object"==typeof n.customInfoPlist&&!Array.isArray(n.customInfoPlist)){a.progress("initiating user custom info.plist config");const e=n.customInfoPlist;for(const i in e)b[i]=e[i]}if(b.CFBundleName=x("CFBundleName",n.name),b.CFBundleDisplayName=x("CFBundleDisplayName",n.name),b.CFBundleShortVersionString=n.version,"number"==typeof n.versionCode?b.CFBundleVersion=parseInt(n.versionCode.toString(),10).toString():b.CFBundleVersion=(parseInt(b.CFBundleVersion,10)+1).toString(),b.CFBundleIdentifier=this.getBundleIdentifier(m),Array.isArray(null==n?void 0:n.openMimeTypes)&&this.validateCFBundleDocumentTypes(n.openMimeTypes,a)&&(b.CFBundleDocumentTypes=n.openMimeTypes,a.message("doing","openMimeTypes 应用成功")),Array.isArray(b.CFBundleURLTypes)||(b.CFBundleURLTypes=[]),(null===(u=null===(c=b.CFBundleURLTypes)||void 0===c?void 0:c[0])||void 0===u?void 0:u.CFBundleURLSchemes)&&(b.CFBundleURLTypes[0].CFBundleURLSchemes=[S]),b.CFBundleURLTypes[0]&&(b.CFBundleURLTypes=[b.CFBundleURLTypes[0]]),Object.keys(miniappJson_1.iosPrivacyDescObj).forEach((e=>{var i,t;(null===(i=null==n?void 0:n.privateDescriptions)||void 0===i?void 0:i[e])?b[e]=x(e,null===(t=n.privateDescriptions)||void 0===t?void 0:t[e]):delete b[e]})),!0===(null===(f=null==n?void 0:n.infoPlist)||void 0===f?void 0:f.DisableAppUsesNonExemptEncryption)?b.ITSAppUsesNonExemptEncryption=!1:delete b.ITSAppUsesNonExemptEncryption,!0===(null===(_=null==n?void 0:n.infoPlist)||void 0===_?void 0:_.requiresFullScreen)?b.UIRequiresFullScreen=!0:delete b.UIRequiresFullScreen,"object"==typeof(null===(h=null==n?void 0:n.infoPlist)||void 0===h?void 0:h.CFBundleURLTypes)){const e=this.generateInfoPlistCFBundleURLTypesItem(n.infoPlist.CFBundleURLTypes);b.CFBundleURLTypes.push(e);const{additionalCFBundleURLTypes:i}=n.infoPlist.CFBundleURLTypes;Array.isArray(i)&&i.forEach((e=>{if("object"==typeof e){const i=this.generateInfoPlistCFBundleURLTypesItem(e);b.CFBundleURLTypes.push(i)}}))}if(null===(y=null==n?void 0:n.useExtendedSdk)||void 0===y?void 0:y.WeAppGoogleLogin){if(!(null==n?void 0:n.googleLoginClientID)||!(null==n?void 0:n.googleLoginBundleUrlType))throw new Error("勾选了 Google Login 拓展模块但未填写 googleLoginClientID 或 googleLoginBundleUrlType 将导致拓展模块无法使用");b.GIDClientID=n.googleLoginClientID,Array.isArray(b.CFBundleURLTypes)?b.CFBundleURLTypes.push({CFBundleURLSchemes:[n.googleLoginBundleUrlType]}):b.CFBundleURLTypes=[{CFBundleURLSchemes:[n.googleLoginBundleUrlType]}]}if(!0===n.enableIpad)if(Array.isArray(n.iPadUISupportedInterfaceOrientations)){const e={Portrait:"UIInterfaceOrientationPortrait",PortraitUpsideDown:"UIInterfaceOrientationPortraitUpsideDown",LandscapeLeft:"UIInterfaceOrientationLandscapeLeft",LandscapeRight:"UIInterfaceOrientationLandscapeRight"},i=n.iPadUISupportedInterfaceOrientations.map((i=>e[i])).filter((e=>!!e));b["UISupportedInterfaceOrientations~ipad"]=i}else(0,miniappJson_1.iOSAppJsonIsUsingIPadResizable)(e)?(b["UISupportedInterfaceOrientations~ipad"]=["UIInterfaceOrientationPortrait","UIInterfaceOrientationPortraitUpsideDown","UIInterfaceOrientationLandscapeLeft","UIInterfaceOrientationLandscapeRight"],a.progress("ipad is support Landscape")):(b["UISupportedInterfaceOrientations~ipad"]=["UIInterfaceOrientationPortrait","UIInterfaceOrientationPortraitUpsideDown"],a.progress("ipad is not support Landscape"));if(null===(g=n.infoPlist)||void 0===g?void 0:g.LSApplicationQueriesSchemes){const e=n.infoPlist.LSApplicationQueriesSchemes.split(",");e.length&&b.LSApplicationQueriesSchemes.push(...e.filter((e=>e)))}try{plist.writeFileSync(I,b)}catch(e){throw new Error(`write info.plist failed!!${e.messenge}`)}return await this.writeI18NInfoFile(t,s,v),b.CFBundleVersion}getBundleIdentifier(e){return e.ios_flag&&e.bundle_id||e.debug_ios_bundle_id}validateCFBundleDocumentTypes(e,i){const t=["Owner","Default"," Alternate","None"],n=["Editor","Viewer"," Shell","None"],a=new Set;for(const s of e){if(a.has(s.CFBundleTypeName))return i.message("error",`openMimeTypes 应用失败,存在重复定义的 CFBundleTypeName: ${s.CFBundleTypeName}`),!1;if(a.add(s.CFBundleTypeName),!t.includes(s.LSHandlerRank))return i.message("error",`openMimeTypes 应用失败,存在不合法的 LSHandlerRank: ${s.LSHandlerRank}`),!1;if(!n.includes(s.CFBundleTypeRole))return i.message("error",`openMimeTypes 应用失败,存在不合法的 CFBundleTypeRole: ${s.CFBundleTypeRole}`),!1;if(!Array.isArray(s.LSItemContentTypes))return i.message("error","openMimeTypes 应用失败,LSItemContentTypes 类型不合法"),!1}return!0}useGDT(e){return(0,miniappJson_1.iOSMiniAppJsonIsUsingGDT)(e)}async updateIOSAppConfigPlistInfo(e,i,t,n,a,s,o,r="Dark",l){var p,d,c,u,f,_,h;o.progress("update app module info...");const{module_info:y={},cpa_info:g={},cpa_package_info:m={enable_remove_watermark:!1}}=i;if(!g.sdk_key||!g.sdk_key_secret)throw new Error("sdkKey and sdkSecret not found");const S=path_1.default.join(t,"MiniApp.bundle"),I=path_1.default.join(S,"AppConfig.plist"),v=plist.readFileSync(I);m.enable_remove_watermark?v.enableRemoveWatermark=!0:v.splashscreenTheme=r,v.miniModuleId=y.module_id,v.sdkKey=g.sdk_key,v.sdkSecret=g.sdk_key_secret;const{privacy:x={}}=n;v.privacy||(v.privacy={}),v.privacy.enable=!!x.enable,v.privacy.enableViewOnly=!!x.enableViewOnly;const b="configs/privacy.json",F=path_1.default.posix.join(S,b),{contentViewImage:P,cancelButtonImage:j,confirmButtonImage:B,template:L}=x;if(x.enable){let i=L||"";if(fs_extra_1.default.ensureDirSync(path_1.default.posix.join(S,"configs")),i.startsWith("%")&&i.endsWith("%")){const t=L.slice(1,-1);i=(null===(d=null===(p=null==l?void 0:l.base)||void 0===p?void 0:p.ios)||void 0===d?void 0:d[t])||"",i||o.message("error",`未在国际化配置 base.json 中找到字段 ${t},请检查`),Object.keys(l).forEach((i=>{var n,a;if("base"===i)return;let s=null===(a=null===(n=l[i])||void 0===n?void 0:n.ios)||void 0===a?void 0:a[t];if(s){s=this.getMaterialFilePath(e,s);const t=`configs/privacy-${i}.json`,n=path_1.default.posix.join(S,t);fs_extra_1.default.existsSync(s)?fs_extra_1.default.copyFileSync(s,n):o.message("error",`未找到隐私协议在国际化配置 ${i}.json 中配置的文件 ${s},请检查`)}}))}i?(i=this.getMaterialFilePath(e,i),fs_extra_1.default.existsSync(i)?(fs_extra_1.default.copyFileSync(i,F),v.privacy.template=b):(o.message("error",`未找到隐私协议中配置的文件 ${i},请检查`),v.privacy.template="configs/defaultPrivacy.json")):v.privacy.template="configs/defaultPrivacy.json",!0===x.enableNativePlugin&&"string"==typeof x.nativePluginId&&x.nativePluginId.length>2&&(v.privacy.plugin={pluginId:x.nativePluginId,enable:!0})}else v.privacy.template="",fs_extra_1.default.removeSync(F);this.updatePrivacyBackgroundImage(e,t,o,"contentViewImage",P),this.updatePrivacyBackgroundImage(e,t,o,"confirmButtonImage",B),this.updatePrivacyBackgroundImage(e,t,o,"cancelButtonImage",j);const{appMenuEnable:$=!0}=n;v.appMenuEnable=$;const{enableVConsole:C="undefined"}=n;if(v.enableVConsole=C,null===(c=n.useExtendedSdk)||void 0===c?void 0:c.WeAppLive){const{weAppLiveLicenseUrl:e,weAppLiveLicenseKey:i}=n.liveInfo||{};e&&i&&(v.weAppLiveLicenseUrl=e,v.weAppLiveLicenseKey=i)}const{tpush:w}=n;let A=!1;if("object"==typeof w){const e=path_1.default.posix.join(t,"PlugIns/TPNSService.appex"),i=path_1.default.posix.join(e,"AppConfig.plist");if(this.useTpush(n)){v.TPNSAccessID=w.accessID,v.TPNSAccessKey=w.accessKey,w.clusterDomainName?v.clusterDomainName=w.clusterDomainName:delete v.clusterDomainName;const t=s?"x86_64":"arm64",n=path_1.default.join(a,`appex/${t}/TPNSService.appex`);if(!fs_extra_1.default.existsSync(n))throw new Error(`can not found extendsdk: ${n}`);try{fs_extra_1.default.copySync(n,e),plist.writeFileSync(i,v),A=!0}catch(e){throw new Error(`copy TPNSService.appex to app failed: ${e}`)}}}if(!A)try{const e=path_1.default.posix.join(t,"PlugIns");fs_extra_1.default.existsSync(e)?(fs_extra_1.default.removeSync(e),o.progress("removed PlugIns folder...")):o.progress("no PlugIns folder...")}catch(e){throw new Error(`remove TPNSService.appex from app failed: ${e}`)}if(null===(u=n.useExtendedSdk)||void 0===u?void 0:u.WeAppLBS){if(!n.qmapAPIKey)throw new Error("You need to provide the Tencent Location Service API Key when using LBS SDK.");v.qmapAPIKey=n.qmapAPIKey}const{gdt:U}=n,D=this.useGDT(n);if(v.GDTAd=D?{appid:U.appid,enable:!0,SplashAd:{placementId:U.splashAd_placementId,fetchDelay:U.splashAd_fetchDelay||3,defaultEnable:null===(f=U.splashAd_defaultEnable)||void 0===f||f}}:{appid:"",enable:!1,SplashAd:{placementId:"",fetchDelay:3}},n["mini-plugin"]&&Array.isArray(n["mini-plugin"].ios)){const e=n["mini-plugin"].ios,i=e.filter((e=>!!(e.open&&e.pluginId&&e.loadWhenStart))).map((e=>e.pluginId)),t=e.map((e=>e.open?{pluginId:e.pluginId,version:e.isFromLocal?"dev":e.pluginVersion}:void 0)).filter((e=>e));v.plugins={loadWhenStart:i,pluginInfoList:t}}const{enableDebugLog:E=!1}=n;v.enableDebugLog=E;const{debugLogSizeLimit:O=10}=n;isNaN(Number(O))?o.message("error",`ios debugLogSizeLimit ${O} is NaN`):v.debugLogSizeLimit=Number(O);const{enableOpenUrlNavigate:k=!1}=n;v.enableOpenUrlNavigate=k;const T=path_1.default.posix.join(S,"configs/locales");if(fs_extra_1.default.ensureDirSync(T),null===(h=null===(_=null==l?void 0:l.base)||void 0===_?void 0:_.ios)||void 0===h?void 0:h.LOCALES){const i=this.getMaterialFilePath(e,l.base.ios.LOCALES);fs_extra_1.default.existsSync(i)?(fs_extra_1.default.copyFileSync(i,path_1.default.posix.join(T,"common-base.json")),o.progress("复制基础语言 locales 配置成功")):o.message("error",`未找到基础语言 locales 配置文件: ${i}`)}Object.keys(l).forEach((i=>{var t,n;if("base"===i)return;const a=null===(n=null===(t=l[i])||void 0===t?void 0:t.ios)||void 0===n?void 0:n.LOCALES;if(a){const t=this.getMaterialFilePath(e,a);fs_extra_1.default.existsSync(t)?(fs_extra_1.default.copyFileSync(t,path_1.default.posix.join(T,`common-${i}.json`)),o.progress(`复制 ${i} 语言 locales 配置成功`)):o.message("error",`未找到 ${i} 语言 locales 配置文件: ${t}`)}})),plist.writeFileSync(I,v)}async updateIOSAppexInfoPlistInfo(e,i,t,n,a){if(this.useTpush(t)){a.progress("update appex for notification base info...");const{mobileapp_info:s={}}=e,o=path_1.default.join(i,"PlugIns/TPNSService.appex"),r=path_1.default.join(o,"Info.plist"),l=plist.readFileSync(r);l.CFBundleShortVersionString=t.version,a.progress(`update appex for CFBundleVersion: ${n}`),l.CFBundleVersion=n;const p=s.ios_flag&&s.bundle_id||s.debug_ios_bundle_id;l.CFBundleIdentifier=t.tpush.serviceBundleId||`${p}.service`,a.progress(`update appex bundle identifier for infoPlist : ${l.CFBundleIdentifier}`),plist.writeFileSync(r,l)}else a.progress("not using tpush...")}updateBundleIcons(e,i,t,n,a){const s=[],o=[],r=[];for(const l in t){if(!t[l])continue;const p=this.getMaterialFilePath(e,t[l]);if(!p)return void a.message("error",`getMatrialFailed: ${t[l]}`);const d=iconInfoMap[l];try{const e=sizeOf(p),i=d.size[0]*d.scale,n=d.size[1]*d.scale;if(e.width!==i||e.height!==n){a.progress(`check ${l} size failed, require [${i}, ${n}] but [${e.width}, ${e.height}] ingore ${t[l]} `);continue}}catch(e){a.progress(`get ${l} info failed, ingore ${t[l]}(e: ${e.message})`);continue}const c=path_1.default.extname(p),u=1===d.scale?"":`@${d.scale}x`,f=`${d.size[0]}x${d.size[1]}`,_=l.startsWith("ipad"),h="appStore1024"===l||"appStore1024Other"===l,y="appStore1024Other"===l?`${n}Other`:n,g=path_1.default.join(i,`${y}${f}${u}${_?"~ipad":""}${c}`),m={from:p,to:g,filename:path_1.default.basename(g),size:f,scale:`${d.scale}x`,idiom:d.idiom,key:l};s.push(m),h||(_?r.includes(`${y}${f}`)||r.push(`${y}${f}${u}`):o.includes(`${y}${f}`)||o.push(`${y}${f}${u}`))}return{iphoneBundleIconFiles:o,ipadBundleIconFiles:r,addFiles:s}}async updateIOSIcons(e,i,t,n,a,s,o=!1,r=""){s.progress("update app icons...");const{icons:l={}}=n,p=(o||a)&&!!t;s.progress(`genAssetCar: ${p}`);const d=glob_1.default.sync("AppIcon*.+(png|jpg|jpeg|webp)",{nodir:!0,cwd:i}).map((e=>path_1.default.join(i,e))),c=`AppIcon-${uuidv4().slice(0,8)}`,u=this.updateBundleIcons(e,i,l,c,s);if(!u)throw new Error("updateBundleIcons failed");const{iphoneBundleIconFiles:f=[],ipadBundleIconFiles:_=[],addFiles:h=[]}=u,y={};for(const e in iconInfoMap){if(!iconInfoMap[e].required||l[e])continue;const i=iconInfoMap[e].size[0]*iconInfoMap[e].scale,t=iconInfoMap[e].size[1]*iconInfoMap[e].scale;if(y[e]=path_1.default.join(defaultIconDirPath,`donut-icon${i}x${t}.png`),s.progress(`using default app icons when ${e} is not config...`),!fs_extra_1.default.existsSync(y[e]))throw new Error(`required ${e} but not default or set`)}const g=this.updateBundleIcons(e,i,y,c,s);if(!g)throw new Error("updateBundleIcons WithDefaultIcon failed");const{iphoneBundleIconFiles:m,ipadBundleIconFiles:S,addFiles:I}=g;if(f.push(...m),_.push(...S),h.push(...I),!f.length&&!_.length)return;d.forEach((e=>{fs_extra_1.default.existsSync(e)&&fs_extra_1.default.removeSync(e)}));const v=path_1.default.join(t,"__assetCarOperateDir/assetsCar/"),x=path_1.default.join(v,`Assets.xcassets/${c}.appiconset/`);p&&(fs_extra_1.default.ensureDirSync(x),fs_extra_1.default.emptyDirSync(x));const b=[];let F=!1;if(h.forEach((e=>{fs_extra_1.default.existsSync(e.to)&&fs_extra_1.default.removeSync(e.to),fs_extra_1.default.copyFileSync(e.from,e.to),p&&(fs_extra_1.default.copySync(e.from,path_1.default.join(x,e.filename)),"ios-marketing-other"===e.idiom&&(F=!0),b.push({filename:e.filename,size:e.size,scale:e.scale,idiom:e.idiom}))})),p&&fs_extra_1.default.writeJsonSync(path_1.default.join(x,"Contents.json"),{images:b,info:{author:"xcode",version:1}},{spaces:"\t"}),p){const e=path_1.default.join(__dirname,"../../../static/scripts/assetsCar/"),t=path_1.default.join(v,"createAssetsCar");fs_extra_1.default.copySync(e,v);try{await(0,codesign_1.checkXcodeEnv)(s),child_process.execSync(`"${t}" ${c}`,{env:(0,env_1.getProcessEnv)()})}catch(e){throw new Error(`createAssetsCar failed ${e.message||""}`)}const n=path_1.default.join(v,"build/Assets.car"),a=path_1.default.join(i,"Assets.car");fs_extra_1.default.copyFileSync(n,a)}else if(r&&fs_extra_1.default.existsSync(r))s.message("success","命中缓存,正在使用缓存的 AssetCar"),fs_extra_1.default.copyFileSync(r,path_1.default.join(i,"Assets.car"));else{const e=path_1.default.join(i,"Assets.car");fs_extra_1.default.removeSync(e),s.message("warn","更新 App 图标可能不生效,可使用远程构建验证图标设置;工具将会缓存图标构建结果")}const P=path_1.default.join(i,"Info.plist"),j=plist.readFileSync(P);if(!j.CFBundleIcons){const e={CFBundlePrimaryIcon:{}};j.CFBundleIcons=e}F&&(j.CFBundleIcons.CFBundleAlternateIcons={OtherAppStoreIcon:{CFBundleIconFiles:[`${c}Other`],CFBundleIconName:"OtherAppStoreIcon"}}),j.CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconName=c,j.CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles=f,j["CFBundleIcons~ipad"]||(j["CFBundleIcons~ipad"]={CFBundlePrimaryIcon:{}}),j["CFBundleIcons~ipad"].CFBundlePrimaryIcon.CFBundleIconName=c,j["CFBundleIcons~ipad"].CFBundlePrimaryIcon.CFBundleIconFiles=_,j.NSAppTransportSecurity={NSAllowsArbitraryLoads:!0},plist.writeFileSync(P,j)}replaceLaunchScreenImage(e,i,t,n,a,s){const o=path_1.default.join(e,"01J-lp-oVM-view-Ze5-6b-2t3.nib");let r=fs_extra_1.default.readFileSync(o).toString("hex");if(!i.endsWith(".png"))return void n.message("error",`IOS 启动页图片配置格式错误,必须为 PNG 格式, 错误配置:${i}`);const l=this.getMaterialFilePath(a,i),p=`${t}.png`,d=`LaunchScreen-${uuidv4().slice(0,12)}`,c=`${d}.png`,u=path_1.default.join(s,c);fs_extra_1.default.copyFileSync(l,u);const f=Buffer.from(p,"utf-8").toString("hex"),_=Buffer.from(c,"utf-8").toString("hex");return-1!==r.indexOf(f)?(r=r.replace(f,_),console.log("replace storyboard customImage success")):console.log("replace storyboard customImage fail"),fs_extra_1.default.writeFileSync(o,Buffer.from(r,"hex")),d}replaceLaunchScreenVideo(e,i,t,n){const a=path_1.default.extname(e);if([".mp4",".mov"].indexOf(a)<0)return void i.message("error",`IOS 启动页视频配置格式错误,必须为 mp4 mov 格式, 错误配置:${e}`);const s=this.getMaterialFilePath(t,e),o=`${`LaunchScreen-${uuidv4().slice(0,12)}`}${a}`,r=path_1.default.join(n,o);return fs_extra_1.default.copyFileSync(s,r),o}async updateSplashScreen(e,i,t,n,a="Dark",s){var o,r,l;let p;n.progress("update splashscreen image..."),allowTheme.includes(a)&&(p=path_1.default.join(i,`/Base.lproj/LaunchScreen${a}.storyboardc`)),p&&fs_extra_1.default.existsSync(p)&&fs_extra_1.default.copySync(p,path_1.default.join(i,"/Base.lproj/LaunchScreen.storyboardc")),allowTheme.forEach((e=>{const t=path_1.default.join(i,`/Base.lproj/LaunchScreen${e}.storyboardc`);fs_extra_1.default.existsSync(t)&&fs_extra_1.default.removeSync(t)}));let d=null===(o=null==t?void 0:t.splashscreen)||void 0===o?void 0:o.customImage;if(!d)return;const c=path_1.default.join(i,"Info.plist"),u=plist.readFileSync(c),f=u.UISplashScreenImageName;if(glob_1.default.sync("LaunchScreen-*.+(png|jpg|jpeg|webp)",{nodir:!0,cwd:i}).forEach((e=>{const t=path_1.default.join(i,e);fs_extra_1.default.removeSync(t)})),d.startsWith("%")&&(null==d?void 0:d.endsWith("%"))){const t=d.slice(1,-1),a=(null===(l=null===(r=null==s?void 0:s.base)||void 0===r?void 0:r.ios)||void 0===l?void 0:l[t])||"";if(!a)return void n.message("error",`未在国际化配置 base.json 中找到字段 ${t},请检查,启动页国际化配置失败`);d=a,Object.keys(s).forEach((a=>{var o,r;if("base"===a)return;const l=null===(r=null===(o=s[a])||void 0===o?void 0:o.ios)||void 0===r?void 0:r[t];if(l){const t=path_1.default.join(i,`/${a}.lproj/LaunchScreen_${a}.storyboardc`);fs_extra_1.default.ensureDirSync(path_1.default.join(t,"..")),fs_extra_1.default.copySync(path_1.default.join(i,"/Base.lproj/LaunchScreen.storyboardc"),t);const s=this.replaceLaunchScreenImage(t,this.getMaterialFilePath(e,l),f,n,e,i);n.progress(`update ${a} splashscreen image...`);const o=fs_extra_1.default.readFileSync(path_1.default.join(i,`${a}.lproj/InfoPlist.strings`),"utf8");let r="";r=s?o.replace("__UISplashScreenImageName__",`UISplashScreenImageName = "${s}";\n`).replace("__UILaunchStoryboardName__",`UILaunchStoryboardName = "LaunchScreen_${a}";\n`):o.replace("__UISplashScreenImageName__","").replace("__UILaunchStoryboardName__",""),fs_extra_1.default.writeFileSync(path_1.default.join(i,`${a}.lproj/InfoPlist.strings`),r),n.progress(`update ${a} splashscreen image success`)}}))}n.progress("update base splashscreen image...");const _=this.replaceLaunchScreenImage(path_1.default.join(i,"/Base.lproj/LaunchScreen.storyboardc"),this.getMaterialFilePath(e,d),f,n,e,i);n.progress("update base splashscreen image success"),_&&(u.UISplashScreenImageName=_,u.UILaunchStoryboardName="LaunchScreen",plist.writeFileSync(c,u))}async updateSplashScreenVideo(e,i,t,n,a){var s,o,r;n.progress("update splashscreen video...");let l=null===(s=null==t?void 0:t.splashscreen)||void 0===s?void 0:s.customVideo;if(!l)return;const p=path_1.default.join(i,"Info.plist"),d=plist.readFileSync(p);if(l.startsWith("%")&&(null==l?void 0:l.endsWith("%"))){const t=l.slice(1,-1),s=(null===(r=null===(o=null==a?void 0:a.base)||void 0===o?void 0:o.ios)||void 0===r?void 0:r[t])||"";if(!s)return void n.message("error",`未在国际化配置 base.json 中找到字段 ${t},请检查,启动页视频国际化配置失败`);l=s,Object.keys(a).forEach((s=>{var o,r;if("base"===s)return;const l=null===(r=null===(o=a[s])||void 0===o?void 0:o.ios)||void 0===r?void 0:r[t];if(l){const t=this.replaceLaunchScreenVideo(this.getMaterialFilePath(e,l),n,e,i);n.progress(`update ${s} splashscreen video...`);const a=fs_extra_1.default.readFileSync(path_1.default.join(i,`${s}.lproj/InfoPlist.strings`),"utf8");let o="";o=t?a.replace("__UISplashScreenVideoName__",`UISplashScreenVideoName = "${t}";\n`):a.replace("__UISplashScreenVideoName__",""),fs_extra_1.default.writeFileSync(path_1.default.join(i,`${s}.lproj/InfoPlist.strings`),o),n.progress(`update ${s} splashscreen video success`)}}))}n.progress("update base splashscreen video...");const c=this.replaceLaunchScreenVideo(this.getMaterialFilePath(e,l),n,e,i);n.progress("update base splashscreen video success"),c&&(d.UISplashScreenVideoName=c,plist.writeFileSync(p,d))}genUseExtendedSdk(e,i){const t="useExtendedLib_",n=Object.assign({},e.useExtendedSdk||{});for(const i in e)if("object"==typeof e[i])for(const a in e[i])if(a.startsWith(`${t}WeApp`)&&!0===e[i][a]){n[a.slice(15)]=!0}return!n.WeAppLBS||n.WeAppOpenFuns||n.WeAppOpenFuns_HasPay||(n.WeAppOpenFuns=!0),"RemoteDebug"===(null==i?void 0:i.debugType)&&(n.WeAppUSB=!0),n}async updateExtendedSdk(e,i,t,n,a,s,o){const r=path_1.default.join(i,"Frameworks");fs_extra_1.default.ensureDirSync(r),o.progress("update extendsdk...");const l=path_1.default.join(t,"WeAppSDK.podspec"),p=fs_extra_1.default.readFileSync(l,"utf-8"),d=this.genUseExtendedSdk(a,s);o.progress(`useExtendedSdks: ${JSON.stringify(d)}`);const{mobileapp_info:c={}}=e,u=this.getBundleIdentifier(c);if(d.WeAppOpenFuns&&d.WeAppOpenFuns_HasPay)throw new Error("OpenFuncs SDK 只可勾选使用一个,请按需勾选使用");const f={},_=["WeAppUSB"];for(const e in d){if(!d[e])continue;const i=getDepReg(e),a=p.match(i);if(!(null==a?void 0:a[1])){if(_.includes(e))continue;throw new Error(`拓展模块 ${e} 不存在或已被移除,请检查 project.miniapp.json -> 对应平台 -> useExtendedSdk 删除配置 ${e},版本配置差异请参考更新日志或 https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/miniapp/changelog/difflog.html`)}const s=[];if(a[1].split("\n").forEach((e=>{const i=e.match(/.*'(.*?)',/);if(null==i?void 0:i[1]){const e=i[1].split("/").pop(),a=path_1.default.join(t,"Libs",n,e);if(!fs_extra_1.default.existsSync(a)){if(_.includes(`${e}.framework`))return;throw new Error(`拓展模块 ${e} 不存在或已被移除,请检查 project.miniapp.json -> 对应平台 -> useExtendedSdk 删除配置 ${e},版本配置差异请参考更新日志或 https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/miniapp/changelog/difflog.html`)}const o=path_1.default.join(r,e);fs_extra_1.default.copySync(a,o),s.push(path_1.default.basename(e));const l=path_1.default.join(o,"info.plist");if(!fs_extra_1.default.existsSync(l))throw new Error(`can not found extendsdk info.plist: ${e}`);this.changeExtendSDKInfoplistBundleId(l,u,e)}})),s.length){f[s.shift()]=s}}const h=path_1.default.join(i,"DyFrameworks.plist");fs_extra_1.default.existsSync(h)&&fs_extra_1.default.removeSync(h),plist.writeFileSync(h,f)}async updatePrivacyInfo(e,i,t){var n;const a=null===(n=null==i?void 0:i.privacy)||void 0===n?void 0:n.privacyInfo;a&&(a.endsWith("PrivacyInfo.xcprivacy")?fs_extra_1.default.existsSync(a)?(fs_extra_1.default.copySync(a,path_1.default.join(e,"/PrivacyInfo.xcprivacy")),t.progress("隐私清单文件替换成功")):t.message("error","隐私清单文件替换失败,文件不存在,将使用默认文件"):t.message("error","隐私清单文件替换失败,文件名必须为 PrivacyInfo.xcprivacy,将使用默认文件"))}async updatePlugin(e,i,t,n,a,s,o,r){const l={},p={},d=[];if(n["mini-plugin"]&&Array.isArray(n["mini-plugin"].ios)){n["mini-plugin"].ios.forEach((e=>{e.open&&e.pluginId?("string"==typeof e.resourcePath&&e.resourcePath.length>0&&(l[e.pluginId]=e.resourcePath),"object"==typeof e.resourceObjects&&Object.keys(e.resourceObjects).length>0&&(p[e.pluginId]=e.resourceObjects)):d.push(e.pluginId)}))}if(d.length>0&&r.message("warn",`下列插件未启用,请确认project.miniapp.json中的配置:${d.join(", ")}`),!i.length)return;const c=path_1.default.join(e,"Frameworks"),u=path_1.default.join(e,"PlugIns");fs_extra_1.default.ensureDirSync(c),r.progress("update plugin...");const f=this.prepareAppexProfileConfig(i,n,t,a,s,o,n.version,r);if(!f)throw new Error("依赖的多端插件需要配置对应的profile");i.forEach((i=>{const{pluginId:n}=i,a=i.dir,s=`${n}.framework`,o=path_1.default.join(c,s);if(-1!==a.indexOf("local-miniapp-plugin")){const e=fs_extra_1.default.statSync(a),{mtime:i}=e;r.progress(`${n}.framework 正在使用本地版本,修改时间为 ${i}`)}fs_extra_1.default.existsSync(o)&&fs_extra_1.default.removeSync(o);const d=path_1.default.join(a,s);if(fs_extra_1.default.existsSync(d)){fs_extra_1.default.copySync(d,o),this.copyResourcesToMainBundle(d,e),this.copyUserResourcePathIntoPlugins(n,t,l[n],p[n],path_1.default.join(o,"MiniPlugin.bundle"),r);fs_extra_1.default.readdirSync(a).forEach((i=>{if(i.endsWith(".appex")){const s=path_1.default.parse(i).name,o=f[s],d=path_1.default.join(u,i);if(!o||!0!==o.enable)return;r.progress(`${n} 插件使用 appex 中 : ${i}`),fs_extra_1.default.existsSync(d)&&fs_extra_1.default.removeSync(d),fs_extra_1.default.ensureDirSync(d);const c=path_1.default.join(a,i);fs_extra_1.default.copySync(c,d),(null==o?void 0:o.profilePath)&&fs_extra_1.default.copySync(o.profilePath,path_1.default.join(d,"embedded.mobileprovision")),this.copyResourcesToMainBundle(c,e),this.copyUserResourcePathIntoPlugins(n,t,l[n],p[n],path_1.default.join(d,"MiniPlugin.bundle"),r)}else if(i.endsWith("framework")&&i!==s){const e=path_1.default.join(c,i),t=path_1.default.join(a,i);fs_extra_1.default.existsSync(e)&&fs_extra_1.default.removeSync(e),fs_extra_1.default.copySync(t,e)}}))}else fs_extra_1.default.copySync(a,o),this.copyResourcesToMainBundle(a,e),this.copyUserResourcePathIntoPlugins(n,t,l[n],p[n],path_1.default.join(o,"MiniPlugin.bundle"),r)}))}copyUserResourcePathIntoPlugins(e,i,t,n,a,s){const o=a;if(t){const n=path_1.default.basename(t),a=this.getMaterialFilePath(i,t);if(a){s.progress(`${e}.framework 正在拷贝配置的资源:${t}`);const i=fs_extra_1.default.lstatSync(a);fs_extra_1.default.ensureDirSync(o),i.isDirectory()?fs_extra_1.default.copySync(a,o):i.isFile()&&fs_extra_1.default.copyFileSync(a,path_1.default.join(o,n))}}if(n){s.progress(`${e}.framework 正在写入配置的资源`),fs_extra_1.default.ensureDirSync(o);for(const e in n){const i=n[e],t=path_1.default.join(o,e);fs_extra_1.default.ensureDirSync(o),fs_extra_1.default.ensureFileSync(t),fs_extra_1.default.writeFileSync(t,i)}}}copyResourcesToMainBundle(e,i){const t=path_1.default.join(e,"MiniPlugin.bundle"),n=path_1.default.join(t,"PluginConfig.plist");if(fs_extra_1.default.existsSync(n)){const e=plist.readFileSync(n).CopyResourcesToMainBundle;(null==e?void 0:e.length)&&e.forEach((e=>{const n=path_1.default.join(t,e);fs_extra_1.default.existsSync(n)&&fs_extra_1.default.copySync(n,path_1.default.join(i,e))}))}}prepareAppexProfileConfig(e,i,t,n,a,s,o,r){if(!n)return void r.message("doing","miniappCacheDirPath is missing");let l=!1;const p={};if(i["mini-plugin"]&&Array.isArray(i["mini-plugin"].ios)){i["mini-plugin"].ios.forEach((e=>{if(e.open&&e.pluginId&&"object"==typeof e.appexProfiles)for(const i in e.appexProfiles){r.message("doing",`检查插件 ${e.pluginId} ${i} appex 配置中 ...`);const n=e.appexProfiles[i];if(!0===n.enable){const s=`${e.pluginId}_${i}`;p[s]={enable:!0};let o=n.profilePath;if(a&&(o=n.distributeProfilePath),n.bundleID&&o){const a=path_1.default.join(t,o);fs_extra_1.default.existsSync(a)?(p[s].bundleID=n.bundleID,p[s].profilePath=path_1.default.join(t,o)):(l=!0,r.message("error",`${e.pluginId} 中 ${i} 的 profilePath 无法找到对应的文件:${a}(需要在小程序项目路径下,填入相对于项目根目录的路径)`))}else l=!0,r.message("error",`${e.pluginId}中${i} 是 无效的appexProfiles配置。需要配置 bundleID,profilePath,distributeProfilePath。profile 文件需要放置在小程序项目内,然后配置相对于小程序项目根目录的相对路径。分发证书构建的情况下, 一定需要配置distributeProfilePath。查看文档了解详情。`)}}}))}if(e.forEach((e=>{fs_extra_1.default.readdirSync(e.dir).forEach((i=>{if(i.endsWith(".appex")){const t=path_1.default.parse(i).name,n=p[t];if(n&&!0===n.enable)if(n.bundleID&&n.profilePath){if(n.bundleID&&n.profilePath){const t=path_1.default.join(e.dir,i,"info.plist"),a=n.bundleID;this.changeInfoplistBundleId(t,a),this.changeInfoplistBundleVersion(t,s,o),r.message("doing",`${e.pluginId} ${i} ${a} ${t} 处理 appex bundle ID 中`)}}else l=!0,r.message("error",`${e.pluginId} 的 多端插件包含了${t.slice(e.pluginId.length+1)} 的 appex。开发者需要在project.miniapp.json 中 mini-plugin 配置下对应合理的 profile 文件。查看文档了解详情。`)}}))})),l)return!1;if(!(0,lodash_1.isEmpty)(p)){const e=path_1.default.join(n,APPEX_PROFILES_MAPS_FILE);fs_extra_1.default.existsSync(e)&&fs_extra_1.default.removeSync(e),fs_extra_1.default.ensureFileSync(e);const i={};for(const e in p)i[e]={bundleID:p[e].bundleID,profilePath:p[e].profilePath};fs_extra_1.default.writeFileSync(e,JSON.stringify(i));const t=path_1.default.join(n,APPEX_PROFILES_MAPS_FOR_SHELL_FILE);fs_extra_1.default.existsSync(t)&&fs_extra_1.default.removeSync(t),fs_extra_1.default.ensureFileSync(t);const a=Object.keys(p).map((e=>{const i=p[e];return`pluginAppexName:${e};_;_;bundleID:${i.bundleID};_;_;profile:${i.profilePath}\n\n`})).join("");fs_extra_1.default.writeFileSync(t,a)}return p}changeExtendSDKInfoplistBundleId(e,i,t){const n=`${i}.${path_1.default.parse(t).name.replace(/_/g,"")}`;return this.changeInfoplistBundleId(e,n)}changeInfoplistBundleId(e,i){const t=plist.readFileSync(e);return t.CFBundleIdentifier=i,plist.writeFileSync(e,t),t.CFBundleIdentifier}changeInfoplistBundleVersion(e,i,t){const n=plist.readFileSync(e);return n.CFBundleVersion=i,n.CFBundleShortVersionString=t,plist.writeFileSync(e,n),n.CFBundleIdentifier}async getEntitlements(e,i,t,n){const{mobileapp_info:a={}}=e;let s=a.ios_universal_link||a.debug_ios_universal_link;s=this.polyfillUniversalLink(s);let o=[];t.universalLink&&(o=t.universalLink.split(","),o=o.filter((e=>"string"==typeof e&&e.length>0)).map((e=>this.polyfillUniversalLink(e))));let r=[];if(Array.isArray(t.__customAssociatedDomains)){r=(t.__customAssociatedDomains||[]).filter((e=>"string"==typeof e&&e.length>0)).map((e=>this.polyfillUniversalLink(e)))}return{"com.apple.developer.associated-domains":[s,...o,...r].join("_$_ULinK_$_")}}polyfillUniversalLink(e){let i=e;return(i.startsWith("https://")||i.startsWith("http://"))&&(i=i.replace(/^http(s)?:\/\//g,"applinks:")),i}useTpush(e){return(0,miniappJson_1.iOSMiniAppJsonIsUsingTpush)(e)}async buildCloud(e,i){const{projectPath:t,demoIpaPath:n,sdkPath:a,arch:s="arm64",bindingInfo:o,certificateInfo:r,output:l,miniappCacheDirPath:p,pluginDirList:d,inLandun:c,theme:u,i18nInfo:f,debugInfo:_,CILocalBuild:h,cacheAssetCarPath:y}=e,g=this.generateTempDemoIpaPath(n),{selfCertificate:m={}}=r,S=(null==m?void 0:m.isPublish)||!1,I=(0,miniappJson_1.tryGetIOSMiniappJson)(t),v=this.useTpush(I);if((0,lodash_1.isEmpty)(I))throw new Error("获取project.miniapp.json失败");if(errorIOSSdkVersions.includes(I.sdkVersion))throw new Error("当前 mini-ios.sdkVersion 存在缺陷,请参考更新日志进行修改");let x=o;if(r.signType===miniapp_builder_1.miniappSinTypes.appleId.type){const{mobileapp_info:e={}}=x;x=Object.assign(Object.assign({},x),{mobileapp_info:Object.assign(Object.assign({},e),{bundle_id:miniapp_builder_1.DEFAULT_BUNDLE_ID,debug_ios_bundle_id:miniapp_builder_1.DEFAULT_BUNDLE_ID})})}const b=await this.updateIOSInfoPlistInfo(t,x,g,I,i,f);await this.updateIOSAppConfigPlistInfo(t,x,g,I,a,!1,i,u,f),await this.updateIOSAppexInfoPlistInfo(x,g,I,b,i),await this.updateIOSIcons(t,g,p,I,S,i,!0===c,y),await this.updateSplashScreen(t,g,I,i,u,f),await this.updateSplashScreenVideo(t,g,I,i,f),await this.updateExtendedSdk(x,g,a,s,I,_,i),await this.updatePlugin(g,d,t,I,p,S,b,i),await this.updatePrivacyInfo(g,I,i),await this.updateIOSAppResource(t,g,I,i);const F=await this.getEntitlements(x,g,I,i),{mobileapp_info:P={}}=x;let j;j=r.signType===miniapp_builder_1.miniappSinTypes.appleId.type?miniapp_builder_1.DEFAULT_BUNDLE_ID:P.ios_flag&&P.bundle_id||P.debug_ios_bundle_id;const B={bundleId:j,output:l,entitlements:F,isPublish:m.isPublish};if(I.buildCloud&&(I.buildCloud.certificate&&"string"==typeof I.buildCloud.certificate&&(B.certificate=I.buildCloud.certificate),I.buildCloud.profile&&"string"==typeof I.buildCloud.profile&&(B.profile=path_1.default.join(t,I.buildCloud.profile)),v&&I.buildCloud.tpnsProfile&&"string"==typeof I.buildCloud.tpnsProfile&&(B.tpnsProfile=path_1.default.join(t,I.buildCloud.tpnsProfile))),h&&(B.profile=m.profilePath,B.certificate=m.certificateName),m.isPublish||h){const e=await(0,codesign_1.codesignAndExport)(t,g,p||"",B,i,v,!0===c);if(!0!==e.success)throw new Error(`Build ipa failed:${e.errMsg||"codesignAndExport failed"}`)}return{projectPath:t,demoIpaPath:g,opts:B,iosMiniappJson:I,isPublish:S}}async writeI18NInfoFile(e,i,t){Object.keys(i).forEach((n=>{if("base"===n)return;let a="";Object.keys(t).forEach((e=>{var s,o,r,l;"UISplashScreenImageName"!==e?"UISplashScreenVideoName"!==e?"UILaunchStoryboardName"!==e?(null===(o=null===(s=i[n])||void 0===s?void 0:s.ios)||void 0===o?void 0:o[t[e]])&&(a+=`${e} = "${null===(l=null===(r=i[n])||void 0===r?void 0:r.ios)||void 0===l?void 0:l[t[e]]}";\n`):a+="__UILaunchStoryboardName__\n":a+="__UISplashScreenVideoName__\n":a+="__UISplashScreenImageName__\n"})),a&&(fs_extra_1.default.ensureDirSync(path_1.default.join(e,`${n}.lproj`)),fs_extra_1.default.writeFileSync(path_1.default.join(e,`${n}.lproj/InfoPlist.strings`),a))}))}getMaterialFilePath(e,i){if(!i)return"";let t=i;if(path_1.default.isAbsolute(i)||(t=path_1.default.join(e,i)),fs_extra_1.default.existsSync(t))return t;const n=(0,tools_1.generateMD5)(i),a=path_1.default.basename(i),s=path_1.default.join(e,exports.remoteBuildProjectMaterialAbsoluteCacheDir,`${n}_${a}`);return fs_extra_1.default.existsSync(s)?s:""}updateIOSAppResource(e,i,t,n){const a=t.resourcePath;if(!a)return;const s=this.getMaterialFilePath(e,a);if(s){n.progress(`正在拷贝资源至主包:${s}`);const e=fs_extra_1.default.lstatSync(s);if(e.isDirectory())this.copyDirectory(s,i,!1);else if(e.isFile()){const e=path_1.default.basename(a),t=path_1.default.join(i,e);if(fs_extra_1.default.existsSync(t))throw new Error(`fail to copy ${s}, overwrite is not allowed`);fs_extra_1.default.copyFileSync(s,t)}}}copyDirectory(e,i,t=!0){if(fs_extra_1.default.ensureDirSync(i),t)fs_extra_1.default.copySync(e,i);else{fs_extra_1.default.readdirSync(e).forEach((n=>{const a=path_1.default.join(e,n),s=path_1.default.join(i,n);if(fs_extra_1.default.statSync(a).isDirectory())this.copyDirectory(a,s,t);else{if(fs_extra_1.default.existsSync(s))throw new Error(`fail to copy ${a}, overwrite is not allowed`);fs_extra_1.default.copyFileSync(a,s)}}))}}}exports.default=new buildCloudManager;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.printFoundDevices=exports.formattedDeviceName=exports.matchingDevice=exports.findMatchingSimulator=exports.getDevices=exports.parseXctraceIOSDevicesList=void 0;const tslib_1=require("tslib"),execa=tslib_1.__importStar(require("execa")),env_1=require("../../../utils/env"),miniappBuilder=tslib_1.__importStar(require("../../../utils/miniapp-builder"));function parseIOSDevicesList(e){const i=[];return e.split("\n").forEach(e=>{const t=e.match(/(.*?) (\(([0-9.]+)\) )?\[([0-9A-F-]+)\]( \(Simulator\))?/i);if(t){const[,e,,r,n,s]=t,c={name:e,udid:n};r?(c.version=r,c.type=s?"simulator":"device"):c.type="catalyst",i.push(c)}}),i}function parseXctraceIOSDevicesList(e){const i=[];let t=!1;return e.split("\n").forEach(e=>{"== Simulators =="===e&&(t=!0);const r=e.match(/^(.*?) (\(([0-9.]{3,})\) )?\(([0-9A-F-]{5,})\)$/i);if(r){const[,e,,n,s]=r,c={name:e,udid:s};n?(c.version=n,c.type=t?"simulator":"device"):c.type="catalyst",i.push(c)}}),i}async function getDevices(e){let i=[];const{recorder:t}=e||{};try{const e=await execa.default("xcrun",["xctrace","list","devices"],{env:(0,env_1.getProcessEnv)()});i=parseXctraceIOSDevicesList(""===e.stderr?e.stdout:e.stderr)}catch(e){try{i=parseIOSDevicesList(execa.sync("xcrun",["instruments","-s"],{env:(0,env_1.getProcessEnv)()}).stdout)}catch(e){}}let r=i.filter(e=>"device"===e.type);if(!r.length)try{r=await miniappBuilder.getIOSDevices(e||{}),r.forEach(e=>{i.find(i=>i.udid===e.udid)||i.push(e)})}catch(e){t?t.progress("get Devices error:"+e.message):console.error("get Devices error:",e)}return i.filter(e=>!!e.version)}function findMatchingSimulator(e,i){if(!e.devices)return null;const{devices:t}=e;let r,n,s=null;if(null==i?void 0:i.device){const e=i.device.match(/(.*)? (?:\((\d+\.\d+)?\))$/);void 0!==(null==e?void 0:e[2])?(r=e[2],s=e[1]):s=i.device}for(const e in t){const c=t[e];let o=e;if(o.startsWith("com.apple.CoreSimulator.SimRuntime.")&&(o=o.replace(/^com\.apple\.CoreSimulator\.SimRuntime\.([^-]+)-([^-]+)-([^-]+)$/g,"$1 $2.$3")),(o.includes("iOS")||o.includes("tvOS"))&&(!r||o.endsWith(r)))for(const e of c){if("(available)"!==e.availability&&"YES"!==e.isAvailable&&!0!==e.isAvailable)continue;const t="Booted"===e.state,r={udid:e.udid,name:e.name,booted:t,version:o};if(null==i?void 0:i.udid){if(e.udid===i.udid)return r}else{if(t&&null===s)return r;e.name!==s||n||(n=r)}}}return n}function matchingDevice(e,i,t){if(!0===i){const i=e.find(e=>"device"===e.type);return i?(t.progress(`Using first available device named "${i.name}" due to lack of name supplied.`),i):void t.progress("No iOS devices connected.")}const r=e.find(e=>e.name===i||formattedDeviceName(e)===i);if(!r)throw new Error(`Could not find a device named: "${String(i)} ${printFoundDevices(e)}}".`);return r}function formattedDeviceName(e){return e.version?`${e.name} (${e.version})`:e.name}function printFoundDevices(e){return["Available devices:",...e.map(e=>` - ${e.name} (${e.udid})`)].join("\n")}exports.parseXctraceIOSDevicesList=parseXctraceIOSDevicesList,exports.getDevices=getDevices,exports.findMatchingSimulator=findMatchingSimulator,exports.matchingDevice=matchingDevice,exports.formattedDeviceName=formattedDeviceName,exports.printFoundDevices=printFoundDevices;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.parseXctraceIOSDevicesList=parseXctraceIOSDevicesList,exports.getDevices=getDevices,exports.findMatchingSimulator=findMatchingSimulator,exports.matchingDevice=matchingDevice,exports.formattedDeviceName=formattedDeviceName,exports.printFoundDevices=printFoundDevices;const tslib_1=require("tslib"),execa=tslib_1.__importStar(require("execa")),env_1=require("../../../utils/env"),miniappBuilder=tslib_1.__importStar(require("../../../utils/miniapp-builder"));function parseIOSDevicesList(e){const i=[];return e.split("\n").forEach((e=>{const t=e.match(/(.*?) (\(([0-9.]+)\) )?\[([0-9A-F-]+)\]( \(Simulator\))?/i);if(t){const[,e,,r,n,s]=t,c={name:e,udid:n};r?(c.version=r,c.type=s?"simulator":"device"):c.type="catalyst",i.push(c)}})),i}function parseXctraceIOSDevicesList(e){const i=[];let t=!1;return e.split("\n").forEach((e=>{"== Simulators =="===e&&(t=!0);const r=e.match(/^(.*?) (\(([0-9.]{3,})\) )?\(([0-9A-F-]{5,})\)$/i);if(r){const[,e,,n,s]=r,c={name:e,udid:s};n?(c.version=n,c.type=t?"simulator":"device"):c.type="catalyst",i.push(c)}})),i}async function getDevices(e){let i=[];const{recorder:t}=e||{};try{const e=await execa.default("xcrun",["xctrace","list","devices"],{env:(0,env_1.getProcessEnv)()});i=parseXctraceIOSDevicesList(""===e.stderr?e.stdout:e.stderr)}catch(e){try{i=parseIOSDevicesList(execa.sync("xcrun",["instruments","-s"],{env:(0,env_1.getProcessEnv)()}).stdout)}catch(e){}}let r=i.filter((e=>"device"===e.type));if(!r.length)try{r=await miniappBuilder.getIOSDevices(e||{}),r.forEach((e=>{i.find((i=>i.udid===e.udid))||i.push(e)}))}catch(e){t?t.progress(`get Devices error:${e.message}`):console.error("get Devices error:",e)}return i.filter((e=>!!e.version))}function findMatchingSimulator(e,i){if(!e.devices)return null;const{devices:t}=e;let r,n,s=null;if(null==i?void 0:i.device){const e=i.device.match(/(.*)? (?:\((\d+\.\d+)?\))$/);void 0!==(null==e?void 0:e[2])?(r=e[2],s=e[1]):s=i.device}for(const e in t){const c=t[e];let a=e;if(a.startsWith("com.apple.CoreSimulator.SimRuntime.")&&(a=a.replace(/^com\.apple\.CoreSimulator\.SimRuntime\.([^-]+)-([^-]+)-([^-]+)$/g,"$1 $2.$3")),(a.includes("iOS")||a.includes("tvOS"))&&(!r||a.endsWith(r)))for(const e of c){if("(available)"!==e.availability&&"YES"!==e.isAvailable&&!0!==e.isAvailable)continue;const t="Booted"===e.state,r={udid:e.udid,name:e.name,booted:t,version:a};if(null==i?void 0:i.udid){if(e.udid===i.udid)return r}else{if(t&&null===s)return r;e.name!==s||n||(n=r)}}}return n}function matchingDevice(e,i,t){if(!0===i){const i=e.find((e=>"device"===e.type));return i?(t.progress(`Using first available device named "${i.name}" due to lack of name supplied.`),i):void t.progress("No iOS devices connected.")}const r=e.find((e=>e.name===i||formattedDeviceName(e)===i));if(!r)throw new Error(`Could not find a device named: "${String(i)} ${printFoundDevices(e)}}".`);return r}function formattedDeviceName(e){return e.version?`${e.name} (${e.version})`:e.name}function printFoundDevices(e){return["Available devices:",...e.map((e=>` - ${e.name} (${e.udid})`))].join("\n")}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.IOSUtils=void 0;const tslib_1=require("tslib"),child_process=tslib_1.__importStar(require("child_process")),path_1=tslib_1.__importDefault(require("path")),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),env_1=require("../../../utils/env"),deviceUtils=tslib_1.__importStar(require("./device")),projectConfigUtils=tslib_1.__importStar(require("./projectconfig")),cp_1=require("../../../utils/cp"),miniapp_builder_1=require("../../../utils/miniapp-builder"),usbProcess_1=require("../../../utils/usbProcess"),miniappJson_1=require("../../../utils/miniappJson"),singletontask_1=require("../../../utils/singletontask"),buildCloud_1=tslib_1.__importStar(require("./buildCloud")),tools_1=require("../../../utils/tools"),codesign_1=require("../../../utils/codesign"),ProjectMiniappJsonSplashScreenThemeKey="__splashscreenTheme",_iconInfoMap={appStore1024:{size:[1024,1024],scale:1,idiom:"ios-marketing",required:!0},mainIcon120:{size:[60,60],scale:2,idiom:"iphone",required:!0},mainIcon180:{size:[60,60],scale:3,idiom:"iphone"},spotlightIcon80:{size:[40,40],scale:2,idiom:"iphone"},spotlightIcon120:{size:[40,40],scale:3,idiom:"iphone"},settingsIcon58:{size:[29,29],scale:2,idiom:"iphone"},settingsIcon87:{size:[29,29],scale:3,idiom:"iphone"},notificationIcon40:{size:[20,20],scale:2,idiom:"iphone"},notificationIcon60:{size:[20,20],scale:3,idiom:"iphone"},ipadMainIcon152:{size:[76,76],scale:2,idiom:"ipad"},ipadMainIcon167:{size:[83.5,83.5],scale:2,idiom:"ipad"},ipadSpotlightIcon40:{size:[40,40],scale:1,idiom:"ipad"},ipadSpotlightIcon80:{size:[40,40],scale:2,idiom:"ipad"},ipadSettingsIcon29:{size:[29,29],scale:1,idiom:"ipad"},ipadSpotlightIcon58:{size:[29,29],scale:2,idiom:"ipad"},ipadNotificationIcon20:{size:[20,20],scale:1,idiom:"ipad"},ipadNotificationIcon40:{size:[20,20],scale:2,idiom:"ipad"}},_allowTheme=["Light","LightSpecial","Dark","DarkSpecial","Default"],_getDepReg=e=>new RegExp(`s.subspec '${e}'.*\n(?:.*\n)*?(?:.*sp.vendored_frameworks = \\[\n)((?:.*'.*?'.*\n)*?)(?:.*\\]\n)`,"m"),buildIOSPluginTask={};class IOSUtils{constructor(e,i={},t,o){this.root=e,this.userConfig=i,this.miniappDirPath=t,this.devtoolsVersion=o}getProjectConfig(){const e=projectConfigUtils.getProjectConfig(this.root,this.userConfig);if(!e)throw new Error("iOS project folder not found. Are you sure this is a miniapp project?");return e}getBundleId(e){return child_process.execFileSync("/usr/libexec/PlistBuddy",["-c","Print:CFBundleIdentifier",path_1.default.join(e,"Info.plist")],{encoding:"utf8",env:(0,env_1.getProcessEnv)()}).trim()}tryInstallPod(e,i){const t=this.getProjectConfig(),{sourceDir:o}=t,n={cwd:o,env:(0,env_1.getProcessEnv)()};i.progress("export LANG=en_US.UTF-8 && pod install"),child_process.execSync("export LANG=en_US.UTF-8 && pod install",n)}async runLocal(e,i){const t=this.getProjectConfig(),{sourceDir:o}=t;process.chdir(o),this.tryInstallPod(e,i);const n=path_1.default.basename(t.name,path_1.default.extname(t.name)),s=e.scheme||n;if(i.progress(`Found Xcode ${t.isWorkspace?"workspace":"project"} "${t.name}"`),e.device||e.udid){if(e.udid||e.device){const o=await deviceUtils.getDevices({recorder:i}),n=o.find(i=>i.udid===e.udid||i.name===e.device);if(!n)throw new Error(`Could not find a device with udid(${e.udid}) or device(${e.device}). ${deviceUtils.printFoundDevices(o)}`);if("simulator"===n.type)return void await this.runOnSimulatorLocal(t,s,e,i);await this.runOnDeviceLocal(t,s,n,i)}}else await this.runOnSimulatorLocal(t,s,e,i)}async runCloud(e,i){var t;try{const{deviceType:o,udid:n,projectPath:s,demoIpaPath:r,sdkPath:a,bindingInfo:c,certificateInfo:l,arch:d="arm64",pluginDirList:u,miniappCacheDirPath:p,theme:h,i18nInfo:f,debugInfo:_,cacheAssetCarPath:m}=e,g=buildCloud_1.default.generateTempDemoIpaPath(r),b="simulator"===o,P=(0,miniappJson_1.tryGetIOSMiniappJson)(s);let v=c;if(l.signType===miniapp_builder_1.miniappSinTypes.appleId.type){const{mobileapp_info:e={}}=v;v=Object.assign(Object.assign({},v),{mobileapp_info:Object.assign(Object.assign({},e),{bundle_id:miniapp_builder_1.DEFAULT_BUNDLE_ID,debug_ios_bundle_id:miniapp_builder_1.DEFAULT_BUNDLE_ID})})}const y=await buildCloud_1.default.updateIOSInfoPlistInfo(s,v,g,P,i,f);await buildCloud_1.default.updateIOSAppConfigPlistInfo(s,v,g,P,a,b,i,h,f),await buildCloud_1.default.updateIOSAppexInfoPlistInfo(v,g,P,y,i),await buildCloud_1.default.updateIOSIcons(s,g,"",P,!1,i,!1,m),await buildCloud_1.default.updateSplashScreen(s,g,P,i,h,f),await buildCloud_1.default.updateSplashScreenVideo(s,g,P,i,f),await buildCloud_1.default.updateExtendedSdk(v,g,a,d,P,_,i),await buildCloud_1.default.updatePlugin(g,u,s,P,p,!1,y,i);const S=await buildCloud_1.default.getEntitlements(v,g,P,i);if(await buildCloud_1.default.updateIOSAppResource(s,g,P,i),"device"===o){const{mobileapp_info:e={}}=v,o=e.ios_flag&&e.bundle_id||e.debug_ios_bundle_id;await(0,miniapp_builder_1.signAndInstallOrExport)(s,g,p,l,{bundleId:o,install:!0,deviceId:n,entitlements:S,isPublish:!!(null===(t=null==l?void 0:l.selfCertificate)||void 0===t?void 0:t.isPublish)},{recorder:i,miniappDirPath:this.miniappDirPath,devtoolsVersion:this.devtoolsVersion})}else await this.runOnSimulatorCloud(g,{udid:n},i)}catch(e){throw new Error(e.message)}}async buildLocal(e,i){const t=this.getProjectConfig();process.chdir(t.sourceDir);const o=path_1.default.basename(t.name,path_1.default.extname(t.name)),n=e.scheme||o;this.tryInstallPod(e,i),i.progress("start build ipa...");const s=await this.buildProjectArchive(t,{output:e.output,scheme:n},i),r=await this.exportArchive(t,s,e,i);return console.log("Successfully build ipa: "+r),r}async buildCloud(e,i){try{const{projectPath:t,certificateInfo:o,miniappCacheDirPath:n}=e,s=await buildCloud_1.default.buildCloud(e,i),{demoIpaPath:r,opts:a}=s,c={recorder:i,miniappDirPath:this.miniappDirPath,devtoolsVersion:this.devtoolsVersion};s.isPublish||e.CILocalBuild||await(0,miniapp_builder_1.signAndInstallOrExport)(t,r,n,o,a,c)}catch(e){throw new Error(e.message)}}async genProjectMaterialMap(e,i,t,o){var n,s;const r=buildCloud_1.remoteBuildProjectMaterialAbsoluteCacheDir,a=path_1.default.join(i,r),c=(0,miniappJson_1.tryGetIOSMiniappJson)(e);function l(e,i){const t=fs_extra_1.default.lstatSync(e);fs_extra_1.default.ensureDirSync(path_1.default.dirname(i)),t.isDirectory()?fs_extra_1.default.copySync(e,i):fs_extra_1.default.copyFileSync(e,i)}function d(t,n,s=!0){if(!n){if(s)return"";throw new Error(`file cant be empty for cloud build, key: ${t} , fileName: ${n}`)}if(path_1.default.isAbsolute(n)){const e=path_1.default.basename(n);if(!fs_extra_1.default.existsSync(n)){if(s)return"";throw new Error(`file cant be empty for cloud build, key: ${t} , fileName: ${n}`)}const i=(0,tools_1.generateMD5)(n);return l(n,path_1.default.join(a,`${i}_${e}`)),path_1.default.join(r,e)}const c=path_1.default.join(e,n),d=path_1.default.join(i,n);if(!fs_extra_1.default.existsSync(c)){if(s)return"";throw new Error(`file cant be empty for cloud build, key: ${t} , fileName: ${n}`)}return l(c,d),o.progress("prepare material for cloud build: "+n),n}fs_extra_1.default.ensureDirSync(a);const{privacy:u={},icons:p={},splashscreen:h={},buildCloud:f={}}=c,_=d("project.miniapp.json","project.miniapp.json",!1),m=d("project.config.json","project.config.json",!1),g=(0,miniappJson_1.getMiniprogramRoot)(e),b=d("app.json",path_1.default.join(g,"app.json"),!1),{template:P,contentViewImage:v,cancelButtonImage:y,confirmButtonImage:S}=u,w=d("privacy template",P),I=d("privacy contentViewImage",v),x=d("privacy cancelButtonImage",y),j=d("privacy confirmButtonImage",S),E=[];for(const e in p)if(p[e]){const i=d("icons."+e,p[e],!1);i&&E.push(i)}const O=d("splashscreen.customImage",h.customImage),D=d("splashscreen.customVideo",h.customVideo),{p12:C,profile:A,tpnsProfile:$}=f,T=d("p12 Path",C,!1),k=d("profile Path",A,!1);let B=void 0;!0===(null===(n=null==c?void 0:c.tpush)||void 0===n?void 0:n.useExtendedLib_WeAppTPNS)&&(B=d("tpns profile Path",$,!0!==(null===(s=null==c?void 0:c.tpush)||void 0===s?void 0:s.useExtendedLib_WeAppTPNS)));const U="miniapp/ios/i18nInfo.json",F=path_1.default.join(e,U),L=d("i18n",U,!0);if(fs_extra_1.default.existsSync(F)){const i=function(e,i){function t(i,t,o){if(t[o]&&"object"==typeof t[o][i])for(const n in t[o][i])if("object"==typeof t[o][i]){const s=t[o][i][n];if("string"==typeof s&&s.length>0){fs_extra_1.default.existsSync(path_1.default.isAbsolute(s)?s:path_1.default.join(e,s))&&d(`i18nFiles.${o}.${n}`,s,!0)}}}try{const o=fs_extra_1.default.readJSONSync(path_1.default.join(e,i));for(const e in o)t("ios",o,e),t("android",o,e)}catch(e){return e.message}}(e,U);if(i)throw o.message("error",i),new Error("copyi18NFiles error "+i)}const M=path_1.default.join(i,"project.miniapp.json");try{const e=fs_extra_1.default.readJsonSync(M);let{theme:i}=t;t.theme||(i="Dark"),e.__splashscreenTheme=i,fs_extra_1.default.writeJSONSync(M,e)}catch(e){throw new Error(`ReadWriteJsonFailed projectMiniappJsonCacheFilePath: ${M},error ${e.message}`)}const N=c["mini-plugin"];N&&Array.isArray(N.ios)&&N.ios.forEach(e=>{if(!0===e.open&&(e.resourcePath&&d(`mini-plugin ios ${e.pluginId}:${e.resourcePath}`,e.resourcePath),"object"==typeof e.appexProfiles))for(const i in e.appexProfiles){const t=e.appexProfiles[i];!0===t.enable&&("string"==typeof t.profilePath&&t.profilePath.length>0&&d("mini-plugin ios "+t.profilePath,t.profilePath),"string"==typeof t.distributeProfilePath&&t.distributeProfilePath.length>0&&d("mini-plugin ios "+t.distributeProfilePath,t.distributeProfilePath))}});return{projectMiniappJson:_,projectConfigJson:m,appJson:b,privacyJson:w,privacyContentViewImage:I,privacyCancelButtonImage:x,privacyConfirmButtonImage:j,icons:E,splashScreen:O,splashScreenVideo:D,p12:T,profile:k,tpnsProfile:B,i18nJson:L,resourcePath:d("ios resourcePath",c.resourcePath,!0)}}async codesignIOSApp(e,i){const{projectPath:t,demoIpaPath:o,opts:n}=e,s=await(0,codesign_1.codesignAndExport)(t,o,e.miniappCacheDir||"",n,i,e.isUsingTpush,!1,!0);if(!0!==s.success)throw new Error("Build ipa failed:"+(s.errMsg||"codesignAndExport failed"))}async packIOSCloudBuildMaterial(e,i){i.progress("start uploadProjectAllMaterial");const{projectPath:t,matrialDistPath:o,theme:n}=e;await this.genProjectMaterialMap(t,o,e,i);i.progress("packIOSCloudBuildMaterial done")}async initUSBConnectionProcess(e,i){await(0,usbProcess_1.startUSBManagerProcess)(e,i)&&i.progress("Init USB Process Successfully")}launchSimulator(e,i){let t;try{t=JSON.parse(child_process.execFileSync("xcrun",["simctl","list","--json","devices"],{encoding:"utf8",env:(0,env_1.getProcessEnv)()}))}catch(e){throw new Error("Could not get the simulator list from Xcode. Please open Xcode and try running project directly from there to resolve the remaining issues."+e.message)}const o=["iPhone 13","iPhone 12","iPhone 11"].reduce((e,i)=>e||deviceUtils.findMatchingSimulator(t,{device:i}),deviceUtils.findMatchingSimulator(t,e));if(!o)throw new Error("No simulator available with "+(e.device?`name "${e.device}"`:`udid "${e.udid}"`));const n=child_process.execFileSync("xcode-select",["-p"],{encoding:"utf8",env:(0,env_1.getProcessEnv)()}).trim();if(child_process.execFileSync("open",[n+"/Applications/Simulator.app","--args","-CurrentDeviceUDID",o.udid],{env:(0,env_1.getProcessEnv)()}),!o.booted){const e=deviceUtils.formattedDeviceName(o);i.progress("Launching "+e),child_process.spawnSync("xcrun",["simctl","boot",o.udid],{env:(0,env_1.getProcessEnv)()})}return o}async runOnSimulatorCloud(e,i,t){const{udid:o}=i,n=this.launchSimulator({udid:o},t);await this.installAppOnSimulator(n,e,t),await this.launchAppOnSimulator(n,e,t)}async runOnSimulatorLocal(e,i,t,o){const n=this.launchSimulator(t,o),{appPath:s}=await this.buildProjectApp(e,{udid:n.udid,scheme:i},o);await this.installAppOnSimulator(n,s,o),await this.launchAppOnSimulator(n,s,o)}async runOnDeviceLocal(e,i,t,o){const{appPath:n}=await this.buildProjectApp(e,{udid:t.udid,scheme:i},o);if("catalyst"===t.type){child_process.spawn(`${n}/${i}`,[],{detached:!0,stdio:"ignore",env:(0,env_1.getProcessEnv)()}).unref()}else{const e=["--bundle",n,"--id",t.udid,"--justlaunch"];o.progress("Installing and launching your app on "+t.name);const i=path_1.default.join(__dirname,"../../../vendor/ios-deploy/ios-deploy");await(0,cp_1.spawnSync)(i,e,{},o)}return o.progress("Install successfully the app to the device.")}buildProjectApp(e,i,t){return new Promise((o,n)=>{const{scheme:s,udid:r}=i,a=[e.isWorkspace?"-workspace":"-project",e.name,"-scheme",s];let c;r&&a.push("-destination","id="+r),t.progress(`Building (using "xcodebuild ${a.join(" ")}")`),this.xcbeautifyAvailable()?c=child_process.spawn("xcbeautify",[],{stdio:["pipe",process.stdout,process.stderr],env:(0,env_1.getProcessEnv)()}):this.xcprettyAvailable()&&(c=child_process.spawn("xcpretty",[],{stdio:["pipe",process.stdout,process.stderr],env:(0,env_1.getProcessEnv)()}));const l=child_process.spawn("xcodebuild",a,{env:(0,env_1.getProcessEnv)()});let d="",u="";l.stdout.on("data",e=>{const i=e.toString();t.progress(i),d+=i,c&&c.stdin.write(e)}),l.stderr.on("data",e=>{const i=e.toString();u+=i,t.progress(i)}),l.on("close",i=>{if(c&&c.stdin.end(),0!==i)return void n(new Error(` Failed to build iOS project.\n We ran "xcodebuild" command but it exited with error code ${i}. To debug build\n logs further, consider building your app with Xcode.app, by opening\n ${e.name}.\n ${c?void 0:`${d}\n${u}`}\n `));let r;try{r=this.getBuildInfo(e,d,s)}catch(e){n(e)}t.progress("Successfully built the app"),o(r)})})}async installAppOnSimulator(e,i,t){const o=["simctl","install",e.udid,i];await(0,cp_1.spawnSync)("xcrun",o,{},t)}async launchAppOnSimulator(e,i,t){const o=this.getBundleId(i),n=["simctl","launch",e.udid,o];await(0,cp_1.spawnSync)("xcrun",n,{},t),t.progress("Successfully launched the app on the simulator")}async buildProjectArchive(e,i,t){const{output:o,scheme:n,udid:s}=i,r=path_1.default.join(o,"./app"),{sourceDir:a}=e;fs_extra_1.default.ensureDirSync(path_1.default.dirname(r));const c=["archive",e.isWorkspace?"-workspace":"-project",e.name,"-scheme",n,"-archivePath",r];s&&c.push("-destination","id="+s);try{if(await(0,cp_1.spawnSync)("xcodebuild",c,{cwd:a},t),!fs_extra_1.default.existsSync(r+".xcarchive"))throw new Error(`Failed to build iOS project.\n ${r+".xcarchive"} does not found\n `);return t.progress(`Successfully archive the app: ${r}.xcarchive`),r+".xcarchive"}catch(i){throw new Error(`Failed to build iOS project. To debug build\n logs further, consider building your app with Xcode.app, by opening\n ${e.name}.\n `)}}async exportArchive(e,i,t,o){const n=path_1.default.join(t.output,"ipa");fs_extra_1.default.ensureDirSync(n),fs_extra_1.default.emptyDirSync(n);const{exportOptionPlistPath:s}=t;if(!s)throw new Error("build ios ipa require exportOptionPlistPath in project.miniapp.json");let r="";r=path_1.default.isAbsolute(s)?s:path_1.default.join(t.projectPath,s);const a=["-exportArchive","-archivePath",i,"-exportOptionsPlist",r,"-exportPath",n];try{await(0,cp_1.spawnSync)("xcodebuild",a,{cwd:e.sourceDir},o)}catch(i){throw new Error(`To debug build\n logs further, consider building your app with Xcode.app, by opening\n ${e.name}.\n `)}return fs_extra_1.default.removeSync(i),n}getTargetPaths(e){const i=JSON.parse(e);for(const e in i){if("app"===i[e].buildSettings.WRAPPER_EXTENSION)return{targetBuildDir:i[e].buildSettings.TARGET_BUILD_DIR,executableFolderPath:i[e].buildSettings.EXECUTABLE_FOLDER_PATH}}return{}}getBuildInfo(e,i,t){const o=this.getPlatformName(i),n=[e.isWorkspace?"-workspace":"-project",e.name,"-scheme",t,"-sdk",o,"-showBuildSettings","-json"].join(" "),s=child_process.execSync("xcodebuild "+n,{encoding:"utf8",cwd:e.sourceDir,env:(0,env_1.getProcessEnv)()}),r=this.getBuildProductDir(i),{executableFolderPath:a}=this.getTargetPaths(s);if(!a)throw new Error("Failed to get the app name.");return{sdk:o,appPath:`${r}/${a}`}}getPlatformName(e){const i=/export PLATFORM_NAME\\?="?(\w+)"?$/m.exec(e);if(!i)throw new Error("Couldn't find PLATFORM_NAME in xcodebuild output.");return i[1]}getBuildProductDir(e){const i=/export BUILT_PRODUCTS_DIR\\?="?(.+)"?$/m.exec(e);if(!i)throw new Error("Couldn't find BUILT_PRODUCTS_DIR in xcodebuild output.");return i[1]}xcbeautifyAvailable(){try{child_process.execSync("xcbeautify --version",{stdio:[0,"pipe","ignore"],env:(0,env_1.getProcessEnv)()})}catch(e){return!1}return!0}xcprettyAvailable(){try{child_process.execSync("xcpretty --version",{stdio:[0,"pipe","ignore"],env:(0,env_1.getProcessEnv)()})}catch(e){return!1}return!0}async buildPlugin(e,i){const{pluginId:t,projectPath:o,buildShellPath:n}=e;i.progress("start build native plugin...");try{const e=[o,t];fs_extra_1.default.chmodSync(n,"777"),buildIOSPluginTask[t]?(i.message("error","存在未结束的插件构建任务,需等待构建结束..."),await buildIOSPluginTask[t].getResult(!0)):(buildIOSPluginTask[t]=new singletontask_1.SingletonTask(cp_1.spawnSyncExecShell.bind(null,n,e,{},i)),await buildIOSPluginTask[t].getResult(!0),buildIOSPluginTask[t]=void 0)}catch(e){throw buildIOSPluginTask[t]=void 0,new Error("build plugin failed: "+e)}}async writeI18NInfoFile(e,i,t){Object.keys(i).forEach(o=>{if("base"===o)return;let n="";Object.keys(t).forEach(e=>{var s,r,a,c;(null===(r=null===(s=i[o])||void 0===s?void 0:s.ios)||void 0===r?void 0:r[t[e]])&&(n+=`${e} = "${null===(c=null===(a=i[o])||void 0===a?void 0:a.ios)||void 0===c?void 0:c[t[e]]}";\n`)}),n&&(fs_extra_1.default.ensureDirSync(path_1.default.join(e,o+".lproj")),fs_extra_1.default.writeFileSync(path_1.default.join(e,o+".lproj/InfoPlist.strings"),n))})}}exports.IOSUtils=IOSUtils;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.IOSUtils=void 0;const tslib_1=require("tslib"),child_process=tslib_1.__importStar(require("child_process")),path_1=tslib_1.__importDefault(require("path")),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),env_1=require("../../../utils/env"),deviceUtils=tslib_1.__importStar(require("./device")),projectConfigUtils=tslib_1.__importStar(require("./projectconfig")),cp_1=require("../../../utils/cp"),miniapp_builder_1=require("../../../utils/miniapp-builder"),usbProcess_1=require("../../../utils/usbProcess"),miniappJson_1=require("../../../utils/miniappJson"),singletontask_1=require("../../../utils/singletontask"),buildCloud_1=tslib_1.__importStar(require("./buildCloud")),tools_1=require("../../../utils/tools"),codesign_1=require("../../../utils/codesign"),ProjectMiniappJsonSplashScreenThemeKey="__splashscreenTheme",_iconInfoMap={appStore1024:{size:[1024,1024],scale:1,idiom:"ios-marketing",required:!0},mainIcon120:{size:[60,60],scale:2,idiom:"iphone",required:!0},mainIcon180:{size:[60,60],scale:3,idiom:"iphone"},spotlightIcon80:{size:[40,40],scale:2,idiom:"iphone"},spotlightIcon120:{size:[40,40],scale:3,idiom:"iphone"},settingsIcon58:{size:[29,29],scale:2,idiom:"iphone"},settingsIcon87:{size:[29,29],scale:3,idiom:"iphone"},notificationIcon40:{size:[20,20],scale:2,idiom:"iphone"},notificationIcon60:{size:[20,20],scale:3,idiom:"iphone"},ipadMainIcon152:{size:[76,76],scale:2,idiom:"ipad"},ipadMainIcon167:{size:[83.5,83.5],scale:2,idiom:"ipad"},ipadSpotlightIcon40:{size:[40,40],scale:1,idiom:"ipad"},ipadSpotlightIcon80:{size:[40,40],scale:2,idiom:"ipad"},ipadSettingsIcon29:{size:[29,29],scale:1,idiom:"ipad"},ipadSpotlightIcon58:{size:[29,29],scale:2,idiom:"ipad"},ipadNotificationIcon20:{size:[20,20],scale:1,idiom:"ipad"},ipadNotificationIcon40:{size:[20,20],scale:2,idiom:"ipad"}},_allowTheme=["Light","LightSpecial","Dark","DarkSpecial","Default"],_getDepReg=e=>new RegExp(`s.subspec '${e}'.*\n(?:.*\n)*?(?:.*sp.vendored_frameworks = \\[\n)((?:.*'.*?'.*\n)*?)(?:.*\\]\n)`,"m"),buildIOSPluginTask={};class IOSUtils{constructor(e,i={},t,o){this.root=e,this.userConfig=i,this.miniappDirPath=t,this.devtoolsVersion=o}getProjectConfig(){const e=projectConfigUtils.getProjectConfig(this.root,this.userConfig);if(!e)throw new Error("iOS project folder not found. Are you sure this is a miniapp project?");return e}getBundleId(e){return child_process.execFileSync("/usr/libexec/PlistBuddy",["-c","Print:CFBundleIdentifier",path_1.default.join(e,"Info.plist")],{encoding:"utf8",env:(0,env_1.getProcessEnv)()}).trim()}tryInstallPod(e,i){const t=this.getProjectConfig(),{sourceDir:o}=t,n={cwd:o,env:(0,env_1.getProcessEnv)()};i.progress("export LANG=en_US.UTF-8 && pod install"),child_process.execSync("export LANG=en_US.UTF-8 && pod install",n)}async runLocal(e,i){const t=this.getProjectConfig(),{sourceDir:o}=t;process.chdir(o),this.tryInstallPod(e,i);const n=path_1.default.basename(t.name,path_1.default.extname(t.name)),s=e.scheme||n;if(i.progress(`Found Xcode ${t.isWorkspace?"workspace":"project"} "${t.name}"`),e.device||e.udid){if(e.udid||e.device){const o=await deviceUtils.getDevices({recorder:i}),n=o.find((i=>i.udid===e.udid||i.name===e.device));if(!n)throw new Error(`Could not find a device with udid(${e.udid}) or device(${e.device}). ${deviceUtils.printFoundDevices(o)}`);if("simulator"===n.type)return void await this.runOnSimulatorLocal(t,s,e,i);await this.runOnDeviceLocal(t,s,n,i)}}else await this.runOnSimulatorLocal(t,s,e,i)}async runCloud(e,i){var t;try{const{deviceType:o,udid:n,projectPath:s,demoIpaPath:r,sdkPath:a,bindingInfo:c,certificateInfo:l,arch:d="arm64",pluginDirList:u,miniappCacheDirPath:p,theme:h,i18nInfo:f,debugInfo:_,cacheAssetCarPath:m}=e,g=buildCloud_1.default.generateTempDemoIpaPath(r),b="simulator"===o,P=(0,miniappJson_1.tryGetIOSMiniappJson)(s);let v=c;if(l.signType===miniapp_builder_1.miniappSinTypes.appleId.type){const{mobileapp_info:e={}}=v;v=Object.assign(Object.assign({},v),{mobileapp_info:Object.assign(Object.assign({},e),{bundle_id:miniapp_builder_1.DEFAULT_BUNDLE_ID,debug_ios_bundle_id:miniapp_builder_1.DEFAULT_BUNDLE_ID})})}const y=await buildCloud_1.default.updateIOSInfoPlistInfo(s,v,g,P,i,f);await buildCloud_1.default.updateIOSAppConfigPlistInfo(s,v,g,P,a,b,i,h,f),await buildCloud_1.default.updateIOSAppexInfoPlistInfo(v,g,P,y,i),await buildCloud_1.default.updateIOSIcons(s,g,"",P,!1,i,!1,m),await buildCloud_1.default.updateSplashScreen(s,g,P,i,h,f),await buildCloud_1.default.updateSplashScreenVideo(s,g,P,i,f),await buildCloud_1.default.updateExtendedSdk(v,g,a,d,P,_,i),await buildCloud_1.default.updatePlugin(g,u,s,P,p,!1,y,i);const S=await buildCloud_1.default.getEntitlements(v,g,P,i);if(await buildCloud_1.default.updateIOSAppResource(s,g,P,i),"device"===o){const{mobileapp_info:e={}}=v,o=e.ios_flag&&e.bundle_id||e.debug_ios_bundle_id;await(0,miniapp_builder_1.signAndInstallOrExport)(s,g,p,l,{bundleId:o,install:!0,deviceId:n,entitlements:S,isPublish:!!(null===(t=null==l?void 0:l.selfCertificate)||void 0===t?void 0:t.isPublish)},{recorder:i,miniappDirPath:this.miniappDirPath,devtoolsVersion:this.devtoolsVersion})}else await this.runOnSimulatorCloud(g,{udid:n},i)}catch(e){throw new Error(e.message)}}async buildLocal(e,i){const t=this.getProjectConfig();process.chdir(t.sourceDir);const o=path_1.default.basename(t.name,path_1.default.extname(t.name)),n=e.scheme||o;this.tryInstallPod(e,i),i.progress("start build ipa...");const s=await this.buildProjectArchive(t,{output:e.output,scheme:n},i),r=await this.exportArchive(t,s,e,i);return console.log(`Successfully build ipa: ${r}`),r}async buildCloud(e,i){try{const{projectPath:t,certificateInfo:o,miniappCacheDirPath:n}=e,s=await buildCloud_1.default.buildCloud(e,i),{demoIpaPath:r,opts:a}=s,c={recorder:i,miniappDirPath:this.miniappDirPath,devtoolsVersion:this.devtoolsVersion};s.isPublish||e.CILocalBuild||await(0,miniapp_builder_1.signAndInstallOrExport)(t,r,n,o,a,c)}catch(e){throw new Error(e.message)}}async genProjectMaterialMap(e,i,t,o){var n,s;const r=buildCloud_1.remoteBuildProjectMaterialAbsoluteCacheDir,a=path_1.default.join(i,r),c=(0,miniappJson_1.tryGetIOSMiniappJson)(e);function l(e,i){const t=fs_extra_1.default.lstatSync(e);fs_extra_1.default.ensureDirSync(path_1.default.dirname(i)),t.isDirectory()?fs_extra_1.default.copySync(e,i):fs_extra_1.default.copyFileSync(e,i)}function d(t,n,s=!0){if(!n){if(s)return"";throw new Error(`file cant be empty for cloud build, key: ${t} , fileName: ${n}`)}if(path_1.default.isAbsolute(n)){const e=path_1.default.basename(n);if(!fs_extra_1.default.existsSync(n)){if(s)return"";throw new Error(`file cant be empty for cloud build, key: ${t} , fileName: ${n}`)}const i=(0,tools_1.generateMD5)(n);return l(n,path_1.default.join(a,`${i}_${e}`)),path_1.default.join(r,e)}const c=path_1.default.join(e,n),d=path_1.default.join(i,n);if(!fs_extra_1.default.existsSync(c)){if(s)return"";throw new Error(`file cant be empty for cloud build, key: ${t} , fileName: ${n}`)}return l(c,d),o.progress(`prepare material for cloud build: ${n}`),n}fs_extra_1.default.ensureDirSync(a);const{privacy:u={},icons:p={},splashscreen:h={},buildCloud:f={}}=c,_=d("project.miniapp.json","project.miniapp.json",!1),m=d("project.config.json","project.config.json",!1),g=(0,miniappJson_1.getMiniprogramRoot)(e),b=d("app.json",path_1.default.join(g,"app.json"),!1),{template:P,contentViewImage:v,cancelButtonImage:y,confirmButtonImage:S}=u,w=d("privacy template",P),I=d("privacy contentViewImage",v),x=d("privacy cancelButtonImage",y),j=d("privacy confirmButtonImage",S),E=[];for(const e in p)if(p[e]){const i=d(`icons.${e}`,p[e],!1);i&&E.push(i)}const O=d("splashscreen.customImage",h.customImage),$=d("splashscreen.customVideo",h.customVideo),{p12:D,profile:C,tpnsProfile:A}=f,T=d("p12 Path",D,!1),k=d("profile Path",C,!1);let B;!0===(null===(n=null==c?void 0:c.tpush)||void 0===n?void 0:n.useExtendedLib_WeAppTPNS)&&(B=d("tpns profile Path",A,!0!==(null===(s=null==c?void 0:c.tpush)||void 0===s?void 0:s.useExtendedLib_WeAppTPNS)));const U="miniapp/ios/i18nInfo.json",F=path_1.default.join(e,U),L=d("i18n",U,!0);if(fs_extra_1.default.existsSync(F)){const i=function(e,i){function t(i,t,o){if(t[o]&&"object"==typeof t[o][i])for(const n in t[o][i])if("object"==typeof t[o][i]){const s=t[o][i][n];"string"==typeof s&&s.length>0&&fs_extra_1.default.existsSync(path_1.default.isAbsolute(s)?s:path_1.default.join(e,s))&&d(`i18nFiles.${o}.${n}`,s,!0)}}try{const o=fs_extra_1.default.readJSONSync(path_1.default.join(e,i));for(const e in o)t("ios",o,e),t("android",o,e)}catch(e){return e.message}}(e,U);if(i)throw o.message("error",i),new Error(`copyi18NFiles error ${i}`)}const M=path_1.default.join(i,"project.miniapp.json");try{const e=fs_extra_1.default.readJsonSync(M);let{theme:i}=t;t.theme||(i="Dark"),e.__splashscreenTheme=i,fs_extra_1.default.writeJSONSync(M,e)}catch(e){throw new Error(`ReadWriteJsonFailed projectMiniappJsonCacheFilePath: ${M},error ${e.message}`)}const N=c["mini-plugin"];N&&Array.isArray(N.ios)&&N.ios.forEach((e=>{if(!0===e.open&&(e.resourcePath&&d(`mini-plugin ios ${e.pluginId}:${e.resourcePath}`,e.resourcePath),"object"==typeof e.appexProfiles))for(const i in e.appexProfiles){const t=e.appexProfiles[i];!0===t.enable&&("string"==typeof t.profilePath&&t.profilePath.length>0&&d(`mini-plugin ios ${t.profilePath}`,t.profilePath),"string"==typeof t.distributeProfilePath&&t.distributeProfilePath.length>0&&d(`mini-plugin ios ${t.distributeProfilePath}`,t.distributeProfilePath))}}));return{projectMiniappJson:_,projectConfigJson:m,appJson:b,privacyJson:w,privacyContentViewImage:I,privacyCancelButtonImage:x,privacyConfirmButtonImage:j,icons:E,splashScreen:O,splashScreenVideo:$,p12:T,profile:k,tpnsProfile:B,i18nJson:L,resourcePath:d("ios resourcePath",c.resourcePath,!0)}}async codesignIOSApp(e,i){const{projectPath:t,demoIpaPath:o,opts:n}=e,s=await(0,codesign_1.codesignAndExport)(t,o,e.miniappCacheDir||"",n,i,e.isUsingTpush,!1,!0);if(!0!==s.success)throw new Error(`Build ipa failed:${s.errMsg||"codesignAndExport failed"}`)}async packIOSCloudBuildMaterial(e,i){i.progress("start uploadProjectAllMaterial");const{projectPath:t,matrialDistPath:o,theme:n}=e;await this.genProjectMaterialMap(t,o,e,i);i.progress("packIOSCloudBuildMaterial done")}async initUSBConnectionProcess(e,i){await(0,usbProcess_1.startUSBManagerProcess)(e,i)&&i.progress("Init USB Process Successfully")}launchSimulator(e,i){let t;try{t=JSON.parse(child_process.execFileSync("xcrun",["simctl","list","--json","devices"],{encoding:"utf8",env:(0,env_1.getProcessEnv)()}))}catch(e){throw new Error(`Could not get the simulator list from Xcode. Please open Xcode and try running project directly from there to resolve the remaining issues.${e.message}`)}const o=["iPhone 13","iPhone 12","iPhone 11"].reduce(((e,i)=>e||deviceUtils.findMatchingSimulator(t,{device:i})),deviceUtils.findMatchingSimulator(t,e));if(!o)throw new Error("No simulator available with "+(e.device?`name "${e.device}"`:`udid "${e.udid}"`));const n=child_process.execFileSync("xcode-select",["-p"],{encoding:"utf8",env:(0,env_1.getProcessEnv)()}).trim();if(child_process.execFileSync("open",[`${n}/Applications/Simulator.app`,"--args","-CurrentDeviceUDID",o.udid],{env:(0,env_1.getProcessEnv)()}),!o.booted){const e=deviceUtils.formattedDeviceName(o);i.progress(`Launching ${e}`),child_process.spawnSync("xcrun",["simctl","boot",o.udid],{env:(0,env_1.getProcessEnv)()})}return o}async runOnSimulatorCloud(e,i,t){const{udid:o}=i,n=this.launchSimulator({udid:o},t);await this.installAppOnSimulator(n,e,t),await this.launchAppOnSimulator(n,e,t)}async runOnSimulatorLocal(e,i,t,o){const n=this.launchSimulator(t,o),{appPath:s}=await this.buildProjectApp(e,{udid:n.udid,scheme:i},o);await this.installAppOnSimulator(n,s,o),await this.launchAppOnSimulator(n,s,o)}async runOnDeviceLocal(e,i,t,o){const{appPath:n}=await this.buildProjectApp(e,{udid:t.udid,scheme:i},o);if("catalyst"===t.type){child_process.spawn(`${n}/${i}`,[],{detached:!0,stdio:"ignore",env:(0,env_1.getProcessEnv)()}).unref()}else{const e=["--bundle",n,"--id",t.udid,"--justlaunch"];o.progress(`Installing and launching your app on ${t.name}`);const i=path_1.default.join(__dirname,"../../../vendor/ios-deploy/ios-deploy");await(0,cp_1.spawnSync)(i,e,{},o)}return o.progress("Install successfully the app to the device.")}buildProjectApp(e,i,t){return new Promise(((o,n)=>{const{scheme:s,udid:r}=i,a=[e.isWorkspace?"-workspace":"-project",e.name,"-scheme",s];let c;r&&a.push("-destination",`id=${r}`),t.progress(`Building (using "xcodebuild ${a.join(" ")}")`),this.xcbeautifyAvailable()?c=child_process.spawn("xcbeautify",[],{stdio:["pipe",process.stdout,process.stderr],env:(0,env_1.getProcessEnv)()}):this.xcprettyAvailable()&&(c=child_process.spawn("xcpretty",[],{stdio:["pipe",process.stdout,process.stderr],env:(0,env_1.getProcessEnv)()}));const l=child_process.spawn("xcodebuild",a,{env:(0,env_1.getProcessEnv)()});let d="",u="";l.stdout.on("data",(e=>{const i=e.toString();t.progress(i),d+=i,c&&c.stdin.write(e)})),l.stderr.on("data",(e=>{const i=e.toString();u+=i,t.progress(i)})),l.on("close",(i=>{if(c&&c.stdin.end(),0!==i)return void n(new Error(` Failed to build iOS project.\n We ran "xcodebuild" command but it exited with error code ${i}. To debug build\n logs further, consider building your app with Xcode.app, by opening\n ${e.name}.\n ${c?void 0:`${d}\n${u}`}\n `));let r;try{r=this.getBuildInfo(e,d,s)}catch(e){n(e)}t.progress("Successfully built the app"),o(r)}))}))}async installAppOnSimulator(e,i,t){const o=["simctl","install",e.udid,i];await(0,cp_1.spawnSync)("xcrun",o,{},t)}async launchAppOnSimulator(e,i,t){const o=this.getBundleId(i),n=["simctl","launch",e.udid,o];await(0,cp_1.spawnSync)("xcrun",n,{},t),t.progress("Successfully launched the app on the simulator")}async buildProjectArchive(e,i,t){const{output:o,scheme:n,udid:s}=i,r=path_1.default.join(o,"./app"),{sourceDir:a}=e;fs_extra_1.default.ensureDirSync(path_1.default.dirname(r));const c=["archive",e.isWorkspace?"-workspace":"-project",e.name,"-scheme",n,"-archivePath",r];s&&c.push("-destination",`id=${s}`);try{if(await(0,cp_1.spawnSync)("xcodebuild",c,{cwd:a},t),!fs_extra_1.default.existsSync(`${r}.xcarchive`))throw new Error(`Failed to build iOS project.\n ${r}.xcarchive does not found\n `);return t.progress(`Successfully archive the app: ${r}.xcarchive`),`${r}.xcarchive`}catch(i){throw new Error(`Failed to build iOS project. To debug build\n logs further, consider building your app with Xcode.app, by opening\n ${e.name}.\n `)}}async exportArchive(e,i,t,o){const n=path_1.default.join(t.output,"ipa");fs_extra_1.default.ensureDirSync(n),fs_extra_1.default.emptyDirSync(n);const{exportOptionPlistPath:s}=t;if(!s)throw new Error("build ios ipa require exportOptionPlistPath in project.miniapp.json");let r="";r=path_1.default.isAbsolute(s)?s:path_1.default.join(t.projectPath,s);const a=["-exportArchive","-archivePath",i,"-exportOptionsPlist",r,"-exportPath",n];try{await(0,cp_1.spawnSync)("xcodebuild",a,{cwd:e.sourceDir},o)}catch(i){throw new Error(`To debug build\n logs further, consider building your app with Xcode.app, by opening\n ${e.name}.\n `)}return fs_extra_1.default.removeSync(i),n}getTargetPaths(e){const i=JSON.parse(e);for(const e in i){if("app"===i[e].buildSettings.WRAPPER_EXTENSION)return{targetBuildDir:i[e].buildSettings.TARGET_BUILD_DIR,executableFolderPath:i[e].buildSettings.EXECUTABLE_FOLDER_PATH}}return{}}getBuildInfo(e,i,t){const o=this.getPlatformName(i),n=[e.isWorkspace?"-workspace":"-project",e.name,"-scheme",t,"-sdk",o,"-showBuildSettings","-json"].join(" "),s=child_process.execSync(`xcodebuild ${n}`,{encoding:"utf8",cwd:e.sourceDir,env:(0,env_1.getProcessEnv)()}),r=this.getBuildProductDir(i),{executableFolderPath:a}=this.getTargetPaths(s);if(!a)throw new Error("Failed to get the app name.");return{sdk:o,appPath:`${r}/${a}`}}getPlatformName(e){const i=/export PLATFORM_NAME\\?="?(\w+)"?$/m.exec(e);if(!i)throw new Error("Couldn't find PLATFORM_NAME in xcodebuild output.");return i[1]}getBuildProductDir(e){const i=/export BUILT_PRODUCTS_DIR\\?="?(.+)"?$/m.exec(e);if(!i)throw new Error("Couldn't find BUILT_PRODUCTS_DIR in xcodebuild output.");return i[1]}xcbeautifyAvailable(){try{child_process.execSync("xcbeautify --version",{stdio:[0,"pipe","ignore"],env:(0,env_1.getProcessEnv)()})}catch(e){return!1}return!0}xcprettyAvailable(){try{child_process.execSync("xcpretty --version",{stdio:[0,"pipe","ignore"],env:(0,env_1.getProcessEnv)()})}catch(e){return!1}return!0}async buildPlugin(e,i){const{pluginId:t,projectPath:o,buildShellPath:n}=e;i.progress("start build native plugin...");try{const e=[o,t];fs_extra_1.default.chmodSync(n,"777"),buildIOSPluginTask[t]?(i.message("error","存在未结束的插件构建任务,需等待构建结束..."),await buildIOSPluginTask[t].getResult(!0)):(buildIOSPluginTask[t]=new singletontask_1.SingletonTask(cp_1.spawnSyncExecShell.bind(null,n,e,{},i)),await buildIOSPluginTask[t].getResult(!0),buildIOSPluginTask[t]=void 0)}catch(e){throw buildIOSPluginTask[t]=void 0,new Error(`build plugin failed: ${e}`)}}async writeI18NInfoFile(e,i,t){Object.keys(i).forEach((o=>{if("base"===o)return;let n="";Object.keys(t).forEach((e=>{var s,r,a,c;(null===(r=null===(s=i[o])||void 0===s?void 0:s.ios)||void 0===r?void 0:r[t[e]])&&(n+=`${e} = "${null===(c=null===(a=i[o])||void 0===a?void 0:a.ios)||void 0===c?void 0:c[t[e]]}";\n`)})),n&&(fs_extra_1.default.ensureDirSync(path_1.default.join(e,`${o}.lproj`)),fs_extra_1.default.writeFileSync(path_1.default.join(e,`${o}.lproj/InfoPlist.strings`),n))}))}}exports.IOSUtils=IOSUtils;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.findAllPodfilePaths=exports.getProjectConfig=void 0;const tslib_1=require("tslib"),path=tslib_1.__importStar(require("path")),fs=tslib_1.__importStar(require("fs")),glob=tslib_1.__importStar(require("glob")),GLOB_EXCLUDE_PATTERN=["**/@(Pods|node_modules|Carthage)/**"];function getProjectConfig(e,t={}){const o=findXcodeProject(e);return o?Object.assign({sourceDir:e},o):null}function findXcodeProject(e){const t=fs.readdirSync(e);for(let e=t.sort().length-1;e>=0;e--){const o=t[e],r=path.extname(o);if(".xcworkspace"===r)return{name:o,isWorkspace:!0};if(".xcodeproj"===r)return{name:o,isWorkspace:!1}}return null}function findAllPodfilePaths(e){return glob.sync("**/Podfile",{cwd:e,ignore:GLOB_EXCLUDE_PATTERN})}exports.getProjectConfig=getProjectConfig,exports.findAllPodfilePaths=findAllPodfilePaths;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getProjectConfig=getProjectConfig,exports.findAllPodfilePaths=findAllPodfilePaths;const tslib_1=require("tslib"),path=tslib_1.__importStar(require("path")),fs=tslib_1.__importStar(require("fs")),glob=tslib_1.__importStar(require("glob")),GLOB_EXCLUDE_PATTERN=["**/@(Pods|node_modules|Carthage)/**"];function getProjectConfig(e,t={}){const r=findXcodeProject(e);return r?Object.assign({sourceDir:e},r):null}function findXcodeProject(e){const t=fs.readdirSync(e);for(let e=t.sort().length-1;e>=0;e--){const r=t[e],o=path.extname(r);if(".xcworkspace"===o)return{name:r,isWorkspace:!0};if(".xcodeproj"===o)return{name:r,isWorkspace:!1}}return null}function findAllPodfilePaths(e){return glob.sync("**/Podfile",{cwd:e,ignore:GLOB_EXCLUDE_PATTERN})}
@@ -1 +1 @@
1
- var _a,_b;process.env&&process.env.isDevtools&&require("../../utils/hackrequire/index"),Object.defineProperty(exports,"__esModule",{value:!0}),(null===(_a=process.env)||void 0===_a?void 0:_a.isDevtools)&&require("../../utils/hackrequire/index");const entryProcess_1=require("../../utils/subprocess/entryProcess"),processHandler_1=require("./processHandler");(0,entryProcess_1.runSubProcess)({initHandler:processHandler_1.initHandler,messageHandler:processHandler_1.messageHandler,timeout:(null===(_b=process.env)||void 0===_b?void 0:_b.timeout)||3e5});
1
+ var _a;process.env&&process.env.isDevtools&&require("../../utils/hackrequire/index"),Object.defineProperty(exports,"__esModule",{value:!0}),require("../../utils/processBootstrap").installProcessBootstrap({baseDir:__dirname,hackRequirePath:"../../utils/hackrequire/index",moduleFallbackPath:"../../../../../unpack/module-fallback"});const entryProcess_1=require("../../utils/subprocess/entryProcess"),processHandler_1=require("./processHandler");(0,entryProcess_1.runSubProcess)({initHandler:processHandler_1.initHandler,messageHandler:processHandler_1.messageHandler,timeout:(null===(_a=process.env)||void 0===_a?void 0:_a.timeout)||3e5});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.messageHandler=exports.onMessage=exports.destroy=exports.initHandler=void 0;const progressRecorder_1=require("../../utils/progressRecorder"),nativeCompiler_1=require("./nativeCompiler");let nativeCompiler,inited=!1;function processSend(e){emiter.emit("message",e)}async function initHandler(e){const{projectInfo:t,passData:i}=e.data;if(inited)return;const{miniappDirPath:n,devtoolsVersion:s}=i;nativeCompiler=new nativeCompiler_1.NativeCompiler({projectInfo:t,miniappDirPath:n,devtoolsVersion:s}),inited=!0}async function destroy(){nativeCompiler=void 0,inited=!1}exports.initHandler=initHandler,exports.destroy=destroy;const emiter=function(){const e={};return{on:(t,i)=>{e.hasOwnProperty(t)||(e[t]=[]),e[t].push(i)},emit:(t,...i)=>{const n=e[t];if((null==n?void 0:n.length)>0)for(const e of n)try{e(...i)}catch(e){}}}}(),onMessage=e=>{emiter.on("message",e)};async function messageHandler(e){if("event"!==e.type&&"request"===e.type){const{id:t,name:i,data:n}=e,s=t,a=new progressRecorder_1.Recorder((e,t,i)=>{processSend({type:"progress",id:e,taskId:s,status:t,message:i})});n.fullEnv&&(global.fullEnv=n.fullEnv);try{let e;const r=`${i}-${s}`;if("buildNative"===i)e=await a.run(r,async()=>await nativeCompiler.build(n,a));else if("runNative"===i)e=await a.run(r,async()=>await nativeCompiler.run(n,a));else if("buildNativePlugin"===i)e=await a.run(r,async()=>await nativeCompiler.buildPlugin(n,a));else if("packIOSCloudBuildMaterial"===i)e=await a.run(r,async()=>await nativeCompiler.packIOSCloudBuildMaterial(n,a));else if("initUSBConnectionProcess"===i)e=await a.run(r,async()=>await nativeCompiler.initUSBConnectionProcess(n,a));else{if("codesignIOSApp"!==i)throw new Error("unknown command "+i);e=await a.run(r,async()=>await nativeCompiler.codesignIOSApp(n,a))}processSend({type:"response",id:t,data:e})}catch(e){processSend({type:"response",id:t,data:null,error:{code:e.code||-1,message:e.message,stack:e.stack,path:e.path||""}})}}}exports.onMessage=onMessage,exports.messageHandler=messageHandler;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.onMessage=void 0,exports.initHandler=initHandler,exports.destroy=destroy,exports.messageHandler=messageHandler;const debug_1=require("../../utils/debug"),progressRecorder_1=require("../../utils/progressRecorder"),nativeCompiler_1=require("./nativeCompiler");let nativeCompiler,inited=!1;async function processSend(e){await(0,debug_1.shouldRunInMainProcess)()?emiter.emit("message",e):process.send(e)}async function initHandler(e){const{projectInfo:i,passData:n}=e.data;if(inited)return;const{miniappDirPath:t,devtoolsVersion:s}=n;nativeCompiler=new nativeCompiler_1.NativeCompiler({projectInfo:i,miniappDirPath:t,devtoolsVersion:s}),inited=!0}async function destroy(){nativeCompiler=void 0,inited=!1}const emiter=function(){const e={};return{on:(i,n)=>{e.hasOwnProperty(i)||(e[i]=[]),e[i].push(n)},emit:(i,...n)=>{const t=e[i];if((null==t?void 0:t.length)>0)for(const e of t)try{e(...n)}catch(e){}}}}(),onMessage=async e=>{emiter.on("message",e)};async function messageHandler(e){if("event"!==e.type&&"request"===e.type){const{id:i,name:n,data:t}=e,s=i,a=new progressRecorder_1.Recorder(((e,i,n)=>{processSend({type:"progress",id:e,taskId:s,status:i,message:n})}));t.fullEnv&&(global.fullEnv=t.fullEnv);try{let e;const r=`${n}-${s}`;if("buildNative"===n)e=await a.run(r,(async()=>await nativeCompiler.build(t,a)));else if("runNative"===n)e=await a.run(r,(async()=>await nativeCompiler.run(t,a)));else if("buildNativePlugin"===n)e=await a.run(r,(async()=>await nativeCompiler.buildPlugin(t,a)));else if("packIOSCloudBuildMaterial"===n)e=await a.run(r,(async()=>await nativeCompiler.packIOSCloudBuildMaterial(t,a)));else if("initUSBConnectionProcess"===n)e=await a.run(r,(async()=>await nativeCompiler.initUSBConnectionProcess(t,a)));else{if("codesignIOSApp"!==n)throw new Error(`unknown command ${n}`);e=await a.run(r,(async()=>await nativeCompiler.codesignIOSApp(t,a)))}processSend({type:"response",id:i,data:e})}catch(e){processSend({type:"response",id:i,data:null,error:{code:e.code||-1,message:e.message,stack:e.stack,path:e.path||""}})}}}exports.onMessage=onMessage;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.JSONConditionCompiler=void 0;const tslib_1=require("tslib"),lodash_1=tslib_1.__importDefault(require("lodash")),define_1=require("../../../../config/define"),config_1=require("../../../../config/config"),common_1=require("../../../../utils/common"),tools_1=require("../../../../utils/tools"),base_1=require("./base");class JSONConditionCompiler extends base_1.BaseConditionCompiler{doCompile(e){const{filePath:o,content:i,macroDefine:r}=e,t=i.toString();t||(0,common_1.throwError)({filePath:o,msg:"Empty file is NOT a valid json file",code:config_1.JSON_PARSE_ERR});const s=r.getDefines(),n=Object.values(define_1.PLATFORM),a=s.PLATFORM;let c={};try{c=JSON.parse(t)}catch(e){const i=(0,tools_1.formatJSONParseErr)({filePath:o,data:t,error:e});(0,common_1.throwError)({filePath:o,msg:i,code:config_1.JSON_PARSE_ERR})}const l=c[a]||("mini-weixin"===a?c["mini-wechat"]:{})||{};n.forEach(e=>{c[e]&&delete c[e]});const f=c.subPackages||c.subpackages,d=l.subPackages||l.subpackages;if(Array.isArray(f)&&Array.isArray(d)){for(const e in d){const o=d[e].root,i=d[e].pages;if(o&&i){const r=f.find(e=>e.root===o);r?(r.pages=[...new Set([...r.pages,...i])],r.name=d[e].name):f.push(d[e])}}return delete l.subPackages,delete l.subpackages,JSON.stringify(lodash_1.default.merge(c,l))}return JSON.stringify(lodash_1.default.merge(c,l))}}exports.JSONConditionCompiler=JSONConditionCompiler;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.JSONConditionCompiler=void 0;const tslib_1=require("tslib"),lodash_1=tslib_1.__importDefault(require("lodash")),define_1=require("../../../../config/define"),config_1=require("../../../../config/config"),common_1=require("../../../../utils/common"),tools_1=require("../../../../utils/tools"),base_1=require("./base");class JSONConditionCompiler extends base_1.BaseConditionCompiler{doCompile(e){const{filePath:o,content:i,macroDefine:r}=e,t=i.toString();t||(0,common_1.throwError)({filePath:o,msg:"Empty file is NOT a valid json file",code:config_1.JSON_PARSE_ERR});const s=r.getDefines(),n=Object.values(define_1.PLATFORM),a=s.PLATFORM;let c={};try{c=JSON.parse(t)}catch(e){const i=(0,tools_1.formatJSONParseErr)({filePath:o,data:t,error:e});(0,common_1.throwError)({filePath:o,msg:i,code:config_1.JSON_PARSE_ERR})}const l=c[a]||("mini-weixin"===a?c["mini-wechat"]:{})||{};n.forEach((e=>{c[e]&&delete c[e]}));const f=c.subPackages||c.subpackages,d=l.subPackages||l.subpackages;if(Array.isArray(f)&&Array.isArray(d)){for(const e in d){const o=d[e].root,i=d[e].pages;if(o&&i){const r=f.find((e=>e.root===o));r?(r.pages=[...new Set([...r.pages,...i])],r.name=d[e].name):f.push(d[e])}}return delete l.subPackages,delete l.subpackages,JSON.stringify(lodash_1.default.merge(c,l))}return JSON.stringify(lodash_1.default.merge(c,l))}}exports.JSONConditionCompiler=JSONConditionCompiler;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MacroConditionCompiler=void 0;const tslib_1=require("tslib"),expression_1=tslib_1.__importDefault(require("../../../../utils/expression")),base_1=require("./base");var IfType;!function(e){e[e.If=0]="If",e[e.Elif=1]="Elif"}(IfType||(IfType={}));const deleteFlag="-----mini-delete-flag-----";let useTripleSlash;class IfBlock{constructor(e,s,t=[],i=null,n=[]){this.startIx=e,this.endIx=s,this.elifIxs=t,this.elseIx=i,this.innerIfs=n}getIfRange(){const e=this.elifIxs.length>0?this.elifIxs[0]:null!==this.elseIx?this.elseIx:this.endIx;return[this.startIx,e]}getElifRange(e){if(this.elifIxs.length>e){return[this.elifIxs[e],this.elifIxs.length>e+1?this.elifIxs[e+1]:null!==this.elseIx?this.elseIx:this.endIx]}throw new Error(`Invalid elif index '${e}', there are only ${this.elifIxs.length} elifs.`)}getElseRange(){if(null!==this.elseIx)return[this.elseIx,this.endIx];throw new Error("Cannot use elseRange when elseIx is null.")}}class MacroConditionCompiler extends base_1.BaseConditionCompiler{constructor(){super(...arguments),this.getIFRegex=()=>".wxml"===this.type?/^[\s]*<!--[\s]*#(if|elif)[\s]+([\s\S]+)-->[\s]*$/g:".wxss"===this.type?/^[\s]*\/\*[\s]*#(if|elif)[\s]+([\s\S]+)\*\/[\s]*$/g:useTripleSlash?/^[\s]*\/\/\/[\s]*#(if|elif)[\s]+([\s\S]+)$/g:/^[\s]*\/\/[\s]*#(if|elif)[\s]+([\s\S]+)$/g,this.getELSERegex=()=>".wxml"===this.type?/^[\s]*<!--[\s]*#(else)[\s]*-->[\s]*$/g:".wxss"===this.type?/^[\s]*\/\*[\s]*#(else)[\s]*\*\/[\s]*$/g:useTripleSlash?/^[\s]*\/\/\/[\s]*#(else)[\s]*$/g:/^[\s]*\/\/[\s]*#(else)[\s]*$/g,this.getENDIFRegex=()=>".wxml"===this.type?/^[\s]*<!--[\s]*#(endif)[\s]*-->[\s]*$/g:".wxss"===this.type?/^[\s]*\/\*[\s]*#(endif)[\s]*\*\/[\s]*$/g:useTripleSlash?/^[\s]*\/\/\/[\s]*#(endif)[\s]*$/g:/^[\s]*\/\/[\s]*#(endif)[\s]*$/g,this.getFefineRegex=()=>".wxml"===this.type?/^[\s]*<!--[\s]*#define[\s]+(\S+)[\s]+(\S+)[\s]*-->[\s]*$/g:".wxss"===this.type?/^[\s]*\/\*[\s]*#define[\s]+(\S+)[\s]+(\S+)[\s]*\*\/[\s]*$/g:useTripleSlash?/^[\s]*\/\/\/[\s]*#define[\s]+(\S+)[\s]+(\S+)[\s]*$/g:/^[\s]*\/\/[\s]*#define[\s]+(\S+)[\s]+(\S+)[\s]*$/g}getFileDefines(e){if(-1===e.indexOf("#define"))return{};const s=e.split("\n"),t={};for(let e=0;e<s.length;e++)if(this.matchDefine(s[e])){const{key:i,val:n}=this.parseDefine(s[e]);t[i]=n}return t}matchDefine(e){return null!==this.getFefineRegex().exec(e)}parseDefine(e){const s=this.getFefineRegex().exec(e);if(s)return{key:s[1].trim(),val:s[2].trim()};throw new Error(`Could not parse #if: '${e}'.`)}applyDefines(e){for(let s=0;s<e.length;s++)this.matchDefine(e[s])&&(e[s]=deleteFlag)}findIFBlocks(e){const s=[];for(let t=0;t<e.length;t++)if(this.matchIF(e[t])){const i=this.parseIFBlock(e,t);s.push(i),t=i.endIx}return s}parseIFBlock(e,s){const t=[];let i,n=null;const l=[];for(let r=s+1;r<e.length;r++){const s=e[r];if(this.matchIF(s)){const s=this.parseIFBlock(e,r);l.push(s),r=s.endIx;continue}if(this.matchIF(s,IfType.Elif)){t.push(r);continue}if(this.matchELSE(s)){n=r;continue}if(this.matchENDIF(s)){i=r;break}}if(void 0===i)throw new Error(`#if without #endif on line ${s+1}.`);return new IfBlock(s,i,t,n,l)}matchIF(e,s=IfType.If){const t=this.getIFRegex().exec(e);return null!==t&&(s===IfType.If&&"if"===t[1]||s===IfType.Elif&&"elif"===t[1])}parseIF(e){const s=this.getIFRegex().exec(e);if(s)return s[2].trim();throw new Error(`Could not parse #if: '${e}'.`)}matchENDIF(e){const s=this.getENDIFRegex().exec(e);return Boolean(s)}matchELSE(e){const s=this.getELSERegex().exec(e);return Boolean(s)}applyIF(e,s,t,i=!1,n){let l=null;const r=this.parseIF(e[s.startIx]),o=(e,t)=>{if(i)throw new Error(`#if block lines [${s.startIx+1}-${s.endIx+1}]: Condition '${e}' is ${t?"TRUE":"FALSE"}. ${null!==l?`Including lines [${l[0]+1}-${l[1]+1}]`:"Excluding everything"} (${n})`)};if(this.evaluate(r,t))l=s.getIfRange(),o(r,!0);else{for(let i=0;i<s.elifIxs.length;i++){const n=e[s.elifIxs[i]],r=this.parseIF(n);if(this.evaluate(r,t)){l=s.getElifRange(i),o(r,!0);break}}null===l&&(null!==s.elseIx&&(l=s.getElseRange()),o(r,!1))}null!==l?(this.blankCode(e,s.startIx,l[0]),this.blankCode(e,l[1],s.endIx)):this.blankCode(e,s.startIx,s.endIx);for(const i of s.innerIfs)null!==l&&i.startIx>=l[0]&&i.startIx<=l[1]&&this.applyIF(e,i,t,this.verbose)}evaluate(e,s){let t;e=e.replace(/defined\(([a-z0-9]*)\)/gi,(e,s)=>`(typeof ${s} !== "undefined")`);try{t=new expression_1.default(e).parse()(s)}catch(e){t=!1}return t}blankCode(e,s,t=s){for(let i=s;i<=t;i++)e[i]=deleteFlag}doCompile(e){const{filePath:s,content:t,macroDefine:i}=e;try{const e=t.toString(),n=this.getFileDefines(e),l=Object.assign(Object.assign({},i.getDefines()),n);void 0===this.tripleSlash&&(this.tripleSlash=!1),useTripleSlash=this.tripleSlash;const r=e.split("\n");if(this.applyDefines(r),-1!==t.indexOf("#if")){const e=this.findIFBlocks(r);for(const t of e)this.applyIF(r,t,l,this.verbose,s)}return r.filter(e=>e!==deleteFlag).join("\n")}catch(e){throw new Error(`[PreCompiler]compile ${s} error:${e.message}`)}}}exports.MacroConditionCompiler=MacroConditionCompiler;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MacroConditionCompiler=void 0;const tslib_1=require("tslib"),expression_1=tslib_1.__importDefault(require("../../../../utils/expression")),base_1=require("./base");var IfType;!function(e){e[e.If=0]="If",e[e.Elif=1]="Elif"}(IfType||(IfType={}));const deleteFlag="-----mini-delete-flag-----";let useTripleSlash;class IfBlock{constructor(e,s,t=[],i=null,n=[]){this.startIx=e,this.endIx=s,this.elifIxs=t,this.elseIx=i,this.innerIfs=n}getIfRange(){const e=this.elifIxs.length>0?this.elifIxs[0]:null!==this.elseIx?this.elseIx:this.endIx;return[this.startIx,e]}getElifRange(e){if(this.elifIxs.length>e){return[this.elifIxs[e],this.elifIxs.length>e+1?this.elifIxs[e+1]:null!==this.elseIx?this.elseIx:this.endIx]}throw new Error(`Invalid elif index '${e}', there are only ${this.elifIxs.length} elifs.`)}getElseRange(){if(null!==this.elseIx)return[this.elseIx,this.endIx];throw new Error("Cannot use elseRange when elseIx is null.")}}class MacroConditionCompiler extends base_1.BaseConditionCompiler{constructor(){super(...arguments),this.getIFRegex=()=>".wxml"===this.type?/^[\s]*<!--[\s]*#(if|elif)[\s]+([\s\S]+)-->[\s]*$/g:".wxss"===this.type?/^[\s]*\/\*[\s]*#(if|elif)[\s]+([\s\S]+)\*\/[\s]*$/g:useTripleSlash?/^[\s]*\/\/\/[\s]*#(if|elif)[\s]+([\s\S]+)$/g:/^[\s]*\/\/[\s]*#(if|elif)[\s]+([\s\S]+)$/g,this.getELSERegex=()=>".wxml"===this.type?/^[\s]*<!--[\s]*#(else)[\s]*-->[\s]*$/g:".wxss"===this.type?/^[\s]*\/\*[\s]*#(else)[\s]*\*\/[\s]*$/g:useTripleSlash?/^[\s]*\/\/\/[\s]*#(else)[\s]*$/g:/^[\s]*\/\/[\s]*#(else)[\s]*$/g,this.getENDIFRegex=()=>".wxml"===this.type?/^[\s]*<!--[\s]*#(endif)[\s]*-->[\s]*$/g:".wxss"===this.type?/^[\s]*\/\*[\s]*#(endif)[\s]*\*\/[\s]*$/g:useTripleSlash?/^[\s]*\/\/\/[\s]*#(endif)[\s]*$/g:/^[\s]*\/\/[\s]*#(endif)[\s]*$/g,this.getFefineRegex=()=>".wxml"===this.type?/^[\s]*<!--[\s]*#define[\s]+(\S+)[\s]+(\S+)[\s]*-->[\s]*$/g:".wxss"===this.type?/^[\s]*\/\*[\s]*#define[\s]+(\S+)[\s]+(\S+)[\s]*\*\/[\s]*$/g:useTripleSlash?/^[\s]*\/\/\/[\s]*#define[\s]+(\S+)[\s]+(\S+)[\s]*$/g:/^[\s]*\/\/[\s]*#define[\s]+(\S+)[\s]+(\S+)[\s]*$/g}getFileDefines(e){if(-1===e.indexOf("#define"))return{};const s=e.split("\n"),t={};for(let e=0;e<s.length;e++)if(this.matchDefine(s[e])){const{key:i,val:n}=this.parseDefine(s[e]);t[i]=n}return t}matchDefine(e){return null!==this.getFefineRegex().exec(e)}parseDefine(e){const s=this.getFefineRegex().exec(e);if(s)return{key:s[1].trim(),val:s[2].trim()};throw new Error(`Could not parse #if: '${e}'.`)}applyDefines(e){for(let s=0;s<e.length;s++)this.matchDefine(e[s])&&(e[s]=deleteFlag)}findIFBlocks(e){const s=[];for(let t=0;t<e.length;t++)if(this.matchIF(e[t])){const i=this.parseIFBlock(e,t);s.push(i),t=i.endIx}return s}parseIFBlock(e,s){const t=[];let i,n=null;const l=[];for(let r=s+1;r<e.length;r++){const s=e[r];if(this.matchIF(s)){const s=this.parseIFBlock(e,r);l.push(s),r=s.endIx;continue}if(this.matchIF(s,IfType.Elif)){t.push(r);continue}if(this.matchELSE(s)){n=r;continue}if(this.matchENDIF(s)){i=r;break}}if(void 0===i)throw new Error(`#if without #endif on line ${s+1}.`);return new IfBlock(s,i,t,n,l)}matchIF(e,s=IfType.If){const t=this.getIFRegex().exec(e);return null!==t&&(s===IfType.If&&"if"===t[1]||s===IfType.Elif&&"elif"===t[1])}parseIF(e){const s=this.getIFRegex().exec(e);if(s)return s[2].trim();throw new Error(`Could not parse #if: '${e}'.`)}matchENDIF(e){const s=this.getENDIFRegex().exec(e);return Boolean(s)}matchELSE(e){const s=this.getELSERegex().exec(e);return Boolean(s)}applyIF(e,s,t,i=!1,n){let l=null;const r=this.parseIF(e[s.startIx]),o=(e,t)=>{if(i)throw new Error(`#if block lines [${s.startIx+1}-${s.endIx+1}]: Condition '${e}' is ${t?"TRUE":"FALSE"}. ${null!==l?`Including lines [${l[0]+1}-${l[1]+1}]`:"Excluding everything"} (${n})`)};if(this.evaluate(r,t))l=s.getIfRange(),o(r,!0);else{for(let i=0;i<s.elifIxs.length;i++){const n=e[s.elifIxs[i]],r=this.parseIF(n);if(this.evaluate(r,t)){l=s.getElifRange(i),o(r,!0);break}}null===l&&(null!==s.elseIx&&(l=s.getElseRange()),o(r,!1))}null!==l?(this.blankCode(e,s.startIx,l[0]),this.blankCode(e,l[1],s.endIx)):this.blankCode(e,s.startIx,s.endIx);for(const i of s.innerIfs)null!==l&&i.startIx>=l[0]&&i.startIx<=l[1]&&this.applyIF(e,i,t,this.verbose)}evaluate(e,s){let t;e=e.replace(/defined\(([a-z0-9]*)\)/gi,((e,s)=>`(typeof ${s} !== "undefined")`));try{t=new expression_1.default(e).parse()(s)}catch(e){t=!1}return t}blankCode(e,s,t=s){for(let i=s;i<=t;i++)e[i]=deleteFlag}doCompile(e){const{filePath:s,content:t,macroDefine:i}=e;try{const e=t.toString(),n=this.getFileDefines(e),l=Object.assign(Object.assign({},i.getDefines()),n);void 0===this.tripleSlash&&(this.tripleSlash=!1),useTripleSlash=this.tripleSlash;const r=e.split("\n");if(this.applyDefines(r),-1!==t.indexOf("#if")){const e=this.findIFBlocks(r);for(const t of e)this.applyIF(r,t,l,this.verbose,s)}return r.filter((e=>e!==deleteFlag)).join("\n")}catch(e){throw new Error(`[PreCompiler]compile ${s} error:${e.message}`)}}}exports.MacroConditionCompiler=MacroConditionCompiler;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ConditionCompiler=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),fs_1=tslib_1.__importDefault(require("fs")),define_1=require("../../../config/define"),plant_1=require("./compiler/plant"),json_1=require("./compiler/json"),macro_1=require("./compiler/macro"),minimatch_1=tslib_1.__importDefault(require("minimatch")),tools_1=require("../../../utils/tools"),defaultCompileSetting={targetPlatform:define_1.PLATFORM["mini-weixin"],targetPlatformDefines:{}};class ConditionCompiler{constructor(t,e,o){this.extToCompiler={},this.project=t,this.devtoolMessagehub=e,this.consoleDisplay=o}getCompiler(t,e){const{targetPlatform:o,targetPlatformDefines:i={}}=e;if(!Object.values(define_1.PLATFORM).includes(o))throw new Error(`platform ${o} is not supported`);if(!this.extToCompiler[t]){let e=null;const r={targetPlatform:o,targetPlatformDefines:i,type:t};e=[".wxml",".wxss",".less",".scss",".wxs",".ts",".js"].includes(t)?new macro_1.MacroConditionCompiler(r):".json"===t?new json_1.JSONConditionCompiler(r):new plant_1.PlantConditionCompiler(r),this.extToCompiler[t]=e}return this.extToCompiler[t].targetPlatform=e.targetPlatform,this.extToCompiler[t].targetPlatformDefines=e.targetPlatformDefines||{},this.extToCompiler[t]}shouldCompile(t){return!this.project.miniprogramRoot||this.project.miniprogramRoot&&t.startsWith(this.project.miniprogramRoot)||"project.config.json"===t||"project.private.config.json"===t}compileFile(t,e=defaultCompileSetting){var o,i;try{const o=path_1.default.join(this.project.projectPath,t);if(!fs_1.default.existsSync(o))throw Error("no such file or direactory: "+o);const i=path_1.default.extname(o),r=this.getCompiler(i,e),s=this.project.getFile("",t),l=r.compile(o,s);return Buffer.isBuffer(l)?l:Buffer.from(l)}catch(t){throw null===(o=this.devtoolMessagehub)||void 0===o||o.showBuildLog("compileFile","error",t.message),null===(i=this.consoleDisplay)||void 0===i||i.display({command:"DISPLAY_ERROR",data:{error:{message:t.message}}}),t}}compileProject(t=defaultCompileSetting){var e;if(!Object.values(define_1.PLATFORM).includes(t.targetPlatform))throw new Error(`platform ${t.targetPlatform} is not supported`);try{const e={},{targetPlatform:o,targetPlatformDefines:i={}}=t,r=this.project.getFileList();for(const t of r){if(!this.shouldCompile(t))continue;const r=this.compileFile(t,{targetPlatform:o,targetPlatformDefines:i});e[t]=r}}catch(t){throw null===(e=this.devtoolMessagehub)||void 0===e||e.showBuildLog("compileProject","error",t.message),t}return{}}filterResourceByPlatfrom(t=defaultCompileSetting){const{targetPlatform:e=define_1.PLATFORM["mini-weixin"]}=t;let o=this.project.getFileList();const i=(0,tools_1.getAppJson)(this.project,e).static||[];for(const t of i){const{pattern:i="",platforms:r=[]}=t,s=path_1.default.join(this.project.miniprogramRoot||"",i);if(!r.includes(e)){const t=o.filter(t=>(0,minimatch_1.default)(t,s));o=o.filter(e=>!t.includes(e)&&e!==s&&!(0,tools_1.normalizePath)(e).startsWith((0,tools_1.normalizePath)(s)))}}return o}}exports.ConditionCompiler=ConditionCompiler;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ConditionCompiler=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),fs_1=tslib_1.__importDefault(require("fs")),define_1=require("../../../config/define"),plant_1=require("./compiler/plant"),json_1=require("./compiler/json"),macro_1=require("./compiler/macro"),minimatch_1=tslib_1.__importDefault(require("minimatch")),tools_1=require("../../../utils/tools"),defaultCompileSetting={targetPlatform:define_1.PLATFORM["mini-weixin"],targetPlatformDefines:{}};class ConditionCompiler{constructor(t,e,o){this.extToCompiler={},this.project=t,this.devtoolMessagehub=e,this.consoleDisplay=o}getCompiler(t,e){const{targetPlatform:o,targetPlatformDefines:i={}}=e;if(!Object.values(define_1.PLATFORM).includes(o))throw new Error(`platform ${o} is not supported`);if(!this.extToCompiler[t]){let e=null;const r={targetPlatform:o,targetPlatformDefines:i,type:t};e=[".wxml",".wxss",".less",".scss",".wxs",".ts",".js"].includes(t)?new macro_1.MacroConditionCompiler(r):".json"===t?new json_1.JSONConditionCompiler(r):new plant_1.PlantConditionCompiler(r),this.extToCompiler[t]=e}return this.extToCompiler[t].targetPlatform=e.targetPlatform,this.extToCompiler[t].targetPlatformDefines=e.targetPlatformDefines||{},this.extToCompiler[t]}shouldCompile(t){return!this.project.miniprogramRoot||this.project.miniprogramRoot&&t.startsWith(this.project.miniprogramRoot)||"project.config.json"===t||"project.private.config.json"===t}compileFile(t,e=defaultCompileSetting){var o,i;try{const o=path_1.default.join(this.project.projectPath,t);if(!fs_1.default.existsSync(o))throw Error(`no such file or direactory: ${o}`);const i=path_1.default.extname(o),r=this.getCompiler(i,e),s=this.project.getFile("",t),l=r.compile(o,s);return Buffer.isBuffer(l)?l:Buffer.from(l)}catch(t){throw null===(o=this.devtoolMessagehub)||void 0===o||o.showBuildLog("compileFile","error",t.message),null===(i=this.consoleDisplay)||void 0===i||i.display({command:"DISPLAY_ERROR",data:{error:{message:t.message}}}),t}}compileProject(t=defaultCompileSetting){var e;if(!Object.values(define_1.PLATFORM).includes(t.targetPlatform))throw new Error(`platform ${t.targetPlatform} is not supported`);try{const e={},{targetPlatform:o,targetPlatformDefines:i={}}=t,r=this.project.getFileList();for(const t of r){if(!this.shouldCompile(t))continue;const r=this.compileFile(t,{targetPlatform:o,targetPlatformDefines:i});e[t]=r}}catch(t){throw null===(e=this.devtoolMessagehub)||void 0===e||e.showBuildLog("compileProject","error",t.message),t}return{}}filterResourceByPlatfrom(t=defaultCompileSetting){const{targetPlatform:e=define_1.PLATFORM["mini-weixin"]}=t;let o=this.project.getFileList();const i=(0,tools_1.getAppJson)(this.project,e).static||[];for(const t of i){const{pattern:i="",platforms:r=[]}=t,s=path_1.default.join(this.project.miniprogramRoot||"",i);if(!r.includes(e)){const t=o.filter((t=>(0,minimatch_1.default)(t,s)));o=o.filter((e=>!t.includes(e)&&e!==s&&!(0,tools_1.normalizePath)(e).startsWith((0,tools_1.normalizePath)(s))))}}return o}}exports.ConditionCompiler=ConditionCompiler;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PreCompileProject=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),events_1=tslib_1.__importDefault(require("events")),baseProject_1=require("../baseProject"),tools_1=require("../../utils/tools"),define_1=require("../../config/define");class PreCompileProject extends baseProject_1.BaseProject{constructor(t,e,i){var r,s,o;if(super(),this.event=new events_1.default,this.targetPlatform=define_1.PLATFORM["mini-weixin"],this.targetPlatformDefines={},this._fileBufferCache={},this.onFileChange=async(t,e)=>{if(e=(0,tools_1.normalizePath)(e).replace(/\/$/,"").replace(/^\//,""),"add"===t&&(this.cacheDirName(this._dirSet,path_1.default.posix.dirname(e)),this._fileSet.add(e)),"addDir"===t&&this.cacheDirName(this._dirSet,e),"unlink"===t&&(this.deleteDirOrFileOfSet(this._dirSet,this._fileSet,e),this._fileBufferCache[e]&&delete this._fileBufferCache[e]),"unlinkDir"===t&&this.deleteDirOrFileOfSet(this._dirSet,this._fileSet,e),"change"===t&&delete this._fileBufferCache[e],this.event.emit("fileChange",t,e),"change"===t&&e===path_1.default.posix.join(this.project.miniprogramRoot||"","app.json")){const t=Array.from(this._fileSet);this.updateFileAndDirs(),this.notifyRefreshFileOrDirs(t)}},this.project=t,this._projectPath=(0,tools_1.normalizePath)(t.projectPath),this._projectArchitecture=t.projectArchitecture,this._miniprogramRoot=t.miniprogramRoot||"",this._pluginRoot=t.pluginRoot,this._appid=t.appid,this._type=t.type?t.type:"miniProgram",this._privateKey=t.privateKey,this.ignores=t.ignores||[],null===(r=this.project.event)||void 0===r||r.on("fileChange",(t,e)=>{this.onFileChange(t,e)}),null===(s=this.project.event)||void 0===s||s.on("optionsChange",t=>{this.updateOptions(t)}),this.runEnv=i.runEnv,null===(o=this.project)||void 0===o?void 0:o.setting)this.setting=this.project.setting;else{const t=this.getProjectConfig();(null==t?void 0:t.setting)&&(this.setting=t.setting)}this.conditionCompiler=e,this.updateConditionCompileOptions({targetPlatform:i.targetPlatform||define_1.PLATFORM["mini-weixin"],targetPlatformDefines:i.targetPlatformDefines}),this.packOptions=t.packOptions||{ignore:[],include:[]}}async ready(){await this.wait(this.init.bind(this))}async init(){this.updateFileAndDirs()}shouldConditionalCompile(){var t;return!!(null===(t=this.project.setting)||void 0===t?void 0:t.condition)}updateOptions(t){this._appid=t.appid,this._attr=t.attr,this._type=this.getProjectType(t.attr,t.compileType),this._miniprogramRoot=t.miniprogramRoot,this._pluginRoot=t.pluginRoot,this._projectArchitecture=t.projectArchitecture,this.packOptions=t.packOptions||{ignore:[],include:[]}}updateConditionCompileOptions(t){const e=this.targetPlatform;if(this.targetPlatform=t.targetPlatform||define_1.PLATFORM["mini-weixin"],this.targetPlatformDefines=t.targetPlatformDefines||{},this.targetPlatform!==e){this._fileBufferCache={};const t=Array.from(this._fileSet);this.updateFileAndDirs(),this.notifyRefreshFileOrDirs(t),this.event.emit("precompileOptionsChange",{targetPlatform:this.targetPlatform,targetPlatformDefines:this.targetPlatformDefines})}}updateFileAndDirs(){var t,e;if(null===(t=this._fileSet)||void 0===t||t.clear(),null===(e=this._dirSet)||void 0===e||e.clear(),this.shouldConditionalCompile()){const t=this.conditionCompiler.filterResourceByPlatfrom({targetPlatform:this.targetPlatform});for(const e of t){const t=e.replace(/\\/g,path_1.default.posix.sep);this._fileSet.add(t),this.cacheDirName(this._dirSet,t)}}else{const{files:t,dirs:e}=this.project.getFilesAndDirs();this._fileSet=new Set(t),this._dirSet=new Set(e)}}get srcPath(){return this.project.srcPath||""}async attr(){return await this.project.attr()}async serialize(){const t=await super.serialize();return Object.assign(Object.assign({},t),{targetPlatform:this.targetPlatform,targetPlatformDefines:this.targetPlatformDefines})}getSrcFile(t="",e){return this.project.getFile(t,e)}getFile(t="",e){var i;const r=this.getTargetPath(t,e);if(!this._fileBufferCache[r]){if("condition"!==(null===(i=this._fileBufferCache[r])||void 0===i?void 0:i.type)&&this.shouldConditionalCompile())try{const t=this.conditionCompiler.compileFile(r,{targetPlatform:this.targetPlatform,targetPlatformDefines:this.targetPlatformDefines});return this._fileBufferCache[r]={content:t,type:"condition"},this._fileBufferCache[r].content}catch(t){}this._fileBufferCache[r]={content:this.project.getFile(t,e),type:"raw"}}return this._fileBufferCache[r].content}notifyRefreshFileOrDirs(t){const e=Array.from(this._fileSet);e.length!==t.length&&(e.forEach(e=>{t.includes(e)||this.event.emit("fileChange","add",e)}),t.forEach(t=>{e.includes(t)||this.event.emit("fileChange","unlink",t)}))}clearCache(){var t,e;this._fileBufferCache={},null===(e=(t=this.project).clearCache)||void 0===e||e.call(t)}}exports.PreCompileProject=PreCompileProject;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PreCompileProject=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),events_1=tslib_1.__importDefault(require("events")),baseProject_1=require("../baseProject"),tools_1=require("../../utils/tools"),define_1=require("../../config/define");class PreCompileProject extends baseProject_1.BaseProject{constructor(t,e,i){var r,s,o;if(super(),this.event=new events_1.default,this.targetPlatform=define_1.PLATFORM["mini-weixin"],this.targetPlatformDefines={},this._fileBufferCache={},this.onFileChange=async(t,e)=>{if(e=(0,tools_1.normalizePath)(e).replace(/\/$/,"").replace(/^\//,""),"add"===t&&(this.cacheDirName(this._dirSet,path_1.default.posix.dirname(e)),this._fileSet.add(e)),"addDir"===t&&this.cacheDirName(this._dirSet,e),"unlink"===t&&(this.deleteDirOrFileOfSet(this._dirSet,this._fileSet,e),this._fileBufferCache[e]&&delete this._fileBufferCache[e]),"unlinkDir"===t&&this.deleteDirOrFileOfSet(this._dirSet,this._fileSet,e),"change"===t&&delete this._fileBufferCache[e],this.event.emit("fileChange",t,e),"change"===t&&e===path_1.default.posix.join(this.project.miniprogramRoot||"","app.json")){const t=Array.from(this._fileSet);this.updateFileAndDirs(),this.notifyRefreshFileOrDirs(t)}},this.project=t,this._projectPath=(0,tools_1.normalizePath)(t.projectPath),this._projectArchitecture=t.projectArchitecture,this._miniprogramRoot=t.miniprogramRoot||"",this._pluginRoot=t.pluginRoot,this._appid=t.appid,this._type=t.type?t.type:"miniProgram",this._privateKey=t.privateKey,this.ignores=t.ignores||[],null===(r=this.project.event)||void 0===r||r.on("fileChange",((t,e)=>{this.onFileChange(t,e)})),null===(s=this.project.event)||void 0===s||s.on("optionsChange",(t=>{this.updateOptions(t)})),this.runEnv=i.runEnv,null===(o=this.project)||void 0===o?void 0:o.setting)this.setting=this.project.setting;else{const t=this.getProjectConfig();(null==t?void 0:t.setting)&&(this.setting=t.setting)}this.conditionCompiler=e,this.updateConditionCompileOptions({targetPlatform:i.targetPlatform||define_1.PLATFORM["mini-weixin"],targetPlatformDefines:i.targetPlatformDefines}),this.packOptions=t.packOptions||{ignore:[],include:[]}}async ready(){await this.wait(this.init.bind(this))}async init(){this.updateFileAndDirs()}shouldConditionalCompile(){var t;return!!(null===(t=this.project.setting)||void 0===t?void 0:t.condition)}updateOptions(t){this._appid=t.appid,this._attr=t.attr,this._type=this.getProjectType(t.attr,t.compileType),this._miniprogramRoot=t.miniprogramRoot,this._pluginRoot=t.pluginRoot,this._projectArchitecture=t.projectArchitecture,this.packOptions=t.packOptions||{ignore:[],include:[]}}updateConditionCompileOptions(t){const e=this.targetPlatform;if(this.targetPlatform=t.targetPlatform||define_1.PLATFORM["mini-weixin"],this.targetPlatformDefines=t.targetPlatformDefines||{},this.targetPlatform!==e){this._fileBufferCache={};const t=Array.from(this._fileSet);this.updateFileAndDirs(),this.notifyRefreshFileOrDirs(t),this.event.emit("precompileOptionsChange",{targetPlatform:this.targetPlatform,targetPlatformDefines:this.targetPlatformDefines})}}updateFileAndDirs(){var t,e;if(null===(t=this._fileSet)||void 0===t||t.clear(),null===(e=this._dirSet)||void 0===e||e.clear(),this.shouldConditionalCompile()){const t=this.conditionCompiler.filterResourceByPlatfrom({targetPlatform:this.targetPlatform});for(const e of t){const t=e.replace(/\\/g,path_1.default.posix.sep);this._fileSet.add(t),this.cacheDirName(this._dirSet,t)}}else{const{files:t,dirs:e}=this.project.getFilesAndDirs();this._fileSet=new Set(t),this._dirSet=new Set(e)}}get srcPath(){return this.project.srcPath||""}async attr(){return await this.project.attr()}async serialize(){const t=await super.serialize();return Object.assign(Object.assign({},t),{targetPlatform:this.targetPlatform,targetPlatformDefines:this.targetPlatformDefines})}getSrcFile(t="",e){return this.project.getFile(t,e)}getFile(t="",e){var i;const r=this.getTargetPath(t,e);if("condition"!==(null===(i=this._fileBufferCache[r])||void 0===i?void 0:i.type)&&this.shouldConditionalCompile())try{const t=this.conditionCompiler.compileFile(r,{targetPlatform:this.targetPlatform,targetPlatformDefines:this.targetPlatformDefines});return this._fileBufferCache[r]={content:t,type:"condition"},this._fileBufferCache[r].content}catch(t){}return this._fileBufferCache[r]||(this._fileBufferCache[r]={content:this.project.getFile(t,e),type:"raw"}),this._fileBufferCache[r].content}notifyRefreshFileOrDirs(t){const e=Array.from(this._fileSet);e.length!==t.length&&(e.forEach((e=>{t.includes(e)||this.event.emit("fileChange","add",e)})),t.forEach((t=>{e.includes(t)||this.event.emit("fileChange","unlink",t)})))}clearCache(){var t,e;this._fileBufferCache={},null===(e=(t=this.project).clearCache)||void 0===e||e.call(t)}}exports.PreCompileProject=PreCompileProject;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ReactiveProject=void 0;const reactivity_1=require("@vue/reactivity"),lodash_1=require("lodash"),tools_1=require("../../utils/tools"),config_1=require("../../config/config"),baseProject_1=require("../baseProject");function isAttrEqual(t,e){return"object"==typeof t&&"object"==typeof e&&(!(!t||!e)&&(t.platform===e.platform&&t.appType===e.appType&&t.gameApp===e.gameApp&&t.isSandbox===e.isSandbox&&t.released===e.released&&(t.setting.MaxCodeSize===e.setting.MaxCodeSize&&t.setting.MaxSubpackageSubCodeSize===e.setting.MaxSubpackageSubCodeSize&&t.setting.MaxSubpackageFullCodeSize===e.setting.MaxSubpackageFullCodeSize&&t.setting.NavigateMiniprogramLimit===e.setting.NavigateMiniprogramLimit&&t.setting.MaxSubPackageLimit===e.setting.MaxSubPackageLimit&&t.setting.MinTabbarCount===e.setting.MinTabbarCount&&t.setting.MaxTabbarCount===e.setting.MaxTabbarCount&&t.setting.MaxCustomTabbarCount===e.setting.MaxCustomTabbarCount&&t.setting.MaxTabbarIconSize===e.setting.MaxTabbarIconSize)))}class ReactiveProject extends baseProject_1.BaseProject{constructor(t){var e;super(),this.fileBoxs=new Map,this.statBoxs=new Map,this.onFileChange=async(t,e)=>{if("change"===t){const t=this.fileBoxs.get(e);if(t){let i;try{i=this.project.getFile("",e)}catch(t){i=t}i instanceof Error||t.value instanceof Error?t.value=i:t.value&&0===i.compare(t.value)||(t.value=i)}}else if("unlink"===t){const t=this.fileBoxs.get(e);t&&(this.fileBoxs.delete(e),t.value=void 0);const i=this.statBoxs.get(e);if(i){const t=this.project.stat("",e);(0,lodash_1.isEqual)(t,i.value)||(i.value=t)}}else if("unlinkDir"===t){const t=e+"/";let i=Array.from(this.fileBoxs.keys());for(const e of i)if(e.startsWith(t)){const t=this.fileBoxs.get(e);this.fileBoxs.delete(e),t.value=void 0}i=Array.from(this.statBoxs.keys());for(const e of i)if(e.startsWith(t)){const t=this.statBoxs.get(e);void 0!==t.value&&(this.statBoxs.delete(e),t.value=void 0)}}else if("add"===t||"addDir"===t){const t=this.statBoxs.get(e);if(t){const i=this.project.stat("",e);(0,lodash_1.isEqual)(i,t.value)||(t.value=i)}}},this.project=t,null===(e=this.project.event)||void 0===e||e.on("fileChange",this.onFileChange),this._projectArchitecture=t.projectArchitecture,this.miniprogramRootBox=(0,reactivity_1.ref)(t.miniprogramRoot),this.pluginRootBox=(0,reactivity_1.ref)(t.pluginRoot),this.appidBox=(0,reactivity_1.ref)(t.appid),this.typeBox=(0,reactivity_1.ref)(t.type),this.attrBox=(0,reactivity_1.ref)(config_1.DefaultProjectAttr),this.init()}get appid(){return this.appidBox.value}get type(){return this.typeBox.value}get nameMappingFromDevtools(){return this.project.nameMappingFromDevtools}get projectPath(){return this.project.projectPath}get privateKey(){return this.project.privateKey}get miniprogramRoot(){return this.miniprogramRootBox.value}set miniprogramRoot(t){this.miniprogramRootBox.value=t,this.project.miniprogramRoot=t}get pluginRoot(){return this.pluginRootBox.value}set pluginRoot(t){this.pluginRootBox.value=t,this.project.pluginRoot=t}async init(){}updateFileAndDirs(){throw new Error("Method updateFileAndDirs not implemented.")}async updateProject(){this.appidBox.value!==this.project.appid&&(this.appidBox.value=this.project.appid),this.typeBox.value!==this.project.type&&(this.typeBox.value=this.project.type),this.miniprogramRootBox.value!==this.project.miniprogramRoot&&(this.miniprogramRootBox.value=this.project.miniprogramRoot),this.pluginRootBox.value!==this.project.pluginRoot&&(this.pluginRootBox.value=this.project.pluginRoot);const t=await this.project.attr();return isAttrEqual(t,this.attrBox.value)||(this.attrBox.value=t),new Promise(t=>{setTimeout(t,0)})}release(){(0,tools_1.devtoolsLog)("[reactiveCache] reactiveProject release")}async attr(){return this.attrSync()}getSrcFile(t,e){return this.project.getSrcFile(t,e)}getFileList(t="",e=""){return this.project.getFileList(t,e)}getFilesAndDirs(){return this.project.getFilesAndDirs()}getExtAppid(){return this.project.getExtAppid()}getFile(t,e){const i=this.getTargetPath(t,e),o=this.fileBoxs.get(i);if(o){if(o.value instanceof Error)throw o.value;return o.value}const r=this.project.getFile(t,e),a=(0,reactivity_1.ref)(r);return this.fileBoxs.set(i,a),a.value}stat(t,e){const i=this.getTargetPath(t,e),o=this.statBoxs.get(i);if(o)return o.value;const r=this.project.stat(t,e),a=(0,reactivity_1.ref)(r);return this.statBoxs.set(i,a),a.value}attrSync(){return this.attrBox.value}}exports.ReactiveProject=ReactiveProject;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ReactiveProject=void 0;const reactivity_1=require("@vue/reactivity"),lodash_1=require("lodash"),tools_1=require("../../utils/tools"),config_1=require("../../config/config"),baseProject_1=require("../baseProject");function isAttrEqual(t,e){return"object"==typeof t&&"object"==typeof e&&(!(!t||!e)&&(t.platform===e.platform&&t.appType===e.appType&&t.gameApp===e.gameApp&&t.isSandbox===e.isSandbox&&t.released===e.released&&(t.setting.MaxCodeSize===e.setting.MaxCodeSize&&t.setting.MaxSubpackageSubCodeSize===e.setting.MaxSubpackageSubCodeSize&&t.setting.MaxSubpackageFullCodeSize===e.setting.MaxSubpackageFullCodeSize&&t.setting.NavigateMiniprogramLimit===e.setting.NavigateMiniprogramLimit&&t.setting.MaxSubPackageLimit===e.setting.MaxSubPackageLimit&&t.setting.MinTabbarCount===e.setting.MinTabbarCount&&t.setting.MaxTabbarCount===e.setting.MaxTabbarCount&&t.setting.MaxCustomTabbarCount===e.setting.MaxCustomTabbarCount&&t.setting.MaxTabbarIconSize===e.setting.MaxTabbarIconSize)))}class ReactiveProject extends baseProject_1.BaseProject{constructor(t){var e;super(),this.fileBoxs=new Map,this.statBoxs=new Map,this.onFileChange=async(t,e)=>{if("change"===t){const t=this.fileBoxs.get(e);if(t){let i;try{i=this.project.getFile("",e)}catch(t){i=t}i instanceof Error||t.value instanceof Error?t.value=i:t.value&&0===i.compare(t.value)||(t.value=i)}}else if("unlink"===t){const t=this.fileBoxs.get(e);t&&(this.fileBoxs.delete(e),t.value=void 0);const i=this.statBoxs.get(e);if(i){const t=await this.project.stat("",e);(0,lodash_1.isEqual)(t,i.value)||(i.value=t)}}else if("unlinkDir"===t){const t=`${e}/`;let i=Array.from(this.fileBoxs.keys());for(const e of i)if(e.startsWith(t)){const t=this.fileBoxs.get(e);this.fileBoxs.delete(e),t.value=void 0}i=Array.from(this.statBoxs.keys());for(const e of i)if(e.startsWith(t)){const t=this.statBoxs.get(e);void 0!==t.value&&(this.statBoxs.delete(e),t.value=void 0)}}else if("add"===t||"addDir"===t){const t=this.statBoxs.get(e);if(t){const i=await this.project.stat("",e);(0,lodash_1.isEqual)(i,t.value)||(t.value=i)}}},this.project=t,null===(e=this.project.event)||void 0===e||e.on("fileChange",this.onFileChange),this._projectArchitecture=t.projectArchitecture,this.miniprogramRootBox=(0,reactivity_1.ref)(t.miniprogramRoot),this.pluginRootBox=(0,reactivity_1.ref)(t.pluginRoot),this.appidBox=(0,reactivity_1.ref)(t.appid),this.typeBox=(0,reactivity_1.ref)(t.type),this.attrBox=(0,reactivity_1.ref)(config_1.DefaultProjectAttr),this.init()}get appid(){return this.appidBox.value}get type(){return this.typeBox.value}get nameMappingFromDevtools(){return this.project.nameMappingFromDevtools}get projectPath(){return this.project.projectPath}get privateKey(){return this.project.privateKey}get miniprogramRoot(){return this.miniprogramRootBox.value}set miniprogramRoot(t){this.miniprogramRootBox.value=t,this.project.miniprogramRoot=t}get pluginRoot(){return this.pluginRootBox.value}set pluginRoot(t){this.pluginRootBox.value=t,this.project.pluginRoot=t}async init(){}updateFileAndDirs(){throw new Error("Method updateFileAndDirs not implemented.")}async updateProject(){this.appidBox.value!==this.project.appid&&(this.appidBox.value=this.project.appid),this.typeBox.value!==this.project.type&&(this.typeBox.value=this.project.type),this.miniprogramRootBox.value!==this.project.miniprogramRoot&&(this.miniprogramRootBox.value=this.project.miniprogramRoot),this.pluginRootBox.value!==this.project.pluginRoot&&(this.pluginRootBox.value=this.project.pluginRoot);const t=await this.project.attr();return isAttrEqual(t,this.attrBox.value)||(this.attrBox.value=t),new Promise((t=>{setTimeout(t,0)}))}release(){(0,tools_1.devtoolsLog)("[reactiveCache] reactiveProject release")}async attr(){return this.attrSync()}getSrcFile(t,e){return this.project.getSrcFile(t,e)}getFileList(t="",e=""){return this.project.getFileList(t,e)}getFilesAndDirs(){return this.project.getFilesAndDirs()}getExtAppid(){return this.project.getExtAppid()}getFile(t,e){const i=this.getTargetPath(t,e),o=this.fileBoxs.get(i);if(o){if(o.value instanceof Error)throw o.value;return o.value}const r=this.project.getFile(t,e),a=(0,reactivity_1.ref)(r);return this.fileBoxs.set(i,a),a.value}stat(t,e){const i=this.getTargetPath(t,e),o=this.statBoxs.get(i);if(o)return o.value;const r=this.project.stat(t,e),a=(0,reactivity_1.ref)(r);return this.statBoxs.set(i,a),a.value}attrSync(){return this.attrBox.value}}exports.ReactiveProject=ReactiveProject;