@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/dist/index.d.ts
CHANGED
|
@@ -478,6 +478,9 @@ interface ComponentInfo {
|
|
|
478
478
|
*/
|
|
479
479
|
builderLinkComponent?: boolean;
|
|
480
480
|
};
|
|
481
|
+
meta?: {
|
|
482
|
+
[key: string]: any;
|
|
483
|
+
};
|
|
481
484
|
}
|
|
482
485
|
type Permission = 'read' | 'publish' | 'editCode' | 'editDesigns' | 'admin' | 'create';
|
|
483
486
|
|
|
@@ -524,6 +527,7 @@ interface BuilderContextInterface extends Pick<BlocksWrapperProps, 'BlocksWrappe
|
|
|
524
527
|
componentInfos: Dictionary<ComponentInfo>;
|
|
525
528
|
inheritedStyles: Record<string, unknown>;
|
|
526
529
|
nonce: string;
|
|
530
|
+
model: string;
|
|
527
531
|
canTrack?: boolean;
|
|
528
532
|
}
|
|
529
533
|
|
|
@@ -761,6 +765,7 @@ declare const _default: solid_js.Context<{
|
|
|
761
765
|
BlocksWrapper: string;
|
|
762
766
|
BlocksWrapperProps: {};
|
|
763
767
|
nonce: string;
|
|
768
|
+
model: string;
|
|
764
769
|
}>;
|
|
765
770
|
|
|
766
771
|
type QueryObject = Record<string, string | string[]>;
|
|
@@ -1088,4 +1093,4 @@ declare const _processContentResult: (options: GetContentOptions, content: Conte
|
|
|
1088
1093
|
*/
|
|
1089
1094
|
declare function fetchEntries(options: GetContentOptions): Promise<BuilderContent[]>;
|
|
1090
1095
|
|
|
1091
|
-
export { Blocks, BlocksProps, BuilderBlock, BuilderContent, _default as BuilderContext, Button, ButtonProps, ColumnProps, Columns, ComponentInfo, ContentVariants as Content, ContentVariantsPrps as ContentProps, FragmentComponent as Fragment, FragmentProps, GetContentOptions, Image, ImageProps, InsertMenuConfig, InsertMenuItem, RegisteredComponent, SectionComponent as Section, SectionProps, Settings, Symbol, SymbolProps, Text, TextProps, Video, VideoProps, _processContentResult, createRegisterComponentMessage, fetchBuilderProps, fetchEntries, fetchOneEntry, getBuilderSearchParams, isEditing, isPreviewing, register, setEditorSettings, subscribeToEditor, track };
|
|
1096
|
+
export { Blocks, BlocksProps, BuilderBlock, BuilderContent, _default as BuilderContext, BuilderContextInterface, Button, ButtonProps, ColumnProps, Columns, ComponentInfo, ContentVariants as Content, ContentVariantsPrps as ContentProps, FragmentComponent as Fragment, FragmentProps, GetContentOptions, Image, ImageProps, InsertMenuConfig, InsertMenuItem, RegisteredComponent, RegisteredComponents, SectionComponent as Section, SectionProps, Settings, Symbol, SymbolProps, Text, TextProps, Video, VideoProps, _processContentResult, createRegisterComponentMessage, fetchBuilderProps, fetchEntries, fetchOneEntry, getBuilderSearchParams, isEditing, isPreviewing, register, setEditorSettings, subscribeToEditor, track };
|
package/lib/browser/dev.js
CHANGED
|
@@ -114,27 +114,11 @@ var builder_context_default = createContext({
|
|
|
114
114
|
inheritedStyles: {},
|
|
115
115
|
BlocksWrapper: "div",
|
|
116
116
|
BlocksWrapperProps: {},
|
|
117
|
-
nonce: ""
|
|
117
|
+
nonce: "",
|
|
118
|
+
model: ""
|
|
118
119
|
});
|
|
119
120
|
var components_context_default = createContext({ registeredComponents: {} });
|
|
120
121
|
|
|
121
|
-
// src/functions/get-block-component-options.ts
|
|
122
|
-
function getBlockComponentOptions(block) {
|
|
123
|
-
return {
|
|
124
|
-
...block.component?.options,
|
|
125
|
-
...block.options
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// src/helpers/omit.ts
|
|
130
|
-
function omit(obj, ...values) {
|
|
131
|
-
const newObject = Object.assign({}, obj);
|
|
132
|
-
for (const key of values) {
|
|
133
|
-
delete newObject[key];
|
|
134
|
-
}
|
|
135
|
-
return newObject;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
122
|
// src/helpers/logger.ts
|
|
139
123
|
var MSG_PREFIX = "[Builder.io]: ";
|
|
140
124
|
var logger = {
|
|
@@ -401,6 +385,109 @@ function evaluate({
|
|
|
401
385
|
}
|
|
402
386
|
}
|
|
403
387
|
|
|
388
|
+
// src/functions/get-block-component-options.ts
|
|
389
|
+
function getBlockComponentOptions(block, context) {
|
|
390
|
+
return {
|
|
391
|
+
...block.component?.options,
|
|
392
|
+
...block.options,
|
|
393
|
+
...evaluateTextComponentTextOption(block, context)
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
var evaluateTextComponentTextOption = (block, context) => {
|
|
397
|
+
if (block.component?.name === "Text" && block.component.options?.text && typeof block.component.options.text === "string") {
|
|
398
|
+
return {
|
|
399
|
+
...block.component.options,
|
|
400
|
+
text: block.component.options.text.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
|
|
401
|
+
code: group,
|
|
402
|
+
context,
|
|
403
|
+
localState: context.localState,
|
|
404
|
+
rootState: context.rootState,
|
|
405
|
+
rootSetState: context.rootSetState
|
|
406
|
+
}))
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
// src/helpers/omit.ts
|
|
412
|
+
function omit(obj, ...values) {
|
|
413
|
+
const newObject = Object.assign({}, obj);
|
|
414
|
+
for (const key of values) {
|
|
415
|
+
delete newObject[key];
|
|
416
|
+
}
|
|
417
|
+
return newObject;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// src/functions/traverse.ts
|
|
421
|
+
function traverse(obj, callback, parent2 = null, key = null, visited = /* @__PURE__ */ new WeakSet()) {
|
|
422
|
+
if (obj == null || typeof obj !== "object") {
|
|
423
|
+
callback(obj, (newValue) => {
|
|
424
|
+
if (parent2 !== null && key !== null) {
|
|
425
|
+
parent2[key] = newValue;
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
if (visited.has(obj)) {
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
visited.add(obj);
|
|
434
|
+
if (Array.isArray(obj)) {
|
|
435
|
+
obj.forEach((item, index) => {
|
|
436
|
+
const update = (newValue) => {
|
|
437
|
+
obj[index] = newValue;
|
|
438
|
+
};
|
|
439
|
+
callback(item, update);
|
|
440
|
+
traverse(item, callback, obj, index, visited);
|
|
441
|
+
});
|
|
442
|
+
} else {
|
|
443
|
+
Object.entries(obj).forEach(([key2, value]) => {
|
|
444
|
+
const update = (newValue) => {
|
|
445
|
+
obj[key2] = newValue;
|
|
446
|
+
};
|
|
447
|
+
callback(value, update);
|
|
448
|
+
traverse(value, callback, obj, key2, visited);
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// src/functions/extract-localized-values.ts
|
|
454
|
+
function isLocalizedField(value) {
|
|
455
|
+
return value && typeof value === "object" && value["@type"] === "@builder.io/core:LocalizedValue";
|
|
456
|
+
}
|
|
457
|
+
function containsLocalizedValues(data) {
|
|
458
|
+
if (!data || !Object.getOwnPropertyNames(data).length) {
|
|
459
|
+
return false;
|
|
460
|
+
}
|
|
461
|
+
let hasLocalizedValues = false;
|
|
462
|
+
traverse(data, (value) => {
|
|
463
|
+
if (isLocalizedField(value)) {
|
|
464
|
+
hasLocalizedValues = true;
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
return hasLocalizedValues;
|
|
469
|
+
}
|
|
470
|
+
function extractLocalizedValues(data, locale) {
|
|
471
|
+
if (!data || !Object.getOwnPropertyNames(data).length) {
|
|
472
|
+
return {};
|
|
473
|
+
}
|
|
474
|
+
traverse(data, (value, update) => {
|
|
475
|
+
if (isLocalizedField(value)) {
|
|
476
|
+
update(value[locale] ?? void 0);
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
return data;
|
|
480
|
+
}
|
|
481
|
+
function resolveLocalizedValues(block, locale) {
|
|
482
|
+
if (block.component?.options && containsLocalizedValues(block.component?.options)) {
|
|
483
|
+
if (!locale) {
|
|
484
|
+
console.warn("[Builder.io] In order to use localized fields in Builder, you must pass a locale prop to the BuilderComponent or to options object while fetching the content to resolve localized fields. Learn more: https://www.builder.io/c/docs/localization-inline#targeting-and-inline-localization");
|
|
485
|
+
}
|
|
486
|
+
block.component.options = extractLocalizedValues(block.component.options, locale ?? "Default");
|
|
487
|
+
}
|
|
488
|
+
return block;
|
|
489
|
+
}
|
|
490
|
+
|
|
404
491
|
// src/functions/fast-clone.ts
|
|
405
492
|
var fastClone = (obj) => JSON.parse(JSON.stringify(obj));
|
|
406
493
|
|
|
@@ -494,23 +581,19 @@ var evaluateBindings = ({
|
|
|
494
581
|
function getProcessedBlock({
|
|
495
582
|
block,
|
|
496
583
|
context,
|
|
497
|
-
shouldEvaluateBindings,
|
|
498
584
|
localState,
|
|
499
585
|
rootState,
|
|
500
586
|
rootSetState
|
|
501
587
|
}) {
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
} else {
|
|
512
|
-
return transformedBlock;
|
|
513
|
-
}
|
|
588
|
+
let transformedBlock = resolveLocalizedValues(block, rootState.locale);
|
|
589
|
+
transformedBlock = transformBlock(transformedBlock);
|
|
590
|
+
return evaluateBindings({
|
|
591
|
+
block: transformedBlock,
|
|
592
|
+
localState,
|
|
593
|
+
rootState,
|
|
594
|
+
rootSetState,
|
|
595
|
+
context
|
|
596
|
+
});
|
|
514
597
|
}
|
|
515
598
|
|
|
516
599
|
// src/functions/camel-to-kebab-case.ts
|
|
@@ -757,16 +840,24 @@ function mapStyleObjToStrIfNeeded(style) {
|
|
|
757
840
|
}
|
|
758
841
|
|
|
759
842
|
// src/components/block/block.helpers.ts
|
|
843
|
+
var checkIsComponentRestricted = (component, model) => {
|
|
844
|
+
if (!component)
|
|
845
|
+
return true;
|
|
846
|
+
if (!model)
|
|
847
|
+
return false;
|
|
848
|
+
return component.models && component.models.length > 0 && !component.models.includes(model);
|
|
849
|
+
};
|
|
760
850
|
var getComponent = ({
|
|
761
851
|
block,
|
|
762
|
-
registeredComponents
|
|
852
|
+
registeredComponents,
|
|
853
|
+
model
|
|
763
854
|
}) => {
|
|
764
855
|
const componentName = block.component?.name;
|
|
765
856
|
if (!componentName) {
|
|
766
857
|
return null;
|
|
767
858
|
}
|
|
768
859
|
const ref = registeredComponents[componentName];
|
|
769
|
-
if (!ref) {
|
|
860
|
+
if (!ref || checkIsComponentRestricted(ref, model)) {
|
|
770
861
|
console.warn(`
|
|
771
862
|
Could not find a registered component named "${componentName}".
|
|
772
863
|
If you registered it, is the file that registered it imported by the file that needs to render it?`);
|
|
@@ -820,11 +911,15 @@ var provideLinkComponent = (block, linkComponent) => {
|
|
|
820
911
|
};
|
|
821
912
|
return {};
|
|
822
913
|
};
|
|
823
|
-
var provideRegisteredComponents = (block, registeredComponents) => {
|
|
824
|
-
if (block?.shouldReceiveBuilderProps?.builderComponents)
|
|
914
|
+
var provideRegisteredComponents = (block, registeredComponents, model) => {
|
|
915
|
+
if (block?.shouldReceiveBuilderProps?.builderComponents) {
|
|
916
|
+
const filteredRegisteredComponents = Object.fromEntries(Object.entries(registeredComponents).filter(([_, component]) => {
|
|
917
|
+
return !checkIsComponentRestricted(component, model);
|
|
918
|
+
}));
|
|
825
919
|
return {
|
|
826
|
-
builderComponents:
|
|
920
|
+
builderComponents: filteredRegisteredComponents
|
|
827
921
|
};
|
|
922
|
+
}
|
|
828
923
|
return {};
|
|
829
924
|
};
|
|
830
925
|
var provideBuilderBlock = (block, builderBlock) => {
|
|
@@ -1278,15 +1373,15 @@ function Block(props) {
|
|
|
1278
1373
|
localState: props.context.localState,
|
|
1279
1374
|
rootState: props.context.rootState,
|
|
1280
1375
|
rootSetState: props.context.rootSetState,
|
|
1281
|
-
context: props.context.context
|
|
1282
|
-
shouldEvaluateBindings: true
|
|
1376
|
+
context: props.context.context
|
|
1283
1377
|
});
|
|
1284
1378
|
return blockToUse;
|
|
1285
1379
|
});
|
|
1286
1380
|
const blockComponent = createMemo(() => {
|
|
1287
1381
|
return getComponent({
|
|
1288
1382
|
block: processedBlock(),
|
|
1289
|
-
registeredComponents: props.registeredComponents
|
|
1383
|
+
registeredComponents: props.registeredComponents,
|
|
1384
|
+
model: props.context.model
|
|
1290
1385
|
});
|
|
1291
1386
|
});
|
|
1292
1387
|
const Tag = createMemo(() => {
|
|
@@ -1315,11 +1410,11 @@ function Block(props) {
|
|
|
1315
1410
|
blockChildren: processedBlock().children ?? [],
|
|
1316
1411
|
componentRef: blockComponent()?.component,
|
|
1317
1412
|
componentOptions: {
|
|
1318
|
-
...getBlockComponentOptions(processedBlock()),
|
|
1413
|
+
...getBlockComponentOptions(processedBlock(), props.context),
|
|
1319
1414
|
...provideBuilderBlock(blockComponent(), processedBlock()),
|
|
1320
1415
|
...provideBuilderContext(blockComponent(), props.context),
|
|
1321
1416
|
...provideLinkComponent(blockComponent(), props.linkComponent),
|
|
1322
|
-
...provideRegisteredComponents(blockComponent(), props.registeredComponents)
|
|
1417
|
+
...provideRegisteredComponents(blockComponent(), props.registeredComponents, props.context.model)
|
|
1323
1418
|
},
|
|
1324
1419
|
context: props.context,
|
|
1325
1420
|
linkComponent: props.linkComponent,
|
|
@@ -1917,16 +2012,16 @@ function getSrcSet(url) {
|
|
|
1917
2012
|
// src/blocks/image/image.tsx
|
|
1918
2013
|
var _tmpl$5 = /* @__PURE__ */ template(`<source type=image/webp>`);
|
|
1919
2014
|
var _tmpl$23 = /* @__PURE__ */ template(`<picture><img>`);
|
|
1920
|
-
var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-
|
|
1921
|
-
var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-
|
|
1922
|
-
var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-
|
|
2015
|
+
var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-070d7e88">`);
|
|
2016
|
+
var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-070d7e88-2>`);
|
|
2017
|
+
var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-070d7e88 {
|
|
1923
2018
|
opacity: 1;
|
|
1924
2019
|
transition: opacity 0.2s ease-in-out;
|
|
1925
|
-
}.div-
|
|
2020
|
+
}.div-070d7e88 {
|
|
1926
2021
|
width: 100%;
|
|
1927
2022
|
pointer-events: none;
|
|
1928
2023
|
font-size: 0;
|
|
1929
|
-
}.div-
|
|
2024
|
+
}.div-070d7e88-2 {
|
|
1930
2025
|
display: flex;
|
|
1931
2026
|
flex-direction: column;
|
|
1932
2027
|
align-items: stretch;
|
|
@@ -1942,7 +2037,7 @@ function Image(props) {
|
|
|
1942
2037
|
const url = imageToUse;
|
|
1943
2038
|
if (!url || // We can auto add srcset for cdn.builder.io and shopify
|
|
1944
2039
|
// images, otherwise you can supply this prop manually
|
|
1945
|
-
!(url.match(/builder\.io/) || url.match(/cdn\.shopify\.com/))) {
|
|
2040
|
+
!(typeof url === "string" && (url.match(/builder\.io/) || url.match(/cdn\.shopify\.com/)))) {
|
|
1946
2041
|
return props.srcset;
|
|
1947
2042
|
}
|
|
1948
2043
|
if (props.noWebp) {
|
|
@@ -1991,7 +2086,7 @@ function Image(props) {
|
|
|
1991
2086
|
}
|
|
1992
2087
|
}), _el$3);
|
|
1993
2088
|
effect((_p$) => {
|
|
1994
|
-
const _v$ = "builder-image" + (props.className ? " " + props.className : "") + " img-
|
|
2089
|
+
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 = {
|
|
1995
2090
|
"object-position": props.backgroundPosition || "center",
|
|
1996
2091
|
"object-fit": props.backgroundSize || "cover",
|
|
1997
2092
|
...aspectRatioCss()
|
|
@@ -2857,6 +2952,10 @@ var componentInfo4 = {
|
|
|
2857
2952
|
noWrap: true
|
|
2858
2953
|
};
|
|
2859
2954
|
|
|
2955
|
+
// src/constants/file-types.ts
|
|
2956
|
+
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"];
|
|
2957
|
+
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"];
|
|
2958
|
+
|
|
2860
2959
|
// src/blocks/image/component-info.ts
|
|
2861
2960
|
var componentInfo5 = {
|
|
2862
2961
|
name: "Image",
|
|
@@ -2873,7 +2972,7 @@ var componentInfo5 = {
|
|
|
2873
2972
|
name: "image",
|
|
2874
2973
|
type: "file",
|
|
2875
2974
|
bubble: true,
|
|
2876
|
-
allowedFileTypes:
|
|
2975
|
+
allowedFileTypes: IMAGE_FILE_TYPES,
|
|
2877
2976
|
required: true,
|
|
2878
2977
|
defaultValue: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F72c80f114dc149019051b6852a9e3b7a",
|
|
2879
2978
|
onChange: (options) => {
|
|
@@ -3391,26 +3490,10 @@ var componentInfo10 = {
|
|
|
3391
3490
|
};
|
|
3392
3491
|
var _tmpl$10 = /* @__PURE__ */ template(`<div class=builder-text>`);
|
|
3393
3492
|
function Text(props) {
|
|
3394
|
-
const processedText = createMemo(() => {
|
|
3395
|
-
const context = props.builderContext;
|
|
3396
|
-
const {
|
|
3397
|
-
context: contextContext,
|
|
3398
|
-
localState,
|
|
3399
|
-
rootState,
|
|
3400
|
-
rootSetState
|
|
3401
|
-
} = context;
|
|
3402
|
-
return String(props.text?.toString() || "").replace(/{{([^}]+)}}/g, (match, group) => evaluate({
|
|
3403
|
-
code: group,
|
|
3404
|
-
context: contextContext,
|
|
3405
|
-
localState,
|
|
3406
|
-
rootState,
|
|
3407
|
-
rootSetState
|
|
3408
|
-
}));
|
|
3409
|
-
});
|
|
3410
3493
|
return (() => {
|
|
3411
3494
|
const _el$ = _tmpl$10();
|
|
3412
3495
|
_el$.style.setProperty("outline", "none");
|
|
3413
|
-
effect(() => _el$.innerHTML =
|
|
3496
|
+
effect(() => _el$.innerHTML = props.text?.toString() || "");
|
|
3414
3497
|
return _el$;
|
|
3415
3498
|
})();
|
|
3416
3499
|
}
|
|
@@ -4405,7 +4488,7 @@ var componentInfo18 = {
|
|
|
4405
4488
|
name: "image",
|
|
4406
4489
|
bubble: true,
|
|
4407
4490
|
type: "file",
|
|
4408
|
-
allowedFileTypes:
|
|
4491
|
+
allowedFileTypes: IMAGE_FILE_TYPES,
|
|
4409
4492
|
required: true
|
|
4410
4493
|
}],
|
|
4411
4494
|
noWrap: true,
|
|
@@ -4449,14 +4532,14 @@ var componentInfo19 = {
|
|
|
4449
4532
|
inputs: [{
|
|
4450
4533
|
name: "video",
|
|
4451
4534
|
type: "file",
|
|
4452
|
-
allowedFileTypes:
|
|
4535
|
+
allowedFileTypes: VIDEO_FILE_TYPES,
|
|
4453
4536
|
bubble: true,
|
|
4454
4537
|
defaultValue: "https://cdn.builder.io/o/assets%2FYJIGb4i01jvw0SRdL5Bt%2Fd27731a526464deba0016216f5f9e570%2Fcompressed?apiKey=YJIGb4i01jvw0SRdL5Bt&token=d27731a526464deba0016216f5f9e570&alt=media&optimized=true",
|
|
4455
4538
|
required: true
|
|
4456
4539
|
}, {
|
|
4457
4540
|
name: "posterImage",
|
|
4458
4541
|
type: "file",
|
|
4459
|
-
allowedFileTypes:
|
|
4542
|
+
allowedFileTypes: IMAGE_FILE_TYPES,
|
|
4460
4543
|
helperText: "Image to show before the video plays"
|
|
4461
4544
|
}, {
|
|
4462
4545
|
name: "autoPlay",
|
|
@@ -4712,7 +4795,7 @@ var createRegisterComponentMessage = (info) => ({
|
|
|
4712
4795
|
var serializeFn = (fnValue) => {
|
|
4713
4796
|
const fnStr = fnValue.toString().trim();
|
|
4714
4797
|
const isArrowWithoutParens = /^[a-zA-Z0-9_]+\s*=>/i.test(fnStr);
|
|
4715
|
-
const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(") && !isArrowWithoutParens;
|
|
4798
|
+
const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("async") && !fnStr.startsWith("(") && !isArrowWithoutParens;
|
|
4716
4799
|
return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
|
|
4717
4800
|
};
|
|
4718
4801
|
function serializeIncludingFunctions(info) {
|
|
@@ -4795,7 +4878,7 @@ function getPreviewContent(_searchParams) {
|
|
|
4795
4878
|
}
|
|
4796
4879
|
|
|
4797
4880
|
// src/constants/sdk-version.ts
|
|
4798
|
-
var SDK_VERSION = "3.0.
|
|
4881
|
+
var SDK_VERSION = "3.0.2";
|
|
4799
4882
|
|
|
4800
4883
|
// src/helpers/sdk-headers.ts
|
|
4801
4884
|
var getSdkHeaders = () => ({
|
|
@@ -4860,6 +4943,23 @@ function flattenMongoQuery(obj, _current, _res = {}) {
|
|
|
4860
4943
|
}
|
|
4861
4944
|
return _res;
|
|
4862
4945
|
}
|
|
4946
|
+
function unflatten(obj) {
|
|
4947
|
+
const result = {};
|
|
4948
|
+
for (const key in obj) {
|
|
4949
|
+
const parts = key.split(".");
|
|
4950
|
+
let current = result;
|
|
4951
|
+
for (let i = 0; i < parts.length; i++) {
|
|
4952
|
+
const part = parts[i];
|
|
4953
|
+
if (i === parts.length - 1) {
|
|
4954
|
+
current[part] = obj[key];
|
|
4955
|
+
} else {
|
|
4956
|
+
current[part] = current[part] || {};
|
|
4957
|
+
current = current[part];
|
|
4958
|
+
}
|
|
4959
|
+
}
|
|
4960
|
+
}
|
|
4961
|
+
return result;
|
|
4962
|
+
}
|
|
4863
4963
|
|
|
4864
4964
|
// src/types/api-version.ts
|
|
4865
4965
|
var DEFAULT_API_VERSION = "v3";
|
|
@@ -4924,7 +5024,7 @@ var generateContentUrl = (options) => {
|
|
|
4924
5024
|
url.searchParams.set("noTraverse", String(noTraverse));
|
|
4925
5025
|
url.searchParams.set("includeRefs", String(true));
|
|
4926
5026
|
const finalLocale = locale || userAttributes?.locale;
|
|
4927
|
-
let finalUserAttributes = userAttributes;
|
|
5027
|
+
let finalUserAttributes = userAttributes || {};
|
|
4928
5028
|
if (finalLocale) {
|
|
4929
5029
|
url.searchParams.set("locale", finalLocale);
|
|
4930
5030
|
finalUserAttributes = {
|
|
@@ -4962,11 +5062,15 @@ var generateContentUrl = (options) => {
|
|
|
4962
5062
|
...getBuilderSearchParamsFromWindow(),
|
|
4963
5063
|
...normalizeSearchParams(options.options || {})
|
|
4964
5064
|
};
|
|
5065
|
+
finalUserAttributes = {
|
|
5066
|
+
...finalUserAttributes,
|
|
5067
|
+
...getUserAttributesAsJSON(queryOptions)
|
|
5068
|
+
};
|
|
4965
5069
|
const flattened = flatten(queryOptions);
|
|
4966
5070
|
for (const key in flattened) {
|
|
4967
5071
|
url.searchParams.set(key, String(flattened[key]));
|
|
4968
5072
|
}
|
|
4969
|
-
if (finalUserAttributes) {
|
|
5073
|
+
if (Object.keys(finalUserAttributes).length > 0) {
|
|
4970
5074
|
url.searchParams.set("userAttributes", JSON.stringify(finalUserAttributes));
|
|
4971
5075
|
}
|
|
4972
5076
|
if (query) {
|
|
@@ -4979,6 +5083,28 @@ var generateContentUrl = (options) => {
|
|
|
4979
5083
|
}
|
|
4980
5084
|
return url;
|
|
4981
5085
|
};
|
|
5086
|
+
var getUserAttributesFromQueryOptions = (queryOptions) => {
|
|
5087
|
+
const newUserAttributes = {};
|
|
5088
|
+
for (const key in queryOptions) {
|
|
5089
|
+
if (key.startsWith("userAttributes.")) {
|
|
5090
|
+
newUserAttributes[key] = queryOptions[key];
|
|
5091
|
+
delete queryOptions[key];
|
|
5092
|
+
}
|
|
5093
|
+
}
|
|
5094
|
+
return newUserAttributes;
|
|
5095
|
+
};
|
|
5096
|
+
var getUserAttributesAsJSON = (queryOptions) => {
|
|
5097
|
+
if (isBrowser() && queryOptions["preview"] === "BUILDER_STUDIO") {
|
|
5098
|
+
queryOptions["userAttributes.urlPath"] = window.location.pathname;
|
|
5099
|
+
queryOptions["userAttributes.host"] = window.location.host;
|
|
5100
|
+
const queryOptionsForUserAttributes = getUserAttributesFromQueryOptions(queryOptions);
|
|
5101
|
+
const {
|
|
5102
|
+
userAttributes
|
|
5103
|
+
} = unflatten(queryOptionsForUserAttributes);
|
|
5104
|
+
return userAttributes;
|
|
5105
|
+
}
|
|
5106
|
+
return {};
|
|
5107
|
+
};
|
|
4982
5108
|
|
|
4983
5109
|
// src/functions/get-content/index.ts
|
|
4984
5110
|
var checkContentHasResults = (content) => "results" in content;
|
|
@@ -5513,6 +5639,12 @@ var subscribeToEditor = (model, callback, options) => {
|
|
|
5513
5639
|
};
|
|
5514
5640
|
};
|
|
5515
5641
|
|
|
5642
|
+
// src/components/content/components/enable-editor.helpers.ts
|
|
5643
|
+
var SDKS_USING_ELEMENT_REF_APPROACH = ["svelte", "qwik", "vue"];
|
|
5644
|
+
var needsElementRefDivForEditing = () => {
|
|
5645
|
+
return SDKS_USING_ELEMENT_REF_APPROACH.includes(TARGET) && (isEditing() || isPreviewing());
|
|
5646
|
+
};
|
|
5647
|
+
|
|
5516
5648
|
// src/components/content/components/styles.helpers.ts
|
|
5517
5649
|
var getCssFromFont = (font) => {
|
|
5518
5650
|
const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
|
|
@@ -5748,8 +5880,10 @@ function EnableEditor(props) {
|
|
|
5748
5880
|
} : {}
|
|
5749
5881
|
});
|
|
5750
5882
|
Object.values(props.builderContextSignal.componentInfos).forEach((registeredComponent) => {
|
|
5751
|
-
|
|
5752
|
-
|
|
5883
|
+
if (!props.model || !registeredComponent.models?.length || registeredComponent.models.includes(props.model)) {
|
|
5884
|
+
const message = createRegisterComponentMessage(registeredComponent);
|
|
5885
|
+
window.parent?.postMessage(message, "*");
|
|
5886
|
+
}
|
|
5753
5887
|
});
|
|
5754
5888
|
window.addEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate);
|
|
5755
5889
|
}
|
|
@@ -5772,11 +5906,16 @@ function EnableEditor(props) {
|
|
|
5772
5906
|
const searchParamPreviewModel = searchParams.get("builder.preview");
|
|
5773
5907
|
const searchParamPreviewId = searchParams.get(`builder.overrides.${searchParamPreviewModel}`);
|
|
5774
5908
|
const previewApiKey = searchParams.get("apiKey") || searchParams.get("builder.space");
|
|
5775
|
-
if (searchParamPreviewModel === props.model && previewApiKey === props.apiKey && (!props.content || searchParamPreviewId === props.content.id)) {
|
|
5909
|
+
if (searchParamPreviewModel === "BUILDER_STUDIO" || searchParamPreviewModel === props.model && previewApiKey === props.apiKey && (!props.content || searchParamPreviewId === props.content.id)) {
|
|
5776
5910
|
fetchOneEntry({
|
|
5777
|
-
model: props.model,
|
|
5911
|
+
model: props.model || "",
|
|
5778
5912
|
apiKey: props.apiKey,
|
|
5779
|
-
apiVersion: props.builderContextSignal.apiVersion
|
|
5913
|
+
apiVersion: props.builderContextSignal.apiVersion,
|
|
5914
|
+
...searchParamPreviewModel === "BUILDER_STUDIO" && props.context?.symbolId ? {
|
|
5915
|
+
query: {
|
|
5916
|
+
id: props.context.symbolId
|
|
5917
|
+
}
|
|
5918
|
+
} : {}
|
|
5780
5919
|
}).then((content) => {
|
|
5781
5920
|
if (content) {
|
|
5782
5921
|
mergeNewContent(content);
|
|
@@ -5821,7 +5960,7 @@ function EnableEditor(props) {
|
|
|
5821
5960
|
get children() {
|
|
5822
5961
|
return createComponent(Show, {
|
|
5823
5962
|
get when() {
|
|
5824
|
-
return props.builderContextSignal.content;
|
|
5963
|
+
return props.builderContextSignal.content || needsElementRefDivForEditing();
|
|
5825
5964
|
},
|
|
5826
5965
|
get children() {
|
|
5827
5966
|
return createComponent(Dynamic, mergeProps({
|
|
@@ -5839,6 +5978,11 @@ function EnableEditor(props) {
|
|
|
5839
5978
|
},
|
|
5840
5979
|
get ["builder-model"]() {
|
|
5841
5980
|
return props.model;
|
|
5981
|
+
},
|
|
5982
|
+
get style() {
|
|
5983
|
+
return {
|
|
5984
|
+
display: !props.builderContextSignal.content && needsElementRefDivForEditing() ? "none" : void 0
|
|
5985
|
+
};
|
|
5842
5986
|
}
|
|
5843
5987
|
}, {}, showContentProps, () => props.contentWrapperProps, {
|
|
5844
5988
|
get component() {
|
|
@@ -5921,15 +6065,7 @@ function ContentComponent(props) {
|
|
|
5921
6065
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
5922
6066
|
contentId: props.content?.id
|
|
5923
6067
|
}));
|
|
5924
|
-
const [registeredComponents, setRegisteredComponents] = createSignal([...getDefaultRegisteredComponents(), ...props.customComponents
|
|
5925
|
-
models
|
|
5926
|
-
}) => {
|
|
5927
|
-
if (!models?.length)
|
|
5928
|
-
return true;
|
|
5929
|
-
if (!props.model)
|
|
5930
|
-
return true;
|
|
5931
|
-
return models.includes(props.model);
|
|
5932
|
-
}) || []].reduce((acc, {
|
|
6068
|
+
const [registeredComponents, setRegisteredComponents] = createSignal([...getDefaultRegisteredComponents(), ...props.customComponents || []].reduce((acc, {
|
|
5933
6069
|
component,
|
|
5934
6070
|
...info
|
|
5935
6071
|
}) => ({
|
|
@@ -5955,15 +6091,7 @@ function ContentComponent(props) {
|
|
|
5955
6091
|
canTrack: props.canTrack,
|
|
5956
6092
|
apiKey: props.apiKey,
|
|
5957
6093
|
apiVersion: props.apiVersion,
|
|
5958
|
-
componentInfos: [...getDefaultRegisteredComponents(), ...props.customComponents
|
|
5959
|
-
models
|
|
5960
|
-
}) => {
|
|
5961
|
-
if (!models?.length)
|
|
5962
|
-
return true;
|
|
5963
|
-
if (!props.model)
|
|
5964
|
-
return true;
|
|
5965
|
-
return models.includes(props.model);
|
|
5966
|
-
}) || []].reduce((acc, {
|
|
6094
|
+
componentInfos: [...getDefaultRegisteredComponents(), ...props.customComponents || []].reduce((acc, {
|
|
5967
6095
|
component: _,
|
|
5968
6096
|
...info
|
|
5969
6097
|
}) => ({
|
|
@@ -5973,7 +6101,8 @@ function ContentComponent(props) {
|
|
|
5973
6101
|
inheritedStyles: {},
|
|
5974
6102
|
BlocksWrapper: props.blocksWrapper || "div",
|
|
5975
6103
|
BlocksWrapperProps: props.blocksWrapperProps || {},
|
|
5976
|
-
nonce: props.nonce || ""
|
|
6104
|
+
nonce: props.nonce || "",
|
|
6105
|
+
model: props.model || ""
|
|
5977
6106
|
});
|
|
5978
6107
|
function contentSetState(newRootState) {
|
|
5979
6108
|
setBuilderContextSignal((PREVIOUS_VALUE) => ({
|