@loaders.gl/xml 4.0.0-beta.3 → 4.0.0-beta.4

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.
Files changed (2) hide show
  1. package/dist/dist.dev.js +16 -95
  2. package/package.json +4 -4
package/dist/dist.dev.js CHANGED
@@ -108,7 +108,6 @@ var __exports__ = (() => {
108
108
  var util = require_util();
109
109
  var defaultOptions = {
110
110
  allowBooleanAttributes: false,
111
- //A tag can have attributes without any value
112
111
  unpairedTags: []
113
112
  };
114
113
  exports.validate = function(xmlData, options) {
@@ -405,7 +404,6 @@ var __exports__ = (() => {
405
404
  const lines = xmlData.substring(0, index).split(/\r?\n/);
406
405
  return {
407
406
  line: lines.length,
408
- // column number is last line's length + 1, because column numbering starts at 1:
409
407
  col: lines[lines.length - 1].length + 1
410
408
  };
411
409
  }
@@ -425,14 +423,10 @@ var __exports__ = (() => {
425
423
  textNodeName: "#text",
426
424
  ignoreAttributes: true,
427
425
  removeNSPrefix: false,
428
- // remove NS from tag name or attribute name if true
429
426
  allowBooleanAttributes: false,
430
- //a tag can have attributes without any value
431
- //ignoreRootElement : false,
432
427
  parseTagValue: true,
433
428
  parseAttributeValue: false,
434
429
  trimValues: true,
435
- //Trim string values of tag and attributes
436
430
  cdataPropName: false,
437
431
  numberParseOptions: {
438
432
  hex: true,
@@ -446,7 +440,6 @@ var __exports__ = (() => {
446
440
  return val2;
447
441
  },
448
442
  stopNodes: [],
449
- //nested tags will not be parsed even for errors
450
443
  alwaysCreateTextNode: false,
451
444
  isArray: () => false,
452
445
  commentPropName: false,
@@ -460,7 +453,6 @@ var __exports__ = (() => {
460
453
  updateTag: function(tagName, jPath, attrs) {
461
454
  return tagName;
462
455
  }
463
- // skipEmptyListItem: false
464
456
  };
465
457
  var buildOptions = function(options) {
466
458
  return Object.assign({}, defaultOptions, options);
@@ -757,11 +749,6 @@ var __exports__ = (() => {
757
749
  regex: /&(nbsp|#160);/g,
758
750
  val: " "
759
751
  },
760
- // "lt" : { regex: /&(lt|#60);/g, val: "<" },
761
- // "gt" : { regex: /&(gt|#62);/g, val: ">" },
762
- // "amp" : { regex: /&(amp|#38);/g, val: "&" },
763
- // "quot" : { regex: /&(quot|#34);/g, val: "\"" },
764
- // "apos" : { regex: /&(apos|#39);/g, val: "'" },
765
752
  "cent": {
766
753
  regex: /&(cent|#162);/g,
767
754
  val: "\xA2"
@@ -1351,11 +1338,6 @@ var __exports__ = (() => {
1351
1338
  this.externalEntities = {};
1352
1339
  this.options = buildOptions(options);
1353
1340
  }
1354
- /**
1355
- * Parse XML dats to JS object
1356
- * @param {string|Buffer} xmlData
1357
- * @param {boolean|Object} validationOption
1358
- */
1359
1341
  parse(xmlData, validationOption) {
1360
1342
  if (typeof xmlData === "string") {
1361
1343
  } else if (xmlData.toString) {
@@ -1379,11 +1361,6 @@ var __exports__ = (() => {
1379
1361
  else
1380
1362
  return prettify(orderedResult, this.options);
1381
1363
  }
1382
- /**
1383
- * Add Entity which is not by default supported by this library
1384
- * @param {string} key
1385
- * @param {string} value
1386
- */
1387
1364
  addEntity(key, value) {
1388
1365
  if (value.indexOf("&") !== -1) {
1389
1366
  throw new Error("Entity value can't have '&'");
@@ -1553,33 +1530,24 @@ var __exports__ = (() => {
1553
1530
  preserveOrder: false,
1554
1531
  commentPropName: false,
1555
1532
  unpairedTags: [],
1556
- entities: [
1557
- {
1558
- regex: new RegExp("&", "g"),
1559
- val: "&amp;"
1560
- },
1561
- //it must be on top
1562
- {
1563
- regex: new RegExp(">", "g"),
1564
- val: "&gt;"
1565
- },
1566
- {
1567
- regex: new RegExp("<", "g"),
1568
- val: "&lt;"
1569
- },
1570
- {
1571
- regex: new RegExp("'", "g"),
1572
- val: "&apos;"
1573
- },
1574
- {
1575
- regex: new RegExp('"', "g"),
1576
- val: "&quot;"
1577
- }
1578
- ],
1533
+ entities: [{
1534
+ regex: new RegExp("&", "g"),
1535
+ val: "&amp;"
1536
+ }, {
1537
+ regex: new RegExp(">", "g"),
1538
+ val: "&gt;"
1539
+ }, {
1540
+ regex: new RegExp("<", "g"),
1541
+ val: "&lt;"
1542
+ }, {
1543
+ regex: new RegExp("'", "g"),
1544
+ val: "&apos;"
1545
+ }, {
1546
+ regex: new RegExp('"', "g"),
1547
+ val: "&quot;"
1548
+ }],
1579
1549
  processEntities: true,
1580
1550
  stopNodes: [],
1581
- // transformTagName: false,
1582
- // transformAttributeName: false,
1583
1551
  oneListGroup: false
1584
1552
  };
1585
1553
  function Builder(options) {
@@ -2121,9 +2089,6 @@ var __exports__ = (() => {
2121
2089
  var SAX = class {
2122
2090
  EVENTS = EVENTS;
2123
2091
  ENTITIES = {
2124
- // TODO: make it readonly, needed for entity-mega test
2125
- // amp, gt, lt, quot and apos are resolved to strings instead of numerical
2126
- // codes, IDK why
2127
2092
  ...ENTITIES
2128
2093
  };
2129
2094
  XML_ENTITIES = {
@@ -2150,80 +2115,43 @@ var __exports__ = (() => {
2150
2115
  position = 0;
2151
2116
  STATE = {
2152
2117
  BEGIN: this.S++,
2153
- // leading byte order mark or whitespace
2154
2118
  BEGIN_WHITESPACE: this.S++,
2155
- // leading whitespace
2156
2119
  TEXT: this.S++,
2157
- // general stuff
2158
2120
  TEXT_ENTITY: this.S++,
2159
- // &amp and such.
2160
2121
  OPEN_WAKA: this.S++,
2161
- // <
2162
2122
  SGML_DECL: this.S++,
2163
- // <!BLARG
2164
2123
  SGML_DECL_QUOTED: this.S++,
2165
- // <!BLARG foo "bar
2166
2124
  DOCTYPE: this.S++,
2167
- // <!DOCTYPE
2168
2125
  DOCTYPE_QUOTED: this.S++,
2169
- // <!DOCTYPE "//blah
2170
2126
  DOCTYPE_DTD: this.S++,
2171
- // <!DOCTYPE "//blah" [ ...
2172
2127
  DOCTYPE_DTD_QUOTED: this.S++,
2173
- // <!DOCTYPE "//blah" [ "foo
2174
2128
  COMMENT_STARTING: this.S++,
2175
- // <!-
2176
2129
  COMMENT: this.S++,
2177
- // <!--
2178
2130
  COMMENT_ENDING: this.S++,
2179
- // <!-- blah -
2180
2131
  COMMENT_ENDED: this.S++,
2181
- // <!-- blah --
2182
2132
  CDATA: this.S++,
2183
- // <![CDATA[ something
2184
2133
  CDATA_ENDING: this.S++,
2185
- // ]
2186
2134
  CDATA_ENDING_2: this.S++,
2187
- // ]]
2188
2135
  PROC_INST: this.S++,
2189
- // <?hi
2190
2136
  PROC_INST_BODY: this.S++,
2191
- // <?hi there
2192
2137
  PROC_INST_ENDING: this.S++,
2193
- // <?hi "there" ?
2194
2138
  OPEN_TAG: this.S++,
2195
- // <strong
2196
2139
  OPEN_TAG_SLASH: this.S++,
2197
- // <strong /
2198
2140
  ATTRIB: this.S++,
2199
- // <a
2200
2141
  ATTRIB_NAME: this.S++,
2201
- // <a foo
2202
2142
  ATTRIB_NAME_SAW_WHITE: this.S++,
2203
- // <a foo _
2204
2143
  ATTRIB_VALUE: this.S++,
2205
- // <a foo=
2206
2144
  ATTRIB_VALUE_QUOTED: this.S++,
2207
- // <a foo="bar
2208
2145
  ATTRIB_VALUE_CLOSED: this.S++,
2209
- // <a foo="bar"
2210
2146
  ATTRIB_VALUE_UNQUOTED: this.S++,
2211
- // <a foo=bar
2212
2147
  ATTRIB_VALUE_ENTITY_Q: this.S++,
2213
- // <foo bar="&quot;"
2214
2148
  ATTRIB_VALUE_ENTITY_U: this.S++,
2215
- // <foo bar=&quot
2216
2149
  CLOSE_TAG: this.S++,
2217
- // </a
2218
2150
  CLOSE_TAG_SAW_WHITE: this.S++,
2219
- // </a >
2220
2151
  SCRIPT: this.S++,
2221
- // <script> ...
2222
2152
  SCRIPT_ENDING: this.S++
2223
- // <script> ... <
2224
2153
  };
2225
2154
  BUFFERS = BUFFERS;
2226
- // private parser: (strict: boolean, opt: any) => SAXParser;
2227
2155
  CDATA = "[CDATA[";
2228
2156
  DOCTYPE = "DOCTYPE";
2229
2157
  XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace";
@@ -3173,21 +3101,14 @@ Actual: ${this.attribValue}`);
3173
3101
  throw new Error(options?._parser);
3174
3102
  }
3175
3103
  const fastXMLOptions = {
3176
- // Default FastXML options
3177
- // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md#allowbooleanattributes
3178
3104
  allowBooleanAttributes: true,
3179
- // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md#ignoredeclaration
3180
3105
  ignoreDeclaration: true,
3181
- // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md#removensprefix
3182
3106
  removeNSPrefix: options?.removeNSPrefix,
3183
- // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md#textnodename
3184
3107
  textNodeName: options?.textNodeName,
3185
- // Let's application specify keys that are always arrays
3186
3108
  isArray: (name, jpath, isLeafNode, isAttribute) => {
3187
3109
  const array = Boolean(options?.arrayPaths?.some((path) => jpath === path));
3188
3110
  return array;
3189
3111
  },
3190
- // Application overrides
3191
3112
  ...options?._fastXML
3192
3113
  };
3193
3114
  const xml = fastParseXML(text, fastXMLOptions);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/xml",
3
- "version": "4.0.0-beta.3",
3
+ "version": "4.0.0-beta.4",
4
4
  "description": "Framework-independent loaders for the XML (eXtensible Markup Language) format",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -41,9 +41,9 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "@babel/runtime": "^7.3.1",
44
- "@loaders.gl/loader-utils": "4.0.0-beta.3",
45
- "@loaders.gl/schema": "4.0.0-beta.3",
44
+ "@loaders.gl/loader-utils": "4.0.0-beta.4",
45
+ "@loaders.gl/schema": "4.0.0-beta.4",
46
46
  "fast-xml-parser": "^4.2.5"
47
47
  },
48
- "gitHead": "7ba9621cc51c7a26c407086ac86171f35b8712af"
48
+ "gitHead": "848c20b474532d301f2c3f8d4e1fb9bf262b86d4"
49
49
  }