@loaders.gl/xml 4.4.0-alpha.11 → 4.4.0-alpha.12
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.min.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/xml-loader.js +1 -1
- package/package.json +4 -4
package/dist/dist.min.js
CHANGED
|
@@ -18,6 +18,6 @@ Line: ${this.line}
|
|
|
18
18
|
Column: ${this.column}
|
|
19
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=f.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
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):f.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 A))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 a=this[this.BUFFERS[r]]?.length||0;if(a>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,a)}let s=this.opt.MAX_BUFFER_LENGTH-i;this.bufferCheckPosition=s+this.position}openTag(t){if(this.opt.xmlns){let i=this.tag,s=f.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(a=>{n.emitNode("onopennamespace",{prefix:a,uri:i.ns[a]})})}for(let n=0,a=this.attribList.length;n<a;n++){let h=this.attribList[n],o=h[0],c=h[1],u=f.qname(o,!0),l=u.prefix,p=u.local,N=l===""?"":i.ns[l]||"",d={name:o,value:c,prefix:l,local:p,uri:N};l&&l!=="xmlns"&&!N&&(this.strictFail(`Unbound namespace prefix: ${JSON.stringify(l)}`),d.uri=l),this.tag.attributes[o]=d,this.emitNode("onattribute",d)}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 h in r.ns)r.ns.hasOwnProperty(h)&&(n[h]=r.ns[h]);let a=this.tags[this.tags.length-1]||this;if(this.opt.xmlns&&r.ns!==a.ns){let h=this;Object.keys(r.ns).forEach(o=>{let c=r.ns[o];h.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}},A=class extends f{opt=Ht;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(A,"ENTITIES",_);function v(e){return typeof e=="string"?e.charAt(0).toLowerCase()+e.slice(1):e}function x(e){if(Array.isArray(e))return e.map(t=>x(t));if(e&&typeof e=="object"){let t={};for(let[i,s]of Object.entries(e))t[v(i)]=x(s);return t}return e}var Mt=Z(Bt(),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,a,h)=>Boolean(t?.arrayPaths?.some(c=>n===c)),...t?._fastXML},s=cs(e,i);return t?.uncapitalizeKeys?x(s):s}function cs(e,t){return new Mt.XMLParser({ignoreAttributes:!1,attributeNamePrefix:"",...t}).parse(e)}var us="4.4.0-alpha.
|
|
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):f.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 A))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 a=this[this.BUFFERS[r]]?.length||0;if(a>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,a)}let s=this.opt.MAX_BUFFER_LENGTH-i;this.bufferCheckPosition=s+this.position}openTag(t){if(this.opt.xmlns){let i=this.tag,s=f.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(a=>{n.emitNode("onopennamespace",{prefix:a,uri:i.ns[a]})})}for(let n=0,a=this.attribList.length;n<a;n++){let h=this.attribList[n],o=h[0],c=h[1],u=f.qname(o,!0),l=u.prefix,p=u.local,N=l===""?"":i.ns[l]||"",d={name:o,value:c,prefix:l,local:p,uri:N};l&&l!=="xmlns"&&!N&&(this.strictFail(`Unbound namespace prefix: ${JSON.stringify(l)}`),d.uri=l),this.tag.attributes[o]=d,this.emitNode("onattribute",d)}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 h in r.ns)r.ns.hasOwnProperty(h)&&(n[h]=r.ns[h]);let a=this.tags[this.tags.length-1]||this;if(this.opt.xmlns&&r.ns!==a.ns){let h=this;Object.keys(r.ns).forEach(o=>{let c=r.ns[o];h.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}},A=class extends f{opt=Ht;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(A,"ENTITIES",_);function v(e){return typeof e=="string"?e.charAt(0).toLowerCase()+e.slice(1):e}function x(e){if(Array.isArray(e))return e.map(t=>x(t));if(e&&typeof e=="object"){let t={};for(let[i,s]of Object.entries(e))t[v(i)]=x(s);return t}return e}var Mt=Z(Bt(),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,a,h)=>Boolean(t?.arrayPaths?.some(c=>n===c)),...t?._fastXML},s=cs(e,i);return t?.uncapitalizeKeys?x(s):s}function cs(e,t){return new Mt.XMLParser({ignoreAttributes:!1,attributeNamePrefix:"",...t}).parse(e)}var us="4.4.0-alpha.12",y={dataType:null,batchType:null,name:"XML",id:"xml",module:"xml",version:us,worker:!1,extensions:["xml"],mimeTypes:["application/xml","text/xml"],testText:ls,options:{xml:{_parser:"fast-xml-parser",uncapitalizeKeys:!1,removeNSPrefix:!1,textNodeName:"value",arrayPaths:[]}},parse:async(e,t)=>H(new TextDecoder().decode(e),{...y.options.xml,...t?.xml}),parseTextSync:(e,t)=>H(e,{...y.options.xml,...t?.xml})};function ls(e){return e.startsWith("<?xml")}function z(e,t){return Rt(e||{},t)}function Rt(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]=Rt(s[r]||{},t[r],i+1):s[r]=t[r];return s}var vt={...y,name:"HTML",id:"html",extensions:["html","htm"],mimeTypes:["text/html"],testText:fs,parse:async(e,t)=>Vt(new TextDecoder().decode(e),t),parseTextSync:(e,t)=>Vt(e,t)};function fs(e){return e.startsWith("<html")}function Vt(e,t){return t=z(t,{xml:{_parser:"fast-xml-parser",_fastXML:{htmlEntities:!0}}}),y.parseTextSync?.(e,t)}function K(e){return Array.isArray(e)?e:(e&&typeof e=="object"&&e[0],e?[e]:[])}function Ut(e,t){e[t]=K(e[t])}return Qt(L);})();
|
|
22
22
|
return __exports__;
|
|
23
23
|
});
|
package/dist/index.cjs
CHANGED
|
@@ -1472,7 +1472,7 @@ function fastParseXML(text, options) {
|
|
|
1472
1472
|
}
|
|
1473
1473
|
|
|
1474
1474
|
// dist/xml-loader.js
|
|
1475
|
-
var VERSION = true ? "4.4.0-alpha.
|
|
1475
|
+
var VERSION = true ? "4.4.0-alpha.12" : "latest";
|
|
1476
1476
|
var XMLLoader = {
|
|
1477
1477
|
dataType: null,
|
|
1478
1478
|
batchType: null,
|
package/dist/xml-loader.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { parseXMLSync } from "./lib/parsers/parse-xml.js";
|
|
5
5
|
// __VERSION__ is injected by babel-plugin-version-inline
|
|
6
6
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
7
|
-
const VERSION = typeof "4.4.0-alpha.
|
|
7
|
+
const VERSION = typeof "4.4.0-alpha.12" !== 'undefined' ? "4.4.0-alpha.12" : 'latest';
|
|
8
8
|
/**
|
|
9
9
|
* Loader for XML files
|
|
10
10
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/xml",
|
|
3
|
-
"version": "4.4.0-alpha.
|
|
3
|
+
"version": "4.4.0-alpha.12",
|
|
4
4
|
"description": "Framework-independent loaders for the XML (eXtensible Markup Language) format",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -41,12 +41,12 @@
|
|
|
41
41
|
"build-bundle-dev": "ocular-bundle ./bundle.ts --env=dev --output=dist/dist.dev.js"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@loaders.gl/loader-utils": "4.4.0-alpha.
|
|
45
|
-
"@loaders.gl/schema": "4.4.0-alpha.
|
|
44
|
+
"@loaders.gl/loader-utils": "4.4.0-alpha.12",
|
|
45
|
+
"@loaders.gl/schema": "4.4.0-alpha.12",
|
|
46
46
|
"fast-xml-parser": "^4.2.5"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"@loaders.gl/core": "4.4.0-alpha.1"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "35205e786cbbcf4bd91b74abe210f6c8e378b4cf"
|
|
52
52
|
}
|