miniprogram-ci 2.1.33 → 2.1.35

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 (200) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/README.md +3 -1
  3. package/dist/@types/common/code-analyse/index.d.ts +2 -0
  4. package/dist/@types/config/config.d.ts +1 -1
  5. package/dist/@types/index.d.ts +0 -2
  6. package/dist/@types/modules/corecompiler/original/workerThread/config.d.ts +4 -3
  7. package/dist/@types/modules/corecompiler/original/workerThread/task/func.d.ts +0 -4
  8. package/dist/@types/modules/corecompiler/summerCompiler.d.ts +1 -4
  9. package/dist/@types/modules/nativecompiler/ios/buildCloud.d.ts +2 -0
  10. package/dist/@types/schema/@types/appjson.d.ts +3 -0
  11. package/dist/@types/services/pluginFileReader/common/pluginFileReader.d.ts +3 -4
  12. package/dist/@types/utils/asar.d.ts +1 -0
  13. package/dist/@types/utils/customError.d.ts +1 -1
  14. package/dist/@types/utils/packOptionsHelper.d.ts +1 -1
  15. package/dist/common/code-analyse/index.js +1 -1
  16. package/dist/config/config.js +1 -1
  17. package/dist/index.js +1 -1
  18. package/dist/modules/corecompiler/original/workerThread/config.js +1 -1
  19. package/dist/modules/corecompiler/original/workerThread/task/func.js +1 -1
  20. package/dist/modules/corecompiler/original/workerThread/worker.js +1 -1
  21. package/dist/modules/corecompiler/original/workerThread/workerManager.js +1 -1
  22. package/dist/modules/corecompiler/processHandler.js +1 -1
  23. package/dist/modules/corecompiler/summer/graph/appconf.js +1 -1
  24. package/dist/modules/corecompiler/summer/plugins/script_task/swc_task.js +1 -1
  25. package/dist/modules/corecompiler/summer/worker.js +1 -1
  26. package/dist/modules/corecompiler/summerCompiler.js +1 -1
  27. package/dist/modules/nativecompiler/ios/buildCloud.js +1 -1
  28. package/dist/schema/dist/app.js +18 -0
  29. package/dist/services/common/getservice.js +1 -1
  30. package/dist/services/multiTaskManager/electron/multiTaskManager.js +1 -1
  31. package/dist/utils/asar.js +1 -0
  32. package/dist/utils/codesign.js +1 -1
  33. package/dist/utils/customError.js +1 -1
  34. package/dist/utils/packOptionsHelper.js +1 -1
  35. package/dist/utils/subprocess/processService.js +1 -1
  36. package/dist/utils/swc_config.js +1 -1
  37. package/dist/vendor/swc_runtime/_apply_decorated_descriptor.js +1 -1
  38. package/dist/vendor/swc_runtime/_apply_decs_2203_r.js +1 -1
  39. package/dist/vendor/swc_runtime/_array_like_to_array.js +1 -1
  40. package/dist/vendor/swc_runtime/_array_with_holes.js +1 -1
  41. package/dist/vendor/swc_runtime/_array_without_holes.js +1 -1
  42. package/dist/vendor/swc_runtime/_assert_this_initialized.js +1 -1
  43. package/dist/vendor/swc_runtime/_async_generator.js +1 -1
  44. package/dist/vendor/swc_runtime/_async_generator_delegate.js +1 -1
  45. package/dist/vendor/swc_runtime/_async_iterator.js +1 -1
  46. package/dist/vendor/swc_runtime/_async_to_generator.js +1 -1
  47. package/dist/vendor/swc_runtime/_await_async_generator.js +1 -1
  48. package/dist/vendor/swc_runtime/_await_value.js +1 -1
  49. package/dist/vendor/swc_runtime/_call_super.js +1 -0
  50. package/dist/vendor/swc_runtime/_check_private_redeclaration.js +1 -1
  51. package/dist/vendor/swc_runtime/_class_apply_descriptor_destructure.js +1 -1
  52. package/dist/vendor/swc_runtime/_class_apply_descriptor_get.js +1 -1
  53. package/dist/vendor/swc_runtime/_class_apply_descriptor_set.js +1 -1
  54. package/dist/vendor/swc_runtime/_class_apply_descriptor_update.js +1 -1
  55. package/dist/vendor/swc_runtime/_class_call_check.js +1 -1
  56. package/dist/vendor/swc_runtime/_class_check_private_static_access.js +1 -1
  57. package/dist/vendor/swc_runtime/_class_check_private_static_field_descriptor.js +1 -1
  58. package/dist/vendor/swc_runtime/_class_extract_field_descriptor.js +1 -1
  59. package/dist/vendor/swc_runtime/_class_name_tdz_error.js +1 -1
  60. package/dist/vendor/swc_runtime/_class_private_field_destructure.js +1 -1
  61. package/dist/vendor/swc_runtime/_class_private_field_get.js +1 -1
  62. package/dist/vendor/swc_runtime/_class_private_field_init.js +1 -1
  63. package/dist/vendor/swc_runtime/_class_private_field_loose_base.js +1 -1
  64. package/dist/vendor/swc_runtime/_class_private_field_loose_key.js +1 -1
  65. package/dist/vendor/swc_runtime/_class_private_field_set.js +1 -1
  66. package/dist/vendor/swc_runtime/_class_private_field_update.js +1 -1
  67. package/dist/vendor/swc_runtime/_class_private_method_get.js +1 -1
  68. package/dist/vendor/swc_runtime/_class_private_method_init.js +1 -1
  69. package/dist/vendor/swc_runtime/_class_private_method_set.js +1 -1
  70. package/dist/vendor/swc_runtime/_class_static_private_field_destructure.js +1 -1
  71. package/dist/vendor/swc_runtime/_class_static_private_field_spec_get.js +1 -1
  72. package/dist/vendor/swc_runtime/_class_static_private_field_spec_set.js +1 -1
  73. package/dist/vendor/swc_runtime/_class_static_private_field_update.js +1 -1
  74. package/dist/vendor/swc_runtime/_class_static_private_method_get.js +1 -1
  75. package/dist/vendor/swc_runtime/_construct.js +1 -1
  76. package/dist/vendor/swc_runtime/_create_class.js +1 -1
  77. package/dist/vendor/swc_runtime/_create_for_of_iterator_helper_loose.js +1 -1
  78. package/dist/vendor/swc_runtime/_create_super.js +1 -1
  79. package/dist/vendor/swc_runtime/_decorate.js +1 -1
  80. package/dist/vendor/swc_runtime/_defaults.js +1 -1
  81. package/dist/vendor/swc_runtime/_define_enumerable_properties.js +1 -1
  82. package/dist/vendor/swc_runtime/_define_property.js +1 -1
  83. package/dist/vendor/swc_runtime/_dispose.js +1 -1
  84. package/dist/vendor/swc_runtime/_export_star.js +1 -1
  85. package/dist/vendor/swc_runtime/_extends.js +1 -1
  86. package/dist/vendor/swc_runtime/_get.js +1 -1
  87. package/dist/vendor/swc_runtime/_get_prototype_of.js +1 -1
  88. package/dist/vendor/swc_runtime/_identity.js +1 -1
  89. package/dist/vendor/swc_runtime/_inherits.js +1 -1
  90. package/dist/vendor/swc_runtime/_inherits_loose.js +1 -1
  91. package/dist/vendor/swc_runtime/_initializer_define_property.js +1 -1
  92. package/dist/vendor/swc_runtime/_initializer_warning_helper.js +1 -1
  93. package/dist/vendor/swc_runtime/_instanceof.js +1 -1
  94. package/dist/vendor/swc_runtime/_interop_require_default.js +1 -1
  95. package/dist/vendor/swc_runtime/_interop_require_wildcard.js +1 -1
  96. package/dist/vendor/swc_runtime/_is_native_function.js +1 -1
  97. package/dist/vendor/swc_runtime/_is_native_reflect_construct.js +1 -1
  98. package/dist/vendor/swc_runtime/_iterable_to_array.js +1 -1
  99. package/dist/vendor/swc_runtime/_iterable_to_array_limit.js +1 -1
  100. package/dist/vendor/swc_runtime/_iterable_to_array_limit_loose.js +1 -1
  101. package/dist/vendor/swc_runtime/_jsx.js +1 -1
  102. package/dist/vendor/swc_runtime/_new_arrow_check.js +1 -1
  103. package/dist/vendor/swc_runtime/_non_iterable_rest.js +1 -1
  104. package/dist/vendor/swc_runtime/_non_iterable_spread.js +1 -1
  105. package/dist/vendor/swc_runtime/_object_destructuring_empty.js +1 -1
  106. package/dist/vendor/swc_runtime/_object_spread.js +1 -1
  107. package/dist/vendor/swc_runtime/_object_spread_props.js +1 -1
  108. package/dist/vendor/swc_runtime/_object_without_properties.js +1 -1
  109. package/dist/vendor/swc_runtime/_object_without_properties_loose.js +1 -1
  110. package/dist/vendor/swc_runtime/_overload_yield.js +1 -0
  111. package/dist/vendor/swc_runtime/_possible_constructor_return.js +1 -1
  112. package/dist/vendor/swc_runtime/_read_only_error.js +1 -1
  113. package/dist/vendor/swc_runtime/_set.js +1 -1
  114. package/dist/vendor/swc_runtime/_set_prototype_of.js +1 -1
  115. package/dist/vendor/swc_runtime/_skip_first_generator_next.js +1 -1
  116. package/dist/vendor/swc_runtime/_sliced_to_array.js +1 -1
  117. package/dist/vendor/swc_runtime/_sliced_to_array_loose.js +1 -1
  118. package/dist/vendor/swc_runtime/_super_prop_base.js +1 -1
  119. package/dist/vendor/swc_runtime/_tagged_template_literal.js +1 -1
  120. package/dist/vendor/swc_runtime/_tagged_template_literal_loose.js +1 -1
  121. package/dist/vendor/swc_runtime/_throw.js +1 -1
  122. package/dist/vendor/swc_runtime/_to_array.js +1 -1
  123. package/dist/vendor/swc_runtime/_to_consumable_array.js +1 -1
  124. package/dist/vendor/swc_runtime/_to_primitive.js +1 -1
  125. package/dist/vendor/swc_runtime/_to_property_key.js +1 -1
  126. package/dist/vendor/swc_runtime/_ts_add_disposable_resource.js +1 -0
  127. package/dist/vendor/swc_runtime/_ts_decorate.js +1 -1
  128. package/dist/vendor/swc_runtime/_ts_dispose_resources.js +1 -0
  129. package/dist/vendor/swc_runtime/_ts_generator.js +1 -1
  130. package/dist/vendor/swc_runtime/_ts_metadata.js +1 -1
  131. package/dist/vendor/swc_runtime/_ts_param.js +1 -1
  132. package/dist/vendor/swc_runtime/_ts_values.js +1 -1
  133. package/dist/vendor/swc_runtime/_type_of.js +1 -1
  134. package/dist/vendor/swc_runtime/_unsupported_iterable_to_array.js +1 -1
  135. package/dist/vendor/swc_runtime/_update.js +1 -1
  136. package/dist/vendor/swc_runtime/_using.js +1 -1
  137. package/dist/vendor/swc_runtime/_using_ctx.js +1 -0
  138. package/dist/vendor/swc_runtime/_wrap_async_generator.js +1 -1
  139. package/dist/vendor/swc_runtime/_wrap_native_super.js +1 -1
  140. package/dist/vendor/swc_runtime/_write_only_error.js +1 -1
  141. package/dist/vendor/swc_runtime/index.js +1 -1
  142. package/package.json +3 -60
  143. package/dist/@types/modules/corecompiler/summer/pipeManager/index.d.ts +0 -6
  144. package/dist/@types/modules/corecompiler/summer/pipeManager/pipeCPProject.d.ts +0 -17
  145. package/dist/@types/modules/corecompiler/summer/pipeManager/pipeContext.d.ts +0 -10
  146. package/dist/@types/modules/corecompiler/summer/pipeManager/pipeManager.d.ts +0 -12
  147. package/dist/@types/modules/corecompiler/summer/pipeManager/pipeWorker.d.ts +0 -2
  148. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/appservicePipe/index.d.ts +0 -3
  149. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/compileWxmlToGlassEaselPipe.d.ts +0 -3
  150. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/compileWxssPipe.d.ts +0 -3
  151. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/index.d.ts +0 -2
  152. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/pageInitSourcePipe/index.d.ts +0 -4
  153. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/pageframePipe/index.d.ts +0 -3
  154. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/appdevserver/getAppService.d.ts +0 -6
  155. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/appdevserver/getwxappcode.d.ts +0 -9
  156. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/appservice/getjsfile.d.ts +0 -12
  157. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/appservice/getmainpkgsortedjsfiles.d.ts +0 -11
  158. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/appservice/getwxappcode.d.ts +0 -8
  159. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/common/apperrcode.config.d.ts +0 -92
  160. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/common/tools.d.ts +0 -1
  161. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/project/appconfig.d.ts +0 -6
  162. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/project/appjson.d.ts +0 -3
  163. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/project/customcomponent.d.ts +0 -21
  164. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/project/helper/theme.d.ts +0 -40
  165. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/project/pagejson.d.ts +0 -3
  166. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/project/wxappcodejson.d.ts +0 -3
  167. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/trans/transwxmltojs.d.ts +0 -19
  168. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/trans/transwxsstojs.d.ts +0 -15
  169. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/web/processPath.d.ts +0 -9
  170. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/wccPipe.d.ts +0 -3
  171. package/dist/@types/modules/corecompiler/summer/pipeManager/types.d.ts +0 -100
  172. package/dist/modules/corecompiler/summer/pipeManager/index.js +0 -1
  173. package/dist/modules/corecompiler/summer/pipeManager/pipeCPProject.js +0 -1
  174. package/dist/modules/corecompiler/summer/pipeManager/pipeContext.js +0 -1
  175. package/dist/modules/corecompiler/summer/pipeManager/pipeManager.js +0 -1
  176. package/dist/modules/corecompiler/summer/pipeManager/pipeWorker.js +0 -1
  177. package/dist/modules/corecompiler/summer/pipeManager/pipes/appservicePipe/index.js +0 -1
  178. package/dist/modules/corecompiler/summer/pipeManager/pipes/compileWxmlToGlassEaselPipe.js +0 -1
  179. package/dist/modules/corecompiler/summer/pipeManager/pipes/compileWxssPipe.js +0 -1
  180. package/dist/modules/corecompiler/summer/pipeManager/pipes/index.js +0 -1
  181. package/dist/modules/corecompiler/summer/pipeManager/pipes/pageInitSourcePipe/index.js +0 -1
  182. package/dist/modules/corecompiler/summer/pipeManager/pipes/pageframePipe/index.js +0 -1
  183. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/appdevserver/getAppService.js +0 -1
  184. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/appdevserver/getwxappcode.js +0 -1
  185. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/appservice/getjsfile.js +0 -1
  186. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/appservice/getmainpkgsortedjsfiles.js +0 -1
  187. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/appservice/getwxappcode.js +0 -1
  188. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/common/apperrcode.config.js +0 -1
  189. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/common/tools.js +0 -1
  190. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/project/appconfig.js +0 -1
  191. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/project/appjson.js +0 -1
  192. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/project/customcomponent.js +0 -1
  193. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/project/helper/theme.js +0 -1
  194. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/project/pagejson.js +0 -1
  195. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/project/wxappcodejson.js +0 -1
  196. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/trans/transwxmltojs.js +0 -1
  197. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/trans/transwxsstojs.js +0 -1
  198. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/web/processPath.js +0 -1
  199. package/dist/modules/corecompiler/summer/pipeManager/pipes/wccPipe.js +0 -1
  200. package/dist/modules/corecompiler/summer/pipeManager/types.js +0 -1
@@ -1 +1 @@
1
- "use strict";var COMPILE_TYPE,AstType,EFilterCode;function getDefaultIgnores(e){const _=["node_modules/**/*","**/node_modules/**","**/.git/**",".git/**/*","**/.svn/**",".svn/**/*",".DS_Store","**/.DS_Store"];return"multiPlatform"===e.projectArchitecture&&_.push(`${exports.multiPlatformRoot}/**/*`),_}Object.defineProperty(exports,"__esModule",{value:!0}),exports.MAX_CODE_LENGTH=exports.EFilterCode=exports.AstType=exports.compileTypeConfig=exports.FullPkg=exports.MainPkg=exports.multiPlatformRoot=exports.extendedLibMap=exports.jsonVariablePropertyWhiteList=exports.DefaultProjectAttr=exports.TABBAR_ICON_WHITE_LIST=exports.COMPILE_TYPE=exports.APP_TYPE=exports.MINI_GAME_WORKERS_PACKAGE_ROOT=exports.MINI_GAME_MAIN_PACKAGE_ROOT=exports.MINI_PROGRAM_MAIN_PACKAGE_ROOT=exports.PROJECT_TYPE_ERROR=exports.GET_LATEST_VERSION_CGI_ERR=exports.UPLOAD_JS_SERVER_CGI_ERR=exports.CODE_PROTECT_TRANSLATE_FILENAME=exports.UPLOAD_CGI_ERR=exports.GENERATE_LOCAL_SIGNATURE_ERR=exports.GET_SIGNATURE_RAND_STRING_ERR=exports.APP_JSON_NOT_FOUND=exports.JSON_CONTENT_ERR=exports.FILE_NOT_UTF8=exports.JSON_PARSE_ERR=exports.FILE_NOT_FOUND=exports.PLUGIN_JSON_PARSE_ERR=exports.PLUGIN_JSON_CONTENT_ERR=exports.PLUGIN_JSON_FILE_NOT_FOUND=exports.GAME_PLUGIN_LIB_MD5_NOT_MATCH=exports.SUMMER_PLUGIN_CODE_ERR=exports.SUMMER_PLUGIN_ERR=exports.MINIFY_WXML_ERR=exports.POST_WXSS_ERR=exports.FILE_FLAT_ERR=exports.JS_ES6_ERR=exports.BABILI_JS_ERR=exports.UGLIFY_JS_ERR=exports.BABEL_TRANS_JS_ERR=exports.JS_NOT_FOUND=exports.WXML_NOT_FOUND=exports.PARAM_ERROR=exports.CI_VERSION=void 0,exports.getDefaultIgnores=getDefaultIgnores,exports.CI_VERSION="2.1.33",exports.PARAM_ERROR=1e4,exports.WXML_NOT_FOUND=10007,exports.JS_NOT_FOUND=10008,exports.BABEL_TRANS_JS_ERR=10032,exports.UGLIFY_JS_ERR=10033,exports.BABILI_JS_ERR=10034,exports.JS_ES6_ERR=10035,exports.FILE_FLAT_ERR=10036,exports.POST_WXSS_ERR=10037,exports.MINIFY_WXML_ERR=10038,exports.SUMMER_PLUGIN_ERR=10045,exports.SUMMER_PLUGIN_CODE_ERR=10046,exports.GAME_PLUGIN_LIB_MD5_NOT_MATCH=10081,exports.PLUGIN_JSON_FILE_NOT_FOUND=10091,exports.PLUGIN_JSON_CONTENT_ERR=10092,exports.PLUGIN_JSON_PARSE_ERR=10093,exports.FILE_NOT_FOUND=10005,exports.JSON_PARSE_ERR=10006,exports.FILE_NOT_UTF8=10031,exports.JSON_CONTENT_ERR=10009,exports.APP_JSON_NOT_FOUND=2e4,exports.GET_SIGNATURE_RAND_STRING_ERR=20001,exports.GENERATE_LOCAL_SIGNATURE_ERR=20002,exports.UPLOAD_CGI_ERR=20003,exports.CODE_PROTECT_TRANSLATE_FILENAME=20004,exports.UPLOAD_JS_SERVER_CGI_ERR=20005,exports.GET_LATEST_VERSION_CGI_ERR=20006,exports.PROJECT_TYPE_ERROR=3e4,exports.MINI_PROGRAM_MAIN_PACKAGE_ROOT="__APP__",exports.MINI_GAME_MAIN_PACKAGE_ROOT="__GAME__",exports.MINI_GAME_WORKERS_PACKAGE_ROOT="workers.js",exports.APP_TYPE={NORMAL:0,PLUGIN:1,SHOP:2,MINISHOP:3,GAME:4,CARD:5,NATIVE:7},function(e){e.miniProgram="miniProgram",e.miniProgramPlugin="miniProgramPlugin",e.miniGame="miniGame",e.miniGamePlugin="miniGamePlugin"}(COMPILE_TYPE||(exports.COMPILE_TYPE=COMPILE_TYPE={})),exports.TABBAR_ICON_WHITE_LIST=[".png",".jpg",".jpeg"],exports.DefaultProjectAttr={platform:!1,appType:0,isSandbox:!1,released:!1,setting:{MaxCodeSize:2,MaxSubpackageSubCodeSize:2,MaxSubpackageFullCodeSize:12,NavigateMiniprogramLimit:10,MaxSubPackageLimit:100,MinTabbarCount:2,MaxTabbarCount:5,MaxCustomTabbarCount:10,MaxTabbarIconSize:40}},exports.jsonVariablePropertyWhiteList={windowPropertWhiteList:["navigationBarBackgroundColor","navigationBarTextStyle","backgroundColor","backgroundTextStyle","backgroundColorTop","backgroundColorBottom","backgroundColorContent"],tabBarPropertyWhiteList:["color","selectedColor","backgroundColor","borderStyle"],tabbarListItemPropertyWhiteList:["iconPath","selectedIconPath"]},exports.extendedLibMap={kbone:{packages:["miniprogram-element","miniprogram-render"]},weui:{packages:["weui-miniprogram"]}},exports.multiPlatformRoot="miniapp",exports.MainPkg="__APP__",exports.FullPkg="__FULL__",exports.compileTypeConfig={weapp:"weapp",game:"game",plugin:"plugin",gamePlugin:"gamePlugin"},function(e){e.Babel="babel",e.Acorn="acorn"}(AstType||(exports.AstType=AstType={})),function(e){e[e.Include=0]="Include",e[e.PackOptionsIgnore=1]="PackOptionsIgnore",e[e.AnalyseNoUse=2]="AnalyseNoUse",e[e.PartialCompileNoUse=3]="PartialCompileNoUse"}(EFilterCode||(exports.EFilterCode=EFilterCode={})),exports.MAX_CODE_LENGTH=2048e3;
1
+ "use strict";var COMPILE_TYPE,AstType,EFilterCode;function getDefaultIgnores(e){const _=["node_modules/**/*","**/node_modules/**","**/.git/**",".git/**/*","**/.svn/**",".svn/**/*",".DS_Store","**/.DS_Store"];return"multiPlatform"===e.projectArchitecture&&_.push(`${exports.multiPlatformRoot}/**/*`),_}Object.defineProperty(exports,"__esModule",{value:!0}),exports.MAX_CODE_LENGTH=exports.EFilterCode=exports.AstType=exports.compileTypeConfig=exports.FullPkg=exports.MainPkg=exports.multiPlatformRoot=exports.extendedLibMap=exports.jsonVariablePropertyWhiteList=exports.DefaultProjectAttr=exports.TABBAR_ICON_WHITE_LIST=exports.COMPILE_TYPE=exports.APP_TYPE=exports.MINI_GAME_WORKERS_PACKAGE_ROOT=exports.MINI_GAME_MAIN_PACKAGE_ROOT=exports.MINI_PROGRAM_MAIN_PACKAGE_ROOT=exports.PROJECT_TYPE_ERROR=exports.GET_LATEST_VERSION_CGI_ERR=exports.UPLOAD_JS_SERVER_CGI_ERR=exports.CODE_PROTECT_TRANSLATE_FILENAME=exports.UPLOAD_CGI_ERR=exports.GENERATE_LOCAL_SIGNATURE_ERR=exports.GET_SIGNATURE_RAND_STRING_ERR=exports.APP_JSON_NOT_FOUND=exports.JSON_CONTENT_ERR=exports.FILE_NOT_UTF8=exports.JSON_PARSE_ERR=exports.FILE_NOT_FOUND=exports.PLUGIN_JSON_PARSE_ERR=exports.PLUGIN_JSON_CONTENT_ERR=exports.PLUGIN_JSON_FILE_NOT_FOUND=exports.GAME_PLUGIN_LIB_MD5_NOT_MATCH=exports.SUMMER_PLUGIN_CODE_ERR=exports.SUMMER_PLUGIN_ERR=exports.MINIFY_WXML_ERR=exports.POST_WXSS_ERR=exports.FILE_FLAT_ERR=exports.JS_ES6_ERR=exports.BABILI_JS_ERR=exports.UGLIFY_JS_ERR=exports.BABEL_TRANS_JS_ERR=exports.JS_NOT_FOUND=exports.WXML_NOT_FOUND=exports.PARAM_ERROR=exports.CI_VERSION=void 0,exports.getDefaultIgnores=getDefaultIgnores,exports.CI_VERSION="2.1.35",exports.PARAM_ERROR=1e4,exports.WXML_NOT_FOUND=10007,exports.JS_NOT_FOUND=10008,exports.BABEL_TRANS_JS_ERR=10032,exports.UGLIFY_JS_ERR=10033,exports.BABILI_JS_ERR=10034,exports.JS_ES6_ERR=10035,exports.FILE_FLAT_ERR=10036,exports.POST_WXSS_ERR=10037,exports.MINIFY_WXML_ERR=10038,exports.SUMMER_PLUGIN_ERR=10045,exports.SUMMER_PLUGIN_CODE_ERR=10046,exports.GAME_PLUGIN_LIB_MD5_NOT_MATCH=10081,exports.PLUGIN_JSON_FILE_NOT_FOUND=10091,exports.PLUGIN_JSON_CONTENT_ERR=10092,exports.PLUGIN_JSON_PARSE_ERR=10093,exports.FILE_NOT_FOUND=10005,exports.JSON_PARSE_ERR=10006,exports.FILE_NOT_UTF8=10031,exports.JSON_CONTENT_ERR=10009,exports.APP_JSON_NOT_FOUND=2e4,exports.GET_SIGNATURE_RAND_STRING_ERR=20001,exports.GENERATE_LOCAL_SIGNATURE_ERR=20002,exports.UPLOAD_CGI_ERR=20003,exports.CODE_PROTECT_TRANSLATE_FILENAME=20004,exports.UPLOAD_JS_SERVER_CGI_ERR=20005,exports.GET_LATEST_VERSION_CGI_ERR=20006,exports.PROJECT_TYPE_ERROR=3e4,exports.MINI_PROGRAM_MAIN_PACKAGE_ROOT="__APP__",exports.MINI_GAME_MAIN_PACKAGE_ROOT="__GAME__",exports.MINI_GAME_WORKERS_PACKAGE_ROOT="workers.js",exports.APP_TYPE={NORMAL:0,PLUGIN:1,SHOP:2,MINISHOP:3,GAME:4,CARD:5,NATIVE:7},function(e){e.miniProgram="miniProgram",e.miniProgramPlugin="miniProgramPlugin",e.miniGame="miniGame",e.miniGamePlugin="miniGamePlugin"}(COMPILE_TYPE||(exports.COMPILE_TYPE=COMPILE_TYPE={})),exports.TABBAR_ICON_WHITE_LIST=[".png",".jpg",".jpeg"],exports.DefaultProjectAttr={platform:!1,appType:0,isSandbox:!1,released:!1,setting:{MaxCodeSize:2,MaxSubpackageSubCodeSize:2,MaxSubpackageFullCodeSize:12,NavigateMiniprogramLimit:10,MaxSubPackageLimit:100,MinTabbarCount:2,MaxTabbarCount:5,MaxCustomTabbarCount:10,MaxTabbarIconSize:40}},exports.jsonVariablePropertyWhiteList={windowPropertWhiteList:["navigationBarBackgroundColor","navigationBarTextStyle","backgroundColor","backgroundTextStyle","backgroundColorTop","backgroundColorBottom","backgroundColorContent"],tabBarPropertyWhiteList:["color","selectedColor","backgroundColor","borderStyle"],tabbarListItemPropertyWhiteList:["iconPath","selectedIconPath"]},exports.extendedLibMap={kbone:{packages:["miniprogram-element","miniprogram-render"]},weui:{packages:["weui-miniprogram"]}},exports.multiPlatformRoot="miniapp",exports.MainPkg="__APP__",exports.FullPkg="__FULL__",exports.compileTypeConfig={weapp:"weapp",game:"game",plugin:"plugin",gamePlugin:"gamePlugin"},function(e){e.Babel="babel",e.Acorn="acorn"}(AstType||(exports.AstType=AstType={})),function(e){e[e.Include=0]="Include",e[e.PackOptionsIgnore=1]="PackOptionsIgnore",e[e.AnalyseNoUse=2]="AnalyseNoUse",e[e.PartialCompileNoUse=3]="PartialCompileNoUse"}(EFilterCode||(exports.EFilterCode=EFilterCode={})),exports.MAX_CODE_LENGTH=2048e3;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MiniAppJson=exports.MiniAppI18N=exports.encryptLocalFile=exports.generateFileMD5=exports.miniappBuilder=exports.iosDeviceUtils=exports.adroidDeviceUtils=exports.cosUpload=exports.escapeScript=exports.escapeQuot=exports.checkIsInSubPackage=exports.compareVersion=exports.normalizePath=exports.mkdirSync=exports.generateMD5=exports.compileTypeConfig=exports.JSON_CONTENT_ERR=exports.DefaultProjectAttr=exports.isHexColor=exports.locales=exports.proxy=exports.getWhiteExtList=exports.OriginalCompiler=exports.BaseCoreCompiler=exports.EPipeCMD=exports.CIProject=exports.Project=exports.PreCompileProject=exports.WebProject=exports.BaseProject=exports.EFilterCode=exports.EServiceEnviroment=exports.workletVersion=exports.initServices=exports.PackOptionsHelper=exports.packOptionsHelper=exports.getHelperDeps=exports.getHelperOutputPath=exports.getHelperContent=exports.getHelperName=exports.isValidHelperFunc=exports.getBabelHelperDepMap=exports.getBabelHelperVersion=exports.getSummerPluginConfig=exports.DevtoolsProject=exports.SummerCompiler=exports.Builder=void 0;const tslib_1=require("tslib");tslib_1.__exportStar(require("./ci/index"),exports);const modules_1=require("./modules");Object.defineProperty(exports,"Builder",{enumerable:!0,get:function(){return modules_1.Builder}});const summerCompiler_1=require("./modules/corecompiler/summerCompiler");Object.defineProperty(exports,"SummerCompiler",{enumerable:!0,get:function(){return summerCompiler_1.SummerCompiler}});const devtoolsProject_1=require("./project/devtoolsProject");Object.defineProperty(exports,"DevtoolsProject",{enumerable:!0,get:function(){return devtoolsProject_1.DevtoolsProject}});const pluginconfig_1=require("./modules/corecompiler/summer/pluginconfig");Object.defineProperty(exports,"getSummerPluginConfig",{enumerable:!0,get:function(){return pluginconfig_1.getSummerPluginConfig}});const babel_helper_1=require("./utils/babel_helper");Object.defineProperty(exports,"getBabelHelperVersion",{enumerable:!0,get:function(){return babel_helper_1.getBabelHelperVersion}}),Object.defineProperty(exports,"getBabelHelperDepMap",{enumerable:!0,get:function(){return babel_helper_1.getBabelHelperDepMap}});const helper_util_1=require("./utils/helper_util");Object.defineProperty(exports,"getHelperOutputPath",{enumerable:!0,get:function(){return helper_util_1.getHelperOutputPath}}),Object.defineProperty(exports,"getHelperDeps",{enumerable:!0,get:function(){return helper_util_1.getHelperDeps}}),Object.defineProperty(exports,"isValidHelperFunc",{enumerable:!0,get:function(){return helper_util_1.isValidHelperFunc}}),Object.defineProperty(exports,"getHelperContent",{enumerable:!0,get:function(){return helper_util_1.getHelperContent}}),Object.defineProperty(exports,"getHelperName",{enumerable:!0,get:function(){return helper_util_1.getHelperName}});const packOptionsHelper_1=tslib_1.__importStar(require("./utils/packOptionsHelper"));exports.packOptionsHelper=packOptionsHelper_1.default,Object.defineProperty(exports,"PackOptionsHelper",{enumerable:!0,get:function(){return packOptionsHelper_1.PackOptionsHelper}});const baseProject_1=require("./project/baseProject");Object.defineProperty(exports,"BaseProject",{enumerable:!0,get:function(){return baseProject_1.BaseProject}});const webProject_1=require("./project/webProject");Object.defineProperty(exports,"WebProject",{enumerable:!0,get:function(){return webProject_1.WebProject}});const precompileProject_1=require("./project/advance/precompileProject");Object.defineProperty(exports,"PreCompileProject",{enumerable:!0,get:function(){return precompileProject_1.PreCompileProject}});const ciProject_1=require("./project/ciProject");Object.defineProperty(exports,"Project",{enumerable:!0,get:function(){return ciProject_1.CIProject}}),Object.defineProperty(exports,"CIProject",{enumerable:!0,get:function(){return ciProject_1.CIProject}});const baseCompiler_1=require("./modules/corecompiler/baseCompiler");Object.defineProperty(exports,"BaseCoreCompiler",{enumerable:!0,get:function(){return baseCompiler_1.BaseCoreCompiler}});const originalCompiler_1=require("./modules/corecompiler/originalCompiler");Object.defineProperty(exports,"OriginalCompiler",{enumerable:!0,get:function(){return originalCompiler_1.OriginalCompiler}});const white_ext_list_1=require("./utils/white_ext_list");Object.defineProperty(exports,"getWhiteExtList",{enumerable:!0,get:function(){return white_ext_list_1.getWhiteExtList}});const request_1=require("./utils/request");Object.defineProperty(exports,"proxy",{enumerable:!0,get:function(){return request_1.setCiProxy}});const locales_1=tslib_1.__importDefault(require("./utils/locales/locales"));exports.locales=locales_1.default;const tools_1=require("./utils/tools");Object.defineProperty(exports,"checkIsInSubPackage",{enumerable:!0,get:function(){return tools_1.checkIsInSubPackage}}),Object.defineProperty(exports,"escapeQuot",{enumerable:!0,get:function(){return tools_1.escapeQuot}}),Object.defineProperty(exports,"escapeScript",{enumerable:!0,get:function(){return tools_1.escapeScript}}),Object.defineProperty(exports,"generateMD5",{enumerable:!0,get:function(){return tools_1.generateMD5}}),Object.defineProperty(exports,"isHexColor",{enumerable:!0,get:function(){return tools_1.isHexColor}}),Object.defineProperty(exports,"mkdirSync",{enumerable:!0,get:function(){return tools_1.mkdirSync}}),Object.defineProperty(exports,"normalizePath",{enumerable:!0,get:function(){return tools_1.normalizePath}}),Object.defineProperty(exports,"compareVersion",{enumerable:!0,get:function(){return tools_1.compareVersion}});const config_1=require("./config/config");Object.defineProperty(exports,"DefaultProjectAttr",{enumerable:!0,get:function(){return config_1.DefaultProjectAttr}}),Object.defineProperty(exports,"JSON_CONTENT_ERR",{enumerable:!0,get:function(){return config_1.JSON_CONTENT_ERR}}),Object.defineProperty(exports,"compileTypeConfig",{enumerable:!0,get:function(){return config_1.compileTypeConfig}}),Object.defineProperty(exports,"EFilterCode",{enumerable:!0,get:function(){return config_1.EFilterCode}});const adroidDeviceUtils=tslib_1.__importStar(require("./modules/nativecompiler/android/device"));exports.adroidDeviceUtils=adroidDeviceUtils;const iosDeviceUtils=tslib_1.__importStar(require("./modules/nativecompiler/ios/device"));exports.iosDeviceUtils=iosDeviceUtils;const miniappBuilder=tslib_1.__importStar(require("./utils/miniapp-builder"));exports.miniappBuilder=miniappBuilder;const miniAppI18N_1=tslib_1.__importDefault(require("./utils/miniAppI18N"));exports.MiniAppI18N=miniAppI18N_1.default;const MiniAppJson=tslib_1.__importStar(require("./utils/miniappJson"));exports.MiniAppJson=MiniAppJson;const cosUpload=tslib_1.__importStar(require("./utils/cosUpload"));exports.cosUpload=cosUpload;const getservice_1=require("./services/common/getservice");Object.defineProperty(exports,"EServiceEnviroment",{enumerable:!0,get:function(){return getservice_1.EServiceEnviroment}}),Object.defineProperty(exports,"initServices",{enumerable:!0,get:function(){return getservice_1.initServices}});const types_1=require("./modules/corecompiler/summer/pipeManager/types");Object.defineProperty(exports,"EPipeCMD",{enumerable:!0,get:function(){return types_1.EPipeCMD}}),(0,getservice_1.initServicesByEnv)(),exports.workletVersion=require("./utils/common").workletVersion,tslib_1.__exportStar(require("./modules/corecompiler/original"),exports);var tools_2=require("./utils/tools");Object.defineProperty(exports,"generateFileMD5",{enumerable:!0,get:function(){return tools_2.generateFileMD5}});var asyncTask_1=require("./utils/asyncTask");Object.defineProperty(exports,"encryptLocalFile",{enumerable:!0,get:function(){return asyncTask_1.encryptLocalFile}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MiniAppJson=exports.MiniAppI18N=exports.encryptLocalFile=exports.generateFileMD5=exports.miniappBuilder=exports.iosDeviceUtils=exports.adroidDeviceUtils=exports.cosUpload=exports.escapeScript=exports.escapeQuot=exports.checkIsInSubPackage=exports.compareVersion=exports.normalizePath=exports.mkdirSync=exports.generateMD5=exports.compileTypeConfig=exports.JSON_CONTENT_ERR=exports.DefaultProjectAttr=exports.isHexColor=exports.locales=exports.proxy=exports.getWhiteExtList=exports.OriginalCompiler=exports.BaseCoreCompiler=exports.CIProject=exports.Project=exports.PreCompileProject=exports.WebProject=exports.BaseProject=exports.EFilterCode=exports.EServiceEnviroment=exports.workletVersion=exports.initServices=exports.PackOptionsHelper=exports.packOptionsHelper=exports.getHelperDeps=exports.getHelperOutputPath=exports.getHelperContent=exports.getHelperName=exports.isValidHelperFunc=exports.getBabelHelperDepMap=exports.getBabelHelperVersion=exports.getSummerPluginConfig=exports.DevtoolsProject=exports.SummerCompiler=exports.Builder=void 0;const tslib_1=require("tslib");tslib_1.__exportStar(require("./ci/index"),exports);const modules_1=require("./modules");Object.defineProperty(exports,"Builder",{enumerable:!0,get:function(){return modules_1.Builder}});const summerCompiler_1=require("./modules/corecompiler/summerCompiler");Object.defineProperty(exports,"SummerCompiler",{enumerable:!0,get:function(){return summerCompiler_1.SummerCompiler}});const devtoolsProject_1=require("./project/devtoolsProject");Object.defineProperty(exports,"DevtoolsProject",{enumerable:!0,get:function(){return devtoolsProject_1.DevtoolsProject}});const pluginconfig_1=require("./modules/corecompiler/summer/pluginconfig");Object.defineProperty(exports,"getSummerPluginConfig",{enumerable:!0,get:function(){return pluginconfig_1.getSummerPluginConfig}});const babel_helper_1=require("./utils/babel_helper");Object.defineProperty(exports,"getBabelHelperVersion",{enumerable:!0,get:function(){return babel_helper_1.getBabelHelperVersion}}),Object.defineProperty(exports,"getBabelHelperDepMap",{enumerable:!0,get:function(){return babel_helper_1.getBabelHelperDepMap}});const helper_util_1=require("./utils/helper_util");Object.defineProperty(exports,"getHelperOutputPath",{enumerable:!0,get:function(){return helper_util_1.getHelperOutputPath}}),Object.defineProperty(exports,"getHelperDeps",{enumerable:!0,get:function(){return helper_util_1.getHelperDeps}}),Object.defineProperty(exports,"isValidHelperFunc",{enumerable:!0,get:function(){return helper_util_1.isValidHelperFunc}}),Object.defineProperty(exports,"getHelperContent",{enumerable:!0,get:function(){return helper_util_1.getHelperContent}}),Object.defineProperty(exports,"getHelperName",{enumerable:!0,get:function(){return helper_util_1.getHelperName}});const packOptionsHelper_1=tslib_1.__importStar(require("./utils/packOptionsHelper"));exports.packOptionsHelper=packOptionsHelper_1.default,Object.defineProperty(exports,"PackOptionsHelper",{enumerable:!0,get:function(){return packOptionsHelper_1.PackOptionsHelper}});const baseProject_1=require("./project/baseProject");Object.defineProperty(exports,"BaseProject",{enumerable:!0,get:function(){return baseProject_1.BaseProject}});const webProject_1=require("./project/webProject");Object.defineProperty(exports,"WebProject",{enumerable:!0,get:function(){return webProject_1.WebProject}});const precompileProject_1=require("./project/advance/precompileProject");Object.defineProperty(exports,"PreCompileProject",{enumerable:!0,get:function(){return precompileProject_1.PreCompileProject}});const ciProject_1=require("./project/ciProject");Object.defineProperty(exports,"Project",{enumerable:!0,get:function(){return ciProject_1.CIProject}}),Object.defineProperty(exports,"CIProject",{enumerable:!0,get:function(){return ciProject_1.CIProject}});const baseCompiler_1=require("./modules/corecompiler/baseCompiler");Object.defineProperty(exports,"BaseCoreCompiler",{enumerable:!0,get:function(){return baseCompiler_1.BaseCoreCompiler}});const originalCompiler_1=require("./modules/corecompiler/originalCompiler");Object.defineProperty(exports,"OriginalCompiler",{enumerable:!0,get:function(){return originalCompiler_1.OriginalCompiler}});const white_ext_list_1=require("./utils/white_ext_list");Object.defineProperty(exports,"getWhiteExtList",{enumerable:!0,get:function(){return white_ext_list_1.getWhiteExtList}});const request_1=require("./utils/request");Object.defineProperty(exports,"proxy",{enumerable:!0,get:function(){return request_1.setCiProxy}});const locales_1=tslib_1.__importDefault(require("./utils/locales/locales"));exports.locales=locales_1.default;const tools_1=require("./utils/tools");Object.defineProperty(exports,"checkIsInSubPackage",{enumerable:!0,get:function(){return tools_1.checkIsInSubPackage}}),Object.defineProperty(exports,"escapeQuot",{enumerable:!0,get:function(){return tools_1.escapeQuot}}),Object.defineProperty(exports,"escapeScript",{enumerable:!0,get:function(){return tools_1.escapeScript}}),Object.defineProperty(exports,"generateMD5",{enumerable:!0,get:function(){return tools_1.generateMD5}}),Object.defineProperty(exports,"isHexColor",{enumerable:!0,get:function(){return tools_1.isHexColor}}),Object.defineProperty(exports,"mkdirSync",{enumerable:!0,get:function(){return tools_1.mkdirSync}}),Object.defineProperty(exports,"normalizePath",{enumerable:!0,get:function(){return tools_1.normalizePath}}),Object.defineProperty(exports,"compareVersion",{enumerable:!0,get:function(){return tools_1.compareVersion}});const config_1=require("./config/config");Object.defineProperty(exports,"DefaultProjectAttr",{enumerable:!0,get:function(){return config_1.DefaultProjectAttr}}),Object.defineProperty(exports,"JSON_CONTENT_ERR",{enumerable:!0,get:function(){return config_1.JSON_CONTENT_ERR}}),Object.defineProperty(exports,"compileTypeConfig",{enumerable:!0,get:function(){return config_1.compileTypeConfig}}),Object.defineProperty(exports,"EFilterCode",{enumerable:!0,get:function(){return config_1.EFilterCode}});const adroidDeviceUtils=tslib_1.__importStar(require("./modules/nativecompiler/android/device"));exports.adroidDeviceUtils=adroidDeviceUtils;const iosDeviceUtils=tslib_1.__importStar(require("./modules/nativecompiler/ios/device"));exports.iosDeviceUtils=iosDeviceUtils;const miniappBuilder=tslib_1.__importStar(require("./utils/miniapp-builder"));exports.miniappBuilder=miniappBuilder;const miniAppI18N_1=tslib_1.__importDefault(require("./utils/miniAppI18N"));exports.MiniAppI18N=miniAppI18N_1.default;const MiniAppJson=tslib_1.__importStar(require("./utils/miniappJson"));exports.MiniAppJson=MiniAppJson;const cosUpload=tslib_1.__importStar(require("./utils/cosUpload"));exports.cosUpload=cosUpload;const getservice_1=require("./services/common/getservice");Object.defineProperty(exports,"EServiceEnviroment",{enumerable:!0,get:function(){return getservice_1.EServiceEnviroment}}),Object.defineProperty(exports,"initServices",{enumerable:!0,get:function(){return getservice_1.initServices}}),(0,getservice_1.initServicesByEnv)(),exports.workletVersion=require("./utils/common").workletVersion,tslib_1.__exportStar(require("./modules/corecompiler/original"),exports);var tools_2=require("./utils/tools");Object.defineProperty(exports,"generateFileMD5",{enumerable:!0,get:function(){return tools_2.generateFileMD5}});var asyncTask_1=require("./utils/asyncTask");Object.defineProperty(exports,"encryptLocalFile",{enumerable:!0,get:function(){return asyncTask_1.encryptLocalFile}});
@@ -1 +1 @@
1
- "use strict";var ETaskStatus,EWorkerStatus,EChildProcessStatus;Object.defineProperty(exports,"__esModule",{value:!0}),exports.SUICIDE_TIME=exports.EChildProcessStatus=exports.EWorkerStatus=exports.COMMAND=exports.TASK_NAME=exports.ETaskStatus=void 0,function(s){s[s.waiting=0]="waiting",s[s.progress=1]="progress",s[s.done=2]="done"}(ETaskStatus||(exports.ETaskStatus=ETaskStatus={})),exports.TASK_NAME={COMPILE_JS:"COMPILE_JS",COMPILE_WXSS:"COMPILE_WXSS",MINIFY_WXML:"MINIFY_WXML",SUMMER_HOOK:"SUMMER_HOOK",PIPE_TASK:"PIPE_TASK"},exports.COMMAND={INIT_START:"INIT_START",INIT_READY:"INIT_READY",RUN_TASK:"RUN_TASK",TASK_DONE:"TASK_DONE",CALL_FUNC:"CALL_FUNC",CALL_FUNC_RESULT:"CALL_FUNC_RESULT",CHILD_PROCESS_READY:"CHILD_PROCESS_READY",SEND_LOG:"SEND_LOG"},function(s){s[s.free=0]="free",s[s.busy=1]="busy",s[s.dying=2]="dying"}(EWorkerStatus||(exports.EWorkerStatus=EWorkerStatus={})),function(s){s[s.free=0]="free",s[s.busy=1]="busy",s[s.fullload=2]="fullload",s[s.dying=3]="dying"}(EChildProcessStatus||(exports.EChildProcessStatus=EChildProcessStatus={})),exports.SUICIDE_TIME={devtools:864e5,"miniprogram-ci":1e4,webide:864e5};
1
+ "use strict";var ETaskStatus,EWorkerStatus,EChildProcessStatus;Object.defineProperty(exports,"__esModule",{value:!0}),exports.SUICIDE_TIME=exports.EChildProcessStatus=exports.EWorkerStatus=exports.COMMAND=exports.TASK_NAME=exports.ETaskStatus=void 0,function(t){t[t.waiting=0]="waiting",t[t.progress=1]="progress",t[t.done=2]="done"}(ETaskStatus||(exports.ETaskStatus=ETaskStatus={})),exports.TASK_NAME={COMPILE_JS:"COMPILE_JS",COMPILE_WXSS:"COMPILE_WXSS",MINIFY_WXML:"MINIFY_WXML",SUMMER_HOOK:"SUMMER_HOOK",PIPE_TASK:"PIPE_TASK"},exports.COMMAND={INIT_START:"INIT_START",INIT_READY:"INIT_READY",RUN_TASK:"RUN_TASK",TASK_DONE:"TASK_DONE",CALL_FUNC:"CALL_FUNC",CALL_FUNC_RESULT:"CALL_FUNC_RESULT",CHILD_PROCESS_READY:"CHILD_PROCESS_READY",SEND_LOG:"SEND_LOG"},function(t){t[t.initiating=0]="initiating",t[t.free=1]="free",t[t.busy=2]="busy",t[t.dying=3]="dying"}(EWorkerStatus||(exports.EWorkerStatus=EWorkerStatus={})),function(t){t[t.free=0]="free",t[t.busy=1]="busy",t[t.fullload=2]="fullload",t[t.dying=3]="dying"}(EChildProcessStatus||(exports.EChildProcessStatus=EChildProcessStatus={})),exports.SUICIDE_TIME={devtools:864e5,"miniprogram-ci":1e4,webide:864e5};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.readFileAsync=readFileAsync,exports.setPipeIPCHandler=setPipeIPCHandler,exports.handlePipeIPC=handlePipeIPC;const tslib_1=require("tslib"),fs_1=tslib_1.__importDefault(require("fs")),progressRecorder_1=require("../../../../../utils/progressRecorder");function readFileAsync(e,r){return new Promise(((i,n)=>{fs_1.default.readFile(e,r,((e,r)=>{if(e)return n(e);i(r)}))}))}let _pipeIPCHandler;function setPipeIPCHandler(e){_pipeIPCHandler=e}async function handlePipeIPC(e){if(!_pipeIPCHandler)throw new Error("pipeIPCHandler not registered");const r=new progressRecorder_1.Recorder((()=>{}));return _pipeIPCHandler(e,r)}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.readFileAsync=readFileAsync;const tslib_1=require("tslib"),fs_1=tslib_1.__importDefault(require("fs"));function readFileAsync(e,r){return new Promise(((s,t)=>{fs_1.default.readFile(e,r,((e,r)=>{if(e)return t(e);s(r)}))}))}
@@ -1 +1 @@
1
- process.env&&process.env.isDevtools&&require("../../../../utils/hackrequire/index"),Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib");require("../../../../utils/processBootstrap").installProcessBootstrap({baseDir:__dirname,hackRequirePath:"../../../../utils/hackrequire/index",moduleFallbackPath:"../../../../../../../unpack/module-fallback"});const worker_threads_1=require("worker_threads"),logger_1=require("../utils/logger"),index_1=tslib_1.__importDefault(require("./task/index")),config_1=require("./config"),getservice_1=require("../../../../services/common/getservice");worker_threads_1.isMainThread?module.exports=index_1.default:worker_threads_1.parentPort.on("message",(e=>{const{command:r,data:t}=e;if(r===config_1.COMMAND.INIT_START){const e=(0,getservice_1.getServicesEnv)();return(0,getservice_1.initServices)(e,t),void worker_threads_1.parentPort.postMessage({command:config_1.COMMAND.INIT_READY})}r===config_1.COMMAND.RUN_TASK&&(logger_1.logger.info("worker process task start",r,t.data.filePath),(0,index_1.default)(t.taskName,t.data).then((e=>{logger_1.logger.info("worker process task end",r,t.data.filePath),worker_threads_1.parentPort.postMessage({command:config_1.COMMAND.TASK_DONE,data:e})})).catch((e=>{worker_threads_1.parentPort.postMessage({command:config_1.COMMAND.TASK_DONE,data:{error:e.toString()}})})))}));
1
+ process.env&&process.env.isDevtools&&require("../../../../utils/hackrequire/index"),Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib");require("../../../../utils/processBootstrap").installProcessBootstrap({baseDir:__dirname,hackRequirePath:"../../../../utils/hackrequire/index",moduleFallbackPath:"../../../../../../../unpack/module-fallback"});const worker_threads_1=require("worker_threads"),logger_1=require("../utils/logger"),index_1=tslib_1.__importDefault(require("./task/index")),config_1=require("./config"),getservice_1=require("../../../../services/common/getservice"),customError_1=require("../../../../utils/customError");worker_threads_1.isMainThread?module.exports=index_1.default:worker_threads_1.parentPort.on("message",(e=>{const{command:r,data:t}=e;if(r===config_1.COMMAND.INIT_START){const e=(0,getservice_1.getServicesEnv)();return(0,getservice_1.initServices)(e,t),void worker_threads_1.parentPort.postMessage({command:config_1.COMMAND.INIT_READY})}r===config_1.COMMAND.RUN_TASK&&(logger_1.logger.info("worker process task start",r,t.data.filePath),(0,index_1.default)(t.taskName,t.data).then((e=>{logger_1.logger.info("worker process task end",r,t.data.filePath),worker_threads_1.parentPort.postMessage({command:config_1.COMMAND.TASK_DONE,data:e})})).catch((e=>{worker_threads_1.parentPort.postMessage({command:config_1.COMMAND.TASK_DONE,data:{error:e instanceof customError_1.CustomError?e.toJSON():e.toString()}})})))}));
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getWorkerManager=exports.AbortEvent=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),events_1=tslib_1.__importDefault(require("events")),log=tslib_1.__importStar(require("../../../../utils/log")),logger_1=require("../utils/logger"),env_1=require("../utils/env"),child_process_1=require("child_process"),call_func_1=require("./task/call_func"),config_1=require("./config"),getWorkerPoolSize_1=tslib_1.__importDefault(require("./getWorkerPoolSize")),debug_1=require("../../../../utils/debug"),async_1=require("../../summer/utils/async"),getservice_1=tslib_1.__importDefault(require("../../../../services/common/getservice")),appDirService_1=require("../../../../services/app/common/appDirService"),nativeModule_1=require("../../../../services/nativeModule/common/nativeModule"),cpus=(0,getWorkerPoolSize_1.default)(),WORKER_PATH=path_1.default.posix.join(__dirname,"./worker.js"),FORK_PATH=path_1.default.posix.join(__dirname,"./fork.js"),MAX_TASK_TRY_TIME=2;let envIsDevtools=!1;function getCurrentScriptPath(){const e=path_1.default.posix.relative(process.cwd(),__filename);return process.cwd()===__dirname?`.${path_1.default.posix.resolve}${e}`:e}const supportWebWorkerThread="undefined"!=typeof WEBIDE_WEBPECK_DEFINE_PLUGIN;let Worker,supportWorkerThread=!1;try{Worker=require("worker_threads").Worker,supportWorkerThread=!0}catch(e){supportWorkerThread=!1}let workerManagerInstance,_workerInspectPort=9320;function resolveTaskLabel(e,t){return e===config_1.TASK_NAME.SUMMER_HOOK&&(null==t?void 0:t.method)?`${e}:${t.plugin}:${t.method}`:e===config_1.TASK_NAME.PIPE_TASK&&(null==t?void 0:t.pipeName)?`${e}:${t.pipeName}`:e}exports.AbortEvent="WorkerTaskAborted";class WorkerInstance extends events_1.default{constructor(){super(),this.status=config_1.EWorkerStatus.free,this.threadId=-1,this._suicideTime=config_1.SUICIDE_TIME["miniprogram-ci"],this._postMessage=()=>{},this._initBarrier=null,this._taskStartTime=0}async init(){envIsDevtools&&(this._suicideTime=config_1.SUICIDE_TIME.devtools);const e={NODE_PATH:process.env.NODE_PATH||path_1.default.posix.join(__filename,"../../../../../../../../node_modules"),ELECTRON_MODULE_FALLBACK_DIRS:process.env.ELECTRON_MODULE_FALLBACK_DIRS||"",ELECTRON_ACTIVE_APP_PATH:process.env.ELECTRON_ACTIVE_APP_PATH||"",ELECTRON_BASE_APP_PATH:process.env.ELECTRON_BASE_APP_PATH||"",isDevtools:String(envIsDevtools)};if(console.log("NODE_ENV",process.cwd(),__filename,getCurrentScriptPath(),e),supportWebWorkerThread);else if(supportWorkerThread){const t=await(0,debug_1.shouldInspectWorker)()?["--inspect-brk="+_workerInspectPort++]:[];this._instance=new Worker(WORKER_PATH,{env:Object.assign(Object.assign({},e),{cpprocessEnv:"workerthread"}),stdout:!0,execArgv:t}),this.threadId=this._instance.threadId,this._postMessage=this._instance.postMessage.bind(this._instance)}else{const t=await(0,debug_1.shouldInspectWorker)()?["--inspect-brk="+_workerInspectPort++]:[];this._instance=(0,child_process_1.fork)(FORK_PATH,[""],{env:Object.assign(Object.assign({},e),{cpprocessEnv:"workerprocess"}),execArgv:t}),this.threadId=this._instance.pid,this._postMessage=this._instance.send.bind(this._instance)}const t=e=>{var t;const{command:s,data:r}=e;s===config_1.COMMAND.INIT_READY&&(null===(t=this._initBarrier)||void 0===t||t.open(),console.log("worker init_ready")),s===config_1.COMMAND.TASK_DONE&&this.onTaskDone(r),s===config_1.COMMAND.SEND_LOG&&logger_1.logger.send(r.level,r.args),s===config_1.COMMAND.CALL_FUNC&&call_func_1.call.apply(null,[r.funcName,...r.args]).then((e=>{this._postMessage({command:config_1.COMMAND.CALL_FUNC_RESULT,data:{id:r.id,result:e}})})).catch((e=>{this._postMessage({command:config_1.COMMAND.CALL_FUNC_RESULT,data:{id:r.id,error:e.toString()}})}))},s=e=>{0!==e&&1!==e&&log.error(`worker thread: ${this.threadId}, status: ${this.status}, exit with code: ${e}`),this.emit("exit",{code:e,status:this.status,task:this._task,threadId:this.threadId})};supportWebWorkerThread?(this._instance.onMsg(t),this._instance.onError(s)):(this._instance.on("message",t),this._instance.on("exit",s)),await this._initWorkerServices()}on(e,t){return super.on(e,t)}async _initWorkerServices(){const e=await(0,getservice_1.default)(appDirService_1.IAppDirService).get("WeappCompileCache"),t=await(0,getservice_1.default)(nativeModule_1.INativeModuleService);this._postMessage({command:config_1.COMMAND.INIT_START,data:{NativeModule:{WXMLParsePath:await t.getWXMLParsePath(),WXSSParsePath:await t.getWXSSParsePath(),GlassEaselLazyModulePath:await t.getGlassEaselTemplateCompilerPath()},AppDirService:{WeappCompileCache:e}}}),this._initBarrier=new async_1.Barrier,await this._initBarrier.wait()}onTaskDone(e){var t,s,r,i;const o=Date.now()-this._taskStartTime,a=resolveTaskLabel(null!==(s=null===(t=this._task)||void 0===t?void 0:t.name)&&void 0!==s?s:"",null===(r=this._task)||void 0===r?void 0:r.data);this.status=config_1.EWorkerStatus.free,(null===(i=this._task)||void 0===i?void 0:i.resolve)&&(this._task.onStatusUpdate(config_1.ETaskStatus.done),this._task.resolve(e)),this._task=void 0,this.emit("taskDone",this.threadId,a,o),env_1.summerProcess&&env_1.nativeProcess||this.setUpSuicideTimer()}setUpSuicideTimer(){this._suicideTimer=setTimeout((()=>{clearTimeout(this._suicideTimer),this.status===config_1.EWorkerStatus.free?(this.status=config_1.EWorkerStatus.dying,supportWebWorkerThread?this._instance.kill():supportWorkerThread?this._instance.terminate():this._instance.kill("SIGTERM")):this._suicideTimer||this.setUpSuicideTimer()}),this._suicideTime)}runTask(e){clearTimeout(this._suicideTimer),this.status=config_1.EWorkerStatus.busy,this._task=e,this._taskStartTime=Date.now(),this._task.onStatusUpdate(config_1.ETaskStatus.progress),this._postMessage({command:config_1.COMMAND.RUN_TASK,data:{taskName:e.name,data:e.data}})}}class WorkerManager{constructor(e,t=!1){this._taskQueue=[],this._workerPool={},this._max_pool_size=4,this._taskRecords=[],this.onWorkerExit=async e=>{const{code:t,status:s,task:r,threadId:i}=e;delete this._workerPool[i],s===config_1.EWorkerStatus.busy&&(r.retryTimes+=1,r.retryTimes<=2?(log.error(`worker thread: ${i} exit with code: ${t} when it is busy, retry ${r.retryTimes} times`),this._taskQueue.push(r)):r.reject(`worker thread exit with code: ${t} when it is busy`)),await this._run()},this._actualWorkerPoolSize=1,this._doneThreadSet=new Set,this.onTaskDone=async(e,t,s)=>{null!=t&&null!=s&&this._taskRecords.push({workerId:e,taskName:t,duration:s}),this._doneThreadSet.add(e),this._actualWorkerPoolSize=Math.min(howManyWorker(this._doneThreadSet.size),this._max_pool_size),await this._run()},this._max_pool_size=e>8?8:e,envIsDevtools=t}runTask(e,t,s=(()=>{})){return new Promise(((r,i)=>{const o={name:e,data:t,resolve:r,reject:i,retryTimes:0,onStatusUpdate:s};s(config_1.ETaskStatus.waiting),this._taskQueue.push(o),this._run()}))}getTaskRecords(){return this._taskRecords}clearTaskRecords(){this._taskRecords=[]}abort(e){const t=[],s=[];this._taskQueue.forEach((r=>{r.name!==e?s.push(r):t.push(r)})),t.forEach((e=>{e.reject(exports.AbortEvent)})),this._taskQueue=s}async _run(){let e=this._taskQueue[0];for(;e;){const t=this.getFreeWorker();if(!t)return;this._taskQueue.shift(),t.runTask(e),e=this._taskQueue[0]}}getFreeWorker(){for(const e in this._workerPool){const t=this._workerPool[e];if(t.status===config_1.EWorkerStatus.free)return t}return this.allocWorker(),null}async allocWorker(){if(this.workerCount()<this._max_pool_size){const e=new WorkerInstance;return await e.init(),e.on("taskDone",this.onTaskDone),e.on("exit",this.onWorkerExit),this._workerPool[e.threadId]=e,this._run(),e}return null}workerCount(){return Object.keys(this._workerPool).length}}function howManyWorker(e){switch(e){case 1:return 4;case 2:return 6;default:return 8}}const getWorkerManager=function(e=!1){return workerManagerInstance||(workerManagerInstance=new WorkerManager(cpus,e)),workerManagerInstance};exports.getWorkerManager=getWorkerManager;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getWorkerManager=exports.AbortEvent=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),events_1=tslib_1.__importDefault(require("events")),log=tslib_1.__importStar(require("../../../../utils/log")),logger_1=require("../utils/logger"),env_1=require("../utils/env"),child_process_1=require("child_process"),call_func_1=require("./task/call_func"),config_1=require("./config"),getWorkerPoolSize_1=tslib_1.__importDefault(require("./getWorkerPoolSize")),debug_1=require("../../../../utils/debug"),async_1=require("../../summer/utils/async"),getservice_1=tslib_1.__importDefault(require("../../../../services/common/getservice")),appDirService_1=require("../../../../services/app/common/appDirService"),nativeModule_1=require("../../../../services/nativeModule/common/nativeModule"),cpus=(0,getWorkerPoolSize_1.default)(),WORKER_PATH=path_1.default.posix.join(__dirname,"./worker.js"),FORK_PATH=path_1.default.posix.join(__dirname,"./fork.js"),MAX_TASK_TRY_TIME=2;let envIsDevtools=!1;function getCurrentScriptPath(){const e=path_1.default.posix.relative(process.cwd(),__filename);return process.cwd()===__dirname?`.${path_1.default.posix.resolve}${e}`:e}const supportWebWorkerThread="undefined"!=typeof WEBIDE_WEBPECK_DEFINE_PLUGIN;let Worker,supportWorkerThread=!1;try{Worker=require("worker_threads").Worker,supportWorkerThread=!0}catch(e){supportWorkerThread=!1}let _workerInspectPort=9320;function resolveTaskLabel(e,t){return e===config_1.TASK_NAME.SUMMER_HOOK&&(null==t?void 0:t.method)?`${e}:${t.plugin}:${t.method}`:e===config_1.TASK_NAME.PIPE_TASK&&(null==t?void 0:t.pipeName)?`${e}:${t.pipeName}`:e}exports.AbortEvent="WorkerTaskAborted";let workerManagerInstance,WorkerInstanceThreadIdIdx=0;class WorkerInstance extends events_1.default{constructor(){super(),this.status=config_1.EWorkerStatus.initiating,this.threadId=-1,this._suicideTime=config_1.SUICIDE_TIME["miniprogram-ci"],this._postMessage=()=>{},this._initBarrier=null,this._taskStartTime=0,this.threadId=WorkerInstanceThreadIdIdx++}async init(){envIsDevtools&&(this._suicideTime=config_1.SUICIDE_TIME.devtools);const e={NODE_PATH:process.env.NODE_PATH||path_1.default.posix.join(__filename,"../../../../../../../../node_modules"),ELECTRON_MODULE_FALLBACK_DIRS:process.env.ELECTRON_MODULE_FALLBACK_DIRS||"",ELECTRON_ACTIVE_APP_PATH:process.env.ELECTRON_ACTIVE_APP_PATH||"",ELECTRON_BASE_APP_PATH:process.env.ELECTRON_BASE_APP_PATH||"",isDevtools:String(envIsDevtools)};if(supportWebWorkerThread);else if(supportWorkerThread){const t=await(0,debug_1.shouldInspectWorker)()?["--inspect="+_workerInspectPort++]:[];this._instance=new Worker(WORKER_PATH,{env:Object.assign(Object.assign({},e),{cpprocessEnv:"workerthread"}),stdout:!0,execArgv:t}),this._postMessage=this._instance.postMessage.bind(this._instance)}else{const t=await(0,debug_1.shouldInspectWorker)()?["--inspect="+_workerInspectPort++]:[];this._instance=(0,child_process_1.fork)(FORK_PATH,[""],{env:Object.assign(Object.assign({},e),{cpprocessEnv:"workerprocess"}),execArgv:t}),this._postMessage=this._instance.send.bind(this._instance)}const t=e=>{var t;const{command:s,data:r}=e;s===config_1.COMMAND.INIT_READY&&(null===(t=this._initBarrier)||void 0===t||t.open(),console.log("worker init_ready")),s===config_1.COMMAND.TASK_DONE&&this.onTaskDone(r),s===config_1.COMMAND.SEND_LOG&&logger_1.logger.send(r.level,r.args),s===config_1.COMMAND.CALL_FUNC&&call_func_1.call.apply(null,[r.funcName,...r.args]).then((e=>{this._postMessage({command:config_1.COMMAND.CALL_FUNC_RESULT,data:{id:r.id,result:e}})})).catch((e=>{this._postMessage({command:config_1.COMMAND.CALL_FUNC_RESULT,data:{id:r.id,error:e.toString()}})}))},s=e=>{0!==e&&1!==e&&log.error(`worker thread: ${this.threadId}, status: ${this.status}, exit with code: ${e}`),this.emit("exit",{code:e,status:this.status,task:this._task,threadId:this.threadId})};supportWebWorkerThread?(this._instance.onMsg(t),this._instance.onError(s)):(this._instance.on("message",t),this._instance.on("exit",s)),await this._initWorkerServices()}on(e,t){return super.on(e,t)}async _initWorkerServices(){let e={};try{const t=await(0,getservice_1.default)(appDirService_1.IAppDirService).get("WeappCompileCache"),s=await(0,getservice_1.default)(nativeModule_1.INativeModuleService);e={NativeModule:{WXMLParsePath:await s.getWXMLParsePath(),WXSSParsePath:await s.getWXSSParsePath(),GlassEaselLazyModulePath:await s.getGlassEaselTemplateCompilerPath()},AppDirService:{WeappCompileCache:t}}}catch(e){console.error("init start getservice(IAppDirService) getservice(INativeModuleService) failed",e)}console.log("COMMAND.INIT_START"),this._postMessage({command:config_1.COMMAND.INIT_START,data:e}),this._initBarrier=new async_1.Barrier,await this._initBarrier.wait()}onTaskDone(e){var t,s,r,i;const o=Date.now()-this._taskStartTime,a=resolveTaskLabel(null!==(s=null===(t=this._task)||void 0===t?void 0:t.name)&&void 0!==s?s:"",null===(r=this._task)||void 0===r?void 0:r.data);this.status=config_1.EWorkerStatus.free,(null===(i=this._task)||void 0===i?void 0:i.resolve)&&(this._task.onStatusUpdate(config_1.ETaskStatus.done),this._task.resolve(e)),this._task=void 0,this.emit("taskDone",this.threadId,a,o),env_1.summerProcess&&env_1.nativeProcess||this.setUpSuicideTimer()}setUpSuicideTimer(){this._suicideTimer=setTimeout((()=>{clearTimeout(this._suicideTimer),this.status===config_1.EWorkerStatus.free?(this.status=config_1.EWorkerStatus.dying,supportWebWorkerThread?this._instance.kill():supportWorkerThread?this._instance.terminate():this._instance.kill("SIGTERM")):this._suicideTimer||this.setUpSuicideTimer()}),this._suicideTime)}runTask(e){clearTimeout(this._suicideTimer),this.status=config_1.EWorkerStatus.busy,this._task=e,this._taskStartTime=Date.now(),this._task.onStatusUpdate(config_1.ETaskStatus.progress),this._postMessage({command:config_1.COMMAND.RUN_TASK,data:{taskName:e.name,data:e.data}})}}class WorkerManager{constructor(e,t=!1){this._taskQueue=[],this._workerPool={},this._max_pool_size=4,this._taskRecords=[],this.onWorkerExit=async e=>{const{code:t,status:s,task:r,threadId:i}=e;delete this._workerPool[i],s===config_1.EWorkerStatus.busy&&(r.retryTimes+=1,r.retryTimes<=2?(log.error(`worker thread: ${i} exit with code: ${t} when it is busy, retry ${r.retryTimes} times`),this._taskQueue.push(r)):r.reject(`worker thread exit with code: ${t} when it is busy`)),await this._run()},this._actualWorkerPoolSize=1,this._doneThreadSet=new Set,this.onTaskDone=async(e,t,s)=>{null!=t&&null!=s&&this._taskRecords.push({workerId:e,taskName:t,duration:s}),this._doneThreadSet.add(e),this._actualWorkerPoolSize=Math.min(howManyWorker(this._doneThreadSet.size),this._max_pool_size),await this._run()},this._max_pool_size=e>8?8:e,envIsDevtools=t}runTask(e,t,s=(()=>{})){return new Promise(((r,i)=>{const o={name:e,data:t,resolve:r,reject:i,retryTimes:0,onStatusUpdate:s};s(config_1.ETaskStatus.waiting),this._taskQueue.push(o),this._run()}))}getTaskRecords(){return this._taskRecords}clearTaskRecords(){this._taskRecords=[]}abort(e){const t=[],s=[];this._taskQueue.forEach((r=>{r.name!==e?s.push(r):t.push(r)})),t.forEach((e=>{e.reject(exports.AbortEvent)})),this._taskQueue=s}async _run(){let e=this._taskQueue[0];for(;e;){const t=this.getFreeWorker();if(!t)return;this._taskQueue.shift(),t.runTask(e),e=this._taskQueue[0]}}getFreeWorker(){for(const e in this._workerPool){const t=this._workerPool[e];if(t.status===config_1.EWorkerStatus.free)return t}return this.allocWorker(),null}async allocWorker(){if(this.workerCount()<this._max_pool_size){const e=new WorkerInstance;return this._workerPool[e.threadId]=e,await e.init(),e.status=config_1.EWorkerStatus.free,e.on("taskDone",this.onTaskDone),e.on("exit",this.onWorkerExit),this._run(),e}return null}workerCount(){return Object.keys(this._workerPool).length}}function howManyWorker(e){switch(e){case 1:return 4;case 2:return 6;default:return 8}}const getWorkerManager=function(e=!1){return workerManagerInstance||(workerManagerInstance=new WorkerManager(cpus,e)),workerManagerInstance};exports.getWorkerManager=getWorkerManager;
@@ -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 summerCPProject_1=require("../../project/summerCPProject"),index_1=require("../precompiler/index"),progressRecorder_1=require("../../utils/progressRecorder"),index_2=require("./original/index"),summer_1=require("./summer/summer"),pipeManager_1=require("./summer/pipeManager/pipeManager"),func_1=require("./original/workerThread/task/func"),debug_1=require("../../utils/debug"),getProcess_1=require("../../utils/subprocess/getProcess"),env_1=require("../../utils/env"),workerManager_1=require("./original/workerThread/workerManager"),getservice_1=require("../../services/common/getservice");let summercompileManager,summerProject,pipeManager,preCompiler,precompileProject,inited=!1;const MEMORY_THRESHOLD=500;async function processSend(e){await(0,debug_1.shouldRunInMainProcess)()?emiter.emit("message",e):(0,getProcess_1.getProcess)().send(e)}async function initHandler(e){const{passData:r,projectInfo:o,options:a}=e.data;if(inited)return;summerProject=new summerCPProject_1.SummerCPProject(o),await summerProject.ready();const{targetPlatform:t,targetPlatformDefines:s}=o;preCompiler=new index_1.PreCompiler(summerProject,{showBuildLog:(e,r,o)=>{processSend({type:"log",id:e,status:r,text:o})}},void 0),precompileProject=await preCompiler.getPreCompileProject({targetPlatform:t,targetPlatformDefines:s,runEnv:"summer cp"});const{cachePath:i}=r;summercompileManager=new summer_1.SummerCompiler(precompileProject,i,a),pipeManager=new pipeManager_1.PipeManager(summercompileManager),(0,func_1.setPipeIPCHandler)(((e,r)=>pipeManager.handlePipeIPC(e,r))),checkMemoryAndGC(),inited=!0}async function checkMemoryAndGC(){(0,env_1.isElectron)()&&process.memoryUsage&&global.gc&&setInterval((()=>{process.memoryUsage().heapTotal>1024*MEMORY_THRESHOLD*1024&&(console.time("[summer-compiler checkMemoryAndGC] gc"),global.gc(),console.timeEnd("[summer-compiler checkMemoryAndGC] gc"))}),3e3)}async function getCodeFiles(e,r,o){let a={};"getDevCodeByFileList"===e?a=await r.run(`getDevCodeByFileList-${o.graphId}`,(()=>summercompileManager.getDevCodeByFileList(o,r))):"getCode"===e&&(a=await r.run(`getCode-${o.graphId}-${o.package}`,(()=>summercompileManager.getCode(o,r))));const{cacheMd5:t}=o;for(const e of Object.keys(t)){const r=a[e];r?"error"in r||r.md5!==t[e]||delete a[e]:a[e]={path:e,md5:"",code:""}}for(const e of Object.values(a))"error"in e&&e.error instanceof Error&&(e.error={code:e.error.code||-1,message:e.error.message,stack:e.error.stack,path:e.path});return a}async function destroy(){null==pipeManager||pipeManager.destroy(),pipeManager=void 0,null==summercompileManager||summercompileManager.destroy(),summercompileManager=void 0,inited=!1,preCompiler=void 0,summerProject=void 0,precompileProject=void 0}const emiter=function(){const e={};return{on:(r,o)=>{e.hasOwnProperty(r)||(e[r]=[]),e[r].push(o)},off:(r,o)=>{var a;e[r]=(null===(a=e[r])||void 0===a?void 0:a.filter((e=>e!==o)))||[]},emit:(r,...o)=>{const a=e[r];if((null==a?void 0:a.length)>0)for(const e of a)try{e(...o)}catch(e){}}}}(),onMessage=e=>{emiter.on("message",e)};async function messageHandler(e){if("event"===e.type)if("fileChange"===e.name){const{type:r,targetPath:o}=e.data;summerProject.onFileChange(r,o)}else if("updateOptions"===e.name){const r=e.data;summerProject.updateOptions(r),summercompileManager.updateOptions(r)}else if("precompileOptionsChange"===e.name){const r=e.data;precompileProject.updateConditionCompileOptions(r)}if("request"===e.type){const{id:r,name:o,data:a}=e,t=r,s=new progressRecorder_1.Recorder(((e,r,o)=>{processSend({type:"progress",id:e,taskId:t,status:r,message:o})}));try{let e;if("getCode"===o||"getDevCodeByFileList"===o)e=await getCodeFiles(o,s,a);else if("getPackageFiles"===o)e=await summercompileManager.getPackageFiles(a,s);else if("getConf"===o)e=await summercompileManager.getConf(a,s);else if("getLocalFileList"===o)e=await summercompileManager.getLocalFileList(a);else if("compile"===o)e=await summercompileManager.compile(a,s);else if("compileNewLogic"===o)e=await summercompileManager.compileNewLogic(a,s);else if("compileSingleCode"===o)e=await summercompileManager.compileSingleCode(a,s);else if("setLocale"===o)(0,index_2.setLocale)(a);else if("clearCache"===o)summercompileManager.clearCache();else if("executePipe"===o)e=await pipeManager.executePipe(a,s);else if("getWorkerTaskStats"===o)e=(0,workerManager_1.getWorkerManager)().getTaskRecords();else if("clearWorkerTaskStats"===o)(0,workerManager_1.getWorkerManager)().clearTaskRecords();else if("loadStatus"===o)e=summercompileManager.getStatus();else{if("initServiceAndloadStatus"!==o)throw new Error(`unknown command ${o}`);{const r=(0,getservice_1.getServicesEnv)();(0,getservice_1.initServices)(r,a),e=summercompileManager.getStatus()}}processSend({type:"response",id:r,data:e})}catch(e){processSend({type:"response",id:r,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 summerCPProject_1=require("../../project/summerCPProject"),index_1=require("../precompiler/index"),progressRecorder_1=require("../../utils/progressRecorder"),index_2=require("./original/index"),summer_1=require("./summer/summer"),debug_1=require("../../utils/debug"),getProcess_1=require("../../utils/subprocess/getProcess"),env_1=require("../../utils/env"),workerManager_1=require("./original/workerThread/workerManager"),getservice_1=require("../../services/common/getservice");let summercompileManager,summerProject,preCompiler,precompileProject,inited=!1;const MEMORY_THRESHOLD=500;async function processSend(e){await(0,debug_1.shouldRunInMainProcess)()?emiter.emit("message",e):(0,getProcess_1.getProcess)().send(e)}async function initHandler(e){const{passData:r,projectInfo:o,options:t}=e.data;if(inited)return;summerProject=new summerCPProject_1.SummerCPProject(o),await summerProject.ready();const{targetPlatform:s,targetPlatformDefines:a}=o;preCompiler=new index_1.PreCompiler(summerProject,{showBuildLog:(e,r,o)=>{processSend({type:"log",id:e,status:r,text:o})}},void 0),precompileProject=await preCompiler.getPreCompileProject({targetPlatform:s,targetPlatformDefines:a,runEnv:"summer cp"});const{cachePath:i}=r;summercompileManager=new summer_1.SummerCompiler(precompileProject,i,t),checkMemoryAndGC(),inited=!0}async function checkMemoryAndGC(){(0,env_1.isElectron)()&&process.memoryUsage&&global.gc&&setInterval((()=>{process.memoryUsage().heapTotal>1024*MEMORY_THRESHOLD*1024&&(console.time("[summer-compiler checkMemoryAndGC] gc"),global.gc(),console.timeEnd("[summer-compiler checkMemoryAndGC] gc"))}),3e3)}async function getCodeFiles(e,r,o){let t={};"getDevCodeByFileList"===e?t=await r.run(`getDevCodeByFileList-${o.graphId}`,(()=>summercompileManager.getDevCodeByFileList(o,r))):"getCode"===e&&(t=await r.run(`getCode-${o.graphId}-${o.package}`,(()=>summercompileManager.getCode(o,r))));const{cacheMd5:s}=o;for(const e of Object.keys(s)){const r=t[e];r?"error"in r||r.md5!==s[e]||delete t[e]:t[e]={path:e,md5:"",code:""}}for(const e of Object.values(t))"error"in e&&e.error instanceof Error&&(e.error={code:e.error.code||-1,message:e.error.message,stack:e.error.stack,path:e.path});return t}async function destroy(){null==summercompileManager||summercompileManager.destroy(),summercompileManager=void 0,inited=!1,preCompiler=void 0,summerProject=void 0,precompileProject=void 0}const emiter=function(){const e={};return{on:(r,o)=>{e.hasOwnProperty(r)||(e[r]=[]),e[r].push(o)},off:(r,o)=>{var t;e[r]=(null===(t=e[r])||void 0===t?void 0:t.filter((e=>e!==o)))||[]},emit:(r,...o)=>{const t=e[r];if((null==t?void 0:t.length)>0)for(const e of t)try{e(...o)}catch(e){}}}}(),onMessage=e=>{emiter.on("message",e)};async function messageHandler(e){if("event"===e.type)if("fileChange"===e.name){const{type:r,targetPath:o}=e.data;summerProject.onFileChange(r,o)}else if("updateOptions"===e.name){const r=e.data;summerProject.updateOptions(r),summercompileManager.updateOptions(r)}else if("precompileOptionsChange"===e.name){const r=e.data;precompileProject.updateConditionCompileOptions(r)}if("request"===e.type){const{id:r,name:o,data:t}=e,s=r,a=new progressRecorder_1.Recorder(((e,r,o)=>{processSend({type:"progress",id:e,taskId:s,status:r,message:o})}));try{let e;if("getCode"===o||"getDevCodeByFileList"===o)e=await getCodeFiles(o,a,t);else if("getPackageFiles"===o)e=await summercompileManager.getPackageFiles(t,a);else if("getConf"===o)e=await summercompileManager.getConf(t,a);else if("getLocalFileList"===o)e=await summercompileManager.getLocalFileList(t);else if("compile"===o)e=await summercompileManager.compile(t,a);else if("compileNewLogic"===o)e=await summercompileManager.compileNewLogic(t,a);else if("compileSingleCode"===o)e=await summercompileManager.compileSingleCode(t,a);else if("setLocale"===o)(0,index_2.setLocale)(t);else if("clearCache"===o)summercompileManager.clearCache();else if("executePipe"===o);else if("getWorkerTaskStats"===o)e=(0,workerManager_1.getWorkerManager)().getTaskRecords();else if("clearWorkerTaskStats"===o)(0,workerManager_1.getWorkerManager)().clearTaskRecords();else if("loadStatus"===o)e=summercompileManager.getStatus();else{if("initServiceAndloadStatus"!==o)throw new Error(`unknown command ${o}`);{const r=(0,getservice_1.getServicesEnv)();(0,getservice_1.initServices)(r,t),e=summercompileManager.getStatus()}}processSend({type:"response",id:r,data:e})}catch(e){processSend({type:"response",id:r,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.AppConf=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),baseconf_1=require("./baseconf"),original_1=require("../../original"),common_1=require("../../original/json/common"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),getPageJSON_1=require("../../original/json/page/getPageJSON"),util_1=require("./util"),taskmanager_1=tslib_1.__importDefault(require("../../../../utils/taskmanager"));class AppConf extends baseconf_1.MiniProgramBaseConf{constructor(){super(...arguments),this.packages=new Map,this.pages=new Map,this.comps=new Map,this.onFileChange=(t,o)=>{}}destroy(){}async getConf(t){return await this.build(t),{app:this.app,ext:this.ext,packages:Object.fromEntries(this.packages.entries()),pages:Object.fromEntries(this.pages.entries()),comps:Object.fromEntries(this.comps.entries()),sitemap:this.sitemap,theme:this.theme}}async buildPagesAndCompsForUpload(t,o=!1){const a={},e={};return await Promise.all(Array.from(this.pages.keys()).map((async t=>{const e=await(o?getPageJSON_1.getPageJSONWithDisableSpreading:original_1.getPageJSON)(this.proxyProject,{miniprogramRoot:this.root,pagePath:t});a[`${t}.json`]=JSON.stringify(e)}))),await Promise.all(Array.from(this.comps.keys()).map((async t=>{const a=await(o?getPageJSON_1.getPageJSONWithDisableSpreading:original_1.getPageJSON)(this.proxyProject,{miniprogramRoot:this.root,pagePath:t});e[`${t}.json`]=JSON.stringify(a)}))),{pageResults:a,componentResults:e}}async buildPagesAndCompsWithFileListForUpload(t,o,a=!1){const e={},s={},i=new taskmanager_1.default;for(const t of Array.from(this.pages.keys()))if(o.includes(`${t}.json`)){const o=async t=>{const o=await(a?getPageJSON_1.getPageJSONWithDisableSpreading:original_1.getPageJSON)(this.proxyProject,{miniprogramRoot:this.root,pagePath:t});e[`${t}.json`]=JSON.stringify(o)};i.addTask(o,t)}for(const t of Array.from(this.comps.keys()))if(o.includes(`${t}.json`)){const o=async t=>{const o=await(a?getPageJSON_1.getPageJSONWithDisableSpreading:original_1.getPageJSON)(this.proxyProject,{miniprogramRoot:this.root,pagePath:t});s[`${t}.json`]=JSON.stringify(o)};i.addTask(o,t)}return await i.runAllAsync(),{pageResults:e,componentResults:s}}async resetState(){this.app=void 0,this.ext=void 0,this.packages.clear(),this.pages.clear(),this.comps.clear(),this.sitemap=void 0,this.theme=void 0}async load(t){const o=await t.run(locales_1.default.config.SUMMER_COMPILE.format("app.json"),(()=>(0,original_1.getAppJSON)(this.proxyProject)));this.app=o;const a=await t.run(locales_1.default.config.SUMMER_COMPILE.format("ext.json"),(()=>(0,original_1.getExtJSON)(this.proxyProject)));this.ext=a;const{project:e}=this.proxyProject,s=new Set;for(const t of o.pages)s.add(t);for(const t of e.injectedPages)s.add((0,util_1.resolvePath)("app.json",t));const i=o.subPackages||[];for(const t of i){const o=t.root;this.packages.set(o,t);for(const a of t.pages)s.add(path_1.default.posix.join(o,a))}await t.run(locales_1.default.config.SUMMER_COMPILE_PAGE_JSON.format(s.size),(async()=>{var t;for(const[t]of s.entries())(0,util_1.isPluginPath)(t)||await this.loadPage(t);for(const t of Object.values(o.usingComponents||{}))if(!t.startsWith("plugin://")&&!(0,util_1.isPluginPath)(t)){const o=(0,util_1.resolvePath)("app.json",t);await this.loadComp(o,t,"app.json")}if(null===(t=o.tabBar)||void 0===t?void 0:t.custom){const t=(0,util_1.resolvePath)("app.json","custom-tab-bar/index");this.proxyProject.stat(this.root,`${t}.json`)&&await this.loadComp(t,"custom-tab-bar/index","app.json")}if(o.appBar){const t=(0,util_1.resolvePath)("app.json","app-bar/index");this.proxyProject.stat(this.root,`${t}.json`)&&await this.loadComp(t,"app-bar/index","app.json")}if(o.plugins)for(const t of Object.values(o.plugins))t.genericsImplementation&&Object.values(t.genericsImplementation).forEach((t=>{Object.values(t).map((async t=>{const o=(0,util_1.resolvePath)("app.json",t);return await this.loadComp(o,t,"app.json")}))}))})),o.themeLocation&&await t.run(locales_1.default.config.SUMMER_COMPILE.format(o.themeLocation),(()=>this.loadTheme(o.themeLocation))),o.accountCardPackage&&await t.run(locales_1.default.config.SUMMER_COMPILE.format(o.themeLocation),(async()=>{for(const t of o.accountCardPackage.cardList){const a=path_1.default.posix.join(o.accountCardPackage.root,t.componentPath);await this.loadComp(a,a,"app.json")}}))}async loadPage(t){const o=await(0,original_1.getPageJSON)(this.proxyProject,{miniprogramRoot:this.root,pagePath:t});this.pages.set(t,o);const a=async o=>{if((0,util_1.isPluginPath)(o))return;const a=(0,util_1.resolvePath)(t,o);await this.loadComp(a,o,t)};if(o.usingComponents)for(const t of Object.values(o.usingComponents))await a(t);if(o.componentGenerics)for(const t of Object.values(o.componentGenerics)){const o=t.default;o&&await a(o)}}async loadComp(t,o,a){if(await this.isExtendedLibComp(t,a))return;if(this.comps.has(t))return;if(!this.proxyProject.stat(this.root,`${t}.json`))throw new Error(`[summer-compiler] Couldn't found the '${o}.json' file relative to '${a}'`);const e=await(0,original_1.getPageJSON)(this.proxyProject,{miniprogramRoot:this.root,pagePath:t});this.comps.set(t,e);const s=async o=>{if((0,util_1.isPluginPath)(o))return;const a=(0,util_1.resolvePath)(t,o);await this.loadComp(a,o,t)};if(e.usingComponents)for(const t of Object.values(e.usingComponents))await s(t);if(e.componentGenerics)for(const t of Object.values(e.componentGenerics)){const o=t.default;o&&await s(o)}}async loadTheme(t){const o=await(0,original_1.checkThemeJSON)(this.proxyProject,{themeLocation:t});this.theme=o}async isExtendedLibComp(t,o){if(t.startsWith("miniprogram_npm/")){const a=(0,common_1.getUseExtendLib)(this.proxyProject,o);if(a.length>0){const o=a.map((t=>`miniprogram_npm/${t}`));for(const a of o)if(t.startsWith(a))return!0}}return!1}}exports.AppConf=AppConf;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppConf=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),baseconf_1=require("./baseconf"),original_1=require("../../original"),common_1=require("../../original/json/common"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),getPageJSON_1=require("../../original/json/page/getPageJSON"),util_1=require("./util"),taskmanager_1=tslib_1.__importDefault(require("../../../../utils/taskmanager"));class AppConf extends baseconf_1.MiniProgramBaseConf{constructor(){super(...arguments),this.packages=new Map,this.pages=new Map,this.comps=new Map,this.onFileChange=(t,o)=>{}}destroy(){}async getConf(t){return await this.build(t),{app:this.app,ext:this.ext,packages:Object.fromEntries(this.packages.entries()),pages:Object.fromEntries(this.pages.entries()),comps:Object.fromEntries(this.comps.entries()),sitemap:this.sitemap,theme:this.theme}}async buildPagesAndCompsForUpload(t,o=!1){const a={},s={};return await Promise.all(Array.from(this.pages.keys()).map((async t=>{const s=await(o?getPageJSON_1.getPageJSONWithDisableSpreading:original_1.getPageJSON)(this.proxyProject,{miniprogramRoot:this.root,pagePath:t});a[`${t}.json`]=JSON.stringify(s)}))),await Promise.all(Array.from(this.comps.keys()).map((async t=>{const a=await(o?getPageJSON_1.getPageJSONWithDisableSpreading:original_1.getPageJSON)(this.proxyProject,{miniprogramRoot:this.root,pagePath:t});s[`${t}.json`]=JSON.stringify(a)}))),{pageResults:a,componentResults:s}}async buildPagesAndCompsWithFileListForUpload(t,o,a=!1){const s={},e={},i=new taskmanager_1.default;for(const t of Array.from(this.pages.keys()))if(o.includes(`${t}.json`)){const o=async t=>{const o=await(a?getPageJSON_1.getPageJSONWithDisableSpreading:original_1.getPageJSON)(this.proxyProject,{miniprogramRoot:this.root,pagePath:t});s[`${t}.json`]=JSON.stringify(o)};i.addTask(o,t)}for(const t of Array.from(this.comps.keys()))if(o.includes(`${t}.json`)){const o=async t=>{const o=await(a?getPageJSON_1.getPageJSONWithDisableSpreading:original_1.getPageJSON)(this.proxyProject,{miniprogramRoot:this.root,pagePath:t});e[`${t}.json`]=JSON.stringify(o)};i.addTask(o,t)}return await i.runAllAsync(),{pageResults:s,componentResults:e}}async resetState(){this.app=void 0,this.ext=void 0,this.packages.clear(),this.pages.clear(),this.comps.clear(),this.sitemap=void 0,this.theme=void 0}async load(t){var o;const a=await t.run(locales_1.default.config.SUMMER_COMPILE.format("app.json"),(()=>(0,original_1.getAppJSON)(this.proxyProject)));this.app=a;const s=await t.run(locales_1.default.config.SUMMER_COMPILE.format("ext.json"),(()=>(0,original_1.getExtJSON)(this.proxyProject)));this.ext=s;const{project:e}=this.proxyProject,i=new Set;for(const t of a.pages)i.add(t);for(const t of e.injectedPages)i.add((0,util_1.resolvePath)("app.json",t));const n=a.subPackages||[];for(const t of n){const o=t.root;this.packages.set(o,t);for(const a of t.pages)i.add(path_1.default.posix.join(o,a))}if(await t.run(locales_1.default.config.SUMMER_COMPILE_PAGE_JSON.format(i.size),(async()=>{var t;for(const[t]of i.entries())(0,util_1.isPluginPath)(t)||await this.loadPage(t);for(const t of Object.values(a.usingComponents||{}))if(!t.startsWith("plugin://")&&!(0,util_1.isPluginPath)(t)){const o=(0,util_1.resolvePath)("app.json",t);await this.loadComp(o,t,"app.json")}if(null===(t=a.tabBar)||void 0===t?void 0:t.custom){const t=(0,util_1.resolvePath)("app.json","custom-tab-bar/index");this.proxyProject.stat(this.root,`${t}.json`)&&await this.loadComp(t,"custom-tab-bar/index","app.json")}if(a.appBar){const t=(0,util_1.resolvePath)("app.json","app-bar/index");this.proxyProject.stat(this.root,`${t}.json`)&&await this.loadComp(t,"app-bar/index","app.json")}if(a.plugins)for(const t of Object.values(a.plugins))t.genericsImplementation&&Object.values(t.genericsImplementation).forEach((t=>{Object.values(t).map((async t=>{const o=(0,util_1.resolvePath)("app.json",t);return await this.loadComp(o,t,"app.json")}))}))})),a.themeLocation&&await t.run(locales_1.default.config.SUMMER_COMPILE.format(a.themeLocation),(()=>this.loadTheme(a.themeLocation))),a.accountCardPackage&&await t.run(locales_1.default.config.SUMMER_COMPILE.format(a.themeLocation),(async()=>{for(const t of a.accountCardPackage.cardList){const o=path_1.default.posix.join(a.accountCardPackage.root,t.componentPath);await this.loadComp(o,o,"app.json")}})),null===(o=a.agent)||void 0===o?void 0:o.skills){const t=new Set(a.agent.skills.map((t=>t.path)).filter((t=>!!t)));for(const o of n){const a=o.root.replace(/\/$/,"");if(!Array.from(t).some((t=>t===a||t.startsWith(`${a}/`))))continue;const s=`${a}/`,n=e.getFileList(this.root,".json");for(const t of n){const o=t.replace(new RegExp(`^${this.root}/?`),"");if(!o.startsWith(s))continue;const a=o.replace(/\.json$/,"");if(!i.has(a)&&(!this.comps.has(a)&&this.proxyProject.stat(this.root,o)))try{const t=e.getFile(this.root,o),s=JSON.parse(t.toString());if(!0!==s.component&&void 0===s.usingComponents)continue;await this.loadComp(a,a,"app.json")}catch(t){}}}}}async loadPage(t){const o=await(0,original_1.getPageJSON)(this.proxyProject,{miniprogramRoot:this.root,pagePath:t});this.pages.set(t,o);const a=async o=>{if((0,util_1.isPluginPath)(o))return;const a=(0,util_1.resolvePath)(t,o);await this.loadComp(a,o,t)};if(o.usingComponents)for(const t of Object.values(o.usingComponents))await a(t);if(o.componentGenerics)for(const t of Object.values(o.componentGenerics)){const o=t.default;o&&await a(o)}}async loadComp(t,o,a){if(await this.isExtendedLibComp(t,a))return;if(this.comps.has(t))return;if(!this.proxyProject.stat(this.root,`${t}.json`))throw new Error(`[summer-compiler] Couldn't found the '${o}.json' file relative to '${a}'`);const s=await(0,original_1.getPageJSON)(this.proxyProject,{miniprogramRoot:this.root,pagePath:t});this.comps.set(t,s);const e=async o=>{if((0,util_1.isPluginPath)(o))return;const a=(0,util_1.resolvePath)(t,o);await this.loadComp(a,o,t)};if(s.usingComponents)for(const t of Object.values(s.usingComponents))await e(t);if(s.componentGenerics)for(const t of Object.values(s.componentGenerics)){const o=t.default;o&&await e(o)}}async loadTheme(t){const o=await(0,original_1.checkThemeJSON)(this.proxyProject,{themeLocation:t});this.theme=o}async isExtendedLibComp(t,o){if(t.startsWith("miniprogram_npm/")){const a=(0,common_1.getUseExtendLib)(this.proxyProject,o);if(a.length>0){const o=a.map((t=>`miniprogram_npm/${t}`));for(const a of o)if(t.startsWith(a))return!0}}return!1}}exports.AppConf=AppConf;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.swcCompileTask=swcCompileTask;const swc_helper_1=require("../../../../../utils/swc_helper"),swc=()=>require("@swc/core");async function swcCompileTask(e,s,r){var o,t;const i=r.disableUseStrict||/^\s*\/\/\s?use strict disable;/i.test(s.sourceCode||""),{swcRoot:c}=r,p=await swc().transform(s.sourceCode,{jsc:{parser:Object.assign(Object.assign({},null===(o=r.rc)||void 0===o?void 0:o.parser),{syntax:e.endsWith("ts")?"typescript":"ecmascript"}),target:r.target,externalHelpers:!0,loose:!1,minify:{compress:{drop_console:!1,drop_debugger:!1},toplevel:!0}},module:Object.assign({type:"commonjs",strictMode:!i,noInterop:!0,allowTopLevelThis:i},null===(t=r.rc)||void 0===t?void 0:t.module),inputSourceMap:s.inputMap?JSON.stringify(s.inputMap):void 0,sourceMaps:!0,filename:e,minify:"dev"!==r.resultType&&r.minify}),a=(0,swc_helper_1.replaceSWCHelpers)(p.code,e,c);return{code:a.transformCode,map:p.map?JSON.parse(p.map):void 0,helpers:a.helpers}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.swcCompileTask=swcCompileTask;const swc_helper_1=require("../../../../../utils/swc_helper"),swc=()=>require("@swc/core");async function swcCompileTask(e,s,r){var o,t;const i=r.disableUseStrict||/^\s*\/\/\s?use strict disable;/i.test(s.sourceCode||""),{swcRoot:c}=r,p=await swc().transform(s.sourceCode,{jsc:{parser:Object.assign(Object.assign({},null===(o=r.rc)||void 0===o?void 0:o.parser),{syntax:e.endsWith("ts")?"typescript":"ecmascript"}),target:r.target,externalHelpers:!0,loose:!1,minify:{compress:{drop_console:!1,drop_debugger:!1},toplevel:!0}},module:Object.assign({type:"commonjs",strictMode:!i,noInterop:!1,allowTopLevelThis:i},null===(t=r.rc)||void 0===t?void 0:t.module),inputSourceMap:s.inputMap?JSON.stringify(s.inputMap):void 0,sourceMaps:!0,filename:e,minify:"dev"!==r.resultType&&r.minify}),a=(0,swc_helper_1.replaceSWCHelpers)(p.code,e,c);return{code:a.transformCode,map:p.map?JSON.parse(p.map):void 0,helpers:a.helpers}}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.runSummerPluginHook=runSummerPluginHook;const customError_1=require("../../../utils/customError"),summerCPProject_1=require("../../../project/summerCPProject"),index_1=require("../../precompiler/index"),initPlugin_1=require("./initPlugin");class PluginContainer{constructor(){this.initedPlugins=new Map}getPluginInstance(r,e,t){let n=this.initedPlugins.get(r);return n||(n=(0,initPlugin_1.initPlugin)(r,e,t),this.initedPlugins.set(r,n)),n}clear(){this.initedPlugins.clear()}}const pluginContainer=new PluginContainer;async function runSummerPluginHook(r){var e;if("clear"===r.command)return pluginContainer.clear(),{};const{plugin:t,projectInfo:n,pluginOption:i,method:o,args:u}=r,l=new summerCPProject_1.SummerCPProject(n);await l.ready();const{targetPlatform:s,targetPlatformDefines:a}=n,c=new index_1.PreCompiler(l,void 0,void 0),P=await c.getPreCompileProject({targetPlatform:s,targetPlatformDefines:a,runEnv:"worker cp"}),g=pluginContainer.getPluginInstance(t,P,i);if("runMethod"===r.command){const r=null===(e=g.workerMethods)||void 0===e?void 0:e[o];if(!r||"function"!=typeof r)throw new Error(`the ${r} is not a workerMethod of plugin(${t})`);try{return{result:await r(...u)}}catch(r){return{error:r instanceof customError_1.CustomError?r.toJSON():r}}}return{}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.runSummerPluginHook=runSummerPluginHook;const customError_1=require("../../../utils/customError"),summerCPProject_1=require("../../../project/summerCPProject"),index_1=require("../../precompiler/index"),initPlugin_1=require("./initPlugin");class PluginContainer{constructor(){this.initedPlugins=new Map}getPluginInstance(e,r,t){let n=this.initedPlugins.get(e);return n||(n=(0,initPlugin_1.initPlugin)(e,r,t),this.initedPlugins.set(e,n)),n}clear(){this.initedPlugins.clear()}}const pluginContainer=new PluginContainer;async function runSummerPluginHook(e){var r;if("clear"===e.command)return pluginContainer.clear(),{};const{plugin:t,projectInfo:n,pluginOption:i,method:o,args:u}=e,s=new summerCPProject_1.SummerCPProject(n);await s.ready();const{targetPlatform:a,targetPlatformDefines:c}=n,l=new index_1.PreCompiler(s,void 0,void 0),g=await l.getPreCompileProject({targetPlatform:a,targetPlatformDefines:c,runEnv:"worker cp"}),m=pluginContainer.getPluginInstance(t,g,i);if("runMethod"===e.command){const e=null===(r=m.workerMethods)||void 0===r?void 0:r[o];if(!e||"function"!=typeof e)throw new Error(`the ${e} is not a workerMethod of plugin(${t})`);try{return{result:await e(...u)}}catch(e){return{error:e instanceof customError_1.CustomError?e.toJSON():{message:e.message,code:e.code,stack:e.stack==e.message?"":e.stack}}}}return{}}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SummerCompiler=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=tslib_1.__importDefault(require("lodash")),locales_1=tslib_1.__importDefault(require("../../utils/locales/locales")),request_1=require("../../utils/request"),common_1=require("./original/compile/common"),tools_1=require("../../utils/tools"),white_ext_list_1=require("../../utils/white_ext_list"),config_1=require("../../config/config"),processManager_1=require("../../utils/subprocess/processManager"),messageHub_1=require("../../utils/messageHub"),singletontask_1=require("../../utils/singletontask"),uglifyfilenames_1=require("./original/protect/uglifyfilenames"),baseCompiler_1=require("./baseCompiler"),packOptionsHelper_1=tslib_1.__importDefault(require("../../utils/packOptionsHelper")),types_1=require("./summer/pipeManager/types"),getservice_1=tslib_1.__importDefault(require("../../services/common/getservice")),appDirService_1=require("../../services/app/common/appDirService"),nativeModule_1=require("../../services/nativeModule/common/nativeModule"),miniProgram=config_1.COMPILE_TYPE.miniProgram,miniGame=config_1.COMPILE_TYPE.miniGame,miniProgramPlugin=config_1.COMPILE_TYPE.miniProgramPlugin,miniGamePlugin=config_1.COMPILE_TYPE.miniGamePlugin;function performanceMark(e,t){}class SummerCompiler extends baseCompiler_1.BaseCoreCompiler{constructor(e,t,i,s,a,o,r){super(e),this.project=e,this.cachePath=t,this.projectInfo=i,this.devtoolMessagehub=s,this.analyzer=a,this._filterFactory=o,this.onInitFinished=r,this.isSummer=!0,this.promiseCache=new Map,this._taskCache=new Map,this._status=void 0,this._eventAdded=!1,this._locale="",this._initServiceForkId=0,this.devCodeCacheByPath=new Map,this.onFileChange=(e,t)=>{if("change"!==e||t.endsWith(".json"))for(const e of this.promiseCache.keys())e.startsWith("getConf-")&&this.promiseCache.delete(e);if("change"!==e){for(const e of this.promiseCache.keys())e.startsWith("getPackageFiles-")&&this.promiseCache.delete(e);for(const e of this._taskCache.keys())e.startsWith("getPackageFiles-")&&this._taskCache.delete(e)}this.invalidCodeCache(t),this.subProcessManager.sendEvent("fileChange",{type:e,targetPath:t}),packOptionsHelper_1.default.clearUnusedFiles()},this.onPreCompileOptionsChange=async e=>{await this.clearCache(),this.subProcessManager.sendEvent("precompileOptionsChange",e)},this.onProgressUpdate=(e,t,i)=>{var s;this.messageHub.showBuildLog(`${e}`,t,i),null===(s=this.progressUpdateFromCompileOptions)||void 0===s||s.call(this,{id:e.toString(),message:i,status:t})},this._getPackageFiles=async(e,t,i="dev")=>{performanceMark("request get getPackageFiles");const s=await this.safeRunTask("getPackageFiles",{graphId:e,root:t},this.onProgressUpdate);performanceMark("request get getPackageFiles",!0);const a=this.isPluginType(e)?this.project.pluginRoot:this.project.miniprogramRoot,o=await this.filterFactory(i),r={},n=s.filter((t=>{const i=path_1.default.posix.join(a,t.source),s=o(e,i);return s!==config_1.EFilterCode.Include&&(r[s]||(r[s]=[]),r[s].push(i)),s===config_1.EFilterCode.Include})),c={[config_1.EFilterCode.AnalyseNoUse]:locales_1.default.config.UNUSE_FILE_LIST,[config_1.EFilterCode.PackOptionsIgnore]:locales_1.default.config.PACK_OPTIONS_IGNORE_LIST,[config_1.EFilterCode.PartialCompileNoUse]:locales_1.default.config.PARTIAL_COMPILE_IGNORE_LIST};for(const e in r)c[e]?this.onProgressUpdate(e,"warn",c[e].format(r[e].join(","))):this.onProgressUpdate(e,"warn",locales_1.default.config.UNKNOWN_REASON_INGORE_LIST.format(e,r[e].join(",")));return n},performanceMark("create summer compiler"),this.messageHub=new messageHub_1.MessageHub(s),this.ready(),global.dumpWorkerTaskStats=this.dumpWorkerTaskStats.bind(this),global.clearWorkerTaskStats=this.clearWorkerTaskStats.bind(this)}get status(){return this._status}async init(){performanceMark("init summer compiler");const e=path_1.default.posix.join(__dirname,"./summerEntryProcess.js"),t="undefined"!=typeof WEBIDE_WEBPECK_DEFINE_PLUGIN?"./summerentryprocess.js":e;this.subProcessManager=new processManager_1.SubProcessProxy(this.project,t,{cachePath:this.cachePath},this.projectInfo,8891,this.onProgressUpdate),this.addProjectListener();this.ensureInitService().then((()=>{var e;null===(e=this.onInitFinished)||void 0===e||e.call(this)}),(e=>{var t;null===(t=this.onInitFinished)||void 0===t||t.call(this,e)})),performanceMark("init summer compiler",!0)}async initServiceAndLoadStatus(){const e={};try{const t=await(0,getservice_1.default)(appDirService_1.IAppDirService).get("WeappCompileCache"),i=await(0,getservice_1.default)(nativeModule_1.INativeModuleService);e.NativeModule={WXMLParsePath:await i.getWXMLParsePath(),WXSSParsePath:await i.getWXSSParsePath(),GlassEaselLazyModulePath:await i.getGlassEaselTemplateCompilerPath()},e.AppDirService={WeappCompileCache:t}}catch(e){console.log("initServiceAndLoadStatus hasno WeappCompileCache / INativeModuleService in ci is normal")}this._status=await this.subProcessManager.runTask("initServiceAndloadStatus",{})}async ensureInitService(){await this.subProcessManager.ready(),this.subProcessManager.forkId!==this._initServiceForkId&&(await this.initServiceAndLoadStatus(),this._initServiceForkId=this.subProcessManager.forkId)}async safeRunTask(e,t,i){return await this.ensureInitService(),this.subProcessManager.runTask(e,t,i)}async loadStatus(){this._status=await this.safeRunTask("loadStatus")}destroy(){var e;null===(e=this.subProcessManager)||void 0===e||e.destroy(),this.removeProjectListener(),this._checkReadyTask=void 0}async clearCache(){await this.safeRunTask("clearCache"),this.promiseCache.clear(),this.devCodeCacheByPath.clear(),this._taskCache.clear()}async dumpWorkerTaskStats(){const e=await this.safeRunTask("getWorkerTaskStats"),t=new Map;for(const i of e){const e=`${i.workerId}_${i.taskName}`;let s=t.get(e);s||(s={workerId:i.workerId,taskName:i.taskName,count:0,total:0},t.set(e,s)),s.count++,s.total+=i.duration}const i=[...t.values()].sort(((e,t)=>String(e.workerId).localeCompare(String(t.workerId)))).map((e=>({Worker:e.workerId,Task:e.taskName,Count:e.count,"Total(ms)":e.total,"Avg(ms)":Math.round(e.total/e.count)})));console.table(i)}async clearWorkerTaskStats(){await this.safeRunTask("clearWorkerTaskStats")}getProjectInfo(){return this.projectInfo}updateOptions(e){lodash_1.default.isEqual(e,this.projectInfo)||this.updateOptionsWithoutJudge(e)}updateOptionsWithoutJudge(e){var t;this.projectInfo=e,this.promiseCache.clear(),this.devCodeCacheByPath.clear(),null===(t=this.subProcessManager)||void 0===t||t.sendEvent("updateOptions",e),this.loadStatus(),this.project.updateOptions(e)}updateOptionsWhenAttrNotChanged(e){var t;lodash_1.default.isEqual(Object.assign(Object.assign({},e),{attr:void 0}),Object.assign(Object.assign({},this.projectInfo),{attr:void 0}))||(this.projectInfo=e,this.promiseCache.clear(),this.devCodeCacheByPath.clear(),null===(t=this.subProcessManager)||void 0===t||t.sendEvent("updateOptions",e),this.loadStatus(),this.project.updateOptions(e))}addProjectListener(){var e,t;this._eventAdded&&this.removeProjectListener(),null===(e=this.project.event)||void 0===e||e.on("fileChange",this.onFileChange),null===(t=this.project.event)||void 0===t||t.on("precompileOptionsChange",this.onPreCompileOptionsChange),this._eventAdded=!0}removeProjectListener(){var e,t;null===(e=this.project.event)||void 0===e||e.off("fileChange",this.onFileChange),null===(t=this.project.event)||void 0===t||t.off("precompileOptionsChange",this.onPreCompileOptionsChange),this._eventAdded=!1}invalidCodeCache(e){const t=this.devCodeCacheByPath.get((0,tools_1.sourcePathToTargetPath)(e));t&&(t.isValid=!1)}async getConf(e){const t=`getConf-${e}`;if(this.promiseCache.has(t))return this.promiseCache.get(t);performanceMark("request get conf");const i={graphId:e},s=this.safeRunTask("getConf",i,this.onProgressUpdate);return this.promiseCache.set(t,s),performanceMark("request get conf",!0),s}async waitSubProcessReady(){await this.subProcessManager.ready()}async getPackageFiles(e,t,i="dev",s=!0){const a=`getPackageFiles-${e}-${t}-${i}`;if(this._taskCache.has(a)&&s){const e=this._taskCache.get(a);return null==e?void 0:e.getResult(!0)}const o=new singletontask_1.SingletonTask(this._getPackageFiles.bind(this,e,t,i),a);return this._taskCache.set(a,o),null==o?void 0:o.getResult(!0)}isMiniappPlatformInclude(e){const t=path_1.default.posix.join(this.project.miniprogramRoot,"app.miniapp.json");return(0,tools_1.isMiniappPlatform)(this.project.targetPlatform)&&t===e}async filterUnusedFiles(e,t,i){const s=e?"miniGame":"miniProgram";return(await this.filterFactory(i))(s,t)}async filterFactory(e){packOptionsHelper_1.default.updateState(this.project),this.onProgressUpdate("initUnusedFiles","doing","analyzing codes..."),await packOptionsHelper_1.default.initUnusedFiles(this.project,this.analyzer,"prod"===e),0!==packOptionsHelper_1.default.getUnusedFiles().size&&this.onProgressUpdate("initUnusedFiles","doing",`ignoring files: ${Array.from(packOptionsHelper_1.default.getUnusedFiles()).join(",")}`),this.onProgressUpdate("initUnusedFiles","success","analyzing codes success");const t=this._filterFactory?await this._filterFactory(e):()=>0;return(i,s)=>{const a=packOptionsHelper_1.default.relativePath(s);return this.isMiniappPlatformInclude(s)||packOptionsHelper_1.default.isFileIncluded(a)?config_1.EFilterCode.Include:packOptionsHelper_1.default.isIgnoredByRules(a)?config_1.EFilterCode.PackOptionsIgnore:i===miniProgram&&packOptionsHelper_1.default.isIgnoreByUnusedFiles(s,"prod"===e)?config_1.EFilterCode.AnalyseNoUse:t(i,s)}}async getCodeByFileList(e,t){const i={},s={},a=this.isPluginType(e)?this.project.pluginRoot:this.project.miniprogramRoot,o=[];for(const e of t){const t=this.devCodeCacheByPath.get(path_1.default.posix.join(a,e)),r=null==t?void 0:t.codeFile;let n=!1;t&&t.isValid&&r&&!("error"in r)||(n=!0,o.push(e)),r&&!("error"in r)&&(n&&(i[e]=r.md5),s[e]=r)}if(o.length>0){const t=await this.safeRunTask("getDevCodeByFileList",{graphId:e,fileList:o,cacheMd5:i},this.onProgressUpdate);for(const e in t){const i=t[e],o=path_1.default.posix.join(a,e);"error"in i||""!==i.md5?this.devCodeCacheByPath.set(o,{isValid:!0,codeFile:i}):this.devCodeCacheByPath.delete(o),s[e]=i}}return s}async getExtJSON(){return(await this.getConf(miniProgram)).ext}async getAppJSON(){return(await this.getConf(miniProgram)).app}async getGameJSON(){return(await this.getConf(miniGame)).app}async getSiteMapJSON(){return(await this.getConf(miniProgram)).sitemap}async getPageJSON(e){const t=await this.getConf(miniProgram),i=t.pages[e]||t.comps[e];if(!i)throw new Error(`summer-compiler 收集json配置有遗漏, ${e}`);return i}async getAllPageAndComponent(){const e=await this.getConf(miniProgram),t=(await this.getPackageFiles(miniProgram,config_1.FullPkg)).map((e=>e.path)).filter((e=>e.endsWith(".json")));return Object.keys(e.pages).concat(Object.keys(e.comps)).filter((e=>t.includes(`${e}.json`)))}async getAllSortedJSFiles(){var e,t,i,s;const a=this.isGameType(this.project.type),o=a?miniGame:miniProgram,r=await this.getConf(o),n=Object.keys(null!==(e=r.pages)&&void 0!==e?e:{}),c=Object.keys(null!==(t=r.comps)&&void 0!==t?t:{}),l=await this.getPackageFiles(o,config_1.FullPkg),p=null!==(i=null==l?void 0:l.map((e=>e.path)).filter((e=>e.endsWith(".js"))))&&void 0!==i?i:[],h=null!==(s=null==n?void 0:n.filter((e=>!c.includes(e))).map((e=>`${e}.js`)).filter((e=>p.includes(e))))&&void 0!==s?s:[],g=c.map((e=>`${e}.js`)).filter((e=>p.includes(e))),u=p.filter((e=>e.endsWith(".js")&&e!==(a?"game.js":"app.js")&&!h.includes(e)&&!g.includes(e)));return{jsPagesFiles:h,components:g,otherJsFiles:u}}async getAllWxmlAndWxsFiles(){const e=(await this.getPackageFiles(miniProgram,config_1.FullPkg)).map((e=>e.path)),t=e.filter((e=>e.endsWith(".wxml"))),i=e.filter((e=>e.endsWith(".wxs"))),s=await this.getCodeByFileList(miniProgram,t.concat(i));return{wxmlFiles:t,wxsFiles:i,content:t.concat(i).reduce(((e,t)=>{const i=s[t];if("error"in i)throw i.error;return e[t]=i.code,e[`./${t}`]=i.code,e}),{})}}async getPackageWxmlAndWxsFiles(e){let t=(await this.getPackageFiles(miniProgram,e)).map((e=>e.path));if(e!==config_1.MainPkg&&e!==config_1.FullPkg){const e=(await this.getPackageFiles(miniProgram,config_1.MainPkg)).map((e=>e.path));t=t.concat(e)}const i=t.filter((e=>e.endsWith(".wxml"))),s=t.filter((e=>e.endsWith(".wxs"))),a=await this.getCodeByFileList(miniProgram,i.concat(s));return{wxmlFiles:i,wxsFiles:s,content:i.concat(s).reduce(((e,t)=>{const i=a[t];if(!i)throw`lack of ${t} code`;if("error"in i)throw i.error;return e[t]=i.code,e[`./${t}`]=i.code,e}),{})}}async getPackageWxssFileList(e){let t=(await this.getPackageFiles(miniProgram,e)).map((e=>e.path));if(e!==config_1.MainPkg&&e!==config_1.FullPkg){const e=(await this.getPackageFiles(miniProgram,config_1.MainPkg)).map((e=>e.path));t=t.concat(e)}return t.filter((e=>e.endsWith(".wxss")))}async getPackageWxssFiles(e){const t=await this.getPackageWxssFileList(e),i=await this.getCodeByFileList(miniProgram,t);return{wxssFiles:t,content:t.reduce(((e,t)=>{const s=i[t];if(!s)throw`lack of ${t} code`;if("error"in s)throw s.error;return e[t]=s.code,e[`./${t}`]=s.code,e}),{})}}getWxssMap(e,t){t=(0,tools_1.normalizePath)(t),e===miniProgram?t=path_1.default.posix.join(this.project.miniprogramRoot,t):e===miniProgramPlugin&&(t=path_1.default.posix.join(this.project.pluginRoot,t));const i=this.devCodeCacheByPath.get(t),s=null==i?void 0:i.codeFile;if(s&&!("error"in s))return s.map}async getMainPkgSortedJSFiles(){const e=await this.getConf(miniProgram),t=(await this.getPackageFiles(miniProgram,config_1.MainPkg)).map((e=>e.path)).filter((e=>e.endsWith(".js"))),i=[],s=[],a=[],o=[],r=[];let n=!1;const c={},l=t=>Object.keys(e.packages).find((e=>t.startsWith(e)))||config_1.MainPkg;e.app.functionalPages&&t.forEach((e=>{if(e.startsWith("functional-pages/")){const t=e.replace(/\.js$/,"");if(c[t])return;c[t]=!0,r.push(encodeURI(t))}})),e.app.workers&&t.forEach((t=>{if(t.startsWith((0,tools_1.getWorkersPath)(e.app.workers))){const e=t.replace(/\.js$/,"");if(c[e])return;c[e]=!0,o.push(e)}}));Object.keys(e.comps).filter((e=>l(e)===config_1.MainPkg)).forEach((t=>{if((t.startsWith("miniprogram_npm/weui-miniprogram")||t.startsWith("weui-miniprogram"))&&e.app.useExtendedLib&&e.app.useExtendedLib.weui)return;if(c[t])return;c[t]=!0;const i=encodeURI(t);a.push(`${i}`)}));Object.keys(e.pages).filter((e=>l(e)===config_1.MainPkg)).forEach((e=>{if(c[e])return;c[e]=!0;const t=encodeURI(e);i.push(`${t}`)})),t.forEach((e=>{const t=e.replace(/\.js$/,"");c[t]||(c[t]=!0,"app.js"!==e?s.push(`${encodeURI(t)}`):n=!0)}));const p=[...s,...a,...i];return n&&p.push("app"),{hasAppJS:n,allFiles:p,pageFiles:i,componentFiles:a,workerFiles:o,functionalPageFiles:r,otherFiles:s}}async getSubPkgSortedJSFiles(e){const t=await this.getConf(miniProgram),i=(await this.getPackageFiles(miniProgram,e)).map((e=>e.path)).filter((e=>e.endsWith(".js"))),s=[],a=[],o=[],r={},n=e=>Object.keys(t.packages).find((t=>e.startsWith(t)))||config_1.MainPkg;Object.keys(t.comps).filter((t=>n(t)===e)).forEach((e=>{if((e.startsWith("miniprogram_npm/weui-miniprogram")||e.startsWith("weui-miniprogram"))&&t.app.useExtendedLib&&t.app.useExtendedLib.weui)return;if(r[e])return;r[e]=!0;const i=encodeURI(e);o.push(`${i}`)}));Object.keys(t.pages).filter((t=>n(t)===e)).forEach((e=>{if(r[e])return;r[e]=!0;const t=encodeURI(e);s.push(`${t}`)}));let c=t.packages[e].entry||"";c&&(c=path_1.default.posix.join(e,c),c=c.replace(/\.js$/,"")),i.forEach((e=>{const t=e.replace(/\.js$/,"");r[t]||(r[t]=!0,t!==c&&a.push(`${encodeURI(t)}`))}));const l=i.map((e=>`${encodeURI(e.replace(/\.js$/,""))}`));return{entryJS:c,allFiles:l,pageFiles:s,componentFiles:o,otherFiles:a}}async compileJSList(e){const t=this.project.type;let i=config_1.COMPILE_TYPE.miniProgram;i=e.root===this.project.miniprogramRoot?this.isGameType(t)?config_1.COMPILE_TYPE.miniGame:config_1.COMPILE_TYPE.miniProgram:this.isGameType(t)?config_1.COMPILE_TYPE.miniGamePlugin:miniProgramPlugin;const s=await this.getCodeByFileList(i,e.fileList),a=[];for(const e in s){const t=s[e];if("error"in t)throw t.error;a.push(Object.assign({filePath:e,code:t.code,map:t.map,mtime:t.mtime},t.jsTag))}return a}async compileJS(e){const t=this.project.type;let i;if(e.root===this.project.miniprogramRoot){i=(await this.getCodeByFileList(this.isGameType(t)?config_1.COMPILE_TYPE.miniGame:config_1.COMPILE_TYPE.miniProgram,[e.filePath]))[e.filePath]}else{i=(await this.getCodeByFileList(this.isGameType(t)?config_1.COMPILE_TYPE.miniGamePlugin:miniProgramPlugin,[e.filePath]))[e.filePath]}if(!i){const t=new Error(`summer-compiler miss ${e.root} js file, ${e.filePath}`);throw t.code="ENOENT",t}if("error"in i)throw i.error;return Object.assign({filePath:e.filePath,code:i.code,map:i.map,mtime:i.mtime},i.jsTag)}async compile(e){Date.now();this.progressUpdateFromCompileOptions=e.onProgressUpdate;const t=(await this.getPackageFiles(this.isGameType(this.project.type)?miniGame:miniProgram,config_1.FullPkg,e.resultType,e.useCache)).map((e=>e.path)),i=await this.safeRunTask("compileNewLogic",Object.assign(Object.assign({},e),{fileList:t,analyzer:void 0}),this.onProgressUpdate),s=i.app,a=Object.keys(s).filter((e=>e.endsWith(".json"))),o=await this.compileOther(this.isGameType(this.project.type)?miniGame:miniProgram,e.resultType||"prod",a);let r={};if(this.isPluginType(this.project.type)){const t=i.plugin,a=Object.keys(t).filter((e=>e.endsWith(".json"))),n=await this.compileOther(this.isGameType(this.project.type)?miniGamePlugin:miniProgramPlugin,e.resultType||"prod",a);Object.keys(o).forEach((e=>{r[path_1.default.posix.join("miniprogram",e)]=o[e]})),Object.keys(n).forEach((e=>{r[path_1.default.posix.join("plugin",e)]=n[e]})),Object.keys(s).forEach((e=>{r[path_1.default.posix.join("miniprogram",e)]=s[e]})),Object.keys(t).forEach((e=>{r[path_1.default.posix.join("plugin",e)]=t[e]})),r["project.config.json"]=JSON.stringify({miniprogramRoot:"miniprogram",pluginRoot:"plugin",__compileDebugInfo__:{useSummer:!0}})}else r=Object.assign(Object.assign({},o),s),r["project.config.json"]=JSON.stringify({miniprogramRoot:"",__compileDebugInfo__:{useSummer:!0}});this.onProgressUpdate(111,"success",locales_1.default.config.SUMMER_PACK_FILES_FINISH.format());for(const e of Object.keys(r))"object"==typeof r[e]&&"Buffer"===r[e].type&&(r[e]=Buffer.from(r[e].data));return r}async compileOther(e,t,i){const s=(0,tools_1.getSupportCodeFileExtSet)(this.project);s.delete(".json");const a=await(0,white_ext_list_1.getWhiteExtList)();let o=a.MiniProgramWhiteList;this.isGameType(this.project.type)&&(o=a.GameWhiteList);const r=this.isPluginType(e)?this.project.pluginRoot:this.project.miniprogramRoot,n=await this.filterFactory(t),c=this.project.getFileList(r,"").filter((t=>{const a=path_1.default.posix.extname(t),c=path_1.default.posix.relative(r,t);return!(!o.has(a)||s.has(a)||i.includes(c))&&n(e,t)===config_1.EFilterCode.Include})),l=await(0,common_1.compileOther)(this.project,c,{onProgressUpdate:()=>{}}),p={};for(const e in l){p[path_1.default.posix.relative(r,e)]=l[e]}return p}async compile2(e){const t=await this.safeRunTask("compile",e,((t,i,s)=>{var a;null===(a=e.onProgressUpdate)||void 0===a||a.call(e,{id:t.toString(),status:i,message:s})}));for(const e of Object.keys(t))"object"==typeof t[e]&&"Buffer"===t[e].type&&(t[e]=Buffer.from(t[e].data));return t}async getPluginJSON(e=""){return(await this.getConf(this.isGameType(this.project.type)?miniGamePlugin:miniProgramPlugin)).plugin}async getPluginPageJSON(e){const t=await this.getConf(miniProgramPlugin),i=t.pages[e]||t.comps[e];if(!i)throw new Error(`summer-compiler 收集plugin json配置有遗漏, ${e}`);return i}async getPluginComponents(){const e=await this.getConf(miniProgramPlugin),t=new Set(Object.keys(e.pages).concat(Object.keys(e.comps)));return Array.from(t)}async getPluginJSFiles(){const e=this.isGameType(this.project.type)?miniGamePlugin:miniProgramPlugin,t=(await this.getPackageFiles(e,config_1.FullPkg)).map((e=>e.path)).filter((e=>e.endsWith(".js"))),i=await this.getCodeByFileList(e,t);return{jsFiles:t,content:t.reduce(((e,t)=>{const s=i[t];if(!s)throw`lack of ${t} code`;if("error"in s)throw s.error;return e[t]=s.code,e[`./${t}`]=s.code,e}),{})}}async getPluginWxssFiles(){const e=(await this.getPackageFiles(miniProgramPlugin,config_1.FullPkg)).map((e=>e.path)).filter((e=>e.endsWith(".wxss"))),t=await this.getCodeByFileList(miniProgramPlugin,e);return{wxssFiles:e,content:e.reduce(((e,i)=>{const s=t[i];if(!s)throw`lack of ${i} code`;if("error"in s)throw s.error;return e[i]=s.code,e[`./${i}`]=s.code,e}),{})}}async getPluginWxmlAndWxsFiles(){const e=(await this.getPackageFiles(miniProgramPlugin,config_1.FullPkg)).map((e=>e.path)),t=e.filter((e=>e.endsWith(".wxml"))),i=e.filter((e=>e.endsWith(".wxs"))),s=await this.getCodeByFileList(miniProgramPlugin,t.concat(i));return{wxmlFiles:t,wxsFiles:i,content:t.concat(i).reduce(((e,t)=>{const i=s[t];if(!i)throw`lack of ${t} code`;if("error"in i)throw i.error;return e[t]=i.code,e[`./${t}`]=i.code,e}),{})}}async checkThemeJSON(e){return(await this.getConf(miniProgram)).theme}setProxy(e){(0,request_1.setCiProxy)(e)}setLocale(e){this._locale!==e&&(this._locale=e,this.safeRunTask("setLocale",e))}async uglifyFileNames(e,t,i){return await(0,uglifyfilenames_1.uglifyFileNames)(e,t,i)}async getMPFileInfo(){return this.safeRunTask("getLocalFileList",miniProgram)}async getPluginFileInfo(){return this.safeRunTask("getLocalFileList",miniProgramPlugin)}async getCompAndPagesOfConf(){const e=await this.getConf(miniProgram);return{pages:e.pages,comps:e.comps}}async getFiltedFileListReason(e){const t=this.project.getFileList(this.project.miniprogramRoot),i=[],s=await this.filterFactory(e),a=this.isGameType(this.project.type)?miniGame:miniProgram;for(const e of t){const t=s(a,e);t!==config_1.EFilterCode.Include&&i.push({file:e,code:t})}if(this.isPluginType(this.project.type)){const e=this.project.getFileList(this.project.pluginRoot),t=this.isGameType(this.project.type)?miniGamePlugin:miniProgramPlugin;for(const a of e){const e=s(t,a);e!==config_1.EFilterCode.Include&&i.push({file:a,code:e})}}return i}async executePipe(e,t){return this.safeRunTask("executePipe",{pipeName:e,params:t},this.onProgressUpdate)}async getPageframe(e=!1,t){return this.safeRunTask("executePipe",Object.assign({pipeName:types_1.EPipeCMD.PAGEFRAME,params:{isMultiPkg:e}},t),this.onProgressUpdate)}async getAppservice(e){return this.safeRunTask("executePipe",Object.assign({pipeName:types_1.EPipeCMD.APPSERVICE,params:{}},e),this.onProgressUpdate)}}exports.SummerCompiler=SummerCompiler;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SummerCompiler=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=tslib_1.__importDefault(require("lodash")),locales_1=tslib_1.__importDefault(require("../../utils/locales/locales")),request_1=require("../../utils/request"),common_1=require("./original/compile/common"),tools_1=require("../../utils/tools"),white_ext_list_1=require("../../utils/white_ext_list"),config_1=require("../../config/config"),processManager_1=require("../../utils/subprocess/processManager"),messageHub_1=require("../../utils/messageHub"),singletontask_1=require("../../utils/singletontask"),uglifyfilenames_1=require("./original/protect/uglifyfilenames"),baseCompiler_1=require("./baseCompiler"),packOptionsHelper_1=tslib_1.__importDefault(require("../../utils/packOptionsHelper")),getservice_1=tslib_1.__importDefault(require("../../services/common/getservice")),appDirService_1=require("../../services/app/common/appDirService"),nativeModule_1=require("../../services/nativeModule/common/nativeModule"),miniProgram=config_1.COMPILE_TYPE.miniProgram,miniGame=config_1.COMPILE_TYPE.miniGame,miniProgramPlugin=config_1.COMPILE_TYPE.miniProgramPlugin,miniGamePlugin=config_1.COMPILE_TYPE.miniGamePlugin;function performanceMark(e,t){}class SummerCompiler extends baseCompiler_1.BaseCoreCompiler{constructor(e,t,i,s,a,o,r){super(e),this.project=e,this.cachePath=t,this.projectInfo=i,this.devtoolMessagehub=s,this.analyzer=a,this._filterFactory=o,this.onInitFinished=r,this.isSummer=!0,this.promiseCache=new Map,this._taskCache=new Map,this._status=void 0,this._eventAdded=!1,this._locale="",this._initServiceForkId=0,this.devCodeCacheByPath=new Map,this._initServiceAndLoadStatusPromise=null,this.onFileChange=(e,t)=>{if("change"!==e||t.endsWith(".json"))for(const e of this.promiseCache.keys())e.startsWith("getConf-")&&this.promiseCache.delete(e);if("change"!==e){for(const e of this.promiseCache.keys())e.startsWith("getPackageFiles-")&&this.promiseCache.delete(e);for(const e of this._taskCache.keys())e.startsWith("getPackageFiles-")&&this._taskCache.delete(e)}this.invalidCodeCache(t),this.subProcessManager.sendEvent("fileChange",{type:e,targetPath:t}),packOptionsHelper_1.default.clearUnusedFiles()},this.onPreCompileOptionsChange=async e=>{await this.clearCache(),this.subProcessManager.sendEvent("precompileOptionsChange",e)},this.onProgressUpdate=(e,t,i)=>{var s;this.messageHub.showBuildLog(`${e}`,t,i),null===(s=this.progressUpdateFromCompileOptions)||void 0===s||s.call(this,{id:e.toString(),message:i,status:t})},this._getPackageFiles=async(e,t,i="dev")=>{performanceMark("request get getPackageFiles");const s=await this.safeRunTask("getPackageFiles",{graphId:e,root:t},this.onProgressUpdate);performanceMark("request get getPackageFiles",!0);const a=this.isPluginType(e)?this.project.pluginRoot:this.project.miniprogramRoot,o=await this.filterFactory(i),r={},n=s.filter((t=>{const i=path_1.default.posix.join(a,t.source),s=o(e,i);return s!==config_1.EFilterCode.Include&&(r[s]||(r[s]=[]),r[s].push(i)),s===config_1.EFilterCode.Include})),c={[config_1.EFilterCode.AnalyseNoUse]:locales_1.default.config.UNUSE_FILE_LIST,[config_1.EFilterCode.PackOptionsIgnore]:locales_1.default.config.PACK_OPTIONS_IGNORE_LIST,[config_1.EFilterCode.PartialCompileNoUse]:locales_1.default.config.PARTIAL_COMPILE_IGNORE_LIST};for(const e in r)c[e]?this.onProgressUpdate(e,"warn",c[e].format(r[e].join(","))):this.onProgressUpdate(e,"warn",locales_1.default.config.UNKNOWN_REASON_INGORE_LIST.format(e,r[e].join(",")));return n},performanceMark("create summer compiler"),this.messageHub=new messageHub_1.MessageHub(s),this.ready(),global.dumpWorkerTaskStats=this.dumpWorkerTaskStats.bind(this),global.clearWorkerTaskStats=this.clearWorkerTaskStats.bind(this)}get status(){return this._status}async init(){performanceMark("init summer compiler");const e=path_1.default.posix.join(__dirname,"./summerEntryProcess.js"),t="undefined"!=typeof WEBIDE_WEBPECK_DEFINE_PLUGIN?"./summerentryprocess.js":e;this.subProcessManager=new processManager_1.SubProcessProxy(this.project,t,{cachePath:this.cachePath},this.projectInfo,8891,this.onProgressUpdate),this.addProjectListener();this.ensureInitService().then((()=>{var e;null===(e=this.onInitFinished)||void 0===e||e.call(this)}),(e=>{var t;null===(t=this.onInitFinished)||void 0===t||t.call(this,e)})),performanceMark("init summer compiler",!0)}async initServiceAndLoadStatus(){null===this._initServiceAndLoadStatusPromise?this._initServiceAndLoadStatusPromise=new Promise((async e=>{const t={};try{const e=await(0,getservice_1.default)(appDirService_1.IAppDirService).get("WeappCompileCache"),i=await(0,getservice_1.default)(nativeModule_1.INativeModuleService);t.NativeModule={WXMLParsePath:await i.getWXMLParsePath(),WXSSParsePath:await i.getWXSSParsePath(),GlassEaselLazyModulePath:await i.getGlassEaselTemplateCompilerPath()},t.AppDirService={WeappCompileCache:e}}catch(e){console.log("initServiceAndLoadStatus hasno WeappCompileCache / INativeModuleService in ci is normal")}this._status=await this.subProcessManager.runTask("initServiceAndloadStatus",t),e()})):await this._initServiceAndLoadStatusPromise}async ensureInitService(){await this.subProcessManager.ready(),this.subProcessManager.forkId!==this._initServiceForkId&&(this._initServiceAndLoadStatusPromise=null,await this.initServiceAndLoadStatus(),this._initServiceForkId=this.subProcessManager.forkId)}async safeRunTask(e,t,i){return await this.ensureInitService(),this.subProcessManager.runTask(e,t,i)}async loadStatus(){this._status=await this.safeRunTask("loadStatus")}destroy(){var e;null===(e=this.subProcessManager)||void 0===e||e.destroy(),this.removeProjectListener(),this._checkReadyTask=void 0}async clearCache(){await this.safeRunTask("clearCache"),this.promiseCache.clear(),this.devCodeCacheByPath.clear(),this._taskCache.clear()}async dumpWorkerTaskStats(){const e=await this.safeRunTask("getWorkerTaskStats"),t=new Map;for(const i of e){const e=`${i.workerId}_${i.taskName}`;let s=t.get(e);s||(s={workerId:i.workerId,taskName:i.taskName,count:0,total:0},t.set(e,s)),s.count++,s.total+=i.duration}const i=[...t.values()].sort(((e,t)=>String(e.workerId).localeCompare(String(t.workerId)))).map((e=>({Worker:e.workerId,Task:e.taskName,Count:e.count,"Total(ms)":e.total,"Avg(ms)":Math.round(e.total/e.count)})));console.table(i)}async clearWorkerTaskStats(){await this.safeRunTask("clearWorkerTaskStats")}getProjectInfo(){return this.projectInfo}updateOptions(e){lodash_1.default.isEqual(e,this.projectInfo)||this.updateOptionsWithoutJudge(e)}updateOptionsWithoutJudge(e){var t;this.projectInfo=e,this.promiseCache.clear(),this.devCodeCacheByPath.clear(),null===(t=this.subProcessManager)||void 0===t||t.sendEvent("updateOptions",e),this.loadStatus(),this.project.updateOptions(e)}updateOptionsWhenAttrNotChanged(e){var t;lodash_1.default.isEqual(Object.assign(Object.assign({},e),{attr:void 0}),Object.assign(Object.assign({},this.projectInfo),{attr:void 0}))||(this.projectInfo=e,this.promiseCache.clear(),this.devCodeCacheByPath.clear(),null===(t=this.subProcessManager)||void 0===t||t.sendEvent("updateOptions",e),this.loadStatus(),this.project.updateOptions(e))}addProjectListener(){var e,t;this._eventAdded&&this.removeProjectListener(),null===(e=this.project.event)||void 0===e||e.on("fileChange",this.onFileChange),null===(t=this.project.event)||void 0===t||t.on("precompileOptionsChange",this.onPreCompileOptionsChange),this._eventAdded=!0}removeProjectListener(){var e,t;null===(e=this.project.event)||void 0===e||e.off("fileChange",this.onFileChange),null===(t=this.project.event)||void 0===t||t.off("precompileOptionsChange",this.onPreCompileOptionsChange),this._eventAdded=!1}invalidCodeCache(e){const t=this.devCodeCacheByPath.get((0,tools_1.sourcePathToTargetPath)(e));t&&(t.isValid=!1)}async getConf(e){const t=`getConf-${e}`;if(this.promiseCache.has(t))return this.promiseCache.get(t);performanceMark("request get conf");const i={graphId:e},s=this.safeRunTask("getConf",i,this.onProgressUpdate);return this.promiseCache.set(t,s),performanceMark("request get conf",!0),s}async waitSubProcessReady(){await this.subProcessManager.ready()}async getPackageFiles(e,t,i="dev",s=!0){const a=`getPackageFiles-${e}-${t}-${i}`;if(this._taskCache.has(a)&&s){const e=this._taskCache.get(a);return null==e?void 0:e.getResult(!0)}const o=new singletontask_1.SingletonTask(this._getPackageFiles.bind(this,e,t,i),a);return this._taskCache.set(a,o),null==o?void 0:o.getResult(!0)}isMiniappPlatformInclude(e){const t=path_1.default.posix.join(this.project.miniprogramRoot,"app.miniapp.json");return(0,tools_1.isMiniappPlatform)(this.project.targetPlatform)&&t===e}async filterUnusedFiles(e,t,i){const s=e?"miniGame":"miniProgram";return(await this.filterFactory(i))(s,t)}async filterFactory(e){packOptionsHelper_1.default.updateState(this.project),await packOptionsHelper_1.default.initUnusedFiles(this.project,this.analyzer,"prod"===e,this.onProgressUpdate);const t=this._filterFactory?await this._filterFactory(e):()=>0;return(i,s)=>{const a=packOptionsHelper_1.default.relativePath(s);return this.isMiniappPlatformInclude(s)||packOptionsHelper_1.default.isFileIncluded(a)?config_1.EFilterCode.Include:packOptionsHelper_1.default.isIgnoredByRules(a)?config_1.EFilterCode.PackOptionsIgnore:i===miniProgram&&packOptionsHelper_1.default.isIgnoreByUnusedFiles(s,"prod"===e)?config_1.EFilterCode.AnalyseNoUse:t(i,s)}}async getCodeByFileList(e,t){const i={},s={},a=this.isPluginType(e)?this.project.pluginRoot:this.project.miniprogramRoot,o=[];for(const e of t){const t=this.devCodeCacheByPath.get(path_1.default.posix.join(a,e)),r=null==t?void 0:t.codeFile;let n=!1;t&&t.isValid&&r&&!("error"in r)||(n=!0,o.push(e)),r&&!("error"in r)&&(n&&(i[e]=r.md5),s[e]=r)}if(o.length>0){const t=await this.safeRunTask("getDevCodeByFileList",{graphId:e,fileList:o,cacheMd5:i},this.onProgressUpdate);for(const e in t){const i=t[e],o=path_1.default.posix.join(a,e);"error"in i||""!==i.md5?this.devCodeCacheByPath.set(o,{isValid:!0,codeFile:i}):this.devCodeCacheByPath.delete(o),s[e]=i}}return s}async getExtJSON(){return(await this.getConf(miniProgram)).ext}async getAppJSON(){return(await this.getConf(miniProgram)).app}async getGameJSON(){return(await this.getConf(miniGame)).app}async getSiteMapJSON(){return(await this.getConf(miniProgram)).sitemap}async getPageJSON(e){const t=await this.getConf(miniProgram),i=t.pages[e]||t.comps[e];if(!i)throw new Error(`summer-compiler 收集json配置有遗漏, ${e}`);return i}async getAllPageAndComponent(){const e=await this.getConf(miniProgram),t=(await this.getPackageFiles(miniProgram,config_1.FullPkg)).map((e=>e.path)).filter((e=>e.endsWith(".json")));return Object.keys(e.pages).concat(Object.keys(e.comps)).filter((e=>t.includes(`${e}.json`)))}async getAllSortedJSFiles(){var e,t,i,s;const a=this.isGameType(this.project.type),o=a?miniGame:miniProgram,r=await this.getConf(o),n=Object.keys(null!==(e=r.pages)&&void 0!==e?e:{}),c=Object.keys(null!==(t=r.comps)&&void 0!==t?t:{}),l=await this.getPackageFiles(o,config_1.FullPkg),p=null!==(i=null==l?void 0:l.map((e=>e.path)).filter((e=>e.endsWith(".js"))))&&void 0!==i?i:[],h=null!==(s=null==n?void 0:n.filter((e=>!c.includes(e))).map((e=>`${e}.js`)).filter((e=>p.includes(e))))&&void 0!==s?s:[],g=c.map((e=>`${e}.js`)).filter((e=>p.includes(e))),m=p.filter((e=>e.endsWith(".js")&&e!==(a?"game.js":"app.js")&&!h.includes(e)&&!g.includes(e)));return{jsPagesFiles:h,components:g,otherJsFiles:m}}async getAllWxmlAndWxsFiles(){const e=(await this.getPackageFiles(miniProgram,config_1.FullPkg)).map((e=>e.path)),t=e.filter((e=>e.endsWith(".wxml"))),i=e.filter((e=>e.endsWith(".wxs"))),s=await this.getCodeByFileList(miniProgram,t.concat(i));return{wxmlFiles:t,wxsFiles:i,content:t.concat(i).reduce(((e,t)=>{const i=s[t];if("error"in i)throw i.error;return e[t]=i.code,e[`./${t}`]=i.code,e}),{})}}async getPackageWxmlAndWxsFiles(e){let t=(await this.getPackageFiles(miniProgram,e)).map((e=>e.path));if(e!==config_1.MainPkg&&e!==config_1.FullPkg){const e=(await this.getPackageFiles(miniProgram,config_1.MainPkg)).map((e=>e.path));t=t.concat(e)}const i=t.filter((e=>e.endsWith(".wxml"))),s=t.filter((e=>e.endsWith(".wxs"))),a=await this.getCodeByFileList(miniProgram,i.concat(s));return{wxmlFiles:i,wxsFiles:s,content:i.concat(s).reduce(((e,t)=>{const i=a[t];if(!i)throw`lack of ${t} code`;if("error"in i)throw i.error;return e[t]=i.code,e[`./${t}`]=i.code,e}),{})}}async getPackageWxssFileList(e){let t=(await this.getPackageFiles(miniProgram,e)).map((e=>e.path));if(e!==config_1.MainPkg&&e!==config_1.FullPkg){const e=(await this.getPackageFiles(miniProgram,config_1.MainPkg)).map((e=>e.path));t=t.concat(e)}return t.filter((e=>e.endsWith(".wxss")))}async getPackageWxssFiles(e){const t=await this.getPackageWxssFileList(e),i=await this.getCodeByFileList(miniProgram,t);return{wxssFiles:t,content:t.reduce(((e,t)=>{const s=i[t];if(!s)throw`lack of ${t} code`;if("error"in s)throw s.error;return e[t]=s.code,e[`./${t}`]=s.code,e}),{})}}getWxssMap(e,t){t=(0,tools_1.normalizePath)(t),e===miniProgram?t=path_1.default.posix.join(this.project.miniprogramRoot,t):e===miniProgramPlugin&&(t=path_1.default.posix.join(this.project.pluginRoot,t));const i=this.devCodeCacheByPath.get(t),s=null==i?void 0:i.codeFile;if(s&&!("error"in s))return s.map}async getMainPkgSortedJSFiles(){const e=await this.getConf(miniProgram),t=(await this.getPackageFiles(miniProgram,config_1.MainPkg)).map((e=>e.path)).filter((e=>e.endsWith(".js"))),i=[],s=[],a=[],o=[],r=[];let n=!1;const c={},l=t=>Object.keys(e.packages).find((e=>t.startsWith(e)))||config_1.MainPkg;e.app.functionalPages&&t.forEach((e=>{if(e.startsWith("functional-pages/")){const t=e.replace(/\.js$/,"");if(c[t])return;c[t]=!0,r.push(encodeURI(t))}})),e.app.workers&&t.forEach((t=>{if(t.startsWith((0,tools_1.getWorkersPath)(e.app.workers))){const e=t.replace(/\.js$/,"");if(c[e])return;c[e]=!0,o.push(e)}}));Object.keys(e.comps).filter((e=>l(e)===config_1.MainPkg)).forEach((t=>{if((t.startsWith("miniprogram_npm/weui-miniprogram")||t.startsWith("weui-miniprogram"))&&e.app.useExtendedLib&&e.app.useExtendedLib.weui)return;if(c[t])return;c[t]=!0;const i=encodeURI(t);a.push(`${i}`)}));Object.keys(e.pages).filter((e=>l(e)===config_1.MainPkg)).forEach((e=>{if(c[e])return;c[e]=!0;const t=encodeURI(e);i.push(`${t}`)})),t.forEach((e=>{const t=e.replace(/\.js$/,"");c[t]||(c[t]=!0,"app.js"!==e?s.push(`${encodeURI(t)}`):n=!0)}));const p=[...s,...a,...i];return n&&p.push("app"),{hasAppJS:n,allFiles:p,pageFiles:i,componentFiles:a,workerFiles:o,functionalPageFiles:r,otherFiles:s}}async getSubPkgSortedJSFiles(e){const t=await this.getConf(miniProgram),i=(await this.getPackageFiles(miniProgram,e)).map((e=>e.path)).filter((e=>e.endsWith(".js"))),s=[],a=[],o=[],r={},n=e=>Object.keys(t.packages).find((t=>e.startsWith(t)))||config_1.MainPkg;Object.keys(t.comps).filter((t=>n(t)===e)).forEach((e=>{if((e.startsWith("miniprogram_npm/weui-miniprogram")||e.startsWith("weui-miniprogram"))&&t.app.useExtendedLib&&t.app.useExtendedLib.weui)return;if(r[e])return;r[e]=!0;const i=encodeURI(e);o.push(`${i}`)}));Object.keys(t.pages).filter((t=>n(t)===e)).forEach((e=>{if(r[e])return;r[e]=!0;const t=encodeURI(e);s.push(`${t}`)}));let c=t.packages[e].entry||"";c&&(c=path_1.default.posix.join(e,c),c=c.replace(/\.js$/,"")),i.forEach((e=>{const t=e.replace(/\.js$/,"");r[t]||(r[t]=!0,t!==c&&a.push(`${encodeURI(t)}`))}));const l=i.map((e=>`${encodeURI(e.replace(/\.js$/,""))}`));return{entryJS:c,allFiles:l,pageFiles:s,componentFiles:o,otherFiles:a}}async compileJSList(e){const t=this.project.type;let i=config_1.COMPILE_TYPE.miniProgram;i=e.root===this.project.miniprogramRoot?this.isGameType(t)?config_1.COMPILE_TYPE.miniGame:config_1.COMPILE_TYPE.miniProgram:this.isGameType(t)?config_1.COMPILE_TYPE.miniGamePlugin:miniProgramPlugin;const s=await this.getCodeByFileList(i,e.fileList),a=[];for(const e in s){const t=s[e];if("error"in t)throw t.error;a.push(Object.assign({filePath:e,code:t.code,map:t.map,mtime:t.mtime},t.jsTag))}return a}async compileJS(e){const t=this.project.type;let i;if(e.root===this.project.miniprogramRoot){i=(await this.getCodeByFileList(this.isGameType(t)?config_1.COMPILE_TYPE.miniGame:config_1.COMPILE_TYPE.miniProgram,[e.filePath]))[e.filePath]}else{i=(await this.getCodeByFileList(this.isGameType(t)?config_1.COMPILE_TYPE.miniGamePlugin:miniProgramPlugin,[e.filePath]))[e.filePath]}if(!i){const t=new Error(`summer-compiler miss ${e.root} js file, ${e.filePath}`);throw t.code="ENOENT",t}if("error"in i)throw i.error;return Object.assign({filePath:e.filePath,code:i.code,map:i.map,mtime:i.mtime},i.jsTag)}async compile(e){Date.now();this.progressUpdateFromCompileOptions=e.onProgressUpdate;const t=(await this.getPackageFiles(this.isGameType(this.project.type)?miniGame:miniProgram,config_1.FullPkg,e.resultType,e.useCache)).map((e=>e.path)),i=await this.safeRunTask("compileNewLogic",Object.assign(Object.assign({},e),{fileList:t,analyzer:void 0}),this.onProgressUpdate),s=i.app,a=Object.keys(s).filter((e=>e.endsWith(".json"))),o=await this.compileOther(this.isGameType(this.project.type)?miniGame:miniProgram,e.resultType||"prod",a);let r={};if(this.isPluginType(this.project.type)){const t=i.plugin,a=Object.keys(t).filter((e=>e.endsWith(".json"))),n=await this.compileOther(this.isGameType(this.project.type)?miniGamePlugin:miniProgramPlugin,e.resultType||"prod",a);Object.keys(o).forEach((e=>{r[path_1.default.posix.join("miniprogram",e)]=o[e]})),Object.keys(n).forEach((e=>{r[path_1.default.posix.join("plugin",e)]=n[e]})),Object.keys(s).forEach((e=>{r[path_1.default.posix.join("miniprogram",e)]=s[e]})),Object.keys(t).forEach((e=>{r[path_1.default.posix.join("plugin",e)]=t[e]})),r["project.config.json"]=JSON.stringify({miniprogramRoot:"miniprogram",pluginRoot:"plugin",__compileDebugInfo__:{useSummer:!0}})}else r=Object.assign(Object.assign({},o),s),r["project.config.json"]=JSON.stringify({miniprogramRoot:"",__compileDebugInfo__:{useSummer:!0}});this.onProgressUpdate(111,"success",locales_1.default.config.SUMMER_PACK_FILES_FINISH.format());for(const e of Object.keys(r))"object"==typeof r[e]&&"Buffer"===r[e].type&&(r[e]=Buffer.from(r[e].data));return r}async compileOther(e,t,i){const s=(0,tools_1.getSupportCodeFileExtSet)(this.project);s.delete(".json");const a=await(0,white_ext_list_1.getWhiteExtList)();let o=a.MiniProgramWhiteList;this.isGameType(this.project.type)&&(o=a.GameWhiteList);const r=this.isPluginType(e)?this.project.pluginRoot:this.project.miniprogramRoot,n=await this.filterFactory(t),c=this.project.getFileList(r,"").filter((t=>{const a=path_1.default.posix.extname(t),c=path_1.default.posix.relative(r,t);return!(!o.has(a)||s.has(a)||i.includes(c))&&n(e,t)===config_1.EFilterCode.Include})),l=await(0,common_1.compileOther)(this.project,c,{onProgressUpdate:()=>{}}),p={};for(const e in l){p[path_1.default.posix.relative(r,e)]=l[e]}return p}async compile2(e){const t=await this.safeRunTask("compile",e,((t,i,s)=>{var a;null===(a=e.onProgressUpdate)||void 0===a||a.call(e,{id:t.toString(),status:i,message:s})}));for(const e of Object.keys(t))"object"==typeof t[e]&&"Buffer"===t[e].type&&(t[e]=Buffer.from(t[e].data));return t}async getPluginJSON(e=""){return(await this.getConf(this.isGameType(this.project.type)?miniGamePlugin:miniProgramPlugin)).plugin}async getPluginPageJSON(e){const t=await this.getConf(miniProgramPlugin),i=t.pages[e]||t.comps[e];if(!i)throw new Error(`summer-compiler 收集plugin json配置有遗漏, ${e}`);return i}async getPluginComponents(){const e=await this.getConf(miniProgramPlugin),t=new Set(Object.keys(e.pages).concat(Object.keys(e.comps)));return Array.from(t)}async getPluginJSFiles(){const e=this.isGameType(this.project.type)?miniGamePlugin:miniProgramPlugin,t=(await this.getPackageFiles(e,config_1.FullPkg)).map((e=>e.path)).filter((e=>e.endsWith(".js"))),i=await this.getCodeByFileList(e,t);return{jsFiles:t,content:t.reduce(((e,t)=>{const s=i[t];if(!s)throw`lack of ${t} code`;if("error"in s)throw s.error;return e[t]=s.code,e[`./${t}`]=s.code,e}),{})}}async getPluginWxssFiles(){const e=(await this.getPackageFiles(miniProgramPlugin,config_1.FullPkg)).map((e=>e.path)).filter((e=>e.endsWith(".wxss"))),t=await this.getCodeByFileList(miniProgramPlugin,e);return{wxssFiles:e,content:e.reduce(((e,i)=>{const s=t[i];if(!s)throw`lack of ${i} code`;if("error"in s)throw s.error;return e[i]=s.code,e[`./${i}`]=s.code,e}),{})}}async getPluginWxmlAndWxsFiles(){const e=(await this.getPackageFiles(miniProgramPlugin,config_1.FullPkg)).map((e=>e.path)),t=e.filter((e=>e.endsWith(".wxml"))),i=e.filter((e=>e.endsWith(".wxs"))),s=await this.getCodeByFileList(miniProgramPlugin,t.concat(i));return{wxmlFiles:t,wxsFiles:i,content:t.concat(i).reduce(((e,t)=>{const i=s[t];if(!i)throw`lack of ${t} code`;if("error"in i)throw i.error;return e[t]=i.code,e[`./${t}`]=i.code,e}),{})}}async checkThemeJSON(e){return(await this.getConf(miniProgram)).theme}setProxy(e){(0,request_1.setCiProxy)(e)}setLocale(e){this._locale!==e&&(this._locale=e,this.safeRunTask("setLocale",e))}async uglifyFileNames(e,t,i){return await(0,uglifyfilenames_1.uglifyFileNames)(e,t,i)}async getMPFileInfo(){return this.safeRunTask("getLocalFileList",miniProgram)}async getPluginFileInfo(){return this.safeRunTask("getLocalFileList",miniProgramPlugin)}async getCompAndPagesOfConf(){const e=await this.getConf(miniProgram);return{pages:e.pages,comps:e.comps}}async getFiltedFileListReason(e){const t=this.project.getFileList(this.project.miniprogramRoot),i=[],s=await this.filterFactory(e),a=this.isGameType(this.project.type)?miniGame:miniProgram;for(const e of t){const t=s(a,e);t!==config_1.EFilterCode.Include&&i.push({file:e,code:t})}if(this.isPluginType(this.project.type)){const e=this.project.getFileList(this.project.pluginRoot),t=this.isGameType(this.project.type)?miniGamePlugin:miniProgramPlugin;for(const a of e){const e=s(t,a);e!==config_1.EFilterCode.Include&&i.push({file:a,code:e})}}return i}}exports.SummerCompiler=SummerCompiler;
@@ -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="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
+ "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"),asar_1=require("../../../utils/asar"),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,d,p,c,u,f,_,h,y,m;a.progress("update app base info...");const{mobileapp_info:g={}}=i,S=g.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===(d=null==n?void 0:n.infoPlist)||void 0===d?void 0:d.AudioInBackgroundMode)&&b.UIBackgroundModes.push("audio"),!0===(null===(p=null==n?void 0:n.infoPlist)||void 0===p?void 0:p.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(g),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===(m=n.infoPlist)||void 0===m?void 0:m.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 d,p,c,u,f,_,h;o.progress("update app module info...");const{module_info:y={},cpa_info:m={},cpa_package_info:g={enable_remove_watermark:!1}}=i;if(!m.sdk_key||!m.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);g.enable_remove_watermark?v.enableRemoveWatermark=!0:v.splashscreenTheme=r,v.miniModuleId=y.module_id,v.sdkKey=m.sdk_key,v.sdkSecret=m.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===(p=null===(d=null==l?void 0:l.base)||void 0===d?void 0:d.ios)||void 0===p?void 0:p[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:D}=n,U=this.useGDT(n);if(v.GDTAd=U?{appid:D.appid,enable:!0,SplashAd:{placementId:D.splashAd_placementId,fetchDelay:D.splashAd_fetchDelay||3,defaultEnable:null===(f=D.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:T=!1}=n;v.enableOpenUrlNavigate=T;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 d=s.ios_flag&&s.bundle_id||s.debug_ios_bundle_id;l.CFBundleIdentifier=t.tpush.serviceBundleId||`${d}.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 d=this.getMaterialFilePath(e,t[l]);if(!d)return void a.message("error",`getMatrialFailed: ${t[l]}`);const p=iconInfoMap[l];try{const e=sizeOf(d),i=p.size[0]*p.scale,n=p.size[1]*p.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(d),u=1===p.scale?"":`@${p.scale}x`,f=`${p.size[0]}x${p.size[1]}`,_=l.startsWith("ipad"),h="appStore1024"===l||"appStore1024Other"===l,y="appStore1024Other"===l?`${n}Other`:n,m=path_1.default.join(i,`${y}${f}${u}${_?"~ipad":""}${c}`),g={from:d,to:m,filename:path_1.default.basename(m),size:f,scale:`${p.scale}x`,idiom:p.idiom,key:l};s.push(g),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,d=(o||a)&&!!t;s.progress(`genAssetCar: ${d}`);const p=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 m=this.updateBundleIcons(e,i,y,c,s);if(!m)throw new Error("updateBundleIcons WithDefaultIcon failed");const{iphoneBundleIconFiles:g,ipadBundleIconFiles:S,addFiles:I}=m;if(f.push(...g),_.push(...S),h.push(...I),!f.length&&!_.length)return;p.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/`);d&&(this.resetAssetCarOperateDir(v),fs_extra_1.default.ensureDirSync(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),d&&(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}))})),d&&fs_extra_1.default.writeJsonSync(path_1.default.join(x,"Contents.json"),{images:b,info:{author:"xcode",version:1}},{spaces:"\t"}),d){const e=(0,asar_1.preferUnpackedPath)(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)}chmodDirectoryTree(e){if(!fs_extra_1.default.existsSync(e))return;fs_extra_1.default.lstatSync(e).isDirectory()&&(fs_extra_1.default.chmodSync(e,493),fs_extra_1.default.readdirSync(e).forEach((i=>{this.chmodDirectoryTree(path_1.default.join(e,i))})))}resetAssetCarOperateDir(e){fs_extra_1.default.existsSync(e)&&(this.chmodDirectoryTree(e),fs_extra_1.default.removeSync(e))}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),d=`${t}.png`,p=`LaunchScreen-${uuidv4().slice(0,12)}`,c=`${p}.png`,u=path_1.default.join(s,c);fs_extra_1.default.copyFileSync(l,u);const f=Buffer.from(d,"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")),p}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 d;n.progress("update splashscreen image..."),allowTheme.includes(a)&&(d=path_1.default.join(i,`/Base.lproj/LaunchScreen${a}.storyboardc`)),d&&fs_extra_1.default.existsSync(d)&&fs_extra_1.default.copySync(d,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 p=null===(o=null==t?void 0:t.splashscreen)||void 0===o?void 0:o.customImage;if(!p)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)})),p.startsWith("%")&&(null==p?void 0:p.endsWith("%"))){const t=p.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},请检查,启动页国际化配置失败`);p=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,p),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 d=path_1.default.join(i,"Info.plist"),p=plist.readFileSync(d);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&&(p.UISplashScreenVideoName=c,plist.writeFileSync(d,p))}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"),d=fs_extra_1.default.readFileSync(l,"utf-8"),p=this.genUseExtendedSdk(a,s);o.progress(`useExtendedSdks: ${JSON.stringify(p)}`);const{mobileapp_info:c={}}=e,u=this.getBundleIdentifier(c);if(p.WeAppOpenFuns&&p.WeAppOpenFuns_HasPay)throw new Error("OpenFuncs SDK 只可勾选使用一个,请按需勾选使用");const f={},_=["WeAppUSB"];for(const e in p){if(!p[e])continue;const i=getDepReg(e),a=d.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={},d={},p=[];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&&(d[e.pluginId]=e.resourceObjects)):p.push(e.pluginId)}))}if(p.length>0&&r.message("warn",`下列插件未启用,请确认project.miniapp.json中的配置:${p.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 p=path_1.default.join(a,s);if(fs_extra_1.default.existsSync(p)){fs_extra_1.default.copySync(p,o),this.copyResourcesToMainBundle(p,e),this.copyUserResourcePathIntoPlugins(n,t,l[n],d[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],p=path_1.default.join(u,i);if(!o||!0!==o.enable)return;r.progress(`${n} 插件使用 appex 中 : ${i}`),fs_extra_1.default.existsSync(p)&&fs_extra_1.default.removeSync(p),fs_extra_1.default.ensureDirSync(p);const c=path_1.default.join(a,i);fs_extra_1.default.copySync(c,p),(null==o?void 0:o.profilePath)&&fs_extra_1.default.copySync(o.profilePath,path_1.default.join(p,"embedded.mobileprovision")),this.copyResourcesToMainBundle(c,e),this.copyUserResourcePathIntoPlugins(n,t,l[n],d[n],path_1.default.join(p,"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],d[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 d={};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}`;d[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)?(d[s].bundleID=n.bundleID,d[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=d[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)(d)){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 d)i[e]={bundleID:d[e].bundleID,profilePath:d[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(d).map((e=>{const i=d[e];return`pluginAppexName:${e};_;_;bundleID:${i.bundleID};_;_;profile:${i.profilePath}\n\n`})).join("");fs_extra_1.default.writeFileSync(t,a)}return d}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:d,pluginDirList:p,inLandun:c,theme:u,i18nInfo:f,debugInfo:_,CILocalBuild:h,cacheAssetCarPath:y}=e,m=this.generateTempDemoIpaPath(n),{selfCertificate:g={}}=r,S=(null==g?void 0:g.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,m,I,i,f);await this.updateIOSAppConfigPlistInfo(t,x,m,I,a,!1,i,u,f),await this.updateIOSAppexInfoPlistInfo(x,m,I,b,i),await this.updateIOSIcons(t,m,d,I,S,i,!0===c,y),await this.updateSplashScreen(t,m,I,i,u,f),await this.updateSplashScreenVideo(t,m,I,i,f),await this.updateExtendedSdk(x,m,a,s,I,_,i),await this.updatePlugin(m,p,t,I,d,S,b,i),await this.updatePrivacyInfo(m,I,i),await this.updateIOSAppResource(t,m,I,i);const F=await this.getEntitlements(x,m,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:g.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=g.profilePath,B.certificate=g.certificateName),g.isPublish||h){const e=await(0,codesign_1.codesignAndExport)(t,m,d||"",B,i,v,!0===c);if(!0!==e.success)throw new Error(`Build ipa failed:${e.errMsg||"codesignAndExport failed"}`)}return{projectPath:t,demoIpaPath:m,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;