@burdenoff/fe-libs 2026.1118.10 → 2026.1118.12
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.
|
@@ -37,71 +37,88 @@ function r(r) {
|
|
|
37
37
|
}
|
|
38
38
|
return null;
|
|
39
39
|
}
|
|
40
|
-
var i;
|
|
41
|
-
function a(
|
|
40
|
+
var i = null;
|
|
41
|
+
function a() {
|
|
42
|
+
if (typeof document > "u") return null;
|
|
43
|
+
if (i?.document !== document) {
|
|
44
|
+
let e = null;
|
|
45
|
+
try {
|
|
46
|
+
let t = document.createElement("canvas");
|
|
47
|
+
t.width = 1, t.height = 1, e = t.getContext("2d", { willReadFrequently: !0 });
|
|
48
|
+
} catch {
|
|
49
|
+
e = null;
|
|
50
|
+
}
|
|
51
|
+
i = {
|
|
52
|
+
document,
|
|
53
|
+
context: e
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return i.context;
|
|
57
|
+
}
|
|
58
|
+
function o(e, t) {
|
|
59
|
+
e.fillStyle = "#000000", e.fillStyle = t;
|
|
60
|
+
let n = String(e.fillStyle);
|
|
61
|
+
return e.fillStyle = "#ffffff", e.fillStyle = t, String(e.fillStyle) === n;
|
|
62
|
+
}
|
|
63
|
+
function s(e) {
|
|
42
64
|
let t = r(e);
|
|
43
65
|
if (t) return t;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
if (!i || typeof CSS < "u" && typeof CSS.supports == "function" && !CSS.supports("color", e)) return null;
|
|
51
|
-
i.fillStyle = e, i.clearRect(0, 0, 1, 1), i.fillRect(0, 0, 1, 1);
|
|
52
|
-
let [n, a, o, s] = i.getImageData(0, 0, 1, 1).data;
|
|
53
|
-
return s === 0 ? {
|
|
66
|
+
let n = a();
|
|
67
|
+
if (!n || typeof CSS < "u" && typeof CSS.supports == "function" && !CSS.supports("color", e) || !o(n, e)) return null;
|
|
68
|
+
n.clearRect(0, 0, 1, 1), n.fillRect(0, 0, 1, 1);
|
|
69
|
+
let [i, s, c, l] = n.getImageData(0, 0, 1, 1).data;
|
|
70
|
+
return l === 0 ? {
|
|
54
71
|
r: 0,
|
|
55
72
|
g: 0,
|
|
56
73
|
b: 0,
|
|
57
74
|
a: 0
|
|
58
75
|
} : {
|
|
59
|
-
r:
|
|
60
|
-
g:
|
|
61
|
-
b:
|
|
62
|
-
a:
|
|
76
|
+
r: i,
|
|
77
|
+
g: s,
|
|
78
|
+
b: c,
|
|
79
|
+
a: l / 255
|
|
63
80
|
};
|
|
64
81
|
}
|
|
65
|
-
function
|
|
66
|
-
return r(e) ??
|
|
82
|
+
function c(e) {
|
|
83
|
+
return r(e) ?? s(e);
|
|
67
84
|
}
|
|
68
|
-
function
|
|
69
|
-
let n =
|
|
85
|
+
function l(e, t) {
|
|
86
|
+
let n = c(e), r = c(t);
|
|
70
87
|
return n && r ? [n, r] : null;
|
|
71
88
|
}
|
|
72
|
-
var
|
|
89
|
+
var u = (e) => {
|
|
73
90
|
let t = e / 255;
|
|
74
91
|
return t <= .04045 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
|
|
75
|
-
},
|
|
92
|
+
}, d = (e) => {
|
|
76
93
|
let t = e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
|
|
77
94
|
return n(Math.round(t * 255), 0, 255);
|
|
78
95
|
};
|
|
79
|
-
function
|
|
80
|
-
let r =
|
|
96
|
+
function f({ r: e, g: t, b: n }) {
|
|
97
|
+
let r = u(e), i = u(t), a = u(n), o = Math.cbrt(.4122214708 * r + .5363325363 * i + .0514459929 * a), s = Math.cbrt(.2119034982 * r + .6806995451 * i + .1073969566 * a), c = Math.cbrt(.0883024619 * r + .2817188376 * i + .6299787005 * a);
|
|
81
98
|
return {
|
|
82
|
-
L: .2104542553 * o + .793617785 * s - .0040720468 *
|
|
83
|
-
a: 1.9779984951 * o - 2.428592205 * s + .4505937099 *
|
|
84
|
-
b: .0259040371 * o + .7827717662 * s - .808675766 *
|
|
99
|
+
L: .2104542553 * o + .793617785 * s - .0040720468 * c,
|
|
100
|
+
a: 1.9779984951 * o - 2.428592205 * s + .4505937099 * c,
|
|
101
|
+
b: .0259040371 * o + .7827717662 * s - .808675766 * c
|
|
85
102
|
};
|
|
86
103
|
}
|
|
87
|
-
function
|
|
88
|
-
let [n, r, i] =
|
|
104
|
+
function p(e, t = 1) {
|
|
105
|
+
let [n, r, i] = h(e);
|
|
89
106
|
return {
|
|
90
|
-
r:
|
|
91
|
-
g:
|
|
92
|
-
b:
|
|
107
|
+
r: d(n),
|
|
108
|
+
g: d(r),
|
|
109
|
+
b: d(i),
|
|
93
110
|
a: t
|
|
94
111
|
};
|
|
95
112
|
}
|
|
96
|
-
function
|
|
97
|
-
let i =
|
|
98
|
-
return
|
|
113
|
+
function m(e, t, r) {
|
|
114
|
+
let i = f(e), a = f(t), o = n(r, 0, 1);
|
|
115
|
+
return p({
|
|
99
116
|
L: i.L + (a.L - i.L) * o,
|
|
100
117
|
a: i.a + (a.a - i.a) * o,
|
|
101
118
|
b: i.b + (a.b - i.b) * o
|
|
102
119
|
}, e.a + (t.a - e.a) * o);
|
|
103
120
|
}
|
|
104
|
-
function
|
|
121
|
+
function h({ L: e, a: t, b: n }) {
|
|
105
122
|
let r = (e + .3963377774 * t + .2158037573 * n) ** 3, i = (e - .1055613458 * t - .0638541728 * n) ** 3, a = (e - .0894841775 * t - 1.291485548 * n) ** 3;
|
|
106
123
|
return [
|
|
107
124
|
4.0767416621 * r - 3.3077115913 * i + .2309699292 * a,
|
|
@@ -109,45 +126,45 @@ function p({ L: e, a: t, b: n }) {
|
|
|
109
126
|
-.0041960863 * r - .7034186147 * i + 1.707614701 * a
|
|
110
127
|
];
|
|
111
128
|
}
|
|
112
|
-
var
|
|
113
|
-
function
|
|
114
|
-
if (
|
|
129
|
+
var g = (e) => h(e).every((e) => e >= -1e-4 && e <= 1.0001);
|
|
130
|
+
function _(e, t = 1) {
|
|
131
|
+
if (g(e)) return p(e, t);
|
|
115
132
|
let n = 0, r = 1;
|
|
116
133
|
for (let t = 0; t < 12; t++) {
|
|
117
134
|
let t = (n + r) / 2;
|
|
118
|
-
|
|
135
|
+
g({
|
|
119
136
|
L: e.L,
|
|
120
137
|
a: e.a * t,
|
|
121
138
|
b: e.b * t
|
|
122
139
|
}) ? n = t : r = t;
|
|
123
140
|
}
|
|
124
|
-
return
|
|
141
|
+
return p({
|
|
125
142
|
L: e.L,
|
|
126
143
|
a: e.a * n,
|
|
127
144
|
b: e.b * n
|
|
128
145
|
}, t);
|
|
129
146
|
}
|
|
130
|
-
function
|
|
131
|
-
let i =
|
|
132
|
-
return
|
|
147
|
+
function v(e, t, r = 1) {
|
|
148
|
+
let i = f(e);
|
|
149
|
+
return _({
|
|
133
150
|
L: n(t, 0, 1),
|
|
134
151
|
a: i.a * r,
|
|
135
152
|
b: i.b * r
|
|
136
153
|
}, e.a);
|
|
137
154
|
}
|
|
138
|
-
function
|
|
139
|
-
return
|
|
155
|
+
function y(e) {
|
|
156
|
+
return f(e).L;
|
|
140
157
|
}
|
|
141
|
-
function
|
|
142
|
-
let t =
|
|
143
|
-
return
|
|
158
|
+
function b(e) {
|
|
159
|
+
let t = f(e);
|
|
160
|
+
return p({
|
|
144
161
|
L: n(1.08 - t.L, .12, .62),
|
|
145
162
|
a: t.a,
|
|
146
163
|
b: t.b
|
|
147
164
|
}, e.a);
|
|
148
165
|
}
|
|
149
|
-
function
|
|
166
|
+
function x({ r: e, g: t, b: r, a: i }, a = 1) {
|
|
150
167
|
let o = n(i * a, 0, 1);
|
|
151
168
|
return `rgba(${Math.round(e)}, ${Math.round(t)}, ${Math.round(r)}, ${Math.round(o * 1e3) / 1e3})`;
|
|
152
169
|
}
|
|
153
|
-
export {
|
|
170
|
+
export { x as cssRgba, p as fromOklab, _ as fromOklabInGamut, y as lightness, m as mixOklab, r as parseColor, c as readColor, l as readColorPair, s as resolveColor, b as toInk, f as toOklab, v as withLightness };
|
|
@@ -23,6 +23,22 @@ const PRECACHE_ASSETS = [
|
|
|
23
23
|
|
|
24
24
|
const CACHE_FIRST_RE = /^\/(assets|chunks|icons)\//;
|
|
25
25
|
|
|
26
|
+
// Hashed assets kept in the static cache. Every deploy adds a new set of
|
|
27
|
+
// content-hashed chunks and nothing else removes the old ones, so without a
|
|
28
|
+
// bound the cache grows for as long as this worker version lives. The oldest
|
|
29
|
+
// entries go first; an evicted chunk is just fetched again. A trim runs inside
|
|
30
|
+
// a fetch event's lifetime once this many entries were added since the last.
|
|
31
|
+
const MAX_STATIC_ENTRIES = 500;
|
|
32
|
+
const STATIC_TRIM_EVERY_PUTS = 50;
|
|
33
|
+
|
|
34
|
+
// Network fetches this worker runs at once for cache-first assets. A cold
|
|
35
|
+
// lazy route asks for 100+ chunks in one burst, and the worker is a single
|
|
36
|
+
// process making every one of them; unthrottled, headless Chrome failed them
|
|
37
|
+
// with net::ERR_INSUFFICIENT_RESOURCES. Each slot is held until the body is
|
|
38
|
+
// in the cache, so the cap bounds in-flight bodies too.
|
|
39
|
+
const MAX_CONCURRENT_ASSET_FETCHES = 8;
|
|
40
|
+
const ASSET_FETCH_RETRY_DELAY_MS = 750;
|
|
41
|
+
|
|
26
42
|
const OFFLINE_FALLBACK_HTML = '<!doctype html><html lang="en"><head><meta charset="utf-8">' +
|
|
27
43
|
'<meta name="viewport" content="width=device-width, initial-scale=1">' +
|
|
28
44
|
'<title>Offline</title></head><body style="font-family:system-ui,sans-serif;' +
|
|
@@ -56,6 +72,7 @@ self.addEventListener('activate', (event) => {
|
|
|
56
72
|
}
|
|
57
73
|
return Promise.all(deletions);
|
|
58
74
|
})
|
|
75
|
+
.then(() => trimStaticCache().catch(() => undefined))
|
|
59
76
|
.then(() => self.clients.claim())
|
|
60
77
|
);
|
|
61
78
|
});
|
|
@@ -89,7 +106,11 @@ self.addEventListener('fetch', (event) => {
|
|
|
89
106
|
|
|
90
107
|
// Content-hashed build outputs + icons: safe to cache.
|
|
91
108
|
if (CACHE_FIRST_RE.test(url.pathname)) {
|
|
92
|
-
|
|
109
|
+
const response = cacheFirstImmutable(request);
|
|
110
|
+
event.respondWith(response);
|
|
111
|
+
// waitUntil keeps the worker alive for the trim; an idle worker can be
|
|
112
|
+
// stopped at any time, so an untracked timer could never fire.
|
|
113
|
+
event.waitUntil(response.then(trimStaticCacheIfDue, () => undefined));
|
|
93
114
|
return;
|
|
94
115
|
}
|
|
95
116
|
|
|
@@ -118,19 +139,107 @@ async function networkFirstHTML(request) {
|
|
|
118
139
|
}
|
|
119
140
|
}
|
|
120
141
|
|
|
142
|
+
const inflightAssets = new Map();
|
|
143
|
+
const assetFetchQueue = [];
|
|
144
|
+
let activeAssetFetches = 0;
|
|
145
|
+
// The browser can stop this worker between sessions, so this counter does not survive a restart.
|
|
146
|
+
// Start it at the threshold: the first asset cached in each worker lifetime triggers a trim, and
|
|
147
|
+
// a session that caches only a few assets still keeps the cache bounded.
|
|
148
|
+
let putsSinceTrim = STATIC_TRIM_EVERY_PUTS;
|
|
149
|
+
let staticTrim = null;
|
|
150
|
+
|
|
121
151
|
async function cacheFirstImmutable(request) {
|
|
122
152
|
const cache = await caches.open(STATIC_CACHE);
|
|
123
153
|
const cached = await cache.match(request);
|
|
124
154
|
if (cached) return cached;
|
|
155
|
+
|
|
156
|
+
// A modulepreload and the import that follows it ask for the same URL.
|
|
157
|
+
// Every concurrent caller joins one network fetch and shares its outcome,
|
|
158
|
+
// a failure included, so a burst never turns into a burst of retries.
|
|
159
|
+
let shared = inflightAssets.get(request.url);
|
|
160
|
+
if (!shared) {
|
|
161
|
+
shared = fetchAndCacheAsset(cache, request);
|
|
162
|
+
inflightAssets.set(request.url, shared);
|
|
163
|
+
const settled = shared;
|
|
164
|
+
const forget = () => {
|
|
165
|
+
if (inflightAssets.get(request.url) === settled) inflightAssets.delete(request.url);
|
|
166
|
+
};
|
|
167
|
+
settled.then(forget, forget);
|
|
168
|
+
}
|
|
125
169
|
try {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
return fresh;
|
|
170
|
+
// Each caller gets its own copy; the shared response body is never read.
|
|
171
|
+
return (await shared).clone();
|
|
129
172
|
} catch (_err) {
|
|
130
|
-
|
|
173
|
+
// A real network error, not a fabricated "offline" 503: the page sees the
|
|
174
|
+
// same failure it would see without a worker, and nothing is cached.
|
|
175
|
+
return Response.error();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function acquireAssetFetchSlot() {
|
|
180
|
+
if (activeAssetFetches < MAX_CONCURRENT_ASSET_FETCHES) {
|
|
181
|
+
activeAssetFetches += 1;
|
|
182
|
+
return Promise.resolve();
|
|
183
|
+
}
|
|
184
|
+
return new Promise((resolve) => assetFetchQueue.push(resolve));
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function releaseAssetFetchSlot() {
|
|
188
|
+
const next = assetFetchQueue.shift();
|
|
189
|
+
if (next) next();
|
|
190
|
+
else activeAssetFetches -= 1;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
async function fetchAndCacheAsset(cache, request) {
|
|
194
|
+
await acquireAssetFetchSlot();
|
|
195
|
+
try {
|
|
196
|
+
let fresh;
|
|
197
|
+
try {
|
|
198
|
+
fresh = await fetch(request);
|
|
199
|
+
} catch (_err) {
|
|
200
|
+
// One retry for a transient failure (connection reset, resource
|
|
201
|
+
// pressure). A second failure is reported to the page as is.
|
|
202
|
+
await new Promise((resolve) => setTimeout(resolve, ASSET_FETCH_RETRY_DELAY_MS));
|
|
203
|
+
fresh = await fetch(request);
|
|
204
|
+
}
|
|
205
|
+
if (fresh.ok) {
|
|
206
|
+
// Wait for the body to land in the cache so the slot covers the download.
|
|
207
|
+
await cache.put(request, fresh.clone()).then(() => {
|
|
208
|
+
putsSinceTrim += 1;
|
|
209
|
+
}, () => undefined);
|
|
210
|
+
}
|
|
211
|
+
return fresh;
|
|
212
|
+
} finally {
|
|
213
|
+
releaseAssetFetchSlot();
|
|
131
214
|
}
|
|
132
215
|
}
|
|
133
216
|
|
|
217
|
+
function trimStaticCacheIfDue() {
|
|
218
|
+
if (staticTrim) return staticTrim;
|
|
219
|
+
if (putsSinceTrim < STATIC_TRIM_EVERY_PUTS) return undefined;
|
|
220
|
+
putsSinceTrim = 0;
|
|
221
|
+
staticTrim = trimStaticCache()
|
|
222
|
+
.catch(() => undefined)
|
|
223
|
+
.then(() => {
|
|
224
|
+
staticTrim = null;
|
|
225
|
+
// Assets cached while this trim ran are counted but not yet trimmed: trim again if due.
|
|
226
|
+
return trimStaticCacheIfDue();
|
|
227
|
+
});
|
|
228
|
+
return staticTrim;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
async function trimStaticCache() {
|
|
232
|
+
const cache = await caches.open(STATIC_CACHE);
|
|
233
|
+
const requests = await cache.keys();
|
|
234
|
+
const excess = requests.length - MAX_STATIC_ENTRIES;
|
|
235
|
+
if (excess <= 0) return;
|
|
236
|
+
// cache.keys() lists entries oldest first. The precached fallbacks stay.
|
|
237
|
+
const evictable = requests.filter(
|
|
238
|
+
(entry) => PRECACHE_ASSETS.indexOf(new URL(entry.url).pathname) === -1
|
|
239
|
+
);
|
|
240
|
+
await Promise.all(evictable.slice(0, excess).map((entry) => cache.delete(entry)));
|
|
241
|
+
}
|
|
242
|
+
|
|
134
243
|
self.addEventListener('message', (event) => {
|
|
135
244
|
if (event.data === 'skipWaiting' || (event.data && event.data.type === 'SKIP_WAITING')) {
|
|
136
245
|
self.skipWaiting();
|