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.
Files changed (3) hide show
  1. package/dist/index.cjs +6 -723
  2. package/dist/index.js +37 -783
  3. package/package.json +65 -63
package/dist/index.js CHANGED
@@ -1,654 +1,3 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
- }) : x)(function(x) {
10
- if (typeof require !== "undefined") return require.apply(this, arguments);
11
- throw Error('Dynamic require of "' + x + '" is not supported');
12
- });
13
- var __commonJS = (cb, mod) => function __require2() {
14
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
- };
16
- var __copyProps = (to, from, except, desc) => {
17
- if (from && typeof from === "object" || typeof from === "function") {
18
- for (let key of __getOwnPropNames(from))
19
- if (!__hasOwnProp.call(to, key) && key !== except)
20
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
- }
22
- return to;
23
- };
24
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
- // If the importer is in node compatibility mode or this is not an ESM
26
- // file that has been converted to a CommonJS file using a Babel-
27
- // compatible transform (i.e. "__esModule" has not been set), then set
28
- // "default" to the CommonJS "module.exports" for node compatibility.
29
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
- mod
31
- ));
32
-
33
- // node_modules/ltx/lib/escape.js
34
- var require_escape = __commonJS({
35
- "node_modules/ltx/lib/escape.js"(exports) {
36
- "use strict";
37
- var escapeXMLTable = {
38
- "&": "&",
39
- "<": "&lt;",
40
- ">": "&gt;",
41
- '"': "&quot;",
42
- "'": "&apos;"
43
- };
44
- function escapeXMLReplace(match) {
45
- return escapeXMLTable[match];
46
- }
47
- var unescapeXMLTable = {
48
- "&amp;": "&",
49
- "&lt;": "<",
50
- "&gt;": ">",
51
- "&quot;": '"',
52
- "&apos;": "'"
53
- };
54
- function unescapeXMLReplace(match) {
55
- if (match[1] === "#") {
56
- const num = match[2] === "x" ? parseInt(match.slice(3), 16) : parseInt(match.slice(2), 10);
57
- if (num === 9 || num === 10 || num === 13 || num >= 32 && num <= 55295 || num >= 57344 && num <= 65533 || num >= 65536 && num <= 1114111) {
58
- return String.fromCodePoint(num);
59
- }
60
- throw new Error("Illegal XML character 0x" + num.toString(16));
61
- }
62
- if (unescapeXMLTable[match]) {
63
- return unescapeXMLTable[match] || match;
64
- }
65
- throw new Error("Illegal XML entity " + match);
66
- }
67
- function escapeXML2(s) {
68
- return s.replace(/["&'<>]/g, escapeXMLReplace);
69
- }
70
- function unescapeXML2(s) {
71
- let result = "";
72
- let start = -1;
73
- let end = -1;
74
- let previous = 0;
75
- while ((start = s.indexOf("&", previous)) !== -1 && (end = s.indexOf(";", start + 1)) !== -1) {
76
- result = result + s.slice(previous, start) + unescapeXMLReplace(s.slice(start, end + 1));
77
- previous = end + 1;
78
- }
79
- if (previous === 0) return s;
80
- result = result + s.substring(previous);
81
- return result;
82
- }
83
- function escapeXMLText2(s) {
84
- return s.replace(/[&<>]/g, escapeXMLReplace);
85
- }
86
- function unescapeXMLText2(s) {
87
- return s.replace(/&(amp|#38|lt|#60|gt|#62);/g, unescapeXMLReplace);
88
- }
89
- exports.escapeXML = escapeXML2;
90
- exports.escapeXMLText = escapeXMLText2;
91
- exports.unescapeXML = unescapeXML2;
92
- exports.unescapeXMLText = unescapeXMLText2;
93
- }
94
- });
95
-
96
- // node_modules/ltx/lib/Element.js
97
- var require_Element = __commonJS({
98
- "node_modules/ltx/lib/Element.js"(exports, module) {
99
- "use strict";
100
- var escape = require_escape();
101
- var Element5 = class _Element {
102
- constructor(name, attrs) {
103
- this.name = name;
104
- this.parent = null;
105
- this.children = [];
106
- this.attrs = {};
107
- this.setAttrs(attrs);
108
- }
109
- /* Accessors */
110
- /**
111
- * if (element.is('message', 'jabber:client')) ...
112
- **/
113
- is(name, xmlns) {
114
- return this.getName() === name && (!xmlns || this.getNS() === xmlns);
115
- }
116
- /* without prefix */
117
- getName() {
118
- const idx = this.name.indexOf(":");
119
- return idx >= 0 ? this.name.slice(idx + 1) : this.name;
120
- }
121
- /**
122
- * retrieves the namespace of the current element, upwards recursively
123
- **/
124
- getNS() {
125
- const idx = this.name.indexOf(":");
126
- if (idx >= 0) {
127
- const prefix = this.name.slice(0, idx);
128
- return this.findNS(prefix);
129
- }
130
- return this.findNS();
131
- }
132
- /**
133
- * find the namespace to the given prefix, upwards recursively
134
- **/
135
- findNS(prefix) {
136
- if (!prefix) {
137
- if (this.attrs.xmlns) {
138
- return this.attrs.xmlns;
139
- } else if (this.parent) {
140
- return this.parent.findNS();
141
- }
142
- } else {
143
- const attr = "xmlns:" + prefix;
144
- if (this.attrs[attr]) {
145
- return this.attrs[attr];
146
- } else if (this.parent) {
147
- return this.parent.findNS(prefix);
148
- }
149
- }
150
- }
151
- /**
152
- * Recursiverly gets all xmlns defined, in the form of {url:prefix}
153
- **/
154
- getXmlns() {
155
- let namespaces = {};
156
- if (this.parent) {
157
- namespaces = this.parent.getXmlns();
158
- }
159
- for (const attr in this.attrs) {
160
- const m = attr.match("xmlns:?(.*)");
161
- if (this.attrs.hasOwnProperty(attr) && m) {
162
- namespaces[this.attrs[attr]] = m[1];
163
- }
164
- }
165
- return namespaces;
166
- }
167
- setAttrs(attrs) {
168
- if (typeof attrs === "string") {
169
- this.attrs.xmlns = attrs;
170
- } else if (attrs) {
171
- Object.assign(this.attrs, attrs);
172
- }
173
- }
174
- /**
175
- * xmlns can be null, returns the matching attribute.
176
- **/
177
- getAttr(name, xmlns) {
178
- if (!xmlns) {
179
- return this.attrs[name];
180
- }
181
- const namespaces = this.getXmlns();
182
- if (!namespaces[xmlns]) {
183
- return null;
184
- }
185
- return this.attrs[[namespaces[xmlns], name].join(":")];
186
- }
187
- /**
188
- * xmlns can be null
189
- **/
190
- getChild(name, xmlns) {
191
- return this.getChildren(name, xmlns)[0];
192
- }
193
- /**
194
- * xmlns can be null
195
- **/
196
- getChildren(name, xmlns) {
197
- const result = [];
198
- for (const child of this.children) {
199
- if (child.getName && child.getName() === name && (!xmlns || child.getNS() === xmlns)) {
200
- result.push(child);
201
- }
202
- }
203
- return result;
204
- }
205
- /**
206
- * xmlns and recursive can be null
207
- **/
208
- getChildByAttr(attr, val, xmlns, recursive) {
209
- return this.getChildrenByAttr(attr, val, xmlns, recursive)[0];
210
- }
211
- /**
212
- * xmlns and recursive can be null
213
- **/
214
- getChildrenByAttr(attr, val, xmlns, recursive) {
215
- let result = [];
216
- for (const child of this.children) {
217
- if (child.attrs && child.attrs[attr] === val && (!xmlns || child.getNS() === xmlns)) {
218
- result.push(child);
219
- }
220
- if (recursive && child.getChildrenByAttr) {
221
- result.push(child.getChildrenByAttr(attr, val, xmlns, true));
222
- }
223
- }
224
- if (recursive) {
225
- result = result.flat();
226
- }
227
- return result;
228
- }
229
- getChildrenByFilter(filter, recursive) {
230
- let result = [];
231
- for (const child of this.children) {
232
- if (filter(child)) {
233
- result.push(child);
234
- }
235
- if (recursive && child.getChildrenByFilter) {
236
- result.push(child.getChildrenByFilter(filter, true));
237
- }
238
- }
239
- if (recursive) {
240
- result = result.flat();
241
- }
242
- return result;
243
- }
244
- getText() {
245
- let text = "";
246
- for (const child of this.children) {
247
- if (typeof child === "string" || typeof child === "number") {
248
- text += child;
249
- }
250
- }
251
- return text;
252
- }
253
- getChildText(name, xmlns) {
254
- const child = this.getChild(name, xmlns);
255
- return child ? child.getText() : null;
256
- }
257
- /**
258
- * Return all direct descendents that are Elements.
259
- * This differs from `getChildren` in that it will exclude text nodes,
260
- * processing instructions, etc.
261
- */
262
- getChildElements() {
263
- return this.getChildrenByFilter((child) => {
264
- return child instanceof _Element;
265
- });
266
- }
267
- /* Builder */
268
- /** returns uppermost parent */
269
- root() {
270
- if (this.parent) {
271
- return this.parent.root();
272
- }
273
- return this;
274
- }
275
- /** just parent or itself */
276
- up() {
277
- if (this.parent) {
278
- return this.parent;
279
- }
280
- return this;
281
- }
282
- /** create child node and return it */
283
- c(name, attrs) {
284
- return this.cnode(new _Element(name, attrs));
285
- }
286
- cnode(child) {
287
- this.children.push(child);
288
- if (typeof child === "object") {
289
- child.parent = this;
290
- }
291
- return child;
292
- }
293
- append(...nodes) {
294
- for (const node of nodes) {
295
- this.children.push(node);
296
- if (typeof node === "object") {
297
- node.parent = this;
298
- }
299
- }
300
- }
301
- prepend(...nodes) {
302
- for (const node of nodes) {
303
- this.children.unshift(node);
304
- if (typeof node === "object") {
305
- node.parent = this;
306
- }
307
- }
308
- }
309
- /** add text node and return element */
310
- t(text) {
311
- this.children.push(text);
312
- return this;
313
- }
314
- /* Manipulation */
315
- /**
316
- * Either:
317
- * el.remove(childEl)
318
- * el.remove('author', 'urn:...')
319
- */
320
- remove(el, xmlns) {
321
- const filter = typeof el === "string" ? (child) => {
322
- return !(child.is && child.is(el, xmlns));
323
- } : (child) => {
324
- return child !== el;
325
- };
326
- this.children = this.children.filter(filter);
327
- return this;
328
- }
329
- text(val) {
330
- if (val && this.children.length === 1) {
331
- this.children[0] = val;
332
- return this;
333
- }
334
- return this.getText();
335
- }
336
- attr(attr, val) {
337
- if (typeof val !== "undefined" || val === null) {
338
- if (!this.attrs) {
339
- this.attrs = {};
340
- }
341
- this.attrs[attr] = val;
342
- return this;
343
- }
344
- return this.attrs[attr];
345
- }
346
- /* Serialization */
347
- toString() {
348
- let s = "";
349
- this.write((c) => {
350
- s += c;
351
- });
352
- return s;
353
- }
354
- _addChildren(writer) {
355
- writer(">");
356
- for (const child of this.children) {
357
- if (child != null) {
358
- if (child.write) {
359
- child.write(writer);
360
- } else if (typeof child === "string") {
361
- writer(escape.escapeXMLText(child));
362
- } else if (child.toString) {
363
- writer(escape.escapeXMLText(child.toString(10)));
364
- }
365
- }
366
- }
367
- writer("</");
368
- writer(this.name);
369
- writer(">");
370
- }
371
- write(writer) {
372
- writer("<");
373
- writer(this.name);
374
- for (const k in this.attrs) {
375
- const v = this.attrs[k];
376
- if (v != null) {
377
- writer(" ");
378
- writer(k);
379
- writer('="');
380
- writer(escape.escapeXML(typeof v === "string" ? v : v.toString(10)));
381
- writer('"');
382
- }
383
- }
384
- if (this.children.length === 0) {
385
- writer("/>");
386
- } else {
387
- this._addChildren(writer);
388
- }
389
- }
390
- };
391
- Element5.prototype.tree = Element5.prototype.root;
392
- module.exports = Element5;
393
- }
394
- });
395
-
396
- // node_modules/ltx/lib/createElement.js
397
- var require_createElement = __commonJS({
398
- "node_modules/ltx/lib/createElement.js"(exports, module) {
399
- "use strict";
400
- var Element5 = require_Element();
401
- function append(el, child) {
402
- if (Array.isArray(child)) {
403
- for (const c of child) append(el, c);
404
- return;
405
- }
406
- if (child === "" || child == null || child === true || child === false) {
407
- return;
408
- }
409
- el.cnode(child);
410
- }
411
- function createElement2(name, attrs, ...children) {
412
- if (typeof attrs === "object" && attrs !== null) {
413
- delete attrs.__source;
414
- delete attrs.__self;
415
- for (const [key, value] of Object.entries(attrs)) {
416
- if (value == null) delete attrs[key];
417
- else attrs[key] = value.toString(10);
418
- }
419
- }
420
- const el = new Element5(name, attrs);
421
- for (const child of children) {
422
- append(el, child);
423
- }
424
- return el;
425
- }
426
- module.exports = createElement2;
427
- }
428
- });
429
-
430
- // node_modules/ltx/lib/parsers/ltx.js
431
- var require_ltx = __commonJS({
432
- "node_modules/ltx/lib/parsers/ltx.js"(exports, module) {
433
- "use strict";
434
- var events = __require("events");
435
- var escape = require_escape();
436
- var STATE_TEXT = 0;
437
- var STATE_IGNORE_COMMENT = 1;
438
- var STATE_IGNORE_INSTRUCTION = 2;
439
- var STATE_TAG_NAME = 3;
440
- var STATE_TAG = 4;
441
- var STATE_ATTR_NAME = 5;
442
- var STATE_ATTR_EQ = 6;
443
- var STATE_ATTR_QUOT = 7;
444
- var STATE_ATTR_VALUE = 8;
445
- var STATE_CDATA = 9;
446
- var STATE_IGNORE_CDATA = 10;
447
- var SaxLtx = class extends events.EventEmitter {
448
- constructor() {
449
- super();
450
- let state = STATE_TEXT;
451
- let remainder;
452
- let parseRemainder;
453
- let tagName;
454
- let attrs;
455
- let endTag;
456
- let selfClosing;
457
- let attrQuote;
458
- let attrQuoteChar;
459
- let recordStart = 0;
460
- let attrName;
461
- this._handleTagOpening = function _handleTagOpening(endTag2, tagName2, attrs2) {
462
- if (!endTag2) {
463
- this.emit("startElement", tagName2, attrs2);
464
- if (selfClosing) {
465
- this.emit("endElement", tagName2, true);
466
- }
467
- } else {
468
- this.emit("endElement", tagName2, false);
469
- }
470
- };
471
- this.write = function write(data) {
472
- if (typeof data !== "string") {
473
- data = data.toString();
474
- }
475
- let pos = 0;
476
- if (remainder) {
477
- data = remainder + data;
478
- pos += !parseRemainder ? remainder.length : 0;
479
- parseRemainder = false;
480
- remainder = null;
481
- }
482
- function endRecording() {
483
- if (typeof recordStart === "number") {
484
- const recorded = data.slice(recordStart, pos);
485
- recordStart = void 0;
486
- return recorded;
487
- }
488
- }
489
- for (; pos < data.length; pos++) {
490
- switch (state) {
491
- case STATE_TEXT: {
492
- const lt = data.indexOf("<", pos);
493
- if (lt !== -1 && pos !== lt) {
494
- pos = lt;
495
- }
496
- break;
497
- }
498
- case STATE_ATTR_VALUE: {
499
- const quot = data.indexOf(attrQuoteChar, pos);
500
- if (quot !== -1) {
501
- pos = quot;
502
- }
503
- break;
504
- }
505
- case STATE_IGNORE_COMMENT: {
506
- const endcomment = data.indexOf("-->", pos);
507
- if (endcomment !== -1) {
508
- pos = endcomment + 2;
509
- }
510
- break;
511
- }
512
- case STATE_IGNORE_CDATA: {
513
- const endCDATA = data.indexOf("]]>", pos);
514
- if (endCDATA !== -1) {
515
- pos = endCDATA + 2;
516
- }
517
- break;
518
- }
519
- }
520
- const c = data.charCodeAt(pos);
521
- switch (state) {
522
- case STATE_TEXT:
523
- if (c === 60) {
524
- const text = endRecording();
525
- if (text) {
526
- this.emit("text", escape.unescapeXML(text));
527
- }
528
- state = STATE_TAG_NAME;
529
- recordStart = pos + 1;
530
- attrs = {};
531
- }
532
- break;
533
- case STATE_CDATA:
534
- if (c === 93) {
535
- if (data.substr(pos + 1, 2) === "]>") {
536
- const cData = endRecording();
537
- if (cData) {
538
- this.emit("text", cData);
539
- }
540
- state = STATE_TEXT;
541
- } else if (data.length < pos + 2) {
542
- parseRemainder = true;
543
- pos = data.length;
544
- }
545
- }
546
- break;
547
- case STATE_TAG_NAME:
548
- if (c === 47 && recordStart === pos) {
549
- recordStart = pos + 1;
550
- endTag = true;
551
- } else if (c === 33) {
552
- if (data.substr(pos + 1, 7) === "[CDATA[") {
553
- recordStart = pos + 8;
554
- state = STATE_CDATA;
555
- } else if (data.length < pos + 8 && "[CDATA[".startsWith(data.slice(pos + 1))) {
556
- parseRemainder = true;
557
- pos = data.length;
558
- } else {
559
- recordStart = void 0;
560
- state = STATE_IGNORE_COMMENT;
561
- }
562
- } else if (c === 63) {
563
- recordStart = void 0;
564
- state = STATE_IGNORE_INSTRUCTION;
565
- } else if (c <= 32 || c === 47 || c === 62) {
566
- tagName = endRecording();
567
- pos--;
568
- state = STATE_TAG;
569
- }
570
- break;
571
- case STATE_IGNORE_COMMENT:
572
- if (c === 62) {
573
- const prevFirst = data.charCodeAt(pos - 1);
574
- const prevSecond = data.charCodeAt(pos - 2);
575
- if (prevFirst === 45 && prevSecond === 45 || prevFirst === 93 && prevSecond === 93) {
576
- state = STATE_TEXT;
577
- }
578
- }
579
- break;
580
- case STATE_IGNORE_INSTRUCTION:
581
- if (c === 62) {
582
- const prev = data.charCodeAt(pos - 1);
583
- if (prev === 63) {
584
- state = STATE_TEXT;
585
- }
586
- }
587
- break;
588
- case STATE_TAG:
589
- if (c === 62) {
590
- this._handleTagOpening(endTag, tagName, attrs);
591
- tagName = void 0;
592
- attrs = void 0;
593
- endTag = void 0;
594
- selfClosing = void 0;
595
- state = STATE_TEXT;
596
- recordStart = pos + 1;
597
- } else if (c === 47) {
598
- selfClosing = true;
599
- } else if (c > 32) {
600
- recordStart = pos;
601
- state = STATE_ATTR_NAME;
602
- }
603
- break;
604
- case STATE_ATTR_NAME:
605
- if (c <= 32 || c === 61) {
606
- attrName = endRecording();
607
- pos--;
608
- state = STATE_ATTR_EQ;
609
- }
610
- break;
611
- case STATE_ATTR_EQ:
612
- if (c === 61) {
613
- state = STATE_ATTR_QUOT;
614
- }
615
- break;
616
- case STATE_ATTR_QUOT:
617
- if (c === 34 || c === 39) {
618
- attrQuote = c;
619
- attrQuoteChar = c === 34 ? '"' : "'";
620
- state = STATE_ATTR_VALUE;
621
- recordStart = pos + 1;
622
- }
623
- break;
624
- case STATE_ATTR_VALUE:
625
- if (c === attrQuote) {
626
- const value = escape.unescapeXML(endRecording());
627
- attrs[attrName] = value;
628
- attrName = void 0;
629
- state = STATE_TAG;
630
- }
631
- break;
632
- }
633
- }
634
- if (typeof recordStart === "number" && recordStart <= data.length) {
635
- remainder = data.slice(recordStart);
636
- recordStart = 0;
637
- }
638
- };
639
- }
640
- end(data) {
641
- if (data) {
642
- this.write(data);
643
- }
644
- this.write = function write() {
645
- };
646
- }
647
- };
648
- module.exports = SaxLtx;
649
- }
650
- });
651
-
652
1
  // src/types/smule-requests.ts
653
2
  import { randomUUID } from "crypto";
654
3
  var Device = class {
@@ -1315,7 +664,7 @@ var SmuleUtil;
1315
664
  import axios from "axios";
1316
665
 
1317
666
  // src/smule-live-chat.ts
1318
- import { client, xml as xml2 } from "@xmpp/client";
667
+ import { client, xml } from "@xmpp/client";
1319
668
 
1320
669
  // src/smule-urls.ts
1321
670
  var SmuleUrls;
@@ -1948,109 +1297,13 @@ var SmuleUrls;
1948
1297
  ]);
1949
1298
  })(SmuleUrls || (SmuleUrls = {}));
1950
1299
 
1951
- // node_modules/@xmpp/xml/index.js
1952
- var import_Element2 = __toESM(require_Element(), 1);
1953
- var import_createElement = __toESM(require_createElement(), 1);
1954
- var import_escape = __toESM(require_escape(), 1);
1955
-
1956
- // node_modules/@xmpp/xml/lib/Parser.js
1957
- var import_ltx = __toESM(require_ltx(), 1);
1958
- var import_Element = __toESM(require_Element(), 1);
1959
-
1960
- // node_modules/@xmpp/events/index.js
1961
- import { EventEmitter } from "events";
1962
-
1963
- // node_modules/@xmpp/xml/lib/XMLError.js
1964
- var XMLError = class extends Error {
1965
- constructor(...args) {
1966
- super(...args);
1967
- this.name = "XMLError";
1968
- }
1969
- };
1970
-
1971
- // node_modules/@xmpp/xml/lib/Parser.js
1972
- var Parser = class extends EventEmitter {
1973
- constructor() {
1974
- super();
1975
- const parser = new import_ltx.default();
1976
- this.root = null;
1977
- this.cursor = null;
1978
- parser.on("startElement", this.onStartElement.bind(this));
1979
- parser.on("endElement", this.onEndElement.bind(this));
1980
- parser.on("text", this.onText.bind(this));
1981
- this.parser = parser;
1982
- }
1983
- onStartElement(name, attrs) {
1984
- const element = new import_Element.default(name, attrs);
1985
- const { root, cursor } = this;
1986
- if (!root) {
1987
- this.root = element;
1988
- this.emit("start", element);
1989
- } else if (cursor !== root) {
1990
- cursor.append(element);
1991
- }
1992
- this.cursor = element;
1993
- }
1994
- onEndElement(name) {
1995
- const { root, cursor } = this;
1996
- if (name !== cursor.name) {
1997
- this.emit("error", new XMLError(`${cursor.name} must be closed.`));
1998
- return;
1999
- }
2000
- if (cursor === root) {
2001
- this.emit("end", root);
2002
- return;
2003
- }
2004
- if (!cursor.parent) {
2005
- cursor.parent = root;
2006
- this.emit("element", cursor);
2007
- this.cursor = root;
2008
- return;
2009
- }
2010
- this.cursor = cursor.parent;
2011
- }
2012
- onText(str) {
2013
- const { cursor } = this;
2014
- if (!cursor) {
2015
- this.emit("error", new XMLError(`${str} must be a child.`));
2016
- return;
2017
- }
2018
- cursor.t(str);
2019
- }
2020
- write(data) {
2021
- this.parser.write(data);
2022
- }
2023
- end(data) {
2024
- if (data) {
2025
- this.parser.write(data);
2026
- }
2027
- }
2028
- };
2029
- Parser.XMLError = XMLError;
2030
- var Parser_default = Parser;
2031
-
2032
- // node_modules/@xmpp/xml/index.js
2033
- function xml(...args) {
2034
- return (0, import_createElement.default)(...args);
2035
- }
2036
- Object.assign(xml, {
2037
- Element: import_Element2.default,
2038
- createElement: import_createElement.default,
2039
- Parser: Parser_default,
2040
- escapeXML: import_escape.escapeXML,
2041
- unescapeXML: import_escape.unescapeXML,
2042
- escapeXMLText: import_escape.escapeXMLText,
2043
- unescapeXMLText: import_escape.unescapeXMLText,
2044
- XMLError,
2045
- xml
2046
- });
2047
-
2048
1300
  // src/smule-live-chat.ts
2049
- import EventEmitter2 from "events";
1301
+ import "@xmpp/xml";
1302
+ import EventEmitter from "events";
2050
1303
  import "@xmpp/jid";
2051
1304
  import { randomUUID as randomUUID2 } from "crypto";
2052
1305
  var SmuleLiveChat = class {
2053
- events = new EventEmitter2();
1306
+ events = new EventEmitter();
2054
1307
  state = "closed";
2055
1308
  client;
2056
1309
  jid;
@@ -2090,16 +1343,16 @@ var SmuleLiveChat = class {
2090
1343
  this.jid = await this.client.start();
2091
1344
  this._log("Connected as:", this.jid.getLocal() + "@" + this.jid.getDomain());
2092
1345
  this.client.send(
2093
- xml2(
1346
+ xml(
2094
1347
  "presence",
2095
1348
  { to: this.roomJID + "/" + this.jid.getLocal() },
2096
- xml2(
1349
+ xml(
2097
1350
  "x",
2098
1351
  { xmlns: "http://jabber.org/protocol/muc" },
2099
- xml2(
1352
+ xml(
2100
1353
  "password"
2101
1354
  ),
2102
- xml2(
1355
+ xml(
2103
1356
  "history",
2104
1357
  { maxstanzas: "1" }
2105
1358
  )
@@ -2120,7 +1373,7 @@ var SmuleLiveChat = class {
2120
1373
  */
2121
1374
  async disconnect() {
2122
1375
  try {
2123
- await this.client.send(xml2("presence", { type: "unavailable" }));
1376
+ await this.client.send(xml("presence", { type: "unavailable" }));
2124
1377
  await this.client.stop();
2125
1378
  } catch {
2126
1379
  }
@@ -2129,7 +1382,7 @@ var SmuleLiveChat = class {
2129
1382
  const id = randomUUID2();
2130
1383
  this.iqs[id] = callback;
2131
1384
  this.client.send(
2132
- xml2(
1385
+ xml(
2133
1386
  "iq",
2134
1387
  { from: this.jid.toString(), to: this.roomJID, type: iqType, id },
2135
1388
  data
@@ -2138,7 +1391,7 @@ var SmuleLiveChat = class {
2138
1391
  }
2139
1392
  sendIqQuery(xmlns, callback, iqType = "get") {
2140
1393
  this.sendIq(
2141
- xml2("query", { xmlns }),
1394
+ xml("query", { xmlns }),
2142
1395
  callback,
2143
1396
  iqType
2144
1397
  );
@@ -2149,10 +1402,10 @@ var SmuleLiveChat = class {
2149
1402
  */
2150
1403
  async sendTextMessage(message) {
2151
1404
  await this.client.send(
2152
- xml2(
1405
+ xml(
2153
1406
  "message",
2154
1407
  { to: this.roomJID, type: "groupchat" },
2155
- xml2("body", {}, message)
1408
+ xml("body", {}, message)
2156
1409
  )
2157
1410
  );
2158
1411
  }
@@ -2851,12 +2104,13 @@ var SmuleMIDI;
2851
2104
  })(SmuleMIDI || (SmuleMIDI = {}));
2852
2105
 
2853
2106
  // src/smule-chat.ts
2854
- import { client as client2, xml as xml3 } from "@xmpp/client";
2855
- import EventEmitter3 from "events";
2107
+ import { client as client2, xml as xml2 } from "@xmpp/client";
2108
+ import "@xmpp/xml";
2109
+ import EventEmitter2 from "events";
2856
2110
  import "@xmpp/jid";
2857
2111
  import { randomUUID as randomUUID3 } from "crypto";
2858
2112
  var SmuleChat = class {
2859
- events = new EventEmitter3();
2113
+ events = new EventEmitter2();
2860
2114
  state = "closed";
2861
2115
  client;
2862
2116
  jid;
@@ -2894,7 +2148,7 @@ var SmuleChat = class {
2894
2148
  async connect() {
2895
2149
  this.jid = await this.client.start();
2896
2150
  this._log("Connected as:", this.jid.getLocal() + "@" + this.jid.getDomain());
2897
- this.client.send(xml3("presence", {}));
2151
+ this.client.send(xml2("presence", {}));
2898
2152
  }
2899
2153
  /**
2900
2154
  * Disconnects the client from the XMPP server.
@@ -2906,7 +2160,7 @@ var SmuleChat = class {
2906
2160
  */
2907
2161
  async disconnect() {
2908
2162
  try {
2909
- await this.client.send(xml3("presence", { type: "unavailable" }));
2163
+ await this.client.send(xml2("presence", { type: "unavailable" }));
2910
2164
  await this.client.stop();
2911
2165
  } catch {
2912
2166
  }
@@ -2915,7 +2169,7 @@ var SmuleChat = class {
2915
2169
  const id = randomUUID3();
2916
2170
  this.iqs[id] = callback;
2917
2171
  this.client.send(
2918
- xml3(
2172
+ xml2(
2919
2173
  "iq",
2920
2174
  { from: this.jid.toString(), to: this.roomJID, type: iqType, id },
2921
2175
  data
@@ -2924,7 +2178,7 @@ var SmuleChat = class {
2924
2178
  }
2925
2179
  sendIqQuery(xmlns, callback, iqType = "get") {
2926
2180
  this.sendIq(
2927
- xml3("query", { xmlns }),
2181
+ xml2("query", { xmlns }),
2928
2182
  callback,
2929
2183
  iqType
2930
2184
  );
@@ -2949,10 +2203,10 @@ var SmuleChat = class {
2949
2203
  async sendChatState(to, state = "active") {
2950
2204
  if (typeof to != "string" && "accountId" in to) to = this.getJIDFromUserId(to.accountId);
2951
2205
  await this.client.send(
2952
- xml3(
2206
+ xml2(
2953
2207
  "message",
2954
2208
  { to: to.toString(), type: "chat" },
2955
- xml3(
2209
+ xml2(
2956
2210
  "chatstate",
2957
2211
  { xmlns: "http://jabber.org/protocol/chatstates" },
2958
2212
  state
@@ -2974,17 +2228,17 @@ var SmuleChat = class {
2974
2228
  this._log(`Loading ${limit} messages from history...`);
2975
2229
  if (!before && !after && !jid) this.chats = {};
2976
2230
  this.sendIq(
2977
- xml3(
2231
+ xml2(
2978
2232
  "query",
2979
2233
  { xmlns: "urn:xmpp:mam:2" },
2980
- xml3(
2234
+ xml2(
2981
2235
  "set",
2982
2236
  { xmlns: "http://jabber.org/protocol/rsm" },
2983
- xml3("max", {}, limit.toString()),
2984
- before ? xml3("before", {}, before.toString()) : null,
2985
- after ? xml3("after", {}, after.toString()) : null
2237
+ xml2("max", {}, limit.toString()),
2238
+ before ? xml2("before", {}, before.toString()) : null,
2239
+ after ? xml2("after", {}, after.toString()) : null
2986
2240
  ),
2987
- jid ? xml3("with", {}, jid.toString()) : null
2241
+ jid ? xml2("with", {}, jid.toString()) : null
2988
2242
  ),
2989
2243
  (el) => {
2990
2244
  this._log("Finished loading history!", el.toString());
@@ -3000,10 +2254,10 @@ var SmuleChat = class {
3000
2254
  async sendTextMessage(jid, message) {
3001
2255
  if (typeof jid != "string" && "accountId" in jid) jid = this.getJIDFromUserId(jid.accountId);
3002
2256
  await this.client.send(
3003
- xml3(
2257
+ xml2(
3004
2258
  "message",
3005
2259
  { to: jid.toString(), type: "chat" },
3006
- xml3("body", {}, message)
2260
+ xml2("body", {}, message)
3007
2261
  )
3008
2262
  );
3009
2263
  }
@@ -3015,19 +2269,19 @@ var SmuleChat = class {
3015
2269
  async sendPerformanceMessage(jid, performanceKey) {
3016
2270
  if (typeof jid != "string" && "accountId" in jid) jid = this.getJIDFromUserId(jid.accountId);
3017
2271
  await this.client.send(
3018
- xml3(
2272
+ xml2(
3019
2273
  "message",
3020
2274
  { to: jid.toString(), type: "chat" },
3021
- xml3(
2275
+ xml2(
3022
2276
  "performance",
3023
2277
  { xmlns: "urn:x-smule:xmpp" },
3024
- xml3(
2278
+ xml2(
3025
2279
  "key",
3026
2280
  {},
3027
2281
  performanceKey
3028
2282
  )
3029
2283
  ),
3030
- xml3("body", {}, "")
2284
+ xml2("body", {}, "")
3031
2285
  )
3032
2286
  );
3033
2287
  }
@@ -3038,10 +2292,10 @@ var SmuleChat = class {
3038
2292
  async sendReadReceipt(jid) {
3039
2293
  if (typeof jid != "string" && "accountId" in jid) jid = this.getJIDFromUserId(jid.accountId);
3040
2294
  await this.client.send(
3041
- xml3(
2295
+ xml2(
3042
2296
  "message",
3043
2297
  { to: jid.toString(), type: "chat" },
3044
- xml3("received", { xmlns: "urn:xmpp:receipts" })
2298
+ xml2("received", { xmlns: "urn:xmpp:receipts" })
3045
2299
  )
3046
2300
  );
3047
2301
  }