@loaders.gl/xml
Advanced tools
Comparing version 3.4.0-alpha.2 to 3.4.0-alpha.3
@@ -24,10 +24,8 @@ "use strict"; | ||
return _regenerator.default.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
return _context.abrupt("return", _parseTextSync(new TextDecoder().decode(arrayBuffer), options)); | ||
case 1: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
while (1) switch (_context.prev = _context.next) { | ||
case 0: | ||
return _context.abrupt("return", _parseTextSync(new TextDecoder().decode(arrayBuffer), options)); | ||
case 1: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
@@ -34,0 +32,0 @@ }, _callee); |
@@ -22,3 +22,2 @@ "use strict"; | ||
} | ||
function parseXMLInBatches(text) { | ||
@@ -25,0 +24,0 @@ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
@@ -15,3 +15,2 @@ "use strict"; | ||
var StreamingXMLParser = function () { | ||
function StreamingXMLParser(options) { | ||
@@ -85,8 +84,5 @@ var _this = this; | ||
} | ||
}, { | ||
key: "_pushOrSet", | ||
value: | ||
function _pushOrSet(value) { | ||
value: function _pushOrSet(value) { | ||
var _this$currentState = this.currentState, | ||
@@ -100,4 +96,3 @@ container = _this$currentState.container, | ||
container.push(value); | ||
} else if (container) { | ||
} | ||
} else if (container) {} | ||
} | ||
@@ -104,0 +99,0 @@ }, { |
@@ -11,7 +11,5 @@ "use strict"; | ||
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); | ||
function uncapitalize(str) { | ||
return typeof str === 'string' ? str.charAt(0).toLowerCase() + str.slice(1) : str; | ||
} | ||
function uncapitalizeKeys(object) { | ||
@@ -18,0 +16,0 @@ if (Array.isArray(object)) { |
@@ -10,3 +10,2 @@ "use strict"; | ||
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); | ||
function convertXMLValueToArray(xmlValue) { | ||
@@ -16,4 +15,3 @@ if (Array.isArray(xmlValue)) { | ||
} | ||
if (xmlValue && (0, _typeof2.default)(xmlValue) === 'object' && xmlValue['0']) { | ||
} | ||
if (xmlValue && (0, _typeof2.default)(xmlValue) === 'object' && xmlValue['0']) {} | ||
if (xmlValue) { | ||
@@ -24,3 +22,2 @@ return [xmlValue]; | ||
} | ||
function convertXMLFieldToArrayInPlace(xml, key) { | ||
@@ -27,0 +24,0 @@ xml[key] = convertXMLValueToArray(xml[key]); |
@@ -20,3 +20,2 @@ "use strict"; | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
var DEFAULT_SAX_EVENTS = { | ||
@@ -320,5 +319,3 @@ ontext: function ontext() {}, | ||
}); | ||
var SAX = function () { | ||
function SAX() { | ||
@@ -424,3 +421,2 @@ (0, _classCallCheck2.default)(this, SAX); | ||
} | ||
this.S = this.STATE; | ||
@@ -521,4 +517,3 @@ } | ||
this.sgmlDecl = ''; | ||
} else if (SAX.isWhitespace(c)) { | ||
} else if (SAX.isMatch(nameStart, c)) { | ||
} else if (SAX.isWhitespace(c)) {} else if (SAX.isMatch(nameStart, c)) { | ||
this.state = this.S.OPEN_TAG; | ||
@@ -921,3 +916,2 @@ this.tagName = c; | ||
} | ||
if (this.position >= this.bufferCheckPosition) { | ||
@@ -1009,3 +1003,2 @@ this.checkBufferLength(); | ||
} | ||
this.attribList.push([this.attribName, this.attribValue]); | ||
@@ -1030,3 +1023,2 @@ } else { | ||
}; | ||
if (this.opt.xmlns) { | ||
@@ -1149,3 +1141,2 @@ tag.ns = parent.ns; | ||
var tag = this.tag; | ||
var qn = SAX.qname(this.tagName); | ||
@@ -1169,3 +1160,2 @@ tag.prefix = qn.prefix; | ||
} | ||
for (var i = 0, l = this.attribList.length; i < l; i++) { | ||
@@ -1186,3 +1176,2 @@ var nv = this.attribList[i]; | ||
}; | ||
if (prefix && prefix !== 'xmlns' && !uri) { | ||
@@ -1198,3 +1187,2 @@ this.strictFail("Unbound namespace prefix: ".concat(JSON.stringify(prefix))); | ||
this.tag.isSelfClosing = Boolean(selfClosing); | ||
this.sawRoot = true; | ||
@@ -1235,3 +1223,2 @@ this.tags.push(this.tag); | ||
} | ||
var t = this.tags.length; | ||
@@ -1250,3 +1237,2 @@ var tagName = this.tagName; | ||
} | ||
if (t < 0) { | ||
@@ -1331,3 +1317,2 @@ this.strictFail("Unmatched closing tag: ".concat(this.tagName)); | ||
var local = qualName[1]; | ||
if (attribute && name === 'xmlns') { | ||
@@ -1370,7 +1355,5 @@ prefix = 'xmlns'; | ||
_this2.attribList = []; | ||
if (_this2.opt.xmlns) { | ||
_this2.ns = Object.create(_this2.rootNS); | ||
} | ||
_this2.trackPosition = _this2.opt.position !== false; | ||
@@ -1377,0 +1360,0 @@ if (_this2.trackPosition) { |
@@ -15,3 +15,3 @@ "use strict"; | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
var VERSION = typeof "3.4.0-alpha.2" !== 'undefined' ? "3.4.0-alpha.2" : 'latest'; | ||
var VERSION = typeof "3.4.0-alpha.3" !== 'undefined' ? "3.4.0-alpha.3" : 'latest'; | ||
var XMLLoader = { | ||
@@ -38,10 +38,8 @@ name: 'XML', | ||
return _regenerator.default.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
return _context.abrupt("return", _parseTextSync(new TextDecoder().decode(arrayBuffer), options)); | ||
case 1: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
while (1) switch (_context.prev = _context.next) { | ||
case 0: | ||
return _context.abrupt("return", _parseTextSync(new TextDecoder().decode(arrayBuffer), options)); | ||
case 1: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
@@ -71,3 +69,2 @@ }, _callee); | ||
ignoreDeclaration: true, | ||
removeNSPrefix: xmlOptions.removeNSPrefix, | ||
@@ -84,3 +81,2 @@ textNodeName: xmlOptions.textNodeName, | ||
var xml = (0, _parseXml.fastParseXML)(text, fastXMLOptions); | ||
return xmlOptions.uncapitalizeKeys ? (0, _uncapitalize.uncapitalizeKeys)(xml) : xml; | ||
@@ -87,0 +83,0 @@ default: |
@@ -1,2 +0,1 @@ | ||
const moduleExports = require('./index'); | ||
@@ -3,0 +2,0 @@ globalThis.loaders = globalThis.loaders || {}; |
@@ -1,3 +0,1 @@ | ||
import { mergeLoaderOptions } from '@loaders.gl/loader-utils'; | ||
@@ -4,0 +2,0 @@ import { XMLLoader } from './xml-loader'; |
@@ -1,12 +0,6 @@ | ||
export { XMLLoader } from './xml-loader'; | ||
export { HTMLLoader } from './html-loader'; | ||
export { SAXParser } from './sax-ts/sax'; | ||
export { convertXMLValueToArray, convertXMLFieldToArrayInPlace } from './lib/xml-utils/xml-utils'; | ||
export { uncapitalize as _uncapitalize, uncapitalizeKeys as _uncapitalizeKeys } from './lib/xml-utils/uncapitalize'; | ||
//# sourceMappingURL=index.js.map |
@@ -1,3 +0,1 @@ | ||
import { StreamingXMLParser } from './streaming-xml-parser'; | ||
@@ -14,3 +12,2 @@ import { XMLParser as FastXMLParser } from 'fast-xml-parser'; | ||
} | ||
export function parseXMLInBatches(text) { | ||
@@ -17,0 +14,0 @@ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
import { SAXParser } from '../../sax-ts/sax'; | ||
export class StreamingXMLParser { | ||
constructor(options) { | ||
@@ -70,3 +67,2 @@ _defineProperty(this, "parser", void 0); | ||
} | ||
_pushOrSet(value) { | ||
@@ -82,4 +78,3 @@ const { | ||
container.push(value); | ||
} else if (container) { | ||
} | ||
} else if (container) {} | ||
} | ||
@@ -86,0 +81,0 @@ _openArray() { |
@@ -1,7 +0,4 @@ | ||
export function uncapitalize(str) { | ||
return typeof str === 'string' ? str.charAt(0).toLowerCase() + str.slice(1) : str; | ||
} | ||
export function uncapitalizeKeys(object) { | ||
@@ -8,0 +5,0 @@ if (Array.isArray(object)) { |
@@ -1,3 +0,1 @@ | ||
export function convertXMLValueToArray(xmlValue) { | ||
@@ -7,4 +5,3 @@ if (Array.isArray(xmlValue)) { | ||
} | ||
if (xmlValue && typeof xmlValue === 'object' && xmlValue['0']) { | ||
} | ||
if (xmlValue && typeof xmlValue === 'object' && xmlValue['0']) {} | ||
if (xmlValue) { | ||
@@ -15,3 +12,2 @@ return [xmlValue]; | ||
} | ||
export function convertXMLFieldToArrayInPlace(xml, key) { | ||
@@ -18,0 +14,0 @@ xml[key] = convertXMLValueToArray(xml[key]); |
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
const DEFAULT_SAX_EVENTS = { | ||
@@ -301,5 +300,3 @@ ontext: () => {}, | ||
}); | ||
class SAX { | ||
constructor() { | ||
@@ -406,3 +403,2 @@ _defineProperty(this, "EVENTS", EVENTS); | ||
} | ||
this.S = this.STATE; | ||
@@ -437,3 +433,2 @@ } | ||
let local = qualName[1]; | ||
if (attribute && name === 'xmlns') { | ||
@@ -539,4 +534,3 @@ prefix = 'xmlns'; | ||
this.sgmlDecl = ''; | ||
} else if (SAX.isWhitespace(c)) { | ||
} else if (SAX.isMatch(nameStart, c)) { | ||
} else if (SAX.isWhitespace(c)) {} else if (SAX.isMatch(nameStart, c)) { | ||
this.state = this.S.OPEN_TAG; | ||
@@ -939,3 +933,2 @@ this.tagName = c; | ||
} | ||
if (this.position >= this.bufferCheckPosition) { | ||
@@ -1015,3 +1008,2 @@ this.checkBufferLength(); | ||
} | ||
this.attribList.push([this.attribName, this.attribValue]); | ||
@@ -1034,3 +1026,2 @@ } else { | ||
}; | ||
if (this.opt.xmlns) { | ||
@@ -1137,3 +1128,2 @@ tag.ns = parent.ns; | ||
const tag = this.tag; | ||
const qn = SAX.qname(this.tagName); | ||
@@ -1157,3 +1147,2 @@ tag.prefix = qn.prefix; | ||
} | ||
for (let i = 0, l = this.attribList.length; i < l; i++) { | ||
@@ -1174,3 +1163,2 @@ const nv = this.attribList[i]; | ||
}; | ||
if (prefix && prefix !== 'xmlns' && !uri) { | ||
@@ -1186,3 +1174,2 @@ this.strictFail("Unbound namespace prefix: ".concat(JSON.stringify(prefix))); | ||
this.tag.isSelfClosing = Boolean(selfClosing); | ||
this.sawRoot = true; | ||
@@ -1220,3 +1207,2 @@ this.tags.push(this.tag); | ||
} | ||
let t = this.tags.length; | ||
@@ -1235,3 +1221,2 @@ let tagName = this.tagName; | ||
} | ||
if (t < 0) { | ||
@@ -1273,3 +1258,2 @@ this.strictFail("Unmatched closing tag: ".concat(this.tagName)); | ||
} | ||
export class SAXParser extends SAX { | ||
@@ -1302,7 +1286,5 @@ constructor(opt) { | ||
this.attribList = []; | ||
if (this.opt.xmlns) { | ||
this.ns = Object.create(this.rootNS); | ||
} | ||
this.trackPosition = this.opt.position !== false; | ||
@@ -1309,0 +1291,0 @@ if (this.trackPosition) { |
import { fastParseXML } from './lib/parsers/parse-xml'; | ||
import { uncapitalizeKeys } from './lib/xml-utils/uncapitalize'; | ||
const VERSION = typeof "3.4.0-alpha.2" !== 'undefined' ? "3.4.0-alpha.2" : 'latest'; | ||
const VERSION = typeof "3.4.0-alpha.3" !== 'undefined' ? "3.4.0-alpha.3" : 'latest'; | ||
export const XMLLoader = { | ||
@@ -40,3 +39,2 @@ name: 'XML', | ||
ignoreDeclaration: true, | ||
removeNSPrefix: xmlOptions.removeNSPrefix, | ||
@@ -52,3 +50,2 @@ textNodeName: xmlOptions.textNodeName, | ||
const xml = fastParseXML(text, fastXMLOptions); | ||
return xmlOptions.uncapitalizeKeys ? uncapitalizeKeys(xml) : xml; | ||
@@ -55,0 +52,0 @@ default: |
@@ -1439,3 +1439,3 @@ "use strict"; | ||
} | ||
SAXParser.ENTITIES = exports.ENTITIES; | ||
exports.SAXParser = SAXParser; | ||
SAXParser.ENTITIES = exports.ENTITIES; |
{ | ||
"name": "@loaders.gl/xml", | ||
"version": "3.4.0-alpha.2", | ||
"version": "3.4.0-alpha.3", | ||
"description": "Framework-independent loaders for the XML (eXtensible Markup Language) format", | ||
@@ -36,4 +36,4 @@ "license": "MIT", | ||
"@babel/runtime": "^7.3.1", | ||
"@loaders.gl/loader-utils": "3.4.0-alpha.2", | ||
"@loaders.gl/schema": "3.4.0-alpha.2", | ||
"@loaders.gl/loader-utils": "3.4.0-alpha.3", | ||
"@loaders.gl/schema": "3.4.0-alpha.3", | ||
"fast-xml-parser": "^4.1.3" | ||
@@ -44,3 +44,3 @@ }, | ||
}, | ||
"gitHead": "f1c00c124d8d0c41a138ff40afb0d1a00711bf2e" | ||
"gitHead": "a954528dd1d78a1f128d8f6b07e4baeb7a296924" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
592924
10271
+ Added@loaders.gl/loader-utils@3.4.0-alpha.3(transitive)
+ Added@loaders.gl/schema@3.4.0-alpha.3(transitive)
+ Added@loaders.gl/worker-utils@3.4.0-alpha.3(transitive)
- Removed@loaders.gl/loader-utils@3.4.0-alpha.2(transitive)
- Removed@loaders.gl/schema@3.4.0-alpha.2(transitive)
- Removed@loaders.gl/worker-utils@3.4.0-alpha.2(transitive)