stanza 12.19.1 → 12.21.0

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/Constants.js CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.directionToSenders = exports.sendersToDirection = exports.JINGLE_INFO_RECEIVED_5 = exports.JINGLE_INFO_CHECKSUM_5 = exports.JINGLE_INFO_RINGING = exports.JINGLE_INFO_ACTIVE = exports.JINGLE_INFO_UNHOLD = exports.JINGLE_INFO_HOLD = exports.JINGLE_INFO_UNMUTE = exports.JINGLE_INFO_MUTE = exports.JINGLE_INFO = exports.USER_ACTIVITY_SPECIFIC = exports.USER_ACTIVITY_GENERAL = exports.USER_MOODS = exports.JingleReasonCondition = exports.JingleErrorCondition = exports.JingleAction = exports.JingleContentSenders = exports.JingleApplicationDirection = exports.JingleSessionRole = exports.ChatState = exports.PubsubErrorCondition = exports.MUCStatusCode = exports.MUCRole = exports.MUCAffiliation = exports.DataFormFieldType = exports.DataFormType = exports.RosterSubscription = exports.PresenceShow = exports.IQType = exports.PresenceType = exports.MessageType = exports.StanzaErrorCondition = exports.StreamErrorCondition = exports.SASLFailureCondition = exports.StreamType = exports.VERSION = void 0;
4
4
  const Namespaces_1 = require("./Namespaces");
5
- exports.VERSION = '12.19.1';
5
+ exports.VERSION = '12.21.0';
6
6
  // ====================================================================
7
7
  // Frequently Used Values
8
8
  // ====================================================================
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "stanza",
3
3
  "description": "Modern XMPP in the browser, with a JSON API",
4
- "version": "12.19.1",
4
+ "version": "12.21.0",
5
5
  "author": "Lance Stout <lancestout@gmail.com>",
6
6
  "bugs": "https://github.com/legastero/stanza/issues",
7
7
  "contributors": [
@@ -1 +1 @@
1
- export function nextTick(fun: any, ...args: any[]): void;
1
+ export declare function nextTick(callback: Function, ...args: any[]): void;
@@ -1,62 +1,8 @@
1
1
  "use strict";
2
- // v8 likes predictible objects
3
- function Item(fun, array) {
4
- this.fun = fun;
5
- this.array = array;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.nextTick = void 0;
4
+ /* eslint-disable @typescript-eslint/ban-types */
5
+ function nextTick(callback, ...args) {
6
+ queueMicrotask(() => callback(...args));
6
7
  }
7
- Item.prototype.run = function () {
8
- this.fun.apply(null, this.array);
9
- };
10
- var queue = [];
11
- var draining = false;
12
- var currentQueue;
13
- var queueIndex = -1;
14
- function cleanUpNextTick() {
15
- if (!draining || !currentQueue) {
16
- return;
17
- }
18
- draining = false;
19
- if (currentQueue.length) {
20
- queue = currentQueue.concat(queue);
21
- }
22
- else {
23
- queueIndex = -1;
24
- }
25
- if (queue.length) {
26
- drainQueue();
27
- }
28
- }
29
- function drainQueue() {
30
- if (draining) {
31
- return;
32
- }
33
- var timeout = setTimeout(cleanUpNextTick, 0);
34
- draining = true;
35
- var len = queue.length;
36
- while (len) {
37
- currentQueue = queue;
38
- queue = [];
39
- while (++queueIndex < len) {
40
- if (currentQueue) {
41
- currentQueue[queueIndex].run();
42
- }
43
- }
44
- queueIndex = -1;
45
- len = queue.length;
46
- }
47
- currentQueue = null;
48
- draining = false;
49
- clearTimeout(timeout);
50
- }
51
- exports.nextTick = function (fun) {
52
- var args = new Array(arguments.length - 1);
53
- if (arguments.length > 1) {
54
- for (var i = 1; i < arguments.length; i++) {
55
- args[i - 1] = arguments[i];
56
- }
57
- }
58
- queue.push(new Item(fun, args));
59
- if (queue.length === 1 && !draining) {
60
- setTimeout(drainQueue, 0);
61
- }
62
- };
8
+ exports.nextTick = nextTick;
@@ -14,6 +14,7 @@ export default class WSConnection extends Duplex implements Transport {
14
14
  private closing;
15
15
  private parser?;
16
16
  private socket?;
17
+ private disconnectTimeoutId?;
17
18
  constructor(client: Agent, sm: StreamManagement, stanzas: Registry);
18
19
  _read(): void;
19
20
  _write(chunk: string, encoding: string, done: (err?: Error) => void): void;
@@ -96,8 +96,14 @@ class WSConnection extends platform_1.Duplex {
96
96
  if (this.socket && !this.closing && this.hasStream && clean) {
97
97
  this.closing = true;
98
98
  this.write(this.closeHeader());
99
+ this.disconnectTimeoutId = setTimeout(() => {
100
+ if (this.socket) {
101
+ this.disconnect(false);
102
+ }
103
+ }, 1000);
99
104
  }
100
105
  else {
106
+ clearTimeout(this.disconnectTimeoutId);
101
107
  this.hasStream = false;
102
108
  this.stream = undefined;
103
109
  if (this.socket) {