From 83354b2b88218090988dd6e526b0a2505b57e0f1 Mon Sep 17 00:00:00 2001 From: RaindropsSys Date: Thu, 6 Apr 2023 22:18:28 +0200 Subject: Updated 5 files and added 1110 files (automated) --- .../dist/parser/formatting-element-list.d.ts | 37 + .../parse5/dist/parser/formatting-element-list.js | 111 + .../node_modules/parse5/dist/parser/index.d.ts | 157 + .../node_modules/parse5/dist/parser/index.js | 3168 ++++++++++++++++++++ .../parse5/dist/parser/open-element-stack.d.ts | 53 + .../parse5/dist/parser/open-element-stack.js | 312 ++ 6 files changed, 3838 insertions(+) create mode 100644 includes/external/addressbook/node_modules/parse5/dist/parser/formatting-element-list.d.ts create mode 100644 includes/external/addressbook/node_modules/parse5/dist/parser/formatting-element-list.js create mode 100644 includes/external/addressbook/node_modules/parse5/dist/parser/index.d.ts create mode 100644 includes/external/addressbook/node_modules/parse5/dist/parser/index.js create mode 100644 includes/external/addressbook/node_modules/parse5/dist/parser/open-element-stack.d.ts create mode 100644 includes/external/addressbook/node_modules/parse5/dist/parser/open-element-stack.js (limited to 'includes/external/addressbook/node_modules/parse5/dist/parser') diff --git a/includes/external/addressbook/node_modules/parse5/dist/parser/formatting-element-list.d.ts b/includes/external/addressbook/node_modules/parse5/dist/parser/formatting-element-list.d.ts new file mode 100644 index 0000000..d6c9dcd --- /dev/null +++ b/includes/external/addressbook/node_modules/parse5/dist/parser/formatting-element-list.d.ts @@ -0,0 +1,37 @@ +import type { TagToken } from '../common/token.js'; +import type { TreeAdapter, TreeAdapterTypeMap } from '../tree-adapters/interface.js'; +export declare enum EntryType { + Marker = 0, + Element = 1 +} +interface MarkerEntry { + type: EntryType.Marker; +} +export interface ElementEntry { + type: EntryType.Element; + element: T['element']; + token: TagToken; +} +export type Entry = MarkerEntry | ElementEntry; +export declare class FormattingElementList { + private treeAdapter; + entries: Entry[]; + bookmark: Entry | null; + constructor(treeAdapter: TreeAdapter); + private _getNoahArkConditionCandidates; + private _ensureNoahArkCondition; + insertMarker(): void; + pushElement(element: T['element'], token: TagToken): void; + insertElementAfterBookmark(element: T['element'], token: TagToken): void; + removeEntry(entry: Entry): void; + /** + * Clears the list of formatting elements up to the last marker. + * + * @see https://html.spec.whatwg.org/multipage/parsing.html#clear-the-list-of-active-formatting-elements-up-to-the-last-marker + */ + clearToLastMarker(): void; + getElementEntryInScopeWithTagName(tagName: string): ElementEntry | null; + getElementEntry(element: T['element']): ElementEntry | undefined; +} +export {}; +//# sourceMappingURL=formatting-element-list.d.ts.map \ No newline at end of file diff --git a/includes/external/addressbook/node_modules/parse5/dist/parser/formatting-element-list.js b/includes/external/addressbook/node_modules/parse5/dist/parser/formatting-element-list.js new file mode 100644 index 0000000..32736bc --- /dev/null +++ b/includes/external/addressbook/node_modules/parse5/dist/parser/formatting-element-list.js @@ -0,0 +1,111 @@ +//Const +const NOAH_ARK_CAPACITY = 3; +export var EntryType; +(function (EntryType) { + EntryType[EntryType["Marker"] = 0] = "Marker"; + EntryType[EntryType["Element"] = 1] = "Element"; +})(EntryType = EntryType || (EntryType = {})); +const MARKER = { type: EntryType.Marker }; +//List of formatting elements +export class FormattingElementList { + constructor(treeAdapter) { + this.treeAdapter = treeAdapter; + this.entries = []; + this.bookmark = null; + } + //Noah Ark's condition + //OPTIMIZATION: at first we try to find possible candidates for exclusion using + //lightweight heuristics without thorough attributes check. + _getNoahArkConditionCandidates(newElement, neAttrs) { + const candidates = []; + const neAttrsLength = neAttrs.length; + const neTagName = this.treeAdapter.getTagName(newElement); + const neNamespaceURI = this.treeAdapter.getNamespaceURI(newElement); + for (let i = 0; i < this.entries.length; i++) { + const entry = this.entries[i]; + if (entry.type === EntryType.Marker) { + break; + } + const { element } = entry; + if (this.treeAdapter.getTagName(element) === neTagName && + this.treeAdapter.getNamespaceURI(element) === neNamespaceURI) { + const elementAttrs = this.treeAdapter.getAttrList(element); + if (elementAttrs.length === neAttrsLength) { + candidates.push({ idx: i, attrs: elementAttrs }); + } + } + } + return candidates; + } + _ensureNoahArkCondition(newElement) { + if (this.entries.length < NOAH_ARK_CAPACITY) + return; + const neAttrs = this.treeAdapter.getAttrList(newElement); + const candidates = this._getNoahArkConditionCandidates(newElement, neAttrs); + if (candidates.length < NOAH_ARK_CAPACITY) + return; + //NOTE: build attrs map for the new element, so we can perform fast lookups + const neAttrsMap = new Map(neAttrs.map((neAttr) => [neAttr.name, neAttr.value])); + let validCandidates = 0; + //NOTE: remove bottommost candidates, until Noah's Ark condition will not be met + for (let i = 0; i < candidates.length; i++) { + const candidate = candidates[i]; + // We know that `candidate.attrs.length === neAttrs.length` + if (candidate.attrs.every((cAttr) => neAttrsMap.get(cAttr.name) === cAttr.value)) { + validCandidates += 1; + if (validCandidates >= NOAH_ARK_CAPACITY) { + this.entries.splice(candidate.idx, 1); + } + } + } + } + //Mutations + insertMarker() { + this.entries.unshift(MARKER); + } + pushElement(element, token) { + this._ensureNoahArkCondition(element); + this.entries.unshift({ + type: EntryType.Element, + element, + token, + }); + } + insertElementAfterBookmark(element, token) { + const bookmarkIdx = this.entries.indexOf(this.bookmark); + this.entries.splice(bookmarkIdx, 0, { + type: EntryType.Element, + element, + token, + }); + } + removeEntry(entry) { + const entryIndex = this.entries.indexOf(entry); + if (entryIndex >= 0) { + this.entries.splice(entryIndex, 1); + } + } + /** + * Clears the list of formatting elements up to the last marker. + * + * @see https://html.spec.whatwg.org/multipage/parsing.html#clear-the-list-of-active-formatting-elements-up-to-the-last-marker + */ + clearToLastMarker() { + const markerIdx = this.entries.indexOf(MARKER); + if (markerIdx >= 0) { + this.entries.splice(0, markerIdx + 1); + } + else { + this.entries.length = 0; + } + } + //Search + getElementEntryInScopeWithTagName(tagName) { + const entry = this.entries.find((entry) => entry.type === EntryType.Marker || this.treeAdapter.getTagName(entry.element) === tagName); + return entry && entry.type === EntryType.Element ? entry : null; + } + getElementEntry(element) { + return this.entries.find((entry) => entry.type === EntryType.Element && entry.element === element); + } +} +//# sourceMappingURL=formatting-element-list.js.map \ No newline at end of file diff --git a/includes/external/addressbook/node_modules/parse5/dist/parser/index.d.ts b/includes/external/addressbook/node_modules/parse5/dist/parser/index.d.ts new file mode 100644 index 0000000..50a9bd0 --- /dev/null +++ b/includes/external/addressbook/node_modules/parse5/dist/parser/index.d.ts @@ -0,0 +1,157 @@ +import { Tokenizer, TokenizerMode, type TokenHandler } from '../tokenizer/index.js'; +import { OpenElementStack, type StackHandler } from './open-element-stack.js'; +import { FormattingElementList } from './formatting-element-list.js'; +import { ERR, type ParserErrorHandler } from '../common/error-codes.js'; +import { TAG_ID as $, NS } from '../common/html.js'; +import type { TreeAdapter, TreeAdapterTypeMap } from '../tree-adapters/interface.js'; +import { type Token, type CommentToken, type CharacterToken, type TagToken, type DoctypeToken, type EOFToken, type LocationWithAttributes } from '../common/token.js'; +declare enum InsertionMode { + INITIAL = 0, + BEFORE_HTML = 1, + BEFORE_HEAD = 2, + IN_HEAD = 3, + IN_HEAD_NO_SCRIPT = 4, + AFTER_HEAD = 5, + IN_BODY = 6, + TEXT = 7, + IN_TABLE = 8, + IN_TABLE_TEXT = 9, + IN_CAPTION = 10, + IN_COLUMN_GROUP = 11, + IN_TABLE_BODY = 12, + IN_ROW = 13, + IN_CELL = 14, + IN_SELECT = 15, + IN_SELECT_IN_TABLE = 16, + IN_TEMPLATE = 17, + AFTER_BODY = 18, + IN_FRAMESET = 19, + AFTER_FRAMESET = 20, + AFTER_AFTER_BODY = 21, + AFTER_AFTER_FRAMESET = 22 +} +export interface ParserOptions { + /** + * The [scripting flag](https://html.spec.whatwg.org/multipage/parsing.html#scripting-flag). If set + * to `true`, `noscript` element content will be parsed as text. + * + * @default `true` + */ + scriptingEnabled?: boolean; + /** + * Enables source code location information. When enabled, each node (except the root node) + * will have a `sourceCodeLocation` property. If the node is not an empty element, `sourceCodeLocation` will + * be a {@link ElementLocation} object, otherwise it will be {@link Location}. + * If the element was implicitly created by the parser (as part of + * [tree correction](https://html.spec.whatwg.org/multipage/syntax.html#an-introduction-to-error-handling-and-strange-cases-in-the-parser)), + * its `sourceCodeLocation` property will be `undefined`. + * + * @default `false` + */ + sourceCodeLocationInfo?: boolean; + /** + * Specifies the resulting tree format. + * + * @default `treeAdapters.default` + */ + treeAdapter?: TreeAdapter; + /** + * Callback for parse errors. + * + * @default `null` + */ + onParseError?: ParserErrorHandler | null; +} +export declare class Parser implements TokenHandler, StackHandler { + fragmentContext: T['element'] | null; + scriptHandler: null | ((pendingScript: T['element']) => void); + treeAdapter: TreeAdapter; + onParseError: ParserErrorHandler | null; + private currentToken; + options: Required>; + document: T['document']; + constructor(options?: ParserOptions, document?: T['document'], fragmentContext?: T['element'] | null, scriptHandler?: null | ((pendingScript: T['element']) => void)); + static parse(html: string, options?: ParserOptions): T['document']; + static getFragmentParser(fragmentContext?: T['parentNode'] | null, options?: ParserOptions): Parser; + getFragment(): T['documentFragment']; + tokenizer: Tokenizer; + stopped: boolean; + insertionMode: InsertionMode; + originalInsertionMode: InsertionMode; + fragmentContextID: $; + headElement: null | T['element']; + formElement: null | T['element']; + openElements: OpenElementStack; + activeFormattingElements: FormattingElementList; + /** Indicates that the current node is not an element in the HTML namespace */ + private currentNotInHTML; + /** + * The template insertion mode stack is maintained from the left. + * Ie. the topmost element will always have index 0. + */ + tmplInsertionModeStack: InsertionMode[]; + pendingCharacterTokens: CharacterToken[]; + hasNonWhitespacePendingCharacterToken: boolean; + framesetOk: boolean; + skipNextNewLine: boolean; + fosterParentingEnabled: boolean; + _err(token: Token, code: ERR, beforeToken?: boolean): void; + onItemPush(node: T['parentNode'], tid: number, isTop: boolean): void; + onItemPop(node: T['parentNode'], isTop: boolean): void; + private _setContextModes; + _switchToTextParsing(currentToken: TagToken, nextTokenizerState: typeof TokenizerMode[keyof typeof TokenizerMode]): void; + switchToPlaintextParsing(): void; + _getAdjustedCurrentElement(): T['element']; + _findFormInFragmentContext(): void; + private _initTokenizerForFragmentParsing; + _setDocumentType(token: DoctypeToken): void; + _attachElementToTree(element: T['element'], location: LocationWithAttributes | null): void; + _appendElement(token: TagToken, namespaceURI: NS): void; + _insertElement(token: TagToken, namespaceURI: NS): void; + _insertFakeElement(tagName: string, tagID: $): void; + _insertTemplate(token: TagToken): void; + _insertFakeRootElement(): void; + _appendCommentNode(token: CommentToken, parent: T['parentNode']): void; + _insertCharacters(token: CharacterToken): void; + _adoptNodes(donor: T['parentNode'], recipient: T['parentNode']): void; + _setEndLocation(element: T['element'], closingToken: Token): void; + private shouldProcessStartTagTokenInForeignContent; + _processToken(token: Token): void; + _isIntegrationPoint(tid: $, element: T['element'], foreignNS?: NS): boolean; + _reconstructActiveFormattingElements(): void; + _closeTableCell(): void; + _closePElement(): void; + _resetInsertionMode(): void; + _resetInsertionModeForSelect(selectIdx: number): void; + _isElementCausesFosterParenting(tn: $): boolean; + _shouldFosterParentOnInsertion(): boolean; + _findFosterParentingLocation(): { + parent: T['parentNode']; + beforeElement: T['element'] | null; + }; + _fosterParentElement(element: T['element']): void; + _isSpecialElement(element: T['element'], id: $): boolean; + onCharacter(token: CharacterToken): void; + onNullCharacter(token: CharacterToken): void; + onComment(token: CommentToken): void; + onDoctype(token: DoctypeToken): void; + onStartTag(token: TagToken): void; + /** + * Processes a given start tag. + * + * `onStartTag` checks if a self-closing tag was recognized. When a token + * is moved inbetween multiple insertion modes, this check for self-closing + * could lead to false positives. To avoid this, `_processStartTag` is used + * for nested calls. + * + * @param token The token to process. + */ + _processStartTag(token: TagToken): void; + _startTagOutsideForeignContent(token: TagToken): void; + onEndTag(token: TagToken): void; + _endTagOutsideForeignContent(token: TagToken): void; + onEof(token: EOFToken): void; + onWhitespaceCharacter(token: CharacterToken): void; +} +export {}; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/includes/external/addressbook/node_modules/parse5/dist/parser/index.js b/includes/external/addressbook/node_modules/parse5/dist/parser/index.js new file mode 100644 index 0000000..4a3dc7a --- /dev/null +++ b/includes/external/addressbook/node_modules/parse5/dist/parser/index.js @@ -0,0 +1,3168 @@ +import { Tokenizer, TokenizerMode } from '../tokenizer/index.js'; +import { OpenElementStack } from './open-element-stack.js'; +import { FormattingElementList, EntryType } from './formatting-element-list.js'; +import { defaultTreeAdapter } from '../tree-adapters/default.js'; +import * as doctype from '../common/doctype.js'; +import * as foreignContent from '../common/foreign-content.js'; +import { ERR } from '../common/error-codes.js'; +import * as unicode from '../common/unicode.js'; +import { TAG_ID as $, TAG_NAMES as TN, NS, ATTRS, SPECIAL_ELEMENTS, DOCUMENT_MODE, isNumberedHeader, getTagID, } from '../common/html.js'; +import { TokenType, getTokenAttr, } from '../common/token.js'; +//Misc constants +const HIDDEN_INPUT_TYPE = 'hidden'; +//Adoption agency loops iteration count +const AA_OUTER_LOOP_ITER = 8; +const AA_INNER_LOOP_ITER = 3; +//Insertion modes +var InsertionMode; +(function (InsertionMode) { + InsertionMode[InsertionMode["INITIAL"] = 0] = "INITIAL"; + InsertionMode[InsertionMode["BEFORE_HTML"] = 1] = "BEFORE_HTML"; + InsertionMode[InsertionMode["BEFORE_HEAD"] = 2] = "BEFORE_HEAD"; + InsertionMode[InsertionMode["IN_HEAD"] = 3] = "IN_HEAD"; + InsertionMode[InsertionMode["IN_HEAD_NO_SCRIPT"] = 4] = "IN_HEAD_NO_SCRIPT"; + InsertionMode[InsertionMode["AFTER_HEAD"] = 5] = "AFTER_HEAD"; + InsertionMode[InsertionMode["IN_BODY"] = 6] = "IN_BODY"; + InsertionMode[InsertionMode["TEXT"] = 7] = "TEXT"; + InsertionMode[InsertionMode["IN_TABLE"] = 8] = "IN_TABLE"; + InsertionMode[InsertionMode["IN_TABLE_TEXT"] = 9] = "IN_TABLE_TEXT"; + InsertionMode[InsertionMode["IN_CAPTION"] = 10] = "IN_CAPTION"; + InsertionMode[InsertionMode["IN_COLUMN_GROUP"] = 11] = "IN_COLUMN_GROUP"; + InsertionMode[InsertionMode["IN_TABLE_BODY"] = 12] = "IN_TABLE_BODY"; + InsertionMode[InsertionMode["IN_ROW"] = 13] = "IN_ROW"; + InsertionMode[InsertionMode["IN_CELL"] = 14] = "IN_CELL"; + InsertionMode[InsertionMode["IN_SELECT"] = 15] = "IN_SELECT"; + InsertionMode[InsertionMode["IN_SELECT_IN_TABLE"] = 16] = "IN_SELECT_IN_TABLE"; + InsertionMode[InsertionMode["IN_TEMPLATE"] = 17] = "IN_TEMPLATE"; + InsertionMode[InsertionMode["AFTER_BODY"] = 18] = "AFTER_BODY"; + InsertionMode[InsertionMode["IN_FRAMESET"] = 19] = "IN_FRAMESET"; + InsertionMode[InsertionMode["AFTER_FRAMESET"] = 20] = "AFTER_FRAMESET"; + InsertionMode[InsertionMode["AFTER_AFTER_BODY"] = 21] = "AFTER_AFTER_BODY"; + InsertionMode[InsertionMode["AFTER_AFTER_FRAMESET"] = 22] = "AFTER_AFTER_FRAMESET"; +})(InsertionMode || (InsertionMode = {})); +const BASE_LOC = { + startLine: -1, + startCol: -1, + startOffset: -1, + endLine: -1, + endCol: -1, + endOffset: -1, +}; +const TABLE_STRUCTURE_TAGS = new Set([$.TABLE, $.TBODY, $.TFOOT, $.THEAD, $.TR]); +const defaultParserOptions = { + scriptingEnabled: true, + sourceCodeLocationInfo: false, + treeAdapter: defaultTreeAdapter, + onParseError: null, +}; +//Parser +export class Parser { + constructor(options, document, fragmentContext = null, scriptHandler = null) { + this.fragmentContext = fragmentContext; + this.scriptHandler = scriptHandler; + this.currentToken = null; + this.stopped = false; + this.insertionMode = InsertionMode.INITIAL; + this.originalInsertionMode = InsertionMode.INITIAL; + this.headElement = null; + this.formElement = null; + /** Indicates that the current node is not an element in the HTML namespace */ + this.currentNotInHTML = false; + /** + * The template insertion mode stack is maintained from the left. + * Ie. the topmost element will always have index 0. + */ + this.tmplInsertionModeStack = []; + this.pendingCharacterTokens = []; + this.hasNonWhitespacePendingCharacterToken = false; + this.framesetOk = true; + this.skipNextNewLine = false; + this.fosterParentingEnabled = false; + this.options = { + ...defaultParserOptions, + ...options, + }; + this.treeAdapter = this.options.treeAdapter; + this.onParseError = this.options.onParseError; + // Always enable location info if we report parse errors. + if (this.onParseError) { + this.options.sourceCodeLocationInfo = true; + } + this.document = document !== null && document !== void 0 ? document : this.treeAdapter.createDocument(); + this.tokenizer = new Tokenizer(this.options, this); + this.activeFormattingElements = new FormattingElementList(this.treeAdapter); + this.fragmentContextID = fragmentContext ? getTagID(this.treeAdapter.getTagName(fragmentContext)) : $.UNKNOWN; + this._setContextModes(fragmentContext !== null && fragmentContext !== void 0 ? fragmentContext : this.document, this.fragmentContextID); + this.openElements = new OpenElementStack(this.document, this.treeAdapter, this); + } + // API + static parse(html, options) { + const parser = new this(options); + parser.tokenizer.write(html, true); + return parser.document; + } + static getFragmentParser(fragmentContext, options) { + const opts = { + ...defaultParserOptions, + ...options, + }; + //NOTE: use a