@push.rocks/smartsocket
Version:
Provides easy and secure websocket communication mechanisms, including server and client implementation, function call routing, connection management, and tagging.
1,330 lines (1,316 loc) • 536 kB
JavaScript
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from2, except, desc) => {
if (from2 && typeof from2 === "object" || typeof from2 === "function") {
for (let key of __getOwnPropNames(from2))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc(from2, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
// node_modules/.pnpm/@push.rocks+isounique@1.0.5/node_modules/@push.rocks/isounique/dist_ts/index.js
var require_dist_ts = __commonJS({
"node_modules/.pnpm/@push.rocks+isounique@1.0.5/node_modules/@push.rocks/isounique/dist_ts/index.js"(exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.uni = void 0;
var uni2 = /* @__PURE__ */ __name((prefix = "uni") => {
return `${prefix}_${`xxxxxxxxxxxxxxxxxxxxxxxx`.replace(/[xy]/g, (c) => {
const r = Math.random() * 16 | 0;
const v2 = c === "x" ? r : r & 3 | 8;
return v2.toString(16);
})}`;
}, "uni");
exports.uni = uni2;
}
});
// node_modules/.pnpm/dayjs@1.11.19/node_modules/dayjs/dayjs.min.js
var require_dayjs_min = __commonJS({
"node_modules/.pnpm/dayjs@1.11.19/node_modules/dayjs/dayjs.min.js"(exports, module) {
!(function(t, e) {
"object" == typeof exports && "undefined" != typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : (t = "undefined" != typeof globalThis ? globalThis : t || self).dayjs = e();
})(exports, (function() {
"use strict";
var t = 1e3, e = 6e4, n = 36e5, r = "millisecond", i = "second", s2 = "minute", u = "hour", a = "day", o = "week", c = "month", f2 = "quarter", h = "year", d = "date", l = "Invalid Date", $ = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, y = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, M = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: /* @__PURE__ */ __name(function(t2) {
var e2 = ["th", "st", "nd", "rd"], n2 = t2 % 100;
return "[" + t2 + (e2[(n2 - 20) % 10] || e2[n2] || e2[0]) + "]";
}, "ordinal") }, m2 = /* @__PURE__ */ __name(function(t2, e2, n2) {
var r2 = String(t2);
return !r2 || r2.length >= e2 ? t2 : "" + Array(e2 + 1 - r2.length).join(n2) + t2;
}, "m"), v2 = { s: m2, z: /* @__PURE__ */ __name(function(t2) {
var e2 = -t2.utcOffset(), n2 = Math.abs(e2), r2 = Math.floor(n2 / 60), i2 = n2 % 60;
return (e2 <= 0 ? "+" : "-") + m2(r2, 2, "0") + ":" + m2(i2, 2, "0");
}, "z"), m: /* @__PURE__ */ __name(function t2(e2, n2) {
if (e2.date() < n2.date()) return -t2(n2, e2);
var r2 = 12 * (n2.year() - e2.year()) + (n2.month() - e2.month()), i2 = e2.clone().add(r2, c), s3 = n2 - i2 < 0, u2 = e2.clone().add(r2 + (s3 ? -1 : 1), c);
return +(-(r2 + (n2 - i2) / (s3 ? i2 - u2 : u2 - i2)) || 0);
}, "t"), a: /* @__PURE__ */ __name(function(t2) {
return t2 < 0 ? Math.ceil(t2) || 0 : Math.floor(t2);
}, "a"), p: /* @__PURE__ */ __name(function(t2) {
return { M: c, y: h, w: o, d: a, D: d, h: u, m: s2, s: i, ms: r, Q: f2 }[t2] || String(t2 || "").toLowerCase().replace(/s$/, "");
}, "p"), u: /* @__PURE__ */ __name(function(t2) {
return void 0 === t2;
}, "u") }, g2 = "en", D2 = {};
D2[g2] = M;
var p2 = "$isDayjsObject", S = /* @__PURE__ */ __name(function(t2) {
return t2 instanceof _2 || !(!t2 || !t2[p2]);
}, "S"), w2 = /* @__PURE__ */ __name(function t2(e2, n2, r2) {
var i2;
if (!e2) return g2;
if ("string" == typeof e2) {
var s3 = e2.toLowerCase();
D2[s3] && (i2 = s3), n2 && (D2[s3] = n2, i2 = s3);
var u2 = e2.split("-");
if (!i2 && u2.length > 1) return t2(u2[0]);
} else {
var a2 = e2.name;
D2[a2] = e2, i2 = a2;
}
return !r2 && i2 && (g2 = i2), i2 || !r2 && g2;
}, "t"), O2 = /* @__PURE__ */ __name(function(t2, e2) {
if (S(t2)) return t2.clone();
var n2 = "object" == typeof e2 ? e2 : {};
return n2.date = t2, n2.args = arguments, new _2(n2);
}, "O"), b2 = v2;
b2.l = w2, b2.i = S, b2.w = function(t2, e2) {
return O2(t2, { locale: e2.$L, utc: e2.$u, x: e2.$x, $offset: e2.$offset });
};
var _2 = (function() {
function M2(t2) {
this.$L = w2(t2.locale, null, true), this.parse(t2), this.$x = this.$x || t2.x || {}, this[p2] = true;
}
__name(M2, "M");
var m3 = M2.prototype;
return m3.parse = function(t2) {
this.$d = (function(t3) {
var e2 = t3.date, n2 = t3.utc;
if (null === e2) return /* @__PURE__ */ new Date(NaN);
if (b2.u(e2)) return /* @__PURE__ */ new Date();
if (e2 instanceof Date) return new Date(e2);
if ("string" == typeof e2 && !/Z$/i.test(e2)) {
var r2 = e2.match($);
if (r2) {
var i2 = r2[2] - 1 || 0, s3 = (r2[7] || "0").substring(0, 3);
return n2 ? new Date(Date.UTC(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s3)) : new Date(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s3);
}
}
return new Date(e2);
})(t2), this.init();
}, m3.init = function() {
var t2 = this.$d;
this.$y = t2.getFullYear(), this.$M = t2.getMonth(), this.$D = t2.getDate(), this.$W = t2.getDay(), this.$H = t2.getHours(), this.$m = t2.getMinutes(), this.$s = t2.getSeconds(), this.$ms = t2.getMilliseconds();
}, m3.$utils = function() {
return b2;
}, m3.isValid = function() {
return !(this.$d.toString() === l);
}, m3.isSame = function(t2, e2) {
var n2 = O2(t2);
return this.startOf(e2) <= n2 && n2 <= this.endOf(e2);
}, m3.isAfter = function(t2, e2) {
return O2(t2) < this.startOf(e2);
}, m3.isBefore = function(t2, e2) {
return this.endOf(e2) < O2(t2);
}, m3.$g = function(t2, e2, n2) {
return b2.u(t2) ? this[e2] : this.set(n2, t2);
}, m3.unix = function() {
return Math.floor(this.valueOf() / 1e3);
}, m3.valueOf = function() {
return this.$d.getTime();
}, m3.startOf = function(t2, e2) {
var n2 = this, r2 = !!b2.u(e2) || e2, f3 = b2.p(t2), l2 = /* @__PURE__ */ __name(function(t3, e3) {
var i2 = b2.w(n2.$u ? Date.UTC(n2.$y, e3, t3) : new Date(n2.$y, e3, t3), n2);
return r2 ? i2 : i2.endOf(a);
}, "l"), $2 = /* @__PURE__ */ __name(function(t3, e3) {
return b2.w(n2.toDate()[t3].apply(n2.toDate("s"), (r2 ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e3)), n2);
}, "$"), y2 = this.$W, M3 = this.$M, m4 = this.$D, v3 = "set" + (this.$u ? "UTC" : "");
switch (f3) {
case h:
return r2 ? l2(1, 0) : l2(31, 11);
case c:
return r2 ? l2(1, M3) : l2(0, M3 + 1);
case o:
var g3 = this.$locale().weekStart || 0, D3 = (y2 < g3 ? y2 + 7 : y2) - g3;
return l2(r2 ? m4 - D3 : m4 + (6 - D3), M3);
case a:
case d:
return $2(v3 + "Hours", 0);
case u:
return $2(v3 + "Minutes", 1);
case s2:
return $2(v3 + "Seconds", 2);
case i:
return $2(v3 + "Milliseconds", 3);
default:
return this.clone();
}
}, m3.endOf = function(t2) {
return this.startOf(t2, false);
}, m3.$set = function(t2, e2) {
var n2, o2 = b2.p(t2), f3 = "set" + (this.$u ? "UTC" : ""), l2 = (n2 = {}, n2[a] = f3 + "Date", n2[d] = f3 + "Date", n2[c] = f3 + "Month", n2[h] = f3 + "FullYear", n2[u] = f3 + "Hours", n2[s2] = f3 + "Minutes", n2[i] = f3 + "Seconds", n2[r] = f3 + "Milliseconds", n2)[o2], $2 = o2 === a ? this.$D + (e2 - this.$W) : e2;
if (o2 === c || o2 === h) {
var y2 = this.clone().set(d, 1);
y2.$d[l2]($2), y2.init(), this.$d = y2.set(d, Math.min(this.$D, y2.daysInMonth())).$d;
} else l2 && this.$d[l2]($2);
return this.init(), this;
}, m3.set = function(t2, e2) {
return this.clone().$set(t2, e2);
}, m3.get = function(t2) {
return this[b2.p(t2)]();
}, m3.add = function(r2, f3) {
var d2, l2 = this;
r2 = Number(r2);
var $2 = b2.p(f3), y2 = /* @__PURE__ */ __name(function(t2) {
var e2 = O2(l2);
return b2.w(e2.date(e2.date() + Math.round(t2 * r2)), l2);
}, "y");
if ($2 === c) return this.set(c, this.$M + r2);
if ($2 === h) return this.set(h, this.$y + r2);
if ($2 === a) return y2(1);
if ($2 === o) return y2(7);
var M3 = (d2 = {}, d2[s2] = e, d2[u] = n, d2[i] = t, d2)[$2] || 1, m4 = this.$d.getTime() + r2 * M3;
return b2.w(m4, this);
}, m3.subtract = function(t2, e2) {
return this.add(-1 * t2, e2);
}, m3.format = function(t2) {
var e2 = this, n2 = this.$locale();
if (!this.isValid()) return n2.invalidDate || l;
var r2 = t2 || "YYYY-MM-DDTHH:mm:ssZ", i2 = b2.z(this), s3 = this.$H, u2 = this.$m, a2 = this.$M, o2 = n2.weekdays, c2 = n2.months, f3 = n2.meridiem, h2 = /* @__PURE__ */ __name(function(t3, n3, i3, s4) {
return t3 && (t3[n3] || t3(e2, r2)) || i3[n3].slice(0, s4);
}, "h"), d2 = /* @__PURE__ */ __name(function(t3) {
return b2.s(s3 % 12 || 12, t3, "0");
}, "d"), $2 = f3 || function(t3, e3, n3) {
var r3 = t3 < 12 ? "AM" : "PM";
return n3 ? r3.toLowerCase() : r3;
};
return r2.replace(y, (function(t3, r3) {
return r3 || (function(t4) {
switch (t4) {
case "YY":
return String(e2.$y).slice(-2);
case "YYYY":
return b2.s(e2.$y, 4, "0");
case "M":
return a2 + 1;
case "MM":
return b2.s(a2 + 1, 2, "0");
case "MMM":
return h2(n2.monthsShort, a2, c2, 3);
case "MMMM":
return h2(c2, a2);
case "D":
return e2.$D;
case "DD":
return b2.s(e2.$D, 2, "0");
case "d":
return String(e2.$W);
case "dd":
return h2(n2.weekdaysMin, e2.$W, o2, 2);
case "ddd":
return h2(n2.weekdaysShort, e2.$W, o2, 3);
case "dddd":
return o2[e2.$W];
case "H":
return String(s3);
case "HH":
return b2.s(s3, 2, "0");
case "h":
return d2(1);
case "hh":
return d2(2);
case "a":
return $2(s3, u2, true);
case "A":
return $2(s3, u2, false);
case "m":
return String(u2);
case "mm":
return b2.s(u2, 2, "0");
case "s":
return String(e2.$s);
case "ss":
return b2.s(e2.$s, 2, "0");
case "SSS":
return b2.s(e2.$ms, 3, "0");
case "Z":
return i2;
}
return null;
})(t3) || i2.replace(":", "");
}));
}, m3.utcOffset = function() {
return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
}, m3.diff = function(r2, d2, l2) {
var $2, y2 = this, M3 = b2.p(d2), m4 = O2(r2), v3 = (m4.utcOffset() - this.utcOffset()) * e, g3 = this - m4, D3 = /* @__PURE__ */ __name(function() {
return b2.m(y2, m4);
}, "D");
switch (M3) {
case h:
$2 = D3() / 12;
break;
case c:
$2 = D3();
break;
case f2:
$2 = D3() / 3;
break;
case o:
$2 = (g3 - v3) / 6048e5;
break;
case a:
$2 = (g3 - v3) / 864e5;
break;
case u:
$2 = g3 / n;
break;
case s2:
$2 = g3 / e;
break;
case i:
$2 = g3 / t;
break;
default:
$2 = g3;
}
return l2 ? $2 : b2.a($2);
}, m3.daysInMonth = function() {
return this.endOf(c).$D;
}, m3.$locale = function() {
return D2[this.$L];
}, m3.locale = function(t2, e2) {
if (!t2) return this.$L;
var n2 = this.clone(), r2 = w2(t2, e2, true);
return r2 && (n2.$L = r2), n2;
}, m3.clone = function() {
return b2.w(this.$d, this);
}, m3.toDate = function() {
return new Date(this.valueOf());
}, m3.toJSON = function() {
return this.isValid() ? this.toISOString() : null;
}, m3.toISOString = function() {
return this.$d.toISOString();
}, m3.toString = function() {
return this.$d.toUTCString();
}, M2;
})(), k2 = _2.prototype;
return O2.prototype = k2, [["$ms", r], ["$s", i], ["$m", s2], ["$H", u], ["$W", a], ["$M", c], ["$y", h], ["$D", d]].forEach((function(t2) {
k2[t2[1]] = function(e2) {
return this.$g(e2, t2[0], t2[1]);
};
})), O2.extend = function(t2, e2) {
return t2.$i || (t2(e2, _2, O2), t2.$i = true), O2;
}, O2.locale = w2, O2.isDayjs = S, O2.unix = function(t2) {
return O2(1e3 * t2);
}, O2.en = D2[g2], O2.Ls = D2, O2.p = {}, O2;
}));
}
});
// node_modules/.pnpm/dayjs@1.11.19/node_modules/dayjs/plugin/isToday.js
var require_isToday = __commonJS({
"node_modules/.pnpm/dayjs@1.11.19/node_modules/dayjs/plugin/isToday.js"(exports, module) {
!(function(e, o) {
"object" == typeof exports && "undefined" != typeof module ? module.exports = o() : "function" == typeof define && define.amd ? define(o) : (e = "undefined" != typeof globalThis ? globalThis : e || self).dayjs_plugin_isToday = o();
})(exports, (function() {
"use strict";
return function(e, o, t) {
o.prototype.isToday = function() {
var e2 = "YYYY-MM-DD", o2 = t();
return this.format(e2) === o2.format(e2);
};
};
}));
}
});
// node_modules/.pnpm/symbol-tree@3.2.4/node_modules/symbol-tree/lib/SymbolTreeNode.js
var require_SymbolTreeNode = __commonJS({
"node_modules/.pnpm/symbol-tree@3.2.4/node_modules/symbol-tree/lib/SymbolTreeNode.js"(exports, module) {
"use strict";
module.exports = class SymbolTreeNode {
static {
__name(this, "SymbolTreeNode");
}
constructor() {
this.parent = null;
this.previousSibling = null;
this.nextSibling = null;
this.firstChild = null;
this.lastChild = null;
this.childrenVersion = 0;
this.childIndexCachedUpTo = null;
this.cachedIndex = -1;
this.cachedIndexVersion = NaN;
}
get isAttached() {
return Boolean(this.parent || this.previousSibling || this.nextSibling);
}
get hasChildren() {
return Boolean(this.firstChild);
}
childrenChanged() {
this.childrenVersion = this.childrenVersion + 1 & 4294967295;
this.childIndexCachedUpTo = null;
}
getCachedIndex(parentNode) {
if (this.cachedIndexVersion !== parentNode.childrenVersion) {
this.cachedIndexVersion = NaN;
return -1;
}
return this.cachedIndex;
}
setCachedIndex(parentNode, index) {
this.cachedIndexVersion = parentNode.childrenVersion;
this.cachedIndex = index;
}
};
}
});
// node_modules/.pnpm/symbol-tree@3.2.4/node_modules/symbol-tree/lib/TreePosition.js
var require_TreePosition = __commonJS({
"node_modules/.pnpm/symbol-tree@3.2.4/node_modules/symbol-tree/lib/TreePosition.js"(exports, module) {
"use strict";
module.exports = Object.freeze({
// same as DOM DOCUMENT_POSITION_
DISCONNECTED: 1,
PRECEDING: 2,
FOLLOWING: 4,
CONTAINS: 8,
CONTAINED_BY: 16
});
}
});
// node_modules/.pnpm/symbol-tree@3.2.4/node_modules/symbol-tree/lib/TreeIterator.js
var require_TreeIterator = __commonJS({
"node_modules/.pnpm/symbol-tree@3.2.4/node_modules/symbol-tree/lib/TreeIterator.js"(exports, module) {
"use strict";
var TREE = /* @__PURE__ */ Symbol();
var ROOT = /* @__PURE__ */ Symbol();
var NEXT = /* @__PURE__ */ Symbol();
var ITERATE_FUNC = /* @__PURE__ */ Symbol();
var TreeIterator = class {
static {
__name(this, "TreeIterator");
}
constructor(tree, root, firstResult, iterateFunction) {
this[TREE] = tree;
this[ROOT] = root;
this[NEXT] = firstResult;
this[ITERATE_FUNC] = iterateFunction;
}
next() {
const tree = this[TREE];
const iterateFunc = this[ITERATE_FUNC];
const root = this[ROOT];
if (!this[NEXT]) {
return {
done: true,
value: root
};
}
const value = this[NEXT];
if (iterateFunc === 1) {
this[NEXT] = tree._node(value).previousSibling;
} else if (iterateFunc === 2) {
this[NEXT] = tree._node(value).nextSibling;
} else if (iterateFunc === 3) {
this[NEXT] = tree._node(value).parent;
} else if (iterateFunc === 4) {
this[NEXT] = tree.preceding(value, { root });
} else {
this[NEXT] = tree.following(value, { root });
}
return {
done: false,
value
};
}
};
Object.defineProperty(TreeIterator.prototype, Symbol.iterator, {
value: /* @__PURE__ */ __name(function() {
return this;
}, "value"),
writable: false
});
TreeIterator.PREV = 1;
TreeIterator.NEXT = 2;
TreeIterator.PARENT = 3;
TreeIterator.PRECEDING = 4;
TreeIterator.FOLLOWING = 5;
Object.freeze(TreeIterator);
Object.freeze(TreeIterator.prototype);
module.exports = TreeIterator;
}
});
// node_modules/.pnpm/symbol-tree@3.2.4/node_modules/symbol-tree/lib/SymbolTree.js
var require_SymbolTree = __commonJS({
"node_modules/.pnpm/symbol-tree@3.2.4/node_modules/symbol-tree/lib/SymbolTree.js"(exports, module) {
"use strict";
var SymbolTreeNode = require_SymbolTreeNode();
var TreePosition = require_TreePosition();
var TreeIterator = require_TreeIterator();
function returnTrue() {
return true;
}
__name(returnTrue, "returnTrue");
function reverseArrayIndex(array, reverseIndex) {
return array[array.length - 1 - reverseIndex];
}
__name(reverseArrayIndex, "reverseArrayIndex");
var SymbolTree = class {
static {
__name(this, "SymbolTree");
}
/**
* @constructor
* @alias module:symbol-tree
* @param {string} [description='SymbolTree data'] Description used for the Symbol
*/
constructor(description) {
this.symbol = Symbol(description || "SymbolTree data");
}
/**
* You can use this function to (optionally) initialize an object right after its creation,
* to take advantage of V8's fast properties. Also useful if you would like to
* freeze your object.
*
* `O(1)`
*
* @method
* @alias module:symbol-tree#initialize
* @param {Object} object
* @return {Object} object
*/
initialize(object) {
this._node(object);
return object;
}
_node(object) {
if (!object) {
return null;
}
const node = object[this.symbol];
if (node) {
return node;
}
return object[this.symbol] = new SymbolTreeNode();
}
/**
* Returns `true` if the object has any children. Otherwise it returns `false`.
*
* * `O(1)`
*
* @method hasChildren
* @memberOf module:symbol-tree#
* @param {Object} object
* @return {Boolean}
*/
hasChildren(object) {
return this._node(object).hasChildren;
}
/**
* Returns the first child of the given object.
*
* * `O(1)`
*
* @method firstChild
* @memberOf module:symbol-tree#
* @param {Object} object
* @return {Object}
*/
firstChild(object) {
return this._node(object).firstChild;
}
/**
* Returns the last child of the given object.
*
* * `O(1)`
*
* @method lastChild
* @memberOf module:symbol-tree#
* @param {Object} object
* @return {Object}
*/
lastChild(object) {
return this._node(object).lastChild;
}
/**
* Returns the previous sibling of the given object.
*
* * `O(1)`
*
* @method previousSibling
* @memberOf module:symbol-tree#
* @param {Object} object
* @return {Object}
*/
previousSibling(object) {
return this._node(object).previousSibling;
}
/**
* Returns the next sibling of the given object.
*
* * `O(1)`
*
* @method nextSibling
* @memberOf module:symbol-tree#
* @param {Object} object
* @return {Object}
*/
nextSibling(object) {
return this._node(object).nextSibling;
}
/**
* Return the parent of the given object.
*
* * `O(1)`
*
* @method parent
* @memberOf module:symbol-tree#
* @param {Object} object
* @return {Object}
*/
parent(object) {
return this._node(object).parent;
}
/**
* Find the inclusive descendant that is last in tree order of the given object.
*
* * `O(n)` (worst case) where `n` is the depth of the subtree of `object`
*
* @method lastInclusiveDescendant
* @memberOf module:symbol-tree#
* @param {Object} object
* @return {Object}
*/
lastInclusiveDescendant(object) {
let lastChild;
let current = object;
while (lastChild = this._node(current).lastChild) {
current = lastChild;
}
return current;
}
/**
* Find the preceding object (A) of the given object (B).
* An object A is preceding an object B if A and B are in the same tree
* and A comes before B in tree order.
*
* * `O(n)` (worst case)
* * `O(1)` (amortized when walking the entire tree)
*
* @method preceding
* @memberOf module:symbol-tree#
* @param {Object} object
* @param {Object} [options]
* @param {Object} [options.root] If set, `root` must be an inclusive ancestor
* of the return value (or else null is returned). This check _assumes_
* that `root` is also an inclusive ancestor of the given `object`
* @return {?Object}
*/
preceding(object, options) {
const treeRoot = options && options.root;
if (object === treeRoot) {
return null;
}
const previousSibling = this._node(object).previousSibling;
if (previousSibling) {
return this.lastInclusiveDescendant(previousSibling);
}
return this._node(object).parent;
}
/**
* Find the following object (A) of the given object (B).
* An object A is following an object B if A and B are in the same tree
* and A comes after B in tree order.
*
* * `O(n)` (worst case) where `n` is the amount of objects in the entire tree
* * `O(1)` (amortized when walking the entire tree)
*
* @method following
* @memberOf module:symbol-tree#
* @param {!Object} object
* @param {Object} [options]
* @param {Object} [options.root] If set, `root` must be an inclusive ancestor
* of the return value (or else null is returned). This check _assumes_
* that `root` is also an inclusive ancestor of the given `object`
* @param {Boolean} [options.skipChildren=false] If set, ignore the children of `object`
* @return {?Object}
*/
following(object, options) {
const treeRoot = options && options.root;
const skipChildren = options && options.skipChildren;
const firstChild = !skipChildren && this._node(object).firstChild;
if (firstChild) {
return firstChild;
}
let current = object;
do {
if (current === treeRoot) {
return null;
}
const nextSibling = this._node(current).nextSibling;
if (nextSibling) {
return nextSibling;
}
current = this._node(current).parent;
} while (current);
return null;
}
/**
* Append all children of the given object to an array.
*
* * `O(n)` where `n` is the amount of children of the given `parent`
*
* @method childrenToArray
* @memberOf module:symbol-tree#
* @param {Object} parent
* @param {Object} [options]
* @param {Object[]} [options.array=[]]
* @param {Function} [options.filter] Function to test each object before it is added to the array.
* Invoked with arguments (object). Should return `true` if an object
* is to be included.
* @param {*} [options.thisArg] Value to use as `this` when executing `filter`.
* @return {Object[]}
*/
childrenToArray(parent, options) {
const array = options && options.array || [];
const filter2 = options && options.filter || returnTrue;
const thisArg = options && options.thisArg || void 0;
const parentNode = this._node(parent);
let object = parentNode.firstChild;
let index = 0;
while (object) {
const node = this._node(object);
node.setCachedIndex(parentNode, index);
if (filter2.call(thisArg, object)) {
array.push(object);
}
object = node.nextSibling;
++index;
}
return array;
}
/**
* Append all inclusive ancestors of the given object to an array.
*
* * `O(n)` where `n` is the amount of ancestors of the given `object`
*
* @method ancestorsToArray
* @memberOf module:symbol-tree#
* @param {Object} object
* @param {Object} [options]
* @param {Object[]} [options.array=[]]
* @param {Function} [options.filter] Function to test each object before it is added to the array.
* Invoked with arguments (object). Should return `true` if an object
* is to be included.
* @param {*} [options.thisArg] Value to use as `this` when executing `filter`.
* @return {Object[]}
*/
ancestorsToArray(object, options) {
const array = options && options.array || [];
const filter2 = options && options.filter || returnTrue;
const thisArg = options && options.thisArg || void 0;
let ancestor = object;
while (ancestor) {
if (filter2.call(thisArg, ancestor)) {
array.push(ancestor);
}
ancestor = this._node(ancestor).parent;
}
return array;
}
/**
* Append all descendants of the given object to an array (in tree order).
*
* * `O(n)` where `n` is the amount of objects in the sub-tree of the given `object`
*
* @method treeToArray
* @memberOf module:symbol-tree#
* @param {Object} root
* @param {Object} [options]
* @param {Object[]} [options.array=[]]
* @param {Function} [options.filter] Function to test each object before it is added to the array.
* Invoked with arguments (object). Should return `true` if an object
* is to be included.
* @param {*} [options.thisArg] Value to use as `this` when executing `filter`.
* @return {Object[]}
*/
treeToArray(root, options) {
const array = options && options.array || [];
const filter2 = options && options.filter || returnTrue;
const thisArg = options && options.thisArg || void 0;
let object = root;
while (object) {
if (filter2.call(thisArg, object)) {
array.push(object);
}
object = this.following(object, { root });
}
return array;
}
/**
* Iterate over all children of the given object
*
* * `O(1)` for a single iteration
*
* @method childrenIterator
* @memberOf module:symbol-tree#
* @param {Object} parent
* @param {Object} [options]
* @param {Boolean} [options.reverse=false]
* @return {Object} An iterable iterator (ES6)
*/
childrenIterator(parent, options) {
const reverse = options && options.reverse;
const parentNode = this._node(parent);
return new TreeIterator(
this,
parent,
reverse ? parentNode.lastChild : parentNode.firstChild,
reverse ? TreeIterator.PREV : TreeIterator.NEXT
);
}
/**
* Iterate over all the previous siblings of the given object. (in reverse tree order)
*
* * `O(1)` for a single iteration
*
* @method previousSiblingsIterator
* @memberOf module:symbol-tree#
* @param {Object} object
* @return {Object} An iterable iterator (ES6)
*/
previousSiblingsIterator(object) {
return new TreeIterator(
this,
object,
this._node(object).previousSibling,
TreeIterator.PREV
);
}
/**
* Iterate over all the next siblings of the given object. (in tree order)
*
* * `O(1)` for a single iteration
*
* @method nextSiblingsIterator
* @memberOf module:symbol-tree#
* @param {Object} object
* @return {Object} An iterable iterator (ES6)
*/
nextSiblingsIterator(object) {
return new TreeIterator(
this,
object,
this._node(object).nextSibling,
TreeIterator.NEXT
);
}
/**
* Iterate over all inclusive ancestors of the given object
*
* * `O(1)` for a single iteration
*
* @method ancestorsIterator
* @memberOf module:symbol-tree#
* @param {Object} object
* @return {Object} An iterable iterator (ES6)
*/
ancestorsIterator(object) {
return new TreeIterator(
this,
object,
object,
TreeIterator.PARENT
);
}
/**
* Iterate over all descendants of the given object (in tree order).
*
* Where `n` is the amount of objects in the sub-tree of the given `root`:
*
* * `O(n)` (worst case for a single iteration)
* * `O(n)` (amortized, when completing the iterator)
*
* @method treeIterator
* @memberOf module:symbol-tree#
* @param {Object} root
* @param {Object} options
* @param {Boolean} [options.reverse=false]
* @return {Object} An iterable iterator (ES6)
*/
treeIterator(root, options) {
const reverse = options && options.reverse;
return new TreeIterator(
this,
root,
reverse ? this.lastInclusiveDescendant(root) : root,
reverse ? TreeIterator.PRECEDING : TreeIterator.FOLLOWING
);
}
/**
* Find the index of the given object (the number of preceding siblings).
*
* * `O(n)` where `n` is the amount of preceding siblings
* * `O(1)` (amortized, if the tree is not modified)
*
* @method index
* @memberOf module:symbol-tree#
* @param {Object} child
* @return {Number} The number of preceding siblings, or -1 if the object has no parent
*/
index(child) {
const childNode = this._node(child);
const parentNode = this._node(childNode.parent);
if (!parentNode) {
return -1;
}
let currentIndex = childNode.getCachedIndex(parentNode);
if (currentIndex >= 0) {
return currentIndex;
}
currentIndex = 0;
let object = parentNode.firstChild;
if (parentNode.childIndexCachedUpTo) {
const cachedUpToNode = this._node(parentNode.childIndexCachedUpTo);
object = cachedUpToNode.nextSibling;
currentIndex = cachedUpToNode.getCachedIndex(parentNode) + 1;
}
while (object) {
const node = this._node(object);
node.setCachedIndex(parentNode, currentIndex);
if (object === child) {
break;
}
++currentIndex;
object = node.nextSibling;
}
parentNode.childIndexCachedUpTo = child;
return currentIndex;
}
/**
* Calculate the number of children.
*
* * `O(n)` where `n` is the amount of children
* * `O(1)` (amortized, if the tree is not modified)
*
* @method childrenCount
* @memberOf module:symbol-tree#
* @param {Object} parent
* @return {Number}
*/
childrenCount(parent) {
const parentNode = this._node(parent);
if (!parentNode.lastChild) {
return 0;
}
return this.index(parentNode.lastChild) + 1;
}
/**
* Compare the position of an object relative to another object. A bit set is returned:
*
* <ul>
* <li>DISCONNECTED : 1</li>
* <li>PRECEDING : 2</li>
* <li>FOLLOWING : 4</li>
* <li>CONTAINS : 8</li>
* <li>CONTAINED_BY : 16</li>
* </ul>
*
* The semantics are the same as compareDocumentPosition in DOM, with the exception that
* DISCONNECTED never occurs with any other bit.
*
* where `n` and `m` are the amount of ancestors of `left` and `right`;
* where `o` is the amount of children of the lowest common ancestor of `left` and `right`:
*
* * `O(n + m + o)` (worst case)
* * `O(n + m)` (amortized, if the tree is not modified)
*
* @method compareTreePosition
* @memberOf module:symbol-tree#
* @param {Object} left
* @param {Object} right
* @return {Number}
*/
compareTreePosition(left, right) {
if (left === right) {
return 0;
}
const leftAncestors = [];
{
let leftAncestor = left;
while (leftAncestor) {
if (leftAncestor === right) {
return TreePosition.CONTAINS | TreePosition.PRECEDING;
}
leftAncestors.push(leftAncestor);
leftAncestor = this.parent(leftAncestor);
}
}
const rightAncestors = [];
{
let rightAncestor = right;
while (rightAncestor) {
if (rightAncestor === left) {
return TreePosition.CONTAINED_BY | TreePosition.FOLLOWING;
}
rightAncestors.push(rightAncestor);
rightAncestor = this.parent(rightAncestor);
}
}
const root = reverseArrayIndex(leftAncestors, 0);
if (!root || root !== reverseArrayIndex(rightAncestors, 0)) {
return TreePosition.DISCONNECTED;
}
let commonAncestorIndex = 0;
const ancestorsMinLength = Math.min(leftAncestors.length, rightAncestors.length);
for (let i = 0; i < ancestorsMinLength; ++i) {
const leftAncestor = reverseArrayIndex(leftAncestors, i);
const rightAncestor = reverseArrayIndex(rightAncestors, i);
if (leftAncestor !== rightAncestor) {
break;
}
commonAncestorIndex = i;
}
const leftIndex = this.index(reverseArrayIndex(leftAncestors, commonAncestorIndex + 1));
const rightIndex = this.index(reverseArrayIndex(rightAncestors, commonAncestorIndex + 1));
return rightIndex < leftIndex ? TreePosition.PRECEDING : TreePosition.FOLLOWING;
}
/**
* Remove the object from this tree.
* Has no effect if already removed.
*
* * `O(1)`
*
* @method remove
* @memberOf module:symbol-tree#
* @param {Object} removeObject
* @return {Object} removeObject
*/
remove(removeObject) {
const removeNode = this._node(removeObject);
const parentNode = this._node(removeNode.parent);
const prevNode = this._node(removeNode.previousSibling);
const nextNode = this._node(removeNode.nextSibling);
if (parentNode) {
if (parentNode.firstChild === removeObject) {
parentNode.firstChild = removeNode.nextSibling;
}
if (parentNode.lastChild === removeObject) {
parentNode.lastChild = removeNode.previousSibling;
}
}
if (prevNode) {
prevNode.nextSibling = removeNode.nextSibling;
}
if (nextNode) {
nextNode.previousSibling = removeNode.previousSibling;
}
removeNode.parent = null;
removeNode.previousSibling = null;
removeNode.nextSibling = null;
removeNode.cachedIndex = -1;
removeNode.cachedIndexVersion = NaN;
if (parentNode) {
parentNode.childrenChanged();
}
return removeObject;
}
/**
* Insert the given object before the reference object.
* `newObject` is now the previous sibling of `referenceObject`.
*
* * `O(1)`
*
* @method insertBefore
* @memberOf module:symbol-tree#
* @param {Object} referenceObject
* @param {Object} newObject
* @throws {Error} If the newObject is already present in this SymbolTree
* @return {Object} newObject
*/
insertBefore(referenceObject, newObject) {
const referenceNode = this._node(referenceObject);
const prevNode = this._node(referenceNode.previousSibling);
const newNode = this._node(newObject);
const parentNode = this._node(referenceNode.parent);
if (newNode.isAttached) {
throw Error("Given object is already present in this SymbolTree, remove it first");
}
newNode.parent = referenceNode.parent;
newNode.previousSibling = referenceNode.previousSibling;
newNode.nextSibling = referenceObject;
referenceNode.previousSibling = newObject;
if (prevNode) {
prevNode.nextSibling = newObject;
}
if (parentNode && parentNode.firstChild === referenceObject) {
parentNode.firstChild = newObject;
}
if (parentNode) {
parentNode.childrenChanged();
}
return newObject;
}
/**
* Insert the given object after the reference object.
* `newObject` is now the next sibling of `referenceObject`.
*
* * `O(1)`
*
* @method insertAfter
* @memberOf module:symbol-tree#
* @param {Object} referenceObject
* @param {Object} newObject
* @throws {Error} If the newObject is already present in this SymbolTree
* @return {Object} newObject
*/
insertAfter(referenceObject, newObject) {
const referenceNode = this._node(referenceObject);
const nextNode = this._node(referenceNode.nextSibling);
const newNode = this._node(newObject);
const parentNode = this._node(referenceNode.parent);
if (newNode.isAttached) {
throw Error("Given object is already present in this SymbolTree, remove it first");
}
newNode.parent = referenceNode.parent;
newNode.previousSibling = referenceObject;
newNode.nextSibling = referenceNode.nextSibling;
referenceNode.nextSibling = newObject;
if (nextNode) {
nextNode.previousSibling = newObject;
}
if (parentNode && parentNode.lastChild === referenceObject) {
parentNode.lastChild = newObject;
}
if (parentNode) {
parentNode.childrenChanged();
}
return newObject;
}
/**
* Insert the given object as the first child of the given reference object.
* `newObject` is now the first child of `referenceObject`.
*
* * `O(1)`
*
* @method prependChild
* @memberOf module:symbol-tree#
* @param {Object} referenceObject
* @param {Object} newObject
* @throws {Error} If the newObject is already present in this SymbolTree
* @return {Object} newObject
*/
prependChild(referenceObject, newObject) {
const referenceNode = this._node(referenceObject);
const newNode = this._node(newObject);
if (newNode.isAttached) {
throw Error("Given object is already present in this SymbolTree, remove it first");
}
if (referenceNode.hasChildren) {
this.insertBefore(referenceNode.firstChild, newObject);
} else {
newNode.parent = referenceObject;
referenceNode.firstChild = newObject;
referenceNode.lastChild = newObject;
referenceNode.childrenChanged();
}
return newObject;
}
/**
* Insert the given object as the last child of the given reference object.
* `newObject` is now the last child of `referenceObject`.
*
* * `O(1)`
*
* @method appendChild
* @memberOf module:symbol-tree#
* @param {Object} referenceObject
* @param {Object} newObject
* @throws {Error} If the newObject is already present in this SymbolTree
* @return {Object} newObject
*/
appendChild(referenceObject, newObject) {
const referenceNode = this._node(referenceObject);
const newNode = this._node(newObject);
if (newNode.isAttached) {
throw Error("Given object is already present in this SymbolTree, remove it first");
}
if (referenceNode.hasChildren) {
this.insertAfter(referenceNode.lastChild, newObject);
} else {
newNode.parent = referenceObject;
referenceNode.firstChild = newObject;
referenceNode.lastChild = newObject;
referenceNode.childrenChanged();
}
return newObject;
}
};
module.exports = SymbolTree;
SymbolTree.TreePosition = TreePosition;
}
});
// node_modules/.pnpm/fast-json-stable-stringify@2.1.0/node_modules/fast-json-stable-stringify/index.js
var require_fast_json_stable_stringify = __commonJS({
"node_modules/.pnpm/fast-json-stable-stringify@2.1.0/node_modules/fast-json-stable-stringify/index.js"(exports, module) {
"use strict";
module.exports = function(data, opts) {
if (!opts) opts = {};
if (typeof opts === "function") opts = { cmp: opts };
var cycles = typeof opts.cycles === "boolean" ? opts.cycles : false;
var cmp = opts.cmp && /* @__PURE__ */ (function(f2) {
return function(node) {
return function(a, b2) {
var aobj = { key: a, value: node[a] };
var bobj = { key: b2, value: node[b2] };
return f2(aobj, bobj);
};
};
})(opts.cmp);
var seen = [];
return (/* @__PURE__ */ __name((function stringify3(node) {
if (node && node.toJSON && typeof node.toJSON === "function") {
node = node.toJSON();
}
if (node === void 0) return;
if (typeof node == "number") return isFinite(node) ? "" + node : "null";
if (typeof node !== "object") return JSON.stringify(node);
var i, out;
if (Array.isArray(node)) {
out = "[";
for (i = 0; i < node.length; i++) {
if (i) out += ",";
out += stringify3(node[i]) || "null";
}
return out + "]";
}
if (node === null) return "null";
if (seen.indexOf(node) !== -1) {
if (cycles) return JSON.stringify("__cycle__");
throw new TypeError("Converting circular structure to JSON");
}
var seenIndex = seen.push(node) - 1;
var keys = Object.keys(node).sort(cmp && cmp(node));
out = "";
for (i = 0; i < keys.length; i++) {
var key = keys[i];
var value = stringify3(node[key]);
if (!value) continue;
if (out) out += ",";
out += JSON.stringify(key) + ":" + value;
}
seen.splice(seenIndex, 1);
return "{" + out + "}";
}), "stringify"))(data);
};
}
});
// node_modules/.pnpm/@api.global+typedrequest-interfaces@3.0.19/node_modules/@api.global/typedrequest-interfaces/dist_ts/index.js
var dist_ts_exports = {};
// node_modules/.pnpm/@push.rocks+lik@6.4.1/node_modules/@push.rocks/lik/dist_ts/index.js
var dist_ts_exports6 = {};
__export(dist_ts_exports6, {
AsyncExecutionStack: () => AsyncExecutionStack,
BackpressuredArray: () => BackpressuredArray,
FastMap: () => FastMap,
Interest: () => Interest,
InterestMap: () => InterestMap,
LimitedArray: () => LimitedArray,
LoopTracker: () => LoopTracker,
ObjectMap: () => ObjectMap,
Stringmap: () => Stringmap,
TimedAggregator: () => TimedAggregtor,
TimedAggregtor: () => TimedAggregtor,
Tree: () => Tree,
uni: () => uni
});
// node_modules/.pnpm/@push.rocks+smartdelay@3.0.5/node_modules/@push.rocks/smartdelay/dist_ts/index.js
var dist_ts_exports3 = {};
__export(dist_ts_exports3, {
Timeout: () => Timeout,
delayFor: () => delayFor,
delayForRandom: () => delayForRandom
});
// node_modules/.pnpm/@push.rocks+smartpromise@4.2.3/node_modules/@push.rocks/smartpromise/dist_ts/index.js
var dist_ts_exports2 = {};
__export(dist_ts_exports2, {
CumulativeDeferred: () => CumulativeDeferred,
Deferred: () => Deferred,
cumulativeDefer: () => cumulativeDefer,
defer: () => defer,
fromCallback: () => fromCallback,
getFirstTrueOrFalse: () => getFirstTrueOrFalse,
map: () => map,
rejectedPromise: () => rejectedPromise,
resolvedPromise: () => resolvedPromise,
timeoutAndContinue: () => timeoutAndContinue,
timeoutWrap: () => timeoutWrap
});
// node_modules/.pnpm/@push.rocks+smartpromise@4.2.3/node_modules/@push.rocks/smartpromise/dist_ts/smartpromise.classes.deferred.js
var Deferred = class {
static {
__name(this, "Deferred");
}
claim() {
if (this.claimed) {
throw new Error("Deferred already claimed");
}
this.claimed = true;
}
get duration() {
if (this.stoppedAt) {
return this.stoppedAt - this.startedAt;
} else {
return Date.now() - this.startedAt;
}
}
constructor() {
this.claimed = false;
this.promise = new Promise((resolve, reject) => {
this.resolve = (valueArg) => {
this.status = "fulfilled";
this.stoppedAt = Date.now();
resolve(valueArg);
};
this.reject = (reason) => {
this.status = "rejected";
this.stoppedAt = Date.now();
reject(reason);
};
this.startedAt = Date.now();
this.status = "pending";
});
}
};
var defer = /* @__PURE__ */ __name(() => {
return new Deferred();
}, "defer");
// node_modules/.pnpm/@push.rocks+smartpromise@4.2.3/node_modules/@push.rocks/smartpromise/dist_ts/smartpromise.classes.cumulativedeferred.js
var CumulativeDeferred = class {
static {
__name(this, "CumulativeDeferred");
}
constructor() {
this.accumulatedPromises = [];
this.deferred = defer();
this.promise = this.deferred.promise;
setTimeout(a