478 lines
17 KiB
JavaScript
478 lines
17 KiB
JavaScript
var __bare_os_bundle_exports__ = (() => {
|
|
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 __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
}) : x)(function(x) {
|
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
});
|
|
var __commonJS = (cb, mod) => function __require2() {
|
|
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, from, except, desc) => {
|
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
for (let key of __getOwnPropNames(from))
|
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, 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
|
|
));
|
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
|
|
// ../../node_modules/bare-timers/binding.js
|
|
var require_binding = __commonJS({
|
|
"../../node_modules/bare-timers/binding.js"(exports, module) {
|
|
module.exports = __require.addon();
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-timers/lib/heap.js
|
|
var require_heap = __commonJS({
|
|
"../../node_modules/bare-timers/lib/heap.js"(exports, module) {
|
|
function compare(a, b) {
|
|
return a._expiry < b._expiry ? -1 : a._expiry > b._expiry ? 1 : a._id < b._id ? -1 : a._id > b._id ? 1 : 0;
|
|
}
|
|
module.exports = class Heap {
|
|
constructor() {
|
|
this._data = [];
|
|
}
|
|
get length() {
|
|
return this._data.length;
|
|
}
|
|
push(value) {
|
|
value._index = this._data.length;
|
|
this._data.push(value);
|
|
this._up(this._data.length - 1);
|
|
}
|
|
shift() {
|
|
const data = this._data;
|
|
if (data.length === 0) return void 0;
|
|
const root = data[0];
|
|
root._index = -1;
|
|
const last = data.pop();
|
|
if (data.length > 0) {
|
|
data[0] = last;
|
|
last._index = 0;
|
|
this._down(0);
|
|
}
|
|
return root;
|
|
}
|
|
peek() {
|
|
return this._data[0];
|
|
}
|
|
update(value) {
|
|
const data = this._data;
|
|
const i = value._index;
|
|
if (i < 0 || i >= data.length) return;
|
|
if (i > 0) {
|
|
const parent = (i - 1) / 2 | 0;
|
|
if (compare(data[i], data[parent]) < 0) {
|
|
return this._up(i);
|
|
}
|
|
}
|
|
this._down(i);
|
|
}
|
|
_swap(i, j) {
|
|
const data = this._data;
|
|
const value = data[i];
|
|
data[i] = data[j];
|
|
data[i]._index = i;
|
|
data[j] = value;
|
|
data[j]._index = j;
|
|
}
|
|
_up(i) {
|
|
const data = this._data;
|
|
while (i > 0) {
|
|
const parent = (i - 1) / 2 | 0;
|
|
if (compare(data[i], data[parent]) >= 0) break;
|
|
this._swap(i, parent);
|
|
i = parent;
|
|
}
|
|
}
|
|
_down(i) {
|
|
const data = this._data;
|
|
const length = data.length;
|
|
while (true) {
|
|
const left = 2 * i + 1;
|
|
const right = 2 * i + 2;
|
|
let smallest = i;
|
|
if (left < length && compare(data[left], data[smallest]) < 0) {
|
|
smallest = left;
|
|
}
|
|
if (right < length && compare(data[right], data[smallest]) < 0) {
|
|
smallest = right;
|
|
}
|
|
if (smallest === i) break;
|
|
this._swap(i, smallest);
|
|
i = smallest;
|
|
}
|
|
}
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-timers/promises.js
|
|
var require_promises = __commonJS({
|
|
"../../node_modules/bare-timers/promises.js"(exports) {
|
|
var timers = require_bare_timers();
|
|
exports.setTimeout = function setTimeout(delay = 1, value, opts = {}) {
|
|
const { ref, signal } = opts;
|
|
if (signal && signal.aborted) return Promise.reject(signal.reason);
|
|
return new Promise((resolve, reject) => {
|
|
if (signal) signal.addEventListener("abort", onabort);
|
|
const timer = timers.setTimeout(ontimeout, delay);
|
|
if (ref === false) timer.unref();
|
|
function ontimeout() {
|
|
if (signal) signal.removeEventListener("abort", onabort);
|
|
resolve(value);
|
|
}
|
|
function onabort() {
|
|
timers.clearTimeout(timer);
|
|
signal.removeEventListener("abort", onabort);
|
|
reject(signal.reason);
|
|
}
|
|
});
|
|
};
|
|
exports.setInterval = function setInterval(delay = 1, value, opts = {}) {
|
|
const { ref, signal } = opts;
|
|
if (signal && signal.aborted) throw signal.reason;
|
|
let error = null;
|
|
let done = false;
|
|
let timeouts = 0;
|
|
const promises = [];
|
|
if (signal && signal.aborted) throw signal.reason;
|
|
if (signal) signal.removeEventListener("abort", onabort);
|
|
let timer = timers.setInterval(ontimeout, delay);
|
|
if (ref === false) timer.unref();
|
|
return {
|
|
next() {
|
|
if (timeouts > 0) {
|
|
timeouts--;
|
|
return Promise.resolve({ value, done: false });
|
|
}
|
|
if (error) {
|
|
const err = error;
|
|
error = null;
|
|
return Promise.reject(err);
|
|
}
|
|
if (done) return onclose();
|
|
return new Promise((resolve, reject) => promises.push({ resolve, reject }));
|
|
},
|
|
return() {
|
|
return onclose();
|
|
},
|
|
throw(err) {
|
|
return onerror(err);
|
|
},
|
|
[Symbol.asyncIterator]() {
|
|
return this;
|
|
}
|
|
};
|
|
function ontimeout() {
|
|
if (promises.length) {
|
|
promises.shift().resolve({ value, done: false });
|
|
} else {
|
|
timeouts++;
|
|
}
|
|
}
|
|
function onerror(err) {
|
|
timers.clearInterval(timer);
|
|
timer = null;
|
|
if (promises.length) {
|
|
promises.shift().reject(err);
|
|
} else {
|
|
error = err;
|
|
}
|
|
return Promise.resolve({ done: true });
|
|
}
|
|
function onabort() {
|
|
signal.removeEventListener("abort", onabort);
|
|
onerror(signal.reason);
|
|
}
|
|
function onclose() {
|
|
if (timer) timers.clearInterval(timer);
|
|
if (signal) signal.removeEventListener("abort", onabort);
|
|
done = true;
|
|
if (promises.length) promises.shift().resolve({ done: true });
|
|
return Promise.resolve({ done: true });
|
|
}
|
|
};
|
|
exports.setImmediate = function setImmediate(value, opts = {}) {
|
|
const { ref, signal } = opts;
|
|
if (signal && signal.aborted) return Promise.reject(signal.reason);
|
|
return new Promise((resolve, reject) => {
|
|
if (signal) signal.addEventListener("abort", onabort);
|
|
const timer = timers.setImmediate(ontimeout);
|
|
if (ref === false) timer.unref();
|
|
function ontimeout() {
|
|
if (signal) signal.removeEventListener("abort", onabort);
|
|
resolve(value);
|
|
}
|
|
function onabort() {
|
|
timers.clearImmediate(timer);
|
|
signal.removeEventListener("abort", onabort);
|
|
reject(signal.reason);
|
|
}
|
|
});
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-timers/index.js
|
|
var require_bare_timers = __commonJS({
|
|
"../../node_modules/bare-timers/index.js"(exports) {
|
|
var binding = require_binding();
|
|
var Heap = require_heap();
|
|
var TIMEOUT = 1;
|
|
var IMMEDIATE = 2;
|
|
var ACTIVE = 1;
|
|
var CLEARED = 2;
|
|
var REFED = 4;
|
|
var REPEAT = 8;
|
|
var Task = class _Task {
|
|
static _id = 0;
|
|
constructor(scheduler2, callback, args) {
|
|
this._id = ++_Task._id;
|
|
this._state = ACTIVE | REFED;
|
|
this._scheduler = scheduler2;
|
|
this._callback = callback;
|
|
this._args = args;
|
|
}
|
|
ref() {
|
|
this._scheduler._ref(this);
|
|
return this;
|
|
}
|
|
unref() {
|
|
this._scheduler._unref(this);
|
|
return this;
|
|
}
|
|
hasRef() {
|
|
return (this._state & REFED) !== 0;
|
|
}
|
|
[Symbol.dispose]() {
|
|
this._scheduler._clear(this);
|
|
}
|
|
};
|
|
var Timeout = class extends Task {
|
|
constructor(scheduler2, delay, expiry, repeat, callback, args) {
|
|
super(scheduler2, callback, args);
|
|
this._index = -1;
|
|
this._delay = delay;
|
|
this._expiry = expiry;
|
|
if (repeat) this._state |= REPEAT;
|
|
}
|
|
get _type() {
|
|
return TIMEOUT;
|
|
}
|
|
refresh() {
|
|
this._scheduler._refresh(this);
|
|
return this;
|
|
}
|
|
};
|
|
var Immediate = class extends Task {
|
|
get _type() {
|
|
return IMMEDIATE;
|
|
}
|
|
};
|
|
var Scheduler = class {
|
|
constructor() {
|
|
this._refs = 0;
|
|
this._timeouts = new Heap();
|
|
this._immediates = [];
|
|
this._handle = binding.init(this, this._ontimeout, this._onimmediate);
|
|
const stop = this._stop.bind(this);
|
|
const start = this._start.bind(this);
|
|
Bare.on("idle", stop).on("resume", start).on("wakeup", start);
|
|
}
|
|
_acquire() {
|
|
if (this._refs++ === 0) binding.ref(this._handle);
|
|
}
|
|
_release() {
|
|
if (--this._refs === 0) binding.unref(this._handle);
|
|
}
|
|
_timeout(delay, repeat, callback, args = []) {
|
|
delay = Math.floor(delay);
|
|
if (delay < 1 || delay > Number.MAX_SAFE_INTEGER || Number.isNaN(delay)) {
|
|
delay = 1;
|
|
}
|
|
const now = Date.now();
|
|
const timeout = new Timeout(this, delay, now + delay, repeat, callback, args);
|
|
this._acquire();
|
|
const next = this._timeouts.peek();
|
|
if (next === void 0 || next._expiry > timeout._expiry) {
|
|
binding.timeout(this._handle, Math.max(0, timeout._expiry - now));
|
|
}
|
|
this._timeouts.push(timeout);
|
|
return timeout;
|
|
}
|
|
_refresh(timeout) {
|
|
timeout._expiry = Date.now() + timeout._delay;
|
|
if ((timeout._state & ACTIVE) !== 0) {
|
|
if ((timeout._state & CLEARED) !== 0) {
|
|
timeout._state &= ~CLEARED;
|
|
if ((timeout._state & REFED) !== 0) this._acquire();
|
|
}
|
|
this._timeouts.update(timeout);
|
|
} else {
|
|
timeout._state |= ACTIVE;
|
|
if ((timeout._state & REFED) !== 0) this._acquire();
|
|
this._timeouts.push(timeout);
|
|
}
|
|
}
|
|
_immediate(callback, args = []) {
|
|
const immediate = new Immediate(this, callback, args);
|
|
this._acquire();
|
|
if (this._immediates.length === 0) binding.immediate(this._handle);
|
|
this._immediates.push(immediate);
|
|
return immediate;
|
|
}
|
|
_clear(task) {
|
|
if (typeof task !== "object" || task === null) return;
|
|
if ((task._state & CLEARED) !== 0 || (task._state & ACTIVE) === 0) {
|
|
return;
|
|
}
|
|
task._state |= CLEARED;
|
|
if ((task._state & REFED) !== 0) this._release();
|
|
if (task._type === TIMEOUT) {
|
|
task._expiry = 0;
|
|
binding.timeout(this._handle, 0);
|
|
this._timeouts.update(task);
|
|
}
|
|
}
|
|
_ref(task) {
|
|
if ((task._state & REFED) !== 0 || (task._state & ACTIVE) === 0) {
|
|
return;
|
|
}
|
|
task._state |= REFED;
|
|
this._acquire();
|
|
}
|
|
_unref(task) {
|
|
if ((task._state & REFED) === 0 || (task._state & ACTIVE) === 0) {
|
|
return;
|
|
}
|
|
task._state &= ~REFED;
|
|
this._release();
|
|
}
|
|
_stop() {
|
|
binding.stop(this._handle);
|
|
}
|
|
_start() {
|
|
if (this._timeouts.length > 0) binding.timeout(this._handle, 0);
|
|
if (this._immediates.length > 0) binding.immediate(this._handle);
|
|
}
|
|
_ontimeout() {
|
|
let caught = false;
|
|
let err = null;
|
|
while (this._timeouts.length > 0) {
|
|
const now = Date.now();
|
|
const timeout = this._timeouts.peek();
|
|
if ((timeout._state & CLEARED) !== 0) {
|
|
timeout._state &= ~ACTIVE & ~CLEARED;
|
|
this._timeouts.shift();
|
|
continue;
|
|
}
|
|
if (caught || timeout._expiry > now) {
|
|
binding.timeout(this._handle, Math.max(0, timeout._expiry - now));
|
|
break;
|
|
}
|
|
if ((timeout._state & REPEAT) !== 0) {
|
|
timeout._expiry = now + timeout._delay;
|
|
this._timeouts.update(timeout);
|
|
} else {
|
|
timeout._state &= ~ACTIVE;
|
|
if ((timeout._state & REFED) !== 0) this._release();
|
|
this._timeouts.shift();
|
|
}
|
|
try {
|
|
Reflect.apply(timeout._callback, null, timeout._args);
|
|
} catch (e) {
|
|
caught = true;
|
|
err = e;
|
|
}
|
|
}
|
|
if (caught) throw err;
|
|
}
|
|
_onimmediate() {
|
|
const immediates = this._immediates;
|
|
this._immediates = [];
|
|
let caught = false;
|
|
let err = null;
|
|
for (let i = 0, n = immediates.length; i < n; i++) {
|
|
const immediate = immediates[i];
|
|
if ((immediate._state & CLEARED) !== 0) {
|
|
immediate._state &= ~ACTIVE & ~CLEARED;
|
|
continue;
|
|
}
|
|
if (caught) {
|
|
const remaining = immediates.slice(i);
|
|
if (this._immediates.length === 0) {
|
|
this._immediates = remaining;
|
|
} else {
|
|
this._immediates = remaining.concat(this._immediates);
|
|
}
|
|
binding.immediate(this._handle);
|
|
break;
|
|
}
|
|
immediate._state &= ~ACTIVE;
|
|
if ((immediate._state & REFED) !== 0) this._release();
|
|
try {
|
|
Reflect.apply(immediate._callback, null, immediate._args);
|
|
} catch (e) {
|
|
caught = true;
|
|
err = e;
|
|
}
|
|
}
|
|
if (caught) throw err;
|
|
}
|
|
};
|
|
var scheduler = new Scheduler();
|
|
exports.setTimeout = function setTimeout(callback, delay, ...args) {
|
|
return scheduler._timeout(delay, false, callback, args);
|
|
};
|
|
exports.clearTimeout = function clearTimeout(timeout) {
|
|
scheduler._clear(timeout);
|
|
};
|
|
exports.setInterval = function setInterval(callback, delay, ...args) {
|
|
return scheduler._timeout(delay, true, callback, args);
|
|
};
|
|
exports.clearInterval = function clearInterval(timeout) {
|
|
scheduler._clear(timeout);
|
|
};
|
|
exports.setImmediate = function setImmediate(callback, ...args) {
|
|
return scheduler._immediate(callback, args);
|
|
};
|
|
exports.clearImmediate = function clearImmediate(immediate) {
|
|
scheduler._clear(immediate);
|
|
};
|
|
exports.promises = require_promises();
|
|
}
|
|
});
|
|
|
|
// ../../bare-lib-entry-bareTimers.js
|
|
var bare_lib_entry_bareTimers_exports = {};
|
|
__export(bare_lib_entry_bareTimers_exports, {
|
|
default: () => bare_lib_entry_bareTimers_default
|
|
});
|
|
var import_bare_timers = __toESM(require_bare_timers());
|
|
var bare_lib_entry_bareTimers_default = import_bare_timers.default;
|
|
return __toCommonJS(bare_lib_entry_bareTimers_exports);
|
|
})();
|
|
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};var e=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;var v=e!=null&&typeof e==="object"&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e;g[s]["bareTimers"]=v;})();
|