@loaders.gl/textures 4.0.0-alpha.6 → 4.0.0-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/basis-loader.d.ts.map +1 -1
  2. package/dist/basis-loader.js +1 -3
  3. package/dist/{basis-nodejs-worker.js → basis-worker-node.js} +370 -2708
  4. package/dist/basis-worker.js +4 -4
  5. package/dist/compressed-texture-worker.js +3 -3
  6. package/dist/crunch-worker.js +2 -2
  7. package/dist/dist.min.js +114 -117
  8. package/dist/es5/basis-loader.js +1 -2
  9. package/dist/es5/basis-loader.js.map +1 -1
  10. package/dist/es5/index.js +1 -2
  11. package/dist/es5/index.js.map +1 -1
  12. package/dist/es5/lib/parsers/basis-module-loader.js +1 -1
  13. package/dist/es5/lib/utils/version.js +1 -1
  14. package/dist/es5/workers/{basis-nodejs-worker.js → basis-worker-node.js} +2 -2
  15. package/dist/es5/workers/basis-worker-node.js.map +1 -0
  16. package/dist/es5/workers/{ktx2-basis-writer-nodejs-worker.js → ktx2-basis-writer-worker-node.js} +5 -4
  17. package/dist/es5/workers/ktx2-basis-writer-worker-node.js.map +1 -0
  18. package/dist/esm/basis-loader.js +1 -2
  19. package/dist/esm/basis-loader.js.map +1 -1
  20. package/dist/esm/index.js +1 -2
  21. package/dist/esm/index.js.map +1 -1
  22. package/dist/esm/lib/parsers/basis-module-loader.js +1 -1
  23. package/dist/esm/lib/utils/version.js +1 -1
  24. package/dist/esm/workers/{basis-nodejs-worker.js → basis-worker-node.js} +2 -2
  25. package/dist/esm/workers/basis-worker-node.js.map +1 -0
  26. package/dist/esm/workers/{ktx2-basis-writer-nodejs-worker.js → ktx2-basis-writer-worker-node.js} +5 -4
  27. package/dist/esm/workers/ktx2-basis-writer-worker-node.js.map +1 -0
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +1 -2
  30. package/dist/{ktx2-basis-writer-nodejs-worker.js → ktx2-basis-writer-worker-node.js} +296 -2634
  31. package/dist/ktx2-basis-writer-worker.js +3 -3
  32. package/dist/npy-worker.js +1 -1
  33. package/dist/workers/basis-worker-node.d.ts +2 -0
  34. package/dist/workers/basis-worker-node.d.ts.map +1 -0
  35. package/dist/workers/{basis-nodejs-worker.js → basis-worker-node.js} +2 -1
  36. package/dist/workers/ktx2-basis-writer-worker-node.d.ts +2 -0
  37. package/dist/workers/ktx2-basis-writer-worker-node.d.ts.map +1 -0
  38. package/dist/workers/{ktx2-basis-writer-nodejs-worker.js → ktx2-basis-writer-worker-node.js} +4 -2
  39. package/package.json +17 -17
  40. package/src/basis-loader.ts +1 -3
  41. package/src/index.ts +1 -2
  42. package/src/workers/{basis-nodejs-worker.ts → basis-worker-node.ts} +2 -1
  43. package/src/workers/{ktx2-basis-writer-nodejs-worker.ts → ktx2-basis-writer-worker-node.ts} +4 -2
  44. package/dist/es5/ktx2-basis-writer-nodejs.js +0 -14
  45. package/dist/es5/ktx2-basis-writer-nodejs.js.map +0 -1
  46. package/dist/es5/workers/basis-nodejs-worker.js.map +0 -1
  47. package/dist/es5/workers/ktx2-basis-writer-nodejs-worker.js.map +0 -1
  48. package/dist/esm/ktx2-basis-writer-nodejs.js +0 -3
  49. package/dist/esm/ktx2-basis-writer-nodejs.js.map +0 -1
  50. package/dist/esm/workers/basis-nodejs-worker.js.map +0 -1
  51. package/dist/esm/workers/ktx2-basis-writer-nodejs-worker.js.map +0 -1
  52. package/dist/ktx2-basis-writer-nodejs.d.ts +0 -3
  53. package/dist/ktx2-basis-writer-nodejs.d.ts.map +0 -1
  54. package/dist/ktx2-basis-writer-nodejs.js +0 -7
  55. package/dist/workers/basis-nodejs-worker.d.ts +0 -2
  56. package/dist/workers/basis-nodejs-worker.d.ts.map +0 -1
  57. package/dist/workers/ktx2-basis-writer-nodejs-worker.d.ts +0 -2
  58. package/dist/workers/ktx2-basis-writer-nodejs-worker.d.ts.map +0 -1
  59. package/src/ktx2-basis-writer-nodejs.ts +0 -4
@@ -42,2338 +42,6 @@ var __toModule = (module2) => {
42
42
  return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
43
43
  };
44
44
 
45
- // ../../node_modules/@xmldom/xmldom/lib/conventions.js
46
- var require_conventions = __commonJS({
47
- "../../node_modules/@xmldom/xmldom/lib/conventions.js"(exports2) {
48
- "use strict";
49
- function find(list, predicate, ac) {
50
- if (ac === void 0) {
51
- ac = Array.prototype;
52
- }
53
- if (list && typeof ac.find === "function") {
54
- return ac.find.call(list, predicate);
55
- }
56
- for (var i = 0; i < list.length; i++) {
57
- if (Object.prototype.hasOwnProperty.call(list, i)) {
58
- var item = list[i];
59
- if (predicate.call(void 0, item, i, list)) {
60
- return item;
61
- }
62
- }
63
- }
64
- }
65
- function freeze(object, oc) {
66
- if (oc === void 0) {
67
- oc = Object;
68
- }
69
- return oc && typeof oc.freeze === "function" ? oc.freeze(object) : object;
70
- }
71
- var MIME_TYPE = freeze({
72
- HTML: "text/html",
73
- isHTML: function(value) {
74
- return value === MIME_TYPE.HTML;
75
- },
76
- XML_APPLICATION: "application/xml",
77
- XML_TEXT: "text/xml",
78
- XML_XHTML_APPLICATION: "application/xhtml+xml",
79
- XML_SVG_IMAGE: "image/svg+xml"
80
- });
81
- var NAMESPACE = freeze({
82
- HTML: "http://www.w3.org/1999/xhtml",
83
- isHTML: function(uri) {
84
- return uri === NAMESPACE.HTML;
85
- },
86
- SVG: "http://www.w3.org/2000/svg",
87
- XML: "http://www.w3.org/XML/1998/namespace",
88
- XMLNS: "http://www.w3.org/2000/xmlns/"
89
- });
90
- exports2.find = find;
91
- exports2.freeze = freeze;
92
- exports2.MIME_TYPE = MIME_TYPE;
93
- exports2.NAMESPACE = NAMESPACE;
94
- }
95
- });
96
-
97
- // ../../node_modules/@xmldom/xmldom/lib/dom.js
98
- var require_dom = __commonJS({
99
- "../../node_modules/@xmldom/xmldom/lib/dom.js"(exports2) {
100
- var conventions = require_conventions();
101
- var find = conventions.find;
102
- var NAMESPACE = conventions.NAMESPACE;
103
- function notEmptyString(input) {
104
- return input !== "";
105
- }
106
- function splitOnASCIIWhitespace(input) {
107
- return input ? input.split(/[\t\n\f\r ]+/).filter(notEmptyString) : [];
108
- }
109
- function orderedSetReducer(current, element) {
110
- if (!current.hasOwnProperty(element)) {
111
- current[element] = true;
112
- }
113
- return current;
114
- }
115
- function toOrderedSet(input) {
116
- if (!input)
117
- return [];
118
- var list = splitOnASCIIWhitespace(input);
119
- return Object.keys(list.reduce(orderedSetReducer, {}));
120
- }
121
- function arrayIncludes(list) {
122
- return function(element) {
123
- return list && list.indexOf(element) !== -1;
124
- };
125
- }
126
- function copy(src, dest) {
127
- for (var p in src) {
128
- if (Object.prototype.hasOwnProperty.call(src, p)) {
129
- dest[p] = src[p];
130
- }
131
- }
132
- }
133
- function _extends(Class, Super) {
134
- var pt = Class.prototype;
135
- if (!(pt instanceof Super)) {
136
- let t2 = function() {
137
- };
138
- var t = t2;
139
- ;
140
- t2.prototype = Super.prototype;
141
- t2 = new t2();
142
- copy(pt, t2);
143
- Class.prototype = pt = t2;
144
- }
145
- if (pt.constructor != Class) {
146
- if (typeof Class != "function") {
147
- console.error("unknown Class:" + Class);
148
- }
149
- pt.constructor = Class;
150
- }
151
- }
152
- var NodeType = {};
153
- var ELEMENT_NODE = NodeType.ELEMENT_NODE = 1;
154
- var ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2;
155
- var TEXT_NODE = NodeType.TEXT_NODE = 3;
156
- var CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4;
157
- var ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5;
158
- var ENTITY_NODE = NodeType.ENTITY_NODE = 6;
159
- var PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7;
160
- var COMMENT_NODE = NodeType.COMMENT_NODE = 8;
161
- var DOCUMENT_NODE = NodeType.DOCUMENT_NODE = 9;
162
- var DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10;
163
- var DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11;
164
- var NOTATION_NODE = NodeType.NOTATION_NODE = 12;
165
- var ExceptionCode = {};
166
- var ExceptionMessage = {};
167
- var INDEX_SIZE_ERR = ExceptionCode.INDEX_SIZE_ERR = (ExceptionMessage[1] = "Index size error", 1);
168
- var DOMSTRING_SIZE_ERR = ExceptionCode.DOMSTRING_SIZE_ERR = (ExceptionMessage[2] = "DOMString size error", 2);
169
- var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = (ExceptionMessage[3] = "Hierarchy request error", 3);
170
- var WRONG_DOCUMENT_ERR = ExceptionCode.WRONG_DOCUMENT_ERR = (ExceptionMessage[4] = "Wrong document", 4);
171
- var INVALID_CHARACTER_ERR = ExceptionCode.INVALID_CHARACTER_ERR = (ExceptionMessage[5] = "Invalid character", 5);
172
- var NO_DATA_ALLOWED_ERR = ExceptionCode.NO_DATA_ALLOWED_ERR = (ExceptionMessage[6] = "No data allowed", 6);
173
- var NO_MODIFICATION_ALLOWED_ERR = ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = (ExceptionMessage[7] = "No modification allowed", 7);
174
- var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = (ExceptionMessage[8] = "Not found", 8);
175
- var NOT_SUPPORTED_ERR = ExceptionCode.NOT_SUPPORTED_ERR = (ExceptionMessage[9] = "Not supported", 9);
176
- var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = (ExceptionMessage[10] = "Attribute in use", 10);
177
- var INVALID_STATE_ERR = ExceptionCode.INVALID_STATE_ERR = (ExceptionMessage[11] = "Invalid state", 11);
178
- var SYNTAX_ERR = ExceptionCode.SYNTAX_ERR = (ExceptionMessage[12] = "Syntax error", 12);
179
- var INVALID_MODIFICATION_ERR = ExceptionCode.INVALID_MODIFICATION_ERR = (ExceptionMessage[13] = "Invalid modification", 13);
180
- var NAMESPACE_ERR = ExceptionCode.NAMESPACE_ERR = (ExceptionMessage[14] = "Invalid namespace", 14);
181
- var INVALID_ACCESS_ERR = ExceptionCode.INVALID_ACCESS_ERR = (ExceptionMessage[15] = "Invalid access", 15);
182
- function DOMException2(code, message) {
183
- if (message instanceof Error) {
184
- var error = message;
185
- } else {
186
- error = this;
187
- Error.call(this, ExceptionMessage[code]);
188
- this.message = ExceptionMessage[code];
189
- if (Error.captureStackTrace)
190
- Error.captureStackTrace(this, DOMException2);
191
- }
192
- error.code = code;
193
- if (message)
194
- this.message = this.message + ": " + message;
195
- return error;
196
- }
197
- DOMException2.prototype = Error.prototype;
198
- copy(ExceptionCode, DOMException2);
199
- function NodeList() {
200
- }
201
- NodeList.prototype = {
202
- length: 0,
203
- item: function(index2) {
204
- return this[index2] || null;
205
- },
206
- toString: function(isHTML, nodeFilter) {
207
- for (var buf = [], i = 0; i < this.length; i++) {
208
- serializeToString(this[i], buf, isHTML, nodeFilter);
209
- }
210
- return buf.join("");
211
- },
212
- filter: function(predicate) {
213
- return Array.prototype.filter.call(this, predicate);
214
- },
215
- indexOf: function(item) {
216
- return Array.prototype.indexOf.call(this, item);
217
- }
218
- };
219
- function LiveNodeList(node, refresh) {
220
- this._node = node;
221
- this._refresh = refresh;
222
- _updateLiveList(this);
223
- }
224
- function _updateLiveList(list) {
225
- var inc = list._node._inc || list._node.ownerDocument._inc;
226
- if (list._inc != inc) {
227
- var ls = list._refresh(list._node);
228
- __set__(list, "length", ls.length);
229
- copy(ls, list);
230
- list._inc = inc;
231
- }
232
- }
233
- LiveNodeList.prototype.item = function(i) {
234
- _updateLiveList(this);
235
- return this[i];
236
- };
237
- _extends(LiveNodeList, NodeList);
238
- function NamedNodeMap() {
239
- }
240
- function _findNodeIndex(list, node) {
241
- var i = list.length;
242
- while (i--) {
243
- if (list[i] === node) {
244
- return i;
245
- }
246
- }
247
- }
248
- function _addNamedNode(el, list, newAttr, oldAttr) {
249
- if (oldAttr) {
250
- list[_findNodeIndex(list, oldAttr)] = newAttr;
251
- } else {
252
- list[list.length++] = newAttr;
253
- }
254
- if (el) {
255
- newAttr.ownerElement = el;
256
- var doc = el.ownerDocument;
257
- if (doc) {
258
- oldAttr && _onRemoveAttribute(doc, el, oldAttr);
259
- _onAddAttribute(doc, el, newAttr);
260
- }
261
- }
262
- }
263
- function _removeNamedNode(el, list, attr) {
264
- var i = _findNodeIndex(list, attr);
265
- if (i >= 0) {
266
- var lastIndex = list.length - 1;
267
- while (i < lastIndex) {
268
- list[i] = list[++i];
269
- }
270
- list.length = lastIndex;
271
- if (el) {
272
- var doc = el.ownerDocument;
273
- if (doc) {
274
- _onRemoveAttribute(doc, el, attr);
275
- attr.ownerElement = null;
276
- }
277
- }
278
- } else {
279
- throw new DOMException2(NOT_FOUND_ERR, new Error(el.tagName + "@" + attr));
280
- }
281
- }
282
- NamedNodeMap.prototype = {
283
- length: 0,
284
- item: NodeList.prototype.item,
285
- getNamedItem: function(key) {
286
- var i = this.length;
287
- while (i--) {
288
- var attr = this[i];
289
- if (attr.nodeName == key) {
290
- return attr;
291
- }
292
- }
293
- },
294
- setNamedItem: function(attr) {
295
- var el = attr.ownerElement;
296
- if (el && el != this._ownerElement) {
297
- throw new DOMException2(INUSE_ATTRIBUTE_ERR);
298
- }
299
- var oldAttr = this.getNamedItem(attr.nodeName);
300
- _addNamedNode(this._ownerElement, this, attr, oldAttr);
301
- return oldAttr;
302
- },
303
- setNamedItemNS: function(attr) {
304
- var el = attr.ownerElement, oldAttr;
305
- if (el && el != this._ownerElement) {
306
- throw new DOMException2(INUSE_ATTRIBUTE_ERR);
307
- }
308
- oldAttr = this.getNamedItemNS(attr.namespaceURI, attr.localName);
309
- _addNamedNode(this._ownerElement, this, attr, oldAttr);
310
- return oldAttr;
311
- },
312
- removeNamedItem: function(key) {
313
- var attr = this.getNamedItem(key);
314
- _removeNamedNode(this._ownerElement, this, attr);
315
- return attr;
316
- },
317
- removeNamedItemNS: function(namespaceURI, localName) {
318
- var attr = this.getNamedItemNS(namespaceURI, localName);
319
- _removeNamedNode(this._ownerElement, this, attr);
320
- return attr;
321
- },
322
- getNamedItemNS: function(namespaceURI, localName) {
323
- var i = this.length;
324
- while (i--) {
325
- var node = this[i];
326
- if (node.localName == localName && node.namespaceURI == namespaceURI) {
327
- return node;
328
- }
329
- }
330
- return null;
331
- }
332
- };
333
- function DOMImplementation() {
334
- }
335
- DOMImplementation.prototype = {
336
- hasFeature: function(feature, version) {
337
- return true;
338
- },
339
- createDocument: function(namespaceURI, qualifiedName, doctype) {
340
- var doc = new Document();
341
- doc.implementation = this;
342
- doc.childNodes = new NodeList();
343
- doc.doctype = doctype || null;
344
- if (doctype) {
345
- doc.appendChild(doctype);
346
- }
347
- if (qualifiedName) {
348
- var root = doc.createElementNS(namespaceURI, qualifiedName);
349
- doc.appendChild(root);
350
- }
351
- return doc;
352
- },
353
- createDocumentType: function(qualifiedName, publicId, systemId) {
354
- var node = new DocumentType();
355
- node.name = qualifiedName;
356
- node.nodeName = qualifiedName;
357
- node.publicId = publicId || "";
358
- node.systemId = systemId || "";
359
- return node;
360
- }
361
- };
362
- function Node() {
363
- }
364
- Node.prototype = {
365
- firstChild: null,
366
- lastChild: null,
367
- previousSibling: null,
368
- nextSibling: null,
369
- attributes: null,
370
- parentNode: null,
371
- childNodes: null,
372
- ownerDocument: null,
373
- nodeValue: null,
374
- namespaceURI: null,
375
- prefix: null,
376
- localName: null,
377
- insertBefore: function(newChild, refChild) {
378
- return _insertBefore(this, newChild, refChild);
379
- },
380
- replaceChild: function(newChild, oldChild) {
381
- _insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument);
382
- if (oldChild) {
383
- this.removeChild(oldChild);
384
- }
385
- },
386
- removeChild: function(oldChild) {
387
- return _removeChild(this, oldChild);
388
- },
389
- appendChild: function(newChild) {
390
- return this.insertBefore(newChild, null);
391
- },
392
- hasChildNodes: function() {
393
- return this.firstChild != null;
394
- },
395
- cloneNode: function(deep) {
396
- return cloneNode(this.ownerDocument || this, this, deep);
397
- },
398
- normalize: function() {
399
- var child = this.firstChild;
400
- while (child) {
401
- var next = child.nextSibling;
402
- if (next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE) {
403
- this.removeChild(next);
404
- child.appendData(next.data);
405
- } else {
406
- child.normalize();
407
- child = next;
408
- }
409
- }
410
- },
411
- isSupported: function(feature, version) {
412
- return this.ownerDocument.implementation.hasFeature(feature, version);
413
- },
414
- hasAttributes: function() {
415
- return this.attributes.length > 0;
416
- },
417
- lookupPrefix: function(namespaceURI) {
418
- var el = this;
419
- while (el) {
420
- var map = el._nsMap;
421
- if (map) {
422
- for (var n in map) {
423
- if (Object.prototype.hasOwnProperty.call(map, n) && map[n] === namespaceURI) {
424
- return n;
425
- }
426
- }
427
- }
428
- el = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode;
429
- }
430
- return null;
431
- },
432
- lookupNamespaceURI: function(prefix) {
433
- var el = this;
434
- while (el) {
435
- var map = el._nsMap;
436
- if (map) {
437
- if (prefix in map) {
438
- if (Object.prototype.hasOwnProperty.call(map, prefix)) {
439
- return map[prefix];
440
- }
441
- }
442
- }
443
- el = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode;
444
- }
445
- return null;
446
- },
447
- isDefaultNamespace: function(namespaceURI) {
448
- var prefix = this.lookupPrefix(namespaceURI);
449
- return prefix == null;
450
- }
451
- };
452
- function _xmlEncoder(c) {
453
- return c == "<" && "&lt;" || c == ">" && "&gt;" || c == "&" && "&amp;" || c == '"' && "&quot;" || "&#" + c.charCodeAt() + ";";
454
- }
455
- copy(NodeType, Node);
456
- copy(NodeType, Node.prototype);
457
- function _visitNode(node, callback) {
458
- if (callback(node)) {
459
- return true;
460
- }
461
- if (node = node.firstChild) {
462
- do {
463
- if (_visitNode(node, callback)) {
464
- return true;
465
- }
466
- } while (node = node.nextSibling);
467
- }
468
- }
469
- function Document() {
470
- this.ownerDocument = this;
471
- }
472
- function _onAddAttribute(doc, el, newAttr) {
473
- doc && doc._inc++;
474
- var ns = newAttr.namespaceURI;
475
- if (ns === NAMESPACE.XMLNS) {
476
- el._nsMap[newAttr.prefix ? newAttr.localName : ""] = newAttr.value;
477
- }
478
- }
479
- function _onRemoveAttribute(doc, el, newAttr, remove) {
480
- doc && doc._inc++;
481
- var ns = newAttr.namespaceURI;
482
- if (ns === NAMESPACE.XMLNS) {
483
- delete el._nsMap[newAttr.prefix ? newAttr.localName : ""];
484
- }
485
- }
486
- function _onUpdateChild(doc, el, newChild) {
487
- if (doc && doc._inc) {
488
- doc._inc++;
489
- var cs = el.childNodes;
490
- if (newChild) {
491
- cs[cs.length++] = newChild;
492
- } else {
493
- var child = el.firstChild;
494
- var i = 0;
495
- while (child) {
496
- cs[i++] = child;
497
- child = child.nextSibling;
498
- }
499
- cs.length = i;
500
- delete cs[cs.length];
501
- }
502
- }
503
- }
504
- function _removeChild(parentNode, child) {
505
- var previous = child.previousSibling;
506
- var next = child.nextSibling;
507
- if (previous) {
508
- previous.nextSibling = next;
509
- } else {
510
- parentNode.firstChild = next;
511
- }
512
- if (next) {
513
- next.previousSibling = previous;
514
- } else {
515
- parentNode.lastChild = previous;
516
- }
517
- child.parentNode = null;
518
- child.previousSibling = null;
519
- child.nextSibling = null;
520
- _onUpdateChild(parentNode.ownerDocument, parentNode);
521
- return child;
522
- }
523
- function hasValidParentNodeType(node) {
524
- return node && (node.nodeType === Node.DOCUMENT_NODE || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE || node.nodeType === Node.ELEMENT_NODE);
525
- }
526
- function hasInsertableNodeType(node) {
527
- 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);
528
- }
529
- function isDocTypeNode(node) {
530
- return node && node.nodeType === Node.DOCUMENT_TYPE_NODE;
531
- }
532
- function isElementNode(node) {
533
- return node && node.nodeType === Node.ELEMENT_NODE;
534
- }
535
- function isTextNode(node) {
536
- return node && node.nodeType === Node.TEXT_NODE;
537
- }
538
- function isElementInsertionPossible(doc, child) {
539
- var parentChildNodes = doc.childNodes || [];
540
- if (find(parentChildNodes, isElementNode) || isDocTypeNode(child)) {
541
- return false;
542
- }
543
- var docTypeNode = find(parentChildNodes, isDocTypeNode);
544
- return !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));
545
- }
546
- function isElementReplacementPossible(doc, child) {
547
- var parentChildNodes = doc.childNodes || [];
548
- function hasElementChildThatIsNotChild(node) {
549
- return isElementNode(node) && node !== child;
550
- }
551
- if (find(parentChildNodes, hasElementChildThatIsNotChild)) {
552
- return false;
553
- }
554
- var docTypeNode = find(parentChildNodes, isDocTypeNode);
555
- return !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));
556
- }
557
- function assertPreInsertionValidity1to5(parent, node, child) {
558
- if (!hasValidParentNodeType(parent)) {
559
- throw new DOMException2(HIERARCHY_REQUEST_ERR, "Unexpected parent node type " + parent.nodeType);
560
- }
561
- if (child && child.parentNode !== parent) {
562
- throw new DOMException2(NOT_FOUND_ERR, "child not in parent");
563
- }
564
- if (!hasInsertableNodeType(node) || isDocTypeNode(node) && parent.nodeType !== Node.DOCUMENT_NODE) {
565
- throw new DOMException2(HIERARCHY_REQUEST_ERR, "Unexpected node type " + node.nodeType + " for parent node type " + parent.nodeType);
566
- }
567
- }
568
- function assertPreInsertionValidityInDocument(parent, node, child) {
569
- var parentChildNodes = parent.childNodes || [];
570
- var nodeChildNodes = node.childNodes || [];
571
- if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
572
- var nodeChildElements = nodeChildNodes.filter(isElementNode);
573
- if (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {
574
- throw new DOMException2(HIERARCHY_REQUEST_ERR, "More than one element or text in fragment");
575
- }
576
- if (nodeChildElements.length === 1 && !isElementInsertionPossible(parent, child)) {
577
- throw new DOMException2(HIERARCHY_REQUEST_ERR, "Element in fragment can not be inserted before doctype");
578
- }
579
- }
580
- if (isElementNode(node)) {
581
- if (!isElementInsertionPossible(parent, child)) {
582
- throw new DOMException2(HIERARCHY_REQUEST_ERR, "Only one element can be added and only after doctype");
583
- }
584
- }
585
- if (isDocTypeNode(node)) {
586
- if (find(parentChildNodes, isDocTypeNode)) {
587
- throw new DOMException2(HIERARCHY_REQUEST_ERR, "Only one doctype is allowed");
588
- }
589
- var parentElementChild = find(parentChildNodes, isElementNode);
590
- if (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {
591
- throw new DOMException2(HIERARCHY_REQUEST_ERR, "Doctype can only be inserted before an element");
592
- }
593
- if (!child && parentElementChild) {
594
- throw new DOMException2(HIERARCHY_REQUEST_ERR, "Doctype can not be appended since element is present");
595
- }
596
- }
597
- }
598
- function assertPreReplacementValidityInDocument(parent, node, child) {
599
- var parentChildNodes = parent.childNodes || [];
600
- var nodeChildNodes = node.childNodes || [];
601
- if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
602
- var nodeChildElements = nodeChildNodes.filter(isElementNode);
603
- if (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {
604
- throw new DOMException2(HIERARCHY_REQUEST_ERR, "More than one element or text in fragment");
605
- }
606
- if (nodeChildElements.length === 1 && !isElementReplacementPossible(parent, child)) {
607
- throw new DOMException2(HIERARCHY_REQUEST_ERR, "Element in fragment can not be inserted before doctype");
608
- }
609
- }
610
- if (isElementNode(node)) {
611
- if (!isElementReplacementPossible(parent, child)) {
612
- throw new DOMException2(HIERARCHY_REQUEST_ERR, "Only one element can be added and only after doctype");
613
- }
614
- }
615
- if (isDocTypeNode(node)) {
616
- let hasDoctypeChildThatIsNotChild2 = function(node2) {
617
- return isDocTypeNode(node2) && node2 !== child;
618
- };
619
- var hasDoctypeChildThatIsNotChild = hasDoctypeChildThatIsNotChild2;
620
- if (find(parentChildNodes, hasDoctypeChildThatIsNotChild2)) {
621
- throw new DOMException2(HIERARCHY_REQUEST_ERR, "Only one doctype is allowed");
622
- }
623
- var parentElementChild = find(parentChildNodes, isElementNode);
624
- if (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {
625
- throw new DOMException2(HIERARCHY_REQUEST_ERR, "Doctype can only be inserted before an element");
626
- }
627
- }
628
- }
629
- function _insertBefore(parent, node, child, _inDocumentAssertion) {
630
- assertPreInsertionValidity1to5(parent, node, child);
631
- if (parent.nodeType === Node.DOCUMENT_NODE) {
632
- (_inDocumentAssertion || assertPreInsertionValidityInDocument)(parent, node, child);
633
- }
634
- var cp = node.parentNode;
635
- if (cp) {
636
- cp.removeChild(node);
637
- }
638
- if (node.nodeType === DOCUMENT_FRAGMENT_NODE) {
639
- var newFirst = node.firstChild;
640
- if (newFirst == null) {
641
- return node;
642
- }
643
- var newLast = node.lastChild;
644
- } else {
645
- newFirst = newLast = node;
646
- }
647
- var pre = child ? child.previousSibling : parent.lastChild;
648
- newFirst.previousSibling = pre;
649
- newLast.nextSibling = child;
650
- if (pre) {
651
- pre.nextSibling = newFirst;
652
- } else {
653
- parent.firstChild = newFirst;
654
- }
655
- if (child == null) {
656
- parent.lastChild = newLast;
657
- } else {
658
- child.previousSibling = newLast;
659
- }
660
- do {
661
- newFirst.parentNode = parent;
662
- } while (newFirst !== newLast && (newFirst = newFirst.nextSibling));
663
- _onUpdateChild(parent.ownerDocument || parent, parent);
664
- if (node.nodeType == DOCUMENT_FRAGMENT_NODE) {
665
- node.firstChild = node.lastChild = null;
666
- }
667
- return node;
668
- }
669
- function _appendSingleChild(parentNode, newChild) {
670
- if (newChild.parentNode) {
671
- newChild.parentNode.removeChild(newChild);
672
- }
673
- newChild.parentNode = parentNode;
674
- newChild.previousSibling = parentNode.lastChild;
675
- newChild.nextSibling = null;
676
- if (newChild.previousSibling) {
677
- newChild.previousSibling.nextSibling = newChild;
678
- } else {
679
- parentNode.firstChild = newChild;
680
- }
681
- parentNode.lastChild = newChild;
682
- _onUpdateChild(parentNode.ownerDocument, parentNode, newChild);
683
- return newChild;
684
- }
685
- Document.prototype = {
686
- nodeName: "#document",
687
- nodeType: DOCUMENT_NODE,
688
- doctype: null,
689
- documentElement: null,
690
- _inc: 1,
691
- insertBefore: function(newChild, refChild) {
692
- if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) {
693
- var child = newChild.firstChild;
694
- while (child) {
695
- var next = child.nextSibling;
696
- this.insertBefore(child, refChild);
697
- child = next;
698
- }
699
- return newChild;
700
- }
701
- _insertBefore(this, newChild, refChild);
702
- newChild.ownerDocument = this;
703
- if (this.documentElement === null && newChild.nodeType === ELEMENT_NODE) {
704
- this.documentElement = newChild;
705
- }
706
- return newChild;
707
- },
708
- removeChild: function(oldChild) {
709
- if (this.documentElement == oldChild) {
710
- this.documentElement = null;
711
- }
712
- return _removeChild(this, oldChild);
713
- },
714
- replaceChild: function(newChild, oldChild) {
715
- _insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument);
716
- newChild.ownerDocument = this;
717
- if (oldChild) {
718
- this.removeChild(oldChild);
719
- }
720
- if (isElementNode(newChild)) {
721
- this.documentElement = newChild;
722
- }
723
- },
724
- importNode: function(importedNode, deep) {
725
- return importNode(this, importedNode, deep);
726
- },
727
- getElementById: function(id) {
728
- var rtv = null;
729
- _visitNode(this.documentElement, function(node) {
730
- if (node.nodeType == ELEMENT_NODE) {
731
- if (node.getAttribute("id") == id) {
732
- rtv = node;
733
- return true;
734
- }
735
- }
736
- });
737
- return rtv;
738
- },
739
- getElementsByClassName: function(classNames) {
740
- var classNamesSet = toOrderedSet(classNames);
741
- return new LiveNodeList(this, function(base) {
742
- var ls = [];
743
- if (classNamesSet.length > 0) {
744
- _visitNode(base.documentElement, function(node) {
745
- if (node !== base && node.nodeType === ELEMENT_NODE) {
746
- var nodeClassNames = node.getAttribute("class");
747
- if (nodeClassNames) {
748
- var matches2 = classNames === nodeClassNames;
749
- if (!matches2) {
750
- var nodeClassNamesSet = toOrderedSet(nodeClassNames);
751
- matches2 = classNamesSet.every(arrayIncludes(nodeClassNamesSet));
752
- }
753
- if (matches2) {
754
- ls.push(node);
755
- }
756
- }
757
- }
758
- });
759
- }
760
- return ls;
761
- });
762
- },
763
- createElement: function(tagName) {
764
- var node = new Element();
765
- node.ownerDocument = this;
766
- node.nodeName = tagName;
767
- node.tagName = tagName;
768
- node.localName = tagName;
769
- node.childNodes = new NodeList();
770
- var attrs = node.attributes = new NamedNodeMap();
771
- attrs._ownerElement = node;
772
- return node;
773
- },
774
- createDocumentFragment: function() {
775
- var node = new DocumentFragment();
776
- node.ownerDocument = this;
777
- node.childNodes = new NodeList();
778
- return node;
779
- },
780
- createTextNode: function(data) {
781
- var node = new Text();
782
- node.ownerDocument = this;
783
- node.appendData(data);
784
- return node;
785
- },
786
- createComment: function(data) {
787
- var node = new Comment();
788
- node.ownerDocument = this;
789
- node.appendData(data);
790
- return node;
791
- },
792
- createCDATASection: function(data) {
793
- var node = new CDATASection();
794
- node.ownerDocument = this;
795
- node.appendData(data);
796
- return node;
797
- },
798
- createProcessingInstruction: function(target, data) {
799
- var node = new ProcessingInstruction();
800
- node.ownerDocument = this;
801
- node.tagName = node.target = target;
802
- node.nodeValue = node.data = data;
803
- return node;
804
- },
805
- createAttribute: function(name) {
806
- var node = new Attr();
807
- node.ownerDocument = this;
808
- node.name = name;
809
- node.nodeName = name;
810
- node.localName = name;
811
- node.specified = true;
812
- return node;
813
- },
814
- createEntityReference: function(name) {
815
- var node = new EntityReference();
816
- node.ownerDocument = this;
817
- node.nodeName = name;
818
- return node;
819
- },
820
- createElementNS: function(namespaceURI, qualifiedName) {
821
- var node = new Element();
822
- var pl = qualifiedName.split(":");
823
- var attrs = node.attributes = new NamedNodeMap();
824
- node.childNodes = new NodeList();
825
- node.ownerDocument = this;
826
- node.nodeName = qualifiedName;
827
- node.tagName = qualifiedName;
828
- node.namespaceURI = namespaceURI;
829
- if (pl.length == 2) {
830
- node.prefix = pl[0];
831
- node.localName = pl[1];
832
- } else {
833
- node.localName = qualifiedName;
834
- }
835
- attrs._ownerElement = node;
836
- return node;
837
- },
838
- createAttributeNS: function(namespaceURI, qualifiedName) {
839
- var node = new Attr();
840
- var pl = qualifiedName.split(":");
841
- node.ownerDocument = this;
842
- node.nodeName = qualifiedName;
843
- node.name = qualifiedName;
844
- node.namespaceURI = namespaceURI;
845
- node.specified = true;
846
- if (pl.length == 2) {
847
- node.prefix = pl[0];
848
- node.localName = pl[1];
849
- } else {
850
- node.localName = qualifiedName;
851
- }
852
- return node;
853
- }
854
- };
855
- _extends(Document, Node);
856
- function Element() {
857
- this._nsMap = {};
858
- }
859
- Element.prototype = {
860
- nodeType: ELEMENT_NODE,
861
- hasAttribute: function(name) {
862
- return this.getAttributeNode(name) != null;
863
- },
864
- getAttribute: function(name) {
865
- var attr = this.getAttributeNode(name);
866
- return attr && attr.value || "";
867
- },
868
- getAttributeNode: function(name) {
869
- return this.attributes.getNamedItem(name);
870
- },
871
- setAttribute: function(name, value) {
872
- var attr = this.ownerDocument.createAttribute(name);
873
- attr.value = attr.nodeValue = "" + value;
874
- this.setAttributeNode(attr);
875
- },
876
- removeAttribute: function(name) {
877
- var attr = this.getAttributeNode(name);
878
- attr && this.removeAttributeNode(attr);
879
- },
880
- appendChild: function(newChild) {
881
- if (newChild.nodeType === DOCUMENT_FRAGMENT_NODE) {
882
- return this.insertBefore(newChild, null);
883
- } else {
884
- return _appendSingleChild(this, newChild);
885
- }
886
- },
887
- setAttributeNode: function(newAttr) {
888
- return this.attributes.setNamedItem(newAttr);
889
- },
890
- setAttributeNodeNS: function(newAttr) {
891
- return this.attributes.setNamedItemNS(newAttr);
892
- },
893
- removeAttributeNode: function(oldAttr) {
894
- return this.attributes.removeNamedItem(oldAttr.nodeName);
895
- },
896
- removeAttributeNS: function(namespaceURI, localName) {
897
- var old = this.getAttributeNodeNS(namespaceURI, localName);
898
- old && this.removeAttributeNode(old);
899
- },
900
- hasAttributeNS: function(namespaceURI, localName) {
901
- return this.getAttributeNodeNS(namespaceURI, localName) != null;
902
- },
903
- getAttributeNS: function(namespaceURI, localName) {
904
- var attr = this.getAttributeNodeNS(namespaceURI, localName);
905
- return attr && attr.value || "";
906
- },
907
- setAttributeNS: function(namespaceURI, qualifiedName, value) {
908
- var attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);
909
- attr.value = attr.nodeValue = "" + value;
910
- this.setAttributeNode(attr);
911
- },
912
- getAttributeNodeNS: function(namespaceURI, localName) {
913
- return this.attributes.getNamedItemNS(namespaceURI, localName);
914
- },
915
- getElementsByTagName: function(tagName) {
916
- return new LiveNodeList(this, function(base) {
917
- var ls = [];
918
- _visitNode(base, function(node) {
919
- if (node !== base && node.nodeType == ELEMENT_NODE && (tagName === "*" || node.tagName == tagName)) {
920
- ls.push(node);
921
- }
922
- });
923
- return ls;
924
- });
925
- },
926
- getElementsByTagNameNS: function(namespaceURI, localName) {
927
- return new LiveNodeList(this, function(base) {
928
- var ls = [];
929
- _visitNode(base, function(node) {
930
- if (node !== base && node.nodeType === ELEMENT_NODE && (namespaceURI === "*" || node.namespaceURI === namespaceURI) && (localName === "*" || node.localName == localName)) {
931
- ls.push(node);
932
- }
933
- });
934
- return ls;
935
- });
936
- }
937
- };
938
- Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName;
939
- Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS;
940
- _extends(Element, Node);
941
- function Attr() {
942
- }
943
- Attr.prototype.nodeType = ATTRIBUTE_NODE;
944
- _extends(Attr, Node);
945
- function CharacterData() {
946
- }
947
- CharacterData.prototype = {
948
- data: "",
949
- substringData: function(offset, count) {
950
- return this.data.substring(offset, offset + count);
951
- },
952
- appendData: function(text) {
953
- text = this.data + text;
954
- this.nodeValue = this.data = text;
955
- this.length = text.length;
956
- },
957
- insertData: function(offset, text) {
958
- this.replaceData(offset, 0, text);
959
- },
960
- appendChild: function(newChild) {
961
- throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR]);
962
- },
963
- deleteData: function(offset, count) {
964
- this.replaceData(offset, count, "");
965
- },
966
- replaceData: function(offset, count, text) {
967
- var start = this.data.substring(0, offset);
968
- var end = this.data.substring(offset + count);
969
- text = start + text + end;
970
- this.nodeValue = this.data = text;
971
- this.length = text.length;
972
- }
973
- };
974
- _extends(CharacterData, Node);
975
- function Text() {
976
- }
977
- Text.prototype = {
978
- nodeName: "#text",
979
- nodeType: TEXT_NODE,
980
- splitText: function(offset) {
981
- var text = this.data;
982
- var newText = text.substring(offset);
983
- text = text.substring(0, offset);
984
- this.data = this.nodeValue = text;
985
- this.length = text.length;
986
- var newNode = this.ownerDocument.createTextNode(newText);
987
- if (this.parentNode) {
988
- this.parentNode.insertBefore(newNode, this.nextSibling);
989
- }
990
- return newNode;
991
- }
992
- };
993
- _extends(Text, CharacterData);
994
- function Comment() {
995
- }
996
- Comment.prototype = {
997
- nodeName: "#comment",
998
- nodeType: COMMENT_NODE
999
- };
1000
- _extends(Comment, CharacterData);
1001
- function CDATASection() {
1002
- }
1003
- CDATASection.prototype = {
1004
- nodeName: "#cdata-section",
1005
- nodeType: CDATA_SECTION_NODE
1006
- };
1007
- _extends(CDATASection, CharacterData);
1008
- function DocumentType() {
1009
- }
1010
- DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
1011
- _extends(DocumentType, Node);
1012
- function Notation() {
1013
- }
1014
- Notation.prototype.nodeType = NOTATION_NODE;
1015
- _extends(Notation, Node);
1016
- function Entity() {
1017
- }
1018
- Entity.prototype.nodeType = ENTITY_NODE;
1019
- _extends(Entity, Node);
1020
- function EntityReference() {
1021
- }
1022
- EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
1023
- _extends(EntityReference, Node);
1024
- function DocumentFragment() {
1025
- }
1026
- DocumentFragment.prototype.nodeName = "#document-fragment";
1027
- DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE;
1028
- _extends(DocumentFragment, Node);
1029
- function ProcessingInstruction() {
1030
- }
1031
- ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
1032
- _extends(ProcessingInstruction, Node);
1033
- function XMLSerializer() {
1034
- }
1035
- XMLSerializer.prototype.serializeToString = function(node, isHtml, nodeFilter) {
1036
- return nodeSerializeToString.call(node, isHtml, nodeFilter);
1037
- };
1038
- Node.prototype.toString = nodeSerializeToString;
1039
- function nodeSerializeToString(isHtml, nodeFilter) {
1040
- var buf = [];
1041
- var refNode = this.nodeType == 9 && this.documentElement || this;
1042
- var prefix = refNode.prefix;
1043
- var uri = refNode.namespaceURI;
1044
- if (uri && prefix == null) {
1045
- var prefix = refNode.lookupPrefix(uri);
1046
- if (prefix == null) {
1047
- var visibleNamespaces = [
1048
- { namespace: uri, prefix: null }
1049
- ];
1050
- }
1051
- }
1052
- serializeToString(this, buf, isHtml, nodeFilter, visibleNamespaces);
1053
- return buf.join("");
1054
- }
1055
- function needNamespaceDefine(node, isHTML, visibleNamespaces) {
1056
- var prefix = node.prefix || "";
1057
- var uri = node.namespaceURI;
1058
- if (!uri) {
1059
- return false;
1060
- }
1061
- if (prefix === "xml" && uri === NAMESPACE.XML || uri === NAMESPACE.XMLNS) {
1062
- return false;
1063
- }
1064
- var i = visibleNamespaces.length;
1065
- while (i--) {
1066
- var ns = visibleNamespaces[i];
1067
- if (ns.prefix === prefix) {
1068
- return ns.namespace !== uri;
1069
- }
1070
- }
1071
- return true;
1072
- }
1073
- function addSerializedAttribute(buf, qualifiedName, value) {
1074
- buf.push(" ", qualifiedName, '="', value.replace(/[<&"]/g, _xmlEncoder), '"');
1075
- }
1076
- function serializeToString(node, buf, isHTML, nodeFilter, visibleNamespaces) {
1077
- if (!visibleNamespaces) {
1078
- visibleNamespaces = [];
1079
- }
1080
- if (nodeFilter) {
1081
- node = nodeFilter(node);
1082
- if (node) {
1083
- if (typeof node == "string") {
1084
- buf.push(node);
1085
- return;
1086
- }
1087
- } else {
1088
- return;
1089
- }
1090
- }
1091
- switch (node.nodeType) {
1092
- case ELEMENT_NODE:
1093
- var attrs = node.attributes;
1094
- var len = attrs.length;
1095
- var child = node.firstChild;
1096
- var nodeName = node.tagName;
1097
- isHTML = NAMESPACE.isHTML(node.namespaceURI) || isHTML;
1098
- var prefixedNodeName = nodeName;
1099
- if (!isHTML && !node.prefix && node.namespaceURI) {
1100
- var defaultNS;
1101
- for (var ai = 0; ai < attrs.length; ai++) {
1102
- if (attrs.item(ai).name === "xmlns") {
1103
- defaultNS = attrs.item(ai).value;
1104
- break;
1105
- }
1106
- }
1107
- if (!defaultNS) {
1108
- for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
1109
- var namespace = visibleNamespaces[nsi];
1110
- if (namespace.prefix === "" && namespace.namespace === node.namespaceURI) {
1111
- defaultNS = namespace.namespace;
1112
- break;
1113
- }
1114
- }
1115
- }
1116
- if (defaultNS !== node.namespaceURI) {
1117
- for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
1118
- var namespace = visibleNamespaces[nsi];
1119
- if (namespace.namespace === node.namespaceURI) {
1120
- if (namespace.prefix) {
1121
- prefixedNodeName = namespace.prefix + ":" + nodeName;
1122
- }
1123
- break;
1124
- }
1125
- }
1126
- }
1127
- }
1128
- buf.push("<", prefixedNodeName);
1129
- for (var i = 0; i < len; i++) {
1130
- var attr = attrs.item(i);
1131
- if (attr.prefix == "xmlns") {
1132
- visibleNamespaces.push({ prefix: attr.localName, namespace: attr.value });
1133
- } else if (attr.nodeName == "xmlns") {
1134
- visibleNamespaces.push({ prefix: "", namespace: attr.value });
1135
- }
1136
- }
1137
- for (var i = 0; i < len; i++) {
1138
- var attr = attrs.item(i);
1139
- if (needNamespaceDefine(attr, isHTML, visibleNamespaces)) {
1140
- var prefix = attr.prefix || "";
1141
- var uri = attr.namespaceURI;
1142
- addSerializedAttribute(buf, prefix ? "xmlns:" + prefix : "xmlns", uri);
1143
- visibleNamespaces.push({ prefix, namespace: uri });
1144
- }
1145
- serializeToString(attr, buf, isHTML, nodeFilter, visibleNamespaces);
1146
- }
1147
- if (nodeName === prefixedNodeName && needNamespaceDefine(node, isHTML, visibleNamespaces)) {
1148
- var prefix = node.prefix || "";
1149
- var uri = node.namespaceURI;
1150
- addSerializedAttribute(buf, prefix ? "xmlns:" + prefix : "xmlns", uri);
1151
- visibleNamespaces.push({ prefix, namespace: uri });
1152
- }
1153
- if (child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)) {
1154
- buf.push(">");
1155
- if (isHTML && /^script$/i.test(nodeName)) {
1156
- while (child) {
1157
- if (child.data) {
1158
- buf.push(child.data);
1159
- } else {
1160
- serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
1161
- }
1162
- child = child.nextSibling;
1163
- }
1164
- } else {
1165
- while (child) {
1166
- serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
1167
- child = child.nextSibling;
1168
- }
1169
- }
1170
- buf.push("</", prefixedNodeName, ">");
1171
- } else {
1172
- buf.push("/>");
1173
- }
1174
- return;
1175
- case DOCUMENT_NODE:
1176
- case DOCUMENT_FRAGMENT_NODE:
1177
- var child = node.firstChild;
1178
- while (child) {
1179
- serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
1180
- child = child.nextSibling;
1181
- }
1182
- return;
1183
- case ATTRIBUTE_NODE:
1184
- return addSerializedAttribute(buf, node.name, node.value);
1185
- case TEXT_NODE:
1186
- return buf.push(node.data.replace(/[<&]/g, _xmlEncoder).replace(/]]>/g, "]]&gt;"));
1187
- case CDATA_SECTION_NODE:
1188
- return buf.push("<![CDATA[", node.data, "]]>");
1189
- case COMMENT_NODE:
1190
- return buf.push("<!--", node.data, "-->");
1191
- case DOCUMENT_TYPE_NODE:
1192
- var pubid = node.publicId;
1193
- var sysid = node.systemId;
1194
- buf.push("<!DOCTYPE ", node.name);
1195
- if (pubid) {
1196
- buf.push(" PUBLIC ", pubid);
1197
- if (sysid && sysid != ".") {
1198
- buf.push(" ", sysid);
1199
- }
1200
- buf.push(">");
1201
- } else if (sysid && sysid != ".") {
1202
- buf.push(" SYSTEM ", sysid, ">");
1203
- } else {
1204
- var sub = node.internalSubset;
1205
- if (sub) {
1206
- buf.push(" [", sub, "]");
1207
- }
1208
- buf.push(">");
1209
- }
1210
- return;
1211
- case PROCESSING_INSTRUCTION_NODE:
1212
- return buf.push("<?", node.target, " ", node.data, "?>");
1213
- case ENTITY_REFERENCE_NODE:
1214
- return buf.push("&", node.nodeName, ";");
1215
- default:
1216
- buf.push("??", node.nodeName);
1217
- }
1218
- }
1219
- function importNode(doc, node, deep) {
1220
- var node2;
1221
- switch (node.nodeType) {
1222
- case ELEMENT_NODE:
1223
- node2 = node.cloneNode(false);
1224
- node2.ownerDocument = doc;
1225
- case DOCUMENT_FRAGMENT_NODE:
1226
- break;
1227
- case ATTRIBUTE_NODE:
1228
- deep = true;
1229
- break;
1230
- }
1231
- if (!node2) {
1232
- node2 = node.cloneNode(false);
1233
- }
1234
- node2.ownerDocument = doc;
1235
- node2.parentNode = null;
1236
- if (deep) {
1237
- var child = node.firstChild;
1238
- while (child) {
1239
- node2.appendChild(importNode(doc, child, deep));
1240
- child = child.nextSibling;
1241
- }
1242
- }
1243
- return node2;
1244
- }
1245
- function cloneNode(doc, node, deep) {
1246
- var node2 = new node.constructor();
1247
- for (var n in node) {
1248
- if (Object.prototype.hasOwnProperty.call(node, n)) {
1249
- var v = node[n];
1250
- if (typeof v != "object") {
1251
- if (v != node2[n]) {
1252
- node2[n] = v;
1253
- }
1254
- }
1255
- }
1256
- }
1257
- if (node.childNodes) {
1258
- node2.childNodes = new NodeList();
1259
- }
1260
- node2.ownerDocument = doc;
1261
- switch (node2.nodeType) {
1262
- case ELEMENT_NODE:
1263
- var attrs = node.attributes;
1264
- var attrs2 = node2.attributes = new NamedNodeMap();
1265
- var len = attrs.length;
1266
- attrs2._ownerElement = node2;
1267
- for (var i = 0; i < len; i++) {
1268
- node2.setAttributeNode(cloneNode(doc, attrs.item(i), true));
1269
- }
1270
- break;
1271
- ;
1272
- case ATTRIBUTE_NODE:
1273
- deep = true;
1274
- }
1275
- if (deep) {
1276
- var child = node.firstChild;
1277
- while (child) {
1278
- node2.appendChild(cloneNode(doc, child, deep));
1279
- child = child.nextSibling;
1280
- }
1281
- }
1282
- return node2;
1283
- }
1284
- function __set__(object, key, value) {
1285
- object[key] = value;
1286
- }
1287
- try {
1288
- if (Object.defineProperty) {
1289
- let getTextContent2 = function(node) {
1290
- switch (node.nodeType) {
1291
- case ELEMENT_NODE:
1292
- case DOCUMENT_FRAGMENT_NODE:
1293
- var buf = [];
1294
- node = node.firstChild;
1295
- while (node) {
1296
- if (node.nodeType !== 7 && node.nodeType !== 8) {
1297
- buf.push(getTextContent2(node));
1298
- }
1299
- node = node.nextSibling;
1300
- }
1301
- return buf.join("");
1302
- default:
1303
- return node.nodeValue;
1304
- }
1305
- };
1306
- getTextContent = getTextContent2;
1307
- Object.defineProperty(LiveNodeList.prototype, "length", {
1308
- get: function() {
1309
- _updateLiveList(this);
1310
- return this.$$length;
1311
- }
1312
- });
1313
- Object.defineProperty(Node.prototype, "textContent", {
1314
- get: function() {
1315
- return getTextContent2(this);
1316
- },
1317
- set: function(data) {
1318
- switch (this.nodeType) {
1319
- case ELEMENT_NODE:
1320
- case DOCUMENT_FRAGMENT_NODE:
1321
- while (this.firstChild) {
1322
- this.removeChild(this.firstChild);
1323
- }
1324
- if (data || String(data)) {
1325
- this.appendChild(this.ownerDocument.createTextNode(data));
1326
- }
1327
- break;
1328
- default:
1329
- this.data = data;
1330
- this.value = data;
1331
- this.nodeValue = data;
1332
- }
1333
- }
1334
- });
1335
- __set__ = function(object, key, value) {
1336
- object["$$" + key] = value;
1337
- };
1338
- }
1339
- } catch (e) {
1340
- }
1341
- var getTextContent;
1342
- exports2.DocumentType = DocumentType;
1343
- exports2.DOMException = DOMException2;
1344
- exports2.DOMImplementation = DOMImplementation;
1345
- exports2.Element = Element;
1346
- exports2.Node = Node;
1347
- exports2.NodeList = NodeList;
1348
- exports2.XMLSerializer = XMLSerializer;
1349
- }
1350
- });
1351
-
1352
- // ../../node_modules/@xmldom/xmldom/lib/entities.js
1353
- var require_entities = __commonJS({
1354
- "../../node_modules/@xmldom/xmldom/lib/entities.js"(exports2) {
1355
- var freeze = require_conventions().freeze;
1356
- exports2.XML_ENTITIES = freeze({ amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' });
1357
- exports2.HTML_ENTITIES = freeze({
1358
- lt: "<",
1359
- gt: ">",
1360
- amp: "&",
1361
- quot: '"',
1362
- apos: "'",
1363
- Agrave: "\xC0",
1364
- Aacute: "\xC1",
1365
- Acirc: "\xC2",
1366
- Atilde: "\xC3",
1367
- Auml: "\xC4",
1368
- Aring: "\xC5",
1369
- AElig: "\xC6",
1370
- Ccedil: "\xC7",
1371
- Egrave: "\xC8",
1372
- Eacute: "\xC9",
1373
- Ecirc: "\xCA",
1374
- Euml: "\xCB",
1375
- Igrave: "\xCC",
1376
- Iacute: "\xCD",
1377
- Icirc: "\xCE",
1378
- Iuml: "\xCF",
1379
- ETH: "\xD0",
1380
- Ntilde: "\xD1",
1381
- Ograve: "\xD2",
1382
- Oacute: "\xD3",
1383
- Ocirc: "\xD4",
1384
- Otilde: "\xD5",
1385
- Ouml: "\xD6",
1386
- Oslash: "\xD8",
1387
- Ugrave: "\xD9",
1388
- Uacute: "\xDA",
1389
- Ucirc: "\xDB",
1390
- Uuml: "\xDC",
1391
- Yacute: "\xDD",
1392
- THORN: "\xDE",
1393
- szlig: "\xDF",
1394
- agrave: "\xE0",
1395
- aacute: "\xE1",
1396
- acirc: "\xE2",
1397
- atilde: "\xE3",
1398
- auml: "\xE4",
1399
- aring: "\xE5",
1400
- aelig: "\xE6",
1401
- ccedil: "\xE7",
1402
- egrave: "\xE8",
1403
- eacute: "\xE9",
1404
- ecirc: "\xEA",
1405
- euml: "\xEB",
1406
- igrave: "\xEC",
1407
- iacute: "\xED",
1408
- icirc: "\xEE",
1409
- iuml: "\xEF",
1410
- eth: "\xF0",
1411
- ntilde: "\xF1",
1412
- ograve: "\xF2",
1413
- oacute: "\xF3",
1414
- ocirc: "\xF4",
1415
- otilde: "\xF5",
1416
- ouml: "\xF6",
1417
- oslash: "\xF8",
1418
- ugrave: "\xF9",
1419
- uacute: "\xFA",
1420
- ucirc: "\xFB",
1421
- uuml: "\xFC",
1422
- yacute: "\xFD",
1423
- thorn: "\xFE",
1424
- yuml: "\xFF",
1425
- nbsp: "\xA0",
1426
- iexcl: "\xA1",
1427
- cent: "\xA2",
1428
- pound: "\xA3",
1429
- curren: "\xA4",
1430
- yen: "\xA5",
1431
- brvbar: "\xA6",
1432
- sect: "\xA7",
1433
- uml: "\xA8",
1434
- copy: "\xA9",
1435
- ordf: "\xAA",
1436
- laquo: "\xAB",
1437
- not: "\xAC",
1438
- shy: "\xAD\xAD",
1439
- reg: "\xAE",
1440
- macr: "\xAF",
1441
- deg: "\xB0",
1442
- plusmn: "\xB1",
1443
- sup2: "\xB2",
1444
- sup3: "\xB3",
1445
- acute: "\xB4",
1446
- micro: "\xB5",
1447
- para: "\xB6",
1448
- middot: "\xB7",
1449
- cedil: "\xB8",
1450
- sup1: "\xB9",
1451
- ordm: "\xBA",
1452
- raquo: "\xBB",
1453
- frac14: "\xBC",
1454
- frac12: "\xBD",
1455
- frac34: "\xBE",
1456
- iquest: "\xBF",
1457
- times: "\xD7",
1458
- divide: "\xF7",
1459
- forall: "\u2200",
1460
- part: "\u2202",
1461
- exist: "\u2203",
1462
- empty: "\u2205",
1463
- nabla: "\u2207",
1464
- isin: "\u2208",
1465
- notin: "\u2209",
1466
- ni: "\u220B",
1467
- prod: "\u220F",
1468
- sum: "\u2211",
1469
- minus: "\u2212",
1470
- lowast: "\u2217",
1471
- radic: "\u221A",
1472
- prop: "\u221D",
1473
- infin: "\u221E",
1474
- ang: "\u2220",
1475
- and: "\u2227",
1476
- or: "\u2228",
1477
- cap: "\u2229",
1478
- cup: "\u222A",
1479
- "int": "\u222B",
1480
- there4: "\u2234",
1481
- sim: "\u223C",
1482
- cong: "\u2245",
1483
- asymp: "\u2248",
1484
- ne: "\u2260",
1485
- equiv: "\u2261",
1486
- le: "\u2264",
1487
- ge: "\u2265",
1488
- sub: "\u2282",
1489
- sup: "\u2283",
1490
- nsub: "\u2284",
1491
- sube: "\u2286",
1492
- supe: "\u2287",
1493
- oplus: "\u2295",
1494
- otimes: "\u2297",
1495
- perp: "\u22A5",
1496
- sdot: "\u22C5",
1497
- Alpha: "\u0391",
1498
- Beta: "\u0392",
1499
- Gamma: "\u0393",
1500
- Delta: "\u0394",
1501
- Epsilon: "\u0395",
1502
- Zeta: "\u0396",
1503
- Eta: "\u0397",
1504
- Theta: "\u0398",
1505
- Iota: "\u0399",
1506
- Kappa: "\u039A",
1507
- Lambda: "\u039B",
1508
- Mu: "\u039C",
1509
- Nu: "\u039D",
1510
- Xi: "\u039E",
1511
- Omicron: "\u039F",
1512
- Pi: "\u03A0",
1513
- Rho: "\u03A1",
1514
- Sigma: "\u03A3",
1515
- Tau: "\u03A4",
1516
- Upsilon: "\u03A5",
1517
- Phi: "\u03A6",
1518
- Chi: "\u03A7",
1519
- Psi: "\u03A8",
1520
- Omega: "\u03A9",
1521
- alpha: "\u03B1",
1522
- beta: "\u03B2",
1523
- gamma: "\u03B3",
1524
- delta: "\u03B4",
1525
- epsilon: "\u03B5",
1526
- zeta: "\u03B6",
1527
- eta: "\u03B7",
1528
- theta: "\u03B8",
1529
- iota: "\u03B9",
1530
- kappa: "\u03BA",
1531
- lambda: "\u03BB",
1532
- mu: "\u03BC",
1533
- nu: "\u03BD",
1534
- xi: "\u03BE",
1535
- omicron: "\u03BF",
1536
- pi: "\u03C0",
1537
- rho: "\u03C1",
1538
- sigmaf: "\u03C2",
1539
- sigma: "\u03C3",
1540
- tau: "\u03C4",
1541
- upsilon: "\u03C5",
1542
- phi: "\u03C6",
1543
- chi: "\u03C7",
1544
- psi: "\u03C8",
1545
- omega: "\u03C9",
1546
- thetasym: "\u03D1",
1547
- upsih: "\u03D2",
1548
- piv: "\u03D6",
1549
- OElig: "\u0152",
1550
- oelig: "\u0153",
1551
- Scaron: "\u0160",
1552
- scaron: "\u0161",
1553
- Yuml: "\u0178",
1554
- fnof: "\u0192",
1555
- circ: "\u02C6",
1556
- tilde: "\u02DC",
1557
- ensp: "\u2002",
1558
- emsp: "\u2003",
1559
- thinsp: "\u2009",
1560
- zwnj: "\u200C",
1561
- zwj: "\u200D",
1562
- lrm: "\u200E",
1563
- rlm: "\u200F",
1564
- ndash: "\u2013",
1565
- mdash: "\u2014",
1566
- lsquo: "\u2018",
1567
- rsquo: "\u2019",
1568
- sbquo: "\u201A",
1569
- ldquo: "\u201C",
1570
- rdquo: "\u201D",
1571
- bdquo: "\u201E",
1572
- dagger: "\u2020",
1573
- Dagger: "\u2021",
1574
- bull: "\u2022",
1575
- hellip: "\u2026",
1576
- permil: "\u2030",
1577
- prime: "\u2032",
1578
- Prime: "\u2033",
1579
- lsaquo: "\u2039",
1580
- rsaquo: "\u203A",
1581
- oline: "\u203E",
1582
- euro: "\u20AC",
1583
- trade: "\u2122",
1584
- larr: "\u2190",
1585
- uarr: "\u2191",
1586
- rarr: "\u2192",
1587
- darr: "\u2193",
1588
- harr: "\u2194",
1589
- crarr: "\u21B5",
1590
- lceil: "\u2308",
1591
- rceil: "\u2309",
1592
- lfloor: "\u230A",
1593
- rfloor: "\u230B",
1594
- loz: "\u25CA",
1595
- spades: "\u2660",
1596
- clubs: "\u2663",
1597
- hearts: "\u2665",
1598
- diams: "\u2666"
1599
- });
1600
- exports2.entityMap = exports2.HTML_ENTITIES;
1601
- }
1602
- });
1603
-
1604
- // ../../node_modules/@xmldom/xmldom/lib/sax.js
1605
- var require_sax = __commonJS({
1606
- "../../node_modules/@xmldom/xmldom/lib/sax.js"(exports2) {
1607
- var NAMESPACE = require_conventions().NAMESPACE;
1608
- 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]/;
1609
- var nameChar = new RegExp("[\\-\\.0-9" + nameStartChar.source.slice(1, -1) + "\\u00B7\\u0300-\\u036F\\u203F-\\u2040]");
1610
- var tagNamePattern = new RegExp("^" + nameStartChar.source + nameChar.source + "*(?::" + nameStartChar.source + nameChar.source + "*)?$");
1611
- var S_TAG = 0;
1612
- var S_ATTR = 1;
1613
- var S_ATTR_SPACE = 2;
1614
- var S_EQ = 3;
1615
- var S_ATTR_NOQUOT_VALUE = 4;
1616
- var S_ATTR_END = 5;
1617
- var S_TAG_SPACE = 6;
1618
- var S_TAG_CLOSE = 7;
1619
- function ParseError(message, locator) {
1620
- this.message = message;
1621
- this.locator = locator;
1622
- if (Error.captureStackTrace)
1623
- Error.captureStackTrace(this, ParseError);
1624
- }
1625
- ParseError.prototype = new Error();
1626
- ParseError.prototype.name = ParseError.name;
1627
- function XMLReader() {
1628
- }
1629
- XMLReader.prototype = {
1630
- parse: function(source, defaultNSMap, entityMap) {
1631
- var domBuilder = this.domBuilder;
1632
- domBuilder.startDocument();
1633
- _copy(defaultNSMap, defaultNSMap = {});
1634
- parse(source, defaultNSMap, entityMap, domBuilder, this.errorHandler);
1635
- domBuilder.endDocument();
1636
- }
1637
- };
1638
- function parse(source, defaultNSMapCopy, entityMap, domBuilder, errorHandler) {
1639
- function fixedFromCharCode(code) {
1640
- if (code > 65535) {
1641
- code -= 65536;
1642
- var surrogate1 = 55296 + (code >> 10), surrogate2 = 56320 + (code & 1023);
1643
- return String.fromCharCode(surrogate1, surrogate2);
1644
- } else {
1645
- return String.fromCharCode(code);
1646
- }
1647
- }
1648
- function entityReplacer(a2) {
1649
- var k = a2.slice(1, -1);
1650
- if (k in entityMap) {
1651
- return entityMap[k];
1652
- } else if (k.charAt(0) === "#") {
1653
- return fixedFromCharCode(parseInt(k.substr(1).replace("x", "0x")));
1654
- } else {
1655
- errorHandler.error("entity not found:" + a2);
1656
- return a2;
1657
- }
1658
- }
1659
- function appendText(end2) {
1660
- if (end2 > start) {
1661
- var xt = source.substring(start, end2).replace(/&#?\w+;/g, entityReplacer);
1662
- locator && position(start);
1663
- domBuilder.characters(xt, 0, end2 - start);
1664
- start = end2;
1665
- }
1666
- }
1667
- function position(p, m) {
1668
- while (p >= lineEnd && (m = linePattern.exec(source))) {
1669
- lineStart = m.index;
1670
- lineEnd = lineStart + m[0].length;
1671
- locator.lineNumber++;
1672
- }
1673
- locator.columnNumber = p - lineStart + 1;
1674
- }
1675
- var lineStart = 0;
1676
- var lineEnd = 0;
1677
- var linePattern = /.*(?:\r\n?|\n)|.*$/g;
1678
- var locator = domBuilder.locator;
1679
- var parseStack = [{ currentNSMap: defaultNSMapCopy }];
1680
- var closeMap = {};
1681
- var start = 0;
1682
- while (true) {
1683
- try {
1684
- var tagStart = source.indexOf("<", start);
1685
- if (tagStart < 0) {
1686
- if (!source.substr(start).match(/^\s*$/)) {
1687
- var doc = domBuilder.doc;
1688
- var text = doc.createTextNode(source.substr(start));
1689
- doc.appendChild(text);
1690
- domBuilder.currentElement = text;
1691
- }
1692
- return;
1693
- }
1694
- if (tagStart > start) {
1695
- appendText(tagStart);
1696
- }
1697
- switch (source.charAt(tagStart + 1)) {
1698
- case "/":
1699
- var end = source.indexOf(">", tagStart + 3);
1700
- var tagName = source.substring(tagStart + 2, end).replace(/[ \t\n\r]+$/g, "");
1701
- var config = parseStack.pop();
1702
- if (end < 0) {
1703
- tagName = source.substring(tagStart + 2).replace(/[\s<].*/, "");
1704
- errorHandler.error("end tag name: " + tagName + " is not complete:" + config.tagName);
1705
- end = tagStart + 1 + tagName.length;
1706
- } else if (tagName.match(/\s</)) {
1707
- tagName = tagName.replace(/[\s<].*/, "");
1708
- errorHandler.error("end tag name: " + tagName + " maybe not complete");
1709
- end = tagStart + 1 + tagName.length;
1710
- }
1711
- var localNSMap = config.localNSMap;
1712
- var endMatch = config.tagName == tagName;
1713
- var endIgnoreCaseMach = endMatch || config.tagName && config.tagName.toLowerCase() == tagName.toLowerCase();
1714
- if (endIgnoreCaseMach) {
1715
- domBuilder.endElement(config.uri, config.localName, tagName);
1716
- if (localNSMap) {
1717
- for (var prefix in localNSMap) {
1718
- if (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) {
1719
- domBuilder.endPrefixMapping(prefix);
1720
- }
1721
- }
1722
- }
1723
- if (!endMatch) {
1724
- errorHandler.fatalError("end tag name: " + tagName + " is not match the current start tagName:" + config.tagName);
1725
- }
1726
- } else {
1727
- parseStack.push(config);
1728
- }
1729
- end++;
1730
- break;
1731
- case "?":
1732
- locator && position(tagStart);
1733
- end = parseInstruction(source, tagStart, domBuilder);
1734
- break;
1735
- case "!":
1736
- locator && position(tagStart);
1737
- end = parseDCC(source, tagStart, domBuilder, errorHandler);
1738
- break;
1739
- default:
1740
- locator && position(tagStart);
1741
- var el = new ElementAttributes();
1742
- var currentNSMap = parseStack[parseStack.length - 1].currentNSMap;
1743
- var end = parseElementStartPart(source, tagStart, el, currentNSMap, entityReplacer, errorHandler);
1744
- var len = el.length;
1745
- if (!el.closed && fixSelfClosed(source, end, el.tagName, closeMap)) {
1746
- el.closed = true;
1747
- if (!entityMap.nbsp) {
1748
- errorHandler.warning("unclosed xml attribute");
1749
- }
1750
- }
1751
- if (locator && len) {
1752
- var locator2 = copyLocator(locator, {});
1753
- for (var i = 0; i < len; i++) {
1754
- var a = el[i];
1755
- position(a.offset);
1756
- a.locator = copyLocator(locator, {});
1757
- }
1758
- domBuilder.locator = locator2;
1759
- if (appendElement(el, domBuilder, currentNSMap)) {
1760
- parseStack.push(el);
1761
- }
1762
- domBuilder.locator = locator;
1763
- } else {
1764
- if (appendElement(el, domBuilder, currentNSMap)) {
1765
- parseStack.push(el);
1766
- }
1767
- }
1768
- if (NAMESPACE.isHTML(el.uri) && !el.closed) {
1769
- end = parseHtmlSpecialContent(source, end, el.tagName, entityReplacer, domBuilder);
1770
- } else {
1771
- end++;
1772
- }
1773
- }
1774
- } catch (e) {
1775
- if (e instanceof ParseError) {
1776
- throw e;
1777
- }
1778
- errorHandler.error("element parse error: " + e);
1779
- end = -1;
1780
- }
1781
- if (end > start) {
1782
- start = end;
1783
- } else {
1784
- appendText(Math.max(tagStart, start) + 1);
1785
- }
1786
- }
1787
- }
1788
- function copyLocator(f, t) {
1789
- t.lineNumber = f.lineNumber;
1790
- t.columnNumber = f.columnNumber;
1791
- return t;
1792
- }
1793
- function parseElementStartPart(source, start, el, currentNSMap, entityReplacer, errorHandler) {
1794
- function addAttribute(qname, value2, startIndex) {
1795
- if (el.attributeNames.hasOwnProperty(qname)) {
1796
- errorHandler.fatalError("Attribute " + qname + " redefined");
1797
- }
1798
- el.addValue(qname, value2, startIndex);
1799
- }
1800
- var attrName;
1801
- var value;
1802
- var p = ++start;
1803
- var s = S_TAG;
1804
- while (true) {
1805
- var c = source.charAt(p);
1806
- switch (c) {
1807
- case "=":
1808
- if (s === S_ATTR) {
1809
- attrName = source.slice(start, p);
1810
- s = S_EQ;
1811
- } else if (s === S_ATTR_SPACE) {
1812
- s = S_EQ;
1813
- } else {
1814
- throw new Error("attribute equal must after attrName");
1815
- }
1816
- break;
1817
- case "'":
1818
- case '"':
1819
- if (s === S_EQ || s === S_ATTR) {
1820
- if (s === S_ATTR) {
1821
- errorHandler.warning('attribute value must after "="');
1822
- attrName = source.slice(start, p);
1823
- }
1824
- start = p + 1;
1825
- p = source.indexOf(c, start);
1826
- if (p > 0) {
1827
- value = source.slice(start, p).replace(/&#?\w+;/g, entityReplacer);
1828
- addAttribute(attrName, value, start - 1);
1829
- s = S_ATTR_END;
1830
- } else {
1831
- throw new Error("attribute value no end '" + c + "' match");
1832
- }
1833
- } else if (s == S_ATTR_NOQUOT_VALUE) {
1834
- value = source.slice(start, p).replace(/&#?\w+;/g, entityReplacer);
1835
- addAttribute(attrName, value, start);
1836
- errorHandler.warning('attribute "' + attrName + '" missed start quot(' + c + ")!!");
1837
- start = p + 1;
1838
- s = S_ATTR_END;
1839
- } else {
1840
- throw new Error('attribute value must after "="');
1841
- }
1842
- break;
1843
- case "/":
1844
- switch (s) {
1845
- case S_TAG:
1846
- el.setTagName(source.slice(start, p));
1847
- case S_ATTR_END:
1848
- case S_TAG_SPACE:
1849
- case S_TAG_CLOSE:
1850
- s = S_TAG_CLOSE;
1851
- el.closed = true;
1852
- case S_ATTR_NOQUOT_VALUE:
1853
- case S_ATTR:
1854
- break;
1855
- case S_ATTR_SPACE:
1856
- el.closed = true;
1857
- break;
1858
- default:
1859
- throw new Error("attribute invalid close char('/')");
1860
- }
1861
- break;
1862
- case "":
1863
- errorHandler.error("unexpected end of input");
1864
- if (s == S_TAG) {
1865
- el.setTagName(source.slice(start, p));
1866
- }
1867
- return p;
1868
- case ">":
1869
- switch (s) {
1870
- case S_TAG:
1871
- el.setTagName(source.slice(start, p));
1872
- case S_ATTR_END:
1873
- case S_TAG_SPACE:
1874
- case S_TAG_CLOSE:
1875
- break;
1876
- case S_ATTR_NOQUOT_VALUE:
1877
- case S_ATTR:
1878
- value = source.slice(start, p);
1879
- if (value.slice(-1) === "/") {
1880
- el.closed = true;
1881
- value = value.slice(0, -1);
1882
- }
1883
- case S_ATTR_SPACE:
1884
- if (s === S_ATTR_SPACE) {
1885
- value = attrName;
1886
- }
1887
- if (s == S_ATTR_NOQUOT_VALUE) {
1888
- errorHandler.warning('attribute "' + value + '" missed quot(")!');
1889
- addAttribute(attrName, value.replace(/&#?\w+;/g, entityReplacer), start);
1890
- } else {
1891
- if (!NAMESPACE.isHTML(currentNSMap[""]) || !value.match(/^(?:disabled|checked|selected)$/i)) {
1892
- errorHandler.warning('attribute "' + value + '" missed value!! "' + value + '" instead!!');
1893
- }
1894
- addAttribute(value, value, start);
1895
- }
1896
- break;
1897
- case S_EQ:
1898
- throw new Error("attribute value missed!!");
1899
- }
1900
- return p;
1901
- case "\x80":
1902
- c = " ";
1903
- default:
1904
- if (c <= " ") {
1905
- switch (s) {
1906
- case S_TAG:
1907
- el.setTagName(source.slice(start, p));
1908
- s = S_TAG_SPACE;
1909
- break;
1910
- case S_ATTR:
1911
- attrName = source.slice(start, p);
1912
- s = S_ATTR_SPACE;
1913
- break;
1914
- case S_ATTR_NOQUOT_VALUE:
1915
- var value = source.slice(start, p).replace(/&#?\w+;/g, entityReplacer);
1916
- errorHandler.warning('attribute "' + value + '" missed quot(")!!');
1917
- addAttribute(attrName, value, start);
1918
- case S_ATTR_END:
1919
- s = S_TAG_SPACE;
1920
- break;
1921
- }
1922
- } else {
1923
- switch (s) {
1924
- case S_ATTR_SPACE:
1925
- var tagName = el.tagName;
1926
- if (!NAMESPACE.isHTML(currentNSMap[""]) || !attrName.match(/^(?:disabled|checked|selected)$/i)) {
1927
- errorHandler.warning('attribute "' + attrName + '" missed value!! "' + attrName + '" instead2!!');
1928
- }
1929
- addAttribute(attrName, attrName, start);
1930
- start = p;
1931
- s = S_ATTR;
1932
- break;
1933
- case S_ATTR_END:
1934
- errorHandler.warning('attribute space is required"' + attrName + '"!!');
1935
- case S_TAG_SPACE:
1936
- s = S_ATTR;
1937
- start = p;
1938
- break;
1939
- case S_EQ:
1940
- s = S_ATTR_NOQUOT_VALUE;
1941
- start = p;
1942
- break;
1943
- case S_TAG_CLOSE:
1944
- throw new Error("elements closed character '/' and '>' must be connected to");
1945
- }
1946
- }
1947
- }
1948
- p++;
1949
- }
1950
- }
1951
- function appendElement(el, domBuilder, currentNSMap) {
1952
- var tagName = el.tagName;
1953
- var localNSMap = null;
1954
- var i = el.length;
1955
- while (i--) {
1956
- var a = el[i];
1957
- var qName = a.qName;
1958
- var value = a.value;
1959
- var nsp = qName.indexOf(":");
1960
- if (nsp > 0) {
1961
- var prefix = a.prefix = qName.slice(0, nsp);
1962
- var localName = qName.slice(nsp + 1);
1963
- var nsPrefix = prefix === "xmlns" && localName;
1964
- } else {
1965
- localName = qName;
1966
- prefix = null;
1967
- nsPrefix = qName === "xmlns" && "";
1968
- }
1969
- a.localName = localName;
1970
- if (nsPrefix !== false) {
1971
- if (localNSMap == null) {
1972
- localNSMap = {};
1973
- _copy(currentNSMap, currentNSMap = {});
1974
- }
1975
- currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
1976
- a.uri = NAMESPACE.XMLNS;
1977
- domBuilder.startPrefixMapping(nsPrefix, value);
1978
- }
1979
- }
1980
- var i = el.length;
1981
- while (i--) {
1982
- a = el[i];
1983
- var prefix = a.prefix;
1984
- if (prefix) {
1985
- if (prefix === "xml") {
1986
- a.uri = NAMESPACE.XML;
1987
- }
1988
- if (prefix !== "xmlns") {
1989
- a.uri = currentNSMap[prefix || ""];
1990
- }
1991
- }
1992
- }
1993
- var nsp = tagName.indexOf(":");
1994
- if (nsp > 0) {
1995
- prefix = el.prefix = tagName.slice(0, nsp);
1996
- localName = el.localName = tagName.slice(nsp + 1);
1997
- } else {
1998
- prefix = null;
1999
- localName = el.localName = tagName;
2000
- }
2001
- var ns = el.uri = currentNSMap[prefix || ""];
2002
- domBuilder.startElement(ns, localName, tagName, el);
2003
- if (el.closed) {
2004
- domBuilder.endElement(ns, localName, tagName);
2005
- if (localNSMap) {
2006
- for (prefix in localNSMap) {
2007
- if (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) {
2008
- domBuilder.endPrefixMapping(prefix);
2009
- }
2010
- }
2011
- }
2012
- } else {
2013
- el.currentNSMap = currentNSMap;
2014
- el.localNSMap = localNSMap;
2015
- return true;
2016
- }
2017
- }
2018
- function parseHtmlSpecialContent(source, elStartEnd, tagName, entityReplacer, domBuilder) {
2019
- if (/^(?:script|textarea)$/i.test(tagName)) {
2020
- var elEndStart = source.indexOf("</" + tagName + ">", elStartEnd);
2021
- var text = source.substring(elStartEnd + 1, elEndStart);
2022
- if (/[&<]/.test(text)) {
2023
- if (/^script$/i.test(tagName)) {
2024
- domBuilder.characters(text, 0, text.length);
2025
- return elEndStart;
2026
- }
2027
- text = text.replace(/&#?\w+;/g, entityReplacer);
2028
- domBuilder.characters(text, 0, text.length);
2029
- return elEndStart;
2030
- }
2031
- }
2032
- return elStartEnd + 1;
2033
- }
2034
- function fixSelfClosed(source, elStartEnd, tagName, closeMap) {
2035
- var pos = closeMap[tagName];
2036
- if (pos == null) {
2037
- pos = source.lastIndexOf("</" + tagName + ">");
2038
- if (pos < elStartEnd) {
2039
- pos = source.lastIndexOf("</" + tagName);
2040
- }
2041
- closeMap[tagName] = pos;
2042
- }
2043
- return pos < elStartEnd;
2044
- }
2045
- function _copy(source, target) {
2046
- for (var n in source) {
2047
- if (Object.prototype.hasOwnProperty.call(source, n)) {
2048
- target[n] = source[n];
2049
- }
2050
- }
2051
- }
2052
- function parseDCC(source, start, domBuilder, errorHandler) {
2053
- var next = source.charAt(start + 2);
2054
- switch (next) {
2055
- case "-":
2056
- if (source.charAt(start + 3) === "-") {
2057
- var end = source.indexOf("-->", start + 4);
2058
- if (end > start) {
2059
- domBuilder.comment(source, start + 4, end - start - 4);
2060
- return end + 3;
2061
- } else {
2062
- errorHandler.error("Unclosed comment");
2063
- return -1;
2064
- }
2065
- } else {
2066
- return -1;
2067
- }
2068
- default:
2069
- if (source.substr(start + 3, 6) == "CDATA[") {
2070
- var end = source.indexOf("]]>", start + 9);
2071
- domBuilder.startCDATA();
2072
- domBuilder.characters(source, start + 9, end - start - 9);
2073
- domBuilder.endCDATA();
2074
- return end + 3;
2075
- }
2076
- var matchs = split(source, start);
2077
- var len = matchs.length;
2078
- if (len > 1 && /!doctype/i.test(matchs[0][0])) {
2079
- var name = matchs[1][0];
2080
- var pubid = false;
2081
- var sysid = false;
2082
- if (len > 3) {
2083
- if (/^public$/i.test(matchs[2][0])) {
2084
- pubid = matchs[3][0];
2085
- sysid = len > 4 && matchs[4][0];
2086
- } else if (/^system$/i.test(matchs[2][0])) {
2087
- sysid = matchs[3][0];
2088
- }
2089
- }
2090
- var lastMatch = matchs[len - 1];
2091
- domBuilder.startDTD(name, pubid, sysid);
2092
- domBuilder.endDTD();
2093
- return lastMatch.index + lastMatch[0].length;
2094
- }
2095
- }
2096
- return -1;
2097
- }
2098
- function parseInstruction(source, start, domBuilder) {
2099
- var end = source.indexOf("?>", start);
2100
- if (end) {
2101
- var match = source.substring(start, end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);
2102
- if (match) {
2103
- var len = match[0].length;
2104
- domBuilder.processingInstruction(match[1], match[2]);
2105
- return end + 2;
2106
- } else {
2107
- return -1;
2108
- }
2109
- }
2110
- return -1;
2111
- }
2112
- function ElementAttributes() {
2113
- this.attributeNames = {};
2114
- }
2115
- ElementAttributes.prototype = {
2116
- setTagName: function(tagName) {
2117
- if (!tagNamePattern.test(tagName)) {
2118
- throw new Error("invalid tagName:" + tagName);
2119
- }
2120
- this.tagName = tagName;
2121
- },
2122
- addValue: function(qName, value, offset) {
2123
- if (!tagNamePattern.test(qName)) {
2124
- throw new Error("invalid attribute:" + qName);
2125
- }
2126
- this.attributeNames[qName] = this.length;
2127
- this[this.length++] = { qName, value, offset };
2128
- },
2129
- length: 0,
2130
- getLocalName: function(i) {
2131
- return this[i].localName;
2132
- },
2133
- getLocator: function(i) {
2134
- return this[i].locator;
2135
- },
2136
- getQName: function(i) {
2137
- return this[i].qName;
2138
- },
2139
- getURI: function(i) {
2140
- return this[i].uri;
2141
- },
2142
- getValue: function(i) {
2143
- return this[i].value;
2144
- }
2145
- };
2146
- function split(source, start) {
2147
- var match;
2148
- var buf = [];
2149
- var reg = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;
2150
- reg.lastIndex = start;
2151
- reg.exec(source);
2152
- while (match = reg.exec(source)) {
2153
- buf.push(match);
2154
- if (match[1])
2155
- return buf;
2156
- }
2157
- }
2158
- exports2.XMLReader = XMLReader;
2159
- exports2.ParseError = ParseError;
2160
- }
2161
- });
2162
-
2163
- // ../../node_modules/@xmldom/xmldom/lib/dom-parser.js
2164
- var require_dom_parser = __commonJS({
2165
- "../../node_modules/@xmldom/xmldom/lib/dom-parser.js"(exports2) {
2166
- var conventions = require_conventions();
2167
- var dom = require_dom();
2168
- var entities = require_entities();
2169
- var sax = require_sax();
2170
- var DOMImplementation = dom.DOMImplementation;
2171
- var NAMESPACE = conventions.NAMESPACE;
2172
- var ParseError = sax.ParseError;
2173
- var XMLReader = sax.XMLReader;
2174
- function DOMParser2(options) {
2175
- this.options = options || { locator: {} };
2176
- }
2177
- DOMParser2.prototype.parseFromString = function(source, mimeType) {
2178
- var options = this.options;
2179
- var sax2 = new XMLReader();
2180
- var domBuilder = options.domBuilder || new DOMHandler();
2181
- var errorHandler = options.errorHandler;
2182
- var locator = options.locator;
2183
- var defaultNSMap = options.xmlns || {};
2184
- var isHTML = /\/x?html?$/.test(mimeType);
2185
- var entityMap = isHTML ? entities.HTML_ENTITIES : entities.XML_ENTITIES;
2186
- if (locator) {
2187
- domBuilder.setDocumentLocator(locator);
2188
- }
2189
- sax2.errorHandler = buildErrorHandler(errorHandler, domBuilder, locator);
2190
- sax2.domBuilder = options.domBuilder || domBuilder;
2191
- if (isHTML) {
2192
- defaultNSMap[""] = NAMESPACE.HTML;
2193
- }
2194
- defaultNSMap.xml = defaultNSMap.xml || NAMESPACE.XML;
2195
- if (source && typeof source === "string") {
2196
- sax2.parse(source, defaultNSMap, entityMap);
2197
- } else {
2198
- sax2.errorHandler.error("invalid doc source");
2199
- }
2200
- return domBuilder.doc;
2201
- };
2202
- function buildErrorHandler(errorImpl, domBuilder, locator) {
2203
- if (!errorImpl) {
2204
- if (domBuilder instanceof DOMHandler) {
2205
- return domBuilder;
2206
- }
2207
- errorImpl = domBuilder;
2208
- }
2209
- var errorHandler = {};
2210
- var isCallback = errorImpl instanceof Function;
2211
- locator = locator || {};
2212
- function build(key) {
2213
- var fn = errorImpl[key];
2214
- if (!fn && isCallback) {
2215
- fn = errorImpl.length == 2 ? function(msg) {
2216
- errorImpl(key, msg);
2217
- } : errorImpl;
2218
- }
2219
- errorHandler[key] = fn && function(msg) {
2220
- fn("[xmldom " + key + "] " + msg + _locator(locator));
2221
- } || function() {
2222
- };
2223
- }
2224
- build("warning");
2225
- build("error");
2226
- build("fatalError");
2227
- return errorHandler;
2228
- }
2229
- function DOMHandler() {
2230
- this.cdata = false;
2231
- }
2232
- function position(locator, node) {
2233
- node.lineNumber = locator.lineNumber;
2234
- node.columnNumber = locator.columnNumber;
2235
- }
2236
- DOMHandler.prototype = {
2237
- startDocument: function() {
2238
- this.doc = new DOMImplementation().createDocument(null, null, null);
2239
- if (this.locator) {
2240
- this.doc.documentURI = this.locator.systemId;
2241
- }
2242
- },
2243
- startElement: function(namespaceURI, localName, qName, attrs) {
2244
- var doc = this.doc;
2245
- var el = doc.createElementNS(namespaceURI, qName || localName);
2246
- var len = attrs.length;
2247
- appendElement(this, el);
2248
- this.currentElement = el;
2249
- this.locator && position(this.locator, el);
2250
- for (var i = 0; i < len; i++) {
2251
- var namespaceURI = attrs.getURI(i);
2252
- var value = attrs.getValue(i);
2253
- var qName = attrs.getQName(i);
2254
- var attr = doc.createAttributeNS(namespaceURI, qName);
2255
- this.locator && position(attrs.getLocator(i), attr);
2256
- attr.value = attr.nodeValue = value;
2257
- el.setAttributeNode(attr);
2258
- }
2259
- },
2260
- endElement: function(namespaceURI, localName, qName) {
2261
- var current = this.currentElement;
2262
- var tagName = current.tagName;
2263
- this.currentElement = current.parentNode;
2264
- },
2265
- startPrefixMapping: function(prefix, uri) {
2266
- },
2267
- endPrefixMapping: function(prefix) {
2268
- },
2269
- processingInstruction: function(target, data) {
2270
- var ins = this.doc.createProcessingInstruction(target, data);
2271
- this.locator && position(this.locator, ins);
2272
- appendElement(this, ins);
2273
- },
2274
- ignorableWhitespace: function(ch, start, length) {
2275
- },
2276
- characters: function(chars, start, length) {
2277
- chars = _toString.apply(this, arguments);
2278
- if (chars) {
2279
- if (this.cdata) {
2280
- var charNode = this.doc.createCDATASection(chars);
2281
- } else {
2282
- var charNode = this.doc.createTextNode(chars);
2283
- }
2284
- if (this.currentElement) {
2285
- this.currentElement.appendChild(charNode);
2286
- } else if (/^\s*$/.test(chars)) {
2287
- this.doc.appendChild(charNode);
2288
- }
2289
- this.locator && position(this.locator, charNode);
2290
- }
2291
- },
2292
- skippedEntity: function(name) {
2293
- },
2294
- endDocument: function() {
2295
- this.doc.normalize();
2296
- },
2297
- setDocumentLocator: function(locator) {
2298
- if (this.locator = locator) {
2299
- locator.lineNumber = 0;
2300
- }
2301
- },
2302
- comment: function(chars, start, length) {
2303
- chars = _toString.apply(this, arguments);
2304
- var comm = this.doc.createComment(chars);
2305
- this.locator && position(this.locator, comm);
2306
- appendElement(this, comm);
2307
- },
2308
- startCDATA: function() {
2309
- this.cdata = true;
2310
- },
2311
- endCDATA: function() {
2312
- this.cdata = false;
2313
- },
2314
- startDTD: function(name, publicId, systemId) {
2315
- var impl = this.doc.implementation;
2316
- if (impl && impl.createDocumentType) {
2317
- var dt = impl.createDocumentType(name, publicId, systemId);
2318
- this.locator && position(this.locator, dt);
2319
- appendElement(this, dt);
2320
- this.doc.doctype = dt;
2321
- }
2322
- },
2323
- warning: function(error) {
2324
- console.warn("[xmldom warning] " + error, _locator(this.locator));
2325
- },
2326
- error: function(error) {
2327
- console.error("[xmldom error] " + error, _locator(this.locator));
2328
- },
2329
- fatalError: function(error) {
2330
- throw new ParseError(error, this.locator);
2331
- }
2332
- };
2333
- function _locator(l) {
2334
- if (l) {
2335
- return "\n@" + (l.systemId || "") + "#[line:" + l.lineNumber + ",col:" + l.columnNumber + "]";
2336
- }
2337
- }
2338
- function _toString(chars, start, length) {
2339
- if (typeof chars == "string") {
2340
- return chars.substr(start, length);
2341
- } else {
2342
- if (chars.length >= start + length || start) {
2343
- return new java.lang.String(chars, start, length) + "";
2344
- }
2345
- return chars;
2346
- }
2347
- }
2348
- "endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g, function(key) {
2349
- DOMHandler.prototype[key] = function() {
2350
- return null;
2351
- };
2352
- });
2353
- function appendElement(hander, node) {
2354
- if (!hander.currentElement) {
2355
- hander.doc.appendChild(node);
2356
- } else {
2357
- hander.currentElement.appendChild(node);
2358
- }
2359
- }
2360
- exports2.__DOMHandler = DOMHandler;
2361
- exports2.DOMParser = DOMParser2;
2362
- exports2.DOMImplementation = dom.DOMImplementation;
2363
- exports2.XMLSerializer = dom.XMLSerializer;
2364
- }
2365
- });
2366
-
2367
- // ../../node_modules/@xmldom/xmldom/lib/index.js
2368
- var require_lib = __commonJS({
2369
- "../../node_modules/@xmldom/xmldom/lib/index.js"(exports2) {
2370
- var dom = require_dom();
2371
- exports2.DOMImplementation = dom.DOMImplementation;
2372
- exports2.XMLSerializer = dom.XMLSerializer;
2373
- exports2.DOMParser = require_dom_parser().DOMParser;
2374
- }
2375
- });
2376
-
2377
45
  // ../../node_modules/contentstream/node_modules/isarray/index.js
2378
46
  var require_isarray = __commonJS({
2379
47
  "../../node_modules/contentstream/node_modules/isarray/index.js"(exports2, module2) {
@@ -26293,7 +23961,7 @@ var require_ber = __commonJS({
26293
23961
  });
26294
23962
 
26295
23963
  // ../../node_modules/asn1/lib/index.js
26296
- var require_lib2 = __commonJS({
23964
+ var require_lib = __commonJS({
26297
23965
  "../../node_modules/asn1/lib/index.js"(exports2, module2) {
26298
23966
  var Ber = require_ber();
26299
23967
  module2.exports = {
@@ -30462,7 +28130,7 @@ var require_utils = __commonJS({
30462
28130
  var Key = require_key();
30463
28131
  var crypto = require("crypto");
30464
28132
  var algs = require_algs();
30465
- var asn1 = require_lib2();
28133
+ var asn1 = require_lib();
30466
28134
  var ec = require_ec();
30467
28135
  var jsbn = require_jsbn().BigInteger;
30468
28136
  var nacl = require_nacl_fast();
@@ -30922,7 +28590,7 @@ var require_signature = __commonJS({
30922
28590
  var crypto = require("crypto");
30923
28591
  var errs = require_errors();
30924
28592
  var utils = require_utils();
30925
- var asn1 = require_lib2();
28593
+ var asn1 = require_lib();
30926
28594
  var SSHBuffer = require_ssh_buffer();
30927
28595
  var InvalidAlgorithmError = errs.InvalidAlgorithmError;
30928
28596
  var SignatureParseError = errs.SignatureParseError;
@@ -31752,7 +29420,7 @@ var require_pkcs8 = __commonJS({
31752
29420
  writeECDSACurve
31753
29421
  };
31754
29422
  var assert3 = require_assert();
31755
- var asn1 = require_lib2();
29423
+ var asn1 = require_lib();
31756
29424
  var Buffer2 = require_safer().Buffer;
31757
29425
  var algs = require_algs();
31758
29426
  var utils = require_utils();
@@ -32235,7 +29903,7 @@ var require_pkcs1 = __commonJS({
32235
29903
  writePkcs1
32236
29904
  };
32237
29905
  var assert3 = require_assert();
32238
- var asn1 = require_lib2();
29906
+ var asn1 = require_lib();
32239
29907
  var Buffer2 = require_safer().Buffer;
32240
29908
  var algs = require_algs();
32241
29909
  var utils = require_utils();
@@ -33928,7 +31596,7 @@ var require_ssh_private = __commonJS({
33928
31596
  write
33929
31597
  };
33930
31598
  var assert3 = require_assert();
33931
- var asn1 = require_lib2();
31599
+ var asn1 = require_lib();
33932
31600
  var Buffer2 = require_safer().Buffer;
33933
31601
  var algs = require_algs();
33934
31602
  var utils = require_utils();
@@ -34141,7 +31809,7 @@ var require_pem = __commonJS({
34141
31809
  write
34142
31810
  };
34143
31811
  var assert3 = require_assert();
34144
- var asn1 = require_lib2();
31812
+ var asn1 = require_lib();
34145
31813
  var crypto = require("crypto");
34146
31814
  var Buffer2 = require_safer().Buffer;
34147
31815
  var algs = require_algs();
@@ -35173,7 +32841,7 @@ var require_identity = __commonJS({
35173
32841
  var errs = require_errors();
35174
32842
  var util = require("util");
35175
32843
  var utils = require_utils();
35176
- var asn1 = require_lib2();
32844
+ var asn1 = require_lib();
35177
32845
  var Buffer2 = require_safer().Buffer;
35178
32846
  var DNS_NAME_RE = /^([*]|[a-z0-9][a-z0-9\-]{0,62})(?:\.([*]|[a-z0-9][a-z0-9\-]{0,62}))*$/i;
35179
32847
  var oids = {};
@@ -35760,7 +33428,7 @@ var require_x509 = __commonJS({
35760
33428
  write
35761
33429
  };
35762
33430
  var assert3 = require_assert();
35763
- var asn1 = require_lib2();
33431
+ var asn1 = require_lib();
35764
33432
  var Buffer2 = require_safer().Buffer;
35765
33433
  var algs = require_algs();
35766
33434
  var utils = require_utils();
@@ -36354,7 +34022,7 @@ var require_x509_pem = __commonJS({
36354
34022
  write
36355
34023
  };
36356
34024
  var assert3 = require_assert();
36357
- var asn1 = require_lib2();
34025
+ var asn1 = require_lib();
36358
34026
  var Buffer2 = require_safer().Buffer;
36359
34027
  var algs = require_algs();
36360
34028
  var utils = require_utils();
@@ -37181,7 +34849,7 @@ var require_key = __commonJS({
37181
34849
  });
37182
34850
 
37183
34851
  // ../../node_modules/sshpk/lib/index.js
37184
- var require_lib3 = __commonJS({
34852
+ var require_lib2 = __commonJS({
37185
34853
  "../../node_modules/sshpk/lib/index.js"(exports2, module2) {
37186
34854
  var Key = require_key();
37187
34855
  var Fingerprint = require_fingerprint();
@@ -37224,7 +34892,7 @@ var require_lib3 = __commonJS({
37224
34892
  var require_utils2 = __commonJS({
37225
34893
  "../../node_modules/http-signature/lib/utils.js"(exports2, module2) {
37226
34894
  var assert3 = require_assert();
37227
- var sshpk = require_lib3();
34895
+ var sshpk = require_lib2();
37228
34896
  var util = require("util");
37229
34897
  var HASH_ALGOS = {
37230
34898
  "sha1": true,
@@ -38710,7 +36378,7 @@ var require_signer = __commonJS({
38710
36378
  var crypto = require("crypto");
38711
36379
  var http2 = require("http");
38712
36380
  var util = require("util");
38713
- var sshpk = require_lib3();
36381
+ var sshpk = require_lib2();
38714
36382
  var jsprim = require_jsprim();
38715
36383
  var utils = require_utils2();
38716
36384
  var sprintf = require("util").format;
@@ -38933,7 +36601,7 @@ var require_verify = __commonJS({
38933
36601
  "../../node_modules/http-signature/lib/verify.js"(exports2, module2) {
38934
36602
  var assert3 = require_assert();
38935
36603
  var crypto = require("crypto");
38936
- var sshpk = require_lib3();
36604
+ var sshpk = require_lib2();
38937
36605
  var utils = require_utils2();
38938
36606
  var HASH_ALGOS = utils.HASH_ALGOS;
38939
36607
  var PK_ALGOS = utils.PK_ALGOS;
@@ -38979,7 +36647,7 @@ var require_verify = __commonJS({
38979
36647
  });
38980
36648
 
38981
36649
  // ../../node_modules/http-signature/lib/index.js
38982
- var require_lib4 = __commonJS({
36650
+ var require_lib3 = __commonJS({
38983
36651
  "../../node_modules/http-signature/lib/index.js"(exports2, module2) {
38984
36652
  var parser = require_parser3();
38985
36653
  var signer = require_signer();
@@ -49151,7 +46819,7 @@ var require_parse = __commonJS({
49151
46819
  });
49152
46820
 
49153
46821
  // ../../node_modules/request/node_modules/qs/lib/index.js
49154
- var require_lib5 = __commonJS({
46822
+ var require_lib4 = __commonJS({
49155
46823
  "../../node_modules/request/node_modules/qs/lib/index.js"(exports2, module2) {
49156
46824
  "use strict";
49157
46825
  var stringify = require_stringify2();
@@ -49169,7 +46837,7 @@ var require_lib5 = __commonJS({
49169
46837
  var require_querystring = __commonJS({
49170
46838
  "../../node_modules/request/lib/querystring.js"(exports2) {
49171
46839
  "use strict";
49172
- var qs = require_lib5();
46840
+ var qs = require_lib4();
49173
46841
  var querystring = require("querystring");
49174
46842
  function Querystring(request) {
49175
46843
  this.request = request;
@@ -56212,7 +53880,7 @@ var require_timings = __commonJS({
56212
53880
  });
56213
53881
 
56214
53882
  // ../../node_modules/har-schema/lib/index.js
56215
- var require_lib6 = __commonJS({
53883
+ var require_lib5 = __commonJS({
56216
53884
  "../../node_modules/har-schema/lib/index.js"(exports2, module2) {
56217
53885
  "use strict";
56218
53886
  module2.exports = {
@@ -56403,7 +54071,7 @@ var require_promise = __commonJS({
56403
54071
  "../../node_modules/har-validator/lib/promise.js"(exports2) {
56404
54072
  var Ajv = require_ajv();
56405
54073
  var HARError = require_error();
56406
- var schemas = require_lib6();
54074
+ var schemas = require_lib5();
56407
54075
  var ajv;
56408
54076
  function createAjvInstance() {
56409
54077
  var ajv2 = new Ajv({
@@ -56959,7 +54627,7 @@ var require_oauth = __commonJS({
56959
54627
  "../../node_modules/request/lib/oauth.js"(exports2) {
56960
54628
  "use strict";
56961
54629
  var url = require("url");
56962
- var qs = require_lib5();
54630
+ var qs = require_lib4();
56963
54631
  var caseless = require_caseless();
56964
54632
  var uuid = require_v4();
56965
54633
  var oauth = require_oauth_sign();
@@ -57757,7 +55425,7 @@ var require_request2 = __commonJS({
57757
55425
  var zlib2 = require("zlib");
57758
55426
  var aws2 = require_aws_sign2();
57759
55427
  var aws4 = require_aws4();
57760
- var httpSignature = require_lib4();
55428
+ var httpSignature = require_lib3();
57761
55429
  var mime = require_mime_types();
57762
55430
  var caseless = require_caseless();
57763
55431
  var ForeverAgent = require_forever_agent();
@@ -63435,337 +61103,14 @@ var require_ktx_parse = __commonJS({
63435
61103
  }
63436
61104
  });
63437
61105
 
63438
- // ../worker-utils/src/lib/env-utils/version.ts
63439
- var VERSION = true ? "4.0.0-alpha.6" : DEFAULT_VERSION;
63440
- if (false) {
63441
- console.error("loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.");
63442
- }
63443
-
63444
- // ../worker-utils/src/lib/env-utils/assert.ts
63445
- function assert(condition, message) {
63446
- if (!condition) {
63447
- throw new Error(message || "loaders.gl assertion failed.");
63448
- }
63449
- }
63450
-
63451
- // ../worker-utils/src/lib/env-utils/globals.ts
63452
- var globals = {
63453
- self: typeof self !== "undefined" && self,
63454
- window: typeof window !== "undefined" && window,
63455
- global: typeof global !== "undefined" && global,
63456
- document: typeof document !== "undefined" && document
63457
- };
63458
- var self_ = globals.self || globals.window || globals.global || {};
63459
- var window_ = globals.window || globals.self || globals.global || {};
63460
- var global_ = globals.global || globals.self || globals.window || {};
63461
- var document_ = globals.document || {};
63462
- var isBrowser = typeof process !== "object" || String(process) !== "[object process]" || process.browser;
63463
- var isWorker = typeof importScripts === "function";
63464
- var isMobile = typeof window !== "undefined" && typeof window.orientation !== "undefined";
63465
- var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
63466
- var nodeVersion = matches && parseFloat(matches[1]) || 0;
63467
-
63468
- // ../worker-utils/src/lib/worker-utils/get-transfer-list.ts
63469
- function getTransferList(object, recursive = true, transfers) {
63470
- const transfersSet = transfers || new Set();
63471
- if (!object) {
63472
- } else if (isTransferable(object)) {
63473
- transfersSet.add(object);
63474
- } else if (isTransferable(object.buffer)) {
63475
- transfersSet.add(object.buffer);
63476
- } else if (ArrayBuffer.isView(object)) {
63477
- } else if (recursive && typeof object === "object") {
63478
- for (const key in object) {
63479
- getTransferList(object[key], recursive, transfersSet);
63480
- }
63481
- }
63482
- return transfers === void 0 ? Array.from(transfersSet) : [];
63483
- }
63484
- function isTransferable(object) {
63485
- if (!object) {
63486
- return false;
63487
- }
63488
- if (object instanceof ArrayBuffer) {
63489
- return true;
63490
- }
63491
- if (typeof MessagePort !== "undefined" && object instanceof MessagePort) {
63492
- return true;
63493
- }
63494
- if (typeof ImageBitmap !== "undefined" && object instanceof ImageBitmap) {
63495
- return true;
63496
- }
63497
- if (typeof OffscreenCanvas !== "undefined" && object instanceof OffscreenCanvas) {
63498
- return true;
63499
- }
63500
- return false;
63501
- }
63502
-
63503
- // ../worker-utils/src/lib/worker-farm/worker-body.ts
63504
- function getParentPort() {
63505
- let parentPort;
63506
- try {
63507
- eval("globalThis.parentPort = require('worker_threads').parentPort");
63508
- parentPort = globalThis.parentPort;
63509
- } catch {
63510
- }
63511
- return parentPort;
63512
- }
63513
- var onMessageWrapperMap = new Map();
63514
- var WorkerBody = class {
63515
- static inWorkerThread() {
63516
- return typeof self !== "undefined" || Boolean(getParentPort());
63517
- }
63518
- static set onmessage(onMessage) {
63519
- function handleMessage(message) {
63520
- const parentPort3 = getParentPort();
63521
- const { type, payload } = parentPort3 ? message : message.data;
63522
- onMessage(type, payload);
63523
- }
63524
- const parentPort2 = getParentPort();
63525
- if (parentPort2) {
63526
- parentPort2.on("message", handleMessage);
63527
- parentPort2.on("exit", () => console.debug("Node worker closing"));
63528
- } else {
63529
- globalThis.onmessage = handleMessage;
63530
- }
63531
- }
63532
- static addEventListener(onMessage) {
63533
- let onMessageWrapper = onMessageWrapperMap.get(onMessage);
63534
- if (!onMessageWrapper) {
63535
- onMessageWrapper = (message) => {
63536
- if (!isKnownMessage(message)) {
63537
- return;
63538
- }
63539
- const parentPort3 = getParentPort();
63540
- const { type, payload } = parentPort3 ? message : message.data;
63541
- onMessage(type, payload);
63542
- };
63543
- }
63544
- const parentPort2 = getParentPort();
63545
- if (parentPort2) {
63546
- console.error("not implemented");
63547
- } else {
63548
- globalThis.addEventListener("message", onMessageWrapper);
63549
- }
63550
- }
63551
- static removeEventListener(onMessage) {
63552
- const onMessageWrapper = onMessageWrapperMap.get(onMessage);
63553
- onMessageWrapperMap.delete(onMessage);
63554
- const parentPort2 = getParentPort();
63555
- if (parentPort2) {
63556
- console.error("not implemented");
63557
- } else {
63558
- globalThis.removeEventListener("message", onMessageWrapper);
63559
- }
63560
- }
63561
- static postMessage(type, payload) {
63562
- const data = { source: "loaders.gl", type, payload };
63563
- const transferList = getTransferList(payload);
63564
- const parentPort2 = getParentPort();
63565
- if (parentPort2) {
63566
- parentPort2.postMessage(data, transferList);
63567
- } else {
63568
- globalThis.postMessage(data, transferList);
63569
- }
63570
- }
63571
- };
63572
- function isKnownMessage(message) {
63573
- const { type, data } = message;
63574
- return type === "message" && data && typeof data.source === "string" && data.source.startsWith("loaders.gl");
63575
- }
63576
-
63577
- // ../worker-utils/src/lib/node/require-utils.node.ts
63578
- var require_utils_node_exports = {};
63579
- __export(require_utils_node_exports, {
63580
- requireFromFile: () => requireFromFile,
63581
- requireFromString: () => requireFromString
63582
- });
63583
- var import_module = __toModule(require("module"));
63584
- var import_path = __toModule(require("path"));
63585
- async function requireFromFile(filename) {
63586
- if (filename.startsWith("http")) {
63587
- const response = await fetch(filename);
63588
- const code = await response.text();
63589
- return requireFromString(code);
63590
- }
63591
- if (!filename.startsWith("/")) {
63592
- filename = `${process.cwd()}/${filename}`;
63593
- }
63594
- return require(filename);
63595
- }
63596
- function requireFromString(code, filename = "", options) {
63597
- if (typeof filename === "object") {
63598
- options = filename;
63599
- filename = "";
63600
- }
63601
- if (typeof code !== "string") {
63602
- throw new Error(`code must be a string, not ${typeof code}`);
63603
- }
63604
- const paths = import_module.default._nodeModulePaths(import_path.default.dirname(filename));
63605
- const parent = module.parent;
63606
- const newModule = new import_module.default(filename, parent);
63607
- newModule.filename = filename;
63608
- newModule.paths = [].concat((options == null ? void 0 : options.prependPaths) || []).concat(paths).concat((options == null ? void 0 : options.appendPaths) || []);
63609
- newModule._compile(code, filename);
63610
- if (parent && parent.children) {
63611
- parent.children.splice(parent.children.indexOf(newModule), 1);
63612
- }
63613
- return newModule.exports;
63614
- }
63615
-
63616
- // ../worker-utils/src/lib/library-utils/library-utils.ts
63617
- var LATEST = "beta";
63618
- var VERSION2 = typeof VERSION !== "undefined" ? VERSION : LATEST;
63619
- var loadLibraryPromises = {};
63620
- async function loadLibrary(libraryUrl, moduleName = null, options = {}) {
63621
- if (moduleName) {
63622
- libraryUrl = getLibraryUrl(libraryUrl, moduleName, options);
63623
- }
63624
- loadLibraryPromises[libraryUrl] = loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl);
63625
- return await loadLibraryPromises[libraryUrl];
63626
- }
63627
- function getLibraryUrl(library, moduleName, options) {
63628
- if (library.startsWith("http")) {
63629
- return library;
63630
- }
63631
- const modules = options.modules || {};
63632
- if (modules[library]) {
63633
- return modules[library];
63634
- }
63635
- if (!isBrowser) {
63636
- return `modules/${moduleName}/dist/libs/${library}`;
63637
- }
63638
- if (options.CDN) {
63639
- assert(options.CDN.startsWith("http"));
63640
- return `${options.CDN}/${moduleName}@${VERSION2}/dist/libs/${library}`;
63641
- }
63642
- if (isWorker) {
63643
- return `../src/libs/${library}`;
63644
- }
63645
- return `modules/${moduleName}/src/libs/${library}`;
63646
- }
63647
- async function loadLibraryFromFile(libraryUrl) {
63648
- if (libraryUrl.endsWith("wasm")) {
63649
- const response2 = await fetch(libraryUrl);
63650
- return await response2.arrayBuffer();
63651
- }
63652
- if (!isBrowser) {
63653
- try {
63654
- return require_utils_node_exports && requireFromFile && await requireFromFile(libraryUrl);
63655
- } catch {
63656
- return null;
63657
- }
63658
- }
63659
- if (isWorker) {
63660
- return importScripts(libraryUrl);
63661
- }
63662
- const response = await fetch(libraryUrl);
63663
- const scriptSource = await response.text();
63664
- return loadLibraryFromString(scriptSource, libraryUrl);
63665
- }
63666
- function loadLibraryFromString(scriptSource, id) {
63667
- if (!isBrowser) {
63668
- return requireFromString && requireFromString(scriptSource, id);
63669
- }
63670
- if (isWorker) {
63671
- eval.call(global_, scriptSource);
63672
- return null;
63673
- }
63674
- const script = document.createElement("script");
63675
- script.id = id;
63676
- try {
63677
- script.appendChild(document.createTextNode(scriptSource));
63678
- } catch (e) {
63679
- script.text = scriptSource;
63680
- }
63681
- document.body.appendChild(script);
63682
- return null;
63683
- }
63684
-
63685
- // ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
63686
- var requestId = 0;
63687
- function createLoaderWorker(loader) {
63688
- if (!WorkerBody.inWorkerThread()) {
63689
- return;
63690
- }
63691
- WorkerBody.onmessage = async (type, payload) => {
63692
- switch (type) {
63693
- case "process":
63694
- try {
63695
- const { input, options = {}, context = {} } = payload;
63696
- const result = await parseData({
63697
- loader,
63698
- arrayBuffer: input,
63699
- options,
63700
- context: __spreadProps(__spreadValues({}, context), {
63701
- parse: parseOnMainThread
63702
- })
63703
- });
63704
- WorkerBody.postMessage("done", { result });
63705
- } catch (error) {
63706
- const message = error instanceof Error ? error.message : "";
63707
- WorkerBody.postMessage("error", { error: message });
63708
- }
63709
- break;
63710
- default:
63711
- }
63712
- };
63713
- }
63714
- function parseOnMainThread(arrayBuffer, options) {
63715
- return new Promise((resolve, reject) => {
63716
- const id = requestId++;
63717
- const onMessage = (type, payload2) => {
63718
- if (payload2.id !== id) {
63719
- return;
63720
- }
63721
- switch (type) {
63722
- case "done":
63723
- WorkerBody.removeEventListener(onMessage);
63724
- resolve(payload2.result);
63725
- break;
63726
- case "error":
63727
- WorkerBody.removeEventListener(onMessage);
63728
- reject(payload2.error);
63729
- break;
63730
- default:
63731
- }
63732
- };
63733
- WorkerBody.addEventListener(onMessage);
63734
- const payload = { id, input: arrayBuffer, options };
63735
- WorkerBody.postMessage("process", payload);
63736
- });
63737
- }
63738
- async function parseData({ loader, arrayBuffer, options, context }) {
63739
- let data;
63740
- let parser;
63741
- if (loader.parseSync || loader.parse) {
63742
- data = arrayBuffer;
63743
- parser = loader.parseSync || loader.parse;
63744
- } else if (loader.parseTextSync) {
63745
- const textDecoder = new TextDecoder();
63746
- data = textDecoder.decode(arrayBuffer);
63747
- parser = loader.parseTextSync;
63748
- } else {
63749
- throw new Error(`Could not load data with ${loader.name} loader`);
63750
- }
63751
- options = __spreadProps(__spreadValues({}, options), {
63752
- modules: loader && loader.options && loader.options.modules || {},
63753
- worker: false
63754
- });
63755
- return await parser(data, __spreadValues({}, options), context, loader);
63756
- }
63757
-
63758
- // ../polyfills/src/index.ts
63759
- var import_xmldom = __toModule(require_lib());
63760
-
63761
61106
  // ../polyfills/src/utils/globals.ts
63762
- var isBrowser2 = typeof process !== "object" || String(process) !== "[object process]" || process.browser;
63763
- var globals2 = {
61107
+ var isBrowser = typeof process !== "object" || String(process) !== "[object process]" || process.browser;
61108
+ var globals = {
63764
61109
  self: typeof self !== "undefined" && self,
63765
61110
  window: typeof window !== "undefined" && window,
63766
61111
  global: typeof global !== "undefined" && global
63767
61112
  };
63768
- var global_2 = globals2.global || globals2.self || globals2.window;
61113
+ var global_ = globals.global || globals.self || globals.window;
63769
61114
 
63770
61115
  // ../polyfills/src/lib/encoding-indexes.ts
63771
61116
  var encoding_indexes_default = {
@@ -65444,7 +62789,7 @@ function iteratorFor(items) {
65444
62789
  }
65445
62790
 
65446
62791
  // ../polyfills/src/utils/assert.ts
65447
- function assert2(condition, message) {
62792
+ function assert(condition, message) {
65448
62793
  if (!condition) {
65449
62794
  throw new Error(`@loaders.gl/polyfills assertion ${message}`);
65450
62795
  }
@@ -65562,8 +62907,8 @@ var Response = class {
65562
62907
  }
65563
62908
  }
65564
62909
  get body() {
65565
- assert2(!this.bodyUsed);
65566
- assert2(isReadableNodeStream(this._body));
62910
+ assert(!this.bodyUsed);
62911
+ assert(isReadableNodeStream(this._body));
65567
62912
  this.bodyUsed = true;
65568
62913
  return this._body;
65569
62914
  }
@@ -65958,48 +63303,365 @@ var FilePolyfill = class extends BlobPolyfill {
65958
63303
  };
65959
63304
 
65960
63305
  // ../polyfills/src/index.ts
65961
- var installTextEncoder = !isBrowser2 || !("TextEncoder" in global_2);
63306
+ var installTextEncoder = !isBrowser || !("TextEncoder" in global_);
65962
63307
  if (installTextEncoder) {
65963
- global_2["TextEncoder"] = TextEncoder2;
63308
+ global_["TextEncoder"] = TextEncoder2;
65964
63309
  }
65965
- var installTextDecoder = !isBrowser2 || !("TextDecoder" in global_2);
63310
+ var installTextDecoder = !isBrowser || !("TextDecoder" in global_);
65966
63311
  if (installTextDecoder) {
65967
- global_2["TextDecoder"] = TextDecoder2;
65968
- }
65969
- if (!isBrowser2 && !("atob" in global_2) && atob) {
65970
- global_2["atob"] = atob;
63312
+ global_["TextDecoder"] = TextDecoder2;
65971
63313
  }
65972
- if (!isBrowser2 && !("btoa" in global_2) && btoa) {
65973
- global_2["btoa"] = btoa;
63314
+ if (!isBrowser && !("atob" in global_) && atob) {
63315
+ global_["atob"] = atob;
65974
63316
  }
65975
- if (!isBrowser2 && !("Headers" in global_2) && Headers) {
65976
- global_2["Headers"] = Headers;
63317
+ if (!isBrowser && !("btoa" in global_) && btoa) {
63318
+ global_["btoa"] = btoa;
65977
63319
  }
65978
- if (!isBrowser2 && !("Response" in global_2) && Response) {
65979
- global_2["Response"] = Response;
63320
+ if (!isBrowser && !("Headers" in global_) && Headers) {
63321
+ global_["Headers"] = Headers;
65980
63322
  }
65981
- if (!isBrowser2 && !("fetch" in global_2) && fetchNode) {
65982
- global_2["fetch"] = fetchNode;
63323
+ if (!isBrowser && !("Response" in global_) && Response) {
63324
+ global_["Response"] = Response;
65983
63325
  }
65984
- if (!isBrowser2 && !("DOMParser" in global_2) && import_xmldom.DOMParser) {
65985
- global_2["DOMParser"] = import_xmldom.DOMParser;
63326
+ if (!isBrowser && !("fetch" in global_) && fetchNode) {
63327
+ global_["fetch"] = fetchNode;
65986
63328
  }
65987
- if (!isBrowser2 && !("_encodeImageNode" in global_2) && encodeImageNode) {
65988
- global_2["_encodeImageNode"] = encodeImageNode;
63329
+ if (!isBrowser && !("_encodeImageNode" in global_) && encodeImageNode) {
63330
+ global_["_encodeImageNode"] = encodeImageNode;
65989
63331
  }
65990
- if (!isBrowser2 && !("_parseImageNode" in global_2) && parseImageNode) {
65991
- global_2["_parseImageNode"] = parseImageNode;
65992
- global_2["_imageFormatsNode"] = NODE_FORMAT_SUPPORT;
63332
+ if (!isBrowser && !("_parseImageNode" in global_) && parseImageNode) {
63333
+ global_["_parseImageNode"] = parseImageNode;
63334
+ global_["_imageFormatsNode"] = NODE_FORMAT_SUPPORT;
65993
63335
  }
65994
63336
  if (!("allSettled" in Promise)) {
65995
63337
  Promise.allSettled = allSettled;
65996
63338
  }
65997
63339
 
63340
+ // ../worker-utils/src/lib/env-utils/version.ts
63341
+ var VERSION = true ? "4.0.0-alpha.8" : DEFAULT_VERSION;
63342
+ if (false) {
63343
+ console.error("loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.");
63344
+ }
63345
+
63346
+ // ../worker-utils/src/lib/env-utils/assert.ts
63347
+ function assert2(condition, message) {
63348
+ if (!condition) {
63349
+ throw new Error(message || "loaders.gl assertion failed.");
63350
+ }
63351
+ }
63352
+
63353
+ // ../worker-utils/src/lib/env-utils/globals.ts
63354
+ var globals2 = {
63355
+ self: typeof self !== "undefined" && self,
63356
+ window: typeof window !== "undefined" && window,
63357
+ global: typeof global !== "undefined" && global,
63358
+ document: typeof document !== "undefined" && document
63359
+ };
63360
+ var self_ = globals2.self || globals2.window || globals2.global || {};
63361
+ var window_ = globals2.window || globals2.self || globals2.global || {};
63362
+ var global_2 = globals2.global || globals2.self || globals2.window || {};
63363
+ var document_ = globals2.document || {};
63364
+ var isBrowser2 = typeof process !== "object" || String(process) !== "[object process]" || process.browser;
63365
+ var isWorker = typeof importScripts === "function";
63366
+ var isMobile = typeof window !== "undefined" && typeof window.orientation !== "undefined";
63367
+ var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
63368
+ var nodeVersion = matches && parseFloat(matches[1]) || 0;
63369
+
63370
+ // ../worker-utils/src/lib/worker-utils/get-transfer-list.ts
63371
+ function getTransferList(object, recursive = true, transfers) {
63372
+ const transfersSet = transfers || new Set();
63373
+ if (!object) {
63374
+ } else if (isTransferable(object)) {
63375
+ transfersSet.add(object);
63376
+ } else if (isTransferable(object.buffer)) {
63377
+ transfersSet.add(object.buffer);
63378
+ } else if (ArrayBuffer.isView(object)) {
63379
+ } else if (recursive && typeof object === "object") {
63380
+ for (const key in object) {
63381
+ getTransferList(object[key], recursive, transfersSet);
63382
+ }
63383
+ }
63384
+ return transfers === void 0 ? Array.from(transfersSet) : [];
63385
+ }
63386
+ function isTransferable(object) {
63387
+ if (!object) {
63388
+ return false;
63389
+ }
63390
+ if (object instanceof ArrayBuffer) {
63391
+ return true;
63392
+ }
63393
+ if (typeof MessagePort !== "undefined" && object instanceof MessagePort) {
63394
+ return true;
63395
+ }
63396
+ if (typeof ImageBitmap !== "undefined" && object instanceof ImageBitmap) {
63397
+ return true;
63398
+ }
63399
+ if (typeof OffscreenCanvas !== "undefined" && object instanceof OffscreenCanvas) {
63400
+ return true;
63401
+ }
63402
+ return false;
63403
+ }
63404
+
63405
+ // ../worker-utils/src/lib/worker-farm/worker-body.ts
63406
+ function getParentPort() {
63407
+ let parentPort;
63408
+ try {
63409
+ eval("globalThis.parentPort = require('worker_threads').parentPort");
63410
+ parentPort = globalThis.parentPort;
63411
+ } catch {
63412
+ }
63413
+ return parentPort;
63414
+ }
63415
+ var onMessageWrapperMap = new Map();
63416
+ var WorkerBody = class {
63417
+ static inWorkerThread() {
63418
+ return typeof self !== "undefined" || Boolean(getParentPort());
63419
+ }
63420
+ static set onmessage(onMessage) {
63421
+ function handleMessage(message) {
63422
+ const parentPort3 = getParentPort();
63423
+ const { type, payload } = parentPort3 ? message : message.data;
63424
+ onMessage(type, payload);
63425
+ }
63426
+ const parentPort2 = getParentPort();
63427
+ if (parentPort2) {
63428
+ parentPort2.on("message", handleMessage);
63429
+ parentPort2.on("exit", () => console.debug("Node worker closing"));
63430
+ } else {
63431
+ globalThis.onmessage = handleMessage;
63432
+ }
63433
+ }
63434
+ static addEventListener(onMessage) {
63435
+ let onMessageWrapper = onMessageWrapperMap.get(onMessage);
63436
+ if (!onMessageWrapper) {
63437
+ onMessageWrapper = (message) => {
63438
+ if (!isKnownMessage(message)) {
63439
+ return;
63440
+ }
63441
+ const parentPort3 = getParentPort();
63442
+ const { type, payload } = parentPort3 ? message : message.data;
63443
+ onMessage(type, payload);
63444
+ };
63445
+ }
63446
+ const parentPort2 = getParentPort();
63447
+ if (parentPort2) {
63448
+ console.error("not implemented");
63449
+ } else {
63450
+ globalThis.addEventListener("message", onMessageWrapper);
63451
+ }
63452
+ }
63453
+ static removeEventListener(onMessage) {
63454
+ const onMessageWrapper = onMessageWrapperMap.get(onMessage);
63455
+ onMessageWrapperMap.delete(onMessage);
63456
+ const parentPort2 = getParentPort();
63457
+ if (parentPort2) {
63458
+ console.error("not implemented");
63459
+ } else {
63460
+ globalThis.removeEventListener("message", onMessageWrapper);
63461
+ }
63462
+ }
63463
+ static postMessage(type, payload) {
63464
+ const data = { source: "loaders.gl", type, payload };
63465
+ const transferList = getTransferList(payload);
63466
+ const parentPort2 = getParentPort();
63467
+ if (parentPort2) {
63468
+ parentPort2.postMessage(data, transferList);
63469
+ } else {
63470
+ globalThis.postMessage(data, transferList);
63471
+ }
63472
+ }
63473
+ };
63474
+ function isKnownMessage(message) {
63475
+ const { type, data } = message;
63476
+ return type === "message" && data && typeof data.source === "string" && data.source.startsWith("loaders.gl");
63477
+ }
63478
+
63479
+ // ../worker-utils/src/lib/node/require-utils.node.ts
63480
+ var require_utils_node_exports = {};
63481
+ __export(require_utils_node_exports, {
63482
+ requireFromFile: () => requireFromFile,
63483
+ requireFromString: () => requireFromString
63484
+ });
63485
+ var import_module = __toModule(require("module"));
63486
+ var import_path = __toModule(require("path"));
63487
+ async function requireFromFile(filename) {
63488
+ if (filename.startsWith("http")) {
63489
+ const response = await fetch(filename);
63490
+ const code = await response.text();
63491
+ return requireFromString(code);
63492
+ }
63493
+ if (!filename.startsWith("/")) {
63494
+ filename = `${process.cwd()}/${filename}`;
63495
+ }
63496
+ return require(filename);
63497
+ }
63498
+ function requireFromString(code, filename = "", options) {
63499
+ if (typeof filename === "object") {
63500
+ options = filename;
63501
+ filename = "";
63502
+ }
63503
+ if (typeof code !== "string") {
63504
+ throw new Error(`code must be a string, not ${typeof code}`);
63505
+ }
63506
+ const paths = import_module.default._nodeModulePaths(import_path.default.dirname(filename));
63507
+ const parent = module.parent;
63508
+ const newModule = new import_module.default(filename, parent);
63509
+ newModule.filename = filename;
63510
+ newModule.paths = [].concat((options == null ? void 0 : options.prependPaths) || []).concat(paths).concat((options == null ? void 0 : options.appendPaths) || []);
63511
+ newModule._compile(code, filename);
63512
+ if (parent && parent.children) {
63513
+ parent.children.splice(parent.children.indexOf(newModule), 1);
63514
+ }
63515
+ return newModule.exports;
63516
+ }
63517
+
63518
+ // ../worker-utils/src/lib/library-utils/library-utils.ts
63519
+ var LATEST = "beta";
63520
+ var VERSION2 = typeof VERSION !== "undefined" ? VERSION : LATEST;
63521
+ var loadLibraryPromises = {};
63522
+ async function loadLibrary(libraryUrl, moduleName = null, options = {}) {
63523
+ if (moduleName) {
63524
+ libraryUrl = getLibraryUrl(libraryUrl, moduleName, options);
63525
+ }
63526
+ loadLibraryPromises[libraryUrl] = loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl);
63527
+ return await loadLibraryPromises[libraryUrl];
63528
+ }
63529
+ function getLibraryUrl(library, moduleName, options) {
63530
+ if (library.startsWith("http")) {
63531
+ return library;
63532
+ }
63533
+ const modules = options.modules || {};
63534
+ if (modules[library]) {
63535
+ return modules[library];
63536
+ }
63537
+ if (!isBrowser2) {
63538
+ return `modules/${moduleName}/dist/libs/${library}`;
63539
+ }
63540
+ if (options.CDN) {
63541
+ assert2(options.CDN.startsWith("http"));
63542
+ return `${options.CDN}/${moduleName}@${VERSION2}/dist/libs/${library}`;
63543
+ }
63544
+ if (isWorker) {
63545
+ return `../src/libs/${library}`;
63546
+ }
63547
+ return `modules/${moduleName}/src/libs/${library}`;
63548
+ }
63549
+ async function loadLibraryFromFile(libraryUrl) {
63550
+ if (libraryUrl.endsWith("wasm")) {
63551
+ const response2 = await fetch(libraryUrl);
63552
+ return await response2.arrayBuffer();
63553
+ }
63554
+ if (!isBrowser2) {
63555
+ try {
63556
+ return require_utils_node_exports && requireFromFile && await requireFromFile(libraryUrl);
63557
+ } catch {
63558
+ return null;
63559
+ }
63560
+ }
63561
+ if (isWorker) {
63562
+ return importScripts(libraryUrl);
63563
+ }
63564
+ const response = await fetch(libraryUrl);
63565
+ const scriptSource = await response.text();
63566
+ return loadLibraryFromString(scriptSource, libraryUrl);
63567
+ }
63568
+ function loadLibraryFromString(scriptSource, id) {
63569
+ if (!isBrowser2) {
63570
+ return requireFromString && requireFromString(scriptSource, id);
63571
+ }
63572
+ if (isWorker) {
63573
+ eval.call(global_2, scriptSource);
63574
+ return null;
63575
+ }
63576
+ const script = document.createElement("script");
63577
+ script.id = id;
63578
+ try {
63579
+ script.appendChild(document.createTextNode(scriptSource));
63580
+ } catch (e) {
63581
+ script.text = scriptSource;
63582
+ }
63583
+ document.body.appendChild(script);
63584
+ return null;
63585
+ }
63586
+
63587
+ // ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
63588
+ var requestId = 0;
63589
+ function createLoaderWorker(loader) {
63590
+ if (!WorkerBody.inWorkerThread()) {
63591
+ return;
63592
+ }
63593
+ WorkerBody.onmessage = async (type, payload) => {
63594
+ switch (type) {
63595
+ case "process":
63596
+ try {
63597
+ const { input, options = {}, context = {} } = payload;
63598
+ const result = await parseData({
63599
+ loader,
63600
+ arrayBuffer: input,
63601
+ options,
63602
+ context: __spreadProps(__spreadValues({}, context), {
63603
+ parse: parseOnMainThread
63604
+ })
63605
+ });
63606
+ WorkerBody.postMessage("done", { result });
63607
+ } catch (error) {
63608
+ const message = error instanceof Error ? error.message : "";
63609
+ WorkerBody.postMessage("error", { error: message });
63610
+ }
63611
+ break;
63612
+ default:
63613
+ }
63614
+ };
63615
+ }
63616
+ function parseOnMainThread(arrayBuffer, options) {
63617
+ return new Promise((resolve, reject) => {
63618
+ const id = requestId++;
63619
+ const onMessage = (type, payload2) => {
63620
+ if (payload2.id !== id) {
63621
+ return;
63622
+ }
63623
+ switch (type) {
63624
+ case "done":
63625
+ WorkerBody.removeEventListener(onMessage);
63626
+ resolve(payload2.result);
63627
+ break;
63628
+ case "error":
63629
+ WorkerBody.removeEventListener(onMessage);
63630
+ reject(payload2.error);
63631
+ break;
63632
+ default:
63633
+ }
63634
+ };
63635
+ WorkerBody.addEventListener(onMessage);
63636
+ const payload = { id, input: arrayBuffer, options };
63637
+ WorkerBody.postMessage("process", payload);
63638
+ });
63639
+ }
63640
+ async function parseData({ loader, arrayBuffer, options, context }) {
63641
+ let data;
63642
+ let parser;
63643
+ if (loader.parseSync || loader.parse) {
63644
+ data = arrayBuffer;
63645
+ parser = loader.parseSync || loader.parse;
63646
+ } else if (loader.parseTextSync) {
63647
+ const textDecoder = new TextDecoder();
63648
+ data = textDecoder.decode(arrayBuffer);
63649
+ parser = loader.parseTextSync;
63650
+ } else {
63651
+ throw new Error(`Could not load data with ${loader.name} loader`);
63652
+ }
63653
+ options = __spreadProps(__spreadValues({}, options), {
63654
+ modules: loader && loader.options && loader.options.modules || {},
63655
+ worker: false
63656
+ });
63657
+ return await parser(data, __spreadValues({}, options), context, loader);
63658
+ }
63659
+
65998
63660
  // src/lib/utils/version.ts
65999
- var VERSION3 = true ? "4.0.0-alpha.6" : "beta";
63661
+ var VERSION3 = true ? "4.0.0-alpha.8" : "beta";
66000
63662
 
66001
63663
  // src/lib/parsers/basis-module-loader.ts
66002
- var VERSION4 = true ? "4.0.0-alpha.6" : "beta";
63664
+ var VERSION4 = true ? "4.0.0-alpha.8" : "beta";
66003
63665
  var BASIS_CDN_ENCODER_WASM = `https://unpkg.com/@loaders.gl/textures@${VERSION4}/dist/libs/basis_encoder.wasm`;
66004
63666
  var BASIS_CDN_ENCODER_JS = `https://unpkg.com/@loaders.gl/textures@${VERSION4}/dist/libs/basis_encoder.js`;
66005
63667
  var loadBasisTranscoderPromise;
@@ -66370,7 +64032,7 @@ function selectSupportedBasisFormat() {
66370
64032
  // src/basis-loader.ts
66371
64033
  var BasisWorkerLoader = {
66372
64034
  name: "Basis",
66373
- id: isBrowser ? "basis" : "basis-nodejs",
64035
+ id: "basis",
66374
64036
  module: "textures",
66375
64037
  version: VERSION3,
66376
64038
  worker: true,
@@ -66391,7 +64053,7 @@ var BasisLoader = __spreadProps(__spreadValues({}, BasisWorkerLoader), {
66391
64053
  parse: parseBasis
66392
64054
  });
66393
64055
 
66394
- // src/workers/basis-nodejs-worker.ts
64056
+ // src/workers/basis-worker-node.ts
66395
64057
  createLoaderWorker(BasisLoader);
66396
64058
  /*!
66397
64059
  * Copyright 2010 LearnBoost <dev@learnboost.com>