@lwc/template-compiler 3.6.0 → 3.7.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.
@@ -1,15 +1,15 @@
1
- import * as parse5 from 'parse5';
1
+ import { Token as parse5Tokens } from '../shared/parse5';
2
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: SourceLocation): {
8
+ export declare function normalizeAttributeValue(ctx: ParserCtx, raw: string, tag: string, attr: parse5Tokens.Attribute, location: SourceLocation): {
9
9
  value: string;
10
10
  escapedExpression: boolean;
11
11
  };
12
- export declare function attributeName(attr: parse5.Attribute): string;
12
+ export declare function attributeName(attr: parse5Tokens.Attribute): string;
13
13
  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;
@@ -1,9 +1,10 @@
1
- import { DocumentFragment, ParsingError } from 'parse5';
1
+ import { ParserError } from 'parse5';
2
+ import { DocumentFragment } from '../../shared/parse5';
2
3
  import type ParserCtx from '../parser';
3
4
  interface ParseFragmentConfig {
4
5
  ctx: ParserCtx;
5
6
  sourceCodeLocationInfo: boolean;
6
- onParseError: (error: ParsingError) => void;
7
+ onParseError: (err: ParserError) => void;
7
8
  }
8
9
  /**
9
10
  * Parse the LWC template using a customized parser & lexer that allow
@@ -1,2 +1,7 @@
1
1
  import type { Node as AcornNode } from 'acorn';
2
+ import type { Preprocessor as Parse5Preprocessor } from '../../shared/parse5';
2
3
  export type PreparsedExpressionMap = Map<number, AcornNode>;
4
+ export type Preprocessor = Omit<Parse5Preprocessor, 'pos'> & {
5
+ pos: number;
6
+ advance: () => void;
7
+ };
@@ -1,5 +1,4 @@
1
- import * as parse5 from 'parse5';
2
1
  import ParserCtx from './parser';
3
- export declare function parseHTML(ctx: ParserCtx, source: string): parse5.DocumentFragment;
2
+ export declare function parseHTML(ctx: ParserCtx, source: string): import("parse5/dist/tree-adapters/default").DocumentFragment;
4
3
  export declare function cleanTextNode(value: string): string;
5
4
  export declare function decodeTextContent(source: string): string;
@@ -1,15 +1,15 @@
1
- import * as parse5 from 'parse5';
1
+ import { Token as parse5TokenInfo } from './parse5';
2
2
  import { Literal, SourceLocation, Element, ExternalComponent, Component, Expression, ComplexExpression, Comment, Text, ForEach, ForBlock, Slot, Identifier, Root, EventListener, KeyDirective, DynamicDirective, DomDirective, PreserveCommentsDirective, RenderModeDirective, Attribute, Property, ParentNode, BaseNode, ForOf, LWCDirectiveRenderMode, If, IfBlock, ElseBlock, ElseifBlock, ElementSourceLocation, InnerHTMLDirective, BaseElement, LWCDirectiveDomMode, RefDirective, SpreadDirective, ElementDirective, RootDirective, SlotBindDirective, ScopedSlotFragment, SlotDataDirective, IsDirective, LwcComponent, LwcTagName, BaseLwcElement } from './types';
3
- export declare function root(parse5ElmLocation: parse5.ElementLocation): Root;
4
- export declare function element(tagName: string, namespaceURI: string, parse5ElmLocation: parse5.ElementLocation): Element;
5
- export declare function externalComponent(tagName: string, parse5ElmLocation: parse5.ElementLocation): ExternalComponent;
6
- export declare function component(tagName: string, parse5ElmLocation: parse5.ElementLocation): Component;
7
- export declare function lwcComponent(tagName: LwcTagName, parse5ElmLocation: parse5.ElementLocation): LwcComponent;
8
- export declare function slot(slotName: string, parse5ElmLocation: parse5.ElementLocation): Slot;
9
- export declare function text(raw: string, value: Literal | Expression | ComplexExpression, parse5Location: parse5.Location): Text;
10
- export declare function comment(raw: string, value: string, parse5Location: parse5.Location): Comment;
11
- export declare function elementSourceLocation(parse5ElmLocation: parse5.ElementLocation): ElementSourceLocation;
12
- export declare function sourceLocation(location: parse5.Location): SourceLocation;
3
+ export declare function root(parse5ElmLocation: parse5TokenInfo.ElementLocation): Root;
4
+ export declare function element(tagName: string, namespaceURI: string, parse5ElmLocation: parse5TokenInfo.ElementLocation): Element;
5
+ export declare function externalComponent(tagName: string, parse5ElmLocation: parse5TokenInfo.ElementLocation): ExternalComponent;
6
+ export declare function component(tagName: string, parse5ElmLocation: parse5TokenInfo.ElementLocation): Component;
7
+ export declare function lwcComponent(tagName: LwcTagName, parse5ElmLocation: parse5TokenInfo.ElementLocation): LwcComponent;
8
+ export declare function slot(slotName: string, parse5ElmLocation: parse5TokenInfo.ElementLocation): Slot;
9
+ export declare function text(raw: string, value: Literal | Expression | ComplexExpression, parse5Location: parse5TokenInfo.Location): Text;
10
+ export declare function comment(raw: string, value: string, parse5Location: parse5TokenInfo.Location): Comment;
11
+ export declare function elementSourceLocation(parse5ElmLocation: parse5TokenInfo.ElementLocation): ElementSourceLocation;
12
+ export declare function sourceLocation(location: parse5TokenInfo.Location): SourceLocation;
13
13
  export declare function literal<T extends string | boolean>(value: T): Literal<T>;
14
14
  export declare function forEach(expression: Expression, elementLocation: SourceLocation, directiveLocation: SourceLocation, item: Identifier, index?: Identifier): ForEach;
15
15
  export declare function forOf(expression: Expression, iterator: Identifier, elementLocation: SourceLocation, directiveLocation: SourceLocation): ForOf;
@@ -1,5 +1,19 @@
1
- import * as parse5 from 'parse5';
2
- export declare function isElementNode(node: parse5.Node): node is parse5.Element;
3
- export declare function isCommentNode(node: parse5.Node): node is parse5.CommentNode;
4
- export declare function isTextNode(node: parse5.Node): node is parse5.TextNode;
5
- export declare function getTemplateContent(templateElement: parse5.Element): parse5.DocumentFragment | undefined;
1
+ import { Token } from 'parse5';
2
+ import type { DefaultTreeAdapterMap } from 'parse5';
3
+ import type { Tokenizer } from 'parse5';
4
+ export type Preprocessor = Tokenizer['preprocessor'];
5
+ export type ElementLocation = Token.ElementLocation;
6
+ export type ChildNode = DefaultTreeAdapterMap['childNode'];
7
+ export type CommentNode = DefaultTreeAdapterMap['commentNode'];
8
+ export type Document = DefaultTreeAdapterMap['document'];
9
+ export type DocumentFragment = DefaultTreeAdapterMap['documentFragment'];
10
+ export type Element = DefaultTreeAdapterMap['element'];
11
+ export type Node = DefaultTreeAdapterMap['node'];
12
+ export type Template = DefaultTreeAdapterMap['template'];
13
+ export type TextNode = DefaultTreeAdapterMap['textNode'];
14
+ export { Token };
15
+ export declare function isElementNode(node: Node | null): node is Element;
16
+ export declare function isCommentNode(node: Node): node is CommentNode;
17
+ export declare function isTextNode(node: Node): node is TextNode;
18
+ export declare function isTemplateNode(node: Node): node is Template;
19
+ export declare function getTemplateContent(templateElement: Element | Template): DocumentFragment | undefined;
@@ -128,6 +128,9 @@ export interface AbstractBaseElement extends BaseParentNode {
128
128
  export interface Element extends AbstractBaseElement {
129
129
  type: 'Element';
130
130
  }
131
+ export interface StaticElement extends Element {
132
+ children: (StaticElement | Text)[];
133
+ }
131
134
  export interface ExternalComponent extends AbstractBaseElement {
132
135
  type: 'ExternalComponent';
133
136
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten."
5
5
  ],
6
6
  "name": "@lwc/template-compiler",
7
- "version": "3.6.0",
7
+ "version": "3.7.0",
8
8
  "description": "Template compiler package",
9
9
  "keywords": [
10
10
  "lwc"
@@ -42,18 +42,17 @@
42
42
  }
43
43
  },
44
44
  "dependencies": {
45
- "@lwc/errors": "3.6.0",
46
- "@lwc/shared": "3.6.0",
45
+ "@lwc/errors": "3.7.0",
46
+ "@lwc/shared": "3.7.0",
47
47
  "acorn": "~8.10.0",
48
48
  "astring": "~1.8.6",
49
49
  "estree-walker": "~2.0.2",
50
- "he": "~1.2.0",
51
- "parse5": "~6.0.1"
50
+ "he": "~1.2.0"
52
51
  },
53
52
  "devDependencies": {
54
53
  "@types/estree": "1.0.2",
55
54
  "@types/he": "^1.2.1",
56
- "@types/parse5": "^6.0.2",
57
- "@types/source-map": "0.5.7"
55
+ "@types/source-map": "0.5.7",
56
+ "parse5": "~7.1.2"
58
57
  }
59
58
  }