web: Allow taking in "conflict" APIs
This commit is contained in:
parent
af01621484
commit
950d19d1c5
|
@ -38,7 +38,7 @@ export class PublicAPI {
|
||||||
*
|
*
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
protected constructor(prev: PublicAPI | null) {
|
protected constructor(prev: PublicAPI | null | Record<string, unknown>) {
|
||||||
this.sources = {};
|
this.sources = {};
|
||||||
this.config = {};
|
this.config = {};
|
||||||
this.invoked = false;
|
this.invoked = false;
|
||||||
|
@ -46,7 +46,7 @@ export class PublicAPI {
|
||||||
this.conflict = null;
|
this.conflict = null;
|
||||||
|
|
||||||
if (prev !== undefined && prev !== null) {
|
if (prev !== undefined && prev !== null) {
|
||||||
if (prev.constructor.name === PublicAPI.name) {
|
if (prev instanceof PublicAPI) {
|
||||||
/// We're upgrading from a previous API to a new one.
|
/// We're upgrading from a previous API to a new one.
|
||||||
this.sources = prev.sources;
|
this.sources = prev.sources;
|
||||||
this.config = prev.config;
|
this.config = prev.config;
|
||||||
|
@ -57,7 +57,7 @@ export class PublicAPI {
|
||||||
prev.superseded();
|
prev.superseded();
|
||||||
} else if (
|
} else if (
|
||||||
prev.constructor === Object &&
|
prev.constructor === Object &&
|
||||||
prev.config !== undefined
|
prev.config instanceof Object
|
||||||
) {
|
) {
|
||||||
/// We're the first, install user configuration
|
/// We're the first, install user configuration
|
||||||
this.config = prev.config;
|
this.config = prev.config;
|
||||||
|
@ -253,15 +253,12 @@ export class PublicAPI {
|
||||||
* @returns The Ruffle Public API.
|
* @returns The Ruffle Public API.
|
||||||
*/
|
*/
|
||||||
static negotiate(
|
static negotiate(
|
||||||
prev_ruffle: PublicAPI | null,
|
prev_ruffle: PublicAPI | null | Record<string, unknown>,
|
||||||
source_name: string | undefined,
|
source_name: string | undefined,
|
||||||
source_api: SourceAPI | undefined
|
source_api: SourceAPI | undefined
|
||||||
): PublicAPI {
|
): PublicAPI {
|
||||||
let public_api;
|
let public_api: PublicAPI;
|
||||||
if (
|
if (prev_ruffle instanceof PublicAPI) {
|
||||||
prev_ruffle != null &&
|
|
||||||
prev_ruffle.constructor.name == PublicAPI.name
|
|
||||||
) {
|
|
||||||
public_api = prev_ruffle;
|
public_api = prev_ruffle;
|
||||||
} else {
|
} else {
|
||||||
public_api = new PublicAPI(prev_ruffle);
|
public_api = new PublicAPI(prev_ruffle);
|
||||||
|
|
Loading…
Reference in New Issue