@builder.io/sdk-solid 0.7.1-1 → 0.7.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 +924 -25
- package/lib/browser/dev.js +1592 -2071
- package/lib/browser/dev.jsx +1629 -2134
- package/lib/browser/index.js +1573 -2052
- package/lib/browser/index.jsx +1624 -2129
- package/lib/edge/dev.js +1825 -2322
- package/lib/edge/dev.jsx +1787 -2310
- package/lib/edge/index.js +1758 -2255
- package/lib/edge/index.jsx +1786 -2309
- package/lib/node/dev.js +1748 -2245
- package/lib/node/dev.jsx +1628 -2149
- package/lib/node/index.js +1656 -2153
- package/lib/node/index.jsx +1640 -2161
- package/package.json +1 -1
package/lib/browser/index.js
CHANGED
|
@@ -2,8 +2,8 @@ import { createComponent, spread, mergeProps, insert, effect, setAttribute, clas
|
|
|
2
2
|
import { createContext, Show, useContext, For, createSignal, onMount, createEffect, on } from 'solid-js';
|
|
3
3
|
import { css } from 'solid-styled-components';
|
|
4
4
|
|
|
5
|
-
// src/blocks/button/button.
|
|
6
|
-
var _tmpl$ = /* @__PURE__ */ template(`<a
|
|
5
|
+
// src/blocks/button/button.tsx
|
|
6
|
+
var _tmpl$ = /* @__PURE__ */ template(`<a>`);
|
|
7
7
|
var _tmpl$2 = /* @__PURE__ */ template(`<button>`);
|
|
8
8
|
function Button(props) {
|
|
9
9
|
return createComponent(Show, {
|
|
@@ -36,7 +36,8 @@ function Button(props) {
|
|
|
36
36
|
},
|
|
37
37
|
get target() {
|
|
38
38
|
return props.openLinkInNewTab ? "_blank" : void 0;
|
|
39
|
-
}
|
|
39
|
+
},
|
|
40
|
+
"role": "button"
|
|
40
41
|
}), false, true);
|
|
41
42
|
insert(_el$, () => props.text);
|
|
42
43
|
return _el$;
|
|
@@ -44,62 +45,33 @@ function Button(props) {
|
|
|
44
45
|
});
|
|
45
46
|
}
|
|
46
47
|
var button_default = Button;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
var SIZES = {
|
|
53
|
-
small: {
|
|
54
|
-
min: 320,
|
|
55
|
-
default: 321,
|
|
56
|
-
max: 640
|
|
57
|
-
},
|
|
58
|
-
medium: {
|
|
59
|
-
min: 641,
|
|
60
|
-
default: 642,
|
|
61
|
-
max: 991
|
|
48
|
+
var builder_context_default = createContext({
|
|
49
|
+
content: null,
|
|
50
|
+
context: {},
|
|
51
|
+
localState: void 0,
|
|
52
|
+
rootSetState() {
|
|
62
53
|
},
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
var
|
|
70
|
-
var getSizesForBreakpoints = ({
|
|
71
|
-
small,
|
|
72
|
-
medium
|
|
73
|
-
}) => {
|
|
74
|
-
const newSizes = fastClone(SIZES);
|
|
75
|
-
if (!small || !medium) {
|
|
76
|
-
return newSizes;
|
|
77
|
-
}
|
|
78
|
-
const smallMin = Math.floor(small / 2);
|
|
79
|
-
newSizes.small = {
|
|
80
|
-
max: small,
|
|
81
|
-
min: smallMin,
|
|
82
|
-
default: smallMin + 1
|
|
83
|
-
};
|
|
84
|
-
const mediumMin = newSizes.small.max + 1;
|
|
85
|
-
newSizes.medium = {
|
|
86
|
-
max: medium,
|
|
87
|
-
min: mediumMin,
|
|
88
|
-
default: mediumMin + 1
|
|
89
|
-
};
|
|
90
|
-
const largeMin = newSizes.medium.max + 1;
|
|
91
|
-
newSizes.large = {
|
|
92
|
-
max: 2e3,
|
|
93
|
-
min: largeMin,
|
|
94
|
-
default: largeMin + 1
|
|
95
|
-
};
|
|
96
|
-
return newSizes;
|
|
97
|
-
};
|
|
54
|
+
rootState: {},
|
|
55
|
+
apiKey: null,
|
|
56
|
+
apiVersion: void 0,
|
|
57
|
+
componentInfos: {},
|
|
58
|
+
inheritedStyles: {}
|
|
59
|
+
});
|
|
60
|
+
var components_context_default = createContext({ registeredComponents: {} });
|
|
98
61
|
|
|
99
|
-
// src/
|
|
100
|
-
|
|
62
|
+
// src/functions/get-block-component-options.ts
|
|
63
|
+
function getBlockComponentOptions(block) {
|
|
64
|
+
return {
|
|
65
|
+
...block.component?.options,
|
|
66
|
+
...block.options,
|
|
67
|
+
/**
|
|
68
|
+
* Our built-in components frequently make use of the block, so we provide all of it under `builderBlock`
|
|
69
|
+
*/
|
|
70
|
+
builderBlock: block
|
|
71
|
+
};
|
|
72
|
+
}
|
|
101
73
|
|
|
102
|
-
// src/helpers/logger.
|
|
74
|
+
// src/helpers/logger.ts
|
|
103
75
|
var logger = {
|
|
104
76
|
log: (...message) => void 0,
|
|
105
77
|
error: (...message) => void 0,
|
|
@@ -107,22 +79,25 @@ var logger = {
|
|
|
107
79
|
debug: (...message) => void 0
|
|
108
80
|
};
|
|
109
81
|
|
|
110
|
-
// src/functions/is-browser.
|
|
82
|
+
// src/functions/is-browser.ts
|
|
111
83
|
function isBrowser() {
|
|
112
84
|
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
113
85
|
}
|
|
114
86
|
|
|
115
|
-
// src/
|
|
87
|
+
// src/constants/target.ts
|
|
88
|
+
var TARGET = "solid";
|
|
89
|
+
|
|
90
|
+
// src/functions/is-iframe.ts
|
|
116
91
|
function isIframe() {
|
|
117
92
|
return isBrowser() && window.self !== window.top;
|
|
118
93
|
}
|
|
119
94
|
|
|
120
|
-
// src/functions/is-editing.
|
|
95
|
+
// src/functions/is-editing.ts
|
|
121
96
|
function isEditing() {
|
|
122
97
|
return isIframe() && (TARGET === "reactNative" || window.location.search.indexOf("builder.frameEditing=") !== -1);
|
|
123
98
|
}
|
|
124
99
|
|
|
125
|
-
// src/functions/track/helpers.
|
|
100
|
+
// src/functions/track/helpers.ts
|
|
126
101
|
var getLocation = () => {
|
|
127
102
|
if (TARGET === "reactNative") {
|
|
128
103
|
return null;
|
|
@@ -162,13 +137,13 @@ var getUserAttributes = () => {
|
|
|
162
137
|
const isTablet = userAgent.match(/Tablet|iPad/i);
|
|
163
138
|
const url = getLocation();
|
|
164
139
|
return {
|
|
165
|
-
urlPath: url
|
|
166
|
-
host:
|
|
140
|
+
urlPath: url?.pathname,
|
|
141
|
+
host: url?.host || url?.hostname,
|
|
167
142
|
device: isTablet ? "tablet" : isMobile.any() ? "mobile" : "desktop"
|
|
168
143
|
};
|
|
169
144
|
};
|
|
170
145
|
|
|
171
|
-
// src/functions/evaluate/helpers.
|
|
146
|
+
// src/functions/evaluate/helpers.ts
|
|
172
147
|
var getFunctionArguments = ({
|
|
173
148
|
builder,
|
|
174
149
|
context,
|
|
@@ -178,6 +153,7 @@ var getFunctionArguments = ({
|
|
|
178
153
|
return Object.entries({
|
|
179
154
|
state,
|
|
180
155
|
Builder: builder,
|
|
156
|
+
// legacy
|
|
181
157
|
builder,
|
|
182
158
|
context,
|
|
183
159
|
event
|
|
@@ -192,12 +168,15 @@ var getBuilderGlobals = () => ({
|
|
|
192
168
|
var parseCode = (code, {
|
|
193
169
|
isExpression = true
|
|
194
170
|
}) => {
|
|
195
|
-
const useReturn =
|
|
171
|
+
const useReturn = (
|
|
172
|
+
// we disable this for cases where we definitely don't want a return
|
|
173
|
+
isExpression && !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "))
|
|
174
|
+
);
|
|
196
175
|
const useCode = useReturn ? `return (${code});` : code;
|
|
197
176
|
return useCode;
|
|
198
177
|
};
|
|
199
178
|
|
|
200
|
-
// src/functions/evaluate/browser-runtime/browser.
|
|
179
|
+
// src/functions/evaluate/browser-runtime/browser.ts
|
|
201
180
|
var runInBrowser = ({
|
|
202
181
|
code,
|
|
203
182
|
builder,
|
|
@@ -231,16 +210,16 @@ function flattenState(rootState, localState, rootSetState) {
|
|
|
231
210
|
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
232
211
|
}
|
|
233
212
|
rootState[prop] = value;
|
|
234
|
-
rootSetState
|
|
213
|
+
rootSetState?.(rootState);
|
|
235
214
|
return true;
|
|
236
215
|
}
|
|
237
216
|
});
|
|
238
217
|
}
|
|
239
218
|
|
|
240
|
-
// src/functions/evaluate/choose-eval.
|
|
219
|
+
// src/functions/evaluate/choose-eval.ts
|
|
241
220
|
var chooseBrowserOrServerEval = (args) => isBrowser() ? runInBrowser(args) : runInBrowser(args);
|
|
242
221
|
|
|
243
|
-
// src/functions/evaluate/evaluate.
|
|
222
|
+
// src/functions/evaluate/evaluate.ts
|
|
244
223
|
function evaluate({
|
|
245
224
|
code,
|
|
246
225
|
context,
|
|
@@ -275,7 +254,10 @@ function evaluate({
|
|
|
275
254
|
}
|
|
276
255
|
}
|
|
277
256
|
|
|
278
|
-
// src/functions/
|
|
257
|
+
// src/functions/fast-clone.ts
|
|
258
|
+
var fastClone = (obj) => JSON.parse(JSON.stringify(obj));
|
|
259
|
+
|
|
260
|
+
// src/functions/set.ts
|
|
279
261
|
var set = (obj, _path, value) => {
|
|
280
262
|
if (Object(obj) !== obj) {
|
|
281
263
|
return obj;
|
|
@@ -285,36 +267,12 @@ var set = (obj, _path, value) => {
|
|
|
285
267
|
return obj;
|
|
286
268
|
};
|
|
287
269
|
|
|
288
|
-
// src/functions/transform-block.
|
|
270
|
+
// src/functions/transform-block.ts
|
|
289
271
|
function transformBlock(block) {
|
|
290
272
|
return block;
|
|
291
273
|
}
|
|
292
274
|
|
|
293
|
-
// src/functions/get-processed-block.
|
|
294
|
-
var __defProp = Object.defineProperty;
|
|
295
|
-
var __defProps = Object.defineProperties;
|
|
296
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
297
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
298
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
299
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
300
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
301
|
-
enumerable: true,
|
|
302
|
-
configurable: true,
|
|
303
|
-
writable: true,
|
|
304
|
-
value
|
|
305
|
-
}) : obj[key] = value;
|
|
306
|
-
var __spreadValues = (a, b) => {
|
|
307
|
-
for (var prop in b || (b = {}))
|
|
308
|
-
if (__hasOwnProp.call(b, prop))
|
|
309
|
-
__defNormalProp(a, prop, b[prop]);
|
|
310
|
-
if (__getOwnPropSymbols)
|
|
311
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
312
|
-
if (__propIsEnum.call(b, prop))
|
|
313
|
-
__defNormalProp(a, prop, b[prop]);
|
|
314
|
-
}
|
|
315
|
-
return a;
|
|
316
|
-
};
|
|
317
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
275
|
+
// src/functions/get-processed-block.ts
|
|
318
276
|
var evaluateBindings = ({
|
|
319
277
|
block,
|
|
320
278
|
context,
|
|
@@ -326,10 +284,15 @@ var evaluateBindings = ({
|
|
|
326
284
|
return block;
|
|
327
285
|
}
|
|
328
286
|
const copy = fastClone(block);
|
|
329
|
-
const copied =
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
287
|
+
const copied = {
|
|
288
|
+
...copy,
|
|
289
|
+
properties: {
|
|
290
|
+
...copy.properties
|
|
291
|
+
},
|
|
292
|
+
actions: {
|
|
293
|
+
...copy.actions
|
|
294
|
+
}
|
|
295
|
+
};
|
|
333
296
|
for (const binding in block.bindings) {
|
|
334
297
|
const expression = block.bindings[binding];
|
|
335
298
|
const value = evaluate({
|
|
@@ -365,13 +328,129 @@ function getProcessedBlock({
|
|
|
365
328
|
}
|
|
366
329
|
}
|
|
367
330
|
|
|
368
|
-
// src/
|
|
331
|
+
// src/components/block/block.helpers.ts
|
|
332
|
+
var EMPTY_HTML_ELEMENTS = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
|
|
333
|
+
var isEmptyHtmlElement = (tagName) => {
|
|
334
|
+
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
|
|
335
|
+
};
|
|
336
|
+
var getComponent = ({
|
|
337
|
+
block,
|
|
338
|
+
context,
|
|
339
|
+
registeredComponents
|
|
340
|
+
}) => {
|
|
341
|
+
const componentName = getProcessedBlock({
|
|
342
|
+
block,
|
|
343
|
+
localState: context.localState,
|
|
344
|
+
rootState: context.rootState,
|
|
345
|
+
rootSetState: context.rootSetState,
|
|
346
|
+
context: context.context,
|
|
347
|
+
shouldEvaluateBindings: false
|
|
348
|
+
}).component?.name;
|
|
349
|
+
if (!componentName) {
|
|
350
|
+
return null;
|
|
351
|
+
}
|
|
352
|
+
const ref = registeredComponents[componentName];
|
|
353
|
+
if (!ref) {
|
|
354
|
+
return void 0;
|
|
355
|
+
} else {
|
|
356
|
+
return ref;
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
var getRepeatItemData = ({
|
|
360
|
+
block,
|
|
361
|
+
context
|
|
362
|
+
}) => {
|
|
363
|
+
const {
|
|
364
|
+
repeat,
|
|
365
|
+
...blockWithoutRepeat
|
|
366
|
+
} = block;
|
|
367
|
+
if (!repeat?.collection) {
|
|
368
|
+
return void 0;
|
|
369
|
+
}
|
|
370
|
+
const itemsArray = evaluate({
|
|
371
|
+
code: repeat.collection,
|
|
372
|
+
localState: context.localState,
|
|
373
|
+
rootState: context.rootState,
|
|
374
|
+
rootSetState: context.rootSetState,
|
|
375
|
+
context: context.context
|
|
376
|
+
});
|
|
377
|
+
if (!Array.isArray(itemsArray)) {
|
|
378
|
+
return void 0;
|
|
379
|
+
}
|
|
380
|
+
const collectionName = repeat.collection.split(".").pop();
|
|
381
|
+
const itemNameToUse = repeat.itemName || (collectionName ? collectionName + "Item" : "item");
|
|
382
|
+
const repeatArray = itemsArray.map((item, index) => ({
|
|
383
|
+
context: {
|
|
384
|
+
...context,
|
|
385
|
+
localState: {
|
|
386
|
+
...context.localState,
|
|
387
|
+
$index: index,
|
|
388
|
+
$item: item,
|
|
389
|
+
[itemNameToUse]: item,
|
|
390
|
+
[`$${itemNameToUse}Index`]: index
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
block: blockWithoutRepeat
|
|
394
|
+
}));
|
|
395
|
+
return repeatArray;
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
// src/constants/device-sizes.ts
|
|
399
|
+
var SIZES = {
|
|
400
|
+
small: {
|
|
401
|
+
min: 320,
|
|
402
|
+
default: 321,
|
|
403
|
+
max: 640
|
|
404
|
+
},
|
|
405
|
+
medium: {
|
|
406
|
+
min: 641,
|
|
407
|
+
default: 642,
|
|
408
|
+
max: 991
|
|
409
|
+
},
|
|
410
|
+
large: {
|
|
411
|
+
min: 990,
|
|
412
|
+
default: 991,
|
|
413
|
+
max: 1200
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
var getMaxWidthQueryForSize = (size, sizeValues = SIZES) => `@media (max-width: ${sizeValues[size].max}px)`;
|
|
417
|
+
var getSizesForBreakpoints = ({
|
|
418
|
+
small,
|
|
419
|
+
medium
|
|
420
|
+
}) => {
|
|
421
|
+
const newSizes = fastClone(SIZES);
|
|
422
|
+
if (!small || !medium) {
|
|
423
|
+
return newSizes;
|
|
424
|
+
}
|
|
425
|
+
const smallMin = Math.floor(small / 2);
|
|
426
|
+
newSizes.small = {
|
|
427
|
+
max: small,
|
|
428
|
+
min: smallMin,
|
|
429
|
+
default: smallMin + 1
|
|
430
|
+
};
|
|
431
|
+
const mediumMin = newSizes.small.max + 1;
|
|
432
|
+
newSizes.medium = {
|
|
433
|
+
max: medium,
|
|
434
|
+
min: mediumMin,
|
|
435
|
+
default: mediumMin + 1
|
|
436
|
+
};
|
|
437
|
+
const largeMin = newSizes.medium.max + 1;
|
|
438
|
+
newSizes.large = {
|
|
439
|
+
max: 2e3,
|
|
440
|
+
// TODO: decide upper limit
|
|
441
|
+
min: largeMin,
|
|
442
|
+
default: largeMin + 1
|
|
443
|
+
};
|
|
444
|
+
return newSizes;
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
// src/functions/camel-to-kebab-case.ts
|
|
369
448
|
var camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
370
449
|
|
|
371
|
-
// src/helpers/nullable.
|
|
450
|
+
// src/helpers/nullable.ts
|
|
372
451
|
var checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
|
|
373
452
|
|
|
374
|
-
// src/helpers/css.
|
|
453
|
+
// src/helpers/css.ts
|
|
375
454
|
var convertStyleMapToCSSArray = (style) => {
|
|
376
455
|
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
377
456
|
if (typeof value === "string") {
|
|
@@ -417,7 +496,7 @@ function InlinedStyles(props) {
|
|
|
417
496
|
}
|
|
418
497
|
var inlined_styles_default = InlinedStyles;
|
|
419
498
|
|
|
420
|
-
// src/components/block/components/block-styles.
|
|
499
|
+
// src/components/block/components/block-styles.tsx
|
|
421
500
|
function BlockStyles(props) {
|
|
422
501
|
function canShowBlock() {
|
|
423
502
|
const processedBlock = getProcessedBlock({
|
|
@@ -486,63 +565,50 @@ function BlockStyles(props) {
|
|
|
486
565
|
}
|
|
487
566
|
var block_styles_default = BlockStyles;
|
|
488
567
|
|
|
489
|
-
// src/functions/
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
var __getOwnPropDescs2 = Object.getOwnPropertyDescriptors;
|
|
493
|
-
var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
|
|
494
|
-
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
495
|
-
var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
|
|
496
|
-
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, {
|
|
497
|
-
enumerable: true,
|
|
498
|
-
configurable: true,
|
|
499
|
-
writable: true,
|
|
500
|
-
value
|
|
501
|
-
}) : obj[key] = value;
|
|
502
|
-
var __spreadValues2 = (a, b) => {
|
|
503
|
-
for (var prop in b || (b = {}))
|
|
504
|
-
if (__hasOwnProp2.call(b, prop))
|
|
505
|
-
__defNormalProp2(a, prop, b[prop]);
|
|
506
|
-
if (__getOwnPropSymbols2)
|
|
507
|
-
for (var prop of __getOwnPropSymbols2(b)) {
|
|
508
|
-
if (__propIsEnum2.call(b, prop))
|
|
509
|
-
__defNormalProp2(a, prop, b[prop]);
|
|
510
|
-
}
|
|
511
|
-
return a;
|
|
512
|
-
};
|
|
513
|
-
var __spreadProps2 = (a, b) => __defProps2(a, __getOwnPropDescs2(b));
|
|
514
|
-
function getBlockComponentOptions(block) {
|
|
515
|
-
var _a;
|
|
516
|
-
return __spreadProps2(__spreadValues2(__spreadValues2({}, (_a = block.component) == null ? void 0 : _a.options), block.options), {
|
|
517
|
-
builderBlock: block
|
|
518
|
-
});
|
|
568
|
+
// src/functions/event-handler-name.ts
|
|
569
|
+
function capitalizeFirstLetter(string) {
|
|
570
|
+
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
519
571
|
}
|
|
572
|
+
var getEventHandlerName = (key) => `on${capitalizeFirstLetter(key)}`;
|
|
520
573
|
|
|
521
|
-
// src/functions/
|
|
522
|
-
var
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
for (var prop of __getOwnPropSymbols3(b)) {
|
|
540
|
-
if (__propIsEnum3.call(b, prop))
|
|
541
|
-
__defNormalProp3(a, prop, b[prop]);
|
|
574
|
+
// src/functions/get-block-actions-handler.ts
|
|
575
|
+
var createEventHandler = (value, options) => (event) => evaluate({
|
|
576
|
+
code: value,
|
|
577
|
+
context: options.context,
|
|
578
|
+
localState: options.localState,
|
|
579
|
+
rootState: options.rootState,
|
|
580
|
+
rootSetState: options.rootSetState,
|
|
581
|
+
event,
|
|
582
|
+
isExpression: false
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
// src/functions/get-block-actions.ts
|
|
586
|
+
function getBlockActions(options) {
|
|
587
|
+
const obj = {};
|
|
588
|
+
const optionActions = options.block.actions ?? {};
|
|
589
|
+
for (const key in optionActions) {
|
|
590
|
+
if (!optionActions.hasOwnProperty(key)) {
|
|
591
|
+
continue;
|
|
542
592
|
}
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
593
|
+
const value = optionActions[key];
|
|
594
|
+
let eventHandlerName = getEventHandlerName(key);
|
|
595
|
+
if (options.stripPrefix) {
|
|
596
|
+
switch (TARGET) {
|
|
597
|
+
case "vue2":
|
|
598
|
+
case "vue3":
|
|
599
|
+
eventHandlerName = eventHandlerName.replace("v-on:", "");
|
|
600
|
+
break;
|
|
601
|
+
case "svelte":
|
|
602
|
+
eventHandlerName = eventHandlerName.replace("on:", "");
|
|
603
|
+
break;
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
obj[eventHandlerName] = createEventHandler(value, options);
|
|
607
|
+
}
|
|
608
|
+
return obj;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
// src/functions/sanitize-react-native-block-styles.ts
|
|
546
612
|
var propertiesThatMustBeNumber = /* @__PURE__ */ new Set(["lineHeight"]);
|
|
547
613
|
var displayValues = /* @__PURE__ */ new Set(["flex", "none"]);
|
|
548
614
|
var normalizeNumber = (value) => {
|
|
@@ -569,46 +635,28 @@ var sanitizeReactNativeBlockStyles = (styles) => {
|
|
|
569
635
|
const newValue = parseFloat(propertyValue);
|
|
570
636
|
const normalizedValue = normalizeNumber(newValue);
|
|
571
637
|
if (normalizedValue) {
|
|
572
|
-
return
|
|
638
|
+
return {
|
|
639
|
+
...acc,
|
|
573
640
|
[key]: normalizedValue
|
|
574
|
-
}
|
|
641
|
+
};
|
|
575
642
|
} else {
|
|
576
643
|
return acc;
|
|
577
644
|
}
|
|
578
645
|
} else if (propertyValue === "0") {
|
|
579
|
-
return
|
|
646
|
+
return {
|
|
647
|
+
...acc,
|
|
580
648
|
[key]: 0
|
|
581
|
-
}
|
|
649
|
+
};
|
|
582
650
|
}
|
|
583
651
|
}
|
|
584
|
-
return
|
|
652
|
+
return {
|
|
653
|
+
...acc,
|
|
585
654
|
[key]: propertyValue
|
|
586
|
-
}
|
|
655
|
+
};
|
|
587
656
|
}, {});
|
|
588
657
|
};
|
|
589
658
|
|
|
590
|
-
// src/functions/get-react-native-block-styles.
|
|
591
|
-
var __defProp4 = Object.defineProperty;
|
|
592
|
-
var __getOwnPropSymbols4 = Object.getOwnPropertySymbols;
|
|
593
|
-
var __hasOwnProp4 = Object.prototype.hasOwnProperty;
|
|
594
|
-
var __propIsEnum4 = Object.prototype.propertyIsEnumerable;
|
|
595
|
-
var __defNormalProp4 = (obj, key, value) => key in obj ? __defProp4(obj, key, {
|
|
596
|
-
enumerable: true,
|
|
597
|
-
configurable: true,
|
|
598
|
-
writable: true,
|
|
599
|
-
value
|
|
600
|
-
}) : obj[key] = value;
|
|
601
|
-
var __spreadValues4 = (a, b) => {
|
|
602
|
-
for (var prop in b || (b = {}))
|
|
603
|
-
if (__hasOwnProp4.call(b, prop))
|
|
604
|
-
__defNormalProp4(a, prop, b[prop]);
|
|
605
|
-
if (__getOwnPropSymbols4)
|
|
606
|
-
for (var prop of __getOwnPropSymbols4(b)) {
|
|
607
|
-
if (__propIsEnum4.call(b, prop))
|
|
608
|
-
__defNormalProp4(a, prop, b[prop]);
|
|
609
|
-
}
|
|
610
|
-
return a;
|
|
611
|
-
};
|
|
659
|
+
// src/functions/get-react-native-block-styles.ts
|
|
612
660
|
function getReactNativeBlockStyles({
|
|
613
661
|
block,
|
|
614
662
|
context,
|
|
@@ -618,41 +666,24 @@ function getReactNativeBlockStyles({
|
|
|
618
666
|
if (!responsiveStyles) {
|
|
619
667
|
return {};
|
|
620
668
|
}
|
|
621
|
-
const styles =
|
|
669
|
+
const styles = {
|
|
670
|
+
// recursively apply inherited styles so that they can be passed down to children `Text` blocks
|
|
671
|
+
...context.inheritedStyles,
|
|
672
|
+
...responsiveStyles.large || {},
|
|
673
|
+
...responsiveStyles.medium || {},
|
|
674
|
+
...responsiveStyles.small || {},
|
|
675
|
+
...blockStyles
|
|
676
|
+
};
|
|
622
677
|
const newStyles = sanitizeReactNativeBlockStyles(styles);
|
|
623
678
|
return newStyles;
|
|
624
679
|
}
|
|
625
680
|
|
|
626
|
-
// src/functions/transform-block-properties.
|
|
681
|
+
// src/functions/transform-block-properties.ts
|
|
627
682
|
function transformBlockProperties(properties) {
|
|
628
683
|
return properties;
|
|
629
684
|
}
|
|
630
685
|
|
|
631
|
-
// src/functions/get-block-properties.
|
|
632
|
-
var __defProp5 = Object.defineProperty;
|
|
633
|
-
var __defProps4 = Object.defineProperties;
|
|
634
|
-
var __getOwnPropDescs4 = Object.getOwnPropertyDescriptors;
|
|
635
|
-
var __getOwnPropSymbols5 = Object.getOwnPropertySymbols;
|
|
636
|
-
var __hasOwnProp5 = Object.prototype.hasOwnProperty;
|
|
637
|
-
var __propIsEnum5 = Object.prototype.propertyIsEnumerable;
|
|
638
|
-
var __defNormalProp5 = (obj, key, value) => key in obj ? __defProp5(obj, key, {
|
|
639
|
-
enumerable: true,
|
|
640
|
-
configurable: true,
|
|
641
|
-
writable: true,
|
|
642
|
-
value
|
|
643
|
-
}) : obj[key] = value;
|
|
644
|
-
var __spreadValues5 = (a, b) => {
|
|
645
|
-
for (var prop in b || (b = {}))
|
|
646
|
-
if (__hasOwnProp5.call(b, prop))
|
|
647
|
-
__defNormalProp5(a, prop, b[prop]);
|
|
648
|
-
if (__getOwnPropSymbols5)
|
|
649
|
-
for (var prop of __getOwnPropSymbols5(b)) {
|
|
650
|
-
if (__propIsEnum5.call(b, prop))
|
|
651
|
-
__defNormalProp5(a, prop, b[prop]);
|
|
652
|
-
}
|
|
653
|
-
return a;
|
|
654
|
-
};
|
|
655
|
-
var __spreadProps4 = (a, b) => __defProps4(a, __getOwnPropDescs4(b));
|
|
686
|
+
// src/functions/get-block-properties.ts
|
|
656
687
|
var extractRelevantRootBlockProperties = (block) => {
|
|
657
688
|
return {
|
|
658
689
|
href: block.href
|
|
@@ -662,12 +693,13 @@ function getBlockProperties({
|
|
|
662
693
|
block,
|
|
663
694
|
context
|
|
664
695
|
}) {
|
|
665
|
-
|
|
666
|
-
|
|
696
|
+
const properties = {
|
|
697
|
+
...extractRelevantRootBlockProperties(block),
|
|
698
|
+
...block.properties,
|
|
667
699
|
"builder-id": block.id,
|
|
668
700
|
style: block.style ? getStyleAttribute(block.style) : void 0,
|
|
669
|
-
class: [block.id, "builder-block", block.class,
|
|
670
|
-
}
|
|
701
|
+
class: [block.id, "builder-block", block.class, block.properties?.class].filter(Boolean).join(" ")
|
|
702
|
+
};
|
|
671
703
|
if (TARGET === "reactNative") {
|
|
672
704
|
properties.style = getReactNativeBlockStyles({
|
|
673
705
|
block,
|
|
@@ -692,188 +724,52 @@ function getStyleAttribute(style) {
|
|
|
692
724
|
}
|
|
693
725
|
}
|
|
694
726
|
|
|
695
|
-
// src/components/block/block.
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
return a;
|
|
718
|
-
};
|
|
719
|
-
var __spreadProps5 = (a, b) => __defProps5(a, __getOwnPropDescs5(b));
|
|
720
|
-
var __objRest = (source, exclude) => {
|
|
721
|
-
var target = {};
|
|
722
|
-
for (var prop in source)
|
|
723
|
-
if (__hasOwnProp6.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
724
|
-
target[prop] = source[prop];
|
|
725
|
-
if (source != null && __getOwnPropSymbols6)
|
|
726
|
-
for (var prop of __getOwnPropSymbols6(source)) {
|
|
727
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum6.call(source, prop))
|
|
728
|
-
target[prop] = source[prop];
|
|
729
|
-
}
|
|
730
|
-
return target;
|
|
731
|
-
};
|
|
732
|
-
var EMPTY_HTML_ELEMENTS = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
|
|
733
|
-
var isEmptyHtmlElement = (tagName) => {
|
|
734
|
-
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
|
|
735
|
-
};
|
|
736
|
-
var getComponent = ({
|
|
737
|
-
block,
|
|
738
|
-
context,
|
|
739
|
-
registeredComponents
|
|
740
|
-
}) => {
|
|
741
|
-
var _a;
|
|
742
|
-
const componentName = (_a = getProcessedBlock({
|
|
743
|
-
block,
|
|
744
|
-
localState: context.localState,
|
|
745
|
-
rootState: context.rootState,
|
|
746
|
-
rootSetState: context.rootSetState,
|
|
747
|
-
context: context.context,
|
|
748
|
-
shouldEvaluateBindings: false
|
|
749
|
-
}).component) == null ? void 0 : _a.name;
|
|
750
|
-
if (!componentName) {
|
|
751
|
-
return null;
|
|
752
|
-
}
|
|
753
|
-
const ref = registeredComponents[componentName];
|
|
754
|
-
if (!ref) {
|
|
755
|
-
return void 0;
|
|
756
|
-
} else {
|
|
757
|
-
return ref;
|
|
758
|
-
}
|
|
759
|
-
};
|
|
760
|
-
var getRepeatItemData = ({
|
|
761
|
-
block,
|
|
762
|
-
context
|
|
763
|
-
}) => {
|
|
764
|
-
const _a = block, {
|
|
765
|
-
repeat
|
|
766
|
-
} = _a, blockWithoutRepeat = __objRest(_a, ["repeat"]);
|
|
767
|
-
if (!(repeat == null ? void 0 : repeat.collection)) {
|
|
768
|
-
return void 0;
|
|
769
|
-
}
|
|
770
|
-
const itemsArray = evaluate({
|
|
771
|
-
code: repeat.collection,
|
|
772
|
-
localState: context.localState,
|
|
773
|
-
rootState: context.rootState,
|
|
774
|
-
rootSetState: context.rootSetState,
|
|
775
|
-
context: context.context
|
|
776
|
-
});
|
|
777
|
-
if (!Array.isArray(itemsArray)) {
|
|
778
|
-
return void 0;
|
|
779
|
-
}
|
|
780
|
-
const collectionName = repeat.collection.split(".").pop();
|
|
781
|
-
const itemNameToUse = repeat.itemName || (collectionName ? collectionName + "Item" : "item");
|
|
782
|
-
const repeatArray = itemsArray.map((item, index) => ({
|
|
783
|
-
context: __spreadProps5(__spreadValues6({}, context), {
|
|
784
|
-
localState: __spreadProps5(__spreadValues6({}, context.localState), {
|
|
785
|
-
$index: index,
|
|
786
|
-
$item: item,
|
|
787
|
-
[itemNameToUse]: item,
|
|
788
|
-
[`$${itemNameToUse}Index`]: index
|
|
789
|
-
})
|
|
790
|
-
}),
|
|
791
|
-
block: blockWithoutRepeat
|
|
792
|
-
}));
|
|
793
|
-
return repeatArray;
|
|
794
|
-
};
|
|
795
|
-
var stdin_default = createContext({
|
|
796
|
-
content: null,
|
|
797
|
-
context: {},
|
|
798
|
-
localState: void 0,
|
|
799
|
-
rootSetState() {
|
|
800
|
-
},
|
|
801
|
-
rootState: {},
|
|
802
|
-
apiKey: null,
|
|
803
|
-
apiVersion: void 0,
|
|
804
|
-
componentInfos: {},
|
|
805
|
-
inheritedStyles: {}
|
|
806
|
-
});
|
|
807
|
-
|
|
808
|
-
// src/components/block/components/repeated-block.jsx
|
|
809
|
-
function RepeatedBlock(props) {
|
|
810
|
-
const [store, setStore] = createSignal(props.repeatContext);
|
|
811
|
-
return createComponent(stdin_default.Provider, {
|
|
812
|
-
get value() {
|
|
813
|
-
return store();
|
|
727
|
+
// src/components/block/components/block-wrapper.tsx
|
|
728
|
+
function BlockWrapper(props) {
|
|
729
|
+
return createComponent(Show, {
|
|
730
|
+
get fallback() {
|
|
731
|
+
return createComponent(Dynamic, mergeProps(() => getBlockProperties({
|
|
732
|
+
block: props.block,
|
|
733
|
+
context: props.context
|
|
734
|
+
}), () => getBlockActions({
|
|
735
|
+
block: props.block,
|
|
736
|
+
rootState: props.context.rootState,
|
|
737
|
+
rootSetState: props.context.rootSetState,
|
|
738
|
+
localState: props.context.localState,
|
|
739
|
+
context: props.context.context,
|
|
740
|
+
stripPrefix: true
|
|
741
|
+
}), {
|
|
742
|
+
get component() {
|
|
743
|
+
return props.Wrapper;
|
|
744
|
+
}
|
|
745
|
+
}));
|
|
746
|
+
},
|
|
747
|
+
get when() {
|
|
748
|
+
return props.hasChildren;
|
|
814
749
|
},
|
|
815
750
|
get children() {
|
|
816
|
-
return createComponent(
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
751
|
+
return createComponent(Dynamic, mergeProps(() => getBlockProperties({
|
|
752
|
+
block: props.block,
|
|
753
|
+
context: props.context
|
|
754
|
+
}), () => getBlockActions({
|
|
755
|
+
block: props.block,
|
|
756
|
+
rootState: props.context.rootState,
|
|
757
|
+
rootSetState: props.context.rootSetState,
|
|
758
|
+
localState: props.context.localState,
|
|
759
|
+
context: props.context.context,
|
|
760
|
+
stripPrefix: true
|
|
761
|
+
}), {
|
|
762
|
+
get component() {
|
|
763
|
+
return props.Wrapper;
|
|
822
764
|
},
|
|
823
|
-
get
|
|
824
|
-
return props.
|
|
765
|
+
get children() {
|
|
766
|
+
return props.children;
|
|
825
767
|
}
|
|
826
|
-
});
|
|
768
|
+
}));
|
|
827
769
|
}
|
|
828
770
|
});
|
|
829
771
|
}
|
|
830
|
-
var
|
|
831
|
-
|
|
832
|
-
// src/functions/event-handler-name.js
|
|
833
|
-
function capitalizeFirstLetter(string) {
|
|
834
|
-
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
835
|
-
}
|
|
836
|
-
var getEventHandlerName = (key) => `on${capitalizeFirstLetter(key)}`;
|
|
837
|
-
|
|
838
|
-
// src/functions/get-block-actions-handler.js
|
|
839
|
-
var createEventHandler = (value, options) => (event) => evaluate({
|
|
840
|
-
code: value,
|
|
841
|
-
context: options.context,
|
|
842
|
-
localState: options.localState,
|
|
843
|
-
rootState: options.rootState,
|
|
844
|
-
rootSetState: options.rootSetState,
|
|
845
|
-
event,
|
|
846
|
-
isExpression: false
|
|
847
|
-
});
|
|
848
|
-
|
|
849
|
-
// src/functions/get-block-actions.js
|
|
850
|
-
function getBlockActions(options) {
|
|
851
|
-
var _a;
|
|
852
|
-
const obj = {};
|
|
853
|
-
const optionActions = (_a = options.block.actions) != null ? _a : {};
|
|
854
|
-
for (const key in optionActions) {
|
|
855
|
-
if (!optionActions.hasOwnProperty(key)) {
|
|
856
|
-
continue;
|
|
857
|
-
}
|
|
858
|
-
const value = optionActions[key];
|
|
859
|
-
let eventHandlerName = getEventHandlerName(key);
|
|
860
|
-
if (options.stripPrefix) {
|
|
861
|
-
switch (TARGET) {
|
|
862
|
-
case "vue2":
|
|
863
|
-
case "vue3":
|
|
864
|
-
eventHandlerName = eventHandlerName.replace("v-on:", "");
|
|
865
|
-
break;
|
|
866
|
-
case "svelte":
|
|
867
|
-
eventHandlerName = eventHandlerName.replace("on:", "");
|
|
868
|
-
break;
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
obj[eventHandlerName] = createEventHandler(value, options);
|
|
872
|
-
}
|
|
873
|
-
return obj;
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
// src/components/block/components/interactive-element.jsx
|
|
772
|
+
var block_wrapper_default = BlockWrapper;
|
|
877
773
|
function InteractiveElement(props) {
|
|
878
774
|
return createComponent(Dynamic, mergeProps(() => props.wrapperProps, {
|
|
879
775
|
get attributes() {
|
|
@@ -901,28 +797,7 @@ function InteractiveElement(props) {
|
|
|
901
797
|
}
|
|
902
798
|
var interactive_element_default = InteractiveElement;
|
|
903
799
|
|
|
904
|
-
// src/components/block/components/component-ref/component-ref.helpers.
|
|
905
|
-
var __defProp7 = Object.defineProperty;
|
|
906
|
-
var __getOwnPropSymbols7 = Object.getOwnPropertySymbols;
|
|
907
|
-
var __hasOwnProp7 = Object.prototype.hasOwnProperty;
|
|
908
|
-
var __propIsEnum7 = Object.prototype.propertyIsEnumerable;
|
|
909
|
-
var __defNormalProp7 = (obj, key, value) => key in obj ? __defProp7(obj, key, {
|
|
910
|
-
enumerable: true,
|
|
911
|
-
configurable: true,
|
|
912
|
-
writable: true,
|
|
913
|
-
value
|
|
914
|
-
}) : obj[key] = value;
|
|
915
|
-
var __spreadValues7 = (a, b) => {
|
|
916
|
-
for (var prop in b || (b = {}))
|
|
917
|
-
if (__hasOwnProp7.call(b, prop))
|
|
918
|
-
__defNormalProp7(a, prop, b[prop]);
|
|
919
|
-
if (__getOwnPropSymbols7)
|
|
920
|
-
for (var prop of __getOwnPropSymbols7(b)) {
|
|
921
|
-
if (__propIsEnum7.call(b, prop))
|
|
922
|
-
__defNormalProp7(a, prop, b[prop]);
|
|
923
|
-
}
|
|
924
|
-
return a;
|
|
925
|
-
};
|
|
800
|
+
// src/components/block/components/component-ref/component-ref.helpers.ts
|
|
926
801
|
var getWrapperProps = ({
|
|
927
802
|
componentOptions,
|
|
928
803
|
builderBlock,
|
|
@@ -938,15 +813,22 @@ var getWrapperProps = ({
|
|
|
938
813
|
context,
|
|
939
814
|
wrapperProps: componentOptions
|
|
940
815
|
};
|
|
941
|
-
return isInteractive ? interactiveElementProps :
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
816
|
+
return isInteractive ? interactiveElementProps : {
|
|
817
|
+
...componentOptions,
|
|
818
|
+
/**
|
|
819
|
+
* If `noWrap` is set to `true`, then the block's props/attributes are provided to the
|
|
820
|
+
* component itself directly. Otherwise, they are provided to the wrapper element.
|
|
821
|
+
*/
|
|
822
|
+
...includeBlockProps ? {
|
|
823
|
+
attributes: getBlockProperties({
|
|
824
|
+
block: builderBlock,
|
|
825
|
+
context: contextValue
|
|
826
|
+
})
|
|
827
|
+
} : {}
|
|
828
|
+
};
|
|
947
829
|
};
|
|
948
830
|
|
|
949
|
-
// src/components/block/components/component-ref/component-ref.
|
|
831
|
+
// src/components/block/components/component-ref/component-ref.tsx
|
|
950
832
|
function ComponentRef(props) {
|
|
951
833
|
const [Wrapper, setWrapper] = createSignal(props.isInteractive ? interactive_element_default : props.componentRef);
|
|
952
834
|
return createComponent(Show, {
|
|
@@ -1009,53 +891,30 @@ function ComponentRef(props) {
|
|
|
1009
891
|
});
|
|
1010
892
|
}
|
|
1011
893
|
var component_ref_default = ComponentRef;
|
|
1012
|
-
function
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
context: props.context
|
|
1018
|
-
}), () => getBlockActions({
|
|
1019
|
-
block: props.block,
|
|
1020
|
-
rootState: props.context.rootState,
|
|
1021
|
-
rootSetState: props.context.rootSetState,
|
|
1022
|
-
localState: props.context.localState,
|
|
1023
|
-
context: props.context.context,
|
|
1024
|
-
stripPrefix: true
|
|
1025
|
-
}), {
|
|
1026
|
-
get component() {
|
|
1027
|
-
return props.Wrapper;
|
|
1028
|
-
}
|
|
1029
|
-
}));
|
|
1030
|
-
},
|
|
1031
|
-
get when() {
|
|
1032
|
-
return props.hasChildren;
|
|
894
|
+
function RepeatedBlock(props) {
|
|
895
|
+
const [store, setStore] = createSignal(props.repeatContext);
|
|
896
|
+
return createComponent(builder_context_default.Provider, {
|
|
897
|
+
get value() {
|
|
898
|
+
return store();
|
|
1033
899
|
},
|
|
1034
900
|
get children() {
|
|
1035
|
-
return createComponent(
|
|
1036
|
-
block
|
|
1037
|
-
|
|
1038
|
-
}), () => getBlockActions({
|
|
1039
|
-
block: props.block,
|
|
1040
|
-
rootState: props.context.rootState,
|
|
1041
|
-
rootSetState: props.context.rootSetState,
|
|
1042
|
-
localState: props.context.localState,
|
|
1043
|
-
context: props.context.context,
|
|
1044
|
-
stripPrefix: true
|
|
1045
|
-
}), {
|
|
1046
|
-
get component() {
|
|
1047
|
-
return props.Wrapper;
|
|
901
|
+
return createComponent(block_default, {
|
|
902
|
+
get block() {
|
|
903
|
+
return props.block;
|
|
1048
904
|
},
|
|
1049
|
-
get
|
|
1050
|
-
return
|
|
905
|
+
get context() {
|
|
906
|
+
return store();
|
|
907
|
+
},
|
|
908
|
+
get registeredComponents() {
|
|
909
|
+
return props.registeredComponents;
|
|
1051
910
|
}
|
|
1052
|
-
})
|
|
911
|
+
});
|
|
1053
912
|
}
|
|
1054
913
|
});
|
|
1055
914
|
}
|
|
1056
|
-
var
|
|
915
|
+
var repeated_block_default = RepeatedBlock;
|
|
1057
916
|
|
|
1058
|
-
// src/components/block/block.
|
|
917
|
+
// src/components/block/block.tsx
|
|
1059
918
|
function Block(props) {
|
|
1060
919
|
const [childrenContext, setChildrenContext] = createSignal(props.context);
|
|
1061
920
|
function blockComponent() {
|
|
@@ -1122,7 +981,32 @@ function Block(props) {
|
|
|
1122
981
|
get children() {
|
|
1123
982
|
return createComponent(Show, {
|
|
1124
983
|
get fallback() {
|
|
1125
|
-
return createComponent(component_ref_default,
|
|
984
|
+
return createComponent(component_ref_default, {
|
|
985
|
+
get componentRef() {
|
|
986
|
+
return componentRefProps().componentRef;
|
|
987
|
+
},
|
|
988
|
+
get componentOptions() {
|
|
989
|
+
return componentRefProps().componentOptions;
|
|
990
|
+
},
|
|
991
|
+
get blockChildren() {
|
|
992
|
+
return componentRefProps().blockChildren;
|
|
993
|
+
},
|
|
994
|
+
get context() {
|
|
995
|
+
return componentRefProps().context;
|
|
996
|
+
},
|
|
997
|
+
get registeredComponents() {
|
|
998
|
+
return componentRefProps().registeredComponents;
|
|
999
|
+
},
|
|
1000
|
+
get builderBlock() {
|
|
1001
|
+
return componentRefProps().builderBlock;
|
|
1002
|
+
},
|
|
1003
|
+
get includeBlockProps() {
|
|
1004
|
+
return componentRefProps().includeBlockProps;
|
|
1005
|
+
},
|
|
1006
|
+
get isInteractive() {
|
|
1007
|
+
return componentRefProps().isInteractive;
|
|
1008
|
+
}
|
|
1009
|
+
});
|
|
1126
1010
|
},
|
|
1127
1011
|
get when() {
|
|
1128
1012
|
return !blockComponent()?.noWrap;
|
|
@@ -1189,7 +1073,32 @@ function Block(props) {
|
|
|
1189
1073
|
},
|
|
1190
1074
|
hasChildren: true,
|
|
1191
1075
|
get children() {
|
|
1192
|
-
return [createComponent(component_ref_default,
|
|
1076
|
+
return [createComponent(component_ref_default, {
|
|
1077
|
+
get componentRef() {
|
|
1078
|
+
return componentRefProps().componentRef;
|
|
1079
|
+
},
|
|
1080
|
+
get componentOptions() {
|
|
1081
|
+
return componentRefProps().componentOptions;
|
|
1082
|
+
},
|
|
1083
|
+
get blockChildren() {
|
|
1084
|
+
return componentRefProps().blockChildren;
|
|
1085
|
+
},
|
|
1086
|
+
get context() {
|
|
1087
|
+
return componentRefProps().context;
|
|
1088
|
+
},
|
|
1089
|
+
get registeredComponents() {
|
|
1090
|
+
return componentRefProps().registeredComponents;
|
|
1091
|
+
},
|
|
1092
|
+
get builderBlock() {
|
|
1093
|
+
return componentRefProps().builderBlock;
|
|
1094
|
+
},
|
|
1095
|
+
get includeBlockProps() {
|
|
1096
|
+
return componentRefProps().includeBlockProps;
|
|
1097
|
+
},
|
|
1098
|
+
get isInteractive() {
|
|
1099
|
+
return componentRefProps().isInteractive;
|
|
1100
|
+
}
|
|
1101
|
+
}), createComponent(For, {
|
|
1193
1102
|
get each() {
|
|
1194
1103
|
return childrenWithoutParentComponent();
|
|
1195
1104
|
},
|
|
@@ -1291,12 +1200,11 @@ function BlocksWrapper(props) {
|
|
|
1291
1200
|
})();
|
|
1292
1201
|
}
|
|
1293
1202
|
var blocks_wrapper_default = BlocksWrapper;
|
|
1294
|
-
var stdin_default2 = createContext({ registeredComponents: {} });
|
|
1295
1203
|
|
|
1296
|
-
// src/components/blocks/blocks.
|
|
1204
|
+
// src/components/blocks/blocks.tsx
|
|
1297
1205
|
function Blocks(props) {
|
|
1298
|
-
const builderContext = useContext(
|
|
1299
|
-
const componentsContext = useContext(
|
|
1206
|
+
const builderContext = useContext(builder_context_default);
|
|
1207
|
+
const componentsContext = useContext(components_context_default);
|
|
1300
1208
|
return createComponent(blocks_wrapper_default, {
|
|
1301
1209
|
get blocks() {
|
|
1302
1210
|
return props.blocks;
|
|
@@ -1366,7 +1274,7 @@ function Blocks(props) {
|
|
|
1366
1274
|
}
|
|
1367
1275
|
var blocks_default = Blocks;
|
|
1368
1276
|
|
|
1369
|
-
// src/blocks/columns/columns.
|
|
1277
|
+
// src/blocks/columns/columns.tsx
|
|
1370
1278
|
var _tmpl$5 = /* @__PURE__ */ template(`<div>`);
|
|
1371
1279
|
function Columns(props) {
|
|
1372
1280
|
const [gutterSize, setGutterSize] = createSignal(typeof props.space === "number" ? props.space || 0 : 20);
|
|
@@ -1541,7 +1449,7 @@ function FragmentComponent(props) {
|
|
|
1541
1449
|
}
|
|
1542
1450
|
var fragment_default = FragmentComponent;
|
|
1543
1451
|
|
|
1544
|
-
// src/blocks/image/image.helpers.
|
|
1452
|
+
// src/blocks/image/image.helpers.ts
|
|
1545
1453
|
function removeProtocol(path) {
|
|
1546
1454
|
return path.replace(/http(s)?:/, "");
|
|
1547
1455
|
}
|
|
@@ -1554,7 +1462,7 @@ function updateQueryParam(uri = "", key, value) {
|
|
|
1554
1462
|
return uri + separator + key + "=" + encodeURIComponent(value);
|
|
1555
1463
|
}
|
|
1556
1464
|
function getShopifyImageUrl(src, size) {
|
|
1557
|
-
if (!src || !
|
|
1465
|
+
if (!src || !src?.match(/cdn\.shopify\.com/) || !size) {
|
|
1558
1466
|
return src;
|
|
1559
1467
|
}
|
|
1560
1468
|
if (size === "master") {
|
|
@@ -1588,9 +1496,9 @@ function getSrcSet(url) {
|
|
|
1588
1496
|
return url;
|
|
1589
1497
|
}
|
|
1590
1498
|
|
|
1591
|
-
// src/blocks/image/image.
|
|
1592
|
-
var _tmpl$7 = /* @__PURE__ */ template(`<source type=
|
|
1593
|
-
var _tmpl$22 = /* @__PURE__ */ template(`<picture><img loading=
|
|
1499
|
+
// src/blocks/image/image.tsx
|
|
1500
|
+
var _tmpl$7 = /* @__PURE__ */ template(`<source type=image/webp>`);
|
|
1501
|
+
var _tmpl$22 = /* @__PURE__ */ template(`<picture><img loading=lazy>`);
|
|
1594
1502
|
var _tmpl$32 = /* @__PURE__ */ template(`<div>`);
|
|
1595
1503
|
function Image(props) {
|
|
1596
1504
|
function srcSetToUse() {
|
|
@@ -1743,181 +1651,203 @@ function SectionComponent(props) {
|
|
|
1743
1651
|
}
|
|
1744
1652
|
var section_default = SectionComponent;
|
|
1745
1653
|
|
|
1746
|
-
// src/
|
|
1747
|
-
var
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
writable: true,
|
|
1757
|
-
value
|
|
1758
|
-
}) : obj[key] = value;
|
|
1759
|
-
var __spreadValues8 = (a, b) => {
|
|
1760
|
-
for (var prop in b || (b = {}))
|
|
1761
|
-
if (__hasOwnProp8.call(b, prop))
|
|
1762
|
-
__defNormalProp8(a, prop, b[prop]);
|
|
1763
|
-
if (__getOwnPropSymbols8)
|
|
1764
|
-
for (var prop of __getOwnPropSymbols8(b)) {
|
|
1765
|
-
if (__propIsEnum8.call(b, prop))
|
|
1766
|
-
__defNormalProp8(a, prop, b[prop]);
|
|
1767
|
-
}
|
|
1768
|
-
return a;
|
|
1654
|
+
// src/helpers/url.ts
|
|
1655
|
+
var getTopLevelDomain = (host) => {
|
|
1656
|
+
if (host === "localhost" || host === "127.0.0.1") {
|
|
1657
|
+
return host;
|
|
1658
|
+
}
|
|
1659
|
+
const parts = host.split(".");
|
|
1660
|
+
if (parts.length > 2) {
|
|
1661
|
+
return parts.slice(1).join(".");
|
|
1662
|
+
}
|
|
1663
|
+
return host;
|
|
1769
1664
|
};
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
var checkShouldRunVariants = ({
|
|
1776
|
-
canTrack,
|
|
1777
|
-
content
|
|
1665
|
+
|
|
1666
|
+
// src/helpers/cookie.ts
|
|
1667
|
+
var getCookieSync = ({
|
|
1668
|
+
name,
|
|
1669
|
+
canTrack
|
|
1778
1670
|
}) => {
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
if (!hasVariants)
|
|
1783
|
-
return false;
|
|
1784
|
-
if (!canTrack)
|
|
1785
|
-
return false;
|
|
1786
|
-
if (TARGET === "vue2" || TARGET === "vue3")
|
|
1787
|
-
return true;
|
|
1788
|
-
if (isBrowser())
|
|
1789
|
-
return false;
|
|
1790
|
-
return true;
|
|
1791
|
-
};
|
|
1792
|
-
function bldrAbTest(contentId, variants, isHydrationTarget2) {
|
|
1793
|
-
var _a;
|
|
1794
|
-
function getAndSetVariantId2() {
|
|
1795
|
-
function setCookie2(name, value, days) {
|
|
1796
|
-
let expires = "";
|
|
1797
|
-
if (days) {
|
|
1798
|
-
const date = /* @__PURE__ */ new Date();
|
|
1799
|
-
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1e3);
|
|
1800
|
-
expires = "; expires=" + date.toUTCString();
|
|
1801
|
-
}
|
|
1802
|
-
document.cookie = name + "=" + (value || "") + expires + "; path=/; Secure; SameSite=None";
|
|
1803
|
-
}
|
|
1804
|
-
function getCookie2(name) {
|
|
1805
|
-
const nameEQ = name + "=";
|
|
1806
|
-
const ca = document.cookie.split(";");
|
|
1807
|
-
for (let i = 0; i < ca.length; i++) {
|
|
1808
|
-
let c = ca[i];
|
|
1809
|
-
while (c.charAt(0) === " ")
|
|
1810
|
-
c = c.substring(1, c.length);
|
|
1811
|
-
if (c.indexOf(nameEQ) === 0)
|
|
1812
|
-
return c.substring(nameEQ.length, c.length);
|
|
1813
|
-
}
|
|
1814
|
-
return null;
|
|
1671
|
+
try {
|
|
1672
|
+
if (!canTrack) {
|
|
1673
|
+
return void 0;
|
|
1815
1674
|
}
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1675
|
+
return document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))?.split("=")[1];
|
|
1676
|
+
} catch (err) {
|
|
1677
|
+
logger.warn("[COOKIE] GET error: ", err?.message || err);
|
|
1678
|
+
return void 0;
|
|
1679
|
+
}
|
|
1680
|
+
};
|
|
1681
|
+
var getCookie = async (args) => getCookieSync(args);
|
|
1682
|
+
var stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).filter(checkIsDefined).join("; ");
|
|
1683
|
+
var SECURE_CONFIG = [["secure", ""], ["SameSite", "None"]];
|
|
1684
|
+
var createCookieString = ({
|
|
1685
|
+
name,
|
|
1686
|
+
value,
|
|
1687
|
+
expires
|
|
1688
|
+
}) => {
|
|
1689
|
+
const secure = isBrowser() ? location.protocol === "https:" : true;
|
|
1690
|
+
const secureObj = secure ? SECURE_CONFIG : [[]];
|
|
1691
|
+
const expiresObj = expires ? [["expires", expires.toUTCString()]] : [[]];
|
|
1692
|
+
const cookieValue = [[name, value], ...expiresObj, ["path", "/"], ["domain", getTopLevelDomain(window.location.hostname)], ...secureObj];
|
|
1693
|
+
const cookie = stringifyCookie(cookieValue);
|
|
1694
|
+
return cookie;
|
|
1695
|
+
};
|
|
1696
|
+
var setCookie = async ({
|
|
1697
|
+
name,
|
|
1698
|
+
value,
|
|
1699
|
+
expires,
|
|
1700
|
+
canTrack
|
|
1701
|
+
}) => {
|
|
1702
|
+
try {
|
|
1703
|
+
if (!canTrack) {
|
|
1704
|
+
return;
|
|
1821
1705
|
}
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1706
|
+
const cookie = createCookieString({
|
|
1707
|
+
name,
|
|
1708
|
+
value,
|
|
1709
|
+
expires
|
|
1710
|
+
});
|
|
1711
|
+
document.cookie = cookie;
|
|
1712
|
+
} catch (err) {
|
|
1713
|
+
logger.warn("[COOKIE] SET error: ", err?.message || err);
|
|
1714
|
+
}
|
|
1715
|
+
};
|
|
1716
|
+
|
|
1717
|
+
// src/helpers/ab-tests.ts
|
|
1718
|
+
var BUILDER_STORE_PREFIX = "builder.tests";
|
|
1719
|
+
var getContentTestKey = (id) => `${BUILDER_STORE_PREFIX}.${id}`;
|
|
1720
|
+
var getContentVariationCookie = ({
|
|
1721
|
+
contentId
|
|
1722
|
+
}) => getCookie({
|
|
1723
|
+
name: getContentTestKey(contentId),
|
|
1724
|
+
canTrack: true
|
|
1725
|
+
});
|
|
1726
|
+
var getContentVariationCookieSync = ({
|
|
1727
|
+
contentId
|
|
1728
|
+
}) => getCookieSync({
|
|
1729
|
+
name: getContentTestKey(contentId),
|
|
1730
|
+
canTrack: true
|
|
1731
|
+
});
|
|
1732
|
+
var setContentVariationCookie = ({
|
|
1733
|
+
contentId,
|
|
1734
|
+
value
|
|
1735
|
+
}) => setCookie({
|
|
1736
|
+
name: getContentTestKey(contentId),
|
|
1737
|
+
value,
|
|
1738
|
+
canTrack: true
|
|
1739
|
+
});
|
|
1740
|
+
var checkIsBuilderContentWithVariations = (item) => checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
|
|
1741
|
+
var getRandomVariationId = ({
|
|
1742
|
+
id,
|
|
1743
|
+
variations
|
|
1744
|
+
}) => {
|
|
1745
|
+
let n = 0;
|
|
1746
|
+
const random = Math.random();
|
|
1747
|
+
for (const id2 in variations) {
|
|
1748
|
+
const testRatio = variations[id2]?.testRatio;
|
|
1749
|
+
n += testRatio;
|
|
1750
|
+
if (random < n) {
|
|
1751
|
+
return id2;
|
|
1832
1752
|
}
|
|
1833
|
-
setCookie2(cookieName, contentId);
|
|
1834
|
-
return contentId;
|
|
1835
1753
|
}
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1754
|
+
return id;
|
|
1755
|
+
};
|
|
1756
|
+
var getAndSetVariantId = (args) => {
|
|
1757
|
+
const randomVariationId = getRandomVariationId(args);
|
|
1758
|
+
setContentVariationCookie({
|
|
1759
|
+
contentId: args.id,
|
|
1760
|
+
value: randomVariationId
|
|
1761
|
+
}).catch((err) => {
|
|
1762
|
+
logger.error("could not store A/B test variation: ", err);
|
|
1763
|
+
});
|
|
1764
|
+
return randomVariationId;
|
|
1765
|
+
};
|
|
1766
|
+
var getTestFields = ({
|
|
1767
|
+
item,
|
|
1768
|
+
testGroupId
|
|
1769
|
+
}) => {
|
|
1770
|
+
const variationValue = item.variations[testGroupId];
|
|
1771
|
+
if (testGroupId === item.id || // handle edge-case where `testGroupId` points to non-existing variation
|
|
1772
|
+
!variationValue) {
|
|
1773
|
+
return {
|
|
1774
|
+
testVariationId: item.id,
|
|
1775
|
+
testVariationName: "Default"
|
|
1776
|
+
};
|
|
1842
1777
|
} else {
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
}).join("");
|
|
1849
|
-
styleEl.innerHTML = newStyleStr;
|
|
1778
|
+
return {
|
|
1779
|
+
data: variationValue.data,
|
|
1780
|
+
testVariationId: variationValue.id,
|
|
1781
|
+
testVariationName: variationValue.name || (variationValue.id === item.id ? "Default" : "")
|
|
1782
|
+
};
|
|
1850
1783
|
}
|
|
1851
|
-
}
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1784
|
+
};
|
|
1785
|
+
var handleABTestingSync = ({
|
|
1786
|
+
item,
|
|
1787
|
+
canTrack
|
|
1788
|
+
}) => {
|
|
1789
|
+
if (TARGET === "reactNative")
|
|
1790
|
+
return item;
|
|
1791
|
+
if (!canTrack) {
|
|
1792
|
+
return item;
|
|
1856
1793
|
}
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
const ca = document.cookie.split(";");
|
|
1860
|
-
for (let i = 0; i < ca.length; i++) {
|
|
1861
|
-
let c = ca[i];
|
|
1862
|
-
while (c.charAt(0) === " ")
|
|
1863
|
-
c = c.substring(1, c.length);
|
|
1864
|
-
if (c.indexOf(nameEQ) === 0)
|
|
1865
|
-
return c.substring(nameEQ.length, c.length);
|
|
1866
|
-
}
|
|
1867
|
-
return null;
|
|
1794
|
+
if (!item) {
|
|
1795
|
+
return void 0;
|
|
1868
1796
|
}
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
const parentDiv = (_a = document.currentScript) == null ? void 0 : _a.parentElement;
|
|
1872
|
-
const variantIsDefaultContent = variantContentId === defaultContentId;
|
|
1873
|
-
if (variantId === variantContentId) {
|
|
1874
|
-
if (variantIsDefaultContent) {
|
|
1875
|
-
return;
|
|
1876
|
-
}
|
|
1877
|
-
parentDiv == null ? void 0 : parentDiv.removeAttribute("hidden");
|
|
1878
|
-
parentDiv == null ? void 0 : parentDiv.removeAttribute("aria-hidden");
|
|
1879
|
-
} else {
|
|
1880
|
-
if (variantIsDefaultContent) {
|
|
1881
|
-
if (isHydrationTarget2) {
|
|
1882
|
-
parentDiv == null ? void 0 : parentDiv.remove();
|
|
1883
|
-
} else {
|
|
1884
|
-
parentDiv == null ? void 0 : parentDiv.setAttribute("hidden", "true");
|
|
1885
|
-
parentDiv == null ? void 0 : parentDiv.setAttribute("aria-hidden", "true");
|
|
1886
|
-
}
|
|
1887
|
-
}
|
|
1888
|
-
return;
|
|
1797
|
+
if (!checkIsBuilderContentWithVariations(item)) {
|
|
1798
|
+
return item;
|
|
1889
1799
|
}
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
};
|
|
1904
|
-
var getVariantsScriptString = (variants, contentId) => {
|
|
1905
|
-
return `
|
|
1906
|
-
window.${AB_TEST_FN_NAME}("${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget})`;
|
|
1800
|
+
const testGroupId = getContentVariationCookieSync({
|
|
1801
|
+
contentId: item.id
|
|
1802
|
+
}) || getAndSetVariantId({
|
|
1803
|
+
variations: item.variations,
|
|
1804
|
+
id: item.id
|
|
1805
|
+
});
|
|
1806
|
+
const variationValue = getTestFields({
|
|
1807
|
+
item,
|
|
1808
|
+
testGroupId
|
|
1809
|
+
});
|
|
1810
|
+
return {
|
|
1811
|
+
...item,
|
|
1812
|
+
...variationValue
|
|
1813
|
+
};
|
|
1907
1814
|
};
|
|
1908
|
-
var
|
|
1909
|
-
|
|
1910
|
-
|
|
1815
|
+
var handleABTesting = async ({
|
|
1816
|
+
item,
|
|
1817
|
+
canTrack
|
|
1911
1818
|
}) => {
|
|
1912
|
-
|
|
1913
|
-
|
|
1819
|
+
if (!canTrack) {
|
|
1820
|
+
return item;
|
|
1821
|
+
}
|
|
1822
|
+
if (!checkIsBuilderContentWithVariations(item)) {
|
|
1823
|
+
return item;
|
|
1824
|
+
}
|
|
1825
|
+
const cookieValue = await getContentVariationCookie({
|
|
1826
|
+
contentId: item.id
|
|
1827
|
+
});
|
|
1828
|
+
const testGroupId = cookieValue || getAndSetVariantId({
|
|
1829
|
+
variations: item.variations,
|
|
1830
|
+
id: item.id
|
|
1831
|
+
});
|
|
1832
|
+
const variationValue = getTestFields({
|
|
1833
|
+
item,
|
|
1834
|
+
testGroupId
|
|
1835
|
+
});
|
|
1836
|
+
return {
|
|
1837
|
+
...item,
|
|
1838
|
+
...variationValue
|
|
1839
|
+
};
|
|
1914
1840
|
};
|
|
1915
1841
|
|
|
1916
|
-
// src/
|
|
1842
|
+
// src/helpers/canTrack.ts
|
|
1843
|
+
var getDefaultCanTrack = (canTrack) => checkIsDefined(canTrack) ? canTrack : true;
|
|
1844
|
+
|
|
1845
|
+
// src/blocks/button/component-info.ts
|
|
1917
1846
|
var componentInfo = {
|
|
1918
1847
|
name: "Core:Button",
|
|
1919
1848
|
image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13",
|
|
1920
1849
|
defaultStyles: {
|
|
1850
|
+
// TODO: make min width more intuitive and set one
|
|
1921
1851
|
appearance: "none",
|
|
1922
1852
|
paddingTop: "15px",
|
|
1923
1853
|
paddingBottom: "15px",
|
|
@@ -1948,8 +1878,9 @@ var componentInfo = {
|
|
|
1948
1878
|
noWrap: true
|
|
1949
1879
|
};
|
|
1950
1880
|
|
|
1951
|
-
// src/blocks/columns/component-info.
|
|
1881
|
+
// src/blocks/columns/component-info.ts
|
|
1952
1882
|
var componentInfo2 = {
|
|
1883
|
+
// TODO: ways to statically preprocess JSON for references, functions, etc
|
|
1953
1884
|
name: "Columns",
|
|
1954
1885
|
isRSC: true,
|
|
1955
1886
|
inputs: [{
|
|
@@ -2167,17 +2098,179 @@ var componentInfo2 = {
|
|
|
2167
2098
|
}]
|
|
2168
2099
|
};
|
|
2169
2100
|
|
|
2170
|
-
// src/blocks/
|
|
2101
|
+
// src/blocks/custom-code/component-info.ts
|
|
2171
2102
|
var componentInfo3 = {
|
|
2172
|
-
name: "
|
|
2103
|
+
name: "Custom Code",
|
|
2173
2104
|
static: true,
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2105
|
+
requiredPermissions: ["editCode"],
|
|
2106
|
+
inputs: [{
|
|
2107
|
+
name: "code",
|
|
2108
|
+
type: "html",
|
|
2109
|
+
required: true,
|
|
2110
|
+
defaultValue: "<p>Hello there, I am custom HTML code!</p>",
|
|
2111
|
+
code: true
|
|
2112
|
+
}, {
|
|
2113
|
+
name: "replaceNodes",
|
|
2114
|
+
type: "boolean",
|
|
2115
|
+
helperText: "Preserve server rendered dom nodes",
|
|
2116
|
+
advanced: true
|
|
2117
|
+
}, {
|
|
2118
|
+
name: "scriptsClientOnly",
|
|
2119
|
+
type: "boolean",
|
|
2120
|
+
defaultValue: false,
|
|
2121
|
+
helperText: "Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads",
|
|
2122
|
+
advanced: true
|
|
2123
|
+
}]
|
|
2124
|
+
};
|
|
2125
|
+
var _tmpl$9 = /* @__PURE__ */ template(`<div>`);
|
|
2126
|
+
function CustomCode(props) {
|
|
2127
|
+
const [scriptsInserted, setScriptsInserted] = createSignal([]);
|
|
2128
|
+
const [scriptsRun, setScriptsRun] = createSignal([]);
|
|
2129
|
+
let elementRef;
|
|
2130
|
+
onMount(() => {
|
|
2131
|
+
if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
|
|
2132
|
+
return;
|
|
2133
|
+
}
|
|
2134
|
+
const scripts = elementRef.getElementsByTagName("script");
|
|
2135
|
+
for (let i = 0; i < scripts.length; i++) {
|
|
2136
|
+
const script = scripts[i];
|
|
2137
|
+
if (script.src) {
|
|
2138
|
+
if (scriptsInserted().includes(script.src)) {
|
|
2139
|
+
continue;
|
|
2140
|
+
}
|
|
2141
|
+
scriptsInserted().push(script.src);
|
|
2142
|
+
const newScript = document.createElement("script");
|
|
2143
|
+
newScript.async = true;
|
|
2144
|
+
newScript.src = script.src;
|
|
2145
|
+
document.head.appendChild(newScript);
|
|
2146
|
+
} else if (!script.type || ["text/javascript", "application/javascript", "application/ecmascript"].includes(script.type)) {
|
|
2147
|
+
if (scriptsRun().includes(script.innerText)) {
|
|
2148
|
+
continue;
|
|
2149
|
+
}
|
|
2150
|
+
try {
|
|
2151
|
+
scriptsRun().push(script.innerText);
|
|
2152
|
+
new Function(script.innerText)();
|
|
2153
|
+
} catch (error) {
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
}
|
|
2157
|
+
});
|
|
2158
|
+
return (() => {
|
|
2159
|
+
const _el$ = _tmpl$9();
|
|
2160
|
+
const _ref$ = elementRef;
|
|
2161
|
+
typeof _ref$ === "function" ? use(_ref$, _el$) : elementRef = _el$;
|
|
2162
|
+
effect((_p$) => {
|
|
2163
|
+
const _v$ = "builder-custom-code" + (props.replaceNodes ? " replace-nodes" : ""), _v$2 = props.code;
|
|
2164
|
+
_v$ !== _p$._v$ && className(_el$, _p$._v$ = _v$);
|
|
2165
|
+
_v$2 !== _p$._v$2 && (_el$.innerHTML = _p$._v$2 = _v$2);
|
|
2166
|
+
return _p$;
|
|
2167
|
+
}, {
|
|
2168
|
+
_v$: void 0,
|
|
2169
|
+
_v$2: void 0
|
|
2170
|
+
});
|
|
2171
|
+
return _el$;
|
|
2172
|
+
})();
|
|
2173
|
+
}
|
|
2174
|
+
var custom_code_default = CustomCode;
|
|
2178
2175
|
|
|
2179
|
-
// src/blocks/
|
|
2176
|
+
// src/blocks/embed/component-info.ts
|
|
2180
2177
|
var componentInfo4 = {
|
|
2178
|
+
name: "Embed",
|
|
2179
|
+
static: true,
|
|
2180
|
+
inputs: [{
|
|
2181
|
+
name: "url",
|
|
2182
|
+
type: "url",
|
|
2183
|
+
required: true,
|
|
2184
|
+
defaultValue: "",
|
|
2185
|
+
helperText: "e.g. enter a youtube url, google map, etc",
|
|
2186
|
+
onChange: (options) => {
|
|
2187
|
+
const url = options.get("url");
|
|
2188
|
+
if (url) {
|
|
2189
|
+
options.set("content", "Loading...");
|
|
2190
|
+
const apiKey = "ae0e60e78201a3f2b0de4b";
|
|
2191
|
+
return fetch(`https://iframe.ly/api/iframely?url=${url}&api_key=${apiKey}`).then((res) => res.json()).then((data) => {
|
|
2192
|
+
if (options.get("url") === url) {
|
|
2193
|
+
if (data.html) {
|
|
2194
|
+
options.set("content", data.html);
|
|
2195
|
+
} else {
|
|
2196
|
+
options.set("content", "Invalid url, please try another");
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2199
|
+
}).catch((_err) => {
|
|
2200
|
+
options.set("content", "There was an error embedding this URL, please try again or another URL");
|
|
2201
|
+
});
|
|
2202
|
+
} else {
|
|
2203
|
+
options.delete("content");
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
}, {
|
|
2207
|
+
name: "content",
|
|
2208
|
+
type: "html",
|
|
2209
|
+
defaultValue: '<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',
|
|
2210
|
+
hideFromUI: true
|
|
2211
|
+
}]
|
|
2212
|
+
};
|
|
2213
|
+
|
|
2214
|
+
// src/blocks/embed/helpers.ts
|
|
2215
|
+
var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
|
|
2216
|
+
var isJsScript = (script) => SCRIPT_MIME_TYPES.includes(script.type);
|
|
2217
|
+
|
|
2218
|
+
// src/blocks/embed/embed.tsx
|
|
2219
|
+
var _tmpl$10 = /* @__PURE__ */ template(`<div class=builder-embed>`);
|
|
2220
|
+
function Embed(props) {
|
|
2221
|
+
const [scriptsInserted, setScriptsInserted] = createSignal([]);
|
|
2222
|
+
const [scriptsRun, setScriptsRun] = createSignal([]);
|
|
2223
|
+
const [ranInitFn, setRanInitFn] = createSignal(false);
|
|
2224
|
+
function findAndRunScripts() {
|
|
2225
|
+
if (!elem || !elem.getElementsByTagName)
|
|
2226
|
+
return;
|
|
2227
|
+
const scripts = elem.getElementsByTagName("script");
|
|
2228
|
+
for (let i = 0; i < scripts.length; i++) {
|
|
2229
|
+
const script = scripts[i];
|
|
2230
|
+
if (script.src && !scriptsInserted().includes(script.src)) {
|
|
2231
|
+
scriptsInserted().push(script.src);
|
|
2232
|
+
const newScript = document.createElement("script");
|
|
2233
|
+
newScript.async = true;
|
|
2234
|
+
newScript.src = script.src;
|
|
2235
|
+
document.head.appendChild(newScript);
|
|
2236
|
+
} else if (isJsScript(script) && !scriptsRun().includes(script.innerText)) {
|
|
2237
|
+
try {
|
|
2238
|
+
scriptsRun().push(script.innerText);
|
|
2239
|
+
new Function(script.innerText)();
|
|
2240
|
+
} catch (error) {
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
let elem;
|
|
2246
|
+
function onUpdateFn_0() {
|
|
2247
|
+
if (elem && !ranInitFn()) {
|
|
2248
|
+
setRanInitFn(true);
|
|
2249
|
+
findAndRunScripts();
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
createEffect(on(() => [elem, ranInitFn()], onUpdateFn_0));
|
|
2253
|
+
return (() => {
|
|
2254
|
+
const _el$ = _tmpl$10();
|
|
2255
|
+
const _ref$ = elem;
|
|
2256
|
+
typeof _ref$ === "function" ? use(_ref$, _el$) : elem = _el$;
|
|
2257
|
+
effect(() => _el$.innerHTML = props.content);
|
|
2258
|
+
return _el$;
|
|
2259
|
+
})();
|
|
2260
|
+
}
|
|
2261
|
+
var embed_default = Embed;
|
|
2262
|
+
|
|
2263
|
+
// src/blocks/fragment/component-info.ts
|
|
2264
|
+
var componentInfo5 = {
|
|
2265
|
+
name: "Fragment",
|
|
2266
|
+
static: true,
|
|
2267
|
+
hidden: true,
|
|
2268
|
+
canHaveChildren: true,
|
|
2269
|
+
noWrap: true
|
|
2270
|
+
};
|
|
2271
|
+
|
|
2272
|
+
// src/blocks/image/component-info.ts
|
|
2273
|
+
var componentInfo6 = {
|
|
2181
2274
|
name: "Image",
|
|
2182
2275
|
static: true,
|
|
2183
2276
|
image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4",
|
|
@@ -2298,8 +2391,50 @@ var componentInfo4 = {
|
|
|
2298
2391
|
}]
|
|
2299
2392
|
};
|
|
2300
2393
|
|
|
2301
|
-
// src/blocks/
|
|
2302
|
-
var
|
|
2394
|
+
// src/blocks/img/component-info.ts
|
|
2395
|
+
var componentInfo7 = {
|
|
2396
|
+
// friendlyName?
|
|
2397
|
+
name: "Raw:Img",
|
|
2398
|
+
hideFromInsertMenu: true,
|
|
2399
|
+
image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4",
|
|
2400
|
+
inputs: [{
|
|
2401
|
+
name: "image",
|
|
2402
|
+
bubble: true,
|
|
2403
|
+
type: "file",
|
|
2404
|
+
allowedFileTypes: ["jpeg", "jpg", "png", "svg", "gif", "webp"],
|
|
2405
|
+
required: true
|
|
2406
|
+
}],
|
|
2407
|
+
noWrap: true,
|
|
2408
|
+
static: true
|
|
2409
|
+
};
|
|
2410
|
+
var _tmpl$11 = /* @__PURE__ */ template(`<img>`);
|
|
2411
|
+
function ImgComponent(props) {
|
|
2412
|
+
return (() => {
|
|
2413
|
+
const _el$ = _tmpl$11();
|
|
2414
|
+
spread(_el$, mergeProps({
|
|
2415
|
+
get style() {
|
|
2416
|
+
return {
|
|
2417
|
+
"object-fit": props.backgroundSize || "cover",
|
|
2418
|
+
"object-position": props.backgroundPosition || "center"
|
|
2419
|
+
};
|
|
2420
|
+
},
|
|
2421
|
+
get key() {
|
|
2422
|
+
return isEditing() && props.imgSrc || "default-key";
|
|
2423
|
+
},
|
|
2424
|
+
get alt() {
|
|
2425
|
+
return props.altText;
|
|
2426
|
+
},
|
|
2427
|
+
get src() {
|
|
2428
|
+
return props.imgSrc || props.image;
|
|
2429
|
+
}
|
|
2430
|
+
}, {}, () => props.attributes), false, false);
|
|
2431
|
+
return _el$;
|
|
2432
|
+
})();
|
|
2433
|
+
}
|
|
2434
|
+
var img_default = ImgComponent;
|
|
2435
|
+
|
|
2436
|
+
// src/blocks/section/component-info.ts
|
|
2437
|
+
var componentInfo8 = {
|
|
2303
2438
|
name: "Core:Section",
|
|
2304
2439
|
static: true,
|
|
2305
2440
|
image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F682efef23ace49afac61748dd305c70a",
|
|
@@ -2340,8 +2475,8 @@ var componentInfo5 = {
|
|
|
2340
2475
|
}]
|
|
2341
2476
|
};
|
|
2342
2477
|
|
|
2343
|
-
// src/blocks/symbol/component-info.
|
|
2344
|
-
var
|
|
2478
|
+
// src/blocks/symbol/component-info.ts
|
|
2479
|
+
var componentInfo9 = {
|
|
2345
2480
|
name: "Symbol",
|
|
2346
2481
|
noWrap: true,
|
|
2347
2482
|
static: true,
|
|
@@ -2376,8 +2511,8 @@ var componentInfo6 = {
|
|
|
2376
2511
|
}]
|
|
2377
2512
|
};
|
|
2378
2513
|
|
|
2379
|
-
// src/blocks/text/component-info.
|
|
2380
|
-
var
|
|
2514
|
+
// src/blocks/text/component-info.ts
|
|
2515
|
+
var componentInfo10 = {
|
|
2381
2516
|
name: "Text",
|
|
2382
2517
|
static: true,
|
|
2383
2518
|
isRSC: true,
|
|
@@ -2396,10 +2531,10 @@ var componentInfo7 = {
|
|
|
2396
2531
|
textAlign: "center"
|
|
2397
2532
|
}
|
|
2398
2533
|
};
|
|
2399
|
-
var _tmpl$
|
|
2534
|
+
var _tmpl$12 = /* @__PURE__ */ template(`<div class=builder-text>`);
|
|
2400
2535
|
function Text(props) {
|
|
2401
2536
|
return (() => {
|
|
2402
|
-
const _el$ = _tmpl$
|
|
2537
|
+
const _el$ = _tmpl$12();
|
|
2403
2538
|
_el$.style.setProperty("outline", "none");
|
|
2404
2539
|
effect(() => _el$.innerHTML = props.text?.toString() || "");
|
|
2405
2540
|
return _el$;
|
|
@@ -2407,8 +2542,8 @@ function Text(props) {
|
|
|
2407
2542
|
}
|
|
2408
2543
|
var text_default = Text;
|
|
2409
2544
|
|
|
2410
|
-
// src/blocks/video/component-info.
|
|
2411
|
-
var
|
|
2545
|
+
// src/blocks/video/component-info.ts
|
|
2546
|
+
var componentInfo11 = {
|
|
2412
2547
|
name: "Video",
|
|
2413
2548
|
canHaveChildren: true,
|
|
2414
2549
|
defaultStyles: {
|
|
@@ -2490,7 +2625,7 @@ var componentInfo8 = {
|
|
|
2490
2625
|
advanced: true
|
|
2491
2626
|
}]
|
|
2492
2627
|
};
|
|
2493
|
-
var _tmpl$
|
|
2628
|
+
var _tmpl$13 = /* @__PURE__ */ template(`<video>`);
|
|
2494
2629
|
function Video(props) {
|
|
2495
2630
|
function videoProps() {
|
|
2496
2631
|
return {
|
|
@@ -2518,7 +2653,7 @@ function Video(props) {
|
|
|
2518
2653
|
};
|
|
2519
2654
|
}
|
|
2520
2655
|
return (() => {
|
|
2521
|
-
const _el$ = _tmpl$
|
|
2656
|
+
const _el$ = _tmpl$13();
|
|
2522
2657
|
spread(_el$, mergeProps(spreadProps, {
|
|
2523
2658
|
get preload() {
|
|
2524
2659
|
return props.preload || "metadata";
|
|
@@ -2547,174 +2682,217 @@ function Video(props) {
|
|
|
2547
2682
|
}
|
|
2548
2683
|
var video_default = Video;
|
|
2549
2684
|
|
|
2550
|
-
// src/
|
|
2551
|
-
var
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
}]
|
|
2586
|
-
};
|
|
2587
|
-
|
|
2588
|
-
// src/blocks/embed/helpers.js
|
|
2589
|
-
var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
|
|
2590
|
-
var isJsScript = (script) => SCRIPT_MIME_TYPES.includes(script.type);
|
|
2685
|
+
// src/constants/builder-registered-components.ts
|
|
2686
|
+
var getDefaultRegisteredComponents = () => [{
|
|
2687
|
+
component: button_default,
|
|
2688
|
+
...componentInfo
|
|
2689
|
+
}, {
|
|
2690
|
+
component: columns_default,
|
|
2691
|
+
...componentInfo2
|
|
2692
|
+
}, {
|
|
2693
|
+
component: custom_code_default,
|
|
2694
|
+
...componentInfo3
|
|
2695
|
+
}, {
|
|
2696
|
+
component: embed_default,
|
|
2697
|
+
...componentInfo4
|
|
2698
|
+
}, {
|
|
2699
|
+
component: fragment_default,
|
|
2700
|
+
...componentInfo5
|
|
2701
|
+
}, {
|
|
2702
|
+
component: image_default,
|
|
2703
|
+
...componentInfo6
|
|
2704
|
+
}, {
|
|
2705
|
+
component: img_default,
|
|
2706
|
+
...componentInfo7
|
|
2707
|
+
}, {
|
|
2708
|
+
component: section_default,
|
|
2709
|
+
...componentInfo8
|
|
2710
|
+
}, {
|
|
2711
|
+
component: symbol_default,
|
|
2712
|
+
...componentInfo9
|
|
2713
|
+
}, {
|
|
2714
|
+
component: text_default,
|
|
2715
|
+
...componentInfo10
|
|
2716
|
+
}, {
|
|
2717
|
+
component: video_default,
|
|
2718
|
+
...componentInfo11
|
|
2719
|
+
}];
|
|
2591
2720
|
|
|
2592
|
-
// src/
|
|
2593
|
-
var
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2721
|
+
// src/functions/register-component.ts
|
|
2722
|
+
var components = [];
|
|
2723
|
+
var createRegisterComponentMessage = (info) => ({
|
|
2724
|
+
type: "builder.registerComponent",
|
|
2725
|
+
data: serializeComponentInfo(info)
|
|
2726
|
+
});
|
|
2727
|
+
var serializeFn = (fnValue) => {
|
|
2728
|
+
const fnStr = fnValue.toString().trim();
|
|
2729
|
+
const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(");
|
|
2730
|
+
return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
|
|
2731
|
+
};
|
|
2732
|
+
var serializeValue = (value) => typeof value === "function" ? serializeFn(value) : fastClone(value);
|
|
2733
|
+
var serializeComponentInfo = ({
|
|
2734
|
+
inputs,
|
|
2735
|
+
...info
|
|
2736
|
+
}) => ({
|
|
2737
|
+
...fastClone(info),
|
|
2738
|
+
inputs: inputs?.map((input) => Object.entries(input).reduce((acc, [key, value]) => ({
|
|
2739
|
+
...acc,
|
|
2740
|
+
[key]: serializeValue(value)
|
|
2741
|
+
}), {}))
|
|
2742
|
+
});
|
|
2743
|
+
|
|
2744
|
+
// src/components/content-variants/helpers.ts
|
|
2745
|
+
var getVariants = (content) => Object.values(content?.variations || {}).map((variant) => ({
|
|
2746
|
+
...variant,
|
|
2747
|
+
testVariationId: variant.id,
|
|
2748
|
+
id: content?.id
|
|
2749
|
+
}));
|
|
2750
|
+
var checkShouldRunVariants = ({
|
|
2751
|
+
canTrack,
|
|
2752
|
+
content
|
|
2753
|
+
}) => {
|
|
2754
|
+
const hasVariants = getVariants(content).length > 0;
|
|
2755
|
+
if (TARGET === "reactNative")
|
|
2756
|
+
return false;
|
|
2757
|
+
if (!hasVariants)
|
|
2758
|
+
return false;
|
|
2759
|
+
if (!canTrack)
|
|
2760
|
+
return false;
|
|
2761
|
+
if (TARGET === "vue2" || TARGET === "vue3")
|
|
2762
|
+
return true;
|
|
2763
|
+
if (isBrowser())
|
|
2764
|
+
return false;
|
|
2765
|
+
return true;
|
|
2766
|
+
};
|
|
2767
|
+
function bldrAbTest(contentId, variants, isHydrationTarget2) {
|
|
2768
|
+
function getAndSetVariantId2() {
|
|
2769
|
+
function setCookie2(name, value, days) {
|
|
2770
|
+
let expires = "";
|
|
2771
|
+
if (days) {
|
|
2772
|
+
const date = /* @__PURE__ */ new Date();
|
|
2773
|
+
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1e3);
|
|
2774
|
+
expires = "; expires=" + date.toUTCString();
|
|
2616
2775
|
}
|
|
2776
|
+
document.cookie = name + "=" + (value || "") + expires + "; path=/; Secure; SameSite=None";
|
|
2617
2777
|
}
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2778
|
+
function getCookie2(name) {
|
|
2779
|
+
const nameEQ = name + "=";
|
|
2780
|
+
const ca = document.cookie.split(";");
|
|
2781
|
+
for (let i = 0; i < ca.length; i++) {
|
|
2782
|
+
let c = ca[i];
|
|
2783
|
+
while (c.charAt(0) === " ")
|
|
2784
|
+
c = c.substring(1, c.length);
|
|
2785
|
+
if (c.indexOf(nameEQ) === 0)
|
|
2786
|
+
return c.substring(nameEQ.length, c.length);
|
|
2787
|
+
}
|
|
2788
|
+
return null;
|
|
2624
2789
|
}
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
spread(_el$, mergeProps({
|
|
2641
|
-
get style() {
|
|
2642
|
-
return {
|
|
2643
|
-
"object-fit": props.backgroundSize || "cover",
|
|
2644
|
-
"object-position": props.backgroundPosition || "center"
|
|
2645
|
-
};
|
|
2646
|
-
},
|
|
2647
|
-
get key() {
|
|
2648
|
-
return isEditing() && props.imgSrc || "default-key";
|
|
2649
|
-
},
|
|
2650
|
-
get alt() {
|
|
2651
|
-
return props.altText;
|
|
2652
|
-
},
|
|
2653
|
-
get src() {
|
|
2654
|
-
return props.imgSrc || props.image;
|
|
2790
|
+
const cookieName = `builder.tests.${contentId}`;
|
|
2791
|
+
const variantInCookie = getCookie2(cookieName);
|
|
2792
|
+
const availableIDs = variants.map((vr) => vr.id).concat(contentId);
|
|
2793
|
+
if (variantInCookie && availableIDs.includes(variantInCookie)) {
|
|
2794
|
+
return variantInCookie;
|
|
2795
|
+
}
|
|
2796
|
+
let n = 0;
|
|
2797
|
+
const random = Math.random();
|
|
2798
|
+
for (let i = 0; i < variants.length; i++) {
|
|
2799
|
+
const variant = variants[i];
|
|
2800
|
+
const testRatio = variant.testRatio;
|
|
2801
|
+
n += testRatio;
|
|
2802
|
+
if (random < n) {
|
|
2803
|
+
setCookie2(cookieName, variant.id);
|
|
2804
|
+
return variant.id;
|
|
2655
2805
|
}
|
|
2656
|
-
}
|
|
2657
|
-
|
|
2658
|
-
|
|
2806
|
+
}
|
|
2807
|
+
setCookie2(cookieName, contentId);
|
|
2808
|
+
return contentId;
|
|
2809
|
+
}
|
|
2810
|
+
const winningVariantId = getAndSetVariantId2();
|
|
2811
|
+
const styleEl = document.currentScript?.previousElementSibling;
|
|
2812
|
+
if (isHydrationTarget2) {
|
|
2813
|
+
styleEl.remove();
|
|
2814
|
+
const thisScriptEl = document.currentScript;
|
|
2815
|
+
thisScriptEl?.remove();
|
|
2816
|
+
} else {
|
|
2817
|
+
const newStyleStr = variants.concat({
|
|
2818
|
+
id: contentId
|
|
2819
|
+
}).filter((variant) => variant.id !== winningVariantId).map((value) => {
|
|
2820
|
+
return `.variant-${value.id} { display: none; }
|
|
2821
|
+
`;
|
|
2822
|
+
}).join("");
|
|
2823
|
+
styleEl.innerHTML = newStyleStr;
|
|
2824
|
+
}
|
|
2659
2825
|
}
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
name
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
}
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
const
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
onMount(() => {
|
|
2683
|
-
if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
|
|
2826
|
+
function bldrCntntScrpt(variantContentId, defaultContentId, isHydrationTarget2) {
|
|
2827
|
+
if (!navigator.cookieEnabled) {
|
|
2828
|
+
return;
|
|
2829
|
+
}
|
|
2830
|
+
function getCookie2(name) {
|
|
2831
|
+
const nameEQ = name + "=";
|
|
2832
|
+
const ca = document.cookie.split(";");
|
|
2833
|
+
for (let i = 0; i < ca.length; i++) {
|
|
2834
|
+
let c = ca[i];
|
|
2835
|
+
while (c.charAt(0) === " ")
|
|
2836
|
+
c = c.substring(1, c.length);
|
|
2837
|
+
if (c.indexOf(nameEQ) === 0)
|
|
2838
|
+
return c.substring(nameEQ.length, c.length);
|
|
2839
|
+
}
|
|
2840
|
+
return null;
|
|
2841
|
+
}
|
|
2842
|
+
const cookieName = `builder.tests.${defaultContentId}`;
|
|
2843
|
+
const variantId = getCookie2(cookieName);
|
|
2844
|
+
const parentDiv = document.currentScript?.parentElement;
|
|
2845
|
+
const variantIsDefaultContent = variantContentId === defaultContentId;
|
|
2846
|
+
if (variantId === variantContentId) {
|
|
2847
|
+
if (variantIsDefaultContent) {
|
|
2684
2848
|
return;
|
|
2685
2849
|
}
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
newScript.async = true;
|
|
2696
|
-
newScript.src = script.src;
|
|
2697
|
-
document.head.appendChild(newScript);
|
|
2698
|
-
} else if (!script.type || ["text/javascript", "application/javascript", "application/ecmascript"].includes(script.type)) {
|
|
2699
|
-
if (scriptsRun().includes(script.innerText)) {
|
|
2700
|
-
continue;
|
|
2701
|
-
}
|
|
2702
|
-
try {
|
|
2703
|
-
scriptsRun().push(script.innerText);
|
|
2704
|
-
new Function(script.innerText)();
|
|
2705
|
-
} catch (error) {
|
|
2706
|
-
}
|
|
2850
|
+
parentDiv?.removeAttribute("hidden");
|
|
2851
|
+
parentDiv?.removeAttribute("aria-hidden");
|
|
2852
|
+
} else {
|
|
2853
|
+
if (variantIsDefaultContent) {
|
|
2854
|
+
if (isHydrationTarget2) {
|
|
2855
|
+
parentDiv?.remove();
|
|
2856
|
+
} else {
|
|
2857
|
+
parentDiv?.setAttribute("hidden", "true");
|
|
2858
|
+
parentDiv?.setAttribute("aria-hidden", "true");
|
|
2707
2859
|
}
|
|
2708
2860
|
}
|
|
2709
|
-
|
|
2861
|
+
return;
|
|
2862
|
+
}
|
|
2863
|
+
return;
|
|
2864
|
+
}
|
|
2865
|
+
var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
|
|
2866
|
+
var isHydrationTarget = getIsHydrationTarget(TARGET);
|
|
2867
|
+
var AB_TEST_FN_NAME = "builderIoAbTest";
|
|
2868
|
+
var CONTENT_FN_NAME = "builderIoRenderContent";
|
|
2869
|
+
var getScriptString = () => {
|
|
2870
|
+
const fnStr = bldrAbTest.toString().replace(/\s+/g, " ");
|
|
2871
|
+
const fnStr2 = bldrCntntScrpt.toString().replace(/\s+/g, " ");
|
|
2872
|
+
return `
|
|
2873
|
+
window.${AB_TEST_FN_NAME} = ${fnStr}
|
|
2874
|
+
window.${CONTENT_FN_NAME} = ${fnStr2}
|
|
2875
|
+
`;
|
|
2876
|
+
};
|
|
2877
|
+
var getVariantsScriptString = (variants, contentId) => {
|
|
2878
|
+
return `
|
|
2879
|
+
window.${AB_TEST_FN_NAME}("${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget})`;
|
|
2880
|
+
};
|
|
2881
|
+
var getRenderContentScriptString = ({
|
|
2882
|
+
contentId,
|
|
2883
|
+
variationId
|
|
2884
|
+
}) => {
|
|
2885
|
+
return `
|
|
2886
|
+
window.${CONTENT_FN_NAME}("${variationId}", "${contentId}", ${isHydrationTarget})`;
|
|
2887
|
+
};
|
|
2888
|
+
var _tmpl$14 = /* @__PURE__ */ template(`<script>`);
|
|
2889
|
+
function InlinedScript(props) {
|
|
2710
2890
|
return (() => {
|
|
2711
|
-
const _el$ = _tmpl$
|
|
2712
|
-
const _ref$ = elementRef;
|
|
2713
|
-
typeof _ref$ === "function" ? use(_ref$, _el$) : elementRef = _el$;
|
|
2891
|
+
const _el$ = _tmpl$14();
|
|
2714
2892
|
effect((_p$) => {
|
|
2715
|
-
const _v$ =
|
|
2716
|
-
_v$ !== _p$._v$ &&
|
|
2717
|
-
_v$2 !== _p$._v$2 && (_el
|
|
2893
|
+
const _v$ = props.scriptStr, _v$2 = props.id;
|
|
2894
|
+
_v$ !== _p$._v$ && (_el$.innerHTML = _p$._v$ = _v$);
|
|
2895
|
+
_v$2 !== _p$._v$2 && setAttribute(_el$, "id", _p$._v$2 = _v$2);
|
|
2718
2896
|
return _p$;
|
|
2719
2897
|
}, {
|
|
2720
2898
|
_v$: void 0,
|
|
@@ -2723,281 +2901,14 @@ function CustomCode(props) {
|
|
|
2723
2901
|
return _el$;
|
|
2724
2902
|
})();
|
|
2725
2903
|
}
|
|
2726
|
-
var
|
|
2904
|
+
var inlined_script_default = InlinedScript;
|
|
2727
2905
|
|
|
2728
|
-
// src/
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
static: true,
|
|
2732
|
-
requiredPermissions: ["editCode"],
|
|
2733
|
-
inputs: [{
|
|
2734
|
-
name: "code",
|
|
2735
|
-
type: "html",
|
|
2736
|
-
required: true,
|
|
2737
|
-
defaultValue: "<p>Hello there, I am custom HTML code!</p>",
|
|
2738
|
-
code: true
|
|
2739
|
-
}, {
|
|
2740
|
-
name: "replaceNodes",
|
|
2741
|
-
type: "boolean",
|
|
2742
|
-
helperText: "Preserve server rendered dom nodes",
|
|
2743
|
-
advanced: true
|
|
2744
|
-
}, {
|
|
2745
|
-
name: "scriptsClientOnly",
|
|
2746
|
-
type: "boolean",
|
|
2747
|
-
defaultValue: false,
|
|
2748
|
-
helperText: "Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads",
|
|
2749
|
-
advanced: true
|
|
2750
|
-
}]
|
|
2751
|
-
};
|
|
2752
|
-
|
|
2753
|
-
// src/constants/builder-registered-components.js
|
|
2754
|
-
var __defProp9 = Object.defineProperty;
|
|
2755
|
-
var __getOwnPropSymbols9 = Object.getOwnPropertySymbols;
|
|
2756
|
-
var __hasOwnProp9 = Object.prototype.hasOwnProperty;
|
|
2757
|
-
var __propIsEnum9 = Object.prototype.propertyIsEnumerable;
|
|
2758
|
-
var __defNormalProp9 = (obj, key, value) => key in obj ? __defProp9(obj, key, {
|
|
2759
|
-
enumerable: true,
|
|
2760
|
-
configurable: true,
|
|
2761
|
-
writable: true,
|
|
2762
|
-
value
|
|
2763
|
-
}) : obj[key] = value;
|
|
2764
|
-
var __spreadValues9 = (a, b) => {
|
|
2765
|
-
for (var prop in b || (b = {}))
|
|
2766
|
-
if (__hasOwnProp9.call(b, prop))
|
|
2767
|
-
__defNormalProp9(a, prop, b[prop]);
|
|
2768
|
-
if (__getOwnPropSymbols9)
|
|
2769
|
-
for (var prop of __getOwnPropSymbols9(b)) {
|
|
2770
|
-
if (__propIsEnum9.call(b, prop))
|
|
2771
|
-
__defNormalProp9(a, prop, b[prop]);
|
|
2772
|
-
}
|
|
2773
|
-
return a;
|
|
2774
|
-
};
|
|
2775
|
-
var getDefaultRegisteredComponents = () => [__spreadValues9({
|
|
2776
|
-
component: button_default
|
|
2777
|
-
}, componentInfo), __spreadValues9({
|
|
2778
|
-
component: columns_default
|
|
2779
|
-
}, componentInfo2), __spreadValues9({
|
|
2780
|
-
component: custom_code_default
|
|
2781
|
-
}, componentInfo11), __spreadValues9({
|
|
2782
|
-
component: embed_default
|
|
2783
|
-
}, componentInfo9), __spreadValues9({
|
|
2784
|
-
component: fragment_default
|
|
2785
|
-
}, componentInfo3), __spreadValues9({
|
|
2786
|
-
component: image_default
|
|
2787
|
-
}, componentInfo4), __spreadValues9({
|
|
2788
|
-
component: img_default
|
|
2789
|
-
}, componentInfo10), __spreadValues9({
|
|
2790
|
-
component: section_default
|
|
2791
|
-
}, componentInfo5), __spreadValues9({
|
|
2792
|
-
component: symbol_default
|
|
2793
|
-
}, componentInfo6), __spreadValues9({
|
|
2794
|
-
component: text_default
|
|
2795
|
-
}, componentInfo7), __spreadValues9({
|
|
2796
|
-
component: video_default
|
|
2797
|
-
}, componentInfo8)];
|
|
2798
|
-
|
|
2799
|
-
// src/functions/register-component.js
|
|
2800
|
-
var __defProp10 = Object.defineProperty;
|
|
2801
|
-
var __defProps7 = Object.defineProperties;
|
|
2802
|
-
var __getOwnPropDescs7 = Object.getOwnPropertyDescriptors;
|
|
2803
|
-
var __getOwnPropSymbols10 = Object.getOwnPropertySymbols;
|
|
2804
|
-
var __hasOwnProp10 = Object.prototype.hasOwnProperty;
|
|
2805
|
-
var __propIsEnum10 = Object.prototype.propertyIsEnumerable;
|
|
2806
|
-
var __defNormalProp10 = (obj, key, value) => key in obj ? __defProp10(obj, key, {
|
|
2807
|
-
enumerable: true,
|
|
2808
|
-
configurable: true,
|
|
2809
|
-
writable: true,
|
|
2810
|
-
value
|
|
2811
|
-
}) : obj[key] = value;
|
|
2812
|
-
var __spreadValues10 = (a, b) => {
|
|
2813
|
-
for (var prop in b || (b = {}))
|
|
2814
|
-
if (__hasOwnProp10.call(b, prop))
|
|
2815
|
-
__defNormalProp10(a, prop, b[prop]);
|
|
2816
|
-
if (__getOwnPropSymbols10)
|
|
2817
|
-
for (var prop of __getOwnPropSymbols10(b)) {
|
|
2818
|
-
if (__propIsEnum10.call(b, prop))
|
|
2819
|
-
__defNormalProp10(a, prop, b[prop]);
|
|
2820
|
-
}
|
|
2821
|
-
return a;
|
|
2822
|
-
};
|
|
2823
|
-
var __spreadProps7 = (a, b) => __defProps7(a, __getOwnPropDescs7(b));
|
|
2824
|
-
var __objRest2 = (source, exclude) => {
|
|
2825
|
-
var target = {};
|
|
2826
|
-
for (var prop in source)
|
|
2827
|
-
if (__hasOwnProp10.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
2828
|
-
target[prop] = source[prop];
|
|
2829
|
-
if (source != null && __getOwnPropSymbols10)
|
|
2830
|
-
for (var prop of __getOwnPropSymbols10(source)) {
|
|
2831
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum10.call(source, prop))
|
|
2832
|
-
target[prop] = source[prop];
|
|
2833
|
-
}
|
|
2834
|
-
return target;
|
|
2835
|
-
};
|
|
2836
|
-
var components = [];
|
|
2837
|
-
var createRegisterComponentMessage = (info) => ({
|
|
2838
|
-
type: "builder.registerComponent",
|
|
2839
|
-
data: serializeComponentInfo(info)
|
|
2840
|
-
});
|
|
2841
|
-
var serializeFn = (fnValue) => {
|
|
2842
|
-
const fnStr = fnValue.toString().trim();
|
|
2843
|
-
const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(");
|
|
2844
|
-
return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
|
|
2845
|
-
};
|
|
2846
|
-
var serializeValue = (value) => typeof value === "function" ? serializeFn(value) : fastClone(value);
|
|
2847
|
-
var serializeComponentInfo = (_a) => {
|
|
2848
|
-
var _b = _a, {
|
|
2849
|
-
inputs
|
|
2850
|
-
} = _b, info = __objRest2(_b, ["inputs"]);
|
|
2851
|
-
return __spreadProps7(__spreadValues10({}, fastClone(info)), {
|
|
2852
|
-
inputs: inputs == null ? void 0 : inputs.map((input) => Object.entries(input).reduce((acc, [key, value]) => __spreadProps7(__spreadValues10({}, acc), {
|
|
2853
|
-
[key]: serializeValue(value)
|
|
2854
|
-
}), {}))
|
|
2855
|
-
});
|
|
2856
|
-
};
|
|
2857
|
-
|
|
2858
|
-
// src/components/content/components/styles.helpers.js
|
|
2859
|
-
var getCssFromFont = (font) => {
|
|
2860
|
-
var _a, _b;
|
|
2861
|
-
const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
|
|
2862
|
-
const name = family.split(",")[0];
|
|
2863
|
-
const url = (_b = font.fileUrl) != null ? _b : (_a = font == null ? void 0 : font.files) == null ? void 0 : _a.regular;
|
|
2864
|
-
let str = "";
|
|
2865
|
-
if (url && family && name) {
|
|
2866
|
-
str += `
|
|
2867
|
-
@font-face {
|
|
2868
|
-
font-family: "${family}";
|
|
2869
|
-
src: local("${name}"), url('${url}') format('woff2');
|
|
2870
|
-
font-display: fallback;
|
|
2871
|
-
font-weight: 400;
|
|
2872
|
-
}
|
|
2873
|
-
`.trim();
|
|
2874
|
-
}
|
|
2875
|
-
if (font.files) {
|
|
2876
|
-
for (const weight in font.files) {
|
|
2877
|
-
const isNumber = String(Number(weight)) === weight;
|
|
2878
|
-
if (!isNumber) {
|
|
2879
|
-
continue;
|
|
2880
|
-
}
|
|
2881
|
-
const weightUrl = font.files[weight];
|
|
2882
|
-
if (weightUrl && weightUrl !== url) {
|
|
2883
|
-
str += `
|
|
2884
|
-
@font-face {
|
|
2885
|
-
font-family: "${family}";
|
|
2886
|
-
src: url('${weightUrl}') format('woff2');
|
|
2887
|
-
font-display: fallback;
|
|
2888
|
-
font-weight: ${weight};
|
|
2889
|
-
}
|
|
2890
|
-
`.trim();
|
|
2891
|
-
}
|
|
2892
|
-
}
|
|
2893
|
-
}
|
|
2894
|
-
return str;
|
|
2895
|
-
};
|
|
2896
|
-
var getFontCss = ({
|
|
2897
|
-
customFonts
|
|
2898
|
-
}) => {
|
|
2899
|
-
var _a;
|
|
2900
|
-
return ((_a = customFonts == null ? void 0 : customFonts.map((font) => getCssFromFont(font))) == null ? void 0 : _a.join(" ")) || "";
|
|
2901
|
-
};
|
|
2902
|
-
var getCss = ({
|
|
2903
|
-
cssCode,
|
|
2904
|
-
contentId
|
|
2905
|
-
}) => {
|
|
2906
|
-
if (!cssCode) {
|
|
2907
|
-
return "";
|
|
2908
|
-
}
|
|
2909
|
-
if (!contentId) {
|
|
2910
|
-
return cssCode;
|
|
2911
|
-
}
|
|
2912
|
-
return (cssCode == null ? void 0 : cssCode.replace(/&/g, `div[builder-content-id="${contentId}"]`)) || "";
|
|
2913
|
-
};
|
|
2914
|
-
|
|
2915
|
-
// src/components/content/components/styles.jsx
|
|
2916
|
-
function ContentStyles(props) {
|
|
2917
|
-
const [injectedStyles, setInjectedStyles] = createSignal(`
|
|
2918
|
-
${getCss({
|
|
2919
|
-
cssCode: props.cssCode,
|
|
2920
|
-
contentId: props.contentId
|
|
2921
|
-
})}
|
|
2922
|
-
${getFontCss({
|
|
2923
|
-
customFonts: props.customFonts
|
|
2924
|
-
})}
|
|
2925
|
-
|
|
2926
|
-
.builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
|
|
2927
|
-
margin: 0;
|
|
2928
|
-
}
|
|
2929
|
-
.builder-text > p, .builder-text > .builder-paragraph {
|
|
2930
|
-
color: inherit;
|
|
2931
|
-
line-height: inherit;
|
|
2932
|
-
letter-spacing: inherit;
|
|
2933
|
-
font-weight: inherit;
|
|
2934
|
-
font-size: inherit;
|
|
2935
|
-
text-align: inherit;
|
|
2936
|
-
font-family: inherit;
|
|
2937
|
-
}
|
|
2938
|
-
`.trim());
|
|
2939
|
-
return createComponent(inlined_styles_default, {
|
|
2940
|
-
get styles() {
|
|
2941
|
-
return injectedStyles();
|
|
2942
|
-
}
|
|
2943
|
-
});
|
|
2906
|
+
// src/helpers/preview-lru-cache/get.ts
|
|
2907
|
+
function getPreviewContent(_searchParams) {
|
|
2908
|
+
return void 0;
|
|
2944
2909
|
}
|
|
2945
|
-
var styles_default = ContentStyles;
|
|
2946
|
-
|
|
2947
|
-
// src/components/content/content.helpers.js
|
|
2948
|
-
var __defProp11 = Object.defineProperty;
|
|
2949
|
-
var __defProps8 = Object.defineProperties;
|
|
2950
|
-
var __getOwnPropDescs8 = Object.getOwnPropertyDescriptors;
|
|
2951
|
-
var __getOwnPropSymbols11 = Object.getOwnPropertySymbols;
|
|
2952
|
-
var __hasOwnProp11 = Object.prototype.hasOwnProperty;
|
|
2953
|
-
var __propIsEnum11 = Object.prototype.propertyIsEnumerable;
|
|
2954
|
-
var __defNormalProp11 = (obj, key, value) => key in obj ? __defProp11(obj, key, {
|
|
2955
|
-
enumerable: true,
|
|
2956
|
-
configurable: true,
|
|
2957
|
-
writable: true,
|
|
2958
|
-
value
|
|
2959
|
-
}) : obj[key] = value;
|
|
2960
|
-
var __spreadValues11 = (a, b) => {
|
|
2961
|
-
for (var prop in b || (b = {}))
|
|
2962
|
-
if (__hasOwnProp11.call(b, prop))
|
|
2963
|
-
__defNormalProp11(a, prop, b[prop]);
|
|
2964
|
-
if (__getOwnPropSymbols11)
|
|
2965
|
-
for (var prop of __getOwnPropSymbols11(b)) {
|
|
2966
|
-
if (__propIsEnum11.call(b, prop))
|
|
2967
|
-
__defNormalProp11(a, prop, b[prop]);
|
|
2968
|
-
}
|
|
2969
|
-
return a;
|
|
2970
|
-
};
|
|
2971
|
-
var __spreadProps8 = (a, b) => __defProps8(a, __getOwnPropDescs8(b));
|
|
2972
|
-
var getContextStateInitialValue = ({
|
|
2973
|
-
content,
|
|
2974
|
-
data,
|
|
2975
|
-
locale
|
|
2976
|
-
}) => {
|
|
2977
|
-
var _a, _b, _c;
|
|
2978
|
-
const defaultValues = {};
|
|
2979
|
-
(_b = (_a = content == null ? void 0 : content.data) == null ? void 0 : _a.inputs) == null ? void 0 : _b.forEach((input) => {
|
|
2980
|
-
var _a2;
|
|
2981
|
-
if (input.name && input.defaultValue !== void 0 && ((_a2 = content == null ? void 0 : content.data) == null ? void 0 : _a2.state) && content.data.state[input.name] === void 0) {
|
|
2982
|
-
defaultValues[input.name] = input.defaultValue;
|
|
2983
|
-
}
|
|
2984
|
-
});
|
|
2985
|
-
const stateToUse = __spreadValues11(__spreadValues11(__spreadValues11({}, (_c = content == null ? void 0 : content.data) == null ? void 0 : _c.state), data), locale ? {
|
|
2986
|
-
locale
|
|
2987
|
-
} : {});
|
|
2988
|
-
return __spreadValues11(__spreadValues11({}, defaultValues), stateToUse);
|
|
2989
|
-
};
|
|
2990
|
-
var getContentInitialValue = ({
|
|
2991
|
-
content,
|
|
2992
|
-
data
|
|
2993
|
-
}) => {
|
|
2994
|
-
return !content ? void 0 : __spreadProps8(__spreadValues11({}, content), {
|
|
2995
|
-
data: __spreadValues11(__spreadValues11({}, content == null ? void 0 : content.data), data),
|
|
2996
|
-
meta: content == null ? void 0 : content.meta
|
|
2997
|
-
});
|
|
2998
|
-
};
|
|
2999
2910
|
|
|
3000
|
-
// src/functions/get-global-this.
|
|
2911
|
+
// src/functions/get-global-this.ts
|
|
3001
2912
|
function getGlobalThis() {
|
|
3002
2913
|
if (typeof globalThis !== "undefined") {
|
|
3003
2914
|
return globalThis;
|
|
@@ -3014,7 +2925,7 @@ function getGlobalThis() {
|
|
|
3014
2925
|
return globalThis;
|
|
3015
2926
|
}
|
|
3016
2927
|
|
|
3017
|
-
// src/functions/get-fetch.
|
|
2928
|
+
// src/functions/get-fetch.ts
|
|
3018
2929
|
function getFetch() {
|
|
3019
2930
|
const globalFetch = getGlobalThis().fetch;
|
|
3020
2931
|
if (typeof globalFetch === "undefined") {
|
|
@@ -3024,746 +2935,26 @@ function getFetch() {
|
|
|
3024
2935
|
}
|
|
3025
2936
|
var fetch2 = getFetch();
|
|
3026
2937
|
|
|
3027
|
-
// src/helpers/
|
|
3028
|
-
var getTopLevelDomain = (host) => {
|
|
3029
|
-
if (host === "localhost" || host === "127.0.0.1") {
|
|
3030
|
-
return host;
|
|
3031
|
-
}
|
|
3032
|
-
const parts = host.split(".");
|
|
3033
|
-
if (parts.length > 2) {
|
|
3034
|
-
return parts.slice(1).join(".");
|
|
3035
|
-
}
|
|
3036
|
-
return host;
|
|
3037
|
-
};
|
|
3038
|
-
|
|
3039
|
-
// src/helpers/cookie.js
|
|
3040
|
-
var __async = (__this, __arguments, generator) => {
|
|
3041
|
-
return new Promise((resolve, reject) => {
|
|
3042
|
-
var fulfilled = (value) => {
|
|
3043
|
-
try {
|
|
3044
|
-
step(generator.next(value));
|
|
3045
|
-
} catch (e) {
|
|
3046
|
-
reject(e);
|
|
3047
|
-
}
|
|
3048
|
-
};
|
|
3049
|
-
var rejected = (value) => {
|
|
3050
|
-
try {
|
|
3051
|
-
step(generator.throw(value));
|
|
3052
|
-
} catch (e) {
|
|
3053
|
-
reject(e);
|
|
3054
|
-
}
|
|
3055
|
-
};
|
|
3056
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
3057
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
3058
|
-
});
|
|
3059
|
-
};
|
|
3060
|
-
var getCookieSync = ({
|
|
3061
|
-
name,
|
|
3062
|
-
canTrack
|
|
3063
|
-
}) => {
|
|
3064
|
-
var _a;
|
|
3065
|
-
try {
|
|
3066
|
-
if (!canTrack) {
|
|
3067
|
-
return void 0;
|
|
3068
|
-
}
|
|
3069
|
-
return (_a = document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))) == null ? void 0 : _a.split("=")[1];
|
|
3070
|
-
} catch (err) {
|
|
3071
|
-
logger.warn("[COOKIE] GET error: ", (err == null ? void 0 : err.message) || err);
|
|
3072
|
-
return void 0;
|
|
3073
|
-
}
|
|
3074
|
-
};
|
|
3075
|
-
var getCookie = (args) => __async(void 0, null, function* () {
|
|
3076
|
-
return getCookieSync(args);
|
|
3077
|
-
});
|
|
3078
|
-
var stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).filter(checkIsDefined).join("; ");
|
|
3079
|
-
var SECURE_CONFIG = [["secure", ""], ["SameSite", "None"]];
|
|
3080
|
-
var createCookieString = ({
|
|
3081
|
-
name,
|
|
3082
|
-
value,
|
|
3083
|
-
expires
|
|
3084
|
-
}) => {
|
|
3085
|
-
const secure = isBrowser() ? location.protocol === "https:" : true;
|
|
3086
|
-
const secureObj = secure ? SECURE_CONFIG : [[]];
|
|
3087
|
-
const expiresObj = expires ? [["expires", expires.toUTCString()]] : [[]];
|
|
3088
|
-
const cookieValue = [[name, value], ...expiresObj, ["path", "/"], ["domain", getTopLevelDomain(window.location.hostname)], ...secureObj];
|
|
3089
|
-
const cookie = stringifyCookie(cookieValue);
|
|
3090
|
-
return cookie;
|
|
3091
|
-
};
|
|
3092
|
-
var setCookie = (_0) => __async(void 0, [_0], function* ({
|
|
3093
|
-
name,
|
|
3094
|
-
value,
|
|
3095
|
-
expires,
|
|
3096
|
-
canTrack
|
|
3097
|
-
}) {
|
|
3098
|
-
try {
|
|
3099
|
-
if (!canTrack) {
|
|
3100
|
-
return;
|
|
3101
|
-
}
|
|
3102
|
-
const cookie = createCookieString({
|
|
3103
|
-
name,
|
|
3104
|
-
value,
|
|
3105
|
-
expires
|
|
3106
|
-
});
|
|
3107
|
-
document.cookie = cookie;
|
|
3108
|
-
} catch (err) {
|
|
3109
|
-
logger.warn("[COOKIE] SET error: ", (err == null ? void 0 : err.message) || err);
|
|
3110
|
-
}
|
|
3111
|
-
});
|
|
3112
|
-
|
|
3113
|
-
// src/helpers/uuid.js
|
|
3114
|
-
function uuidv4() {
|
|
3115
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
3116
|
-
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
|
3117
|
-
return v.toString(16);
|
|
3118
|
-
});
|
|
3119
|
-
}
|
|
3120
|
-
function uuid() {
|
|
3121
|
-
return uuidv4().replace(/-/g, "");
|
|
3122
|
-
}
|
|
3123
|
-
|
|
3124
|
-
// src/helpers/sessionId.js
|
|
3125
|
-
var __async2 = (__this, __arguments, generator) => {
|
|
3126
|
-
return new Promise((resolve, reject) => {
|
|
3127
|
-
var fulfilled = (value) => {
|
|
3128
|
-
try {
|
|
3129
|
-
step(generator.next(value));
|
|
3130
|
-
} catch (e) {
|
|
3131
|
-
reject(e);
|
|
3132
|
-
}
|
|
3133
|
-
};
|
|
3134
|
-
var rejected = (value) => {
|
|
3135
|
-
try {
|
|
3136
|
-
step(generator.throw(value));
|
|
3137
|
-
} catch (e) {
|
|
3138
|
-
reject(e);
|
|
3139
|
-
}
|
|
3140
|
-
};
|
|
3141
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
3142
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
3143
|
-
});
|
|
3144
|
-
};
|
|
3145
|
-
var SESSION_LOCAL_STORAGE_KEY = "builderSessionId";
|
|
3146
|
-
var getSessionId = (_0) => __async2(void 0, [_0], function* ({
|
|
3147
|
-
canTrack
|
|
3148
|
-
}) {
|
|
3149
|
-
if (!canTrack) {
|
|
3150
|
-
return void 0;
|
|
3151
|
-
}
|
|
3152
|
-
const sessionId = yield getCookie({
|
|
3153
|
-
name: SESSION_LOCAL_STORAGE_KEY,
|
|
3154
|
-
canTrack
|
|
3155
|
-
});
|
|
3156
|
-
if (checkIsDefined(sessionId)) {
|
|
3157
|
-
return sessionId;
|
|
3158
|
-
} else {
|
|
3159
|
-
const newSessionId = createSessionId();
|
|
3160
|
-
setSessionId({
|
|
3161
|
-
id: newSessionId,
|
|
3162
|
-
canTrack
|
|
3163
|
-
});
|
|
3164
|
-
return newSessionId;
|
|
3165
|
-
}
|
|
3166
|
-
});
|
|
3167
|
-
var createSessionId = () => uuid();
|
|
3168
|
-
var setSessionId = ({
|
|
3169
|
-
id,
|
|
3170
|
-
canTrack
|
|
3171
|
-
}) => setCookie({
|
|
3172
|
-
name: SESSION_LOCAL_STORAGE_KEY,
|
|
3173
|
-
value: id,
|
|
3174
|
-
canTrack
|
|
3175
|
-
});
|
|
3176
|
-
|
|
3177
|
-
// src/helpers/localStorage.js
|
|
3178
|
-
var getLocalStorage = () => isBrowser() && typeof localStorage !== "undefined" ? localStorage : void 0;
|
|
3179
|
-
var getLocalStorageItem = ({
|
|
3180
|
-
key,
|
|
3181
|
-
canTrack
|
|
3182
|
-
}) => {
|
|
3183
|
-
var _a;
|
|
3184
|
-
try {
|
|
3185
|
-
if (canTrack) {
|
|
3186
|
-
return (_a = getLocalStorage()) == null ? void 0 : _a.getItem(key);
|
|
3187
|
-
}
|
|
3188
|
-
return void 0;
|
|
3189
|
-
} catch (err) {
|
|
3190
|
-
return void 0;
|
|
3191
|
-
}
|
|
3192
|
-
};
|
|
3193
|
-
var setLocalStorageItem = ({
|
|
3194
|
-
key,
|
|
3195
|
-
canTrack,
|
|
3196
|
-
value
|
|
3197
|
-
}) => {
|
|
3198
|
-
var _a;
|
|
3199
|
-
try {
|
|
3200
|
-
if (canTrack) {
|
|
3201
|
-
(_a = getLocalStorage()) == null ? void 0 : _a.setItem(key, value);
|
|
3202
|
-
}
|
|
3203
|
-
} catch (err) {
|
|
3204
|
-
}
|
|
3205
|
-
};
|
|
3206
|
-
|
|
3207
|
-
// src/helpers/visitorId.js
|
|
3208
|
-
var VISITOR_LOCAL_STORAGE_KEY = "builderVisitorId";
|
|
3209
|
-
var getVisitorId = ({
|
|
3210
|
-
canTrack
|
|
3211
|
-
}) => {
|
|
3212
|
-
if (!canTrack) {
|
|
3213
|
-
return void 0;
|
|
3214
|
-
}
|
|
3215
|
-
const visitorId = getLocalStorageItem({
|
|
3216
|
-
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
3217
|
-
canTrack
|
|
3218
|
-
});
|
|
3219
|
-
if (checkIsDefined(visitorId)) {
|
|
3220
|
-
return visitorId;
|
|
3221
|
-
} else {
|
|
3222
|
-
const newVisitorId = createVisitorId();
|
|
3223
|
-
setVisitorId({
|
|
3224
|
-
id: newVisitorId,
|
|
3225
|
-
canTrack
|
|
3226
|
-
});
|
|
3227
|
-
return newVisitorId;
|
|
3228
|
-
}
|
|
3229
|
-
};
|
|
3230
|
-
var createVisitorId = () => uuid();
|
|
3231
|
-
var setVisitorId = ({
|
|
3232
|
-
id,
|
|
3233
|
-
canTrack
|
|
3234
|
-
}) => setLocalStorageItem({
|
|
3235
|
-
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
3236
|
-
value: id,
|
|
3237
|
-
canTrack
|
|
3238
|
-
});
|
|
3239
|
-
|
|
3240
|
-
// src/functions/track/index.js
|
|
3241
|
-
var __defProp12 = Object.defineProperty;
|
|
3242
|
-
var __defProps9 = Object.defineProperties;
|
|
3243
|
-
var __getOwnPropDescs9 = Object.getOwnPropertyDescriptors;
|
|
3244
|
-
var __getOwnPropSymbols12 = Object.getOwnPropertySymbols;
|
|
3245
|
-
var __hasOwnProp12 = Object.prototype.hasOwnProperty;
|
|
3246
|
-
var __propIsEnum12 = Object.prototype.propertyIsEnumerable;
|
|
3247
|
-
var __defNormalProp12 = (obj, key, value) => key in obj ? __defProp12(obj, key, {
|
|
3248
|
-
enumerable: true,
|
|
3249
|
-
configurable: true,
|
|
3250
|
-
writable: true,
|
|
3251
|
-
value
|
|
3252
|
-
}) : obj[key] = value;
|
|
3253
|
-
var __spreadValues12 = (a, b) => {
|
|
3254
|
-
for (var prop in b || (b = {}))
|
|
3255
|
-
if (__hasOwnProp12.call(b, prop))
|
|
3256
|
-
__defNormalProp12(a, prop, b[prop]);
|
|
3257
|
-
if (__getOwnPropSymbols12)
|
|
3258
|
-
for (var prop of __getOwnPropSymbols12(b)) {
|
|
3259
|
-
if (__propIsEnum12.call(b, prop))
|
|
3260
|
-
__defNormalProp12(a, prop, b[prop]);
|
|
3261
|
-
}
|
|
3262
|
-
return a;
|
|
3263
|
-
};
|
|
3264
|
-
var __spreadProps9 = (a, b) => __defProps9(a, __getOwnPropDescs9(b));
|
|
3265
|
-
var __objRest3 = (source, exclude) => {
|
|
3266
|
-
var target = {};
|
|
3267
|
-
for (var prop in source)
|
|
3268
|
-
if (__hasOwnProp12.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
3269
|
-
target[prop] = source[prop];
|
|
3270
|
-
if (source != null && __getOwnPropSymbols12)
|
|
3271
|
-
for (var prop of __getOwnPropSymbols12(source)) {
|
|
3272
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum12.call(source, prop))
|
|
3273
|
-
target[prop] = source[prop];
|
|
3274
|
-
}
|
|
3275
|
-
return target;
|
|
3276
|
-
};
|
|
3277
|
-
var __async3 = (__this, __arguments, generator) => {
|
|
3278
|
-
return new Promise((resolve, reject) => {
|
|
3279
|
-
var fulfilled = (value) => {
|
|
3280
|
-
try {
|
|
3281
|
-
step(generator.next(value));
|
|
3282
|
-
} catch (e) {
|
|
3283
|
-
reject(e);
|
|
3284
|
-
}
|
|
3285
|
-
};
|
|
3286
|
-
var rejected = (value) => {
|
|
3287
|
-
try {
|
|
3288
|
-
step(generator.throw(value));
|
|
3289
|
-
} catch (e) {
|
|
3290
|
-
reject(e);
|
|
3291
|
-
}
|
|
3292
|
-
};
|
|
3293
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
3294
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
3295
|
-
});
|
|
3296
|
-
};
|
|
3297
|
-
var getTrackingEventData = (_0) => __async3(void 0, [_0], function* ({
|
|
3298
|
-
canTrack
|
|
3299
|
-
}) {
|
|
3300
|
-
if (!canTrack) {
|
|
3301
|
-
return {
|
|
3302
|
-
visitorId: void 0,
|
|
3303
|
-
sessionId: void 0
|
|
3304
|
-
};
|
|
3305
|
-
}
|
|
3306
|
-
const sessionId = yield getSessionId({
|
|
3307
|
-
canTrack
|
|
3308
|
-
});
|
|
3309
|
-
const visitorId = getVisitorId({
|
|
3310
|
-
canTrack
|
|
3311
|
-
});
|
|
3312
|
-
return {
|
|
3313
|
-
sessionId,
|
|
3314
|
-
visitorId
|
|
3315
|
-
};
|
|
3316
|
-
});
|
|
3317
|
-
var createEvent = (_a) => __async3(void 0, null, function* () {
|
|
3318
|
-
var _b = _a, {
|
|
3319
|
-
type: eventType,
|
|
3320
|
-
canTrack,
|
|
3321
|
-
apiKey,
|
|
3322
|
-
metadata
|
|
3323
|
-
} = _b, properties = __objRest3(_b, ["type", "canTrack", "apiKey", "metadata"]);
|
|
3324
|
-
return {
|
|
3325
|
-
type: eventType,
|
|
3326
|
-
data: __spreadProps9(__spreadValues12(__spreadProps9(__spreadValues12({}, properties), {
|
|
3327
|
-
metadata: __spreadValues12({
|
|
3328
|
-
url: location.href
|
|
3329
|
-
}, metadata)
|
|
3330
|
-
}), yield getTrackingEventData({
|
|
3331
|
-
canTrack
|
|
3332
|
-
})), {
|
|
3333
|
-
userAttributes: getUserAttributes(),
|
|
3334
|
-
ownerId: apiKey
|
|
3335
|
-
})
|
|
3336
|
-
};
|
|
3337
|
-
});
|
|
3338
|
-
function _track(eventProps) {
|
|
3339
|
-
return __async3(this, null, function* () {
|
|
3340
|
-
if (!eventProps.apiKey) {
|
|
3341
|
-
logger.error("Missing API key for track call. Please provide your API key.");
|
|
3342
|
-
return;
|
|
3343
|
-
}
|
|
3344
|
-
if (!eventProps.canTrack) {
|
|
3345
|
-
return;
|
|
3346
|
-
}
|
|
3347
|
-
if (isEditing()) {
|
|
3348
|
-
return;
|
|
3349
|
-
}
|
|
3350
|
-
if (!(isBrowser() || TARGET === "reactNative")) {
|
|
3351
|
-
return;
|
|
3352
|
-
}
|
|
3353
|
-
return fetch(`https://cdn.builder.io/api/v1/track`, {
|
|
3354
|
-
method: "POST",
|
|
3355
|
-
body: JSON.stringify({
|
|
3356
|
-
events: [yield createEvent(eventProps)]
|
|
3357
|
-
}),
|
|
3358
|
-
headers: {
|
|
3359
|
-
"content-type": "application/json"
|
|
3360
|
-
},
|
|
3361
|
-
mode: "cors"
|
|
3362
|
-
}).catch((err) => {
|
|
3363
|
-
});
|
|
3364
|
-
});
|
|
3365
|
-
}
|
|
3366
|
-
var track = (args) => _track(__spreadProps9(__spreadValues12({}, args), {
|
|
3367
|
-
canTrack: true
|
|
3368
|
-
}));
|
|
3369
|
-
|
|
3370
|
-
// src/constants/sdk-version.js
|
|
3371
|
-
var SDK_VERSION = "0.7.1-1";
|
|
3372
|
-
|
|
3373
|
-
// src/functions/register.js
|
|
3374
|
-
var registry = {};
|
|
3375
|
-
function register(type, info) {
|
|
3376
|
-
let typeList = registry[type];
|
|
3377
|
-
if (!typeList) {
|
|
3378
|
-
typeList = registry[type] = [];
|
|
3379
|
-
}
|
|
3380
|
-
typeList.push(info);
|
|
3381
|
-
if (isBrowser()) {
|
|
3382
|
-
const message = {
|
|
3383
|
-
type: "builder.register",
|
|
3384
|
-
data: {
|
|
3385
|
-
type,
|
|
3386
|
-
info
|
|
3387
|
-
}
|
|
3388
|
-
};
|
|
3389
|
-
try {
|
|
3390
|
-
parent.postMessage(message, "*");
|
|
3391
|
-
if (parent !== window) {
|
|
3392
|
-
window.postMessage(message, "*");
|
|
3393
|
-
}
|
|
3394
|
-
} catch (err) {
|
|
3395
|
-
}
|
|
3396
|
-
}
|
|
3397
|
-
}
|
|
3398
|
-
|
|
3399
|
-
// src/scripts/init-editing.js
|
|
3400
|
-
var registerInsertMenu = () => {
|
|
3401
|
-
register("insertMenu", {
|
|
3402
|
-
name: "_default",
|
|
3403
|
-
default: true,
|
|
3404
|
-
items: [{
|
|
3405
|
-
name: "Box"
|
|
3406
|
-
}, {
|
|
3407
|
-
name: "Text"
|
|
3408
|
-
}, {
|
|
3409
|
-
name: "Image"
|
|
3410
|
-
}, {
|
|
3411
|
-
name: "Columns"
|
|
3412
|
-
}, ...TARGET === "reactNative" ? [] : [{
|
|
3413
|
-
name: "Core:Section"
|
|
3414
|
-
}, {
|
|
3415
|
-
name: "Core:Button"
|
|
3416
|
-
}, {
|
|
3417
|
-
name: "Embed"
|
|
3418
|
-
}, {
|
|
3419
|
-
name: "Custom Code"
|
|
3420
|
-
}]]
|
|
3421
|
-
});
|
|
3422
|
-
};
|
|
3423
|
-
var isSetupForEditing = false;
|
|
3424
|
-
var setupBrowserForEditing = (options = {}) => {
|
|
3425
|
-
var _a, _b;
|
|
3426
|
-
if (isSetupForEditing) {
|
|
3427
|
-
return;
|
|
3428
|
-
}
|
|
3429
|
-
isSetupForEditing = true;
|
|
3430
|
-
if (isBrowser()) {
|
|
3431
|
-
(_a = window.parent) == null ? void 0 : _a.postMessage({
|
|
3432
|
-
type: "builder.sdkInfo",
|
|
3433
|
-
data: {
|
|
3434
|
-
target: TARGET,
|
|
3435
|
-
version: SDK_VERSION,
|
|
3436
|
-
supportsPatchUpdates: false,
|
|
3437
|
-
supportsAddBlockScoping: true,
|
|
3438
|
-
supportsCustomBreakpoints: true
|
|
3439
|
-
}
|
|
3440
|
-
}, "*");
|
|
3441
|
-
(_b = window.parent) == null ? void 0 : _b.postMessage({
|
|
3442
|
-
type: "builder.updateContent",
|
|
3443
|
-
data: {
|
|
3444
|
-
options
|
|
3445
|
-
}
|
|
3446
|
-
}, "*");
|
|
3447
|
-
window.addEventListener("message", ({
|
|
3448
|
-
data
|
|
3449
|
-
}) => {
|
|
3450
|
-
var _a2, _b2;
|
|
3451
|
-
if (!(data == null ? void 0 : data.type)) {
|
|
3452
|
-
return;
|
|
3453
|
-
}
|
|
3454
|
-
switch (data.type) {
|
|
3455
|
-
case "builder.evaluate": {
|
|
3456
|
-
const text = data.data.text;
|
|
3457
|
-
const args = data.data.arguments || [];
|
|
3458
|
-
const id = data.data.id;
|
|
3459
|
-
const fn = new Function(text);
|
|
3460
|
-
let result;
|
|
3461
|
-
let error = null;
|
|
3462
|
-
try {
|
|
3463
|
-
result = fn.apply(null, args);
|
|
3464
|
-
} catch (err) {
|
|
3465
|
-
error = err;
|
|
3466
|
-
}
|
|
3467
|
-
if (error) {
|
|
3468
|
-
(_a2 = window.parent) == null ? void 0 : _a2.postMessage({
|
|
3469
|
-
type: "builder.evaluateError",
|
|
3470
|
-
data: {
|
|
3471
|
-
id,
|
|
3472
|
-
error: error.message
|
|
3473
|
-
}
|
|
3474
|
-
}, "*");
|
|
3475
|
-
} else {
|
|
3476
|
-
if (result && typeof result.then === "function") {
|
|
3477
|
-
result.then((finalResult) => {
|
|
3478
|
-
var _a3;
|
|
3479
|
-
(_a3 = window.parent) == null ? void 0 : _a3.postMessage({
|
|
3480
|
-
type: "builder.evaluateResult",
|
|
3481
|
-
data: {
|
|
3482
|
-
id,
|
|
3483
|
-
result: finalResult
|
|
3484
|
-
}
|
|
3485
|
-
}, "*");
|
|
3486
|
-
}).catch(console.error);
|
|
3487
|
-
} else {
|
|
3488
|
-
(_b2 = window.parent) == null ? void 0 : _b2.postMessage({
|
|
3489
|
-
type: "builder.evaluateResult",
|
|
3490
|
-
data: {
|
|
3491
|
-
result,
|
|
3492
|
-
id
|
|
3493
|
-
}
|
|
3494
|
-
}, "*");
|
|
3495
|
-
}
|
|
3496
|
-
}
|
|
3497
|
-
break;
|
|
3498
|
-
}
|
|
3499
|
-
}
|
|
3500
|
-
});
|
|
3501
|
-
}
|
|
3502
|
-
};
|
|
3503
|
-
|
|
3504
|
-
// src/functions/track/interaction.js
|
|
3505
|
-
function round(num) {
|
|
3506
|
-
return Math.round(num * 1e3) / 1e3;
|
|
3507
|
-
}
|
|
3508
|
-
var findParentElement = (target, callback, checkElement = true) => {
|
|
3509
|
-
if (!(target instanceof HTMLElement)) {
|
|
3510
|
-
return null;
|
|
3511
|
-
}
|
|
3512
|
-
let parent2 = checkElement ? target : target.parentElement;
|
|
3513
|
-
do {
|
|
3514
|
-
if (!parent2) {
|
|
3515
|
-
return null;
|
|
3516
|
-
}
|
|
3517
|
-
const matches = callback(parent2);
|
|
3518
|
-
if (matches) {
|
|
3519
|
-
return parent2;
|
|
3520
|
-
}
|
|
3521
|
-
} while (parent2 = parent2.parentElement);
|
|
3522
|
-
return null;
|
|
3523
|
-
};
|
|
3524
|
-
var findBuilderParent = (target) => findParentElement(target, (el) => {
|
|
3525
|
-
const id = el.getAttribute("builder-id") || el.id;
|
|
3526
|
-
return Boolean((id == null ? void 0 : id.indexOf("builder-")) === 0);
|
|
3527
|
-
});
|
|
3528
|
-
var computeOffset = ({
|
|
3529
|
-
event,
|
|
3530
|
-
target
|
|
3531
|
-
}) => {
|
|
3532
|
-
const targetRect = target.getBoundingClientRect();
|
|
3533
|
-
const xOffset = event.clientX - targetRect.left;
|
|
3534
|
-
const yOffset = event.clientY - targetRect.top;
|
|
3535
|
-
const xRatio = round(xOffset / targetRect.width);
|
|
3536
|
-
const yRatio = round(yOffset / targetRect.height);
|
|
3537
|
-
return {
|
|
3538
|
-
x: xRatio,
|
|
3539
|
-
y: yRatio
|
|
3540
|
-
};
|
|
3541
|
-
};
|
|
3542
|
-
var getInteractionPropertiesForEvent = (event) => {
|
|
3543
|
-
const target = event.target;
|
|
3544
|
-
const targetBuilderElement = target && findBuilderParent(target);
|
|
3545
|
-
const builderId = (targetBuilderElement == null ? void 0 : targetBuilderElement.getAttribute("builder-id")) || (targetBuilderElement == null ? void 0 : targetBuilderElement.id);
|
|
3546
|
-
return {
|
|
3547
|
-
targetBuilderElement: builderId || void 0,
|
|
3548
|
-
metadata: {
|
|
3549
|
-
targetOffset: target ? computeOffset({
|
|
3550
|
-
event,
|
|
3551
|
-
target
|
|
3552
|
-
}) : void 0,
|
|
3553
|
-
builderTargetOffset: targetBuilderElement ? computeOffset({
|
|
3554
|
-
event,
|
|
3555
|
-
target: targetBuilderElement
|
|
3556
|
-
}) : void 0,
|
|
3557
|
-
builderElementIndex: targetBuilderElement && builderId ? [].slice.call(document.getElementsByClassName(builderId)).indexOf(targetBuilderElement) : void 0
|
|
3558
|
-
}
|
|
3559
|
-
};
|
|
3560
|
-
};
|
|
3561
|
-
|
|
3562
|
-
// src/helpers/ab-tests.js
|
|
3563
|
-
var __defProp13 = Object.defineProperty;
|
|
3564
|
-
var __getOwnPropSymbols13 = Object.getOwnPropertySymbols;
|
|
3565
|
-
var __hasOwnProp13 = Object.prototype.hasOwnProperty;
|
|
3566
|
-
var __propIsEnum13 = Object.prototype.propertyIsEnumerable;
|
|
3567
|
-
var __defNormalProp13 = (obj, key, value) => key in obj ? __defProp13(obj, key, {
|
|
3568
|
-
enumerable: true,
|
|
3569
|
-
configurable: true,
|
|
3570
|
-
writable: true,
|
|
3571
|
-
value
|
|
3572
|
-
}) : obj[key] = value;
|
|
3573
|
-
var __spreadValues13 = (a, b) => {
|
|
3574
|
-
for (var prop in b || (b = {}))
|
|
3575
|
-
if (__hasOwnProp13.call(b, prop))
|
|
3576
|
-
__defNormalProp13(a, prop, b[prop]);
|
|
3577
|
-
if (__getOwnPropSymbols13)
|
|
3578
|
-
for (var prop of __getOwnPropSymbols13(b)) {
|
|
3579
|
-
if (__propIsEnum13.call(b, prop))
|
|
3580
|
-
__defNormalProp13(a, prop, b[prop]);
|
|
3581
|
-
}
|
|
3582
|
-
return a;
|
|
3583
|
-
};
|
|
3584
|
-
var __async4 = (__this, __arguments, generator) => {
|
|
3585
|
-
return new Promise((resolve, reject) => {
|
|
3586
|
-
var fulfilled = (value) => {
|
|
3587
|
-
try {
|
|
3588
|
-
step(generator.next(value));
|
|
3589
|
-
} catch (e) {
|
|
3590
|
-
reject(e);
|
|
3591
|
-
}
|
|
3592
|
-
};
|
|
3593
|
-
var rejected = (value) => {
|
|
3594
|
-
try {
|
|
3595
|
-
step(generator.throw(value));
|
|
3596
|
-
} catch (e) {
|
|
3597
|
-
reject(e);
|
|
3598
|
-
}
|
|
3599
|
-
};
|
|
3600
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
3601
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
3602
|
-
});
|
|
3603
|
-
};
|
|
3604
|
-
var BUILDER_STORE_PREFIX = "builder.tests";
|
|
3605
|
-
var getContentTestKey = (id) => `${BUILDER_STORE_PREFIX}.${id}`;
|
|
3606
|
-
var getContentVariationCookie = ({
|
|
3607
|
-
contentId
|
|
3608
|
-
}) => getCookie({
|
|
3609
|
-
name: getContentTestKey(contentId),
|
|
3610
|
-
canTrack: true
|
|
3611
|
-
});
|
|
3612
|
-
var getContentVariationCookieSync = ({
|
|
3613
|
-
contentId
|
|
3614
|
-
}) => getCookieSync({
|
|
3615
|
-
name: getContentTestKey(contentId),
|
|
3616
|
-
canTrack: true
|
|
3617
|
-
});
|
|
3618
|
-
var setContentVariationCookie = ({
|
|
3619
|
-
contentId,
|
|
3620
|
-
value
|
|
3621
|
-
}) => setCookie({
|
|
3622
|
-
name: getContentTestKey(contentId),
|
|
3623
|
-
value,
|
|
3624
|
-
canTrack: true
|
|
3625
|
-
});
|
|
3626
|
-
var checkIsBuilderContentWithVariations = (item) => checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
|
|
3627
|
-
var getRandomVariationId = ({
|
|
3628
|
-
id,
|
|
3629
|
-
variations
|
|
3630
|
-
}) => {
|
|
3631
|
-
var _a;
|
|
3632
|
-
let n = 0;
|
|
3633
|
-
const random = Math.random();
|
|
3634
|
-
for (const id2 in variations) {
|
|
3635
|
-
const testRatio = (_a = variations[id2]) == null ? void 0 : _a.testRatio;
|
|
3636
|
-
n += testRatio;
|
|
3637
|
-
if (random < n) {
|
|
3638
|
-
return id2;
|
|
3639
|
-
}
|
|
3640
|
-
}
|
|
3641
|
-
return id;
|
|
3642
|
-
};
|
|
3643
|
-
var getAndSetVariantId = (args) => {
|
|
3644
|
-
const randomVariationId = getRandomVariationId(args);
|
|
3645
|
-
setContentVariationCookie({
|
|
3646
|
-
contentId: args.id,
|
|
3647
|
-
value: randomVariationId
|
|
3648
|
-
}).catch((err) => {
|
|
3649
|
-
logger.error("could not store A/B test variation: ", err);
|
|
3650
|
-
});
|
|
3651
|
-
return randomVariationId;
|
|
3652
|
-
};
|
|
3653
|
-
var getTestFields = ({
|
|
3654
|
-
item,
|
|
3655
|
-
testGroupId
|
|
3656
|
-
}) => {
|
|
3657
|
-
const variationValue = item.variations[testGroupId];
|
|
3658
|
-
if (testGroupId === item.id || !variationValue) {
|
|
3659
|
-
return {
|
|
3660
|
-
testVariationId: item.id,
|
|
3661
|
-
testVariationName: "Default"
|
|
3662
|
-
};
|
|
3663
|
-
} else {
|
|
3664
|
-
return {
|
|
3665
|
-
data: variationValue.data,
|
|
3666
|
-
testVariationId: variationValue.id,
|
|
3667
|
-
testVariationName: variationValue.name || (variationValue.id === item.id ? "Default" : "")
|
|
3668
|
-
};
|
|
3669
|
-
}
|
|
3670
|
-
};
|
|
3671
|
-
var handleABTestingSync = ({
|
|
3672
|
-
item,
|
|
3673
|
-
canTrack
|
|
3674
|
-
}) => {
|
|
3675
|
-
if (TARGET === "reactNative")
|
|
3676
|
-
return item;
|
|
3677
|
-
if (!canTrack) {
|
|
3678
|
-
return item;
|
|
3679
|
-
}
|
|
3680
|
-
if (!item) {
|
|
3681
|
-
return void 0;
|
|
3682
|
-
}
|
|
3683
|
-
if (!checkIsBuilderContentWithVariations(item)) {
|
|
3684
|
-
return item;
|
|
3685
|
-
}
|
|
3686
|
-
const testGroupId = getContentVariationCookieSync({
|
|
3687
|
-
contentId: item.id
|
|
3688
|
-
}) || getAndSetVariantId({
|
|
3689
|
-
variations: item.variations,
|
|
3690
|
-
id: item.id
|
|
3691
|
-
});
|
|
3692
|
-
const variationValue = getTestFields({
|
|
3693
|
-
item,
|
|
3694
|
-
testGroupId
|
|
3695
|
-
});
|
|
3696
|
-
return __spreadValues13(__spreadValues13({}, item), variationValue);
|
|
3697
|
-
};
|
|
3698
|
-
var handleABTesting = (_0) => __async4(void 0, [_0], function* ({
|
|
3699
|
-
item,
|
|
3700
|
-
canTrack
|
|
3701
|
-
}) {
|
|
3702
|
-
if (!canTrack) {
|
|
3703
|
-
return item;
|
|
3704
|
-
}
|
|
3705
|
-
if (!checkIsBuilderContentWithVariations(item)) {
|
|
3706
|
-
return item;
|
|
3707
|
-
}
|
|
3708
|
-
const cookieValue = yield getContentVariationCookie({
|
|
3709
|
-
contentId: item.id
|
|
3710
|
-
});
|
|
3711
|
-
const testGroupId = cookieValue || getAndSetVariantId({
|
|
3712
|
-
variations: item.variations,
|
|
3713
|
-
id: item.id
|
|
3714
|
-
});
|
|
3715
|
-
const variationValue = getTestFields({
|
|
3716
|
-
item,
|
|
3717
|
-
testGroupId
|
|
3718
|
-
});
|
|
3719
|
-
return __spreadValues13(__spreadValues13({}, item), variationValue);
|
|
3720
|
-
});
|
|
3721
|
-
|
|
3722
|
-
// src/helpers/canTrack.js
|
|
3723
|
-
var getDefaultCanTrack = (canTrack) => checkIsDefined(canTrack) ? canTrack : true;
|
|
3724
|
-
|
|
3725
|
-
// src/helpers/preview-lru-cache/get.js
|
|
3726
|
-
function getPreviewContent(_searchParams) {
|
|
3727
|
-
return void 0;
|
|
3728
|
-
}
|
|
3729
|
-
|
|
3730
|
-
// src/helpers/flatten.js
|
|
3731
|
-
var __defProp14 = Object.defineProperty;
|
|
3732
|
-
var __defProps10 = Object.defineProperties;
|
|
3733
|
-
var __getOwnPropDescs10 = Object.getOwnPropertyDescriptors;
|
|
3734
|
-
var __getOwnPropSymbols14 = Object.getOwnPropertySymbols;
|
|
3735
|
-
var __hasOwnProp14 = Object.prototype.hasOwnProperty;
|
|
3736
|
-
var __propIsEnum14 = Object.prototype.propertyIsEnumerable;
|
|
3737
|
-
var __defNormalProp14 = (obj, key, value) => key in obj ? __defProp14(obj, key, {
|
|
3738
|
-
enumerable: true,
|
|
3739
|
-
configurable: true,
|
|
3740
|
-
writable: true,
|
|
3741
|
-
value
|
|
3742
|
-
}) : obj[key] = value;
|
|
3743
|
-
var __spreadValues14 = (a, b) => {
|
|
3744
|
-
for (var prop in b || (b = {}))
|
|
3745
|
-
if (__hasOwnProp14.call(b, prop))
|
|
3746
|
-
__defNormalProp14(a, prop, b[prop]);
|
|
3747
|
-
if (__getOwnPropSymbols14)
|
|
3748
|
-
for (var prop of __getOwnPropSymbols14(b)) {
|
|
3749
|
-
if (__propIsEnum14.call(b, prop))
|
|
3750
|
-
__defNormalProp14(a, prop, b[prop]);
|
|
3751
|
-
}
|
|
3752
|
-
return a;
|
|
3753
|
-
};
|
|
3754
|
-
var __spreadProps10 = (a, b) => __defProps10(a, __getOwnPropDescs10(b));
|
|
2938
|
+
// src/helpers/flatten.ts
|
|
3755
2939
|
function flatten(object, path = null, separator = ".") {
|
|
3756
2940
|
return Object.keys(object).reduce((acc, key) => {
|
|
3757
2941
|
const value = object[key];
|
|
3758
2942
|
const newPath = [path, key].filter(Boolean).join(separator);
|
|
3759
2943
|
const isObject = [typeof value === "object", value !== null, !(Array.isArray(value) && value.length === 0)].every(Boolean);
|
|
3760
|
-
return isObject ?
|
|
2944
|
+
return isObject ? {
|
|
2945
|
+
...acc,
|
|
2946
|
+
...flatten(value, newPath, separator)
|
|
2947
|
+
} : {
|
|
2948
|
+
...acc,
|
|
3761
2949
|
[newPath]: value
|
|
3762
|
-
}
|
|
2950
|
+
};
|
|
3763
2951
|
}, {});
|
|
3764
2952
|
}
|
|
3765
2953
|
|
|
3766
|
-
// src/
|
|
2954
|
+
// src/types/api-version.ts
|
|
2955
|
+
var DEFAULT_API_VERSION = "v3";
|
|
2956
|
+
|
|
2957
|
+
// src/functions/get-builder-search-params/index.ts
|
|
3767
2958
|
var BUILDER_SEARCHPARAMS_PREFIX = "builder.";
|
|
3768
2959
|
var BUILDER_OPTIONS_PREFIX = "options.";
|
|
3769
2960
|
var convertSearchParamsToQueryObject = (searchParams) => {
|
|
@@ -3796,31 +2987,7 @@ var getBuilderSearchParamsFromWindow = () => {
|
|
|
3796
2987
|
};
|
|
3797
2988
|
var normalizeSearchParams = (searchParams) => searchParams instanceof URLSearchParams ? convertSearchParamsToQueryObject(searchParams) : searchParams;
|
|
3798
2989
|
|
|
3799
|
-
// src/
|
|
3800
|
-
var DEFAULT_API_VERSION = "v3";
|
|
3801
|
-
|
|
3802
|
-
// src/functions/get-content/generate-content-url.js
|
|
3803
|
-
var __defProp15 = Object.defineProperty;
|
|
3804
|
-
var __getOwnPropSymbols15 = Object.getOwnPropertySymbols;
|
|
3805
|
-
var __hasOwnProp15 = Object.prototype.hasOwnProperty;
|
|
3806
|
-
var __propIsEnum15 = Object.prototype.propertyIsEnumerable;
|
|
3807
|
-
var __defNormalProp15 = (obj, key, value) => key in obj ? __defProp15(obj, key, {
|
|
3808
|
-
enumerable: true,
|
|
3809
|
-
configurable: true,
|
|
3810
|
-
writable: true,
|
|
3811
|
-
value
|
|
3812
|
-
}) : obj[key] = value;
|
|
3813
|
-
var __spreadValues15 = (a, b) => {
|
|
3814
|
-
for (var prop in b || (b = {}))
|
|
3815
|
-
if (__hasOwnProp15.call(b, prop))
|
|
3816
|
-
__defNormalProp15(a, prop, b[prop]);
|
|
3817
|
-
if (__getOwnPropSymbols15)
|
|
3818
|
-
for (var prop of __getOwnPropSymbols15(b)) {
|
|
3819
|
-
if (__propIsEnum15.call(b, prop))
|
|
3820
|
-
__defNormalProp15(a, prop, b[prop]);
|
|
3821
|
-
}
|
|
3822
|
-
return a;
|
|
3823
|
-
};
|
|
2990
|
+
// src/functions/get-content/generate-content-url.ts
|
|
3824
2991
|
var isPositiveNumber = (thing) => typeof thing === "number" && !isNaN(thing) && thing >= 0;
|
|
3825
2992
|
var generateContentUrl = (options) => {
|
|
3826
2993
|
let {
|
|
@@ -3878,7 +3045,10 @@ var generateContentUrl = (options) => {
|
|
|
3878
3045
|
url.searchParams.set(key, JSON.stringify(flattened2[key]));
|
|
3879
3046
|
}
|
|
3880
3047
|
}
|
|
3881
|
-
const queryOptions =
|
|
3048
|
+
const queryOptions = {
|
|
3049
|
+
...getBuilderSearchParamsFromWindow(),
|
|
3050
|
+
...normalizeSearchParams(options.options || {})
|
|
3051
|
+
};
|
|
3882
3052
|
const flattened = flatten(queryOptions);
|
|
3883
3053
|
for (const key in flattened) {
|
|
3884
3054
|
url.searchParams.set(key, String(flattened[key]));
|
|
@@ -3897,71 +3067,26 @@ var generateContentUrl = (options) => {
|
|
|
3897
3067
|
return url;
|
|
3898
3068
|
};
|
|
3899
3069
|
|
|
3900
|
-
// src/functions/get-content/index.
|
|
3901
|
-
var __defProp16 = Object.defineProperty;
|
|
3902
|
-
var __defProps11 = Object.defineProperties;
|
|
3903
|
-
var __getOwnPropDescs11 = Object.getOwnPropertyDescriptors;
|
|
3904
|
-
var __getOwnPropSymbols16 = Object.getOwnPropertySymbols;
|
|
3905
|
-
var __hasOwnProp16 = Object.prototype.hasOwnProperty;
|
|
3906
|
-
var __propIsEnum16 = Object.prototype.propertyIsEnumerable;
|
|
3907
|
-
var __defNormalProp16 = (obj, key, value) => key in obj ? __defProp16(obj, key, {
|
|
3908
|
-
enumerable: true,
|
|
3909
|
-
configurable: true,
|
|
3910
|
-
writable: true,
|
|
3911
|
-
value
|
|
3912
|
-
}) : obj[key] = value;
|
|
3913
|
-
var __spreadValues16 = (a, b) => {
|
|
3914
|
-
for (var prop in b || (b = {}))
|
|
3915
|
-
if (__hasOwnProp16.call(b, prop))
|
|
3916
|
-
__defNormalProp16(a, prop, b[prop]);
|
|
3917
|
-
if (__getOwnPropSymbols16)
|
|
3918
|
-
for (var prop of __getOwnPropSymbols16(b)) {
|
|
3919
|
-
if (__propIsEnum16.call(b, prop))
|
|
3920
|
-
__defNormalProp16(a, prop, b[prop]);
|
|
3921
|
-
}
|
|
3922
|
-
return a;
|
|
3923
|
-
};
|
|
3924
|
-
var __spreadProps11 = (a, b) => __defProps11(a, __getOwnPropDescs11(b));
|
|
3925
|
-
var __async5 = (__this, __arguments, generator) => {
|
|
3926
|
-
return new Promise((resolve, reject) => {
|
|
3927
|
-
var fulfilled = (value) => {
|
|
3928
|
-
try {
|
|
3929
|
-
step(generator.next(value));
|
|
3930
|
-
} catch (e) {
|
|
3931
|
-
reject(e);
|
|
3932
|
-
}
|
|
3933
|
-
};
|
|
3934
|
-
var rejected = (value) => {
|
|
3935
|
-
try {
|
|
3936
|
-
step(generator.throw(value));
|
|
3937
|
-
} catch (e) {
|
|
3938
|
-
reject(e);
|
|
3939
|
-
}
|
|
3940
|
-
};
|
|
3941
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
3942
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
3943
|
-
});
|
|
3944
|
-
};
|
|
3070
|
+
// src/functions/get-content/index.ts
|
|
3945
3071
|
var checkContentHasResults = (content) => "results" in content;
|
|
3946
|
-
function fetchOneEntry(options) {
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
}));
|
|
3951
|
-
if (allContent) {
|
|
3952
|
-
return allContent.results[0] || null;
|
|
3953
|
-
}
|
|
3954
|
-
return null;
|
|
3072
|
+
async function fetchOneEntry(options) {
|
|
3073
|
+
const allContent = await fetchEntries({
|
|
3074
|
+
...options,
|
|
3075
|
+
limit: 1
|
|
3955
3076
|
});
|
|
3077
|
+
if (allContent) {
|
|
3078
|
+
return allContent.results[0] || null;
|
|
3079
|
+
}
|
|
3080
|
+
return null;
|
|
3956
3081
|
}
|
|
3957
3082
|
var getContent = fetchOneEntry;
|
|
3958
|
-
var _fetchContent = (options) =>
|
|
3083
|
+
var _fetchContent = async (options) => {
|
|
3959
3084
|
const url = generateContentUrl(options);
|
|
3960
|
-
const res =
|
|
3961
|
-
const content =
|
|
3085
|
+
const res = await fetch2(url.href);
|
|
3086
|
+
const content = await res.json();
|
|
3962
3087
|
return content;
|
|
3963
|
-
}
|
|
3964
|
-
var _processContentResult =
|
|
3088
|
+
};
|
|
3089
|
+
var _processContentResult = async (options, content, url = generateContentUrl(options)) => {
|
|
3965
3090
|
const canTrack = getDefaultCanTrack(options.canTrack);
|
|
3966
3091
|
const isPreviewing2 = url.search.includes(`preview=`);
|
|
3967
3092
|
if (TARGET === "rsc" && isPreviewing2) {
|
|
@@ -3979,7 +3104,7 @@ var _processContentResult = (_0, _1, ..._2) => __async5(void 0, [_0, _1, ..._2],
|
|
|
3979
3104
|
try {
|
|
3980
3105
|
const newResults = [];
|
|
3981
3106
|
for (const item of content.results) {
|
|
3982
|
-
newResults.push(
|
|
3107
|
+
newResults.push(await handleABTesting({
|
|
3983
3108
|
item,
|
|
3984
3109
|
canTrack
|
|
3985
3110
|
}));
|
|
@@ -3989,42 +3114,409 @@ var _processContentResult = (_0, _1, ..._2) => __async5(void 0, [_0, _1, ..._2],
|
|
|
3989
3114
|
logger.error("Could not process A/B tests. ", e);
|
|
3990
3115
|
}
|
|
3991
3116
|
return content;
|
|
3117
|
+
};
|
|
3118
|
+
async function fetchEntries(options) {
|
|
3119
|
+
try {
|
|
3120
|
+
const url = generateContentUrl(options);
|
|
3121
|
+
const content = await _fetchContent(options);
|
|
3122
|
+
if (!checkContentHasResults(content)) {
|
|
3123
|
+
logger.error("Error fetching data. ", {
|
|
3124
|
+
url,
|
|
3125
|
+
content,
|
|
3126
|
+
options
|
|
3127
|
+
});
|
|
3128
|
+
return null;
|
|
3129
|
+
}
|
|
3130
|
+
return _processContentResult(options, content);
|
|
3131
|
+
} catch (error) {
|
|
3132
|
+
logger.error("Error fetching data. ", error);
|
|
3133
|
+
return null;
|
|
3134
|
+
}
|
|
3135
|
+
}
|
|
3136
|
+
var getAllContent = fetchEntries;
|
|
3137
|
+
|
|
3138
|
+
// src/functions/is-previewing.ts
|
|
3139
|
+
function isPreviewing() {
|
|
3140
|
+
if (!isBrowser()) {
|
|
3141
|
+
return false;
|
|
3142
|
+
}
|
|
3143
|
+
if (isEditing()) {
|
|
3144
|
+
return false;
|
|
3145
|
+
}
|
|
3146
|
+
return Boolean(location.search.indexOf("builder.preview=") !== -1);
|
|
3147
|
+
}
|
|
3148
|
+
|
|
3149
|
+
// src/helpers/uuid.ts
|
|
3150
|
+
function uuidv4() {
|
|
3151
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
3152
|
+
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
|
3153
|
+
return v.toString(16);
|
|
3154
|
+
});
|
|
3155
|
+
}
|
|
3156
|
+
function uuid() {
|
|
3157
|
+
return uuidv4().replace(/-/g, "");
|
|
3158
|
+
}
|
|
3159
|
+
|
|
3160
|
+
// src/helpers/sessionId.ts
|
|
3161
|
+
var SESSION_LOCAL_STORAGE_KEY = "builderSessionId";
|
|
3162
|
+
var getSessionId = async ({
|
|
3163
|
+
canTrack
|
|
3164
|
+
}) => {
|
|
3165
|
+
if (!canTrack) {
|
|
3166
|
+
return void 0;
|
|
3167
|
+
}
|
|
3168
|
+
const sessionId = await getCookie({
|
|
3169
|
+
name: SESSION_LOCAL_STORAGE_KEY,
|
|
3170
|
+
canTrack
|
|
3171
|
+
});
|
|
3172
|
+
if (checkIsDefined(sessionId)) {
|
|
3173
|
+
return sessionId;
|
|
3174
|
+
} else {
|
|
3175
|
+
const newSessionId = createSessionId();
|
|
3176
|
+
setSessionId({
|
|
3177
|
+
id: newSessionId,
|
|
3178
|
+
canTrack
|
|
3179
|
+
});
|
|
3180
|
+
return newSessionId;
|
|
3181
|
+
}
|
|
3182
|
+
};
|
|
3183
|
+
var createSessionId = () => uuid();
|
|
3184
|
+
var setSessionId = ({
|
|
3185
|
+
id,
|
|
3186
|
+
canTrack
|
|
3187
|
+
}) => setCookie({
|
|
3188
|
+
name: SESSION_LOCAL_STORAGE_KEY,
|
|
3189
|
+
value: id,
|
|
3190
|
+
canTrack
|
|
3191
|
+
});
|
|
3192
|
+
|
|
3193
|
+
// src/helpers/localStorage.ts
|
|
3194
|
+
var getLocalStorage = () => isBrowser() && typeof localStorage !== "undefined" ? localStorage : void 0;
|
|
3195
|
+
var getLocalStorageItem = ({
|
|
3196
|
+
key,
|
|
3197
|
+
canTrack
|
|
3198
|
+
}) => {
|
|
3199
|
+
try {
|
|
3200
|
+
if (canTrack) {
|
|
3201
|
+
return getLocalStorage()?.getItem(key);
|
|
3202
|
+
}
|
|
3203
|
+
return void 0;
|
|
3204
|
+
} catch (err) {
|
|
3205
|
+
return void 0;
|
|
3206
|
+
}
|
|
3207
|
+
};
|
|
3208
|
+
var setLocalStorageItem = ({
|
|
3209
|
+
key,
|
|
3210
|
+
canTrack,
|
|
3211
|
+
value
|
|
3212
|
+
}) => {
|
|
3213
|
+
try {
|
|
3214
|
+
if (canTrack) {
|
|
3215
|
+
getLocalStorage()?.setItem(key, value);
|
|
3216
|
+
}
|
|
3217
|
+
} catch (err) {
|
|
3218
|
+
}
|
|
3219
|
+
};
|
|
3220
|
+
|
|
3221
|
+
// src/helpers/visitorId.ts
|
|
3222
|
+
var VISITOR_LOCAL_STORAGE_KEY = "builderVisitorId";
|
|
3223
|
+
var getVisitorId = ({
|
|
3224
|
+
canTrack
|
|
3225
|
+
}) => {
|
|
3226
|
+
if (!canTrack) {
|
|
3227
|
+
return void 0;
|
|
3228
|
+
}
|
|
3229
|
+
const visitorId = getLocalStorageItem({
|
|
3230
|
+
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
3231
|
+
canTrack
|
|
3232
|
+
});
|
|
3233
|
+
if (checkIsDefined(visitorId)) {
|
|
3234
|
+
return visitorId;
|
|
3235
|
+
} else {
|
|
3236
|
+
const newVisitorId = createVisitorId();
|
|
3237
|
+
setVisitorId({
|
|
3238
|
+
id: newVisitorId,
|
|
3239
|
+
canTrack
|
|
3240
|
+
});
|
|
3241
|
+
return newVisitorId;
|
|
3242
|
+
}
|
|
3243
|
+
};
|
|
3244
|
+
var createVisitorId = () => uuid();
|
|
3245
|
+
var setVisitorId = ({
|
|
3246
|
+
id,
|
|
3247
|
+
canTrack
|
|
3248
|
+
}) => setLocalStorageItem({
|
|
3249
|
+
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
3250
|
+
value: id,
|
|
3251
|
+
canTrack
|
|
3252
|
+
});
|
|
3253
|
+
|
|
3254
|
+
// src/functions/track/index.ts
|
|
3255
|
+
var getTrackingEventData = async ({
|
|
3256
|
+
canTrack
|
|
3257
|
+
}) => {
|
|
3258
|
+
if (!canTrack) {
|
|
3259
|
+
return {
|
|
3260
|
+
visitorId: void 0,
|
|
3261
|
+
sessionId: void 0
|
|
3262
|
+
};
|
|
3263
|
+
}
|
|
3264
|
+
const sessionId = await getSessionId({
|
|
3265
|
+
canTrack
|
|
3266
|
+
});
|
|
3267
|
+
const visitorId = getVisitorId({
|
|
3268
|
+
canTrack
|
|
3269
|
+
});
|
|
3270
|
+
return {
|
|
3271
|
+
sessionId,
|
|
3272
|
+
visitorId
|
|
3273
|
+
};
|
|
3274
|
+
};
|
|
3275
|
+
var createEvent = async ({
|
|
3276
|
+
type: eventType,
|
|
3277
|
+
canTrack,
|
|
3278
|
+
apiKey,
|
|
3279
|
+
metadata,
|
|
3280
|
+
...properties
|
|
3281
|
+
}) => ({
|
|
3282
|
+
type: eventType,
|
|
3283
|
+
data: {
|
|
3284
|
+
...properties,
|
|
3285
|
+
metadata: {
|
|
3286
|
+
url: location.href,
|
|
3287
|
+
...metadata
|
|
3288
|
+
},
|
|
3289
|
+
...await getTrackingEventData({
|
|
3290
|
+
canTrack
|
|
3291
|
+
}),
|
|
3292
|
+
userAttributes: getUserAttributes(),
|
|
3293
|
+
ownerId: apiKey
|
|
3294
|
+
}
|
|
3295
|
+
});
|
|
3296
|
+
async function _track(eventProps) {
|
|
3297
|
+
if (!eventProps.apiKey) {
|
|
3298
|
+
logger.error("Missing API key for track call. Please provide your API key.");
|
|
3299
|
+
return;
|
|
3300
|
+
}
|
|
3301
|
+
if (!eventProps.canTrack) {
|
|
3302
|
+
return;
|
|
3303
|
+
}
|
|
3304
|
+
if (isEditing()) {
|
|
3305
|
+
return;
|
|
3306
|
+
}
|
|
3307
|
+
if (!(isBrowser() || TARGET === "reactNative")) {
|
|
3308
|
+
return;
|
|
3309
|
+
}
|
|
3310
|
+
return fetch(`https://cdn.builder.io/api/v1/track`, {
|
|
3311
|
+
method: "POST",
|
|
3312
|
+
body: JSON.stringify({
|
|
3313
|
+
events: [await createEvent(eventProps)]
|
|
3314
|
+
}),
|
|
3315
|
+
headers: {
|
|
3316
|
+
"content-type": "application/json"
|
|
3317
|
+
},
|
|
3318
|
+
mode: "cors"
|
|
3319
|
+
}).catch((err) => {
|
|
3320
|
+
});
|
|
3321
|
+
}
|
|
3322
|
+
var track = (args) => _track({
|
|
3323
|
+
...args,
|
|
3324
|
+
canTrack: true
|
|
3325
|
+
});
|
|
3326
|
+
|
|
3327
|
+
// src/functions/track/interaction.ts
|
|
3328
|
+
function round(num) {
|
|
3329
|
+
return Math.round(num * 1e3) / 1e3;
|
|
3330
|
+
}
|
|
3331
|
+
var findParentElement = (target, callback, checkElement = true) => {
|
|
3332
|
+
if (!(target instanceof HTMLElement)) {
|
|
3333
|
+
return null;
|
|
3334
|
+
}
|
|
3335
|
+
let parent2 = checkElement ? target : target.parentElement;
|
|
3336
|
+
do {
|
|
3337
|
+
if (!parent2) {
|
|
3338
|
+
return null;
|
|
3339
|
+
}
|
|
3340
|
+
const matches = callback(parent2);
|
|
3341
|
+
if (matches) {
|
|
3342
|
+
return parent2;
|
|
3343
|
+
}
|
|
3344
|
+
} while (parent2 = parent2.parentElement);
|
|
3345
|
+
return null;
|
|
3346
|
+
};
|
|
3347
|
+
var findBuilderParent = (target) => findParentElement(target, (el) => {
|
|
3348
|
+
const id = el.getAttribute("builder-id") || el.id;
|
|
3349
|
+
return Boolean(id?.indexOf("builder-") === 0);
|
|
3992
3350
|
});
|
|
3993
|
-
|
|
3994
|
-
|
|
3351
|
+
var computeOffset = ({
|
|
3352
|
+
event,
|
|
3353
|
+
target
|
|
3354
|
+
}) => {
|
|
3355
|
+
const targetRect = target.getBoundingClientRect();
|
|
3356
|
+
const xOffset = event.clientX - targetRect.left;
|
|
3357
|
+
const yOffset = event.clientY - targetRect.top;
|
|
3358
|
+
const xRatio = round(xOffset / targetRect.width);
|
|
3359
|
+
const yRatio = round(yOffset / targetRect.height);
|
|
3360
|
+
return {
|
|
3361
|
+
x: xRatio,
|
|
3362
|
+
y: yRatio
|
|
3363
|
+
};
|
|
3364
|
+
};
|
|
3365
|
+
var getInteractionPropertiesForEvent = (event) => {
|
|
3366
|
+
const target = event.target;
|
|
3367
|
+
const targetBuilderElement = target && findBuilderParent(target);
|
|
3368
|
+
const builderId = targetBuilderElement?.getAttribute("builder-id") || targetBuilderElement?.id;
|
|
3369
|
+
return {
|
|
3370
|
+
targetBuilderElement: builderId || void 0,
|
|
3371
|
+
metadata: {
|
|
3372
|
+
targetOffset: target ? computeOffset({
|
|
3373
|
+
event,
|
|
3374
|
+
target
|
|
3375
|
+
}) : void 0,
|
|
3376
|
+
builderTargetOffset: targetBuilderElement ? computeOffset({
|
|
3377
|
+
event,
|
|
3378
|
+
target: targetBuilderElement
|
|
3379
|
+
}) : void 0,
|
|
3380
|
+
builderElementIndex: targetBuilderElement && builderId ? [].slice.call(document.getElementsByClassName(builderId)).indexOf(targetBuilderElement) : void 0
|
|
3381
|
+
}
|
|
3382
|
+
};
|
|
3383
|
+
};
|
|
3384
|
+
|
|
3385
|
+
// src/constants/sdk-version.ts
|
|
3386
|
+
var SDK_VERSION = "0.7.2";
|
|
3387
|
+
|
|
3388
|
+
// src/functions/register.ts
|
|
3389
|
+
var registry = {};
|
|
3390
|
+
function register(type, info) {
|
|
3391
|
+
let typeList = registry[type];
|
|
3392
|
+
if (!typeList) {
|
|
3393
|
+
typeList = registry[type] = [];
|
|
3394
|
+
}
|
|
3395
|
+
typeList.push(info);
|
|
3396
|
+
if (isBrowser()) {
|
|
3397
|
+
const message = {
|
|
3398
|
+
type: "builder.register",
|
|
3399
|
+
data: {
|
|
3400
|
+
type,
|
|
3401
|
+
info
|
|
3402
|
+
}
|
|
3403
|
+
};
|
|
3995
3404
|
try {
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
logger.error("Error fetching data. ", {
|
|
4000
|
-
url,
|
|
4001
|
-
content,
|
|
4002
|
-
options
|
|
4003
|
-
});
|
|
4004
|
-
return null;
|
|
3405
|
+
parent.postMessage(message, "*");
|
|
3406
|
+
if (parent !== window) {
|
|
3407
|
+
window.postMessage(message, "*");
|
|
4005
3408
|
}
|
|
4006
|
-
|
|
4007
|
-
} catch (error) {
|
|
4008
|
-
logger.error("Error fetching data. ", error);
|
|
4009
|
-
return null;
|
|
3409
|
+
} catch (err) {
|
|
4010
3410
|
}
|
|
4011
|
-
}
|
|
3411
|
+
}
|
|
4012
3412
|
}
|
|
4013
|
-
var getAllContent = fetchEntries;
|
|
4014
3413
|
|
|
4015
|
-
// src/
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
3414
|
+
// src/scripts/init-editing.ts
|
|
3415
|
+
var registerInsertMenu = () => {
|
|
3416
|
+
register("insertMenu", {
|
|
3417
|
+
name: "_default",
|
|
3418
|
+
default: true,
|
|
3419
|
+
items: [{
|
|
3420
|
+
name: "Box"
|
|
3421
|
+
}, {
|
|
3422
|
+
name: "Text"
|
|
3423
|
+
}, {
|
|
3424
|
+
name: "Image"
|
|
3425
|
+
}, {
|
|
3426
|
+
name: "Columns"
|
|
3427
|
+
}, ...TARGET === "reactNative" ? [] : [{
|
|
3428
|
+
name: "Core:Section"
|
|
3429
|
+
}, {
|
|
3430
|
+
name: "Core:Button"
|
|
3431
|
+
}, {
|
|
3432
|
+
name: "Embed"
|
|
3433
|
+
}, {
|
|
3434
|
+
name: "Custom Code"
|
|
3435
|
+
}]]
|
|
3436
|
+
});
|
|
3437
|
+
};
|
|
3438
|
+
var isSetupForEditing = false;
|
|
3439
|
+
var setupBrowserForEditing = (options = {}) => {
|
|
3440
|
+
if (isSetupForEditing) {
|
|
3441
|
+
return;
|
|
4019
3442
|
}
|
|
4020
|
-
|
|
4021
|
-
|
|
3443
|
+
isSetupForEditing = true;
|
|
3444
|
+
if (isBrowser()) {
|
|
3445
|
+
window.parent?.postMessage({
|
|
3446
|
+
type: "builder.sdkInfo",
|
|
3447
|
+
data: {
|
|
3448
|
+
target: TARGET,
|
|
3449
|
+
version: SDK_VERSION,
|
|
3450
|
+
supportsPatchUpdates: false,
|
|
3451
|
+
// Supports builder-model="..." attribute which is needed to
|
|
3452
|
+
// scope our '+ add block' button styling
|
|
3453
|
+
supportsAddBlockScoping: true,
|
|
3454
|
+
supportsCustomBreakpoints: true
|
|
3455
|
+
}
|
|
3456
|
+
}, "*");
|
|
3457
|
+
window.parent?.postMessage({
|
|
3458
|
+
type: "builder.updateContent",
|
|
3459
|
+
data: {
|
|
3460
|
+
options
|
|
3461
|
+
}
|
|
3462
|
+
}, "*");
|
|
3463
|
+
window.addEventListener("message", ({
|
|
3464
|
+
data
|
|
3465
|
+
}) => {
|
|
3466
|
+
if (!data?.type) {
|
|
3467
|
+
return;
|
|
3468
|
+
}
|
|
3469
|
+
switch (data.type) {
|
|
3470
|
+
case "builder.evaluate": {
|
|
3471
|
+
const text = data.data.text;
|
|
3472
|
+
const args = data.data.arguments || [];
|
|
3473
|
+
const id = data.data.id;
|
|
3474
|
+
const fn = new Function(text);
|
|
3475
|
+
let result;
|
|
3476
|
+
let error = null;
|
|
3477
|
+
try {
|
|
3478
|
+
result = fn.apply(null, args);
|
|
3479
|
+
} catch (err) {
|
|
3480
|
+
error = err;
|
|
3481
|
+
}
|
|
3482
|
+
if (error) {
|
|
3483
|
+
window.parent?.postMessage({
|
|
3484
|
+
type: "builder.evaluateError",
|
|
3485
|
+
data: {
|
|
3486
|
+
id,
|
|
3487
|
+
error: error.message
|
|
3488
|
+
}
|
|
3489
|
+
}, "*");
|
|
3490
|
+
} else {
|
|
3491
|
+
if (result && typeof result.then === "function") {
|
|
3492
|
+
result.then((finalResult) => {
|
|
3493
|
+
window.parent?.postMessage({
|
|
3494
|
+
type: "builder.evaluateResult",
|
|
3495
|
+
data: {
|
|
3496
|
+
id,
|
|
3497
|
+
result: finalResult
|
|
3498
|
+
}
|
|
3499
|
+
}, "*");
|
|
3500
|
+
}).catch(console.error);
|
|
3501
|
+
} else {
|
|
3502
|
+
window.parent?.postMessage({
|
|
3503
|
+
type: "builder.evaluateResult",
|
|
3504
|
+
data: {
|
|
3505
|
+
result,
|
|
3506
|
+
id
|
|
3507
|
+
}
|
|
3508
|
+
}, "*");
|
|
3509
|
+
}
|
|
3510
|
+
}
|
|
3511
|
+
break;
|
|
3512
|
+
}
|
|
3513
|
+
}
|
|
3514
|
+
});
|
|
4022
3515
|
}
|
|
4023
|
-
|
|
4024
|
-
}
|
|
3516
|
+
};
|
|
4025
3517
|
|
|
4026
|
-
// src/components/content/components/enable-editor.
|
|
4027
|
-
var _tmpl$
|
|
3518
|
+
// src/components/content/components/enable-editor.tsx
|
|
3519
|
+
var _tmpl$15 = /* @__PURE__ */ template(`<div>`);
|
|
4028
3520
|
function EnableEditor(props) {
|
|
4029
3521
|
const [forceReRenderCount, setForceReRenderCount] = createSignal(0);
|
|
4030
3522
|
createSignal(0);
|
|
@@ -4250,7 +3742,7 @@ function EnableEditor(props) {
|
|
|
4250
3742
|
emitStateUpdate();
|
|
4251
3743
|
}
|
|
4252
3744
|
createEffect(on(() => [props.builderContextSignal.rootState], onUpdateFn_4));
|
|
4253
|
-
return createComponent(
|
|
3745
|
+
return createComponent(builder_context_default.Provider, {
|
|
4254
3746
|
get value() {
|
|
4255
3747
|
return props.builderContextSignal;
|
|
4256
3748
|
},
|
|
@@ -4260,7 +3752,7 @@ function EnableEditor(props) {
|
|
|
4260
3752
|
return props.builderContextSignal.content;
|
|
4261
3753
|
},
|
|
4262
3754
|
get children() {
|
|
4263
|
-
const _el$ = _tmpl$
|
|
3755
|
+
const _el$ = _tmpl$15();
|
|
4264
3756
|
const _ref$ = elementRef;
|
|
4265
3757
|
typeof _ref$ === "function" ? use(_ref$, _el$) : elementRef = _el$;
|
|
4266
3758
|
spread(_el$, mergeProps({
|
|
@@ -4290,25 +3782,133 @@ function EnableEditor(props) {
|
|
|
4290
3782
|
});
|
|
4291
3783
|
}
|
|
4292
3784
|
var enable_editor_default = EnableEditor;
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
})();
|
|
3785
|
+
|
|
3786
|
+
// src/components/content/components/styles.helpers.ts
|
|
3787
|
+
var getCssFromFont = (font) => {
|
|
3788
|
+
const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
|
|
3789
|
+
const name = family.split(",")[0];
|
|
3790
|
+
const url = font.fileUrl ?? font?.files?.regular;
|
|
3791
|
+
let str = "";
|
|
3792
|
+
if (url && family && name) {
|
|
3793
|
+
str += `
|
|
3794
|
+
@font-face {
|
|
3795
|
+
font-family: "${family}";
|
|
3796
|
+
src: local("${name}"), url('${url}') format('woff2');
|
|
3797
|
+
font-display: fallback;
|
|
3798
|
+
font-weight: 400;
|
|
4308
3799
|
}
|
|
4309
|
-
|
|
3800
|
+
`.trim();
|
|
3801
|
+
}
|
|
3802
|
+
if (font.files) {
|
|
3803
|
+
for (const weight in font.files) {
|
|
3804
|
+
const isNumber = String(Number(weight)) === weight;
|
|
3805
|
+
if (!isNumber) {
|
|
3806
|
+
continue;
|
|
3807
|
+
}
|
|
3808
|
+
const weightUrl = font.files[weight];
|
|
3809
|
+
if (weightUrl && weightUrl !== url) {
|
|
3810
|
+
str += `
|
|
3811
|
+
@font-face {
|
|
3812
|
+
font-family: "${family}";
|
|
3813
|
+
src: url('${weightUrl}') format('woff2');
|
|
3814
|
+
font-display: fallback;
|
|
3815
|
+
font-weight: ${weight};
|
|
3816
|
+
}
|
|
3817
|
+
`.trim();
|
|
3818
|
+
}
|
|
3819
|
+
}
|
|
3820
|
+
}
|
|
3821
|
+
return str;
|
|
3822
|
+
};
|
|
3823
|
+
var getFontCss = ({
|
|
3824
|
+
customFonts
|
|
3825
|
+
}) => {
|
|
3826
|
+
return customFonts?.map((font) => getCssFromFont(font))?.join(" ") || "";
|
|
3827
|
+
};
|
|
3828
|
+
var getCss = ({
|
|
3829
|
+
cssCode,
|
|
3830
|
+
contentId
|
|
3831
|
+
}) => {
|
|
3832
|
+
if (!cssCode) {
|
|
3833
|
+
return "";
|
|
3834
|
+
}
|
|
3835
|
+
if (!contentId) {
|
|
3836
|
+
return cssCode;
|
|
3837
|
+
}
|
|
3838
|
+
return cssCode?.replace(/&/g, `div[builder-content-id="${contentId}"]`) || "";
|
|
3839
|
+
};
|
|
3840
|
+
|
|
3841
|
+
// src/components/content/components/styles.tsx
|
|
3842
|
+
function ContentStyles(props) {
|
|
3843
|
+
const [injectedStyles, setInjectedStyles] = createSignal(`
|
|
3844
|
+
${getCss({
|
|
3845
|
+
cssCode: props.cssCode,
|
|
3846
|
+
contentId: props.contentId
|
|
3847
|
+
})}
|
|
3848
|
+
${getFontCss({
|
|
3849
|
+
customFonts: props.customFonts
|
|
3850
|
+
})}
|
|
3851
|
+
|
|
3852
|
+
.builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
|
|
3853
|
+
margin: 0;
|
|
3854
|
+
}
|
|
3855
|
+
.builder-text > p, .builder-text > .builder-paragraph {
|
|
3856
|
+
color: inherit;
|
|
3857
|
+
line-height: inherit;
|
|
3858
|
+
letter-spacing: inherit;
|
|
3859
|
+
font-weight: inherit;
|
|
3860
|
+
font-size: inherit;
|
|
3861
|
+
text-align: inherit;
|
|
3862
|
+
font-family: inherit;
|
|
3863
|
+
}
|
|
3864
|
+
`.trim());
|
|
3865
|
+
return createComponent(inlined_styles_default, {
|
|
3866
|
+
get styles() {
|
|
3867
|
+
return injectedStyles();
|
|
3868
|
+
}
|
|
3869
|
+
});
|
|
3870
|
+
}
|
|
3871
|
+
var styles_default = ContentStyles;
|
|
3872
|
+
|
|
3873
|
+
// src/components/content/content.helpers.ts
|
|
3874
|
+
var getContextStateInitialValue = ({
|
|
3875
|
+
content,
|
|
3876
|
+
data,
|
|
3877
|
+
locale
|
|
3878
|
+
}) => {
|
|
3879
|
+
const defaultValues = {};
|
|
3880
|
+
content?.data?.inputs?.forEach((input) => {
|
|
3881
|
+
if (input.name && input.defaultValue !== void 0 && content?.data?.state && content.data.state[input.name] === void 0) {
|
|
3882
|
+
defaultValues[input.name] = input.defaultValue;
|
|
3883
|
+
}
|
|
3884
|
+
});
|
|
3885
|
+
const stateToUse = {
|
|
3886
|
+
...content?.data?.state,
|
|
3887
|
+
...data,
|
|
3888
|
+
...locale ? {
|
|
3889
|
+
locale
|
|
3890
|
+
} : {}
|
|
3891
|
+
};
|
|
3892
|
+
return {
|
|
3893
|
+
...defaultValues,
|
|
3894
|
+
...stateToUse
|
|
3895
|
+
};
|
|
3896
|
+
};
|
|
3897
|
+
var getContentInitialValue = ({
|
|
3898
|
+
content,
|
|
3899
|
+
data
|
|
3900
|
+
}) => {
|
|
3901
|
+
return !content ? void 0 : {
|
|
3902
|
+
...content,
|
|
3903
|
+
data: {
|
|
3904
|
+
...content?.data,
|
|
3905
|
+
...data
|
|
3906
|
+
},
|
|
3907
|
+
meta: content?.meta
|
|
3908
|
+
};
|
|
3909
|
+
};
|
|
4310
3910
|
|
|
4311
|
-
// src/components/content/content.
|
|
3911
|
+
// src/components/content/content.tsx
|
|
4312
3912
|
function ContentComponent(props) {
|
|
4313
3913
|
const [scriptStr, setScriptStr] = createSignal(getRenderContentScriptString({
|
|
4314
3914
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
@@ -4374,7 +3974,7 @@ function ContentComponent(props) {
|
|
|
4374
3974
|
rootState: newRootState
|
|
4375
3975
|
}));
|
|
4376
3976
|
}
|
|
4377
|
-
return createComponent(
|
|
3977
|
+
return createComponent(components_context_default.Provider, {
|
|
4378
3978
|
get value() {
|
|
4379
3979
|
return {
|
|
4380
3980
|
registeredComponents: registeredComponents()
|
|
@@ -4463,7 +4063,7 @@ function ContentComponent(props) {
|
|
|
4463
4063
|
}
|
|
4464
4064
|
var content_default = ContentComponent;
|
|
4465
4065
|
|
|
4466
|
-
// src/components/content-variants/content-variants.
|
|
4066
|
+
// src/components/content-variants/content-variants.tsx
|
|
4467
4067
|
function ContentVariants(props) {
|
|
4468
4068
|
const [shouldRenderVariants, setShouldRenderVariants] = createSignal(checkShouldRunVariants({
|
|
4469
4069
|
canTrack: getDefaultCanTrack(props.canTrack),
|
|
@@ -4488,6 +4088,7 @@ function ContentVariants(props) {
|
|
|
4488
4088
|
});
|
|
4489
4089
|
}
|
|
4490
4090
|
onMount(() => {
|
|
4091
|
+
setShouldRenderVariants(false);
|
|
4491
4092
|
});
|
|
4492
4093
|
return [createComponent(Show, {
|
|
4493
4094
|
get when() {
|
|
@@ -4611,70 +4212,31 @@ function ContentVariants(props) {
|
|
|
4611
4212
|
}
|
|
4612
4213
|
var content_variants_default = ContentVariants;
|
|
4613
4214
|
|
|
4614
|
-
// src/blocks/symbol/symbol.helpers.
|
|
4615
|
-
var
|
|
4616
|
-
var __getOwnPropSymbols17 = Object.getOwnPropertySymbols;
|
|
4617
|
-
var __hasOwnProp17 = Object.prototype.hasOwnProperty;
|
|
4618
|
-
var __propIsEnum17 = Object.prototype.propertyIsEnumerable;
|
|
4619
|
-
var __defNormalProp17 = (obj, key, value) => key in obj ? __defProp17(obj, key, {
|
|
4620
|
-
enumerable: true,
|
|
4621
|
-
configurable: true,
|
|
4622
|
-
writable: true,
|
|
4623
|
-
value
|
|
4624
|
-
}) : obj[key] = value;
|
|
4625
|
-
var __spreadValues17 = (a, b) => {
|
|
4626
|
-
for (var prop in b || (b = {}))
|
|
4627
|
-
if (__hasOwnProp17.call(b, prop))
|
|
4628
|
-
__defNormalProp17(a, prop, b[prop]);
|
|
4629
|
-
if (__getOwnPropSymbols17)
|
|
4630
|
-
for (var prop of __getOwnPropSymbols17(b)) {
|
|
4631
|
-
if (__propIsEnum17.call(b, prop))
|
|
4632
|
-
__defNormalProp17(a, prop, b[prop]);
|
|
4633
|
-
}
|
|
4634
|
-
return a;
|
|
4635
|
-
};
|
|
4636
|
-
var __async6 = (__this, __arguments, generator) => {
|
|
4637
|
-
return new Promise((resolve, reject) => {
|
|
4638
|
-
var fulfilled = (value) => {
|
|
4639
|
-
try {
|
|
4640
|
-
step(generator.next(value));
|
|
4641
|
-
} catch (e) {
|
|
4642
|
-
reject(e);
|
|
4643
|
-
}
|
|
4644
|
-
};
|
|
4645
|
-
var rejected = (value) => {
|
|
4646
|
-
try {
|
|
4647
|
-
step(generator.throw(value));
|
|
4648
|
-
} catch (e) {
|
|
4649
|
-
reject(e);
|
|
4650
|
-
}
|
|
4651
|
-
};
|
|
4652
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
4653
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
4654
|
-
});
|
|
4655
|
-
};
|
|
4656
|
-
var fetchSymbolContent = (_0) => __async6(void 0, [_0], function* ({
|
|
4215
|
+
// src/blocks/symbol/symbol.helpers.ts
|
|
4216
|
+
var fetchSymbolContent = async ({
|
|
4657
4217
|
builderContextValue,
|
|
4658
4218
|
symbol
|
|
4659
|
-
}) {
|
|
4660
|
-
if (
|
|
4661
|
-
|
|
4219
|
+
}) => {
|
|
4220
|
+
if (symbol?.model && // This is a hack, we should not need to check for this, but it is needed for Svelte.
|
|
4221
|
+
builderContextValue?.apiKey) {
|
|
4222
|
+
return fetchOneEntry({
|
|
4662
4223
|
model: symbol.model,
|
|
4663
4224
|
apiKey: builderContextValue.apiKey,
|
|
4664
|
-
apiVersion: builderContextValue.apiVersion
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4225
|
+
apiVersion: builderContextValue.apiVersion,
|
|
4226
|
+
...symbol?.entry && {
|
|
4227
|
+
query: {
|
|
4228
|
+
id: symbol.entry
|
|
4229
|
+
}
|
|
4668
4230
|
}
|
|
4669
|
-
})
|
|
4231
|
+
}).catch((err) => {
|
|
4670
4232
|
logger.error("Could not fetch symbol content: ", err);
|
|
4671
4233
|
return void 0;
|
|
4672
4234
|
});
|
|
4673
4235
|
}
|
|
4674
4236
|
return void 0;
|
|
4675
|
-
}
|
|
4237
|
+
};
|
|
4676
4238
|
|
|
4677
|
-
// src/blocks/symbol/symbol.
|
|
4239
|
+
// src/blocks/symbol/symbol.tsx
|
|
4678
4240
|
var _tmpl$16 = /* @__PURE__ */ template(`<div>`);
|
|
4679
4241
|
function Symbol(props) {
|
|
4680
4242
|
const [contentToUse, setContentToUse] = createSignal(props.symbol?.content);
|
|
@@ -4740,11 +4302,11 @@ function Symbol(props) {
|
|
|
4740
4302
|
}
|
|
4741
4303
|
var symbol_default = Symbol;
|
|
4742
4304
|
|
|
4743
|
-
// src/index-helpers/blocks-exports.
|
|
4305
|
+
// src/index-helpers/blocks-exports.ts
|
|
4744
4306
|
var RenderBlocks = blocks_default;
|
|
4745
4307
|
var RenderContent = content_variants_default;
|
|
4746
4308
|
|
|
4747
|
-
// src/functions/set-editor-settings.
|
|
4309
|
+
// src/functions/set-editor-settings.ts
|
|
4748
4310
|
var settings = {};
|
|
4749
4311
|
function setEditorSettings(newSettings) {
|
|
4750
4312
|
if (isBrowser()) {
|
|
@@ -4757,67 +4319,26 @@ function setEditorSettings(newSettings) {
|
|
|
4757
4319
|
}
|
|
4758
4320
|
}
|
|
4759
4321
|
|
|
4760
|
-
// src/functions/fetch-builder-props.
|
|
4761
|
-
var
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
var __hasOwnProp18 = Object.prototype.hasOwnProperty;
|
|
4766
|
-
var __propIsEnum18 = Object.prototype.propertyIsEnumerable;
|
|
4767
|
-
var __defNormalProp18 = (obj, key, value) => key in obj ? __defProp18(obj, key, {
|
|
4768
|
-
enumerable: true,
|
|
4769
|
-
configurable: true,
|
|
4770
|
-
writable: true,
|
|
4771
|
-
value
|
|
4772
|
-
}) : obj[key] = value;
|
|
4773
|
-
var __spreadValues18 = (a, b) => {
|
|
4774
|
-
for (var prop in b || (b = {}))
|
|
4775
|
-
if (__hasOwnProp18.call(b, prop))
|
|
4776
|
-
__defNormalProp18(a, prop, b[prop]);
|
|
4777
|
-
if (__getOwnPropSymbols18)
|
|
4778
|
-
for (var prop of __getOwnPropSymbols18(b)) {
|
|
4779
|
-
if (__propIsEnum18.call(b, prop))
|
|
4780
|
-
__defNormalProp18(a, prop, b[prop]);
|
|
4781
|
-
}
|
|
4782
|
-
return a;
|
|
4783
|
-
};
|
|
4784
|
-
var __spreadProps12 = (a, b) => __defProps12(a, __getOwnPropDescs12(b));
|
|
4785
|
-
var __async7 = (__this, __arguments, generator) => {
|
|
4786
|
-
return new Promise((resolve, reject) => {
|
|
4787
|
-
var fulfilled = (value) => {
|
|
4788
|
-
try {
|
|
4789
|
-
step(generator.next(value));
|
|
4790
|
-
} catch (e) {
|
|
4791
|
-
reject(e);
|
|
4792
|
-
}
|
|
4793
|
-
};
|
|
4794
|
-
var rejected = (value) => {
|
|
4795
|
-
try {
|
|
4796
|
-
step(generator.throw(value));
|
|
4797
|
-
} catch (e) {
|
|
4798
|
-
reject(e);
|
|
4799
|
-
}
|
|
4800
|
-
};
|
|
4801
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
4802
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
4803
|
-
});
|
|
4804
|
-
};
|
|
4805
|
-
var fetchBuilderProps = (_args) => __async7(void 0, null, function* () {
|
|
4806
|
-
var _a, _b, _c;
|
|
4807
|
-
const urlPath = _args.path || ((_a = _args.url) == null ? void 0 : _a.pathname) || ((_b = _args.userAttributes) == null ? void 0 : _b.urlPath);
|
|
4808
|
-
const getContentArgs = __spreadProps12(__spreadValues18({}, _args), {
|
|
4322
|
+
// src/functions/fetch-builder-props.ts
|
|
4323
|
+
var fetchBuilderProps = async (_args) => {
|
|
4324
|
+
const urlPath = _args.path || _args.url?.pathname || _args.userAttributes?.urlPath;
|
|
4325
|
+
const getContentArgs = {
|
|
4326
|
+
..._args,
|
|
4809
4327
|
apiKey: _args.apiKey,
|
|
4810
4328
|
model: _args.model || "page",
|
|
4811
|
-
userAttributes:
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4329
|
+
userAttributes: {
|
|
4330
|
+
..._args.userAttributes,
|
|
4331
|
+
...urlPath ? {
|
|
4332
|
+
urlPath
|
|
4333
|
+
} : {}
|
|
4334
|
+
},
|
|
4335
|
+
options: getBuilderSearchParams(_args.searchParams || _args.url?.searchParams || _args.options)
|
|
4336
|
+
};
|
|
4816
4337
|
return {
|
|
4817
4338
|
apiKey: getContentArgs.apiKey,
|
|
4818
4339
|
model: getContentArgs.model,
|
|
4819
|
-
content:
|
|
4340
|
+
content: await fetchOneEntry(getContentArgs)
|
|
4820
4341
|
};
|
|
4821
|
-
}
|
|
4342
|
+
};
|
|
4822
4343
|
|
|
4823
4344
|
export { blocks_default as Blocks, button_default as Button, columns_default as Columns, content_variants_default as Content, fragment_default as Fragment, image_default as Image, RenderBlocks, RenderContent, section_default as Section, symbol_default as Symbol, text_default as Text, video_default as Video, _processContentResult, createRegisterComponentMessage, fetchBuilderProps, fetchEntries, fetchOneEntry, getAllContent, getBuilderSearchParams, getContent, isEditing, isPreviewing, register, setEditorSettings, track };
|