Skip to content

Commit

Permalink
extension: Give precedence to toggles over default options (fixes #5825)
Browse files Browse the repository at this point in the history
Also fixes #5696
  • Loading branch information
danielhjacobs authored and Herschel committed Mar 26, 2023
1 parent 9530da2 commit b7c20a6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
7 changes: 5 additions & 2 deletions web/packages/core/src/public-api.ts
Expand Up @@ -12,7 +12,10 @@ declare global {
* [[PublicAPI]] instance itself.
*/
RufflePlayer?:
| { config?: DataLoadOptions | URLLoadOptions | object }
| {
config?: DataLoadOptions | URLLoadOptions | object;
conflict?: Record<string, unknown> | null;
}
| PublicAPI;
}
}
Expand All @@ -33,11 +36,11 @@ export class PublicAPI {
* The configuration object used when Ruffle is instantiated.
*/
config: DataLoadOptions | URLLoadOptions | object;
conflict: Record<string, unknown> | null;

private sources: Record<string, typeof SourceAPI>;
private invoked: boolean;
private newestName: string | null;
private conflict: Record<string, unknown> | null;

/**
* Construct the Ruffle public API.
Expand Down
7 changes: 7 additions & 0 deletions web/packages/core/src/ruffle-player.ts
Expand Up @@ -666,6 +666,13 @@ export class RufflePlayer extends HTMLElement {
try {
this.loadedConfig = {
...DEFAULT_CONFIG,
...(window.RufflePlayer?.conflict &&
window.RufflePlayer?.conflict["newestName"] === "extension"
? (window.RufflePlayer?.conflict["config"] as Record<
string,
unknown
>)
: {}),
...(window.RufflePlayer?.config ?? {}),
...this.config,
...options,
Expand Down
2 changes: 1 addition & 1 deletion web/packages/extension/src/ruffle.ts
Expand Up @@ -16,8 +16,8 @@ function handleMessage(message: Message) {
case "load": {
const api = window.RufflePlayer ?? {};
api.config = {
...api.config,
...message.config,
...api.config,
};
window.RufflePlayer = PublicAPI.negotiate(api, "extension");
return {};
Expand Down

0 comments on commit b7c20a6

Please sign in to comment.