@builder.io/sdk-svelte 2.0.5 → 2.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/components/block/block.svelte +2 -1
- package/lib/browser/components/content/content.svelte +3 -3
- package/lib/browser/components/content-variants/content-variants.svelte +1 -0
- package/lib/browser/components/content-variants/content-variants.types.d.ts +2 -1
- package/lib/browser/components/content-variants/extra-framework-props-types.d.ts +2 -0
- package/lib/browser/components/content-variants/extra-framework-props-types.js +1 -0
- package/lib/browser/constants/sdk-version.d.ts +1 -1
- package/lib/browser/constants/sdk-version.js +1 -1
- package/lib/browser/context/extra-context-types.d.ts +6 -0
- package/lib/browser/context/extra-context-types.js +1 -0
- package/lib/browser/context/types.d.ts +2 -1
- package/lib/browser/functions/register-component.d.ts +1 -1
- package/lib/browser/functions/register-component.js +2 -2
- package/lib/browser/functions/register.js +4 -0
- package/lib/edge/components/block/block.svelte +2 -1
- package/lib/edge/components/content/content.svelte +3 -3
- package/lib/edge/components/content-variants/content-variants.svelte +1 -0
- package/lib/edge/components/content-variants/content-variants.types.d.ts +2 -1
- package/lib/edge/components/content-variants/extra-framework-props-types.d.ts +2 -0
- package/lib/edge/components/content-variants/extra-framework-props-types.js +1 -0
- package/lib/edge/constants/sdk-version.d.ts +1 -1
- package/lib/edge/constants/sdk-version.js +1 -1
- package/lib/edge/context/extra-context-types.d.ts +6 -0
- package/lib/edge/context/extra-context-types.js +1 -0
- package/lib/edge/context/types.d.ts +2 -1
- package/lib/edge/functions/register-component.d.ts +1 -1
- package/lib/edge/functions/register-component.js +2 -2
- package/lib/edge/functions/register.js +4 -0
- package/lib/node/components/block/block.svelte +2 -1
- package/lib/node/components/content/content.svelte +3 -3
- package/lib/node/components/content-variants/content-variants.svelte +1 -0
- package/lib/node/components/content-variants/content-variants.types.d.ts +2 -1
- package/lib/node/components/content-variants/extra-framework-props-types.d.ts +2 -0
- package/lib/node/components/content-variants/extra-framework-props-types.js +1 -0
- package/lib/node/constants/sdk-version.d.ts +1 -1
- package/lib/node/constants/sdk-version.js +1 -1
- package/lib/node/context/extra-context-types.d.ts +6 -0
- package/lib/node/context/extra-context-types.js +1 -0
- package/lib/node/context/types.d.ts +2 -1
- package/lib/node/functions/register-component.d.ts +1 -1
- package/lib/node/functions/register-component.js +2 -2
- package/lib/node/functions/register.js +4 -0
- package/package.json +1 -1
- package/src/components/block/block.svelte +2 -1
- package/src/components/content/content.svelte +3 -3
- package/src/components/content-variants/content-variants.svelte +1 -0
- package/src/components/content-variants/content-variants.types.ts +2 -1
- package/src/components/content-variants/extra-framework-props-types.ts +1 -0
- package/src/constants/sdk-version.ts +1 -1
- package/src/context/extra-context-types.ts +5 -0
- package/src/context/types.ts +2 -1
- package/src/functions/register-component.ts +2 -2
- package/src/functions/register.ts +4 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script context="module"></script>
|
|
2
2
|
|
|
3
3
|
<script>import { onMount } from "svelte";
|
|
4
|
+
import { TARGET } from "../../constants/target";
|
|
4
5
|
import { getBlockComponentOptions } from "../../functions/get-block-component-options";
|
|
5
6
|
import { getProcessedBlock } from "../../functions/get-processed-block";
|
|
6
7
|
import "../dynamic-div.svelte";
|
|
@@ -86,7 +87,7 @@ $: componentRefProps = () => {
|
|
|
86
87
|
registeredComponents: registeredComponents,
|
|
87
88
|
builderBlock: processedBlock(),
|
|
88
89
|
includeBlockProps: blockComponent?.()?.noWrap === true,
|
|
89
|
-
isInteractive: !blockComponent?.()?.isRSC,
|
|
90
|
+
isInteractive: !(blockComponent?.()?.isRSC && TARGET === "rsc"),
|
|
90
91
|
};
|
|
91
92
|
};
|
|
92
93
|
onMount(() => {
|
|
@@ -3,7 +3,7 @@ import { writable } from "svelte/store";
|
|
|
3
3
|
import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components";
|
|
4
4
|
import { TARGET } from "../../constants/target";
|
|
5
5
|
import ComponentsContext from "../../context/components.context";
|
|
6
|
-
import {
|
|
6
|
+
import { serializeIncludingFunctions } from "../../functions/register-component";
|
|
7
7
|
import Blocks from "../blocks/blocks.svelte";
|
|
8
8
|
import { getUpdateVariantVisibilityScript } from "../content-variants/helpers";
|
|
9
9
|
import "../dynamic-div.svelte";
|
|
@@ -54,7 +54,7 @@ let registeredComponents = [
|
|
|
54
54
|
...acc,
|
|
55
55
|
[info.name]: {
|
|
56
56
|
component: component,
|
|
57
|
-
...
|
|
57
|
+
...serializeIncludingFunctions(info),
|
|
58
58
|
},
|
|
59
59
|
}), {});
|
|
60
60
|
let builderContextSignal = writable({
|
|
@@ -84,7 +84,7 @@ let builderContextSignal = writable({
|
|
|
84
84
|
}) || []),
|
|
85
85
|
].reduce((acc, { component: _, ...info }) => ({
|
|
86
86
|
...acc,
|
|
87
|
-
[info.name]:
|
|
87
|
+
[info.name]: serializeIncludingFunctions(info),
|
|
88
88
|
}), {}),
|
|
89
89
|
inheritedStyles: {},
|
|
90
90
|
BlocksWrapper: blocksWrapper || "div",
|
|
@@ -2,7 +2,8 @@ import type { BuilderRenderContext, RegisteredComponent } from '../../context/ty
|
|
|
2
2
|
import type { ApiVersion } from '../../types/api-version';
|
|
3
3
|
import type { BuilderContent } from '../../types/builder-content';
|
|
4
4
|
import type { Nullable } from '../../types/typescript';
|
|
5
|
-
|
|
5
|
+
import type { ExtraFrameworkProps } from './extra-framework-props-types';
|
|
6
|
+
export interface ContentVariantsPrps extends ExtraFrameworkProps {
|
|
6
7
|
/**
|
|
7
8
|
* The Builder content JSON to render (required).
|
|
8
9
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "2.0.
|
|
1
|
+
export declare const SDK_VERSION = "2.0.9";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "2.0.
|
|
1
|
+
export const SDK_VERSION = "2.0.9";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,13 +3,14 @@ import type { ApiVersion } from '../types/api-version';
|
|
|
3
3
|
import type { BuilderContent } from '../types/builder-content';
|
|
4
4
|
import type { ComponentInfo } from '../types/components';
|
|
5
5
|
import type { Dictionary, Nullable } from '../types/typescript';
|
|
6
|
+
import type { ExtraContextTypes } from './extra-context-types';
|
|
6
7
|
export type RegisteredComponent = ComponentInfo & {
|
|
7
8
|
component: any;
|
|
8
9
|
};
|
|
9
10
|
export type RegisteredComponents = Dictionary<RegisteredComponent>;
|
|
10
11
|
export type BuilderRenderState = Record<string, unknown>;
|
|
11
12
|
export type BuilderRenderContext = Record<string, unknown>;
|
|
12
|
-
export interface BuilderContextInterface extends Pick<BlocksWrapperProps, 'BlocksWrapper' | 'BlocksWrapperProps'
|
|
13
|
+
export interface BuilderContextInterface extends Pick<BlocksWrapperProps, 'BlocksWrapper' | 'BlocksWrapperProps'>, ExtraContextTypes {
|
|
13
14
|
content: Nullable<BuilderContent>;
|
|
14
15
|
context: BuilderRenderContext;
|
|
15
16
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const createRegisterComponentMessage = (info) => ({
|
|
2
2
|
type: 'builder.registerComponent',
|
|
3
|
-
data:
|
|
3
|
+
data: serializeIncludingFunctions(info)
|
|
4
4
|
});
|
|
5
5
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
6
6
|
const serializeFn = (fnValue) => {
|
|
@@ -12,7 +12,7 @@ const serializeFn = (fnValue) => {
|
|
|
12
12
|
const appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(');
|
|
13
13
|
return `return (${appendFunction ? 'function ' : ''}${fnStr}).apply(this, arguments)`;
|
|
14
14
|
};
|
|
15
|
-
export function
|
|
15
|
+
export function serializeIncludingFunctions(info) {
|
|
16
16
|
return JSON.parse(JSON.stringify(info, (key, value) => {
|
|
17
17
|
if (typeof value === 'function') {
|
|
18
18
|
return serializeFn(value);
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { isBrowser } from './is-browser';
|
|
2
|
+
import { serializeIncludingFunctions } from './register-component';
|
|
2
3
|
const registry = {};
|
|
3
4
|
export function register(type, info) {
|
|
5
|
+
if (type === 'plugin') {
|
|
6
|
+
info = serializeIncludingFunctions(info);
|
|
7
|
+
}
|
|
4
8
|
let typeList = registry[type];
|
|
5
9
|
if (!typeList) {
|
|
6
10
|
typeList = registry[type] = [];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script context="module"></script>
|
|
2
2
|
|
|
3
3
|
<script>import { onMount } from "svelte";
|
|
4
|
+
import { TARGET } from "../../constants/target";
|
|
4
5
|
import { getBlockComponentOptions } from "../../functions/get-block-component-options";
|
|
5
6
|
import { getProcessedBlock } from "../../functions/get-processed-block";
|
|
6
7
|
import "../dynamic-div.svelte";
|
|
@@ -86,7 +87,7 @@ $: componentRefProps = () => {
|
|
|
86
87
|
registeredComponents: registeredComponents,
|
|
87
88
|
builderBlock: processedBlock(),
|
|
88
89
|
includeBlockProps: blockComponent?.()?.noWrap === true,
|
|
89
|
-
isInteractive: !blockComponent?.()?.isRSC,
|
|
90
|
+
isInteractive: !(blockComponent?.()?.isRSC && TARGET === "rsc"),
|
|
90
91
|
};
|
|
91
92
|
};
|
|
92
93
|
onMount(() => {
|
|
@@ -3,7 +3,7 @@ import { writable } from "svelte/store";
|
|
|
3
3
|
import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components";
|
|
4
4
|
import { TARGET } from "../../constants/target";
|
|
5
5
|
import ComponentsContext from "../../context/components.context";
|
|
6
|
-
import {
|
|
6
|
+
import { serializeIncludingFunctions } from "../../functions/register-component";
|
|
7
7
|
import Blocks from "../blocks/blocks.svelte";
|
|
8
8
|
import { getUpdateVariantVisibilityScript } from "../content-variants/helpers";
|
|
9
9
|
import "../dynamic-div.svelte";
|
|
@@ -54,7 +54,7 @@ let registeredComponents = [
|
|
|
54
54
|
...acc,
|
|
55
55
|
[info.name]: {
|
|
56
56
|
component: component,
|
|
57
|
-
...
|
|
57
|
+
...serializeIncludingFunctions(info),
|
|
58
58
|
},
|
|
59
59
|
}), {});
|
|
60
60
|
let builderContextSignal = writable({
|
|
@@ -84,7 +84,7 @@ let builderContextSignal = writable({
|
|
|
84
84
|
}) || []),
|
|
85
85
|
].reduce((acc, { component: _, ...info }) => ({
|
|
86
86
|
...acc,
|
|
87
|
-
[info.name]:
|
|
87
|
+
[info.name]: serializeIncludingFunctions(info),
|
|
88
88
|
}), {}),
|
|
89
89
|
inheritedStyles: {},
|
|
90
90
|
BlocksWrapper: blocksWrapper || "div",
|
|
@@ -2,7 +2,8 @@ import type { BuilderRenderContext, RegisteredComponent } from '../../context/ty
|
|
|
2
2
|
import type { ApiVersion } from '../../types/api-version';
|
|
3
3
|
import type { BuilderContent } from '../../types/builder-content';
|
|
4
4
|
import type { Nullable } from '../../types/typescript';
|
|
5
|
-
|
|
5
|
+
import type { ExtraFrameworkProps } from './extra-framework-props-types';
|
|
6
|
+
export interface ContentVariantsPrps extends ExtraFrameworkProps {
|
|
6
7
|
/**
|
|
7
8
|
* The Builder content JSON to render (required).
|
|
8
9
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "2.0.
|
|
1
|
+
export declare const SDK_VERSION = "2.0.9";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "2.0.
|
|
1
|
+
export const SDK_VERSION = "2.0.9";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,13 +3,14 @@ import type { ApiVersion } from '../types/api-version';
|
|
|
3
3
|
import type { BuilderContent } from '../types/builder-content';
|
|
4
4
|
import type { ComponentInfo } from '../types/components';
|
|
5
5
|
import type { Dictionary, Nullable } from '../types/typescript';
|
|
6
|
+
import type { ExtraContextTypes } from './extra-context-types';
|
|
6
7
|
export type RegisteredComponent = ComponentInfo & {
|
|
7
8
|
component: any;
|
|
8
9
|
};
|
|
9
10
|
export type RegisteredComponents = Dictionary<RegisteredComponent>;
|
|
10
11
|
export type BuilderRenderState = Record<string, unknown>;
|
|
11
12
|
export type BuilderRenderContext = Record<string, unknown>;
|
|
12
|
-
export interface BuilderContextInterface extends Pick<BlocksWrapperProps, 'BlocksWrapper' | 'BlocksWrapperProps'
|
|
13
|
+
export interface BuilderContextInterface extends Pick<BlocksWrapperProps, 'BlocksWrapper' | 'BlocksWrapperProps'>, ExtraContextTypes {
|
|
13
14
|
content: Nullable<BuilderContent>;
|
|
14
15
|
context: BuilderRenderContext;
|
|
15
16
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const createRegisterComponentMessage = (info) => ({
|
|
2
2
|
type: 'builder.registerComponent',
|
|
3
|
-
data:
|
|
3
|
+
data: serializeIncludingFunctions(info)
|
|
4
4
|
});
|
|
5
5
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
6
6
|
const serializeFn = (fnValue) => {
|
|
@@ -12,7 +12,7 @@ const serializeFn = (fnValue) => {
|
|
|
12
12
|
const appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(');
|
|
13
13
|
return `return (${appendFunction ? 'function ' : ''}${fnStr}).apply(this, arguments)`;
|
|
14
14
|
};
|
|
15
|
-
export function
|
|
15
|
+
export function serializeIncludingFunctions(info) {
|
|
16
16
|
return JSON.parse(JSON.stringify(info, (key, value) => {
|
|
17
17
|
if (typeof value === 'function') {
|
|
18
18
|
return serializeFn(value);
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { isBrowser } from './is-browser';
|
|
2
|
+
import { serializeIncludingFunctions } from './register-component';
|
|
2
3
|
const registry = {};
|
|
3
4
|
export function register(type, info) {
|
|
5
|
+
if (type === 'plugin') {
|
|
6
|
+
info = serializeIncludingFunctions(info);
|
|
7
|
+
}
|
|
4
8
|
let typeList = registry[type];
|
|
5
9
|
if (!typeList) {
|
|
6
10
|
typeList = registry[type] = [];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script context="module"></script>
|
|
2
2
|
|
|
3
3
|
<script>import { onMount } from "svelte";
|
|
4
|
+
import { TARGET } from "../../constants/target";
|
|
4
5
|
import { getBlockComponentOptions } from "../../functions/get-block-component-options";
|
|
5
6
|
import { getProcessedBlock } from "../../functions/get-processed-block";
|
|
6
7
|
import "../dynamic-div.svelte";
|
|
@@ -86,7 +87,7 @@ $: componentRefProps = () => {
|
|
|
86
87
|
registeredComponents: registeredComponents,
|
|
87
88
|
builderBlock: processedBlock(),
|
|
88
89
|
includeBlockProps: blockComponent?.()?.noWrap === true,
|
|
89
|
-
isInteractive: !blockComponent?.()?.isRSC,
|
|
90
|
+
isInteractive: !(blockComponent?.()?.isRSC && TARGET === "rsc"),
|
|
90
91
|
};
|
|
91
92
|
};
|
|
92
93
|
onMount(() => {
|
|
@@ -3,7 +3,7 @@ import { writable } from "svelte/store";
|
|
|
3
3
|
import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components";
|
|
4
4
|
import { TARGET } from "../../constants/target";
|
|
5
5
|
import ComponentsContext from "../../context/components.context";
|
|
6
|
-
import {
|
|
6
|
+
import { serializeIncludingFunctions } from "../../functions/register-component";
|
|
7
7
|
import Blocks from "../blocks/blocks.svelte";
|
|
8
8
|
import { getUpdateVariantVisibilityScript } from "../content-variants/helpers";
|
|
9
9
|
import "../dynamic-div.svelte";
|
|
@@ -54,7 +54,7 @@ let registeredComponents = [
|
|
|
54
54
|
...acc,
|
|
55
55
|
[info.name]: {
|
|
56
56
|
component: component,
|
|
57
|
-
...
|
|
57
|
+
...serializeIncludingFunctions(info),
|
|
58
58
|
},
|
|
59
59
|
}), {});
|
|
60
60
|
let builderContextSignal = writable({
|
|
@@ -84,7 +84,7 @@ let builderContextSignal = writable({
|
|
|
84
84
|
}) || []),
|
|
85
85
|
].reduce((acc, { component: _, ...info }) => ({
|
|
86
86
|
...acc,
|
|
87
|
-
[info.name]:
|
|
87
|
+
[info.name]: serializeIncludingFunctions(info),
|
|
88
88
|
}), {}),
|
|
89
89
|
inheritedStyles: {},
|
|
90
90
|
BlocksWrapper: blocksWrapper || "div",
|
|
@@ -2,7 +2,8 @@ import type { BuilderRenderContext, RegisteredComponent } from '../../context/ty
|
|
|
2
2
|
import type { ApiVersion } from '../../types/api-version';
|
|
3
3
|
import type { BuilderContent } from '../../types/builder-content';
|
|
4
4
|
import type { Nullable } from '../../types/typescript';
|
|
5
|
-
|
|
5
|
+
import type { ExtraFrameworkProps } from './extra-framework-props-types';
|
|
6
|
+
export interface ContentVariantsPrps extends ExtraFrameworkProps {
|
|
6
7
|
/**
|
|
7
8
|
* The Builder content JSON to render (required).
|
|
8
9
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "2.0.
|
|
1
|
+
export declare const SDK_VERSION = "2.0.9";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "2.0.
|
|
1
|
+
export const SDK_VERSION = "2.0.9";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,13 +3,14 @@ import type { ApiVersion } from '../types/api-version';
|
|
|
3
3
|
import type { BuilderContent } from '../types/builder-content';
|
|
4
4
|
import type { ComponentInfo } from '../types/components';
|
|
5
5
|
import type { Dictionary, Nullable } from '../types/typescript';
|
|
6
|
+
import type { ExtraContextTypes } from './extra-context-types';
|
|
6
7
|
export type RegisteredComponent = ComponentInfo & {
|
|
7
8
|
component: any;
|
|
8
9
|
};
|
|
9
10
|
export type RegisteredComponents = Dictionary<RegisteredComponent>;
|
|
10
11
|
export type BuilderRenderState = Record<string, unknown>;
|
|
11
12
|
export type BuilderRenderContext = Record<string, unknown>;
|
|
12
|
-
export interface BuilderContextInterface extends Pick<BlocksWrapperProps, 'BlocksWrapper' | 'BlocksWrapperProps'
|
|
13
|
+
export interface BuilderContextInterface extends Pick<BlocksWrapperProps, 'BlocksWrapper' | 'BlocksWrapperProps'>, ExtraContextTypes {
|
|
13
14
|
content: Nullable<BuilderContent>;
|
|
14
15
|
context: BuilderRenderContext;
|
|
15
16
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const createRegisterComponentMessage = (info) => ({
|
|
2
2
|
type: 'builder.registerComponent',
|
|
3
|
-
data:
|
|
3
|
+
data: serializeIncludingFunctions(info)
|
|
4
4
|
});
|
|
5
5
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
6
6
|
const serializeFn = (fnValue) => {
|
|
@@ -12,7 +12,7 @@ const serializeFn = (fnValue) => {
|
|
|
12
12
|
const appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(');
|
|
13
13
|
return `return (${appendFunction ? 'function ' : ''}${fnStr}).apply(this, arguments)`;
|
|
14
14
|
};
|
|
15
|
-
export function
|
|
15
|
+
export function serializeIncludingFunctions(info) {
|
|
16
16
|
return JSON.parse(JSON.stringify(info, (key, value) => {
|
|
17
17
|
if (typeof value === 'function') {
|
|
18
18
|
return serializeFn(value);
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { isBrowser } from './is-browser';
|
|
2
|
+
import { serializeIncludingFunctions } from './register-component';
|
|
2
3
|
const registry = {};
|
|
3
4
|
export function register(type, info) {
|
|
5
|
+
if (type === 'plugin') {
|
|
6
|
+
info = serializeIncludingFunctions(info);
|
|
7
|
+
}
|
|
4
8
|
let typeList = registry[type];
|
|
5
9
|
if (!typeList) {
|
|
6
10
|
typeList = registry[type] = [];
|
package/package.json
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
<script lang="ts">
|
|
11
11
|
import { onMount } from "svelte";
|
|
12
12
|
|
|
13
|
+
import { TARGET } from "../../constants/target";
|
|
13
14
|
import type {
|
|
14
15
|
BuilderContextInterface,
|
|
15
16
|
RegisteredComponents,
|
|
@@ -115,7 +116,7 @@
|
|
|
115
116
|
registeredComponents: registeredComponents,
|
|
116
117
|
builderBlock: processedBlock(),
|
|
117
118
|
includeBlockProps: blockComponent?.()?.noWrap === true,
|
|
118
|
-
isInteractive: !blockComponent?.()?.isRSC,
|
|
119
|
+
isInteractive: !(blockComponent?.()?.isRSC && TARGET === "rsc"),
|
|
119
120
|
};
|
|
120
121
|
};
|
|
121
122
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
BuilderRenderState,
|
|
11
11
|
RegisteredComponents,
|
|
12
12
|
} from "../../context/types";
|
|
13
|
-
import {
|
|
13
|
+
import { serializeIncludingFunctions } from "../../functions/register-component";
|
|
14
14
|
import type { ComponentInfo } from "../../types/components";
|
|
15
15
|
import type { Dictionary } from "../../types/typescript";
|
|
16
16
|
import Blocks from "../blocks/blocks.svelte";
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
...acc,
|
|
71
71
|
[info.name]: {
|
|
72
72
|
component: component,
|
|
73
|
-
...
|
|
73
|
+
...serializeIncludingFunctions(info),
|
|
74
74
|
},
|
|
75
75
|
}),
|
|
76
76
|
{}
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
].reduce<Dictionary<ComponentInfo>>(
|
|
102
102
|
(acc, { component: _, ...info }) => ({
|
|
103
103
|
...acc,
|
|
104
|
-
[info.name]:
|
|
104
|
+
[info.name]: serializeIncludingFunctions(info),
|
|
105
105
|
}),
|
|
106
106
|
{}
|
|
107
107
|
),
|
|
@@ -2,7 +2,8 @@ import type { BuilderRenderContext, RegisteredComponent } from '../../context/ty
|
|
|
2
2
|
import type { ApiVersion } from '../../types/api-version';
|
|
3
3
|
import type { BuilderContent } from '../../types/builder-content';
|
|
4
4
|
import type { Nullable } from '../../types/typescript';
|
|
5
|
-
|
|
5
|
+
import type { ExtraFrameworkProps } from './extra-framework-props-types';
|
|
6
|
+
export interface ContentVariantsPrps extends ExtraFrameworkProps {
|
|
6
7
|
/**
|
|
7
8
|
* The Builder content JSON to render (required).
|
|
8
9
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export interface ExtraFrameworkProps {}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "2.0.
|
|
1
|
+
export const SDK_VERSION = "2.0.9"
|
package/src/context/types.ts
CHANGED
|
@@ -3,13 +3,14 @@ import type { ApiVersion } from '../types/api-version';
|
|
|
3
3
|
import type { BuilderContent } from '../types/builder-content';
|
|
4
4
|
import type { ComponentInfo } from '../types/components';
|
|
5
5
|
import type { Dictionary, Nullable } from '../types/typescript';
|
|
6
|
+
import type { ExtraContextTypes } from './extra-context-types';
|
|
6
7
|
export type RegisteredComponent = ComponentInfo & {
|
|
7
8
|
component: any;
|
|
8
9
|
};
|
|
9
10
|
export type RegisteredComponents = Dictionary<RegisteredComponent>;
|
|
10
11
|
export type BuilderRenderState = Record<string, unknown>;
|
|
11
12
|
export type BuilderRenderContext = Record<string, unknown>;
|
|
12
|
-
export interface BuilderContextInterface extends Pick<BlocksWrapperProps, 'BlocksWrapper' | 'BlocksWrapperProps'
|
|
13
|
+
export interface BuilderContextInterface extends Pick<BlocksWrapperProps, 'BlocksWrapper' | 'BlocksWrapperProps'>, ExtraContextTypes {
|
|
13
14
|
content: Nullable<BuilderContent>;
|
|
14
15
|
context: BuilderRenderContext;
|
|
15
16
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ComponentInfo } from '../types/components';
|
|
2
2
|
export const createRegisterComponentMessage = (info: ComponentInfo) => ({
|
|
3
3
|
type: 'builder.registerComponent',
|
|
4
|
-
data:
|
|
4
|
+
data: serializeIncludingFunctions(info)
|
|
5
5
|
});
|
|
6
6
|
|
|
7
7
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -15,7 +15,7 @@ const serializeFn = (fnValue: Function) => {
|
|
|
15
15
|
const appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(');
|
|
16
16
|
return `return (${appendFunction ? 'function ' : ''}${fnStr}).apply(this, arguments)`;
|
|
17
17
|
};
|
|
18
|
-
export function
|
|
18
|
+
export function serializeIncludingFunctions(info: ComponentInfo) {
|
|
19
19
|
return JSON.parse(JSON.stringify(info, (key, value) => {
|
|
20
20
|
if (typeof value === 'function') {
|
|
21
21
|
return serializeFn(value);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { BuilderBlock } from '../types/builder-block';
|
|
2
2
|
import type { DeepPartial } from '../types/deep-partial';
|
|
3
3
|
import { isBrowser } from './is-browser';
|
|
4
|
+
import { serializeIncludingFunctions } from './register-component';
|
|
4
5
|
export interface InsertMenuItem {
|
|
5
6
|
name: string;
|
|
6
7
|
icon?: string;
|
|
@@ -19,6 +20,9 @@ const registry: {
|
|
|
19
20
|
export function register(type: 'insertMenu', info: InsertMenuConfig): void;
|
|
20
21
|
export function register(type: string, info: any): void;
|
|
21
22
|
export function register(type: string, info: any) {
|
|
23
|
+
if (type === 'plugin') {
|
|
24
|
+
info = serializeIncludingFunctions(info);
|
|
25
|
+
}
|
|
22
26
|
let typeList = registry[type];
|
|
23
27
|
if (!typeList) {
|
|
24
28
|
typeList = registry[type] = [];
|