angular-html-parser
Advanced tools
| import { Parser } from "./parser.mjs"; | ||
| import { getXmlTagDefinition } from "./xml_tags.mjs"; | ||
| //#region ../compiler/src/ml_parser/xml_parser.ts | ||
| var XmlParser = class extends Parser { | ||
| constructor() { | ||
| super(getXmlTagDefinition); | ||
| } | ||
| parse(source, url, options = {}) { | ||
| return super.parse(source, url, { | ||
| ...options, | ||
| tokenizeBlocks: false, | ||
| tokenizeLet: false, | ||
| selectorlessEnabled: false | ||
| }); | ||
| } | ||
| }; | ||
| //#endregion | ||
| export { XmlParser }; |
| import { TagContentType } from "./tags.mjs"; | ||
| //#region ../compiler/src/ml_parser/xml_tags.ts | ||
| /** | ||
| * @license | ||
| * Copyright Google LLC All Rights Reserved. | ||
| * | ||
| * Use of this source code is governed by an MIT-style license that can be | ||
| * found in the LICENSE file at https://angular.dev/license | ||
| */ | ||
| var XmlTagDefinition = class { | ||
| closedByParent = false; | ||
| implicitNamespacePrefix = null; | ||
| isVoid = false; | ||
| ignoreFirstLf = false; | ||
| canSelfClose = true; | ||
| preventNamespaceInheritance = false; | ||
| requireExtraParent(currentParent) { | ||
| return false; | ||
| } | ||
| isClosedByChild(name) { | ||
| return false; | ||
| } | ||
| getContentType() { | ||
| return TagContentType.PARSABLE_DATA; | ||
| } | ||
| }; | ||
| const _TAG_DEFINITION = new XmlTagDefinition(); | ||
| function getXmlTagDefinition(tagName) { | ||
| return _TAG_DEFINITION; | ||
| } | ||
| //#endregion | ||
| export { getXmlTagDefinition }; |
| //#region rolldown:runtime | ||
| var __defProp = Object.defineProperty; | ||
| var __export = (all, symbols) => { | ||
| var __exportAll = (all, symbols) => { | ||
| let target = {}; | ||
@@ -18,2 +18,2 @@ for (var name in all) { | ||
| //#endregion | ||
| export { __export }; | ||
| export { __exportAll }; |
| //#region ../compiler/src/core.ts | ||
| const CUSTOM_ELEMENTS_SCHEMA = { name: "custom-elements" }; | ||
| const NO_ERRORS_SCHEMA = { name: "no-errors-schema" }; | ||
| let SecurityContext = /* @__PURE__ */ function(SecurityContext$1) { | ||
| SecurityContext$1[SecurityContext$1["NONE"] = 0] = "NONE"; | ||
| SecurityContext$1[SecurityContext$1["HTML"] = 1] = "HTML"; | ||
| SecurityContext$1[SecurityContext$1["STYLE"] = 2] = "STYLE"; | ||
| SecurityContext$1[SecurityContext$1["SCRIPT"] = 3] = "SCRIPT"; | ||
| SecurityContext$1[SecurityContext$1["URL"] = 4] = "URL"; | ||
| SecurityContext$1[SecurityContext$1["RESOURCE_URL"] = 5] = "RESOURCE_URL"; | ||
| SecurityContext$1[SecurityContext$1["ATTRIBUTE_NO_BINDING"] = 6] = "ATTRIBUTE_NO_BINDING"; | ||
| return SecurityContext$1; | ||
| let SecurityContext = /* @__PURE__ */ function(SecurityContext) { | ||
| SecurityContext[SecurityContext["NONE"] = 0] = "NONE"; | ||
| SecurityContext[SecurityContext["HTML"] = 1] = "HTML"; | ||
| SecurityContext[SecurityContext["STYLE"] = 2] = "STYLE"; | ||
| SecurityContext[SecurityContext["SCRIPT"] = 3] = "SCRIPT"; | ||
| SecurityContext[SecurityContext["URL"] = 4] = "URL"; | ||
| SecurityContext[SecurityContext["RESOURCE_URL"] = 5] = "RESOURCE_URL"; | ||
| SecurityContext[SecurityContext["ATTRIBUTE_NO_BINDING"] = 6] = "ATTRIBUTE_NO_BINDING"; | ||
| return SecurityContext; | ||
| }({}); | ||
@@ -14,0 +14,0 @@ |
@@ -11,3 +11,2 @@ import { ParseSourceSpan } from "../parse_util.mjs"; | ||
| */ | ||
| /** | ||
@@ -40,9 +39,9 @@ * Describes the text contents of a placeholder as it appears in an ICU expression, including its | ||
| /** | ||
| * @param nodes message AST | ||
| * @param placeholders maps placeholder names to static content and their source spans | ||
| * @param placeholderToMessage maps placeholder names to messages (used for nested ICU messages) | ||
| * @param meaning | ||
| * @param description | ||
| * @param customId | ||
| */ | ||
| * @param nodes message AST | ||
| * @param placeholders maps placeholder names to static content and their source spans | ||
| * @param placeholderToMessage maps placeholder names to messages (used for nested ICU messages) | ||
| * @param meaning | ||
| * @param description | ||
| * @param customId | ||
| */ | ||
| constructor(nodes: Node[], placeholders: { | ||
@@ -49,0 +48,0 @@ [phName: string]: MessagePlaceholder; |
@@ -13,3 +13,2 @@ //#region ../compiler/src/ml_parser/ast.ts | ||
| this.tokens = tokens; | ||
| this.kind = "text"; | ||
| } | ||
@@ -19,2 +18,3 @@ visit(visitor, context) { | ||
| } | ||
| kind = "text"; | ||
| }; | ||
@@ -26,3 +26,2 @@ var CDATA = class extends NodeWithI18n { | ||
| this.tokens = tokens; | ||
| this.kind = "cdata"; | ||
| } | ||
@@ -32,2 +31,3 @@ visit(visitor, context) { | ||
| } | ||
| kind = "cdata"; | ||
| }; | ||
@@ -41,3 +41,2 @@ var Expansion = class extends NodeWithI18n { | ||
| this.switchValueSourceSpan = switchValueSourceSpan; | ||
| this.kind = "expansion"; | ||
| } | ||
@@ -47,2 +46,3 @@ visit(visitor, context) { | ||
| } | ||
| kind = "expansion"; | ||
| }; | ||
@@ -56,3 +56,2 @@ var ExpansionCase = class { | ||
| this.expSourceSpan = expSourceSpan; | ||
| this.kind = "expansionCase"; | ||
| } | ||
@@ -62,2 +61,3 @@ visit(visitor, context) { | ||
| } | ||
| kind = "expansionCase"; | ||
| }; | ||
@@ -72,3 +72,2 @@ var Attribute = class extends NodeWithI18n { | ||
| this.valueTokens = valueTokens; | ||
| this.kind = "attribute"; | ||
| } | ||
@@ -78,2 +77,3 @@ visit(visitor, context) { | ||
| } | ||
| kind = "attribute"; | ||
| get nameSpan() { | ||
@@ -95,3 +95,2 @@ return this.keySpan; | ||
| this.isVoid = isVoid; | ||
| this.kind = "element"; | ||
| } | ||
@@ -101,2 +100,3 @@ visit(visitor, context) { | ||
| } | ||
| kind = "element"; | ||
| }; | ||
@@ -107,3 +107,2 @@ var Comment = class { | ||
| this.sourceSpan = sourceSpan; | ||
| this.kind = "comment"; | ||
| } | ||
@@ -113,2 +112,3 @@ visit(visitor, context) { | ||
| } | ||
| kind = "comment"; | ||
| }; | ||
@@ -119,3 +119,2 @@ var DocType = class { | ||
| this.sourceSpan = sourceSpan; | ||
| this.kind = "docType"; | ||
| } | ||
@@ -125,2 +124,3 @@ visit(visitor, context) { | ||
| } | ||
| kind = "docType"; | ||
| }; | ||
@@ -136,3 +136,2 @@ var Block = class extends NodeWithI18n { | ||
| this.endSourceSpan = endSourceSpan; | ||
| this.kind = "block"; | ||
| } | ||
@@ -142,2 +141,3 @@ visit(visitor, context) { | ||
| } | ||
| kind = "block"; | ||
| }; | ||
@@ -156,3 +156,2 @@ var Component = class extends NodeWithI18n { | ||
| this.endSourceSpan = endSourceSpan; | ||
| this.kind = "component"; | ||
| } | ||
@@ -162,2 +161,3 @@ visit(visitor, context) { | ||
| } | ||
| kind = "component"; | ||
| }; | ||
@@ -171,3 +171,2 @@ var Directive = class { | ||
| this.endSourceSpan = endSourceSpan; | ||
| this.kind = "directive"; | ||
| } | ||
@@ -177,2 +176,3 @@ visit(visitor, context) { | ||
| } | ||
| kind = "directive"; | ||
| }; | ||
@@ -183,5 +183,2 @@ var BlockParameter = class { | ||
| this.sourceSpan = sourceSpan; | ||
| this.kind = "blockParameter"; | ||
| this.startSourceSpan = null; | ||
| this.endSourceSpan = null; | ||
| } | ||
@@ -191,2 +188,5 @@ visit(visitor, context) { | ||
| } | ||
| kind = "blockParameter"; | ||
| startSourceSpan = null; | ||
| endSourceSpan = null; | ||
| }; | ||
@@ -200,5 +200,2 @@ var LetDeclaration = class { | ||
| this.valueSpan = valueSpan; | ||
| this.kind = "letDeclaration"; | ||
| this.startSourceSpan = null; | ||
| this.endSourceSpan = null; | ||
| } | ||
@@ -208,2 +205,5 @@ visit(visitor, context) { | ||
| } | ||
| kind = "letDeclaration"; | ||
| startSourceSpan = null; | ||
| endSourceSpan = null; | ||
| }; | ||
@@ -210,0 +210,0 @@ function visitAll(visitor, nodes, context = null) { |
@@ -13,5 +13,11 @@ import { TagContentType, getNsPrefix } from "./tags.mjs"; | ||
| var HtmlTagDefinition = class { | ||
| closedByChildren = {}; | ||
| contentType; | ||
| closedByParent = false; | ||
| implicitNamespacePrefix; | ||
| isVoid; | ||
| ignoreFirstLf; | ||
| canSelfClose; | ||
| preventNamespaceInheritance; | ||
| constructor({ closedByChildren, implicitNamespacePrefix, contentType = TagContentType.PARSABLE_DATA, closedByParent = false, isVoid = false, ignoreFirstLf = false, preventNamespaceInheritance = false, canSelfClose = false } = {}) { | ||
| this.closedByChildren = {}; | ||
| this.closedByParent = false; | ||
| if (closedByChildren && closedByChildren.length > 0) closedByChildren.forEach((tagName) => this.closedByChildren[tagName] = true); | ||
@@ -18,0 +24,0 @@ this.isVoid = isVoid; |
@@ -37,6 +37,6 @@ import { TagContentType, mergeNsAndName } from "./tags.mjs"; | ||
| } | ||
| var CharacterReferenceType = /* @__PURE__ */ function(CharacterReferenceType$1) { | ||
| CharacterReferenceType$1["HEX"] = "hexadecimal"; | ||
| CharacterReferenceType$1["DEC"] = "decimal"; | ||
| return CharacterReferenceType$1; | ||
| var CharacterReferenceType = /* @__PURE__ */ function(CharacterReferenceType) { | ||
| CharacterReferenceType["HEX"] = "hexadecimal"; | ||
| CharacterReferenceType["DEC"] = "decimal"; | ||
| return CharacterReferenceType; | ||
| }(CharacterReferenceType || {}); | ||
@@ -61,2 +61,21 @@ const SUPPORTED_BLOCKS = [ | ||
| var _Tokenizer = class { | ||
| _cursor; | ||
| _tokenizeIcu; | ||
| _leadingTriviaCodePoints; | ||
| _canSelfClose; | ||
| _allowHtmComponentClosingTags; | ||
| _currentTokenStart = null; | ||
| _currentTokenType = null; | ||
| _expansionCaseStack = []; | ||
| _openDirectiveCount = 0; | ||
| _inInterpolation = false; | ||
| _preserveLineEndings; | ||
| _i18nNormalizeLineEndingsInICUs; | ||
| _fullNameStack = []; | ||
| _tokenizeBlocks; | ||
| _tokenizeLet; | ||
| _selectorlessEnabled; | ||
| tokens = []; | ||
| errors = []; | ||
| nonNormalizedIcuExpressions = []; | ||
| /** | ||
@@ -70,11 +89,2 @@ * @param _file The html source file being tokenized. | ||
| this._getTagContentType = _getTagContentType; | ||
| this._currentTokenStart = null; | ||
| this._currentTokenType = null; | ||
| this._expansionCaseStack = []; | ||
| this._openDirectiveCount = 0; | ||
| this._inInterpolation = false; | ||
| this._fullNameStack = []; | ||
| this.tokens = []; | ||
| this.errors = []; | ||
| this.nonNormalizedIcuExpressions = []; | ||
| this._tokenizeIcu = options.tokenizeExpansionForms || false; | ||
@@ -929,2 +939,6 @@ this._leadingTriviaCodePoints = options.leadingTriviaChars && options.leadingTriviaChars.map((c) => c.codePointAt(0) || 0); | ||
| var PlainCharacterCursor = class PlainCharacterCursor { | ||
| state; | ||
| file; | ||
| input; | ||
| end; | ||
| constructor(fileOrCursor, range) { | ||
@@ -1010,2 +1024,3 @@ if (fileOrCursor instanceof PlainCharacterCursor) { | ||
| var EscapedCharacterCursor = class EscapedCharacterCursor extends PlainCharacterCursor { | ||
| internalState; | ||
| constructor(fileOrCursor, range) { | ||
@@ -1012,0 +1027,0 @@ if (fileOrCursor instanceof EscapedCharacterCursor) { |
@@ -12,3 +12,2 @@ import { ParseError } from "../parse_util.mjs"; | ||
| */ | ||
| declare class ParseTreeResult { | ||
@@ -15,0 +14,0 @@ rootNodes: Node[]; |
@@ -52,2 +52,7 @@ import { getNsPrefix, mergeNsAndName, splitNsName } from "./tags.mjs"; | ||
| var _TreeBuilder = class _TreeBuilder { | ||
| _index = -1; | ||
| _peek; | ||
| _containerStack = []; | ||
| rootNodes = []; | ||
| errors = []; | ||
| constructor(tokens, tagDefinitionResolver, canSelfClose, allowHtmComponentClosingTags, isTagNameCaseSensitive) { | ||
@@ -59,6 +64,2 @@ this.tokens = tokens; | ||
| this.isTagNameCaseSensitive = isTagNameCaseSensitive; | ||
| this._index = -1; | ||
| this._containerStack = []; | ||
| this.rootNodes = []; | ||
| this.errors = []; | ||
| this._advance(); | ||
@@ -65,0 +66,0 @@ } |
@@ -9,7 +9,7 @@ //#region ../compiler/src/ml_parser/tags.ts | ||
| */ | ||
| let TagContentType = /* @__PURE__ */ function(TagContentType$1) { | ||
| TagContentType$1[TagContentType$1["RAW_TEXT"] = 0] = "RAW_TEXT"; | ||
| TagContentType$1[TagContentType$1["ESCAPABLE_RAW_TEXT"] = 1] = "ESCAPABLE_RAW_TEXT"; | ||
| TagContentType$1[TagContentType$1["PARSABLE_DATA"] = 2] = "PARSABLE_DATA"; | ||
| return TagContentType$1; | ||
| let TagContentType = /* @__PURE__ */ function(TagContentType) { | ||
| TagContentType[TagContentType["RAW_TEXT"] = 0] = "RAW_TEXT"; | ||
| TagContentType[TagContentType["ESCAPABLE_RAW_TEXT"] = 1] = "ESCAPABLE_RAW_TEXT"; | ||
| TagContentType[TagContentType["PARSABLE_DATA"] = 2] = "PARSABLE_DATA"; | ||
| return TagContentType; | ||
| }({}); | ||
@@ -16,0 +16,0 @@ function splitNsName(elementName, fatal = true) { |
| //#region ../compiler/src/ml_parser/tokens.ts | ||
| let TokenType = /* @__PURE__ */ function(TokenType$1) { | ||
| TokenType$1[TokenType$1["TAG_OPEN_START"] = 0] = "TAG_OPEN_START"; | ||
| TokenType$1[TokenType$1["TAG_OPEN_END"] = 1] = "TAG_OPEN_END"; | ||
| TokenType$1[TokenType$1["TAG_OPEN_END_VOID"] = 2] = "TAG_OPEN_END_VOID"; | ||
| TokenType$1[TokenType$1["TAG_CLOSE"] = 3] = "TAG_CLOSE"; | ||
| TokenType$1[TokenType$1["INCOMPLETE_TAG_OPEN"] = 4] = "INCOMPLETE_TAG_OPEN"; | ||
| TokenType$1[TokenType$1["TEXT"] = 5] = "TEXT"; | ||
| TokenType$1[TokenType$1["ESCAPABLE_RAW_TEXT"] = 6] = "ESCAPABLE_RAW_TEXT"; | ||
| TokenType$1[TokenType$1["RAW_TEXT"] = 7] = "RAW_TEXT"; | ||
| TokenType$1[TokenType$1["INTERPOLATION"] = 8] = "INTERPOLATION"; | ||
| TokenType$1[TokenType$1["ENCODED_ENTITY"] = 9] = "ENCODED_ENTITY"; | ||
| TokenType$1[TokenType$1["COMMENT_START"] = 10] = "COMMENT_START"; | ||
| TokenType$1[TokenType$1["COMMENT_END"] = 11] = "COMMENT_END"; | ||
| TokenType$1[TokenType$1["CDATA_START"] = 12] = "CDATA_START"; | ||
| TokenType$1[TokenType$1["CDATA_END"] = 13] = "CDATA_END"; | ||
| TokenType$1[TokenType$1["ATTR_NAME"] = 14] = "ATTR_NAME"; | ||
| TokenType$1[TokenType$1["ATTR_QUOTE"] = 15] = "ATTR_QUOTE"; | ||
| TokenType$1[TokenType$1["ATTR_VALUE_TEXT"] = 16] = "ATTR_VALUE_TEXT"; | ||
| TokenType$1[TokenType$1["ATTR_VALUE_INTERPOLATION"] = 17] = "ATTR_VALUE_INTERPOLATION"; | ||
| TokenType$1[TokenType$1["DOC_TYPE_START"] = 18] = "DOC_TYPE_START"; | ||
| TokenType$1[TokenType$1["DOC_TYPE_END"] = 19] = "DOC_TYPE_END"; | ||
| TokenType$1[TokenType$1["EXPANSION_FORM_START"] = 20] = "EXPANSION_FORM_START"; | ||
| TokenType$1[TokenType$1["EXPANSION_CASE_VALUE"] = 21] = "EXPANSION_CASE_VALUE"; | ||
| TokenType$1[TokenType$1["EXPANSION_CASE_EXP_START"] = 22] = "EXPANSION_CASE_EXP_START"; | ||
| TokenType$1[TokenType$1["EXPANSION_CASE_EXP_END"] = 23] = "EXPANSION_CASE_EXP_END"; | ||
| TokenType$1[TokenType$1["EXPANSION_FORM_END"] = 24] = "EXPANSION_FORM_END"; | ||
| TokenType$1[TokenType$1["BLOCK_OPEN_START"] = 25] = "BLOCK_OPEN_START"; | ||
| TokenType$1[TokenType$1["BLOCK_OPEN_END"] = 26] = "BLOCK_OPEN_END"; | ||
| TokenType$1[TokenType$1["BLOCK_CLOSE"] = 27] = "BLOCK_CLOSE"; | ||
| TokenType$1[TokenType$1["BLOCK_PARAMETER"] = 28] = "BLOCK_PARAMETER"; | ||
| TokenType$1[TokenType$1["INCOMPLETE_BLOCK_OPEN"] = 29] = "INCOMPLETE_BLOCK_OPEN"; | ||
| TokenType$1[TokenType$1["LET_START"] = 30] = "LET_START"; | ||
| TokenType$1[TokenType$1["LET_VALUE"] = 31] = "LET_VALUE"; | ||
| TokenType$1[TokenType$1["LET_END"] = 32] = "LET_END"; | ||
| TokenType$1[TokenType$1["INCOMPLETE_LET"] = 33] = "INCOMPLETE_LET"; | ||
| TokenType$1[TokenType$1["COMPONENT_OPEN_START"] = 34] = "COMPONENT_OPEN_START"; | ||
| TokenType$1[TokenType$1["COMPONENT_OPEN_END"] = 35] = "COMPONENT_OPEN_END"; | ||
| TokenType$1[TokenType$1["COMPONENT_OPEN_END_VOID"] = 36] = "COMPONENT_OPEN_END_VOID"; | ||
| TokenType$1[TokenType$1["COMPONENT_CLOSE"] = 37] = "COMPONENT_CLOSE"; | ||
| TokenType$1[TokenType$1["INCOMPLETE_COMPONENT_OPEN"] = 38] = "INCOMPLETE_COMPONENT_OPEN"; | ||
| TokenType$1[TokenType$1["DIRECTIVE_NAME"] = 39] = "DIRECTIVE_NAME"; | ||
| TokenType$1[TokenType$1["DIRECTIVE_OPEN"] = 40] = "DIRECTIVE_OPEN"; | ||
| TokenType$1[TokenType$1["DIRECTIVE_CLOSE"] = 41] = "DIRECTIVE_CLOSE"; | ||
| TokenType$1[TokenType$1["EOF"] = 42] = "EOF"; | ||
| return TokenType$1; | ||
| let TokenType = /* @__PURE__ */ function(TokenType) { | ||
| TokenType[TokenType["TAG_OPEN_START"] = 0] = "TAG_OPEN_START"; | ||
| TokenType[TokenType["TAG_OPEN_END"] = 1] = "TAG_OPEN_END"; | ||
| TokenType[TokenType["TAG_OPEN_END_VOID"] = 2] = "TAG_OPEN_END_VOID"; | ||
| TokenType[TokenType["TAG_CLOSE"] = 3] = "TAG_CLOSE"; | ||
| TokenType[TokenType["INCOMPLETE_TAG_OPEN"] = 4] = "INCOMPLETE_TAG_OPEN"; | ||
| TokenType[TokenType["TEXT"] = 5] = "TEXT"; | ||
| TokenType[TokenType["ESCAPABLE_RAW_TEXT"] = 6] = "ESCAPABLE_RAW_TEXT"; | ||
| TokenType[TokenType["RAW_TEXT"] = 7] = "RAW_TEXT"; | ||
| TokenType[TokenType["INTERPOLATION"] = 8] = "INTERPOLATION"; | ||
| TokenType[TokenType["ENCODED_ENTITY"] = 9] = "ENCODED_ENTITY"; | ||
| TokenType[TokenType["COMMENT_START"] = 10] = "COMMENT_START"; | ||
| TokenType[TokenType["COMMENT_END"] = 11] = "COMMENT_END"; | ||
| TokenType[TokenType["CDATA_START"] = 12] = "CDATA_START"; | ||
| TokenType[TokenType["CDATA_END"] = 13] = "CDATA_END"; | ||
| TokenType[TokenType["ATTR_NAME"] = 14] = "ATTR_NAME"; | ||
| TokenType[TokenType["ATTR_QUOTE"] = 15] = "ATTR_QUOTE"; | ||
| TokenType[TokenType["ATTR_VALUE_TEXT"] = 16] = "ATTR_VALUE_TEXT"; | ||
| TokenType[TokenType["ATTR_VALUE_INTERPOLATION"] = 17] = "ATTR_VALUE_INTERPOLATION"; | ||
| TokenType[TokenType["DOC_TYPE_START"] = 18] = "DOC_TYPE_START"; | ||
| TokenType[TokenType["DOC_TYPE_END"] = 19] = "DOC_TYPE_END"; | ||
| TokenType[TokenType["EXPANSION_FORM_START"] = 20] = "EXPANSION_FORM_START"; | ||
| TokenType[TokenType["EXPANSION_CASE_VALUE"] = 21] = "EXPANSION_CASE_VALUE"; | ||
| TokenType[TokenType["EXPANSION_CASE_EXP_START"] = 22] = "EXPANSION_CASE_EXP_START"; | ||
| TokenType[TokenType["EXPANSION_CASE_EXP_END"] = 23] = "EXPANSION_CASE_EXP_END"; | ||
| TokenType[TokenType["EXPANSION_FORM_END"] = 24] = "EXPANSION_FORM_END"; | ||
| TokenType[TokenType["BLOCK_OPEN_START"] = 25] = "BLOCK_OPEN_START"; | ||
| TokenType[TokenType["BLOCK_OPEN_END"] = 26] = "BLOCK_OPEN_END"; | ||
| TokenType[TokenType["BLOCK_CLOSE"] = 27] = "BLOCK_CLOSE"; | ||
| TokenType[TokenType["BLOCK_PARAMETER"] = 28] = "BLOCK_PARAMETER"; | ||
| TokenType[TokenType["INCOMPLETE_BLOCK_OPEN"] = 29] = "INCOMPLETE_BLOCK_OPEN"; | ||
| TokenType[TokenType["LET_START"] = 30] = "LET_START"; | ||
| TokenType[TokenType["LET_VALUE"] = 31] = "LET_VALUE"; | ||
| TokenType[TokenType["LET_END"] = 32] = "LET_END"; | ||
| TokenType[TokenType["INCOMPLETE_LET"] = 33] = "INCOMPLETE_LET"; | ||
| TokenType[TokenType["COMPONENT_OPEN_START"] = 34] = "COMPONENT_OPEN_START"; | ||
| TokenType[TokenType["COMPONENT_OPEN_END"] = 35] = "COMPONENT_OPEN_END"; | ||
| TokenType[TokenType["COMPONENT_OPEN_END_VOID"] = 36] = "COMPONENT_OPEN_END_VOID"; | ||
| TokenType[TokenType["COMPONENT_CLOSE"] = 37] = "COMPONENT_CLOSE"; | ||
| TokenType[TokenType["INCOMPLETE_COMPONENT_OPEN"] = 38] = "INCOMPLETE_COMPONENT_OPEN"; | ||
| TokenType[TokenType["DIRECTIVE_NAME"] = 39] = "DIRECTIVE_NAME"; | ||
| TokenType[TokenType["DIRECTIVE_OPEN"] = 40] = "DIRECTIVE_OPEN"; | ||
| TokenType[TokenType["DIRECTIVE_CLOSE"] = 41] = "DIRECTIVE_CLOSE"; | ||
| TokenType[TokenType["EOF"] = 42] = "EOF"; | ||
| return TokenType; | ||
| }({}); | ||
@@ -48,0 +48,0 @@ |
@@ -26,24 +26,24 @@ //#region ../compiler/src/parse_util.d.ts | ||
| /** | ||
| * Create an object that holds information about spans of tokens/nodes captured during | ||
| * lexing/parsing of text. | ||
| * | ||
| * @param start | ||
| * The location of the start of the span (having skipped leading trivia). | ||
| * Skipping leading trivia makes source-spans more "user friendly", since things like HTML | ||
| * elements will appear to begin at the start of the opening tag, rather than at the start of any | ||
| * leading trivia, which could include newlines. | ||
| * | ||
| * @param end | ||
| * The location of the end of the span. | ||
| * | ||
| * @param fullStart | ||
| * The start of the token without skipping the leading trivia. | ||
| * This is used by tooling that splits tokens further, such as extracting Angular interpolations | ||
| * from text tokens. Such tooling creates new source-spans relative to the original token's | ||
| * source-span. If leading trivia characters have been skipped then the new source-spans may be | ||
| * incorrectly offset. | ||
| * | ||
| * @param details | ||
| * Additional information (such as identifier names) that should be associated with the span. | ||
| */ | ||
| * Create an object that holds information about spans of tokens/nodes captured during | ||
| * lexing/parsing of text. | ||
| * | ||
| * @param start | ||
| * The location of the start of the span (having skipped leading trivia). | ||
| * Skipping leading trivia makes source-spans more "user friendly", since things like HTML | ||
| * elements will appear to begin at the start of the opening tag, rather than at the start of any | ||
| * leading trivia, which could include newlines. | ||
| * | ||
| * @param end | ||
| * The location of the end of the span. | ||
| * | ||
| * @param fullStart | ||
| * The start of the token without skipping the leading trivia. | ||
| * This is used by tooling that splits tokens further, such as extracting Angular interpolations | ||
| * from text tokens. Such tooling creates new source-spans relative to the original token's | ||
| * source-span. If leading trivia characters have been skipped then the new source-spans may be | ||
| * incorrectly offset. | ||
| * | ||
| * @param details | ||
| * Additional information (such as identifier names) that should be associated with the span. | ||
| */ | ||
| constructor(start: ParseLocation, end: ParseLocation, fullStart?: ParseLocation, details?: string | null); | ||
@@ -64,14 +64,11 @@ toString(): string; | ||
| /** | ||
| * Error that caused the error to be surfaced. For example, an error in a sub-expression that | ||
| * couldn't be parsed. Not guaranteed to be defined, but can be used to provide more context. | ||
| */ | ||
| * Error that caused the error to be surfaced. For example, an error in a sub-expression that | ||
| * couldn't be parsed. Not guaranteed to be defined, but can be used to provide more context. | ||
| */ | ||
| readonly relatedError?: unknown; | ||
| constructor(/** Location of the error. */ | ||
| span: ParseSourceSpan, /** Error message. */ | ||
| msg: string, /** Severity level of the error. */ | ||
| level?: ParseErrorLevel, | ||
| constructor(/** Location of the error. */span: ParseSourceSpan, /** Error message. */msg: string, /** Severity level of the error. */level?: ParseErrorLevel, | ||
| /** | ||
| * Error that caused the error to be surfaced. For example, an error in a sub-expression that | ||
| * couldn't be parsed. Not guaranteed to be defined, but can be used to provide more context. | ||
| */ | ||
| * Error that caused the error to be surfaced. For example, an error in a sub-expression that | ||
| * couldn't be parsed. Not guaranteed to be defined, but can be used to provide more context. | ||
| */ | ||
| relatedError?: unknown); | ||
@@ -78,0 +75,0 @@ contextualMessage(): string; |
@@ -119,6 +119,6 @@ import { $LF } from "./chars.mjs"; | ||
| }; | ||
| let ParseErrorLevel = /* @__PURE__ */ function(ParseErrorLevel$1) { | ||
| ParseErrorLevel$1[ParseErrorLevel$1["WARNING"] = 0] = "WARNING"; | ||
| ParseErrorLevel$1[ParseErrorLevel$1["ERROR"] = 1] = "ERROR"; | ||
| return ParseErrorLevel$1; | ||
| let ParseErrorLevel = /* @__PURE__ */ function(ParseErrorLevel) { | ||
| ParseErrorLevel[ParseErrorLevel["WARNING"] = 0] = "WARNING"; | ||
| ParseErrorLevel[ParseErrorLevel["ERROR"] = 1] = "ERROR"; | ||
| return ParseErrorLevel; | ||
| }({}); | ||
@@ -125,0 +125,0 @@ var ParseError = class extends Error { |
@@ -308,6 +308,6 @@ import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, SecurityContext } from "../core.mjs"; | ||
| var DomElementSchemaRegistry = class extends ElementSchemaRegistry { | ||
| _schema = /* @__PURE__ */ new Map(); | ||
| _eventSchema = /* @__PURE__ */ new Map(); | ||
| constructor() { | ||
| super(); | ||
| this._schema = /* @__PURE__ */ new Map(); | ||
| this._eventSchema = /* @__PURE__ */ new Map(); | ||
| SCHEMA.forEach((encodedType) => { | ||
@@ -314,0 +314,0 @@ const type = /* @__PURE__ */ new Map(); |
+26
-25
@@ -8,26 +8,26 @@ import { TagContentType } from "./compiler/src/ml_parser/tags.mjs"; | ||
| //#region src/index.d.ts | ||
| interface ParseOptions { | ||
| interface HtmlParseOptions { | ||
| /** | ||
| * any element can self close | ||
| * | ||
| * defaults to false | ||
| */ | ||
| * any element can self close | ||
| * | ||
| * defaults to false | ||
| */ | ||
| canSelfClose?: boolean; | ||
| /** | ||
| * support [`htm`](https://github.com/developit/htm) component closing tags (`<//>`) | ||
| * | ||
| * defaults to false | ||
| */ | ||
| * support [`htm`](https://github.com/developit/htm) component closing tags (`<//>`) | ||
| * | ||
| * defaults to false | ||
| */ | ||
| allowHtmComponentClosingTags?: boolean; | ||
| /** | ||
| * do not lowercase tag names before querying their tag definitions | ||
| * | ||
| * defaults to false | ||
| */ | ||
| * do not lowercase tag names before querying their tag definitions | ||
| * | ||
| * defaults to false | ||
| */ | ||
| isTagNameCaseSensitive?: boolean; | ||
| /** | ||
| * customize tag content type | ||
| * | ||
| * defaults to the content type defined in the HTML spec | ||
| */ | ||
| * customize tag content type | ||
| * | ||
| * defaults to the content type defined in the HTML spec | ||
| */ | ||
| getTagContentType?: (tagName: string, prefix: string, hasParent: boolean, attrs: Array<{ | ||
@@ -39,16 +39,17 @@ prefix: string; | ||
| /** | ||
| * tokenize angular control flow block syntax | ||
| */ | ||
| * tokenize angular control flow block syntax | ||
| */ | ||
| tokenizeAngularBlocks?: boolean; | ||
| /** | ||
| * tokenize angular let declaration syntax | ||
| */ | ||
| * tokenize angular let declaration syntax | ||
| */ | ||
| tokenizeAngularLetDeclaration?: boolean; | ||
| /** | ||
| * enable angular selectorless syntax | ||
| */ | ||
| * enable angular selectorless syntax | ||
| */ | ||
| enableAngularSelectorlessSyntax?: boolean; | ||
| } | ||
| declare function parse(input: string, options?: ParseOptions): ParseTreeResult; | ||
| declare function parseHtml(input: string, options?: HtmlParseOptions): ParseTreeResult; | ||
| declare function parseXml(input: string): ParseTreeResult; | ||
| //#endregion | ||
| export { type ast_d_exports as Ast, ParseLocation, ParseOptions, ParseSourceFile, ParseSourceSpan, type ParseTreeResult, RecursiveVisitor, TagContentType, getHtmlTagDefinition, parse, visitAll }; | ||
| export { type ast_d_exports as Ast, HtmlParseOptions, type HtmlParseOptions as ParseOptions, ParseLocation, ParseSourceFile, ParseSourceSpan, type ParseTreeResult, RecursiveVisitor, TagContentType, getHtmlTagDefinition, parseHtml as parse, parseHtml, parseXml, visitAll }; |
+11
-8
@@ -6,12 +6,10 @@ import { TagContentType } from "./compiler/src/ml_parser/tags.mjs"; | ||
| import { HtmlParser } from "./compiler/src/ml_parser/html_parser.mjs"; | ||
| import { XmlParser } from "./compiler/src/ml_parser/xml_parser.mjs"; | ||
| //#region src/index.ts | ||
| let parser = null; | ||
| const getParser = () => { | ||
| if (!parser) parser = new HtmlParser(); | ||
| return parser; | ||
| }; | ||
| function parse(input, options = {}) { | ||
| let htmlParser; | ||
| function parseHtml(input, options = {}) { | ||
| const { canSelfClose = false, allowHtmComponentClosingTags = false, isTagNameCaseSensitive = false, getTagContentType, tokenizeAngularBlocks = false, tokenizeAngularLetDeclaration = false, enableAngularSelectorlessSyntax = false } = options; | ||
| return getParser().parse(input, "angular-html-parser", { | ||
| htmlParser ?? (htmlParser = new HtmlParser()); | ||
| return htmlParser.parse(input, "angular-html-parser", { | ||
| tokenizeExpansionForms: tokenizeAngularBlocks, | ||
@@ -25,4 +23,9 @@ canSelfClose, | ||
| } | ||
| let xmlParser; | ||
| function parseXml(input) { | ||
| xmlParser ?? (xmlParser = new XmlParser()); | ||
| return xmlParser.parse(input, "angular-xml-parser"); | ||
| } | ||
| //#endregion | ||
| export { ParseLocation, ParseSourceFile, ParseSourceSpan, RecursiveVisitor, TagContentType, getHtmlTagDefinition, parse, visitAll }; | ||
| export { ParseLocation, ParseSourceFile, ParseSourceSpan, RecursiveVisitor, TagContentType, getHtmlTagDefinition, parseHtml as parse, parseHtml, parseXml, visitAll }; |
+1
-1
| { | ||
| "name": "angular-html-parser", | ||
| "version": "10.3.0", | ||
| "version": "10.4.0", | ||
| "description": "A HTML parser extracted from Angular with some modifications", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/prettier/angular-html-parser", |
195596
0.91%31
6.9%5278
1.4%