@builder.io/sdk-react 0.5.7 → 0.5.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/dist/blocks/button/button.js +2 -2
- package/dist/blocks/columns/columns.js +4 -4
- package/dist/blocks/image/image.js +6 -6
- package/dist/components/blocks/blocks-wrapper.js +2 -2
- package/dist/components/content/components/enable-editor.js +2 -1
- package/dist/components/content/content.types.d.ts +2 -2
- package/dist/components/content-variants/content-variants.d.ts +2 -2
- package/dist/components/content-variants/content-variants.types.d.ts +1 -1
- package/dist/constants/sdk-version.d.ts +1 -1
- package/dist/constants/sdk-version.js +1 -1
- package/dist/functions/evaluate/browser-runtime/browser.d.ts +4 -0
- package/dist/functions/evaluate/browser-runtime/browser.js +31 -0
- package/dist/functions/evaluate/browser-runtime/index.d.ts +1 -0
- package/dist/functions/evaluate/browser-runtime/index.js +1 -0
- package/dist/functions/evaluate/evaluate.d.ts +4 -8
- package/dist/functions/evaluate/evaluate.js +15 -38
- package/dist/functions/evaluate/helpers.d.ts +18 -0
- package/dist/functions/evaluate/helpers.js +10 -0
- package/dist/functions/evaluate/index.d.ts +1 -1
- package/dist/functions/evaluate/index.js +1 -1
- package/dist/functions/evaluate/node-runtime/index.d.ts +1 -0
- package/dist/functions/evaluate/node-runtime/index.js +1 -0
- package/dist/functions/evaluate/non-node-runtime/non-node-runtime.d.ts +2 -2
- package/dist/functions/evaluate/non-node-runtime/non-node-runtime.js +12 -13
- package/dist/functions/fetch-builder-props.d.ts +2 -2
- package/dist/functions/get-block-actions-handler.js +1 -1
- package/dist/functions/register-component.js +1 -1
- package/dist/index.d.ts +5 -14
- package/dist/index.js +5 -9
- package/dist/server-index.d.ts +15 -0
- package/dist/server-index.js +10 -0
- package/package.json +1 -1
- package/dist/functions/evaluate/types.d.ts +0 -11
- package/dist/functions/evaluate/types.js +0 -1
- /package/dist/functions/evaluate/{acorn-interpreter.d.ts → non-node-runtime/acorn-interpreter.d.ts} +0 -0
- /package/dist/functions/evaluate/{acorn-interpreter.js → non-node-runtime/acorn-interpreter.js} +0 -0
|
@@ -4,8 +4,8 @@ function Button(props) {
|
|
|
4
4
|
return (React.createElement(React.Fragment, null,
|
|
5
5
|
props.link ? (React.createElement(React.Fragment, null,
|
|
6
6
|
React.createElement("a", { role: "button", ...{}, ...props.attributes, href: props.link, target: props.openLinkInNewTab ? "_blank" : undefined }, props.text))) : (React.createElement(React.Fragment, null,
|
|
7
|
-
React.createElement("button", { ...{}, ...props.attributes, style: props.attributes.style, className: props.attributes.className + " button-
|
|
8
|
-
React.createElement("style", null, `.button-
|
|
7
|
+
React.createElement("button", { ...{}, ...props.attributes, style: props.attributes.style, className: props.attributes.className + " button-3e7bc8b2" }, props.text))),
|
|
8
|
+
React.createElement("style", null, `.button-3e7bc8b2 {
|
|
9
9
|
all: unset;
|
|
10
10
|
}`)));
|
|
11
11
|
}
|
|
@@ -102,17 +102,17 @@ function Columns(props) {
|
|
|
102
102
|
}
|
|
103
103
|
return (React.createElement(React.Fragment, null,
|
|
104
104
|
React.createElement("div", { className: `builder-columns ${props.builderBlock.id}-breakpoints` +
|
|
105
|
-
" div-
|
|
105
|
+
" div-3ea707d8", style: columnsCssVars(), ...{} },
|
|
106
106
|
TARGET !== "reactNative" ? (React.createElement(React.Fragment, null,
|
|
107
107
|
React.createElement(InlinedStyles, { styles: columnsStyles() }))) : null,
|
|
108
|
-
props.columns?.map((column, index) => (React.createElement("div", { className: "builder-column div-
|
|
108
|
+
props.columns?.map((column, index) => (React.createElement("div", { className: "builder-column div-3ea707d8-2", style: columnCssVars(index), ...{}, key: index },
|
|
109
109
|
React.createElement(Blocks, { blocks: column.blocks, path: `component.options.columns.${index}.blocks`, parent: props.builderBlock.id, styleProp: {
|
|
110
110
|
flexGrow: "1",
|
|
111
111
|
}, context: props.builderContext, registeredComponents: props.builderComponents }))))),
|
|
112
|
-
React.createElement("style", null, `.div-
|
|
112
|
+
React.createElement("style", null, `.div-3ea707d8 {
|
|
113
113
|
display: flex;
|
|
114
114
|
line-height: normal;
|
|
115
|
-
}.div-
|
|
115
|
+
}.div-3ea707d8-2 {
|
|
116
116
|
display: flex;
|
|
117
117
|
flex-direction: column;
|
|
118
118
|
align-items: stretch;
|
|
@@ -52,23 +52,23 @@ function Image(props) {
|
|
|
52
52
|
...aspectRatioCss(),
|
|
53
53
|
}, className: "builder-image" +
|
|
54
54
|
(props.className ? " " + props.className : "") +
|
|
55
|
-
" img-
|
|
55
|
+
" img-ef11a6be", src: props.image, srcSet: srcSetToUse(), sizes: props.sizes })),
|
|
56
56
|
props.aspectRatio &&
|
|
57
57
|
!(props.builderBlock?.children?.length && props.fitContent) ? (React.createElement(React.Fragment, null,
|
|
58
|
-
React.createElement("div", { className: "builder-image-sizer div-
|
|
58
|
+
React.createElement("div", { className: "builder-image-sizer div-ef11a6be", style: {
|
|
59
59
|
paddingTop: props.aspectRatio * 100 + "%",
|
|
60
60
|
} }))) : null,
|
|
61
61
|
props.builderBlock?.children?.length && props.fitContent ? (React.createElement(React.Fragment, null, props.children)) : null,
|
|
62
62
|
!props.fitContent && props.children ? (React.createElement(React.Fragment, null,
|
|
63
|
-
React.createElement("div", { className: "div-
|
|
64
|
-
React.createElement("style", null, `.img-
|
|
63
|
+
React.createElement("div", { className: "div-ef11a6be-2" }, props.children))) : null),
|
|
64
|
+
React.createElement("style", null, `.img-ef11a6be {
|
|
65
65
|
opacity: 1;
|
|
66
66
|
transition: opacity 0.2s ease-in-out;
|
|
67
|
-
}.div-
|
|
67
|
+
}.div-ef11a6be {
|
|
68
68
|
width: 100%;
|
|
69
69
|
pointer-events: none;
|
|
70
70
|
font-size: 0;
|
|
71
|
-
}.div-
|
|
71
|
+
}.div-ef11a6be-2 {
|
|
72
72
|
display: flex;
|
|
73
73
|
flex-direction: column;
|
|
74
74
|
align-items: stretch;
|
|
@@ -28,8 +28,8 @@ function BlocksWrapper(props) {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
return (React.createElement(React.Fragment, null,
|
|
31
|
-
React.createElement("div", { className: className() + " div-
|
|
32
|
-
React.createElement("style", null, `.div-
|
|
31
|
+
React.createElement("div", { className: className() + " div-5821bd52", "builder-path": props.path, "builder-parent-id": props.parent, ...{}, style: props.styleProp, onClick: (event) => onClick(), onMouseEnter: (event) => onMouseEnter(), onKeyPress: (event) => onClick() }, props.children),
|
|
32
|
+
React.createElement("style", null, `.div-5821bd52 {
|
|
33
33
|
display: flex;
|
|
34
34
|
flex-direction: column;
|
|
35
35
|
align-items: stretch;
|
|
@@ -14,6 +14,7 @@ import { getInteractionPropertiesForEvent } from "../../../functions/track/inter
|
|
|
14
14
|
import { logger } from "../../../helpers/logger.js";
|
|
15
15
|
import { fetchOneEntry } from "../../../functions/get-content/index.js";
|
|
16
16
|
import { isPreviewing } from "../../../functions/is-previewing.js";
|
|
17
|
+
import { fastClone } from "../../../functions/fast-clone.js";
|
|
17
18
|
function EnableEditor(props) {
|
|
18
19
|
const elementRef = useRef(null);
|
|
19
20
|
const [canTrackToUse, setCanTrackToUse] = useState(() => checkIsDefined(props.canTrack) ? props.canTrack : true);
|
|
@@ -150,7 +151,7 @@ function EnableEditor(props) {
|
|
|
150
151
|
if (isEditing()) {
|
|
151
152
|
window.dispatchEvent(new CustomEvent("builder:component:stateChange", {
|
|
152
153
|
detail: {
|
|
153
|
-
state: props.builderContextSignal.rootState,
|
|
154
|
+
state: fastClone(props.builderContextSignal.rootState),
|
|
154
155
|
ref: {
|
|
155
156
|
name: props.model,
|
|
156
157
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BuilderRenderState } from '../../context/types.js';
|
|
2
2
|
import type { EnforcePartials } from '../../types/enforced-partials.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { ContentVariantsPrps } from '../content-variants/content-variants.types.js';
|
|
4
4
|
interface InternalRenderProps {
|
|
5
5
|
/**
|
|
6
6
|
* TO-DO: improve qwik generator to not remap this name for non-HTML tags, then name it `className`
|
|
@@ -9,7 +9,7 @@ interface InternalRenderProps {
|
|
|
9
9
|
showContent: boolean;
|
|
10
10
|
isSsrAbTest: boolean;
|
|
11
11
|
}
|
|
12
|
-
export type ContentProps = InternalRenderProps & EnforcePartials<
|
|
12
|
+
export type ContentProps = InternalRenderProps & EnforcePartials<ContentVariantsPrps>;
|
|
13
13
|
export interface BuilderComponentStateChange {
|
|
14
14
|
state: BuilderRenderState;
|
|
15
15
|
ref: {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
type VariantsProviderProps =
|
|
2
|
+
type VariantsProviderProps = ContentVariantsPrps & {
|
|
3
3
|
/**
|
|
4
4
|
* For internal use only. Do not provide this prop.
|
|
5
5
|
*/
|
|
6
6
|
__isNestedRender?: boolean;
|
|
7
7
|
};
|
|
8
|
-
import type {
|
|
8
|
+
import type { ContentVariantsPrps } from "./content-variants.types.js";
|
|
9
9
|
declare function ContentVariants(props: VariantsProviderProps): JSX.Element;
|
|
10
10
|
export default ContentVariants;
|
|
@@ -2,7 +2,7 @@ import type { BuilderRenderContext, RegisteredComponent } from '../../context/ty
|
|
|
2
2
|
import type { ApiVersion } from '../../types/api-version.js';
|
|
3
3
|
import type { BuilderContent } from '../../types/builder-content.js';
|
|
4
4
|
import type { Nullable } from '../../types/typescript.js';
|
|
5
|
-
export interface
|
|
5
|
+
export interface ContentVariantsPrps {
|
|
6
6
|
content?: Nullable<BuilderContent>;
|
|
7
7
|
model?: string;
|
|
8
8
|
data?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.5.
|
|
1
|
+
export declare const SDK_VERSION = "0.5.9";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.5.
|
|
1
|
+
export const SDK_VERSION = "0.5.9";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BuilderRenderState } from '../../../context/types.js';
|
|
2
|
+
import type { ExecutorArgs } from '../helpers.js';
|
|
3
|
+
export declare const runInBrowser: ({ code, builder, context, event, localState, rootSetState, rootState }: ExecutorArgs) => any;
|
|
4
|
+
export declare function flattenState(rootState: Record<string | symbol, any>, localState: Record<string | symbol, any> | undefined, rootSetState: ((rootState: BuilderRenderState) => void) | undefined): BuilderRenderState;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { getFunctionArguments } from '../helpers.js';
|
|
2
|
+
export const runInBrowser = ({ code, builder, context, event, localState, rootSetState, rootState }) => {
|
|
3
|
+
const functionArgs = getFunctionArguments({
|
|
4
|
+
builder,
|
|
5
|
+
context,
|
|
6
|
+
event,
|
|
7
|
+
state: flattenState(rootState, localState, rootSetState)
|
|
8
|
+
});
|
|
9
|
+
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
10
|
+
};
|
|
11
|
+
export function flattenState(rootState, localState, rootSetState) {
|
|
12
|
+
if (rootState === localState) {
|
|
13
|
+
throw new Error('rootState === localState');
|
|
14
|
+
}
|
|
15
|
+
return new Proxy(rootState, {
|
|
16
|
+
get: (_, prop) => {
|
|
17
|
+
if (localState && prop in localState) {
|
|
18
|
+
return localState[prop];
|
|
19
|
+
}
|
|
20
|
+
return rootState[prop];
|
|
21
|
+
},
|
|
22
|
+
set: (_, prop, value) => {
|
|
23
|
+
if (localState && prop in localState) {
|
|
24
|
+
throw new Error('Writing to local state is not allowed as it is read-only.');
|
|
25
|
+
}
|
|
26
|
+
rootState[prop] = value;
|
|
27
|
+
rootSetState?.(rootState);
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { runInBrowser as evaluator } from './browser.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { runInBrowser as evaluator } from './browser.js';
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export declare function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression }: {
|
|
4
|
-
code: string;
|
|
1
|
+
import type { ExecutorArgs } from './helpers.js';
|
|
2
|
+
export type EvaluatorArgs = Omit<ExecutorArgs, 'builder' | 'event'> & {
|
|
5
3
|
event?: Event;
|
|
6
4
|
isExpression?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export declare
|
|
9
|
-
export declare const runInNode: (args: ExecutorArgs) => any;
|
|
10
|
-
export declare function flattenState(rootState: Record<string | symbol, any>, localState: Record<string | symbol, any> | undefined, rootSetState: ((rootState: BuilderRenderState) => void) | undefined): BuilderRenderState;
|
|
5
|
+
};
|
|
6
|
+
export declare function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression }: EvaluatorArgs): any;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { logger } from '../../helpers/logger.js';
|
|
2
2
|
import { isBrowser } from '../is-browser.js';
|
|
3
3
|
import { isEditing } from '../is-editing.js';
|
|
4
|
-
import {
|
|
4
|
+
import { getUserAttributes } from '../track/helpers.js';
|
|
5
|
+
import { runInBrowser } from './browser-runtime/browser.js';
|
|
5
6
|
import { runInNonNode } from './non-node-runtime/index.js';
|
|
7
|
+
import { isNonNodeServer } from '../is-non-node-server.js';
|
|
6
8
|
export function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
|
|
7
9
|
if (code === '') {
|
|
8
10
|
logger.warn('Skipping evaluation of empty code block.');
|
|
@@ -11,7 +13,8 @@ export function evaluate({ code, context, localState, rootState, rootSetState, e
|
|
|
11
13
|
const builder = {
|
|
12
14
|
isEditing: isEditing(),
|
|
13
15
|
isBrowser: isBrowser(),
|
|
14
|
-
isServer: !isBrowser()
|
|
16
|
+
isServer: !isBrowser(),
|
|
17
|
+
getUserAttributes: () => getUserAttributes()
|
|
15
18
|
};
|
|
16
19
|
// Be able to handle simple expressions like "state.foo" or "1 + 1"
|
|
17
20
|
// as well as full blocks like "var foo = "bar"; return foo"
|
|
@@ -20,7 +23,7 @@ export function evaluate({ code, context, localState, rootState, rootSetState, e
|
|
|
20
23
|
isExpression && !(code.includes(';') || code.includes(' return ') || code.trim().startsWith('return '));
|
|
21
24
|
const useCode = useReturn ? `return (${code});` : code;
|
|
22
25
|
const args = {
|
|
23
|
-
useCode,
|
|
26
|
+
code: useCode,
|
|
24
27
|
builder,
|
|
25
28
|
context,
|
|
26
29
|
event,
|
|
@@ -28,43 +31,17 @@ export function evaluate({ code, context, localState, rootState, rootSetState, e
|
|
|
28
31
|
rootState,
|
|
29
32
|
localState
|
|
30
33
|
};
|
|
31
|
-
if (isBrowser())
|
|
32
|
-
return runInBrowser(args);
|
|
33
|
-
if (isNonNodeServer())
|
|
34
|
-
return runInNonNode(args);
|
|
35
|
-
return runInNode(args);
|
|
36
|
-
}
|
|
37
|
-
export const runInBrowser = ({ useCode, builder, context, event, localState, rootSetState, rootState }) => {
|
|
38
|
-
const state = flattenState(rootState, localState, rootSetState);
|
|
39
34
|
try {
|
|
40
|
-
|
|
35
|
+
if (isBrowser())
|
|
36
|
+
return runInBrowser(args);
|
|
37
|
+
if (isNonNodeServer())
|
|
38
|
+
return runInNonNode(args);
|
|
39
|
+
return runInBrowser(args);
|
|
41
40
|
}
|
|
42
41
|
catch (e) {
|
|
43
|
-
logger.
|
|
44
|
-
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
// TO-DO: use vm-isolate
|
|
48
|
-
return runInBrowser(args);
|
|
49
|
-
};
|
|
50
|
-
export function flattenState(rootState, localState, rootSetState) {
|
|
51
|
-
if (rootState === localState) {
|
|
52
|
-
throw new Error('rootState === localState');
|
|
42
|
+
logger.error('Failed code evaluation: ' + e.message, {
|
|
43
|
+
code
|
|
44
|
+
});
|
|
45
|
+
return undefined;
|
|
53
46
|
}
|
|
54
|
-
return new Proxy(rootState, {
|
|
55
|
-
get: (_, prop) => {
|
|
56
|
-
if (localState && prop in localState) {
|
|
57
|
-
return localState[prop];
|
|
58
|
-
}
|
|
59
|
-
return rootState[prop];
|
|
60
|
-
},
|
|
61
|
-
set: (_, prop, value) => {
|
|
62
|
-
if (localState && prop in localState) {
|
|
63
|
-
throw new Error('Writing to local state is not allowed as it is read-only.');
|
|
64
|
-
}
|
|
65
|
-
rootState[prop] = value;
|
|
66
|
-
rootSetState?.(rootState);
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
47
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { BuilderContextInterface, BuilderRenderState } from '../../context/types.js';
|
|
2
|
+
import type { getUserAttributes } from '../track/helpers.js';
|
|
3
|
+
export type BuilderGlobals = {
|
|
4
|
+
isEditing: boolean | undefined;
|
|
5
|
+
isBrowser: boolean | undefined;
|
|
6
|
+
isServer: boolean | undefined;
|
|
7
|
+
getUserAttributes: typeof getUserAttributes;
|
|
8
|
+
};
|
|
9
|
+
export type ExecutorArgs = Pick<BuilderContextInterface, 'localState' | 'context' | 'rootState' | 'rootSetState'> & {
|
|
10
|
+
code: string;
|
|
11
|
+
builder: BuilderGlobals;
|
|
12
|
+
event: Event | undefined;
|
|
13
|
+
};
|
|
14
|
+
export type Executor = (args: ExecutorArgs) => any;
|
|
15
|
+
export type FunctionArguments = ReturnType<typeof getFunctionArguments>;
|
|
16
|
+
export declare const getFunctionArguments: ({ builder, context, event, state }: Pick<ExecutorArgs, "context" | "builder" | "event"> & {
|
|
17
|
+
state: BuilderRenderState;
|
|
18
|
+
}) => [string, Event | BuilderRenderState | import("../../context/types.js").BuilderRenderContext | BuilderGlobals][];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { evaluate } from './evaluate';
|
|
1
|
+
export { evaluate } from './evaluate.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { evaluate } from './evaluate';
|
|
1
|
+
export { evaluate } from './evaluate.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { evaluator } from '../browser-runtime/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { evaluator } from '../browser-runtime/index.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ExecutorArgs } from '../
|
|
2
|
-
export declare const runInNonNode: ({ builder, context, event, rootState, localState, rootSetState,
|
|
1
|
+
import type { ExecutorArgs } from '../helpers.js';
|
|
2
|
+
export declare const runInNonNode: ({ builder, context, event, rootState, localState, rootSetState, code }: ExecutorArgs) => any;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { logger } from '../../../helpers/logger';
|
|
2
|
-
import { set } from '../../set';
|
|
3
|
-
import Interpreter from '
|
|
1
|
+
import { logger } from '../../../helpers/logger.js';
|
|
2
|
+
import { set } from '../../set.js';
|
|
3
|
+
import Interpreter from './acorn-interpreter.js';
|
|
4
|
+
import { getFunctionArguments } from '../helpers.js';
|
|
4
5
|
const processCode = (code) => {
|
|
5
6
|
return code.split('\n').map(line => {
|
|
6
7
|
const trimmed = line.trim();
|
|
@@ -21,23 +22,22 @@ const processCode = (code) => {
|
|
|
21
22
|
}).filter(Boolean).join('\n');
|
|
22
23
|
};
|
|
23
24
|
const getJSONValName = (val) => val + 'JSON';
|
|
24
|
-
export const runInNonNode = ({ builder, context, event, rootState, localState, rootSetState,
|
|
25
|
+
export const runInNonNode = ({ builder, context, event, rootState, localState, rootSetState, code }) => {
|
|
25
26
|
const state = {
|
|
26
27
|
...rootState,
|
|
27
28
|
...localState
|
|
28
29
|
};
|
|
29
|
-
const properties = {
|
|
30
|
-
state,
|
|
31
|
-
Builder: builder,
|
|
30
|
+
const properties = getFunctionArguments({
|
|
32
31
|
builder,
|
|
33
32
|
context,
|
|
34
|
-
event
|
|
35
|
-
|
|
33
|
+
event,
|
|
34
|
+
state
|
|
35
|
+
});
|
|
36
36
|
/**
|
|
37
37
|
* Deserialize all properties from JSON strings to JS objects
|
|
38
38
|
*/
|
|
39
|
-
const prependedCode =
|
|
40
|
-
const cleanedCode = processCode(
|
|
39
|
+
const prependedCode = properties.map(([key]) => `var ${key} = JSON.parse(${getJSONValName(key)});`).join('\n');
|
|
40
|
+
const cleanedCode = processCode(code);
|
|
41
41
|
if (cleanedCode === '') {
|
|
42
42
|
logger.warn('Skipping evaluation of empty code block.');
|
|
43
43
|
return;
|
|
@@ -58,8 +58,7 @@ theFunction();
|
|
|
58
58
|
/**
|
|
59
59
|
* serialize all function args to JSON strings
|
|
60
60
|
*/
|
|
61
|
-
|
|
62
|
-
const val = properties[key] || {};
|
|
61
|
+
properties.forEach(([key, val]) => {
|
|
63
62
|
const jsonVal = JSON.stringify(val);
|
|
64
63
|
interpreter.setProperty(globalObject, getJSONValName(key), jsonVal);
|
|
65
64
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ContentVariantsPrps } from '../components/content-variants/content-variants.types.js';
|
|
2
2
|
import type { Dictionary } from '../types/typescript.js';
|
|
3
3
|
import type { GetContentOptions } from './get-content/types.js';
|
|
4
4
|
type GetBuilderPropsOptions = (Omit<GetContentOptions, 'model'> & {
|
|
@@ -35,5 +35,5 @@ type GetBuilderPropsOptions = (Omit<GetContentOptions, 'model'> & {
|
|
|
35
35
|
/**
|
|
36
36
|
* Fetches builder content, and returns it along with sensible defaults for other props that `Content` needs to render.
|
|
37
37
|
*/
|
|
38
|
-
export declare const fetchBuilderProps: (_args: GetBuilderPropsOptions) => Promise<
|
|
38
|
+
export declare const fetchBuilderProps: (_args: GetBuilderPropsOptions) => Promise<ContentVariantsPrps>;
|
|
39
39
|
export {};
|
|
@@ -16,7 +16,7 @@ export function registerComponent(component, info) {
|
|
|
16
16
|
}
|
|
17
17
|
export const createRegisterComponentMessage = (info) => ({
|
|
18
18
|
type: 'builder.registerComponent',
|
|
19
|
-
data: info
|
|
19
|
+
data: serializeComponentInfo(info)
|
|
20
20
|
});
|
|
21
21
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
22
22
|
const serializeFn = (fnValue) => {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
export * from './index-helpers/top-of-file.js';
|
|
2
2
|
export * from './index-helpers/blocks-exports.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
export { setEditorSettings } from './functions/set-editor-settings.js';
|
|
9
|
-
export type { Settings } from './functions/set-editor-settings.js';
|
|
10
|
-
export { fetchEntries, fetchOneEntry, getAllContent, getContent, _processContentResult } from './functions/get-content/index.js';
|
|
11
|
-
export { getBuilderSearchParams } from './functions/get-builder-search-params/index.js';
|
|
12
|
-
export { track } from './functions/track/index.js';
|
|
13
|
-
export type { RegisteredComponent } from './context/types.js';
|
|
14
|
-
export type { ComponentInfo } from './types/components.js';
|
|
15
|
-
export type { ContentProps } from './components/content/content.types.js';
|
|
16
|
-
export { fetchBuilderProps } from './functions/fetch-builder-props.js';
|
|
3
|
+
/**
|
|
4
|
+
* We have a separate entry point to the SDKs that guarantees no components are being imported. This is useful
|
|
5
|
+
* for React SDK, which would break in the NextJS App directory because the component imports have `use client` in them.
|
|
6
|
+
*/
|
|
7
|
+
export * from './server-index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
export * from './index-helpers/top-of-file.js';
|
|
2
2
|
export * from './index-helpers/blocks-exports.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
export { fetchEntries, fetchOneEntry, getAllContent, getContent, _processContentResult } from './functions/get-content/index.js';
|
|
9
|
-
export { getBuilderSearchParams } from './functions/get-builder-search-params/index.js';
|
|
10
|
-
export { track } from './functions/track/index.js';
|
|
11
|
-
export { fetchBuilderProps } from './functions/fetch-builder-props.js';
|
|
3
|
+
/**
|
|
4
|
+
* We have a separate entry point to the SDKs that guarantees no components are being imported. This is useful
|
|
5
|
+
* for React SDK, which would break in the NextJS App directory because the component imports have `use client` in them.
|
|
6
|
+
*/
|
|
7
|
+
export * from './server-index.js';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './index-helpers/top-of-file.js';
|
|
2
|
+
export { isEditing } from './functions/is-editing.js';
|
|
3
|
+
export { isPreviewing } from './functions/is-previewing.js';
|
|
4
|
+
export { createRegisterComponentMessage } from './functions/register-component.js';
|
|
5
|
+
export { register } from './functions/register.js';
|
|
6
|
+
export type { InsertMenuConfig, InsertMenuItem } from './functions/register.js';
|
|
7
|
+
export { setEditorSettings } from './functions/set-editor-settings.js';
|
|
8
|
+
export type { Settings } from './functions/set-editor-settings.js';
|
|
9
|
+
export { fetchEntries, fetchOneEntry, getAllContent, getContent, _processContentResult } from './functions/get-content/index.js';
|
|
10
|
+
export { getBuilderSearchParams } from './functions/get-builder-search-params/index.js';
|
|
11
|
+
export { track } from './functions/track/index.js';
|
|
12
|
+
export type { RegisteredComponent } from './context/types.js';
|
|
13
|
+
export type { ComponentInfo } from './types/components.js';
|
|
14
|
+
export type { ContentProps } from './components/content/content.types.js';
|
|
15
|
+
export { fetchBuilderProps } from './functions/fetch-builder-props.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './index-helpers/top-of-file.js';
|
|
2
|
+
export { isEditing } from './functions/is-editing.js';
|
|
3
|
+
export { isPreviewing } from './functions/is-previewing.js';
|
|
4
|
+
export { createRegisterComponentMessage } from './functions/register-component.js';
|
|
5
|
+
export { register } from './functions/register.js';
|
|
6
|
+
export { setEditorSettings } from './functions/set-editor-settings.js';
|
|
7
|
+
export { fetchEntries, fetchOneEntry, getAllContent, getContent, _processContentResult } from './functions/get-content/index.js';
|
|
8
|
+
export { getBuilderSearchParams } from './functions/get-builder-search-params/index.js';
|
|
9
|
+
export { track } from './functions/track/index.js';
|
|
10
|
+
export { fetchBuilderProps } from './functions/fetch-builder-props.js';
|
package/package.json
CHANGED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { BuilderContextInterface } from '../../context/types';
|
|
2
|
-
export type ExecutorArgs = Pick<BuilderContextInterface, 'localState' | 'context' | 'rootState' | 'rootSetState'> & {
|
|
3
|
-
useCode: string;
|
|
4
|
-
builder: {
|
|
5
|
-
isEditing: boolean | undefined;
|
|
6
|
-
isBrowser: boolean | undefined;
|
|
7
|
-
isServer: boolean | undefined;
|
|
8
|
-
};
|
|
9
|
-
event: Event | undefined;
|
|
10
|
-
};
|
|
11
|
-
export type Executor = (args: ExecutorArgs) => any;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
/package/dist/functions/evaluate/{acorn-interpreter.d.ts → non-node-runtime/acorn-interpreter.d.ts}
RENAMED
|
File without changes
|
/package/dist/functions/evaluate/{acorn-interpreter.js → non-node-runtime/acorn-interpreter.js}
RENAMED
|
File without changes
|