@loaders.gl/xml 3.3.0-alpha.8

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.
@@ -0,0 +1,38 @@
1
+ import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';
2
+ import type {SAXParserOptions} from './sax-ts/sax';
3
+ import {parseXML} from './lib/parse-xml';
4
+
5
+ // __VERSION__ is injected by babel-plugin-version-inline
6
+ // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
+ const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
8
+
9
+ export type XMLLoaderOptions = LoaderOptions & {
10
+ xml?: SAXParserOptions;
11
+ };
12
+
13
+ /**
14
+ * Worker loader for the OBJ geometry format
15
+ */
16
+ export const XMLLoader = {
17
+ name: 'XML',
18
+ id: 'xml',
19
+ module: 'xml',
20
+ version: VERSION,
21
+ worker: false,
22
+ extensions: ['xml'],
23
+ mimeTypes: ['application/xml', 'text/xml'],
24
+ testText: testXMLFile,
25
+ options: {
26
+ xml: {}
27
+ },
28
+ parse: async (arrayBuffer: ArrayBuffer, options?: XMLLoaderOptions) =>
29
+ parseXML(new TextDecoder().decode(arrayBuffer), options),
30
+ parseTextSync: (text: string, options?: XMLLoaderOptions) => parseXML(text, options)
31
+ };
32
+
33
+ function testXMLFile(text: string): boolean {
34
+ // TODO - There could be space first.
35
+ return text.startsWith('<?xml');
36
+ }
37
+
38
+ export const _typecheckXMLLoader: LoaderWithParser = XMLLoader;