feedback5 R5: split the field-view helpers out of the render app

PIXI loading, pick records, tunables, view kind, unit info and the asset / GL
host now live in public/js/render/app/*.js. createFieldView stays in app.js,
unchanged, and every name the file used to export is re-exported. One
pixiPromise. Two source pins follow the lines that moved.
This commit is contained in:
sganggs committed 2026-10-05 17:22:20 +08:00
1 parent c1b8292f92
commit aaef748ad9
9 files changed
+323 -276

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
// public/js/render/app/pixi.js — load PIXI and pixi-spine once (one module-level promise).
const VENDOR = { pixi: '/vendor/pixi.min.js', spine: '/vendor/pixi-spine.js' };
let pixiPromise = null;
function loadScript(src) {
return new Promise((resolve, reject) => {
const s = document.createElement('script');
s.src = src;
s.async = false;
s.onload = () => resolve();
s.onerror = () => reject(new Error(`failed to load ${src}`));
document.head.appendChild(s);
});
}
/** Make sure PIXI and PIXI.spine exist (classic scripts; loaded once). */
export function ensurePixi() {
if (globalThis.PIXI && globalThis.PIXI.spine) return Promise.resolve(globalThis.PIXI);
if (!pixiPromise) {
pixiPromise = (async () => {
if (!globalThis.PIXI) await loadScript(VENDOR.pixi);
if (!globalThis.PIXI?.spine) await loadScript(VENDOR.spine);
if (!globalThis.PIXI || !globalThis.PIXI.spine) throw new Error('PIXI / pixi-spine unavailable');
return globalThis.PIXI;
})();
pixiPromise.catch(() => { pixiPromise = null; });
}
return pixiPromise;
}