GPR authentication support

This commit is contained in:
Alex Mullans
2019-09-09 10:27:23 -07:00
committed by Alex Mullans
parent 6c0e2a2a6b
commit 6bd4969ec6
518 changed files with 95599 additions and 2875 deletions

1
node_modules/fast-xml-parser/BACKERS.md generated vendored Normal file
View File

@ -0,0 +1 @@

274
node_modules/fast-xml-parser/CHANGELOG.md generated vendored Normal file
View File

@ -0,0 +1,274 @@
3.12.20 / 2019-08-16
* Revert: Fix #167: '>' in attribute value as it is causing high performance degrade.
3.12.19 / 2019-07-28
* Fix js to xml parser should work for date values. (broken: `tagValueProcessor` will receive the original value instead of string always) (breaking change)
3.12.18 / 2019-07-27
* remove configstore dependency
3.12.17 / 2019-07-14
* Fix #167: '>' in attribute value
3.12.16 / 2019-03-23
* Support a new option "stopNodes". (#150)
Accept the list of tags which are not required to be parsed. Instead, all the nested tag and data will be assigned as string.
* Don't show post-install message
3.12.12 / 2019-01-11
* fix : IE parseInt, parseFloat error
3.12.11 / 2018-12-24
* fix #132: "/" should not be parsed as boolean attr in case of self closing tags
3.12.9 / 2018-11-23
* fix #129 : validator should not fail when an atrribute name is 'length'
3.12.8 / 2018-11-22
* fix #128 : use 'attrValueProcessor' to process attribute value in json2xml parser
3.12.6 / 2018-11-10
* Fix #126: check for type
3.12.4 / 2018-09-12
* Fix: include tasks in npm package
3.12.3 / 2018-09-12
* Fix CLI issue raised in last PR
3.12.2 / 2018-09-11
* Fix formatting for JSON to XML output
* Migrate to webpack (PR merged)
* fix cli (PR merged)
3.12.0 / 2018-08-06
* Support hexadecimal values
* Support true number parsing
3.11.2 / 2018-07-23
* Update Demo for more options
* Update license information
* Update readme for formatting, users, and spelling mistakes
* Add missing typescript definition for j2xParser
* refactoring: change filenames
3.11.1 / 2018-06-05
* fix #93: read the text after self closing tag
3.11.0 / 2018-05-20
* return defaultOptions if there are not options in buildOptions function
* added localeRange declaration in parser.d.ts
* Added support of cyrillic characters in validator XML
* fixed bug in validator work when XML data with byte order marker
3.10.0 / 2018-05-13
* Added support of cyrillic characters in parsing XML to JSON
3.9.11 / 2018-05-09
* fix https://github.com/NaturalIntelligence/fast-xml-parser/issues/80 fix nimn chars
* update package information
* fix https://github.com/NaturalIntelligence/fast-xml-parser/issues/86: json 2 xml parser : property with null value should be parsed to self closing tag.
* update online demo
* revert zombiejs to old version to support old version of node
* update dependencies
3.3.10 / 2018-04-23
* fix #77 : parse even if closing tag has space before '>'
* include all css & js lib in demo app
* remove babel dependencies until needed
3.3.9 / 2018-04-18
* fix #74 : TS2314 TypeScript compiler error
3.3.8 / 2018-04-17
* fix #73 : IE doesn't support Object.assign
3.3.7 / 2018-04-14
* fix: use let insted of const in for loop of validator
* Merge pull request
https://github.com/NaturalIntelligence/fast-xml-parser/issues/71 from bb/master
first draft of typings for typescript
https://github.com/NaturalIntelligence/fast-xml-parser/issues/69
* Merge pull request
https://github.com/NaturalIntelligence/fast-xml-parser/issues/70 from bb/patch-1
fix some typos in readme
3.3.6 / 2018-03-21
* change arrow functions to full notation for IE compatibility
3.3.5 / 2018-03-15
* fix https://github.com/NaturalIntelligence/fast-xml-parser/issues/67 : attrNodeName invalid behavior
* fix: remove decodeHTML char condition
3.3.4 / 2018-03-14
* remove dependency on "he" package
* refactor code to separate methods in separate files.
* draft code for transforming XML to json string. It is not officially documented due to performance issue.
3.3.0 / 2018-03-05
* use common default options for XML parsing for consistency. And add `parseToNimn` method.
* update nexttodo
* update README about XML to Nimn transformation and remove special notes about 3.x release
* update CONTRIBUTING.ms mentioning nexttodo
* add negative case for XML PIs
* validate xml processing instruction tags https://github.com/NaturalIntelligence/fast-xml-parser/issues/62
* nimndata: handle array with object
* nimndata: node with nested node and text node
* nimndata: handle attributes and text node
* nimndata: add options, handle array
* add xml to nimn data converter
* x2j: direct access property with tagname
* update changelog
* fix validator when single quote presents in value enclosed with double quotes or vice versa
* Revert "remove unneded nimnjs dependency, move opencollective to devDependencies and replace it
with more light opencollective-postinstall"
This reverts commit d47aa7181075d82db4fee97fd8ea32b056fe3f46.
* Merge pull request: https://github.com/NaturalIntelligence/fast-xml-parser/issues/63 from HaroldPutman/suppress-undefined
Keep undefined nodes out of the XML output : This is useful when you are deleting nodes from the JSON and rewriting XML.
3.2.4 / 2018-03-01
* fix #59 fix in validator when open quote presents in attribute value
* Create nexttodo.md
* exclude static from bitHound tests
* add package lock
3.2.3 / 2018-02-28
* Merge pull request from Delagen/master: fix namespaces can contain the same characters as xml names
3.2.2 / 2018-02-22
* fix: attribute xmlns should not be removed if ignoreNameSpace is false
* create CONTRIBUTING.md
3.2.1 / 2018-02-17
* fix: empty attribute should be parsed
3.2.0 / 2018-02-16
* Merge pull request : Dev to Master
* Update README and version
* j2x:add performance test
* j2x: Remove extra empty line before closing tag
* j2x: suppress empty nodes to self closing node if configured
* j2x: provide option to give indentation depth
* j2x: make optional formatting
* j2x: encodeHTMLchat
* j2x: handle cdata tag
* j2x: handle grouped attributes
* convert json to xml
- nested object
- array
- attributes
- text value
* small refactoring
* Merge pull request: Update cli.js to let user validate XML file or data
* Add option for rendering CDATA as separate property
3.0.1 / 2018-02-09
* fix CRLF: replace it with single space in attributes value only.
3.0.0 / 2018-02-08
* change online tool with new changes
* update info about new options
* separate tag value processing to separate function
* make HTML decoding optional
* give an option to allow boolean attributes
* change cli options as per v3
* Correct comparison table format on README
* update v3 information
* some performance improvement changes
* Make regex object local to the method and move some common methods to util
* Change parser to
- handle multiple instances of CDATA
- make triming of value optionals
- HTML decode attribute and text value
- refactor code to separate files
* Ignore newline chars without RE (in validator)
* validate for XML prolog
* Validate DOCTYPE without RE
* Update validator to return error response
* Update README to add detail about V3
* Separate xmlNode model class
* include vscode debug config
* fix for repeated object
* fix attribute regex for boolean attributes
* Fix validator for invalid attributes
2.9.4 / 2018-02-02
* Merge pull request: Decode HTML characters
* refactor source folder name
* ignore bundle / browser js to be published to npm
2.9.3 / 2018-01-26
* Merge pull request: Correctly remove CRLF line breaks
* Enable to parse attribute in online editor
* Fix testing demo app test
* Describe parsing options
* Add options for online demo
2.9.2 / 2018-01-18
* Remove check if tag starting with "XML"
* Fix: when there are spaces before / after CDATA
2.9.1 / 2018-01-16
* Fix: newline should be replaced with single space
* Fix: for single and multiline comments
* validate xml with CDATA
* Fix: the issue when there is no space between 2 attributes
* Fix: https://github.com/NaturalIntelligence/fast-xml-parser/issues/33: when there is newline char in attr val, it doesn't parse
* Merge pull request: fix ignoreNamespace
* fix: don't wrap attributes if only namespace attrs
* fix: use portfinder for run tests, update deps
* fix: don't treat namespaces as attributes when ignoreNamespace enabled
2.9.0 / 2018-01-10
* Rewrite the validator to handle large files.
Ignore DOCTYPE validation.
* Fix: When attribute value has equal sign
2.8.3 / 2017-12-15
* Fix: when a tag has value along with subtags
2.8.2 / 2017-12-04
* Fix value parsing for IE
2.8.1 / 2017-12-01
* fix: validator should return false instead of err when invalid XML
2.8.0 / 2017-11-29
* Add CLI option to ignore value conversion
* Fix variable name when filename is given on CLI
* Update CLI help text
* Merge pull request: xml2js: Accept standard input
* Test Node 8
* Update dependencies
* Bundle readToEnd
* Add ability to read from standard input
2.7.4 / 2017-09-22
* Merge pull request: Allow wrap attributes with subobject to compatible with other parsers output
2.7.3 / 2017-08-02
* fix: handle CDATA with regx
2.7.2 / 2017-07-30
* Change travis config for yarn caching
* fix validator: when tag property is same as array property
* Merge pull request: Failing test case in validator for valid SVG
2.7.1 / 2017-07-26
* Fix: Handle val 0
2.7.0 / 2017-07-25
* Fix test for arrayMode
* Merge pull request: Add arrayMode option to parse any nodes as arrays
2.6.0 / 2017-07-14
* code improvement
* Add unit tests for value conversion for attr
* Merge pull request: option of an attribute value conversion to a number (textAttrConversion) the same way as the textNodeConversion option does. Default value is false.
2.5.1 / 2017-07-01
* Fix XML element name pattern
* Fix XML element name pattern while parsing
* Fix validation for xml tag element
2.5.0 / 2017-06-25
* Improve Validator performance
* update attr matching regex
* Add perf tests
* Improve atrr regex to handle all cases
2.4.4 / 2017-06-08
* Bug fix: when an attribute has single or double quote in value
2.4.3 / 2017-06-05
* Bug fix: when multiple CDATA tags are given
* Merge pull request: add option "textNodeConversion"
* add option "textNodeConversion"
2.4.1 / 2017-04-14
* fix tests
* Bug fix: preserve initial space of node value
* Handle CDATA
2.3.1 / 2017-03-15
* Bug fix: when single self closing tag
* Merge pull request: fix .codeclimate.yml
* Update .codeclimate.yml - Fixed config so it does not error anymore.
* Update .codeclimate.yml
2.3.0 / 2017-02-26
* Code improvement
* add bithound config
* Update usage
* Update travis to generate bundle js before running tests
* 1.Browserify, 2. add more tests for validator
* Add validator
* Fix CLI default parameter bug
2.2.1 / 2017-02-05
* Bug fix: CLI default option

46
node_modules/fast-xml-parser/CONTRIBUTING.md generated vendored Normal file
View File

@ -0,0 +1,46 @@
# Thanks
I would like to thank you for your valuable time and effort and applogies if this PR is rejected due to any reason.
This repository is written with the aim of providing high performance not in terms of speed only but comfortability of the user as well.
If your change is not a bug fix please check **nexttodo.md** before implementing any new feature.
## No rights are resserved
Your contribution is valuable. We try to mention your name on README with the avatar. We can't promise to pay you for your contribution.
### DoD
Here is the check list to publish any change
* Changes are not half implemented due to the library limitation or any other reason.
* Changes are well discussed by raising github issue. So they are well known by other contributers and users
* Echoing the above point. The purpose / goal for the PR should be mentioned in the description.
* Multiple unrelated changes should not be clubbed in single PR.
* Please run perf tests `node benchmark\perfTest3.js` before and after the changes. And mention it in PR description.
* If you are adding any dependency (specially if it is not the dev dependency) please check that
* it is not dependent on other language packages like c/c++
* the package is not very old, very new, discontinued, or has any vulnerability etc.
* please check the performance and size of package
* please check alternate available options
* Please write tests for the new changes
* Don't forget to write tests for negative cases
* Don't comment existing test case.
Changes need to do be done by owner
* Increase the version number
* Update the change log & README if required
* Generate the browser bundle
* Release in github and publish to npm
Note that publishing changes or accepting any PR may take time. So please keep patience.
### Guidelines for first time contributors
* https://github.com/Roshanjossey/first-contributions
* **Don't stretch**. If you complete an issue in long time, there is a possibility that other developers finish their part and you face code conflicts which may increase code complexity for you. So it is always good to complete an issue ASAP.
* Please refrain to work on multiple issues marked with "first-timers-only" in the same repo. Ask and help your friends and colleagues to attempt rest issues.
* Please claim the issue and clear your doubts before raising PR. So other users will not start working on the same issue.
* Mention the issue number either in PR detail or in commit message.
* Keep increasing the level of challenge.
* Don't hesitate to question on github issue or on twitter.

23
node_modules/fast-xml-parser/LICENSE generated vendored Normal file
View File

@ -0,0 +1,23 @@
MIT License
Copyright (c) 2017 Amit Kumar Gupta
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
If you use this library in a public repository then you give us the right to mention your company name and logo in user's list without further permission required, but you can request them to be taken down within 30 days.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

317
node_modules/fast-xml-parser/README.md generated vendored Normal file
View File

@ -0,0 +1,317 @@
# [fast-xml-parser](https://www.npmjs.com/package/fast-xml-parser)
Validate XML, Parse XML to JS/JSON and vice versa, or parse XML to Nimn rapidly without C/C++ based libraries and no callback
> This project welcomes **contributors**. If you have a feature you'd like to see implemented or a bug you'd liked fixed, the best and fastest way to make that happen is to implement it and submit a PR. Basic knowledge of JS is sufficient. Feel free to ask for any guidance.
## Users
List of some applications/projects using Fast XML Parser. (Raise an issue to submit yours)
<a href="https://github.com/NaturalIntelligence/imglab" title="imglab" ><img src="https://github.com/NaturalIntelligence/imglab/blob/master/img/imglab_logo.png?raw=true" width="80px" ></a>
<a href="https://github.com/NaturalIntelligence/Stubmatic" title="stubmatic" ><img src="https://camo.githubusercontent.com/ff711425dc2286cd215637b7114eb43e571f001d/68747470733a2f2f6e61747572616c696e74656c6c6967656e63652e6769746875622e696f2f537475626d617469632f696d672f737475626d617469635f6c6f676f2e706e673f7261773d74727565" width="80px" ></a>
<a href="https://github.com/muneem4node/muneem" title="Muneem" ><img src="https://github.com/muneem4node/muneem/raw/master/static/muneem.png?raw=true" width="80px" ></a>
<a href="https://github.com/badges/shields" title="shields" ><img src="https://avatars2.githubusercontent.com/u/6254238" width="80px" ></a>
<a href="https://github.com/renovatebot/renovate" title="renovate" ><img src="https://avatars1.githubusercontent.com/u/38656520" width="80px" ></a>
<a href="https://vmware.com/" title="vmware" > <img src="https://avatars0.githubusercontent.com/u/473334" width="80px" ></a>
<a href="https://opensource.microsoft.com/" title="microsoft" > <img src="https://avatars0.githubusercontent.com/u/6154722" width="80px" ></a>
<a href="https://github.com/notable/notable" title="notable" > <img src="https://avatars3.githubusercontent.com/u/46467536" width="80px" ></a>
<a href="http://ibm.github.io/" title="IBM" > <img src="https://avatars2.githubusercontent.com/u/1459110" width="80px" ></a>
<a href="https://www.ft.com/" title="Financial Times" > <img src="https://avatars2.githubusercontent.com/u/3502508" width="80px" ></a>
<a href="https://github.com/camunda" title="camunda BPM" > <img src="https://avatars3.githubusercontent.com/u/2443838" width="80px" ></a>
<a href="https://github.com/AnyChart" title="AnyChart" > <img src="https://avatars0.githubusercontent.com/u/703373" width="80px" ></a>
<a href="https://github.com/magda-io" title="magda-io" > <img src="https://avatars0.githubusercontent.com/u/40348684" width="80px" ></a>
<a href="https://github.com/geistinteractive" title="Geist Interactive" > <img src="https://avatars0.githubusercontent.com/u/11617965" width="80px" ></a>
<a href="https://www.tourstream.eu/" title="tourstream" > <img src="https://avatars1.githubusercontent.com/u/23242088" width="80px" ></a>
<a href="https://www.atomist.com/" title="Atomist" > <img src="https://avatars3.githubusercontent.com/u/19392" width="80px" ></a>
<a href="http://www.opuscapita.com/" title="OpusCapita" > <img src="https://avatars1.githubusercontent.com/u/23256480" width="80px" ></a>
<a href="https://nevatrip.ru/" title="nevatrip" > <img src="https://avatars2.githubusercontent.com/u/35730984" width="80px" ></a>
<a href="http://eosnavigator.com/" title="nevatrip" > <img src="https://avatars1.githubusercontent.com/u/40260563" width="80px" ></a>
<a href="http://pds.nasa.gov/" title="NASA-PDS" > <img src="https://avatars2.githubusercontent.com/u/26313833" width="80px" ></a>
<a href="http://qgis.org/" title="QGIS" > <img src="https://avatars2.githubusercontent.com/u/483444" width="80px" ></a>
<a href="http://www.craft.ai/" title="craft ai" > <img src="https://avatars1.githubusercontent.com/u/12046764" width="80px" ></a>
<a href="http://brownspace.org/" title="Brown Space Engineering" > <img src="https://avatars2.githubusercontent.com/u/5504507" width="80px" ></a>
<a href="http://www.appcelerator.com/" title="Team Appcelerator" > <img src="https://avatars1.githubusercontent.com/u/82188" width="80px" ></a>
<a href="http://orange-opensource.github.io/" title="Open Source by Orange" > <img src="https://avatars3.githubusercontent.com/u/1506386" width="80px" ></a>
<a href="http://www.ybrain.com/" title="YBRAIN Inc." > <img src="https://avatars2.githubusercontent.com/u/38232440" width="80px" ></a>
<a href="http://99bitcoins.com/" title="99 bitcoins" > <img src="https://avatars0.githubusercontent.com/u/9527779" width="80px" ></a>
<a href="https://opendatakit.org" title="Open Data Kit" > <img src="https://avatars0.githubusercontent.com/u/6222985" width="80px" ></a>
<a href="https://ridibooks.com" title="RIDI Books" > <img src="https://avatars1.githubusercontent.com/u/24955411" width="80px" ></a>
<a href="http://signalk.org" title="Signal K" > <img src="https://avatars1.githubusercontent.com/u/7126740" width="80px" ></a>
<a href="http://brain.js.org/" title="brain.js" > <img src="https://avatars2.githubusercontent.com/u/23732838" width="80px" ></a>
<a href="https://skygear.io/" title="Skegear" > <img src="https://avatars1.githubusercontent.com/u/15025887" width="80px" ></a>
<a href=" https://www.mindpointgroup.com" title="mindpointgroup" > <img src="https://avatars1.githubusercontent.com/u/6413533" width="80px" ></a>
<a href="http://www.acuantcorp.com/" title="Acuant Inc" > <img src="https://avatars3.githubusercontent.com/u/11580319?s=200&v=4" width="80px" ></a>
<a href="https://www.wazuh.com/" title="wazuh" > <img src="https://avatars2.githubusercontent.com/u/13752566" width="80px" ></a>
<a href="https://orbs.com/" title="ORBS The Hybrid Blockchain" > <img src="https://avatars1.githubusercontent.com/u/33665977" width="80px" ></a>
<a href="https://texlab.netlify.com/" title="latex-lsp" > <img src="https://avatars1.githubusercontent.com/u/48360002" width="80px" ></a>
<a href="https://frontside.io/" title="The Frontside " > <img src="https://avatars1.githubusercontent.com/u/223096" width="80px" ></a>
<a href="https://www.hustunique.com/" title="UniqueStudio" > <img src="https://avatars1.githubusercontent.com/u/4847684" width="80px" ></a>
<a href="http://www.openforis.org/" title="Open Foris" > <img src="https://avatars2.githubusercontent.com/u/1212750" width="80px" ></a>
<a href="#" title="NHS Connect" > <img src="https://avatars3.githubusercontent.com/u/20316669" width="80px" ></a>
<a href="https://tradle.io/" title="Tradle" > <img src="https://avatars2.githubusercontent.com/u/9482126" width="80px" ></a>
<a href="http://www.anl.gov/" title="Argonne National Laboratory" > <img src="https://avatars0.githubusercontent.com/u/10468712" width="80px" ></a>
<a href="https://simpleicons.org/" title="Simple Icons" > <img src="https://avatars2.githubusercontent.com/u/29872746" width="80px" ></a>
### Join this project as collaborator / maintainer.
[![Backers on Open Collective](https://opencollective.com/fast-xml-parser/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/fast-xml-parser/sponsors/badge.svg)](#sponsors) [![Known Vulnerabilities](https://snyk.io/test/github/naturalintelligence/fast-xml-parser/badge.svg)](https://snyk.io/test/github/naturalintelligence/fast-xml-parser)
[![NPM quality][quality-image]][quality-url]
[![Travis ci Build Status](https://travis-ci.org/NaturalIntelligence/fast-xml-parser.svg?branch=master)](https://travis-ci.org/NaturalIntelligence/fast-xml-parser)
[![Coverage Status](https://coveralls.io/repos/github/NaturalIntelligence/fast-xml-parser/badge.svg?branch=master)](https://coveralls.io/github/NaturalIntelligence/fast-xml-parser?branch=master)
[<img src="https://img.shields.io/badge/Try-me-blue.svg?colorA=FFA500&colorB=0000FF" alt="Try me"/>](https://naturalintelligence.github.io/fast-xml-parser/)
[![NPM total downloads](https://img.shields.io/npm/dt/fast-xml-parser.svg)](https://npm.im/fast-xml-parser)
[quality-image]: http://npm.packagequality.com/shield/fast-xml-parser.svg?style=flat-square
[quality-url]: http://packagequality.com/#?package=fast-xml-parser
<a href="https://opencollective.com/fast-xml-parser/donate" target="_blank">
<img src="https://opencollective.com/fast-xml-parser/donate/button@2x.png?color=blue" width=200 />
</a>
<a href="https://www.patreon.com/bePatron?u=9531404" data-patreon-widget-type="become-patron-button"><img src="https://c5.patreon.com/external/logo/become_a_patron_button.png" alt="Become a Patron!" width="200" /></a>
<a href="https://www.paypal.me/amitkumarguptagwl"> <img src="static/img/support_paypal.svg" alt="Stubmatic donate button" width="200"/></a>
### Main Features
<img align="right" src="static/img/fxp_logo.png" width="180px" alt="FXP logo"/>
* Validate XML data syntactically
* Transform XML to JSON or Nimn
* Transform JSON back to XML
* Works with node packages, in browser, and in CLI (press try me button above for demo)
* Faster than any pure JS implementation.
* It can handle big files (tested up to 100mb).
* Various options are available to customize the transformation
* You can parse CDATA as separate property.
* You can prefix attributes or group them to separate property. Or can ignore them from result completely.
* You can parse tag's or attribute's value to primitive type: string, integer, float, hexadecimal, or boolean. And can optionally decode for HTML char.
* You can remove namespace from tag or attribute name while parsing
* It supports boolean attributes, if configured.
## How to use
To use it in **NPM package** install it first
`$npm install fast-xml-parser` or using [yarn](https://yarnpkg.com/) `$yarn add fast-xml-parser`
To use it from **CLI** Install it globally with `-g` option.
`$npm install fast-xml-parser -g`
To use it on a **webpage** include it from a [CDN](https://cdnjs.com/libraries/fast-xml-parser)
### XML to JSON
```js
var jsonObj = parser.parse(xmlData [,options] );
```
```js
var parser = require('fast-xml-parser');
var he = require('he');
var options = {
attributeNamePrefix : "@_",
attrNodeName: "attr", //default is 'false'
textNodeName : "#text",
ignoreAttributes : true,
ignoreNameSpace : false,
allowBooleanAttributes : false,
parseNodeValue : true,
parseAttributeValue : false,
trimValues: true,
cdataTagName: "__cdata", //default is 'false'
cdataPositionChar: "\\c",
localeRange: "", //To support non english character in tag/attribute values.
parseTrueNumberOnly: false,
attrValueProcessor: a => he.decode(a, {isAttributeValue: true}),//default is a=>a
tagValueProcessor : a => he.decode(a) //default is a=>a
};
if( parser.validate(xmlData) === true) { //optional (it'll return an object in case it's not valid)
var jsonObj = parser.parse(xmlData,options);
}
// Intermediate obj
var tObj = parser.getTraversalObj(xmlData,options);
var jsonObj = parser.convertToJson(tObj,options);
```
#### Note: [he](https://www.npmjs.com/package/he) library is used in this example
<details>
<summary>OPTIONS :</summary>
* **attributeNamePrefix** : prepend given string to attribute name for identification
* **attrNodeName**: (Valid name) Group all the attributes as properties of given name.
* **ignoreAttributes** : Ignore attributes to be parsed.
* **ignoreNameSpace** : Remove namespace string from tag and attribute names.
* **allowBooleanAttributes** : a tag can have attributes without any value
* **parseNodeValue** : Parse the value of text node to float, integer, or boolean.
* **parseAttributeValue** : Parse the value of an attribute to float, integer, or boolean.
* **trimValues** : trim string values of an attribute or node
* **decodeHTMLchar** : This options has been removed from 3.3.4. Instead, use tagValueProcessor, and attrValueProcessor. See above example.
* **cdataTagName** : If specified, parser parse CDATA as nested tag instead of adding it's value to parent tag.
* **cdataPositionChar** : It'll help to covert JSON back to XML without losing CDATA position.
* **localeRange**: Parser will accept non-English character in tag or attribute name. Check #87 for more detail. Eg `localeRange: "a-zA-Zа-яёА-ЯЁ"`
* **parseTrueNumberOnly**: if true then values like "+123", or "0123" will not be parsed as number.
* **tagValueProcessor** : Process tag value during transformation. Like HTML decoding, word capitalization, etc. Applicable in case of string only.
* **attrValueProcessor** : Process attribute value during transformation. Like HTML decoding, word capitalization, etc. Applicable in case of string only.
* **stopNodes** : an array of tag names which are not required to be parsed. Instead their values are parsed as string.
</details>
<details>
<summary>To use from <b>command line</b></summary>
```bash
$xml2js [-ns|-a|-c|-v|-V] <filename> [-o outputfile.json]
$cat xmlfile.xml | xml2js [-ns|-a|-c|-v|-V] [-o outputfile.json]
```
* -ns : To include namespaces (by default ignored)
* -a : To ignore attributes
* -c : To ignore value conversion (i.e. "-3" will not be converted to number -3)
* -v : validate before parsing
* -V : only validate
</details>
<details>
<summary>To use it <b>on webpage</b></summary>
```js
var result = parser.validate(xmlData);
if (result !== true) console.log(result.err);
var jsonObj = parser.parse(xmlData);
```
</details>
### JSON / JS Object to XML
```js
var Parser = require("fast-xml-parser").j2xParser;
//default options need not to set
var defaultOptions = {
attributeNamePrefix : "@_",
attrNodeName: "@", //default is false
textNodeName : "#text",
ignoreAttributes : true,
cdataTagName: "__cdata", //default is false
cdataPositionChar: "\\c",
format: false,
indentBy: " ",
supressEmptyNode: false,
tagValueProcessor: a=> he.encode(a, { useNamedReferences: true}),// default is a=>a
attrValueProcessor: a=> he.encode(a, {isAttributeValue: isAttribute, useNamedReferences: true})// default is a=>a
};
var parser = new Parser(defaultOptions);
var xml = parser.parse(json_or_js_obj);
```
<details>
<summary>OPTIONS :</summary>
With the correct options, you can get the almost original XML without losing any information.
* **attributeNamePrefix** : Identify attributes with this prefix otherwise treat them as a tag.
* **attrNodeName**: Identify attributes when they are grouped under single property.
* **ignoreAttributes** : Don't check for attributes. Treats everything as tag.
* **encodeHTMLchar** : This option has been removed from 3.3.4. Use tagValueProcessor, and attrValueProcessor instead. See above example.
* **cdataTagName** : If specified, parse matching tag as CDATA
* **cdataPositionChar** : Identify the position where CDATA tag should be placed. If it is blank then CDATA will be added in the last of tag's value.
* **format** : If set to true, then format the XML output.
* **indentBy** : indent by this char `when` format is set to `true`
* **supressEmptyNode** : If set to `true`, tags with no value (text or nested tags) are written as self closing tags.
* **tagValueProcessor** : Process tag value during transformation. Like HTML encoding, word capitalization, etc. Applicable in case of string only.
* **attrValueProcessor** : Process attribute value during transformation. Like HTML encoding, word capitalization, etc. Applicable in case of string only.
</details>
## Benchmark
#### XML to JSON
![npm_xml2json_compare](static/img/fxpv3-vs-xml2jsv0419_chart.png)
<details>
<summary>report</summary>
| file size | fxp 3.0 validator (rps) | fxp 3.0 parser (rps) | xml2js 0.4.19 (rps) |
| ---------- | ----------------------- | ------------------- | ------------------- |
| 1.5k | 16581.06758 | 14032.09323 | 4615.930805 |
| 1.5m | 14918.47793 | 13.23366098 | 5.90682005 |
| 13m | 1.834479235 | 1.135582008 | -1 |
| 1.3k with CDATA | 30583.35319 | 43160.52342 | 8398.556349 |
| 1.3m with CDATA | 27.29266471 | 52.68877009 | 7.966000795 |
| 1.6k with cdata,prolog,doctype | 27690.26082 | 41433.98547 | 7872.399268 |
| 98m | 0.08473858148 | 0.2600104004 | -1 |
* -1 indicates error or incorrect output.
</details>
#### JSON to XML
![npm_xml2json_compare](static/img/j2x.png)
<details>
<summary>report</summary>
| file size | fxp 3.2 js to xml | xml2js 0.4.19 builder |
|------------|-----------------|-----------------|
| 1.3k | 160148.9801 | 10384.99401|
| 1.1m | 173.6374831 | 8.611884025|
</details>
### Limitations
Currently FXP fails to parse XML with attributes has ">" in the value. This problem is left open as change in regex for its fix is degrading the performance. And the parser become very slow in case of long attrbute names.
### Worth to mention
- **[BigBit standard)](https://github.com/amitguptagwl/bigbit)** : A standard to reprent any number in the universe in comparitively less space and without precision loss. A standard to save space to represent any text string in comparision of UTF encoding.
- **[imglab](https://github.com/NaturalIntelligence/imglab)** : Speedup and simplify image labeling / annotation. Supports multiple formats, one click annotation, easy interface and much more. There are more than 20k images are annotated every month.
- **[अनुमार्गक (anumargak)](https://github.com/NaturalIntelligence/anumargak)** : The fastest and simple router for node js web frameworks with many unique features.
- [stubmatic](https://github.com/NaturalIntelligence/Stubmatic) : A stub server to mock behaviour of HTTP(s) / REST / SOAP services, incuding DynamoDB calls. You can also mock binary formats.
- [मुनीम (Muneem)](https://github.com/muneem4node/muneem) : A webframework made for all team members. Faster tha fastify, express, koa, hapi and others.
- [शब्दावली (shabdawali)](https://github.com/amitguptagwl/shabdawali) : Amazing human like typing effects beyond your imagination.
## Contributors
This project exists thanks to [all](graphs/contributors) the people who contribute. [[Contribute](CONTRIBUTING.md)].
<!-- <a href="graphs/contributors"><img src="https://opencollective.com/fast-xml-parser/contributors.svg?width=890&button=false" /></a> -->
<!--
### Lead Maintainers
![Amit Gupta](https://avatars1.githubusercontent.com/u/7692328?s=100&v=4)
[![Vohmyanin Sergey Vasilevich](https://avatars3.githubusercontent.com/u/783335?s=100&v=4)](https://github.com/Delagen)
### All Contributors -->
<a href="graphs/contributors"><img src="https://opencollective.com/fast-xml-parser/contributors.svg?width=890&button=false" /></a>
## Backers
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/fast-xml-parser#backer)]
<a href="https://opencollective.com/fast-xml-parser#backers" target="_blank"><img src="https://opencollective.com/fast-xml-parser/backers.svg?width=890"></a>
## Sponsors
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/fast-xml-parser#sponsor)]
<a href="https://opencollective.com/fast-xml-parser/sponsor/0/website" target="_blank"><img src="https://opencollective.com/fast-xml-parser/sponsor/0/avatar.svg"></a>
<a href="https://opencollective.com/fast-xml-parser/sponsor/1/website" target="_blank"><img src="https://opencollective.com/fast-xml-parser/sponsor/1/avatar.svg"></a>
<a href="https://opencollective.com/fast-xml-parser/sponsor/2/website" target="_blank"><img src="https://opencollective.com/fast-xml-parser/sponsor/2/avatar.svg"></a>
<a href="https://opencollective.com/fast-xml-parser/sponsor/3/website" target="_blank"><img src="https://opencollective.com/fast-xml-parser/sponsor/3/avatar.svg"></a>
<a href="https://opencollective.com/fast-xml-parser/sponsor/4/website" target="_blank"><img src="https://opencollective.com/fast-xml-parser/sponsor/4/avatar.svg"></a>
<a href="https://opencollective.com/fast-xml-parser/sponsor/5/website" target="_blank"><img src="https://opencollective.com/fast-xml-parser/sponsor/5/avatar.svg"></a>
<a href="https://opencollective.com/fast-xml-parser/sponsor/6/website" target="_blank"><img src="https://opencollective.com/fast-xml-parser/sponsor/6/avatar.svg"></a>
<a href="https://opencollective.com/fast-xml-parser/sponsor/7/website" target="_blank"><img src="https://opencollective.com/fast-xml-parser/sponsor/7/avatar.svg"></a>
<a href="https://opencollective.com/fast-xml-parser/sponsor/8/website" target="_blank"><img src="https://opencollective.com/fast-xml-parser/sponsor/8/avatar.svg"></a>
<a href="https://opencollective.com/fast-xml-parser/sponsor/9/website" target="_blank"><img src="https://opencollective.com/fast-xml-parser/sponsor/9/avatar.svg"></a>

101
node_modules/fast-xml-parser/cli.js generated vendored Normal file
View File

@ -0,0 +1,101 @@
#!/usr/bin/env node
'use strict';
/*eslint-disable no-console*/
const fs = require('fs');
const path = require('path');
const parser = require('./src/parser');
const readToEnd = require('./src/read').readToEnd;
if (process.argv[2] === '--help' || process.argv[2] === '-h') {
console.log('Fast XML Parser ' + require(path.join(__dirname + '/package.json')).version);
console.log('----------------');
console.log('xml2js [-ns|-a|-c|-v|-V] <filename> [-o outputfile.json]');
console.log('cat xmlfile.xml | xml2js [-ns|-a|-c|-v|-V] [-o outputfile.json]');
console.log('-ns: remove namespace from tag and atrribute name.');
console.log("-a: don't parse attributes.");
console.log('-c: parse values to premitive type.');
console.log('-v: validate before parsing.');
console.log('-V: validate only.');
} else if (process.argv[2] === '--version') {
console.log(require(path.join(__dirname + '/package.json')).version);
} else {
const options = {
ignoreNameSpace: true,
ignoreAttributes: false,
parseNodeValue: true,
parseAttributeValue: true,
};
let fileName = '';
let outputFileName;
let validate = false;
let validateOnly = false;
for (let i = 2; i < process.argv.length; i++) {
if (process.argv[i] === '-ns') {
options.ignoreNameSpace = false;
} else if (process.argv[i] === '-a') {
options.ignoreAttributes = true;
} else if (process.argv[i] === '-c') {
options.parseNodeValue = false;
options.parseAttributeValue = false;
} else if (process.argv[i] === '-o') {
outputFileName = process.argv[++i];
} else if (process.argv[i] === '-v') {
validate = true;
} else if (process.argv[i] === '-V') {
validateOnly = true;
} else {
//filename
fileName = process.argv[i];
}
}
const callback = function(xmlData) {
let output = '';
if (validate) {
const result = parser.validate(xmlData);
if (result === true) {
output = JSON.stringify(parser.parse(xmlData, options), null, 4);
} else {
output = result;
}
} else if (validateOnly) {
output = parser.validate(xmlData);
process.exitCode = output === true ? 0 : 1;
} else {
output = JSON.stringify(parser.parse(xmlData, options), null, 4);
}
if (outputFileName) {
writeToFile(outputFileName, output);
} else {
console.log(output);
}
};
try {
if (!fileName) {
readToEnd(process.stdin, function(err, data) {
if (err) {
throw err;
}
callback(data.toString());
});
} else {
fs.readFile(fileName, function(err, data) {
if (err) {
throw err;
}
callback(data.toString());
});
}
} catch (e) {
console.log('Seems an invalid file or stream.' + e);
}
}
function writeToFile(fileName, data) {
fs.writeFile(fileName, data, function(err) {
if (err) {
throw err;
}
console.log('JSON output has been written to ' + fileName);
});
}

17
node_modules/fast-xml-parser/codecept.json generated vendored Normal file
View File

@ -0,0 +1,17 @@
{
"tests": "./spec/*_spec.js",
"timeout": 10000,
"output": "./output",
"helpers": {
"WebDriverIO": {
"url": "http://localhost",
"browser": "chrome"
}
},
"include": {
"I": "./steps_file.js"
},
"bootstrap": false,
"mocha": {},
"name": "fxp"
}

8
node_modules/fast-xml-parser/nexttodo.md generated vendored Normal file
View File

@ -0,0 +1,8 @@
* check test coverage and write necessary tests
* validate XML stream data
* Fix jTox for json array. Not sure if a bug exist.
* generate separate and combined browser bundle for xml -> nimn, xml -> json , json -> xml
* Es6 to es5 migration without workaround.
* Parse JSON string to XML. Currently it transforms JSON object to XML. Partially done. Need to work on performance.
* build properties only once
* XML to JSON ML : https://en.wikipedia.org/wiki/JsonML

128
node_modules/fast-xml-parser/package.json generated vendored Normal file
View File

@ -0,0 +1,128 @@
{
"_args": [
[
"fast-xml-parser@3.12.20",
"C:\\dev\\repos\\actions\\setup-dotnet"
]
],
"_from": "fast-xml-parser@3.12.20",
"_id": "fast-xml-parser@3.12.20",
"_inBundle": false,
"_integrity": "sha512-viadHdefuuqkyJWUhF2r2Ymb5LJ0T7uQhzSRv4OZzYxpoPQnY05KtaX0pLkolabD7tLzIE8q/OytIAEhqPyYbw==",
"_location": "/fast-xml-parser",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "fast-xml-parser@3.12.20",
"name": "fast-xml-parser",
"escapedName": "fast-xml-parser",
"rawSpec": "3.12.20",
"saveSpec": null,
"fetchSpec": "3.12.20"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-3.12.20.tgz",
"_spec": "3.12.20",
"_where": "C:\\dev\\repos\\actions\\setup-dotnet",
"author": {
"name": "Amit Gupta",
"url": "https://amitkumargupta.work/"
},
"bin": {
"xml2js": "./cli.js"
},
"bugs": {
"url": "https://github.com/NaturalIntelligence/fast-xml-parser/issues"
},
"contributors": [
{
"name": "Alfonso Muñoz-Pomer Fuentes",
"email": "amunoz@ebi.ac.uk",
"url": "https://github.com/alfonsomunozpomer"
},
{
"name": "Steve Reichenbach",
"url": "https://github.com/EyesOnlyNet"
},
{
"name": "Vohmyanin Sergey Vasilevich",
"url": "http://delagen.livejournal.com"
},
{
"name": "Andrew Udvare",
"url": "https://github.com/Tatsh"
}
],
"dependencies": {
"nimnjs": "^1.3.2"
},
"description": "Validate XML or Parse XML to JS/JSON very fast without C/C++ based libraries",
"devDependencies": {
"@babel/core": "^7.4.0",
"@babel/plugin-transform-runtime": "^7.4.0",
"@babel/preset-env": "^7.4.2",
"@babel/register": "^7.4.0",
"babel-loader": "^8.0.5",
"benchmark": "^2.1.4",
"eslint": "^5.15.3",
"he": "^1.2.0",
"http-server": "^0.11.1",
"istanbul": "^0.4.5",
"jasmine": "^3.3.1",
"portfinder": "^1.0.20",
"prettier": "^1.15.3",
"webpack": "^4.29.6",
"webpack-cli": "^3.3.0",
"xml2js": "^0.4.19",
"zombie": "^5.0.8"
},
"homepage": "https://github.com/NaturalIntelligence/fast-xml-parser#readme",
"keywords": [
"fast",
"xml",
"json",
"parser",
"xml2js",
"x2js",
"xml2json",
"js",
"traversable",
"cli",
"command",
"validator",
"validate",
"transformer",
"checker",
"assert",
"big",
"js2xml",
"json2xml",
"nimn",
"xml2nimn",
"locale",
"html"
],
"license": "MIT",
"main": "./src/parser.js",
"name": "fast-xml-parser",
"repository": {
"type": "git",
"url": "git+https://github.com/NaturalIntelligence/fast-xml-parser.git"
},
"scripts": {
"bundle": "webpack && webpack --config webpack-prod.config.js",
"coverage": "istanbul cover -x \"cli.js\" -x \"spec/*spec.js\" jasmine spec/*spec.js;",
"coverage:check": "istanbul check-coverage --branch 90 --statement 90",
"lint": "eslint src/*.js spec/*.js",
"perf": "node ./benchmark/perfTest3.js",
"postinstall": "node tasks/postinstall.js || exit 0",
"prettier": "prettier --write src/**/*.js",
"test": "jasmine spec/*spec.js",
"unit": "jasmine"
},
"typings": "src/parser.d.ts",
"version": "3.12.20"
}

268
node_modules/fast-xml-parser/src/json2xml.js generated vendored Normal file
View File

@ -0,0 +1,268 @@
'use strict';
//parse Empty Node as self closing node
const buildOptions = require('./util').buildOptions;
const defaultOptions = {
attributeNamePrefix: '@_',
attrNodeName: false,
textNodeName: '#text',
ignoreAttributes: true,
cdataTagName: false,
cdataPositionChar: '\\c',
format: false,
indentBy: ' ',
supressEmptyNode: false,
tagValueProcessor: function(a) {
return a;
},
attrValueProcessor: function(a) {
return a;
},
};
const props = [
'attributeNamePrefix',
'attrNodeName',
'textNodeName',
'ignoreAttributes',
'cdataTagName',
'cdataPositionChar',
'format',
'indentBy',
'supressEmptyNode',
'tagValueProcessor',
'attrValueProcessor',
];
function Parser(options) {
this.options = buildOptions(options, defaultOptions, props);
if (this.options.ignoreAttributes || this.options.attrNodeName) {
this.isAttribute = function(/*a*/) {
return false;
};
} else {
this.attrPrefixLen = this.options.attributeNamePrefix.length;
this.isAttribute = isAttribute;
}
if (this.options.cdataTagName) {
this.isCDATA = isCDATA;
} else {
this.isCDATA = function(/*a*/) {
return false;
};
}
this.replaceCDATAstr = replaceCDATAstr;
this.replaceCDATAarr = replaceCDATAarr;
if (this.options.format) {
this.indentate = indentate;
this.tagEndChar = '>\n';
this.newLine = '\n';
} else {
this.indentate = function() {
return '';
};
this.tagEndChar = '>';
this.newLine = '';
}
if (this.options.supressEmptyNode) {
this.buildTextNode = buildEmptyTextNode;
this.buildObjNode = buildEmptyObjNode;
} else {
this.buildTextNode = buildTextValNode;
this.buildObjNode = buildObjectNode;
}
this.buildTextValNode = buildTextValNode;
this.buildObjectNode = buildObjectNode;
}
Parser.prototype.parse = function(jObj) {
return this.j2x(jObj, 0).val;
};
Parser.prototype.j2x = function(jObj, level) {
let attrStr = '';
let val = '';
const keys = Object.keys(jObj);
const len = keys.length;
for (let i = 0; i < len; i++) {
const key = keys[i];
if (typeof jObj[key] === 'undefined') {
// supress undefined node
} else if (jObj[key] === null) {
val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;
} else if (jObj[key] instanceof Date) {
val += this.buildTextNode(jObj[key], key, '', level);
} else if (typeof jObj[key] !== 'object') {
//premitive type
const attr = this.isAttribute(key);
if (attr) {
attrStr += ' ' + attr + '="' + this.options.attrValueProcessor('' + jObj[key]) + '"';
} else if (this.isCDATA(key)) {
if (jObj[this.options.textNodeName]) {
val += this.replaceCDATAstr(jObj[this.options.textNodeName], jObj[key]);
} else {
val += this.replaceCDATAstr('', jObj[key]);
}
} else {
//tag value
if (key === this.options.textNodeName) {
if (jObj[this.options.cdataTagName]) {
//value will added while processing cdata
} else {
val += this.options.tagValueProcessor('' + jObj[key]);
}
} else {
val += this.buildTextNode(jObj[key], key, '', level);
}
}
} else if (Array.isArray(jObj[key])) {
//repeated nodes
if (this.isCDATA(key)) {
val += this.indentate(level);
if (jObj[this.options.textNodeName]) {
val += this.replaceCDATAarr(jObj[this.options.textNodeName], jObj[key]);
} else {
val += this.replaceCDATAarr('', jObj[key]);
}
} else {
//nested nodes
const arrLen = jObj[key].length;
for (let j = 0; j < arrLen; j++) {
const item = jObj[key][j];
if (typeof item === 'undefined') {
// supress undefined node
} else if (item === null) {
val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;
} else if (typeof item === 'object') {
const result = this.j2x(item, level + 1);
val += this.buildObjNode(result.val, key, result.attrStr, level);
} else {
val += this.buildTextNode(item, key, '', level);
}
}
}
} else {
//nested node
if (this.options.attrNodeName && key === this.options.attrNodeName) {
const Ks = Object.keys(jObj[key]);
const L = Ks.length;
for (let j = 0; j < L; j++) {
attrStr += ' ' + Ks[j] + '="' + this.options.attrValueProcessor('' + jObj[key][Ks[j]]) + '"';
}
} else {
const result = this.j2x(jObj[key], level + 1);
val += this.buildObjNode(result.val, key, result.attrStr, level);
}
}
}
return {attrStr: attrStr, val: val};
};
function replaceCDATAstr(str, cdata) {
str = this.options.tagValueProcessor('' + str);
if (this.options.cdataPositionChar === '' || str === '') {
return str + '<![CDATA[' + cdata + ']]' + this.tagEndChar;
} else {
return str.replace(this.options.cdataPositionChar, '<![CDATA[' + cdata + ']]' + this.tagEndChar);
}
}
function replaceCDATAarr(str, cdata) {
str = this.options.tagValueProcessor('' + str);
if (this.options.cdataPositionChar === '' || str === '') {
return str + '<![CDATA[' + cdata.join(']]><![CDATA[') + ']]' + this.tagEndChar;
} else {
for (let v in cdata) {
str = str.replace(this.options.cdataPositionChar, '<![CDATA[' + cdata[v] + ']]>');
}
return str + this.newLine;
}
}
function buildObjectNode(val, key, attrStr, level) {
if (attrStr && !val.includes('<')) {
return (
this.indentate(level) +
'<' +
key +
attrStr +
'>' +
val +
//+ this.newLine
// + this.indentate(level)
'</' +
key +
this.tagEndChar
);
} else {
return (
this.indentate(level) +
'<' +
key +
attrStr +
this.tagEndChar +
val +
//+ this.newLine
this.indentate(level) +
'</' +
key +
this.tagEndChar
);
}
}
function buildEmptyObjNode(val, key, attrStr, level) {
if (val !== '') {
return this.buildObjectNode(val, key, attrStr, level);
} else {
return this.indentate(level) + '<' + key + attrStr + '/' + this.tagEndChar;
//+ this.newLine
}
}
function buildTextValNode(val, key, attrStr, level) {
return (
this.indentate(level) +
'<' +
key +
attrStr +
'>' +
this.options.tagValueProcessor(val) +
'</' +
key +
this.tagEndChar
);
}
function buildEmptyTextNode(val, key, attrStr, level) {
if (val !== '') {
return this.buildTextValNode(val, key, attrStr, level);
} else {
return this.indentate(level) + '<' + key + attrStr + '/' + this.tagEndChar;
}
}
function indentate(level) {
return this.options.indentBy.repeat(level);
}
function isAttribute(name /*, options*/) {
if (name.startsWith(this.options.attributeNamePrefix)) {
return name.substr(this.attrPrefixLen);
} else {
return false;
}
}
function isCDATA(name) {
return name === this.options.cdataTagName;
}
//formatting
//indentation
//\n after each closing or self closing tag
module.exports = Parser;

144
node_modules/fast-xml-parser/src/nimndata.js generated vendored Normal file
View File

@ -0,0 +1,144 @@
'use strict';
const char = function(a) {
return String.fromCharCode(a);
};
const chars = {
nilChar: char(176),
missingChar: char(201),
nilPremitive: char(175),
missingPremitive: char(200),
emptyChar: char(178),
emptyValue: char(177), //empty Premitive
boundryChar: char(179),
objStart: char(198),
arrStart: char(204),
arrayEnd: char(185),
};
const charsArr = [
chars.nilChar,
chars.nilPremitive,
chars.missingChar,
chars.missingPremitive,
chars.boundryChar,
chars.emptyChar,
chars.emptyValue,
chars.arrayEnd,
chars.objStart,
chars.arrStart,
];
const _e = function(node, e_schema, options) {
if (typeof e_schema === 'string') {
//premitive
if (node && node[0] && node[0].val !== undefined) {
return getValue(node[0].val, e_schema);
} else {
return getValue(node, e_schema);
}
} else {
const hasValidData = hasData(node);
if (hasValidData === true) {
let str = '';
if (Array.isArray(e_schema)) {
//attributes can't be repeated. hence check in children tags only
str += chars.arrStart;
const itemSchema = e_schema[0];
//var itemSchemaType = itemSchema;
const arr_len = node.length;
if (typeof itemSchema === 'string') {
for (let arr_i = 0; arr_i < arr_len; arr_i++) {
const r = getValue(node[arr_i].val, itemSchema);
str = processValue(str, r);
}
} else {
for (let arr_i = 0; arr_i < arr_len; arr_i++) {
const r = _e(node[arr_i], itemSchema, options);
str = processValue(str, r);
}
}
str += chars.arrayEnd; //indicates that next item is not array item
} else {
//object
str += chars.objStart;
const keys = Object.keys(e_schema);
if (Array.isArray(node)) {
node = node[0];
}
for (let i in keys) {
const key = keys[i];
//a property defined in schema can be present either in attrsMap or children tags
//options.textNodeName will not present in both maps, take it's value from val
//options.attrNodeName will be present in attrsMap
let r;
if (!options.ignoreAttributes && node.attrsMap && node.attrsMap[key]) {
r = _e(node.attrsMap[key], e_schema[key], options);
} else if (key === options.textNodeName) {
r = _e(node.val, e_schema[key], options);
} else {
r = _e(node.child[key], e_schema[key], options);
}
str = processValue(str, r);
}
}
return str;
} else {
return hasValidData;
}
}
};
const getValue = function(a /*, type*/) {
switch (a) {
case undefined:
return chars.missingPremitive;
case null:
return chars.nilPremitive;
case '':
return chars.emptyValue;
default:
return a;
}
};
const processValue = function(str, r) {
if (!isAppChar(r[0]) && !isAppChar(str[str.length - 1])) {
str += chars.boundryChar;
}
return str + r;
};
const isAppChar = function(ch) {
return charsArr.indexOf(ch) !== -1;
};
function hasData(jObj) {
if (jObj === undefined) {
return chars.missingChar;
} else if (jObj === null) {
return chars.nilChar;
} else if (
jObj.child &&
Object.keys(jObj.child).length === 0 &&
(!jObj.attrsMap || Object.keys(jObj.attrsMap).length === 0)
) {
return chars.emptyChar;
} else {
return true;
}
}
const x2j = require('./xmlstr2xmlnode');
const buildOptions = require('./util').buildOptions;
const convert2nimn = function(node, e_schema, options) {
options = buildOptions(options, x2j.defaultOptions, x2j.props);
return _e(node, e_schema, options);
};
exports.convert2nimn = convert2nimn;

39
node_modules/fast-xml-parser/src/node2json.js generated vendored Normal file
View File

@ -0,0 +1,39 @@
'use strict';
const util = require('./util');
const convertToJson = function(node, options) {
const jObj = {};
//when no child node or attr is present
if ((!node.child || util.isEmptyObject(node.child)) && (!node.attrsMap || util.isEmptyObject(node.attrsMap))) {
return util.isExist(node.val) ? node.val : '';
} else {
//otherwise create a textnode if node has some text
if (util.isExist(node.val)) {
if (!(typeof node.val === 'string' && (node.val === '' || node.val === options.cdataPositionChar))) {
jObj[options.textNodeName] = node.val;
}
}
}
util.merge(jObj, node.attrsMap);
const keys = Object.keys(node.child);
for (let index = 0; index < keys.length; index++) {
var tagname = keys[index];
if (node.child[tagname] && node.child[tagname].length > 1) {
jObj[tagname] = [];
for (var tag in node.child[tagname]) {
jObj[tagname].push(convertToJson(node.child[tagname][tag], options));
}
} else {
jObj[tagname] = convertToJson(node.child[tagname][0], options);
}
}
//add value
return jObj;
};
exports.convertToJson = convertToJson;

63
node_modules/fast-xml-parser/src/node2json_str.js generated vendored Normal file
View File

@ -0,0 +1,63 @@
'use strict';
const util = require('./util');
const buildOptions = require('./util').buildOptions;
const x2j = require('./xmlstr2xmlnode');
//TODO: do it later
const convertToJsonString = function(node, options) {
options = buildOptions(options, x2j.defaultOptions, x2j.props);
options.indentBy = options.indentBy || '';
return _cToJsonStr(node, options, 0);
};
const _cToJsonStr = function(node, options, level) {
let jObj = '{';
//traver through all the children
const keys = Object.keys(node.child);
for (let index = 0; index < keys.length; index++) {
var tagname = keys[index];
if (node.child[tagname] && node.child[tagname].length > 1) {
jObj += '"' + tagname + '" : [ ';
for (var tag in node.child[tagname]) {
jObj += _cToJsonStr(node.child[tagname][tag], options) + ' , ';
}
jObj = jObj.substr(0, jObj.length - 1) + ' ] '; //remove extra comma in last
} else {
jObj += '"' + tagname + '" : ' + _cToJsonStr(node.child[tagname][0], options) + ' ,';
}
}
util.merge(jObj, node.attrsMap);
//add attrsMap as new children
if (util.isEmptyObject(jObj)) {
return util.isExist(node.val) ? node.val : '';
} else {
if (util.isExist(node.val)) {
if (!(typeof node.val === 'string' && (node.val === '' || node.val === options.cdataPositionChar))) {
jObj += '"' + options.textNodeName + '" : ' + stringval(node.val);
}
}
}
//add value
if (jObj[jObj.length - 1] === ',') {
jObj = jObj.substr(0, jObj.length - 2);
}
return jObj + '}';
};
function stringval(v) {
if (v === true || v === false || !isNaN(v)) {
return v;
} else {
return '"' + v + '"';
}
}
function indentate(options, level) {
return options.indentBy.repeat(level);
}
exports.convertToJsonString = convertToJsonString;

69
node_modules/fast-xml-parser/src/parser.d.ts generated vendored Normal file
View File

@ -0,0 +1,69 @@
type X2jOptions = {
attributeNamePrefix: string;
attrNodeName: false | string;
textNodeName: string;
ignoreAttributes: boolean;
ignoreNameSpace: boolean;
allowBooleanAttributes: boolean;
parseNodeValue: boolean;
parseAttributeValue: boolean;
arrayMode: boolean;
trimValues: boolean;
cdataTagName: false | string;
cdataPositionChar: string;
localeRange: string;
parseTrueNumberOnly: boolean;
tagValueProcessor: (tagValue: string) => string;
attrValueProcessor: (attrValue: string) => string;
};
type X2jOptionsOptional = Partial<X2jOptions>;
type J2xOptions = {
attributeNamePrefix: string;
attrNodeName: false | string;
textNodeName: string;
ignoreAttributes: boolean;
cdataTagName: false | string;
cdataPositionChar: string;
format: boolean;
indentBy: string;
supressEmptyNode: boolean;
tagValueProcessor: (tagValue: string) => string;
attrValueProcessor: (attrValue: string) => string;
};
type J2xOptionsOptional = Partial<J2xOptions>;
type ESchema = string | object | Array<string|object>;
type ValidationError = {
err: { code: string; msg: string };
};
export function parse(xmlData: string, options?: X2jOptionsOptional): any;
export function convert2nimn(
node: any,
e_schema: ESchema,
options?: X2jOptionsOptional
): any;
export function getTraversalObj(
xmlData: string,
options?: X2jOptionsOptional
): any;
export function convertToJson(node: any, options?: X2jOptionsOptional): any;
export function convertToJsonString(
node: any,
options?: X2jOptionsOptional
): string;
export function validate(
xmlData: string,
options?: { allowBooleanAttributes?: boolean }
): true | ValidationError;
export class j2xParser {
constructor(options: J2xOptionsOptional);
parse(options: any): any;
}
export function parseToNimn(
xmlData: string,
schema: any,
options: Partial<X2jOptions>
): any;

20
node_modules/fast-xml-parser/src/parser.js generated vendored Normal file
View File

@ -0,0 +1,20 @@
'use strict';
const nodeToJson = require('./node2json');
const xmlToNodeobj = require('./xmlstr2xmlnode');
const x2xmlnode = require('./xmlstr2xmlnode');
const buildOptions = require('./util').buildOptions;
exports.parse = function(xmlData, options) {
options = buildOptions(options, x2xmlnode.defaultOptions, x2xmlnode.props);
return nodeToJson.convertToJson(xmlToNodeobj.getTraversalObj(xmlData, options), options);
};
exports.convertTonimn = require('../src/nimndata').convert2nimn;
exports.getTraversalObj = xmlToNodeobj.getTraversalObj;
exports.convertToJson = nodeToJson.convertToJson;
exports.convertToJsonString = require('./node2json_str').convertToJsonString;
exports.validate = require('./validator').validate;
exports.j2xParser = require('./json2xml');
exports.parseToNimn = function(xmlData, schema, options) {
return exports.convertTonimn(exports.getTraversalObj(xmlData, options), schema, options);
};

92
node_modules/fast-xml-parser/src/read.js generated vendored Normal file
View File

@ -0,0 +1,92 @@
'use strict';
// Copyright 2013 Timothy J Fontaine <tjfontaine@gmail.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the 'Software'), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE
/*
Read any stream all the way to the end and trigger a single cb
const http = require('http');
const rte = require('readtoend');
http.get('http://nodejs.org', function(response) {
rte.readToEnd(response, function(err, body) {
console.log(body);
});
});
*/
let stream = require('stream');
const util = require('util');
if (!stream.Transform) {
stream = require('readable-stream');
}
function ReadToEnd(opts) {
if (!(this instanceof ReadToEnd)) {
return new ReadToEnd(opts);
}
stream.Transform.call(this, opts);
this._rte_encoding = opts.encoding || 'utf8';
this._buff = '';
}
module.exports = ReadToEnd;
util.inherits(ReadToEnd, stream.Transform);
ReadToEnd.prototype._transform = function(chunk, encoding, done) {
this._buff += chunk.toString(this._rte_encoding);
this.push(chunk);
done();
};
ReadToEnd.prototype._flush = function(done) {
this.emit('complete', undefined, this._buff);
done();
};
ReadToEnd.readToEnd = function(stream, options, cb) {
if (!cb) {
cb = options;
options = {};
}
const dest = new ReadToEnd(options);
stream.pipe(dest);
stream.on('error', function(err) {
stream.unpipe(dest);
cb(err);
});
dest.on('complete', cb);
dest.resume();
return dest;
};

82
node_modules/fast-xml-parser/src/util.js generated vendored Normal file
View File

@ -0,0 +1,82 @@
'use strict';
const getAllMatches = function(string, regex) {
const matches = [];
let match = regex.exec(string);
while (match) {
const allmatches = [];
const len = match.length;
for (let index = 0; index < len; index++) {
allmatches.push(match[index]);
}
matches.push(allmatches);
match = regex.exec(string);
}
return matches;
};
const doesMatch = function(string, regex) {
const match = regex.exec(string);
return !(match === null || typeof match === 'undefined');
};
const doesNotMatch = function(string, regex) {
return !doesMatch(string, regex);
};
exports.isExist = function(v) {
return typeof v !== 'undefined';
};
exports.isEmptyObject = function(obj) {
return Object.keys(obj).length === 0;
};
/**
* Copy all the properties of a into b.
* @param {*} target
* @param {*} a
*/
exports.merge = function(target, a) {
if (a) {
const keys = Object.keys(a); // will return an array of own properties
const len = keys.length; //don't make it inline
for (let i = 0; i < len; i++) {
target[keys[i]] = a[keys[i]];
}
}
};
/* exports.merge =function (b,a){
return Object.assign(b,a);
} */
exports.getValue = function(v) {
if (exports.isExist(v)) {
return v;
} else {
return '';
}
};
// const fakeCall = function(a) {return a;};
// const fakeCallNoReturn = function() {};
exports.buildOptions = function(options, defaultOptions, props) {
var newOptions = {};
if (!options) {
return defaultOptions; //if there are not options
}
for (let i = 0; i < props.length; i++) {
if (options[props[i]] !== undefined) {
newOptions[props[i]] = options[props[i]];
} else {
newOptions[props[i]] = defaultOptions[props[i]];
}
}
return newOptions;
};
exports.doesMatch = doesMatch;
exports.doesNotMatch = doesNotMatch;
exports.getAllMatches = getAllMatches;

319
node_modules/fast-xml-parser/src/validator.js generated vendored Normal file
View File

@ -0,0 +1,319 @@
'use strict';
const util = require('./util');
const defaultOptions = {
allowBooleanAttributes: false, //A tag can have attributes without any value
localeRange: 'a-zA-Z',
};
const props = ['allowBooleanAttributes', 'localeRange'];
//const tagsPattern = new RegExp("<\\/?([\\w:\\-_\.]+)\\s*\/?>","g");
exports.validate = function(xmlData, options) {
options = util.buildOptions(options, defaultOptions, props);
//xmlData = xmlData.replace(/(\r\n|\n|\r)/gm,"");//make it single line
//xmlData = xmlData.replace(/(^\s*<\?xml.*?\?>)/g,"");//Remove XML starting tag
//xmlData = xmlData.replace(/(<!DOCTYPE[\s\w\"\.\/\-\:]+(\[.*\])*\s*>)/g,"");//Remove DOCTYPE
const tags = [];
let tagFound = false;
if (xmlData[0] === '\ufeff') {
// check for byte order mark (BOM)
xmlData = xmlData.substr(1);
}
const regxAttrName = new RegExp('^[_w][\\w\\-.:]*$'.replace('_w', '_' + options.localeRange));
const regxTagName = new RegExp('^([w]|_)[\\w.\\-_:]*'.replace('([w', '([' + options.localeRange));
for (let i = 0; i < xmlData.length; i++) {
if (xmlData[i] === '<') {
//starting of tag
//read until you reach to '>' avoiding any '>' in attribute value
i++;
if (xmlData[i] === '?') {
i = readPI(xmlData, ++i);
if (i.err) {
return i;
}
} else if (xmlData[i] === '!') {
i = readCommentAndCDATA(xmlData, i);
continue;
} else {
let closingTag = false;
if (xmlData[i] === '/') {
//closing tag
closingTag = true;
i++;
}
//read tagname
let tagName = '';
for (
;
i < xmlData.length &&
xmlData[i] !== '>' &&
xmlData[i] !== ' ' &&
xmlData[i] !== '\t' &&
xmlData[i] !== '\n' &&
xmlData[i] !== '\r';
i++
) {
tagName += xmlData[i];
}
tagName = tagName.trim();
//console.log(tagName);
if (tagName[tagName.length - 1] === '/') {
//self closing tag without attributes
tagName = tagName.substring(0, tagName.length - 1);
continue;
}
if (!validateTagName(tagName, regxTagName)) {
return {err: {code: 'InvalidTag', msg: 'Tag ' + tagName + ' is an invalid name.'}};
}
const result = readAttributeStr(xmlData, i);
if (result === false) {
return {err: {code: 'InvalidAttr', msg: 'Attributes for ' + tagName + ' have open quote'}};
}
let attrStr = result.value;
i = result.index;
if (attrStr[attrStr.length - 1] === '/') {
//self closing tag
attrStr = attrStr.substring(0, attrStr.length - 1);
const isValid = validateAttributeString(attrStr, options, regxAttrName);
if (isValid === true) {
tagFound = true;
//continue; //text may presents after self closing tag
} else {
return isValid;
}
} else if (closingTag) {
if (attrStr.trim().length > 0) {
return {
err: {code: 'InvalidTag', msg: 'closing tag ' + tagName + " can't have attributes or invalid starting."},
};
} else {
const otg = tags.pop();
if (tagName !== otg) {
return {
err: {code: 'InvalidTag', msg: 'closing tag ' + otg + ' is expected inplace of ' + tagName + '.'},
};
}
}
} else {
const isValid = validateAttributeString(attrStr, options, regxAttrName);
if (isValid !== true) {
return isValid;
}
tags.push(tagName);
tagFound = true;
}
//skip tag text value
//It may include comments and CDATA value
for (i++; i < xmlData.length; i++) {
if (xmlData[i] === '<') {
if (xmlData[i + 1] === '!') {
//comment or CADATA
i++;
i = readCommentAndCDATA(xmlData, i);
continue;
} else {
break;
}
}
} //end of reading tag text value
if (xmlData[i] === '<') {
i--;
}
}
} else {
if (xmlData[i] === ' ' || xmlData[i] === '\t' || xmlData[i] === '\n' || xmlData[i] === '\r') {
continue;
}
return {err: {code: 'InvalidChar', msg: 'char ' + xmlData[i] + ' is not expected .'}};
}
}
if (!tagFound) {
return {err: {code: 'InvalidXml', msg: 'Start tag expected.'}};
} else if (tags.length > 0) {
return {
err: {code: 'InvalidXml', msg: 'Invalid ' + JSON.stringify(tags, null, 4).replace(/\r?\n/g, '') + ' found.'},
};
}
return true;
};
/**
* Read Processing insstructions and skip
* @param {*} xmlData
* @param {*} i
*/
function readPI(xmlData, i) {
var start = i;
for (; i < xmlData.length; i++) {
if (xmlData[i] == '?' || xmlData[i] == ' ') {
//tagname
var tagname = xmlData.substr(start, i - start);
if (i > 5 && tagname === 'xml') {
return {err: {code: 'InvalidXml', msg: 'XML declaration allowed only at the start of the document.'}};
} else if (xmlData[i] == '?' && xmlData[i + 1] == '>') {
//check if valid attribut string
i++;
break;
} else {
continue;
}
}
}
return i;
}
function readCommentAndCDATA(xmlData, i) {
if (xmlData.length > i + 5 && xmlData[i + 1] === '-' && xmlData[i + 2] === '-') {
//comment
for (i += 3; i < xmlData.length; i++) {
if (xmlData[i] === '-' && xmlData[i + 1] === '-' && xmlData[i + 2] === '>') {
i += 2;
break;
}
}
} else if (
xmlData.length > i + 8 &&
xmlData[i + 1] === 'D' &&
xmlData[i + 2] === 'O' &&
xmlData[i + 3] === 'C' &&
xmlData[i + 4] === 'T' &&
xmlData[i + 5] === 'Y' &&
xmlData[i + 6] === 'P' &&
xmlData[i + 7] === 'E'
) {
let angleBracketsCount = 1;
for (i += 8; i < xmlData.length; i++) {
if (xmlData[i] === '<') {
angleBracketsCount++;
} else if (xmlData[i] === '>') {
angleBracketsCount--;
if (angleBracketsCount === 0) {
break;
}
}
}
} else if (
xmlData.length > i + 9 &&
xmlData[i + 1] === '[' &&
xmlData[i + 2] === 'C' &&
xmlData[i + 3] === 'D' &&
xmlData[i + 4] === 'A' &&
xmlData[i + 5] === 'T' &&
xmlData[i + 6] === 'A' &&
xmlData[i + 7] === '['
) {
for (i += 8; i < xmlData.length; i++) {
if (xmlData[i] === ']' && xmlData[i + 1] === ']' && xmlData[i + 2] === '>') {
i += 2;
break;
}
}
}
return i;
}
var doubleQuote = '"';
var singleQuote = "'";
/**
* Keep reading xmlData until '<' is found outside the attribute value.
* @param {string} xmlData
* @param {number} i
*/
function readAttributeStr(xmlData, i) {
let attrStr = '';
let startChar = '';
for (; i < xmlData.length; i++) {
if (xmlData[i] === doubleQuote || xmlData[i] === singleQuote) {
if (startChar === '') {
startChar = xmlData[i];
} else if (startChar !== xmlData[i]) {
//if vaue is enclosed with double quote then single quotes are allowed inside the value and vice versa
continue;
} else {
startChar = '';
}
} else if (xmlData[i] === '>') {
if (startChar === '') {
break;
}
}
attrStr += xmlData[i];
}
if (startChar !== '') {
return false;
}
return {value: attrStr, index: i};
}
/**
* Select all the attributes whether valid or invalid.
*/
const validAttrStrRegxp = new RegExp('(\\s*)([^\\s=]+)(\\s*=)?(\\s*([\'"])(([\\s\\S])*?)\\5)?', 'g');
//attr, ="sd", a="amit's", a="sd"b="saf", ab cd=""
function validateAttributeString(attrStr, options, regxAttrName) {
//console.log("start:"+attrStr+":end");
//if(attrStr.trim().length === 0) return true; //empty string
const matches = util.getAllMatches(attrStr, validAttrStrRegxp);
const attrNames = {};
for (let i = 0; i < matches.length; i++) {
//console.log(matches[i]);
if (matches[i][1].length === 0) {
//nospace before attribute name: a="sd"b="saf"
return {err: {code: 'InvalidAttr', msg: 'attribute ' + matches[i][2] + ' has no space in starting.'}};
} else if (matches[i][3] === undefined && !options.allowBooleanAttributes) {
//independent attribute: ab
return {err: {code: 'InvalidAttr', msg: 'boolean attribute ' + matches[i][2] + ' is not allowed.'}};
}
/* else if(matches[i][6] === undefined){//attribute without value: ab=
return { err: { code:"InvalidAttr",msg:"attribute " + matches[i][2] + " has no value assigned."}};
} */
const attrName = matches[i][2];
if (!validateAttrName(attrName, regxAttrName)) {
return {err: {code: 'InvalidAttr', msg: 'attribute ' + attrName + ' is an invalid name.'}};
}
if (!attrNames.hasOwnProperty(attrName)) {
//check for duplicate attribute.
attrNames[attrName] = 1;
} else {
return {err: {code: 'InvalidAttr', msg: 'attribute ' + attrName + ' is repeated.'}};
}
}
return true;
}
// const validAttrRegxp = /^[_a-zA-Z][\w\-.:]*$/;
function validateAttrName(attrName, regxAttrName) {
// const validAttrRegxp = new RegExp(regxAttrName);
return util.doesMatch(attrName, regxAttrName);
}
//const startsWithXML = new RegExp("^[Xx][Mm][Ll]");
// startsWith = /^([a-zA-Z]|_)[\w.\-_:]*/;
function validateTagName(tagname, regxTagName) {
/*if(util.doesMatch(tagname,startsWithXML)) return false;
else*/
return !util.doesNotMatch(tagname, regxTagName);
}

17
node_modules/fast-xml-parser/src/xmlNode.js generated vendored Normal file
View File

@ -0,0 +1,17 @@
'use strict';
module.exports = function(tagname, parent, val) {
this.tagname = tagname;
this.parent = parent;
this.child = {}; //child tags
this.attrsMap = {}; //attributes map
this.val = val; //text only
this.addChild = function(child) {
if (Array.isArray(this.child[child.tagname])) {
//already presents
this.child[child.tagname].push(child);
} else {
this.child[child.tagname] = [child];
}
};
};

251
node_modules/fast-xml-parser/src/xmlstr2xmlnode.js generated vendored Normal file
View File

@ -0,0 +1,251 @@
'use strict';
const util = require('./util');
const buildOptions = require('./util').buildOptions;
const xmlNode = require('./xmlNode');
const TagType = {OPENING: 1, CLOSING: 2, SELF: 3, CDATA: 4};
let regx =
'<((!\\[CDATA\\[([\\s\\S]*?)(]]>))|(([\\w:\\-._]*:)?([\\w:\\-._]+))([^>]*)>|((\\/)(([\\w:\\-._]*:)?([\\w:\\-._]+))\\s*>))([^<]*)';
//const tagsRegx = new RegExp("<(\\/?[\\w:\\-\._]+)([^>]*)>(\\s*"+cdataRegx+")*([^<]+)?","g");
//const tagsRegx = new RegExp("<(\\/?)((\\w*:)?([\\w:\\-\._]+))([^>]*)>([^<]*)("+cdataRegx+"([^<]*))*([^<]+)?","g");
//polyfill
if (!Number.parseInt && window.parseInt) {
Number.parseInt = window.parseInt;
}
if (!Number.parseFloat && window.parseFloat) {
Number.parseFloat = window.parseFloat;
}
const defaultOptions = {
attributeNamePrefix: '@_',
attrNodeName: false,
textNodeName: '#text',
ignoreAttributes: true,
ignoreNameSpace: false,
allowBooleanAttributes: false, //a tag can have attributes without any value
//ignoreRootElement : false,
parseNodeValue: true,
parseAttributeValue: false,
arrayMode: false,
trimValues: true, //Trim string values of tag and attributes
cdataTagName: false,
cdataPositionChar: '\\c',
localeRange: '',
tagValueProcessor: function(a) {
return a;
},
attrValueProcessor: function(a) {
return a;
},
stopNodes: []
//decodeStrict: false,
};
exports.defaultOptions = defaultOptions;
const props = [
'attributeNamePrefix',
'attrNodeName',
'textNodeName',
'ignoreAttributes',
'ignoreNameSpace',
'allowBooleanAttributes',
'parseNodeValue',
'parseAttributeValue',
'arrayMode',
'trimValues',
'cdataTagName',
'cdataPositionChar',
'localeRange',
'tagValueProcessor',
'attrValueProcessor',
'parseTrueNumberOnly',
'stopNodes'
];
exports.props = props;
const getTraversalObj = function(xmlData, options) {
options = buildOptions(options, defaultOptions, props);
//xmlData = xmlData.replace(/\r?\n/g, " ");//make it single line
xmlData = xmlData.replace(/<!--[\s\S]*?-->/g, ''); //Remove comments
const xmlObj = new xmlNode('!xml');
let currentNode = xmlObj;
regx = regx.replace(/\[\\w/g, '[' + options.localeRange + '\\w');
const tagsRegx = new RegExp(regx, 'g');
let tag = tagsRegx.exec(xmlData);
let nextTag = tagsRegx.exec(xmlData);
while (tag) {
const tagType = checkForTagType(tag);
if (tagType === TagType.CLOSING) {
//add parsed data to parent node
if (currentNode.parent && tag[14]) {
currentNode.parent.val = util.getValue(currentNode.parent.val) + '' + processTagValue(tag[14], options);
}
if (options.stopNodes.length && options.stopNodes.includes(currentNode.tagname)) {
currentNode.child = []
if (currentNode.attrsMap == undefined) { currentNode.attrsMap = {}}
currentNode.val = xmlData.substr(currentNode.startIndex + 1, tag.index - currentNode.startIndex - 1)
}
currentNode = currentNode.parent;
} else if (tagType === TagType.CDATA) {
if (options.cdataTagName) {
//add cdata node
const childNode = new xmlNode(options.cdataTagName, currentNode, tag[3]);
childNode.attrsMap = buildAttributesMap(tag[8], options);
currentNode.addChild(childNode);
//for backtracking
currentNode.val = util.getValue(currentNode.val) + options.cdataPositionChar;
//add rest value to parent node
if (tag[14]) {
currentNode.val += processTagValue(tag[14], options);
}
} else {
currentNode.val = (currentNode.val || '') + (tag[3] || '') + processTagValue(tag[14], options);
}
} else if (tagType === TagType.SELF) {
if (currentNode && tag[14]) {
currentNode.val = util.getValue(currentNode.val) + '' + processTagValue(tag[14], options);
}
const childNode = new xmlNode(options.ignoreNameSpace ? tag[7] : tag[5], currentNode, '');
if (tag[8] && tag[8].length > 0) {
tag[8] = tag[8].substr(0, tag[8].length - 1);
}
childNode.attrsMap = buildAttributesMap(tag[8], options);
currentNode.addChild(childNode);
} else {
//TagType.OPENING
const childNode = new xmlNode(
options.ignoreNameSpace ? tag[7] : tag[5],
currentNode,
processTagValue(tag[14], options)
);
if (options.stopNodes.length && options.stopNodes.includes(childNode.tagname)) {
childNode.startIndex=tag.index + tag[1].length
}
childNode.attrsMap = buildAttributesMap(tag[8], options);
currentNode.addChild(childNode);
currentNode = childNode;
}
tag = nextTag;
nextTag = tagsRegx.exec(xmlData);
}
return xmlObj;
};
function processTagValue(val, options) {
if (val) {
if (options.trimValues) {
val = val.trim();
}
val = options.tagValueProcessor(val);
val = parseValue(val, options.parseNodeValue, options.parseTrueNumberOnly);
}
return val;
}
function checkForTagType(match) {
if (match[4] === ']]>') {
return TagType.CDATA;
} else if (match[10] === '/') {
return TagType.CLOSING;
} else if (typeof match[8] !== 'undefined' && match[8].substr(match[8].length - 1) === '/') {
return TagType.SELF;
} else {
return TagType.OPENING;
}
}
function resolveNameSpace(tagname, options) {
if (options.ignoreNameSpace) {
const tags = tagname.split(':');
const prefix = tagname.charAt(0) === '/' ? '/' : '';
if (tags[0] === 'xmlns') {
return '';
}
if (tags.length === 2) {
tagname = prefix + tags[1];
}
}
return tagname;
}
function parseValue(val, shouldParse, parseTrueNumberOnly) {
if (shouldParse && typeof val === 'string') {
let parsed;
if (val.trim() === '' || isNaN(val)) {
parsed = val === 'true' ? true : val === 'false' ? false : val;
} else {
if (val.indexOf('0x') !== -1) {
//support hexa decimal
parsed = Number.parseInt(val, 16);
} else if (val.indexOf('.') !== -1) {
parsed = Number.parseFloat(val);
} else {
parsed = Number.parseInt(val, 10);
}
if (parseTrueNumberOnly) {
parsed = String(parsed) === val ? parsed : val;
}
}
return parsed;
} else {
if (util.isExist(val)) {
return val;
} else {
return '';
}
}
}
//TODO: change regex to capture NS
//const attrsRegx = new RegExp("([\\w\\-\\.\\:]+)\\s*=\\s*(['\"])((.|\n)*?)\\2","gm");
const attrsRegx = new RegExp('([^\\s=]+)\\s*(=\\s*([\'"])(.*?)\\3)?', 'g');
function buildAttributesMap(attrStr, options) {
if (!options.ignoreAttributes && typeof attrStr === 'string') {
attrStr = attrStr.replace(/\r?\n/g, ' ');
//attrStr = attrStr || attrStr.trim();
const matches = util.getAllMatches(attrStr, attrsRegx);
const len = matches.length; //don't make it inline
const attrs = {};
for (let i = 0; i < len; i++) {
const attrName = resolveNameSpace(matches[i][1], options);
if (attrName.length) {
if (matches[i][4] !== undefined) {
if (options.trimValues) {
matches[i][4] = matches[i][4].trim();
}
matches[i][4] = options.attrValueProcessor(matches[i][4]);
attrs[options.attributeNamePrefix + attrName] = parseValue(
matches[i][4],
options.parseAttributeValue,
options.parseTrueNumberOnly
);
} else if (options.allowBooleanAttributes) {
attrs[options.attributeNamePrefix + attrName] = true;
}
}
}
if (!Object.keys(attrs).length) {
return;
}
if (options.attrNodeName) {
const attrCollection = {};
attrCollection[options.attrNodeName] = attrs;
return attrCollection;
}
return attrs;
}
}
exports.getTraversalObj = getTraversalObj;

5
node_modules/fast-xml-parser/tasks/postinstall.js generated vendored Normal file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env node
const msg = '\u001b[96m\u001b[1mLove fast-xml-parser? Check \u001b[32mhttps://amitkumargupta.work \u001b[96m\u001b[1mfor more projects and contribution.\u001b[0m\n';
console.log(msg)

5236
node_modules/fast-xml-parser/yarn.lock generated vendored Normal file

File diff suppressed because it is too large Load Diff