feedback3 WD: a fresh model load also forgets PIXI's pending requests keyed by the absolute URL of the same path (GitHub #68)

This commit is contained in:
sganggs committed 2026-10-04 17:43:32 +08:00
1 parent 207a49103f
commit 28a00e0f33
2 files changed
+6 -2

No files matched your search

+3 -2
View File
@@ -573,9 +573,10 @@ export function forgetPendingSpine(entry, keep) {
const done = (u) => { try { return !!PIXI.Assets.cache?.has?.(u); } catch { return true; } };
if (done(skel)) return 0;
const atlas = (typeof entry.atlas === 'string' && entry.atlas) || skel.replace(/\.skel$/, '.atlas');
const urls = done(atlas) ? [skel] : [skel, atlas, ...spinePages(entry)];
const urls = (done(atlas) ? [skel] : [skel, atlas, ...spinePages(entry)]).filter((u) => !(keep && keep.has(u)));
let n = 0;
for (const u of urls) if (!(keep && keep.has(u)) && Object.hasOwn(cache, u)) { delete cache[u]; n++; }
// the loader keys its cache by the resolved URL: the manifest path itself, or that path made absolute
for (const key of Object.keys(cache)) if (urls.some((u) => key === u || (u.startsWith('/') && key.endsWith(u)))) { delete cache[key]; n++; }
return n;
}
+3
View File
@@ -77,6 +77,9 @@ test('forgetPendingSpine: PIXI\'s pending requests of an unfinished skeleton go,
c = setup([]);
forgetPendingSpine(e, new Set([page]));
assert.ok(c[page], 'a page another cached skeleton uses stays');
c = setup([]);
c[`http://127.0.0.1:8080${e.atlas}`] = {};
assert.equal(forgetPendingSpine(e), 4, 'an absolute key of the same path too');
globalThis.PIXI = {};
assert.equal(forgetPendingSpine(e), 0, 'no loader cache: nothing');
} finally { globalThis.PIXI = prev; }