@builder.io/sdk-svelte 4.2.3 → 5.0.0

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 (29) hide show
  1. package/lib/browser/components/content/content.svelte +27 -3
  2. package/lib/browser/components/content/content.svelte.d.ts +3 -3
  3. package/lib/browser/constants/sdk-version.d.ts +1 -1
  4. package/lib/browser/constants/sdk-version.js +1 -1
  5. package/lib/browser/functions/get-builder-search-params/index.d.ts +8 -2
  6. package/lib/browser/functions/get-builder-search-params/index.js +8 -2
  7. package/lib/browser/functions/is-previewing.d.ts +11 -1
  8. package/lib/browser/functions/is-previewing.js +14 -4
  9. package/lib/edge/components/content/content.svelte +27 -3
  10. package/lib/edge/components/content/content.svelte.d.ts +3 -3
  11. package/lib/edge/constants/sdk-version.d.ts +1 -1
  12. package/lib/edge/constants/sdk-version.js +1 -1
  13. package/lib/edge/functions/get-builder-search-params/index.d.ts +8 -2
  14. package/lib/edge/functions/get-builder-search-params/index.js +8 -2
  15. package/lib/edge/functions/is-previewing.d.ts +11 -1
  16. package/lib/edge/functions/is-previewing.js +14 -4
  17. package/lib/node/components/content/content.svelte +27 -3
  18. package/lib/node/components/content/content.svelte.d.ts +3 -3
  19. package/lib/node/constants/sdk-version.d.ts +1 -1
  20. package/lib/node/constants/sdk-version.js +1 -1
  21. package/lib/node/functions/get-builder-search-params/index.d.ts +8 -2
  22. package/lib/node/functions/get-builder-search-params/index.js +8 -2
  23. package/lib/node/functions/is-previewing.d.ts +11 -1
  24. package/lib/node/functions/is-previewing.js +14 -4
  25. package/package.json +2 -2
  26. package/src/components/content/content.svelte +30 -3
  27. package/src/constants/sdk-version.ts +1 -1
  28. package/src/functions/get-builder-search-params/index.ts +8 -2
  29. package/src/functions/is-previewing.ts +15 -4
@@ -14,12 +14,12 @@ import EnableEditor from "./components/enable-editor.svelte";
14
14
  import ContentStyles from "./components/styles.svelte";
15
15
  import { getContentInitialValue, getRootStateInitialValue, } from "./content.helpers";
16
16
  import "./wrap-component-ref";
17
- export let apiKey;
18
- export let context = undefined;
19
17
  export let content;
20
- export let customComponents = undefined;
21
18
  export let data = undefined;
22
19
  export let locale = undefined;
20
+ export let apiKey;
21
+ export let context = undefined;
22
+ export let customComponents = undefined;
23
23
  export let canTrack = undefined;
24
24
  export let apiVersion = undefined;
25
25
  export let blocksWrapper = undefined;
@@ -100,6 +100,30 @@ if (jsCode) {
100
100
  isExpression: false,
101
101
  });
102
102
  }
103
+ function onUpdateFn_0(..._args) {
104
+ const updateContentAndRootState = () => {
105
+ const nextId = content?.id;
106
+ const currentId = $builderContextSignal.content?.id;
107
+ if (nextId && nextId !== currentId) {
108
+ // Update content and root state to reflect the new entry
109
+ $builderContextSignal.content = getContentInitialValue({
110
+ content: content,
111
+ data: data,
112
+ });
113
+ $builderContextSignal.rootState = getRootStateInitialValue({
114
+ content: content,
115
+ data: data,
116
+ locale: locale,
117
+ });
118
+ // Update AB-test visibility script
119
+ scriptStr = getUpdateVariantVisibilityScript({
120
+ variationId: content?.testVariationId || "",
121
+ contentId: nextId,
122
+ });
123
+ }
124
+ };
125
+ }
126
+ $: onUpdateFn_0(...[content, data, locale]);
103
127
  setContext(ComponentsContext.key, {
104
128
  registeredComponents: registeredComponents,
105
129
  });
@@ -2,12 +2,12 @@ import { SvelteComponent } from "svelte";
2
2
  import type { ContentProps } from "./content.types";
3
3
  declare const __propDef: {
4
4
  props: {
5
- apiKey: ContentProps["apiKey"];
6
- context?: ContentProps["context"];
7
5
  content: ContentProps["content"];
8
- customComponents?: ContentProps["customComponents"];
9
6
  data?: ContentProps["data"];
10
7
  locale?: ContentProps["locale"];
8
+ apiKey: ContentProps["apiKey"];
9
+ context?: ContentProps["context"];
10
+ customComponents?: ContentProps["customComponents"];
11
11
  canTrack?: ContentProps["canTrack"];
12
12
  apiVersion?: ContentProps["apiVersion"];
13
13
  blocksWrapper?: ContentProps["blocksWrapper"];
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "4.2.3";
1
+ export declare const SDK_VERSION = "5.0.0";
@@ -1 +1 @@
1
- export const SDK_VERSION = "4.2.3";
1
+ export const SDK_VERSION = "5.0.0";
@@ -1,7 +1,13 @@
1
1
  import type { QueryObject } from '../../helpers/search/search';
2
2
  /**
3
- * Receives a `URLSearchParams` object or a regular query object, and returns the subset of query params that are
4
- * relevant to the Builder SDK.
3
+ * Receives a `URLSearchParams` object or a regular query object, and returns
4
+ * the subset of query params that are relevant to the Builder SDK.
5
+ *
6
+ * Outputs a key-value object to be passed to `fetchOneEntry` or `fetchEntries`
7
+ * functions as the `options` argument.
8
+ *
9
+ * NOTE: This function is generally not needed. Instead, it is recommended to use `isPreviewing()`
10
+ * to check if the current page requires previewed content.
5
11
  *
6
12
  * @returns
7
13
  */
@@ -3,8 +3,14 @@ import { isBrowser } from '../is-browser';
3
3
  const BUILDER_SEARCHPARAMS_PREFIX = 'builder.';
4
4
  const BUILDER_OPTIONS_PREFIX = 'options.';
5
5
  /**
6
- * Receives a `URLSearchParams` object or a regular query object, and returns the subset of query params that are
7
- * relevant to the Builder SDK.
6
+ * Receives a `URLSearchParams` object or a regular query object, and returns
7
+ * the subset of query params that are relevant to the Builder SDK.
8
+ *
9
+ * Outputs a key-value object to be passed to `fetchOneEntry` or `fetchEntries`
10
+ * functions as the `options` argument.
11
+ *
12
+ * NOTE: This function is generally not needed. Instead, it is recommended to use `isPreviewing()`
13
+ * to check if the current page requires previewed content.
8
14
  *
9
15
  * @returns
10
16
  */
@@ -1,2 +1,12 @@
1
1
  import type { Search } from '../helpers/search/search';
2
- export declare function isPreviewing(_search?: Search): boolean;
2
+ /**
3
+ * Checks the current URL's search parameters to see if it is attempting to
4
+ * preview Builder Content.
5
+ *
6
+ * When called on the client, it uses `window.location.search`.
7
+ * When called on the server (SSR), it requires a `search` argument.
8
+ *
9
+ * @param search - The search parameters to check. Can be a URL string (containing the search parameters), `URLSearchParams`, or a key-value object containing the search parameters.
10
+ * @returns `true` if the current page is being previewed, `false` otherwise.
11
+ */
12
+ export declare function isPreviewing(search?: Search): boolean;
@@ -1,14 +1,24 @@
1
1
  import { getSearchString } from '../helpers/search/search';
2
2
  import { isBrowser } from './is-browser';
3
- export function isPreviewing(_search) {
4
- const search = _search || (isBrowser() ? window.location.search : undefined);
3
+ /**
4
+ * Checks the current URL's search parameters to see if it is attempting to
5
+ * preview Builder Content.
6
+ *
7
+ * When called on the client, it uses `window.location.search`.
8
+ * When called on the server (SSR), it requires a `search` argument.
9
+ *
10
+ * @param search - The search parameters to check. Can be a URL string (containing the search parameters), `URLSearchParams`, or a key-value object containing the search parameters.
11
+ * @returns `true` if the current page is being previewed, `false` otherwise.
12
+ */
13
+ export function isPreviewing(search) {
14
+ const searchToUse = search || (isBrowser() ? window.location.search : undefined);
5
15
  /**
6
16
  * If this function is called on the server without an explicit `search` argument,
7
17
  * then it can't check if the user is previewing, and will return `false`.
8
18
  */
9
- if (!search) {
19
+ if (!searchToUse) {
10
20
  return false;
11
21
  }
12
- const normalizedSearch = getSearchString(search);
22
+ const normalizedSearch = getSearchString(searchToUse);
13
23
  return Boolean(normalizedSearch.indexOf('builder.preview=') !== -1);
14
24
  }
@@ -14,12 +14,12 @@ import EnableEditor from "./components/enable-editor.svelte";
14
14
  import ContentStyles from "./components/styles.svelte";
15
15
  import { getContentInitialValue, getRootStateInitialValue, } from "./content.helpers";
16
16
  import "./wrap-component-ref";
17
- export let apiKey;
18
- export let context = undefined;
19
17
  export let content;
20
- export let customComponents = undefined;
21
18
  export let data = undefined;
22
19
  export let locale = undefined;
20
+ export let apiKey;
21
+ export let context = undefined;
22
+ export let customComponents = undefined;
23
23
  export let canTrack = undefined;
24
24
  export let apiVersion = undefined;
25
25
  export let blocksWrapper = undefined;
@@ -100,6 +100,30 @@ if (jsCode) {
100
100
  isExpression: false,
101
101
  });
102
102
  }
103
+ function onUpdateFn_0(..._args) {
104
+ const updateContentAndRootState = () => {
105
+ const nextId = content?.id;
106
+ const currentId = $builderContextSignal.content?.id;
107
+ if (nextId && nextId !== currentId) {
108
+ // Update content and root state to reflect the new entry
109
+ $builderContextSignal.content = getContentInitialValue({
110
+ content: content,
111
+ data: data,
112
+ });
113
+ $builderContextSignal.rootState = getRootStateInitialValue({
114
+ content: content,
115
+ data: data,
116
+ locale: locale,
117
+ });
118
+ // Update AB-test visibility script
119
+ scriptStr = getUpdateVariantVisibilityScript({
120
+ variationId: content?.testVariationId || "",
121
+ contentId: nextId,
122
+ });
123
+ }
124
+ };
125
+ }
126
+ $: onUpdateFn_0(...[content, data, locale]);
103
127
  setContext(ComponentsContext.key, {
104
128
  registeredComponents: registeredComponents,
105
129
  });
@@ -2,12 +2,12 @@ import { SvelteComponent } from "svelte";
2
2
  import type { ContentProps } from "./content.types";
3
3
  declare const __propDef: {
4
4
  props: {
5
- apiKey: ContentProps["apiKey"];
6
- context?: ContentProps["context"];
7
5
  content: ContentProps["content"];
8
- customComponents?: ContentProps["customComponents"];
9
6
  data?: ContentProps["data"];
10
7
  locale?: ContentProps["locale"];
8
+ apiKey: ContentProps["apiKey"];
9
+ context?: ContentProps["context"];
10
+ customComponents?: ContentProps["customComponents"];
11
11
  canTrack?: ContentProps["canTrack"];
12
12
  apiVersion?: ContentProps["apiVersion"];
13
13
  blocksWrapper?: ContentProps["blocksWrapper"];
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "4.2.3";
1
+ export declare const SDK_VERSION = "5.0.0";
@@ -1 +1 @@
1
- export const SDK_VERSION = "4.2.3";
1
+ export const SDK_VERSION = "5.0.0";
@@ -1,7 +1,13 @@
1
1
  import type { QueryObject } from '../../helpers/search/search';
2
2
  /**
3
- * Receives a `URLSearchParams` object or a regular query object, and returns the subset of query params that are
4
- * relevant to the Builder SDK.
3
+ * Receives a `URLSearchParams` object or a regular query object, and returns
4
+ * the subset of query params that are relevant to the Builder SDK.
5
+ *
6
+ * Outputs a key-value object to be passed to `fetchOneEntry` or `fetchEntries`
7
+ * functions as the `options` argument.
8
+ *
9
+ * NOTE: This function is generally not needed. Instead, it is recommended to use `isPreviewing()`
10
+ * to check if the current page requires previewed content.
5
11
  *
6
12
  * @returns
7
13
  */
@@ -3,8 +3,14 @@ import { isBrowser } from '../is-browser';
3
3
  const BUILDER_SEARCHPARAMS_PREFIX = 'builder.';
4
4
  const BUILDER_OPTIONS_PREFIX = 'options.';
5
5
  /**
6
- * Receives a `URLSearchParams` object or a regular query object, and returns the subset of query params that are
7
- * relevant to the Builder SDK.
6
+ * Receives a `URLSearchParams` object or a regular query object, and returns
7
+ * the subset of query params that are relevant to the Builder SDK.
8
+ *
9
+ * Outputs a key-value object to be passed to `fetchOneEntry` or `fetchEntries`
10
+ * functions as the `options` argument.
11
+ *
12
+ * NOTE: This function is generally not needed. Instead, it is recommended to use `isPreviewing()`
13
+ * to check if the current page requires previewed content.
8
14
  *
9
15
  * @returns
10
16
  */
@@ -1,2 +1,12 @@
1
1
  import type { Search } from '../helpers/search/search';
2
- export declare function isPreviewing(_search?: Search): boolean;
2
+ /**
3
+ * Checks the current URL's search parameters to see if it is attempting to
4
+ * preview Builder Content.
5
+ *
6
+ * When called on the client, it uses `window.location.search`.
7
+ * When called on the server (SSR), it requires a `search` argument.
8
+ *
9
+ * @param search - The search parameters to check. Can be a URL string (containing the search parameters), `URLSearchParams`, or a key-value object containing the search parameters.
10
+ * @returns `true` if the current page is being previewed, `false` otherwise.
11
+ */
12
+ export declare function isPreviewing(search?: Search): boolean;
@@ -1,14 +1,24 @@
1
1
  import { getSearchString } from '../helpers/search/search';
2
2
  import { isBrowser } from './is-browser';
3
- export function isPreviewing(_search) {
4
- const search = _search || (isBrowser() ? window.location.search : undefined);
3
+ /**
4
+ * Checks the current URL's search parameters to see if it is attempting to
5
+ * preview Builder Content.
6
+ *
7
+ * When called on the client, it uses `window.location.search`.
8
+ * When called on the server (SSR), it requires a `search` argument.
9
+ *
10
+ * @param search - The search parameters to check. Can be a URL string (containing the search parameters), `URLSearchParams`, or a key-value object containing the search parameters.
11
+ * @returns `true` if the current page is being previewed, `false` otherwise.
12
+ */
13
+ export function isPreviewing(search) {
14
+ const searchToUse = search || (isBrowser() ? window.location.search : undefined);
5
15
  /**
6
16
  * If this function is called on the server without an explicit `search` argument,
7
17
  * then it can't check if the user is previewing, and will return `false`.
8
18
  */
9
- if (!search) {
19
+ if (!searchToUse) {
10
20
  return false;
11
21
  }
12
- const normalizedSearch = getSearchString(search);
22
+ const normalizedSearch = getSearchString(searchToUse);
13
23
  return Boolean(normalizedSearch.indexOf('builder.preview=') !== -1);
14
24
  }
@@ -14,12 +14,12 @@ import EnableEditor from "./components/enable-editor.svelte";
14
14
  import ContentStyles from "./components/styles.svelte";
15
15
  import { getContentInitialValue, getRootStateInitialValue, } from "./content.helpers";
16
16
  import "./wrap-component-ref";
17
- export let apiKey;
18
- export let context = undefined;
19
17
  export let content;
20
- export let customComponents = undefined;
21
18
  export let data = undefined;
22
19
  export let locale = undefined;
20
+ export let apiKey;
21
+ export let context = undefined;
22
+ export let customComponents = undefined;
23
23
  export let canTrack = undefined;
24
24
  export let apiVersion = undefined;
25
25
  export let blocksWrapper = undefined;
@@ -100,6 +100,30 @@ if (jsCode) {
100
100
  isExpression: false,
101
101
  });
102
102
  }
103
+ function onUpdateFn_0(..._args) {
104
+ const updateContentAndRootState = () => {
105
+ const nextId = content?.id;
106
+ const currentId = $builderContextSignal.content?.id;
107
+ if (nextId && nextId !== currentId) {
108
+ // Update content and root state to reflect the new entry
109
+ $builderContextSignal.content = getContentInitialValue({
110
+ content: content,
111
+ data: data,
112
+ });
113
+ $builderContextSignal.rootState = getRootStateInitialValue({
114
+ content: content,
115
+ data: data,
116
+ locale: locale,
117
+ });
118
+ // Update AB-test visibility script
119
+ scriptStr = getUpdateVariantVisibilityScript({
120
+ variationId: content?.testVariationId || "",
121
+ contentId: nextId,
122
+ });
123
+ }
124
+ };
125
+ }
126
+ $: onUpdateFn_0(...[content, data, locale]);
103
127
  setContext(ComponentsContext.key, {
104
128
  registeredComponents: registeredComponents,
105
129
  });
@@ -2,12 +2,12 @@ import { SvelteComponent } from "svelte";
2
2
  import type { ContentProps } from "./content.types";
3
3
  declare const __propDef: {
4
4
  props: {
5
- apiKey: ContentProps["apiKey"];
6
- context?: ContentProps["context"];
7
5
  content: ContentProps["content"];
8
- customComponents?: ContentProps["customComponents"];
9
6
  data?: ContentProps["data"];
10
7
  locale?: ContentProps["locale"];
8
+ apiKey: ContentProps["apiKey"];
9
+ context?: ContentProps["context"];
10
+ customComponents?: ContentProps["customComponents"];
11
11
  canTrack?: ContentProps["canTrack"];
12
12
  apiVersion?: ContentProps["apiVersion"];
13
13
  blocksWrapper?: ContentProps["blocksWrapper"];
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "4.2.3";
1
+ export declare const SDK_VERSION = "5.0.0";
@@ -1 +1 @@
1
- export const SDK_VERSION = "4.2.3";
1
+ export const SDK_VERSION = "5.0.0";
@@ -1,7 +1,13 @@
1
1
  import type { QueryObject } from '../../helpers/search/search';
2
2
  /**
3
- * Receives a `URLSearchParams` object or a regular query object, and returns the subset of query params that are
4
- * relevant to the Builder SDK.
3
+ * Receives a `URLSearchParams` object or a regular query object, and returns
4
+ * the subset of query params that are relevant to the Builder SDK.
5
+ *
6
+ * Outputs a key-value object to be passed to `fetchOneEntry` or `fetchEntries`
7
+ * functions as the `options` argument.
8
+ *
9
+ * NOTE: This function is generally not needed. Instead, it is recommended to use `isPreviewing()`
10
+ * to check if the current page requires previewed content.
5
11
  *
6
12
  * @returns
7
13
  */
@@ -3,8 +3,14 @@ import { isBrowser } from '../is-browser';
3
3
  const BUILDER_SEARCHPARAMS_PREFIX = 'builder.';
4
4
  const BUILDER_OPTIONS_PREFIX = 'options.';
5
5
  /**
6
- * Receives a `URLSearchParams` object or a regular query object, and returns the subset of query params that are
7
- * relevant to the Builder SDK.
6
+ * Receives a `URLSearchParams` object or a regular query object, and returns
7
+ * the subset of query params that are relevant to the Builder SDK.
8
+ *
9
+ * Outputs a key-value object to be passed to `fetchOneEntry` or `fetchEntries`
10
+ * functions as the `options` argument.
11
+ *
12
+ * NOTE: This function is generally not needed. Instead, it is recommended to use `isPreviewing()`
13
+ * to check if the current page requires previewed content.
8
14
  *
9
15
  * @returns
10
16
  */
@@ -1,2 +1,12 @@
1
1
  import type { Search } from '../helpers/search/search';
2
- export declare function isPreviewing(_search?: Search): boolean;
2
+ /**
3
+ * Checks the current URL's search parameters to see if it is attempting to
4
+ * preview Builder Content.
5
+ *
6
+ * When called on the client, it uses `window.location.search`.
7
+ * When called on the server (SSR), it requires a `search` argument.
8
+ *
9
+ * @param search - The search parameters to check. Can be a URL string (containing the search parameters), `URLSearchParams`, or a key-value object containing the search parameters.
10
+ * @returns `true` if the current page is being previewed, `false` otherwise.
11
+ */
12
+ export declare function isPreviewing(search?: Search): boolean;
@@ -1,14 +1,24 @@
1
1
  import { getSearchString } from '../helpers/search/search';
2
2
  import { isBrowser } from './is-browser';
3
- export function isPreviewing(_search) {
4
- const search = _search || (isBrowser() ? window.location.search : undefined);
3
+ /**
4
+ * Checks the current URL's search parameters to see if it is attempting to
5
+ * preview Builder Content.
6
+ *
7
+ * When called on the client, it uses `window.location.search`.
8
+ * When called on the server (SSR), it requires a `search` argument.
9
+ *
10
+ * @param search - The search parameters to check. Can be a URL string (containing the search parameters), `URLSearchParams`, or a key-value object containing the search parameters.
11
+ * @returns `true` if the current page is being previewed, `false` otherwise.
12
+ */
13
+ export function isPreviewing(search) {
14
+ const searchToUse = search || (isBrowser() ? window.location.search : undefined);
5
15
  /**
6
16
  * If this function is called on the server without an explicit `search` argument,
7
17
  * then it can't check if the user is previewing, and will return `false`.
8
18
  */
9
- if (!search) {
19
+ if (!searchToUse) {
10
20
  return false;
11
21
  }
12
- const normalizedSearch = getSearchString(search);
22
+ const normalizedSearch = getSearchString(searchToUse);
13
23
  return Boolean(normalizedSearch.indexOf('builder.preview=') !== -1);
14
24
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-svelte",
3
3
  "description": "Builder.io SDK for Svelte",
4
- "version": "4.2.3",
4
+ "version": "5.0.0",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "lib",
@@ -48,7 +48,7 @@
48
48
  "check": "SDK_ENV=browser svelte-check --tsconfig ./tsconfig.json"
49
49
  },
50
50
  "dependencies": {
51
- "isolated-vm": "^5.0.0"
51
+ "isolated-vm": "^6.0.0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@builder.io/sdks": "workspace:*",
@@ -28,12 +28,12 @@
28
28
  import type { ContentProps } from "./content.types";
29
29
  import { wrapComponentRef } from "./wrap-component-ref";
30
30
 
31
- export let apiKey: ContentProps["apiKey"];
32
- export let context: ContentProps["context"] = undefined;
33
31
  export let content: ContentProps["content"];
34
- export let customComponents: ContentProps["customComponents"] = undefined;
35
32
  export let data: ContentProps["data"] = undefined;
36
33
  export let locale: ContentProps["locale"] = undefined;
34
+ export let apiKey: ContentProps["apiKey"];
35
+ export let context: ContentProps["context"] = undefined;
36
+ export let customComponents: ContentProps["customComponents"] = undefined;
37
37
  export let canTrack: ContentProps["canTrack"] = undefined;
38
38
  export let apiVersion: ContentProps["apiVersion"] = undefined;
39
39
  export let blocksWrapper: ContentProps["blocksWrapper"] = undefined;
@@ -127,6 +127,33 @@
127
127
  });
128
128
  }
129
129
 
130
+ function onUpdateFn_0(..._args: any[]) {
131
+ const updateContentAndRootState = () => {
132
+ const nextId = content?.id;
133
+ const currentId = $builderContextSignal.content?.id;
134
+ if (nextId && nextId !== currentId) {
135
+ // Update content and root state to reflect the new entry
136
+ $builderContextSignal.content = getContentInitialValue({
137
+ content: content,
138
+ data: data,
139
+ });
140
+ $builderContextSignal.rootState = getRootStateInitialValue({
141
+ content: content,
142
+ data: data,
143
+ locale: locale,
144
+ });
145
+
146
+ // Update AB-test visibility script
147
+ scriptStr = getUpdateVariantVisibilityScript({
148
+ variationId: content?.testVariationId || "",
149
+ contentId: nextId,
150
+ });
151
+ }
152
+ };
153
+ }
154
+
155
+ $: onUpdateFn_0(...[content, data, locale]);
156
+
130
157
  setContext(ComponentsContext.key, {
131
158
  registeredComponents: registeredComponents,
132
159
  });
@@ -1 +1 @@
1
- export const SDK_VERSION = "4.2.3"
1
+ export const SDK_VERSION = "5.0.0"
@@ -5,8 +5,14 @@ const BUILDER_SEARCHPARAMS_PREFIX = 'builder.';
5
5
  const BUILDER_OPTIONS_PREFIX = 'options.';
6
6
 
7
7
  /**
8
- * Receives a `URLSearchParams` object or a regular query object, and returns the subset of query params that are
9
- * relevant to the Builder SDK.
8
+ * Receives a `URLSearchParams` object or a regular query object, and returns
9
+ * the subset of query params that are relevant to the Builder SDK.
10
+ *
11
+ * Outputs a key-value object to be passed to `fetchOneEntry` or `fetchEntries`
12
+ * functions as the `options` argument.
13
+ *
14
+ * NOTE: This function is generally not needed. Instead, it is recommended to use `isPreviewing()`
15
+ * to check if the current page requires previewed content.
10
16
  *
11
17
  * @returns
12
18
  */
@@ -1,16 +1,27 @@
1
1
  import type { Search } from '../helpers/search/search';
2
2
  import { getSearchString } from '../helpers/search/search';
3
3
  import { isBrowser } from './is-browser';
4
- export function isPreviewing(_search?: Search) {
5
- const search = _search || (isBrowser() ? window.location.search : undefined);
4
+
5
+ /**
6
+ * Checks the current URL's search parameters to see if it is attempting to
7
+ * preview Builder Content.
8
+ *
9
+ * When called on the client, it uses `window.location.search`.
10
+ * When called on the server (SSR), it requires a `search` argument.
11
+ *
12
+ * @param search - The search parameters to check. Can be a URL string (containing the search parameters), `URLSearchParams`, or a key-value object containing the search parameters.
13
+ * @returns `true` if the current page is being previewed, `false` otherwise.
14
+ */
15
+ export function isPreviewing(search?: Search) {
16
+ const searchToUse = search || (isBrowser() ? window.location.search : undefined);
6
17
 
7
18
  /**
8
19
  * If this function is called on the server without an explicit `search` argument,
9
20
  * then it can't check if the user is previewing, and will return `false`.
10
21
  */
11
- if (!search) {
22
+ if (!searchToUse) {
12
23
  return false;
13
24
  }
14
- const normalizedSearch = getSearchString(search);
25
+ const normalizedSearch = getSearchString(searchToUse);
15
26
  return Boolean(normalizedSearch.indexOf('builder.preview=') !== -1);
16
27
  }