@loaders.gl/ogc 5.0.0-beta.1 → 5.0.0-beta.2

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 (133) hide show
  1. package/README.md +4 -2
  2. package/dist/{wms/gml-loader.cjs → gml-loader.cjs} +2748 -3796
  3. package/dist/gml-loader.cjs.map +6 -0
  4. package/dist/gml-loader.d.ts +2 -0
  5. package/dist/gml-loader.d.ts.map +1 -0
  6. package/dist/gml-loader.js +2 -0
  7. package/dist/gml-loader.js.map +1 -0
  8. package/dist/index.cjs +333 -4376
  9. package/dist/index.cjs.map +3 -3
  10. package/dist/stac/index.cjs +19 -1041
  11. package/dist/stac/index.cjs.map +3 -3
  12. package/dist/stac/stac-source-loader-types.js +3 -3
  13. package/dist/stac/stac-source-loader-types.js.map +1 -1
  14. package/dist/{stac/stac-source.cjs → stac-source.cjs} +212 -779
  15. package/dist/stac-source.cjs.map +6 -0
  16. package/dist/stac-source.d.ts +2 -0
  17. package/dist/stac-source.d.ts.map +1 -0
  18. package/dist/stac-source.js +2 -0
  19. package/dist/stac-source.js.map +1 -0
  20. package/dist/wms/bundled.cjs +2552 -3514
  21. package/dist/wms/bundled.cjs.map +3 -3
  22. package/dist/wms/csw-capabilities-loader-with-parser.d.ts +1 -1
  23. package/dist/wms/csw-capabilities-loader-with-parser.d.ts.map +1 -1
  24. package/dist/wms/csw-capabilities-loader.d.ts +1 -1
  25. package/dist/wms/csw-capabilities-loader.d.ts.map +1 -1
  26. package/dist/wms/csw-capabilities-loader.js +1 -1
  27. package/dist/wms/csw-domain-loader-with-parser.d.ts +1 -1
  28. package/dist/wms/csw-domain-loader-with-parser.d.ts.map +1 -1
  29. package/dist/wms/csw-domain-loader.d.ts +1 -1
  30. package/dist/wms/csw-domain-loader.d.ts.map +1 -1
  31. package/dist/wms/csw-domain-loader.js +1 -1
  32. package/dist/wms/csw-records-loader-with-parser.d.ts +1 -1
  33. package/dist/wms/csw-records-loader-with-parser.d.ts.map +1 -1
  34. package/dist/wms/csw-records-loader.d.ts +1 -1
  35. package/dist/wms/csw-records-loader.d.ts.map +1 -1
  36. package/dist/wms/csw-records-loader.js +1 -1
  37. package/dist/wms/csw-source-loader.js +1 -1
  38. package/dist/wms/gml-loader-types.js +2 -2
  39. package/dist/wms/gml-loader-types.js.map +1 -1
  40. package/dist/wms/index.cjs +3035 -3896
  41. package/dist/wms/index.cjs.map +3 -3
  42. package/dist/wms/lib/parsers/csw/parse-csw-capabilities.d.ts +1 -1
  43. package/dist/wms/lib/parsers/csw/parse-csw-capabilities.d.ts.map +1 -1
  44. package/dist/wms/lib/parsers/csw/parse-csw-domain.d.ts +1 -1
  45. package/dist/wms/lib/parsers/csw/parse-csw-domain.d.ts.map +1 -1
  46. package/dist/wms/lib/parsers/csw/parse-csw-records.d.ts +1 -1
  47. package/dist/wms/lib/parsers/csw/parse-csw-records.d.ts.map +1 -1
  48. package/dist/wms/lib/parsers/csw/parse-csw-records.js +2 -5
  49. package/dist/wms/lib/parsers/csw/parse-csw-records.js.map +1 -1
  50. package/dist/wms/lib/parsers/csw/parse-exception-report.js +2 -2
  51. package/dist/wms/lib/parsers/csw/parse-exception-report.js.map +1 -1
  52. package/dist/wms/lib/parsers/wms/parse-wms-error.d.ts.map +1 -1
  53. package/dist/wms/lib/parsers/wms/parse-wms-error.js +3 -1
  54. package/dist/wms/lib/parsers/wms/parse-wms-error.js.map +1 -1
  55. package/dist/wms/lib/parsers/wms/parse-wms-layer-description.d.ts +1 -1
  56. package/dist/wms/lib/parsers/wms/parse-wms-layer-description.d.ts.map +1 -1
  57. package/dist/wms/lib/parsers/wmts/parse-wmts-capabilities.js +1 -1
  58. package/dist/wms/lib/parsers/wmts/parse-wmts-capabilities.js.map +1 -1
  59. package/dist/wms/lib/parsers/xml/parse-xml-text.d.ts +1 -1
  60. package/dist/wms/lib/parsers/xml/parse-xml-text.d.ts.map +1 -1
  61. package/dist/wms/lib/parsers/xml/parse-xml-text.js +2 -1
  62. package/dist/wms/lib/parsers/xml/parse-xml-text.js.map +1 -1
  63. package/dist/wms/unbundled.cjs +304 -3330
  64. package/dist/wms/unbundled.cjs.map +3 -3
  65. package/dist/wms/wcs-source-loader.js +1 -1
  66. package/dist/wms/wcs-source-loader.js.map +1 -1
  67. package/dist/wms/wfs-capabilities-loader.js +1 -1
  68. package/dist/wms/wfs-source-loader.d.ts +2 -2
  69. package/dist/wms/wfs-source-loader.js +2 -2
  70. package/dist/wms/wip/wcs-capabilities-loader.js +1 -1
  71. package/dist/wms/wip/wmts-capabilities-loader-with-parser.d.ts +1 -1
  72. package/dist/wms/wip/wmts-capabilities-loader-with-parser.d.ts.map +1 -1
  73. package/dist/wms/wip/wmts-capabilities-loader.d.ts +1 -1
  74. package/dist/wms/wip/wmts-capabilities-loader.d.ts.map +1 -1
  75. package/dist/wms/wip/wmts-capabilities-loader.js +1 -1
  76. package/dist/wms/wms-capabilities-loader-with-parser.d.ts +1 -1
  77. package/dist/wms/wms-capabilities-loader-with-parser.d.ts.map +1 -1
  78. package/dist/wms/wms-capabilities-loader.d.ts +1 -1
  79. package/dist/wms/wms-capabilities-loader.d.ts.map +1 -1
  80. package/dist/wms/wms-capabilities-loader.js +1 -1
  81. package/dist/wms/wms-error-loader.js +1 -1
  82. package/dist/wms/wms-source-loader.d.ts +2 -2
  83. package/dist/wms/wms-source-loader.d.ts.map +1 -1
  84. package/dist/wms/wms-source-loader.js +3 -3
  85. package/dist/wms/wms-source-loader.js.map +1 -1
  86. package/dist/wms/wmts-capabilities-loader.js +1 -1
  87. package/dist/wms/wmts-capabilities-loader.js.map +1 -1
  88. package/dist/wms/wmts-source-loader.d.ts +2 -2
  89. package/dist/wms/wmts-source-loader.d.ts.map +1 -1
  90. package/dist/wms/wmts-source-loader.js +3 -3
  91. package/dist/wms/wmts-source-loader.js.map +1 -1
  92. package/dist/{wms/wmts-capabilities-loader-with-parser.cjs → wmts-capabilities-loader-with-parser.cjs} +218 -179
  93. package/dist/wmts-capabilities-loader-with-parser.cjs.map +6 -0
  94. package/dist/wmts-capabilities-loader-with-parser.d.ts +2 -0
  95. package/dist/wmts-capabilities-loader-with-parser.d.ts.map +1 -0
  96. package/dist/wmts-capabilities-loader-with-parser.js +3 -0
  97. package/dist/wmts-capabilities-loader-with-parser.js.map +1 -0
  98. package/package.json +27 -20
  99. package/src/gml-loader.ts +1 -0
  100. package/src/stac/stac-source-loader-types.ts +2 -2
  101. package/src/stac-source.ts +1 -0
  102. package/src/wms/csw-capabilities-loader-with-parser.ts +1 -1
  103. package/src/wms/csw-capabilities-loader.ts +1 -1
  104. package/src/wms/csw-domain-loader-with-parser.ts +1 -1
  105. package/src/wms/csw-domain-loader.ts +1 -1
  106. package/src/wms/csw-records-loader-with-parser.ts +1 -1
  107. package/src/wms/csw-records-loader.ts +1 -1
  108. package/src/wms/gml-loader-types.ts +1 -1
  109. package/src/wms/lib/parsers/csw/parse-csw-capabilities.ts +1 -1
  110. package/src/wms/lib/parsers/csw/parse-csw-domain.ts +1 -1
  111. package/src/wms/lib/parsers/csw/parse-csw-records.ts +3 -6
  112. package/src/wms/lib/parsers/csw/parse-exception-report.ts +2 -2
  113. package/src/wms/lib/parsers/wms/parse-wms-error.ts +3 -1
  114. package/src/wms/lib/parsers/wms/parse-wms-layer-description.ts +1 -1
  115. package/src/wms/lib/parsers/wmts/parse-wmts-capabilities.ts +1 -1
  116. package/src/wms/lib/parsers/xml/parse-xml-text.ts +3 -2
  117. package/src/wms/wcs-source-loader.ts +1 -1
  118. package/src/wms/wfs-source-loader.ts +2 -2
  119. package/src/wms/wip/wms-feature-info-loader-with-parser.ts +1 -1
  120. package/src/wms/wip/wms-feature-info-loader.ts +1 -1
  121. package/src/wms/wip/wms-layer-description-loader-with-parser.ts +1 -1
  122. package/src/wms/wip/wms-layer-description-loader.ts +1 -1
  123. package/src/wms/wip/wmts-capabilities-loader-with-parser.ts +1 -1
  124. package/src/wms/wip/wmts-capabilities-loader.ts +1 -1
  125. package/src/wms/wms-capabilities-loader-with-parser.ts +1 -1
  126. package/src/wms/wms-capabilities-loader.ts +1 -1
  127. package/src/wms/wms-source-loader.ts +5 -13
  128. package/src/wms/wmts-capabilities-loader.ts +1 -1
  129. package/src/wms/wmts-source-loader.ts +5 -5
  130. package/src/wmts-capabilities-loader-with-parser.ts +2 -0
  131. package/dist/stac/stac-source.cjs.map +0 -6
  132. package/dist/wms/gml-loader.cjs.map +0 -6
  133. package/dist/wms/wmts-capabilities-loader-with-parser.cjs.map +0 -6
@@ -25,26 +25,7 @@ var __copyProps = (to, from, except, desc) => {
25
25
  };
26
26
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
27
 
28
- // ../xml/src/xml-format.ts
29
- var XMLFormat;
30
- var init_xml_format = __esm({
31
- "../xml/src/xml-format.ts"() {
32
- "use strict";
33
- XMLFormat = {
34
- name: "XML",
35
- id: "xml",
36
- module: "xml",
37
- encoding: "xml",
38
- format: "xml",
39
- extensions: ["xml"],
40
- mimeTypes: ["application/xml", "text/xml"],
41
- category: "table",
42
- text: true
43
- };
44
- }
45
- });
46
-
47
- // ../xml/src/lib/xml-utils/uncapitalize.ts
28
+ // ../documents/src/lib/xml-utils/uncapitalize.ts
48
29
  function uncapitalize(str) {
49
30
  return typeof str === "string" ? str.charAt(0).toLowerCase() + str.slice(1) : str;
50
31
  }
@@ -55,22 +36,27 @@ function uncapitalizeKeys(object) {
55
36
  if (object && typeof object === "object") {
56
37
  const newObject = {};
57
38
  for (const [key, value] of Object.entries(object)) {
58
- newObject[uncapitalize(key)] = uncapitalizeKeys(value);
39
+ Object.defineProperty(newObject, uncapitalize(key), {
40
+ value: uncapitalizeKeys(value),
41
+ enumerable: true,
42
+ configurable: true,
43
+ writable: true
44
+ });
59
45
  }
60
46
  return newObject;
61
47
  }
62
48
  return object;
63
49
  }
64
50
  var init_uncapitalize = __esm({
65
- "../xml/src/lib/xml-utils/uncapitalize.ts"() {
51
+ "../documents/src/lib/xml-utils/uncapitalize.ts"() {
66
52
  "use strict";
67
53
  }
68
54
  });
69
55
 
70
- // ../xml/src/sax-ts/sax.ts
56
+ // ../documents/src/sax-ts/sax.ts
71
57
  var DEFAULT_SAX_EVENTS, DEFAULT_SAX_PARSER_OPTIONS, EVENTS, BUFFERS, nameStart, nameBody, entityStart, entityBody, ENTITIES, SAX, SAXParser;
72
58
  var init_sax = __esm({
73
- "../xml/src/sax-ts/sax.ts"() {
59
+ "../documents/src/sax-ts/sax.ts"() {
74
60
  "use strict";
75
61
  DEFAULT_SAX_EVENTS = {
76
62
  ontext: () => {
@@ -118,6 +104,9 @@ var init_sax = __esm({
118
104
  lowercasetags: false,
119
105
  noscript: false,
120
106
  strictEntities: false,
107
+ preserveCase: false,
108
+ caseInsensitiveTags: false,
109
+ processEntities: true,
121
110
  xmlns: void 0,
122
111
  position: void 0,
123
112
  trim: void 0,
@@ -934,7 +923,12 @@ var init_sax = __esm({
934
923
  continue;
935
924
  } else {
936
925
  this.strictFail("Attribute without value");
937
- this.tag.attributes[this.attribName] = "";
926
+ Object.defineProperty(this.tag.attributes, this.attribName, {
927
+ value: "",
928
+ enumerable: true,
929
+ configurable: true,
930
+ writable: true
931
+ });
938
932
  this.attribValue = "";
939
933
  this.emitNode("onattribute", {
940
934
  name: this.attribName,
@@ -1115,7 +1109,7 @@ var init_sax = __esm({
1115
1109
  }
1116
1110
  end() {
1117
1111
  if (this.sawRoot && !this.closedRoot) this.strictFail("Unclosed root tag");
1118
- if (this.state !== this.S.BEGIN && this.state !== this.S.BEGIN_WHITESPACE && this.state !== this.S.TEXT) {
1112
+ if (this.strict && this.state !== this.S.BEGIN && this.state !== this.S.BEGIN_WHITESPACE && this.state !== this.S.TEXT) {
1119
1113
  this.errorFunction("Unexpected end");
1120
1114
  }
1121
1115
  this.closeText();
@@ -1138,10 +1132,11 @@ Char: ${this.c}`;
1138
1132
  return this;
1139
1133
  }
1140
1134
  attrib() {
1141
- if (!this.strict) {
1135
+ if (!this.strict && !this.opt.preserveCase) {
1142
1136
  this.attribName = this.attribName[this.looseCase]();
1143
1137
  }
1144
- if (this.attribList.indexOf(this.attribName) !== -1 || this.tag.attributes.hasOwnProperty(this.attribName)) {
1138
+ if (this.attribList.indexOf(this.attribName) !== -1 || Object.hasOwn(this.tag.attributes, this.attribName)) {
1139
+ this.strictFail("Duplicate attribute");
1145
1140
  this.attribName = this.attribValue = "";
1146
1141
  return;
1147
1142
  }
@@ -1171,7 +1166,12 @@ Actual: ${this.attribValue}`
1171
1166
  }
1172
1167
  this.attribList.push([this.attribName, this.attribValue]);
1173
1168
  } else {
1174
- this.tag.attributes[this.attribName] = this.attribValue;
1169
+ Object.defineProperty(this.tag.attributes, this.attribName, {
1170
+ value: this.attribValue,
1171
+ enumerable: true,
1172
+ configurable: true,
1173
+ writable: true
1174
+ });
1175
1175
  this.emitNode("onattribute", {
1176
1176
  name: this.attribName,
1177
1177
  value: this.attribValue
@@ -1180,7 +1180,7 @@ Actual: ${this.attribValue}`
1180
1180
  this.attribName = this.attribValue = "";
1181
1181
  }
1182
1182
  newTag() {
1183
- if (!this.strict) this.tagName = this.tagName[this.looseCase]();
1183
+ if (!this.strict && !this.opt.preserveCase) this.tagName = this.tagName[this.looseCase]();
1184
1184
  const parent = this.tags[this.tags.length - 1] || this;
1185
1185
  const tag = { name: this.tagName, attributes: {} };
1186
1186
  this.tag = tag;
@@ -1190,15 +1190,21 @@ Actual: ${this.attribValue}`
1190
1190
  this.attribList.length = 0;
1191
1191
  this.emitNode("onopentagstart", tag);
1192
1192
  }
1193
+ /** Validates an entity before optionally preserving its authored spelling. */
1193
1194
  parseEntity() {
1195
+ const decoded = this.decodeEntity();
1196
+ return this.opt.processEntities === false ? `&${this.entity};` : decoded;
1197
+ }
1198
+ /** Decodes predefined, configured, or numeric entities without resolving document types. */
1199
+ decodeEntity() {
1194
1200
  let entity = this.entity;
1195
1201
  const entityLC = entity.toLowerCase();
1196
1202
  let num = NaN;
1197
1203
  let numStr = "";
1198
- if (this.ENTITIES[entity]) {
1204
+ if (typeof this.ENTITIES[entity] === "string" || typeof this.ENTITIES[entity] === "number") {
1199
1205
  return this.ENTITIES[entity];
1200
1206
  }
1201
- if (this.ENTITIES[entityLC]) {
1207
+ if (typeof this.ENTITIES[entityLC] === "string" || typeof this.ENTITIES[entityLC] === "number") {
1202
1208
  return this.ENTITIES[entityLC];
1203
1209
  }
1204
1210
  entity = entityLC;
@@ -1218,6 +1224,10 @@ Actual: ${this.attribValue}`
1218
1224
  this.strictFail("Invalid character entity");
1219
1225
  return `&${this.entity};`;
1220
1226
  }
1227
+ if (num < 0 || num > 1114111 || num >= 55296 && num <= 57343 || num < 32 && ![9, 10, 13].includes(num) || num === 65534 || num === 65535) {
1228
+ this.strictFail("Invalid character entity");
1229
+ return `&${this.entity};`;
1230
+ }
1221
1231
  return String.fromCodePoint(num);
1222
1232
  }
1223
1233
  beginWhiteSpace(c) {
@@ -1323,7 +1333,12 @@ Actual: ${this.attribValue}`
1323
1333
  this.strictFail(`Unbound namespace prefix: ${JSON.stringify(prefix)}`);
1324
1334
  a.uri = prefix;
1325
1335
  }
1326
- this.tag.attributes[name] = a;
1336
+ Object.defineProperty(this.tag.attributes, name, {
1337
+ value: a,
1338
+ enumerable: true,
1339
+ configurable: true,
1340
+ writable: true
1341
+ });
1327
1342
  this.emitNode("onattribute", a);
1328
1343
  }
1329
1344
  this.attribList.length = 0;
@@ -1351,8 +1366,10 @@ Actual: ${this.attribValue}`
1351
1366
  this.state = this.S.TEXT;
1352
1367
  return;
1353
1368
  }
1369
+ const caseInsensitiveTags = !this.strict && (this.opt.caseInsensitiveTags || !this.opt.preserveCase);
1354
1370
  if (this.script) {
1355
- if (this.tagName !== "script") {
1371
+ const normalizedScriptCloseTag = caseInsensitiveTags ? this.tagName.toLowerCase() : this.tagName;
1372
+ if (normalizedScriptCloseTag !== "script") {
1356
1373
  this.script += `</${this.tagName}>`;
1357
1374
  this.tagName = "";
1358
1375
  this.state = this.S.SCRIPT;
@@ -1363,12 +1380,11 @@ Actual: ${this.attribValue}`
1363
1380
  }
1364
1381
  let t = this.tags.length;
1365
1382
  let tagName = this.tagName;
1366
- if (!this.strict) {
1367
- tagName = tagName[this.looseCase]();
1368
- }
1383
+ const normalizedTagName = caseInsensitiveTags ? tagName.toLowerCase() : tagName;
1369
1384
  while (t--) {
1370
1385
  const close = this.tags[t];
1371
- if (close.name !== tagName) {
1386
+ const normalizedOpenTagName = caseInsensitiveTags ? close.name.toLowerCase() : close.name;
1387
+ if (normalizedOpenTagName !== normalizedTagName) {
1372
1388
  this.strictFail("Unexpected close tag");
1373
1389
  } else {
1374
1390
  break;
@@ -1453,200 +1469,216 @@ Actual: ${this.attribValue}`
1453
1469
  }
1454
1470
  });
1455
1471
 
1456
- // ../xml/src/lib/parsers/parse-xml-internal.ts
1472
+ // ../documents/src/lib/parsers/parse-xml-internal.ts
1473
+ function setXMLField(object, name, value) {
1474
+ Object.defineProperty(object, name, {
1475
+ value,
1476
+ enumerable: true,
1477
+ configurable: true,
1478
+ writable: true
1479
+ });
1480
+ }
1457
1481
  function parseXMLInternal(text3, options = {}) {
1458
- const state = new InternalXMLParserState(options);
1482
+ if (options.strict !== false && /[^\u0009\u000a\u000d\u0020-\ud7ff\ue000-\ufffd\u{10000}-\u{10ffff}]/u.test(text3)) {
1483
+ throw new Error("XML: invalid XML character");
1484
+ }
1485
+ const maximumDepth = options.maxDepth ?? 256;
1486
+ if (!Number.isSafeInteger(maximumDepth) || maximumDepth < 1 || maximumDepth > 4096) {
1487
+ throw new Error("XML: maxDepth must be an integer between 1 and 4096");
1488
+ }
1489
+ const state = new InternalXMLParserState(options, maximumDepth);
1459
1490
  const parser = new SAXParser({
1460
- strict: true,
1491
+ strict: options.strict !== false,
1492
+ strictEntities: !options.htmlEntities,
1493
+ preserveCase: true,
1494
+ caseInsensitiveTags: options.strict === false,
1495
+ processEntities: options.processEntities !== false,
1461
1496
  onopentag: (tag) => state.openElement(tag.name, tag.attributes || {}),
1462
- ontext: (nodeText) => state.addText(nodeText),
1463
- oncdata: (cdataText) => state.addText(cdataText),
1497
+ ontext: (value) => state.addText(value),
1498
+ oncdata: (value) => state.addText(value),
1499
+ onscript: (value) => state.addText(value),
1464
1500
  onclosetag: () => state.closeElement(),
1465
1501
  onerror: (error) => {
1466
1502
  throw error;
1467
1503
  }
1468
1504
  });
1469
1505
  parser.write(text3).close();
1506
+ if (options.strict === false) {
1507
+ while (state.stack.length) state.closeElement();
1508
+ }
1509
+ if (state.result === void 0) throw new Error("XML: document requires a root element");
1470
1510
  return state.result;
1471
1511
  }
1472
1512
  var InternalXMLParserState;
1473
1513
  var init_parse_xml_internal = __esm({
1474
- "../xml/src/lib/parsers/parse-xml-internal.ts"() {
1514
+ "../documents/src/lib/parsers/parse-xml-internal.ts"() {
1475
1515
  "use strict";
1476
1516
  init_sax();
1477
1517
  InternalXMLParserState = class {
1478
- /** XML parse options. */
1518
+ /** Initializes conversion options and the element nesting budget. */
1519
+ constructor(options, maximumDepth) {
1520
+ this.options = options;
1521
+ this.maximumDepth = maximumDepth;
1522
+ }
1479
1523
  options;
1524
+ maximumDepth;
1480
1525
  /** Open element stack. */
1481
1526
  stack = [];
1482
- /** Final root result. */
1527
+ /** Parsed root document. */
1483
1528
  result;
1484
- /** Create parser state from XML parse options. */
1485
- constructor(options) {
1486
- this.options = options;
1487
- }
1488
- /** Start a new element. */
1529
+ /** Starts an element, rejecting multiple roots and excessive nesting. */
1489
1530
  openElement(name, attributes) {
1531
+ if (this.stack.length >= this.maximumDepth)
1532
+ throw new Error("XML: maximum nesting depth exceeded");
1533
+ if (!this.stack.length && this.result !== void 0 && this.options.strict !== false) {
1534
+ throw new Error("XML: document requires a single root element");
1535
+ }
1490
1536
  const elementName = this.normalizeName(name);
1491
1537
  const parent = this.stack[this.stack.length - 1];
1492
- const path = parent ? `${parent.path}.${elementName}` : elementName;
1493
1538
  this.stack.push({
1494
1539
  name: elementName,
1495
- path,
1540
+ path: parent ? `${parent.path}.${elementName}` : elementName,
1496
1541
  attributes: this.normalizeAttributes(attributes),
1497
1542
  children: {},
1498
1543
  text: ""
1499
1544
  });
1500
1545
  }
1501
- /** Add text or CDATA content to the current element. */
1546
+ /** Accumulates text without losing whitespace between text and CDATA chunks. */
1502
1547
  addText(text3) {
1503
- const currentElement = this.stack[this.stack.length - 1];
1504
- const trimmedText = text3.trim();
1505
- if (currentElement && trimmedText) {
1506
- currentElement.text += trimmedText;
1507
- }
1548
+ const current = this.stack[this.stack.length - 1];
1549
+ if (current) current.text += text3;
1508
1550
  }
1509
- /** Finalize the current element and append it to its parent. */
1551
+ /** Finishes an element and attaches it to its parent or the document root. */
1510
1552
  closeElement() {
1511
1553
  const node = this.stack.pop();
1512
- if (!node) {
1513
- return;
1514
- }
1554
+ if (!node) return;
1515
1555
  const value = this.finalizeElement(node);
1516
1556
  const parent = this.stack[this.stack.length - 1];
1517
- if (parent) {
1518
- this.addChild(parent, node.name, node.path, value);
1519
- } else {
1520
- this.result = { [node.name]: value };
1557
+ if (parent) this.addChild(parent.children, node.name, node.path, value);
1558
+ else {
1559
+ if (this.result === void 0) this.result = {};
1560
+ this.addChild(this.result, node.name, node.path, value);
1521
1561
  }
1522
1562
  }
1523
- /** Convert an open element node into its public value. */
1563
+ /** Converts a completed element, keeping grouping and coercion independent. */
1524
1564
  finalizeElement(node) {
1565
+ const text3 = this.options.trimValues === false ? node.text : node.text.trim();
1525
1566
  const hasAttributes = Object.keys(node.attributes).length > 0;
1526
- const hasChildren = Object.keys(node.children).length > 0;
1527
- const hasText = node.text.length > 0;
1528
- if (!hasAttributes && !hasChildren) {
1529
- return hasText ? this.parseValue(node.text) : "";
1567
+ if (!hasAttributes && !Object.keys(node.children).length) {
1568
+ return this.parseValue(text3, this.options.parseTagValue !== false);
1530
1569
  }
1531
- const object = { ...node.children };
1532
- if (hasText) {
1533
- object[this.options.textNodeName || "value"] = this.parseValue(node.text);
1570
+ const object = node.children;
1571
+ if (text3)
1572
+ setXMLField(
1573
+ object,
1574
+ this.options.textNodeName ?? "value",
1575
+ this.parseValue(text3, this.options.parseTagValue !== false)
1576
+ );
1577
+ if (hasAttributes && this.options.attributesGroupName) {
1578
+ setXMLField(object, this.options.attributesGroupName, node.attributes);
1579
+ } else {
1580
+ for (const [name, value] of Object.entries(node.attributes)) setXMLField(object, name, value);
1534
1581
  }
1535
- Object.assign(object, node.attributes);
1536
1582
  return object;
1537
1583
  }
1538
- /** Append a child element value, promoting repeated names to arrays. */
1539
- addChild(parent, name, path, value) {
1584
+ /** Appends an element while preserving repeated and explicitly array-valued fields. */
1585
+ addChild(object, name, path, value) {
1540
1586
  var _a;
1541
- const existingValue = parent.children[name];
1542
- const shouldBeArray = Boolean((_a = this.options.arrayPaths) == null ? void 0 : _a.some((arrayPath) => arrayPath === path));
1543
- if (existingValue === void 0) {
1544
- parent.children[name] = shouldBeArray ? [value] : value;
1545
- } else if (Array.isArray(existingValue)) {
1546
- existingValue.push(value);
1587
+ if (!Object.hasOwn(object, name)) {
1588
+ setXMLField(object, name, ((_a = this.options.arrayPaths) == null ? void 0 : _a.includes(path)) ? [value] : value);
1547
1589
  } else {
1548
- parent.children[name] = [existingValue, value];
1590
+ const existing = object[name];
1591
+ if (Array.isArray(existing)) existing.push(value);
1592
+ else setXMLField(object, name, [existing, value]);
1549
1593
  }
1550
1594
  }
1551
- /** Normalize all attributes for an element. */
1595
+ /** Applies namespace, prefix, grouping and scalar options to attributes. */
1552
1596
  normalizeAttributes(attributes) {
1553
- const normalizedAttributes = {};
1597
+ const normalized = {};
1598
+ if (this.options.ignoreAttributes) return normalized;
1554
1599
  for (const [name, value] of Object.entries(attributes)) {
1555
- if (this.options.removeNSPrefix && name.startsWith("xmlns")) {
1556
- continue;
1557
- }
1558
- normalizedAttributes[this.normalizeName(name)] = this.parseAttributeValue(value);
1600
+ if (this.options.removeNSPrefix && (name === "xmlns" || name.startsWith("xmlns:"))) continue;
1601
+ const text3 = this.options.trimValues === false ? value : value.trim();
1602
+ setXMLField(
1603
+ normalized,
1604
+ (this.options.attributeNamePrefix ?? "") + this.normalizeName(name),
1605
+ this.parseValue(text3, this.options.parseAttributeValue === true)
1606
+ );
1559
1607
  }
1560
- return normalizedAttributes;
1608
+ return normalized;
1561
1609
  }
1562
- /** Normalize XML tag or attribute names according to namespace options. */
1610
+ /** Removes a namespace prefix only when requested. */
1563
1611
  normalizeName(name) {
1564
- if (!this.options.removeNSPrefix) {
1565
- return name;
1566
- }
1567
- const separatorIndex = name.indexOf(":");
1568
- return separatorIndex === -1 ? name : name.slice(separatorIndex + 1);
1612
+ return this.options.removeNSPrefix ? name.slice(name.indexOf(":") + 1) : name;
1569
1613
  }
1570
- /** Parse attribute values only when the fast-xml-parser compatibility option requests it. */
1571
- parseAttributeValue(value) {
1572
- var _a;
1573
- return ((_a = this.options._fastXML) == null ? void 0 : _a.parseAttributeValue) ? this.parseValue(value) : value;
1574
- }
1575
- /** Parse text node values unless the fast-xml-parser compatibility option disables it. */
1576
- parseValue(value) {
1577
- var _a;
1578
- if (((_a = this.options._fastXML) == null ? void 0 : _a.parseTagValue) === false) {
1579
- return value;
1580
- }
1581
- if (/^(?:true|false)$/i.test(value)) {
1582
- return value.toLowerCase() === "true";
1583
- }
1584
- if (value !== "" && Number.isFinite(Number(value))) {
1585
- return Number(value);
1586
- }
1614
+ /** Coerces only finite numeric values and lowercase XML boolean literals. */
1615
+ parseValue(value, convert) {
1616
+ if (!convert) return value;
1617
+ if (value === "true" || value === "false") return value === "true";
1618
+ if (value !== "" && value.trim() !== "" && Number.isFinite(Number(value))) return Number(value);
1587
1619
  return value;
1588
1620
  }
1589
1621
  };
1590
1622
  }
1591
1623
  });
1592
1624
 
1593
- // ../xml/src/lib/parsers/parse-xml.ts
1594
- function parseXMLSync(text3, options) {
1595
- const xml3 = (options == null ? void 0 : options._parser) === "internal" || (options == null ? void 0 : options._parser) === "sax" ? parseXMLInternal(text3, options) : parseXMLSyncFast(text3, options);
1596
- return (options == null ? void 0 : options.uncapitalizeKeys) ? uncapitalizeKeys(xml3) : xml3;
1597
- }
1598
- function parseXMLSyncFast(text3, options) {
1599
- const fastXMLOptions = {
1600
- // Default FastXML options
1601
- // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md#allowbooleanattributes
1602
- allowBooleanAttributes: true,
1603
- // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md#ignoredeclaration
1604
- ignoreDeclaration: true,
1605
- // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md#removensprefix
1606
- removeNSPrefix: options == null ? void 0 : options.removeNSPrefix,
1607
- // https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md#textnodename
1608
- textNodeName: options == null ? void 0 : options.textNodeName,
1609
- // Let's application specify keys that are always arrays
1610
- isArray: (name, jpath, isLeafNode, isAttribute) => {
1611
- var _a;
1612
- const array = Boolean((_a = options == null ? void 0 : options.arrayPaths) == null ? void 0 : _a.some((path) => jpath.toString() === path));
1613
- return array;
1614
- },
1615
- // Application overrides
1616
- ...options == null ? void 0 : options._fastXML
1617
- };
1618
- return fastParseXML(text3, fastXMLOptions);
1619
- }
1620
- function fastParseXML(text3, options) {
1621
- const parser = new import_fast_xml_parser.XMLParser({
1622
- ignoreAttributes: false,
1623
- attributeNamePrefix: "",
1624
- ...options
1625
- });
1626
- const parsedXML = parser.parse(text3);
1627
- return parsedXML;
1625
+ // ../documents/src/lib/parsers/parse-xml.ts
1626
+ function parseXMLSync(text3, options = {}) {
1627
+ if (Object.hasOwn(options, "_fastXML") || Object.hasOwn(options, "_sax")) {
1628
+ throw new Error("XML: backend-specific options were removed; use native XML options");
1629
+ }
1630
+ if (options._parser && !["internal", "sax"].includes(options._parser)) {
1631
+ throw new Error("XML: unsupported parser backend; use the native documents parser");
1632
+ }
1633
+ const parsed = parseXMLInternal(text3, options);
1634
+ return options.uncapitalizeKeys ? uncapitalizeKeys(parsed) : parsed;
1628
1635
  }
1629
- var import_fast_xml_parser;
1630
1636
  var init_parse_xml = __esm({
1631
- "../xml/src/lib/parsers/parse-xml.ts"() {
1637
+ "../documents/src/lib/parsers/parse-xml.ts"() {
1632
1638
  "use strict";
1633
1639
  init_uncapitalize();
1634
1640
  init_parse_xml_internal();
1635
- import_fast_xml_parser = require("fast-xml-parser");
1636
1641
  }
1637
1642
  });
1638
1643
 
1639
- // ../xml/src/xml-loader-with-parser.ts
1640
- var xml_loader_with_parser_exports = {};
1641
- __export(xml_loader_with_parser_exports, {
1644
+ // ../documents/src/xml-parser.ts
1645
+ var init_xml_parser = __esm({
1646
+ "../documents/src/xml-parser.ts"() {
1647
+ "use strict";
1648
+ init_parse_xml();
1649
+ }
1650
+ });
1651
+
1652
+ // ../documents/src/xml-format.ts
1653
+ var XMLFormat;
1654
+ var init_xml_format = __esm({
1655
+ "../documents/src/xml-format.ts"() {
1656
+ "use strict";
1657
+ XMLFormat = {
1658
+ name: "XML",
1659
+ id: "xml",
1660
+ module: "documents",
1661
+ encoding: "xml",
1662
+ format: "xml",
1663
+ extensions: ["xml"],
1664
+ mimeTypes: ["application/xml", "text/xml"],
1665
+ category: "table",
1666
+ text: true
1667
+ };
1668
+ }
1669
+ });
1670
+
1671
+ // ../documents/src/xml-loader.ts
1672
+ var xml_loader_exports = {};
1673
+ __export(xml_loader_exports, {
1642
1674
  XMLLoaderWithParser: () => XMLLoaderWithParser
1643
1675
  });
1644
1676
  var _XMLLoaderPreload, XMLLoaderMetadataWithoutPreload, XMLLoaderWithParser;
1645
- var init_xml_loader_with_parser = __esm({
1646
- "../xml/src/xml-loader-with-parser.ts"() {
1677
+ var init_xml_loader = __esm({
1678
+ "../documents/src/xml-loader.ts"() {
1647
1679
  "use strict";
1648
1680
  init_parse_xml();
1649
- init_xml_loader();
1681
+ init_xml_loader_types();
1650
1682
  ({ preload: _XMLLoaderPreload, ...XMLLoaderMetadataWithoutPreload } = XMLLoader);
1651
1683
  XMLLoaderWithParser = {
1652
1684
  ...XMLLoaderMetadataWithoutPreload,
@@ -1659,17 +1691,17 @@ var init_xml_loader_with_parser = __esm({
1659
1691
  }
1660
1692
  });
1661
1693
 
1662
- // ../xml/src/xml-loader.ts
1694
+ // ../documents/src/xml-loader-types.ts
1663
1695
  async function preload() {
1664
- const { XMLLoaderWithParser: XMLLoaderWithParser2 } = await Promise.resolve().then(() => (init_xml_loader_with_parser(), xml_loader_with_parser_exports));
1696
+ const { XMLLoaderWithParser: XMLLoaderWithParser2 } = await Promise.resolve().then(() => (init_xml_loader(), xml_loader_exports));
1665
1697
  return XMLLoaderWithParser2;
1666
1698
  }
1667
1699
  function testXMLFile(text3) {
1668
1700
  return text3.startsWith("<?xml");
1669
1701
  }
1670
1702
  var VERSION, XMLLoader;
1671
- var init_xml_loader = __esm({
1672
- "../xml/src/xml-loader.ts"() {
1703
+ var init_xml_loader_types = __esm({
1704
+ "../documents/src/xml-loader-types.ts"() {
1673
1705
  "use strict";
1674
1706
  init_xml_format();
1675
1707
  VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
@@ -1682,7 +1714,7 @@ var init_xml_loader = __esm({
1682
1714
  testText: testXMLFile,
1683
1715
  options: {
1684
1716
  xml: {
1685
- _parser: "fast-xml-parser",
1717
+ strict: true,
1686
1718
  uncapitalizeKeys: false,
1687
1719
  removeNSPrefix: false,
1688
1720
  textNodeName: "value",
@@ -1694,12 +1726,11 @@ var init_xml_loader = __esm({
1694
1726
  }
1695
1727
  });
1696
1728
 
1697
- // ../xml/src/index.ts
1729
+ // ../documents/src/index.ts
1698
1730
  var init_src = __esm({
1699
- "../xml/src/index.ts"() {
1731
+ "../documents/src/index.ts"() {
1700
1732
  "use strict";
1701
- init_xml_loader();
1702
- init_parse_xml();
1733
+ init_xml_loader_types();
1703
1734
  }
1704
1735
  });
1705
1736
 
@@ -1710,19 +1741,19 @@ function parseXMLTextSync2(text3, options) {
1710
1741
  var init_parse_xml_text = __esm({
1711
1742
  "src/wms/lib/parsers/xml/parse-xml-text.ts"() {
1712
1743
  "use strict";
1744
+ init_xml_parser();
1713
1745
  init_src();
1714
1746
  }
1715
1747
  });
1716
1748
 
1717
1749
  // src/wms/lib/parsers/wmts/parse-wmts-capabilities.ts
1718
1750
  function parseWMTSCapabilities2(text3, options) {
1719
- var _a;
1720
1751
  const parsedXML = parseXMLTextSync2(text3, {
1721
1752
  xml: {
1722
1753
  ...(options == null ? void 0 : options.xml) || {},
1723
1754
  _parser: "internal",
1724
1755
  textNodeName: "#text",
1725
- _fastXML: { ...((_a = options == null ? void 0 : options.xml) == null ? void 0 : _a._fastXML) || {}, parseTagValue: false },
1756
+ parseTagValue: false,
1726
1757
  removeNSPrefix: true,
1727
1758
  uncapitalizeKeys: true
1728
1759
  }
@@ -1945,16 +1976,12 @@ var init_wmts_capabilities_loader = __esm({
1945
1976
  extensions: ["xml"],
1946
1977
  mimeTypes: ["application/vnd.ogc.wmts_xml", "application/xml", "text/xml"],
1947
1978
  options: { wmts: {} },
1948
- preload: async () => (await Promise.resolve().then(() => (init_wmts_capabilities_loader_with_parser(), wmts_capabilities_loader_with_parser_exports))).WMTSCapabilitiesLoaderWithParser
1979
+ preload: async () => (await Promise.resolve().then(() => (init_wmts_capabilities_loader_with_parser2(), wmts_capabilities_loader_with_parser_exports))).WMTSCapabilitiesLoaderWithParser
1949
1980
  };
1950
1981
  }
1951
1982
  });
1952
1983
 
1953
1984
  // src/wms/wmts-capabilities-loader-with-parser.ts
1954
- var wmts_capabilities_loader_with_parser_exports = {};
1955
- __export(wmts_capabilities_loader_with_parser_exports, {
1956
- WMTSCapabilitiesLoaderWithParser: () => WMTSCapabilitiesLoaderWithParser
1957
- });
1958
1985
  var _preload, metadata, WMTSCapabilitiesLoaderWithParser;
1959
1986
  var init_wmts_capabilities_loader_with_parser = __esm({
1960
1987
  "src/wms/wmts-capabilities-loader-with-parser.ts"() {
@@ -1970,7 +1997,19 @@ var init_wmts_capabilities_loader_with_parser = __esm({
1970
1997
  }
1971
1998
  });
1972
1999
 
1973
- // dist/wms/wmts-capabilities-loader-with-parser.js
2000
+ // src/wmts-capabilities-loader-with-parser.ts
2001
+ var wmts_capabilities_loader_with_parser_exports = {};
2002
+ __export(wmts_capabilities_loader_with_parser_exports, {
2003
+ WMTSCapabilitiesLoaderWithParser: () => WMTSCapabilitiesLoaderWithParser
2004
+ });
2005
+ var init_wmts_capabilities_loader_with_parser2 = __esm({
2006
+ "src/wmts-capabilities-loader-with-parser.ts"() {
2007
+ "use strict";
2008
+ init_wmts_capabilities_loader_with_parser();
2009
+ }
2010
+ });
2011
+
2012
+ // dist/wmts-capabilities-loader-with-parser.js
1974
2013
  var wmts_capabilities_loader_with_parser_exports2 = {};
1975
2014
  __export(wmts_capabilities_loader_with_parser_exports2, {
1976
2015
  WMTSCapabilitiesLoaderWithParser: () => WMTSCapabilitiesLoaderWithParser2
@@ -1978,6 +2017,7 @@ __export(wmts_capabilities_loader_with_parser_exports2, {
1978
2017
  module.exports = __toCommonJS(wmts_capabilities_loader_with_parser_exports2);
1979
2018
 
1980
2019
  // dist/wms/lib/parsers/xml/parse-xml-text.js
2020
+ init_xml_parser();
1981
2021
  init_src();
1982
2022
  function parseXMLTextSync(text3, options) {
1983
2023
  return parseXMLSync(text3, { ...XMLLoader.options.xml, ...options == null ? void 0 : options.xml });
@@ -1985,13 +2025,12 @@ function parseXMLTextSync(text3, options) {
1985
2025
 
1986
2026
  // dist/wms/lib/parsers/wmts/parse-wmts-capabilities.js
1987
2027
  function parseWMTSCapabilities(text3, options) {
1988
- var _a;
1989
2028
  const parsedXML = parseXMLTextSync(text3, {
1990
2029
  xml: {
1991
2030
  ...(options == null ? void 0 : options.xml) || {},
1992
2031
  _parser: "internal",
1993
2032
  textNodeName: "#text",
1994
- _fastXML: { ...((_a = options == null ? void 0 : options.xml) == null ? void 0 : _a._fastXML) || {}, parseTagValue: false },
2033
+ parseTagValue: false,
1995
2034
  removeNSPrefix: true,
1996
2035
  uncapitalizeKeys: true
1997
2036
  }
@@ -2176,7 +2215,7 @@ var WMTSCapabilitiesLoader2 = {
2176
2215
  extensions: ["xml"],
2177
2216
  mimeTypes: ["application/vnd.ogc.wmts_xml", "application/xml", "text/xml"],
2178
2217
  options: { wmts: {} },
2179
- preload: async () => (await Promise.resolve().then(() => (init_wmts_capabilities_loader_with_parser(), wmts_capabilities_loader_with_parser_exports))).WMTSCapabilitiesLoaderWithParser
2218
+ preload: async () => (await Promise.resolve().then(() => (init_wmts_capabilities_loader_with_parser2(), wmts_capabilities_loader_with_parser_exports))).WMTSCapabilitiesLoaderWithParser
2180
2219
  };
2181
2220
 
2182
2221
  // dist/wms/wmts-capabilities-loader-with-parser.js