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