2024-05-27 04:50:59 -05:00
|
|
|
import { translateChildren, translateMaskChildren } from '@plugin/translators';
|
2024-04-15 07:06:38 -05:00
|
|
|
|
2024-04-15 07:09:48 -05:00
|
|
|
import { Children } from '@ui/lib/types/utils/children';
|
2024-04-15 07:06:38 -05:00
|
|
|
|
2024-05-27 04:50:59 -05:00
|
|
|
const nodeActsAsMask = (node: SceneNode): boolean => {
|
|
|
|
return 'isMask' in node && node.isMask;
|
|
|
|
};
|
|
|
|
|
2024-06-19 01:10:20 -05:00
|
|
|
export const transformChildren = async (node: ChildrenMixin): Promise<Children> => {
|
2024-05-27 04:50:59 -05:00
|
|
|
const maskIndex = node.children.findIndex(nodeActsAsMask);
|
|
|
|
const containsMask = maskIndex !== -1;
|
|
|
|
|
2024-04-15 07:06:38 -05:00
|
|
|
return {
|
2024-05-27 04:50:59 -05:00
|
|
|
children: containsMask
|
2024-06-19 01:10:20 -05:00
|
|
|
? await translateMaskChildren(node.children, maskIndex)
|
|
|
|
: await translateChildren(node.children)
|
2024-04-15 07:06:38 -05:00
|
|
|
};
|
|
|
|
};
|