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
13 changes: 13 additions & 0 deletions .changeset/quiet-cooks-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
"@builder.io/sdk": minor
"@builder.io/sdk-angular": minor
"@builder.io/sdk-react-nextjs": minor
"@builder.io/sdk-qwik": minor
"@builder.io/sdk-react": minor
"@builder.io/sdk-react-native": minor
"@builder.io/sdk-solid": minor
"@builder.io/sdk-svelte": minor
"@builder.io/sdk-vue": minor
---

componentInfos usage replaced with registeredComponents
4 changes: 0 additions & 4 deletions packages/sdks/mitosis.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -738,10 +738,6 @@ module.exports = {
code: 'props.context.apiKey',
type: 'property',
},
componentInfos: {
code: 'props.context.componentInfos',
type: 'property',
},
inheritedStyles: {
code: 'props.context.inheritedStyles',
type: 'property',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
useTarget,
} from '@builder.io/mitosis';
import builderContext from '../../../context/builder.context.lite.js';
import type { BuilderContextInterface } from '../../../context/types.js';
import type { BuilderContextInterface, RegisteredComponents } from '../../../context/types.js';
import { evaluate } from '../../../functions/evaluate/index.js';
import { fastClone } from '../../../functions/fast-clone.js';
import { fetchOneEntry } from '../../../functions/get-content/index.js';
Expand Down Expand Up @@ -61,6 +61,7 @@ type BuilderEditorProps = Omit<
| 'blocksWrapperProps'
| 'linkComponent'
> & {
registeredComponents: RegisteredComponents,
builderContextSignal: Signal<BuilderContextInterface>;
setBuilderContextSignal?: (signal: any) => any;
children?: any;
Expand Down Expand Up @@ -365,9 +366,7 @@ export default function EnableEditor(props: BuilderEditorProps) {
modelName: props.model ?? '',
apiKey: props.apiKey,
});
Object.values<ComponentInfo>(
props.builderContextSignal.value.componentInfos
).forEach((registeredComponent) => {
Object.values<ComponentInfo>(props.registeredComponents).forEach((registeredComponent) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Incorrect Object Type Causes Serialization Errors

The createRegisterComponentMessage function now receives RegisteredComponent objects, which contain unserializable component references, instead of the expected ComponentInfo objects. This can lead to serialization errors when posting messages to the parent window.

Fix in Cursor Fix in Web

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it matter? only the component property is unserializable and that's unused anyway. I've tested this against Builder and it picked up all of my components fine after going through postMessage

if (
!registeredComponent.models?.length ||
registeredComponent.models.includes(props.model)
Expand Down
13 changes: 1 addition & 12 deletions packages/sdks/src/components/content/content.lite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import type {
import { evaluate } from '../../functions/evaluate/evaluate.js';
import { serializeIncludingFunctions } from '../../functions/register-component.js';
import { logger } from '../../helpers/logger.js';
import type { ComponentInfo } from '../../types/components.js';
import type { Dictionary } from '../../types/typescript.js';
import Blocks from '../blocks/blocks.lite.jsx';
import { getUpdateVariantVisibilityScript } from '../content-variants/helpers.js';
import DynamicDiv from '../dynamic-div.lite.jsx';
Expand Down Expand Up @@ -103,16 +101,6 @@ export default function ContentComponent(props: ContentProps) {
canTrack: props.canTrack,
apiKey: props.apiKey,
apiVersion: props.apiVersion,
componentInfos: [
...getDefaultRegisteredComponents(),
...(props.customComponents || []),
].reduce<Dictionary<ComponentInfo>>(
(acc, { component: _, ...info }) => ({
...acc,
[info.name]: serializeIncludingFunctions(info),
}),
{}
),
inheritedStyles: {},
BlocksWrapper: useTarget({
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
Expand Down Expand Up @@ -189,6 +177,7 @@ export default function ContentComponent(props: ContentProps) {
enrich={props.enrich}
showContent={props.showContent}
builderContextSignal={builderContextSignal}
registeredComponents={state.registeredComponents}
contentWrapper={props.contentWrapper}
contentWrapperProps={props.contentWrapperProps}
trustedHosts={props.trustedHosts}
Expand Down
1 change: 0 additions & 1 deletion packages/sdks/src/context/builder.context.lite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export default createContext<BuilderContextInterface>(
rootState: {},
apiKey: null,
apiVersion: undefined,
componentInfos: {},
inheritedStyles: {},
BlocksWrapper: 'div',
BlocksWrapperProps: {},
Expand Down
1 change: 0 additions & 1 deletion packages/sdks/src/context/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export interface BuilderContextInterface
localState: BuilderRenderState | undefined;
apiKey: string | null;
apiVersion: ApiVersion | undefined;
componentInfos: Dictionary<ComponentInfo>;
// Used to recursively store all CSS coming from a parent that would apply to a Text block
inheritedStyles: Record<string, unknown>;
nonce: string;
Expand Down
Loading