Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions platform/wab/src/wab/client/ProjectDependencyManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
28 changes: 11 additions & 17 deletions platform/wab/src/wab/client/init-ctx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand All @@ -153,12 +147,12 @@ export async function checkDepPkgHosts(
<a
target="_blank"
href={fillRoute(APP_ROUTES.project, {
projectId: pkgVersion.pkg.pkg?.projectId,
projectId: dep.pkg?.projectId,
})}
>
{pkgVersion.pkg.pkg?.name}
{dep.pkg?.name}
</a>
, which is hosted by {pkgVersion.pkg.hostUrl}. <br />
, which is hosted by {dep.hostUrl}. <br />
Notice this can prevent the canvas from rendering components
correctly.
</p>
Expand Down
13 changes: 2 additions & 11 deletions platform/wab/src/wab/client/studio-ctx/StudioCtx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ import {
VariantGroup,
isKnownArenaFrame,
isKnownComponentArena,
isKnownProjectDependency,
isKnownVariantSetting,
} from "@/wab/shared/model/classes";
import { modelSchemaHash } from "@/wab/shared/model/classes-metas";
Expand Down Expand Up @@ -5826,23 +5825,15 @@ export class StudioCtx extends WithDbCtx {
})();
runInAction(() => {
const newBundler = new FastBundler();
const { site, depPkgs: depPkgVersions } = unbundleSite(
const { site } = unbundleSite(
newBundler,
this.siteInfo.id,
bundle,
depPkgs
);
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();
Expand Down
Loading