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
package/esm/deps.d.ts CHANGED
@@ -1,2 +1,6 @@
1
- export * as path from "./deps/deno.land/std@0.210.0/path/mod.js";
2
- export * as html from "./deps/deno.land/std@0.210.0/html/mod.js";
1
+ export * as path from "./deps/deno.land/std@0.219.1/path/mod.js";
2
+ export * as html from "./deps/deno.land/std@0.219.1/html/mod.js";
3
+ export * as astring from "./deps/deno.land/x/astring@v1.8.6/src/astring.js";
4
+ export * as meriyah from "meriyah";
5
+ export * as walker from "estree-walker";
6
+ export type * as ESTree from "estree";
package/esm/deps.js CHANGED
@@ -1,2 +1,5 @@
1
- export * as path from "./deps/deno.land/std@0.210.0/path/mod.js";
2
- export * as html from "./deps/deno.land/std@0.210.0/html/mod.js";
1
+ export * as path from "./deps/deno.land/std@0.219.1/path/mod.js";
2
+ export * as html from "./deps/deno.land/std@0.219.1/html/mod.js";
3
+ export * as astring from "./deps/deno.land/x/astring@v1.8.6/src/astring.js";
4
+ export * as meriyah from "meriyah";
5
+ export * as walker from "estree-walker";
package/esm/mod.d.ts CHANGED
@@ -2,6 +2,7 @@ import { Environment } from "./src/environment.js";
2
2
  import { Loader } from "./src/loader.js";
3
3
  export interface Options {
4
4
  includes?: string | Loader;
5
+ /** @deprecated */
5
6
  useWith?: boolean;
6
7
  dataVarname?: string;
7
8
  autoescape?: boolean;
package/esm/mod.js CHANGED
@@ -13,6 +13,7 @@ import exportTag from "./plugins/export.js";
13
13
  import echoTag from "./plugins/echo.js";
14
14
  import escape from "./plugins/escape.js";
15
15
  import unescape from "./plugins/unescape.js";
16
+ import trim from "./plugins/trim.js";
16
17
  export default function (options = {}) {
17
18
  const loader = typeof options.includes === "object"
18
19
  ? options.includes
@@ -36,5 +37,6 @@ export default function (options = {}) {
36
37
  env.use(echoTag());
37
38
  env.use(escape());
38
39
  env.use(unescape());
40
+ env.use(trim());
39
41
  return env;
40
42
  }
@@ -0,0 +1,8 @@
1
+ import type { Token } from "../src/tokenizer.js";
2
+ import type { Environment } from "../src/environment.js";
3
+ export declare const defaultTags: string[];
4
+ export type AutoTrimOptions = {
5
+ tags: string[];
6
+ };
7
+ export default function (options?: AutoTrimOptions): (env: Environment) => void;
8
+ export declare function autoTrim(tokens: Token[], options: AutoTrimOptions): void;
@@ -0,0 +1,36 @@
1
+ export const defaultTags = [
2
+ ">",
3
+ "#",
4
+ "set",
5
+ "/set",
6
+ "if",
7
+ "/if",
8
+ "else",
9
+ "for",
10
+ "/for",
11
+ "function",
12
+ "async",
13
+ "/function",
14
+ "export",
15
+ "/export",
16
+ "import",
17
+ ];
18
+ export default function (options = { tags: defaultTags }) {
19
+ return (env) => {
20
+ env.tokenPreprocessors.push((_, tokens) => autoTrim(tokens, options));
21
+ };
22
+ }
23
+ export function autoTrim(tokens, options) {
24
+ for (let i = 0; i < tokens.length; i++) {
25
+ const previous = tokens[i - 1];
26
+ const token = tokens[i];
27
+ const next = tokens[i + 1];
28
+ const [type, code] = token;
29
+ if (type === "tag" && options.tags.find((tag) => code.startsWith(tag))) {
30
+ // Remove leading horizontal space
31
+ previous[1] = previous[1].replace(/[ \t]*$/, "");
32
+ // Remove trailing horizontal space + newline
33
+ next[1] = next[1].replace(/^[ \t]*(?:\r\n|\n)/, "");
34
+ }
35
+ }
36
+ }
@@ -1,6 +1,7 @@
1
1
  import { html } from "../deps.js";
2
2
  export default function () {
3
3
  return (env) => {
4
- env.filters.escape = html.escape;
4
+ // deno-lint-ignore no-explicit-any
5
+ env.filters.escape = (value) => value ? html.escape(value.toString()) : "";
5
6
  };
6
7
  }
@@ -0,0 +1,4 @@
1
+ import type { Token } from "../src/tokenizer.js";
2
+ import type { Environment } from "../src/environment.js";
3
+ export default function (): (env: Environment) => void;
4
+ export declare function trim(_: Environment, tokens: Token[]): void;
@@ -0,0 +1,28 @@
1
+ export default function () {
2
+ return (env) => {
3
+ env.tokenPreprocessors.push(trim);
4
+ };
5
+ }
6
+ export function trim(_, tokens) {
7
+ for (let i = 0; i < tokens.length; i++) {
8
+ const previous = tokens[i - 1];
9
+ const token = tokens[i];
10
+ const next = tokens[i + 1];
11
+ let [type, code] = token;
12
+ if (type === "tag" && code.startsWith("-")) {
13
+ previous[1] = previous[1].trimEnd();
14
+ code = code.slice(1);
15
+ }
16
+ if (type === "tag" && code.endsWith("-")) {
17
+ next[1] = next[1].trimStart();
18
+ code = code.slice(0, -1);
19
+ }
20
+ // Trim tag and filter code
21
+ switch (type) {
22
+ case "tag":
23
+ case "filter":
24
+ token[1] = code.trim();
25
+ break;
26
+ }
27
+ }
28
+ }
@@ -1,6 +1,7 @@
1
1
  import { html } from "../deps.js";
2
2
  export default function () {
3
3
  return (env) => {
4
- env.filters.unescape = html.unescape;
4
+ // deno-lint-ignore no-explicit-any
5
+ env.filters.unescape = (value) => value ? html.unescape(value.toString()) : "";
5
6
  };
6
7
  }
@@ -16,6 +16,7 @@ export interface TemplateSync {
16
16
  code: string;
17
17
  file?: string;
18
18
  }
19
+ export type TokenPreprocessor = (env: Environment, tokens: Token[], path?: string) => Token[] | void;
19
20
  export type Tag = (env: Environment, code: string, output: string, tokens: Token[]) => string | undefined;
20
21
  export type FilterThis = {
21
22
  data: Record<string, unknown>;
@@ -33,6 +34,7 @@ export declare class Environment {
33
34
  cache: Map<string, Template>;
34
35
  options: Options;
35
36
  tags: Tag[];
37
+ tokenPreprocessors: TokenPreprocessor[];
36
38
  filters: Record<string, Filter>;
37
39
  utils: Record<string, unknown>;
38
40
  constructor(options: Options);
@@ -42,6 +44,7 @@ export declare class Environment {
42
44
  runStringSync(source: string, data?: Record<string, unknown>): TemplateResult;
43
45
  compile(source: string, path?: string, defaults?: Record<string, unknown>, sync?: false): Template;
44
46
  compile(source: string, path?: string, defaults?: Record<string, unknown>, sync?: true): TemplateSync;
47
+ tokenize(source: string, path?: string): Token[];
45
48
  load(file: string, from?: string): Promise<Template>;
46
49
  compileTokens(tokens: Token[], outputVar?: string, stopAt?: string[]): string[];
47
50
  compileFilters(tokens: Token[], output: string, autoescape?: boolean): string;
@@ -1,9 +1,11 @@
1
1
  import * as dntShim from "../_dnt.shims.js";
2
2
  import tokenize from "./tokenizer.js";
3
+ import { transformTemplateCode } from "./transformer.js";
3
4
  export class Environment {
4
5
  cache = new Map();
5
6
  options;
6
7
  tags = [];
8
+ tokenPreprocessors = [];
7
9
  filters = {};
8
10
  utils = {};
9
11
  constructor(options) {
@@ -34,18 +36,18 @@ export class Environment {
34
36
  return template(data);
35
37
  }
36
38
  compile(source, path, defaults, sync = false) {
37
- const { tokens, position, error } = tokenize(source);
38
- if (error) {
39
- throw this.createError(path || "unknown", source, position, error);
40
- }
41
- const code = this.compileTokens(tokens).join("\n");
39
+ const tokens = this.tokenize(source, path);
40
+ let code = this.compileTokens(tokens).join("\n");
42
41
  const { dataVarname, useWith } = this.options;
42
+ if (useWith) {
43
+ code = transformTemplateCode(code, dataVarname);
44
+ }
43
45
  const constructor = new Function("__file", "__env", "__defaults", `return${sync ? "" : " async"} function (${dataVarname}) {
44
46
  let __pos = 0;
45
47
  try {
46
48
  ${dataVarname} = Object.assign({}, __defaults, ${dataVarname});
47
49
  const __exports = { content: "" };
48
- ${useWith ? `with (${dataVarname}) {${code}}` : code}
50
+ ${code}
49
51
  return __exports;
50
52
  } catch (cause) {
51
53
  const template = __env.cache.get(__file);
@@ -59,10 +61,29 @@ export class Environment {
59
61
  template.source = source;
60
62
  return template;
61
63
  }
64
+ tokenize(source, path) {
65
+ const result = tokenize(source);
66
+ let { tokens } = result;
67
+ const { position, error } = result;
68
+ if (error) {
69
+ throw this.createError(path || "unknown", source, position, error);
70
+ }
71
+ for (const tokenPreprocessor of this.tokenPreprocessors) {
72
+ const result = tokenPreprocessor(this, tokens, path);
73
+ if (result !== undefined) {
74
+ tokens = result;
75
+ }
76
+ }
77
+ return tokens;
78
+ }
62
79
  async load(file, from) {
63
80
  const path = from ? this.options.loader.resolve(from, file) : file;
64
81
  if (!this.cache.has(path)) {
65
- const { source, data } = await this.options.loader.load(path);
82
+ // Remove query and hash params from path before loading
83
+ const cleanPath = path
84
+ .split("?")[0]
85
+ .split("#")[0];
86
+ const { source, data } = await this.options.loader.load(cleanPath);
66
87
  const template = this.compile(source, path, data);
67
88
  this.cache.set(path, template);
68
89
  }
@@ -1,20 +1,13 @@
1
1
  export default function tokenize(source) {
2
2
  const tokens = [];
3
3
  let type = "string";
4
- let trimNext = false;
5
4
  let position = 0;
6
5
  try {
7
6
  while (source.length > 0) {
8
7
  if (type === "string") {
9
8
  const index = source.indexOf("{{");
10
9
  const code = index === -1 ? source : source.slice(0, index);
11
- if (trimNext) {
12
- tokens.push([type, code.trimStart(), position]);
13
- trimNext = false;
14
- }
15
- else {
16
- tokens.push([type, code, position]);
17
- }
10
+ tokens.push([type, code, position]);
18
11
  if (index === -1) {
19
12
  break;
20
13
  }
@@ -41,39 +34,23 @@ export default function tokenize(source) {
41
34
  const lastIndex = indexes.length - 1;
42
35
  let tag;
43
36
  indexes.reduce((prev, curr, index) => {
44
- let code = source.slice(prev, curr - 2);
37
+ const code = source.slice(prev, curr - 2);
45
38
  // Tag
46
39
  if (index === 1) {
47
- // Left trim
48
- if (code.startsWith("-")) {
49
- code = code.slice(1);
50
- const lastToken = tokens[tokens.length - 1];
51
- lastToken[1] = lastToken[1].trimEnd();
52
- }
53
- // Right trim
54
- if (code.endsWith("-") && index === lastIndex) {
55
- code = code.slice(0, -1);
56
- trimNext = true;
57
- }
58
- tag = [type, code.trim(), position];
40
+ tag = [type, code, position];
59
41
  tokens.push(tag);
60
42
  return curr;
61
43
  }
62
- // Right trim
63
- if (index === lastIndex && code.endsWith("-")) {
64
- code = code.slice(0, -1);
65
- trimNext = true;
66
- }
67
44
  // Filters
68
- tokens.push(["filter", code.trim()]);
45
+ tokens.push(["filter", code]);
69
46
  return curr;
70
47
  });
71
48
  position += indexes[lastIndex];
72
49
  source = source.slice(indexes[lastIndex]);
73
50
  type = "string";
74
51
  // Search the closing echo tag {{ /echo }}
75
- if (tag?.[1] === "echo") {
76
- const end = source.match(/{{\s*\/echo\s*}}/);
52
+ if (tag?.[1].match(/^\-?\s*echo\s*\-?$/)) {
53
+ const end = source.match(/{{\-?\s*\/echo\s*\-?}}/);
77
54
  if (!end) {
78
55
  throw new Error("Unclosed echo tag");
79
56
  }
@@ -0,0 +1 @@
1
+ export declare function transformTemplateCode(code: string, templateState: string): string;
@@ -0,0 +1,180 @@
1
+ import * as dntShim from "../_dnt.shims.js";
2
+ import { astring, meriyah, walker } from "../deps.js";
3
+ // List of identifiers that are in globalThis
4
+ // but should be accessed as templateState.identifier
5
+ const INCLUDE_GLOBAL = [
6
+ "name",
7
+ ];
8
+ // List of identifiers that should be ignored
9
+ // when transforming the code
10
+ const DEFAULT_EXCLUDES = [
11
+ "globalThis",
12
+ "self",
13
+ "global",
14
+ "this",
15
+ "undefined",
16
+ "null",
17
+ ];
18
+ // Tracks the scope of the code
19
+ // and the variables that should be ignored
20
+ class ScopeTracker {
21
+ scopes = [];
22
+ // The index of the global/function scope
23
+ globalScope = 0;
24
+ includes(val) {
25
+ for (let i = this.scopes.length - 1; i >= 0; i--) {
26
+ if (this.scopes[i].stack.includes(val)) {
27
+ return true;
28
+ }
29
+ }
30
+ return false;
31
+ }
32
+ pushScope(global) {
33
+ if (global) {
34
+ this.globalScope = this.scopes.length;
35
+ }
36
+ const newScope = {
37
+ globalScope: this.globalScope,
38
+ stack: [],
39
+ };
40
+ this.scopes.push(newScope);
41
+ }
42
+ popScope() {
43
+ this.globalScope = this.scopes[this.scopes.length - 1].globalScope;
44
+ this.scopes.pop();
45
+ }
46
+ pushBinding(val, global) {
47
+ if (this.scopes.length === 0) {
48
+ this.scopes.push({ globalScope: this.globalScope, stack: [] });
49
+ }
50
+ if (global) {
51
+ this.scopes[this.globalScope].stack.push(val);
52
+ }
53
+ else {
54
+ this.scopes[this.scopes.length - 1].stack.push(val);
55
+ }
56
+ }
57
+ pushPatternBinding(pattern, global) {
58
+ switch (pattern.type) {
59
+ case "Identifier":
60
+ this.pushBinding(pattern.name, global);
61
+ break;
62
+ case "RestElement":
63
+ this.pushPatternBinding(pattern.argument, global);
64
+ break;
65
+ case "ArrayPattern":
66
+ for (const element of pattern.elements) {
67
+ if (element) {
68
+ this.pushPatternBinding(element, global);
69
+ }
70
+ }
71
+ break;
72
+ case "ObjectPattern":
73
+ for (const prop of pattern.properties) {
74
+ if (prop.type === "RestElement") {
75
+ this.pushPatternBinding(prop.argument, global);
76
+ }
77
+ else {
78
+ this.pushPatternBinding(prop.value, global);
79
+ }
80
+ }
81
+ break;
82
+ case "AssignmentPattern":
83
+ this.pushPatternBinding(pattern.left, global);
84
+ break;
85
+ }
86
+ }
87
+ pushPatternBindings(patterns, global) {
88
+ for (const pattern of patterns) {
89
+ this.pushPatternBinding(pattern, global);
90
+ }
91
+ }
92
+ }
93
+ export function transformTemplateCode(code, templateState) {
94
+ const parsed = meriyah.parseScript(code, { module: true });
95
+ const tracker = new ScopeTracker();
96
+ const exclude = [
97
+ templateState,
98
+ ...DEFAULT_EXCLUDES,
99
+ ];
100
+ if (parsed.type !== "Program") {
101
+ throw new Error("Expected a program");
102
+ }
103
+ if (parsed.body.length === 0) {
104
+ throw new Error("Empty program");
105
+ }
106
+ // Transforms an identifier to a MemberExpression
107
+ // if it's not in the exclude list
108
+ //
109
+ // Example:
110
+ // Transforms {{ name }} to {{ id.name }}
111
+ function transformIdentifier(id) {
112
+ if ((!INCLUDE_GLOBAL.includes(id.name) &&
113
+ dntShim.dntGlobalThis[id.name] !== undefined) ||
114
+ exclude.includes(id.name) ||
115
+ tracker.includes(id.name) ||
116
+ id.name.startsWith("__")) {
117
+ return id;
118
+ }
119
+ return {
120
+ type: "MemberExpression",
121
+ object: {
122
+ type: "Identifier",
123
+ name: templateState,
124
+ },
125
+ optional: false,
126
+ computed: false,
127
+ property: id,
128
+ };
129
+ }
130
+ walker.walk(parsed, {
131
+ enter(node) {
132
+ switch (node.type) {
133
+ // Track variable declarations
134
+ case "VariableDeclaration":
135
+ // "var" declarations are scoped to the function/global scope.
136
+ tracker.pushPatternBindings(node.declarations.map((d) => d.id), node.kind === "var");
137
+ break;
138
+ // Track function declarations, and
139
+ // function parameters.
140
+ // Also track the scope.
141
+ case "FunctionDeclaration":
142
+ case "FunctionExpression":
143
+ if (node.id) {
144
+ tracker.pushBinding(node.id.name);
145
+ }
146
+ tracker.pushScope(true);
147
+ tracker.pushPatternBindings(node.params);
148
+ break;
149
+ case "ArrowFunctionExpression":
150
+ tracker.pushScope();
151
+ tracker.pushPatternBindings(node.params);
152
+ break;
153
+ }
154
+ },
155
+ leave(node, parent) {
156
+ switch (node.type) {
157
+ // Pop the scope when leaving a function
158
+ case "FunctionDeclaration":
159
+ case "FunctionExpression":
160
+ case "ArrowFunctionExpression":
161
+ tracker.popScope();
162
+ break;
163
+ case "Identifier":
164
+ // Don't transform identifiers that aren't at the start of a MemberExpression
165
+ // ie. don't transform `bar` or `baz` in `foo.bar.baz`
166
+ if (parent?.type === "MemberExpression" && parent.property === node) {
167
+ return;
168
+ }
169
+ // Don't transform identifiers that are keys in an object
170
+ if (parent?.type === "Property" && parent.key === node) {
171
+ return;
172
+ }
173
+ this.replace(transformIdentifier(node));
174
+ break;
175
+ }
176
+ },
177
+ });
178
+ const generated = astring.generate(parsed);
179
+ return generated;
180
+ }
package/package.json CHANGED
@@ -1,27 +1,40 @@
1
1
  {
2
2
  "module": "./esm/mod.js",
3
- "main": "./script/mod.js",
4
3
  "name": "ventojs",
5
- "version": "0.10.2",
4
+ "version": "0.12.0",
6
5
  "description": "🌬 A minimal but powerful template engine",
7
6
  "license": "MIT",
8
7
  "repository": "github:oscarotero/vento",
9
8
  "homepage": "https://vento.js.org/",
10
9
  "bugs": "https://github.com/oscarotero/vento/issues",
10
+ "devDependencies": {
11
+ "@types/node": "^18.11.9",
12
+ "picocolors": "^1.0.0",
13
+ "@types/estree": "1.0.5"
14
+ },
11
15
  "exports": {
12
16
  ".": {
13
- "import": "./esm/mod.js",
14
- "require": "./script/mod.js"
17
+ "import": "./esm/mod.js"
18
+ },
19
+ "./src/environment.js": {
20
+ "import": "./esm/src/environment.js"
21
+ },
22
+ "./src/loader.js": {
23
+ "import": "./esm/src/loader.js"
24
+ },
25
+ "./src/tokenizer.js": {
26
+ "import": "./esm/src/tokenizer.js"
27
+ },
28
+ "./plugins/auto_trim.js": {
29
+ "import": "./esm/plugins/auto_trim.js"
15
30
  }
16
31
  },
17
32
  "scripts": {
18
33
  "test": "node test_runner.js"
19
34
  },
20
35
  "dependencies": {
36
+ "estree-walker": "3.0.3",
37
+ "meriyah": "4.4.0",
21
38
  "@deno/shim-deno": "~0.16.1"
22
- },
23
- "devDependencies": {
24
- "@types/node": "^18.11.9",
25
- "picocolors": "^1.0.0"
26
39
  }
27
40
  }
@@ -1,38 +0,0 @@
1
- export type EntityList = Record<string, string>;
2
- /**
3
- * Escapes text for safe interpolation into HTML text content and quoted attributes
4
- *
5
- * @example
6
- * ```ts
7
- * import { escape } from "https://deno.land/std@$STD_VERSION/html/entities.ts";
8
- * import { assertEquals } from "https://deno.land/std@$STD_VERSION/assert/assert_equals.ts";
9
- *
10
- * assertEquals(escape("<>'&AA"), "&lt;&gt;&#39;&amp;AA");
11
- *
12
- * // characters that don't need to be escaped will be left alone,
13
- * // even if named HTML entities exist for them
14
- * assertEquals(escape("þð"), "þð");
15
- * ```
16
- */
17
- export declare function escape(str: string): string;
18
- export type UnescapeOptions = {
19
- entityList: EntityList;
20
- };
21
- /**
22
- * Unescapes HTML entities in text
23
- *
24
- * @example
25
- * ```ts
26
- * import { unescape } from "https://deno.land/std@$STD_VERSION/html/entities.ts";
27
- * import { assertEquals } from "https://deno.land/std@$STD_VERSION/assert/assert_equals.ts";
28
- *
29
- * // default options (only handles &<>'" and numeric entities)
30
- * assertEquals(unescape("&lt;&gt;&apos;&amp;&#65;&#x41;"), "<>'&AA");
31
- * assertEquals(unescape("&thorn;&eth;"), "&thorn;&eth;");
32
- *
33
- * // using the full named entity list from the HTML spec (~47K unminified)
34
- * import entityList from "https://deno.land/std@$STD_VERSION/html/named_entity_list.json" assert { type: "json" };
35
- * assertEquals(unescape("&thorn;&eth;", { entityList }), "þð");
36
- * ```
37
- */
38
- export declare function unescape(str: string, options?: Partial<UnescapeOptions>): string;
@@ -1 +0,0 @@
1
- export declare function assertPath(path: string): void;
@@ -1,3 +0,0 @@
1
- // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
- // This module is browser compatible.
3
- export {};
@@ -1,13 +0,0 @@
1
- /** Determines the common path from a set of paths, using an optional separator,
2
- * which defaults to the OS default separator.
3
- *
4
- * ```ts
5
- * import { common } from "https://deno.land/std@$STD_VERSION/path/mod.ts";
6
- * const p = common([
7
- * "./deno/std/path/mod.ts",
8
- * "./deno/std/fs/mod.ts",
9
- * ]);
10
- * console.log(p); // "./deno/std/"
11
- * ```
12
- */
13
- export declare function common(paths: string[], sep?: "/" | "\\"): string;
@@ -1,61 +0,0 @@
1
- import type { GlobOptions } from "./_common/glob_to_reg_exp.js";
2
- import { OSType } from "./_os.js";
3
- export type GlobToRegExpOptions = GlobOptions & {
4
- os?: OSType;
5
- };
6
- /** Convert a glob string to a regular expression.
7
- *
8
- * Tries to match bash glob expansion as closely as possible.
9
- *
10
- * Basic glob syntax:
11
- * - `*` - Matches everything without leaving the path segment.
12
- * - `?` - Matches any single character.
13
- * - `{foo,bar}` - Matches `foo` or `bar`.
14
- * - `[abcd]` - Matches `a`, `b`, `c` or `d`.
15
- * - `[a-d]` - Matches `a`, `b`, `c` or `d`.
16
- * - `[!abcd]` - Matches any single character besides `a`, `b`, `c` or `d`.
17
- * - `[[:<class>:]]` - Matches any character belonging to `<class>`.
18
- * - `[[:alnum:]]` - Matches any digit or letter.
19
- * - `[[:digit:]abc]` - Matches any digit, `a`, `b` or `c`.
20
- * - See https://facelessuser.github.io/wcmatch/glob/#posix-character-classes
21
- * for a complete list of supported character classes.
22
- * - `\` - Escapes the next character for an `os` other than `"windows"`.
23
- * - \` - Escapes the next character for `os` set to `"windows"`.
24
- * - `/` - Path separator.
25
- * - `\` - Additional path separator only for `os` set to `"windows"`.
26
- *
27
- * Extended syntax:
28
- * - Requires `{ extended: true }`.
29
- * - `?(foo|bar)` - Matches 0 or 1 instance of `{foo,bar}`.
30
- * - `@(foo|bar)` - Matches 1 instance of `{foo,bar}`. They behave the same.
31
- * - `*(foo|bar)` - Matches _n_ instances of `{foo,bar}`.
32
- * - `+(foo|bar)` - Matches _n > 0_ instances of `{foo,bar}`.
33
- * - `!(foo|bar)` - Matches anything other than `{foo,bar}`.
34
- * - See https://www.linuxjournal.com/content/bash-extended-globbing.
35
- *
36
- * Globstar syntax:
37
- * - Requires `{ globstar: true }`.
38
- * - `**` - Matches any number of any path segments.
39
- * - Must comprise its entire path segment in the provided glob.
40
- * - See https://www.linuxjournal.com/content/globstar-new-bash-globbing-option.
41
- *
42
- * Note the following properties:
43
- * - The generated `RegExp` is anchored at both start and end.
44
- * - Repeating and trailing separators are tolerated. Trailing separators in the
45
- * provided glob have no meaning and are discarded.
46
- * - Absolute globs will only match absolute paths, etc.
47
- * - Empty globs will match nothing.
48
- * - Any special glob syntax must be contained to one path segment. For example,
49
- * `?(foo|bar/baz)` is invalid. The separator will take precedence and the
50
- * first segment ends with an unclosed group.
51
- * - If a path segment ends with unclosed groups or a dangling escape prefix, a
52
- * parse error has occurred. Every character for that segment is taken
53
- * literally in this event.
54
- *
55
- * Limitations:
56
- * - A negative group like `!(foo|bar)` will wrongly be converted to a negative
57
- * look-ahead followed by a wildcard. This means that `!(foo).js` will wrongly
58
- * fail to match `foobar.js`, even though `foobar` is not `foo`. Effectively,
59
- * `!(foo|bar)` is treated like `!(@(foo|bar)*)`. This will work correctly if
60
- * the group occurs not nested at the end of the segment. */
61
- export declare function globToRegExp(glob: string, options?: GlobToRegExpOptions): RegExp;