ventojs 2.0.2 → 2.1.1
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 +16 -0
- package/core/environment.js +18 -2
- package/core/js.js +1 -1
- package/mod.js +1 -0
- package/package.json +1 -1
- package/plugins/include.js +2 -2
- package/types/core/environment.d.ts +1 -0
- package/types/mod.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [2.1.1] - 2025-09-18
|
|
8
|
+
### Fixed
|
|
9
|
+
- The tag `include` fails when it's inside a `slot`.
|
|
10
|
+
|
|
11
|
+
## [2.1.0] - 2025-09-17
|
|
12
|
+
### Added
|
|
13
|
+
- New `strict` mode to fail when using an undefined variable. This mode has a different performance profile than normal mode; it's mostly intended for testing and debug purposes. [#101], [#142]
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
- Variable detection with spread operator [#156]
|
|
17
|
+
|
|
7
18
|
## [2.0.2] - 2025-09-13
|
|
8
19
|
### Added
|
|
9
20
|
- The closing tag `{{ /layout }}` is optional. [#145], [#151].
|
|
@@ -60,18 +71,23 @@ Vento 2.0 is now dependency-free and compatible with browsers without a build st
|
|
|
60
71
|
- Improved escape filter performance [#134]
|
|
61
72
|
|
|
62
73
|
[#95]: https://github.com/ventojs/vento/issues/95
|
|
74
|
+
[#101]: https://github.com/ventojs/vento/issues/101
|
|
63
75
|
[#128]: https://github.com/ventojs/vento/issues/128
|
|
64
76
|
[#131]: https://github.com/ventojs/vento/issues/131
|
|
65
77
|
[#134]: https://github.com/ventojs/vento/issues/134
|
|
66
78
|
[#137]: https://github.com/ventojs/vento/issues/137
|
|
67
79
|
[#140]: https://github.com/ventojs/vento/issues/140
|
|
80
|
+
[#142]: https://github.com/ventojs/vento/issues/142
|
|
68
81
|
[#145]: https://github.com/ventojs/vento/issues/145
|
|
69
82
|
[#146]: https://github.com/ventojs/vento/issues/146
|
|
70
83
|
[#147]: https://github.com/ventojs/vento/issues/147
|
|
71
84
|
[#148]: https://github.com/ventojs/vento/issues/148
|
|
72
85
|
[#150]: https://github.com/ventojs/vento/issues/150
|
|
73
86
|
[#151]: https://github.com/ventojs/vento/issues/151
|
|
87
|
+
[#156]: https://github.com/ventojs/vento/issues/156
|
|
74
88
|
|
|
89
|
+
[2.1.1]: https://github.com/ventojs/vento/compare/v2.1.0...v2.1.1
|
|
90
|
+
[2.1.0]: https://github.com/ventojs/vento/compare/v2.0.2...v2.1.0
|
|
75
91
|
[2.0.2]: https://github.com/ventojs/vento/compare/v2.0.1...v2.0.2
|
|
76
92
|
[2.0.1]: https://github.com/ventojs/vento/compare/v2.0.0...v2.0.1
|
|
77
93
|
[2.0.0]: https://github.com/ventojs/vento/releases/tag/v2.0.0
|
package/core/environment.js
CHANGED
|
@@ -55,8 +55,24 @@ export class Environment {
|
|
|
55
55
|
}
|
|
56
56
|
throw error;
|
|
57
57
|
}
|
|
58
|
-
const { dataVarname, autoDataVarname } = this.options;
|
|
59
|
-
if (autoDataVarname) {
|
|
58
|
+
const { dataVarname, autoDataVarname, strict } = this.options;
|
|
59
|
+
if (strict && autoDataVarname) {
|
|
60
|
+
const innerCode = JSON.stringify(`
|
|
61
|
+
const __exports = { content: "" };
|
|
62
|
+
${code}
|
|
63
|
+
return __exports;
|
|
64
|
+
`);
|
|
65
|
+
code = `
|
|
66
|
+
return new (async function(){}).constructor(
|
|
67
|
+
"__env",
|
|
68
|
+
"__template",
|
|
69
|
+
"${dataVarname}",
|
|
70
|
+
\`{\${Object.keys(${dataVarname}).join(",")}}\`,
|
|
71
|
+
${innerCode}
|
|
72
|
+
)(__env, __template, ${dataVarname}, ${dataVarname});
|
|
73
|
+
`;
|
|
74
|
+
}
|
|
75
|
+
else if (autoDataVarname) {
|
|
60
76
|
const generator = iterateTopLevel(code);
|
|
61
77
|
const [, , variables] = generator.next().value;
|
|
62
78
|
while (!generator.next().done)
|
package/core/js.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import reserved from "./reserved.js";
|
|
2
2
|
const TEMPLATE_PART = /[`}](?:\\?[^])*?(?:`|\${)/y;
|
|
3
3
|
const REGEX_LITERAL_START = /(?<=[(=:,?&!]\s*)\//y;
|
|
4
|
-
const STOPPING_POINT = /['"`{}[\]/|]|((?<!\.\??)\b[a-zA-Z_]\w*)/g;
|
|
4
|
+
const STOPPING_POINT = /['"`{}[\]/|]|(((?<=\.\.\.)|(?<!\.\??))\b[a-zA-Z_]\w*)/g;
|
|
5
5
|
/**
|
|
6
6
|
* This function iterates over the top-level scope of a JavaScript source code
|
|
7
7
|
* string. It yields pairs of the index and the type of each top-level element
|
package/mod.js
CHANGED
|
@@ -12,6 +12,7 @@ export default function (options = {}) {
|
|
|
12
12
|
dataVarname: options.dataVarname || "it",
|
|
13
13
|
autoescape: options.autoescape ?? false,
|
|
14
14
|
autoDataVarname: options.autoDataVarname ?? true,
|
|
15
|
+
strict: options.strict ?? false,
|
|
15
16
|
});
|
|
16
17
|
// Register the default plugins
|
|
17
18
|
env.use(defaultPlugins());
|
package/package.json
CHANGED
package/plugins/include.js
CHANGED
|
@@ -28,11 +28,11 @@ function includeTag(env, token, output, tokens) {
|
|
|
28
28
|
}
|
|
29
29
|
const { dataVarname } = env.options;
|
|
30
30
|
return `{
|
|
31
|
-
const
|
|
31
|
+
const __include = await __env.run(${file},
|
|
32
32
|
{...${dataVarname}${data ? `, ...${data}` : ""}},
|
|
33
33
|
__template.path,
|
|
34
34
|
${position}
|
|
35
35
|
);
|
|
36
|
-
${output} += ${env.compileFilters(tokens, "
|
|
36
|
+
${output} += ${env.compileFilters(tokens, "__include.content")};
|
|
37
37
|
}`;
|
|
38
38
|
}
|