smule.js 1.4.0 → 1.4.1
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/index.cjs +6 -723
- package/dist/index.js +37 -783
- package/package.json +65 -63
package/dist/index.cjs
CHANGED
|
@@ -4,9 +4,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
-
};
|
|
10
7
|
var __export = (target, all) => {
|
|
11
8
|
for (var name in all)
|
|
12
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -29,625 +26,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
29
26
|
));
|
|
30
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
28
|
|
|
32
|
-
// node_modules/ltx/lib/escape.js
|
|
33
|
-
var require_escape = __commonJS({
|
|
34
|
-
"node_modules/ltx/lib/escape.js"(exports2) {
|
|
35
|
-
"use strict";
|
|
36
|
-
var escapeXMLTable = {
|
|
37
|
-
"&": "&",
|
|
38
|
-
"<": "<",
|
|
39
|
-
">": ">",
|
|
40
|
-
'"': """,
|
|
41
|
-
"'": "'"
|
|
42
|
-
};
|
|
43
|
-
function escapeXMLReplace(match) {
|
|
44
|
-
return escapeXMLTable[match];
|
|
45
|
-
}
|
|
46
|
-
var unescapeXMLTable = {
|
|
47
|
-
"&": "&",
|
|
48
|
-
"<": "<",
|
|
49
|
-
">": ">",
|
|
50
|
-
""": '"',
|
|
51
|
-
"'": "'"
|
|
52
|
-
};
|
|
53
|
-
function unescapeXMLReplace(match) {
|
|
54
|
-
if (match[1] === "#") {
|
|
55
|
-
const num = match[2] === "x" ? parseInt(match.slice(3), 16) : parseInt(match.slice(2), 10);
|
|
56
|
-
if (num === 9 || num === 10 || num === 13 || num >= 32 && num <= 55295 || num >= 57344 && num <= 65533 || num >= 65536 && num <= 1114111) {
|
|
57
|
-
return String.fromCodePoint(num);
|
|
58
|
-
}
|
|
59
|
-
throw new Error("Illegal XML character 0x" + num.toString(16));
|
|
60
|
-
}
|
|
61
|
-
if (unescapeXMLTable[match]) {
|
|
62
|
-
return unescapeXMLTable[match] || match;
|
|
63
|
-
}
|
|
64
|
-
throw new Error("Illegal XML entity " + match);
|
|
65
|
-
}
|
|
66
|
-
function escapeXML2(s) {
|
|
67
|
-
return s.replace(/["&'<>]/g, escapeXMLReplace);
|
|
68
|
-
}
|
|
69
|
-
function unescapeXML2(s) {
|
|
70
|
-
let result = "";
|
|
71
|
-
let start = -1;
|
|
72
|
-
let end = -1;
|
|
73
|
-
let previous = 0;
|
|
74
|
-
while ((start = s.indexOf("&", previous)) !== -1 && (end = s.indexOf(";", start + 1)) !== -1) {
|
|
75
|
-
result = result + s.slice(previous, start) + unescapeXMLReplace(s.slice(start, end + 1));
|
|
76
|
-
previous = end + 1;
|
|
77
|
-
}
|
|
78
|
-
if (previous === 0) return s;
|
|
79
|
-
result = result + s.substring(previous);
|
|
80
|
-
return result;
|
|
81
|
-
}
|
|
82
|
-
function escapeXMLText2(s) {
|
|
83
|
-
return s.replace(/[&<>]/g, escapeXMLReplace);
|
|
84
|
-
}
|
|
85
|
-
function unescapeXMLText2(s) {
|
|
86
|
-
return s.replace(/&(amp|#38|lt|#60|gt|#62);/g, unescapeXMLReplace);
|
|
87
|
-
}
|
|
88
|
-
exports2.escapeXML = escapeXML2;
|
|
89
|
-
exports2.escapeXMLText = escapeXMLText2;
|
|
90
|
-
exports2.unescapeXML = unescapeXML2;
|
|
91
|
-
exports2.unescapeXMLText = unescapeXMLText2;
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
// node_modules/ltx/lib/Element.js
|
|
96
|
-
var require_Element = __commonJS({
|
|
97
|
-
"node_modules/ltx/lib/Element.js"(exports2, module2) {
|
|
98
|
-
"use strict";
|
|
99
|
-
var escape = require_escape();
|
|
100
|
-
var Element5 = class _Element {
|
|
101
|
-
constructor(name, attrs) {
|
|
102
|
-
this.name = name;
|
|
103
|
-
this.parent = null;
|
|
104
|
-
this.children = [];
|
|
105
|
-
this.attrs = {};
|
|
106
|
-
this.setAttrs(attrs);
|
|
107
|
-
}
|
|
108
|
-
/* Accessors */
|
|
109
|
-
/**
|
|
110
|
-
* if (element.is('message', 'jabber:client')) ...
|
|
111
|
-
**/
|
|
112
|
-
is(name, xmlns) {
|
|
113
|
-
return this.getName() === name && (!xmlns || this.getNS() === xmlns);
|
|
114
|
-
}
|
|
115
|
-
/* without prefix */
|
|
116
|
-
getName() {
|
|
117
|
-
const idx = this.name.indexOf(":");
|
|
118
|
-
return idx >= 0 ? this.name.slice(idx + 1) : this.name;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* retrieves the namespace of the current element, upwards recursively
|
|
122
|
-
**/
|
|
123
|
-
getNS() {
|
|
124
|
-
const idx = this.name.indexOf(":");
|
|
125
|
-
if (idx >= 0) {
|
|
126
|
-
const prefix = this.name.slice(0, idx);
|
|
127
|
-
return this.findNS(prefix);
|
|
128
|
-
}
|
|
129
|
-
return this.findNS();
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* find the namespace to the given prefix, upwards recursively
|
|
133
|
-
**/
|
|
134
|
-
findNS(prefix) {
|
|
135
|
-
if (!prefix) {
|
|
136
|
-
if (this.attrs.xmlns) {
|
|
137
|
-
return this.attrs.xmlns;
|
|
138
|
-
} else if (this.parent) {
|
|
139
|
-
return this.parent.findNS();
|
|
140
|
-
}
|
|
141
|
-
} else {
|
|
142
|
-
const attr = "xmlns:" + prefix;
|
|
143
|
-
if (this.attrs[attr]) {
|
|
144
|
-
return this.attrs[attr];
|
|
145
|
-
} else if (this.parent) {
|
|
146
|
-
return this.parent.findNS(prefix);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Recursiverly gets all xmlns defined, in the form of {url:prefix}
|
|
152
|
-
**/
|
|
153
|
-
getXmlns() {
|
|
154
|
-
let namespaces = {};
|
|
155
|
-
if (this.parent) {
|
|
156
|
-
namespaces = this.parent.getXmlns();
|
|
157
|
-
}
|
|
158
|
-
for (const attr in this.attrs) {
|
|
159
|
-
const m = attr.match("xmlns:?(.*)");
|
|
160
|
-
if (this.attrs.hasOwnProperty(attr) && m) {
|
|
161
|
-
namespaces[this.attrs[attr]] = m[1];
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
return namespaces;
|
|
165
|
-
}
|
|
166
|
-
setAttrs(attrs) {
|
|
167
|
-
if (typeof attrs === "string") {
|
|
168
|
-
this.attrs.xmlns = attrs;
|
|
169
|
-
} else if (attrs) {
|
|
170
|
-
Object.assign(this.attrs, attrs);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* xmlns can be null, returns the matching attribute.
|
|
175
|
-
**/
|
|
176
|
-
getAttr(name, xmlns) {
|
|
177
|
-
if (!xmlns) {
|
|
178
|
-
return this.attrs[name];
|
|
179
|
-
}
|
|
180
|
-
const namespaces = this.getXmlns();
|
|
181
|
-
if (!namespaces[xmlns]) {
|
|
182
|
-
return null;
|
|
183
|
-
}
|
|
184
|
-
return this.attrs[[namespaces[xmlns], name].join(":")];
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* xmlns can be null
|
|
188
|
-
**/
|
|
189
|
-
getChild(name, xmlns) {
|
|
190
|
-
return this.getChildren(name, xmlns)[0];
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* xmlns can be null
|
|
194
|
-
**/
|
|
195
|
-
getChildren(name, xmlns) {
|
|
196
|
-
const result = [];
|
|
197
|
-
for (const child of this.children) {
|
|
198
|
-
if (child.getName && child.getName() === name && (!xmlns || child.getNS() === xmlns)) {
|
|
199
|
-
result.push(child);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
return result;
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* xmlns and recursive can be null
|
|
206
|
-
**/
|
|
207
|
-
getChildByAttr(attr, val, xmlns, recursive) {
|
|
208
|
-
return this.getChildrenByAttr(attr, val, xmlns, recursive)[0];
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* xmlns and recursive can be null
|
|
212
|
-
**/
|
|
213
|
-
getChildrenByAttr(attr, val, xmlns, recursive) {
|
|
214
|
-
let result = [];
|
|
215
|
-
for (const child of this.children) {
|
|
216
|
-
if (child.attrs && child.attrs[attr] === val && (!xmlns || child.getNS() === xmlns)) {
|
|
217
|
-
result.push(child);
|
|
218
|
-
}
|
|
219
|
-
if (recursive && child.getChildrenByAttr) {
|
|
220
|
-
result.push(child.getChildrenByAttr(attr, val, xmlns, true));
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
if (recursive) {
|
|
224
|
-
result = result.flat();
|
|
225
|
-
}
|
|
226
|
-
return result;
|
|
227
|
-
}
|
|
228
|
-
getChildrenByFilter(filter, recursive) {
|
|
229
|
-
let result = [];
|
|
230
|
-
for (const child of this.children) {
|
|
231
|
-
if (filter(child)) {
|
|
232
|
-
result.push(child);
|
|
233
|
-
}
|
|
234
|
-
if (recursive && child.getChildrenByFilter) {
|
|
235
|
-
result.push(child.getChildrenByFilter(filter, true));
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
if (recursive) {
|
|
239
|
-
result = result.flat();
|
|
240
|
-
}
|
|
241
|
-
return result;
|
|
242
|
-
}
|
|
243
|
-
getText() {
|
|
244
|
-
let text = "";
|
|
245
|
-
for (const child of this.children) {
|
|
246
|
-
if (typeof child === "string" || typeof child === "number") {
|
|
247
|
-
text += child;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
return text;
|
|
251
|
-
}
|
|
252
|
-
getChildText(name, xmlns) {
|
|
253
|
-
const child = this.getChild(name, xmlns);
|
|
254
|
-
return child ? child.getText() : null;
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* Return all direct descendents that are Elements.
|
|
258
|
-
* This differs from `getChildren` in that it will exclude text nodes,
|
|
259
|
-
* processing instructions, etc.
|
|
260
|
-
*/
|
|
261
|
-
getChildElements() {
|
|
262
|
-
return this.getChildrenByFilter((child) => {
|
|
263
|
-
return child instanceof _Element;
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
/* Builder */
|
|
267
|
-
/** returns uppermost parent */
|
|
268
|
-
root() {
|
|
269
|
-
if (this.parent) {
|
|
270
|
-
return this.parent.root();
|
|
271
|
-
}
|
|
272
|
-
return this;
|
|
273
|
-
}
|
|
274
|
-
/** just parent or itself */
|
|
275
|
-
up() {
|
|
276
|
-
if (this.parent) {
|
|
277
|
-
return this.parent;
|
|
278
|
-
}
|
|
279
|
-
return this;
|
|
280
|
-
}
|
|
281
|
-
/** create child node and return it */
|
|
282
|
-
c(name, attrs) {
|
|
283
|
-
return this.cnode(new _Element(name, attrs));
|
|
284
|
-
}
|
|
285
|
-
cnode(child) {
|
|
286
|
-
this.children.push(child);
|
|
287
|
-
if (typeof child === "object") {
|
|
288
|
-
child.parent = this;
|
|
289
|
-
}
|
|
290
|
-
return child;
|
|
291
|
-
}
|
|
292
|
-
append(...nodes) {
|
|
293
|
-
for (const node of nodes) {
|
|
294
|
-
this.children.push(node);
|
|
295
|
-
if (typeof node === "object") {
|
|
296
|
-
node.parent = this;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
prepend(...nodes) {
|
|
301
|
-
for (const node of nodes) {
|
|
302
|
-
this.children.unshift(node);
|
|
303
|
-
if (typeof node === "object") {
|
|
304
|
-
node.parent = this;
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
/** add text node and return element */
|
|
309
|
-
t(text) {
|
|
310
|
-
this.children.push(text);
|
|
311
|
-
return this;
|
|
312
|
-
}
|
|
313
|
-
/* Manipulation */
|
|
314
|
-
/**
|
|
315
|
-
* Either:
|
|
316
|
-
* el.remove(childEl)
|
|
317
|
-
* el.remove('author', 'urn:...')
|
|
318
|
-
*/
|
|
319
|
-
remove(el, xmlns) {
|
|
320
|
-
const filter = typeof el === "string" ? (child) => {
|
|
321
|
-
return !(child.is && child.is(el, xmlns));
|
|
322
|
-
} : (child) => {
|
|
323
|
-
return child !== el;
|
|
324
|
-
};
|
|
325
|
-
this.children = this.children.filter(filter);
|
|
326
|
-
return this;
|
|
327
|
-
}
|
|
328
|
-
text(val) {
|
|
329
|
-
if (val && this.children.length === 1) {
|
|
330
|
-
this.children[0] = val;
|
|
331
|
-
return this;
|
|
332
|
-
}
|
|
333
|
-
return this.getText();
|
|
334
|
-
}
|
|
335
|
-
attr(attr, val) {
|
|
336
|
-
if (typeof val !== "undefined" || val === null) {
|
|
337
|
-
if (!this.attrs) {
|
|
338
|
-
this.attrs = {};
|
|
339
|
-
}
|
|
340
|
-
this.attrs[attr] = val;
|
|
341
|
-
return this;
|
|
342
|
-
}
|
|
343
|
-
return this.attrs[attr];
|
|
344
|
-
}
|
|
345
|
-
/* Serialization */
|
|
346
|
-
toString() {
|
|
347
|
-
let s = "";
|
|
348
|
-
this.write((c) => {
|
|
349
|
-
s += c;
|
|
350
|
-
});
|
|
351
|
-
return s;
|
|
352
|
-
}
|
|
353
|
-
_addChildren(writer) {
|
|
354
|
-
writer(">");
|
|
355
|
-
for (const child of this.children) {
|
|
356
|
-
if (child != null) {
|
|
357
|
-
if (child.write) {
|
|
358
|
-
child.write(writer);
|
|
359
|
-
} else if (typeof child === "string") {
|
|
360
|
-
writer(escape.escapeXMLText(child));
|
|
361
|
-
} else if (child.toString) {
|
|
362
|
-
writer(escape.escapeXMLText(child.toString(10)));
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
writer("</");
|
|
367
|
-
writer(this.name);
|
|
368
|
-
writer(">");
|
|
369
|
-
}
|
|
370
|
-
write(writer) {
|
|
371
|
-
writer("<");
|
|
372
|
-
writer(this.name);
|
|
373
|
-
for (const k in this.attrs) {
|
|
374
|
-
const v = this.attrs[k];
|
|
375
|
-
if (v != null) {
|
|
376
|
-
writer(" ");
|
|
377
|
-
writer(k);
|
|
378
|
-
writer('="');
|
|
379
|
-
writer(escape.escapeXML(typeof v === "string" ? v : v.toString(10)));
|
|
380
|
-
writer('"');
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
if (this.children.length === 0) {
|
|
384
|
-
writer("/>");
|
|
385
|
-
} else {
|
|
386
|
-
this._addChildren(writer);
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
Element5.prototype.tree = Element5.prototype.root;
|
|
391
|
-
module2.exports = Element5;
|
|
392
|
-
}
|
|
393
|
-
});
|
|
394
|
-
|
|
395
|
-
// node_modules/ltx/lib/createElement.js
|
|
396
|
-
var require_createElement = __commonJS({
|
|
397
|
-
"node_modules/ltx/lib/createElement.js"(exports2, module2) {
|
|
398
|
-
"use strict";
|
|
399
|
-
var Element5 = require_Element();
|
|
400
|
-
function append(el, child) {
|
|
401
|
-
if (Array.isArray(child)) {
|
|
402
|
-
for (const c of child) append(el, c);
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
|
-
if (child === "" || child == null || child === true || child === false) {
|
|
406
|
-
return;
|
|
407
|
-
}
|
|
408
|
-
el.cnode(child);
|
|
409
|
-
}
|
|
410
|
-
function createElement2(name, attrs, ...children) {
|
|
411
|
-
if (typeof attrs === "object" && attrs !== null) {
|
|
412
|
-
delete attrs.__source;
|
|
413
|
-
delete attrs.__self;
|
|
414
|
-
for (const [key, value] of Object.entries(attrs)) {
|
|
415
|
-
if (value == null) delete attrs[key];
|
|
416
|
-
else attrs[key] = value.toString(10);
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
const el = new Element5(name, attrs);
|
|
420
|
-
for (const child of children) {
|
|
421
|
-
append(el, child);
|
|
422
|
-
}
|
|
423
|
-
return el;
|
|
424
|
-
}
|
|
425
|
-
module2.exports = createElement2;
|
|
426
|
-
}
|
|
427
|
-
});
|
|
428
|
-
|
|
429
|
-
// node_modules/ltx/lib/parsers/ltx.js
|
|
430
|
-
var require_ltx = __commonJS({
|
|
431
|
-
"node_modules/ltx/lib/parsers/ltx.js"(exports2, module2) {
|
|
432
|
-
"use strict";
|
|
433
|
-
var events = require("events");
|
|
434
|
-
var escape = require_escape();
|
|
435
|
-
var STATE_TEXT = 0;
|
|
436
|
-
var STATE_IGNORE_COMMENT = 1;
|
|
437
|
-
var STATE_IGNORE_INSTRUCTION = 2;
|
|
438
|
-
var STATE_TAG_NAME = 3;
|
|
439
|
-
var STATE_TAG = 4;
|
|
440
|
-
var STATE_ATTR_NAME = 5;
|
|
441
|
-
var STATE_ATTR_EQ = 6;
|
|
442
|
-
var STATE_ATTR_QUOT = 7;
|
|
443
|
-
var STATE_ATTR_VALUE = 8;
|
|
444
|
-
var STATE_CDATA = 9;
|
|
445
|
-
var STATE_IGNORE_CDATA = 10;
|
|
446
|
-
var SaxLtx = class extends events.EventEmitter {
|
|
447
|
-
constructor() {
|
|
448
|
-
super();
|
|
449
|
-
let state = STATE_TEXT;
|
|
450
|
-
let remainder;
|
|
451
|
-
let parseRemainder;
|
|
452
|
-
let tagName;
|
|
453
|
-
let attrs;
|
|
454
|
-
let endTag;
|
|
455
|
-
let selfClosing;
|
|
456
|
-
let attrQuote;
|
|
457
|
-
let attrQuoteChar;
|
|
458
|
-
let recordStart = 0;
|
|
459
|
-
let attrName;
|
|
460
|
-
this._handleTagOpening = function _handleTagOpening(endTag2, tagName2, attrs2) {
|
|
461
|
-
if (!endTag2) {
|
|
462
|
-
this.emit("startElement", tagName2, attrs2);
|
|
463
|
-
if (selfClosing) {
|
|
464
|
-
this.emit("endElement", tagName2, true);
|
|
465
|
-
}
|
|
466
|
-
} else {
|
|
467
|
-
this.emit("endElement", tagName2, false);
|
|
468
|
-
}
|
|
469
|
-
};
|
|
470
|
-
this.write = function write(data) {
|
|
471
|
-
if (typeof data !== "string") {
|
|
472
|
-
data = data.toString();
|
|
473
|
-
}
|
|
474
|
-
let pos = 0;
|
|
475
|
-
if (remainder) {
|
|
476
|
-
data = remainder + data;
|
|
477
|
-
pos += !parseRemainder ? remainder.length : 0;
|
|
478
|
-
parseRemainder = false;
|
|
479
|
-
remainder = null;
|
|
480
|
-
}
|
|
481
|
-
function endRecording() {
|
|
482
|
-
if (typeof recordStart === "number") {
|
|
483
|
-
const recorded = data.slice(recordStart, pos);
|
|
484
|
-
recordStart = void 0;
|
|
485
|
-
return recorded;
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
for (; pos < data.length; pos++) {
|
|
489
|
-
switch (state) {
|
|
490
|
-
case STATE_TEXT: {
|
|
491
|
-
const lt = data.indexOf("<", pos);
|
|
492
|
-
if (lt !== -1 && pos !== lt) {
|
|
493
|
-
pos = lt;
|
|
494
|
-
}
|
|
495
|
-
break;
|
|
496
|
-
}
|
|
497
|
-
case STATE_ATTR_VALUE: {
|
|
498
|
-
const quot = data.indexOf(attrQuoteChar, pos);
|
|
499
|
-
if (quot !== -1) {
|
|
500
|
-
pos = quot;
|
|
501
|
-
}
|
|
502
|
-
break;
|
|
503
|
-
}
|
|
504
|
-
case STATE_IGNORE_COMMENT: {
|
|
505
|
-
const endcomment = data.indexOf("-->", pos);
|
|
506
|
-
if (endcomment !== -1) {
|
|
507
|
-
pos = endcomment + 2;
|
|
508
|
-
}
|
|
509
|
-
break;
|
|
510
|
-
}
|
|
511
|
-
case STATE_IGNORE_CDATA: {
|
|
512
|
-
const endCDATA = data.indexOf("]]>", pos);
|
|
513
|
-
if (endCDATA !== -1) {
|
|
514
|
-
pos = endCDATA + 2;
|
|
515
|
-
}
|
|
516
|
-
break;
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
const c = data.charCodeAt(pos);
|
|
520
|
-
switch (state) {
|
|
521
|
-
case STATE_TEXT:
|
|
522
|
-
if (c === 60) {
|
|
523
|
-
const text = endRecording();
|
|
524
|
-
if (text) {
|
|
525
|
-
this.emit("text", escape.unescapeXML(text));
|
|
526
|
-
}
|
|
527
|
-
state = STATE_TAG_NAME;
|
|
528
|
-
recordStart = pos + 1;
|
|
529
|
-
attrs = {};
|
|
530
|
-
}
|
|
531
|
-
break;
|
|
532
|
-
case STATE_CDATA:
|
|
533
|
-
if (c === 93) {
|
|
534
|
-
if (data.substr(pos + 1, 2) === "]>") {
|
|
535
|
-
const cData = endRecording();
|
|
536
|
-
if (cData) {
|
|
537
|
-
this.emit("text", cData);
|
|
538
|
-
}
|
|
539
|
-
state = STATE_TEXT;
|
|
540
|
-
} else if (data.length < pos + 2) {
|
|
541
|
-
parseRemainder = true;
|
|
542
|
-
pos = data.length;
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
break;
|
|
546
|
-
case STATE_TAG_NAME:
|
|
547
|
-
if (c === 47 && recordStart === pos) {
|
|
548
|
-
recordStart = pos + 1;
|
|
549
|
-
endTag = true;
|
|
550
|
-
} else if (c === 33) {
|
|
551
|
-
if (data.substr(pos + 1, 7) === "[CDATA[") {
|
|
552
|
-
recordStart = pos + 8;
|
|
553
|
-
state = STATE_CDATA;
|
|
554
|
-
} else if (data.length < pos + 8 && "[CDATA[".startsWith(data.slice(pos + 1))) {
|
|
555
|
-
parseRemainder = true;
|
|
556
|
-
pos = data.length;
|
|
557
|
-
} else {
|
|
558
|
-
recordStart = void 0;
|
|
559
|
-
state = STATE_IGNORE_COMMENT;
|
|
560
|
-
}
|
|
561
|
-
} else if (c === 63) {
|
|
562
|
-
recordStart = void 0;
|
|
563
|
-
state = STATE_IGNORE_INSTRUCTION;
|
|
564
|
-
} else if (c <= 32 || c === 47 || c === 62) {
|
|
565
|
-
tagName = endRecording();
|
|
566
|
-
pos--;
|
|
567
|
-
state = STATE_TAG;
|
|
568
|
-
}
|
|
569
|
-
break;
|
|
570
|
-
case STATE_IGNORE_COMMENT:
|
|
571
|
-
if (c === 62) {
|
|
572
|
-
const prevFirst = data.charCodeAt(pos - 1);
|
|
573
|
-
const prevSecond = data.charCodeAt(pos - 2);
|
|
574
|
-
if (prevFirst === 45 && prevSecond === 45 || prevFirst === 93 && prevSecond === 93) {
|
|
575
|
-
state = STATE_TEXT;
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
break;
|
|
579
|
-
case STATE_IGNORE_INSTRUCTION:
|
|
580
|
-
if (c === 62) {
|
|
581
|
-
const prev = data.charCodeAt(pos - 1);
|
|
582
|
-
if (prev === 63) {
|
|
583
|
-
state = STATE_TEXT;
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
break;
|
|
587
|
-
case STATE_TAG:
|
|
588
|
-
if (c === 62) {
|
|
589
|
-
this._handleTagOpening(endTag, tagName, attrs);
|
|
590
|
-
tagName = void 0;
|
|
591
|
-
attrs = void 0;
|
|
592
|
-
endTag = void 0;
|
|
593
|
-
selfClosing = void 0;
|
|
594
|
-
state = STATE_TEXT;
|
|
595
|
-
recordStart = pos + 1;
|
|
596
|
-
} else if (c === 47) {
|
|
597
|
-
selfClosing = true;
|
|
598
|
-
} else if (c > 32) {
|
|
599
|
-
recordStart = pos;
|
|
600
|
-
state = STATE_ATTR_NAME;
|
|
601
|
-
}
|
|
602
|
-
break;
|
|
603
|
-
case STATE_ATTR_NAME:
|
|
604
|
-
if (c <= 32 || c === 61) {
|
|
605
|
-
attrName = endRecording();
|
|
606
|
-
pos--;
|
|
607
|
-
state = STATE_ATTR_EQ;
|
|
608
|
-
}
|
|
609
|
-
break;
|
|
610
|
-
case STATE_ATTR_EQ:
|
|
611
|
-
if (c === 61) {
|
|
612
|
-
state = STATE_ATTR_QUOT;
|
|
613
|
-
}
|
|
614
|
-
break;
|
|
615
|
-
case STATE_ATTR_QUOT:
|
|
616
|
-
if (c === 34 || c === 39) {
|
|
617
|
-
attrQuote = c;
|
|
618
|
-
attrQuoteChar = c === 34 ? '"' : "'";
|
|
619
|
-
state = STATE_ATTR_VALUE;
|
|
620
|
-
recordStart = pos + 1;
|
|
621
|
-
}
|
|
622
|
-
break;
|
|
623
|
-
case STATE_ATTR_VALUE:
|
|
624
|
-
if (c === attrQuote) {
|
|
625
|
-
const value = escape.unescapeXML(endRecording());
|
|
626
|
-
attrs[attrName] = value;
|
|
627
|
-
attrName = void 0;
|
|
628
|
-
state = STATE_TAG;
|
|
629
|
-
}
|
|
630
|
-
break;
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
if (typeof recordStart === "number" && recordStart <= data.length) {
|
|
634
|
-
remainder = data.slice(recordStart);
|
|
635
|
-
recordStart = 0;
|
|
636
|
-
}
|
|
637
|
-
};
|
|
638
|
-
}
|
|
639
|
-
end(data) {
|
|
640
|
-
if (data) {
|
|
641
|
-
this.write(data);
|
|
642
|
-
}
|
|
643
|
-
this.write = function write() {
|
|
644
|
-
};
|
|
645
|
-
}
|
|
646
|
-
};
|
|
647
|
-
module2.exports = SaxLtx;
|
|
648
|
-
}
|
|
649
|
-
});
|
|
650
|
-
|
|
651
29
|
// src/index.ts
|
|
652
30
|
var index_exports = {};
|
|
653
31
|
__export(index_exports, {
|
|
@@ -1982,109 +1360,13 @@ var SmuleUrls;
|
|
|
1982
1360
|
]);
|
|
1983
1361
|
})(SmuleUrls || (SmuleUrls = {}));
|
|
1984
1362
|
|
|
1985
|
-
// node_modules/@xmpp/xml/index.js
|
|
1986
|
-
var import_Element2 = __toESM(require_Element(), 1);
|
|
1987
|
-
var import_createElement = __toESM(require_createElement(), 1);
|
|
1988
|
-
var import_escape = __toESM(require_escape(), 1);
|
|
1989
|
-
|
|
1990
|
-
// node_modules/@xmpp/xml/lib/Parser.js
|
|
1991
|
-
var import_ltx = __toESM(require_ltx(), 1);
|
|
1992
|
-
var import_Element = __toESM(require_Element(), 1);
|
|
1993
|
-
|
|
1994
|
-
// node_modules/@xmpp/events/index.js
|
|
1995
|
-
var import_events = require("events");
|
|
1996
|
-
|
|
1997
|
-
// node_modules/@xmpp/xml/lib/XMLError.js
|
|
1998
|
-
var XMLError = class extends Error {
|
|
1999
|
-
constructor(...args) {
|
|
2000
|
-
super(...args);
|
|
2001
|
-
this.name = "XMLError";
|
|
2002
|
-
}
|
|
2003
|
-
};
|
|
2004
|
-
|
|
2005
|
-
// node_modules/@xmpp/xml/lib/Parser.js
|
|
2006
|
-
var Parser = class extends import_events.EventEmitter {
|
|
2007
|
-
constructor() {
|
|
2008
|
-
super();
|
|
2009
|
-
const parser = new import_ltx.default();
|
|
2010
|
-
this.root = null;
|
|
2011
|
-
this.cursor = null;
|
|
2012
|
-
parser.on("startElement", this.onStartElement.bind(this));
|
|
2013
|
-
parser.on("endElement", this.onEndElement.bind(this));
|
|
2014
|
-
parser.on("text", this.onText.bind(this));
|
|
2015
|
-
this.parser = parser;
|
|
2016
|
-
}
|
|
2017
|
-
onStartElement(name, attrs) {
|
|
2018
|
-
const element = new import_Element.default(name, attrs);
|
|
2019
|
-
const { root, cursor } = this;
|
|
2020
|
-
if (!root) {
|
|
2021
|
-
this.root = element;
|
|
2022
|
-
this.emit("start", element);
|
|
2023
|
-
} else if (cursor !== root) {
|
|
2024
|
-
cursor.append(element);
|
|
2025
|
-
}
|
|
2026
|
-
this.cursor = element;
|
|
2027
|
-
}
|
|
2028
|
-
onEndElement(name) {
|
|
2029
|
-
const { root, cursor } = this;
|
|
2030
|
-
if (name !== cursor.name) {
|
|
2031
|
-
this.emit("error", new XMLError(`${cursor.name} must be closed.`));
|
|
2032
|
-
return;
|
|
2033
|
-
}
|
|
2034
|
-
if (cursor === root) {
|
|
2035
|
-
this.emit("end", root);
|
|
2036
|
-
return;
|
|
2037
|
-
}
|
|
2038
|
-
if (!cursor.parent) {
|
|
2039
|
-
cursor.parent = root;
|
|
2040
|
-
this.emit("element", cursor);
|
|
2041
|
-
this.cursor = root;
|
|
2042
|
-
return;
|
|
2043
|
-
}
|
|
2044
|
-
this.cursor = cursor.parent;
|
|
2045
|
-
}
|
|
2046
|
-
onText(str) {
|
|
2047
|
-
const { cursor } = this;
|
|
2048
|
-
if (!cursor) {
|
|
2049
|
-
this.emit("error", new XMLError(`${str} must be a child.`));
|
|
2050
|
-
return;
|
|
2051
|
-
}
|
|
2052
|
-
cursor.t(str);
|
|
2053
|
-
}
|
|
2054
|
-
write(data) {
|
|
2055
|
-
this.parser.write(data);
|
|
2056
|
-
}
|
|
2057
|
-
end(data) {
|
|
2058
|
-
if (data) {
|
|
2059
|
-
this.parser.write(data);
|
|
2060
|
-
}
|
|
2061
|
-
}
|
|
2062
|
-
};
|
|
2063
|
-
Parser.XMLError = XMLError;
|
|
2064
|
-
var Parser_default = Parser;
|
|
2065
|
-
|
|
2066
|
-
// node_modules/@xmpp/xml/index.js
|
|
2067
|
-
function xml(...args) {
|
|
2068
|
-
return (0, import_createElement.default)(...args);
|
|
2069
|
-
}
|
|
2070
|
-
Object.assign(xml, {
|
|
2071
|
-
Element: import_Element2.default,
|
|
2072
|
-
createElement: import_createElement.default,
|
|
2073
|
-
Parser: Parser_default,
|
|
2074
|
-
escapeXML: import_escape.escapeXML,
|
|
2075
|
-
unescapeXML: import_escape.unescapeXML,
|
|
2076
|
-
escapeXMLText: import_escape.escapeXMLText,
|
|
2077
|
-
unescapeXMLText: import_escape.unescapeXMLText,
|
|
2078
|
-
XMLError,
|
|
2079
|
-
xml
|
|
2080
|
-
});
|
|
2081
|
-
|
|
2082
1363
|
// src/smule-live-chat.ts
|
|
2083
|
-
var
|
|
1364
|
+
var import_xml = require("@xmpp/xml");
|
|
1365
|
+
var import_events = __toESM(require("events"), 1);
|
|
2084
1366
|
var import_jid = require("@xmpp/jid");
|
|
2085
1367
|
var import_crypto2 = require("crypto");
|
|
2086
1368
|
var SmuleLiveChat = class {
|
|
2087
|
-
events = new
|
|
1369
|
+
events = new import_events.default();
|
|
2088
1370
|
state = "closed";
|
|
2089
1371
|
client;
|
|
2090
1372
|
jid;
|
|
@@ -2886,11 +2168,12 @@ var SmuleMIDI;
|
|
|
2886
2168
|
|
|
2887
2169
|
// src/smule-chat.ts
|
|
2888
2170
|
var import_client2 = require("@xmpp/client");
|
|
2889
|
-
var
|
|
2171
|
+
var import_xml2 = require("@xmpp/xml");
|
|
2172
|
+
var import_events2 = __toESM(require("events"), 1);
|
|
2890
2173
|
var import_jid2 = require("@xmpp/jid");
|
|
2891
2174
|
var import_crypto3 = require("crypto");
|
|
2892
2175
|
var SmuleChat = class {
|
|
2893
|
-
events = new
|
|
2176
|
+
events = new import_events2.default();
|
|
2894
2177
|
state = "closed";
|
|
2895
2178
|
client;
|
|
2896
2179
|
jid;
|