diff --git a/platform/wab/src/wab/client/ProjectDependencyManager.ts b/platform/wab/src/wab/client/ProjectDependencyManager.ts index 3081bad96..8922497ab 100644 --- a/platform/wab/src/wab/client/ProjectDependencyManager.ts +++ b/platform/wab/src/wab/client/ProjectDependencyManager.ts @@ -368,18 +368,14 @@ export class ProjectDependencyManager { pkg.id ); - const { projectDependency, depPkgs: depPkgVersions } = - unbundleProjectDependency(this._sc.bundler(), latest, depPkgs); - - spawn( - checkDepPkgHosts(this._sc.appCtx, this._sc.siteInfo, [ - projectDependency, - ...depPkgVersions.filter((dep): dep is ProjectDependency => - isKnownProjectDependency(dep) - ), - ]) + const { projectDependency } = unbundleProjectDependency( + this._sc.bundler(), + latest, + depPkgs ); + checkDepPkgHosts(this._sc.appCtx, this._sc.siteInfo, [latest, ...depPkgs]); + this.canAddDependency(projectDependency, maybeMyPkg); await this.addDependency(projectDependency); diff --git a/platform/wab/src/wab/client/init-ctx.tsx b/platform/wab/src/wab/client/init-ctx.tsx index 1539cb853..3d565b8a6 100644 --- a/platform/wab/src/wab/client/init-ctx.tsx +++ b/platform/wab/src/wab/client/init-ctx.tsx @@ -7,7 +7,7 @@ import { } from "@/wab/client/cli-routes"; import * as DbMod from "@/wab/client/db"; import { ApiBranch, MainBranchId, ProjectId } from "@/wab/shared/ApiSchema"; -import { SiteInfo } from "@/wab/shared/SharedApi"; +import { PkgVersionInfo, SiteInfo } from "@/wab/shared/SharedApi"; import * as slotUtils from "@/wab/shared/SlotUtils"; import { $$$ } from "@/wab/shared/TplQuery"; import { getBundle } from "@/wab/shared/bundles"; @@ -18,7 +18,6 @@ import { unbundleSite } from "@/wab/shared/core/tagged-unbundle"; import * as tpls from "@/wab/shared/core/tpls"; import { getProjectFlags } from "@/wab/shared/devflags"; import { instUtil } from "@/wab/shared/model/InstUtil"; -import { ProjectDependency } from "@/wab/shared/model/classes"; import { APP_ROUTES } from "@/wab/shared/route/app-routes"; import { fillRoute } from "@/wab/shared/route/route"; import { fixPageHrefsToLocal } from "@/wab/shared/utils/split-site-utils"; @@ -85,14 +84,14 @@ export async function loadSiteDbCtx( siteInfo.isMainBranchProtected = isMainBranchProtected; const bundle = getBundle(rev, appCtx.lastBundleVersion); - const { site, depPkgs: depPkgVersions } = unbundleSite( + const { site } = unbundleSite( bundler, siteInfo.id, bundle, depPkgs ); appCtx.appConfig = getProjectFlags(site, appCtx.appConfig); - spawn(checkDepPkgHosts(appCtx, siteInfo, depPkgVersions)); + checkDepPkgHosts(appCtx, siteInfo, depPkgs); // Enable data queries after RSC release if any components already use them. // Occurs after applyPlasmicUserDevFlagOverrides, so skip if already enabled @@ -129,20 +128,15 @@ export async function loadSiteDbCtx( return dbCtx; } -export async function checkDepPkgHosts( +export function checkDepPkgHosts( appCtx: AppCtx, siteInfo: SiteInfo, - deps: ProjectDependency[] + deps: PkgVersionInfo[] ) { - const pkgMetas = await Promise.all( - deps.map((dep) => appCtx.api.getPkgVersionMeta(dep.pkgId, dep.version)) - ); - for (const pkgVersion of pkgMetas) { + for (const dep of deps) { if ( - pkgVersion.pkg.hostUrl && - ![siteInfo.hostUrl, appCtx.appConfig.defaultHostUrl].includes( - pkgVersion.pkg.hostUrl - ) + dep.hostUrl && + ![siteInfo.hostUrl, appCtx.appConfig.defaultHostUrl].includes(dep.hostUrl) ) { notification.warn({ message: "This project imports from a project hosted by another app", @@ -153,12 +147,12 @@ export async function checkDepPkgHosts( - {pkgVersion.pkg.pkg?.name} + {dep.pkg?.name} - , which is hosted by {pkgVersion.pkg.hostUrl}.
+ , which is hosted by {dep.hostUrl}.
Notice this can prevent the canvas from rendering components correctly.

diff --git a/platform/wab/src/wab/client/studio-ctx/StudioCtx.tsx b/platform/wab/src/wab/client/studio-ctx/StudioCtx.tsx index c033d4790..14e20c1e9 100644 --- a/platform/wab/src/wab/client/studio-ctx/StudioCtx.tsx +++ b/platform/wab/src/wab/client/studio-ctx/StudioCtx.tsx @@ -333,7 +333,6 @@ import { VariantGroup, isKnownArenaFrame, isKnownComponentArena, - isKnownProjectDependency, isKnownVariantSetting, } from "@/wab/shared/model/classes"; import { modelSchemaHash } from "@/wab/shared/model/classes-metas"; @@ -5826,7 +5825,7 @@ export class StudioCtx extends WithDbCtx { })(); runInAction(() => { const newBundler = new FastBundler(); - const { site, depPkgs: depPkgVersions } = unbundleSite( + const { site } = unbundleSite( newBundler, this.siteInfo.id, bundle, @@ -5834,15 +5833,7 @@ export class StudioCtx extends WithDbCtx { ); this.appCtx.bundler = newBundler; this.dbCtx().setSite(site, branch, versionOrRevision); - spawn( - checkDepPkgHosts( - this.appCtx, - this.siteInfo, - depPkgVersions.filter((dep): dep is ProjectDependency => - isKnownProjectDependency(dep) - ) - ) - ); + checkDepPkgHosts(this.appCtx, this.siteInfo, depPkgs); this.projectDependencyManager.syncDirectDeps(); this.pruneInvalidViewCtxs(); this.pruneDetachedTpls();