@builder.io/sdk-solid 3.0.0 → 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 +6 -1
- package/lib/browser/dev.js +227 -98
- package/lib/browser/dev.jsx +272 -142
- package/lib/browser/index.js +224 -98
- package/lib/browser/index.jsx +271 -142
- package/lib/edge/dev.js +228 -101
- package/lib/edge/dev.jsx +273 -145
- package/lib/edge/index.js +225 -101
- package/lib/edge/index.jsx +272 -145
- package/lib/node/dev.js +227 -98
- package/lib/node/dev.jsx +272 -142
- package/lib/node/index.js +224 -98
- package/lib/node/index.jsx +271 -142
- package/package.json +1 -1
package/lib/edge/index.js
CHANGED
|
@@ -120,27 +120,11 @@ var builder_context_default = createContext({
|
|
|
120
120
|
inheritedStyles: {},
|
|
121
121
|
BlocksWrapper: "div",
|
|
122
122
|
BlocksWrapperProps: {},
|
|
123
|
-
nonce: ""
|
|
123
|
+
nonce: "",
|
|
124
|
+
model: ""
|
|
124
125
|
});
|
|
125
126
|
var components_context_default = createContext({ registeredComponents: {} });
|
|
126
127
|
|
|
127
|
-
// src/functions/get-block-component-options.ts
|
|
128
|
-
function getBlockComponentOptions(block) {
|
|
129
|
-
return {
|
|
130
|
-
...block.component?.options,
|
|
131
|
-
...block.options
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// src/helpers/omit.ts
|
|
136
|
-
function omit(obj, ...values) {
|
|
137
|
-
const newObject = Object.assign({}, obj);
|
|
138
|
-
for (const key of values) {
|
|
139
|
-
delete newObject[key];
|
|
140
|
-
}
|
|
141
|
-
return newObject;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
128
|
// src/helpers/logger.ts
|
|
145
129
|
var logger = {
|
|
146
130
|
log: (...message) => void 0,
|
|
@@ -3473,10 +3457,8 @@ var runInEdge = ({
|
|
|
3473
3457
|
return `var ${key} = ${jsonValName} === undefined ? undefined : JSON.parse(${jsonValName});`;
|
|
3474
3458
|
}).join("\n");
|
|
3475
3459
|
const cleanedCode = processCode(code);
|
|
3476
|
-
if (cleanedCode === "")
|
|
3477
|
-
logger.warn("Skipping evaluation of empty code block.");
|
|
3460
|
+
if (cleanedCode === "")
|
|
3478
3461
|
return;
|
|
3479
|
-
}
|
|
3480
3462
|
const transformed = `
|
|
3481
3463
|
function theFunction() {
|
|
3482
3464
|
${prependedCode}
|
|
@@ -3582,6 +3564,106 @@ function evaluate({
|
|
|
3582
3564
|
}
|
|
3583
3565
|
}
|
|
3584
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
|
+
|
|
3599
|
+
// src/functions/traverse.ts
|
|
3600
|
+
function traverse(obj, callback, parent2 = null, key = null, visited = /* @__PURE__ */ new WeakSet()) {
|
|
3601
|
+
if (obj == null || typeof obj !== "object") {
|
|
3602
|
+
callback(obj, (newValue) => {
|
|
3603
|
+
if (parent2 !== null && key !== null) {
|
|
3604
|
+
parent2[key] = newValue;
|
|
3605
|
+
}
|
|
3606
|
+
});
|
|
3607
|
+
return;
|
|
3608
|
+
}
|
|
3609
|
+
if (visited.has(obj)) {
|
|
3610
|
+
return;
|
|
3611
|
+
}
|
|
3612
|
+
visited.add(obj);
|
|
3613
|
+
if (Array.isArray(obj)) {
|
|
3614
|
+
obj.forEach((item, index) => {
|
|
3615
|
+
const update = (newValue) => {
|
|
3616
|
+
obj[index] = newValue;
|
|
3617
|
+
};
|
|
3618
|
+
callback(item, update);
|
|
3619
|
+
traverse(item, callback, obj, index, visited);
|
|
3620
|
+
});
|
|
3621
|
+
} else {
|
|
3622
|
+
Object.entries(obj).forEach(([key2, value]) => {
|
|
3623
|
+
const update = (newValue) => {
|
|
3624
|
+
obj[key2] = newValue;
|
|
3625
|
+
};
|
|
3626
|
+
callback(value, update);
|
|
3627
|
+
traverse(value, callback, obj, key2, visited);
|
|
3628
|
+
});
|
|
3629
|
+
}
|
|
3630
|
+
}
|
|
3631
|
+
|
|
3632
|
+
// src/functions/extract-localized-values.ts
|
|
3633
|
+
function isLocalizedField(value) {
|
|
3634
|
+
return value && typeof value === "object" && value["@type"] === "@builder.io/core:LocalizedValue";
|
|
3635
|
+
}
|
|
3636
|
+
function containsLocalizedValues(data) {
|
|
3637
|
+
if (!data || !Object.getOwnPropertyNames(data).length) {
|
|
3638
|
+
return false;
|
|
3639
|
+
}
|
|
3640
|
+
let hasLocalizedValues = false;
|
|
3641
|
+
traverse(data, (value) => {
|
|
3642
|
+
if (isLocalizedField(value)) {
|
|
3643
|
+
hasLocalizedValues = true;
|
|
3644
|
+
return;
|
|
3645
|
+
}
|
|
3646
|
+
});
|
|
3647
|
+
return hasLocalizedValues;
|
|
3648
|
+
}
|
|
3649
|
+
function extractLocalizedValues(data, locale) {
|
|
3650
|
+
if (!data || !Object.getOwnPropertyNames(data).length) {
|
|
3651
|
+
return {};
|
|
3652
|
+
}
|
|
3653
|
+
traverse(data, (value, update) => {
|
|
3654
|
+
if (isLocalizedField(value)) {
|
|
3655
|
+
update(value[locale] ?? void 0);
|
|
3656
|
+
}
|
|
3657
|
+
});
|
|
3658
|
+
return data;
|
|
3659
|
+
}
|
|
3660
|
+
function resolveLocalizedValues(block, locale) {
|
|
3661
|
+
if (block.component?.options && containsLocalizedValues(block.component?.options)) {
|
|
3662
|
+
block.component.options = extractLocalizedValues(block.component.options, locale ?? "Default");
|
|
3663
|
+
}
|
|
3664
|
+
return block;
|
|
3665
|
+
}
|
|
3666
|
+
|
|
3585
3667
|
// src/functions/fast-clone.ts
|
|
3586
3668
|
var fastClone = (obj) => JSON.parse(JSON.stringify(obj));
|
|
3587
3669
|
|
|
@@ -3675,23 +3757,19 @@ var evaluateBindings = ({
|
|
|
3675
3757
|
function getProcessedBlock({
|
|
3676
3758
|
block,
|
|
3677
3759
|
context,
|
|
3678
|
-
shouldEvaluateBindings,
|
|
3679
3760
|
localState,
|
|
3680
3761
|
rootState,
|
|
3681
3762
|
rootSetState
|
|
3682
3763
|
}) {
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
} else {
|
|
3693
|
-
return transformedBlock;
|
|
3694
|
-
}
|
|
3764
|
+
let transformedBlock = resolveLocalizedValues(block, rootState.locale);
|
|
3765
|
+
transformedBlock = transformBlock(transformedBlock);
|
|
3766
|
+
return evaluateBindings({
|
|
3767
|
+
block: transformedBlock,
|
|
3768
|
+
localState,
|
|
3769
|
+
rootState,
|
|
3770
|
+
rootSetState,
|
|
3771
|
+
context
|
|
3772
|
+
});
|
|
3695
3773
|
}
|
|
3696
3774
|
|
|
3697
3775
|
// src/functions/camel-to-kebab-case.ts
|
|
@@ -3937,16 +4015,24 @@ function mapStyleObjToStrIfNeeded(style) {
|
|
|
3937
4015
|
}
|
|
3938
4016
|
|
|
3939
4017
|
// src/components/block/block.helpers.ts
|
|
4018
|
+
var checkIsComponentRestricted = (component, model) => {
|
|
4019
|
+
if (!component)
|
|
4020
|
+
return true;
|
|
4021
|
+
if (!model)
|
|
4022
|
+
return false;
|
|
4023
|
+
return component.models && component.models.length > 0 && !component.models.includes(model);
|
|
4024
|
+
};
|
|
3940
4025
|
var getComponent = ({
|
|
3941
4026
|
block,
|
|
3942
|
-
registeredComponents
|
|
4027
|
+
registeredComponents,
|
|
4028
|
+
model
|
|
3943
4029
|
}) => {
|
|
3944
4030
|
const componentName = block.component?.name;
|
|
3945
4031
|
if (!componentName) {
|
|
3946
4032
|
return null;
|
|
3947
4033
|
}
|
|
3948
4034
|
const ref = registeredComponents[componentName];
|
|
3949
|
-
if (!ref) {
|
|
4035
|
+
if (!ref || checkIsComponentRestricted(ref, model)) {
|
|
3950
4036
|
return void 0;
|
|
3951
4037
|
} else {
|
|
3952
4038
|
return ref;
|
|
@@ -3997,11 +4083,15 @@ var provideLinkComponent = (block, linkComponent) => {
|
|
|
3997
4083
|
};
|
|
3998
4084
|
return {};
|
|
3999
4085
|
};
|
|
4000
|
-
var provideRegisteredComponents = (block, registeredComponents) => {
|
|
4001
|
-
if (block?.shouldReceiveBuilderProps?.builderComponents)
|
|
4086
|
+
var provideRegisteredComponents = (block, registeredComponents, model) => {
|
|
4087
|
+
if (block?.shouldReceiveBuilderProps?.builderComponents) {
|
|
4088
|
+
const filteredRegisteredComponents = Object.fromEntries(Object.entries(registeredComponents).filter(([_, component]) => {
|
|
4089
|
+
return !checkIsComponentRestricted(component, model);
|
|
4090
|
+
}));
|
|
4002
4091
|
return {
|
|
4003
|
-
builderComponents:
|
|
4092
|
+
builderComponents: filteredRegisteredComponents
|
|
4004
4093
|
};
|
|
4094
|
+
}
|
|
4005
4095
|
return {};
|
|
4006
4096
|
};
|
|
4007
4097
|
var provideBuilderBlock = (block, builderBlock) => {
|
|
@@ -4455,15 +4545,15 @@ function Block(props) {
|
|
|
4455
4545
|
localState: props.context.localState,
|
|
4456
4546
|
rootState: props.context.rootState,
|
|
4457
4547
|
rootSetState: props.context.rootSetState,
|
|
4458
|
-
context: props.context.context
|
|
4459
|
-
shouldEvaluateBindings: true
|
|
4548
|
+
context: props.context.context
|
|
4460
4549
|
});
|
|
4461
4550
|
return blockToUse;
|
|
4462
4551
|
});
|
|
4463
4552
|
const blockComponent = createMemo(() => {
|
|
4464
4553
|
return getComponent({
|
|
4465
4554
|
block: processedBlock(),
|
|
4466
|
-
registeredComponents: props.registeredComponents
|
|
4555
|
+
registeredComponents: props.registeredComponents,
|
|
4556
|
+
model: props.context.model
|
|
4467
4557
|
});
|
|
4468
4558
|
});
|
|
4469
4559
|
const Tag = createMemo(() => {
|
|
@@ -4492,11 +4582,11 @@ function Block(props) {
|
|
|
4492
4582
|
blockChildren: processedBlock().children ?? [],
|
|
4493
4583
|
componentRef: blockComponent()?.component,
|
|
4494
4584
|
componentOptions: {
|
|
4495
|
-
...getBlockComponentOptions(processedBlock()),
|
|
4585
|
+
...getBlockComponentOptions(processedBlock(), props.context),
|
|
4496
4586
|
...provideBuilderBlock(blockComponent(), processedBlock()),
|
|
4497
4587
|
...provideBuilderContext(blockComponent(), props.context),
|
|
4498
4588
|
...provideLinkComponent(blockComponent(), props.linkComponent),
|
|
4499
|
-
...provideRegisteredComponents(blockComponent(), props.registeredComponents)
|
|
4589
|
+
...provideRegisteredComponents(blockComponent(), props.registeredComponents, props.context.model)
|
|
4500
4590
|
},
|
|
4501
4591
|
context: props.context,
|
|
4502
4592
|
linkComponent: props.linkComponent,
|
|
@@ -5094,16 +5184,16 @@ function getSrcSet(url) {
|
|
|
5094
5184
|
// src/blocks/image/image.tsx
|
|
5095
5185
|
var _tmpl$5 = /* @__PURE__ */ template(`<source type=image/webp>`);
|
|
5096
5186
|
var _tmpl$23 = /* @__PURE__ */ template(`<picture><img>`);
|
|
5097
|
-
var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-
|
|
5098
|
-
var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-
|
|
5099
|
-
var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-
|
|
5187
|
+
var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-070d7e88">`);
|
|
5188
|
+
var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-070d7e88-2>`);
|
|
5189
|
+
var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-070d7e88 {
|
|
5100
5190
|
opacity: 1;
|
|
5101
5191
|
transition: opacity 0.2s ease-in-out;
|
|
5102
|
-
}.div-
|
|
5192
|
+
}.div-070d7e88 {
|
|
5103
5193
|
width: 100%;
|
|
5104
5194
|
pointer-events: none;
|
|
5105
5195
|
font-size: 0;
|
|
5106
|
-
}.div-
|
|
5196
|
+
}.div-070d7e88-2 {
|
|
5107
5197
|
display: flex;
|
|
5108
5198
|
flex-direction: column;
|
|
5109
5199
|
align-items: stretch;
|
|
@@ -5119,7 +5209,7 @@ function Image(props) {
|
|
|
5119
5209
|
const url = imageToUse;
|
|
5120
5210
|
if (!url || // We can auto add srcset for cdn.builder.io and shopify
|
|
5121
5211
|
// images, otherwise you can supply this prop manually
|
|
5122
|
-
!(url.match(/builder\.io/) || url.match(/cdn\.shopify\.com/))) {
|
|
5212
|
+
!(typeof url === "string" && (url.match(/builder\.io/) || url.match(/cdn\.shopify\.com/)))) {
|
|
5123
5213
|
return props.srcset;
|
|
5124
5214
|
}
|
|
5125
5215
|
if (props.noWebp) {
|
|
@@ -5167,7 +5257,7 @@ function Image(props) {
|
|
|
5167
5257
|
}
|
|
5168
5258
|
}), _el$3);
|
|
5169
5259
|
effect((_p$) => {
|
|
5170
|
-
const _v$ = "builder-image" + (props.className ? " " + props.className : "") + " img-
|
|
5260
|
+
const _v$ = "builder-image" + (props.className ? " " + props.className : "") + " img-070d7e88", _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 = {
|
|
5171
5261
|
"object-position": props.backgroundPosition || "center",
|
|
5172
5262
|
"object-fit": props.backgroundSize || "cover",
|
|
5173
5263
|
...aspectRatioCss()
|
|
@@ -6033,6 +6123,10 @@ var componentInfo4 = {
|
|
|
6033
6123
|
noWrap: true
|
|
6034
6124
|
};
|
|
6035
6125
|
|
|
6126
|
+
// src/constants/file-types.ts
|
|
6127
|
+
var IMAGE_FILE_TYPES = ["jpeg", "jpg", "png", "svg", "webp", "gif", "jfif", "pjpeg", "pjp", "apng", "avif", "tif", "tiff", "heif", "bmp", "eps", "raw", "cr2", "nef", "orf", "sr2", "psd", "heic", "dib", "ai"];
|
|
6128
|
+
var VIDEO_FILE_TYPES = ["mp4", "webm", "mkv", "flv", "vob", "ogv", "ogg", "drc", "gif", "gifv", "mng", "avi", "mov", "qt", "mts", "m2ts", "ts", "wmv", "yuv", "rm", "rmvb", "viv", "asf", "amv", "m4p", "mpeg", "mpe", "m2v", "m4v", "svi", "3gp", "3g2", "mxf", "roq", "nsv", "f4v", "f4p", "f4a", "f4b"];
|
|
6129
|
+
|
|
6036
6130
|
// src/blocks/image/component-info.ts
|
|
6037
6131
|
var componentInfo5 = {
|
|
6038
6132
|
name: "Image",
|
|
@@ -6049,7 +6143,7 @@ var componentInfo5 = {
|
|
|
6049
6143
|
name: "image",
|
|
6050
6144
|
type: "file",
|
|
6051
6145
|
bubble: true,
|
|
6052
|
-
allowedFileTypes:
|
|
6146
|
+
allowedFileTypes: IMAGE_FILE_TYPES,
|
|
6053
6147
|
required: true,
|
|
6054
6148
|
defaultValue: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F72c80f114dc149019051b6852a9e3b7a",
|
|
6055
6149
|
onChange: (options) => {
|
|
@@ -6566,26 +6660,10 @@ var componentInfo10 = {
|
|
|
6566
6660
|
};
|
|
6567
6661
|
var _tmpl$10 = /* @__PURE__ */ template(`<div class=builder-text>`);
|
|
6568
6662
|
function Text(props) {
|
|
6569
|
-
const processedText = createMemo(() => {
|
|
6570
|
-
const context = props.builderContext;
|
|
6571
|
-
const {
|
|
6572
|
-
context: contextContext,
|
|
6573
|
-
localState,
|
|
6574
|
-
rootState,
|
|
6575
|
-
rootSetState
|
|
6576
|
-
} = context;
|
|
6577
|
-
return String(props.text?.toString() || "").replace(/{{([^}]+)}}/g, (match, group) => evaluate({
|
|
6578
|
-
code: group,
|
|
6579
|
-
context: contextContext,
|
|
6580
|
-
localState,
|
|
6581
|
-
rootState,
|
|
6582
|
-
rootSetState
|
|
6583
|
-
}));
|
|
6584
|
-
});
|
|
6585
6663
|
return (() => {
|
|
6586
6664
|
const _el$ = _tmpl$10();
|
|
6587
6665
|
_el$.style.setProperty("outline", "none");
|
|
6588
|
-
effect(() => _el$.innerHTML =
|
|
6666
|
+
effect(() => _el$.innerHTML = props.text?.toString() || "");
|
|
6589
6667
|
return _el$;
|
|
6590
6668
|
})();
|
|
6591
6669
|
}
|
|
@@ -7578,7 +7656,7 @@ var componentInfo18 = {
|
|
|
7578
7656
|
name: "image",
|
|
7579
7657
|
bubble: true,
|
|
7580
7658
|
type: "file",
|
|
7581
|
-
allowedFileTypes:
|
|
7659
|
+
allowedFileTypes: IMAGE_FILE_TYPES,
|
|
7582
7660
|
required: true
|
|
7583
7661
|
}],
|
|
7584
7662
|
noWrap: true,
|
|
@@ -7622,14 +7700,14 @@ var componentInfo19 = {
|
|
|
7622
7700
|
inputs: [{
|
|
7623
7701
|
name: "video",
|
|
7624
7702
|
type: "file",
|
|
7625
|
-
allowedFileTypes:
|
|
7703
|
+
allowedFileTypes: VIDEO_FILE_TYPES,
|
|
7626
7704
|
bubble: true,
|
|
7627
7705
|
defaultValue: "https://cdn.builder.io/o/assets%2FYJIGb4i01jvw0SRdL5Bt%2Fd27731a526464deba0016216f5f9e570%2Fcompressed?apiKey=YJIGb4i01jvw0SRdL5Bt&token=d27731a526464deba0016216f5f9e570&alt=media&optimized=true",
|
|
7628
7706
|
required: true
|
|
7629
7707
|
}, {
|
|
7630
7708
|
name: "posterImage",
|
|
7631
7709
|
type: "file",
|
|
7632
|
-
allowedFileTypes:
|
|
7710
|
+
allowedFileTypes: IMAGE_FILE_TYPES,
|
|
7633
7711
|
helperText: "Image to show before the video plays"
|
|
7634
7712
|
}, {
|
|
7635
7713
|
name: "autoPlay",
|
|
@@ -7885,7 +7963,7 @@ var createRegisterComponentMessage = (info) => ({
|
|
|
7885
7963
|
var serializeFn = (fnValue) => {
|
|
7886
7964
|
const fnStr = fnValue.toString().trim();
|
|
7887
7965
|
const isArrowWithoutParens = /^[a-zA-Z0-9_]+\s*=>/i.test(fnStr);
|
|
7888
|
-
const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(") && !isArrowWithoutParens;
|
|
7966
|
+
const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("async") && !fnStr.startsWith("(") && !isArrowWithoutParens;
|
|
7889
7967
|
return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
|
|
7890
7968
|
};
|
|
7891
7969
|
function serializeIncludingFunctions(info) {
|
|
@@ -7968,7 +8046,7 @@ function getPreviewContent(_searchParams) {
|
|
|
7968
8046
|
}
|
|
7969
8047
|
|
|
7970
8048
|
// src/constants/sdk-version.ts
|
|
7971
|
-
var SDK_VERSION = "3.0.
|
|
8049
|
+
var SDK_VERSION = "3.0.2";
|
|
7972
8050
|
|
|
7973
8051
|
// src/helpers/sdk-headers.ts
|
|
7974
8052
|
var getSdkHeaders = () => ({
|
|
@@ -8031,6 +8109,23 @@ function flattenMongoQuery(obj, _current, _res = {}) {
|
|
|
8031
8109
|
}
|
|
8032
8110
|
return _res;
|
|
8033
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
|
+
}
|
|
8034
8129
|
|
|
8035
8130
|
// src/types/api-version.ts
|
|
8036
8131
|
var DEFAULT_API_VERSION = "v3";
|
|
@@ -8095,7 +8190,7 @@ var generateContentUrl = (options) => {
|
|
|
8095
8190
|
url.searchParams.set("noTraverse", String(noTraverse));
|
|
8096
8191
|
url.searchParams.set("includeRefs", String(true));
|
|
8097
8192
|
const finalLocale = locale || userAttributes?.locale;
|
|
8098
|
-
let finalUserAttributes = userAttributes;
|
|
8193
|
+
let finalUserAttributes = userAttributes || {};
|
|
8099
8194
|
if (finalLocale) {
|
|
8100
8195
|
url.searchParams.set("locale", finalLocale);
|
|
8101
8196
|
finalUserAttributes = {
|
|
@@ -8133,11 +8228,15 @@ var generateContentUrl = (options) => {
|
|
|
8133
8228
|
...getBuilderSearchParamsFromWindow(),
|
|
8134
8229
|
...normalizeSearchParams(options.options || {})
|
|
8135
8230
|
};
|
|
8231
|
+
finalUserAttributes = {
|
|
8232
|
+
...finalUserAttributes,
|
|
8233
|
+
...getUserAttributesAsJSON(queryOptions)
|
|
8234
|
+
};
|
|
8136
8235
|
const flattened = flatten(queryOptions);
|
|
8137
8236
|
for (const key in flattened) {
|
|
8138
8237
|
url.searchParams.set(key, String(flattened[key]));
|
|
8139
8238
|
}
|
|
8140
|
-
if (finalUserAttributes) {
|
|
8239
|
+
if (Object.keys(finalUserAttributes).length > 0) {
|
|
8141
8240
|
url.searchParams.set("userAttributes", JSON.stringify(finalUserAttributes));
|
|
8142
8241
|
}
|
|
8143
8242
|
if (query) {
|
|
@@ -8150,6 +8249,28 @@ var generateContentUrl = (options) => {
|
|
|
8150
8249
|
}
|
|
8151
8250
|
return url;
|
|
8152
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
|
+
};
|
|
8153
8274
|
|
|
8154
8275
|
// src/functions/get-content/index.ts
|
|
8155
8276
|
var checkContentHasResults = (content) => "results" in content;
|
|
@@ -8680,6 +8801,12 @@ var subscribeToEditor = (model, callback, options) => {
|
|
|
8680
8801
|
};
|
|
8681
8802
|
};
|
|
8682
8803
|
|
|
8804
|
+
// src/components/content/components/enable-editor.helpers.ts
|
|
8805
|
+
var SDKS_USING_ELEMENT_REF_APPROACH = ["svelte", "qwik", "vue"];
|
|
8806
|
+
var needsElementRefDivForEditing = () => {
|
|
8807
|
+
return SDKS_USING_ELEMENT_REF_APPROACH.includes(TARGET) && (isEditing() || isPreviewing());
|
|
8808
|
+
};
|
|
8809
|
+
|
|
8683
8810
|
// src/components/content/components/styles.helpers.ts
|
|
8684
8811
|
var getCssFromFont = (font) => {
|
|
8685
8812
|
const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
|
|
@@ -8914,8 +9041,10 @@ function EnableEditor(props) {
|
|
|
8914
9041
|
} : {}
|
|
8915
9042
|
});
|
|
8916
9043
|
Object.values(props.builderContextSignal.componentInfos).forEach((registeredComponent) => {
|
|
8917
|
-
|
|
8918
|
-
|
|
9044
|
+
if (!props.model || !registeredComponent.models?.length || registeredComponent.models.includes(props.model)) {
|
|
9045
|
+
const message = createRegisterComponentMessage(registeredComponent);
|
|
9046
|
+
window.parent?.postMessage(message, "*");
|
|
9047
|
+
}
|
|
8919
9048
|
});
|
|
8920
9049
|
window.addEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate);
|
|
8921
9050
|
}
|
|
@@ -8938,11 +9067,16 @@ function EnableEditor(props) {
|
|
|
8938
9067
|
const searchParamPreviewModel = searchParams.get("builder.preview");
|
|
8939
9068
|
const searchParamPreviewId = searchParams.get(`builder.overrides.${searchParamPreviewModel}`);
|
|
8940
9069
|
const previewApiKey = searchParams.get("apiKey") || searchParams.get("builder.space");
|
|
8941
|
-
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)) {
|
|
8942
9071
|
fetchOneEntry({
|
|
8943
|
-
model: props.model,
|
|
9072
|
+
model: props.model || "",
|
|
8944
9073
|
apiKey: props.apiKey,
|
|
8945
|
-
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
|
+
} : {}
|
|
8946
9080
|
}).then((content) => {
|
|
8947
9081
|
if (content) {
|
|
8948
9082
|
mergeNewContent(content);
|
|
@@ -8987,7 +9121,7 @@ function EnableEditor(props) {
|
|
|
8987
9121
|
get children() {
|
|
8988
9122
|
return createComponent(Show, {
|
|
8989
9123
|
get when() {
|
|
8990
|
-
return props.builderContextSignal.content;
|
|
9124
|
+
return props.builderContextSignal.content || needsElementRefDivForEditing();
|
|
8991
9125
|
},
|
|
8992
9126
|
get children() {
|
|
8993
9127
|
return createComponent(Dynamic, mergeProps({
|
|
@@ -9005,6 +9139,11 @@ function EnableEditor(props) {
|
|
|
9005
9139
|
},
|
|
9006
9140
|
get ["builder-model"]() {
|
|
9007
9141
|
return props.model;
|
|
9142
|
+
},
|
|
9143
|
+
get style() {
|
|
9144
|
+
return {
|
|
9145
|
+
display: !props.builderContextSignal.content && needsElementRefDivForEditing() ? "none" : void 0
|
|
9146
|
+
};
|
|
9008
9147
|
}
|
|
9009
9148
|
}, {}, showContentProps, () => props.contentWrapperProps, {
|
|
9010
9149
|
get component() {
|
|
@@ -9087,15 +9226,7 @@ function ContentComponent(props) {
|
|
|
9087
9226
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
9088
9227
|
contentId: props.content?.id
|
|
9089
9228
|
}));
|
|
9090
|
-
const [registeredComponents, setRegisteredComponents] = createSignal([...getDefaultRegisteredComponents(), ...props.customComponents
|
|
9091
|
-
models
|
|
9092
|
-
}) => {
|
|
9093
|
-
if (!models?.length)
|
|
9094
|
-
return true;
|
|
9095
|
-
if (!props.model)
|
|
9096
|
-
return true;
|
|
9097
|
-
return models.includes(props.model);
|
|
9098
|
-
}) || []].reduce((acc, {
|
|
9229
|
+
const [registeredComponents, setRegisteredComponents] = createSignal([...getDefaultRegisteredComponents(), ...props.customComponents || []].reduce((acc, {
|
|
9099
9230
|
component,
|
|
9100
9231
|
...info
|
|
9101
9232
|
}) => ({
|
|
@@ -9121,15 +9252,7 @@ function ContentComponent(props) {
|
|
|
9121
9252
|
canTrack: props.canTrack,
|
|
9122
9253
|
apiKey: props.apiKey,
|
|
9123
9254
|
apiVersion: props.apiVersion,
|
|
9124
|
-
componentInfos: [...getDefaultRegisteredComponents(), ...props.customComponents
|
|
9125
|
-
models
|
|
9126
|
-
}) => {
|
|
9127
|
-
if (!models?.length)
|
|
9128
|
-
return true;
|
|
9129
|
-
if (!props.model)
|
|
9130
|
-
return true;
|
|
9131
|
-
return models.includes(props.model);
|
|
9132
|
-
}) || []].reduce((acc, {
|
|
9255
|
+
componentInfos: [...getDefaultRegisteredComponents(), ...props.customComponents || []].reduce((acc, {
|
|
9133
9256
|
component: _,
|
|
9134
9257
|
...info
|
|
9135
9258
|
}) => ({
|
|
@@ -9139,7 +9262,8 @@ function ContentComponent(props) {
|
|
|
9139
9262
|
inheritedStyles: {},
|
|
9140
9263
|
BlocksWrapper: props.blocksWrapper || "div",
|
|
9141
9264
|
BlocksWrapperProps: props.blocksWrapperProps || {},
|
|
9142
|
-
nonce: props.nonce || ""
|
|
9265
|
+
nonce: props.nonce || "",
|
|
9266
|
+
model: props.model || ""
|
|
9143
9267
|
});
|
|
9144
9268
|
function contentSetState(newRootState) {
|
|
9145
9269
|
setBuilderContextSignal((PREVIOUS_VALUE) => ({
|