@builder.io/sdk-svelte 1.0.14 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/blocks/columns/columns.svelte +1 -1
- package/lib/browser/components/block/components/block-styles.svelte +1 -1
- package/lib/browser/components/content/components/styles.svelte +1 -1
- package/lib/browser/components/content/content.svelte +1 -1
- package/lib/browser/components/content-variants/content-variants.svelte +9 -6
- package/lib/browser/components/content-variants/helpers.d.ts +1 -1
- package/lib/browser/components/content-variants/helpers.js +1 -1
- package/lib/browser/components/inlined-script.svelte +2 -2
- package/lib/browser/components/inlined-script.svelte.d.ts +2 -2
- package/lib/browser/components/inlined-styles.svelte +2 -2
- package/lib/browser/components/inlined-styles.svelte.d.ts +2 -2
- package/lib/browser/constants/sdk-version.d.ts +1 -1
- package/lib/browser/constants/sdk-version.js +1 -1
- package/lib/browser/functions/get-content/index.js +2 -1
- package/lib/browser/functions/get-content/types.d.ts +8 -0
- package/lib/edge/blocks/columns/columns.svelte +1 -1
- package/lib/edge/components/block/components/block-styles.svelte +1 -1
- package/lib/edge/components/content/components/styles.svelte +1 -1
- package/lib/edge/components/content/content.svelte +1 -1
- package/lib/edge/components/content-variants/content-variants.svelte +9 -6
- package/lib/edge/components/content-variants/helpers.d.ts +1 -1
- package/lib/edge/components/content-variants/helpers.js +1 -1
- package/lib/edge/components/inlined-script.svelte +2 -2
- package/lib/edge/components/inlined-script.svelte.d.ts +2 -2
- package/lib/edge/components/inlined-styles.svelte +2 -2
- package/lib/edge/components/inlined-styles.svelte.d.ts +2 -2
- package/lib/edge/constants/sdk-version.d.ts +1 -1
- package/lib/edge/constants/sdk-version.js +1 -1
- package/lib/edge/functions/get-content/index.js +2 -1
- package/lib/edge/functions/get-content/types.d.ts +8 -0
- package/lib/node/blocks/columns/columns.svelte +1 -1
- package/lib/node/components/block/components/block-styles.svelte +1 -1
- package/lib/node/components/content/components/styles.svelte +1 -1
- package/lib/node/components/content/content.svelte +1 -1
- package/lib/node/components/content-variants/content-variants.svelte +9 -6
- package/lib/node/components/content-variants/helpers.d.ts +1 -1
- package/lib/node/components/content-variants/helpers.js +1 -1
- package/lib/node/components/inlined-script.svelte +2 -2
- package/lib/node/components/inlined-script.svelte.d.ts +2 -2
- package/lib/node/components/inlined-styles.svelte +2 -2
- package/lib/node/components/inlined-styles.svelte.d.ts +2 -2
- package/lib/node/constants/sdk-version.d.ts +1 -1
- package/lib/node/constants/sdk-version.js +1 -1
- package/lib/node/functions/get-content/index.js +2 -1
- package/lib/node/functions/get-content/types.d.ts +8 -0
- package/package.json +1 -1
- package/src/blocks/columns/columns.svelte +1 -1
- package/src/components/block/components/block-styles.svelte +1 -1
- package/src/components/content/components/styles.svelte +1 -1
- package/src/components/content/content.svelte +1 -1
- package/src/components/content-variants/content-variants.svelte +9 -6
- package/src/components/content-variants/helpers.ts +1 -1
- package/src/components/inlined-script.svelte +3 -3
- package/src/components/inlined-styles.svelte +3 -3
- package/src/constants/sdk-version.ts +1 -1
- package/src/functions/get-content/index.ts +2 -1
- package/src/functions/get-content/types.ts +10 -0
|
@@ -129,7 +129,7 @@ let flexDir = stackColumnsAt === "never"
|
|
|
129
129
|
{...{}}
|
|
130
130
|
>
|
|
131
131
|
{#if TARGET !== "reactNative"}
|
|
132
|
-
<InlinedStyles styles={columnsStyles()} />
|
|
132
|
+
<InlinedStyles id="builderio-columns" styles={columnsStyles()} />
|
|
133
133
|
{/if}
|
|
134
134
|
{#each columns as column, index (index)}
|
|
135
135
|
<DynamicRenderer
|
|
@@ -7,7 +7,7 @@ import { getDefaultCanTrack } from "../../helpers/canTrack.js";
|
|
|
7
7
|
import ContentComponent from "../content/content.svelte";
|
|
8
8
|
import InlinedScript from "../inlined-script.svelte";
|
|
9
9
|
import InlinedStyles from "../inlined-styles.svelte";
|
|
10
|
-
import { checkShouldRenderVariants,
|
|
10
|
+
import { checkShouldRenderVariants, getInitVariantsFnsScriptString, getUpdateCookieAndStylesScript, getVariants, } from "./helpers.js";
|
|
11
11
|
export let canTrack = undefined;
|
|
12
12
|
export let content = undefined;
|
|
13
13
|
export let isNestedRender = undefined;
|
|
@@ -60,15 +60,18 @@ onMount(() => {
|
|
|
60
60
|
</script>
|
|
61
61
|
|
|
62
62
|
{#if !isNestedRender && TARGET !== "reactNative"}
|
|
63
|
-
<InlinedScript
|
|
63
|
+
<InlinedScript
|
|
64
|
+
id="builderio-init-variants-fns"
|
|
65
|
+
scriptStr={getInitVariantsFnsScriptString()}
|
|
66
|
+
/>
|
|
64
67
|
{/if}
|
|
65
68
|
|
|
66
69
|
{#if shouldRenderVariants}
|
|
67
|
-
<InlinedStyles
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
<InlinedStyles id="builderio-variants" styles={hideVariantsStyleString()} />
|
|
71
|
+
<InlinedScript
|
|
72
|
+
id="builderio-variants-visibility"
|
|
73
|
+
scriptStr={updateCookieAndStylesScriptStr()}
|
|
70
74
|
/>
|
|
71
|
-
<InlinedScript scriptStr={updateCookieAndStylesScriptStr()} />
|
|
72
75
|
|
|
73
76
|
{#each getVariants(content) as variant (variant.testVariationId)}
|
|
74
77
|
<ContentComponent
|
|
@@ -32,7 +32,7 @@ type VariantData = {
|
|
|
32
32
|
id: string;
|
|
33
33
|
testRatio?: number;
|
|
34
34
|
};
|
|
35
|
-
export declare const
|
|
35
|
+
export declare const getInitVariantsFnsScriptString: () => string;
|
|
36
36
|
export declare const getUpdateCookieAndStylesScript: (variants: VariantData[], contentId: string) => string;
|
|
37
37
|
export declare const getUpdateVariantVisibilityScript: ({ contentId, variationId }: {
|
|
38
38
|
variationId: string;
|
|
@@ -41,7 +41,7 @@ export const checkShouldRenderVariants = ({ canTrack, content }) => {
|
|
|
41
41
|
};
|
|
42
42
|
const getIsHydrationTarget = (target) => target === 'react' || target === 'reactNative';
|
|
43
43
|
const isHydrationTarget = getIsHydrationTarget(TARGET);
|
|
44
|
-
export const
|
|
44
|
+
export const getInitVariantsFnsScriptString = () => `
|
|
45
45
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
46
46
|
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
|
|
47
47
|
`;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
2
|
interface Props {
|
|
3
3
|
scriptStr: string;
|
|
4
|
-
id
|
|
4
|
+
id: string;
|
|
5
5
|
}
|
|
6
6
|
declare const __propDef: {
|
|
7
7
|
props: {
|
|
8
8
|
scriptStr: Props["scriptStr"];
|
|
9
|
-
id
|
|
9
|
+
id: Props["id"];
|
|
10
10
|
};
|
|
11
11
|
events: {
|
|
12
12
|
[evt: string]: CustomEvent<any>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
2
|
interface Props {
|
|
3
3
|
styles: string;
|
|
4
|
-
id
|
|
4
|
+
id: string;
|
|
5
5
|
}
|
|
6
6
|
declare const __propDef: {
|
|
7
7
|
props: {
|
|
8
8
|
styles: Props["styles"];
|
|
9
|
-
id
|
|
9
|
+
id: Props["id"];
|
|
10
10
|
};
|
|
11
11
|
events: {
|
|
12
12
|
[evt: string]: CustomEvent<any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.0.
|
|
1
|
+
export declare const SDK_VERSION = "1.0.16";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.0.
|
|
1
|
+
export const SDK_VERSION = "1.0.16";
|
|
@@ -22,7 +22,8 @@ export async function fetchOneEntry(options) {
|
|
|
22
22
|
}
|
|
23
23
|
const _fetchContent = async (options) => {
|
|
24
24
|
const url = generateContentUrl(options);
|
|
25
|
-
const
|
|
25
|
+
const _fetch = options.fetch ?? fetch;
|
|
26
|
+
const res = await _fetch(url.href, options.fetchOptions);
|
|
26
27
|
const content = await res.json();
|
|
27
28
|
return content;
|
|
28
29
|
};
|
|
@@ -128,4 +128,12 @@ export interface GetContentOptions {
|
|
|
128
128
|
* draft mode and un-archived. Default is false.
|
|
129
129
|
*/
|
|
130
130
|
includeUnpublished?: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Optional override of the `fetch` function. (Defaults to global `fetch`)
|
|
133
|
+
*/
|
|
134
|
+
fetch?: typeof global.fetch;
|
|
135
|
+
/**
|
|
136
|
+
* Optional fetch options to be passed to the `fetch` function.
|
|
137
|
+
*/
|
|
138
|
+
fetchOptions?: RequestInit;
|
|
131
139
|
}
|
|
@@ -129,7 +129,7 @@ let flexDir = stackColumnsAt === "never"
|
|
|
129
129
|
{...{}}
|
|
130
130
|
>
|
|
131
131
|
{#if TARGET !== "reactNative"}
|
|
132
|
-
<InlinedStyles styles={columnsStyles()} />
|
|
132
|
+
<InlinedStyles id="builderio-columns" styles={columnsStyles()} />
|
|
133
133
|
{/if}
|
|
134
134
|
{#each columns as column, index (index)}
|
|
135
135
|
<DynamicRenderer
|
|
@@ -7,7 +7,7 @@ import { getDefaultCanTrack } from "../../helpers/canTrack.js";
|
|
|
7
7
|
import ContentComponent from "../content/content.svelte";
|
|
8
8
|
import InlinedScript from "../inlined-script.svelte";
|
|
9
9
|
import InlinedStyles from "../inlined-styles.svelte";
|
|
10
|
-
import { checkShouldRenderVariants,
|
|
10
|
+
import { checkShouldRenderVariants, getInitVariantsFnsScriptString, getUpdateCookieAndStylesScript, getVariants, } from "./helpers.js";
|
|
11
11
|
export let canTrack = undefined;
|
|
12
12
|
export let content = undefined;
|
|
13
13
|
export let isNestedRender = undefined;
|
|
@@ -60,15 +60,18 @@ onMount(() => {
|
|
|
60
60
|
</script>
|
|
61
61
|
|
|
62
62
|
{#if !isNestedRender && TARGET !== "reactNative"}
|
|
63
|
-
<InlinedScript
|
|
63
|
+
<InlinedScript
|
|
64
|
+
id="builderio-init-variants-fns"
|
|
65
|
+
scriptStr={getInitVariantsFnsScriptString()}
|
|
66
|
+
/>
|
|
64
67
|
{/if}
|
|
65
68
|
|
|
66
69
|
{#if shouldRenderVariants}
|
|
67
|
-
<InlinedStyles
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
<InlinedStyles id="builderio-variants" styles={hideVariantsStyleString()} />
|
|
71
|
+
<InlinedScript
|
|
72
|
+
id="builderio-variants-visibility"
|
|
73
|
+
scriptStr={updateCookieAndStylesScriptStr()}
|
|
70
74
|
/>
|
|
71
|
-
<InlinedScript scriptStr={updateCookieAndStylesScriptStr()} />
|
|
72
75
|
|
|
73
76
|
{#each getVariants(content) as variant (variant.testVariationId)}
|
|
74
77
|
<ContentComponent
|
|
@@ -32,7 +32,7 @@ type VariantData = {
|
|
|
32
32
|
id: string;
|
|
33
33
|
testRatio?: number;
|
|
34
34
|
};
|
|
35
|
-
export declare const
|
|
35
|
+
export declare const getInitVariantsFnsScriptString: () => string;
|
|
36
36
|
export declare const getUpdateCookieAndStylesScript: (variants: VariantData[], contentId: string) => string;
|
|
37
37
|
export declare const getUpdateVariantVisibilityScript: ({ contentId, variationId }: {
|
|
38
38
|
variationId: string;
|
|
@@ -41,7 +41,7 @@ export const checkShouldRenderVariants = ({ canTrack, content }) => {
|
|
|
41
41
|
};
|
|
42
42
|
const getIsHydrationTarget = (target) => target === 'react' || target === 'reactNative';
|
|
43
43
|
const isHydrationTarget = getIsHydrationTarget(TARGET);
|
|
44
|
-
export const
|
|
44
|
+
export const getInitVariantsFnsScriptString = () => `
|
|
45
45
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
46
46
|
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
|
|
47
47
|
`;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
2
|
interface Props {
|
|
3
3
|
scriptStr: string;
|
|
4
|
-
id
|
|
4
|
+
id: string;
|
|
5
5
|
}
|
|
6
6
|
declare const __propDef: {
|
|
7
7
|
props: {
|
|
8
8
|
scriptStr: Props["scriptStr"];
|
|
9
|
-
id
|
|
9
|
+
id: Props["id"];
|
|
10
10
|
};
|
|
11
11
|
events: {
|
|
12
12
|
[evt: string]: CustomEvent<any>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
2
|
interface Props {
|
|
3
3
|
styles: string;
|
|
4
|
-
id
|
|
4
|
+
id: string;
|
|
5
5
|
}
|
|
6
6
|
declare const __propDef: {
|
|
7
7
|
props: {
|
|
8
8
|
styles: Props["styles"];
|
|
9
|
-
id
|
|
9
|
+
id: Props["id"];
|
|
10
10
|
};
|
|
11
11
|
events: {
|
|
12
12
|
[evt: string]: CustomEvent<any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.0.
|
|
1
|
+
export declare const SDK_VERSION = "1.0.16";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.0.
|
|
1
|
+
export const SDK_VERSION = "1.0.16";
|
|
@@ -22,7 +22,8 @@ export async function fetchOneEntry(options) {
|
|
|
22
22
|
}
|
|
23
23
|
const _fetchContent = async (options) => {
|
|
24
24
|
const url = generateContentUrl(options);
|
|
25
|
-
const
|
|
25
|
+
const _fetch = options.fetch ?? fetch;
|
|
26
|
+
const res = await _fetch(url.href, options.fetchOptions);
|
|
26
27
|
const content = await res.json();
|
|
27
28
|
return content;
|
|
28
29
|
};
|
|
@@ -128,4 +128,12 @@ export interface GetContentOptions {
|
|
|
128
128
|
* draft mode and un-archived. Default is false.
|
|
129
129
|
*/
|
|
130
130
|
includeUnpublished?: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Optional override of the `fetch` function. (Defaults to global `fetch`)
|
|
133
|
+
*/
|
|
134
|
+
fetch?: typeof global.fetch;
|
|
135
|
+
/**
|
|
136
|
+
* Optional fetch options to be passed to the `fetch` function.
|
|
137
|
+
*/
|
|
138
|
+
fetchOptions?: RequestInit;
|
|
131
139
|
}
|
|
@@ -129,7 +129,7 @@ let flexDir = stackColumnsAt === "never"
|
|
|
129
129
|
{...{}}
|
|
130
130
|
>
|
|
131
131
|
{#if TARGET !== "reactNative"}
|
|
132
|
-
<InlinedStyles styles={columnsStyles()} />
|
|
132
|
+
<InlinedStyles id="builderio-columns" styles={columnsStyles()} />
|
|
133
133
|
{/if}
|
|
134
134
|
{#each columns as column, index (index)}
|
|
135
135
|
<DynamicRenderer
|
|
@@ -7,7 +7,7 @@ import { getDefaultCanTrack } from "../../helpers/canTrack.js";
|
|
|
7
7
|
import ContentComponent from "../content/content.svelte";
|
|
8
8
|
import InlinedScript from "../inlined-script.svelte";
|
|
9
9
|
import InlinedStyles from "../inlined-styles.svelte";
|
|
10
|
-
import { checkShouldRenderVariants,
|
|
10
|
+
import { checkShouldRenderVariants, getInitVariantsFnsScriptString, getUpdateCookieAndStylesScript, getVariants, } from "./helpers.js";
|
|
11
11
|
export let canTrack = undefined;
|
|
12
12
|
export let content = undefined;
|
|
13
13
|
export let isNestedRender = undefined;
|
|
@@ -60,15 +60,18 @@ onMount(() => {
|
|
|
60
60
|
</script>
|
|
61
61
|
|
|
62
62
|
{#if !isNestedRender && TARGET !== "reactNative"}
|
|
63
|
-
<InlinedScript
|
|
63
|
+
<InlinedScript
|
|
64
|
+
id="builderio-init-variants-fns"
|
|
65
|
+
scriptStr={getInitVariantsFnsScriptString()}
|
|
66
|
+
/>
|
|
64
67
|
{/if}
|
|
65
68
|
|
|
66
69
|
{#if shouldRenderVariants}
|
|
67
|
-
<InlinedStyles
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
<InlinedStyles id="builderio-variants" styles={hideVariantsStyleString()} />
|
|
71
|
+
<InlinedScript
|
|
72
|
+
id="builderio-variants-visibility"
|
|
73
|
+
scriptStr={updateCookieAndStylesScriptStr()}
|
|
70
74
|
/>
|
|
71
|
-
<InlinedScript scriptStr={updateCookieAndStylesScriptStr()} />
|
|
72
75
|
|
|
73
76
|
{#each getVariants(content) as variant (variant.testVariationId)}
|
|
74
77
|
<ContentComponent
|
|
@@ -32,7 +32,7 @@ type VariantData = {
|
|
|
32
32
|
id: string;
|
|
33
33
|
testRatio?: number;
|
|
34
34
|
};
|
|
35
|
-
export declare const
|
|
35
|
+
export declare const getInitVariantsFnsScriptString: () => string;
|
|
36
36
|
export declare const getUpdateCookieAndStylesScript: (variants: VariantData[], contentId: string) => string;
|
|
37
37
|
export declare const getUpdateVariantVisibilityScript: ({ contentId, variationId }: {
|
|
38
38
|
variationId: string;
|
|
@@ -41,7 +41,7 @@ export const checkShouldRenderVariants = ({ canTrack, content }) => {
|
|
|
41
41
|
};
|
|
42
42
|
const getIsHydrationTarget = (target) => target === 'react' || target === 'reactNative';
|
|
43
43
|
const isHydrationTarget = getIsHydrationTarget(TARGET);
|
|
44
|
-
export const
|
|
44
|
+
export const getInitVariantsFnsScriptString = () => `
|
|
45
45
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
46
46
|
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
|
|
47
47
|
`;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
2
|
interface Props {
|
|
3
3
|
scriptStr: string;
|
|
4
|
-
id
|
|
4
|
+
id: string;
|
|
5
5
|
}
|
|
6
6
|
declare const __propDef: {
|
|
7
7
|
props: {
|
|
8
8
|
scriptStr: Props["scriptStr"];
|
|
9
|
-
id
|
|
9
|
+
id: Props["id"];
|
|
10
10
|
};
|
|
11
11
|
events: {
|
|
12
12
|
[evt: string]: CustomEvent<any>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
2
|
interface Props {
|
|
3
3
|
styles: string;
|
|
4
|
-
id
|
|
4
|
+
id: string;
|
|
5
5
|
}
|
|
6
6
|
declare const __propDef: {
|
|
7
7
|
props: {
|
|
8
8
|
styles: Props["styles"];
|
|
9
|
-
id
|
|
9
|
+
id: Props["id"];
|
|
10
10
|
};
|
|
11
11
|
events: {
|
|
12
12
|
[evt: string]: CustomEvent<any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.0.
|
|
1
|
+
export declare const SDK_VERSION = "1.0.16";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.0.
|
|
1
|
+
export const SDK_VERSION = "1.0.16";
|
|
@@ -22,7 +22,8 @@ export async function fetchOneEntry(options) {
|
|
|
22
22
|
}
|
|
23
23
|
const _fetchContent = async (options) => {
|
|
24
24
|
const url = generateContentUrl(options);
|
|
25
|
-
const
|
|
25
|
+
const _fetch = options.fetch ?? fetch;
|
|
26
|
+
const res = await _fetch(url.href, options.fetchOptions);
|
|
26
27
|
const content = await res.json();
|
|
27
28
|
return content;
|
|
28
29
|
};
|
|
@@ -128,4 +128,12 @@ export interface GetContentOptions {
|
|
|
128
128
|
* draft mode and un-archived. Default is false.
|
|
129
129
|
*/
|
|
130
130
|
includeUnpublished?: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Optional override of the `fetch` function. (Defaults to global `fetch`)
|
|
133
|
+
*/
|
|
134
|
+
fetch?: typeof global.fetch;
|
|
135
|
+
/**
|
|
136
|
+
* Optional fetch options to be passed to the `fetch` function.
|
|
137
|
+
*/
|
|
138
|
+
fetchOptions?: RequestInit;
|
|
131
139
|
}
|
package/package.json
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
import type { ContentVariantsPrps } from "./content-variants.types.js";
|
|
20
20
|
import {
|
|
21
21
|
checkShouldRenderVariants,
|
|
22
|
-
|
|
22
|
+
getInitVariantsFnsScriptString,
|
|
23
23
|
getUpdateCookieAndStylesScript,
|
|
24
24
|
getVariants,
|
|
25
25
|
} from "./helpers.js";
|
|
@@ -87,15 +87,18 @@
|
|
|
87
87
|
</script>
|
|
88
88
|
|
|
89
89
|
{#if !isNestedRender && TARGET !== "reactNative"}
|
|
90
|
-
<InlinedScript
|
|
90
|
+
<InlinedScript
|
|
91
|
+
id="builderio-init-variants-fns"
|
|
92
|
+
scriptStr={getInitVariantsFnsScriptString()}
|
|
93
|
+
/>
|
|
91
94
|
{/if}
|
|
92
95
|
|
|
93
96
|
{#if shouldRenderVariants}
|
|
94
|
-
<InlinedStyles
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
<InlinedStyles id="builderio-variants" styles={hideVariantsStyleString()} />
|
|
98
|
+
<InlinedScript
|
|
99
|
+
id="builderio-variants-visibility"
|
|
100
|
+
scriptStr={updateCookieAndStylesScriptStr()}
|
|
97
101
|
/>
|
|
98
|
-
<InlinedScript scriptStr={updateCookieAndStylesScriptStr()} />
|
|
99
102
|
|
|
100
103
|
{#each getVariants(content) as variant (variant.testVariationId)}
|
|
101
104
|
<ContentComponent
|
|
@@ -52,7 +52,7 @@ type VariantData = {
|
|
|
52
52
|
};
|
|
53
53
|
const getIsHydrationTarget = (target: Target) => target === 'react' || target === 'reactNative';
|
|
54
54
|
const isHydrationTarget = getIsHydrationTarget(TARGET);
|
|
55
|
-
export const
|
|
55
|
+
export const getInitVariantsFnsScriptString = () => `
|
|
56
56
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
57
57
|
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
|
|
58
58
|
`;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<script context="module" lang="ts">
|
|
2
2
|
interface Props {
|
|
3
3
|
scriptStr: string;
|
|
4
|
-
id
|
|
4
|
+
id: string;
|
|
5
5
|
}
|
|
6
6
|
</script>
|
|
7
7
|
|
|
8
8
|
<script lang="ts">
|
|
9
9
|
export let scriptStr: Props["scriptStr"];
|
|
10
|
-
export let id: Props["id"]
|
|
10
|
+
export let id: Props["id"];
|
|
11
11
|
</script>
|
|
12
12
|
|
|
13
|
-
{@html `<script id=${id
|
|
13
|
+
{@html `<script data-id=${id}>${scriptStr}</script>`}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<script context="module" lang="ts">
|
|
2
2
|
interface Props {
|
|
3
3
|
styles: string;
|
|
4
|
-
id
|
|
4
|
+
id: string;
|
|
5
5
|
}
|
|
6
6
|
</script>
|
|
7
7
|
|
|
8
8
|
<script lang="ts">
|
|
9
9
|
export let styles: Props["styles"];
|
|
10
|
-
export let id: Props["id"]
|
|
10
|
+
export let id: Props["id"];
|
|
11
11
|
</script>
|
|
12
12
|
|
|
13
|
-
{@html `<${"style"} id=${id} >${styles}<${"/style"}>`}
|
|
13
|
+
{@html `<${"style"} data-id=${id} >${styles}<${"/style"}>`}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.0.
|
|
1
|
+
export const SDK_VERSION = "1.0.16"
|
|
@@ -32,7 +32,8 @@ type ContentResponse = ContentResults | {
|
|
|
32
32
|
};
|
|
33
33
|
const _fetchContent = async (options: GetContentOptions) => {
|
|
34
34
|
const url = generateContentUrl(options);
|
|
35
|
-
const
|
|
35
|
+
const _fetch = options.fetch ?? fetch;
|
|
36
|
+
const res = await _fetch(url.href, options.fetchOptions);
|
|
36
37
|
const content = await (res.json() as Promise<ContentResponse>);
|
|
37
38
|
return content;
|
|
38
39
|
};
|
|
@@ -144,4 +144,14 @@ export interface GetContentOptions {
|
|
|
144
144
|
* draft mode and un-archived. Default is false.
|
|
145
145
|
*/
|
|
146
146
|
includeUnpublished?: boolean;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Optional override of the `fetch` function. (Defaults to global `fetch`)
|
|
150
|
+
*/
|
|
151
|
+
fetch?: typeof global.fetch;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Optional fetch options to be passed to the `fetch` function.
|
|
155
|
+
*/
|
|
156
|
+
fetchOptions?: RequestInit;
|
|
147
157
|
}
|