@lwc/template-compiler 2.15.0 → 2.18.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.
- package/README.md +33 -1
- package/dist/commonjs/codegen/codegen.js +5 -4
- package/dist/commonjs/codegen/codegen.js.map +1 -1
- package/dist/commonjs/codegen/helpers.js +7 -5
- package/dist/commonjs/codegen/helpers.js.map +1 -1
- package/dist/commonjs/codegen/index.js +22 -9
- package/dist/commonjs/codegen/index.js.map +1 -1
- package/dist/commonjs/config.js +36 -2
- package/dist/commonjs/config.js.map +1 -1
- package/dist/commonjs/index.js +1 -1
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/parser/attribute.js +14 -13
- package/dist/commonjs/parser/attribute.js.map +1 -1
- package/dist/commonjs/parser/constants.js +32 -11
- package/dist/commonjs/parser/constants.js.map +1 -1
- package/dist/commonjs/parser/index.js +28 -26
- package/dist/commonjs/parser/index.js.map +1 -1
- package/dist/commonjs/parser/tag.js +15 -0
- package/dist/commonjs/parser/tag.js.map +1 -0
- package/dist/commonjs/shared/constants.js +12 -1
- package/dist/commonjs/shared/constants.js.map +1 -1
- package/dist/commonjs/shared/renderer-hooks.js +68 -0
- package/dist/commonjs/shared/renderer-hooks.js.map +1 -0
- package/dist/commonjs/shared/utils.js +11 -1
- package/dist/commonjs/shared/utils.js.map +1 -1
- package/dist/commonjs/state.js +9 -0
- package/dist/commonjs/state.js.map +1 -1
- package/dist/types/codegen/codegen.d.ts +7 -3
- package/dist/types/codegen/helpers.d.ts +2 -1
- package/dist/types/codegen/index.d.ts +2 -2
- package/dist/types/config.d.ts +8 -3
- package/dist/types/index.d.ts +1 -0
- package/dist/types/parser/constants.d.ts +13 -1
- package/dist/types/parser/tag.d.ts +2 -0
- package/dist/types/shared/constants.d.ts +2 -0
- package/dist/types/shared/renderer-hooks.d.ts +43 -0
- package/dist/types/shared/utils.d.ts +6 -0
- package/dist/types/state.d.ts +18 -0
- package/package.json +3 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as t from '../shared/estree';
|
|
2
2
|
import { ChildNode, Node, Root } from '../shared/types';
|
|
3
|
+
import State from '../state';
|
|
3
4
|
import CodeGen from './codegen';
|
|
4
5
|
export declare function identifierFromComponentName(name: string): t.Identifier;
|
|
5
6
|
export declare function getMemberExpressionRoot(expression: t.MemberExpression): t.Identifier;
|
|
@@ -25,4 +26,4 @@ export declare function styleMapToStyleDeclsAST(styleMap: {
|
|
|
25
26
|
[name: string]: string;
|
|
26
27
|
}): t.ArrayExpression;
|
|
27
28
|
export declare function parseClassNames(classNames: string): string[];
|
|
28
|
-
export declare function getStaticNodes(root: Root): Set<ChildNode>;
|
|
29
|
+
export declare function getStaticNodes(root: Root, state: State): Set<ChildNode>;
|
package/dist/types/config.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
import { CustomRendererConfig } from './shared/renderer-hooks';
|
|
1
2
|
export interface Config {
|
|
3
|
+
/**
|
|
4
|
+
* Specification to use to determine which nodes in the template require custom renderer hooks.
|
|
5
|
+
*/
|
|
6
|
+
customRendererConfig?: CustomRendererConfig;
|
|
2
7
|
/**
|
|
3
8
|
* Enable computed member expression in the template. eg:
|
|
4
9
|
* <template>
|
|
@@ -15,9 +20,9 @@ export interface Config {
|
|
|
15
20
|
*/
|
|
16
21
|
preserveHtmlComments?: boolean;
|
|
17
22
|
/**
|
|
18
|
-
* When
|
|
23
|
+
* When false, the template compiler will not generate optimized code for static content.
|
|
19
24
|
*/
|
|
20
|
-
|
|
25
|
+
enableStaticContentOptimization?: boolean;
|
|
21
26
|
}
|
|
22
|
-
export declare type NormalizedConfig = Required<Config
|
|
27
|
+
export declare type NormalizedConfig = Required<Omit<Config, 'customRendererConfig'>> & Partial<Pick<Config, 'customRendererConfig'>>;
|
|
23
28
|
export declare function normalizeConfig(config: Config): NormalizedConfig;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Config } from './config';
|
|
2
2
|
import { TemplateCompileResult, TemplateParseResult } from './shared/types';
|
|
3
3
|
export * from './shared/types';
|
|
4
|
+
export { CustomRendererConfig, CustomRendererElementConfig } from './shared/renderer-hooks';
|
|
4
5
|
export { Config } from './config';
|
|
5
6
|
export declare function parse(source: string, config?: Config): TemplateParseResult;
|
|
6
7
|
export default function compile(source: string, config: Config): TemplateCompileResult;
|
|
@@ -20,7 +20,6 @@ export declare const DATA_RE: RegExp;
|
|
|
20
20
|
export declare const SUPPORTED_SVG_TAGS: Set<string>;
|
|
21
21
|
export declare const DISALLOWED_MATHML_TAGS: Set<string>;
|
|
22
22
|
export declare const VOID_ELEMENT_SET: Set<string>;
|
|
23
|
-
export declare const DASHED_TAGNAME_ELEMENT_SET: Set<string>;
|
|
24
23
|
export declare const ATTRS_PROPS_TRANFORMS: {
|
|
25
24
|
[name: string]: string;
|
|
26
25
|
};
|
|
@@ -32,6 +31,18 @@ export declare const KNOWN_HTML_ELEMENTS: Set<string>;
|
|
|
32
31
|
export declare const HTML_TAG: {
|
|
33
32
|
A: string;
|
|
34
33
|
AREA: string;
|
|
34
|
+
BODY: string;
|
|
35
|
+
CAPTION: string;
|
|
36
|
+
COL: string;
|
|
37
|
+
COLGROUP: string;
|
|
38
|
+
HEAD: string;
|
|
39
|
+
HTML: string;
|
|
40
|
+
TBODY: string;
|
|
41
|
+
TD: string;
|
|
42
|
+
TFOOT: string;
|
|
43
|
+
TH: string;
|
|
44
|
+
THEAD: string;
|
|
45
|
+
TR: string;
|
|
35
46
|
USE: string;
|
|
36
47
|
};
|
|
37
48
|
export declare const ATTR_NAME: {
|
|
@@ -39,3 +50,4 @@ export declare const ATTR_NAME: {
|
|
|
39
50
|
XLINK_HREF: string;
|
|
40
51
|
};
|
|
41
52
|
export declare const TEMPLATE_DIRECTIVES: RegExp[];
|
|
53
|
+
export declare const TAGS_THAT_CANNOT_BE_PARSED_AS_TOP_LEVEL: Set<string>;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export declare const SECURE_REGISTER_TEMPLATE_METHOD_NAME = "registerTemplate";
|
|
2
2
|
export declare const PARSE_FRAGMENT_METHOD_NAME = "parseFragment";
|
|
3
3
|
export declare const PARSE_SVG_FRAGMENT_METHOD_NAME = "parseSVGFragment";
|
|
4
|
+
export declare const RENDERER = "renderer";
|
|
4
5
|
export declare const LWC_MODULE_NAME = "lwc";
|
|
5
6
|
export declare const TEMPLATE_MODULES_PARAMETER: string;
|
|
6
7
|
export declare const TEMPLATE_FUNCTION_NAME: string;
|
|
7
8
|
export declare const TEMPLATE_PARAMS: {
|
|
8
9
|
[label: string]: string;
|
|
9
10
|
};
|
|
11
|
+
export declare const DASHED_TAGNAME_ELEMENT_SET: Set<string>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import State from '../state';
|
|
2
|
+
import { BaseElement, ElementDirective } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Config representing criteria for an element match.
|
|
5
|
+
* All conditions specified must be satisfied to be considered a match.
|
|
6
|
+
*/
|
|
7
|
+
export interface CustomRendererElementConfig {
|
|
8
|
+
/**
|
|
9
|
+
* Tag name to use to match an element.
|
|
10
|
+
*/
|
|
11
|
+
tagName: string;
|
|
12
|
+
/**
|
|
13
|
+
* Optional namespace to match an element.
|
|
14
|
+
*/
|
|
15
|
+
namespace?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Specify attributes that need to be matched.
|
|
18
|
+
* This field is optional.
|
|
19
|
+
* If undefined or empty, attribute matching is skipped.
|
|
20
|
+
*/
|
|
21
|
+
attributes?: string[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Config to specify which elements and directives require a customizable renderer.
|
|
25
|
+
* An element is qualified if it matches the CustomRendererElementConfig OR the directives.
|
|
26
|
+
*/
|
|
27
|
+
export interface CustomRendererConfig {
|
|
28
|
+
/**
|
|
29
|
+
* Element matching criteria. Element much satisfy all conditions of the CustomRendererElementConfig
|
|
30
|
+
*/
|
|
31
|
+
elements: CustomRendererElementConfig[];
|
|
32
|
+
/**
|
|
33
|
+
* List of lwc directives that qualify an element. An element must use at least 1
|
|
34
|
+
* directive to be considered a match.
|
|
35
|
+
* If empty, elements matching is not done based on directives.
|
|
36
|
+
*/
|
|
37
|
+
directives: string[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Mapping of Directive.name to string literals used in template
|
|
41
|
+
*/
|
|
42
|
+
export declare const LWC_DIRECTIVES: Record<ElementDirective['name'], string>;
|
|
43
|
+
export declare function isCustomRendererHookRequired(element: BaseElement, state: State): boolean;
|
|
@@ -1 +1,7 @@
|
|
|
1
1
|
export declare function toPropertyName(attr: string): string;
|
|
2
|
+
/**
|
|
3
|
+
* Test if given tag name is a custom element.
|
|
4
|
+
* @param tagName element tag name to test
|
|
5
|
+
* @returns true if given tag name represents a custom element, false otherwise.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isCustomElementTag(tagName: string): boolean;
|
package/dist/types/state.d.ts
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
import { NormalizedConfig } from './config';
|
|
2
|
+
import { BaseElement } from './shared/types';
|
|
2
3
|
export default class State {
|
|
3
4
|
config: NormalizedConfig;
|
|
5
|
+
/**
|
|
6
|
+
* Look up custom renderer config by tag name.
|
|
7
|
+
*/
|
|
8
|
+
crElmToConfigMap: {
|
|
9
|
+
[tagName: string]: {
|
|
10
|
+
namespace: string | undefined;
|
|
11
|
+
attributes: Set<string>;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Look up for directives that require custom renderer
|
|
16
|
+
*/
|
|
17
|
+
crDirectives: Set<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Cache the result of elements that have already been checked if they require custom renderer
|
|
20
|
+
*/
|
|
21
|
+
crCheckedElements: Map<BaseElement, boolean>;
|
|
4
22
|
constructor(config: NormalizedConfig);
|
|
5
23
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lwc/template-compiler",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.18.0",
|
|
4
4
|
"description": "Template compiler package",
|
|
5
5
|
"homepage": "https://lwc.dev/",
|
|
6
6
|
"repository": {
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
},
|
|
27
27
|
"//": "Currently can't upgrade estree-walker to v3.0.0 because it dropped CommonJS support: https://git.io/JXguS",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@lwc/errors": "2.
|
|
30
|
-
"@lwc/shared": "2.
|
|
29
|
+
"@lwc/errors": "2.18.0",
|
|
30
|
+
"@lwc/shared": "2.18.0",
|
|
31
31
|
"acorn": "~8.7.1",
|
|
32
32
|
"astring": "~1.8.3",
|
|
33
33
|
"estree-walker": "~2.0.2",
|