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