@builder.io/sdk-solid 3.0.1 → 3.0.3
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/dist/index.d.ts +12 -1
- package/lib/browser/dev.js +108 -67
- package/lib/browser/dev.jsx +152 -115
- package/lib/browser/index.js +108 -67
- package/lib/browser/index.jsx +152 -115
- package/lib/edge/dev.js +109 -70
- package/lib/edge/dev.jsx +153 -118
- package/lib/edge/index.js +109 -70
- package/lib/edge/index.jsx +153 -118
- package/lib/node/dev.js +108 -67
- package/lib/node/dev.jsx +152 -115
- package/lib/node/index.js +108 -67
- package/lib/node/index.jsx +152 -115
- package/package.json +1 -1
package/lib/node/index.js
CHANGED
|
@@ -120,23 +120,6 @@ var builder_context_default = createContext({
|
|
|
120
120
|
});
|
|
121
121
|
var components_context_default = createContext({ registeredComponents: {} });
|
|
122
122
|
|
|
123
|
-
// src/functions/get-block-component-options.ts
|
|
124
|
-
function getBlockComponentOptions(block) {
|
|
125
|
-
return {
|
|
126
|
-
...block.component?.options,
|
|
127
|
-
...block.options
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// src/helpers/omit.ts
|
|
132
|
-
function omit(obj, ...values) {
|
|
133
|
-
const newObject = Object.assign({}, obj);
|
|
134
|
-
for (const key of values) {
|
|
135
|
-
delete newObject[key];
|
|
136
|
-
}
|
|
137
|
-
return newObject;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
123
|
// src/helpers/logger.ts
|
|
141
124
|
var MSG_PREFIX = "[Builder.io]: ";
|
|
142
125
|
var logger = {
|
|
@@ -582,6 +565,38 @@ function evaluate({
|
|
|
582
565
|
}
|
|
583
566
|
}
|
|
584
567
|
|
|
568
|
+
// src/functions/get-block-component-options.ts
|
|
569
|
+
function getBlockComponentOptions(block, context) {
|
|
570
|
+
return {
|
|
571
|
+
...block.component?.options,
|
|
572
|
+
...block.options,
|
|
573
|
+
...evaluateTextComponentTextOption(block, context)
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
var evaluateTextComponentTextOption = (block, context) => {
|
|
577
|
+
if (block.component?.name === "Text" && block.component.options?.text && typeof block.component.options.text === "string") {
|
|
578
|
+
return {
|
|
579
|
+
...block.component.options,
|
|
580
|
+
text: block.component.options.text.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
|
|
581
|
+
code: group,
|
|
582
|
+
context,
|
|
583
|
+
localState: context.localState,
|
|
584
|
+
rootState: context.rootState,
|
|
585
|
+
rootSetState: context.rootSetState
|
|
586
|
+
}))
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
};
|
|
590
|
+
|
|
591
|
+
// src/helpers/omit.ts
|
|
592
|
+
function omit(obj, ...values) {
|
|
593
|
+
const newObject = Object.assign({}, obj);
|
|
594
|
+
for (const key of values) {
|
|
595
|
+
delete newObject[key];
|
|
596
|
+
}
|
|
597
|
+
return newObject;
|
|
598
|
+
}
|
|
599
|
+
|
|
585
600
|
// src/functions/traverse.ts
|
|
586
601
|
function traverse(obj, callback, parent2 = null, key = null, visited = /* @__PURE__ */ new WeakSet()) {
|
|
587
602
|
if (obj == null || typeof obj !== "object") {
|
|
@@ -730,24 +745,19 @@ var evaluateBindings = ({
|
|
|
730
745
|
function getProcessedBlock({
|
|
731
746
|
block,
|
|
732
747
|
context,
|
|
733
|
-
shouldEvaluateBindings,
|
|
734
748
|
localState,
|
|
735
749
|
rootState,
|
|
736
750
|
rootSetState
|
|
737
751
|
}) {
|
|
738
752
|
let transformedBlock = resolveLocalizedValues(block, rootState.locale);
|
|
739
753
|
transformedBlock = transformBlock(transformedBlock);
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
});
|
|
748
|
-
} else {
|
|
749
|
-
return transformedBlock;
|
|
750
|
-
}
|
|
754
|
+
return evaluateBindings({
|
|
755
|
+
block: transformedBlock,
|
|
756
|
+
localState,
|
|
757
|
+
rootState,
|
|
758
|
+
rootSetState,
|
|
759
|
+
context
|
|
760
|
+
});
|
|
751
761
|
}
|
|
752
762
|
|
|
753
763
|
// src/functions/camel-to-kebab-case.ts
|
|
@@ -1523,8 +1533,7 @@ function Block(props) {
|
|
|
1523
1533
|
localState: props.context.localState,
|
|
1524
1534
|
rootState: props.context.rootState,
|
|
1525
1535
|
rootSetState: props.context.rootSetState,
|
|
1526
|
-
context: props.context.context
|
|
1527
|
-
shouldEvaluateBindings: true
|
|
1536
|
+
context: props.context.context
|
|
1528
1537
|
});
|
|
1529
1538
|
return blockToUse;
|
|
1530
1539
|
});
|
|
@@ -1561,7 +1570,7 @@ function Block(props) {
|
|
|
1561
1570
|
blockChildren: processedBlock().children ?? [],
|
|
1562
1571
|
componentRef: blockComponent()?.component,
|
|
1563
1572
|
componentOptions: {
|
|
1564
|
-
...getBlockComponentOptions(processedBlock()),
|
|
1573
|
+
...getBlockComponentOptions(processedBlock(), props.context),
|
|
1565
1574
|
...provideBuilderBlock(blockComponent(), processedBlock()),
|
|
1566
1575
|
...provideBuilderContext(blockComponent(), props.context),
|
|
1567
1576
|
...provideLinkComponent(blockComponent(), props.linkComponent),
|
|
@@ -1767,7 +1776,7 @@ function Block(props) {
|
|
|
1767
1776
|
});
|
|
1768
1777
|
}
|
|
1769
1778
|
var block_default = Block;
|
|
1770
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-
|
|
1779
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-3c4beb0c {
|
|
1771
1780
|
display: flex;
|
|
1772
1781
|
flex-direction: column;
|
|
1773
1782
|
align-items: stretch;
|
|
@@ -1810,7 +1819,7 @@ function BlocksWrapper(props) {
|
|
|
1810
1819
|
});
|
|
1811
1820
|
return [createComponent(Dynamic, mergeProps({
|
|
1812
1821
|
get ["class"]() {
|
|
1813
|
-
return className() + " dynamic-
|
|
1822
|
+
return className() + " dynamic-3c4beb0c";
|
|
1814
1823
|
},
|
|
1815
1824
|
ref(r$) {
|
|
1816
1825
|
const _ref$ = blocksWrapperRef;
|
|
@@ -1909,7 +1918,7 @@ var getColumnsClass = (id) => {
|
|
|
1909
1918
|
|
|
1910
1919
|
// src/blocks/columns/columns.tsx
|
|
1911
1920
|
var _tmpl$3 = /* @__PURE__ */ template(`<div>`);
|
|
1912
|
-
var _tmpl$22 = /* @__PURE__ */ template(`<style>.div-
|
|
1921
|
+
var _tmpl$22 = /* @__PURE__ */ template(`<style>.div-3e5f33a4 {
|
|
1913
1922
|
display: flex;
|
|
1914
1923
|
line-height: normal;
|
|
1915
1924
|
}`);
|
|
@@ -2038,7 +2047,7 @@ function Columns(props) {
|
|
|
2038
2047
|
const _el$ = _tmpl$3();
|
|
2039
2048
|
spread(_el$, mergeProps({
|
|
2040
2049
|
get ["class"]() {
|
|
2041
|
-
return getColumnsClass(props.builderBlock?.id) + " div-
|
|
2050
|
+
return getColumnsClass(props.builderBlock?.id) + " div-3e5f33a4";
|
|
2042
2051
|
},
|
|
2043
2052
|
get style() {
|
|
2044
2053
|
return columnsCssVars();
|
|
@@ -2163,16 +2172,16 @@ function getSrcSet(url) {
|
|
|
2163
2172
|
// src/blocks/image/image.tsx
|
|
2164
2173
|
var _tmpl$5 = /* @__PURE__ */ template(`<source type=image/webp>`);
|
|
2165
2174
|
var _tmpl$23 = /* @__PURE__ */ template(`<picture><img>`);
|
|
2166
|
-
var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-
|
|
2167
|
-
var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-
|
|
2168
|
-
var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-
|
|
2175
|
+
var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-56e07140">`);
|
|
2176
|
+
var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-56e07140-2>`);
|
|
2177
|
+
var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-56e07140 {
|
|
2169
2178
|
opacity: 1;
|
|
2170
2179
|
transition: opacity 0.2s ease-in-out;
|
|
2171
|
-
}.div-
|
|
2180
|
+
}.div-56e07140 {
|
|
2172
2181
|
width: 100%;
|
|
2173
2182
|
pointer-events: none;
|
|
2174
2183
|
font-size: 0;
|
|
2175
|
-
}.div-
|
|
2184
|
+
}.div-56e07140-2 {
|
|
2176
2185
|
display: flex;
|
|
2177
2186
|
flex-direction: column;
|
|
2178
2187
|
align-items: stretch;
|
|
@@ -2236,7 +2245,7 @@ function Image(props) {
|
|
|
2236
2245
|
}
|
|
2237
2246
|
}), _el$3);
|
|
2238
2247
|
effect((_p$) => {
|
|
2239
|
-
const _v$ = "builder-image" + (props.className ? " " + props.className : "") + " img-
|
|
2248
|
+
const _v$ = "builder-image" + (props.className ? " " + props.className : "") + " img-56e07140", _v$2 = props.highPriority ? "eager" : "lazy", _v$3 = props.highPriority ? "high" : "auto", _v$4 = props.altText, _v$5 = props.altText ? void 0 : "presentation", _v$6 = {
|
|
2240
2249
|
"object-position": props.backgroundPosition || "center",
|
|
2241
2250
|
"object-fit": props.backgroundSize || "cover",
|
|
2242
2251
|
...aspectRatioCss()
|
|
@@ -3639,26 +3648,10 @@ var componentInfo10 = {
|
|
|
3639
3648
|
};
|
|
3640
3649
|
var _tmpl$10 = /* @__PURE__ */ template(`<div class=builder-text>`);
|
|
3641
3650
|
function Text(props) {
|
|
3642
|
-
const processedText = createMemo(() => {
|
|
3643
|
-
const context = props.builderContext;
|
|
3644
|
-
const {
|
|
3645
|
-
context: contextContext,
|
|
3646
|
-
localState,
|
|
3647
|
-
rootState,
|
|
3648
|
-
rootSetState
|
|
3649
|
-
} = context;
|
|
3650
|
-
return String(props.text?.toString() || "").replace(/{{([^}]+)}}/g, (match, group) => evaluate({
|
|
3651
|
-
code: group,
|
|
3652
|
-
context: contextContext,
|
|
3653
|
-
localState,
|
|
3654
|
-
rootState,
|
|
3655
|
-
rootSetState
|
|
3656
|
-
}));
|
|
3657
|
-
});
|
|
3658
3651
|
return (() => {
|
|
3659
3652
|
const _el$ = _tmpl$10();
|
|
3660
3653
|
_el$.style.setProperty("outline", "none");
|
|
3661
|
-
effect(() => _el$.innerHTML =
|
|
3654
|
+
effect(() => _el$.innerHTML = props.text?.toString() || "");
|
|
3662
3655
|
return _el$;
|
|
3663
3656
|
})();
|
|
3664
3657
|
}
|
|
@@ -4065,9 +4058,9 @@ function logFetch(url) {
|
|
|
4065
4058
|
}
|
|
4066
4059
|
|
|
4067
4060
|
// src/blocks/form/form/form.tsx
|
|
4068
|
-
var _tmpl$13 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-
|
|
4061
|
+
var _tmpl$13 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-27d18614">`);
|
|
4069
4062
|
var _tmpl$26 = /* @__PURE__ */ template(`<form>`);
|
|
4070
|
-
var _tmpl$34 = /* @__PURE__ */ template(`<style>.pre-
|
|
4063
|
+
var _tmpl$34 = /* @__PURE__ */ template(`<style>.pre-27d18614 {
|
|
4071
4064
|
padding: 10px;
|
|
4072
4065
|
color: red;
|
|
4073
4066
|
text-align: center;
|
|
@@ -5041,7 +5034,7 @@ function getPreviewContent(_searchParams) {
|
|
|
5041
5034
|
}
|
|
5042
5035
|
|
|
5043
5036
|
// src/constants/sdk-version.ts
|
|
5044
|
-
var SDK_VERSION = "3.0.
|
|
5037
|
+
var SDK_VERSION = "3.0.3";
|
|
5045
5038
|
|
|
5046
5039
|
// src/helpers/sdk-headers.ts
|
|
5047
5040
|
var getSdkHeaders = () => ({
|
|
@@ -5104,6 +5097,23 @@ function flattenMongoQuery(obj, _current, _res = {}) {
|
|
|
5104
5097
|
}
|
|
5105
5098
|
return _res;
|
|
5106
5099
|
}
|
|
5100
|
+
function unflatten(obj) {
|
|
5101
|
+
const result = {};
|
|
5102
|
+
for (const key in obj) {
|
|
5103
|
+
const parts = key.split(".");
|
|
5104
|
+
let current = result;
|
|
5105
|
+
for (let i = 0; i < parts.length; i++) {
|
|
5106
|
+
const part = parts[i];
|
|
5107
|
+
if (i === parts.length - 1) {
|
|
5108
|
+
current[part] = obj[key];
|
|
5109
|
+
} else {
|
|
5110
|
+
current[part] = current[part] || {};
|
|
5111
|
+
current = current[part];
|
|
5112
|
+
}
|
|
5113
|
+
}
|
|
5114
|
+
}
|
|
5115
|
+
return result;
|
|
5116
|
+
}
|
|
5107
5117
|
|
|
5108
5118
|
// src/types/api-version.ts
|
|
5109
5119
|
var DEFAULT_API_VERSION = "v3";
|
|
@@ -5168,7 +5178,7 @@ var generateContentUrl = (options) => {
|
|
|
5168
5178
|
url.searchParams.set("noTraverse", String(noTraverse));
|
|
5169
5179
|
url.searchParams.set("includeRefs", String(true));
|
|
5170
5180
|
const finalLocale = locale || userAttributes?.locale;
|
|
5171
|
-
let finalUserAttributes = userAttributes;
|
|
5181
|
+
let finalUserAttributes = userAttributes || {};
|
|
5172
5182
|
if (finalLocale) {
|
|
5173
5183
|
url.searchParams.set("locale", finalLocale);
|
|
5174
5184
|
finalUserAttributes = {
|
|
@@ -5206,11 +5216,15 @@ var generateContentUrl = (options) => {
|
|
|
5206
5216
|
...getBuilderSearchParamsFromWindow(),
|
|
5207
5217
|
...normalizeSearchParams(options.options || {})
|
|
5208
5218
|
};
|
|
5219
|
+
finalUserAttributes = {
|
|
5220
|
+
...finalUserAttributes,
|
|
5221
|
+
...getUserAttributesAsJSON(queryOptions)
|
|
5222
|
+
};
|
|
5209
5223
|
const flattened = flatten(queryOptions);
|
|
5210
5224
|
for (const key in flattened) {
|
|
5211
5225
|
url.searchParams.set(key, String(flattened[key]));
|
|
5212
5226
|
}
|
|
5213
|
-
if (finalUserAttributes) {
|
|
5227
|
+
if (Object.keys(finalUserAttributes).length > 0) {
|
|
5214
5228
|
url.searchParams.set("userAttributes", JSON.stringify(finalUserAttributes));
|
|
5215
5229
|
}
|
|
5216
5230
|
if (query) {
|
|
@@ -5223,6 +5237,28 @@ var generateContentUrl = (options) => {
|
|
|
5223
5237
|
}
|
|
5224
5238
|
return url;
|
|
5225
5239
|
};
|
|
5240
|
+
var getUserAttributesFromQueryOptions = (queryOptions) => {
|
|
5241
|
+
const newUserAttributes = {};
|
|
5242
|
+
for (const key in queryOptions) {
|
|
5243
|
+
if (key.startsWith("userAttributes.")) {
|
|
5244
|
+
newUserAttributes[key] = queryOptions[key];
|
|
5245
|
+
delete queryOptions[key];
|
|
5246
|
+
}
|
|
5247
|
+
}
|
|
5248
|
+
return newUserAttributes;
|
|
5249
|
+
};
|
|
5250
|
+
var getUserAttributesAsJSON = (queryOptions) => {
|
|
5251
|
+
if (isBrowser() && queryOptions["preview"] === "BUILDER_STUDIO") {
|
|
5252
|
+
queryOptions["userAttributes.urlPath"] = window.location.pathname;
|
|
5253
|
+
queryOptions["userAttributes.host"] = window.location.host;
|
|
5254
|
+
const queryOptionsForUserAttributes = getUserAttributesFromQueryOptions(queryOptions);
|
|
5255
|
+
const {
|
|
5256
|
+
userAttributes
|
|
5257
|
+
} = unflatten(queryOptionsForUserAttributes);
|
|
5258
|
+
return userAttributes;
|
|
5259
|
+
}
|
|
5260
|
+
return {};
|
|
5261
|
+
};
|
|
5226
5262
|
|
|
5227
5263
|
// src/functions/get-content/index.ts
|
|
5228
5264
|
var checkContentHasResults = (content) => "results" in content;
|
|
@@ -6019,11 +6055,16 @@ function EnableEditor(props) {
|
|
|
6019
6055
|
const searchParamPreviewModel = searchParams.get("builder.preview");
|
|
6020
6056
|
const searchParamPreviewId = searchParams.get(`builder.overrides.${searchParamPreviewModel}`);
|
|
6021
6057
|
const previewApiKey = searchParams.get("apiKey") || searchParams.get("builder.space");
|
|
6022
|
-
if (searchParamPreviewModel === props.model && previewApiKey === props.apiKey && (!props.content || searchParamPreviewId === props.content.id)) {
|
|
6058
|
+
if (searchParamPreviewModel === "BUILDER_STUDIO" || searchParamPreviewModel === props.model && previewApiKey === props.apiKey && (!props.content || searchParamPreviewId === props.content.id)) {
|
|
6023
6059
|
fetchOneEntry({
|
|
6024
|
-
model: props.model,
|
|
6060
|
+
model: props.model || "",
|
|
6025
6061
|
apiKey: props.apiKey,
|
|
6026
|
-
apiVersion: props.builderContextSignal.apiVersion
|
|
6062
|
+
apiVersion: props.builderContextSignal.apiVersion,
|
|
6063
|
+
...searchParamPreviewModel === "BUILDER_STUDIO" && props.context?.symbolId ? {
|
|
6064
|
+
query: {
|
|
6065
|
+
id: props.context.symbolId
|
|
6066
|
+
}
|
|
6067
|
+
} : {}
|
|
6027
6068
|
}).then((content) => {
|
|
6028
6069
|
if (content) {
|
|
6029
6070
|
mergeNewContent(content);
|