@lwc/template-compiler 2.15.0 → 2.16.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.
Files changed (35) hide show
  1. package/README.md +33 -1
  2. package/dist/commonjs/codegen/codegen.js +5 -4
  3. package/dist/commonjs/codegen/codegen.js.map +1 -1
  4. package/dist/commonjs/codegen/helpers.js +7 -5
  5. package/dist/commonjs/codegen/helpers.js.map +1 -1
  6. package/dist/commonjs/codegen/index.js +17 -8
  7. package/dist/commonjs/codegen/index.js.map +1 -1
  8. package/dist/commonjs/config.js +36 -2
  9. package/dist/commonjs/config.js.map +1 -1
  10. package/dist/commonjs/index.js +1 -1
  11. package/dist/commonjs/index.js.map +1 -1
  12. package/dist/commonjs/parser/attribute.js +14 -13
  13. package/dist/commonjs/parser/attribute.js.map +1 -1
  14. package/dist/commonjs/parser/constants.js +1 -11
  15. package/dist/commonjs/parser/constants.js.map +1 -1
  16. package/dist/commonjs/parser/index.js +28 -26
  17. package/dist/commonjs/parser/index.js.map +1 -1
  18. package/dist/commonjs/shared/constants.js +12 -1
  19. package/dist/commonjs/shared/constants.js.map +1 -1
  20. package/dist/commonjs/shared/renderer-hooks.js +68 -0
  21. package/dist/commonjs/shared/renderer-hooks.js.map +1 -0
  22. package/dist/commonjs/shared/utils.js +11 -1
  23. package/dist/commonjs/shared/utils.js.map +1 -1
  24. package/dist/commonjs/state.js +9 -0
  25. package/dist/commonjs/state.js.map +1 -1
  26. package/dist/types/codegen/codegen.d.ts +7 -3
  27. package/dist/types/codegen/helpers.d.ts +2 -1
  28. package/dist/types/codegen/index.d.ts +2 -2
  29. package/dist/types/config.d.ts +8 -3
  30. package/dist/types/parser/constants.d.ts +0 -1
  31. package/dist/types/shared/constants.d.ts +2 -0
  32. package/dist/types/shared/renderer-hooks.d.ts +43 -0
  33. package/dist/types/shared/utils.d.ts +6 -0
  34. package/dist/types/state.d.ts +18 -0
  35. package/package.json +3 -3
@@ -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;
@@ -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.15.0",
3
+ "version": "2.16.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.15.0",
30
- "@lwc/shared": "2.15.0",
29
+ "@lwc/errors": "2.16.0",
30
+ "@lwc/shared": "2.16.0",
31
31
  "acorn": "~8.7.1",
32
32
  "astring": "~1.8.3",
33
33
  "estree-walker": "~2.0.2",