@loaders.gl/xml 4.0.0-alpha.9 → 4.0.0-beta.2

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 CHANGED
@@ -1380,9 +1380,9 @@ Actual: ${this.attribValue}`);
1380
1380
  }
1381
1381
  });
1382
1382
 
1383
- // node_modules/fast-xml-parser/src/util.js
1383
+ // ../../node_modules/fast-xml-parser/src/util.js
1384
1384
  var require_util = __commonJS({
1385
- "node_modules/fast-xml-parser/src/util.js"(exports) {
1385
+ "../../node_modules/fast-xml-parser/src/util.js"(exports) {
1386
1386
  "use strict";
1387
1387
  var nameStartChar = ":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";
1388
1388
  var nameChar = nameStartChar + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
@@ -1439,9 +1439,9 @@ Actual: ${this.attribValue}`);
1439
1439
  }
1440
1440
  });
1441
1441
 
1442
- // node_modules/fast-xml-parser/src/validator.js
1442
+ // ../../node_modules/fast-xml-parser/src/validator.js
1443
1443
  var require_validator = __commonJS({
1444
- "node_modules/fast-xml-parser/src/validator.js"(exports) {
1444
+ "../../node_modules/fast-xml-parser/src/validator.js"(exports) {
1445
1445
  "use strict";
1446
1446
  var util = require_util();
1447
1447
  var defaultOptions = {
@@ -1745,9 +1745,9 @@ Actual: ${this.attribValue}`);
1745
1745
  }
1746
1746
  });
1747
1747
 
1748
- // node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js
1748
+ // ../../node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js
1749
1749
  var require_OptionsBuilder = __commonJS({
1750
- "node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js"(exports) {
1750
+ "../../node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js"(exports) {
1751
1751
  var defaultOptions = {
1752
1752
  preserveOrder: false,
1753
1753
  attributeNamePrefix: "@_",
@@ -1794,9 +1794,9 @@ Actual: ${this.attribValue}`);
1794
1794
  }
1795
1795
  });
1796
1796
 
1797
- // node_modules/fast-xml-parser/src/xmlparser/xmlNode.js
1797
+ // ../../node_modules/fast-xml-parser/src/xmlparser/xmlNode.js
1798
1798
  var require_xmlNode = __commonJS({
1799
- "node_modules/fast-xml-parser/src/xmlparser/xmlNode.js"(exports, module) {
1799
+ "../../node_modules/fast-xml-parser/src/xmlparser/xmlNode.js"(exports, module) {
1800
1800
  "use strict";
1801
1801
  var XmlNode = class {
1802
1802
  constructor(tagname) {
@@ -1823,9 +1823,10 @@ Actual: ${this.attribValue}`);
1823
1823
  }
1824
1824
  });
1825
1825
 
1826
- // node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js
1826
+ // ../../node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js
1827
1827
  var require_DocTypeReader = __commonJS({
1828
- "node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js"(exports, module) {
1828
+ "../../node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js"(exports, module) {
1829
+ var util = require_util();
1829
1830
  function readDocType(xmlData, i) {
1830
1831
  const entities = {};
1831
1832
  if (xmlData[i + 3] === "O" && xmlData[i + 4] === "C" && xmlData[i + 5] === "T" && xmlData[i + 6] === "Y" && xmlData[i + 7] === "P" && xmlData[i + 8] === "E") {
@@ -1839,7 +1840,7 @@ Actual: ${this.attribValue}`);
1839
1840
  i += 7;
1840
1841
  [entityName, val, i] = readEntityExp(xmlData, i + 1);
1841
1842
  if (val.indexOf("&") === -1)
1842
- entities[entityName] = {
1843
+ entities[validateEntityName(entityName)] = {
1843
1844
  regx: RegExp(`&${entityName};`, "g"),
1844
1845
  val
1845
1846
  };
@@ -1921,6 +1922,12 @@ Actual: ${this.attribValue}`);
1921
1922
  return true;
1922
1923
  return false;
1923
1924
  }
1925
+ function validateEntityName(name) {
1926
+ if (util.isName(name))
1927
+ return name;
1928
+ else
1929
+ throw new Error(`Invalid entity name ${name}`);
1930
+ }
1924
1931
  module.exports = readDocType;
1925
1932
  }
1926
1933
  });
@@ -2021,9 +2028,9 @@ Actual: ${this.attribValue}`);
2021
2028
  }
2022
2029
  });
2023
2030
 
2024
- // node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js
2031
+ // ../../node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js
2025
2032
  var require_OrderedObjParser = __commonJS({
2026
- "node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js"(exports, module) {
2033
+ "../../node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js"(exports, module) {
2027
2034
  "use strict";
2028
2035
  var util = require_util();
2029
2036
  var xmlNode = require_xmlNode();
@@ -2495,9 +2502,9 @@ Actual: ${this.attribValue}`);
2495
2502
  }
2496
2503
  });
2497
2504
 
2498
- // node_modules/fast-xml-parser/src/xmlparser/node2json.js
2505
+ // ../../node_modules/fast-xml-parser/src/xmlparser/node2json.js
2499
2506
  var require_node2json = __commonJS({
2500
- "node_modules/fast-xml-parser/src/xmlparser/node2json.js"(exports) {
2507
+ "../../node_modules/fast-xml-parser/src/xmlparser/node2json.js"(exports) {
2501
2508
  "use strict";
2502
2509
  function prettify(node, options) {
2503
2510
  return compress(node, options);
@@ -2591,9 +2598,9 @@ Actual: ${this.attribValue}`);
2591
2598
  }
2592
2599
  });
2593
2600
 
2594
- // node_modules/fast-xml-parser/src/xmlparser/XMLParser.js
2601
+ // ../../node_modules/fast-xml-parser/src/xmlparser/XMLParser.js
2595
2602
  var require_XMLParser = __commonJS({
2596
- "node_modules/fast-xml-parser/src/xmlparser/XMLParser.js"(exports, module) {
2603
+ "../../node_modules/fast-xml-parser/src/xmlparser/XMLParser.js"(exports, module) {
2597
2604
  var { buildOptions } = require_OptionsBuilder();
2598
2605
  var OrderedObjParser = require_OrderedObjParser();
2599
2606
  var { prettify } = require_node2json();
@@ -2642,9 +2649,9 @@ Actual: ${this.attribValue}`);
2642
2649
  }
2643
2650
  });
2644
2651
 
2645
- // node_modules/fast-xml-parser/src/xmlbuilder/orderedJs2Xml.js
2652
+ // ../../node_modules/fast-xml-parser/src/xmlbuilder/orderedJs2Xml.js
2646
2653
  var require_orderedJs2Xml = __commonJS({
2647
- "node_modules/fast-xml-parser/src/xmlbuilder/orderedJs2Xml.js"(exports, module) {
2654
+ "../../node_modules/fast-xml-parser/src/xmlbuilder/orderedJs2Xml.js"(exports, module) {
2648
2655
  var EOL = "\n";
2649
2656
  function toXml(jArray, options) {
2650
2657
  let indentation = "";
@@ -2770,9 +2777,9 @@ Actual: ${this.attribValue}`);
2770
2777
  }
2771
2778
  });
2772
2779
 
2773
- // node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js
2780
+ // ../../node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js
2774
2781
  var require_json2xml = __commonJS({
2775
- "node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js"(exports, module) {
2782
+ "../../node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js"(exports, module) {
2776
2783
  "use strict";
2777
2784
  var buildFromOrderedJs = require_orderedJs2Xml();
2778
2785
  var defaultOptions = {
@@ -2995,9 +3002,9 @@ Actual: ${this.attribValue}`);
2995
3002
  }
2996
3003
  });
2997
3004
 
2998
- // node_modules/fast-xml-parser/src/fxp.js
3005
+ // ../../node_modules/fast-xml-parser/src/fxp.js
2999
3006
  var require_fxp = __commonJS({
3000
- "node_modules/fast-xml-parser/src/fxp.js"(exports, module) {
3007
+ "../../node_modules/fast-xml-parser/src/fxp.js"(exports, module) {
3001
3008
  "use strict";
3002
3009
  var validator = require_validator();
3003
3010
  var XMLParser = require_XMLParser();
@@ -3089,7 +3096,7 @@ Actual: ${this.attribValue}`);
3089
3096
  function mergeOptionsRecursively(baseOptions, newOptions) {
3090
3097
  const options = { ...baseOptions };
3091
3098
  for (const [key, newValue] of Object.entries(newOptions)) {
3092
- if (newValue && typeof newValue === "object") {
3099
+ if (newValue && typeof newValue === "object" && !Array.isArray(newValue)) {
3093
3100
  options[key] = mergeOptionsRecursively(options[key] || {}, newOptions[key]);
3094
3101
  } else {
3095
3102
  options[key] = newOptions[key];
@@ -1 +1 @@
1
- {"version":3,"file":"html-loader.js","names":["_loaderUtils","require","_xmlLoader","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","HTMLLoader","XMLLoader","name","id","extensions","mimeTypes","testText","testHTMLFile","parse","_parse","_asyncToGenerator2","_regenerator","mark","_callee","arrayBuffer","options","wrap","_callee$","_context","prev","next","abrupt","parseTextSync","TextDecoder","decode","stop","_x","_x2","text","exports","startsWith","_XMLLoader$parseTextS","mergeLoaderOptions","xml","_parser","_fastXML","htmlEntities","call"],"sources":["../../src/html-loader.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {mergeLoaderOptions} from '@loaders.gl/loader-utils';\nimport {XMLLoader, XMLLoaderOptions} from './xml-loader';\n\nexport type HTMLLoaderOptions = XMLLoaderOptions;\n\n/**\n * Loader for HTML files\n * Essentially a copy of the XMLLoader with different mime types, file extensions and content tests.\n * This split enables applications can control whether they want HTML responses to be parsed by the XML loader or not.\n * This loader does not have any additional understanding of the structure of HTML or the document.\n */\nexport const HTMLLoader: LoaderWithParser = {\n ...XMLLoader,\n name: 'HTML',\n id: 'html',\n extensions: ['html', 'htm'],\n mimeTypes: ['text/html'],\n testText: testHTMLFile,\n parse: async (arrayBuffer: ArrayBuffer, options?: XMLLoaderOptions) =>\n parseTextSync(new TextDecoder().decode(arrayBuffer), options),\n parseTextSync: (text: string, options?: XMLLoaderOptions) => parseTextSync(text, options)\n};\n\nfunction testHTMLFile(text: string): boolean {\n // TODO - There could be space first.\n return text.startsWith('<html');\n}\n\nfunction parseTextSync(text: string, options?: XMLLoaderOptions): any {\n // fast-xml-parser can recognize HTML entities\n // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md#htmlentities\n // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/5.Entities.md\n options = mergeLoaderOptions(options, {\n xml: {\n _parser: 'fast-xml-parser',\n _fastXML: {\n htmlEntities: true\n }\n }\n });\n\n return XMLLoader.parseTextSync?.(text, options);\n}\n"],"mappings":";;;;;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAAyD,SAAAE,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,WAAAJ,MAAA,CAAAK,wBAAA,CAAAR,MAAA,EAAAO,GAAA,EAAAE,UAAA,OAAAP,IAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,IAAA,EAAAG,OAAA,YAAAH,IAAA;AAAA,SAAAU,cAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAF,CAAA,UAAAG,MAAA,WAAAF,SAAA,CAAAD,CAAA,IAAAC,SAAA,CAAAD,CAAA,QAAAA,CAAA,OAAAf,OAAA,CAAAI,MAAA,CAAAc,MAAA,OAAAC,OAAA,WAAAC,GAAA,QAAAC,gBAAA,CAAAC,OAAA,EAAAR,MAAA,EAAAM,GAAA,EAAAF,MAAA,CAAAE,GAAA,SAAAhB,MAAA,CAAAmB,yBAAA,GAAAnB,MAAA,CAAAoB,gBAAA,CAAAV,MAAA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F,SAASO,YAAYA,CAACqB,IAAY,EAAW;EAE3C,OAAOA,IAAI,CAACE,UAAU,CAAC,OAAO,CAAC;AACjC;AAEA,SAASR,cAAaA,CAACM,IAAY,EAAEb,OAA0B,EAAO;EAAA,IAAAgB,qBAAA;EAIpEhB,OAAO,GAAG,IAAAiB,+BAAkB,EAACjB,OAAO,EAAE;IACpCkB,GAAG,EAAE;MACHC,OAAO,EAAE,iBAAiB;MAC1BC,QAAQ,EAAE;QACRC,YAAY,EAAE;MAChB;IACF;EACF,CAAC,CAAC;EAEF,QAAAL,qBAAA,GAAO9B,oBAAS,CAACqB,aAAa,cAAAS,qBAAA,uBAAvBA,qBAAA,CAAAM,IAAA,CAAApC,oBAAS,EAAiB2B,IAAI,EAAEb,OAAO,CAAC;AACjD"}
1
+ {"version":3,"file":"html-loader.js","names":["_loaderUtils","require","_xmlLoader","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","HTMLLoader","XMLLoader","name","id","extensions","mimeTypes","testText","testHTMLFile","parse","_parse","_asyncToGenerator2","_regenerator","mark","_callee","arrayBuffer","options","wrap","_callee$","_context","prev","next","abrupt","parseTextSync","TextDecoder","decode","stop","_x","_x2","text","exports","startsWith","_XMLLoader$parseTextS","mergeLoaderOptions","xml","_parser","_fastXML","htmlEntities","call"],"sources":["../../src/html-loader.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {mergeLoaderOptions} from '@loaders.gl/loader-utils';\nimport {XMLLoader, XMLLoaderOptions} from './xml-loader';\n\nexport type HTMLLoaderOptions = XMLLoaderOptions;\n\n/**\n * Loader for HTML files\n * Essentially a copy of the XMLLoader with different mime types, file extensions and content tests.\n * This split enables applications can control whether they want HTML responses to be parsed by the XML loader or not.\n * This loader does not have any additional understanding of the structure of HTML or the document.\n */\nexport const HTMLLoader: LoaderWithParser<any, never, HTMLLoaderOptions> = {\n ...XMLLoader,\n name: 'HTML',\n id: 'html',\n extensions: ['html', 'htm'],\n mimeTypes: ['text/html'],\n testText: testHTMLFile,\n parse: async (arrayBuffer: ArrayBuffer, options?: XMLLoaderOptions) =>\n parseTextSync(new TextDecoder().decode(arrayBuffer), options),\n parseTextSync: (text: string, options?: XMLLoaderOptions) => parseTextSync(text, options)\n};\n\nfunction testHTMLFile(text: string): boolean {\n // TODO - There could be space first.\n return text.startsWith('<html');\n}\n\nfunction parseTextSync(text: string, options?: XMLLoaderOptions): any {\n // fast-xml-parser can recognize HTML entities\n // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md#htmlentities\n // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/5.Entities.md\n options = mergeLoaderOptions(options, {\n xml: {\n _parser: 'fast-xml-parser',\n _fastXML: {\n htmlEntities: true\n }\n }\n });\n\n return XMLLoader.parseTextSync?.(text, options);\n}\n"],"mappings":";;;;;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAAyD,SAAAE,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,WAAAJ,MAAA,CAAAK,wBAAA,CAAAR,MAAA,EAAAO,GAAA,EAAAE,UAAA,OAAAP,IAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,IAAA,EAAAG,OAAA,YAAAH,IAAA;AAAA,SAAAU,cAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAF,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,OAAA;IAAA;IAAA,SAAAL,MAAAkB,EAAA,EAAAC,GAAA;MAAA,OAAAlB,MAAA,CAAAvB,KAAA,OAAAI,SAAA;IAAA;IAAA,OAAAkB,KAAA;EAAA;EAC/Dc,aAAa,EAAE,SAAAA,cAACM,IAAY,EAAEb,OAA0B;IAAA,OAAKO,cAAa,CAACM,IAAI,EAAEb,OAAO,CAAC;EAAA;AAAA,EAC1F;AAACc,OAAA,CAAA7B,UAAA,GAAAA,UAAA;AAEF,SAASO,YAAYA,CAACqB,IAAY,EAAW;EAE3C,OAAOA,IAAI,CAACE,UAAU,CAAC,OAAO,CAAC;AACjC;AAEA,SAASR,cAAaA,CAACM,IAAY,EAAEb,OAA0B,EAAO;EAAA,IAAAgB,qBAAA;EAIpEhB,OAAO,GAAG,IAAAiB,+BAAkB,EAACjB,OAAO,EAAE;IACpCkB,GAAG,EAAE;MACHC,OAAO,EAAE,iBAAiB;MAC1BC,QAAQ,EAAE;QACRC,YAAY,EAAE;MAChB;IACF;EACF,CAAC,CAAC;EAEF,QAAAL,qBAAA,GAAO9B,oBAAS,CAACqB,aAAa,cAAAS,qBAAA,uBAAvBA,qBAAA,CAAAM,IAAA,CAAApC,oBAAS,EAAiB2B,IAAI,EAAEb,OAAO,CAAC;AACjD"}
@@ -11,7 +11,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
11
11
  var _parseXml = require("./lib/parsers/parse-xml");
12
12
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
13
13
  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; }
14
- var VERSION = typeof "4.0.0-alpha.9" !== 'undefined' ? "4.0.0-alpha.9" : 'latest';
14
+ var VERSION = typeof "4.0.0-beta.2" !== 'undefined' ? "4.0.0-beta.2" : 'latest';
15
15
  var XMLLoader = {
16
16
  name: 'XML',
17
17
  id: 'xml',
@@ -1 +1 @@
1
- {"version":3,"file":"xml-loader.js","names":["_parseXml","require","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","VERSION","XMLLoader","name","id","module","version","worker","extensions","mimeTypes","testText","testXMLFile","options","xml","_parser","uncapitalizeKeys","removeNSPrefix","textNodeName","arrayPaths","parse","_parse","_asyncToGenerator2","_regenerator","mark","_callee","arrayBuffer","wrap","_callee$","_context","prev","next","abrupt","parseXMLSync","TextDecoder","decode","stop","_x","_x2","parseTextSync","text","exports","startsWith"],"sources":["../../src/xml-loader.ts"],"sourcesContent":["import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport type {ParseXMLOptions} from './lib/parsers/parse-xml';\nimport {parseXMLSync} from './lib/parsers/parse-xml';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type XMLLoaderOptions = LoaderOptions & {\n xml?: ParseXMLOptions;\n};\n\n/**\n * Loader for XML files\n */\nexport const XMLLoader: LoaderWithParser<any, never, XMLLoaderOptions> = {\n name: 'XML',\n id: 'xml',\n module: 'xml',\n version: VERSION,\n worker: false,\n extensions: ['xml'],\n mimeTypes: ['application/xml', 'text/xml'],\n testText: testXMLFile,\n options: {\n xml: {\n _parser: 'fast-xml-parser',\n uncapitalizeKeys: false,\n removeNSPrefix: false,\n textNodeName: 'value',\n arrayPaths: []\n }\n },\n parse: async (arrayBuffer: ArrayBuffer, options?: XMLLoaderOptions) =>\n parseXMLSync(new TextDecoder().decode(arrayBuffer), {\n ...XMLLoader.options.xml,\n ...options?.xml\n }),\n parseTextSync: (text: string, options?: XMLLoaderOptions) =>\n parseXMLSync(text, {...XMLLoader.options.xml, ...options?.xml})\n};\n\nfunction testXMLFile(text: string): boolean {\n // TODO - There could be space first.\n return text.startsWith('<?xml');\n}\n"],"mappings":";;;;;;;;;;AAEA,IAAAA,SAAA,GAAAC,OAAA;AAAqD,SAAAC,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,WAAAJ,MAAA,CAAAK,wBAAA,CAAAR,MAAA,EAAAO,GAAA,EAAAE,UAAA,OAAAP,IAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,IAAA,EAAAG,OAAA,YAAAH,IAAA;AAAA,SAAAU,cAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAF,CAAA,UAAAG,MAAA,WAAAF,SAAA,CAAAD,CAAA,IAAAC,SAAA,CAAAD,CAAA,QAAAA,CAAA,OAAAf,OAAA,CAAAI,MAAA,CAAAc,MAAA,OAAAC,OAAA,WAAAC,GAAA,QAAAC,gBAAA,CAAAC,OAAA,EAAAR,MAAA,EAAAM,GAAA,EAAAF,MAAA,CAAAE,GAAA,SAAAhB,MAAA,CAAAmB,yBAAA,GAAAnB,MAAA,CAAAoB,gBAAA,CAAAV,MAAA,EAAAV,MAAA,CAAA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,GAAG,CAChB,CAAC;UAAA;UAAA;YAAA,OAAAe,QAAA,CAAAO,IAAA;QAAA;MAAA,GAAAX,OAAA;IAAA;IAAA,SAAAL,MAAAiB,EAAA,EAAAC,GAAA;MAAA,OAAAjB,MAAA,CAAAjC,KAAA,OAAAI,SAAA;IAAA;IAAA,OAAA4B,KAAA;EAAA;EACJmB,aAAa,EAAE,SAAAA,cAACC,IAAY,EAAE3B,OAA0B;IAAA,OACtD,IAAAoB,sBAAY,EAACO,IAAI,EAAAnD,aAAA,CAAAA,aAAA,KAAMc,SAAS,CAACU,OAAO,CAACC,GAAG,GAAKD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,GAAG,CAAC,CAAC;EAAA;AACnE,CAAC;AAAC2B,OAAA,CAAAtC,SAAA,GAAAA,SAAA;AAEF,SAASS,WAAWA,CAAC4B,IAAY,EAAW;EAE1C,OAAOA,IAAI,CAACE,UAAU,CAAC,OAAO,CAAC;AACjC"}
1
+ {"version":3,"file":"xml-loader.js","names":["_parseXml","require","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","VERSION","XMLLoader","name","id","module","version","worker","extensions","mimeTypes","testText","testXMLFile","options","xml","_parser","uncapitalizeKeys","removeNSPrefix","textNodeName","arrayPaths","parse","_parse","_asyncToGenerator2","_regenerator","mark","_callee","arrayBuffer","wrap","_callee$","_context","prev","next","abrupt","parseXMLSync","TextDecoder","decode","stop","_x","_x2","parseTextSync","text","exports","startsWith"],"sources":["../../src/xml-loader.ts"],"sourcesContent":["import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport type {ParseXMLOptions} from './lib/parsers/parse-xml';\nimport {parseXMLSync} from './lib/parsers/parse-xml';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type XMLLoaderOptions = LoaderOptions & {\n xml?: ParseXMLOptions;\n};\n\n/**\n * Loader for XML files\n */\nexport const XMLLoader: LoaderWithParser<any, never, XMLLoaderOptions> = {\n name: 'XML',\n id: 'xml',\n module: 'xml',\n version: VERSION,\n worker: false,\n extensions: ['xml'],\n mimeTypes: ['application/xml', 'text/xml'],\n testText: testXMLFile,\n options: {\n xml: {\n _parser: 'fast-xml-parser',\n uncapitalizeKeys: false,\n removeNSPrefix: false,\n textNodeName: 'value',\n arrayPaths: []\n }\n },\n parse: async (arrayBuffer: ArrayBuffer, options?: XMLLoaderOptions) =>\n parseXMLSync(new TextDecoder().decode(arrayBuffer), {\n ...XMLLoader.options.xml,\n ...options?.xml\n }),\n parseTextSync: (text: string, options?: XMLLoaderOptions) =>\n parseXMLSync(text, {...XMLLoader.options.xml, ...options?.xml})\n};\n\nfunction testXMLFile(text: string): boolean {\n // TODO - There could be space first.\n return text.startsWith('<?xml');\n}\n"],"mappings":";;;;;;;;;;AAEA,IAAAA,SAAA,GAAAC,OAAA;AAAqD,SAAAC,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,WAAAJ,MAAA,CAAAK,wBAAA,CAAAR,MAAA,EAAAO,GAAA,EAAAE,UAAA,OAAAP,IAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,IAAA,EAAAG,OAAA,YAAAH,IAAA;AAAA,SAAAU,cAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAF,CAAA,UAAAG,MAAA,WAAAF,SAAA,CAAA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BAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;UAAA;YAAA,OAAAF,QAAA,CAAAG,MAAA,WAChE,IAAAC,sBAAY,EAAC,IAAIC,WAAW,CAAC,CAAC,CAACC,MAAM,CAACT,WAAW,CAAC,EAAArC,aAAA,CAAAA,aAAA,KAC7Cc,SAAS,CAACU,OAAO,CAACC,GAAG,GACrBD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,GAAG,CAChB,CAAC;UAAA;UAAA;YAAA,OAAAe,QAAA,CAAAO,IAAA;QAAA;MAAA,GAAAX,OAAA;IAAA;IAAA,SAAAL,MAAAiB,EAAA,EAAAC,GAAA;MAAA,OAAAjB,MAAA,CAAAjC,KAAA,OAAAI,SAAA;IAAA;IAAA,OAAA4B,KAAA;EAAA;EACJmB,aAAa,EAAE,SAAAA,cAACC,IAAY,EAAE3B,OAA0B;IAAA,OACtD,IAAAoB,sBAAY,EAACO,IAAI,EAAAnD,aAAA,CAAAA,aAAA,KAAMc,SAAS,CAACU,OAAO,CAACC,GAAG,GAAKD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,GAAG,CAAC,CAAC;EAAA;AACnE,CAAC;AAAC2B,OAAA,CAAAtC,SAAA,GAAAA,SAAA;AAEF,SAASS,WAAWA,CAAC4B,IAAY,EAAW;EAE1C,OAAOA,IAAI,CAACE,UAAU,CAAC,OAAO,CAAC;AACjC"}
@@ -1 +1 @@
1
- {"version":3,"file":"html-loader.js","names":["mergeLoaderOptions","XMLLoader","HTMLLoader","name","id","extensions","mimeTypes","testText","testHTMLFile","parse","arrayBuffer","options","parseTextSync","TextDecoder","decode","text","startsWith","_XMLLoader$parseTextS","xml","_parser","_fastXML","htmlEntities","call"],"sources":["../../src/html-loader.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {mergeLoaderOptions} from '@loaders.gl/loader-utils';\nimport {XMLLoader, XMLLoaderOptions} from './xml-loader';\n\nexport type HTMLLoaderOptions = XMLLoaderOptions;\n\n/**\n * Loader for HTML files\n * Essentially a copy of the XMLLoader with different mime types, file extensions and content tests.\n * This split enables applications can control whether they want HTML responses to be parsed by the XML loader or not.\n * This loader does not have any additional understanding of the structure of HTML or the document.\n */\nexport const HTMLLoader: LoaderWithParser = {\n ...XMLLoader,\n name: 'HTML',\n id: 'html',\n extensions: ['html', 'htm'],\n mimeTypes: ['text/html'],\n testText: testHTMLFile,\n parse: async (arrayBuffer: ArrayBuffer, options?: XMLLoaderOptions) =>\n parseTextSync(new TextDecoder().decode(arrayBuffer), options),\n parseTextSync: (text: string, options?: XMLLoaderOptions) => parseTextSync(text, options)\n};\n\nfunction testHTMLFile(text: string): boolean {\n // TODO - There could be space first.\n return text.startsWith('<html');\n}\n\nfunction parseTextSync(text: string, options?: XMLLoaderOptions): any {\n // fast-xml-parser can recognize HTML entities\n // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md#htmlentities\n // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/5.Entities.md\n options = mergeLoaderOptions(options, {\n xml: {\n _parser: 'fast-xml-parser',\n _fastXML: {\n htmlEntities: true\n }\n }\n });\n\n return XMLLoader.parseTextSync?.(text, options);\n}\n"],"mappings":"AAGA,SAAQA,kBAAkB,QAAO,0BAA0B;AAC3D,SAAQC,SAAS,QAAyB,cAAc;AAUxD,OAAO,MAAMC,UAA4B,GAAG;EAC1C,GAAGD,SAAS;EACZE,IAAI,EAAE,MAAM;EACZC,EAAE,EAAE,MAAM;EACVC,UAAU,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC;EAC3BC,SAAS,EAAE,CAAC,WAAW,CAAC;EACxBC,QAAQ,EAAEC,YAAY;EACtBC,KAAK,EAAE,MAAAA,CAAOC,WAAwB,EAAEC,OAA0B,KAChEC,aAAa,CAAC,IAAIC,WAAW,CAAC,CAAC,CAACC,MAAM,CAACJ,WAAW,CAAC,EAAEC,OAAO,CAAC;EAC/DC,aAAa,EAAEA,CAACG,IAAY,EAAEJ,OAA0B,KAAKC,aAAa,CAACG,IAAI,EAAEJ,OAAO;AAC1F,CAAC;AAED,SAASH,YAAYA,CAACO,IAAY,EAAW;EAE3C,OAAOA,IAAI,CAACC,UAAU,CAAC,OAAO,CAAC;AACjC;AAEA,SAASJ,aAAaA,CAACG,IAAY,EAAEJ,OAA0B,EAAO;EAAA,IAAAM,qBAAA;EAIpEN,OAAO,GAAGX,kBAAkB,CAACW,OAAO,EAAE;IACpCO,GAAG,EAAE;MACHC,OAAO,EAAE,iBAAiB;MAC1BC,QAAQ,EAAE;QACRC,YAAY,EAAE;MAChB;IACF;EACF,CAAC,CAAC;EAEF,QAAAJ,qBAAA,GAAOhB,SAAS,CAACW,aAAa,cAAAK,qBAAA,uBAAvBA,qBAAA,CAAAK,IAAA,CAAArB,SAAS,EAAiBc,IAAI,EAAEJ,OAAO,CAAC;AACjD"}
1
+ {"version":3,"file":"html-loader.js","names":["mergeLoaderOptions","XMLLoader","HTMLLoader","name","id","extensions","mimeTypes","testText","testHTMLFile","parse","arrayBuffer","options","parseTextSync","TextDecoder","decode","text","startsWith","_XMLLoader$parseTextS","xml","_parser","_fastXML","htmlEntities","call"],"sources":["../../src/html-loader.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {mergeLoaderOptions} from '@loaders.gl/loader-utils';\nimport {XMLLoader, XMLLoaderOptions} from './xml-loader';\n\nexport type HTMLLoaderOptions = XMLLoaderOptions;\n\n/**\n * Loader for HTML files\n * Essentially a copy of the XMLLoader with different mime types, file extensions and content tests.\n * This split enables applications can control whether they want HTML responses to be parsed by the XML loader or not.\n * This loader does not have any additional understanding of the structure of HTML or the document.\n */\nexport const HTMLLoader: LoaderWithParser<any, never, HTMLLoaderOptions> = {\n ...XMLLoader,\n name: 'HTML',\n id: 'html',\n extensions: ['html', 'htm'],\n mimeTypes: ['text/html'],\n testText: testHTMLFile,\n parse: async (arrayBuffer: ArrayBuffer, options?: XMLLoaderOptions) =>\n parseTextSync(new TextDecoder().decode(arrayBuffer), options),\n parseTextSync: (text: string, options?: XMLLoaderOptions) => parseTextSync(text, options)\n};\n\nfunction testHTMLFile(text: string): boolean {\n // TODO - There could be space first.\n return text.startsWith('<html');\n}\n\nfunction parseTextSync(text: string, options?: XMLLoaderOptions): any {\n // fast-xml-parser can recognize HTML entities\n // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md#htmlentities\n // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/5.Entities.md\n options = mergeLoaderOptions(options, {\n xml: {\n _parser: 'fast-xml-parser',\n _fastXML: {\n htmlEntities: true\n }\n }\n });\n\n return XMLLoader.parseTextSync?.(text, options);\n}\n"],"mappings":"AAGA,SAAQA,kBAAkB,QAAO,0BAA0B;AAC3D,SAAQC,SAAS,QAAyB,cAAc;AAUxD,OAAO,MAAMC,UAA2D,GAAG;EACzE,GAAGD,SAAS;EACZE,IAAI,EAAE,MAAM;EACZC,EAAE,EAAE,MAAM;EACVC,UAAU,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC;EAC3BC,SAAS,EAAE,CAAC,WAAW,CAAC;EACxBC,QAAQ,EAAEC,YAAY;EACtBC,KAAK,EAAE,MAAAA,CAAOC,WAAwB,EAAEC,OAA0B,KAChEC,aAAa,CAAC,IAAIC,WAAW,CAAC,CAAC,CAACC,MAAM,CAACJ,WAAW,CAAC,EAAEC,OAAO,CAAC;EAC/DC,aAAa,EAAEA,CAACG,IAAY,EAAEJ,OAA0B,KAAKC,aAAa,CAACG,IAAI,EAAEJ,OAAO;AAC1F,CAAC;AAED,SAASH,YAAYA,CAACO,IAAY,EAAW;EAE3C,OAAOA,IAAI,CAACC,UAAU,CAAC,OAAO,CAAC;AACjC;AAEA,SAASJ,aAAaA,CAACG,IAAY,EAAEJ,OAA0B,EAAO;EAAA,IAAAM,qBAAA;EAIpEN,OAAO,GAAGX,kBAAkB,CAACW,OAAO,EAAE;IACpCO,GAAG,EAAE;MACHC,OAAO,EAAE,iBAAiB;MAC1BC,QAAQ,EAAE;QACRC,YAAY,EAAE;MAChB;IACF;EACF,CAAC,CAAC;EAEF,QAAAJ,qBAAA,GAAOhB,SAAS,CAACW,aAAa,cAAAK,qBAAA,uBAAvBA,qBAAA,CAAAK,IAAA,CAAArB,SAAS,EAAiBc,IAAI,EAAEJ,OAAO,CAAC;AACjD"}
@@ -1,5 +1,5 @@
1
1
  import { parseXMLSync } from './lib/parsers/parse-xml';
2
- const VERSION = typeof "4.0.0-alpha.9" !== 'undefined' ? "4.0.0-alpha.9" : 'latest';
2
+ const VERSION = typeof "4.0.0-beta.2" !== 'undefined' ? "4.0.0-beta.2" : 'latest';
3
3
  export const XMLLoader = {
4
4
  name: 'XML',
5
5
  id: 'xml',
@@ -1 +1 @@
1
- {"version":3,"file":"xml-loader.js","names":["parseXMLSync","VERSION","XMLLoader","name","id","module","version","worker","extensions","mimeTypes","testText","testXMLFile","options","xml","_parser","uncapitalizeKeys","removeNSPrefix","textNodeName","arrayPaths","parse","arrayBuffer","TextDecoder","decode","parseTextSync","text","startsWith"],"sources":["../../src/xml-loader.ts"],"sourcesContent":["import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport type {ParseXMLOptions} from './lib/parsers/parse-xml';\nimport {parseXMLSync} from './lib/parsers/parse-xml';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type XMLLoaderOptions = LoaderOptions & {\n xml?: ParseXMLOptions;\n};\n\n/**\n * Loader for XML files\n */\nexport const XMLLoader: LoaderWithParser<any, never, XMLLoaderOptions> = {\n name: 'XML',\n id: 'xml',\n module: 'xml',\n version: VERSION,\n worker: false,\n extensions: ['xml'],\n mimeTypes: ['application/xml', 'text/xml'],\n testText: testXMLFile,\n options: {\n xml: {\n _parser: 'fast-xml-parser',\n uncapitalizeKeys: false,\n removeNSPrefix: false,\n textNodeName: 'value',\n arrayPaths: []\n }\n },\n parse: async (arrayBuffer: ArrayBuffer, options?: XMLLoaderOptions) =>\n parseXMLSync(new TextDecoder().decode(arrayBuffer), {\n ...XMLLoader.options.xml,\n ...options?.xml\n }),\n parseTextSync: (text: string, options?: XMLLoaderOptions) =>\n parseXMLSync(text, {...XMLLoader.options.xml, ...options?.xml})\n};\n\nfunction testXMLFile(text: string): boolean {\n // TODO - There could be space first.\n return text.startsWith('<?xml');\n}\n"],"mappings":"AAEA,SAAQA,YAAY,QAAO,yBAAyB;AAIpD,MAAMC,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiB,QAAQ;AAS3E,OAAO,MAAMC,SAAyD,GAAG;EACvEC,IAAI,EAAE,KAAK;EACXC,EAAE,EAAE,KAAK;EACTC,MAAM,EAAE,KAAK;EACbC,OAAO,EAAEL,OAAO;EAChBM,MAAM,EAAE,KAAK;EACbC,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBC,SAAS,EAAE,CAAC,iBAAiB,EAAE,UAAU,CAAC;EAC1CC,QAAQ,EAAEC,WAAW;EACrBC,OAAO,EAAE;IACPC,GAAG,EAAE;MACHC,OAAO,EAAE,iBAAiB;MAC1BC,gBAAgB,EAAE,KAAK;MACvBC,cAAc,EAAE,KAAK;MACrBC,YAAY,EAAE,OAAO;MACrBC,UAAU,EAAE;IACd;EACF,CAAC;EACDC,KAAK,EAAE,MAAAA,CAAOC,WAAwB,EAAER,OAA0B,KAChEZ,YAAY,CAAC,IAAIqB,WAAW,CAAC,CAAC,CAACC,MAAM,CAACF,WAAW,CAAC,EAAE;IAClD,GAAGlB,SAAS,CAACU,OAAO,CAACC,GAAG;IACxB,IAAGD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,GAAG;EACjB,CAAC,CAAC;EACJU,aAAa,EAAEA,CAACC,IAAY,EAAEZ,OAA0B,KACtDZ,YAAY,CAACwB,IAAI,EAAE;IAAC,GAAGtB,SAAS,CAACU,OAAO,CAACC,GAAG;IAAE,IAAGD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,GAAG;EAAA,CAAC;AAClE,CAAC;AAED,SAASF,WAAWA,CAACa,IAAY,EAAW;EAE1C,OAAOA,IAAI,CAACC,UAAU,CAAC,OAAO,CAAC;AACjC"}
1
+ {"version":3,"file":"xml-loader.js","names":["parseXMLSync","VERSION","XMLLoader","name","id","module","version","worker","extensions","mimeTypes","testText","testXMLFile","options","xml","_parser","uncapitalizeKeys","removeNSPrefix","textNodeName","arrayPaths","parse","arrayBuffer","TextDecoder","decode","parseTextSync","text","startsWith"],"sources":["../../src/xml-loader.ts"],"sourcesContent":["import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport type {ParseXMLOptions} from './lib/parsers/parse-xml';\nimport {parseXMLSync} from './lib/parsers/parse-xml';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type XMLLoaderOptions = LoaderOptions & {\n xml?: ParseXMLOptions;\n};\n\n/**\n * Loader for XML files\n */\nexport const XMLLoader: LoaderWithParser<any, never, XMLLoaderOptions> = {\n name: 'XML',\n id: 'xml',\n module: 'xml',\n version: VERSION,\n worker: false,\n extensions: ['xml'],\n mimeTypes: ['application/xml', 'text/xml'],\n testText: testXMLFile,\n options: {\n xml: {\n _parser: 'fast-xml-parser',\n uncapitalizeKeys: false,\n removeNSPrefix: false,\n textNodeName: 'value',\n arrayPaths: []\n }\n },\n parse: async (arrayBuffer: ArrayBuffer, options?: XMLLoaderOptions) =>\n parseXMLSync(new TextDecoder().decode(arrayBuffer), {\n ...XMLLoader.options.xml,\n ...options?.xml\n }),\n parseTextSync: (text: string, options?: XMLLoaderOptions) =>\n parseXMLSync(text, {...XMLLoader.options.xml, ...options?.xml})\n};\n\nfunction testXMLFile(text: string): boolean {\n // TODO - There could be space first.\n return text.startsWith('<?xml');\n}\n"],"mappings":"AAEA,SAAQA,YAAY,QAAO,yBAAyB;AAIpD,MAAMC,OAAO,GAAG,qBAAkB,KAAK,WAAW,oBAAiB,QAAQ;AAS3E,OAAO,MAAMC,SAAyD,GAAG;EACvEC,IAAI,EAAE,KAAK;EACXC,EAAE,EAAE,KAAK;EACTC,MAAM,EAAE,KAAK;EACbC,OAAO,EAAEL,OAAO;EAChBM,MAAM,EAAE,KAAK;EACbC,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBC,SAAS,EAAE,CAAC,iBAAiB,EAAE,UAAU,CAAC;EAC1CC,QAAQ,EAAEC,WAAW;EACrBC,OAAO,EAAE;IACPC,GAAG,EAAE;MACHC,OAAO,EAAE,iBAAiB;MAC1BC,gBAAgB,EAAE,KAAK;MACvBC,cAAc,EAAE,KAAK;MACrBC,YAAY,EAAE,OAAO;MACrBC,UAAU,EAAE;IACd;EACF,CAAC;EACDC,KAAK,EAAE,MAAAA,CAAOC,WAAwB,EAAER,OAA0B,KAChEZ,YAAY,CAAC,IAAIqB,WAAW,CAAC,CAAC,CAACC,MAAM,CAACF,WAAW,CAAC,EAAE;IAClD,GAAGlB,SAAS,CAACU,OAAO,CAACC,GAAG;IACxB,IAAGD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,GAAG;EACjB,CAAC,CAAC;EACJU,aAAa,EAAEA,CAACC,IAAY,EAAEZ,OAA0B,KACtDZ,YAAY,CAACwB,IAAI,EAAE;IAAC,GAAGtB,SAAS,CAACU,OAAO,CAACC,GAAG;IAAE,IAAGD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,GAAG;EAAA,CAAC;AAClE,CAAC;AAED,SAASF,WAAWA,CAACa,IAAY,EAAW;EAE1C,OAAOA,IAAI,CAACC,UAAU,CAAC,OAAO,CAAC;AACjC"}
@@ -7,5 +7,5 @@ export type HTMLLoaderOptions = XMLLoaderOptions;
7
7
  * This split enables applications can control whether they want HTML responses to be parsed by the XML loader or not.
8
8
  * This loader does not have any additional understanding of the structure of HTML or the document.
9
9
  */
10
- export declare const HTMLLoader: LoaderWithParser;
10
+ export declare const HTMLLoader: LoaderWithParser<any, never, HTMLLoaderOptions>;
11
11
  //# sourceMappingURL=html-loader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"html-loader.d.ts","sourceRoot":"","sources":["../src/html-loader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAY,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAEzD,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,gBAUxB,CAAC"}
1
+ {"version":3,"file":"html-loader.d.ts","sourceRoot":"","sources":["../src/html-loader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAY,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAEzD,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,gBAAgB,CAAC,GAAG,EAAE,KAAK,EAAE,iBAAiB,CAUtE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/xml",
3
- "version": "4.0.0-alpha.9",
3
+ "version": "4.0.0-beta.2",
4
4
  "description": "Framework-independent loaders for the XML (eXtensible Markup Language) format",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -33,12 +33,9 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@babel/runtime": "^7.3.1",
36
- "@loaders.gl/loader-utils": "4.0.0-alpha.9",
37
- "@loaders.gl/schema": "4.0.0-alpha.9",
38
- "fast-xml-parser": "^4.1.3"
36
+ "@loaders.gl/loader-utils": "4.0.0-beta.2",
37
+ "@loaders.gl/schema": "4.0.0-beta.2",
38
+ "fast-xml-parser": "^4.2.5"
39
39
  },
40
- "devDependencies": {
41
- "xmldom": "0.6.0"
42
- },
43
- "gitHead": "03ff81ab468f20f3bddeec787aa88d477a7e1c72"
40
+ "gitHead": "79c2033f755e88e11bc30a04428e3666b177b8fc"
44
41
  }
@@ -12,7 +12,7 @@ export type HTMLLoaderOptions = XMLLoaderOptions;
12
12
  * This split enables applications can control whether they want HTML responses to be parsed by the XML loader or not.
13
13
  * This loader does not have any additional understanding of the structure of HTML or the document.
14
14
  */
15
- export const HTMLLoader: LoaderWithParser = {
15
+ export const HTMLLoader: LoaderWithParser<any, never, HTMLLoaderOptions> = {
16
16
  ...XMLLoader,
17
17
  name: 'HTML',
18
18
  id: 'html',
package/dist/bundle.js DELETED
@@ -1,5 +0,0 @@
1
- "use strict";
2
- // @ts-nocheck
3
- const moduleExports = require('./index');
4
- globalThis.loaders = globalThis.loaders || {};
5
- module.exports = Object.assign(globalThis.loaders, moduleExports);
@@ -1,40 +0,0 @@
1
- "use strict";
2
- // loaders.gl, MIT license
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.HTMLLoader = void 0;
5
- const loader_utils_1 = require("@loaders.gl/loader-utils");
6
- const xml_loader_1 = require("./xml-loader");
7
- /**
8
- * Loader for HTML files
9
- * Essentially a copy of the XMLLoader with different mime types, file extensions and content tests.
10
- * This split enables applications can control whether they want HTML responses to be parsed by the XML loader or not.
11
- * This loader does not have any additional understanding of the structure of HTML or the document.
12
- */
13
- exports.HTMLLoader = {
14
- ...xml_loader_1.XMLLoader,
15
- name: 'HTML',
16
- id: 'html',
17
- extensions: ['html', 'htm'],
18
- mimeTypes: ['text/html'],
19
- testText: testHTMLFile,
20
- parse: async (arrayBuffer, options) => parseTextSync(new TextDecoder().decode(arrayBuffer), options),
21
- parseTextSync: (text, options) => parseTextSync(text, options)
22
- };
23
- function testHTMLFile(text) {
24
- // TODO - There could be space first.
25
- return text.startsWith('<html');
26
- }
27
- function parseTextSync(text, options) {
28
- // fast-xml-parser can recognize HTML entities
29
- // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md#htmlentities
30
- // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/5.Entities.md
31
- options = (0, loader_utils_1.mergeLoaderOptions)(options, {
32
- xml: {
33
- _parser: 'fast-xml-parser',
34
- _fastXML: {
35
- htmlEntities: true
36
- }
37
- }
38
- });
39
- return xml_loader_1.XMLLoader.parseTextSync?.(text, options);
40
- }
package/dist/index.js DELETED
@@ -1,18 +0,0 @@
1
- "use strict";
2
- // loaders.gl, MIT license
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports._uncapitalizeKeys = exports._uncapitalize = exports.convertXMLFieldToArrayInPlace = exports.convertXMLValueToArray = exports.SAXParser = exports.HTMLLoader = exports.XMLLoader = void 0;
5
- var xml_loader_1 = require("./xml-loader");
6
- Object.defineProperty(exports, "XMLLoader", { enumerable: true, get: function () { return xml_loader_1.XMLLoader; } });
7
- var html_loader_1 = require("./html-loader");
8
- Object.defineProperty(exports, "HTMLLoader", { enumerable: true, get: function () { return html_loader_1.HTMLLoader; } });
9
- var sax_1 = require("./sax-ts/sax");
10
- Object.defineProperty(exports, "SAXParser", { enumerable: true, get: function () { return sax_1.SAXParser; } });
11
- // Utilities
12
- var xml_utils_1 = require("./lib/xml-utils/xml-utils");
13
- Object.defineProperty(exports, "convertXMLValueToArray", { enumerable: true, get: function () { return xml_utils_1.convertXMLValueToArray; } });
14
- Object.defineProperty(exports, "convertXMLFieldToArrayInPlace", { enumerable: true, get: function () { return xml_utils_1.convertXMLFieldToArrayInPlace; } });
15
- // Experimental
16
- var uncapitalize_1 = require("./lib/xml-utils/uncapitalize");
17
- Object.defineProperty(exports, "_uncapitalize", { enumerable: true, get: function () { return uncapitalize_1.uncapitalize; } });
18
- Object.defineProperty(exports, "_uncapitalizeKeys", { enumerable: true, get: function () { return uncapitalize_1.uncapitalizeKeys; } });
@@ -1,60 +0,0 @@
1
- "use strict";
2
- // loaders.gl, MIT license
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.parseXMLInBatches = exports.fastParseXML = exports.parseXMLSync = void 0;
5
- const streaming_xml_parser_1 = require("./streaming-xml-parser");
6
- const uncapitalize_1 = require("../xml-utils/uncapitalize");
7
- const fast_xml_parser_1 = require("fast-xml-parser");
8
- function parseXMLSync(text, options) {
9
- if (options?._parser && options._parser !== 'fast-xml-parser') {
10
- throw new Error(options?._parser);
11
- }
12
- const fastXMLOptions = {
13
- // Default FastXML options
14
- // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md#allowbooleanattributes
15
- allowBooleanAttributes: true,
16
- // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md#ignoredeclaration
17
- ignoreDeclaration: true,
18
- // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md#removensprefix
19
- removeNSPrefix: options?.removeNSPrefix,
20
- // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md#textnodename
21
- textNodeName: options?.textNodeName,
22
- // Let's application specify keys that are always arrays
23
- isArray: (name, jpath, isLeafNode, isAttribute) => {
24
- const array = Boolean(options?.arrayPaths?.some((path) => jpath === path));
25
- return array;
26
- },
27
- // Application overrides
28
- ...options?._fastXML
29
- };
30
- const xml = fastParseXML(text, fastXMLOptions);
31
- // Note - could be done with FastXML tag processing
32
- return options?.uncapitalizeKeys ? (0, uncapitalize_1.uncapitalizeKeys)(xml) : xml;
33
- }
34
- exports.parseXMLSync = parseXMLSync;
35
- function fastParseXML(text, options) {
36
- const parser = new fast_xml_parser_1.XMLParser({
37
- ignoreAttributes: false,
38
- attributeNamePrefix: '',
39
- ...options
40
- });
41
- const parsedXML = parser.parse(text);
42
- return parsedXML;
43
- }
44
- exports.fastParseXML = fastParseXML;
45
- /**
46
- * @todo Build a streaming XML parser based on sax-js
47
- * @param text
48
- * @param options
49
- * @returns
50
- */
51
- function parseXMLInBatches(text, options = {}) {
52
- const parser = new streaming_xml_parser_1.StreamingXMLParser({
53
- ...options,
54
- strict: true
55
- });
56
- parser.write(text);
57
- parser.close();
58
- return parser.result;
59
- }
60
- exports.parseXMLInBatches = parseXMLInBatches;
@@ -1,98 +0,0 @@
1
- "use strict";
2
- // @ts-nocheck
3
- /* eslint-disable */
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.StreamingXMLParser = void 0;
6
- const sax_1 = require("../../sax-ts/sax");
7
- /**
8
- * StreamingXMLParser builds a JSON object using the events emitted by the SAX parser
9
- */
10
- class StreamingXMLParser {
11
- // jsonpath: JSONPath = new JSONPath();
12
- constructor(options) {
13
- this.result = undefined;
14
- this.previousStates = [];
15
- this.currentState = Object.freeze({ container: [], key: null });
16
- this.reset();
17
- this.parser = new sax_1.SAXParser({
18
- onready: () => {
19
- this.previousStates.length = 0;
20
- this.currentState.container.length = 0;
21
- },
22
- onopentag: ({ name, attributes, isSelfClosing }) => {
23
- this._openObject({});
24
- if (typeof name !== 'undefined') {
25
- this.parser.emit('onkey', name);
26
- }
27
- },
28
- onkey: (name) => {
29
- this.currentState.key = name;
30
- },
31
- onclosetag: () => {
32
- this._closeObject();
33
- },
34
- onopenarray: () => {
35
- this._openArray();
36
- },
37
- onclosearray: () => {
38
- this._closeArray();
39
- },
40
- ontext: (value) => {
41
- this._pushOrSet(value);
42
- },
43
- onerror: (error) => {
44
- throw error;
45
- },
46
- onend: () => {
47
- this.result = this.currentState.container.pop();
48
- },
49
- ...options
50
- });
51
- }
52
- reset() {
53
- this.result = undefined;
54
- this.previousStates = [];
55
- this.currentState = Object.freeze({ container: [], key: null });
56
- }
57
- write(chunk) {
58
- this.parser.write(chunk);
59
- }
60
- close() {
61
- this.parser.close();
62
- }
63
- // PRIVATE METHODS
64
- _pushOrSet(value) {
65
- const { container, key } = this.currentState;
66
- if (key !== null) {
67
- container[key] = value;
68
- this.currentState.key = null;
69
- }
70
- else if (Array.isArray(container)) {
71
- container.push(value);
72
- }
73
- else if (container) {
74
- // debugger
75
- }
76
- }
77
- _openArray(newContainer = []) {
78
- // this.jsonpath.push(null);
79
- this._pushOrSet(newContainer);
80
- this.previousStates.push(this.currentState);
81
- this.currentState = { container: newContainer, isArray: true, key: null };
82
- }
83
- _closeArray() {
84
- // this.jsonpath.pop();
85
- this.currentState = this.previousStates.pop();
86
- }
87
- _openObject(newContainer = {}) {
88
- // this.jsonpath.push(null);
89
- this._pushOrSet(newContainer);
90
- this.previousStates.push(this.currentState);
91
- this.currentState = { container: newContainer, isArray: false, key: null };
92
- }
93
- _closeObject() {
94
- // this.jsonpath.pop();
95
- this.currentState = this.previousStates.pop();
96
- }
97
- }
98
- exports.StreamingXMLParser = StreamingXMLParser;
@@ -1,32 +0,0 @@
1
- "use strict";
2
- // loaders.gl, MIT license
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.uncapitalizeKeys = exports.uncapitalize = void 0;
5
- /**
6
- * Uncapitalize first letter of a string
7
- * @param str
8
- * @returns
9
- */
10
- function uncapitalize(str) {
11
- return typeof str === 'string' ? str.charAt(0).toLowerCase() + str.slice(1) : str;
12
- }
13
- exports.uncapitalize = uncapitalize;
14
- /**
15
- * Recursively uncapitalize all keys in a nested object
16
- * @param object
17
- * @returns
18
- */
19
- function uncapitalizeKeys(object) {
20
- if (Array.isArray(object)) {
21
- return object.map((element) => uncapitalizeKeys(element));
22
- }
23
- if (object && typeof object === 'object') {
24
- const newObject = {};
25
- for (const [key, value] of Object.entries(object)) {
26
- newObject[uncapitalize(key)] = uncapitalizeKeys(value);
27
- }
28
- return newObject;
29
- }
30
- return object;
31
- }
32
- exports.uncapitalizeKeys = uncapitalizeKeys;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- // TODO - these utilities could be moved to the XML parser.
3
- // uncapitalizeKeys could be an XMLLoader option
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.convertXMLFieldToArrayInPlace = exports.convertXMLValueToArray = void 0;
6
- /**
7
- * Extracts a value or array and always return an array
8
- * Useful since XML parses to object instead of array when only a single value is provided
9
- */
10
- function convertXMLValueToArray(xmlValue) {
11
- if (Array.isArray(xmlValue)) {
12
- return xmlValue;
13
- }
14
- if (xmlValue && typeof xmlValue === 'object' && xmlValue['0']) {
15
- // Error this is an objectified array
16
- }
17
- if (xmlValue) {
18
- return [xmlValue];
19
- }
20
- return [];
21
- }
22
- exports.convertXMLValueToArray = convertXMLValueToArray;
23
- /**
24
- * Mutates a field in place, converting it to array
25
- * Useful since XML parses to object instead of array when only a single value is provided
26
- */
27
- function convertXMLFieldToArrayInPlace(xml, key) {
28
- xml[key] = convertXMLValueToArray(xml[key]);
29
- }
30
- exports.convertXMLFieldToArrayInPlace = convertXMLFieldToArrayInPlace;