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.
- package/README.md +35 -93
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/assert/assert.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/assert/assertion_error.js +1 -1
- package/esm/deps/deno.land/std@0.219.1/html/entities.d.ts +39 -0
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/html/entities.js +14 -15
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/html/mod.d.ts +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/html/mod.js +2 -2
- package/esm/deps/deno.land/std@0.219.1/path/_common/assert_path.d.ts +1 -0
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/assert_path.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/basename.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/common.js +9 -9
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/constants.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/dirname.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/format.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/from_file_url.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/glob_to_reg_exp.js +4 -2
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/normalize.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/normalize_string.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/relative.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/strip_trailing_separators.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/to_file_url.js +1 -1
- package/esm/deps/deno.land/std@0.219.1/path/_interface.js +3 -0
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_os.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/basename.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/common.js +3 -3
- package/esm/deps/deno.land/std@0.219.1/path/constants.d.ts +3 -0
- package/esm/deps/deno.land/std@0.219.1/path/constants.js +6 -0
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/dirname.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/extname.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/format.d.ts +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/format.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/from_file_url.js +1 -1
- 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
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/glob_to_regexp.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/is_absolute.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/is_glob.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/join.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/join_globs.d.ts +1 -0
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/join_globs.js +1 -1
- package/esm/deps/deno.land/std@0.219.1/path/mod.d.ts +56 -0
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/mod.js +3 -8
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/normalize.js +1 -1
- package/{script/deps/deno.land/std@0.210.0 → esm/deps/deno.land/std@0.219.1}/path/normalize_glob.d.ts +1 -0
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/normalize_glob.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/parse.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/_util.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/basename.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0/path/windows → std@0.219.1/path/posix}/common.js +3 -3
- package/esm/deps/deno.land/std@0.219.1/path/posix/constants.d.ts +3 -0
- package/esm/deps/deno.land/std@0.219.1/path/posix/constants.js +5 -0
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/dirname.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/extname.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/format.js +1 -1
- 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
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/from_file_url.js +2 -2
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/glob_to_regexp.d.ts +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/glob_to_regexp.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/is_absolute.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0/path/windows → std@0.219.1/path/posix}/is_glob.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/join.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0/path/windows → std@0.219.1/path/posix}/join_globs.d.ts +2 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/join_globs.js +3 -3
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/mod.d.ts +1 -3
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/mod.js +2 -4
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/normalize.js +1 -1
- 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
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/normalize_glob.js +3 -3
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/parse.d.ts +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/parse.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/relative.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/resolve.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/to_file_url.d.ts +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/to_file_url.js +2 -2
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/to_namespaced_path.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/relative.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/resolve.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/to_file_url.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/to_namespaced_path.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/_util.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/basename.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0/path/posix → std@0.219.1/path/windows}/common.js +3 -3
- package/esm/deps/deno.land/std@0.219.1/path/windows/constants.d.ts +3 -0
- package/esm/deps/deno.land/std@0.219.1/path/windows/constants.js +5 -0
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/dirname.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/extname.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/format.js +1 -1
- 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
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/from_file_url.js +2 -2
- 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
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/glob_to_regexp.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/is_absolute.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0/path/posix → std@0.219.1/path/windows}/is_glob.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/join.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0/path/posix → std@0.219.1/path/windows}/join_globs.d.ts +2 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/join_globs.js +3 -3
- 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
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/mod.js +2 -4
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/normalize.js +1 -1
- 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
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/normalize_glob.js +3 -3
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/parse.d.ts +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/parse.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/relative.js +1 -1
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/resolve.js +1 -1
- 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
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/to_file_url.js +2 -2
- package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/to_namespaced_path.js +1 -1
- package/esm/deps/deno.land/x/astring@v1.8.6/src/astring.d.ts +109 -0
- package/esm/deps/deno.land/x/astring@v1.8.6/src/astring.js +1159 -0
- package/esm/deps.d.ts +6 -2
- package/esm/deps.js +5 -2
- package/esm/mod.d.ts +1 -0
- package/esm/mod.js +2 -0
- package/esm/plugins/auto_trim.d.ts +8 -0
- package/esm/plugins/auto_trim.js +36 -0
- package/esm/plugins/escape.js +2 -1
- package/esm/plugins/trim.d.ts +4 -0
- package/esm/plugins/trim.js +28 -0
- package/esm/plugins/unescape.js +2 -1
- package/esm/src/environment.d.ts +3 -0
- package/esm/src/environment.js +28 -7
- package/esm/src/tokenizer.js +6 -29
- package/esm/src/transformer.d.ts +1 -0
- package/esm/src/transformer.js +180 -0
- package/package.json +21 -8
- package/esm/deps/deno.land/std@0.210.0/html/entities.d.ts +0 -38
- package/esm/deps/deno.land/std@0.210.0/path/_common/assert_path.d.ts +0 -1
- package/esm/deps/deno.land/std@0.210.0/path/_interface.js +0 -3
- package/esm/deps/deno.land/std@0.210.0/path/common.d.ts +0 -13
- package/esm/deps/deno.land/std@0.210.0/path/glob_to_regexp.d.ts +0 -61
- package/esm/deps/deno.land/std@0.210.0/path/mod.d.ts +0 -28
- package/esm/deps/deno.land/std@0.210.0/path/normalize_glob.d.ts +0 -3
- package/esm/deps/deno.land/std@0.210.0/path/posix/from_file_url.d.ts +0 -12
- package/esm/deps/deno.land/std@0.210.0/path/posix/normalize_glob.d.ts +0 -3
- package/esm/deps/deno.land/std@0.210.0/path/posix/separator.d.ts +0 -2
- package/esm/deps/deno.land/std@0.210.0/path/posix/separator.js +0 -4
- package/esm/deps/deno.land/std@0.210.0/path/separator.d.ts +0 -2
- package/esm/deps/deno.land/std@0.210.0/path/separator.js +0 -5
- package/esm/deps/deno.land/std@0.210.0/path/windows/from_file_url.d.ts +0 -14
- package/esm/deps/deno.land/std@0.210.0/path/windows/glob_to_regexp.d.ts +0 -57
- package/esm/deps/deno.land/std@0.210.0/path/windows/mod.d.ts +0 -40
- package/esm/deps/deno.land/std@0.210.0/path/windows/normalize_glob.d.ts +0 -3
- package/esm/deps/deno.land/std@0.210.0/path/windows/separator.d.ts +0 -2
- package/esm/deps/deno.land/std@0.210.0/path/windows/separator.js +0 -4
- package/esm/deps/deno.land/std@0.210.0/path/windows/to_file_url.d.ts +0 -14
- package/script/_dnt.shims.d.ts +0 -5
- package/script/_dnt.shims.js +0 -65
- package/script/deps/deno.land/std@0.210.0/assert/assert.d.ts +0 -12
- package/script/deps/deno.land/std@0.210.0/assert/assert.js +0 -22
- package/script/deps/deno.land/std@0.210.0/assert/assertion_error.d.ts +0 -14
- package/script/deps/deno.land/std@0.210.0/assert/assertion_error.js +0 -22
- package/script/deps/deno.land/std@0.210.0/html/entities.d.ts +0 -38
- package/script/deps/deno.land/std@0.210.0/html/entities.js +0 -81
- package/script/deps/deno.land/std@0.210.0/html/mod.d.ts +0 -6
- package/script/deps/deno.land/std@0.210.0/html/mod.js +0 -24
- package/script/deps/deno.land/std@0.210.0/path/_common/assert_path.d.ts +0 -1
- package/script/deps/deno.land/std@0.210.0/path/_common/assert_path.js +0 -11
- package/script/deps/deno.land/std@0.210.0/path/_common/basename.d.ts +0 -3
- package/script/deps/deno.land/std@0.210.0/path/_common/basename.js +0 -46
- package/script/deps/deno.land/std@0.210.0/path/_common/common.d.ts +0 -1
- package/script/deps/deno.land/std@0.210.0/path/_common/common.js +0 -27
- package/script/deps/deno.land/std@0.210.0/path/_common/constants.d.ts +0 -39
- package/script/deps/deno.land/std@0.210.0/path/_common/constants.js +0 -49
- package/script/deps/deno.land/std@0.210.0/path/_common/dirname.d.ts +0 -1
- package/script/deps/deno.land/std@0.210.0/path/_common/dirname.js +0 -12
- package/script/deps/deno.land/std@0.210.0/path/_common/format.d.ts +0 -3
- package/script/deps/deno.land/std@0.210.0/path/_common/format.js +0 -24
- package/script/deps/deno.land/std@0.210.0/path/_common/from_file_url.d.ts +0 -2
- package/script/deps/deno.land/std@0.210.0/path/_common/from_file_url.js +0 -13
- package/script/deps/deno.land/std@0.210.0/path/_common/glob_to_reg_exp.d.ts +0 -28
- package/script/deps/deno.land/std@0.210.0/path/_common/glob_to_reg_exp.js +0 -239
- package/script/deps/deno.land/std@0.210.0/path/_common/normalize.d.ts +0 -1
- package/script/deps/deno.land/std@0.210.0/path/_common/normalize.js +0 -12
- package/script/deps/deno.land/std@0.210.0/path/_common/normalize_string.d.ts +0 -1
- package/script/deps/deno.land/std@0.210.0/path/_common/normalize_string.js +0 -81
- package/script/deps/deno.land/std@0.210.0/path/_common/relative.d.ts +0 -1
- package/script/deps/deno.land/std@0.210.0/path/_common/relative.js +0 -13
- package/script/deps/deno.land/std@0.210.0/path/_common/strip_trailing_separators.d.ts +0 -1
- package/script/deps/deno.land/std@0.210.0/path/_common/strip_trailing_separators.js +0 -23
- package/script/deps/deno.land/std@0.210.0/path/_common/to_file_url.d.ts +0 -1
- package/script/deps/deno.land/std@0.210.0/path/_common/to_file_url.js +0 -19
- package/script/deps/deno.land/std@0.210.0/path/_interface.d.ts +0 -26
- package/script/deps/deno.land/std@0.210.0/path/_interface.js +0 -4
- package/script/deps/deno.land/std@0.210.0/path/_os.d.ts +0 -3
- package/script/deps/deno.land/std@0.210.0/path/_os.js +0 -44
- package/script/deps/deno.land/std@0.210.0/path/basename.d.ts +0 -8
- package/script/deps/deno.land/std@0.210.0/path/basename.js +0 -21
- package/script/deps/deno.land/std@0.210.0/path/common.d.ts +0 -13
- package/script/deps/deno.land/std@0.210.0/path/common.js +0 -23
- package/script/deps/deno.land/std@0.210.0/path/dirname.d.ts +0 -5
- package/script/deps/deno.land/std@0.210.0/path/dirname.js +0 -16
- package/script/deps/deno.land/std@0.210.0/path/extname.d.ts +0 -6
- package/script/deps/deno.land/std@0.210.0/path/extname.js +0 -17
- package/script/deps/deno.land/std@0.210.0/path/format.d.ts +0 -6
- package/script/deps/deno.land/std@0.210.0/path/format.js +0 -16
- package/script/deps/deno.land/std@0.210.0/path/from_file_url.d.ts +0 -18
- package/script/deps/deno.land/std@0.210.0/path/from_file_url.js +0 -28
- package/script/deps/deno.land/std@0.210.0/path/glob_to_regexp.js +0 -69
- package/script/deps/deno.land/std@0.210.0/path/is_absolute.d.ts +0 -5
- package/script/deps/deno.land/std@0.210.0/path/is_absolute.js +0 -16
- package/script/deps/deno.land/std@0.210.0/path/is_glob.d.ts +0 -2
- package/script/deps/deno.land/std@0.210.0/path/is_glob.js +0 -32
- package/script/deps/deno.land/std@0.210.0/path/join.d.ts +0 -5
- package/script/deps/deno.land/std@0.210.0/path/join.js +0 -16
- package/script/deps/deno.land/std@0.210.0/path/join_globs.d.ts +0 -3
- package/script/deps/deno.land/std@0.210.0/path/join_globs.js +0 -15
- package/script/deps/deno.land/std@0.210.0/path/mod.d.ts +0 -28
- package/script/deps/deno.land/std@0.210.0/path/mod.js +0 -94
- package/script/deps/deno.land/std@0.210.0/path/normalize.d.ts +0 -7
- package/script/deps/deno.land/std@0.210.0/path/normalize.js +0 -18
- package/script/deps/deno.land/std@0.210.0/path/normalize_glob.js +0 -15
- package/script/deps/deno.land/std@0.210.0/path/parse.d.ts +0 -6
- package/script/deps/deno.land/std@0.210.0/path/parse.js +0 -16
- package/script/deps/deno.land/std@0.210.0/path/posix/_util.d.ts +0 -1
- package/script/deps/deno.land/std@0.210.0/path/posix/_util.js +0 -12
- package/script/deps/deno.land/std@0.210.0/path/posix/basename.d.ts +0 -8
- package/script/deps/deno.land/std@0.210.0/path/posix/basename.js +0 -22
- package/script/deps/deno.land/std@0.210.0/path/posix/common.js +0 -23
- package/script/deps/deno.land/std@0.210.0/path/posix/dirname.d.ts +0 -5
- package/script/deps/deno.land/std@0.210.0/path/posix/dirname.js +0 -40
- package/script/deps/deno.land/std@0.210.0/path/posix/extname.d.ts +0 -6
- package/script/deps/deno.land/std@0.210.0/path/posix/extname.js +0 -63
- package/script/deps/deno.land/std@0.210.0/path/posix/format.d.ts +0 -6
- package/script/deps/deno.land/std@0.210.0/path/posix/format.js +0 -15
- package/script/deps/deno.land/std@0.210.0/path/posix/from_file_url.js +0 -21
- package/script/deps/deno.land/std@0.210.0/path/posix/glob_to_regexp.js +0 -73
- package/script/deps/deno.land/std@0.210.0/path/posix/is_absolute.d.ts +0 -5
- package/script/deps/deno.land/std@0.210.0/path/posix/is_absolute.js +0 -16
- package/script/deps/deno.land/std@0.210.0/path/posix/is_glob.d.ts +0 -1
- package/script/deps/deno.land/std@0.210.0/path/posix/is_glob.js +0 -7
- package/script/deps/deno.land/std@0.210.0/path/posix/join.d.ts +0 -5
- package/script/deps/deno.land/std@0.210.0/path/posix/join.js +0 -30
- package/script/deps/deno.land/std@0.210.0/path/posix/join_globs.d.ts +0 -3
- package/script/deps/deno.land/std@0.210.0/path/posix/join_globs.js +0 -30
- package/script/deps/deno.land/std@0.210.0/path/posix/mod.js +0 -61
- package/script/deps/deno.land/std@0.210.0/path/posix/normalize.d.ts +0 -7
- package/script/deps/deno.land/std@0.210.0/path/posix/normalize.js +0 -29
- package/script/deps/deno.land/std@0.210.0/path/posix/normalize_glob.js +0 -20
- package/script/deps/deno.land/std@0.210.0/path/posix/parse.d.ts +0 -6
- package/script/deps/deno.land/std@0.210.0/path/posix/parse.js +0 -102
- package/script/deps/deno.land/std@0.210.0/path/posix/relative.d.ts +0 -7
- package/script/deps/deno.land/std@0.210.0/path/posix/relative.js +0 -98
- package/script/deps/deno.land/std@0.210.0/path/posix/resolve.d.ts +0 -5
- package/script/deps/deno.land/std@0.210.0/path/posix/resolve.js +0 -75
- package/script/deps/deno.land/std@0.210.0/path/posix/separator.d.ts +0 -2
- package/script/deps/deno.land/std@0.210.0/path/posix/separator.js +0 -7
- package/script/deps/deno.land/std@0.210.0/path/posix/to_file_url.d.ts +0 -12
- package/script/deps/deno.land/std@0.210.0/path/posix/to_file_url.js +0 -26
- package/script/deps/deno.land/std@0.210.0/path/posix/to_namespaced_path.d.ts +0 -5
- package/script/deps/deno.land/std@0.210.0/path/posix/to_namespaced_path.js +0 -14
- package/script/deps/deno.land/std@0.210.0/path/relative.d.ts +0 -12
- package/script/deps/deno.land/std@0.210.0/path/relative.js +0 -23
- package/script/deps/deno.land/std@0.210.0/path/resolve.d.ts +0 -5
- package/script/deps/deno.land/std@0.210.0/path/resolve.js +0 -18
- package/script/deps/deno.land/std@0.210.0/path/separator.d.ts +0 -2
- package/script/deps/deno.land/std@0.210.0/path/separator.js +0 -8
- package/script/deps/deno.land/std@0.210.0/path/to_file_url.d.ts +0 -18
- package/script/deps/deno.land/std@0.210.0/path/to_file_url.js +0 -28
- package/script/deps/deno.land/std@0.210.0/path/to_namespaced_path.d.ts +0 -5
- package/script/deps/deno.land/std@0.210.0/path/to_namespaced_path.js +0 -18
- package/script/deps/deno.land/std@0.210.0/path/windows/_util.d.ts +0 -3
- package/script/deps/deno.land/std@0.210.0/path/windows/_util.js +0 -21
- package/script/deps/deno.land/std@0.210.0/path/windows/basename.d.ts +0 -8
- package/script/deps/deno.land/std@0.210.0/path/windows/basename.js +0 -34
- package/script/deps/deno.land/std@0.210.0/path/windows/common.d.ts +0 -13
- package/script/deps/deno.land/std@0.210.0/path/windows/common.js +0 -23
- package/script/deps/deno.land/std@0.210.0/path/windows/dirname.d.ts +0 -5
- package/script/deps/deno.land/std@0.210.0/path/windows/dirname.js +0 -102
- package/script/deps/deno.land/std@0.210.0/path/windows/extname.d.ts +0 -6
- package/script/deps/deno.land/std@0.210.0/path/windows/extname.js +0 -72
- package/script/deps/deno.land/std@0.210.0/path/windows/format.d.ts +0 -6
- package/script/deps/deno.land/std@0.210.0/path/windows/format.js +0 -15
- package/script/deps/deno.land/std@0.210.0/path/windows/from_file_url.js +0 -30
- package/script/deps/deno.land/std@0.210.0/path/windows/glob_to_regexp.d.ts +0 -57
- package/script/deps/deno.land/std@0.210.0/path/windows/glob_to_regexp.js +0 -73
- package/script/deps/deno.land/std@0.210.0/path/windows/is_absolute.d.ts +0 -5
- package/script/deps/deno.land/std@0.210.0/path/windows/is_absolute.js +0 -31
- package/script/deps/deno.land/std@0.210.0/path/windows/is_glob.d.ts +0 -1
- package/script/deps/deno.land/std@0.210.0/path/windows/is_glob.js +0 -7
- package/script/deps/deno.land/std@0.210.0/path/windows/join.d.ts +0 -5
- package/script/deps/deno.land/std@0.210.0/path/windows/join.js +0 -76
- package/script/deps/deno.land/std@0.210.0/path/windows/join_globs.d.ts +0 -3
- package/script/deps/deno.land/std@0.210.0/path/windows/join_globs.js +0 -30
- package/script/deps/deno.land/std@0.210.0/path/windows/mod.d.ts +0 -40
- package/script/deps/deno.land/std@0.210.0/path/windows/mod.js +0 -61
- package/script/deps/deno.land/std@0.210.0/path/windows/normalize.d.ts +0 -7
- package/script/deps/deno.land/std@0.210.0/path/windows/normalize.js +0 -134
- package/script/deps/deno.land/std@0.210.0/path/windows/normalize_glob.js +0 -20
- package/script/deps/deno.land/std@0.210.0/path/windows/parse.d.ts +0 -6
- package/script/deps/deno.land/std@0.210.0/path/windows/parse.js +0 -163
- package/script/deps/deno.land/std@0.210.0/path/windows/relative.d.ts +0 -12
- package/script/deps/deno.land/std@0.210.0/path/windows/relative.js +0 -125
- package/script/deps/deno.land/std@0.210.0/path/windows/resolve.d.ts +0 -5
- package/script/deps/deno.land/std@0.210.0/path/windows/resolve.js +0 -170
- package/script/deps/deno.land/std@0.210.0/path/windows/separator.d.ts +0 -2
- package/script/deps/deno.land/std@0.210.0/path/windows/separator.js +0 -7
- package/script/deps/deno.land/std@0.210.0/path/windows/to_file_url.js +0 -35
- package/script/deps/deno.land/std@0.210.0/path/windows/to_namespaced_path.d.ts +0 -5
- package/script/deps/deno.land/std@0.210.0/path/windows/to_namespaced_path.js +0 -42
- package/script/deps.d.ts +0 -2
- package/script/deps.js +0 -28
- package/script/mod.d.ts +0 -9
- package/script/mod.js +0 -69
- package/script/package.json +0 -3
- package/script/plugins/echo.d.ts +0 -2
- package/script/plugins/echo.js +0 -16
- package/script/plugins/escape.d.ts +0 -2
- package/script/plugins/escape.js +0 -9
- package/script/plugins/export.d.ts +0 -2
- package/script/plugins/export.js +0 -50
- package/script/plugins/for.d.ts +0 -2
- package/script/plugins/for.js +0 -77
- package/script/plugins/function.d.ts +0 -2
- package/script/plugins/function.js +0 -40
- package/script/plugins/if.d.ts +0 -2
- package/script/plugins/if.js +0 -35
- package/script/plugins/import.d.ts +0 -2
- package/script/plugins/import.js +0 -20
- package/script/plugins/include.d.ts +0 -2
- package/script/plugins/include.js +0 -26
- package/script/plugins/js.d.ts +0 -2
- package/script/plugins/js.js +0 -14
- package/script/plugins/layout.d.ts +0 -2
- package/script/plugins/layout.js +0 -37
- package/script/plugins/set.d.ts +0 -2
- package/script/plugins/set.js +0 -48
- package/script/plugins/unescape.d.ts +0 -2
- package/script/plugins/unescape.js +0 -9
- package/script/src/environment.d.ts +0 -51
- package/script/src/environment.js +0 -208
- package/script/src/loader.d.ts +0 -14
- package/script/src/loader.js +0 -46
- package/script/src/tokenizer.d.ts +0 -13
- package/script/src/tokenizer.js +0 -249
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/assert/assert.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/assert/assertion_error.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/basename.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/common.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/constants.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/dirname.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/format.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/from_file_url.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/glob_to_reg_exp.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/normalize.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/normalize_string.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/relative.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/strip_trailing_separators.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_common/to_file_url.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_interface.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/_os.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/basename.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0/path/posix → std@0.219.1/path}/common.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/dirname.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/extname.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/from_file_url.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/is_absolute.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/is_glob.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/join.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/normalize.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/parse.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/_util.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/basename.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0/path/windows → std@0.219.1/path/posix}/common.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/dirname.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/extname.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/format.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/is_absolute.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/is_glob.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/join.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/normalize.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/relative.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/resolve.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/posix/to_namespaced_path.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/relative.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/resolve.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/to_file_url.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/to_namespaced_path.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/_util.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/basename.d.ts +0 -0
- /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
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/dirname.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/extname.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/format.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/is_absolute.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/is_glob.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/join.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/normalize.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/relative.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.210.0 → std@0.219.1}/path/windows/resolve.d.ts +0 -0
- /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.
|
|
2
|
-
export * as html from "./deps/deno.land/std@0.
|
|
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.
|
|
2
|
-
export * as html from "./deps/deno.land/std@0.
|
|
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
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
|
+
}
|
package/esm/plugins/escape.js
CHANGED
|
@@ -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
|
+
}
|
package/esm/plugins/unescape.js
CHANGED
package/esm/src/environment.d.ts
CHANGED
|
@@ -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;
|
package/esm/src/environment.js
CHANGED
|
@@ -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
|
|
38
|
-
|
|
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
|
-
${
|
|
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
|
-
|
|
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
|
}
|
package/esm/src/tokenizer.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
37
|
+
const code = source.slice(prev, curr - 2);
|
|
45
38
|
// Tag
|
|
46
39
|
if (index === 1) {
|
|
47
|
-
|
|
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
|
|
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]
|
|
76
|
-
const end = source.match(/{{
|
|
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.
|
|
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
|
-
|
|
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"), "<>'&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("<>'&AA"), "<>'&AA");
|
|
31
|
-
* assertEquals(unescape("þð"), "þð");
|
|
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("þð", { 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,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;
|