mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-25 16:26:25 +00:00
Add cache busting
This commit is contained in:
parent
814eb3053e
commit
eb6ee79b3e
6
package-lock.json
generated
6
package-lock.json
generated
@ -2381,9 +2381,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/follow-redirects": {
|
"node_modules/follow-redirects": {
|
||||||
"version": "1.15.5",
|
"version": "1.15.6",
|
||||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz",
|
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
|
||||||
"integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==",
|
"integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
|
@ -56,6 +56,7 @@ import PokemonInfoContainer from './ui/pokemon-info-container';
|
|||||||
import { biomeDepths } from './data/biomes';
|
import { biomeDepths } from './data/biomes';
|
||||||
import { initTouchControls } from './touch-controls';
|
import { initTouchControls } from './touch-controls';
|
||||||
import { UiTheme } from './enums/ui-theme';
|
import { UiTheme } from './enums/ui-theme';
|
||||||
|
import CacheBustedLoaderPlugin from './plugins/cache-busted-loader-plugin';
|
||||||
|
|
||||||
export const bypassLogin = false;
|
export const bypassLogin = false;
|
||||||
|
|
||||||
@ -188,6 +189,8 @@ export default class BattleScene extends Phaser.Scene {
|
|||||||
this.phaseQueuePrepend = [];
|
this.phaseQueuePrepend = [];
|
||||||
this.phaseQueuePrependSpliceIndex = -1;
|
this.phaseQueuePrependSpliceIndex = -1;
|
||||||
this.nextCommandPhaseQueue = [];
|
this.nextCommandPhaseQueue = [];
|
||||||
|
|
||||||
|
Phaser.Plugins.PluginCache.register('Loader', CacheBustedLoaderPlugin, 'load');
|
||||||
}
|
}
|
||||||
|
|
||||||
loadImage(key: string, folder: string, filename?: string) {
|
loadImage(key: string, folder: string, filename?: string) {
|
||||||
@ -266,6 +269,13 @@ export default class BattleScene extends Phaser.Scene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
preload() {
|
preload() {
|
||||||
|
const indexFile = Array.from(document.querySelectorAll('script')).map(s => s.src).find(s => /\/index/.test(s));
|
||||||
|
if (indexFile) {
|
||||||
|
const buildIdMatch = /index\-(.*?)\.js$/.exec(indexFile);
|
||||||
|
if (buildIdMatch)
|
||||||
|
this.load['cacheBuster'] = buildIdMatch[1];
|
||||||
|
}
|
||||||
|
|
||||||
// Load menu images
|
// Load menu images
|
||||||
this.loadAtlas('bg', 'ui');
|
this.loadAtlas('bg', 'ui');
|
||||||
this.loadImage('command_fight_labels', 'ui');
|
this.loadImage('command_fight_labels', 'ui');
|
||||||
|
25
src/plugins/cache-busted-loader-plugin.ts
Normal file
25
src/plugins/cache-busted-loader-plugin.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
let cacheBuster = '';
|
||||||
|
|
||||||
|
export default class CacheBustedLoaderPlugin extends Phaser.Loader.LoaderPlugin {
|
||||||
|
constructor(scene: Phaser.Scene) {
|
||||||
|
super(scene)
|
||||||
|
}
|
||||||
|
|
||||||
|
get cacheBuster() {
|
||||||
|
return cacheBuster
|
||||||
|
}
|
||||||
|
|
||||||
|
set cacheBuster(version) {
|
||||||
|
cacheBuster = version
|
||||||
|
}
|
||||||
|
|
||||||
|
addFile(file): void {
|
||||||
|
if (!Array.isArray(file))
|
||||||
|
file = [ file ]
|
||||||
|
|
||||||
|
if (cacheBuster)
|
||||||
|
file.forEach(item => item.url += '?v=' + cacheBuster);
|
||||||
|
|
||||||
|
super.addFile(file);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user