ventojs 0.6.0 → 0.7.2
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 +23 -7
- package/esm/_dnt.shims.js +0 -1
- package/esm/deps/deno.land/std@0.201.0/assert/assert.d.ts +2 -0
- package/esm/deps/deno.land/std@0.201.0/assert/assert.js +8 -0
- package/esm/deps/deno.land/std@0.201.0/assert/assertion_error.d.ts +4 -0
- package/esm/deps/deno.land/std@0.201.0/assert/assertion_error.js +7 -0
- package/esm/deps/deno.land/std@0.201.0/path/_basename.d.ts +16 -0
- package/esm/deps/deno.land/std@0.201.0/path/_basename.js +78 -0
- package/esm/deps/deno.land/std@0.201.0/path/_dirname.d.ts +10 -0
- package/esm/deps/deno.land/std@0.201.0/path/_dirname.js +132 -0
- package/esm/deps/deno.land/std@0.201.0/path/_extname.d.ts +12 -0
- package/esm/deps/deno.land/std@0.201.0/path/_extname.js +121 -0
- package/esm/deps/deno.land/std@0.201.0/path/_format.d.ts +11 -0
- package/esm/deps/deno.land/std@0.201.0/path/_format.js +35 -0
- package/esm/deps/deno.land/std@0.201.0/path/_from_file_url.d.ts +25 -0
- package/esm/deps/deno.land/std@0.201.0/path/_from_file_url.js +46 -0
- package/esm/deps/deno.land/std@0.201.0/path/_is_absolute.d.ts +10 -0
- package/esm/deps/deno.land/std@0.201.0/path/_is_absolute.js +34 -0
- package/esm/deps/deno.land/std@0.201.0/path/_join.d.ts +10 -0
- package/esm/deps/deno.land/std@0.201.0/path/_join.js +93 -0
- package/esm/deps/deno.land/std@0.201.0/path/_normalize.d.ts +14 -0
- package/esm/deps/deno.land/std@0.201.0/path/_normalize.js +153 -0
- package/esm/deps/deno.land/std@0.201.0/path/_parse.d.ts +11 -0
- package/esm/deps/deno.land/std@0.201.0/path/_parse.js +250 -0
- package/esm/deps/deno.land/std@0.201.0/path/_relative.d.ts +19 -0
- package/esm/deps/deno.land/std@0.201.0/path/_relative.js +216 -0
- package/esm/deps/deno.land/std@0.201.0/path/_resolve.d.ts +10 -0
- package/esm/deps/deno.land/std@0.201.0/path/_resolve.js +183 -0
- package/esm/deps/deno.land/std@0.201.0/path/_to_file_url.d.ts +25 -0
- package/esm/deps/deno.land/std@0.201.0/path/_to_file_url.js +61 -0
- package/esm/deps/deno.land/std@0.201.0/path/_to_namespaced_path.d.ts +10 -0
- package/esm/deps/deno.land/std@0.201.0/path/_to_namespaced_path.js +46 -0
- package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/_util.d.ts +0 -5
- package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/_util.js +0 -54
- package/esm/deps/deno.land/std@0.201.0/path/basename.d.ts +8 -0
- package/esm/deps/deno.land/std@0.201.0/path/basename.js +16 -0
- package/esm/deps/deno.land/std@0.201.0/path/dirname.d.ts +5 -0
- package/esm/deps/deno.land/std@0.201.0/path/dirname.js +11 -0
- package/esm/deps/deno.land/std@0.201.0/path/extname.d.ts +6 -0
- package/esm/deps/deno.land/std@0.201.0/path/extname.js +12 -0
- package/esm/deps/deno.land/std@0.201.0/path/format.d.ts +6 -0
- package/esm/deps/deno.land/std@0.201.0/path/format.js +11 -0
- package/esm/deps/deno.land/std@0.201.0/path/from_file_url.d.ts +18 -0
- package/esm/deps/deno.land/std@0.201.0/path/from_file_url.js +23 -0
- package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/glob.d.ts +1 -1
- package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/glob.js +50 -50
- package/esm/deps/deno.land/std@0.201.0/path/is_absolute.d.ts +5 -0
- package/esm/deps/deno.land/std@0.201.0/path/is_absolute.js +11 -0
- package/esm/deps/deno.land/std@0.201.0/path/join.d.ts +5 -0
- package/esm/deps/deno.land/std@0.201.0/path/join.js +11 -0
- package/esm/deps/deno.land/std@0.201.0/path/mod.d.ts +22 -0
- package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/mod.js +17 -4
- package/esm/deps/deno.land/std@0.201.0/path/normalize.d.ts +7 -0
- package/esm/deps/deno.land/std@0.201.0/path/normalize.js +13 -0
- package/esm/deps/deno.land/std@0.201.0/path/parse.d.ts +6 -0
- package/esm/deps/deno.land/std@0.201.0/path/parse.js +11 -0
- package/esm/deps/deno.land/std@0.201.0/path/posix.d.ts +15 -0
- package/esm/deps/deno.land/std@0.201.0/path/posix.js +19 -0
- package/esm/deps/deno.land/std@0.201.0/path/relative.d.ts +12 -0
- package/esm/deps/deno.land/std@0.201.0/path/relative.js +18 -0
- package/esm/deps/deno.land/std@0.201.0/path/resolve.d.ts +5 -0
- package/esm/deps/deno.land/std@0.201.0/path/resolve.js +13 -0
- package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/separator.js +1 -1
- package/esm/deps/deno.land/std@0.201.0/path/to_file_url.d.ts +18 -0
- package/esm/deps/deno.land/std@0.201.0/path/to_file_url.js +23 -0
- package/esm/deps/deno.land/std@0.201.0/path/to_namespaced_path.d.ts +5 -0
- package/esm/deps/deno.land/std@0.201.0/path/to_namespaced_path.js +13 -0
- package/esm/deps/deno.land/std@0.201.0/path/win32.d.ts +15 -0
- package/esm/deps/deno.land/std@0.201.0/path/win32.js +19 -0
- package/esm/deps.d.ts +1 -1
- package/esm/deps.js +1 -1
- package/esm/mod.js +6 -0
- package/esm/plugins/export.d.ts +2 -0
- package/esm/plugins/export.js +46 -0
- package/esm/plugins/function.d.ts +2 -0
- package/esm/plugins/function.js +37 -0
- package/esm/plugins/import.d.ts +2 -0
- package/esm/plugins/import.js +24 -0
- package/esm/plugins/include.js +7 -1
- package/esm/plugins/layout.js +5 -1
- package/esm/src/environment.d.ts +15 -4
- package/esm/src/environment.js +13 -6
- package/package.json +2 -2
- package/esm/_dnt.test_polyfills.d.ts +0 -11
- package/esm/_dnt.test_shims.d.ts +0 -5
- package/esm/deps/deno.land/std@0.178.0/_util/asserts.d.ts +0 -10
- package/esm/deps/deno.land/std@0.178.0/_util/asserts.js +0 -21
- package/esm/deps/deno.land/std@0.178.0/path/mod.d.ts +0 -9
- package/esm/deps/deno.land/std@0.178.0/path/posix.d.ts +0 -86
- package/esm/deps/deno.land/std@0.178.0/path/posix.js +0 -442
- package/esm/deps/deno.land/std@0.178.0/path/win32.d.ts +0 -91
- package/esm/deps/deno.land/std@0.178.0/path/win32.js +0 -909
- package/esm/deps/deno.land/std@0.190.0/_util/asserts.d.ts +0 -10
- package/esm/deps/deno.land/std@0.190.0/bytes/copy.d.ts +0 -27
- package/esm/deps/deno.land/std@0.190.0/fmt/colors.d.ts +0 -270
- package/esm/deps/deno.land/std@0.190.0/front_matter/mod.d.ts +0 -78
- package/esm/deps/deno.land/std@0.190.0/front_matter/yaml.d.ts +0 -4
- package/esm/deps/deno.land/std@0.190.0/io/buffer.d.ts +0 -81
- package/esm/deps/deno.land/std@0.190.0/testing/_diff.d.ts +0 -26
- package/esm/deps/deno.land/std@0.190.0/testing/_format.d.ts +0 -1
- package/esm/deps/deno.land/std@0.190.0/testing/asserts.d.ts +0 -284
- package/esm/deps/deno.land/std@0.190.0/yaml/_error.d.ts +0 -6
- package/esm/deps/deno.land/std@0.190.0/yaml/_loader/loader.d.ts +0 -4
- package/esm/deps/deno.land/std@0.190.0/yaml/_loader/loader_state.d.ts +0 -43
- package/esm/deps/deno.land/std@0.190.0/yaml/_mark.d.ts +0 -10
- package/esm/deps/deno.land/std@0.190.0/yaml/_state.d.ts +0 -5
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/binary.d.ts +0 -2
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/bool.d.ts +0 -2
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/float.d.ts +0 -2
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/function.d.ts +0 -2
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/int.d.ts +0 -2
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/map.d.ts +0 -2
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/merge.d.ts +0 -2
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/mod.d.ts +0 -16
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/nil.d.ts +0 -2
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/omap.d.ts +0 -2
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/pairs.d.ts +0 -2
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/regexp.d.ts +0 -2
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/seq.d.ts +0 -2
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/set.d.ts +0 -2
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/str.d.ts +0 -2
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/timestamp.d.ts +0 -2
- package/esm/deps/deno.land/std@0.190.0/yaml/_type/undefined.d.ts +0 -2
- package/esm/deps/deno.land/std@0.190.0/yaml/_utils.d.ts +0 -19
- package/esm/deps/deno.land/std@0.190.0/yaml/parse.d.ts +0 -35
- package/esm/deps/deno.land/std@0.190.0/yaml/schema/core.d.ts +0 -2
- package/esm/deps/deno.land/std@0.190.0/yaml/schema/default.d.ts +0 -2
- package/esm/deps/deno.land/std@0.190.0/yaml/schema/extended.d.ts +0 -30
- package/esm/deps/deno.land/std@0.190.0/yaml/schema/failsafe.d.ts +0 -2
- package/esm/deps/deno.land/std@0.190.0/yaml/schema/json.d.ts +0 -2
- package/esm/deps/deno.land/std@0.190.0/yaml/schema/mod.d.ts +0 -5
- package/esm/deps/deno.land/std@0.190.0/yaml/schema.d.ts +0 -22
- package/esm/deps/deno.land/std@0.190.0/yaml/type.d.ts +0 -28
- package/esm/test/comment.test.d.ts +0 -1
- package/esm/test/escape.test.d.ts +0 -1
- package/esm/test/for.test.d.ts +0 -1
- package/esm/test/if.test.d.ts +0 -1
- package/esm/test/include.test.d.ts +0 -1
- package/esm/test/js.test.d.ts +0 -1
- package/esm/test/layout.test.d.ts +0 -1
- package/esm/test/print.test.d.ts +0 -1
- package/esm/test/raw.test.d.ts +0 -1
- package/esm/test/set.test.d.ts +0 -1
- package/esm/test/tokenizer.test.d.ts +0 -1
- package/esm/test/utils.d.ts +0 -23
- /package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/_constants.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/_constants.js +0 -0
- /package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/_interface.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/_interface.js +0 -0
- /package/esm/deps/deno.land/{std@0.178.0/_util/os.d.ts → std@0.201.0/path/_os.d.ts} +0 -0
- /package/esm/deps/deno.land/{std@0.178.0/_util/os.js → std@0.201.0/path/_os.js} +0 -0
- /package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/common.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/common.js +0 -0
- /package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/separator.d.ts +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const sep = "\\";
|
|
2
|
+
export declare const delimiter = ";";
|
|
3
|
+
export { windowsResolve as resolve } from "./_resolve.js";
|
|
4
|
+
export { windowsNormalize as normalize } from "./_normalize.js";
|
|
5
|
+
export { windowsIsAbsolute as isAbsolute } from "./_is_absolute.js";
|
|
6
|
+
export { windowsJoin as join } from "./_join.js";
|
|
7
|
+
export { windowsRelative as relative } from "./_relative.js";
|
|
8
|
+
export { windowsToNamespacedPath as toNamespacedPath } from "./_to_namespaced_path.js";
|
|
9
|
+
export { windowsDirname as dirname } from "./_dirname.js";
|
|
10
|
+
export { windowsBasename as basename } from "./_basename.js";
|
|
11
|
+
export { windowsExtname as extname } from "./_extname.js";
|
|
12
|
+
export { windowsFormat as format } from "./_format.js";
|
|
13
|
+
export { windowsParse as parse } from "./_parse.js";
|
|
14
|
+
export { windowsFromFileUrl as fromFileUrl } from "./_from_file_url.js";
|
|
15
|
+
export { windowsToFileUrl as toFileUrl } from "./_to_file_url.js";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
2
|
+
// Copyright the Browserify authors. MIT License.
|
|
3
|
+
// Ported from https://github.com/browserify/path-browserify/
|
|
4
|
+
// This module is browser compatible.
|
|
5
|
+
export const sep = "\\";
|
|
6
|
+
export const delimiter = ";";
|
|
7
|
+
export { windowsResolve as resolve } from "./_resolve.js";
|
|
8
|
+
export { windowsNormalize as normalize } from "./_normalize.js";
|
|
9
|
+
export { windowsIsAbsolute as isAbsolute } from "./_is_absolute.js";
|
|
10
|
+
export { windowsJoin as join } from "./_join.js";
|
|
11
|
+
export { windowsRelative as relative } from "./_relative.js";
|
|
12
|
+
export { windowsToNamespacedPath as toNamespacedPath } from "./_to_namespaced_path.js";
|
|
13
|
+
export { windowsDirname as dirname } from "./_dirname.js";
|
|
14
|
+
export { windowsBasename as basename } from "./_basename.js";
|
|
15
|
+
export { windowsExtname as extname } from "./_extname.js";
|
|
16
|
+
export { windowsFormat as format } from "./_format.js";
|
|
17
|
+
export { windowsParse as parse } from "./_parse.js";
|
|
18
|
+
export { windowsFromFileUrl as fromFileUrl } from "./_from_file_url.js";
|
|
19
|
+
export { windowsToFileUrl as toFileUrl } from "./_to_file_url.js";
|
package/esm/deps.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * as path from "./deps/deno.land/std@0.
|
|
1
|
+
export * as path from "./deps/deno.land/std@0.201.0/path/mod.js";
|
package/esm/deps.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * as path from "./deps/deno.land/std@0.
|
|
1
|
+
export * as path from "./deps/deno.land/std@0.201.0/path/mod.js";
|
package/esm/mod.js
CHANGED
|
@@ -7,6 +7,9 @@ import includeTag from "./plugins/include.js";
|
|
|
7
7
|
import setTag from "./plugins/set.js";
|
|
8
8
|
import jsTag from "./plugins/js.js";
|
|
9
9
|
import layoutTag from "./plugins/layout.js";
|
|
10
|
+
import functionTag from "./plugins/function.js";
|
|
11
|
+
import importTag from "./plugins/import.js";
|
|
12
|
+
import exportTag from "./plugins/export.js";
|
|
10
13
|
import escape from "./plugins/escape.js";
|
|
11
14
|
export default function (options = {}) {
|
|
12
15
|
const loader = typeof options.includes === "object"
|
|
@@ -23,6 +26,9 @@ export default function (options = {}) {
|
|
|
23
26
|
env.use(includeTag());
|
|
24
27
|
env.use(setTag());
|
|
25
28
|
env.use(layoutTag());
|
|
29
|
+
env.use(functionTag());
|
|
30
|
+
env.use(importTag());
|
|
31
|
+
env.use(exportTag());
|
|
26
32
|
env.use(escape());
|
|
27
33
|
return env;
|
|
28
34
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export default function () {
|
|
2
|
+
return (env) => {
|
|
3
|
+
env.tags.push(exportTag);
|
|
4
|
+
};
|
|
5
|
+
}
|
|
6
|
+
function exportTag(env, code, _output, tokens) {
|
|
7
|
+
if (!code.startsWith("export ")) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const expression = code.replace(/^export\s+/, "");
|
|
11
|
+
// Value is set (e.g. {{ export foo = "bar" }})
|
|
12
|
+
if (expression.includes("=")) {
|
|
13
|
+
const match = code.match(/^export\s+([\w]+)\s*=\s*([\s\S]+)$/);
|
|
14
|
+
if (!match) {
|
|
15
|
+
throw new Error(`Invalid export tag: ${code}`);
|
|
16
|
+
}
|
|
17
|
+
const [, variable, value] = match;
|
|
18
|
+
const val = env.compileFilters(tokens, value);
|
|
19
|
+
return `if (__data.hasOwnProperty("${variable}")) {
|
|
20
|
+
${variable} = ${val};
|
|
21
|
+
} else {
|
|
22
|
+
var ${variable} = ${val};
|
|
23
|
+
}
|
|
24
|
+
__data["${variable}"] = ${variable};
|
|
25
|
+
__exports["${variable}"] = ${variable};
|
|
26
|
+
`;
|
|
27
|
+
}
|
|
28
|
+
// Value is captured (eg: {{ export foo }}bar{{ /export }})
|
|
29
|
+
const compiled = [];
|
|
30
|
+
const compiledFilters = env.compileFilters(tokens, expression);
|
|
31
|
+
compiled.push(`if (__data.hasOwnProperty("${expression}")) {
|
|
32
|
+
${expression} = "";
|
|
33
|
+
} else {
|
|
34
|
+
var ${expression} = "";
|
|
35
|
+
}
|
|
36
|
+
`);
|
|
37
|
+
compiled.push(...env.compileTokens(tokens, expression, ["/export"]));
|
|
38
|
+
if (tokens.length && (tokens[0][0] !== "tag" || tokens[0][1] !== "/export")) {
|
|
39
|
+
throw new Error(`Missing closing tag for export tag: ${code}`);
|
|
40
|
+
}
|
|
41
|
+
tokens.shift();
|
|
42
|
+
compiled.push(`${expression} = ${compiledFilters};`);
|
|
43
|
+
compiled.push(`__data["${expression.trim()}"] = ${expression};`);
|
|
44
|
+
compiled.push(`__exports["${expression.trim()}"] = ${expression};`);
|
|
45
|
+
return compiled.join("\n");
|
|
46
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export default function () {
|
|
2
|
+
return (env) => {
|
|
3
|
+
env.tags.push(functionTag);
|
|
4
|
+
};
|
|
5
|
+
}
|
|
6
|
+
function functionTag(env, code, _output, tokens) {
|
|
7
|
+
if (!code.match(/(export\s+)?(async\s+)?function\s/)) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const match = code.match(/^(export\s+)?(async\s+)?function\s+(\w+)\s*(\([^)]+\))?$/);
|
|
11
|
+
if (!match) {
|
|
12
|
+
throw new Error(`Invalid function: ${code}`);
|
|
13
|
+
}
|
|
14
|
+
const [_, exp, as, name, args] = match;
|
|
15
|
+
const compiled = [];
|
|
16
|
+
compiled.push(`${as || ""} function ${name} ${args || "()"} {`);
|
|
17
|
+
compiled.push(`let __output = "";`);
|
|
18
|
+
if (exp) {
|
|
19
|
+
compiled.push(...env.compileTokens(tokens, "__output", ["/export"]));
|
|
20
|
+
if (tokens.length && (tokens[0][0] !== "tag" || tokens[0][1] !== "/export")) {
|
|
21
|
+
throw new Error(`Missing closing tag for export function tag: ${code}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
compiled.push(...env.compileTokens(tokens, "__output", ["/function"]));
|
|
26
|
+
if (tokens.length && (tokens[0][0] !== "tag" || tokens[0][1] !== "/function")) {
|
|
27
|
+
throw new Error(`Missing closing tag for function tag: ${code}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
tokens.shift();
|
|
31
|
+
compiled.push(`return __output;`);
|
|
32
|
+
compiled.push(`}`);
|
|
33
|
+
if (exp) {
|
|
34
|
+
compiled.push(`__exports["${name}"] = ${name}`);
|
|
35
|
+
}
|
|
36
|
+
return compiled.join("\n");
|
|
37
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export default function () {
|
|
2
|
+
return (env) => {
|
|
3
|
+
env.tags.push(importTag);
|
|
4
|
+
};
|
|
5
|
+
}
|
|
6
|
+
function importTag(_env, code) {
|
|
7
|
+
if (!code.startsWith("import ")) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const match = code?.match(/^import\s+(\{[\s|\S]*\}|\w+)\s+from\s+(.+)$/);
|
|
11
|
+
if (!match) {
|
|
12
|
+
throw new Error(`Invalid import: ${code}`);
|
|
13
|
+
}
|
|
14
|
+
const [_, vars, file] = match;
|
|
15
|
+
const compiled = [];
|
|
16
|
+
compiled.push(`__tmp = await __env.run(${file}, {...__data}, __file);`);
|
|
17
|
+
if (vars.startsWith("{")) {
|
|
18
|
+
compiled.push(`let ${vars} = __tmp;`);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
compiled.push(`let ${vars} = __tmp;`);
|
|
22
|
+
}
|
|
23
|
+
return compiled.join("\n");
|
|
24
|
+
}
|
package/esm/plugins/include.js
CHANGED
|
@@ -12,5 +12,11 @@ function includeTag(_env, code, output) {
|
|
|
12
12
|
throw new Error(`Invalid include: ${code}`);
|
|
13
13
|
}
|
|
14
14
|
const [_, file, data] = match;
|
|
15
|
-
return
|
|
15
|
+
return `{
|
|
16
|
+
__tmp = await __env.run(${file},
|
|
17
|
+
{...__data${data ? `, ${data}` : ""}},
|
|
18
|
+
__file
|
|
19
|
+
);
|
|
20
|
+
${output} += __tmp.content;
|
|
21
|
+
}`;
|
|
16
22
|
}
|
package/esm/plugins/layout.js
CHANGED
|
@@ -23,7 +23,11 @@ function layoutTag(env, code, output, tokens) {
|
|
|
23
23
|
}
|
|
24
24
|
tokens.shift();
|
|
25
25
|
compiled.push(`${varname} = ${compiledFilters};`);
|
|
26
|
-
compiled.push(
|
|
26
|
+
compiled.push(`__tmp = await __env.run(${file},
|
|
27
|
+
{...__data${data ? `, ${data}` : ""}, content: ${varname}},
|
|
28
|
+
__file
|
|
29
|
+
);
|
|
30
|
+
${output} += __tmp.content;`);
|
|
27
31
|
compiled.push("}");
|
|
28
32
|
return compiled.join("\n");
|
|
29
33
|
}
|
package/esm/src/environment.d.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { Token } from "./tokenizer.js";
|
|
2
2
|
import type { Loader } from "./loader.js";
|
|
3
|
+
export interface TemplateResult {
|
|
4
|
+
content: string;
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}
|
|
3
7
|
export interface Template {
|
|
4
|
-
(data?: Record<string, unknown>): Promise<
|
|
8
|
+
(data?: Record<string, unknown>): Promise<TemplateResult>;
|
|
9
|
+
code: string;
|
|
10
|
+
file?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface TemplateSync {
|
|
13
|
+
(data?: Record<string, unknown>): TemplateResult;
|
|
5
14
|
code: string;
|
|
6
15
|
file?: string;
|
|
7
16
|
}
|
|
@@ -20,9 +29,11 @@ export declare class Environment {
|
|
|
20
29
|
utils: Record<string, unknown>;
|
|
21
30
|
constructor(options: Options);
|
|
22
31
|
use(plugin: Plugin): void;
|
|
23
|
-
run(file: string, data: Record<string, unknown>, from?: string): Promise<
|
|
24
|
-
runString(source: string, data?: Record<string, unknown>, file?: string): Promise<
|
|
25
|
-
|
|
32
|
+
run(file: string, data: Record<string, unknown>, from?: string): Promise<TemplateResult>;
|
|
33
|
+
runString(source: string, data?: Record<string, unknown>, file?: string): Promise<TemplateResult>;
|
|
34
|
+
runStringSync(source: string, data?: Record<string, unknown>): TemplateResult;
|
|
35
|
+
compile(source: string, path?: string, defaults?: Record<string, unknown>, sync?: false): Template;
|
|
36
|
+
compile(source: string, path?: string, defaults?: Record<string, unknown>, sync?: true): TemplateSync;
|
|
26
37
|
load(file: string, from?: string): Promise<Template>;
|
|
27
38
|
compileTokens(tokens: Token[], outputVar?: string, stopAt?: string[]): string[];
|
|
28
39
|
compileFilters(tokens: Token[], output: string): string;
|
package/esm/src/environment.js
CHANGED
|
@@ -29,19 +29,24 @@ export class Environment {
|
|
|
29
29
|
const template = this.compile(source, file);
|
|
30
30
|
return await template(data);
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
runStringSync(source, data) {
|
|
33
|
+
const template = this.compile(source, "", {}, true);
|
|
34
|
+
return template(data);
|
|
35
|
+
}
|
|
36
|
+
compile(source, path, defaults, sync = false) {
|
|
33
37
|
try {
|
|
34
38
|
const tokens = tokenize(source);
|
|
35
39
|
const code = this.compileTokens(tokens).join("\n");
|
|
36
|
-
const constructor = new Function("__file", "__env", "__defaults", `return async function (__data) {
|
|
40
|
+
const constructor = new Function("__file", "__env", "__defaults", `return${sync ? "" : " async"} function (__data) {
|
|
37
41
|
try {
|
|
38
42
|
__data = Object.assign({}, __defaults, __data);
|
|
39
43
|
const ${this.options.dataVarname} = __data;
|
|
40
|
-
let
|
|
44
|
+
let __tmp;
|
|
45
|
+
const __exports = { content: "" };
|
|
41
46
|
with (__data) {
|
|
42
47
|
${code}
|
|
43
48
|
}
|
|
44
|
-
return
|
|
49
|
+
return __exports;
|
|
45
50
|
} catch (cause) {
|
|
46
51
|
throw new Error(\`Error rendering template: \${__file}\`, { cause });
|
|
47
52
|
}
|
|
@@ -66,7 +71,7 @@ export class Environment {
|
|
|
66
71
|
}
|
|
67
72
|
return this.cache.get(file);
|
|
68
73
|
}
|
|
69
|
-
compileTokens(tokens, outputVar = "
|
|
74
|
+
compileTokens(tokens, outputVar = "__exports.content", stopAt) {
|
|
70
75
|
const compiled = [];
|
|
71
76
|
tokens: while (tokens.length > 0) {
|
|
72
77
|
if (stopAt && tokens[0][0] === "tag" && stopAt.includes(tokens[0][1])) {
|
|
@@ -77,7 +82,9 @@ export class Environment {
|
|
|
77
82
|
continue;
|
|
78
83
|
}
|
|
79
84
|
if (type === "string" || type === "raw") {
|
|
80
|
-
compiled.push(`${outputVar} += \`${code
|
|
85
|
+
compiled.push(`${outputVar} += \`${code
|
|
86
|
+
.replaceAll("`", "\\`")
|
|
87
|
+
.replaceAll("${", "\\${")}\`;`);
|
|
81
88
|
continue;
|
|
82
89
|
}
|
|
83
90
|
if (type === "tag") {
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"module": "./esm/mod.js",
|
|
3
3
|
"name": "ventojs",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.7.2",
|
|
5
5
|
"description": "🌬 A minimal but powerful template engine",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": "github:oscarotero/vento",
|
|
8
|
-
"homepage": "https://
|
|
8
|
+
"homepage": "https://vento.js.org/",
|
|
9
9
|
"bugs": "https://github.com/oscarotero/vento/issues",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
package/esm/_dnt.test_shims.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* All internal non-test code, that is files that do not have `test` or `bench` in the name, must use the assertion functions within `_utils/asserts.ts` and not `testing/asserts.ts`. This is to create a separation of concerns between internal and testing assertions.
|
|
3
|
-
*/
|
|
4
|
-
export declare class DenoStdInternalError extends Error {
|
|
5
|
-
constructor(message: string);
|
|
6
|
-
}
|
|
7
|
-
/** Make an assertion, if not `true`, then throw. */
|
|
8
|
-
export declare function assert(expr: unknown, msg?: string): asserts expr;
|
|
9
|
-
/** Use this to assert unreachable code. */
|
|
10
|
-
export declare function unreachable(): never;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
2
|
-
// This module is browser compatible.
|
|
3
|
-
/**
|
|
4
|
-
* All internal non-test code, that is files that do not have `test` or `bench` in the name, must use the assertion functions within `_utils/asserts.ts` and not `testing/asserts.ts`. This is to create a separation of concerns between internal and testing assertions.
|
|
5
|
-
*/
|
|
6
|
-
export class DenoStdInternalError extends Error {
|
|
7
|
-
constructor(message) {
|
|
8
|
-
super(message);
|
|
9
|
-
this.name = "DenoStdInternalError";
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
/** Make an assertion, if not `true`, then throw. */
|
|
13
|
-
export function assert(expr, msg = "") {
|
|
14
|
-
if (!expr) {
|
|
15
|
-
throw new DenoStdInternalError(msg);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
/** Use this to assert unreachable code. */
|
|
19
|
-
export function unreachable() {
|
|
20
|
-
throw new DenoStdInternalError("unreachable");
|
|
21
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as _win32 from "./win32.js";
|
|
2
|
-
import * as _posix from "./posix.js";
|
|
3
|
-
export declare const win32: typeof _win32;
|
|
4
|
-
export declare const posix: typeof _posix;
|
|
5
|
-
export declare const basename: typeof _posix.basename | typeof _win32.basename, delimiter: string, dirname: typeof _posix.dirname | typeof _win32.dirname, extname: typeof _posix.extname | typeof _win32.extname, format: typeof _posix.format | typeof _win32.format, fromFileUrl: typeof _posix.fromFileUrl | typeof _win32.fromFileUrl, isAbsolute: typeof _win32.isAbsolute | typeof _posix.isAbsolute, join: typeof _posix.join | typeof _win32.join, normalize: typeof _win32.normalize | typeof _posix.normalize, parse: typeof _posix.parse | typeof _win32.parse, relative: typeof _posix.relative | typeof _win32.relative, resolve: typeof _win32.resolve | typeof _posix.resolve, sep: string, toFileUrl: typeof _posix.toFileUrl | typeof _win32.toFileUrl, toNamespacedPath: typeof _posix.toNamespacedPath | typeof _win32.toNamespacedPath;
|
|
6
|
-
export * from "./common.js";
|
|
7
|
-
export { SEP, SEP_PATTERN } from "./separator.js";
|
|
8
|
-
export * from "./_interface.js";
|
|
9
|
-
export * from "./glob.js";
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import type { FormatInputPathObject, ParsedPath } from "./_interface.js";
|
|
3
|
-
export declare const sep = "/";
|
|
4
|
-
export declare const delimiter = ":";
|
|
5
|
-
/**
|
|
6
|
-
* Resolves `pathSegments` into an absolute path.
|
|
7
|
-
* @param pathSegments an array of path segments
|
|
8
|
-
*/
|
|
9
|
-
export declare function resolve(...pathSegments: string[]): string;
|
|
10
|
-
/**
|
|
11
|
-
* Normalize the `path`, resolving `'..'` and `'.'` segments.
|
|
12
|
-
* Note that resolving these segments does not necessarily mean that all will be eliminated.
|
|
13
|
-
* A `'..'` at the top-level will be preserved, and an empty path is canonically `'.'`.
|
|
14
|
-
* @param path to be normalized
|
|
15
|
-
*/
|
|
16
|
-
export declare function normalize(path: string): string;
|
|
17
|
-
/**
|
|
18
|
-
* Verifies whether provided path is absolute
|
|
19
|
-
* @param path to be verified as absolute
|
|
20
|
-
*/
|
|
21
|
-
export declare function isAbsolute(path: string): boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Join all given a sequence of `paths`,then normalizes the resulting path.
|
|
24
|
-
* @param paths to be joined and normalized
|
|
25
|
-
*/
|
|
26
|
-
export declare function join(...paths: string[]): string;
|
|
27
|
-
/**
|
|
28
|
-
* Return the relative path from `from` to `to` based on current working directory.
|
|
29
|
-
* @param from path in current working directory
|
|
30
|
-
* @param to path in current working directory
|
|
31
|
-
*/
|
|
32
|
-
export declare function relative(from: string, to: string): string;
|
|
33
|
-
/**
|
|
34
|
-
* Resolves path to a namespace path
|
|
35
|
-
* @param path to resolve to namespace
|
|
36
|
-
*/
|
|
37
|
-
export declare function toNamespacedPath(path: string): string;
|
|
38
|
-
/**
|
|
39
|
-
* Return the directory path of a `path`.
|
|
40
|
-
* @param path - path to extract the directory from.
|
|
41
|
-
*/
|
|
42
|
-
export declare function dirname(path: string): string;
|
|
43
|
-
/**
|
|
44
|
-
* Return the last portion of a `path`.
|
|
45
|
-
* Trailing directory separators are ignored, and optional suffix is removed.
|
|
46
|
-
*
|
|
47
|
-
* @param path - path to extract the name from.
|
|
48
|
-
* @param [suffix] - suffix to remove from extracted name.
|
|
49
|
-
*/
|
|
50
|
-
export declare function basename(path: string, suffix?: string): string;
|
|
51
|
-
/**
|
|
52
|
-
* Return the extension of the `path` with leading period.
|
|
53
|
-
* @param path with extension
|
|
54
|
-
* @returns extension (ex. for `file.ts` returns `.ts`)
|
|
55
|
-
*/
|
|
56
|
-
export declare function extname(path: string): string;
|
|
57
|
-
/**
|
|
58
|
-
* Generate a path from `FormatInputPathObject` object.
|
|
59
|
-
* @param pathObject with path
|
|
60
|
-
*/
|
|
61
|
-
export declare function format(pathObject: FormatInputPathObject): string;
|
|
62
|
-
/**
|
|
63
|
-
* Return a `ParsedPath` object of the `path`.
|
|
64
|
-
* @param path to process
|
|
65
|
-
*/
|
|
66
|
-
export declare function parse(path: string): ParsedPath;
|
|
67
|
-
/**
|
|
68
|
-
* Converts a file URL to a path string.
|
|
69
|
-
*
|
|
70
|
-
* ```ts
|
|
71
|
-
* import { fromFileUrl } from "https://deno.land/std@$STD_VERSION/path/posix.ts";
|
|
72
|
-
* fromFileUrl("file:///home/foo"); // "/home/foo"
|
|
73
|
-
* ```
|
|
74
|
-
* @param url of a file URL
|
|
75
|
-
*/
|
|
76
|
-
export declare function fromFileUrl(url: string | URL): string;
|
|
77
|
-
/**
|
|
78
|
-
* Converts a path string to a file URL.
|
|
79
|
-
*
|
|
80
|
-
* ```ts
|
|
81
|
-
* import { toFileUrl } from "https://deno.land/std@$STD_VERSION/path/posix.ts";
|
|
82
|
-
* toFileUrl("/home/foo"); // new URL("file:///home/foo")
|
|
83
|
-
* ```
|
|
84
|
-
* @param path to convert to file URL
|
|
85
|
-
*/
|
|
86
|
-
export declare function toFileUrl(path: string): URL;
|