@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/dev.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 = {
|
|
@@ -584,6 +567,38 @@ function evaluate({
|
|
|
584
567
|
}
|
|
585
568
|
}
|
|
586
569
|
|
|
570
|
+
// src/functions/get-block-component-options.ts
|
|
571
|
+
function getBlockComponentOptions(block, context) {
|
|
572
|
+
return {
|
|
573
|
+
...block.component?.options,
|
|
574
|
+
...block.options,
|
|
575
|
+
...evaluateTextComponentTextOption(block, context)
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
var evaluateTextComponentTextOption = (block, context) => {
|
|
579
|
+
if (block.component?.name === "Text" && block.component.options?.text && typeof block.component.options.text === "string") {
|
|
580
|
+
return {
|
|
581
|
+
...block.component.options,
|
|
582
|
+
text: block.component.options.text.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
|
|
583
|
+
code: group,
|
|
584
|
+
context,
|
|
585
|
+
localState: context.localState,
|
|
586
|
+
rootState: context.rootState,
|
|
587
|
+
rootSetState: context.rootSetState
|
|
588
|
+
}))
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
// src/helpers/omit.ts
|
|
594
|
+
function omit(obj, ...values) {
|
|
595
|
+
const newObject = Object.assign({}, obj);
|
|
596
|
+
for (const key of values) {
|
|
597
|
+
delete newObject[key];
|
|
598
|
+
}
|
|
599
|
+
return newObject;
|
|
600
|
+
}
|
|
601
|
+
|
|
587
602
|
// src/functions/traverse.ts
|
|
588
603
|
function traverse(obj, callback, parent2 = null, key = null, visited = /* @__PURE__ */ new WeakSet()) {
|
|
589
604
|
if (obj == null || typeof obj !== "object") {
|
|
@@ -735,24 +750,19 @@ var evaluateBindings = ({
|
|
|
735
750
|
function getProcessedBlock({
|
|
736
751
|
block,
|
|
737
752
|
context,
|
|
738
|
-
shouldEvaluateBindings,
|
|
739
753
|
localState,
|
|
740
754
|
rootState,
|
|
741
755
|
rootSetState
|
|
742
756
|
}) {
|
|
743
757
|
let transformedBlock = resolveLocalizedValues(block, rootState.locale);
|
|
744
758
|
transformedBlock = transformBlock(transformedBlock);
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
});
|
|
753
|
-
} else {
|
|
754
|
-
return transformedBlock;
|
|
755
|
-
}
|
|
759
|
+
return evaluateBindings({
|
|
760
|
+
block: transformedBlock,
|
|
761
|
+
localState,
|
|
762
|
+
rootState,
|
|
763
|
+
rootSetState,
|
|
764
|
+
context
|
|
765
|
+
});
|
|
756
766
|
}
|
|
757
767
|
|
|
758
768
|
// src/functions/camel-to-kebab-case.ts
|
|
@@ -1532,8 +1542,7 @@ function Block(props) {
|
|
|
1532
1542
|
localState: props.context.localState,
|
|
1533
1543
|
rootState: props.context.rootState,
|
|
1534
1544
|
rootSetState: props.context.rootSetState,
|
|
1535
|
-
context: props.context.context
|
|
1536
|
-
shouldEvaluateBindings: true
|
|
1545
|
+
context: props.context.context
|
|
1537
1546
|
});
|
|
1538
1547
|
return blockToUse;
|
|
1539
1548
|
});
|
|
@@ -1570,7 +1579,7 @@ function Block(props) {
|
|
|
1570
1579
|
blockChildren: processedBlock().children ?? [],
|
|
1571
1580
|
componentRef: blockComponent()?.component,
|
|
1572
1581
|
componentOptions: {
|
|
1573
|
-
...getBlockComponentOptions(processedBlock()),
|
|
1582
|
+
...getBlockComponentOptions(processedBlock(), props.context),
|
|
1574
1583
|
...provideBuilderBlock(blockComponent(), processedBlock()),
|
|
1575
1584
|
...provideBuilderContext(blockComponent(), props.context),
|
|
1576
1585
|
...provideLinkComponent(blockComponent(), props.linkComponent),
|
|
@@ -3650,26 +3659,10 @@ var componentInfo10 = {
|
|
|
3650
3659
|
};
|
|
3651
3660
|
var _tmpl$10 = /* @__PURE__ */ template(`<div class=builder-text>`);
|
|
3652
3661
|
function Text(props) {
|
|
3653
|
-
const processedText = createMemo(() => {
|
|
3654
|
-
const context = props.builderContext;
|
|
3655
|
-
const {
|
|
3656
|
-
context: contextContext,
|
|
3657
|
-
localState,
|
|
3658
|
-
rootState,
|
|
3659
|
-
rootSetState
|
|
3660
|
-
} = context;
|
|
3661
|
-
return String(props.text?.toString() || "").replace(/{{([^}]+)}}/g, (match, group) => evaluate({
|
|
3662
|
-
code: group,
|
|
3663
|
-
context: contextContext,
|
|
3664
|
-
localState,
|
|
3665
|
-
rootState,
|
|
3666
|
-
rootSetState
|
|
3667
|
-
}));
|
|
3668
|
-
});
|
|
3669
3662
|
return (() => {
|
|
3670
3663
|
const _el$ = _tmpl$10();
|
|
3671
3664
|
_el$.style.setProperty("outline", "none");
|
|
3672
|
-
effect(() => _el$.innerHTML =
|
|
3665
|
+
effect(() => _el$.innerHTML = props.text?.toString() || "");
|
|
3673
3666
|
return _el$;
|
|
3674
3667
|
})();
|
|
3675
3668
|
}
|
|
@@ -5054,7 +5047,7 @@ function getPreviewContent(_searchParams) {
|
|
|
5054
5047
|
}
|
|
5055
5048
|
|
|
5056
5049
|
// src/constants/sdk-version.ts
|
|
5057
|
-
var SDK_VERSION = "3.0.
|
|
5050
|
+
var SDK_VERSION = "3.0.2";
|
|
5058
5051
|
|
|
5059
5052
|
// src/helpers/sdk-headers.ts
|
|
5060
5053
|
var getSdkHeaders = () => ({
|
|
@@ -5119,6 +5112,23 @@ function flattenMongoQuery(obj, _current, _res = {}) {
|
|
|
5119
5112
|
}
|
|
5120
5113
|
return _res;
|
|
5121
5114
|
}
|
|
5115
|
+
function unflatten(obj) {
|
|
5116
|
+
const result = {};
|
|
5117
|
+
for (const key in obj) {
|
|
5118
|
+
const parts = key.split(".");
|
|
5119
|
+
let current = result;
|
|
5120
|
+
for (let i = 0; i < parts.length; i++) {
|
|
5121
|
+
const part = parts[i];
|
|
5122
|
+
if (i === parts.length - 1) {
|
|
5123
|
+
current[part] = obj[key];
|
|
5124
|
+
} else {
|
|
5125
|
+
current[part] = current[part] || {};
|
|
5126
|
+
current = current[part];
|
|
5127
|
+
}
|
|
5128
|
+
}
|
|
5129
|
+
}
|
|
5130
|
+
return result;
|
|
5131
|
+
}
|
|
5122
5132
|
|
|
5123
5133
|
// src/types/api-version.ts
|
|
5124
5134
|
var DEFAULT_API_VERSION = "v3";
|
|
@@ -5183,7 +5193,7 @@ var generateContentUrl = (options) => {
|
|
|
5183
5193
|
url.searchParams.set("noTraverse", String(noTraverse));
|
|
5184
5194
|
url.searchParams.set("includeRefs", String(true));
|
|
5185
5195
|
const finalLocale = locale || userAttributes?.locale;
|
|
5186
|
-
let finalUserAttributes = userAttributes;
|
|
5196
|
+
let finalUserAttributes = userAttributes || {};
|
|
5187
5197
|
if (finalLocale) {
|
|
5188
5198
|
url.searchParams.set("locale", finalLocale);
|
|
5189
5199
|
finalUserAttributes = {
|
|
@@ -5221,11 +5231,15 @@ var generateContentUrl = (options) => {
|
|
|
5221
5231
|
...getBuilderSearchParamsFromWindow(),
|
|
5222
5232
|
...normalizeSearchParams(options.options || {})
|
|
5223
5233
|
};
|
|
5234
|
+
finalUserAttributes = {
|
|
5235
|
+
...finalUserAttributes,
|
|
5236
|
+
...getUserAttributesAsJSON(queryOptions)
|
|
5237
|
+
};
|
|
5224
5238
|
const flattened = flatten(queryOptions);
|
|
5225
5239
|
for (const key in flattened) {
|
|
5226
5240
|
url.searchParams.set(key, String(flattened[key]));
|
|
5227
5241
|
}
|
|
5228
|
-
if (finalUserAttributes) {
|
|
5242
|
+
if (Object.keys(finalUserAttributes).length > 0) {
|
|
5229
5243
|
url.searchParams.set("userAttributes", JSON.stringify(finalUserAttributes));
|
|
5230
5244
|
}
|
|
5231
5245
|
if (query) {
|
|
@@ -5238,6 +5252,28 @@ var generateContentUrl = (options) => {
|
|
|
5238
5252
|
}
|
|
5239
5253
|
return url;
|
|
5240
5254
|
};
|
|
5255
|
+
var getUserAttributesFromQueryOptions = (queryOptions) => {
|
|
5256
|
+
const newUserAttributes = {};
|
|
5257
|
+
for (const key in queryOptions) {
|
|
5258
|
+
if (key.startsWith("userAttributes.")) {
|
|
5259
|
+
newUserAttributes[key] = queryOptions[key];
|
|
5260
|
+
delete queryOptions[key];
|
|
5261
|
+
}
|
|
5262
|
+
}
|
|
5263
|
+
return newUserAttributes;
|
|
5264
|
+
};
|
|
5265
|
+
var getUserAttributesAsJSON = (queryOptions) => {
|
|
5266
|
+
if (isBrowser() && queryOptions["preview"] === "BUILDER_STUDIO") {
|
|
5267
|
+
queryOptions["userAttributes.urlPath"] = window.location.pathname;
|
|
5268
|
+
queryOptions["userAttributes.host"] = window.location.host;
|
|
5269
|
+
const queryOptionsForUserAttributes = getUserAttributesFromQueryOptions(queryOptions);
|
|
5270
|
+
const {
|
|
5271
|
+
userAttributes
|
|
5272
|
+
} = unflatten(queryOptionsForUserAttributes);
|
|
5273
|
+
return userAttributes;
|
|
5274
|
+
}
|
|
5275
|
+
return {};
|
|
5276
|
+
};
|
|
5241
5277
|
|
|
5242
5278
|
// src/functions/get-content/index.ts
|
|
5243
5279
|
var checkContentHasResults = (content) => "results" in content;
|
|
@@ -6039,11 +6075,16 @@ function EnableEditor(props) {
|
|
|
6039
6075
|
const searchParamPreviewModel = searchParams.get("builder.preview");
|
|
6040
6076
|
const searchParamPreviewId = searchParams.get(`builder.overrides.${searchParamPreviewModel}`);
|
|
6041
6077
|
const previewApiKey = searchParams.get("apiKey") || searchParams.get("builder.space");
|
|
6042
|
-
if (searchParamPreviewModel === props.model && previewApiKey === props.apiKey && (!props.content || searchParamPreviewId === props.content.id)) {
|
|
6078
|
+
if (searchParamPreviewModel === "BUILDER_STUDIO" || searchParamPreviewModel === props.model && previewApiKey === props.apiKey && (!props.content || searchParamPreviewId === props.content.id)) {
|
|
6043
6079
|
fetchOneEntry({
|
|
6044
|
-
model: props.model,
|
|
6080
|
+
model: props.model || "",
|
|
6045
6081
|
apiKey: props.apiKey,
|
|
6046
|
-
apiVersion: props.builderContextSignal.apiVersion
|
|
6082
|
+
apiVersion: props.builderContextSignal.apiVersion,
|
|
6083
|
+
...searchParamPreviewModel === "BUILDER_STUDIO" && props.context?.symbolId ? {
|
|
6084
|
+
query: {
|
|
6085
|
+
id: props.context.symbolId
|
|
6086
|
+
}
|
|
6087
|
+
} : {}
|
|
6047
6088
|
}).then((content) => {
|
|
6048
6089
|
if (content) {
|
|
6049
6090
|
mergeNewContent(content);
|