crabatool 1.0.2 → 1.0.3

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 (625) hide show
  1. package/index.js +23 -2
  2. package/ngp/config.js +2 -2
  3. package/ngp/node_modules/.bin/mime +12 -0
  4. package/ngp/node_modules/.bin/mime.cmd +17 -0
  5. package/ngp/node_modules/.bin/mime.ps1 +28 -0
  6. package/ngp/node_modules/.bin/uglifyjs +12 -0
  7. package/ngp/node_modules/.bin/uglifyjs.cmd +17 -0
  8. package/ngp/node_modules/.bin/uglifyjs.ps1 +28 -0
  9. package/ngp/node_modules/.package-lock.json +863 -0
  10. package/ngp/node_modules/accepts/HISTORY.md +243 -0
  11. package/ngp/node_modules/accepts/LICENSE +23 -0
  12. package/ngp/node_modules/accepts/README.md +140 -0
  13. package/ngp/node_modules/accepts/index.js +238 -0
  14. package/ngp/node_modules/accepts/package.json +47 -0
  15. package/ngp/node_modules/anymatch/LICENSE +15 -0
  16. package/ngp/node_modules/anymatch/README.md +87 -0
  17. package/ngp/node_modules/anymatch/index.d.ts +19 -0
  18. package/ngp/node_modules/anymatch/index.js +104 -0
  19. package/ngp/node_modules/anymatch/package.json +48 -0
  20. package/ngp/node_modules/array-flatten/LICENSE +21 -0
  21. package/ngp/node_modules/array-flatten/README.md +43 -0
  22. package/ngp/node_modules/array-flatten/array-flatten.js +64 -0
  23. package/ngp/node_modules/array-flatten/package.json +39 -0
  24. package/ngp/node_modules/binary-extensions/binary-extensions.json +260 -0
  25. package/ngp/node_modules/binary-extensions/binary-extensions.json.d.ts +3 -0
  26. package/ngp/node_modules/binary-extensions/index.d.ts +14 -0
  27. package/ngp/node_modules/binary-extensions/index.js +1 -0
  28. package/ngp/node_modules/binary-extensions/license +9 -0
  29. package/ngp/node_modules/binary-extensions/package.json +38 -0
  30. package/ngp/node_modules/binary-extensions/readme.md +41 -0
  31. package/ngp/node_modules/body-parser/HISTORY.md +651 -0
  32. package/ngp/node_modules/body-parser/LICENSE +23 -0
  33. package/ngp/node_modules/body-parser/README.md +464 -0
  34. package/ngp/node_modules/body-parser/SECURITY.md +25 -0
  35. package/ngp/node_modules/body-parser/index.js +157 -0
  36. package/ngp/node_modules/body-parser/lib/read.js +205 -0
  37. package/ngp/node_modules/body-parser/lib/types/json.js +236 -0
  38. package/ngp/node_modules/body-parser/lib/types/raw.js +101 -0
  39. package/ngp/node_modules/body-parser/lib/types/text.js +121 -0
  40. package/ngp/node_modules/body-parser/lib/types/urlencoded.js +284 -0
  41. package/ngp/node_modules/body-parser/node_modules/bytes/History.md +97 -0
  42. package/ngp/node_modules/body-parser/node_modules/bytes/LICENSE +23 -0
  43. package/ngp/node_modules/body-parser/node_modules/bytes/Readme.md +152 -0
  44. package/ngp/node_modules/body-parser/node_modules/bytes/index.js +170 -0
  45. package/ngp/node_modules/body-parser/node_modules/bytes/package.json +42 -0
  46. package/ngp/node_modules/body-parser/node_modules/iconv-lite/Changelog.md +162 -0
  47. package/ngp/node_modules/body-parser/node_modules/iconv-lite/LICENSE +21 -0
  48. package/ngp/node_modules/body-parser/node_modules/iconv-lite/README.md +156 -0
  49. package/ngp/node_modules/body-parser/node_modules/iconv-lite/encodings/dbcs-codec.js +555 -0
  50. package/ngp/node_modules/body-parser/node_modules/iconv-lite/encodings/dbcs-data.js +176 -0
  51. package/ngp/node_modules/body-parser/node_modules/iconv-lite/encodings/index.js +22 -0
  52. package/ngp/node_modules/body-parser/node_modules/iconv-lite/encodings/internal.js +188 -0
  53. package/ngp/node_modules/body-parser/node_modules/iconv-lite/encodings/sbcs-codec.js +72 -0
  54. package/ngp/node_modules/body-parser/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
  55. package/ngp/node_modules/body-parser/node_modules/iconv-lite/encodings/sbcs-data.js +174 -0
  56. package/ngp/node_modules/body-parser/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
  57. package/ngp/node_modules/body-parser/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
  58. package/ngp/node_modules/body-parser/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
  59. package/ngp/node_modules/body-parser/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
  60. package/ngp/node_modules/body-parser/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
  61. package/ngp/node_modules/body-parser/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
  62. package/ngp/node_modules/body-parser/node_modules/iconv-lite/encodings/tables/gbk-added.json +55 -0
  63. package/ngp/node_modules/body-parser/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
  64. package/ngp/node_modules/body-parser/node_modules/iconv-lite/encodings/utf16.js +177 -0
  65. package/ngp/node_modules/body-parser/node_modules/iconv-lite/encodings/utf7.js +290 -0
  66. package/ngp/node_modules/body-parser/node_modules/iconv-lite/lib/bom-handling.js +52 -0
  67. package/ngp/node_modules/body-parser/node_modules/iconv-lite/lib/extend-node.js +217 -0
  68. package/ngp/node_modules/body-parser/node_modules/iconv-lite/lib/index.d.ts +24 -0
  69. package/ngp/node_modules/body-parser/node_modules/iconv-lite/lib/index.js +153 -0
  70. package/ngp/node_modules/body-parser/node_modules/iconv-lite/lib/streams.js +121 -0
  71. package/ngp/node_modules/body-parser/node_modules/iconv-lite/package.json +46 -0
  72. package/ngp/node_modules/body-parser/package.json +56 -0
  73. package/ngp/node_modules/braces/CHANGELOG.md +184 -0
  74. package/ngp/node_modules/braces/LICENSE +21 -0
  75. package/ngp/node_modules/braces/README.md +593 -0
  76. package/ngp/node_modules/braces/index.js +170 -0
  77. package/ngp/node_modules/braces/lib/compile.js +57 -0
  78. package/ngp/node_modules/braces/lib/constants.js +57 -0
  79. package/ngp/node_modules/braces/lib/expand.js +113 -0
  80. package/ngp/node_modules/braces/lib/parse.js +333 -0
  81. package/ngp/node_modules/braces/lib/stringify.js +32 -0
  82. package/ngp/node_modules/braces/lib/utils.js +112 -0
  83. package/ngp/node_modules/braces/package.json +77 -0
  84. package/ngp/node_modules/bytes/History.md +82 -0
  85. package/ngp/node_modules/bytes/LICENSE +23 -0
  86. package/ngp/node_modules/bytes/Readme.md +125 -0
  87. package/ngp/node_modules/bytes/index.js +159 -0
  88. package/ngp/node_modules/bytes/package.json +39 -0
  89. package/ngp/node_modules/call-bind/.eslintignore +1 -0
  90. package/ngp/node_modules/call-bind/.eslintrc +17 -0
  91. package/ngp/node_modules/call-bind/.github/FUNDING.yml +12 -0
  92. package/ngp/node_modules/call-bind/.nycrc +13 -0
  93. package/ngp/node_modules/call-bind/CHANGELOG.md +42 -0
  94. package/ngp/node_modules/call-bind/LICENSE +21 -0
  95. package/ngp/node_modules/call-bind/README.md +2 -0
  96. package/ngp/node_modules/call-bind/callBound.js +15 -0
  97. package/ngp/node_modules/call-bind/index.js +47 -0
  98. package/ngp/node_modules/call-bind/package.json +80 -0
  99. package/ngp/node_modules/call-bind/test/callBound.js +55 -0
  100. package/ngp/node_modules/call-bind/test/index.js +66 -0
  101. package/ngp/node_modules/chokidar/LICENSE +21 -0
  102. package/ngp/node_modules/chokidar/README.md +308 -0
  103. package/ngp/node_modules/chokidar/index.js +973 -0
  104. package/ngp/node_modules/chokidar/lib/constants.js +65 -0
  105. package/ngp/node_modules/chokidar/lib/fsevents-handler.js +524 -0
  106. package/ngp/node_modules/chokidar/lib/nodefs-handler.js +654 -0
  107. package/ngp/node_modules/chokidar/package.json +85 -0
  108. package/ngp/node_modules/chokidar/types/index.d.ts +188 -0
  109. package/ngp/node_modules/compressible/HISTORY.md +111 -0
  110. package/ngp/node_modules/compressible/LICENSE +24 -0
  111. package/ngp/node_modules/compressible/README.md +61 -0
  112. package/ngp/node_modules/compressible/index.js +58 -0
  113. package/ngp/node_modules/compressible/package.json +48 -0
  114. package/ngp/node_modules/compression/HISTORY.md +307 -0
  115. package/ngp/node_modules/compression/LICENSE +23 -0
  116. package/ngp/node_modules/compression/README.md +240 -0
  117. package/ngp/node_modules/compression/index.js +288 -0
  118. package/ngp/node_modules/compression/package.json +47 -0
  119. package/ngp/node_modules/content-disposition/HISTORY.md +60 -0
  120. package/ngp/node_modules/content-disposition/LICENSE +22 -0
  121. package/ngp/node_modules/content-disposition/README.md +142 -0
  122. package/ngp/node_modules/content-disposition/index.js +458 -0
  123. package/ngp/node_modules/content-disposition/node_modules/safe-buffer/LICENSE +21 -0
  124. package/ngp/node_modules/content-disposition/node_modules/safe-buffer/README.md +584 -0
  125. package/ngp/node_modules/content-disposition/node_modules/safe-buffer/index.d.ts +187 -0
  126. package/ngp/node_modules/content-disposition/node_modules/safe-buffer/index.js +65 -0
  127. package/ngp/node_modules/content-disposition/node_modules/safe-buffer/package.json +51 -0
  128. package/ngp/node_modules/content-disposition/package.json +44 -0
  129. package/ngp/node_modules/content-type/HISTORY.md +24 -0
  130. package/ngp/node_modules/content-type/LICENSE +22 -0
  131. package/ngp/node_modules/content-type/README.md +92 -0
  132. package/ngp/node_modules/content-type/index.js +222 -0
  133. package/ngp/node_modules/content-type/package.json +40 -0
  134. package/ngp/node_modules/cookie/HISTORY.md +142 -0
  135. package/ngp/node_modules/cookie/LICENSE +24 -0
  136. package/ngp/node_modules/cookie/README.md +302 -0
  137. package/ngp/node_modules/cookie/SECURITY.md +25 -0
  138. package/ngp/node_modules/cookie/index.js +270 -0
  139. package/ngp/node_modules/cookie/package.json +44 -0
  140. package/ngp/node_modules/cookie-signature/History.md +38 -0
  141. package/ngp/node_modules/cookie-signature/Readme.md +42 -0
  142. package/ngp/node_modules/cookie-signature/index.js +51 -0
  143. package/ngp/node_modules/cookie-signature/package.json +18 -0
  144. package/ngp/node_modules/crabatool/index.js +28 -0
  145. package/ngp/node_modules/crabatool/ngp/config.js +25 -0
  146. package/ngp/node_modules/crabatool/ngp/ngp.js +3 -0
  147. package/ngp/node_modules/crabatool/ngp/package.json +15 -0
  148. package/ngp/node_modules/crabatool/ngp/readme.md +4 -0
  149. package/ngp/node_modules/crabatool/package.json +25 -0
  150. package/ngp/node_modules/crabatool/readme.md +12 -0
  151. package/ngp/node_modules/crabatool/server.js +124 -0
  152. package/ngp/node_modules/debug/.coveralls.yml +1 -0
  153. package/ngp/node_modules/debug/.eslintrc +11 -0
  154. package/ngp/node_modules/debug/.travis.yml +14 -0
  155. package/ngp/node_modules/debug/CHANGELOG.md +362 -0
  156. package/ngp/node_modules/debug/LICENSE +19 -0
  157. package/ngp/node_modules/debug/Makefile +50 -0
  158. package/ngp/node_modules/debug/README.md +312 -0
  159. package/ngp/node_modules/debug/component.json +19 -0
  160. package/ngp/node_modules/debug/karma.conf.js +70 -0
  161. package/ngp/node_modules/debug/node.js +1 -0
  162. package/ngp/node_modules/debug/package.json +49 -0
  163. package/ngp/node_modules/debug/src/browser.js +185 -0
  164. package/ngp/node_modules/debug/src/debug.js +202 -0
  165. package/ngp/node_modules/debug/src/index.js +10 -0
  166. package/ngp/node_modules/debug/src/inspector-log.js +15 -0
  167. package/ngp/node_modules/debug/src/node.js +248 -0
  168. package/ngp/node_modules/depd/History.md +103 -0
  169. package/ngp/node_modules/depd/LICENSE +22 -0
  170. package/ngp/node_modules/depd/Readme.md +280 -0
  171. package/ngp/node_modules/depd/index.js +538 -0
  172. package/ngp/node_modules/depd/lib/browser/index.js +77 -0
  173. package/ngp/node_modules/depd/package.json +45 -0
  174. package/ngp/node_modules/destroy/LICENSE +23 -0
  175. package/ngp/node_modules/destroy/README.md +63 -0
  176. package/ngp/node_modules/destroy/index.js +209 -0
  177. package/ngp/node_modules/destroy/package.json +48 -0
  178. package/ngp/node_modules/ee-first/LICENSE +22 -0
  179. package/ngp/node_modules/ee-first/README.md +80 -0
  180. package/ngp/node_modules/ee-first/index.js +95 -0
  181. package/ngp/node_modules/ee-first/package.json +29 -0
  182. package/ngp/node_modules/encodeurl/HISTORY.md +14 -0
  183. package/ngp/node_modules/encodeurl/LICENSE +22 -0
  184. package/ngp/node_modules/encodeurl/README.md +128 -0
  185. package/ngp/node_modules/encodeurl/index.js +60 -0
  186. package/ngp/node_modules/encodeurl/package.json +40 -0
  187. package/ngp/node_modules/escape-html/LICENSE +24 -0
  188. package/ngp/node_modules/escape-html/Readme.md +43 -0
  189. package/ngp/node_modules/escape-html/index.js +78 -0
  190. package/ngp/node_modules/escape-html/package.json +24 -0
  191. package/ngp/node_modules/etag/HISTORY.md +83 -0
  192. package/ngp/node_modules/etag/LICENSE +22 -0
  193. package/ngp/node_modules/etag/README.md +159 -0
  194. package/ngp/node_modules/etag/index.js +131 -0
  195. package/ngp/node_modules/etag/package.json +47 -0
  196. package/ngp/node_modules/express/History.md +3579 -0
  197. package/ngp/node_modules/express/LICENSE +24 -0
  198. package/ngp/node_modules/express/Readme.md +166 -0
  199. package/ngp/node_modules/express/index.js +11 -0
  200. package/ngp/node_modules/express/lib/application.js +661 -0
  201. package/ngp/node_modules/express/lib/express.js +116 -0
  202. package/ngp/node_modules/express/lib/middleware/init.js +43 -0
  203. package/ngp/node_modules/express/lib/middleware/query.js +47 -0
  204. package/ngp/node_modules/express/lib/request.js +525 -0
  205. package/ngp/node_modules/express/lib/response.js +1169 -0
  206. package/ngp/node_modules/express/lib/router/index.js +673 -0
  207. package/ngp/node_modules/express/lib/router/layer.js +181 -0
  208. package/ngp/node_modules/express/lib/router/route.js +225 -0
  209. package/ngp/node_modules/express/lib/utils.js +304 -0
  210. package/ngp/node_modules/express/lib/view.js +182 -0
  211. package/ngp/node_modules/express/node_modules/safe-buffer/LICENSE +21 -0
  212. package/ngp/node_modules/express/node_modules/safe-buffer/README.md +584 -0
  213. package/ngp/node_modules/express/node_modules/safe-buffer/index.d.ts +187 -0
  214. package/ngp/node_modules/express/node_modules/safe-buffer/index.js +65 -0
  215. package/ngp/node_modules/express/node_modules/safe-buffer/package.json +51 -0
  216. package/ngp/node_modules/express/package.json +99 -0
  217. package/ngp/node_modules/fill-range/LICENSE +21 -0
  218. package/ngp/node_modules/fill-range/README.md +237 -0
  219. package/ngp/node_modules/fill-range/index.js +249 -0
  220. package/ngp/node_modules/fill-range/package.json +69 -0
  221. package/ngp/node_modules/finalhandler/HISTORY.md +195 -0
  222. package/ngp/node_modules/finalhandler/LICENSE +22 -0
  223. package/ngp/node_modules/finalhandler/README.md +147 -0
  224. package/ngp/node_modules/finalhandler/SECURITY.md +25 -0
  225. package/ngp/node_modules/finalhandler/index.js +336 -0
  226. package/ngp/node_modules/finalhandler/package.json +46 -0
  227. package/ngp/node_modules/forwarded/HISTORY.md +21 -0
  228. package/ngp/node_modules/forwarded/LICENSE +22 -0
  229. package/ngp/node_modules/forwarded/README.md +57 -0
  230. package/ngp/node_modules/forwarded/index.js +90 -0
  231. package/ngp/node_modules/forwarded/package.json +45 -0
  232. package/ngp/node_modules/fresh/HISTORY.md +70 -0
  233. package/ngp/node_modules/fresh/LICENSE +23 -0
  234. package/ngp/node_modules/fresh/README.md +119 -0
  235. package/ngp/node_modules/fresh/index.js +137 -0
  236. package/ngp/node_modules/fresh/package.json +46 -0
  237. package/ngp/node_modules/function-bind/.editorconfig +20 -0
  238. package/ngp/node_modules/function-bind/.eslintrc +15 -0
  239. package/ngp/node_modules/function-bind/.jscs.json +176 -0
  240. package/ngp/node_modules/function-bind/.travis.yml +168 -0
  241. package/ngp/node_modules/function-bind/LICENSE +20 -0
  242. package/ngp/node_modules/function-bind/README.md +48 -0
  243. package/ngp/node_modules/function-bind/implementation.js +52 -0
  244. package/ngp/node_modules/function-bind/index.js +5 -0
  245. package/ngp/node_modules/function-bind/package.json +63 -0
  246. package/ngp/node_modules/function-bind/test/.eslintrc +9 -0
  247. package/ngp/node_modules/function-bind/test/index.js +252 -0
  248. package/ngp/node_modules/get-intrinsic/.eslintignore +1 -0
  249. package/ngp/node_modules/get-intrinsic/.eslintrc +43 -0
  250. package/ngp/node_modules/get-intrinsic/.github/FUNDING.yml +12 -0
  251. package/ngp/node_modules/get-intrinsic/.nycrc +13 -0
  252. package/ngp/node_modules/get-intrinsic/CHANGELOG.md +64 -0
  253. package/ngp/node_modules/get-intrinsic/LICENSE +21 -0
  254. package/ngp/node_modules/get-intrinsic/README.md +65 -0
  255. package/ngp/node_modules/get-intrinsic/index.js +330 -0
  256. package/ngp/node_modules/get-intrinsic/package.json +78 -0
  257. package/ngp/node_modules/get-intrinsic/test/GetIntrinsic.js +260 -0
  258. package/ngp/node_modules/glob-parent/CHANGELOG.md +110 -0
  259. package/ngp/node_modules/glob-parent/LICENSE +15 -0
  260. package/ngp/node_modules/glob-parent/README.md +137 -0
  261. package/ngp/node_modules/glob-parent/index.js +42 -0
  262. package/ngp/node_modules/glob-parent/package.json +48 -0
  263. package/ngp/node_modules/has/LICENSE-MIT +22 -0
  264. package/ngp/node_modules/has/README.md +18 -0
  265. package/ngp/node_modules/has/package.json +48 -0
  266. package/ngp/node_modules/has/src/index.js +5 -0
  267. package/ngp/node_modules/has/test/index.js +10 -0
  268. package/ngp/node_modules/has-symbols/.eslintrc +11 -0
  269. package/ngp/node_modules/has-symbols/.github/FUNDING.yml +12 -0
  270. package/ngp/node_modules/has-symbols/.nycrc +9 -0
  271. package/ngp/node_modules/has-symbols/CHANGELOG.md +75 -0
  272. package/ngp/node_modules/has-symbols/LICENSE +21 -0
  273. package/ngp/node_modules/has-symbols/README.md +46 -0
  274. package/ngp/node_modules/has-symbols/index.js +13 -0
  275. package/ngp/node_modules/has-symbols/package.json +101 -0
  276. package/ngp/node_modules/has-symbols/shams.js +42 -0
  277. package/ngp/node_modules/has-symbols/test/index.js +22 -0
  278. package/ngp/node_modules/has-symbols/test/shams/core-js.js +28 -0
  279. package/ngp/node_modules/has-symbols/test/shams/get-own-property-symbols.js +28 -0
  280. package/ngp/node_modules/has-symbols/test/tests.js +56 -0
  281. package/ngp/node_modules/http-errors/HISTORY.md +180 -0
  282. package/ngp/node_modules/http-errors/LICENSE +23 -0
  283. package/ngp/node_modules/http-errors/README.md +169 -0
  284. package/ngp/node_modules/http-errors/index.js +289 -0
  285. package/ngp/node_modules/http-errors/package.json +50 -0
  286. package/ngp/node_modules/iconv-lite/Changelog.md +184 -0
  287. package/ngp/node_modules/iconv-lite/LICENSE +21 -0
  288. package/ngp/node_modules/iconv-lite/README.md +166 -0
  289. package/ngp/node_modules/iconv-lite/encodings/dbcs-codec.js +555 -0
  290. package/ngp/node_modules/iconv-lite/encodings/dbcs-data.js +176 -0
  291. package/ngp/node_modules/iconv-lite/encodings/index.js +23 -0
  292. package/ngp/node_modules/iconv-lite/encodings/internal.js +188 -0
  293. package/ngp/node_modules/iconv-lite/encodings/sbcs-codec.js +72 -0
  294. package/ngp/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
  295. package/ngp/node_modules/iconv-lite/encodings/sbcs-data.js +179 -0
  296. package/ngp/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
  297. package/ngp/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
  298. package/ngp/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
  299. package/ngp/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
  300. package/ngp/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
  301. package/ngp/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
  302. package/ngp/node_modules/iconv-lite/encodings/tables/gbk-added.json +55 -0
  303. package/ngp/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
  304. package/ngp/node_modules/iconv-lite/encodings/utf16.js +177 -0
  305. package/ngp/node_modules/iconv-lite/encodings/utf32.js +281 -0
  306. package/ngp/node_modules/iconv-lite/encodings/utf7.js +290 -0
  307. package/ngp/node_modules/iconv-lite/lib/bom-handling.js +52 -0
  308. package/ngp/node_modules/iconv-lite/lib/extend-node.js +217 -0
  309. package/ngp/node_modules/iconv-lite/lib/index.d.ts +41 -0
  310. package/ngp/node_modules/iconv-lite/lib/index.js +153 -0
  311. package/ngp/node_modules/iconv-lite/lib/streams.js +121 -0
  312. package/ngp/node_modules/iconv-lite/package.json +45 -0
  313. package/ngp/node_modules/inherits/LICENSE +16 -0
  314. package/ngp/node_modules/inherits/README.md +42 -0
  315. package/ngp/node_modules/inherits/inherits.js +9 -0
  316. package/ngp/node_modules/inherits/inherits_browser.js +27 -0
  317. package/ngp/node_modules/inherits/package.json +29 -0
  318. package/ngp/node_modules/ipaddr.js/LICENSE +19 -0
  319. package/ngp/node_modules/ipaddr.js/README.md +233 -0
  320. package/ngp/node_modules/ipaddr.js/ipaddr.min.js +1 -0
  321. package/ngp/node_modules/ipaddr.js/lib/ipaddr.js +673 -0
  322. package/ngp/node_modules/ipaddr.js/lib/ipaddr.js.d.ts +68 -0
  323. package/ngp/node_modules/ipaddr.js/package.json +35 -0
  324. package/ngp/node_modules/is-binary-path/index.d.ts +17 -0
  325. package/ngp/node_modules/is-binary-path/index.js +7 -0
  326. package/ngp/node_modules/is-binary-path/license +9 -0
  327. package/ngp/node_modules/is-binary-path/package.json +40 -0
  328. package/ngp/node_modules/is-binary-path/readme.md +34 -0
  329. package/ngp/node_modules/is-extglob/LICENSE +21 -0
  330. package/ngp/node_modules/is-extglob/README.md +107 -0
  331. package/ngp/node_modules/is-extglob/index.js +20 -0
  332. package/ngp/node_modules/is-extglob/package.json +69 -0
  333. package/ngp/node_modules/is-glob/LICENSE +21 -0
  334. package/ngp/node_modules/is-glob/README.md +206 -0
  335. package/ngp/node_modules/is-glob/index.js +150 -0
  336. package/ngp/node_modules/is-glob/package.json +81 -0
  337. package/ngp/node_modules/is-number/LICENSE +21 -0
  338. package/ngp/node_modules/is-number/README.md +187 -0
  339. package/ngp/node_modules/is-number/index.js +18 -0
  340. package/ngp/node_modules/is-number/package.json +82 -0
  341. package/ngp/node_modules/media-typer/HISTORY.md +22 -0
  342. package/ngp/node_modules/media-typer/LICENSE +22 -0
  343. package/ngp/node_modules/media-typer/README.md +81 -0
  344. package/ngp/node_modules/media-typer/index.js +270 -0
  345. package/ngp/node_modules/media-typer/package.json +26 -0
  346. package/ngp/node_modules/merge-descriptors/HISTORY.md +21 -0
  347. package/ngp/node_modules/merge-descriptors/LICENSE +23 -0
  348. package/ngp/node_modules/merge-descriptors/README.md +48 -0
  349. package/ngp/node_modules/merge-descriptors/index.js +60 -0
  350. package/ngp/node_modules/merge-descriptors/package.json +32 -0
  351. package/ngp/node_modules/methods/HISTORY.md +29 -0
  352. package/ngp/node_modules/methods/LICENSE +24 -0
  353. package/ngp/node_modules/methods/README.md +51 -0
  354. package/ngp/node_modules/methods/index.js +69 -0
  355. package/ngp/node_modules/methods/package.json +36 -0
  356. package/ngp/node_modules/mime/CHANGELOG.md +164 -0
  357. package/ngp/node_modules/mime/LICENSE +21 -0
  358. package/ngp/node_modules/mime/README.md +90 -0
  359. package/ngp/node_modules/mime/cli.js +8 -0
  360. package/ngp/node_modules/mime/mime.js +108 -0
  361. package/ngp/node_modules/mime/package.json +44 -0
  362. package/ngp/node_modules/mime/src/build.js +53 -0
  363. package/ngp/node_modules/mime/src/test.js +60 -0
  364. package/ngp/node_modules/mime/types.json +1 -0
  365. package/ngp/node_modules/mime-db/HISTORY.md +507 -0
  366. package/ngp/node_modules/mime-db/LICENSE +23 -0
  367. package/ngp/node_modules/mime-db/README.md +100 -0
  368. package/ngp/node_modules/mime-db/db.json +8519 -0
  369. package/ngp/node_modules/mime-db/index.js +12 -0
  370. package/ngp/node_modules/mime-db/package.json +60 -0
  371. package/ngp/node_modules/mime-types/HISTORY.md +397 -0
  372. package/ngp/node_modules/mime-types/LICENSE +23 -0
  373. package/ngp/node_modules/mime-types/README.md +113 -0
  374. package/ngp/node_modules/mime-types/index.js +188 -0
  375. package/ngp/node_modules/mime-types/package.json +44 -0
  376. package/ngp/node_modules/ms/index.js +152 -0
  377. package/ngp/node_modules/ms/license.md +21 -0
  378. package/ngp/node_modules/ms/package.json +37 -0
  379. package/ngp/node_modules/ms/readme.md +51 -0
  380. package/ngp/node_modules/negotiator/HISTORY.md +108 -0
  381. package/ngp/node_modules/negotiator/LICENSE +24 -0
  382. package/ngp/node_modules/negotiator/README.md +203 -0
  383. package/ngp/node_modules/negotiator/index.js +82 -0
  384. package/ngp/node_modules/negotiator/lib/charset.js +169 -0
  385. package/ngp/node_modules/negotiator/lib/encoding.js +184 -0
  386. package/ngp/node_modules/negotiator/lib/language.js +179 -0
  387. package/ngp/node_modules/negotiator/lib/mediaType.js +294 -0
  388. package/ngp/node_modules/negotiator/package.json +42 -0
  389. package/ngp/node_modules/normalize-path/LICENSE +21 -0
  390. package/ngp/node_modules/normalize-path/README.md +127 -0
  391. package/ngp/node_modules/normalize-path/index.js +35 -0
  392. package/ngp/node_modules/normalize-path/package.json +77 -0
  393. package/ngp/node_modules/object-inspect/.eslintrc +53 -0
  394. package/ngp/node_modules/object-inspect/.github/FUNDING.yml +12 -0
  395. package/ngp/node_modules/object-inspect/.nycrc +13 -0
  396. package/ngp/node_modules/object-inspect/CHANGELOG.md +360 -0
  397. package/ngp/node_modules/object-inspect/LICENSE +21 -0
  398. package/ngp/node_modules/object-inspect/example/all.js +23 -0
  399. package/ngp/node_modules/object-inspect/example/circular.js +6 -0
  400. package/ngp/node_modules/object-inspect/example/fn.js +5 -0
  401. package/ngp/node_modules/object-inspect/example/inspect.js +10 -0
  402. package/ngp/node_modules/object-inspect/index.js +512 -0
  403. package/ngp/node_modules/object-inspect/package-support.json +20 -0
  404. package/ngp/node_modules/object-inspect/package.json +94 -0
  405. package/ngp/node_modules/object-inspect/readme.markdown +86 -0
  406. package/ngp/node_modules/object-inspect/test/bigint.js +58 -0
  407. package/ngp/node_modules/object-inspect/test/browser/dom.js +15 -0
  408. package/ngp/node_modules/object-inspect/test/circular.js +16 -0
  409. package/ngp/node_modules/object-inspect/test/deep.js +12 -0
  410. package/ngp/node_modules/object-inspect/test/element.js +53 -0
  411. package/ngp/node_modules/object-inspect/test/err.js +48 -0
  412. package/ngp/node_modules/object-inspect/test/fakes.js +29 -0
  413. package/ngp/node_modules/object-inspect/test/fn.js +76 -0
  414. package/ngp/node_modules/object-inspect/test/has.js +15 -0
  415. package/ngp/node_modules/object-inspect/test/holes.js +15 -0
  416. package/ngp/node_modules/object-inspect/test/indent-option.js +271 -0
  417. package/ngp/node_modules/object-inspect/test/inspect.js +139 -0
  418. package/ngp/node_modules/object-inspect/test/lowbyte.js +12 -0
  419. package/ngp/node_modules/object-inspect/test/number.js +58 -0
  420. package/ngp/node_modules/object-inspect/test/quoteStyle.js +17 -0
  421. package/ngp/node_modules/object-inspect/test/toStringTag.js +40 -0
  422. package/ngp/node_modules/object-inspect/test/undef.js +12 -0
  423. package/ngp/node_modules/object-inspect/test/values.js +211 -0
  424. package/ngp/node_modules/object-inspect/test-core-js.js +26 -0
  425. package/ngp/node_modules/object-inspect/util.inspect.js +1 -0
  426. package/ngp/node_modules/on-finished/HISTORY.md +98 -0
  427. package/ngp/node_modules/on-finished/LICENSE +23 -0
  428. package/ngp/node_modules/on-finished/README.md +162 -0
  429. package/ngp/node_modules/on-finished/index.js +234 -0
  430. package/ngp/node_modules/on-finished/package.json +39 -0
  431. package/ngp/node_modules/on-headers/HISTORY.md +21 -0
  432. package/ngp/node_modules/on-headers/LICENSE +22 -0
  433. package/ngp/node_modules/on-headers/README.md +81 -0
  434. package/ngp/node_modules/on-headers/index.js +132 -0
  435. package/ngp/node_modules/on-headers/package.json +42 -0
  436. package/ngp/node_modules/parseurl/HISTORY.md +58 -0
  437. package/ngp/node_modules/parseurl/LICENSE +24 -0
  438. package/ngp/node_modules/parseurl/README.md +133 -0
  439. package/ngp/node_modules/parseurl/index.js +158 -0
  440. package/ngp/node_modules/parseurl/package.json +40 -0
  441. package/ngp/node_modules/path-to-regexp/History.md +36 -0
  442. package/ngp/node_modules/path-to-regexp/LICENSE +21 -0
  443. package/ngp/node_modules/path-to-regexp/Readme.md +35 -0
  444. package/ngp/node_modules/path-to-regexp/index.js +129 -0
  445. package/ngp/node_modules/path-to-regexp/package.json +30 -0
  446. package/ngp/node_modules/picomatch/CHANGELOG.md +136 -0
  447. package/ngp/node_modules/picomatch/LICENSE +21 -0
  448. package/ngp/node_modules/picomatch/README.md +708 -0
  449. package/ngp/node_modules/picomatch/index.js +3 -0
  450. package/ngp/node_modules/picomatch/lib/constants.js +179 -0
  451. package/ngp/node_modules/picomatch/lib/parse.js +1091 -0
  452. package/ngp/node_modules/picomatch/lib/picomatch.js +342 -0
  453. package/ngp/node_modules/picomatch/lib/scan.js +391 -0
  454. package/ngp/node_modules/picomatch/lib/utils.js +64 -0
  455. package/ngp/node_modules/picomatch/package.json +81 -0
  456. package/ngp/node_modules/proxy-addr/HISTORY.md +161 -0
  457. package/ngp/node_modules/proxy-addr/LICENSE +22 -0
  458. package/ngp/node_modules/proxy-addr/README.md +139 -0
  459. package/ngp/node_modules/proxy-addr/index.js +327 -0
  460. package/ngp/node_modules/proxy-addr/package.json +47 -0
  461. package/ngp/node_modules/qs/.editorconfig +40 -0
  462. package/ngp/node_modules/qs/.eslintrc +38 -0
  463. package/ngp/node_modules/qs/.github/FUNDING.yml +12 -0
  464. package/ngp/node_modules/qs/.nycrc +13 -0
  465. package/ngp/node_modules/qs/CHANGELOG.md +388 -0
  466. package/ngp/node_modules/qs/LICENSE.md +29 -0
  467. package/ngp/node_modules/qs/README.md +623 -0
  468. package/ngp/node_modules/qs/dist/qs.js +2044 -0
  469. package/ngp/node_modules/qs/lib/formats.js +23 -0
  470. package/ngp/node_modules/qs/lib/index.js +11 -0
  471. package/ngp/node_modules/qs/lib/parse.js +263 -0
  472. package/ngp/node_modules/qs/lib/stringify.js +317 -0
  473. package/ngp/node_modules/qs/lib/utils.js +252 -0
  474. package/ngp/node_modules/qs/package.json +73 -0
  475. package/ngp/node_modules/qs/test/parse.js +841 -0
  476. package/ngp/node_modules/qs/test/stringify.js +865 -0
  477. package/ngp/node_modules/qs/test/utils.js +136 -0
  478. package/ngp/node_modules/range-parser/HISTORY.md +56 -0
  479. package/ngp/node_modules/range-parser/LICENSE +23 -0
  480. package/ngp/node_modules/range-parser/README.md +84 -0
  481. package/ngp/node_modules/range-parser/index.js +162 -0
  482. package/ngp/node_modules/range-parser/package.json +44 -0
  483. package/ngp/node_modules/raw-body/HISTORY.md +303 -0
  484. package/ngp/node_modules/raw-body/LICENSE +22 -0
  485. package/ngp/node_modules/raw-body/README.md +223 -0
  486. package/ngp/node_modules/raw-body/SECURITY.md +24 -0
  487. package/ngp/node_modules/raw-body/index.d.ts +87 -0
  488. package/ngp/node_modules/raw-body/index.js +329 -0
  489. package/ngp/node_modules/raw-body/node_modules/bytes/History.md +97 -0
  490. package/ngp/node_modules/raw-body/node_modules/bytes/LICENSE +23 -0
  491. package/ngp/node_modules/raw-body/node_modules/bytes/Readme.md +152 -0
  492. package/ngp/node_modules/raw-body/node_modules/bytes/index.js +170 -0
  493. package/ngp/node_modules/raw-body/node_modules/bytes/package.json +42 -0
  494. package/ngp/node_modules/raw-body/node_modules/iconv-lite/Changelog.md +162 -0
  495. package/ngp/node_modules/raw-body/node_modules/iconv-lite/LICENSE +21 -0
  496. package/ngp/node_modules/raw-body/node_modules/iconv-lite/README.md +156 -0
  497. package/ngp/node_modules/raw-body/node_modules/iconv-lite/encodings/dbcs-codec.js +555 -0
  498. package/ngp/node_modules/raw-body/node_modules/iconv-lite/encodings/dbcs-data.js +176 -0
  499. package/ngp/node_modules/raw-body/node_modules/iconv-lite/encodings/index.js +22 -0
  500. package/ngp/node_modules/raw-body/node_modules/iconv-lite/encodings/internal.js +188 -0
  501. package/ngp/node_modules/raw-body/node_modules/iconv-lite/encodings/sbcs-codec.js +72 -0
  502. package/ngp/node_modules/raw-body/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
  503. package/ngp/node_modules/raw-body/node_modules/iconv-lite/encodings/sbcs-data.js +174 -0
  504. package/ngp/node_modules/raw-body/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
  505. package/ngp/node_modules/raw-body/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
  506. package/ngp/node_modules/raw-body/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
  507. package/ngp/node_modules/raw-body/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
  508. package/ngp/node_modules/raw-body/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
  509. package/ngp/node_modules/raw-body/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
  510. package/ngp/node_modules/raw-body/node_modules/iconv-lite/encodings/tables/gbk-added.json +55 -0
  511. package/ngp/node_modules/raw-body/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
  512. package/ngp/node_modules/raw-body/node_modules/iconv-lite/encodings/utf16.js +177 -0
  513. package/ngp/node_modules/raw-body/node_modules/iconv-lite/encodings/utf7.js +290 -0
  514. package/ngp/node_modules/raw-body/node_modules/iconv-lite/lib/bom-handling.js +52 -0
  515. package/ngp/node_modules/raw-body/node_modules/iconv-lite/lib/extend-node.js +217 -0
  516. package/ngp/node_modules/raw-body/node_modules/iconv-lite/lib/index.d.ts +24 -0
  517. package/ngp/node_modules/raw-body/node_modules/iconv-lite/lib/index.js +153 -0
  518. package/ngp/node_modules/raw-body/node_modules/iconv-lite/lib/streams.js +121 -0
  519. package/ngp/node_modules/raw-body/node_modules/iconv-lite/package.json +46 -0
  520. package/ngp/node_modules/raw-body/package.json +49 -0
  521. package/ngp/node_modules/readdirp/LICENSE +21 -0
  522. package/ngp/node_modules/readdirp/README.md +122 -0
  523. package/ngp/node_modules/readdirp/index.d.ts +43 -0
  524. package/ngp/node_modules/readdirp/index.js +287 -0
  525. package/ngp/node_modules/readdirp/package.json +122 -0
  526. package/ngp/node_modules/safe-buffer/LICENSE +21 -0
  527. package/ngp/node_modules/safe-buffer/README.md +584 -0
  528. package/ngp/node_modules/safe-buffer/index.d.ts +187 -0
  529. package/ngp/node_modules/safe-buffer/index.js +62 -0
  530. package/ngp/node_modules/safe-buffer/package.json +37 -0
  531. package/ngp/node_modules/safer-buffer/LICENSE +21 -0
  532. package/ngp/node_modules/safer-buffer/Porting-Buffer.md +268 -0
  533. package/ngp/node_modules/safer-buffer/Readme.md +156 -0
  534. package/ngp/node_modules/safer-buffer/dangerous.js +58 -0
  535. package/ngp/node_modules/safer-buffer/package.json +34 -0
  536. package/ngp/node_modules/safer-buffer/safer.js +77 -0
  537. package/ngp/node_modules/safer-buffer/tests.js +406 -0
  538. package/ngp/node_modules/send/HISTORY.md +521 -0
  539. package/ngp/node_modules/send/LICENSE +23 -0
  540. package/ngp/node_modules/send/README.md +327 -0
  541. package/ngp/node_modules/send/SECURITY.md +24 -0
  542. package/ngp/node_modules/send/index.js +1143 -0
  543. package/ngp/node_modules/send/node_modules/ms/index.js +162 -0
  544. package/ngp/node_modules/send/node_modules/ms/license.md +21 -0
  545. package/ngp/node_modules/send/node_modules/ms/package.json +38 -0
  546. package/ngp/node_modules/send/node_modules/ms/readme.md +59 -0
  547. package/ngp/node_modules/send/package.json +62 -0
  548. package/ngp/node_modules/serve-static/HISTORY.md +471 -0
  549. package/ngp/node_modules/serve-static/LICENSE +25 -0
  550. package/ngp/node_modules/serve-static/README.md +257 -0
  551. package/ngp/node_modules/serve-static/index.js +210 -0
  552. package/ngp/node_modules/serve-static/package.json +42 -0
  553. package/ngp/node_modules/setprototypeof/LICENSE +13 -0
  554. package/ngp/node_modules/setprototypeof/README.md +31 -0
  555. package/ngp/node_modules/setprototypeof/index.d.ts +2 -0
  556. package/ngp/node_modules/setprototypeof/index.js +17 -0
  557. package/ngp/node_modules/setprototypeof/package.json +38 -0
  558. package/ngp/node_modules/setprototypeof/test/index.js +24 -0
  559. package/ngp/node_modules/side-channel/.eslintignore +1 -0
  560. package/ngp/node_modules/side-channel/.eslintrc +11 -0
  561. package/ngp/node_modules/side-channel/.github/FUNDING.yml +12 -0
  562. package/ngp/node_modules/side-channel/.nycrc +13 -0
  563. package/ngp/node_modules/side-channel/CHANGELOG.md +65 -0
  564. package/ngp/node_modules/side-channel/LICENSE +21 -0
  565. package/ngp/node_modules/side-channel/README.md +2 -0
  566. package/ngp/node_modules/side-channel/index.js +124 -0
  567. package/ngp/node_modules/side-channel/package.json +67 -0
  568. package/ngp/node_modules/side-channel/test/index.js +78 -0
  569. package/ngp/node_modules/statuses/HISTORY.md +82 -0
  570. package/ngp/node_modules/statuses/LICENSE +23 -0
  571. package/ngp/node_modules/statuses/README.md +136 -0
  572. package/ngp/node_modules/statuses/codes.json +65 -0
  573. package/ngp/node_modules/statuses/index.js +146 -0
  574. package/ngp/node_modules/statuses/package.json +49 -0
  575. package/ngp/node_modules/to-regex-range/LICENSE +21 -0
  576. package/ngp/node_modules/to-regex-range/README.md +305 -0
  577. package/ngp/node_modules/to-regex-range/index.js +288 -0
  578. package/ngp/node_modules/to-regex-range/package.json +88 -0
  579. package/ngp/node_modules/toidentifier/HISTORY.md +9 -0
  580. package/ngp/node_modules/toidentifier/LICENSE +21 -0
  581. package/ngp/node_modules/toidentifier/README.md +61 -0
  582. package/ngp/node_modules/toidentifier/index.js +32 -0
  583. package/ngp/node_modules/toidentifier/package.json +38 -0
  584. package/ngp/node_modules/type-is/HISTORY.md +259 -0
  585. package/ngp/node_modules/type-is/LICENSE +23 -0
  586. package/ngp/node_modules/type-is/README.md +170 -0
  587. package/ngp/node_modules/type-is/index.js +266 -0
  588. package/ngp/node_modules/type-is/package.json +45 -0
  589. package/ngp/node_modules/uglify-js/LICENSE +29 -0
  590. package/ngp/node_modules/uglify-js/README.md +1423 -0
  591. package/ngp/node_modules/uglify-js/bin/uglifyjs +603 -0
  592. package/ngp/node_modules/uglify-js/lib/ast.js +2132 -0
  593. package/ngp/node_modules/uglify-js/lib/compress.js +13762 -0
  594. package/ngp/node_modules/uglify-js/lib/minify.js +277 -0
  595. package/ngp/node_modules/uglify-js/lib/mozilla-ast.js +1274 -0
  596. package/ngp/node_modules/uglify-js/lib/output.js +1936 -0
  597. package/ngp/node_modules/uglify-js/lib/parse.js +2559 -0
  598. package/ngp/node_modules/uglify-js/lib/propmangle.js +259 -0
  599. package/ngp/node_modules/uglify-js/lib/scope.js +860 -0
  600. package/ngp/node_modules/uglify-js/lib/sourcemap.js +195 -0
  601. package/ngp/node_modules/uglify-js/lib/transform.js +250 -0
  602. package/ngp/node_modules/uglify-js/lib/utils.js +285 -0
  603. package/ngp/node_modules/uglify-js/package.json +56 -0
  604. package/ngp/node_modules/uglify-js/tools/domprops.html +456 -0
  605. package/ngp/node_modules/uglify-js/tools/domprops.json +8325 -0
  606. package/ngp/node_modules/uglify-js/tools/exports.js +8 -0
  607. package/ngp/node_modules/uglify-js/tools/node.js +110 -0
  608. package/ngp/node_modules/uglify-js/tools/tty.js +22 -0
  609. package/ngp/node_modules/unpipe/HISTORY.md +4 -0
  610. package/ngp/node_modules/unpipe/LICENSE +22 -0
  611. package/ngp/node_modules/unpipe/README.md +43 -0
  612. package/ngp/node_modules/unpipe/index.js +69 -0
  613. package/ngp/node_modules/unpipe/package.json +27 -0
  614. package/ngp/node_modules/utils-merge/LICENSE +20 -0
  615. package/ngp/node_modules/utils-merge/README.md +34 -0
  616. package/ngp/node_modules/utils-merge/index.js +23 -0
  617. package/ngp/node_modules/utils-merge/package.json +40 -0
  618. package/ngp/node_modules/vary/HISTORY.md +39 -0
  619. package/ngp/node_modules/vary/LICENSE +22 -0
  620. package/ngp/node_modules/vary/README.md +101 -0
  621. package/ngp/node_modules/vary/index.js +149 -0
  622. package/ngp/node_modules/vary/package.json +43 -0
  623. package/ngp/package-lock.json +1508 -0
  624. package/package.json +3 -2
  625. package/readme.md +0 -4
@@ -0,0 +1,1936 @@
1
+ /***********************************************************************
2
+
3
+ A JavaScript tokenizer / parser / beautifier / compressor.
4
+ https://github.com/mishoo/UglifyJS
5
+
6
+ -------------------------------- (C) ---------------------------------
7
+
8
+ Author: Mihai Bazon
9
+ <mihai.bazon@gmail.com>
10
+ http://mihai.bazon.net/blog
11
+
12
+ Distributed under the BSD license:
13
+
14
+ Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
15
+
16
+ Redistribution and use in source and binary forms, with or without
17
+ modification, are permitted provided that the following conditions
18
+ are met:
19
+
20
+ * Redistributions of source code must retain the above
21
+ copyright notice, this list of conditions and the following
22
+ disclaimer.
23
+
24
+ * Redistributions in binary form must reproduce the above
25
+ copyright notice, this list of conditions and the following
26
+ disclaimer in the documentation and/or other materials
27
+ provided with the distribution.
28
+
29
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
30
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
32
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
33
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
34
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
35
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
36
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
38
+ TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
39
+ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40
+ SUCH DAMAGE.
41
+
42
+ ***********************************************************************/
43
+
44
+ "use strict";
45
+
46
+ function is_some_comments(comment) {
47
+ // multiline comment
48
+ return comment.type == "comment2" && /@preserve|@license|@cc_on/i.test(comment.value);
49
+ }
50
+
51
+ function OutputStream(options) {
52
+ options = defaults(options, {
53
+ annotations : false,
54
+ ascii_only : false,
55
+ beautify : false,
56
+ braces : false,
57
+ comments : false,
58
+ galio : false,
59
+ ie : false,
60
+ indent_level : 4,
61
+ indent_start : 0,
62
+ inline_script : true,
63
+ keep_quoted_props: false,
64
+ max_line_len : false,
65
+ preamble : null,
66
+ preserve_line : false,
67
+ quote_keys : false,
68
+ quote_style : 0,
69
+ semicolons : true,
70
+ shebang : true,
71
+ source_map : null,
72
+ v8 : false,
73
+ webkit : false,
74
+ width : 80,
75
+ wrap_iife : false,
76
+ }, true);
77
+
78
+ // Convert comment option to RegExp if neccessary and set up comments filter
79
+ var comment_filter = return_false; // Default case, throw all comments away
80
+ if (options.comments) {
81
+ var comments = options.comments;
82
+ if (typeof options.comments === "string" && /^\/.*\/[a-zA-Z]*$/.test(options.comments)) {
83
+ var regex_pos = options.comments.lastIndexOf("/");
84
+ comments = new RegExp(
85
+ options.comments.substr(1, regex_pos - 1),
86
+ options.comments.substr(regex_pos + 1)
87
+ );
88
+ }
89
+ if (comments instanceof RegExp) {
90
+ comment_filter = function(comment) {
91
+ return comment.type != "comment5" && comments.test(comment.value);
92
+ };
93
+ } else if (typeof comments === "function") {
94
+ comment_filter = function(comment) {
95
+ return comment.type != "comment5" && comments(this, comment);
96
+ };
97
+ } else if (comments === "some") {
98
+ comment_filter = is_some_comments;
99
+ } else { // NOTE includes "all" option
100
+ comment_filter = return_true;
101
+ }
102
+ }
103
+
104
+ function make_indent(value) {
105
+ if (typeof value == "number") return new Array(value + 1).join(" ");
106
+ if (!value) return "";
107
+ if (!/^\s*$/.test(value)) throw new Error("unsupported indentation: " + JSON.stringify("" + value));
108
+ return value;
109
+ }
110
+
111
+ var current_col = 0;
112
+ var current_line = 1;
113
+ var current_indent = make_indent(options.indent_start);
114
+ var full_indent = make_indent(options.indent_level);
115
+ var half_indent = full_indent.length + 1 >> 1;
116
+ var last;
117
+ var line_end = 0;
118
+ var line_fixed = true;
119
+ var mappings = options.source_map && [];
120
+ var mapping_name;
121
+ var mapping_token;
122
+ var might_need_space;
123
+ var might_need_semicolon;
124
+ var need_newline_indented = false;
125
+ var need_space = false;
126
+ var output;
127
+ var stack;
128
+ var stored = "";
129
+
130
+ function reset() {
131
+ last = "";
132
+ might_need_space = false;
133
+ might_need_semicolon = false;
134
+ stack = [];
135
+ var str = output;
136
+ output = "";
137
+ return str;
138
+ }
139
+
140
+ reset();
141
+ var to_utf8 = options.ascii_only ? function(str, identifier) {
142
+ if (identifier) str = str.replace(/[\ud800-\udbff][\udc00-\udfff]/g, function(ch) {
143
+ return "\\u{" + (ch.charCodeAt(0) - 0xd7c0 << 10 | ch.charCodeAt(1) - 0xdc00).toString(16) + "}";
144
+ });
145
+ return str.replace(/[\u0000-\u001f\u007f-\uffff]/g, function(ch) {
146
+ var code = ch.charCodeAt(0).toString(16);
147
+ if (code.length <= 2 && !identifier) {
148
+ while (code.length < 2) code = "0" + code;
149
+ return "\\x" + code;
150
+ } else {
151
+ while (code.length < 4) code = "0" + code;
152
+ return "\\u" + code;
153
+ }
154
+ });
155
+ } : function(str) {
156
+ var s = "";
157
+ for (var i = 0, j = 0; i < str.length; i++) {
158
+ var code = str.charCodeAt(i);
159
+ if (is_surrogate_pair_head(code)) {
160
+ if (is_surrogate_pair_tail(str.charCodeAt(i + 1))) {
161
+ i++;
162
+ continue;
163
+ }
164
+ } else if (!is_surrogate_pair_tail(code)) {
165
+ continue;
166
+ }
167
+ s += str.slice(j, i) + "\\u" + code.toString(16);
168
+ j = i + 1;
169
+ }
170
+ return j == 0 ? str : s + str.slice(j);
171
+ };
172
+
173
+ function quote_single(str) {
174
+ return "'" + str.replace(/\x27/g, "\\'") + "'";
175
+ }
176
+
177
+ function quote_double(str) {
178
+ return '"' + str.replace(/\x22/g, '\\"') + '"';
179
+ }
180
+
181
+ var quote_string = [
182
+ null,
183
+ quote_single,
184
+ quote_double,
185
+ function(str, quote) {
186
+ return quote == "'" ? quote_single(str) : quote_double(str);
187
+ },
188
+ ][options.quote_style] || function(str, quote, dq, sq) {
189
+ return dq > sq ? quote_single(str) : quote_double(str);
190
+ };
191
+
192
+ function make_string(str, quote) {
193
+ var dq = 0, sq = 0;
194
+ str = str.replace(/[\\\b\f\n\r\v\t\x22\x27\u2028\u2029\0\ufeff]/g, function(s, i) {
195
+ switch (s) {
196
+ case '"': ++dq; return '"';
197
+ case "'": ++sq; return "'";
198
+ case "\\": return "\\\\";
199
+ case "\n": return "\\n";
200
+ case "\r": return "\\r";
201
+ case "\t": return "\\t";
202
+ case "\b": return "\\b";
203
+ case "\f": return "\\f";
204
+ case "\x0B": return options.ie ? "\\x0B" : "\\v";
205
+ case "\u2028": return "\\u2028";
206
+ case "\u2029": return "\\u2029";
207
+ case "\ufeff": return "\\ufeff";
208
+ case "\0":
209
+ return /[0-9]/.test(str.charAt(i+1)) ? "\\x00" : "\\0";
210
+ }
211
+ return s;
212
+ });
213
+ return quote_string(to_utf8(str), quote, dq, sq);
214
+ }
215
+
216
+ /* -----[ beautification/minification ]----- */
217
+
218
+ var adjust_mappings = mappings ? function(line, col) {
219
+ mappings.forEach(function(mapping) {
220
+ mapping.line += line;
221
+ mapping.col += col;
222
+ });
223
+ } : noop;
224
+
225
+ var flush_mappings = mappings ? function() {
226
+ mappings.forEach(function(mapping) {
227
+ options.source_map.add(
228
+ mapping.token.file,
229
+ mapping.line, mapping.col,
230
+ mapping.token.line, mapping.token.col,
231
+ !mapping.name && mapping.token.type == "name" ? mapping.token.value : mapping.name
232
+ );
233
+ });
234
+ mappings = [];
235
+ } : noop;
236
+
237
+ function insert_newlines(count) {
238
+ stored += output.slice(0, line_end);
239
+ output = output.slice(line_end);
240
+ var new_col = output.length;
241
+ adjust_mappings(count, new_col - current_col);
242
+ current_line += count;
243
+ current_col = new_col;
244
+ while (count--) stored += "\n";
245
+ }
246
+
247
+ var fix_line = options.max_line_len ? function(flush) {
248
+ if (line_fixed) {
249
+ if (current_col > options.max_line_len) {
250
+ AST_Node.warn("Output exceeds {max_line_len} characters", options);
251
+ }
252
+ return;
253
+ }
254
+ if (current_col > options.max_line_len) {
255
+ insert_newlines(1);
256
+ line_fixed = true;
257
+ }
258
+ if (line_fixed || flush) flush_mappings();
259
+ } : noop;
260
+
261
+ var require_semicolon = makePredicate("( [ + * / - , .");
262
+
263
+ var print = options.beautify
264
+ || options.comments
265
+ || options.max_line_len
266
+ || options.preserve_line
267
+ || options.shebang
268
+ || !options.semicolons
269
+ || options.source_map
270
+ || options.width ? function(str) {
271
+ var ch = str.charAt(0);
272
+ if (need_newline_indented && ch) {
273
+ need_newline_indented = false;
274
+ if (ch != "\n") {
275
+ print("\n");
276
+ indent();
277
+ }
278
+ }
279
+ if (need_space && ch) {
280
+ need_space = false;
281
+ if (!/[\s;})]/.test(ch)) {
282
+ space();
283
+ }
284
+ }
285
+ var prev = last.slice(-1);
286
+ if (might_need_semicolon) {
287
+ might_need_semicolon = false;
288
+ if (prev == ":" && ch == "}" || prev != ";" && (!ch || ";}".indexOf(ch) < 0)) {
289
+ var need_semicolon = require_semicolon[ch];
290
+ if (need_semicolon || options.semicolons) {
291
+ output += ";";
292
+ current_col++;
293
+ if (!line_fixed) {
294
+ fix_line();
295
+ if (line_fixed && !need_semicolon && output == ";") {
296
+ output = "";
297
+ current_col = 0;
298
+ }
299
+ }
300
+ if (line_end == output.length - 1) line_end++;
301
+ } else {
302
+ fix_line();
303
+ output += "\n";
304
+ current_line++;
305
+ current_col = 0;
306
+ // reset the semicolon flag, since we didn't print one
307
+ // now and might still have to later
308
+ if (/^\s+$/.test(str)) might_need_semicolon = true;
309
+ }
310
+ if (!options.beautify) might_need_space = false;
311
+ }
312
+ }
313
+
314
+ if (might_need_space) {
315
+ if (is_identifier_char(prev) && (is_identifier_char(ch) || ch == "\\")
316
+ || (ch == "/" && ch == prev)
317
+ || ((ch == "+" || ch == "-") && ch == last)
318
+ || str == "--" && last == "!"
319
+ || str == "in" && prev == "/"
320
+ || last == "--" && ch == ">") {
321
+ output += " ";
322
+ current_col++;
323
+ }
324
+ if (prev != "<" || str != "!") might_need_space = false;
325
+ }
326
+
327
+ if (mapping_token) {
328
+ mappings.push({
329
+ token: mapping_token,
330
+ name: mapping_name,
331
+ line: current_line,
332
+ col: current_col,
333
+ });
334
+ mapping_token = false;
335
+ if (line_fixed) flush_mappings();
336
+ }
337
+
338
+ output += str;
339
+ var a = str.split(/\r?\n/), n = a.length - 1;
340
+ current_line += n;
341
+ current_col += a[0].length;
342
+ if (n > 0) {
343
+ fix_line();
344
+ current_col = a[n].length;
345
+ }
346
+ last = str;
347
+ } : function(str) {
348
+ var ch = str.charAt(0);
349
+ var prev = last.slice(-1);
350
+ if (might_need_semicolon) {
351
+ might_need_semicolon = false;
352
+ if (prev == ":" && ch == "}" || (!ch || ";}".indexOf(ch) < 0) && prev != ";") {
353
+ output += ";";
354
+ might_need_space = false;
355
+ }
356
+ }
357
+ if (might_need_space) {
358
+ if (is_identifier_char(prev) && (is_identifier_char(ch) || ch == "\\")
359
+ || (ch == "/" && ch == prev)
360
+ || ((ch == "+" || ch == "-") && ch == last)
361
+ || str == "--" && last == "!"
362
+ || str == "in" && prev == "/"
363
+ || last == "--" && ch == ">") {
364
+ output += " ";
365
+ }
366
+ if (prev != "<" || str != "!") might_need_space = false;
367
+ }
368
+ output += str;
369
+ last = str;
370
+ };
371
+
372
+ var space = options.beautify ? function() {
373
+ print(" ");
374
+ } : function() {
375
+ might_need_space = true;
376
+ };
377
+
378
+ var indent = options.beautify ? function(half) {
379
+ if (need_newline_indented) print("\n");
380
+ print(half ? current_indent.slice(0, -half_indent) : current_indent);
381
+ } : noop;
382
+
383
+ var with_indent = options.beautify ? function(cont) {
384
+ var save_indentation = current_indent;
385
+ current_indent += full_indent;
386
+ cont();
387
+ current_indent = save_indentation;
388
+ } : function(cont) { cont() };
389
+
390
+ var may_add_newline = options.max_line_len || options.preserve_line ? function() {
391
+ fix_line();
392
+ line_end = output.length;
393
+ line_fixed = false;
394
+ } : noop;
395
+
396
+ var newline = options.beautify ? function() {
397
+ print("\n");
398
+ line_end = output.length;
399
+ } : may_add_newline;
400
+
401
+ var semicolon = options.beautify ? function() {
402
+ print(";");
403
+ } : function() {
404
+ might_need_semicolon = true;
405
+ };
406
+
407
+ function force_semicolon() {
408
+ if (might_need_semicolon) print(";");
409
+ print(";");
410
+ }
411
+
412
+ function with_block(cont) {
413
+ print("{");
414
+ newline();
415
+ with_indent(cont);
416
+ indent();
417
+ print("}");
418
+ }
419
+
420
+ function with_parens(cont) {
421
+ print("(");
422
+ may_add_newline();
423
+ cont();
424
+ may_add_newline();
425
+ print(")");
426
+ }
427
+
428
+ function with_square(cont) {
429
+ print("[");
430
+ may_add_newline();
431
+ cont();
432
+ may_add_newline();
433
+ print("]");
434
+ }
435
+
436
+ function comma() {
437
+ may_add_newline();
438
+ print(",");
439
+ may_add_newline();
440
+ space();
441
+ }
442
+
443
+ function colon() {
444
+ print(":");
445
+ space();
446
+ }
447
+
448
+ var add_mapping = mappings ? function(token, name) {
449
+ mapping_token = token;
450
+ mapping_name = name;
451
+ } : noop;
452
+
453
+ function get() {
454
+ if (!line_fixed) fix_line(true);
455
+ return stored + output;
456
+ }
457
+
458
+ function has_nlb() {
459
+ return /(^|\n) *$/.test(output);
460
+ }
461
+
462
+ function pad_comment(token, force) {
463
+ if (need_newline_indented) return;
464
+ if (token.nlb && (force || !has_nlb())) {
465
+ need_newline_indented = true;
466
+ } else if (force) {
467
+ need_space = true;
468
+ }
469
+ }
470
+
471
+ function print_comment(comment) {
472
+ var value = comment.value.replace(/[@#]__PURE__/g, " ");
473
+ if (/^\s*$/.test(value) && !/^\s*$/.test(comment.value)) return false;
474
+ if (/comment[134]/.test(comment.type)) {
475
+ print("//" + value);
476
+ need_newline_indented = true;
477
+ } else if (comment.type == "comment2") {
478
+ print("/*" + value + "*/");
479
+ }
480
+ return true;
481
+ }
482
+
483
+ function should_merge_comments(node, parent) {
484
+ if (parent instanceof AST_Binary) return parent.left === node;
485
+ if (parent.TYPE == "Call") return parent.expression === node;
486
+ if (parent instanceof AST_Conditional) return parent.condition === node;
487
+ if (parent instanceof AST_Dot) return parent.expression === node;
488
+ if (parent instanceof AST_Exit) return true;
489
+ if (parent instanceof AST_Sequence) return parent.expressions[0] === node;
490
+ if (parent instanceof AST_Sub) return parent.expression === node;
491
+ if (parent instanceof AST_UnaryPostfix) return true;
492
+ if (parent instanceof AST_Yield) return true;
493
+ }
494
+
495
+ function prepend_comments(node) {
496
+ var self = this;
497
+ var scan;
498
+ if (node instanceof AST_Exit) {
499
+ scan = node.value;
500
+ } else if (node instanceof AST_Yield) {
501
+ scan = node.expression;
502
+ }
503
+ var comments = dump(node);
504
+ if (!comments) comments = [];
505
+
506
+ if (scan) {
507
+ var tw = new TreeWalker(function(node) {
508
+ if (!should_merge_comments(node, tw.parent())) return true;
509
+ var before = dump(node);
510
+ if (before) comments = comments.concat(before);
511
+ });
512
+ tw.push(node);
513
+ scan.walk(tw);
514
+ }
515
+
516
+ if (current_line == 1 && current_col == 0) {
517
+ if (comments.length > 0 && options.shebang && comments[0].type == "comment5") {
518
+ print("#!" + comments.shift().value + "\n");
519
+ indent();
520
+ }
521
+ var preamble = options.preamble;
522
+ if (preamble) print(preamble.replace(/\r\n?|\u2028|\u2029|(^|\S)\s*$/g, "$1\n"));
523
+ }
524
+
525
+ comments = comments.filter(comment_filter, node);
526
+ var printed = false;
527
+ comments.forEach(function(comment, index) {
528
+ pad_comment(comment, index);
529
+ if (print_comment(comment)) printed = true;
530
+ });
531
+ if (printed) pad_comment(node.start, true);
532
+
533
+ function dump(node) {
534
+ var token = node.start;
535
+ if (!token) {
536
+ if (!scan) return;
537
+ node.start = token = new AST_Token();
538
+ }
539
+ var comments = token.comments_before;
540
+ if (!comments) {
541
+ if (!scan) return;
542
+ token.comments_before = comments = [];
543
+ }
544
+ if (comments._dumped === self) return;
545
+ comments._dumped = self;
546
+ return comments;
547
+ }
548
+ }
549
+
550
+ function append_comments(node, tail) {
551
+ var self = this;
552
+ var token = node.end;
553
+ if (!token) return;
554
+ var comments = token[tail ? "comments_before" : "comments_after"];
555
+ if (!comments || comments._dumped === self) return;
556
+ if (!(node instanceof AST_Statement || all(comments, function(c) {
557
+ return !/comment[134]/.test(c.type);
558
+ }))) return;
559
+ comments._dumped = self;
560
+ comments.filter(comment_filter, node).forEach(function(comment, index) {
561
+ pad_comment(comment, index || !tail);
562
+ print_comment(comment);
563
+ });
564
+ }
565
+
566
+ return {
567
+ get : get,
568
+ reset : reset,
569
+ indent : indent,
570
+ should_break : options.beautify && options.width ? function() {
571
+ return current_col >= options.width;
572
+ } : return_false,
573
+ has_parens : function() { return last.slice(-1) == "(" },
574
+ newline : newline,
575
+ print : print,
576
+ space : space,
577
+ comma : comma,
578
+ colon : colon,
579
+ last : function() { return last },
580
+ semicolon : semicolon,
581
+ force_semicolon : force_semicolon,
582
+ to_utf8 : to_utf8,
583
+ print_name : function(name) { print(to_utf8(name.toString(), true)) },
584
+ print_string : options.inline_script ? function(str, quote) {
585
+ str = make_string(str, quote).replace(/<\x2f(script)([>\/\t\n\f\r ])/gi, "<\\/$1$2");
586
+ print(str.replace(/\x3c!--/g, "\\x3c!--").replace(/--\x3e/g, "--\\x3e"));
587
+ } : function(str, quote) {
588
+ print(make_string(str, quote));
589
+ },
590
+ with_indent : with_indent,
591
+ with_block : with_block,
592
+ with_parens : with_parens,
593
+ with_square : with_square,
594
+ add_mapping : add_mapping,
595
+ option : function(opt) { return options[opt] },
596
+ prepend_comments: options.comments || options.shebang ? prepend_comments : noop,
597
+ append_comments : options.comments ? append_comments : noop,
598
+ push_node : function(node) { stack.push(node) },
599
+ pop_node : options.preserve_line ? function() {
600
+ var node = stack.pop();
601
+ if (node.start && node.start.line > current_line) {
602
+ insert_newlines(node.start.line - current_line);
603
+ }
604
+ } : function() {
605
+ stack.pop();
606
+ },
607
+ parent : function(n) {
608
+ return stack[stack.length - 2 - (n || 0)];
609
+ },
610
+ };
611
+ }
612
+
613
+ /* -----[ code generators ]----- */
614
+
615
+ (function() {
616
+
617
+ /* -----[ utils ]----- */
618
+
619
+ function DEFPRINT(nodetype, generator) {
620
+ nodetype.DEFMETHOD("_codegen", generator);
621
+ }
622
+
623
+ var use_asm = false;
624
+
625
+ AST_Node.DEFMETHOD("print", function(stream, force_parens) {
626
+ var self = this;
627
+ stream.push_node(self);
628
+ if (force_parens || self.needs_parens(stream)) {
629
+ stream.with_parens(doit);
630
+ } else {
631
+ doit();
632
+ }
633
+ stream.pop_node();
634
+
635
+ function doit() {
636
+ stream.prepend_comments(self);
637
+ self.add_source_map(stream);
638
+ self._codegen(stream);
639
+ stream.append_comments(self);
640
+ }
641
+ });
642
+ var readonly = OutputStream({
643
+ inline_script: false,
644
+ shebang: false,
645
+ width: false,
646
+ });
647
+ AST_Node.DEFMETHOD("print_to_string", function(options) {
648
+ if (options) {
649
+ var stream = OutputStream(options);
650
+ this.print(stream);
651
+ return stream.get();
652
+ }
653
+ this.print(readonly);
654
+ return readonly.reset();
655
+ });
656
+
657
+ /* -----[ PARENTHESES ]----- */
658
+
659
+ function PARENS(nodetype, func) {
660
+ nodetype.DEFMETHOD("needs_parens", func);
661
+ }
662
+
663
+ PARENS(AST_Node, return_false);
664
+
665
+ // a function expression needs parens around it when it's provably
666
+ // the first token to appear in a statement.
667
+ function needs_parens_function(output) {
668
+ var p = output.parent();
669
+ if (!output.has_parens() && first_in_statement(output, false, true)) {
670
+ // export default function() {}
671
+ // export default (function foo() {});
672
+ // export default (function() {})(foo);
673
+ // export default (function() {})`foo`;
674
+ // export default (function() {}) ? foo : bar;
675
+ return this.name || !(p instanceof AST_ExportDefault);
676
+ }
677
+ if (output.option("webkit") && p instanceof AST_PropAccess && p.expression === this) return true;
678
+ if (output.option("wrap_iife") && p instanceof AST_Call && p.expression === this) return true;
679
+ }
680
+ PARENS(AST_AsyncFunction, needs_parens_function);
681
+ PARENS(AST_AsyncGeneratorFunction, needs_parens_function);
682
+ PARENS(AST_ClassExpression, needs_parens_function);
683
+ PARENS(AST_Function, needs_parens_function);
684
+ PARENS(AST_GeneratorFunction, needs_parens_function);
685
+
686
+ // same goes for an object literal, because otherwise it would be
687
+ // interpreted as a block of code.
688
+ function needs_parens_obj(output) {
689
+ return !output.has_parens() && first_in_statement(output, true);
690
+ }
691
+ PARENS(AST_Object, needs_parens_obj);
692
+
693
+ function needs_parens_unary(output) {
694
+ var p = output.parent();
695
+ // (-x) ** y
696
+ if (p instanceof AST_Binary) return p.operator == "**" && p.left === this;
697
+ // (await x)(y)
698
+ // new (await x)
699
+ if (p instanceof AST_Call) return p.expression === this;
700
+ // class extends (x++) {}
701
+ // class x extends (typeof y) {}
702
+ if (p instanceof AST_Class) return true;
703
+ // (x++)[y]
704
+ // (typeof x).y
705
+ if (p instanceof AST_PropAccess) return p.expression === this;
706
+ // (~x)`foo`
707
+ if (p instanceof AST_Template) return p.tag === this;
708
+ }
709
+ PARENS(AST_Await, needs_parens_unary);
710
+ PARENS(AST_Unary, needs_parens_unary);
711
+
712
+ PARENS(AST_Sequence, function(output) {
713
+ var p = output.parent();
714
+ // [ 1, (2, 3), 4 ] ---> [ 1, 3, 4 ]
715
+ return p instanceof AST_Array
716
+ // () ---> (foo, bar)
717
+ || is_arrow(p) && p.value === this
718
+ // await (foo, bar)
719
+ || p instanceof AST_Await
720
+ // 1 + (2, 3) + 4 ---> 8
721
+ || p instanceof AST_Binary
722
+ // new (foo, bar) or foo(1, (2, 3), 4)
723
+ || p instanceof AST_Call
724
+ // class extends (foo, bar) {}
725
+ // class foo extends (bar, baz) {}
726
+ || p instanceof AST_Class
727
+ // class { foo = (bar, baz) }
728
+ // class { [(foo, bar)]() {} }
729
+ || p instanceof AST_ClassProperty
730
+ // (false, true) ? (a = 10, b = 20) : (c = 30)
731
+ // ---> 20 (side effect, set a := 10 and b := 20)
732
+ || p instanceof AST_Conditional
733
+ // [ a = (1, 2) ] = [] ---> a == 2
734
+ || p instanceof AST_DefaultValue
735
+ // { [(1, 2)]: foo } = bar
736
+ // { 1: (2, foo) } = bar
737
+ || p instanceof AST_DestructuredKeyVal
738
+ // export default (foo, bar)
739
+ || p instanceof AST_ExportDefault
740
+ // for (foo of (bar, baz));
741
+ || p instanceof AST_ForOf
742
+ // { [(1, 2)]: 3 }[2] ---> 3
743
+ // { foo: (1, 2) }.foo ---> 2
744
+ || p instanceof AST_ObjectProperty
745
+ // (1, {foo:2}).foo or (1, {foo:2})["foo"] ---> 2
746
+ || p instanceof AST_PropAccess && p.expression === this
747
+ // ...(foo, bar, baz)
748
+ || p instanceof AST_Spread
749
+ // (foo, bar)`baz`
750
+ || p instanceof AST_Template && p.tag === this
751
+ // !(foo, bar, baz)
752
+ || p instanceof AST_Unary
753
+ // var a = (1, 2), b = a + a; ---> b == 4
754
+ || p instanceof AST_VarDef
755
+ // yield (foo, bar)
756
+ || p instanceof AST_Yield;
757
+ });
758
+
759
+ PARENS(AST_Binary, function(output) {
760
+ var p = output.parent();
761
+ // await (foo && bar)
762
+ if (p instanceof AST_Await) return true;
763
+ // this deals with precedence:
764
+ // 3 * (2 + 1)
765
+ // 3 - (2 - 1)
766
+ // (1 ** 2) ** 3
767
+ if (p instanceof AST_Binary) {
768
+ var po = p.operator, pp = PRECEDENCE[po];
769
+ var so = this.operator, sp = PRECEDENCE[so];
770
+ return pp > sp
771
+ || po == "??" && (so == "&&" || so == "||")
772
+ || (pp == sp && this === p[po == "**" ? "left" : "right"]);
773
+ }
774
+ // (foo && bar)()
775
+ if (p instanceof AST_Call) return p.expression === this;
776
+ // class extends (foo && bar) {}
777
+ // class foo extends (bar || null) {}
778
+ if (p instanceof AST_Class) return true;
779
+ // (foo && bar)["prop"], (foo && bar).prop
780
+ if (p instanceof AST_PropAccess) return p.expression === this;
781
+ // (foo && bar)``
782
+ if (p instanceof AST_Template) return p.tag === this;
783
+ // typeof (foo && bar)
784
+ if (p instanceof AST_Unary) return true;
785
+ });
786
+
787
+ function need_chain_parens(node, parent) {
788
+ if (!node.terminal) return false;
789
+ if (!(parent instanceof AST_Call || parent instanceof AST_PropAccess)) return false;
790
+ return parent.expression === node;
791
+ }
792
+
793
+ PARENS(AST_PropAccess, function(output) {
794
+ var node = this;
795
+ var p = output.parent();
796
+ // i.e. new (foo().bar)
797
+ //
798
+ // if there's one call into this subtree, then we need
799
+ // parens around it too, otherwise the call will be
800
+ // interpreted as passing the arguments to the upper New
801
+ // expression.
802
+ if (p instanceof AST_New && p.expression === node && root_expr(node).TYPE == "Call") return true;
803
+ // (foo?.bar)()
804
+ // (foo?.bar).baz
805
+ // new (foo?.bar)()
806
+ return need_chain_parens(node, p);
807
+ });
808
+
809
+ PARENS(AST_Call, function(output) {
810
+ var node = this;
811
+ var p = output.parent();
812
+ if (p instanceof AST_New) return p.expression === node;
813
+ // https://bugs.webkit.org/show_bug.cgi?id=123506
814
+ if (output.option("webkit")
815
+ && node.expression instanceof AST_Function
816
+ && p instanceof AST_PropAccess
817
+ && p.expression === node) {
818
+ var g = output.parent(1);
819
+ if (g instanceof AST_Assign && g.left === p) return true;
820
+ }
821
+ // (foo?.())()
822
+ // (foo?.()).bar
823
+ // new (foo?.())()
824
+ return need_chain_parens(node, p);
825
+ });
826
+
827
+ PARENS(AST_New, function(output) {
828
+ if (need_constructor_parens(this, output)) return false;
829
+ var p = output.parent();
830
+ // (new foo)(bar)
831
+ if (p instanceof AST_Call) return p.expression === this;
832
+ // (new Date).getTime(), (new Date)["getTime"]()
833
+ if (p instanceof AST_PropAccess) return true;
834
+ // (new foo)`bar`
835
+ if (p instanceof AST_Template) return p.tag === this;
836
+ });
837
+
838
+ PARENS(AST_Number, function(output) {
839
+ if (!output.option("galio")) return false;
840
+ // https://github.com/mishoo/UglifyJS/pull/1009
841
+ var p = output.parent();
842
+ return p instanceof AST_PropAccess && p.expression === this && /^0/.test(make_num(this.value));
843
+ });
844
+
845
+ function needs_parens_assign_cond(self, output) {
846
+ var p = output.parent();
847
+ // await (a = foo)
848
+ if (p instanceof AST_Await) return true;
849
+ // 1 + (a = 2) + 3 → 6, side effect setting a = 2
850
+ if (p instanceof AST_Binary) return !(p instanceof AST_Assign);
851
+ // (a = func)() —or— new (a = Object)()
852
+ if (p instanceof AST_Call) return p.expression === self;
853
+ // class extends (a = foo) {}
854
+ // class foo extends (bar ? baz : moo) {}
855
+ if (p instanceof AST_Class) return true;
856
+ // (a = foo) ? bar : baz
857
+ if (p instanceof AST_Conditional) return p.condition === self;
858
+ // (a = foo)["prop"] —or— (a = foo).prop
859
+ if (p instanceof AST_PropAccess) return p.expression === self;
860
+ // (a = foo)`bar`
861
+ if (p instanceof AST_Template) return p.tag === self;
862
+ // !(a = false) → true
863
+ if (p instanceof AST_Unary) return true;
864
+ }
865
+ PARENS(AST_Arrow, function(output) {
866
+ return needs_parens_assign_cond(this, output);
867
+ });
868
+ PARENS(AST_Assign, function(output) {
869
+ if (needs_parens_assign_cond(this, output)) return true;
870
+ // v8 parser bug ---> workaround
871
+ // f([1], [a] = []) ---> f([1], ([a] = []))
872
+ if (output.option("v8")) return this.left instanceof AST_Destructured;
873
+ // ({ p: a } = o);
874
+ if (this.left instanceof AST_DestructuredObject) return needs_parens_obj(output);
875
+ });
876
+ PARENS(AST_AsyncArrow, function(output) {
877
+ return needs_parens_assign_cond(this, output);
878
+ });
879
+ PARENS(AST_Conditional, function(output) {
880
+ return needs_parens_assign_cond(this, output);
881
+ });
882
+ PARENS(AST_Yield, function(output) {
883
+ return needs_parens_assign_cond(this, output);
884
+ });
885
+
886
+ /* -----[ PRINTERS ]----- */
887
+
888
+ DEFPRINT(AST_Directive, function(output) {
889
+ var quote = this.quote;
890
+ var value = this.value;
891
+ switch (output.option("quote_style")) {
892
+ case 0:
893
+ case 2:
894
+ if (value.indexOf('"') == -1) quote = '"';
895
+ break;
896
+ case 1:
897
+ if (value.indexOf("'") == -1) quote = "'";
898
+ break;
899
+ }
900
+ output.print(quote + value + quote);
901
+ output.semicolon();
902
+ });
903
+ DEFPRINT(AST_Debugger, function(output) {
904
+ output.print("debugger");
905
+ output.semicolon();
906
+ });
907
+
908
+ /* -----[ statements ]----- */
909
+
910
+ function display_body(body, is_toplevel, output, allow_directives) {
911
+ var last = body.length - 1;
912
+ var in_directive = allow_directives;
913
+ var was_asm = use_asm;
914
+ body.forEach(function(stmt, i) {
915
+ if (in_directive) {
916
+ if (stmt instanceof AST_Directive) {
917
+ if (stmt.value == "use asm") use_asm = true;
918
+ } else if (!(stmt instanceof AST_EmptyStatement)) {
919
+ if (stmt instanceof AST_SimpleStatement && stmt.body instanceof AST_String) {
920
+ output.force_semicolon();
921
+ }
922
+ in_directive = false;
923
+ }
924
+ }
925
+ if (stmt instanceof AST_EmptyStatement) return;
926
+ output.indent();
927
+ stmt.print(output);
928
+ if (i == last && is_toplevel) return;
929
+ output.newline();
930
+ if (is_toplevel) output.newline();
931
+ });
932
+ use_asm = was_asm;
933
+ }
934
+
935
+ DEFPRINT(AST_Toplevel, function(output) {
936
+ display_body(this.body, true, output, true);
937
+ output.print("");
938
+ });
939
+ DEFPRINT(AST_LabeledStatement, function(output) {
940
+ this.label.print(output);
941
+ output.colon();
942
+ this.body.print(output);
943
+ });
944
+ DEFPRINT(AST_SimpleStatement, function(output) {
945
+ this.body.print(output);
946
+ output.semicolon();
947
+ });
948
+ function print_braced_empty(self, output) {
949
+ output.print("{");
950
+ output.with_indent(function() {
951
+ output.append_comments(self, true);
952
+ });
953
+ output.print("}");
954
+ }
955
+ function print_braced(self, output, allow_directives) {
956
+ if (self.body.length > 0) {
957
+ output.with_block(function() {
958
+ display_body(self.body, false, output, allow_directives);
959
+ });
960
+ } else print_braced_empty(self, output);
961
+ }
962
+ DEFPRINT(AST_BlockStatement, function(output) {
963
+ print_braced(this, output);
964
+ });
965
+ DEFPRINT(AST_EmptyStatement, function(output) {
966
+ output.semicolon();
967
+ });
968
+ DEFPRINT(AST_Do, function(output) {
969
+ var self = this;
970
+ output.print("do");
971
+ make_block(self.body, output);
972
+ output.space();
973
+ output.print("while");
974
+ output.space();
975
+ output.with_parens(function() {
976
+ self.condition.print(output);
977
+ });
978
+ output.semicolon();
979
+ });
980
+ DEFPRINT(AST_While, function(output) {
981
+ var self = this;
982
+ output.print("while");
983
+ output.space();
984
+ output.with_parens(function() {
985
+ self.condition.print(output);
986
+ });
987
+ force_statement(self.body, output);
988
+ });
989
+ DEFPRINT(AST_For, function(output) {
990
+ var self = this;
991
+ output.print("for");
992
+ output.space();
993
+ output.with_parens(function() {
994
+ if (self.init) {
995
+ if (self.init instanceof AST_Definitions) {
996
+ self.init.print(output);
997
+ } else {
998
+ parenthesize_for_noin(self.init, output, true);
999
+ }
1000
+ output.print(";");
1001
+ output.space();
1002
+ } else {
1003
+ output.print(";");
1004
+ }
1005
+ if (self.condition) {
1006
+ self.condition.print(output);
1007
+ output.print(";");
1008
+ output.space();
1009
+ } else {
1010
+ output.print(";");
1011
+ }
1012
+ if (self.step) {
1013
+ self.step.print(output);
1014
+ }
1015
+ });
1016
+ force_statement(self.body, output);
1017
+ });
1018
+ function print_for_enum(prefix, infix) {
1019
+ return function(output) {
1020
+ var self = this;
1021
+ output.print(prefix);
1022
+ output.space();
1023
+ output.with_parens(function() {
1024
+ self.init.print(output);
1025
+ output.space();
1026
+ output.print(infix);
1027
+ output.space();
1028
+ self.object.print(output);
1029
+ });
1030
+ force_statement(self.body, output);
1031
+ };
1032
+ }
1033
+ DEFPRINT(AST_ForAwaitOf, print_for_enum("for await", "of"));
1034
+ DEFPRINT(AST_ForIn, print_for_enum("for", "in"));
1035
+ DEFPRINT(AST_ForOf, print_for_enum("for", "of"));
1036
+ DEFPRINT(AST_With, function(output) {
1037
+ var self = this;
1038
+ output.print("with");
1039
+ output.space();
1040
+ output.with_parens(function() {
1041
+ self.expression.print(output);
1042
+ });
1043
+ force_statement(self.body, output);
1044
+ });
1045
+ DEFPRINT(AST_ExportDeclaration, function(output) {
1046
+ output.print("export");
1047
+ output.space();
1048
+ this.body.print(output);
1049
+ });
1050
+ DEFPRINT(AST_ExportDefault, function(output) {
1051
+ output.print("export");
1052
+ output.space();
1053
+ output.print("default");
1054
+ output.space();
1055
+ var body = this.body;
1056
+ body.print(output);
1057
+ if (body instanceof AST_ClassExpression) {
1058
+ if (!body.name) return;
1059
+ }
1060
+ if (body instanceof AST_DefClass) return;
1061
+ if (body instanceof AST_LambdaDefinition) return;
1062
+ if (body instanceof AST_LambdaExpression) {
1063
+ if (!body.name && !is_arrow(body)) return;
1064
+ }
1065
+ output.semicolon();
1066
+ });
1067
+ DEFPRINT(AST_ExportForeign, function(output) {
1068
+ var self = this;
1069
+ output.print("export");
1070
+ output.space();
1071
+ var len = self.keys.length;
1072
+ if (len == 0) {
1073
+ print_braced_empty(self, output);
1074
+ } else if (self.keys[0] == "*") {
1075
+ print_entry(0);
1076
+ } else output.with_block(function() {
1077
+ output.indent();
1078
+ print_entry(0);
1079
+ for (var i = 1; i < len; i++) {
1080
+ output.print(",");
1081
+ output.newline();
1082
+ output.indent();
1083
+ print_entry(i);
1084
+ }
1085
+ output.newline();
1086
+ });
1087
+ output.space();
1088
+ output.print("from");
1089
+ output.space();
1090
+ output.print_string(self.path, self.quote);
1091
+ output.semicolon();
1092
+
1093
+ function print_entry(index) {
1094
+ var alias = self.aliases[index];
1095
+ var key = self.keys[index];
1096
+ output.print_name(key);
1097
+ if (alias != key) {
1098
+ output.space();
1099
+ output.print("as");
1100
+ output.space();
1101
+ output.print_name(alias);
1102
+ }
1103
+ }
1104
+ });
1105
+ DEFPRINT(AST_ExportReferences, function(output) {
1106
+ var self = this;
1107
+ output.print("export");
1108
+ output.space();
1109
+ print_properties(self, output);
1110
+ output.semicolon();
1111
+ });
1112
+ DEFPRINT(AST_Import, function(output) {
1113
+ var self = this;
1114
+ output.print("import");
1115
+ output.space();
1116
+ if (self.default) self.default.print(output);
1117
+ if (self.all) {
1118
+ if (self.default) output.comma();
1119
+ self.all.print(output);
1120
+ }
1121
+ if (self.properties) {
1122
+ if (self.default) output.comma();
1123
+ print_properties(self, output);
1124
+ }
1125
+ if (self.all || self.default || self.properties) {
1126
+ output.space();
1127
+ output.print("from");
1128
+ output.space();
1129
+ }
1130
+ output.print_string(self.path, self.quote);
1131
+ output.semicolon();
1132
+ });
1133
+
1134
+ /* -----[ functions ]----- */
1135
+ function print_funargs(self, output) {
1136
+ output.with_parens(function() {
1137
+ self.argnames.forEach(function(arg, i) {
1138
+ if (i) output.comma();
1139
+ arg.print(output);
1140
+ });
1141
+ if (self.rest) {
1142
+ if (self.argnames.length) output.comma();
1143
+ output.print("...");
1144
+ self.rest.print(output);
1145
+ }
1146
+ });
1147
+ }
1148
+ function print_arrow(self, output) {
1149
+ var argname = self.argnames.length == 1 && !self.rest && self.argnames[0];
1150
+ if (argname instanceof AST_SymbolFunarg && argname.name != "yield") {
1151
+ argname.print(output);
1152
+ } else {
1153
+ print_funargs(self, output);
1154
+ }
1155
+ output.space();
1156
+ output.print("=>");
1157
+ output.space();
1158
+ if (self.value) {
1159
+ self.value.print(output);
1160
+ } else {
1161
+ print_braced(self, output, true);
1162
+ }
1163
+ }
1164
+ DEFPRINT(AST_Arrow, function(output) {
1165
+ print_arrow(this, output);
1166
+ });
1167
+ DEFPRINT(AST_AsyncArrow, function(output) {
1168
+ output.print("async");
1169
+ output.space();
1170
+ print_arrow(this, output);
1171
+ });
1172
+ function print_lambda(self, output) {
1173
+ if (self.name) {
1174
+ output.space();
1175
+ self.name.print(output);
1176
+ }
1177
+ print_funargs(self, output);
1178
+ output.space();
1179
+ print_braced(self, output, true);
1180
+ }
1181
+ DEFPRINT(AST_Lambda, function(output) {
1182
+ output.print("function");
1183
+ print_lambda(this, output);
1184
+ });
1185
+ function print_async(output) {
1186
+ output.print("async");
1187
+ output.space();
1188
+ output.print("function");
1189
+ print_lambda(this, output);
1190
+ }
1191
+ DEFPRINT(AST_AsyncDefun, print_async);
1192
+ DEFPRINT(AST_AsyncFunction, print_async);
1193
+ function print_async_generator(output) {
1194
+ output.print("async");
1195
+ output.space();
1196
+ output.print("function*");
1197
+ print_lambda(this, output);
1198
+ }
1199
+ DEFPRINT(AST_AsyncGeneratorDefun, print_async_generator);
1200
+ DEFPRINT(AST_AsyncGeneratorFunction, print_async_generator);
1201
+ function print_generator(output) {
1202
+ output.print("function*");
1203
+ print_lambda(this, output);
1204
+ }
1205
+ DEFPRINT(AST_GeneratorDefun, print_generator);
1206
+ DEFPRINT(AST_GeneratorFunction, print_generator);
1207
+
1208
+ /* -----[ classes ]----- */
1209
+ DEFPRINT(AST_Class, function(output) {
1210
+ var self = this;
1211
+ output.print("class");
1212
+ if (self.name) {
1213
+ output.space();
1214
+ self.name.print(output);
1215
+ }
1216
+ if (self.extends) {
1217
+ output.space();
1218
+ output.print("extends");
1219
+ output.space();
1220
+ self.extends.print(output);
1221
+ }
1222
+ output.space();
1223
+ print_properties(self, output, true);
1224
+ });
1225
+ DEFPRINT(AST_ClassField, function(output) {
1226
+ var self = this;
1227
+ if (self.static) {
1228
+ output.print("static");
1229
+ output.space();
1230
+ }
1231
+ print_property_key(self, output);
1232
+ if (self.value) {
1233
+ output.space();
1234
+ output.print("=");
1235
+ output.space();
1236
+ self.value.print(output);
1237
+ }
1238
+ output.semicolon();
1239
+ });
1240
+ DEFPRINT(AST_ClassGetter, print_accessor("get"));
1241
+ DEFPRINT(AST_ClassSetter, print_accessor("set"));
1242
+ function print_method(self, output) {
1243
+ var fn = self.value;
1244
+ if (is_async(fn)) {
1245
+ output.print("async");
1246
+ output.space();
1247
+ }
1248
+ if (is_generator(fn)) output.print("*");
1249
+ print_property_key(self, output);
1250
+ print_lambda(self.value, output);
1251
+ }
1252
+ DEFPRINT(AST_ClassMethod, function(output) {
1253
+ var self = this;
1254
+ if (self.static) {
1255
+ output.print("static");
1256
+ output.space();
1257
+ }
1258
+ print_method(self, output);
1259
+ });
1260
+
1261
+ /* -----[ jumps ]----- */
1262
+ function print_jump(kind, prop) {
1263
+ return function(output) {
1264
+ output.print(kind);
1265
+ var target = this[prop];
1266
+ if (target) {
1267
+ output.space();
1268
+ target.print(output);
1269
+ }
1270
+ output.semicolon();
1271
+ };
1272
+ }
1273
+ DEFPRINT(AST_Return, print_jump("return", "value"));
1274
+ DEFPRINT(AST_Throw, print_jump("throw", "value"));
1275
+ DEFPRINT(AST_Break, print_jump("break", "label"));
1276
+ DEFPRINT(AST_Continue, print_jump("continue", "label"));
1277
+
1278
+ /* -----[ if ]----- */
1279
+ function make_then(self, output) {
1280
+ var b = self.body;
1281
+ if (output.option("braces") && !(b instanceof AST_Const || b instanceof AST_Let)
1282
+ || output.option("ie") && b instanceof AST_Do)
1283
+ return make_block(b, output);
1284
+ // The squeezer replaces "block"-s that contain only a single
1285
+ // statement with the statement itself; technically, the AST
1286
+ // is correct, but this can create problems when we output an
1287
+ // IF having an ELSE clause where the THEN clause ends in an
1288
+ // IF *without* an ELSE block (then the outer ELSE would refer
1289
+ // to the inner IF). This function checks for this case and
1290
+ // adds the block braces if needed.
1291
+ if (!b) return output.force_semicolon();
1292
+ while (true) {
1293
+ if (b instanceof AST_If) {
1294
+ if (!b.alternative) {
1295
+ make_block(self.body, output);
1296
+ return;
1297
+ }
1298
+ b = b.alternative;
1299
+ } else if (b instanceof AST_StatementWithBody) {
1300
+ b = b.body;
1301
+ } else break;
1302
+ }
1303
+ force_statement(self.body, output);
1304
+ }
1305
+ DEFPRINT(AST_If, function(output) {
1306
+ var self = this;
1307
+ output.print("if");
1308
+ output.space();
1309
+ output.with_parens(function() {
1310
+ self.condition.print(output);
1311
+ });
1312
+ if (self.alternative) {
1313
+ make_then(self, output);
1314
+ output.space();
1315
+ output.print("else");
1316
+ if (self.alternative instanceof AST_If) {
1317
+ output.space();
1318
+ self.alternative.print(output);
1319
+ } else {
1320
+ force_statement(self.alternative, output);
1321
+ }
1322
+ } else {
1323
+ force_statement(self.body, output);
1324
+ }
1325
+ });
1326
+
1327
+ /* -----[ switch ]----- */
1328
+ DEFPRINT(AST_Switch, function(output) {
1329
+ var self = this;
1330
+ output.print("switch");
1331
+ output.space();
1332
+ output.with_parens(function() {
1333
+ self.expression.print(output);
1334
+ });
1335
+ output.space();
1336
+ var last = self.body.length - 1;
1337
+ if (last < 0) print_braced_empty(self, output);
1338
+ else output.with_block(function() {
1339
+ self.body.forEach(function(branch, i) {
1340
+ output.indent(true);
1341
+ branch.print(output);
1342
+ if (i < last && branch.body.length > 0)
1343
+ output.newline();
1344
+ });
1345
+ });
1346
+ });
1347
+ function print_branch_body(self, output) {
1348
+ output.newline();
1349
+ self.body.forEach(function(stmt) {
1350
+ output.indent();
1351
+ stmt.print(output);
1352
+ output.newline();
1353
+ });
1354
+ }
1355
+ DEFPRINT(AST_Default, function(output) {
1356
+ output.print("default:");
1357
+ print_branch_body(this, output);
1358
+ });
1359
+ DEFPRINT(AST_Case, function(output) {
1360
+ var self = this;
1361
+ output.print("case");
1362
+ output.space();
1363
+ self.expression.print(output);
1364
+ output.print(":");
1365
+ print_branch_body(self, output);
1366
+ });
1367
+
1368
+ /* -----[ exceptions ]----- */
1369
+ DEFPRINT(AST_Try, function(output) {
1370
+ var self = this;
1371
+ output.print("try");
1372
+ output.space();
1373
+ print_braced(self, output);
1374
+ if (self.bcatch) {
1375
+ output.space();
1376
+ self.bcatch.print(output);
1377
+ }
1378
+ if (self.bfinally) {
1379
+ output.space();
1380
+ self.bfinally.print(output);
1381
+ }
1382
+ });
1383
+ DEFPRINT(AST_Catch, function(output) {
1384
+ var self = this;
1385
+ output.print("catch");
1386
+ if (self.argname) {
1387
+ output.space();
1388
+ output.with_parens(function() {
1389
+ self.argname.print(output);
1390
+ });
1391
+ }
1392
+ output.space();
1393
+ print_braced(self, output);
1394
+ });
1395
+ DEFPRINT(AST_Finally, function(output) {
1396
+ output.print("finally");
1397
+ output.space();
1398
+ print_braced(this, output);
1399
+ });
1400
+
1401
+ function print_definitinos(type) {
1402
+ return function(output) {
1403
+ var self = this;
1404
+ output.print(type);
1405
+ output.space();
1406
+ self.definitions.forEach(function(def, i) {
1407
+ if (i) output.comma();
1408
+ def.print(output);
1409
+ });
1410
+ var p = output.parent();
1411
+ if (!(p instanceof AST_IterationStatement && p.init === self)) output.semicolon();
1412
+ };
1413
+ }
1414
+ DEFPRINT(AST_Const, print_definitinos("const"));
1415
+ DEFPRINT(AST_Let, print_definitinos("let"));
1416
+ DEFPRINT(AST_Var, print_definitinos("var"));
1417
+
1418
+ function parenthesize_for_noin(node, output, noin) {
1419
+ var parens = false;
1420
+ // need to take some precautions here:
1421
+ // https://github.com/mishoo/UglifyJS/issues/60
1422
+ if (noin) node.walk(new TreeWalker(function(node) {
1423
+ if (parens) return true;
1424
+ if (node instanceof AST_Binary && node.operator == "in") return parens = true;
1425
+ if (node instanceof AST_Scope && !(is_arrow(node) && node.value)) return true;
1426
+ }));
1427
+ node.print(output, parens);
1428
+ }
1429
+
1430
+ DEFPRINT(AST_VarDef, function(output) {
1431
+ var self = this;
1432
+ self.name.print(output);
1433
+ if (self.value) {
1434
+ output.space();
1435
+ output.print("=");
1436
+ output.space();
1437
+ var p = output.parent(1);
1438
+ var noin = p instanceof AST_For || p instanceof AST_ForEnumeration;
1439
+ parenthesize_for_noin(self.value, output, noin);
1440
+ }
1441
+ });
1442
+
1443
+ DEFPRINT(AST_DefaultValue, function(output) {
1444
+ var self = this;
1445
+ self.name.print(output);
1446
+ output.space();
1447
+ output.print("=");
1448
+ output.space();
1449
+ self.value.print(output);
1450
+ });
1451
+
1452
+ /* -----[ other expressions ]----- */
1453
+ function print_annotation(self, output) {
1454
+ if (!output.option("annotations")) return;
1455
+ if (!self.pure) return;
1456
+ var level = 0, parent = self, node;
1457
+ do {
1458
+ node = parent;
1459
+ parent = output.parent(level++);
1460
+ if (parent instanceof AST_Call && parent.expression === node) return;
1461
+ } while (parent instanceof AST_PropAccess && parent.expression === node);
1462
+ output.print("/*@__PURE__*/");
1463
+ }
1464
+ function print_call_args(self, output) {
1465
+ if (self.expression instanceof AST_Call || self.expression instanceof AST_Lambda) {
1466
+ output.add_mapping(self.start);
1467
+ }
1468
+ output.with_parens(function() {
1469
+ self.args.forEach(function(expr, i) {
1470
+ if (i) output.comma();
1471
+ expr.print(output);
1472
+ });
1473
+ });
1474
+ }
1475
+ DEFPRINT(AST_Call, function(output) {
1476
+ var self = this;
1477
+ print_annotation(self, output);
1478
+ self.expression.print(output);
1479
+ if (self.optional) output.print("?.");
1480
+ print_call_args(self, output);
1481
+ });
1482
+ DEFPRINT(AST_New, function(output) {
1483
+ var self = this;
1484
+ print_annotation(self, output);
1485
+ output.print("new");
1486
+ output.space();
1487
+ self.expression.print(output);
1488
+ if (need_constructor_parens(self, output)) print_call_args(self, output);
1489
+ });
1490
+ DEFPRINT(AST_Sequence, function(output) {
1491
+ this.expressions.forEach(function(node, index) {
1492
+ if (index > 0) {
1493
+ output.comma();
1494
+ if (output.should_break()) {
1495
+ output.newline();
1496
+ output.indent();
1497
+ }
1498
+ }
1499
+ node.print(output);
1500
+ });
1501
+ });
1502
+ DEFPRINT(AST_Dot, function(output) {
1503
+ var self = this;
1504
+ var expr = self.expression;
1505
+ expr.print(output);
1506
+ var prop = self.property;
1507
+ if (output.option("ie") && RESERVED_WORDS[prop]) {
1508
+ output.print(self.optional ? "?.[" : "[");
1509
+ output.add_mapping(self.end);
1510
+ output.print_string(prop);
1511
+ output.print("]");
1512
+ } else {
1513
+ if (expr instanceof AST_Number && !/[ex.)]/i.test(output.last())) output.print(".");
1514
+ output.print(self.optional ? "?." : ".");
1515
+ // the name after dot would be mapped about here.
1516
+ output.add_mapping(self.end);
1517
+ output.print_name(prop);
1518
+ }
1519
+ });
1520
+ DEFPRINT(AST_Sub, function(output) {
1521
+ var self = this;
1522
+ self.expression.print(output);
1523
+ output.print(self.optional ? "?.[" : "[");
1524
+ self.property.print(output);
1525
+ output.print("]");
1526
+ });
1527
+ DEFPRINT(AST_Spread, function(output) {
1528
+ output.print("...");
1529
+ this.expression.print(output);
1530
+ });
1531
+ DEFPRINT(AST_UnaryPrefix, function(output) {
1532
+ var op = this.operator;
1533
+ var exp = this.expression;
1534
+ output.print(op);
1535
+ if (/^[a-z]/i.test(op)
1536
+ || (/[+-]$/.test(op)
1537
+ && exp instanceof AST_UnaryPrefix
1538
+ && /^[+-]/.test(exp.operator))) {
1539
+ output.space();
1540
+ }
1541
+ exp.print(output);
1542
+ });
1543
+ DEFPRINT(AST_UnaryPostfix, function(output) {
1544
+ this.expression.print(output);
1545
+ output.print(this.operator);
1546
+ });
1547
+ DEFPRINT(AST_Binary, function(output) {
1548
+ var self = this;
1549
+ self.left.print(output);
1550
+ output.space();
1551
+ output.print(self.operator);
1552
+ output.space();
1553
+ self.right.print(output);
1554
+ });
1555
+ DEFPRINT(AST_Conditional, function(output) {
1556
+ var self = this;
1557
+ self.condition.print(output);
1558
+ output.space();
1559
+ output.print("?");
1560
+ output.space();
1561
+ self.consequent.print(output);
1562
+ output.space();
1563
+ output.colon();
1564
+ self.alternative.print(output);
1565
+ });
1566
+ DEFPRINT(AST_Await, function(output) {
1567
+ output.print("await");
1568
+ output.space();
1569
+ this.expression.print(output);
1570
+ });
1571
+ DEFPRINT(AST_Yield, function(output) {
1572
+ output.print(this.nested ? "yield*" : "yield");
1573
+ if (this.expression) {
1574
+ output.space();
1575
+ this.expression.print(output);
1576
+ }
1577
+ });
1578
+
1579
+ /* -----[ literals ]----- */
1580
+ DEFPRINT(AST_Array, function(output) {
1581
+ var a = this.elements, len = a.length;
1582
+ output.with_square(len > 0 ? function() {
1583
+ output.space();
1584
+ a.forEach(function(exp, i) {
1585
+ if (i) output.comma();
1586
+ exp.print(output);
1587
+ // If the final element is a hole, we need to make sure it
1588
+ // doesn't look like a trailing comma, by inserting an actual
1589
+ // trailing comma.
1590
+ if (i === len - 1 && exp instanceof AST_Hole)
1591
+ output.comma();
1592
+ });
1593
+ output.space();
1594
+ } : noop);
1595
+ });
1596
+ DEFPRINT(AST_DestructuredArray, function(output) {
1597
+ var a = this.elements, len = a.length, rest = this.rest;
1598
+ output.with_square(len || rest ? function() {
1599
+ output.space();
1600
+ a.forEach(function(exp, i) {
1601
+ if (i) output.comma();
1602
+ exp.print(output);
1603
+ });
1604
+ if (rest) {
1605
+ if (len) output.comma();
1606
+ output.print("...");
1607
+ rest.print(output);
1608
+ } else if (a[len - 1] instanceof AST_Hole) {
1609
+ // If the final element is a hole, we need to make sure it
1610
+ // doesn't look like a trailing comma, by inserting an actual
1611
+ // trailing comma.
1612
+ output.comma();
1613
+ }
1614
+ output.space();
1615
+ } : noop);
1616
+ });
1617
+ DEFPRINT(AST_DestructuredKeyVal, function(output) {
1618
+ var self = this;
1619
+ var key = print_property_key(self, output);
1620
+ var value = self.value;
1621
+ if (key) {
1622
+ if (value instanceof AST_DefaultValue) {
1623
+ if (value.name instanceof AST_Symbol && key == get_symbol_name(value.name)) {
1624
+ output.space();
1625
+ output.print("=");
1626
+ output.space();
1627
+ value.value.print(output);
1628
+ return;
1629
+ }
1630
+ } else if (value instanceof AST_Symbol) {
1631
+ if (key == get_symbol_name(value)) return;
1632
+ }
1633
+ }
1634
+ output.colon();
1635
+ value.print(output);
1636
+ });
1637
+ DEFPRINT(AST_DestructuredObject, function(output) {
1638
+ var props = this.properties, len = props.length, rest = this.rest;
1639
+ if (len || rest) output.with_block(function() {
1640
+ props.forEach(function(prop, i) {
1641
+ if (i) {
1642
+ output.print(",");
1643
+ output.newline();
1644
+ }
1645
+ output.indent();
1646
+ prop.print(output);
1647
+ });
1648
+ if (rest) {
1649
+ if (len) {
1650
+ output.print(",");
1651
+ output.newline();
1652
+ }
1653
+ output.indent();
1654
+ output.print("...");
1655
+ rest.print(output);
1656
+ }
1657
+ output.newline();
1658
+ });
1659
+ else print_braced_empty(this, output);
1660
+ });
1661
+ function print_properties(self, output, no_comma) {
1662
+ var props = self.properties;
1663
+ if (props.length > 0) output.with_block(function() {
1664
+ props.forEach(function(prop, i) {
1665
+ if (i) {
1666
+ if (!no_comma) output.print(",");
1667
+ output.newline();
1668
+ }
1669
+ output.indent();
1670
+ prop.print(output);
1671
+ });
1672
+ output.newline();
1673
+ });
1674
+ else print_braced_empty(self, output);
1675
+ }
1676
+ DEFPRINT(AST_Object, function(output) {
1677
+ print_properties(this, output);
1678
+ });
1679
+
1680
+ function print_property_key(self, output) {
1681
+ var key = self.key;
1682
+ if (key instanceof AST_Node) return output.with_square(function() {
1683
+ key.print(output);
1684
+ });
1685
+ var quote = self.start && self.start.quote;
1686
+ if (output.option("quote_keys") || quote && output.option("keep_quoted_props")) {
1687
+ output.print_string(key, quote);
1688
+ } else if ("" + +key == key && key >= 0) {
1689
+ output.print(make_num(key));
1690
+ } else if (self.private) {
1691
+ output.print_name(key);
1692
+ } else if (RESERVED_WORDS[key] ? !output.option("ie") : is_identifier_string(key)) {
1693
+ output.print_name(key);
1694
+ return key;
1695
+ } else {
1696
+ output.print_string(key, quote);
1697
+ }
1698
+ }
1699
+ DEFPRINT(AST_ObjectKeyVal, function(output) {
1700
+ var self = this;
1701
+ print_property_key(self, output);
1702
+ output.colon();
1703
+ self.value.print(output);
1704
+ });
1705
+ DEFPRINT(AST_ObjectMethod, function(output) {
1706
+ print_method(this, output);
1707
+ });
1708
+ function print_accessor(type) {
1709
+ return function(output) {
1710
+ var self = this;
1711
+ if (self.static) {
1712
+ output.print("static");
1713
+ output.space();
1714
+ }
1715
+ output.print(type);
1716
+ output.space();
1717
+ print_property_key(self, output);
1718
+ print_lambda(self.value, output);
1719
+ };
1720
+ }
1721
+ DEFPRINT(AST_ObjectGetter, print_accessor("get"));
1722
+ DEFPRINT(AST_ObjectSetter, print_accessor("set"));
1723
+ function get_symbol_name(sym) {
1724
+ var def = sym.definition();
1725
+ return def && def.mangled_name || sym.name;
1726
+ }
1727
+ DEFPRINT(AST_Symbol, function(output) {
1728
+ output.print_name(get_symbol_name(this));
1729
+ });
1730
+ DEFPRINT(AST_SymbolExport, function(output) {
1731
+ var self = this;
1732
+ var name = get_symbol_name(self);
1733
+ output.print_name(name);
1734
+ var alias = self.alias;
1735
+ if (alias != name) {
1736
+ output.space();
1737
+ output.print("as");
1738
+ output.space();
1739
+ output.print_name(alias);
1740
+ }
1741
+ });
1742
+ DEFPRINT(AST_SymbolImport, function(output) {
1743
+ var self = this;
1744
+ var name = get_symbol_name(self);
1745
+ var key = self.key;
1746
+ if (key && key != name) {
1747
+ output.print_name(key);
1748
+ output.space();
1749
+ output.print("as");
1750
+ output.space();
1751
+ }
1752
+ output.print_name(name);
1753
+ });
1754
+ DEFPRINT(AST_Hole, noop);
1755
+ DEFPRINT(AST_Template, function(output) {
1756
+ var self = this;
1757
+ if (self.tag) self.tag.print(output);
1758
+ output.print("`");
1759
+ for (var i = 0; i < self.expressions.length; i++) {
1760
+ output.print(self.strings[i]);
1761
+ output.print("${");
1762
+ self.expressions[i].print(output);
1763
+ output.print("}");
1764
+ }
1765
+ output.print(self.strings[i]);
1766
+ output.print("`");
1767
+ });
1768
+ DEFPRINT(AST_Constant, function(output) {
1769
+ output.print("" + this.value);
1770
+ });
1771
+ DEFPRINT(AST_String, function(output) {
1772
+ output.print_string(this.value, this.quote);
1773
+ });
1774
+ DEFPRINT(AST_Number, function(output) {
1775
+ var start = this.start;
1776
+ if (use_asm && start && start.raw != null) {
1777
+ output.print(start.raw);
1778
+ } else {
1779
+ output.print(make_num(this.value));
1780
+ }
1781
+ });
1782
+
1783
+ DEFPRINT(AST_RegExp, function(output) {
1784
+ var regexp = this.value;
1785
+ var str = regexp.toString();
1786
+ var end = str.lastIndexOf("/");
1787
+ if (regexp.raw_source) {
1788
+ str = "/" + regexp.raw_source + str.slice(end);
1789
+ } else if (end == 1) {
1790
+ str = "/(?:)" + str.slice(end);
1791
+ } else if (str.indexOf("/", 1) < end) {
1792
+ str = "/" + str.slice(1, end).replace(/\\\\|[^/]?\//g, function(match) {
1793
+ return match[0] == "\\" ? match : match.slice(0, -1) + "\\/";
1794
+ }) + str.slice(end);
1795
+ }
1796
+ output.print(output.to_utf8(str).replace(/\\(?:\0(?![0-9])|[^\0])/g, function(match) {
1797
+ switch (match[1]) {
1798
+ case "\n": return "\\n";
1799
+ case "\r": return "\\r";
1800
+ case "\t": return "\t";
1801
+ case "\b": return "\b";
1802
+ case "\f": return "\f";
1803
+ case "\0": return "\0";
1804
+ case "\x0B": return "\v";
1805
+ case "\u2028": return "\\u2028";
1806
+ case "\u2029": return "\\u2029";
1807
+ default: return match;
1808
+ }
1809
+ }).replace(/[\n\r\u2028\u2029]/g, function(c) {
1810
+ switch (c) {
1811
+ case "\n": return "\\n";
1812
+ case "\r": return "\\r";
1813
+ case "\u2028": return "\\u2028";
1814
+ case "\u2029": return "\\u2029";
1815
+ }
1816
+ }));
1817
+ var p = output.parent();
1818
+ if (p instanceof AST_Binary && /^in/.test(p.operator) && p.left === this)
1819
+ output.print(" ");
1820
+ });
1821
+
1822
+ function force_statement(stat, output) {
1823
+ if (output.option("braces") && !(stat instanceof AST_Const || stat instanceof AST_Let)) {
1824
+ make_block(stat, output);
1825
+ } else if (stat instanceof AST_EmptyStatement) {
1826
+ output.force_semicolon();
1827
+ } else {
1828
+ output.space();
1829
+ stat.print(output);
1830
+ }
1831
+ }
1832
+
1833
+ // self should be AST_New. decide if we want to show parens or not.
1834
+ function need_constructor_parens(self, output) {
1835
+ // Always print parentheses with arguments
1836
+ if (self.args.length > 0) return true;
1837
+
1838
+ return output.option("beautify");
1839
+ }
1840
+
1841
+ function best_of(a) {
1842
+ var best = a[0], len = best.length;
1843
+ for (var i = 1; i < a.length; ++i) {
1844
+ if (a[i].length < len) {
1845
+ best = a[i];
1846
+ len = best.length;
1847
+ }
1848
+ }
1849
+ return best;
1850
+ }
1851
+
1852
+ function make_num(num) {
1853
+ var str = num.toString(10).replace(/^0\./, ".").replace("e+", "e");
1854
+ var candidates = [ str ];
1855
+ if (Math.floor(num) === num) {
1856
+ if (num < 0) {
1857
+ candidates.push("-0x" + (-num).toString(16).toLowerCase());
1858
+ } else {
1859
+ candidates.push("0x" + num.toString(16).toLowerCase());
1860
+ }
1861
+ }
1862
+ var match, len, digits;
1863
+ if (match = /^\.0+/.exec(str)) {
1864
+ len = match[0].length;
1865
+ digits = str.slice(len);
1866
+ candidates.push(digits + "e-" + (digits.length + len - 1));
1867
+ } else if (match = /[^0]0+$/.exec(str)) {
1868
+ len = match[0].length - 1;
1869
+ candidates.push(str.slice(0, -len) + "e" + len);
1870
+ } else if (match = /^(\d)\.(\d+)e(-?\d+)$/.exec(str)) {
1871
+ candidates.push(match[1] + match[2] + "e" + (match[3] - match[2].length));
1872
+ }
1873
+ return best_of(candidates);
1874
+ }
1875
+
1876
+ function make_block(stmt, output) {
1877
+ output.space();
1878
+ if (stmt instanceof AST_EmptyStatement) {
1879
+ print_braced_empty(stmt, output);
1880
+ } else if (stmt instanceof AST_BlockStatement) {
1881
+ stmt.print(output);
1882
+ } else output.with_block(function() {
1883
+ output.indent();
1884
+ stmt.print(output);
1885
+ output.newline();
1886
+ });
1887
+ }
1888
+
1889
+ /* -----[ source map generators ]----- */
1890
+
1891
+ function DEFMAP(nodetype, generator) {
1892
+ nodetype.forEach(function(nodetype) {
1893
+ nodetype.DEFMETHOD("add_source_map", generator);
1894
+ });
1895
+ }
1896
+
1897
+ DEFMAP([
1898
+ // We could easily add info for ALL nodes, but it seems to me that
1899
+ // would be quite wasteful, hence this noop in the base class.
1900
+ AST_Node,
1901
+ // since the label symbol will mark it
1902
+ AST_LabeledStatement,
1903
+ ], noop);
1904
+
1905
+ // XXX: I'm not exactly sure if we need it for all of these nodes,
1906
+ // or if we should add even more.
1907
+ DEFMAP([
1908
+ AST_Array,
1909
+ AST_BlockStatement,
1910
+ AST_Catch,
1911
+ AST_Constant,
1912
+ AST_Debugger,
1913
+ AST_Definitions,
1914
+ AST_Destructured,
1915
+ AST_Finally,
1916
+ AST_Jump,
1917
+ AST_Lambda,
1918
+ AST_New,
1919
+ AST_Object,
1920
+ AST_StatementWithBody,
1921
+ AST_Symbol,
1922
+ AST_Switch,
1923
+ AST_SwitchBranch,
1924
+ AST_Try,
1925
+ ], function(output) {
1926
+ output.add_mapping(this.start);
1927
+ });
1928
+
1929
+ DEFMAP([
1930
+ AST_ClassProperty,
1931
+ AST_DestructuredKeyVal,
1932
+ AST_ObjectProperty,
1933
+ ], function(output) {
1934
+ if (typeof this.key == "string") output.add_mapping(this.start, this.key);
1935
+ });
1936
+ })();