@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/browser/index.js
CHANGED
|
@@ -119,23 +119,6 @@ var builder_context_default = createContext({
|
|
|
119
119
|
});
|
|
120
120
|
var components_context_default = createContext({ registeredComponents: {} });
|
|
121
121
|
|
|
122
|
-
// src/functions/get-block-component-options.ts
|
|
123
|
-
function getBlockComponentOptions(block) {
|
|
124
|
-
return {
|
|
125
|
-
...block.component?.options,
|
|
126
|
-
...block.options
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// src/helpers/omit.ts
|
|
131
|
-
function omit(obj, ...values) {
|
|
132
|
-
const newObject = Object.assign({}, obj);
|
|
133
|
-
for (const key of values) {
|
|
134
|
-
delete newObject[key];
|
|
135
|
-
}
|
|
136
|
-
return newObject;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
122
|
// src/helpers/logger.ts
|
|
140
123
|
var logger = {
|
|
141
124
|
log: (...message) => void 0,
|
|
@@ -400,6 +383,38 @@ function evaluate({
|
|
|
400
383
|
}
|
|
401
384
|
}
|
|
402
385
|
|
|
386
|
+
// src/functions/get-block-component-options.ts
|
|
387
|
+
function getBlockComponentOptions(block, context) {
|
|
388
|
+
return {
|
|
389
|
+
...block.component?.options,
|
|
390
|
+
...block.options,
|
|
391
|
+
...evaluateTextComponentTextOption(block, context)
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
var evaluateTextComponentTextOption = (block, context) => {
|
|
395
|
+
if (block.component?.name === "Text" && block.component.options?.text && typeof block.component.options.text === "string") {
|
|
396
|
+
return {
|
|
397
|
+
...block.component.options,
|
|
398
|
+
text: block.component.options.text.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
|
|
399
|
+
code: group,
|
|
400
|
+
context,
|
|
401
|
+
localState: context.localState,
|
|
402
|
+
rootState: context.rootState,
|
|
403
|
+
rootSetState: context.rootSetState
|
|
404
|
+
}))
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
// src/helpers/omit.ts
|
|
410
|
+
function omit(obj, ...values) {
|
|
411
|
+
const newObject = Object.assign({}, obj);
|
|
412
|
+
for (const key of values) {
|
|
413
|
+
delete newObject[key];
|
|
414
|
+
}
|
|
415
|
+
return newObject;
|
|
416
|
+
}
|
|
417
|
+
|
|
403
418
|
// src/functions/traverse.ts
|
|
404
419
|
function traverse(obj, callback, parent2 = null, key = null, visited = /* @__PURE__ */ new WeakSet()) {
|
|
405
420
|
if (obj == null || typeof obj !== "object") {
|
|
@@ -561,24 +576,19 @@ var evaluateBindings = ({
|
|
|
561
576
|
function getProcessedBlock({
|
|
562
577
|
block,
|
|
563
578
|
context,
|
|
564
|
-
shouldEvaluateBindings,
|
|
565
579
|
localState,
|
|
566
580
|
rootState,
|
|
567
581
|
rootSetState
|
|
568
582
|
}) {
|
|
569
583
|
let transformedBlock = resolveLocalizedValues(block, rootState.locale);
|
|
570
584
|
transformedBlock = transformBlock(transformedBlock);
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
});
|
|
579
|
-
} else {
|
|
580
|
-
return transformedBlock;
|
|
581
|
-
}
|
|
585
|
+
return evaluateBindings({
|
|
586
|
+
block: transformedBlock,
|
|
587
|
+
localState,
|
|
588
|
+
rootState,
|
|
589
|
+
rootSetState,
|
|
590
|
+
context
|
|
591
|
+
});
|
|
582
592
|
}
|
|
583
593
|
|
|
584
594
|
// src/functions/camel-to-kebab-case.ts
|
|
@@ -1354,8 +1364,7 @@ function Block(props) {
|
|
|
1354
1364
|
localState: props.context.localState,
|
|
1355
1365
|
rootState: props.context.rootState,
|
|
1356
1366
|
rootSetState: props.context.rootSetState,
|
|
1357
|
-
context: props.context.context
|
|
1358
|
-
shouldEvaluateBindings: true
|
|
1367
|
+
context: props.context.context
|
|
1359
1368
|
});
|
|
1360
1369
|
return blockToUse;
|
|
1361
1370
|
});
|
|
@@ -1392,7 +1401,7 @@ function Block(props) {
|
|
|
1392
1401
|
blockChildren: processedBlock().children ?? [],
|
|
1393
1402
|
componentRef: blockComponent()?.component,
|
|
1394
1403
|
componentOptions: {
|
|
1395
|
-
...getBlockComponentOptions(processedBlock()),
|
|
1404
|
+
...getBlockComponentOptions(processedBlock(), props.context),
|
|
1396
1405
|
...provideBuilderBlock(blockComponent(), processedBlock()),
|
|
1397
1406
|
...provideBuilderContext(blockComponent(), props.context),
|
|
1398
1407
|
...provideLinkComponent(blockComponent(), props.linkComponent),
|
|
@@ -1598,7 +1607,7 @@ function Block(props) {
|
|
|
1598
1607
|
});
|
|
1599
1608
|
}
|
|
1600
1609
|
var block_default = Block;
|
|
1601
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-
|
|
1610
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-3c4beb0c {
|
|
1602
1611
|
display: flex;
|
|
1603
1612
|
flex-direction: column;
|
|
1604
1613
|
align-items: stretch;
|
|
@@ -1641,7 +1650,7 @@ function BlocksWrapper(props) {
|
|
|
1641
1650
|
});
|
|
1642
1651
|
return [createComponent(Dynamic, mergeProps({
|
|
1643
1652
|
get ["class"]() {
|
|
1644
|
-
return className() + " dynamic-
|
|
1653
|
+
return className() + " dynamic-3c4beb0c";
|
|
1645
1654
|
},
|
|
1646
1655
|
ref(r$) {
|
|
1647
1656
|
const _ref$ = blocksWrapperRef;
|
|
@@ -1740,7 +1749,7 @@ var getColumnsClass = (id) => {
|
|
|
1740
1749
|
|
|
1741
1750
|
// src/blocks/columns/columns.tsx
|
|
1742
1751
|
var _tmpl$3 = /* @__PURE__ */ template(`<div>`);
|
|
1743
|
-
var _tmpl$22 = /* @__PURE__ */ template(`<style>.div-
|
|
1752
|
+
var _tmpl$22 = /* @__PURE__ */ template(`<style>.div-3e5f33a4 {
|
|
1744
1753
|
display: flex;
|
|
1745
1754
|
line-height: normal;
|
|
1746
1755
|
}`);
|
|
@@ -1869,7 +1878,7 @@ function Columns(props) {
|
|
|
1869
1878
|
const _el$ = _tmpl$3();
|
|
1870
1879
|
spread(_el$, mergeProps({
|
|
1871
1880
|
get ["class"]() {
|
|
1872
|
-
return getColumnsClass(props.builderBlock?.id) + " div-
|
|
1881
|
+
return getColumnsClass(props.builderBlock?.id) + " div-3e5f33a4";
|
|
1873
1882
|
},
|
|
1874
1883
|
get style() {
|
|
1875
1884
|
return columnsCssVars();
|
|
@@ -1994,16 +2003,16 @@ function getSrcSet(url) {
|
|
|
1994
2003
|
// src/blocks/image/image.tsx
|
|
1995
2004
|
var _tmpl$5 = /* @__PURE__ */ template(`<source type=image/webp>`);
|
|
1996
2005
|
var _tmpl$23 = /* @__PURE__ */ template(`<picture><img>`);
|
|
1997
|
-
var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-
|
|
1998
|
-
var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-
|
|
1999
|
-
var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-
|
|
2006
|
+
var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-56e07140">`);
|
|
2007
|
+
var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-56e07140-2>`);
|
|
2008
|
+
var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-56e07140 {
|
|
2000
2009
|
opacity: 1;
|
|
2001
2010
|
transition: opacity 0.2s ease-in-out;
|
|
2002
|
-
}.div-
|
|
2011
|
+
}.div-56e07140 {
|
|
2003
2012
|
width: 100%;
|
|
2004
2013
|
pointer-events: none;
|
|
2005
2014
|
font-size: 0;
|
|
2006
|
-
}.div-
|
|
2015
|
+
}.div-56e07140-2 {
|
|
2007
2016
|
display: flex;
|
|
2008
2017
|
flex-direction: column;
|
|
2009
2018
|
align-items: stretch;
|
|
@@ -2067,7 +2076,7 @@ function Image(props) {
|
|
|
2067
2076
|
}
|
|
2068
2077
|
}), _el$3);
|
|
2069
2078
|
effect((_p$) => {
|
|
2070
|
-
const _v$ = "builder-image" + (props.className ? " " + props.className : "") + " img-
|
|
2079
|
+
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 = {
|
|
2071
2080
|
"object-position": props.backgroundPosition || "center",
|
|
2072
2081
|
"object-fit": props.backgroundSize || "cover",
|
|
2073
2082
|
...aspectRatioCss()
|
|
@@ -3470,26 +3479,10 @@ var componentInfo10 = {
|
|
|
3470
3479
|
};
|
|
3471
3480
|
var _tmpl$10 = /* @__PURE__ */ template(`<div class=builder-text>`);
|
|
3472
3481
|
function Text(props) {
|
|
3473
|
-
const processedText = createMemo(() => {
|
|
3474
|
-
const context = props.builderContext;
|
|
3475
|
-
const {
|
|
3476
|
-
context: contextContext,
|
|
3477
|
-
localState,
|
|
3478
|
-
rootState,
|
|
3479
|
-
rootSetState
|
|
3480
|
-
} = context;
|
|
3481
|
-
return String(props.text?.toString() || "").replace(/{{([^}]+)}}/g, (match, group) => evaluate({
|
|
3482
|
-
code: group,
|
|
3483
|
-
context: contextContext,
|
|
3484
|
-
localState,
|
|
3485
|
-
rootState,
|
|
3486
|
-
rootSetState
|
|
3487
|
-
}));
|
|
3488
|
-
});
|
|
3489
3482
|
return (() => {
|
|
3490
3483
|
const _el$ = _tmpl$10();
|
|
3491
3484
|
_el$.style.setProperty("outline", "none");
|
|
3492
|
-
effect(() => _el$.innerHTML =
|
|
3485
|
+
effect(() => _el$.innerHTML = props.text?.toString() || "");
|
|
3493
3486
|
return _el$;
|
|
3494
3487
|
})();
|
|
3495
3488
|
}
|
|
@@ -3896,9 +3889,9 @@ function logFetch(url) {
|
|
|
3896
3889
|
}
|
|
3897
3890
|
|
|
3898
3891
|
// src/blocks/form/form/form.tsx
|
|
3899
|
-
var _tmpl$13 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-
|
|
3892
|
+
var _tmpl$13 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-27d18614">`);
|
|
3900
3893
|
var _tmpl$26 = /* @__PURE__ */ template(`<form>`);
|
|
3901
|
-
var _tmpl$34 = /* @__PURE__ */ template(`<style>.pre-
|
|
3894
|
+
var _tmpl$34 = /* @__PURE__ */ template(`<style>.pre-27d18614 {
|
|
3902
3895
|
padding: 10px;
|
|
3903
3896
|
color: red;
|
|
3904
3897
|
text-align: center;
|
|
@@ -4872,7 +4865,7 @@ function getPreviewContent(_searchParams) {
|
|
|
4872
4865
|
}
|
|
4873
4866
|
|
|
4874
4867
|
// src/constants/sdk-version.ts
|
|
4875
|
-
var SDK_VERSION = "3.0.
|
|
4868
|
+
var SDK_VERSION = "3.0.3";
|
|
4876
4869
|
|
|
4877
4870
|
// src/helpers/sdk-headers.ts
|
|
4878
4871
|
var getSdkHeaders = () => ({
|
|
@@ -4935,6 +4928,23 @@ function flattenMongoQuery(obj, _current, _res = {}) {
|
|
|
4935
4928
|
}
|
|
4936
4929
|
return _res;
|
|
4937
4930
|
}
|
|
4931
|
+
function unflatten(obj) {
|
|
4932
|
+
const result = {};
|
|
4933
|
+
for (const key in obj) {
|
|
4934
|
+
const parts = key.split(".");
|
|
4935
|
+
let current = result;
|
|
4936
|
+
for (let i = 0; i < parts.length; i++) {
|
|
4937
|
+
const part = parts[i];
|
|
4938
|
+
if (i === parts.length - 1) {
|
|
4939
|
+
current[part] = obj[key];
|
|
4940
|
+
} else {
|
|
4941
|
+
current[part] = current[part] || {};
|
|
4942
|
+
current = current[part];
|
|
4943
|
+
}
|
|
4944
|
+
}
|
|
4945
|
+
}
|
|
4946
|
+
return result;
|
|
4947
|
+
}
|
|
4938
4948
|
|
|
4939
4949
|
// src/types/api-version.ts
|
|
4940
4950
|
var DEFAULT_API_VERSION = "v3";
|
|
@@ -4999,7 +5009,7 @@ var generateContentUrl = (options) => {
|
|
|
4999
5009
|
url.searchParams.set("noTraverse", String(noTraverse));
|
|
5000
5010
|
url.searchParams.set("includeRefs", String(true));
|
|
5001
5011
|
const finalLocale = locale || userAttributes?.locale;
|
|
5002
|
-
let finalUserAttributes = userAttributes;
|
|
5012
|
+
let finalUserAttributes = userAttributes || {};
|
|
5003
5013
|
if (finalLocale) {
|
|
5004
5014
|
url.searchParams.set("locale", finalLocale);
|
|
5005
5015
|
finalUserAttributes = {
|
|
@@ -5037,11 +5047,15 @@ var generateContentUrl = (options) => {
|
|
|
5037
5047
|
...getBuilderSearchParamsFromWindow(),
|
|
5038
5048
|
...normalizeSearchParams(options.options || {})
|
|
5039
5049
|
};
|
|
5050
|
+
finalUserAttributes = {
|
|
5051
|
+
...finalUserAttributes,
|
|
5052
|
+
...getUserAttributesAsJSON(queryOptions)
|
|
5053
|
+
};
|
|
5040
5054
|
const flattened = flatten(queryOptions);
|
|
5041
5055
|
for (const key in flattened) {
|
|
5042
5056
|
url.searchParams.set(key, String(flattened[key]));
|
|
5043
5057
|
}
|
|
5044
|
-
if (finalUserAttributes) {
|
|
5058
|
+
if (Object.keys(finalUserAttributes).length > 0) {
|
|
5045
5059
|
url.searchParams.set("userAttributes", JSON.stringify(finalUserAttributes));
|
|
5046
5060
|
}
|
|
5047
5061
|
if (query) {
|
|
@@ -5054,6 +5068,28 @@ var generateContentUrl = (options) => {
|
|
|
5054
5068
|
}
|
|
5055
5069
|
return url;
|
|
5056
5070
|
};
|
|
5071
|
+
var getUserAttributesFromQueryOptions = (queryOptions) => {
|
|
5072
|
+
const newUserAttributes = {};
|
|
5073
|
+
for (const key in queryOptions) {
|
|
5074
|
+
if (key.startsWith("userAttributes.")) {
|
|
5075
|
+
newUserAttributes[key] = queryOptions[key];
|
|
5076
|
+
delete queryOptions[key];
|
|
5077
|
+
}
|
|
5078
|
+
}
|
|
5079
|
+
return newUserAttributes;
|
|
5080
|
+
};
|
|
5081
|
+
var getUserAttributesAsJSON = (queryOptions) => {
|
|
5082
|
+
if (isBrowser() && queryOptions["preview"] === "BUILDER_STUDIO") {
|
|
5083
|
+
queryOptions["userAttributes.urlPath"] = window.location.pathname;
|
|
5084
|
+
queryOptions["userAttributes.host"] = window.location.host;
|
|
5085
|
+
const queryOptionsForUserAttributes = getUserAttributesFromQueryOptions(queryOptions);
|
|
5086
|
+
const {
|
|
5087
|
+
userAttributes
|
|
5088
|
+
} = unflatten(queryOptionsForUserAttributes);
|
|
5089
|
+
return userAttributes;
|
|
5090
|
+
}
|
|
5091
|
+
return {};
|
|
5092
|
+
};
|
|
5057
5093
|
|
|
5058
5094
|
// src/functions/get-content/index.ts
|
|
5059
5095
|
var checkContentHasResults = (content) => "results" in content;
|
|
@@ -5850,11 +5886,16 @@ function EnableEditor(props) {
|
|
|
5850
5886
|
const searchParamPreviewModel = searchParams.get("builder.preview");
|
|
5851
5887
|
const searchParamPreviewId = searchParams.get(`builder.overrides.${searchParamPreviewModel}`);
|
|
5852
5888
|
const previewApiKey = searchParams.get("apiKey") || searchParams.get("builder.space");
|
|
5853
|
-
if (searchParamPreviewModel === props.model && previewApiKey === props.apiKey && (!props.content || searchParamPreviewId === props.content.id)) {
|
|
5889
|
+
if (searchParamPreviewModel === "BUILDER_STUDIO" || searchParamPreviewModel === props.model && previewApiKey === props.apiKey && (!props.content || searchParamPreviewId === props.content.id)) {
|
|
5854
5890
|
fetchOneEntry({
|
|
5855
|
-
model: props.model,
|
|
5891
|
+
model: props.model || "",
|
|
5856
5892
|
apiKey: props.apiKey,
|
|
5857
|
-
apiVersion: props.builderContextSignal.apiVersion
|
|
5893
|
+
apiVersion: props.builderContextSignal.apiVersion,
|
|
5894
|
+
...searchParamPreviewModel === "BUILDER_STUDIO" && props.context?.symbolId ? {
|
|
5895
|
+
query: {
|
|
5896
|
+
id: props.context.symbolId
|
|
5897
|
+
}
|
|
5898
|
+
} : {}
|
|
5858
5899
|
}).then((content) => {
|
|
5859
5900
|
if (content) {
|
|
5860
5901
|
mergeNewContent(content);
|