Fixing WebAudio for Cordova by introducing localScheme configuration

This commit is contained in:
Krzysztof Głogocki 2022-02-15 12:07:48 +01:00
parent 1a086fc57c
commit 897d2444f5
12 changed files with 70 additions and 11 deletions

View file

@ -4871,7 +4871,8 @@ var File = new Class({
// On iOS, Capacitor often runs on a capacitor:// protocol, meaning local files are served from capacitor:// rather than file://
// See: https://github.com/photonstorm/phaser/issues/5685
var isLocalFile = xhr.responseURL && (xhr.responseURL.indexOf('file://') === 0 || xhr.responseURL.indexOf('capacitor://') === 0);
var localSchemes = [ 'file://', 'capacitor://', this.loader.systems.game.config.loaderLocalScheme ];
var isLocalFile = xhr.responseURL && localSchemes.some(function (scheme) { return xhr.responseURL.indexOf(scheme) === 0; });
var localFileOk = (isLocalFile && event.target.status === 0);
@ -71880,6 +71881,11 @@ var Config = new Class({
*/
this.loaderWithCredentials = GetValue(config, 'loader.withCredentials', false);
/**
* @const {string} Phaser.Core.Config#loaderLocalScheme - Optional local scheme definition.
*/
this.loaderLocalScheme = GetValue(config, 'loader.localScheme', '');
/*
* Allows `plugins` property to either be an array, in which case it just replaces
* the default plugins like previously, or a config object.

File diff suppressed because one or more lines are too long

View file

@ -5415,7 +5415,8 @@ var File = new Class({
// On iOS, Capacitor often runs on a capacitor:// protocol, meaning local files are served from capacitor:// rather than file://
// See: https://github.com/photonstorm/phaser/issues/5685
var isLocalFile = xhr.responseURL && (xhr.responseURL.indexOf('file://') === 0 || xhr.responseURL.indexOf('capacitor://') === 0);
var localSchemes = [ 'file://', 'capacitor://', this.loader.systems.game.config.loaderLocalScheme ];
var isLocalFile = xhr.responseURL && localSchemes.some(function (scheme) { return xhr.responseURL.indexOf(scheme) === 0; });
var localFileOk = (isLocalFile && event.target.status === 0);
@ -79630,6 +79631,11 @@ var Config = new Class({
*/
this.loaderWithCredentials = GetValue(config, 'loader.withCredentials', false);
/**
* @const {string} Phaser.Core.Config#loaderLocalScheme - Optional local scheme definition.
*/
this.loaderLocalScheme = GetValue(config, 'loader.localScheme', '');
/*
* Allows `plugins` property to either be an array, in which case it just replaces
* the default plugins like previously, or a config object.

File diff suppressed because one or more lines are too long

8
dist/phaser-ie9.js vendored
View file

@ -4871,7 +4871,8 @@ var File = new Class({
// On iOS, Capacitor often runs on a capacitor:// protocol, meaning local files are served from capacitor:// rather than file://
// See: https://github.com/photonstorm/phaser/issues/5685
var isLocalFile = xhr.responseURL && (xhr.responseURL.indexOf('file://') === 0 || xhr.responseURL.indexOf('capacitor://') === 0);
var localSchemes = [ 'file://', 'capacitor://', this.loader.systems.game.config.loaderLocalScheme ];
var isLocalFile = xhr.responseURL && localSchemes.some(function (scheme) { return xhr.responseURL.indexOf(scheme) === 0; });
var localFileOk = (isLocalFile && event.target.status === 0);
@ -77068,6 +77069,11 @@ var Config = new Class({
*/
this.loaderWithCredentials = GetValue(config, 'loader.withCredentials', false);
/**
* @const {string} Phaser.Core.Config#loaderLocalScheme - Optional local scheme definition.
*/
this.loaderLocalScheme = GetValue(config, 'loader.localScheme', '');
/*
* Allows `plugins` property to either be an array, in which case it just replaces
* the default plugins like previously, or a config object.

File diff suppressed because one or more lines are too long

8
dist/phaser.js vendored
View file

@ -4871,7 +4871,8 @@ var File = new Class({
// On iOS, Capacitor often runs on a capacitor:// protocol, meaning local files are served from capacitor:// rather than file://
// See: https://github.com/photonstorm/phaser/issues/5685
var isLocalFile = xhr.responseURL && (xhr.responseURL.indexOf('file://') === 0 || xhr.responseURL.indexOf('capacitor://') === 0);
var localSchemes = [ 'file://', 'capacitor://', this.loader.systems.game.config.loaderLocalScheme ];
var isLocalFile = xhr.responseURL && localSchemes.some(function (scheme) { return xhr.responseURL.indexOf(scheme) === 0; });
var localFileOk = (isLocalFile && event.target.status === 0);
@ -77068,6 +77069,11 @@ var Config = new Class({
*/
this.loaderWithCredentials = GetValue(config, 'loader.withCredentials', false);
/**
* @const {string} Phaser.Core.Config#loaderLocalScheme - Optional local scheme definition.
*/
this.loaderLocalScheme = GetValue(config, 'loader.localScheme', '');
/*
* Allows `plugins` property to either be an array, in which case it just replaces
* the default plugins like previously, or a config object.

2
dist/phaser.min.js vendored

File diff suppressed because one or more lines are too long

32
package-lock.json generated
View file

@ -1,6 +1,6 @@
{
"name": "phaser",
"version": "3.53.0",
"version": "3.55.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -692,6 +692,16 @@
"dev": true,
"optional": true
},
"bindings": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
"dev": true,
"optional": true,
"requires": {
"file-uri-to-path": "1.0.0"
}
},
"bluebird": {
"version": "3.7.2",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
@ -2067,6 +2077,13 @@
"flat-cache": "^2.0.1"
}
},
"file-uri-to-path": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==",
"dev": true,
"optional": true
},
"fill-range": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz",
@ -3236,6 +3253,13 @@
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true
},
"nan": {
"version": "2.15.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.15.0.tgz",
"integrity": "sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ==",
"dev": true,
"optional": true
},
"nanomatch": {
"version": "1.2.13",
"resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz",
@ -5027,7 +5051,11 @@
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz",
"integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==",
"dev": true,
"optional": true
"optional": true,
"requires": {
"bindings": "^1.5.0",
"nan": "^2.12.1"
}
},
"glob-parent": {
"version": "3.1.0",

View file

@ -518,6 +518,11 @@ var Config = new Class({
*/
this.loaderWithCredentials = GetValue(config, 'loader.withCredentials', false);
/**
* @const {string} Phaser.Core.Config#loaderLocalScheme - Optional local scheme definition.
*/
this.loaderLocalScheme = GetValue(config, 'loader.localScheme', '');
/*
* Allows `plugins` property to either be an array, in which case it just replaces
* the default plugins like previously, or a config object.

View file

@ -11,4 +11,5 @@
* @property {string} [user] - Optional username for all XHR requests.
* @property {string} [password] - Optional password for all XHR requests.
* @property {number} [timeout=0] - Optional XHR timeout value, in ms.
* @property {string} [localScheme] - Optional local scheme definition.
*/

View file

@ -313,7 +313,8 @@ var File = new Class({
// On iOS, Capacitor often runs on a capacitor:// protocol, meaning local files are served from capacitor:// rather than file://
// See: https://github.com/photonstorm/phaser/issues/5685
var isLocalFile = xhr.responseURL && (xhr.responseURL.indexOf('file://') === 0 || xhr.responseURL.indexOf('capacitor://') === 0);
var localSchemes = [ 'file://', 'capacitor://', this.loader.systems.game.config.loaderLocalScheme ];
var isLocalFile = xhr.responseURL && localSchemes.some(function (scheme) { return xhr.responseURL.indexOf(scheme) === 0; });
var localFileOk = (isLocalFile && event.target.status === 0);