@loaders.gl/geotiff 4.3.0-alpha.4 → 4.3.0-alpha.6

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.
package/dist/dist.dev.js CHANGED
@@ -8034,6 +8034,8 @@ var __exports__ = (() => {
8034
8034
  return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' doesn't have proper closing.", getLineNumberForPosition(xmlData, i));
8035
8035
  } else if (attrStr.trim().length > 0) {
8036
8036
  return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' can't have attributes or invalid starting.", getLineNumberForPosition(xmlData, tagStartPos));
8037
+ } else if (tags.length === 0) {
8038
+ return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' has not been opened.", getLineNumberForPosition(xmlData, tagStartPos));
8037
8039
  } else {
8038
8040
  const otg = tags.pop();
8039
8041
  if (tagName !== otg.tagName) {
@@ -8570,7 +8572,6 @@ var __exports__ = (() => {
8570
8572
  var xmlNode = require_xmlNode();
8571
8573
  var readDocType = require_DocTypeReader();
8572
8574
  var toNumber = require_strnum();
8573
- var regx = "<((!\\[CDATA\\[([\\s\\S]*?)(]]>))|((NAME:)?(NAME))([^>]*)>|((\\/)(NAME)\\s*>))([^<]*)".replace(/NAME/g, util.nameRegexp);
8574
8575
  var OrderedObjParser = class {
8575
8576
  constructor(options) {
8576
8577
  this.options = options;
@@ -8597,7 +8598,9 @@ var __exports__ = (() => {
8597
8598
  "euro": { regex: /&(euro|#8364);/g, val: "\u20AC" },
8598
8599
  "copyright": { regex: /&(copy|#169);/g, val: "\xA9" },
8599
8600
  "reg": { regex: /&(reg|#174);/g, val: "\xAE" },
8600
- "inr": { regex: /&(inr|#8377);/g, val: "\u20B9" }
8601
+ "inr": { regex: /&(inr|#8377);/g, val: "\u20B9" },
8602
+ "num_dec": { regex: /&#([0-9]{1,7});/g, val: (_, str) => String.fromCharCode(Number.parseInt(str, 10)) },
8603
+ "num_hex": { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (_, str) => String.fromCharCode(Number.parseInt(str, 16)) }
8601
8604
  };
8602
8605
  this.addExternalEntities = addExternalEntities;
8603
8606
  this.parseXml = parseXml;
@@ -8779,18 +8782,19 @@ var __exports__ = (() => {
8779
8782
  const closeIndex = findClosingIndex(xmlData, "]]>", i, "CDATA is not closed.") - 2;
8780
8783
  const tagExp = xmlData.substring(i + 9, closeIndex);
8781
8784
  textData = this.saveTextToParentTag(textData, currentNode, jPath);
8785
+ let val2 = this.parseTextData(tagExp, currentNode.tagname, jPath, true, false, true, true);
8786
+ if (val2 == void 0)
8787
+ val2 = "";
8782
8788
  if (this.options.cdataPropName) {
8783
8789
  currentNode.add(this.options.cdataPropName, [{ [this.options.textNodeName]: tagExp }]);
8784
8790
  } else {
8785
- let val2 = this.parseTextData(tagExp, currentNode.tagname, jPath, true, false, true);
8786
- if (val2 == void 0)
8787
- val2 = "";
8788
8791
  currentNode.add(this.options.textNodeName, val2);
8789
8792
  }
8790
8793
  i = closeIndex + 2;
8791
8794
  } else {
8792
8795
  let result = readTagExp(xmlData, i, this.options.removeNSPrefix);
8793
8796
  let tagName = result.tagName;
8797
+ const rawTagName = result.rawTagName;
8794
8798
  let tagExp = result.tagExp;
8795
8799
  let attrExpPresent = result.attrExpPresent;
8796
8800
  let closeIndex = result.closeIndex;
@@ -8813,13 +8817,20 @@ var __exports__ = (() => {
8813
8817
  if (this.isItStopNode(this.options.stopNodes, jPath, tagName)) {
8814
8818
  let tagContent = "";
8815
8819
  if (tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1) {
8820
+ if (tagName[tagName.length - 1] === "/") {
8821
+ tagName = tagName.substr(0, tagName.length - 1);
8822
+ jPath = jPath.substr(0, jPath.length - 1);
8823
+ tagExp = tagName;
8824
+ } else {
8825
+ tagExp = tagExp.substr(0, tagExp.length - 1);
8826
+ }
8816
8827
  i = result.closeIndex;
8817
8828
  } else if (this.options.unpairedTags.indexOf(tagName) !== -1) {
8818
8829
  i = result.closeIndex;
8819
8830
  } else {
8820
- const result2 = this.readStopNodeData(xmlData, tagName, closeIndex + 1);
8831
+ const result2 = this.readStopNodeData(xmlData, rawTagName, closeIndex + 1);
8821
8832
  if (!result2)
8822
- throw new Error(`Unexpected end of ${tagName}`);
8833
+ throw new Error(`Unexpected end of ${rawTagName}`);
8823
8834
  i = result2.i;
8824
8835
  tagContent = result2.tagContent;
8825
8836
  }
@@ -8837,6 +8848,7 @@ var __exports__ = (() => {
8837
8848
  if (tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1) {
8838
8849
  if (tagName[tagName.length - 1] === "/") {
8839
8850
  tagName = tagName.substr(0, tagName.length - 1);
8851
+ jPath = jPath.substr(0, jPath.length - 1);
8840
8852
  tagExp = tagName;
8841
8853
  } else {
8842
8854
  tagExp = tagExp.substr(0, tagExp.length - 1);
@@ -8974,9 +8986,10 @@ var __exports__ = (() => {
8974
8986
  let tagName = tagExp;
8975
8987
  let attrExpPresent = true;
8976
8988
  if (separatorIndex !== -1) {
8977
- tagName = tagExp.substr(0, separatorIndex).replace(/\s\s*$/, "");
8978
- tagExp = tagExp.substr(separatorIndex + 1);
8989
+ tagName = tagExp.substring(0, separatorIndex);
8990
+ tagExp = tagExp.substring(separatorIndex + 1).trimStart();
8979
8991
  }
8992
+ const rawTagName = tagName;
8980
8993
  if (removeNSPrefix) {
8981
8994
  const colonIndex = tagName.indexOf(":");
8982
8995
  if (colonIndex !== -1) {
@@ -8988,7 +9001,8 @@ var __exports__ = (() => {
8988
9001
  tagName,
8989
9002
  tagExp,
8990
9003
  closeIndex,
8991
- attrExpPresent
9004
+ attrExpPresent,
9005
+ rawTagName
8992
9006
  };
8993
9007
  }
8994
9008
  function readStopNodeData(xmlData, tagName, i) {
@@ -9226,6 +9240,8 @@ var __exports__ = (() => {
9226
9240
  for (let i = 0; i < arr.length; i++) {
9227
9241
  const tagObj = arr[i];
9228
9242
  const tagName = propName(tagObj);
9243
+ if (tagName === void 0)
9244
+ continue;
9229
9245
  let newJPath = "";
9230
9246
  if (jPath.length === 0)
9231
9247
  newJPath = tagName;
@@ -9296,6 +9312,8 @@ var __exports__ = (() => {
9296
9312
  const keys = Object.keys(obj);
9297
9313
  for (let i = 0; i < keys.length; i++) {
9298
9314
  const key = keys[i];
9315
+ if (!obj.hasOwnProperty(key))
9316
+ continue;
9299
9317
  if (key !== ":@")
9300
9318
  return key;
9301
9319
  }
@@ -9304,6 +9322,8 @@ var __exports__ = (() => {
9304
9322
  let attrStr = "";
9305
9323
  if (attrMap && !options.ignoreAttributes) {
9306
9324
  for (let attr in attrMap) {
9325
+ if (!attrMap.hasOwnProperty(attr))
9326
+ continue;
9307
9327
  let attrVal = options.attributeValueProcessor(attr, attrMap[attr]);
9308
9328
  attrVal = replaceEntitiesValue(attrVal, options);
9309
9329
  if (attrVal === true && options.suppressBooleanAttributes) {
@@ -9415,12 +9435,20 @@ var __exports__ = (() => {
9415
9435
  let attrStr = "";
9416
9436
  let val2 = "";
9417
9437
  for (let key in jObj) {
9438
+ if (!Object.prototype.hasOwnProperty.call(jObj, key))
9439
+ continue;
9418
9440
  if (typeof jObj[key] === "undefined") {
9441
+ if (this.isAttribute(key)) {
9442
+ val2 += "";
9443
+ }
9419
9444
  } else if (jObj[key] === null) {
9420
- if (key[0] === "?")
9445
+ if (this.isAttribute(key)) {
9446
+ val2 += "";
9447
+ } else if (key[0] === "?") {
9421
9448
  val2 += this.indentate(level) + "<" + key + "?" + this.tagEndChar;
9422
- else
9449
+ } else {
9423
9450
  val2 += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
9451
+ }
9424
9452
  } else if (jObj[key] instanceof Date) {
9425
9453
  val2 += this.buildTextValNode(jObj[key], key, "", level);
9426
9454
  } else if (typeof jObj[key] !== "object") {
@@ -9438,6 +9466,7 @@ var __exports__ = (() => {
9438
9466
  } else if (Array.isArray(jObj[key])) {
9439
9467
  const arrLen = jObj[key].length;
9440
9468
  let listTagVal = "";
9469
+ let listTagAttr = "";
9441
9470
  for (let j = 0; j < arrLen; j++) {
9442
9471
  const item = jObj[key][j];
9443
9472
  if (typeof item === "undefined") {
@@ -9448,16 +9477,26 @@ var __exports__ = (() => {
9448
9477
  val2 += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
9449
9478
  } else if (typeof item === "object") {
9450
9479
  if (this.options.oneListGroup) {
9451
- listTagVal += this.j2x(item, level + 1).val;
9480
+ const result = this.j2x(item, level + 1);
9481
+ listTagVal += result.val;
9482
+ if (this.options.attributesGroupName && item.hasOwnProperty(this.options.attributesGroupName)) {
9483
+ listTagAttr += result.attrStr;
9484
+ }
9452
9485
  } else {
9453
9486
  listTagVal += this.processTextOrObjNode(item, key, level);
9454
9487
  }
9455
9488
  } else {
9456
- listTagVal += this.buildTextValNode(item, key, "", level);
9489
+ if (this.options.oneListGroup) {
9490
+ let textValue = this.options.tagValueProcessor(key, item);
9491
+ textValue = this.replaceEntitiesValue(textValue);
9492
+ listTagVal += textValue;
9493
+ } else {
9494
+ listTagVal += this.buildTextValNode(item, key, "", level);
9495
+ }
9457
9496
  }
9458
9497
  }
9459
9498
  if (this.options.oneListGroup) {
9460
- listTagVal = this.buildObjectNode(listTagVal, key, "", level);
9499
+ listTagVal = this.buildObjectNode(listTagVal, key, listTagAttr, level);
9461
9500
  }
9462
9501
  val2 += listTagVal;
9463
9502
  } else {
@@ -9504,7 +9543,7 @@ var __exports__ = (() => {
9504
9543
  piClosingChar = "?";
9505
9544
  tagEndExp = "";
9506
9545
  }
9507
- if (attrStr && val2.indexOf("<") === -1) {
9546
+ if ((attrStr || attrStr === "") && val2.indexOf("<") === -1) {
9508
9547
  return this.indentate(level) + "<" + key + attrStr + piClosingChar + ">" + val2 + tagEndExp;
9509
9548
  } else if (this.options.commentPropName !== false && key === this.options.commentPropName && piClosingChar.length === 0) {
9510
9549
  return this.indentate(level) + `<!--${val2}-->` + this.newLine;
@@ -9555,7 +9594,7 @@ var __exports__ = (() => {
9555
9594
  return this.options.indentBy.repeat(level);
9556
9595
  }
9557
9596
  function isAttribute(name) {
9558
- if (name.startsWith(this.options.attributeNamePrefix)) {
9597
+ if (name.startsWith(this.options.attributeNamePrefix) && name !== this.options.textNodeName) {
9559
9598
  return name.substr(this.attrPrefixLen);
9560
9599
  } else {
9561
9600
  return false;