From a02a81f80f030ae3e212db1b85f91c7f61f55df9 Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Wed, 25 Nov 2020 00:03:39 +0100 Subject: [PATCH] web: Fixed extension & local not detecting eachother correctly --- web/packages/core/src/public-api.ts | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/web/packages/core/src/public-api.ts b/web/packages/core/src/public-api.ts index 8c0250bf1..0337d6751 100644 --- a/web/packages/core/src/public-api.ts +++ b/web/packages/core/src/public-api.ts @@ -62,15 +62,19 @@ export class PublicAPI { this.conflict = null; if (prev !== undefined && prev !== null) { - if (prev instanceof PublicAPI) { + if ( + prev instanceof PublicAPI || + ("version" in prev && prev.version == this.version) + ) { /// We're upgrading from a previous API to a new one. - this.sources = prev.sources; - this.config = prev.config; - this.invoked = prev.invoked; - this.conflict = prev.conflict; - this.newestName = prev.newestName; + const previous = prev; + this.sources = previous.sources; + this.config = previous.config; + this.invoked = previous.invoked; + this.conflict = previous.conflict; + this.newestName = previous.newestName; - prev.superseded(); + previous.superseded(); } else if ( prev.constructor === Object && prev.config instanceof Object @@ -276,8 +280,8 @@ export class PublicAPI { sourceAPI: SourceAPI | undefined ): PublicAPI { let publicAPI: PublicAPI; - if (prevRuffle instanceof PublicAPI) { - publicAPI = prevRuffle; + if (prevRuffle?.constructor.name === PublicAPI.name) { + publicAPI = prevRuffle; } else { publicAPI = new PublicAPI(prevRuffle); }