miniprogram-ci 2.1.32 → 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 (355) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +2 -0
  3. package/dist/@types/ci/cloud/utils.d.ts +1 -1
  4. package/dist/@types/common/code-analyse/index.d.ts +16 -1
  5. package/dist/@types/config/config.d.ts +1 -1
  6. package/dist/@types/index.d.ts +2 -0
  7. package/dist/@types/modules/corecompiler/original/compile/game.d.ts +1 -1
  8. package/dist/@types/modules/corecompiler/original/compile/index.d.ts +1 -1
  9. package/dist/@types/modules/corecompiler/original/index.d.ts +1 -1
  10. package/dist/@types/modules/corecompiler/original/workerThread/childprocessManager.d.ts +1 -1
  11. package/dist/@types/modules/corecompiler/original/workerThread/config.d.ts +3 -0
  12. package/dist/@types/modules/corecompiler/original/workerThread/task/compilejs.d.ts +3 -0
  13. package/dist/@types/modules/corecompiler/original/workerThread/task/func.d.ts +4 -0
  14. package/dist/@types/modules/corecompiler/original/workerThread/workerManager.d.ts +8 -0
  15. package/dist/@types/modules/corecompiler/originalCompiler.d.ts +1 -1
  16. package/dist/@types/modules/corecompiler/summer/pipeManager/index.d.ts +6 -0
  17. package/dist/@types/modules/corecompiler/summer/pipeManager/pipeCPProject.d.ts +17 -0
  18. package/dist/@types/modules/corecompiler/summer/pipeManager/pipeContext.d.ts +10 -0
  19. package/dist/@types/modules/corecompiler/summer/pipeManager/pipeManager.d.ts +12 -0
  20. package/dist/@types/modules/corecompiler/summer/pipeManager/pipeWorker.d.ts +2 -0
  21. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/appservicePipe/index.d.ts +3 -0
  22. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/compileWxmlToGlassEaselPipe.d.ts +3 -0
  23. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/compileWxssPipe.d.ts +3 -0
  24. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/index.d.ts +2 -0
  25. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/pageInitSourcePipe/index.d.ts +4 -0
  26. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/pageframePipe/index.d.ts +3 -0
  27. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/appdevserver/getAppService.d.ts +6 -0
  28. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/appdevserver/getwxappcode.d.ts +9 -0
  29. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/appservice/getjsfile.d.ts +12 -0
  30. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/appservice/getmainpkgsortedjsfiles.d.ts +11 -0
  31. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/appservice/getwxappcode.d.ts +8 -0
  32. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/common/apperrcode.config.d.ts +92 -0
  33. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/common/tools.d.ts +1 -0
  34. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/project/appconfig.d.ts +6 -0
  35. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/project/appjson.d.ts +3 -0
  36. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/project/customcomponent.d.ts +21 -0
  37. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/project/helper/theme.d.ts +40 -0
  38. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/project/pagejson.d.ts +3 -0
  39. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/project/wxappcodejson.d.ts +3 -0
  40. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/trans/transwxmltojs.d.ts +19 -0
  41. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/trans/transwxsstojs.d.ts +15 -0
  42. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/web/processPath.d.ts +9 -0
  43. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/wccPipe.d.ts +3 -0
  44. package/dist/@types/modules/corecompiler/summer/pipeManager/types.d.ts +100 -0
  45. package/dist/@types/modules/corecompiler/summer/plugins/script_task/minify_script_task.d.ts +1 -1
  46. package/dist/@types/modules/corecompiler/summerCompiler.d.ts +10 -0
  47. package/dist/@types/modules/index.d.ts +1 -1
  48. package/dist/@types/modules/precompiler/conditioncompile/compiler/plant.d.ts +1 -1
  49. package/dist/@types/modules/precompiler/conditioncompile/index.d.ts +1 -1
  50. package/dist/@types/project/advance/precompileProject.d.ts +1 -1
  51. package/dist/@types/project/baseProject.d.ts +1 -0
  52. package/dist/@types/services/app/ci/appDirService.d.ts +6 -0
  53. package/dist/@types/services/common/getservice.d.ts +6 -3
  54. package/dist/@types/services/compilewxml/common/compilewxmlService.d.ts +2 -2
  55. package/dist/@types/services/compilewxml/node/compileglasseasel.d.ts +14 -0
  56. package/dist/@types/services/multiTaskManager/ci/multiTaskManager.d.ts +5 -0
  57. package/dist/@types/services/multiTaskManager/common/multiTaskManager.d.ts +5 -0
  58. package/dist/@types/services/multiTaskManager/electron/multiTaskManager.d.ts +5 -0
  59. package/dist/@types/services/multiTaskManager/webide/multiTaskManager.d.ts +5 -0
  60. package/dist/@types/services/nativeModule/ci/nativeModule.d.ts +3 -0
  61. package/dist/@types/services/nativeModule/common/nativeModule.d.ts +2 -2
  62. package/dist/@types/services/nativeModule/common/nativeModule.impl.d.ts +3 -2
  63. package/dist/@types/services/pluginFileReader/ci/pluginFileReader.d.ts +3 -0
  64. package/dist/@types/services/pluginFileReader/common/pluginFileReader.base.d.ts +9 -0
  65. package/dist/@types/services/pluginFileReader/common/pluginFileReader.d.ts +12 -0
  66. package/dist/@types/services/pluginFileReader/electron/pluginFileReader.d.ts +3 -0
  67. package/dist/@types/services/pluginFileReader/webide/pluginFileReader.d.ts +9 -0
  68. package/dist/@types/services/root/ci/rootService.d.ts +2 -0
  69. package/dist/@types/services/root/webide/root.d.ts +11 -0
  70. package/dist/@types/services/root/webide/rootService.d.ts +2 -0
  71. package/dist/@types/utils/colorutils.d.ts +4 -0
  72. package/dist/@types/utils/debug.d.ts +1 -0
  73. package/dist/@types/utils/error.d.ts +1 -1
  74. package/dist/@types/utils/fsagent.d.ts +4 -3
  75. package/dist/@types/utils/processBootstrap.d.ts +7 -0
  76. package/dist/@types/utils/subprocess/processManager.d.ts +1 -0
  77. package/dist/@types/utils/wxapkg/pack.d.ts +2 -2
  78. package/dist/ci/android-miniapp-toolkit/dist/index.js +1 -1
  79. package/dist/ci/build-apk.js +1 -1
  80. package/dist/ci/build-ipa.js +1 -1
  81. package/dist/ci/checkCodeQuality.js +1 -1
  82. package/dist/ci/cloud/cloudapi.js +1 -1
  83. package/dist/ci/cloud/createTimeTrigger.js +1 -1
  84. package/dist/ci/cloud/uploadContainer.js +1 -1
  85. package/dist/ci/cloud/uploadFile.js +1 -1
  86. package/dist/ci/cloud/uploadFunction.js +1 -1
  87. package/dist/ci/cloud/utils.js +1 -1
  88. package/dist/ci/code-analyse.js +1 -1
  89. package/dist/ci/cos-upload.js +1 -1
  90. package/dist/ci/gamepkg/apkplug.js +1 -1
  91. package/dist/ci/gamepkg/index.js +1 -1
  92. package/dist/ci/getCompiledResult.js +1 -1
  93. package/dist/ci/getDevSourceMap.js +1 -1
  94. package/dist/ci/getcompiler.js +1 -1
  95. package/dist/ci/miniapp/androidCloudBuild.js +1 -1
  96. package/dist/ci/miniapp/archive.js +1 -1
  97. package/dist/ci/miniapp/iosCloudBuild.js +1 -1
  98. package/dist/ci/miniapp/miniappPlugin.js +1 -1
  99. package/dist/ci/miniapp/sdkManager.js +1 -1
  100. package/dist/ci/miniapp/upload.js +1 -1
  101. package/dist/ci/miniapp-cloud-upload.js +1 -1
  102. package/dist/ci/preview.js +1 -1
  103. package/dist/ci/upload.js +1 -1
  104. package/dist/ci/utils/codeDenpendencyQualityChecker.js +1 -1
  105. package/dist/ci/utils/filterUnusedFile.js +1 -1
  106. package/dist/ci/utils/pack.js +1 -1
  107. package/dist/ci/utils/packfile.js +1 -1
  108. package/dist/ci/utils/terminalQrcode.js +1 -1
  109. package/dist/ci/utils/tools.js +1 -1
  110. package/dist/ci/utils/unpack.js +1 -1
  111. package/dist/ci/utils/wxvpkg/unpack/version0.js +1 -1
  112. package/dist/ci/utils/wxvpkg/unpack/version10.js +1 -1
  113. package/dist/cli/index.js +1 -1
  114. package/dist/common/code-analyse/index.js +1 -1
  115. package/dist/config/config.js +1 -1
  116. package/dist/config/url.config.js +1 -1
  117. package/dist/index.js +1 -1
  118. package/dist/modules/corecompiler/baseCompiler.js +1 -1
  119. package/dist/modules/corecompiler/original/analyse/partial.js +1 -1
  120. package/dist/modules/corecompiler/original/compile/common.js +1 -1
  121. package/dist/modules/corecompiler/original/compile/game.js +1 -1
  122. package/dist/modules/corecompiler/original/compile/gamePlugin.js +1 -1
  123. package/dist/modules/corecompiler/original/compile/handler/js.js +1 -1
  124. package/dist/modules/corecompiler/original/compile/handler/mpjson.js +1 -1
  125. package/dist/modules/corecompiler/original/compile/handler/wxml.js +1 -1
  126. package/dist/modules/corecompiler/original/compile/handler/wxss.js +1 -1
  127. package/dist/modules/corecompiler/original/compile/miniprogram.js +1 -1
  128. package/dist/modules/corecompiler/original/compile/miniprogramPlugin.js +1 -1
  129. package/dist/modules/corecompiler/original/js/enhance.js +1 -1
  130. package/dist/modules/corecompiler/original/js/es6Transform.js +1 -1
  131. package/dist/modules/corecompiler/original/js/generateMap.js +1 -1
  132. package/dist/modules/corecompiler/original/js/minifyjs.js +1 -1
  133. package/dist/modules/corecompiler/original/js/minifyjsAfterWrap.js +1 -1
  134. package/dist/modules/corecompiler/original/js/workletCompile.js +1 -1
  135. package/dist/modules/corecompiler/original/json/app/appJSON.js +1 -1
  136. package/dist/modules/corecompiler/original/json/app/checkAppFields.js +1 -1
  137. package/dist/modules/corecompiler/original/json/app/extJSON.js +1 -1
  138. package/dist/modules/corecompiler/original/json/app/index.js +1 -1
  139. package/dist/modules/corecompiler/original/json/common.js +1 -1
  140. package/dist/modules/corecompiler/original/json/game.js +1 -1
  141. package/dist/modules/corecompiler/original/json/page/checkPageJSON.js +1 -1
  142. package/dist/modules/corecompiler/original/json/page/getPageJSON.js +1 -1
  143. package/dist/modules/corecompiler/original/json/plugin/plugin.js +1 -1
  144. package/dist/modules/corecompiler/original/json/plugin/pluginPage.js +1 -1
  145. package/dist/modules/corecompiler/original/json/projectconfig.js +1 -1
  146. package/dist/modules/corecompiler/original/json/reactiveCache.js +1 -1
  147. package/dist/modules/corecompiler/original/json/signaturejson.js +1 -1
  148. package/dist/modules/corecompiler/original/json/sitemap.js +1 -1
  149. package/dist/modules/corecompiler/original/json/theme.js +1 -1
  150. package/dist/modules/corecompiler/original/npm/filterdeps.js +1 -1
  151. package/dist/modules/corecompiler/original/npm/packnpm.js +1 -1
  152. package/dist/modules/corecompiler/original/protect/fileFlatter.js +1 -1
  153. package/dist/modules/corecompiler/original/protect/uglifyfilenames.js +1 -1
  154. package/dist/modules/corecompiler/original/utils/logger.js +1 -1
  155. package/dist/modules/corecompiler/original/validate/schemaValidate.js +1 -1
  156. package/dist/modules/corecompiler/original/validate/validate.js +1 -1
  157. package/dist/modules/corecompiler/original/workerThread/childprocess.js +1 -1
  158. package/dist/modules/corecompiler/original/workerThread/childprocessManager.js +1 -1
  159. package/dist/modules/corecompiler/original/workerThread/config.js +1 -1
  160. package/dist/modules/corecompiler/original/workerThread/fork.js +1 -1
  161. package/dist/modules/corecompiler/original/workerThread/index.js +1 -1
  162. package/dist/modules/corecompiler/original/workerThread/task/call_func.js +1 -1
  163. package/dist/modules/corecompiler/original/workerThread/task/compilejs.js +1 -1
  164. package/dist/modules/corecompiler/original/workerThread/task/compilewxss.js +1 -1
  165. package/dist/modules/corecompiler/original/workerThread/task/func.js +1 -1
  166. package/dist/modules/corecompiler/original/workerThread/task/index.js +1 -1
  167. package/dist/modules/corecompiler/original/workerThread/task/minifywxml.js +1 -1
  168. package/dist/modules/corecompiler/original/workerThread/worker.js +1 -1
  169. package/dist/modules/corecompiler/original/workerThread/workerManager.js +1 -1
  170. package/dist/modules/corecompiler/originalCompiler.js +1 -1
  171. package/dist/modules/corecompiler/processHandler.js +1 -1
  172. package/dist/modules/corecompiler/summer/graph/appconf.js +1 -1
  173. package/dist/modules/corecompiler/summer/graph/appgraph.js +1 -1
  174. package/dist/modules/corecompiler/summer/graph/basegraph.js +1 -1
  175. package/dist/modules/corecompiler/summer/graph/gameconf.js +1 -1
  176. package/dist/modules/corecompiler/summer/graph/gamegraph.js +1 -1
  177. package/dist/modules/corecompiler/summer/graph/gamepluginconf.js +1 -1
  178. package/dist/modules/corecompiler/summer/graph/gameplugingraph.js +1 -1
  179. package/dist/modules/corecompiler/summer/graph/pluginconf.js +1 -1
  180. package/dist/modules/corecompiler/summer/graph/plugingraph.js +1 -1
  181. package/dist/modules/corecompiler/summer/index.js +1 -1
  182. package/dist/modules/corecompiler/summer/initPlugin.js +1 -1
  183. package/dist/modules/corecompiler/summer/module.js +1 -1
  184. package/dist/modules/corecompiler/summer/persistCache.js +1 -1
  185. package/dist/modules/corecompiler/summer/pipeManager/index.js +1 -0
  186. package/dist/modules/corecompiler/summer/pipeManager/pipeCPProject.js +1 -0
  187. package/dist/modules/corecompiler/summer/pipeManager/pipeContext.js +1 -0
  188. package/dist/modules/corecompiler/summer/pipeManager/pipeManager.js +1 -0
  189. package/dist/modules/corecompiler/summer/pipeManager/pipeWorker.js +1 -0
  190. package/dist/modules/corecompiler/summer/pipeManager/pipes/appservicePipe/index.js +1 -0
  191. package/dist/modules/corecompiler/summer/pipeManager/pipes/compileWxmlToGlassEaselPipe.js +1 -0
  192. package/dist/modules/corecompiler/summer/pipeManager/pipes/compileWxssPipe.js +1 -0
  193. package/dist/modules/corecompiler/summer/pipeManager/pipes/index.js +1 -0
  194. package/dist/modules/corecompiler/summer/pipeManager/pipes/pageInitSourcePipe/index.js +1 -0
  195. package/dist/modules/corecompiler/summer/pipeManager/pipes/pageframePipe/index.js +1 -0
  196. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/appdevserver/getAppService.js +1 -0
  197. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/appdevserver/getwxappcode.js +1 -0
  198. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/appservice/getjsfile.js +1 -0
  199. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/appservice/getmainpkgsortedjsfiles.js +1 -0
  200. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/appservice/getwxappcode.js +1 -0
  201. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/common/apperrcode.config.js +1 -0
  202. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/common/tools.js +1 -0
  203. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/project/appconfig.js +1 -0
  204. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/project/appjson.js +1 -0
  205. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/project/customcomponent.js +1 -0
  206. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/project/helper/theme.js +1 -0
  207. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/project/pagejson.js +1 -0
  208. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/project/wxappcodejson.js +1 -0
  209. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/trans/transwxmltojs.js +1 -0
  210. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/trans/transwxsstojs.js +1 -0
  211. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/web/processPath.js +1 -0
  212. package/dist/modules/corecompiler/summer/pipeManager/pipes/wccPipe.js +1 -0
  213. package/dist/modules/corecompiler/summer/pipeManager/types.js +1 -0
  214. package/dist/modules/corecompiler/summer/pluginDriver.js +1 -1
  215. package/dist/modules/corecompiler/summer/pluginconfig.js +1 -1
  216. package/dist/modules/corecompiler/summer/plugins/base/es6module.js +1 -1
  217. package/dist/modules/corecompiler/summer/plugins/base/javascript.js +1 -1
  218. package/dist/modules/corecompiler/summer/plugins/base/swc.js +1 -1
  219. package/dist/modules/corecompiler/summer/plugins/base/wxss.js +1 -1
  220. package/dist/modules/corecompiler/summer/plugins/enhance.js +1 -1
  221. package/dist/modules/corecompiler/summer/plugins/filetask/script.js +1 -1
  222. package/dist/modules/corecompiler/summer/plugins/less.js +1 -1
  223. package/dist/modules/corecompiler/summer/plugins/minifywxml.js +1 -1
  224. package/dist/modules/corecompiler/summer/plugins/sass.js +1 -1
  225. package/dist/modules/corecompiler/summer/plugins/script_task/babel_script_task.js +1 -1
  226. package/dist/modules/corecompiler/summer/plugins/script_task/load_script_task.js +1 -1
  227. package/dist/modules/corecompiler/summer/plugins/script_task/minify_script_task.js +1 -1
  228. package/dist/modules/corecompiler/summer/plugins/script_task/swc_task.js +1 -1
  229. package/dist/modules/corecompiler/summer/plugins/terser.js +1 -1
  230. package/dist/modules/corecompiler/summer/plugins/typescript.js +1 -1
  231. package/dist/modules/corecompiler/summer/plugins/worklet.js +1 -1
  232. package/dist/modules/corecompiler/summer/resolver.js +1 -1
  233. package/dist/modules/corecompiler/summer/summer.js +1 -1
  234. package/dist/modules/corecompiler/summer/utils/async.js +1 -1
  235. package/dist/modules/corecompiler/summer/utils/inputsourcemap.js +1 -1
  236. package/dist/modules/corecompiler/summerCompiler.js +1 -1
  237. package/dist/modules/corecompiler/summerEntryProcess.js +1 -1
  238. package/dist/modules/createSummer.js +1 -1
  239. package/dist/modules/fullcompiler/app/app.js +1 -1
  240. package/dist/modules/fullcompiler/app/contactandlaunch/updateContactForSubpkg.js +1 -1
  241. package/dist/modules/fullcompiler/app/contactandlaunch/updatecontactandlaunch.js +1 -1
  242. package/dist/modules/index.js +1 -1
  243. package/dist/modules/nativecompiler/android/adb.js +1 -1
  244. package/dist/modules/nativecompiler/android/device.js +1 -1
  245. package/dist/modules/nativecompiler/android/index.js +1 -1
  246. package/dist/modules/nativecompiler/android/projectconfig.js +1 -1
  247. package/dist/modules/nativecompiler/index.js +1 -1
  248. package/dist/modules/nativecompiler/ios/buildCloud.js +1 -1
  249. package/dist/modules/nativecompiler/ios/device.js +1 -1
  250. package/dist/modules/nativecompiler/ios/index.js +1 -1
  251. package/dist/modules/nativecompiler/nativeEntryProcess.js +1 -1
  252. package/dist/modules/nativecompiler/processHandler.js +1 -1
  253. package/dist/modules/precompiler/conditioncompile/compiler/json.js +1 -1
  254. package/dist/modules/precompiler/conditioncompile/compiler/macro.js +1 -1
  255. package/dist/modules/precompiler/conditioncompile/index.js +1 -1
  256. package/dist/project/advance/precompileProject.js +1 -1
  257. package/dist/project/advance/reactiveProject.js +1 -1
  258. package/dist/project/baseProject.js +1 -1
  259. package/dist/project/ciProjectWithMockBuffer.js +1 -1
  260. package/dist/project/summerCPProject.js +1 -1
  261. package/dist/services/app/ci/appDirService.js +1 -0
  262. package/dist/services/common/getservice.js +1 -1
  263. package/dist/services/common/vsbase.js +1 -1
  264. package/dist/services/compilewxml/node/compileUtils.js +1 -1
  265. package/dist/services/compilewxml/node/compileglasseasel.js +1 -1
  266. package/dist/services/compilewxml/webide/pageFrameWasm/wcc/runWcc.js +1 -1
  267. package/dist/services/compilewxss/node/compileUtils.js +1 -1
  268. package/dist/services/compilewxss/webide/pageFrameWasm/wcsc/runWcsc.js +1 -1
  269. package/dist/services/multiTaskManager/ci/multiTaskManager.js +1 -0
  270. package/dist/services/multiTaskManager/common/multiTaskManager.js +1 -0
  271. package/dist/services/multiTaskManager/electron/multiTaskManager.js +1 -0
  272. package/dist/services/multiTaskManager/webide/multiTaskManager.js +1 -0
  273. package/dist/services/nativeModule/ci/nativeModule.js +1 -0
  274. package/dist/services/nativeModule/common/nativeModule.impl.js +1 -1
  275. package/dist/services/pluginFileReader/ci/pluginFileReader.js +1 -0
  276. package/dist/services/pluginFileReader/common/pluginFileReader.base.js +1 -0
  277. package/dist/services/pluginFileReader/common/pluginFileReader.js +1 -0
  278. package/dist/services/pluginFileReader/electron/pluginFileReader.js +1 -0
  279. package/dist/services/pluginFileReader/webide/pluginFileReader.js +1 -0
  280. package/dist/services/root/{node → ci}/root.js +1 -1
  281. package/dist/services/root/ci/rootService.js +1 -0
  282. package/dist/services/root/electron/root.js +1 -1
  283. package/dist/services/root/electron/rootService.js +1 -1
  284. package/dist/services/root/nw/root.js +1 -1
  285. package/dist/services/root/webide/root.js +1 -0
  286. package/dist/services/root/webide/rootService.js +1 -0
  287. package/dist/utils/asyncTask/index.js +1 -1
  288. package/dist/utils/babel_helper.js +1 -1
  289. package/dist/utils/babel_plugin_worklet.js +1 -1
  290. package/dist/utils/colorutils.js +1 -0
  291. package/dist/utils/common.js +1 -1
  292. package/dist/utils/cosUpload.js +1 -1
  293. package/dist/utils/cp.js +1 -1
  294. package/dist/utils/customError.js +1 -1
  295. package/dist/utils/debug.js +1 -1
  296. package/dist/utils/download.js +1 -1
  297. package/dist/utils/expression.js +1 -1
  298. package/dist/utils/fsagent.js +1 -1
  299. package/dist/utils/genTempFile.js +1 -1
  300. package/dist/utils/generateIpa.js +1 -1
  301. package/dist/utils/glob.js +1 -1
  302. package/dist/utils/hackrequire/wxvpkgreader.js +1 -1
  303. package/dist/utils/helper_util.js +1 -1
  304. package/dist/utils/jsonlint.js +1 -1
  305. package/dist/utils/locales/fomatable_string.js +1 -1
  306. package/dist/utils/locales/locales.js +1 -1
  307. package/dist/utils/log.js +1 -1
  308. package/dist/utils/messageHub.js +1 -1
  309. package/dist/utils/miniAppI18N.js +1 -1
  310. package/dist/utils/miniapp-builder.js +1 -1
  311. package/dist/utils/miniappJson.js +1 -1
  312. package/dist/utils/officialDonutPlugin.js +1 -1
  313. package/dist/utils/packOptionsHelper.js +1 -1
  314. package/dist/utils/processBootstrap.js +1 -0
  315. package/dist/utils/progressRecorder.js +1 -1
  316. package/dist/utils/request.js +1 -1
  317. package/dist/utils/singletontask.js +1 -1
  318. package/dist/utils/subprocess/entryProcess.js +1 -1
  319. package/dist/utils/subprocess/processManager.js +1 -1
  320. package/dist/utils/subprocess/processService.js +1 -1
  321. package/dist/utils/swc_helper.js +1 -1
  322. package/dist/utils/taskmanager.js +1 -1
  323. package/dist/utils/tools.js +1 -1
  324. package/dist/utils/usbProcess.js +1 -1
  325. package/dist/utils/waitable.js +1 -1
  326. package/dist/utils/web/common.js +1 -1
  327. package/dist/utils/white_ext_list.js +1 -1
  328. package/dist/utils/wxapkg/pack.js +1 -1
  329. package/dist/utils/wxvpkgreader/wxvpkg/reader/version0.js +1 -1
  330. package/dist/utils/wxvpkgreader/wxvpkg/reader/version10.js +1 -1
  331. package/dist/utils/wxvpkgreader/wxvpkg/unpack/version0.js +1 -1
  332. package/dist/utils/wxvpkgreader/wxvpkg/unpack/version10.js +1 -1
  333. package/dist/utils/wxvpkgreader/wxvpkgreader.js +1 -1
  334. package/dist/utils/zip.js +1 -1
  335. package/package.json +62 -3
  336. package/dist/@types/services/root/node/rootService.d.ts +0 -0
  337. package/dist/modules/fullcompiler/trans/wcc/build/darwin_arm64/wcc.node +0 -0
  338. package/dist/modules/fullcompiler/trans/wcc/build/darwin_arm64/wcsc.node +0 -0
  339. package/dist/modules/fullcompiler/trans/wcc/build/darwin_x64/wcc.node +0 -0
  340. package/dist/modules/fullcompiler/trans/wcc/build/darwin_x64/wcsc.node +0 -0
  341. package/dist/modules/fullcompiler/trans/wcc/build/node_16.1.0_darwin_arm64_release/wcc.node +0 -0
  342. package/dist/modules/fullcompiler/trans/wcc/build/node_16.1.0_darwin_arm64_release/wcsc.node +0 -0
  343. package/dist/modules/fullcompiler/trans/wcc/build/node_16.1.0_darwin_x64_release/wcc.node +0 -0
  344. package/dist/modules/fullcompiler/trans/wcc/build/node_16.1.0_darwin_x64_release/wcsc.node +0 -0
  345. package/dist/modules/fullcompiler/trans/wcc/build/win32_ia32/wcc.node +0 -0
  346. package/dist/modules/fullcompiler/trans/wcc/build/win32_ia32/wcsc.node +0 -0
  347. package/dist/modules/fullcompiler/trans/wcc/build/win32_x64/wcc.node +0 -0
  348. package/dist/modules/fullcompiler/trans/wcc/build/win32_x64/wcsc.node +0 -0
  349. package/dist/modules/fullcompiler/trans/wcc/lib/addonVersion.js +0 -19
  350. package/dist/modules/fullcompiler/trans/wcc/lib/index.js +0 -4
  351. package/dist/modules/fullcompiler/trans/wcc/lib/util.js +0 -1134
  352. package/dist/modules/fullcompiler/trans/wcc/lib/wcc.js +0 -94
  353. package/dist/modules/fullcompiler/trans/wcc/lib/wcsc.js +0 -93
  354. package/dist/services/root/node/rootService.js +0 -1
  355. /package/dist/@types/services/root/{node → ci}/root.d.ts +0 -0
@@ -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.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
+ "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
- 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.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
+ "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("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
+ "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=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;
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;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BaseProject=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),events_1=tslib_1.__importDefault(require("events")),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),tools_1=require("../utils/tools"),waitable_1=tslib_1.__importDefault(require("../utils/waitable")),rootConfig={qcloudRoot:"腾讯云 wafer 方案目录",miniprogramRoot:"小程序代码的目录",srcMiniprogramRoot:"小程序源码的目录",pluginRoot:"插件目录",cloudfunctionRoot:"云函数目录",cloudfunctionTemplateRoot:"云函数本地调试模板目录",cloudcontainerRoot:"云容器目录",cloudbaseRoot:"cloudbaseRoot",jsserverRoot:"小游戏 jsserver 目录",testRoot:"自动化测试脚本录制的存放目录"};class BaseProject extends waitable_1.default{constructor(){super(...arguments),this._projectPath="",this._injectedPages=[],this._projectArchitecture="miniProgram",this._type="miniProgram",this._privateKey="",this.ignores=[],this.setting={},this._dirSet=new Set,this._fileSet=new Set,this.event=new events_1.default,this.normalizeRootPath=(t="")=>t&&"/"!==t?(t=(0,tools_1.normalizePath)(t+"/")).replace(/\.\.\//g,"").replace(/^\//,"").replace(/^\.\//,""):""}get projectPath(){return this._projectPath}get injectedPages(){return this._injectedPages}get projectArchitecture(){return this._projectArchitecture}get srcPath(){let t="";return"miniProgramPlugin"!==this._type&&"miniGamePlugin"!==this._type||(t=(0,tools_1.normalizePath)(path_1.default.join(this.projectPath,this.pluginRoot||""))),t=(0,tools_1.normalizePath)(path_1.default.join(this.projectPath,this.miniprogramRoot||"")),(this._projectPath.startsWith("//")||this._projectPath.startsWith("\\\\"))&&(t.startsWith("//")||(t="/"+t)),t}get pluginSrcPath(){return(0,tools_1.normalizePath)(path_1.default.join(this.projectPath,this.pluginRoot||""))}get type(){return this._type}set type(t){this._type=t}get appid(){return this._appid}set appid(t){this._appid=t}get privateKey(){return this._privateKey}set privateKey(t){this._privateKey=t}get miniprogramRoot(){return this._miniprogramRoot||""}set miniprogramRoot(t){this._miniprogramRoot=t}get pluginRoot(){return this._pluginRoot}set pluginRoot(t){this._pluginRoot=t}get nameMappingFromDevtools(){return this._nameMappingFromDevtools}set nameMappingFromDevtools(t){this._nameMappingFromDevtools=t}async attr(){return this._attr}async ready(){await this.wait()}getProjectType(t,e){let i="";return i=(null==t?void 0:t.gameApp)?"miniGamePlugin"===e?"miniGamePlugin":"miniGame":e,i}getProjectConfig(){let t={};const e=path_1.default.join(this.projectPath,"project.config.json");if(fs_extra_1.default.existsSync(e))try{t=fs_extra_1.default.readJsonSync(e)}catch(t){throw new Error("project.config.json not exist")}for(const e in rootConfig)"string"==typeof t[e]&&(t[e]=this.normalizeRootPath(t[e]));return t}async serialize(){const{files:t,dirs:e}=this.getFilesAndDirs();return{projectPath:this.projectPath,appid:this.appid,attr:await this.attr(),type:this.type,projectArchitecture:this.projectArchitecture,miniprogramRoot:this.miniprogramRoot,pluginRoot:this.pluginRoot,files:t,dirs:e,setting:this.setting}}updateFiles(){this.updateFileAndDirs(...arguments)}updateOptions(t){this._appid=t.appid,this._injectedPages=t.injectedPages||[],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:[]},this.event.emit("optionsChange",t)}cacheDirName(t,e){t.has(e)||(t.add(e),this.cacheDirName(t,path_1.default.posix.dirname(e)))}deleteDirOrFileOfSet(t,e,i){if(t.has(i)){t.delete(i);const r=i+"/",s=Array.from(t);for(const e of s)e.startsWith(r)&&t.delete(e);const o=Array.from(e);for(const t of o)t.startsWith(r)&&e.delete(t)}e.has(i)&&e.delete(i)}getTargetPath(t="",e=""){return(0,tools_1.normalizePath)((0,tools_1.joinPath)(t,e)).replace(/\/$/,"").replace(/^\//,"")}getFilesAndDirs(){return{files:Array.from(this._fileSet),dirs:Array.from(this._dirSet)}}exists(t="",e=""){const i=this.getTargetPath(t,e);if(!i.startsWith(t))return!1;if(this._fileSet.has(i)||this._dirSet.has(i))return!0;const r=(0,tools_1.normalizePath)((0,tools_1.joinPath)(this.projectPath,i));return fs_extra_1.default.existsSync(r)}async statAsync(t="",e=""){return this.stat(t,e)}stat(t="",e=""){if(!this.exists(t,e))return;const i=this.getTargetPath(t,e),r=path_1.default.join(this.projectPath,i);let s={};try{s=fs_extra_1.default.statSync(r)}catch(t){fs_extra_1.default.existsSync(r)||this.deleteDirOrFileOfSet(this._dirSet,this._fileSet,i)}if(this._fileSet.has(i)){return{isFile:!0,isDirectory:!1,size:this.getFileSize(t,e),mtimeMs:s.mtimeMs||""}}return this._dirSet.has(i)?{isFile:!1,isDirectory:!0,size:0,mtimeMs:s.mtimeMs}:void 0}async getAllFileInfo(t=""){const e=this.getFileList(t),i={};for(const t of e)i[t]=await this.stat("",t)||{};return i}getFileList(t="",e=""){return Array.from(this._fileSet).filter(i=>(!e||path_1.default.posix.extname(i)===e)&&!(t&&!i.startsWith(t)))}getSrcFile(t,e){t=t||"";const i=this.getTargetPath(t,e),r=(0,tools_1.normalizePath)((0,tools_1.joinPath)(this.projectPath,i));return fs_extra_1.default.readFileSync(r,null)}getFile(t,e){return this.getSrcFile(t,e)}getJson(t="",e=""){const i=this.getFile(t,e).toString("utf-8");try{return JSON.parse(i)}catch(i){throw new Error("JSON parse failed: "+this.getTargetPath(t,e))}}getFileSize(t="",e=""){const i=this.getFile(t,e);return i?i.byteLength:0}getExtAppid(){throw new Error("Method not implemented.")}async onFileChange(t,e){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),"unlinkDir"===t&&this.deleteDirOrFileOfSet(this._dirSet,this._fileSet,e),"change"===t&&this._fileSet.has(e),this.event.emit("fileChange",t,e)}clearCache(){}}exports.BaseProject=BaseProject;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BaseProject=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),events_1=tslib_1.__importDefault(require("events")),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),tools_1=require("../utils/tools"),waitable_1=tslib_1.__importDefault(require("../utils/waitable")),rootConfig={qcloudRoot:"腾讯云 wafer 方案目录",miniprogramRoot:"小程序代码的目录",srcMiniprogramRoot:"小程序源码的目录",pluginRoot:"插件目录",cloudfunctionRoot:"云函数目录",cloudfunctionTemplateRoot:"云函数本地调试模板目录",cloudcontainerRoot:"云容器目录",cloudbaseRoot:"cloudbaseRoot",jsserverRoot:"小游戏 jsserver 目录",testRoot:"自动化测试脚本录制的存放目录"};class BaseProject extends waitable_1.default{constructor(){super(...arguments),this._projectPath="",this._injectedPages=[],this._projectArchitecture="miniProgram",this._type="miniProgram",this._privateKey="",this.ignores=[],this.setting={},this._dirSet=new Set,this._fileSet=new Set,this.event=new events_1.default,this.normalizeRootPath=(t="")=>t&&"/"!==t?(t=(0,tools_1.normalizePath)(`${t}/`)).replace(/\.\.\//g,"").replace(/^\//,"").replace(/^\.\//,""):""}get projectPath(){return this._projectPath}get projectpath(){return this._projectPath}get injectedPages(){return this._injectedPages}get projectArchitecture(){return this._projectArchitecture}get srcPath(){let t="";return"miniProgramPlugin"!==this._type&&"miniGamePlugin"!==this._type||(t=(0,tools_1.normalizePath)(path_1.default.join(this.projectPath,this.pluginRoot||""))),t=(0,tools_1.normalizePath)(path_1.default.join(this.projectPath,this.miniprogramRoot||"")),(this._projectPath.startsWith("//")||this._projectPath.startsWith("\\\\"))&&(t.startsWith("//")||(t=`/${t}`)),t}get pluginSrcPath(){return(0,tools_1.normalizePath)(path_1.default.join(this.projectPath,this.pluginRoot||""))}get type(){return this._type}set type(t){this._type=t}get appid(){return this._appid}set appid(t){this._appid=t}get privateKey(){return this._privateKey}set privateKey(t){this._privateKey=t}get miniprogramRoot(){return this._miniprogramRoot||""}set miniprogramRoot(t){this._miniprogramRoot=t}get pluginRoot(){return this._pluginRoot}set pluginRoot(t){this._pluginRoot=t}get nameMappingFromDevtools(){return this._nameMappingFromDevtools}set nameMappingFromDevtools(t){this._nameMappingFromDevtools=t}async attr(){return this._attr}async ready(){await this.wait()}getProjectType(t,e){let i="";return i=(null==t?void 0:t.gameApp)?"miniGamePlugin"===e?"miniGamePlugin":"miniGame":e,i}getProjectConfig(){let t={};const e=path_1.default.join(this.projectPath,"project.config.json");if(fs_extra_1.default.existsSync(e))try{t=fs_extra_1.default.readJsonSync(e)}catch(t){throw new Error("project.config.json not exist")}for(const e in rootConfig)"string"==typeof t[e]&&(t[e]=this.normalizeRootPath(t[e]));return t}async serialize(){const{files:t,dirs:e}=this.getFilesAndDirs();return{projectPath:this.projectPath,appid:this.appid,attr:await this.attr(),type:this.type,projectArchitecture:this.projectArchitecture,miniprogramRoot:this.miniprogramRoot,pluginRoot:this.pluginRoot,files:t,dirs:e,setting:this.setting}}updateFiles(){this.updateFileAndDirs(...arguments)}updateOptions(t){this._appid=t.appid,this._injectedPages=t.injectedPages||[],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:[]},this.event.emit("optionsChange",t)}cacheDirName(t,e){t.has(e)||(t.add(e),this.cacheDirName(t,path_1.default.posix.dirname(e)))}deleteDirOrFileOfSet(t,e,i){if(t.has(i)){t.delete(i);const r=`${i}/`,s=Array.from(t);for(const e of s)e.startsWith(r)&&t.delete(e);const o=Array.from(e);for(const t of o)t.startsWith(r)&&e.delete(t)}e.has(i)&&e.delete(i)}getTargetPath(t="",e=""){return(0,tools_1.normalizePath)((0,tools_1.joinPath)(t,e)).replace(/\/$/,"").replace(/^\//,"")}getFilesAndDirs(){return{files:Array.from(this._fileSet),dirs:Array.from(this._dirSet)}}exists(t="",e=""){const i=this.getTargetPath(t,e);if(!i.startsWith(t))return!1;if(this._fileSet.has(i)||this._dirSet.has(i))return!0;const r=(0,tools_1.normalizePath)((0,tools_1.joinPath)(this.projectPath,i));return fs_extra_1.default.existsSync(r)}async statAsync(t="",e=""){return this.stat(t,e)}stat(t="",e=""){if(!this.exists(t,e))return;const i=this.getTargetPath(t,e),r=path_1.default.join(this.projectPath,i);let s={};try{s=fs_extra_1.default.statSync(r)}catch(t){fs_extra_1.default.existsSync(r)||this.deleteDirOrFileOfSet(this._dirSet,this._fileSet,i)}if(this._fileSet.has(i)){return{isFile:!0,isDirectory:!1,size:this.getFileSize(t,e),mtimeMs:s.mtimeMs||""}}return this._dirSet.has(i)?{isFile:!1,isDirectory:!0,size:0,mtimeMs:s.mtimeMs}:void 0}async getAllFileInfo(t=""){const e=this.getFileList(t),i={};for(const t of e)i[t]=await this.stat("",t)||{};return i}getFileList(t="",e=""){return Array.from(this._fileSet).filter((i=>(!e||path_1.default.posix.extname(i)===e)&&!(t&&!i.startsWith(t))))}getSrcFile(t,e){t=t||"";const i=this.getTargetPath(t,e),r=(0,tools_1.normalizePath)((0,tools_1.joinPath)(this.projectPath,i));return fs_extra_1.default.readFileSync(r,null)}getFile(t,e){return this.getSrcFile(t,e)}getJson(t="",e=""){const i=this.getFile(t,e).toString("utf-8");try{return JSON.parse(i)}catch(i){throw new Error(`JSON parse failed: ${this.getTargetPath(t,e)}`)}}getFileSize(t="",e=""){const i=this.getFile(t,e);return i?i.byteLength:0}getExtAppid(){throw new Error("Method not implemented.")}async onFileChange(t,e){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),"unlinkDir"===t&&this.deleteDirOrFileOfSet(this._dirSet,this._fileSet,e),"change"===t&&this._fileSet.has(e),this.event.emit("fileChange",t,e)}clearCache(){}}exports.BaseProject=BaseProject;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CIProjectWithMockBuffer=void 0;const ciProject_1=require("./ciProject");class CIProjectWithMockBuffer extends ciProject_1.CIProject{constructor(){super(...arguments),this.mockBuffer={}}setMockFileCache(e){Object.entries(e).forEach(([e,t])=>{this.mockBuffer[e]=Buffer.from(t)})}getFile(e,t){const r=this.getTargetPath(e,t);return this.mockBuffer[r]?this.mockBuffer[r]:super.getFile(e,t)}stat(e,t){const r=this.getTargetPath(e,t),s=super.stat(e,t);return this.mockBuffer[r]?{isFile:!0,isDirectory:!1,size:this.mockBuffer[r].byteLength,mtimeMs:(null==s?void 0:s.mtimeMs)||0}:super.stat(e,t)}}exports.CIProjectWithMockBuffer=CIProjectWithMockBuffer;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CIProjectWithMockBuffer=void 0;const ciProject_1=require("./ciProject");class CIProjectWithMockBuffer extends ciProject_1.CIProject{constructor(){super(...arguments),this.mockBuffer={}}setMockFileCache(e){Object.entries(e).forEach((([e,t])=>{this.mockBuffer[e]=Buffer.from(t)}))}getFile(e,t){const r=this.getTargetPath(e,t);return this.mockBuffer[r]?this.mockBuffer[r]:super.getFile(e,t)}stat(e,t){const r=this.getTargetPath(e,t),s=super.stat(e,t);return this.mockBuffer[r]?{isFile:!0,isDirectory:!1,size:this.mockBuffer[r].byteLength,mtimeMs:(null==s?void 0:s.mtimeMs)||0}:super.stat(e,t)}}exports.CIProjectWithMockBuffer=CIProjectWithMockBuffer;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SummerCPProject=void 0;const tools_1=require("../utils/tools"),baseProject_1=require("./baseProject");class SummerCPProject extends baseProject_1.BaseProject{constructor(t){super(),this._projectPath=(0,tools_1.normalizePath)(t.projectPath),this._appid=t.appid,this._attr=t.attr,this._type=this.getProjectType(t.attr,t.type),this._miniprogramRoot=t.miniprogramRoot,this._pluginRoot=t.pluginRoot,this._projectArchitecture=t.projectArchitecture,this.setting=t.setting,this.init(t.files,t.dirs)}async init(t,e){this.updateFileAndDirs(t,e)}updateFileAndDirs(t,e){this._fileSet=new Set(t.filter(t=>!this.isIgnore(t))),this._dirSet=new Set(e)}isIgnore(t){return t.endsWith(".d.ts")}}exports.SummerCPProject=SummerCPProject;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SummerCPProject=void 0;const tools_1=require("../utils/tools"),baseProject_1=require("./baseProject");class SummerCPProject extends baseProject_1.BaseProject{constructor(t){super(),this._projectPath=(0,tools_1.normalizePath)(t.projectPath),this._appid=t.appid,this._attr=t.attr,this._type=this.getProjectType(t.attr,t.type),this._miniprogramRoot=t.miniprogramRoot,this._pluginRoot=t.pluginRoot,this._projectArchitecture=t.projectArchitecture,this.setting=t.setting,this.init(t.files,t.dirs)}async init(t,e){this.updateFileAndDirs(t,e)}updateFileAndDirs(t,e){this._fileSet=new Set(t.filter((t=>!this.isIgnore(t)))),this._dirSet=new Set(e)}isIgnore(t){return t.endsWith(".d.ts")}}exports.SummerCPProject=SummerCPProject;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CIAppDirService=void 0;class CIAppDirService{async init(){return{}}async get(e){return""}async cleanDir(e){}}exports.CIAppDirService=CIAppDirService;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.EServiceEnviroment=void 0,exports.initServices=initServices;const vsbase_1=require("../common/vsbase"),nativeModule_1=require("../nativeModule/common/nativeModule"),createService_1=require("../root/common/createService"),appDirService_1=require("../app/common/appDirService");var EServiceEnviroment;let _env;function getRootFactory(){let e;if(_env===EServiceEnviroment.SERVER)e=require("../root/server/root").Root;else if(_env===EServiceEnviroment.ELECTRON)e=require("../root/electron/root").Root;else if(_env===EServiceEnviroment.NW)e=require("../root/nw/root").Root;else{if(_env!==EServiceEnviroment.NODE)throw new Error("[Builder Services] Not Define Env");e=require("../root/node/root").Root}return e}!function(e){e.ELECTRON="ELECTRON",e.SERVER="SERVER",e.NW="NW",e.NODE="NODE"}(EServiceEnviroment||(exports.EServiceEnviroment=EServiceEnviroment={}));let _Root=null;function getServiceFactory(){return function(e){var r;let o;return _Root||(_Root=getRootFactory()),null===(r=_Root.iis)||void 0===r||r.invokeFunction(r=>{o=r.get(e)}),o}}async function initServices(e,r,o){let t,i;o&&(0,vsbase_1.setGetVsBaseBundle)(o),_env=e,e===EServiceEnviroment.SERVER?(i=require("../root/server/root").Root,t=require("../root/server/rootService").getSingletonServiceDescriptors):e===EServiceEnviroment.ELECTRON?(i=require("../root/electron/root").Root,t=require("../root/electron/rootService").getSingletonServiceDescriptors):e===EServiceEnviroment.NW?(i=require("../root/nw/root").Root,t=require("../root/nw/rootService").getSingletonServiceDescriptors):e===EServiceEnviroment.NODE&&(i=require("../root/node/root").Root,t=require("../root/node/rootService").getSingletonServiceDescriptors);const n=(0,createService_1.createService)(t());i.initIisWithServices(n.instantiationService),i.iis.invokeFunction(async e=>{"NativeModule"in r&&(e.get(nativeModule_1.INativeModuleService).setWXMLParsePath(r.NativeModule.WXMLParsePath),e.get(nativeModule_1.INativeModuleService).setWXSSParsePath(r.NativeModule.WXSSParsePath),e.get(nativeModule_1.INativeModuleService).setGlassEaselLazyModulePath(r.NativeModule.GlassEaselLazyModulePath),e.get(appDirService_1.IAppDirService).init(r.AppDirService))})}exports.default=getServiceFactory();
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.EServiceEnviroment=void 0,exports.initServices=initServices,exports.getServicesEnv=getServicesEnv,exports.initServicesByEnv=initServicesByEnv;const vsbase_1=require("../common/vsbase"),nativeModule_1=require("../nativeModule/common/nativeModule"),createService_1=require("../root/common/createService"),appDirService_1=require("../app/common/appDirService");var EServiceEnviroment;let _env;function getRootFactory(){let e;if(console.log("[miniprogram-builder] getservice",_env),_env===EServiceEnviroment.SERVER)e=require("../root/server/root").Root;else if(_env===EServiceEnviroment.ELECTRON)e=require("../root/electron/root").Root;else if(_env===EServiceEnviroment.NW)e=require("../root/nw/root").Root;else if(_env===EServiceEnviroment.CI)e=require("../root/ci/root").Root;else{if(_env!==EServiceEnviroment.WEBIDE)throw new Error("[Builder Services] Not Define Env");e=require("../root/webide/root").Root}return e}!function(e){e.ELECTRON="ELECTRON",e.SERVER="SERVER",e.NW="NW",e.CI="CI",e.WEBIDE="WEBIDE"}(EServiceEnviroment||(exports.EServiceEnviroment=EServiceEnviroment={}));let _Root=null;function getServiceFactory(){return function(e){var r;let i;return _Root||(_Root=getRootFactory()),null===(r=_Root.iis)||void 0===r||r.invokeFunction((r=>{i=r.get(e)})),i}}function initServices(e,r,i){let o,t;if(i&&(0,vsbase_1.setGetVsBaseBundle)(i),_env=e,console.log("[miniprogram-builder] initservices",_env),e===EServiceEnviroment.SERVER)t=require("../root/server/root").Root,o=require("../root/server/rootService").getSingletonServiceDescriptors;else if(e===EServiceEnviroment.ELECTRON)t=require("../root/electron/root").Root,o=require("../root/electron/rootService").getSingletonServiceDescriptors;else if(e===EServiceEnviroment.NW)t=require("../root/nw/root").Root,o=require("../root/nw/rootService").getSingletonServiceDescriptors;else if(e===EServiceEnviroment.CI)t=require("../root/ci/root").Root,o=require("../root/ci/rootService").getSingletonServiceDescriptors;else{if(e!==EServiceEnviroment.WEBIDE)throw new Error("[Builder Services] Not Define Env");t=require("../root/webide/root").Root,o=require("../root/webide/rootService").getSingletonServiceDescriptors}const n=(0,createService_1.createService)(o());t.initIisWithServices(n.instantiationService),t.iis.invokeFunction((e=>{"NativeModule"in r&&(e.get(nativeModule_1.INativeModuleService).setWXMLParsePath(r.NativeModule.WXMLParsePath),e.get(nativeModule_1.INativeModuleService).setWXSSParsePath(r.NativeModule.WXSSParsePath),e.get(nativeModule_1.INativeModuleService).setGlassEaselTemplateCompilerPath(r.NativeModule.GlassEaselLazyModulePath),e.get(appDirService_1.IAppDirService).init(r.AppDirService))}))}function getServicesEnv(){let e=EServiceEnviroment.ELECTRON;return e=EServiceEnviroment.CI,e}function initServicesByEnv(){let e=EServiceEnviroment.ELECTRON;e=EServiceEnviroment.CI,e===EServiceEnviroment.ELECTRON&&global.BACKEND||initServices(e,{})}exports.default=getServiceFactory();
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.vsbase=void 0,exports.setGetVsBaseBundle=setGetVsBaseBundle;const librarybase_1=require("./librarybase");let _getvsBase,_vsBase;Object.defineProperty(exports,"vsbase",{enumerable:!0,get:function(){return librarybase_1.vslib}});const getLocalVsBaseBundle=()=>{if(!_vsBase)try{_vsBase=require("../../vendor/vslibrary/bundled/base.bundled.js")}catch(e){}return _vsBase};function setGetVsBaseBundle(e){_getvsBase=e}(0,librarybase_1.setLoaderFn)(e=>getLocalVsBaseBundle().editorbase.getLoad()(e));
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.vsbase=void 0,exports.setGetVsBaseBundle=setGetVsBaseBundle;const librarybase_1=require("./librarybase");let _getvsBase,_vsBase;Object.defineProperty(exports,"vsbase",{enumerable:!0,get:function(){return librarybase_1.vslib}});const getLocalVsBaseBundle=()=>{if(!_vsBase)try{_vsBase=require("../../vendor/vslibrary/bundled/base.bundled.js")}catch(e){}return _vsBase};function setGetVsBaseBundle(e){_getvsBase=e}(0,librarybase_1.setLoaderFn)((e=>getLocalVsBaseBundle().editorbase.getLoad()(e)));
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compileUseWCC=compileUseWCC,exports.compileWxmlToGlassEasel=compileWxmlToGlassEasel;const tslib_1=require("tslib"),getservice_1=tslib_1.__importDefault(require("../../common/getservice")),nativeModule_1=require("../../nativeModule/common/nativeModule"),genTempFileService_1=require("../../genTempFile/common/genTempFileService"),common_1=require("../../../utils/node/common"),tools_1=require("../../../utils/tools"),fs=require("fs"),path=require("path"),{spawn:spawn}=require("child_process");async function compileUseWCC(e){const{isCut:t,configContent:a,configSplit:n,files:s,genfuncName:i,cwd:o,hasWxs:l,lazyloadConfig:r,isPlugin:c}=e,u=Date.now();let m=["-d","--split",n,t?"-xc":"-cc",a];l&&m.unshift("-ds"),r&&(m=m.concat([t?"-lla":"-llw",r])),m=c?m.concat(s).concat(["-p","-gn",i]):m.concat(s).concat(["-gn",i]);const p=await(0,getservice_1.default)(genTempFileService_1.IGenTempFile).genPath(),g=(0,common_1.shouldUseConfigFile)(m);g&&fs.writeFileSync(p,m.join("\n"));const d=(0,getservice_1.default)(nativeModule_1.INativeModuleService),f=await d.getWXMLParsePath(),_=spawn(f,g?["--config-path",(0,tools_1.normalizePath)(p)]:m,{cwd:o}),w=[],h=[];return _.stdout.on("data",e=>{w.push(e)}),_.stderr.on("data",e=>{h.push(e)}),new Promise((e,t)=>{_.on("close",a=>{if(g&&fs.unlinkSync(p),console.warn("[wcc bindary] compile cost:",Date.now()-u),0===a){const a=Buffer.concat(w).toString();if(!r)return e({code:a,name:i});try{const{generateFunctionContent:t,generateFunctionName:n}=JSON.parse(a);return e({pages:t,names:n})}catch(e){return t(new Error("lazyload parse wxml fail: "+e))}}return t(new Error(Buffer.concat(h).toString()))})})}async function compileWxmlToGlassEasel(e){const t=(0,getservice_1.default)(nativeModule_1.INativeModuleService),a=await t.getWXMLParsePath(),n=(0,getservice_1.default)(genTempFileService_1.IGenTempFile).genPath(),s=path.join(await t.getGlassEaselLazyModulePath(),"glass_easel_template_compiler.js"),i=require("./compileglasseasel.js");return await i({taskName:"compileglasseasel",dataStr:JSON.stringify({wxmlParserPath:a,tempCompileConfigFilePath:n,wxmlAndWxsFiles:e.wxmlAndWxsFiles,glassEaselTemplateCompilerPath:s}),useBackup:!1})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compileUseWCC=compileUseWCC,exports.compileWxmlToGlassEasel=compileWxmlToGlassEasel;const tslib_1=require("tslib"),getservice_1=tslib_1.__importDefault(require("../../common/getservice")),nativeModule_1=require("../../nativeModule/common/nativeModule"),genTempFileService_1=require("../../genTempFile/common/genTempFileService"),common_1=require("../../../utils/node/common"),tools_1=require("../../../utils/tools"),fs=require("fs"),compileglasseasel_1=tslib_1.__importDefault(require("./compileglasseasel")),{spawn:spawn}=require("child_process");async function compileUseWCC(e){const{isCut:t,configContent:i,configSplit:n,files:o,genfuncName:a,cwd:l,hasWxs:s,lazyloadConfig:r,isPlugin:c}=e,m=Date.now();let u=["-d","--split",n,t?"-xc":"-cc",i];s&&u.unshift("-ds"),r&&(u=u.concat([t?"-lla":"-llw",r])),u=c?u.concat(o).concat(["-p","-gn",a]):u.concat(o).concat(["-gn",a]);const p=await(0,getservice_1.default)(genTempFileService_1.IGenTempFile).genPath(),g=(0,common_1.shouldUseConfigFile)(u);g&&fs.writeFileSync(p,u.join("\n"));const d=(0,getservice_1.default)(nativeModule_1.INativeModuleService),f=await d.getWXMLParsePath(),_=spawn(f,g?["--config-path",(0,tools_1.normalizePath)(p)]:u,{cwd:l}),w=[],v=[];return _.stdout.on("data",(e=>{w.push(e)})),_.stderr.on("data",(e=>{v.push(e)})),new Promise(((e,t)=>{_.on("close",(i=>{if(g&&fs.unlinkSync(p),console.warn("[wcc bindary] compile cost:",Date.now()-m),0===i){const i=Buffer.concat(w).toString();if(!r)return e({code:i,name:a});try{const{generateFunctionContent:t,generateFunctionName:n}=JSON.parse(i);return e({pages:t,names:n})}catch(e){return t(new Error(`lazyload parse wxml fail: ${e}`))}}return t(new Error(Buffer.concat(v).toString()))}))}))}async function compileWxmlToGlassEasel(e){const t=(0,getservice_1.default)(nativeModule_1.INativeModuleService),i=await t.getWXMLParsePath(),n=await(0,getservice_1.default)(genTempFileService_1.IGenTempFile).genPath(),o=await t.getGlassEaselTemplateCompilerPath();return await(0,compileglasseasel_1.default)({wxmlParserPath:i,tempCompileConfigFilePath:n,wxmlAndWxsFiles:e.wxmlAndWxsFiles,glassEaselTemplateCompilerPath:o})}
@@ -1 +1 @@
1
- "use strict";
1
+ "use strict";const childProcess=require("child_process"),fs=require("fs");async function wxsPreCompiler(e,t,n){fs.writeFileSync(t,JSON.stringify(n));const r=childProcess.spawn(e,["--wxs",t]),s=[],o=[];r.stdout.on("data",(e=>{s.push(e)})),r.stderr.on("data",(e=>{o.push(e)}));return await new Promise(((e,n)=>{r.on("close",(r=>{if(fs.unlinkSync(t),0===r){const t=Buffer.concat(s).toString();try{return e(JSON.parse(t))}catch(e){return n(new Error(`parse result json content fail: ${e}`))}}return n(new Error(Buffer.concat(o).toString()))}))}))}let runtimeGlobals="";async function getRuntimeGlobals(e){if(!runtimeGlobals){const t=childProcess.spawn(e,["--runtime-globals"]),n=[],r=[];t.stdout.on("data",(e=>{n.push(e)})),t.stderr.on("data",(e=>{r.push(e)})),runtimeGlobals=await new Promise(((e,s)=>{t.on("close",(t=>{if(0===t){const t=Buffer.concat(n).toString();return e(t)}return s(new Error(Buffer.concat(r).toString()))}))}))}return runtimeGlobals}let wxsEnvContent="";async function getWxsEnvContent(e){if(!wxsEnvContent){const t=childProcess.spawn(e,["--wxs-env"]),n=[],r=[];t.stdout.on("data",(e=>{n.push(e)})),t.stderr.on("data",(e=>{r.push(e)})),wxsEnvContent=await new Promise(((e,s)=>{t.on("close",(t=>{if(0===t){const t=Buffer.concat(n).toString();return e(t)}return s(new Error(Buffer.concat(r).toString()))}))}))}return wxsEnvContent}function toNormalizeName(e,t){let n=e;return n.endsWith(t)&&(n=n.slice(0,-t.length)),n.startsWith("./")&&(n=n.slice(2)),n.startsWith("/")&&(n=n.slice(1)),n}module.exports=async function(e){const{wxmlParserPath:t,tempCompileConfigFilePath:n,wxmlAndWxsFiles:r,glassEaselTemplateCompilerPath:s}=e,o={},i={},a=require(s);Object.entries(r).forEach((([e,t])=>{e.endsWith(".wxs")?o[toNormalizeName(e,".wxs")]=t:e.endsWith(".wxml")&&(i[toNormalizeName(e,".wxml")]=t)}));let c=!1;const l=[],u={},m=a.TmplGroup.newDev();Object.entries(i).forEach((([e,t])=>{const n=m.addTmpl(e,t);c||(c=n.some((e=>"Fatal"===e.level))),n.forEach((t=>{l.push(`- /${e}.wxml:${t.startLine+1}:${t.startColumn}-${t.endLine+1}:${t.endColumn}: ${t.level}: ${t.message}`)}));try{m.getInlineScriptModuleNames(e).forEach((t=>{const n=m.getInlineScript(e,t);u[`${e}#${t}`]=n,m.setInlineScript(e,t,"")}))}catch(t){l.push(`- /${e}.wxml: Get inline WXS error ${t.message}`)}}));const p=await wxsPreCompiler(t,n,u),w=Object.entries(p).map((([e,t])=>{const n=JSON.stringify(e);return`R[${n}]=D(${n},(require,exports,module)=>{${t}})`})).join(";"),f=await wxsPreCompiler(t,n,o);Object.entries(f).forEach((([e,t])=>{m.addScript(e,t)}));const h={},d={};Object.keys(i).forEach((e=>{try{h[e]=m.getTmplGenObject(e);const t=m.getDirectDependencies(e);t.length>0&&(d[e]=t)}catch(t){l.push(`- /${e}.wxml: Get compile result error: ${t.message}`)}}));const g=`${m.exportAllScripts()};${w}`,x=m.getRuntimeString();if(m.free(),c)throw new Error(`Failed to compile WXML files:\n\n${l.join("\n")}`);return{templateResults:h,wxmlDependencies:d,scriptResult:g,runtimeString:x,runtimeGlobals:await getRuntimeGlobals(t),wxsEnvContent:await getWxsEnvContent(t)}};