@builder.io/sdk-solid 3.0.1 → 3.0.2
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 +1 -1
- package/lib/browser/dev.js +96 -55
- package/lib/browser/dev.jsx +140 -103
- package/lib/browser/index.js +96 -55
- package/lib/browser/index.jsx +140 -103
- package/lib/edge/dev.js +97 -58
- package/lib/edge/dev.jsx +141 -106
- package/lib/edge/index.js +97 -58
- package/lib/edge/index.jsx +141 -106
- package/lib/node/dev.js +96 -55
- package/lib/node/dev.jsx +140 -103
- package/lib/node/index.js +96 -55
- package/lib/node/index.jsx +140 -103
- 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),
|
|
@@ -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
|
}
|
|
@@ -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.2";
|
|
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);
|