@loaders.gl/xml
Advanced tools
Comparing version 4.3.0-alpha.1 to 4.3.0-alpha.2
@@ -21,4 +21,4 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
Actual: ${this.attribValue}`);else if(s==="xmlns"&&this.attribValue!==this.XMLNS_NAMESPACE)this.strictFail(`xmlns: prefix must be bound to ${this.XMLNS_NAMESPACE} | ||
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 b))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}},b=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(b,"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",I={dataType:null,batchType:null,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 Mt(e||{},t)}function Mt(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]=Mt(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)=>Bt(new TextDecoder().decode(e),t),parseTextSync:(e,t)=>Bt(e,t)};function as(e){return e.startsWith("<html")}function Bt(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);})(); | ||
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 b))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}},b=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(b,"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.3.0-alpha.1",I={dataType:null,batchType:null,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 Mt(e||{},t)}function Mt(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]=Mt(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)=>Bt(new TextDecoder().decode(e),t),parseTextSync:(e,t)=>Bt(e,t)};function as(e){return e.startsWith("<html")}function Bt(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);})(); | ||
return __exports__; | ||
}); |
@@ -7,3 +7,3 @@ // loaders.gl | ||
// @ts-ignore TS2304: Cannot find name '__VERSION__'. | ||
const VERSION = typeof "4.2.0" !== 'undefined' ? "4.2.0" : 'latest'; | ||
const VERSION = typeof "4.3.0-alpha.1" !== 'undefined' ? "4.3.0-alpha.1" : 'latest'; | ||
/** | ||
@@ -10,0 +10,0 @@ * Loader for XML files |
{ | ||
"name": "@loaders.gl/xml", | ||
"version": "4.3.0-alpha.1", | ||
"version": "4.3.0-alpha.2", | ||
"description": "Framework-independent loaders for the XML (eXtensible Markup Language) format", | ||
@@ -44,4 +44,4 @@ "license": "MIT", | ||
"dependencies": { | ||
"@loaders.gl/loader-utils": "4.3.0-alpha.1", | ||
"@loaders.gl/schema": "4.3.0-alpha.1", | ||
"@loaders.gl/loader-utils": "4.3.0-alpha.2", | ||
"@loaders.gl/schema": "4.3.0-alpha.2", | ||
"fast-xml-parser": "^4.2.5" | ||
@@ -52,3 +52,3 @@ }, | ||
}, | ||
"gitHead": "568446ea69eb590f0c42d965459b636216cda74e" | ||
"gitHead": "77a3cb538ab7a1fbf74245f25590210451689f5c" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
426680
+ Added@loaders.gl/loader-utils@4.3.0-alpha.2(transitive)
+ Added@loaders.gl/schema@4.3.0-alpha.2(transitive)
+ Added@loaders.gl/worker-utils@4.3.0-alpha.2(transitive)
- Removed@loaders.gl/loader-utils@4.3.0-alpha.1(transitive)
- Removed@loaders.gl/schema@4.3.0-alpha.1(transitive)
- Removed@loaders.gl/worker-utils@4.3.0-alpha.1(transitive)