@builder.io/sdk-react 0.7.3 → 0.7.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.
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.3",
4
+ "version": "0.7.4",
5
5
  "files": [
6
6
  "lib",
7
7
  "types"
@@ -95,6 +95,7 @@
95
95
  },
96
96
  "scripts": {
97
97
  "release": "npm publish",
98
+ "build-inline-fns": "yarn g:build-inline-fns",
98
99
  "types": "tsc",
99
100
  "build": "nx run-many -p @builder.io/sdk-react -t types build:node build:edge build:browser",
100
101
  "build:node": "SDK_ENV=node vite build --mode lib",
@@ -119,8 +120,14 @@
119
120
  },
120
121
  "nx": {
121
122
  "targets": {
123
+ "build-inline-fns": {
124
+ "dependsOn": [
125
+ "^build:react"
126
+ ]
127
+ },
122
128
  "build": {
123
129
  "dependsOn": [
130
+ "build-inline-fns",
124
131
  "^build:react",
125
132
  "^build"
126
133
  ],
@@ -15,6 +15,10 @@ export interface VideoProps {
15
15
  position?: "center" | "top" | "left" | "right" | "bottom" | "top left" | "top right" | "bottom left" | "bottom right";
16
16
  posterImage?: string;
17
17
  lazyLoad?: boolean;
18
+ children?: any;
19
+ fitContent?: boolean;
20
+ builderBlock?: BuilderBlock;
18
21
  }
22
+ import type { BuilderBlock } from "../../types/builder-block.js";
19
23
  declare function Video(props: VideoProps): React.JSX.Element;
20
24
  export default Video;
@@ -2,10 +2,6 @@ import type { BuilderRenderState } from '../../context/types.js';
2
2
  import type { EnforcePartials } from '../../types/enforced-partials.js';
3
3
  import type { ContentVariantsPrps } from '../content-variants/content-variants.types.js';
4
4
  interface InternalRenderProps {
5
- /**
6
- * TO-DO: improve qwik generator to not remap this name for non-HTML tags, then name it `className`
7
- */
8
- classNameProp: string | undefined;
9
5
  showContent: boolean;
10
6
  isSsrAbTest: boolean;
11
7
  }
@@ -24,7 +24,7 @@ export declare const getVariants: (content: Nullable<BuilderContent>) => {
24
24
  breakpoints?: import("../../types/builder-content.js").Breakpoints;
25
25
  };
26
26
  }[];
27
- export declare const checkShouldRunVariants: ({ canTrack, content }: {
27
+ export declare const checkShouldRenderVariants: ({ canTrack, content }: {
28
28
  canTrack: Nullable<boolean>;
29
29
  content: Nullable<BuilderContent>;
30
30
  }) => boolean;
@@ -33,8 +33,8 @@ type VariantData = {
33
33
  testRatio?: number;
34
34
  };
35
35
  export declare const getScriptString: () => string;
36
- export declare const getVariantsScriptString: (variants: VariantData[], contentId: string) => string;
37
- export declare const getRenderContentScriptString: ({ contentId, variationId }: {
36
+ export declare const getUpdateCookieAndStylesScript: (variants: VariantData[], contentId: string) => string;
37
+ export declare const getUpdateVariantVisibilityScript: ({ contentId, variationId }: {
38
38
  variationId: string;
39
39
  contentId: string;
40
40
  }) => string;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * WARNING: This file contains functions that get stringified and inlined into the HTML at build-time.
3
+ * They cannot import anything.
4
+ */
5
+ /**
6
+ * For more information on how this works,
7
+ * see our [SSR A/B Test Docs](https://github.com/BuilderIO/builder/tree/main/packages/sdks/src/SSR_AB_TEST.md)
8
+ */
9
+ /**
10
+ * For more information on how this works,
11
+ * see our [SSR A/B Test Docs](https://github.com/BuilderIO/builder/tree/main/packages/sdks/src/SSR_AB_TEST.md)
12
+ */
13
+ export declare const UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget) {\n function getAndSetVariantId() {\n function setCookie(name, value, days) {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = '; expires=' + date.toUTCString();\n }\n document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${contentId}`;\n const variantInCookie = getCookie(cookieName);\n const availableIDs = variants.map(vr => vr.id).concat(contentId);\n if (variantInCookie && availableIDs.includes(variantInCookie)) {\n return variantInCookie;\n }\n let n = 0;\n const random = Math.random();\n for (let i = 0; i < variants.length; i++) {\n const variant = variants[i];\n const testRatio = variant.testRatio;\n n += testRatio;\n if (random < n) {\n setCookie(cookieName, variant.id);\n return variant.id;\n }\n }\n setCookie(cookieName, contentId);\n return contentId;\n }\n const winningVariantId = getAndSetVariantId();\n const styleEl = document.currentScript?.previousElementSibling;\n if (isHydrationTarget) {\n styleEl.remove();\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n } else {\n const newStyleStr = variants.concat({\n id: contentId\n }).filter(variant => variant.id !== winningVariantId).map(value => {\n return `.variant-${value.id} { display: none; }\n `;\n }).join('');\n styleEl.innerHTML = newStyleStr;\n }\n}";
14
+ export declare const UPDATE_VARIANT_VISIBILITY_SCRIPT = "function updateVariantVisibility(variantContentId, defaultContentId, isHydrationTarget) {\n if (!navigator.cookieEnabled) {\n return;\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${defaultContentId}`;\n const winningVariant = getCookie(cookieName);\n const parentDiv = document.currentScript?.parentElement;\n const isDefaultContent = variantContentId === defaultContentId;\n const isWinningVariant = winningVariant === variantContentId;\n if (isWinningVariant && !isDefaultContent) {\n parentDiv?.removeAttribute('hidden');\n parentDiv?.removeAttribute('aria-hidden');\n } else if (!isWinningVariant && isDefaultContent) {\n parentDiv?.setAttribute('hidden', 'true');\n parentDiv?.setAttribute('aria-hidden', 'true');\n }\n if (isHydrationTarget) {\n if (!isWinningVariant) {\n parentDiv?.remove();\n }\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n }\n return;\n}";
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.7.3";
1
+ export declare const SDK_VERSION = "0.7.4";