@builder.io/sdk-react 0.5.2 → 0.5.4

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.
Files changed (61) hide show
  1. package/README.md +4 -0
  2. package/dist/blocks/BaseText.d.ts +1 -0
  3. package/dist/blocks/button/button.d.ts +1 -0
  4. package/dist/blocks/button/button.js +2 -2
  5. package/dist/blocks/columns/columns.d.ts +1 -0
  6. package/dist/blocks/columns/columns.js +2 -2
  7. package/dist/blocks/custom-code/custom-code.d.ts +1 -0
  8. package/dist/blocks/embed/embed.d.ts +1 -0
  9. package/dist/blocks/form/form.d.ts +1 -0
  10. package/dist/blocks/fragment/fragment.d.ts +1 -0
  11. package/dist/blocks/image/image.d.ts +1 -0
  12. package/dist/blocks/img/img.d.ts +1 -0
  13. package/dist/blocks/img/img.js +1 -1
  14. package/dist/blocks/input/input.d.ts +1 -0
  15. package/dist/blocks/input/input.js +1 -1
  16. package/dist/blocks/raw-text/raw-text.d.ts +1 -0
  17. package/dist/blocks/section/section.d.ts +1 -0
  18. package/dist/blocks/section/section.js +1 -1
  19. package/dist/blocks/select/select.d.ts +1 -0
  20. package/dist/blocks/select/select.js +1 -1
  21. package/dist/blocks/submit-button/submit-button.d.ts +1 -0
  22. package/dist/blocks/submit-button/submit-button.js +1 -1
  23. package/dist/blocks/symbol/symbol.d.ts +1 -0
  24. package/dist/blocks/symbol/symbol.js +1 -1
  25. package/dist/blocks/text/text.d.ts +1 -0
  26. package/dist/blocks/text/text.js +1 -1
  27. package/dist/blocks/textarea/textarea.d.ts +1 -0
  28. package/dist/blocks/textarea/textarea.js +1 -1
  29. package/dist/blocks/video/video.d.ts +1 -0
  30. package/dist/components/block/block.d.ts +1 -0
  31. package/dist/components/block/components/block-styles.d.ts +1 -0
  32. package/dist/components/block/components/block-wrapper.d.ts +1 -0
  33. package/dist/components/block/components/component-ref/component-ref.d.ts +1 -0
  34. package/dist/components/block/components/interactive-element.d.ts +1 -0
  35. package/dist/components/block/components/repeated-block.d.ts +1 -0
  36. package/dist/components/blocks/blocks-wrapper.d.ts +1 -0
  37. package/dist/components/blocks/blocks-wrapper.js +1 -1
  38. package/dist/components/blocks/blocks.d.ts +1 -0
  39. package/dist/components/content/components/enable-editor.d.ts +1 -0
  40. package/dist/components/content/components/enable-editor.js +1 -1
  41. package/dist/components/content/components/styles.d.ts +1 -0
  42. package/dist/components/content/content.d.ts +1 -0
  43. package/dist/components/content/content.js +3 -1
  44. package/dist/components/content-variants/content-variants.d.ts +1 -0
  45. package/dist/components/content-variants/content-variants.js +12 -6
  46. package/dist/components/inlined-script.d.ts +1 -0
  47. package/dist/components/inlined-styles.d.ts +1 -0
  48. package/dist/constants/sdk-version.d.ts +1 -1
  49. package/dist/constants/sdk-version.js +1 -1
  50. package/dist/functions/evaluate/acorn-interpreter.js +3111 -0
  51. package/dist/functions/evaluate/evaluate.js +1 -1
  52. package/dist/functions/evaluate/non-node-runtime/index.d.ts +1 -0
  53. package/dist/functions/evaluate/non-node-runtime/index.js +2 -0
  54. package/dist/functions/evaluate/{non-node-runtime.d.ts → non-node-runtime/non-node-runtime.d.ts} +1 -1
  55. package/dist/functions/evaluate/{non-node-runtime.js → non-node-runtime/non-node-runtime.js} +3 -3
  56. package/dist/functions/evaluate/types.d.ts +1 -0
  57. package/package.json +9 -2
  58. package/dist/functions/evaluate/acorn.d.ts +0 -0
  59. package/dist/functions/evaluate/acorn.js +0 -2432
  60. package/dist/functions/evaluate/interpreter.js +0 -3853
  61. /package/dist/functions/evaluate/{interpreter.d.ts → acorn-interpreter.d.ts} +0 -0
package/README.md CHANGED
@@ -90,3 +90,7 @@ npm install @builder.io/sdk-react
90
90
  ## Fetch
91
91
 
92
92
  This Package uses fetch. See [these docs](https://github.com/BuilderIO/this-package-uses-fetch/blob/main/README.md) for more information.
93
+
94
+ ## Non-Node.js Runtimes (Edge, Serverless)
95
+
96
+ If planning to deploy your app to a non-Node.js runtime (like Edge or Serverless functions), make sure to read the [Non-Node.js Runtimes](../../README.md#non-nodejs-runtimes-edge-serverless) section of the main README.
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export interface BaseTextProps {
2
3
  text: string;
3
4
  }
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  /**
2
3
  * This import is used by the Svelte SDK. Do not remove.
3
4
  */ export interface ButtonProps {
@@ -3,8 +3,8 @@ import * as React from "react";
3
3
  function Button(props) {
4
4
  return (React.createElement(React.Fragment, null,
5
5
  props.link ? (React.createElement(React.Fragment, null,
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-7267e9c6" }, props.text))),
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-7267e9c6" }, props.text))),
8
8
  React.createElement("style", null, `.button-7267e9c6 {
9
9
  all: unset;
10
10
  }`)));
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  type Column = {
2
3
  blocks: BuilderBlock[];
3
4
  width?: number;
@@ -102,10 +102,10 @@ 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-9f5ab4f8", style: columnsCssVars() },
105
+ " div-9f5ab4f8", 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-9f5ab4f8-2", style: columnCssVars(index), key: index },
108
+ props.columns?.map((column, index) => (React.createElement("div", { className: "builder-column div-9f5ab4f8-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 }))))),
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export interface CustomCodeProps {
2
3
  code: string;
3
4
  replaceNodes?: boolean;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export interface EmbedProps {
2
3
  content: string;
3
4
  }
@@ -1,2 +1,3 @@
1
+ /// <reference types="react" />
1
2
  declare function FormComponent(props: any): JSX.Element;
2
3
  export default FormComponent;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export interface FragmentProps {
2
3
  maxWidth?: number;
3
4
  attributes?: any;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export interface ImageProps {
2
3
  className?: string;
3
4
  image: string;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  /**
2
3
  * This import is used by the Svelte SDK. Do not remove.
3
4
  */ export interface ImgProps {
@@ -5,6 +5,6 @@ function ImgComponent(props) {
5
5
  return (React.createElement("img", { style: {
6
6
  objectFit: props.backgroundSize || "cover",
7
7
  objectPosition: props.backgroundPosition || "center",
8
- }, key: (isEditing() && props.imgSrc) || "default-key", alt: props.altText, src: props.imgSrc || props.image, ...props.attributes }));
8
+ }, key: (isEditing() && props.imgSrc) || "default-key", alt: props.altText, src: props.imgSrc || props.image, ...{}, ...props.attributes }));
9
9
  }
10
10
  export default ImgComponent;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  /**
2
3
  * This import is used by the Svelte SDK. Do not remove.
3
4
  */ export interface FormInputProps {
@@ -2,6 +2,6 @@
2
2
  import * as React from "react";
3
3
  import { isEditing } from "../../functions/is-editing.js";
4
4
  function FormInputComponent(props) {
5
- return (React.createElement("input", { ...props.attributes, key: isEditing() && props.defaultValue ? props.defaultValue : "default-key", placeholder: props.placeholder, type: props.type, name: props.name, value: props.value, defaultValue: props.defaultValue, required: props.required }));
5
+ return (React.createElement("input", { ...{}, ...props.attributes, key: isEditing() && props.defaultValue ? props.defaultValue : "default-key", placeholder: props.placeholder, type: props.type, name: props.name, value: props.value, defaultValue: props.defaultValue, required: props.required }));
6
6
  }
7
7
  export default FormInputComponent;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export interface RawTextProps {
2
3
  attributes?: any;
3
4
  text?: string;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  /**
2
3
  * This import is used by the Svelte SDK. Do not remove.
3
4
  */ export interface SectionProps {
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import * as React from "react";
3
3
  function SectionComponent(props) {
4
- return (React.createElement("section", { ...props.attributes, style: {
4
+ return (React.createElement("section", { ...{}, ...props.attributes, style: {
5
5
  width: "100%",
6
6
  alignSelf: "stretch",
7
7
  flexGrow: 1,
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  /**
2
3
  * This import is used by the Svelte SDK. Do not remove.
3
4
  */ export interface FormSelectProps {
@@ -2,6 +2,6 @@
2
2
  import * as React from "react";
3
3
  import { isEditing } from "../../functions/is-editing.js";
4
4
  function SelectComponent(props) {
5
- return (React.createElement("select", { ...props.attributes, value: props.value, key: isEditing() && props.defaultValue ? props.defaultValue : "default-key", defaultValue: props.defaultValue, name: props.name }, props.options?.map((option) => (React.createElement("option", { value: option.value }, option.name || option.value)))));
5
+ return (React.createElement("select", { ...{}, ...props.attributes, value: props.value, key: isEditing() && props.defaultValue ? props.defaultValue : "default-key", defaultValue: props.defaultValue, name: props.name }, props.options?.map((option) => (React.createElement("option", { value: option.value }, option.name || option.value)))));
6
6
  }
7
7
  export default SelectComponent;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  /**
2
3
  * This import is used by the Svelte SDK. Do not remove.
3
4
  */ export interface ButtonProps {
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import * as React from "react";
3
3
  function SubmitButton(props) {
4
- return (React.createElement("button", { type: "submit", ...props.attributes }, props.text));
4
+ return (React.createElement("button", { type: "submit", ...{}, ...props.attributes }, props.text));
5
5
  }
6
6
  export default SubmitButton;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  /**
2
3
  * This import is used by the Svelte SDK. Do not remove.
3
4
  */ export interface SymbolInfo {
@@ -35,7 +35,7 @@ function Symbol(props) {
35
35
  useEffect(() => {
36
36
  setContent();
37
37
  }, [props.symbol]);
38
- return (React.createElement("div", { ...props.attributes, className: className() },
38
+ return (React.createElement("div", { ...{}, ...props.attributes, ...{}, className: className() },
39
39
  React.createElement(ContentVariants, { __isNestedRender: true, apiVersion: props.builderContext.apiVersion, apiKey: props.builderContext.apiKey, context: props.builderContext.context, customComponents: Object.values(props.builderComponents), data: {
40
40
  ...props.symbol?.data,
41
41
  ...props.builderContext.localState,
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export interface TextProps {
2
3
  text?: string;
3
4
  }
@@ -3,6 +3,6 @@ import * as React from "react";
3
3
  function Text(props) {
4
4
  return (React.createElement("span", { className: "builder-text", dangerouslySetInnerHTML: { __html: props.text?.toString() || "" }, style: {
5
5
  outline: "none",
6
- } }));
6
+ }, ...{} }));
7
7
  }
8
8
  export default Text;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  /**
2
3
  * This import is used by the Svelte SDK. Do not remove.
3
4
  */ export interface TextareaProps {
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import * as React from "react";
3
3
  function Textarea(props) {
4
- return (React.createElement("textarea", { ...props.attributes, placeholder: props.placeholder, name: props.name, value: props.value, defaultValue: props.defaultValue }));
4
+ return (React.createElement("textarea", { ...{}, ...props.attributes, placeholder: props.placeholder, name: props.name, value: props.value, defaultValue: props.defaultValue }));
5
5
  }
6
6
  export default Textarea;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export interface VideoProps {
2
3
  attributes?: any;
3
4
  video?: string;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export type BlockProps = {
2
3
  block: BuilderBlock;
3
4
  context: BuilderContextInterface;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export type BlockStylesProps = {
2
3
  block: BuilderBlock;
3
4
  context: BuilderContextInterface;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  /**
2
3
  * This import is used by the Svelte SDK. Do not remove.
3
4
  */ type BlockWrapperProps = {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import type { ComponentProps } from "./component-ref.helpers.js";
2
3
  declare function ComponentRef(props: ComponentProps): JSX.Element;
3
4
  export default ComponentRef;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export type InteractiveElementProps = {
2
3
  Wrapper: any;
3
4
  block: BuilderBlock;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  type Props = {
2
3
  block: BuilderBlock;
3
4
  repeatContext: BuilderContextInterface;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export type BlocksWrapperProps = {
2
3
  blocks: BuilderBlock[] | undefined;
3
4
  parent: string | undefined;
@@ -28,7 +28,7 @@ function BlocksWrapper(props) {
28
28
  }
29
29
  }
30
30
  return (React.createElement(React.Fragment, null,
31
- React.createElement("div", { className: className() + " div-b2473120", "builder-path": props.path, "builder-parent-id": props.parent, style: props.styleProp, onClick: (event) => onClick(), onMouseEnter: (event) => onMouseEnter(), onKeyPress: (event) => onClick() }, props.children),
31
+ React.createElement("div", { className: className() + " div-b2473120", "builder-path": props.path, "builder-parent-id": props.parent, ...{}, style: props.styleProp, onClick: (event) => onClick(), onMouseEnter: (event) => onMouseEnter(), onKeyPress: (event) => onClick() }, props.children),
32
32
  React.createElement("style", null, `.div-b2473120 {
33
33
  display: flex;
34
34
  flex-direction: column;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export type BlocksProps = Partial<BlocksWrapperProps> & {
2
3
  context?: BuilderContextInterface;
3
4
  registeredComponents?: RegisteredComponents;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  type BuilderEditorProps = Omit<ContentProps, "customComponents" | "data" | "apiVersion" | "isSsrAbTest"> & {
2
3
  builderContextSignal: BuilderContextInterface;
3
4
  setBuilderContextSignal?: (signal: any) => any;
@@ -260,7 +260,7 @@ function EnableEditor(props) {
260
260
  };
261
261
  }, []);
262
262
  return (React.createElement(builderContext.Provider, { value: props.builderContextSignal }, props.builderContextSignal.content ? (React.createElement(React.Fragment, null,
263
- React.createElement("div", { key: forceReRenderCount, ref: elementRef, onClick: (event) => onClick(event), "builder-content-id": props.builderContextSignal.content?.id, "builder-model": props.model, ...(props.showContent
263
+ React.createElement("div", { key: forceReRenderCount, ref: elementRef, onClick: (event) => onClick(event), "builder-content-id": props.builderContextSignal.content?.id, "builder-model": props.model, ...{}, ...(props.showContent
264
264
  ? {}
265
265
  : {
266
266
  hidden: true,
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  interface Props {
2
3
  cssCode?: string;
3
4
  customFonts?: CustomFont[];
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import type { ContentProps } from "./content.types.js";
2
3
  declare function ContentComponent(props: ContentProps): JSX.Element;
3
4
  export default ContentComponent;
@@ -73,7 +73,9 @@ function ContentComponent(props) {
73
73
  return (React.createElement(ComponentsContext.Provider, { value: {
74
74
  registeredComponents: registeredComponents,
75
75
  } },
76
- React.createElement(EnableEditor, { content: props.content, model: props.model, context: props.context, apiKey: props.apiKey, canTrack: props.canTrack, locale: props.locale, includeRefs: props.includeRefs, enrich: props.enrich, classNameProp: props.classNameProp, showContent: props.showContent, builderContextSignal: builderContextSignal, setBuilderContextSignal: setBuilderContextSignal },
76
+ React.createElement(EnableEditor, { content: props.content, model: props.model, context: props.context, apiKey: props.apiKey, canTrack: props.canTrack, locale: props.locale, includeRefs: props.includeRefs, enrich: props.enrich, classNameProp: props.classNameProp, showContent: props.showContent, builderContextSignal: builderContextSignal, ...{
77
+ setBuilderContextSignal: setBuilderContextSignal,
78
+ } },
77
79
  props.isSsrAbTest ? (React.createElement(React.Fragment, null,
78
80
  React.createElement(InlinedScript, { scriptStr: scriptStr }))) : null,
79
81
  TARGET !== "reactNative" ? (React.createElement(React.Fragment, null,
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  type VariantsProviderProps = ContentVariantsProps & {
2
3
  /**
3
4
  * For internal use only. Do not provide this prop.
@@ -24,6 +24,17 @@ function ContentVariants(props) {
24
24
  .map((value) => `.variant-${value.testVariationId} { display: none; } `)
25
25
  .join("");
26
26
  }
27
+ function defaultContent() {
28
+ return shouldRenderVariants
29
+ ? {
30
+ ...props.content,
31
+ testVariationId: props.content?.id,
32
+ }
33
+ : handleABTestingSync({
34
+ item: props.content,
35
+ canTrack: getDefaultCanTrack(props.canTrack),
36
+ });
37
+ }
27
38
  useEffect(() => {
28
39
  /**
29
40
  * We unmount the non-winning variants post-hydration in Vue.
@@ -36,11 +47,6 @@ function ContentVariants(props) {
36
47
  React.createElement(InlinedStyles, { id: `variants-styles-${props.content?.id}`, styles: hideVariantsStyleString() }),
37
48
  React.createElement(InlinedScript, { scriptStr: variantScriptStr() }),
38
49
  getVariants(props.content)?.map((variant) => (React.createElement(ContentComponent, { key: variant.testVariationId, content: variant, showContent: false, classNameProp: undefined, model: props.model, data: props.data, context: props.context, apiKey: props.apiKey, apiVersion: props.apiVersion, customComponents: props.customComponents, canTrack: props.canTrack, locale: props.locale, includeRefs: props.includeRefs, enrich: props.enrich, isSsrAbTest: shouldRenderVariants }))))) : null,
39
- React.createElement(ContentComponent, { content: shouldRenderVariants
40
- ? props.content
41
- : handleABTestingSync({
42
- item: props.content,
43
- canTrack: getDefaultCanTrack(props.canTrack),
44
- }), classNameProp: `variant-${props.content?.id}`, showContent: true, model: props.model, data: props.data, context: props.context, apiKey: props.apiKey, apiVersion: props.apiVersion, customComponents: props.customComponents, canTrack: props.canTrack, locale: props.locale, includeRefs: props.includeRefs, enrich: props.enrich, isSsrAbTest: shouldRenderVariants })));
50
+ React.createElement(ContentComponent, { ...{}, content: defaultContent(), classNameProp: `variant-${props.content?.id}`, showContent: true, model: props.model, data: props.data, context: props.context, apiKey: props.apiKey, apiVersion: props.apiVersion, customComponents: props.customComponents, canTrack: props.canTrack, locale: props.locale, includeRefs: props.includeRefs, enrich: props.enrich, isSsrAbTest: shouldRenderVariants })));
45
51
  }
46
52
  export default ContentVariants;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  interface Props {
2
3
  scriptStr: string;
3
4
  id?: string;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  interface Props {
2
3
  styles: string;
3
4
  id?: string;
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.5.2";
1
+ export declare const SDK_VERSION = "UNKNOWN_VERSION";
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.5.2";
1
+ export const SDK_VERSION = 'UNKNOWN_VERSION';