// loaders.gl // SPDX-License-Identifier: MIT // Copyright (c) vis.gl contributors import { parseXMLSync } from "./lib/parsers/parse-xml.js"; // __VERSION__ is injected by babel-plugin-version-inline // @ts-ignore TS2304: Cannot find name '__VERSION__'. const VERSION = typeof "4.3.1" !== 'undefined' ? "4.3.1" : 'latest'; /** * Loader for XML files */ export const XMLLoader = { dataType: null, batchType: null, name: 'XML', id: 'xml', module: 'xml', version: VERSION, worker: false, extensions: ['xml'], mimeTypes: ['application/xml', 'text/xml'], testText: testXMLFile, options: { xml: { _parser: 'fast-xml-parser', uncapitalizeKeys: false, removeNSPrefix: false, textNodeName: 'value', arrayPaths: [] } }, parse: async (arrayBuffer, options) => parseXMLSync(new TextDecoder().decode(arrayBuffer), { ...XMLLoader.options.xml, ...options?.xml }), parseTextSync: (text, options) => parseXMLSync(text, { ...XMLLoader.options.xml, ...options?.xml }) }; function testXMLFile(text) { // TODO - There could be space first. return text.startsWith('