@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/edge/index.js
CHANGED
|
@@ -125,23 +125,6 @@ var builder_context_default = createContext({
|
|
|
125
125
|
});
|
|
126
126
|
var components_context_default = createContext({ registeredComponents: {} });
|
|
127
127
|
|
|
128
|
-
// src/functions/get-block-component-options.ts
|
|
129
|
-
function getBlockComponentOptions(block) {
|
|
130
|
-
return {
|
|
131
|
-
...block.component?.options,
|
|
132
|
-
...block.options
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// src/helpers/omit.ts
|
|
137
|
-
function omit(obj, ...values) {
|
|
138
|
-
const newObject = Object.assign({}, obj);
|
|
139
|
-
for (const key of values) {
|
|
140
|
-
delete newObject[key];
|
|
141
|
-
}
|
|
142
|
-
return newObject;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
128
|
// src/helpers/logger.ts
|
|
146
129
|
var logger = {
|
|
147
130
|
log: (...message) => void 0,
|
|
@@ -3474,10 +3457,8 @@ var runInEdge = ({
|
|
|
3474
3457
|
return `var ${key} = ${jsonValName} === undefined ? undefined : JSON.parse(${jsonValName});`;
|
|
3475
3458
|
}).join("\n");
|
|
3476
3459
|
const cleanedCode = processCode(code);
|
|
3477
|
-
if (cleanedCode === "")
|
|
3478
|
-
logger.warn("Skipping evaluation of empty code block.");
|
|
3460
|
+
if (cleanedCode === "")
|
|
3479
3461
|
return;
|
|
3480
|
-
}
|
|
3481
3462
|
const transformed = `
|
|
3482
3463
|
function theFunction() {
|
|
3483
3464
|
${prependedCode}
|
|
@@ -3583,6 +3564,38 @@ function evaluate({
|
|
|
3583
3564
|
}
|
|
3584
3565
|
}
|
|
3585
3566
|
|
|
3567
|
+
// src/functions/get-block-component-options.ts
|
|
3568
|
+
function getBlockComponentOptions(block, context) {
|
|
3569
|
+
return {
|
|
3570
|
+
...block.component?.options,
|
|
3571
|
+
...block.options,
|
|
3572
|
+
...evaluateTextComponentTextOption(block, context)
|
|
3573
|
+
};
|
|
3574
|
+
}
|
|
3575
|
+
var evaluateTextComponentTextOption = (block, context) => {
|
|
3576
|
+
if (block.component?.name === "Text" && block.component.options?.text && typeof block.component.options.text === "string") {
|
|
3577
|
+
return {
|
|
3578
|
+
...block.component.options,
|
|
3579
|
+
text: block.component.options.text.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
|
|
3580
|
+
code: group,
|
|
3581
|
+
context,
|
|
3582
|
+
localState: context.localState,
|
|
3583
|
+
rootState: context.rootState,
|
|
3584
|
+
rootSetState: context.rootSetState
|
|
3585
|
+
}))
|
|
3586
|
+
};
|
|
3587
|
+
}
|
|
3588
|
+
};
|
|
3589
|
+
|
|
3590
|
+
// src/helpers/omit.ts
|
|
3591
|
+
function omit(obj, ...values) {
|
|
3592
|
+
const newObject = Object.assign({}, obj);
|
|
3593
|
+
for (const key of values) {
|
|
3594
|
+
delete newObject[key];
|
|
3595
|
+
}
|
|
3596
|
+
return newObject;
|
|
3597
|
+
}
|
|
3598
|
+
|
|
3586
3599
|
// src/functions/traverse.ts
|
|
3587
3600
|
function traverse(obj, callback, parent2 = null, key = null, visited = /* @__PURE__ */ new WeakSet()) {
|
|
3588
3601
|
if (obj == null || typeof obj !== "object") {
|
|
@@ -3744,24 +3757,19 @@ var evaluateBindings = ({
|
|
|
3744
3757
|
function getProcessedBlock({
|
|
3745
3758
|
block,
|
|
3746
3759
|
context,
|
|
3747
|
-
shouldEvaluateBindings,
|
|
3748
3760
|
localState,
|
|
3749
3761
|
rootState,
|
|
3750
3762
|
rootSetState
|
|
3751
3763
|
}) {
|
|
3752
3764
|
let transformedBlock = resolveLocalizedValues(block, rootState.locale);
|
|
3753
3765
|
transformedBlock = transformBlock(transformedBlock);
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
});
|
|
3762
|
-
} else {
|
|
3763
|
-
return transformedBlock;
|
|
3764
|
-
}
|
|
3766
|
+
return evaluateBindings({
|
|
3767
|
+
block: transformedBlock,
|
|
3768
|
+
localState,
|
|
3769
|
+
rootState,
|
|
3770
|
+
rootSetState,
|
|
3771
|
+
context
|
|
3772
|
+
});
|
|
3765
3773
|
}
|
|
3766
3774
|
|
|
3767
3775
|
// src/functions/camel-to-kebab-case.ts
|
|
@@ -4537,8 +4545,7 @@ function Block(props) {
|
|
|
4537
4545
|
localState: props.context.localState,
|
|
4538
4546
|
rootState: props.context.rootState,
|
|
4539
4547
|
rootSetState: props.context.rootSetState,
|
|
4540
|
-
context: props.context.context
|
|
4541
|
-
shouldEvaluateBindings: true
|
|
4548
|
+
context: props.context.context
|
|
4542
4549
|
});
|
|
4543
4550
|
return blockToUse;
|
|
4544
4551
|
});
|
|
@@ -4575,7 +4582,7 @@ function Block(props) {
|
|
|
4575
4582
|
blockChildren: processedBlock().children ?? [],
|
|
4576
4583
|
componentRef: blockComponent()?.component,
|
|
4577
4584
|
componentOptions: {
|
|
4578
|
-
...getBlockComponentOptions(processedBlock()),
|
|
4585
|
+
...getBlockComponentOptions(processedBlock(), props.context),
|
|
4579
4586
|
...provideBuilderBlock(blockComponent(), processedBlock()),
|
|
4580
4587
|
...provideBuilderContext(blockComponent(), props.context),
|
|
4581
4588
|
...provideLinkComponent(blockComponent(), props.linkComponent),
|
|
@@ -4781,7 +4788,7 @@ function Block(props) {
|
|
|
4781
4788
|
});
|
|
4782
4789
|
}
|
|
4783
4790
|
var block_default = Block;
|
|
4784
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-
|
|
4791
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-3c4beb0c {
|
|
4785
4792
|
display: flex;
|
|
4786
4793
|
flex-direction: column;
|
|
4787
4794
|
align-items: stretch;
|
|
@@ -4824,7 +4831,7 @@ function BlocksWrapper(props) {
|
|
|
4824
4831
|
});
|
|
4825
4832
|
return [createComponent(Dynamic, mergeProps({
|
|
4826
4833
|
get ["class"]() {
|
|
4827
|
-
return className() + " dynamic-
|
|
4834
|
+
return className() + " dynamic-3c4beb0c";
|
|
4828
4835
|
},
|
|
4829
4836
|
ref(r$) {
|
|
4830
4837
|
const _ref$ = blocksWrapperRef;
|
|
@@ -4923,7 +4930,7 @@ var getColumnsClass = (id2) => {
|
|
|
4923
4930
|
|
|
4924
4931
|
// src/blocks/columns/columns.tsx
|
|
4925
4932
|
var _tmpl$3 = /* @__PURE__ */ template(`<div>`);
|
|
4926
|
-
var _tmpl$22 = /* @__PURE__ */ template(`<style>.div-
|
|
4933
|
+
var _tmpl$22 = /* @__PURE__ */ template(`<style>.div-3e5f33a4 {
|
|
4927
4934
|
display: flex;
|
|
4928
4935
|
line-height: normal;
|
|
4929
4936
|
}`);
|
|
@@ -5052,7 +5059,7 @@ function Columns(props) {
|
|
|
5052
5059
|
const _el$ = _tmpl$3();
|
|
5053
5060
|
spread(_el$, mergeProps({
|
|
5054
5061
|
get ["class"]() {
|
|
5055
|
-
return getColumnsClass(props.builderBlock?.id) + " div-
|
|
5062
|
+
return getColumnsClass(props.builderBlock?.id) + " div-3e5f33a4";
|
|
5056
5063
|
},
|
|
5057
5064
|
get style() {
|
|
5058
5065
|
return columnsCssVars();
|
|
@@ -5177,16 +5184,16 @@ function getSrcSet(url) {
|
|
|
5177
5184
|
// src/blocks/image/image.tsx
|
|
5178
5185
|
var _tmpl$5 = /* @__PURE__ */ template(`<source type=image/webp>`);
|
|
5179
5186
|
var _tmpl$23 = /* @__PURE__ */ template(`<picture><img>`);
|
|
5180
|
-
var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-
|
|
5181
|
-
var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-
|
|
5182
|
-
var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-
|
|
5187
|
+
var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-56e07140">`);
|
|
5188
|
+
var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-56e07140-2>`);
|
|
5189
|
+
var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-56e07140 {
|
|
5183
5190
|
opacity: 1;
|
|
5184
5191
|
transition: opacity 0.2s ease-in-out;
|
|
5185
|
-
}.div-
|
|
5192
|
+
}.div-56e07140 {
|
|
5186
5193
|
width: 100%;
|
|
5187
5194
|
pointer-events: none;
|
|
5188
5195
|
font-size: 0;
|
|
5189
|
-
}.div-
|
|
5196
|
+
}.div-56e07140-2 {
|
|
5190
5197
|
display: flex;
|
|
5191
5198
|
flex-direction: column;
|
|
5192
5199
|
align-items: stretch;
|
|
@@ -5250,7 +5257,7 @@ function Image(props) {
|
|
|
5250
5257
|
}
|
|
5251
5258
|
}), _el$3);
|
|
5252
5259
|
effect((_p$) => {
|
|
5253
|
-
const _v$ = "builder-image" + (props.className ? " " + props.className : "") + " img-
|
|
5260
|
+
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 = {
|
|
5254
5261
|
"object-position": props.backgroundPosition || "center",
|
|
5255
5262
|
"object-fit": props.backgroundSize || "cover",
|
|
5256
5263
|
...aspectRatioCss()
|
|
@@ -6653,26 +6660,10 @@ var componentInfo10 = {
|
|
|
6653
6660
|
};
|
|
6654
6661
|
var _tmpl$10 = /* @__PURE__ */ template(`<div class=builder-text>`);
|
|
6655
6662
|
function Text(props) {
|
|
6656
|
-
const processedText = createMemo(() => {
|
|
6657
|
-
const context = props.builderContext;
|
|
6658
|
-
const {
|
|
6659
|
-
context: contextContext,
|
|
6660
|
-
localState,
|
|
6661
|
-
rootState,
|
|
6662
|
-
rootSetState
|
|
6663
|
-
} = context;
|
|
6664
|
-
return String(props.text?.toString() || "").replace(/{{([^}]+)}}/g, (match, group) => evaluate({
|
|
6665
|
-
code: group,
|
|
6666
|
-
context: contextContext,
|
|
6667
|
-
localState,
|
|
6668
|
-
rootState,
|
|
6669
|
-
rootSetState
|
|
6670
|
-
}));
|
|
6671
|
-
});
|
|
6672
6663
|
return (() => {
|
|
6673
6664
|
const _el$ = _tmpl$10();
|
|
6674
6665
|
_el$.style.setProperty("outline", "none");
|
|
6675
|
-
effect(() => _el$.innerHTML =
|
|
6666
|
+
effect(() => _el$.innerHTML = props.text?.toString() || "");
|
|
6676
6667
|
return _el$;
|
|
6677
6668
|
})();
|
|
6678
6669
|
}
|
|
@@ -7079,9 +7070,9 @@ function logFetch(url) {
|
|
|
7079
7070
|
}
|
|
7080
7071
|
|
|
7081
7072
|
// src/blocks/form/form/form.tsx
|
|
7082
|
-
var _tmpl$13 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-
|
|
7073
|
+
var _tmpl$13 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-27d18614">`);
|
|
7083
7074
|
var _tmpl$26 = /* @__PURE__ */ template(`<form>`);
|
|
7084
|
-
var _tmpl$34 = /* @__PURE__ */ template(`<style>.pre-
|
|
7075
|
+
var _tmpl$34 = /* @__PURE__ */ template(`<style>.pre-27d18614 {
|
|
7085
7076
|
padding: 10px;
|
|
7086
7077
|
color: red;
|
|
7087
7078
|
text-align: center;
|
|
@@ -8055,7 +8046,7 @@ function getPreviewContent(_searchParams) {
|
|
|
8055
8046
|
}
|
|
8056
8047
|
|
|
8057
8048
|
// src/constants/sdk-version.ts
|
|
8058
|
-
var SDK_VERSION = "3.0.
|
|
8049
|
+
var SDK_VERSION = "3.0.3";
|
|
8059
8050
|
|
|
8060
8051
|
// src/helpers/sdk-headers.ts
|
|
8061
8052
|
var getSdkHeaders = () => ({
|
|
@@ -8118,6 +8109,23 @@ function flattenMongoQuery(obj, _current, _res = {}) {
|
|
|
8118
8109
|
}
|
|
8119
8110
|
return _res;
|
|
8120
8111
|
}
|
|
8112
|
+
function unflatten(obj) {
|
|
8113
|
+
const result = {};
|
|
8114
|
+
for (const key in obj) {
|
|
8115
|
+
const parts = key.split(".");
|
|
8116
|
+
let current = result;
|
|
8117
|
+
for (let i = 0; i < parts.length; i++) {
|
|
8118
|
+
const part = parts[i];
|
|
8119
|
+
if (i === parts.length - 1) {
|
|
8120
|
+
current[part] = obj[key];
|
|
8121
|
+
} else {
|
|
8122
|
+
current[part] = current[part] || {};
|
|
8123
|
+
current = current[part];
|
|
8124
|
+
}
|
|
8125
|
+
}
|
|
8126
|
+
}
|
|
8127
|
+
return result;
|
|
8128
|
+
}
|
|
8121
8129
|
|
|
8122
8130
|
// src/types/api-version.ts
|
|
8123
8131
|
var DEFAULT_API_VERSION = "v3";
|
|
@@ -8182,7 +8190,7 @@ var generateContentUrl = (options) => {
|
|
|
8182
8190
|
url.searchParams.set("noTraverse", String(noTraverse));
|
|
8183
8191
|
url.searchParams.set("includeRefs", String(true));
|
|
8184
8192
|
const finalLocale = locale || userAttributes?.locale;
|
|
8185
|
-
let finalUserAttributes = userAttributes;
|
|
8193
|
+
let finalUserAttributes = userAttributes || {};
|
|
8186
8194
|
if (finalLocale) {
|
|
8187
8195
|
url.searchParams.set("locale", finalLocale);
|
|
8188
8196
|
finalUserAttributes = {
|
|
@@ -8220,11 +8228,15 @@ var generateContentUrl = (options) => {
|
|
|
8220
8228
|
...getBuilderSearchParamsFromWindow(),
|
|
8221
8229
|
...normalizeSearchParams(options.options || {})
|
|
8222
8230
|
};
|
|
8231
|
+
finalUserAttributes = {
|
|
8232
|
+
...finalUserAttributes,
|
|
8233
|
+
...getUserAttributesAsJSON(queryOptions)
|
|
8234
|
+
};
|
|
8223
8235
|
const flattened = flatten(queryOptions);
|
|
8224
8236
|
for (const key in flattened) {
|
|
8225
8237
|
url.searchParams.set(key, String(flattened[key]));
|
|
8226
8238
|
}
|
|
8227
|
-
if (finalUserAttributes) {
|
|
8239
|
+
if (Object.keys(finalUserAttributes).length > 0) {
|
|
8228
8240
|
url.searchParams.set("userAttributes", JSON.stringify(finalUserAttributes));
|
|
8229
8241
|
}
|
|
8230
8242
|
if (query) {
|
|
@@ -8237,6 +8249,28 @@ var generateContentUrl = (options) => {
|
|
|
8237
8249
|
}
|
|
8238
8250
|
return url;
|
|
8239
8251
|
};
|
|
8252
|
+
var getUserAttributesFromQueryOptions = (queryOptions) => {
|
|
8253
|
+
const newUserAttributes = {};
|
|
8254
|
+
for (const key in queryOptions) {
|
|
8255
|
+
if (key.startsWith("userAttributes.")) {
|
|
8256
|
+
newUserAttributes[key] = queryOptions[key];
|
|
8257
|
+
delete queryOptions[key];
|
|
8258
|
+
}
|
|
8259
|
+
}
|
|
8260
|
+
return newUserAttributes;
|
|
8261
|
+
};
|
|
8262
|
+
var getUserAttributesAsJSON = (queryOptions) => {
|
|
8263
|
+
if (isBrowser() && queryOptions["preview"] === "BUILDER_STUDIO") {
|
|
8264
|
+
queryOptions["userAttributes.urlPath"] = window.location.pathname;
|
|
8265
|
+
queryOptions["userAttributes.host"] = window.location.host;
|
|
8266
|
+
const queryOptionsForUserAttributes = getUserAttributesFromQueryOptions(queryOptions);
|
|
8267
|
+
const {
|
|
8268
|
+
userAttributes
|
|
8269
|
+
} = unflatten(queryOptionsForUserAttributes);
|
|
8270
|
+
return userAttributes;
|
|
8271
|
+
}
|
|
8272
|
+
return {};
|
|
8273
|
+
};
|
|
8240
8274
|
|
|
8241
8275
|
// src/functions/get-content/index.ts
|
|
8242
8276
|
var checkContentHasResults = (content) => "results" in content;
|
|
@@ -9033,11 +9067,16 @@ function EnableEditor(props) {
|
|
|
9033
9067
|
const searchParamPreviewModel = searchParams.get("builder.preview");
|
|
9034
9068
|
const searchParamPreviewId = searchParams.get(`builder.overrides.${searchParamPreviewModel}`);
|
|
9035
9069
|
const previewApiKey = searchParams.get("apiKey") || searchParams.get("builder.space");
|
|
9036
|
-
if (searchParamPreviewModel === props.model && previewApiKey === props.apiKey && (!props.content || searchParamPreviewId === props.content.id)) {
|
|
9070
|
+
if (searchParamPreviewModel === "BUILDER_STUDIO" || searchParamPreviewModel === props.model && previewApiKey === props.apiKey && (!props.content || searchParamPreviewId === props.content.id)) {
|
|
9037
9071
|
fetchOneEntry({
|
|
9038
|
-
model: props.model,
|
|
9072
|
+
model: props.model || "",
|
|
9039
9073
|
apiKey: props.apiKey,
|
|
9040
|
-
apiVersion: props.builderContextSignal.apiVersion
|
|
9074
|
+
apiVersion: props.builderContextSignal.apiVersion,
|
|
9075
|
+
...searchParamPreviewModel === "BUILDER_STUDIO" && props.context?.symbolId ? {
|
|
9076
|
+
query: {
|
|
9077
|
+
id: props.context.symbolId
|
|
9078
|
+
}
|
|
9079
|
+
} : {}
|
|
9041
9080
|
}).then((content) => {
|
|
9042
9081
|
if (content) {
|
|
9043
9082
|
mergeNewContent(content);
|