1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00

Add option to ensure cross-origin isolation headers on web export

This commit is contained in:
Adam Scott
2023-12-12 15:39:25 -05:00
parent 4e990cd7e5
commit 62cec03a06
7 changed files with 180 additions and 63 deletions

View File

@@ -179,9 +179,7 @@ const Engine = (function () {
preloader.preloadedFiles.length = 0; // Clear memory
me.rtenv['callMain'](me.config.args);
initPromise = null;
if (me.config.serviceWorker && 'serviceWorker' in navigator) {
navigator.serviceWorker.register(me.config.serviceWorker);
}
me.installServiceWorker();
resolve();
});
});
@@ -242,6 +240,17 @@ const Engine = (function () {
this.rtenv['request_quit']();
}
},
/**
* Install the progressive-web app service worker.
* @returns {Promise} The service worker registration promise.
*/
installServiceWorker: function () {
if (this.config.serviceWorker && 'serviceWorker' in navigator) {
return navigator.serviceWorker.register(this.config.serviceWorker);
}
return Promise.resolve();
},
};
Engine.prototype = proto;
@@ -252,6 +261,7 @@ const Engine = (function () {
Engine.prototype['startGame'] = Engine.prototype.startGame;
Engine.prototype['copyToFS'] = Engine.prototype.copyToFS;
Engine.prototype['requestQuit'] = Engine.prototype.requestQuit;
Engine.prototype['installServiceWorker'] = Engine.prototype.installServiceWorker;
// Also expose static methods as instance methods
Engine.prototype['load'] = Engine.load;
Engine.prototype['unload'] = Engine.unload;