ventojs 1.13.2 → 1.14.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.
@@ -7,7 +7,7 @@ export declare const DELIMITER: ":" | ";";
7
7
  * The character used to separate components of a file path.
8
8
  * On Windows, this is `\`. On all other platforms, this is `/`.
9
9
  */
10
- export declare const SEPARATOR: "/" | "\\";
10
+ export declare const SEPARATOR: "\\" | "/";
11
11
  /**
12
12
  * A regular expression that matches one or more path separators.
13
13
  */
@@ -0,0 +1,19 @@
1
+ /** Determines the common path from a set of paths for POSIX systems.
2
+ *
3
+ * @example Usage
4
+ * ```ts
5
+ * import { common } from "@std/path/posix/common";
6
+ * import { assertEquals } from "@std/assert";
7
+ *
8
+ * const path = common([
9
+ * "./deno/std/path/mod.ts",
10
+ * "./deno/std/fs/mod.ts",
11
+ * ]);
12
+ * assertEquals(path, "./deno/std/");
13
+ * ```
14
+ *
15
+ * @param paths The paths to compare.
16
+ * @returns The common path.
17
+ */
18
+ export declare function common(paths: string[]): string;
19
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../../../../src/deps/jsr.io/@std/path/1.0.8/posix/common.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAE9C"}
@@ -0,0 +1,24 @@
1
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+ import { common as _common } from "../_common/common.js";
4
+ import { SEPARATOR } from "./constants.js";
5
+ /** Determines the common path from a set of paths for POSIX systems.
6
+ *
7
+ * @example Usage
8
+ * ```ts
9
+ * import { common } from "@std/path/posix/common";
10
+ * import { assertEquals } from "@std/assert";
11
+ *
12
+ * const path = common([
13
+ * "./deno/std/path/mod.ts",
14
+ * "./deno/std/fs/mod.ts",
15
+ * ]);
16
+ * assertEquals(path, "./deno/std/");
17
+ * ```
18
+ *
19
+ * @param paths The paths to compare.
20
+ * @returns The common path.
21
+ */
22
+ export function common(paths) {
23
+ return _common(paths, SEPARATOR);
24
+ }
@@ -0,0 +1,2 @@
1
+ export { isGlob } from "../is_glob.js";
2
+ //# sourceMappingURL=is_glob.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is_glob.d.ts","sourceRoot":"","sources":["../../../../../../../src/deps/jsr.io/@std/path/1.0.8/posix/is_glob.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,3 @@
1
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+ export { isGlob } from "../is_glob.js";
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Utilities for working with POSIX-formatted paths.
3
+ *
4
+ * This module also provides some functions that help when working with URLs.
5
+ * See the documentation for examples.
6
+ *
7
+ * Codes in the examples uses POSIX path but it automatically use Windows path
8
+ * on Windows. Use methods under `posix` or `win32` object instead to handle non
9
+ * platform specific path like:
10
+ *
11
+ * ```ts
12
+ * import { fromFileUrl } from "@std/path/posix/from-file-url";
13
+ * import { assertEquals } from "@std/assert";
14
+ *
15
+ * assertEquals(fromFileUrl("file:///home/foo"), "/home/foo");
16
+ * ```
17
+ *
18
+ * @module
19
+ */
20
+ export * from "./basename.js";
21
+ export * from "./constants.js";
22
+ export * from "./dirname.js";
23
+ export * from "./extname.js";
24
+ export * from "./format.js";
25
+ export * from "./from_file_url.js";
26
+ export * from "./is_absolute.js";
27
+ export * from "./join.js";
28
+ export * from "./normalize.js";
29
+ export * from "./parse.js";
30
+ export * from "./relative.js";
31
+ export * from "./resolve.js";
32
+ export * from "./to_file_url.js";
33
+ export * from "./to_namespaced_path.js";
34
+ export * from "./common.js";
35
+ export * from "../types.js";
36
+ export * from "./glob_to_regexp.js";
37
+ export * from "./is_glob.js";
38
+ export * from "./join_globs.js";
39
+ export * from "./normalize_glob.js";
40
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../../../../src/deps/jsr.io/@std/path/1.0.8/posix/mod.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;GAkBG;AACH,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,43 @@
1
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
+ // Copyright the Browserify authors. MIT License.
3
+ // Ported mostly from https://github.com/browserify/path-browserify/
4
+ // This module is browser compatible.
5
+ /**
6
+ * Utilities for working with POSIX-formatted paths.
7
+ *
8
+ * This module also provides some functions that help when working with URLs.
9
+ * See the documentation for examples.
10
+ *
11
+ * Codes in the examples uses POSIX path but it automatically use Windows path
12
+ * on Windows. Use methods under `posix` or `win32` object instead to handle non
13
+ * platform specific path like:
14
+ *
15
+ * ```ts
16
+ * import { fromFileUrl } from "@std/path/posix/from-file-url";
17
+ * import { assertEquals } from "@std/assert";
18
+ *
19
+ * assertEquals(fromFileUrl("file:///home/foo"), "/home/foo");
20
+ * ```
21
+ *
22
+ * @module
23
+ */
24
+ export * from "./basename.js";
25
+ export * from "./constants.js";
26
+ export * from "./dirname.js";
27
+ export * from "./extname.js";
28
+ export * from "./format.js";
29
+ export * from "./from_file_url.js";
30
+ export * from "./is_absolute.js";
31
+ export * from "./join.js";
32
+ export * from "./normalize.js";
33
+ export * from "./parse.js";
34
+ export * from "./relative.js";
35
+ export * from "./resolve.js";
36
+ export * from "./to_file_url.js";
37
+ export * from "./to_namespaced_path.js";
38
+ export * from "./common.js";
39
+ export * from "../types.js";
40
+ export * from "./glob_to_regexp.js";
41
+ export * from "./is_glob.js";
42
+ export * from "./join_globs.js";
43
+ export * from "./normalize_glob.js";
package/esm/deps.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * as path from "./deps/jsr.io/@std/path/1.0.8/mod.js";
2
+ export * as posix from "./deps/jsr.io/@std/path/1.0.8/posix/mod.js";
2
3
  export * as html from "./deps/jsr.io/@std/html/1.0.3/mod.js";
3
4
  export * as astring from "./deps/jsr.io/@davidbonnet/astring/1.8.6/src/astring.js";
4
5
  export * as meriyah from "meriyah";
package/esm/deps.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"deps.d.ts","sourceRoot":"","sources":["../src/deps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,sCAAsC,CAAC;AAC7D,OAAO,KAAK,IAAI,MAAM,sCAAsC,CAAC;AAE7D,OAAO,KAAK,OAAO,MAAM,yDAAyD,CAAC;AACnF,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,YAAY,KAAK,MAAM,MAAM,QAAQ,CAAC"}
1
+ {"version":3,"file":"deps.d.ts","sourceRoot":"","sources":["../src/deps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,sCAAsC,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,4CAA4C,CAAC;AACpE,OAAO,KAAK,IAAI,MAAM,sCAAsC,CAAC;AAE7D,OAAO,KAAK,OAAO,MAAM,yDAAyD,CAAC;AACnF,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,YAAY,KAAK,MAAM,MAAM,QAAQ,CAAC"}
package/esm/deps.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * as path from "./deps/jsr.io/@std/path/1.0.8/mod.js";
2
+ export * as posix from "./deps/jsr.io/@std/path/1.0.8/posix/mod.js";
2
3
  export * as html from "./deps/jsr.io/@std/html/1.0.3/mod.js";
3
4
  export * as astring from "./deps/jsr.io/@davidbonnet/astring/1.8.6/src/astring.js";
4
5
  export * as meriyah from "meriyah";
@@ -1 +1 @@
1
- {"version":3,"file":"for.d.ts","sourceRoot":"","sources":["../../src/plugins/for.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAe,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEjE,MAAM,CAAC,OAAO,cAAc,MAAM,CAKjC"}
1
+ {"version":3,"file":"for.d.ts","sourceRoot":"","sources":["../../src/plugins/for.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAe,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEjE,MAAM,CAAC,OAAO,cAAc,MAAM,CAKjC"}
@@ -1,3 +1,4 @@
1
+ import analyze from "../src/js.js";
1
2
  export default function () {
2
3
  return (env) => {
3
4
  env.tags.push(forTag);
@@ -5,15 +6,50 @@ export default function () {
5
6
  };
6
7
  }
7
8
  function forTag(env, code, output, tokens) {
9
+ if (code === "break" || code === "continue") {
10
+ return `${code};`;
11
+ }
8
12
  if (!code.startsWith("for ")) {
9
13
  return;
10
14
  }
11
15
  const compiled = [];
12
- const match = code.match(/^for\s+(await\s+)?(\w+)(?:,\s*(\w+))?\s+of\s+([\s|\S]+)$/);
16
+ const match = code.match(/^for\s+(await\s+)?([\s\S]*)$/);
13
17
  if (!match) {
14
18
  throw new Error(`Invalid for loop: ${code}`);
15
19
  }
16
- const [_, aw, var1, var2, collection] = match;
20
+ let [, aw, tagCode] = match;
21
+ let var1;
22
+ let var2 = undefined;
23
+ let collection = "";
24
+ if (tagCode.startsWith("[") || tagCode.startsWith("{")) {
25
+ [var1, tagCode] = getDestructureContent(tagCode);
26
+ }
27
+ else {
28
+ const parts = tagCode.match(/(^[^\s,]+)([\s|\S]+)$/);
29
+ if (!parts) {
30
+ throw new Error(`Invalid for loop variable: ${tagCode}`);
31
+ }
32
+ var1 = parts[1].trim();
33
+ tagCode = parts[2].trim();
34
+ }
35
+ if (tagCode.startsWith(",")) {
36
+ tagCode = tagCode.slice(1).trim();
37
+ if (tagCode.startsWith("[") || tagCode.startsWith("{")) {
38
+ [var2, tagCode] = getDestructureContent(tagCode);
39
+ collection = tagCode.slice(3).trim(); // Remove "of " from the start
40
+ }
41
+ else {
42
+ const parts = tagCode.match(/^([\w]+)\s+of\s+([\s|\S]+)$/);
43
+ if (!parts) {
44
+ throw new Error(`Invalid for loop variable: ${tagCode}`);
45
+ }
46
+ var2 = parts[1].trim();
47
+ collection = parts[2].trim();
48
+ }
49
+ }
50
+ else if (tagCode.startsWith("of ")) {
51
+ collection = tagCode.slice(3).trim();
52
+ }
17
53
  if (var2) {
18
54
  compiled.push(`for ${aw || ""}(let [${var1}, ${var2}] of __env.utils.toIterator(${env.compileFilters(tokens, collection)}, true)) {`);
19
55
  }
@@ -72,3 +108,16 @@ async function* asyncIterableToEntries(iterator) {
72
108
  yield [i++, value];
73
109
  }
74
110
  }
111
+ function getDestructureContent(code) {
112
+ let index = 0;
113
+ analyze(code, (type, i) => {
114
+ if (type === "close") {
115
+ index = i;
116
+ return false;
117
+ }
118
+ });
119
+ return [
120
+ code.slice(0, index).trim(),
121
+ code.slice(index + 1).trim(),
122
+ ];
123
+ }
@@ -15,6 +15,7 @@ function functionTag(env, code, _output, tokens) {
15
15
  const compiled = [];
16
16
  compiled.push(`${as || ""} function ${name} ${args || "()"} {`);
17
17
  compiled.push(`let __output = "";`);
18
+ const result = env.compileFilters(tokens, "__output");
18
19
  if (exp) {
19
20
  compiled.push(...env.compileTokens(tokens, "__output", ["/export"]));
20
21
  if (tokens.length && (tokens[0][0] !== "tag" || tokens[0][1] !== "/export")) {
@@ -28,7 +29,7 @@ function functionTag(env, code, _output, tokens) {
28
29
  }
29
30
  }
30
31
  tokens.shift();
31
- compiled.push(`return __output;`);
32
+ compiled.push(`return ${result};`);
32
33
  compiled.push(`}`);
33
34
  if (exp) {
34
35
  compiled.push(`__exports["${name}"] = ${name}`);
package/esm/plugins/if.js CHANGED
@@ -10,7 +10,8 @@ function ifTag(env, code, output, tokens) {
10
10
  }
11
11
  const condition = code.replace(/^if\s+/, "").trim();
12
12
  const compiled = [];
13
- compiled.push(`if (${condition}) {`);
13
+ const val = env.compileFilters(tokens, condition);
14
+ compiled.push(`if (${val}) {`);
14
15
  compiled.push(...env.compileTokens(tokens, output, ["/if"]));
15
16
  tokens.shift();
16
17
  compiled.push("}");
@@ -1,6 +1,5 @@
1
1
  import "../_dnt.polyfills.js";
2
2
  import { Token } from "./tokenizer.js";
3
- import type { Loader } from "./loader.node.js";
4
3
  export interface TemplateResult {
5
4
  content: string;
6
5
  [key: string]: unknown;
@@ -25,6 +24,14 @@ export type FilterThis = {
25
24
  };
26
25
  export type Filter = (this: FilterThis, ...args: any[]) => any;
27
26
  export type Plugin = (env: Environment) => void;
27
+ export interface TemplateSource {
28
+ source: string;
29
+ data?: Record<string, unknown>;
30
+ }
31
+ export interface Loader {
32
+ load(file: string): TemplateSource | Promise<TemplateSource>;
33
+ resolve(from: string, file: string): string;
34
+ }
28
35
  export interface Options {
29
36
  loader: Loader;
30
37
  dataVarname: string;
@@ -1 +1 @@
1
- {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/src/environment.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B,OAAiB,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,KAAK,EAAE,MAAM,E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AAM,EAAE,UAAU,UAAQ,GAAG,MAAM;CA8C5E"}
@@ -1 +1 @@
1
- {"version":3,"file":"js.d.ts","sourceRoot":"","sources":["../../src/src/js.ts"],"names":[],"mappings":"AAAA,KAAK,WAAW,GACZ,YAAY,GACZ,cAAc,GACd,OAAO,GACP,UAAU,CAAC;AAWf,KAAK,OAAO,GAAG,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,KAAK,KAAK,GAAG,IAAI,CAAC;AAElE,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,QAuK/D"}
1
+ {"version":3,"file":"js.d.ts","sourceRoot":"","sources":["../../src/src/js.ts"],"names":[],"mappings":"AAAA,KAAK,WAAW,GACZ,YAAY,GACZ,cAAc,GACd,OAAO,GACP,UAAU,CAAC;AAaf,KAAK,OAAO,GAAG,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,KAAK,KAAK,GAAG,IAAI,CAAC;AAElE,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,QA0N/D"}
package/esm/src/js.js CHANGED
@@ -5,130 +5,177 @@ export default function analyze(source, visitor) {
5
5
  while (index < length) {
6
6
  const char = source.charAt(index++);
7
7
  switch (char) {
8
- // Detect start brackets
9
8
  case "{": {
10
- const status = statuses[0];
11
- if (status === "literal" && source.charAt(index - 2) === "$") {
12
- statuses.unshift("bracket");
13
- }
14
- else if (status !== "comment" && status !== "single-quote" &&
15
- status !== "double-quote" && status !== "literal" &&
16
- status !== "regex" && status !== "line-comment") {
17
- if (statuses.length === 0 && visitor("open-bracket", index) === false) {
18
- return;
19
- }
20
- statuses.unshift("bracket");
9
+ switch (statuses[0]) {
10
+ // String interpolation `${...}`
11
+ case "literal":
12
+ if (source.charAt(index - 2) === "$" &&
13
+ source.charAt(index - 3) !== "\\") {
14
+ statuses.unshift("bracket");
15
+ }
16
+ break;
17
+ // Open bracket
18
+ case undefined:
19
+ case "square-bracket":
20
+ case "bracket":
21
+ if (!statuses.length && visitor("open-bracket", index) === false) {
22
+ return;
23
+ }
24
+ statuses.unshift("bracket");
25
+ break;
21
26
  }
22
27
  break;
23
28
  }
24
29
  // Detect end brackets
25
30
  case "}": {
26
- const status = statuses[0];
27
- if (status === "bracket") {
28
- statuses.shift();
29
- if (statuses.length === 0 && visitor("close", index) === false) {
30
- return;
31
- }
31
+ switch (statuses[0]) {
32
+ // Close a bracket
33
+ case "bracket":
34
+ statuses.shift();
35
+ if (statuses.length === 0 && visitor("close", index) === false) {
36
+ return;
37
+ }
38
+ break;
32
39
  }
33
40
  break;
34
41
  }
35
- // Detect double quotes
36
42
  case '"': {
37
- const status = statuses[0];
38
- if (status === "double-quote") {
39
- statuses.shift();
40
- }
41
- else if (status !== "comment" &&
42
- status !== "single-quote" &&
43
- status !== "literal" &&
44
- status !== "regex" &&
45
- status !== "line-comment") {
46
- statuses.unshift("double-quote");
43
+ switch (statuses[0]) {
44
+ // Close double quotes
45
+ case "double-quote":
46
+ statuses.shift();
47
+ break;
48
+ // Open double quotes
49
+ case undefined:
50
+ case "square-bracket":
51
+ case "bracket":
52
+ statuses.unshift("double-quote");
53
+ break;
47
54
  }
48
55
  break;
49
56
  }
50
- // Detect single quotes
51
57
  case "'": {
52
- const status = statuses[0];
53
- if (status === "single-quote") {
54
- statuses.shift();
55
- }
56
- else if (status !== "comment" &&
57
- status !== "double-quote" &&
58
- status !== "literal" &&
59
- status !== "regex" &&
60
- status !== "line-comment") {
61
- statuses.unshift("single-quote");
58
+ switch (statuses[0]) {
59
+ // Close single quotes
60
+ case "single-quote":
61
+ statuses.shift();
62
+ break;
63
+ // Open single quotes
64
+ case undefined:
65
+ case "square-bracket":
66
+ case "bracket":
67
+ statuses.unshift("single-quote");
68
+ break;
62
69
  }
63
70
  break;
64
71
  }
65
- // Detect literals
66
72
  case "`": {
67
- const status = statuses[0];
68
- if (status === "literal") {
69
- statuses.shift();
70
- }
71
- else if (status !== "comment" &&
72
- status !== "double-quote" &&
73
- status !== "single-quote" &&
74
- status !== "regex" &&
75
- status !== "line-comment") {
76
- statuses.unshift("literal");
73
+ switch (statuses[0]) {
74
+ // Close literal
75
+ case "literal":
76
+ statuses.shift();
77
+ break;
78
+ // Open literal
79
+ case undefined:
80
+ case "square-bracket":
81
+ case "bracket":
82
+ statuses.unshift("literal");
83
+ break;
77
84
  }
78
85
  break;
79
86
  }
80
- // Detect comments and regex
81
- case "/": {
82
- const status = statuses[0];
83
- if (status === "single-quote" || status === "double-quote" ||
84
- status === "literal" || status === "line-comment") {
85
- break;
87
+ case "[": {
88
+ switch (statuses[0]) {
89
+ // Open a square bracket in a regex
90
+ case "regex":
91
+ if (source.charAt(index - 2) !== "\\") {
92
+ statuses.unshift("regex-bracket");
93
+ }
94
+ break;
95
+ // Open a square bracket
96
+ case undefined:
97
+ case "square-bracket":
98
+ case "bracket":
99
+ if (!statuses.length && visitor("open-bracket", index) === false) {
100
+ return;
101
+ }
102
+ statuses.unshift("square-bracket");
103
+ break;
86
104
  }
87
- // We are in a comment: close or ignore
88
- if (status === "comment") {
89
- if (source.charAt(index - 2) === "*") {
90
- statuses.shift();
91
- }
92
- break;
93
- }
94
- // We are in a regex: close or ignore
95
- if (status === "regex") {
96
- if (source.charAt(index - 2) !== "\\") {
105
+ break;
106
+ }
107
+ case "]": {
108
+ switch (statuses[0]) {
109
+ // Close a square bracket in a regex
110
+ case "regex-bracket":
111
+ if (source.charAt(index - 2) !== "\\") {
112
+ statuses.shift();
113
+ }
114
+ break;
115
+ // Close a square bracket
116
+ case "square-bracket":
97
117
  statuses.shift();
98
- }
99
- break;
100
- }
101
- // Start a new comment
102
- if (source.charAt(index) === "*") {
103
- statuses.unshift("comment");
104
- break;
105
- }
106
- // Start a new line comment
107
- if (source.charAt(index - 2) === "/") {
108
- statuses.unshift("line-comment");
109
- break;
118
+ if (statuses.length === 0 && visitor("close", index) === false) {
119
+ return;
120
+ }
121
+ break;
110
122
  }
111
- // Start a new regex
112
- const prev = prevChar(source, index - 1);
113
- if (prev === "(" || prev === "=" || prev === ":" || prev === ",") {
114
- statuses.unshift("regex");
123
+ break;
124
+ }
125
+ case "/": {
126
+ switch (statuses[0]) {
127
+ // Close a comment
128
+ case "comment":
129
+ if (source.charAt(index - 2) === "*") {
130
+ statuses.shift();
131
+ }
132
+ break;
133
+ // Close a regular expression
134
+ case "regex":
135
+ if (source.charAt(index - 2) !== "\\") {
136
+ statuses.shift();
137
+ }
138
+ break;
139
+ case undefined:
140
+ case "square-bracket":
141
+ case "bracket":
142
+ // Open a new comment
143
+ if (source.charAt(index) === "*") {
144
+ statuses.unshift("comment");
145
+ break;
146
+ }
147
+ // Open a new line comment
148
+ if (source.charAt(index - 2) === "/") {
149
+ statuses.unshift("line-comment");
150
+ break;
151
+ }
152
+ // Open a new regex
153
+ if (["(", "=", ":", ",", "?", "&", "!"].includes(prevChar(source, index - 1))) {
154
+ statuses.unshift("regex");
155
+ break;
156
+ }
157
+ break;
115
158
  }
116
159
  break;
117
160
  }
118
- // Detect end of line comments
119
161
  case "\n": {
120
- const status = statuses[0];
121
- if (status === "line-comment") {
122
- statuses.shift();
162
+ switch (statuses[0]) {
163
+ // Close a line comment
164
+ case "line-comment":
165
+ statuses.shift();
166
+ break;
123
167
  }
124
168
  break;
125
169
  }
126
- // Detect filters
127
170
  case "|": {
128
- const status = statuses[0];
129
- if (status === "bracket" && source.charAt(index) === ">" &&
130
- visitor("new-filter", index + 1) === false) {
131
- return;
171
+ switch (statuses[0]) {
172
+ // New pipeline
173
+ case "bracket":
174
+ if (source.charAt(index) === ">" &&
175
+ visitor("new-filter", index + 1) === false) {
176
+ return;
177
+ }
178
+ break;
132
179
  }
133
180
  break;
134
181
  }
@@ -1,12 +1,6 @@
1
1
  import "../_dnt.polyfills.js";
2
- export interface TemplateSource {
3
- source: string;
4
- data?: Record<string, unknown>;
5
- }
6
- export interface Loader {
7
- load(file: string): TemplateSource | Promise<TemplateSource>;
8
- resolve(from: string, file: string): string;
9
- }
2
+ import type { Loader, TemplateSource } from "./environment.js";
3
+ export type { Loader, TemplateSource };
10
4
  export declare class FileLoader implements Loader {
11
5
  #private;
12
6
  constructor(root?: string);
@@ -1 +1 @@
1
- {"version":3,"file":"loader.node.d.ts","sourceRoot":"","sources":["../../src/src/loader.node.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAK9B,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,MAAM;IACrB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAC7D,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CAC7C;AAED,qBAAa,UAAW,YAAW,MAAM;;gBAG3B,IAAI,GAAE,MAAsB;IAIlC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAMjD,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;CAW5C"}
1
+ {"version":3,"file":"loader.node.d.ts","sourceRoot":"","sources":["../../src/src/loader.node.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAI9B,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAG/D,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;AAEvC,qBAAa,UAAW,YAAW,MAAM;;gBAG3B,IAAI,GAAE,MAAsB;IAIlC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAMjD,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;CAW5C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ventojs",
3
- "version": "1.13.2",
3
+ "version": "1.14.0",
4
4
  "description": "🌬 A minimal but powerful template engine",
5
5
  "homepage": "https://vento.js.org/",
6
6
  "repository": "github:oscarotero/vento",