@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/dev.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 MSG_PREFIX = "[Builder.io]: ";
|
|
147
130
|
var logger = {
|
|
@@ -3476,10 +3459,8 @@ var runInEdge = ({
|
|
|
3476
3459
|
return `var ${key} = ${jsonValName} === undefined ? undefined : JSON.parse(${jsonValName});`;
|
|
3477
3460
|
}).join("\n");
|
|
3478
3461
|
const cleanedCode = processCode(code);
|
|
3479
|
-
if (cleanedCode === "")
|
|
3480
|
-
logger.warn("Skipping evaluation of empty code block.");
|
|
3462
|
+
if (cleanedCode === "")
|
|
3481
3463
|
return;
|
|
3482
|
-
}
|
|
3483
3464
|
const transformed = `
|
|
3484
3465
|
function theFunction() {
|
|
3485
3466
|
${prependedCode}
|
|
@@ -3585,6 +3566,38 @@ function evaluate({
|
|
|
3585
3566
|
}
|
|
3586
3567
|
}
|
|
3587
3568
|
|
|
3569
|
+
// src/functions/get-block-component-options.ts
|
|
3570
|
+
function getBlockComponentOptions(block, context) {
|
|
3571
|
+
return {
|
|
3572
|
+
...block.component?.options,
|
|
3573
|
+
...block.options,
|
|
3574
|
+
...evaluateTextComponentTextOption(block, context)
|
|
3575
|
+
};
|
|
3576
|
+
}
|
|
3577
|
+
var evaluateTextComponentTextOption = (block, context) => {
|
|
3578
|
+
if (block.component?.name === "Text" && block.component.options?.text && typeof block.component.options.text === "string") {
|
|
3579
|
+
return {
|
|
3580
|
+
...block.component.options,
|
|
3581
|
+
text: block.component.options.text.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
|
|
3582
|
+
code: group,
|
|
3583
|
+
context,
|
|
3584
|
+
localState: context.localState,
|
|
3585
|
+
rootState: context.rootState,
|
|
3586
|
+
rootSetState: context.rootSetState
|
|
3587
|
+
}))
|
|
3588
|
+
};
|
|
3589
|
+
}
|
|
3590
|
+
};
|
|
3591
|
+
|
|
3592
|
+
// src/helpers/omit.ts
|
|
3593
|
+
function omit(obj, ...values) {
|
|
3594
|
+
const newObject = Object.assign({}, obj);
|
|
3595
|
+
for (const key of values) {
|
|
3596
|
+
delete newObject[key];
|
|
3597
|
+
}
|
|
3598
|
+
return newObject;
|
|
3599
|
+
}
|
|
3600
|
+
|
|
3588
3601
|
// src/functions/traverse.ts
|
|
3589
3602
|
function traverse(obj, callback, parent2 = null, key = null, visited = /* @__PURE__ */ new WeakSet()) {
|
|
3590
3603
|
if (obj == null || typeof obj !== "object") {
|
|
@@ -3749,24 +3762,19 @@ var evaluateBindings = ({
|
|
|
3749
3762
|
function getProcessedBlock({
|
|
3750
3763
|
block,
|
|
3751
3764
|
context,
|
|
3752
|
-
shouldEvaluateBindings,
|
|
3753
3765
|
localState,
|
|
3754
3766
|
rootState,
|
|
3755
3767
|
rootSetState
|
|
3756
3768
|
}) {
|
|
3757
3769
|
let transformedBlock = resolveLocalizedValues(block, rootState.locale);
|
|
3758
3770
|
transformedBlock = transformBlock(transformedBlock);
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
});
|
|
3767
|
-
} else {
|
|
3768
|
-
return transformedBlock;
|
|
3769
|
-
}
|
|
3771
|
+
return evaluateBindings({
|
|
3772
|
+
block: transformedBlock,
|
|
3773
|
+
localState,
|
|
3774
|
+
rootState,
|
|
3775
|
+
rootSetState,
|
|
3776
|
+
context
|
|
3777
|
+
});
|
|
3770
3778
|
}
|
|
3771
3779
|
|
|
3772
3780
|
// src/functions/camel-to-kebab-case.ts
|
|
@@ -4546,8 +4554,7 @@ function Block(props) {
|
|
|
4546
4554
|
localState: props.context.localState,
|
|
4547
4555
|
rootState: props.context.rootState,
|
|
4548
4556
|
rootSetState: props.context.rootSetState,
|
|
4549
|
-
context: props.context.context
|
|
4550
|
-
shouldEvaluateBindings: true
|
|
4557
|
+
context: props.context.context
|
|
4551
4558
|
});
|
|
4552
4559
|
return blockToUse;
|
|
4553
4560
|
});
|
|
@@ -4584,7 +4591,7 @@ function Block(props) {
|
|
|
4584
4591
|
blockChildren: processedBlock().children ?? [],
|
|
4585
4592
|
componentRef: blockComponent()?.component,
|
|
4586
4593
|
componentOptions: {
|
|
4587
|
-
...getBlockComponentOptions(processedBlock()),
|
|
4594
|
+
...getBlockComponentOptions(processedBlock(), props.context),
|
|
4588
4595
|
...provideBuilderBlock(blockComponent(), processedBlock()),
|
|
4589
4596
|
...provideBuilderContext(blockComponent(), props.context),
|
|
4590
4597
|
...provideLinkComponent(blockComponent(), props.linkComponent),
|
|
@@ -4790,7 +4797,7 @@ function Block(props) {
|
|
|
4790
4797
|
});
|
|
4791
4798
|
}
|
|
4792
4799
|
var block_default = Block;
|
|
4793
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-
|
|
4800
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-3c4beb0c {
|
|
4794
4801
|
display: flex;
|
|
4795
4802
|
flex-direction: column;
|
|
4796
4803
|
align-items: stretch;
|
|
@@ -4833,7 +4840,7 @@ function BlocksWrapper(props) {
|
|
|
4833
4840
|
});
|
|
4834
4841
|
return [createComponent(Dynamic, mergeProps({
|
|
4835
4842
|
get ["class"]() {
|
|
4836
|
-
return className() + " dynamic-
|
|
4843
|
+
return className() + " dynamic-3c4beb0c";
|
|
4837
4844
|
},
|
|
4838
4845
|
ref(r$) {
|
|
4839
4846
|
const _ref$ = blocksWrapperRef;
|
|
@@ -4932,7 +4939,7 @@ var getColumnsClass = (id2) => {
|
|
|
4932
4939
|
|
|
4933
4940
|
// src/blocks/columns/columns.tsx
|
|
4934
4941
|
var _tmpl$3 = /* @__PURE__ */ template(`<div>`);
|
|
4935
|
-
var _tmpl$22 = /* @__PURE__ */ template(`<style>.div-
|
|
4942
|
+
var _tmpl$22 = /* @__PURE__ */ template(`<style>.div-3e5f33a4 {
|
|
4936
4943
|
display: flex;
|
|
4937
4944
|
line-height: normal;
|
|
4938
4945
|
}`);
|
|
@@ -5061,7 +5068,7 @@ function Columns(props) {
|
|
|
5061
5068
|
const _el$ = _tmpl$3();
|
|
5062
5069
|
spread(_el$, mergeProps({
|
|
5063
5070
|
get ["class"]() {
|
|
5064
|
-
return getColumnsClass(props.builderBlock?.id) + " div-
|
|
5071
|
+
return getColumnsClass(props.builderBlock?.id) + " div-3e5f33a4";
|
|
5065
5072
|
},
|
|
5066
5073
|
get style() {
|
|
5067
5074
|
return columnsCssVars();
|
|
@@ -5186,16 +5193,16 @@ function getSrcSet(url) {
|
|
|
5186
5193
|
// src/blocks/image/image.tsx
|
|
5187
5194
|
var _tmpl$5 = /* @__PURE__ */ template(`<source type=image/webp>`);
|
|
5188
5195
|
var _tmpl$23 = /* @__PURE__ */ template(`<picture><img>`);
|
|
5189
|
-
var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-
|
|
5190
|
-
var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-
|
|
5191
|
-
var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-
|
|
5196
|
+
var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-56e07140">`);
|
|
5197
|
+
var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-56e07140-2>`);
|
|
5198
|
+
var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-56e07140 {
|
|
5192
5199
|
opacity: 1;
|
|
5193
5200
|
transition: opacity 0.2s ease-in-out;
|
|
5194
|
-
}.div-
|
|
5201
|
+
}.div-56e07140 {
|
|
5195
5202
|
width: 100%;
|
|
5196
5203
|
pointer-events: none;
|
|
5197
5204
|
font-size: 0;
|
|
5198
|
-
}.div-
|
|
5205
|
+
}.div-56e07140-2 {
|
|
5199
5206
|
display: flex;
|
|
5200
5207
|
flex-direction: column;
|
|
5201
5208
|
align-items: stretch;
|
|
@@ -5260,7 +5267,7 @@ function Image(props) {
|
|
|
5260
5267
|
}
|
|
5261
5268
|
}), _el$3);
|
|
5262
5269
|
effect((_p$) => {
|
|
5263
|
-
const _v$ = "builder-image" + (props.className ? " " + props.className : "") + " img-
|
|
5270
|
+
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 = {
|
|
5264
5271
|
"object-position": props.backgroundPosition || "center",
|
|
5265
5272
|
"object-fit": props.backgroundSize || "cover",
|
|
5266
5273
|
...aspectRatioCss()
|
|
@@ -6664,26 +6671,10 @@ var componentInfo10 = {
|
|
|
6664
6671
|
};
|
|
6665
6672
|
var _tmpl$10 = /* @__PURE__ */ template(`<div class=builder-text>`);
|
|
6666
6673
|
function Text(props) {
|
|
6667
|
-
const processedText = createMemo(() => {
|
|
6668
|
-
const context = props.builderContext;
|
|
6669
|
-
const {
|
|
6670
|
-
context: contextContext,
|
|
6671
|
-
localState,
|
|
6672
|
-
rootState,
|
|
6673
|
-
rootSetState
|
|
6674
|
-
} = context;
|
|
6675
|
-
return String(props.text?.toString() || "").replace(/{{([^}]+)}}/g, (match, group) => evaluate({
|
|
6676
|
-
code: group,
|
|
6677
|
-
context: contextContext,
|
|
6678
|
-
localState,
|
|
6679
|
-
rootState,
|
|
6680
|
-
rootSetState
|
|
6681
|
-
}));
|
|
6682
|
-
});
|
|
6683
6674
|
return (() => {
|
|
6684
6675
|
const _el$ = _tmpl$10();
|
|
6685
6676
|
_el$.style.setProperty("outline", "none");
|
|
6686
|
-
effect(() => _el$.innerHTML =
|
|
6677
|
+
effect(() => _el$.innerHTML = props.text?.toString() || "");
|
|
6687
6678
|
return _el$;
|
|
6688
6679
|
})();
|
|
6689
6680
|
}
|
|
@@ -7092,9 +7083,9 @@ function logFetch(url) {
|
|
|
7092
7083
|
}
|
|
7093
7084
|
|
|
7094
7085
|
// src/blocks/form/form/form.tsx
|
|
7095
|
-
var _tmpl$13 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-
|
|
7086
|
+
var _tmpl$13 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-27d18614">`);
|
|
7096
7087
|
var _tmpl$26 = /* @__PURE__ */ template(`<form>`);
|
|
7097
|
-
var _tmpl$34 = /* @__PURE__ */ template(`<style>.pre-
|
|
7088
|
+
var _tmpl$34 = /* @__PURE__ */ template(`<style>.pre-27d18614 {
|
|
7098
7089
|
padding: 10px;
|
|
7099
7090
|
color: red;
|
|
7100
7091
|
text-align: center;
|
|
@@ -8068,7 +8059,7 @@ function getPreviewContent(_searchParams) {
|
|
|
8068
8059
|
}
|
|
8069
8060
|
|
|
8070
8061
|
// src/constants/sdk-version.ts
|
|
8071
|
-
var SDK_VERSION = "3.0.
|
|
8062
|
+
var SDK_VERSION = "3.0.3";
|
|
8072
8063
|
|
|
8073
8064
|
// src/helpers/sdk-headers.ts
|
|
8074
8065
|
var getSdkHeaders = () => ({
|
|
@@ -8133,6 +8124,23 @@ function flattenMongoQuery(obj, _current, _res = {}) {
|
|
|
8133
8124
|
}
|
|
8134
8125
|
return _res;
|
|
8135
8126
|
}
|
|
8127
|
+
function unflatten(obj) {
|
|
8128
|
+
const result = {};
|
|
8129
|
+
for (const key in obj) {
|
|
8130
|
+
const parts = key.split(".");
|
|
8131
|
+
let current = result;
|
|
8132
|
+
for (let i = 0; i < parts.length; i++) {
|
|
8133
|
+
const part = parts[i];
|
|
8134
|
+
if (i === parts.length - 1) {
|
|
8135
|
+
current[part] = obj[key];
|
|
8136
|
+
} else {
|
|
8137
|
+
current[part] = current[part] || {};
|
|
8138
|
+
current = current[part];
|
|
8139
|
+
}
|
|
8140
|
+
}
|
|
8141
|
+
}
|
|
8142
|
+
return result;
|
|
8143
|
+
}
|
|
8136
8144
|
|
|
8137
8145
|
// src/types/api-version.ts
|
|
8138
8146
|
var DEFAULT_API_VERSION = "v3";
|
|
@@ -8197,7 +8205,7 @@ var generateContentUrl = (options) => {
|
|
|
8197
8205
|
url.searchParams.set("noTraverse", String(noTraverse));
|
|
8198
8206
|
url.searchParams.set("includeRefs", String(true));
|
|
8199
8207
|
const finalLocale = locale || userAttributes?.locale;
|
|
8200
|
-
let finalUserAttributes = userAttributes;
|
|
8208
|
+
let finalUserAttributes = userAttributes || {};
|
|
8201
8209
|
if (finalLocale) {
|
|
8202
8210
|
url.searchParams.set("locale", finalLocale);
|
|
8203
8211
|
finalUserAttributes = {
|
|
@@ -8235,11 +8243,15 @@ var generateContentUrl = (options) => {
|
|
|
8235
8243
|
...getBuilderSearchParamsFromWindow(),
|
|
8236
8244
|
...normalizeSearchParams(options.options || {})
|
|
8237
8245
|
};
|
|
8246
|
+
finalUserAttributes = {
|
|
8247
|
+
...finalUserAttributes,
|
|
8248
|
+
...getUserAttributesAsJSON(queryOptions)
|
|
8249
|
+
};
|
|
8238
8250
|
const flattened = flatten(queryOptions);
|
|
8239
8251
|
for (const key in flattened) {
|
|
8240
8252
|
url.searchParams.set(key, String(flattened[key]));
|
|
8241
8253
|
}
|
|
8242
|
-
if (finalUserAttributes) {
|
|
8254
|
+
if (Object.keys(finalUserAttributes).length > 0) {
|
|
8243
8255
|
url.searchParams.set("userAttributes", JSON.stringify(finalUserAttributes));
|
|
8244
8256
|
}
|
|
8245
8257
|
if (query) {
|
|
@@ -8252,6 +8264,28 @@ var generateContentUrl = (options) => {
|
|
|
8252
8264
|
}
|
|
8253
8265
|
return url;
|
|
8254
8266
|
};
|
|
8267
|
+
var getUserAttributesFromQueryOptions = (queryOptions) => {
|
|
8268
|
+
const newUserAttributes = {};
|
|
8269
|
+
for (const key in queryOptions) {
|
|
8270
|
+
if (key.startsWith("userAttributes.")) {
|
|
8271
|
+
newUserAttributes[key] = queryOptions[key];
|
|
8272
|
+
delete queryOptions[key];
|
|
8273
|
+
}
|
|
8274
|
+
}
|
|
8275
|
+
return newUserAttributes;
|
|
8276
|
+
};
|
|
8277
|
+
var getUserAttributesAsJSON = (queryOptions) => {
|
|
8278
|
+
if (isBrowser() && queryOptions["preview"] === "BUILDER_STUDIO") {
|
|
8279
|
+
queryOptions["userAttributes.urlPath"] = window.location.pathname;
|
|
8280
|
+
queryOptions["userAttributes.host"] = window.location.host;
|
|
8281
|
+
const queryOptionsForUserAttributes = getUserAttributesFromQueryOptions(queryOptions);
|
|
8282
|
+
const {
|
|
8283
|
+
userAttributes
|
|
8284
|
+
} = unflatten(queryOptionsForUserAttributes);
|
|
8285
|
+
return userAttributes;
|
|
8286
|
+
}
|
|
8287
|
+
return {};
|
|
8288
|
+
};
|
|
8255
8289
|
|
|
8256
8290
|
// src/functions/get-content/index.ts
|
|
8257
8291
|
var checkContentHasResults = (content) => "results" in content;
|
|
@@ -9053,11 +9087,16 @@ function EnableEditor(props) {
|
|
|
9053
9087
|
const searchParamPreviewModel = searchParams.get("builder.preview");
|
|
9054
9088
|
const searchParamPreviewId = searchParams.get(`builder.overrides.${searchParamPreviewModel}`);
|
|
9055
9089
|
const previewApiKey = searchParams.get("apiKey") || searchParams.get("builder.space");
|
|
9056
|
-
if (searchParamPreviewModel === props.model && previewApiKey === props.apiKey && (!props.content || searchParamPreviewId === props.content.id)) {
|
|
9090
|
+
if (searchParamPreviewModel === "BUILDER_STUDIO" || searchParamPreviewModel === props.model && previewApiKey === props.apiKey && (!props.content || searchParamPreviewId === props.content.id)) {
|
|
9057
9091
|
fetchOneEntry({
|
|
9058
|
-
model: props.model,
|
|
9092
|
+
model: props.model || "",
|
|
9059
9093
|
apiKey: props.apiKey,
|
|
9060
|
-
apiVersion: props.builderContextSignal.apiVersion
|
|
9094
|
+
apiVersion: props.builderContextSignal.apiVersion,
|
|
9095
|
+
...searchParamPreviewModel === "BUILDER_STUDIO" && props.context?.symbolId ? {
|
|
9096
|
+
query: {
|
|
9097
|
+
id: props.context.symbolId
|
|
9098
|
+
}
|
|
9099
|
+
} : {}
|
|
9061
9100
|
}).then((content) => {
|
|
9062
9101
|
if (content) {
|
|
9063
9102
|
mergeNewContent(content);
|