@scrabble-solver/scrabble-solver 2.12.2 → 2.12.4
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/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +6 -6
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/cache/eslint/.cache_8dgz12 +1 -1
- package/.next/cache/next-server.js.nft.json +1 -1
- package/.next/cache/webpack/client-production/0.pack +0 -0
- package/.next/cache/webpack/client-production/index.pack +0 -0
- package/.next/cache/webpack/edge-server-production/0.pack +0 -0
- package/.next/cache/webpack/edge-server-production/index.pack +0 -0
- package/.next/cache/webpack/server-production/0.pack +0 -0
- package/.next/cache/webpack/server-production/index.pack +0 -0
- package/.next/next-server.js.nft.json +1 -1
- package/.next/prerender-manifest.json +1 -1
- package/.next/routes-manifest.json +1 -1
- package/.next/server/chunks/131.js +478 -106
- package/.next/server/chunks/277.js +1132 -976
- package/.next/server/chunks/44.js +37 -9
- package/.next/server/chunks/865.js +597 -169
- package/.next/server/chunks/911.js +894 -773
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/404.js.nft.json +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/pages/_app.js +3 -1
- package/.next/server/pages/_app.js.nft.json +1 -1
- package/.next/server/pages/_document.js.nft.json +1 -1
- package/.next/server/pages/api/dictionary/[locale]/[word].js +4 -2
- package/.next/server/pages/api/solve.js +23 -19
- package/.next/server/pages/api/verify.js +8 -5
- package/.next/server/pages/index.html +1 -1
- package/.next/server/pages/index.js +42 -55
- package/.next/server/pages/index.js.nft.json +1 -1
- package/.next/server/pages/index.json +1 -1
- package/.next/server/pages-manifest.json +2 -2
- package/.next/static/{9dmPfnTc_AQTHBPvL7xQe → 8oRk1nUMQYFWmhu4SExQI}/_buildManifest.js +1 -1
- package/.next/static/chunks/pages/_app-e7f3d1c9c09c8f91.js +32 -0
- package/.next/static/chunks/pages/index-82b2939158c7729f.js +1 -0
- package/.next/static/css/4e8b47fe382a8a8f.css +2 -0
- package/.next/static/css/cfae5256f1689f57.css +1 -0
- package/.next/trace +51 -52
- package/package.json +9 -9
- package/src/components/Board/components/Cell/Cell.module.scss +4 -12
- package/src/components/Board/components/Cell/Cell.tsx +4 -0
- package/src/components/Board/hooks/useBackgroundImage.tsx +23 -0
- package/src/components/PlainTiles/lib/createPlainTile.ts +4 -4
- package/src/components/Radio/Radio.module.scss +4 -0
- package/src/components/Radio/Radio.tsx +1 -0
- package/src/components/SeoMessage/SeoMessage.tsx +3 -3
- package/src/hooks/useAppLayout.ts +1 -2
- package/src/hooks/useLocalStorage.ts +5 -5
- package/src/i18n/constants.ts +31 -61
- package/src/lib/extractCharacters.test.ts +3 -3
- package/src/lib/extractCharactersByCase.test.ts +3 -3
- package/src/lib/getCellSize.ts +2 -2
- package/src/modals/MenuModal/MenuModal.module.scss +0 -1
- package/src/modals/MenuModal/MenuModal.tsx +3 -3
- package/src/modals/SettingsModal/components/ConfigSetting/ConfigSetting.tsx +16 -7
- package/src/modals/SettingsModal/components/LocaleSetting/LocaleSetting.module.scss +1 -4
- package/src/modals/SettingsModal/components/LocaleSetting/LocaleSetting.tsx +8 -8
- package/src/pages/_app.tsx +3 -1
- package/src/pages/api/dictionary/[locale]/[word].ts +6 -3
- package/src/pages/api/solve.ts +11 -7
- package/src/pages/api/verify.ts +11 -7
- package/src/pages/index.module.scss +0 -1
- package/src/parameters/index.ts +4 -6
- package/src/sdk/solve.ts +3 -3
- package/src/sdk/verify.ts +3 -3
- package/src/service-worker/routeSolveRequests.ts +3 -3
- package/src/state/localStorage.ts +6 -6
- package/src/state/sagas.ts +18 -7
- package/src/state/selectors.ts +3 -3
- package/src/state/slices/boardInitialState.ts +3 -3
- package/src/state/slices/boardSlice.ts +20 -6
- package/src/state/slices/settingsInitialState.ts +3 -4
- package/src/state/slices/settingsSlice.ts +5 -5
- package/src/styles/variables.scss +0 -9
- package/.next/static/chunks/pages/_app-02851b06b95b19cb.js +0 -32
- package/.next/static/chunks/pages/index-0ba5607d1aad8a09.js +0 -1
- package/.next/static/css/09dfdea53eba31a9.css +0 -2
- package/.next/static/css/60e8258da7362a1a.css +0 -1
- package/src/i18n/i18n.module.scss +0 -27
- package/src/modals/SettingsModal/components/ConfigSetting/options.ts +0 -19
- package/src/modals/SettingsModal/components/ConfigSetting/types.ts +0 -9
- package/src/modals/SettingsModal/components/InputModeSetting/types.ts +0 -7
- package/src/modals/SettingsModal/components/LocaleSetting/types.ts +0 -9
- /package/.next/static/{9dmPfnTc_AQTHBPvL7xQe → 8oRk1nUMQYFWmhu4SExQI}/_ssgManifest.js +0 -0
|
@@ -7139,7 +7139,7 @@ function getRssFeed(feedRoot) {
|
|
|
7139
7139
|
addConditionally(entry, "title", "title", children);
|
|
7140
7140
|
addConditionally(entry, "link", "link", children);
|
|
7141
7141
|
addConditionally(entry, "description", "description", children);
|
|
7142
|
-
var pubDate = fetch("pubDate", children);
|
|
7142
|
+
var pubDate = fetch("pubDate", children) || fetch("dc:date", children);
|
|
7143
7143
|
if (pubDate)
|
|
7144
7144
|
entry.pubDate = new Date(pubDate);
|
|
7145
7145
|
return entry;
|
|
@@ -7256,11 +7256,12 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
7256
7256
|
exports.uniqueSort = exports.compareDocumentPosition = exports.DocumentPosition = exports.removeSubsets = void 0;
|
|
7257
7257
|
var domhandler_1 = __webpack_require__(67122);
|
|
7258
7258
|
/**
|
|
7259
|
-
* Given an array of nodes, remove any member that is contained by another
|
|
7259
|
+
* Given an array of nodes, remove any member that is contained by another
|
|
7260
|
+
* member.
|
|
7260
7261
|
*
|
|
7261
7262
|
* @category Helpers
|
|
7262
7263
|
* @param nodes Nodes to filter.
|
|
7263
|
-
* @returns Remaining nodes that aren't
|
|
7264
|
+
* @returns Remaining nodes that aren't contained by other nodes.
|
|
7264
7265
|
*/
|
|
7265
7266
|
function removeSubsets(nodes) {
|
|
7266
7267
|
var idx = nodes.length;
|
|
@@ -7302,8 +7303,8 @@ var DocumentPosition;
|
|
|
7302
7303
|
DocumentPosition[DocumentPosition["CONTAINED_BY"] = 16] = "CONTAINED_BY";
|
|
7303
7304
|
})(DocumentPosition = exports.DocumentPosition || (exports.DocumentPosition = {}));
|
|
7304
7305
|
/**
|
|
7305
|
-
* Compare the position of one node against another node in any other document
|
|
7306
|
-
*
|
|
7306
|
+
* Compare the position of one node against another node in any other document,
|
|
7307
|
+
* returning a bitmask with the values from {@link DocumentPosition}.
|
|
7307
7308
|
*
|
|
7308
7309
|
* Document order:
|
|
7309
7310
|
* > There is an ordering, document order, defined on all the nodes in the
|
|
@@ -7368,9 +7369,9 @@ function compareDocumentPosition(nodeA, nodeB) {
|
|
|
7368
7369
|
}
|
|
7369
7370
|
exports.compareDocumentPosition = compareDocumentPosition;
|
|
7370
7371
|
/**
|
|
7371
|
-
* Sort an array of nodes based on their relative position in the document
|
|
7372
|
-
*
|
|
7373
|
-
* the same document, sort order is unspecified.
|
|
7372
|
+
* Sort an array of nodes based on their relative position in the document,
|
|
7373
|
+
* removing any duplicate nodes. If the array contains nodes that do not belong
|
|
7374
|
+
* to the same document, sort order is unspecified.
|
|
7374
7375
|
*
|
|
7375
7376
|
* @category Helpers
|
|
7376
7377
|
* @param nodes Array of DOM nodes.
|
|
@@ -7444,6 +7445,9 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
7444
7445
|
exports.getElementsByTagType = exports.getElementsByTagName = exports.getElementById = exports.getElements = exports.testElement = void 0;
|
|
7445
7446
|
var domhandler_1 = __webpack_require__(67122);
|
|
7446
7447
|
var querying_js_1 = __webpack_require__(30688);
|
|
7448
|
+
/**
|
|
7449
|
+
* A map of functions to check nodes against.
|
|
7450
|
+
*/
|
|
7447
7451
|
var Checks = {
|
|
7448
7452
|
tag_name: function (name) {
|
|
7449
7453
|
if (typeof name === "function") {
|
|
@@ -7468,6 +7472,9 @@ var Checks = {
|
|
|
7468
7472
|
},
|
|
7469
7473
|
};
|
|
7470
7474
|
/**
|
|
7475
|
+
* Returns a function to check whether a node has an attribute with a particular
|
|
7476
|
+
* value.
|
|
7477
|
+
*
|
|
7471
7478
|
* @param attrib Attribute to check.
|
|
7472
7479
|
* @param value Attribute value to look for.
|
|
7473
7480
|
* @returns A function to check whether the a node has an attribute with a
|
|
@@ -7480,6 +7487,9 @@ function getAttribCheck(attrib, value) {
|
|
|
7480
7487
|
return function (elem) { return (0, domhandler_1.isTag)(elem) && elem.attribs[attrib] === value; };
|
|
7481
7488
|
}
|
|
7482
7489
|
/**
|
|
7490
|
+
* Returns a function that returns `true` if either of the input functions
|
|
7491
|
+
* returns `true` for a node.
|
|
7492
|
+
*
|
|
7483
7493
|
* @param a First function to combine.
|
|
7484
7494
|
* @param b Second function to combine.
|
|
7485
7495
|
* @returns A function taking a node and returning `true` if either of the input
|
|
@@ -7489,9 +7499,12 @@ function combineFuncs(a, b) {
|
|
|
7489
7499
|
return function (elem) { return a(elem) || b(elem); };
|
|
7490
7500
|
}
|
|
7491
7501
|
/**
|
|
7502
|
+
* Returns a function that executes all checks in `options` and returns `true`
|
|
7503
|
+
* if any of them match a node.
|
|
7504
|
+
*
|
|
7492
7505
|
* @param options An object describing nodes to look for.
|
|
7493
|
-
* @returns A function
|
|
7494
|
-
* any of them match a node.
|
|
7506
|
+
* @returns A function that executes all checks in `options` and returns `true`
|
|
7507
|
+
* if any of them match a node.
|
|
7495
7508
|
*/
|
|
7496
7509
|
function compileTest(options) {
|
|
7497
7510
|
var funcs = Object.keys(options).map(function (key) {
|
|
@@ -7503,6 +7516,8 @@ function compileTest(options) {
|
|
|
7503
7516
|
return funcs.length === 0 ? null : funcs.reduce(combineFuncs);
|
|
7504
7517
|
}
|
|
7505
7518
|
/**
|
|
7519
|
+
* Checks whether a node matches the description in `options`.
|
|
7520
|
+
*
|
|
7506
7521
|
* @category Legacy Query Functions
|
|
7507
7522
|
* @param options An object describing nodes to look for.
|
|
7508
7523
|
* @param node The element to test.
|
|
@@ -7514,6 +7529,8 @@ function testElement(options, node) {
|
|
|
7514
7529
|
}
|
|
7515
7530
|
exports.testElement = testElement;
|
|
7516
7531
|
/**
|
|
7532
|
+
* Returns all nodes that match `options`.
|
|
7533
|
+
*
|
|
7517
7534
|
* @category Legacy Query Functions
|
|
7518
7535
|
* @param options An object describing nodes to look for.
|
|
7519
7536
|
* @param nodes Nodes to search through.
|
|
@@ -7528,6 +7545,8 @@ function getElements(options, nodes, recurse, limit) {
|
|
|
7528
7545
|
}
|
|
7529
7546
|
exports.getElements = getElements;
|
|
7530
7547
|
/**
|
|
7548
|
+
* Returns the node with the supplied ID.
|
|
7549
|
+
*
|
|
7531
7550
|
* @category Legacy Query Functions
|
|
7532
7551
|
* @param id The unique ID attribute value to look for.
|
|
7533
7552
|
* @param nodes Nodes to search through.
|
|
@@ -7542,6 +7561,8 @@ function getElementById(id, nodes, recurse) {
|
|
|
7542
7561
|
}
|
|
7543
7562
|
exports.getElementById = getElementById;
|
|
7544
7563
|
/**
|
|
7564
|
+
* Returns all nodes with the supplied `tagName`.
|
|
7565
|
+
*
|
|
7545
7566
|
* @category Legacy Query Functions
|
|
7546
7567
|
* @param tagName Tag name to search for.
|
|
7547
7568
|
* @param nodes Nodes to search through.
|
|
@@ -7556,6 +7577,8 @@ function getElementsByTagName(tagName, nodes, recurse, limit) {
|
|
|
7556
7577
|
}
|
|
7557
7578
|
exports.getElementsByTagName = getElementsByTagName;
|
|
7558
7579
|
/**
|
|
7580
|
+
* Returns all nodes with the supplied `type`.
|
|
7581
|
+
*
|
|
7559
7582
|
* @category Legacy Query Functions
|
|
7560
7583
|
* @param type Element type to look for.
|
|
7561
7584
|
* @param nodes Nodes to search through.
|
|
@@ -7593,8 +7616,14 @@ function removeElement(elem) {
|
|
|
7593
7616
|
elem.next.prev = elem.prev;
|
|
7594
7617
|
if (elem.parent) {
|
|
7595
7618
|
var childs = elem.parent.children;
|
|
7596
|
-
childs.
|
|
7619
|
+
var childsIndex = childs.lastIndexOf(elem);
|
|
7620
|
+
if (childsIndex >= 0) {
|
|
7621
|
+
childs.splice(childsIndex, 1);
|
|
7622
|
+
}
|
|
7597
7623
|
}
|
|
7624
|
+
elem.next = null;
|
|
7625
|
+
elem.prev = null;
|
|
7626
|
+
elem.parent = null;
|
|
7598
7627
|
}
|
|
7599
7628
|
exports.removeElement = removeElement;
|
|
7600
7629
|
/**
|
|
@@ -7625,15 +7654,15 @@ exports.replaceElement = replaceElement;
|
|
|
7625
7654
|
* Append a child to an element.
|
|
7626
7655
|
*
|
|
7627
7656
|
* @category Manipulation
|
|
7628
|
-
* @param
|
|
7657
|
+
* @param parent The element to append to.
|
|
7629
7658
|
* @param child The element to be added as a child.
|
|
7630
7659
|
*/
|
|
7631
|
-
function appendChild(
|
|
7660
|
+
function appendChild(parent, child) {
|
|
7632
7661
|
removeElement(child);
|
|
7633
7662
|
child.next = null;
|
|
7634
|
-
child.parent =
|
|
7635
|
-
if (
|
|
7636
|
-
var sibling =
|
|
7663
|
+
child.parent = parent;
|
|
7664
|
+
if (parent.children.push(child) > 1) {
|
|
7665
|
+
var sibling = parent.children[parent.children.length - 2];
|
|
7637
7666
|
sibling.next = child;
|
|
7638
7667
|
child.prev = sibling;
|
|
7639
7668
|
}
|
|
@@ -7673,15 +7702,15 @@ exports.append = append;
|
|
|
7673
7702
|
* Prepend a child to an element.
|
|
7674
7703
|
*
|
|
7675
7704
|
* @category Manipulation
|
|
7676
|
-
* @param
|
|
7705
|
+
* @param parent The element to prepend before.
|
|
7677
7706
|
* @param child The element to be added as a child.
|
|
7678
7707
|
*/
|
|
7679
|
-
function prependChild(
|
|
7708
|
+
function prependChild(parent, child) {
|
|
7680
7709
|
removeElement(child);
|
|
7681
|
-
child.parent =
|
|
7710
|
+
child.parent = parent;
|
|
7682
7711
|
child.prev = null;
|
|
7683
|
-
if (
|
|
7684
|
-
var sibling =
|
|
7712
|
+
if (parent.children.unshift(child) !== 1) {
|
|
7713
|
+
var sibling = parent.children[1];
|
|
7685
7714
|
sibling.prev = child;
|
|
7686
7715
|
child.next = sibling;
|
|
7687
7716
|
}
|
|
@@ -7726,7 +7755,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
7726
7755
|
exports.findAll = exports.existsOne = exports.findOne = exports.findOneChild = exports.find = exports.filter = void 0;
|
|
7727
7756
|
var domhandler_1 = __webpack_require__(67122);
|
|
7728
7757
|
/**
|
|
7729
|
-
* Search a node and its children for nodes passing a test function.
|
|
7758
|
+
* Search a node and its children for nodes passing a test function. If `node` is not an array, it will be wrapped in one.
|
|
7730
7759
|
*
|
|
7731
7760
|
* @category Querying
|
|
7732
7761
|
* @param test Function to test nodes on.
|
|
@@ -7738,13 +7767,11 @@ var domhandler_1 = __webpack_require__(67122);
|
|
|
7738
7767
|
function filter(test, node, recurse, limit) {
|
|
7739
7768
|
if (recurse === void 0) { recurse = true; }
|
|
7740
7769
|
if (limit === void 0) { limit = Infinity; }
|
|
7741
|
-
|
|
7742
|
-
node = [node];
|
|
7743
|
-
return find(test, node, recurse, limit);
|
|
7770
|
+
return find(test, Array.isArray(node) ? node : [node], recurse, limit);
|
|
7744
7771
|
}
|
|
7745
7772
|
exports.filter = filter;
|
|
7746
7773
|
/**
|
|
7747
|
-
* Search an array of
|
|
7774
|
+
* Search an array of nodes and their children for nodes passing a test function.
|
|
7748
7775
|
*
|
|
7749
7776
|
* @category Querying
|
|
7750
7777
|
* @param test Function to test nodes on.
|
|
@@ -7755,26 +7782,42 @@ exports.filter = filter;
|
|
|
7755
7782
|
*/
|
|
7756
7783
|
function find(test, nodes, recurse, limit) {
|
|
7757
7784
|
var result = [];
|
|
7758
|
-
|
|
7759
|
-
|
|
7785
|
+
/** Stack of the arrays we are looking at. */
|
|
7786
|
+
var nodeStack = [nodes];
|
|
7787
|
+
/** Stack of the indices within the arrays. */
|
|
7788
|
+
var indexStack = [0];
|
|
7789
|
+
for (;;) {
|
|
7790
|
+
// First, check if the current array has any more elements to look at.
|
|
7791
|
+
if (indexStack[0] >= nodeStack[0].length) {
|
|
7792
|
+
// If we have no more arrays to look at, we are done.
|
|
7793
|
+
if (indexStack.length === 1) {
|
|
7794
|
+
return result;
|
|
7795
|
+
}
|
|
7796
|
+
// Otherwise, remove the current array from the stack.
|
|
7797
|
+
nodeStack.shift();
|
|
7798
|
+
indexStack.shift();
|
|
7799
|
+
// Loop back to the start to continue with the next array.
|
|
7800
|
+
continue;
|
|
7801
|
+
}
|
|
7802
|
+
var elem = nodeStack[0][indexStack[0]++];
|
|
7760
7803
|
if (test(elem)) {
|
|
7761
7804
|
result.push(elem);
|
|
7762
7805
|
if (--limit <= 0)
|
|
7763
|
-
|
|
7806
|
+
return result;
|
|
7764
7807
|
}
|
|
7765
7808
|
if (recurse && (0, domhandler_1.hasChildren)(elem) && elem.children.length > 0) {
|
|
7766
|
-
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
|
|
7770
|
-
|
|
7809
|
+
/*
|
|
7810
|
+
* Add the children to the stack. We are depth-first, so this is
|
|
7811
|
+
* the next array we look at.
|
|
7812
|
+
*/
|
|
7813
|
+
indexStack.unshift(0);
|
|
7814
|
+
nodeStack.unshift(elem.children);
|
|
7771
7815
|
}
|
|
7772
7816
|
}
|
|
7773
|
-
return result;
|
|
7774
7817
|
}
|
|
7775
7818
|
exports.find = find;
|
|
7776
7819
|
/**
|
|
7777
|
-
* Finds the first element inside of an array that matches a test function.
|
|
7820
|
+
* Finds the first element inside of an array that matches a test function. This is an alias for `Array.prototype.find`.
|
|
7778
7821
|
*
|
|
7779
7822
|
* @category Querying
|
|
7780
7823
|
* @param test Function to test nodes on.
|
|
@@ -7791,29 +7834,31 @@ exports.findOneChild = findOneChild;
|
|
|
7791
7834
|
*
|
|
7792
7835
|
* @category Querying
|
|
7793
7836
|
* @param test Function to test nodes on.
|
|
7794
|
-
* @param nodes
|
|
7837
|
+
* @param nodes Node or array of nodes to search.
|
|
7795
7838
|
* @param recurse Also consider child nodes.
|
|
7796
|
-
* @returns The first
|
|
7839
|
+
* @returns The first node that passes `test`.
|
|
7797
7840
|
*/
|
|
7798
7841
|
function findOne(test, nodes, recurse) {
|
|
7799
7842
|
if (recurse === void 0) { recurse = true; }
|
|
7800
7843
|
var elem = null;
|
|
7801
7844
|
for (var i = 0; i < nodes.length && !elem; i++) {
|
|
7802
|
-
var
|
|
7803
|
-
if (!(0, domhandler_1.isTag)(
|
|
7845
|
+
var node = nodes[i];
|
|
7846
|
+
if (!(0, domhandler_1.isTag)(node)) {
|
|
7804
7847
|
continue;
|
|
7805
7848
|
}
|
|
7806
|
-
else if (test(
|
|
7807
|
-
elem =
|
|
7849
|
+
else if (test(node)) {
|
|
7850
|
+
elem = node;
|
|
7808
7851
|
}
|
|
7809
|
-
else if (recurse &&
|
|
7810
|
-
elem = findOne(test,
|
|
7852
|
+
else if (recurse && node.children.length > 0) {
|
|
7853
|
+
elem = findOne(test, node.children, true);
|
|
7811
7854
|
}
|
|
7812
7855
|
}
|
|
7813
7856
|
return elem;
|
|
7814
7857
|
}
|
|
7815
7858
|
exports.findOne = findOne;
|
|
7816
7859
|
/**
|
|
7860
|
+
* Checks if a tree of nodes contains at least one node passing a test.
|
|
7861
|
+
*
|
|
7817
7862
|
* @category Querying
|
|
7818
7863
|
* @param test Function to test nodes on.
|
|
7819
7864
|
* @param nodes Array of nodes to search.
|
|
@@ -7822,14 +7867,12 @@ exports.findOne = findOne;
|
|
|
7822
7867
|
function existsOne(test, nodes) {
|
|
7823
7868
|
return nodes.some(function (checked) {
|
|
7824
7869
|
return (0, domhandler_1.isTag)(checked) &&
|
|
7825
|
-
(test(checked) ||
|
|
7826
|
-
(checked.children.length > 0 &&
|
|
7827
|
-
existsOne(test, checked.children)));
|
|
7870
|
+
(test(checked) || existsOne(test, checked.children));
|
|
7828
7871
|
});
|
|
7829
7872
|
}
|
|
7830
7873
|
exports.existsOne = existsOne;
|
|
7831
7874
|
/**
|
|
7832
|
-
* Search
|
|
7875
|
+
* Search an array of nodes and their children for elements passing a test function.
|
|
7833
7876
|
*
|
|
7834
7877
|
* Same as `find`, but limited to elements and with less options, leading to reduced complexity.
|
|
7835
7878
|
*
|
|
@@ -7839,19 +7882,30 @@ exports.existsOne = existsOne;
|
|
|
7839
7882
|
* @returns All nodes passing `test`.
|
|
7840
7883
|
*/
|
|
7841
7884
|
function findAll(test, nodes) {
|
|
7842
|
-
var _a;
|
|
7843
7885
|
var result = [];
|
|
7844
|
-
var
|
|
7845
|
-
var
|
|
7846
|
-
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
|
|
7886
|
+
var nodeStack = [nodes];
|
|
7887
|
+
var indexStack = [0];
|
|
7888
|
+
for (;;) {
|
|
7889
|
+
if (indexStack[0] >= nodeStack[0].length) {
|
|
7890
|
+
if (nodeStack.length === 1) {
|
|
7891
|
+
return result;
|
|
7892
|
+
}
|
|
7893
|
+
// Otherwise, remove the current array from the stack.
|
|
7894
|
+
nodeStack.shift();
|
|
7895
|
+
indexStack.shift();
|
|
7896
|
+
// Loop back to the start to continue with the next array.
|
|
7897
|
+
continue;
|
|
7850
7898
|
}
|
|
7899
|
+
var elem = nodeStack[0][indexStack[0]++];
|
|
7900
|
+
if (!(0, domhandler_1.isTag)(elem))
|
|
7901
|
+
continue;
|
|
7851
7902
|
if (test(elem))
|
|
7852
7903
|
result.push(elem);
|
|
7904
|
+
if (elem.children.length > 0) {
|
|
7905
|
+
indexStack.unshift(0);
|
|
7906
|
+
nodeStack.unshift(elem.children);
|
|
7907
|
+
}
|
|
7853
7908
|
}
|
|
7854
|
-
return result;
|
|
7855
7909
|
}
|
|
7856
7910
|
exports.findAll = findAll;
|
|
7857
7911
|
//# sourceMappingURL=querying.js.map
|
|
@@ -7896,7 +7950,7 @@ function getInnerHTML(node, options) {
|
|
|
7896
7950
|
}
|
|
7897
7951
|
exports.getInnerHTML = getInnerHTML;
|
|
7898
7952
|
/**
|
|
7899
|
-
* Get a node's inner text. Same as `textContent`, but inserts newlines for `<br>` tags.
|
|
7953
|
+
* Get a node's inner text. Same as `textContent`, but inserts newlines for `<br>` tags. Ignores comments.
|
|
7900
7954
|
*
|
|
7901
7955
|
* @category Stringify
|
|
7902
7956
|
* @deprecated Use `textContent` instead.
|
|
@@ -7916,7 +7970,7 @@ function getText(node) {
|
|
|
7916
7970
|
}
|
|
7917
7971
|
exports.getText = getText;
|
|
7918
7972
|
/**
|
|
7919
|
-
* Get a node's text content.
|
|
7973
|
+
* Get a node's text content. Ignores comments.
|
|
7920
7974
|
*
|
|
7921
7975
|
* @category Stringify
|
|
7922
7976
|
* @param node Node to get the text content of.
|
|
@@ -7935,7 +7989,7 @@ function textContent(node) {
|
|
|
7935
7989
|
}
|
|
7936
7990
|
exports.textContent = textContent;
|
|
7937
7991
|
/**
|
|
7938
|
-
* Get a node's inner text.
|
|
7992
|
+
* Get a node's inner text, ignoring `<script>` and `<style>` tags. Ignores comments.
|
|
7939
7993
|
*
|
|
7940
7994
|
* @category Stringify
|
|
7941
7995
|
* @param node Node to get the inner text of.
|
|
@@ -7981,7 +8035,7 @@ exports.getChildren = getChildren;
|
|
|
7981
8035
|
*
|
|
7982
8036
|
* @category Traversal
|
|
7983
8037
|
* @param elem Node to get the parent of.
|
|
7984
|
-
* @returns `elem`'s parent node.
|
|
8038
|
+
* @returns `elem`'s parent node, or `null` if `elem` is a root node.
|
|
7985
8039
|
*/
|
|
7986
8040
|
function getParent(elem) {
|
|
7987
8041
|
return elem.parent || null;
|
|
@@ -7996,7 +8050,7 @@ exports.getParent = getParent;
|
|
|
7996
8050
|
*
|
|
7997
8051
|
* @category Traversal
|
|
7998
8052
|
* @param elem Element to get the siblings of.
|
|
7999
|
-
* @returns `elem`'s siblings
|
|
8053
|
+
* @returns `elem`'s siblings, including `elem`.
|
|
8000
8054
|
*/
|
|
8001
8055
|
function getSiblings(elem) {
|
|
8002
8056
|
var _a, _b;
|
|
@@ -8059,7 +8113,8 @@ exports.getName = getName;
|
|
|
8059
8113
|
*
|
|
8060
8114
|
* @category Traversal
|
|
8061
8115
|
* @param elem The element to get the next sibling of.
|
|
8062
|
-
* @returns `elem`'s next sibling that is a tag
|
|
8116
|
+
* @returns `elem`'s next sibling that is a tag, or `null` if there is no next
|
|
8117
|
+
* sibling.
|
|
8063
8118
|
*/
|
|
8064
8119
|
function nextElementSibling(elem) {
|
|
8065
8120
|
var _a;
|
|
@@ -8074,7 +8129,8 @@ exports.nextElementSibling = nextElementSibling;
|
|
|
8074
8129
|
*
|
|
8075
8130
|
* @category Traversal
|
|
8076
8131
|
* @param elem The element to get the previous sibling of.
|
|
8077
|
-
* @returns `elem`'s previous sibling that is a tag
|
|
8132
|
+
* @returns `elem`'s previous sibling that is a tag, or `null` if there is no
|
|
8133
|
+
* previous sibling.
|
|
8078
8134
|
*/
|
|
8079
8135
|
function prevElementSibling(elem) {
|
|
8080
8136
|
var _a;
|
|
@@ -8093,16 +8149,39 @@ exports.prevElementSibling = prevElementSibling;
|
|
|
8093
8149
|
|
|
8094
8150
|
"use strict";
|
|
8095
8151
|
|
|
8152
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8153
|
+
if (k2 === undefined) k2 = k;
|
|
8154
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8155
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8156
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8157
|
+
}
|
|
8158
|
+
Object.defineProperty(o, k2, desc);
|
|
8159
|
+
}) : (function(o, m, k, k2) {
|
|
8160
|
+
if (k2 === undefined) k2 = k;
|
|
8161
|
+
o[k2] = m[k];
|
|
8162
|
+
}));
|
|
8163
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
8164
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
8165
|
+
}) : function(o, v) {
|
|
8166
|
+
o["default"] = v;
|
|
8167
|
+
});
|
|
8168
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
8169
|
+
if (mod && mod.__esModule) return mod;
|
|
8170
|
+
var result = {};
|
|
8171
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
8172
|
+
__setModuleDefault(result, mod);
|
|
8173
|
+
return result;
|
|
8174
|
+
};
|
|
8096
8175
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8097
8176
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8098
8177
|
};
|
|
8099
8178
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
8100
|
-
exports.decodeXML = exports.decodeHTMLStrict = exports.decodeHTML = exports.determineBranch = exports.BinTrieFlags = exports.fromCodePoint = exports.replaceCodePoint = exports.decodeCodePoint = exports.xmlDecodeTree = exports.htmlDecodeTree = void 0;
|
|
8179
|
+
exports.decodeXML = exports.decodeHTMLStrict = exports.decodeHTMLAttribute = exports.decodeHTML = exports.determineBranch = exports.EntityDecoder = exports.DecodingMode = exports.BinTrieFlags = exports.fromCodePoint = exports.replaceCodePoint = exports.decodeCodePoint = exports.xmlDecodeTree = exports.htmlDecodeTree = void 0;
|
|
8101
8180
|
var decode_data_html_js_1 = __importDefault(__webpack_require__(18910));
|
|
8102
8181
|
exports.htmlDecodeTree = decode_data_html_js_1.default;
|
|
8103
8182
|
var decode_data_xml_js_1 = __importDefault(__webpack_require__(77247));
|
|
8104
8183
|
exports.xmlDecodeTree = decode_data_xml_js_1.default;
|
|
8105
|
-
var decode_codepoint_js_1 =
|
|
8184
|
+
var decode_codepoint_js_1 = __importStar(__webpack_require__(79233));
|
|
8106
8185
|
exports.decodeCodePoint = decode_codepoint_js_1.default;
|
|
8107
8186
|
var decode_codepoint_js_2 = __webpack_require__(79233);
|
|
8108
8187
|
Object.defineProperty(exports, "replaceCodePoint", ({ enumerable: true, get: function () { return decode_codepoint_js_2.replaceCodePoint; } }));
|
|
@@ -8111,99 +8190,421 @@ var CharCodes;
|
|
|
8111
8190
|
(function (CharCodes) {
|
|
8112
8191
|
CharCodes[CharCodes["NUM"] = 35] = "NUM";
|
|
8113
8192
|
CharCodes[CharCodes["SEMI"] = 59] = "SEMI";
|
|
8193
|
+
CharCodes[CharCodes["EQUALS"] = 61] = "EQUALS";
|
|
8114
8194
|
CharCodes[CharCodes["ZERO"] = 48] = "ZERO";
|
|
8115
8195
|
CharCodes[CharCodes["NINE"] = 57] = "NINE";
|
|
8116
8196
|
CharCodes[CharCodes["LOWER_A"] = 97] = "LOWER_A";
|
|
8117
8197
|
CharCodes[CharCodes["LOWER_F"] = 102] = "LOWER_F";
|
|
8118
8198
|
CharCodes[CharCodes["LOWER_X"] = 120] = "LOWER_X";
|
|
8119
|
-
|
|
8120
|
-
CharCodes[CharCodes["
|
|
8199
|
+
CharCodes[CharCodes["LOWER_Z"] = 122] = "LOWER_Z";
|
|
8200
|
+
CharCodes[CharCodes["UPPER_A"] = 65] = "UPPER_A";
|
|
8201
|
+
CharCodes[CharCodes["UPPER_F"] = 70] = "UPPER_F";
|
|
8202
|
+
CharCodes[CharCodes["UPPER_Z"] = 90] = "UPPER_Z";
|
|
8121
8203
|
})(CharCodes || (CharCodes = {}));
|
|
8204
|
+
/** Bit that needs to be set to convert an upper case ASCII character to lower case */
|
|
8205
|
+
var TO_LOWER_BIT = 32;
|
|
8122
8206
|
var BinTrieFlags;
|
|
8123
8207
|
(function (BinTrieFlags) {
|
|
8124
8208
|
BinTrieFlags[BinTrieFlags["VALUE_LENGTH"] = 49152] = "VALUE_LENGTH";
|
|
8125
8209
|
BinTrieFlags[BinTrieFlags["BRANCH_LENGTH"] = 16256] = "BRANCH_LENGTH";
|
|
8126
8210
|
BinTrieFlags[BinTrieFlags["JUMP_TABLE"] = 127] = "JUMP_TABLE";
|
|
8127
8211
|
})(BinTrieFlags = exports.BinTrieFlags || (exports.BinTrieFlags = {}));
|
|
8128
|
-
function
|
|
8129
|
-
return
|
|
8130
|
-
|
|
8131
|
-
|
|
8132
|
-
|
|
8133
|
-
|
|
8134
|
-
|
|
8135
|
-
|
|
8136
|
-
|
|
8137
|
-
|
|
8138
|
-
|
|
8139
|
-
|
|
8140
|
-
|
|
8141
|
-
|
|
8142
|
-
|
|
8143
|
-
|
|
8144
|
-
|
|
8145
|
-
|
|
8146
|
-
|
|
8147
|
-
|
|
8148
|
-
|
|
8149
|
-
|
|
8150
|
-
|
|
8151
|
-
|
|
8152
|
-
|
|
8153
|
-
|
|
8154
|
-
|
|
8155
|
-
|
|
8156
|
-
|
|
8157
|
-
|
|
8158
|
-
|
|
8159
|
-
|
|
8160
|
-
|
|
8161
|
-
|
|
8162
|
-
|
|
8163
|
-
|
|
8164
|
-
|
|
8165
|
-
|
|
8212
|
+
function isNumber(code) {
|
|
8213
|
+
return code >= CharCodes.ZERO && code <= CharCodes.NINE;
|
|
8214
|
+
}
|
|
8215
|
+
function isHexadecimalCharacter(code) {
|
|
8216
|
+
return ((code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_F) ||
|
|
8217
|
+
(code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_F));
|
|
8218
|
+
}
|
|
8219
|
+
function isAsciiAlphaNumeric(code) {
|
|
8220
|
+
return ((code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_Z) ||
|
|
8221
|
+
(code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_Z) ||
|
|
8222
|
+
isNumber(code));
|
|
8223
|
+
}
|
|
8224
|
+
/**
|
|
8225
|
+
* Checks if the given character is a valid end character for an entity in an attribute.
|
|
8226
|
+
*
|
|
8227
|
+
* Attribute values that aren't terminated properly aren't parsed, and shouldn't lead to a parser error.
|
|
8228
|
+
* See the example in https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state
|
|
8229
|
+
*/
|
|
8230
|
+
function isEntityInAttributeInvalidEnd(code) {
|
|
8231
|
+
return code === CharCodes.EQUALS || isAsciiAlphaNumeric(code);
|
|
8232
|
+
}
|
|
8233
|
+
var EntityDecoderState;
|
|
8234
|
+
(function (EntityDecoderState) {
|
|
8235
|
+
EntityDecoderState[EntityDecoderState["EntityStart"] = 0] = "EntityStart";
|
|
8236
|
+
EntityDecoderState[EntityDecoderState["NumericStart"] = 1] = "NumericStart";
|
|
8237
|
+
EntityDecoderState[EntityDecoderState["NumericDecimal"] = 2] = "NumericDecimal";
|
|
8238
|
+
EntityDecoderState[EntityDecoderState["NumericHex"] = 3] = "NumericHex";
|
|
8239
|
+
EntityDecoderState[EntityDecoderState["NamedEntity"] = 4] = "NamedEntity";
|
|
8240
|
+
})(EntityDecoderState || (EntityDecoderState = {}));
|
|
8241
|
+
var DecodingMode;
|
|
8242
|
+
(function (DecodingMode) {
|
|
8243
|
+
/** Entities in text nodes that can end with any character. */
|
|
8244
|
+
DecodingMode[DecodingMode["Legacy"] = 0] = "Legacy";
|
|
8245
|
+
/** Only allow entities terminated with a semicolon. */
|
|
8246
|
+
DecodingMode[DecodingMode["Strict"] = 1] = "Strict";
|
|
8247
|
+
/** Entities in attributes have limitations on ending characters. */
|
|
8248
|
+
DecodingMode[DecodingMode["Attribute"] = 2] = "Attribute";
|
|
8249
|
+
})(DecodingMode = exports.DecodingMode || (exports.DecodingMode = {}));
|
|
8250
|
+
/**
|
|
8251
|
+
* Token decoder with support of writing partial entities.
|
|
8252
|
+
*/
|
|
8253
|
+
var EntityDecoder = /** @class */ (function () {
|
|
8254
|
+
function EntityDecoder(
|
|
8255
|
+
/** The tree used to decode entities. */
|
|
8256
|
+
decodeTree,
|
|
8257
|
+
/**
|
|
8258
|
+
* The function that is called when a codepoint is decoded.
|
|
8259
|
+
*
|
|
8260
|
+
* For multi-byte named entities, this will be called multiple times,
|
|
8261
|
+
* with the second codepoint, and the same `consumed` value.
|
|
8262
|
+
*
|
|
8263
|
+
* @param codepoint The decoded codepoint.
|
|
8264
|
+
* @param consumed The number of bytes consumed by the decoder.
|
|
8265
|
+
*/
|
|
8266
|
+
emitCodePoint,
|
|
8267
|
+
/** An object that is used to produce errors. */
|
|
8268
|
+
errors) {
|
|
8269
|
+
this.decodeTree = decodeTree;
|
|
8270
|
+
this.emitCodePoint = emitCodePoint;
|
|
8271
|
+
this.errors = errors;
|
|
8272
|
+
/** The current state of the decoder. */
|
|
8273
|
+
this.state = EntityDecoderState.EntityStart;
|
|
8274
|
+
/** Characters that were consumed while parsing an entity. */
|
|
8275
|
+
this.consumed = 1;
|
|
8276
|
+
/**
|
|
8277
|
+
* The result of the entity.
|
|
8278
|
+
*
|
|
8279
|
+
* Either the result index of a numeric entity, or the codepoint of a
|
|
8280
|
+
* numeric entity.
|
|
8281
|
+
*/
|
|
8282
|
+
this.result = 0;
|
|
8283
|
+
/** The current index in the decode tree. */
|
|
8284
|
+
this.treeIndex = 0;
|
|
8285
|
+
/** The number of characters that were consumed in excess. */
|
|
8286
|
+
this.excess = 1;
|
|
8287
|
+
/** The mode in which the decoder is operating. */
|
|
8288
|
+
this.decodeMode = DecodingMode.Strict;
|
|
8289
|
+
}
|
|
8290
|
+
/** Resets the instance to make it reusable. */
|
|
8291
|
+
EntityDecoder.prototype.startEntity = function (decodeMode) {
|
|
8292
|
+
this.decodeMode = decodeMode;
|
|
8293
|
+
this.state = EntityDecoderState.EntityStart;
|
|
8294
|
+
this.result = 0;
|
|
8295
|
+
this.treeIndex = 0;
|
|
8296
|
+
this.excess = 1;
|
|
8297
|
+
this.consumed = 1;
|
|
8298
|
+
};
|
|
8299
|
+
/**
|
|
8300
|
+
* Write an entity to the decoder. This can be called multiple times with partial entities.
|
|
8301
|
+
* If the entity is incomplete, the decoder will return -1.
|
|
8302
|
+
*
|
|
8303
|
+
* Mirrors the implementation of `getDecoder`, but with the ability to stop decoding if the
|
|
8304
|
+
* entity is incomplete, and resume when the next string is written.
|
|
8305
|
+
*
|
|
8306
|
+
* @param string The string containing the entity (or a continuation of the entity).
|
|
8307
|
+
* @param offset The offset at which the entity begins. Should be 0 if this is not the first call.
|
|
8308
|
+
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
8309
|
+
*/
|
|
8310
|
+
EntityDecoder.prototype.write = function (str, offset) {
|
|
8311
|
+
switch (this.state) {
|
|
8312
|
+
case EntityDecoderState.EntityStart: {
|
|
8313
|
+
if (str.charCodeAt(offset) === CharCodes.NUM) {
|
|
8314
|
+
this.state = EntityDecoderState.NumericStart;
|
|
8315
|
+
this.consumed += 1;
|
|
8316
|
+
return this.stateNumericStart(str, offset + 1);
|
|
8166
8317
|
}
|
|
8167
|
-
|
|
8318
|
+
this.state = EntityDecoderState.NamedEntity;
|
|
8319
|
+
return this.stateNamedEntity(str, offset);
|
|
8168
8320
|
}
|
|
8169
|
-
|
|
8170
|
-
|
|
8171
|
-
|
|
8172
|
-
|
|
8173
|
-
|
|
8174
|
-
|
|
8175
|
-
|
|
8176
|
-
|
|
8177
|
-
|
|
8178
|
-
|
|
8179
|
-
|
|
8180
|
-
|
|
8181
|
-
|
|
8182
|
-
|
|
8183
|
-
|
|
8184
|
-
|
|
8185
|
-
|
|
8186
|
-
|
|
8187
|
-
|
|
8188
|
-
|
|
8189
|
-
|
|
8190
|
-
|
|
8321
|
+
case EntityDecoderState.NumericStart: {
|
|
8322
|
+
return this.stateNumericStart(str, offset);
|
|
8323
|
+
}
|
|
8324
|
+
case EntityDecoderState.NumericDecimal: {
|
|
8325
|
+
return this.stateNumericDecimal(str, offset);
|
|
8326
|
+
}
|
|
8327
|
+
case EntityDecoderState.NumericHex: {
|
|
8328
|
+
return this.stateNumericHex(str, offset);
|
|
8329
|
+
}
|
|
8330
|
+
case EntityDecoderState.NamedEntity: {
|
|
8331
|
+
return this.stateNamedEntity(str, offset);
|
|
8332
|
+
}
|
|
8333
|
+
}
|
|
8334
|
+
};
|
|
8335
|
+
/**
|
|
8336
|
+
* Switches between the numeric decimal and hexadecimal states.
|
|
8337
|
+
*
|
|
8338
|
+
* Equivalent to the `Numeric character reference state` in the HTML spec.
|
|
8339
|
+
*
|
|
8340
|
+
* @param str The string containing the entity (or a continuation of the entity).
|
|
8341
|
+
* @param offset The current offset.
|
|
8342
|
+
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
8343
|
+
*/
|
|
8344
|
+
EntityDecoder.prototype.stateNumericStart = function (str, offset) {
|
|
8345
|
+
if (offset >= str.length) {
|
|
8346
|
+
return -1;
|
|
8347
|
+
}
|
|
8348
|
+
if ((str.charCodeAt(offset) | TO_LOWER_BIT) === CharCodes.LOWER_X) {
|
|
8349
|
+
this.state = EntityDecoderState.NumericHex;
|
|
8350
|
+
this.consumed += 1;
|
|
8351
|
+
return this.stateNumericHex(str, offset + 1);
|
|
8352
|
+
}
|
|
8353
|
+
this.state = EntityDecoderState.NumericDecimal;
|
|
8354
|
+
return this.stateNumericDecimal(str, offset);
|
|
8355
|
+
};
|
|
8356
|
+
EntityDecoder.prototype.addToNumericResult = function (str, start, end, base) {
|
|
8357
|
+
if (start !== end) {
|
|
8358
|
+
var digitCount = end - start;
|
|
8359
|
+
this.result =
|
|
8360
|
+
this.result * Math.pow(base, digitCount) +
|
|
8361
|
+
parseInt(str.substr(start, digitCount), base);
|
|
8362
|
+
this.consumed += digitCount;
|
|
8363
|
+
}
|
|
8364
|
+
};
|
|
8365
|
+
/**
|
|
8366
|
+
* Parses a hexadecimal numeric entity.
|
|
8367
|
+
*
|
|
8368
|
+
* Equivalent to the `Hexademical character reference state` in the HTML spec.
|
|
8369
|
+
*
|
|
8370
|
+
* @param str The string containing the entity (or a continuation of the entity).
|
|
8371
|
+
* @param offset The current offset.
|
|
8372
|
+
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
8373
|
+
*/
|
|
8374
|
+
EntityDecoder.prototype.stateNumericHex = function (str, offset) {
|
|
8375
|
+
var startIdx = offset;
|
|
8376
|
+
while (offset < str.length) {
|
|
8377
|
+
var char = str.charCodeAt(offset);
|
|
8378
|
+
if (isNumber(char) || isHexadecimalCharacter(char)) {
|
|
8379
|
+
offset += 1;
|
|
8380
|
+
}
|
|
8381
|
+
else {
|
|
8382
|
+
this.addToNumericResult(str, startIdx, offset, 16);
|
|
8383
|
+
return this.emitNumericEntity(char, 3);
|
|
8384
|
+
}
|
|
8385
|
+
}
|
|
8386
|
+
this.addToNumericResult(str, startIdx, offset, 16);
|
|
8387
|
+
return -1;
|
|
8388
|
+
};
|
|
8389
|
+
/**
|
|
8390
|
+
* Parses a decimal numeric entity.
|
|
8391
|
+
*
|
|
8392
|
+
* Equivalent to the `Decimal character reference state` in the HTML spec.
|
|
8393
|
+
*
|
|
8394
|
+
* @param str The string containing the entity (or a continuation of the entity).
|
|
8395
|
+
* @param offset The current offset.
|
|
8396
|
+
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
8397
|
+
*/
|
|
8398
|
+
EntityDecoder.prototype.stateNumericDecimal = function (str, offset) {
|
|
8399
|
+
var startIdx = offset;
|
|
8400
|
+
while (offset < str.length) {
|
|
8401
|
+
var char = str.charCodeAt(offset);
|
|
8402
|
+
if (isNumber(char)) {
|
|
8403
|
+
offset += 1;
|
|
8404
|
+
}
|
|
8405
|
+
else {
|
|
8406
|
+
this.addToNumericResult(str, startIdx, offset, 10);
|
|
8407
|
+
return this.emitNumericEntity(char, 2);
|
|
8408
|
+
}
|
|
8409
|
+
}
|
|
8410
|
+
this.addToNumericResult(str, startIdx, offset, 10);
|
|
8411
|
+
return -1;
|
|
8412
|
+
};
|
|
8413
|
+
/**
|
|
8414
|
+
* Validate and emit a numeric entity.
|
|
8415
|
+
*
|
|
8416
|
+
* Implements the logic from the `Hexademical character reference start
|
|
8417
|
+
* state` and `Numeric character reference end state` in the HTML spec.
|
|
8418
|
+
*
|
|
8419
|
+
* @param lastCp The last code point of the entity. Used to see if the
|
|
8420
|
+
* entity was terminated with a semicolon.
|
|
8421
|
+
* @param expectedLength The minimum number of characters that should be
|
|
8422
|
+
* consumed. Used to validate that at least one digit
|
|
8423
|
+
* was consumed.
|
|
8424
|
+
* @returns The number of characters that were consumed.
|
|
8425
|
+
*/
|
|
8426
|
+
EntityDecoder.prototype.emitNumericEntity = function (lastCp, expectedLength) {
|
|
8427
|
+
var _a;
|
|
8428
|
+
// Ensure we consumed at least one digit.
|
|
8429
|
+
if (this.consumed <= expectedLength) {
|
|
8430
|
+
(_a = this.errors) === null || _a === void 0 ? void 0 : _a.absenceOfDigitsInNumericCharacterReference(this.consumed);
|
|
8431
|
+
return 0;
|
|
8432
|
+
}
|
|
8433
|
+
// Figure out if this is a legit end of the entity
|
|
8434
|
+
if (lastCp === CharCodes.SEMI) {
|
|
8435
|
+
this.consumed += 1;
|
|
8436
|
+
}
|
|
8437
|
+
else if (this.decodeMode === DecodingMode.Strict) {
|
|
8438
|
+
return 0;
|
|
8439
|
+
}
|
|
8440
|
+
this.emitCodePoint((0, decode_codepoint_js_1.replaceCodePoint)(this.result), this.consumed);
|
|
8441
|
+
if (this.errors) {
|
|
8442
|
+
if (lastCp !== CharCodes.SEMI) {
|
|
8443
|
+
this.errors.missingSemicolonAfterCharacterReference();
|
|
8444
|
+
}
|
|
8445
|
+
this.errors.validateNumericCharacterReference(this.result);
|
|
8446
|
+
}
|
|
8447
|
+
return this.consumed;
|
|
8448
|
+
};
|
|
8449
|
+
/**
|
|
8450
|
+
* Parses a named entity.
|
|
8451
|
+
*
|
|
8452
|
+
* Equivalent to the `Named character reference state` in the HTML spec.
|
|
8453
|
+
*
|
|
8454
|
+
* @param str The string containing the entity (or a continuation of the entity).
|
|
8455
|
+
* @param offset The current offset.
|
|
8456
|
+
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
8457
|
+
*/
|
|
8458
|
+
EntityDecoder.prototype.stateNamedEntity = function (str, offset) {
|
|
8459
|
+
var decodeTree = this.decodeTree;
|
|
8460
|
+
var current = decodeTree[this.treeIndex];
|
|
8461
|
+
// The mask is the number of bytes of the value, including the current byte.
|
|
8462
|
+
var valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;
|
|
8463
|
+
for (; offset < str.length; offset++, this.excess++) {
|
|
8464
|
+
var char = str.charCodeAt(offset);
|
|
8465
|
+
this.treeIndex = determineBranch(decodeTree, current, this.treeIndex + Math.max(1, valueLength), char);
|
|
8466
|
+
if (this.treeIndex < 0) {
|
|
8467
|
+
return this.result === 0 ||
|
|
8468
|
+
// If we are parsing an attribute
|
|
8469
|
+
(this.decodeMode === DecodingMode.Attribute &&
|
|
8470
|
+
// We shouldn't have consumed any characters after the entity,
|
|
8471
|
+
(valueLength === 0 ||
|
|
8472
|
+
// And there should be no invalid characters.
|
|
8473
|
+
isEntityInAttributeInvalidEnd(char)))
|
|
8474
|
+
? 0
|
|
8475
|
+
: this.emitNotTerminatedNamedEntity();
|
|
8476
|
+
}
|
|
8477
|
+
current = decodeTree[this.treeIndex];
|
|
8478
|
+
valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;
|
|
8479
|
+
// If the branch is a value, store it and continue
|
|
8480
|
+
if (valueLength !== 0) {
|
|
8481
|
+
// If the entity is terminated by a semicolon, we are done.
|
|
8482
|
+
if (char === CharCodes.SEMI) {
|
|
8483
|
+
return this.emitNamedEntityData(this.treeIndex, valueLength, this.consumed + this.excess);
|
|
8484
|
+
}
|
|
8485
|
+
// If we encounter a non-terminated (legacy) entity while parsing strictly, then ignore it.
|
|
8486
|
+
if (this.decodeMode !== DecodingMode.Strict) {
|
|
8487
|
+
this.result = this.treeIndex;
|
|
8488
|
+
this.consumed += this.excess;
|
|
8489
|
+
this.excess = 0;
|
|
8191
8490
|
}
|
|
8192
8491
|
}
|
|
8193
|
-
|
|
8194
|
-
|
|
8195
|
-
|
|
8196
|
-
|
|
8197
|
-
|
|
8198
|
-
|
|
8199
|
-
|
|
8200
|
-
|
|
8201
|
-
|
|
8492
|
+
}
|
|
8493
|
+
return -1;
|
|
8494
|
+
};
|
|
8495
|
+
/**
|
|
8496
|
+
* Emit a named entity that was not terminated with a semicolon.
|
|
8497
|
+
*
|
|
8498
|
+
* @returns The number of characters consumed.
|
|
8499
|
+
*/
|
|
8500
|
+
EntityDecoder.prototype.emitNotTerminatedNamedEntity = function () {
|
|
8501
|
+
var _a;
|
|
8502
|
+
var _b = this, result = _b.result, decodeTree = _b.decodeTree;
|
|
8503
|
+
var valueLength = (decodeTree[result] & BinTrieFlags.VALUE_LENGTH) >> 14;
|
|
8504
|
+
this.emitNamedEntityData(result, valueLength, this.consumed);
|
|
8505
|
+
(_a = this.errors) === null || _a === void 0 ? void 0 : _a.missingSemicolonAfterCharacterReference();
|
|
8506
|
+
return this.consumed;
|
|
8507
|
+
};
|
|
8508
|
+
/**
|
|
8509
|
+
* Emit a named entity.
|
|
8510
|
+
*
|
|
8511
|
+
* @param result The index of the entity in the decode tree.
|
|
8512
|
+
* @param valueLength The number of bytes in the entity.
|
|
8513
|
+
* @param consumed The number of characters consumed.
|
|
8514
|
+
*
|
|
8515
|
+
* @returns The number of characters consumed.
|
|
8516
|
+
*/
|
|
8517
|
+
EntityDecoder.prototype.emitNamedEntityData = function (result, valueLength, consumed) {
|
|
8518
|
+
var decodeTree = this.decodeTree;
|
|
8519
|
+
this.emitCodePoint(valueLength === 1
|
|
8520
|
+
? decodeTree[result] & ~BinTrieFlags.VALUE_LENGTH
|
|
8521
|
+
: decodeTree[result + 1], consumed);
|
|
8522
|
+
if (valueLength === 3) {
|
|
8523
|
+
// For multi-byte values, we need to emit the second byte.
|
|
8524
|
+
this.emitCodePoint(decodeTree[result + 2], consumed);
|
|
8525
|
+
}
|
|
8526
|
+
return consumed;
|
|
8527
|
+
};
|
|
8528
|
+
/**
|
|
8529
|
+
* Signal to the parser that the end of the input was reached.
|
|
8530
|
+
*
|
|
8531
|
+
* Remaining data will be emitted and relevant errors will be produced.
|
|
8532
|
+
*
|
|
8533
|
+
* @returns The number of characters consumed.
|
|
8534
|
+
*/
|
|
8535
|
+
EntityDecoder.prototype.end = function () {
|
|
8536
|
+
var _a;
|
|
8537
|
+
switch (this.state) {
|
|
8538
|
+
case EntityDecoderState.NamedEntity: {
|
|
8539
|
+
// Emit a named entity if we have one.
|
|
8540
|
+
return this.result !== 0 &&
|
|
8541
|
+
(this.decodeMode !== DecodingMode.Attribute ||
|
|
8542
|
+
this.result === this.treeIndex)
|
|
8543
|
+
? this.emitNotTerminatedNamedEntity()
|
|
8544
|
+
: 0;
|
|
8545
|
+
}
|
|
8546
|
+
// Otherwise, emit a numeric entity if we have one.
|
|
8547
|
+
case EntityDecoderState.NumericDecimal: {
|
|
8548
|
+
return this.emitNumericEntity(0, 2);
|
|
8549
|
+
}
|
|
8550
|
+
case EntityDecoderState.NumericHex: {
|
|
8551
|
+
return this.emitNumericEntity(0, 3);
|
|
8552
|
+
}
|
|
8553
|
+
case EntityDecoderState.NumericStart: {
|
|
8554
|
+
(_a = this.errors) === null || _a === void 0 ? void 0 : _a.absenceOfDigitsInNumericCharacterReference(this.consumed);
|
|
8555
|
+
return 0;
|
|
8556
|
+
}
|
|
8557
|
+
case EntityDecoderState.EntityStart: {
|
|
8558
|
+
// Return 0 if we have no entity.
|
|
8559
|
+
return 0;
|
|
8560
|
+
}
|
|
8561
|
+
}
|
|
8562
|
+
};
|
|
8563
|
+
return EntityDecoder;
|
|
8564
|
+
}());
|
|
8565
|
+
exports.EntityDecoder = EntityDecoder;
|
|
8566
|
+
/**
|
|
8567
|
+
* Creates a function that decodes entities in a string.
|
|
8568
|
+
*
|
|
8569
|
+
* @param decodeTree The decode tree.
|
|
8570
|
+
* @returns A function that decodes entities in a string.
|
|
8571
|
+
*/
|
|
8572
|
+
function getDecoder(decodeTree) {
|
|
8573
|
+
var ret = "";
|
|
8574
|
+
var decoder = new EntityDecoder(decodeTree, function (str) { return (ret += (0, decode_codepoint_js_1.fromCodePoint)(str)); });
|
|
8575
|
+
return function decodeWithTrie(str, decodeMode) {
|
|
8576
|
+
var lastIndex = 0;
|
|
8577
|
+
var offset = 0;
|
|
8578
|
+
while ((offset = str.indexOf("&", offset)) >= 0) {
|
|
8579
|
+
ret += str.slice(lastIndex, offset);
|
|
8580
|
+
decoder.startEntity(decodeMode);
|
|
8581
|
+
var len = decoder.write(str,
|
|
8582
|
+
// Skip the "&"
|
|
8583
|
+
offset + 1);
|
|
8584
|
+
if (len < 0) {
|
|
8585
|
+
lastIndex = offset + decoder.end();
|
|
8586
|
+
break;
|
|
8202
8587
|
}
|
|
8588
|
+
lastIndex = offset + len;
|
|
8589
|
+
// If `len` is 0, skip the current `&` and continue.
|
|
8590
|
+
offset = len === 0 ? lastIndex + 1 : lastIndex;
|
|
8203
8591
|
}
|
|
8204
|
-
|
|
8592
|
+
var result = ret + str.slice(lastIndex);
|
|
8593
|
+
// Make sure we don't keep a reference to the final string.
|
|
8594
|
+
ret = "";
|
|
8595
|
+
return result;
|
|
8205
8596
|
};
|
|
8206
8597
|
}
|
|
8598
|
+
/**
|
|
8599
|
+
* Determines the branch of the current node that is taken given the current
|
|
8600
|
+
* character. This function is used to traverse the trie.
|
|
8601
|
+
*
|
|
8602
|
+
* @param decodeTree The trie.
|
|
8603
|
+
* @param current The current node.
|
|
8604
|
+
* @param nodeIdx The index right after the current node and its value.
|
|
8605
|
+
* @param char The current character.
|
|
8606
|
+
* @returns The index of the next node, or -1 if no branch is taken.
|
|
8607
|
+
*/
|
|
8207
8608
|
function determineBranch(decodeTree, current, nodeIdx, char) {
|
|
8208
8609
|
var branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
|
|
8209
8610
|
var jumpOffset = current & BinTrieFlags.JUMP_TABLE;
|
|
@@ -8241,33 +8642,45 @@ exports.determineBranch = determineBranch;
|
|
|
8241
8642
|
var htmlDecoder = getDecoder(decode_data_html_js_1.default);
|
|
8242
8643
|
var xmlDecoder = getDecoder(decode_data_xml_js_1.default);
|
|
8243
8644
|
/**
|
|
8244
|
-
* Decodes an HTML string
|
|
8645
|
+
* Decodes an HTML string.
|
|
8245
8646
|
*
|
|
8246
8647
|
* @param str The string to decode.
|
|
8648
|
+
* @param mode The decoding mode.
|
|
8247
8649
|
* @returns The decoded string.
|
|
8248
8650
|
*/
|
|
8249
|
-
function decodeHTML(str) {
|
|
8250
|
-
|
|
8651
|
+
function decodeHTML(str, mode) {
|
|
8652
|
+
if (mode === void 0) { mode = DecodingMode.Legacy; }
|
|
8653
|
+
return htmlDecoder(str, mode);
|
|
8251
8654
|
}
|
|
8252
8655
|
exports.decodeHTML = decodeHTML;
|
|
8253
8656
|
/**
|
|
8254
|
-
* Decodes an HTML string
|
|
8657
|
+
* Decodes an HTML string in an attribute.
|
|
8658
|
+
*
|
|
8659
|
+
* @param str The string to decode.
|
|
8660
|
+
* @returns The decoded string.
|
|
8661
|
+
*/
|
|
8662
|
+
function decodeHTMLAttribute(str) {
|
|
8663
|
+
return htmlDecoder(str, DecodingMode.Attribute);
|
|
8664
|
+
}
|
|
8665
|
+
exports.decodeHTMLAttribute = decodeHTMLAttribute;
|
|
8666
|
+
/**
|
|
8667
|
+
* Decodes an HTML string, requiring all entities to be terminated by a semicolon.
|
|
8255
8668
|
*
|
|
8256
8669
|
* @param str The string to decode.
|
|
8257
8670
|
* @returns The decoded string.
|
|
8258
8671
|
*/
|
|
8259
8672
|
function decodeHTMLStrict(str) {
|
|
8260
|
-
return htmlDecoder(str,
|
|
8673
|
+
return htmlDecoder(str, DecodingMode.Strict);
|
|
8261
8674
|
}
|
|
8262
8675
|
exports.decodeHTMLStrict = decodeHTMLStrict;
|
|
8263
8676
|
/**
|
|
8264
|
-
* Decodes an XML string, requiring all entities to be terminated by a
|
|
8677
|
+
* Decodes an XML string, requiring all entities to be terminated by a semicolon.
|
|
8265
8678
|
*
|
|
8266
8679
|
* @param str The string to decode.
|
|
8267
8680
|
* @returns The decoded string.
|
|
8268
8681
|
*/
|
|
8269
8682
|
function decodeXML(str) {
|
|
8270
|
-
return xmlDecoder(str,
|
|
8683
|
+
return xmlDecoder(str, DecodingMode.Strict);
|
|
8271
8684
|
}
|
|
8272
8685
|
exports.decodeXML = decodeXML;
|
|
8273
8686
|
//# sourceMappingURL=decode.js.map
|
|
@@ -8285,6 +8698,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
8285
8698
|
exports.replaceCodePoint = exports.fromCodePoint = void 0;
|
|
8286
8699
|
var decodeMap = new Map([
|
|
8287
8700
|
[0, 65533],
|
|
8701
|
+
// C1 Unicode control character reference replacements
|
|
8288
8702
|
[128, 8364],
|
|
8289
8703
|
[130, 8218],
|
|
8290
8704
|
[131, 402],
|
|
@@ -8313,6 +8727,9 @@ var decodeMap = new Map([
|
|
|
8313
8727
|
[158, 382],
|
|
8314
8728
|
[159, 376],
|
|
8315
8729
|
]);
|
|
8730
|
+
/**
|
|
8731
|
+
* Polyfill for `String.fromCodePoint`. It is used to create a string from a Unicode code point.
|
|
8732
|
+
*/
|
|
8316
8733
|
exports.fromCodePoint =
|
|
8317
8734
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, node/no-unsupported-features/es-builtins
|
|
8318
8735
|
(_a = String.fromCodePoint) !== null && _a !== void 0 ? _a : function (codePoint) {
|
|
@@ -8325,6 +8742,11 @@ exports.fromCodePoint =
|
|
|
8325
8742
|
output += String.fromCharCode(codePoint);
|
|
8326
8743
|
return output;
|
|
8327
8744
|
};
|
|
8745
|
+
/**
|
|
8746
|
+
* Replace the given code point with a replacement character if it is a
|
|
8747
|
+
* surrogate or is outside the valid range. Otherwise return the code
|
|
8748
|
+
* point unchanged.
|
|
8749
|
+
*/
|
|
8328
8750
|
function replaceCodePoint(codePoint) {
|
|
8329
8751
|
var _a;
|
|
8330
8752
|
if ((codePoint >= 0xd800 && codePoint <= 0xdfff) || codePoint > 0x10ffff) {
|
|
@@ -8333,6 +8755,13 @@ function replaceCodePoint(codePoint) {
|
|
|
8333
8755
|
return (_a = decodeMap.get(codePoint)) !== null && _a !== void 0 ? _a : codePoint;
|
|
8334
8756
|
}
|
|
8335
8757
|
exports.replaceCodePoint = replaceCodePoint;
|
|
8758
|
+
/**
|
|
8759
|
+
* Replace the code point if relevant, then convert it to a string.
|
|
8760
|
+
*
|
|
8761
|
+
* @deprecated Use `fromCodePoint(replaceCodePoint(codePoint))` instead.
|
|
8762
|
+
* @param codePoint The code point to decode.
|
|
8763
|
+
* @returns The decoded code point.
|
|
8764
|
+
*/
|
|
8336
8765
|
function decodeCodePoint(codePoint) {
|
|
8337
8766
|
return (0, exports.fromCodePoint)(replaceCodePoint(codePoint));
|
|
8338
8767
|
}
|
|
@@ -8407,7 +8836,7 @@ function encodeHTMLTrieRe(regExp, str) {
|
|
|
8407
8836
|
}
|
|
8408
8837
|
next = next.v;
|
|
8409
8838
|
}
|
|
8410
|
-
// We might have a tree node without a value; skip and use a numeric
|
|
8839
|
+
// We might have a tree node without a value; skip and use a numeric entity.
|
|
8411
8840
|
if (next !== undefined) {
|
|
8412
8841
|
ret += next;
|
|
8413
8842
|
lastIdx = i + 1;
|
|
@@ -8492,6 +8921,16 @@ exports.encodeXML = encodeXML;
|
|
|
8492
8921
|
* @param data String to escape.
|
|
8493
8922
|
*/
|
|
8494
8923
|
exports.escape = encodeXML;
|
|
8924
|
+
/**
|
|
8925
|
+
* Creates a function that escapes all characters matched by the given regular
|
|
8926
|
+
* expression using the given map of characters to escape to their entities.
|
|
8927
|
+
*
|
|
8928
|
+
* @param regex Regular expression to match characters to escape.
|
|
8929
|
+
* @param map Map of characters to escape to their entities.
|
|
8930
|
+
*
|
|
8931
|
+
* @returns Function that escapes all characters matched by the given regular
|
|
8932
|
+
* expression using the given map of characters to escape to their entities.
|
|
8933
|
+
*/
|
|
8495
8934
|
function getEscaper(regex, map) {
|
|
8496
8935
|
return function escape(data) {
|
|
8497
8936
|
var match;
|
|
@@ -8501,7 +8940,7 @@ function getEscaper(regex, map) {
|
|
|
8501
8940
|
if (lastIdx !== match.index) {
|
|
8502
8941
|
result += data.substring(lastIdx, match.index);
|
|
8503
8942
|
}
|
|
8504
|
-
// We know that this
|
|
8943
|
+
// We know that this character will be in the map.
|
|
8505
8944
|
result += map.get(match[0].charCodeAt(0));
|
|
8506
8945
|
// Every match will be of length 1
|
|
8507
8946
|
lastIdx = match.index + 1;
|
|
@@ -8601,7 +9040,7 @@ exports["default"] = new Map(/* #__PURE__ */ restoreDiff([[9, "	"], [0, "&Ne
|
|
|
8601
9040
|
"use strict";
|
|
8602
9041
|
|
|
8603
9042
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
8604
|
-
exports.decodeXMLStrict = exports.decodeHTML5Strict = exports.decodeHTML4Strict = exports.decodeHTML5 = exports.decodeHTML4 = exports.decodeHTMLStrict = exports.decodeHTML = exports.decodeXML = exports.encodeHTML5 = exports.encodeHTML4 = exports.encodeNonAsciiHTML = exports.encodeHTML = exports.escapeText = exports.escapeAttribute = exports.escapeUTF8 = exports.escape = exports.encodeXML = exports.encode = exports.decodeStrict = exports.decode = exports.EncodingMode = exports.
|
|
9043
|
+
exports.decodeXMLStrict = exports.decodeHTML5Strict = exports.decodeHTML4Strict = exports.decodeHTML5 = exports.decodeHTML4 = exports.decodeHTMLAttribute = exports.decodeHTMLStrict = exports.decodeHTML = exports.decodeXML = exports.DecodingMode = exports.EntityDecoder = exports.encodeHTML5 = exports.encodeHTML4 = exports.encodeNonAsciiHTML = exports.encodeHTML = exports.escapeText = exports.escapeAttribute = exports.escapeUTF8 = exports.escape = exports.encodeXML = exports.encode = exports.decodeStrict = exports.decode = exports.EncodingMode = exports.EntityLevel = void 0;
|
|
8605
9044
|
var decode_js_1 = __webpack_require__(80624);
|
|
8606
9045
|
var encode_js_1 = __webpack_require__(12031);
|
|
8607
9046
|
var escape_js_1 = __webpack_require__(60170);
|
|
@@ -8613,14 +9052,6 @@ var EntityLevel;
|
|
|
8613
9052
|
/** Support HTML entities, which are a superset of XML entities. */
|
|
8614
9053
|
EntityLevel[EntityLevel["HTML"] = 1] = "HTML";
|
|
8615
9054
|
})(EntityLevel = exports.EntityLevel || (exports.EntityLevel = {}));
|
|
8616
|
-
/** Determines whether some entities are allowed to be written without a trailing `;`. */
|
|
8617
|
-
var DecodingMode;
|
|
8618
|
-
(function (DecodingMode) {
|
|
8619
|
-
/** Support legacy HTML entities. */
|
|
8620
|
-
DecodingMode[DecodingMode["Legacy"] = 0] = "Legacy";
|
|
8621
|
-
/** Do not support legacy HTML entities. */
|
|
8622
|
-
DecodingMode[DecodingMode["Strict"] = 1] = "Strict";
|
|
8623
|
-
})(DecodingMode = exports.DecodingMode || (exports.DecodingMode = {}));
|
|
8624
9055
|
var EncodingMode;
|
|
8625
9056
|
(function (EncodingMode) {
|
|
8626
9057
|
/**
|
|
@@ -8658,12 +9089,10 @@ var EncodingMode;
|
|
|
8658
9089
|
*/
|
|
8659
9090
|
function decode(data, options) {
|
|
8660
9091
|
if (options === void 0) { options = EntityLevel.XML; }
|
|
8661
|
-
var
|
|
8662
|
-
if (
|
|
8663
|
-
|
|
8664
|
-
|
|
8665
|
-
}
|
|
8666
|
-
return (0, decode_js_1.decodeHTML)(data);
|
|
9092
|
+
var level = typeof options === "number" ? options : options.level;
|
|
9093
|
+
if (level === EntityLevel.HTML) {
|
|
9094
|
+
var mode = typeof options === "object" ? options.mode : undefined;
|
|
9095
|
+
return (0, decode_js_1.decodeHTML)(data, mode);
|
|
8667
9096
|
}
|
|
8668
9097
|
return (0, decode_js_1.decodeXML)(data);
|
|
8669
9098
|
}
|
|
@@ -8676,15 +9105,11 @@ exports.decode = decode;
|
|
|
8676
9105
|
* @deprecated Use `decode` with the `mode` set to `Strict`.
|
|
8677
9106
|
*/
|
|
8678
9107
|
function decodeStrict(data, options) {
|
|
9108
|
+
var _a;
|
|
8679
9109
|
if (options === void 0) { options = EntityLevel.XML; }
|
|
8680
9110
|
var opts = typeof options === "number" ? { level: options } : options;
|
|
8681
|
-
|
|
8682
|
-
|
|
8683
|
-
return (0, decode_js_1.decodeHTML)(data);
|
|
8684
|
-
}
|
|
8685
|
-
return (0, decode_js_1.decodeHTMLStrict)(data);
|
|
8686
|
-
}
|
|
8687
|
-
return (0, decode_js_1.decodeXML)(data);
|
|
9111
|
+
(_a = opts.mode) !== null && _a !== void 0 ? _a : (opts.mode = decode_js_1.DecodingMode.Strict);
|
|
9112
|
+
return decode(data, opts);
|
|
8688
9113
|
}
|
|
8689
9114
|
exports.decodeStrict = decodeStrict;
|
|
8690
9115
|
/**
|
|
@@ -8726,9 +9151,12 @@ Object.defineProperty(exports, "encodeNonAsciiHTML", ({ enumerable: true, get: f
|
|
|
8726
9151
|
Object.defineProperty(exports, "encodeHTML4", ({ enumerable: true, get: function () { return encode_js_2.encodeHTML; } }));
|
|
8727
9152
|
Object.defineProperty(exports, "encodeHTML5", ({ enumerable: true, get: function () { return encode_js_2.encodeHTML; } }));
|
|
8728
9153
|
var decode_js_2 = __webpack_require__(80624);
|
|
9154
|
+
Object.defineProperty(exports, "EntityDecoder", ({ enumerable: true, get: function () { return decode_js_2.EntityDecoder; } }));
|
|
9155
|
+
Object.defineProperty(exports, "DecodingMode", ({ enumerable: true, get: function () { return decode_js_2.DecodingMode; } }));
|
|
8729
9156
|
Object.defineProperty(exports, "decodeXML", ({ enumerable: true, get: function () { return decode_js_2.decodeXML; } }));
|
|
8730
9157
|
Object.defineProperty(exports, "decodeHTML", ({ enumerable: true, get: function () { return decode_js_2.decodeHTML; } }));
|
|
8731
9158
|
Object.defineProperty(exports, "decodeHTMLStrict", ({ enumerable: true, get: function () { return decode_js_2.decodeHTMLStrict; } }));
|
|
9159
|
+
Object.defineProperty(exports, "decodeHTMLAttribute", ({ enumerable: true, get: function () { return decode_js_2.decodeHTMLAttribute; } }));
|
|
8732
9160
|
// Legacy aliases (deprecated)
|
|
8733
9161
|
Object.defineProperty(exports, "decodeHTML4", ({ enumerable: true, get: function () { return decode_js_2.decodeHTML; } }));
|
|
8734
9162
|
Object.defineProperty(exports, "decodeHTML5", ({ enumerable: true, get: function () { return decode_js_2.decodeHTML; } }));
|