Files
beall-11ty/node_modules/@rgrove/parse-xml/dist/global.min.js

12 lines
12 KiB
JavaScript
Raw Normal View History

2026-03-31 16:38:22 -07:00
/*! @rgrove/parse-xml v4.2.0 | ISC License | Copyright Ryan Grove */
"use strict";var parseXml=(()=>{var T=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var $=(n,t)=>{for(var e in t)T(n,e,{get:t[e],enumerable:!0})},L=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of R(t))!_.call(n,i)&&i!==e&&T(n,i,{get:()=>t[i],enumerable:!(r=Y(t,i))||r.enumerable});return n};var B=n=>L(T({},"__esModule",{value:!0}),n);var z={};$(z,{XmlCdata:()=>d,XmlComment:()=>p,XmlDeclaration:()=>x,XmlDocument:()=>g,XmlDocumentType:()=>y,XmlElement:()=>c,XmlError:()=>b,XmlNode:()=>o,XmlProcessingInstruction:()=>f,XmlText:()=>u,parseXml:()=>k});var O="",V=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,E=class{constructor(t){if(this.m=this.E(t,!0),this.i=0,this.length=t.length,this.u=this.m!==this.length,this.l=t,this.u){let e=[];for(let r=0,i=0;i<this.m;++i)e[i]=r,r+=t.codePointAt(r)>65535?2:1;this.D=e}}get C(){return this.i>=this.m}E(t,e=this.u){return e?t.replace(V,"_").length:t.length}p(t=1){this.i=Math.min(this.m,this.i+t)}s(t=this.i){var e;return this.u?(e=this.D[t])!=null?e:1/0:t}j(t=1){let e=this.c(t);return this.p(t),e}X(t){let e=this.s(),r=this.l.slice(e,e+t);return this.p(this.E(r)),r}v(t){let{length:e,u:r,l:i}=this,s=this.s(),l=s;if(r)for(;l<e;){let a=i[l],h=a>="\uD800"&&a<="\uDBFF";if(h&&(a+=i[l+1]),!t(a))break;l+=h?2:1}else for(;l<e&&t(i[l]);)++l;return this.X(l-s)}e(t){let{length:e}=t,r=this.s();return t===this.l.slice(r,r+e)?(this.p(e===1?1:this.E(t)),t):O}w(t){let e=this.l.slice(this.s()).search(t);return e>0?this.X(e):O}y(t){let e=this.s(),r=this.l.indexOf(t,e);return r>0?this.X(r-e):O}c(t=1){let{i:e,l:r}=this;return this.u?r.slice(this.s(e),this.s(e+t)):r.slice(e,e+t)}f(t=0){this.i=t>=0?Math.min(this.m,t):Math.max(0,this.i+t)}};var F=/["&<]/,I=/['&<]/,j=/\r\n|[\n\r\t]/g,A=/<|&|]]>/,S=Object.freeze(Object.assign(Object.create(null),{amp:"&",apos:"'",gt:">",lt:"<",quot:'"'}));function D(n){let t=n.codePointAt(0);return t>=97&&t<=122||t>=65&&t<=90||t>=48&&t<=57||t===45||t===46||t===183||t>=768&&t<=879||t===8255||t===8256||C(n,t)}function C(n,t=n.codePointAt(0)){return t>=97&&t<=122||t>=65&&t<=90||t===58||t===95||t>=192&&t<=214||t>=216&&t<=246||t>=248&&t<=767||t>=880&&t<=893||t>=895&&t<=8191||t===8204||t===8205||t>=8304&&t<=8591||t>=11264&&t<=12271||t>=12289&&t<=55295||t>=63744&&t<=64975||t>=65008&&t<=65533||t>=65536&&t<=983039}function M(n){return n==="#"||D(n)}function J(n){let t=n.codePointAt(0);return t===32||t===9||t===10||t===13}function N(n){return n>=32&&n<=55295||n===10||n===9||n===13||n>=57344&&n<=65533||n>=65536&&n<=1114111}var m=class m{constructor(){this.parent=null;this.start=-1;this.end=-1}get document(){var t,e;return(e=(t=this.parent)==null?void 0:t.document)!=null?e:null}get isRootNode(){return this.parent!==null&&this.parent===this.document&&this.type===m.TYPE_ELEMENT}get preserveWhitespace(){var t;return!!((t=this.parent)!=null&&t.preserveWhitespace)}get type(){return""}toJSON(){let t={type:this.type};return this.isRootNode&&(t.isRootNode=!0),this.preserveWhitespace&&(t.preserveWhitespace=!0),this.start!==-1&&(t.start=this.start,t.end=this.end),t}};m.TYPE_CDATA="cdata",m.TYPE_COMMENT="comment",m.TYPE_DOCUMENT="document",m.TYPE_DOCUMENT_TYPE="doctype",m.TYPE_ELEMENT="element",m.TYPE_PROCESSING_INSTRUCTION="pi",m.TYPE_TEXT="text",m.TYPE_XML_DECLARATION="xmldecl";var o=m;var u=class extends o{constructor(t=""){super(),this.text=t}get type(){return o.TYPE_TEXT}toJSON(){return Object.assign(o.prototype.toJSON.call(this),{text:this.text})}};var d=class extends u{get type(){return o.TYPE_CDATA}};var p=class extends o{constructor(t=""){super(),this.content=t}get type(){return o.TYPE_COMMENT}toJSON(){return Object.assign(o.prototype.toJSON.call(this),{content:this.content})}};var x=class extends o{constructor(t,e,r){super(),this.version=t,this.encoding=e!=null?e:null,this.standalone=r!=null?r:null}get type(){return o.TYPE_XML_DECLARATION}toJSON(){let t=o.prototype.toJSON.call(this);t.version=this.version;for(let e of["encoding","standalone"])this[e]!==null&&(t[e]=this[e]);return t}};var c=class n exten
`?(i=1,s="",l+=1):(i+=1,s+=P)}let a=r.indexOf(`
`,e);s+=a===-1?r.slice(e):r.slice(e,a);let h=0;s.length>50&&(i<40?s=s.slice(0,50):(h=i-20,s=s.slice(h,i+30))),super(`${t} (line ${l}, column ${i})
${s}
`+" ".repeat(i-h+1)+`^
`),this.column=i,this.excerpt=s,this.line=l,this.name="XmlError",this.pos=e}};var f=class extends o{constructor(t,e=""){super(),this.name=t,this.content=e}get type(){return o.TYPE_PROCESSING_INSTRUCTION}toJSON(){return Object.assign(o.prototype.toJSON.call(this),{name:this.name,content:this.content})}};var U="",v=class{constructor(t,e={}){let r=this.document=new g;this.h=r,this.o=e,this.r=new E(t),this.o.includeOffsets&&(r.start=0,r.end=t.length),this.parse()}a(t,e){return t.parent=this.h,this.o.includeOffsets&&(t.start=this.r.s(e),t.end=this.r.s()),this.h.children.push(t),!0}T(t,e){let{children:r}=this.h,{length:i}=r;if(t=X(t),i>0){let s=r[i-1];if((s==null?void 0:s.type)===o.TYPE_TEXT){let l=s;return l.text+=t,this.o.includeOffsets&&(l.end=this.r.s()),!0}}return this.a(new u(t),e)}A(){let t=Object.create(null);for(;this.n();){let e=this.x();if(!e)break;let r=this.b()&&this.S();if(r===!1)throw this.t("Attribute value expected");if(e in t)throw this.t(`Duplicate attribute: ${e}`);if(e==="xml:space"&&r!=="default"&&r!=="preserve")throw this.t('Value of the `xml:space` attribute must be "default" or "preserve"');t[e]=r}if(this.o.sortAttributes){let e=Object.keys(t).sort(),r=Object.create(null);for(let i=0;i<e.length;++i){let s=e[i];r[s]=t[s]}t=r}return t}S(){let{r:t}=this,e=t.c();if(e!=='"'&&e!=="'")return!1;t.p();let r,i=!1,s=U,l=e==='"'?F:I;t:for(;!t.C;)switch(r=t.w(l),r&&(this.d(r),s+=r.replace(j," ")),t.c()){case e:i=!0;break t;case"&":s+=this.N();continue;case"<":throw this.t("Unescaped `<` is not allowed in an attribute value");default:break t}if(!i)throw this.t("Unclosed attribute");return t.p(),s}J(){let{r:t}=this,e=t.i;if(!t.e("<![CDATA["))return!1;let r=t.y("]]>");if(this.d(r),!t.e("]]>"))throw this.t("Unclosed CDATA section");return this.o.preserveCdata?this.a(new d(X(r)),e):this.T(r,e)}M(){let{r:t}=this,e=t.i,r=t.w(A);if(!r)return!1;if(this.d(r),t.c(3)==="]]>")throw this.t("Element content may not contain the CDATA section close delimiter `]]>`");return this.T(r,e)}P(){let{r:t}=this,e=t.i;if(!t.e("<!--"))return!1;let r=t.y("--");if(this.d(r),!t.e("-->"))throw t.c(2)==="--"?this.t("The string `--` isn't allowed inside a comment"):this.t("Unclosed comment");return this.o.preserveComments?this.a(new p(X(r)),e):!0}U(){let t=this.r.i,e=this.N();return e?this.T(e,t):!1}Y(){let{r:t}=this,e=t.i;if(!t.e("<!DOCTYPE"))return!1;let r=this.n()&&this.x();if(!r)throw this.t("Expected a name");let i,s;if(this.n()){if(t.e("PUBLIC")){if(i=this.n()&&this.R(),i===!1)throw this.t("Expected a public identifier");this.n()}if(i!==void 0||t.e("SYSTEM")){if(this.n(),s=this.g(),s===!1)throw this.t("Expected a system identifier");this.n()}}let l;if(t.e("[")){if(l=t.w(/\][\x20\t\r\n]*>/),!t.e("]"))throw this.t("Unclosed internal subset");this.n()}if(!t.e(">"))throw this.t("Unclosed doctype declaration");return this.o.preserveDocumentType?this.a(new y(r,i,s,l),e):!0}F(){let{r:t}=this,e=t.i;if(!t.e("<"))return!1;let r=this.x();if(!r)return t.f(e),!1;let i=this.A(),s=!!t.e("/>"),l=new c(r,i);if(l.parent=this.h,!s){if(!t.e(">"))throw this.t(`Unclosed start tag for element \`${r}\``);this.h=l;do this.M();while(this.F()||this.U()||this.J()||this.I()||this.P());let a=t.i,h;if(!t.e("</")||!(h=this.x())||h!==r)throw t.f(a),this.t(`Missing end tag for element ${r}`);if(this.n(),!t.e(">"))throw this.t(`Unclosed end tag for element ${r}`);this.h=l.parent}return this.a(l,e)}b(){return this.n(),this.r.e("=")?(this.n(),!0):!1}O(){return this.P()||this.I()||this.n()}x(){return C(this.r.c())?this.r.v(D):U}I(){let{r:t}=this,e=t.i;if(!t.e("<?"))return!1;let r=this.x();if(r){if(r.toLowerCase()==="xml")throw t.f(e),this.t("XML declaration isn't allowed here")}else throw this.t("Invalid processing instruction");if(!this.n()){if(t.e("?>"))return this.a(new f(r),e);throw this.t("Whitespace is required after a processing instruction name")}let i=t.y("?>");if(this.d(i),!t.e("?>"))throw this.t("Unterminated processing instruction");return this.a(new f(r,X(i)),e)}_(){let{r:t}=this,e=t.i;for(this.$();this.O(););if(this.Y())for(;this.O(););return e<t.i}R(){let t=this.r
`?n.slice(0,t)+n.slice(t+1):n.slice(0,t)+`
`+n.slice(t+1);return n}function k(n,t){return new v(n,t).document}return B(z);})();
parseXml=parseXml.parseXml
//# sourceMappingURL=global.min.js.map