524 lines
19 KiB
JavaScript
524 lines
19 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-performance/binding.js
|
|
var require_binding = __commonJS({
|
|
"../../node_modules/bare-performance/binding.js"(exports, module) {
|
|
module.exports = __require.addon();
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-performance/lib/hr-time.js
|
|
var require_hr_time = __commonJS({
|
|
"../../node_modules/bare-performance/lib/hr-time.js"(exports) {
|
|
var binding = require_binding();
|
|
var { TIME_ORIGIN } = binding;
|
|
exports.now = function now() {
|
|
return binding.now() / 1e6 - TIME_ORIGIN;
|
|
};
|
|
exports.timeOrigin = TIME_ORIGIN;
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-performance/lib/constants.js
|
|
var require_constants = __commonJS({
|
|
"../../node_modules/bare-performance/lib/constants.js"(exports, module) {
|
|
module.exports = {
|
|
observerType: {
|
|
UNDEFINED: 1,
|
|
SINGLE: 2,
|
|
MULTIPLE: 3
|
|
}
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-performance/lib/errors.js
|
|
var require_errors = __commonJS({
|
|
"../../node_modules/bare-performance/lib/errors.js"(exports) {
|
|
var InvalidModificationError = class extends Error {
|
|
get name() {
|
|
return "InvalidModificationError";
|
|
}
|
|
};
|
|
exports.InvalidModificationError = InvalidModificationError;
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-performance/lib/timing.js
|
|
var require_timing = __commonJS({
|
|
"../../node_modules/bare-performance/lib/timing.js"(exports) {
|
|
var binding = require_binding();
|
|
var { now, timeOrigin } = require_hr_time();
|
|
var { observerType } = require_constants();
|
|
var { InvalidModificationError } = require_errors();
|
|
var globalObservers = /* @__PURE__ */ new Set();
|
|
var globalPendingObservers = /* @__PURE__ */ new Set();
|
|
var globalBuffer = [];
|
|
var pending = false;
|
|
exports.PerformanceEntry = class PerformanceEntry {
|
|
constructor(name, type, start, duration) {
|
|
this._name = name;
|
|
this._type = type;
|
|
this._start = start;
|
|
this._duration = duration;
|
|
}
|
|
get name() {
|
|
return this._name;
|
|
}
|
|
get entryType() {
|
|
return this._type;
|
|
}
|
|
get startTime() {
|
|
return this._start;
|
|
}
|
|
get duration() {
|
|
return this._duration;
|
|
}
|
|
};
|
|
var PerformanceGCEntry = class _PerformanceGCEntry extends exports.PerformanceEntry {
|
|
static _handle = null;
|
|
static _refs = 0;
|
|
static _ref() {
|
|
if (this._refs++ === 0) {
|
|
this._handle = binding.enableGarbageCollectionTracking(this, this._onentry);
|
|
}
|
|
}
|
|
static _unref() {
|
|
if (--this._refs === 0) {
|
|
binding.disableGarbageCollectionTracking(this._handle);
|
|
this._handle = null;
|
|
}
|
|
}
|
|
static _onentry(startTime, duration, kind) {
|
|
startTime -= timeOrigin;
|
|
const entry = new _PerformanceGCEntry(startTime, duration, kind);
|
|
processEntry(entry);
|
|
}
|
|
constructor(startTime, duration, kind) {
|
|
super("gc", "gc", startTime, duration);
|
|
this._detail = { kind };
|
|
}
|
|
get detail() {
|
|
return this._detail;
|
|
}
|
|
};
|
|
exports.PerformanceMark = class PerformanceMark extends exports.PerformanceEntry {
|
|
constructor(name, opts = {}) {
|
|
const { startTime = now(), detail = null } = opts;
|
|
super(name, "mark", startTime, 0);
|
|
this._detail = detail;
|
|
}
|
|
get detail() {
|
|
return this._detail;
|
|
}
|
|
};
|
|
exports.PerformanceMeasure = class PerformanceMeasure extends exports.PerformanceEntry {
|
|
constructor(name, startTime, duration, opts = {}) {
|
|
const { detail = null } = opts;
|
|
super(name, "measure", startTime, duration);
|
|
this._detail = detail;
|
|
}
|
|
get detail() {
|
|
return this._detail;
|
|
}
|
|
};
|
|
exports.PerformanceObserverEntryList = class PerformanceObserverEntryList {
|
|
constructor(entryList) {
|
|
this._list = entryList;
|
|
}
|
|
getEntries() {
|
|
return this._list;
|
|
}
|
|
getEntriesByType(type) {
|
|
return this._list.filter((entry) => entry.entryType === type);
|
|
}
|
|
getEntriesByName(name) {
|
|
return this._list.filter((entry) => entry.name === name);
|
|
}
|
|
};
|
|
exports.PerformanceObserver = class PerformanceObserver {
|
|
constructor(cb) {
|
|
this._entryTypes = /* @__PURE__ */ new Set();
|
|
this._type = observerType.UNDEFINED;
|
|
this._buffer = [];
|
|
this._cb = cb;
|
|
}
|
|
static get supportedEntryTypes() {
|
|
return ["mark", "measure", "gc"];
|
|
}
|
|
observe(opts = {}) {
|
|
if (!opts.entryTypes && !opts.type || opts.entryTypes && opts.type) {
|
|
throw new TypeError("opts.entryTypes OR opts.type must be specified");
|
|
}
|
|
if (this._type === observerType.MULTIPLE && opts.type || this._type === observerType.SINGLE && opts.entryTypes) {
|
|
throw new InvalidModificationError("Cannot change the PerformanceObserver type");
|
|
}
|
|
if (this._type === observerType.UNDEFINED) {
|
|
this._type = opts.entryTypes ? observerType.MULTIPLE : observerType.SINGLE;
|
|
}
|
|
this._entryTypes.clear();
|
|
if (this._type === observerType.MULTIPLE) {
|
|
for (const entryType of opts.entryTypes) {
|
|
if (PerformanceObserver.supportedEntryTypes.includes(entryType)) {
|
|
this._entryTypes.add(entryType);
|
|
}
|
|
}
|
|
} else {
|
|
if (PerformanceObserver.supportedEntryTypes.includes(opts.type)) {
|
|
this._entryTypes.add(opts.type);
|
|
if (opts.buffered === true) {
|
|
const bufferedEntries = globalBuffer.filter((entry) => entry.entryType === opts.type);
|
|
if (bufferedEntries.length > 0) {
|
|
this._buffer.push(...bufferedEntries);
|
|
globalPendingObservers.add(this);
|
|
processPendingObservers();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (this._entryTypes.size > 0) {
|
|
globalObservers.add(this);
|
|
if (this._entryTypes.has("gc")) PerformanceGCEntry._ref();
|
|
} else {
|
|
this.disconnect();
|
|
}
|
|
}
|
|
takeRecords() {
|
|
const buf = this._buffer;
|
|
this._buffer = [];
|
|
return buf;
|
|
}
|
|
disconnect() {
|
|
globalObservers.delete(this);
|
|
if (this._entryTypes.has("gc")) PerformanceGCEntry._unref();
|
|
this._entryTypes.clear();
|
|
this._type = observerType.UNDEFINED;
|
|
}
|
|
};
|
|
exports.mark = function mark(name, opts) {
|
|
const mark2 = new exports.PerformanceMark(name, opts);
|
|
processEntry(mark2);
|
|
globalBuffer.push(mark2);
|
|
return mark2;
|
|
};
|
|
exports.clearMarks = function clearMarks(name) {
|
|
if (name) {
|
|
globalBuffer = globalBuffer.filter((entry) => entry.name !== name && entry.entryType !== "mark");
|
|
} else {
|
|
globalBuffer = globalBuffer.filter((entry) => entry.entryType !== "mark");
|
|
}
|
|
};
|
|
exports.measure = function measure(name, start, end) {
|
|
let opts = {};
|
|
if (typeof start === "object" && start !== null && Object.keys(start).length > 0) {
|
|
opts = start;
|
|
if (!opts.start && !opts.end) {
|
|
throw new TypeError("opts.start or opts.end must be specified");
|
|
}
|
|
if (opts.start && opts.end && opts.duration) {
|
|
throw new TypeError("One of opts.start, opts.end or opts.duration must not be specified");
|
|
}
|
|
start = opts.start;
|
|
end = opts.end;
|
|
}
|
|
let endTime;
|
|
if (end) {
|
|
endTime = toTimestamp(end);
|
|
} else if (start && opts.duration) {
|
|
endTime = toTimestamp(start) + toTimestamp(duration);
|
|
} else {
|
|
endTime = now();
|
|
}
|
|
let startTime;
|
|
if (start) {
|
|
startTime = toTimestamp(start);
|
|
} else if (end && opts.duration) {
|
|
startTime = toTimestamp(end) - toTimestamp(duration);
|
|
} else {
|
|
startTime = 0;
|
|
}
|
|
const duration = endTime - startTime;
|
|
const measure2 = new exports.PerformanceMeasure(name, startTime, duration, opts);
|
|
processEntry(measure2);
|
|
globalBuffer.push(measure2);
|
|
return measure2;
|
|
};
|
|
exports.clearMeasures = function clearMeasures(name) {
|
|
if (name) {
|
|
globalBuffer = globalBuffer.filter(
|
|
(entry) => entry.name !== name && entry.entryType !== "measure"
|
|
);
|
|
} else {
|
|
globalBuffer = globalBuffer.filter((entry) => entry.entryType !== "measure");
|
|
}
|
|
};
|
|
exports.getEntries = function getEntries() {
|
|
return new exports.PerformanceObserverEntryList(globalBuffer).getEntries();
|
|
};
|
|
exports.getEntriesByName = function getEntriesByName(name) {
|
|
return new exports.PerformanceObserverEntryList(globalBuffer).getEntriesByName(name);
|
|
};
|
|
exports.getEntriesByType = function getEntriesByType(type) {
|
|
return new exports.PerformanceObserverEntryList(globalBuffer).getEntriesByType(type);
|
|
};
|
|
function processEntry(entry) {
|
|
for (const observer of globalObservers) {
|
|
if (observer._entryTypes.has(entry.entryType)) {
|
|
observer._buffer.push(entry);
|
|
globalPendingObservers.add(observer);
|
|
processPendingObservers();
|
|
}
|
|
}
|
|
}
|
|
function processPendingObservers() {
|
|
if (pending) return;
|
|
pending = true;
|
|
setImmediate(() => {
|
|
pending = false;
|
|
const observers = Array.from(globalPendingObservers.values());
|
|
globalPendingObservers.clear();
|
|
for (const observer of observers) {
|
|
observer._cb(new exports.PerformanceObserverEntryList(observer.takeRecords()), observer);
|
|
}
|
|
});
|
|
}
|
|
function toTimestamp(mark) {
|
|
if (typeof mark === "string") {
|
|
const performanceMark = globalBuffer.findLast(
|
|
(entry) => entry.name === mark && entry.entryType === "mark"
|
|
);
|
|
if (performanceMark === void 0) {
|
|
throw new SyntaxError(`Mark ${mark} not found`);
|
|
}
|
|
return performanceMark.startTime;
|
|
} else if (typeof mark === "number") {
|
|
return mark;
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-performance/lib/histogram.js
|
|
var require_histogram = __commonJS({
|
|
"../../node_modules/bare-performance/lib/histogram.js"(exports) {
|
|
var binding = require_binding();
|
|
var Histogram = class {
|
|
constructor(opts = {}) {
|
|
const { lowest = 1, highest = Number.MAX_SAFE_INTEGER, figures = 3 } = opts;
|
|
this._handle = binding.histogramInit(this, lowest, highest, figures);
|
|
this._count = 0;
|
|
this._exceeds = 0;
|
|
}
|
|
get max() {
|
|
return binding.histogramMax(this._handle);
|
|
}
|
|
get min() {
|
|
return binding.histogramMin(this._handle);
|
|
}
|
|
get mean() {
|
|
return binding.histogramMean(this._handle);
|
|
}
|
|
get percentiles() {
|
|
return new Map(binding.histogramPercentiles(this._handle));
|
|
}
|
|
get stddev() {
|
|
return binding.histogramStddev(this._handle);
|
|
}
|
|
get count() {
|
|
return this._count;
|
|
}
|
|
get exceeds() {
|
|
return this._exceeds;
|
|
}
|
|
percentile(percentile) {
|
|
return binding.histogramPercentile(this._handle, percentile);
|
|
}
|
|
reset() {
|
|
this._count = 0;
|
|
this._exceeds = 0;
|
|
binding.histogramReset(this._handle);
|
|
}
|
|
};
|
|
exports.RecordableHistogram = class RecordableHistogram extends Histogram {
|
|
add(other) {
|
|
this._count += other._count;
|
|
this._exceeds += other._exceeds;
|
|
binding.histogramAdd(this._handle, other._handle);
|
|
}
|
|
record(value) {
|
|
if (binding.histogramRecord(this._handle, value)) this._count++;
|
|
else this._exceeds++;
|
|
}
|
|
};
|
|
exports.IntervalHistogram = class IntervalHistogram extends Histogram {
|
|
constructor(opts = {}) {
|
|
const { resolution = 10 } = opts;
|
|
super({
|
|
lowest: 1,
|
|
highest: 36e11
|
|
// One hour in nanoseconds
|
|
});
|
|
this._resolution = resolution;
|
|
this._enabled = false;
|
|
this._timerId = -1;
|
|
this._timerStartTime = -1;
|
|
}
|
|
enable() {
|
|
if (this._enabled === true) return false;
|
|
this._timerStartTime = binding.now();
|
|
this._timerId = setInterval(this._oninterval.bind(this), this._resolution);
|
|
this._timerId.unref();
|
|
this._enabled = true;
|
|
return true;
|
|
}
|
|
disable() {
|
|
if (this._enabled === false) return false;
|
|
clearInterval(this._timerId);
|
|
this._enabled = false;
|
|
return true;
|
|
}
|
|
_oninterval() {
|
|
const now = binding.now();
|
|
const actual = now - this._timerStartTime;
|
|
const expected = this._resolution * 1e6;
|
|
const hasDelay = actual > expected;
|
|
if (hasDelay) {
|
|
const delay = actual - expected;
|
|
if (binding.histogramRecord(this._handle, delay)) this._count++;
|
|
else this._exceeds++;
|
|
}
|
|
this._timerStartTime = now;
|
|
}
|
|
[Symbol.dispose]() {
|
|
this.disable();
|
|
}
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-performance/index.js
|
|
var require_bare_performance = __commonJS({
|
|
"../../node_modules/bare-performance/index.js"(exports) {
|
|
var { now, timeOrigin } = require_hr_time();
|
|
var {
|
|
PerformanceEntry,
|
|
PerformanceMark,
|
|
PerformanceMeasure,
|
|
PerformanceObserverEntryList,
|
|
PerformanceObserver,
|
|
mark,
|
|
clearMarks,
|
|
measure,
|
|
clearMeasures,
|
|
getEntries,
|
|
getEntriesByName,
|
|
getEntriesByType
|
|
} = require_timing();
|
|
var { RecordableHistogram, IntervalHistogram } = require_histogram();
|
|
var binding = require_binding();
|
|
exports.now = now;
|
|
exports.timeOrigin = timeOrigin;
|
|
exports.eventLoopUtilization = function eventLoopUtilization(prevUtil, secUtil) {
|
|
if (secUtil) {
|
|
const idle2 = prevUtil.idle - secUtil.idle;
|
|
const active2 = prevUtil.active - secUtil.active;
|
|
return { idle: idle2, active: active2, utilization: active2 / (idle2 + active2) };
|
|
}
|
|
let idle = exports.idleTime();
|
|
if (idle === 0) return { idle: 0, active: 0, utilization: 0 };
|
|
let active = exports.now() - idle;
|
|
if (!prevUtil) return { idle, active, utilization: active / (idle + active) };
|
|
idle = idle - prevUtil.idle;
|
|
active = active - prevUtil.active;
|
|
return { idle, active, utilization: active / (idle + active) };
|
|
};
|
|
exports.idleTime = function idleTime() {
|
|
return binding.idleTime();
|
|
};
|
|
exports.metricsInfo = function metricsInfo() {
|
|
return binding.metricsInfo();
|
|
};
|
|
exports.performance = exports;
|
|
var PerformanceNodeTiming = class {
|
|
get idleTime() {
|
|
return exports.idleTime();
|
|
}
|
|
get uvMetricsInfo() {
|
|
return exports.metricsInfo();
|
|
}
|
|
};
|
|
exports.nodeTiming = new PerformanceNodeTiming();
|
|
exports.PerformanceEntry = PerformanceEntry;
|
|
exports.PerformanceMark = PerformanceMark;
|
|
exports.PerformanceMeasure = PerformanceMeasure;
|
|
exports.PerformanceObserverEntryList = PerformanceObserverEntryList;
|
|
exports.PerformanceObserver = PerformanceObserver;
|
|
exports.mark = mark;
|
|
exports.clearMarks = clearMarks;
|
|
exports.measure = measure;
|
|
exports.clearMeasures = clearMeasures;
|
|
exports.getEntries = getEntries;
|
|
exports.getEntriesByName = getEntriesByName;
|
|
exports.getEntriesByType = getEntriesByType;
|
|
exports.createHistogram = function createHistogram(opts) {
|
|
return new RecordableHistogram(opts);
|
|
};
|
|
exports.monitorEventLoopDelay = function monitorEventLoopDelay(opts) {
|
|
return new IntervalHistogram(opts);
|
|
};
|
|
exports.constants = {
|
|
NODE_PERFORMANCE_GC_MAJOR: binding.constants.MARK_COMPACT,
|
|
NODE_PERFORMANCE_GC_MINOR: binding.constants.GENERATIONAL,
|
|
NODE_PERFORMANCE_GC_INCREMENTAL: -1,
|
|
NODE_PERFORMANCE_GC_WEAKCB: -1
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../bare-lib-entry-barePerformance.js
|
|
var bare_lib_entry_barePerformance_exports = {};
|
|
__export(bare_lib_entry_barePerformance_exports, {
|
|
default: () => bare_lib_entry_barePerformance_default
|
|
});
|
|
var import_bare_performance = __toESM(require_bare_performance());
|
|
var bare_lib_entry_barePerformance_default = import_bare_performance.default;
|
|
return __toCommonJS(bare_lib_entry_barePerformance_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]["barePerformance"]=v;})();
|