@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/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),
|
|
@@ -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
|
}
|
|
@@ -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.2";
|
|
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);
|