@loaders.gl/xml 3.4.11 → 3.4.13

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.
@@ -1,66 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._typecheckXMLLoader = exports.XMLLoader = void 0;
4
- const parse_xml_1 = require("./lib/parsers/parse-xml");
5
- const uncapitalize_1 = require("./lib/xml-utils/uncapitalize");
6
- // __VERSION__ is injected by babel-plugin-version-inline
7
- // @ts-ignore TS2304: Cannot find name '__VERSION__'.
8
- const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
9
- /**
10
- * Loader for XML files
11
- */
12
- exports.XMLLoader = {
13
- name: 'XML',
14
- id: 'xml',
15
- module: 'xml',
16
- version: VERSION,
17
- worker: false,
18
- extensions: ['xml'],
19
- mimeTypes: ['application/xml', 'text/xml'],
20
- testText: testXMLFile,
21
- options: {
22
- xml: {
23
- parser: 'fast-xml-parser',
24
- uncapitalizeKeys: false,
25
- removeNSPrefix: false,
26
- textNodeName: 'value',
27
- arrayPaths: []
28
- }
29
- },
30
- parse: async (arrayBuffer, options) => parseTextSync(new TextDecoder().decode(arrayBuffer), options),
31
- parseTextSync: (text, options) => parseTextSync(text, options)
32
- };
33
- function testXMLFile(text) {
34
- // TODO - There could be space first.
35
- return text.startsWith('<?xml');
36
- }
37
- function parseTextSync(text, options) {
38
- const xmlOptions = { ...exports.XMLLoader.options.xml, ...options?.xml };
39
- switch (xmlOptions.parser) {
40
- case 'fast-xml-parser':
41
- const fastXMLOptions = {
42
- // Default FastXML options
43
- // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md#allowbooleanattributes
44
- allowBooleanAttributes: true,
45
- // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md#ignoredeclaration
46
- ignoreDeclaration: true,
47
- // XMLLoader Options: Map to FastXMLOptions
48
- // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md#removensprefix
49
- removeNSPrefix: xmlOptions.removeNSPrefix,
50
- // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md#textnodename
51
- textNodeName: xmlOptions.textNodeName,
52
- isArray: (name, jpath, isLeafNode, isAttribute) => {
53
- const array = Boolean(xmlOptions?.arrayPaths?.some((path) => jpath === path));
54
- return array;
55
- },
56
- // Application overrides
57
- ...options?._fastXML
58
- };
59
- const xml = (0, parse_xml_1.fastParseXML)(text, fastXMLOptions);
60
- // Note - could be done with FastXML tag processing
61
- return xmlOptions.uncapitalizeKeys ? (0, uncapitalize_1.uncapitalizeKeys)(xml) : xml;
62
- default:
63
- throw new Error(options?.xml?.parser);
64
- }
65
- }
66
- exports._typecheckXMLLoader = exports.XMLLoader;