@mavogel/cdk-vscode-server 0.0.123 → 0.0.124
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.
- package/.jsii +3 -3
- package/lib/idle-monitor/idle-monitor.js +1 -1
- package/lib/vscode-server.js +1 -1
- package/node_modules/node-html-parser/CHANGELOG.md +79 -0
- package/node_modules/node-html-parser/README.md +39 -39
- package/node_modules/node-html-parser/dist/index.cjs +5079 -0
- package/node_modules/node-html-parser/dist/index.d.ts +10 -10
- package/node_modules/node-html-parser/dist/index.mjs +5068 -0
- package/node_modules/node-html-parser/dist/index.umd.js +5083 -0
- package/node_modules/node-html-parser/dist/matcher.d.ts +22 -6
- package/node_modules/node-html-parser/dist/nodes/comment.d.ts +1 -1
- package/node_modules/node-html-parser/dist/nodes/html.d.ts +2 -2
- package/node_modules/node-html-parser/dist/nodes/node.d.ts +2 -2
- package/node_modules/node-html-parser/dist/nodes/text.d.ts +1 -1
- package/node_modules/node-html-parser/dist/valid.d.ts +1 -1
- package/node_modules/node-html-parser/node_modules/entities/LICENSE +11 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/decode-codepoint.d.ts +28 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/decode-codepoint.d.ts.map +1 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/decode-codepoint.js +61 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/decode-codepoint.js.map +1 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/decode.d.ts +227 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/decode.d.ts.map +1 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/decode.js +1132 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/decode.js.map +1 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/encode.d.ts +26 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/encode.d.ts.map +1 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/encode.js +295 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/encode.js.map +1 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/escape.d.ts +60 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/escape.d.ts.map +1 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/escape.js +172 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/escape.js.map +1 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/generated/decode-data-html.d.ts +3 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/generated/decode-data-html.d.ts.map +1 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/generated/decode-data-html.js +5 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/generated/decode-data-html.js.map +1 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/generated/decode-data-xml.d.ts +3 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/generated/decode-data-xml.d.ts.map +1 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/generated/decode-data-xml.js +7 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/generated/decode-data-xml.js.map +1 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/generated/encode-html.d.ts +3 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/generated/encode-html.d.ts.map +1 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/generated/encode-html.js +3 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/generated/encode-html.js.map +1 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/index.d.ts +89 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/index.d.ts.map +1 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/index.js +87 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/index.js.map +1 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/internal/bin-trie-flags.d.ts +48 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/internal/bin-trie-flags.d.ts.map +1 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/internal/bin-trie-flags.js +49 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/internal/bin-trie-flags.js.map +1 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/internal/decode-shared.d.ts +38 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/internal/decode-shared.d.ts.map +1 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/internal/decode-shared.js +195 -0
- package/node_modules/node-html-parser/node_modules/entities/dist/internal/decode-shared.js.map +1 -0
- package/node_modules/node-html-parser/node_modules/entities/package.json +83 -0
- package/node_modules/node-html-parser/node_modules/entities/readme.md +131 -0
- package/node_modules/node-html-parser/node_modules/entities/src/decode-codepoint.ts +69 -0
- package/node_modules/node-html-parser/node_modules/entities/src/decode.ts +1368 -0
- package/node_modules/node-html-parser/node_modules/entities/src/encode.ts +337 -0
- package/node_modules/node-html-parser/node_modules/entities/src/escape.ts +187 -0
- package/node_modules/node-html-parser/node_modules/entities/src/generated/decode-data-html.ts +12 -0
- package/node_modules/node-html-parser/node_modules/entities/src/generated/decode-data-xml.ts +7 -0
- package/node_modules/node-html-parser/node_modules/entities/src/generated/encode-html.ts +3 -0
- package/node_modules/node-html-parser/node_modules/entities/src/index.ts +160 -0
- package/node_modules/node-html-parser/node_modules/entities/src/internal/bin-trie-flags.ts +47 -0
- package/node_modules/node-html-parser/node_modules/entities/src/internal/decode-shared.ts +209 -0
- package/node_modules/node-html-parser/package.json +35 -30
- package/package.json +3 -3
- package/node_modules/he/LICENSE-MIT.txt +0 -20
- package/node_modules/he/README.md +0 -379
- package/node_modules/he/bin/he +0 -148
- package/node_modules/he/he.js +0 -345
- package/node_modules/he/man/he.1 +0 -78
- package/node_modules/he/package.json +0 -58
- package/node_modules/node-html-parser/dist/back.js +0 -6
- package/node_modules/node-html-parser/dist/index.js +0 -31
- package/node_modules/node-html-parser/dist/main.js +0 -1804
- package/node_modules/node-html-parser/dist/matcher.js +0 -106
- package/node_modules/node-html-parser/dist/nodes/comment.js +0 -33
- package/node_modules/node-html-parser/dist/nodes/html.js +0 -1186
- package/node_modules/node-html-parser/dist/nodes/node.js +0 -41
- package/node_modules/node-html-parser/dist/nodes/text.js +0 -105
- package/node_modules/node-html-parser/dist/nodes/type.js +0 -9
- package/node_modules/node-html-parser/dist/parse.js +0 -5
- package/node_modules/node-html-parser/dist/valid.js +0 -12
- package/node_modules/node-html-parser/dist/void-tag.js +0 -27
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import type HTMLElement from './nodes/html';
|
|
2
|
+
import type Node from './nodes/node';
|
|
3
|
+
/**
|
|
4
|
+
* Minimal Adapter interface matching css-select's Adapter<Node, ElementNode>.
|
|
5
|
+
* Defined locally because css-select v5 does not export its types publicly.
|
|
6
|
+
*/
|
|
7
|
+
interface Adapter {
|
|
8
|
+
isTag: (node: Node) => node is HTMLElement;
|
|
9
|
+
existsOne: (test: (elem: HTMLElement) => boolean, elems: Node[]) => boolean;
|
|
10
|
+
getAttributeValue: (elem: HTMLElement, name: string) => string | undefined;
|
|
11
|
+
getChildren: (node: Node) => Node[];
|
|
12
|
+
getName: (elem: HTMLElement) => string;
|
|
13
|
+
getParent: (node: HTMLElement) => Node | null;
|
|
14
|
+
getSiblings: (node: Node) => Node[];
|
|
15
|
+
getText: (node: Node) => string;
|
|
16
|
+
hasAttrib: (elem: HTMLElement, name: string) => boolean;
|
|
17
|
+
removeSubsets: (nodes: Node[]) => Node[];
|
|
18
|
+
findAll: (test: (elem: HTMLElement) => boolean, nodes: Node[]) => HTMLElement[];
|
|
19
|
+
findOne: (test: (elem: HTMLElement) => boolean, elems: Node[]) => HTMLElement | null;
|
|
20
|
+
}
|
|
21
|
+
declare const matcher: Adapter;
|
|
22
|
+
export default matcher;
|
|
@@ -5,7 +5,7 @@ export default class CommentNode extends Node {
|
|
|
5
5
|
rawText: string;
|
|
6
6
|
rawTagName: string;
|
|
7
7
|
clone(): CommentNode;
|
|
8
|
-
constructor(rawText: string, parentNode?: HTMLElement, range?: [number, number], rawTagName?: string);
|
|
8
|
+
constructor(rawText: string, parentNode?: HTMLElement | null, range?: [number, number], rawTagName?: string);
|
|
9
9
|
/**
|
|
10
10
|
* Node Type declaration.
|
|
11
11
|
* @type {Number}
|
|
@@ -24,7 +24,7 @@ declare class DOMTokenList {
|
|
|
24
24
|
toggle(c: string): void;
|
|
25
25
|
contains(c: string): boolean;
|
|
26
26
|
get length(): number;
|
|
27
|
-
values():
|
|
27
|
+
values(): SetIterator<string>;
|
|
28
28
|
get value(): string[];
|
|
29
29
|
toString(): string;
|
|
30
30
|
}
|
|
@@ -63,7 +63,7 @@ export default class HTMLElement extends Node {
|
|
|
63
63
|
*
|
|
64
64
|
* @memberof HTMLElement
|
|
65
65
|
*/
|
|
66
|
-
constructor(tagName: string, keyAttrs: KeyAttributes, rawAttrs?: string, parentNode?: HTMLElement, range?: [number, number], voidTag?: VoidTag, _parseOptions?: Partial<Options>);
|
|
66
|
+
constructor(tagName: string, keyAttrs: KeyAttributes, rawAttrs?: string, parentNode?: HTMLElement | null, range?: [number, number], voidTag?: VoidTag, _parseOptions?: Partial<Options>);
|
|
67
67
|
/**
|
|
68
68
|
* Remove Child element from childNodes array
|
|
69
69
|
* @param {HTMLElement} node node to remove
|
|
@@ -4,7 +4,7 @@ import HTMLElement from './html';
|
|
|
4
4
|
* Node Class as base class for TextNode and HTMLElement.
|
|
5
5
|
*/
|
|
6
6
|
export default abstract class Node {
|
|
7
|
-
parentNode: HTMLElement;
|
|
7
|
+
parentNode: HTMLElement | null;
|
|
8
8
|
abstract rawTagName: string;
|
|
9
9
|
abstract nodeType: NodeType;
|
|
10
10
|
childNodes: Node[];
|
|
@@ -13,7 +13,7 @@ export default abstract class Node {
|
|
|
13
13
|
abstract rawText: string;
|
|
14
14
|
abstract toString(): string;
|
|
15
15
|
abstract clone(): Node;
|
|
16
|
-
constructor(parentNode?: HTMLElement, range?: [number, number]);
|
|
16
|
+
constructor(parentNode?: HTMLElement | null, range?: [number, number]);
|
|
17
17
|
/**
|
|
18
18
|
* Remove current node
|
|
19
19
|
*/
|
|
@@ -7,7 +7,7 @@ import NodeType from './type';
|
|
|
7
7
|
*/
|
|
8
8
|
export default class TextNode extends Node {
|
|
9
9
|
clone(): TextNode;
|
|
10
|
-
constructor(rawText: string, parentNode?: HTMLElement, range?: [number, number]);
|
|
10
|
+
constructor(rawText: string, parentNode?: HTMLElement | null, range?: [number, number]);
|
|
11
11
|
/**
|
|
12
12
|
* Node Type declaration.
|
|
13
13
|
* @type {Number}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Copyright (c) Felix Böhm
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
5
|
+
|
|
6
|
+
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
7
|
+
|
|
8
|
+
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
9
|
+
|
|
10
|
+
THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS,
|
|
11
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Replace the given code point with U+FFFD if it is NUL (0), a surrogate, or
|
|
3
|
+
* outside the valid Unicode range. Code points in the C1 controls range
|
|
4
|
+
* (128–159) are remapped to their Windows-1252 equivalents, following the
|
|
5
|
+
* HTML spec. All other code points are returned unchanged.
|
|
6
|
+
* @param codePoint Unicode code point to convert.
|
|
7
|
+
*/
|
|
8
|
+
export declare function replaceCodePoint(codePoint: number): number;
|
|
9
|
+
/**
|
|
10
|
+
* XML numeric character references are the referenced Unicode code point.
|
|
11
|
+
* Invalid values still become U+FFFD; the HTML Windows-1252 C1 remap is not
|
|
12
|
+
* applied.
|
|
13
|
+
* @see https://www.w3.org/TR/xml/#NT-CharRef
|
|
14
|
+
* @param codePoint Unicode code point to convert.
|
|
15
|
+
*/
|
|
16
|
+
export declare function replaceCodePointXML(codePoint: number): number;
|
|
17
|
+
/**
|
|
18
|
+
* Convert the code point of a decoded numeric entity to a string, replacing
|
|
19
|
+
* invalid values.
|
|
20
|
+
*
|
|
21
|
+
* Fast path for plain BMP code points: [1..0x7F] and [0xA0..0xD7FF] pass
|
|
22
|
+
* `replaceCodePoint` unchanged (no NUL, C1 remap, surrogate, or out-of-range
|
|
23
|
+
* handling) and fit a single charCode. 0xd760 = 0xD800 (the first surrogate)
|
|
24
|
+
* - 0xA0.
|
|
25
|
+
* @param codePoint Unicode code point to convert.
|
|
26
|
+
*/
|
|
27
|
+
export declare function codePointToString(codePoint: number): string;
|
|
28
|
+
//# sourceMappingURL=decode-codepoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode-codepoint.d.ts","sourceRoot":"","sources":["../src/decode-codepoint.ts"],"names":[],"mappings":"AAwBA;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAU1D;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAI3D"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Adapted from https://github.com/mathiasbynens/he/blob/36afe179392226cf1b6ccdb16ebbb7a5a844d93a/src/he.js#L106-L134
|
|
2
|
+
/**
|
|
3
|
+
* C1 Unicode control character reference replacements (code points 128–159).
|
|
4
|
+
* Index i gives the replacement for code point 128+i; 0 means "no replacement".
|
|
5
|
+
*/
|
|
6
|
+
const c1 = [
|
|
7
|
+
8364, 0, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 352, 8249, 338, 0,
|
|
8
|
+
381, 0, 0, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 732, 8482, 353, 8250,
|
|
9
|
+
339, 0, 382, 376,
|
|
10
|
+
];
|
|
11
|
+
/**
|
|
12
|
+
* True for NUL, UTF-16 surrogates, and values past U+10FFFF.
|
|
13
|
+
* @param codePoint Unicode code point to check.
|
|
14
|
+
*/
|
|
15
|
+
function isInvalidCodePoint(codePoint) {
|
|
16
|
+
return (codePoint === 0 ||
|
|
17
|
+
(codePoint >= 0xd8_00 && codePoint <= 0xdf_ff) ||
|
|
18
|
+
codePoint > 0x10_ff_ff);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Replace the given code point with U+FFFD if it is NUL (0), a surrogate, or
|
|
22
|
+
* outside the valid Unicode range. Code points in the C1 controls range
|
|
23
|
+
* (128–159) are remapped to their Windows-1252 equivalents, following the
|
|
24
|
+
* HTML spec. All other code points are returned unchanged.
|
|
25
|
+
* @param codePoint Unicode code point to convert.
|
|
26
|
+
*/
|
|
27
|
+
export function replaceCodePoint(codePoint) {
|
|
28
|
+
if (isInvalidCodePoint(codePoint)) {
|
|
29
|
+
return 0xff_fd;
|
|
30
|
+
}
|
|
31
|
+
if (codePoint >= 128 && codePoint <= 159) {
|
|
32
|
+
return c1[codePoint - 128] || codePoint;
|
|
33
|
+
}
|
|
34
|
+
return codePoint;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* XML numeric character references are the referenced Unicode code point.
|
|
38
|
+
* Invalid values still become U+FFFD; the HTML Windows-1252 C1 remap is not
|
|
39
|
+
* applied.
|
|
40
|
+
* @see https://www.w3.org/TR/xml/#NT-CharRef
|
|
41
|
+
* @param codePoint Unicode code point to convert.
|
|
42
|
+
*/
|
|
43
|
+
export function replaceCodePointXML(codePoint) {
|
|
44
|
+
return isInvalidCodePoint(codePoint) ? 0xff_fd : codePoint;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Convert the code point of a decoded numeric entity to a string, replacing
|
|
48
|
+
* invalid values.
|
|
49
|
+
*
|
|
50
|
+
* Fast path for plain BMP code points: [1..0x7F] and [0xA0..0xD7FF] pass
|
|
51
|
+
* `replaceCodePoint` unchanged (no NUL, C1 remap, surrogate, or out-of-range
|
|
52
|
+
* handling) and fit a single charCode. 0xd760 = 0xD800 (the first surrogate)
|
|
53
|
+
* - 0xA0.
|
|
54
|
+
* @param codePoint Unicode code point to convert.
|
|
55
|
+
*/
|
|
56
|
+
export function codePointToString(codePoint) {
|
|
57
|
+
return (codePoint - 1) >>> 0 < 0x7f || (codePoint - 0xa0) >>> 0 < 0xd7_60
|
|
58
|
+
? String.fromCharCode(codePoint)
|
|
59
|
+
: String.fromCodePoint(replaceCodePoint(codePoint));
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=decode-codepoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode-codepoint.js","sourceRoot":"","sources":["../src/decode-codepoint.ts"],"names":[],"mappings":"AAAA,qHAAqH;AAErH;;;GAGG;AACH,MAAM,EAAE,GAAa;IACjB,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,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AAC,SAAS,CAAC;QAChC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC;AAC5D,CAAC"}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decoding mode for named entities.
|
|
3
|
+
*/
|
|
4
|
+
export declare enum DecodingMode {
|
|
5
|
+
/** Entities in text nodes that can end with any character. */
|
|
6
|
+
Legacy = 0,
|
|
7
|
+
/** Only allow entities terminated with a semicolon. */
|
|
8
|
+
Strict = 1,
|
|
9
|
+
/** Entities in attributes have limitations on ending characters. */
|
|
10
|
+
Attribute = 2
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Producers for character reference errors as defined in the HTML spec.
|
|
14
|
+
*/
|
|
15
|
+
export interface EntityErrorProducer {
|
|
16
|
+
missingSemicolonAfterCharacterReference(): void;
|
|
17
|
+
absenceOfDigitsInNumericCharacterReference(consumedCharacters: number): void;
|
|
18
|
+
/**
|
|
19
|
+
* Validate the accumulated numeric value, before Unicode replacement.
|
|
20
|
+
* Values beyond the JavaScript number range are positive infinity.
|
|
21
|
+
*/
|
|
22
|
+
validateNumericCharacterReference(code: number): void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Token decoder with support of writing partial entities.
|
|
26
|
+
*/
|
|
27
|
+
export declare class EntityDecoder {
|
|
28
|
+
/** The predefined HTML or XML decode tree. */
|
|
29
|
+
private readonly decodeTree;
|
|
30
|
+
/**
|
|
31
|
+
* The function that is called when a codepoint is decoded.
|
|
32
|
+
*
|
|
33
|
+
* For named entities that decode to multiple code points, this will
|
|
34
|
+
* be called multiple times, with the second codepoint, and the same
|
|
35
|
+
* `consumed` value.
|
|
36
|
+
* @param codepoint The decoded codepoint.
|
|
37
|
+
* @param consumed The number of characters consumed by the decoder.
|
|
38
|
+
*/
|
|
39
|
+
private readonly emitCodePoint;
|
|
40
|
+
/** An object that is used to produce errors. */
|
|
41
|
+
private readonly errors?;
|
|
42
|
+
/** The current state of the decoder. */
|
|
43
|
+
private state;
|
|
44
|
+
/** Characters that were consumed while parsing an entity. */
|
|
45
|
+
private consumed;
|
|
46
|
+
/**
|
|
47
|
+
* The result of the entity.
|
|
48
|
+
*
|
|
49
|
+
* For named entities: the trie index of the best legacy match so far
|
|
50
|
+
* (0 = none). For numeric entities: the accumulated code point.
|
|
51
|
+
*/
|
|
52
|
+
private result;
|
|
53
|
+
/** The current index in the decode tree. */
|
|
54
|
+
private treeIndex;
|
|
55
|
+
/**
|
|
56
|
+
* Characters consumed since the last recorded legacy match, plus one.
|
|
57
|
+
* Invariant at the top of the `stateNamedEntity` loop: `excess` equals
|
|
58
|
+
* the number of unrecorded consumed characters + 1.
|
|
59
|
+
*/
|
|
60
|
+
private excess;
|
|
61
|
+
/** The mode in which the decoder is operating. */
|
|
62
|
+
private decodeMode;
|
|
63
|
+
/** The number of characters that have been consumed in the current run. */
|
|
64
|
+
private runConsumed;
|
|
65
|
+
constructor(
|
|
66
|
+
/** The predefined HTML or XML decode tree. */
|
|
67
|
+
decodeTree: Uint16Array,
|
|
68
|
+
/**
|
|
69
|
+
* The function that is called when a codepoint is decoded.
|
|
70
|
+
*
|
|
71
|
+
* For named entities that decode to multiple code points, this will
|
|
72
|
+
* be called multiple times, with the second codepoint, and the same
|
|
73
|
+
* `consumed` value.
|
|
74
|
+
* @param codepoint The decoded codepoint.
|
|
75
|
+
* @param consumed The number of characters consumed by the decoder.
|
|
76
|
+
*/
|
|
77
|
+
emitCodePoint: (cp: number, consumed: number) => void,
|
|
78
|
+
/** An object that is used to produce errors. */
|
|
79
|
+
errors?: EntityErrorProducer | undefined);
|
|
80
|
+
/**
|
|
81
|
+
* Resets the instance to make it reusable.
|
|
82
|
+
* @param decodeMode Entity decoding mode to use.
|
|
83
|
+
*/
|
|
84
|
+
startEntity(decodeMode: DecodingMode): void;
|
|
85
|
+
/**
|
|
86
|
+
* Write an entity to the decoder. This can be called multiple times with partial entities.
|
|
87
|
+
* If the entity is incomplete, the decoder will return -1.
|
|
88
|
+
*
|
|
89
|
+
* Mirrors the non-streaming `decodeWithTrie`, but with the ability to stop decoding if the
|
|
90
|
+
* entity is incomplete, and resume when the next string is written.
|
|
91
|
+
* @param input The string containing the entity (or a continuation of the entity).
|
|
92
|
+
* @param offset The offset at which the entity begins. Should be 0 if this is not the first call.
|
|
93
|
+
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
94
|
+
*/
|
|
95
|
+
write(input: string, offset: number): number;
|
|
96
|
+
/**
|
|
97
|
+
* Switches between the numeric decimal and hexadecimal states.
|
|
98
|
+
*
|
|
99
|
+
* Equivalent to the `Numeric character reference state` in the HTML spec.
|
|
100
|
+
* @param input The string containing the entity (or a continuation of the entity).
|
|
101
|
+
* @param offset The current offset.
|
|
102
|
+
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
103
|
+
*/
|
|
104
|
+
private stateNumericStart;
|
|
105
|
+
/**
|
|
106
|
+
* Parses a hexadecimal numeric entity.
|
|
107
|
+
*
|
|
108
|
+
* Equivalent to the `Hexademical character reference state` in the HTML
|
|
109
|
+
* spec. Digit parsing matches the hex loop in `parseNumericEntity`.
|
|
110
|
+
* The accumulated value is preserved for numeric validation callbacks.
|
|
111
|
+
* @param input The string containing the entity (or a continuation of the entity).
|
|
112
|
+
* @param offset The current offset.
|
|
113
|
+
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
114
|
+
*/
|
|
115
|
+
private stateNumericHex;
|
|
116
|
+
/**
|
|
117
|
+
* Parses a decimal numeric entity.
|
|
118
|
+
*
|
|
119
|
+
* Equivalent to the `Decimal character reference state` in the HTML
|
|
120
|
+
* spec. Digit parsing matches the decimal loop in `parseNumericEntity`.
|
|
121
|
+
* The accumulated value is preserved for numeric validation callbacks.
|
|
122
|
+
* @param input The string containing the entity (or a continuation of the entity).
|
|
123
|
+
* @param offset The current offset.
|
|
124
|
+
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
125
|
+
*/
|
|
126
|
+
private stateNumericDecimal;
|
|
127
|
+
/**
|
|
128
|
+
* Validate and emit a numeric entity.
|
|
129
|
+
*
|
|
130
|
+
* Implements the logic from the `Hexademical character reference start
|
|
131
|
+
* state` and `Numeric character reference end state` in the HTML spec.
|
|
132
|
+
* @param lastCp The last code point of the entity. Used to see if the
|
|
133
|
+
* entity was terminated with a semicolon.
|
|
134
|
+
* @param expectedLength The minimum number of characters that should be
|
|
135
|
+
* consumed. Used to validate that at least one digit
|
|
136
|
+
* was consumed.
|
|
137
|
+
* @returns The number of characters that were consumed.
|
|
138
|
+
*/
|
|
139
|
+
private emitNumericEntity;
|
|
140
|
+
/**
|
|
141
|
+
* Flush locally-tracked walk state back to the fields, then emit the
|
|
142
|
+
* recorded legacy match or reject (cold path — at most once per
|
|
143
|
+
* entity). Called after failed navigation (leaf node, branch miss, or
|
|
144
|
+
* compact-run mismatch). In attribute mode, reject if no legacy was
|
|
145
|
+
* recorded at the current node, if we descended past it, or if the
|
|
146
|
+
* pending input character is an invalid attribute terminator.
|
|
147
|
+
* @param consumed Locally-tracked consumed count.
|
|
148
|
+
* @param excess Locally-tracked excess count.
|
|
149
|
+
* @param char Pending input character (may be the mismatching char).
|
|
150
|
+
* @param valueLength Value length at the current trie node.
|
|
151
|
+
*/
|
|
152
|
+
private flushAndEmitLegacyOrReject;
|
|
153
|
+
/**
|
|
154
|
+
* Parses a named entity.
|
|
155
|
+
*
|
|
156
|
+
* Equivalent to the `Named character reference state` in the HTML spec.
|
|
157
|
+
* @param input The string containing the entity (or a continuation of the entity).
|
|
158
|
+
* @param offset The current offset.
|
|
159
|
+
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
160
|
+
*/
|
|
161
|
+
private stateNamedEntity;
|
|
162
|
+
/**
|
|
163
|
+
* Emit a named entity that was not terminated with a semicolon.
|
|
164
|
+
* @returns The number of characters consumed.
|
|
165
|
+
*/
|
|
166
|
+
private emitNotTerminatedNamedEntity;
|
|
167
|
+
/**
|
|
168
|
+
* Emit a named entity.
|
|
169
|
+
* @param result The index of the entity in the decode tree.
|
|
170
|
+
* @param valueLength Encoded value length (header plus any value words).
|
|
171
|
+
* @param consumed The number of characters consumed.
|
|
172
|
+
* @returns The number of characters consumed.
|
|
173
|
+
*/
|
|
174
|
+
private emitNamedEntityData;
|
|
175
|
+
/**
|
|
176
|
+
* Signal to the parser that the end of the input was reached.
|
|
177
|
+
*
|
|
178
|
+
* Remaining data will be emitted and relevant errors will be produced.
|
|
179
|
+
* @returns The number of characters consumed.
|
|
180
|
+
*/
|
|
181
|
+
end(): number;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Determines the branch of the current node that is taken given the current
|
|
185
|
+
* character. This function is used to traverse the trie.
|
|
186
|
+
*
|
|
187
|
+
* See `BinTrieFlags` for the branch-data layouts handled here.
|
|
188
|
+
* @param decodeTree The trie.
|
|
189
|
+
* @param current The current node's header word.
|
|
190
|
+
* @param nodeIndex Index of the node's first branch-data word (the header
|
|
191
|
+
* plus any value words have been skipped by the caller).
|
|
192
|
+
* @param char The current character.
|
|
193
|
+
* @returns The index of the next node, or -1 if no branch is taken.
|
|
194
|
+
*/
|
|
195
|
+
export declare function determineBranch(decodeTree: Uint16Array, current: number, nodeIndex: number, char: number): number;
|
|
196
|
+
/**
|
|
197
|
+
* Decodes an HTML string.
|
|
198
|
+
* @param htmlString The string to decode.
|
|
199
|
+
* @param mode The decoding mode.
|
|
200
|
+
* @returns The decoded string.
|
|
201
|
+
*/
|
|
202
|
+
export declare function decodeHTML(htmlString: string, mode?: DecodingMode): string;
|
|
203
|
+
/**
|
|
204
|
+
* Decodes an HTML string in an attribute.
|
|
205
|
+
* @param htmlAttribute The string to decode.
|
|
206
|
+
* @returns The decoded string.
|
|
207
|
+
*/
|
|
208
|
+
export declare function decodeHTMLAttribute(htmlAttribute: string): string;
|
|
209
|
+
/**
|
|
210
|
+
* Decodes an HTML string, requiring all entities to be terminated by a semicolon.
|
|
211
|
+
* @param htmlString The string to decode.
|
|
212
|
+
* @returns The decoded string.
|
|
213
|
+
*/
|
|
214
|
+
export declare function decodeHTMLStrict(htmlString: string): string;
|
|
215
|
+
/**
|
|
216
|
+
* Decodes an XML string, requiring all entities to be terminated by a semicolon.
|
|
217
|
+
*
|
|
218
|
+
* Uses a hand-coded fast path for the 5 XML named entities (amp, lt, gt,
|
|
219
|
+
* quot, apos) plus numeric entities, bypassing the trie entirely.
|
|
220
|
+
* @param xmlString The string to decode.
|
|
221
|
+
* @returns The decoded string.
|
|
222
|
+
*/
|
|
223
|
+
export declare function decodeXML(xmlString: string): string;
|
|
224
|
+
export { replaceCodePoint, replaceCodePointXML, } from "./decode-codepoint.js";
|
|
225
|
+
export { htmlDecodeTree } from "./generated/decode-data-html.js";
|
|
226
|
+
export { xmlDecodeTree } from "./generated/decode-data-xml.js";
|
|
227
|
+
//# sourceMappingURL=decode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../src/decode.ts"],"names":[],"mappings":"AAiGA;;GAEG;AACH,oBAAY,YAAY;IACpB,8DAA8D;IAC9D,MAAM,IAAI;IACV,uDAAuD;IACvD,MAAM,IAAI;IACV,oEAAoE;IACpE,SAAS,IAAI;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC,uCAAuC,IAAI,IAAI,CAAC;IAChD,0CAA0C,CACtC,kBAAkB,EAAE,MAAM,GAC3B,IAAI,CAAC;IACR;;;OAGG;IACH,iCAAiC,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACzD;AAED;;GAEG;AACH,qBAAa,aAAa;IA6BlB,8CAA8C;IAC9C,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B;;;;;;;;OAQG;IACH,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,gDAAgD;IAChD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;IAzC5B,wCAAwC;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