entities 2.1.0 → 7.0.1
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/decode.d.ts +3 -0
- package/decode.js +3 -0
- package/dist/commonjs/decode-codepoint.d.ts +19 -0
- package/dist/commonjs/decode-codepoint.d.ts.map +1 -0
- package/dist/commonjs/decode-codepoint.js +77 -0
- package/dist/commonjs/decode-codepoint.js.map +1 -0
- package/dist/commonjs/decode.d.ts +205 -0
- package/dist/commonjs/decode.d.ts.map +1 -0
- package/dist/commonjs/decode.js +568 -0
- package/dist/commonjs/decode.js.map +1 -0
- package/dist/commonjs/encode.d.ts +22 -0
- package/dist/commonjs/encode.d.ts.map +1 -0
- package/dist/commonjs/encode.js +92 -0
- package/dist/commonjs/encode.js.map +1 -0
- package/dist/commonjs/escape.d.ts +46 -0
- package/dist/commonjs/escape.d.ts.map +1 -0
- package/dist/commonjs/escape.js +138 -0
- package/dist/commonjs/escape.js.map +1 -0
- package/dist/commonjs/generated/decode-data-html.d.ts +2 -0
- package/dist/commonjs/generated/decode-data-html.d.ts.map +1 -0
- package/dist/commonjs/generated/decode-data-html.js +7 -0
- package/dist/commonjs/generated/decode-data-html.js.map +1 -0
- package/dist/commonjs/generated/decode-data-xml.d.ts +2 -0
- package/dist/commonjs/generated/decode-data-xml.d.ts.map +1 -0
- package/dist/commonjs/generated/decode-data-xml.js +7 -0
- package/dist/commonjs/generated/decode-data-xml.js.map +1 -0
- package/dist/commonjs/generated/encode-html.d.ts +3 -0
- package/dist/commonjs/generated/encode-html.d.ts.map +1 -0
- package/dist/commonjs/generated/encode-html.js +14 -0
- package/dist/commonjs/generated/encode-html.js.map +1 -0
- package/dist/commonjs/index.d.ts +96 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +131 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/internal/bin-trie-flags.d.ts +17 -0
- package/dist/commonjs/internal/bin-trie-flags.d.ts.map +1 -0
- package/dist/commonjs/internal/bin-trie-flags.js +21 -0
- package/dist/commonjs/internal/bin-trie-flags.js.map +1 -0
- package/dist/commonjs/internal/decode-shared.d.ts +2 -0
- package/dist/commonjs/internal/decode-shared.d.ts.map +1 -0
- package/dist/commonjs/internal/decode-shared.js +31 -0
- package/dist/commonjs/internal/decode-shared.js.map +1 -0
- package/dist/commonjs/internal/encode-shared.d.ts +32 -0
- package/dist/commonjs/internal/encode-shared.d.ts.map +1 -0
- package/dist/commonjs/internal/encode-shared.js +94 -0
- package/dist/commonjs/internal/encode-shared.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/esm/decode-codepoint.d.ts +19 -0
- package/dist/esm/decode-codepoint.d.ts.map +1 -0
- package/dist/esm/decode-codepoint.js +72 -0
- package/dist/esm/decode-codepoint.js.map +1 -0
- package/dist/esm/decode.d.ts +205 -0
- package/dist/esm/decode.d.ts.map +1 -0
- package/dist/esm/decode.js +554 -0
- package/dist/esm/decode.js.map +1 -0
- package/dist/esm/encode.d.ts +22 -0
- package/dist/esm/encode.d.ts.map +1 -0
- package/dist/esm/encode.js +88 -0
- package/dist/esm/encode.js.map +1 -0
- package/dist/esm/escape.d.ts +46 -0
- package/dist/esm/escape.d.ts.map +1 -0
- package/dist/esm/escape.js +134 -0
- package/dist/esm/escape.js.map +1 -0
- package/dist/esm/generated/decode-data-html.d.ts +2 -0
- package/dist/esm/generated/decode-data-html.d.ts.map +1 -0
- package/dist/esm/generated/decode-data-html.js +4 -0
- package/dist/esm/generated/decode-data-html.js.map +1 -0
- package/dist/esm/generated/decode-data-xml.d.ts +2 -0
- package/dist/esm/generated/decode-data-xml.d.ts.map +1 -0
- package/dist/esm/generated/decode-data-xml.js +4 -0
- package/dist/esm/generated/decode-data-xml.js.map +1 -0
- package/dist/esm/generated/encode-html.d.ts +3 -0
- package/dist/esm/generated/encode-html.d.ts.map +1 -0
- package/dist/esm/generated/encode-html.js +11 -0
- package/dist/esm/generated/encode-html.js.map +1 -0
- package/dist/esm/index.d.ts +96 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +107 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/internal/bin-trie-flags.d.ts +17 -0
- package/dist/esm/internal/bin-trie-flags.d.ts.map +1 -0
- package/dist/esm/internal/bin-trie-flags.js +18 -0
- package/dist/esm/internal/bin-trie-flags.js.map +1 -0
- package/dist/esm/internal/decode-shared.d.ts +2 -0
- package/dist/esm/internal/decode-shared.d.ts.map +1 -0
- package/dist/esm/internal/decode-shared.js +28 -0
- package/dist/esm/internal/decode-shared.js.map +1 -0
- package/dist/esm/internal/encode-shared.d.ts +32 -0
- package/dist/esm/internal/encode-shared.d.ts.map +1 -0
- package/dist/esm/internal/encode-shared.js +91 -0
- package/dist/esm/internal/encode-shared.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/escape.d.ts +3 -0
- package/escape.js +3 -0
- package/package.json +106 -49
- package/readme.md +109 -16
- package/src/decode-codepoint.ts +81 -0
- package/src/decode.ts +685 -0
- package/src/encode.ts +93 -0
- package/src/escape.ts +161 -0
- package/src/generated/.eslintrc.json +10 -0
- package/src/generated/decode-data-html.ts +6 -0
- package/src/generated/decode-data-xml.ts +6 -0
- package/src/generated/encode-html.ts +17 -0
- package/src/index.ts +187 -0
- package/src/internal/bin-trie-flags.ts +16 -0
- package/src/internal/decode-shared.ts +30 -0
- package/src/internal/encode-shared.ts +121 -0
- package/lib/decode.d.ts +0 -7
- package/lib/decode.d.ts.map +0 -1
- package/lib/decode.js +0 -54
- package/lib/decode_codepoint.d.ts +0 -2
- package/lib/decode_codepoint.d.ts.map +0 -1
- package/lib/decode_codepoint.js +0 -24
- package/lib/encode.d.ts +0 -4
- package/lib/encode.d.ts.map +0 -1
- package/lib/encode.js +0 -73
- package/lib/index.d.ts +0 -24
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -52
- package/lib/maps/decode.json +0 -1
- package/lib/maps/entities.json +0 -1
- package/lib/maps/legacy.json +0 -1
- package/lib/maps/xml.json +0 -1
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { DecodingMode, decodeHTML, decodeXML } from "./decode.js";
|
|
2
|
+
import { encodeHTML, encodeNonAsciiHTML } from "./encode.js";
|
|
3
|
+
import { encodeXML, escapeAttribute, escapeText, escapeUTF8, } from "./escape.js";
|
|
4
|
+
/** The level of entities to support. */
|
|
5
|
+
export var EntityLevel;
|
|
6
|
+
(function (EntityLevel) {
|
|
7
|
+
/** Support only XML entities. */
|
|
8
|
+
EntityLevel[EntityLevel["XML"] = 0] = "XML";
|
|
9
|
+
/** Support HTML entities, which are a superset of XML entities. */
|
|
10
|
+
EntityLevel[EntityLevel["HTML"] = 1] = "HTML";
|
|
11
|
+
})(EntityLevel || (EntityLevel = {}));
|
|
12
|
+
export var EncodingMode;
|
|
13
|
+
(function (EncodingMode) {
|
|
14
|
+
/**
|
|
15
|
+
* The output is UTF-8 encoded. Only characters that need escaping within
|
|
16
|
+
* XML will be escaped.
|
|
17
|
+
*/
|
|
18
|
+
EncodingMode[EncodingMode["UTF8"] = 0] = "UTF8";
|
|
19
|
+
/**
|
|
20
|
+
* The output consists only of ASCII characters. Characters that need
|
|
21
|
+
* escaping within HTML, and characters that aren't ASCII characters will
|
|
22
|
+
* be escaped.
|
|
23
|
+
*/
|
|
24
|
+
EncodingMode[EncodingMode["ASCII"] = 1] = "ASCII";
|
|
25
|
+
/**
|
|
26
|
+
* Encode all characters that have an equivalent entity, as well as all
|
|
27
|
+
* characters that are not ASCII characters.
|
|
28
|
+
*/
|
|
29
|
+
EncodingMode[EncodingMode["Extensive"] = 2] = "Extensive";
|
|
30
|
+
/**
|
|
31
|
+
* Encode all characters that have to be escaped in HTML attributes,
|
|
32
|
+
* following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
|
|
33
|
+
*/
|
|
34
|
+
EncodingMode[EncodingMode["Attribute"] = 3] = "Attribute";
|
|
35
|
+
/**
|
|
36
|
+
* Encode all characters that have to be escaped in HTML text,
|
|
37
|
+
* following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
|
|
38
|
+
*/
|
|
39
|
+
EncodingMode[EncodingMode["Text"] = 4] = "Text";
|
|
40
|
+
})(EncodingMode || (EncodingMode = {}));
|
|
41
|
+
/**
|
|
42
|
+
* Decodes a string with entities.
|
|
43
|
+
*
|
|
44
|
+
* @param input String to decode.
|
|
45
|
+
* @param options Decoding options.
|
|
46
|
+
*/
|
|
47
|
+
export function decode(input, options = EntityLevel.XML) {
|
|
48
|
+
const level = typeof options === "number" ? options : options.level;
|
|
49
|
+
if (level === EntityLevel.HTML) {
|
|
50
|
+
const mode = typeof options === "object" ? options.mode : undefined;
|
|
51
|
+
return decodeHTML(input, mode);
|
|
52
|
+
}
|
|
53
|
+
return decodeXML(input);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Decodes a string with entities. Does not allow missing trailing semicolons for entities.
|
|
57
|
+
*
|
|
58
|
+
* @param input String to decode.
|
|
59
|
+
* @param options Decoding options.
|
|
60
|
+
* @deprecated Use `decode` with the `mode` set to `Strict`.
|
|
61
|
+
*/
|
|
62
|
+
export function decodeStrict(input, options = EntityLevel.XML) {
|
|
63
|
+
var _a;
|
|
64
|
+
const normalizedOptions = typeof options === "number" ? { level: options } : options;
|
|
65
|
+
(_a = normalizedOptions.mode) !== null && _a !== void 0 ? _a : (normalizedOptions.mode = DecodingMode.Strict);
|
|
66
|
+
return decode(input, normalizedOptions);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Encodes a string with entities.
|
|
70
|
+
*
|
|
71
|
+
* @param input String to encode.
|
|
72
|
+
* @param options Encoding options.
|
|
73
|
+
*/
|
|
74
|
+
export function encode(input, options = EntityLevel.XML) {
|
|
75
|
+
const { mode = EncodingMode.Extensive, level = EntityLevel.XML } = typeof options === "number" ? { level: options } : options;
|
|
76
|
+
switch (mode) {
|
|
77
|
+
case EncodingMode.UTF8: {
|
|
78
|
+
return escapeUTF8(input);
|
|
79
|
+
}
|
|
80
|
+
case EncodingMode.Attribute: {
|
|
81
|
+
return escapeAttribute(input);
|
|
82
|
+
}
|
|
83
|
+
case EncodingMode.Text: {
|
|
84
|
+
return escapeText(input);
|
|
85
|
+
}
|
|
86
|
+
case EncodingMode.ASCII: {
|
|
87
|
+
return level === EntityLevel.HTML
|
|
88
|
+
? encodeNonAsciiHTML(input)
|
|
89
|
+
: encodeXML(input);
|
|
90
|
+
}
|
|
91
|
+
// biome-ignore lint/complexity/noUselessSwitchCase: we get an error for the switch not being exhaustive
|
|
92
|
+
case EncodingMode.Extensive: // eslint-disable-line unicorn/no-useless-switch-case
|
|
93
|
+
default: {
|
|
94
|
+
return level === EntityLevel.HTML
|
|
95
|
+
? encodeHTML(input)
|
|
96
|
+
: encodeXML(input);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
export { DecodingMode, decodeHTML,
|
|
101
|
+
// Legacy aliases (deprecated)
|
|
102
|
+
decodeHTML as decodeHTML4, decodeHTML as decodeHTML5, decodeHTMLAttribute, decodeHTMLStrict, decodeHTMLStrict as decodeHTML4Strict, decodeHTMLStrict as decodeHTML5Strict, decodeXML, decodeXML as decodeXMLStrict, EntityDecoder, } from "./decode.js";
|
|
103
|
+
export { encodeHTML,
|
|
104
|
+
// Legacy aliases (deprecated)
|
|
105
|
+
encodeHTML as encodeHTML4, encodeHTML as encodeHTML5, encodeNonAsciiHTML, } from "./encode.js";
|
|
106
|
+
export { encodeXML, escape, escapeAttribute, escapeText, escapeUTF8, } from "./escape.js";
|
|
107
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM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L,CAAC;AAED,OAAO,EACH,YAAY,EACZ,UAAU;AACV,8BAA8B;AAC9B,UAAU,IAAI,WAAW,EACzB,UAAU,IAAI,WAAW,EACzB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,IAAI,iBAAiB,EACrC,gBAAgB,IAAI,iBAAiB,EACrC,SAAS,EACT,SAAS,IAAI,eAAe,EAC5B,aAAa,GAChB,MAAM,aAAa,CAAC;AAErB,OAAO,EACH,UAAU;AACV,8BAA8B;AAC9B,UAAU,IAAI,WAAW,EACzB,UAAU,IAAI,WAAW,EACzB,kBAAkB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EACH,SAAS,EACT,MAAM,EACN,eAAe,EACf,UAAU,EACV,UAAU,GACb,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bit flags & masks for the binary trie encoding used for entity decoding.
|
|
3
|
+
*
|
|
4
|
+
* Bit layout (16 bits total):
|
|
5
|
+
* 15..14 VALUE_LENGTH (+1 encoding; 0 => no value)
|
|
6
|
+
* 13 FLAG13. If valueLength>0: semicolon required flag (implicit ';').
|
|
7
|
+
* If valueLength==0: compact run flag.
|
|
8
|
+
* 12..7 BRANCH_LENGTH Branch length (0 => single branch in 6..0 if jumpOffset==char) OR run length (when compact run)
|
|
9
|
+
* 6..0 JUMP_TABLE Jump offset (jump table) OR single-branch char code OR first run char
|
|
10
|
+
*/
|
|
11
|
+
export declare enum BinTrieFlags {
|
|
12
|
+
VALUE_LENGTH = 49152,
|
|
13
|
+
FLAG13 = 8192,
|
|
14
|
+
BRANCH_LENGTH = 8064,
|
|
15
|
+
JUMP_TABLE = 127
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=bin-trie-flags.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin-trie-flags.d.ts","sourceRoot":"","sources":["../../../src/internal/bin-trie-flags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,oBAAY,YAAY;IACpB,YAAY,QAAwB;IACpC,MAAM,OAAwB;IAC9B,aAAa,OAAwB;IACrC,UAAU,MAAwB;CACrC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bit flags & masks for the binary trie encoding used for entity decoding.
|
|
3
|
+
*
|
|
4
|
+
* Bit layout (16 bits total):
|
|
5
|
+
* 15..14 VALUE_LENGTH (+1 encoding; 0 => no value)
|
|
6
|
+
* 13 FLAG13. If valueLength>0: semicolon required flag (implicit ';').
|
|
7
|
+
* If valueLength==0: compact run flag.
|
|
8
|
+
* 12..7 BRANCH_LENGTH Branch length (0 => single branch in 6..0 if jumpOffset==char) OR run length (when compact run)
|
|
9
|
+
* 6..0 JUMP_TABLE Jump offset (jump table) OR single-branch char code OR first run char
|
|
10
|
+
*/
|
|
11
|
+
export var BinTrieFlags;
|
|
12
|
+
(function (BinTrieFlags) {
|
|
13
|
+
BinTrieFlags[BinTrieFlags["VALUE_LENGTH"] = 49152] = "VALUE_LENGTH";
|
|
14
|
+
BinTrieFlags[BinTrieFlags["FLAG13"] = 8192] = "FLAG13";
|
|
15
|
+
BinTrieFlags[BinTrieFlags["BRANCH_LENGTH"] = 8064] = "BRANCH_LENGTH";
|
|
16
|
+
BinTrieFlags[BinTrieFlags["JUMP_TABLE"] = 127] = "JUMP_TABLE";
|
|
17
|
+
})(BinTrieFlags || (BinTrieFlags = {}));
|
|
18
|
+
//# sourceMappingURL=bin-trie-flags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin-trie-flags.js","sourceRoot":"","sources":["../../../src/internal/bin-trie-flags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACpB,mEAAoC,CAAA;IACpC,sDAA8B,CAAA;IAC9B,oEAAqC,CAAA;IACrC,6DAAkC,CAAA;AACtC,CAAC,EALW,YAAY,KAAZ,YAAY,QAKvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode-shared.d.ts","sourceRoot":"","sources":["../../../src/internal/decode-shared.ts"],"names":[],"mappings":"AAIA,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAyBvD"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Shared base64 decode helper for generated decode data.
|
|
3
|
+
* Assumes global atob is available.
|
|
4
|
+
*/
|
|
5
|
+
export function decodeBase64(input) {
|
|
6
|
+
const binary =
|
|
7
|
+
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
|
8
|
+
typeof atob === "function"
|
|
9
|
+
? // Browser (and Node >=16)
|
|
10
|
+
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
|
11
|
+
atob(input)
|
|
12
|
+
: // Older Node versions (<16)
|
|
13
|
+
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
|
14
|
+
typeof Buffer.from === "function"
|
|
15
|
+
? // eslint-disable-next-line n/no-unsupported-features/node-builtins
|
|
16
|
+
Buffer.from(input, "base64").toString("binary")
|
|
17
|
+
: // eslint-disable-next-line unicorn/no-new-buffer, n/no-deprecated-api
|
|
18
|
+
new Buffer(input, "base64").toString("binary");
|
|
19
|
+
const evenLength = binary.length & ~1; // Round down to even length
|
|
20
|
+
const out = new Uint16Array(evenLength / 2);
|
|
21
|
+
for (let index = 0, outIndex = 0; index < evenLength; index += 2) {
|
|
22
|
+
const lo = binary.charCodeAt(index);
|
|
23
|
+
const hi = binary.charCodeAt(index + 1);
|
|
24
|
+
out[outIndex++] = lo | (hi << 8);
|
|
25
|
+
}
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=decode-shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode-shared.js","sourceRoot":"","sources":["../../../src/internal/decode-shared.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACtC,MAAM,MAAM;IACR,mEAAmE;IACnE,OAAO,IAAI,KAAK,UAAU;QACtB,CAAC,CAAC,0BAA0B;YAC1B,mEAAmE;YACnE,IAAI,CAAC,KAAK,CAAC;QACb,CAAC,CAAC,4BAA4B;YAC5B,mEAAmE;YACnE,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU;gBACjC,CAAC,CAAC,mEAAmE;oBACnE,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBACjD,CAAC,CAAC,sEAAsE;oBACtE,IAAI,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAE3D,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,4BAA4B;IACnE,MAAM,GAAG,GAAG,IAAI,WAAW,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;IAE5C,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,QAAQ,GAAG,CAAC,EAAE,KAAK,GAAG,UAAU,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAC/D,MAAM,EAAE,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACpC,MAAM,EAAE,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QACxC,GAAG,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;IACrC,CAAC;IAED,OAAO,GAAG,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A node inside the encoding trie used by `encode.ts`.
|
|
3
|
+
*
|
|
4
|
+
* There are two physical shapes to minimize allocations and lookup cost:
|
|
5
|
+
*
|
|
6
|
+
* 1. Leaf node (string)
|
|
7
|
+
* - A plain string (already in the form `"&name;"`).
|
|
8
|
+
* - Represents a terminal match with no children.
|
|
9
|
+
*
|
|
10
|
+
* 2. Branch / value node (object)
|
|
11
|
+
*/
|
|
12
|
+
export type EncodeTrieNode = string | {
|
|
13
|
+
/**
|
|
14
|
+
* Entity value for the current code point sequence (wrapped: `&...;`).
|
|
15
|
+
* Present when the path to this node itself is a valid named entity.
|
|
16
|
+
*/
|
|
17
|
+
value: string | undefined;
|
|
18
|
+
/** If a number, the next code unit of the only next character. */
|
|
19
|
+
next: number | Map<number, EncodeTrieNode>;
|
|
20
|
+
/** If next is a number, `nextValue` contains the entity value. */
|
|
21
|
+
nextValue?: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Parse a compact encode trie string into a Map structure used for encoding.
|
|
25
|
+
*
|
|
26
|
+
* Format per entry (ascending code points using delta encoding):
|
|
27
|
+
* <diffBase36>[&name;][{<children>}] -- diff omitted when 0
|
|
28
|
+
* Where diff = currentKey - previousKey - 1 (first entry stores absolute key).
|
|
29
|
+
* `&name;` is the entity value (already wrapped); a following `{` denotes children.
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseEncodeTrie(serialized: string): Map<number, EncodeTrieNode>;
|
|
32
|
+
//# sourceMappingURL=encode-shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode-shared.d.ts","sourceRoot":"","sources":["../../../src/internal/encode-shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,MAAM,cAAc,GACpB,MAAM,GACN;IACI;;;OAGG;IACH,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,kEAAkE;IAClE,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC3C,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAER;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC3B,UAAU,EAAE,MAAM,GACnB,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAqF7B"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a compact encode trie string into a Map structure used for encoding.
|
|
3
|
+
*
|
|
4
|
+
* Format per entry (ascending code points using delta encoding):
|
|
5
|
+
* <diffBase36>[&name;][{<children>}] -- diff omitted when 0
|
|
6
|
+
* Where diff = currentKey - previousKey - 1 (first entry stores absolute key).
|
|
7
|
+
* `&name;` is the entity value (already wrapped); a following `{` denotes children.
|
|
8
|
+
*/
|
|
9
|
+
export function parseEncodeTrie(serialized) {
|
|
10
|
+
const top = new Map();
|
|
11
|
+
const totalLength = serialized.length;
|
|
12
|
+
let cursor = 0;
|
|
13
|
+
let lastTopKey = -1;
|
|
14
|
+
function readDiff() {
|
|
15
|
+
const start = cursor;
|
|
16
|
+
while (cursor < totalLength) {
|
|
17
|
+
const char = serialized.charAt(cursor);
|
|
18
|
+
if ((char < "0" || char > "9") && (char < "a" || char > "z")) {
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
cursor++;
|
|
22
|
+
}
|
|
23
|
+
if (cursor === start)
|
|
24
|
+
return 0;
|
|
25
|
+
return Number.parseInt(serialized.slice(start, cursor), 36);
|
|
26
|
+
}
|
|
27
|
+
function readEntity() {
|
|
28
|
+
if (serialized[cursor] !== "&") {
|
|
29
|
+
throw new Error(`Child entry missing value near index ${cursor}`);
|
|
30
|
+
}
|
|
31
|
+
// Cursor currently points at '&'
|
|
32
|
+
const start = cursor;
|
|
33
|
+
const end = serialized.indexOf(";", cursor + 1);
|
|
34
|
+
if (end === -1) {
|
|
35
|
+
throw new Error(`Unterminated entity starting at index ${start}`);
|
|
36
|
+
}
|
|
37
|
+
cursor = end + 1; // Move past ';'
|
|
38
|
+
return serialized.slice(start, cursor); // Includes & ... ;
|
|
39
|
+
}
|
|
40
|
+
while (cursor < totalLength) {
|
|
41
|
+
const keyDiff = readDiff();
|
|
42
|
+
const key = lastTopKey === -1 ? keyDiff : lastTopKey + keyDiff + 1;
|
|
43
|
+
let value;
|
|
44
|
+
if (serialized[cursor] === "&")
|
|
45
|
+
value = readEntity();
|
|
46
|
+
if (serialized[cursor] === "{") {
|
|
47
|
+
cursor++; // Skip '{'
|
|
48
|
+
// Parse first child
|
|
49
|
+
let diff = readDiff();
|
|
50
|
+
let childKey = diff; // First key (lastChildKey = -1)
|
|
51
|
+
const firstValue = readEntity();
|
|
52
|
+
if (serialized[cursor] === "{") {
|
|
53
|
+
throw new Error("Unexpected nested '{' beyond depth 2");
|
|
54
|
+
}
|
|
55
|
+
// If end of block -> single child optimization
|
|
56
|
+
if (serialized[cursor] === "}") {
|
|
57
|
+
top.set(key, { value, next: childKey, nextValue: firstValue });
|
|
58
|
+
cursor++; // Skip '}'
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
const childMap = new Map();
|
|
62
|
+
childMap.set(childKey, firstValue);
|
|
63
|
+
let lastChildKey = childKey;
|
|
64
|
+
while (cursor < totalLength && serialized[cursor] !== "}") {
|
|
65
|
+
diff = readDiff();
|
|
66
|
+
childKey = lastChildKey + diff + 1;
|
|
67
|
+
const childValue = readEntity();
|
|
68
|
+
if (serialized[cursor] === "{") {
|
|
69
|
+
throw new Error("Unexpected nested '{' beyond depth 2");
|
|
70
|
+
}
|
|
71
|
+
childMap.set(childKey, childValue);
|
|
72
|
+
lastChildKey = childKey;
|
|
73
|
+
}
|
|
74
|
+
if (serialized[cursor] !== "}") {
|
|
75
|
+
throw new Error("Unterminated child block");
|
|
76
|
+
}
|
|
77
|
+
cursor++; // Skip '}'
|
|
78
|
+
top.set(key, { value, next: childMap });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else if (value === undefined) {
|
|
82
|
+
throw new Error(`Malformed encode trie: missing value at index ${cursor}`);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
top.set(key, value);
|
|
86
|
+
}
|
|
87
|
+
lastTopKey = key;
|
|
88
|
+
}
|
|
89
|
+
return top;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=encode-shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode-shared.js","sourceRoot":"","sources":["../../../src/internal/encode-shared.ts"],"names":[],"mappings":"AAyBA;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC3B,UAAkB;IAElB,MAAM,GAAG,GAAG,IAAI,GAAG,EAA0B,CAAC;IAC9C,MAAM,WAAW,GAAG,UAAU,CAAC,MAAM,CAAC;IACtC,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,UAAU,GAAG,CAAC,CAAC,CAAC;IAEpB,SAAS,QAAQ;QACb,MAAM,KAAK,GAAG,MAAM,CAAC;QACrB,OAAO,MAAM,GAAG,WAAW,EAAE,CAAC;YAC1B,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAEvC,IAAI,CAAC,IAAI,GAAG,GAAG,IAAI,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,GAAG,GAAG,IAAI,IAAI,GAAG,GAAG,CAAC,EAAE,CAAC;gBAC3D,MAAM;YACV,CAAC;YACD,MAAM,EAAE,CAAC;QACb,CAAC;QACD,IAAI,MAAM,KAAK,KAAK;YAAE,OAAO,CAAC,CAAC;QAC/B,OAAO,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC;IAChE,CAAC;IAED,SAAS,UAAU;QACf,IAAI,UAAU,CAAC,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,wCAAwC,MAAM,EAAE,CAAC,CAAC;QACtE,CAAC;QAED,iCAAiC;QACjC,MAAM,KAAK,GAAG,MAAM,CAAC;QACrB,MAAM,GAAG,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM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.js
ADDED
package/package.json
CHANGED
|
@@ -1,63 +1,120 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "entities",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Encode & decode XML and HTML entities with ease",
|
|
5
|
-
"author": "Felix Boehm <me@feedic.com>",
|
|
6
|
-
"funding": "https://github.com/fb55/entities?sponsor=1",
|
|
7
|
-
"sideEffects": false,
|
|
3
|
+
"version": "7.0.1",
|
|
4
|
+
"description": "Encode & decode XML and HTML entities with ease & speed",
|
|
8
5
|
"keywords": [
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"encoding",
|
|
12
|
-
"html",
|
|
13
|
-
"
|
|
14
|
-
"
|
|
6
|
+
"html entities",
|
|
7
|
+
"entity decoder",
|
|
8
|
+
"entity encoding",
|
|
9
|
+
"html decoding",
|
|
10
|
+
"html encoding",
|
|
11
|
+
"xml decoding",
|
|
12
|
+
"xml encoding"
|
|
15
13
|
],
|
|
16
|
-
"
|
|
17
|
-
"
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/fb55/entities.git"
|
|
17
|
+
},
|
|
18
|
+
"funding": "https://github.com/fb55/entities?sponsor=1",
|
|
19
|
+
"license": "BSD-2-Clause",
|
|
20
|
+
"author": "Felix Boehm <me@feedic.com>",
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"type": "module",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"import": {
|
|
26
|
+
"types": "./dist/esm/index.d.ts",
|
|
27
|
+
"default": "./dist/esm/index.js"
|
|
28
|
+
},
|
|
29
|
+
"require": {
|
|
30
|
+
"types": "./dist/commonjs/index.d.ts",
|
|
31
|
+
"default": "./dist/commonjs/index.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"./decode": {
|
|
35
|
+
"import": {
|
|
36
|
+
"types": "./dist/esm/decode.d.ts",
|
|
37
|
+
"default": "./dist/esm/decode.js"
|
|
38
|
+
},
|
|
39
|
+
"require": {
|
|
40
|
+
"types": "./dist/commonjs/decode.d.ts",
|
|
41
|
+
"default": "./dist/commonjs/decode.js"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"./escape": {
|
|
45
|
+
"import": {
|
|
46
|
+
"types": "./dist/esm/escape.d.ts",
|
|
47
|
+
"default": "./dist/esm/escape.js"
|
|
48
|
+
},
|
|
49
|
+
"require": {
|
|
50
|
+
"types": "./dist/commonjs/escape.d.ts",
|
|
51
|
+
"default": "./dist/commonjs/escape.js"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
18
54
|
},
|
|
19
|
-
"main": "
|
|
20
|
-
"
|
|
55
|
+
"main": "./dist/commonjs/index.js",
|
|
56
|
+
"module": "./dist/esm/index.js",
|
|
57
|
+
"types": "./dist/commonjs/index.d.ts",
|
|
21
58
|
"files": [
|
|
22
|
-
"
|
|
59
|
+
"decode.js",
|
|
60
|
+
"decode.d.ts",
|
|
61
|
+
"escape.js",
|
|
62
|
+
"escape.d.ts",
|
|
63
|
+
"dist",
|
|
64
|
+
"src",
|
|
65
|
+
"!**/*.spec.ts"
|
|
23
66
|
],
|
|
24
|
-
"devDependencies": {
|
|
25
|
-
"@types/jest": "^26.0.0",
|
|
26
|
-
"@types/node": "^14.11.8",
|
|
27
|
-
"@typescript-eslint/eslint-plugin": "^4.4.1",
|
|
28
|
-
"@typescript-eslint/parser": "^4.4.1",
|
|
29
|
-
"coveralls": "*",
|
|
30
|
-
"eslint": "^7.11.0",
|
|
31
|
-
"eslint-config-prettier": "^6.0.0",
|
|
32
|
-
"eslint-plugin-node": "^11.1.0",
|
|
33
|
-
"jest": "^26.5.3",
|
|
34
|
-
"prettier": "^2.0.5",
|
|
35
|
-
"ts-jest": "^26.1.0",
|
|
36
|
-
"typescript": "^4.0.2"
|
|
37
|
-
},
|
|
38
67
|
"scripts": {
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"format": "npm run format:es && npm run format:prettier",
|
|
68
|
+
"build:docs": "typedoc --hideGenerator src/index.ts",
|
|
69
|
+
"build:encode-trie": "node --import=tsx scripts/write-encode-map.ts",
|
|
70
|
+
"build:trie": "node --import=tsx scripts/write-decode-map.ts",
|
|
71
|
+
"benchmark": "node --import=tsx scripts/benchmark.ts",
|
|
72
|
+
"format": "npm run format:es && npm run format:biome",
|
|
45
73
|
"format:es": "npm run lint:es -- --fix",
|
|
46
|
-
"format:
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
74
|
+
"format:biome": "biome check --fix .",
|
|
75
|
+
"lint": "npm run lint:es && npm run lint:ts && npm run lint:biome",
|
|
76
|
+
"lint:es": "eslint . --ignore-path .gitignore",
|
|
77
|
+
"lint:biome": "biome check .",
|
|
78
|
+
"lint:ts": "tsc --noEmit",
|
|
79
|
+
"prepublishOnly": "tshy",
|
|
80
|
+
"test": "npm run test:vi && npm run lint",
|
|
81
|
+
"test:vi": "vitest run"
|
|
50
82
|
},
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
83
|
+
"devDependencies": {
|
|
84
|
+
"@biomejs/biome": "^2.3.11",
|
|
85
|
+
"@types/node": "^25.0.9",
|
|
86
|
+
"@typescript-eslint/eslint-plugin": "^8.53.1",
|
|
87
|
+
"@typescript-eslint/parser": "^8.53.1",
|
|
88
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
89
|
+
"@types/he": "^1.2.3",
|
|
90
|
+
"eslint": "^8.57.1",
|
|
91
|
+
"eslint-config-biome": "^2.1.3",
|
|
92
|
+
"eslint-plugin-n": "^17.23.2",
|
|
93
|
+
"eslint-plugin-unicorn": "^56.0.1",
|
|
94
|
+
"he": "^1.2.0",
|
|
95
|
+
"html-entities": "^2.6.0",
|
|
96
|
+
"parse-entities": "^4.0.2",
|
|
97
|
+
"tinybench": "^5.1.0",
|
|
98
|
+
"tshy": "^3.1.0",
|
|
99
|
+
"tsx": "^4.21.0",
|
|
100
|
+
"typedoc": "^0.28.16",
|
|
101
|
+
"typescript": "^5.9.3",
|
|
102
|
+
"vitest": "^3.2.4"
|
|
54
103
|
},
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
"preset": "ts-jest",
|
|
58
|
-
"testEnvironment": "node"
|
|
104
|
+
"engines": {
|
|
105
|
+
"node": ">=0.12"
|
|
59
106
|
},
|
|
60
|
-
"
|
|
61
|
-
"
|
|
107
|
+
"tshy": {
|
|
108
|
+
"exclude": [
|
|
109
|
+
"**/*.spec.ts",
|
|
110
|
+
"**/__fixtures__/*",
|
|
111
|
+
"**/__tests__/*",
|
|
112
|
+
"**/__snapshots__/*"
|
|
113
|
+
],
|
|
114
|
+
"exports": {
|
|
115
|
+
".": "./src/index.ts",
|
|
116
|
+
"./decode": "./src/decode.ts",
|
|
117
|
+
"./escape": "./src/escape.ts"
|
|
118
|
+
}
|
|
62
119
|
}
|
|
63
120
|
}
|