@lwc/template-compiler 4.0.0-alpha.0 → 4.0.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 } from '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: Token.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: Token.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 '@parse5/tools';
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 { Tokenizer } from 'parse5';
2
3
  export type PreparsedExpressionMap = Map<number, AcornNode>;
4
+ export type Preprocessor = Omit<Tokenizer['preprocessor'], '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;
@@ -21,6 +21,7 @@ export declare function binaryExpression(operator: t.BinaryExpression['operator'
21
21
  export declare function logicalExpression(operator: t.LogicalExpression['operator'], left: t.LogicalExpression['left'], right: t.LogicalExpression['right'], config?: Partial<t.LogicalExpression>): t.LogicalExpression;
22
22
  export declare function assignmentExpression(operator: t.AssignmentExpression['operator'], left: t.AssignmentExpression['left'], right: t.AssignmentExpression['right'], config?: Partial<t.AssignmentExpression>): t.AssignmentExpression;
23
23
  export declare function property(key: t.Property['key'], value: t.Property['value'], config?: Partial<t.Property>): t.Property;
24
+ export declare function spreadElement(argument: t.Expression): t.SpreadElement;
24
25
  export declare function assignmentProperty(key: t.AssignmentProperty['key'], value: t.AssignmentProperty['value'], config?: Partial<t.AssignmentProperty>): t.AssignmentProperty;
25
26
  export declare function objectExpression(properties: t.ObjectExpression['properties'], config?: Partial<t.ObjectExpression>): t.ObjectExpression;
26
27
  export declare function objectPattern(properties: t.ObjectPattern['properties'], config?: Partial<t.ObjectPattern>): t.ObjectPattern;
@@ -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": "4.0.0-alpha.0",
7
+ "version": "4.0.0",
8
8
  "description": "Template compiler package",
9
9
  "keywords": [
10
10
  "lwc"
@@ -36,24 +36,24 @@
36
36
  "targets": {
37
37
  "build": {
38
38
  "outputs": [
39
- "./dist"
39
+ "{projectRoot}/dist"
40
40
  ]
41
41
  }
42
42
  }
43
43
  },
44
44
  "dependencies": {
45
- "@lwc/errors": "4.0.0-alpha.0",
46
- "@lwc/shared": "4.0.0-alpha.0",
45
+ "@lwc/errors": "4.0.0",
46
+ "@lwc/shared": "4.0.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
- "@types/estree": "1.0.1",
55
- "@types/he": "^1.2.0",
56
- "@types/parse5": "^6.0.2",
57
- "@types/source-map": "0.5.7"
53
+ "@types/estree": "1.0.2",
54
+ "@types/he": "^1.2.1",
55
+ "@types/source-map": "0.5.7",
56
+ "parse5": "~7.1.2",
57
+ "@parse5/tools": "^0.3.0"
58
58
  }
59
- }
59
+ }
@@ -1,5 +0,0 @@
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;