@loaders.gl/xml 4.2.0-alpha.5 → 4.2.0-beta.1

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.
@@ -335,89 +335,104 @@ Object.keys(ENTITIES).forEach((key) => {
335
335
  * Internal helper class
336
336
  */
337
337
  class SAX {
338
+ EVENTS = EVENTS;
339
+ ENTITIES = {
340
+ // TODO: make it readonly, needed for entity-mega test
341
+ // amp, gt, lt, quot and apos are resolved to strings instead of numerical
342
+ // codes, IDK why
343
+ ...ENTITIES
344
+ };
345
+ XML_ENTITIES = {
346
+ amp: '&',
347
+ gt: '>',
348
+ lt: '<',
349
+ quot: '"',
350
+ apos: "'"
351
+ };
352
+ S = 0;
353
+ opt;
354
+ trackPosition = false;
355
+ column = 0;
356
+ line = 0;
357
+ c = '';
358
+ error;
359
+ q = '';
360
+ bufferCheckPosition;
361
+ closed = false;
362
+ tags = [];
363
+ looseCase = '';
364
+ closedRoot = false;
365
+ sawRoot = false;
366
+ strict = false;
367
+ tag;
368
+ strictEntities;
369
+ state;
370
+ noscript = false;
371
+ attribList = [];
372
+ ns;
373
+ position = 0;
374
+ STATE = {
375
+ BEGIN: this.S++, // leading byte order mark or whitespace
376
+ BEGIN_WHITESPACE: this.S++, // leading whitespace
377
+ TEXT: this.S++, // general stuff
378
+ TEXT_ENTITY: this.S++, // &amp and such.
379
+ OPEN_WAKA: this.S++, // <
380
+ SGML_DECL: this.S++, // <!BLARG
381
+ SGML_DECL_QUOTED: this.S++, // <!BLARG foo "bar
382
+ DOCTYPE: this.S++, // <!DOCTYPE
383
+ DOCTYPE_QUOTED: this.S++, // <!DOCTYPE "//blah
384
+ DOCTYPE_DTD: this.S++, // <!DOCTYPE "//blah" [ ...
385
+ DOCTYPE_DTD_QUOTED: this.S++, // <!DOCTYPE "//blah" [ "foo
386
+ COMMENT_STARTING: this.S++, // <!-
387
+ COMMENT: this.S++, // <!--
388
+ COMMENT_ENDING: this.S++, // <!-- blah -
389
+ COMMENT_ENDED: this.S++, // <!-- blah --
390
+ CDATA: this.S++, // <![CDATA[ something
391
+ CDATA_ENDING: this.S++, // ]
392
+ CDATA_ENDING_2: this.S++, // ]]
393
+ PROC_INST: this.S++, // <?hi
394
+ PROC_INST_BODY: this.S++, // <?hi there
395
+ PROC_INST_ENDING: this.S++, // <?hi "there" ?
396
+ OPEN_TAG: this.S++, // <strong
397
+ OPEN_TAG_SLASH: this.S++, // <strong /
398
+ ATTRIB: this.S++, // <a
399
+ ATTRIB_NAME: this.S++, // <a foo
400
+ ATTRIB_NAME_SAW_WHITE: this.S++, // <a foo _
401
+ ATTRIB_VALUE: this.S++, // <a foo=
402
+ ATTRIB_VALUE_QUOTED: this.S++, // <a foo="bar
403
+ ATTRIB_VALUE_CLOSED: this.S++, // <a foo="bar"
404
+ ATTRIB_VALUE_UNQUOTED: this.S++, // <a foo=bar
405
+ ATTRIB_VALUE_ENTITY_Q: this.S++, // <foo bar="&quot;"
406
+ ATTRIB_VALUE_ENTITY_U: this.S++, // <foo bar=&quot
407
+ CLOSE_TAG: this.S++, // </a
408
+ CLOSE_TAG_SAW_WHITE: this.S++, // </a >
409
+ SCRIPT: this.S++, // <script> ...
410
+ SCRIPT_ENDING: this.S++ // <script> ... <
411
+ };
412
+ BUFFERS = BUFFERS;
413
+ // private parser: (strict: boolean, opt: any) => SAXParser;
414
+ CDATA = '[CDATA[';
415
+ DOCTYPE = 'DOCTYPE';
416
+ XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
417
+ XMLNS_NAMESPACE = 'http://www.w3.org/2000/xmlns/';
418
+ rootNS = {
419
+ xml: this.XML_NAMESPACE,
420
+ xmlns: this.XMLNS_NAMESPACE
421
+ };
422
+ comment;
423
+ sgmlDecl;
424
+ textNode = '';
425
+ tagName;
426
+ doctype;
427
+ procInstName;
428
+ procInstBody;
429
+ entity = '';
430
+ attribName;
431
+ attribValue;
432
+ cdata = '';
433
+ script = '';
434
+ startTagPosition = 0;
338
435
  constructor() {
339
- this.EVENTS = EVENTS;
340
- this.ENTITIES = {
341
- // TODO: make it readonly, needed for entity-mega test
342
- // amp, gt, lt, quot and apos are resolved to strings instead of numerical
343
- // codes, IDK why
344
- ...ENTITIES
345
- };
346
- this.XML_ENTITIES = {
347
- amp: '&',
348
- gt: '>',
349
- lt: '<',
350
- quot: '"',
351
- apos: "'"
352
- };
353
- this.S = 0;
354
- this.trackPosition = false;
355
- this.column = 0;
356
- this.line = 0;
357
- this.c = '';
358
- this.q = '';
359
- this.closed = false;
360
- this.tags = [];
361
- this.looseCase = '';
362
- this.closedRoot = false;
363
- this.sawRoot = false;
364
- this.strict = false;
365
- this.noscript = false;
366
- this.attribList = [];
367
- this.position = 0;
368
- this.STATE = {
369
- BEGIN: this.S++, // leading byte order mark or whitespace
370
- BEGIN_WHITESPACE: this.S++, // leading whitespace
371
- TEXT: this.S++, // general stuff
372
- TEXT_ENTITY: this.S++, // &amp and such.
373
- OPEN_WAKA: this.S++, // <
374
- SGML_DECL: this.S++, // <!BLARG
375
- SGML_DECL_QUOTED: this.S++, // <!BLARG foo "bar
376
- DOCTYPE: this.S++, // <!DOCTYPE
377
- DOCTYPE_QUOTED: this.S++, // <!DOCTYPE "//blah
378
- DOCTYPE_DTD: this.S++, // <!DOCTYPE "//blah" [ ...
379
- DOCTYPE_DTD_QUOTED: this.S++, // <!DOCTYPE "//blah" [ "foo
380
- COMMENT_STARTING: this.S++, // <!-
381
- COMMENT: this.S++, // <!--
382
- COMMENT_ENDING: this.S++, // <!-- blah -
383
- COMMENT_ENDED: this.S++, // <!-- blah --
384
- CDATA: this.S++, // <![CDATA[ something
385
- CDATA_ENDING: this.S++, // ]
386
- CDATA_ENDING_2: this.S++, // ]]
387
- PROC_INST: this.S++, // <?hi
388
- PROC_INST_BODY: this.S++, // <?hi there
389
- PROC_INST_ENDING: this.S++, // <?hi "there" ?
390
- OPEN_TAG: this.S++, // <strong
391
- OPEN_TAG_SLASH: this.S++, // <strong /
392
- ATTRIB: this.S++, // <a
393
- ATTRIB_NAME: this.S++, // <a foo
394
- ATTRIB_NAME_SAW_WHITE: this.S++, // <a foo _
395
- ATTRIB_VALUE: this.S++, // <a foo=
396
- ATTRIB_VALUE_QUOTED: this.S++, // <a foo="bar
397
- ATTRIB_VALUE_CLOSED: this.S++, // <a foo="bar"
398
- ATTRIB_VALUE_UNQUOTED: this.S++, // <a foo=bar
399
- ATTRIB_VALUE_ENTITY_Q: this.S++, // <foo bar="&quot;"
400
- ATTRIB_VALUE_ENTITY_U: this.S++, // <foo bar=&quot
401
- CLOSE_TAG: this.S++, // </a
402
- CLOSE_TAG_SAW_WHITE: this.S++, // </a >
403
- SCRIPT: this.S++, // <script> ...
404
- SCRIPT_ENDING: this.S++ // <script> ... <
405
- };
406
- this.BUFFERS = BUFFERS;
407
- // private parser: (strict: boolean, opt: any) => SAXParser;
408
- this.CDATA = '[CDATA[';
409
- this.DOCTYPE = 'DOCTYPE';
410
- this.XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
411
- this.XMLNS_NAMESPACE = 'http://www.w3.org/2000/xmlns/';
412
- this.rootNS = {
413
- xml: this.XML_NAMESPACE,
414
- xmlns: this.XMLNS_NAMESPACE
415
- };
416
- this.textNode = '';
417
- this.entity = '';
418
- this.cdata = '';
419
- this.script = '';
420
- this.startTagPosition = 0;
421
436
  this.S = 0;
422
437
  for (const s in this.STATE) {
423
438
  if (this.STATE.hasOwnProperty(s)) {
@@ -1389,10 +1404,11 @@ class SAX {
1389
1404
  * @todo Weird inheritance, with some variables initialized in subclass
1390
1405
  */
1391
1406
  export class SAXParser extends SAX {
1407
+ static ENTITIES = ENTITIES;
1408
+ opt = DEFAULT_SAX_PARSER_OPTIONS;
1409
+ events = DEFAULT_SAX_EVENTS;
1392
1410
  constructor(opt) {
1393
1411
  super();
1394
- this.opt = DEFAULT_SAX_PARSER_OPTIONS;
1395
- this.events = DEFAULT_SAX_EVENTS;
1396
1412
  this.clearBuffers();
1397
1413
  this.opt = opt = { ...this.opt, ...opt };
1398
1414
  this.events = { ...this.events, ...opt };
@@ -1435,4 +1451,3 @@ export class SAXParser extends SAX {
1435
1451
  this.flushBuffers();
1436
1452
  }
1437
1453
  }
1438
- SAXParser.ENTITIES = ENTITIES;
@@ -1,4 +1,4 @@
1
- import type { LoaderWithParser, LoaderOptions } from '@loaders.gl/loader-utils';
1
+ import type { LoaderOptions } from '@loaders.gl/loader-utils';
2
2
  import type { ParseXMLOptions } from "./lib/parsers/parse-xml.js";
3
3
  export type XMLLoaderOptions = LoaderOptions & {
4
4
  xml?: ParseXMLOptions;
@@ -6,5 +6,5 @@ export type XMLLoaderOptions = LoaderOptions & {
6
6
  /**
7
7
  * Loader for XML files
8
8
  */
9
- export declare const XMLLoader: LoaderWithParser<any, never, XMLLoaderOptions>;
9
+ export declare const XMLLoader: any;
10
10
  //# sourceMappingURL=xml-loader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"xml-loader.d.ts","sourceRoot":"","sources":["../src/xml-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,gBAAgB,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAC9E,OAAO,KAAK,EAAC,eAAe,EAAC,mCAAgC;AAO7D,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC7C,GAAG,CAAC,EAAE,eAAe,CAAC;CACvB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,gBAAgB,CAAC,GAAG,EAAE,KAAK,EAAE,gBAAgB,CAyBpE,CAAC"}
1
+ {"version":3,"file":"xml-loader.d.ts","sourceRoot":"","sources":["../src/xml-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAmB,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAC9E,OAAO,KAAK,EAAC,eAAe,EAAC,mCAAgC;AAO7D,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC7C,GAAG,CAAC,EAAE,eAAe,CAAC;CACvB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,KA2B6C,CAAC"}
@@ -4,11 +4,13 @@
4
4
  import { parseXMLSync } from "./lib/parsers/parse-xml.js";
5
5
  // __VERSION__ is injected by babel-plugin-version-inline
6
6
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
- const VERSION = typeof "4.2.0-alpha.4" !== 'undefined' ? "4.2.0-alpha.4" : 'latest';
7
+ const VERSION = typeof "4.2.0-alpha.6" !== 'undefined' ? "4.2.0-alpha.6" : 'latest';
8
8
  /**
9
9
  * Loader for XML files
10
10
  */
11
11
  export const XMLLoader = {
12
+ dataType: null,
13
+ batchType: null,
12
14
  name: 'XML',
13
15
  id: 'xml',
14
16
  module: 'xml',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/xml",
3
- "version": "4.2.0-alpha.5",
3
+ "version": "4.2.0-beta.1",
4
4
  "description": "Framework-independent loaders for the XML (eXtensible Markup Language) format",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -41,12 +41,12 @@
41
41
  "build-bundle-dev": "ocular-bundle ./bundle.ts --env=dev --output=dist/dist.dev.js"
42
42
  },
43
43
  "dependencies": {
44
- "@loaders.gl/loader-utils": "4.2.0-alpha.5",
45
- "@loaders.gl/schema": "4.2.0-alpha.5",
44
+ "@loaders.gl/loader-utils": "4.2.0-beta.1",
45
+ "@loaders.gl/schema": "4.2.0-beta.1",
46
46
  "fast-xml-parser": "^4.2.5"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "@loaders.gl/core": "^4.0.0"
50
50
  },
51
- "gitHead": "32d95a81971f104e4dfeb88ab57065f05321a76a"
51
+ "gitHead": "c386a9196516fe3ff24847b40e6c77be039cf905"
52
52
  }
@@ -14,7 +14,7 @@ export type HTMLLoaderOptions = XMLLoaderOptions;
14
14
  * This split enables applications can control whether they want HTML responses to be parsed by the XML loader or not.
15
15
  * This loader does not have any additional understanding of the structure of HTML or the document.
16
16
  */
17
- export const HTMLLoader: LoaderWithParser<any, never, HTMLLoaderOptions> = {
17
+ export const HTMLLoader = {
18
18
  ...XMLLoader,
19
19
  name: 'HTML',
20
20
  id: 'html',
@@ -24,7 +24,7 @@ export const HTMLLoader: LoaderWithParser<any, never, HTMLLoaderOptions> = {
24
24
  parse: async (arrayBuffer: ArrayBuffer, options?: XMLLoaderOptions) =>
25
25
  parseTextSync(new TextDecoder().decode(arrayBuffer), options),
26
26
  parseTextSync: (text: string, options?: XMLLoaderOptions) => parseTextSync(text, options)
27
- };
27
+ } as const satisfies LoaderWithParser<any, never, HTMLLoaderOptions>;
28
28
 
29
29
  function testHTMLFile(text: string): boolean {
30
30
  // TODO - There could be space first.
package/src/xml-loader.ts CHANGED
@@ -17,7 +17,9 @@ export type XMLLoaderOptions = LoaderOptions & {
17
17
  /**
18
18
  * Loader for XML files
19
19
  */
20
- export const XMLLoader: LoaderWithParser<any, never, XMLLoaderOptions> = {
20
+ export const XMLLoader = {
21
+ dataType: null as any,
22
+ batchType: null as never,
21
23
  name: 'XML',
22
24
  id: 'xml',
23
25
  module: 'xml',
@@ -42,7 +44,7 @@ export const XMLLoader: LoaderWithParser<any, never, XMLLoaderOptions> = {
42
44
  }),
43
45
  parseTextSync: (text: string, options?: XMLLoaderOptions) =>
44
46
  parseXMLSync(text, {...XMLLoader.options.xml, ...options?.xml})
45
- };
47
+ } as const satisfies LoaderWithParser<any, never, XMLLoaderOptions>;
46
48
 
47
49
  function testXMLFile(text: string): boolean {
48
50
  // TODO - There could be space first.