@builder.io/sdk-svelte 0.13.3 → 1.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.
- package/lib/browser/blocks/video/component-info.js +1 -1
- package/lib/browser/components/content/components/enable-editor.svelte +0 -6
- package/lib/browser/components/content/components/enable-editor.svelte.d.ts +0 -1
- package/lib/browser/components/content/content.svelte +1 -15
- package/lib/browser/components/content/content.svelte.d.ts +0 -1
- package/lib/browser/components/content-variants/content-variants.svelte +0 -3
- package/lib/browser/components/content-variants/content-variants.svelte.d.ts +0 -1
- package/lib/browser/components/content-variants/content-variants.types.d.ts +0 -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/generate-content-url.js +12 -7
- package/lib/browser/functions/get-content/index.d.ts +0 -10
- package/lib/browser/functions/get-content/index.js +0 -10
- package/lib/browser/functions/get-content/types.d.ts +0 -11
- package/lib/browser/functions/register-component.d.ts +0 -9
- package/lib/browser/functions/register-component.js +0 -15
- package/lib/browser/index-helpers/blocks-exports.d.ts +0 -8
- package/lib/browser/index-helpers/blocks-exports.js +0 -8
- package/lib/browser/server-index.d.ts +1 -1
- package/lib/browser/server-index.js +1 -1
- package/lib/edge/blocks/video/component-info.js +1 -1
- package/lib/edge/components/content/components/enable-editor.svelte +0 -6
- package/lib/edge/components/content/components/enable-editor.svelte.d.ts +0 -1
- package/lib/edge/components/content/content.svelte +1 -15
- package/lib/edge/components/content/content.svelte.d.ts +0 -1
- package/lib/edge/components/content-variants/content-variants.svelte +0 -3
- package/lib/edge/components/content-variants/content-variants.svelte.d.ts +0 -1
- package/lib/edge/components/content-variants/content-variants.types.d.ts +0 -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/generate-content-url.js +12 -7
- package/lib/edge/functions/get-content/index.d.ts +0 -10
- package/lib/edge/functions/get-content/index.js +0 -10
- package/lib/edge/functions/get-content/types.d.ts +0 -11
- package/lib/edge/functions/register-component.d.ts +0 -9
- package/lib/edge/functions/register-component.js +0 -15
- package/lib/edge/index-helpers/blocks-exports.d.ts +0 -8
- package/lib/edge/index-helpers/blocks-exports.js +0 -8
- package/lib/edge/server-index.d.ts +1 -1
- package/lib/edge/server-index.js +1 -1
- package/lib/node/blocks/video/component-info.js +1 -1
- package/lib/node/components/content/components/enable-editor.svelte +0 -6
- package/lib/node/components/content/components/enable-editor.svelte.d.ts +0 -1
- package/lib/node/components/content/content.svelte +1 -15
- package/lib/node/components/content/content.svelte.d.ts +0 -1
- package/lib/node/components/content-variants/content-variants.svelte +0 -3
- package/lib/node/components/content-variants/content-variants.svelte.d.ts +0 -1
- package/lib/node/components/content-variants/content-variants.types.d.ts +0 -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/generate-content-url.js +12 -7
- package/lib/node/functions/get-content/index.d.ts +0 -10
- package/lib/node/functions/get-content/index.js +0 -10
- package/lib/node/functions/get-content/types.d.ts +0 -11
- package/lib/node/functions/register-component.d.ts +0 -9
- package/lib/node/functions/register-component.js +0 -15
- package/lib/node/index-helpers/blocks-exports.d.ts +0 -8
- package/lib/node/index-helpers/blocks-exports.js +0 -8
- package/lib/node/server-index.d.ts +1 -1
- package/lib/node/server-index.js +1 -1
- package/package.json +1 -1
- package/src/blocks/video/component-info.ts +1 -1
- package/src/components/content/components/enable-editor.svelte +0 -6
- package/src/components/content/content.svelte +1 -18
- package/src/components/content-variants/content-variants.svelte +0 -3
- package/src/components/content-variants/content-variants.types.ts +0 -3
- package/src/constants/sdk-version.ts +1 -1
- package/src/functions/get-content/generate-content-url.ts +9 -9
- package/src/functions/get-content/index.ts +1 -13
- package/src/functions/get-content/types.ts +0 -13
- package/src/functions/register-component.ts +0 -18
- package/src/index-helpers/blocks-exports.ts +1 -10
- package/src/server-index.ts +1 -1
|
@@ -11,7 +11,7 @@ export const componentInfo = {
|
|
|
11
11
|
type: 'file',
|
|
12
12
|
allowedFileTypes: ['mp4'],
|
|
13
13
|
bubble: true,
|
|
14
|
-
defaultValue: 'https://
|
|
14
|
+
defaultValue: 'https://cdn.builder.io/o/assets%2FYJIGb4i01jvw0SRdL5Bt%2Fd27731a526464deba0016216f5f9e570%2Fcompressed?apiKey=YJIGb4i01jvw0SRdL5Bt&token=d27731a526464deba0016216f5f9e570&alt=media&optimized=true',
|
|
15
15
|
required: true
|
|
16
16
|
}, {
|
|
17
17
|
name: 'posterImage',
|
|
@@ -26,7 +26,6 @@ export let context = undefined;
|
|
|
26
26
|
export let canTrack = undefined;
|
|
27
27
|
export let apiKey;
|
|
28
28
|
export let locale = undefined;
|
|
29
|
-
export let includeRefs = undefined;
|
|
30
29
|
export let enrich = undefined;
|
|
31
30
|
export let content = undefined;
|
|
32
31
|
export let showContent;
|
|
@@ -179,11 +178,6 @@ function elementRef_onIniteditingbldr(event) {
|
|
|
179
178
|
locale: locale,
|
|
180
179
|
}
|
|
181
180
|
: {}),
|
|
182
|
-
...(includeRefs
|
|
183
|
-
? {
|
|
184
|
-
includeRefs: includeRefs,
|
|
185
|
-
}
|
|
186
|
-
: {}),
|
|
187
181
|
...(enrich
|
|
188
182
|
? {
|
|
189
183
|
enrich: enrich,
|
|
@@ -17,7 +17,6 @@ declare const __propDef: {
|
|
|
17
17
|
canTrack?: BuilderEditorProps["canTrack"];
|
|
18
18
|
apiKey: BuilderEditorProps["apiKey"];
|
|
19
19
|
locale?: BuilderEditorProps["locale"];
|
|
20
|
-
includeRefs?: BuilderEditorProps["includeRefs"];
|
|
21
20
|
enrich?: BuilderEditorProps["enrich"];
|
|
22
21
|
content?: BuilderEditorProps["content"];
|
|
23
22
|
showContent: BuilderEditorProps["showContent"];
|
|
@@ -3,7 +3,7 @@ import { writable } from "svelte/store";
|
|
|
3
3
|
import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
|
|
4
4
|
import { TARGET } from "../../constants/target.js";
|
|
5
5
|
import ComponentsContext from "../../context/components.context.js";
|
|
6
|
-
import {
|
|
6
|
+
import { serializeComponentInfo } from "../../functions/register-component.js";
|
|
7
7
|
import Blocks from "../blocks/blocks.svelte";
|
|
8
8
|
import { getUpdateVariantVisibilityScript } from "../content-variants/helpers.js";
|
|
9
9
|
import InlinedScript from "../inlined-script.svelte";
|
|
@@ -22,7 +22,6 @@ export let blocksWrapper = undefined;
|
|
|
22
22
|
export let blocksWrapperProps = undefined;
|
|
23
23
|
export let model = undefined;
|
|
24
24
|
export let canTrack = undefined;
|
|
25
|
-
export let includeRefs = undefined;
|
|
26
25
|
export let enrich = undefined;
|
|
27
26
|
export let showContent;
|
|
28
27
|
export let contentWrapper = undefined;
|
|
@@ -41,12 +40,6 @@ let scriptStr = getUpdateVariantVisibilityScript({
|
|
|
41
40
|
});
|
|
42
41
|
let registeredComponents = [
|
|
43
42
|
...getDefaultRegisteredComponents(),
|
|
44
|
-
// While this `components` object is deprecated, we must maintain support for it.
|
|
45
|
-
// Since users are able to override our default components, we need to make sure that we do not break such
|
|
46
|
-
// existing usage.
|
|
47
|
-
// This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
|
|
48
|
-
// which is the new standard way of providing custom components, and must therefore take precedence.
|
|
49
|
-
...components,
|
|
50
43
|
...(customComponents || []),
|
|
51
44
|
].reduce((acc, { component, ...info }) => ({
|
|
52
45
|
...acc,
|
|
@@ -72,12 +65,6 @@ let builderContextSignal = writable({
|
|
|
72
65
|
apiVersion: apiVersion,
|
|
73
66
|
componentInfos: [
|
|
74
67
|
...getDefaultRegisteredComponents(),
|
|
75
|
-
// While this `components` object is deprecated, we must maintain support for it.
|
|
76
|
-
// Since users are able to override our default components, we need to make sure that we do not break such
|
|
77
|
-
// existing usage.
|
|
78
|
-
// This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
|
|
79
|
-
// which is the new standard way of providing custom components, and must therefore take precedence.
|
|
80
|
-
...components,
|
|
81
68
|
...(customComponents || []),
|
|
82
69
|
].reduce((acc, { component: _, ...info }) => ({
|
|
83
70
|
...acc,
|
|
@@ -100,7 +87,6 @@ setContext(ComponentsContext.key, {
|
|
|
100
87
|
{apiKey}
|
|
101
88
|
{canTrack}
|
|
102
89
|
{locale}
|
|
103
|
-
{includeRefs}
|
|
104
90
|
{enrich}
|
|
105
91
|
{showContent}
|
|
106
92
|
{builderContextSignal}
|
|
@@ -13,7 +13,6 @@ declare const __propDef: {
|
|
|
13
13
|
blocksWrapperProps?: ContentProps["blocksWrapperProps"];
|
|
14
14
|
model?: ContentProps["model"];
|
|
15
15
|
canTrack?: ContentProps["canTrack"];
|
|
16
|
-
includeRefs?: ContentProps["includeRefs"];
|
|
17
16
|
enrich?: ContentProps["enrich"];
|
|
18
17
|
showContent: ContentProps["showContent"];
|
|
19
18
|
contentWrapper?: ContentProps["contentWrapper"];
|
|
@@ -19,7 +19,6 @@ export let apiVersion = undefined;
|
|
|
19
19
|
export let customComponents = undefined;
|
|
20
20
|
export let linkComponent = undefined;
|
|
21
21
|
export let locale = undefined;
|
|
22
|
-
export let includeRefs = undefined;
|
|
23
22
|
export let enrich = undefined;
|
|
24
23
|
export let blocksWrapper = undefined;
|
|
25
24
|
export let blocksWrapperProps = undefined;
|
|
@@ -85,7 +84,6 @@ onMount(() => {
|
|
|
85
84
|
{linkComponent}
|
|
86
85
|
{canTrack}
|
|
87
86
|
{locale}
|
|
88
|
-
{includeRefs}
|
|
89
87
|
{enrich}
|
|
90
88
|
isSsrAbTest={shouldRenderVariants}
|
|
91
89
|
{blocksWrapper}
|
|
@@ -110,7 +108,6 @@ onMount(() => {
|
|
|
110
108
|
{linkComponent}
|
|
111
109
|
{canTrack}
|
|
112
110
|
{locale}
|
|
113
|
-
{includeRefs}
|
|
114
111
|
{enrich}
|
|
115
112
|
isSsrAbTest={shouldRenderVariants}
|
|
116
113
|
{blocksWrapper}
|
|
@@ -19,7 +19,6 @@ declare const __propDef: {
|
|
|
19
19
|
customComponents?: VariantsProviderProps["customComponents"];
|
|
20
20
|
linkComponent?: VariantsProviderProps["linkComponent"];
|
|
21
21
|
locale?: VariantsProviderProps["locale"];
|
|
22
|
-
includeRefs?: VariantsProviderProps["includeRefs"];
|
|
23
22
|
enrich?: VariantsProviderProps["enrich"];
|
|
24
23
|
blocksWrapper?: VariantsProviderProps["blocksWrapper"];
|
|
25
24
|
blocksWrapperProps?: VariantsProviderProps["blocksWrapperProps"];
|
|
@@ -42,8 +42,6 @@ export interface ContentVariantsPrps {
|
|
|
42
42
|
* If provided, the API will auto-resolve localized objects to the value of this `locale` key (optional).
|
|
43
43
|
*/
|
|
44
44
|
locale?: string;
|
|
45
|
-
/** @deprecated use `enrich` instead */
|
|
46
|
-
includeRefs?: boolean;
|
|
47
45
|
/**
|
|
48
46
|
* A boolean to enable or disable enriching API content (optional).
|
|
49
47
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "1.0.0";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.
|
|
1
|
+
export const SDK_VERSION = "1.0.0";
|
|
@@ -3,19 +3,24 @@ import { DEFAULT_API_VERSION } from '../../types/api-version.js';
|
|
|
3
3
|
import { getBuilderSearchParamsFromWindow, normalizeSearchParams } from '../get-builder-search-params/index.js';
|
|
4
4
|
const isPositiveNumber = (thing) => typeof thing === 'number' && !isNaN(thing) && thing >= 0;
|
|
5
5
|
export const generateContentUrl = (options) => {
|
|
6
|
-
|
|
7
|
-
const { limit = 30, userAttributes, query, model, apiKey, includeRefs = true, enrich, locale, apiVersion = DEFAULT_API_VERSION, fields, omit, offset, cacheSeconds, staleCacheSeconds, sort, includeUnpublished } = options;
|
|
6
|
+
const { limit = 30, userAttributes, query, model, apiKey, enrich, locale, apiVersion = DEFAULT_API_VERSION, fields, omit, offset, cacheSeconds, staleCacheSeconds, sort, includeUnpublished } = options;
|
|
8
7
|
if (!apiKey) {
|
|
9
8
|
throw new Error('Missing API key');
|
|
10
9
|
}
|
|
11
10
|
if (!['v3'].includes(apiVersion)) {
|
|
12
11
|
throw new Error(`Invalid apiVersion: expected 'v3', received '${apiVersion}'`);
|
|
13
12
|
}
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
// if we are fetching an array of content, we disable noTraverse for perf reasons.
|
|
14
|
+
const noTraverse = limit !== 1;
|
|
15
|
+
const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}`);
|
|
16
|
+
url.searchParams.set('apiKey', apiKey);
|
|
17
|
+
url.searchParams.set('limit', String(limit));
|
|
18
|
+
url.searchParams.set('noTraverse', String(noTraverse));
|
|
19
|
+
url.searchParams.set('includeRefs', String(true));
|
|
20
|
+
if (locale)
|
|
21
|
+
url.searchParams.set('locale', locale);
|
|
22
|
+
if (enrich)
|
|
23
|
+
url.searchParams.set('enrich', String(enrich));
|
|
19
24
|
url.searchParams.set('omit', omit || 'meta.componentsUsed');
|
|
20
25
|
if (fields) {
|
|
21
26
|
url.searchParams.set('fields', fields);
|
|
@@ -4,12 +4,6 @@ import type { GetContentOptions } from './types.js';
|
|
|
4
4
|
* Returns the first content entry that matches the given options.
|
|
5
5
|
*/
|
|
6
6
|
export declare function fetchOneEntry(options: GetContentOptions): Promise<BuilderContent | null>;
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated `getContent` was renamed to `fetchOneEntry`. This is a temporary alias to avoid breaking changes.
|
|
9
|
-
*
|
|
10
|
-
* NOTE: consider using `fetchBuilderProps` instead for easier setup.
|
|
11
|
-
*/
|
|
12
|
-
export declare const getContent: typeof fetchOneEntry;
|
|
13
7
|
type ContentResults = {
|
|
14
8
|
results: BuilderContent[];
|
|
15
9
|
};
|
|
@@ -21,8 +15,4 @@ export declare const _processContentResult: (options: GetContentOptions, content
|
|
|
21
15
|
* Returns a paginated array of entries that match the given options.
|
|
22
16
|
*/
|
|
23
17
|
export declare function fetchEntries(options: GetContentOptions): Promise<BuilderContent[] | null>;
|
|
24
|
-
/**
|
|
25
|
-
* @deprecated `getAllContent` was renamed to `fetchEntries`. This is a temporary alias to avoid breaking changes.
|
|
26
|
-
*/
|
|
27
|
-
export declare const getAllContent: typeof fetchEntries;
|
|
28
18
|
export {};
|
|
@@ -20,12 +20,6 @@ export async function fetchOneEntry(options) {
|
|
|
20
20
|
}
|
|
21
21
|
return null;
|
|
22
22
|
}
|
|
23
|
-
/**
|
|
24
|
-
* @deprecated `getContent` was renamed to `fetchOneEntry`. This is a temporary alias to avoid breaking changes.
|
|
25
|
-
*
|
|
26
|
-
* NOTE: consider using `fetchBuilderProps` instead for easier setup.
|
|
27
|
-
*/
|
|
28
|
-
export const getContent = fetchOneEntry;
|
|
29
23
|
const _fetchContent = async (options) => {
|
|
30
24
|
const url = generateContentUrl(options);
|
|
31
25
|
const res = await fetch(url.href);
|
|
@@ -93,7 +87,3 @@ export async function fetchEntries(options) {
|
|
|
93
87
|
return null;
|
|
94
88
|
}
|
|
95
89
|
}
|
|
96
|
-
/**
|
|
97
|
-
* @deprecated `getAllContent` was renamed to `fetchEntries`. This is a temporary alias to avoid breaking changes.
|
|
98
|
-
*/
|
|
99
|
-
export const getAllContent = fetchEntries;
|
|
@@ -47,12 +47,6 @@ export interface GetContentOptions {
|
|
|
47
47
|
* Accepts both a key/value object or a `URLSearchParams` instance
|
|
48
48
|
* */
|
|
49
49
|
options?: Record<string, any> | URLSearchParams;
|
|
50
|
-
/**
|
|
51
|
-
* If set to `true`, it will lazy load symbols/references.
|
|
52
|
-
* If set to `false`, it will render the entire content tree eagerly.
|
|
53
|
-
* @deprecated use `enrich` instead
|
|
54
|
-
*/
|
|
55
|
-
noTraverse?: boolean;
|
|
56
50
|
/**
|
|
57
51
|
* If set to `false`, it will not use cookies to target content. Therefore, A/B Testing will be disabled and
|
|
58
52
|
* only the default variation will be returned to every user.
|
|
@@ -60,11 +54,6 @@ export interface GetContentOptions {
|
|
|
60
54
|
* Defaults to `true`.
|
|
61
55
|
*/
|
|
62
56
|
canTrack?: boolean;
|
|
63
|
-
/**
|
|
64
|
-
* Include content of references in the response. Defaults to `true`.
|
|
65
|
-
* @deprecated use `enrich` instead
|
|
66
|
-
*/
|
|
67
|
-
includeRefs?: boolean;
|
|
68
57
|
/**
|
|
69
58
|
* Include multilevel references in the response.
|
|
70
59
|
*/
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
import type { RegisteredComponent } from '../context/types.js';
|
|
2
1
|
import type { ComponentInfo } from '../types/components.js';
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.
|
|
5
|
-
*/
|
|
6
|
-
export declare const components: RegisteredComponent[];
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.
|
|
9
|
-
*/
|
|
10
|
-
export declare function registerComponent(component: any, info: ComponentInfo): void;
|
|
11
2
|
export declare const createRegisterComponentMessage: (info: ComponentInfo) => {
|
|
12
3
|
type: string;
|
|
13
4
|
data: ComponentInfo;
|
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
import { fastClone } from './fast-clone.js';
|
|
2
|
-
/**
|
|
3
|
-
* @deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.
|
|
4
|
-
*/
|
|
5
|
-
export const components = [];
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.
|
|
8
|
-
*/
|
|
9
|
-
export function registerComponent(component, info) {
|
|
10
|
-
components.push({
|
|
11
|
-
component,
|
|
12
|
-
...info
|
|
13
|
-
});
|
|
14
|
-
console.warn('registerComponent is deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.');
|
|
15
|
-
return component;
|
|
16
|
-
}
|
|
17
2
|
export const createRegisterComponentMessage = (info) => ({
|
|
18
3
|
type: 'builder.registerComponent',
|
|
19
4
|
data: serializeComponentInfo(info)
|
|
@@ -9,11 +9,3 @@ export { default as Video } from '../blocks/video/video.svelte';
|
|
|
9
9
|
import { default as Blocks } from '../components/blocks/blocks.svelte';
|
|
10
10
|
import { default as Content } from '../components/content-variants/content-variants.svelte';
|
|
11
11
|
export { Blocks, Content };
|
|
12
|
-
/**
|
|
13
|
-
* @deprecated Renamed to `Blocks`.
|
|
14
|
-
*/
|
|
15
|
-
export declare const RenderBlocks: typeof Blocks;
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated Renamed to `Content`.
|
|
18
|
-
*/
|
|
19
|
-
export declare const RenderContent: typeof Content;
|
|
@@ -9,11 +9,3 @@ export { default as Video } from '../blocks/video/video.svelte';
|
|
|
9
9
|
import { default as Blocks } from '../components/blocks/blocks.svelte';
|
|
10
10
|
import { default as Content } from '../components/content-variants/content-variants.svelte';
|
|
11
11
|
export { Blocks, Content };
|
|
12
|
-
/**
|
|
13
|
-
* @deprecated Renamed to `Blocks`.
|
|
14
|
-
*/
|
|
15
|
-
export const RenderBlocks = Blocks;
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated Renamed to `Content`.
|
|
18
|
-
*/
|
|
19
|
-
export const RenderContent = Content;
|
|
@@ -36,4 +36,4 @@ export { subscribeToEditor } from './helpers/subscribe-to-editor.js';
|
|
|
36
36
|
* Content fetching
|
|
37
37
|
*/
|
|
38
38
|
export { fetchBuilderProps } from './functions/fetch-builder-props.js';
|
|
39
|
-
export { _processContentResult, fetchEntries, fetchOneEntry
|
|
39
|
+
export { _processContentResult, fetchEntries, fetchOneEntry } from './functions/get-content/index.js';
|
|
@@ -14,4 +14,4 @@ export { subscribeToEditor } from './helpers/subscribe-to-editor.js';
|
|
|
14
14
|
* Content fetching
|
|
15
15
|
*/
|
|
16
16
|
export { fetchBuilderProps } from './functions/fetch-builder-props.js';
|
|
17
|
-
export { _processContentResult, fetchEntries, fetchOneEntry
|
|
17
|
+
export { _processContentResult, fetchEntries, fetchOneEntry } from './functions/get-content/index.js';
|
|
@@ -11,7 +11,7 @@ export const componentInfo = {
|
|
|
11
11
|
type: 'file',
|
|
12
12
|
allowedFileTypes: ['mp4'],
|
|
13
13
|
bubble: true,
|
|
14
|
-
defaultValue: 'https://
|
|
14
|
+
defaultValue: 'https://cdn.builder.io/o/assets%2FYJIGb4i01jvw0SRdL5Bt%2Fd27731a526464deba0016216f5f9e570%2Fcompressed?apiKey=YJIGb4i01jvw0SRdL5Bt&token=d27731a526464deba0016216f5f9e570&alt=media&optimized=true',
|
|
15
15
|
required: true
|
|
16
16
|
}, {
|
|
17
17
|
name: 'posterImage',
|
|
@@ -26,7 +26,6 @@ export let context = undefined;
|
|
|
26
26
|
export let canTrack = undefined;
|
|
27
27
|
export let apiKey;
|
|
28
28
|
export let locale = undefined;
|
|
29
|
-
export let includeRefs = undefined;
|
|
30
29
|
export let enrich = undefined;
|
|
31
30
|
export let content = undefined;
|
|
32
31
|
export let showContent;
|
|
@@ -179,11 +178,6 @@ function elementRef_onIniteditingbldr(event) {
|
|
|
179
178
|
locale: locale,
|
|
180
179
|
}
|
|
181
180
|
: {}),
|
|
182
|
-
...(includeRefs
|
|
183
|
-
? {
|
|
184
|
-
includeRefs: includeRefs,
|
|
185
|
-
}
|
|
186
|
-
: {}),
|
|
187
181
|
...(enrich
|
|
188
182
|
? {
|
|
189
183
|
enrich: enrich,
|
|
@@ -17,7 +17,6 @@ declare const __propDef: {
|
|
|
17
17
|
canTrack?: BuilderEditorProps["canTrack"];
|
|
18
18
|
apiKey: BuilderEditorProps["apiKey"];
|
|
19
19
|
locale?: BuilderEditorProps["locale"];
|
|
20
|
-
includeRefs?: BuilderEditorProps["includeRefs"];
|
|
21
20
|
enrich?: BuilderEditorProps["enrich"];
|
|
22
21
|
content?: BuilderEditorProps["content"];
|
|
23
22
|
showContent: BuilderEditorProps["showContent"];
|
|
@@ -3,7 +3,7 @@ import { writable } from "svelte/store";
|
|
|
3
3
|
import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
|
|
4
4
|
import { TARGET } from "../../constants/target.js";
|
|
5
5
|
import ComponentsContext from "../../context/components.context.js";
|
|
6
|
-
import {
|
|
6
|
+
import { serializeComponentInfo } from "../../functions/register-component.js";
|
|
7
7
|
import Blocks from "../blocks/blocks.svelte";
|
|
8
8
|
import { getUpdateVariantVisibilityScript } from "../content-variants/helpers.js";
|
|
9
9
|
import InlinedScript from "../inlined-script.svelte";
|
|
@@ -22,7 +22,6 @@ export let blocksWrapper = undefined;
|
|
|
22
22
|
export let blocksWrapperProps = undefined;
|
|
23
23
|
export let model = undefined;
|
|
24
24
|
export let canTrack = undefined;
|
|
25
|
-
export let includeRefs = undefined;
|
|
26
25
|
export let enrich = undefined;
|
|
27
26
|
export let showContent;
|
|
28
27
|
export let contentWrapper = undefined;
|
|
@@ -41,12 +40,6 @@ let scriptStr = getUpdateVariantVisibilityScript({
|
|
|
41
40
|
});
|
|
42
41
|
let registeredComponents = [
|
|
43
42
|
...getDefaultRegisteredComponents(),
|
|
44
|
-
// While this `components` object is deprecated, we must maintain support for it.
|
|
45
|
-
// Since users are able to override our default components, we need to make sure that we do not break such
|
|
46
|
-
// existing usage.
|
|
47
|
-
// This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
|
|
48
|
-
// which is the new standard way of providing custom components, and must therefore take precedence.
|
|
49
|
-
...components,
|
|
50
43
|
...(customComponents || []),
|
|
51
44
|
].reduce((acc, { component, ...info }) => ({
|
|
52
45
|
...acc,
|
|
@@ -72,12 +65,6 @@ let builderContextSignal = writable({
|
|
|
72
65
|
apiVersion: apiVersion,
|
|
73
66
|
componentInfos: [
|
|
74
67
|
...getDefaultRegisteredComponents(),
|
|
75
|
-
// While this `components` object is deprecated, we must maintain support for it.
|
|
76
|
-
// Since users are able to override our default components, we need to make sure that we do not break such
|
|
77
|
-
// existing usage.
|
|
78
|
-
// This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
|
|
79
|
-
// which is the new standard way of providing custom components, and must therefore take precedence.
|
|
80
|
-
...components,
|
|
81
68
|
...(customComponents || []),
|
|
82
69
|
].reduce((acc, { component: _, ...info }) => ({
|
|
83
70
|
...acc,
|
|
@@ -100,7 +87,6 @@ setContext(ComponentsContext.key, {
|
|
|
100
87
|
{apiKey}
|
|
101
88
|
{canTrack}
|
|
102
89
|
{locale}
|
|
103
|
-
{includeRefs}
|
|
104
90
|
{enrich}
|
|
105
91
|
{showContent}
|
|
106
92
|
{builderContextSignal}
|
|
@@ -13,7 +13,6 @@ declare const __propDef: {
|
|
|
13
13
|
blocksWrapperProps?: ContentProps["blocksWrapperProps"];
|
|
14
14
|
model?: ContentProps["model"];
|
|
15
15
|
canTrack?: ContentProps["canTrack"];
|
|
16
|
-
includeRefs?: ContentProps["includeRefs"];
|
|
17
16
|
enrich?: ContentProps["enrich"];
|
|
18
17
|
showContent: ContentProps["showContent"];
|
|
19
18
|
contentWrapper?: ContentProps["contentWrapper"];
|
|
@@ -19,7 +19,6 @@ export let apiVersion = undefined;
|
|
|
19
19
|
export let customComponents = undefined;
|
|
20
20
|
export let linkComponent = undefined;
|
|
21
21
|
export let locale = undefined;
|
|
22
|
-
export let includeRefs = undefined;
|
|
23
22
|
export let enrich = undefined;
|
|
24
23
|
export let blocksWrapper = undefined;
|
|
25
24
|
export let blocksWrapperProps = undefined;
|
|
@@ -85,7 +84,6 @@ onMount(() => {
|
|
|
85
84
|
{linkComponent}
|
|
86
85
|
{canTrack}
|
|
87
86
|
{locale}
|
|
88
|
-
{includeRefs}
|
|
89
87
|
{enrich}
|
|
90
88
|
isSsrAbTest={shouldRenderVariants}
|
|
91
89
|
{blocksWrapper}
|
|
@@ -110,7 +108,6 @@ onMount(() => {
|
|
|
110
108
|
{linkComponent}
|
|
111
109
|
{canTrack}
|
|
112
110
|
{locale}
|
|
113
|
-
{includeRefs}
|
|
114
111
|
{enrich}
|
|
115
112
|
isSsrAbTest={shouldRenderVariants}
|
|
116
113
|
{blocksWrapper}
|
|
@@ -19,7 +19,6 @@ declare const __propDef: {
|
|
|
19
19
|
customComponents?: VariantsProviderProps["customComponents"];
|
|
20
20
|
linkComponent?: VariantsProviderProps["linkComponent"];
|
|
21
21
|
locale?: VariantsProviderProps["locale"];
|
|
22
|
-
includeRefs?: VariantsProviderProps["includeRefs"];
|
|
23
22
|
enrich?: VariantsProviderProps["enrich"];
|
|
24
23
|
blocksWrapper?: VariantsProviderProps["blocksWrapper"];
|
|
25
24
|
blocksWrapperProps?: VariantsProviderProps["blocksWrapperProps"];
|
|
@@ -42,8 +42,6 @@ export interface ContentVariantsPrps {
|
|
|
42
42
|
* If provided, the API will auto-resolve localized objects to the value of this `locale` key (optional).
|
|
43
43
|
*/
|
|
44
44
|
locale?: string;
|
|
45
|
-
/** @deprecated use `enrich` instead */
|
|
46
|
-
includeRefs?: boolean;
|
|
47
45
|
/**
|
|
48
46
|
* A boolean to enable or disable enriching API content (optional).
|
|
49
47
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "1.0.0";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.
|
|
1
|
+
export const SDK_VERSION = "1.0.0";
|
|
@@ -3,19 +3,24 @@ import { DEFAULT_API_VERSION } from '../../types/api-version.js';
|
|
|
3
3
|
import { getBuilderSearchParamsFromWindow, normalizeSearchParams } from '../get-builder-search-params/index.js';
|
|
4
4
|
const isPositiveNumber = (thing) => typeof thing === 'number' && !isNaN(thing) && thing >= 0;
|
|
5
5
|
export const generateContentUrl = (options) => {
|
|
6
|
-
|
|
7
|
-
const { limit = 30, userAttributes, query, model, apiKey, includeRefs = true, enrich, locale, apiVersion = DEFAULT_API_VERSION, fields, omit, offset, cacheSeconds, staleCacheSeconds, sort, includeUnpublished } = options;
|
|
6
|
+
const { limit = 30, userAttributes, query, model, apiKey, enrich, locale, apiVersion = DEFAULT_API_VERSION, fields, omit, offset, cacheSeconds, staleCacheSeconds, sort, includeUnpublished } = options;
|
|
8
7
|
if (!apiKey) {
|
|
9
8
|
throw new Error('Missing API key');
|
|
10
9
|
}
|
|
11
10
|
if (!['v3'].includes(apiVersion)) {
|
|
12
11
|
throw new Error(`Invalid apiVersion: expected 'v3', received '${apiVersion}'`);
|
|
13
12
|
}
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
// if we are fetching an array of content, we disable noTraverse for perf reasons.
|
|
14
|
+
const noTraverse = limit !== 1;
|
|
15
|
+
const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}`);
|
|
16
|
+
url.searchParams.set('apiKey', apiKey);
|
|
17
|
+
url.searchParams.set('limit', String(limit));
|
|
18
|
+
url.searchParams.set('noTraverse', String(noTraverse));
|
|
19
|
+
url.searchParams.set('includeRefs', String(true));
|
|
20
|
+
if (locale)
|
|
21
|
+
url.searchParams.set('locale', locale);
|
|
22
|
+
if (enrich)
|
|
23
|
+
url.searchParams.set('enrich', String(enrich));
|
|
19
24
|
url.searchParams.set('omit', omit || 'meta.componentsUsed');
|
|
20
25
|
if (fields) {
|
|
21
26
|
url.searchParams.set('fields', fields);
|
|
@@ -4,12 +4,6 @@ import type { GetContentOptions } from './types.js';
|
|
|
4
4
|
* Returns the first content entry that matches the given options.
|
|
5
5
|
*/
|
|
6
6
|
export declare function fetchOneEntry(options: GetContentOptions): Promise<BuilderContent | null>;
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated `getContent` was renamed to `fetchOneEntry`. This is a temporary alias to avoid breaking changes.
|
|
9
|
-
*
|
|
10
|
-
* NOTE: consider using `fetchBuilderProps` instead for easier setup.
|
|
11
|
-
*/
|
|
12
|
-
export declare const getContent: typeof fetchOneEntry;
|
|
13
7
|
type ContentResults = {
|
|
14
8
|
results: BuilderContent[];
|
|
15
9
|
};
|
|
@@ -21,8 +15,4 @@ export declare const _processContentResult: (options: GetContentOptions, content
|
|
|
21
15
|
* Returns a paginated array of entries that match the given options.
|
|
22
16
|
*/
|
|
23
17
|
export declare function fetchEntries(options: GetContentOptions): Promise<BuilderContent[] | null>;
|
|
24
|
-
/**
|
|
25
|
-
* @deprecated `getAllContent` was renamed to `fetchEntries`. This is a temporary alias to avoid breaking changes.
|
|
26
|
-
*/
|
|
27
|
-
export declare const getAllContent: typeof fetchEntries;
|
|
28
18
|
export {};
|
|
@@ -20,12 +20,6 @@ export async function fetchOneEntry(options) {
|
|
|
20
20
|
}
|
|
21
21
|
return null;
|
|
22
22
|
}
|
|
23
|
-
/**
|
|
24
|
-
* @deprecated `getContent` was renamed to `fetchOneEntry`. This is a temporary alias to avoid breaking changes.
|
|
25
|
-
*
|
|
26
|
-
* NOTE: consider using `fetchBuilderProps` instead for easier setup.
|
|
27
|
-
*/
|
|
28
|
-
export const getContent = fetchOneEntry;
|
|
29
23
|
const _fetchContent = async (options) => {
|
|
30
24
|
const url = generateContentUrl(options);
|
|
31
25
|
const res = await fetch(url.href);
|
|
@@ -93,7 +87,3 @@ export async function fetchEntries(options) {
|
|
|
93
87
|
return null;
|
|
94
88
|
}
|
|
95
89
|
}
|
|
96
|
-
/**
|
|
97
|
-
* @deprecated `getAllContent` was renamed to `fetchEntries`. This is a temporary alias to avoid breaking changes.
|
|
98
|
-
*/
|
|
99
|
-
export const getAllContent = fetchEntries;
|
|
@@ -47,12 +47,6 @@ export interface GetContentOptions {
|
|
|
47
47
|
* Accepts both a key/value object or a `URLSearchParams` instance
|
|
48
48
|
* */
|
|
49
49
|
options?: Record<string, any> | URLSearchParams;
|
|
50
|
-
/**
|
|
51
|
-
* If set to `true`, it will lazy load symbols/references.
|
|
52
|
-
* If set to `false`, it will render the entire content tree eagerly.
|
|
53
|
-
* @deprecated use `enrich` instead
|
|
54
|
-
*/
|
|
55
|
-
noTraverse?: boolean;
|
|
56
50
|
/**
|
|
57
51
|
* If set to `false`, it will not use cookies to target content. Therefore, A/B Testing will be disabled and
|
|
58
52
|
* only the default variation will be returned to every user.
|
|
@@ -60,11 +54,6 @@ export interface GetContentOptions {
|
|
|
60
54
|
* Defaults to `true`.
|
|
61
55
|
*/
|
|
62
56
|
canTrack?: boolean;
|
|
63
|
-
/**
|
|
64
|
-
* Include content of references in the response. Defaults to `true`.
|
|
65
|
-
* @deprecated use `enrich` instead
|
|
66
|
-
*/
|
|
67
|
-
includeRefs?: boolean;
|
|
68
57
|
/**
|
|
69
58
|
* Include multilevel references in the response.
|
|
70
59
|
*/
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
import type { RegisteredComponent } from '../context/types.js';
|
|
2
1
|
import type { ComponentInfo } from '../types/components.js';
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.
|
|
5
|
-
*/
|
|
6
|
-
export declare const components: RegisteredComponent[];
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.
|
|
9
|
-
*/
|
|
10
|
-
export declare function registerComponent(component: any, info: ComponentInfo): void;
|
|
11
2
|
export declare const createRegisterComponentMessage: (info: ComponentInfo) => {
|
|
12
3
|
type: string;
|
|
13
4
|
data: ComponentInfo;
|
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
import { fastClone } from './fast-clone.js';
|
|
2
|
-
/**
|
|
3
|
-
* @deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.
|
|
4
|
-
*/
|
|
5
|
-
export const components = [];
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.
|
|
8
|
-
*/
|
|
9
|
-
export function registerComponent(component, info) {
|
|
10
|
-
components.push({
|
|
11
|
-
component,
|
|
12
|
-
...info
|
|
13
|
-
});
|
|
14
|
-
console.warn('registerComponent is deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.');
|
|
15
|
-
return component;
|
|
16
|
-
}
|
|
17
2
|
export const createRegisterComponentMessage = (info) => ({
|
|
18
3
|
type: 'builder.registerComponent',
|
|
19
4
|
data: serializeComponentInfo(info)
|
|
@@ -9,11 +9,3 @@ export { default as Video } from '../blocks/video/video.svelte';
|
|
|
9
9
|
import { default as Blocks } from '../components/blocks/blocks.svelte';
|
|
10
10
|
import { default as Content } from '../components/content-variants/content-variants.svelte';
|
|
11
11
|
export { Blocks, Content };
|
|
12
|
-
/**
|
|
13
|
-
* @deprecated Renamed to `Blocks`.
|
|
14
|
-
*/
|
|
15
|
-
export declare const RenderBlocks: typeof Blocks;
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated Renamed to `Content`.
|
|
18
|
-
*/
|
|
19
|
-
export declare const RenderContent: typeof Content;
|