planning
All checks were successful
Publish To Prod / deploy_and_publish (push) Successful in 35s

This commit is contained in:
2024-10-14 09:15:30 +02:00
parent bcba00a730
commit 6e64e138e2
21059 changed files with 2317811 additions and 1 deletions

121
node_modules/xml-utils/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,121 @@
Creative Commons Legal Code
CC0 1.0 Universal
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.
Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator
and subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").
Certain owners wish to permanently relinquish those rights to a Work for
the purpose of contributing to a commons of creative, cultural and
scientific works ("Commons") that the public can reliably and without fear
of later claims of infringement build upon, modify, incorporate in other
works, reuse and redistribute as freely as possible in any form whatsoever
and for any purposes, including without limitation commercial purposes.
These owners may contribute to the Commons to promote the ideal of a free
culture and the further production of creative, cultural and scientific
works, or to gain reputation or greater distribution for their Work in
part through the use and efforts of others.
For these and/or other purposes and motivations, and without any
expectation of additional consideration or compensation, the person
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
is an owner of Copyright and Related Rights in the Work, voluntarily
elects to apply CC0 to the Work and publicly distribute the Work under its
terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:
i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
vii. other similar, equivalent or corresponding rights throughout the
world based on applicable law or treaty, and any national
implementations thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.
4. Limitations and Disclaimers.
a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.

135
node_modules/xml-utils/README.md generated vendored Normal file
View File

@@ -0,0 +1,135 @@
# xml-utils
> The lightest XML parsing library
## features
- Only import the functions that you need
- No external dependencies
- Runs the same in NodeJS and Browser
- Supports TypeScript
## install
```bash
npm install xml-utils
```
# usage
## the simple tag object
XML tags are represented by a simple object with an outer and inner property.
The "outer" property is the text string that completely encompasses the tag, equivalent to an HTML element's "outerHTML".
The "inner" property represents the sub-parts of the tag. It is similar to an HTML element's "textContent".
Here's an example of a tag:
```javascript
{
outer: "<MDI key="INTERLEAVE">PIXEL</MDI>",
inner: "PIXEL"
}
```
## get attribute
```javascript
const getAttribute = require("xml-utils/get-attribute.js");
const xml = `<MDI key="INTERLEAVE">PIXEL</MDI>`;
const key = getAttribute(xml, "key");
// key is "INTERLEAVE"
```
## find one tag by name
```javascript
const findTagByName = require("xml-utils/find-tag-by-name.js");
const xml = `<Metadata domain="IMAGE_STRUCTURE"><MDI key="INTERLEAVE">PIXEL</MDI></Metadata>`
const tag = findTagByName(xml, "MDI");
```
tag is
```javascript
{
outer: "<MDI key="INTERLEAVE">PIXEL</MDI>",
inner: "PIXEL"
}
```
## find multiple tags with the same name
```javascript
const findTagsByName = require("xml-utils/find-tags-by-name.js");
const xml = `
<Metadata>
<MDI key="SourceBandIndex">1</MDI>
<MDI key="STATISTICS_MAXIMUM">255</MDI>
<MDI key="STATISTICS_MEAN">96.372431147996</MDI>
<MDI key="STATISTICS_MINIMUM">0</MDI>
<MDI key="STATISTICS_STDDEV">50.057898474622</MDI>
</Metadata>
`;
const tags = findTagsByName(xml, "MDI");
// tags is an array of tags
```
## find one tag by path
```javascript
const findTagByPath = require("xml-utils/find-tag-by-path.js");
const xml = `
<gmd:referenceSystemIdentifier>
<gmd:RS_Identifier>
<gmd:code>
<gco:CharacterString>4326</gco:CharacterString>
</gmd:code>
<gmd:codeSpace>
<gco:CharacterString>EPSG</gco:CharacterString>
</gmd:codeSpace>
<gmd:version>
<gco:CharacterString>6.11</gco:CharacterString>
</gmd:version>
</gmd:RS_Identifier>
</gmd:referenceSystemIdentifier>
`;
const tag = findTagByPath(xml, ["gmd:RS_Identifier", "gmd:code", "gco:CharacterString"]);
```
## find multiple tags by path
To get an array of tags that follow a path:
```javascript
const findTagsByPath = require("xml-utils/find-tags-by-path.js");
const tags = findTagsByPath(xml, ["Metadata", "MDI"]);
// tags is an array of tags
// find description for 10th tag in list
const tags = findTagsByPath(iso, [
{ name: "gmd:onLine", index: 9 }, // using zero-based index
"gmd:description",
"gco:CharacterString"
]);
```
## remove comments
```javascript
const removeComments = require("xml-utils/remove-comments.js");
const xml = `<list>
<!--<A/>-->
<B/>
</list>`;
removeComments(xml);
"<list>\n \n<B/><list>";
```
## remove tags by name
```js
const removeTagsByName = require("xml-utils/remove-tags-by-name.js");
const xml = "<ul><li>A</li><li>B</li></ul>";
removeTagsByName(xml, "li")
"<ul></ul>"
```
## setup
download test files with:
```bash
npm run setup
```
## test
```bash
npm run test
```
# contact
Post an issue at https://github.com/DanielJDufour/xml-utils/issues or email the package author at daniel.j.dufour@gmail.com

8
node_modules/xml-utils/count-substring.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
function countSubstring(string, substring) {
const pattern = new RegExp(substring, "g");
const match = string.match(pattern);
return match ? match.length : 0;
}
module.exports = countSubstring;
module.exports.default = countSubstring;

5
node_modules/xml-utils/count-substring.mjs generated vendored Normal file
View File

@@ -0,0 +1,5 @@
export default function countSubstring(string, substring) {
const pattern = new RegExp(substring, "g");
const match = string.match(pattern);
return match ? match.length : 0;
}

61
node_modules/xml-utils/find-tag-by-name.js generated vendored Normal file
View File

@@ -0,0 +1,61 @@
const indexOfMatch = require("./index-of-match.js");
const indexOfMatchEnd = require("./index-of-match-end.js");
const countSubstring = require("./count-substring.js");
function findTagByName(xml, tagName, options) {
const debug = (options && options.debug) || false;
const nested = !(options && typeof options.nested === false);
const startIndex = (options && options.startIndex) || 0;
if (debug) console.log("[xml-utils] starting findTagByName with", tagName, " and ", options);
const start = indexOfMatch(xml, `\<${tagName}[ \n\>\/]`, startIndex);
if (debug) console.log("[xml-utils] start:", start);
if (start === -1) return undefined;
const afterStart = xml.slice(start + tagName.length);
let relativeEnd = indexOfMatchEnd(afterStart, "^[^<]*[ /]>", 0);
const selfClosing = relativeEnd !== -1 && afterStart[relativeEnd - 1] === "/";
if (debug) console.log("[xml-utils] selfClosing:", selfClosing);
if (selfClosing === false) {
// check if tag has subtags with the same name
if (nested) {
let startIndex = 0;
let openings = 1;
let closings = 0;
while ((relativeEnd = indexOfMatchEnd(afterStart, "[ /]" + tagName + ">", startIndex)) !== -1) {
const clip = afterStart.substring(startIndex, relativeEnd + 1);
openings += countSubstring(clip, "<" + tagName + "[ \n\t>]");
closings += countSubstring(clip, "</" + tagName + ">");
// we can't have more openings than closings
if (closings >= openings) break;
startIndex = relativeEnd;
}
} else {
relativeEnd = indexOfMatchEnd(afterStart, "[ /]" + tagName + ">", 0);
}
}
const end = start + tagName.length + relativeEnd + 1;
if (debug) console.log("[xml-utils] end:", end);
if (end === -1) return undefined;
const outer = xml.slice(start, end);
// tag is like <gml:identifier codeSpace="OGP">urn:ogc:def:crs:EPSG::32617</gml:identifier>
let inner;
if (selfClosing) {
inner = null;
} else {
inner = outer.slice(outer.indexOf(">") + 1, outer.lastIndexOf("<"));
}
return { inner, outer, start, end };
}
module.exports = findTagByName;
module.exports.default = findTagByName;

58
node_modules/xml-utils/find-tag-by-name.mjs generated vendored Normal file
View File

@@ -0,0 +1,58 @@
import indexOfMatch from "./index-of-match.mjs";
import indexOfMatchEnd from "./index-of-match-end.mjs";
import countSubstring from "./count-substring.mjs";
export default function findTagByName(xml, tagName, options) {
const debug = (options && options.debug) || false;
const nested = !(options && typeof options.nested === false);
const startIndex = (options && options.startIndex) || 0;
if (debug) console.log("[xml-utils] starting findTagByName with", tagName, " and ", options);
const start = indexOfMatch(xml, `\<${tagName}[ \n\>\/]`, startIndex);
if (debug) console.log("[xml-utils] start:", start);
if (start === -1) return undefined;
const afterStart = xml.slice(start + tagName.length);
let relativeEnd = indexOfMatchEnd(afterStart, "^[^<]*[ /]>", 0);
const selfClosing = relativeEnd !== -1 && afterStart[relativeEnd - 1] === "/";
if (debug) console.log("[xml-utils] selfClosing:", selfClosing);
if (selfClosing === false) {
// check if tag has subtags with the same name
if (nested) {
let startIndex = 0;
let openings = 1;
let closings = 0;
while ((relativeEnd = indexOfMatchEnd(afterStart, "[ /]" + tagName + ">", startIndex)) !== -1) {
const clip = afterStart.substring(startIndex, relativeEnd + 1);
openings += countSubstring(clip, "<" + tagName + "[ \n\t>]");
closings += countSubstring(clip, "</" + tagName + ">");
// we can't have more openings than closings
if (closings >= openings) break;
startIndex = relativeEnd;
}
} else {
relativeEnd = indexOfMatchEnd(afterStart, "[ /]" + tagName + ">", 0);
}
}
const end = start + tagName.length + relativeEnd + 1;
if (debug) console.log("[xml-utils] end:", end);
if (end === -1) return undefined;
const outer = xml.slice(start, end);
// tag is like <gml:identifier codeSpace="OGP">urn:ogc:def:crs:EPSG::32617</gml:identifier>
let inner;
if (selfClosing) {
inner = null;
} else {
inner = outer.slice(outer.indexOf(">") + 1, outer.lastIndexOf("<"));
}
return { inner, outer, start, end };
}

10
node_modules/xml-utils/find-tag-by-path.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
const findTagsByPath = require("./find-tags-by-path.js");
function findTagByPath(xml, path, options) {
const debug = (options && options.debug) || false;
const found = findTagsByPath(xml, path, { debug, returnOnFirst: true });
if (Array.isArray(found) && found.length === 1) return found[0];
else return undefined;
}
module.exports = findTagByPath;
module.exports.default = findTagByPath;

8
node_modules/xml-utils/find-tag-by-path.mjs generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import findTagsByPath from "./find-tags-by-path.mjs";
export default function findTagByPath(xml, path, options) {
const debug = (options && options.debug) || false;
const found = findTagsByPath(xml, path, { debug, returnOnFirst: true });
if (Array.isArray(found) && found.length === 1) return found[0];
else return undefined;
}

22
node_modules/xml-utils/find-tags-by-name.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
const findTagByName = require("./find-tag-by-name.js");
function findTagsByName(xml, tagName, options) {
const tags = [];
const debug = (options && options.debug) || false;
const nested = options && typeof options.nested === "boolean" ? options.nested : true;
let startIndex = (options && options.startIndex) || 0;
let tag;
while ((tag = findTagByName(xml, tagName, { debug, startIndex }))) {
if (nested) {
startIndex = tag.start + 1 + tagName.length;
} else {
startIndex = tag.end;
}
tags.push(tag);
}
if (debug) console.log("findTagsByName found", tags.length, "tags");
return tags;
}
module.exports = findTagsByName;
module.exports.default = findTagsByName;

19
node_modules/xml-utils/find-tags-by-name.mjs generated vendored Normal file
View File

@@ -0,0 +1,19 @@
import findTagByName from "./find-tag-by-name.mjs";
export default function findTagsByName(xml, tagName, options) {
const tags = [];
const debug = (options && options.debug) || false;
const nested = options && typeof options.nested === "boolean" ? options.nested : true;
let startIndex = (options && options.startIndex) || 0;
let tag;
while ((tag = findTagByName(xml, tagName, { debug, startIndex }))) {
if (nested) {
startIndex = tag.start + 1 + tagName.length;
} else {
startIndex = tag.end;
}
tags.push(tag);
}
if (debug) console.log("findTagsByName found", tags.length, "tags");
return tags;
}

56
node_modules/xml-utils/find-tags-by-path.js generated vendored Normal file
View File

@@ -0,0 +1,56 @@
const findTagsByName = require("./find-tags-by-name.js");
function findTagsByPath(xml, path, options) {
const debug = (options && options.debug) || false;
if (debug) console.log("[xml-utils] starting findTagsByPath with: ", xml.substring(0, 500));
const returnOnFirst = (options && options.returnOnFirst) || false;
if (Array.isArray(path) === false) throw new Error("[xml-utils] path should be an array");
const path0 = typeof path[0] === "string" ? { name: path[0] } : path[0];
let tags = findTagsByName(xml, path0.name, { debug, nested: false });
if (typeof tags !== "undefined" && typeof path0.index === "number") {
if (typeof tags[path0.index] === "undefined") {
tags = [];
} else {
tags = [tags[path0.index]];
}
}
if (debug) console.log("first tags are:", tags);
path = path.slice(1);
for (let pathIndex = 0; pathIndex < path.length; pathIndex++) {
const part = typeof path[pathIndex] === "string" ? { name: path[pathIndex] } : path[pathIndex];
if (debug) console.log("part.name:", part.name);
let allSubTags = [];
for (let tagIndex = 0; tagIndex < tags.length; tagIndex++) {
const tag = tags[tagIndex];
const subTags = findTagsByName(tag.outer, part.name, {
debug,
startIndex: 1
});
if (debug) console.log("subTags.length:", subTags.length);
if (subTags.length > 0) {
subTags.forEach(subTag => {
(subTag.start += tag.start), (subTag.end += tag.start);
});
if (returnOnFirst && pathIndex === path.length - 1) return [subTags[0]];
allSubTags = allSubTags.concat(subTags);
}
}
tags = allSubTags;
if (typeof part.index === "number") {
if (typeof tags[part.index] === "undefined") {
tags = [];
} else {
tags = [tags[part.index]];
}
}
}
return tags;
}
module.exports = findTagsByPath;
module.exports.default = findTagsByPath;

53
node_modules/xml-utils/find-tags-by-path.mjs generated vendored Normal file
View File

@@ -0,0 +1,53 @@
import findTagsByName from "./find-tags-by-name.mjs";
export default function findTagsByPath(xml, path, options) {
const debug = (options && options.debug) || false;
if (debug) console.log("[xml-utils] starting findTagsByPath with: ", xml.substring(0, 500));
const returnOnFirst = (options && options.returnOnFirst) || false;
if (Array.isArray(path) === false) throw new Error("[xml-utils] path should be an array");
const path0 = typeof path[0] === "string" ? { name: path[0] } : path[0];
let tags = findTagsByName(xml, path0.name, { debug, nested: false });
if (typeof tags !== "undefined" && typeof path0.index === "number") {
if (typeof tags[path0.index] === "undefined") {
tags = [];
} else {
tags = [tags[path0.index]];
}
}
if (debug) console.log("first tags are:", tags);
path = path.slice(1);
for (let pathIndex = 0; pathIndex < path.length; pathIndex++) {
const part = typeof path[pathIndex] === "string" ? { name: path[pathIndex] } : path[pathIndex];
if (debug) console.log("part.name:", part.name);
let allSubTags = [];
for (let tagIndex = 0; tagIndex < tags.length; tagIndex++) {
const tag = tags[tagIndex];
const subTags = findTagsByName(tag.outer, part.name, {
debug,
startIndex: 1
});
if (debug) console.log("subTags.length:", subTags.length);
if (subTags.length > 0) {
subTags.forEach(subTag => {
(subTag.start += tag.start), (subTag.end += tag.start);
});
if (returnOnFirst && pathIndex === path.length - 1) return [subTags[0]];
allSubTags = allSubTags.concat(subTags);
}
}
tags = allSubTags;
if (typeof part.index === "number") {
if (typeof tags[part.index] === "undefined") {
tags = [];
} else {
tags = [tags[part.index]];
}
}
}
return tags;
}

24
node_modules/xml-utils/get-attribute.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
function getAttribute(tag, attributeName, options) {
const debug = (options && options.debug) || false;
if (debug) console.log("[xml-utils] getting " + attributeName + " in " + tag);
const xml = typeof tag === "object" ? tag.outer : tag;
// only search for attributes in the opening tag
const opening = xml.slice(0, xml.indexOf(">") + 1);
const quotechars = ['"', "'"];
for (let i = 0; i < quotechars.length; i++) {
const char = quotechars[i];
const pattern = attributeName + "\\=" + char + "([^" + char + "]*)" + char;
if (debug) console.log("[xml-utils] pattern:", pattern);
const re = new RegExp(pattern);
const match = re.exec(opening);
if (debug) console.log("[xml-utils] match:", match);
if (match) return match[1];
}
}
module.exports = getAttribute;
module.exports.default = getAttribute;

21
node_modules/xml-utils/get-attribute.mjs generated vendored Normal file
View File

@@ -0,0 +1,21 @@
export default function getAttribute(tag, attributeName, options) {
const debug = (options && options.debug) || false;
if (debug) console.log("[xml-utils] getting " + attributeName + " in " + tag);
const xml = typeof tag === "object" ? tag.outer : tag;
// only search for attributes in the opening tag
const opening = xml.slice(0, xml.indexOf(">") + 1);
const quotechars = ['"', "'"];
for (let i = 0; i < quotechars.length; i++) {
const char = quotechars[i];
const pattern = attributeName + "\\=" + char + "([^" + char + "]*)" + char;
if (debug) console.log("[xml-utils] pattern:", pattern);
const re = new RegExp(pattern);
const match = re.exec(opening);
if (debug) console.log("[xml-utils] match:", match);
if (match) return match[1];
}
}

9
node_modules/xml-utils/index-of-match-end.js generated vendored Normal file
View File

@@ -0,0 +1,9 @@
function indexOfMatchEnd(xml, pattern, startIndex) {
const re = new RegExp(pattern);
const match = re.exec(xml.slice(startIndex));
if (match) return startIndex + match.index + match[0].length - 1;
else return -1;
}
module.exports = indexOfMatchEnd;
module.exports.default = indexOfMatchEnd;

6
node_modules/xml-utils/index-of-match-end.mjs generated vendored Normal file
View File

@@ -0,0 +1,6 @@
export default function indexOfMatchEnd(xml, pattern, startIndex) {
const re = new RegExp(pattern);
const match = re.exec(xml.slice(startIndex));
if (match) return startIndex + match.index + match[0].length - 1;
else return -1;
}

9
node_modules/xml-utils/index-of-match.js generated vendored Normal file
View File

@@ -0,0 +1,9 @@
function indexOfMatch(xml, pattern, startIndex) {
const re = new RegExp(pattern);
const match = re.exec(xml.slice(startIndex));
if (match) return startIndex + match.index;
else return -1;
}
module.exports = indexOfMatch;
module.exports.default = indexOfMatch;

6
node_modules/xml-utils/index-of-match.mjs generated vendored Normal file
View File

@@ -0,0 +1,6 @@
export default function indexOfMatch(xml, pattern, startIndex) {
const re = new RegExp(pattern);
const match = re.exec(xml.slice(startIndex));
if (match) return startIndex + match.index;
else return -1;
}

31
node_modules/xml-utils/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,31 @@
export type Tag = { inner: null | string, outer: string };
export type Step = { name: string, index?: number | undefined | null };
export type Path = Array<string | Step> | ReadonlyArray<string | Step>;
export function findTagByName(
xml: string,
tagName: string,
options?: { debug?: boolean, nested?: boolean, startIndex?: number }
): Tag | undefined;
export function findTagsByName(
xml: string,
tagName: string,
options?: { debug?: boolean, nested?: boolean, startIndex?: boolean }
): Tag[];
export function findTagsByPath(
xml: string,
path: Path,
options?: { debug?: boolean, returnOnFirst?: boolean }
): Tag[];
export function findTagByPath(
xml: string,
path: Path,
options?: { debug?: boolean }
): Tag | undefined;
export function getAttribute(tag: string | Tag, attributeName: string, options?: { debug?: boolean } ): string;
export function removeTagsByName(xml: string, tagName: string, options?: { debug?: boolean }): string;

17
node_modules/xml-utils/index.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
const getAttribute = require("./get-attribute.js");
const findTagByName = require("./find-tag-by-name.js");
const findTagsByName = require("./find-tags-by-name.js");
const findTagByPath = require("./find-tag-by-path.js");
const findTagsByPath = require("./find-tags-by-path.js");
const removeComments = require("./remove-comments.js");
const removeTagsByName = require("./remove-tags-by-name.js");
module.exports = {
getAttribute,
findTagByName,
findTagsByName,
findTagByPath,
findTagsByPath,
removeComments,
removeTagsByName
};

6
node_modules/xml-utils/index.mjs generated vendored Normal file
View File

@@ -0,0 +1,6 @@
export { default as getAttribute } from "./get-attribute.mjs";
export { default as findTagByName } from "./find-tag-by-name.mjs";
export { default as findTagsByName } from "./find-tags-by-name.mjs";
export { default as findTagByPath } from "./find-tag-by-path.mjs";
export { default as findTagsByPath } from "./find-tags-by-path.mjs";
export { default as removeComments } from "./remove-comments.mjs";

99
node_modules/xml-utils/package.json generated vendored Normal file
View File

@@ -0,0 +1,99 @@
{
"name": "xml-utils",
"version": "1.10.1",
"description": "Parse XML without Blowing Up Your Bundle Size",
"main": "index.js",
"module": "index.mjs",
"types": "index.d.ts",
"exports": {
".": {
"require": "./index.js",
"import": "./index.mjs"
},
"./index": {
"require": "./index.js",
"import": "./index.mjs"
},
"./index.js": "./index.js",
"./index.mjs": "./index.mjs",
"./find-tag-by-name": "./find-tag-by-name.js",
"./find-tag-by-name.js": "./find-tag-by-name.js",
"./find-tag-by-name.mjs": "./find-tag-by-name.mjs",
"./find-tag-by-path": "./find-tag-by-path.js",
"./find-tag-by-path.js": "./find-tag-by-path.js",
"./find-tag-by-path.mjs": "./find-tag-by-path.mjs",
"./find-tags-by-name": "./find-tags-by-name.js",
"./find-tags-by-name.js": "./find-tags-by-name.js",
"./find-tags-by-name.mjs": "./find-tags-by-name.mjs",
"./find-tags-by-path": "./find-tags-by-path.js",
"./find-tags-by-path.js": "./find-tags-by-path.js",
"./find-tags-by-path.mjs": "./find-tags-by-path.mjs",
"./get-attribute": "./get-attribute.js",
"./get-attribute.js": "./get-attribute.js",
"./get-attribute.mjs": "./get-attribute.mjs",
"./remove-comments": "./remove-comments.js",
"./remove-comments.js": "./remove-comments.js",
"./remove-comments.mjs": "./remove-comments.mjs",
"./remove-tags-by-name": "./remove-tags-by-name",
"./remove-tags-by-name.js": "./remove-tags-by-name.js",
"./remove-tags-by-name.mjs": "./remove-tags-by-name.mjs"
},
"files": [
"index.d.ts",
"index.js",
"index.mjs",
"count-substring.js",
"find-tag-by-name.js",
"find-tag-by-path.js",
"find-tags-by-name.js",
"find-tags-by-path.js",
"get-attribute.js",
"index-of-match.js",
"index-of-match-end.js",
"remove-comments.js",
"remove-tags-by-name.js",
"count-substring.mjs",
"find-tag-by-name.mjs",
"find-tag-by-path.mjs",
"find-tags-by-name.mjs",
"find-tags-by-path.mjs",
"get-attribute.mjs",
"index-of-match.mjs",
"index-of-match-end.mjs",
"remove-comments.mjs",
"remove-tags-by-name.mjs"
],
"scripts": {
"f": "npm run format",
"format": "npx prettier --arrow-parens=avoid --print-width=140 --trailing-comma=none --write *.js *.mjs */*.js */*.mjs */*.ts",
"setup": "cd test/data && bash setup.sh",
"test": "npm run test:js && npm run test:ts && npm run test:tsc && npm run test:esm",
"test:js": "node ./test/test.js",
"test:esm": "node ./test/test.mjs",
"test:ts": "npx ts-node ./test/test.ts",
"test:tsc": "tsc --noEmit ./test/test.ts"
},
"repository": {
"type": "git",
"url": "git+https://github.com/DanielJDufour/xml-utils.git"
},
"keywords": [
"fast",
"mrf",
"xml",
"tag",
"lite",
"utils",
"parse"
],
"author": "Daniel J. Dufour",
"license": "CC0-1.0",
"bugs": {
"url": "https://github.com/DanielJDufour/xml-utils/issues"
},
"homepage": "https://github.com/DanielJDufour/xml-utils#readme",
"devDependencies": {
"flug": "^2.7.2",
"typescript": "^5.4.2"
}
}

6
node_modules/xml-utils/remove-comments.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
function removeComments(xml) {
return xml.replace(/<!--[^]*-->/g, "");
}
module.exports = removeComments;
module.exports.default = removeComments;

3
node_modules/xml-utils/remove-comments.mjs generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export default function removeComments(xml) {
return xml.replace(/<!--[^]*-->/g, "");
}

14
node_modules/xml-utils/remove-tags-by-name.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
const findTagByName = require("./find-tag-by-name.js");
function removeTagsByName(xml, tagName, options) {
const debug = (options && options.debug) || false;
let tag;
while ((tag = findTagByName(xml, tagName, { debug }))) {
xml = xml.substring(0, tag.start) + xml.substring(tag.end);
if (debug) console.log("[xml-utils] removed:", tag);
}
return xml;
}
module.exports = removeTagsByName;
module.exports.default = removeTagsByName;

11
node_modules/xml-utils/remove-tags-by-name.mjs generated vendored Normal file
View File

@@ -0,0 +1,11 @@
import findTagByName from "./find-tag-by-name.mjs";
export default function removeTagsByName(xml, tagName, options) {
const debug = (options && options.debug) || false;
let tag;
while ((tag = findTagByName(xml, tagName, { debug }))) {
xml = xml.substring(0, tag.start) + xml.substring(tag.end);
if (debug) console.log("[xml-utils] removed:", tag);
}
return xml;
}