ventojs 1.14.0 → 2.0.0-canary.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/CHANGELOG.md +24 -0
- package/README.md +2 -0
- package/browser.js +19 -0
- package/{esm/src → core}/environment.js +30 -32
- package/{esm/src → core}/errors.js +0 -7
- package/core/js.js +191 -0
- package/core/reserved.js +63 -0
- package/core/tokenizer.js +86 -0
- package/highlightjs-vento.js +24 -0
- package/{esm/src/loader.node.js → loaders/file.js} +5 -2
- package/loaders/memory.js +24 -0
- package/loaders/url.js +28 -0
- package/{esm/bare.js → mod.js} +7 -2
- package/package.json +167 -29
- package/{esm/plugins → plugins}/auto_trim.js +0 -1
- package/plugins/echo.js +31 -0
- package/plugins/escape.js +17 -0
- package/plugins/export.js +68 -0
- package/{esm/plugins → plugins}/for.js +6 -10
- package/plugins/import.js +58 -0
- package/plugins/include.js +35 -0
- package/plugins/mod.js +30 -0
- package/{esm/plugins → plugins}/set.js +4 -3
- package/plugins/unescape.js +25 -0
- package/prism-vento.js +26 -0
- package/types/browser.d.ts +8 -0
- package/{esm/src → types/core}/environment.d.ts +4 -6
- package/{esm/src → types/core}/errors.d.ts +0 -5
- package/types/core/js.d.ts +11 -0
- package/types/core/reserved.d.ts +2 -0
- package/{esm/src → types/core}/tokenizer.d.ts +1 -8
- package/{esm/src/loader.node.d.ts → types/loaders/file.d.ts} +5 -4
- package/types/loaders/memory.d.ts +11 -0
- package/types/loaders/url.d.ts +11 -0
- package/{esm/bare.d.ts → types/mod.d.ts} +1 -3
- package/{esm → types}/plugins/auto_trim.d.ts +2 -4
- package/types/plugins/echo.d.ts +2 -0
- package/types/plugins/escape.d.ts +2 -0
- package/types/plugins/export.d.ts +2 -0
- package/types/plugins/for.d.ts +2 -0
- package/types/plugins/function.d.ts +2 -0
- package/types/plugins/if.d.ts +2 -0
- package/types/plugins/import.d.ts +2 -0
- package/types/plugins/include.d.ts +2 -0
- package/types/plugins/js.d.ts +2 -0
- package/types/plugins/layout.d.ts +2 -0
- package/types/plugins/mod.d.ts +2 -0
- package/types/plugins/set.d.ts +2 -0
- package/types/plugins/trim.d.ts +4 -0
- package/types/plugins/unescape.d.ts +2 -0
- package/esm/_dnt.polyfills.d.ts +0 -12
- package/esm/_dnt.polyfills.d.ts.map +0 -1
- package/esm/_dnt.polyfills.js +0 -15
- package/esm/_dnt.shims.d.ts +0 -2
- package/esm/_dnt.shims.d.ts.map +0 -1
- package/esm/_dnt.shims.js +0 -57
- package/esm/_dnt.test_polyfills.d.ts.map +0 -1
- package/esm/_dnt.test_shims.d.ts.map +0 -1
- package/esm/bare.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/assert/_constants.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/assert/assert_equals.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/assert/assert_is_error.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/assert/assert_throws.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/assert/assertion_error.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/assert/equal.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/collections/_utils.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/collections/deep_merge.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/fmt/colors.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/front_matter/_formats.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/front_matter/create_extractor.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/front_matter/json.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/front_matter/mod.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/front_matter/test.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/front_matter/toml.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/front_matter/yaml.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/internal/diff.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/internal/format.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/internal/mod.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/toml/_parser.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/toml/parse.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/_error.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/_loader/loader.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/_loader/loader_state.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/_mark.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/_state.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/_type/binary.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/_type/bool.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/_type/float.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/_type/function.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/_type/int.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/_type/map.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/_type/merge.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/_type/mod.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/_type/nil.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/_type/omap.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/_type/pairs.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/_type/regexp.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/_type/seq.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/_type/set.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/_type/str.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/_type/timestamp.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/_type/undefined.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/_utils.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/parse.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/schema/core.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/schema/default.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/schema/extended.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/schema/failsafe.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/schema/json.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/schema/mod.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/schema.d.ts.map +0 -1
- package/esm/deps/deno.land/std@0.224.0/yaml/type.d.ts.map +0 -1
- package/esm/deps/jsr.io/@davidbonnet/astring/1.8.6/src/astring.d.ts +0 -110
- package/esm/deps/jsr.io/@davidbonnet/astring/1.8.6/src/astring.d.ts.map +0 -1
- package/esm/deps/jsr.io/@davidbonnet/astring/1.8.6/src/astring.js +0 -1159
- package/esm/deps/jsr.io/@std/html/1.0.3/entities.d.ts +0 -57
- package/esm/deps/jsr.io/@std/html/1.0.3/entities.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/html/1.0.3/entities.js +0 -92
- package/esm/deps/jsr.io/@std/html/1.0.3/mod.d.ts +0 -15
- package/esm/deps/jsr.io/@std/html/1.0.3/mod.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/html/1.0.3/mod.js +0 -16
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/assert_path.d.ts +0 -2
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/assert_path.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/assert_path.js +0 -7
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/basename.d.ts +0 -4
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/basename.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/basename.js +0 -40
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/common.d.ts +0 -2
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/common.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/common.js +0 -23
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/constants.d.ts +0 -40
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/constants.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/constants.js +0 -46
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/dirname.d.ts +0 -2
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/dirname.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/dirname.js +0 -8
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/format.d.ts +0 -4
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/format.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/format.js +0 -19
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/from_file_url.d.ts +0 -3
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/from_file_url.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/from_file_url.js +0 -9
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/glob_to_reg_exp.d.ts +0 -35
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/glob_to_reg_exp.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/glob_to_reg_exp.js +0 -234
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/normalize.d.ts +0 -2
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/normalize.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/normalize.js +0 -8
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/normalize_string.d.ts +0 -2
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/normalize_string.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/normalize_string.js +0 -77
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/relative.d.ts +0 -2
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/relative.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/relative.js +0 -9
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/strip_trailing_separators.d.ts +0 -2
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/strip_trailing_separators.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/strip_trailing_separators.js +0 -19
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/to_file_url.d.ts +0 -2
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/to_file_url.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/_common/to_file_url.js +0 -15
- package/esm/deps/jsr.io/@std/path/1.0.8/_os.d.ts +0 -2
- package/esm/deps/jsr.io/@std/path/1.0.8/_os.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/_os.js +0 -9
- package/esm/deps/jsr.io/@std/path/1.0.8/basename.d.ts +0 -28
- package/esm/deps/jsr.io/@std/path/1.0.8/basename.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/basename.js +0 -36
- package/esm/deps/jsr.io/@std/path/1.0.8/common.d.ts +0 -28
- package/esm/deps/jsr.io/@std/path/1.0.8/common.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/common.js +0 -33
- package/esm/deps/jsr.io/@std/path/1.0.8/constants.d.ts +0 -15
- package/esm/deps/jsr.io/@std/path/1.0.8/constants.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/constants.js +0 -17
- package/esm/deps/jsr.io/@std/path/1.0.8/dirname.d.ts +0 -23
- package/esm/deps/jsr.io/@std/path/1.0.8/dirname.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/dirname.js +0 -29
- package/esm/deps/jsr.io/@std/path/1.0.8/extname.d.ts +0 -23
- package/esm/deps/jsr.io/@std/path/1.0.8/extname.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/extname.js +0 -29
- package/esm/deps/jsr.io/@std/path/1.0.8/format.d.ts +0 -22
- package/esm/deps/jsr.io/@std/path/1.0.8/format.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/format.js +0 -27
- package/esm/deps/jsr.io/@std/path/1.0.8/from_file_url.d.ts +0 -23
- package/esm/deps/jsr.io/@std/path/1.0.8/from_file_url.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/from_file_url.js +0 -28
- package/esm/deps/jsr.io/@std/path/1.0.8/glob_to_regexp.d.ts +0 -77
- package/esm/deps/jsr.io/@std/path/1.0.8/glob_to_regexp.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/glob_to_regexp.js +0 -83
- package/esm/deps/jsr.io/@std/path/1.0.8/is_absolute.d.ts +0 -22
- package/esm/deps/jsr.io/@std/path/1.0.8/is_absolute.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/is_absolute.js +0 -28
- package/esm/deps/jsr.io/@std/path/1.0.8/is_glob.d.ts +0 -17
- package/esm/deps/jsr.io/@std/path/1.0.8/is_glob.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/is_glob.js +0 -42
- package/esm/deps/jsr.io/@std/path/1.0.8/join.d.ts +0 -23
- package/esm/deps/jsr.io/@std/path/1.0.8/join.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/join.js +0 -29
- package/esm/deps/jsr.io/@std/path/1.0.8/join_globs.d.ts +0 -28
- package/esm/deps/jsr.io/@std/path/1.0.8/join_globs.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/join_globs.js +0 -34
- package/esm/deps/jsr.io/@std/path/1.0.8/mod.d.ts +0 -54
- package/esm/deps/jsr.io/@std/path/1.0.8/mod.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/mod.js +0 -57
- package/esm/deps/jsr.io/@std/path/1.0.8/normalize.d.ts +0 -27
- package/esm/deps/jsr.io/@std/path/1.0.8/normalize.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/normalize.js +0 -33
- package/esm/deps/jsr.io/@std/path/1.0.8/normalize_glob.d.ts +0 -29
- package/esm/deps/jsr.io/@std/path/1.0.8/normalize_glob.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/normalize_glob.js +0 -35
- package/esm/deps/jsr.io/@std/path/1.0.8/parse.d.ts +0 -35
- package/esm/deps/jsr.io/@std/path/1.0.8/parse.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/parse.js +0 -39
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/_util.d.ts +0 -2
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/_util.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/_util.js +0 -8
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/basename.d.ts +0 -40
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/basename.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/basename.js +0 -49
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/common.d.ts +0 -19
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/common.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/common.js +0 -24
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/constants.d.ts +0 -13
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/constants.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/constants.js +0 -14
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/dirname.d.ts +0 -32
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/dirname.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/dirname.js +0 -62
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/extname.d.ts +0 -37
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/extname.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/extname.js +0 -89
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/format.d.ts +0 -24
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/format.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/format.js +0 -28
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/from_file_url.d.ts +0 -17
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/from_file_url.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/from_file_url.js +0 -21
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/glob_to_regexp.d.ts +0 -72
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/glob_to_regexp.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/glob_to_regexp.js +0 -82
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/is_absolute.d.ts +0 -17
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/is_absolute.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/is_absolute.js +0 -23
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/is_glob.d.ts +0 -2
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/is_glob.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/is_glob.js +0 -3
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/join.d.ts +0 -33
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/join.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/join.js +0 -42
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/join_globs.d.ts +0 -20
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/join_globs.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/join_globs.js +0 -40
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/mod.d.ts +0 -40
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/mod.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/mod.js +0 -43
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/normalize.d.ts +0 -40
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/normalize.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/normalize.js +0 -57
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/normalize_glob.d.ts +0 -20
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/normalize_glob.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/normalize_glob.js +0 -32
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/parse.d.ts +0 -25
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/parse.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/parse.js +0 -115
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/relative.d.ts +0 -20
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/relative.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/relative.js +0 -106
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/resolve.d.ts +0 -17
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/resolve.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/resolve.js +0 -59
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/to_file_url.d.ts +0 -18
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/to_file_url.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/to_file_url.js +0 -27
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/to_namespaced_path.d.ts +0 -16
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/to_namespaced_path.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/posix/to_namespaced_path.js +0 -20
- package/esm/deps/jsr.io/@std/path/1.0.8/relative.d.ts +0 -24
- package/esm/deps/jsr.io/@std/path/1.0.8/relative.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/relative.js +0 -30
- package/esm/deps/jsr.io/@std/path/1.0.8/resolve.d.ts +0 -22
- package/esm/deps/jsr.io/@std/path/1.0.8/resolve.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/resolve.js +0 -30
- package/esm/deps/jsr.io/@std/path/1.0.8/to_file_url.d.ts +0 -23
- package/esm/deps/jsr.io/@std/path/1.0.8/to_file_url.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/to_file_url.js +0 -28
- package/esm/deps/jsr.io/@std/path/1.0.8/to_namespaced_path.d.ts +0 -21
- package/esm/deps/jsr.io/@std/path/1.0.8/to_namespaced_path.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/to_namespaced_path.js +0 -29
- package/esm/deps/jsr.io/@std/path/1.0.8/types.d.ts +0 -38
- package/esm/deps/jsr.io/@std/path/1.0.8/types.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/types.js +0 -3
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/_util.d.ts +0 -4
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/_util.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/_util.js +0 -15
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/basename.d.ts +0 -23
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/basename.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/basename.js +0 -44
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/constants.d.ts +0 -13
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/constants.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/constants.js +0 -14
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/dirname.d.ts +0 -20
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/dirname.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/dirname.js +0 -112
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/extname.d.ts +0 -20
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/extname.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/extname.js +0 -81
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/format.d.ts +0 -24
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/format.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/format.js +0 -28
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/from_file_url.d.ts +0 -19
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/from_file_url.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/from_file_url.js +0 -30
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/glob_to_regexp.d.ts +0 -71
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/glob_to_regexp.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/glob_to_regexp.js +0 -82
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/is_absolute.d.ts +0 -17
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/is_absolute.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/is_absolute.js +0 -38
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/join.d.ts +0 -20
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/join.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/join.js +0 -74
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/join_globs.d.ts +0 -21
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/join_globs.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/join_globs.js +0 -41
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/normalize.d.ts +0 -22
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/normalize.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/normalize.js +0 -134
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/normalize_glob.d.ts +0 -20
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/normalize_glob.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/normalize_glob.js +0 -32
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/parse.d.ts +0 -25
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/parse.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/parse.js +0 -176
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/relative.d.ts +0 -23
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/relative.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/relative.js +0 -131
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/resolve.d.ts +0 -17
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/resolve.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/resolve.js +0 -154
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/to_file_url.d.ts +0 -18
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/to_file_url.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/to_file_url.js +0 -34
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/to_namespaced_path.d.ts +0 -17
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/to_namespaced_path.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/path/1.0.8/windows/to_namespaced_path.js +0 -49
- package/esm/deps.d.ts +0 -8
- package/esm/deps.d.ts.map +0 -1
- package/esm/deps.js +0 -6
- package/esm/mod.d.ts +0 -9
- package/esm/mod.d.ts.map +0 -1
- package/esm/mod.js +0 -36
- package/esm/package.json +0 -3
- package/esm/plugins/auto_trim.d.ts.map +0 -1
- package/esm/plugins/echo.d.ts +0 -3
- package/esm/plugins/echo.d.ts.map +0 -1
- package/esm/plugins/echo.js +0 -13
- package/esm/plugins/escape.d.ts +0 -3
- package/esm/plugins/escape.d.ts.map +0 -1
- package/esm/plugins/escape.js +0 -7
- package/esm/plugins/export.d.ts +0 -3
- package/esm/plugins/export.d.ts.map +0 -1
- package/esm/plugins/export.js +0 -47
- package/esm/plugins/for.d.ts +0 -3
- package/esm/plugins/for.d.ts.map +0 -1
- package/esm/plugins/function.d.ts +0 -3
- package/esm/plugins/function.d.ts.map +0 -1
- package/esm/plugins/if.d.ts +0 -3
- package/esm/plugins/if.d.ts.map +0 -1
- package/esm/plugins/import.d.ts +0 -3
- package/esm/plugins/import.d.ts.map +0 -1
- package/esm/plugins/import.js +0 -17
- package/esm/plugins/include.d.ts +0 -3
- package/esm/plugins/include.d.ts.map +0 -1
- package/esm/plugins/include.js +0 -31
- package/esm/plugins/js.d.ts +0 -3
- package/esm/plugins/js.d.ts.map +0 -1
- package/esm/plugins/layout.d.ts +0 -3
- package/esm/plugins/layout.d.ts.map +0 -1
- package/esm/plugins/set.d.ts +0 -3
- package/esm/plugins/set.d.ts.map +0 -1
- package/esm/plugins/trim.d.ts +0 -5
- package/esm/plugins/trim.d.ts.map +0 -1
- package/esm/plugins/unescape.d.ts +0 -3
- package/esm/plugins/unescape.d.ts.map +0 -1
- package/esm/plugins/unescape.js +0 -7
- package/esm/src/environment.d.ts.map +0 -1
- package/esm/src/errors.d.ts.map +0 -1
- package/esm/src/js.d.ts +0 -5
- package/esm/src/js.d.ts.map +0 -1
- package/esm/src/js.js +0 -197
- package/esm/src/loader.node.d.ts.map +0 -1
- package/esm/src/tokenizer.d.ts.map +0 -1
- package/esm/src/tokenizer.js +0 -93
- package/esm/src/transformer.d.ts +0 -2
- package/esm/src/transformer.d.ts.map +0 -1
- package/esm/src/transformer.js +0 -218
- package/esm/test/auto_trim.test.d.ts.map +0 -1
- package/esm/test/comment.test.d.ts.map +0 -1
- package/esm/test/compile.test.d.ts.map +0 -1
- package/esm/test/echo.test.d.ts.map +0 -1
- package/esm/test/escape.test.d.ts.map +0 -1
- package/esm/test/for.test.d.ts.map +0 -1
- package/esm/test/function.test.d.ts.map +0 -1
- package/esm/test/if.test.d.ts.map +0 -1
- package/esm/test/import.test.d.ts.map +0 -1
- package/esm/test/include.test.d.ts.map +0 -1
- package/esm/test/js.test.d.ts.map +0 -1
- package/esm/test/layout.test.d.ts.map +0 -1
- package/esm/test/print.test.d.ts.map +0 -1
- package/esm/test/safe.test.d.ts.map +0 -1
- package/esm/test/set.test.d.ts.map +0 -1
- package/esm/test/tokenizer.test.d.ts.map +0 -1
- package/esm/test/unescape.test.d.ts.map +0 -1
- package/esm/test/utils.d.ts.map +0 -1
- package/esm/test/with.test.d.ts.map +0 -1
- /package/{esm/plugins → plugins}/function.js +0 -0
- /package/{esm/plugins → plugins}/if.js +0 -0
- /package/{esm/plugins → plugins}/js.js +0 -0
- /package/{esm/plugins → plugins}/layout.js +0 -0
- /package/{esm/plugins → plugins}/trim.js +0 -0
package/package.json
CHANGED
@@ -1,41 +1,179 @@
|
|
1
1
|
{
|
2
2
|
"name": "ventojs",
|
3
|
-
"version": "
|
3
|
+
"version": "2.0.0-canary.0",
|
4
4
|
"description": "🌬 A minimal but powerful template engine",
|
5
|
-
"
|
6
|
-
"repository":
|
5
|
+
"type": "module",
|
6
|
+
"repository": {
|
7
|
+
"type": "git",
|
8
|
+
"url": "git+https://github.com/ventojs/vento.git"
|
9
|
+
},
|
10
|
+
"keywords": [
|
11
|
+
"template engine"
|
12
|
+
],
|
13
|
+
"author": "Óscar Otero",
|
7
14
|
"license": "MIT",
|
8
|
-
"bugs":
|
9
|
-
|
15
|
+
"bugs": {
|
16
|
+
"url": "https://github.com/ventojs/vento/issues"
|
17
|
+
},
|
18
|
+
"homepage": "https://vento.js.org/",
|
10
19
|
"exports": {
|
11
20
|
".": {
|
12
|
-
"import":
|
21
|
+
"import": {
|
22
|
+
"types": "./types/mod.d.ts",
|
23
|
+
"default": "./mod.js"
|
24
|
+
}
|
25
|
+
},
|
26
|
+
"./browser.js": {
|
27
|
+
"import": {
|
28
|
+
"types": "./types/browser.d.ts",
|
29
|
+
"default": "./browser.js"
|
30
|
+
}
|
31
|
+
},
|
32
|
+
"./core/environment.js": {
|
33
|
+
"import": {
|
34
|
+
"types": "./types/core/environment.d.ts",
|
35
|
+
"default": "./core/environment.js"
|
36
|
+
}
|
37
|
+
},
|
38
|
+
"./core/errors.js": {
|
39
|
+
"import": {
|
40
|
+
"types": "./types/core/errors.d.ts",
|
41
|
+
"default": "./core/errors.js"
|
42
|
+
}
|
43
|
+
},
|
44
|
+
"./core/js.js": {
|
45
|
+
"import": {
|
46
|
+
"types": "./types/core/js.d.ts",
|
47
|
+
"default": "./core/js.js"
|
48
|
+
}
|
13
49
|
},
|
14
|
-
"./
|
15
|
-
"import":
|
50
|
+
"./core/reserved.js": {
|
51
|
+
"import": {
|
52
|
+
"types": "./types/core/reserved.d.ts",
|
53
|
+
"default": "./core/reserved.js"
|
54
|
+
}
|
16
55
|
},
|
17
|
-
"./
|
18
|
-
"import":
|
56
|
+
"./core/tokenizer.js": {
|
57
|
+
"import": {
|
58
|
+
"types": "./types/core/tokenizer.d.ts",
|
59
|
+
"default": "./core/tokenizer.js"
|
60
|
+
}
|
19
61
|
},
|
20
|
-
"./
|
21
|
-
|
62
|
+
"./highlightjs-vento.js": "./highlightjs-vento.js",
|
63
|
+
"./loaders/file.js": {
|
64
|
+
"import": {
|
65
|
+
"types": "./types/loaders/file.d.ts",
|
66
|
+
"default": "./loaders/file.js"
|
67
|
+
}
|
68
|
+
},
|
69
|
+
"./loaders/memory.js": {
|
70
|
+
"import": {
|
71
|
+
"types": "./types/loaders/memory.d.ts",
|
72
|
+
"default": "./loaders/memory.js"
|
73
|
+
}
|
74
|
+
},
|
75
|
+
"./loaders/url.js": {
|
76
|
+
"import": {
|
77
|
+
"types": "./types/loaders/url.d.ts",
|
78
|
+
"default": "./loaders/url.js"
|
79
|
+
}
|
80
|
+
},
|
81
|
+
"./mod.js": {
|
82
|
+
"import": {
|
83
|
+
"types": "./types/mod.d.ts",
|
84
|
+
"default": "./mod.js"
|
85
|
+
}
|
22
86
|
},
|
23
87
|
"./plugins/auto_trim.js": {
|
24
|
-
"import":
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
"
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
88
|
+
"import": {
|
89
|
+
"types": "./types/plugins/auto_trim.d.ts",
|
90
|
+
"default": "./plugins/auto_trim.js"
|
91
|
+
}
|
92
|
+
},
|
93
|
+
"./plugins/echo.js": {
|
94
|
+
"import": {
|
95
|
+
"types": "./types/plugins/echo.d.ts",
|
96
|
+
"default": "./plugins/echo.js"
|
97
|
+
}
|
98
|
+
},
|
99
|
+
"./plugins/escape.js": {
|
100
|
+
"import": {
|
101
|
+
"types": "./types/plugins/escape.d.ts",
|
102
|
+
"default": "./plugins/escape.js"
|
103
|
+
}
|
104
|
+
},
|
105
|
+
"./plugins/export.js": {
|
106
|
+
"import": {
|
107
|
+
"types": "./types/plugins/export.d.ts",
|
108
|
+
"default": "./plugins/export.js"
|
109
|
+
}
|
110
|
+
},
|
111
|
+
"./plugins/for.js": {
|
112
|
+
"import": {
|
113
|
+
"types": "./types/plugins/for.d.ts",
|
114
|
+
"default": "./plugins/for.js"
|
115
|
+
}
|
116
|
+
},
|
117
|
+
"./plugins/function.js": {
|
118
|
+
"import": {
|
119
|
+
"types": "./types/plugins/function.d.ts",
|
120
|
+
"default": "./plugins/function.js"
|
121
|
+
}
|
122
|
+
},
|
123
|
+
"./plugins/if.js": {
|
124
|
+
"import": {
|
125
|
+
"types": "./types/plugins/if.d.ts",
|
126
|
+
"default": "./plugins/if.js"
|
127
|
+
}
|
128
|
+
},
|
129
|
+
"./plugins/import.js": {
|
130
|
+
"import": {
|
131
|
+
"types": "./types/plugins/import.d.ts",
|
132
|
+
"default": "./plugins/import.js"
|
133
|
+
}
|
134
|
+
},
|
135
|
+
"./plugins/include.js": {
|
136
|
+
"import": {
|
137
|
+
"types": "./types/plugins/include.d.ts",
|
138
|
+
"default": "./plugins/include.js"
|
139
|
+
}
|
140
|
+
},
|
141
|
+
"./plugins/js.js": {
|
142
|
+
"import": {
|
143
|
+
"types": "./types/plugins/js.d.ts",
|
144
|
+
"default": "./plugins/js.js"
|
145
|
+
}
|
146
|
+
},
|
147
|
+
"./plugins/layout.js": {
|
148
|
+
"import": {
|
149
|
+
"types": "./types/plugins/layout.d.ts",
|
150
|
+
"default": "./plugins/layout.js"
|
151
|
+
}
|
152
|
+
},
|
153
|
+
"./plugins/mod.js": {
|
154
|
+
"import": {
|
155
|
+
"types": "./types/plugins/mod.d.ts",
|
156
|
+
"default": "./plugins/mod.js"
|
157
|
+
}
|
158
|
+
},
|
159
|
+
"./plugins/set.js": {
|
160
|
+
"import": {
|
161
|
+
"types": "./types/plugins/set.d.ts",
|
162
|
+
"default": "./plugins/set.js"
|
163
|
+
}
|
164
|
+
},
|
165
|
+
"./plugins/trim.js": {
|
166
|
+
"import": {
|
167
|
+
"types": "./types/plugins/trim.d.ts",
|
168
|
+
"default": "./plugins/trim.js"
|
169
|
+
}
|
170
|
+
},
|
171
|
+
"./plugins/unescape.js": {
|
172
|
+
"import": {
|
173
|
+
"types": "./types/plugins/unescape.d.ts",
|
174
|
+
"default": "./plugins/unescape.js"
|
175
|
+
}
|
176
|
+
},
|
177
|
+
"./prism-vento.js": "./prism-vento.js"
|
178
|
+
}
|
41
179
|
}
|
package/plugins/echo.js
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
export default function () {
|
2
|
+
return (env) => {
|
3
|
+
env.tags.push(echoTag);
|
4
|
+
};
|
5
|
+
}
|
6
|
+
function echoTag(env, code, output, tokens) {
|
7
|
+
if (!/^echo\b/.test(code)) {
|
8
|
+
return;
|
9
|
+
}
|
10
|
+
const inline = code.slice(4).trim();
|
11
|
+
// Inline value, e.g. {{ echo "foo" |> toUpperCase() }}
|
12
|
+
if (inline) {
|
13
|
+
const compiled = env.compileFilters(tokens, inline, env.options.autoescape);
|
14
|
+
return `${output} += ${compiled};`;
|
15
|
+
}
|
16
|
+
// Captured echo, e.g. {{ echo |> toUpperCase }} foo {{ /echo }}
|
17
|
+
const compiled = [`let __tmp = "";`];
|
18
|
+
const filters = env.compileFilters(tokens, "__tmp");
|
19
|
+
compiled.push(...env.compileTokens(tokens, "__tmp", ["/echo"]));
|
20
|
+
if (filters != "__tmp") {
|
21
|
+
compiled.push(`__tmp = ${filters}`);
|
22
|
+
}
|
23
|
+
const closeToken = tokens.shift();
|
24
|
+
if (!closeToken || closeToken[0] != "tag" || closeToken[1] != "/echo") {
|
25
|
+
throw new Error("Unclosed echo tag");
|
26
|
+
}
|
27
|
+
return `{
|
28
|
+
${compiled.join("\n")}
|
29
|
+
${output} += __tmp;
|
30
|
+
}`;
|
31
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
const UNSAFE = /['"&<>]/g;
|
2
|
+
const escapeMap = {
|
3
|
+
"'": "'",
|
4
|
+
'"': """,
|
5
|
+
"&": "&",
|
6
|
+
"<": "<",
|
7
|
+
">": ">",
|
8
|
+
};
|
9
|
+
export default function () {
|
10
|
+
return (env) => {
|
11
|
+
env.filters.escape = (value) => {
|
12
|
+
if (!value)
|
13
|
+
return "";
|
14
|
+
return value.toString().replace(UNSAFE, (match) => escapeMap[match]);
|
15
|
+
};
|
16
|
+
};
|
17
|
+
}
|
@@ -0,0 +1,68 @@
|
|
1
|
+
export default function () {
|
2
|
+
return (env) => {
|
3
|
+
env.tags.push(exportTag);
|
4
|
+
};
|
5
|
+
}
|
6
|
+
const EXPORT_START = /^export\b\s*/;
|
7
|
+
const BLOCK_EXPORT = /^([a-zA-Z_]\w*)\s*$/;
|
8
|
+
const INLINE_NAMED_EXPORT = /^([a-zA-Z_]\w*)\s*=([^]*)$/;
|
9
|
+
const NAMED_EXPORTS = /^{[^]*?}$/;
|
10
|
+
const AS = /\s+\bas\b\s+/;
|
11
|
+
function exportTag(env, code, _output, tokens) {
|
12
|
+
const exportStart = code.match(EXPORT_START);
|
13
|
+
if (!exportStart) {
|
14
|
+
return;
|
15
|
+
}
|
16
|
+
const source = code.slice(exportStart[0].length);
|
17
|
+
const compiled = [];
|
18
|
+
const { dataVarname } = env.options;
|
19
|
+
// {{ export foo }}content{{ /export }}
|
20
|
+
const blockExport = source.match(BLOCK_EXPORT);
|
21
|
+
if (blockExport) {
|
22
|
+
const [, name] = blockExport;
|
23
|
+
const compiledFilters = env.compileFilters(tokens, name);
|
24
|
+
compiled.push(`var ${name} = "";`);
|
25
|
+
compiled.push(...env.compileTokens(tokens, name, ["/export"]));
|
26
|
+
if (tokens[0]?.[0] !== "tag" || tokens[0]?.[1] !== "/export") {
|
27
|
+
throw new Error(`Missing closing tag for export tag: ${code}`);
|
28
|
+
}
|
29
|
+
tokens.shift();
|
30
|
+
compiled.push(`${name} = ${compiledFilters}`);
|
31
|
+
compiled.push(`${dataVarname}["${name}"] = ${name};`);
|
32
|
+
compiled.push(`__exports["${name}"] = ${name};`);
|
33
|
+
return compiled.join("\n");
|
34
|
+
}
|
35
|
+
// {{ export foo = "content" }}
|
36
|
+
const inlineNamedExport = source.match(INLINE_NAMED_EXPORT);
|
37
|
+
if (inlineNamedExport) {
|
38
|
+
const [, name, content] = inlineNamedExport;
|
39
|
+
compiled.push(`var ${name} = "";`);
|
40
|
+
compiled.push(`${name} = ${env.compileFilters(tokens, content)};`);
|
41
|
+
compiled.push(`${dataVarname}["${name}"] = ${name};`);
|
42
|
+
compiled.push(`__exports["${name}"] = ${name};`);
|
43
|
+
return compiled.join("\n");
|
44
|
+
}
|
45
|
+
// {{ export { foo, bar as baz } }}
|
46
|
+
const namedExports = source.match(NAMED_EXPORTS);
|
47
|
+
if (namedExports) {
|
48
|
+
const [full] = namedExports;
|
49
|
+
const chunks = full.slice(1, -1).split(",");
|
50
|
+
for (const chunk of chunks) {
|
51
|
+
const names = chunk.trim().split(AS);
|
52
|
+
if (names.length == 1) {
|
53
|
+
const [name] = names;
|
54
|
+
const value = `${dataVarname}["${name}"] ?? ${name}`;
|
55
|
+
compiled.push(`__exports["${name}"] = ${value};`);
|
56
|
+
}
|
57
|
+
else if (names.length == 2) {
|
58
|
+
const [name, rename] = names;
|
59
|
+
const value = `${dataVarname}["${name}"] ?? ${name}`;
|
60
|
+
compiled.push(`__exports["${rename}"] = ${value};`);
|
61
|
+
}
|
62
|
+
else {
|
63
|
+
throw new Error(`Invalid export: ${code}`);
|
64
|
+
}
|
65
|
+
}
|
66
|
+
return compiled.join("\n");
|
67
|
+
}
|
68
|
+
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import
|
1
|
+
import iterateTopLevel from "../core/js.js";
|
2
2
|
export default function () {
|
3
3
|
return (env) => {
|
4
4
|
env.tags.push(forTag);
|
@@ -109,15 +109,11 @@ async function* asyncIterableToEntries(iterator) {
|
|
109
109
|
}
|
110
110
|
}
|
111
111
|
function getDestructureContent(code) {
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
index = i;
|
116
|
-
return false;
|
117
|
-
}
|
118
|
-
});
|
112
|
+
const generator = iterateTopLevel(code);
|
113
|
+
generator.next();
|
114
|
+
const [position] = generator.next().value;
|
119
115
|
return [
|
120
|
-
code.slice(0,
|
121
|
-
code.slice(
|
116
|
+
code.slice(0, position + 1).trim(),
|
117
|
+
code.slice(position + 1).trim(),
|
122
118
|
];
|
123
119
|
}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
export default function () {
|
2
|
+
return (env) => {
|
3
|
+
env.tags.push(importTag);
|
4
|
+
};
|
5
|
+
}
|
6
|
+
const IMPORT_STATEMENT = /^import\b\s*([^]*?)\s*\bfrom\b([^]*)$/;
|
7
|
+
const DEFAULT_IMPORT = /^\b[a-zA-Z_]\w*\b$/i;
|
8
|
+
const NAMED_IMPORTS = /^{[^]*?}$/;
|
9
|
+
const AS = /\s+\bas\b\s+/;
|
10
|
+
function importTag(env, code) {
|
11
|
+
if (!code.startsWith("import ")) {
|
12
|
+
return;
|
13
|
+
}
|
14
|
+
const match = code.match(IMPORT_STATEMENT);
|
15
|
+
if (!match) {
|
16
|
+
throw new Error(`Invalid import: ${code}`);
|
17
|
+
}
|
18
|
+
const compiled = [];
|
19
|
+
const variables = [];
|
20
|
+
const [, identifiers, specifier] = match;
|
21
|
+
const defaultImport = identifiers.match(DEFAULT_IMPORT);
|
22
|
+
if (defaultImport) {
|
23
|
+
const [name] = defaultImport;
|
24
|
+
variables.push(name);
|
25
|
+
compiled.push(`${name} = __tmp;`);
|
26
|
+
}
|
27
|
+
else {
|
28
|
+
const namedImports = identifiers.match(NAMED_IMPORTS);
|
29
|
+
if (namedImports) {
|
30
|
+
const [full] = namedImports;
|
31
|
+
const chunks = full.slice(1, -1).split(",").map((chunk) => {
|
32
|
+
const names = chunk.trim().split(AS);
|
33
|
+
if (names.length == 1) {
|
34
|
+
const [name] = names;
|
35
|
+
variables.push(name);
|
36
|
+
return name;
|
37
|
+
}
|
38
|
+
else if (names.length == 2) {
|
39
|
+
const [name, rename] = names;
|
40
|
+
variables.push(rename);
|
41
|
+
return `${name}: ${rename}`;
|
42
|
+
}
|
43
|
+
else {
|
44
|
+
throw new Error(`Invalid import: ${code}`);
|
45
|
+
}
|
46
|
+
});
|
47
|
+
compiled.push(`({${chunks.join(",")}} = __tmp);`);
|
48
|
+
}
|
49
|
+
else {
|
50
|
+
throw new Error(`Invalid import: ${code}`);
|
51
|
+
}
|
52
|
+
}
|
53
|
+
const { dataVarname } = env.options;
|
54
|
+
return `let ${variables.join(",")}; {
|
55
|
+
let __tmp = await __env.run(${specifier}, {...${dataVarname}}, __file);
|
56
|
+
${compiled.join("\n")}
|
57
|
+
}`;
|
58
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import iterateTopLevel from "../core/js.js";
|
2
|
+
export default function () {
|
3
|
+
return (env) => {
|
4
|
+
env.tags.push(includeTag);
|
5
|
+
};
|
6
|
+
}
|
7
|
+
function includeTag(env, code, output, tokens) {
|
8
|
+
if (!code.startsWith("include ")) {
|
9
|
+
return;
|
10
|
+
}
|
11
|
+
const tagCode = code.substring(7).trim();
|
12
|
+
let file = tagCode;
|
13
|
+
let data = "";
|
14
|
+
// includes { data }
|
15
|
+
if (tagCode.endsWith("}")) {
|
16
|
+
let bracketIndex = -1;
|
17
|
+
for (const [index, reason] of iterateTopLevel(tagCode)) {
|
18
|
+
if (reason == "{")
|
19
|
+
bracketIndex = index;
|
20
|
+
}
|
21
|
+
if (bracketIndex == -1) {
|
22
|
+
throw Error(`Invalid include tag: ${tagCode}`);
|
23
|
+
}
|
24
|
+
file = tagCode.slice(0, bracketIndex).trim();
|
25
|
+
data = tagCode.slice(bracketIndex).trim();
|
26
|
+
}
|
27
|
+
const { dataVarname } = env.options;
|
28
|
+
return `{
|
29
|
+
const __tmp = await __env.run(${file},
|
30
|
+
{...${dataVarname}${data ? `, ...${data}` : ""}},
|
31
|
+
__file
|
32
|
+
);
|
33
|
+
${output} += ${env.compileFilters(tokens, "__tmp.content")};
|
34
|
+
}`;
|
35
|
+
}
|
package/plugins/mod.js
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
import ifTag from "./if.js";
|
2
|
+
import forTag from "./for.js";
|
3
|
+
import includeTag from "./include.js";
|
4
|
+
import setTag from "./set.js";
|
5
|
+
import jsTag from "./js.js";
|
6
|
+
import layoutTag from "./layout.js";
|
7
|
+
import functionTag from "./function.js";
|
8
|
+
import importTag from "./import.js";
|
9
|
+
import exportTag from "./export.js";
|
10
|
+
import echoTag from "./echo.js";
|
11
|
+
import escape from "./escape.js";
|
12
|
+
import unescape from "./unescape.js";
|
13
|
+
import trim from "./trim.js";
|
14
|
+
export default function () {
|
15
|
+
return (env) => {
|
16
|
+
env.use(ifTag());
|
17
|
+
env.use(forTag());
|
18
|
+
env.use(jsTag());
|
19
|
+
env.use(includeTag());
|
20
|
+
env.use(setTag());
|
21
|
+
env.use(layoutTag());
|
22
|
+
env.use(functionTag());
|
23
|
+
env.use(importTag());
|
24
|
+
env.use(exportTag());
|
25
|
+
env.use(echoTag());
|
26
|
+
env.use(escape());
|
27
|
+
env.use(unescape());
|
28
|
+
env.use(trim());
|
29
|
+
};
|
30
|
+
}
|
@@ -17,11 +17,12 @@ function setTag(env, code, _output, tokens) {
|
|
17
17
|
}
|
18
18
|
const [, variable, value] = match;
|
19
19
|
const val = env.compileFilters(tokens, value);
|
20
|
-
return
|
20
|
+
return `var ${variable} = ${dataVarname}["${variable}"] = ${val};`;
|
21
21
|
}
|
22
22
|
// Value is captured (eg: {{ set foo }}bar{{ /set }})
|
23
23
|
const compiled = [];
|
24
|
-
const
|
24
|
+
const varName = expression.trim();
|
25
|
+
const subvarName = `${dataVarname}["${varName}"]`;
|
25
26
|
const compiledFilters = env.compileFilters(tokens, subvarName);
|
26
27
|
compiled.push(`${subvarName} = "";`);
|
27
28
|
compiled.push(...env.compileTokens(tokens, subvarName, ["/set"]));
|
@@ -29,6 +30,6 @@ function setTag(env, code, _output, tokens) {
|
|
29
30
|
throw new Error(`Missing closing tag for set tag: ${code}`);
|
30
31
|
}
|
31
32
|
tokens.shift();
|
32
|
-
compiled.push(
|
33
|
+
compiled.push(`var ${varName} = ${subvarName} = ${compiledFilters};`);
|
33
34
|
return compiled.join("\n");
|
34
35
|
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
const NAMED_ENTITIES = /&(apos|quot|amp|lt|gt);/g;
|
2
|
+
const CHAR_REF = /&#(x[0-9A-F]{1,6}|[0-9]{1,7});/gi;
|
3
|
+
const entities = {
|
4
|
+
apos: "'",
|
5
|
+
quot: '"',
|
6
|
+
amp: "&",
|
7
|
+
lt: "<",
|
8
|
+
gt: ">",
|
9
|
+
};
|
10
|
+
export default function () {
|
11
|
+
return (env) => {
|
12
|
+
env.filters.unescape = (value) => {
|
13
|
+
if (!value)
|
14
|
+
return "";
|
15
|
+
return value.toString().replace(NAMED_ENTITIES, (_, name) => {
|
16
|
+
return entities[name];
|
17
|
+
}).replace(CHAR_REF, (full, number) => {
|
18
|
+
const parsed = Number(`0${number}`);
|
19
|
+
if (parsed > 0x10FFFF)
|
20
|
+
return full;
|
21
|
+
return String.fromCodePoint(parsed);
|
22
|
+
});
|
23
|
+
};
|
24
|
+
};
|
25
|
+
}
|
package/prism-vento.js
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Prism.languages.vento = {
|
2
|
+
"delimiter": {
|
3
|
+
pattern: /\{{2}[->]?|-?\}{2}/,
|
4
|
+
alias: "punctuation",
|
5
|
+
lookbehind: true,
|
6
|
+
},
|
7
|
+
"comment": /^#[\s\S]*#$/,
|
8
|
+
"javascript": {
|
9
|
+
pattern: /\s*\S[\s\S]*/,
|
10
|
+
alias: "language-javascript",
|
11
|
+
inside: Prism.languages.javascript,
|
12
|
+
},
|
13
|
+
};
|
14
|
+
|
15
|
+
Prism.hooks.add("before-tokenize", function (env) {
|
16
|
+
const ventoPattern = /\{{2}[\s\S]+\}{2}/g;
|
17
|
+
Prism.languages["markup-templating"].buildPlaceholders(
|
18
|
+
env,
|
19
|
+
"vento",
|
20
|
+
ventoPattern,
|
21
|
+
);
|
22
|
+
});
|
23
|
+
|
24
|
+
Prism.hooks.add("after-tokenize", function (env) {
|
25
|
+
Prism.languages["markup-templating"].tokenizePlaceholders(env, "vento");
|
26
|
+
});
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import "
|
2
|
-
import { Token } from "./tokenizer.js";
|
1
|
+
import { Token } from "./tokenizer.d.ts";
|
3
2
|
export interface TemplateResult {
|
4
3
|
content: string;
|
5
4
|
[key: string]: unknown;
|
@@ -29,7 +28,7 @@ export interface TemplateSource {
|
|
29
28
|
data?: Record<string, unknown>;
|
30
29
|
}
|
31
30
|
export interface Loader {
|
32
|
-
load(file: string):
|
31
|
+
load(file: string): Promise<TemplateSource>;
|
33
32
|
resolve(from: string, file: string): string;
|
34
33
|
}
|
35
34
|
export interface Options {
|
@@ -39,7 +38,7 @@ export interface Options {
|
|
39
38
|
autoDataVarname: boolean;
|
40
39
|
}
|
41
40
|
export declare class Environment {
|
42
|
-
cache: Map<string, Template
|
41
|
+
cache: Map<string, Template | Promise<Template>>;
|
43
42
|
options: Options;
|
44
43
|
tags: Tag[];
|
45
44
|
tokenPreprocessors: TokenPreprocessor[];
|
@@ -47,7 +46,7 @@ export declare class Environment {
|
|
47
46
|
utils: Record<string, unknown>;
|
48
47
|
constructor(options: Options);
|
49
48
|
use(plugin: Plugin): void;
|
50
|
-
run(file: string, data
|
49
|
+
run(file: string, data?: Record<string, unknown>, from?: string): Promise<TemplateResult>;
|
51
50
|
runString(source: string, data?: Record<string, unknown>, file?: string): Promise<TemplateResult>;
|
52
51
|
runStringSync(source: string, data?: Record<string, unknown>): TemplateResult;
|
53
52
|
compile(source: string, path?: string, defaults?: Record<string, unknown>, sync?: false): Template;
|
@@ -57,4 +56,3 @@ export declare class Environment {
|
|
57
56
|
compileTokens(tokens: Token[], outputVar?: string, stopAt?: string[]): string[];
|
58
57
|
compileFilters(tokens: Token[], output: string, autoescape?: boolean): string;
|
59
58
|
}
|
60
|
-
//# sourceMappingURL=environment.d.ts.map
|
@@ -7,10 +7,6 @@ export declare class TemplateError extends VentoBaseError {
|
|
7
7
|
position: number;
|
8
8
|
constructor(path?: string, source?: string, position?: number, cause?: Error);
|
9
9
|
}
|
10
|
-
export declare class TransformError extends VentoBaseError {
|
11
|
-
position: number;
|
12
|
-
constructor(message: string, position?: number, cause?: Error);
|
13
|
-
}
|
14
10
|
/** Returns the number and code of the errored line */
|
15
11
|
export declare function errorLine(source: string, position: number): {
|
16
12
|
line: number;
|
@@ -18,4 +14,3 @@ export declare function errorLine(source: string, position: number): {
|
|
18
14
|
code: string;
|
19
15
|
};
|
20
16
|
export {};
|
21
|
-
//# sourceMappingURL=errors.d.ts.map
|
@@ -0,0 +1,11 @@
|
|
1
|
+
/**
|
2
|
+
* This function iterates over the top-level scope of a JavaScript source code
|
3
|
+
* string. It yields pairs of the index and the type of each top-level element
|
4
|
+
* found.
|
5
|
+
*
|
6
|
+
* @example `{ foo: { bar: 1 } }` will yield:
|
7
|
+
* - [0, "{", Set[]] for the first opening brace
|
8
|
+
* - [18, "}", Set['foo', 'bar']] for the _second_ closing brace
|
9
|
+
* - [18, "", Set['foo', 'bar']] for the end of the string
|
10
|
+
*/
|
11
|
+
export default function iterateTopLevel(source: string, start?: number): Generator<[number, string, Set<string>]>;
|
@@ -1,15 +1,8 @@
|
|
1
|
-
import "../_dnt.polyfills.js";
|
2
1
|
export type TokenType = "string" | "tag" | "filter" | "comment";
|
3
2
|
export type Token = [TokenType, string, number?];
|
4
|
-
export
|
5
|
-
tokens: Token[];
|
6
|
-
position: number;
|
7
|
-
error: Error | undefined;
|
8
|
-
}
|
9
|
-
export default function tokenize(source: string): TokenizeResult;
|
3
|
+
export default function tokenize(source: string): Token[];
|
10
4
|
/**
|
11
5
|
* Parse a tag and return the indexes of the start and end brackets, and the filters between.
|
12
6
|
* For example: {{ tag |> filter1 |> filter2 }} => [2, 9, 20, 31]
|
13
7
|
*/
|
14
8
|
export declare function parseTag(source: string): number[];
|
15
|
-
//# sourceMappingURL=tokenizer.d.ts.map
|