extension: Give precedence to toggles over default options (fixes #5825)
Also fixes #5696
This commit is contained in:
parent
9530da22e2
commit
b7c20a6c60
|
@ -12,7 +12,10 @@ declare global {
|
||||||
* [[PublicAPI]] instance itself.
|
* [[PublicAPI]] instance itself.
|
||||||
*/
|
*/
|
||||||
RufflePlayer?:
|
RufflePlayer?:
|
||||||
| { config?: DataLoadOptions | URLLoadOptions | object }
|
| {
|
||||||
|
config?: DataLoadOptions | URLLoadOptions | object;
|
||||||
|
conflict?: Record<string, unknown> | null;
|
||||||
|
}
|
||||||
| PublicAPI;
|
| PublicAPI;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,11 +36,11 @@ export class PublicAPI {
|
||||||
* The configuration object used when Ruffle is instantiated.
|
* The configuration object used when Ruffle is instantiated.
|
||||||
*/
|
*/
|
||||||
config: DataLoadOptions | URLLoadOptions | object;
|
config: DataLoadOptions | URLLoadOptions | object;
|
||||||
|
conflict: Record<string, unknown> | null;
|
||||||
|
|
||||||
private sources: Record<string, typeof SourceAPI>;
|
private sources: Record<string, typeof SourceAPI>;
|
||||||
private invoked: boolean;
|
private invoked: boolean;
|
||||||
private newestName: string | null;
|
private newestName: string | null;
|
||||||
private conflict: Record<string, unknown> | null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the Ruffle public API.
|
* Construct the Ruffle public API.
|
||||||
|
|
|
@ -666,6 +666,13 @@ export class RufflePlayer extends HTMLElement {
|
||||||
try {
|
try {
|
||||||
this.loadedConfig = {
|
this.loadedConfig = {
|
||||||
...DEFAULT_CONFIG,
|
...DEFAULT_CONFIG,
|
||||||
|
...(window.RufflePlayer?.conflict &&
|
||||||
|
window.RufflePlayer?.conflict["newestName"] === "extension"
|
||||||
|
? (window.RufflePlayer?.conflict["config"] as Record<
|
||||||
|
string,
|
||||||
|
unknown
|
||||||
|
>)
|
||||||
|
: {}),
|
||||||
...(window.RufflePlayer?.config ?? {}),
|
...(window.RufflePlayer?.config ?? {}),
|
||||||
...this.config,
|
...this.config,
|
||||||
...options,
|
...options,
|
||||||
|
|
|
@ -16,8 +16,8 @@ function handleMessage(message: Message) {
|
||||||
case "load": {
|
case "load": {
|
||||||
const api = window.RufflePlayer ?? {};
|
const api = window.RufflePlayer ?? {};
|
||||||
api.config = {
|
api.config = {
|
||||||
...api.config,
|
|
||||||
...message.config,
|
...message.config,
|
||||||
|
...api.config,
|
||||||
};
|
};
|
||||||
window.RufflePlayer = PublicAPI.negotiate(api, "extension");
|
window.RufflePlayer = PublicAPI.negotiate(api, "extension");
|
||||||
return {};
|
return {};
|
||||||
|
|
Loading…
Reference in New Issue