@loaders.gl/xml 4.2.0-alpha.4 → 4.2.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.dev.js +209 -154
- package/dist/dist.min.js +23 -0
- package/dist/html-loader.d.ts +1 -1
- package/dist/html-loader.d.ts.map +1 -1
- package/dist/html-loader.js +31 -20
- package/dist/index.cjs +157 -140
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +8 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/lib/parsers/parse-xml.d.ts +1 -1
- package/dist/lib/parsers/parse-xml.d.ts.map +1 -1
- package/dist/lib/parsers/parse-xml.js +48 -34
- package/dist/lib/parsers/streaming-xml-parser.d.ts +1 -1
- package/dist/lib/parsers/streaming-xml-parser.d.ts.map +1 -1
- package/dist/lib/parsers/streaming-xml-parser.js +94 -101
- package/dist/lib/xml-utils/uncapitalize.js +24 -12
- package/dist/lib/xml-utils/xml-utils.js +24 -10
- package/dist/sax-ts/sax.js +1396 -1235
- package/dist/xml-loader.d.ts +1 -1
- package/dist/xml-loader.d.ts.map +1 -1
- package/dist/xml-loader.js +33 -28
- package/package.json +10 -7
- package/dist/html-loader.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/parsers/parse-xml.js.map +0 -1
- package/dist/lib/parsers/streaming-xml-parser.js.map +0 -1
- package/dist/lib/xml-utils/uncapitalize.js.map +0 -1
- package/dist/lib/xml-utils/xml-utils.js.map +0 -1
- package/dist/sax-ts/sax.js.map +0 -1
- package/dist/xml-loader.js.map +0 -1
package/dist/dist.min.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
2
|
+
if (typeof exports === 'object' && typeof module === 'object')
|
|
3
|
+
module.exports = factory();
|
|
4
|
+
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
|
+
else if (typeof exports === 'object') exports['loaders'] = factory();
|
|
6
|
+
else root['loaders'] = factory();})(globalThis, function () {
|
|
7
|
+
"use strict";var __exports__=(()=>{var Ut=Object.create;var C=Object.defineProperty;var vt=Object.getOwnPropertyDescriptor;var Gt=Object.getOwnPropertyNames;var $t=Object.getPrototypeOf,qt=Object.prototype.hasOwnProperty;var Wt=(e,t,i)=>t in e?C(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var m=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),kt=(e,t)=>{for(var i in t)C(e,i,{get:t[i],enumerable:!0})},B=(e,t,i,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Gt(t))!qt.call(e,r)&&r!==i&&C(e,r,{get:()=>t[r],enumerable:!(s=vt(t,r))||s.enumerable});return e},M=(e,t,i)=>(B(e,t,"default"),i&&B(i,t,"default")),Z=(e,t,i)=>(i=e!=null?Ut($t(e)):{},B(t||!e||!e.__esModule?C(i,"default",{value:e,enumerable:!0}):i,e)),Yt=e=>B(C({},"__esModule",{value:!0}),e);var j=(e,t,i)=>(Wt(e,typeof t!="symbol"?t+"":t,i),i);var D=m((cs,J)=>{J.exports=globalThis.loaders});var R=m(E=>{"use strict";var et=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",Zt=et+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",st="["+et+"]["+Zt+"]*",jt=new RegExp("^"+st+"$"),Jt=function(e,t){let i=[],s=t.exec(e);for(;s;){let r=[];r.startIndex=t.lastIndex-s[0].length;let n=s.length;for(let h=0;h<n;h++)r.push(s[h]);i.push(r),s=t.exec(e)}return i},Dt=function(e){let t=jt.exec(e);return!(t===null||typeof t>"u")};E.isExist=function(e){return typeof e<"u"};E.isEmptyObject=function(e){return Object.keys(e).length===0};E.merge=function(e,t,i){if(t){let s=Object.keys(t),r=s.length;for(let n=0;n<r;n++)i==="strict"?e[s[n]]=[t[s[n]]]:e[s[n]]=t[s[n]]}};E.getValue=function(e){return E.isExist(e)?e:""};E.isName=Dt;E.getAllMatches=Jt;E.nameRegexp=st});var G=m(at=>{"use strict";var v=R(),te={allowBooleanAttributes:!1,unpairedTags:[]};at.validate=function(e,t){t=Object.assign({},te,t);let i=[],s=!1,r=!1;e[0]==="\uFEFF"&&(e=e.substr(1));for(let n=0;n<e.length;n++)if(e[n]==="<"&&e[n+1]==="?"){if(n+=2,n=rt(e,n),n.err)return n}else if(e[n]==="<"){let h=n;if(n++,e[n]==="!"){n=nt(e,n);continue}else{let a=!1;e[n]==="/"&&(a=!0,n++);let o="";for(;n<e.length&&e[n]!==">"&&e[n]!==" "&&e[n]!==" "&&e[n]!==`
|
|
8
|
+
`&&e[n]!=="\r";n++)o+=e[n];if(o=o.trim(),o[o.length-1]==="/"&&(o=o.substring(0,o.length-1),n--),!he(o)){let f;return o.trim().length===0?f="Invalid space after '<'.":f="Tag '"+o+"' is an invalid name.",d("InvalidTag",f,T(e,n))}let c=ie(e,n);if(c===!1)return d("InvalidAttr","Attributes for '"+o+"' have open quote.",T(e,n));let u=c.value;if(n=c.index,u[u.length-1]==="/"){let f=n-u.length;u=u.substring(0,u.length-1);let g=ot(u,t);if(g===!0)s=!0;else return d(g.err.code,g.err.msg,T(e,f+g.err.line))}else if(a)if(c.tagClosed){if(u.trim().length>0)return d("InvalidTag","Closing tag '"+o+"' can't have attributes or invalid starting.",T(e,h));{let f=i.pop();if(o!==f.tagName){let g=T(e,f.tagStartPos);return d("InvalidTag","Expected closing tag '"+f.tagName+"' (opened in line "+g.line+", col "+g.col+") instead of closing tag '"+o+"'.",T(e,h))}i.length==0&&(r=!0)}}else return d("InvalidTag","Closing tag '"+o+"' doesn't have proper closing.",T(e,n));else{let f=ot(u,t);if(f!==!0)return d(f.err.code,f.err.msg,T(e,n-u.length+f.err.line));if(r===!0)return d("InvalidXml","Multiple possible root nodes found.",T(e,n));t.unpairedTags.indexOf(o)!==-1||i.push({tagName:o,tagStartPos:h}),s=!0}for(n++;n<e.length;n++)if(e[n]==="<")if(e[n+1]==="!"){n++,n=nt(e,n);continue}else if(e[n+1]==="?"){if(n=rt(e,++n),n.err)return n}else break;else if(e[n]==="&"){let f=oe(e,n);if(f==-1)return d("InvalidChar","char '&' is not expected.",T(e,n));n=f}else if(r===!0&&!it(e[n]))return d("InvalidXml","Extra text at the end",T(e,n));e[n]==="<"&&n--}}else{if(it(e[n]))continue;return d("InvalidChar","char '"+e[n]+"' is not expected.",T(e,n))}if(s){if(i.length==1)return d("InvalidTag","Unclosed tag '"+i[0].tagName+"'.",T(e,i[0].tagStartPos));if(i.length>0)return d("InvalidXml","Invalid '"+JSON.stringify(i.map(n=>n.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return d("InvalidXml","Start tag expected.",1);return!0};function it(e){return e===" "||e===" "||e===`
|
|
9
|
+
`||e==="\r"}function rt(e,t){let i=t;for(;t<e.length;t++)if(e[t]=="?"||e[t]==" "){let s=e.substr(i,t-i);if(t>5&&s==="xml")return d("InvalidXml","XML declaration allowed only at the start of the document.",T(e,t));if(e[t]=="?"&&e[t+1]==">"){t++;break}else continue}return t}function nt(e,t){if(e.length>t+5&&e[t+1]==="-"&&e[t+2]==="-"){for(t+=3;t<e.length;t++)if(e[t]==="-"&&e[t+1]==="-"&&e[t+2]===">"){t+=2;break}}else if(e.length>t+8&&e[t+1]==="D"&&e[t+2]==="O"&&e[t+3]==="C"&&e[t+4]==="T"&&e[t+5]==="Y"&&e[t+6]==="P"&&e[t+7]==="E"){let i=1;for(t+=8;t<e.length;t++)if(e[t]==="<")i++;else if(e[t]===">"&&(i--,i===0))break}else if(e.length>t+9&&e[t+1]==="["&&e[t+2]==="C"&&e[t+3]==="D"&&e[t+4]==="A"&&e[t+5]==="T"&&e[t+6]==="A"&&e[t+7]==="["){for(t+=8;t<e.length;t++)if(e[t]==="]"&&e[t+1]==="]"&&e[t+2]===">"){t+=2;break}}return t}var ee='"',se="'";function ie(e,t){let i="",s="",r=!1;for(;t<e.length;t++){if(e[t]===ee||e[t]===se)s===""?s=e[t]:s!==e[t]||(s="");else if(e[t]===">"&&s===""){r=!0;break}i+=e[t]}return s!==""?!1:{value:i,index:t,tagClosed:r}}var re=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function ot(e,t){let i=v.getAllMatches(e,re),s={};for(let r=0;r<i.length;r++){if(i[r][1].length===0)return d("InvalidAttr","Attribute '"+i[r][2]+"' has no space in starting.",_(i[r]));if(i[r][3]!==void 0&&i[r][4]===void 0)return d("InvalidAttr","Attribute '"+i[r][2]+"' is without value.",_(i[r]));if(i[r][3]===void 0&&!t.allowBooleanAttributes)return d("InvalidAttr","boolean attribute '"+i[r][2]+"' is not allowed.",_(i[r]));let n=i[r][2];if(!ae(n))return d("InvalidAttr","Attribute '"+n+"' is an invalid name.",_(i[r]));if(!s.hasOwnProperty(n))s[n]=1;else return d("InvalidAttr","Attribute '"+n+"' is repeated.",_(i[r]))}return!0}function ne(e,t){let i=/\d/;for(e[t]==="x"&&(t++,i=/[\da-fA-F]/);t<e.length;t++){if(e[t]===";")return t;if(!e[t].match(i))break}return-1}function oe(e,t){if(t++,e[t]===";")return-1;if(e[t]==="#")return t++,ne(e,t);let i=0;for(;t<e.length;t++,i++)if(!(e[t].match(/\w/)&&i<20)){if(e[t]===";")break;return-1}return t}function d(e,t,i){return{err:{code:e,msg:t,line:i.line||i,col:i.col}}}function ae(e){return v.isName(e)}function he(e){return v.isName(e)}function T(e,t){let i=e.substring(0,t).split(/\r?\n/);return{line:i.length,col:i[i.length-1].length+1}}function _(e){return e.startIndex+e[1].length}});var ct=m($=>{var ht={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(e,t,i){return e}},ce=function(e){return Object.assign({},ht,e)};$.buildOptions=ce;$.defaultOptions=ht});var ut=m((Ns,lt)=>{"use strict";var q=class{constructor(t){this.tagname=t,this.child=[],this[":@"]={}}add(t,i){t==="__proto__"&&(t="#__proto__"),this.child.push({[t]:i})}addChild(t){t.tagname==="__proto__"&&(t.tagname="#__proto__"),t[":@"]&&Object.keys(t[":@"]).length>0?this.child.push({[t.tagname]:t.child,[":@"]:t[":@"]}):this.child.push({[t.tagname]:t.child})}};lt.exports=q});var pt=m((Ts,ft)=>{var le=R();function ue(e,t){let i={};if(e[t+3]==="O"&&e[t+4]==="C"&&e[t+5]==="T"&&e[t+6]==="Y"&&e[t+7]==="P"&&e[t+8]==="E"){t=t+9;let s=1,r=!1,n=!1,h="";for(;t<e.length;t++)if(e[t]==="<"&&!n){if(r&&de(e,t))t+=7,[entityName,val,t]=fe(e,t+1),val.indexOf("&")===-1&&(i[me(entityName)]={regx:RegExp(`&${entityName};`,"g"),val});else if(r&&ge(e,t))t+=8;else if(r&&Ne(e,t))t+=8;else if(r&&Te(e,t))t+=9;else if(pe)n=!0;else throw new Error("Invalid DOCTYPE");s++,h=""}else if(e[t]===">"){if(n?e[t-1]==="-"&&e[t-2]==="-"&&(n=!1,s--):s--,s===0)break}else e[t]==="["?r=!0:h+=e[t];if(s!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:i,i:t}}function fe(e,t){let i="";for(;t<e.length&&e[t]!=="'"&&e[t]!=='"';t++)i+=e[t];if(i=i.trim(),i.indexOf(" ")!==-1)throw new Error("External entites are not supported");let s=e[t++],r="";for(;t<e.length&&e[t]!==s;t++)r+=e[t];return[i,r,t]}function pe(e,t){return e[t+1]==="!"&&e[t+2]==="-"&&e[t+3]==="-"}function de(e,t){return e[t+1]==="!"&&e[t+2]==="E"&&e[t+3]==="N"&&e[t+4]==="T"&&e[t+5]==="I"&&e[t+6]==="T"&&e[t+7]==="Y"}function ge(e,t){return e[t+1]==="!"&&e[t+2]==="E"&&e[t+3]==="L"&&e[t+4]==="E"&&e[t+5]==="M"&&e[t+6]==="E"&&e[t+7]==="N"&&e[t+8]==="T"}function Ne(e,t){return e[t+1]==="!"&&e[t+2]==="A"&&e[t+3]==="T"&&e[t+4]==="T"&&e[t+5]==="L"&&e[t+6]==="I"&&e[t+7]==="S"&&e[t+8]==="T"}function Te(e,t){return e[t+1]==="!"&&e[t+2]==="N"&&e[t+3]==="O"&&e[t+4]==="T"&&e[t+5]==="A"&&e[t+6]==="T"&&e[t+7]==="I"&&e[t+8]==="O"&&e[t+9]==="N"}function me(e){if(le.isName(e))return e;throw new Error(`Invalid entity name ${e}`)}ft.exports=ue});var gt=m((ms,dt)=>{var Ee=/^[-+]?0x[a-fA-F0-9]+$/,be=/^([\-\+])?(0*)(\.[0-9]+([eE]\-?[0-9]+)?|[0-9]+(\.[0-9]+([eE]\-?[0-9]+)?)?)$/;!Number.parseInt&&window.parseInt&&(Number.parseInt=window.parseInt);!Number.parseFloat&&window.parseFloat&&(Number.parseFloat=window.parseFloat);var Se={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function Ae(e,t={}){if(t=Object.assign({},Se,t),!e||typeof e!="string")return e;let i=e.trim();if(t.skipLike!==void 0&&t.skipLike.test(i))return e;if(t.hex&&Ee.test(i))return Number.parseInt(i,16);{let s=be.exec(i);if(s){let r=s[1],n=s[2],h=Ie(s[3]),a=s[4]||s[6];if(!t.leadingZeros&&n.length>0&&r&&i[2]!==".")return e;if(!t.leadingZeros&&n.length>0&&!r&&i[1]!==".")return e;{let o=Number(i),c=""+o;return c.search(/[eE]/)!==-1||a?t.eNotation?o:e:i.indexOf(".")!==-1?c==="0"&&h===""||c===h||r&&c==="-"+h?o:e:n?h===c||r+h===c?o:e:i===c||i===r+c?o:e}}else return e}}function Ie(e){return e&&e.indexOf(".")!==-1&&(e=e.replace(/0+$/,""),e==="."?e="0":e[0]==="."?e="0"+e:e[e.length-1]==="."&&(e=e.substr(0,e.length-1))),e}dt.exports=Ae});var Tt=m((bs,Nt)=>{"use strict";var X=R(),P=ut(),ye=pt(),xe=gt(),Es="<((!\\[CDATA\\[([\\s\\S]*?)(]]>))|((NAME:)?(NAME))([^>]*)>|((\\/)(NAME)\\s*>))([^<]*)".replace(/NAME/g,X.nameRegexp),W=class{constructor(t){this.options=t,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"\xA2"},pound:{regex:/&(pound|#163);/g,val:"\xA3"},yen:{regex:/&(yen|#165);/g,val:"\xA5"},euro:{regex:/&(euro|#8364);/g,val:"\u20AC"},copyright:{regex:/&(copy|#169);/g,val:"\xA9"},reg:{regex:/&(reg|#174);/g,val:"\xAE"},inr:{regex:/&(inr|#8377);/g,val:"\u20B9"}},this.addExternalEntities=Ce,this.parseXml=we,this.parseTextData=Fe,this.resolveNameSpace=Oe,this.buildAttributesMap=Pe,this.isItStopNode=Re,this.replaceEntitiesValue=Be,this.readStopNodeData=Ue,this.saveTextToParentTag=Me,this.addChild=Le}};function Ce(e){let t=Object.keys(e);for(let i=0;i<t.length;i++){let s=t[i];this.lastEntities[s]={regex:new RegExp("&"+s+";","g"),val:e[s]}}}function Fe(e,t,i,s,r,n,h){if(e!==void 0&&(this.options.trimValues&&!s&&(e=e.trim()),e.length>0)){h||(e=this.replaceEntitiesValue(e));let a=this.options.tagValueProcessor(t,e,i,r,n);return a==null?e:typeof a!=typeof e||a!==e?a:this.options.trimValues?Y(e,this.options.parseTagValue,this.options.numberParseOptions):e.trim()===e?Y(e,this.options.parseTagValue,this.options.numberParseOptions):e}}function Oe(e){if(this.options.removeNSPrefix){let t=e.split(":"),i=e.charAt(0)==="/"?"/":"";if(t[0]==="xmlns")return"";t.length===2&&(e=i+t[1])}return e}var _e=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function Pe(e,t,i){if(!this.options.ignoreAttributes&&typeof e=="string"){let s=X.getAllMatches(e,_e),r=s.length,n={};for(let h=0;h<r;h++){let a=this.resolveNameSpace(s[h][1]),o=s[h][4],c=this.options.attributeNamePrefix+a;if(a.length)if(this.options.transformAttributeName&&(c=this.options.transformAttributeName(c)),c==="__proto__"&&(c="#__proto__"),o!==void 0){this.options.trimValues&&(o=o.trim()),o=this.replaceEntitiesValue(o);let u=this.options.attributeValueProcessor(a,o,t);u==null?n[c]=o:typeof u!=typeof o||u!==o?n[c]=u:n[c]=Y(o,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(n[c]=!0)}if(!Object.keys(n).length)return;if(this.options.attributesGroupName){let h={};return h[this.options.attributesGroupName]=n,h}return n}}var we=function(e){e=e.replace(/\r\n?/g,`
|
|
10
|
+
`);let t=new P("!xml"),i=t,s="",r="";for(let n=0;n<e.length;n++)if(e[n]==="<")if(e[n+1]==="/"){let a=A(e,">",n,"Closing Tag is not closed."),o=e.substring(n+2,a).trim();if(this.options.removeNSPrefix){let f=o.indexOf(":");f!==-1&&(o=o.substr(f+1))}this.options.transformTagName&&(o=this.options.transformTagName(o)),i&&(s=this.saveTextToParentTag(s,i,r));let c=r.substring(r.lastIndexOf(".")+1);if(o&&this.options.unpairedTags.indexOf(o)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${o}>`);let u=0;c&&this.options.unpairedTags.indexOf(c)!==-1?(u=r.lastIndexOf(".",r.lastIndexOf(".")-1),this.tagsNodeStack.pop()):u=r.lastIndexOf("."),r=r.substring(0,u),i=this.tagsNodeStack.pop(),s="",n=a}else if(e[n+1]==="?"){let a=k(e,n,!1,"?>");if(!a)throw new Error("Pi Tag is not closed.");if(s=this.saveTextToParentTag(s,i,r),!(this.options.ignoreDeclaration&&a.tagName==="?xml"||this.options.ignorePiTags)){let o=new P(a.tagName);o.add(this.options.textNodeName,""),a.tagName!==a.tagExp&&a.attrExpPresent&&(o[":@"]=this.buildAttributesMap(a.tagExp,r,a.tagName)),this.addChild(i,o,r)}n=a.closeIndex+1}else if(e.substr(n+1,3)==="!--"){let a=A(e,"-->",n+4,"Comment is not closed.");if(this.options.commentPropName){let o=e.substring(n+4,a-2);s=this.saveTextToParentTag(s,i,r),i.add(this.options.commentPropName,[{[this.options.textNodeName]:o}])}n=a}else if(e.substr(n+1,2)==="!D"){let a=ye(e,n);this.docTypeEntities=a.entities,n=a.i}else if(e.substr(n+1,2)==="!["){let a=A(e,"]]>",n,"CDATA is not closed.")-2,o=e.substring(n+9,a);if(s=this.saveTextToParentTag(s,i,r),this.options.cdataPropName)i.add(this.options.cdataPropName,[{[this.options.textNodeName]:o}]);else{let c=this.parseTextData(o,i.tagname,r,!0,!1,!0);c==null&&(c=""),i.add(this.options.textNodeName,c)}n=a+2}else{let a=k(e,n,this.options.removeNSPrefix),o=a.tagName,c=a.tagExp,u=a.attrExpPresent,f=a.closeIndex;this.options.transformTagName&&(o=this.options.transformTagName(o)),i&&s&&i.tagname!=="!xml"&&(s=this.saveTextToParentTag(s,i,r,!1));let g=i;if(g&&this.options.unpairedTags.indexOf(g.tagname)!==-1&&(i=this.tagsNodeStack.pop(),r=r.substring(0,r.lastIndexOf("."))),o!==t.tagname&&(r+=r?"."+o:o),this.isItStopNode(this.options.stopNodes,r,o)){let p="";if(c.length>0&&c.lastIndexOf("/")===c.length-1)n=a.closeIndex;else if(this.options.unpairedTags.indexOf(o)!==-1)n=a.closeIndex;else{let x=this.readStopNodeData(e,o,f+1);if(!x)throw new Error(`Unexpected end of ${o}`);n=x.i,p=x.tagContent}let N=new P(o);o!==c&&u&&(N[":@"]=this.buildAttributesMap(c,r,o)),p&&(p=this.parseTextData(p,o,r,!0,u,!0,!0)),r=r.substr(0,r.lastIndexOf(".")),N.add(this.options.textNodeName,p),this.addChild(i,N,r)}else{if(c.length>0&&c.lastIndexOf("/")===c.length-1){o[o.length-1]==="/"?(o=o.substr(0,o.length-1),c=o):c=c.substr(0,c.length-1),this.options.transformTagName&&(o=this.options.transformTagName(o));let p=new P(o);o!==c&&u&&(p[":@"]=this.buildAttributesMap(c,r,o)),this.addChild(i,p,r),r=r.substr(0,r.lastIndexOf("."))}else{let p=new P(o);this.tagsNodeStack.push(i),o!==c&&u&&(p[":@"]=this.buildAttributesMap(c,r,o)),this.addChild(i,p,r),i=p}s="",n=f}}else s+=e[n];return t.child};function Le(e,t,i){let s=this.options.updateTag(t.tagname,i,t[":@"]);s===!1||(typeof s=="string"&&(t.tagname=s),e.addChild(t))}var Be=function(e){if(this.options.processEntities){for(let t in this.docTypeEntities){let i=this.docTypeEntities[t];e=e.replace(i.regx,i.val)}for(let t in this.lastEntities){let i=this.lastEntities[t];e=e.replace(i.regex,i.val)}if(this.options.htmlEntities)for(let t in this.htmlEntities){let i=this.htmlEntities[t];e=e.replace(i.regex,i.val)}e=e.replace(this.ampEntity.regex,this.ampEntity.val)}return e};function Me(e,t,i,s){return e&&(s===void 0&&(s=Object.keys(t.child).length===0),e=this.parseTextData(e,t.tagname,i,!1,t[":@"]?Object.keys(t[":@"]).length!==0:!1,s),e!==void 0&&e!==""&&t.add(this.options.textNodeName,e),e=""),e}function Re(e,t,i){let s="*."+i;for(let r in e){let n=e[r];if(s===n||t===n)return!0}return!1}function Ve(e,t,i=">"){let s,r="";for(let n=t;n<e.length;n++){let h=e[n];if(s)h===s&&(s="");else if(h==='"'||h==="'")s=h;else if(h===i[0])if(i[1]){if(e[n+1]===i[1])return{data:r,index:n}}else return{data:r,index:n};else h===" "&&(h=" ");r+=h}}function A(e,t,i,s){let r=e.indexOf(t,i);if(r===-1)throw new Error(s);return r+t.length-1}function k(e,t,i,s=">"){let r=Ve(e,t+1,s);if(!r)return;let n=r.data,h=r.index,a=n.search(/\s/),o=n,c=!0;if(a!==-1&&(o=n.substr(0,a).replace(/\s\s*$/,""),n=n.substr(a+1)),i){let u=o.indexOf(":");u!==-1&&(o=o.substr(u+1),c=o!==r.data.substr(u+1))}return{tagName:o,tagExp:n,closeIndex:h,attrExpPresent:c}}function Ue(e,t,i){let s=i,r=1;for(;i<e.length;i++)if(e[i]==="<")if(e[i+1]==="/"){let n=A(e,">",i,`${t} is not closed`);if(e.substring(i+2,n).trim()===t&&(r--,r===0))return{tagContent:e.substring(s,i),i:n};i=n}else if(e[i+1]==="?")i=A(e,"?>",i+1,"StopNode is not closed.");else if(e.substr(i+1,3)==="!--")i=A(e,"-->",i+3,"StopNode is not closed.");else if(e.substr(i+1,2)==="![")i=A(e,"]]>",i,"StopNode is not closed.")-2;else{let n=k(e,i,">");n&&((n&&n.tagName)===t&&n.tagExp[n.tagExp.length-1]!=="/"&&r++,i=n.closeIndex)}}function Y(e,t,i){if(t&&typeof e=="string"){let s=e.trim();return s==="true"?!0:s==="false"?!1:xe(e,i)}else return X.isExist(e)?e:""}Nt.exports=W});var bt=m(Et=>{"use strict";function ve(e,t){return mt(e,t)}function mt(e,t,i){let s,r={};for(let n=0;n<e.length;n++){let h=e[n],a=Ge(h),o="";if(i===void 0?o=a:o=i+"."+a,a===t.textNodeName)s===void 0?s=h[a]:s+=""+h[a];else{if(a===void 0)continue;if(h[a]){let c=mt(h[a],t,o),u=qe(c,t);h[":@"]?$e(c,h[":@"],o,t):Object.keys(c).length===1&&c[t.textNodeName]!==void 0&&!t.alwaysCreateTextNode?c=c[t.textNodeName]:Object.keys(c).length===0&&(t.alwaysCreateTextNode?c[t.textNodeName]="":c=""),r[a]!==void 0&&r.hasOwnProperty(a)?(Array.isArray(r[a])||(r[a]=[r[a]]),r[a].push(c)):t.isArray(a,o,u)?r[a]=[c]:r[a]=c}}}return typeof s=="string"?s.length>0&&(r[t.textNodeName]=s):s!==void 0&&(r[t.textNodeName]=s),r}function Ge(e){let t=Object.keys(e);for(let i=0;i<t.length;i++){let s=t[i];if(s!==":@")return s}}function $e(e,t,i,s){if(t){let r=Object.keys(t),n=r.length;for(let h=0;h<n;h++){let a=r[h];s.isArray(a,i+"."+a,!0,!0)?e[a]=[t[a]]:e[a]=t[a]}}}function qe(e,t){let{textNodeName:i}=t,s=Object.keys(e).length;return!!(s===0||s===1&&(e[i]||typeof e[i]=="boolean"||e[i]===0))}Et.prettify=ve});var At=m((As,St)=>{var{buildOptions:We}=ct(),ke=Tt(),{prettify:Ye}=bt(),Xe=G(),Q=class{constructor(t){this.externalEntities={},this.options=We(t)}parse(t,i){if(typeof t!="string")if(t.toString)t=t.toString();else throw new Error("XML data is accepted in String or Bytes[] form.");if(i){i===!0&&(i={});let n=Xe.validate(t,i);if(n!==!0)throw Error(`${n.err.msg}:${n.err.line}:${n.err.col}`)}let s=new ke(this.options);s.addExternalEntities(this.externalEntities);let r=s.parseXml(t);return this.options.preserveOrder||r===void 0?r:Ye(r,this.options)}addEntity(t,i){if(i.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(t.indexOf("&")!==-1||t.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");if(i==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[t]=i}};St.exports=Q});var Ft=m((Is,Ct)=>{var Qe=`
|
|
11
|
+
`;function He(e,t){let i="";return t.format&&t.indentBy.length>0&&(i=Qe),yt(e,t,"",i)}function yt(e,t,i,s){let r="",n=!1;for(let h=0;h<e.length;h++){let a=e[h],o=ze(a),c="";if(i.length===0?c=o:c=`${i}.${o}`,o===t.textNodeName){let N=a[o];Ke(c,t)||(N=t.tagValueProcessor(o,N),N=xt(N,t)),n&&(r+=s),r+=N,n=!1;continue}else if(o===t.cdataPropName){n&&(r+=s),r+=`<![CDATA[${a[o][0][t.textNodeName]}]]>`,n=!1;continue}else if(o===t.commentPropName){r+=s+`<!--${a[o][0][t.textNodeName]}-->`,n=!0;continue}else if(o[0]==="?"){let N=It(a[":@"],t),x=o==="?xml"?"":s,L=a[o][0][t.textNodeName];L=L.length!==0?" "+L:"",r+=x+`<${o}${L}${N}?>`,n=!0;continue}let u=s;u!==""&&(u+=t.indentBy);let f=It(a[":@"],t),g=s+`<${o}${f}`,p=yt(a[o],t,c,u);t.unpairedTags.indexOf(o)!==-1?t.suppressUnpairedNode?r+=g+">":r+=g+"/>":(!p||p.length===0)&&t.suppressEmptyNode?r+=g+"/>":p&&p.endsWith(">")?r+=g+`>${p}${s}</${o}>`:(r+=g+">",p&&s!==""&&(p.includes("/>")||p.includes("</"))?r+=s+t.indentBy+p+s:r+=p,r+=`</${o}>`),n=!0}return r}function ze(e){let t=Object.keys(e);for(let i=0;i<t.length;i++){let s=t[i];if(s!==":@")return s}}function It(e,t){let i="";if(e&&!t.ignoreAttributes)for(let s in e){let r=t.attributeValueProcessor(s,e[s]);r=xt(r,t),r===!0&&t.suppressBooleanAttributes?i+=` ${s.substr(t.attributeNamePrefix.length)}`:i+=` ${s.substr(t.attributeNamePrefix.length)}="${r}"`}return i}function Ke(e,t){e=e.substr(0,e.length-t.textNodeName.length-1);let i=e.substr(e.lastIndexOf(".")+1);for(let s in t.stopNodes)if(t.stopNodes[s]===e||t.stopNodes[s]==="*."+i)return!0;return!1}function xt(e,t){if(e&&e.length>0&&t.processEntities)for(let i=0;i<t.entities.length;i++){let s=t.entities[i];e=e.replace(s.regex,s.val)}return e}Ct.exports=He});var _t=m((ys,Ot)=>{"use strict";var Ze=Ft(),je={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&"},{regex:new RegExp(">","g"),val:">"},{regex:new RegExp("<","g"),val:"<"},{regex:new RegExp("'","g"),val:"'"},{regex:new RegExp('"',"g"),val:"""}],processEntities:!0,stopNodes:[],oneListGroup:!1};function b(e){this.options=Object.assign({},je,e),this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=ts),this.processTextOrObjNode=Je,this.options.format?(this.indentate=De,this.tagEndChar=`>
|
|
12
|
+
`,this.newLine=`
|
|
13
|
+
`):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}b.prototype.build=function(e){return this.options.preserveOrder?Ze(e,this.options):(Array.isArray(e)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(e={[this.options.arrayNodeName]:e}),this.j2x(e,0).val)};b.prototype.j2x=function(e,t){let i="",s="";for(let r in e)if(!(typeof e[r]>"u"))if(e[r]===null)r[0]==="?"?s+=this.indentate(t)+"<"+r+"?"+this.tagEndChar:s+=this.indentate(t)+"<"+r+"/"+this.tagEndChar;else if(e[r]instanceof Date)s+=this.buildTextValNode(e[r],r,"",t);else if(typeof e[r]!="object"){let n=this.isAttribute(r);if(n)i+=this.buildAttrPairStr(n,""+e[r]);else if(r===this.options.textNodeName){let h=this.options.tagValueProcessor(r,""+e[r]);s+=this.replaceEntitiesValue(h)}else s+=this.buildTextValNode(e[r],r,"",t)}else if(Array.isArray(e[r])){let n=e[r].length,h="";for(let a=0;a<n;a++){let o=e[r][a];typeof o>"u"||(o===null?r[0]==="?"?s+=this.indentate(t)+"<"+r+"?"+this.tagEndChar:s+=this.indentate(t)+"<"+r+"/"+this.tagEndChar:typeof o=="object"?this.options.oneListGroup?h+=this.j2x(o,t+1).val:h+=this.processTextOrObjNode(o,r,t):h+=this.buildTextValNode(o,r,"",t))}this.options.oneListGroup&&(h=this.buildObjectNode(h,r,"",t)),s+=h}else if(this.options.attributesGroupName&&r===this.options.attributesGroupName){let n=Object.keys(e[r]),h=n.length;for(let a=0;a<h;a++)i+=this.buildAttrPairStr(n[a],""+e[r][n[a]])}else s+=this.processTextOrObjNode(e[r],r,t);return{attrStr:i,val:s}};b.prototype.buildAttrPairStr=function(e,t){return t=this.options.attributeValueProcessor(e,""+t),t=this.replaceEntitiesValue(t),this.options.suppressBooleanAttributes&&t==="true"?" "+e:" "+e+'="'+t+'"'};function Je(e,t,i){let s=this.j2x(e,i+1);return e[this.options.textNodeName]!==void 0&&Object.keys(e).length===1?this.buildTextValNode(e[this.options.textNodeName],t,s.attrStr,i):this.buildObjectNode(s.val,t,s.attrStr,i)}b.prototype.buildObjectNode=function(e,t,i,s){if(e==="")return t[0]==="?"?this.indentate(s)+"<"+t+i+"?"+this.tagEndChar:this.indentate(s)+"<"+t+i+this.closeTag(t)+this.tagEndChar;{let r="</"+t+this.tagEndChar,n="";return t[0]==="?"&&(n="?",r=""),i&&e.indexOf("<")===-1?this.indentate(s)+"<"+t+i+n+">"+e+r:this.options.commentPropName!==!1&&t===this.options.commentPropName&&n.length===0?this.indentate(s)+`<!--${e}-->`+this.newLine:this.indentate(s)+"<"+t+i+n+this.tagEndChar+e+this.indentate(s)+r}};b.prototype.closeTag=function(e){let t="";return this.options.unpairedTags.indexOf(e)!==-1?this.options.suppressUnpairedNode||(t="/"):this.options.suppressEmptyNode?t="/":t=`></${e}`,t};b.prototype.buildTextValNode=function(e,t,i,s){if(this.options.cdataPropName!==!1&&t===this.options.cdataPropName)return this.indentate(s)+`<![CDATA[${e}]]>`+this.newLine;if(this.options.commentPropName!==!1&&t===this.options.commentPropName)return this.indentate(s)+`<!--${e}-->`+this.newLine;if(t[0]==="?")return this.indentate(s)+"<"+t+i+"?"+this.tagEndChar;{let r=this.options.tagValueProcessor(t,e);return r=this.replaceEntitiesValue(r),r===""?this.indentate(s)+"<"+t+i+this.closeTag(t)+this.tagEndChar:this.indentate(s)+"<"+t+i+">"+r+"</"+t+this.tagEndChar}};b.prototype.replaceEntitiesValue=function(e){if(e&&e.length>0&&this.options.processEntities)for(let t=0;t<this.options.entities.length;t++){let i=this.options.entities[t];e=e.replace(i.regex,i.val)}return e};function De(e){return this.options.indentBy.repeat(e)}function ts(e){return e.startsWith(this.options.attributeNamePrefix)?e.substr(this.attrPrefixLen):!1}Ot.exports=b});var wt=m((xs,Pt)=>{"use strict";var es=G(),ss=At(),is=_t();Pt.exports={XMLParser:ss,XMLValidator:es,XMLBuilder:is}});var w={};kt(w,{HTMLLoader:()=>Rt,SAXParser:()=>S,XMLLoader:()=>I,_uncapitalize:()=>U,_uncapitalizeKeys:()=>y,convertXMLFieldToArrayInPlace:()=>Vt,convertXMLValueToArray:()=>K});M(w,Z(D(),1));var tt={ontext:()=>{},onprocessinginstruction:()=>{},onsgmldeclaration:()=>{},ondoctype:()=>{},oncomment:()=>{},onopentagstart:()=>{},onattribute:()=>{},onopentag:()=>{},onclosetag:()=>{},onopencdata:()=>{},oncdata:()=>{},onclosecdata:()=>{},onerror:()=>{},onend:()=>{},onready:()=>{},onscript:()=>{},onopennamespace:()=>{},onclosenamespace:()=>{}},Xt={...tt,strict:!1,MAX_BUFFER_LENGTH:64*1024,lowercase:!1,lowercasetags:!1,noscript:!1,strictEntities:!1,xmlns:void 0,position:void 0,trim:void 0,normalize:void 0},Qt=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"],Ht=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"],F=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,V=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,zt=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,Kt=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,O={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830};Object.keys(O).forEach(e=>{let t=O[e];O[e]=typeof t=="number"?String.fromCharCode(t):t});var l=class{EVENTS=Qt;ENTITIES={...O};XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"};S=0;opt;trackPosition=!1;column=0;line=0;c="";error;q="";bufferCheckPosition;closed=!1;tags=[];looseCase="";closedRoot=!1;sawRoot=!1;strict=!1;tag;strictEntities;state;noscript=!1;attribList=[];ns;position=0;STATE={BEGIN:this.S++,BEGIN_WHITESPACE:this.S++,TEXT:this.S++,TEXT_ENTITY:this.S++,OPEN_WAKA:this.S++,SGML_DECL:this.S++,SGML_DECL_QUOTED:this.S++,DOCTYPE:this.S++,DOCTYPE_QUOTED:this.S++,DOCTYPE_DTD:this.S++,DOCTYPE_DTD_QUOTED:this.S++,COMMENT_STARTING:this.S++,COMMENT:this.S++,COMMENT_ENDING:this.S++,COMMENT_ENDED:this.S++,CDATA:this.S++,CDATA_ENDING:this.S++,CDATA_ENDING_2:this.S++,PROC_INST:this.S++,PROC_INST_BODY:this.S++,PROC_INST_ENDING:this.S++,OPEN_TAG:this.S++,OPEN_TAG_SLASH:this.S++,ATTRIB:this.S++,ATTRIB_NAME:this.S++,ATTRIB_NAME_SAW_WHITE:this.S++,ATTRIB_VALUE:this.S++,ATTRIB_VALUE_QUOTED:this.S++,ATTRIB_VALUE_CLOSED:this.S++,ATTRIB_VALUE_UNQUOTED:this.S++,ATTRIB_VALUE_ENTITY_Q:this.S++,ATTRIB_VALUE_ENTITY_U:this.S++,CLOSE_TAG:this.S++,CLOSE_TAG_SAW_WHITE:this.S++,SCRIPT:this.S++,SCRIPT_ENDING:this.S++};BUFFERS=Ht;CDATA="[CDATA[";DOCTYPE="DOCTYPE";XML_NAMESPACE="http://www.w3.org/XML/1998/namespace";XMLNS_NAMESPACE="http://www.w3.org/2000/xmlns/";rootNS={xml:this.XML_NAMESPACE,xmlns:this.XMLNS_NAMESPACE};comment;sgmlDecl;textNode="";tagName;doctype;procInstName;procInstBody;entity="";attribName;attribValue;cdata="";script="";startTagPosition=0;constructor(){this.S=0;for(let t in this.STATE)this.STATE.hasOwnProperty(t)&&(this.STATE[this.STATE[t]]=t);this.S=this.STATE}static charAt(t,i){let s="";return i<t.length&&(s=t.charAt(i)),s}static isWhitespace(t){return t===" "||t===`
|
|
14
|
+
`||t==="\r"||t===" "}static isQuote(t){return t==='"'||t==="'"}static isAttribEnd(t){return t===">"||l.isWhitespace(t)}static isMatch(t,i){return t.test(i)}static notMatch(t,i){return!l.isMatch(t,i)}static qname(t,i){let r=t.indexOf(":")<0?["",t]:t.split(":"),n=r[0],h=r[1];return i&&t==="xmlns"&&(n="xmlns",h=""),{prefix:n,local:h}}write(t){if(this.error)throw this.error;if(this.closed)return this.errorFunction("Cannot write after close. Assign an onready handler.");if(t===null)return this.end();typeof t=="object"&&(t=t.toString());let i=0,s;for(;s=l.charAt(t,i++),this.c=s,!!s;)switch(this.trackPosition&&(this.position++,s===`
|
|
15
|
+
`?(this.line++,this.column=0):this.column++),this.state){case this.S.BEGIN:if(this.state=this.S.BEGIN_WHITESPACE,s==="\uFEFF")continue;this.beginWhiteSpace(s);continue;case this.S.BEGIN_WHITESPACE:this.beginWhiteSpace(s);continue;case this.S.TEXT:if(this.sawRoot&&!this.closedRoot){let h=i-1;for(;s&&s!=="<"&&s!=="&";)s=l.charAt(t,i++),s&&this.trackPosition&&(this.position++,s===`
|
|
16
|
+
`?(this.line++,this.column=0):this.column++);this.textNode+=t.substring(h,i-1)}s==="<"&&!(this.sawRoot&&this.closedRoot&&!this.strict)?(this.state=this.S.OPEN_WAKA,this.startTagPosition=this.position):(!l.isWhitespace(s)&&(!this.sawRoot||this.closedRoot)&&this.strictFail("Text data outside of root node."),s==="&"?this.state=this.S.TEXT_ENTITY:this.textNode+=s);continue;case this.S.SCRIPT:s==="<"?this.state=this.S.SCRIPT_ENDING:this.script+=s;continue;case this.S.SCRIPT_ENDING:s==="/"?this.state=this.S.CLOSE_TAG:(this.script+=`<${s}`,this.state=this.S.SCRIPT);continue;case this.S.OPEN_WAKA:if(s==="!")this.state=this.S.SGML_DECL,this.sgmlDecl="";else if(!l.isWhitespace(s))if(l.isMatch(F,s))this.state=this.S.OPEN_TAG,this.tagName=s;else if(s==="/")this.state=this.S.CLOSE_TAG,this.tagName="";else if(s==="?")this.state=this.S.PROC_INST,this.procInstName=this.procInstBody="";else{if(this.strictFail("Unencoded <"),this.startTagPosition+1<this.position){let h=this.position-this.startTagPosition;s=new Array(h).join(" ")+s}this.textNode+=`<${s}`,this.state=this.S.TEXT}continue;case this.S.SGML_DECL:(this.sgmlDecl+s).toUpperCase()===this.CDATA?(this.emitNode("onopencdata"),this.state=this.S.CDATA,this.sgmlDecl="",this.cdata=""):this.sgmlDecl+s==="--"?(this.state=this.S.COMMENT,this.comment="",this.sgmlDecl=""):(this.sgmlDecl+s).toUpperCase()===this.DOCTYPE?(this.state=this.S.DOCTYPE,(this.doctype||this.sawRoot)&&this.strictFail("Inappropriately located doctype declaration"),this.doctype="",this.sgmlDecl=""):s===">"?(this.emitNode("onsgmldeclaration",this.sgmlDecl),this.sgmlDecl="",this.state=this.S.TEXT):l.isQuote(s)?(this.state=this.S.SGML_DECL_QUOTED,this.sgmlDecl+=s):this.sgmlDecl+=s;continue;case this.S.SGML_DECL_QUOTED:s===this.q&&(this.state=this.S.SGML_DECL,this.q=""),this.sgmlDecl+=s;continue;case this.S.DOCTYPE:s===">"?(this.state=this.S.TEXT,this.emitNode("ondoctype",this.doctype),this.doctype=!0):(this.doctype+=s,s==="["?this.state=this.S.DOCTYPE_DTD:l.isQuote(s)&&(this.state=this.S.DOCTYPE_QUOTED,this.q=s));continue;case this.S.DOCTYPE_QUOTED:this.doctype+=s,s===this.q&&(this.q="",this.state=this.S.DOCTYPE);continue;case this.S.DOCTYPE_DTD:this.doctype+=s,s==="]"?this.state=this.S.DOCTYPE:l.isQuote(s)&&(this.state=this.S.DOCTYPE_DTD_QUOTED,this.q=s);continue;case this.S.DOCTYPE_DTD_QUOTED:this.doctype+=s,s===this.q&&(this.state=this.S.DOCTYPE_DTD,this.q="");continue;case this.S.COMMENT:s==="-"?this.state=this.S.COMMENT_ENDING:this.comment+=s;continue;case this.S.COMMENT_ENDING:s==="-"?(this.state=this.S.COMMENT_ENDED,this.comment=this.textApplyOptions(this.comment),this.comment&&this.emitNode("oncomment",this.comment),this.comment=""):(this.comment+=`-${s}`,this.state=this.S.COMMENT);continue;case this.S.COMMENT_ENDED:s!==">"?(this.strictFail("Malformed comment"),this.comment+=`--${s}`,this.state=this.S.COMMENT):this.state=this.S.TEXT;continue;case this.S.CDATA:s==="]"?this.state=this.S.CDATA_ENDING:this.cdata+=s;continue;case this.S.CDATA_ENDING:s==="]"?this.state=this.S.CDATA_ENDING_2:(this.cdata+=`]${s}`,this.state=this.S.CDATA);continue;case this.S.CDATA_ENDING_2:s===">"?(this.cdata&&this.emitNode("oncdata",this.cdata),this.emitNode("onclosecdata"),this.cdata="",this.state=this.S.TEXT):s==="]"?this.cdata+="]":(this.cdata+=`]]${s}`,this.state=this.S.CDATA);continue;case this.S.PROC_INST:s==="?"?this.state=this.S.PROC_INST_ENDING:l.isWhitespace(s)?this.state=this.S.PROC_INST_BODY:this.procInstName+=s;continue;case this.S.PROC_INST_BODY:if(!this.procInstBody&&l.isWhitespace(s))continue;s==="?"?this.state=this.S.PROC_INST_ENDING:this.procInstBody+=s;continue;case this.S.PROC_INST_ENDING:s===">"?(this.emitNode("onprocessinginstruction",{name:this.procInstName,body:this.procInstBody}),this.procInstName=this.procInstBody="",this.state=this.S.TEXT):(this.procInstBody+=`?${s}`,this.state=this.S.PROC_INST_BODY);continue;case this.S.OPEN_TAG:l.isMatch(V,s)?this.tagName+=s:(this.newTag(),s===">"?this.openTag():s==="/"?this.state=this.S.OPEN_TAG_SLASH:(l.isWhitespace(s)||this.strictFail("Invalid character in tag name"),this.state=this.S.ATTRIB));continue;case this.S.OPEN_TAG_SLASH:s===">"?(this.openTag(!0),this.closeTag()):(this.strictFail("Forward-slash in opening tag not followed by >"),this.state=this.S.ATTRIB);continue;case this.S.ATTRIB:if(l.isWhitespace(s))continue;s===">"?this.openTag():s==="/"?this.state=this.S.OPEN_TAG_SLASH:l.isMatch(F,s)?(this.attribName=s,this.attribValue="",this.state=this.S.ATTRIB_NAME):this.strictFail("Invalid attribute name");continue;case this.S.ATTRIB_NAME:s==="="?this.state=this.S.ATTRIB_VALUE:s===">"?(this.strictFail("Attribute without value"),this.attribValue=this.attribName,this.attrib(),this.openTag()):l.isWhitespace(s)?this.state=this.S.ATTRIB_NAME_SAW_WHITE:l.isMatch(V,s)?this.attribName+=s:this.strictFail("Invalid attribute name");continue;case this.S.ATTRIB_NAME_SAW_WHITE:if(s==="=")this.state=this.S.ATTRIB_VALUE;else{if(l.isWhitespace(s))continue;this.strictFail("Attribute without value"),this.tag.attributes[this.attribName]="",this.attribValue="",this.emitNode("onattribute",{name:this.attribName,value:""}),this.attribName="",s===">"?this.openTag():l.isMatch(F,s)?(this.attribName=s,this.state=this.S.ATTRIB_NAME):(this.strictFail("Invalid attribute name"),this.state=this.S.ATTRIB)}continue;case this.S.ATTRIB_VALUE:if(l.isWhitespace(s))continue;l.isQuote(s)?(this.q=s,this.state=this.S.ATTRIB_VALUE_QUOTED):(this.strictFail("Unquoted attribute value"),this.state=this.S.ATTRIB_VALUE_UNQUOTED,this.attribValue=s);continue;case this.S.ATTRIB_VALUE_QUOTED:if(s!==this.q){s==="&"?this.state=this.S.ATTRIB_VALUE_ENTITY_Q:this.attribValue+=s;continue}this.attrib(),this.q="",this.state=this.S.ATTRIB_VALUE_CLOSED;continue;case this.S.ATTRIB_VALUE_CLOSED:l.isWhitespace(s)?this.state=this.S.ATTRIB:s===">"?this.openTag():s==="/"?this.state=this.S.OPEN_TAG_SLASH:l.isMatch(F,s)?(this.strictFail("No whitespace between attributes"),this.attribName=s,this.attribValue="",this.state=this.S.ATTRIB_NAME):this.strictFail("Invalid attribute name");continue;case this.S.ATTRIB_VALUE_UNQUOTED:if(!l.isAttribEnd(s)){s==="&"?this.state=this.S.ATTRIB_VALUE_ENTITY_U:this.attribValue+=s;continue}this.attrib(),s===">"?this.openTag():this.state=this.S.ATTRIB;continue;case this.S.CLOSE_TAG:if(this.tagName)s===">"?this.closeTag():l.isMatch(V,s)?this.tagName+=s:this.script?(this.script+=`</${this.tagName}`,this.tagName="",this.state=this.S.SCRIPT):(l.isWhitespace(s)||this.strictFail("Invalid tagname in closing tag"),this.state=this.S.CLOSE_TAG_SAW_WHITE);else{if(l.isWhitespace(s))continue;l.notMatch(F,s)?this.script?(this.script+=`</${s}`,this.state=this.S.SCRIPT):this.strictFail("Invalid tagname in closing tag."):this.tagName=s}continue;case this.S.CLOSE_TAG_SAW_WHITE:if(l.isWhitespace(s))continue;s===">"?this.closeTag():this.strictFail("Invalid characters in closing tag");continue;case this.S.TEXT_ENTITY:case this.S.ATTRIB_VALUE_ENTITY_Q:case this.S.ATTRIB_VALUE_ENTITY_U:let r,n;switch(this.state){case this.S.TEXT_ENTITY:r=this.S.TEXT,n="textNode";break;case this.S.ATTRIB_VALUE_ENTITY_Q:r=this.S.ATTRIB_VALUE_QUOTED,n="attribValue";break;case this.S.ATTRIB_VALUE_ENTITY_U:r=this.S.ATTRIB_VALUE_UNQUOTED,n="attribValue";break;default:throw new Error(`Unknown state: ${this.state}`)}s===";"?(this[n]+=this.parseEntity(),this.entity="",this.state=r):l.isMatch(this.entity.length?Kt:zt,s)?this.entity+=s:(this.strictFail("Invalid character in entity name"),this[n]+=`&${this.entity}${s}`,this.entity="",this.state=r);continue;default:throw new Error(`Unknown state: ${this.state}`)}return this.position>=this.bufferCheckPosition&&this.checkBufferLength(),this}emit(t,i){if(this.events.hasOwnProperty(t)){let s=t.replace(/^on/,"");this.events[t](i,s,this)}}clearBuffers(){for(let t=0,i=this.BUFFERS.length;t<i;t++)this[this[t]]=""}flushBuffers(){this.closeText(),this.cdata!==""&&(this.emitNode("oncdata",this.cdata),this.cdata=""),this.script!==""&&(this.emitNode("onscript",this.script),this.script="")}end(){return this.sawRoot&&!this.closedRoot&&this.strictFail("Unclosed root tag"),this.state!==this.S.BEGIN&&this.state!==this.S.BEGIN_WHITESPACE&&this.state!==this.S.TEXT&&this.errorFunction("Unexpected end"),this.closeText(),this.c="",this.closed=!0,this.emit("onend"),new S(this.opt)}errorFunction(t){this.closeText(),this.trackPosition&&(t+=`
|
|
17
|
+
Line: ${this.line}
|
|
18
|
+
Column: ${this.column}
|
|
19
|
+
Char: ${this.c}`);let i=new Error(t);return this.error=i,this.emit("onerror",i),this}attrib(){if(this.strict||(this.attribName=this.attribName[this.looseCase]()),this.attribList.indexOf(this.attribName)!==-1||this.tag.attributes.hasOwnProperty(this.attribName)){this.attribName=this.attribValue="";return}if(this.opt.xmlns){let t=l.qname(this.attribName,!0),i=t.prefix,s=t.local;if(i==="xmlns")if(s==="xml"&&this.attribValue!==this.XML_NAMESPACE)this.strictFail(`xml: prefix must be bound to ${this.XML_NAMESPACE}
|
|
20
|
+
Actual: ${this.attribValue}`);else if(s==="xmlns"&&this.attribValue!==this.XMLNS_NAMESPACE)this.strictFail(`xmlns: prefix must be bound to ${this.XMLNS_NAMESPACE}
|
|
21
|
+
Actual: ${this.attribValue}`);else{let r=this.tag,n=this.tags[this.tags.length-1]||this;r.ns===n.ns&&(r.ns=Object.create(n.ns)),r.ns[s]=this.attribValue}this.attribList.push([this.attribName,this.attribValue])}else this.tag.attributes[this.attribName]=this.attribValue,this.emitNode("onattribute",{name:this.attribName,value:this.attribValue});this.attribName=this.attribValue=""}newTag(){this.strict||(this.tagName=this.tagName[this.looseCase]());let t=this.tags[this.tags.length-1]||this,i=this.tag={name:this.tagName,attributes:{}};this.opt.xmlns&&(i.ns=t.ns),this.attribList.length=0,this.emitNode("onopentagstart",i)}parseEntity(){let t=this.entity,i=t.toLowerCase(),s=NaN,r="";return this.ENTITIES[t]?this.ENTITIES[t]:this.ENTITIES[i]?this.ENTITIES[i]:(t=i,t.charAt(0)==="#"&&(t.charAt(1)==="x"?(t=t.slice(2),s=parseInt(t,16),r=s.toString(16)):(t=t.slice(1),s=parseInt(t,10),r=s.toString(10))),t=t.replace(/^0+/,""),isNaN(s)||r.toLowerCase()!==t?(this.strictFail("Invalid character entity"),`&${this.entity};`):String.fromCodePoint(s))}beginWhiteSpace(t){t==="<"?(this.state=this.S.OPEN_WAKA,this.startTagPosition=this.position):l.isWhitespace(t)||(this.strictFail("Non-whitespace before first tag."),this.textNode=t,this.state=this.S.TEXT)}strictFail(t){if(typeof this!="object"||!(this instanceof S))throw new Error("bad call to strictFail");this.strict&&this.errorFunction(t)}textApplyOptions(t){return this.opt.trim&&(t=t.trim()),this.opt.normalize&&(t=t.replace(/\s+/g," ")),t}emitNode(t,i){this.textNode&&this.closeText(),this.emit(t,i)}closeText(){this.textNode=this.textApplyOptions(this.textNode),this.textNode!==void 0&&this.textNode!==""&&this.textNode!=="undefined"&&this.emit("ontext",this.textNode),this.textNode=""}checkBufferLength(){let t=Math.max(this.opt.MAX_BUFFER_LENGTH,10),i=0;for(let r=0,n=this.BUFFERS.length;r<n;r++){let h=this[this.BUFFERS[r]]?.length||0;if(h>t)switch(this.BUFFERS[r]){case"textNode":this.closeText();break;case"cdata":this.emitNode("oncdata",this.cdata),this.cdata="";break;case"script":this.emitNode("onscript",this.script),this.script="";break;default:this.errorFunction(`Max buffer length exceeded: ${this.BUFFERS[r]}`)}i=Math.max(i,h)}let s=this.opt.MAX_BUFFER_LENGTH-i;this.bufferCheckPosition=s+this.position}openTag(t){if(this.opt.xmlns){let i=this.tag,s=l.qname(this.tagName);i.prefix=s.prefix,i.local=s.local,i.uri=i.ns[s.prefix]||"",i.prefix&&!i.uri&&(this.strictFail(`Unbound namespace prefix: ${JSON.stringify(this.tagName)}`),i.uri=s.prefix);let r=this.tags[this.tags.length-1]||this;if(i.ns&&r.ns!==i.ns){let n=this;Object.keys(i.ns).forEach(h=>{n.emitNode("onopennamespace",{prefix:h,uri:i.ns[h]})})}for(let n=0,h=this.attribList.length;n<h;n++){let a=this.attribList[n],o=a[0],c=a[1],u=l.qname(o,!0),f=u.prefix,g=u.local,p=f===""?"":i.ns[f]||"",N={name:o,value:c,prefix:f,local:g,uri:p};f&&f!=="xmlns"&&!p&&(this.strictFail(`Unbound namespace prefix: ${JSON.stringify(f)}`),N.uri=f),this.tag.attributes[o]=N,this.emitNode("onattribute",N)}this.attribList.length=0}this.tag.isSelfClosing=Boolean(t),this.sawRoot=!0,this.tags.push(this.tag),this.emitNode("onopentag",this.tag),t||(!this.noscript&&this.tagName.toLowerCase()==="script"?this.state=this.S.SCRIPT:this.state=this.S.TEXT,this.tag=null,this.tagName=""),this.attribName=this.attribValue="",this.attribList.length=0}closeTag(){if(!this.tagName){this.strictFail("Weird empty close tag."),this.textNode+="</>",this.state=this.S.TEXT;return}if(this.script){if(this.tagName!=="script"){this.script+=`</${this.tagName}>`,this.tagName="",this.state=this.S.SCRIPT;return}this.emitNode("onscript",this.script),this.script=""}let t=this.tags.length,i=this.tagName;for(this.strict||(i=i[this.looseCase]());t--&&this.tags[t].name!==i;)this.strictFail("Unexpected close tag");if(t<0){this.strictFail(`Unmatched closing tag: ${this.tagName}`),this.textNode+=`</${this.tagName}>`,this.state=this.S.TEXT;return}this.tagName=i;let s=this.tags.length;for(;s-- >t;){let r=this.tag=this.tags.pop();this.tagName=this.tag.name,this.emitNode("onclosetag",this.tagName);let n={};for(let a in r.ns)r.ns.hasOwnProperty(a)&&(n[a]=r.ns[a]);let h=this.tags[this.tags.length-1]||this;if(this.opt.xmlns&&r.ns!==h.ns){let a=this;Object.keys(r.ns).forEach(o=>{let c=r.ns[o];a.emitNode("onclosenamespace",{prefix:o,uri:c})})}}t===0&&(this.closedRoot=!0),this.tagName=this.attribValue=this.attribName="",this.attribList.length=0,this.state=this.S.TEXT}},S=class extends l{opt=Xt;events=tt;constructor(t){super(),this.clearBuffers(),this.opt=t={...this.opt,...t},this.events={...this.events,...t},this.q=this.c="",this.opt.lowercase=this.opt.lowercase||this.opt.lowercasetags,this.bufferCheckPosition=this.opt.MAX_BUFFER_LENGTH,this.looseCase=this.opt.lowercase?"toLowerCase":"toUpperCase",this.tags=[],this.closed=this.closedRoot=this.sawRoot=!1,this.tag=this.error=null,this.strict=Boolean(this.opt.strict),this.noscript=Boolean(this.opt.strict||this.opt.noscript),this.state=this.S.BEGIN,this.strictEntities=this.opt.strictEntities,this.ENTITIES=this.strictEntities?Object.create(this.XML_ENTITIES):Object.create(this.ENTITIES),this.attribList=[],this.opt.xmlns&&(this.ns=Object.create(this.rootNS)),this.trackPosition=this.opt.position!==!1,this.trackPosition&&(this.position=this.line=this.column=0),this.emit("onready")}resume(){return this.error=null,this}close(){return this.write(null)}flush(){this.flushBuffers()}};j(S,"ENTITIES",O);function U(e){return typeof e=="string"?e.charAt(0).toLowerCase()+e.slice(1):e}function y(e){if(Array.isArray(e))return e.map(t=>y(t));if(e&&typeof e=="object"){let t={};for(let[i,s]of Object.entries(e))t[U(i)]=y(s);return t}return e}var Lt=Z(wt(),1);function H(e,t){if(t?._parser&&t._parser!=="fast-xml-parser")throw new Error(t?._parser);let i={allowBooleanAttributes:!0,ignoreDeclaration:!0,removeNSPrefix:t?.removeNSPrefix,textNodeName:t?.textNodeName,isArray:(r,n,h,a)=>Boolean(t?.arrayPaths?.some(c=>n===c)),...t?._fastXML},s=rs(e,i);return t?.uncapitalizeKeys?y(s):s}function rs(e,t){return new Lt.XMLParser({ignoreAttributes:!1,attributeNamePrefix:"",...t}).parse(e)}var ns="4.2.0-alpha.5",I={name:"XML",id:"xml",module:"xml",version:ns,worker:!1,extensions:["xml"],mimeTypes:["application/xml","text/xml"],testText:os,options:{xml:{_parser:"fast-xml-parser",uncapitalizeKeys:!1,removeNSPrefix:!1,textNodeName:"value",arrayPaths:[]}},parse:async(e,t)=>H(new TextDecoder().decode(e),{...I.options.xml,...t?.xml}),parseTextSync:(e,t)=>H(e,{...I.options.xml,...t?.xml})};function os(e){return e.startsWith("<?xml")}function z(e,t){return Bt(e||{},t)}function Bt(e,t,i=0){if(i>3)return t;let s={...e};for(let[r,n]of Object.entries(t))n&&typeof n=="object"&&!Array.isArray(n)?s[r]=Bt(s[r]||{},t[r],i+1):s[r]=t[r];return s}var Rt={...I,name:"HTML",id:"html",extensions:["html","htm"],mimeTypes:["text/html"],testText:as,parse:async(e,t)=>Mt(new TextDecoder().decode(e),t),parseTextSync:(e,t)=>Mt(e,t)};function as(e){return e.startsWith("<html")}function Mt(e,t){return t=z(t,{xml:{_parser:"fast-xml-parser",_fastXML:{htmlEntities:!0}}}),I.parseTextSync?.(e,t)}function K(e){return Array.isArray(e)?e:(e&&typeof e=="object"&&e[0],e?[e]:[])}function Vt(e,t){e[t]=K(e[t])}return Yt(w);})();
|
|
22
|
+
return __exports__;
|
|
23
|
+
});
|
package/dist/html-loader.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-loader.d.ts","sourceRoot":"","sources":["../src/html-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAY,gBAAgB,EAAC,
|
|
1
|
+
{"version":3,"file":"html-loader.d.ts","sourceRoot":"","sources":["../src/html-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAY,gBAAgB,EAAC,wBAAqB;AAEzD,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,gBAAgB,CAAC,GAAG,EAAE,KAAK,EAAE,iBAAiB,CAUtE,CAAC"}
|
package/dist/html-loader.js
CHANGED
|
@@ -1,28 +1,39 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import { mergeLoaderOptions } from '@loaders.gl/loader-utils';
|
|
2
5
|
import { XMLLoader } from "./xml-loader.js";
|
|
6
|
+
/**
|
|
7
|
+
* Loader for HTML files
|
|
8
|
+
* Essentially a copy of the XMLLoader with different mime types, file extensions and content tests.
|
|
9
|
+
* This split enables applications can control whether they want HTML responses to be parsed by the XML loader or not.
|
|
10
|
+
* This loader does not have any additional understanding of the structure of HTML or the document.
|
|
11
|
+
*/
|
|
3
12
|
export const HTMLLoader = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
...XMLLoader,
|
|
14
|
+
name: 'HTML',
|
|
15
|
+
id: 'html',
|
|
16
|
+
extensions: ['html', 'htm'],
|
|
17
|
+
mimeTypes: ['text/html'],
|
|
18
|
+
testText: testHTMLFile,
|
|
19
|
+
parse: async (arrayBuffer, options) => parseTextSync(new TextDecoder().decode(arrayBuffer), options),
|
|
20
|
+
parseTextSync: (text, options) => parseTextSync(text, options)
|
|
12
21
|
};
|
|
13
22
|
function testHTMLFile(text) {
|
|
14
|
-
|
|
23
|
+
// TODO - There could be space first.
|
|
24
|
+
return text.startsWith('<html');
|
|
15
25
|
}
|
|
16
26
|
function parseTextSync(text, options) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
xml
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
// fast-xml-parser can recognize HTML entities
|
|
28
|
+
// https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md#htmlentities
|
|
29
|
+
// https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/5.Entities.md
|
|
30
|
+
options = mergeLoaderOptions(options, {
|
|
31
|
+
xml: {
|
|
32
|
+
_parser: 'fast-xml-parser',
|
|
33
|
+
_fastXML: {
|
|
34
|
+
htmlEntities: true
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
return XMLLoader.parseTextSync?.(text, options);
|
|
27
39
|
}
|
|
28
|
-
//# sourceMappingURL=html-loader.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -3,6 +3,7 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
7
|
var __export = (target, all) => {
|
|
7
8
|
for (var name in all)
|
|
8
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -16,10 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
17
|
return to;
|
|
17
18
|
};
|
|
18
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var __publicField = (obj, key, value) => {
|
|
21
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
22
|
+
return value;
|
|
23
|
+
};
|
|
19
24
|
|
|
20
|
-
//
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
25
|
+
// dist/index.js
|
|
26
|
+
var dist_exports = {};
|
|
27
|
+
__export(dist_exports, {
|
|
23
28
|
HTMLLoader: () => HTMLLoader,
|
|
24
29
|
SAXParser: () => SAXParser,
|
|
25
30
|
XMLLoader: () => XMLLoader,
|
|
@@ -28,9 +33,9 @@ __export(src_exports, {
|
|
|
28
33
|
convertXMLFieldToArrayInPlace: () => convertXMLFieldToArrayInPlace,
|
|
29
34
|
convertXMLValueToArray: () => convertXMLValueToArray
|
|
30
35
|
});
|
|
31
|
-
module.exports = __toCommonJS(
|
|
36
|
+
module.exports = __toCommonJS(dist_exports);
|
|
32
37
|
|
|
33
|
-
//
|
|
38
|
+
// dist/sax-ts/sax.js
|
|
34
39
|
var DEFAULT_SAX_EVENTS = {
|
|
35
40
|
ontext: () => {
|
|
36
41
|
},
|
|
@@ -380,125 +385,140 @@ Object.keys(ENTITIES).forEach((key) => {
|
|
|
380
385
|
ENTITIES[key] = typeof e === "number" ? String.fromCharCode(e) : e;
|
|
381
386
|
});
|
|
382
387
|
var SAX = class {
|
|
388
|
+
EVENTS = EVENTS;
|
|
389
|
+
ENTITIES = {
|
|
390
|
+
// TODO: make it readonly, needed for entity-mega test
|
|
391
|
+
// amp, gt, lt, quot and apos are resolved to strings instead of numerical
|
|
392
|
+
// codes, IDK why
|
|
393
|
+
...ENTITIES
|
|
394
|
+
};
|
|
395
|
+
XML_ENTITIES = {
|
|
396
|
+
amp: "&",
|
|
397
|
+
gt: ">",
|
|
398
|
+
lt: "<",
|
|
399
|
+
quot: '"',
|
|
400
|
+
apos: "'"
|
|
401
|
+
};
|
|
402
|
+
S = 0;
|
|
403
|
+
opt;
|
|
404
|
+
trackPosition = false;
|
|
405
|
+
column = 0;
|
|
406
|
+
line = 0;
|
|
407
|
+
c = "";
|
|
408
|
+
error;
|
|
409
|
+
q = "";
|
|
410
|
+
bufferCheckPosition;
|
|
411
|
+
closed = false;
|
|
412
|
+
tags = [];
|
|
413
|
+
looseCase = "";
|
|
414
|
+
closedRoot = false;
|
|
415
|
+
sawRoot = false;
|
|
416
|
+
strict = false;
|
|
417
|
+
tag;
|
|
418
|
+
strictEntities;
|
|
419
|
+
state;
|
|
420
|
+
noscript = false;
|
|
421
|
+
attribList = [];
|
|
422
|
+
ns;
|
|
423
|
+
position = 0;
|
|
424
|
+
STATE = {
|
|
425
|
+
BEGIN: this.S++,
|
|
426
|
+
// leading byte order mark or whitespace
|
|
427
|
+
BEGIN_WHITESPACE: this.S++,
|
|
428
|
+
// leading whitespace
|
|
429
|
+
TEXT: this.S++,
|
|
430
|
+
// general stuff
|
|
431
|
+
TEXT_ENTITY: this.S++,
|
|
432
|
+
// & and such.
|
|
433
|
+
OPEN_WAKA: this.S++,
|
|
434
|
+
// <
|
|
435
|
+
SGML_DECL: this.S++,
|
|
436
|
+
// <!BLARG
|
|
437
|
+
SGML_DECL_QUOTED: this.S++,
|
|
438
|
+
// <!BLARG foo "bar
|
|
439
|
+
DOCTYPE: this.S++,
|
|
440
|
+
// <!DOCTYPE
|
|
441
|
+
DOCTYPE_QUOTED: this.S++,
|
|
442
|
+
// <!DOCTYPE "//blah
|
|
443
|
+
DOCTYPE_DTD: this.S++,
|
|
444
|
+
// <!DOCTYPE "//blah" [ ...
|
|
445
|
+
DOCTYPE_DTD_QUOTED: this.S++,
|
|
446
|
+
// <!DOCTYPE "//blah" [ "foo
|
|
447
|
+
COMMENT_STARTING: this.S++,
|
|
448
|
+
// <!-
|
|
449
|
+
COMMENT: this.S++,
|
|
450
|
+
// <!--
|
|
451
|
+
COMMENT_ENDING: this.S++,
|
|
452
|
+
// <!-- blah -
|
|
453
|
+
COMMENT_ENDED: this.S++,
|
|
454
|
+
// <!-- blah --
|
|
455
|
+
CDATA: this.S++,
|
|
456
|
+
// <![CDATA[ something
|
|
457
|
+
CDATA_ENDING: this.S++,
|
|
458
|
+
// ]
|
|
459
|
+
CDATA_ENDING_2: this.S++,
|
|
460
|
+
// ]]
|
|
461
|
+
PROC_INST: this.S++,
|
|
462
|
+
// <?hi
|
|
463
|
+
PROC_INST_BODY: this.S++,
|
|
464
|
+
// <?hi there
|
|
465
|
+
PROC_INST_ENDING: this.S++,
|
|
466
|
+
// <?hi "there" ?
|
|
467
|
+
OPEN_TAG: this.S++,
|
|
468
|
+
// <strong
|
|
469
|
+
OPEN_TAG_SLASH: this.S++,
|
|
470
|
+
// <strong /
|
|
471
|
+
ATTRIB: this.S++,
|
|
472
|
+
// <a
|
|
473
|
+
ATTRIB_NAME: this.S++,
|
|
474
|
+
// <a foo
|
|
475
|
+
ATTRIB_NAME_SAW_WHITE: this.S++,
|
|
476
|
+
// <a foo _
|
|
477
|
+
ATTRIB_VALUE: this.S++,
|
|
478
|
+
// <a foo=
|
|
479
|
+
ATTRIB_VALUE_QUOTED: this.S++,
|
|
480
|
+
// <a foo="bar
|
|
481
|
+
ATTRIB_VALUE_CLOSED: this.S++,
|
|
482
|
+
// <a foo="bar"
|
|
483
|
+
ATTRIB_VALUE_UNQUOTED: this.S++,
|
|
484
|
+
// <a foo=bar
|
|
485
|
+
ATTRIB_VALUE_ENTITY_Q: this.S++,
|
|
486
|
+
// <foo bar="""
|
|
487
|
+
ATTRIB_VALUE_ENTITY_U: this.S++,
|
|
488
|
+
// <foo bar="
|
|
489
|
+
CLOSE_TAG: this.S++,
|
|
490
|
+
// </a
|
|
491
|
+
CLOSE_TAG_SAW_WHITE: this.S++,
|
|
492
|
+
// </a >
|
|
493
|
+
SCRIPT: this.S++,
|
|
494
|
+
// <script> ...
|
|
495
|
+
SCRIPT_ENDING: this.S++
|
|
496
|
+
// <script> ... <
|
|
497
|
+
};
|
|
498
|
+
BUFFERS = BUFFERS;
|
|
499
|
+
// private parser: (strict: boolean, opt: any) => SAXParser;
|
|
500
|
+
CDATA = "[CDATA[";
|
|
501
|
+
DOCTYPE = "DOCTYPE";
|
|
502
|
+
XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace";
|
|
503
|
+
XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/";
|
|
504
|
+
rootNS = {
|
|
505
|
+
xml: this.XML_NAMESPACE,
|
|
506
|
+
xmlns: this.XMLNS_NAMESPACE
|
|
507
|
+
};
|
|
508
|
+
comment;
|
|
509
|
+
sgmlDecl;
|
|
510
|
+
textNode = "";
|
|
511
|
+
tagName;
|
|
512
|
+
doctype;
|
|
513
|
+
procInstName;
|
|
514
|
+
procInstBody;
|
|
515
|
+
entity = "";
|
|
516
|
+
attribName;
|
|
517
|
+
attribValue;
|
|
518
|
+
cdata = "";
|
|
519
|
+
script = "";
|
|
520
|
+
startTagPosition = 0;
|
|
383
521
|
constructor() {
|
|
384
|
-
this.EVENTS = EVENTS;
|
|
385
|
-
this.ENTITIES = {
|
|
386
|
-
// TODO: make it readonly, needed for entity-mega test
|
|
387
|
-
// amp, gt, lt, quot and apos are resolved to strings instead of numerical
|
|
388
|
-
// codes, IDK why
|
|
389
|
-
...ENTITIES
|
|
390
|
-
};
|
|
391
|
-
this.XML_ENTITIES = {
|
|
392
|
-
amp: "&",
|
|
393
|
-
gt: ">",
|
|
394
|
-
lt: "<",
|
|
395
|
-
quot: '"',
|
|
396
|
-
apos: "'"
|
|
397
|
-
};
|
|
398
|
-
this.S = 0;
|
|
399
|
-
this.trackPosition = false;
|
|
400
|
-
this.column = 0;
|
|
401
|
-
this.line = 0;
|
|
402
|
-
this.c = "";
|
|
403
|
-
this.q = "";
|
|
404
|
-
this.closed = false;
|
|
405
|
-
this.tags = [];
|
|
406
|
-
this.looseCase = "";
|
|
407
|
-
this.closedRoot = false;
|
|
408
|
-
this.sawRoot = false;
|
|
409
|
-
this.strict = false;
|
|
410
|
-
this.noscript = false;
|
|
411
|
-
this.attribList = [];
|
|
412
|
-
this.position = 0;
|
|
413
|
-
this.STATE = {
|
|
414
|
-
BEGIN: this.S++,
|
|
415
|
-
// leading byte order mark or whitespace
|
|
416
|
-
BEGIN_WHITESPACE: this.S++,
|
|
417
|
-
// leading whitespace
|
|
418
|
-
TEXT: this.S++,
|
|
419
|
-
// general stuff
|
|
420
|
-
TEXT_ENTITY: this.S++,
|
|
421
|
-
// & and such.
|
|
422
|
-
OPEN_WAKA: this.S++,
|
|
423
|
-
// <
|
|
424
|
-
SGML_DECL: this.S++,
|
|
425
|
-
// <!BLARG
|
|
426
|
-
SGML_DECL_QUOTED: this.S++,
|
|
427
|
-
// <!BLARG foo "bar
|
|
428
|
-
DOCTYPE: this.S++,
|
|
429
|
-
// <!DOCTYPE
|
|
430
|
-
DOCTYPE_QUOTED: this.S++,
|
|
431
|
-
// <!DOCTYPE "//blah
|
|
432
|
-
DOCTYPE_DTD: this.S++,
|
|
433
|
-
// <!DOCTYPE "//blah" [ ...
|
|
434
|
-
DOCTYPE_DTD_QUOTED: this.S++,
|
|
435
|
-
// <!DOCTYPE "//blah" [ "foo
|
|
436
|
-
COMMENT_STARTING: this.S++,
|
|
437
|
-
// <!-
|
|
438
|
-
COMMENT: this.S++,
|
|
439
|
-
// <!--
|
|
440
|
-
COMMENT_ENDING: this.S++,
|
|
441
|
-
// <!-- blah -
|
|
442
|
-
COMMENT_ENDED: this.S++,
|
|
443
|
-
// <!-- blah --
|
|
444
|
-
CDATA: this.S++,
|
|
445
|
-
// <![CDATA[ something
|
|
446
|
-
CDATA_ENDING: this.S++,
|
|
447
|
-
// ]
|
|
448
|
-
CDATA_ENDING_2: this.S++,
|
|
449
|
-
// ]]
|
|
450
|
-
PROC_INST: this.S++,
|
|
451
|
-
// <?hi
|
|
452
|
-
PROC_INST_BODY: this.S++,
|
|
453
|
-
// <?hi there
|
|
454
|
-
PROC_INST_ENDING: this.S++,
|
|
455
|
-
// <?hi "there" ?
|
|
456
|
-
OPEN_TAG: this.S++,
|
|
457
|
-
// <strong
|
|
458
|
-
OPEN_TAG_SLASH: this.S++,
|
|
459
|
-
// <strong /
|
|
460
|
-
ATTRIB: this.S++,
|
|
461
|
-
// <a
|
|
462
|
-
ATTRIB_NAME: this.S++,
|
|
463
|
-
// <a foo
|
|
464
|
-
ATTRIB_NAME_SAW_WHITE: this.S++,
|
|
465
|
-
// <a foo _
|
|
466
|
-
ATTRIB_VALUE: this.S++,
|
|
467
|
-
// <a foo=
|
|
468
|
-
ATTRIB_VALUE_QUOTED: this.S++,
|
|
469
|
-
// <a foo="bar
|
|
470
|
-
ATTRIB_VALUE_CLOSED: this.S++,
|
|
471
|
-
// <a foo="bar"
|
|
472
|
-
ATTRIB_VALUE_UNQUOTED: this.S++,
|
|
473
|
-
// <a foo=bar
|
|
474
|
-
ATTRIB_VALUE_ENTITY_Q: this.S++,
|
|
475
|
-
// <foo bar="""
|
|
476
|
-
ATTRIB_VALUE_ENTITY_U: this.S++,
|
|
477
|
-
// <foo bar="
|
|
478
|
-
CLOSE_TAG: this.S++,
|
|
479
|
-
// </a
|
|
480
|
-
CLOSE_TAG_SAW_WHITE: this.S++,
|
|
481
|
-
// </a >
|
|
482
|
-
SCRIPT: this.S++,
|
|
483
|
-
// <script> ...
|
|
484
|
-
SCRIPT_ENDING: this.S++
|
|
485
|
-
// <script> ... <
|
|
486
|
-
};
|
|
487
|
-
this.BUFFERS = BUFFERS;
|
|
488
|
-
// private parser: (strict: boolean, opt: any) => SAXParser;
|
|
489
|
-
this.CDATA = "[CDATA[";
|
|
490
|
-
this.DOCTYPE = "DOCTYPE";
|
|
491
|
-
this.XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace";
|
|
492
|
-
this.XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/";
|
|
493
|
-
this.rootNS = {
|
|
494
|
-
xml: this.XML_NAMESPACE,
|
|
495
|
-
xmlns: this.XMLNS_NAMESPACE
|
|
496
|
-
};
|
|
497
|
-
this.textNode = "";
|
|
498
|
-
this.entity = "";
|
|
499
|
-
this.cdata = "";
|
|
500
|
-
this.script = "";
|
|
501
|
-
this.startTagPosition = 0;
|
|
502
522
|
this.S = 0;
|
|
503
523
|
for (const s in this.STATE) {
|
|
504
524
|
if (this.STATE.hasOwnProperty(s)) {
|
|
@@ -1096,15 +1116,11 @@ Char: ${this.c}`;
|
|
|
1096
1116
|
const local = qn.local;
|
|
1097
1117
|
if (prefix === "xmlns") {
|
|
1098
1118
|
if (local === "xml" && this.attribValue !== this.XML_NAMESPACE) {
|
|
1099
|
-
this.strictFail(
|
|
1100
|
-
|
|
1101
|
-
Actual: ${this.attribValue}`
|
|
1102
|
-
);
|
|
1119
|
+
this.strictFail(`xml: prefix must be bound to ${this.XML_NAMESPACE}
|
|
1120
|
+
Actual: ${this.attribValue}`);
|
|
1103
1121
|
} else if (local === "xmlns" && this.attribValue !== this.XMLNS_NAMESPACE) {
|
|
1104
|
-
this.strictFail(
|
|
1105
|
-
|
|
1106
|
-
Actual: ${this.attribValue}`
|
|
1107
|
-
);
|
|
1122
|
+
this.strictFail(`xmlns: prefix must be bound to ${this.XMLNS_NAMESPACE}
|
|
1123
|
+
Actual: ${this.attribValue}`);
|
|
1108
1124
|
} else {
|
|
1109
1125
|
const tag = this.tag;
|
|
1110
1126
|
const parent = this.tags[this.tags.length - 1] || this;
|
|
@@ -1357,10 +1373,10 @@ Actual: ${this.attribValue}`
|
|
|
1357
1373
|
}
|
|
1358
1374
|
};
|
|
1359
1375
|
var SAXParser = class extends SAX {
|
|
1376
|
+
opt = DEFAULT_SAX_PARSER_OPTIONS;
|
|
1377
|
+
events = DEFAULT_SAX_EVENTS;
|
|
1360
1378
|
constructor(opt) {
|
|
1361
1379
|
super();
|
|
1362
|
-
this.opt = DEFAULT_SAX_PARSER_OPTIONS;
|
|
1363
|
-
this.events = DEFAULT_SAX_EVENTS;
|
|
1364
1380
|
this.clearBuffers();
|
|
1365
1381
|
this.opt = opt = { ...this.opt, ...opt };
|
|
1366
1382
|
this.events = { ...this.events, ...opt };
|
|
@@ -1397,9 +1413,9 @@ var SAXParser = class extends SAX {
|
|
|
1397
1413
|
this.flushBuffers();
|
|
1398
1414
|
}
|
|
1399
1415
|
};
|
|
1400
|
-
SAXParser
|
|
1416
|
+
__publicField(SAXParser, "ENTITIES", ENTITIES);
|
|
1401
1417
|
|
|
1402
|
-
//
|
|
1418
|
+
// dist/lib/xml-utils/uncapitalize.js
|
|
1403
1419
|
function uncapitalize(str) {
|
|
1404
1420
|
return typeof str === "string" ? str.charAt(0).toLowerCase() + str.slice(1) : str;
|
|
1405
1421
|
}
|
|
@@ -1417,7 +1433,7 @@ function uncapitalizeKeys(object) {
|
|
|
1417
1433
|
return object;
|
|
1418
1434
|
}
|
|
1419
1435
|
|
|
1420
|
-
//
|
|
1436
|
+
// dist/lib/parsers/parse-xml.js
|
|
1421
1437
|
var import_fast_xml_parser = require("fast-xml-parser");
|
|
1422
1438
|
function parseXMLSync(text, options) {
|
|
1423
1439
|
if ((options == null ? void 0 : options._parser) && options._parser !== "fast-xml-parser") {
|
|
@@ -1455,8 +1471,8 @@ function fastParseXML(text, options) {
|
|
|
1455
1471
|
return parsedXML;
|
|
1456
1472
|
}
|
|
1457
1473
|
|
|
1458
|
-
//
|
|
1459
|
-
var VERSION =
|
|
1474
|
+
// dist/xml-loader.js
|
|
1475
|
+
var VERSION = true ? "4.2.0-alpha.5" : "latest";
|
|
1460
1476
|
var XMLLoader = {
|
|
1461
1477
|
name: "XML",
|
|
1462
1478
|
id: "xml",
|
|
@@ -1485,7 +1501,7 @@ function testXMLFile(text) {
|
|
|
1485
1501
|
return text.startsWith("<?xml");
|
|
1486
1502
|
}
|
|
1487
1503
|
|
|
1488
|
-
//
|
|
1504
|
+
// dist/html-loader.js
|
|
1489
1505
|
var import_loader_utils = require("@loaders.gl/loader-utils");
|
|
1490
1506
|
var HTMLLoader = {
|
|
1491
1507
|
...XMLLoader,
|
|
@@ -1513,7 +1529,7 @@ function parseTextSync(text, options) {
|
|
|
1513
1529
|
return (_b = (_a = XMLLoader).parseTextSync) == null ? void 0 : _b.call(_a, text, options);
|
|
1514
1530
|
}
|
|
1515
1531
|
|
|
1516
|
-
//
|
|
1532
|
+
// dist/lib/xml-utils/xml-utils.js
|
|
1517
1533
|
function convertXMLValueToArray(xmlValue) {
|
|
1518
1534
|
if (Array.isArray(xmlValue)) {
|
|
1519
1535
|
return xmlValue;
|
|
@@ -1528,3 +1544,4 @@ function convertXMLValueToArray(xmlValue) {
|
|
|
1528
1544
|
function convertXMLFieldToArrayInPlace(xml, key) {
|
|
1529
1545
|
xml[key] = convertXMLValueToArray(xml[key]);
|
|
1530
1546
|
}
|
|
1547
|
+
//# sourceMappingURL=index.cjs.map
|