@d1g1tal/transportr 0.1.2 → 0.1.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.
@@ -1,9 +1,14 @@
1
1
  var Transportr = (() => {
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __commonJS = (cb, mod) => function __require() {
10
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
11
+ };
7
12
  var __export = (target, all) => {
8
13
  for (var name in all)
9
14
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -16,6 +21,14 @@ var Transportr = (() => {
16
21
  }
17
22
  return to;
18
23
  };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
+ mod
31
+ ));
19
32
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
33
  var __publicField = (obj, key, value) => {
21
34
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -44,6 +57,2605 @@ var Transportr = (() => {
44
57
  return method;
45
58
  };
46
59
 
60
+ // node_modules/@xmldom/xmldom/lib/conventions.js
61
+ var require_conventions = __commonJS({
62
+ "node_modules/@xmldom/xmldom/lib/conventions.js"(exports) {
63
+ "use strict";
64
+ function find(list, predicate, ac) {
65
+ if (ac === void 0) {
66
+ ac = Array.prototype;
67
+ }
68
+ if (list && typeof ac.find === "function") {
69
+ return ac.find.call(list, predicate);
70
+ }
71
+ for (var i = 0; i < list.length; i++) {
72
+ if (Object.prototype.hasOwnProperty.call(list, i)) {
73
+ var item = list[i];
74
+ if (predicate.call(void 0, item, i, list)) {
75
+ return item;
76
+ }
77
+ }
78
+ }
79
+ }
80
+ function freeze(object, oc) {
81
+ if (oc === void 0) {
82
+ oc = Object;
83
+ }
84
+ return oc && typeof oc.freeze === "function" ? oc.freeze(object) : object;
85
+ }
86
+ function assign(target, source) {
87
+ if (target === null || typeof target !== "object") {
88
+ throw new TypeError("target is not an object");
89
+ }
90
+ for (var key in source) {
91
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
92
+ target[key] = source[key];
93
+ }
94
+ }
95
+ return target;
96
+ }
97
+ var MIME_TYPE = freeze({
98
+ /**
99
+ * `text/html`, the only mime type that triggers treating an XML document as HTML.
100
+ *
101
+ * @see DOMParser.SupportedType.isHTML
102
+ * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration
103
+ * @see https://en.wikipedia.org/wiki/HTML Wikipedia
104
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN
105
+ * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring WHATWG HTML Spec
106
+ */
107
+ HTML: "text/html",
108
+ /**
109
+ * Helper method to check a mime type if it indicates an HTML document
110
+ *
111
+ * @param {string} [value]
112
+ * @returns {boolean}
113
+ *
114
+ * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration
115
+ * @see https://en.wikipedia.org/wiki/HTML Wikipedia
116
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN
117
+ * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring */
118
+ isHTML: function(value) {
119
+ return value === MIME_TYPE.HTML;
120
+ },
121
+ /**
122
+ * `application/xml`, the standard mime type for XML documents.
123
+ *
124
+ * @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType registration
125
+ * @see https://tools.ietf.org/html/rfc7303#section-9.1 RFC 7303
126
+ * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
127
+ */
128
+ XML_APPLICATION: "application/xml",
129
+ /**
130
+ * `text/html`, an alias for `application/xml`.
131
+ *
132
+ * @see https://tools.ietf.org/html/rfc7303#section-9.2 RFC 7303
133
+ * @see https://www.iana.org/assignments/media-types/text/xml IANA MimeType registration
134
+ * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
135
+ */
136
+ XML_TEXT: "text/xml",
137
+ /**
138
+ * `application/xhtml+xml`, indicates an XML document that has the default HTML namespace,
139
+ * but is parsed as an XML document.
140
+ *
141
+ * @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType registration
142
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument WHATWG DOM Spec
143
+ * @see https://en.wikipedia.org/wiki/XHTML Wikipedia
144
+ */
145
+ XML_XHTML_APPLICATION: "application/xhtml+xml",
146
+ /**
147
+ * `image/svg+xml`,
148
+ *
149
+ * @see https://www.iana.org/assignments/media-types/image/svg+xml IANA MimeType registration
150
+ * @see https://www.w3.org/TR/SVG11/ W3C SVG 1.1
151
+ * @see https://en.wikipedia.org/wiki/Scalable_Vector_Graphics Wikipedia
152
+ */
153
+ XML_SVG_IMAGE: "image/svg+xml"
154
+ });
155
+ var NAMESPACE = freeze({
156
+ /**
157
+ * The XHTML namespace.
158
+ *
159
+ * @see http://www.w3.org/1999/xhtml
160
+ */
161
+ HTML: "http://www.w3.org/1999/xhtml",
162
+ /**
163
+ * Checks if `uri` equals `NAMESPACE.HTML`.
164
+ *
165
+ * @param {string} [uri]
166
+ *
167
+ * @see NAMESPACE.HTML
168
+ */
169
+ isHTML: function(uri) {
170
+ return uri === NAMESPACE.HTML;
171
+ },
172
+ /**
173
+ * The SVG namespace.
174
+ *
175
+ * @see http://www.w3.org/2000/svg
176
+ */
177
+ SVG: "http://www.w3.org/2000/svg",
178
+ /**
179
+ * The `xml:` namespace.
180
+ *
181
+ * @see http://www.w3.org/XML/1998/namespace
182
+ */
183
+ XML: "http://www.w3.org/XML/1998/namespace",
184
+ /**
185
+ * The `xmlns:` namespace
186
+ *
187
+ * @see https://www.w3.org/2000/xmlns/
188
+ */
189
+ XMLNS: "http://www.w3.org/2000/xmlns/"
190
+ });
191
+ exports.assign = assign;
192
+ exports.find = find;
193
+ exports.freeze = freeze;
194
+ exports.MIME_TYPE = MIME_TYPE;
195
+ exports.NAMESPACE = NAMESPACE;
196
+ }
197
+ });
198
+
199
+ // node_modules/@xmldom/xmldom/lib/dom.js
200
+ var require_dom = __commonJS({
201
+ "node_modules/@xmldom/xmldom/lib/dom.js"(exports) {
202
+ var conventions = require_conventions();
203
+ var find = conventions.find;
204
+ var NAMESPACE = conventions.NAMESPACE;
205
+ function notEmptyString(input) {
206
+ return input !== "";
207
+ }
208
+ function splitOnASCIIWhitespace(input) {
209
+ return input ? input.split(/[\t\n\f\r ]+/).filter(notEmptyString) : [];
210
+ }
211
+ function orderedSetReducer(current, element) {
212
+ if (!current.hasOwnProperty(element)) {
213
+ current[element] = true;
214
+ }
215
+ return current;
216
+ }
217
+ function toOrderedSet(input) {
218
+ if (!input)
219
+ return [];
220
+ var list = splitOnASCIIWhitespace(input);
221
+ return Object.keys(list.reduce(orderedSetReducer, {}));
222
+ }
223
+ function arrayIncludes(list) {
224
+ return function(element) {
225
+ return list && list.indexOf(element) !== -1;
226
+ };
227
+ }
228
+ function copy(src, dest) {
229
+ for (var p in src) {
230
+ if (Object.prototype.hasOwnProperty.call(src, p)) {
231
+ dest[p] = src[p];
232
+ }
233
+ }
234
+ }
235
+ function _extends(Class, Super) {
236
+ var pt = Class.prototype;
237
+ if (!(pt instanceof Super)) {
238
+ let t2 = function() {
239
+ };
240
+ var t = t2;
241
+ ;
242
+ t2.prototype = Super.prototype;
243
+ t2 = new t2();
244
+ copy(pt, t2);
245
+ Class.prototype = pt = t2;
246
+ }
247
+ if (pt.constructor != Class) {
248
+ if (typeof Class != "function") {
249
+ console.error("unknown Class:" + Class);
250
+ }
251
+ pt.constructor = Class;
252
+ }
253
+ }
254
+ var NodeType = {};
255
+ var ELEMENT_NODE = NodeType.ELEMENT_NODE = 1;
256
+ var ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2;
257
+ var TEXT_NODE = NodeType.TEXT_NODE = 3;
258
+ var CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4;
259
+ var ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5;
260
+ var ENTITY_NODE = NodeType.ENTITY_NODE = 6;
261
+ var PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7;
262
+ var COMMENT_NODE = NodeType.COMMENT_NODE = 8;
263
+ var DOCUMENT_NODE = NodeType.DOCUMENT_NODE = 9;
264
+ var DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10;
265
+ var DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11;
266
+ var NOTATION_NODE = NodeType.NOTATION_NODE = 12;
267
+ var ExceptionCode = {};
268
+ var ExceptionMessage = {};
269
+ var INDEX_SIZE_ERR = ExceptionCode.INDEX_SIZE_ERR = (ExceptionMessage[1] = "Index size error", 1);
270
+ var DOMSTRING_SIZE_ERR = ExceptionCode.DOMSTRING_SIZE_ERR = (ExceptionMessage[2] = "DOMString size error", 2);
271
+ var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = (ExceptionMessage[3] = "Hierarchy request error", 3);
272
+ var WRONG_DOCUMENT_ERR = ExceptionCode.WRONG_DOCUMENT_ERR = (ExceptionMessage[4] = "Wrong document", 4);
273
+ var INVALID_CHARACTER_ERR = ExceptionCode.INVALID_CHARACTER_ERR = (ExceptionMessage[5] = "Invalid character", 5);
274
+ var NO_DATA_ALLOWED_ERR = ExceptionCode.NO_DATA_ALLOWED_ERR = (ExceptionMessage[6] = "No data allowed", 6);
275
+ var NO_MODIFICATION_ALLOWED_ERR = ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = (ExceptionMessage[7] = "No modification allowed", 7);
276
+ var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = (ExceptionMessage[8] = "Not found", 8);
277
+ var NOT_SUPPORTED_ERR = ExceptionCode.NOT_SUPPORTED_ERR = (ExceptionMessage[9] = "Not supported", 9);
278
+ var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = (ExceptionMessage[10] = "Attribute in use", 10);
279
+ var INVALID_STATE_ERR = ExceptionCode.INVALID_STATE_ERR = (ExceptionMessage[11] = "Invalid state", 11);
280
+ var SYNTAX_ERR = ExceptionCode.SYNTAX_ERR = (ExceptionMessage[12] = "Syntax error", 12);
281
+ var INVALID_MODIFICATION_ERR = ExceptionCode.INVALID_MODIFICATION_ERR = (ExceptionMessage[13] = "Invalid modification", 13);
282
+ var NAMESPACE_ERR = ExceptionCode.NAMESPACE_ERR = (ExceptionMessage[14] = "Invalid namespace", 14);
283
+ var INVALID_ACCESS_ERR = ExceptionCode.INVALID_ACCESS_ERR = (ExceptionMessage[15] = "Invalid access", 15);
284
+ function DOMException(code, message) {
285
+ if (message instanceof Error) {
286
+ var error = message;
287
+ } else {
288
+ error = this;
289
+ Error.call(this, ExceptionMessage[code]);
290
+ this.message = ExceptionMessage[code];
291
+ if (Error.captureStackTrace)
292
+ Error.captureStackTrace(this, DOMException);
293
+ }
294
+ error.code = code;
295
+ if (message)
296
+ this.message = this.message + ": " + message;
297
+ return error;
298
+ }
299
+ DOMException.prototype = Error.prototype;
300
+ copy(ExceptionCode, DOMException);
301
+ function NodeList() {
302
+ }
303
+ NodeList.prototype = {
304
+ /**
305
+ * The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive.
306
+ * @standard level1
307
+ */
308
+ length: 0,
309
+ /**
310
+ * Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null.
311
+ * @standard level1
312
+ * @param index unsigned long
313
+ * Index into the collection.
314
+ * @return Node
315
+ * The node at the indexth position in the NodeList, or null if that is not a valid index.
316
+ */
317
+ item: function(index) {
318
+ return this[index] || null;
319
+ },
320
+ toString: function(isHTML, nodeFilter) {
321
+ for (var buf = [], i = 0; i < this.length; i++) {
322
+ serializeToString(this[i], buf, isHTML, nodeFilter);
323
+ }
324
+ return buf.join("");
325
+ },
326
+ /**
327
+ * @private
328
+ * @param {function (Node):boolean} predicate
329
+ * @returns {Node[]}
330
+ */
331
+ filter: function(predicate) {
332
+ return Array.prototype.filter.call(this, predicate);
333
+ },
334
+ /**
335
+ * @private
336
+ * @param {Node} item
337
+ * @returns {number}
338
+ */
339
+ indexOf: function(item) {
340
+ return Array.prototype.indexOf.call(this, item);
341
+ }
342
+ };
343
+ function LiveNodeList(node, refresh) {
344
+ this._node = node;
345
+ this._refresh = refresh;
346
+ _updateLiveList(this);
347
+ }
348
+ function _updateLiveList(list) {
349
+ var inc = list._node._inc || list._node.ownerDocument._inc;
350
+ if (list._inc != inc) {
351
+ var ls = list._refresh(list._node);
352
+ __set__(list, "length", ls.length);
353
+ copy(ls, list);
354
+ list._inc = inc;
355
+ }
356
+ }
357
+ LiveNodeList.prototype.item = function(i) {
358
+ _updateLiveList(this);
359
+ return this[i];
360
+ };
361
+ _extends(LiveNodeList, NodeList);
362
+ function NamedNodeMap() {
363
+ }
364
+ function _findNodeIndex(list, node) {
365
+ var i = list.length;
366
+ while (i--) {
367
+ if (list[i] === node) {
368
+ return i;
369
+ }
370
+ }
371
+ }
372
+ function _addNamedNode(el, list, newAttr, oldAttr) {
373
+ if (oldAttr) {
374
+ list[_findNodeIndex(list, oldAttr)] = newAttr;
375
+ } else {
376
+ list[list.length++] = newAttr;
377
+ }
378
+ if (el) {
379
+ newAttr.ownerElement = el;
380
+ var doc = el.ownerDocument;
381
+ if (doc) {
382
+ oldAttr && _onRemoveAttribute(doc, el, oldAttr);
383
+ _onAddAttribute(doc, el, newAttr);
384
+ }
385
+ }
386
+ }
387
+ function _removeNamedNode(el, list, attr) {
388
+ var i = _findNodeIndex(list, attr);
389
+ if (i >= 0) {
390
+ var lastIndex = list.length - 1;
391
+ while (i < lastIndex) {
392
+ list[i] = list[++i];
393
+ }
394
+ list.length = lastIndex;
395
+ if (el) {
396
+ var doc = el.ownerDocument;
397
+ if (doc) {
398
+ _onRemoveAttribute(doc, el, attr);
399
+ attr.ownerElement = null;
400
+ }
401
+ }
402
+ } else {
403
+ throw new DOMException(NOT_FOUND_ERR, new Error(el.tagName + "@" + attr));
404
+ }
405
+ }
406
+ NamedNodeMap.prototype = {
407
+ length: 0,
408
+ item: NodeList.prototype.item,
409
+ getNamedItem: function(key) {
410
+ var i = this.length;
411
+ while (i--) {
412
+ var attr = this[i];
413
+ if (attr.nodeName == key) {
414
+ return attr;
415
+ }
416
+ }
417
+ },
418
+ setNamedItem: function(attr) {
419
+ var el = attr.ownerElement;
420
+ if (el && el != this._ownerElement) {
421
+ throw new DOMException(INUSE_ATTRIBUTE_ERR);
422
+ }
423
+ var oldAttr = this.getNamedItem(attr.nodeName);
424
+ _addNamedNode(this._ownerElement, this, attr, oldAttr);
425
+ return oldAttr;
426
+ },
427
+ /* returns Node */
428
+ setNamedItemNS: function(attr) {
429
+ var el = attr.ownerElement, oldAttr;
430
+ if (el && el != this._ownerElement) {
431
+ throw new DOMException(INUSE_ATTRIBUTE_ERR);
432
+ }
433
+ oldAttr = this.getNamedItemNS(attr.namespaceURI, attr.localName);
434
+ _addNamedNode(this._ownerElement, this, attr, oldAttr);
435
+ return oldAttr;
436
+ },
437
+ /* returns Node */
438
+ removeNamedItem: function(key) {
439
+ var attr = this.getNamedItem(key);
440
+ _removeNamedNode(this._ownerElement, this, attr);
441
+ return attr;
442
+ },
443
+ // raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR
444
+ //for level2
445
+ removeNamedItemNS: function(namespaceURI, localName) {
446
+ var attr = this.getNamedItemNS(namespaceURI, localName);
447
+ _removeNamedNode(this._ownerElement, this, attr);
448
+ return attr;
449
+ },
450
+ getNamedItemNS: function(namespaceURI, localName) {
451
+ var i = this.length;
452
+ while (i--) {
453
+ var node = this[i];
454
+ if (node.localName == localName && node.namespaceURI == namespaceURI) {
455
+ return node;
456
+ }
457
+ }
458
+ return null;
459
+ }
460
+ };
461
+ function DOMImplementation() {
462
+ }
463
+ DOMImplementation.prototype = {
464
+ /**
465
+ * The DOMImplementation.hasFeature() method returns a Boolean flag indicating if a given feature is supported.
466
+ * The different implementations fairly diverged in what kind of features were reported.
467
+ * The latest version of the spec settled to force this method to always return true, where the functionality was accurate and in use.
468
+ *
469
+ * @deprecated It is deprecated and modern browsers return true in all cases.
470
+ *
471
+ * @param {string} feature
472
+ * @param {string} [version]
473
+ * @returns {boolean} always true
474
+ *
475
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/hasFeature MDN
476
+ * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-5CED94D7 DOM Level 1 Core
477
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature DOM Living Standard
478
+ */
479
+ hasFeature: function(feature, version) {
480
+ return true;
481
+ },
482
+ /**
483
+ * Creates an XML Document object of the specified type with its document element.
484
+ *
485
+ * __It behaves slightly different from the description in the living standard__:
486
+ * - There is no interface/class `XMLDocument`, it returns a `Document` instance.
487
+ * - `contentType`, `encoding`, `mode`, `origin`, `url` fields are currently not declared.
488
+ * - this implementation is not validating names or qualified names
489
+ * (when parsing XML strings, the SAX parser takes care of that)
490
+ *
491
+ * @param {string|null} namespaceURI
492
+ * @param {string} qualifiedName
493
+ * @param {DocumentType=null} doctype
494
+ * @returns {Document}
495
+ *
496
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocument MDN
497
+ * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocument DOM Level 2 Core (initial)
498
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument DOM Level 2 Core
499
+ *
500
+ * @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract
501
+ * @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names
502
+ * @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names
503
+ */
504
+ createDocument: function(namespaceURI, qualifiedName, doctype) {
505
+ var doc = new Document();
506
+ doc.implementation = this;
507
+ doc.childNodes = new NodeList();
508
+ doc.doctype = doctype || null;
509
+ if (doctype) {
510
+ doc.appendChild(doctype);
511
+ }
512
+ if (qualifiedName) {
513
+ var root = doc.createElementNS(namespaceURI, qualifiedName);
514
+ doc.appendChild(root);
515
+ }
516
+ return doc;
517
+ },
518
+ /**
519
+ * Returns a doctype, with the given `qualifiedName`, `publicId`, and `systemId`.
520
+ *
521
+ * __This behavior is slightly different from the in the specs__:
522
+ * - this implementation is not validating names or qualified names
523
+ * (when parsing XML strings, the SAX parser takes care of that)
524
+ *
525
+ * @param {string} qualifiedName
526
+ * @param {string} [publicId]
527
+ * @param {string} [systemId]
528
+ * @returns {DocumentType} which can either be used with `DOMImplementation.createDocument` upon document creation
529
+ * or can be put into the document via methods like `Node.insertBefore()` or `Node.replaceChild()`
530
+ *
531
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocumentType MDN
532
+ * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocType DOM Level 2 Core
533
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype DOM Living Standard
534
+ *
535
+ * @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract
536
+ * @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names
537
+ * @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names
538
+ */
539
+ createDocumentType: function(qualifiedName, publicId, systemId) {
540
+ var node = new DocumentType();
541
+ node.name = qualifiedName;
542
+ node.nodeName = qualifiedName;
543
+ node.publicId = publicId || "";
544
+ node.systemId = systemId || "";
545
+ return node;
546
+ }
547
+ };
548
+ function Node() {
549
+ }
550
+ Node.prototype = {
551
+ firstChild: null,
552
+ lastChild: null,
553
+ previousSibling: null,
554
+ nextSibling: null,
555
+ attributes: null,
556
+ parentNode: null,
557
+ childNodes: null,
558
+ ownerDocument: null,
559
+ nodeValue: null,
560
+ namespaceURI: null,
561
+ prefix: null,
562
+ localName: null,
563
+ // Modified in DOM Level 2:
564
+ insertBefore: function(newChild, refChild) {
565
+ return _insertBefore(this, newChild, refChild);
566
+ },
567
+ replaceChild: function(newChild, oldChild) {
568
+ _insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument);
569
+ if (oldChild) {
570
+ this.removeChild(oldChild);
571
+ }
572
+ },
573
+ removeChild: function(oldChild) {
574
+ return _removeChild(this, oldChild);
575
+ },
576
+ appendChild: function(newChild) {
577
+ return this.insertBefore(newChild, null);
578
+ },
579
+ hasChildNodes: function() {
580
+ return this.firstChild != null;
581
+ },
582
+ cloneNode: function(deep) {
583
+ return cloneNode(this.ownerDocument || this, this, deep);
584
+ },
585
+ // Modified in DOM Level 2:
586
+ normalize: function() {
587
+ var child = this.firstChild;
588
+ while (child) {
589
+ var next = child.nextSibling;
590
+ if (next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE) {
591
+ this.removeChild(next);
592
+ child.appendData(next.data);
593
+ } else {
594
+ child.normalize();
595
+ child = next;
596
+ }
597
+ }
598
+ },
599
+ // Introduced in DOM Level 2:
600
+ isSupported: function(feature, version) {
601
+ return this.ownerDocument.implementation.hasFeature(feature, version);
602
+ },
603
+ // Introduced in DOM Level 2:
604
+ hasAttributes: function() {
605
+ return this.attributes.length > 0;
606
+ },
607
+ /**
608
+ * Look up the prefix associated to the given namespace URI, starting from this node.
609
+ * **The default namespace declarations are ignored by this method.**
610
+ * See Namespace Prefix Lookup for details on the algorithm used by this method.
611
+ *
612
+ * _Note: The implementation seems to be incomplete when compared to the algorithm described in the specs._
613
+ *
614
+ * @param {string | null} namespaceURI
615
+ * @returns {string | null}
616
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespacePrefix
617
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/namespaces-algorithms.html#lookupNamespacePrefixAlgo
618
+ * @see https://dom.spec.whatwg.org/#dom-node-lookupprefix
619
+ * @see https://github.com/xmldom/xmldom/issues/322
620
+ */
621
+ lookupPrefix: function(namespaceURI) {
622
+ var el = this;
623
+ while (el) {
624
+ var map = el._nsMap;
625
+ if (map) {
626
+ for (var n in map) {
627
+ if (Object.prototype.hasOwnProperty.call(map, n) && map[n] === namespaceURI) {
628
+ return n;
629
+ }
630
+ }
631
+ }
632
+ el = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode;
633
+ }
634
+ return null;
635
+ },
636
+ // Introduced in DOM Level 3:
637
+ lookupNamespaceURI: function(prefix) {
638
+ var el = this;
639
+ while (el) {
640
+ var map = el._nsMap;
641
+ if (map) {
642
+ if (Object.prototype.hasOwnProperty.call(map, prefix)) {
643
+ return map[prefix];
644
+ }
645
+ }
646
+ el = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode;
647
+ }
648
+ return null;
649
+ },
650
+ // Introduced in DOM Level 3:
651
+ isDefaultNamespace: function(namespaceURI) {
652
+ var prefix = this.lookupPrefix(namespaceURI);
653
+ return prefix == null;
654
+ }
655
+ };
656
+ function _xmlEncoder(c) {
657
+ return c == "<" && "&lt;" || c == ">" && "&gt;" || c == "&" && "&amp;" || c == '"' && "&quot;" || "&#" + c.charCodeAt() + ";";
658
+ }
659
+ copy(NodeType, Node);
660
+ copy(NodeType, Node.prototype);
661
+ function _visitNode(node, callback) {
662
+ if (callback(node)) {
663
+ return true;
664
+ }
665
+ if (node = node.firstChild) {
666
+ do {
667
+ if (_visitNode(node, callback)) {
668
+ return true;
669
+ }
670
+ } while (node = node.nextSibling);
671
+ }
672
+ }
673
+ function Document() {
674
+ this.ownerDocument = this;
675
+ }
676
+ function _onAddAttribute(doc, el, newAttr) {
677
+ doc && doc._inc++;
678
+ var ns = newAttr.namespaceURI;
679
+ if (ns === NAMESPACE.XMLNS) {
680
+ el._nsMap[newAttr.prefix ? newAttr.localName : ""] = newAttr.value;
681
+ }
682
+ }
683
+ function _onRemoveAttribute(doc, el, newAttr, remove) {
684
+ doc && doc._inc++;
685
+ var ns = newAttr.namespaceURI;
686
+ if (ns === NAMESPACE.XMLNS) {
687
+ delete el._nsMap[newAttr.prefix ? newAttr.localName : ""];
688
+ }
689
+ }
690
+ function _onUpdateChild(doc, el, newChild) {
691
+ if (doc && doc._inc) {
692
+ doc._inc++;
693
+ var cs = el.childNodes;
694
+ if (newChild) {
695
+ cs[cs.length++] = newChild;
696
+ } else {
697
+ var child = el.firstChild;
698
+ var i = 0;
699
+ while (child) {
700
+ cs[i++] = child;
701
+ child = child.nextSibling;
702
+ }
703
+ cs.length = i;
704
+ delete cs[cs.length];
705
+ }
706
+ }
707
+ }
708
+ function _removeChild(parentNode, child) {
709
+ var previous = child.previousSibling;
710
+ var next = child.nextSibling;
711
+ if (previous) {
712
+ previous.nextSibling = next;
713
+ } else {
714
+ parentNode.firstChild = next;
715
+ }
716
+ if (next) {
717
+ next.previousSibling = previous;
718
+ } else {
719
+ parentNode.lastChild = previous;
720
+ }
721
+ child.parentNode = null;
722
+ child.previousSibling = null;
723
+ child.nextSibling = null;
724
+ _onUpdateChild(parentNode.ownerDocument, parentNode);
725
+ return child;
726
+ }
727
+ function hasValidParentNodeType(node) {
728
+ return node && (node.nodeType === Node.DOCUMENT_NODE || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE || node.nodeType === Node.ELEMENT_NODE);
729
+ }
730
+ function hasInsertableNodeType(node) {
731
+ return node && (isElementNode(node) || isTextNode(node) || isDocTypeNode(node) || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE || node.nodeType === Node.COMMENT_NODE || node.nodeType === Node.PROCESSING_INSTRUCTION_NODE);
732
+ }
733
+ function isDocTypeNode(node) {
734
+ return node && node.nodeType === Node.DOCUMENT_TYPE_NODE;
735
+ }
736
+ function isElementNode(node) {
737
+ return node && node.nodeType === Node.ELEMENT_NODE;
738
+ }
739
+ function isTextNode(node) {
740
+ return node && node.nodeType === Node.TEXT_NODE;
741
+ }
742
+ function isElementInsertionPossible(doc, child) {
743
+ var parentChildNodes = doc.childNodes || [];
744
+ if (find(parentChildNodes, isElementNode) || isDocTypeNode(child)) {
745
+ return false;
746
+ }
747
+ var docTypeNode = find(parentChildNodes, isDocTypeNode);
748
+ return !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));
749
+ }
750
+ function isElementReplacementPossible(doc, child) {
751
+ var parentChildNodes = doc.childNodes || [];
752
+ function hasElementChildThatIsNotChild(node) {
753
+ return isElementNode(node) && node !== child;
754
+ }
755
+ if (find(parentChildNodes, hasElementChildThatIsNotChild)) {
756
+ return false;
757
+ }
758
+ var docTypeNode = find(parentChildNodes, isDocTypeNode);
759
+ return !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));
760
+ }
761
+ function assertPreInsertionValidity1to5(parent, node, child) {
762
+ if (!hasValidParentNodeType(parent)) {
763
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Unexpected parent node type " + parent.nodeType);
764
+ }
765
+ if (child && child.parentNode !== parent) {
766
+ throw new DOMException(NOT_FOUND_ERR, "child not in parent");
767
+ }
768
+ if (
769
+ // 4. If `node` is not a DocumentFragment, DocumentType, Element, or CharacterData node, then throw a "HierarchyRequestError" DOMException.
770
+ !hasInsertableNodeType(node) || // 5. If either `node` is a Text node and `parent` is a document,
771
+ // the sax parser currently adds top level text nodes, this will be fixed in 0.9.0
772
+ // || (node.nodeType === Node.TEXT_NODE && parent.nodeType === Node.DOCUMENT_NODE)
773
+ // or `node` is a doctype and `parent` is not a document, then throw a "HierarchyRequestError" DOMException.
774
+ isDocTypeNode(node) && parent.nodeType !== Node.DOCUMENT_NODE
775
+ ) {
776
+ throw new DOMException(
777
+ HIERARCHY_REQUEST_ERR,
778
+ "Unexpected node type " + node.nodeType + " for parent node type " + parent.nodeType
779
+ );
780
+ }
781
+ }
782
+ function assertPreInsertionValidityInDocument(parent, node, child) {
783
+ var parentChildNodes = parent.childNodes || [];
784
+ var nodeChildNodes = node.childNodes || [];
785
+ if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
786
+ var nodeChildElements = nodeChildNodes.filter(isElementNode);
787
+ if (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {
788
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "More than one element or text in fragment");
789
+ }
790
+ if (nodeChildElements.length === 1 && !isElementInsertionPossible(parent, child)) {
791
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Element in fragment can not be inserted before doctype");
792
+ }
793
+ }
794
+ if (isElementNode(node)) {
795
+ if (!isElementInsertionPossible(parent, child)) {
796
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Only one element can be added and only after doctype");
797
+ }
798
+ }
799
+ if (isDocTypeNode(node)) {
800
+ if (find(parentChildNodes, isDocTypeNode)) {
801
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Only one doctype is allowed");
802
+ }
803
+ var parentElementChild = find(parentChildNodes, isElementNode);
804
+ if (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {
805
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Doctype can only be inserted before an element");
806
+ }
807
+ if (!child && parentElementChild) {
808
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Doctype can not be appended since element is present");
809
+ }
810
+ }
811
+ }
812
+ function assertPreReplacementValidityInDocument(parent, node, child) {
813
+ var parentChildNodes = parent.childNodes || [];
814
+ var nodeChildNodes = node.childNodes || [];
815
+ if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
816
+ var nodeChildElements = nodeChildNodes.filter(isElementNode);
817
+ if (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {
818
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "More than one element or text in fragment");
819
+ }
820
+ if (nodeChildElements.length === 1 && !isElementReplacementPossible(parent, child)) {
821
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Element in fragment can not be inserted before doctype");
822
+ }
823
+ }
824
+ if (isElementNode(node)) {
825
+ if (!isElementReplacementPossible(parent, child)) {
826
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Only one element can be added and only after doctype");
827
+ }
828
+ }
829
+ if (isDocTypeNode(node)) {
830
+ let hasDoctypeChildThatIsNotChild2 = function(node2) {
831
+ return isDocTypeNode(node2) && node2 !== child;
832
+ };
833
+ var hasDoctypeChildThatIsNotChild = hasDoctypeChildThatIsNotChild2;
834
+ if (find(parentChildNodes, hasDoctypeChildThatIsNotChild2)) {
835
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Only one doctype is allowed");
836
+ }
837
+ var parentElementChild = find(parentChildNodes, isElementNode);
838
+ if (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {
839
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Doctype can only be inserted before an element");
840
+ }
841
+ }
842
+ }
843
+ function _insertBefore(parent, node, child, _inDocumentAssertion) {
844
+ assertPreInsertionValidity1to5(parent, node, child);
845
+ if (parent.nodeType === Node.DOCUMENT_NODE) {
846
+ (_inDocumentAssertion || assertPreInsertionValidityInDocument)(parent, node, child);
847
+ }
848
+ var cp = node.parentNode;
849
+ if (cp) {
850
+ cp.removeChild(node);
851
+ }
852
+ if (node.nodeType === DOCUMENT_FRAGMENT_NODE) {
853
+ var newFirst = node.firstChild;
854
+ if (newFirst == null) {
855
+ return node;
856
+ }
857
+ var newLast = node.lastChild;
858
+ } else {
859
+ newFirst = newLast = node;
860
+ }
861
+ var pre = child ? child.previousSibling : parent.lastChild;
862
+ newFirst.previousSibling = pre;
863
+ newLast.nextSibling = child;
864
+ if (pre) {
865
+ pre.nextSibling = newFirst;
866
+ } else {
867
+ parent.firstChild = newFirst;
868
+ }
869
+ if (child == null) {
870
+ parent.lastChild = newLast;
871
+ } else {
872
+ child.previousSibling = newLast;
873
+ }
874
+ do {
875
+ newFirst.parentNode = parent;
876
+ } while (newFirst !== newLast && (newFirst = newFirst.nextSibling));
877
+ _onUpdateChild(parent.ownerDocument || parent, parent);
878
+ if (node.nodeType == DOCUMENT_FRAGMENT_NODE) {
879
+ node.firstChild = node.lastChild = null;
880
+ }
881
+ return node;
882
+ }
883
+ function _appendSingleChild(parentNode, newChild) {
884
+ if (newChild.parentNode) {
885
+ newChild.parentNode.removeChild(newChild);
886
+ }
887
+ newChild.parentNode = parentNode;
888
+ newChild.previousSibling = parentNode.lastChild;
889
+ newChild.nextSibling = null;
890
+ if (newChild.previousSibling) {
891
+ newChild.previousSibling.nextSibling = newChild;
892
+ } else {
893
+ parentNode.firstChild = newChild;
894
+ }
895
+ parentNode.lastChild = newChild;
896
+ _onUpdateChild(parentNode.ownerDocument, parentNode, newChild);
897
+ return newChild;
898
+ }
899
+ Document.prototype = {
900
+ //implementation : null,
901
+ nodeName: "#document",
902
+ nodeType: DOCUMENT_NODE,
903
+ /**
904
+ * The DocumentType node of the document.
905
+ *
906
+ * @readonly
907
+ * @type DocumentType
908
+ */
909
+ doctype: null,
910
+ documentElement: null,
911
+ _inc: 1,
912
+ insertBefore: function(newChild, refChild) {
913
+ if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) {
914
+ var child = newChild.firstChild;
915
+ while (child) {
916
+ var next = child.nextSibling;
917
+ this.insertBefore(child, refChild);
918
+ child = next;
919
+ }
920
+ return newChild;
921
+ }
922
+ _insertBefore(this, newChild, refChild);
923
+ newChild.ownerDocument = this;
924
+ if (this.documentElement === null && newChild.nodeType === ELEMENT_NODE) {
925
+ this.documentElement = newChild;
926
+ }
927
+ return newChild;
928
+ },
929
+ removeChild: function(oldChild) {
930
+ if (this.documentElement == oldChild) {
931
+ this.documentElement = null;
932
+ }
933
+ return _removeChild(this, oldChild);
934
+ },
935
+ replaceChild: function(newChild, oldChild) {
936
+ _insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument);
937
+ newChild.ownerDocument = this;
938
+ if (oldChild) {
939
+ this.removeChild(oldChild);
940
+ }
941
+ if (isElementNode(newChild)) {
942
+ this.documentElement = newChild;
943
+ }
944
+ },
945
+ // Introduced in DOM Level 2:
946
+ importNode: function(importedNode, deep) {
947
+ return importNode(this, importedNode, deep);
948
+ },
949
+ // Introduced in DOM Level 2:
950
+ getElementById: function(id) {
951
+ var rtv = null;
952
+ _visitNode(this.documentElement, function(node) {
953
+ if (node.nodeType == ELEMENT_NODE) {
954
+ if (node.getAttribute("id") == id) {
955
+ rtv = node;
956
+ return true;
957
+ }
958
+ }
959
+ });
960
+ return rtv;
961
+ },
962
+ /**
963
+ * The `getElementsByClassName` method of `Document` interface returns an array-like object
964
+ * of all child elements which have **all** of the given class name(s).
965
+ *
966
+ * Returns an empty list if `classeNames` is an empty string or only contains HTML white space characters.
967
+ *
968
+ *
969
+ * Warning: This is a live LiveNodeList.
970
+ * Changes in the DOM will reflect in the array as the changes occur.
971
+ * If an element selected by this array no longer qualifies for the selector,
972
+ * it will automatically be removed. Be aware of this for iteration purposes.
973
+ *
974
+ * @param {string} classNames is a string representing the class name(s) to match; multiple class names are separated by (ASCII-)whitespace
975
+ *
976
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName
977
+ * @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname
978
+ */
979
+ getElementsByClassName: function(classNames) {
980
+ var classNamesSet = toOrderedSet(classNames);
981
+ return new LiveNodeList(this, function(base) {
982
+ var ls = [];
983
+ if (classNamesSet.length > 0) {
984
+ _visitNode(base.documentElement, function(node) {
985
+ if (node !== base && node.nodeType === ELEMENT_NODE) {
986
+ var nodeClassNames = node.getAttribute("class");
987
+ if (nodeClassNames) {
988
+ var matches = classNames === nodeClassNames;
989
+ if (!matches) {
990
+ var nodeClassNamesSet = toOrderedSet(nodeClassNames);
991
+ matches = classNamesSet.every(arrayIncludes(nodeClassNamesSet));
992
+ }
993
+ if (matches) {
994
+ ls.push(node);
995
+ }
996
+ }
997
+ }
998
+ });
999
+ }
1000
+ return ls;
1001
+ });
1002
+ },
1003
+ //document factory method:
1004
+ createElement: function(tagName) {
1005
+ var node = new Element();
1006
+ node.ownerDocument = this;
1007
+ node.nodeName = tagName;
1008
+ node.tagName = tagName;
1009
+ node.localName = tagName;
1010
+ node.childNodes = new NodeList();
1011
+ var attrs = node.attributes = new NamedNodeMap();
1012
+ attrs._ownerElement = node;
1013
+ return node;
1014
+ },
1015
+ createDocumentFragment: function() {
1016
+ var node = new DocumentFragment();
1017
+ node.ownerDocument = this;
1018
+ node.childNodes = new NodeList();
1019
+ return node;
1020
+ },
1021
+ createTextNode: function(data) {
1022
+ var node = new Text();
1023
+ node.ownerDocument = this;
1024
+ node.appendData(data);
1025
+ return node;
1026
+ },
1027
+ createComment: function(data) {
1028
+ var node = new Comment();
1029
+ node.ownerDocument = this;
1030
+ node.appendData(data);
1031
+ return node;
1032
+ },
1033
+ createCDATASection: function(data) {
1034
+ var node = new CDATASection();
1035
+ node.ownerDocument = this;
1036
+ node.appendData(data);
1037
+ return node;
1038
+ },
1039
+ createProcessingInstruction: function(target, data) {
1040
+ var node = new ProcessingInstruction();
1041
+ node.ownerDocument = this;
1042
+ node.tagName = node.target = target;
1043
+ node.nodeValue = node.data = data;
1044
+ return node;
1045
+ },
1046
+ createAttribute: function(name) {
1047
+ var node = new Attr();
1048
+ node.ownerDocument = this;
1049
+ node.name = name;
1050
+ node.nodeName = name;
1051
+ node.localName = name;
1052
+ node.specified = true;
1053
+ return node;
1054
+ },
1055
+ createEntityReference: function(name) {
1056
+ var node = new EntityReference();
1057
+ node.ownerDocument = this;
1058
+ node.nodeName = name;
1059
+ return node;
1060
+ },
1061
+ // Introduced in DOM Level 2:
1062
+ createElementNS: function(namespaceURI, qualifiedName) {
1063
+ var node = new Element();
1064
+ var pl = qualifiedName.split(":");
1065
+ var attrs = node.attributes = new NamedNodeMap();
1066
+ node.childNodes = new NodeList();
1067
+ node.ownerDocument = this;
1068
+ node.nodeName = qualifiedName;
1069
+ node.tagName = qualifiedName;
1070
+ node.namespaceURI = namespaceURI;
1071
+ if (pl.length == 2) {
1072
+ node.prefix = pl[0];
1073
+ node.localName = pl[1];
1074
+ } else {
1075
+ node.localName = qualifiedName;
1076
+ }
1077
+ attrs._ownerElement = node;
1078
+ return node;
1079
+ },
1080
+ // Introduced in DOM Level 2:
1081
+ createAttributeNS: function(namespaceURI, qualifiedName) {
1082
+ var node = new Attr();
1083
+ var pl = qualifiedName.split(":");
1084
+ node.ownerDocument = this;
1085
+ node.nodeName = qualifiedName;
1086
+ node.name = qualifiedName;
1087
+ node.namespaceURI = namespaceURI;
1088
+ node.specified = true;
1089
+ if (pl.length == 2) {
1090
+ node.prefix = pl[0];
1091
+ node.localName = pl[1];
1092
+ } else {
1093
+ node.localName = qualifiedName;
1094
+ }
1095
+ return node;
1096
+ }
1097
+ };
1098
+ _extends(Document, Node);
1099
+ function Element() {
1100
+ this._nsMap = {};
1101
+ }
1102
+ Element.prototype = {
1103
+ nodeType: ELEMENT_NODE,
1104
+ hasAttribute: function(name) {
1105
+ return this.getAttributeNode(name) != null;
1106
+ },
1107
+ getAttribute: function(name) {
1108
+ var attr = this.getAttributeNode(name);
1109
+ return attr && attr.value || "";
1110
+ },
1111
+ getAttributeNode: function(name) {
1112
+ return this.attributes.getNamedItem(name);
1113
+ },
1114
+ setAttribute: function(name, value) {
1115
+ var attr = this.ownerDocument.createAttribute(name);
1116
+ attr.value = attr.nodeValue = "" + value;
1117
+ this.setAttributeNode(attr);
1118
+ },
1119
+ removeAttribute: function(name) {
1120
+ var attr = this.getAttributeNode(name);
1121
+ attr && this.removeAttributeNode(attr);
1122
+ },
1123
+ //four real opeartion method
1124
+ appendChild: function(newChild) {
1125
+ if (newChild.nodeType === DOCUMENT_FRAGMENT_NODE) {
1126
+ return this.insertBefore(newChild, null);
1127
+ } else {
1128
+ return _appendSingleChild(this, newChild);
1129
+ }
1130
+ },
1131
+ setAttributeNode: function(newAttr) {
1132
+ return this.attributes.setNamedItem(newAttr);
1133
+ },
1134
+ setAttributeNodeNS: function(newAttr) {
1135
+ return this.attributes.setNamedItemNS(newAttr);
1136
+ },
1137
+ removeAttributeNode: function(oldAttr) {
1138
+ return this.attributes.removeNamedItem(oldAttr.nodeName);
1139
+ },
1140
+ //get real attribute name,and remove it by removeAttributeNode
1141
+ removeAttributeNS: function(namespaceURI, localName) {
1142
+ var old = this.getAttributeNodeNS(namespaceURI, localName);
1143
+ old && this.removeAttributeNode(old);
1144
+ },
1145
+ hasAttributeNS: function(namespaceURI, localName) {
1146
+ return this.getAttributeNodeNS(namespaceURI, localName) != null;
1147
+ },
1148
+ getAttributeNS: function(namespaceURI, localName) {
1149
+ var attr = this.getAttributeNodeNS(namespaceURI, localName);
1150
+ return attr && attr.value || "";
1151
+ },
1152
+ setAttributeNS: function(namespaceURI, qualifiedName, value) {
1153
+ var attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);
1154
+ attr.value = attr.nodeValue = "" + value;
1155
+ this.setAttributeNode(attr);
1156
+ },
1157
+ getAttributeNodeNS: function(namespaceURI, localName) {
1158
+ return this.attributes.getNamedItemNS(namespaceURI, localName);
1159
+ },
1160
+ getElementsByTagName: function(tagName) {
1161
+ return new LiveNodeList(this, function(base) {
1162
+ var ls = [];
1163
+ _visitNode(base, function(node) {
1164
+ if (node !== base && node.nodeType == ELEMENT_NODE && (tagName === "*" || node.tagName == tagName)) {
1165
+ ls.push(node);
1166
+ }
1167
+ });
1168
+ return ls;
1169
+ });
1170
+ },
1171
+ getElementsByTagNameNS: function(namespaceURI, localName) {
1172
+ return new LiveNodeList(this, function(base) {
1173
+ var ls = [];
1174
+ _visitNode(base, function(node) {
1175
+ if (node !== base && node.nodeType === ELEMENT_NODE && (namespaceURI === "*" || node.namespaceURI === namespaceURI) && (localName === "*" || node.localName == localName)) {
1176
+ ls.push(node);
1177
+ }
1178
+ });
1179
+ return ls;
1180
+ });
1181
+ }
1182
+ };
1183
+ Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName;
1184
+ Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS;
1185
+ _extends(Element, Node);
1186
+ function Attr() {
1187
+ }
1188
+ Attr.prototype.nodeType = ATTRIBUTE_NODE;
1189
+ _extends(Attr, Node);
1190
+ function CharacterData() {
1191
+ }
1192
+ CharacterData.prototype = {
1193
+ data: "",
1194
+ substringData: function(offset, count) {
1195
+ return this.data.substring(offset, offset + count);
1196
+ },
1197
+ appendData: function(text) {
1198
+ text = this.data + text;
1199
+ this.nodeValue = this.data = text;
1200
+ this.length = text.length;
1201
+ },
1202
+ insertData: function(offset, text) {
1203
+ this.replaceData(offset, 0, text);
1204
+ },
1205
+ appendChild: function(newChild) {
1206
+ throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR]);
1207
+ },
1208
+ deleteData: function(offset, count) {
1209
+ this.replaceData(offset, count, "");
1210
+ },
1211
+ replaceData: function(offset, count, text) {
1212
+ var start = this.data.substring(0, offset);
1213
+ var end = this.data.substring(offset + count);
1214
+ text = start + text + end;
1215
+ this.nodeValue = this.data = text;
1216
+ this.length = text.length;
1217
+ }
1218
+ };
1219
+ _extends(CharacterData, Node);
1220
+ function Text() {
1221
+ }
1222
+ Text.prototype = {
1223
+ nodeName: "#text",
1224
+ nodeType: TEXT_NODE,
1225
+ splitText: function(offset) {
1226
+ var text = this.data;
1227
+ var newText = text.substring(offset);
1228
+ text = text.substring(0, offset);
1229
+ this.data = this.nodeValue = text;
1230
+ this.length = text.length;
1231
+ var newNode = this.ownerDocument.createTextNode(newText);
1232
+ if (this.parentNode) {
1233
+ this.parentNode.insertBefore(newNode, this.nextSibling);
1234
+ }
1235
+ return newNode;
1236
+ }
1237
+ };
1238
+ _extends(Text, CharacterData);
1239
+ function Comment() {
1240
+ }
1241
+ Comment.prototype = {
1242
+ nodeName: "#comment",
1243
+ nodeType: COMMENT_NODE
1244
+ };
1245
+ _extends(Comment, CharacterData);
1246
+ function CDATASection() {
1247
+ }
1248
+ CDATASection.prototype = {
1249
+ nodeName: "#cdata-section",
1250
+ nodeType: CDATA_SECTION_NODE
1251
+ };
1252
+ _extends(CDATASection, CharacterData);
1253
+ function DocumentType() {
1254
+ }
1255
+ DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
1256
+ _extends(DocumentType, Node);
1257
+ function Notation() {
1258
+ }
1259
+ Notation.prototype.nodeType = NOTATION_NODE;
1260
+ _extends(Notation, Node);
1261
+ function Entity() {
1262
+ }
1263
+ Entity.prototype.nodeType = ENTITY_NODE;
1264
+ _extends(Entity, Node);
1265
+ function EntityReference() {
1266
+ }
1267
+ EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
1268
+ _extends(EntityReference, Node);
1269
+ function DocumentFragment() {
1270
+ }
1271
+ DocumentFragment.prototype.nodeName = "#document-fragment";
1272
+ DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE;
1273
+ _extends(DocumentFragment, Node);
1274
+ function ProcessingInstruction() {
1275
+ }
1276
+ ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
1277
+ _extends(ProcessingInstruction, Node);
1278
+ function XMLSerializer() {
1279
+ }
1280
+ XMLSerializer.prototype.serializeToString = function(node, isHtml, nodeFilter) {
1281
+ return nodeSerializeToString.call(node, isHtml, nodeFilter);
1282
+ };
1283
+ Node.prototype.toString = nodeSerializeToString;
1284
+ function nodeSerializeToString(isHtml, nodeFilter) {
1285
+ var buf = [];
1286
+ var refNode = this.nodeType == 9 && this.documentElement || this;
1287
+ var prefix = refNode.prefix;
1288
+ var uri = refNode.namespaceURI;
1289
+ if (uri && prefix == null) {
1290
+ var prefix = refNode.lookupPrefix(uri);
1291
+ if (prefix == null) {
1292
+ var visibleNamespaces = [
1293
+ { namespace: uri, prefix: null }
1294
+ //{namespace:uri,prefix:''}
1295
+ ];
1296
+ }
1297
+ }
1298
+ serializeToString(this, buf, isHtml, nodeFilter, visibleNamespaces);
1299
+ return buf.join("");
1300
+ }
1301
+ function needNamespaceDefine(node, isHTML, visibleNamespaces) {
1302
+ var prefix = node.prefix || "";
1303
+ var uri = node.namespaceURI;
1304
+ if (!uri) {
1305
+ return false;
1306
+ }
1307
+ if (prefix === "xml" && uri === NAMESPACE.XML || uri === NAMESPACE.XMLNS) {
1308
+ return false;
1309
+ }
1310
+ var i = visibleNamespaces.length;
1311
+ while (i--) {
1312
+ var ns = visibleNamespaces[i];
1313
+ if (ns.prefix === prefix) {
1314
+ return ns.namespace !== uri;
1315
+ }
1316
+ }
1317
+ return true;
1318
+ }
1319
+ function addSerializedAttribute(buf, qualifiedName, value) {
1320
+ buf.push(" ", qualifiedName, '="', value.replace(/[<>&"\t\n\r]/g, _xmlEncoder), '"');
1321
+ }
1322
+ function serializeToString(node, buf, isHTML, nodeFilter, visibleNamespaces) {
1323
+ if (!visibleNamespaces) {
1324
+ visibleNamespaces = [];
1325
+ }
1326
+ if (nodeFilter) {
1327
+ node = nodeFilter(node);
1328
+ if (node) {
1329
+ if (typeof node == "string") {
1330
+ buf.push(node);
1331
+ return;
1332
+ }
1333
+ } else {
1334
+ return;
1335
+ }
1336
+ }
1337
+ switch (node.nodeType) {
1338
+ case ELEMENT_NODE:
1339
+ var attrs = node.attributes;
1340
+ var len = attrs.length;
1341
+ var child = node.firstChild;
1342
+ var nodeName = node.tagName;
1343
+ isHTML = NAMESPACE.isHTML(node.namespaceURI) || isHTML;
1344
+ var prefixedNodeName = nodeName;
1345
+ if (!isHTML && !node.prefix && node.namespaceURI) {
1346
+ var defaultNS;
1347
+ for (var ai = 0; ai < attrs.length; ai++) {
1348
+ if (attrs.item(ai).name === "xmlns") {
1349
+ defaultNS = attrs.item(ai).value;
1350
+ break;
1351
+ }
1352
+ }
1353
+ if (!defaultNS) {
1354
+ for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
1355
+ var namespace = visibleNamespaces[nsi];
1356
+ if (namespace.prefix === "" && namespace.namespace === node.namespaceURI) {
1357
+ defaultNS = namespace.namespace;
1358
+ break;
1359
+ }
1360
+ }
1361
+ }
1362
+ if (defaultNS !== node.namespaceURI) {
1363
+ for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
1364
+ var namespace = visibleNamespaces[nsi];
1365
+ if (namespace.namespace === node.namespaceURI) {
1366
+ if (namespace.prefix) {
1367
+ prefixedNodeName = namespace.prefix + ":" + nodeName;
1368
+ }
1369
+ break;
1370
+ }
1371
+ }
1372
+ }
1373
+ }
1374
+ buf.push("<", prefixedNodeName);
1375
+ for (var i = 0; i < len; i++) {
1376
+ var attr = attrs.item(i);
1377
+ if (attr.prefix == "xmlns") {
1378
+ visibleNamespaces.push({ prefix: attr.localName, namespace: attr.value });
1379
+ } else if (attr.nodeName == "xmlns") {
1380
+ visibleNamespaces.push({ prefix: "", namespace: attr.value });
1381
+ }
1382
+ }
1383
+ for (var i = 0; i < len; i++) {
1384
+ var attr = attrs.item(i);
1385
+ if (needNamespaceDefine(attr, isHTML, visibleNamespaces)) {
1386
+ var prefix = attr.prefix || "";
1387
+ var uri = attr.namespaceURI;
1388
+ addSerializedAttribute(buf, prefix ? "xmlns:" + prefix : "xmlns", uri);
1389
+ visibleNamespaces.push({ prefix, namespace: uri });
1390
+ }
1391
+ serializeToString(attr, buf, isHTML, nodeFilter, visibleNamespaces);
1392
+ }
1393
+ if (nodeName === prefixedNodeName && needNamespaceDefine(node, isHTML, visibleNamespaces)) {
1394
+ var prefix = node.prefix || "";
1395
+ var uri = node.namespaceURI;
1396
+ addSerializedAttribute(buf, prefix ? "xmlns:" + prefix : "xmlns", uri);
1397
+ visibleNamespaces.push({ prefix, namespace: uri });
1398
+ }
1399
+ if (child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)) {
1400
+ buf.push(">");
1401
+ if (isHTML && /^script$/i.test(nodeName)) {
1402
+ while (child) {
1403
+ if (child.data) {
1404
+ buf.push(child.data);
1405
+ } else {
1406
+ serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
1407
+ }
1408
+ child = child.nextSibling;
1409
+ }
1410
+ } else {
1411
+ while (child) {
1412
+ serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
1413
+ child = child.nextSibling;
1414
+ }
1415
+ }
1416
+ buf.push("</", prefixedNodeName, ">");
1417
+ } else {
1418
+ buf.push("/>");
1419
+ }
1420
+ return;
1421
+ case DOCUMENT_NODE:
1422
+ case DOCUMENT_FRAGMENT_NODE:
1423
+ var child = node.firstChild;
1424
+ while (child) {
1425
+ serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
1426
+ child = child.nextSibling;
1427
+ }
1428
+ return;
1429
+ case ATTRIBUTE_NODE:
1430
+ return addSerializedAttribute(buf, node.name, node.value);
1431
+ case TEXT_NODE:
1432
+ return buf.push(
1433
+ node.data.replace(/[<&>]/g, _xmlEncoder)
1434
+ );
1435
+ case CDATA_SECTION_NODE:
1436
+ return buf.push("<![CDATA[", node.data, "]]>");
1437
+ case COMMENT_NODE:
1438
+ return buf.push("<!--", node.data, "-->");
1439
+ case DOCUMENT_TYPE_NODE:
1440
+ var pubid = node.publicId;
1441
+ var sysid = node.systemId;
1442
+ buf.push("<!DOCTYPE ", node.name);
1443
+ if (pubid) {
1444
+ buf.push(" PUBLIC ", pubid);
1445
+ if (sysid && sysid != ".") {
1446
+ buf.push(" ", sysid);
1447
+ }
1448
+ buf.push(">");
1449
+ } else if (sysid && sysid != ".") {
1450
+ buf.push(" SYSTEM ", sysid, ">");
1451
+ } else {
1452
+ var sub = node.internalSubset;
1453
+ if (sub) {
1454
+ buf.push(" [", sub, "]");
1455
+ }
1456
+ buf.push(">");
1457
+ }
1458
+ return;
1459
+ case PROCESSING_INSTRUCTION_NODE:
1460
+ return buf.push("<?", node.target, " ", node.data, "?>");
1461
+ case ENTITY_REFERENCE_NODE:
1462
+ return buf.push("&", node.nodeName, ";");
1463
+ default:
1464
+ buf.push("??", node.nodeName);
1465
+ }
1466
+ }
1467
+ function importNode(doc, node, deep) {
1468
+ var node2;
1469
+ switch (node.nodeType) {
1470
+ case ELEMENT_NODE:
1471
+ node2 = node.cloneNode(false);
1472
+ node2.ownerDocument = doc;
1473
+ case DOCUMENT_FRAGMENT_NODE:
1474
+ break;
1475
+ case ATTRIBUTE_NODE:
1476
+ deep = true;
1477
+ break;
1478
+ }
1479
+ if (!node2) {
1480
+ node2 = node.cloneNode(false);
1481
+ }
1482
+ node2.ownerDocument = doc;
1483
+ node2.parentNode = null;
1484
+ if (deep) {
1485
+ var child = node.firstChild;
1486
+ while (child) {
1487
+ node2.appendChild(importNode(doc, child, deep));
1488
+ child = child.nextSibling;
1489
+ }
1490
+ }
1491
+ return node2;
1492
+ }
1493
+ function cloneNode(doc, node, deep) {
1494
+ var node2 = new node.constructor();
1495
+ for (var n in node) {
1496
+ if (Object.prototype.hasOwnProperty.call(node, n)) {
1497
+ var v = node[n];
1498
+ if (typeof v != "object") {
1499
+ if (v != node2[n]) {
1500
+ node2[n] = v;
1501
+ }
1502
+ }
1503
+ }
1504
+ }
1505
+ if (node.childNodes) {
1506
+ node2.childNodes = new NodeList();
1507
+ }
1508
+ node2.ownerDocument = doc;
1509
+ switch (node2.nodeType) {
1510
+ case ELEMENT_NODE:
1511
+ var attrs = node.attributes;
1512
+ var attrs2 = node2.attributes = new NamedNodeMap();
1513
+ var len = attrs.length;
1514
+ attrs2._ownerElement = node2;
1515
+ for (var i = 0; i < len; i++) {
1516
+ node2.setAttributeNode(cloneNode(doc, attrs.item(i), true));
1517
+ }
1518
+ break;
1519
+ ;
1520
+ case ATTRIBUTE_NODE:
1521
+ deep = true;
1522
+ }
1523
+ if (deep) {
1524
+ var child = node.firstChild;
1525
+ while (child) {
1526
+ node2.appendChild(cloneNode(doc, child, deep));
1527
+ child = child.nextSibling;
1528
+ }
1529
+ }
1530
+ return node2;
1531
+ }
1532
+ function __set__(object, key, value) {
1533
+ object[key] = value;
1534
+ }
1535
+ try {
1536
+ if (Object.defineProperty) {
1537
+ let getTextContent2 = function(node) {
1538
+ switch (node.nodeType) {
1539
+ case ELEMENT_NODE:
1540
+ case DOCUMENT_FRAGMENT_NODE:
1541
+ var buf = [];
1542
+ node = node.firstChild;
1543
+ while (node) {
1544
+ if (node.nodeType !== 7 && node.nodeType !== 8) {
1545
+ buf.push(getTextContent2(node));
1546
+ }
1547
+ node = node.nextSibling;
1548
+ }
1549
+ return buf.join("");
1550
+ default:
1551
+ return node.nodeValue;
1552
+ }
1553
+ };
1554
+ getTextContent = getTextContent2;
1555
+ Object.defineProperty(LiveNodeList.prototype, "length", {
1556
+ get: function() {
1557
+ _updateLiveList(this);
1558
+ return this.$$length;
1559
+ }
1560
+ });
1561
+ Object.defineProperty(Node.prototype, "textContent", {
1562
+ get: function() {
1563
+ return getTextContent2(this);
1564
+ },
1565
+ set: function(data) {
1566
+ switch (this.nodeType) {
1567
+ case ELEMENT_NODE:
1568
+ case DOCUMENT_FRAGMENT_NODE:
1569
+ while (this.firstChild) {
1570
+ this.removeChild(this.firstChild);
1571
+ }
1572
+ if (data || String(data)) {
1573
+ this.appendChild(this.ownerDocument.createTextNode(data));
1574
+ }
1575
+ break;
1576
+ default:
1577
+ this.data = data;
1578
+ this.value = data;
1579
+ this.nodeValue = data;
1580
+ }
1581
+ }
1582
+ });
1583
+ __set__ = function(object, key, value) {
1584
+ object["$$" + key] = value;
1585
+ };
1586
+ }
1587
+ } catch (e) {
1588
+ }
1589
+ var getTextContent;
1590
+ exports.DocumentType = DocumentType;
1591
+ exports.DOMException = DOMException;
1592
+ exports.DOMImplementation = DOMImplementation;
1593
+ exports.Element = Element;
1594
+ exports.Node = Node;
1595
+ exports.NodeList = NodeList;
1596
+ exports.XMLSerializer = XMLSerializer;
1597
+ }
1598
+ });
1599
+
1600
+ // node_modules/@xmldom/xmldom/lib/entities.js
1601
+ var require_entities = __commonJS({
1602
+ "node_modules/@xmldom/xmldom/lib/entities.js"(exports) {
1603
+ var freeze = require_conventions().freeze;
1604
+ exports.XML_ENTITIES = freeze({ amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' });
1605
+ exports.HTML_ENTITIES = freeze({
1606
+ lt: "<",
1607
+ gt: ">",
1608
+ amp: "&",
1609
+ quot: '"',
1610
+ apos: "'",
1611
+ Agrave: "\xC0",
1612
+ Aacute: "\xC1",
1613
+ Acirc: "\xC2",
1614
+ Atilde: "\xC3",
1615
+ Auml: "\xC4",
1616
+ Aring: "\xC5",
1617
+ AElig: "\xC6",
1618
+ Ccedil: "\xC7",
1619
+ Egrave: "\xC8",
1620
+ Eacute: "\xC9",
1621
+ Ecirc: "\xCA",
1622
+ Euml: "\xCB",
1623
+ Igrave: "\xCC",
1624
+ Iacute: "\xCD",
1625
+ Icirc: "\xCE",
1626
+ Iuml: "\xCF",
1627
+ ETH: "\xD0",
1628
+ Ntilde: "\xD1",
1629
+ Ograve: "\xD2",
1630
+ Oacute: "\xD3",
1631
+ Ocirc: "\xD4",
1632
+ Otilde: "\xD5",
1633
+ Ouml: "\xD6",
1634
+ Oslash: "\xD8",
1635
+ Ugrave: "\xD9",
1636
+ Uacute: "\xDA",
1637
+ Ucirc: "\xDB",
1638
+ Uuml: "\xDC",
1639
+ Yacute: "\xDD",
1640
+ THORN: "\xDE",
1641
+ szlig: "\xDF",
1642
+ agrave: "\xE0",
1643
+ aacute: "\xE1",
1644
+ acirc: "\xE2",
1645
+ atilde: "\xE3",
1646
+ auml: "\xE4",
1647
+ aring: "\xE5",
1648
+ aelig: "\xE6",
1649
+ ccedil: "\xE7",
1650
+ egrave: "\xE8",
1651
+ eacute: "\xE9",
1652
+ ecirc: "\xEA",
1653
+ euml: "\xEB",
1654
+ igrave: "\xEC",
1655
+ iacute: "\xED",
1656
+ icirc: "\xEE",
1657
+ iuml: "\xEF",
1658
+ eth: "\xF0",
1659
+ ntilde: "\xF1",
1660
+ ograve: "\xF2",
1661
+ oacute: "\xF3",
1662
+ ocirc: "\xF4",
1663
+ otilde: "\xF5",
1664
+ ouml: "\xF6",
1665
+ oslash: "\xF8",
1666
+ ugrave: "\xF9",
1667
+ uacute: "\xFA",
1668
+ ucirc: "\xFB",
1669
+ uuml: "\xFC",
1670
+ yacute: "\xFD",
1671
+ thorn: "\xFE",
1672
+ yuml: "\xFF",
1673
+ nbsp: "\xA0",
1674
+ iexcl: "\xA1",
1675
+ cent: "\xA2",
1676
+ pound: "\xA3",
1677
+ curren: "\xA4",
1678
+ yen: "\xA5",
1679
+ brvbar: "\xA6",
1680
+ sect: "\xA7",
1681
+ uml: "\xA8",
1682
+ copy: "\xA9",
1683
+ ordf: "\xAA",
1684
+ laquo: "\xAB",
1685
+ not: "\xAC",
1686
+ shy: "\xAD\xAD",
1687
+ reg: "\xAE",
1688
+ macr: "\xAF",
1689
+ deg: "\xB0",
1690
+ plusmn: "\xB1",
1691
+ sup2: "\xB2",
1692
+ sup3: "\xB3",
1693
+ acute: "\xB4",
1694
+ micro: "\xB5",
1695
+ para: "\xB6",
1696
+ middot: "\xB7",
1697
+ cedil: "\xB8",
1698
+ sup1: "\xB9",
1699
+ ordm: "\xBA",
1700
+ raquo: "\xBB",
1701
+ frac14: "\xBC",
1702
+ frac12: "\xBD",
1703
+ frac34: "\xBE",
1704
+ iquest: "\xBF",
1705
+ times: "\xD7",
1706
+ divide: "\xF7",
1707
+ forall: "\u2200",
1708
+ part: "\u2202",
1709
+ exist: "\u2203",
1710
+ empty: "\u2205",
1711
+ nabla: "\u2207",
1712
+ isin: "\u2208",
1713
+ notin: "\u2209",
1714
+ ni: "\u220B",
1715
+ prod: "\u220F",
1716
+ sum: "\u2211",
1717
+ minus: "\u2212",
1718
+ lowast: "\u2217",
1719
+ radic: "\u221A",
1720
+ prop: "\u221D",
1721
+ infin: "\u221E",
1722
+ ang: "\u2220",
1723
+ and: "\u2227",
1724
+ or: "\u2228",
1725
+ cap: "\u2229",
1726
+ cup: "\u222A",
1727
+ "int": "\u222B",
1728
+ there4: "\u2234",
1729
+ sim: "\u223C",
1730
+ cong: "\u2245",
1731
+ asymp: "\u2248",
1732
+ ne: "\u2260",
1733
+ equiv: "\u2261",
1734
+ le: "\u2264",
1735
+ ge: "\u2265",
1736
+ sub: "\u2282",
1737
+ sup: "\u2283",
1738
+ nsub: "\u2284",
1739
+ sube: "\u2286",
1740
+ supe: "\u2287",
1741
+ oplus: "\u2295",
1742
+ otimes: "\u2297",
1743
+ perp: "\u22A5",
1744
+ sdot: "\u22C5",
1745
+ Alpha: "\u0391",
1746
+ Beta: "\u0392",
1747
+ Gamma: "\u0393",
1748
+ Delta: "\u0394",
1749
+ Epsilon: "\u0395",
1750
+ Zeta: "\u0396",
1751
+ Eta: "\u0397",
1752
+ Theta: "\u0398",
1753
+ Iota: "\u0399",
1754
+ Kappa: "\u039A",
1755
+ Lambda: "\u039B",
1756
+ Mu: "\u039C",
1757
+ Nu: "\u039D",
1758
+ Xi: "\u039E",
1759
+ Omicron: "\u039F",
1760
+ Pi: "\u03A0",
1761
+ Rho: "\u03A1",
1762
+ Sigma: "\u03A3",
1763
+ Tau: "\u03A4",
1764
+ Upsilon: "\u03A5",
1765
+ Phi: "\u03A6",
1766
+ Chi: "\u03A7",
1767
+ Psi: "\u03A8",
1768
+ Omega: "\u03A9",
1769
+ alpha: "\u03B1",
1770
+ beta: "\u03B2",
1771
+ gamma: "\u03B3",
1772
+ delta: "\u03B4",
1773
+ epsilon: "\u03B5",
1774
+ zeta: "\u03B6",
1775
+ eta: "\u03B7",
1776
+ theta: "\u03B8",
1777
+ iota: "\u03B9",
1778
+ kappa: "\u03BA",
1779
+ lambda: "\u03BB",
1780
+ mu: "\u03BC",
1781
+ nu: "\u03BD",
1782
+ xi: "\u03BE",
1783
+ omicron: "\u03BF",
1784
+ pi: "\u03C0",
1785
+ rho: "\u03C1",
1786
+ sigmaf: "\u03C2",
1787
+ sigma: "\u03C3",
1788
+ tau: "\u03C4",
1789
+ upsilon: "\u03C5",
1790
+ phi: "\u03C6",
1791
+ chi: "\u03C7",
1792
+ psi: "\u03C8",
1793
+ omega: "\u03C9",
1794
+ thetasym: "\u03D1",
1795
+ upsih: "\u03D2",
1796
+ piv: "\u03D6",
1797
+ OElig: "\u0152",
1798
+ oelig: "\u0153",
1799
+ Scaron: "\u0160",
1800
+ scaron: "\u0161",
1801
+ Yuml: "\u0178",
1802
+ fnof: "\u0192",
1803
+ circ: "\u02C6",
1804
+ tilde: "\u02DC",
1805
+ ensp: "\u2002",
1806
+ emsp: "\u2003",
1807
+ thinsp: "\u2009",
1808
+ zwnj: "\u200C",
1809
+ zwj: "\u200D",
1810
+ lrm: "\u200E",
1811
+ rlm: "\u200F",
1812
+ ndash: "\u2013",
1813
+ mdash: "\u2014",
1814
+ lsquo: "\u2018",
1815
+ rsquo: "\u2019",
1816
+ sbquo: "\u201A",
1817
+ ldquo: "\u201C",
1818
+ rdquo: "\u201D",
1819
+ bdquo: "\u201E",
1820
+ dagger: "\u2020",
1821
+ Dagger: "\u2021",
1822
+ bull: "\u2022",
1823
+ hellip: "\u2026",
1824
+ permil: "\u2030",
1825
+ prime: "\u2032",
1826
+ Prime: "\u2033",
1827
+ lsaquo: "\u2039",
1828
+ rsaquo: "\u203A",
1829
+ oline: "\u203E",
1830
+ euro: "\u20AC",
1831
+ trade: "\u2122",
1832
+ larr: "\u2190",
1833
+ uarr: "\u2191",
1834
+ rarr: "\u2192",
1835
+ darr: "\u2193",
1836
+ harr: "\u2194",
1837
+ crarr: "\u21B5",
1838
+ lceil: "\u2308",
1839
+ rceil: "\u2309",
1840
+ lfloor: "\u230A",
1841
+ rfloor: "\u230B",
1842
+ loz: "\u25CA",
1843
+ spades: "\u2660",
1844
+ clubs: "\u2663",
1845
+ hearts: "\u2665",
1846
+ diams: "\u2666"
1847
+ });
1848
+ exports.entityMap = exports.HTML_ENTITIES;
1849
+ }
1850
+ });
1851
+
1852
+ // node_modules/@xmldom/xmldom/lib/sax.js
1853
+ var require_sax = __commonJS({
1854
+ "node_modules/@xmldom/xmldom/lib/sax.js"(exports) {
1855
+ var NAMESPACE = require_conventions().NAMESPACE;
1856
+ var nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;
1857
+ var nameChar = new RegExp("[\\-\\.0-9" + nameStartChar.source.slice(1, -1) + "\\u00B7\\u0300-\\u036F\\u203F-\\u2040]");
1858
+ var tagNamePattern = new RegExp("^" + nameStartChar.source + nameChar.source + "*(?::" + nameStartChar.source + nameChar.source + "*)?$");
1859
+ var S_TAG = 0;
1860
+ var S_ATTR = 1;
1861
+ var S_ATTR_SPACE = 2;
1862
+ var S_EQ = 3;
1863
+ var S_ATTR_NOQUOT_VALUE = 4;
1864
+ var S_ATTR_END = 5;
1865
+ var S_TAG_SPACE = 6;
1866
+ var S_TAG_CLOSE = 7;
1867
+ function ParseError(message, locator) {
1868
+ this.message = message;
1869
+ this.locator = locator;
1870
+ if (Error.captureStackTrace)
1871
+ Error.captureStackTrace(this, ParseError);
1872
+ }
1873
+ ParseError.prototype = new Error();
1874
+ ParseError.prototype.name = ParseError.name;
1875
+ function XMLReader() {
1876
+ }
1877
+ XMLReader.prototype = {
1878
+ parse: function(source, defaultNSMap, entityMap) {
1879
+ var domBuilder = this.domBuilder;
1880
+ domBuilder.startDocument();
1881
+ _copy(defaultNSMap, defaultNSMap = {});
1882
+ parse2(
1883
+ source,
1884
+ defaultNSMap,
1885
+ entityMap,
1886
+ domBuilder,
1887
+ this.errorHandler
1888
+ );
1889
+ domBuilder.endDocument();
1890
+ }
1891
+ };
1892
+ function parse2(source, defaultNSMapCopy, entityMap, domBuilder, errorHandler) {
1893
+ function fixedFromCharCode(code) {
1894
+ if (code > 65535) {
1895
+ code -= 65536;
1896
+ var surrogate1 = 55296 + (code >> 10), surrogate2 = 56320 + (code & 1023);
1897
+ return String.fromCharCode(surrogate1, surrogate2);
1898
+ } else {
1899
+ return String.fromCharCode(code);
1900
+ }
1901
+ }
1902
+ function entityReplacer(a2) {
1903
+ var k = a2.slice(1, -1);
1904
+ if (Object.hasOwnProperty.call(entityMap, k)) {
1905
+ return entityMap[k];
1906
+ } else if (k.charAt(0) === "#") {
1907
+ return fixedFromCharCode(parseInt(k.substr(1).replace("x", "0x")));
1908
+ } else {
1909
+ errorHandler.error("entity not found:" + a2);
1910
+ return a2;
1911
+ }
1912
+ }
1913
+ function appendText(end2) {
1914
+ if (end2 > start) {
1915
+ var xt = source.substring(start, end2).replace(/&#?\w+;/g, entityReplacer);
1916
+ locator && position(start);
1917
+ domBuilder.characters(xt, 0, end2 - start);
1918
+ start = end2;
1919
+ }
1920
+ }
1921
+ function position(p, m) {
1922
+ while (p >= lineEnd && (m = linePattern.exec(source))) {
1923
+ lineStart = m.index;
1924
+ lineEnd = lineStart + m[0].length;
1925
+ locator.lineNumber++;
1926
+ }
1927
+ locator.columnNumber = p - lineStart + 1;
1928
+ }
1929
+ var lineStart = 0;
1930
+ var lineEnd = 0;
1931
+ var linePattern = /.*(?:\r\n?|\n)|.*$/g;
1932
+ var locator = domBuilder.locator;
1933
+ var parseStack = [{ currentNSMap: defaultNSMapCopy }];
1934
+ var closeMap = {};
1935
+ var start = 0;
1936
+ while (true) {
1937
+ try {
1938
+ var tagStart = source.indexOf("<", start);
1939
+ if (tagStart < 0) {
1940
+ if (!source.substr(start).match(/^\s*$/)) {
1941
+ var doc = domBuilder.doc;
1942
+ var text = doc.createTextNode(source.substr(start));
1943
+ doc.appendChild(text);
1944
+ domBuilder.currentElement = text;
1945
+ }
1946
+ return;
1947
+ }
1948
+ if (tagStart > start) {
1949
+ appendText(tagStart);
1950
+ }
1951
+ switch (source.charAt(tagStart + 1)) {
1952
+ case "/":
1953
+ var end = source.indexOf(">", tagStart + 3);
1954
+ var tagName = source.substring(tagStart + 2, end).replace(/[ \t\n\r]+$/g, "");
1955
+ var config = parseStack.pop();
1956
+ if (end < 0) {
1957
+ tagName = source.substring(tagStart + 2).replace(/[\s<].*/, "");
1958
+ errorHandler.error("end tag name: " + tagName + " is not complete:" + config.tagName);
1959
+ end = tagStart + 1 + tagName.length;
1960
+ } else if (tagName.match(/\s</)) {
1961
+ tagName = tagName.replace(/[\s<].*/, "");
1962
+ errorHandler.error("end tag name: " + tagName + " maybe not complete");
1963
+ end = tagStart + 1 + tagName.length;
1964
+ }
1965
+ var localNSMap = config.localNSMap;
1966
+ var endMatch = config.tagName == tagName;
1967
+ var endIgnoreCaseMach = endMatch || config.tagName && config.tagName.toLowerCase() == tagName.toLowerCase();
1968
+ if (endIgnoreCaseMach) {
1969
+ domBuilder.endElement(config.uri, config.localName, tagName);
1970
+ if (localNSMap) {
1971
+ for (var prefix in localNSMap) {
1972
+ if (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) {
1973
+ domBuilder.endPrefixMapping(prefix);
1974
+ }
1975
+ }
1976
+ }
1977
+ if (!endMatch) {
1978
+ errorHandler.fatalError("end tag name: " + tagName + " is not match the current start tagName:" + config.tagName);
1979
+ }
1980
+ } else {
1981
+ parseStack.push(config);
1982
+ }
1983
+ end++;
1984
+ break;
1985
+ case "?":
1986
+ locator && position(tagStart);
1987
+ end = parseInstruction(source, tagStart, domBuilder);
1988
+ break;
1989
+ case "!":
1990
+ locator && position(tagStart);
1991
+ end = parseDCC(source, tagStart, domBuilder, errorHandler);
1992
+ break;
1993
+ default:
1994
+ locator && position(tagStart);
1995
+ var el = new ElementAttributes();
1996
+ var currentNSMap = parseStack[parseStack.length - 1].currentNSMap;
1997
+ var end = parseElementStartPart(source, tagStart, el, currentNSMap, entityReplacer, errorHandler);
1998
+ var len = el.length;
1999
+ if (!el.closed && fixSelfClosed(source, end, el.tagName, closeMap)) {
2000
+ el.closed = true;
2001
+ if (!entityMap.nbsp) {
2002
+ errorHandler.warning("unclosed xml attribute");
2003
+ }
2004
+ }
2005
+ if (locator && len) {
2006
+ var locator2 = copyLocator(locator, {});
2007
+ for (var i = 0; i < len; i++) {
2008
+ var a = el[i];
2009
+ position(a.offset);
2010
+ a.locator = copyLocator(locator, {});
2011
+ }
2012
+ domBuilder.locator = locator2;
2013
+ if (appendElement(el, domBuilder, currentNSMap)) {
2014
+ parseStack.push(el);
2015
+ }
2016
+ domBuilder.locator = locator;
2017
+ } else {
2018
+ if (appendElement(el, domBuilder, currentNSMap)) {
2019
+ parseStack.push(el);
2020
+ }
2021
+ }
2022
+ if (NAMESPACE.isHTML(el.uri) && !el.closed) {
2023
+ end = parseHtmlSpecialContent(source, end, el.tagName, entityReplacer, domBuilder);
2024
+ } else {
2025
+ end++;
2026
+ }
2027
+ }
2028
+ } catch (e) {
2029
+ if (e instanceof ParseError) {
2030
+ throw e;
2031
+ }
2032
+ errorHandler.error("element parse error: " + e);
2033
+ end = -1;
2034
+ }
2035
+ if (end > start) {
2036
+ start = end;
2037
+ } else {
2038
+ appendText(Math.max(tagStart, start) + 1);
2039
+ }
2040
+ }
2041
+ }
2042
+ function copyLocator(f, t) {
2043
+ t.lineNumber = f.lineNumber;
2044
+ t.columnNumber = f.columnNumber;
2045
+ return t;
2046
+ }
2047
+ function parseElementStartPart(source, start, el, currentNSMap, entityReplacer, errorHandler) {
2048
+ function addAttribute(qname, value2, startIndex) {
2049
+ if (el.attributeNames.hasOwnProperty(qname)) {
2050
+ errorHandler.fatalError("Attribute " + qname + " redefined");
2051
+ }
2052
+ el.addValue(
2053
+ qname,
2054
+ // @see https://www.w3.org/TR/xml/#AVNormalize
2055
+ // since the xmldom sax parser does not "interpret" DTD the following is not implemented:
2056
+ // - recursive replacement of (DTD) entity references
2057
+ // - trimming and collapsing multiple spaces into a single one for attributes that are not of type CDATA
2058
+ value2.replace(/[\t\n\r]/g, " ").replace(/&#?\w+;/g, entityReplacer),
2059
+ startIndex
2060
+ );
2061
+ }
2062
+ var attrName;
2063
+ var value;
2064
+ var p = ++start;
2065
+ var s = S_TAG;
2066
+ while (true) {
2067
+ var c = source.charAt(p);
2068
+ switch (c) {
2069
+ case "=":
2070
+ if (s === S_ATTR) {
2071
+ attrName = source.slice(start, p);
2072
+ s = S_EQ;
2073
+ } else if (s === S_ATTR_SPACE) {
2074
+ s = S_EQ;
2075
+ } else {
2076
+ throw new Error("attribute equal must after attrName");
2077
+ }
2078
+ break;
2079
+ case "'":
2080
+ case '"':
2081
+ if (s === S_EQ || s === S_ATTR) {
2082
+ if (s === S_ATTR) {
2083
+ errorHandler.warning('attribute value must after "="');
2084
+ attrName = source.slice(start, p);
2085
+ }
2086
+ start = p + 1;
2087
+ p = source.indexOf(c, start);
2088
+ if (p > 0) {
2089
+ value = source.slice(start, p);
2090
+ addAttribute(attrName, value, start - 1);
2091
+ s = S_ATTR_END;
2092
+ } else {
2093
+ throw new Error("attribute value no end '" + c + "' match");
2094
+ }
2095
+ } else if (s == S_ATTR_NOQUOT_VALUE) {
2096
+ value = source.slice(start, p);
2097
+ addAttribute(attrName, value, start);
2098
+ errorHandler.warning('attribute "' + attrName + '" missed start quot(' + c + ")!!");
2099
+ start = p + 1;
2100
+ s = S_ATTR_END;
2101
+ } else {
2102
+ throw new Error('attribute value must after "="');
2103
+ }
2104
+ break;
2105
+ case "/":
2106
+ switch (s) {
2107
+ case S_TAG:
2108
+ el.setTagName(source.slice(start, p));
2109
+ case S_ATTR_END:
2110
+ case S_TAG_SPACE:
2111
+ case S_TAG_CLOSE:
2112
+ s = S_TAG_CLOSE;
2113
+ el.closed = true;
2114
+ case S_ATTR_NOQUOT_VALUE:
2115
+ case S_ATTR:
2116
+ case S_ATTR_SPACE:
2117
+ break;
2118
+ default:
2119
+ throw new Error("attribute invalid close char('/')");
2120
+ }
2121
+ break;
2122
+ case "":
2123
+ errorHandler.error("unexpected end of input");
2124
+ if (s == S_TAG) {
2125
+ el.setTagName(source.slice(start, p));
2126
+ }
2127
+ return p;
2128
+ case ">":
2129
+ switch (s) {
2130
+ case S_TAG:
2131
+ el.setTagName(source.slice(start, p));
2132
+ case S_ATTR_END:
2133
+ case S_TAG_SPACE:
2134
+ case S_TAG_CLOSE:
2135
+ break;
2136
+ case S_ATTR_NOQUOT_VALUE:
2137
+ case S_ATTR:
2138
+ value = source.slice(start, p);
2139
+ if (value.slice(-1) === "/") {
2140
+ el.closed = true;
2141
+ value = value.slice(0, -1);
2142
+ }
2143
+ case S_ATTR_SPACE:
2144
+ if (s === S_ATTR_SPACE) {
2145
+ value = attrName;
2146
+ }
2147
+ if (s == S_ATTR_NOQUOT_VALUE) {
2148
+ errorHandler.warning('attribute "' + value + '" missed quot(")!');
2149
+ addAttribute(attrName, value, start);
2150
+ } else {
2151
+ if (!NAMESPACE.isHTML(currentNSMap[""]) || !value.match(/^(?:disabled|checked|selected)$/i)) {
2152
+ errorHandler.warning('attribute "' + value + '" missed value!! "' + value + '" instead!!');
2153
+ }
2154
+ addAttribute(value, value, start);
2155
+ }
2156
+ break;
2157
+ case S_EQ:
2158
+ throw new Error("attribute value missed!!");
2159
+ }
2160
+ return p;
2161
+ case "\x80":
2162
+ c = " ";
2163
+ default:
2164
+ if (c <= " ") {
2165
+ switch (s) {
2166
+ case S_TAG:
2167
+ el.setTagName(source.slice(start, p));
2168
+ s = S_TAG_SPACE;
2169
+ break;
2170
+ case S_ATTR:
2171
+ attrName = source.slice(start, p);
2172
+ s = S_ATTR_SPACE;
2173
+ break;
2174
+ case S_ATTR_NOQUOT_VALUE:
2175
+ var value = source.slice(start, p);
2176
+ errorHandler.warning('attribute "' + value + '" missed quot(")!!');
2177
+ addAttribute(attrName, value, start);
2178
+ case S_ATTR_END:
2179
+ s = S_TAG_SPACE;
2180
+ break;
2181
+ }
2182
+ } else {
2183
+ switch (s) {
2184
+ case S_ATTR_SPACE:
2185
+ var tagName = el.tagName;
2186
+ if (!NAMESPACE.isHTML(currentNSMap[""]) || !attrName.match(/^(?:disabled|checked|selected)$/i)) {
2187
+ errorHandler.warning('attribute "' + attrName + '" missed value!! "' + attrName + '" instead2!!');
2188
+ }
2189
+ addAttribute(attrName, attrName, start);
2190
+ start = p;
2191
+ s = S_ATTR;
2192
+ break;
2193
+ case S_ATTR_END:
2194
+ errorHandler.warning('attribute space is required"' + attrName + '"!!');
2195
+ case S_TAG_SPACE:
2196
+ s = S_ATTR;
2197
+ start = p;
2198
+ break;
2199
+ case S_EQ:
2200
+ s = S_ATTR_NOQUOT_VALUE;
2201
+ start = p;
2202
+ break;
2203
+ case S_TAG_CLOSE:
2204
+ throw new Error("elements closed character '/' and '>' must be connected to");
2205
+ }
2206
+ }
2207
+ }
2208
+ p++;
2209
+ }
2210
+ }
2211
+ function appendElement(el, domBuilder, currentNSMap) {
2212
+ var tagName = el.tagName;
2213
+ var localNSMap = null;
2214
+ var i = el.length;
2215
+ while (i--) {
2216
+ var a = el[i];
2217
+ var qName = a.qName;
2218
+ var value = a.value;
2219
+ var nsp = qName.indexOf(":");
2220
+ if (nsp > 0) {
2221
+ var prefix = a.prefix = qName.slice(0, nsp);
2222
+ var localName = qName.slice(nsp + 1);
2223
+ var nsPrefix = prefix === "xmlns" && localName;
2224
+ } else {
2225
+ localName = qName;
2226
+ prefix = null;
2227
+ nsPrefix = qName === "xmlns" && "";
2228
+ }
2229
+ a.localName = localName;
2230
+ if (nsPrefix !== false) {
2231
+ if (localNSMap == null) {
2232
+ localNSMap = {};
2233
+ _copy(currentNSMap, currentNSMap = {});
2234
+ }
2235
+ currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
2236
+ a.uri = NAMESPACE.XMLNS;
2237
+ domBuilder.startPrefixMapping(nsPrefix, value);
2238
+ }
2239
+ }
2240
+ var i = el.length;
2241
+ while (i--) {
2242
+ a = el[i];
2243
+ var prefix = a.prefix;
2244
+ if (prefix) {
2245
+ if (prefix === "xml") {
2246
+ a.uri = NAMESPACE.XML;
2247
+ }
2248
+ if (prefix !== "xmlns") {
2249
+ a.uri = currentNSMap[prefix || ""];
2250
+ }
2251
+ }
2252
+ }
2253
+ var nsp = tagName.indexOf(":");
2254
+ if (nsp > 0) {
2255
+ prefix = el.prefix = tagName.slice(0, nsp);
2256
+ localName = el.localName = tagName.slice(nsp + 1);
2257
+ } else {
2258
+ prefix = null;
2259
+ localName = el.localName = tagName;
2260
+ }
2261
+ var ns = el.uri = currentNSMap[prefix || ""];
2262
+ domBuilder.startElement(ns, localName, tagName, el);
2263
+ if (el.closed) {
2264
+ domBuilder.endElement(ns, localName, tagName);
2265
+ if (localNSMap) {
2266
+ for (prefix in localNSMap) {
2267
+ if (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) {
2268
+ domBuilder.endPrefixMapping(prefix);
2269
+ }
2270
+ }
2271
+ }
2272
+ } else {
2273
+ el.currentNSMap = currentNSMap;
2274
+ el.localNSMap = localNSMap;
2275
+ return true;
2276
+ }
2277
+ }
2278
+ function parseHtmlSpecialContent(source, elStartEnd, tagName, entityReplacer, domBuilder) {
2279
+ if (/^(?:script|textarea)$/i.test(tagName)) {
2280
+ var elEndStart = source.indexOf("</" + tagName + ">", elStartEnd);
2281
+ var text = source.substring(elStartEnd + 1, elEndStart);
2282
+ if (/[&<]/.test(text)) {
2283
+ if (/^script$/i.test(tagName)) {
2284
+ domBuilder.characters(text, 0, text.length);
2285
+ return elEndStart;
2286
+ }
2287
+ text = text.replace(/&#?\w+;/g, entityReplacer);
2288
+ domBuilder.characters(text, 0, text.length);
2289
+ return elEndStart;
2290
+ }
2291
+ }
2292
+ return elStartEnd + 1;
2293
+ }
2294
+ function fixSelfClosed(source, elStartEnd, tagName, closeMap) {
2295
+ var pos = closeMap[tagName];
2296
+ if (pos == null) {
2297
+ pos = source.lastIndexOf("</" + tagName + ">");
2298
+ if (pos < elStartEnd) {
2299
+ pos = source.lastIndexOf("</" + tagName);
2300
+ }
2301
+ closeMap[tagName] = pos;
2302
+ }
2303
+ return pos < elStartEnd;
2304
+ }
2305
+ function _copy(source, target) {
2306
+ for (var n in source) {
2307
+ if (Object.prototype.hasOwnProperty.call(source, n)) {
2308
+ target[n] = source[n];
2309
+ }
2310
+ }
2311
+ }
2312
+ function parseDCC(source, start, domBuilder, errorHandler) {
2313
+ var next = source.charAt(start + 2);
2314
+ switch (next) {
2315
+ case "-":
2316
+ if (source.charAt(start + 3) === "-") {
2317
+ var end = source.indexOf("-->", start + 4);
2318
+ if (end > start) {
2319
+ domBuilder.comment(source, start + 4, end - start - 4);
2320
+ return end + 3;
2321
+ } else {
2322
+ errorHandler.error("Unclosed comment");
2323
+ return -1;
2324
+ }
2325
+ } else {
2326
+ return -1;
2327
+ }
2328
+ default:
2329
+ if (source.substr(start + 3, 6) == "CDATA[") {
2330
+ var end = source.indexOf("]]>", start + 9);
2331
+ domBuilder.startCDATA();
2332
+ domBuilder.characters(source, start + 9, end - start - 9);
2333
+ domBuilder.endCDATA();
2334
+ return end + 3;
2335
+ }
2336
+ var matchs = split(source, start);
2337
+ var len = matchs.length;
2338
+ if (len > 1 && /!doctype/i.test(matchs[0][0])) {
2339
+ var name = matchs[1][0];
2340
+ var pubid = false;
2341
+ var sysid = false;
2342
+ if (len > 3) {
2343
+ if (/^public$/i.test(matchs[2][0])) {
2344
+ pubid = matchs[3][0];
2345
+ sysid = len > 4 && matchs[4][0];
2346
+ } else if (/^system$/i.test(matchs[2][0])) {
2347
+ sysid = matchs[3][0];
2348
+ }
2349
+ }
2350
+ var lastMatch = matchs[len - 1];
2351
+ domBuilder.startDTD(name, pubid, sysid);
2352
+ domBuilder.endDTD();
2353
+ return lastMatch.index + lastMatch[0].length;
2354
+ }
2355
+ }
2356
+ return -1;
2357
+ }
2358
+ function parseInstruction(source, start, domBuilder) {
2359
+ var end = source.indexOf("?>", start);
2360
+ if (end) {
2361
+ var match = source.substring(start, end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);
2362
+ if (match) {
2363
+ var len = match[0].length;
2364
+ domBuilder.processingInstruction(match[1], match[2]);
2365
+ return end + 2;
2366
+ } else {
2367
+ return -1;
2368
+ }
2369
+ }
2370
+ return -1;
2371
+ }
2372
+ function ElementAttributes() {
2373
+ this.attributeNames = {};
2374
+ }
2375
+ ElementAttributes.prototype = {
2376
+ setTagName: function(tagName) {
2377
+ if (!tagNamePattern.test(tagName)) {
2378
+ throw new Error("invalid tagName:" + tagName);
2379
+ }
2380
+ this.tagName = tagName;
2381
+ },
2382
+ addValue: function(qName, value, offset) {
2383
+ if (!tagNamePattern.test(qName)) {
2384
+ throw new Error("invalid attribute:" + qName);
2385
+ }
2386
+ this.attributeNames[qName] = this.length;
2387
+ this[this.length++] = { qName, value, offset };
2388
+ },
2389
+ length: 0,
2390
+ getLocalName: function(i) {
2391
+ return this[i].localName;
2392
+ },
2393
+ getLocator: function(i) {
2394
+ return this[i].locator;
2395
+ },
2396
+ getQName: function(i) {
2397
+ return this[i].qName;
2398
+ },
2399
+ getURI: function(i) {
2400
+ return this[i].uri;
2401
+ },
2402
+ getValue: function(i) {
2403
+ return this[i].value;
2404
+ }
2405
+ // ,getIndex:function(uri, localName)){
2406
+ // if(localName){
2407
+ //
2408
+ // }else{
2409
+ // var qName = uri
2410
+ // }
2411
+ // },
2412
+ // getValue:function(){return this.getValue(this.getIndex.apply(this,arguments))},
2413
+ // getType:function(uri,localName){}
2414
+ // getType:function(i){},
2415
+ };
2416
+ function split(source, start) {
2417
+ var match;
2418
+ var buf = [];
2419
+ var reg = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;
2420
+ reg.lastIndex = start;
2421
+ reg.exec(source);
2422
+ while (match = reg.exec(source)) {
2423
+ buf.push(match);
2424
+ if (match[1])
2425
+ return buf;
2426
+ }
2427
+ }
2428
+ exports.XMLReader = XMLReader;
2429
+ exports.ParseError = ParseError;
2430
+ }
2431
+ });
2432
+
2433
+ // node_modules/@xmldom/xmldom/lib/dom-parser.js
2434
+ var require_dom_parser = __commonJS({
2435
+ "node_modules/@xmldom/xmldom/lib/dom-parser.js"(exports) {
2436
+ var conventions = require_conventions();
2437
+ var dom = require_dom();
2438
+ var entities = require_entities();
2439
+ var sax = require_sax();
2440
+ var DOMImplementation = dom.DOMImplementation;
2441
+ var NAMESPACE = conventions.NAMESPACE;
2442
+ var ParseError = sax.ParseError;
2443
+ var XMLReader = sax.XMLReader;
2444
+ function normalizeLineEndings(input) {
2445
+ return input.replace(/\r[\n\u0085]/g, "\n").replace(/[\r\u0085\u2028]/g, "\n");
2446
+ }
2447
+ function DOMParser2(options) {
2448
+ this.options = options || { locator: {} };
2449
+ }
2450
+ DOMParser2.prototype.parseFromString = function(source, mimeType) {
2451
+ var options = this.options;
2452
+ var sax2 = new XMLReader();
2453
+ var domBuilder = options.domBuilder || new DOMHandler();
2454
+ var errorHandler = options.errorHandler;
2455
+ var locator = options.locator;
2456
+ var defaultNSMap = options.xmlns || {};
2457
+ var isHTML = /\/x?html?$/.test(mimeType);
2458
+ var entityMap = isHTML ? entities.HTML_ENTITIES : entities.XML_ENTITIES;
2459
+ if (locator) {
2460
+ domBuilder.setDocumentLocator(locator);
2461
+ }
2462
+ sax2.errorHandler = buildErrorHandler(errorHandler, domBuilder, locator);
2463
+ sax2.domBuilder = options.domBuilder || domBuilder;
2464
+ if (isHTML) {
2465
+ defaultNSMap[""] = NAMESPACE.HTML;
2466
+ }
2467
+ defaultNSMap.xml = defaultNSMap.xml || NAMESPACE.XML;
2468
+ var normalize = options.normalizeLineEndings || normalizeLineEndings;
2469
+ if (source && typeof source === "string") {
2470
+ sax2.parse(
2471
+ normalize(source),
2472
+ defaultNSMap,
2473
+ entityMap
2474
+ );
2475
+ } else {
2476
+ sax2.errorHandler.error("invalid doc source");
2477
+ }
2478
+ return domBuilder.doc;
2479
+ };
2480
+ function buildErrorHandler(errorImpl, domBuilder, locator) {
2481
+ if (!errorImpl) {
2482
+ if (domBuilder instanceof DOMHandler) {
2483
+ return domBuilder;
2484
+ }
2485
+ errorImpl = domBuilder;
2486
+ }
2487
+ var errorHandler = {};
2488
+ var isCallback = errorImpl instanceof Function;
2489
+ locator = locator || {};
2490
+ function build(key) {
2491
+ var fn = errorImpl[key];
2492
+ if (!fn && isCallback) {
2493
+ fn = errorImpl.length == 2 ? function(msg) {
2494
+ errorImpl(key, msg);
2495
+ } : errorImpl;
2496
+ }
2497
+ errorHandler[key] = fn && function(msg) {
2498
+ fn("[xmldom " + key + "] " + msg + _locator(locator));
2499
+ } || function() {
2500
+ };
2501
+ }
2502
+ build("warning");
2503
+ build("error");
2504
+ build("fatalError");
2505
+ return errorHandler;
2506
+ }
2507
+ function DOMHandler() {
2508
+ this.cdata = false;
2509
+ }
2510
+ function position(locator, node) {
2511
+ node.lineNumber = locator.lineNumber;
2512
+ node.columnNumber = locator.columnNumber;
2513
+ }
2514
+ DOMHandler.prototype = {
2515
+ startDocument: function() {
2516
+ this.doc = new DOMImplementation().createDocument(null, null, null);
2517
+ if (this.locator) {
2518
+ this.doc.documentURI = this.locator.systemId;
2519
+ }
2520
+ },
2521
+ startElement: function(namespaceURI, localName, qName, attrs) {
2522
+ var doc = this.doc;
2523
+ var el = doc.createElementNS(namespaceURI, qName || localName);
2524
+ var len = attrs.length;
2525
+ appendElement(this, el);
2526
+ this.currentElement = el;
2527
+ this.locator && position(this.locator, el);
2528
+ for (var i = 0; i < len; i++) {
2529
+ var namespaceURI = attrs.getURI(i);
2530
+ var value = attrs.getValue(i);
2531
+ var qName = attrs.getQName(i);
2532
+ var attr = doc.createAttributeNS(namespaceURI, qName);
2533
+ this.locator && position(attrs.getLocator(i), attr);
2534
+ attr.value = attr.nodeValue = value;
2535
+ el.setAttributeNode(attr);
2536
+ }
2537
+ },
2538
+ endElement: function(namespaceURI, localName, qName) {
2539
+ var current = this.currentElement;
2540
+ var tagName = current.tagName;
2541
+ this.currentElement = current.parentNode;
2542
+ },
2543
+ startPrefixMapping: function(prefix, uri) {
2544
+ },
2545
+ endPrefixMapping: function(prefix) {
2546
+ },
2547
+ processingInstruction: function(target, data) {
2548
+ var ins = this.doc.createProcessingInstruction(target, data);
2549
+ this.locator && position(this.locator, ins);
2550
+ appendElement(this, ins);
2551
+ },
2552
+ ignorableWhitespace: function(ch, start, length) {
2553
+ },
2554
+ characters: function(chars, start, length) {
2555
+ chars = _toString.apply(this, arguments);
2556
+ if (chars) {
2557
+ if (this.cdata) {
2558
+ var charNode = this.doc.createCDATASection(chars);
2559
+ } else {
2560
+ var charNode = this.doc.createTextNode(chars);
2561
+ }
2562
+ if (this.currentElement) {
2563
+ this.currentElement.appendChild(charNode);
2564
+ } else if (/^\s*$/.test(chars)) {
2565
+ this.doc.appendChild(charNode);
2566
+ }
2567
+ this.locator && position(this.locator, charNode);
2568
+ }
2569
+ },
2570
+ skippedEntity: function(name) {
2571
+ },
2572
+ endDocument: function() {
2573
+ this.doc.normalize();
2574
+ },
2575
+ setDocumentLocator: function(locator) {
2576
+ if (this.locator = locator) {
2577
+ locator.lineNumber = 0;
2578
+ }
2579
+ },
2580
+ //LexicalHandler
2581
+ comment: function(chars, start, length) {
2582
+ chars = _toString.apply(this, arguments);
2583
+ var comm = this.doc.createComment(chars);
2584
+ this.locator && position(this.locator, comm);
2585
+ appendElement(this, comm);
2586
+ },
2587
+ startCDATA: function() {
2588
+ this.cdata = true;
2589
+ },
2590
+ endCDATA: function() {
2591
+ this.cdata = false;
2592
+ },
2593
+ startDTD: function(name, publicId, systemId) {
2594
+ var impl = this.doc.implementation;
2595
+ if (impl && impl.createDocumentType) {
2596
+ var dt = impl.createDocumentType(name, publicId, systemId);
2597
+ this.locator && position(this.locator, dt);
2598
+ appendElement(this, dt);
2599
+ this.doc.doctype = dt;
2600
+ }
2601
+ },
2602
+ /**
2603
+ * @see org.xml.sax.ErrorHandler
2604
+ * @link http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html
2605
+ */
2606
+ warning: function(error) {
2607
+ console.warn("[xmldom warning] " + error, _locator(this.locator));
2608
+ },
2609
+ error: function(error) {
2610
+ console.error("[xmldom error] " + error, _locator(this.locator));
2611
+ },
2612
+ fatalError: function(error) {
2613
+ throw new ParseError(error, this.locator);
2614
+ }
2615
+ };
2616
+ function _locator(l) {
2617
+ if (l) {
2618
+ return "\n@" + (l.systemId || "") + "#[line:" + l.lineNumber + ",col:" + l.columnNumber + "]";
2619
+ }
2620
+ }
2621
+ function _toString(chars, start, length) {
2622
+ if (typeof chars == "string") {
2623
+ return chars.substr(start, length);
2624
+ } else {
2625
+ if (chars.length >= start + length || start) {
2626
+ return new java.lang.String(chars, start, length) + "";
2627
+ }
2628
+ return chars;
2629
+ }
2630
+ }
2631
+ "endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g, function(key) {
2632
+ DOMHandler.prototype[key] = function() {
2633
+ return null;
2634
+ };
2635
+ });
2636
+ function appendElement(hander, node) {
2637
+ if (!hander.currentElement) {
2638
+ hander.doc.appendChild(node);
2639
+ } else {
2640
+ hander.currentElement.appendChild(node);
2641
+ }
2642
+ }
2643
+ exports.__DOMHandler = DOMHandler;
2644
+ exports.normalizeLineEndings = normalizeLineEndings;
2645
+ exports.DOMParser = DOMParser2;
2646
+ }
2647
+ });
2648
+
2649
+ // node_modules/@xmldom/xmldom/lib/index.js
2650
+ var require_lib = __commonJS({
2651
+ "node_modules/@xmldom/xmldom/lib/index.js"(exports) {
2652
+ var dom = require_dom();
2653
+ exports.DOMImplementation = dom.DOMImplementation;
2654
+ exports.XMLSerializer = dom.XMLSerializer;
2655
+ exports.DOMParser = require_dom_parser().DOMParser;
2656
+ }
2657
+ });
2658
+
47
2659
  // src/transportr.js
48
2660
  var transportr_exports = {};
49
2661
  __export(transportr_exports, {
@@ -60,25 +2672,35 @@ var Transportr = (() => {
60
2672
 
61
2673
  // node_modules/@d1g1tal/chrysalis/src/esm/object-merge.js
62
2674
  var _objectMerge = (...objects) => {
63
- return objects.reduce((prev, obj) => {
64
- Object.keys(obj).forEach((key) => {
65
- const pVal = prev[key];
66
- const oVal = obj[key];
67
- if (Array.isArray(pVal) && Array.isArray(oVal)) {
68
- prev[key] = [.../* @__PURE__ */ new Set([...oVal, ...pVal])];
69
- } else if (object_is_type_default(pVal, Object) && object_is_type_default(oVal, Object)) {
70
- prev[key] = _objectMerge(pVal, oVal);
71
- } else {
72
- prev[key] = oVal;
2675
+ return objects.reduce((previousValue, currentValue) => {
2676
+ for (const [key, value] of Object.entries(currentValue)) {
2677
+ switch (true) {
2678
+ case (Array.isArray(value) && Array.isArray(previousValue[key])): {
2679
+ previousValue[key] = [.../* @__PURE__ */ new Set([...value, ...previousValue[key]])];
2680
+ break;
2681
+ }
2682
+ case (object_is_type_default(value, Object) && object_is_type_default(previousValue[key], Object)): {
2683
+ previousValue[key] = _objectMerge(previousValue[key], value);
2684
+ break;
2685
+ }
2686
+ default:
2687
+ previousValue[key] = value;
73
2688
  }
74
- });
75
- return prev;
2689
+ }
2690
+ return previousValue;
76
2691
  }, {});
77
2692
  };
78
2693
  var object_merge_default = _objectMerge;
79
2694
 
80
2695
  // node_modules/@d1g1tal/collections/src/set-multi-map.js
81
2696
  var SetMultiMap = class extends Map {
2697
+ /**
2698
+ * Adds a new element with a specified key and value to the SetMultiMap. If an element with the same key already exists, the value will be added to the underlying {@link Set}.
2699
+ *
2700
+ * @param {K} key The key to set.
2701
+ * @param {V} value The value to add to the SetMultiMap
2702
+ * @returns {SetMultiMap} The SetMultiMap with the updated key and value.
2703
+ */
82
2704
  set(key, value) {
83
2705
  super.set(key, (super.get(key) ?? /* @__PURE__ */ new Set()).add(value));
84
2706
  return this;
@@ -124,18 +2746,48 @@ var Transportr = (() => {
124
2746
 
125
2747
  // node_modules/@d1g1tal/media-type/src/media-type-parameters.js
126
2748
  var MediaTypeParameters = class {
2749
+ /**
2750
+ * Create a new MediaTypeParameters instance.
2751
+ *
2752
+ * @param {Map.<string, string>} map The map of parameters for a media type.
2753
+ */
127
2754
  constructor(map) {
128
2755
  this._map = map;
129
2756
  }
2757
+ /**
2758
+ * Gets the number of media type parameters.
2759
+ *
2760
+ * @returns {number} The number of media type parameters
2761
+ */
130
2762
  get size() {
131
2763
  return this._map.size;
132
2764
  }
2765
+ /**
2766
+ * Gets the media type parameter value for the supplied name.
2767
+ *
2768
+ * @param {string} name The name of the media type parameter to retrieve.
2769
+ * @returns {string} The media type parameter value.
2770
+ */
133
2771
  get(name) {
134
2772
  return this._map.get(asciiLowercase(String(name)));
135
2773
  }
2774
+ /**
2775
+ * Indicates whether the media type parameter with the specified name exists or not.
2776
+ *
2777
+ * @param {string} name The name of the media type parameter to check.
2778
+ * @returns {boolean} true if the media type parameter exists, false otherwise.
2779
+ */
136
2780
  has(name) {
137
2781
  return this._map.has(asciiLowercase(String(name)));
138
2782
  }
2783
+ /**
2784
+ * Adds a new media type parameter using the specified name and value to the MediaTypeParameters.
2785
+ * If an parameter with the same name already exists, the parameter will be updated.
2786
+ *
2787
+ * @param {string} name The name of the media type parameter to set.
2788
+ * @param {string} value The media type parameter value.
2789
+ * @returns {MediaTypeParameters} This instance.
2790
+ */
139
2791
  set(name, value) {
140
2792
  name = asciiLowercase(String(name));
141
2793
  value = String(value);
@@ -148,25 +2800,60 @@ var Transportr = (() => {
148
2800
  this._map.set(name, value);
149
2801
  return this;
150
2802
  }
2803
+ /**
2804
+ * Clears all the media type parameters.
2805
+ */
151
2806
  clear() {
152
2807
  this._map.clear();
153
2808
  }
2809
+ /**
2810
+ * Removes the media type parameter using the specified name.
2811
+ *
2812
+ * @param {string} name The name of the media type parameter to delete.
2813
+ * @returns {boolean} true if the parameter existed and has been removed, or false if the parameter does not exist.
2814
+ */
154
2815
  delete(name) {
155
2816
  name = asciiLowercase(String(name));
156
2817
  return this._map.delete(name);
157
2818
  }
2819
+ /**
2820
+ * Executes a provided function once per each name/value pair in the MediaTypeParameters, in insertion order.
2821
+ *
2822
+ * @param {function(string, string): void} callback The function called on each iteration.
2823
+ * @param {*} [thisArg] Optional object when binding 'this' to the callback.
2824
+ */
158
2825
  forEach(callback, thisArg) {
159
2826
  this._map.forEach(callback, thisArg);
160
2827
  }
2828
+ /**
2829
+ * Returns an iterable of parameter names.
2830
+ *
2831
+ * @returns {IterableIterator<string>} The {@link IterableIterator} of media type parameter names.
2832
+ */
161
2833
  keys() {
162
2834
  return this._map.keys();
163
2835
  }
2836
+ /**
2837
+ * Returns an iterable of parameter values.
2838
+ *
2839
+ * @returns {IterableIterator<string>} The {@link IterableIterator} of media type parameter values.
2840
+ */
164
2841
  values() {
165
2842
  return this._map.values();
166
2843
  }
2844
+ /**
2845
+ * Returns an iterable of name, value pairs for every parameter entry in the media type parameters.
2846
+ *
2847
+ * @returns {IterableIterator<Array<Array<string>>>} The media type parameter entries.
2848
+ */
167
2849
  entries() {
168
2850
  return this._map.entries();
169
2851
  }
2852
+ /**
2853
+ * A method that returns the default iterator for the {@link MediaTypeParameters}. Called by the semantics of the for-of statement.
2854
+ *
2855
+ * @returns {Iterator<string, string, undefined>} The {@link Symbol.iterator} for the media type parameters.
2856
+ */
170
2857
  [Symbol.iterator]() {
171
2858
  return this._map[Symbol.iterator]();
172
2859
  }
@@ -266,6 +2953,11 @@ var Transportr = (() => {
266
2953
 
267
2954
  // node_modules/@d1g1tal/media-type/src/media-type.js
268
2955
  var MediaType = class {
2956
+ /**
2957
+ * Create a new MediaType instance from a string representation.
2958
+ *
2959
+ * @param {string} string The media type to parse
2960
+ */
269
2961
  constructor(string) {
270
2962
  string = String(string);
271
2963
  const result = parser_default(string);
@@ -276,6 +2968,12 @@ var Transportr = (() => {
276
2968
  this._subtype = result.subtype;
277
2969
  this._parameters = new MediaTypeParameters(result.parameters);
278
2970
  }
2971
+ /**
2972
+ * Static factor method for parsing a media type.
2973
+ *
2974
+ * @param {string} string The media type to parse
2975
+ * @returns {MediaType} The parsed {@link MediaType} object
2976
+ */
279
2977
  static parse(string) {
280
2978
  try {
281
2979
  return new this(string);
@@ -283,12 +2981,25 @@ var Transportr = (() => {
283
2981
  return null;
284
2982
  }
285
2983
  }
2984
+ /**
2985
+ * Gets the media type essence (type/subtype).
2986
+ *
2987
+ * @returns {string} The media type without any parameters
2988
+ */
286
2989
  get essence() {
287
2990
  return `${this.type}/${this.subtype}`;
288
2991
  }
2992
+ /**
2993
+ * Gets the type.
2994
+ *
2995
+ * @returns {string} The type.
2996
+ */
289
2997
  get type() {
290
2998
  return this._type;
291
2999
  }
3000
+ /**
3001
+ * Sets the type.
3002
+ */
292
3003
  set type(value) {
293
3004
  value = asciiLowercase(String(value));
294
3005
  if (value.length === 0) {
@@ -299,9 +3010,17 @@ var Transportr = (() => {
299
3010
  }
300
3011
  this._type = value;
301
3012
  }
3013
+ /**
3014
+ * Gets the subtype.
3015
+ *
3016
+ * @returns {string} The subtype.
3017
+ */
302
3018
  get subtype() {
303
3019
  return this._subtype;
304
3020
  }
3021
+ /**
3022
+ * Sets the subtype.
3023
+ */
305
3024
  set subtype(value) {
306
3025
  value = asciiLowercase(String(value));
307
3026
  if (value.length === 0) {
@@ -312,12 +3031,29 @@ var Transportr = (() => {
312
3031
  }
313
3032
  this._subtype = value;
314
3033
  }
3034
+ /**
3035
+ * Gets the parameters.
3036
+ *
3037
+ * @returns {MediaTypeParameters} The media type parameters.
3038
+ */
315
3039
  get parameters() {
316
3040
  return this._parameters;
317
3041
  }
3042
+ /**
3043
+ * Gets the serialized version of the media type.
3044
+ *
3045
+ * @returns {string} The serialized media type.
3046
+ */
318
3047
  toString() {
319
3048
  return serializer_default(this);
320
3049
  }
3050
+ /**
3051
+ * Determines if this instance is a JavaScript media type.
3052
+ *
3053
+ * @param {Object} [options] Optional options.
3054
+ * @param {boolean} [options.prohibitParameters=false] The option to prohibit parameters when checking if the media type is JavaScript.
3055
+ * @returns {boolean} true if this instance represents a JavaScript media type, false otherwise.
3056
+ */
321
3057
  isJavaScript({ prohibitParameters = false } = {}) {
322
3058
  switch (this._type) {
323
3059
  case "text": {
@@ -354,231 +3090,1247 @@ var Transportr = (() => {
354
3090
  return false;
355
3091
  }
356
3092
  }
3093
+ /**
3094
+ * Determines if this instance is an XML media type.
3095
+ *
3096
+ * @returns {boolean} true if this instance represents an XML media type, false otherwise.
3097
+ */
357
3098
  isXML() {
358
3099
  return this._subtype === "xml" && (this._type === "text" || this._type === "application") || this._subtype.endsWith("+xml");
359
3100
  }
3101
+ /**
3102
+ * Determines if this instance is an HTML media type.
3103
+ *
3104
+ * @returns {boolean} true if this instance represents an HTML media type, false otherwise.
3105
+ */
360
3106
  isHTML() {
361
3107
  return this._subtype === "html" && this._type === "text";
362
3108
  }
3109
+ /**
3110
+ * Gets the name of the class.
3111
+ *
3112
+ * @returns {string} The class name
3113
+ */
363
3114
  get [Symbol.toStringTag]() {
364
3115
  return "MediaType";
365
3116
  }
366
3117
  };
367
3118
 
3119
+ // src/http-error.js
3120
+ var HttpError = class extends Error {
3121
+ /** @type {ResponseBody} */
3122
+ #entity;
3123
+ /** @type {ResponseStatus} */
3124
+ #responseStatus;
3125
+ /**
3126
+ * @param {string} [message] The error message.
3127
+ * @param {HttpErrorOptions} [httpErrorOptions] The http error options.
3128
+ * @param {any} [httpErrorOptions.cause] The cause of the error.
3129
+ * @param {ResponseStatus} [httpErrorOptions.status] The response status.
3130
+ * @param {ResponseBody} [httpErrorOptions.entity] The error entity from the server, if any.
3131
+ */
3132
+ constructor(message, { cause, status, entity }) {
3133
+ super(message, { cause });
3134
+ this.#entity = entity;
3135
+ this.#responseStatus = status;
3136
+ }
3137
+ /**
3138
+ * It returns the value of the private variable #entity.
3139
+ *
3140
+ * @returns {ResponseBody} The entity property of the class.
3141
+ */
3142
+ get entity() {
3143
+ return this.#entity;
3144
+ }
3145
+ /**
3146
+ * It returns the status code of the {@link Response}.
3147
+ *
3148
+ * @returns {number} The status code of the {@link Response}.
3149
+ */
3150
+ get statusCode() {
3151
+ return this.#responseStatus?.code;
3152
+ }
3153
+ /**
3154
+ * It returns the status text of the {@link Response}.
3155
+ *
3156
+ * @returns {string} The status code and status text of the {@link Response}.
3157
+ */
3158
+ get statusText() {
3159
+ return this.#responseStatus?.text;
3160
+ }
3161
+ };
3162
+
368
3163
  // src/http-media-type.js
369
3164
  var HttpMediaType = {
3165
+ /** Advanced Audio Coding (AAC) */
370
3166
  AAC: "audio/aac",
3167
+ /** AbiWord */
371
3168
  ABW: "application/x-abiword",
3169
+ /** Archive document (multiple files embedded) */
372
3170
  ARC: "application/x-freearc",
3171
+ /** AVIF image */
373
3172
  AVIF: "image/avif",
3173
+ /** Audio Video Interleave (AVI) */
374
3174
  AVI: "video/x-msvideo",
3175
+ /** Amazon Kindle eBook format */
375
3176
  AZW: "application/vnd.amazon.ebook",
3177
+ /** Binary Data */
376
3178
  BIN: "application/octet-stream",
3179
+ /** Windows OS/2 Bitmap Graphics */
377
3180
  BMP: "image/bmp",
3181
+ /** Bzip Archive */
378
3182
  BZIP: "application/x-bzip",
3183
+ /** Bzip2 Archive */
379
3184
  BZIP2: "application/x-bzip2",
3185
+ /** CD audio */
380
3186
  CDA: "application/x-cdf",
3187
+ /** C Shell Script */
381
3188
  CSH: "application/x-csh",
3189
+ /** Cascading Style Sheets (CSS) */
382
3190
  CSS: "text/css",
3191
+ /** Comma-Separated Values */
383
3192
  CSV: "text/csv",
3193
+ /** Microsoft Office Word Document */
384
3194
  DOC: "application/msword",
3195
+ /** Microsoft Office Word Document (OpenXML) */
385
3196
  DOCX: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
3197
+ /** Microsoft Embedded OpenType */
386
3198
  EOT: "application/vnd.ms-fontobject",
3199
+ /** Electronic Publication (EPUB) */
387
3200
  EPUB: "application/epub+zip",
3201
+ /** GZip Compressed Archive */
388
3202
  GZIP: "application/gzip",
3203
+ /** Graphics Interchange Format */
389
3204
  GIF: "image/gif",
3205
+ /** HyperText Markup Language (HTML) */
390
3206
  HTML: "text/html",
3207
+ /** Icon Format */
391
3208
  ICO: "image/vnd.microsoft.icon",
3209
+ /** iCalendar Format */
392
3210
  ICS: "text/calendar",
3211
+ /** Java Archive (JAR) */
393
3212
  JAR: "application/java-archive",
3213
+ /** JPEG Image */
394
3214
  JPEG: "image/jpeg",
3215
+ /** JavaScript */
395
3216
  JAVA_SCRIPT: "text/javascript",
3217
+ /** JavaScript Object Notation Format (JSON) */
396
3218
  JSON: "application/json",
3219
+ /** JavaScript Object Notation LD Format */
397
3220
  JSON_LD: "application/ld+json",
3221
+ /** Musical Instrument Digital Interface (MIDI) */
398
3222
  MID: "audio/midi",
3223
+ /** Musical Instrument Digital Interface (MIDI) */
399
3224
  X_MID: "audio/x-midi",
3225
+ /** MP3 Audio */
400
3226
  MP3: "audio/mpeg",
3227
+ /** MPEG-4 Audio */
401
3228
  MP4A: "audio/mp4",
3229
+ /** MPEG-4 Video */
402
3230
  MP4: "video/mp4",
3231
+ /** MPEG Video */
403
3232
  MPEG: "video/mpeg",
3233
+ /** Apple Installer Package */
404
3234
  MPKG: "application/vnd.apple.installer+xml",
3235
+ /** OpenDocument Presentation Document */
405
3236
  ODP: "application/vnd.oasis.opendocument.presentation",
3237
+ /** OpenDocument Spreadsheet Document */
406
3238
  ODS: "application/vnd.oasis.opendocument.spreadsheet",
3239
+ /** OpenDocument Text Document */
407
3240
  ODT: "application/vnd.oasis.opendocument.text",
3241
+ /** Ogg Audio */
408
3242
  OGA: "audio/ogg",
3243
+ /** Ogg Video */
409
3244
  OGV: "video/ogg",
3245
+ /** Ogg */
410
3246
  OGX: "application/ogg",
3247
+ /** Opus audio */
411
3248
  OPUS: "audio/opus",
3249
+ /** OpenType Font File */
412
3250
  OTF: "font/otf",
3251
+ /** Portable Network Graphics (PNG) */
413
3252
  PNG: "image/png",
3253
+ /** Adobe Portable Document Format */
414
3254
  PDF: "application/pdf",
3255
+ /** Hypertext Preprocessor (Personal Home Page) */
415
3256
  PHP: "application/x-httpd-php",
3257
+ /** Microsoft PowerPoint */
416
3258
  PPT: "application/vnd.ms-powerpoint",
3259
+ /** Microsoft Office Presentation (OpenXML) */
417
3260
  PPTX: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
3261
+ /** RAR Archive */
418
3262
  RAR: "application/vnd.rar",
3263
+ /** Rich Text Format */
419
3264
  RTF: "application/rtf",
3265
+ /** Bourne Shell Script */
420
3266
  SH: "application/x-sh",
3267
+ /** Scalable Vector Graphics (SVG) */
421
3268
  SVG: "image/svg+xml",
3269
+ /** Tape Archive (TAR) */
422
3270
  TAR: "application/x-tar",
3271
+ /** Tagged Image File Format (TIFF) */
423
3272
  TIFF: "image/tiff",
3273
+ /** MPEG transport stream */
424
3274
  TRANSPORT_STREAM: "video/mp2t",
3275
+ /** TrueType Font */
425
3276
  TTF: "font/ttf",
3277
+ /** Text, (generally ASCII or ISO 8859-n) */
426
3278
  TEXT: "text/plain",
3279
+ /** Microsoft Visio */
427
3280
  VSD: "application/vnd.visio",
3281
+ /** Waveform Audio Format (WAV) */
428
3282
  WAV: "audio/wav",
3283
+ /** Open Web Media Project - Audio */
429
3284
  WEBA: "audio/webm",
3285
+ /** Open Web Media Project - Video */
430
3286
  WEBM: "video/webm",
3287
+ /** WebP Image */
431
3288
  WEBP: "image/webp",
3289
+ /** Web Open Font Format */
432
3290
  WOFF: "font/woff",
3291
+ /** Web Open Font Format */
433
3292
  WOFF2: "font/woff2",
3293
+ /** XHTML - The Extensible HyperText Markup Language */
434
3294
  XHTML: "application/xhtml+xml",
3295
+ /** Microsoft Excel Document */
435
3296
  XLS: "application/vnd.ms-excel",
3297
+ /** Microsoft Office Spreadsheet Document (OpenXML) */
436
3298
  XLSX: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
3299
+ /** Extensible Markup Language (XML) */
437
3300
  XML: "application/xml",
3301
+ /** XML User Interface Language (XUL) */
438
3302
  XUL: "application/vnd.mozilla.xul+xml",
3303
+ /** Zip Archive */
439
3304
  ZIP: "application/zip",
3305
+ /** 3GPP audio/video container */
440
3306
  "3GP": "video/3gpp",
3307
+ /** 3GPP2 audio/video container */
441
3308
  "3G2": "video/3gpp2",
3309
+ /** 7-Zip Archive */
442
3310
  "7Z": "application/x-7z-compressed"
443
3311
  };
444
3312
  var http_media_type_default = HttpMediaType;
445
3313
 
446
3314
  // src/http-request-headers.js
447
3315
  var HttpRequestHeader = {
3316
+ /**
3317
+ * Content-Types that are acceptable for the response. See Content negotiation. Permanent.
3318
+ *
3319
+ * @example
3320
+ * <code>Accept: text/plain</code>
3321
+ */
448
3322
  ACCEPT: "accept",
3323
+ /**
3324
+ * Character sets that are acceptable. Permanent.
3325
+ *
3326
+ * @example
3327
+ * <code>Accept-Charset: utf-8</code>
3328
+ */
449
3329
  ACCEPT_CHARSET: "accept-charset",
3330
+ /**
3331
+ * List of acceptable encodings. See HTTP compression. Permanent.
3332
+ *
3333
+ * @example
3334
+ * <code>Accept-Encoding: gzip, deflate</code>
3335
+ */
450
3336
  ACCEPT_ENCODING: "accept-encoding",
3337
+ /**
3338
+ * List of acceptable human languages for response. See Content negotiation. Permanent.
3339
+ *
3340
+ * @example
3341
+ * <code>Accept-Language: en-US</code>
3342
+ */
451
3343
  ACCEPT_LANGUAGE: "accept-language",
3344
+ /**
3345
+ * Authentication credentials for HTTP authentication. Permanent.
3346
+ *
3347
+ * @example
3348
+ * <code>Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==</code>
3349
+ */
452
3350
  AUTHORIZATION: "authorization",
3351
+ /**
3352
+ * Used to specify directives that must be obeyed by all caching mechanisms along the request-response chain.
3353
+ * Permanent.
3354
+ *
3355
+ * @example
3356
+ * <code>Cache-Control: no-cache</code>
3357
+ */
453
3358
  CACHE_CONTROL: "cache-control",
3359
+ /**
3360
+ * Control options for the current connection and list of hop-by-hop request fields. Permanent.
3361
+ *
3362
+ * @example
3363
+ * <code>Connection: keep-alive</code>
3364
+ * <code>Connection: Upgrade</code>
3365
+ */
454
3366
  CONNECTION: "connection",
3367
+ /**
3368
+ * An HTTP cookie previously sent by the server with Set-Cookie (below). Permanent: standard.
3369
+ *
3370
+ * @example
3371
+ * <code>Cookie: $Version=1, Skin=new,</code>
3372
+ */
455
3373
  COOKIE: "cookie",
3374
+ /**
3375
+ * The length of the request body in octets (8-bit bytes). Permanent.
3376
+ *
3377
+ * @example
3378
+ * <code>Content-Length: 348</code>
3379
+ */
456
3380
  CONTENT_LENGTH: "content-length",
3381
+ /**
3382
+ * A Base64-encoded binary MD5 sum of the content of the request body. Obsolete.
3383
+ *
3384
+ * @example
3385
+ * <code>Content-MD5: Q2hlY2sgSW50ZWdyaXR5IQ==</code>
3386
+ */
457
3387
  CONTENT_MD5: "content-md5",
3388
+ /**
3389
+ * The MIME type of the body of the request (used with POST and PUT requests). Permanent.
3390
+ * <code>Content-Type: application/x-www-form-urlencoded</code>
3391
+ */
458
3392
  CONTENT_TYPE: "content-type",
3393
+ /**
3394
+ * The date and time that the message was sent (in "HTTP-date" format as defined by RFC 7231 Date/Time Formats).
3395
+ * Permanent.
3396
+ *
3397
+ * @example
3398
+ * <code>Date: Tue, 15 Nov 1994 08:12:31 GMT</code>
3399
+ */
459
3400
  DATE: "date",
3401
+ /**
3402
+ * Indicates that particular server behaviors are required by the client. Permanent.
3403
+ *
3404
+ * @example
3405
+ * <code>Expect: 100-continue</code>
3406
+ */
460
3407
  EXPECT: "expect",
3408
+ /**
3409
+ * The email address of the user making the request. Permanent.
3410
+ *
3411
+ * @example
3412
+ * <code>From: user@example.com</code>
3413
+ */
461
3414
  FROM: "from",
3415
+ /**
3416
+ * The domain name of the server (for virtual hosting), and the TCP port number on which the server is listening. The
3417
+ * port number may be omitted if the port is the standard port for the service requested. Permanent. Mandatory since
3418
+ * HTTP/1.1.
3419
+ *
3420
+ * @example
3421
+ * <code>Host: en.wikipedia.org:80</code>
3422
+ * <code>Host: en.wikipedia.org</code>
3423
+ */
462
3424
  HOST: "host",
3425
+ /**
3426
+ * Only perform the action if the client supplied entity matches the same entity on the server. This is mainly for
3427
+ * methods like PUT to only update a resource if it has not been modified since the user last updated it. Permanent.
3428
+ *
3429
+ * @example
3430
+ * <code>If-Match: "737060cd8c284d8af7ad3082f209582d"</code>
3431
+ */
463
3432
  IF_MATCH: "if-match",
3433
+ /**
3434
+ * Allows a 304 Not Modified to be returned if content is unchanged. Permanent.
3435
+ *
3436
+ * @example
3437
+ * <code>If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT</code>
3438
+ */
464
3439
  IF_MODIFIED_SINCE: "if-modified-since",
3440
+ /**
3441
+ * Allows a 304 Not Modified to be returned if content is unchanged, see HTTP ETag. Permanent.
3442
+ *
3443
+ * @example
3444
+ * <code>If-None-Match: "737060cd8c284d8af7ad3082f209582d"</code>
3445
+ */
465
3446
  IF_NONE_MATCH: "if-none-match",
3447
+ /**
3448
+ * If the entity is unchanged, send me the part(s) that I am missing, otherwise, send me the entire new entity.
3449
+ * Permanent.
3450
+ *
3451
+ * @example
3452
+ * <code>If-Range: "737060cd8c284d8af7ad3082f209582d"</code>
3453
+ */
466
3454
  IF_RANGE: "if-range",
3455
+ /**
3456
+ * Only send the response if the entity has not been modified since a specific time. Permanent.
3457
+ *
3458
+ * @example
3459
+ * <code>If-Unmodified-Since: Sat, 29 Oct 1994 19:43:31 GMT</code>
3460
+ */
467
3461
  IF_UNMODIFIED_SINCE: "if-unmodified-since",
3462
+ /**
3463
+ * Limit the number of times the message can be forwarded through proxies or gateways. Permanent.
3464
+ *
3465
+ * @example
3466
+ * <code>Max-Forwards: 10</code>
3467
+ */
468
3468
  MAX_FORWARDS: "max-forwards",
3469
+ /**
3470
+ * Initiates a request for cross-origin resource sharing (asks server for an 'Access-Control-Allow-Origin' response
3471
+ * field). Permanent: standard.
3472
+ *
3473
+ * @example
3474
+ * <code>Origin: http://www.example-social-network.com</code>
3475
+ */
469
3476
  ORIGIN: "origin",
3477
+ /**
3478
+ * Implementation-specific fields that may have various effects anywhere along the request-response chain. Permanent.
3479
+ *
3480
+ * @example
3481
+ * <code>Pragma: no-cache</code>
3482
+ */
470
3483
  PRAGMA: "pragma",
3484
+ /**
3485
+ * Authorization credentials for connecting to a proxy. Permanent.
3486
+ *
3487
+ * @example
3488
+ * <code>Proxy-Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==</code>
3489
+ */
471
3490
  PROXY_AUTHORIZATION: "proxy-authorization",
3491
+ /**
3492
+ * Request only part of an entity. Bytes are numbered from 0. See Byte serving. Permanent.
3493
+ *
3494
+ * @example
3495
+ * <code>Range: bytes=500-999</code>
3496
+ */
472
3497
  RANGE: "range",
3498
+ /**
3499
+ * This is the address of the previous web page from which a link to the currently requested page was followed. (The
3500
+ * word "referrer" has been misspelled in the RFC as well as in most implementations to the point that it has become
3501
+ * standard usage and is considered correct terminology). Permanent.
3502
+ *
3503
+ * @example
3504
+ * <code>Referer: http://en.wikipedia.org/wiki/Main_Page</code>
3505
+ */
473
3506
  REFERER: "referer",
3507
+ /**
3508
+ * The transfer encodings the user agent is willing to accept: the same values as for the response header field
3509
+ * Transfer-Encoding can be used, plus the "trailers" value (related to the "chunked" transfer method) to notify the
3510
+ * server it expects to receive additional fields in the trailer after the last, zero-sized, chunk. Permanent.
3511
+ *
3512
+ * @example
3513
+ * <code>TE: trailers, deflate</code>
3514
+ */
474
3515
  TE: "te",
3516
+ /**
3517
+ * The user agent string of the user agent. Permanent.
3518
+ *
3519
+ * @example
3520
+ * <code>User-Agent: Mozilla/5.0 (X11, Linux x86_64, rv:12.0) Gecko/20100101 Firefox/21.0</code>
3521
+ */
475
3522
  USER_AGENT: "user-agent",
3523
+ /**
3524
+ * Ask the server to upgrade to another protocol. Permanent.
3525
+ *
3526
+ * @example
3527
+ * <code>Upgrade: HTTP/2.0, SHTTP/1.3, IRC/6.9, RTA/x11</code>
3528
+ */
476
3529
  UPGRADE: "upgrade",
3530
+ /**
3531
+ * Informs the server of proxies through which the request was sent. Permanent.
3532
+ *
3533
+ * @example
3534
+ * <code>Via: 1.0 fred, 1.1 example.com (Apache/1.1)</code>
3535
+ */
477
3536
  VIA: "via",
3537
+ /**
3538
+ * A general warning about possible problems with the entity body. Permanent.
3539
+ *
3540
+ * @example
3541
+ * <code>Warning: 199 Miscellaneous warning</code>
3542
+ */
478
3543
  WARNING: "warning",
3544
+ /**
3545
+ * mainly used to identify Ajax requests. Most JavaScript frameworks send this field with value of XMLHttpRequest.
3546
+ *
3547
+ * @example
3548
+ * <code>X-Requested-With: XMLHttpRequest</code>
3549
+ */
479
3550
  X_REQUESTED_WITH: "x-requested-with",
3551
+ /**
3552
+ * Requests a web application to disable their tracking of a user. This is Mozilla's version of the X-Do-Not-Track
3553
+ * header field (since Firefox 4.0 Beta 11). Safari and IE9 also have support for this field. On March 7, 2011, a
3554
+ * draft proposal was submitted to IETF. The W3C Tracking Protection Working Group is producing a specification.
3555
+ *
3556
+ * @example
3557
+ * <code>DNT: 1 (Do Not Track Enabled)</code>
3558
+ * <code>DNT: 0 (Do Not Track Disabled)</code>
3559
+ */
480
3560
  DNT: "dnt",
3561
+ /**
3562
+ * A de facto standard for identifying the originating IP address of a client connecting to a web server through an
3563
+ * HTTP proxy or load balancer.
3564
+ *
3565
+ * @example
3566
+ * <code>X-Forwarded-For: client1, proxy1, proxy2</code>
3567
+ * <code>X-Forwarded-For: 129.78.138.66, 129.78.64.103</code>
3568
+ */
481
3569
  X_FORWARDED_FOR: "x-forwarded-for",
3570
+ /**
3571
+ * A de facto standard for identifying the original host requested by the client in the Host HTTP request header, since
3572
+ * the host name and/or port of the reverse proxy (load balancer) may differ from the origin server handling the
3573
+ * request.
3574
+ *
3575
+ * @example
3576
+ * <code>X-Forwarded-Host: en.wikipedia.org:80</code>
3577
+ * <code>X-Forwarded-Host: en.wikipedia.org</code>
3578
+ */
482
3579
  X_FORWARDED_HOST: "x-forwarded-host",
3580
+ /**
3581
+ * A de facto standard for identifying the originating protocol of an HTTP request, since a reverse proxy (load
3582
+ * balancer) may communicate with a web server using HTTP even if the request to the reverse proxy is HTTPS. An
3583
+ * alternative form of the header (X-ProxyUser-Ip) is used by Google clients talking to Google servers.
3584
+ *
3585
+ * @example
3586
+ * <code>X-Forwarded-Proto: https</code>
3587
+ */
483
3588
  X_FORWARDED_PROTO: "x-forwarded-proto",
3589
+ /**
3590
+ * Non-standard header field used by Microsoft applications and load-balancers.
3591
+ *
3592
+ * @example
3593
+ * <code>Front-End-Https: on</code>
3594
+ */
484
3595
  FRONT_END_HTTPS: "front-end-https",
3596
+ /**
3597
+ * Requests a web application override the method specified in the request (typically POST) with the method given in
3598
+ * the header field (typically PUT or DELETE). Can be used when a user agent or firewall prevents PUT or DELETE methods
3599
+ * from being sent directly (note that this either a bug in the software component, which ought to be fixed, or an
3600
+ * intentional configuration, in which case bypassing it may be the wrong thing to do).
3601
+ *
3602
+ * @example
3603
+ * <code>X-HTTP-Method-Override: DELETE</code>
3604
+ */
485
3605
  X_HTTP_METHOD_OVERRIDE: "x-http-method-override",
3606
+ /**
3607
+ * Allows easier parsing of the MakeModel/Firmware that is usually found in the User-Agent String of AT&T Devices.
3608
+ *
3609
+ * @example
3610
+ * <code>X-Att-Deviceid: GT-P7320/P7320XXLPG</code>
3611
+ */
486
3612
  X_ATT_DEVICE_ID: "x-att-deviceid",
3613
+ /**
3614
+ * Links to an XML file on the Internet with a full description and details about the device currently connecting. In the example to the right is an XML file for an AT&T Samsung Galaxy S2.
3615
+ * x-wap-profile: http://wap.samsungmobile.com/uaprof/SGH-I777.xml
3616
+ */
487
3617
  X_WAP_PROFILE: "x-wap-profile"
488
3618
  };
489
3619
  var http_request_headers_default = HttpRequestHeader;
490
3620
 
491
3621
  // src/http-request-methods.js
492
3622
  var HttpRequestMethod = {
3623
+ /**
3624
+ * The OPTIONS method represents a request for information about the communication options available on the
3625
+ * request/response chain identified by the Request-URI. This method allows the client to determine the options and/or
3626
+ * requirements associated with a resource, or the capabilities of a server, without implying a resource action or
3627
+ * initiating a resource retrieval.
3628
+ *
3629
+ * Responses to this method are not cacheable.
3630
+ *
3631
+ * If the OPTIONS request includes an entity-body (as indicated by the presence of Content-Length or
3632
+ * Transfer-Encoding), then the media type MUST be indicated by a Content-Type field. Although this specification does
3633
+ * not define any use for such a body, future extensions to HTTP might use the OPTIONS body to make more detailed
3634
+ * queries on the server. A server that does not support such an extension MAY discard the request body.
3635
+ *
3636
+ * If the Request-URI is an asterisk ("*"), the OPTIONS request is intended to apply to the server in general rather
3637
+ * than to a specific resource. Since a server's communication options typically depend on the resource, the "*"
3638
+ * request is only useful as a "ping" or "no-op" type of method, it does nothing beyond allowing the client to test the
3639
+ * capabilities of the server. For example, this can be used to test a proxy for HTTP/1.1 compliance (or lack thereof).
3640
+ *
3641
+ * If the Request-URI is not an asterisk, the OPTIONS request applies only to the options that are available when
3642
+ * communicating with that resource.
3643
+ *
3644
+ * A 200 response SHOULD include any header fields that indicate optional features implemented by the server and
3645
+ * applicable to that resource (e.g., Allow), possibly including extensions not defined by this specification. The
3646
+ * response body, if any, SHOULD also include information about the communication options. The format for such a body
3647
+ * is not defined by this specification, but might be defined by future extensions to HTTP. Content negotiation MAY be
3648
+ * used to select the appropriate response format. If no response body is included, the response MUST include a
3649
+ * Content-Length field with a field-value of "0".
3650
+ *
3651
+ * The Max-Forwards request-header field MAY be used to target a specific proxy in the request chain. When a proxy
3652
+ * receives an OPTIONS request on an absoluteURI for which request forwarding is permitted, the proxy MUST check for a
3653
+ * Max-Forwards field. If the Max-Forwards field-value is zero ("0"), the proxy MUST NOT forward the message, instead,
3654
+ * the proxy SHOULD respond with its own communication options. If the Max-Forwards field-value is an integer greater
3655
+ * than zero, the proxy MUST decrement the field-value when it forwards the request. If no Max-Forwards field is
3656
+ * present in the request, then the forwarded request MUST NOT include a Max-Forwards field.
3657
+ */
493
3658
  OPTIONS: "OPTIONS",
3659
+ /**
3660
+ * The GET method means retrieve whatever information (in the form of an entity) is identified by the Request-URI. If
3661
+ * the Request-URI refers to a data-producing process, it is the produced data which shall be returned as the entity in
3662
+ * the response and not the source text of the process, unless that text happens to be the output of the process.
3663
+ *
3664
+ * The semantics of the GET method change to a "conditional GET" if the request message includes an If-Modified-Since;
3665
+ * If-Unmodified-Since, If-Match, If-None-Match, or If-Range header field. A conditional GET method requests that the
3666
+ * entity be transferred only under the circumstances described by the conditional header field(s). The conditional GET
3667
+ * method is intended to reduce unnecessary network usage by allowing cached entities to be refreshed without requiring
3668
+ * multiple requests or transferring data already held by the client.
3669
+ *
3670
+ * The semantics of the GET method change to a "partial GET" if the request message includes a Range header field. A
3671
+ * partial GET requests that only part of the entity be transferred, as described in section 14.35. The partial GET
3672
+ * method is intended to reduce unnecessary network usage by allowing partially-retrieved entities to be completed
3673
+ * without transferring data already held by the client.
3674
+ *
3675
+ * The response to a GET request is cacheable if and only if it meets the requirements for HTTP caching described in
3676
+ * section 13.
3677
+ *
3678
+ * See section 15.1.3 for security considerations when used for forms.
3679
+ */
494
3680
  GET: "GET",
3681
+ /**
3682
+ * The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response. The
3683
+ * meta information contained in the HTTP headers in response to a HEAD request SHOULD be identical to the information
3684
+ * sent in response to a GET request. This method can be used for obtaining meta information about the entity implied by
3685
+ * the request without transferring the entity-body itself. This method is often used for testing hypertext links for
3686
+ * validity, accessibility, and recent modification.
3687
+ *
3688
+ * The response to a HEAD request MAY be cacheable in the sense that the information contained in the response MAY be
3689
+ * used to update a previously cached entity from that resource. If the new field values indicate that the cached
3690
+ * entity differs from the current entity (as would be indicated by a change in Content-Length, Content-MD5, ETag or
3691
+ * Last-Modified), then the cache MUST treat the cache entry as stale.
3692
+ */
495
3693
  HEAD: "HEAD",
3694
+ /**
3695
+ * The POST method is used to request that the origin server accept the entity enclosed in the request as a new
3696
+ * subordinate of the resource identified by the Request-URI in the Request-Line. POST is designed to allow a uniform
3697
+ * method to cover the following functions:
3698
+ * <ul>
3699
+ * <li>Annotation of existing resources,</li>
3700
+ * <li>Posting a message to a bulletin board, newsgroup, mailing list, or similar group of articles,</li>
3701
+ * <li>Providing a block of data, such as the result of submitting a form, to a data-handling process,</li>
3702
+ * <li>Extending a database through an append operation.</li>
3703
+ * </ul>
3704
+ *
3705
+ * The actual function performed by the POST method is determined by the server and is usually dependent on the
3706
+ * Request-URI. The posted entity is subordinate to that URI in the same way that a file is subordinate to a directory
3707
+ * containing it, a news article is subordinate to a newsgroup to which it is posted, or a record is subordinate to a
3708
+ * database.
3709
+ *
3710
+ * The action performed by the POST method might not result in a resource that can be identified by a URI. In this
3711
+ * case, either 200 (OK) or 204 (No Content) is the appropriate response status, depending on whether or not the
3712
+ * response includes an entity that describes the result.
3713
+ *
3714
+ * If a resource has been created on the origin server, the response SHOULD be 201 (Created) and contain an entity
3715
+ * which describes the status of the request and refers to the new resource, and a Location header (see section 14.30).
3716
+ *
3717
+ * Responses to this method are not cacheable, unless the response includes appropriate Cache-Control or Expires header
3718
+ * fields. However, the 303 (See Other) response can be used to direct the user agent to retrieve a cacheable resource.
3719
+ *
3720
+ * POST requests MUST obey the message transmission requirements set out in section 8.2.
3721
+ *
3722
+ * See section 15.1.3 for security considerations.
3723
+ */
496
3724
  POST: "POST",
3725
+ /**
3726
+ * The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers
3727
+ * to an already existing resource, the enclosed entity SHOULD be considered as a modified version of the one residing
3728
+ * on the origin server. If the Request-URI does not point to an existing resource, and that URI is capable of being
3729
+ * defined as a new resource by the requesting user agent, the origin server can create the resource with that URI. If
3730
+ * a new resource is created, the origin server MUST inform the user agent via the 201 (Created) response. If an
3731
+ * existing resource is modified, either the 200 (OK) or 204 (No Content) response codes SHOULD be sent to indicate
3732
+ * successful completion of the request. If the resource could not be created or modified with the Request-URI, an
3733
+ * appropriate error response SHOULD be given that reflects the nature of the problem. The recipient of the entity MUST
3734
+ * \NOT ignore any Content-* (e.g. Content-Range) headers that it does not understand or implement and MUST return a
3735
+ * 501 (Not Implemented) response in such cases.
3736
+ *
3737
+ * If the request passes through a cache and the Request-URI identifies one or more currently cached entities, those
3738
+ * entries SHOULD be treated as stale. Responses to this method are not cacheable.
3739
+ *
3740
+ * The fundamental difference between the POST and PUT requests is reflected in the different meaning of the
3741
+ * Request-URI. The URI in a POST request identifies the resource that will handle the enclosed entity. That resource
3742
+ * might be a data-accepting process, a gateway to some other protocol, or a separate entity that accepts annotations.
3743
+ * In contrast, the URI in a PUT request identifies the entity enclosed with the request -- the user agent knows what
3744
+ * URI is intended and the server MUST NOT attempt to apply the request to some other resource. If the server desires
3745
+ * that the request be applied to a different URI, it MUST send a 301 (Moved Permanently) response, the user agent MAY
3746
+ * then make its own decision regarding whether or not to redirect the request.
3747
+ *
3748
+ * A single resource MAY be identified by many different URIs. For example, an article might have a URI for identifying
3749
+ * "the current version" which is separate from the URI identifying each particular version. In this case, a PUT
3750
+ * request on a general URI might result in several other URIs being defined by the origin server.
3751
+ *
3752
+ * HTTP/1.1 does not define how a PUT method affects the state of an origin server.
3753
+ *
3754
+ * PUT requests MUST obey the message transmission requirements set out in section 8.2.
3755
+ *
3756
+ * Unless otherwise specified for a particular entity-header, the entity-headers in the PUT request SHOULD be applied
3757
+ * to the resource created or modified by the PUT.
3758
+ */
497
3759
  PUT: "PUT",
3760
+ /**
3761
+ * The DELETE method requests that the origin server delete the resource identified by the Request-URI. This method MAY
3762
+ * be overridden by human intervention (or other means) on the origin server. The client cannot be guaranteed that the
3763
+ * operation has been carried out, even if the status code returned from the origin server indicates that the action
3764
+ * has been completed successfully. However, the server SHOULD NOT indicate success unless, at the time the response
3765
+ * is given, it intends to delete the resource or move it to an inaccessible location.
3766
+ *
3767
+ * A successful response SHOULD be 200 (OK) if the response includes an entity describing the status, 202 (Accepted) if
3768
+ * the action has not yet been enacted, or 204 (No Content) if the action has been enacted but the response does not
3769
+ * include an entity.
3770
+ *
3771
+ * If the request passes through a cache and the Request-URI identifies one or more currently cached entities, those
3772
+ * entries SHOULD be treated as stale. Responses to this method are not cacheable.
3773
+ */
498
3774
  DELETE: "DELETE",
3775
+ /**
3776
+ * The TRACE method is used to invoke a remote, application-layer loop- back of the request message. The final
3777
+ * recipient of the request SHOULD reflect the message received back to the client as the entity-body of a 200 (OK)
3778
+ * response. The final recipient is either the origin server or the first proxy or gateway to receive a Max-Forwards
3779
+ * value of zero (0) in the request (see section 14.31). A TRACE request MUST NOT include an entity.
3780
+ *
3781
+ * TRACE allows the client to see what is being received at the other end of the request chain and use that data for
3782
+ * testing or diagnostic information. The value of the Via header field (section 14.45) is of particular interest,
3783
+ * since it acts as a trace of the request chain. Use of the Max-Forwards header field allows the client to limit the
3784
+ * length of the request chain, which is useful for testing a chain of proxies forwarding messages in an infinite loop.
3785
+ *
3786
+ * If the request is valid, the response SHOULD contain the entire request message in the entity-body, with a
3787
+ * Content-Type of "message/http". Responses to this method MUST NOT be cached.
3788
+ */
499
3789
  TRACE: "TRACE",
3790
+ /**
3791
+ * This specification reserves the method name CONNECT for use with a proxy that can dynamically switch to being a
3792
+ * tunnel (e.g. SSL tunneling [44]).
3793
+ */
500
3794
  CONNECT: "CONNECT",
3795
+ /**
3796
+ * The PATCH method requests that a set of changes described in the
3797
+ * request entity be applied to the resource identified by the Request-
3798
+ * URI. The set of changes is represented in a format called a "patch
3799
+ * document" identified by a media type. If the Request-URI does not
3800
+ * point to an existing resource, the server MAY create a new resource,
3801
+ * depending on the patch document type (whether it can logically modify
3802
+ * a null resource) and permissions, etc.
3803
+ *
3804
+ * The difference between the PUT and PATCH requests is reflected in the
3805
+ * way the server processes the enclosed entity to modify the resource
3806
+ * identified by the Request-URI. In a PUT request, the enclosed entity
3807
+ * is considered to be a modified version of the resource stored on the
3808
+ * origin server, and the client is requesting that the stored version
3809
+ * be replaced. With PATCH, however, the enclosed entity contains a set
3810
+ * of instructions describing how a resource currently residing on the
3811
+ * origin server should be modified to produce a new version. The PATCH
3812
+ * method affects the resource identified by the Request-URI, and it
3813
+ * also MAY have side effects on other resources; i.e., new resources
3814
+ * may be created, or existing ones modified, by the application of a
3815
+ * PATCH.
3816
+ *
3817
+ * PATCH is neither safe nor idempotent as defined by [RFC2616], Section
3818
+ * 9.1.
3819
+ *
3820
+ * A PATCH request can be issued in such a way as to be idempotent,
3821
+ * which also helps prevent bad outcomes from collisions between two
3822
+ * PATCH requests on the same resource in a similar time frame.
3823
+ * Collisions from multiple PATCH requests may be more dangerous than
3824
+ * PUT collisions because some patch formats need to operate from a
3825
+ * known base-point or else they will corrupt the resource. Clients
3826
+ * using this kind of patch application SHOULD use a conditional request
3827
+ * such that the request will fail if the resource has been updated
3828
+ * since the client last accessed the resource. For example, the client
3829
+ * can use a strong ETag [RFC2616] in an If-Match header on the PATCH
3830
+ * request.
3831
+ *
3832
+ * There are also cases where patch formats do not need to operate from
3833
+ * a known base-point (e.g., appending text lines to log files, or non-
3834
+ * colliding rows to database tables), in which case the same care in
3835
+ * client requests is not needed.
3836
+ *
3837
+ * The server MUST apply the entire set of changes atomically and never
3838
+ * provide (e.g., in response to a GET during this operation) a
3839
+ * partially modified representation. If the entire patch document
3840
+ * cannot be successfully applied, then the server MUST NOT apply any of
3841
+ * the changes. The determination of what constitutes a successful
3842
+ * PATCH can vary depending on the patch document and the type of
3843
+ * resource(s) being modified. For example, the common 'diff' utility
3844
+ * can generate a patch document that applies to multiple files in a
3845
+ * directory hierarchy. The atomicity requirement holds for all
3846
+ * directly affected files. See "Error Handling", Section 2.2, for
3847
+ * details on status codes and possible error conditions.
3848
+ *
3849
+ * If the request passes through a cache and the Request-URI identifies
3850
+ * one or more currently cached entities, those entries SHOULD be
3851
+ * treated as stale. A response to this method is only cacheable if it
3852
+ * contains explicit freshness information (such as an Expires header or
3853
+ * "Cache-Control: max-age" directive) as well as the Content-Location
3854
+ * header matching the Request-URI, indicating that the PATCH response
3855
+ * body is a resource representation. A cached PATCH response can only
3856
+ * be used to respond to subsequent GET and HEAD requests; it MUST NOT
3857
+ * be used to respond to other methods (in particular, PATCH).
3858
+ *
3859
+ * Note that entity-headers contained in the request apply only to the
3860
+ * contained patch document and MUST NOT be applied to the resource
3861
+ * being modified. Thus, a Content-Language header could be present on
3862
+ * the request, but it would only mean (for whatever that's worth) that
3863
+ * the patch document had a language. Servers SHOULD NOT store such
3864
+ * headers except as trace information, and SHOULD NOT use such header
3865
+ * values the same way they might be used on PUT requests. Therefore,
3866
+ * this document does not specify a way to modify a document's Content-
3867
+ * Type or Content-Language value through headers, though a mechanism
3868
+ * could well be designed to achieve this goal through a patch document.
3869
+ *
3870
+ * There is no guarantee that a resource can be modified with PATCH.
3871
+ * Further, it is expected that different patch document formats will be
3872
+ * appropriate for different types of resources and that no single
3873
+ * format will be appropriate for all types of resources. Therefore,
3874
+ * there is no single default patch document format that implementations
3875
+ * are required to support. Servers MUST ensure that a received patch
3876
+ * document is appropriate for the type of resource identified by the
3877
+ * Request-URI.
3878
+ *
3879
+ * Clients need to choose when to use PATCH rather than PUT. For
3880
+ * example, if the patch document size is larger than the size of the
3881
+ * new resource data that would be used in a PUT, then it might make
3882
+ * sense to use PUT instead of PATCH. A comparison to POST is even more
3883
+ * difficult, because POST is used in widely varying ways and can
3884
+ * encompass PUT and PATCH-like operations if the server chooses. If
3885
+ * the operation does not modify the resource identified by the Request-
3886
+ * URI in a predictable way, POST should be considered instead of PATCH
3887
+ * or PUT.
3888
+ */
501
3889
  PATCH: "PATCH"
502
3890
  };
503
3891
  var http_request_methods_default = HttpRequestMethod;
504
3892
 
505
3893
  // src/http-response-headers.js
506
3894
  var HttpResponseHeader = {
3895
+ /**
3896
+ * Implemented as a misunderstanding of the HTTP specifications. Common because of mistakes in implementations of early HTTP versions. Has exactly the same functionality as standard Connection field.
3897
+ *
3898
+ * @example
3899
+ * proxy-connection: keep-alive
3900
+ */
507
3901
  PROXY_CONNECTION: "proxy-connection",
3902
+ /**
3903
+ * Server-side deep packet insertion of a unique ID identifying customers of Verizon Wireless, also known as "perma-cookie" or "supercookie"
3904
+ *
3905
+ * @example
3906
+ * x-uidh: ...
3907
+ */
508
3908
  X_UIDH: "x-uidh",
3909
+ /**
3910
+ * Used to prevent cross-site request forgery. Alternative header names are: X-CSRFToken and X-XSRF-TOKEN
3911
+ *
3912
+ * @example
3913
+ * x-csrf-token: i8XNjC4b8KVok4uw5RftR38Wgp2BFwql
3914
+ */
509
3915
  X_CSRF_TOKEN: "x-csrf-token",
3916
+ /**
3917
+ * Specifying which web sites can participate in cross-origin resource sharing
3918
+ *
3919
+ * @example
3920
+ * access-control-allow-origin: *
3921
+ * Provisional
3922
+ */
510
3923
  ACCESS_CONTROL_ALLOW_ORIGIN: "access-control-allow-origin",
3924
+ /**
3925
+ * Specifies which patch document formats this server supports
3926
+ *
3927
+ * @example
3928
+ * accept-patch: text/example,charset=utf-8
3929
+ * Permanent
3930
+ */
511
3931
  ACCEPT_PATCH: "accept-patch",
3932
+ /**
3933
+ * What partial content range types this server supports via byte serving
3934
+ *
3935
+ * @example
3936
+ * accept-ranges: bytes
3937
+ * Permanent
3938
+ */
512
3939
  ACCEPT_RANGES: "accept-ranges",
3940
+ /**
3941
+ * The age the object has been in a proxy cache in seconds
3942
+ *
3943
+ * @example
3944
+ * age: 12
3945
+ * Permanent
3946
+ */
513
3947
  AGE: "age",
3948
+ /**
3949
+ * Valid actions for a specified resource. To be used for a 405 Method not allowed
3950
+ *
3951
+ * @example
3952
+ * allow: GET, HEAD
3953
+ * Permanent
3954
+ */
514
3955
  ALLOW: "allow",
3956
+ /**
3957
+ * Tells all caching mechanisms from server to client whether they may cache this object. It is measured in seconds
3958
+ *
3959
+ * @example
3960
+ * cache-control: max-age=3600
3961
+ * Permanent
3962
+ */
515
3963
  CACHE_CONTROL: "cache-control",
3964
+ /**
3965
+ * Control options for the current connection and list of hop-by-hop response fields
3966
+ *
3967
+ * @example
3968
+ * connection: close
3969
+ * Permanent
3970
+ */
516
3971
  CONNECTION: "connection",
3972
+ /**
3973
+ * An opportunity to raise a "File Download" dialogue box for a known MIME type with binary format or suggest a filename for dynamic content. Quotes are necessary with special characters.
3974
+ *
3975
+ * @example
3976
+ * content-disposition: attachment, filename="fname.ext"
3977
+ * Permanent
3978
+ */
517
3979
  CONTENT_DISPOSITION: "content-disposition",
3980
+ /**
3981
+ * The type of encoding used on the data. See HTTP compression.
3982
+ *
3983
+ * @example
3984
+ * content-encoding: gzip
3985
+ * Permanent
3986
+ */
518
3987
  CONTENT_ENCODING: "content-encoding",
3988
+ /**
3989
+ * The natural language or languages of the intended audience for the enclosed content
3990
+ *
3991
+ * @example
3992
+ * content-language: da
3993
+ * Permanent
3994
+ */
519
3995
  CONTENT_LANGUAGE: "content-language",
3996
+ /**
3997
+ * The length of the response body in octets (8-bit bytes)
3998
+ *
3999
+ * @example
4000
+ * content-length: 348
4001
+ * Permanent
4002
+ */
520
4003
  CONTENT_LENGTH: "content-length",
4004
+ /**
4005
+ * An alternate location for the returned data
4006
+ *
4007
+ * @example
4008
+ * content-location: /index.htm
4009
+ * Permanent
4010
+ */
521
4011
  CONTENT_LOCATION: "content-location",
4012
+ /**
4013
+ * Where in a full body message this partial message belongs
4014
+ *
4015
+ * @example
4016
+ * content-range: bytes 21010-47021/47022
4017
+ * Permanent
4018
+ */
522
4019
  CONTENT_RANGE: "content-range",
4020
+ /**
4021
+ * The MIME type of this content
4022
+ *
4023
+ * @example
4024
+ * content-type: text/html, charset=utf-8
4025
+ * Permanent
4026
+ */
523
4027
  CONTENT_TYPE: "content-type",
4028
+ /**
4029
+ * The date and time that the message was sent (in "HTTP-date" format as defined by RFC 7231)
4030
+ *
4031
+ * @example
4032
+ * date: Tue, 15 Nov 1994 08:12:31 GMT
4033
+ * Permanent
4034
+ */
524
4035
  DATE: "date",
4036
+ /**
4037
+ * An identifier for a specific version of a resource, often a message digest
4038
+ *
4039
+ * @example
4040
+ * etag: "737060cd8c284d8af7ad3082f209582d"
4041
+ * Permanent
4042
+ */
525
4043
  ETAG: "etag",
4044
+ /**
4045
+ * Gives the date/time after which the response is considered stale (in "HTTP-date" format as defined by RFC 7231)
4046
+ *
4047
+ * @example
4048
+ * expires: Thu, 01 Dec 1994 16:00:00 GMT
4049
+ * Permanent
4050
+ */
526
4051
  EXPIRES: "expires",
4052
+ /**
4053
+ * The last modified date for the requested object (in "HTTP-date" format as defined by RFC 7231)
4054
+ *
4055
+ * @example
4056
+ * last-modified: Tue, 15 Nov 1994 12:45:26 GMT
4057
+ * Permanent
4058
+ */
527
4059
  LAST_MODIFIED: "last-modified",
4060
+ /**
4061
+ * Used to express a typed relationship with another resource, where the relation type is defined by RFC 5988
4062
+ *
4063
+ * @example
4064
+ * link: </feed>, rel="alternate"
4065
+ * Permanent
4066
+ */
528
4067
  LINK: "link",
4068
+ /**
4069
+ * Used in redirection, or when a new resource has been created.
4070
+ *
4071
+ * @example
4072
+ * location: http://www.w3.org/pub/WWW/People.html
4073
+ * Permanent
4074
+ */
529
4075
  LOCATION: "location",
4076
+ /**
4077
+ * This field is supposed to set P3P policy, in the form of P3P:CP="your_compact_policy". However, P3P did not take off, most browsers have never fully
4078
+ * implemented it, a lot of websites set this field with fake policy text, that was enough to fool browsers the existence of P3P policy and grant permissions for third party cookies.
4079
+ *
4080
+ * @example
4081
+ * p3p: CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info."
4082
+ * Permanent
4083
+ */
530
4084
  P3P: "p3p",
4085
+ /**
4086
+ * Implementation-specific fields that may have various effects anywhere along the request-response chain.
4087
+ *
4088
+ * @example
4089
+ * pragma: no-cache
4090
+ * Permanent
4091
+ */
531
4092
  PRAGMA: "pragma",
4093
+ /**
4094
+ * Request authentication to access the proxy.
4095
+ *
4096
+ * @example
4097
+ * proxy-authenticate: Basic
4098
+ * Permanent
4099
+ */
532
4100
  PROXY_AUTHENTICATION: "proxy-authenticate",
4101
+ /**
4102
+ * HTTP Public Key Pinning, announces hash of website's authentic TLS certificate
4103
+ *
4104
+ * @example
4105
+ * public-key-pins: max-age=2592000, pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=",
4106
+ * Permanent
4107
+ */
533
4108
  PUBLIC_KEY_PINS: "public-key-pins",
4109
+ /**
4110
+ * If an entity is temporarily unavailable, this instructs the client to try again later. Value could be a specified period of time (in seconds) or a HTTP-date.
4111
+ *
4112
+ * @example
4113
+ * retry-after: 120
4114
+ * retry-after: Fri, 07 Nov 2014 23:59:59 GMT
4115
+ * Permanent
4116
+ */
534
4117
  RETRY_AFTER: "retry-after",
4118
+ /**
4119
+ * A name for the server
4120
+ *
4121
+ * @example
4122
+ * server: Apache/2.4.1 (Unix)
4123
+ * Permanent
4124
+ */
535
4125
  SERVER: "server",
4126
+ /**
4127
+ * An HTTP cookie
4128
+ *
4129
+ * @example
4130
+ * set-cookie: UserID=JohnDoe, Max-Age=3600, Version=1
4131
+ * Permanent
4132
+ */
536
4133
  SET_COOKIE: "set-cookie",
4134
+ /**
4135
+ * CGI header field specifying the status of the HTTP response. Normal HTTP responses use a separate "Status-Line" instead, defined by RFC 7230.
4136
+ *
4137
+ * @example
4138
+ * status: 200 OK
4139
+ */
537
4140
  STATUS: "status",
4141
+ /**
4142
+ * A HSTS Policy informing the HTTP client how long to cache the HTTPS only policy and whether this applies to subdomains.
4143
+ *
4144
+ * @example
4145
+ * strict-transport-security: max-age=16070400, includeSubDomains
4146
+ * Permanent
4147
+ */
538
4148
  STRICT_TRANSPORT_SECURITY: "strict-transport-security",
4149
+ /**
4150
+ * The Trailer general field value indicates that the given set of header fields is present in the trailer of a message encoded with chunked transfer coding.
4151
+ *
4152
+ * @example
4153
+ * trailer: Max-Forwards
4154
+ * Permanent
4155
+ */
539
4156
  TRAILER: "trailer",
4157
+ /**
4158
+ * The form of encoding used to safely transfer the entity to the user. Currently defined methods are: chunked, compress, deflate, gzip, identity.
4159
+ *
4160
+ * @example
4161
+ * transfer-encoding: chunked
4162
+ * Permanent
4163
+ */
540
4164
  TRANSFER_ENCODING: "transfer-encoding",
4165
+ /**
4166
+ * Ask the client to upgrade to another protocol.
4167
+ *
4168
+ * @example
4169
+ * upgrade: HTTP/2.0, SHTTP/1.3, IRC/6.9, RTA/x11
4170
+ * Permanent
4171
+ */
541
4172
  UPGRADE: "upgrade",
4173
+ /**
4174
+ * Tells downstream proxies how to match future request headers to decide whether the cached response can be used rather than requesting a fresh one from the origin server.
4175
+ *
4176
+ * @example
4177
+ * vary: *
4178
+ * Permanent
4179
+ */
542
4180
  VARY: "vary",
4181
+ /**
4182
+ * Informs the client of proxies through which the response was sent.
4183
+ *
4184
+ * @example
4185
+ * via: 1.0 fred, 1.1 example.com (Apache/1.1)
4186
+ * Permanent
4187
+ */
543
4188
  VIA: "via",
4189
+ /**
4190
+ * A general warning about possible problems with the entity body.
4191
+ *
4192
+ * @example
4193
+ * warning: 199 Miscellaneous warning
4194
+ * Permanent
4195
+ */
544
4196
  WARNING: "warning",
4197
+ /**
4198
+ * Indicates the authentication scheme that should be used to access the requested entity.
4199
+ *
4200
+ * @example
4201
+ * www-authenticate: Basic
4202
+ * Permanent
4203
+ */
545
4204
  WWW_AUTHENTICATE: "www-authenticate",
4205
+ /**
4206
+ * Cross-site scripting (XSS) filter
4207
+ *
4208
+ * @example
4209
+ * x-xss-protection: 1, mode=block
4210
+ */
546
4211
  X_XSS_PROTECTION: "x-xss-protection",
4212
+ /**
4213
+ * The HTTP Content-Security-Policy response header allows web site administrators to control resources the user agent is allowed
4214
+ * to load for a given page. With a few exceptions, policies mostly involve specifying server origins and script endpoints.
4215
+ * This helps guard against cross-site scripting attacks (Cross-site_scripting).
4216
+ *
4217
+ * @example
4218
+ * content-security-policy: default-src
4219
+ */
547
4220
  CONTENT_SECURITY_POLICY: "content-security-policy",
4221
+ /**
4222
+ * The only defined value, "nosniff", prevents Internet Explorer from MIME-sniffing a response away from the declared content-type. This also applies to Google Chrome, when downloading extensions.
4223
+ *
4224
+ * @example
4225
+ * x-content-type-options: nosniff
4226
+ */
548
4227
  X_CONTENT_TYPE_OPTIONS: "x-content-type-options",
4228
+ /**
4229
+ * specifies the technology (e.g. ASP.NET, PHP, JBoss) supporting the web application (version details are often in X-Runtime, X-Version, or X-AspNet-Version)
4230
+ *
4231
+ * @example
4232
+ * x-powered-by: PHP/5.4.0
4233
+ */
549
4234
  X_POWERED_BY: "x-powered-by"
550
4235
  };
551
4236
  var http_response_headers_default = HttpResponseHeader;
552
4237
 
553
- // src/transportr.js
554
- var HttpError = class extends Error {
4238
+ // src/response-status.js
4239
+ var ResponseStatus = class {
4240
+ /** @type {number} */
4241
+ #code;
4242
+ /** @type {string} */
4243
+ #text;
4244
+ /**
4245
+ *
4246
+ * @param {number} code The status code from the {@link Response}
4247
+ * @param {string} text The status text from the {@link Response}
4248
+ */
4249
+ constructor(code, text) {
4250
+ this.#code = code;
4251
+ this.#text = text;
4252
+ }
4253
+ /**
4254
+ * Returns the status code from the {@link Response}
4255
+ *
4256
+ * @returns {number} The status code.
4257
+ */
4258
+ get code() {
4259
+ return this.#code;
4260
+ }
4261
+ /**
4262
+ * Returns the status text from the {@link Response}.
4263
+ *
4264
+ * @returns {string} The status text.
4265
+ */
4266
+ get text() {
4267
+ return this.#text;
4268
+ }
555
4269
  };
4270
+
4271
+ // src/transportr.js
4272
+ var import_xmldom = __toESM(require_lib(), 1);
556
4273
  var endsWithSlashRegEx = /\/$/;
557
4274
  var _handleText = async (response) => await response.text();
558
4275
  var _handleScript = async (response) => {
559
4276
  const objectURL = URL.createObjectURL(await response.blob());
560
4277
  document.head.removeChild(document.head.appendChild(Object.assign(document.createElement("script"), { src: objectURL, type: http_media_type_default.JAVA_SCRIPT, async: true })));
561
4278
  URL.revokeObjectURL(objectURL);
4279
+ return Promise.resolve();
562
4280
  };
563
4281
  var _handleCss = async (response) => {
564
4282
  const objectURL = URL.createObjectURL(await response.blob());
565
4283
  document.head.appendChild(Object.assign(document.createElement("link"), { href: objectURL, type: http_media_type_default.CSS, rel: "stylesheet" }));
566
4284
  URL.revokeObjectURL(objectURL);
4285
+ return Promise.resolve();
567
4286
  };
568
4287
  var _handleJson = async (response) => await response.json();
569
4288
  var _handleBlob = async (response) => await response.blob();
570
4289
  var _handleImage = async (response) => URL.createObjectURL(await response.blob());
571
4290
  var _handleBuffer = async (response) => await response.arrayBuffer();
572
4291
  var _handleReadableStream = async (response) => response.body;
573
- var _handleXml = async (response) => new DOMParser().parseFromString(await response.text(), Transportr.MediaType.XML.essence);
574
- var _handleHtml = async (response) => new DOMParser().parseFromString(await response.text(), Transportr.MediaType.HTML.essence);
4292
+ var _handleXml = async (response) => new import_xmldom.DOMParser().parseFromString(await response.text(), http_media_type_default.XML.essence);
4293
+ var _handleHtml = async (response) => new import_xmldom.DOMParser().parseFromString(await response.text(), http_media_type_default.HTML.essence);
575
4294
  var _handleHtmlFragment = async (response) => document.createRange().createContextualFragment(await response.text());
576
- var _baseUrl, _options, _contentTypeHandlers, _contentSubtypeHandlers, _defaultRequestOptions, _get, get_fn, _request, request_fn, _createUrl, createUrl_fn, _processResponse, processResponse_fn;
4295
+ var _baseUrl, _options, _contentTypeHandlers, _defaultRequestOptions, _get, get_fn, _request, request_fn, _processResponse, processResponse_fn, _createUrl, createUrl_fn, _needsSerialization, needsSerialization_fn;
577
4296
  var _Transportr = class {
4297
+ /**
4298
+ * Create a new Transportr instance with the provided location or origin and context path.
4299
+ *
4300
+ * @param {URL | string | RequestOptions} [url=location.origin] The URL for {@link fetch} requests.
4301
+ * @param {RequestOptions} [options=Transportr.#defaultRequestOptions] The default {@link RequestOptions} for this instance.
4302
+ */
578
4303
  constructor(url = location.origin, options = __privateGet(_Transportr, _defaultRequestOptions)) {
4304
+ /**
4305
+ * Makes a GET request to the given path, using the given options, and then calls the
4306
+ * given response handler with the response.
4307
+ *
4308
+ * @private
4309
+ * @async
4310
+ * @param {string} path - The path to the endpoint you want to call.
4311
+ * @param {RequestOptions} [userOptions] - The options passed to the public function to use for the request.
4312
+ * @param {RequestOptions} [options] - The options for the request.
4313
+ * @param {ResponseHandler<ResponseBody>} [responseHandler] - A function that will be called with the response object.
4314
+ * @returns {Promise<ResponseBody>} The result of the #request method.
4315
+ */
579
4316
  __privateAdd(this, _get);
4317
+ /**
4318
+ * It takes a path, options, and a response handler, and returns a promise that resolves to the
4319
+ * response entity.
4320
+ *
4321
+ * @private
4322
+ * @async
4323
+ * @param {string} path - The path to the resource you want to access.
4324
+ * @param {RequestOptions} [userOptions={}] - The options passed to the public function to use for the request.
4325
+ * @param {RequestOptions} [options={}] - The options to use for the request.
4326
+ * @param {ResponseHandler<ResponseBody>} [responseHandler] - A function that will be called with the response body as a parameter. This
4327
+ * is useful if you want to do something with the response body before returning it.
4328
+ * @returns {Promise<ResponseBody>} The response from the API call.
4329
+ */
580
4330
  __privateAdd(this, _request);
4331
+ /** @type {URL} */
581
4332
  __privateAdd(this, _baseUrl, void 0);
4333
+ /** @type {RequestOptions} */
582
4334
  __privateAdd(this, _options, void 0);
583
4335
  const type = object_type_default(url);
584
4336
  if (type == Object) {
@@ -590,135 +4342,331 @@ var Transportr = (() => {
590
4342
  __privateSet(this, _baseUrl, url);
591
4343
  __privateSet(this, _options, options);
592
4344
  }
4345
+ /**
4346
+ * It returns the base {@link URL} for the API.
4347
+ *
4348
+ * @returns {URL} The baseUrl property.
4349
+ */
593
4350
  get baseUrl() {
594
4351
  return __privateGet(this, _baseUrl);
595
4352
  }
596
- async get(path, options = {}) {
597
- return __privateMethod(this, _request, request_fn).call(this, path, object_merge_default(options, { method: http_request_methods_default.GET }));
4353
+ /**
4354
+ * This function returns a promise that resolves to the result of a request to the specified path with
4355
+ * the specified options, where the method is GET.
4356
+ *
4357
+ * @async
4358
+ * @param {string} path - The path to the resource you want to get.
4359
+ * @param {RequestOptions} [options] - The options for the request.
4360
+ * @returns {Promise<ResponseBody>} A promise that resolves to the response of the request.
4361
+ */
4362
+ async get(path, options) {
4363
+ return __privateMethod(this, _get, get_fn).call(this, path, options);
598
4364
  }
599
- async post(path, body, options = {}) {
600
- return __privateMethod(this, _request, request_fn).call(this, path, object_merge_default(options, { body, method: http_request_methods_default.POST }));
4365
+ /**
4366
+ * This function makes a POST request to the given path with the given body and options.
4367
+ *
4368
+ * @async
4369
+ * @param {string} path - The path to the endpoint you want to call.
4370
+ * @param {Object} body - The body of the request.
4371
+ * @param {RequestOptions} [options] - The options for the request.
4372
+ * @returns {Promise<ResponseBody>} A promise that resolves to the response body.
4373
+ */
4374
+ async post(path, body, options) {
4375
+ return __privateMethod(this, _request, request_fn).call(this, path, options, { body, method: http_request_methods_default.POST });
601
4376
  }
602
- async put(path, options = {}) {
603
- return __privateMethod(this, _request, request_fn).call(this, path, object_merge_default(options, { method: http_request_methods_default.PUT }));
4377
+ /**
4378
+ * This function returns a promise that resolves to the result of a request to the specified path with
4379
+ * the specified options, where the method is PUT.
4380
+ *
4381
+ * @async
4382
+ * @param {string} path - The path to the endpoint you want to call.
4383
+ * @param {RequestOptions} [options] - The options for the request.
4384
+ * @returns {Promise<ResponseBody>} The return value of the #request method.
4385
+ */
4386
+ async put(path, options) {
4387
+ return __privateMethod(this, _request, request_fn).call(this, path, options, { method: http_request_methods_default.PUT });
604
4388
  }
605
- async patch(path, options = {}) {
606
- return __privateMethod(this, _request, request_fn).call(this, path, object_merge_default(options, { method: http_request_methods_default.PATCH }));
4389
+ /**
4390
+ * It takes a path and options, and returns a request with the method set to PATCH.
4391
+ *
4392
+ * @async
4393
+ * @param {string} path - The path to the endpoint you want to hit.
4394
+ * @param {RequestOptions} [options] - The options for the request.
4395
+ * @returns {Promise<ResponseBody>} A promise that resolves to the response of the request.
4396
+ */
4397
+ async patch(path, options) {
4398
+ return __privateMethod(this, _request, request_fn).call(this, path, options, { method: http_request_methods_default.PATCH });
607
4399
  }
608
- async delete(path, options = {}) {
609
- return __privateMethod(this, _request, request_fn).call(this, path, object_merge_default(options, { method: http_request_methods_default.DELETE }));
4400
+ /**
4401
+ * It takes a path and options, and returns a request with the method set to DELETE.
4402
+ *
4403
+ * @async
4404
+ * @param {string} path - The path to the resource you want to access.
4405
+ * @param {RequestOptions} [options] - The options for the request.
4406
+ * @returns {Promise<ResponseBody>} The result of the request.
4407
+ */
4408
+ async delete(path, options) {
4409
+ return __privateMethod(this, _request, request_fn).call(this, path, options, { method: http_request_methods_default.DELETE });
610
4410
  }
611
- async head(path, options = {}) {
612
- return __privateMethod(this, _request, request_fn).call(this, path, object_merge_default(options, { method: http_request_methods_default.HEAD }));
4411
+ /**
4412
+ * Returns the response headers of a request to the given path.
4413
+ *
4414
+ * @async
4415
+ * @param {string} path - The path to the resource you want to access.
4416
+ * @param {RequestOptions} [options] - The options for the request.
4417
+ * @returns {Promise<ResponseBody>} A promise that resolves to the response object.
4418
+ */
4419
+ async head(path, options) {
4420
+ return __privateMethod(this, _request, request_fn).call(this, path, options, { method: http_request_methods_default.HEAD });
613
4421
  }
614
- async options(path, options = {}) {
615
- return __privateMethod(this, _request, request_fn).call(this, path, object_merge_default(options, { method: http_request_methods_default.OPTIONS }));
4422
+ /**
4423
+ * It takes a path and options, and returns a request with the method set to OPTIONS.
4424
+ *
4425
+ * @async
4426
+ * @param {string} path - The path to the resource.
4427
+ * @param {RequestOptions} [options] - The options for the request.
4428
+ * @returns {Promise<ResponseBody>} The return value of the #request method.
4429
+ */
4430
+ async options(path, options) {
4431
+ return __privateMethod(this, _request, request_fn).call(this, path, options, { method: http_request_methods_default.OPTIONS });
616
4432
  }
617
- async request(path, options = {}) {
4433
+ /**
4434
+ * It takes a path and options, and makes a request to the server.
4435
+ *
4436
+ * @async
4437
+ * @param {string} path - The path to the endpoint you want to hit.
4438
+ * @param {RequestOptions} [options] - The options for the request.
4439
+ * @returns {Promise<ResponseBody>} The return value of the function is the return value of the function that is passed to the `then` method of the promise returned by the `fetch` method.
4440
+ */
4441
+ async request(path, options) {
618
4442
  return __privateMethod(this, _request, request_fn).call(this, path, options);
619
4443
  }
620
- async getJson(path, options = {}) {
621
- return __privateMethod(this, _get, get_fn).call(this, path, object_merge_default(options, { headers: { [http_request_headers_default.ACCEPT]: _Transportr.MediaType.JSON } }), _handleJson);
4444
+ /**
4445
+ * It gets a JSON resource from the server.
4446
+ *
4447
+ * @async
4448
+ * @param {string} path - The path to the resource.
4449
+ * @param {RequestOptions} [options] - The options object to pass to the request.
4450
+ * @returns {Promise<JsonObject>} A promise that resolves to the response body as a JSON object.
4451
+ */
4452
+ async getJson(path, options) {
4453
+ return __privateMethod(this, _get, get_fn).call(this, path, options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.JSON } }, _handleJson);
622
4454
  }
623
- async getXml(path, options = {}) {
624
- return await __privateMethod(this, _get, get_fn).call(this, path, object_merge_default(options, { headers: { [http_request_headers_default.ACCEPT]: _Transportr.MediaType.XML } }), _handleXml);
4455
+ /**
4456
+ * It gets the XML representation of the resource at the given path.
4457
+ *
4458
+ * @async
4459
+ * @param {string} path - The path to the resource you want to get.
4460
+ * @param {RequestOptions} [options] - The options for the request.
4461
+ * @returns {Promise<Document>} The result of the function call to #get.
4462
+ */
4463
+ async getXml(path, options) {
4464
+ return __privateMethod(this, _get, get_fn).call(this, path, options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.XML } }, _handleXml);
625
4465
  }
626
- async getHtml(path, options = {}) {
627
- return __privateMethod(this, _get, get_fn).call(this, path, object_merge_default(options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.HTML } }), _handleHtml);
4466
+ /**
4467
+ * Get the HTML content of the specified path.
4468
+ *
4469
+ * @todo Add way to return portion of the retrieved HTML using a selector. Like jQuery.
4470
+ * @async
4471
+ * @param {string} path - The path to the resource.
4472
+ * @param {RequestOptions} [options] - The options for the request.
4473
+ * @returns {Promise<Document>} The return value of the function is the return value of the function passed to the `then`
4474
+ * method of the promise returned by the `#get` method.
4475
+ */
4476
+ async getHtml(path, options) {
4477
+ return __privateMethod(this, _get, get_fn).call(this, path, options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.HTML } }, _handleHtml);
628
4478
  }
629
- async getHtmlFragment(path, options = {}) {
630
- return __privateMethod(this, _get, get_fn).call(this, path, object_merge_default(options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.HTML } }), _handleHtmlFragment);
4479
+ /**
4480
+ * It returns a promise that resolves to the HTML fragment at the given path.
4481
+ *
4482
+ * @todo - Add way to return portion of the retrieved HTML using a selector. Like jQuery.
4483
+ * @async
4484
+ * @param {string} path - The path to the resource.
4485
+ * @param {RequestOptions} [options] - The options for the request.
4486
+ * @returns {Promise<DocumentFragment>} A promise that resolves to an HTML fragment.
4487
+ */
4488
+ async getHtmlFragment(path, options) {
4489
+ return __privateMethod(this, _get, get_fn).call(this, path, options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.HTML } }, _handleHtmlFragment);
631
4490
  }
632
- async getScript(path, options = {}) {
633
- return __privateMethod(this, _get, get_fn).call(this, path, object_merge_default(options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.JAVA_SCRIPT } }), _handleScript);
4491
+ /**
4492
+ * It gets a script from the server, and appends the script to the {@link Document} {@link HTMLHeadElement}
4493
+ * CORS is enabled by default.
4494
+ *
4495
+ * @async
4496
+ * @param {string} path - The path to the script.
4497
+ * @param {RequestOptions} [options] - The options for the request.
4498
+ * @returns {Promise<void>} A promise that has been resolved.
4499
+ */
4500
+ async getScript(path, options) {
4501
+ return __privateMethod(this, _get, get_fn).call(this, path, options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.JAVA_SCRIPT } }, _handleScript);
634
4502
  }
635
- async getStylesheet(path, options = {}) {
636
- return __privateMethod(this, _get, get_fn).call(this, path, object_merge_default(options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.CSS } }), _handleCss);
4503
+ /**
4504
+ * Gets a stylesheet from the server, and adds it as a {@link Blob} {@link URL}.
4505
+ *
4506
+ * @async
4507
+ * @param {string} path - The path to the stylesheet.
4508
+ * @param {RequestOptions} [options] - The options for the request.
4509
+ * @returns {Promise<void>} A promise that has been resolved.
4510
+ */
4511
+ async getStylesheet(path, options) {
4512
+ return __privateMethod(this, _get, get_fn).call(this, path, options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.CSS } }, _handleCss);
637
4513
  }
638
- async getBlob(path, options = {}) {
639
- return await __privateMethod(this, _get, get_fn).call(this, path, object_merge_default(options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.BIN } }), _handleBlob);
4514
+ /**
4515
+ * It returns a blob from the specified path.
4516
+ *
4517
+ * @async
4518
+ * @param {string} path - The path to the resource.
4519
+ * @param {RequestOptions} [options] - The options for the request.
4520
+ * @returns {Promise<Blob>} A promise that resolves to a blob.
4521
+ */
4522
+ async getBlob(path, options) {
4523
+ return __privateMethod(this, _get, get_fn).call(this, path, options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.BIN } }, _handleBlob);
640
4524
  }
641
- async getImage(path, options = {}) {
642
- return await __privateMethod(this, _get, get_fn).call(this, path, object_merge_default(options, { headers: { [http_request_headers_default.ACCEPT]: "image/*" } }), _handleBlob);
4525
+ /**
4526
+ * It returns a promise that resolves to an object URL.
4527
+ *
4528
+ * @async
4529
+ * @param {string} path - The path to the resource.
4530
+ * @param {RequestOptions} [options] - The options for the request.
4531
+ * @returns {Promise<string>} A promise that resolves to an object URL.
4532
+ */
4533
+ async getImage(path, options) {
4534
+ return __privateMethod(this, _get, get_fn).call(this, path, options, { headers: { [http_request_headers_default.ACCEPT]: "image/*" } }, _handleImage);
643
4535
  }
644
- async getBuffer(path, options = {}) {
645
- return await __privateMethod(this, _get, get_fn).call(this, path, object_merge_default(options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.BIN } }), _handleBuffer);
4536
+ /**
4537
+ * It gets a buffer from the specified path
4538
+ *
4539
+ * @async
4540
+ * @param {string} path - The path to the resource.
4541
+ * @param {RequestOptions} [options] - The options for the request.
4542
+ * @returns {Promise<ArrayBuffer>} A promise that resolves to a buffer.
4543
+ */
4544
+ async getBuffer(path, options) {
4545
+ return __privateMethod(this, _get, get_fn).call(this, path, options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.BIN } }, _handleBuffer);
646
4546
  }
647
- async getStream(path, options = {}) {
648
- return await __privateMethod(this, _get, get_fn).call(this, path, object_merge_default(options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.BIN } }), _handleReadableStream);
4547
+ /**
4548
+ * It returns a readable stream of the response body from the specified path.
4549
+ *
4550
+ * @async
4551
+ * @param {string} path - The path to the resource.
4552
+ * @param {RequestOptions} [options] - The options for the request.
4553
+ * @returns {Promise<ReadableStream<Uint8Array>>} A readable stream.
4554
+ */
4555
+ async getStream(path, options) {
4556
+ return __privateMethod(this, _get, get_fn).call(this, path, options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.BIN } }, _handleReadableStream);
649
4557
  }
650
4558
  };
651
4559
  var Transportr = _Transportr;
652
4560
  _baseUrl = new WeakMap();
653
4561
  _options = new WeakMap();
654
4562
  _contentTypeHandlers = new WeakMap();
655
- _contentSubtypeHandlers = new WeakMap();
656
4563
  _defaultRequestOptions = new WeakMap();
657
4564
  _get = new WeakSet();
658
- get_fn = async function(path, options, responseHandler) {
659
- return __privateMethod(this, _request, request_fn).call(this, path, object_merge_default(options, { method: _Transportr.Method.GET }), responseHandler);
4565
+ get_fn = async function(path, userOptions, options, responseHandler) {
4566
+ return __privateMethod(this, _request, request_fn).call(this, path, userOptions, options, responseHandler);
660
4567
  };
661
4568
  _request = new WeakSet();
662
- request_fn = async function(path, options, responseHandler) {
663
- var _a, _b;
664
- const requestOptions = object_merge_default(__privateGet(this, _options), options);
665
- const headers = new Headers(requestOptions.headers);
4569
+ request_fn = async function(path, userOptions = {}, options = {}, responseHandler) {
4570
+ var _a, _b, _c, _d;
4571
+ if (object_type_default(userOptions.headers) == Headers) {
4572
+ userOptions.headers = Object.fromEntries(userOptions.headers.entries());
4573
+ }
4574
+ const requestOptions = object_merge_default(__privateGet(this, _options), userOptions, options);
4575
+ requestOptions.headers = new Headers(requestOptions.headers);
666
4576
  const errorMessage = `An error has occurred with your Request: ${path}`;
667
- if (headers.get(_Transportr.RequestHeader.CONTENT_TYPE) == _Transportr.MediaType.JSON) {
4577
+ if (__privateMethod(_a = _Transportr, _needsSerialization, needsSerialization_fn).call(_a, requestOptions.method, requestOptions.headers.get(http_request_headers_default.CONTENT_TYPE))) {
668
4578
  requestOptions.body = JSON.stringify(requestOptions.body);
669
4579
  }
4580
+ if (requestOptions.searchParams && !(requestOptions.searchParams instanceof URLSearchParams)) {
4581
+ requestOptions.searchParams = new URLSearchParams(requestOptions.searchParams);
4582
+ }
670
4583
  let response;
671
4584
  try {
672
- response = await fetch(__privateMethod(_a = _Transportr, _createUrl, createUrl_fn).call(_a, __privateGet(this, _baseUrl), path, requestOptions.searchParams), requestOptions);
4585
+ response = await fetch(__privateMethod(_b = _Transportr, _createUrl, createUrl_fn).call(_b, __privateGet(this, _baseUrl), path, requestOptions.searchParams), requestOptions);
673
4586
  } catch (error) {
674
4587
  console.error(errorMessage, error);
675
- throw new HttpError(errorMessage);
4588
+ throw new HttpError(errorMessage, { cause: error, status: new ResponseStatus(response.status, response.statusText) });
676
4589
  }
677
4590
  if (!response.ok) {
678
- throw new HttpError(`${errorMessage}. Response: ${response.status} - ${await response.text()}`);
4591
+ throw new HttpError(errorMessage, { status: new ResponseStatus(response.status, response.statusText), entity: await __privateMethod(_c = _Transportr, _processResponse, processResponse_fn).call(_c, response) });
679
4592
  }
4593
+ return await __privateMethod(_d = _Transportr, _processResponse, processResponse_fn).call(_d, response, responseHandler);
4594
+ };
4595
+ _processResponse = new WeakSet();
4596
+ processResponse_fn = async function(response, handler) {
680
4597
  try {
681
- return await (responseHandler ? responseHandler(response) : __privateMethod(_b = _Transportr, _processResponse, processResponse_fn).call(_b, response));
4598
+ if (!handler) {
4599
+ const mediaType = new MediaType(response.headers.get(http_response_headers_default.CONTENT_TYPE));
4600
+ if (mediaType) {
4601
+ for (const [responseHandler, contentTypes] of __privateGet(_Transportr, _contentTypeHandlers)) {
4602
+ if (contentTypes.has(mediaType.type) || contentTypes.has(mediaType.subtype)) {
4603
+ handler = responseHandler;
4604
+ break;
4605
+ }
4606
+ }
4607
+ }
4608
+ }
4609
+ return (handler ?? _handleText)(response);
682
4610
  } catch (error) {
683
- console.error(errorMessage, error);
684
- throw new HttpError(errorMessage);
4611
+ const errorMessage = "Unable to process response.";
4612
+ console.error(errorMessage, error, response);
4613
+ throw new HttpError(errorMessage, { cause: error });
685
4614
  }
686
4615
  };
687
4616
  _createUrl = new WeakSet();
688
- createUrl_fn = function(url, path, searchParams = {}) {
4617
+ createUrl_fn = function(url, path, searchParams = new URLSearchParams()) {
689
4618
  url = path.startsWith("/") ? new URL(`${url.pathname.replace(endsWithSlashRegEx, "")}${path}`, url.origin) : new URL(path);
690
- for (const [name, value] of Object.entries(searchParams)) {
691
- if (Array.isArray(value)) {
692
- value.forEach((v) => url.searchParams.set(name, v));
693
- } else {
694
- url.searchParams.append(name, value);
695
- }
696
- }
4619
+ searchParams.forEach(([name, value]) => url.searchParams.append(name, value));
697
4620
  return url;
698
4621
  };
699
- _processResponse = new WeakSet();
700
- processResponse_fn = async function(response) {
701
- const mediaType = new MediaType(response.headers.get(http_response_headers_default.CONTENT_TYPE));
702
- for (const [responseHandler, contentTypes] of __privateGet(_Transportr, _contentSubtypeHandlers).entries()) {
703
- if (contentTypes.has(mediaType.subtype)) {
704
- return await responseHandler(response);
705
- }
706
- }
707
- for (const [responseHandler, contentTypes] of __privateGet(_Transportr, _contentTypeHandlers).entries()) {
708
- if (contentTypes.has(mediaType.type)) {
709
- return await responseHandler(response);
710
- }
711
- }
712
- console.warn("Unable to process response. Unknown content-type or no response handler defined.");
713
- return response;
4622
+ _needsSerialization = new WeakSet();
4623
+ needsSerialization_fn = function(method, contentType) {
4624
+ return contentType == http_media_type_default.JSON && [http_request_methods_default.POST, http_request_methods_default.PUT, http_request_methods_default.PATCH].includes(method);
714
4625
  };
715
- __privateAdd(Transportr, _createUrl);
4626
+ /**
4627
+ * It takes a response and a handler, and if the handler is not defined, it tries to find a handler
4628
+ * based on the response's content type
4629
+ *
4630
+ * @private
4631
+ * @static
4632
+ * @async
4633
+ * @param {Response} response - The response object returned by the fetch API.
4634
+ * @param {ResponseHandler<ResponseBody>} [handler] - The handler to use for processing the response.
4635
+ * @returns {Promise<ResponseBody>} The response is being returned.
4636
+ */
716
4637
  __privateAdd(Transportr, _processResponse);
4638
+ /**
4639
+ * It takes a URL, a path, and a set of search parameters, and returns a new URL with the path and
4640
+ * search parameters applied.
4641
+ *
4642
+ * @private
4643
+ * @static
4644
+ * @param {URL} url - The URL to use as a base.
4645
+ * @param {string} path - The path to the resource. This can be a relative path or a full URL.
4646
+ * @param {URLSearchParams} [searchParams=new URLSearchParams()] - An object containing the query parameters to be added to the URL.
4647
+ * @returns {URL} A new URL object with the pathname and origin of the url parameter, and the path parameter
4648
+ * appended to the end of the pathname.
4649
+ */
4650
+ __privateAdd(Transportr, _createUrl);
4651
+ /**
4652
+ * If the request method is POST, PUT, or PATCH, and the content type is JSON, then the request body
4653
+ * needs to be serialized.
4654
+ *
4655
+ * @private
4656
+ * @static
4657
+ * @param {RequestMethod} method - The HTTP request method.
4658
+ * @param {HttpMediaType} contentType - The headers of the request.
4659
+ * @returns {boolean} `true` if the request body needs to be serialized, `false` otherwise.
4660
+ */
4661
+ __privateAdd(Transportr, _needsSerialization);
4662
+ /**
4663
+ * @private
4664
+ * @static
4665
+ * @type {SetMultiMap<ResponseHandler<ResponseBody>, string>}
4666
+ */
717
4667
  __privateAdd(Transportr, _contentTypeHandlers, new SetMultiMap([
718
4668
  [_handleImage, new MediaType(http_media_type_default.PNG).type],
719
- [_handleText, new MediaType(http_media_type_default.TEXT).type]
720
- ]));
721
- __privateAdd(Transportr, _contentSubtypeHandlers, new SetMultiMap([
4669
+ [_handleText, new MediaType(http_media_type_default.TEXT).type],
722
4670
  [_handleJson, new MediaType(http_media_type_default.JSON).subtype],
723
4671
  [_handleHtml, new MediaType(http_media_type_default.HTML).subtype],
724
4672
  [_handleScript, new MediaType(http_media_type_default.JAVA_SCRIPT).subtype],
@@ -726,35 +4674,72 @@ var Transportr = (() => {
726
4674
  [_handleXml, new MediaType(http_media_type_default.XML).subtype],
727
4675
  [_handleReadableStream, new MediaType(http_media_type_default.BIN).subtype]
728
4676
  ]));
4677
+ /**
4678
+ * @static
4679
+ * @constant {Object<string, HttpRequestMethod>}
4680
+ */
729
4681
  __publicField(Transportr, "Method", Object.freeze(http_request_methods_default));
730
- __publicField(Transportr, "MediaType", http_media_type_default);
731
- __publicField(Transportr, "RequestHeader", http_request_headers_default);
4682
+ /**
4683
+ * @static
4684
+ * @constant {Object<string, HttpMediaType>}
4685
+ */
4686
+ __publicField(Transportr, "MediaType", Object.freeze(http_media_type_default));
4687
+ /**
4688
+ * @static
4689
+ * @see {@link HttpRequestHeader}
4690
+ * @constant {Object<string, HttpRequestHeader>}
4691
+ */
4692
+ __publicField(Transportr, "RequestHeader", Object.freeze(http_request_headers_default));
4693
+ /**
4694
+ * @static
4695
+ * @constant {Object<string, HttpResponseHeader>}
4696
+ */
732
4697
  __publicField(Transportr, "ResponseHeader", Object.freeze(http_response_headers_default));
733
- __publicField(Transportr, "CachingPolicy", {
4698
+ /**
4699
+ * @static
4700
+ * @constant {Object<string, RequestCache>}
4701
+ */
4702
+ __publicField(Transportr, "CachingPolicy", Object.freeze({
734
4703
  DEFAULT: "default",
735
4704
  FORCE_CACHE: "force-cache",
736
4705
  NO_CACHE: "no-cache",
737
4706
  NO_STORE: "no-store",
738
4707
  ONLY_IF_CACHED: "only-if-cached",
739
4708
  RELOAD: "reload"
740
- });
741
- __publicField(Transportr, "CredentialsPolicy", {
4709
+ }));
4710
+ /**
4711
+ * @static
4712
+ * @constant {Object<string, RequestCredentials>}
4713
+ */
4714
+ __publicField(Transportr, "CredentialsPolicy", Object.freeze({
742
4715
  INCLUDE: "include",
743
4716
  OMIT: "omit",
744
4717
  SAME_ORIGIN: "same-origin"
745
- });
746
- __publicField(Transportr, "RequestMode", {
4718
+ }));
4719
+ /**
4720
+ * @static
4721
+ * @constant {Object<string, RequestMode>}
4722
+ */
4723
+ __publicField(Transportr, "RequestMode", Object.freeze({
747
4724
  CORS: "cors",
748
4725
  NAVIGATE: "navigate",
749
4726
  NO_CORS: "no-cors",
750
4727
  SAME_ORIGIN: "same-origin"
751
- });
752
- __publicField(Transportr, "RedirectPolicy", {
4728
+ }));
4729
+ /**
4730
+ * @static
4731
+ * @constant {Object<string, RequestRedirect>}
4732
+ */
4733
+ __publicField(Transportr, "RedirectPolicy", Object.freeze({
753
4734
  ERROR: "error",
754
4735
  FOLLOW: "follow",
755
4736
  MANUAL: "manual"
756
- });
757
- __publicField(Transportr, "ReferrerPolicy", {
4737
+ }));
4738
+ /**
4739
+ * @static
4740
+ * @constant {Object<string, ReferrerPolicy>}
4741
+ */
4742
+ __publicField(Transportr, "ReferrerPolicy", Object.freeze({
758
4743
  NO_REFERRER: "no-referrer",
759
4744
  NO_REFERRER_WHEN_DOWNGRADE: "no-referrer-when-downgrade",
760
4745
  ORIGIN: "origin",
@@ -763,22 +4748,27 @@ var Transportr = (() => {
763
4748
  STRICT_ORIGIN: "strict-origin",
764
4749
  STRICT_ORIGIN_WHEN_CROSS_ORIGIN: "strict-origin-when-cross-origin",
765
4750
  UNSAFE_URL: "unsafe-url"
766
- });
767
- __privateAdd(Transportr, _defaultRequestOptions, {
4751
+ }));
4752
+ /**
4753
+ * @private
4754
+ * @static
4755
+ * @type {RequestOptions}
4756
+ */
4757
+ __privateAdd(Transportr, _defaultRequestOptions, Object.freeze({
768
4758
  body: null,
769
4759
  cache: _Transportr.CachingPolicy.NO_STORE,
770
4760
  credentials: _Transportr.CredentialsPolicy.SAME_ORIGIN,
771
4761
  headers: {},
772
4762
  integrity: void 0,
773
4763
  keepalive: void 0,
774
- method: void 0,
4764
+ method: http_request_methods_default.GET,
775
4765
  mode: _Transportr.RequestMode.CORS,
776
4766
  redirect: _Transportr.RedirectPolicy.FOLLOW,
777
4767
  referrer: "about:client",
778
4768
  referrerPolicy: _Transportr.ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN,
779
4769
  signal: null,
780
4770
  window: null
781
- });
4771
+ }));
782
4772
  return __toCommonJS(transportr_exports);
783
4773
  })();
784
4774
  window.Transportr = Transportr.default;