@builder.io/sdk-solid 0.0.8-16 → 0.0.8-19
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 +1 -1
- package/src/blocks/image/image.jsx +10 -2
- package/src/blocks/symbol/symbol.jsx +1 -1
- package/src/components/render-block/render-block.jsx +4 -1
- package/src/components/render-block/types.js +0 -0
- package/src/components/render-content/render-content.jsx +11 -9
- package/src/functions/get-builder-search-params/index.js +12 -1
- package/src/functions/get-content/index.js +11 -8
- package/src/functions/previewing-model-name.js +0 -11
package/package.json
CHANGED
|
@@ -25,6 +25,14 @@ function Image(props) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
return getSrcSet(url);
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
get webpSrcSet() {
|
|
31
|
+
if (state.srcSetToUse?.match(/builder\.io/) && !props.noWebp) {
|
|
32
|
+
return state.srcSetToUse.replace(/\?/g, "?format=webp&");
|
|
33
|
+
} else {
|
|
34
|
+
return "";
|
|
35
|
+
}
|
|
28
36
|
}
|
|
29
37
|
|
|
30
38
|
});
|
|
@@ -32,8 +40,8 @@ function Image(props) {
|
|
|
32
40
|
position: "relative"
|
|
33
41
|
})}>
|
|
34
42
|
<picture>
|
|
35
|
-
<Show when={state.
|
|
36
|
-
<source type="image/webp" srcset={state.
|
|
43
|
+
<Show when={state.webpSrcSet}>
|
|
44
|
+
<source type="image/webp" srcset={state.webpSrcSet} />
|
|
37
45
|
</Show>
|
|
38
46
|
<img class={"builder-image" + (props.className ? " " + props.className : "") + " " + css({
|
|
39
47
|
opacity: "1",
|
|
@@ -43,7 +43,7 @@ function Symbol(props) {
|
|
|
43
43
|
return <div class={state.className} {...props.attributes} dataSet={{
|
|
44
44
|
class: state.className
|
|
45
45
|
}}>
|
|
46
|
-
<RenderContent apiKey={builderContext.apiKey} context={builderContext.context} data={{ ...props.symbol?.data,
|
|
46
|
+
<RenderContent apiKey={builderContext.apiKey} context={builderContext.context} customComponents={Object.values(builderContext.registeredComponents)} data={{ ...props.symbol?.data,
|
|
47
47
|
...builderContext.state,
|
|
48
48
|
...props.symbol?.content?.data?.state
|
|
49
49
|
}} model={props.symbol?.model} content={state.content}></RenderContent>
|
|
@@ -170,7 +170,7 @@ function RenderBlock(props) {
|
|
|
170
170
|
return <Show fallback={<RenderComponent {...state.renderComponentProps}></RenderComponent>} when={state.shouldWrap}>
|
|
171
171
|
<Show fallback={<Dynamic {...state.attributes} component={state.tagName}></Dynamic>} when={!isEmptyHtmlElement(state.tagName)}>
|
|
172
172
|
<Dynamic {...state.attributes} component={state.tagName}>
|
|
173
|
-
<Show
|
|
173
|
+
<Show when={state.repeatItemData}>
|
|
174
174
|
<For each={state.repeatItemData}>
|
|
175
175
|
{(data, _index) => {
|
|
176
176
|
const index = _index();
|
|
@@ -179,6 +179,9 @@ function RenderBlock(props) {
|
|
|
179
179
|
}}
|
|
180
180
|
</For>
|
|
181
181
|
</Show>
|
|
182
|
+
<Show when={!state.repeatItemData}>
|
|
183
|
+
<RenderComponent {...state.renderComponentProps}></RenderComponent>
|
|
184
|
+
</Show>
|
|
182
185
|
<For each={state.childrenWithoutParentComponent}>
|
|
183
186
|
{(child, _index) => {
|
|
184
187
|
const index = _index();
|
|
File without changes
|
|
@@ -5,13 +5,11 @@ import { getDefaultRegisteredComponents } from "../../constants/builder-register
|
|
|
5
5
|
import { TARGET } from "../../constants/target.js";
|
|
6
6
|
import BuilderContext from "../../context/builder.context";
|
|
7
7
|
import { evaluate } from "../../functions/evaluate.js";
|
|
8
|
-
import { convertSearchParamsToQueryObject, getBuilderSearchParams } from "../../functions/get-builder-search-params/index.js";
|
|
9
8
|
import { getContent } from "../../functions/get-content/index.js";
|
|
10
9
|
import { getFetch } from "../../functions/get-fetch.js";
|
|
11
10
|
import { isBrowser } from "../../functions/is-browser.js";
|
|
12
11
|
import { isEditing } from "../../functions/is-editing.js";
|
|
13
12
|
import { isPreviewing } from "../../functions/is-previewing.js";
|
|
14
|
-
import { previewingModelName } from "../../functions/previewing-model-name.js";
|
|
15
13
|
import { components, createRegisterComponentMessage } from "../../functions/register-component.js";
|
|
16
14
|
import { track } from "../../functions/track.js";
|
|
17
15
|
import RenderBlocks from "../render-blocks.jsx";
|
|
@@ -153,6 +151,10 @@ function RenderContent(props) {
|
|
|
153
151
|
}
|
|
154
152
|
}));
|
|
155
153
|
}
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
get shouldRenderContentStyles() {
|
|
157
|
+
return Boolean((state.useContent?.data?.cssCode || state.useContent?.data?.customFonts?.length) && TARGET !== "reactNative");
|
|
156
158
|
}
|
|
157
159
|
|
|
158
160
|
});
|
|
@@ -175,15 +177,15 @@ function RenderContent(props) {
|
|
|
175
177
|
|
|
176
178
|
|
|
177
179
|
if (isPreviewing()) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
+
const searchParams = new URL(location.href).searchParams;
|
|
181
|
+
|
|
182
|
+
if (props.model && searchParams.get("builder.preview") === props.model) {
|
|
180
183
|
const previewApiKey = searchParams.get("apiKey") || searchParams.get("builder.space");
|
|
181
184
|
|
|
182
185
|
if (previewApiKey) {
|
|
183
186
|
getContent({
|
|
184
187
|
model: props.model,
|
|
185
|
-
apiKey: previewApiKey
|
|
186
|
-
options: getBuilderSearchParams(convertSearchParamsToQueryObject(searchParams))
|
|
188
|
+
apiKey: previewApiKey
|
|
187
189
|
}).then(content => {
|
|
188
190
|
if (content) {
|
|
189
191
|
state.overrideContent = content;
|
|
@@ -241,9 +243,9 @@ function RenderContent(props) {
|
|
|
241
243
|
<Show when={state.useContent}>
|
|
242
244
|
<div onClick={event => track("click", {
|
|
243
245
|
contentId: state.useContent.id
|
|
244
|
-
})}
|
|
245
|
-
<Show when={
|
|
246
|
-
<RenderContentStyles cssCode={state.useContent
|
|
246
|
+
})} builder-content-id={state.useContent?.id}>
|
|
247
|
+
<Show when={state.shouldRenderContentStyles}>
|
|
248
|
+
<RenderContentStyles cssCode={state.useContent?.data?.cssCode} customFonts={state.useContent?.data?.customFonts}></RenderContentStyles>
|
|
247
249
|
</Show>
|
|
248
250
|
<RenderBlocks blocks={state.useContent?.data?.blocks}></RenderBlocks>
|
|
249
251
|
</div>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isBrowser } from "../is-browser";
|
|
1
2
|
const BUILDER_SEARCHPARAMS_PREFIX = "builder.";
|
|
2
3
|
const convertSearchParamsToQueryObject = (searchParams) => {
|
|
3
4
|
const options = {};
|
|
@@ -16,7 +17,17 @@ const getBuilderSearchParams = (options) => {
|
|
|
16
17
|
});
|
|
17
18
|
return newOptions;
|
|
18
19
|
};
|
|
20
|
+
const getBuilderSearchParamsFromWindow = () => {
|
|
21
|
+
if (!isBrowser()) {
|
|
22
|
+
return {};
|
|
23
|
+
}
|
|
24
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
25
|
+
return getBuilderSearchParams(convertSearchParamsToQueryObject(searchParams));
|
|
26
|
+
};
|
|
27
|
+
const normalizeSearchParams = (searchParams) => searchParams instanceof URLSearchParams ? convertSearchParamsToQueryObject(searchParams) : searchParams;
|
|
19
28
|
export {
|
|
20
29
|
convertSearchParamsToQueryObject,
|
|
21
|
-
getBuilderSearchParams
|
|
30
|
+
getBuilderSearchParams,
|
|
31
|
+
getBuilderSearchParamsFromWindow,
|
|
32
|
+
normalizeSearchParams
|
|
22
33
|
};
|
|
@@ -38,6 +38,10 @@ var __async = (__this, __arguments, generator) => {
|
|
|
38
38
|
});
|
|
39
39
|
};
|
|
40
40
|
import { flatten } from "../../helpers/flatten.js";
|
|
41
|
+
import {
|
|
42
|
+
getBuilderSearchParamsFromWindow,
|
|
43
|
+
normalizeSearchParams
|
|
44
|
+
} from "../get-builder-search-params/index.js";
|
|
41
45
|
import { getFetch } from "../get-fetch.js";
|
|
42
46
|
import { handleABTesting } from "./ab-testing.js";
|
|
43
47
|
const fetch$ = getFetch();
|
|
@@ -56,19 +60,18 @@ const generateContentUrl = (options) => {
|
|
|
56
60
|
apiKey
|
|
57
61
|
} = options;
|
|
58
62
|
const url = new URL(`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}`);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
63
|
+
const queryOptions = __spreadValues(__spreadValues({}, getBuilderSearchParamsFromWindow()), normalizeSearchParams(options.options || {}));
|
|
64
|
+
const flattened = flatten(queryOptions);
|
|
65
|
+
for (const key in flattened) {
|
|
66
|
+
url.searchParams.set(key, String(flattened[key]));
|
|
64
67
|
}
|
|
65
68
|
if (userAttributes) {
|
|
66
69
|
url.searchParams.set("userAttributes", JSON.stringify(userAttributes));
|
|
67
70
|
}
|
|
68
71
|
if (query) {
|
|
69
|
-
const
|
|
70
|
-
for (const key in
|
|
71
|
-
url.searchParams.set(key, JSON.stringify(
|
|
72
|
+
const flattened2 = flatten({ query });
|
|
73
|
+
for (const key in flattened2) {
|
|
74
|
+
url.searchParams.set(key, JSON.stringify(flattened2[key]));
|
|
72
75
|
}
|
|
73
76
|
}
|
|
74
77
|
return url;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { isPreviewing } from "./is-previewing.js";
|
|
2
|
-
function previewingModelName() {
|
|
3
|
-
if (!isPreviewing()) {
|
|
4
|
-
return null;
|
|
5
|
-
}
|
|
6
|
-
const url = new URL(location.href);
|
|
7
|
-
return url.searchParams.get("builder.preview");
|
|
8
|
-
}
|
|
9
|
-
export {
|
|
10
|
-
previewingModelName
|
|
11
|
-
};
|