@loaders.gl/polyfills 4.0.0-alpha.4 → 4.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/dist.min.js +3994 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/encoding-indexes.d.ts +31 -0
- package/dist/lib/encoding-indexes.d.ts.map +1 -0
- package/dist/lib/encoding-indexes.js +30 -0
- package/dist/lib/encoding-indexes.js.map +1 -0
- package/dist/lib/encoding.d.ts +15 -0
- package/dist/lib/encoding.d.ts.map +1 -0
- package/dist/lib/encoding.js +1450 -0
- package/dist/lib/encoding.js.map +1 -0
- package/dist/libs/encoding-indexes-asian.d.ts +10 -0
- package/dist/libs/encoding-indexes-asian.d.ts.map +1 -0
- package/dist/libs/{encoding-indexes.js → encoding-indexes-asian.js} +2 -40
- package/dist/node/buffer/btoa.node.d.ts +3 -0
- package/dist/node/buffer/btoa.node.d.ts.map +1 -0
- package/dist/node/buffer/to-array-buffer.node.d.ts +2 -0
- package/dist/node/buffer/to-array-buffer.node.d.ts.map +1 -0
- package/dist/node/fetch/fetch.node.d.ts +7 -0
- package/dist/node/fetch/fetch.node.d.ts.map +1 -0
- package/dist/node/fetch/headers.node.d.ts +34 -0
- package/dist/node/fetch/headers.node.d.ts.map +1 -0
- package/dist/node/fetch/response.node.d.ts +22 -0
- package/dist/node/fetch/response.node.d.ts.map +1 -0
- package/dist/node/fetch/utils/decode-data-uri.node.d.ts +16 -0
- package/dist/node/fetch/utils/decode-data-uri.node.d.ts.map +1 -0
- package/dist/node/fetch/utils/decode-data-uri.node.js +1 -3
- package/dist/node/fetch/utils/decode-data-uri.node.js.map +1 -1
- package/dist/node/fetch/utils/stream-utils.node.d.ts +10 -0
- package/dist/node/fetch/utils/stream-utils.node.d.ts.map +1 -0
- package/dist/node/fetch/utils/stream-utils.node.js +21 -12
- package/dist/node/fetch/utils/stream-utils.node.js.map +1 -1
- package/dist/node/file/blob-stream-controller.d.ts +29 -0
- package/dist/node/file/blob-stream-controller.d.ts.map +1 -0
- package/dist/node/file/blob-stream.d.ts +25 -0
- package/dist/node/file/blob-stream.d.ts.map +1 -0
- package/dist/node/file/blob.d.ts +58 -0
- package/dist/node/file/blob.d.ts.map +1 -0
- package/dist/node/file/file-reader.d.ts +24 -0
- package/dist/node/file/file-reader.d.ts.map +1 -0
- package/dist/node/file/file.d.ts +25 -0
- package/dist/node/file/file.d.ts.map +1 -0
- package/dist/node/file/install-file-polyfills.d.ts +2 -0
- package/dist/node/file/install-file-polyfills.d.ts.map +1 -0
- package/dist/node/file/readable-stream.d.ts +4 -0
- package/dist/node/file/readable-stream.d.ts.map +1 -0
- package/dist/node/images/encode-image.node.d.ts +20 -0
- package/dist/node/images/encode-image.node.d.ts.map +1 -0
- package/dist/node/images/parse-image.node.d.ts +11 -0
- package/dist/node/images/parse-image.node.d.ts.map +1 -0
- package/dist/promise/all-settled.d.ts +10 -0
- package/dist/promise/all-settled.d.ts.map +1 -0
- package/dist/utils/assert.d.ts +2 -0
- package/dist/utils/assert.d.ts.map +1 -0
- package/dist/utils/globals.d.ts +4 -0
- package/dist/utils/globals.d.ts.map +1 -0
- package/package.json +6 -6
- package/src/index.ts +2 -2
- package/src/lib/encoding-indexes.ts +34 -0
- package/{dist/libs/encoding.js → src/lib/encoding.ts} +78 -78
- package/src/libs/{encoding-indexes.js → encoding-indexes-asian.js} +2 -40
- package/src/node/fetch/utils/decode-data-uri.node.ts +7 -6
- package/src/node/fetch/utils/stream-utils.node.ts +38 -15
- package/src/libs/encoding.js +0 -3084
package/dist/dist.min.js
ADDED
|
@@ -0,0 +1,3994 @@
|
|
|
1
|
+
(() => {
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
9
|
+
var __esm = (fn, res) => function __init() {
|
|
10
|
+
return fn && (res = (0, fn[Object.keys(fn)[0]])(fn = 0)), res;
|
|
11
|
+
};
|
|
12
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
13
|
+
return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
14
|
+
};
|
|
15
|
+
var __export = (target, all) => {
|
|
16
|
+
__markAsModule(target);
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __reExport = (target, module, desc) => {
|
|
21
|
+
if (module && typeof module === "object" || typeof module === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(module))
|
|
23
|
+
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
24
|
+
__defProp(target, key, { get: () => module[key], enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return target;
|
|
27
|
+
};
|
|
28
|
+
var __toModule = (module) => {
|
|
29
|
+
return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// ../../node_modules/@xmldom/xmldom/lib/conventions.js
|
|
33
|
+
var require_conventions = __commonJS({
|
|
34
|
+
"../../node_modules/@xmldom/xmldom/lib/conventions.js"(exports) {
|
|
35
|
+
"use strict";
|
|
36
|
+
function freeze(object, oc) {
|
|
37
|
+
if (oc === void 0) {
|
|
38
|
+
oc = Object;
|
|
39
|
+
}
|
|
40
|
+
return oc && typeof oc.freeze === "function" ? oc.freeze(object) : object;
|
|
41
|
+
}
|
|
42
|
+
var MIME_TYPE = freeze({
|
|
43
|
+
HTML: "text/html",
|
|
44
|
+
isHTML: function(value) {
|
|
45
|
+
return value === MIME_TYPE.HTML;
|
|
46
|
+
},
|
|
47
|
+
XML_APPLICATION: "application/xml",
|
|
48
|
+
XML_TEXT: "text/xml",
|
|
49
|
+
XML_XHTML_APPLICATION: "application/xhtml+xml",
|
|
50
|
+
XML_SVG_IMAGE: "image/svg+xml"
|
|
51
|
+
});
|
|
52
|
+
var NAMESPACE = freeze({
|
|
53
|
+
HTML: "http://www.w3.org/1999/xhtml",
|
|
54
|
+
isHTML: function(uri) {
|
|
55
|
+
return uri === NAMESPACE.HTML;
|
|
56
|
+
},
|
|
57
|
+
SVG: "http://www.w3.org/2000/svg",
|
|
58
|
+
XML: "http://www.w3.org/XML/1998/namespace",
|
|
59
|
+
XMLNS: "http://www.w3.org/2000/xmlns/"
|
|
60
|
+
});
|
|
61
|
+
exports.freeze = freeze;
|
|
62
|
+
exports.MIME_TYPE = MIME_TYPE;
|
|
63
|
+
exports.NAMESPACE = NAMESPACE;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// ../../node_modules/@xmldom/xmldom/lib/dom.js
|
|
68
|
+
var require_dom = __commonJS({
|
|
69
|
+
"../../node_modules/@xmldom/xmldom/lib/dom.js"(exports) {
|
|
70
|
+
var conventions = require_conventions();
|
|
71
|
+
var NAMESPACE = conventions.NAMESPACE;
|
|
72
|
+
function notEmptyString(input) {
|
|
73
|
+
return input !== "";
|
|
74
|
+
}
|
|
75
|
+
function splitOnASCIIWhitespace(input) {
|
|
76
|
+
return input ? input.split(/[\t\n\f\r ]+/).filter(notEmptyString) : [];
|
|
77
|
+
}
|
|
78
|
+
function orderedSetReducer(current, element) {
|
|
79
|
+
if (!current.hasOwnProperty(element)) {
|
|
80
|
+
current[element] = true;
|
|
81
|
+
}
|
|
82
|
+
return current;
|
|
83
|
+
}
|
|
84
|
+
function toOrderedSet(input) {
|
|
85
|
+
if (!input)
|
|
86
|
+
return [];
|
|
87
|
+
var list = splitOnASCIIWhitespace(input);
|
|
88
|
+
return Object.keys(list.reduce(orderedSetReducer, {}));
|
|
89
|
+
}
|
|
90
|
+
function arrayIncludes(list) {
|
|
91
|
+
return function(element) {
|
|
92
|
+
return list && list.indexOf(element) !== -1;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function copy(src, dest) {
|
|
96
|
+
for (var p in src) {
|
|
97
|
+
dest[p] = src[p];
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function _extends(Class, Super) {
|
|
101
|
+
var pt = Class.prototype;
|
|
102
|
+
if (!(pt instanceof Super)) {
|
|
103
|
+
let t2 = function() {
|
|
104
|
+
};
|
|
105
|
+
var t = t2;
|
|
106
|
+
;
|
|
107
|
+
t2.prototype = Super.prototype;
|
|
108
|
+
t2 = new t2();
|
|
109
|
+
copy(pt, t2);
|
|
110
|
+
Class.prototype = pt = t2;
|
|
111
|
+
}
|
|
112
|
+
if (pt.constructor != Class) {
|
|
113
|
+
if (typeof Class != "function") {
|
|
114
|
+
console.error("unknown Class:" + Class);
|
|
115
|
+
}
|
|
116
|
+
pt.constructor = Class;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
var NodeType = {};
|
|
120
|
+
var ELEMENT_NODE = NodeType.ELEMENT_NODE = 1;
|
|
121
|
+
var ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2;
|
|
122
|
+
var TEXT_NODE = NodeType.TEXT_NODE = 3;
|
|
123
|
+
var CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4;
|
|
124
|
+
var ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5;
|
|
125
|
+
var ENTITY_NODE = NodeType.ENTITY_NODE = 6;
|
|
126
|
+
var PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7;
|
|
127
|
+
var COMMENT_NODE = NodeType.COMMENT_NODE = 8;
|
|
128
|
+
var DOCUMENT_NODE = NodeType.DOCUMENT_NODE = 9;
|
|
129
|
+
var DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10;
|
|
130
|
+
var DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11;
|
|
131
|
+
var NOTATION_NODE = NodeType.NOTATION_NODE = 12;
|
|
132
|
+
var ExceptionCode = {};
|
|
133
|
+
var ExceptionMessage = {};
|
|
134
|
+
var INDEX_SIZE_ERR = ExceptionCode.INDEX_SIZE_ERR = (ExceptionMessage[1] = "Index size error", 1);
|
|
135
|
+
var DOMSTRING_SIZE_ERR = ExceptionCode.DOMSTRING_SIZE_ERR = (ExceptionMessage[2] = "DOMString size error", 2);
|
|
136
|
+
var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = (ExceptionMessage[3] = "Hierarchy request error", 3);
|
|
137
|
+
var WRONG_DOCUMENT_ERR = ExceptionCode.WRONG_DOCUMENT_ERR = (ExceptionMessage[4] = "Wrong document", 4);
|
|
138
|
+
var INVALID_CHARACTER_ERR = ExceptionCode.INVALID_CHARACTER_ERR = (ExceptionMessage[5] = "Invalid character", 5);
|
|
139
|
+
var NO_DATA_ALLOWED_ERR = ExceptionCode.NO_DATA_ALLOWED_ERR = (ExceptionMessage[6] = "No data allowed", 6);
|
|
140
|
+
var NO_MODIFICATION_ALLOWED_ERR = ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = (ExceptionMessage[7] = "No modification allowed", 7);
|
|
141
|
+
var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = (ExceptionMessage[8] = "Not found", 8);
|
|
142
|
+
var NOT_SUPPORTED_ERR = ExceptionCode.NOT_SUPPORTED_ERR = (ExceptionMessage[9] = "Not supported", 9);
|
|
143
|
+
var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = (ExceptionMessage[10] = "Attribute in use", 10);
|
|
144
|
+
var INVALID_STATE_ERR = ExceptionCode.INVALID_STATE_ERR = (ExceptionMessage[11] = "Invalid state", 11);
|
|
145
|
+
var SYNTAX_ERR = ExceptionCode.SYNTAX_ERR = (ExceptionMessage[12] = "Syntax error", 12);
|
|
146
|
+
var INVALID_MODIFICATION_ERR = ExceptionCode.INVALID_MODIFICATION_ERR = (ExceptionMessage[13] = "Invalid modification", 13);
|
|
147
|
+
var NAMESPACE_ERR = ExceptionCode.NAMESPACE_ERR = (ExceptionMessage[14] = "Invalid namespace", 14);
|
|
148
|
+
var INVALID_ACCESS_ERR = ExceptionCode.INVALID_ACCESS_ERR = (ExceptionMessage[15] = "Invalid access", 15);
|
|
149
|
+
function DOMException(code, message) {
|
|
150
|
+
if (message instanceof Error) {
|
|
151
|
+
var error = message;
|
|
152
|
+
} else {
|
|
153
|
+
error = this;
|
|
154
|
+
Error.call(this, ExceptionMessage[code]);
|
|
155
|
+
this.message = ExceptionMessage[code];
|
|
156
|
+
if (Error.captureStackTrace)
|
|
157
|
+
Error.captureStackTrace(this, DOMException);
|
|
158
|
+
}
|
|
159
|
+
error.code = code;
|
|
160
|
+
if (message)
|
|
161
|
+
this.message = this.message + ": " + message;
|
|
162
|
+
return error;
|
|
163
|
+
}
|
|
164
|
+
DOMException.prototype = Error.prototype;
|
|
165
|
+
copy(ExceptionCode, DOMException);
|
|
166
|
+
function NodeList() {
|
|
167
|
+
}
|
|
168
|
+
NodeList.prototype = {
|
|
169
|
+
length: 0,
|
|
170
|
+
item: function(index2) {
|
|
171
|
+
return this[index2] || null;
|
|
172
|
+
},
|
|
173
|
+
toString: function(isHTML, nodeFilter) {
|
|
174
|
+
for (var buf = [], i = 0; i < this.length; i++) {
|
|
175
|
+
serializeToString(this[i], buf, isHTML, nodeFilter);
|
|
176
|
+
}
|
|
177
|
+
return buf.join("");
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
function LiveNodeList(node, refresh) {
|
|
181
|
+
this._node = node;
|
|
182
|
+
this._refresh = refresh;
|
|
183
|
+
_updateLiveList(this);
|
|
184
|
+
}
|
|
185
|
+
function _updateLiveList(list) {
|
|
186
|
+
var inc = list._node._inc || list._node.ownerDocument._inc;
|
|
187
|
+
if (list._inc != inc) {
|
|
188
|
+
var ls = list._refresh(list._node);
|
|
189
|
+
__set__(list, "length", ls.length);
|
|
190
|
+
copy(ls, list);
|
|
191
|
+
list._inc = inc;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
LiveNodeList.prototype.item = function(i) {
|
|
195
|
+
_updateLiveList(this);
|
|
196
|
+
return this[i];
|
|
197
|
+
};
|
|
198
|
+
_extends(LiveNodeList, NodeList);
|
|
199
|
+
function NamedNodeMap() {
|
|
200
|
+
}
|
|
201
|
+
function _findNodeIndex(list, node) {
|
|
202
|
+
var i = list.length;
|
|
203
|
+
while (i--) {
|
|
204
|
+
if (list[i] === node) {
|
|
205
|
+
return i;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
function _addNamedNode(el, list, newAttr, oldAttr) {
|
|
210
|
+
if (oldAttr) {
|
|
211
|
+
list[_findNodeIndex(list, oldAttr)] = newAttr;
|
|
212
|
+
} else {
|
|
213
|
+
list[list.length++] = newAttr;
|
|
214
|
+
}
|
|
215
|
+
if (el) {
|
|
216
|
+
newAttr.ownerElement = el;
|
|
217
|
+
var doc = el.ownerDocument;
|
|
218
|
+
if (doc) {
|
|
219
|
+
oldAttr && _onRemoveAttribute(doc, el, oldAttr);
|
|
220
|
+
_onAddAttribute(doc, el, newAttr);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
function _removeNamedNode(el, list, attr) {
|
|
225
|
+
var i = _findNodeIndex(list, attr);
|
|
226
|
+
if (i >= 0) {
|
|
227
|
+
var lastIndex = list.length - 1;
|
|
228
|
+
while (i < lastIndex) {
|
|
229
|
+
list[i] = list[++i];
|
|
230
|
+
}
|
|
231
|
+
list.length = lastIndex;
|
|
232
|
+
if (el) {
|
|
233
|
+
var doc = el.ownerDocument;
|
|
234
|
+
if (doc) {
|
|
235
|
+
_onRemoveAttribute(doc, el, attr);
|
|
236
|
+
attr.ownerElement = null;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
} else {
|
|
240
|
+
throw DOMException(NOT_FOUND_ERR, new Error(el.tagName + "@" + attr));
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
NamedNodeMap.prototype = {
|
|
244
|
+
length: 0,
|
|
245
|
+
item: NodeList.prototype.item,
|
|
246
|
+
getNamedItem: function(key) {
|
|
247
|
+
var i = this.length;
|
|
248
|
+
while (i--) {
|
|
249
|
+
var attr = this[i];
|
|
250
|
+
if (attr.nodeName == key) {
|
|
251
|
+
return attr;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
setNamedItem: function(attr) {
|
|
256
|
+
var el = attr.ownerElement;
|
|
257
|
+
if (el && el != this._ownerElement) {
|
|
258
|
+
throw new DOMException(INUSE_ATTRIBUTE_ERR);
|
|
259
|
+
}
|
|
260
|
+
var oldAttr = this.getNamedItem(attr.nodeName);
|
|
261
|
+
_addNamedNode(this._ownerElement, this, attr, oldAttr);
|
|
262
|
+
return oldAttr;
|
|
263
|
+
},
|
|
264
|
+
setNamedItemNS: function(attr) {
|
|
265
|
+
var el = attr.ownerElement, oldAttr;
|
|
266
|
+
if (el && el != this._ownerElement) {
|
|
267
|
+
throw new DOMException(INUSE_ATTRIBUTE_ERR);
|
|
268
|
+
}
|
|
269
|
+
oldAttr = this.getNamedItemNS(attr.namespaceURI, attr.localName);
|
|
270
|
+
_addNamedNode(this._ownerElement, this, attr, oldAttr);
|
|
271
|
+
return oldAttr;
|
|
272
|
+
},
|
|
273
|
+
removeNamedItem: function(key) {
|
|
274
|
+
var attr = this.getNamedItem(key);
|
|
275
|
+
_removeNamedNode(this._ownerElement, this, attr);
|
|
276
|
+
return attr;
|
|
277
|
+
},
|
|
278
|
+
removeNamedItemNS: function(namespaceURI, localName) {
|
|
279
|
+
var attr = this.getNamedItemNS(namespaceURI, localName);
|
|
280
|
+
_removeNamedNode(this._ownerElement, this, attr);
|
|
281
|
+
return attr;
|
|
282
|
+
},
|
|
283
|
+
getNamedItemNS: function(namespaceURI, localName) {
|
|
284
|
+
var i = this.length;
|
|
285
|
+
while (i--) {
|
|
286
|
+
var node = this[i];
|
|
287
|
+
if (node.localName == localName && node.namespaceURI == namespaceURI) {
|
|
288
|
+
return node;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
function DOMImplementation() {
|
|
295
|
+
}
|
|
296
|
+
DOMImplementation.prototype = {
|
|
297
|
+
hasFeature: function(feature, version) {
|
|
298
|
+
return true;
|
|
299
|
+
},
|
|
300
|
+
createDocument: function(namespaceURI, qualifiedName, doctype) {
|
|
301
|
+
var doc = new Document();
|
|
302
|
+
doc.implementation = this;
|
|
303
|
+
doc.childNodes = new NodeList();
|
|
304
|
+
doc.doctype = doctype || null;
|
|
305
|
+
if (doctype) {
|
|
306
|
+
doc.appendChild(doctype);
|
|
307
|
+
}
|
|
308
|
+
if (qualifiedName) {
|
|
309
|
+
var root = doc.createElementNS(namespaceURI, qualifiedName);
|
|
310
|
+
doc.appendChild(root);
|
|
311
|
+
}
|
|
312
|
+
return doc;
|
|
313
|
+
},
|
|
314
|
+
createDocumentType: function(qualifiedName, publicId, systemId) {
|
|
315
|
+
var node = new DocumentType();
|
|
316
|
+
node.name = qualifiedName;
|
|
317
|
+
node.nodeName = qualifiedName;
|
|
318
|
+
node.publicId = publicId || "";
|
|
319
|
+
node.systemId = systemId || "";
|
|
320
|
+
return node;
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
function Node() {
|
|
324
|
+
}
|
|
325
|
+
Node.prototype = {
|
|
326
|
+
firstChild: null,
|
|
327
|
+
lastChild: null,
|
|
328
|
+
previousSibling: null,
|
|
329
|
+
nextSibling: null,
|
|
330
|
+
attributes: null,
|
|
331
|
+
parentNode: null,
|
|
332
|
+
childNodes: null,
|
|
333
|
+
ownerDocument: null,
|
|
334
|
+
nodeValue: null,
|
|
335
|
+
namespaceURI: null,
|
|
336
|
+
prefix: null,
|
|
337
|
+
localName: null,
|
|
338
|
+
insertBefore: function(newChild, refChild) {
|
|
339
|
+
return _insertBefore(this, newChild, refChild);
|
|
340
|
+
},
|
|
341
|
+
replaceChild: function(newChild, oldChild) {
|
|
342
|
+
this.insertBefore(newChild, oldChild);
|
|
343
|
+
if (oldChild) {
|
|
344
|
+
this.removeChild(oldChild);
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
removeChild: function(oldChild) {
|
|
348
|
+
return _removeChild(this, oldChild);
|
|
349
|
+
},
|
|
350
|
+
appendChild: function(newChild) {
|
|
351
|
+
return this.insertBefore(newChild, null);
|
|
352
|
+
},
|
|
353
|
+
hasChildNodes: function() {
|
|
354
|
+
return this.firstChild != null;
|
|
355
|
+
},
|
|
356
|
+
cloneNode: function(deep) {
|
|
357
|
+
return cloneNode(this.ownerDocument || this, this, deep);
|
|
358
|
+
},
|
|
359
|
+
normalize: function() {
|
|
360
|
+
var child = this.firstChild;
|
|
361
|
+
while (child) {
|
|
362
|
+
var next = child.nextSibling;
|
|
363
|
+
if (next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE) {
|
|
364
|
+
this.removeChild(next);
|
|
365
|
+
child.appendData(next.data);
|
|
366
|
+
} else {
|
|
367
|
+
child.normalize();
|
|
368
|
+
child = next;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
isSupported: function(feature, version) {
|
|
373
|
+
return this.ownerDocument.implementation.hasFeature(feature, version);
|
|
374
|
+
},
|
|
375
|
+
hasAttributes: function() {
|
|
376
|
+
return this.attributes.length > 0;
|
|
377
|
+
},
|
|
378
|
+
lookupPrefix: function(namespaceURI) {
|
|
379
|
+
var el = this;
|
|
380
|
+
while (el) {
|
|
381
|
+
var map = el._nsMap;
|
|
382
|
+
if (map) {
|
|
383
|
+
for (var n in map) {
|
|
384
|
+
if (map[n] == namespaceURI) {
|
|
385
|
+
return n;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
el = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode;
|
|
390
|
+
}
|
|
391
|
+
return null;
|
|
392
|
+
},
|
|
393
|
+
lookupNamespaceURI: function(prefix) {
|
|
394
|
+
var el = this;
|
|
395
|
+
while (el) {
|
|
396
|
+
var map = el._nsMap;
|
|
397
|
+
if (map) {
|
|
398
|
+
if (prefix in map) {
|
|
399
|
+
return map[prefix];
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
el = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode;
|
|
403
|
+
}
|
|
404
|
+
return null;
|
|
405
|
+
},
|
|
406
|
+
isDefaultNamespace: function(namespaceURI) {
|
|
407
|
+
var prefix = this.lookupPrefix(namespaceURI);
|
|
408
|
+
return prefix == null;
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
function _xmlEncoder(c) {
|
|
412
|
+
return c == "<" && "<" || c == ">" && ">" || c == "&" && "&" || c == '"' && """ || "&#" + c.charCodeAt() + ";";
|
|
413
|
+
}
|
|
414
|
+
copy(NodeType, Node);
|
|
415
|
+
copy(NodeType, Node.prototype);
|
|
416
|
+
function _visitNode(node, callback) {
|
|
417
|
+
if (callback(node)) {
|
|
418
|
+
return true;
|
|
419
|
+
}
|
|
420
|
+
if (node = node.firstChild) {
|
|
421
|
+
do {
|
|
422
|
+
if (_visitNode(node, callback)) {
|
|
423
|
+
return true;
|
|
424
|
+
}
|
|
425
|
+
} while (node = node.nextSibling);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
function Document() {
|
|
429
|
+
}
|
|
430
|
+
function _onAddAttribute(doc, el, newAttr) {
|
|
431
|
+
doc && doc._inc++;
|
|
432
|
+
var ns = newAttr.namespaceURI;
|
|
433
|
+
if (ns === NAMESPACE.XMLNS) {
|
|
434
|
+
el._nsMap[newAttr.prefix ? newAttr.localName : ""] = newAttr.value;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
function _onRemoveAttribute(doc, el, newAttr, remove) {
|
|
438
|
+
doc && doc._inc++;
|
|
439
|
+
var ns = newAttr.namespaceURI;
|
|
440
|
+
if (ns === NAMESPACE.XMLNS) {
|
|
441
|
+
delete el._nsMap[newAttr.prefix ? newAttr.localName : ""];
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
function _onUpdateChild(doc, el, newChild) {
|
|
445
|
+
if (doc && doc._inc) {
|
|
446
|
+
doc._inc++;
|
|
447
|
+
var cs = el.childNodes;
|
|
448
|
+
if (newChild) {
|
|
449
|
+
cs[cs.length++] = newChild;
|
|
450
|
+
} else {
|
|
451
|
+
var child = el.firstChild;
|
|
452
|
+
var i = 0;
|
|
453
|
+
while (child) {
|
|
454
|
+
cs[i++] = child;
|
|
455
|
+
child = child.nextSibling;
|
|
456
|
+
}
|
|
457
|
+
cs.length = i;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
function _removeChild(parentNode, child) {
|
|
462
|
+
var previous = child.previousSibling;
|
|
463
|
+
var next = child.nextSibling;
|
|
464
|
+
if (previous) {
|
|
465
|
+
previous.nextSibling = next;
|
|
466
|
+
} else {
|
|
467
|
+
parentNode.firstChild = next;
|
|
468
|
+
}
|
|
469
|
+
if (next) {
|
|
470
|
+
next.previousSibling = previous;
|
|
471
|
+
} else {
|
|
472
|
+
parentNode.lastChild = previous;
|
|
473
|
+
}
|
|
474
|
+
_onUpdateChild(parentNode.ownerDocument, parentNode);
|
|
475
|
+
return child;
|
|
476
|
+
}
|
|
477
|
+
function _insertBefore(parentNode, newChild, nextChild) {
|
|
478
|
+
var cp = newChild.parentNode;
|
|
479
|
+
if (cp) {
|
|
480
|
+
cp.removeChild(newChild);
|
|
481
|
+
}
|
|
482
|
+
if (newChild.nodeType === DOCUMENT_FRAGMENT_NODE) {
|
|
483
|
+
var newFirst = newChild.firstChild;
|
|
484
|
+
if (newFirst == null) {
|
|
485
|
+
return newChild;
|
|
486
|
+
}
|
|
487
|
+
var newLast = newChild.lastChild;
|
|
488
|
+
} else {
|
|
489
|
+
newFirst = newLast = newChild;
|
|
490
|
+
}
|
|
491
|
+
var pre = nextChild ? nextChild.previousSibling : parentNode.lastChild;
|
|
492
|
+
newFirst.previousSibling = pre;
|
|
493
|
+
newLast.nextSibling = nextChild;
|
|
494
|
+
if (pre) {
|
|
495
|
+
pre.nextSibling = newFirst;
|
|
496
|
+
} else {
|
|
497
|
+
parentNode.firstChild = newFirst;
|
|
498
|
+
}
|
|
499
|
+
if (nextChild == null) {
|
|
500
|
+
parentNode.lastChild = newLast;
|
|
501
|
+
} else {
|
|
502
|
+
nextChild.previousSibling = newLast;
|
|
503
|
+
}
|
|
504
|
+
do {
|
|
505
|
+
newFirst.parentNode = parentNode;
|
|
506
|
+
} while (newFirst !== newLast && (newFirst = newFirst.nextSibling));
|
|
507
|
+
_onUpdateChild(parentNode.ownerDocument || parentNode, parentNode);
|
|
508
|
+
if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) {
|
|
509
|
+
newChild.firstChild = newChild.lastChild = null;
|
|
510
|
+
}
|
|
511
|
+
return newChild;
|
|
512
|
+
}
|
|
513
|
+
function _appendSingleChild(parentNode, newChild) {
|
|
514
|
+
var cp = newChild.parentNode;
|
|
515
|
+
if (cp) {
|
|
516
|
+
var pre = parentNode.lastChild;
|
|
517
|
+
cp.removeChild(newChild);
|
|
518
|
+
var pre = parentNode.lastChild;
|
|
519
|
+
}
|
|
520
|
+
var pre = parentNode.lastChild;
|
|
521
|
+
newChild.parentNode = parentNode;
|
|
522
|
+
newChild.previousSibling = pre;
|
|
523
|
+
newChild.nextSibling = null;
|
|
524
|
+
if (pre) {
|
|
525
|
+
pre.nextSibling = newChild;
|
|
526
|
+
} else {
|
|
527
|
+
parentNode.firstChild = newChild;
|
|
528
|
+
}
|
|
529
|
+
parentNode.lastChild = newChild;
|
|
530
|
+
_onUpdateChild(parentNode.ownerDocument, parentNode, newChild);
|
|
531
|
+
return newChild;
|
|
532
|
+
}
|
|
533
|
+
Document.prototype = {
|
|
534
|
+
nodeName: "#document",
|
|
535
|
+
nodeType: DOCUMENT_NODE,
|
|
536
|
+
doctype: null,
|
|
537
|
+
documentElement: null,
|
|
538
|
+
_inc: 1,
|
|
539
|
+
insertBefore: function(newChild, refChild) {
|
|
540
|
+
if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) {
|
|
541
|
+
var child = newChild.firstChild;
|
|
542
|
+
while (child) {
|
|
543
|
+
var next = child.nextSibling;
|
|
544
|
+
this.insertBefore(child, refChild);
|
|
545
|
+
child = next;
|
|
546
|
+
}
|
|
547
|
+
return newChild;
|
|
548
|
+
}
|
|
549
|
+
if (this.documentElement == null && newChild.nodeType == ELEMENT_NODE) {
|
|
550
|
+
this.documentElement = newChild;
|
|
551
|
+
}
|
|
552
|
+
return _insertBefore(this, newChild, refChild), newChild.ownerDocument = this, newChild;
|
|
553
|
+
},
|
|
554
|
+
removeChild: function(oldChild) {
|
|
555
|
+
if (this.documentElement == oldChild) {
|
|
556
|
+
this.documentElement = null;
|
|
557
|
+
}
|
|
558
|
+
return _removeChild(this, oldChild);
|
|
559
|
+
},
|
|
560
|
+
importNode: function(importedNode, deep) {
|
|
561
|
+
return importNode(this, importedNode, deep);
|
|
562
|
+
},
|
|
563
|
+
getElementById: function(id) {
|
|
564
|
+
var rtv = null;
|
|
565
|
+
_visitNode(this.documentElement, function(node) {
|
|
566
|
+
if (node.nodeType == ELEMENT_NODE) {
|
|
567
|
+
if (node.getAttribute("id") == id) {
|
|
568
|
+
rtv = node;
|
|
569
|
+
return true;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
return rtv;
|
|
574
|
+
},
|
|
575
|
+
getElementsByClassName: function(classNames) {
|
|
576
|
+
var classNamesSet = toOrderedSet(classNames);
|
|
577
|
+
return new LiveNodeList(this, function(base) {
|
|
578
|
+
var ls = [];
|
|
579
|
+
if (classNamesSet.length > 0) {
|
|
580
|
+
_visitNode(base.documentElement, function(node) {
|
|
581
|
+
if (node !== base && node.nodeType === ELEMENT_NODE) {
|
|
582
|
+
var nodeClassNames = node.getAttribute("class");
|
|
583
|
+
if (nodeClassNames) {
|
|
584
|
+
var matches = classNames === nodeClassNames;
|
|
585
|
+
if (!matches) {
|
|
586
|
+
var nodeClassNamesSet = toOrderedSet(nodeClassNames);
|
|
587
|
+
matches = classNamesSet.every(arrayIncludes(nodeClassNamesSet));
|
|
588
|
+
}
|
|
589
|
+
if (matches) {
|
|
590
|
+
ls.push(node);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
return ls;
|
|
597
|
+
});
|
|
598
|
+
},
|
|
599
|
+
createElement: function(tagName) {
|
|
600
|
+
var node = new Element();
|
|
601
|
+
node.ownerDocument = this;
|
|
602
|
+
node.nodeName = tagName;
|
|
603
|
+
node.tagName = tagName;
|
|
604
|
+
node.localName = tagName;
|
|
605
|
+
node.childNodes = new NodeList();
|
|
606
|
+
var attrs = node.attributes = new NamedNodeMap();
|
|
607
|
+
attrs._ownerElement = node;
|
|
608
|
+
return node;
|
|
609
|
+
},
|
|
610
|
+
createDocumentFragment: function() {
|
|
611
|
+
var node = new DocumentFragment();
|
|
612
|
+
node.ownerDocument = this;
|
|
613
|
+
node.childNodes = new NodeList();
|
|
614
|
+
return node;
|
|
615
|
+
},
|
|
616
|
+
createTextNode: function(data) {
|
|
617
|
+
var node = new Text();
|
|
618
|
+
node.ownerDocument = this;
|
|
619
|
+
node.appendData(data);
|
|
620
|
+
return node;
|
|
621
|
+
},
|
|
622
|
+
createComment: function(data) {
|
|
623
|
+
var node = new Comment();
|
|
624
|
+
node.ownerDocument = this;
|
|
625
|
+
node.appendData(data);
|
|
626
|
+
return node;
|
|
627
|
+
},
|
|
628
|
+
createCDATASection: function(data) {
|
|
629
|
+
var node = new CDATASection();
|
|
630
|
+
node.ownerDocument = this;
|
|
631
|
+
node.appendData(data);
|
|
632
|
+
return node;
|
|
633
|
+
},
|
|
634
|
+
createProcessingInstruction: function(target, data) {
|
|
635
|
+
var node = new ProcessingInstruction();
|
|
636
|
+
node.ownerDocument = this;
|
|
637
|
+
node.tagName = node.target = target;
|
|
638
|
+
node.nodeValue = node.data = data;
|
|
639
|
+
return node;
|
|
640
|
+
},
|
|
641
|
+
createAttribute: function(name) {
|
|
642
|
+
var node = new Attr();
|
|
643
|
+
node.ownerDocument = this;
|
|
644
|
+
node.name = name;
|
|
645
|
+
node.nodeName = name;
|
|
646
|
+
node.localName = name;
|
|
647
|
+
node.specified = true;
|
|
648
|
+
return node;
|
|
649
|
+
},
|
|
650
|
+
createEntityReference: function(name) {
|
|
651
|
+
var node = new EntityReference();
|
|
652
|
+
node.ownerDocument = this;
|
|
653
|
+
node.nodeName = name;
|
|
654
|
+
return node;
|
|
655
|
+
},
|
|
656
|
+
createElementNS: function(namespaceURI, qualifiedName) {
|
|
657
|
+
var node = new Element();
|
|
658
|
+
var pl = qualifiedName.split(":");
|
|
659
|
+
var attrs = node.attributes = new NamedNodeMap();
|
|
660
|
+
node.childNodes = new NodeList();
|
|
661
|
+
node.ownerDocument = this;
|
|
662
|
+
node.nodeName = qualifiedName;
|
|
663
|
+
node.tagName = qualifiedName;
|
|
664
|
+
node.namespaceURI = namespaceURI;
|
|
665
|
+
if (pl.length == 2) {
|
|
666
|
+
node.prefix = pl[0];
|
|
667
|
+
node.localName = pl[1];
|
|
668
|
+
} else {
|
|
669
|
+
node.localName = qualifiedName;
|
|
670
|
+
}
|
|
671
|
+
attrs._ownerElement = node;
|
|
672
|
+
return node;
|
|
673
|
+
},
|
|
674
|
+
createAttributeNS: function(namespaceURI, qualifiedName) {
|
|
675
|
+
var node = new Attr();
|
|
676
|
+
var pl = qualifiedName.split(":");
|
|
677
|
+
node.ownerDocument = this;
|
|
678
|
+
node.nodeName = qualifiedName;
|
|
679
|
+
node.name = qualifiedName;
|
|
680
|
+
node.namespaceURI = namespaceURI;
|
|
681
|
+
node.specified = true;
|
|
682
|
+
if (pl.length == 2) {
|
|
683
|
+
node.prefix = pl[0];
|
|
684
|
+
node.localName = pl[1];
|
|
685
|
+
} else {
|
|
686
|
+
node.localName = qualifiedName;
|
|
687
|
+
}
|
|
688
|
+
return node;
|
|
689
|
+
}
|
|
690
|
+
};
|
|
691
|
+
_extends(Document, Node);
|
|
692
|
+
function Element() {
|
|
693
|
+
this._nsMap = {};
|
|
694
|
+
}
|
|
695
|
+
Element.prototype = {
|
|
696
|
+
nodeType: ELEMENT_NODE,
|
|
697
|
+
hasAttribute: function(name) {
|
|
698
|
+
return this.getAttributeNode(name) != null;
|
|
699
|
+
},
|
|
700
|
+
getAttribute: function(name) {
|
|
701
|
+
var attr = this.getAttributeNode(name);
|
|
702
|
+
return attr && attr.value || "";
|
|
703
|
+
},
|
|
704
|
+
getAttributeNode: function(name) {
|
|
705
|
+
return this.attributes.getNamedItem(name);
|
|
706
|
+
},
|
|
707
|
+
setAttribute: function(name, value) {
|
|
708
|
+
var attr = this.ownerDocument.createAttribute(name);
|
|
709
|
+
attr.value = attr.nodeValue = "" + value;
|
|
710
|
+
this.setAttributeNode(attr);
|
|
711
|
+
},
|
|
712
|
+
removeAttribute: function(name) {
|
|
713
|
+
var attr = this.getAttributeNode(name);
|
|
714
|
+
attr && this.removeAttributeNode(attr);
|
|
715
|
+
},
|
|
716
|
+
appendChild: function(newChild) {
|
|
717
|
+
if (newChild.nodeType === DOCUMENT_FRAGMENT_NODE) {
|
|
718
|
+
return this.insertBefore(newChild, null);
|
|
719
|
+
} else {
|
|
720
|
+
return _appendSingleChild(this, newChild);
|
|
721
|
+
}
|
|
722
|
+
},
|
|
723
|
+
setAttributeNode: function(newAttr) {
|
|
724
|
+
return this.attributes.setNamedItem(newAttr);
|
|
725
|
+
},
|
|
726
|
+
setAttributeNodeNS: function(newAttr) {
|
|
727
|
+
return this.attributes.setNamedItemNS(newAttr);
|
|
728
|
+
},
|
|
729
|
+
removeAttributeNode: function(oldAttr) {
|
|
730
|
+
return this.attributes.removeNamedItem(oldAttr.nodeName);
|
|
731
|
+
},
|
|
732
|
+
removeAttributeNS: function(namespaceURI, localName) {
|
|
733
|
+
var old = this.getAttributeNodeNS(namespaceURI, localName);
|
|
734
|
+
old && this.removeAttributeNode(old);
|
|
735
|
+
},
|
|
736
|
+
hasAttributeNS: function(namespaceURI, localName) {
|
|
737
|
+
return this.getAttributeNodeNS(namespaceURI, localName) != null;
|
|
738
|
+
},
|
|
739
|
+
getAttributeNS: function(namespaceURI, localName) {
|
|
740
|
+
var attr = this.getAttributeNodeNS(namespaceURI, localName);
|
|
741
|
+
return attr && attr.value || "";
|
|
742
|
+
},
|
|
743
|
+
setAttributeNS: function(namespaceURI, qualifiedName, value) {
|
|
744
|
+
var attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);
|
|
745
|
+
attr.value = attr.nodeValue = "" + value;
|
|
746
|
+
this.setAttributeNode(attr);
|
|
747
|
+
},
|
|
748
|
+
getAttributeNodeNS: function(namespaceURI, localName) {
|
|
749
|
+
return this.attributes.getNamedItemNS(namespaceURI, localName);
|
|
750
|
+
},
|
|
751
|
+
getElementsByTagName: function(tagName) {
|
|
752
|
+
return new LiveNodeList(this, function(base) {
|
|
753
|
+
var ls = [];
|
|
754
|
+
_visitNode(base, function(node) {
|
|
755
|
+
if (node !== base && node.nodeType == ELEMENT_NODE && (tagName === "*" || node.tagName == tagName)) {
|
|
756
|
+
ls.push(node);
|
|
757
|
+
}
|
|
758
|
+
});
|
|
759
|
+
return ls;
|
|
760
|
+
});
|
|
761
|
+
},
|
|
762
|
+
getElementsByTagNameNS: function(namespaceURI, localName) {
|
|
763
|
+
return new LiveNodeList(this, function(base) {
|
|
764
|
+
var ls = [];
|
|
765
|
+
_visitNode(base, function(node) {
|
|
766
|
+
if (node !== base && node.nodeType === ELEMENT_NODE && (namespaceURI === "*" || node.namespaceURI === namespaceURI) && (localName === "*" || node.localName == localName)) {
|
|
767
|
+
ls.push(node);
|
|
768
|
+
}
|
|
769
|
+
});
|
|
770
|
+
return ls;
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
};
|
|
774
|
+
Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName;
|
|
775
|
+
Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS;
|
|
776
|
+
_extends(Element, Node);
|
|
777
|
+
function Attr() {
|
|
778
|
+
}
|
|
779
|
+
Attr.prototype.nodeType = ATTRIBUTE_NODE;
|
|
780
|
+
_extends(Attr, Node);
|
|
781
|
+
function CharacterData() {
|
|
782
|
+
}
|
|
783
|
+
CharacterData.prototype = {
|
|
784
|
+
data: "",
|
|
785
|
+
substringData: function(offset, count) {
|
|
786
|
+
return this.data.substring(offset, offset + count);
|
|
787
|
+
},
|
|
788
|
+
appendData: function(text) {
|
|
789
|
+
text = this.data + text;
|
|
790
|
+
this.nodeValue = this.data = text;
|
|
791
|
+
this.length = text.length;
|
|
792
|
+
},
|
|
793
|
+
insertData: function(offset, text) {
|
|
794
|
+
this.replaceData(offset, 0, text);
|
|
795
|
+
},
|
|
796
|
+
appendChild: function(newChild) {
|
|
797
|
+
throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR]);
|
|
798
|
+
},
|
|
799
|
+
deleteData: function(offset, count) {
|
|
800
|
+
this.replaceData(offset, count, "");
|
|
801
|
+
},
|
|
802
|
+
replaceData: function(offset, count, text) {
|
|
803
|
+
var start = this.data.substring(0, offset);
|
|
804
|
+
var end = this.data.substring(offset + count);
|
|
805
|
+
text = start + text + end;
|
|
806
|
+
this.nodeValue = this.data = text;
|
|
807
|
+
this.length = text.length;
|
|
808
|
+
}
|
|
809
|
+
};
|
|
810
|
+
_extends(CharacterData, Node);
|
|
811
|
+
function Text() {
|
|
812
|
+
}
|
|
813
|
+
Text.prototype = {
|
|
814
|
+
nodeName: "#text",
|
|
815
|
+
nodeType: TEXT_NODE,
|
|
816
|
+
splitText: function(offset) {
|
|
817
|
+
var text = this.data;
|
|
818
|
+
var newText = text.substring(offset);
|
|
819
|
+
text = text.substring(0, offset);
|
|
820
|
+
this.data = this.nodeValue = text;
|
|
821
|
+
this.length = text.length;
|
|
822
|
+
var newNode = this.ownerDocument.createTextNode(newText);
|
|
823
|
+
if (this.parentNode) {
|
|
824
|
+
this.parentNode.insertBefore(newNode, this.nextSibling);
|
|
825
|
+
}
|
|
826
|
+
return newNode;
|
|
827
|
+
}
|
|
828
|
+
};
|
|
829
|
+
_extends(Text, CharacterData);
|
|
830
|
+
function Comment() {
|
|
831
|
+
}
|
|
832
|
+
Comment.prototype = {
|
|
833
|
+
nodeName: "#comment",
|
|
834
|
+
nodeType: COMMENT_NODE
|
|
835
|
+
};
|
|
836
|
+
_extends(Comment, CharacterData);
|
|
837
|
+
function CDATASection() {
|
|
838
|
+
}
|
|
839
|
+
CDATASection.prototype = {
|
|
840
|
+
nodeName: "#cdata-section",
|
|
841
|
+
nodeType: CDATA_SECTION_NODE
|
|
842
|
+
};
|
|
843
|
+
_extends(CDATASection, CharacterData);
|
|
844
|
+
function DocumentType() {
|
|
845
|
+
}
|
|
846
|
+
DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
|
|
847
|
+
_extends(DocumentType, Node);
|
|
848
|
+
function Notation() {
|
|
849
|
+
}
|
|
850
|
+
Notation.prototype.nodeType = NOTATION_NODE;
|
|
851
|
+
_extends(Notation, Node);
|
|
852
|
+
function Entity() {
|
|
853
|
+
}
|
|
854
|
+
Entity.prototype.nodeType = ENTITY_NODE;
|
|
855
|
+
_extends(Entity, Node);
|
|
856
|
+
function EntityReference() {
|
|
857
|
+
}
|
|
858
|
+
EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
|
|
859
|
+
_extends(EntityReference, Node);
|
|
860
|
+
function DocumentFragment() {
|
|
861
|
+
}
|
|
862
|
+
DocumentFragment.prototype.nodeName = "#document-fragment";
|
|
863
|
+
DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE;
|
|
864
|
+
_extends(DocumentFragment, Node);
|
|
865
|
+
function ProcessingInstruction() {
|
|
866
|
+
}
|
|
867
|
+
ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
|
|
868
|
+
_extends(ProcessingInstruction, Node);
|
|
869
|
+
function XMLSerializer() {
|
|
870
|
+
}
|
|
871
|
+
XMLSerializer.prototype.serializeToString = function(node, isHtml, nodeFilter) {
|
|
872
|
+
return nodeSerializeToString.call(node, isHtml, nodeFilter);
|
|
873
|
+
};
|
|
874
|
+
Node.prototype.toString = nodeSerializeToString;
|
|
875
|
+
function nodeSerializeToString(isHtml, nodeFilter) {
|
|
876
|
+
var buf = [];
|
|
877
|
+
var refNode = this.nodeType == 9 && this.documentElement || this;
|
|
878
|
+
var prefix = refNode.prefix;
|
|
879
|
+
var uri = refNode.namespaceURI;
|
|
880
|
+
if (uri && prefix == null) {
|
|
881
|
+
var prefix = refNode.lookupPrefix(uri);
|
|
882
|
+
if (prefix == null) {
|
|
883
|
+
var visibleNamespaces = [
|
|
884
|
+
{ namespace: uri, prefix: null }
|
|
885
|
+
];
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
serializeToString(this, buf, isHtml, nodeFilter, visibleNamespaces);
|
|
889
|
+
return buf.join("");
|
|
890
|
+
}
|
|
891
|
+
function needNamespaceDefine(node, isHTML, visibleNamespaces) {
|
|
892
|
+
var prefix = node.prefix || "";
|
|
893
|
+
var uri = node.namespaceURI;
|
|
894
|
+
if (!uri) {
|
|
895
|
+
return false;
|
|
896
|
+
}
|
|
897
|
+
if (prefix === "xml" && uri === NAMESPACE.XML || uri === NAMESPACE.XMLNS) {
|
|
898
|
+
return false;
|
|
899
|
+
}
|
|
900
|
+
var i = visibleNamespaces.length;
|
|
901
|
+
while (i--) {
|
|
902
|
+
var ns = visibleNamespaces[i];
|
|
903
|
+
if (ns.prefix === prefix) {
|
|
904
|
+
return ns.namespace !== uri;
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
return true;
|
|
908
|
+
}
|
|
909
|
+
function addSerializedAttribute(buf, qualifiedName, value) {
|
|
910
|
+
buf.push(" ", qualifiedName, '="', value.replace(/[<&"]/g, _xmlEncoder), '"');
|
|
911
|
+
}
|
|
912
|
+
function serializeToString(node, buf, isHTML, nodeFilter, visibleNamespaces) {
|
|
913
|
+
if (!visibleNamespaces) {
|
|
914
|
+
visibleNamespaces = [];
|
|
915
|
+
}
|
|
916
|
+
if (nodeFilter) {
|
|
917
|
+
node = nodeFilter(node);
|
|
918
|
+
if (node) {
|
|
919
|
+
if (typeof node == "string") {
|
|
920
|
+
buf.push(node);
|
|
921
|
+
return;
|
|
922
|
+
}
|
|
923
|
+
} else {
|
|
924
|
+
return;
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
switch (node.nodeType) {
|
|
928
|
+
case ELEMENT_NODE:
|
|
929
|
+
var attrs = node.attributes;
|
|
930
|
+
var len = attrs.length;
|
|
931
|
+
var child = node.firstChild;
|
|
932
|
+
var nodeName = node.tagName;
|
|
933
|
+
isHTML = NAMESPACE.isHTML(node.namespaceURI) || isHTML;
|
|
934
|
+
var prefixedNodeName = nodeName;
|
|
935
|
+
if (!isHTML && !node.prefix && node.namespaceURI) {
|
|
936
|
+
var defaultNS;
|
|
937
|
+
for (var ai = 0; ai < attrs.length; ai++) {
|
|
938
|
+
if (attrs.item(ai).name === "xmlns") {
|
|
939
|
+
defaultNS = attrs.item(ai).value;
|
|
940
|
+
break;
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
if (!defaultNS) {
|
|
944
|
+
for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
|
|
945
|
+
var namespace = visibleNamespaces[nsi];
|
|
946
|
+
if (namespace.prefix === "" && namespace.namespace === node.namespaceURI) {
|
|
947
|
+
defaultNS = namespace.namespace;
|
|
948
|
+
break;
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
if (defaultNS !== node.namespaceURI) {
|
|
953
|
+
for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
|
|
954
|
+
var namespace = visibleNamespaces[nsi];
|
|
955
|
+
if (namespace.namespace === node.namespaceURI) {
|
|
956
|
+
if (namespace.prefix) {
|
|
957
|
+
prefixedNodeName = namespace.prefix + ":" + nodeName;
|
|
958
|
+
}
|
|
959
|
+
break;
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
buf.push("<", prefixedNodeName);
|
|
965
|
+
for (var i = 0; i < len; i++) {
|
|
966
|
+
var attr = attrs.item(i);
|
|
967
|
+
if (attr.prefix == "xmlns") {
|
|
968
|
+
visibleNamespaces.push({ prefix: attr.localName, namespace: attr.value });
|
|
969
|
+
} else if (attr.nodeName == "xmlns") {
|
|
970
|
+
visibleNamespaces.push({ prefix: "", namespace: attr.value });
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
for (var i = 0; i < len; i++) {
|
|
974
|
+
var attr = attrs.item(i);
|
|
975
|
+
if (needNamespaceDefine(attr, isHTML, visibleNamespaces)) {
|
|
976
|
+
var prefix = attr.prefix || "";
|
|
977
|
+
var uri = attr.namespaceURI;
|
|
978
|
+
addSerializedAttribute(buf, prefix ? "xmlns:" + prefix : "xmlns", uri);
|
|
979
|
+
visibleNamespaces.push({ prefix, namespace: uri });
|
|
980
|
+
}
|
|
981
|
+
serializeToString(attr, buf, isHTML, nodeFilter, visibleNamespaces);
|
|
982
|
+
}
|
|
983
|
+
if (nodeName === prefixedNodeName && needNamespaceDefine(node, isHTML, visibleNamespaces)) {
|
|
984
|
+
var prefix = node.prefix || "";
|
|
985
|
+
var uri = node.namespaceURI;
|
|
986
|
+
addSerializedAttribute(buf, prefix ? "xmlns:" + prefix : "xmlns", uri);
|
|
987
|
+
visibleNamespaces.push({ prefix, namespace: uri });
|
|
988
|
+
}
|
|
989
|
+
if (child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)) {
|
|
990
|
+
buf.push(">");
|
|
991
|
+
if (isHTML && /^script$/i.test(nodeName)) {
|
|
992
|
+
while (child) {
|
|
993
|
+
if (child.data) {
|
|
994
|
+
buf.push(child.data);
|
|
995
|
+
} else {
|
|
996
|
+
serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
|
|
997
|
+
}
|
|
998
|
+
child = child.nextSibling;
|
|
999
|
+
}
|
|
1000
|
+
} else {
|
|
1001
|
+
while (child) {
|
|
1002
|
+
serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
|
|
1003
|
+
child = child.nextSibling;
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
buf.push("</", prefixedNodeName, ">");
|
|
1007
|
+
} else {
|
|
1008
|
+
buf.push("/>");
|
|
1009
|
+
}
|
|
1010
|
+
return;
|
|
1011
|
+
case DOCUMENT_NODE:
|
|
1012
|
+
case DOCUMENT_FRAGMENT_NODE:
|
|
1013
|
+
var child = node.firstChild;
|
|
1014
|
+
while (child) {
|
|
1015
|
+
serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
|
|
1016
|
+
child = child.nextSibling;
|
|
1017
|
+
}
|
|
1018
|
+
return;
|
|
1019
|
+
case ATTRIBUTE_NODE:
|
|
1020
|
+
return addSerializedAttribute(buf, node.name, node.value);
|
|
1021
|
+
case TEXT_NODE:
|
|
1022
|
+
return buf.push(node.data.replace(/[<&]/g, _xmlEncoder).replace(/]]>/g, "]]>"));
|
|
1023
|
+
case CDATA_SECTION_NODE:
|
|
1024
|
+
return buf.push("<![CDATA[", node.data, "]]>");
|
|
1025
|
+
case COMMENT_NODE:
|
|
1026
|
+
return buf.push("<!--", node.data, "-->");
|
|
1027
|
+
case DOCUMENT_TYPE_NODE:
|
|
1028
|
+
var pubid = node.publicId;
|
|
1029
|
+
var sysid = node.systemId;
|
|
1030
|
+
buf.push("<!DOCTYPE ", node.name);
|
|
1031
|
+
if (pubid) {
|
|
1032
|
+
buf.push(" PUBLIC ", pubid);
|
|
1033
|
+
if (sysid && sysid != ".") {
|
|
1034
|
+
buf.push(" ", sysid);
|
|
1035
|
+
}
|
|
1036
|
+
buf.push(">");
|
|
1037
|
+
} else if (sysid && sysid != ".") {
|
|
1038
|
+
buf.push(" SYSTEM ", sysid, ">");
|
|
1039
|
+
} else {
|
|
1040
|
+
var sub = node.internalSubset;
|
|
1041
|
+
if (sub) {
|
|
1042
|
+
buf.push(" [", sub, "]");
|
|
1043
|
+
}
|
|
1044
|
+
buf.push(">");
|
|
1045
|
+
}
|
|
1046
|
+
return;
|
|
1047
|
+
case PROCESSING_INSTRUCTION_NODE:
|
|
1048
|
+
return buf.push("<?", node.target, " ", node.data, "?>");
|
|
1049
|
+
case ENTITY_REFERENCE_NODE:
|
|
1050
|
+
return buf.push("&", node.nodeName, ";");
|
|
1051
|
+
default:
|
|
1052
|
+
buf.push("??", node.nodeName);
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
function importNode(doc, node, deep) {
|
|
1056
|
+
var node2;
|
|
1057
|
+
switch (node.nodeType) {
|
|
1058
|
+
case ELEMENT_NODE:
|
|
1059
|
+
node2 = node.cloneNode(false);
|
|
1060
|
+
node2.ownerDocument = doc;
|
|
1061
|
+
case DOCUMENT_FRAGMENT_NODE:
|
|
1062
|
+
break;
|
|
1063
|
+
case ATTRIBUTE_NODE:
|
|
1064
|
+
deep = true;
|
|
1065
|
+
break;
|
|
1066
|
+
}
|
|
1067
|
+
if (!node2) {
|
|
1068
|
+
node2 = node.cloneNode(false);
|
|
1069
|
+
}
|
|
1070
|
+
node2.ownerDocument = doc;
|
|
1071
|
+
node2.parentNode = null;
|
|
1072
|
+
if (deep) {
|
|
1073
|
+
var child = node.firstChild;
|
|
1074
|
+
while (child) {
|
|
1075
|
+
node2.appendChild(importNode(doc, child, deep));
|
|
1076
|
+
child = child.nextSibling;
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
return node2;
|
|
1080
|
+
}
|
|
1081
|
+
function cloneNode(doc, node, deep) {
|
|
1082
|
+
var node2 = new node.constructor();
|
|
1083
|
+
for (var n in node) {
|
|
1084
|
+
var v = node[n];
|
|
1085
|
+
if (typeof v != "object") {
|
|
1086
|
+
if (v != node2[n]) {
|
|
1087
|
+
node2[n] = v;
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
if (node.childNodes) {
|
|
1092
|
+
node2.childNodes = new NodeList();
|
|
1093
|
+
}
|
|
1094
|
+
node2.ownerDocument = doc;
|
|
1095
|
+
switch (node2.nodeType) {
|
|
1096
|
+
case ELEMENT_NODE:
|
|
1097
|
+
var attrs = node.attributes;
|
|
1098
|
+
var attrs2 = node2.attributes = new NamedNodeMap();
|
|
1099
|
+
var len = attrs.length;
|
|
1100
|
+
attrs2._ownerElement = node2;
|
|
1101
|
+
for (var i = 0; i < len; i++) {
|
|
1102
|
+
node2.setAttributeNode(cloneNode(doc, attrs.item(i), true));
|
|
1103
|
+
}
|
|
1104
|
+
break;
|
|
1105
|
+
;
|
|
1106
|
+
case ATTRIBUTE_NODE:
|
|
1107
|
+
deep = true;
|
|
1108
|
+
}
|
|
1109
|
+
if (deep) {
|
|
1110
|
+
var child = node.firstChild;
|
|
1111
|
+
while (child) {
|
|
1112
|
+
node2.appendChild(cloneNode(doc, child, deep));
|
|
1113
|
+
child = child.nextSibling;
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
return node2;
|
|
1117
|
+
}
|
|
1118
|
+
function __set__(object, key, value) {
|
|
1119
|
+
object[key] = value;
|
|
1120
|
+
}
|
|
1121
|
+
try {
|
|
1122
|
+
if (Object.defineProperty) {
|
|
1123
|
+
let getTextContent2 = function(node) {
|
|
1124
|
+
switch (node.nodeType) {
|
|
1125
|
+
case ELEMENT_NODE:
|
|
1126
|
+
case DOCUMENT_FRAGMENT_NODE:
|
|
1127
|
+
var buf = [];
|
|
1128
|
+
node = node.firstChild;
|
|
1129
|
+
while (node) {
|
|
1130
|
+
if (node.nodeType !== 7 && node.nodeType !== 8) {
|
|
1131
|
+
buf.push(getTextContent2(node));
|
|
1132
|
+
}
|
|
1133
|
+
node = node.nextSibling;
|
|
1134
|
+
}
|
|
1135
|
+
return buf.join("");
|
|
1136
|
+
default:
|
|
1137
|
+
return node.nodeValue;
|
|
1138
|
+
}
|
|
1139
|
+
};
|
|
1140
|
+
getTextContent = getTextContent2;
|
|
1141
|
+
Object.defineProperty(LiveNodeList.prototype, "length", {
|
|
1142
|
+
get: function() {
|
|
1143
|
+
_updateLiveList(this);
|
|
1144
|
+
return this.$$length;
|
|
1145
|
+
}
|
|
1146
|
+
});
|
|
1147
|
+
Object.defineProperty(Node.prototype, "textContent", {
|
|
1148
|
+
get: function() {
|
|
1149
|
+
return getTextContent2(this);
|
|
1150
|
+
},
|
|
1151
|
+
set: function(data) {
|
|
1152
|
+
switch (this.nodeType) {
|
|
1153
|
+
case ELEMENT_NODE:
|
|
1154
|
+
case DOCUMENT_FRAGMENT_NODE:
|
|
1155
|
+
while (this.firstChild) {
|
|
1156
|
+
this.removeChild(this.firstChild);
|
|
1157
|
+
}
|
|
1158
|
+
if (data || String(data)) {
|
|
1159
|
+
this.appendChild(this.ownerDocument.createTextNode(data));
|
|
1160
|
+
}
|
|
1161
|
+
break;
|
|
1162
|
+
default:
|
|
1163
|
+
this.data = data;
|
|
1164
|
+
this.value = data;
|
|
1165
|
+
this.nodeValue = data;
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
});
|
|
1169
|
+
__set__ = function(object, key, value) {
|
|
1170
|
+
object["$$" + key] = value;
|
|
1171
|
+
};
|
|
1172
|
+
}
|
|
1173
|
+
} catch (e) {
|
|
1174
|
+
}
|
|
1175
|
+
var getTextContent;
|
|
1176
|
+
exports.DocumentType = DocumentType;
|
|
1177
|
+
exports.DOMException = DOMException;
|
|
1178
|
+
exports.DOMImplementation = DOMImplementation;
|
|
1179
|
+
exports.Element = Element;
|
|
1180
|
+
exports.Node = Node;
|
|
1181
|
+
exports.NodeList = NodeList;
|
|
1182
|
+
exports.XMLSerializer = XMLSerializer;
|
|
1183
|
+
}
|
|
1184
|
+
});
|
|
1185
|
+
|
|
1186
|
+
// ../../node_modules/@xmldom/xmldom/lib/entities.js
|
|
1187
|
+
var require_entities = __commonJS({
|
|
1188
|
+
"../../node_modules/@xmldom/xmldom/lib/entities.js"(exports) {
|
|
1189
|
+
var freeze = require_conventions().freeze;
|
|
1190
|
+
exports.XML_ENTITIES = freeze({ amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' });
|
|
1191
|
+
exports.HTML_ENTITIES = freeze({
|
|
1192
|
+
lt: "<",
|
|
1193
|
+
gt: ">",
|
|
1194
|
+
amp: "&",
|
|
1195
|
+
quot: '"',
|
|
1196
|
+
apos: "'",
|
|
1197
|
+
Agrave: "\xC0",
|
|
1198
|
+
Aacute: "\xC1",
|
|
1199
|
+
Acirc: "\xC2",
|
|
1200
|
+
Atilde: "\xC3",
|
|
1201
|
+
Auml: "\xC4",
|
|
1202
|
+
Aring: "\xC5",
|
|
1203
|
+
AElig: "\xC6",
|
|
1204
|
+
Ccedil: "\xC7",
|
|
1205
|
+
Egrave: "\xC8",
|
|
1206
|
+
Eacute: "\xC9",
|
|
1207
|
+
Ecirc: "\xCA",
|
|
1208
|
+
Euml: "\xCB",
|
|
1209
|
+
Igrave: "\xCC",
|
|
1210
|
+
Iacute: "\xCD",
|
|
1211
|
+
Icirc: "\xCE",
|
|
1212
|
+
Iuml: "\xCF",
|
|
1213
|
+
ETH: "\xD0",
|
|
1214
|
+
Ntilde: "\xD1",
|
|
1215
|
+
Ograve: "\xD2",
|
|
1216
|
+
Oacute: "\xD3",
|
|
1217
|
+
Ocirc: "\xD4",
|
|
1218
|
+
Otilde: "\xD5",
|
|
1219
|
+
Ouml: "\xD6",
|
|
1220
|
+
Oslash: "\xD8",
|
|
1221
|
+
Ugrave: "\xD9",
|
|
1222
|
+
Uacute: "\xDA",
|
|
1223
|
+
Ucirc: "\xDB",
|
|
1224
|
+
Uuml: "\xDC",
|
|
1225
|
+
Yacute: "\xDD",
|
|
1226
|
+
THORN: "\xDE",
|
|
1227
|
+
szlig: "\xDF",
|
|
1228
|
+
agrave: "\xE0",
|
|
1229
|
+
aacute: "\xE1",
|
|
1230
|
+
acirc: "\xE2",
|
|
1231
|
+
atilde: "\xE3",
|
|
1232
|
+
auml: "\xE4",
|
|
1233
|
+
aring: "\xE5",
|
|
1234
|
+
aelig: "\xE6",
|
|
1235
|
+
ccedil: "\xE7",
|
|
1236
|
+
egrave: "\xE8",
|
|
1237
|
+
eacute: "\xE9",
|
|
1238
|
+
ecirc: "\xEA",
|
|
1239
|
+
euml: "\xEB",
|
|
1240
|
+
igrave: "\xEC",
|
|
1241
|
+
iacute: "\xED",
|
|
1242
|
+
icirc: "\xEE",
|
|
1243
|
+
iuml: "\xEF",
|
|
1244
|
+
eth: "\xF0",
|
|
1245
|
+
ntilde: "\xF1",
|
|
1246
|
+
ograve: "\xF2",
|
|
1247
|
+
oacute: "\xF3",
|
|
1248
|
+
ocirc: "\xF4",
|
|
1249
|
+
otilde: "\xF5",
|
|
1250
|
+
ouml: "\xF6",
|
|
1251
|
+
oslash: "\xF8",
|
|
1252
|
+
ugrave: "\xF9",
|
|
1253
|
+
uacute: "\xFA",
|
|
1254
|
+
ucirc: "\xFB",
|
|
1255
|
+
uuml: "\xFC",
|
|
1256
|
+
yacute: "\xFD",
|
|
1257
|
+
thorn: "\xFE",
|
|
1258
|
+
yuml: "\xFF",
|
|
1259
|
+
nbsp: "\xA0",
|
|
1260
|
+
iexcl: "\xA1",
|
|
1261
|
+
cent: "\xA2",
|
|
1262
|
+
pound: "\xA3",
|
|
1263
|
+
curren: "\xA4",
|
|
1264
|
+
yen: "\xA5",
|
|
1265
|
+
brvbar: "\xA6",
|
|
1266
|
+
sect: "\xA7",
|
|
1267
|
+
uml: "\xA8",
|
|
1268
|
+
copy: "\xA9",
|
|
1269
|
+
ordf: "\xAA",
|
|
1270
|
+
laquo: "\xAB",
|
|
1271
|
+
not: "\xAC",
|
|
1272
|
+
shy: "\xAD\xAD",
|
|
1273
|
+
reg: "\xAE",
|
|
1274
|
+
macr: "\xAF",
|
|
1275
|
+
deg: "\xB0",
|
|
1276
|
+
plusmn: "\xB1",
|
|
1277
|
+
sup2: "\xB2",
|
|
1278
|
+
sup3: "\xB3",
|
|
1279
|
+
acute: "\xB4",
|
|
1280
|
+
micro: "\xB5",
|
|
1281
|
+
para: "\xB6",
|
|
1282
|
+
middot: "\xB7",
|
|
1283
|
+
cedil: "\xB8",
|
|
1284
|
+
sup1: "\xB9",
|
|
1285
|
+
ordm: "\xBA",
|
|
1286
|
+
raquo: "\xBB",
|
|
1287
|
+
frac14: "\xBC",
|
|
1288
|
+
frac12: "\xBD",
|
|
1289
|
+
frac34: "\xBE",
|
|
1290
|
+
iquest: "\xBF",
|
|
1291
|
+
times: "\xD7",
|
|
1292
|
+
divide: "\xF7",
|
|
1293
|
+
forall: "\u2200",
|
|
1294
|
+
part: "\u2202",
|
|
1295
|
+
exist: "\u2203",
|
|
1296
|
+
empty: "\u2205",
|
|
1297
|
+
nabla: "\u2207",
|
|
1298
|
+
isin: "\u2208",
|
|
1299
|
+
notin: "\u2209",
|
|
1300
|
+
ni: "\u220B",
|
|
1301
|
+
prod: "\u220F",
|
|
1302
|
+
sum: "\u2211",
|
|
1303
|
+
minus: "\u2212",
|
|
1304
|
+
lowast: "\u2217",
|
|
1305
|
+
radic: "\u221A",
|
|
1306
|
+
prop: "\u221D",
|
|
1307
|
+
infin: "\u221E",
|
|
1308
|
+
ang: "\u2220",
|
|
1309
|
+
and: "\u2227",
|
|
1310
|
+
or: "\u2228",
|
|
1311
|
+
cap: "\u2229",
|
|
1312
|
+
cup: "\u222A",
|
|
1313
|
+
"int": "\u222B",
|
|
1314
|
+
there4: "\u2234",
|
|
1315
|
+
sim: "\u223C",
|
|
1316
|
+
cong: "\u2245",
|
|
1317
|
+
asymp: "\u2248",
|
|
1318
|
+
ne: "\u2260",
|
|
1319
|
+
equiv: "\u2261",
|
|
1320
|
+
le: "\u2264",
|
|
1321
|
+
ge: "\u2265",
|
|
1322
|
+
sub: "\u2282",
|
|
1323
|
+
sup: "\u2283",
|
|
1324
|
+
nsub: "\u2284",
|
|
1325
|
+
sube: "\u2286",
|
|
1326
|
+
supe: "\u2287",
|
|
1327
|
+
oplus: "\u2295",
|
|
1328
|
+
otimes: "\u2297",
|
|
1329
|
+
perp: "\u22A5",
|
|
1330
|
+
sdot: "\u22C5",
|
|
1331
|
+
Alpha: "\u0391",
|
|
1332
|
+
Beta: "\u0392",
|
|
1333
|
+
Gamma: "\u0393",
|
|
1334
|
+
Delta: "\u0394",
|
|
1335
|
+
Epsilon: "\u0395",
|
|
1336
|
+
Zeta: "\u0396",
|
|
1337
|
+
Eta: "\u0397",
|
|
1338
|
+
Theta: "\u0398",
|
|
1339
|
+
Iota: "\u0399",
|
|
1340
|
+
Kappa: "\u039A",
|
|
1341
|
+
Lambda: "\u039B",
|
|
1342
|
+
Mu: "\u039C",
|
|
1343
|
+
Nu: "\u039D",
|
|
1344
|
+
Xi: "\u039E",
|
|
1345
|
+
Omicron: "\u039F",
|
|
1346
|
+
Pi: "\u03A0",
|
|
1347
|
+
Rho: "\u03A1",
|
|
1348
|
+
Sigma: "\u03A3",
|
|
1349
|
+
Tau: "\u03A4",
|
|
1350
|
+
Upsilon: "\u03A5",
|
|
1351
|
+
Phi: "\u03A6",
|
|
1352
|
+
Chi: "\u03A7",
|
|
1353
|
+
Psi: "\u03A8",
|
|
1354
|
+
Omega: "\u03A9",
|
|
1355
|
+
alpha: "\u03B1",
|
|
1356
|
+
beta: "\u03B2",
|
|
1357
|
+
gamma: "\u03B3",
|
|
1358
|
+
delta: "\u03B4",
|
|
1359
|
+
epsilon: "\u03B5",
|
|
1360
|
+
zeta: "\u03B6",
|
|
1361
|
+
eta: "\u03B7",
|
|
1362
|
+
theta: "\u03B8",
|
|
1363
|
+
iota: "\u03B9",
|
|
1364
|
+
kappa: "\u03BA",
|
|
1365
|
+
lambda: "\u03BB",
|
|
1366
|
+
mu: "\u03BC",
|
|
1367
|
+
nu: "\u03BD",
|
|
1368
|
+
xi: "\u03BE",
|
|
1369
|
+
omicron: "\u03BF",
|
|
1370
|
+
pi: "\u03C0",
|
|
1371
|
+
rho: "\u03C1",
|
|
1372
|
+
sigmaf: "\u03C2",
|
|
1373
|
+
sigma: "\u03C3",
|
|
1374
|
+
tau: "\u03C4",
|
|
1375
|
+
upsilon: "\u03C5",
|
|
1376
|
+
phi: "\u03C6",
|
|
1377
|
+
chi: "\u03C7",
|
|
1378
|
+
psi: "\u03C8",
|
|
1379
|
+
omega: "\u03C9",
|
|
1380
|
+
thetasym: "\u03D1",
|
|
1381
|
+
upsih: "\u03D2",
|
|
1382
|
+
piv: "\u03D6",
|
|
1383
|
+
OElig: "\u0152",
|
|
1384
|
+
oelig: "\u0153",
|
|
1385
|
+
Scaron: "\u0160",
|
|
1386
|
+
scaron: "\u0161",
|
|
1387
|
+
Yuml: "\u0178",
|
|
1388
|
+
fnof: "\u0192",
|
|
1389
|
+
circ: "\u02C6",
|
|
1390
|
+
tilde: "\u02DC",
|
|
1391
|
+
ensp: "\u2002",
|
|
1392
|
+
emsp: "\u2003",
|
|
1393
|
+
thinsp: "\u2009",
|
|
1394
|
+
zwnj: "\u200C",
|
|
1395
|
+
zwj: "\u200D",
|
|
1396
|
+
lrm: "\u200E",
|
|
1397
|
+
rlm: "\u200F",
|
|
1398
|
+
ndash: "\u2013",
|
|
1399
|
+
mdash: "\u2014",
|
|
1400
|
+
lsquo: "\u2018",
|
|
1401
|
+
rsquo: "\u2019",
|
|
1402
|
+
sbquo: "\u201A",
|
|
1403
|
+
ldquo: "\u201C",
|
|
1404
|
+
rdquo: "\u201D",
|
|
1405
|
+
bdquo: "\u201E",
|
|
1406
|
+
dagger: "\u2020",
|
|
1407
|
+
Dagger: "\u2021",
|
|
1408
|
+
bull: "\u2022",
|
|
1409
|
+
hellip: "\u2026",
|
|
1410
|
+
permil: "\u2030",
|
|
1411
|
+
prime: "\u2032",
|
|
1412
|
+
Prime: "\u2033",
|
|
1413
|
+
lsaquo: "\u2039",
|
|
1414
|
+
rsaquo: "\u203A",
|
|
1415
|
+
oline: "\u203E",
|
|
1416
|
+
euro: "\u20AC",
|
|
1417
|
+
trade: "\u2122",
|
|
1418
|
+
larr: "\u2190",
|
|
1419
|
+
uarr: "\u2191",
|
|
1420
|
+
rarr: "\u2192",
|
|
1421
|
+
darr: "\u2193",
|
|
1422
|
+
harr: "\u2194",
|
|
1423
|
+
crarr: "\u21B5",
|
|
1424
|
+
lceil: "\u2308",
|
|
1425
|
+
rceil: "\u2309",
|
|
1426
|
+
lfloor: "\u230A",
|
|
1427
|
+
rfloor: "\u230B",
|
|
1428
|
+
loz: "\u25CA",
|
|
1429
|
+
spades: "\u2660",
|
|
1430
|
+
clubs: "\u2663",
|
|
1431
|
+
hearts: "\u2665",
|
|
1432
|
+
diams: "\u2666"
|
|
1433
|
+
});
|
|
1434
|
+
exports.entityMap = exports.HTML_ENTITIES;
|
|
1435
|
+
}
|
|
1436
|
+
});
|
|
1437
|
+
|
|
1438
|
+
// ../../node_modules/@xmldom/xmldom/lib/sax.js
|
|
1439
|
+
var require_sax = __commonJS({
|
|
1440
|
+
"../../node_modules/@xmldom/xmldom/lib/sax.js"(exports) {
|
|
1441
|
+
var NAMESPACE = require_conventions().NAMESPACE;
|
|
1442
|
+
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]/;
|
|
1443
|
+
var nameChar = new RegExp("[\\-\\.0-9" + nameStartChar.source.slice(1, -1) + "\\u00B7\\u0300-\\u036F\\u203F-\\u2040]");
|
|
1444
|
+
var tagNamePattern = new RegExp("^" + nameStartChar.source + nameChar.source + "*(?::" + nameStartChar.source + nameChar.source + "*)?$");
|
|
1445
|
+
var S_TAG = 0;
|
|
1446
|
+
var S_ATTR = 1;
|
|
1447
|
+
var S_ATTR_SPACE = 2;
|
|
1448
|
+
var S_EQ = 3;
|
|
1449
|
+
var S_ATTR_NOQUOT_VALUE = 4;
|
|
1450
|
+
var S_ATTR_END = 5;
|
|
1451
|
+
var S_TAG_SPACE = 6;
|
|
1452
|
+
var S_TAG_CLOSE = 7;
|
|
1453
|
+
function ParseError(message, locator) {
|
|
1454
|
+
this.message = message;
|
|
1455
|
+
this.locator = locator;
|
|
1456
|
+
if (Error.captureStackTrace)
|
|
1457
|
+
Error.captureStackTrace(this, ParseError);
|
|
1458
|
+
}
|
|
1459
|
+
ParseError.prototype = new Error();
|
|
1460
|
+
ParseError.prototype.name = ParseError.name;
|
|
1461
|
+
function XMLReader() {
|
|
1462
|
+
}
|
|
1463
|
+
XMLReader.prototype = {
|
|
1464
|
+
parse: function(source, defaultNSMap, entityMap) {
|
|
1465
|
+
var domBuilder = this.domBuilder;
|
|
1466
|
+
domBuilder.startDocument();
|
|
1467
|
+
_copy(defaultNSMap, defaultNSMap = {});
|
|
1468
|
+
parse(source, defaultNSMap, entityMap, domBuilder, this.errorHandler);
|
|
1469
|
+
domBuilder.endDocument();
|
|
1470
|
+
}
|
|
1471
|
+
};
|
|
1472
|
+
function parse(source, defaultNSMapCopy, entityMap, domBuilder, errorHandler) {
|
|
1473
|
+
function fixedFromCharCode(code) {
|
|
1474
|
+
if (code > 65535) {
|
|
1475
|
+
code -= 65536;
|
|
1476
|
+
var surrogate1 = 55296 + (code >> 10), surrogate2 = 56320 + (code & 1023);
|
|
1477
|
+
return String.fromCharCode(surrogate1, surrogate2);
|
|
1478
|
+
} else {
|
|
1479
|
+
return String.fromCharCode(code);
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
function entityReplacer(a2) {
|
|
1483
|
+
var k = a2.slice(1, -1);
|
|
1484
|
+
if (k in entityMap) {
|
|
1485
|
+
return entityMap[k];
|
|
1486
|
+
} else if (k.charAt(0) === "#") {
|
|
1487
|
+
return fixedFromCharCode(parseInt(k.substr(1).replace("x", "0x")));
|
|
1488
|
+
} else {
|
|
1489
|
+
errorHandler.error("entity not found:" + a2);
|
|
1490
|
+
return a2;
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
function appendText(end2) {
|
|
1494
|
+
if (end2 > start) {
|
|
1495
|
+
var xt = source.substring(start, end2).replace(/&#?\w+;/g, entityReplacer);
|
|
1496
|
+
locator && position(start);
|
|
1497
|
+
domBuilder.characters(xt, 0, end2 - start);
|
|
1498
|
+
start = end2;
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
function position(p, m) {
|
|
1502
|
+
while (p >= lineEnd && (m = linePattern.exec(source))) {
|
|
1503
|
+
lineStart = m.index;
|
|
1504
|
+
lineEnd = lineStart + m[0].length;
|
|
1505
|
+
locator.lineNumber++;
|
|
1506
|
+
}
|
|
1507
|
+
locator.columnNumber = p - lineStart + 1;
|
|
1508
|
+
}
|
|
1509
|
+
var lineStart = 0;
|
|
1510
|
+
var lineEnd = 0;
|
|
1511
|
+
var linePattern = /.*(?:\r\n?|\n)|.*$/g;
|
|
1512
|
+
var locator = domBuilder.locator;
|
|
1513
|
+
var parseStack = [{ currentNSMap: defaultNSMapCopy }];
|
|
1514
|
+
var closeMap = {};
|
|
1515
|
+
var start = 0;
|
|
1516
|
+
while (true) {
|
|
1517
|
+
try {
|
|
1518
|
+
var tagStart = source.indexOf("<", start);
|
|
1519
|
+
if (tagStart < 0) {
|
|
1520
|
+
if (!source.substr(start).match(/^\s*$/)) {
|
|
1521
|
+
var doc = domBuilder.doc;
|
|
1522
|
+
var text = doc.createTextNode(source.substr(start));
|
|
1523
|
+
doc.appendChild(text);
|
|
1524
|
+
domBuilder.currentElement = text;
|
|
1525
|
+
}
|
|
1526
|
+
return;
|
|
1527
|
+
}
|
|
1528
|
+
if (tagStart > start) {
|
|
1529
|
+
appendText(tagStart);
|
|
1530
|
+
}
|
|
1531
|
+
switch (source.charAt(tagStart + 1)) {
|
|
1532
|
+
case "/":
|
|
1533
|
+
var end = source.indexOf(">", tagStart + 3);
|
|
1534
|
+
var tagName = source.substring(tagStart + 2, end).replace(/[ \t\n\r]+$/g, "");
|
|
1535
|
+
var config = parseStack.pop();
|
|
1536
|
+
if (end < 0) {
|
|
1537
|
+
tagName = source.substring(tagStart + 2).replace(/[\s<].*/, "");
|
|
1538
|
+
errorHandler.error("end tag name: " + tagName + " is not complete:" + config.tagName);
|
|
1539
|
+
end = tagStart + 1 + tagName.length;
|
|
1540
|
+
} else if (tagName.match(/\s</)) {
|
|
1541
|
+
tagName = tagName.replace(/[\s<].*/, "");
|
|
1542
|
+
errorHandler.error("end tag name: " + tagName + " maybe not complete");
|
|
1543
|
+
end = tagStart + 1 + tagName.length;
|
|
1544
|
+
}
|
|
1545
|
+
var localNSMap = config.localNSMap;
|
|
1546
|
+
var endMatch = config.tagName == tagName;
|
|
1547
|
+
var endIgnoreCaseMach = endMatch || config.tagName && config.tagName.toLowerCase() == tagName.toLowerCase();
|
|
1548
|
+
if (endIgnoreCaseMach) {
|
|
1549
|
+
domBuilder.endElement(config.uri, config.localName, tagName);
|
|
1550
|
+
if (localNSMap) {
|
|
1551
|
+
for (var prefix in localNSMap) {
|
|
1552
|
+
domBuilder.endPrefixMapping(prefix);
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
if (!endMatch) {
|
|
1556
|
+
errorHandler.fatalError("end tag name: " + tagName + " is not match the current start tagName:" + config.tagName);
|
|
1557
|
+
}
|
|
1558
|
+
} else {
|
|
1559
|
+
parseStack.push(config);
|
|
1560
|
+
}
|
|
1561
|
+
end++;
|
|
1562
|
+
break;
|
|
1563
|
+
case "?":
|
|
1564
|
+
locator && position(tagStart);
|
|
1565
|
+
end = parseInstruction(source, tagStart, domBuilder);
|
|
1566
|
+
break;
|
|
1567
|
+
case "!":
|
|
1568
|
+
locator && position(tagStart);
|
|
1569
|
+
end = parseDCC(source, tagStart, domBuilder, errorHandler);
|
|
1570
|
+
break;
|
|
1571
|
+
default:
|
|
1572
|
+
locator && position(tagStart);
|
|
1573
|
+
var el = new ElementAttributes();
|
|
1574
|
+
var currentNSMap = parseStack[parseStack.length - 1].currentNSMap;
|
|
1575
|
+
var end = parseElementStartPart(source, tagStart, el, currentNSMap, entityReplacer, errorHandler);
|
|
1576
|
+
var len = el.length;
|
|
1577
|
+
if (!el.closed && fixSelfClosed(source, end, el.tagName, closeMap)) {
|
|
1578
|
+
el.closed = true;
|
|
1579
|
+
if (!entityMap.nbsp) {
|
|
1580
|
+
errorHandler.warning("unclosed xml attribute");
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
if (locator && len) {
|
|
1584
|
+
var locator2 = copyLocator(locator, {});
|
|
1585
|
+
for (var i = 0; i < len; i++) {
|
|
1586
|
+
var a = el[i];
|
|
1587
|
+
position(a.offset);
|
|
1588
|
+
a.locator = copyLocator(locator, {});
|
|
1589
|
+
}
|
|
1590
|
+
domBuilder.locator = locator2;
|
|
1591
|
+
if (appendElement(el, domBuilder, currentNSMap)) {
|
|
1592
|
+
parseStack.push(el);
|
|
1593
|
+
}
|
|
1594
|
+
domBuilder.locator = locator;
|
|
1595
|
+
} else {
|
|
1596
|
+
if (appendElement(el, domBuilder, currentNSMap)) {
|
|
1597
|
+
parseStack.push(el);
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
if (NAMESPACE.isHTML(el.uri) && !el.closed) {
|
|
1601
|
+
end = parseHtmlSpecialContent(source, end, el.tagName, entityReplacer, domBuilder);
|
|
1602
|
+
} else {
|
|
1603
|
+
end++;
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
} catch (e) {
|
|
1607
|
+
if (e instanceof ParseError) {
|
|
1608
|
+
throw e;
|
|
1609
|
+
}
|
|
1610
|
+
errorHandler.error("element parse error: " + e);
|
|
1611
|
+
end = -1;
|
|
1612
|
+
}
|
|
1613
|
+
if (end > start) {
|
|
1614
|
+
start = end;
|
|
1615
|
+
} else {
|
|
1616
|
+
appendText(Math.max(tagStart, start) + 1);
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
function copyLocator(f, t) {
|
|
1621
|
+
t.lineNumber = f.lineNumber;
|
|
1622
|
+
t.columnNumber = f.columnNumber;
|
|
1623
|
+
return t;
|
|
1624
|
+
}
|
|
1625
|
+
function parseElementStartPart(source, start, el, currentNSMap, entityReplacer, errorHandler) {
|
|
1626
|
+
function addAttribute(qname, value2, startIndex) {
|
|
1627
|
+
if (el.attributeNames.hasOwnProperty(qname)) {
|
|
1628
|
+
errorHandler.fatalError("Attribute " + qname + " redefined");
|
|
1629
|
+
}
|
|
1630
|
+
el.addValue(qname, value2, startIndex);
|
|
1631
|
+
}
|
|
1632
|
+
var attrName;
|
|
1633
|
+
var value;
|
|
1634
|
+
var p = ++start;
|
|
1635
|
+
var s = S_TAG;
|
|
1636
|
+
while (true) {
|
|
1637
|
+
var c = source.charAt(p);
|
|
1638
|
+
switch (c) {
|
|
1639
|
+
case "=":
|
|
1640
|
+
if (s === S_ATTR) {
|
|
1641
|
+
attrName = source.slice(start, p);
|
|
1642
|
+
s = S_EQ;
|
|
1643
|
+
} else if (s === S_ATTR_SPACE) {
|
|
1644
|
+
s = S_EQ;
|
|
1645
|
+
} else {
|
|
1646
|
+
throw new Error("attribute equal must after attrName");
|
|
1647
|
+
}
|
|
1648
|
+
break;
|
|
1649
|
+
case "'":
|
|
1650
|
+
case '"':
|
|
1651
|
+
if (s === S_EQ || s === S_ATTR) {
|
|
1652
|
+
if (s === S_ATTR) {
|
|
1653
|
+
errorHandler.warning('attribute value must after "="');
|
|
1654
|
+
attrName = source.slice(start, p);
|
|
1655
|
+
}
|
|
1656
|
+
start = p + 1;
|
|
1657
|
+
p = source.indexOf(c, start);
|
|
1658
|
+
if (p > 0) {
|
|
1659
|
+
value = source.slice(start, p).replace(/&#?\w+;/g, entityReplacer);
|
|
1660
|
+
addAttribute(attrName, value, start - 1);
|
|
1661
|
+
s = S_ATTR_END;
|
|
1662
|
+
} else {
|
|
1663
|
+
throw new Error("attribute value no end '" + c + "' match");
|
|
1664
|
+
}
|
|
1665
|
+
} else if (s == S_ATTR_NOQUOT_VALUE) {
|
|
1666
|
+
value = source.slice(start, p).replace(/&#?\w+;/g, entityReplacer);
|
|
1667
|
+
addAttribute(attrName, value, start);
|
|
1668
|
+
errorHandler.warning('attribute "' + attrName + '" missed start quot(' + c + ")!!");
|
|
1669
|
+
start = p + 1;
|
|
1670
|
+
s = S_ATTR_END;
|
|
1671
|
+
} else {
|
|
1672
|
+
throw new Error('attribute value must after "="');
|
|
1673
|
+
}
|
|
1674
|
+
break;
|
|
1675
|
+
case "/":
|
|
1676
|
+
switch (s) {
|
|
1677
|
+
case S_TAG:
|
|
1678
|
+
el.setTagName(source.slice(start, p));
|
|
1679
|
+
case S_ATTR_END:
|
|
1680
|
+
case S_TAG_SPACE:
|
|
1681
|
+
case S_TAG_CLOSE:
|
|
1682
|
+
s = S_TAG_CLOSE;
|
|
1683
|
+
el.closed = true;
|
|
1684
|
+
case S_ATTR_NOQUOT_VALUE:
|
|
1685
|
+
case S_ATTR:
|
|
1686
|
+
case S_ATTR_SPACE:
|
|
1687
|
+
break;
|
|
1688
|
+
default:
|
|
1689
|
+
throw new Error("attribute invalid close char('/')");
|
|
1690
|
+
}
|
|
1691
|
+
break;
|
|
1692
|
+
case "":
|
|
1693
|
+
errorHandler.error("unexpected end of input");
|
|
1694
|
+
if (s == S_TAG) {
|
|
1695
|
+
el.setTagName(source.slice(start, p));
|
|
1696
|
+
}
|
|
1697
|
+
return p;
|
|
1698
|
+
case ">":
|
|
1699
|
+
switch (s) {
|
|
1700
|
+
case S_TAG:
|
|
1701
|
+
el.setTagName(source.slice(start, p));
|
|
1702
|
+
case S_ATTR_END:
|
|
1703
|
+
case S_TAG_SPACE:
|
|
1704
|
+
case S_TAG_CLOSE:
|
|
1705
|
+
break;
|
|
1706
|
+
case S_ATTR_NOQUOT_VALUE:
|
|
1707
|
+
case S_ATTR:
|
|
1708
|
+
value = source.slice(start, p);
|
|
1709
|
+
if (value.slice(-1) === "/") {
|
|
1710
|
+
el.closed = true;
|
|
1711
|
+
value = value.slice(0, -1);
|
|
1712
|
+
}
|
|
1713
|
+
case S_ATTR_SPACE:
|
|
1714
|
+
if (s === S_ATTR_SPACE) {
|
|
1715
|
+
value = attrName;
|
|
1716
|
+
}
|
|
1717
|
+
if (s == S_ATTR_NOQUOT_VALUE) {
|
|
1718
|
+
errorHandler.warning('attribute "' + value + '" missed quot(")!');
|
|
1719
|
+
addAttribute(attrName, value.replace(/&#?\w+;/g, entityReplacer), start);
|
|
1720
|
+
} else {
|
|
1721
|
+
if (!NAMESPACE.isHTML(currentNSMap[""]) || !value.match(/^(?:disabled|checked|selected)$/i)) {
|
|
1722
|
+
errorHandler.warning('attribute "' + value + '" missed value!! "' + value + '" instead!!');
|
|
1723
|
+
}
|
|
1724
|
+
addAttribute(value, value, start);
|
|
1725
|
+
}
|
|
1726
|
+
break;
|
|
1727
|
+
case S_EQ:
|
|
1728
|
+
throw new Error("attribute value missed!!");
|
|
1729
|
+
}
|
|
1730
|
+
return p;
|
|
1731
|
+
case "\x80":
|
|
1732
|
+
c = " ";
|
|
1733
|
+
default:
|
|
1734
|
+
if (c <= " ") {
|
|
1735
|
+
switch (s) {
|
|
1736
|
+
case S_TAG:
|
|
1737
|
+
el.setTagName(source.slice(start, p));
|
|
1738
|
+
s = S_TAG_SPACE;
|
|
1739
|
+
break;
|
|
1740
|
+
case S_ATTR:
|
|
1741
|
+
attrName = source.slice(start, p);
|
|
1742
|
+
s = S_ATTR_SPACE;
|
|
1743
|
+
break;
|
|
1744
|
+
case S_ATTR_NOQUOT_VALUE:
|
|
1745
|
+
var value = source.slice(start, p).replace(/&#?\w+;/g, entityReplacer);
|
|
1746
|
+
errorHandler.warning('attribute "' + value + '" missed quot(")!!');
|
|
1747
|
+
addAttribute(attrName, value, start);
|
|
1748
|
+
case S_ATTR_END:
|
|
1749
|
+
s = S_TAG_SPACE;
|
|
1750
|
+
break;
|
|
1751
|
+
}
|
|
1752
|
+
} else {
|
|
1753
|
+
switch (s) {
|
|
1754
|
+
case S_ATTR_SPACE:
|
|
1755
|
+
var tagName = el.tagName;
|
|
1756
|
+
if (!NAMESPACE.isHTML(currentNSMap[""]) || !attrName.match(/^(?:disabled|checked|selected)$/i)) {
|
|
1757
|
+
errorHandler.warning('attribute "' + attrName + '" missed value!! "' + attrName + '" instead2!!');
|
|
1758
|
+
}
|
|
1759
|
+
addAttribute(attrName, attrName, start);
|
|
1760
|
+
start = p;
|
|
1761
|
+
s = S_ATTR;
|
|
1762
|
+
break;
|
|
1763
|
+
case S_ATTR_END:
|
|
1764
|
+
errorHandler.warning('attribute space is required"' + attrName + '"!!');
|
|
1765
|
+
case S_TAG_SPACE:
|
|
1766
|
+
s = S_ATTR;
|
|
1767
|
+
start = p;
|
|
1768
|
+
break;
|
|
1769
|
+
case S_EQ:
|
|
1770
|
+
s = S_ATTR_NOQUOT_VALUE;
|
|
1771
|
+
start = p;
|
|
1772
|
+
break;
|
|
1773
|
+
case S_TAG_CLOSE:
|
|
1774
|
+
throw new Error("elements closed character '/' and '>' must be connected to");
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
p++;
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
function appendElement(el, domBuilder, currentNSMap) {
|
|
1782
|
+
var tagName = el.tagName;
|
|
1783
|
+
var localNSMap = null;
|
|
1784
|
+
var i = el.length;
|
|
1785
|
+
while (i--) {
|
|
1786
|
+
var a = el[i];
|
|
1787
|
+
var qName = a.qName;
|
|
1788
|
+
var value = a.value;
|
|
1789
|
+
var nsp = qName.indexOf(":");
|
|
1790
|
+
if (nsp > 0) {
|
|
1791
|
+
var prefix = a.prefix = qName.slice(0, nsp);
|
|
1792
|
+
var localName = qName.slice(nsp + 1);
|
|
1793
|
+
var nsPrefix = prefix === "xmlns" && localName;
|
|
1794
|
+
} else {
|
|
1795
|
+
localName = qName;
|
|
1796
|
+
prefix = null;
|
|
1797
|
+
nsPrefix = qName === "xmlns" && "";
|
|
1798
|
+
}
|
|
1799
|
+
a.localName = localName;
|
|
1800
|
+
if (nsPrefix !== false) {
|
|
1801
|
+
if (localNSMap == null) {
|
|
1802
|
+
localNSMap = {};
|
|
1803
|
+
_copy(currentNSMap, currentNSMap = {});
|
|
1804
|
+
}
|
|
1805
|
+
currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
|
|
1806
|
+
a.uri = NAMESPACE.XMLNS;
|
|
1807
|
+
domBuilder.startPrefixMapping(nsPrefix, value);
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
var i = el.length;
|
|
1811
|
+
while (i--) {
|
|
1812
|
+
a = el[i];
|
|
1813
|
+
var prefix = a.prefix;
|
|
1814
|
+
if (prefix) {
|
|
1815
|
+
if (prefix === "xml") {
|
|
1816
|
+
a.uri = NAMESPACE.XML;
|
|
1817
|
+
}
|
|
1818
|
+
if (prefix !== "xmlns") {
|
|
1819
|
+
a.uri = currentNSMap[prefix || ""];
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
var nsp = tagName.indexOf(":");
|
|
1824
|
+
if (nsp > 0) {
|
|
1825
|
+
prefix = el.prefix = tagName.slice(0, nsp);
|
|
1826
|
+
localName = el.localName = tagName.slice(nsp + 1);
|
|
1827
|
+
} else {
|
|
1828
|
+
prefix = null;
|
|
1829
|
+
localName = el.localName = tagName;
|
|
1830
|
+
}
|
|
1831
|
+
var ns = el.uri = currentNSMap[prefix || ""];
|
|
1832
|
+
domBuilder.startElement(ns, localName, tagName, el);
|
|
1833
|
+
if (el.closed) {
|
|
1834
|
+
domBuilder.endElement(ns, localName, tagName);
|
|
1835
|
+
if (localNSMap) {
|
|
1836
|
+
for (prefix in localNSMap) {
|
|
1837
|
+
domBuilder.endPrefixMapping(prefix);
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1840
|
+
} else {
|
|
1841
|
+
el.currentNSMap = currentNSMap;
|
|
1842
|
+
el.localNSMap = localNSMap;
|
|
1843
|
+
return true;
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
function parseHtmlSpecialContent(source, elStartEnd, tagName, entityReplacer, domBuilder) {
|
|
1847
|
+
if (/^(?:script|textarea)$/i.test(tagName)) {
|
|
1848
|
+
var elEndStart = source.indexOf("</" + tagName + ">", elStartEnd);
|
|
1849
|
+
var text = source.substring(elStartEnd + 1, elEndStart);
|
|
1850
|
+
if (/[&<]/.test(text)) {
|
|
1851
|
+
if (/^script$/i.test(tagName)) {
|
|
1852
|
+
domBuilder.characters(text, 0, text.length);
|
|
1853
|
+
return elEndStart;
|
|
1854
|
+
}
|
|
1855
|
+
text = text.replace(/&#?\w+;/g, entityReplacer);
|
|
1856
|
+
domBuilder.characters(text, 0, text.length);
|
|
1857
|
+
return elEndStart;
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
return elStartEnd + 1;
|
|
1861
|
+
}
|
|
1862
|
+
function fixSelfClosed(source, elStartEnd, tagName, closeMap) {
|
|
1863
|
+
var pos = closeMap[tagName];
|
|
1864
|
+
if (pos == null) {
|
|
1865
|
+
pos = source.lastIndexOf("</" + tagName + ">");
|
|
1866
|
+
if (pos < elStartEnd) {
|
|
1867
|
+
pos = source.lastIndexOf("</" + tagName);
|
|
1868
|
+
}
|
|
1869
|
+
closeMap[tagName] = pos;
|
|
1870
|
+
}
|
|
1871
|
+
return pos < elStartEnd;
|
|
1872
|
+
}
|
|
1873
|
+
function _copy(source, target) {
|
|
1874
|
+
for (var n in source) {
|
|
1875
|
+
target[n] = source[n];
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1878
|
+
function parseDCC(source, start, domBuilder, errorHandler) {
|
|
1879
|
+
var next = source.charAt(start + 2);
|
|
1880
|
+
switch (next) {
|
|
1881
|
+
case "-":
|
|
1882
|
+
if (source.charAt(start + 3) === "-") {
|
|
1883
|
+
var end = source.indexOf("-->", start + 4);
|
|
1884
|
+
if (end > start) {
|
|
1885
|
+
domBuilder.comment(source, start + 4, end - start - 4);
|
|
1886
|
+
return end + 3;
|
|
1887
|
+
} else {
|
|
1888
|
+
errorHandler.error("Unclosed comment");
|
|
1889
|
+
return -1;
|
|
1890
|
+
}
|
|
1891
|
+
} else {
|
|
1892
|
+
return -1;
|
|
1893
|
+
}
|
|
1894
|
+
default:
|
|
1895
|
+
if (source.substr(start + 3, 6) == "CDATA[") {
|
|
1896
|
+
var end = source.indexOf("]]>", start + 9);
|
|
1897
|
+
domBuilder.startCDATA();
|
|
1898
|
+
domBuilder.characters(source, start + 9, end - start - 9);
|
|
1899
|
+
domBuilder.endCDATA();
|
|
1900
|
+
return end + 3;
|
|
1901
|
+
}
|
|
1902
|
+
var matchs = split(source, start);
|
|
1903
|
+
var len = matchs.length;
|
|
1904
|
+
if (len > 1 && /!doctype/i.test(matchs[0][0])) {
|
|
1905
|
+
var name = matchs[1][0];
|
|
1906
|
+
var pubid = false;
|
|
1907
|
+
var sysid = false;
|
|
1908
|
+
if (len > 3) {
|
|
1909
|
+
if (/^public$/i.test(matchs[2][0])) {
|
|
1910
|
+
pubid = matchs[3][0];
|
|
1911
|
+
sysid = len > 4 && matchs[4][0];
|
|
1912
|
+
} else if (/^system$/i.test(matchs[2][0])) {
|
|
1913
|
+
sysid = matchs[3][0];
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1916
|
+
var lastMatch = matchs[len - 1];
|
|
1917
|
+
domBuilder.startDTD(name, pubid, sysid);
|
|
1918
|
+
domBuilder.endDTD();
|
|
1919
|
+
return lastMatch.index + lastMatch[0].length;
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
return -1;
|
|
1923
|
+
}
|
|
1924
|
+
function parseInstruction(source, start, domBuilder) {
|
|
1925
|
+
var end = source.indexOf("?>", start);
|
|
1926
|
+
if (end) {
|
|
1927
|
+
var match = source.substring(start, end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);
|
|
1928
|
+
if (match) {
|
|
1929
|
+
var len = match[0].length;
|
|
1930
|
+
domBuilder.processingInstruction(match[1], match[2]);
|
|
1931
|
+
return end + 2;
|
|
1932
|
+
} else {
|
|
1933
|
+
return -1;
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
return -1;
|
|
1937
|
+
}
|
|
1938
|
+
function ElementAttributes() {
|
|
1939
|
+
this.attributeNames = {};
|
|
1940
|
+
}
|
|
1941
|
+
ElementAttributes.prototype = {
|
|
1942
|
+
setTagName: function(tagName) {
|
|
1943
|
+
if (!tagNamePattern.test(tagName)) {
|
|
1944
|
+
throw new Error("invalid tagName:" + tagName);
|
|
1945
|
+
}
|
|
1946
|
+
this.tagName = tagName;
|
|
1947
|
+
},
|
|
1948
|
+
addValue: function(qName, value, offset) {
|
|
1949
|
+
if (!tagNamePattern.test(qName)) {
|
|
1950
|
+
throw new Error("invalid attribute:" + qName);
|
|
1951
|
+
}
|
|
1952
|
+
this.attributeNames[qName] = this.length;
|
|
1953
|
+
this[this.length++] = { qName, value, offset };
|
|
1954
|
+
},
|
|
1955
|
+
length: 0,
|
|
1956
|
+
getLocalName: function(i) {
|
|
1957
|
+
return this[i].localName;
|
|
1958
|
+
},
|
|
1959
|
+
getLocator: function(i) {
|
|
1960
|
+
return this[i].locator;
|
|
1961
|
+
},
|
|
1962
|
+
getQName: function(i) {
|
|
1963
|
+
return this[i].qName;
|
|
1964
|
+
},
|
|
1965
|
+
getURI: function(i) {
|
|
1966
|
+
return this[i].uri;
|
|
1967
|
+
},
|
|
1968
|
+
getValue: function(i) {
|
|
1969
|
+
return this[i].value;
|
|
1970
|
+
}
|
|
1971
|
+
};
|
|
1972
|
+
function split(source, start) {
|
|
1973
|
+
var match;
|
|
1974
|
+
var buf = [];
|
|
1975
|
+
var reg = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;
|
|
1976
|
+
reg.lastIndex = start;
|
|
1977
|
+
reg.exec(source);
|
|
1978
|
+
while (match = reg.exec(source)) {
|
|
1979
|
+
buf.push(match);
|
|
1980
|
+
if (match[1])
|
|
1981
|
+
return buf;
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
exports.XMLReader = XMLReader;
|
|
1985
|
+
exports.ParseError = ParseError;
|
|
1986
|
+
}
|
|
1987
|
+
});
|
|
1988
|
+
|
|
1989
|
+
// ../../node_modules/@xmldom/xmldom/lib/dom-parser.js
|
|
1990
|
+
var require_dom_parser = __commonJS({
|
|
1991
|
+
"../../node_modules/@xmldom/xmldom/lib/dom-parser.js"(exports) {
|
|
1992
|
+
var conventions = require_conventions();
|
|
1993
|
+
var dom = require_dom();
|
|
1994
|
+
var entities = require_entities();
|
|
1995
|
+
var sax = require_sax();
|
|
1996
|
+
var DOMImplementation = dom.DOMImplementation;
|
|
1997
|
+
var NAMESPACE = conventions.NAMESPACE;
|
|
1998
|
+
var ParseError = sax.ParseError;
|
|
1999
|
+
var XMLReader = sax.XMLReader;
|
|
2000
|
+
function DOMParser2(options) {
|
|
2001
|
+
this.options = options || { locator: {} };
|
|
2002
|
+
}
|
|
2003
|
+
DOMParser2.prototype.parseFromString = function(source, mimeType) {
|
|
2004
|
+
var options = this.options;
|
|
2005
|
+
var sax2 = new XMLReader();
|
|
2006
|
+
var domBuilder = options.domBuilder || new DOMHandler();
|
|
2007
|
+
var errorHandler = options.errorHandler;
|
|
2008
|
+
var locator = options.locator;
|
|
2009
|
+
var defaultNSMap = options.xmlns || {};
|
|
2010
|
+
var isHTML = /\/x?html?$/.test(mimeType);
|
|
2011
|
+
var entityMap = isHTML ? entities.HTML_ENTITIES : entities.XML_ENTITIES;
|
|
2012
|
+
if (locator) {
|
|
2013
|
+
domBuilder.setDocumentLocator(locator);
|
|
2014
|
+
}
|
|
2015
|
+
sax2.errorHandler = buildErrorHandler(errorHandler, domBuilder, locator);
|
|
2016
|
+
sax2.domBuilder = options.domBuilder || domBuilder;
|
|
2017
|
+
if (isHTML) {
|
|
2018
|
+
defaultNSMap[""] = NAMESPACE.HTML;
|
|
2019
|
+
}
|
|
2020
|
+
defaultNSMap.xml = defaultNSMap.xml || NAMESPACE.XML;
|
|
2021
|
+
if (source && typeof source === "string") {
|
|
2022
|
+
sax2.parse(source, defaultNSMap, entityMap);
|
|
2023
|
+
} else {
|
|
2024
|
+
sax2.errorHandler.error("invalid doc source");
|
|
2025
|
+
}
|
|
2026
|
+
return domBuilder.doc;
|
|
2027
|
+
};
|
|
2028
|
+
function buildErrorHandler(errorImpl, domBuilder, locator) {
|
|
2029
|
+
if (!errorImpl) {
|
|
2030
|
+
if (domBuilder instanceof DOMHandler) {
|
|
2031
|
+
return domBuilder;
|
|
2032
|
+
}
|
|
2033
|
+
errorImpl = domBuilder;
|
|
2034
|
+
}
|
|
2035
|
+
var errorHandler = {};
|
|
2036
|
+
var isCallback = errorImpl instanceof Function;
|
|
2037
|
+
locator = locator || {};
|
|
2038
|
+
function build(key) {
|
|
2039
|
+
var fn = errorImpl[key];
|
|
2040
|
+
if (!fn && isCallback) {
|
|
2041
|
+
fn = errorImpl.length == 2 ? function(msg) {
|
|
2042
|
+
errorImpl(key, msg);
|
|
2043
|
+
} : errorImpl;
|
|
2044
|
+
}
|
|
2045
|
+
errorHandler[key] = fn && function(msg) {
|
|
2046
|
+
fn("[xmldom " + key + "] " + msg + _locator(locator));
|
|
2047
|
+
} || function() {
|
|
2048
|
+
};
|
|
2049
|
+
}
|
|
2050
|
+
build("warning");
|
|
2051
|
+
build("error");
|
|
2052
|
+
build("fatalError");
|
|
2053
|
+
return errorHandler;
|
|
2054
|
+
}
|
|
2055
|
+
function DOMHandler() {
|
|
2056
|
+
this.cdata = false;
|
|
2057
|
+
}
|
|
2058
|
+
function position(locator, node) {
|
|
2059
|
+
node.lineNumber = locator.lineNumber;
|
|
2060
|
+
node.columnNumber = locator.columnNumber;
|
|
2061
|
+
}
|
|
2062
|
+
DOMHandler.prototype = {
|
|
2063
|
+
startDocument: function() {
|
|
2064
|
+
this.doc = new DOMImplementation().createDocument(null, null, null);
|
|
2065
|
+
if (this.locator) {
|
|
2066
|
+
this.doc.documentURI = this.locator.systemId;
|
|
2067
|
+
}
|
|
2068
|
+
},
|
|
2069
|
+
startElement: function(namespaceURI, localName, qName, attrs) {
|
|
2070
|
+
var doc = this.doc;
|
|
2071
|
+
var el = doc.createElementNS(namespaceURI, qName || localName);
|
|
2072
|
+
var len = attrs.length;
|
|
2073
|
+
appendElement(this, el);
|
|
2074
|
+
this.currentElement = el;
|
|
2075
|
+
this.locator && position(this.locator, el);
|
|
2076
|
+
for (var i = 0; i < len; i++) {
|
|
2077
|
+
var namespaceURI = attrs.getURI(i);
|
|
2078
|
+
var value = attrs.getValue(i);
|
|
2079
|
+
var qName = attrs.getQName(i);
|
|
2080
|
+
var attr = doc.createAttributeNS(namespaceURI, qName);
|
|
2081
|
+
this.locator && position(attrs.getLocator(i), attr);
|
|
2082
|
+
attr.value = attr.nodeValue = value;
|
|
2083
|
+
el.setAttributeNode(attr);
|
|
2084
|
+
}
|
|
2085
|
+
},
|
|
2086
|
+
endElement: function(namespaceURI, localName, qName) {
|
|
2087
|
+
var current = this.currentElement;
|
|
2088
|
+
var tagName = current.tagName;
|
|
2089
|
+
this.currentElement = current.parentNode;
|
|
2090
|
+
},
|
|
2091
|
+
startPrefixMapping: function(prefix, uri) {
|
|
2092
|
+
},
|
|
2093
|
+
endPrefixMapping: function(prefix) {
|
|
2094
|
+
},
|
|
2095
|
+
processingInstruction: function(target, data) {
|
|
2096
|
+
var ins = this.doc.createProcessingInstruction(target, data);
|
|
2097
|
+
this.locator && position(this.locator, ins);
|
|
2098
|
+
appendElement(this, ins);
|
|
2099
|
+
},
|
|
2100
|
+
ignorableWhitespace: function(ch, start, length) {
|
|
2101
|
+
},
|
|
2102
|
+
characters: function(chars, start, length) {
|
|
2103
|
+
chars = _toString.apply(this, arguments);
|
|
2104
|
+
if (chars) {
|
|
2105
|
+
if (this.cdata) {
|
|
2106
|
+
var charNode = this.doc.createCDATASection(chars);
|
|
2107
|
+
} else {
|
|
2108
|
+
var charNode = this.doc.createTextNode(chars);
|
|
2109
|
+
}
|
|
2110
|
+
if (this.currentElement) {
|
|
2111
|
+
this.currentElement.appendChild(charNode);
|
|
2112
|
+
} else if (/^\s*$/.test(chars)) {
|
|
2113
|
+
this.doc.appendChild(charNode);
|
|
2114
|
+
}
|
|
2115
|
+
this.locator && position(this.locator, charNode);
|
|
2116
|
+
}
|
|
2117
|
+
},
|
|
2118
|
+
skippedEntity: function(name) {
|
|
2119
|
+
},
|
|
2120
|
+
endDocument: function() {
|
|
2121
|
+
this.doc.normalize();
|
|
2122
|
+
},
|
|
2123
|
+
setDocumentLocator: function(locator) {
|
|
2124
|
+
if (this.locator = locator) {
|
|
2125
|
+
locator.lineNumber = 0;
|
|
2126
|
+
}
|
|
2127
|
+
},
|
|
2128
|
+
comment: function(chars, start, length) {
|
|
2129
|
+
chars = _toString.apply(this, arguments);
|
|
2130
|
+
var comm = this.doc.createComment(chars);
|
|
2131
|
+
this.locator && position(this.locator, comm);
|
|
2132
|
+
appendElement(this, comm);
|
|
2133
|
+
},
|
|
2134
|
+
startCDATA: function() {
|
|
2135
|
+
this.cdata = true;
|
|
2136
|
+
},
|
|
2137
|
+
endCDATA: function() {
|
|
2138
|
+
this.cdata = false;
|
|
2139
|
+
},
|
|
2140
|
+
startDTD: function(name, publicId, systemId) {
|
|
2141
|
+
var impl = this.doc.implementation;
|
|
2142
|
+
if (impl && impl.createDocumentType) {
|
|
2143
|
+
var dt = impl.createDocumentType(name, publicId, systemId);
|
|
2144
|
+
this.locator && position(this.locator, dt);
|
|
2145
|
+
appendElement(this, dt);
|
|
2146
|
+
this.doc.doctype = dt;
|
|
2147
|
+
}
|
|
2148
|
+
},
|
|
2149
|
+
warning: function(error) {
|
|
2150
|
+
console.warn("[xmldom warning] " + error, _locator(this.locator));
|
|
2151
|
+
},
|
|
2152
|
+
error: function(error) {
|
|
2153
|
+
console.error("[xmldom error] " + error, _locator(this.locator));
|
|
2154
|
+
},
|
|
2155
|
+
fatalError: function(error) {
|
|
2156
|
+
throw new ParseError(error, this.locator);
|
|
2157
|
+
}
|
|
2158
|
+
};
|
|
2159
|
+
function _locator(l) {
|
|
2160
|
+
if (l) {
|
|
2161
|
+
return "\n@" + (l.systemId || "") + "#[line:" + l.lineNumber + ",col:" + l.columnNumber + "]";
|
|
2162
|
+
}
|
|
2163
|
+
}
|
|
2164
|
+
function _toString(chars, start, length) {
|
|
2165
|
+
if (typeof chars == "string") {
|
|
2166
|
+
return chars.substr(start, length);
|
|
2167
|
+
} else {
|
|
2168
|
+
if (chars.length >= start + length || start) {
|
|
2169
|
+
return new java.lang.String(chars, start, length) + "";
|
|
2170
|
+
}
|
|
2171
|
+
return chars;
|
|
2172
|
+
}
|
|
2173
|
+
}
|
|
2174
|
+
"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g, function(key) {
|
|
2175
|
+
DOMHandler.prototype[key] = function() {
|
|
2176
|
+
return null;
|
|
2177
|
+
};
|
|
2178
|
+
});
|
|
2179
|
+
function appendElement(hander, node) {
|
|
2180
|
+
if (!hander.currentElement) {
|
|
2181
|
+
hander.doc.appendChild(node);
|
|
2182
|
+
} else {
|
|
2183
|
+
hander.currentElement.appendChild(node);
|
|
2184
|
+
}
|
|
2185
|
+
}
|
|
2186
|
+
exports.__DOMHandler = DOMHandler;
|
|
2187
|
+
exports.DOMParser = DOMParser2;
|
|
2188
|
+
exports.DOMImplementation = dom.DOMImplementation;
|
|
2189
|
+
exports.XMLSerializer = dom.XMLSerializer;
|
|
2190
|
+
}
|
|
2191
|
+
});
|
|
2192
|
+
|
|
2193
|
+
// ../../node_modules/@xmldom/xmldom/lib/index.js
|
|
2194
|
+
var require_lib = __commonJS({
|
|
2195
|
+
"../../node_modules/@xmldom/xmldom/lib/index.js"(exports) {
|
|
2196
|
+
var dom = require_dom();
|
|
2197
|
+
exports.DOMImplementation = dom.DOMImplementation;
|
|
2198
|
+
exports.XMLSerializer = dom.XMLSerializer;
|
|
2199
|
+
exports.DOMParser = require_dom_parser().DOMParser;
|
|
2200
|
+
}
|
|
2201
|
+
});
|
|
2202
|
+
|
|
2203
|
+
// src/utils/globals.ts
|
|
2204
|
+
var isBrowser, globals, global_;
|
|
2205
|
+
var init_globals = __esm({
|
|
2206
|
+
"src/utils/globals.ts"() {
|
|
2207
|
+
isBrowser = typeof process !== "object" || String(process) !== "[object process]" || process.browser;
|
|
2208
|
+
globals = {
|
|
2209
|
+
self: typeof self !== "undefined" && self,
|
|
2210
|
+
window: typeof window !== "undefined" && window,
|
|
2211
|
+
global: typeof global !== "undefined" && global
|
|
2212
|
+
};
|
|
2213
|
+
global_ = globals.global || globals.self || globals.window;
|
|
2214
|
+
}
|
|
2215
|
+
});
|
|
2216
|
+
|
|
2217
|
+
// src/lib/encoding-indexes.ts
|
|
2218
|
+
var encoding_indexes_default;
|
|
2219
|
+
var init_encoding_indexes = __esm({
|
|
2220
|
+
"src/lib/encoding-indexes.ts"() {
|
|
2221
|
+
encoding_indexes_default = {
|
|
2222
|
+
"ibm866": [1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 9617, 9618, 9619, 9474, 9508, 9569, 9570, 9558, 9557, 9571, 9553, 9559, 9565, 9564, 9563, 9488, 9492, 9524, 9516, 9500, 9472, 9532, 9566, 9567, 9562, 9556, 9577, 9574, 9568, 9552, 9580, 9575, 9576, 9572, 9573, 9561, 9560, 9554, 9555, 9579, 9578, 9496, 9484, 9608, 9604, 9612, 9616, 9600, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1025, 1105, 1028, 1108, 1031, 1111, 1038, 1118, 176, 8729, 183, 8730, 8470, 164, 9632, 160],
|
|
2223
|
+
"iso-8859-2": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 260, 728, 321, 164, 317, 346, 167, 168, 352, 350, 356, 377, 173, 381, 379, 176, 261, 731, 322, 180, 318, 347, 711, 184, 353, 351, 357, 378, 733, 382, 380, 340, 193, 194, 258, 196, 313, 262, 199, 268, 201, 280, 203, 282, 205, 206, 270, 272, 323, 327, 211, 212, 336, 214, 215, 344, 366, 218, 368, 220, 221, 354, 223, 341, 225, 226, 259, 228, 314, 263, 231, 269, 233, 281, 235, 283, 237, 238, 271, 273, 324, 328, 243, 244, 337, 246, 247, 345, 367, 250, 369, 252, 253, 355, 729],
|
|
2224
|
+
"iso-8859-3": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 294, 728, 163, 164, null, 292, 167, 168, 304, 350, 286, 308, 173, null, 379, 176, 295, 178, 179, 180, 181, 293, 183, 184, 305, 351, 287, 309, 189, null, 380, 192, 193, 194, null, 196, 266, 264, 199, 200, 201, 202, 203, 204, 205, 206, 207, null, 209, 210, 211, 212, 288, 214, 215, 284, 217, 218, 219, 220, 364, 348, 223, 224, 225, 226, null, 228, 267, 265, 231, 232, 233, 234, 235, 236, 237, 238, 239, null, 241, 242, 243, 244, 289, 246, 247, 285, 249, 250, 251, 252, 365, 349, 729],
|
|
2225
|
+
"iso-8859-4": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 260, 312, 342, 164, 296, 315, 167, 168, 352, 274, 290, 358, 173, 381, 175, 176, 261, 731, 343, 180, 297, 316, 711, 184, 353, 275, 291, 359, 330, 382, 331, 256, 193, 194, 195, 196, 197, 198, 302, 268, 201, 280, 203, 278, 205, 206, 298, 272, 325, 332, 310, 212, 213, 214, 215, 216, 370, 218, 219, 220, 360, 362, 223, 257, 225, 226, 227, 228, 229, 230, 303, 269, 233, 281, 235, 279, 237, 238, 299, 273, 326, 333, 311, 244, 245, 246, 247, 248, 371, 250, 251, 252, 361, 363, 729],
|
|
2226
|
+
"iso-8859-5": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 173, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 8470, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 167, 1118, 1119],
|
|
2227
|
+
"iso-8859-6": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, null, null, null, 164, null, null, null, null, null, null, null, 1548, 173, null, null, null, null, null, null, null, null, null, null, null, null, null, 1563, null, null, null, 1567, null, 1569, 1570, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1578, 1579, 1580, 1581, 1582, 1583, 1584, 1585, 1586, 1587, 1588, 1589, 1590, 1591, 1592, 1593, 1594, null, null, null, null, null, 1600, 1601, 1602, 1603, 1604, 1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613, 1614, 1615, 1616, 1617, 1618, null, null, null, null, null, null, null, null, null, null, null, null, null],
|
|
2228
|
+
"iso-8859-7": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 8216, 8217, 163, 8364, 8367, 166, 167, 168, 169, 890, 171, 172, 173, null, 8213, 176, 177, 178, 179, 900, 901, 902, 183, 904, 905, 906, 187, 908, 189, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, null, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, null],
|
|
2229
|
+
"iso-8859-8": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, null, 162, 163, 164, 165, 166, 167, 168, 169, 215, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 247, 187, 188, 189, 190, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 8215, 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496, 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, null, null, 8206, 8207, null],
|
|
2230
|
+
"iso-8859-10": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 260, 274, 290, 298, 296, 310, 167, 315, 272, 352, 358, 381, 173, 362, 330, 176, 261, 275, 291, 299, 297, 311, 183, 316, 273, 353, 359, 382, 8213, 363, 331, 256, 193, 194, 195, 196, 197, 198, 302, 268, 201, 280, 203, 278, 205, 206, 207, 208, 325, 332, 211, 212, 213, 214, 360, 216, 370, 218, 219, 220, 221, 222, 223, 257, 225, 226, 227, 228, 229, 230, 303, 269, 233, 281, 235, 279, 237, 238, 239, 240, 326, 333, 243, 244, 245, 246, 361, 248, 371, 250, 251, 252, 253, 254, 312],
|
|
2231
|
+
"iso-8859-13": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 8221, 162, 163, 164, 8222, 166, 167, 216, 169, 342, 171, 172, 173, 174, 198, 176, 177, 178, 179, 8220, 181, 182, 183, 248, 185, 343, 187, 188, 189, 190, 230, 260, 302, 256, 262, 196, 197, 280, 274, 268, 201, 377, 278, 290, 310, 298, 315, 352, 323, 325, 211, 332, 213, 214, 215, 370, 321, 346, 362, 220, 379, 381, 223, 261, 303, 257, 263, 228, 229, 281, 275, 269, 233, 378, 279, 291, 311, 299, 316, 353, 324, 326, 243, 333, 245, 246, 247, 371, 322, 347, 363, 252, 380, 382, 8217],
|
|
2232
|
+
"iso-8859-14": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 7682, 7683, 163, 266, 267, 7690, 167, 7808, 169, 7810, 7691, 7922, 173, 174, 376, 7710, 7711, 288, 289, 7744, 7745, 182, 7766, 7809, 7767, 7811, 7776, 7923, 7812, 7813, 7777, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 372, 209, 210, 211, 212, 213, 214, 7786, 216, 217, 218, 219, 220, 221, 374, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 373, 241, 242, 243, 244, 245, 246, 7787, 248, 249, 250, 251, 252, 253, 375, 255],
|
|
2233
|
+
"iso-8859-15": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 8364, 165, 352, 167, 353, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 381, 181, 182, 183, 382, 185, 186, 187, 338, 339, 376, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255],
|
|
2234
|
+
"iso-8859-16": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 260, 261, 321, 8364, 8222, 352, 167, 353, 169, 536, 171, 377, 173, 378, 379, 176, 177, 268, 322, 381, 8221, 182, 183, 382, 269, 537, 187, 338, 339, 376, 380, 192, 193, 194, 258, 196, 262, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 272, 323, 210, 211, 212, 336, 214, 346, 368, 217, 218, 219, 220, 280, 538, 223, 224, 225, 226, 259, 228, 263, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 273, 324, 242, 243, 244, 337, 246, 347, 369, 249, 250, 251, 252, 281, 539, 255],
|
|
2235
|
+
"koi8-r": [9472, 9474, 9484, 9488, 9492, 9496, 9500, 9508, 9516, 9524, 9532, 9600, 9604, 9608, 9612, 9616, 9617, 9618, 9619, 8992, 9632, 8729, 8730, 8776, 8804, 8805, 160, 8993, 176, 178, 183, 247, 9552, 9553, 9554, 1105, 9555, 9556, 9557, 9558, 9559, 9560, 9561, 9562, 9563, 9564, 9565, 9566, 9567, 9568, 9569, 1025, 9570, 9571, 9572, 9573, 9574, 9575, 9576, 9577, 9578, 9579, 9580, 169, 1102, 1072, 1073, 1094, 1076, 1077, 1092, 1075, 1093, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1103, 1088, 1089, 1090, 1091, 1078, 1074, 1100, 1099, 1079, 1096, 1101, 1097, 1095, 1098, 1070, 1040, 1041, 1062, 1044, 1045, 1060, 1043, 1061, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1071, 1056, 1057, 1058, 1059, 1046, 1042, 1068, 1067, 1047, 1064, 1069, 1065, 1063, 1066],
|
|
2236
|
+
"koi8-u": [9472, 9474, 9484, 9488, 9492, 9496, 9500, 9508, 9516, 9524, 9532, 9600, 9604, 9608, 9612, 9616, 9617, 9618, 9619, 8992, 9632, 8729, 8730, 8776, 8804, 8805, 160, 8993, 176, 178, 183, 247, 9552, 9553, 9554, 1105, 1108, 9556, 1110, 1111, 9559, 9560, 9561, 9562, 9563, 1169, 1118, 9566, 9567, 9568, 9569, 1025, 1028, 9571, 1030, 1031, 9574, 9575, 9576, 9577, 9578, 1168, 1038, 169, 1102, 1072, 1073, 1094, 1076, 1077, 1092, 1075, 1093, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1103, 1088, 1089, 1090, 1091, 1078, 1074, 1100, 1099, 1079, 1096, 1101, 1097, 1095, 1098, 1070, 1040, 1041, 1062, 1044, 1045, 1060, 1043, 1061, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1071, 1056, 1057, 1058, 1059, 1046, 1042, 1068, 1067, 1047, 1064, 1069, 1065, 1063, 1066],
|
|
2237
|
+
"macintosh": [196, 197, 199, 201, 209, 214, 220, 225, 224, 226, 228, 227, 229, 231, 233, 232, 234, 235, 237, 236, 238, 239, 241, 243, 242, 244, 246, 245, 250, 249, 251, 252, 8224, 176, 162, 163, 167, 8226, 182, 223, 174, 169, 8482, 180, 168, 8800, 198, 216, 8734, 177, 8804, 8805, 165, 181, 8706, 8721, 8719, 960, 8747, 170, 186, 937, 230, 248, 191, 161, 172, 8730, 402, 8776, 8710, 171, 187, 8230, 160, 192, 195, 213, 338, 339, 8211, 8212, 8220, 8221, 8216, 8217, 247, 9674, 255, 376, 8260, 8364, 8249, 8250, 64257, 64258, 8225, 183, 8218, 8222, 8240, 194, 202, 193, 203, 200, 205, 206, 207, 204, 211, 212, 63743, 210, 218, 219, 217, 305, 710, 732, 175, 728, 729, 730, 184, 733, 731, 711],
|
|
2238
|
+
"windows-874": [8364, 129, 130, 131, 132, 8230, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 152, 153, 154, 155, 156, 157, 158, 159, 160, 3585, 3586, 3587, 3588, 3589, 3590, 3591, 3592, 3593, 3594, 3595, 3596, 3597, 3598, 3599, 3600, 3601, 3602, 3603, 3604, 3605, 3606, 3607, 3608, 3609, 3610, 3611, 3612, 3613, 3614, 3615, 3616, 3617, 3618, 3619, 3620, 3621, 3622, 3623, 3624, 3625, 3626, 3627, 3628, 3629, 3630, 3631, 3632, 3633, 3634, 3635, 3636, 3637, 3638, 3639, 3640, 3641, 3642, null, null, null, null, 3647, 3648, 3649, 3650, 3651, 3652, 3653, 3654, 3655, 3656, 3657, 3658, 3659, 3660, 3661, 3662, 3663, 3664, 3665, 3666, 3667, 3668, 3669, 3670, 3671, 3672, 3673, 3674, 3675, null, null, null, null],
|
|
2239
|
+
"windows-1250": [8364, 129, 8218, 131, 8222, 8230, 8224, 8225, 136, 8240, 352, 8249, 346, 356, 381, 377, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 152, 8482, 353, 8250, 347, 357, 382, 378, 160, 711, 728, 321, 164, 260, 166, 167, 168, 169, 350, 171, 172, 173, 174, 379, 176, 177, 731, 322, 180, 181, 182, 183, 184, 261, 351, 187, 317, 733, 318, 380, 340, 193, 194, 258, 196, 313, 262, 199, 268, 201, 280, 203, 282, 205, 206, 270, 272, 323, 327, 211, 212, 336, 214, 215, 344, 366, 218, 368, 220, 221, 354, 223, 341, 225, 226, 259, 228, 314, 263, 231, 269, 233, 281, 235, 283, 237, 238, 271, 273, 324, 328, 243, 244, 337, 246, 247, 345, 367, 250, 369, 252, 253, 355, 729],
|
|
2240
|
+
"windows-1251": [1026, 1027, 8218, 1107, 8222, 8230, 8224, 8225, 8364, 8240, 1033, 8249, 1034, 1036, 1035, 1039, 1106, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 152, 8482, 1113, 8250, 1114, 1116, 1115, 1119, 160, 1038, 1118, 1032, 164, 1168, 166, 167, 1025, 169, 1028, 171, 172, 173, 174, 1031, 176, 177, 1030, 1110, 1169, 181, 182, 183, 1105, 8470, 1108, 187, 1112, 1029, 1109, 1111, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103],
|
|
2241
|
+
"windows-1252": [8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 352, 8249, 338, 141, 381, 143, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 732, 8482, 353, 8250, 339, 157, 382, 376, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255],
|
|
2242
|
+
"windows-1253": [8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 136, 8240, 138, 8249, 140, 141, 142, 143, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 152, 8482, 154, 8250, 156, 157, 158, 159, 160, 901, 902, 163, 164, 165, 166, 167, 168, 169, null, 171, 172, 173, 174, 8213, 176, 177, 178, 179, 900, 181, 182, 183, 904, 905, 906, 187, 908, 189, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, null, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, null],
|
|
2243
|
+
"windows-1254": [8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 352, 8249, 338, 141, 142, 143, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 732, 8482, 353, 8250, 339, 157, 158, 376, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 286, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 304, 350, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 287, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 305, 351, 255],
|
|
2244
|
+
"windows-1255": [8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 138, 8249, 140, 141, 142, 143, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 732, 8482, 154, 8250, 156, 157, 158, 159, 160, 161, 162, 163, 8362, 165, 166, 167, 168, 169, 215, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 247, 187, 188, 189, 190, 191, 1456, 1457, 1458, 1459, 1460, 1461, 1462, 1463, 1464, 1465, 1466, 1467, 1468, 1469, 1470, 1471, 1472, 1473, 1474, 1475, 1520, 1521, 1522, 1523, 1524, null, null, null, null, null, null, null, 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496, 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, null, null, 8206, 8207, null],
|
|
2245
|
+
"windows-1256": [8364, 1662, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 1657, 8249, 338, 1670, 1688, 1672, 1711, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 1705, 8482, 1681, 8250, 339, 8204, 8205, 1722, 160, 1548, 162, 163, 164, 165, 166, 167, 168, 169, 1726, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 1563, 187, 188, 189, 190, 1567, 1729, 1569, 1570, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1578, 1579, 1580, 1581, 1582, 1583, 1584, 1585, 1586, 1587, 1588, 1589, 1590, 215, 1591, 1592, 1593, 1594, 1600, 1601, 1602, 1603, 224, 1604, 226, 1605, 1606, 1607, 1608, 231, 232, 233, 234, 235, 1609, 1610, 238, 239, 1611, 1612, 1613, 1614, 244, 1615, 1616, 247, 1617, 249, 1618, 251, 252, 8206, 8207, 1746],
|
|
2246
|
+
"windows-1257": [8364, 129, 8218, 131, 8222, 8230, 8224, 8225, 136, 8240, 138, 8249, 140, 168, 711, 184, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 152, 8482, 154, 8250, 156, 175, 731, 159, 160, null, 162, 163, 164, null, 166, 167, 216, 169, 342, 171, 172, 173, 174, 198, 176, 177, 178, 179, 180, 181, 182, 183, 248, 185, 343, 187, 188, 189, 190, 230, 260, 302, 256, 262, 196, 197, 280, 274, 268, 201, 377, 278, 290, 310, 298, 315, 352, 323, 325, 211, 332, 213, 214, 215, 370, 321, 346, 362, 220, 379, 381, 223, 261, 303, 257, 263, 228, 229, 281, 275, 269, 233, 378, 279, 291, 311, 299, 316, 353, 324, 326, 243, 333, 245, 246, 247, 371, 322, 347, 363, 252, 380, 382, 729],
|
|
2247
|
+
"windows-1258": [8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 138, 8249, 338, 141, 142, 143, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 732, 8482, 154, 8250, 339, 157, 158, 376, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 258, 196, 197, 198, 199, 200, 201, 202, 203, 768, 205, 206, 207, 272, 209, 777, 211, 212, 416, 214, 215, 216, 217, 218, 219, 220, 431, 771, 223, 224, 225, 226, 259, 228, 229, 230, 231, 232, 233, 234, 235, 769, 237, 238, 239, 273, 241, 803, 243, 244, 417, 246, 247, 248, 249, 250, 251, 252, 432, 8363, 255],
|
|
2248
|
+
"x-mac-cyrillic": [1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 8224, 176, 1168, 163, 167, 8226, 182, 1030, 174, 169, 8482, 1026, 1106, 8800, 1027, 1107, 8734, 177, 8804, 8805, 1110, 181, 1169, 1032, 1028, 1108, 1031, 1111, 1033, 1113, 1034, 1114, 1112, 1029, 172, 8730, 402, 8776, 8710, 171, 187, 8230, 160, 1035, 1115, 1036, 1116, 1109, 8211, 8212, 8220, 8221, 8216, 8217, 247, 8222, 1038, 1118, 1039, 1119, 8470, 1025, 1105, 1103, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 8364]
|
|
2249
|
+
};
|
|
2250
|
+
}
|
|
2251
|
+
});
|
|
2252
|
+
|
|
2253
|
+
// src/lib/encoding.ts
|
|
2254
|
+
function inRange(a, min, max) {
|
|
2255
|
+
return min <= a && a <= max;
|
|
2256
|
+
}
|
|
2257
|
+
function includes(array, item) {
|
|
2258
|
+
return array.indexOf(item) !== -1;
|
|
2259
|
+
}
|
|
2260
|
+
function ToDictionary(o) {
|
|
2261
|
+
if (o === void 0)
|
|
2262
|
+
return {};
|
|
2263
|
+
if (o === Object(o))
|
|
2264
|
+
return o;
|
|
2265
|
+
throw TypeError("Could not convert argument to dictionary");
|
|
2266
|
+
}
|
|
2267
|
+
function stringToCodePoints(string) {
|
|
2268
|
+
var s = String(string);
|
|
2269
|
+
var n = s.length;
|
|
2270
|
+
var i = 0;
|
|
2271
|
+
var u = [];
|
|
2272
|
+
while (i < n) {
|
|
2273
|
+
var c = s.charCodeAt(i);
|
|
2274
|
+
if (c < 55296 || c > 57343) {
|
|
2275
|
+
u.push(c);
|
|
2276
|
+
} else if (56320 <= c && c <= 57343) {
|
|
2277
|
+
u.push(65533);
|
|
2278
|
+
} else if (55296 <= c && c <= 56319) {
|
|
2279
|
+
if (i === n - 1) {
|
|
2280
|
+
u.push(65533);
|
|
2281
|
+
} else {
|
|
2282
|
+
var d = s.charCodeAt(i + 1);
|
|
2283
|
+
if (56320 <= d && d <= 57343) {
|
|
2284
|
+
var a = c & 1023;
|
|
2285
|
+
var b = d & 1023;
|
|
2286
|
+
u.push(65536 + (a << 10) + b);
|
|
2287
|
+
i += 1;
|
|
2288
|
+
} else {
|
|
2289
|
+
u.push(65533);
|
|
2290
|
+
}
|
|
2291
|
+
}
|
|
2292
|
+
}
|
|
2293
|
+
i += 1;
|
|
2294
|
+
}
|
|
2295
|
+
return u;
|
|
2296
|
+
}
|
|
2297
|
+
function codePointsToString(code_points) {
|
|
2298
|
+
var s = "";
|
|
2299
|
+
for (var i = 0; i < code_points.length; ++i) {
|
|
2300
|
+
var cp = code_points[i];
|
|
2301
|
+
if (cp <= 65535) {
|
|
2302
|
+
s += String.fromCharCode(cp);
|
|
2303
|
+
} else {
|
|
2304
|
+
cp -= 65536;
|
|
2305
|
+
s += String.fromCharCode((cp >> 10) + 55296, (cp & 1023) + 56320);
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
2308
|
+
return s;
|
|
2309
|
+
}
|
|
2310
|
+
function isASCIIByte(a) {
|
|
2311
|
+
return 0 <= a && a <= 127;
|
|
2312
|
+
}
|
|
2313
|
+
function Stream(tokens) {
|
|
2314
|
+
this.tokens = [].slice.call(tokens);
|
|
2315
|
+
this.tokens.reverse();
|
|
2316
|
+
}
|
|
2317
|
+
function decoderError(fatal, opt_code_point) {
|
|
2318
|
+
if (fatal)
|
|
2319
|
+
throw TypeError("Decoder error");
|
|
2320
|
+
return opt_code_point || 65533;
|
|
2321
|
+
}
|
|
2322
|
+
function encoderError(code_point) {
|
|
2323
|
+
throw TypeError("The code point " + code_point + " could not be encoded.");
|
|
2324
|
+
}
|
|
2325
|
+
function Decoder() {
|
|
2326
|
+
}
|
|
2327
|
+
function Encoder() {
|
|
2328
|
+
}
|
|
2329
|
+
function getEncoding(label) {
|
|
2330
|
+
label = String(label).trim().toLowerCase();
|
|
2331
|
+
if (Object.prototype.hasOwnProperty.call(label_to_encoding, label)) {
|
|
2332
|
+
return label_to_encoding[label];
|
|
2333
|
+
}
|
|
2334
|
+
return null;
|
|
2335
|
+
}
|
|
2336
|
+
function indexCodePointFor(pointer, index2) {
|
|
2337
|
+
if (!index2)
|
|
2338
|
+
return null;
|
|
2339
|
+
return index2[pointer] || null;
|
|
2340
|
+
}
|
|
2341
|
+
function indexPointerFor(code_point, index2) {
|
|
2342
|
+
var pointer = index2.indexOf(code_point);
|
|
2343
|
+
return pointer === -1 ? null : pointer;
|
|
2344
|
+
}
|
|
2345
|
+
function index(name) {
|
|
2346
|
+
if (!("encoding-indexes" in global)) {
|
|
2347
|
+
throw Error("Indexes missing. Did you forget to include encoding-indexes.js first?");
|
|
2348
|
+
}
|
|
2349
|
+
return global["encoding-indexes"][name];
|
|
2350
|
+
}
|
|
2351
|
+
function indexGB18030RangesCodePointFor(pointer) {
|
|
2352
|
+
if (pointer > 39419 && pointer < 189e3 || pointer > 1237575)
|
|
2353
|
+
return null;
|
|
2354
|
+
if (pointer === 7457)
|
|
2355
|
+
return 59335;
|
|
2356
|
+
var offset = 0;
|
|
2357
|
+
var code_point_offset = 0;
|
|
2358
|
+
var idx = index("gb18030-ranges");
|
|
2359
|
+
var i;
|
|
2360
|
+
for (i = 0; i < idx.length; ++i) {
|
|
2361
|
+
var entry = idx[i];
|
|
2362
|
+
if (entry[0] <= pointer) {
|
|
2363
|
+
offset = entry[0];
|
|
2364
|
+
code_point_offset = entry[1];
|
|
2365
|
+
} else {
|
|
2366
|
+
break;
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
return code_point_offset + pointer - offset;
|
|
2370
|
+
}
|
|
2371
|
+
function indexGB18030RangesPointerFor(code_point) {
|
|
2372
|
+
if (code_point === 59335)
|
|
2373
|
+
return 7457;
|
|
2374
|
+
var offset = 0;
|
|
2375
|
+
var pointer_offset = 0;
|
|
2376
|
+
var idx = index("gb18030-ranges");
|
|
2377
|
+
var i;
|
|
2378
|
+
for (i = 0; i < idx.length; ++i) {
|
|
2379
|
+
var entry = idx[i];
|
|
2380
|
+
if (entry[1] <= code_point) {
|
|
2381
|
+
offset = entry[1];
|
|
2382
|
+
pointer_offset = entry[0];
|
|
2383
|
+
} else {
|
|
2384
|
+
break;
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
2387
|
+
return pointer_offset + code_point - offset;
|
|
2388
|
+
}
|
|
2389
|
+
function indexShiftJISPointerFor(code_point) {
|
|
2390
|
+
shift_jis_index = shift_jis_index || index("jis0208").map(function(code_point2, pointer) {
|
|
2391
|
+
return inRange(pointer, 8272, 8835) ? null : code_point2;
|
|
2392
|
+
});
|
|
2393
|
+
var index_ = shift_jis_index;
|
|
2394
|
+
return index_.indexOf(code_point);
|
|
2395
|
+
}
|
|
2396
|
+
function indexBig5PointerFor(code_point) {
|
|
2397
|
+
big5_index_no_hkscs = big5_index_no_hkscs || index("big5").map(function(code_point2, pointer) {
|
|
2398
|
+
return pointer < (161 - 129) * 157 ? null : code_point2;
|
|
2399
|
+
});
|
|
2400
|
+
var index_ = big5_index_no_hkscs;
|
|
2401
|
+
if (code_point === 9552 || code_point === 9566 || code_point === 9569 || code_point === 9578 || code_point === 21313 || code_point === 21317) {
|
|
2402
|
+
return index_.lastIndexOf(code_point);
|
|
2403
|
+
}
|
|
2404
|
+
return indexPointerFor(code_point, index_);
|
|
2405
|
+
}
|
|
2406
|
+
function TextDecoder(label, options) {
|
|
2407
|
+
if (!(this instanceof TextDecoder))
|
|
2408
|
+
throw TypeError("Called as a function. Did you forget 'new'?");
|
|
2409
|
+
label = label !== void 0 ? String(label) : DEFAULT_ENCODING;
|
|
2410
|
+
options = ToDictionary(options);
|
|
2411
|
+
this._encoding = null;
|
|
2412
|
+
this._decoder = null;
|
|
2413
|
+
this._ignoreBOM = false;
|
|
2414
|
+
this._BOMseen = false;
|
|
2415
|
+
this._error_mode = "replacement";
|
|
2416
|
+
this._do_not_flush = false;
|
|
2417
|
+
var encoding = getEncoding(label);
|
|
2418
|
+
if (encoding === null || encoding.name === "replacement")
|
|
2419
|
+
throw RangeError("Unknown encoding: " + label);
|
|
2420
|
+
if (!decoders[encoding.name]) {
|
|
2421
|
+
throw Error("Decoder not present. Did you forget to include encoding-indexes.js first?");
|
|
2422
|
+
}
|
|
2423
|
+
var dec = this;
|
|
2424
|
+
dec._encoding = encoding;
|
|
2425
|
+
if (Boolean(options["fatal"]))
|
|
2426
|
+
dec._error_mode = "fatal";
|
|
2427
|
+
if (Boolean(options["ignoreBOM"]))
|
|
2428
|
+
dec._ignoreBOM = true;
|
|
2429
|
+
if (!Object.defineProperty) {
|
|
2430
|
+
this.encoding = dec._encoding.name.toLowerCase();
|
|
2431
|
+
this.fatal = dec._error_mode === "fatal";
|
|
2432
|
+
this.ignoreBOM = dec._ignoreBOM;
|
|
2433
|
+
}
|
|
2434
|
+
return dec;
|
|
2435
|
+
}
|
|
2436
|
+
function TextEncoder(label, options) {
|
|
2437
|
+
if (!(this instanceof TextEncoder))
|
|
2438
|
+
throw TypeError("Called as a function. Did you forget 'new'?");
|
|
2439
|
+
options = ToDictionary(options);
|
|
2440
|
+
this._encoding = null;
|
|
2441
|
+
this._encoder = null;
|
|
2442
|
+
this._do_not_flush = false;
|
|
2443
|
+
this._fatal = Boolean(options["fatal"]) ? "fatal" : "replacement";
|
|
2444
|
+
var enc = this;
|
|
2445
|
+
if (Boolean(options["NONSTANDARD_allowLegacyEncoding"])) {
|
|
2446
|
+
label = label !== void 0 ? String(label) : DEFAULT_ENCODING;
|
|
2447
|
+
var encoding = getEncoding(label);
|
|
2448
|
+
if (encoding === null || encoding.name === "replacement")
|
|
2449
|
+
throw RangeError("Unknown encoding: " + label);
|
|
2450
|
+
if (!encoders[encoding.name]) {
|
|
2451
|
+
throw Error("Encoder not present. Did you forget to include encoding-indexes.js first?");
|
|
2452
|
+
}
|
|
2453
|
+
enc._encoding = encoding;
|
|
2454
|
+
} else {
|
|
2455
|
+
enc._encoding = getEncoding("utf-8");
|
|
2456
|
+
if (label !== void 0 && "console" in global) {
|
|
2457
|
+
console.warn("TextEncoder constructor called with encoding label, which is ignored.");
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2460
|
+
if (!Object.defineProperty)
|
|
2461
|
+
this.encoding = enc._encoding.name.toLowerCase();
|
|
2462
|
+
return enc;
|
|
2463
|
+
}
|
|
2464
|
+
function UTF8Decoder(options) {
|
|
2465
|
+
var fatal = options.fatal;
|
|
2466
|
+
var utf8_code_point = 0, utf8_bytes_seen = 0, utf8_bytes_needed = 0, utf8_lower_boundary = 128, utf8_upper_boundary = 191;
|
|
2467
|
+
this.handler = function(stream, bite) {
|
|
2468
|
+
if (bite === end_of_stream && utf8_bytes_needed !== 0) {
|
|
2469
|
+
utf8_bytes_needed = 0;
|
|
2470
|
+
return decoderError(fatal);
|
|
2471
|
+
}
|
|
2472
|
+
if (bite === end_of_stream)
|
|
2473
|
+
return finished;
|
|
2474
|
+
if (utf8_bytes_needed === 0) {
|
|
2475
|
+
if (inRange(bite, 0, 127)) {
|
|
2476
|
+
return bite;
|
|
2477
|
+
} else if (inRange(bite, 194, 223)) {
|
|
2478
|
+
utf8_bytes_needed = 1;
|
|
2479
|
+
utf8_code_point = bite & 31;
|
|
2480
|
+
} else if (inRange(bite, 224, 239)) {
|
|
2481
|
+
if (bite === 224)
|
|
2482
|
+
utf8_lower_boundary = 160;
|
|
2483
|
+
if (bite === 237)
|
|
2484
|
+
utf8_upper_boundary = 159;
|
|
2485
|
+
utf8_bytes_needed = 2;
|
|
2486
|
+
utf8_code_point = bite & 15;
|
|
2487
|
+
} else if (inRange(bite, 240, 244)) {
|
|
2488
|
+
if (bite === 240)
|
|
2489
|
+
utf8_lower_boundary = 144;
|
|
2490
|
+
if (bite === 244)
|
|
2491
|
+
utf8_upper_boundary = 143;
|
|
2492
|
+
utf8_bytes_needed = 3;
|
|
2493
|
+
utf8_code_point = bite & 7;
|
|
2494
|
+
} else {
|
|
2495
|
+
return decoderError(fatal);
|
|
2496
|
+
}
|
|
2497
|
+
return null;
|
|
2498
|
+
}
|
|
2499
|
+
if (!inRange(bite, utf8_lower_boundary, utf8_upper_boundary)) {
|
|
2500
|
+
utf8_code_point = utf8_bytes_needed = utf8_bytes_seen = 0;
|
|
2501
|
+
utf8_lower_boundary = 128;
|
|
2502
|
+
utf8_upper_boundary = 191;
|
|
2503
|
+
stream.prepend(bite);
|
|
2504
|
+
return decoderError(fatal);
|
|
2505
|
+
}
|
|
2506
|
+
utf8_lower_boundary = 128;
|
|
2507
|
+
utf8_upper_boundary = 191;
|
|
2508
|
+
utf8_code_point = utf8_code_point << 6 | bite & 63;
|
|
2509
|
+
utf8_bytes_seen += 1;
|
|
2510
|
+
if (utf8_bytes_seen !== utf8_bytes_needed)
|
|
2511
|
+
return null;
|
|
2512
|
+
var code_point = utf8_code_point;
|
|
2513
|
+
utf8_code_point = utf8_bytes_needed = utf8_bytes_seen = 0;
|
|
2514
|
+
return code_point;
|
|
2515
|
+
};
|
|
2516
|
+
}
|
|
2517
|
+
function UTF8Encoder(options) {
|
|
2518
|
+
var fatal = options.fatal;
|
|
2519
|
+
this.handler = function(stream, code_point) {
|
|
2520
|
+
if (code_point === end_of_stream)
|
|
2521
|
+
return finished;
|
|
2522
|
+
if (isASCIICodePoint(code_point))
|
|
2523
|
+
return code_point;
|
|
2524
|
+
var count, offset;
|
|
2525
|
+
if (inRange(code_point, 128, 2047)) {
|
|
2526
|
+
count = 1;
|
|
2527
|
+
offset = 192;
|
|
2528
|
+
} else if (inRange(code_point, 2048, 65535)) {
|
|
2529
|
+
count = 2;
|
|
2530
|
+
offset = 224;
|
|
2531
|
+
} else if (inRange(code_point, 65536, 1114111)) {
|
|
2532
|
+
count = 3;
|
|
2533
|
+
offset = 240;
|
|
2534
|
+
}
|
|
2535
|
+
var bytes = [(code_point >> 6 * count) + offset];
|
|
2536
|
+
while (count > 0) {
|
|
2537
|
+
var temp = code_point >> 6 * (count - 1);
|
|
2538
|
+
bytes.push(128 | temp & 63);
|
|
2539
|
+
count -= 1;
|
|
2540
|
+
}
|
|
2541
|
+
return bytes;
|
|
2542
|
+
};
|
|
2543
|
+
}
|
|
2544
|
+
function SingleByteDecoder(index2, options) {
|
|
2545
|
+
var fatal = options.fatal;
|
|
2546
|
+
this.handler = function(stream, bite) {
|
|
2547
|
+
if (bite === end_of_stream)
|
|
2548
|
+
return finished;
|
|
2549
|
+
if (isASCIIByte(bite))
|
|
2550
|
+
return bite;
|
|
2551
|
+
var code_point = index2[bite - 128];
|
|
2552
|
+
if (code_point === null)
|
|
2553
|
+
return decoderError(fatal);
|
|
2554
|
+
return code_point;
|
|
2555
|
+
};
|
|
2556
|
+
}
|
|
2557
|
+
function SingleByteEncoder(index2, options) {
|
|
2558
|
+
var fatal = options.fatal;
|
|
2559
|
+
this.handler = function(stream, code_point) {
|
|
2560
|
+
if (code_point === end_of_stream)
|
|
2561
|
+
return finished;
|
|
2562
|
+
if (isASCIICodePoint(code_point))
|
|
2563
|
+
return code_point;
|
|
2564
|
+
var pointer = indexPointerFor(code_point, index2);
|
|
2565
|
+
if (pointer === null)
|
|
2566
|
+
encoderError(code_point);
|
|
2567
|
+
return pointer + 128;
|
|
2568
|
+
};
|
|
2569
|
+
}
|
|
2570
|
+
function GB18030Decoder(options) {
|
|
2571
|
+
var fatal = options.fatal;
|
|
2572
|
+
var gb18030_first = 0, gb18030_second = 0, gb18030_third = 0;
|
|
2573
|
+
this.handler = function(stream, bite) {
|
|
2574
|
+
if (bite === end_of_stream && gb18030_first === 0 && gb18030_second === 0 && gb18030_third === 0) {
|
|
2575
|
+
return finished;
|
|
2576
|
+
}
|
|
2577
|
+
if (bite === end_of_stream && (gb18030_first !== 0 || gb18030_second !== 0 || gb18030_third !== 0)) {
|
|
2578
|
+
gb18030_first = 0;
|
|
2579
|
+
gb18030_second = 0;
|
|
2580
|
+
gb18030_third = 0;
|
|
2581
|
+
decoderError(fatal);
|
|
2582
|
+
}
|
|
2583
|
+
var code_point;
|
|
2584
|
+
if (gb18030_third !== 0) {
|
|
2585
|
+
code_point = null;
|
|
2586
|
+
if (inRange(bite, 48, 57)) {
|
|
2587
|
+
code_point = indexGB18030RangesCodePointFor((((gb18030_first - 129) * 10 + gb18030_second - 48) * 126 + gb18030_third - 129) * 10 + bite - 48);
|
|
2588
|
+
}
|
|
2589
|
+
var buffer = [gb18030_second, gb18030_third, bite];
|
|
2590
|
+
gb18030_first = 0;
|
|
2591
|
+
gb18030_second = 0;
|
|
2592
|
+
gb18030_third = 0;
|
|
2593
|
+
if (code_point === null) {
|
|
2594
|
+
stream.prepend(buffer);
|
|
2595
|
+
return decoderError(fatal);
|
|
2596
|
+
}
|
|
2597
|
+
return code_point;
|
|
2598
|
+
}
|
|
2599
|
+
if (gb18030_second !== 0) {
|
|
2600
|
+
if (inRange(bite, 129, 254)) {
|
|
2601
|
+
gb18030_third = bite;
|
|
2602
|
+
return null;
|
|
2603
|
+
}
|
|
2604
|
+
stream.prepend([gb18030_second, bite]);
|
|
2605
|
+
gb18030_first = 0;
|
|
2606
|
+
gb18030_second = 0;
|
|
2607
|
+
return decoderError(fatal);
|
|
2608
|
+
}
|
|
2609
|
+
if (gb18030_first !== 0) {
|
|
2610
|
+
if (inRange(bite, 48, 57)) {
|
|
2611
|
+
gb18030_second = bite;
|
|
2612
|
+
return null;
|
|
2613
|
+
}
|
|
2614
|
+
var lead = gb18030_first;
|
|
2615
|
+
var pointer = null;
|
|
2616
|
+
gb18030_first = 0;
|
|
2617
|
+
var offset = bite < 127 ? 64 : 65;
|
|
2618
|
+
if (inRange(bite, 64, 126) || inRange(bite, 128, 254))
|
|
2619
|
+
pointer = (lead - 129) * 190 + (bite - offset);
|
|
2620
|
+
code_point = pointer === null ? null : indexCodePointFor(pointer, index("gb18030"));
|
|
2621
|
+
if (code_point === null && isASCIIByte(bite))
|
|
2622
|
+
stream.prepend(bite);
|
|
2623
|
+
if (code_point === null)
|
|
2624
|
+
return decoderError(fatal);
|
|
2625
|
+
return code_point;
|
|
2626
|
+
}
|
|
2627
|
+
if (isASCIIByte(bite))
|
|
2628
|
+
return bite;
|
|
2629
|
+
if (bite === 128)
|
|
2630
|
+
return 8364;
|
|
2631
|
+
if (inRange(bite, 129, 254)) {
|
|
2632
|
+
gb18030_first = bite;
|
|
2633
|
+
return null;
|
|
2634
|
+
}
|
|
2635
|
+
return decoderError(fatal);
|
|
2636
|
+
};
|
|
2637
|
+
}
|
|
2638
|
+
function GB18030Encoder(options, gbk_flag) {
|
|
2639
|
+
var fatal = options.fatal;
|
|
2640
|
+
this.handler = function(stream, code_point) {
|
|
2641
|
+
if (code_point === end_of_stream)
|
|
2642
|
+
return finished;
|
|
2643
|
+
if (isASCIICodePoint(code_point))
|
|
2644
|
+
return code_point;
|
|
2645
|
+
if (code_point === 58853)
|
|
2646
|
+
return encoderError(code_point);
|
|
2647
|
+
if (gbk_flag && code_point === 8364)
|
|
2648
|
+
return 128;
|
|
2649
|
+
var pointer = indexPointerFor(code_point, index("gb18030"));
|
|
2650
|
+
if (pointer !== null) {
|
|
2651
|
+
var lead = floor(pointer / 190) + 129;
|
|
2652
|
+
var trail = pointer % 190;
|
|
2653
|
+
var offset = trail < 63 ? 64 : 65;
|
|
2654
|
+
return [lead, trail + offset];
|
|
2655
|
+
}
|
|
2656
|
+
if (gbk_flag)
|
|
2657
|
+
return encoderError(code_point);
|
|
2658
|
+
pointer = indexGB18030RangesPointerFor(code_point);
|
|
2659
|
+
var byte1 = floor(pointer / 10 / 126 / 10);
|
|
2660
|
+
pointer = pointer - byte1 * 10 * 126 * 10;
|
|
2661
|
+
var byte2 = floor(pointer / 10 / 126);
|
|
2662
|
+
pointer = pointer - byte2 * 10 * 126;
|
|
2663
|
+
var byte3 = floor(pointer / 10);
|
|
2664
|
+
var byte4 = pointer - byte3 * 10;
|
|
2665
|
+
return [byte1 + 129, byte2 + 48, byte3 + 129, byte4 + 48];
|
|
2666
|
+
};
|
|
2667
|
+
}
|
|
2668
|
+
function Big5Decoder(options) {
|
|
2669
|
+
var fatal = options.fatal;
|
|
2670
|
+
var Big5_lead = 0;
|
|
2671
|
+
this.handler = function(stream, bite) {
|
|
2672
|
+
if (bite === end_of_stream && Big5_lead !== 0) {
|
|
2673
|
+
Big5_lead = 0;
|
|
2674
|
+
return decoderError(fatal);
|
|
2675
|
+
}
|
|
2676
|
+
if (bite === end_of_stream && Big5_lead === 0)
|
|
2677
|
+
return finished;
|
|
2678
|
+
if (Big5_lead !== 0) {
|
|
2679
|
+
var lead = Big5_lead;
|
|
2680
|
+
var pointer = null;
|
|
2681
|
+
Big5_lead = 0;
|
|
2682
|
+
var offset = bite < 127 ? 64 : 98;
|
|
2683
|
+
if (inRange(bite, 64, 126) || inRange(bite, 161, 254))
|
|
2684
|
+
pointer = (lead - 129) * 157 + (bite - offset);
|
|
2685
|
+
switch (pointer) {
|
|
2686
|
+
case 1133:
|
|
2687
|
+
return [202, 772];
|
|
2688
|
+
case 1135:
|
|
2689
|
+
return [202, 780];
|
|
2690
|
+
case 1164:
|
|
2691
|
+
return [234, 772];
|
|
2692
|
+
case 1166:
|
|
2693
|
+
return [234, 780];
|
|
2694
|
+
}
|
|
2695
|
+
var code_point = pointer === null ? null : indexCodePointFor(pointer, index("big5"));
|
|
2696
|
+
if (code_point === null && isASCIIByte(bite))
|
|
2697
|
+
stream.prepend(bite);
|
|
2698
|
+
if (code_point === null)
|
|
2699
|
+
return decoderError(fatal);
|
|
2700
|
+
return code_point;
|
|
2701
|
+
}
|
|
2702
|
+
if (isASCIIByte(bite))
|
|
2703
|
+
return bite;
|
|
2704
|
+
if (inRange(bite, 129, 254)) {
|
|
2705
|
+
Big5_lead = bite;
|
|
2706
|
+
return null;
|
|
2707
|
+
}
|
|
2708
|
+
return decoderError(fatal);
|
|
2709
|
+
};
|
|
2710
|
+
}
|
|
2711
|
+
function Big5Encoder(options) {
|
|
2712
|
+
var fatal = options.fatal;
|
|
2713
|
+
this.handler = function(stream, code_point) {
|
|
2714
|
+
if (code_point === end_of_stream)
|
|
2715
|
+
return finished;
|
|
2716
|
+
if (isASCIICodePoint(code_point))
|
|
2717
|
+
return code_point;
|
|
2718
|
+
var pointer = indexBig5PointerFor(code_point);
|
|
2719
|
+
if (pointer === null)
|
|
2720
|
+
return encoderError(code_point);
|
|
2721
|
+
var lead = floor(pointer / 157) + 129;
|
|
2722
|
+
if (lead < 161)
|
|
2723
|
+
return encoderError(code_point);
|
|
2724
|
+
var trail = pointer % 157;
|
|
2725
|
+
var offset = trail < 63 ? 64 : 98;
|
|
2726
|
+
return [lead, trail + offset];
|
|
2727
|
+
};
|
|
2728
|
+
}
|
|
2729
|
+
function EUCJPDecoder(options) {
|
|
2730
|
+
var fatal = options.fatal;
|
|
2731
|
+
var eucjp_jis0212_flag = false, eucjp_lead = 0;
|
|
2732
|
+
this.handler = function(stream, bite) {
|
|
2733
|
+
if (bite === end_of_stream && eucjp_lead !== 0) {
|
|
2734
|
+
eucjp_lead = 0;
|
|
2735
|
+
return decoderError(fatal);
|
|
2736
|
+
}
|
|
2737
|
+
if (bite === end_of_stream && eucjp_lead === 0)
|
|
2738
|
+
return finished;
|
|
2739
|
+
if (eucjp_lead === 142 && inRange(bite, 161, 223)) {
|
|
2740
|
+
eucjp_lead = 0;
|
|
2741
|
+
return 65377 - 161 + bite;
|
|
2742
|
+
}
|
|
2743
|
+
if (eucjp_lead === 143 && inRange(bite, 161, 254)) {
|
|
2744
|
+
eucjp_jis0212_flag = true;
|
|
2745
|
+
eucjp_lead = bite;
|
|
2746
|
+
return null;
|
|
2747
|
+
}
|
|
2748
|
+
if (eucjp_lead !== 0) {
|
|
2749
|
+
var lead = eucjp_lead;
|
|
2750
|
+
eucjp_lead = 0;
|
|
2751
|
+
var code_point = null;
|
|
2752
|
+
if (inRange(lead, 161, 254) && inRange(bite, 161, 254)) {
|
|
2753
|
+
code_point = indexCodePointFor((lead - 161) * 94 + (bite - 161), index(!eucjp_jis0212_flag ? "jis0208" : "jis0212"));
|
|
2754
|
+
}
|
|
2755
|
+
eucjp_jis0212_flag = false;
|
|
2756
|
+
if (!inRange(bite, 161, 254))
|
|
2757
|
+
stream.prepend(bite);
|
|
2758
|
+
if (code_point === null)
|
|
2759
|
+
return decoderError(fatal);
|
|
2760
|
+
return code_point;
|
|
2761
|
+
}
|
|
2762
|
+
if (isASCIIByte(bite))
|
|
2763
|
+
return bite;
|
|
2764
|
+
if (bite === 142 || bite === 143 || inRange(bite, 161, 254)) {
|
|
2765
|
+
eucjp_lead = bite;
|
|
2766
|
+
return null;
|
|
2767
|
+
}
|
|
2768
|
+
return decoderError(fatal);
|
|
2769
|
+
};
|
|
2770
|
+
}
|
|
2771
|
+
function EUCJPEncoder(options) {
|
|
2772
|
+
var fatal = options.fatal;
|
|
2773
|
+
this.handler = function(stream, code_point) {
|
|
2774
|
+
if (code_point === end_of_stream)
|
|
2775
|
+
return finished;
|
|
2776
|
+
if (isASCIICodePoint(code_point))
|
|
2777
|
+
return code_point;
|
|
2778
|
+
if (code_point === 165)
|
|
2779
|
+
return 92;
|
|
2780
|
+
if (code_point === 8254)
|
|
2781
|
+
return 126;
|
|
2782
|
+
if (inRange(code_point, 65377, 65439))
|
|
2783
|
+
return [142, code_point - 65377 + 161];
|
|
2784
|
+
if (code_point === 8722)
|
|
2785
|
+
code_point = 65293;
|
|
2786
|
+
var pointer = indexPointerFor(code_point, index("jis0208"));
|
|
2787
|
+
if (pointer === null)
|
|
2788
|
+
return encoderError(code_point);
|
|
2789
|
+
var lead = floor(pointer / 94) + 161;
|
|
2790
|
+
var trail = pointer % 94 + 161;
|
|
2791
|
+
return [lead, trail];
|
|
2792
|
+
};
|
|
2793
|
+
}
|
|
2794
|
+
function ISO2022JPDecoder(options) {
|
|
2795
|
+
var fatal = options.fatal;
|
|
2796
|
+
var states = {
|
|
2797
|
+
ASCII: 0,
|
|
2798
|
+
Roman: 1,
|
|
2799
|
+
Katakana: 2,
|
|
2800
|
+
LeadByte: 3,
|
|
2801
|
+
TrailByte: 4,
|
|
2802
|
+
EscapeStart: 5,
|
|
2803
|
+
Escape: 6
|
|
2804
|
+
};
|
|
2805
|
+
var iso2022jp_decoder_state = states.ASCII, iso2022jp_decoder_output_state = states.ASCII, iso2022jp_lead = 0, iso2022jp_output_flag = false;
|
|
2806
|
+
this.handler = function(stream, bite) {
|
|
2807
|
+
switch (iso2022jp_decoder_state) {
|
|
2808
|
+
default:
|
|
2809
|
+
case states.ASCII:
|
|
2810
|
+
if (bite === 27) {
|
|
2811
|
+
iso2022jp_decoder_state = states.EscapeStart;
|
|
2812
|
+
return null;
|
|
2813
|
+
}
|
|
2814
|
+
if (inRange(bite, 0, 127) && bite !== 14 && bite !== 15 && bite !== 27) {
|
|
2815
|
+
iso2022jp_output_flag = false;
|
|
2816
|
+
return bite;
|
|
2817
|
+
}
|
|
2818
|
+
if (bite === end_of_stream) {
|
|
2819
|
+
return finished;
|
|
2820
|
+
}
|
|
2821
|
+
iso2022jp_output_flag = false;
|
|
2822
|
+
return decoderError(fatal);
|
|
2823
|
+
case states.Roman:
|
|
2824
|
+
if (bite === 27) {
|
|
2825
|
+
iso2022jp_decoder_state = states.EscapeStart;
|
|
2826
|
+
return null;
|
|
2827
|
+
}
|
|
2828
|
+
if (bite === 92) {
|
|
2829
|
+
iso2022jp_output_flag = false;
|
|
2830
|
+
return 165;
|
|
2831
|
+
}
|
|
2832
|
+
if (bite === 126) {
|
|
2833
|
+
iso2022jp_output_flag = false;
|
|
2834
|
+
return 8254;
|
|
2835
|
+
}
|
|
2836
|
+
if (inRange(bite, 0, 127) && bite !== 14 && bite !== 15 && bite !== 27 && bite !== 92 && bite !== 126) {
|
|
2837
|
+
iso2022jp_output_flag = false;
|
|
2838
|
+
return bite;
|
|
2839
|
+
}
|
|
2840
|
+
if (bite === end_of_stream) {
|
|
2841
|
+
return finished;
|
|
2842
|
+
}
|
|
2843
|
+
iso2022jp_output_flag = false;
|
|
2844
|
+
return decoderError(fatal);
|
|
2845
|
+
case states.Katakana:
|
|
2846
|
+
if (bite === 27) {
|
|
2847
|
+
iso2022jp_decoder_state = states.EscapeStart;
|
|
2848
|
+
return null;
|
|
2849
|
+
}
|
|
2850
|
+
if (inRange(bite, 33, 95)) {
|
|
2851
|
+
iso2022jp_output_flag = false;
|
|
2852
|
+
return 65377 - 33 + bite;
|
|
2853
|
+
}
|
|
2854
|
+
if (bite === end_of_stream) {
|
|
2855
|
+
return finished;
|
|
2856
|
+
}
|
|
2857
|
+
iso2022jp_output_flag = false;
|
|
2858
|
+
return decoderError(fatal);
|
|
2859
|
+
case states.LeadByte:
|
|
2860
|
+
if (bite === 27) {
|
|
2861
|
+
iso2022jp_decoder_state = states.EscapeStart;
|
|
2862
|
+
return null;
|
|
2863
|
+
}
|
|
2864
|
+
if (inRange(bite, 33, 126)) {
|
|
2865
|
+
iso2022jp_output_flag = false;
|
|
2866
|
+
iso2022jp_lead = bite;
|
|
2867
|
+
iso2022jp_decoder_state = states.TrailByte;
|
|
2868
|
+
return null;
|
|
2869
|
+
}
|
|
2870
|
+
if (bite === end_of_stream) {
|
|
2871
|
+
return finished;
|
|
2872
|
+
}
|
|
2873
|
+
iso2022jp_output_flag = false;
|
|
2874
|
+
return decoderError(fatal);
|
|
2875
|
+
case states.TrailByte:
|
|
2876
|
+
if (bite === 27) {
|
|
2877
|
+
iso2022jp_decoder_state = states.EscapeStart;
|
|
2878
|
+
return decoderError(fatal);
|
|
2879
|
+
}
|
|
2880
|
+
if (inRange(bite, 33, 126)) {
|
|
2881
|
+
iso2022jp_decoder_state = states.LeadByte;
|
|
2882
|
+
var pointer = (iso2022jp_lead - 33) * 94 + bite - 33;
|
|
2883
|
+
var code_point = indexCodePointFor(pointer, index("jis0208"));
|
|
2884
|
+
if (code_point === null)
|
|
2885
|
+
return decoderError(fatal);
|
|
2886
|
+
return code_point;
|
|
2887
|
+
}
|
|
2888
|
+
if (bite === end_of_stream) {
|
|
2889
|
+
iso2022jp_decoder_state = states.LeadByte;
|
|
2890
|
+
stream.prepend(bite);
|
|
2891
|
+
return decoderError(fatal);
|
|
2892
|
+
}
|
|
2893
|
+
iso2022jp_decoder_state = states.LeadByte;
|
|
2894
|
+
return decoderError(fatal);
|
|
2895
|
+
case states.EscapeStart:
|
|
2896
|
+
if (bite === 36 || bite === 40) {
|
|
2897
|
+
iso2022jp_lead = bite;
|
|
2898
|
+
iso2022jp_decoder_state = states.Escape;
|
|
2899
|
+
return null;
|
|
2900
|
+
}
|
|
2901
|
+
stream.prepend(bite);
|
|
2902
|
+
iso2022jp_output_flag = false;
|
|
2903
|
+
iso2022jp_decoder_state = iso2022jp_decoder_output_state;
|
|
2904
|
+
return decoderError(fatal);
|
|
2905
|
+
case states.Escape:
|
|
2906
|
+
var lead = iso2022jp_lead;
|
|
2907
|
+
iso2022jp_lead = 0;
|
|
2908
|
+
var state = null;
|
|
2909
|
+
if (lead === 40 && bite === 66)
|
|
2910
|
+
state = states.ASCII;
|
|
2911
|
+
if (lead === 40 && bite === 74)
|
|
2912
|
+
state = states.Roman;
|
|
2913
|
+
if (lead === 40 && bite === 73)
|
|
2914
|
+
state = states.Katakana;
|
|
2915
|
+
if (lead === 36 && (bite === 64 || bite === 66))
|
|
2916
|
+
state = states.LeadByte;
|
|
2917
|
+
if (state !== null) {
|
|
2918
|
+
iso2022jp_decoder_state = iso2022jp_decoder_state = state;
|
|
2919
|
+
var output_flag = iso2022jp_output_flag;
|
|
2920
|
+
iso2022jp_output_flag = true;
|
|
2921
|
+
return !output_flag ? null : decoderError(fatal);
|
|
2922
|
+
}
|
|
2923
|
+
stream.prepend([lead, bite]);
|
|
2924
|
+
iso2022jp_output_flag = false;
|
|
2925
|
+
iso2022jp_decoder_state = iso2022jp_decoder_output_state;
|
|
2926
|
+
return decoderError(fatal);
|
|
2927
|
+
}
|
|
2928
|
+
};
|
|
2929
|
+
}
|
|
2930
|
+
function ISO2022JPEncoder(options) {
|
|
2931
|
+
var fatal = options.fatal;
|
|
2932
|
+
var states = {
|
|
2933
|
+
ASCII: 0,
|
|
2934
|
+
Roman: 1,
|
|
2935
|
+
jis0208: 2
|
|
2936
|
+
};
|
|
2937
|
+
var iso2022jp_state = states.ASCII;
|
|
2938
|
+
this.handler = function(stream, code_point) {
|
|
2939
|
+
if (code_point === end_of_stream && iso2022jp_state !== states.ASCII) {
|
|
2940
|
+
stream.prepend(code_point);
|
|
2941
|
+
iso2022jp_state = states.ASCII;
|
|
2942
|
+
return [27, 40, 66];
|
|
2943
|
+
}
|
|
2944
|
+
if (code_point === end_of_stream && iso2022jp_state === states.ASCII)
|
|
2945
|
+
return finished;
|
|
2946
|
+
if ((iso2022jp_state === states.ASCII || iso2022jp_state === states.Roman) && (code_point === 14 || code_point === 15 || code_point === 27)) {
|
|
2947
|
+
return encoderError(65533);
|
|
2948
|
+
}
|
|
2949
|
+
if (iso2022jp_state === states.ASCII && isASCIICodePoint(code_point))
|
|
2950
|
+
return code_point;
|
|
2951
|
+
if (iso2022jp_state === states.Roman && (isASCIICodePoint(code_point) && code_point !== 92 && code_point !== 126 || code_point == 165 || code_point == 8254)) {
|
|
2952
|
+
if (isASCIICodePoint(code_point))
|
|
2953
|
+
return code_point;
|
|
2954
|
+
if (code_point === 165)
|
|
2955
|
+
return 92;
|
|
2956
|
+
if (code_point === 8254)
|
|
2957
|
+
return 126;
|
|
2958
|
+
}
|
|
2959
|
+
if (isASCIICodePoint(code_point) && iso2022jp_state !== states.ASCII) {
|
|
2960
|
+
stream.prepend(code_point);
|
|
2961
|
+
iso2022jp_state = states.ASCII;
|
|
2962
|
+
return [27, 40, 66];
|
|
2963
|
+
}
|
|
2964
|
+
if ((code_point === 165 || code_point === 8254) && iso2022jp_state !== states.Roman) {
|
|
2965
|
+
stream.prepend(code_point);
|
|
2966
|
+
iso2022jp_state = states.Roman;
|
|
2967
|
+
return [27, 40, 74];
|
|
2968
|
+
}
|
|
2969
|
+
if (code_point === 8722)
|
|
2970
|
+
code_point = 65293;
|
|
2971
|
+
var pointer = indexPointerFor(code_point, index("jis0208"));
|
|
2972
|
+
if (pointer === null)
|
|
2973
|
+
return encoderError(code_point);
|
|
2974
|
+
if (iso2022jp_state !== states.jis0208) {
|
|
2975
|
+
stream.prepend(code_point);
|
|
2976
|
+
iso2022jp_state = states.jis0208;
|
|
2977
|
+
return [27, 36, 66];
|
|
2978
|
+
}
|
|
2979
|
+
var lead = floor(pointer / 94) + 33;
|
|
2980
|
+
var trail = pointer % 94 + 33;
|
|
2981
|
+
return [lead, trail];
|
|
2982
|
+
};
|
|
2983
|
+
}
|
|
2984
|
+
function ShiftJISDecoder(options) {
|
|
2985
|
+
var fatal = options.fatal;
|
|
2986
|
+
var Shift_JIS_lead = 0;
|
|
2987
|
+
this.handler = function(stream, bite) {
|
|
2988
|
+
if (bite === end_of_stream && Shift_JIS_lead !== 0) {
|
|
2989
|
+
Shift_JIS_lead = 0;
|
|
2990
|
+
return decoderError(fatal);
|
|
2991
|
+
}
|
|
2992
|
+
if (bite === end_of_stream && Shift_JIS_lead === 0)
|
|
2993
|
+
return finished;
|
|
2994
|
+
if (Shift_JIS_lead !== 0) {
|
|
2995
|
+
var lead = Shift_JIS_lead;
|
|
2996
|
+
var pointer = null;
|
|
2997
|
+
Shift_JIS_lead = 0;
|
|
2998
|
+
var offset = bite < 127 ? 64 : 65;
|
|
2999
|
+
var lead_offset = lead < 160 ? 129 : 193;
|
|
3000
|
+
if (inRange(bite, 64, 126) || inRange(bite, 128, 252))
|
|
3001
|
+
pointer = (lead - lead_offset) * 188 + bite - offset;
|
|
3002
|
+
if (inRange(pointer, 8836, 10715))
|
|
3003
|
+
return 57344 - 8836 + pointer;
|
|
3004
|
+
var code_point = pointer === null ? null : indexCodePointFor(pointer, index("jis0208"));
|
|
3005
|
+
if (code_point === null && isASCIIByte(bite))
|
|
3006
|
+
stream.prepend(bite);
|
|
3007
|
+
if (code_point === null)
|
|
3008
|
+
return decoderError(fatal);
|
|
3009
|
+
return code_point;
|
|
3010
|
+
}
|
|
3011
|
+
if (isASCIIByte(bite) || bite === 128)
|
|
3012
|
+
return bite;
|
|
3013
|
+
if (inRange(bite, 161, 223))
|
|
3014
|
+
return 65377 - 161 + bite;
|
|
3015
|
+
if (inRange(bite, 129, 159) || inRange(bite, 224, 252)) {
|
|
3016
|
+
Shift_JIS_lead = bite;
|
|
3017
|
+
return null;
|
|
3018
|
+
}
|
|
3019
|
+
return decoderError(fatal);
|
|
3020
|
+
};
|
|
3021
|
+
}
|
|
3022
|
+
function ShiftJISEncoder(options) {
|
|
3023
|
+
var fatal = options.fatal;
|
|
3024
|
+
this.handler = function(stream, code_point) {
|
|
3025
|
+
if (code_point === end_of_stream)
|
|
3026
|
+
return finished;
|
|
3027
|
+
if (isASCIICodePoint(code_point) || code_point === 128)
|
|
3028
|
+
return code_point;
|
|
3029
|
+
if (code_point === 165)
|
|
3030
|
+
return 92;
|
|
3031
|
+
if (code_point === 8254)
|
|
3032
|
+
return 126;
|
|
3033
|
+
if (inRange(code_point, 65377, 65439))
|
|
3034
|
+
return code_point - 65377 + 161;
|
|
3035
|
+
if (code_point === 8722)
|
|
3036
|
+
code_point = 65293;
|
|
3037
|
+
var pointer = indexShiftJISPointerFor(code_point);
|
|
3038
|
+
if (pointer === null)
|
|
3039
|
+
return encoderError(code_point);
|
|
3040
|
+
var lead = floor(pointer / 188);
|
|
3041
|
+
var lead_offset = lead < 31 ? 129 : 193;
|
|
3042
|
+
var trail = pointer % 188;
|
|
3043
|
+
var offset = trail < 63 ? 64 : 65;
|
|
3044
|
+
return [lead + lead_offset, trail + offset];
|
|
3045
|
+
};
|
|
3046
|
+
}
|
|
3047
|
+
function EUCKRDecoder(options) {
|
|
3048
|
+
var fatal = options.fatal;
|
|
3049
|
+
var euckr_lead = 0;
|
|
3050
|
+
this.handler = function(stream, bite) {
|
|
3051
|
+
if (bite === end_of_stream && euckr_lead !== 0) {
|
|
3052
|
+
euckr_lead = 0;
|
|
3053
|
+
return decoderError(fatal);
|
|
3054
|
+
}
|
|
3055
|
+
if (bite === end_of_stream && euckr_lead === 0)
|
|
3056
|
+
return finished;
|
|
3057
|
+
if (euckr_lead !== 0) {
|
|
3058
|
+
var lead = euckr_lead;
|
|
3059
|
+
var pointer = null;
|
|
3060
|
+
euckr_lead = 0;
|
|
3061
|
+
if (inRange(bite, 65, 254))
|
|
3062
|
+
pointer = (lead - 129) * 190 + (bite - 65);
|
|
3063
|
+
var code_point = pointer === null ? null : indexCodePointFor(pointer, index("euc-kr"));
|
|
3064
|
+
if (pointer === null && isASCIIByte(bite))
|
|
3065
|
+
stream.prepend(bite);
|
|
3066
|
+
if (code_point === null)
|
|
3067
|
+
return decoderError(fatal);
|
|
3068
|
+
return code_point;
|
|
3069
|
+
}
|
|
3070
|
+
if (isASCIIByte(bite))
|
|
3071
|
+
return bite;
|
|
3072
|
+
if (inRange(bite, 129, 254)) {
|
|
3073
|
+
euckr_lead = bite;
|
|
3074
|
+
return null;
|
|
3075
|
+
}
|
|
3076
|
+
return decoderError(fatal);
|
|
3077
|
+
};
|
|
3078
|
+
}
|
|
3079
|
+
function EUCKREncoder(options) {
|
|
3080
|
+
var fatal = options.fatal;
|
|
3081
|
+
this.handler = function(stream, code_point) {
|
|
3082
|
+
if (code_point === end_of_stream)
|
|
3083
|
+
return finished;
|
|
3084
|
+
if (isASCIICodePoint(code_point))
|
|
3085
|
+
return code_point;
|
|
3086
|
+
var pointer = indexPointerFor(code_point, index("euc-kr"));
|
|
3087
|
+
if (pointer === null)
|
|
3088
|
+
return encoderError(code_point);
|
|
3089
|
+
var lead = floor(pointer / 190) + 129;
|
|
3090
|
+
var trail = pointer % 190 + 65;
|
|
3091
|
+
return [lead, trail];
|
|
3092
|
+
};
|
|
3093
|
+
}
|
|
3094
|
+
function convertCodeUnitToBytes(code_unit, utf16be) {
|
|
3095
|
+
var byte1 = code_unit >> 8;
|
|
3096
|
+
var byte2 = code_unit & 255;
|
|
3097
|
+
if (utf16be)
|
|
3098
|
+
return [byte1, byte2];
|
|
3099
|
+
return [byte2, byte1];
|
|
3100
|
+
}
|
|
3101
|
+
function UTF16Decoder(utf16_be, options) {
|
|
3102
|
+
var fatal = options.fatal;
|
|
3103
|
+
var utf16_lead_byte = null, utf16_lead_surrogate = null;
|
|
3104
|
+
this.handler = function(stream, bite) {
|
|
3105
|
+
if (bite === end_of_stream && (utf16_lead_byte !== null || utf16_lead_surrogate !== null)) {
|
|
3106
|
+
return decoderError(fatal);
|
|
3107
|
+
}
|
|
3108
|
+
if (bite === end_of_stream && utf16_lead_byte === null && utf16_lead_surrogate === null) {
|
|
3109
|
+
return finished;
|
|
3110
|
+
}
|
|
3111
|
+
if (utf16_lead_byte === null) {
|
|
3112
|
+
utf16_lead_byte = bite;
|
|
3113
|
+
return null;
|
|
3114
|
+
}
|
|
3115
|
+
var code_unit;
|
|
3116
|
+
if (utf16_be) {
|
|
3117
|
+
code_unit = (utf16_lead_byte << 8) + bite;
|
|
3118
|
+
} else {
|
|
3119
|
+
code_unit = (bite << 8) + utf16_lead_byte;
|
|
3120
|
+
}
|
|
3121
|
+
utf16_lead_byte = null;
|
|
3122
|
+
if (utf16_lead_surrogate !== null) {
|
|
3123
|
+
var lead_surrogate = utf16_lead_surrogate;
|
|
3124
|
+
utf16_lead_surrogate = null;
|
|
3125
|
+
if (inRange(code_unit, 56320, 57343)) {
|
|
3126
|
+
return 65536 + (lead_surrogate - 55296) * 1024 + (code_unit - 56320);
|
|
3127
|
+
}
|
|
3128
|
+
stream.prepend(convertCodeUnitToBytes(code_unit, utf16_be));
|
|
3129
|
+
return decoderError(fatal);
|
|
3130
|
+
}
|
|
3131
|
+
if (inRange(code_unit, 55296, 56319)) {
|
|
3132
|
+
utf16_lead_surrogate = code_unit;
|
|
3133
|
+
return null;
|
|
3134
|
+
}
|
|
3135
|
+
if (inRange(code_unit, 56320, 57343))
|
|
3136
|
+
return decoderError(fatal);
|
|
3137
|
+
return code_unit;
|
|
3138
|
+
};
|
|
3139
|
+
}
|
|
3140
|
+
function UTF16Encoder(utf16_be, options) {
|
|
3141
|
+
var fatal = options.fatal;
|
|
3142
|
+
this.handler = function(stream, code_point) {
|
|
3143
|
+
if (code_point === end_of_stream)
|
|
3144
|
+
return finished;
|
|
3145
|
+
if (inRange(code_point, 0, 65535))
|
|
3146
|
+
return convertCodeUnitToBytes(code_point, utf16_be);
|
|
3147
|
+
var lead = convertCodeUnitToBytes((code_point - 65536 >> 10) + 55296, utf16_be);
|
|
3148
|
+
var trail = convertCodeUnitToBytes((code_point - 65536 & 1023) + 56320, utf16_be);
|
|
3149
|
+
return lead.concat(trail);
|
|
3150
|
+
};
|
|
3151
|
+
}
|
|
3152
|
+
function XUserDefinedDecoder(options) {
|
|
3153
|
+
var fatal = options.fatal;
|
|
3154
|
+
this.handler = function(stream, bite) {
|
|
3155
|
+
if (bite === end_of_stream)
|
|
3156
|
+
return finished;
|
|
3157
|
+
if (isASCIIByte(bite))
|
|
3158
|
+
return bite;
|
|
3159
|
+
return 63360 + bite - 128;
|
|
3160
|
+
};
|
|
3161
|
+
}
|
|
3162
|
+
function XUserDefinedEncoder(options) {
|
|
3163
|
+
var fatal = options.fatal;
|
|
3164
|
+
this.handler = function(stream, code_point) {
|
|
3165
|
+
if (code_point === end_of_stream)
|
|
3166
|
+
return finished;
|
|
3167
|
+
if (isASCIICodePoint(code_point))
|
|
3168
|
+
return code_point;
|
|
3169
|
+
if (inRange(code_point, 63360, 63487))
|
|
3170
|
+
return code_point - 63360 + 128;
|
|
3171
|
+
return encoderError(code_point);
|
|
3172
|
+
};
|
|
3173
|
+
}
|
|
3174
|
+
var floor, isASCIICodePoint, end_of_stream, finished, encodings, label_to_encoding, encoders, decoders, shift_jis_index, big5_index_no_hkscs, DEFAULT_ENCODING;
|
|
3175
|
+
var init_encoding = __esm({
|
|
3176
|
+
"src/lib/encoding.ts"() {
|
|
3177
|
+
init_encoding_indexes();
|
|
3178
|
+
global["encoding-indexes"] = encoding_indexes_default || {};
|
|
3179
|
+
floor = Math.floor;
|
|
3180
|
+
isASCIICodePoint = isASCIIByte;
|
|
3181
|
+
end_of_stream = -1;
|
|
3182
|
+
Stream.prototype = {
|
|
3183
|
+
endOfStream: function() {
|
|
3184
|
+
return !this.tokens.length;
|
|
3185
|
+
},
|
|
3186
|
+
read: function() {
|
|
3187
|
+
if (!this.tokens.length)
|
|
3188
|
+
return end_of_stream;
|
|
3189
|
+
return this.tokens.pop();
|
|
3190
|
+
},
|
|
3191
|
+
prepend: function(token) {
|
|
3192
|
+
if (Array.isArray(token)) {
|
|
3193
|
+
var tokens = token;
|
|
3194
|
+
while (tokens.length)
|
|
3195
|
+
this.tokens.push(tokens.pop());
|
|
3196
|
+
} else {
|
|
3197
|
+
this.tokens.push(token);
|
|
3198
|
+
}
|
|
3199
|
+
},
|
|
3200
|
+
push: function(token) {
|
|
3201
|
+
if (Array.isArray(token)) {
|
|
3202
|
+
var tokens = token;
|
|
3203
|
+
while (tokens.length)
|
|
3204
|
+
this.tokens.unshift(tokens.shift());
|
|
3205
|
+
} else {
|
|
3206
|
+
this.tokens.unshift(token);
|
|
3207
|
+
}
|
|
3208
|
+
}
|
|
3209
|
+
};
|
|
3210
|
+
finished = -1;
|
|
3211
|
+
Decoder.prototype = {
|
|
3212
|
+
handler: function(stream, bite) {
|
|
3213
|
+
}
|
|
3214
|
+
};
|
|
3215
|
+
Encoder.prototype = {
|
|
3216
|
+
handler: function(stream, code_point) {
|
|
3217
|
+
}
|
|
3218
|
+
};
|
|
3219
|
+
encodings = [
|
|
3220
|
+
{
|
|
3221
|
+
encodings: [
|
|
3222
|
+
{
|
|
3223
|
+
labels: ["unicode-1-1-utf-8", "utf-8", "utf8"],
|
|
3224
|
+
name: "UTF-8"
|
|
3225
|
+
}
|
|
3226
|
+
],
|
|
3227
|
+
heading: "The Encoding"
|
|
3228
|
+
},
|
|
3229
|
+
{
|
|
3230
|
+
encodings: [
|
|
3231
|
+
{
|
|
3232
|
+
labels: ["866", "cp866", "csibm866", "ibm866"],
|
|
3233
|
+
name: "IBM866"
|
|
3234
|
+
},
|
|
3235
|
+
{
|
|
3236
|
+
labels: [
|
|
3237
|
+
"csisolatin2",
|
|
3238
|
+
"iso-8859-2",
|
|
3239
|
+
"iso-ir-101",
|
|
3240
|
+
"iso8859-2",
|
|
3241
|
+
"iso88592",
|
|
3242
|
+
"iso_8859-2",
|
|
3243
|
+
"iso_8859-2:1987",
|
|
3244
|
+
"l2",
|
|
3245
|
+
"latin2"
|
|
3246
|
+
],
|
|
3247
|
+
name: "ISO-8859-2"
|
|
3248
|
+
},
|
|
3249
|
+
{
|
|
3250
|
+
labels: [
|
|
3251
|
+
"csisolatin3",
|
|
3252
|
+
"iso-8859-3",
|
|
3253
|
+
"iso-ir-109",
|
|
3254
|
+
"iso8859-3",
|
|
3255
|
+
"iso88593",
|
|
3256
|
+
"iso_8859-3",
|
|
3257
|
+
"iso_8859-3:1988",
|
|
3258
|
+
"l3",
|
|
3259
|
+
"latin3"
|
|
3260
|
+
],
|
|
3261
|
+
name: "ISO-8859-3"
|
|
3262
|
+
},
|
|
3263
|
+
{
|
|
3264
|
+
labels: [
|
|
3265
|
+
"csisolatin4",
|
|
3266
|
+
"iso-8859-4",
|
|
3267
|
+
"iso-ir-110",
|
|
3268
|
+
"iso8859-4",
|
|
3269
|
+
"iso88594",
|
|
3270
|
+
"iso_8859-4",
|
|
3271
|
+
"iso_8859-4:1988",
|
|
3272
|
+
"l4",
|
|
3273
|
+
"latin4"
|
|
3274
|
+
],
|
|
3275
|
+
name: "ISO-8859-4"
|
|
3276
|
+
},
|
|
3277
|
+
{
|
|
3278
|
+
labels: [
|
|
3279
|
+
"csisolatincyrillic",
|
|
3280
|
+
"cyrillic",
|
|
3281
|
+
"iso-8859-5",
|
|
3282
|
+
"iso-ir-144",
|
|
3283
|
+
"iso8859-5",
|
|
3284
|
+
"iso88595",
|
|
3285
|
+
"iso_8859-5",
|
|
3286
|
+
"iso_8859-5:1988"
|
|
3287
|
+
],
|
|
3288
|
+
name: "ISO-8859-5"
|
|
3289
|
+
},
|
|
3290
|
+
{
|
|
3291
|
+
labels: [
|
|
3292
|
+
"arabic",
|
|
3293
|
+
"asmo-708",
|
|
3294
|
+
"csiso88596e",
|
|
3295
|
+
"csiso88596i",
|
|
3296
|
+
"csisolatinarabic",
|
|
3297
|
+
"ecma-114",
|
|
3298
|
+
"iso-8859-6",
|
|
3299
|
+
"iso-8859-6-e",
|
|
3300
|
+
"iso-8859-6-i",
|
|
3301
|
+
"iso-ir-127",
|
|
3302
|
+
"iso8859-6",
|
|
3303
|
+
"iso88596",
|
|
3304
|
+
"iso_8859-6",
|
|
3305
|
+
"iso_8859-6:1987"
|
|
3306
|
+
],
|
|
3307
|
+
name: "ISO-8859-6"
|
|
3308
|
+
},
|
|
3309
|
+
{
|
|
3310
|
+
labels: [
|
|
3311
|
+
"csisolatingreek",
|
|
3312
|
+
"ecma-118",
|
|
3313
|
+
"elot_928",
|
|
3314
|
+
"greek",
|
|
3315
|
+
"greek8",
|
|
3316
|
+
"iso-8859-7",
|
|
3317
|
+
"iso-ir-126",
|
|
3318
|
+
"iso8859-7",
|
|
3319
|
+
"iso88597",
|
|
3320
|
+
"iso_8859-7",
|
|
3321
|
+
"iso_8859-7:1987",
|
|
3322
|
+
"sun_eu_greek"
|
|
3323
|
+
],
|
|
3324
|
+
name: "ISO-8859-7"
|
|
3325
|
+
},
|
|
3326
|
+
{
|
|
3327
|
+
labels: [
|
|
3328
|
+
"csiso88598e",
|
|
3329
|
+
"csisolatinhebrew",
|
|
3330
|
+
"hebrew",
|
|
3331
|
+
"iso-8859-8",
|
|
3332
|
+
"iso-8859-8-e",
|
|
3333
|
+
"iso-ir-138",
|
|
3334
|
+
"iso8859-8",
|
|
3335
|
+
"iso88598",
|
|
3336
|
+
"iso_8859-8",
|
|
3337
|
+
"iso_8859-8:1988",
|
|
3338
|
+
"visual"
|
|
3339
|
+
],
|
|
3340
|
+
name: "ISO-8859-8"
|
|
3341
|
+
},
|
|
3342
|
+
{
|
|
3343
|
+
labels: ["csiso88598i", "iso-8859-8-i", "logical"],
|
|
3344
|
+
name: "ISO-8859-8-I"
|
|
3345
|
+
},
|
|
3346
|
+
{
|
|
3347
|
+
labels: [
|
|
3348
|
+
"csisolatin6",
|
|
3349
|
+
"iso-8859-10",
|
|
3350
|
+
"iso-ir-157",
|
|
3351
|
+
"iso8859-10",
|
|
3352
|
+
"iso885910",
|
|
3353
|
+
"l6",
|
|
3354
|
+
"latin6"
|
|
3355
|
+
],
|
|
3356
|
+
name: "ISO-8859-10"
|
|
3357
|
+
},
|
|
3358
|
+
{
|
|
3359
|
+
labels: ["iso-8859-13", "iso8859-13", "iso885913"],
|
|
3360
|
+
name: "ISO-8859-13"
|
|
3361
|
+
},
|
|
3362
|
+
{
|
|
3363
|
+
labels: ["iso-8859-14", "iso8859-14", "iso885914"],
|
|
3364
|
+
name: "ISO-8859-14"
|
|
3365
|
+
},
|
|
3366
|
+
{
|
|
3367
|
+
labels: ["csisolatin9", "iso-8859-15", "iso8859-15", "iso885915", "iso_8859-15", "l9"],
|
|
3368
|
+
name: "ISO-8859-15"
|
|
3369
|
+
},
|
|
3370
|
+
{
|
|
3371
|
+
labels: ["iso-8859-16"],
|
|
3372
|
+
name: "ISO-8859-16"
|
|
3373
|
+
},
|
|
3374
|
+
{
|
|
3375
|
+
labels: ["cskoi8r", "koi", "koi8", "koi8-r", "koi8_r"],
|
|
3376
|
+
name: "KOI8-R"
|
|
3377
|
+
},
|
|
3378
|
+
{
|
|
3379
|
+
labels: ["koi8-ru", "koi8-u"],
|
|
3380
|
+
name: "KOI8-U"
|
|
3381
|
+
},
|
|
3382
|
+
{
|
|
3383
|
+
labels: ["csmacintosh", "mac", "macintosh", "x-mac-roman"],
|
|
3384
|
+
name: "macintosh"
|
|
3385
|
+
},
|
|
3386
|
+
{
|
|
3387
|
+
labels: ["dos-874", "iso-8859-11", "iso8859-11", "iso885911", "tis-620", "windows-874"],
|
|
3388
|
+
name: "windows-874"
|
|
3389
|
+
},
|
|
3390
|
+
{
|
|
3391
|
+
labels: ["cp1250", "windows-1250", "x-cp1250"],
|
|
3392
|
+
name: "windows-1250"
|
|
3393
|
+
},
|
|
3394
|
+
{
|
|
3395
|
+
labels: ["cp1251", "windows-1251", "x-cp1251"],
|
|
3396
|
+
name: "windows-1251"
|
|
3397
|
+
},
|
|
3398
|
+
{
|
|
3399
|
+
labels: [
|
|
3400
|
+
"ansi_x3.4-1968",
|
|
3401
|
+
"ascii",
|
|
3402
|
+
"cp1252",
|
|
3403
|
+
"cp819",
|
|
3404
|
+
"csisolatin1",
|
|
3405
|
+
"ibm819",
|
|
3406
|
+
"iso-8859-1",
|
|
3407
|
+
"iso-ir-100",
|
|
3408
|
+
"iso8859-1",
|
|
3409
|
+
"iso88591",
|
|
3410
|
+
"iso_8859-1",
|
|
3411
|
+
"iso_8859-1:1987",
|
|
3412
|
+
"l1",
|
|
3413
|
+
"latin1",
|
|
3414
|
+
"us-ascii",
|
|
3415
|
+
"windows-1252",
|
|
3416
|
+
"x-cp1252"
|
|
3417
|
+
],
|
|
3418
|
+
name: "windows-1252"
|
|
3419
|
+
},
|
|
3420
|
+
{
|
|
3421
|
+
labels: ["cp1253", "windows-1253", "x-cp1253"],
|
|
3422
|
+
name: "windows-1253"
|
|
3423
|
+
},
|
|
3424
|
+
{
|
|
3425
|
+
labels: [
|
|
3426
|
+
"cp1254",
|
|
3427
|
+
"csisolatin5",
|
|
3428
|
+
"iso-8859-9",
|
|
3429
|
+
"iso-ir-148",
|
|
3430
|
+
"iso8859-9",
|
|
3431
|
+
"iso88599",
|
|
3432
|
+
"iso_8859-9",
|
|
3433
|
+
"iso_8859-9:1989",
|
|
3434
|
+
"l5",
|
|
3435
|
+
"latin5",
|
|
3436
|
+
"windows-1254",
|
|
3437
|
+
"x-cp1254"
|
|
3438
|
+
],
|
|
3439
|
+
name: "windows-1254"
|
|
3440
|
+
},
|
|
3441
|
+
{
|
|
3442
|
+
labels: ["cp1255", "windows-1255", "x-cp1255"],
|
|
3443
|
+
name: "windows-1255"
|
|
3444
|
+
},
|
|
3445
|
+
{
|
|
3446
|
+
labels: ["cp1256", "windows-1256", "x-cp1256"],
|
|
3447
|
+
name: "windows-1256"
|
|
3448
|
+
},
|
|
3449
|
+
{
|
|
3450
|
+
labels: ["cp1257", "windows-1257", "x-cp1257"],
|
|
3451
|
+
name: "windows-1257"
|
|
3452
|
+
},
|
|
3453
|
+
{
|
|
3454
|
+
labels: ["cp1258", "windows-1258", "x-cp1258"],
|
|
3455
|
+
name: "windows-1258"
|
|
3456
|
+
},
|
|
3457
|
+
{
|
|
3458
|
+
labels: ["x-mac-cyrillic", "x-mac-ukrainian"],
|
|
3459
|
+
name: "x-mac-cyrillic"
|
|
3460
|
+
}
|
|
3461
|
+
],
|
|
3462
|
+
heading: "Legacy single-byte encodings"
|
|
3463
|
+
},
|
|
3464
|
+
{
|
|
3465
|
+
encodings: [
|
|
3466
|
+
{
|
|
3467
|
+
labels: [
|
|
3468
|
+
"chinese",
|
|
3469
|
+
"csgb2312",
|
|
3470
|
+
"csiso58gb231280",
|
|
3471
|
+
"gb2312",
|
|
3472
|
+
"gb_2312",
|
|
3473
|
+
"gb_2312-80",
|
|
3474
|
+
"gbk",
|
|
3475
|
+
"iso-ir-58",
|
|
3476
|
+
"x-gbk"
|
|
3477
|
+
],
|
|
3478
|
+
name: "GBK"
|
|
3479
|
+
},
|
|
3480
|
+
{
|
|
3481
|
+
labels: ["gb18030"],
|
|
3482
|
+
name: "gb18030"
|
|
3483
|
+
}
|
|
3484
|
+
],
|
|
3485
|
+
heading: "Legacy multi-byte Chinese (simplified) encodings"
|
|
3486
|
+
},
|
|
3487
|
+
{
|
|
3488
|
+
encodings: [
|
|
3489
|
+
{
|
|
3490
|
+
labels: ["big5", "big5-hkscs", "cn-big5", "csbig5", "x-x-big5"],
|
|
3491
|
+
name: "Big5"
|
|
3492
|
+
}
|
|
3493
|
+
],
|
|
3494
|
+
heading: "Legacy multi-byte Chinese (traditional) encodings"
|
|
3495
|
+
},
|
|
3496
|
+
{
|
|
3497
|
+
encodings: [
|
|
3498
|
+
{
|
|
3499
|
+
labels: ["cseucpkdfmtjapanese", "euc-jp", "x-euc-jp"],
|
|
3500
|
+
name: "EUC-JP"
|
|
3501
|
+
},
|
|
3502
|
+
{
|
|
3503
|
+
labels: ["csiso2022jp", "iso-2022-jp"],
|
|
3504
|
+
name: "ISO-2022-JP"
|
|
3505
|
+
},
|
|
3506
|
+
{
|
|
3507
|
+
labels: [
|
|
3508
|
+
"csshiftjis",
|
|
3509
|
+
"ms932",
|
|
3510
|
+
"ms_kanji",
|
|
3511
|
+
"shift-jis",
|
|
3512
|
+
"shift_jis",
|
|
3513
|
+
"sjis",
|
|
3514
|
+
"windows-31j",
|
|
3515
|
+
"x-sjis"
|
|
3516
|
+
],
|
|
3517
|
+
name: "Shift_JIS"
|
|
3518
|
+
}
|
|
3519
|
+
],
|
|
3520
|
+
heading: "Legacy multi-byte Japanese encodings"
|
|
3521
|
+
},
|
|
3522
|
+
{
|
|
3523
|
+
encodings: [
|
|
3524
|
+
{
|
|
3525
|
+
labels: [
|
|
3526
|
+
"cseuckr",
|
|
3527
|
+
"csksc56011987",
|
|
3528
|
+
"euc-kr",
|
|
3529
|
+
"iso-ir-149",
|
|
3530
|
+
"korean",
|
|
3531
|
+
"ks_c_5601-1987",
|
|
3532
|
+
"ks_c_5601-1989",
|
|
3533
|
+
"ksc5601",
|
|
3534
|
+
"ksc_5601",
|
|
3535
|
+
"windows-949"
|
|
3536
|
+
],
|
|
3537
|
+
name: "EUC-KR"
|
|
3538
|
+
}
|
|
3539
|
+
],
|
|
3540
|
+
heading: "Legacy multi-byte Korean encodings"
|
|
3541
|
+
},
|
|
3542
|
+
{
|
|
3543
|
+
encodings: [
|
|
3544
|
+
{
|
|
3545
|
+
labels: ["csiso2022kr", "hz-gb-2312", "iso-2022-cn", "iso-2022-cn-ext", "iso-2022-kr"],
|
|
3546
|
+
name: "replacement"
|
|
3547
|
+
},
|
|
3548
|
+
{
|
|
3549
|
+
labels: ["utf-16be"],
|
|
3550
|
+
name: "UTF-16BE"
|
|
3551
|
+
},
|
|
3552
|
+
{
|
|
3553
|
+
labels: ["utf-16", "utf-16le"],
|
|
3554
|
+
name: "UTF-16LE"
|
|
3555
|
+
},
|
|
3556
|
+
{
|
|
3557
|
+
labels: ["x-user-defined"],
|
|
3558
|
+
name: "x-user-defined"
|
|
3559
|
+
}
|
|
3560
|
+
],
|
|
3561
|
+
heading: "Legacy miscellaneous encodings"
|
|
3562
|
+
}
|
|
3563
|
+
];
|
|
3564
|
+
label_to_encoding = {};
|
|
3565
|
+
encodings.forEach(function(category) {
|
|
3566
|
+
category.encodings.forEach(function(encoding) {
|
|
3567
|
+
encoding.labels.forEach(function(label) {
|
|
3568
|
+
label_to_encoding[label] = encoding;
|
|
3569
|
+
});
|
|
3570
|
+
});
|
|
3571
|
+
});
|
|
3572
|
+
encoders = {};
|
|
3573
|
+
decoders = {};
|
|
3574
|
+
DEFAULT_ENCODING = "utf-8";
|
|
3575
|
+
if (Object.defineProperty) {
|
|
3576
|
+
Object.defineProperty(TextDecoder.prototype, "encoding", {
|
|
3577
|
+
get: function() {
|
|
3578
|
+
return this._encoding.name.toLowerCase();
|
|
3579
|
+
}
|
|
3580
|
+
});
|
|
3581
|
+
Object.defineProperty(TextDecoder.prototype, "fatal", {
|
|
3582
|
+
get: function() {
|
|
3583
|
+
return this._error_mode === "fatal";
|
|
3584
|
+
}
|
|
3585
|
+
});
|
|
3586
|
+
Object.defineProperty(TextDecoder.prototype, "ignoreBOM", {
|
|
3587
|
+
get: function() {
|
|
3588
|
+
return this._ignoreBOM;
|
|
3589
|
+
}
|
|
3590
|
+
});
|
|
3591
|
+
}
|
|
3592
|
+
TextDecoder.prototype.decode = function decode(input, options) {
|
|
3593
|
+
var bytes;
|
|
3594
|
+
if (typeof input === "object" && input instanceof ArrayBuffer) {
|
|
3595
|
+
bytes = new Uint8Array(input);
|
|
3596
|
+
} else if (typeof input === "object" && "buffer" in input && input.buffer instanceof ArrayBuffer) {
|
|
3597
|
+
bytes = new Uint8Array(input.buffer, input.byteOffset, input.byteLength);
|
|
3598
|
+
} else {
|
|
3599
|
+
bytes = new Uint8Array(0);
|
|
3600
|
+
}
|
|
3601
|
+
options = ToDictionary(options);
|
|
3602
|
+
if (!this._do_not_flush) {
|
|
3603
|
+
this._decoder = decoders[this._encoding.name]({
|
|
3604
|
+
fatal: this._error_mode === "fatal"
|
|
3605
|
+
});
|
|
3606
|
+
this._BOMseen = false;
|
|
3607
|
+
}
|
|
3608
|
+
this._do_not_flush = Boolean(options["stream"]);
|
|
3609
|
+
var input_stream = new Stream(bytes);
|
|
3610
|
+
var output = [];
|
|
3611
|
+
var result;
|
|
3612
|
+
while (true) {
|
|
3613
|
+
var token = input_stream.read();
|
|
3614
|
+
if (token === end_of_stream)
|
|
3615
|
+
break;
|
|
3616
|
+
result = this._decoder.handler(input_stream, token);
|
|
3617
|
+
if (result === finished)
|
|
3618
|
+
break;
|
|
3619
|
+
if (result !== null) {
|
|
3620
|
+
if (Array.isArray(result))
|
|
3621
|
+
output.push.apply(output, result);
|
|
3622
|
+
else
|
|
3623
|
+
output.push(result);
|
|
3624
|
+
}
|
|
3625
|
+
}
|
|
3626
|
+
if (!this._do_not_flush) {
|
|
3627
|
+
do {
|
|
3628
|
+
result = this._decoder.handler(input_stream, input_stream.read());
|
|
3629
|
+
if (result === finished)
|
|
3630
|
+
break;
|
|
3631
|
+
if (result === null)
|
|
3632
|
+
continue;
|
|
3633
|
+
if (Array.isArray(result))
|
|
3634
|
+
output.push.apply(output, result);
|
|
3635
|
+
else
|
|
3636
|
+
output.push(result);
|
|
3637
|
+
} while (!input_stream.endOfStream());
|
|
3638
|
+
this._decoder = null;
|
|
3639
|
+
}
|
|
3640
|
+
function serializeStream(stream) {
|
|
3641
|
+
if (includes(["UTF-8", "UTF-16LE", "UTF-16BE"], this._encoding.name) && !this._ignoreBOM && !this._BOMseen) {
|
|
3642
|
+
if (stream.length > 0 && stream[0] === 65279) {
|
|
3643
|
+
this._BOMseen = true;
|
|
3644
|
+
stream.shift();
|
|
3645
|
+
} else if (stream.length > 0) {
|
|
3646
|
+
this._BOMseen = true;
|
|
3647
|
+
} else {
|
|
3648
|
+
}
|
|
3649
|
+
}
|
|
3650
|
+
return codePointsToString(stream);
|
|
3651
|
+
}
|
|
3652
|
+
return serializeStream.call(this, output);
|
|
3653
|
+
};
|
|
3654
|
+
if (Object.defineProperty) {
|
|
3655
|
+
Object.defineProperty(TextEncoder.prototype, "encoding", {
|
|
3656
|
+
get: function() {
|
|
3657
|
+
return this._encoding.name.toLowerCase();
|
|
3658
|
+
}
|
|
3659
|
+
});
|
|
3660
|
+
}
|
|
3661
|
+
TextEncoder.prototype.encode = function encode(opt_string, options) {
|
|
3662
|
+
opt_string = opt_string === void 0 ? "" : String(opt_string);
|
|
3663
|
+
options = ToDictionary(options);
|
|
3664
|
+
if (!this._do_not_flush)
|
|
3665
|
+
this._encoder = encoders[this._encoding.name]({
|
|
3666
|
+
fatal: this._fatal === "fatal"
|
|
3667
|
+
});
|
|
3668
|
+
this._do_not_flush = Boolean(options["stream"]);
|
|
3669
|
+
var input = new Stream(stringToCodePoints(opt_string));
|
|
3670
|
+
var output = [];
|
|
3671
|
+
var result;
|
|
3672
|
+
while (true) {
|
|
3673
|
+
var token = input.read();
|
|
3674
|
+
if (token === end_of_stream)
|
|
3675
|
+
break;
|
|
3676
|
+
result = this._encoder.handler(input, token);
|
|
3677
|
+
if (result === finished)
|
|
3678
|
+
break;
|
|
3679
|
+
if (Array.isArray(result))
|
|
3680
|
+
output.push.apply(output, result);
|
|
3681
|
+
else
|
|
3682
|
+
output.push(result);
|
|
3683
|
+
}
|
|
3684
|
+
if (!this._do_not_flush) {
|
|
3685
|
+
while (true) {
|
|
3686
|
+
result = this._encoder.handler(input, input.read());
|
|
3687
|
+
if (result === finished)
|
|
3688
|
+
break;
|
|
3689
|
+
if (Array.isArray(result))
|
|
3690
|
+
output.push.apply(output, result);
|
|
3691
|
+
else
|
|
3692
|
+
output.push(result);
|
|
3693
|
+
}
|
|
3694
|
+
this._encoder = null;
|
|
3695
|
+
}
|
|
3696
|
+
return new Uint8Array(output);
|
|
3697
|
+
};
|
|
3698
|
+
encoders["UTF-8"] = function(options) {
|
|
3699
|
+
return new UTF8Encoder(options);
|
|
3700
|
+
};
|
|
3701
|
+
decoders["UTF-8"] = function(options) {
|
|
3702
|
+
return new UTF8Decoder(options);
|
|
3703
|
+
};
|
|
3704
|
+
(function() {
|
|
3705
|
+
if (!("encoding-indexes" in global))
|
|
3706
|
+
return;
|
|
3707
|
+
encodings.forEach(function(category) {
|
|
3708
|
+
if (category.heading !== "Legacy single-byte encodings")
|
|
3709
|
+
return;
|
|
3710
|
+
category.encodings.forEach(function(encoding) {
|
|
3711
|
+
var name = encoding.name;
|
|
3712
|
+
var idx = index(name.toLowerCase());
|
|
3713
|
+
decoders[name] = function(options) {
|
|
3714
|
+
return new SingleByteDecoder(idx, options);
|
|
3715
|
+
};
|
|
3716
|
+
encoders[name] = function(options) {
|
|
3717
|
+
return new SingleByteEncoder(idx, options);
|
|
3718
|
+
};
|
|
3719
|
+
});
|
|
3720
|
+
});
|
|
3721
|
+
})();
|
|
3722
|
+
decoders["GBK"] = function(options) {
|
|
3723
|
+
return new GB18030Decoder(options);
|
|
3724
|
+
};
|
|
3725
|
+
encoders["GBK"] = function(options) {
|
|
3726
|
+
return new GB18030Encoder(options, true);
|
|
3727
|
+
};
|
|
3728
|
+
encoders["gb18030"] = function(options) {
|
|
3729
|
+
return new GB18030Encoder(options);
|
|
3730
|
+
};
|
|
3731
|
+
decoders["gb18030"] = function(options) {
|
|
3732
|
+
return new GB18030Decoder(options);
|
|
3733
|
+
};
|
|
3734
|
+
encoders["Big5"] = function(options) {
|
|
3735
|
+
return new Big5Encoder(options);
|
|
3736
|
+
};
|
|
3737
|
+
decoders["Big5"] = function(options) {
|
|
3738
|
+
return new Big5Decoder(options);
|
|
3739
|
+
};
|
|
3740
|
+
encoders["EUC-JP"] = function(options) {
|
|
3741
|
+
return new EUCJPEncoder(options);
|
|
3742
|
+
};
|
|
3743
|
+
decoders["EUC-JP"] = function(options) {
|
|
3744
|
+
return new EUCJPDecoder(options);
|
|
3745
|
+
};
|
|
3746
|
+
encoders["ISO-2022-JP"] = function(options) {
|
|
3747
|
+
return new ISO2022JPEncoder(options);
|
|
3748
|
+
};
|
|
3749
|
+
decoders["ISO-2022-JP"] = function(options) {
|
|
3750
|
+
return new ISO2022JPDecoder(options);
|
|
3751
|
+
};
|
|
3752
|
+
encoders["Shift_JIS"] = function(options) {
|
|
3753
|
+
return new ShiftJISEncoder(options);
|
|
3754
|
+
};
|
|
3755
|
+
decoders["Shift_JIS"] = function(options) {
|
|
3756
|
+
return new ShiftJISDecoder(options);
|
|
3757
|
+
};
|
|
3758
|
+
encoders["EUC-KR"] = function(options) {
|
|
3759
|
+
return new EUCKREncoder(options);
|
|
3760
|
+
};
|
|
3761
|
+
decoders["EUC-KR"] = function(options) {
|
|
3762
|
+
return new EUCKRDecoder(options);
|
|
3763
|
+
};
|
|
3764
|
+
encoders["UTF-16BE"] = function(options) {
|
|
3765
|
+
return new UTF16Encoder(true, options);
|
|
3766
|
+
};
|
|
3767
|
+
decoders["UTF-16BE"] = function(options) {
|
|
3768
|
+
return new UTF16Decoder(true, options);
|
|
3769
|
+
};
|
|
3770
|
+
encoders["UTF-16LE"] = function(options) {
|
|
3771
|
+
return new UTF16Encoder(false, options);
|
|
3772
|
+
};
|
|
3773
|
+
decoders["UTF-16LE"] = function(options) {
|
|
3774
|
+
return new UTF16Decoder(false, options);
|
|
3775
|
+
};
|
|
3776
|
+
encoders["x-user-defined"] = function(options) {
|
|
3777
|
+
return new XUserDefinedEncoder(options);
|
|
3778
|
+
};
|
|
3779
|
+
decoders["x-user-defined"] = function(options) {
|
|
3780
|
+
return new XUserDefinedDecoder(options);
|
|
3781
|
+
};
|
|
3782
|
+
}
|
|
3783
|
+
});
|
|
3784
|
+
|
|
3785
|
+
// src/promise/all-settled.ts
|
|
3786
|
+
function allSettled(promises) {
|
|
3787
|
+
const mappedPromises = promises.map((promise) => {
|
|
3788
|
+
return promise.then((value) => {
|
|
3789
|
+
return { status: FULFILLED_STATUS, value };
|
|
3790
|
+
}).catch((reason) => {
|
|
3791
|
+
return { status: REJECTED_STATUS, reason };
|
|
3792
|
+
});
|
|
3793
|
+
});
|
|
3794
|
+
return Promise.all(mappedPromises);
|
|
3795
|
+
}
|
|
3796
|
+
var REJECTED_STATUS, FULFILLED_STATUS;
|
|
3797
|
+
var init_all_settled = __esm({
|
|
3798
|
+
"src/promise/all-settled.ts"() {
|
|
3799
|
+
REJECTED_STATUS = "rejected";
|
|
3800
|
+
FULFILLED_STATUS = "fulfilled";
|
|
3801
|
+
}
|
|
3802
|
+
});
|
|
3803
|
+
|
|
3804
|
+
// (disabled):src/node/buffer/btoa.node
|
|
3805
|
+
var init_btoa = __esm({
|
|
3806
|
+
"(disabled):src/node/buffer/btoa.node"() {
|
|
3807
|
+
}
|
|
3808
|
+
});
|
|
3809
|
+
|
|
3810
|
+
// (disabled):src/node/fetch/headers.node
|
|
3811
|
+
var require_headers = __commonJS({
|
|
3812
|
+
"(disabled):src/node/fetch/headers.node"() {
|
|
3813
|
+
}
|
|
3814
|
+
});
|
|
3815
|
+
|
|
3816
|
+
// (disabled):src/node/fetch/response.node
|
|
3817
|
+
var require_response = __commonJS({
|
|
3818
|
+
"(disabled):src/node/fetch/response.node"() {
|
|
3819
|
+
}
|
|
3820
|
+
});
|
|
3821
|
+
|
|
3822
|
+
// (disabled):src/node/fetch/fetch.node
|
|
3823
|
+
var require_fetch = __commonJS({
|
|
3824
|
+
"(disabled):src/node/fetch/fetch.node"() {
|
|
3825
|
+
}
|
|
3826
|
+
});
|
|
3827
|
+
|
|
3828
|
+
// (disabled):src/node/images/encode-image.node
|
|
3829
|
+
var init_encode_image = __esm({
|
|
3830
|
+
"(disabled):src/node/images/encode-image.node"() {
|
|
3831
|
+
}
|
|
3832
|
+
});
|
|
3833
|
+
|
|
3834
|
+
// (disabled):src/node/images/parse-image.node
|
|
3835
|
+
var init_parse_image = __esm({
|
|
3836
|
+
"(disabled):src/node/images/parse-image.node"() {
|
|
3837
|
+
}
|
|
3838
|
+
});
|
|
3839
|
+
|
|
3840
|
+
// (disabled):src/node/file/readable-stream
|
|
3841
|
+
var init_readable_stream = __esm({
|
|
3842
|
+
"(disabled):src/node/file/readable-stream"() {
|
|
3843
|
+
}
|
|
3844
|
+
});
|
|
3845
|
+
|
|
3846
|
+
// (disabled):src/node/file/blob
|
|
3847
|
+
var init_blob = __esm({
|
|
3848
|
+
"(disabled):src/node/file/blob"() {
|
|
3849
|
+
}
|
|
3850
|
+
});
|
|
3851
|
+
|
|
3852
|
+
// src/node/file/file-reader.ts
|
|
3853
|
+
var FileReaderPolyfill;
|
|
3854
|
+
var init_file_reader = __esm({
|
|
3855
|
+
"src/node/file/file-reader.ts"() {
|
|
3856
|
+
init_btoa();
|
|
3857
|
+
FileReaderPolyfill = class {
|
|
3858
|
+
constructor() {
|
|
3859
|
+
this.onload = null;
|
|
3860
|
+
}
|
|
3861
|
+
abort() {
|
|
3862
|
+
return;
|
|
3863
|
+
}
|
|
3864
|
+
async readAsArrayBuffer(blob) {
|
|
3865
|
+
const arrayBuffer = await blob.arrayBuffer();
|
|
3866
|
+
if (this.onload) {
|
|
3867
|
+
this.onload({ target: { result: arrayBuffer } });
|
|
3868
|
+
}
|
|
3869
|
+
}
|
|
3870
|
+
async readAsBinaryString(blob) {
|
|
3871
|
+
throw Error("Not implemented");
|
|
3872
|
+
}
|
|
3873
|
+
async readAsDataURL(blob) {
|
|
3874
|
+
const text = await blob.text();
|
|
3875
|
+
const dataUrl = `data://;base64,${(0, import_btoa.atob)(text)}`;
|
|
3876
|
+
if (this.onload) {
|
|
3877
|
+
this.onload({ target: { result: dataUrl } });
|
|
3878
|
+
}
|
|
3879
|
+
}
|
|
3880
|
+
async readAsText(blob) {
|
|
3881
|
+
const text = await blob.text();
|
|
3882
|
+
if (this.onload) {
|
|
3883
|
+
this.onload({ target: { result: text } });
|
|
3884
|
+
}
|
|
3885
|
+
}
|
|
3886
|
+
};
|
|
3887
|
+
}
|
|
3888
|
+
});
|
|
3889
|
+
|
|
3890
|
+
// (disabled):src/node/file/file
|
|
3891
|
+
var init_file = __esm({
|
|
3892
|
+
"(disabled):src/node/file/file"() {
|
|
3893
|
+
}
|
|
3894
|
+
});
|
|
3895
|
+
|
|
3896
|
+
// src/node/file/install-file-polyfills.ts
|
|
3897
|
+
function installFilePolyfills() {
|
|
3898
|
+
if (typeof ReadableStream === "undefined" && global) {
|
|
3899
|
+
global.ReadableStream = import_readable_stream.ReadableStreamPolyfill;
|
|
3900
|
+
}
|
|
3901
|
+
if (typeof Blob === "undefined" && global) {
|
|
3902
|
+
global.Blob = import_blob.BlobPolyfill;
|
|
3903
|
+
}
|
|
3904
|
+
if (typeof FileReader === "undefined" && global) {
|
|
3905
|
+
global.FileReader = FileReaderPolyfill;
|
|
3906
|
+
}
|
|
3907
|
+
if (typeof File === "undefined" && global) {
|
|
3908
|
+
global.File = import_file.FilePolyfill;
|
|
3909
|
+
}
|
|
3910
|
+
}
|
|
3911
|
+
var init_install_file_polyfills = __esm({
|
|
3912
|
+
"src/node/file/install-file-polyfills.ts"() {
|
|
3913
|
+
init_readable_stream();
|
|
3914
|
+
init_blob();
|
|
3915
|
+
init_file_reader();
|
|
3916
|
+
init_file();
|
|
3917
|
+
}
|
|
3918
|
+
});
|
|
3919
|
+
|
|
3920
|
+
// src/index.ts
|
|
3921
|
+
var src_exports = {};
|
|
3922
|
+
__export(src_exports, {
|
|
3923
|
+
BlobPolyfill: () => import_blob2.BlobPolyfill,
|
|
3924
|
+
FilePolyfill: () => import_file2.FilePolyfill,
|
|
3925
|
+
FileReaderPolyfill: () => FileReaderPolyfill,
|
|
3926
|
+
ReadableStreamPolyfill: () => import_readable_stream2.ReadableStreamPolyfill,
|
|
3927
|
+
installFilePolyfills: () => installFilePolyfills
|
|
3928
|
+
});
|
|
3929
|
+
var import_xmldom, import_headers, import_response, import_fetch, installTextEncoder, installTextDecoder;
|
|
3930
|
+
var init_src = __esm({
|
|
3931
|
+
"src/index.ts"() {
|
|
3932
|
+
import_xmldom = __toModule(require_lib());
|
|
3933
|
+
init_globals();
|
|
3934
|
+
init_encoding();
|
|
3935
|
+
init_all_settled();
|
|
3936
|
+
init_btoa();
|
|
3937
|
+
import_headers = __toModule(require_headers());
|
|
3938
|
+
import_response = __toModule(require_response());
|
|
3939
|
+
import_fetch = __toModule(require_fetch());
|
|
3940
|
+
init_encode_image();
|
|
3941
|
+
init_parse_image();
|
|
3942
|
+
init_readable_stream();
|
|
3943
|
+
init_blob();
|
|
3944
|
+
init_file_reader();
|
|
3945
|
+
init_file();
|
|
3946
|
+
init_install_file_polyfills();
|
|
3947
|
+
installTextEncoder = !isBrowser || !("TextEncoder" in global_);
|
|
3948
|
+
if (installTextEncoder) {
|
|
3949
|
+
global_["TextEncoder"] = TextEncoder;
|
|
3950
|
+
}
|
|
3951
|
+
installTextDecoder = !isBrowser || !("TextDecoder" in global_);
|
|
3952
|
+
if (installTextDecoder) {
|
|
3953
|
+
global_["TextDecoder"] = TextDecoder;
|
|
3954
|
+
}
|
|
3955
|
+
if (!isBrowser && !("atob" in global_) && base64.atob) {
|
|
3956
|
+
global_["atob"] = base64.atob;
|
|
3957
|
+
}
|
|
3958
|
+
if (!isBrowser && !("btoa" in global_) && base64.btoa) {
|
|
3959
|
+
global_["btoa"] = base64.btoa;
|
|
3960
|
+
}
|
|
3961
|
+
if (!isBrowser && !("Headers" in global_) && import_headers.default) {
|
|
3962
|
+
global_["Headers"] = import_headers.default;
|
|
3963
|
+
}
|
|
3964
|
+
if (!isBrowser && !("Response" in global_) && import_response.default) {
|
|
3965
|
+
global_["Response"] = import_response.default;
|
|
3966
|
+
}
|
|
3967
|
+
if (!isBrowser && !("fetch" in global_) && import_fetch.default) {
|
|
3968
|
+
global_["fetch"] = import_fetch.default;
|
|
3969
|
+
}
|
|
3970
|
+
if (!isBrowser && !("DOMParser" in global_) && import_xmldom.DOMParser) {
|
|
3971
|
+
global_["DOMParser"] = import_xmldom.DOMParser;
|
|
3972
|
+
}
|
|
3973
|
+
if (!isBrowser && !("_encodeImageNode" in global_) && import_encode_image.encodeImageNode) {
|
|
3974
|
+
global_["_encodeImageNode"] = import_encode_image.encodeImageNode;
|
|
3975
|
+
}
|
|
3976
|
+
if (!isBrowser && !("_parseImageNode" in global_) && import_parse_image.parseImageNode) {
|
|
3977
|
+
global_["_parseImageNode"] = import_parse_image.parseImageNode;
|
|
3978
|
+
}
|
|
3979
|
+
if (!("allSettled" in Promise)) {
|
|
3980
|
+
Promise.allSettled = allSettled;
|
|
3981
|
+
}
|
|
3982
|
+
}
|
|
3983
|
+
});
|
|
3984
|
+
|
|
3985
|
+
// src/bundle.ts
|
|
3986
|
+
var require_bundle = __commonJS({
|
|
3987
|
+
"src/bundle.ts"(exports, module) {
|
|
3988
|
+
var moduleExports = (init_src(), src_exports);
|
|
3989
|
+
globalThis.loaders = globalThis.loaders || {};
|
|
3990
|
+
module.exports = Object.assign(globalThis.loaders, moduleExports);
|
|
3991
|
+
}
|
|
3992
|
+
});
|
|
3993
|
+
require_bundle();
|
|
3994
|
+
})();
|