146 lines
3.5 KiB
JavaScript
146 lines
3.5 KiB
JavaScript
/*
|
|
* Extracted from browser-delivered Turbopack chunk: fd0220e4d10052af.701bdafa2d.js
|
|
* Module id: 217884
|
|
* For reading/searching only; this factory depends on the original Turbopack runtime.
|
|
*/
|
|
|
|
const moduleFactory = (e) => {
|
|
"use strict";
|
|
let t = void 0 !== e.i(23741).default && !1;
|
|
function n() {
|
|
return !0;
|
|
}
|
|
let i = [],
|
|
r = [],
|
|
a = 0,
|
|
o = 0,
|
|
s = !1,
|
|
c = new Set(),
|
|
l =
|
|
"function" == typeof requestIdleCallback
|
|
? (e) => requestIdleCallback(e, { timeout: 5e3 })
|
|
: (e) => setTimeout(e, 2e3),
|
|
u =
|
|
"function" == typeof cancelIdleCallback
|
|
? cancelIdleCallback
|
|
: clearTimeout,
|
|
h = null;
|
|
function f(e, t) {
|
|
e.status = "running";
|
|
let n = new AbortController();
|
|
(e.abort = n),
|
|
"warm" === t ? a++ : o++,
|
|
c.add(e.url),
|
|
y({
|
|
kind: "start",
|
|
url: e.url,
|
|
lane: t,
|
|
tierKind: e.kind,
|
|
nodeId: e.nodeId,
|
|
});
|
|
let i = { mode: "cors", signal: n.signal };
|
|
"idle" === t && (i.priority = "low"),
|
|
fetch(e.url, i)
|
|
.catch(() => void 0)
|
|
.finally(() => {
|
|
(e.abort = null),
|
|
"warm" === t ? a-- : o--,
|
|
y({
|
|
kind: "complete",
|
|
url: e.url,
|
|
lane: t,
|
|
tierKind: e.kind,
|
|
nodeId: e.nodeId,
|
|
}),
|
|
d();
|
|
});
|
|
}
|
|
function d() {
|
|
null !== h && u(h),
|
|
(h = l(() => {
|
|
for (h = null; a < 4 && i.length > 0; ) {
|
|
let e = i.shift();
|
|
!e || c.has(e.url) || f(e, "warm");
|
|
}
|
|
if (!s)
|
|
for (; o < 2 && r.length > 0; ) {
|
|
let e = r.shift();
|
|
!e || c.has(e.url) || f(e, "idle");
|
|
}
|
|
}));
|
|
}
|
|
function p(e, t, n, a) {
|
|
if (c.has(e)) return;
|
|
let o = "warm" === n ? i : r;
|
|
o.some((t) => t.url === e) ||
|
|
(o.push({ url: e, kind: t, nodeId: a, status: "queued", abort: null }),
|
|
y({
|
|
kind: "enqueue",
|
|
url: e,
|
|
lane: n,
|
|
tierKind: t,
|
|
nodeId: a,
|
|
queueDepth: o.length,
|
|
}),
|
|
d());
|
|
}
|
|
function g(e) {
|
|
c.add(e);
|
|
}
|
|
function b(e) {
|
|
let t = s;
|
|
(s = e), t && !e && d();
|
|
}
|
|
function m(e) {
|
|
w(i, e) + w(r, e) > 0 &&
|
|
y({ kind: "cancelled", nodeId: e, queueDepth: i.length + r.length });
|
|
}
|
|
function w(e, t) {
|
|
let n = 0;
|
|
for (let i = e.length - 1; i >= 0; i--)
|
|
e[i].nodeId === t && "queued" === e[i].status && (e.splice(i, 1), n++);
|
|
return n;
|
|
}
|
|
function v() {
|
|
for (let e of [...i, ...r]) e.abort && e.abort.abort();
|
|
(i.length = 0),
|
|
(r.length = 0),
|
|
(a = 0),
|
|
(o = 0),
|
|
(s = !1),
|
|
c.clear(),
|
|
null !== h && (u(h), (h = null)),
|
|
y({ kind: "reset" });
|
|
}
|
|
let x = new Set();
|
|
function y(e) {
|
|
for (let n of (t &&
|
|
console.debug(
|
|
"[tier-scheduler]",
|
|
e.kind,
|
|
e.url?.slice(-60) ?? "",
|
|
e.lane ?? "",
|
|
),
|
|
x))
|
|
try {
|
|
n(e);
|
|
} catch {}
|
|
}
|
|
e.s([
|
|
"cancelByOwner",
|
|
() => m,
|
|
"enqueueTierPrefetch",
|
|
() => p,
|
|
"isTierSchedulerEnabled",
|
|
() => n,
|
|
"markUrlKnown",
|
|
() => g,
|
|
"resetScheduler",
|
|
() => v,
|
|
"setSchedulerInteracting",
|
|
() => b,
|
|
]);
|
|
};
|
|
|
|
export default moduleFactory;
|