Skip to content

Commit fab4d33

Browse files
committed
fix: replace duplicate componentInfos with registeredComponents
1 parent 220b988 commit fab4d33

File tree

5 files changed

+4
-22
lines changed

5 files changed

+4
-22
lines changed

packages/sdks/mitosis.config.cjs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -738,10 +738,6 @@ module.exports = {
738738
code: 'props.context.apiKey',
739739
type: 'property',
740740
},
741-
componentInfos: {
742-
code: 'props.context.componentInfos',
743-
type: 'property',
744-
},
745741
inheritedStyles: {
746742
code: 'props.context.inheritedStyles',
747743
type: 'property',

packages/sdks/src/components/content/components/enable-editor.lite.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
useTarget,
1515
} from '@builder.io/mitosis';
1616
import builderContext from '../../../context/builder.context.lite.js';
17-
import type { BuilderContextInterface } from '../../../context/types.js';
17+
import type { BuilderContextInterface, RegisteredComponents } from '../../../context/types.js';
1818
import { evaluate } from '../../../functions/evaluate/index.js';
1919
import { fastClone } from '../../../functions/fast-clone.js';
2020
import { fetchOneEntry } from '../../../functions/get-content/index.js';
@@ -61,6 +61,7 @@ type BuilderEditorProps = Omit<
6161
| 'blocksWrapperProps'
6262
| 'linkComponent'
6363
> & {
64+
registeredComponents: Signal<RegisteredComponents>
6465
builderContextSignal: Signal<BuilderContextInterface>;
6566
setBuilderContextSignal?: (signal: any) => any;
6667
children?: any;
@@ -365,9 +366,7 @@ export default function EnableEditor(props: BuilderEditorProps) {
365366
modelName: props.model ?? '',
366367
apiKey: props.apiKey,
367368
});
368-
Object.values<ComponentInfo>(
369-
props.builderContextSignal.value.componentInfos
370-
).forEach((registeredComponent) => {
369+
Object.values<ComponentInfo>(props.registeredComponents.value).forEach((registeredComponent) => {
371370
if (
372371
!registeredComponent.models?.length ||
373372
registeredComponent.models.includes(props.model)

packages/sdks/src/components/content/content.lite.tsx

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import type {
1818
import { evaluate } from '../../functions/evaluate/evaluate.js';
1919
import { serializeIncludingFunctions } from '../../functions/register-component.js';
2020
import { logger } from '../../helpers/logger.js';
21-
import type { ComponentInfo } from '../../types/components.js';
22-
import type { Dictionary } from '../../types/typescript.js';
2321
import Blocks from '../blocks/blocks.lite.jsx';
2422
import { getUpdateVariantVisibilityScript } from '../content-variants/helpers.js';
2523
import DynamicDiv from '../dynamic-div.lite.jsx';
@@ -103,16 +101,6 @@ export default function ContentComponent(props: ContentProps) {
103101
canTrack: props.canTrack,
104102
apiKey: props.apiKey,
105103
apiVersion: props.apiVersion,
106-
componentInfos: [
107-
...getDefaultRegisteredComponents(),
108-
...(props.customComponents || []),
109-
].reduce<Dictionary<ComponentInfo>>(
110-
(acc, { component: _, ...info }) => ({
111-
...acc,
112-
[info.name]: serializeIncludingFunctions(info),
113-
}),
114-
{}
115-
),
116104
inheritedStyles: {},
117105
BlocksWrapper: useTarget({
118106
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -189,6 +177,7 @@ export default function ContentComponent(props: ContentProps) {
189177
enrich={props.enrich}
190178
showContent={props.showContent}
191179
builderContextSignal={builderContextSignal}
180+
registeredComponents={state.registeredComponents}
192181
contentWrapper={props.contentWrapper}
193182
contentWrapperProps={props.contentWrapperProps}
194183
trustedHosts={props.trustedHosts}

packages/sdks/src/context/builder.context.lite.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export default createContext<BuilderContextInterface>(
1010
rootState: {},
1111
apiKey: null,
1212
apiVersion: undefined,
13-
componentInfos: {},
1413
inheritedStyles: {},
1514
BlocksWrapper: 'div',
1615
BlocksWrapperProps: {},

packages/sdks/src/context/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ export interface BuilderContextInterface
4040
localState: BuilderRenderState | undefined;
4141
apiKey: string | null;
4242
apiVersion: ApiVersion | undefined;
43-
componentInfos: Dictionary<ComponentInfo>;
4443
// Used to recursively store all CSS coming from a parent that would apply to a Text block
4544
inheritedStyles: Record<string, unknown>;
4645
nonce: string;

0 commit comments

Comments
 (0)