ventojs 0.10.2 → 0.12.0

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 (390) hide show
  1. package/README.md +35 -93
  2. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/assert/assert.js +1 -1
  3. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/assert/assertion_error.js +1 -1
  4. package/esm/deps/deno.land/std@0.219.1/html/entities.d.ts +39 -0
  5. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/html/entities.js +14 -15
  6. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/html/mod.d.ts +1 -1
  7. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/html/mod.js +2 -2
  8. package/esm/deps/deno.land/std@0.219.1/path/_common/assert_path.d.ts +1 -0
  9. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/assert_path.js +1 -1
  10. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/basename.js +1 -1
  11. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/common.js +9 -9
  12. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/constants.js +1 -1
  13. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/dirname.js +1 -1
  14. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/format.js +1 -1
  15. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/from_file_url.js +1 -1
  16. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/glob_to_reg_exp.js +4 -2
  17. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/normalize.js +1 -1
  18. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/normalize_string.js +1 -1
  19. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/relative.js +1 -1
  20. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/strip_trailing_separators.js +1 -1
  21. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/to_file_url.js +1 -1
  22. package/esm/deps/deno.land/std@0.219.1/path/_interface.js +3 -0
  23. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_os.js +1 -1
  24. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/basename.js +1 -1
  25. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/common.js +3 -3
  26. package/esm/deps/deno.land/std@0.219.1/path/constants.d.ts +3 -0
  27. package/esm/deps/deno.land/std@0.219.1/path/constants.js +6 -0
  28. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/dirname.js +1 -1
  29. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/extname.js +1 -1
  30. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/format.d.ts +1 -1
  31. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/format.js +1 -1
  32. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/from_file_url.js +1 -1
  33. package/{script/deps/deno.land/std@0.210.0 → esm/deps/deno.land/std@0.219.1}/path/glob_to_regexp.d.ts +2 -1
  34. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/glob_to_regexp.js +1 -1
  35. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/is_absolute.js +1 -1
  36. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/is_glob.js +1 -1
  37. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/join.js +1 -1
  38. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/join_globs.d.ts +1 -0
  39. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/join_globs.js +1 -1
  40. package/esm/deps/deno.land/std@0.219.1/path/mod.d.ts +56 -0
  41. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/mod.js +3 -8
  42. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/normalize.js +1 -1
  43. package/{script/deps/deno.land/std@0.210.0 → esm/deps/deno.land/std@0.219.1}/path/normalize_glob.d.ts +1 -0
  44. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/normalize_glob.js +1 -1
  45. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/parse.js +1 -1
  46. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/_util.js +1 -1
  47. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/basename.js +1 -1
  48. package/esm/deps/deno.land/{std@0.210.0/path/windows → std@0.219.1/path/posix}/common.js +3 -3
  49. package/esm/deps/deno.land/std@0.219.1/path/posix/constants.d.ts +3 -0
  50. package/esm/deps/deno.land/std@0.219.1/path/posix/constants.js +5 -0
  51. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/dirname.js +1 -1
  52. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/extname.js +1 -1
  53. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/format.js +1 -1
  54. package/{script/deps/deno.land/std@0.210.0 → esm/deps/deno.land/std@0.219.1}/path/posix/from_file_url.d.ts +1 -1
  55. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/from_file_url.js +2 -2
  56. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/glob_to_regexp.d.ts +1 -1
  57. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/glob_to_regexp.js +1 -1
  58. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/is_absolute.js +1 -1
  59. package/esm/deps/deno.land/{std@0.210.0/path/windows → std@0.219.1/path/posix}/is_glob.js +1 -1
  60. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/join.js +1 -1
  61. package/esm/deps/deno.land/{std@0.210.0/path/windows → std@0.219.1/path/posix}/join_globs.d.ts +2 -1
  62. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/join_globs.js +3 -3
  63. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/mod.d.ts +1 -3
  64. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/mod.js +2 -4
  65. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/normalize.js +1 -1
  66. package/{script/deps/deno.land/std@0.210.0 → esm/deps/deno.land/std@0.219.1}/path/posix/normalize_glob.d.ts +2 -1
  67. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/normalize_glob.js +3 -3
  68. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/parse.d.ts +1 -1
  69. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/parse.js +1 -1
  70. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/relative.js +1 -1
  71. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/resolve.js +1 -1
  72. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/to_file_url.d.ts +1 -1
  73. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/to_file_url.js +2 -2
  74. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/to_namespaced_path.js +1 -1
  75. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/relative.js +1 -1
  76. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/resolve.js +1 -1
  77. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/to_file_url.js +1 -1
  78. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/to_namespaced_path.js +1 -1
  79. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/_util.js +1 -1
  80. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/basename.js +1 -1
  81. package/esm/deps/deno.land/{std@0.210.0/path/posix → std@0.219.1/path/windows}/common.js +3 -3
  82. package/esm/deps/deno.land/std@0.219.1/path/windows/constants.d.ts +3 -0
  83. package/esm/deps/deno.land/std@0.219.1/path/windows/constants.js +5 -0
  84. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/dirname.js +1 -1
  85. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/extname.js +1 -1
  86. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/format.js +1 -1
  87. package/{script/deps/deno.land/std@0.210.0 → esm/deps/deno.land/std@0.219.1}/path/windows/from_file_url.d.ts +1 -1
  88. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/from_file_url.js +2 -2
  89. package/{script/deps/deno.land/std@0.210.0/path/posix → esm/deps/deno.land/std@0.219.1/path/windows}/glob_to_regexp.d.ts +1 -1
  90. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/glob_to_regexp.js +1 -1
  91. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/is_absolute.js +1 -1
  92. package/esm/deps/deno.land/{std@0.210.0/path/posix → std@0.219.1/path/windows}/is_glob.js +1 -1
  93. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/join.js +1 -1
  94. package/esm/deps/deno.land/{std@0.210.0/path/posix → std@0.219.1/path/windows}/join_globs.d.ts +2 -1
  95. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/join_globs.js +3 -3
  96. package/{script/deps/deno.land/std@0.210.0/path/posix → esm/deps/deno.land/std@0.219.1/path/windows}/mod.d.ts +1 -3
  97. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/mod.js +2 -4
  98. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/normalize.js +1 -1
  99. package/{script/deps/deno.land/std@0.210.0 → esm/deps/deno.land/std@0.219.1}/path/windows/normalize_glob.d.ts +2 -1
  100. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/normalize_glob.js +3 -3
  101. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/parse.d.ts +1 -1
  102. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/parse.js +1 -1
  103. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/relative.js +1 -1
  104. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/resolve.js +1 -1
  105. package/{script/deps/deno.land/std@0.210.0 → esm/deps/deno.land/std@0.219.1}/path/windows/to_file_url.d.ts +1 -1
  106. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/to_file_url.js +2 -2
  107. package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/to_namespaced_path.js +1 -1
  108. package/esm/deps/deno.land/x/astring@v1.8.6/src/astring.d.ts +109 -0
  109. package/esm/deps/deno.land/x/astring@v1.8.6/src/astring.js +1159 -0
  110. package/esm/deps.d.ts +6 -2
  111. package/esm/deps.js +5 -2
  112. package/esm/mod.d.ts +1 -0
  113. package/esm/mod.js +2 -0
  114. package/esm/plugins/auto_trim.d.ts +8 -0
  115. package/esm/plugins/auto_trim.js +36 -0
  116. package/esm/plugins/escape.js +2 -1
  117. package/esm/plugins/trim.d.ts +4 -0
  118. package/esm/plugins/trim.js +28 -0
  119. package/esm/plugins/unescape.js +2 -1
  120. package/esm/src/environment.d.ts +3 -0
  121. package/esm/src/environment.js +28 -7
  122. package/esm/src/tokenizer.js +6 -29
  123. package/esm/src/transformer.d.ts +1 -0
  124. package/esm/src/transformer.js +180 -0
  125. package/package.json +21 -8
  126. package/esm/deps/deno.land/std@0.210.0/html/entities.d.ts +0 -38
  127. package/esm/deps/deno.land/std@0.210.0/path/_common/assert_path.d.ts +0 -1
  128. package/esm/deps/deno.land/std@0.210.0/path/_interface.js +0 -3
  129. package/esm/deps/deno.land/std@0.210.0/path/common.d.ts +0 -13
  130. package/esm/deps/deno.land/std@0.210.0/path/glob_to_regexp.d.ts +0 -61
  131. package/esm/deps/deno.land/std@0.210.0/path/mod.d.ts +0 -28
  132. package/esm/deps/deno.land/std@0.210.0/path/normalize_glob.d.ts +0 -3
  133. package/esm/deps/deno.land/std@0.210.0/path/posix/from_file_url.d.ts +0 -12
  134. package/esm/deps/deno.land/std@0.210.0/path/posix/normalize_glob.d.ts +0 -3
  135. package/esm/deps/deno.land/std@0.210.0/path/posix/separator.d.ts +0 -2
  136. package/esm/deps/deno.land/std@0.210.0/path/posix/separator.js +0 -4
  137. package/esm/deps/deno.land/std@0.210.0/path/separator.d.ts +0 -2
  138. package/esm/deps/deno.land/std@0.210.0/path/separator.js +0 -5
  139. package/esm/deps/deno.land/std@0.210.0/path/windows/from_file_url.d.ts +0 -14
  140. package/esm/deps/deno.land/std@0.210.0/path/windows/glob_to_regexp.d.ts +0 -57
  141. package/esm/deps/deno.land/std@0.210.0/path/windows/mod.d.ts +0 -40
  142. package/esm/deps/deno.land/std@0.210.0/path/windows/normalize_glob.d.ts +0 -3
  143. package/esm/deps/deno.land/std@0.210.0/path/windows/separator.d.ts +0 -2
  144. package/esm/deps/deno.land/std@0.210.0/path/windows/separator.js +0 -4
  145. package/esm/deps/deno.land/std@0.210.0/path/windows/to_file_url.d.ts +0 -14
  146. package/script/_dnt.shims.d.ts +0 -5
  147. package/script/_dnt.shims.js +0 -65
  148. package/script/deps/deno.land/std@0.210.0/assert/assert.d.ts +0 -12
  149. package/script/deps/deno.land/std@0.210.0/assert/assert.js +0 -22
  150. package/script/deps/deno.land/std@0.210.0/assert/assertion_error.d.ts +0 -14
  151. package/script/deps/deno.land/std@0.210.0/assert/assertion_error.js +0 -22
  152. package/script/deps/deno.land/std@0.210.0/html/entities.d.ts +0 -38
  153. package/script/deps/deno.land/std@0.210.0/html/entities.js +0 -81
  154. package/script/deps/deno.land/std@0.210.0/html/mod.d.ts +0 -6
  155. package/script/deps/deno.land/std@0.210.0/html/mod.js +0 -24
  156. package/script/deps/deno.land/std@0.210.0/path/_common/assert_path.d.ts +0 -1
  157. package/script/deps/deno.land/std@0.210.0/path/_common/assert_path.js +0 -11
  158. package/script/deps/deno.land/std@0.210.0/path/_common/basename.d.ts +0 -3
  159. package/script/deps/deno.land/std@0.210.0/path/_common/basename.js +0 -46
  160. package/script/deps/deno.land/std@0.210.0/path/_common/common.d.ts +0 -1
  161. package/script/deps/deno.land/std@0.210.0/path/_common/common.js +0 -27
  162. package/script/deps/deno.land/std@0.210.0/path/_common/constants.d.ts +0 -39
  163. package/script/deps/deno.land/std@0.210.0/path/_common/constants.js +0 -49
  164. package/script/deps/deno.land/std@0.210.0/path/_common/dirname.d.ts +0 -1
  165. package/script/deps/deno.land/std@0.210.0/path/_common/dirname.js +0 -12
  166. package/script/deps/deno.land/std@0.210.0/path/_common/format.d.ts +0 -3
  167. package/script/deps/deno.land/std@0.210.0/path/_common/format.js +0 -24
  168. package/script/deps/deno.land/std@0.210.0/path/_common/from_file_url.d.ts +0 -2
  169. package/script/deps/deno.land/std@0.210.0/path/_common/from_file_url.js +0 -13
  170. package/script/deps/deno.land/std@0.210.0/path/_common/glob_to_reg_exp.d.ts +0 -28
  171. package/script/deps/deno.land/std@0.210.0/path/_common/glob_to_reg_exp.js +0 -239
  172. package/script/deps/deno.land/std@0.210.0/path/_common/normalize.d.ts +0 -1
  173. package/script/deps/deno.land/std@0.210.0/path/_common/normalize.js +0 -12
  174. package/script/deps/deno.land/std@0.210.0/path/_common/normalize_string.d.ts +0 -1
  175. package/script/deps/deno.land/std@0.210.0/path/_common/normalize_string.js +0 -81
  176. package/script/deps/deno.land/std@0.210.0/path/_common/relative.d.ts +0 -1
  177. package/script/deps/deno.land/std@0.210.0/path/_common/relative.js +0 -13
  178. package/script/deps/deno.land/std@0.210.0/path/_common/strip_trailing_separators.d.ts +0 -1
  179. package/script/deps/deno.land/std@0.210.0/path/_common/strip_trailing_separators.js +0 -23
  180. package/script/deps/deno.land/std@0.210.0/path/_common/to_file_url.d.ts +0 -1
  181. package/script/deps/deno.land/std@0.210.0/path/_common/to_file_url.js +0 -19
  182. package/script/deps/deno.land/std@0.210.0/path/_interface.d.ts +0 -26
  183. package/script/deps/deno.land/std@0.210.0/path/_interface.js +0 -4
  184. package/script/deps/deno.land/std@0.210.0/path/_os.d.ts +0 -3
  185. package/script/deps/deno.land/std@0.210.0/path/_os.js +0 -44
  186. package/script/deps/deno.land/std@0.210.0/path/basename.d.ts +0 -8
  187. package/script/deps/deno.land/std@0.210.0/path/basename.js +0 -21
  188. package/script/deps/deno.land/std@0.210.0/path/common.d.ts +0 -13
  189. package/script/deps/deno.land/std@0.210.0/path/common.js +0 -23
  190. package/script/deps/deno.land/std@0.210.0/path/dirname.d.ts +0 -5
  191. package/script/deps/deno.land/std@0.210.0/path/dirname.js +0 -16
  192. package/script/deps/deno.land/std@0.210.0/path/extname.d.ts +0 -6
  193. package/script/deps/deno.land/std@0.210.0/path/extname.js +0 -17
  194. package/script/deps/deno.land/std@0.210.0/path/format.d.ts +0 -6
  195. package/script/deps/deno.land/std@0.210.0/path/format.js +0 -16
  196. package/script/deps/deno.land/std@0.210.0/path/from_file_url.d.ts +0 -18
  197. package/script/deps/deno.land/std@0.210.0/path/from_file_url.js +0 -28
  198. package/script/deps/deno.land/std@0.210.0/path/glob_to_regexp.js +0 -69
  199. package/script/deps/deno.land/std@0.210.0/path/is_absolute.d.ts +0 -5
  200. package/script/deps/deno.land/std@0.210.0/path/is_absolute.js +0 -16
  201. package/script/deps/deno.land/std@0.210.0/path/is_glob.d.ts +0 -2
  202. package/script/deps/deno.land/std@0.210.0/path/is_glob.js +0 -32
  203. package/script/deps/deno.land/std@0.210.0/path/join.d.ts +0 -5
  204. package/script/deps/deno.land/std@0.210.0/path/join.js +0 -16
  205. package/script/deps/deno.land/std@0.210.0/path/join_globs.d.ts +0 -3
  206. package/script/deps/deno.land/std@0.210.0/path/join_globs.js +0 -15
  207. package/script/deps/deno.land/std@0.210.0/path/mod.d.ts +0 -28
  208. package/script/deps/deno.land/std@0.210.0/path/mod.js +0 -94
  209. package/script/deps/deno.land/std@0.210.0/path/normalize.d.ts +0 -7
  210. package/script/deps/deno.land/std@0.210.0/path/normalize.js +0 -18
  211. package/script/deps/deno.land/std@0.210.0/path/normalize_glob.js +0 -15
  212. package/script/deps/deno.land/std@0.210.0/path/parse.d.ts +0 -6
  213. package/script/deps/deno.land/std@0.210.0/path/parse.js +0 -16
  214. package/script/deps/deno.land/std@0.210.0/path/posix/_util.d.ts +0 -1
  215. package/script/deps/deno.land/std@0.210.0/path/posix/_util.js +0 -12
  216. package/script/deps/deno.land/std@0.210.0/path/posix/basename.d.ts +0 -8
  217. package/script/deps/deno.land/std@0.210.0/path/posix/basename.js +0 -22
  218. package/script/deps/deno.land/std@0.210.0/path/posix/common.js +0 -23
  219. package/script/deps/deno.land/std@0.210.0/path/posix/dirname.d.ts +0 -5
  220. package/script/deps/deno.land/std@0.210.0/path/posix/dirname.js +0 -40
  221. package/script/deps/deno.land/std@0.210.0/path/posix/extname.d.ts +0 -6
  222. package/script/deps/deno.land/std@0.210.0/path/posix/extname.js +0 -63
  223. package/script/deps/deno.land/std@0.210.0/path/posix/format.d.ts +0 -6
  224. package/script/deps/deno.land/std@0.210.0/path/posix/format.js +0 -15
  225. package/script/deps/deno.land/std@0.210.0/path/posix/from_file_url.js +0 -21
  226. package/script/deps/deno.land/std@0.210.0/path/posix/glob_to_regexp.js +0 -73
  227. package/script/deps/deno.land/std@0.210.0/path/posix/is_absolute.d.ts +0 -5
  228. package/script/deps/deno.land/std@0.210.0/path/posix/is_absolute.js +0 -16
  229. package/script/deps/deno.land/std@0.210.0/path/posix/is_glob.d.ts +0 -1
  230. package/script/deps/deno.land/std@0.210.0/path/posix/is_glob.js +0 -7
  231. package/script/deps/deno.land/std@0.210.0/path/posix/join.d.ts +0 -5
  232. package/script/deps/deno.land/std@0.210.0/path/posix/join.js +0 -30
  233. package/script/deps/deno.land/std@0.210.0/path/posix/join_globs.d.ts +0 -3
  234. package/script/deps/deno.land/std@0.210.0/path/posix/join_globs.js +0 -30
  235. package/script/deps/deno.land/std@0.210.0/path/posix/mod.js +0 -61
  236. package/script/deps/deno.land/std@0.210.0/path/posix/normalize.d.ts +0 -7
  237. package/script/deps/deno.land/std@0.210.0/path/posix/normalize.js +0 -29
  238. package/script/deps/deno.land/std@0.210.0/path/posix/normalize_glob.js +0 -20
  239. package/script/deps/deno.land/std@0.210.0/path/posix/parse.d.ts +0 -6
  240. package/script/deps/deno.land/std@0.210.0/path/posix/parse.js +0 -102
  241. package/script/deps/deno.land/std@0.210.0/path/posix/relative.d.ts +0 -7
  242. package/script/deps/deno.land/std@0.210.0/path/posix/relative.js +0 -98
  243. package/script/deps/deno.land/std@0.210.0/path/posix/resolve.d.ts +0 -5
  244. package/script/deps/deno.land/std@0.210.0/path/posix/resolve.js +0 -75
  245. package/script/deps/deno.land/std@0.210.0/path/posix/separator.d.ts +0 -2
  246. package/script/deps/deno.land/std@0.210.0/path/posix/separator.js +0 -7
  247. package/script/deps/deno.land/std@0.210.0/path/posix/to_file_url.d.ts +0 -12
  248. package/script/deps/deno.land/std@0.210.0/path/posix/to_file_url.js +0 -26
  249. package/script/deps/deno.land/std@0.210.0/path/posix/to_namespaced_path.d.ts +0 -5
  250. package/script/deps/deno.land/std@0.210.0/path/posix/to_namespaced_path.js +0 -14
  251. package/script/deps/deno.land/std@0.210.0/path/relative.d.ts +0 -12
  252. package/script/deps/deno.land/std@0.210.0/path/relative.js +0 -23
  253. package/script/deps/deno.land/std@0.210.0/path/resolve.d.ts +0 -5
  254. package/script/deps/deno.land/std@0.210.0/path/resolve.js +0 -18
  255. package/script/deps/deno.land/std@0.210.0/path/separator.d.ts +0 -2
  256. package/script/deps/deno.land/std@0.210.0/path/separator.js +0 -8
  257. package/script/deps/deno.land/std@0.210.0/path/to_file_url.d.ts +0 -18
  258. package/script/deps/deno.land/std@0.210.0/path/to_file_url.js +0 -28
  259. package/script/deps/deno.land/std@0.210.0/path/to_namespaced_path.d.ts +0 -5
  260. package/script/deps/deno.land/std@0.210.0/path/to_namespaced_path.js +0 -18
  261. package/script/deps/deno.land/std@0.210.0/path/windows/_util.d.ts +0 -3
  262. package/script/deps/deno.land/std@0.210.0/path/windows/_util.js +0 -21
  263. package/script/deps/deno.land/std@0.210.0/path/windows/basename.d.ts +0 -8
  264. package/script/deps/deno.land/std@0.210.0/path/windows/basename.js +0 -34
  265. package/script/deps/deno.land/std@0.210.0/path/windows/common.d.ts +0 -13
  266. package/script/deps/deno.land/std@0.210.0/path/windows/common.js +0 -23
  267. package/script/deps/deno.land/std@0.210.0/path/windows/dirname.d.ts +0 -5
  268. package/script/deps/deno.land/std@0.210.0/path/windows/dirname.js +0 -102
  269. package/script/deps/deno.land/std@0.210.0/path/windows/extname.d.ts +0 -6
  270. package/script/deps/deno.land/std@0.210.0/path/windows/extname.js +0 -72
  271. package/script/deps/deno.land/std@0.210.0/path/windows/format.d.ts +0 -6
  272. package/script/deps/deno.land/std@0.210.0/path/windows/format.js +0 -15
  273. package/script/deps/deno.land/std@0.210.0/path/windows/from_file_url.js +0 -30
  274. package/script/deps/deno.land/std@0.210.0/path/windows/glob_to_regexp.d.ts +0 -57
  275. package/script/deps/deno.land/std@0.210.0/path/windows/glob_to_regexp.js +0 -73
  276. package/script/deps/deno.land/std@0.210.0/path/windows/is_absolute.d.ts +0 -5
  277. package/script/deps/deno.land/std@0.210.0/path/windows/is_absolute.js +0 -31
  278. package/script/deps/deno.land/std@0.210.0/path/windows/is_glob.d.ts +0 -1
  279. package/script/deps/deno.land/std@0.210.0/path/windows/is_glob.js +0 -7
  280. package/script/deps/deno.land/std@0.210.0/path/windows/join.d.ts +0 -5
  281. package/script/deps/deno.land/std@0.210.0/path/windows/join.js +0 -76
  282. package/script/deps/deno.land/std@0.210.0/path/windows/join_globs.d.ts +0 -3
  283. package/script/deps/deno.land/std@0.210.0/path/windows/join_globs.js +0 -30
  284. package/script/deps/deno.land/std@0.210.0/path/windows/mod.d.ts +0 -40
  285. package/script/deps/deno.land/std@0.210.0/path/windows/mod.js +0 -61
  286. package/script/deps/deno.land/std@0.210.0/path/windows/normalize.d.ts +0 -7
  287. package/script/deps/deno.land/std@0.210.0/path/windows/normalize.js +0 -134
  288. package/script/deps/deno.land/std@0.210.0/path/windows/normalize_glob.js +0 -20
  289. package/script/deps/deno.land/std@0.210.0/path/windows/parse.d.ts +0 -6
  290. package/script/deps/deno.land/std@0.210.0/path/windows/parse.js +0 -163
  291. package/script/deps/deno.land/std@0.210.0/path/windows/relative.d.ts +0 -12
  292. package/script/deps/deno.land/std@0.210.0/path/windows/relative.js +0 -125
  293. package/script/deps/deno.land/std@0.210.0/path/windows/resolve.d.ts +0 -5
  294. package/script/deps/deno.land/std@0.210.0/path/windows/resolve.js +0 -170
  295. package/script/deps/deno.land/std@0.210.0/path/windows/separator.d.ts +0 -2
  296. package/script/deps/deno.land/std@0.210.0/path/windows/separator.js +0 -7
  297. package/script/deps/deno.land/std@0.210.0/path/windows/to_file_url.js +0 -35
  298. package/script/deps/deno.land/std@0.210.0/path/windows/to_namespaced_path.d.ts +0 -5
  299. package/script/deps/deno.land/std@0.210.0/path/windows/to_namespaced_path.js +0 -42
  300. package/script/deps.d.ts +0 -2
  301. package/script/deps.js +0 -28
  302. package/script/mod.d.ts +0 -9
  303. package/script/mod.js +0 -69
  304. package/script/package.json +0 -3
  305. package/script/plugins/echo.d.ts +0 -2
  306. package/script/plugins/echo.js +0 -16
  307. package/script/plugins/escape.d.ts +0 -2
  308. package/script/plugins/escape.js +0 -9
  309. package/script/plugins/export.d.ts +0 -2
  310. package/script/plugins/export.js +0 -50
  311. package/script/plugins/for.d.ts +0 -2
  312. package/script/plugins/for.js +0 -77
  313. package/script/plugins/function.d.ts +0 -2
  314. package/script/plugins/function.js +0 -40
  315. package/script/plugins/if.d.ts +0 -2
  316. package/script/plugins/if.js +0 -35
  317. package/script/plugins/import.d.ts +0 -2
  318. package/script/plugins/import.js +0 -20
  319. package/script/plugins/include.d.ts +0 -2
  320. package/script/plugins/include.js +0 -26
  321. package/script/plugins/js.d.ts +0 -2
  322. package/script/plugins/js.js +0 -14
  323. package/script/plugins/layout.d.ts +0 -2
  324. package/script/plugins/layout.js +0 -37
  325. package/script/plugins/set.d.ts +0 -2
  326. package/script/plugins/set.js +0 -48
  327. package/script/plugins/unescape.d.ts +0 -2
  328. package/script/plugins/unescape.js +0 -9
  329. package/script/src/environment.d.ts +0 -51
  330. package/script/src/environment.js +0 -208
  331. package/script/src/loader.d.ts +0 -14
  332. package/script/src/loader.js +0 -46
  333. package/script/src/tokenizer.d.ts +0 -13
  334. package/script/src/tokenizer.js +0 -249
  335. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/assert/assert.d.ts +0 -0
  336. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/assert/assertion_error.d.ts +0 -0
  337. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/basename.d.ts +0 -0
  338. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/common.d.ts +0 -0
  339. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/constants.d.ts +0 -0
  340. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/dirname.d.ts +0 -0
  341. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/format.d.ts +0 -0
  342. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/from_file_url.d.ts +0 -0
  343. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/glob_to_reg_exp.d.ts +0 -0
  344. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/normalize.d.ts +0 -0
  345. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/normalize_string.d.ts +0 -0
  346. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/relative.d.ts +0 -0
  347. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/strip_trailing_separators.d.ts +0 -0
  348. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/to_file_url.d.ts +0 -0
  349. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_interface.d.ts +0 -0
  350. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_os.d.ts +0 -0
  351. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/basename.d.ts +0 -0
  352. /package/esm/deps/deno.land/{std@0.210.0/path/posix → std@0.219.1/path}/common.d.ts +0 -0
  353. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/dirname.d.ts +0 -0
  354. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/extname.d.ts +0 -0
  355. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/from_file_url.d.ts +0 -0
  356. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/is_absolute.d.ts +0 -0
  357. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/is_glob.d.ts +0 -0
  358. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/join.d.ts +0 -0
  359. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/normalize.d.ts +0 -0
  360. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/parse.d.ts +0 -0
  361. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/_util.d.ts +0 -0
  362. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/basename.d.ts +0 -0
  363. /package/esm/deps/deno.land/{std@0.210.0/path/windows → std@0.219.1/path/posix}/common.d.ts +0 -0
  364. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/dirname.d.ts +0 -0
  365. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/extname.d.ts +0 -0
  366. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/format.d.ts +0 -0
  367. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/is_absolute.d.ts +0 -0
  368. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/is_glob.d.ts +0 -0
  369. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/join.d.ts +0 -0
  370. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/normalize.d.ts +0 -0
  371. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/relative.d.ts +0 -0
  372. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/resolve.d.ts +0 -0
  373. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/to_namespaced_path.d.ts +0 -0
  374. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/relative.d.ts +0 -0
  375. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/resolve.d.ts +0 -0
  376. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/to_file_url.d.ts +0 -0
  377. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/to_namespaced_path.d.ts +0 -0
  378. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/_util.d.ts +0 -0
  379. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/basename.d.ts +0 -0
  380. /package/{script/deps/deno.land/std@0.210.0/path/posix → esm/deps/deno.land/std@0.219.1/path/windows}/common.d.ts +0 -0
  381. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/dirname.d.ts +0 -0
  382. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/extname.d.ts +0 -0
  383. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/format.d.ts +0 -0
  384. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/is_absolute.d.ts +0 -0
  385. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/is_glob.d.ts +0 -0
  386. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/join.d.ts +0 -0
  387. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/normalize.d.ts +0 -0
  388. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/relative.d.ts +0 -0
  389. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/resolve.d.ts +0 -0
  390. /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/to_namespaced_path.d.ts +0 -0
@@ -0,0 +1,1159 @@
1
+ // Astring is a tiny and fast JavaScript code generator from an ESTree-compliant AST.
2
+ //
3
+ // Astring was written by David Bonnet and released under an MIT license.
4
+ //
5
+ // The Git repository for Astring is available at:
6
+ // https://github.com/davidbonnet/astring.git
7
+ //
8
+ // Please use the GitHub bug tracker to report issues:
9
+ // https://github.com/davidbonnet/astring/issues
10
+ const { stringify } = JSON;
11
+ /* c8 ignore if */
12
+ if (!String.prototype.repeat) {
13
+ /* c8 ignore next */
14
+ throw new Error('String.prototype.repeat is undefined, see https://github.com/davidbonnet/astring#installation');
15
+ }
16
+ /* c8 ignore if */
17
+ if (!String.prototype.endsWith) {
18
+ /* c8 ignore next */
19
+ throw new Error('String.prototype.endsWith is undefined, see https://github.com/davidbonnet/astring#installation');
20
+ }
21
+ const OPERATOR_PRECEDENCE = {
22
+ '||': 2,
23
+ '??': 3,
24
+ '&&': 4,
25
+ '|': 5,
26
+ '^': 6,
27
+ '&': 7,
28
+ '==': 8,
29
+ '!=': 8,
30
+ '===': 8,
31
+ '!==': 8,
32
+ '<': 9,
33
+ '>': 9,
34
+ '<=': 9,
35
+ '>=': 9,
36
+ in: 9,
37
+ instanceof: 9,
38
+ '<<': 10,
39
+ '>>': 10,
40
+ '>>>': 10,
41
+ '+': 11,
42
+ '-': 11,
43
+ '*': 12,
44
+ '%': 12,
45
+ '/': 12,
46
+ '**': 13,
47
+ };
48
+ // Enables parenthesis regardless of precedence
49
+ export const NEEDS_PARENTHESES = 17;
50
+ export const EXPRESSIONS_PRECEDENCE = {
51
+ // Definitions
52
+ ArrayExpression: 20,
53
+ TaggedTemplateExpression: 20,
54
+ ThisExpression: 20,
55
+ Identifier: 20,
56
+ PrivateIdentifier: 20,
57
+ Literal: 18,
58
+ TemplateLiteral: 20,
59
+ Super: 20,
60
+ SequenceExpression: 20,
61
+ // Operations
62
+ MemberExpression: 19,
63
+ ChainExpression: 19,
64
+ CallExpression: 19,
65
+ NewExpression: 19,
66
+ // Other definitions
67
+ ArrowFunctionExpression: NEEDS_PARENTHESES,
68
+ ClassExpression: NEEDS_PARENTHESES,
69
+ FunctionExpression: NEEDS_PARENTHESES,
70
+ ObjectExpression: NEEDS_PARENTHESES,
71
+ // Other operations
72
+ UpdateExpression: 16,
73
+ UnaryExpression: 15,
74
+ AwaitExpression: 15,
75
+ BinaryExpression: 14,
76
+ LogicalExpression: 13,
77
+ ConditionalExpression: 4,
78
+ AssignmentExpression: 3,
79
+ YieldExpression: 2,
80
+ RestElement: 1,
81
+ };
82
+ function formatSequence(state, nodes) {
83
+ /*
84
+ Writes into `state` a sequence of `nodes`.
85
+ */
86
+ const { generator } = state;
87
+ state.write('(');
88
+ if (nodes != null && nodes.length > 0) {
89
+ generator[nodes[0].type](nodes[0], state);
90
+ const { length } = nodes;
91
+ for (let i = 1; i < length; i++) {
92
+ const param = nodes[i];
93
+ state.write(', ');
94
+ generator[param.type](param, state);
95
+ }
96
+ }
97
+ state.write(')');
98
+ }
99
+ function expressionNeedsParenthesis(state, node, parentNode, isRightHand) {
100
+ const nodePrecedence = state.expressionsPrecedence[node.type];
101
+ if (nodePrecedence === NEEDS_PARENTHESES) {
102
+ return true;
103
+ }
104
+ const parentNodePrecedence = state.expressionsPrecedence[parentNode.type];
105
+ if (nodePrecedence !== parentNodePrecedence) {
106
+ // Different node types
107
+ return ((!isRightHand &&
108
+ nodePrecedence === 15 &&
109
+ parentNodePrecedence === 14 &&
110
+ parentNode.operator === '**') ||
111
+ nodePrecedence < parentNodePrecedence);
112
+ }
113
+ if (nodePrecedence !== 13 && nodePrecedence !== 14) {
114
+ // Not a `LogicalExpression` or `BinaryExpression`
115
+ return false;
116
+ }
117
+ if (node.operator === '**' && parentNode.operator === '**') {
118
+ // Exponentiation operator has right-to-left associativity
119
+ return !isRightHand;
120
+ }
121
+ if (nodePrecedence === 13 &&
122
+ parentNodePrecedence === 13 &&
123
+ (node.operator === '??' || parentNode.operator === '??')) {
124
+ // Nullish coalescing and boolean operators cannot be combined
125
+ return true;
126
+ }
127
+ if (isRightHand) {
128
+ // Parenthesis are used if both operators have the same precedence
129
+ return (OPERATOR_PRECEDENCE[node.operator] <=
130
+ OPERATOR_PRECEDENCE[parentNode.operator]);
131
+ }
132
+ return (OPERATOR_PRECEDENCE[node.operator] <
133
+ OPERATOR_PRECEDENCE[parentNode.operator]);
134
+ }
135
+ function formatExpression(state, node, parentNode, isRightHand) {
136
+ /*
137
+ Writes into `state` the provided `node`, adding parenthesis around if the provided `parentNode` needs it. If `node` is a right-hand argument, the provided `isRightHand` parameter should be `true`.
138
+ */
139
+ const { generator } = state;
140
+ if (expressionNeedsParenthesis(state, node, parentNode, isRightHand)) {
141
+ state.write('(');
142
+ generator[node.type](node, state);
143
+ state.write(')');
144
+ }
145
+ else {
146
+ generator[node.type](node, state);
147
+ }
148
+ }
149
+ function reindent(state, text, indent, lineEnd) {
150
+ /*
151
+ Writes into `state` the `text` string reindented with the provided `indent`.
152
+ */
153
+ const lines = text.split('\n');
154
+ const end = lines.length - 1;
155
+ state.write(lines[0].trim());
156
+ if (end > 0) {
157
+ state.write(lineEnd);
158
+ for (let i = 1; i < end; i++) {
159
+ state.write(indent + lines[i].trim() + lineEnd);
160
+ }
161
+ state.write(indent + lines[end].trim());
162
+ }
163
+ }
164
+ function formatComments(state, comments, indent, lineEnd) {
165
+ /*
166
+ Writes into `state` the provided list of `comments`, with the given `indent` and `lineEnd` strings.
167
+ Line comments will end with `"\n"` regardless of the value of `lineEnd`.
168
+ Expects to start on a new unindented line.
169
+ */
170
+ const { length } = comments;
171
+ for (let i = 0; i < length; i++) {
172
+ const comment = comments[i];
173
+ state.write(indent);
174
+ if (comment.type[0] === 'L') {
175
+ // Line comment
176
+ state.write('// ' + comment.value.trim() + '\n', comment);
177
+ }
178
+ else {
179
+ // Block comment
180
+ state.write('/*');
181
+ reindent(state, comment.value, indent, lineEnd);
182
+ state.write('*/' + lineEnd);
183
+ }
184
+ }
185
+ }
186
+ function hasCallExpression(node) {
187
+ /*
188
+ Returns `true` if the provided `node` contains a call expression and `false` otherwise.
189
+ */
190
+ let currentNode = node;
191
+ while (currentNode != null) {
192
+ const { type } = currentNode;
193
+ if (type[0] === 'C' && type[1] === 'a') {
194
+ // Is CallExpression
195
+ return true;
196
+ }
197
+ else if (type[0] === 'M' && type[1] === 'e' && type[2] === 'm') {
198
+ // Is MemberExpression
199
+ currentNode = currentNode.object;
200
+ }
201
+ else {
202
+ return false;
203
+ }
204
+ }
205
+ }
206
+ function formatVariableDeclaration(state, node) {
207
+ /*
208
+ Writes into `state` a variable declaration.
209
+ */
210
+ const { generator } = state;
211
+ const { declarations } = node;
212
+ state.write(node.kind + ' ');
213
+ const { length } = declarations;
214
+ if (length > 0) {
215
+ generator.VariableDeclarator(declarations[0], state);
216
+ for (let i = 1; i < length; i++) {
217
+ state.write(', ');
218
+ generator.VariableDeclarator(declarations[i], state);
219
+ }
220
+ }
221
+ }
222
+ let ForInStatement, FunctionDeclaration, RestElement, BinaryExpression, ArrayExpression, BlockStatement;
223
+ export const GENERATOR = {
224
+ /*
225
+ Default generator.
226
+ */
227
+ Program(node, state) {
228
+ const indent = state.indent.repeat(state.indentLevel);
229
+ const { lineEnd, writeComments } = state;
230
+ if (writeComments && node.comments != null) {
231
+ formatComments(state, node.comments, indent, lineEnd);
232
+ }
233
+ const statements = node.body;
234
+ const { length } = statements;
235
+ for (let i = 0; i < length; i++) {
236
+ const statement = statements[i];
237
+ if (writeComments && statement.comments != null) {
238
+ formatComments(state, statement.comments, indent, lineEnd);
239
+ }
240
+ state.write(indent);
241
+ this[statement.type](statement, state);
242
+ state.write(lineEnd);
243
+ }
244
+ if (writeComments && node.trailingComments != null) {
245
+ formatComments(state, node.trailingComments, indent, lineEnd);
246
+ }
247
+ },
248
+ BlockStatement: (BlockStatement = function (node, state) {
249
+ const indent = state.indent.repeat(state.indentLevel++);
250
+ const { lineEnd, writeComments } = state;
251
+ const statementIndent = indent + state.indent;
252
+ state.write('{');
253
+ const statements = node.body;
254
+ if (statements != null && statements.length > 0) {
255
+ state.write(lineEnd);
256
+ if (writeComments && node.comments != null) {
257
+ formatComments(state, node.comments, statementIndent, lineEnd);
258
+ }
259
+ const { length } = statements;
260
+ for (let i = 0; i < length; i++) {
261
+ const statement = statements[i];
262
+ if (writeComments && statement.comments != null) {
263
+ formatComments(state, statement.comments, statementIndent, lineEnd);
264
+ }
265
+ state.write(statementIndent);
266
+ this[statement.type](statement, state);
267
+ state.write(lineEnd);
268
+ }
269
+ state.write(indent);
270
+ }
271
+ else {
272
+ if (writeComments && node.comments != null) {
273
+ state.write(lineEnd);
274
+ formatComments(state, node.comments, statementIndent, lineEnd);
275
+ state.write(indent);
276
+ }
277
+ }
278
+ if (writeComments && node.trailingComments != null) {
279
+ formatComments(state, node.trailingComments, statementIndent, lineEnd);
280
+ }
281
+ state.write('}');
282
+ state.indentLevel--;
283
+ }),
284
+ ClassBody: BlockStatement,
285
+ StaticBlock(node, state) {
286
+ state.write('static ');
287
+ this.BlockStatement(node, state);
288
+ },
289
+ EmptyStatement(node, state) {
290
+ state.write(';');
291
+ },
292
+ ExpressionStatement(node, state) {
293
+ const precedence = state.expressionsPrecedence[node.expression.type];
294
+ if (precedence === NEEDS_PARENTHESES ||
295
+ (precedence === 3 && node.expression.left.type[0] === 'O')) {
296
+ // Should always have parentheses or is an AssignmentExpression to an ObjectPattern
297
+ state.write('(');
298
+ this[node.expression.type](node.expression, state);
299
+ state.write(')');
300
+ }
301
+ else {
302
+ this[node.expression.type](node.expression, state);
303
+ }
304
+ state.write(';');
305
+ },
306
+ IfStatement(node, state) {
307
+ state.write('if (');
308
+ this[node.test.type](node.test, state);
309
+ state.write(') ');
310
+ this[node.consequent.type](node.consequent, state);
311
+ if (node.alternate != null) {
312
+ state.write(' else ');
313
+ this[node.alternate.type](node.alternate, state);
314
+ }
315
+ },
316
+ LabeledStatement(node, state) {
317
+ this[node.label.type](node.label, state);
318
+ state.write(': ');
319
+ this[node.body.type](node.body, state);
320
+ },
321
+ BreakStatement(node, state) {
322
+ state.write('break');
323
+ if (node.label != null) {
324
+ state.write(' ');
325
+ this[node.label.type](node.label, state);
326
+ }
327
+ state.write(';');
328
+ },
329
+ ContinueStatement(node, state) {
330
+ state.write('continue');
331
+ if (node.label != null) {
332
+ state.write(' ');
333
+ this[node.label.type](node.label, state);
334
+ }
335
+ state.write(';');
336
+ },
337
+ WithStatement(node, state) {
338
+ state.write('with (');
339
+ this[node.object.type](node.object, state);
340
+ state.write(') ');
341
+ this[node.body.type](node.body, state);
342
+ },
343
+ SwitchStatement(node, state) {
344
+ const indent = state.indent.repeat(state.indentLevel++);
345
+ const { lineEnd, writeComments } = state;
346
+ state.indentLevel++;
347
+ const caseIndent = indent + state.indent;
348
+ const statementIndent = caseIndent + state.indent;
349
+ state.write('switch (');
350
+ this[node.discriminant.type](node.discriminant, state);
351
+ state.write(') {' + lineEnd);
352
+ const { cases: occurences } = node;
353
+ const { length: occurencesCount } = occurences;
354
+ for (let i = 0; i < occurencesCount; i++) {
355
+ const occurence = occurences[i];
356
+ if (writeComments && occurence.comments != null) {
357
+ formatComments(state, occurence.comments, caseIndent, lineEnd);
358
+ }
359
+ if (occurence.test) {
360
+ state.write(caseIndent + 'case ');
361
+ this[occurence.test.type](occurence.test, state);
362
+ state.write(':' + lineEnd);
363
+ }
364
+ else {
365
+ state.write(caseIndent + 'default:' + lineEnd);
366
+ }
367
+ const { consequent } = occurence;
368
+ const { length: consequentCount } = consequent;
369
+ for (let i = 0; i < consequentCount; i++) {
370
+ const statement = consequent[i];
371
+ if (writeComments && statement.comments != null) {
372
+ formatComments(state, statement.comments, statementIndent, lineEnd);
373
+ }
374
+ state.write(statementIndent);
375
+ this[statement.type](statement, state);
376
+ state.write(lineEnd);
377
+ }
378
+ }
379
+ state.indentLevel -= 2;
380
+ state.write(indent + '}');
381
+ },
382
+ ReturnStatement(node, state) {
383
+ state.write('return');
384
+ if (node.argument) {
385
+ state.write(' ');
386
+ this[node.argument.type](node.argument, state);
387
+ }
388
+ state.write(';');
389
+ },
390
+ ThrowStatement(node, state) {
391
+ state.write('throw ');
392
+ this[node.argument.type](node.argument, state);
393
+ state.write(';');
394
+ },
395
+ TryStatement(node, state) {
396
+ state.write('try ');
397
+ this[node.block.type](node.block, state);
398
+ if (node.handler) {
399
+ const { handler } = node;
400
+ if (handler.param == null) {
401
+ state.write(' catch ');
402
+ }
403
+ else {
404
+ state.write(' catch (');
405
+ this[handler.param.type](handler.param, state);
406
+ state.write(') ');
407
+ }
408
+ this[handler.body.type](handler.body, state);
409
+ }
410
+ if (node.finalizer) {
411
+ state.write(' finally ');
412
+ this[node.finalizer.type](node.finalizer, state);
413
+ }
414
+ },
415
+ WhileStatement(node, state) {
416
+ state.write('while (');
417
+ this[node.test.type](node.test, state);
418
+ state.write(') ');
419
+ this[node.body.type](node.body, state);
420
+ },
421
+ DoWhileStatement(node, state) {
422
+ state.write('do ');
423
+ this[node.body.type](node.body, state);
424
+ state.write(' while (');
425
+ this[node.test.type](node.test, state);
426
+ state.write(');');
427
+ },
428
+ ForStatement(node, state) {
429
+ state.write('for (');
430
+ if (node.init != null) {
431
+ const { init } = node;
432
+ if (init.type[0] === 'V') {
433
+ formatVariableDeclaration(state, init);
434
+ }
435
+ else {
436
+ this[init.type](init, state);
437
+ }
438
+ }
439
+ state.write('; ');
440
+ if (node.test) {
441
+ this[node.test.type](node.test, state);
442
+ }
443
+ state.write('; ');
444
+ if (node.update) {
445
+ this[node.update.type](node.update, state);
446
+ }
447
+ state.write(') ');
448
+ this[node.body.type](node.body, state);
449
+ },
450
+ ForInStatement: (ForInStatement = function (node, state) {
451
+ state.write(`for ${node.await ? 'await ' : ''}(`);
452
+ const { left } = node;
453
+ if (left.type[0] === 'V') {
454
+ formatVariableDeclaration(state, left);
455
+ }
456
+ else {
457
+ this[left.type](left, state);
458
+ }
459
+ // Identifying whether node.type is `ForInStatement` or `ForOfStatement`
460
+ state.write(node.type[3] === 'I' ? ' in ' : ' of ');
461
+ this[node.right.type](node.right, state);
462
+ state.write(') ');
463
+ this[node.body.type](node.body, state);
464
+ }),
465
+ ForOfStatement: ForInStatement,
466
+ DebuggerStatement(node, state) {
467
+ state.write('debugger;', node);
468
+ },
469
+ FunctionDeclaration: (FunctionDeclaration = function (node, state) {
470
+ state.write((node.async ? 'async ' : '') +
471
+ (node.generator ? 'function* ' : 'function ') +
472
+ (node.id ? node.id.name : ''), node);
473
+ formatSequence(state, node.params);
474
+ state.write(' ');
475
+ this[node.body.type](node.body, state);
476
+ }),
477
+ FunctionExpression: FunctionDeclaration,
478
+ VariableDeclaration(node, state) {
479
+ formatVariableDeclaration(state, node);
480
+ state.write(';');
481
+ },
482
+ VariableDeclarator(node, state) {
483
+ this[node.id.type](node.id, state);
484
+ if (node.init != null) {
485
+ state.write(' = ');
486
+ this[node.init.type](node.init, state);
487
+ }
488
+ },
489
+ ClassDeclaration(node, state) {
490
+ state.write('class ' + (node.id ? `${node.id.name} ` : ''), node);
491
+ if (node.superClass) {
492
+ state.write('extends ');
493
+ const { superClass } = node;
494
+ const { type } = superClass;
495
+ const precedence = state.expressionsPrecedence[type];
496
+ if ((type[0] !== 'C' || type[1] !== 'l' || type[5] !== 'E') &&
497
+ (precedence === NEEDS_PARENTHESES ||
498
+ precedence < state.expressionsPrecedence.ClassExpression)) {
499
+ // Not a ClassExpression that needs parentheses
500
+ state.write('(');
501
+ this[node.superClass.type](superClass, state);
502
+ state.write(')');
503
+ }
504
+ else {
505
+ this[superClass.type](superClass, state);
506
+ }
507
+ state.write(' ');
508
+ }
509
+ this.ClassBody(node.body, state);
510
+ },
511
+ ImportDeclaration(node, state) {
512
+ state.write('import ');
513
+ const { specifiers } = node;
514
+ const { length } = specifiers;
515
+ // TODO: Once babili is fixed, put this after condition
516
+ // https://github.com/babel/babili/issues/430
517
+ let i = 0;
518
+ if (length > 0) {
519
+ for (; i < length;) {
520
+ if (i > 0) {
521
+ state.write(', ');
522
+ }
523
+ const specifier = specifiers[i];
524
+ const type = specifier.type[6];
525
+ if (type === 'D') {
526
+ // ImportDefaultSpecifier
527
+ state.write(specifier.local.name, specifier);
528
+ i++;
529
+ }
530
+ else if (type === 'N') {
531
+ // ImportNamespaceSpecifier
532
+ state.write('* as ' + specifier.local.name, specifier);
533
+ i++;
534
+ }
535
+ else {
536
+ // ImportSpecifier
537
+ break;
538
+ }
539
+ }
540
+ if (i < length) {
541
+ state.write('{');
542
+ for (;;) {
543
+ const specifier = specifiers[i];
544
+ const { name } = specifier.imported;
545
+ state.write(name, specifier);
546
+ if (name !== specifier.local.name) {
547
+ state.write(' as ' + specifier.local.name);
548
+ }
549
+ if (++i < length) {
550
+ state.write(', ');
551
+ }
552
+ else {
553
+ break;
554
+ }
555
+ }
556
+ state.write('}');
557
+ }
558
+ state.write(' from ');
559
+ }
560
+ this.Literal(node.source, state);
561
+ state.write(';');
562
+ },
563
+ ImportExpression(node, state) {
564
+ state.write('import(');
565
+ this[node.source.type](node.source, state);
566
+ state.write(')');
567
+ },
568
+ ExportDefaultDeclaration(node, state) {
569
+ state.write('export default ');
570
+ this[node.declaration.type](node.declaration, state);
571
+ if (state.expressionsPrecedence[node.declaration.type] != null &&
572
+ node.declaration.type[0] !== 'F') {
573
+ // All expression nodes except `FunctionExpression`
574
+ state.write(';');
575
+ }
576
+ },
577
+ ExportNamedDeclaration(node, state) {
578
+ state.write('export ');
579
+ if (node.declaration) {
580
+ this[node.declaration.type](node.declaration, state);
581
+ }
582
+ else {
583
+ state.write('{');
584
+ const { specifiers } = node, { length } = specifiers;
585
+ if (length > 0) {
586
+ for (let i = 0;;) {
587
+ const specifier = specifiers[i];
588
+ const { name } = specifier.local;
589
+ state.write(name, specifier);
590
+ if (name !== specifier.exported.name) {
591
+ state.write(' as ' + specifier.exported.name);
592
+ }
593
+ if (++i < length) {
594
+ state.write(', ');
595
+ }
596
+ else {
597
+ break;
598
+ }
599
+ }
600
+ }
601
+ state.write('}');
602
+ if (node.source) {
603
+ state.write(' from ');
604
+ this.Literal(node.source, state);
605
+ }
606
+ state.write(';');
607
+ }
608
+ },
609
+ ExportAllDeclaration(node, state) {
610
+ if (node.exported != null) {
611
+ state.write('export * as ' + node.exported.name + ' from ');
612
+ }
613
+ else {
614
+ state.write('export * from ');
615
+ }
616
+ this.Literal(node.source, state);
617
+ state.write(';');
618
+ },
619
+ MethodDefinition(node, state) {
620
+ if (node.static) {
621
+ state.write('static ');
622
+ }
623
+ const kind = node.kind[0];
624
+ if (kind === 'g' || kind === 's') {
625
+ // Getter or setter
626
+ state.write(node.kind + ' ');
627
+ }
628
+ if (node.value.async) {
629
+ state.write('async ');
630
+ }
631
+ if (node.value.generator) {
632
+ state.write('*');
633
+ }
634
+ if (node.computed) {
635
+ state.write('[');
636
+ this[node.key.type](node.key, state);
637
+ state.write(']');
638
+ }
639
+ else {
640
+ this[node.key.type](node.key, state);
641
+ }
642
+ formatSequence(state, node.value.params);
643
+ state.write(' ');
644
+ this[node.value.body.type](node.value.body, state);
645
+ },
646
+ ClassExpression(node, state) {
647
+ this.ClassDeclaration(node, state);
648
+ },
649
+ ArrowFunctionExpression(node, state) {
650
+ state.write(node.async ? 'async ' : '', node);
651
+ const { params } = node;
652
+ if (params != null) {
653
+ // Omit parenthesis if only one named parameter
654
+ if (params.length === 1 && params[0].type[0] === 'I') {
655
+ // If params[0].type[0] starts with 'I', it can't be `ImportDeclaration` nor `IfStatement` and thus is `Identifier`
656
+ state.write(params[0].name, params[0]);
657
+ }
658
+ else {
659
+ formatSequence(state, node.params);
660
+ }
661
+ }
662
+ state.write(' => ');
663
+ if (node.body.type[0] === 'O') {
664
+ // Body is an object expression
665
+ state.write('(');
666
+ this.ObjectExpression(node.body, state);
667
+ state.write(')');
668
+ }
669
+ else {
670
+ this[node.body.type](node.body, state);
671
+ }
672
+ },
673
+ ThisExpression(node, state) {
674
+ state.write('this', node);
675
+ },
676
+ Super(node, state) {
677
+ state.write('super', node);
678
+ },
679
+ RestElement: (RestElement = function (node, state) {
680
+ state.write('...');
681
+ this[node.argument.type](node.argument, state);
682
+ }),
683
+ SpreadElement: RestElement,
684
+ YieldExpression(node, state) {
685
+ state.write(node.delegate ? 'yield*' : 'yield');
686
+ if (node.argument) {
687
+ state.write(' ');
688
+ this[node.argument.type](node.argument, state);
689
+ }
690
+ },
691
+ AwaitExpression(node, state) {
692
+ state.write('await ', node);
693
+ formatExpression(state, node.argument, node);
694
+ },
695
+ TemplateLiteral(node, state) {
696
+ const { quasis, expressions } = node;
697
+ state.write('`');
698
+ const { length } = expressions;
699
+ for (let i = 0; i < length; i++) {
700
+ const expression = expressions[i];
701
+ const quasi = quasis[i];
702
+ state.write(quasi.value.raw, quasi);
703
+ state.write('${');
704
+ this[expression.type](expression, state);
705
+ state.write('}');
706
+ }
707
+ const quasi = quasis[quasis.length - 1];
708
+ state.write(quasi.value.raw, quasi);
709
+ state.write('`');
710
+ },
711
+ TemplateElement(node, state) {
712
+ state.write(node.value.raw, node);
713
+ },
714
+ TaggedTemplateExpression(node, state) {
715
+ formatExpression(state, node.tag, node);
716
+ this[node.quasi.type](node.quasi, state);
717
+ },
718
+ ArrayExpression: (ArrayExpression = function (node, state) {
719
+ state.write('[');
720
+ if (node.elements.length > 0) {
721
+ const { elements } = node, { length } = elements;
722
+ for (let i = 0;;) {
723
+ const element = elements[i];
724
+ if (element != null) {
725
+ this[element.type](element, state);
726
+ }
727
+ if (++i < length) {
728
+ state.write(', ');
729
+ }
730
+ else {
731
+ if (element == null) {
732
+ state.write(', ');
733
+ }
734
+ break;
735
+ }
736
+ }
737
+ }
738
+ state.write(']');
739
+ }),
740
+ ArrayPattern: ArrayExpression,
741
+ ObjectExpression(node, state) {
742
+ const indent = state.indent.repeat(state.indentLevel++);
743
+ const { lineEnd, writeComments } = state;
744
+ const propertyIndent = indent + state.indent;
745
+ state.write('{');
746
+ if (node.properties.length > 0) {
747
+ state.write(lineEnd);
748
+ if (writeComments && node.comments != null) {
749
+ formatComments(state, node.comments, propertyIndent, lineEnd);
750
+ }
751
+ const comma = ',' + lineEnd;
752
+ const { properties } = node, { length } = properties;
753
+ for (let i = 0;;) {
754
+ const property = properties[i];
755
+ if (writeComments && property.comments != null) {
756
+ formatComments(state, property.comments, propertyIndent, lineEnd);
757
+ }
758
+ state.write(propertyIndent);
759
+ this[property.type](property, state);
760
+ if (++i < length) {
761
+ state.write(comma);
762
+ }
763
+ else {
764
+ break;
765
+ }
766
+ }
767
+ state.write(lineEnd);
768
+ if (writeComments && node.trailingComments != null) {
769
+ formatComments(state, node.trailingComments, propertyIndent, lineEnd);
770
+ }
771
+ state.write(indent + '}');
772
+ }
773
+ else if (writeComments) {
774
+ if (node.comments != null) {
775
+ state.write(lineEnd);
776
+ formatComments(state, node.comments, propertyIndent, lineEnd);
777
+ if (node.trailingComments != null) {
778
+ formatComments(state, node.trailingComments, propertyIndent, lineEnd);
779
+ }
780
+ state.write(indent + '}');
781
+ }
782
+ else if (node.trailingComments != null) {
783
+ state.write(lineEnd);
784
+ formatComments(state, node.trailingComments, propertyIndent, lineEnd);
785
+ state.write(indent + '}');
786
+ }
787
+ else {
788
+ state.write('}');
789
+ }
790
+ }
791
+ else {
792
+ state.write('}');
793
+ }
794
+ state.indentLevel--;
795
+ },
796
+ Property(node, state) {
797
+ if (node.method || node.kind[0] !== 'i') {
798
+ // Either a method or of kind `set` or `get` (not `init`)
799
+ this.MethodDefinition(node, state);
800
+ }
801
+ else {
802
+ if (!node.shorthand) {
803
+ if (node.computed) {
804
+ state.write('[');
805
+ this[node.key.type](node.key, state);
806
+ state.write(']');
807
+ }
808
+ else {
809
+ this[node.key.type](node.key, state);
810
+ }
811
+ state.write(': ');
812
+ }
813
+ this[node.value.type](node.value, state);
814
+ }
815
+ },
816
+ PropertyDefinition(node, state) {
817
+ if (node.static) {
818
+ state.write('static ');
819
+ }
820
+ if (node.computed) {
821
+ state.write('[');
822
+ }
823
+ this[node.key.type](node.key, state);
824
+ if (node.computed) {
825
+ state.write(']');
826
+ }
827
+ if (node.value == null) {
828
+ if (node.key.type[0] !== 'F') {
829
+ state.write(';');
830
+ }
831
+ return;
832
+ }
833
+ state.write(' = ');
834
+ this[node.value.type](node.value, state);
835
+ state.write(';');
836
+ },
837
+ ObjectPattern(node, state) {
838
+ state.write('{');
839
+ if (node.properties.length > 0) {
840
+ const { properties } = node, { length } = properties;
841
+ for (let i = 0;;) {
842
+ this[properties[i].type](properties[i], state);
843
+ if (++i < length) {
844
+ state.write(', ');
845
+ }
846
+ else {
847
+ break;
848
+ }
849
+ }
850
+ }
851
+ state.write('}');
852
+ },
853
+ SequenceExpression(node, state) {
854
+ formatSequence(state, node.expressions);
855
+ },
856
+ UnaryExpression(node, state) {
857
+ if (node.prefix) {
858
+ const { operator, argument, argument: { type }, } = node;
859
+ state.write(operator);
860
+ const needsParentheses = expressionNeedsParenthesis(state, argument, node);
861
+ if (!needsParentheses &&
862
+ (operator.length > 1 ||
863
+ (type[0] === 'U' &&
864
+ (type[1] === 'n' || type[1] === 'p') &&
865
+ argument.prefix &&
866
+ argument.operator[0] === operator &&
867
+ (operator === '+' || operator === '-')))) {
868
+ // Large operator or argument is UnaryExpression or UpdateExpression node
869
+ state.write(' ');
870
+ }
871
+ if (needsParentheses) {
872
+ state.write(operator.length > 1 ? ' (' : '(');
873
+ this[type](argument, state);
874
+ state.write(')');
875
+ }
876
+ else {
877
+ this[type](argument, state);
878
+ }
879
+ }
880
+ else {
881
+ // FIXME: This case never occurs
882
+ this[node.argument.type](node.argument, state);
883
+ state.write(node.operator);
884
+ }
885
+ },
886
+ UpdateExpression(node, state) {
887
+ // Always applied to identifiers or members, no parenthesis check needed
888
+ if (node.prefix) {
889
+ state.write(node.operator);
890
+ this[node.argument.type](node.argument, state);
891
+ }
892
+ else {
893
+ this[node.argument.type](node.argument, state);
894
+ state.write(node.operator);
895
+ }
896
+ },
897
+ AssignmentExpression(node, state) {
898
+ this[node.left.type](node.left, state);
899
+ state.write(' ' + node.operator + ' ');
900
+ this[node.right.type](node.right, state);
901
+ },
902
+ AssignmentPattern(node, state) {
903
+ this[node.left.type](node.left, state);
904
+ state.write(' = ');
905
+ this[node.right.type](node.right, state);
906
+ },
907
+ BinaryExpression: (BinaryExpression = function (node, state) {
908
+ const isIn = node.operator === 'in';
909
+ if (isIn) {
910
+ // Avoids confusion in `for` loops initializers
911
+ state.write('(');
912
+ }
913
+ formatExpression(state, node.left, node, false);
914
+ state.write(' ' + node.operator + ' ');
915
+ formatExpression(state, node.right, node, true);
916
+ if (isIn) {
917
+ state.write(')');
918
+ }
919
+ }),
920
+ LogicalExpression: BinaryExpression,
921
+ ConditionalExpression(node, state) {
922
+ const { test } = node;
923
+ const precedence = state.expressionsPrecedence[test.type];
924
+ if (precedence === NEEDS_PARENTHESES ||
925
+ precedence <= state.expressionsPrecedence.ConditionalExpression) {
926
+ state.write('(');
927
+ this[test.type](test, state);
928
+ state.write(')');
929
+ }
930
+ else {
931
+ this[test.type](test, state);
932
+ }
933
+ state.write(' ? ');
934
+ this[node.consequent.type](node.consequent, state);
935
+ state.write(' : ');
936
+ this[node.alternate.type](node.alternate, state);
937
+ },
938
+ NewExpression(node, state) {
939
+ state.write('new ');
940
+ const precedence = state.expressionsPrecedence[node.callee.type];
941
+ if (precedence === NEEDS_PARENTHESES ||
942
+ precedence < state.expressionsPrecedence.CallExpression ||
943
+ hasCallExpression(node.callee)) {
944
+ state.write('(');
945
+ this[node.callee.type](node.callee, state);
946
+ state.write(')');
947
+ }
948
+ else {
949
+ this[node.callee.type](node.callee, state);
950
+ }
951
+ formatSequence(state, node['arguments']);
952
+ },
953
+ CallExpression(node, state) {
954
+ const precedence = state.expressionsPrecedence[node.callee.type];
955
+ if (precedence === NEEDS_PARENTHESES ||
956
+ precedence < state.expressionsPrecedence.CallExpression) {
957
+ state.write('(');
958
+ this[node.callee.type](node.callee, state);
959
+ state.write(')');
960
+ }
961
+ else {
962
+ this[node.callee.type](node.callee, state);
963
+ }
964
+ if (node.optional) {
965
+ state.write('?.');
966
+ }
967
+ formatSequence(state, node['arguments']);
968
+ },
969
+ ChainExpression(node, state) {
970
+ this[node.expression.type](node.expression, state);
971
+ },
972
+ MemberExpression(node, state) {
973
+ const precedence = state.expressionsPrecedence[node.object.type];
974
+ if (precedence === NEEDS_PARENTHESES ||
975
+ precedence < state.expressionsPrecedence.MemberExpression) {
976
+ state.write('(');
977
+ this[node.object.type](node.object, state);
978
+ state.write(')');
979
+ }
980
+ else {
981
+ this[node.object.type](node.object, state);
982
+ }
983
+ if (node.computed) {
984
+ if (node.optional) {
985
+ state.write('?.');
986
+ }
987
+ state.write('[');
988
+ this[node.property.type](node.property, state);
989
+ state.write(']');
990
+ }
991
+ else {
992
+ if (node.optional) {
993
+ state.write('?.');
994
+ }
995
+ else {
996
+ state.write('.');
997
+ }
998
+ this[node.property.type](node.property, state);
999
+ }
1000
+ },
1001
+ MetaProperty(node, state) {
1002
+ state.write(node.meta.name + '.' + node.property.name, node);
1003
+ },
1004
+ Identifier(node, state) {
1005
+ state.write(node.name, node);
1006
+ },
1007
+ PrivateIdentifier(node, state) {
1008
+ state.write(`#${node.name}`, node);
1009
+ },
1010
+ Literal(node, state) {
1011
+ if (node.raw != null) {
1012
+ // Non-standard property
1013
+ state.write(node.raw, node);
1014
+ }
1015
+ else if (node.regex != null) {
1016
+ this.RegExpLiteral(node, state);
1017
+ }
1018
+ else if (node.bigint != null) {
1019
+ state.write(node.bigint + 'n', node);
1020
+ }
1021
+ else {
1022
+ state.write(stringify(node.value), node);
1023
+ }
1024
+ },
1025
+ RegExpLiteral(node, state) {
1026
+ const { regex } = node;
1027
+ state.write(`/${regex.pattern}/${regex.flags}`, node);
1028
+ },
1029
+ };
1030
+ const EMPTY_OBJECT = {};
1031
+ /*
1032
+ DEPRECATED: Alternate export of `GENERATOR`.
1033
+ */
1034
+ export const baseGenerator = GENERATOR;
1035
+ class State {
1036
+ constructor(options) {
1037
+ const setup = options == null ? EMPTY_OBJECT : options;
1038
+ this.output = '';
1039
+ // Functional options
1040
+ if (setup.output != null) {
1041
+ this.output = setup.output;
1042
+ this.write = this.writeToStream;
1043
+ }
1044
+ else {
1045
+ this.output = '';
1046
+ }
1047
+ this.generator = setup.generator != null ? setup.generator : GENERATOR;
1048
+ this.expressionsPrecedence =
1049
+ setup.expressionsPrecedence != null
1050
+ ? setup.expressionsPrecedence
1051
+ : EXPRESSIONS_PRECEDENCE;
1052
+ // Formating setup
1053
+ this.indent = setup.indent != null ? setup.indent : ' ';
1054
+ this.lineEnd = setup.lineEnd != null ? setup.lineEnd : '\n';
1055
+ this.indentLevel =
1056
+ setup.startingIndentLevel != null ? setup.startingIndentLevel : 0;
1057
+ this.writeComments = setup.comments ? setup.comments : false;
1058
+ // Source map
1059
+ if (setup.sourceMap != null) {
1060
+ this.write =
1061
+ setup.output == null ? this.writeAndMap : this.writeToStreamAndMap;
1062
+ this.sourceMap = setup.sourceMap;
1063
+ this.line = 1;
1064
+ this.column = 0;
1065
+ this.lineEndSize = this.lineEnd.split('\n').length - 1;
1066
+ this.mapping = {
1067
+ original: null,
1068
+ // Uses the entire state to avoid generating ephemeral objects
1069
+ generated: this,
1070
+ name: undefined,
1071
+ source: setup.sourceMap.file || setup.sourceMap._file,
1072
+ };
1073
+ }
1074
+ }
1075
+ write(code) {
1076
+ this.output += code;
1077
+ }
1078
+ writeToStream(code) {
1079
+ this.output.write(code);
1080
+ }
1081
+ writeAndMap(code, node) {
1082
+ this.output += code;
1083
+ this.map(code, node);
1084
+ }
1085
+ writeToStreamAndMap(code, node) {
1086
+ this.output.write(code);
1087
+ this.map(code, node);
1088
+ }
1089
+ map(code, node) {
1090
+ if (node != null) {
1091
+ const { type } = node;
1092
+ if (type[0] === 'L' && type[2] === 'n') {
1093
+ // LineComment
1094
+ this.column = 0;
1095
+ this.line++;
1096
+ return;
1097
+ }
1098
+ if (node.loc != null) {
1099
+ const { mapping } = this;
1100
+ mapping.original = node.loc.start;
1101
+ mapping.name = node.name;
1102
+ this.sourceMap.addMapping(mapping);
1103
+ }
1104
+ if ((type[0] === 'T' && type[8] === 'E') ||
1105
+ (type[0] === 'L' && type[1] === 'i' && typeof node.value === 'string')) {
1106
+ // TemplateElement or Literal string node
1107
+ const { length } = code;
1108
+ let { column, line } = this;
1109
+ for (let i = 0; i < length; i++) {
1110
+ if (code[i] === '\n') {
1111
+ column = 0;
1112
+ line++;
1113
+ }
1114
+ else {
1115
+ column++;
1116
+ }
1117
+ }
1118
+ this.column = column;
1119
+ this.line = line;
1120
+ return;
1121
+ }
1122
+ }
1123
+ const { length } = code;
1124
+ const { lineEnd } = this;
1125
+ if (length > 0) {
1126
+ if (this.lineEndSize > 0 &&
1127
+ (lineEnd.length === 1
1128
+ ? code[length - 1] === lineEnd
1129
+ : code.endsWith(lineEnd))) {
1130
+ this.line += this.lineEndSize;
1131
+ this.column = 0;
1132
+ }
1133
+ else {
1134
+ this.column += length;
1135
+ }
1136
+ }
1137
+ }
1138
+ toString() {
1139
+ return this.output;
1140
+ }
1141
+ }
1142
+ export function generate(node, options) {
1143
+ /*
1144
+ Returns a string representing the rendered code of the provided AST `node`.
1145
+ The `options` are:
1146
+
1147
+ - `indent`: string to use for indentation (defaults to `␣␣`)
1148
+ - `lineEnd`: string to use for line endings (defaults to `\n`)
1149
+ - `startingIndentLevel`: indent level to start from (defaults to `0`)
1150
+ - `comments`: generate comments if `true` (defaults to `false`)
1151
+ - `output`: output stream to write the rendered code to (defaults to `null`)
1152
+ - `generator`: custom code generator (defaults to `GENERATOR`)
1153
+ - `expressionsPrecedence`: custom map of node types and their precedence level (defaults to `EXPRESSIONS_PRECEDENCE`)
1154
+ */
1155
+ const state = new State(options);
1156
+ // Travel through the AST node and generate the code
1157
+ state.generator[node.type](node, state);
1158
+ return state.output;
1159
+ }