@builder.io/sdk-react 0.7.1-1 → 0.7.1

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 (64) hide show
  1. package/lib/browser/index.cjs +26 -26
  2. package/lib/browser/index.mjs +942 -918
  3. package/lib/{node/server-entry-13b7e1e6.mjs → browser/server-entry-0aebe4be.mjs} +261 -261
  4. package/lib/browser/server-entry-a5d2c777.js +2 -0
  5. package/lib/browser/server-entry.cjs +1 -1
  6. package/lib/browser/server-entry.mjs +1 -1
  7. package/lib/edge/index.cjs +34 -34
  8. package/lib/edge/index.mjs +1056 -1032
  9. package/lib/edge/{server-entry-13b7e1e6.mjs → server-entry-0aebe4be.mjs} +261 -261
  10. package/lib/edge/server-entry-a5d2c777.js +2 -0
  11. package/lib/edge/server-entry.cjs +1 -1
  12. package/lib/edge/server-entry.mjs +1 -1
  13. package/lib/node/index.cjs +16 -16
  14. package/lib/node/index.mjs +796 -772
  15. package/lib/node/server-entry-a5d2c777.js +2 -0
  16. package/lib/{browser/server-entry-13b7e1e6.mjs → node/server-entry-e4cd1e05.mjs} +260 -260
  17. package/lib/node/server-entry.cjs +1 -1
  18. package/lib/node/server-entry.mjs +1 -1
  19. package/package.json +2 -2
  20. package/types/blocks/BaseText.d.ts +2 -2
  21. package/types/blocks/button/button.d.ts +4 -3
  22. package/types/blocks/columns/columns.d.ts +2 -2
  23. package/types/blocks/custom-code/custom-code.d.ts +2 -2
  24. package/types/blocks/embed/embed.d.ts +2 -2
  25. package/types/blocks/form/form.d.ts +2 -2
  26. package/types/blocks/fragment/fragment.d.ts +2 -2
  27. package/types/blocks/image/image.d.ts +2 -2
  28. package/types/blocks/img/img.d.ts +4 -3
  29. package/types/blocks/input/input.d.ts +4 -3
  30. package/types/blocks/raw-text/raw-text.d.ts +2 -2
  31. package/types/blocks/section/section.d.ts +4 -3
  32. package/types/blocks/select/select.d.ts +4 -3
  33. package/types/blocks/submit-button/submit-button.d.ts +4 -3
  34. package/types/blocks/symbol/symbol.d.ts +6 -4
  35. package/types/blocks/text/text.d.ts +2 -2
  36. package/types/blocks/textarea/textarea.d.ts +4 -3
  37. package/types/blocks/video/video.d.ts +2 -2
  38. package/types/components/block/block.d.ts +2 -2
  39. package/types/components/block/components/block-styles.d.ts +2 -2
  40. package/types/components/block/components/block-wrapper.d.ts +6 -5
  41. package/types/components/block/components/component-ref/component-ref.d.ts +2 -2
  42. package/types/components/block/components/interactive-element.d.ts +2 -2
  43. package/types/components/block/components/repeated-block.d.ts +2 -2
  44. package/types/components/blocks/blocks-wrapper.d.ts +2 -2
  45. package/types/components/blocks/blocks.d.ts +3 -3
  46. package/types/components/content/components/enable-editor.d.ts +2 -2
  47. package/types/components/content/components/styles.d.ts +2 -2
  48. package/types/components/content/content.d.ts +2 -2
  49. package/types/components/content-variants/content-variants.d.ts +2 -2
  50. package/types/components/inlined-script.d.ts +2 -2
  51. package/types/components/inlined-styles.d.ts +2 -2
  52. package/types/constants/sdk-version.d.ts +1 -1
  53. package/types/context/types.d.ts +1 -1
  54. package/types/functions/evaluate/node-runtime/safeDynamicRequire.d.ts +0 -2
  55. package/types/helpers/ab-tests.d.ts +1 -1
  56. package/types/server-index.d.ts +2 -2
  57. package/lib/browser/server-entry-c98db16c.js +0 -2
  58. package/lib/edge/server-entry-c98db16c.js +0 -2
  59. package/lib/index.cjs +0 -14
  60. package/lib/index.mjs +0 -10
  61. package/lib/node/server-entry-c98db16c.js +0 -2
  62. package/types/node-runtime/index.d.ts +0 -1
  63. package/types/node-runtime/node-runtime.d.ts +0 -1
  64. package/types/node-runtime.d.ts +0 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./server-entry-c98db16c.js");exports._processContentResult=e._processContentResult;exports.createRegisterComponentMessage=e.createRegisterComponentMessage;exports.fetchBuilderProps=e.fetchBuilderProps;exports.fetchEntries=e.fetchEntries;exports.fetchOneEntry=e.fetchOneEntry;exports.getAllContent=e.getAllContent;exports.getBuilderSearchParams=e.getBuilderSearchParams;exports.getContent=e.getContent;exports.isEditing=e.isEditing;exports.isPreviewing=e.isPreviewing;exports.register=e.register;exports.setEditorSettings=e.setEditorSettings;exports.track=e.track;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./server-entry-a5d2c777.js");exports._processContentResult=e._processContentResult;exports.createRegisterComponentMessage=e.createRegisterComponentMessage;exports.fetchBuilderProps=e.fetchBuilderProps;exports.fetchEntries=e.fetchEntries;exports.fetchOneEntry=e.fetchOneEntry;exports.getAllContent=e.getAllContent;exports.getBuilderSearchParams=e.getBuilderSearchParams;exports.getContent=e.getContent;exports.isEditing=e.isEditing;exports.isPreviewing=e.isPreviewing;exports.register=e.register;exports.setEditorSettings=e.setEditorSettings;exports.track=e.track;
@@ -1,4 +1,4 @@
1
- import { _ as t, c as a, h as r, f as i, b as n, g, e as o, d as c, i as d, a as f, r as h, s as l, t as p } from "./server-entry-13b7e1e6.mjs";
1
+ import { _ as t, c as a, h as r, f as i, b as n, g, e as o, d as c, i as d, a as f, r as h, s as l, t as p } from "./server-entry-e4cd1e05.mjs";
2
2
  export {
3
3
  t as _processContentResult,
4
4
  a as createRegisterComponentMessage,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-react",
3
3
  "description": "Builder.io SDK for React",
4
- "version": "0.7.1-1",
4
+ "version": "0.7.1",
5
5
  "files": [
6
6
  "lib",
7
7
  "types"
@@ -88,7 +88,7 @@
88
88
  "require": "./lib/browser/index.cjs"
89
89
  },
90
90
  "./server": {
91
- "types": "./types/functions/get-content/index.d.ts",
91
+ "types": "./types/server-index.d.ts",
92
92
  "import": "./lib/node/server-entry.mjs",
93
93
  "require": "./lib/node/server-entry.cjs"
94
94
  }
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  export interface BaseTextProps {
3
3
  text: string;
4
4
  }
5
- declare function BaseText(props: BaseTextProps): JSX.Element;
5
+ declare function BaseText(props: BaseTextProps): React.JSX.Element;
6
6
  export default BaseText;
@@ -1,11 +1,12 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  /**
3
3
  * This import is used by the Svelte SDK. Do not remove.
4
- */ export interface ButtonProps {
4
+ */
5
+ export interface ButtonProps {
5
6
  attributes?: any;
6
7
  text?: string;
7
8
  link?: string;
8
9
  openLinkInNewTab?: boolean;
9
10
  }
10
- declare function Button(props: ButtonProps): JSX.Element;
11
+ declare function Button(props: ButtonProps): React.JSX.Element;
11
12
  export default Button;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  type Column = {
3
3
  blocks: BuilderBlock[];
4
4
  width?: number;
@@ -13,5 +13,5 @@ export interface ColumnProps extends BuilderComponentsProp {
13
13
  }
14
14
  import type { BuilderBlock } from "../../types/builder-block.js";
15
15
  import type { BuilderComponentsProp, PropsWithBuilderData } from "../../types/builder-props.js";
16
- declare function Columns(props: PropsWithBuilderData<ColumnProps>): JSX.Element;
16
+ declare function Columns(props: PropsWithBuilderData<ColumnProps>): React.JSX.Element;
17
17
  export default Columns;
@@ -1,7 +1,7 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  export interface CustomCodeProps {
3
3
  code: string;
4
4
  replaceNodes?: boolean;
5
5
  }
6
- declare function CustomCode(props: CustomCodeProps): JSX.Element;
6
+ declare function CustomCode(props: CustomCodeProps): React.JSX.Element;
7
7
  export default CustomCode;
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  export interface EmbedProps {
3
3
  content: string;
4
4
  }
5
- declare function Embed(props: EmbedProps): JSX.Element;
5
+ declare function Embed(props: EmbedProps): React.JSX.Element;
6
6
  export default Embed;
@@ -1,3 +1,3 @@
1
- /// <reference types="react" />
2
- declare function FormComponent(props: any): JSX.Element;
1
+ import * as React from "react";
2
+ declare function FormComponent(props: any): React.JSX.Element;
3
3
  export default FormComponent;
@@ -1,8 +1,8 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  export interface FragmentProps {
3
3
  maxWidth?: number;
4
4
  attributes?: any;
5
5
  children?: any;
6
6
  }
7
- declare function FragmentComponent(props: FragmentProps): JSX.Element;
7
+ declare function FragmentComponent(props: FragmentProps): React.JSX.Element;
8
8
  export default FragmentComponent;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  export interface ImageProps {
3
3
  className?: string;
4
4
  image: string;
@@ -18,5 +18,5 @@ export interface ImageProps {
18
18
  src?: string;
19
19
  }
20
20
  import type { BuilderBlock } from "../../types/builder-block.js";
21
- declare function Image(props: ImageProps): JSX.Element;
21
+ declare function Image(props: ImageProps): React.JSX.Element;
22
22
  export default Image;
@@ -1,7 +1,8 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  /**
3
3
  * This import is used by the Svelte SDK. Do not remove.
4
- */ export interface ImgProps {
4
+ */
5
+ export interface ImgProps {
5
6
  attributes?: any;
6
7
  imgSrc?: string;
7
8
  image?: string;
@@ -9,5 +10,5 @@
9
10
  backgroundSize?: "cover" | "contain";
10
11
  backgroundPosition?: "center" | "top" | "left" | "right" | "bottom" | "top left" | "top right" | "bottom left" | "bottom right";
11
12
  }
12
- declare function ImgComponent(props: ImgProps): JSX.Element;
13
+ declare function ImgComponent(props: ImgProps): React.JSX.Element;
13
14
  export default ImgComponent;
@@ -1,7 +1,8 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  /**
3
3
  * This import is used by the Svelte SDK. Do not remove.
4
- */ export interface FormInputProps {
4
+ */
5
+ export interface FormInputProps {
5
6
  type?: string;
6
7
  attributes?: any;
7
8
  name?: string;
@@ -10,5 +11,5 @@
10
11
  defaultValue?: string;
11
12
  required?: boolean;
12
13
  }
13
- declare function FormInputComponent(props: FormInputProps): JSX.Element;
14
+ declare function FormInputComponent(props: FormInputProps): React.JSX.Element;
14
15
  export default FormInputComponent;
@@ -1,7 +1,7 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  export interface RawTextProps {
3
3
  attributes?: any;
4
4
  text?: string;
5
5
  }
6
- declare function RawText(props: RawTextProps): JSX.Element;
6
+ declare function RawText(props: RawTextProps): React.JSX.Element;
7
7
  export default RawText;
@@ -1,11 +1,12 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  /**
3
3
  * This import is used by the Svelte SDK. Do not remove.
4
- */ export interface SectionProps {
4
+ */
5
+ export interface SectionProps {
5
6
  maxWidth?: number;
6
7
  attributes?: any;
7
8
  children?: any;
8
9
  builderBlock?: any;
9
10
  }
10
- declare function SectionComponent(props: SectionProps): JSX.Element;
11
+ declare function SectionComponent(props: SectionProps): React.JSX.Element;
11
12
  export default SectionComponent;
@@ -1,7 +1,8 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  /**
3
3
  * This import is used by the Svelte SDK. Do not remove.
4
- */ export interface FormSelectProps {
4
+ */
5
+ export interface FormSelectProps {
5
6
  options?: {
6
7
  name?: string;
7
8
  value: string;
@@ -11,5 +12,5 @@
11
12
  value?: string;
12
13
  defaultValue?: string;
13
14
  }
14
- declare function SelectComponent(props: FormSelectProps): JSX.Element;
15
+ declare function SelectComponent(props: FormSelectProps): React.JSX.Element;
15
16
  export default SelectComponent;
@@ -1,9 +1,10 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  /**
3
3
  * This import is used by the Svelte SDK. Do not remove.
4
- */ export interface ButtonProps {
4
+ */
5
+ export interface ButtonProps {
5
6
  attributes?: any;
6
7
  text?: string;
7
8
  }
8
- declare function SubmitButton(props: ButtonProps): JSX.Element;
9
+ declare function SubmitButton(props: ButtonProps): React.JSX.Element;
9
10
  export default SubmitButton;
@@ -1,7 +1,8 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  /**
3
3
  * This import is used by the Svelte SDK. Do not remove.
4
- */ export interface SymbolInfo {
4
+ */
5
+ export interface SymbolInfo {
5
6
  model?: string;
6
7
  entry?: string;
7
8
  data?: any;
@@ -11,7 +12,8 @@
11
12
  }
12
13
  /**
13
14
  * This import is used by the Svelte SDK. Do not remove.
14
- */ export interface SymbolProps extends BuilderComponentsProp {
15
+ */
16
+ export interface SymbolProps extends BuilderComponentsProp {
15
17
  symbol?: SymbolInfo;
16
18
  dataOnly?: boolean;
17
19
  dynamic?: boolean;
@@ -20,5 +22,5 @@
20
22
  }
21
23
  import type { BuilderContent } from "../../types/builder-content.js";
22
24
  import type { BuilderComponentsProp, PropsWithBuilderData } from "../../types/builder-props.js";
23
- declare function Symbol(props: PropsWithBuilderData<SymbolProps>): JSX.Element;
25
+ declare function Symbol(props: PropsWithBuilderData<SymbolProps>): React.JSX.Element;
24
26
  export default Symbol;
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  export interface TextProps {
3
3
  text?: string;
4
4
  }
5
- declare function Text(props: TextProps): JSX.Element;
5
+ declare function Text(props: TextProps): React.JSX.Element;
6
6
  export default Text;
@@ -1,12 +1,13 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  /**
3
3
  * This import is used by the Svelte SDK. Do not remove.
4
- */ export interface TextareaProps {
4
+ */
5
+ export interface TextareaProps {
5
6
  attributes?: any;
6
7
  name?: string;
7
8
  value?: string;
8
9
  defaultValue?: string;
9
10
  placeholder?: string;
10
11
  }
11
- declare function Textarea(props: TextareaProps): JSX.Element;
12
+ declare function Textarea(props: TextareaProps): React.JSX.Element;
12
13
  export default Textarea;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  export interface VideoProps {
3
3
  attributes?: any;
4
4
  video?: string;
@@ -16,5 +16,5 @@ export interface VideoProps {
16
16
  posterImage?: string;
17
17
  lazyLoad?: boolean;
18
18
  }
19
- declare function Video(props: VideoProps): JSX.Element;
19
+ declare function Video(props: VideoProps): React.JSX.Element;
20
20
  export default Video;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  export type BlockProps = {
3
3
  block: BuilderBlock;
4
4
  context: BuilderContextInterface;
@@ -6,5 +6,5 @@ export type BlockProps = {
6
6
  };
7
7
  import type { BuilderContextInterface, RegisteredComponents } from "../../context/types.js";
8
8
  import type { BuilderBlock } from "../../types/builder-block.js";
9
- declare function Block(props: BlockProps): JSX.Element;
9
+ declare function Block(props: BlockProps): React.JSX.Element;
10
10
  export default Block;
@@ -1,9 +1,9 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  export type BlockStylesProps = {
3
3
  block: BuilderBlock;
4
4
  context: BuilderContextInterface;
5
5
  };
6
6
  import type { BuilderContextInterface } from "../../../context/types.js";
7
7
  import type { BuilderBlock } from "../../../types/builder-block.js";
8
- declare function BlockStyles(props: BlockStylesProps): JSX.Element;
8
+ declare function BlockStyles(props: BlockStylesProps): React.JSX.Element;
9
9
  export default BlockStyles;
@@ -1,7 +1,8 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  /**
3
3
  * This import is used by the Svelte SDK. Do not remove.
4
- */ type BlockWrapperProps = {
4
+ */
5
+ type BlockWrapperProps = {
5
6
  Wrapper: string;
6
7
  block: BuilderBlock;
7
8
  context: BuilderContextInterface;
@@ -10,8 +11,8 @@
10
11
  /**
11
12
  * This component renders a block's wrapper HTML element (from the block's `tagName` property).
12
13
  * It reuses the exact same logic as the `InteractiveElement` component, but we need to have 2 separate components for
13
- * Svelte's sake, as it needs to know at compile-time whether to use: * - `<svelte:element>` (for HTML element) or * - `<svelte:component>` (for custom components) */ import type { PropsWithChildren } from "../../../types/typescript.js";
14
+ * Svelte's sake, as it needs to know at compile-time whether to use: * - `<svelte:element>` (for HTML element) or * - `<svelte:component>` (for custom components) */ import type { BuilderContextInterface } from "../../../context/types.js";
14
15
  import type { BuilderBlock } from "../../../types/builder-block.js";
15
- import type { BuilderContextInterface } from "../../../context/types.js";
16
- declare function BlockWrapper(props: PropsWithChildren<BlockWrapperProps>): JSX.Element;
16
+ import type { PropsWithChildren } from "../../../types/typescript.js";
17
+ declare function BlockWrapper(props: PropsWithChildren<BlockWrapperProps>): React.JSX.Element;
17
18
  export default BlockWrapper;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  import type { ComponentProps } from "./component-ref.helpers.js";
3
- declare function ComponentRef(props: ComponentProps): JSX.Element;
3
+ declare function ComponentRef(props: ComponentProps): React.JSX.Element;
4
4
  export default ComponentRef;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  export type InteractiveElementProps = {
3
3
  Wrapper: any;
4
4
  block: BuilderBlock;
@@ -8,5 +8,5 @@ export type InteractiveElementProps = {
8
8
  import type { BuilderContextInterface } from "../../../context/types.js";
9
9
  import type { BuilderBlock } from "../../../types/builder-block.js";
10
10
  import type { PropsWithChildren } from "../../../types/typescript.js";
11
- declare function InteractiveElement(props: PropsWithChildren<InteractiveElementProps>): JSX.Element;
11
+ declare function InteractiveElement(props: PropsWithChildren<InteractiveElementProps>): React.JSX.Element;
12
12
  export default InteractiveElement;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  type Props = {
3
3
  block: BuilderBlock;
4
4
  repeatContext: BuilderContextInterface;
@@ -6,5 +6,5 @@ type Props = {
6
6
  };
7
7
  import type { BuilderContextInterface, RegisteredComponents } from "../../../context/types.js";
8
8
  import type { BuilderBlock } from "../../../types/builder-block.js";
9
- declare function RepeatedBlock(props: Props): JSX.Element;
9
+ declare function RepeatedBlock(props: Props): React.JSX.Element;
10
10
  export default RepeatedBlock;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  export type BlocksWrapperProps = {
3
3
  blocks: BuilderBlock[] | undefined;
4
4
  parent: string | undefined;
@@ -7,5 +7,5 @@ export type BlocksWrapperProps = {
7
7
  };
8
8
  import type { BuilderBlock } from "../../types/builder-block.js";
9
9
  import type { PropsWithChildren } from "../../types/typescript.js";
10
- declare function BlocksWrapper(props: PropsWithChildren<BlocksWrapperProps>): JSX.Element;
10
+ declare function BlocksWrapper(props: PropsWithChildren<BlocksWrapperProps>): React.JSX.Element;
11
11
  export default BlocksWrapper;
@@ -1,9 +1,9 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  export type BlocksProps = Partial<BlocksWrapperProps> & {
3
3
  context?: BuilderContextInterface;
4
4
  registeredComponents?: RegisteredComponents;
5
5
  };
6
- import type { BlocksWrapperProps } from "./blocks-wrapper";
7
6
  import type { BuilderContextInterface, RegisteredComponents } from "../../context/types.js";
8
- declare function Blocks(props: BlocksProps): JSX.Element;
7
+ import type { BlocksWrapperProps } from "./blocks-wrapper";
8
+ declare function Blocks(props: BlocksProps): React.JSX.Element;
9
9
  export default Blocks;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  type BuilderEditorProps = Omit<ContentProps, "customComponents" | "data" | "apiVersion" | "isSsrAbTest"> & {
3
3
  builderContextSignal: BuilderContextInterface;
4
4
  setBuilderContextSignal?: (signal: any) => any;
@@ -6,5 +6,5 @@ type BuilderEditorProps = Omit<ContentProps, "customComponents" | "data" | "apiV
6
6
  };
7
7
  import type { BuilderContextInterface } from "../../../context/types.js";
8
8
  import type { ContentProps } from "../content.types.js";
9
- declare function EnableEditor(props: BuilderEditorProps): JSX.Element;
9
+ declare function EnableEditor(props: BuilderEditorProps): React.JSX.Element;
10
10
  export default EnableEditor;
@@ -1,9 +1,9 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  interface Props {
3
3
  cssCode?: string;
4
4
  customFonts?: CustomFont[];
5
5
  contentId?: string;
6
6
  }
7
7
  import type { CustomFont } from "./styles.helpers.js";
8
- declare function ContentStyles(props: Props): JSX.Element;
8
+ declare function ContentStyles(props: Props): React.JSX.Element;
9
9
  export default ContentStyles;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  import type { ContentProps } from "./content.types.js";
3
- declare function ContentComponent(props: ContentProps): JSX.Element;
3
+ declare function ContentComponent(props: ContentProps): React.JSX.Element;
4
4
  export default ContentComponent;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  type VariantsProviderProps = ContentVariantsPrps & {
3
3
  /**
4
4
  * For internal use only. Do not provide this prop.
@@ -6,5 +6,5 @@ type VariantsProviderProps = ContentVariantsPrps & {
6
6
  __isNestedRender?: boolean;
7
7
  };
8
8
  import type { ContentVariantsPrps } from "./content-variants.types.js";
9
- declare function ContentVariants(props: VariantsProviderProps): JSX.Element;
9
+ declare function ContentVariants(props: VariantsProviderProps): React.JSX.Element;
10
10
  export default ContentVariants;
@@ -1,7 +1,7 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  interface Props {
3
3
  scriptStr: string;
4
4
  id?: string;
5
5
  }
6
- declare function InlinedScript(props: Props): JSX.Element;
6
+ declare function InlinedScript(props: Props): React.JSX.Element;
7
7
  export default InlinedScript;
@@ -1,7 +1,7 @@
1
- /// <reference types="react" />
1
+ import * as React from "react";
2
2
  interface Props {
3
3
  styles: string;
4
4
  id?: string;
5
5
  }
6
- declare function InlinedStyles(props: Props): JSX.Element;
6
+ declare function InlinedStyles(props: Props): React.JSX.Element;
7
7
  export default InlinedStyles;
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.7.1-1";
1
+ export declare const SDK_VERSION = "0.7.1";
@@ -1,7 +1,7 @@
1
+ import type { ApiVersion } from '../types/api-version.js';
1
2
  import type { BuilderContent } from '../types/builder-content.js';
2
3
  import type { ComponentInfo } from '../types/components.js';
3
4
  import type { Dictionary, Nullable } from '../types/typescript.js';
4
- import type { ApiVersion } from '../types/api-version.js';
5
5
  export type RegisteredComponent = ComponentInfo & {
6
6
  component: any;
7
7
  };
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="react-native" />
3
1
  /**
4
2
  * Allows us to require node-specific code safely within bundlers.
5
3
  *
@@ -1,5 +1,5 @@
1
- import type { CanTrack } from '../types/can-track.js';
2
1
  import type { BuilderContent } from '../types/builder-content.js';
2
+ import type { CanTrack } from '../types/can-track.js';
3
3
  import type { Nullable } from '../types/typescript.js';
4
4
  export declare const handleABTestingSync: ({ item, canTrack }: {
5
5
  item: Nullable<BuilderContent>;
@@ -6,10 +6,10 @@ export { register } from './functions/register.js';
6
6
  export type { InsertMenuConfig, InsertMenuItem } from './functions/register.js';
7
7
  export { setEditorSettings } from './functions/set-editor-settings.js';
8
8
  export type { Settings } from './functions/set-editor-settings.js';
9
- export { fetchEntries, fetchOneEntry, getAllContent, getContent, _processContentResult } from './functions/get-content/index.js';
9
+ export { _processContentResult, fetchEntries, fetchOneEntry, getAllContent, getContent } from './functions/get-content/index.js';
10
10
  export { getBuilderSearchParams } from './functions/get-builder-search-params/index.js';
11
11
  export { track } from './functions/track/index.js';
12
+ export type { ContentProps } from './components/content/content.types.js';
12
13
  export type { RegisteredComponent } from './context/types.js';
13
14
  export type { ComponentInfo } from './types/components.js';
14
- export type { ContentProps } from './components/content/content.types.js';
15
15
  export { fetchBuilderProps } from './functions/fetch-builder-props.js';
@@ -1,2 +0,0 @@
1
- "use strict";const v=t=>JSON.parse(JSON.stringify(t)),p="react",h="[Builder.io]: ",l={log:(...t)=>console.log(h,...t),error:(...t)=>console.error(h,...t),warn:(...t)=>console.warn(h,...t),debug:(...t)=>console.debug(h,...t)};function a(){return typeof window<"u"&&typeof document<"u"}function rt(){return a()&&window.self!==window.top}function I(){return rt()&&window.location.search.indexOf("builder.frameEditing=")!==-1}const ot=()=>{if(a()){const t=new URL(location.href);return t.pathname===""&&(t.pathname="/"),t}else return console.warn("Cannot get location for tracking in non-browser environment"),null},st=()=>typeof navigator=="object"&&navigator.userAgent||"",U=()=>{const t=st(),e={Android(){return t.match(/Android/i)},BlackBerry(){return t.match(/BlackBerry/i)},iOS(){return t.match(/iPhone|iPod/i)},Opera(){return t.match(/Opera Mini/i)},Windows(){return t.match(/IEMobile/i)||t.match(/WPDesktop/i)},any(){return e.Android()||e.BlackBerry()||e.iOS()||e.Opera()||e.Windows()||p==="reactNative"}},n=t.match(/Tablet|iPad/i),r=ot();return{urlPath:r==null?void 0:r.pathname,host:(r==null?void 0:r.host)||(r==null?void 0:r.hostname),device:n?"tablet":e.any()?"mobile":"desktop"}},d=t=>t!=null,it=[],at=t=>({type:"builder.registerComponent",data:F(t)}),ct=t=>{const e=t.toString().trim();return`return (${!e.startsWith("function")&&!e.startsWith("(")?"function ":""}${e}).apply(this, arguments)`},ut=t=>typeof t=="function"?ct(t):v(t),F=({inputs:t,...e})=>({...v(e),inputs:t==null?void 0:t.map(n=>Object.entries(n).reduce((r,[o,s])=>({...r,[o]:ut(s)}),{}))});function lt(){return typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:globalThis}function dt(){const t=lt().fetch;if(typeof t>"u")throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
2
- For more information, read https://github.com/BuilderIO/this-package-uses-fetch`),new Error("Builder SDK could not find a global `fetch` function");return t}const M=dt(),ft=t=>{if(t==="localhost"||t==="127.0.0.1")return t;const e=t.split(".");return e.length>2?e.slice(1).join("."):t},D=({name:t,canTrack:e})=>{var n;try{return e?(n=document.cookie.split("; ").find(r=>r.startsWith(`${t}=`)))==null?void 0:n.split("=")[1]:void 0}catch(r){l.warn("[COOKIE] GET error: ",(r==null?void 0:r.message)||r);return}},K=async t=>D(t),ht=t=>t.map(([e,n])=>n?`${e}=${n}`:e).filter(d).join("; "),gt=[["secure",""],["SameSite","None"]],pt=({name:t,value:e,expires:n})=>{const o=(a()?location.protocol==="https:":!0)?gt:[[]],s=n?[["expires",n.toUTCString()]]:[[]],c=[[t,e],...s,["path","/"],["domain",ft(window.location.hostname)],...o];return ht(c)},_=async({name:t,value:e,expires:n,canTrack:r})=>{try{if(!r)return;const o=pt({name:t,value:e,expires:n});document.cookie=o}catch(o){l.warn("[COOKIE] SET error: ",(o==null?void 0:o.message)||o)}};function yt(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=Math.random()*16|0;return(t=="x"?e:e&3|8).toString(16)})}function G(){return yt().replace(/-/g,"")}const W="builderSessionId",mt=async({canTrack:t})=>{if(!t)return;const e=await K({name:W,canTrack:t});if(d(e))return e;{const n=St();return wt({id:n,canTrack:t}),n}},St=()=>G(),wt=({id:t,canTrack:e})=>_({name:W,value:t,canTrack:e}),J=()=>a()&&typeof localStorage<"u"?localStorage:void 0,bt=({key:t,canTrack:e})=>{var n;try{return e?(n=J())==null?void 0:n.getItem(t):void 0}catch(r){console.debug("[LocalStorage] GET error: ",r);return}},vt=({key:t,canTrack:e,value:n})=>{var r;try{e&&((r=J())==null||r.setItem(t,n))}catch(o){console.debug("[LocalStorage] SET error: ",o)}},z="builderVisitorId",It=({canTrack:t})=>{if(!t)return;const e=bt({key:z,canTrack:t});if(d(e))return e;{const n=Ct();return kt({id:n,canTrack:t}),n}},Ct=()=>G(),kt=({id:t,canTrack:e})=>vt({key:z,value:t,canTrack:e}),Et=async({canTrack:t})=>{if(!t)return{visitorId:void 0,sessionId:void 0};const e=await mt({canTrack:t}),n=It({canTrack:t});return{sessionId:e,visitorId:n}},Ot=async({type:t,canTrack:e,apiKey:n,metadata:r,...o})=>({type:t,data:{...o,metadata:{url:location.href,...r},...await Et({canTrack:e}),userAttributes:U(),ownerId:n}});async function X(t){if(!t.apiKey){l.error("Missing API key for track call. Please provide your API key.");return}if(t.canTrack&&!I()&&(a()||p==="reactNative"))return fetch("https://cdn.builder.io/api/v1/track",{method:"POST",body:JSON.stringify({events:[await Ot(t)]}),headers:{"content-type":"application/json"},mode:"cors"}).catch(e=>{console.error("Failed to track: ",e)})}const Pt=t=>X({...t,canTrack:!0}),L={};function At(t,e){let n=L[t];if(n||(n=L[t]=[]),n.push(e),a()){const r={type:"builder.register",data:{type:t,info:e}};try{parent.postMessage(r,"*"),parent!==window&&window.postMessage(r,"*")}catch(o){console.debug("Could not postmessage",o)}}}const xt="builder.tests",C=t=>`${xt}.${t}`,Tt=({contentId:t})=>K({name:C(t),canTrack:!0}),Rt=({contentId:t})=>D({name:C(t),canTrack:!0}),Bt=({contentId:t,value:e})=>_({name:C(t),value:e,canTrack:!0}),q=t=>d(t.id)&&d(t.variations)&&Object.keys(t.variations).length>0,Vt=({id:t,variations:e})=>{var o;let n=0;const r=Math.random();for(const s in e){const c=(o=e[s])==null?void 0:o.testRatio;if(n+=c,r<n)return s}return t},H=t=>{const e=Vt(t);return Bt({contentId:t.id,value:e}).catch(n=>{l.error("could not store A/B test variation: ",n)}),e},Y=({item:t,testGroupId:e})=>{const n=t.variations[e];return e===t.id||!n?{testVariationId:t.id,testVariationName:"Default"}:{data:n.data,testVariationId:n.id,testVariationName:n.name||(n.id===t.id?"Default":"")}},Lt=({item:t,canTrack:e})=>{if(!e)return t;if(!t)return;if(!q(t))return t;const n=Rt({contentId:t.id})||H({variations:t.variations,id:t.id}),r=Y({item:t,testGroupId:n});return{...t,...r}},Nt=async({item:t,canTrack:e})=>{if(!e||!q(t))return t;const r=await Tt({contentId:t.id})||H({variations:t.variations,id:t.id}),o=Y({item:t,testGroupId:r});return{...t,...o}},Q=t=>d(t)?t:!0;function g(t,e=null,n="."){return Object.keys(t).reduce((r,o)=>{const s=t[o],c=[e,o].filter(Boolean).join(n);return[typeof s=="object",s!==null,!(Array.isArray(s)&&s.length===0)].every(Boolean)?{...r,...g(s,c,n)}:{...r,[c]:s}},{})}const N="builder.",$t="options.",jt=t=>{const e={};return t.forEach((n,r)=>{e[r]=n}),e},k=t=>{if(!t)return{};const e=Z(t),n={};return Object.keys(e).forEach(r=>{if(r.startsWith(N)){const o=r.replace(N,"").replace($t,"");n[o]=e[r]}}),n},Ut=()=>{if(!a())return{};const t=new URLSearchParams(window.location.search);return k(t)},Z=t=>t instanceof URLSearchParams?jt(t):t,Ft="v3",$=t=>typeof t=="number"&&!isNaN(t)&&t>=0,E=t=>{let{noTraverse:e=!1}=t;const{limit:n=30,userAttributes:r,query:o,model:s,apiKey:c,includeRefs:y=!0,enrich:A,locale:x,apiVersion:m=Ft,fields:T,omit:et,offset:S,cacheSeconds:w,staleCacheSeconds:b,sort:R,includeUnpublished:B}=t;if(!c)throw new Error("Missing API key");if(!["v2","v3"].includes(m))throw new Error(`Invalid apiVersion: expected 'v2' or 'v3', received '${m}'`);(t.limit===void 0||t.limit>1)&&!("noTraverse"in t)&&(e=!0);const i=new URL(`https://cdn.builder.io/api/${m}/content/${s}?apiKey=${c}&limit=${n}&noTraverse=${e}&includeRefs=${y}${x?`&locale=${x}`:""}${A?`&enrich=${A}`:""}`);if(i.searchParams.set("omit",et||"meta.componentsUsed"),T&&i.searchParams.set("fields",T),Number.isFinite(S)&&S>-1&&i.searchParams.set("offset",String(Math.floor(S))),typeof B=="boolean"&&i.searchParams.set("includeUnpublished",String(B)),w&&$(w)&&i.searchParams.set("cacheSeconds",String(w)),b&&$(b)&&i.searchParams.set("staleCacheSeconds",String(b)),R){const u=g({sort:R});for(const f in u)i.searchParams.set(f,JSON.stringify(u[f]))}const nt={...Ut(),...Z(t.options||{})},V=g(nt);for(const u in V)i.searchParams.set(u,String(V[u]));if(r&&i.searchParams.set("userAttributes",JSON.stringify(r)),o){const u=g({query:o});for(const f in u)i.searchParams.set(f,JSON.stringify(u[f]))}return i},Mt=t=>"results"in t;async function O(t){const e=await P({...t,limit:1});return e&&e.results[0]||null}const Dt=O,Kt=async t=>{const e=E(t);return await(await M(e.href)).json()},tt=async(t,e,n=E(t))=>{const r=Q(t.canTrack);if(n.search.includes("preview="),!r||!(a()||p==="reactNative"))return e;try{const o=[];for(const s of e.results)o.push(await Nt({item:s,canTrack:r}));e.results=o}catch(o){l.error("Could not process A/B tests. ",o)}return e};async function P(t){try{const e=E(t),n=await Kt(t);return Mt(n)?tt(t,n):(l.error("Error fetching data. ",{url:e,content:n,options:t}),null)}catch(e){return l.error("Error fetching data. ",e),null}}const _t=P;function Gt(){return!a()||I()?!1:location.search.indexOf("builder.preview=")!==-1}const j={};function Wt(t){if(a()){Object.assign(j,t);const e={type:"builder.settingsChange",data:j};parent.postMessage(e,"*")}}const Jt=async t=>{var r,o,s;const e=t.path||((r=t.url)==null?void 0:r.pathname)||((o=t.userAttributes)==null?void 0:o.urlPath),n={...t,apiKey:t.apiKey,model:t.model||"page",userAttributes:{...t.userAttributes,...e?{urlPath:e}:{}},options:k(t.searchParams||((s=t.url)==null?void 0:s.searchParams)||t.options)};return{apiKey:n.apiKey,model:n.model,content:await O(n)}};exports.TARGET=p;exports._processContentResult=tt;exports._track=X;exports.checkIsDefined=d;exports.components=it;exports.createRegisterComponentMessage=at;exports.fastClone=v;exports.fetch=M;exports.fetchBuilderProps=Jt;exports.fetchEntries=P;exports.fetchOneEntry=O;exports.getAllContent=_t;exports.getBuilderSearchParams=k;exports.getContent=Dt;exports.getDefaultCanTrack=Q;exports.getUserAttributes=U;exports.handleABTestingSync=Lt;exports.isBrowser=a;exports.isEditing=I;exports.isPreviewing=Gt;exports.logger=l;exports.register=At;exports.serializeComponentInfo=F;exports.setEditorSettings=Wt;exports.track=Pt;
@@ -1,2 +0,0 @@
1
- "use strict";const v=t=>JSON.parse(JSON.stringify(t)),p="react",h="[Builder.io]: ",l={log:(...t)=>console.log(h,...t),error:(...t)=>console.error(h,...t),warn:(...t)=>console.warn(h,...t),debug:(...t)=>console.debug(h,...t)};function a(){return typeof window<"u"&&typeof document<"u"}function rt(){return a()&&window.self!==window.top}function I(){return rt()&&window.location.search.indexOf("builder.frameEditing=")!==-1}const ot=()=>{if(a()){const t=new URL(location.href);return t.pathname===""&&(t.pathname="/"),t}else return console.warn("Cannot get location for tracking in non-browser environment"),null},st=()=>typeof navigator=="object"&&navigator.userAgent||"",U=()=>{const t=st(),e={Android(){return t.match(/Android/i)},BlackBerry(){return t.match(/BlackBerry/i)},iOS(){return t.match(/iPhone|iPod/i)},Opera(){return t.match(/Opera Mini/i)},Windows(){return t.match(/IEMobile/i)||t.match(/WPDesktop/i)},any(){return e.Android()||e.BlackBerry()||e.iOS()||e.Opera()||e.Windows()||p==="reactNative"}},n=t.match(/Tablet|iPad/i),r=ot();return{urlPath:r==null?void 0:r.pathname,host:(r==null?void 0:r.host)||(r==null?void 0:r.hostname),device:n?"tablet":e.any()?"mobile":"desktop"}},d=t=>t!=null,it=[],at=t=>({type:"builder.registerComponent",data:F(t)}),ct=t=>{const e=t.toString().trim();return`return (${!e.startsWith("function")&&!e.startsWith("(")?"function ":""}${e}).apply(this, arguments)`},ut=t=>typeof t=="function"?ct(t):v(t),F=({inputs:t,...e})=>({...v(e),inputs:t==null?void 0:t.map(n=>Object.entries(n).reduce((r,[o,s])=>({...r,[o]:ut(s)}),{}))});function lt(){return typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:globalThis}function dt(){const t=lt().fetch;if(typeof t>"u")throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
2
- For more information, read https://github.com/BuilderIO/this-package-uses-fetch`),new Error("Builder SDK could not find a global `fetch` function");return t}const M=dt(),ft=t=>{if(t==="localhost"||t==="127.0.0.1")return t;const e=t.split(".");return e.length>2?e.slice(1).join("."):t},D=({name:t,canTrack:e})=>{var n;try{return e?(n=document.cookie.split("; ").find(r=>r.startsWith(`${t}=`)))==null?void 0:n.split("=")[1]:void 0}catch(r){l.warn("[COOKIE] GET error: ",(r==null?void 0:r.message)||r);return}},K=async t=>D(t),ht=t=>t.map(([e,n])=>n?`${e}=${n}`:e).filter(d).join("; "),gt=[["secure",""],["SameSite","None"]],pt=({name:t,value:e,expires:n})=>{const o=(a()?location.protocol==="https:":!0)?gt:[[]],s=n?[["expires",n.toUTCString()]]:[[]],c=[[t,e],...s,["path","/"],["domain",ft(window.location.hostname)],...o];return ht(c)},_=async({name:t,value:e,expires:n,canTrack:r})=>{try{if(!r)return;const o=pt({name:t,value:e,expires:n});document.cookie=o}catch(o){l.warn("[COOKIE] SET error: ",(o==null?void 0:o.message)||o)}};function yt(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=Math.random()*16|0;return(t=="x"?e:e&3|8).toString(16)})}function G(){return yt().replace(/-/g,"")}const W="builderSessionId",mt=async({canTrack:t})=>{if(!t)return;const e=await K({name:W,canTrack:t});if(d(e))return e;{const n=St();return wt({id:n,canTrack:t}),n}},St=()=>G(),wt=({id:t,canTrack:e})=>_({name:W,value:t,canTrack:e}),J=()=>a()&&typeof localStorage<"u"?localStorage:void 0,bt=({key:t,canTrack:e})=>{var n;try{return e?(n=J())==null?void 0:n.getItem(t):void 0}catch(r){console.debug("[LocalStorage] GET error: ",r);return}},vt=({key:t,canTrack:e,value:n})=>{var r;try{e&&((r=J())==null||r.setItem(t,n))}catch(o){console.debug("[LocalStorage] SET error: ",o)}},z="builderVisitorId",It=({canTrack:t})=>{if(!t)return;const e=bt({key:z,canTrack:t});if(d(e))return e;{const n=Ct();return kt({id:n,canTrack:t}),n}},Ct=()=>G(),kt=({id:t,canTrack:e})=>vt({key:z,value:t,canTrack:e}),Et=async({canTrack:t})=>{if(!t)return{visitorId:void 0,sessionId:void 0};const e=await mt({canTrack:t}),n=It({canTrack:t});return{sessionId:e,visitorId:n}},Ot=async({type:t,canTrack:e,apiKey:n,metadata:r,...o})=>({type:t,data:{...o,metadata:{url:location.href,...r},...await Et({canTrack:e}),userAttributes:U(),ownerId:n}});async function X(t){if(!t.apiKey){l.error("Missing API key for track call. Please provide your API key.");return}if(t.canTrack&&!I()&&(a()||p==="reactNative"))return fetch("https://cdn.builder.io/api/v1/track",{method:"POST",body:JSON.stringify({events:[await Ot(t)]}),headers:{"content-type":"application/json"},mode:"cors"}).catch(e=>{console.error("Failed to track: ",e)})}const Pt=t=>X({...t,canTrack:!0}),L={};function At(t,e){let n=L[t];if(n||(n=L[t]=[]),n.push(e),a()){const r={type:"builder.register",data:{type:t,info:e}};try{parent.postMessage(r,"*"),parent!==window&&window.postMessage(r,"*")}catch(o){console.debug("Could not postmessage",o)}}}const xt="builder.tests",C=t=>`${xt}.${t}`,Tt=({contentId:t})=>K({name:C(t),canTrack:!0}),Rt=({contentId:t})=>D({name:C(t),canTrack:!0}),Bt=({contentId:t,value:e})=>_({name:C(t),value:e,canTrack:!0}),q=t=>d(t.id)&&d(t.variations)&&Object.keys(t.variations).length>0,Vt=({id:t,variations:e})=>{var o;let n=0;const r=Math.random();for(const s in e){const c=(o=e[s])==null?void 0:o.testRatio;if(n+=c,r<n)return s}return t},H=t=>{const e=Vt(t);return Bt({contentId:t.id,value:e}).catch(n=>{l.error("could not store A/B test variation: ",n)}),e},Y=({item:t,testGroupId:e})=>{const n=t.variations[e];return e===t.id||!n?{testVariationId:t.id,testVariationName:"Default"}:{data:n.data,testVariationId:n.id,testVariationName:n.name||(n.id===t.id?"Default":"")}},Lt=({item:t,canTrack:e})=>{if(!e)return t;if(!t)return;if(!q(t))return t;const n=Rt({contentId:t.id})||H({variations:t.variations,id:t.id}),r=Y({item:t,testGroupId:n});return{...t,...r}},Nt=async({item:t,canTrack:e})=>{if(!e||!q(t))return t;const r=await Tt({contentId:t.id})||H({variations:t.variations,id:t.id}),o=Y({item:t,testGroupId:r});return{...t,...o}},Q=t=>d(t)?t:!0;function g(t,e=null,n="."){return Object.keys(t).reduce((r,o)=>{const s=t[o],c=[e,o].filter(Boolean).join(n);return[typeof s=="object",s!==null,!(Array.isArray(s)&&s.length===0)].every(Boolean)?{...r,...g(s,c,n)}:{...r,[c]:s}},{})}const N="builder.",$t="options.",jt=t=>{const e={};return t.forEach((n,r)=>{e[r]=n}),e},k=t=>{if(!t)return{};const e=Z(t),n={};return Object.keys(e).forEach(r=>{if(r.startsWith(N)){const o=r.replace(N,"").replace($t,"");n[o]=e[r]}}),n},Ut=()=>{if(!a())return{};const t=new URLSearchParams(window.location.search);return k(t)},Z=t=>t instanceof URLSearchParams?jt(t):t,Ft="v3",$=t=>typeof t=="number"&&!isNaN(t)&&t>=0,E=t=>{let{noTraverse:e=!1}=t;const{limit:n=30,userAttributes:r,query:o,model:s,apiKey:c,includeRefs:y=!0,enrich:A,locale:x,apiVersion:m=Ft,fields:T,omit:et,offset:S,cacheSeconds:w,staleCacheSeconds:b,sort:R,includeUnpublished:B}=t;if(!c)throw new Error("Missing API key");if(!["v2","v3"].includes(m))throw new Error(`Invalid apiVersion: expected 'v2' or 'v3', received '${m}'`);(t.limit===void 0||t.limit>1)&&!("noTraverse"in t)&&(e=!0);const i=new URL(`https://cdn.builder.io/api/${m}/content/${s}?apiKey=${c}&limit=${n}&noTraverse=${e}&includeRefs=${y}${x?`&locale=${x}`:""}${A?`&enrich=${A}`:""}`);if(i.searchParams.set("omit",et||"meta.componentsUsed"),T&&i.searchParams.set("fields",T),Number.isFinite(S)&&S>-1&&i.searchParams.set("offset",String(Math.floor(S))),typeof B=="boolean"&&i.searchParams.set("includeUnpublished",String(B)),w&&$(w)&&i.searchParams.set("cacheSeconds",String(w)),b&&$(b)&&i.searchParams.set("staleCacheSeconds",String(b)),R){const u=g({sort:R});for(const f in u)i.searchParams.set(f,JSON.stringify(u[f]))}const nt={...Ut(),...Z(t.options||{})},V=g(nt);for(const u in V)i.searchParams.set(u,String(V[u]));if(r&&i.searchParams.set("userAttributes",JSON.stringify(r)),o){const u=g({query:o});for(const f in u)i.searchParams.set(f,JSON.stringify(u[f]))}return i},Mt=t=>"results"in t;async function O(t){const e=await P({...t,limit:1});return e&&e.results[0]||null}const Dt=O,Kt=async t=>{const e=E(t);return await(await M(e.href)).json()},tt=async(t,e,n=E(t))=>{const r=Q(t.canTrack);if(n.search.includes("preview="),!r||!(a()||p==="reactNative"))return e;try{const o=[];for(const s of e.results)o.push(await Nt({item:s,canTrack:r}));e.results=o}catch(o){l.error("Could not process A/B tests. ",o)}return e};async function P(t){try{const e=E(t),n=await Kt(t);return Mt(n)?tt(t,n):(l.error("Error fetching data. ",{url:e,content:n,options:t}),null)}catch(e){return l.error("Error fetching data. ",e),null}}const _t=P;function Gt(){return!a()||I()?!1:location.search.indexOf("builder.preview=")!==-1}const j={};function Wt(t){if(a()){Object.assign(j,t);const e={type:"builder.settingsChange",data:j};parent.postMessage(e,"*")}}const Jt=async t=>{var r,o,s;const e=t.path||((r=t.url)==null?void 0:r.pathname)||((o=t.userAttributes)==null?void 0:o.urlPath),n={...t,apiKey:t.apiKey,model:t.model||"page",userAttributes:{...t.userAttributes,...e?{urlPath:e}:{}},options:k(t.searchParams||((s=t.url)==null?void 0:s.searchParams)||t.options)};return{apiKey:n.apiKey,model:n.model,content:await O(n)}};exports.TARGET=p;exports._processContentResult=tt;exports._track=X;exports.checkIsDefined=d;exports.components=it;exports.createRegisterComponentMessage=at;exports.fastClone=v;exports.fetch=M;exports.fetchBuilderProps=Jt;exports.fetchEntries=P;exports.fetchOneEntry=O;exports.getAllContent=_t;exports.getBuilderSearchParams=k;exports.getContent=Dt;exports.getDefaultCanTrack=Q;exports.getUserAttributes=U;exports.handleABTestingSync=Lt;exports.isBrowser=a;exports.isEditing=I;exports.isPreviewing=Gt;exports.logger=l;exports.register=At;exports.serializeComponentInfo=F;exports.setEditorSettings=Wt;exports.track=Pt;
package/lib/index.cjs DELETED
@@ -1,14 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3
- const o = require('isolated-vm'),
4
- s = (e) => {
5
- const t = new o.Isolate({ memoryLimit: 128 })
6
- .createContextSync()
7
- .evalSync(e);
8
- try {
9
- return JSON.parse(t);
10
- } catch {
11
- return t;
12
- }
13
- };
14
- exports.evaluator = s;
package/lib/index.mjs DELETED
@@ -1,10 +0,0 @@
1
- import r from 'isolated-vm';
2
- const c = (e) => {
3
- const t = new r.Isolate({ memoryLimit: 128 }).createContextSync().evalSync(e);
4
- try {
5
- return JSON.parse(t);
6
- } catch {
7
- return t;
8
- }
9
- };
10
- export { c as evaluator };