Skip to content

Commit

Permalink
fix(dependencies): when removing a slot, clear the removed tpls from …
Browse files Browse the repository at this point in the history
…the list of tpls to be fixed

GitOrigin-RevId: 04ad5b6043bb4915721f65129f6d129af3625a3e
  • Loading branch information
IcaroG authored and actions-user committed Nov 25, 2024
1 parent fba9982 commit a34fb42
Showing 1 changed file with 65 additions and 57 deletions.
122 changes: 65 additions & 57 deletions platform/wab/src/wab/shared/core/project-deps.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
import {
assert,
assignReadonly,
ensure,
maybe,
tuple,
withoutNils,
} from "@/wab/shared/common";
import { removeFromArray } from "@/wab/commons/collections";
import {
derefToken,
Expand All @@ -14,6 +6,30 @@ import {
replaceAllTokenRefs,
TokenType,
} from "@/wab/commons/StyleToken";
import {
getArenaFrames,
isComponentArena,
isPageArena,
} from "@/wab/shared/Arenas";
import { flattenComponent } from "@/wab/shared/cached-selectors";
import {
collectUsedIconAssetsForTpl,
collectUsedPictureAssetsForTpl,
} from "@/wab/shared/codegen/image-assets";
import { collectUsedMixinsForTpl } from "@/wab/shared/codegen/mixins";
import {
collectUsedTokensForTpl,
extractUsedTokensForMixins,
extractUsedTokensForTokens,
} from "@/wab/shared/codegen/style-tokens";
import {
assert,
assignReadonly,
ensure,
maybe,
tuple,
withoutNils,
} from "@/wab/shared/common";
import {
getComponentDisplayName,
isCodeComponent,
Expand All @@ -31,21 +47,33 @@ import {
replaceAllAssetRefs,
} from "@/wab/shared/core/image-assets";
import {
getArenaFrames,
isComponentArena,
isPageArena,
} from "@/wab/shared/Arenas";
import { flattenComponent } from "@/wab/shared/cached-selectors";
allGlobalVariants,
allImageAssets,
allStyleTokens,
getAllAttachedTpls,
getSiteArenas,
isHostLessPackage,
} from "@/wab/shared/core/sites";
import {
collectUsedIconAssetsForTpl,
collectUsedPictureAssetsForTpl,
} from "@/wab/shared/codegen/image-assets";
import { collectUsedMixinsForTpl } from "@/wab/shared/codegen/mixins";
ensureCorrectImplicitStates,
getStateDisplayName,
isPrivateState,
isStateUsedInExpr,
removeComponentState,
} from "@/wab/shared/core/states";
import { cloneMixin } from "@/wab/shared/core/styles";
import {
collectUsedTokensForTpl,
extractUsedTokensForMixins,
extractUsedTokensForTokens,
} from "@/wab/shared/codegen/style-tokens";
clone,
findExprsInComponent,
findExprsInNode,
flattenTpls,
isTplColumns,
isTplComponent,
isTplImage,
isTplNamable,
isTplVariantable,
replaceTplTreeByEmptyBox,
} from "@/wab/shared/core/tpls";
import { ensureComponentsObserved } from "@/wab/shared/mobx-util";
import {
ArenaFrame,
Expand Down Expand Up @@ -108,34 +136,6 @@ import {
isScreenVariantGroup,
VariantGroupType,
} from "@/wab/shared/Variants";
import {
allGlobalVariants,
allImageAssets,
allStyleTokens,
getAllAttachedTpls,
getSiteArenas,
isHostLessPackage,
} from "@/wab/shared/core/sites";
import {
ensureCorrectImplicitStates,
getStateDisplayName,
isPrivateState,
isStateUsedInExpr,
removeComponentState,
} from "@/wab/shared/core/states";
import { cloneMixin } from "@/wab/shared/core/styles";
import {
clone,
findExprsInComponent,
findExprsInNode,
flattenTpls,
isTplColumns,
isTplComponent,
isTplImage,
isTplNamable,
isTplVariantable,
replaceTplTreeByEmptyBox,
} from "@/wab/shared/core/tpls";
import L from "lodash";

export type DependencyWalkScope = "all" | "direct";
Expand Down Expand Up @@ -1200,15 +1200,23 @@ function upgradeProjectDep(
if (!newParam) {
// This param has been deleted, so we delete the
// corresponding arg.
// Search for slots and remove them from the parent component
if (isKnownRenderExpr(arg.expr) && isKnownComponent(owner)) {
if (isKnownRenderExpr(arg.expr)) {
arg.expr.tpl.forEach((tplNode) => {
const slots = flattenTpls(tplNode).filter((t) =>
isKnownTplSlot(t)
);
slots.forEach((tplSlot) => {
removeComponentParam(site, owner, (tplSlot as TplSlot).param);
});
// Mark tpls from the slots as unnatached, as they are going to be removed from the site
attachedTpls.delete(tplNode);
// Search for slots and remove them from the parent component
if (isKnownComponent(owner)) {
const slots = flattenTpls(tplNode).filter((t) =>
isKnownTplSlot(t)
);
slots.forEach((tplSlot) => {
removeComponentParam(
site,
owner,
(tplSlot as TplSlot).param
);
});
}
});
}
removeFromArray(vs.args, arg);
Expand Down

0 comments on commit a34fb42

Please sign in to comment.