@lwc/template-compiler 2.6.2 → 2.7.3
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/commonjs/codegen/codegen.js +73 -3
- package/dist/commonjs/codegen/codegen.js.map +1 -1
- package/dist/commonjs/codegen/helpers.js +34 -20
- package/dist/commonjs/codegen/helpers.js.map +1 -1
- package/dist/commonjs/codegen/index.js +183 -192
- package/dist/commonjs/codegen/index.js.map +1 -1
- package/dist/commonjs/index.js +12 -5
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/parser/attribute.js +3 -3
- package/dist/commonjs/parser/attribute.js.map +1 -1
- package/dist/commonjs/parser/constants.js +1 -7
- package/dist/commonjs/parser/constants.js.map +1 -1
- package/dist/commonjs/parser/expression.js +5 -2
- package/dist/commonjs/parser/expression.js.map +1 -1
- package/dist/commonjs/parser/html.js +2 -1
- package/dist/commonjs/parser/html.js.map +1 -1
- package/dist/commonjs/parser/index.js +365 -337
- package/dist/commonjs/parser/index.js.map +1 -1
- package/dist/commonjs/parser/parser.js +85 -30
- package/dist/commonjs/parser/parser.js.map +1 -1
- package/dist/commonjs/shared/ast.js +303 -0
- package/dist/commonjs/shared/ast.js.map +1 -0
- package/dist/commonjs/shared/parse5.js +1 -15
- package/dist/commonjs/shared/parse5.js.map +1 -1
- package/dist/commonjs/shared/types.js +1 -7
- package/dist/commonjs/shared/types.js.map +1 -1
- package/dist/types/codegen/codegen.d.ts +25 -3
- package/dist/types/codegen/helpers.d.ts +11 -5
- package/dist/types/codegen/index.d.ts +2 -2
- package/dist/types/index.d.ts +1 -2
- package/dist/types/parser/attribute.d.ts +7 -7
- package/dist/types/parser/constants.d.ts +0 -6
- package/dist/types/parser/expression.d.ts +3 -4
- package/dist/types/parser/parser.d.ts +57 -28
- package/dist/types/shared/ast.d.ts +45 -0
- package/dist/types/shared/estree.d.ts +0 -2
- package/dist/types/shared/parse5.d.ts +0 -1
- package/dist/types/shared/types.d.ts +129 -86
- package/package.json +5 -5
- package/dist/commonjs/codegen/scope.js +0 -61
- package/dist/commonjs/codegen/scope.js.map +0 -1
- package/dist/commonjs/shared/ir.js +0 -90
- package/dist/commonjs/shared/ir.js.map +0 -1
- package/dist/types/codegen/scope.d.ts +0 -8
- package/dist/types/shared/ir.d.ts +0 -15
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getTemplateContent = exports.isTextNode = exports.isCommentNode = exports.isElementNode = void 0;
|
|
4
4
|
function isElementNode(node) {
|
|
5
5
|
return 'tagName' in node;
|
|
6
6
|
}
|
|
@@ -17,18 +17,4 @@ function getTemplateContent(templateElement) {
|
|
|
17
17
|
return templateElement.content;
|
|
18
18
|
}
|
|
19
19
|
exports.getTemplateContent = getTemplateContent;
|
|
20
|
-
// Creates a parse5.ElementLocation where all values are set to 0.
|
|
21
|
-
function createEmptyElementLocation() {
|
|
22
|
-
const startTag = createEmptyStartTagLocation();
|
|
23
|
-
const endTag = createEmptyLocation();
|
|
24
|
-
const elementLocation = createEmptyStartTagLocation();
|
|
25
|
-
return { ...elementLocation, startTag, endTag };
|
|
26
|
-
}
|
|
27
|
-
exports.createEmptyElementLocation = createEmptyElementLocation;
|
|
28
|
-
function createEmptyStartTagLocation() {
|
|
29
|
-
return { attrs: {}, ...createEmptyLocation() };
|
|
30
|
-
}
|
|
31
|
-
function createEmptyLocation() {
|
|
32
|
-
return { startCol: 0, startOffset: 0, startLine: 0, endCol: 0, endOffset: 0, endLine: 0 };
|
|
33
|
-
}
|
|
34
20
|
//# sourceMappingURL=parse5.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse5.js","sourceRoot":"","sources":["../../../src/shared/parse5.ts"],"names":[],"mappings":";;;AAQA,SAAgB,aAAa,CAAC,IAAiB;IAC3C,OAAO,SAAS,IAAI,IAAI,CAAC;AAC7B,CAAC;AAFD,sCAEC;AAED,SAAgB,aAAa,CAAC,IAAiB;IAC3C,OAAO,IAAI,CAAC,QAAQ,KAAK,UAAU,CAAC;AACxC,CAAC;AAFD,sCAEC;AAED,SAAgB,UAAU,CAAC,IAAiB;IACxC,OAAO,IAAI,CAAC,QAAQ,KAAK,OAAO,CAAC;AACrC,CAAC;AAFD,gCAEC;AAED,SAAgB,kBAAkB,CAC9B,eAA+B;IAE/B,OAAQ,eAAuB,CAAC,OAAO,CAAC;AAC5C,CAAC;AAJD,gDAIC
|
|
1
|
+
{"version":3,"file":"parse5.js","sourceRoot":"","sources":["../../../src/shared/parse5.ts"],"names":[],"mappings":";;;AAQA,SAAgB,aAAa,CAAC,IAAiB;IAC3C,OAAO,SAAS,IAAI,IAAI,CAAC;AAC7B,CAAC;AAFD,sCAEC;AAED,SAAgB,aAAa,CAAC,IAAiB;IAC3C,OAAO,IAAI,CAAC,QAAQ,KAAK,UAAU,CAAC;AACxC,CAAC;AAFD,sCAEC;AAED,SAAgB,UAAU,CAAC,IAAiB;IACxC,OAAO,IAAI,CAAC,QAAQ,KAAK,OAAO,CAAC;AACrC,CAAC;AAFD,gCAEC;AAED,SAAgB,kBAAkB,CAC9B,eAA+B;IAE/B,OAAQ,eAAuB,CAAC,OAAO,CAAC;AAC5C,CAAC;AAJD,gDAIC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.LWCDirectiveRenderMode = exports.LWCDirectiveDomMode = void 0;
|
|
4
4
|
var LWCDirectiveDomMode;
|
|
5
5
|
(function (LWCDirectiveDomMode) {
|
|
6
6
|
LWCDirectiveDomMode["manual"] = "manual";
|
|
@@ -10,10 +10,4 @@ var LWCDirectiveRenderMode;
|
|
|
10
10
|
LWCDirectiveRenderMode["shadow"] = "shadow";
|
|
11
11
|
LWCDirectiveRenderMode["light"] = "light";
|
|
12
12
|
})(LWCDirectiveRenderMode = exports.LWCDirectiveRenderMode || (exports.LWCDirectiveRenderMode = {}));
|
|
13
|
-
var IRAttributeType;
|
|
14
|
-
(function (IRAttributeType) {
|
|
15
|
-
IRAttributeType[IRAttributeType["Expression"] = 0] = "Expression";
|
|
16
|
-
IRAttributeType[IRAttributeType["String"] = 1] = "String";
|
|
17
|
-
IRAttributeType[IRAttributeType["Boolean"] = 2] = "Boolean";
|
|
18
|
-
})(IRAttributeType = exports.IRAttributeType || (exports.IRAttributeType = {}));
|
|
19
13
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/shared/types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/shared/types.ts"],"names":[],"mappings":";;;AAkBA,IAAY,mBAEX;AAFD,WAAY,mBAAmB;IAC3B,wCAAiB,CAAA;AACrB,CAAC,EAFW,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAE9B;AAED,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAC9B,2CAAiB,CAAA;IACjB,yCAAe,CAAA;AACnB,CAAC,EAHW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAGjC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ResolvedConfig } from '../config';
|
|
2
2
|
import * as t from '../shared/estree';
|
|
3
|
-
import {
|
|
3
|
+
import { Expression, Literal, LWCDirectiveRenderMode, Root } from '../shared/types';
|
|
4
4
|
export default class CodeGen {
|
|
5
5
|
/** The AST root. */
|
|
6
|
-
readonly root:
|
|
6
|
+
readonly root: Root;
|
|
7
7
|
/** The template render mode. */
|
|
8
8
|
readonly renderMode: LWCDirectiveRenderMode;
|
|
9
9
|
/** Indicates whether the generated code should preserve HTML comments or not. */
|
|
@@ -16,6 +16,14 @@ export default class CodeGen {
|
|
|
16
16
|
* fashion.
|
|
17
17
|
*/
|
|
18
18
|
readonly scopeFragmentId: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* The scope keeps track of the identifiers that have been seen while traversing the AST.
|
|
21
|
+
* Currently, we are keeping track of item, index and iterator on the ForEach and ForOf nodes respectively.
|
|
22
|
+
*
|
|
23
|
+
* Scope is used in bindExpression to determine if the expression is a known identifier.
|
|
24
|
+
* A known identifier exists if it exists in the scope chain.
|
|
25
|
+
*/
|
|
26
|
+
private scope;
|
|
19
27
|
currentId: number;
|
|
20
28
|
currentKey: number;
|
|
21
29
|
innerHtmlInstances: number;
|
|
@@ -27,7 +35,7 @@ export default class CodeGen {
|
|
|
27
35
|
memorizedIds: t.Identifier[];
|
|
28
36
|
referencedComponents: Set<string>;
|
|
29
37
|
constructor({ root, config, scopeFragmentId, }: {
|
|
30
|
-
root:
|
|
38
|
+
root: Root;
|
|
31
39
|
config: ResolvedConfig;
|
|
32
40
|
scopeFragmentId: boolean;
|
|
33
41
|
});
|
|
@@ -58,4 +66,18 @@ export default class CodeGen {
|
|
|
58
66
|
*/
|
|
59
67
|
genSanitizedHtmlExpr(expr: t.Expression): import("estree").LogicalExpression | import("estree").ConditionalExpression;
|
|
60
68
|
private _renderApiCall;
|
|
69
|
+
beginScope(): void;
|
|
70
|
+
private createScope;
|
|
71
|
+
endScope(): void;
|
|
72
|
+
declareIdentifier(identifier: t.Identifier): void;
|
|
73
|
+
/**
|
|
74
|
+
* Searches the scopes to find an identifier with a matching name.
|
|
75
|
+
*/
|
|
76
|
+
isLocalIdentifier(identifier: t.Identifier): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Bind the passed expression to the component instance. It applies the following transformation to the expression:
|
|
79
|
+
* - {value} --> {$cmp.value}
|
|
80
|
+
* - {value[index]} --> {$cmp.value[$cmp.index]}
|
|
81
|
+
*/
|
|
82
|
+
bindExpression(expression: Expression | Literal): t.Expression;
|
|
61
83
|
}
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import * as t from '../shared/estree';
|
|
2
|
-
import {
|
|
2
|
+
import { ChildNode, Node } from '../shared/types';
|
|
3
3
|
import CodeGen from './codegen';
|
|
4
4
|
export declare function identifierFromComponentName(name: string): t.Identifier;
|
|
5
5
|
export declare function getMemberExpressionRoot(expression: t.MemberExpression): t.Identifier;
|
|
6
6
|
export declare function objectToAST(obj: object, valueMapper: (key: string) => t.Expression): t.ObjectExpression;
|
|
7
|
-
export declare function containsDynamicChildren(children:
|
|
8
|
-
|
|
7
|
+
export declare function containsDynamicChildren(children: ChildNode[]): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Returns true if the children should be flattened.
|
|
10
|
+
*
|
|
11
|
+
* Children should be flattened if they contain an iterator,
|
|
12
|
+
* a dynamic directive or a slot inside a light dom element.
|
|
13
|
+
*/
|
|
14
|
+
export declare function shouldFlatten(codeGen: CodeGen, children: ChildNode[]): boolean;
|
|
9
15
|
/**
|
|
10
16
|
* Returns true if the AST element or any of its descendants use an id attribute.
|
|
11
17
|
*/
|
|
12
|
-
export declare function hasIdAttribute(
|
|
13
|
-
export declare function memorizeHandler(codeGen: CodeGen,
|
|
18
|
+
export declare function hasIdAttribute(node: Node): boolean;
|
|
19
|
+
export declare function memorizeHandler(codeGen: CodeGen, componentHandler: t.Expression, handler: t.Expression): t.Expression;
|
|
14
20
|
export declare function generateTemplateMetadata(codeGen: CodeGen): t.Statement[];
|
|
15
21
|
export declare function parseStyleText(cssText: string): {
|
|
16
22
|
[name: string]: string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ResolvedConfig } from '../config';
|
|
2
|
-
import {
|
|
3
|
-
export default function (root:
|
|
2
|
+
import { Root } from '../shared/types';
|
|
3
|
+
export default function (root: Root, config: ResolvedConfig): string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Config } from './config';
|
|
2
2
|
import { TemplateCompileResult, TemplateParseResult } from './shared/types';
|
|
3
|
-
export
|
|
4
|
-
export { isElement } from './shared/ir';
|
|
3
|
+
export * from './shared/types';
|
|
5
4
|
export { Config } from './config';
|
|
6
5
|
export declare function parse(source: string, config?: Config): TemplateParseResult;
|
|
7
6
|
export default function compile(source: string, config: Config): TemplateCompileResult;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as parse5 from 'parse5';
|
|
2
|
-
import {
|
|
2
|
+
import { Attribute, BaseElement, SourceLocation } from '../shared/types';
|
|
3
3
|
import ParserCtx from './parser';
|
|
4
4
|
export declare function isIdReferencingAttribute(attrName: string): boolean;
|
|
5
5
|
export declare function isAllowedFragOnlyUrlsXHTML(tagName: string, attrName: string, namespaceURI: string): boolean;
|
|
6
6
|
export declare function isSvgUseHref(tagName: string, attrName: string, namespaceURI: string): boolean;
|
|
7
7
|
export declare function isFragmentOnlyUrl(url: string): boolean;
|
|
8
|
-
export declare function normalizeAttributeValue(ctx: ParserCtx, raw: string, tag: string, attr: parse5.Attribute, location:
|
|
8
|
+
export declare function normalizeAttributeValue(ctx: ParserCtx, raw: string, tag: string, attr: parse5.Attribute, location: SourceLocation): {
|
|
9
9
|
value: string;
|
|
10
10
|
escapedExpression: boolean;
|
|
11
11
|
};
|
|
@@ -14,7 +14,7 @@ export declare function isProhibitedIsAttribute(attrName: string): boolean;
|
|
|
14
14
|
export declare function isTabIndexAttribute(attrName: string): boolean;
|
|
15
15
|
export declare function isValidTabIndexAttributeValue(value: any): boolean;
|
|
16
16
|
export declare function isAriaOrDataOrFmkAttribute(attrName: string): boolean;
|
|
17
|
-
export declare function isAttribute(element:
|
|
17
|
+
export declare function isAttribute(element: BaseElement, attrName: string): boolean;
|
|
18
18
|
export declare function isValidHTMLAttribute(tagName: string, attrName: string): boolean;
|
|
19
19
|
/**
|
|
20
20
|
* Convert attribute name from kebab case to camel case property name
|
|
@@ -22,9 +22,9 @@ export declare function isValidHTMLAttribute(tagName: string, attrName: string):
|
|
|
22
22
|
export declare function attributeToPropertyName(attrName: string): string;
|
|
23
23
|
export declare class ParsedAttribute {
|
|
24
24
|
private readonly attributes;
|
|
25
|
-
append(attr:
|
|
26
|
-
get(pattern: string | RegExp):
|
|
27
|
-
pick(pattern: string | RegExp):
|
|
25
|
+
append(attr: Attribute): void;
|
|
26
|
+
get(pattern: string | RegExp): Attribute | undefined;
|
|
27
|
+
pick(pattern: string | RegExp): Attribute | undefined;
|
|
28
28
|
private getKey;
|
|
29
|
-
getAttributes():
|
|
29
|
+
getAttributes(): Attribute[];
|
|
30
30
|
}
|
|
@@ -11,16 +11,10 @@ export declare const LWC_DIRECTIVES: {
|
|
|
11
11
|
INNER_HTML: string;
|
|
12
12
|
};
|
|
13
13
|
export declare const LWC_DIRECTIVE_SET: Set<string>;
|
|
14
|
-
export declare const FOR_DIRECTIVES: {
|
|
15
|
-
FOR_EACH: string;
|
|
16
|
-
FOR_ITEM: string;
|
|
17
|
-
FOR_INDEX: string;
|
|
18
|
-
};
|
|
19
14
|
export declare const ROOT_TEMPLATE_DIRECTIVES: {
|
|
20
15
|
PRESERVE_COMMENTS: string;
|
|
21
16
|
RENDER_MODE: string;
|
|
22
17
|
};
|
|
23
|
-
export declare const ROOT_TEMPLATE_DIRECTIVES_SET: Set<string>;
|
|
24
18
|
export declare const ID_REFERENCING_ATTRIBUTES_SET: Set<string>;
|
|
25
19
|
export declare const DATA_RE: RegExp;
|
|
26
20
|
export declare const SUPPORTED_SVG_TAGS: Set<string>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { Location } from 'parse5';
|
|
2
|
-
import { TemplateExpression, TemplateIdentifier } from '../shared/types';
|
|
3
1
|
import ParserCtx from './parser';
|
|
2
|
+
import { Expression, Identifier, SourceLocation } from '../shared/types';
|
|
4
3
|
export declare const EXPRESSION_SYMBOL_START = "{";
|
|
5
4
|
export declare const EXPRESSION_SYMBOL_END = "}";
|
|
6
5
|
export declare function isExpression(source: string): boolean;
|
|
7
6
|
export declare function isPotentialExpression(source: string): boolean;
|
|
8
|
-
export declare function parseExpression(ctx: ParserCtx, source: string, location:
|
|
9
|
-
export declare function parseIdentifier(ctx: ParserCtx, source: string, location:
|
|
7
|
+
export declare function parseExpression(ctx: ParserCtx, source: string, location: SourceLocation): Expression;
|
|
8
|
+
export declare function parseIdentifier(ctx: ParserCtx, source: string, location: SourceLocation): Identifier;
|
|
@@ -1,28 +1,59 @@
|
|
|
1
|
-
import * as parse5 from 'parse5';
|
|
2
1
|
import { CompilerDiagnostic, LWCErrorInfo } from '@lwc/errors';
|
|
3
|
-
import { IRElement, LWCDirectiveRenderMode, IRBaseAttribute, IRNode } from '../shared/types';
|
|
4
2
|
import { ResolvedConfig } from '../config';
|
|
3
|
+
import { Root, SourceLocation, ParentNode, BaseNode, LWCDirectiveRenderMode } from '../shared/types';
|
|
4
|
+
interface ParentWrapper {
|
|
5
|
+
parent: ParentNode | null;
|
|
6
|
+
current: ParentNode;
|
|
7
|
+
}
|
|
5
8
|
export default class ParserCtx {
|
|
6
9
|
private readonly source;
|
|
7
10
|
readonly config: ResolvedConfig;
|
|
8
11
|
readonly warnings: CompilerDiagnostic[];
|
|
9
12
|
readonly seenIds: Set<string>;
|
|
10
13
|
readonly seenSlots: Set<string>;
|
|
11
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Scopes keep track of the hierarchy of ParentNodes as the parser traverses the parse5 AST.
|
|
16
|
+
* Each scope is represented by an array where each node in the array correspond to either
|
|
17
|
+
* a ForEach, ForOf, If, Element, Component, or Slot.
|
|
18
|
+
*
|
|
19
|
+
* Currently, each scope has a hierarchy of ForBlock > IfBlock > Element | Component | Slot.
|
|
20
|
+
* Note: Not all scopes will have all three, but when they do, they will appear in this order.
|
|
21
|
+
* We do not keep track of template nodes.
|
|
22
|
+
*
|
|
23
|
+
* Each scope corresponds to the original parse5.Element node.
|
|
24
|
+
*/
|
|
25
|
+
private readonly scopes;
|
|
26
|
+
renderMode: LWCDirectiveRenderMode;
|
|
27
|
+
preserveComments: boolean;
|
|
12
28
|
constructor(source: String, config: ResolvedConfig);
|
|
13
29
|
getSource(start: number, end: number): string;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
30
|
+
setRootDirective(root: Root): void;
|
|
31
|
+
/**
|
|
32
|
+
* This method flattens the scopes into a single array for traversal.
|
|
33
|
+
*/
|
|
34
|
+
ancestors(element?: ParentNode): IterableIterator<ParentWrapper>;
|
|
35
|
+
/**
|
|
36
|
+
* This method returns an iterator over ancestor nodes, starting at the parent and ending at the root node.
|
|
37
|
+
*
|
|
38
|
+
* Note: There are instances when we want to terminate the traversal early, such as searching for a ForBlock parent.
|
|
39
|
+
*
|
|
40
|
+
* @param {ParentNode} startNode - Starting node to begin search, defaults to the tail of the current scope.
|
|
41
|
+
* @param {function} predicate - This callback is called once for each ancestor until it finds one where predicate returns true.
|
|
42
|
+
* @param {function} traversalCond - This callback is called after predicate and will terminate the traversal if it returns false.
|
|
43
|
+
* traversalCond is ignored if no value is provided.
|
|
44
|
+
*/
|
|
45
|
+
findAncestor<A extends ParentNode>(predicate: (node: ParentNode) => node is A, traversalCond?: (nodes: ParentWrapper) => unknown, startNode?: ParentNode): A | null;
|
|
46
|
+
/**
|
|
47
|
+
* This method searchs the current scope and returns the value that satisfies the predicate.
|
|
48
|
+
*
|
|
49
|
+
* @param {function} predicate - This callback is called once for each sibling in the current scope
|
|
50
|
+
* until it finds one where predicate returns true.
|
|
51
|
+
*/
|
|
52
|
+
findSibling<A extends ParentNode>(predicate: (node: ParentNode) => node is A): A | null;
|
|
53
|
+
beginScope(): void;
|
|
54
|
+
endScope(): void;
|
|
55
|
+
addNodeCurrentScope(node: ParentNode): void;
|
|
56
|
+
private currentScope;
|
|
26
57
|
/**
|
|
27
58
|
* This method recovers from diagnostic errors that are encountered when fn is invoked.
|
|
28
59
|
* All other errors are considered compiler errors and can not be recovered from.
|
|
@@ -30,34 +61,32 @@ export default class ParserCtx {
|
|
|
30
61
|
* @param fn - method to be invoked.
|
|
31
62
|
*/
|
|
32
63
|
withErrorRecovery<T>(fn: () => T): T | undefined;
|
|
33
|
-
withErrorWrapping<T>(fn: () => T, errorInfo: LWCErrorInfo, location:
|
|
34
|
-
throwOnError(errorInfo: LWCErrorInfo, error: any, location?:
|
|
64
|
+
withErrorWrapping<T>(fn: () => T, errorInfo: LWCErrorInfo, location: SourceLocation, msgFormatter?: (error: any) => string): T;
|
|
65
|
+
throwOnError(errorInfo: LWCErrorInfo, error: any, location?: SourceLocation): never;
|
|
35
66
|
/**
|
|
36
|
-
* This method throws a diagnostic error with the
|
|
67
|
+
* This method throws a diagnostic error with the node's location.
|
|
37
68
|
*/
|
|
38
|
-
|
|
69
|
+
throwOnNode(errorInfo: LWCErrorInfo, node: BaseNode, messageArgs?: any[]): never;
|
|
39
70
|
/**
|
|
40
71
|
* This method throws a diagnostic error with location information.
|
|
41
72
|
*/
|
|
42
|
-
throwAtLocation(errorInfo: LWCErrorInfo, location:
|
|
73
|
+
throwAtLocation(errorInfo: LWCErrorInfo, location: SourceLocation, messageArgs?: any[]): never;
|
|
43
74
|
/**
|
|
44
75
|
* This method throws a diagnostic error and will immediately exit the current routine.
|
|
45
76
|
*/
|
|
46
|
-
throw(errorInfo: LWCErrorInfo, messageArgs?: any[], location?:
|
|
77
|
+
throw(errorInfo: LWCErrorInfo, messageArgs?: any[], location?: SourceLocation): never;
|
|
47
78
|
/**
|
|
48
|
-
* This method logs a diagnostic warning with the
|
|
79
|
+
* This method logs a diagnostic warning with the node's location.
|
|
49
80
|
*/
|
|
50
|
-
|
|
81
|
+
warnOnNode(errorInfo: LWCErrorInfo, node: BaseNode, messageArgs?: any[]): void;
|
|
51
82
|
/**
|
|
52
83
|
* This method logs a diagnostic warning with location information.
|
|
53
84
|
*/
|
|
54
|
-
warnAtLocation(errorInfo: LWCErrorInfo, location:
|
|
85
|
+
warnAtLocation(errorInfo: LWCErrorInfo, location: SourceLocation, messageArgs?: any[]): void;
|
|
55
86
|
/**
|
|
56
87
|
* This method logs a diagnostic warning and will continue execution of the current routine.
|
|
57
88
|
*/
|
|
58
|
-
warn(errorInfo: LWCErrorInfo, messageArgs?: any[], location?:
|
|
89
|
+
warn(errorInfo: LWCErrorInfo, messageArgs?: any[], location?: SourceLocation): void;
|
|
59
90
|
private addDiagnostic;
|
|
60
|
-
getRoot(element: IRElement): IRElement;
|
|
61
|
-
getRenderMode(element: IRElement): LWCDirectiveRenderMode;
|
|
62
|
-
getPreserveComments(element: IRElement): boolean;
|
|
63
91
|
}
|
|
92
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as parse5 from 'parse5';
|
|
2
|
+
import { Literal, SourceLocation, Element, Component, Expression, Comment, Text, ForEach, ForBlock, Slot, Identifier, Root, EventListener, KeyDirective, DynamicDirective, DomDirective, PreserveCommentsDirective, RenderModeDirective, Attribute, Property, ParentNode, BaseNode, ForOf, LWCDirectiveRenderMode, If, ElementSourceLocation, InnerHTMLDirective, Directive, BaseElement, LWCDirectiveDomMode } from './types';
|
|
3
|
+
export declare function root(parse5ElmLocation: parse5.ElementLocation): Root;
|
|
4
|
+
export declare function element(parse5Elm: parse5.Element, parse5ElmLocation: parse5.ElementLocation): Element;
|
|
5
|
+
export declare function component(parse5Elm: parse5.Element, parse5ElmLocation: parse5.ElementLocation): Component;
|
|
6
|
+
export declare function slot(slotName: string, parse5ElmLocation: parse5.ElementLocation): Slot;
|
|
7
|
+
export declare function text(value: Literal | Expression, parse5Location: parse5.Location): Text;
|
|
8
|
+
export declare function comment(value: string, parse5Location: parse5.Location): Comment;
|
|
9
|
+
export declare function elementSourceLocation(parse5ElmLocation: parse5.ElementLocation): ElementSourceLocation;
|
|
10
|
+
export declare function sourceLocation(location: parse5.Location): SourceLocation;
|
|
11
|
+
export declare function literal<T extends string | boolean>(value: T): Literal<T>;
|
|
12
|
+
export declare function forEach(expression: Expression, elementLocation: SourceLocation, directiveLocation: SourceLocation, item: Identifier, index?: Identifier): ForEach;
|
|
13
|
+
export declare function forOf(expression: Expression, iterator: Identifier, elementLocation: SourceLocation, directiveLocation: SourceLocation): ForOf;
|
|
14
|
+
export declare function ifNode(modifier: string, condition: Expression, elementLocation: SourceLocation, directiveLocation: SourceLocation): If;
|
|
15
|
+
export declare function eventListener(name: string, handler: Expression, location: SourceLocation): EventListener;
|
|
16
|
+
export declare function keyDirective(value: Expression, location: SourceLocation): KeyDirective;
|
|
17
|
+
export declare function dynamicDirective(value: Expression, location: SourceLocation): DynamicDirective;
|
|
18
|
+
export declare function domDirective(lwcDomAttr: LWCDirectiveDomMode, location: SourceLocation): DomDirective;
|
|
19
|
+
export declare function innerHTMLDirective(value: Expression | Literal<string>, location: SourceLocation): InnerHTMLDirective;
|
|
20
|
+
export declare function preserveCommentsDirective(preserveComments: boolean, location: SourceLocation): PreserveCommentsDirective;
|
|
21
|
+
export declare function renderModeDirective(renderMode: LWCDirectiveRenderMode, location: SourceLocation): RenderModeDirective;
|
|
22
|
+
export declare function attribute(name: string, value: Expression | Literal, location: SourceLocation): Attribute;
|
|
23
|
+
export declare function property(name: string, attributeName: string, value: Expression | Literal, location: SourceLocation): Property;
|
|
24
|
+
export declare function isElement(node: BaseNode): node is Element;
|
|
25
|
+
export declare function isRoot(node: BaseNode): node is Root;
|
|
26
|
+
export declare function isComponent(node: BaseNode): node is Component;
|
|
27
|
+
export declare function isSlot(node: BaseNode): node is Slot;
|
|
28
|
+
export declare function isBaseElement(node: BaseNode): node is BaseElement;
|
|
29
|
+
export declare function isText(node: BaseNode): node is Text;
|
|
30
|
+
export declare function isComment(node: BaseNode): node is Comment;
|
|
31
|
+
export declare function isExpression(node: Expression | Literal): node is Expression;
|
|
32
|
+
export declare function isStringLiteral(node: Expression | Literal): node is Literal<string>;
|
|
33
|
+
export declare function isBooleanLiteral(node: Expression | Literal): node is Literal<boolean>;
|
|
34
|
+
export declare function isForOf(node: BaseNode): node is ForOf;
|
|
35
|
+
export declare function isForEach(node: BaseNode): node is ForEach;
|
|
36
|
+
export declare function isForBlock(node: BaseNode): node is ForBlock;
|
|
37
|
+
export declare function isIf(node: BaseNode): node is If;
|
|
38
|
+
export declare function isParentNode(node: BaseNode): node is ParentNode;
|
|
39
|
+
export declare function isDynamicDirective(directive: Directive): directive is DynamicDirective;
|
|
40
|
+
export declare function isDomDirective(directive: Directive): directive is DomDirective;
|
|
41
|
+
export declare function isInnerHTMLDirective(directive: Directive): directive is InnerHTMLDirective;
|
|
42
|
+
export declare function isKeyDirective(directive: Directive): directive is KeyDirective;
|
|
43
|
+
export declare function isRenderModeDirective(directive: Directive): directive is RenderModeDirective;
|
|
44
|
+
export declare function isPreserveCommentsDirective(directive: Directive): directive is PreserveCommentsDirective;
|
|
45
|
+
export declare function isProperty(node: BaseNode): node is Property;
|
|
@@ -52,8 +52,6 @@ export declare type BlockStatement = t.BlockStatement;
|
|
|
52
52
|
export declare type ReturnStatement = t.ReturnStatement;
|
|
53
53
|
export declare type VariableDeclarator = t.VariableDeclarator;
|
|
54
54
|
export declare type VariableDeclaration = t.VariableDeclaration;
|
|
55
|
-
export declare type TemplateLiteral = t.TemplateLiteral;
|
|
56
|
-
export declare type TemplateElement = t.TemplateElement;
|
|
57
55
|
export declare type ImportDeclaration = t.ImportDeclaration;
|
|
58
56
|
export declare type ImportDefaultSpecifier = t.ImportDefaultSpecifier;
|
|
59
57
|
export declare type ImportSpecifier = t.ImportSpecifier;
|
|
@@ -3,4 +3,3 @@ export declare function isElementNode(node: parse5.Node): node is parse5.Element
|
|
|
3
3
|
export declare function isCommentNode(node: parse5.Node): node is parse5.CommentNode;
|
|
4
4
|
export declare function isTextNode(node: parse5.Node): node is parse5.TextNode;
|
|
5
5
|
export declare function getTemplateContent(templateElement: parse5.Element): parse5.DocumentFragment | undefined;
|
|
6
|
-
export declare function createEmptyElementLocation(): parse5.ElementLocation;
|