miniprogram-ci 2.1.32 → 2.1.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (355) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +2 -0
  3. package/dist/@types/ci/cloud/utils.d.ts +1 -1
  4. package/dist/@types/common/code-analyse/index.d.ts +16 -1
  5. package/dist/@types/config/config.d.ts +1 -1
  6. package/dist/@types/index.d.ts +2 -0
  7. package/dist/@types/modules/corecompiler/original/compile/game.d.ts +1 -1
  8. package/dist/@types/modules/corecompiler/original/compile/index.d.ts +1 -1
  9. package/dist/@types/modules/corecompiler/original/index.d.ts +1 -1
  10. package/dist/@types/modules/corecompiler/original/workerThread/childprocessManager.d.ts +1 -1
  11. package/dist/@types/modules/corecompiler/original/workerThread/config.d.ts +3 -0
  12. package/dist/@types/modules/corecompiler/original/workerThread/task/compilejs.d.ts +3 -0
  13. package/dist/@types/modules/corecompiler/original/workerThread/task/func.d.ts +4 -0
  14. package/dist/@types/modules/corecompiler/original/workerThread/workerManager.d.ts +8 -0
  15. package/dist/@types/modules/corecompiler/originalCompiler.d.ts +1 -1
  16. package/dist/@types/modules/corecompiler/summer/pipeManager/index.d.ts +6 -0
  17. package/dist/@types/modules/corecompiler/summer/pipeManager/pipeCPProject.d.ts +17 -0
  18. package/dist/@types/modules/corecompiler/summer/pipeManager/pipeContext.d.ts +10 -0
  19. package/dist/@types/modules/corecompiler/summer/pipeManager/pipeManager.d.ts +12 -0
  20. package/dist/@types/modules/corecompiler/summer/pipeManager/pipeWorker.d.ts +2 -0
  21. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/appservicePipe/index.d.ts +3 -0
  22. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/compileWxmlToGlassEaselPipe.d.ts +3 -0
  23. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/compileWxssPipe.d.ts +3 -0
  24. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/index.d.ts +2 -0
  25. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/pageInitSourcePipe/index.d.ts +4 -0
  26. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/pageframePipe/index.d.ts +3 -0
  27. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/appdevserver/getAppService.d.ts +6 -0
  28. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/appdevserver/getwxappcode.d.ts +9 -0
  29. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/appservice/getjsfile.d.ts +12 -0
  30. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/appservice/getmainpkgsortedjsfiles.d.ts +11 -0
  31. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/appservice/getwxappcode.d.ts +8 -0
  32. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/common/apperrcode.config.d.ts +92 -0
  33. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/common/tools.d.ts +1 -0
  34. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/project/appconfig.d.ts +6 -0
  35. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/project/appjson.d.ts +3 -0
  36. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/project/customcomponent.d.ts +21 -0
  37. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/project/helper/theme.d.ts +40 -0
  38. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/project/pagejson.d.ts +3 -0
  39. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/project/wxappcodejson.d.ts +3 -0
  40. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/trans/transwxmltojs.d.ts +19 -0
  41. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/trans/transwxsstojs.d.ts +15 -0
  42. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/web/processPath.d.ts +9 -0
  43. package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/wccPipe.d.ts +3 -0
  44. package/dist/@types/modules/corecompiler/summer/pipeManager/types.d.ts +100 -0
  45. package/dist/@types/modules/corecompiler/summer/plugins/script_task/minify_script_task.d.ts +1 -1
  46. package/dist/@types/modules/corecompiler/summerCompiler.d.ts +10 -0
  47. package/dist/@types/modules/index.d.ts +1 -1
  48. package/dist/@types/modules/precompiler/conditioncompile/compiler/plant.d.ts +1 -1
  49. package/dist/@types/modules/precompiler/conditioncompile/index.d.ts +1 -1
  50. package/dist/@types/project/advance/precompileProject.d.ts +1 -1
  51. package/dist/@types/project/baseProject.d.ts +1 -0
  52. package/dist/@types/services/app/ci/appDirService.d.ts +6 -0
  53. package/dist/@types/services/common/getservice.d.ts +6 -3
  54. package/dist/@types/services/compilewxml/common/compilewxmlService.d.ts +2 -2
  55. package/dist/@types/services/compilewxml/node/compileglasseasel.d.ts +14 -0
  56. package/dist/@types/services/multiTaskManager/ci/multiTaskManager.d.ts +5 -0
  57. package/dist/@types/services/multiTaskManager/common/multiTaskManager.d.ts +5 -0
  58. package/dist/@types/services/multiTaskManager/electron/multiTaskManager.d.ts +5 -0
  59. package/dist/@types/services/multiTaskManager/webide/multiTaskManager.d.ts +5 -0
  60. package/dist/@types/services/nativeModule/ci/nativeModule.d.ts +3 -0
  61. package/dist/@types/services/nativeModule/common/nativeModule.d.ts +2 -2
  62. package/dist/@types/services/nativeModule/common/nativeModule.impl.d.ts +3 -2
  63. package/dist/@types/services/pluginFileReader/ci/pluginFileReader.d.ts +3 -0
  64. package/dist/@types/services/pluginFileReader/common/pluginFileReader.base.d.ts +9 -0
  65. package/dist/@types/services/pluginFileReader/common/pluginFileReader.d.ts +12 -0
  66. package/dist/@types/services/pluginFileReader/electron/pluginFileReader.d.ts +3 -0
  67. package/dist/@types/services/pluginFileReader/webide/pluginFileReader.d.ts +9 -0
  68. package/dist/@types/services/root/ci/rootService.d.ts +2 -0
  69. package/dist/@types/services/root/webide/root.d.ts +11 -0
  70. package/dist/@types/services/root/webide/rootService.d.ts +2 -0
  71. package/dist/@types/utils/colorutils.d.ts +4 -0
  72. package/dist/@types/utils/debug.d.ts +1 -0
  73. package/dist/@types/utils/error.d.ts +1 -1
  74. package/dist/@types/utils/fsagent.d.ts +4 -3
  75. package/dist/@types/utils/processBootstrap.d.ts +7 -0
  76. package/dist/@types/utils/subprocess/processManager.d.ts +1 -0
  77. package/dist/@types/utils/wxapkg/pack.d.ts +2 -2
  78. package/dist/ci/android-miniapp-toolkit/dist/index.js +1 -1
  79. package/dist/ci/build-apk.js +1 -1
  80. package/dist/ci/build-ipa.js +1 -1
  81. package/dist/ci/checkCodeQuality.js +1 -1
  82. package/dist/ci/cloud/cloudapi.js +1 -1
  83. package/dist/ci/cloud/createTimeTrigger.js +1 -1
  84. package/dist/ci/cloud/uploadContainer.js +1 -1
  85. package/dist/ci/cloud/uploadFile.js +1 -1
  86. package/dist/ci/cloud/uploadFunction.js +1 -1
  87. package/dist/ci/cloud/utils.js +1 -1
  88. package/dist/ci/code-analyse.js +1 -1
  89. package/dist/ci/cos-upload.js +1 -1
  90. package/dist/ci/gamepkg/apkplug.js +1 -1
  91. package/dist/ci/gamepkg/index.js +1 -1
  92. package/dist/ci/getCompiledResult.js +1 -1
  93. package/dist/ci/getDevSourceMap.js +1 -1
  94. package/dist/ci/getcompiler.js +1 -1
  95. package/dist/ci/miniapp/androidCloudBuild.js +1 -1
  96. package/dist/ci/miniapp/archive.js +1 -1
  97. package/dist/ci/miniapp/iosCloudBuild.js +1 -1
  98. package/dist/ci/miniapp/miniappPlugin.js +1 -1
  99. package/dist/ci/miniapp/sdkManager.js +1 -1
  100. package/dist/ci/miniapp/upload.js +1 -1
  101. package/dist/ci/miniapp-cloud-upload.js +1 -1
  102. package/dist/ci/preview.js +1 -1
  103. package/dist/ci/upload.js +1 -1
  104. package/dist/ci/utils/codeDenpendencyQualityChecker.js +1 -1
  105. package/dist/ci/utils/filterUnusedFile.js +1 -1
  106. package/dist/ci/utils/pack.js +1 -1
  107. package/dist/ci/utils/packfile.js +1 -1
  108. package/dist/ci/utils/terminalQrcode.js +1 -1
  109. package/dist/ci/utils/tools.js +1 -1
  110. package/dist/ci/utils/unpack.js +1 -1
  111. package/dist/ci/utils/wxvpkg/unpack/version0.js +1 -1
  112. package/dist/ci/utils/wxvpkg/unpack/version10.js +1 -1
  113. package/dist/cli/index.js +1 -1
  114. package/dist/common/code-analyse/index.js +1 -1
  115. package/dist/config/config.js +1 -1
  116. package/dist/config/url.config.js +1 -1
  117. package/dist/index.js +1 -1
  118. package/dist/modules/corecompiler/baseCompiler.js +1 -1
  119. package/dist/modules/corecompiler/original/analyse/partial.js +1 -1
  120. package/dist/modules/corecompiler/original/compile/common.js +1 -1
  121. package/dist/modules/corecompiler/original/compile/game.js +1 -1
  122. package/dist/modules/corecompiler/original/compile/gamePlugin.js +1 -1
  123. package/dist/modules/corecompiler/original/compile/handler/js.js +1 -1
  124. package/dist/modules/corecompiler/original/compile/handler/mpjson.js +1 -1
  125. package/dist/modules/corecompiler/original/compile/handler/wxml.js +1 -1
  126. package/dist/modules/corecompiler/original/compile/handler/wxss.js +1 -1
  127. package/dist/modules/corecompiler/original/compile/miniprogram.js +1 -1
  128. package/dist/modules/corecompiler/original/compile/miniprogramPlugin.js +1 -1
  129. package/dist/modules/corecompiler/original/js/enhance.js +1 -1
  130. package/dist/modules/corecompiler/original/js/es6Transform.js +1 -1
  131. package/dist/modules/corecompiler/original/js/generateMap.js +1 -1
  132. package/dist/modules/corecompiler/original/js/minifyjs.js +1 -1
  133. package/dist/modules/corecompiler/original/js/minifyjsAfterWrap.js +1 -1
  134. package/dist/modules/corecompiler/original/js/workletCompile.js +1 -1
  135. package/dist/modules/corecompiler/original/json/app/appJSON.js +1 -1
  136. package/dist/modules/corecompiler/original/json/app/checkAppFields.js +1 -1
  137. package/dist/modules/corecompiler/original/json/app/extJSON.js +1 -1
  138. package/dist/modules/corecompiler/original/json/app/index.js +1 -1
  139. package/dist/modules/corecompiler/original/json/common.js +1 -1
  140. package/dist/modules/corecompiler/original/json/game.js +1 -1
  141. package/dist/modules/corecompiler/original/json/page/checkPageJSON.js +1 -1
  142. package/dist/modules/corecompiler/original/json/page/getPageJSON.js +1 -1
  143. package/dist/modules/corecompiler/original/json/plugin/plugin.js +1 -1
  144. package/dist/modules/corecompiler/original/json/plugin/pluginPage.js +1 -1
  145. package/dist/modules/corecompiler/original/json/projectconfig.js +1 -1
  146. package/dist/modules/corecompiler/original/json/reactiveCache.js +1 -1
  147. package/dist/modules/corecompiler/original/json/signaturejson.js +1 -1
  148. package/dist/modules/corecompiler/original/json/sitemap.js +1 -1
  149. package/dist/modules/corecompiler/original/json/theme.js +1 -1
  150. package/dist/modules/corecompiler/original/npm/filterdeps.js +1 -1
  151. package/dist/modules/corecompiler/original/npm/packnpm.js +1 -1
  152. package/dist/modules/corecompiler/original/protect/fileFlatter.js +1 -1
  153. package/dist/modules/corecompiler/original/protect/uglifyfilenames.js +1 -1
  154. package/dist/modules/corecompiler/original/utils/logger.js +1 -1
  155. package/dist/modules/corecompiler/original/validate/schemaValidate.js +1 -1
  156. package/dist/modules/corecompiler/original/validate/validate.js +1 -1
  157. package/dist/modules/corecompiler/original/workerThread/childprocess.js +1 -1
  158. package/dist/modules/corecompiler/original/workerThread/childprocessManager.js +1 -1
  159. package/dist/modules/corecompiler/original/workerThread/config.js +1 -1
  160. package/dist/modules/corecompiler/original/workerThread/fork.js +1 -1
  161. package/dist/modules/corecompiler/original/workerThread/index.js +1 -1
  162. package/dist/modules/corecompiler/original/workerThread/task/call_func.js +1 -1
  163. package/dist/modules/corecompiler/original/workerThread/task/compilejs.js +1 -1
  164. package/dist/modules/corecompiler/original/workerThread/task/compilewxss.js +1 -1
  165. package/dist/modules/corecompiler/original/workerThread/task/func.js +1 -1
  166. package/dist/modules/corecompiler/original/workerThread/task/index.js +1 -1
  167. package/dist/modules/corecompiler/original/workerThread/task/minifywxml.js +1 -1
  168. package/dist/modules/corecompiler/original/workerThread/worker.js +1 -1
  169. package/dist/modules/corecompiler/original/workerThread/workerManager.js +1 -1
  170. package/dist/modules/corecompiler/originalCompiler.js +1 -1
  171. package/dist/modules/corecompiler/processHandler.js +1 -1
  172. package/dist/modules/corecompiler/summer/graph/appconf.js +1 -1
  173. package/dist/modules/corecompiler/summer/graph/appgraph.js +1 -1
  174. package/dist/modules/corecompiler/summer/graph/basegraph.js +1 -1
  175. package/dist/modules/corecompiler/summer/graph/gameconf.js +1 -1
  176. package/dist/modules/corecompiler/summer/graph/gamegraph.js +1 -1
  177. package/dist/modules/corecompiler/summer/graph/gamepluginconf.js +1 -1
  178. package/dist/modules/corecompiler/summer/graph/gameplugingraph.js +1 -1
  179. package/dist/modules/corecompiler/summer/graph/pluginconf.js +1 -1
  180. package/dist/modules/corecompiler/summer/graph/plugingraph.js +1 -1
  181. package/dist/modules/corecompiler/summer/index.js +1 -1
  182. package/dist/modules/corecompiler/summer/initPlugin.js +1 -1
  183. package/dist/modules/corecompiler/summer/module.js +1 -1
  184. package/dist/modules/corecompiler/summer/persistCache.js +1 -1
  185. package/dist/modules/corecompiler/summer/pipeManager/index.js +1 -0
  186. package/dist/modules/corecompiler/summer/pipeManager/pipeCPProject.js +1 -0
  187. package/dist/modules/corecompiler/summer/pipeManager/pipeContext.js +1 -0
  188. package/dist/modules/corecompiler/summer/pipeManager/pipeManager.js +1 -0
  189. package/dist/modules/corecompiler/summer/pipeManager/pipeWorker.js +1 -0
  190. package/dist/modules/corecompiler/summer/pipeManager/pipes/appservicePipe/index.js +1 -0
  191. package/dist/modules/corecompiler/summer/pipeManager/pipes/compileWxmlToGlassEaselPipe.js +1 -0
  192. package/dist/modules/corecompiler/summer/pipeManager/pipes/compileWxssPipe.js +1 -0
  193. package/dist/modules/corecompiler/summer/pipeManager/pipes/index.js +1 -0
  194. package/dist/modules/corecompiler/summer/pipeManager/pipes/pageInitSourcePipe/index.js +1 -0
  195. package/dist/modules/corecompiler/summer/pipeManager/pipes/pageframePipe/index.js +1 -0
  196. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/appdevserver/getAppService.js +1 -0
  197. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/appdevserver/getwxappcode.js +1 -0
  198. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/appservice/getjsfile.js +1 -0
  199. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/appservice/getmainpkgsortedjsfiles.js +1 -0
  200. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/appservice/getwxappcode.js +1 -0
  201. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/common/apperrcode.config.js +1 -0
  202. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/common/tools.js +1 -0
  203. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/project/appconfig.js +1 -0
  204. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/project/appjson.js +1 -0
  205. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/project/customcomponent.js +1 -0
  206. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/project/helper/theme.js +1 -0
  207. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/project/pagejson.js +1 -0
  208. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/project/wxappcodejson.js +1 -0
  209. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/trans/transwxmltojs.js +1 -0
  210. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/trans/transwxsstojs.js +1 -0
  211. package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/web/processPath.js +1 -0
  212. package/dist/modules/corecompiler/summer/pipeManager/pipes/wccPipe.js +1 -0
  213. package/dist/modules/corecompiler/summer/pipeManager/types.js +1 -0
  214. package/dist/modules/corecompiler/summer/pluginDriver.js +1 -1
  215. package/dist/modules/corecompiler/summer/pluginconfig.js +1 -1
  216. package/dist/modules/corecompiler/summer/plugins/base/es6module.js +1 -1
  217. package/dist/modules/corecompiler/summer/plugins/base/javascript.js +1 -1
  218. package/dist/modules/corecompiler/summer/plugins/base/swc.js +1 -1
  219. package/dist/modules/corecompiler/summer/plugins/base/wxss.js +1 -1
  220. package/dist/modules/corecompiler/summer/plugins/enhance.js +1 -1
  221. package/dist/modules/corecompiler/summer/plugins/filetask/script.js +1 -1
  222. package/dist/modules/corecompiler/summer/plugins/less.js +1 -1
  223. package/dist/modules/corecompiler/summer/plugins/minifywxml.js +1 -1
  224. package/dist/modules/corecompiler/summer/plugins/sass.js +1 -1
  225. package/dist/modules/corecompiler/summer/plugins/script_task/babel_script_task.js +1 -1
  226. package/dist/modules/corecompiler/summer/plugins/script_task/load_script_task.js +1 -1
  227. package/dist/modules/corecompiler/summer/plugins/script_task/minify_script_task.js +1 -1
  228. package/dist/modules/corecompiler/summer/plugins/script_task/swc_task.js +1 -1
  229. package/dist/modules/corecompiler/summer/plugins/terser.js +1 -1
  230. package/dist/modules/corecompiler/summer/plugins/typescript.js +1 -1
  231. package/dist/modules/corecompiler/summer/plugins/worklet.js +1 -1
  232. package/dist/modules/corecompiler/summer/resolver.js +1 -1
  233. package/dist/modules/corecompiler/summer/summer.js +1 -1
  234. package/dist/modules/corecompiler/summer/utils/async.js +1 -1
  235. package/dist/modules/corecompiler/summer/utils/inputsourcemap.js +1 -1
  236. package/dist/modules/corecompiler/summerCompiler.js +1 -1
  237. package/dist/modules/corecompiler/summerEntryProcess.js +1 -1
  238. package/dist/modules/createSummer.js +1 -1
  239. package/dist/modules/fullcompiler/app/app.js +1 -1
  240. package/dist/modules/fullcompiler/app/contactandlaunch/updateContactForSubpkg.js +1 -1
  241. package/dist/modules/fullcompiler/app/contactandlaunch/updatecontactandlaunch.js +1 -1
  242. package/dist/modules/index.js +1 -1
  243. package/dist/modules/nativecompiler/android/adb.js +1 -1
  244. package/dist/modules/nativecompiler/android/device.js +1 -1
  245. package/dist/modules/nativecompiler/android/index.js +1 -1
  246. package/dist/modules/nativecompiler/android/projectconfig.js +1 -1
  247. package/dist/modules/nativecompiler/index.js +1 -1
  248. package/dist/modules/nativecompiler/ios/buildCloud.js +1 -1
  249. package/dist/modules/nativecompiler/ios/device.js +1 -1
  250. package/dist/modules/nativecompiler/ios/index.js +1 -1
  251. package/dist/modules/nativecompiler/nativeEntryProcess.js +1 -1
  252. package/dist/modules/nativecompiler/processHandler.js +1 -1
  253. package/dist/modules/precompiler/conditioncompile/compiler/json.js +1 -1
  254. package/dist/modules/precompiler/conditioncompile/compiler/macro.js +1 -1
  255. package/dist/modules/precompiler/conditioncompile/index.js +1 -1
  256. package/dist/project/advance/precompileProject.js +1 -1
  257. package/dist/project/advance/reactiveProject.js +1 -1
  258. package/dist/project/baseProject.js +1 -1
  259. package/dist/project/ciProjectWithMockBuffer.js +1 -1
  260. package/dist/project/summerCPProject.js +1 -1
  261. package/dist/services/app/ci/appDirService.js +1 -0
  262. package/dist/services/common/getservice.js +1 -1
  263. package/dist/services/common/vsbase.js +1 -1
  264. package/dist/services/compilewxml/node/compileUtils.js +1 -1
  265. package/dist/services/compilewxml/node/compileglasseasel.js +1 -1
  266. package/dist/services/compilewxml/webide/pageFrameWasm/wcc/runWcc.js +1 -1
  267. package/dist/services/compilewxss/node/compileUtils.js +1 -1
  268. package/dist/services/compilewxss/webide/pageFrameWasm/wcsc/runWcsc.js +1 -1
  269. package/dist/services/multiTaskManager/ci/multiTaskManager.js +1 -0
  270. package/dist/services/multiTaskManager/common/multiTaskManager.js +1 -0
  271. package/dist/services/multiTaskManager/electron/multiTaskManager.js +1 -0
  272. package/dist/services/multiTaskManager/webide/multiTaskManager.js +1 -0
  273. package/dist/services/nativeModule/ci/nativeModule.js +1 -0
  274. package/dist/services/nativeModule/common/nativeModule.impl.js +1 -1
  275. package/dist/services/pluginFileReader/ci/pluginFileReader.js +1 -0
  276. package/dist/services/pluginFileReader/common/pluginFileReader.base.js +1 -0
  277. package/dist/services/pluginFileReader/common/pluginFileReader.js +1 -0
  278. package/dist/services/pluginFileReader/electron/pluginFileReader.js +1 -0
  279. package/dist/services/pluginFileReader/webide/pluginFileReader.js +1 -0
  280. package/dist/services/root/{node → ci}/root.js +1 -1
  281. package/dist/services/root/ci/rootService.js +1 -0
  282. package/dist/services/root/electron/root.js +1 -1
  283. package/dist/services/root/electron/rootService.js +1 -1
  284. package/dist/services/root/nw/root.js +1 -1
  285. package/dist/services/root/webide/root.js +1 -0
  286. package/dist/services/root/webide/rootService.js +1 -0
  287. package/dist/utils/asyncTask/index.js +1 -1
  288. package/dist/utils/babel_helper.js +1 -1
  289. package/dist/utils/babel_plugin_worklet.js +1 -1
  290. package/dist/utils/colorutils.js +1 -0
  291. package/dist/utils/common.js +1 -1
  292. package/dist/utils/cosUpload.js +1 -1
  293. package/dist/utils/cp.js +1 -1
  294. package/dist/utils/customError.js +1 -1
  295. package/dist/utils/debug.js +1 -1
  296. package/dist/utils/download.js +1 -1
  297. package/dist/utils/expression.js +1 -1
  298. package/dist/utils/fsagent.js +1 -1
  299. package/dist/utils/genTempFile.js +1 -1
  300. package/dist/utils/generateIpa.js +1 -1
  301. package/dist/utils/glob.js +1 -1
  302. package/dist/utils/hackrequire/wxvpkgreader.js +1 -1
  303. package/dist/utils/helper_util.js +1 -1
  304. package/dist/utils/jsonlint.js +1 -1
  305. package/dist/utils/locales/fomatable_string.js +1 -1
  306. package/dist/utils/locales/locales.js +1 -1
  307. package/dist/utils/log.js +1 -1
  308. package/dist/utils/messageHub.js +1 -1
  309. package/dist/utils/miniAppI18N.js +1 -1
  310. package/dist/utils/miniapp-builder.js +1 -1
  311. package/dist/utils/miniappJson.js +1 -1
  312. package/dist/utils/officialDonutPlugin.js +1 -1
  313. package/dist/utils/packOptionsHelper.js +1 -1
  314. package/dist/utils/processBootstrap.js +1 -0
  315. package/dist/utils/progressRecorder.js +1 -1
  316. package/dist/utils/request.js +1 -1
  317. package/dist/utils/singletontask.js +1 -1
  318. package/dist/utils/subprocess/entryProcess.js +1 -1
  319. package/dist/utils/subprocess/processManager.js +1 -1
  320. package/dist/utils/subprocess/processService.js +1 -1
  321. package/dist/utils/swc_helper.js +1 -1
  322. package/dist/utils/taskmanager.js +1 -1
  323. package/dist/utils/tools.js +1 -1
  324. package/dist/utils/usbProcess.js +1 -1
  325. package/dist/utils/waitable.js +1 -1
  326. package/dist/utils/web/common.js +1 -1
  327. package/dist/utils/white_ext_list.js +1 -1
  328. package/dist/utils/wxapkg/pack.js +1 -1
  329. package/dist/utils/wxvpkgreader/wxvpkg/reader/version0.js +1 -1
  330. package/dist/utils/wxvpkgreader/wxvpkg/reader/version10.js +1 -1
  331. package/dist/utils/wxvpkgreader/wxvpkg/unpack/version0.js +1 -1
  332. package/dist/utils/wxvpkgreader/wxvpkg/unpack/version10.js +1 -1
  333. package/dist/utils/wxvpkgreader/wxvpkgreader.js +1 -1
  334. package/dist/utils/zip.js +1 -1
  335. package/package.json +62 -3
  336. package/dist/@types/services/root/node/rootService.d.ts +0 -0
  337. package/dist/modules/fullcompiler/trans/wcc/build/darwin_arm64/wcc.node +0 -0
  338. package/dist/modules/fullcompiler/trans/wcc/build/darwin_arm64/wcsc.node +0 -0
  339. package/dist/modules/fullcompiler/trans/wcc/build/darwin_x64/wcc.node +0 -0
  340. package/dist/modules/fullcompiler/trans/wcc/build/darwin_x64/wcsc.node +0 -0
  341. package/dist/modules/fullcompiler/trans/wcc/build/node_16.1.0_darwin_arm64_release/wcc.node +0 -0
  342. package/dist/modules/fullcompiler/trans/wcc/build/node_16.1.0_darwin_arm64_release/wcsc.node +0 -0
  343. package/dist/modules/fullcompiler/trans/wcc/build/node_16.1.0_darwin_x64_release/wcc.node +0 -0
  344. package/dist/modules/fullcompiler/trans/wcc/build/node_16.1.0_darwin_x64_release/wcsc.node +0 -0
  345. package/dist/modules/fullcompiler/trans/wcc/build/win32_ia32/wcc.node +0 -0
  346. package/dist/modules/fullcompiler/trans/wcc/build/win32_ia32/wcsc.node +0 -0
  347. package/dist/modules/fullcompiler/trans/wcc/build/win32_x64/wcc.node +0 -0
  348. package/dist/modules/fullcompiler/trans/wcc/build/win32_x64/wcsc.node +0 -0
  349. package/dist/modules/fullcompiler/trans/wcc/lib/addonVersion.js +0 -19
  350. package/dist/modules/fullcompiler/trans/wcc/lib/index.js +0 -4
  351. package/dist/modules/fullcompiler/trans/wcc/lib/util.js +0 -1134
  352. package/dist/modules/fullcompiler/trans/wcc/lib/wcc.js +0 -94
  353. package/dist/modules/fullcompiler/trans/wcc/lib/wcsc.js +0 -93
  354. package/dist/services/root/node/rootService.js +0 -1
  355. /package/dist/@types/services/root/{node → ci}/root.d.ts +0 -0
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),log=tslib_1.__importStar(require("../../../../utils/log")),index_1=tslib_1.__importDefault(require("./task/index")),config_1=require("./config"),getProcess_1=require("../../../../utils/subprocess/getProcess"),process=(0,getProcess_1.getProcess)();let isbusy=!1;process.on("message",s=>{const{command:e,data:r}=s;e===config_1.COMMAND.RUN_TASK&&(isbusy=!0,(0,index_1.default)(r.taskName,r.data).then(s=>{isbusy=!1,process.send({command:config_1.COMMAND.TASK_DONE,data:s})}).catch(s=>{isbusy=!1,process.send({command:config_1.COMMAND.TASK_DONE,data:{error:s.toString()}})}))}),process.on("SIGTERM",()=>{isbusy&&(log.error("forked sub process is kill when busy"),process.exit(1)),process.exit(0)});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib");require("../../../../utils/processBootstrap").installProcessBootstrap({baseDir:__dirname,moduleFallbackPath:"../../../../../../../unpack/module-fallback"});const log=tslib_1.__importStar(require("../../../../utils/log")),index_1=tslib_1.__importDefault(require("./task/index")),config_1=require("./config"),getProcess_1=require("../../../../utils/subprocess/getProcess"),getservice_1=require("../../../../services/common/getservice"),process=(0,getProcess_1.getProcess)();let isbusy=!1;process.on("message",(e=>{const{command:s,data:r}=e;if(s===config_1.COMMAND.INIT_START){const e=(0,getservice_1.getServicesEnv)();return(0,getservice_1.initServices)(e,r),void process.send({command:config_1.COMMAND.INIT_READY})}s===config_1.COMMAND.RUN_TASK&&(isbusy=!0,(0,index_1.default)(r.taskName,r.data).then((e=>{isbusy=!1,process.send({command:config_1.COMMAND.TASK_DONE,data:e})})).catch((e=>{isbusy=!1,process.send({command:config_1.COMMAND.TASK_DONE,data:{error:e.toString()}})})))})),process.on("SIGTERM",(()=>{isbusy&&(log.error("forked sub process is kill when busy"),process.exit(1)),process.exit(0)}));
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.runTask=runTask,exports.abortTask=abortTask;const tslib_1=require("tslib"),logger_1=require("../utils/logger"),workerManager_1=require("./workerManager"),childprocessManager_1=require("./childprocessManager"),index_1=tslib_1.__importDefault(require("./task/index")),env_1=require("../../../../utils/env");tslib_1.__exportStar(require("./config"),exports);const isDevtools=void 0!==(null===process||void 0===process?void 0:process.env.__nwjs);async function runTask(r,e,o=(()=>{})){var s,a;if(logger_1.logger.info("runTask",r,e.filePath),global.__MINIPROGRAM_CI_TEST__||"true"===(null===(s=null===process||void 0===process?void 0:process.env)||void 0===s?void 0:s.__MINIPROGRAM_CI_TEST__))return(0,index_1.default)(r,e);try{if((null===process||void 0===process?void 0:process.__nwjs)&&"wechatwebdevtools"===nw.App.manifest.appname||(null===(a=null===process||void 0===process?void 0:process.versions)||void 0===a?void 0:a.electron))return await childprocessManager_1.childProcessManager.runTask(r,e,o);const s=(0,workerManager_1.getWorkerManager)(isDevtools);return await s.runTask(r,e,o)}catch(o){if(env_1.isWebIDE)throw o;if(o===workerManager_1.AbortEvent)throw o;if(logger_1.logger.error(`runTask ${r}, ${e.filePath} catch error ${o}`),o instanceof childprocessManager_1.ChildProcessCrashedError)throw new Error(`runTask ${r}, ${e.filePath} catch error ${o}`);return(0,index_1.default)(r,e)}}function abortTask(r){(0,workerManager_1.getWorkerManager)(isDevtools).abort(r)}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.runTask=runTask,exports.abortTask=abortTask;const tslib_1=require("tslib"),logger_1=require("../utils/logger"),workerManager_1=require("./workerManager"),index_1=tslib_1.__importDefault(require("./task/index")),getservice_1=tslib_1.__importDefault(require("../../../../services/common/getservice")),multiTaskManager_1=require("../../../../services/multiTaskManager/common/multiTaskManager");tslib_1.__exportStar(require("./config"),exports);const isDevtools=void 0!==(null===process||void 0===process?void 0:process.env.__nwjs);async function runTask(e,r,a=(()=>{})){if(logger_1.logger.info("runTask",e,r.filePath),global.__MINIPROGRAM_CI_TEST__)return(0,index_1.default)(e,r);try{return await(0,getservice_1.default)(multiTaskManager_1.IMultiTaskManagerService).runTask(e,r,a)}catch(a){throw logger_1.logger.error(`runTask ${e}, ${r.filePath} catch error ${a}`),a}}function abortTask(e){(0,workerManager_1.getWorkerManager)(isDevtools).abort(e)}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.call=call;const tslib_1=require("tslib"),config_1=require("../config"),FUNC=tslib_1.__importStar(require("./func"));let workerThreads,supportWorkerThread=!1;try{workerThreads=require("worker_threads"),supportWorkerThread=!0}catch(r){supportWorkerThread=!1}const callMainThread=function(){if(!supportWorkerThread||workerThreads.isMainThread)return(r,e)=>{};let r=0;const e={};return workerThreads.parentPort.on("message",r=>{const{command:o,data:t}=r;if(o!==config_1.COMMAND.CALL_FUNC_RESULT)return;const{id:a,result:s,error:n}=t,i=e[a];return delete e[a],i?n?i.reject(n):void i.resolve(s):void 0}),(o,t)=>new Promise((a,s)=>{const n=r++;e[n]={resolve:a,reject:s},workerThreads.parentPort.postMessage({command:config_1.COMMAND.CALL_FUNC,data:{id:n,funcName:o,args:t}})})}();function call(r,...e){return!supportWorkerThread||workerThreads.isMainThread?FUNC[r].apply(null,e):callMainThread(r,e)}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.call=call;const tslib_1=require("tslib"),config_1=require("../config"),FUNC=tslib_1.__importStar(require("./func"));let workerThreads,supportWorkerThread=!1;try{workerThreads=require("worker_threads"),supportWorkerThread=!0}catch(r){supportWorkerThread=!1}const callMainThread=function(){if(!supportWorkerThread||workerThreads.isMainThread)return(r,e)=>{};let r=0;const e={};return workerThreads.parentPort.on("message",(r=>{const{command:o,data:t}=r;if(o!==config_1.COMMAND.CALL_FUNC_RESULT)return;const{id:a,result:s,error:n}=t,i=e[a];return delete e[a],i?n?i.reject(n):void i.resolve(s):void 0})),(o,t)=>new Promise(((a,s)=>{const n=r++;e[n]={resolve:a,reject:s},workerThreads.parentPort.postMessage({command:config_1.COMMAND.CALL_FUNC,data:{id:n,funcName:o,args:t}})}))}();function call(r,...e){return!supportWorkerThread||workerThreads.isMainThread?FUNC[r].apply(null,e):callMainThread(r,e)}
@@ -1 +1 @@
1
- "use strict";const tslib_1=require("tslib"),fs_1=tslib_1.__importDefault(require("fs")),path_1=tslib_1.__importDefault(require("path")),locales_1=tslib_1.__importDefault(require("../../../../../utils/locales/locales")),tools_1=require("../../../../../utils/tools"),config_1=require("../../../../../config/config"),log=tslib_1.__importStar(require("../../../../../utils/log")),babel_helper_1=require("../../../../../utils/babel_helper"),jsonParse_1=require("../../../../../utils/jsonParse"),call_func_1=require("./call_func"),sourcemap=()=>require("source-map"),enhanceCompile=()=>require("../../js/enhance"),workletCompile=()=>require("../../js/workletCompile"),es6Compile=()=>require("../../js/es6Transform"),minifyJS=()=>require("../../js/minifyjs"),minifyJSAfterWrap=()=>require("../../js/minifyjsAfterWrap");async function tryGetInputSourceMap(e,r){try{const t=/\/\/[#|@] sourceMappingURL=[\s]*(\S*)[\s]*$/m.exec(e),s=path_1.default.posix.dirname(r),o=path_1.default.posix.basename(r);let i;if(null==t?void 0:t[1])if(t[1].endsWith(".js.map"))i=await(0,call_func_1.call)("readFileAsync",path_1.default.posix.join(s,t[1]),"utf-8");else{const e=t[1].split("base64,")[1];i=Buffer.from(e,"base64").toString()}else{const e=path_1.default.posix.join(s,o+".map");fs_1.default.existsSync(e)&&(i=await(0,call_func_1.call)("readFileAsync",e,"utf-8"))}if(i){const e=(0,jsonParse_1.jsonParse)(i);new(require("source-map").SourceMapConsumer)(e);return await insertSourcesContent(e,r),e}}catch(e){log.log(`try to get input sourcemap of ${r} catch error ${e}`)}}const insertSourcesContent=async(e,r)=>{if(Array.isArray(e.sources)&&!Array.isArray(e.sourcesContent)){const t=e.sourcesContent;try{const t=path_1.default.posix.dirname(r),s=[],{sources:o}=e;for(const e of o){const r=await(0,call_func_1.call)("readFileAsync",path_1.default.posix.join(t,e),"utf-8");s.push(r)}e.sourcesContent=s}catch(r){e.sourcesContent=t}}};async function compileJS(e){const{code:r,filePath:t,projectPath:s,setting:o,babelRoot:i="@babel/runtime",root:a="",babelIgnore:n=[]}=e,{enhance:c,es6:l,disableUseStrict:u,compileWorklet:p}=o,f="string"==typeof r?r:(0,tools_1.bufferToUtf8String)(Buffer.from(r)),_=path_1.default.posix.join(a,t),m=o.minified;if(void 0===f)return{error:{code:config_1.FILE_NOT_UTF8,path:_,message:locales_1.default.config.FILE_NOT_UTF8.format(_)}};const b=f.length>=config_1.MAX_CODE_LENGTH;let h=!1;c&&(h=(0,babel_helper_1.isIgnore)(n,t));const d=await tryGetInputSourceMap(f,path_1.default.posix.join(s,a,t));if(b||h)return{error:null,isLargeFile:b,isBabelIgnore:h,map:"object"==typeof d?JSON.stringify(d):d,code:f,helpers:[]};let g=f,j=d,y=[];if(c){const e=await require("../../js/enhance")({code:f,babelRoot:i,filePath:t,disableUseStrict:u,inputSourceMap:d});if(e.error)return{error:Object.assign(Object.assign({},e.error),{path:_})};g=e.code||"",j=e.map,y=e.helpers||[]}else if(l){const e=require("../../js/es6Transform")({code:f,filePath:t,inputSourceMap:d});if(e.error)return{error:Object.assign(Object.assign({},e.error),{path:_})};g=e.code||"",j=e.map}else if(p){if(f.includes('"worklet"')||f.includes("'worklet'")){const e=await require("../../js/workletCompile")({code:f,babelRoot:i,filePath:t,disableUseStrict:u,inputSourceMap:d});if(e.error)return{error:Object.assign(Object.assign({},e.error),{path:_})};g=e.code||"",j=e.map,y=e.helpers||[]}}if(m){if(!l&&!c){const e=require("../../js/minifyjsAfterWrap")({filePath:t,code:g,inputSourceMap:j});if(e.error)return{error:Object.assign(Object.assign({},e.error),{path:_})};g=e.code,j=e.map}else{const e=require("../../js/minifyjs")({filePath:t,code:g,useTerser:!!c,inputSourceMap:j});if(e.error)return{error:Object.assign(Object.assign({},e.error),{path:_})};g=e.code,j=e.map}}if("string"!=typeof j)try{(null==j?void 0:j.sourcesContent)&&(j.sourcesContent=j.sourcesContent.map(e=>e.replace(/\r\n/g,"\n"))),j=JSON.stringify(j)}catch(e){j=""}else j=j.replace(/\\r\\n/g,"\\n");return{error:null,isLargeFile:b,isBabelIgnore:h,map:j,code:g.replace(/\r\n/g,"\n"),helpers:y||[]}}module.exports=compileJS;
1
+ "use strict";const tslib_1=require("tslib"),fs_1=tslib_1.__importDefault(require("fs")),path_1=tslib_1.__importDefault(require("path")),locales_1=tslib_1.__importDefault(require("../../../../../utils/locales/locales")),tools_1=require("../../../../../utils/tools"),config_1=require("../../../../../config/config"),log=tslib_1.__importStar(require("../../../../../utils/log")),babel_helper_1=require("../../../../../utils/babel_helper"),jsonParse_1=require("../../../../../utils/jsonParse"),call_func_1=require("./call_func"),sourcemap=()=>require("source-map"),enhanceCompile=()=>require("../../js/enhance"),workletCompile=()=>require("../../js/workletCompile"),es6Compile=()=>require("../../js/es6Transform"),minifyJS=()=>require("../../js/minifyjs"),minifyJSAfterWrap=()=>require("../../js/minifyjsAfterWrap");async function tryGetInputSourceMap(e,r){try{const t=/\/\/[#|@] sourceMappingURL=[\s]*(\S*)[\s]*$/m.exec(e),o=path_1.default.posix.dirname(r),s=path_1.default.posix.basename(r);let i;if(null==t?void 0:t[1])if(t[1].endsWith(".js.map"))i=await(0,call_func_1.call)("readFileAsync",path_1.default.posix.join(o,t[1]),"utf-8");else{const e=t[1].split("base64,")[1];i=Buffer.from(e,"base64").toString()}else{const e=path_1.default.posix.join(o,`${s}.map`);fs_1.default.existsSync(e)&&(i=await(0,call_func_1.call)("readFileAsync",e,"utf-8"))}if(i){const e=(0,jsonParse_1.jsonParse)(i);new(sourcemap().SourceMapConsumer)(e);return await insertSourcesContent(e,r),e}}catch(e){log.log(`try to get input sourcemap of ${r} catch error ${e}`)}}const insertSourcesContent=async(e,r)=>{if(Array.isArray(e.sources)&&!Array.isArray(e.sourcesContent)){const t=e.sourcesContent;try{const t=path_1.default.posix.dirname(r),o=[],{sources:s}=e;for(const e of s){const r=await(0,call_func_1.call)("readFileAsync",path_1.default.posix.join(t,e),"utf-8");o.push(r)}e.sourcesContent=o}catch(r){e.sourcesContent=t}}};async function compileJS(e){const{code:r,filePath:t,projectPath:o,setting:s,babelRoot:i="@babel/runtime",root:a="",babelIgnore:n=[]}=e,{enhance:l,es6:c,disableUseStrict:u,compileWorklet:p}=s,f="string"==typeof r?r:(0,tools_1.bufferToUtf8String)(Buffer.from(r)),_=path_1.default.posix.join(a,t),m=s.minified;if(void 0===f)return{error:{code:config_1.FILE_NOT_UTF8,path:_,message:locales_1.default.config.FILE_NOT_UTF8.format(_)}};const b=f.length>=config_1.MAX_CODE_LENGTH;let h=!1;l&&(h=(0,babel_helper_1.isIgnore)(n,t));const d=await tryGetInputSourceMap(f,path_1.default.posix.join(o,a,t));if(b||h)return{error:null,isLargeFile:b,isBabelIgnore:h,map:"object"==typeof d?JSON.stringify(d):d,code:f,helpers:[]};let g=f,j=d,y=[];if(l){const e=await enhanceCompile()({code:f,babelRoot:i,filePath:t,disableUseStrict:u,inputSourceMap:d});if(e.error)return{error:Object.assign(Object.assign({},e.error),{path:_})};g=e.code||"",j=e.map,y=e.helpers||[]}else if(c){const e=es6Compile()({code:f,filePath:t,inputSourceMap:d});if(e.error)return{error:Object.assign(Object.assign({},e.error),{path:_})};g=e.code||"",j=e.map}else if(p){if(f.includes('"worklet"')||f.includes("'worklet'")){const e=await workletCompile()({code:f,babelRoot:i,filePath:t,disableUseStrict:u,inputSourceMap:d});if(e.error)return{error:Object.assign(Object.assign({},e.error),{path:_})};g=e.code||"",j=e.map,y=e.helpers||[]}}if(m){if(!c&&!l){const e=minifyJSAfterWrap()({filePath:t,code:g,inputSourceMap:j});if("error"in e)return{error:Object.assign(Object.assign({},e.error),{path:_})};g=e.code,j=e.map}else{const e=minifyJS()({filePath:t,code:g,useTerser:!!l,inputSourceMap:j});if("error"in e)return{error:Object.assign(Object.assign({},e.error),{path:_})};g=e.code,j=e.map}}if("string"!=typeof j)try{(null==j?void 0:j.sourcesContent)&&(j.sourcesContent=j.sourcesContent.map((e=>e.replace(/\r\n/g,"\n")))),j=JSON.stringify(j)}catch(e){j=""}else j=j.replace(/\\r\\n/g,"\\n");return{error:null,isLargeFile:b,isBabelIgnore:h,map:j,code:g.replace(/\r\n/g,"\n"),helpers:y||[]}}module.exports=compileJS;
@@ -1 +1 @@
1
- "use strict";const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),postcss_1=tslib_1.__importDefault(require("postcss")),autoprefixer_1=tslib_1.__importDefault(require("autoprefixer")),cssnano_1=tslib_1.__importDefault(require("cssnano")),locales_1=tslib_1.__importDefault(require("../../../../../utils/locales/locales")),tools_1=require("../../../../../utils/tools"),config_1=require("../../../../../config/config"),log=tslib_1.__importStar(require("../../../../../utils/log")),wxssBrowser=["iOS >= 8","Chrome >= 37"];async function compileWXSS(e){const{code:r,filePath:o,setting:s={},root:t=""}=e,i=Buffer.from(r),l=(0,tools_1.bufferToUtf8String)(i),{minifyWXSS:c,postcss:a}=s,u=path_1.default.posix.join(t,o),_=c;if(void 0===l)return{error:{code:config_1.FILE_NOT_UTF8,path:u,message:locales_1.default.config.FILE_NOT_UTF8.format(u)}};if(_||a)try{const e=[];a&&e.push((0,autoprefixer_1.default)({overrideBrowserslist:wxssBrowser,remove:!1})),_&&e.push((0,cssnano_1.default)({preset:["default",{reduceTransforms:!1,calc:!1,minifySelectors:!1,normalizeUrl:!1,reduceInitial:!1}]}));return{error:null,code:(await(0,postcss_1.default)(e).process(l,{from:(0,tools_1.leading)(o,"/")})).css.replace(/\r\n/g,"\n")}}catch(e){return log.error("postcss error @ "+u),log.error(e),{error:{code:config_1.POST_WXSS_ERR,path:u,message:e.message}}}return{error:null,code:l.replace(/\r\n/g,"\n")}}process.env.BROWSERSLIST=process.env.BROWSERSLIST||"iOS >= 8, Chrome >= 37",module.exports=compileWXSS;
1
+ "use strict";const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),postcss_1=tslib_1.__importDefault(require("postcss")),autoprefixer_1=tslib_1.__importDefault(require("autoprefixer")),cssnano_1=tslib_1.__importDefault(require("cssnano")),locales_1=tslib_1.__importDefault(require("../../../../../utils/locales/locales")),tools_1=require("../../../../../utils/tools"),config_1=require("../../../../../config/config"),log=tslib_1.__importStar(require("../../../../../utils/log")),wxssBrowser=["iOS >= 8","Chrome >= 37"];async function compileWXSS(e){const{code:r,filePath:o,setting:s={},root:t=""}=e,i=Buffer.from(r),l=(0,tools_1.bufferToUtf8String)(i),{minifyWXSS:c,postcss:a}=s,u=path_1.default.posix.join(t,o),_=c;if(void 0===l)return{error:{code:config_1.FILE_NOT_UTF8,path:u,message:locales_1.default.config.FILE_NOT_UTF8.format(u)}};if(_||a)try{const e=[];a&&e.push((0,autoprefixer_1.default)({overrideBrowserslist:wxssBrowser,remove:!1})),_&&e.push((0,cssnano_1.default)({preset:["default",{reduceTransforms:!1,calc:!1,minifySelectors:!1,normalizeUrl:!1,reduceInitial:!1}]}));return{error:null,code:(await(0,postcss_1.default)(e).process(l,{from:(0,tools_1.leading)(o,"/")})).css.replace(/\r\n/g,"\n")}}catch(e){return log.error(`postcss error @ ${u}`),log.error(e),{error:{code:config_1.POST_WXSS_ERR,path:u,message:e.message}}}return{error:null,code:l.replace(/\r\n/g,"\n")}}process.env.BROWSERSLIST=process.env.BROWSERSLIST||"iOS >= 8, Chrome >= 37",module.exports=compileWXSS;
@@ -1 +1 @@
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
+ "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 +1 @@
1
- "use strict";const config_1=require("../config"),compileJS=()=>require("./compilejs"),compileWXSS=()=>require("./compilewxss"),summerWorker=()=>require("../../../summer/worker");async function processTask(e,r){return e===config_1.TASK_NAME.COMPILE_JS?require("./compilejs")(r):e===config_1.TASK_NAME.COMPILE_WXSS?require("./compilewxss")(r):e===config_1.TASK_NAME.SUMMER_HOOK?require("../../../summer/worker").runSummerPluginHook(r):void 0}module.exports=processTask;
1
+ "use strict";const config_1=require("../config"),compileJS=()=>require("./compilejs"),compileWXSS=()=>require("./compilewxss"),summerWorker=()=>require("../../../summer/worker"),pipeWorker=()=>require("../../../summer/pipeManager/pipeWorker");async function processTask(e,r){return e===config_1.TASK_NAME.COMPILE_JS?compileJS()(r):e===config_1.TASK_NAME.COMPILE_WXSS?compileWXSS()(r):e===config_1.TASK_NAME.SUMMER_HOOK?summerWorker().runSummerPluginHook(r):e===config_1.TASK_NAME.PIPE_TASK?pipeWorker().runPipeTask(r):void 0}module.exports=processTask;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.StyleAttrValueTokenizer=exports.TemplateTokenizer=void 0,exports.minifyWXML=minifyWXML;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),log=tslib_1.__importStar(require("../../../../../utils/log")),config_1=require("../../../../../config/config");function getCharCode(T){return T.charCodeAt(0)>=256?BASE_STATE.OTHERS:T.charCodeAt(0)}function trimStringLeft(T,E=!0){return E?T.trimLeft():T.split("\n").map(T=>T.replace(/^[ \t]*/g,"")).join("\n")}function trimStringRight(T,E=!0){return E?T.trimRight():T.split("\n").map(T=>T.replace(/[ \t]*$/,"")).join("\n")}var TokenType,BASE_STATE,STATE,TEMPLATE_STATE,STYLE_ATTR_VALUE_STATE,ACTION;!function(T){T[T.ATTR=0]="ATTR",T[T.TAG=1]="TAG",T[T.LEFT_ANGLE_BRACKET=2]="LEFT_ANGLE_BRACKET",T[T.RIGHT_ANGLE_BRACKET=3]="RIGHT_ANGLE_BRACKET",T[T.END_LEFT_ANGLE_BRACKET=4]="END_LEFT_ANGLE_BRACKET",T[T.STRING1=5]="STRING1",T[T.STRING2=6]="STRING2",T[T.ATTR_VALUE=7]="ATTR_VALUE",T[T.TEXT_VALUE=8]="TEXT_VALUE",T[T.TAG_TEXT_VALUE=9]="TAG_TEXT_VALUE",T[T.TEMPLATE_START=10]="TEMPLATE_START",T[T.TEMPLATE_END=11]="TEMPLATE_END",T[T.TEMPLATE_ITEM=12]="TEMPLATE_ITEM",T[T.TEMPLATE_STRING=13]="TEMPLATE_STRING",T[T.SELF_CLOSE=14]="SELF_CLOSE",T[T.WXS_VALUE=15]="WXS_VALUE",T[T.STYLE_KEY=16]="STYLE_KEY",T[T.TAG_EQ=17]="TAG_EQ",T[T.STYLE_VALUE=18]="STYLE_VALUE",T[T.STYLE_ATTR_VALUE=19]="STYLE_ATTR_VALUE",T[T.CLASS_ATTR_VALUE=20]="CLASS_ATTR_VALUE",T[T.OTHERS=21]="OTHERS"}(TokenType||(TokenType={})),function(T){T[T.ERROR=-1]="ERROR",T[T.NOT_SET=0]="NOT_SET",T[T.START=1]="START",T[T.OTHERS=2]="OTHERS",T[T.END=3]="END",T[T.MAX_STATE=4]="MAX_STATE"}(BASE_STATE||(BASE_STATE={})),function(T){T[T.IN_TAG_TEXT=5]="IN_TAG_TEXT",T[T.TAG_START=6]="TAG_START",T[T.IN_TAG_WORD=7]="IN_TAG_WORD",T[T.TAG_EQ=8]="TAG_EQ",T[T.IN_TAG_ATTR_WORD=9]="IN_TAG_ATTR_WORD",T[T.IN_TAG_ATTR_VALUE_STRING=10]="IN_TAG_ATTR_VALUE_STRING",T[T.IN_TAG_ATTR_VALUE_STRING_ESCAPE=11]="IN_TAG_ATTR_VALUE_STRING_ESCAPE",T[T.IN_TAG_ATTR_VALUE_STRING_SINGLE=12]="IN_TAG_ATTR_VALUE_STRING_SINGLE",T[T.IN_TAG_ATTR_VALUE_STRING_SINGLE_ESCAPE=13]="IN_TAG_ATTR_VALUE_STRING_SINGLE_ESCAPE",T[T.WAIT_TEMPLATE_START=14]="WAIT_TEMPLATE_START",T[T.IN_TEMPLATE=15]="IN_TEMPLATE",T[T.WAIT_TEMPLATE_END=16]="WAIT_TEMPLATE_END",T[T.TEMPLATE_END_CHECK=17]="TEMPLATE_END_CHECK",T[T.IN_TEMPLATE_STRING=18]="IN_TEMPLATE_STRING",T[T.IN_TEMPLATE_STRING_ESCAPE=19]="IN_TEMPLATE_STRING_ESCAPE",T[T.IN_TEMPLATE_STRING2=20]="IN_TEMPLATE_STRING2",T[T.IN_TEMPLATE_STRING2_ESCAPE=21]="IN_TEMPLATE_STRING2_ESCAPE",T[T.WAIT_FOR_RIGHT_BRACKET=22]="WAIT_FOR_RIGHT_BRACKET",T[T.IN_WXS=23]="IN_WXS",T[T.IN_WXS_STRING=24]="IN_WXS_STRING",T[T.IN_WXS_STRING_ESCAPE=25]="IN_WXS_STRING_ESCAPE",T[T.IN_WXS_STRING_SINGLE=26]="IN_WXS_STRING_SINGLE",T[T.IN_WXS_STRING_SINGLE_ESCAPE=27]="IN_WXS_STRING_SINGLE_ESCAPE",T[T.WXS_END_STEP=28]="WXS_END_STEP",T[T.IN_COMMENT_BEGIN1=29]="IN_COMMENT_BEGIN1",T[T.IN_COMMENT_BEGIN2=30]="IN_COMMENT_BEGIN2",T[T.IN_COMMENT=31]="IN_COMMENT",T[T.WAIT_FOR_COMMENT_END1=32]="WAIT_FOR_COMMENT_END1",T[T.WAIT_FOR_COMMENT_END2=33]="WAIT_FOR_COMMENT_END2",T[T.IN_TEXT=34]="IN_TEXT",T[T.IN_END_TAG=35]="IN_END_TAG",T[T.IN_END_TAG_WORD=36]="IN_END_TAG_WORD",T[T.MAX_STATE=37]="MAX_STATE"}(STATE||(STATE={})),function(T){T[T.WAIT_TEMPLATE_START=5]="WAIT_TEMPLATE_START",T[T.IN_TEMPLATE_ITEM=6]="IN_TEMPLATE_ITEM",T[T.WAIT_TEMPLATE_END=7]="WAIT_TEMPLATE_END",T[T.SPACE_AFTER_WAIT_TEMPLATE_END=8]="SPACE_AFTER_WAIT_TEMPLATE_END",T[T.IN_TEMPLATE_STRING=9]="IN_TEMPLATE_STRING",T[T.IN_TEMPLATE_STRING_ESCAPE=10]="IN_TEMPLATE_STRING_ESCAPE",T[T.IN_TEMPLATE_STRING2=11]="IN_TEMPLATE_STRING2",T[T.IN_TEMPLATE_STRING2_ESCAPE=12]="IN_TEMPLATE_STRING2_ESCAPE",T[T.WAIT_FOR_COMMENT_START=13]="WAIT_FOR_COMMENT_START",T[T.IN_COMMENT=14]="IN_COMMENT",T[T.WAIT_FOR_COMMENT_END=15]="WAIT_FOR_COMMENT_END",T[T.IN_TEMPLATE_SPACE=16]="IN_TEMPLATE_SPACE",T[T.MAX_STATE=17]="MAX_STATE"}(TEMPLATE_STATE||(TEMPLATE_STATE={})),function(T){T[T.WAIT_KEY=5]="WAIT_KEY",T[T.IN_KEY=6]="IN_KEY",T[T.WAIT_KEY_VALUE_SAPERATE=7]="WAIT_KEY_VALUE_SAPERATE",T[T.IN_KEY_VALUE_SAPERATE=8]="IN_KEY_VALUE_SAPERATE",T[T.WAIT_VALUE=9]="WAIT_VALUE",T[T.IN_VALUE=10]="IN_VALUE",T[T.WAIT_ITEM_SAPERATE=11]="WAIT_ITEM_SAPERATE",T[T.IN_ITEM_SAPERATE=12]="IN_ITEM_SAPERATE",T[T.IN_STRING=13]="IN_STRING",T[T.IN_STRING_ESCAPE=14]="IN_STRING_ESCAPE",T[T.IN_STRING2=15]="IN_STRING2",T[T.IN_STRING2_ESCAPE=16]="IN_STRING2_ESCAPE",T[T.WAIT_TEMPLATE_START=17]="WAIT_TEMPLATE_START",T[T.IN_TEMPLATE=18]="IN_TEMPLATE",T[T.WAIT_TEMPLATE_END=19]="WAIT_TEMPLATE_END",T[T.IN_TEMPLATE_STRING=20]="IN_TEMPLATE_STRING",T[T.IN_TEMPLATE_STRING_ESCAPE=21]="IN_TEMPLATE_STRING_ESCAPE",T[T.IN_TEMPLATE_STRING2=22]="IN_TEMPLATE_STRING2",T[T.IN_TEMPLATE_STRING2_ESCAPE=23]="IN_TEMPLATE_STRING2_ESCAPE",T[T.WAIT_FOR_COMMENT_START=24]="WAIT_FOR_COMMENT_START",T[T.IN_COMMENT=25]="IN_COMMENT",T[T.WAIT_FOR_COMMENT_END=26]="WAIT_FOR_COMMENT_END",T[T.MAX_STATE=27]="MAX_STATE"}(STYLE_ATTR_VALUE_STATE||(STYLE_ATTR_VALUE_STATE={})),function(T){T[T.NOTHING=0]="NOTHING",T[T.DO_ACTION=65536]="DO_ACTION",T[T.STORE_TOKEN_EXCLUDE=131072]="STORE_TOKEN_EXCLUDE",T[T.STORE_TOKEN_INCLUDE=262144]="STORE_TOKEN_INCLUDE",T[T.IGNORE=524288]="IGNORE",T[T.REFEED=1048576]="REFEED",T[T.STORE_TOKEN_FIRST=2097152]="STORE_TOKEN_FIRST",T[T.STORE_ONE_SPACE=4194304]="STORE_ONE_SPACE",T[T.STORE_ONE_LINE_BREAK=8388608]="STORE_ONE_LINE_BREAK",T[T.GET_STATE_BEFORE=16777216]="GET_STATE_BEFORE",T[T.STORE_STATE_BEFORE=33554432]="STORE_STATE_BEFORE",T[T.SET_WXS_STATE=67108864]="SET_WXS_STATE",T[T.RECORD_IN_TEMPLATE_OBJECT=134217728]="RECORD_IN_TEMPLATE_OBJECT",T[T.CHECK_IN_TEMPLATE_OBJECT=268435456]="CHECK_IN_TEMPLATE_OBJECT"}(ACTION||(ACTION={}));class Token{constructor(T,E){this.type=T,this.value=E}}class MachineState{constructor(){this.cur_pos=0,this.last_pos=0,this.line=1,this.col=1,this.mark_pos=0,this.mark_col=0,this.last_line=this.line,this.last_col=1,this.state=BASE_STATE.START,this.in_template_object_count=0}}const ALPHA="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-:",DIGIT="0123456789.",WHITECHARS=" \n\t\r";class BaseMachine{constructor(T,E){this.mState=new MachineState,this.storedStates=[],this.oldState=BASE_STATE.START,this.tokens=[],this.mPath=T,this.mSrc=E}FillTT(T,E,_,A){for(const S of A)this.TT[T][getCharCode(S)]=E|_}Reset(){return this.mState.cur_pos=0,this.mState.last_pos=0,this.mState.mark_pos=0,this.mState.line=1,this.mState.col=1,this.mState.last_col=1,this.mState.mark_col=1,this.mState.last_line=this.mState.line,this.mState.state=BASE_STATE.START,0}refeed(T){let E=this.TT[this.mState.state][getCharCode(T)];if(E===BASE_STATE.NOT_SET&&(E=this.TT[this.mState.state][BASE_STATE.OTHERS]),E===BASE_STATE.NOT_SET)throw{col:this.mState.col,line:this.mState.line,message:"BAD STATE MACHINE!"};if(E<0){if("\0"!==T)throw{col:this.mState.col,line:this.mState.line,message:`unexpected character \`${T.replace(/\n/g,"\\n")}\``};throw{col:this.mState.col,line:this.mState.line,message:"unexpected end"}}const _=E,A=65535&E,S=this.mState.state;_&ACTION.STORE_STATE_BEFORE&&(this.storedStates.push(S),this.mState.mark_pos=this.mState.cur_pos,this.mState.mark_col=this.mState.mark_col),this.mState.state=A,this.doAction(T,S,_)}Feed(T){"\n"===T&&(this.mState.line++,this.mState.col=0),this.refeed(T)}FillTT_template_string(T,E,_){const A=T+1;this.TT[T][getCharCode("\\")]=A,this.TT[A][BASE_STATE.OTHERS]=T,this.TT[T][getCharCode(_)]=E,this.TT[T][0]=BASE_STATE.ERROR,this.TT[T][BASE_STATE.OTHERS]=T}updatePosition(){this.mState.last_pos=this.mState.cur_pos,this.mState.last_col=this.mState.col,this.mState.last_line=this.mState.line}processPosition(){this.mState.cur_pos++,this.mState.col++}doAction(T,E,_){if(_&ACTION.STORE_TOKEN_FIRST&&this.mState.mark_pos>this.mState.last_pos){const T=this.mSrc.substring(this.mState.last_pos,this.mState.mark_pos);this.doExcludeAction(this.storedStates[this.storedStates.length-1],T),this.mState.last_pos=this.mState.mark_pos,this.mState.last_col=this.mState.mark_col}if(_&ACTION.STORE_ONE_LINE_BREAK&&(this.appendToken(TokenType.OTHERS,"\n"),this.updatePosition()),_&ACTION.STORE_ONE_SPACE&&(this.appendToken(TokenType.OTHERS," "),this.updatePosition()),_&ACTION.STORE_TOKEN_EXCLUDE){const T=this.mState.cur_pos,_=this.mState.last_pos;if(T>=_){const A=this.mSrc.substring(_,T);this.doExcludeAction(E,A),this.updatePosition()}}if(_&ACTION.RECORD_IN_TEMPLATE_OBJECT&&this.mState.in_template_object_count++,_&ACTION.CHECK_IN_TEMPLATE_OBJECT&&this.mState.in_template_object_count>0&&(this.mState.in_template_object_count--,this.mState.state=STATE.IN_TEMPLATE),_&ACTION.REFEED){if(_&ACTION.IGNORE&&this.updatePosition(),_&ACTION.GET_STATE_BEFORE){const T=this.storedStates.pop();T&&(this.mState.state=T)}this.refeed(T)}else{if(this.processPosition(),_&ACTION.STORE_TOKEN_INCLUDE){const _=this.mSrc.substring(this.mState.last_pos,this.mState.cur_pos);this.doIncludeAction(T,E,_),this.updatePosition()}if(_&ACTION.IGNORE&&this.updatePosition(),_&ACTION.GET_STATE_BEFORE){const T=this.storedStates.pop();T&&(this.mState.state=T)}}}}class StyleAttrValueMachine extends BaseMachine{get TT(){return StyleAttrValueMachine._TT||this.InitTransitTable(),StyleAttrValueMachine._TT}constructor(T,E){super(T,E),this.mState.state=BASE_STATE.START}getTokens(){return[...this.tokens]}appendToken(T,E){T===TokenType.STYLE_VALUE&&(E=E.replace(/[ \t]+/g," ")),this.tokens.push(new Token(T,E))}doExcludeAction(T,E){let _=TokenType.OTHERS;switch(T){case STYLE_ATTR_VALUE_STATE.IN_KEY:_=TokenType.STYLE_KEY;break;case STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE:_=TokenType.OTHERS;break;case STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE:_=TokenType.OTHERS,E=";";break;case STYLE_ATTR_VALUE_STATE.IN_VALUE:_=TokenType.STYLE_VALUE}this.appendToken(_,E)}doIncludeAction(T,E,_){let A=TokenType.OTHERS;switch(E){case STYLE_ATTR_VALUE_STATE.IN_STRING:A=TokenType.STRING1;break;case STYLE_ATTR_VALUE_STATE.IN_STRING2:A=TokenType.STRING2;break;case STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_END:A=TokenType.TEMPLATE_ITEM,_=new TemplateTokenizer(_,this.mPath).toString();break;case STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START:this.doExcludeAction(this.storedStates[this.storedStates.length-1],_.replace(/\/\*$/,"")),A=TokenType.OTHERS,_="/*";break;case STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_END:A=TokenType.OTHERS,_="*/"}this.appendToken(A,_)}FillTT_string(T,E,_){const A=T+1;this.TT[T][getCharCode("\\")]=A,this.TT[T][getCharCode("\n")]=BASE_STATE.ERROR,this.TT[A][BASE_STATE.OTHERS]=T,this.TT[A][getCharCode("\n")]=E|ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE,this.TT[T][getCharCode(_)]=E|ACTION.STORE_TOKEN_INCLUDE,this.TT[T][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[T][0]=BASE_STATE.ERROR,this.TT[T][BASE_STATE.OTHERS]=T}InitTransitTable(){StyleAttrValueMachine._TT=new Array(STYLE_ATTR_VALUE_STATE.MAX_STATE);for(let T=0;T<STYLE_ATTR_VALUE_STATE.MAX_STATE;T++){const E=new Array(257);E.fill(0),this.TT[T]=E}this.TT[BASE_STATE.END][BASE_STATE.OTHERS]=BASE_STATE.END,this.FillTT(BASE_STATE.START,BASE_STATE.START,ACTION.IGNORE," \n\t\r"),this.TT[BASE_STATE.START][getCharCode(":")]=BASE_STATE.ERROR,this.TT[BASE_STATE.START][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[BASE_STATE.START][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[BASE_STATE.START][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.TT[BASE_STATE.START][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_KEY,this.FillTT(STYLE_ATTR_VALUE_STATE.WAIT_KEY,STYLE_ATTR_VALUE_STATE.WAIT_KEY,ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY][getCharCode(":")]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.IN_KEY|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_KEY,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.FillTT(STYLE_ATTR_VALUE_STATE.IN_KEY,STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode(":")]=STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode('"')]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode("'")]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_KEY,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.FillTT(STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE,STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE,ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE][getCharCode(":")]=STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.WAIT_KEY|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.FillTT(STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE,STYLE_ATTR_VALUE_STATE.WAIT_VALUE,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode(":")]=STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode("\0")]=BASE_STATE.END|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode('"')]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode("'")]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.REFEED|ACTION.STORE_TOKEN_EXCLUDE,this.FillTT(STYLE_ATTR_VALUE_STATE.WAIT_VALUE,STYLE_ATTR_VALUE_STATE.WAIT_VALUE,ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode(":")]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode('"')]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode("'")]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode("\0")]=BASE_STATE.END,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_VALUE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode('"')]=STYLE_ATTR_VALUE_STATE.IN_STRING|ACTION.STORE_STATE_BEFORE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode("'")]=STYLE_ATTR_VALUE_STATE.IN_STRING2|ACTION.STORE_STATE_BEFORE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_VALUE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode("\0")]=BASE_STATE.END|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.FillTT(STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE,STYLE_ATTR_VALUE_STATE.WAIT_KEY,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode("'")]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode('"')]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_KEY|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode("\0")]=BASE_STATE.END|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.IN_KEY|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.IN_TEMPLATE|ACTION.STORE_TOKEN_FIRST,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START][BASE_STATE.OTHERS]=ACTION.GET_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][getCharCode("}")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_END,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][getCharCode("\\")]=BASE_STATE.ERROR,this.FillTT(STYLE_ATTR_VALUE_STATE.IN_TEMPLATE,STYLE_ATTR_VALUE_STATE.IN_TEMPLATE,ACTION.NOTHING," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_TEMPLATE,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][0]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_END][getCharCode("}")]=ACTION.GET_STATE_BEFORE|ACTION.STORE_TOKEN_INCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_END][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_TEMPLATE|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_END][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][getCharCode('"')]=STYLE_ATTR_VALUE_STATE.IN_TEMPLATE_STRING|ACTION.NOTHING,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][getCharCode("'")]=STYLE_ATTR_VALUE_STATE.IN_TEMPLATE_STRING2|ACTION.NOTHING,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START][getCharCode("*")]=STYLE_ATTR_VALUE_STATE.IN_COMMENT|ACTION.STORE_TOKEN_INCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START][BASE_STATE.OTHERS]=ACTION.GET_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_COMMENT][getCharCode("*")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_END,this.TT[STYLE_ATTR_VALUE_STATE.IN_COMMENT][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_COMMENT|ACTION.IGNORE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_END][getCharCode("/")]=ACTION.GET_STATE_BEFORE|ACTION.STORE_TOKEN_INCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_END][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_COMMENT|ACTION.NOTHING,this.FillTT_template_string(STYLE_ATTR_VALUE_STATE.IN_TEMPLATE_STRING,STYLE_ATTR_VALUE_STATE.IN_TEMPLATE|ACTION.NOTHING,'"'),this.FillTT_template_string(STYLE_ATTR_VALUE_STATE.IN_TEMPLATE_STRING2,STYLE_ATTR_VALUE_STATE.IN_TEMPLATE|ACTION.NOTHING,"'"),this.FillTT_string(STYLE_ATTR_VALUE_STATE.IN_STRING,ACTION.GET_STATE_BEFORE,'"'),this.FillTT_string(STYLE_ATTR_VALUE_STATE.IN_STRING2,ACTION.GET_STATE_BEFORE,"'")}}class TemplateMachine extends BaseMachine{get TT(){return TemplateMachine._TT||this.InitTransitTable(),TemplateMachine._TT}constructor(T,E){super(T,E),this.mState.state=BASE_STATE.START}getTokens(){return[...this.tokens]}appendToken(T,E){this.tokens.push(new Token(T,E))}doExcludeAction(T,E){let _=TokenType.OTHERS;switch(T){case TEMPLATE_STATE.IN_TEMPLATE_ITEM:case TEMPLATE_STATE.WAIT_TEMPLATE_END:_=TokenType.TEMPLATE_ITEM}this.appendToken(_,E)}doIncludeAction(T,E,_){let A=TokenType.OTHERS;switch(E){case TEMPLATE_STATE.WAIT_TEMPLATE_START:A=TokenType.TEMPLATE_START;break;case TEMPLATE_STATE.WAIT_TEMPLATE_END:A=TokenType.TEMPLATE_END}this.appendToken(A,_)}InitTransitTable(){TemplateMachine._TT=new Array(TEMPLATE_STATE.MAX_STATE);for(let T=0;T<TEMPLATE_STATE.MAX_STATE;T++){const E=new Array(257);E.fill(0),this.TT[T]=E}this.FillTT(BASE_STATE.START,BASE_STATE.START,ACTION.IGNORE," \n\t\r"),this.TT[BASE_STATE.START][getCharCode("{")]=TEMPLATE_STATE.WAIT_TEMPLATE_START,this.TT[BASE_STATE.START][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[TEMPLATE_STATE.WAIT_TEMPLATE_START][getCharCode("{")]=TEMPLATE_STATE.IN_TEMPLATE_ITEM|ACTION.STORE_TOKEN_INCLUDE,this.TT[TEMPLATE_STATE.WAIT_TEMPLATE_START][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.FillTT(TEMPLATE_STATE.IN_TEMPLATE_SPACE,TEMPLATE_STATE.IN_TEMPLATE_SPACE,ACTION.IGNORE," \n\t\r"),this.TT[TEMPLATE_STATE.IN_TEMPLATE_SPACE][getCharCode("}")]=TEMPLATE_STATE.WAIT_TEMPLATE_END,this.TT[TEMPLATE_STATE.IN_TEMPLATE_SPACE][getCharCode('"')]=TEMPLATE_STATE.IN_TEMPLATE_STRING|ACTION.STORE_STATE_BEFORE,this.TT[TEMPLATE_STATE.IN_TEMPLATE_SPACE][getCharCode("'")]=TEMPLATE_STATE.IN_TEMPLATE_STRING2|ACTION.STORE_STATE_BEFORE,this.TT[TEMPLATE_STATE.IN_TEMPLATE_SPACE][getCharCode("/")]=TEMPLATE_STATE.WAIT_FOR_COMMENT_START,this.TT[TEMPLATE_STATE.IN_TEMPLATE_SPACE][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_TEMPLATE_ITEM,this.FillTT(TEMPLATE_STATE.IN_TEMPLATE_ITEM,TEMPLATE_STATE.IN_TEMPLATE_SPACE,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][getCharCode("}")]=TEMPLATE_STATE.WAIT_TEMPLATE_END,this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][getCharCode("\\")]=BASE_STATE.ERROR,this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][getCharCode('"')]=TEMPLATE_STATE.IN_TEMPLATE_STRING|ACTION.STORE_STATE_BEFORE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][getCharCode("'")]=TEMPLATE_STATE.IN_TEMPLATE_STRING2|ACTION.STORE_STATE_BEFORE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_TEMPLATE_ITEM,this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][0]=BASE_STATE.ERROR,this.TT[TEMPLATE_STATE.WAIT_FOR_COMMENT_START][getCharCode("*")]=TEMPLATE_STATE.IN_COMMENT,this.FillTT(TEMPLATE_STATE.WAIT_FOR_COMMENT_START,TEMPLATE_STATE.IN_TEMPLATE_ITEM,ACTION.REFEED," \n\t\r"),this.TT[TEMPLATE_STATE.WAIT_FOR_COMMENT_START][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_TEMPLATE_ITEM,this.TT[TEMPLATE_STATE.IN_COMMENT][getCharCode("*")]=TEMPLATE_STATE.WAIT_FOR_COMMENT_END,this.TT[TEMPLATE_STATE.IN_COMMENT][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_COMMENT,this.TT[TEMPLATE_STATE.WAIT_FOR_COMMENT_END][getCharCode("/")]=TEMPLATE_STATE.IN_TEMPLATE_SPACE|ACTION.IGNORE,this.FillTT_template_string(TEMPLATE_STATE.IN_TEMPLATE_STRING,TEMPLATE_STATE.IN_TEMPLATE_ITEM|ACTION.STORE_TOKEN_INCLUDE|ACTION.GET_STATE_BEFORE,'"'),this.FillTT_template_string(TEMPLATE_STATE.IN_TEMPLATE_STRING2,TEMPLATE_STATE.IN_TEMPLATE_ITEM|ACTION.STORE_TOKEN_INCLUDE|ACTION.GET_STATE_BEFORE,"'"),this.TT[TEMPLATE_STATE.WAIT_TEMPLATE_END][getCharCode("}")]=BASE_STATE.END|ACTION.STORE_TOKEN_INCLUDE,this.FillTT(TEMPLATE_STATE.WAIT_TEMPLATE_END,TEMPLATE_STATE.SPACE_AFTER_WAIT_TEMPLATE_END,ACTION.STORE_TOKEN_EXCLUDE," \n\t\r"),this.TT[TEMPLATE_STATE.WAIT_TEMPLATE_END][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_TEMPLATE_ITEM|ACTION.REFEED,this.FillTT(TEMPLATE_STATE.SPACE_AFTER_WAIT_TEMPLATE_END,TEMPLATE_STATE.SPACE_AFTER_WAIT_TEMPLATE_END,ACTION.IGNORE," \n\t\r"),this.TT[TEMPLATE_STATE.SPACE_AFTER_WAIT_TEMPLATE_END][getCharCode("}")]=TEMPLATE_STATE.WAIT_TEMPLATE_END|ACTION.STORE_ONE_SPACE,this.TT[TEMPLATE_STATE.SPACE_AFTER_WAIT_TEMPLATE_END][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_TEMPLATE_ITEM|ACTION.IGNORE|ACTION.REFEED,this.FillTT(BASE_STATE.END,BASE_STATE.END,ACTION.IGNORE," \n\t\r"),this.TT[BASE_STATE.END][getCharCode("\0")]=BASE_STATE.END,this.TT[BASE_STATE.END][BASE_STATE.OTHERS]=BASE_STATE.ERROR}}class TemplateTokenizer{constructor(T,E){this.machine=new TemplateMachine(E,T),this.m_pSrc=T,this.path=E}toString(){this.tokens||(this.tokens=this.generateTokens());return this.tokens.map(T=>T.value).join("")}generateTokens(){if(this.machine.Reset(),0===this.m_pSrc.length)return[];for(let T=0;T<this.m_pSrc.length;T++){const E=this.m_pSrc[T];this.machine.Feed(E)}return this.machine.Feed("\0"),this.machine.getTokens()}}exports.TemplateTokenizer=TemplateTokenizer;class StyleAttrValueTokenizer{constructor(T,E){this.machine=new StyleAttrValueMachine(E,T),this.m_pSrc=T,this.path=E}toString(){return this.tokens||(this.tokens=this.generateTokens()),this.tokens.map(T=>T.value).join("")}generateTokens(){if(this.machine.Reset(),0===this.m_pSrc.length)return[];for(let T=0;T<this.m_pSrc.length;T++){const E=this.m_pSrc[T];this.machine.Feed(E)}return this.machine.Feed("\0"),this.machine.getTokens()}}exports.StyleAttrValueTokenizer=StyleAttrValueTokenizer;class Machine extends BaseMachine{get TT(){return Machine._TT||this.InitTransitTable(),Machine._TT}constructor(T,E){super(T,E),this.tagStack=[],this.InitTransitTable(),this.mPath=T,this.mSrc=E}get wxsState(){return"wxs"===this.tagStack[this.tagStack.length-1]}get textState(){return"text"===this.tagStack[this.tagStack.length-1]}getTokens(){return[...this.tokens]}checkLastTokenIfTypeMatch(T){var E;return(null===(E=this.tokens[this.tokens.length-1])||void 0===E?void 0:E.type)===T?this.tokens[this.tokens.length-1]:void 0}getLastTokenIfTypeMatch(T){if(0!==this.tokens.length)for(let E=this.tokens.length-1;E>=0;E--){const _=this.tokens[E];if(_.type===T)return _}}canBeOmittedTokenType(T){return T===TokenType.WXS_VALUE}appendToken(T,E){if(this.canBeOmittedTokenType(T)&&(E=this.transTagTextTokenValue(E)),T===TokenType.ATTR_VALUE){const T=this.getLastTokenIfTypeMatch(TokenType.ATTR);"style"===(null==T?void 0:T.value)&&(E=this.trySlimStyleAttrValue(E))}E&&this.tokens.push(new Token(T,E))}transTagTextTokenValue(T){return this.wxsState?T=T.split("\n").map(T=>T.trim()).join("\n"):T}trySlimStyleAttrValue(T){const E=[];try{if(T.length<=1)return T;for(let T=this.tokens.length-1;T>=0;T--){if(this.tokens[T].type===TokenType.TAG_EQ)break;E.unshift(this.tokens.pop())}const _=`${E.map(T=>null==T?void 0:T.value).join("")}${T}`,A=_.startsWith('"')||_.startsWith("'"),S=_.endsWith('"')||_.endsWith("'"),t=new StyleAttrValueTokenizer(_.replace(/^['"]/,"").replace(/['"]$/,""),this.mPath).toString();return`${A?_.substr(0,1):""}${t}${S?_.substr(_.length-1,1):""}`}catch(T){this.tokens.push(...E)}return T}doExcludeAction(T,E){let _=TokenType.OTHERS;switch(T){case STATE.IN_TAG_ATTR_VALUE_STRING:case STATE.IN_TAG_ATTR_VALUE_STRING_SINGLE:_=TokenType.ATTR_VALUE;break;case STATE.IN_TAG_WORD:_=TokenType.TAG,this.tagStack.push(E);break;case STATE.IN_END_TAG_WORD:_=TokenType.TAG;if(this.tagStack.pop()!==E)throw{col:this.mState.col-E.length,line:this.mState.line,message:"unexpected end tag: "+E};break;case STATE.IN_WXS:_=TokenType.WXS_VALUE;break;case STATE.IN_TEXT:_=TokenType.TEXT_VALUE;break;case STATE.IN_TAG_TEXT:_=TokenType.TAG_TEXT_VALUE;break;case STATE.IN_TAG_ATTR_WORD:_=TokenType.ATTR;break;case STATE.TAG_START:_=TokenType.LEFT_ANGLE_BRACKET;break;case STATE.IN_TEMPLATE:_=TokenType.TEMPLATE_ITEM;break;case STATE.TAG_EQ:_=TokenType.TAG_EQ;break;case STATE.TEMPLATE_END_CHECK:{const T=this.mState.cur_pos;if("}"===this.mSrc.substring(T-3,T-2))throw{col:this.mState.col-3,line:this.mState.line,message:"unexpected end tag: }. } should not be followed by }} direactly, add a space and change it to } }}"};this.appendToken(TokenType.TEMPLATE_ITEM,""+new TemplateTokenizer(E,this.mPath)),_=TokenType.TEMPLATE_END,E=""}}this.appendToken(_,E)}doIncludeAction(T,E,_){const A=this.mState.state;let S;E===STATE.WXS_END_STEP?(this.appendToken(TokenType.WXS_VALUE,_.substr(0,_.length-2)),S=TokenType.END_LEFT_ANGLE_BRACKET,_="</"):E===STATE.IN_WXS_STRING||E===STATE.IN_WXS_STRING_SINGLE?S=TokenType.WXS_VALUE:E===STATE.IN_TAG_ATTR_VALUE_STRING||E===STATE.IN_TAG_ATTR_VALUE_STRING_SINGLE?S=TokenType.ATTR_VALUE:E===STATE.TAG_START&&A===STATE.IN_END_TAG?S=TokenType.END_LEFT_ANGLE_BRACKET:E===STATE.WAIT_FOR_RIGHT_BRACKET?(S=TokenType.SELF_CLOSE,this.tagStack.pop()):S=TokenType.OTHERS,">"!==T||E!==STATE.IN_TAG_WORD&&E!==STATE.IN_TAG_ATTR_WORD&&E!==STATE.IN_TAG_ATTR_VALUE_STRING&&E!==STATE.IN_TAG_ATTR_VALUE_STRING_SINGLE&&E!==STATE.IN_END_TAG_WORD||(S=TokenType.RIGHT_ANGLE_BRACKET),this.appendToken(S,_)}Feed(T){super.Feed(T),this.wxsState&&this.mState.state===STATE.IN_TAG_TEXT&&(this.mState.state=STATE.IN_WXS),this.textState&&this.mState.state===STATE.IN_TAG_TEXT&&(this.mState.state=STATE.IN_TEXT)}FillTT_attr_string(T,E,_){const A=T+1;this.TT[T][getCharCode("\\")]=A,this.TT[A][BASE_STATE.OTHERS]=T,this.TT[A][getCharCode("\n")]=E|ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE,this.TT[T][getCharCode(_)]=E|ACTION.STORE_TOKEN_INCLUDE,this.TT[T][getCharCode("{")]=STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[T][0]=BASE_STATE.ERROR,this.TT[T][BASE_STATE.OTHERS]=T}InitTransitTable(){Machine._TT=new Array(STATE.MAX_STATE);for(let T=0;T<STATE.MAX_STATE;T++){const E=new Array(257);E.fill(0),this.TT[T]=E}this.TT[BASE_STATE.END][BASE_STATE.OTHERS]=BASE_STATE.END,this.TT[BASE_STATE.START][getCharCode("<")]=STATE.TAG_START|ACTION.STORE_TOKEN_EXCLUDE|ACTION.STORE_STATE_BEFORE,this.TT[BASE_STATE.START][getCharCode("{")]=STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[BASE_STATE.START][BASE_STATE.OTHERS]=STATE.IN_TAG_TEXT|ACTION.NOTHING,this.TT[BASE_STATE.START][0]=BASE_STATE.END|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TAG_TEXT][getCharCode("<")]=STATE.TAG_START|ACTION.STORE_TOKEN_EXCLUDE|ACTION.STORE_STATE_BEFORE,this.TT[STATE.IN_TAG_TEXT][getCharCode("{")]=STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[STATE.IN_TAG_TEXT][BASE_STATE.OTHERS]=STATE.IN_TAG_TEXT|ACTION.NOTHING,this.TT[STATE.IN_TAG_TEXT][0]=BASE_STATE.END|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TAG_TEXT][BASE_STATE.OTHERS]=STATE.IN_TAG_TEXT,this.TT[STATE.WAIT_TEMPLATE_START][getCharCode("{")]=STATE.IN_TEMPLATE|ACTION.STORE_TOKEN_FIRST,this.TT[STATE.WAIT_TEMPLATE_START][BASE_STATE.OTHERS]=STATE.IN_TAG_TEXT|ACTION.GET_STATE_BEFORE,this.TT[STATE.IN_TEMPLATE][getCharCode("{")]=STATE.IN_TEMPLATE|ACTION.RECORD_IN_TEMPLATE_OBJECT,this.TT[STATE.IN_TEMPLATE][getCharCode("}")]=STATE.WAIT_TEMPLATE_END|ACTION.CHECK_IN_TEMPLATE_OBJECT,this.TT[STATE.IN_TEMPLATE][getCharCode("\\")]=BASE_STATE.ERROR,this.FillTT(STATE.IN_TEMPLATE,STATE.IN_TEMPLATE,ACTION.NOTHING," \n\t\r"),this.TT[STATE.IN_TEMPLATE][BASE_STATE.OTHERS]=STATE.IN_TEMPLATE,this.TT[STATE.IN_TEMPLATE][0]=BASE_STATE.ERROR,this.TT[STATE.WAIT_TEMPLATE_END][getCharCode("}")]=STATE.TEMPLATE_END_CHECK,this.TT[STATE.TEMPLATE_END_CHECK][BASE_STATE.OTHERS]=STATE.IN_TAG_TEXT|ACTION.REFEED|ACTION.STORE_TOKEN_EXCLUDE|ACTION.GET_STATE_BEFORE,this.TT[STATE.WAIT_TEMPLATE_END][BASE_STATE.OTHERS]=STATE.IN_TEMPLATE|ACTION.REFEED,this.TT[STATE.IN_TEMPLATE][getCharCode('"')]=STATE.IN_TEMPLATE_STRING|ACTION.NOTHING,this.TT[STATE.IN_TEMPLATE][getCharCode("'")]=STATE.IN_TEMPLATE_STRING2|ACTION.NOTHING,this.FillTT_template_string(STATE.IN_TEMPLATE_STRING,STATE.IN_TEMPLATE|ACTION.NOTHING,'"'),this.FillTT_template_string(STATE.IN_TEMPLATE_STRING2,STATE.IN_TEMPLATE|ACTION.NOTHING,"'"),this.FillTT(STATE.TAG_START,STATE.TAG_START,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.FillTT(STATE.TAG_START,STATE.IN_TAG_WORD,ACTION.STORE_TOKEN_EXCLUDE,ALPHA),this.TT[STATE.TAG_START][getCharCode("/")]=STATE.IN_END_TAG|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.TAG_START][getCharCode("!")]=STATE.IN_COMMENT_BEGIN1,this.TT[STATE.TAG_START][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STATE.IN_COMMENT_BEGIN1][getCharCode("-")]=STATE.IN_COMMENT_BEGIN2,this.TT[STATE.IN_COMMENT_BEGIN1][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STATE.IN_COMMENT_BEGIN2][getCharCode("-")]=STATE.IN_COMMENT,this.TT[STATE.IN_COMMENT_BEGIN2][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STATE.IN_COMMENT][getCharCode("-")]=STATE.WAIT_FOR_COMMENT_END1,this.TT[STATE.IN_COMMENT][BASE_STATE.OTHERS]=STATE.IN_COMMENT,this.TT[STATE.WAIT_FOR_COMMENT_END1][getCharCode("-")]=STATE.WAIT_FOR_COMMENT_END2,this.TT[STATE.WAIT_FOR_COMMENT_END1][BASE_STATE.OTHERS]=STATE.IN_COMMENT,this.TT[STATE.WAIT_FOR_COMMENT_END2][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.IGNORE|ACTION.GET_STATE_BEFORE,this.TT[STATE.WAIT_FOR_COMMENT_END2][getCharCode("-")]=STATE.WAIT_FOR_COMMENT_END2,this.TT[STATE.WAIT_FOR_COMMENT_END2][BASE_STATE.OTHERS]=STATE.IN_COMMENT,this.FillTT(STATE.IN_TAG_WORD,STATE.IN_TAG_WORD,ACTION.NOTHING,ALPHA),this.FillTT(STATE.IN_TAG_WORD,STATE.IN_TAG_WORD,ACTION.NOTHING,DIGIT),this.FillTT(STATE.IN_TAG_WORD,STATE.IN_TAG_ATTR_WORD,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STATE.IN_TAG_WORD][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.STORE_TOKEN_EXCLUDE|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.IN_TAG_WORD][getCharCode("/")]=STATE.WAIT_FOR_RIGHT_BRACKET|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TAG_WORD][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STATE.IN_TAG_WORD][0]=BASE_STATE.ERROR,this.FillTT(STATE.IN_TAG_ATTR_WORD,STATE.IN_TAG_ATTR_WORD,ACTION.NOTHING,ALPHA),this.FillTT(STATE.IN_TAG_ATTR_WORD,STATE.IN_TAG_ATTR_WORD,ACTION.NOTHING,DIGIT),this.FillTT(STATE.IN_TAG_ATTR_WORD,STATE.IN_TAG_ATTR_WORD,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STATE.IN_TAG_ATTR_WORD][getCharCode("=")]=STATE.TAG_EQ|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TAG_ATTR_WORD][getCharCode('"')]=BASE_STATE.ERROR,this.TT[STATE.IN_TAG_ATTR_WORD][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.STORE_TOKEN_EXCLUDE|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.IN_TAG_ATTR_WORD][getCharCode("/")]=STATE.WAIT_FOR_RIGHT_BRACKET|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TAG_ATTR_WORD][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STATE.IN_TAG_ATTR_WORD][0]=BASE_STATE.ERROR,this.FillTT(STATE.TAG_EQ,STATE.TAG_EQ,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.FillTT(STATE.TAG_EQ,STATE.IN_TAG_ATTR_VALUE_STRING,ACTION.STORE_TOKEN_EXCLUDE,ALPHA),this.TT[STATE.TAG_EQ][getCharCode('"')]=STATE.IN_TAG_ATTR_VALUE_STRING|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.TAG_EQ][getCharCode("'")]=STATE.IN_TAG_ATTR_VALUE_STRING_SINGLE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.TAG_EQ][0]=BASE_STATE.ERROR,this.TT[STATE.TAG_EQ][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.FillTT(STATE.IN_END_TAG,STATE.IN_END_TAG,ACTION.IGNORE," \n\t\r"),this.FillTT(STATE.IN_END_TAG,STATE.IN_END_TAG_WORD,ACTION.NOTHING,ALPHA),this.FillTT(STATE.IN_END_TAG,BASE_STATE.ERROR,ACTION.NOTHING,DIGIT),this.TT[STATE.IN_END_TAG][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.IN_END_TAG][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.FillTT(STATE.IN_END_TAG_WORD,STATE.IN_END_TAG_WORD,ACTION.NOTHING,ALPHA),this.FillTT(STATE.IN_END_TAG_WORD,STATE.IN_END_TAG_WORD,ACTION.NOTHING,DIGIT),this.FillTT(STATE.IN_END_TAG_WORD,STATE.IN_END_TAG,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STATE.IN_END_TAG_WORD][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.STORE_TOKEN_EXCLUDE|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.IN_END_TAG_WORD][getCharCode("/")]=STATE.WAIT_FOR_RIGHT_BRACKET|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_END_TAG_WORD][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.FillTT(STATE.WAIT_FOR_RIGHT_BRACKET,STATE.IN_TAG_WORD,ACTION.STORE_TOKEN_EXCLUDE,ALPHA),this.TT[STATE.WAIT_FOR_RIGHT_BRACKET][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.WAIT_FOR_RIGHT_BRACKET][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.FillTT_attr_string(STATE.IN_TAG_ATTR_VALUE_STRING,STATE.IN_TAG_ATTR_WORD,'"'),this.FillTT_attr_string(STATE.IN_TAG_ATTR_VALUE_STRING_SINGLE,STATE.IN_TAG_ATTR_WORD,"'"),this.TT[STATE.IN_WXS][getCharCode("<")]=STATE.WXS_END_STEP,this.TT[STATE.IN_WXS][getCharCode('"')]=STATE.IN_WXS_STRING|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_WXS][getCharCode("'")]=STATE.IN_WXS_STRING_SINGLE|ACTION.STORE_TOKEN_EXCLUDE,this.FillTT_attr_string(STATE.IN_WXS_STRING,STATE.IN_WXS,'"'),this.FillTT_attr_string(STATE.IN_WXS_STRING_SINGLE,STATE.IN_WXS,"'"),this.TT[STATE.IN_WXS][BASE_STATE.OTHERS]=STATE.IN_WXS,this.TT[STATE.WXS_END_STEP][getCharCode("/")]=STATE.IN_END_TAG|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.WXS_END_STEP][BASE_STATE.OTHERS]=STATE.IN_WXS,this.TT[STATE.IN_TEXT][getCharCode("<")]=STATE.TAG_START|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TEXT][BASE_STATE.OTHERS]=STATE.IN_TEXT,this.TT[STATE.IN_TEXT][getCharCode("{")]=STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE}}class Tokenizer{constructor(T,E){this.machine=new Machine(E,T),this.m_pSrc=T,this.path=E}generateTokens(){if(this.machine.Reset(),0===this.m_pSrc.length)return[];try{for(let T=0;T<this.m_pSrc.length;T++){const E=this.m_pSrc[T];this.machine.Feed(E)}this.machine.Feed("\0")}catch(T){throw new Error(`${T.line}:${T.col}:${T.message}`)}return this.machine.getTokens()}}function generateWXMLFromTokens(T,E={collapseWhitespace:!0,conservativeCollapse:!1,preserveLineBreaks:!1}){const{collapseWhitespace:_,conservativeCollapse:A,preserveLineBreaks:S}=E,t=[];for(let E=0;E<T.length;E++){const e=T[E];let N=e.value;const R=e.type;if(R===TokenType.ATTR&&(N=" "+N),R===TokenType.TAG_TEXT_VALUE){S||(N=N.replace(/\n/g," ")),_&&(N=N.replace(/([ \t])+/g," "));const t=T[E-1];t&&t.type!==TokenType.RIGHT_ANGLE_BRACKET&&t.type!==TokenType.SELF_CLOSE||_&&!A&&(N=trimStringLeft(N,!1)),(null==t?void 0:t.type)===TokenType.TAG_TEXT_VALUE&&((null==t?void 0:t.value.endsWith(" "))||(null==t?void 0:t.value.endsWith("\n")))&&_&&(N=trimStringLeft(N,!1))}if(R===TokenType.LEFT_ANGLE_BRACKET||R===TokenType.END_LEFT_ANGLE_BRACKET){const S=T[E-1];if((null==S?void 0:S.type)===TokenType.TAG_TEXT_VALUE&&_&&!A){const T=t.pop()||"";t.push(trimStringRight(T,!1))}}t.push(N)}return t.join("")}async function minifyWXML(T){const{filePath:E,root:_=""}=T,A=T.code instanceof Buffer?T.code.toString():T.code,S=Object.assign({collapseWhitespace:!0,conservativeCollapse:!1,preserveLineBreaks:!1},T.setting),t=path_1.default.posix.join(_,E);if(A.length>0)try{const T=new Tokenizer(A.replace(/\r\n/g,"\n"),t);return{error:null,code:generateWXMLFromTokens(T.generateTokens(),S)}}catch(T){return log.error("minifywxml error @ "+t),log.error(T.message),{error:{code:config_1.MINIFY_WXML_ERR,path:t,message:T.message}}}return{error:null,code:A.replace(/\r\n/g,"\n")}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.StyleAttrValueTokenizer=exports.TemplateTokenizer=void 0,exports.minifyWXML=minifyWXML;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),log=tslib_1.__importStar(require("../../../../../utils/log")),config_1=require("../../../../../config/config");function getCharCode(T){return T.charCodeAt(0)>=256?BASE_STATE.OTHERS:T.charCodeAt(0)}function trimStringLeft(T,E=!0){return E?T.trimLeft():T.split("\n").map((T=>T.replace(/^[ \t]*/g,""))).join("\n")}function trimStringRight(T,E=!0){return E?T.trimRight():T.split("\n").map((T=>T.replace(/[ \t]*$/,""))).join("\n")}var TokenType,BASE_STATE,STATE,TEMPLATE_STATE,STYLE_ATTR_VALUE_STATE,ACTION;!function(T){T[T.ATTR=0]="ATTR",T[T.TAG=1]="TAG",T[T.LEFT_ANGLE_BRACKET=2]="LEFT_ANGLE_BRACKET",T[T.RIGHT_ANGLE_BRACKET=3]="RIGHT_ANGLE_BRACKET",T[T.END_LEFT_ANGLE_BRACKET=4]="END_LEFT_ANGLE_BRACKET",T[T.STRING1=5]="STRING1",T[T.STRING2=6]="STRING2",T[T.ATTR_VALUE=7]="ATTR_VALUE",T[T.TEXT_VALUE=8]="TEXT_VALUE",T[T.TAG_TEXT_VALUE=9]="TAG_TEXT_VALUE",T[T.TEMPLATE_START=10]="TEMPLATE_START",T[T.TEMPLATE_END=11]="TEMPLATE_END",T[T.TEMPLATE_ITEM=12]="TEMPLATE_ITEM",T[T.TEMPLATE_STRING=13]="TEMPLATE_STRING",T[T.SELF_CLOSE=14]="SELF_CLOSE",T[T.WXS_VALUE=15]="WXS_VALUE",T[T.STYLE_KEY=16]="STYLE_KEY",T[T.TAG_EQ=17]="TAG_EQ",T[T.STYLE_VALUE=18]="STYLE_VALUE",T[T.STYLE_ATTR_VALUE=19]="STYLE_ATTR_VALUE",T[T.CLASS_ATTR_VALUE=20]="CLASS_ATTR_VALUE",T[T.OTHERS=21]="OTHERS"}(TokenType||(TokenType={})),function(T){T[T.ERROR=-1]="ERROR",T[T.NOT_SET=0]="NOT_SET",T[T.START=1]="START",T[T.OTHERS=2]="OTHERS",T[T.END=3]="END",T[T.MAX_STATE=4]="MAX_STATE"}(BASE_STATE||(BASE_STATE={})),function(T){T[T.IN_TAG_TEXT=5]="IN_TAG_TEXT",T[T.TAG_START=6]="TAG_START",T[T.IN_TAG_WORD=7]="IN_TAG_WORD",T[T.TAG_EQ=8]="TAG_EQ",T[T.IN_TAG_ATTR_WORD=9]="IN_TAG_ATTR_WORD",T[T.IN_TAG_ATTR_VALUE_STRING=10]="IN_TAG_ATTR_VALUE_STRING",T[T.IN_TAG_ATTR_VALUE_STRING_ESCAPE=11]="IN_TAG_ATTR_VALUE_STRING_ESCAPE",T[T.IN_TAG_ATTR_VALUE_STRING_SINGLE=12]="IN_TAG_ATTR_VALUE_STRING_SINGLE",T[T.IN_TAG_ATTR_VALUE_STRING_SINGLE_ESCAPE=13]="IN_TAG_ATTR_VALUE_STRING_SINGLE_ESCAPE",T[T.WAIT_TEMPLATE_START=14]="WAIT_TEMPLATE_START",T[T.IN_TEMPLATE=15]="IN_TEMPLATE",T[T.WAIT_TEMPLATE_END=16]="WAIT_TEMPLATE_END",T[T.TEMPLATE_END_CHECK=17]="TEMPLATE_END_CHECK",T[T.IN_TEMPLATE_STRING=18]="IN_TEMPLATE_STRING",T[T.IN_TEMPLATE_STRING_ESCAPE=19]="IN_TEMPLATE_STRING_ESCAPE",T[T.IN_TEMPLATE_STRING2=20]="IN_TEMPLATE_STRING2",T[T.IN_TEMPLATE_STRING2_ESCAPE=21]="IN_TEMPLATE_STRING2_ESCAPE",T[T.WAIT_FOR_RIGHT_BRACKET=22]="WAIT_FOR_RIGHT_BRACKET",T[T.IN_WXS=23]="IN_WXS",T[T.IN_WXS_STRING=24]="IN_WXS_STRING",T[T.IN_WXS_STRING_ESCAPE=25]="IN_WXS_STRING_ESCAPE",T[T.IN_WXS_STRING_SINGLE=26]="IN_WXS_STRING_SINGLE",T[T.IN_WXS_STRING_SINGLE_ESCAPE=27]="IN_WXS_STRING_SINGLE_ESCAPE",T[T.WXS_END_STEP=28]="WXS_END_STEP",T[T.IN_COMMENT_BEGIN1=29]="IN_COMMENT_BEGIN1",T[T.IN_COMMENT_BEGIN2=30]="IN_COMMENT_BEGIN2",T[T.IN_COMMENT=31]="IN_COMMENT",T[T.WAIT_FOR_COMMENT_END1=32]="WAIT_FOR_COMMENT_END1",T[T.WAIT_FOR_COMMENT_END2=33]="WAIT_FOR_COMMENT_END2",T[T.IN_TEXT=34]="IN_TEXT",T[T.IN_END_TAG=35]="IN_END_TAG",T[T.IN_END_TAG_WORD=36]="IN_END_TAG_WORD",T[T.MAX_STATE=37]="MAX_STATE"}(STATE||(STATE={})),function(T){T[T.WAIT_TEMPLATE_START=5]="WAIT_TEMPLATE_START",T[T.IN_TEMPLATE_ITEM=6]="IN_TEMPLATE_ITEM",T[T.WAIT_TEMPLATE_END=7]="WAIT_TEMPLATE_END",T[T.SPACE_AFTER_WAIT_TEMPLATE_END=8]="SPACE_AFTER_WAIT_TEMPLATE_END",T[T.IN_TEMPLATE_STRING=9]="IN_TEMPLATE_STRING",T[T.IN_TEMPLATE_STRING_ESCAPE=10]="IN_TEMPLATE_STRING_ESCAPE",T[T.IN_TEMPLATE_STRING2=11]="IN_TEMPLATE_STRING2",T[T.IN_TEMPLATE_STRING2_ESCAPE=12]="IN_TEMPLATE_STRING2_ESCAPE",T[T.WAIT_FOR_COMMENT_START=13]="WAIT_FOR_COMMENT_START",T[T.IN_COMMENT=14]="IN_COMMENT",T[T.WAIT_FOR_COMMENT_END=15]="WAIT_FOR_COMMENT_END",T[T.IN_TEMPLATE_SPACE=16]="IN_TEMPLATE_SPACE",T[T.MAX_STATE=17]="MAX_STATE"}(TEMPLATE_STATE||(TEMPLATE_STATE={})),function(T){T[T.WAIT_KEY=5]="WAIT_KEY",T[T.IN_KEY=6]="IN_KEY",T[T.WAIT_KEY_VALUE_SAPERATE=7]="WAIT_KEY_VALUE_SAPERATE",T[T.IN_KEY_VALUE_SAPERATE=8]="IN_KEY_VALUE_SAPERATE",T[T.WAIT_VALUE=9]="WAIT_VALUE",T[T.IN_VALUE=10]="IN_VALUE",T[T.WAIT_ITEM_SAPERATE=11]="WAIT_ITEM_SAPERATE",T[T.IN_ITEM_SAPERATE=12]="IN_ITEM_SAPERATE",T[T.IN_STRING=13]="IN_STRING",T[T.IN_STRING_ESCAPE=14]="IN_STRING_ESCAPE",T[T.IN_STRING2=15]="IN_STRING2",T[T.IN_STRING2_ESCAPE=16]="IN_STRING2_ESCAPE",T[T.WAIT_TEMPLATE_START=17]="WAIT_TEMPLATE_START",T[T.IN_TEMPLATE=18]="IN_TEMPLATE",T[T.WAIT_TEMPLATE_END=19]="WAIT_TEMPLATE_END",T[T.IN_TEMPLATE_STRING=20]="IN_TEMPLATE_STRING",T[T.IN_TEMPLATE_STRING_ESCAPE=21]="IN_TEMPLATE_STRING_ESCAPE",T[T.IN_TEMPLATE_STRING2=22]="IN_TEMPLATE_STRING2",T[T.IN_TEMPLATE_STRING2_ESCAPE=23]="IN_TEMPLATE_STRING2_ESCAPE",T[T.WAIT_FOR_COMMENT_START=24]="WAIT_FOR_COMMENT_START",T[T.IN_COMMENT=25]="IN_COMMENT",T[T.WAIT_FOR_COMMENT_END=26]="WAIT_FOR_COMMENT_END",T[T.MAX_STATE=27]="MAX_STATE"}(STYLE_ATTR_VALUE_STATE||(STYLE_ATTR_VALUE_STATE={})),function(T){T[T.NOTHING=0]="NOTHING",T[T.DO_ACTION=65536]="DO_ACTION",T[T.STORE_TOKEN_EXCLUDE=131072]="STORE_TOKEN_EXCLUDE",T[T.STORE_TOKEN_INCLUDE=262144]="STORE_TOKEN_INCLUDE",T[T.IGNORE=524288]="IGNORE",T[T.REFEED=1048576]="REFEED",T[T.STORE_TOKEN_FIRST=2097152]="STORE_TOKEN_FIRST",T[T.STORE_ONE_SPACE=4194304]="STORE_ONE_SPACE",T[T.STORE_ONE_LINE_BREAK=8388608]="STORE_ONE_LINE_BREAK",T[T.GET_STATE_BEFORE=16777216]="GET_STATE_BEFORE",T[T.STORE_STATE_BEFORE=33554432]="STORE_STATE_BEFORE",T[T.SET_WXS_STATE=67108864]="SET_WXS_STATE",T[T.RECORD_IN_TEMPLATE_OBJECT=134217728]="RECORD_IN_TEMPLATE_OBJECT",T[T.CHECK_IN_TEMPLATE_OBJECT=268435456]="CHECK_IN_TEMPLATE_OBJECT"}(ACTION||(ACTION={}));class Token{constructor(T,E){this.type=T,this.value=E}}class MachineState{constructor(){this.cur_pos=0,this.last_pos=0,this.line=1,this.col=1,this.mark_pos=0,this.mark_col=0,this.last_line=this.line,this.last_col=1,this.state=BASE_STATE.START,this.in_template_object_count=0}}const ALPHA="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-:",DIGIT="0123456789.",WHITECHARS=" \n\t\r";class BaseMachine{constructor(T,E){this.mState=new MachineState,this.storedStates=[],this.oldState=BASE_STATE.START,this.tokens=[],this.mPath=T,this.mSrc=E}FillTT(T,E,_,A){for(const S of A)this.TT[T][getCharCode(S)]=E|_}Reset(){return this.mState.cur_pos=0,this.mState.last_pos=0,this.mState.mark_pos=0,this.mState.line=1,this.mState.col=1,this.mState.last_col=1,this.mState.mark_col=1,this.mState.last_line=this.mState.line,this.mState.state=BASE_STATE.START,0}refeed(T){let E=this.TT[this.mState.state][getCharCode(T)];if(E===BASE_STATE.NOT_SET&&(E=this.TT[this.mState.state][BASE_STATE.OTHERS]),E===BASE_STATE.NOT_SET)throw{col:this.mState.col,line:this.mState.line,message:"BAD STATE MACHINE!"};if(E<0){if("\0"!==T)throw{col:this.mState.col,line:this.mState.line,message:`unexpected character \`${T.replace(/\n/g,"\\n")}\``};throw{col:this.mState.col,line:this.mState.line,message:"unexpected end"}}const _=E,A=65535&E,S=this.mState.state;_&ACTION.STORE_STATE_BEFORE&&(this.storedStates.push(S),this.mState.mark_pos=this.mState.cur_pos,this.mState.mark_col=this.mState.mark_col),this.mState.state=A,this.doAction(T,S,_)}Feed(T){"\n"===T&&(this.mState.line++,this.mState.col=0),this.refeed(T)}FillTT_template_string(T,E,_){const A=T+1;this.TT[T][getCharCode("\\")]=A,this.TT[A][BASE_STATE.OTHERS]=T,this.TT[T][getCharCode(_)]=E,this.TT[T][0]=BASE_STATE.ERROR,this.TT[T][BASE_STATE.OTHERS]=T}updatePosition(){this.mState.last_pos=this.mState.cur_pos,this.mState.last_col=this.mState.col,this.mState.last_line=this.mState.line}processPosition(){this.mState.cur_pos++,this.mState.col++}doAction(T,E,_){if(_&ACTION.STORE_TOKEN_FIRST&&this.mState.mark_pos>this.mState.last_pos){const T=this.mSrc.substring(this.mState.last_pos,this.mState.mark_pos);this.doExcludeAction(this.storedStates[this.storedStates.length-1],T),this.mState.last_pos=this.mState.mark_pos,this.mState.last_col=this.mState.mark_col}if(_&ACTION.STORE_ONE_LINE_BREAK&&(this.appendToken(TokenType.OTHERS,"\n"),this.updatePosition()),_&ACTION.STORE_ONE_SPACE&&(this.appendToken(TokenType.OTHERS," "),this.updatePosition()),_&ACTION.STORE_TOKEN_EXCLUDE){const T=this.mState.cur_pos,_=this.mState.last_pos;if(T>=_){const A=this.mSrc.substring(_,T);this.doExcludeAction(E,A),this.updatePosition()}}if(_&ACTION.RECORD_IN_TEMPLATE_OBJECT&&this.mState.in_template_object_count++,_&ACTION.CHECK_IN_TEMPLATE_OBJECT&&this.mState.in_template_object_count>0&&(this.mState.in_template_object_count--,this.mState.state=STATE.IN_TEMPLATE),_&ACTION.REFEED){if(_&ACTION.IGNORE&&this.updatePosition(),_&ACTION.GET_STATE_BEFORE){const T=this.storedStates.pop();T&&(this.mState.state=T)}this.refeed(T)}else{if(this.processPosition(),_&ACTION.STORE_TOKEN_INCLUDE){const _=this.mSrc.substring(this.mState.last_pos,this.mState.cur_pos);this.doIncludeAction(T,E,_),this.updatePosition()}if(_&ACTION.IGNORE&&this.updatePosition(),_&ACTION.GET_STATE_BEFORE){const T=this.storedStates.pop();T&&(this.mState.state=T)}}}}class StyleAttrValueMachine extends BaseMachine{get TT(){return StyleAttrValueMachine._TT||this.InitTransitTable(),StyleAttrValueMachine._TT}constructor(T,E){super(T,E),this.mState.state=BASE_STATE.START}getTokens(){return[...this.tokens]}appendToken(T,E){T===TokenType.STYLE_VALUE&&(E=E.replace(/[ \t]+/g," ")),this.tokens.push(new Token(T,E))}doExcludeAction(T,E){let _=TokenType.OTHERS;switch(T){case STYLE_ATTR_VALUE_STATE.IN_KEY:_=TokenType.STYLE_KEY;break;case STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE:_=TokenType.OTHERS;break;case STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE:_=TokenType.OTHERS,E=";";break;case STYLE_ATTR_VALUE_STATE.IN_VALUE:_=TokenType.STYLE_VALUE}this.appendToken(_,E)}doIncludeAction(T,E,_){let A=TokenType.OTHERS;switch(E){case STYLE_ATTR_VALUE_STATE.IN_STRING:A=TokenType.STRING1;break;case STYLE_ATTR_VALUE_STATE.IN_STRING2:A=TokenType.STRING2;break;case STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_END:A=TokenType.TEMPLATE_ITEM,_=new TemplateTokenizer(_,this.mPath).toString();break;case STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START:this.doExcludeAction(this.storedStates[this.storedStates.length-1],_.replace(/\/\*$/,"")),A=TokenType.OTHERS,_="/*";break;case STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_END:A=TokenType.OTHERS,_="*/"}this.appendToken(A,_)}FillTT_string(T,E,_){const A=T+1;this.TT[T][getCharCode("\\")]=A,this.TT[T][getCharCode("\n")]=BASE_STATE.ERROR,this.TT[A][BASE_STATE.OTHERS]=T,this.TT[A][getCharCode("\n")]=E|ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE,this.TT[T][getCharCode(_)]=E|ACTION.STORE_TOKEN_INCLUDE,this.TT[T][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[T][0]=BASE_STATE.ERROR,this.TT[T][BASE_STATE.OTHERS]=T}InitTransitTable(){StyleAttrValueMachine._TT=new Array(STYLE_ATTR_VALUE_STATE.MAX_STATE);for(let T=0;T<STYLE_ATTR_VALUE_STATE.MAX_STATE;T++){const E=new Array(257);E.fill(0),this.TT[T]=E}this.TT[BASE_STATE.END][BASE_STATE.OTHERS]=BASE_STATE.END,this.FillTT(BASE_STATE.START,BASE_STATE.START,ACTION.IGNORE," \n\t\r"),this.TT[BASE_STATE.START][getCharCode(":")]=BASE_STATE.ERROR,this.TT[BASE_STATE.START][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[BASE_STATE.START][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[BASE_STATE.START][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.TT[BASE_STATE.START][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_KEY,this.FillTT(STYLE_ATTR_VALUE_STATE.WAIT_KEY,STYLE_ATTR_VALUE_STATE.WAIT_KEY,ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY][getCharCode(":")]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.IN_KEY|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_KEY,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.FillTT(STYLE_ATTR_VALUE_STATE.IN_KEY,STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode(":")]=STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode('"')]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode("'")]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_KEY,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.FillTT(STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE,STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE,ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE][getCharCode(":")]=STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.WAIT_KEY|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.FillTT(STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE,STYLE_ATTR_VALUE_STATE.WAIT_VALUE,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode(":")]=STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode("\0")]=BASE_STATE.END|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode('"')]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode("'")]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.REFEED|ACTION.STORE_TOKEN_EXCLUDE,this.FillTT(STYLE_ATTR_VALUE_STATE.WAIT_VALUE,STYLE_ATTR_VALUE_STATE.WAIT_VALUE,ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode(":")]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode('"')]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode("'")]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode("\0")]=BASE_STATE.END,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_VALUE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode('"')]=STYLE_ATTR_VALUE_STATE.IN_STRING|ACTION.STORE_STATE_BEFORE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode("'")]=STYLE_ATTR_VALUE_STATE.IN_STRING2|ACTION.STORE_STATE_BEFORE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_VALUE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode("\0")]=BASE_STATE.END|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.FillTT(STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE,STYLE_ATTR_VALUE_STATE.WAIT_KEY,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode("'")]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode('"')]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_KEY|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode("\0")]=BASE_STATE.END|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.IN_KEY|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.IN_TEMPLATE|ACTION.STORE_TOKEN_FIRST,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START][BASE_STATE.OTHERS]=ACTION.GET_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][getCharCode("}")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_END,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][getCharCode("\\")]=BASE_STATE.ERROR,this.FillTT(STYLE_ATTR_VALUE_STATE.IN_TEMPLATE,STYLE_ATTR_VALUE_STATE.IN_TEMPLATE,ACTION.NOTHING," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_TEMPLATE,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][0]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_END][getCharCode("}")]=ACTION.GET_STATE_BEFORE|ACTION.STORE_TOKEN_INCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_END][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_TEMPLATE|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_END][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][getCharCode('"')]=STYLE_ATTR_VALUE_STATE.IN_TEMPLATE_STRING|ACTION.NOTHING,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][getCharCode("'")]=STYLE_ATTR_VALUE_STATE.IN_TEMPLATE_STRING2|ACTION.NOTHING,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START][getCharCode("*")]=STYLE_ATTR_VALUE_STATE.IN_COMMENT|ACTION.STORE_TOKEN_INCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START][BASE_STATE.OTHERS]=ACTION.GET_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_COMMENT][getCharCode("*")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_END,this.TT[STYLE_ATTR_VALUE_STATE.IN_COMMENT][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_COMMENT|ACTION.IGNORE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_END][getCharCode("/")]=ACTION.GET_STATE_BEFORE|ACTION.STORE_TOKEN_INCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_END][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_COMMENT|ACTION.NOTHING,this.FillTT_template_string(STYLE_ATTR_VALUE_STATE.IN_TEMPLATE_STRING,STYLE_ATTR_VALUE_STATE.IN_TEMPLATE|ACTION.NOTHING,'"'),this.FillTT_template_string(STYLE_ATTR_VALUE_STATE.IN_TEMPLATE_STRING2,STYLE_ATTR_VALUE_STATE.IN_TEMPLATE|ACTION.NOTHING,"'"),this.FillTT_string(STYLE_ATTR_VALUE_STATE.IN_STRING,ACTION.GET_STATE_BEFORE,'"'),this.FillTT_string(STYLE_ATTR_VALUE_STATE.IN_STRING2,ACTION.GET_STATE_BEFORE,"'")}}class TemplateMachine extends BaseMachine{get TT(){return TemplateMachine._TT||this.InitTransitTable(),TemplateMachine._TT}constructor(T,E){super(T,E),this.mState.state=BASE_STATE.START}getTokens(){return[...this.tokens]}appendToken(T,E){this.tokens.push(new Token(T,E))}doExcludeAction(T,E){let _=TokenType.OTHERS;switch(T){case TEMPLATE_STATE.IN_TEMPLATE_ITEM:case TEMPLATE_STATE.WAIT_TEMPLATE_END:_=TokenType.TEMPLATE_ITEM}this.appendToken(_,E)}doIncludeAction(T,E,_){let A=TokenType.OTHERS;switch(E){case TEMPLATE_STATE.WAIT_TEMPLATE_START:A=TokenType.TEMPLATE_START;break;case TEMPLATE_STATE.WAIT_TEMPLATE_END:A=TokenType.TEMPLATE_END}this.appendToken(A,_)}InitTransitTable(){TemplateMachine._TT=new Array(TEMPLATE_STATE.MAX_STATE);for(let T=0;T<TEMPLATE_STATE.MAX_STATE;T++){const E=new Array(257);E.fill(0),this.TT[T]=E}this.FillTT(BASE_STATE.START,BASE_STATE.START,ACTION.IGNORE," \n\t\r"),this.TT[BASE_STATE.START][getCharCode("{")]=TEMPLATE_STATE.WAIT_TEMPLATE_START,this.TT[BASE_STATE.START][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[TEMPLATE_STATE.WAIT_TEMPLATE_START][getCharCode("{")]=TEMPLATE_STATE.IN_TEMPLATE_ITEM|ACTION.STORE_TOKEN_INCLUDE,this.TT[TEMPLATE_STATE.WAIT_TEMPLATE_START][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.FillTT(TEMPLATE_STATE.IN_TEMPLATE_SPACE,TEMPLATE_STATE.IN_TEMPLATE_SPACE,ACTION.IGNORE," \n\t\r"),this.TT[TEMPLATE_STATE.IN_TEMPLATE_SPACE][getCharCode("}")]=TEMPLATE_STATE.WAIT_TEMPLATE_END,this.TT[TEMPLATE_STATE.IN_TEMPLATE_SPACE][getCharCode('"')]=TEMPLATE_STATE.IN_TEMPLATE_STRING|ACTION.STORE_STATE_BEFORE,this.TT[TEMPLATE_STATE.IN_TEMPLATE_SPACE][getCharCode("'")]=TEMPLATE_STATE.IN_TEMPLATE_STRING2|ACTION.STORE_STATE_BEFORE,this.TT[TEMPLATE_STATE.IN_TEMPLATE_SPACE][getCharCode("/")]=TEMPLATE_STATE.WAIT_FOR_COMMENT_START,this.TT[TEMPLATE_STATE.IN_TEMPLATE_SPACE][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_TEMPLATE_ITEM,this.FillTT(TEMPLATE_STATE.IN_TEMPLATE_ITEM,TEMPLATE_STATE.IN_TEMPLATE_SPACE,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][getCharCode("}")]=TEMPLATE_STATE.WAIT_TEMPLATE_END,this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][getCharCode("\\")]=BASE_STATE.ERROR,this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][getCharCode('"')]=TEMPLATE_STATE.IN_TEMPLATE_STRING|ACTION.STORE_STATE_BEFORE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][getCharCode("'")]=TEMPLATE_STATE.IN_TEMPLATE_STRING2|ACTION.STORE_STATE_BEFORE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_TEMPLATE_ITEM,this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][0]=BASE_STATE.ERROR,this.TT[TEMPLATE_STATE.WAIT_FOR_COMMENT_START][getCharCode("*")]=TEMPLATE_STATE.IN_COMMENT,this.FillTT(TEMPLATE_STATE.WAIT_FOR_COMMENT_START,TEMPLATE_STATE.IN_TEMPLATE_ITEM,ACTION.REFEED," \n\t\r"),this.TT[TEMPLATE_STATE.WAIT_FOR_COMMENT_START][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_TEMPLATE_ITEM,this.TT[TEMPLATE_STATE.IN_COMMENT][getCharCode("*")]=TEMPLATE_STATE.WAIT_FOR_COMMENT_END,this.TT[TEMPLATE_STATE.IN_COMMENT][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_COMMENT,this.TT[TEMPLATE_STATE.WAIT_FOR_COMMENT_END][getCharCode("/")]=TEMPLATE_STATE.IN_TEMPLATE_SPACE|ACTION.IGNORE,this.FillTT_template_string(TEMPLATE_STATE.IN_TEMPLATE_STRING,TEMPLATE_STATE.IN_TEMPLATE_ITEM|ACTION.STORE_TOKEN_INCLUDE|ACTION.GET_STATE_BEFORE,'"'),this.FillTT_template_string(TEMPLATE_STATE.IN_TEMPLATE_STRING2,TEMPLATE_STATE.IN_TEMPLATE_ITEM|ACTION.STORE_TOKEN_INCLUDE|ACTION.GET_STATE_BEFORE,"'"),this.TT[TEMPLATE_STATE.WAIT_TEMPLATE_END][getCharCode("}")]=BASE_STATE.END|ACTION.STORE_TOKEN_INCLUDE,this.FillTT(TEMPLATE_STATE.WAIT_TEMPLATE_END,TEMPLATE_STATE.SPACE_AFTER_WAIT_TEMPLATE_END,ACTION.STORE_TOKEN_EXCLUDE," \n\t\r"),this.TT[TEMPLATE_STATE.WAIT_TEMPLATE_END][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_TEMPLATE_ITEM|ACTION.REFEED,this.FillTT(TEMPLATE_STATE.SPACE_AFTER_WAIT_TEMPLATE_END,TEMPLATE_STATE.SPACE_AFTER_WAIT_TEMPLATE_END,ACTION.IGNORE," \n\t\r"),this.TT[TEMPLATE_STATE.SPACE_AFTER_WAIT_TEMPLATE_END][getCharCode("}")]=TEMPLATE_STATE.WAIT_TEMPLATE_END|ACTION.STORE_ONE_SPACE,this.TT[TEMPLATE_STATE.SPACE_AFTER_WAIT_TEMPLATE_END][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_TEMPLATE_ITEM|ACTION.IGNORE|ACTION.REFEED,this.FillTT(BASE_STATE.END,BASE_STATE.END,ACTION.IGNORE," \n\t\r"),this.TT[BASE_STATE.END][getCharCode("\0")]=BASE_STATE.END,this.TT[BASE_STATE.END][BASE_STATE.OTHERS]=BASE_STATE.ERROR}}class TemplateTokenizer{constructor(T,E){this.machine=new TemplateMachine(E,T),this.m_pSrc=T,this.path=E}toString(){this.tokens||(this.tokens=this.generateTokens());return this.tokens.map((T=>T.value)).join("")}generateTokens(){if(this.machine.Reset(),0===this.m_pSrc.length)return[];for(let T=0;T<this.m_pSrc.length;T++){const E=this.m_pSrc[T];this.machine.Feed(E)}return this.machine.Feed("\0"),this.machine.getTokens()}}exports.TemplateTokenizer=TemplateTokenizer;class StyleAttrValueTokenizer{constructor(T,E){this.machine=new StyleAttrValueMachine(E,T),this.m_pSrc=T,this.path=E}toString(){return this.tokens||(this.tokens=this.generateTokens()),this.tokens.map((T=>T.value)).join("")}generateTokens(){if(this.machine.Reset(),0===this.m_pSrc.length)return[];for(let T=0;T<this.m_pSrc.length;T++){const E=this.m_pSrc[T];this.machine.Feed(E)}return this.machine.Feed("\0"),this.machine.getTokens()}}exports.StyleAttrValueTokenizer=StyleAttrValueTokenizer;class Machine extends BaseMachine{get TT(){return Machine._TT||this.InitTransitTable(),Machine._TT}constructor(T,E){super(T,E),this.tagStack=[],this.InitTransitTable(),this.mPath=T,this.mSrc=E}get wxsState(){return"wxs"===this.tagStack[this.tagStack.length-1]}get textState(){return"text"===this.tagStack[this.tagStack.length-1]}getTokens(){return[...this.tokens]}checkLastTokenIfTypeMatch(T){var E;return(null===(E=this.tokens[this.tokens.length-1])||void 0===E?void 0:E.type)===T?this.tokens[this.tokens.length-1]:void 0}getLastTokenIfTypeMatch(T){if(0!==this.tokens.length)for(let E=this.tokens.length-1;E>=0;E--){const _=this.tokens[E];if(_.type===T)return _}}canBeOmittedTokenType(T){return T===TokenType.WXS_VALUE}appendToken(T,E){if(this.canBeOmittedTokenType(T)&&(E=this.transTagTextTokenValue(E)),T===TokenType.ATTR_VALUE){const T=this.getLastTokenIfTypeMatch(TokenType.ATTR);"style"===(null==T?void 0:T.value)&&(E=this.trySlimStyleAttrValue(E))}E&&this.tokens.push(new Token(T,E))}transTagTextTokenValue(T){return this.wxsState?T=T.split("\n").map((T=>T.trim())).join("\n"):T}trySlimStyleAttrValue(T){const E=[];try{if(T.length<=1)return T;for(let T=this.tokens.length-1;T>=0;T--){if(this.tokens[T].type===TokenType.TAG_EQ)break;E.unshift(this.tokens.pop())}const _=`${E.map((T=>null==T?void 0:T.value)).join("")}${T}`,A=_.startsWith('"')||_.startsWith("'"),S=_.endsWith('"')||_.endsWith("'"),t=new StyleAttrValueTokenizer(_.replace(/^['"]/,"").replace(/['"]$/,""),this.mPath).toString();return`${A?_.substr(0,1):""}${t}${S?_.substr(_.length-1,1):""}`}catch(T){this.tokens.push(...E)}return T}doExcludeAction(T,E){let _=TokenType.OTHERS;switch(T){case STATE.IN_TAG_ATTR_VALUE_STRING:case STATE.IN_TAG_ATTR_VALUE_STRING_SINGLE:_=TokenType.ATTR_VALUE;break;case STATE.IN_TAG_WORD:_=TokenType.TAG,this.tagStack.push(E);break;case STATE.IN_END_TAG_WORD:_=TokenType.TAG;if(this.tagStack.pop()!==E)throw{col:this.mState.col-E.length,line:this.mState.line,message:`unexpected end tag: ${E}`};break;case STATE.IN_WXS:_=TokenType.WXS_VALUE;break;case STATE.IN_TEXT:_=TokenType.TEXT_VALUE;break;case STATE.IN_TAG_TEXT:_=TokenType.TAG_TEXT_VALUE;break;case STATE.IN_TAG_ATTR_WORD:_=TokenType.ATTR;break;case STATE.TAG_START:_=TokenType.LEFT_ANGLE_BRACKET;break;case STATE.IN_TEMPLATE:_=TokenType.TEMPLATE_ITEM;break;case STATE.TAG_EQ:_=TokenType.TAG_EQ;break;case STATE.TEMPLATE_END_CHECK:{const T=this.mState.cur_pos;if("}"===this.mSrc.substring(T-3,T-2))throw{col:this.mState.col-3,line:this.mState.line,message:"unexpected end tag: }. } should not be followed by }} direactly, add a space and change it to } }}"};this.appendToken(TokenType.TEMPLATE_ITEM,`${new TemplateTokenizer(E,this.mPath)}`),_=TokenType.TEMPLATE_END,E=""}}this.appendToken(_,E)}doIncludeAction(T,E,_){const A=this.mState.state;let S;E===STATE.WXS_END_STEP?(this.appendToken(TokenType.WXS_VALUE,_.substr(0,_.length-2)),S=TokenType.END_LEFT_ANGLE_BRACKET,_="</"):E===STATE.IN_WXS_STRING||E===STATE.IN_WXS_STRING_SINGLE?S=TokenType.WXS_VALUE:E===STATE.IN_TAG_ATTR_VALUE_STRING||E===STATE.IN_TAG_ATTR_VALUE_STRING_SINGLE?S=TokenType.ATTR_VALUE:E===STATE.TAG_START&&A===STATE.IN_END_TAG?S=TokenType.END_LEFT_ANGLE_BRACKET:E===STATE.WAIT_FOR_RIGHT_BRACKET?(S=TokenType.SELF_CLOSE,this.tagStack.pop()):S=TokenType.OTHERS,">"!==T||E!==STATE.IN_TAG_WORD&&E!==STATE.IN_TAG_ATTR_WORD&&E!==STATE.IN_TAG_ATTR_VALUE_STRING&&E!==STATE.IN_TAG_ATTR_VALUE_STRING_SINGLE&&E!==STATE.IN_END_TAG_WORD||(S=TokenType.RIGHT_ANGLE_BRACKET),this.appendToken(S,_)}Feed(T){super.Feed(T),this.wxsState&&this.mState.state===STATE.IN_TAG_TEXT&&(this.mState.state=STATE.IN_WXS),this.textState&&this.mState.state===STATE.IN_TAG_TEXT&&(this.mState.state=STATE.IN_TEXT)}FillTT_attr_string(T,E,_){const A=T+1;this.TT[T][getCharCode("\\")]=A,this.TT[A][BASE_STATE.OTHERS]=T,this.TT[A][getCharCode("\n")]=E|ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE,this.TT[T][getCharCode(_)]=E|ACTION.STORE_TOKEN_INCLUDE,this.TT[T][getCharCode("{")]=STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[T][0]=BASE_STATE.ERROR,this.TT[T][BASE_STATE.OTHERS]=T}InitTransitTable(){Machine._TT=new Array(STATE.MAX_STATE);for(let T=0;T<STATE.MAX_STATE;T++){const E=new Array(257);E.fill(0),this.TT[T]=E}this.TT[BASE_STATE.END][BASE_STATE.OTHERS]=BASE_STATE.END,this.TT[BASE_STATE.START][getCharCode("<")]=STATE.TAG_START|ACTION.STORE_TOKEN_EXCLUDE|ACTION.STORE_STATE_BEFORE,this.TT[BASE_STATE.START][getCharCode("{")]=STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[BASE_STATE.START][BASE_STATE.OTHERS]=STATE.IN_TAG_TEXT|ACTION.NOTHING,this.TT[BASE_STATE.START][0]=BASE_STATE.END|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TAG_TEXT][getCharCode("<")]=STATE.TAG_START|ACTION.STORE_TOKEN_EXCLUDE|ACTION.STORE_STATE_BEFORE,this.TT[STATE.IN_TAG_TEXT][getCharCode("{")]=STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[STATE.IN_TAG_TEXT][BASE_STATE.OTHERS]=STATE.IN_TAG_TEXT|ACTION.NOTHING,this.TT[STATE.IN_TAG_TEXT][0]=BASE_STATE.END|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TAG_TEXT][BASE_STATE.OTHERS]=STATE.IN_TAG_TEXT,this.TT[STATE.WAIT_TEMPLATE_START][getCharCode("{")]=STATE.IN_TEMPLATE|ACTION.STORE_TOKEN_FIRST,this.TT[STATE.WAIT_TEMPLATE_START][BASE_STATE.OTHERS]=STATE.IN_TAG_TEXT|ACTION.GET_STATE_BEFORE,this.TT[STATE.IN_TEMPLATE][getCharCode("{")]=STATE.IN_TEMPLATE|ACTION.RECORD_IN_TEMPLATE_OBJECT,this.TT[STATE.IN_TEMPLATE][getCharCode("}")]=STATE.WAIT_TEMPLATE_END|ACTION.CHECK_IN_TEMPLATE_OBJECT,this.TT[STATE.IN_TEMPLATE][getCharCode("\\")]=BASE_STATE.ERROR,this.FillTT(STATE.IN_TEMPLATE,STATE.IN_TEMPLATE,ACTION.NOTHING," \n\t\r"),this.TT[STATE.IN_TEMPLATE][BASE_STATE.OTHERS]=STATE.IN_TEMPLATE,this.TT[STATE.IN_TEMPLATE][0]=BASE_STATE.ERROR,this.TT[STATE.WAIT_TEMPLATE_END][getCharCode("}")]=STATE.TEMPLATE_END_CHECK,this.TT[STATE.TEMPLATE_END_CHECK][BASE_STATE.OTHERS]=STATE.IN_TAG_TEXT|ACTION.REFEED|ACTION.STORE_TOKEN_EXCLUDE|ACTION.GET_STATE_BEFORE,this.TT[STATE.WAIT_TEMPLATE_END][BASE_STATE.OTHERS]=STATE.IN_TEMPLATE|ACTION.REFEED,this.TT[STATE.IN_TEMPLATE][getCharCode('"')]=STATE.IN_TEMPLATE_STRING|ACTION.NOTHING,this.TT[STATE.IN_TEMPLATE][getCharCode("'")]=STATE.IN_TEMPLATE_STRING2|ACTION.NOTHING,this.FillTT_template_string(STATE.IN_TEMPLATE_STRING,STATE.IN_TEMPLATE|ACTION.NOTHING,'"'),this.FillTT_template_string(STATE.IN_TEMPLATE_STRING2,STATE.IN_TEMPLATE|ACTION.NOTHING,"'"),this.FillTT(STATE.TAG_START,STATE.TAG_START,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.FillTT(STATE.TAG_START,STATE.IN_TAG_WORD,ACTION.STORE_TOKEN_EXCLUDE,ALPHA),this.TT[STATE.TAG_START][getCharCode("/")]=STATE.IN_END_TAG|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.TAG_START][getCharCode("!")]=STATE.IN_COMMENT_BEGIN1,this.TT[STATE.TAG_START][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STATE.IN_COMMENT_BEGIN1][getCharCode("-")]=STATE.IN_COMMENT_BEGIN2,this.TT[STATE.IN_COMMENT_BEGIN1][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STATE.IN_COMMENT_BEGIN2][getCharCode("-")]=STATE.IN_COMMENT,this.TT[STATE.IN_COMMENT_BEGIN2][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STATE.IN_COMMENT][getCharCode("-")]=STATE.WAIT_FOR_COMMENT_END1,this.TT[STATE.IN_COMMENT][BASE_STATE.OTHERS]=STATE.IN_COMMENT,this.TT[STATE.WAIT_FOR_COMMENT_END1][getCharCode("-")]=STATE.WAIT_FOR_COMMENT_END2,this.TT[STATE.WAIT_FOR_COMMENT_END1][BASE_STATE.OTHERS]=STATE.IN_COMMENT,this.TT[STATE.WAIT_FOR_COMMENT_END2][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.IGNORE|ACTION.GET_STATE_BEFORE,this.TT[STATE.WAIT_FOR_COMMENT_END2][getCharCode("-")]=STATE.WAIT_FOR_COMMENT_END2,this.TT[STATE.WAIT_FOR_COMMENT_END2][BASE_STATE.OTHERS]=STATE.IN_COMMENT,this.FillTT(STATE.IN_TAG_WORD,STATE.IN_TAG_WORD,ACTION.NOTHING,ALPHA),this.FillTT(STATE.IN_TAG_WORD,STATE.IN_TAG_WORD,ACTION.NOTHING,DIGIT),this.FillTT(STATE.IN_TAG_WORD,STATE.IN_TAG_ATTR_WORD,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STATE.IN_TAG_WORD][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.STORE_TOKEN_EXCLUDE|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.IN_TAG_WORD][getCharCode("/")]=STATE.WAIT_FOR_RIGHT_BRACKET|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TAG_WORD][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STATE.IN_TAG_WORD][0]=BASE_STATE.ERROR,this.FillTT(STATE.IN_TAG_ATTR_WORD,STATE.IN_TAG_ATTR_WORD,ACTION.NOTHING,ALPHA),this.FillTT(STATE.IN_TAG_ATTR_WORD,STATE.IN_TAG_ATTR_WORD,ACTION.NOTHING,DIGIT),this.FillTT(STATE.IN_TAG_ATTR_WORD,STATE.IN_TAG_ATTR_WORD,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STATE.IN_TAG_ATTR_WORD][getCharCode("=")]=STATE.TAG_EQ|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TAG_ATTR_WORD][getCharCode('"')]=BASE_STATE.ERROR,this.TT[STATE.IN_TAG_ATTR_WORD][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.STORE_TOKEN_EXCLUDE|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.IN_TAG_ATTR_WORD][getCharCode("/")]=STATE.WAIT_FOR_RIGHT_BRACKET|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TAG_ATTR_WORD][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STATE.IN_TAG_ATTR_WORD][0]=BASE_STATE.ERROR,this.FillTT(STATE.TAG_EQ,STATE.TAG_EQ,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.FillTT(STATE.TAG_EQ,STATE.IN_TAG_ATTR_VALUE_STRING,ACTION.STORE_TOKEN_EXCLUDE,ALPHA),this.TT[STATE.TAG_EQ][getCharCode('"')]=STATE.IN_TAG_ATTR_VALUE_STRING|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.TAG_EQ][getCharCode("'")]=STATE.IN_TAG_ATTR_VALUE_STRING_SINGLE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.TAG_EQ][0]=BASE_STATE.ERROR,this.TT[STATE.TAG_EQ][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.FillTT(STATE.IN_END_TAG,STATE.IN_END_TAG,ACTION.IGNORE," \n\t\r"),this.FillTT(STATE.IN_END_TAG,STATE.IN_END_TAG_WORD,ACTION.NOTHING,ALPHA),this.FillTT(STATE.IN_END_TAG,BASE_STATE.ERROR,ACTION.NOTHING,DIGIT),this.TT[STATE.IN_END_TAG][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.IN_END_TAG][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.FillTT(STATE.IN_END_TAG_WORD,STATE.IN_END_TAG_WORD,ACTION.NOTHING,ALPHA),this.FillTT(STATE.IN_END_TAG_WORD,STATE.IN_END_TAG_WORD,ACTION.NOTHING,DIGIT),this.FillTT(STATE.IN_END_TAG_WORD,STATE.IN_END_TAG,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STATE.IN_END_TAG_WORD][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.STORE_TOKEN_EXCLUDE|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.IN_END_TAG_WORD][getCharCode("/")]=STATE.WAIT_FOR_RIGHT_BRACKET|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_END_TAG_WORD][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.FillTT(STATE.WAIT_FOR_RIGHT_BRACKET,STATE.IN_TAG_WORD,ACTION.STORE_TOKEN_EXCLUDE,ALPHA),this.TT[STATE.WAIT_FOR_RIGHT_BRACKET][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.WAIT_FOR_RIGHT_BRACKET][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.FillTT_attr_string(STATE.IN_TAG_ATTR_VALUE_STRING,STATE.IN_TAG_ATTR_WORD,'"'),this.FillTT_attr_string(STATE.IN_TAG_ATTR_VALUE_STRING_SINGLE,STATE.IN_TAG_ATTR_WORD,"'"),this.TT[STATE.IN_WXS][getCharCode("<")]=STATE.WXS_END_STEP,this.TT[STATE.IN_WXS][getCharCode('"')]=STATE.IN_WXS_STRING|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_WXS][getCharCode("'")]=STATE.IN_WXS_STRING_SINGLE|ACTION.STORE_TOKEN_EXCLUDE,this.FillTT_attr_string(STATE.IN_WXS_STRING,STATE.IN_WXS,'"'),this.FillTT_attr_string(STATE.IN_WXS_STRING_SINGLE,STATE.IN_WXS,"'"),this.TT[STATE.IN_WXS][BASE_STATE.OTHERS]=STATE.IN_WXS,this.TT[STATE.WXS_END_STEP][getCharCode("/")]=STATE.IN_END_TAG|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.WXS_END_STEP][BASE_STATE.OTHERS]=STATE.IN_WXS,this.TT[STATE.IN_TEXT][getCharCode("<")]=STATE.TAG_START|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TEXT][BASE_STATE.OTHERS]=STATE.IN_TEXT,this.TT[STATE.IN_TEXT][getCharCode("{")]=STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE}}class Tokenizer{constructor(T,E){this.machine=new Machine(E,T),this.m_pSrc=T,this.path=E}generateTokens(){if(this.machine.Reset(),0===this.m_pSrc.length)return[];try{for(let T=0;T<this.m_pSrc.length;T++){const E=this.m_pSrc[T];this.machine.Feed(E)}this.machine.Feed("\0")}catch(T){throw new Error(`${T.line}:${T.col}:${T.message}`)}return this.machine.getTokens()}}function generateWXMLFromTokens(T,E={collapseWhitespace:!0,conservativeCollapse:!1,preserveLineBreaks:!1}){const{collapseWhitespace:_,conservativeCollapse:A,preserveLineBreaks:S}=E,t=[];for(let E=0;E<T.length;E++){const e=T[E];let N=e.value;const R=e.type;if(R===TokenType.ATTR&&(N=` ${N}`),R===TokenType.TAG_TEXT_VALUE){S||(N=N.replace(/\n/g," ")),_&&(N=N.replace(/([ \t])+/g," "));const t=T[E-1];t&&t.type!==TokenType.RIGHT_ANGLE_BRACKET&&t.type!==TokenType.SELF_CLOSE||_&&!A&&(N=trimStringLeft(N,!1)),(null==t?void 0:t.type)===TokenType.TAG_TEXT_VALUE&&((null==t?void 0:t.value.endsWith(" "))||(null==t?void 0:t.value.endsWith("\n")))&&_&&(N=trimStringLeft(N,!1))}if(R===TokenType.LEFT_ANGLE_BRACKET||R===TokenType.END_LEFT_ANGLE_BRACKET){const S=T[E-1];if((null==S?void 0:S.type)===TokenType.TAG_TEXT_VALUE&&_&&!A){const T=t.pop()||"";t.push(trimStringRight(T,!1))}}t.push(N)}return t.join("")}async function minifyWXML(T){const{filePath:E,root:_=""}=T,A=T.code instanceof Buffer?T.code.toString():T.code,S=Object.assign({collapseWhitespace:!0,conservativeCollapse:!1,preserveLineBreaks:!1},T.setting),t=path_1.default.posix.join(_,E);if(A.length>0)try{const T=new Tokenizer(A.replace(/\r\n/g,"\n"),t);return{error:null,code:generateWXMLFromTokens(T.generateTokens(),S)}}catch(T){return log.error(`minifywxml error @ ${t}`),log.error(T.message),{error:{code:config_1.MINIFY_WXML_ERR,path:t,message:T.message}}}return{error:null,code:A.replace(/\r\n/g,"\n")}}
@@ -1 +1 @@
1
- var _a;process.env&&process.env.isDevtools&&require("../../../../utils/hackrequire/index"),Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib");(null===(_a=process.env)||void 0===_a?void 0:_a.isDevtools)&&require("../../../../utils/hackrequire/index");const worker_threads_1=require("worker_threads"),logger_1=require("../utils/logger"),index_1=tslib_1.__importDefault(require("./task/index")),config_1=require("./config");worker_threads_1.isMainThread?module.exports=index_1.default:worker_threads_1.parentPort.on("message",e=>{const{command:r,data:o}=e;r===config_1.COMMAND.RUN_TASK&&(logger_1.logger.info("worker process task start",r,o.data.filePath),(0,index_1.default)(o.taskName,o.data).then(e=>{logger_1.logger.info("worker process task end",r,o.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");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 +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")),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,workerManagerInstance,supportWorkerThread=!1;try{Worker=require("worker_threads").Worker,supportWorkerThread=!0}catch(e){supportWorkerThread=!1}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=()=>{}}async init(){envIsDevtools&&(this._suicideTime=config_1.SUICIDE_TIME.devtools);const e={NODE_PATH:path_1.default.posix.join(getCurrentScriptPath(),"../../../node_modules"),isDevtools:String(envIsDevtools)};supportWebWorkerThread||(supportWorkerThread?(logger_1.logger.info("create worker start"),this._instance=new Worker(WORKER_PATH,{env:Object.assign(Object.assign({},e),{cpprocessEnv:"workerthread"}),stdout:!0}),this.threadId=this._instance.threadId,this._postMessage=this._instance.postMessage.bind(this._instance)):(this._instance=(0,child_process_1.fork)(FORK_PATH,[""],{env:Object.assign(Object.assign({},e),{cpprocessEnv:"workerprocess"})}),this.threadId=this._instance.pid,this._postMessage=this._instance.send.bind(this._instance)));const t=e=>{const{command:t,data:s}=e;t===config_1.COMMAND.TASK_DONE&&this.onTaskDone(s),t===config_1.COMMAND.SEND_LOG&&logger_1.logger.send(s.level,s.args),t===config_1.COMMAND.CALL_FUNC&&call_func_1.call.apply(null,[s.funcName,...s.args]).then(e=>{this._postMessage({command:config_1.COMMAND.CALL_FUNC_RESULT,data:{id:s.id,result:e}})}).catch(e=>{this._postMessage({command:config_1.COMMAND.CALL_FUNC_RESULT,data:{id:s.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))}on(e,t){return super.on(e,t)}onTaskDone(e){var t;this.status=config_1.EWorkerStatus.free,(null===(t=this._task)||void 0===t?void 0:t.resolve)&&(this._task.onStatusUpdate(config_1.ETaskStatus.done),this._task.resolve(e)),this._task=void 0,this.emit("taskDone",this.threadId),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._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.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=>{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()})}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 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 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OriginalCompiler=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=tslib_1.__importDefault(require("lodash")),baseCompiler_1=require("./baseCompiler"),original_1=require("./original"),tools_1=require("../../utils/tools");class OriginalCompiler extends baseCompiler_1.BaseCoreCompiler{async waitSubProcessReady(){}constructor(e){super(e),this.isSummer=!1,this.ready()}destroy(){this._checkReadyTask=void 0,this.compileManager=void 0}async init(){this.compileManager=new original_1.OriginalCompileManager(this.project)}async isGameApp(){if(!this.project)return!1;const e=await this.project.attr();return null==e?void 0:e.gameApp}checkProject(){}async getExtJSON(){return await this.compileManager.getExtJSON()}async getAppJSON(){return this.checkProject(),await this.compileManager.getAppJSON()}async getSiteMapJSON(){const e=await this.compileManager.getSiteMapJSON();return lodash_1.default.cloneDeep(e)}async getPageJSON(e){this.checkProject();return await this.compileManager.getPageJSON({miniprogramRoot:this.project.miniprogramRoot,pagePath:e})}async getGameJSON(){return this.checkProject(),this.compileManager.getGameJSON()}async getPluginJSON(e=""){return this.checkProject(),await this.compileManager.getPluginJSON(e)}async getPluginPageJSON(e){this.checkProject();return await this.compileManager.getPluginPageJSON({root:this.project.pluginRoot,project:this.project,filePath:path_1.default.posix.join(this.project.pluginRoot||"",e+".json")})}async getPluginComponents(){var e;const t=this.getPluginJSONFileList(),o=[];for(let i=0,r=t.length;i<r;i++){const r=t[i].replace(/\.json$/,"");"plugin"!==path_1.default.normalize(r)&&(this.isValidComponent(null===(e=this.project)||void 0===e?void 0:e.pluginRoot,r)&&o.push(r))}return o}getWxssMap(e,t){throw new Error("Method not implemented.")}async getPluginJSFiles(){const e=this.getPluginJSFileList();return{jsFiles:e,content:e.reduce((e,t)=>{var o;return e[t]=this.project.getFile((null===(o=this.project)||void 0===o?void 0:o.pluginRoot)||"",t).toString(),e},{})}}async getPluginWxssFiles(){const e=this.getPluginWXSSFileList();return{wxssFiles:e,content:e.reduce((e,t)=>{var o;return e[t]=this.project.getFile((null===(o=this.project)||void 0===o?void 0:o.pluginRoot)||"",t).toString(),e},{})}}async getPluginWxmlAndWxsFiles(){const e=this.getPluginWXSFileList(),t=this.getPluginWXMLFileList(),o=e.concat(t);return{wxsFiles:e,wxmlFiles:t,content:o.reduce((e,t)=>{var o;return e[t]=this.project.getFile((null===(o=this.project)||void 0===o?void 0:o.pluginRoot)||"",t).toString(),e},{})}}async getMPFileInfo(){var e,t;const o=null===(e=this.project)||void 0===e?void 0:e.miniprogramRoot;return this.excludeKeyRoot(this.getAllFileInfo(null===(t=this.project)||void 0===t?void 0:t.miniprogramRoot),o)}async getPluginFileInfo(){var e,t;const o=null===(e=this.project)||void 0===e?void 0:e.pluginRoot;return this.excludeKeyRoot(this.getAllFileInfo(null===(t=this.project)||void 0===t?void 0:t.pluginRoot),o)}async checkThemeJSON(e){return this.checkProject(),await this.compileManager.checkThemeJSON(e)}async compile(e){return this.checkProject(),await this.compileManager.compile({nameMapping:e.nameMapping||{},setting:e.setting,onProgressUpdate:e.onProgressUpdate,__compileDebugInfo__:e.__compileDebugInfo__,compilePages:e.compilePages,analyzer:e.analyzer,devToolsCompileCache:e.devToolsCompileCache,disableSpreadingUsingComponents:e.disableSpreadingUsingComponents,resultType:e.resultType})}async compileJS(e){this.checkProject();const{root:t,filePath:o,babelRoot:i="@babel/runtime"}=e;try{return await this.compileManager.compileJS(o,{root:t,sourceCode:e.sourceCode,setting:Object.assign({},e.setting),babelRoot:i,onProgressUpdate:e.onProgressUpdate})}catch(e){throw e}}setLocale(e){this.compileManager.setLocale(e)}clearCache(){this.compileManager.clearCache()}async getPackageWxssFileList(e){return[]}async getPackageWxssFiles(e){return{}}async getPackageWxmlAndWxsFiles(e){return{}}async getAllWxmlAndWxsFiles(){return{}}getAllSortedJSFiles(){throw new Error("Method not implemented.")}getMainPkgSortedJSFiles(){throw new Error("Method not implemented.")}async getPackageFiles(e,t){if(this.isGameType(e)){const e=await this.getGameJSON(),o=this.getMPFileList();let i=e.workers||"";i="string"==typeof i?i:i.path;const r=e.openDataContext,n={__APP__:[],[r]:[]};i&&(n[i]=[]);for(const t of o)if(r&&(0,tools_1.isLeftSubPathOfRight)(t,r))n[r].push({path:t,source:t,sourceExt:path_1.default.extname(t),independentRoot:r,isBabelIgnore:!1});else if(i&&(0,tools_1.isLeftSubPathOfRight)(t,i))n[i].push({path:t,source:t,sourceExt:path_1.default.extname(t),independentRoot:"object"==typeof e.workers&&e.workers.isSubpackage?i:"",isBabelIgnore:!1});else{if(e.subPackages){let o=!1;for(const i of e.subPackages){const e=i.root.replace(/^\//,"");if((0,tools_1.isLeftSubPathOfRight)(t,e)){n[i.root]||(n[e]=[]),n[e].push({path:t,source:t,sourceExt:path_1.default.extname(t),independentRoot:i.independent?e:"",isBabelIgnore:!1}),o=!0;break}}if(o)continue}n.__APP__.push({path:t,source:t,sourceExt:path_1.default.extname(t),independentRoot:"",isBabelIgnore:!1})}return n[t]||[]}throw new Error("Method not implemented.")}getSubPkgSortedJSFiles(e){throw new Error("Method not implemented.")}getCompAndPagesOfConf(){throw new Error("Method not implemented.")}async getAllPageAndComponent(){var e;const t=this.getMPJSONFileList(),o=[];for(let i=0,r=t.length;i<r;i++){const r=t[i].replace(/\.json$/,"");this.isValidComponent(null===(e=this.project)||void 0===e?void 0:e.miniprogramRoot,r)&&o.push(r)}return o}}exports.OriginalCompiler=OriginalCompiler;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OriginalCompiler=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=tslib_1.__importDefault(require("lodash")),baseCompiler_1=require("./baseCompiler"),original_1=require("./original"),tools_1=require("../../utils/tools");class OriginalCompiler extends baseCompiler_1.BaseCoreCompiler{async waitSubProcessReady(){}constructor(e){super(e),this.isSummer=!1,this.ready()}destroy(){this._checkReadyTask=void 0,this.compileManager=void 0}async init(){this.compileManager=new original_1.OriginalCompileManager(this.project)}async isGameApp(){if(!this.project)return!1;const e=await this.project.attr();return null==e?void 0:e.gameApp}checkProject(){}async getExtJSON(){return await this.compileManager.getExtJSON()}async getAppJSON(){return this.checkProject(),await this.compileManager.getAppJSON()}async getSiteMapJSON(){const e=await this.compileManager.getSiteMapJSON();return lodash_1.default.cloneDeep(e)}async getPageJSON(e){this.checkProject();return await this.compileManager.getPageJSON({miniprogramRoot:this.project.miniprogramRoot,pagePath:e})}async getGameJSON(){return this.checkProject(),this.compileManager.getGameJSON()}async getPluginJSON(e=""){return this.checkProject(),await this.compileManager.getPluginJSON(e)}async getPluginPageJSON(e){this.checkProject();return await this.compileManager.getPluginPageJSON({root:this.project.pluginRoot,project:this.project,filePath:path_1.default.posix.join(this.project.pluginRoot||"",`${e}.json`)})}async getPluginComponents(){var e;const t=this.getPluginJSONFileList(),o=[];for(let i=0,r=t.length;i<r;i++){const r=t[i].replace(/\.json$/,"");"plugin"!==path_1.default.normalize(r)&&(this.isValidComponent(null===(e=this.project)||void 0===e?void 0:e.pluginRoot,r)&&o.push(r))}return o}getWxssMap(e,t){throw new Error("Method not implemented.")}async getPluginJSFiles(){const e=this.getPluginJSFileList();return{jsFiles:e,content:e.reduce(((e,t)=>{var o;return e[t]=this.project.getFile((null===(o=this.project)||void 0===o?void 0:o.pluginRoot)||"",t).toString(),e}),{})}}async getPluginWxssFiles(){const e=this.getPluginWXSSFileList();return{wxssFiles:e,content:e.reduce(((e,t)=>{var o;return e[t]=this.project.getFile((null===(o=this.project)||void 0===o?void 0:o.pluginRoot)||"",t).toString(),e}),{})}}async getPluginWxmlAndWxsFiles(){const e=this.getPluginWXSFileList(),t=this.getPluginWXMLFileList(),o=e.concat(t);return{wxsFiles:e,wxmlFiles:t,content:o.reduce(((e,t)=>{var o;return e[t]=this.project.getFile((null===(o=this.project)||void 0===o?void 0:o.pluginRoot)||"",t).toString(),e}),{})}}async getMPFileInfo(){var e,t;const o=null===(e=this.project)||void 0===e?void 0:e.miniprogramRoot;return this.excludeKeyRoot(this.getAllFileInfo(null===(t=this.project)||void 0===t?void 0:t.miniprogramRoot),o)}async getPluginFileInfo(){var e,t;const o=null===(e=this.project)||void 0===e?void 0:e.pluginRoot;return this.excludeKeyRoot(this.getAllFileInfo(null===(t=this.project)||void 0===t?void 0:t.pluginRoot),o)}async checkThemeJSON(e){return this.checkProject(),await this.compileManager.checkThemeJSON(e)}async compile(e){return this.checkProject(),await this.compileManager.compile({nameMapping:e.nameMapping||{},setting:e.setting,onProgressUpdate:e.onProgressUpdate,__compileDebugInfo__:e.__compileDebugInfo__,compilePages:e.compilePages,analyzer:e.analyzer,devToolsCompileCache:e.devToolsCompileCache,disableSpreadingUsingComponents:e.disableSpreadingUsingComponents,resultType:e.resultType})}async compileJS(e){this.checkProject();const{root:t,filePath:o,babelRoot:i="@babel/runtime"}=e;try{return await this.compileManager.compileJS(o,{root:t,sourceCode:e.sourceCode,setting:Object.assign({},e.setting),babelRoot:i,onProgressUpdate:e.onProgressUpdate})}catch(e){throw e}}setLocale(e){this.compileManager.setLocale(e)}clearCache(){this.compileManager.clearCache()}async getPackageWxssFileList(e){return[]}async getPackageWxssFiles(e){return{}}async getPackageWxmlAndWxsFiles(e){return{}}async getAllWxmlAndWxsFiles(){return{}}getAllSortedJSFiles(){throw new Error("Method not implemented.")}getMainPkgSortedJSFiles(){throw new Error("Method not implemented.")}async getPackageFiles(e,t){if(this.isGameType(e)){const e=await this.getGameJSON(),o=this.getMPFileList();let i=e.workers||"";i="string"==typeof i?i:i.path;const r=e.openDataContext,n={__APP__:[],[r]:[]};i&&(n[i]=[]);for(const t of o)if(r&&(0,tools_1.isLeftSubPathOfRight)(t,r))n[r].push({path:t,source:t,sourceExt:path_1.default.extname(t),independentRoot:r,isBabelIgnore:!1});else if(i&&(0,tools_1.isLeftSubPathOfRight)(t,i))n[i].push({path:t,source:t,sourceExt:path_1.default.extname(t),independentRoot:"object"==typeof e.workers&&e.workers.isSubpackage?i:"",isBabelIgnore:!1});else{if(e.subPackages){let o=!1;for(const i of e.subPackages){const e=i.root.replace(/^\//,"");if((0,tools_1.isLeftSubPathOfRight)(t,e)){n[i.root]||(n[e]=[]),n[e].push({path:t,source:t,sourceExt:path_1.default.extname(t),independentRoot:i.independent?e:"",isBabelIgnore:!1}),o=!0;break}}if(o)continue}n.__APP__.push({path:t,source:t,sourceExt:path_1.default.extname(t),independentRoot:"",isBabelIgnore:!1})}return n[t]||[]}throw new Error("Method not implemented.")}getSubPkgSortedJSFiles(e){throw new Error("Method not implemented.")}getCompAndPagesOfConf(){throw new Error("Method not implemented.")}async getAllPageAndComponent(){var e;const t=this.getMPJSONFileList(),o=[];for(let i=0,r=t.length;i<r;i++){const r=t[i].replace(/\.json$/,"");this.isValidComponent(null===(e=this.project)||void 0===e?void 0:e.miniprogramRoot,r)&&o.push(r)}return o}}exports.OriginalCompiler=OriginalCompiler;
@@ -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"),debug_1=require("../../utils/debug"),getProcess_1=require("../../utils/subprocess/getProcess"),env_1=require("../../utils/env");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>524288e3&&(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("loadStatus"!==o)throw new Error("unknown command "+o);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"),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 +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={},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 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppGraph=void 0;const tools_1=require("../../../../utils/tools"),mpjson_1=require("../../original/compile/handler/mpjson"),config_1=require("../../../../config/config"),progressRecorder_1=require("../../../../utils/progressRecorder"),white_ext_list_1=require("../../../../utils/white_ext_list"),appconf_1=require("./appconf"),basegraph_1=require("./basegraph");class AppGraph extends basegraph_1.BaseGraph{constructor(e){super(e),this.appConf=new appconf_1.AppConf(this.compiler.proxyProject,this.root)}async getWhiteListConfig(){if(!this._whiteListConfig){const e=await(0,white_ext_list_1.getWhiteExtList)();this._whiteListConfig=e.MiniProgramWhiteList}return this._whiteListConfig}destroy(){this.appConf.destroy(),super.destroy()}async getConf(e){return this.conf=await this.appConf.getConf(e),this.conf}async compileSingleCode(e,t){await this.ensureConf(progressRecorder_1.silentRecorder);const s=this.resolver.resolveInfoMap.get(e);if(s)return super.doCompileSingleCode(Object.assign(Object.assign({},s),{independentRoot:this.getIndependentRoot(s.path),isBabelIgnore:this.isBabelSettingIgnore(s)}),t);throw new Error("file not found")}async getDevCode(e,t){let s=await this.getPackageFile(t.package);return s=s.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(s,e)}async getProdCode(e,t){let s=await this.getPackageFile(t.package);return s=s.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(s,e,Object.assign(Object.assign({},t),{useCache:!1,resultType:t.resultType||"prod"}))}getLocalCodeFileList(){return Array.from(this.resolver.resolveInfoMap.entries()).map(([e,t])=>t.source)}onFileChangeForGraph(e,t){this.appConf.onFileChange(e,t)}getIndependentRoot(e){for(const t of Object.values(this.conf.packages))if(!0===t.independent){const s=t.root.replace(/^\//,"");if(e.startsWith(s))return s}if("object"==typeof this.conf.app.functionalPages&&!0===this.conf.app.functionalPages.independent&&e.startsWith("functional-pages/"))return"functional-pages";if("string"==typeof this.conf.app.openDataContext&&e.startsWith(this.conf.app.openDataContext))return this.conf.app.openDataContext;const t=this.conf.app.workers&&(0,tools_1.getWorkersPath)(this.conf.app.workers);return t&&e.startsWith(t)?t:""}checkFilePackage(e){for(const t of Object.keys(this.conf.packages))if(e.startsWith(t))return t;return config_1.MainPkg}async compileJSON(e,t){const s=await this.getConf(progressRecorder_1.silentRecorder),o={};o["app.json"]=JSON.stringify(s.app),s.ext&&(o["ext.json"]=JSON.stringify(s.ext));const{pageResults:n,componentResults:i}=await this.appConf.buildPagesAndCompsForUpload(progressRecorder_1.silentRecorder,e.disableSpreadingUsingComponents);return(0,mpjson_1.addSkylineRendererToComponents)(n,i),{conf:s,jsons:Object.assign(Object.assign(Object.assign({},o),n),i)}}async compileJSONWithFileList(e,t){const s=await this.getConf(progressRecorder_1.silentRecorder),o={};o["app.json"]=JSON.stringify(s.app),s.ext&&(o["ext.json"]=JSON.stringify(s.ext));const{pageResults:n,componentResults:i}=await this.appConf.buildPagesAndCompsWithFileListForUpload(progressRecorder_1.silentRecorder,e.fileList,e.disableSpreadingUsingComponents);return(0,mpjson_1.addSkylineRendererToComponents)(n,i),{conf:s,jsons:Object.assign(Object.assign(Object.assign({},o),n),i)}}}exports.AppGraph=AppGraph;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppGraph=void 0;const tools_1=require("../../../../utils/tools"),mpjson_1=require("../../original/compile/handler/mpjson"),config_1=require("../../../../config/config"),progressRecorder_1=require("../../../../utils/progressRecorder"),white_ext_list_1=require("../../../../utils/white_ext_list"),appconf_1=require("./appconf"),basegraph_1=require("./basegraph");class AppGraph extends basegraph_1.BaseGraph{constructor(e){super(e),this.appConf=new appconf_1.AppConf(this.compiler.proxyProject,this.root)}async getWhiteListConfig(){if(!this._whiteListConfig){const e=await(0,white_ext_list_1.getWhiteExtList)();this._whiteListConfig=e.MiniProgramWhiteList}return this._whiteListConfig}destroy(){this.appConf.destroy(),super.destroy()}async getConf(e){return this.conf=await this.appConf.getConf(e),this.conf}async compileSingleCode(e,t){await this.ensureConf(progressRecorder_1.silentRecorder);const s=this.resolver.resolveInfoMap.get(e);if(s)return super.doCompileSingleCode(Object.assign(Object.assign({},s),{independentRoot:this.getIndependentRoot(s.path),isBabelIgnore:this.isBabelSettingIgnore(s)}),t);throw new Error("file not found")}async getDevCode(e,t){let s=await this.getPackageFile(t.package);return s=s.filter((e=>!e.path.endsWith("json"))),this.getCodeFiles(s,e)}async getProdCode(e,t){let s=await this.getPackageFile(t.package);return s=s.filter((e=>!e.path.endsWith("json"))),this.getCodeFiles(s,e,Object.assign(Object.assign({},t),{useCache:!1,resultType:t.resultType||"prod"}))}getLocalCodeFileList(){return Array.from(this.resolver.resolveInfoMap.entries()).map((([e,t])=>t.source))}onFileChangeForGraph(e,t){this.appConf.onFileChange(e,t)}getIndependentRoot(e){for(const t of Object.values(this.conf.packages))if(!0===t.independent){const s=t.root.replace(/^\//,"");if(e.startsWith(s))return s}if("object"==typeof this.conf.app.functionalPages&&!0===this.conf.app.functionalPages.independent&&e.startsWith("functional-pages/"))return"functional-pages";if("string"==typeof this.conf.app.openDataContext&&e.startsWith(this.conf.app.openDataContext))return this.conf.app.openDataContext;const t=this.conf.app.workers&&(0,tools_1.getWorkersPath)(this.conf.app.workers);return t&&e.startsWith(t)?t:""}checkFilePackage(e){for(const t of Object.keys(this.conf.packages))if(e.startsWith(t))return t;return config_1.MainPkg}async compileJSON(e,t){const s=await this.getConf(progressRecorder_1.silentRecorder),o={};o["app.json"]=JSON.stringify(s.app),s.ext&&(o["ext.json"]=JSON.stringify(s.ext));const{pageResults:n,componentResults:i}=await this.appConf.buildPagesAndCompsForUpload(progressRecorder_1.silentRecorder,e.disableSpreadingUsingComponents);return(0,mpjson_1.addSkylineRendererToComponents)(n,i),{conf:s,jsons:Object.assign(Object.assign(Object.assign({},o),n),i)}}async compileJSONWithFileList(e,t){const s=await this.getConf(progressRecorder_1.silentRecorder),o={};o["app.json"]=JSON.stringify(s.app),s.ext&&(o["ext.json"]=JSON.stringify(s.ext));const{pageResults:n,componentResults:i}=await this.appConf.buildPagesAndCompsWithFileListForUpload(progressRecorder_1.silentRecorder,e.fileList,e.disableSpreadingUsingComponents);return(0,mpjson_1.addSkylineRendererToComponents)(n,i),{conf:s,jsons:Object.assign(Object.assign(Object.assign({},o),n),i)}}}exports.AppGraph=AppGraph;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BaseGraph=exports.JSONType=exports.FileType=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=require("lodash"),pluginDriver_1=require("../pluginDriver"),module_1=tslib_1.__importDefault(require("../module")),config_1=require("../../../../config/config"),resolver_1=require("../resolver"),common_1=require("../../original/compile/common"),packOptionsHelper_1=tslib_1.__importDefault(require("../../../../utils/packOptionsHelper")),tools_1=require("../../../../utils/tools"),babel_helper_1=require("../../../../utils/babel_helper"),helper_util_1=require("../../../../utils/helper_util"),progressRecorder_1=require("../../../../utils/progressRecorder"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),customError_1=require("../../../../utils/customError"),taskmanager_1=tslib_1.__importDefault(require("../../../../utils/taskmanager")),pluginconfig_1=require("../pluginconfig");var FileType,JSONType;function getFileType(e){let t=path_1.default.extname(e);if(t.startsWith(".")){if(t=t.slice(1),t===FileType.JS)return FileType.JS;if(t===FileType.WXML)return FileType.WXML;if(t===FileType.WXSS)return FileType.WXSS;if(t===FileType.WXS)return FileType.WXS;if(t===FileType.JSON)return FileType.JSON}throw Error("unknown the filetype of "+e)}!function(e){e.JSON="json",e.WXML="wxml",e.WXSS="wxss",e.WXS="wxs",e.JS="js"}(FileType||(exports.FileType=FileType={})),function(e){e.APP="app",e.Page="page",e.EXT="ext",e.SITEMAP="sitemap",e.THEME="theme"}(JSONType||(exports.JSONType=JSONType={}));class BaseGraph{constructor(e){var t;this.invalidated=!0,this.running=!1,this.onFileChange=(e,t)=>{t.startsWith(this.root)&&(t=t.replace(new RegExp("^"+this.root),""),this.resolver.onFileChange(e,t),"change"!==e&&"unlink"!==e||this.invalidateModules(t),this.onFileChangeForGraph(e,t))},this.getCodeFileTask=async(e,t,o={useCache:!0,resultType:"dev"})=>{const i=this.loadModuleFromFile(e,t,o);if(i.sourcePath.endsWith(".js")||i.sourcePath.endsWith(".ts")){return{file:e,codeFile:await i.toCodeFile2(o.resultType||"dev"),process:[]}}const r=await i.toCodeFile(o.resultType||"dev");if(!("error"in r)&&"dev"!==o.resultType){const e=await i.toGenerateResult(o.resultType||"dev");if(!("error"in e)){const t=await this.optimize(e,o),i=await this.compress(t,o);r.code=i.target.code,r.map=i.target.map}}return{file:e,codeFile:r,process:await i.getProcessInfo(o.resultType||"dev")||[]}},this.type=e.type,this.root=e.root,this.rootPath=(0,tools_1.joinPath)(e.compiler.project.projectPath,this.root),this.persistCache=e.persistCache,this.compiler=e.compiler,this.project=this.compiler.project,this.cachedModules=new Map,this.pluginDriver=new pluginDriver_1.PluginDriver(this,e),this.modulesByPath=new Map,this.resolver=new resolver_1.Resolver(this,this.root,this.pluginDriver.resolveExtConf),this.compiler.proxyProject.addResolver(this.resolver),null===(t=this.project.event)||void 0===t||t.on("fileChange",this.onFileChange)}destroy(){var e;this.compiler.proxyProject.removeResolver(this.resolver),null===(e=this.project.event)||void 0===e||e.off("fileChange",this.onFileChange)}clearCache(){this.modulesByPath.clear()}async ensureConf(e){this.conf||await this.getConf(e)}async getPackageFile(e){await this.ensureConf(progressRecorder_1.silentRecorder);const t=[];for(const[o,i]of this.resolver.resolveInfoMap.entries())e!==config_1.FullPkg&&this.checkFilePackage(o)!==e||t.push(i);return t.map(e=>Object.assign(Object.assign({},e),{independentRoot:this.getIndependentRoot(e.path),isBabelIgnore:this.isBabelSettingIgnore(e)}))}invalidateModules(e){for(const t of this.modulesByPath.values())(t.sourcePath===e||t.depFiles.includes(e))&&this.modulesByPath.delete(t.path)}loadModuleFromFile(e,t,o){let i=this.modulesByPath.get(e.path),r=!i||i.sourcePath!==e.source||i.independentRoot!==e.independentRoot;if(!r&&(null==i?void 0:i.getError(o.resultType))){if(i.getGeneratedTS(o.resultType)+1e3>Date.now())return i;r=!0}if(r){const t=getFileType(e.path);i=new module_1.default(e.path,e.source,t),i.independentRoot=e.independentRoot,e.isBabelIgnore&&(i.isBabelIgnore=!0),this.modulesByPath.set(e.path,i)}if(e.path.endsWith(".ts")||e.path.endsWith(".js")){let r=i.getLoadingPromise();void 0===r&&(r=t.run(locales_1.default.config.SUMMER_COMPILING_MODULE.format(e.source),()=>this.loadSourceForModuleWithoutTransform(i,o)),i.setLoadingPromise(r));let s=i.getCompilePromise(o.resultType);return void 0===s&&(s=t.run(locales_1.default.config.SUMMER_COMPILING_MODULE.format(e.source),async()=>{const e=await i.getLoadingPromise();return this.compileCode(e,i,o)}),i.setCompilePromise(o.resultType,s)),i}let s=i.getLoadingPromise();void 0===s&&(s=t.run(locales_1.default.config.SUMMER_COMPILING_MODULE.format(e.source),()=>this.loadSourceForModule(i,o)),i.setLoadingPromise(s));let a=i.getGeneratingPromise(o.resultType);return void 0===a&&(a=t.run(locales_1.default.config.SUMMER_COMPILING_MODULE.format(e.source),async()=>{const e=await i.getLoadingPromise();return this.generate(e,i,o)}),i.setGeneratingPromise(o.resultType,a)),i}async loadSourceForModuleWithoutTransform(e,t){try{const o=(0,tools_1.joinPath)(this.rootPath,e.sourcePath),i=t=>Object.assign(Object.assign({},t),{rootPath:this.rootPath,addWatchFile:t=>{const o=(0,tools_1.normalizePath)(t);if(!o.startsWith(this.rootPath))throw(0,customError_1.makeCustomError)(`The file (${t}) required by ${e.sourcePath} is outside the project`,customError_1.CustomErrors.SUMMER_PLUGIN_CODE_ERR,e.path);e.addWatchFile(path_1.default.posix.relative(this.rootPath,o))}});let r=await this.pluginDriver.hookFirst("load",[e.path,o,Object.assign(Object.assign({},t),{independentRoot:e.independentRoot,isBabelIgnore:e.isBabelIgnore||!1})],i);if(!r){const t=Date.now(),i=await this.readFile(o);r={targetPath:e.path,source:{sourceCode:i},process:[{cost:Date.now()-t,pluginName:"readFile",action:"load"}]}}return r}catch(o){throw o.path=(0,tools_1.joinPath)(this.root,e.sourcePath),e.setError(t.resultType,o),o}}async loadSourceForModule(e,t){try{const o=await this.loadSourceForModuleWithoutTransform(e,t);return await this.tranform(o,e,t)}catch(o){throw o.path=(0,tools_1.joinPath)(this.root,e.sourcePath),e.setError(t.resultType,o),o}}async doCompileSingleCode(e,t){const o=this.loadModuleFromFile(e,progressRecorder_1.silentRecorder,{resultType:"dev"}),i=o.getError("dev");if(i)throw i;return await o.toCodeFile("dev")}async getCodeFiles(e,t,o={useCache:!0,resultType:"dev"}){var i;const r=Date.now(),s={},a=new taskmanager_1.default({poolLimit:10,breakWhenError:!0});for(const i of e)a.addTask(this.getCodeFileTask,i,t,o);const n=await a.runAllAsync();for(const e of n)s[e.file.path]=e.codeFile,(null===(i=e.codeFile.jsTag)||void 0===i?void 0:i.isLargeFile)&&t.message("warn",locales_1.default.config.LARGEFILE_WARNING.format(e.file.path,config_1.MAX_CODE_LENGTH/1024));return console.info(`getCodeFiles: count: ${e.length}, cost: ${Date.now()-r}ms.`),s}async readFile(e){const t=path_1.default.relative(this.project.projectPath,e);return this.project.getFile("",t).toString()}async tranform(e,t,o){return await this.pluginDriver.hookReduceArg0("transform",[e,t.path,t.sourcePath,Object.assign(Object.assign({},o),{independentRoot:t.independentRoot,isBabelIgnore:t.isBabelIgnore||!1})],(function(e,t){return void 0===t?e:t}))}async generate(e,t,o){const i=await this.pluginDriver.hookFirst("generate",[e,t.path,t.sourcePath,Object.assign(Object.assign({},o),{independentRoot:t.independentRoot,isBabelIgnore:t.isBabelIgnore||!1})]);return void 0===i||(0,lodash_1.isNull)(i)?Object.assign(Object.assign({},e),{target:{code:e.source.sourceCode,map:e.source.inputMap}}):i}async compileCode(e,t,o){const i=await this.pluginDriver.hookFirst("compile",[t.path,t.sourcePath,e,Object.assign(Object.assign({},o),{independentRoot:t.independentRoot,isBabelIgnore:t.isBabelIgnore||!1})]);if(!i)throw new Error("not handle for "+t.sourcePath);return i}async optimize(e,t){return await this.pluginDriver.hookReduceArg0("optimize",[e,t],(e,t)=>t,e=>e)}async compress(e,t){return await this.pluginDriver.hookReduceArg0("compress",[e,t],(e,t)=>t,e=>e)}async compile(e,t){const{jsons:o}=await t.run(locales_1.default.config.SUMMER_COMPILE_JSON.format(),()=>this.compileJSON(e,t)),i=await this.compileCodeWithoutJSON(e,t),r=await t.run(locales_1.default.config.SUMMER_PACK_FILES.format(),()=>this.compileOther(Object.keys(o),t)),s=Object.assign(Object.assign(Object.assign({},r),i),o);return await t.run(locales_1.default.config.SUMMER_SEAL_PACK.format(),()=>this.pluginDriver.hookParallel("sealed",[s])),s}async compileWithFileList(e,t){const o=e.fileList,{jsons:i}=await t.run(locales_1.default.config.SUMMER_COMPILE_JSON.format(),()=>this.compileJSONWithFileList(Object.assign(Object.assign({},e),{fileList:o.filter(e=>e.endsWith(".json"))}),t)),r=o.filter(e=>!e.endsWith(".json")),s=await this.compileCodeWithoutJSONWithFileList(Object.assign(Object.assign({},e),{fileList:r}),t),a=Object.assign(Object.assign({},s),i);return await t.run(locales_1.default.config.SUMMER_SEAL_PACK.format(),()=>this.pluginDriver.hookParallel("sealed",[a])),a}async getLocalFileList(){const e=this.getLocalCodeFileList(),t=new Set(this.resolver.allExts.map(e=>"."+e)),o=await this.getWhiteListConfig(),i=this.project.getFileList(this.root,"").filter(e=>{const i=path_1.default.posix.extname(e);return o.has(i)&&!t.has(i)}).map(e=>e.replace(new RegExp("^"+this.root),"")),r={};for(const t of e.concat(i)){const e=this.project.stat(this.root,t);r[t]=e}return r}async compileOther(e,t=progressRecorder_1.silentRecorder){const o=new Set(this.resolver.allExts.map(e=>"."+e));o.delete(".json");const i=await this.getWhiteListConfig(),r=this.project.getFileList(this.root,"").filter(r=>{const s=path_1.default.posix.extname(r),a=path_1.default.posix.relative(this.root,r);if(!i.has(s)||o.has(s)||e.includes(a))return!1;return!packOptionsHelper_1.default.isIgnoredByRules(r)||(t.message("warn",r+" is ignored by project.config.json packOptions.ignore setting"),!1)}),s=await(0,common_1.compileOther)(this.project,r,{onProgressUpdate:()=>{}}),a={};for(const e in s){a[path_1.default.posix.relative(this.root,e)]=s[e]}return a}async compileCodeWithoutJSON(e,t){var o;const i={},r=await this.getProdCode(t,Object.assign(Object.assign({},e),{package:config_1.FullPkg})),s=new Set;for(const e in r){const t=r[e];if("error"in t)throw t.error;if(t.path.endsWith(".js")){((null===(o=t.jsTag)||void 0===o?void 0:o.helpers)||[]).forEach(e=>{s.add(e)}),i[e]=t.code;const r=t.map&&(0,tools_1.formatSourceMap)(t.map);r&&(i[e+".map"]=r)}else i[e]=t.code}return await t.run(locales_1.default.config.SUMMER_APPEND_BABEL_HELPERS.format((0,pluginconfig_1.couldUseSWCMode)(this.project.setting)?"swc":"babel"),()=>(0,helper_util_1.appendHelpers)(this.project,s,"",i)),i}async compileCodeWithoutJSONWithFileList(e,t){var o;const i={},r=await this.getProdCodeByFileList(t,e),s=new Set;for(const e in r){const t=r[e];if("error"in t)throw t.error;if(t.path.endsWith(".js")){((null===(o=t.jsTag)||void 0===o?void 0:o.helpers)||[]).forEach(e=>{s.add(e)}),i[e]=t.code;const r=t.map&&(0,tools_1.formatSourceMap)(t.map);r&&(i[e+".map"]=r)}else i[e]=t.code}return await t.run(locales_1.default.config.SUMMER_APPEND_BABEL_HELPERS.format((0,pluginconfig_1.couldUseSWCMode)(this.project.setting)?"swc":"babel"),()=>(0,helper_util_1.appendHelpers)(this.project,s,"",i)),i}isBabelSettingIgnore(e){var t,o;let i=!1;if(e.path.endsWith(".js")){const r=(0,pluginconfig_1.couldUseSWCMode)(this.project.setting)?null===(t=this.compiler.getSWCSetting())||void 0===t?void 0:t.ignore:null===(o=this.compiler.getBabelSetting())||void 0===o?void 0:o.ignore;r&&(i=(0,babel_helper_1.isIgnore)(r,e.source))}return i}async getDevCodeByFileList(e,t){let o=await this.getPackageFile(config_1.FullPkg);return o=o.filter(e=>t.fileList.includes(e.path)),this.getCodeFiles(o,e)}async getProdCodeByFileList(e,t){let o=await this.getPackageFile(config_1.FullPkg);return o=o.filter(e=>t.fileList.includes(e.path)),this.getCodeFiles(o,e,{useCache:!1,resultType:t.resultType||"prod"})}}exports.BaseGraph=BaseGraph;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BaseGraph=exports.JSONType=exports.FileType=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=require("lodash"),pluginDriver_1=require("../pluginDriver"),module_1=tslib_1.__importDefault(require("../module")),config_1=require("../../../../config/config"),resolver_1=require("../resolver"),common_1=require("../../original/compile/common"),packOptionsHelper_1=tslib_1.__importDefault(require("../../../../utils/packOptionsHelper")),tools_1=require("../../../../utils/tools"),babel_helper_1=require("../../../../utils/babel_helper"),helper_util_1=require("../../../../utils/helper_util"),progressRecorder_1=require("../../../../utils/progressRecorder"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),customError_1=require("../../../../utils/customError"),taskmanager_1=tslib_1.__importDefault(require("../../../../utils/taskmanager")),pluginconfig_1=require("../pluginconfig");var FileType,JSONType;function getFileType(e){let t=path_1.default.extname(e);if(t.startsWith(".")){if(t=t.slice(1),t===FileType.JS)return FileType.JS;if(t===FileType.WXML)return FileType.WXML;if(t===FileType.WXSS)return FileType.WXSS;if(t===FileType.WXS)return FileType.WXS;if(t===FileType.JSON)return FileType.JSON}throw Error(`unknown the filetype of ${e}`)}!function(e){e.JSON="json",e.WXML="wxml",e.WXSS="wxss",e.WXS="wxs",e.JS="js"}(FileType||(exports.FileType=FileType={})),function(e){e.APP="app",e.Page="page",e.EXT="ext",e.SITEMAP="sitemap",e.THEME="theme"}(JSONType||(exports.JSONType=JSONType={}));class BaseGraph{constructor(e){var t;this.invalidated=!0,this.running=!1,this.onFileChange=(e,t)=>{t.startsWith(this.root)&&(t=t.replace(new RegExp(`^${this.root}`),""),this.resolver.onFileChange(e,t),"change"!==e&&"unlink"!==e||this.invalidateModules(t),this.onFileChangeForGraph(e,t))},this.getCodeFileTask=async(e,t,o={useCache:!0,resultType:"dev"})=>{const i=this.loadModuleFromFile(e,t,o);if(i.sourcePath.endsWith(".js")||i.sourcePath.endsWith(".ts")){return{file:e,codeFile:await i.toCodeFile2(o.resultType||"dev"),process:[]}}const r=await i.toCodeFile(o.resultType||"dev");if(!("error"in r)&&"dev"!==o.resultType){const e=await i.toGenerateResult(o.resultType||"dev");if(!("error"in e)){const t=await this.optimize(e,o),i=await this.compress(t,o);r.code=i.target.code,r.map=i.target.map}}return{file:e,codeFile:r,process:await i.getProcessInfo(o.resultType||"dev")||[]}},this.type=e.type,this.root=e.root,this.rootPath=(0,tools_1.joinPath)(e.compiler.project.projectPath,this.root),this.persistCache=e.persistCache,this.compiler=e.compiler,this.project=this.compiler.project,this.cachedModules=new Map,this.pluginDriver=new pluginDriver_1.PluginDriver(this,e),this.modulesByPath=new Map,this.resolver=new resolver_1.Resolver(this,this.root,this.pluginDriver.resolveExtConf),this.compiler.proxyProject.addResolver(this.resolver),null===(t=this.project.event)||void 0===t||t.on("fileChange",this.onFileChange)}destroy(){var e;this.compiler.proxyProject.removeResolver(this.resolver),null===(e=this.project.event)||void 0===e||e.off("fileChange",this.onFileChange)}clearCache(){this.modulesByPath.clear()}async ensureConf(e){this.conf||await this.getConf(e)}async getPackageFile(e){await this.ensureConf(progressRecorder_1.silentRecorder);const t=[];for(const[o,i]of this.resolver.resolveInfoMap.entries())e!==config_1.FullPkg&&this.checkFilePackage(o)!==e||t.push(i);return t.map((e=>Object.assign(Object.assign({},e),{independentRoot:this.getIndependentRoot(e.path),isBabelIgnore:this.isBabelSettingIgnore(e)})))}invalidateModules(e){for(const t of this.modulesByPath.values())(t.sourcePath===e||t.depFiles.includes(e))&&this.modulesByPath.delete(t.path)}loadModuleFromFile(e,t,o){let i=this.modulesByPath.get(e.path),r=!i||i.sourcePath!==e.source||i.independentRoot!==e.independentRoot;if(!r&&(null==i?void 0:i.getError(o.resultType))){if(i.getGeneratedTS(o.resultType)+1e3>Date.now())return i;r=!0}if(r){const t=getFileType(e.path);i=new module_1.default(e.path,e.source,t),i.independentRoot=e.independentRoot,e.isBabelIgnore&&(i.isBabelIgnore=!0),this.modulesByPath.set(e.path,i)}if(e.path.endsWith(".ts")||e.path.endsWith(".js")){let r=i.getLoadingPromise();void 0===r&&(r=t.run(locales_1.default.config.SUMMER_COMPILING_MODULE.format(e.source),(()=>this.loadSourceForModuleWithoutTransform(i,o))),i.setLoadingPromise(r));let s=i.getCompilePromise(o.resultType);return void 0===s&&(s=t.run(locales_1.default.config.SUMMER_COMPILING_MODULE.format(e.source),(async()=>{const e=await i.getLoadingPromise();return this.compileCode(e,i,o)})),i.setCompilePromise(o.resultType,s)),i}let s=i.getLoadingPromise();void 0===s&&(s=t.run(locales_1.default.config.SUMMER_COMPILING_MODULE.format(e.source),(()=>this.loadSourceForModule(i,o))),i.setLoadingPromise(s));let a=i.getGeneratingPromise(o.resultType);return void 0===a&&(a=t.run(locales_1.default.config.SUMMER_COMPILING_MODULE.format(e.source),(async()=>{const e=await i.getLoadingPromise();return this.generate(e,i,o)})),i.setGeneratingPromise(o.resultType,a)),i}async loadSourceForModuleWithoutTransform(e,t){try{const o=(0,tools_1.joinPath)(this.rootPath,e.sourcePath),i=t=>Object.assign(Object.assign({},t),{rootPath:this.rootPath,addWatchFile:t=>{const o=(0,tools_1.normalizePath)(t);if(!o.startsWith(this.rootPath))throw(0,customError_1.makeCustomError)(`The file (${t}) required by ${e.sourcePath} is outside the project`,customError_1.CustomErrors.SUMMER_PLUGIN_CODE_ERR,e.path);e.addWatchFile(path_1.default.posix.relative(this.rootPath,o))}});let r=await this.pluginDriver.hookFirst("load",[e.path,o,Object.assign(Object.assign({},t),{independentRoot:e.independentRoot,isBabelIgnore:e.isBabelIgnore||!1})],i);if(!r){const t=Date.now(),i=await this.readFile(o);r={targetPath:e.path,source:{sourceCode:i},process:[{cost:Date.now()-t,pluginName:"readFile",action:"load"}]}}return r}catch(o){throw o.path=(0,tools_1.joinPath)(this.root,e.sourcePath),e.setError(t.resultType,o),o}}async loadSourceForModule(e,t){try{const o=await this.loadSourceForModuleWithoutTransform(e,t);return await this.tranform(o,e,t)}catch(o){throw o.path=(0,tools_1.joinPath)(this.root,e.sourcePath),e.setError(t.resultType,o),o}}async doCompileSingleCode(e,t){const o=this.loadModuleFromFile(e,progressRecorder_1.silentRecorder,{resultType:"dev"}),i=o.getError("dev");if(i)throw i;return await o.toCodeFile("dev")}async getCodeFiles(e,t,o={useCache:!0,resultType:"dev"}){var i;const r=Date.now(),s={},a=new taskmanager_1.default({poolLimit:10,breakWhenError:!0});for(const i of e)a.addTask(this.getCodeFileTask,i,t,o);const n=await a.runAllAsync();for(const e of n)s[e.file.path]=e.codeFile,(null===(i=e.codeFile.jsTag)||void 0===i?void 0:i.isLargeFile)&&t.message("warn",locales_1.default.config.LARGEFILE_WARNING.format(e.file.path,config_1.MAX_CODE_LENGTH/1024));return console.info(`getCodeFiles: count: ${e.length}, cost: ${Date.now()-r}ms.`),s}async readFile(e){const t=path_1.default.relative(this.project.projectPath,e);return this.project.getFile("",t).toString()}async tranform(e,t,o){const i=await this.pluginDriver.hookReduceArg0("transform",[e,t.path,t.sourcePath,Object.assign(Object.assign({},o),{independentRoot:t.independentRoot,isBabelIgnore:t.isBabelIgnore||!1})],(function(e,t){return void 0===t?e:t}));return i}async generate(e,t,o){const i=await this.pluginDriver.hookFirst("generate",[e,t.path,t.sourcePath,Object.assign(Object.assign({},o),{independentRoot:t.independentRoot,isBabelIgnore:t.isBabelIgnore||!1})]);return void 0===i||(0,lodash_1.isNull)(i)?Object.assign(Object.assign({},e),{target:{code:e.source.sourceCode,map:e.source.inputMap}}):i}async compileCode(e,t,o){const i=await this.pluginDriver.hookFirst("compile",[t.path,t.sourcePath,e,Object.assign(Object.assign({},o),{independentRoot:t.independentRoot,isBabelIgnore:t.isBabelIgnore||!1})]);if(!i)throw new Error(`not handle for ${t.sourcePath}`);return i}async optimize(e,t){return await this.pluginDriver.hookReduceArg0("optimize",[e,t],((e,t)=>t),(e=>e))}async compress(e,t){return await this.pluginDriver.hookReduceArg0("compress",[e,t],((e,t)=>t),(e=>e))}async compile(e,t){const{jsons:o}=await t.run(locales_1.default.config.SUMMER_COMPILE_JSON.format(),(()=>this.compileJSON(e,t))),i=await this.compileCodeWithoutJSON(e,t),r=await t.run(locales_1.default.config.SUMMER_PACK_FILES.format(),(()=>this.compileOther(Object.keys(o),t))),s=Object.assign(Object.assign(Object.assign({},r),i),o);return await t.run(locales_1.default.config.SUMMER_SEAL_PACK.format(),(()=>this.pluginDriver.hookParallel("sealed",[s]))),s}async compileWithFileList(e,t){const o=e.fileList,{jsons:i}=await t.run(locales_1.default.config.SUMMER_COMPILE_JSON.format(),(()=>this.compileJSONWithFileList(Object.assign(Object.assign({},e),{fileList:o.filter((e=>e.endsWith(".json")))}),t))),r=o.filter((e=>!e.endsWith(".json"))),s=await this.compileCodeWithoutJSONWithFileList(Object.assign(Object.assign({},e),{fileList:r}),t),a=Object.assign(Object.assign({},s),i);return await t.run(locales_1.default.config.SUMMER_SEAL_PACK.format(),(()=>this.pluginDriver.hookParallel("sealed",[a]))),a}async getLocalFileList(){const e=this.getLocalCodeFileList(),t=new Set(this.resolver.allExts.map((e=>`.${e}`))),o=await this.getWhiteListConfig(),i=this.project.getFileList(this.root,"").filter((e=>{const i=path_1.default.posix.extname(e);return o.has(i)&&!t.has(i)})).map((e=>e.replace(new RegExp(`^${this.root}`),""))),r={};for(const t of e.concat(i)){const e=this.project.stat(this.root,t);r[t]=e}return r}async compileOther(e,t=progressRecorder_1.silentRecorder){const o=new Set(this.resolver.allExts.map((e=>`.${e}`)));o.delete(".json");const i=await this.getWhiteListConfig(),r=this.project.getFileList(this.root,"").filter((r=>{const s=path_1.default.posix.extname(r),a=path_1.default.posix.relative(this.root,r);if(!i.has(s)||o.has(s)||e.includes(a))return!1;return!packOptionsHelper_1.default.isIgnoredByRules(r)||(t.message("warn",`${r} is ignored by project.config.json packOptions.ignore setting`),!1)})),s=await(0,common_1.compileOther)(this.project,r,{onProgressUpdate:()=>{}}),a={};for(const e in s){a[path_1.default.posix.relative(this.root,e)]=s[e]}return a}async compileCodeWithoutJSON(e,t){var o;const i={},r=await this.getProdCode(t,Object.assign(Object.assign({},e),{package:config_1.FullPkg})),s=new Set;for(const e in r){const t=r[e];if("error"in t)throw t.error;if(t.path.endsWith(".js")){((null===(o=t.jsTag)||void 0===o?void 0:o.helpers)||[]).forEach((e=>{s.add(e)})),i[e]=t.code;const r=t.map&&(0,tools_1.formatSourceMap)(t.map);r&&(i[`${e}.map`]=r)}else i[e]=t.code}return await t.run(locales_1.default.config.SUMMER_APPEND_BABEL_HELPERS.format((0,pluginconfig_1.couldUseSWCMode)(this.project.setting)?"swc":"babel"),(()=>(0,helper_util_1.appendHelpers)(this.project,s,"",i))),i}async compileCodeWithoutJSONWithFileList(e,t){var o;const i={},r=await this.getProdCodeByFileList(t,e),s=new Set;for(const e in r){const t=r[e];if("error"in t)throw t.error;if(t.path.endsWith(".js")){((null===(o=t.jsTag)||void 0===o?void 0:o.helpers)||[]).forEach((e=>{s.add(e)})),i[e]=t.code;const r=t.map&&(0,tools_1.formatSourceMap)(t.map);r&&(i[`${e}.map`]=r)}else i[e]=t.code}return await t.run(locales_1.default.config.SUMMER_APPEND_BABEL_HELPERS.format((0,pluginconfig_1.couldUseSWCMode)(this.project.setting)?"swc":"babel"),(()=>(0,helper_util_1.appendHelpers)(this.project,s,"",i))),i}isBabelSettingIgnore(e){var t,o;let i=!1;if(e.path.endsWith(".js")){const r=(0,pluginconfig_1.couldUseSWCMode)(this.project.setting)?null===(t=this.compiler.getSWCSetting())||void 0===t?void 0:t.ignore:null===(o=this.compiler.getBabelSetting())||void 0===o?void 0:o.ignore;r&&(i=(0,babel_helper_1.isIgnore)(r,e.source))}return i}async getDevCodeByFileList(e,t){let o=await this.getPackageFile(config_1.FullPkg);return o=o.filter((e=>t.fileList.includes(e.path))),this.getCodeFiles(o,e)}async getProdCodeByFileList(e,t){let o=await this.getPackageFile(config_1.FullPkg);return o=o.filter((e=>t.fileList.includes(e.path))),this.getCodeFiles(o,e,{useCache:!1,resultType:t.resultType||"prod"})}}exports.BaseGraph=BaseGraph;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GameConf=void 0;const tslib_1=require("tslib"),original_1=require("../../original"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),baseconf_1=require("./baseconf");class GameConf extends baseconf_1.BaseConf{constructor(){super(...arguments),this.packages=new Map,this.onFileChange=(e,t)=>{}}destroy(){}async getConf(e){return await this.build(e),{app:this.app,packages:Object.fromEntries(this.packages.entries())}}async buildPagesAndCompsForUpload(e,t=!1){return{pageResults:{},componentResults:{}}}async resetState(){this.app=void 0,this.packages.clear()}async load(e){var t;const s=await e.run(locales_1.default.config.SUMMER_COMPILE.format("game.json"),()=>(0,original_1.getGameJSON)(this.proxyProject));this.app=s;const o=s.subPackages||[];for(const e of o){const t=e.root.startsWith("/")?e.root.replace(/^\//,""):e.root;this.packages.set(t,Object.assign(Object.assign({},e),{root:t}))}s.openDataContext&&this.packages.set(s.openDataContext,{root:s.openDataContext,independent:!0,openDataContext:!0});const a="string"==typeof s.workers?s.workers:null===(t=s.workers)||void 0===t?void 0:t.path;a&&this.packages.set(a,{root:a,independent:!0,workers:!0})}}exports.GameConf=GameConf;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GameConf=void 0;const tslib_1=require("tslib"),original_1=require("../../original"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),baseconf_1=require("./baseconf");class GameConf extends baseconf_1.BaseConf{constructor(){super(...arguments),this.packages=new Map,this.onFileChange=(e,t)=>{}}destroy(){}async getConf(e){return await this.build(e),{app:this.app,packages:Object.fromEntries(this.packages.entries())}}async buildPagesAndCompsForUpload(e,t=!1){return{pageResults:{},componentResults:{}}}async resetState(){this.app=void 0,this.packages.clear()}async load(e){var t;const s=await e.run(locales_1.default.config.SUMMER_COMPILE.format("game.json"),(()=>(0,original_1.getGameJSON)(this.proxyProject)));this.app=s;const o=s.subPackages||[];for(const e of o){const t=e.root.startsWith("/")?e.root.replace(/^\//,""):e.root;this.packages.set(t,Object.assign(Object.assign({},e),{root:t}))}s.openDataContext&&this.packages.set(s.openDataContext,{root:s.openDataContext,independent:!0,openDataContext:!0});const a="string"==typeof s.workers?s.workers:null===(t=s.workers)||void 0===t?void 0:t.path;a&&this.packages.set(a,{root:a,independent:!0,workers:!0})}}exports.GameConf=GameConf;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GameGraph=void 0;const tools_1=require("../../../../utils/tools"),config_1=require("../../../../config/config"),white_ext_list_1=require("../../../../utils/white_ext_list"),progressRecorder_1=require("../../../../utils/progressRecorder"),gameconf_1=require("./gameconf"),basegraph_1=require("./basegraph");class GameGraph extends basegraph_1.BaseGraph{constructor(e){super(e),this.appConf=new gameconf_1.GameConf(this.compiler.proxyProject,this.root)}async getWhiteListConfig(){if(!this._whiteListConfig){const e=await(0,white_ext_list_1.getWhiteExtList)();this._whiteListConfig=e.GameWhiteList}return this._whiteListConfig}destroy(){this.appConf.destroy(),super.destroy()}async getConf(e){return this.conf=await this.appConf.getConf(e),this.conf}async compileSingleCode(e,t){await this.ensureConf(progressRecorder_1.silentRecorder);const s=this.resolver.resolveInfoMap.get(e);if(s)return super.doCompileSingleCode(Object.assign(Object.assign({},s),{independentRoot:this.getIndependentRoot(s.path),isBabelIgnore:this.isBabelSettingIgnore(s)}),t);throw new Error("file not found")}async getDevCode(e,t){let s=await this.getPackageFile(t.package);return s=s.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(s,e)}async getProdCode(e,t){let s=await this.getPackageFile(t.package);return s=s.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(s,e,Object.assign(Object.assign({},t),{useCache:!1}))}getLocalCodeFileList(){return Array.from(this.resolver.resolveInfoMap.entries()).map(([e,t])=>t.source)}onFileChangeForGraph(e,t){this.appConf.onFileChange(e,t)}getIndependentRoot(e){for(const t of Object.values(this.conf.packages))if(!0===t.independent){const s=t.root.replace(/^\//,"");if(e.startsWith(s))return s}if("string"==typeof this.conf.app.openDataContext&&e.startsWith(this.conf.app.openDataContext))return this.conf.app.openDataContext;const t=this.conf.app.workers&&(0,tools_1.getWorkersPath)(this.conf.app.workers);return t&&e.startsWith(t)?t:""}checkFilePackage(e){for(const t of Object.keys(this.conf.packages))if(e.startsWith(t))return t;return config_1.MainPkg}async compileJSON(e,t){const s=await this.getConf(progressRecorder_1.silentRecorder),o={};return o["game.json"]=JSON.stringify(s.app),{conf:s,jsons:Object.assign({},o)}}async compileJSONWithFileList(e,t){return this.compileJSON(e,t)}}exports.GameGraph=GameGraph;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GameGraph=void 0;const tools_1=require("../../../../utils/tools"),config_1=require("../../../../config/config"),white_ext_list_1=require("../../../../utils/white_ext_list"),progressRecorder_1=require("../../../../utils/progressRecorder"),gameconf_1=require("./gameconf"),basegraph_1=require("./basegraph");class GameGraph extends basegraph_1.BaseGraph{constructor(e){super(e),this.appConf=new gameconf_1.GameConf(this.compiler.proxyProject,this.root)}async getWhiteListConfig(){if(!this._whiteListConfig){const e=await(0,white_ext_list_1.getWhiteExtList)();this._whiteListConfig=e.GameWhiteList}return this._whiteListConfig}destroy(){this.appConf.destroy(),super.destroy()}async getConf(e){return this.conf=await this.appConf.getConf(e),this.conf}async compileSingleCode(e,t){await this.ensureConf(progressRecorder_1.silentRecorder);const s=this.resolver.resolveInfoMap.get(e);if(s)return super.doCompileSingleCode(Object.assign(Object.assign({},s),{independentRoot:this.getIndependentRoot(s.path),isBabelIgnore:this.isBabelSettingIgnore(s)}),t);throw new Error("file not found")}async getDevCode(e,t){let s=await this.getPackageFile(t.package);return s=s.filter((e=>!e.path.endsWith("json"))),this.getCodeFiles(s,e)}async getProdCode(e,t){let s=await this.getPackageFile(t.package);return s=s.filter((e=>!e.path.endsWith("json"))),this.getCodeFiles(s,e,Object.assign(Object.assign({},t),{useCache:!1}))}getLocalCodeFileList(){return Array.from(this.resolver.resolveInfoMap.entries()).map((([e,t])=>t.source))}onFileChangeForGraph(e,t){this.appConf.onFileChange(e,t)}getIndependentRoot(e){for(const t of Object.values(this.conf.packages))if(!0===t.independent){const s=t.root.replace(/^\//,"");if(e.startsWith(s))return s}if("string"==typeof this.conf.app.openDataContext&&e.startsWith(this.conf.app.openDataContext))return this.conf.app.openDataContext;const t=this.conf.app.workers&&(0,tools_1.getWorkersPath)(this.conf.app.workers);return t&&e.startsWith(t)?t:""}checkFilePackage(e){for(const t of Object.keys(this.conf.packages))if(e.startsWith(t))return t;return config_1.MainPkg}async compileJSON(e,t){const s=await this.getConf(progressRecorder_1.silentRecorder),o={};return o["game.json"]=JSON.stringify(s.app),{conf:s,jsons:Object.assign({},o)}}async compileJSONWithFileList(e,t){return this.compileJSON(e,t)}}exports.GameGraph=GameGraph;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GamePluginConf=void 0;const tslib_1=require("tslib"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),original_1=require("../../original"),baseconf_1=require("./baseconf");class GamePluginConf extends baseconf_1.BaseConf{destroy(){this.plugin=void 0}async getConf(e){return await this.build(e),{plugin:this.plugin}}async resetState(){this.plugin=void 0}async load(e){const i=await e.run(locales_1.default.config.SUMMER_COMPILE.format("plugin.json"),()=>(0,original_1.getPluginJSON)(this.proxyProject));this.plugin=i}}exports.GamePluginConf=GamePluginConf;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GamePluginConf=void 0;const tslib_1=require("tslib"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),original_1=require("../../original"),baseconf_1=require("./baseconf");class GamePluginConf extends baseconf_1.BaseConf{destroy(){this.plugin=void 0}async getConf(e){return await this.build(e),{plugin:this.plugin}}async resetState(){this.plugin=void 0}async load(e){const i=await e.run(locales_1.default.config.SUMMER_COMPILE.format("plugin.json"),(()=>(0,original_1.getPluginJSON)(this.proxyProject)));this.plugin=i}}exports.GamePluginConf=GamePluginConf;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GamePluginGraph=void 0;const progressRecorder_1=require("../../../../utils/progressRecorder"),white_ext_list_1=require("../../../../utils/white_ext_list"),basegraph_1=require("./basegraph"),gamepluginconf_1=require("./gamepluginconf"),config_1=require("../../../../config/config");class GamePluginGraph extends basegraph_1.BaseGraph{constructor(e){super(e),this.pluginConf=new gamepluginconf_1.GamePluginConf(this.compiler.proxyProject,this.root)}async getWhiteListConfig(){if(!this._whiteListConfig){const e=await(0,white_ext_list_1.getWhiteExtList)();this._whiteListConfig=e.GameWhiteList}return this._whiteListConfig}destroy(){this.pluginConf.destroy(),super.destroy()}async getConf(e){if("plugin"!==this.type)throw new Error("Couldn't call getAppConf without plugin type");return this.conf=await this.pluginConf.getConf(e),this.conf}async compileSingleCode(e,t){await this.ensureConf(progressRecorder_1.silentRecorder);const i=this.resolver.resolveInfoMap.get(e);if(i)return super.doCompileSingleCode(Object.assign(Object.assign({},i),{independentRoot:this.getIndependentRoot(i.path),isBabelIgnore:this.isBabelSettingIgnore(i)}),t);throw new Error("file not found")}async getDevCode(e){let t=await this.getPackageFile(config_1.FullPkg);return t=t.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(t,e)}async getProdCode(e,t){let i=await this.getPackageFile(config_1.FullPkg);return i=i.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(i,e,{useCache:!1,resultType:t.resultType})}getLocalCodeFileList(){return Array.from(this.resolver.resolveInfoMap.entries()).map(([e,t])=>t.source)}onFileChangeForGraph(e,t){}async getPackageFile(e){await this.ensureConf(progressRecorder_1.silentRecorder);const t=[];for(const[e,i]of this.resolver.resolveInfoMap.entries())t.push(i);return t.map(e=>Object.assign(Object.assign({},e),{independentRoot:this.getIndependentRoot(e.path),isBabelIgnore:this.isBabelSettingIgnore(e)}))}checkFilePackage(e){return config_1.MainPkg}getIndependentRoot(e){const t=this.conf.plugin;return"string"==typeof t.workers&&e.startsWith(t.workers)?t.workers:""}async compileJSON(){const e=await this.getConf(progressRecorder_1.silentRecorder),t={};return t["plugin.json"]=JSON.stringify(e.plugin),{conf:e,jsons:t}}async compileJSONWithFileList(){return this.compileJSON()}}exports.GamePluginGraph=GamePluginGraph;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GamePluginGraph=void 0;const progressRecorder_1=require("../../../../utils/progressRecorder"),white_ext_list_1=require("../../../../utils/white_ext_list"),basegraph_1=require("./basegraph"),gamepluginconf_1=require("./gamepluginconf"),config_1=require("../../../../config/config");class GamePluginGraph extends basegraph_1.BaseGraph{constructor(e){super(e),this.pluginConf=new gamepluginconf_1.GamePluginConf(this.compiler.proxyProject,this.root)}async getWhiteListConfig(){if(!this._whiteListConfig){const e=await(0,white_ext_list_1.getWhiteExtList)();this._whiteListConfig=e.GameWhiteList}return this._whiteListConfig}destroy(){this.pluginConf.destroy(),super.destroy()}async getConf(e){if("plugin"!==this.type)throw new Error("Couldn't call getAppConf without plugin type");return this.conf=await this.pluginConf.getConf(e),this.conf}async compileSingleCode(e,t){await this.ensureConf(progressRecorder_1.silentRecorder);const i=this.resolver.resolveInfoMap.get(e);if(i)return super.doCompileSingleCode(Object.assign(Object.assign({},i),{independentRoot:this.getIndependentRoot(i.path),isBabelIgnore:this.isBabelSettingIgnore(i)}),t);throw new Error("file not found")}async getDevCode(e){let t=await this.getPackageFile(config_1.FullPkg);return t=t.filter((e=>!e.path.endsWith("json"))),this.getCodeFiles(t,e)}async getProdCode(e,t){let i=await this.getPackageFile(config_1.FullPkg);return i=i.filter((e=>!e.path.endsWith("json"))),this.getCodeFiles(i,e,{useCache:!1,resultType:t.resultType})}getLocalCodeFileList(){return Array.from(this.resolver.resolveInfoMap.entries()).map((([e,t])=>t.source))}onFileChangeForGraph(e,t){}async getPackageFile(e){await this.ensureConf(progressRecorder_1.silentRecorder);const t=[];for(const[e,i]of this.resolver.resolveInfoMap.entries())t.push(i);return t.map((e=>Object.assign(Object.assign({},e),{independentRoot:this.getIndependentRoot(e.path),isBabelIgnore:this.isBabelSettingIgnore(e)})))}checkFilePackage(e){return config_1.MainPkg}getIndependentRoot(e){const t=this.conf.plugin;return"string"==typeof t.workers&&e.startsWith(t.workers)?t.workers:""}async compileJSON(){const e=await this.getConf(progressRecorder_1.silentRecorder),t={};return t["plugin.json"]=JSON.stringify(e.plugin),{conf:e,jsons:t}}async compileJSONWithFileList(){return this.compileJSON()}}exports.GamePluginGraph=GamePluginGraph;