@lwc/template-compiler 6.1.1 → 6.2.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/dist/codegen/codegen.d.ts +8 -2
- package/dist/codegen/expression.d.ts +10 -8
- package/dist/codegen/formatters/module.d.ts +2 -1
- package/dist/codegen/helpers.d.ts +3 -0
- package/dist/codegen/optimize.d.ts +1 -0
- package/dist/config.d.ts +14 -13
- package/dist/index.cjs.js +335 -170
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +12 -0
- package/dist/index.js +335 -170
- package/dist/index.js.map +1 -1
- package/dist/parser/attribute.d.ts +1 -0
- package/dist/parser/expression-complex/html.d.ts +3 -5
- package/dist/parser/parser.d.ts +27 -9
- package/dist/shared/utils.d.ts +2 -0
- package/package.json +3 -3
|
@@ -69,10 +69,15 @@ export default class CodeGen {
|
|
|
69
69
|
genScopedFragId(id: string | t.Expression): t.CallExpression;
|
|
70
70
|
/**
|
|
71
71
|
* Generates childs vnodes when slot content is static.
|
|
72
|
+
* @param slotName
|
|
73
|
+
* @param data
|
|
74
|
+
* @param children
|
|
72
75
|
*/
|
|
73
76
|
getSlot(slotName: string, data: t.ObjectExpression, children: t.Expression): import("estree").CallExpression;
|
|
74
77
|
/**
|
|
75
78
|
* Generates a factory function that inturn generates child vnodes for scoped slot content.
|
|
79
|
+
* @param callback
|
|
80
|
+
* @param slotName
|
|
76
81
|
*/
|
|
77
82
|
getScopedSlotFactory(callback: t.FunctionExpression, slotName: t.Expression | t.SimpleLiteral): import("estree").CallExpression;
|
|
78
83
|
genTabIndex(children: [t.Expression]): import("estree").CallExpression;
|
|
@@ -84,9 +89,8 @@ export default class CodeGen {
|
|
|
84
89
|
* This routine generates an expression that avoids
|
|
85
90
|
* computing the sanitized html of a raw html if it does not change
|
|
86
91
|
* between renders.
|
|
87
|
-
*
|
|
88
92
|
* @param expr
|
|
89
|
-
* @returns
|
|
93
|
+
* @returns The generated expression
|
|
90
94
|
*/
|
|
91
95
|
genSanitizedHtmlExpr(expr: t.Expression): import("estree").ConditionalExpression | import("estree").LogicalExpression;
|
|
92
96
|
private _renderApiCall;
|
|
@@ -96,12 +100,14 @@ export default class CodeGen {
|
|
|
96
100
|
declareIdentifier(identifier: t.Identifier): void;
|
|
97
101
|
/**
|
|
98
102
|
* Searches the scopes to find an identifier with a matching name.
|
|
103
|
+
* @param identifier
|
|
99
104
|
*/
|
|
100
105
|
isLocalIdentifier(identifier: t.Identifier): boolean;
|
|
101
106
|
/**
|
|
102
107
|
* Bind the passed expression to the component instance. It applies the following transformation to the expression:
|
|
103
108
|
* - {value} --> {$cmp.value}
|
|
104
109
|
* - {value[index]} --> {$cmp.value[$cmp.index]}
|
|
110
|
+
* @param expression
|
|
105
111
|
*/
|
|
106
112
|
bindExpression(expression: Expression | Literal | ComplexExpression): t.Expression;
|
|
107
113
|
genStaticElement(element: StaticElement, slotParentName?: string): t.Expression;
|
|
@@ -4,20 +4,22 @@ import type CodeGen from './codegen';
|
|
|
4
4
|
/**
|
|
5
5
|
* Bind the passed expression to the component instance. It applies the following
|
|
6
6
|
* transformation to the expression:
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* - `{value}` --> `{$cmp.value}`
|
|
8
|
+
* - `{value[index]}` --> `{$cmp.value[$cmp.index]}`
|
|
9
|
+
* - `{foo ?? bar}` --> `{$cmp.foo ?? $cmp.bar}`
|
|
10
|
+
* - `{foo?.bar}` --> `{$cmp.foo?.bar}`
|
|
11
11
|
*
|
|
12
12
|
* However, parameter variables are not be transformed in this way. For example,
|
|
13
13
|
* the following transformations do not happen:
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* - `{(foo) => foo && bar}` --> `{(foo) => $cmp.foo && $cmp.bar}`
|
|
15
|
+
* - `{(foo) => foo && bar}` --> `{($cmp.foo) => foo && $cmp.bar}`
|
|
16
|
+
* - `{(foo) => foo && bar}` --> `{($cmp.foo) => $cmp.foo && $cmp.bar}`
|
|
17
17
|
*
|
|
18
18
|
* Instead, the scopes are respected:
|
|
19
|
-
*
|
|
19
|
+
* - `{(foo) => foo && $cmp.bar}`
|
|
20
20
|
*
|
|
21
21
|
* Similar checks occur for local identifiers introduced via for:each or similar.
|
|
22
|
+
* @param expression
|
|
23
|
+
* @param codeGen
|
|
22
24
|
*/
|
|
23
25
|
export declare function bindComplexExpression(expression: ComplexExpression, codeGen: CodeGen): t.Expression;
|
|
@@ -4,7 +4,8 @@ import CodeGen from '../codegen';
|
|
|
4
4
|
* Generate an ES module AST from a template ESTree AST. The generated module imports the dependent
|
|
5
5
|
* LWC components via import statements and expose the template function via a default export
|
|
6
6
|
* statement.
|
|
7
|
-
*
|
|
7
|
+
* @param templateFn
|
|
8
|
+
* @param codeGen
|
|
8
9
|
* @example
|
|
9
10
|
* ```js
|
|
10
11
|
* import { registerTemplate } from 'lwc';
|
|
@@ -10,10 +10,13 @@ export declare function objectToAST(obj: object, valueMapper: (key: string) => t
|
|
|
10
10
|
*
|
|
11
11
|
* This function searches through the children to determine if flattening needs to occur in the runtime.
|
|
12
12
|
* Children should be flattened if they contain an iterator, a dynamic directive or a slot inside a light dom element.
|
|
13
|
+
* @param codeGen
|
|
14
|
+
* @param children
|
|
13
15
|
*/
|
|
14
16
|
export declare function shouldFlatten(codeGen: CodeGen, children: ChildNode[]): boolean;
|
|
15
17
|
/**
|
|
16
18
|
* Returns true if the AST element or any of its descendants use an id attribute.
|
|
19
|
+
* @param node
|
|
17
20
|
*/
|
|
18
21
|
export declare function hasIdAttribute(node: Node): boolean;
|
|
19
22
|
export declare function memorizeHandler(codeGen: CodeGen, componentHandler: t.Expression, handler: t.Expression): t.Expression;
|
package/dist/config.d.ts
CHANGED
|
@@ -6,23 +6,24 @@ export interface Config {
|
|
|
6
6
|
*/
|
|
7
7
|
customRendererConfig?: CustomRendererConfig;
|
|
8
8
|
/**
|
|
9
|
-
* Enable computed member expression in the template.
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* Enable computed member expression in the template.
|
|
10
|
+
* @example
|
|
11
|
+
* <template>
|
|
12
|
+
* {list[0].name}
|
|
13
|
+
* </template>
|
|
13
14
|
*/
|
|
14
15
|
experimentalComputedMemberExpression?: boolean;
|
|
15
16
|
/**
|
|
16
17
|
* Enable use of (a subset of) JavaScript expressions in place of template bindings.
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
18
|
+
* @example
|
|
19
|
+
* <template>
|
|
20
|
+
* <input
|
|
21
|
+
* attr={complex ?? expressions()}
|
|
22
|
+
* onchange={({ target }) => componentMethod(target.value)}
|
|
23
|
+
* >
|
|
24
|
+
* Hey there {inAustralia ? 'mate' : 'friend'}
|
|
25
|
+
* </input>
|
|
26
|
+
* </template>
|
|
26
27
|
*/
|
|
27
28
|
experimentalComplexExpressions?: boolean;
|
|
28
29
|
/**
|