@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/node/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { createComponent, spread, mergeProps, insert, effect, setAttribute, className, style, template, memo, Dynamic, use } from 'solid-js/web';
|
|
2
2
|
import { createContext, Show, useContext, For, createSignal, onMount, createEffect, on } from 'solid-js';
|
|
3
3
|
import { css } from 'solid-styled-components';
|
|
4
|
+
import { createRequire } from 'node:module';
|
|
4
5
|
|
|
5
|
-
// src/blocks/button/button.
|
|
6
|
-
var _tmpl$ = /* @__PURE__ */ template(`<a
|
|
6
|
+
// src/blocks/button/button.tsx
|
|
7
|
+
var _tmpl$ = /* @__PURE__ */ template(`<a>`);
|
|
7
8
|
var _tmpl$2 = /* @__PURE__ */ template(`<button>`);
|
|
8
9
|
function Button(props) {
|
|
9
10
|
return createComponent(Show, {
|
|
@@ -36,7 +37,8 @@ function Button(props) {
|
|
|
36
37
|
},
|
|
37
38
|
get target() {
|
|
38
39
|
return props.openLinkInNewTab ? "_blank" : void 0;
|
|
39
|
-
}
|
|
40
|
+
},
|
|
41
|
+
"role": "button"
|
|
40
42
|
}), false, true);
|
|
41
43
|
insert(_el$, () => props.text);
|
|
42
44
|
return _el$;
|
|
@@ -44,62 +46,33 @@ function Button(props) {
|
|
|
44
46
|
});
|
|
45
47
|
}
|
|
46
48
|
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
|
|
49
|
+
var builder_context_default = createContext({
|
|
50
|
+
content: null,
|
|
51
|
+
context: {},
|
|
52
|
+
localState: void 0,
|
|
53
|
+
rootSetState() {
|
|
62
54
|
},
|
|
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
|
-
};
|
|
55
|
+
rootState: {},
|
|
56
|
+
apiKey: null,
|
|
57
|
+
apiVersion: void 0,
|
|
58
|
+
componentInfos: {},
|
|
59
|
+
inheritedStyles: {}
|
|
60
|
+
});
|
|
61
|
+
var components_context_default = createContext({ registeredComponents: {} });
|
|
98
62
|
|
|
99
|
-
// src/
|
|
100
|
-
|
|
63
|
+
// src/functions/get-block-component-options.ts
|
|
64
|
+
function getBlockComponentOptions(block) {
|
|
65
|
+
return {
|
|
66
|
+
...block.component?.options,
|
|
67
|
+
...block.options,
|
|
68
|
+
/**
|
|
69
|
+
* Our built-in components frequently make use of the block, so we provide all of it under `builderBlock`
|
|
70
|
+
*/
|
|
71
|
+
builderBlock: block
|
|
72
|
+
};
|
|
73
|
+
}
|
|
101
74
|
|
|
102
|
-
// src/helpers/logger.
|
|
75
|
+
// src/helpers/logger.ts
|
|
103
76
|
var logger = {
|
|
104
77
|
log: (...message) => void 0,
|
|
105
78
|
error: (...message) => void 0,
|
|
@@ -107,22 +80,25 @@ var logger = {
|
|
|
107
80
|
debug: (...message) => void 0
|
|
108
81
|
};
|
|
109
82
|
|
|
110
|
-
// src/functions/is-browser.
|
|
83
|
+
// src/functions/is-browser.ts
|
|
111
84
|
function isBrowser() {
|
|
112
85
|
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
113
86
|
}
|
|
114
87
|
|
|
115
|
-
// src/
|
|
88
|
+
// src/constants/target.ts
|
|
89
|
+
var TARGET = "solid";
|
|
90
|
+
|
|
91
|
+
// src/functions/is-iframe.ts
|
|
116
92
|
function isIframe() {
|
|
117
93
|
return isBrowser() && window.self !== window.top;
|
|
118
94
|
}
|
|
119
95
|
|
|
120
|
-
// src/functions/is-editing.
|
|
96
|
+
// src/functions/is-editing.ts
|
|
121
97
|
function isEditing() {
|
|
122
98
|
return isIframe() && (TARGET === "reactNative" || window.location.search.indexOf("builder.frameEditing=") !== -1);
|
|
123
99
|
}
|
|
124
100
|
|
|
125
|
-
// src/functions/track/helpers.
|
|
101
|
+
// src/functions/track/helpers.ts
|
|
126
102
|
var getLocation = () => {
|
|
127
103
|
if (TARGET === "reactNative") {
|
|
128
104
|
return null;
|
|
@@ -162,13 +138,13 @@ var getUserAttributes = () => {
|
|
|
162
138
|
const isTablet = userAgent.match(/Tablet|iPad/i);
|
|
163
139
|
const url = getLocation();
|
|
164
140
|
return {
|
|
165
|
-
urlPath: url
|
|
166
|
-
host:
|
|
141
|
+
urlPath: url?.pathname,
|
|
142
|
+
host: url?.host || url?.hostname,
|
|
167
143
|
device: isTablet ? "tablet" : isMobile.any() ? "mobile" : "desktop"
|
|
168
144
|
};
|
|
169
145
|
};
|
|
170
146
|
|
|
171
|
-
// src/functions/evaluate/helpers.
|
|
147
|
+
// src/functions/evaluate/helpers.ts
|
|
172
148
|
var getFunctionArguments = ({
|
|
173
149
|
builder,
|
|
174
150
|
context,
|
|
@@ -178,6 +154,7 @@ var getFunctionArguments = ({
|
|
|
178
154
|
return Object.entries({
|
|
179
155
|
state,
|
|
180
156
|
Builder: builder,
|
|
157
|
+
// legacy
|
|
181
158
|
builder,
|
|
182
159
|
context,
|
|
183
160
|
event
|
|
@@ -192,12 +169,15 @@ var getBuilderGlobals = () => ({
|
|
|
192
169
|
var parseCode = (code, {
|
|
193
170
|
isExpression = true
|
|
194
171
|
}) => {
|
|
195
|
-
const useReturn =
|
|
172
|
+
const useReturn = (
|
|
173
|
+
// we disable this for cases where we definitely don't want a return
|
|
174
|
+
isExpression && !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "))
|
|
175
|
+
);
|
|
196
176
|
const useCode = useReturn ? `return (${code});` : code;
|
|
197
177
|
return useCode;
|
|
198
178
|
};
|
|
199
179
|
|
|
200
|
-
// src/functions/evaluate/browser-runtime/browser.
|
|
180
|
+
// src/functions/evaluate/browser-runtime/browser.ts
|
|
201
181
|
var runInBrowser = ({
|
|
202
182
|
code,
|
|
203
183
|
builder,
|
|
@@ -231,21 +211,16 @@ function flattenState(rootState, localState, rootSetState) {
|
|
|
231
211
|
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
232
212
|
}
|
|
233
213
|
rootState[prop] = value;
|
|
234
|
-
rootSetState
|
|
214
|
+
rootSetState?.(rootState);
|
|
235
215
|
return true;
|
|
236
216
|
}
|
|
237
217
|
});
|
|
238
218
|
}
|
|
239
219
|
|
|
240
|
-
// src/functions/
|
|
241
|
-
var
|
|
242
|
-
var safeDynamicRequire = noop;
|
|
243
|
-
try {
|
|
244
|
-
safeDynamicRequire = eval("require");
|
|
245
|
-
} catch (error) {
|
|
246
|
-
}
|
|
220
|
+
// src/functions/fast-clone.ts
|
|
221
|
+
var fastClone = (obj) => JSON.parse(JSON.stringify(obj));
|
|
247
222
|
|
|
248
|
-
// src/functions/set.
|
|
223
|
+
// src/functions/set.ts
|
|
249
224
|
var set = (obj, _path, value) => {
|
|
250
225
|
if (Object(obj) !== obj) {
|
|
251
226
|
return obj;
|
|
@@ -254,32 +229,14 @@ var set = (obj, _path, value) => {
|
|
|
254
229
|
path.slice(0, -1).reduce((a, c, i) => Object(a[c]) === a[c] ? a[c] : a[c] = Math.abs(Number(path[i + 1])) >> 0 === +path[i + 1] ? [] : {}, obj)[path[path.length - 1]] = value;
|
|
255
230
|
return obj;
|
|
256
231
|
};
|
|
232
|
+
var noop = () => null;
|
|
233
|
+
var safeDynamicRequire = noop;
|
|
234
|
+
try {
|
|
235
|
+
safeDynamicRequire = createRequire(import.meta.url);
|
|
236
|
+
} catch (error) {
|
|
237
|
+
}
|
|
257
238
|
|
|
258
|
-
// src/functions/evaluate/node-runtime/node-runtime.
|
|
259
|
-
var __defProp = Object.defineProperty;
|
|
260
|
-
var __defProps = Object.defineProperties;
|
|
261
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
262
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
263
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
264
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
265
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
266
|
-
enumerable: true,
|
|
267
|
-
configurable: true,
|
|
268
|
-
writable: true,
|
|
269
|
-
value
|
|
270
|
-
}) : obj[key] = value;
|
|
271
|
-
var __spreadValues = (a, b) => {
|
|
272
|
-
for (var prop in b || (b = {}))
|
|
273
|
-
if (__hasOwnProp.call(b, prop))
|
|
274
|
-
__defNormalProp(a, prop, b[prop]);
|
|
275
|
-
if (__getOwnPropSymbols)
|
|
276
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
277
|
-
if (__propIsEnum.call(b, prop))
|
|
278
|
-
__defNormalProp(a, prop, b[prop]);
|
|
279
|
-
}
|
|
280
|
-
return a;
|
|
281
|
-
};
|
|
282
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
239
|
+
// src/functions/evaluate/node-runtime/node-runtime.ts
|
|
283
240
|
var ivm = safeDynamicRequire("isolated-vm");
|
|
284
241
|
var getSyncValName = (key) => `bldr_${key}_sync`;
|
|
285
242
|
var BUILDER_SET_STATE_NAME = "BUILDER_SET_STATE";
|
|
@@ -347,7 +304,10 @@ var runInNode = ({
|
|
|
347
304
|
rootSetState,
|
|
348
305
|
rootState
|
|
349
306
|
}) => {
|
|
350
|
-
const state = fastClone(
|
|
307
|
+
const state = fastClone({
|
|
308
|
+
...rootState,
|
|
309
|
+
...localState
|
|
310
|
+
});
|
|
351
311
|
const args = getFunctionArguments({
|
|
352
312
|
builder,
|
|
353
313
|
context,
|
|
@@ -361,12 +321,16 @@ var runInNode = ({
|
|
|
361
321
|
});
|
|
362
322
|
jail.setSync(BUILDER_SET_STATE_NAME, function(key, value) {
|
|
363
323
|
set(rootState, key, value);
|
|
364
|
-
rootSetState
|
|
324
|
+
rootSetState?.(rootState);
|
|
365
325
|
});
|
|
366
326
|
args.forEach(([key, arg]) => {
|
|
367
|
-
const val = typeof arg === "object" ? new ivm.Reference(
|
|
368
|
-
|
|
369
|
-
|
|
327
|
+
const val = typeof arg === "object" ? new ivm.Reference(
|
|
328
|
+
// workaround: methods with default values for arguments is not being cloned over
|
|
329
|
+
key === "builder" ? {
|
|
330
|
+
...arg,
|
|
331
|
+
getUserAttributes: () => arg.getUserAttributes()
|
|
332
|
+
} : arg
|
|
333
|
+
) : null;
|
|
370
334
|
jail.setSync(getSyncValName(key), val);
|
|
371
335
|
});
|
|
372
336
|
jail.setSync(INJECTED_IVM_GLOBAL, ivm);
|
|
@@ -383,10 +347,10 @@ var runInNode = ({
|
|
|
383
347
|
}
|
|
384
348
|
};
|
|
385
349
|
|
|
386
|
-
// src/functions/evaluate/choose-eval.
|
|
350
|
+
// src/functions/evaluate/choose-eval.ts
|
|
387
351
|
var chooseBrowserOrServerEval = (args) => isBrowser() ? runInBrowser(args) : runInNode(args);
|
|
388
352
|
|
|
389
|
-
// src/functions/evaluate/evaluate.
|
|
353
|
+
// src/functions/evaluate/evaluate.ts
|
|
390
354
|
function evaluate({
|
|
391
355
|
code,
|
|
392
356
|
context,
|
|
@@ -421,36 +385,12 @@ function evaluate({
|
|
|
421
385
|
}
|
|
422
386
|
}
|
|
423
387
|
|
|
424
|
-
// src/functions/transform-block.
|
|
388
|
+
// src/functions/transform-block.ts
|
|
425
389
|
function transformBlock(block) {
|
|
426
390
|
return block;
|
|
427
391
|
}
|
|
428
392
|
|
|
429
|
-
// src/functions/get-processed-block.
|
|
430
|
-
var __defProp2 = Object.defineProperty;
|
|
431
|
-
var __defProps2 = Object.defineProperties;
|
|
432
|
-
var __getOwnPropDescs2 = Object.getOwnPropertyDescriptors;
|
|
433
|
-
var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
|
|
434
|
-
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
435
|
-
var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
|
|
436
|
-
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, {
|
|
437
|
-
enumerable: true,
|
|
438
|
-
configurable: true,
|
|
439
|
-
writable: true,
|
|
440
|
-
value
|
|
441
|
-
}) : obj[key] = value;
|
|
442
|
-
var __spreadValues2 = (a, b) => {
|
|
443
|
-
for (var prop in b || (b = {}))
|
|
444
|
-
if (__hasOwnProp2.call(b, prop))
|
|
445
|
-
__defNormalProp2(a, prop, b[prop]);
|
|
446
|
-
if (__getOwnPropSymbols2)
|
|
447
|
-
for (var prop of __getOwnPropSymbols2(b)) {
|
|
448
|
-
if (__propIsEnum2.call(b, prop))
|
|
449
|
-
__defNormalProp2(a, prop, b[prop]);
|
|
450
|
-
}
|
|
451
|
-
return a;
|
|
452
|
-
};
|
|
453
|
-
var __spreadProps2 = (a, b) => __defProps2(a, __getOwnPropDescs2(b));
|
|
393
|
+
// src/functions/get-processed-block.ts
|
|
454
394
|
var evaluateBindings = ({
|
|
455
395
|
block,
|
|
456
396
|
context,
|
|
@@ -462,10 +402,15 @@ var evaluateBindings = ({
|
|
|
462
402
|
return block;
|
|
463
403
|
}
|
|
464
404
|
const copy = fastClone(block);
|
|
465
|
-
const copied =
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
405
|
+
const copied = {
|
|
406
|
+
...copy,
|
|
407
|
+
properties: {
|
|
408
|
+
...copy.properties
|
|
409
|
+
},
|
|
410
|
+
actions: {
|
|
411
|
+
...copy.actions
|
|
412
|
+
}
|
|
413
|
+
};
|
|
469
414
|
for (const binding in block.bindings) {
|
|
470
415
|
const expression = block.bindings[binding];
|
|
471
416
|
const value = evaluate({
|
|
@@ -501,13 +446,129 @@ function getProcessedBlock({
|
|
|
501
446
|
}
|
|
502
447
|
}
|
|
503
448
|
|
|
504
|
-
// src/
|
|
449
|
+
// src/components/block/block.helpers.ts
|
|
450
|
+
var EMPTY_HTML_ELEMENTS = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
|
|
451
|
+
var isEmptyHtmlElement = (tagName) => {
|
|
452
|
+
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
|
|
453
|
+
};
|
|
454
|
+
var getComponent = ({
|
|
455
|
+
block,
|
|
456
|
+
context,
|
|
457
|
+
registeredComponents
|
|
458
|
+
}) => {
|
|
459
|
+
const componentName = getProcessedBlock({
|
|
460
|
+
block,
|
|
461
|
+
localState: context.localState,
|
|
462
|
+
rootState: context.rootState,
|
|
463
|
+
rootSetState: context.rootSetState,
|
|
464
|
+
context: context.context,
|
|
465
|
+
shouldEvaluateBindings: false
|
|
466
|
+
}).component?.name;
|
|
467
|
+
if (!componentName) {
|
|
468
|
+
return null;
|
|
469
|
+
}
|
|
470
|
+
const ref = registeredComponents[componentName];
|
|
471
|
+
if (!ref) {
|
|
472
|
+
return void 0;
|
|
473
|
+
} else {
|
|
474
|
+
return ref;
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
var getRepeatItemData = ({
|
|
478
|
+
block,
|
|
479
|
+
context
|
|
480
|
+
}) => {
|
|
481
|
+
const {
|
|
482
|
+
repeat,
|
|
483
|
+
...blockWithoutRepeat
|
|
484
|
+
} = block;
|
|
485
|
+
if (!repeat?.collection) {
|
|
486
|
+
return void 0;
|
|
487
|
+
}
|
|
488
|
+
const itemsArray = evaluate({
|
|
489
|
+
code: repeat.collection,
|
|
490
|
+
localState: context.localState,
|
|
491
|
+
rootState: context.rootState,
|
|
492
|
+
rootSetState: context.rootSetState,
|
|
493
|
+
context: context.context
|
|
494
|
+
});
|
|
495
|
+
if (!Array.isArray(itemsArray)) {
|
|
496
|
+
return void 0;
|
|
497
|
+
}
|
|
498
|
+
const collectionName = repeat.collection.split(".").pop();
|
|
499
|
+
const itemNameToUse = repeat.itemName || (collectionName ? collectionName + "Item" : "item");
|
|
500
|
+
const repeatArray = itemsArray.map((item, index) => ({
|
|
501
|
+
context: {
|
|
502
|
+
...context,
|
|
503
|
+
localState: {
|
|
504
|
+
...context.localState,
|
|
505
|
+
$index: index,
|
|
506
|
+
$item: item,
|
|
507
|
+
[itemNameToUse]: item,
|
|
508
|
+
[`$${itemNameToUse}Index`]: index
|
|
509
|
+
}
|
|
510
|
+
},
|
|
511
|
+
block: blockWithoutRepeat
|
|
512
|
+
}));
|
|
513
|
+
return repeatArray;
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
// src/constants/device-sizes.ts
|
|
517
|
+
var SIZES = {
|
|
518
|
+
small: {
|
|
519
|
+
min: 320,
|
|
520
|
+
default: 321,
|
|
521
|
+
max: 640
|
|
522
|
+
},
|
|
523
|
+
medium: {
|
|
524
|
+
min: 641,
|
|
525
|
+
default: 642,
|
|
526
|
+
max: 991
|
|
527
|
+
},
|
|
528
|
+
large: {
|
|
529
|
+
min: 990,
|
|
530
|
+
default: 991,
|
|
531
|
+
max: 1200
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
var getMaxWidthQueryForSize = (size, sizeValues = SIZES) => `@media (max-width: ${sizeValues[size].max}px)`;
|
|
535
|
+
var getSizesForBreakpoints = ({
|
|
536
|
+
small,
|
|
537
|
+
medium
|
|
538
|
+
}) => {
|
|
539
|
+
const newSizes = fastClone(SIZES);
|
|
540
|
+
if (!small || !medium) {
|
|
541
|
+
return newSizes;
|
|
542
|
+
}
|
|
543
|
+
const smallMin = Math.floor(small / 2);
|
|
544
|
+
newSizes.small = {
|
|
545
|
+
max: small,
|
|
546
|
+
min: smallMin,
|
|
547
|
+
default: smallMin + 1
|
|
548
|
+
};
|
|
549
|
+
const mediumMin = newSizes.small.max + 1;
|
|
550
|
+
newSizes.medium = {
|
|
551
|
+
max: medium,
|
|
552
|
+
min: mediumMin,
|
|
553
|
+
default: mediumMin + 1
|
|
554
|
+
};
|
|
555
|
+
const largeMin = newSizes.medium.max + 1;
|
|
556
|
+
newSizes.large = {
|
|
557
|
+
max: 2e3,
|
|
558
|
+
// TODO: decide upper limit
|
|
559
|
+
min: largeMin,
|
|
560
|
+
default: largeMin + 1
|
|
561
|
+
};
|
|
562
|
+
return newSizes;
|
|
563
|
+
};
|
|
564
|
+
|
|
565
|
+
// src/functions/camel-to-kebab-case.ts
|
|
505
566
|
var camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
506
567
|
|
|
507
|
-
// src/helpers/nullable.
|
|
568
|
+
// src/helpers/nullable.ts
|
|
508
569
|
var checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
|
|
509
570
|
|
|
510
|
-
// src/helpers/css.
|
|
571
|
+
// src/helpers/css.ts
|
|
511
572
|
var convertStyleMapToCSSArray = (style) => {
|
|
512
573
|
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
513
574
|
if (typeof value === "string") {
|
|
@@ -553,7 +614,7 @@ function InlinedStyles(props) {
|
|
|
553
614
|
}
|
|
554
615
|
var inlined_styles_default = InlinedStyles;
|
|
555
616
|
|
|
556
|
-
// src/components/block/components/block-styles.
|
|
617
|
+
// src/components/block/components/block-styles.tsx
|
|
557
618
|
function BlockStyles(props) {
|
|
558
619
|
function canShowBlock() {
|
|
559
620
|
const processedBlock = getProcessedBlock({
|
|
@@ -622,63 +683,50 @@ function BlockStyles(props) {
|
|
|
622
683
|
}
|
|
623
684
|
var block_styles_default = BlockStyles;
|
|
624
685
|
|
|
625
|
-
// src/functions/
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
var __getOwnPropDescs3 = Object.getOwnPropertyDescriptors;
|
|
629
|
-
var __getOwnPropSymbols3 = Object.getOwnPropertySymbols;
|
|
630
|
-
var __hasOwnProp3 = Object.prototype.hasOwnProperty;
|
|
631
|
-
var __propIsEnum3 = Object.prototype.propertyIsEnumerable;
|
|
632
|
-
var __defNormalProp3 = (obj, key, value) => key in obj ? __defProp3(obj, key, {
|
|
633
|
-
enumerable: true,
|
|
634
|
-
configurable: true,
|
|
635
|
-
writable: true,
|
|
636
|
-
value
|
|
637
|
-
}) : obj[key] = value;
|
|
638
|
-
var __spreadValues3 = (a, b) => {
|
|
639
|
-
for (var prop in b || (b = {}))
|
|
640
|
-
if (__hasOwnProp3.call(b, prop))
|
|
641
|
-
__defNormalProp3(a, prop, b[prop]);
|
|
642
|
-
if (__getOwnPropSymbols3)
|
|
643
|
-
for (var prop of __getOwnPropSymbols3(b)) {
|
|
644
|
-
if (__propIsEnum3.call(b, prop))
|
|
645
|
-
__defNormalProp3(a, prop, b[prop]);
|
|
646
|
-
}
|
|
647
|
-
return a;
|
|
648
|
-
};
|
|
649
|
-
var __spreadProps3 = (a, b) => __defProps3(a, __getOwnPropDescs3(b));
|
|
650
|
-
function getBlockComponentOptions(block) {
|
|
651
|
-
var _a;
|
|
652
|
-
return __spreadProps3(__spreadValues3(__spreadValues3({}, (_a = block.component) == null ? void 0 : _a.options), block.options), {
|
|
653
|
-
builderBlock: block
|
|
654
|
-
});
|
|
686
|
+
// src/functions/event-handler-name.ts
|
|
687
|
+
function capitalizeFirstLetter(string) {
|
|
688
|
+
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
655
689
|
}
|
|
690
|
+
var getEventHandlerName = (key) => `on${capitalizeFirstLetter(key)}`;
|
|
656
691
|
|
|
657
|
-
// src/functions/
|
|
658
|
-
var
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
for (var prop of __getOwnPropSymbols4(b)) {
|
|
676
|
-
if (__propIsEnum4.call(b, prop))
|
|
677
|
-
__defNormalProp4(a, prop, b[prop]);
|
|
692
|
+
// src/functions/get-block-actions-handler.ts
|
|
693
|
+
var createEventHandler = (value, options) => (event) => evaluate({
|
|
694
|
+
code: value,
|
|
695
|
+
context: options.context,
|
|
696
|
+
localState: options.localState,
|
|
697
|
+
rootState: options.rootState,
|
|
698
|
+
rootSetState: options.rootSetState,
|
|
699
|
+
event,
|
|
700
|
+
isExpression: false
|
|
701
|
+
});
|
|
702
|
+
|
|
703
|
+
// src/functions/get-block-actions.ts
|
|
704
|
+
function getBlockActions(options) {
|
|
705
|
+
const obj = {};
|
|
706
|
+
const optionActions = options.block.actions ?? {};
|
|
707
|
+
for (const key in optionActions) {
|
|
708
|
+
if (!optionActions.hasOwnProperty(key)) {
|
|
709
|
+
continue;
|
|
678
710
|
}
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
711
|
+
const value = optionActions[key];
|
|
712
|
+
let eventHandlerName = getEventHandlerName(key);
|
|
713
|
+
if (options.stripPrefix) {
|
|
714
|
+
switch (TARGET) {
|
|
715
|
+
case "vue2":
|
|
716
|
+
case "vue3":
|
|
717
|
+
eventHandlerName = eventHandlerName.replace("v-on:", "");
|
|
718
|
+
break;
|
|
719
|
+
case "svelte":
|
|
720
|
+
eventHandlerName = eventHandlerName.replace("on:", "");
|
|
721
|
+
break;
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
obj[eventHandlerName] = createEventHandler(value, options);
|
|
725
|
+
}
|
|
726
|
+
return obj;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
// src/functions/sanitize-react-native-block-styles.ts
|
|
682
730
|
var propertiesThatMustBeNumber = /* @__PURE__ */ new Set(["lineHeight"]);
|
|
683
731
|
var displayValues = /* @__PURE__ */ new Set(["flex", "none"]);
|
|
684
732
|
var normalizeNumber = (value) => {
|
|
@@ -705,46 +753,28 @@ var sanitizeReactNativeBlockStyles = (styles) => {
|
|
|
705
753
|
const newValue = parseFloat(propertyValue);
|
|
706
754
|
const normalizedValue = normalizeNumber(newValue);
|
|
707
755
|
if (normalizedValue) {
|
|
708
|
-
return
|
|
756
|
+
return {
|
|
757
|
+
...acc,
|
|
709
758
|
[key]: normalizedValue
|
|
710
|
-
}
|
|
759
|
+
};
|
|
711
760
|
} else {
|
|
712
761
|
return acc;
|
|
713
762
|
}
|
|
714
763
|
} else if (propertyValue === "0") {
|
|
715
|
-
return
|
|
764
|
+
return {
|
|
765
|
+
...acc,
|
|
716
766
|
[key]: 0
|
|
717
|
-
}
|
|
767
|
+
};
|
|
718
768
|
}
|
|
719
769
|
}
|
|
720
|
-
return
|
|
770
|
+
return {
|
|
771
|
+
...acc,
|
|
721
772
|
[key]: propertyValue
|
|
722
|
-
}
|
|
773
|
+
};
|
|
723
774
|
}, {});
|
|
724
775
|
};
|
|
725
776
|
|
|
726
|
-
// src/functions/get-react-native-block-styles.
|
|
727
|
-
var __defProp5 = Object.defineProperty;
|
|
728
|
-
var __getOwnPropSymbols5 = Object.getOwnPropertySymbols;
|
|
729
|
-
var __hasOwnProp5 = Object.prototype.hasOwnProperty;
|
|
730
|
-
var __propIsEnum5 = Object.prototype.propertyIsEnumerable;
|
|
731
|
-
var __defNormalProp5 = (obj, key, value) => key in obj ? __defProp5(obj, key, {
|
|
732
|
-
enumerable: true,
|
|
733
|
-
configurable: true,
|
|
734
|
-
writable: true,
|
|
735
|
-
value
|
|
736
|
-
}) : obj[key] = value;
|
|
737
|
-
var __spreadValues5 = (a, b) => {
|
|
738
|
-
for (var prop in b || (b = {}))
|
|
739
|
-
if (__hasOwnProp5.call(b, prop))
|
|
740
|
-
__defNormalProp5(a, prop, b[prop]);
|
|
741
|
-
if (__getOwnPropSymbols5)
|
|
742
|
-
for (var prop of __getOwnPropSymbols5(b)) {
|
|
743
|
-
if (__propIsEnum5.call(b, prop))
|
|
744
|
-
__defNormalProp5(a, prop, b[prop]);
|
|
745
|
-
}
|
|
746
|
-
return a;
|
|
747
|
-
};
|
|
777
|
+
// src/functions/get-react-native-block-styles.ts
|
|
748
778
|
function getReactNativeBlockStyles({
|
|
749
779
|
block,
|
|
750
780
|
context,
|
|
@@ -754,41 +784,24 @@ function getReactNativeBlockStyles({
|
|
|
754
784
|
if (!responsiveStyles) {
|
|
755
785
|
return {};
|
|
756
786
|
}
|
|
757
|
-
const styles =
|
|
787
|
+
const styles = {
|
|
788
|
+
// recursively apply inherited styles so that they can be passed down to children `Text` blocks
|
|
789
|
+
...context.inheritedStyles,
|
|
790
|
+
...responsiveStyles.large || {},
|
|
791
|
+
...responsiveStyles.medium || {},
|
|
792
|
+
...responsiveStyles.small || {},
|
|
793
|
+
...blockStyles
|
|
794
|
+
};
|
|
758
795
|
const newStyles = sanitizeReactNativeBlockStyles(styles);
|
|
759
796
|
return newStyles;
|
|
760
797
|
}
|
|
761
798
|
|
|
762
|
-
// src/functions/transform-block-properties.
|
|
799
|
+
// src/functions/transform-block-properties.ts
|
|
763
800
|
function transformBlockProperties(properties) {
|
|
764
801
|
return properties;
|
|
765
802
|
}
|
|
766
803
|
|
|
767
|
-
// src/functions/get-block-properties.
|
|
768
|
-
var __defProp6 = Object.defineProperty;
|
|
769
|
-
var __defProps5 = Object.defineProperties;
|
|
770
|
-
var __getOwnPropDescs5 = Object.getOwnPropertyDescriptors;
|
|
771
|
-
var __getOwnPropSymbols6 = Object.getOwnPropertySymbols;
|
|
772
|
-
var __hasOwnProp6 = Object.prototype.hasOwnProperty;
|
|
773
|
-
var __propIsEnum6 = Object.prototype.propertyIsEnumerable;
|
|
774
|
-
var __defNormalProp6 = (obj, key, value) => key in obj ? __defProp6(obj, key, {
|
|
775
|
-
enumerable: true,
|
|
776
|
-
configurable: true,
|
|
777
|
-
writable: true,
|
|
778
|
-
value
|
|
779
|
-
}) : obj[key] = value;
|
|
780
|
-
var __spreadValues6 = (a, b) => {
|
|
781
|
-
for (var prop in b || (b = {}))
|
|
782
|
-
if (__hasOwnProp6.call(b, prop))
|
|
783
|
-
__defNormalProp6(a, prop, b[prop]);
|
|
784
|
-
if (__getOwnPropSymbols6)
|
|
785
|
-
for (var prop of __getOwnPropSymbols6(b)) {
|
|
786
|
-
if (__propIsEnum6.call(b, prop))
|
|
787
|
-
__defNormalProp6(a, prop, b[prop]);
|
|
788
|
-
}
|
|
789
|
-
return a;
|
|
790
|
-
};
|
|
791
|
-
var __spreadProps5 = (a, b) => __defProps5(a, __getOwnPropDescs5(b));
|
|
804
|
+
// src/functions/get-block-properties.ts
|
|
792
805
|
var extractRelevantRootBlockProperties = (block) => {
|
|
793
806
|
return {
|
|
794
807
|
href: block.href
|
|
@@ -798,12 +811,13 @@ function getBlockProperties({
|
|
|
798
811
|
block,
|
|
799
812
|
context
|
|
800
813
|
}) {
|
|
801
|
-
|
|
802
|
-
|
|
814
|
+
const properties = {
|
|
815
|
+
...extractRelevantRootBlockProperties(block),
|
|
816
|
+
...block.properties,
|
|
803
817
|
"builder-id": block.id,
|
|
804
818
|
style: block.style ? getStyleAttribute(block.style) : void 0,
|
|
805
|
-
class: [block.id, "builder-block", block.class,
|
|
806
|
-
}
|
|
819
|
+
class: [block.id, "builder-block", block.class, block.properties?.class].filter(Boolean).join(" ")
|
|
820
|
+
};
|
|
807
821
|
if (TARGET === "reactNative") {
|
|
808
822
|
properties.style = getReactNativeBlockStyles({
|
|
809
823
|
block,
|
|
@@ -828,188 +842,52 @@ function getStyleAttribute(style) {
|
|
|
828
842
|
}
|
|
829
843
|
}
|
|
830
844
|
|
|
831
|
-
// src/components/block/block.
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
return a;
|
|
854
|
-
};
|
|
855
|
-
var __spreadProps6 = (a, b) => __defProps6(a, __getOwnPropDescs6(b));
|
|
856
|
-
var __objRest = (source, exclude) => {
|
|
857
|
-
var target = {};
|
|
858
|
-
for (var prop in source)
|
|
859
|
-
if (__hasOwnProp7.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
860
|
-
target[prop] = source[prop];
|
|
861
|
-
if (source != null && __getOwnPropSymbols7)
|
|
862
|
-
for (var prop of __getOwnPropSymbols7(source)) {
|
|
863
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum7.call(source, prop))
|
|
864
|
-
target[prop] = source[prop];
|
|
865
|
-
}
|
|
866
|
-
return target;
|
|
867
|
-
};
|
|
868
|
-
var EMPTY_HTML_ELEMENTS = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
|
|
869
|
-
var isEmptyHtmlElement = (tagName) => {
|
|
870
|
-
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
|
|
871
|
-
};
|
|
872
|
-
var getComponent = ({
|
|
873
|
-
block,
|
|
874
|
-
context,
|
|
875
|
-
registeredComponents
|
|
876
|
-
}) => {
|
|
877
|
-
var _a;
|
|
878
|
-
const componentName = (_a = getProcessedBlock({
|
|
879
|
-
block,
|
|
880
|
-
localState: context.localState,
|
|
881
|
-
rootState: context.rootState,
|
|
882
|
-
rootSetState: context.rootSetState,
|
|
883
|
-
context: context.context,
|
|
884
|
-
shouldEvaluateBindings: false
|
|
885
|
-
}).component) == null ? void 0 : _a.name;
|
|
886
|
-
if (!componentName) {
|
|
887
|
-
return null;
|
|
888
|
-
}
|
|
889
|
-
const ref = registeredComponents[componentName];
|
|
890
|
-
if (!ref) {
|
|
891
|
-
return void 0;
|
|
892
|
-
} else {
|
|
893
|
-
return ref;
|
|
894
|
-
}
|
|
895
|
-
};
|
|
896
|
-
var getRepeatItemData = ({
|
|
897
|
-
block,
|
|
898
|
-
context
|
|
899
|
-
}) => {
|
|
900
|
-
const _a = block, {
|
|
901
|
-
repeat
|
|
902
|
-
} = _a, blockWithoutRepeat = __objRest(_a, ["repeat"]);
|
|
903
|
-
if (!(repeat == null ? void 0 : repeat.collection)) {
|
|
904
|
-
return void 0;
|
|
905
|
-
}
|
|
906
|
-
const itemsArray = evaluate({
|
|
907
|
-
code: repeat.collection,
|
|
908
|
-
localState: context.localState,
|
|
909
|
-
rootState: context.rootState,
|
|
910
|
-
rootSetState: context.rootSetState,
|
|
911
|
-
context: context.context
|
|
912
|
-
});
|
|
913
|
-
if (!Array.isArray(itemsArray)) {
|
|
914
|
-
return void 0;
|
|
915
|
-
}
|
|
916
|
-
const collectionName = repeat.collection.split(".").pop();
|
|
917
|
-
const itemNameToUse = repeat.itemName || (collectionName ? collectionName + "Item" : "item");
|
|
918
|
-
const repeatArray = itemsArray.map((item, index) => ({
|
|
919
|
-
context: __spreadProps6(__spreadValues7({}, context), {
|
|
920
|
-
localState: __spreadProps6(__spreadValues7({}, context.localState), {
|
|
921
|
-
$index: index,
|
|
922
|
-
$item: item,
|
|
923
|
-
[itemNameToUse]: item,
|
|
924
|
-
[`$${itemNameToUse}Index`]: index
|
|
925
|
-
})
|
|
926
|
-
}),
|
|
927
|
-
block: blockWithoutRepeat
|
|
928
|
-
}));
|
|
929
|
-
return repeatArray;
|
|
930
|
-
};
|
|
931
|
-
var stdin_default = createContext({
|
|
932
|
-
content: null,
|
|
933
|
-
context: {},
|
|
934
|
-
localState: void 0,
|
|
935
|
-
rootSetState() {
|
|
936
|
-
},
|
|
937
|
-
rootState: {},
|
|
938
|
-
apiKey: null,
|
|
939
|
-
apiVersion: void 0,
|
|
940
|
-
componentInfos: {},
|
|
941
|
-
inheritedStyles: {}
|
|
942
|
-
});
|
|
943
|
-
|
|
944
|
-
// src/components/block/components/repeated-block.jsx
|
|
945
|
-
function RepeatedBlock(props) {
|
|
946
|
-
const [store, setStore] = createSignal(props.repeatContext);
|
|
947
|
-
return createComponent(stdin_default.Provider, {
|
|
948
|
-
get value() {
|
|
949
|
-
return store();
|
|
845
|
+
// src/components/block/components/block-wrapper.tsx
|
|
846
|
+
function BlockWrapper(props) {
|
|
847
|
+
return createComponent(Show, {
|
|
848
|
+
get fallback() {
|
|
849
|
+
return createComponent(Dynamic, mergeProps(() => getBlockProperties({
|
|
850
|
+
block: props.block,
|
|
851
|
+
context: props.context
|
|
852
|
+
}), () => getBlockActions({
|
|
853
|
+
block: props.block,
|
|
854
|
+
rootState: props.context.rootState,
|
|
855
|
+
rootSetState: props.context.rootSetState,
|
|
856
|
+
localState: props.context.localState,
|
|
857
|
+
context: props.context.context,
|
|
858
|
+
stripPrefix: true
|
|
859
|
+
}), {
|
|
860
|
+
get component() {
|
|
861
|
+
return props.Wrapper;
|
|
862
|
+
}
|
|
863
|
+
}));
|
|
864
|
+
},
|
|
865
|
+
get when() {
|
|
866
|
+
return props.hasChildren;
|
|
950
867
|
},
|
|
951
868
|
get children() {
|
|
952
|
-
return createComponent(
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
869
|
+
return createComponent(Dynamic, mergeProps(() => getBlockProperties({
|
|
870
|
+
block: props.block,
|
|
871
|
+
context: props.context
|
|
872
|
+
}), () => getBlockActions({
|
|
873
|
+
block: props.block,
|
|
874
|
+
rootState: props.context.rootState,
|
|
875
|
+
rootSetState: props.context.rootSetState,
|
|
876
|
+
localState: props.context.localState,
|
|
877
|
+
context: props.context.context,
|
|
878
|
+
stripPrefix: true
|
|
879
|
+
}), {
|
|
880
|
+
get component() {
|
|
881
|
+
return props.Wrapper;
|
|
958
882
|
},
|
|
959
|
-
get
|
|
960
|
-
return props.
|
|
883
|
+
get children() {
|
|
884
|
+
return props.children;
|
|
961
885
|
}
|
|
962
|
-
});
|
|
886
|
+
}));
|
|
963
887
|
}
|
|
964
888
|
});
|
|
965
889
|
}
|
|
966
|
-
var
|
|
967
|
-
|
|
968
|
-
// src/functions/event-handler-name.js
|
|
969
|
-
function capitalizeFirstLetter(string) {
|
|
970
|
-
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
971
|
-
}
|
|
972
|
-
var getEventHandlerName = (key) => `on${capitalizeFirstLetter(key)}`;
|
|
973
|
-
|
|
974
|
-
// src/functions/get-block-actions-handler.js
|
|
975
|
-
var createEventHandler = (value, options) => (event) => evaluate({
|
|
976
|
-
code: value,
|
|
977
|
-
context: options.context,
|
|
978
|
-
localState: options.localState,
|
|
979
|
-
rootState: options.rootState,
|
|
980
|
-
rootSetState: options.rootSetState,
|
|
981
|
-
event,
|
|
982
|
-
isExpression: false
|
|
983
|
-
});
|
|
984
|
-
|
|
985
|
-
// src/functions/get-block-actions.js
|
|
986
|
-
function getBlockActions(options) {
|
|
987
|
-
var _a;
|
|
988
|
-
const obj = {};
|
|
989
|
-
const optionActions = (_a = options.block.actions) != null ? _a : {};
|
|
990
|
-
for (const key in optionActions) {
|
|
991
|
-
if (!optionActions.hasOwnProperty(key)) {
|
|
992
|
-
continue;
|
|
993
|
-
}
|
|
994
|
-
const value = optionActions[key];
|
|
995
|
-
let eventHandlerName = getEventHandlerName(key);
|
|
996
|
-
if (options.stripPrefix) {
|
|
997
|
-
switch (TARGET) {
|
|
998
|
-
case "vue2":
|
|
999
|
-
case "vue3":
|
|
1000
|
-
eventHandlerName = eventHandlerName.replace("v-on:", "");
|
|
1001
|
-
break;
|
|
1002
|
-
case "svelte":
|
|
1003
|
-
eventHandlerName = eventHandlerName.replace("on:", "");
|
|
1004
|
-
break;
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
obj[eventHandlerName] = createEventHandler(value, options);
|
|
1008
|
-
}
|
|
1009
|
-
return obj;
|
|
1010
|
-
}
|
|
1011
|
-
|
|
1012
|
-
// src/components/block/components/interactive-element.jsx
|
|
890
|
+
var block_wrapper_default = BlockWrapper;
|
|
1013
891
|
function InteractiveElement(props) {
|
|
1014
892
|
return createComponent(Dynamic, mergeProps(() => props.wrapperProps, {
|
|
1015
893
|
get attributes() {
|
|
@@ -1037,28 +915,7 @@ function InteractiveElement(props) {
|
|
|
1037
915
|
}
|
|
1038
916
|
var interactive_element_default = InteractiveElement;
|
|
1039
917
|
|
|
1040
|
-
// src/components/block/components/component-ref/component-ref.helpers.
|
|
1041
|
-
var __defProp8 = Object.defineProperty;
|
|
1042
|
-
var __getOwnPropSymbols8 = Object.getOwnPropertySymbols;
|
|
1043
|
-
var __hasOwnProp8 = Object.prototype.hasOwnProperty;
|
|
1044
|
-
var __propIsEnum8 = Object.prototype.propertyIsEnumerable;
|
|
1045
|
-
var __defNormalProp8 = (obj, key, value) => key in obj ? __defProp8(obj, key, {
|
|
1046
|
-
enumerable: true,
|
|
1047
|
-
configurable: true,
|
|
1048
|
-
writable: true,
|
|
1049
|
-
value
|
|
1050
|
-
}) : obj[key] = value;
|
|
1051
|
-
var __spreadValues8 = (a, b) => {
|
|
1052
|
-
for (var prop in b || (b = {}))
|
|
1053
|
-
if (__hasOwnProp8.call(b, prop))
|
|
1054
|
-
__defNormalProp8(a, prop, b[prop]);
|
|
1055
|
-
if (__getOwnPropSymbols8)
|
|
1056
|
-
for (var prop of __getOwnPropSymbols8(b)) {
|
|
1057
|
-
if (__propIsEnum8.call(b, prop))
|
|
1058
|
-
__defNormalProp8(a, prop, b[prop]);
|
|
1059
|
-
}
|
|
1060
|
-
return a;
|
|
1061
|
-
};
|
|
918
|
+
// src/components/block/components/component-ref/component-ref.helpers.ts
|
|
1062
919
|
var getWrapperProps = ({
|
|
1063
920
|
componentOptions,
|
|
1064
921
|
builderBlock,
|
|
@@ -1074,15 +931,22 @@ var getWrapperProps = ({
|
|
|
1074
931
|
context,
|
|
1075
932
|
wrapperProps: componentOptions
|
|
1076
933
|
};
|
|
1077
|
-
return isInteractive ? interactiveElementProps :
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
934
|
+
return isInteractive ? interactiveElementProps : {
|
|
935
|
+
...componentOptions,
|
|
936
|
+
/**
|
|
937
|
+
* If `noWrap` is set to `true`, then the block's props/attributes are provided to the
|
|
938
|
+
* component itself directly. Otherwise, they are provided to the wrapper element.
|
|
939
|
+
*/
|
|
940
|
+
...includeBlockProps ? {
|
|
941
|
+
attributes: getBlockProperties({
|
|
942
|
+
block: builderBlock,
|
|
943
|
+
context: contextValue
|
|
944
|
+
})
|
|
945
|
+
} : {}
|
|
946
|
+
};
|
|
1083
947
|
};
|
|
1084
948
|
|
|
1085
|
-
// src/components/block/components/component-ref/component-ref.
|
|
949
|
+
// src/components/block/components/component-ref/component-ref.tsx
|
|
1086
950
|
function ComponentRef(props) {
|
|
1087
951
|
const [Wrapper, setWrapper] = createSignal(props.isInteractive ? interactive_element_default : props.componentRef);
|
|
1088
952
|
return createComponent(Show, {
|
|
@@ -1145,53 +1009,30 @@ function ComponentRef(props) {
|
|
|
1145
1009
|
});
|
|
1146
1010
|
}
|
|
1147
1011
|
var component_ref_default = ComponentRef;
|
|
1148
|
-
function
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
context: props.context
|
|
1154
|
-
}), () => getBlockActions({
|
|
1155
|
-
block: props.block,
|
|
1156
|
-
rootState: props.context.rootState,
|
|
1157
|
-
rootSetState: props.context.rootSetState,
|
|
1158
|
-
localState: props.context.localState,
|
|
1159
|
-
context: props.context.context,
|
|
1160
|
-
stripPrefix: true
|
|
1161
|
-
}), {
|
|
1162
|
-
get component() {
|
|
1163
|
-
return props.Wrapper;
|
|
1164
|
-
}
|
|
1165
|
-
}));
|
|
1166
|
-
},
|
|
1167
|
-
get when() {
|
|
1168
|
-
return props.hasChildren;
|
|
1012
|
+
function RepeatedBlock(props) {
|
|
1013
|
+
const [store, setStore] = createSignal(props.repeatContext);
|
|
1014
|
+
return createComponent(builder_context_default.Provider, {
|
|
1015
|
+
get value() {
|
|
1016
|
+
return store();
|
|
1169
1017
|
},
|
|
1170
1018
|
get children() {
|
|
1171
|
-
return createComponent(
|
|
1172
|
-
block
|
|
1173
|
-
|
|
1174
|
-
}), () => getBlockActions({
|
|
1175
|
-
block: props.block,
|
|
1176
|
-
rootState: props.context.rootState,
|
|
1177
|
-
rootSetState: props.context.rootSetState,
|
|
1178
|
-
localState: props.context.localState,
|
|
1179
|
-
context: props.context.context,
|
|
1180
|
-
stripPrefix: true
|
|
1181
|
-
}), {
|
|
1182
|
-
get component() {
|
|
1183
|
-
return props.Wrapper;
|
|
1019
|
+
return createComponent(block_default, {
|
|
1020
|
+
get block() {
|
|
1021
|
+
return props.block;
|
|
1184
1022
|
},
|
|
1185
|
-
get
|
|
1186
|
-
return
|
|
1023
|
+
get context() {
|
|
1024
|
+
return store();
|
|
1025
|
+
},
|
|
1026
|
+
get registeredComponents() {
|
|
1027
|
+
return props.registeredComponents;
|
|
1187
1028
|
}
|
|
1188
|
-
})
|
|
1029
|
+
});
|
|
1189
1030
|
}
|
|
1190
1031
|
});
|
|
1191
1032
|
}
|
|
1192
|
-
var
|
|
1033
|
+
var repeated_block_default = RepeatedBlock;
|
|
1193
1034
|
|
|
1194
|
-
// src/components/block/block.
|
|
1035
|
+
// src/components/block/block.tsx
|
|
1195
1036
|
function Block(props) {
|
|
1196
1037
|
const [childrenContext, setChildrenContext] = createSignal(props.context);
|
|
1197
1038
|
function blockComponent() {
|
|
@@ -1258,7 +1099,32 @@ function Block(props) {
|
|
|
1258
1099
|
get children() {
|
|
1259
1100
|
return createComponent(Show, {
|
|
1260
1101
|
get fallback() {
|
|
1261
|
-
return createComponent(component_ref_default,
|
|
1102
|
+
return createComponent(component_ref_default, {
|
|
1103
|
+
get componentRef() {
|
|
1104
|
+
return componentRefProps().componentRef;
|
|
1105
|
+
},
|
|
1106
|
+
get componentOptions() {
|
|
1107
|
+
return componentRefProps().componentOptions;
|
|
1108
|
+
},
|
|
1109
|
+
get blockChildren() {
|
|
1110
|
+
return componentRefProps().blockChildren;
|
|
1111
|
+
},
|
|
1112
|
+
get context() {
|
|
1113
|
+
return componentRefProps().context;
|
|
1114
|
+
},
|
|
1115
|
+
get registeredComponents() {
|
|
1116
|
+
return componentRefProps().registeredComponents;
|
|
1117
|
+
},
|
|
1118
|
+
get builderBlock() {
|
|
1119
|
+
return componentRefProps().builderBlock;
|
|
1120
|
+
},
|
|
1121
|
+
get includeBlockProps() {
|
|
1122
|
+
return componentRefProps().includeBlockProps;
|
|
1123
|
+
},
|
|
1124
|
+
get isInteractive() {
|
|
1125
|
+
return componentRefProps().isInteractive;
|
|
1126
|
+
}
|
|
1127
|
+
});
|
|
1262
1128
|
},
|
|
1263
1129
|
get when() {
|
|
1264
1130
|
return !blockComponent()?.noWrap;
|
|
@@ -1325,7 +1191,32 @@ function Block(props) {
|
|
|
1325
1191
|
},
|
|
1326
1192
|
hasChildren: true,
|
|
1327
1193
|
get children() {
|
|
1328
|
-
return [createComponent(component_ref_default,
|
|
1194
|
+
return [createComponent(component_ref_default, {
|
|
1195
|
+
get componentRef() {
|
|
1196
|
+
return componentRefProps().componentRef;
|
|
1197
|
+
},
|
|
1198
|
+
get componentOptions() {
|
|
1199
|
+
return componentRefProps().componentOptions;
|
|
1200
|
+
},
|
|
1201
|
+
get blockChildren() {
|
|
1202
|
+
return componentRefProps().blockChildren;
|
|
1203
|
+
},
|
|
1204
|
+
get context() {
|
|
1205
|
+
return componentRefProps().context;
|
|
1206
|
+
},
|
|
1207
|
+
get registeredComponents() {
|
|
1208
|
+
return componentRefProps().registeredComponents;
|
|
1209
|
+
},
|
|
1210
|
+
get builderBlock() {
|
|
1211
|
+
return componentRefProps().builderBlock;
|
|
1212
|
+
},
|
|
1213
|
+
get includeBlockProps() {
|
|
1214
|
+
return componentRefProps().includeBlockProps;
|
|
1215
|
+
},
|
|
1216
|
+
get isInteractive() {
|
|
1217
|
+
return componentRefProps().isInteractive;
|
|
1218
|
+
}
|
|
1219
|
+
}), createComponent(For, {
|
|
1329
1220
|
get each() {
|
|
1330
1221
|
return childrenWithoutParentComponent();
|
|
1331
1222
|
},
|
|
@@ -1427,12 +1318,11 @@ function BlocksWrapper(props) {
|
|
|
1427
1318
|
})();
|
|
1428
1319
|
}
|
|
1429
1320
|
var blocks_wrapper_default = BlocksWrapper;
|
|
1430
|
-
var stdin_default2 = createContext({ registeredComponents: {} });
|
|
1431
1321
|
|
|
1432
|
-
// src/components/blocks/blocks.
|
|
1322
|
+
// src/components/blocks/blocks.tsx
|
|
1433
1323
|
function Blocks(props) {
|
|
1434
|
-
const builderContext = useContext(
|
|
1435
|
-
const componentsContext = useContext(
|
|
1324
|
+
const builderContext = useContext(builder_context_default);
|
|
1325
|
+
const componentsContext = useContext(components_context_default);
|
|
1436
1326
|
return createComponent(blocks_wrapper_default, {
|
|
1437
1327
|
get blocks() {
|
|
1438
1328
|
return props.blocks;
|
|
@@ -1502,7 +1392,7 @@ function Blocks(props) {
|
|
|
1502
1392
|
}
|
|
1503
1393
|
var blocks_default = Blocks;
|
|
1504
1394
|
|
|
1505
|
-
// src/blocks/columns/columns.
|
|
1395
|
+
// src/blocks/columns/columns.tsx
|
|
1506
1396
|
var _tmpl$5 = /* @__PURE__ */ template(`<div>`);
|
|
1507
1397
|
function Columns(props) {
|
|
1508
1398
|
const [gutterSize, setGutterSize] = createSignal(typeof props.space === "number" ? props.space || 0 : 20);
|
|
@@ -1677,7 +1567,7 @@ function FragmentComponent(props) {
|
|
|
1677
1567
|
}
|
|
1678
1568
|
var fragment_default = FragmentComponent;
|
|
1679
1569
|
|
|
1680
|
-
// src/blocks/image/image.helpers.
|
|
1570
|
+
// src/blocks/image/image.helpers.ts
|
|
1681
1571
|
function removeProtocol(path) {
|
|
1682
1572
|
return path.replace(/http(s)?:/, "");
|
|
1683
1573
|
}
|
|
@@ -1690,7 +1580,7 @@ function updateQueryParam(uri = "", key, value) {
|
|
|
1690
1580
|
return uri + separator + key + "=" + encodeURIComponent(value);
|
|
1691
1581
|
}
|
|
1692
1582
|
function getShopifyImageUrl(src, size) {
|
|
1693
|
-
if (!src || !
|
|
1583
|
+
if (!src || !src?.match(/cdn\.shopify\.com/) || !size) {
|
|
1694
1584
|
return src;
|
|
1695
1585
|
}
|
|
1696
1586
|
if (size === "master") {
|
|
@@ -1724,9 +1614,9 @@ function getSrcSet(url) {
|
|
|
1724
1614
|
return url;
|
|
1725
1615
|
}
|
|
1726
1616
|
|
|
1727
|
-
// src/blocks/image/image.
|
|
1728
|
-
var _tmpl$7 = /* @__PURE__ */ template(`<source type=
|
|
1729
|
-
var _tmpl$22 = /* @__PURE__ */ template(`<picture><img loading=
|
|
1617
|
+
// src/blocks/image/image.tsx
|
|
1618
|
+
var _tmpl$7 = /* @__PURE__ */ template(`<source type=image/webp>`);
|
|
1619
|
+
var _tmpl$22 = /* @__PURE__ */ template(`<picture><img loading=lazy>`);
|
|
1730
1620
|
var _tmpl$32 = /* @__PURE__ */ template(`<div>`);
|
|
1731
1621
|
function Image(props) {
|
|
1732
1622
|
function srcSetToUse() {
|
|
@@ -1879,188 +1769,210 @@ function SectionComponent(props) {
|
|
|
1879
1769
|
}
|
|
1880
1770
|
var section_default = SectionComponent;
|
|
1881
1771
|
|
|
1882
|
-
// src/
|
|
1883
|
-
var
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
writable: true,
|
|
1893
|
-
value
|
|
1894
|
-
}) : obj[key] = value;
|
|
1895
|
-
var __spreadValues9 = (a, b) => {
|
|
1896
|
-
for (var prop in b || (b = {}))
|
|
1897
|
-
if (__hasOwnProp9.call(b, prop))
|
|
1898
|
-
__defNormalProp9(a, prop, b[prop]);
|
|
1899
|
-
if (__getOwnPropSymbols9)
|
|
1900
|
-
for (var prop of __getOwnPropSymbols9(b)) {
|
|
1901
|
-
if (__propIsEnum9.call(b, prop))
|
|
1902
|
-
__defNormalProp9(a, prop, b[prop]);
|
|
1903
|
-
}
|
|
1904
|
-
return a;
|
|
1772
|
+
// src/helpers/url.ts
|
|
1773
|
+
var getTopLevelDomain = (host) => {
|
|
1774
|
+
if (host === "localhost" || host === "127.0.0.1") {
|
|
1775
|
+
return host;
|
|
1776
|
+
}
|
|
1777
|
+
const parts = host.split(".");
|
|
1778
|
+
if (parts.length > 2) {
|
|
1779
|
+
return parts.slice(1).join(".");
|
|
1780
|
+
}
|
|
1781
|
+
return host;
|
|
1905
1782
|
};
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
var checkShouldRunVariants = ({
|
|
1912
|
-
canTrack,
|
|
1913
|
-
content
|
|
1783
|
+
|
|
1784
|
+
// src/helpers/cookie.ts
|
|
1785
|
+
var getCookieSync = ({
|
|
1786
|
+
name,
|
|
1787
|
+
canTrack
|
|
1914
1788
|
}) => {
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
if (!hasVariants)
|
|
1919
|
-
return false;
|
|
1920
|
-
if (!canTrack)
|
|
1921
|
-
return false;
|
|
1922
|
-
if (TARGET === "vue2" || TARGET === "vue3")
|
|
1923
|
-
return true;
|
|
1924
|
-
if (isBrowser())
|
|
1925
|
-
return false;
|
|
1926
|
-
return true;
|
|
1927
|
-
};
|
|
1928
|
-
function bldrAbTest(contentId, variants, isHydrationTarget2) {
|
|
1929
|
-
var _a;
|
|
1930
|
-
function getAndSetVariantId2() {
|
|
1931
|
-
function setCookie2(name, value, days) {
|
|
1932
|
-
let expires = "";
|
|
1933
|
-
if (days) {
|
|
1934
|
-
const date = /* @__PURE__ */ new Date();
|
|
1935
|
-
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1e3);
|
|
1936
|
-
expires = "; expires=" + date.toUTCString();
|
|
1937
|
-
}
|
|
1938
|
-
document.cookie = name + "=" + (value || "") + expires + "; path=/; Secure; SameSite=None";
|
|
1939
|
-
}
|
|
1940
|
-
function getCookie2(name) {
|
|
1941
|
-
const nameEQ = name + "=";
|
|
1942
|
-
const ca = document.cookie.split(";");
|
|
1943
|
-
for (let i = 0; i < ca.length; i++) {
|
|
1944
|
-
let c = ca[i];
|
|
1945
|
-
while (c.charAt(0) === " ")
|
|
1946
|
-
c = c.substring(1, c.length);
|
|
1947
|
-
if (c.indexOf(nameEQ) === 0)
|
|
1948
|
-
return c.substring(nameEQ.length, c.length);
|
|
1949
|
-
}
|
|
1950
|
-
return null;
|
|
1789
|
+
try {
|
|
1790
|
+
if (!canTrack) {
|
|
1791
|
+
return void 0;
|
|
1951
1792
|
}
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1793
|
+
return document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))?.split("=")[1];
|
|
1794
|
+
} catch (err) {
|
|
1795
|
+
logger.warn("[COOKIE] GET error: ", err?.message || err);
|
|
1796
|
+
return void 0;
|
|
1797
|
+
}
|
|
1798
|
+
};
|
|
1799
|
+
var getCookie = async (args) => getCookieSync(args);
|
|
1800
|
+
var stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).filter(checkIsDefined).join("; ");
|
|
1801
|
+
var SECURE_CONFIG = [["secure", ""], ["SameSite", "None"]];
|
|
1802
|
+
var createCookieString = ({
|
|
1803
|
+
name,
|
|
1804
|
+
value,
|
|
1805
|
+
expires
|
|
1806
|
+
}) => {
|
|
1807
|
+
const secure = isBrowser() ? location.protocol === "https:" : true;
|
|
1808
|
+
const secureObj = secure ? SECURE_CONFIG : [[]];
|
|
1809
|
+
const expiresObj = expires ? [["expires", expires.toUTCString()]] : [[]];
|
|
1810
|
+
const cookieValue = [[name, value], ...expiresObj, ["path", "/"], ["domain", getTopLevelDomain(window.location.hostname)], ...secureObj];
|
|
1811
|
+
const cookie = stringifyCookie(cookieValue);
|
|
1812
|
+
return cookie;
|
|
1813
|
+
};
|
|
1814
|
+
var setCookie = async ({
|
|
1815
|
+
name,
|
|
1816
|
+
value,
|
|
1817
|
+
expires,
|
|
1818
|
+
canTrack
|
|
1819
|
+
}) => {
|
|
1820
|
+
try {
|
|
1821
|
+
if (!canTrack) {
|
|
1822
|
+
return;
|
|
1957
1823
|
}
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1824
|
+
const cookie = createCookieString({
|
|
1825
|
+
name,
|
|
1826
|
+
value,
|
|
1827
|
+
expires
|
|
1828
|
+
});
|
|
1829
|
+
document.cookie = cookie;
|
|
1830
|
+
} catch (err) {
|
|
1831
|
+
logger.warn("[COOKIE] SET error: ", err?.message || err);
|
|
1832
|
+
}
|
|
1833
|
+
};
|
|
1834
|
+
|
|
1835
|
+
// src/helpers/ab-tests.ts
|
|
1836
|
+
var BUILDER_STORE_PREFIX = "builder.tests";
|
|
1837
|
+
var getContentTestKey = (id) => `${BUILDER_STORE_PREFIX}.${id}`;
|
|
1838
|
+
var getContentVariationCookie = ({
|
|
1839
|
+
contentId
|
|
1840
|
+
}) => getCookie({
|
|
1841
|
+
name: getContentTestKey(contentId),
|
|
1842
|
+
canTrack: true
|
|
1843
|
+
});
|
|
1844
|
+
var getContentVariationCookieSync = ({
|
|
1845
|
+
contentId
|
|
1846
|
+
}) => getCookieSync({
|
|
1847
|
+
name: getContentTestKey(contentId),
|
|
1848
|
+
canTrack: true
|
|
1849
|
+
});
|
|
1850
|
+
var setContentVariationCookie = ({
|
|
1851
|
+
contentId,
|
|
1852
|
+
value
|
|
1853
|
+
}) => setCookie({
|
|
1854
|
+
name: getContentTestKey(contentId),
|
|
1855
|
+
value,
|
|
1856
|
+
canTrack: true
|
|
1857
|
+
});
|
|
1858
|
+
var checkIsBuilderContentWithVariations = (item) => checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
|
|
1859
|
+
var getRandomVariationId = ({
|
|
1860
|
+
id,
|
|
1861
|
+
variations
|
|
1862
|
+
}) => {
|
|
1863
|
+
let n = 0;
|
|
1864
|
+
const random = Math.random();
|
|
1865
|
+
for (const id2 in variations) {
|
|
1866
|
+
const testRatio = variations[id2]?.testRatio;
|
|
1867
|
+
n += testRatio;
|
|
1868
|
+
if (random < n) {
|
|
1869
|
+
return id2;
|
|
1968
1870
|
}
|
|
1969
|
-
setCookie2(cookieName, contentId);
|
|
1970
|
-
return contentId;
|
|
1971
1871
|
}
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1872
|
+
return id;
|
|
1873
|
+
};
|
|
1874
|
+
var getAndSetVariantId = (args) => {
|
|
1875
|
+
const randomVariationId = getRandomVariationId(args);
|
|
1876
|
+
setContentVariationCookie({
|
|
1877
|
+
contentId: args.id,
|
|
1878
|
+
value: randomVariationId
|
|
1879
|
+
}).catch((err) => {
|
|
1880
|
+
logger.error("could not store A/B test variation: ", err);
|
|
1881
|
+
});
|
|
1882
|
+
return randomVariationId;
|
|
1883
|
+
};
|
|
1884
|
+
var getTestFields = ({
|
|
1885
|
+
item,
|
|
1886
|
+
testGroupId
|
|
1887
|
+
}) => {
|
|
1888
|
+
const variationValue = item.variations[testGroupId];
|
|
1889
|
+
if (testGroupId === item.id || // handle edge-case where `testGroupId` points to non-existing variation
|
|
1890
|
+
!variationValue) {
|
|
1891
|
+
return {
|
|
1892
|
+
testVariationId: item.id,
|
|
1893
|
+
testVariationName: "Default"
|
|
1894
|
+
};
|
|
1978
1895
|
} else {
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
}).join("");
|
|
1985
|
-
styleEl.innerHTML = newStyleStr;
|
|
1896
|
+
return {
|
|
1897
|
+
data: variationValue.data,
|
|
1898
|
+
testVariationId: variationValue.id,
|
|
1899
|
+
testVariationName: variationValue.name || (variationValue.id === item.id ? "Default" : "")
|
|
1900
|
+
};
|
|
1986
1901
|
}
|
|
1987
|
-
}
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1902
|
+
};
|
|
1903
|
+
var handleABTestingSync = ({
|
|
1904
|
+
item,
|
|
1905
|
+
canTrack
|
|
1906
|
+
}) => {
|
|
1907
|
+
if (TARGET === "reactNative")
|
|
1908
|
+
return item;
|
|
1909
|
+
if (!canTrack) {
|
|
1910
|
+
return item;
|
|
1992
1911
|
}
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
const ca = document.cookie.split(";");
|
|
1996
|
-
for (let i = 0; i < ca.length; i++) {
|
|
1997
|
-
let c = ca[i];
|
|
1998
|
-
while (c.charAt(0) === " ")
|
|
1999
|
-
c = c.substring(1, c.length);
|
|
2000
|
-
if (c.indexOf(nameEQ) === 0)
|
|
2001
|
-
return c.substring(nameEQ.length, c.length);
|
|
2002
|
-
}
|
|
2003
|
-
return null;
|
|
1912
|
+
if (!item) {
|
|
1913
|
+
return void 0;
|
|
2004
1914
|
}
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
const parentDiv = (_a = document.currentScript) == null ? void 0 : _a.parentElement;
|
|
2008
|
-
const variantIsDefaultContent = variantContentId === defaultContentId;
|
|
2009
|
-
if (variantId === variantContentId) {
|
|
2010
|
-
if (variantIsDefaultContent) {
|
|
2011
|
-
return;
|
|
2012
|
-
}
|
|
2013
|
-
parentDiv == null ? void 0 : parentDiv.removeAttribute("hidden");
|
|
2014
|
-
parentDiv == null ? void 0 : parentDiv.removeAttribute("aria-hidden");
|
|
2015
|
-
} else {
|
|
2016
|
-
if (variantIsDefaultContent) {
|
|
2017
|
-
if (isHydrationTarget2) {
|
|
2018
|
-
parentDiv == null ? void 0 : parentDiv.remove();
|
|
2019
|
-
} else {
|
|
2020
|
-
parentDiv == null ? void 0 : parentDiv.setAttribute("hidden", "true");
|
|
2021
|
-
parentDiv == null ? void 0 : parentDiv.setAttribute("aria-hidden", "true");
|
|
2022
|
-
}
|
|
2023
|
-
}
|
|
2024
|
-
return;
|
|
1915
|
+
if (!checkIsBuilderContentWithVariations(item)) {
|
|
1916
|
+
return item;
|
|
2025
1917
|
}
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
};
|
|
2040
|
-
var getVariantsScriptString = (variants, contentId) => {
|
|
2041
|
-
return `
|
|
2042
|
-
window.${AB_TEST_FN_NAME}("${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget})`;
|
|
1918
|
+
const testGroupId = getContentVariationCookieSync({
|
|
1919
|
+
contentId: item.id
|
|
1920
|
+
}) || getAndSetVariantId({
|
|
1921
|
+
variations: item.variations,
|
|
1922
|
+
id: item.id
|
|
1923
|
+
});
|
|
1924
|
+
const variationValue = getTestFields({
|
|
1925
|
+
item,
|
|
1926
|
+
testGroupId
|
|
1927
|
+
});
|
|
1928
|
+
return {
|
|
1929
|
+
...item,
|
|
1930
|
+
...variationValue
|
|
1931
|
+
};
|
|
2043
1932
|
};
|
|
2044
|
-
var
|
|
2045
|
-
|
|
2046
|
-
|
|
1933
|
+
var handleABTesting = async ({
|
|
1934
|
+
item,
|
|
1935
|
+
canTrack
|
|
2047
1936
|
}) => {
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
}
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
1937
|
+
if (!canTrack) {
|
|
1938
|
+
return item;
|
|
1939
|
+
}
|
|
1940
|
+
if (!checkIsBuilderContentWithVariations(item)) {
|
|
1941
|
+
return item;
|
|
1942
|
+
}
|
|
1943
|
+
const cookieValue = await getContentVariationCookie({
|
|
1944
|
+
contentId: item.id
|
|
1945
|
+
});
|
|
1946
|
+
const testGroupId = cookieValue || getAndSetVariantId({
|
|
1947
|
+
variations: item.variations,
|
|
1948
|
+
id: item.id
|
|
1949
|
+
});
|
|
1950
|
+
const variationValue = getTestFields({
|
|
1951
|
+
item,
|
|
1952
|
+
testGroupId
|
|
1953
|
+
});
|
|
1954
|
+
return {
|
|
1955
|
+
...item,
|
|
1956
|
+
...variationValue
|
|
1957
|
+
};
|
|
1958
|
+
};
|
|
1959
|
+
|
|
1960
|
+
// src/helpers/canTrack.ts
|
|
1961
|
+
var getDefaultCanTrack = (canTrack) => checkIsDefined(canTrack) ? canTrack : true;
|
|
1962
|
+
|
|
1963
|
+
// src/blocks/button/component-info.ts
|
|
1964
|
+
var componentInfo = {
|
|
1965
|
+
name: "Core:Button",
|
|
1966
|
+
image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13",
|
|
1967
|
+
defaultStyles: {
|
|
1968
|
+
// TODO: make min width more intuitive and set one
|
|
1969
|
+
appearance: "none",
|
|
1970
|
+
paddingTop: "15px",
|
|
1971
|
+
paddingBottom: "15px",
|
|
1972
|
+
paddingLeft: "25px",
|
|
1973
|
+
paddingRight: "25px",
|
|
1974
|
+
backgroundColor: "#000000",
|
|
1975
|
+
color: "white",
|
|
2064
1976
|
borderRadius: "4px",
|
|
2065
1977
|
textAlign: "center",
|
|
2066
1978
|
cursor: "pointer"
|
|
@@ -2084,8 +1996,9 @@ var componentInfo = {
|
|
|
2084
1996
|
noWrap: true
|
|
2085
1997
|
};
|
|
2086
1998
|
|
|
2087
|
-
// src/blocks/columns/component-info.
|
|
1999
|
+
// src/blocks/columns/component-info.ts
|
|
2088
2000
|
var componentInfo2 = {
|
|
2001
|
+
// TODO: ways to statically preprocess JSON for references, functions, etc
|
|
2089
2002
|
name: "Columns",
|
|
2090
2003
|
isRSC: true,
|
|
2091
2004
|
inputs: [{
|
|
@@ -2303,8 +2216,170 @@ var componentInfo2 = {
|
|
|
2303
2216
|
}]
|
|
2304
2217
|
};
|
|
2305
2218
|
|
|
2306
|
-
// src/blocks/
|
|
2219
|
+
// src/blocks/custom-code/component-info.ts
|
|
2307
2220
|
var componentInfo3 = {
|
|
2221
|
+
name: "Custom Code",
|
|
2222
|
+
static: true,
|
|
2223
|
+
requiredPermissions: ["editCode"],
|
|
2224
|
+
inputs: [{
|
|
2225
|
+
name: "code",
|
|
2226
|
+
type: "html",
|
|
2227
|
+
required: true,
|
|
2228
|
+
defaultValue: "<p>Hello there, I am custom HTML code!</p>",
|
|
2229
|
+
code: true
|
|
2230
|
+
}, {
|
|
2231
|
+
name: "replaceNodes",
|
|
2232
|
+
type: "boolean",
|
|
2233
|
+
helperText: "Preserve server rendered dom nodes",
|
|
2234
|
+
advanced: true
|
|
2235
|
+
}, {
|
|
2236
|
+
name: "scriptsClientOnly",
|
|
2237
|
+
type: "boolean",
|
|
2238
|
+
defaultValue: false,
|
|
2239
|
+
helperText: "Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads",
|
|
2240
|
+
advanced: true
|
|
2241
|
+
}]
|
|
2242
|
+
};
|
|
2243
|
+
var _tmpl$9 = /* @__PURE__ */ template(`<div>`);
|
|
2244
|
+
function CustomCode(props) {
|
|
2245
|
+
const [scriptsInserted, setScriptsInserted] = createSignal([]);
|
|
2246
|
+
const [scriptsRun, setScriptsRun] = createSignal([]);
|
|
2247
|
+
let elementRef;
|
|
2248
|
+
onMount(() => {
|
|
2249
|
+
if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
|
|
2250
|
+
return;
|
|
2251
|
+
}
|
|
2252
|
+
const scripts = elementRef.getElementsByTagName("script");
|
|
2253
|
+
for (let i = 0; i < scripts.length; i++) {
|
|
2254
|
+
const script = scripts[i];
|
|
2255
|
+
if (script.src) {
|
|
2256
|
+
if (scriptsInserted().includes(script.src)) {
|
|
2257
|
+
continue;
|
|
2258
|
+
}
|
|
2259
|
+
scriptsInserted().push(script.src);
|
|
2260
|
+
const newScript = document.createElement("script");
|
|
2261
|
+
newScript.async = true;
|
|
2262
|
+
newScript.src = script.src;
|
|
2263
|
+
document.head.appendChild(newScript);
|
|
2264
|
+
} else if (!script.type || ["text/javascript", "application/javascript", "application/ecmascript"].includes(script.type)) {
|
|
2265
|
+
if (scriptsRun().includes(script.innerText)) {
|
|
2266
|
+
continue;
|
|
2267
|
+
}
|
|
2268
|
+
try {
|
|
2269
|
+
scriptsRun().push(script.innerText);
|
|
2270
|
+
new Function(script.innerText)();
|
|
2271
|
+
} catch (error) {
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2275
|
+
});
|
|
2276
|
+
return (() => {
|
|
2277
|
+
const _el$ = _tmpl$9();
|
|
2278
|
+
const _ref$ = elementRef;
|
|
2279
|
+
typeof _ref$ === "function" ? use(_ref$, _el$) : elementRef = _el$;
|
|
2280
|
+
effect((_p$) => {
|
|
2281
|
+
const _v$ = "builder-custom-code" + (props.replaceNodes ? " replace-nodes" : ""), _v$2 = props.code;
|
|
2282
|
+
_v$ !== _p$._v$ && className(_el$, _p$._v$ = _v$);
|
|
2283
|
+
_v$2 !== _p$._v$2 && (_el$.innerHTML = _p$._v$2 = _v$2);
|
|
2284
|
+
return _p$;
|
|
2285
|
+
}, {
|
|
2286
|
+
_v$: void 0,
|
|
2287
|
+
_v$2: void 0
|
|
2288
|
+
});
|
|
2289
|
+
return _el$;
|
|
2290
|
+
})();
|
|
2291
|
+
}
|
|
2292
|
+
var custom_code_default = CustomCode;
|
|
2293
|
+
|
|
2294
|
+
// src/blocks/embed/component-info.ts
|
|
2295
|
+
var componentInfo4 = {
|
|
2296
|
+
name: "Embed",
|
|
2297
|
+
static: true,
|
|
2298
|
+
inputs: [{
|
|
2299
|
+
name: "url",
|
|
2300
|
+
type: "url",
|
|
2301
|
+
required: true,
|
|
2302
|
+
defaultValue: "",
|
|
2303
|
+
helperText: "e.g. enter a youtube url, google map, etc",
|
|
2304
|
+
onChange: (options) => {
|
|
2305
|
+
const url = options.get("url");
|
|
2306
|
+
if (url) {
|
|
2307
|
+
options.set("content", "Loading...");
|
|
2308
|
+
const apiKey = "ae0e60e78201a3f2b0de4b";
|
|
2309
|
+
return fetch(`https://iframe.ly/api/iframely?url=${url}&api_key=${apiKey}`).then((res) => res.json()).then((data) => {
|
|
2310
|
+
if (options.get("url") === url) {
|
|
2311
|
+
if (data.html) {
|
|
2312
|
+
options.set("content", data.html);
|
|
2313
|
+
} else {
|
|
2314
|
+
options.set("content", "Invalid url, please try another");
|
|
2315
|
+
}
|
|
2316
|
+
}
|
|
2317
|
+
}).catch((_err) => {
|
|
2318
|
+
options.set("content", "There was an error embedding this URL, please try again or another URL");
|
|
2319
|
+
});
|
|
2320
|
+
} else {
|
|
2321
|
+
options.delete("content");
|
|
2322
|
+
}
|
|
2323
|
+
}
|
|
2324
|
+
}, {
|
|
2325
|
+
name: "content",
|
|
2326
|
+
type: "html",
|
|
2327
|
+
defaultValue: '<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',
|
|
2328
|
+
hideFromUI: true
|
|
2329
|
+
}]
|
|
2330
|
+
};
|
|
2331
|
+
|
|
2332
|
+
// src/blocks/embed/helpers.ts
|
|
2333
|
+
var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
|
|
2334
|
+
var isJsScript = (script) => SCRIPT_MIME_TYPES.includes(script.type);
|
|
2335
|
+
|
|
2336
|
+
// src/blocks/embed/embed.tsx
|
|
2337
|
+
var _tmpl$10 = /* @__PURE__ */ template(`<div class=builder-embed>`);
|
|
2338
|
+
function Embed(props) {
|
|
2339
|
+
const [scriptsInserted, setScriptsInserted] = createSignal([]);
|
|
2340
|
+
const [scriptsRun, setScriptsRun] = createSignal([]);
|
|
2341
|
+
const [ranInitFn, setRanInitFn] = createSignal(false);
|
|
2342
|
+
function findAndRunScripts() {
|
|
2343
|
+
if (!elem || !elem.getElementsByTagName)
|
|
2344
|
+
return;
|
|
2345
|
+
const scripts = elem.getElementsByTagName("script");
|
|
2346
|
+
for (let i = 0; i < scripts.length; i++) {
|
|
2347
|
+
const script = scripts[i];
|
|
2348
|
+
if (script.src && !scriptsInserted().includes(script.src)) {
|
|
2349
|
+
scriptsInserted().push(script.src);
|
|
2350
|
+
const newScript = document.createElement("script");
|
|
2351
|
+
newScript.async = true;
|
|
2352
|
+
newScript.src = script.src;
|
|
2353
|
+
document.head.appendChild(newScript);
|
|
2354
|
+
} else if (isJsScript(script) && !scriptsRun().includes(script.innerText)) {
|
|
2355
|
+
try {
|
|
2356
|
+
scriptsRun().push(script.innerText);
|
|
2357
|
+
new Function(script.innerText)();
|
|
2358
|
+
} catch (error) {
|
|
2359
|
+
}
|
|
2360
|
+
}
|
|
2361
|
+
}
|
|
2362
|
+
}
|
|
2363
|
+
let elem;
|
|
2364
|
+
function onUpdateFn_0() {
|
|
2365
|
+
if (elem && !ranInitFn()) {
|
|
2366
|
+
setRanInitFn(true);
|
|
2367
|
+
findAndRunScripts();
|
|
2368
|
+
}
|
|
2369
|
+
}
|
|
2370
|
+
createEffect(on(() => [elem, ranInitFn()], onUpdateFn_0));
|
|
2371
|
+
return (() => {
|
|
2372
|
+
const _el$ = _tmpl$10();
|
|
2373
|
+
const _ref$ = elem;
|
|
2374
|
+
typeof _ref$ === "function" ? use(_ref$, _el$) : elem = _el$;
|
|
2375
|
+
effect(() => _el$.innerHTML = props.content);
|
|
2376
|
+
return _el$;
|
|
2377
|
+
})();
|
|
2378
|
+
}
|
|
2379
|
+
var embed_default = Embed;
|
|
2380
|
+
|
|
2381
|
+
// src/blocks/fragment/component-info.ts
|
|
2382
|
+
var componentInfo5 = {
|
|
2308
2383
|
name: "Fragment",
|
|
2309
2384
|
static: true,
|
|
2310
2385
|
hidden: true,
|
|
@@ -2312,8 +2387,8 @@ var componentInfo3 = {
|
|
|
2312
2387
|
noWrap: true
|
|
2313
2388
|
};
|
|
2314
2389
|
|
|
2315
|
-
// src/blocks/image/component-info.
|
|
2316
|
-
var
|
|
2390
|
+
// src/blocks/image/component-info.ts
|
|
2391
|
+
var componentInfo6 = {
|
|
2317
2392
|
name: "Image",
|
|
2318
2393
|
static: true,
|
|
2319
2394
|
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",
|
|
@@ -2434,8 +2509,50 @@ var componentInfo4 = {
|
|
|
2434
2509
|
}]
|
|
2435
2510
|
};
|
|
2436
2511
|
|
|
2437
|
-
// src/blocks/
|
|
2438
|
-
var
|
|
2512
|
+
// src/blocks/img/component-info.ts
|
|
2513
|
+
var componentInfo7 = {
|
|
2514
|
+
// friendlyName?
|
|
2515
|
+
name: "Raw:Img",
|
|
2516
|
+
hideFromInsertMenu: true,
|
|
2517
|
+
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",
|
|
2518
|
+
inputs: [{
|
|
2519
|
+
name: "image",
|
|
2520
|
+
bubble: true,
|
|
2521
|
+
type: "file",
|
|
2522
|
+
allowedFileTypes: ["jpeg", "jpg", "png", "svg", "gif", "webp"],
|
|
2523
|
+
required: true
|
|
2524
|
+
}],
|
|
2525
|
+
noWrap: true,
|
|
2526
|
+
static: true
|
|
2527
|
+
};
|
|
2528
|
+
var _tmpl$11 = /* @__PURE__ */ template(`<img>`);
|
|
2529
|
+
function ImgComponent(props) {
|
|
2530
|
+
return (() => {
|
|
2531
|
+
const _el$ = _tmpl$11();
|
|
2532
|
+
spread(_el$, mergeProps({
|
|
2533
|
+
get style() {
|
|
2534
|
+
return {
|
|
2535
|
+
"object-fit": props.backgroundSize || "cover",
|
|
2536
|
+
"object-position": props.backgroundPosition || "center"
|
|
2537
|
+
};
|
|
2538
|
+
},
|
|
2539
|
+
get key() {
|
|
2540
|
+
return isEditing() && props.imgSrc || "default-key";
|
|
2541
|
+
},
|
|
2542
|
+
get alt() {
|
|
2543
|
+
return props.altText;
|
|
2544
|
+
},
|
|
2545
|
+
get src() {
|
|
2546
|
+
return props.imgSrc || props.image;
|
|
2547
|
+
}
|
|
2548
|
+
}, {}, () => props.attributes), false, false);
|
|
2549
|
+
return _el$;
|
|
2550
|
+
})();
|
|
2551
|
+
}
|
|
2552
|
+
var img_default = ImgComponent;
|
|
2553
|
+
|
|
2554
|
+
// src/blocks/section/component-info.ts
|
|
2555
|
+
var componentInfo8 = {
|
|
2439
2556
|
name: "Core:Section",
|
|
2440
2557
|
static: true,
|
|
2441
2558
|
image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F682efef23ace49afac61748dd305c70a",
|
|
@@ -2476,8 +2593,8 @@ var componentInfo5 = {
|
|
|
2476
2593
|
}]
|
|
2477
2594
|
};
|
|
2478
2595
|
|
|
2479
|
-
// src/blocks/symbol/component-info.
|
|
2480
|
-
var
|
|
2596
|
+
// src/blocks/symbol/component-info.ts
|
|
2597
|
+
var componentInfo9 = {
|
|
2481
2598
|
name: "Symbol",
|
|
2482
2599
|
noWrap: true,
|
|
2483
2600
|
static: true,
|
|
@@ -2512,8 +2629,8 @@ var componentInfo6 = {
|
|
|
2512
2629
|
}]
|
|
2513
2630
|
};
|
|
2514
2631
|
|
|
2515
|
-
// src/blocks/text/component-info.
|
|
2516
|
-
var
|
|
2632
|
+
// src/blocks/text/component-info.ts
|
|
2633
|
+
var componentInfo10 = {
|
|
2517
2634
|
name: "Text",
|
|
2518
2635
|
static: true,
|
|
2519
2636
|
isRSC: true,
|
|
@@ -2532,10 +2649,10 @@ var componentInfo7 = {
|
|
|
2532
2649
|
textAlign: "center"
|
|
2533
2650
|
}
|
|
2534
2651
|
};
|
|
2535
|
-
var _tmpl$
|
|
2652
|
+
var _tmpl$12 = /* @__PURE__ */ template(`<div class=builder-text>`);
|
|
2536
2653
|
function Text(props) {
|
|
2537
2654
|
return (() => {
|
|
2538
|
-
const _el$ = _tmpl$
|
|
2655
|
+
const _el$ = _tmpl$12();
|
|
2539
2656
|
_el$.style.setProperty("outline", "none");
|
|
2540
2657
|
effect(() => _el$.innerHTML = props.text?.toString() || "");
|
|
2541
2658
|
return _el$;
|
|
@@ -2543,8 +2660,8 @@ function Text(props) {
|
|
|
2543
2660
|
}
|
|
2544
2661
|
var text_default = Text;
|
|
2545
2662
|
|
|
2546
|
-
// src/blocks/video/component-info.
|
|
2547
|
-
var
|
|
2663
|
+
// src/blocks/video/component-info.ts
|
|
2664
|
+
var componentInfo11 = {
|
|
2548
2665
|
name: "Video",
|
|
2549
2666
|
canHaveChildren: true,
|
|
2550
2667
|
defaultStyles: {
|
|
@@ -2626,7 +2743,7 @@ var componentInfo8 = {
|
|
|
2626
2743
|
advanced: true
|
|
2627
2744
|
}]
|
|
2628
2745
|
};
|
|
2629
|
-
var _tmpl$
|
|
2746
|
+
var _tmpl$13 = /* @__PURE__ */ template(`<video>`);
|
|
2630
2747
|
function Video(props) {
|
|
2631
2748
|
function videoProps() {
|
|
2632
2749
|
return {
|
|
@@ -2644,1262 +2761,318 @@ function Video(props) {
|
|
|
2644
2761
|
} : {},
|
|
2645
2762
|
...props.playsInline === true ? {
|
|
2646
2763
|
playsInline: true
|
|
2647
|
-
} : {}
|
|
2648
|
-
};
|
|
2649
|
-
}
|
|
2650
|
-
function spreadProps() {
|
|
2651
|
-
return {
|
|
2652
|
-
...props.attributes,
|
|
2653
|
-
...videoProps()
|
|
2654
|
-
};
|
|
2655
|
-
}
|
|
2656
|
-
return (() => {
|
|
2657
|
-
const _el$ = _tmpl$10();
|
|
2658
|
-
spread(_el$, mergeProps(spreadProps, {
|
|
2659
|
-
get preload() {
|
|
2660
|
-
return props.preload || "metadata";
|
|
2661
|
-
},
|
|
2662
|
-
get style() {
|
|
2663
|
-
return {
|
|
2664
|
-
width: "100%",
|
|
2665
|
-
height: "100%",
|
|
2666
|
-
...props.attributes?.style,
|
|
2667
|
-
"object-fit": props.fit,
|
|
2668
|
-
"object-position": props.position,
|
|
2669
|
-
// Hack to get object fit to work as expected and
|
|
2670
|
-
// not have the video overflow
|
|
2671
|
-
"border-radius": 1
|
|
2672
|
-
};
|
|
2673
|
-
},
|
|
2674
|
-
get src() {
|
|
2675
|
-
return props.video || "no-src";
|
|
2676
|
-
},
|
|
2677
|
-
get poster() {
|
|
2678
|
-
return props.posterImage;
|
|
2679
|
-
}
|
|
2680
|
-
}), false, false);
|
|
2681
|
-
return _el$;
|
|
2682
|
-
})();
|
|
2683
|
-
}
|
|
2684
|
-
var video_default = Video;
|
|
2685
|
-
|
|
2686
|
-
// src/blocks/embed/component-info.js
|
|
2687
|
-
var componentInfo9 = {
|
|
2688
|
-
name: "Embed",
|
|
2689
|
-
static: true,
|
|
2690
|
-
inputs: [{
|
|
2691
|
-
name: "url",
|
|
2692
|
-
type: "url",
|
|
2693
|
-
required: true,
|
|
2694
|
-
defaultValue: "",
|
|
2695
|
-
helperText: "e.g. enter a youtube url, google map, etc",
|
|
2696
|
-
onChange: (options) => {
|
|
2697
|
-
const url = options.get("url");
|
|
2698
|
-
if (url) {
|
|
2699
|
-
options.set("content", "Loading...");
|
|
2700
|
-
const apiKey = "ae0e60e78201a3f2b0de4b";
|
|
2701
|
-
return fetch(`https://iframe.ly/api/iframely?url=${url}&api_key=${apiKey}`).then((res) => res.json()).then((data) => {
|
|
2702
|
-
if (options.get("url") === url) {
|
|
2703
|
-
if (data.html) {
|
|
2704
|
-
options.set("content", data.html);
|
|
2705
|
-
} else {
|
|
2706
|
-
options.set("content", "Invalid url, please try another");
|
|
2707
|
-
}
|
|
2708
|
-
}
|
|
2709
|
-
}).catch((_err) => {
|
|
2710
|
-
options.set("content", "There was an error embedding this URL, please try again or another URL");
|
|
2711
|
-
});
|
|
2712
|
-
} else {
|
|
2713
|
-
options.delete("content");
|
|
2714
|
-
}
|
|
2715
|
-
}
|
|
2716
|
-
}, {
|
|
2717
|
-
name: "content",
|
|
2718
|
-
type: "html",
|
|
2719
|
-
defaultValue: '<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',
|
|
2720
|
-
hideFromUI: true
|
|
2721
|
-
}]
|
|
2722
|
-
};
|
|
2723
|
-
|
|
2724
|
-
// src/blocks/embed/helpers.js
|
|
2725
|
-
var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
|
|
2726
|
-
var isJsScript = (script) => SCRIPT_MIME_TYPES.includes(script.type);
|
|
2727
|
-
|
|
2728
|
-
// src/blocks/embed/embed.jsx
|
|
2729
|
-
var _tmpl$11 = /* @__PURE__ */ template(`<div class="builder-embed">`);
|
|
2730
|
-
function Embed(props) {
|
|
2731
|
-
const [scriptsInserted, setScriptsInserted] = createSignal([]);
|
|
2732
|
-
const [scriptsRun, setScriptsRun] = createSignal([]);
|
|
2733
|
-
const [ranInitFn, setRanInitFn] = createSignal(false);
|
|
2734
|
-
function findAndRunScripts() {
|
|
2735
|
-
if (!elem || !elem.getElementsByTagName)
|
|
2736
|
-
return;
|
|
2737
|
-
const scripts = elem.getElementsByTagName("script");
|
|
2738
|
-
for (let i = 0; i < scripts.length; i++) {
|
|
2739
|
-
const script = scripts[i];
|
|
2740
|
-
if (script.src && !scriptsInserted().includes(script.src)) {
|
|
2741
|
-
scriptsInserted().push(script.src);
|
|
2742
|
-
const newScript = document.createElement("script");
|
|
2743
|
-
newScript.async = true;
|
|
2744
|
-
newScript.src = script.src;
|
|
2745
|
-
document.head.appendChild(newScript);
|
|
2746
|
-
} else if (isJsScript(script) && !scriptsRun().includes(script.innerText)) {
|
|
2747
|
-
try {
|
|
2748
|
-
scriptsRun().push(script.innerText);
|
|
2749
|
-
new Function(script.innerText)();
|
|
2750
|
-
} catch (error) {
|
|
2751
|
-
}
|
|
2752
|
-
}
|
|
2753
|
-
}
|
|
2754
|
-
}
|
|
2755
|
-
let elem;
|
|
2756
|
-
function onUpdateFn_0() {
|
|
2757
|
-
if (elem && !ranInitFn()) {
|
|
2758
|
-
setRanInitFn(true);
|
|
2759
|
-
findAndRunScripts();
|
|
2760
|
-
}
|
|
2761
|
-
}
|
|
2762
|
-
createEffect(on(() => [elem, ranInitFn()], onUpdateFn_0));
|
|
2763
|
-
return (() => {
|
|
2764
|
-
const _el$ = _tmpl$11();
|
|
2765
|
-
const _ref$ = elem;
|
|
2766
|
-
typeof _ref$ === "function" ? use(_ref$, _el$) : elem = _el$;
|
|
2767
|
-
effect(() => _el$.innerHTML = props.content);
|
|
2768
|
-
return _el$;
|
|
2769
|
-
})();
|
|
2770
|
-
}
|
|
2771
|
-
var embed_default = Embed;
|
|
2772
|
-
var _tmpl$12 = /* @__PURE__ */ template(`<img>`);
|
|
2773
|
-
function ImgComponent(props) {
|
|
2774
|
-
return (() => {
|
|
2775
|
-
const _el$ = _tmpl$12();
|
|
2776
|
-
spread(_el$, mergeProps({
|
|
2777
|
-
get style() {
|
|
2778
|
-
return {
|
|
2779
|
-
"object-fit": props.backgroundSize || "cover",
|
|
2780
|
-
"object-position": props.backgroundPosition || "center"
|
|
2781
|
-
};
|
|
2782
|
-
},
|
|
2783
|
-
get key() {
|
|
2784
|
-
return isEditing() && props.imgSrc || "default-key";
|
|
2785
|
-
},
|
|
2786
|
-
get alt() {
|
|
2787
|
-
return props.altText;
|
|
2788
|
-
},
|
|
2789
|
-
get src() {
|
|
2790
|
-
return props.imgSrc || props.image;
|
|
2791
|
-
}
|
|
2792
|
-
}, {}, () => props.attributes), false, false);
|
|
2793
|
-
return _el$;
|
|
2794
|
-
})();
|
|
2795
|
-
}
|
|
2796
|
-
var img_default = ImgComponent;
|
|
2797
|
-
|
|
2798
|
-
// src/blocks/img/component-info.js
|
|
2799
|
-
var componentInfo10 = {
|
|
2800
|
-
name: "Raw:Img",
|
|
2801
|
-
hideFromInsertMenu: true,
|
|
2802
|
-
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",
|
|
2803
|
-
inputs: [{
|
|
2804
|
-
name: "image",
|
|
2805
|
-
bubble: true,
|
|
2806
|
-
type: "file",
|
|
2807
|
-
allowedFileTypes: ["jpeg", "jpg", "png", "svg", "gif", "webp"],
|
|
2808
|
-
required: true
|
|
2809
|
-
}],
|
|
2810
|
-
noWrap: true,
|
|
2811
|
-
static: true
|
|
2812
|
-
};
|
|
2813
|
-
var _tmpl$13 = /* @__PURE__ */ template(`<div>`);
|
|
2814
|
-
function CustomCode(props) {
|
|
2815
|
-
const [scriptsInserted, setScriptsInserted] = createSignal([]);
|
|
2816
|
-
const [scriptsRun, setScriptsRun] = createSignal([]);
|
|
2817
|
-
let elementRef;
|
|
2818
|
-
onMount(() => {
|
|
2819
|
-
if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
|
|
2820
|
-
return;
|
|
2821
|
-
}
|
|
2822
|
-
const scripts = elementRef.getElementsByTagName("script");
|
|
2823
|
-
for (let i = 0; i < scripts.length; i++) {
|
|
2824
|
-
const script = scripts[i];
|
|
2825
|
-
if (script.src) {
|
|
2826
|
-
if (scriptsInserted().includes(script.src)) {
|
|
2827
|
-
continue;
|
|
2828
|
-
}
|
|
2829
|
-
scriptsInserted().push(script.src);
|
|
2830
|
-
const newScript = document.createElement("script");
|
|
2831
|
-
newScript.async = true;
|
|
2832
|
-
newScript.src = script.src;
|
|
2833
|
-
document.head.appendChild(newScript);
|
|
2834
|
-
} else if (!script.type || ["text/javascript", "application/javascript", "application/ecmascript"].includes(script.type)) {
|
|
2835
|
-
if (scriptsRun().includes(script.innerText)) {
|
|
2836
|
-
continue;
|
|
2837
|
-
}
|
|
2838
|
-
try {
|
|
2839
|
-
scriptsRun().push(script.innerText);
|
|
2840
|
-
new Function(script.innerText)();
|
|
2841
|
-
} catch (error) {
|
|
2842
|
-
}
|
|
2843
|
-
}
|
|
2844
|
-
}
|
|
2845
|
-
});
|
|
2846
|
-
return (() => {
|
|
2847
|
-
const _el$ = _tmpl$13();
|
|
2848
|
-
const _ref$ = elementRef;
|
|
2849
|
-
typeof _ref$ === "function" ? use(_ref$, _el$) : elementRef = _el$;
|
|
2850
|
-
effect((_p$) => {
|
|
2851
|
-
const _v$ = "builder-custom-code" + (props.replaceNodes ? " replace-nodes" : ""), _v$2 = props.code;
|
|
2852
|
-
_v$ !== _p$._v$ && className(_el$, _p$._v$ = _v$);
|
|
2853
|
-
_v$2 !== _p$._v$2 && (_el$.innerHTML = _p$._v$2 = _v$2);
|
|
2854
|
-
return _p$;
|
|
2855
|
-
}, {
|
|
2856
|
-
_v$: void 0,
|
|
2857
|
-
_v$2: void 0
|
|
2858
|
-
});
|
|
2859
|
-
return _el$;
|
|
2860
|
-
})();
|
|
2861
|
-
}
|
|
2862
|
-
var custom_code_default = CustomCode;
|
|
2863
|
-
|
|
2864
|
-
// src/blocks/custom-code/component-info.js
|
|
2865
|
-
var componentInfo11 = {
|
|
2866
|
-
name: "Custom Code",
|
|
2867
|
-
static: true,
|
|
2868
|
-
requiredPermissions: ["editCode"],
|
|
2869
|
-
inputs: [{
|
|
2870
|
-
name: "code",
|
|
2871
|
-
type: "html",
|
|
2872
|
-
required: true,
|
|
2873
|
-
defaultValue: "<p>Hello there, I am custom HTML code!</p>",
|
|
2874
|
-
code: true
|
|
2875
|
-
}, {
|
|
2876
|
-
name: "replaceNodes",
|
|
2877
|
-
type: "boolean",
|
|
2878
|
-
helperText: "Preserve server rendered dom nodes",
|
|
2879
|
-
advanced: true
|
|
2880
|
-
}, {
|
|
2881
|
-
name: "scriptsClientOnly",
|
|
2882
|
-
type: "boolean",
|
|
2883
|
-
defaultValue: false,
|
|
2884
|
-
helperText: "Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads",
|
|
2885
|
-
advanced: true
|
|
2886
|
-
}]
|
|
2887
|
-
};
|
|
2888
|
-
|
|
2889
|
-
// src/constants/builder-registered-components.js
|
|
2890
|
-
var __defProp10 = Object.defineProperty;
|
|
2891
|
-
var __getOwnPropSymbols10 = Object.getOwnPropertySymbols;
|
|
2892
|
-
var __hasOwnProp10 = Object.prototype.hasOwnProperty;
|
|
2893
|
-
var __propIsEnum10 = Object.prototype.propertyIsEnumerable;
|
|
2894
|
-
var __defNormalProp10 = (obj, key, value) => key in obj ? __defProp10(obj, key, {
|
|
2895
|
-
enumerable: true,
|
|
2896
|
-
configurable: true,
|
|
2897
|
-
writable: true,
|
|
2898
|
-
value
|
|
2899
|
-
}) : obj[key] = value;
|
|
2900
|
-
var __spreadValues10 = (a, b) => {
|
|
2901
|
-
for (var prop in b || (b = {}))
|
|
2902
|
-
if (__hasOwnProp10.call(b, prop))
|
|
2903
|
-
__defNormalProp10(a, prop, b[prop]);
|
|
2904
|
-
if (__getOwnPropSymbols10)
|
|
2905
|
-
for (var prop of __getOwnPropSymbols10(b)) {
|
|
2906
|
-
if (__propIsEnum10.call(b, prop))
|
|
2907
|
-
__defNormalProp10(a, prop, b[prop]);
|
|
2908
|
-
}
|
|
2909
|
-
return a;
|
|
2910
|
-
};
|
|
2911
|
-
var getDefaultRegisteredComponents = () => [__spreadValues10({
|
|
2912
|
-
component: button_default
|
|
2913
|
-
}, componentInfo), __spreadValues10({
|
|
2914
|
-
component: columns_default
|
|
2915
|
-
}, componentInfo2), __spreadValues10({
|
|
2916
|
-
component: custom_code_default
|
|
2917
|
-
}, componentInfo11), __spreadValues10({
|
|
2918
|
-
component: embed_default
|
|
2919
|
-
}, componentInfo9), __spreadValues10({
|
|
2920
|
-
component: fragment_default
|
|
2921
|
-
}, componentInfo3), __spreadValues10({
|
|
2922
|
-
component: image_default
|
|
2923
|
-
}, componentInfo4), __spreadValues10({
|
|
2924
|
-
component: img_default
|
|
2925
|
-
}, componentInfo10), __spreadValues10({
|
|
2926
|
-
component: section_default
|
|
2927
|
-
}, componentInfo5), __spreadValues10({
|
|
2928
|
-
component: symbol_default
|
|
2929
|
-
}, componentInfo6), __spreadValues10({
|
|
2930
|
-
component: text_default
|
|
2931
|
-
}, componentInfo7), __spreadValues10({
|
|
2932
|
-
component: video_default
|
|
2933
|
-
}, componentInfo8)];
|
|
2934
|
-
|
|
2935
|
-
// src/functions/register-component.js
|
|
2936
|
-
var __defProp11 = Object.defineProperty;
|
|
2937
|
-
var __defProps8 = Object.defineProperties;
|
|
2938
|
-
var __getOwnPropDescs8 = Object.getOwnPropertyDescriptors;
|
|
2939
|
-
var __getOwnPropSymbols11 = Object.getOwnPropertySymbols;
|
|
2940
|
-
var __hasOwnProp11 = Object.prototype.hasOwnProperty;
|
|
2941
|
-
var __propIsEnum11 = Object.prototype.propertyIsEnumerable;
|
|
2942
|
-
var __defNormalProp11 = (obj, key, value) => key in obj ? __defProp11(obj, key, {
|
|
2943
|
-
enumerable: true,
|
|
2944
|
-
configurable: true,
|
|
2945
|
-
writable: true,
|
|
2946
|
-
value
|
|
2947
|
-
}) : obj[key] = value;
|
|
2948
|
-
var __spreadValues11 = (a, b) => {
|
|
2949
|
-
for (var prop in b || (b = {}))
|
|
2950
|
-
if (__hasOwnProp11.call(b, prop))
|
|
2951
|
-
__defNormalProp11(a, prop, b[prop]);
|
|
2952
|
-
if (__getOwnPropSymbols11)
|
|
2953
|
-
for (var prop of __getOwnPropSymbols11(b)) {
|
|
2954
|
-
if (__propIsEnum11.call(b, prop))
|
|
2955
|
-
__defNormalProp11(a, prop, b[prop]);
|
|
2956
|
-
}
|
|
2957
|
-
return a;
|
|
2958
|
-
};
|
|
2959
|
-
var __spreadProps8 = (a, b) => __defProps8(a, __getOwnPropDescs8(b));
|
|
2960
|
-
var __objRest2 = (source, exclude) => {
|
|
2961
|
-
var target = {};
|
|
2962
|
-
for (var prop in source)
|
|
2963
|
-
if (__hasOwnProp11.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
2964
|
-
target[prop] = source[prop];
|
|
2965
|
-
if (source != null && __getOwnPropSymbols11)
|
|
2966
|
-
for (var prop of __getOwnPropSymbols11(source)) {
|
|
2967
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum11.call(source, prop))
|
|
2968
|
-
target[prop] = source[prop];
|
|
2969
|
-
}
|
|
2970
|
-
return target;
|
|
2971
|
-
};
|
|
2972
|
-
var components = [];
|
|
2973
|
-
var createRegisterComponentMessage = (info) => ({
|
|
2974
|
-
type: "builder.registerComponent",
|
|
2975
|
-
data: serializeComponentInfo(info)
|
|
2976
|
-
});
|
|
2977
|
-
var serializeFn = (fnValue) => {
|
|
2978
|
-
const fnStr = fnValue.toString().trim();
|
|
2979
|
-
const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(");
|
|
2980
|
-
return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
|
|
2981
|
-
};
|
|
2982
|
-
var serializeValue = (value) => typeof value === "function" ? serializeFn(value) : fastClone(value);
|
|
2983
|
-
var serializeComponentInfo = (_a) => {
|
|
2984
|
-
var _b = _a, {
|
|
2985
|
-
inputs
|
|
2986
|
-
} = _b, info = __objRest2(_b, ["inputs"]);
|
|
2987
|
-
return __spreadProps8(__spreadValues11({}, fastClone(info)), {
|
|
2988
|
-
inputs: inputs == null ? void 0 : inputs.map((input) => Object.entries(input).reduce((acc, [key, value]) => __spreadProps8(__spreadValues11({}, acc), {
|
|
2989
|
-
[key]: serializeValue(value)
|
|
2990
|
-
}), {}))
|
|
2991
|
-
});
|
|
2992
|
-
};
|
|
2993
|
-
|
|
2994
|
-
// src/components/content/components/styles.helpers.js
|
|
2995
|
-
var getCssFromFont = (font) => {
|
|
2996
|
-
var _a, _b;
|
|
2997
|
-
const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
|
|
2998
|
-
const name = family.split(",")[0];
|
|
2999
|
-
const url = (_b = font.fileUrl) != null ? _b : (_a = font == null ? void 0 : font.files) == null ? void 0 : _a.regular;
|
|
3000
|
-
let str = "";
|
|
3001
|
-
if (url && family && name) {
|
|
3002
|
-
str += `
|
|
3003
|
-
@font-face {
|
|
3004
|
-
font-family: "${family}";
|
|
3005
|
-
src: local("${name}"), url('${url}') format('woff2');
|
|
3006
|
-
font-display: fallback;
|
|
3007
|
-
font-weight: 400;
|
|
3008
|
-
}
|
|
3009
|
-
`.trim();
|
|
3010
|
-
}
|
|
3011
|
-
if (font.files) {
|
|
3012
|
-
for (const weight in font.files) {
|
|
3013
|
-
const isNumber = String(Number(weight)) === weight;
|
|
3014
|
-
if (!isNumber) {
|
|
3015
|
-
continue;
|
|
3016
|
-
}
|
|
3017
|
-
const weightUrl = font.files[weight];
|
|
3018
|
-
if (weightUrl && weightUrl !== url) {
|
|
3019
|
-
str += `
|
|
3020
|
-
@font-face {
|
|
3021
|
-
font-family: "${family}";
|
|
3022
|
-
src: url('${weightUrl}') format('woff2');
|
|
3023
|
-
font-display: fallback;
|
|
3024
|
-
font-weight: ${weight};
|
|
3025
|
-
}
|
|
3026
|
-
`.trim();
|
|
3027
|
-
}
|
|
3028
|
-
}
|
|
3029
|
-
}
|
|
3030
|
-
return str;
|
|
3031
|
-
};
|
|
3032
|
-
var getFontCss = ({
|
|
3033
|
-
customFonts
|
|
3034
|
-
}) => {
|
|
3035
|
-
var _a;
|
|
3036
|
-
return ((_a = customFonts == null ? void 0 : customFonts.map((font) => getCssFromFont(font))) == null ? void 0 : _a.join(" ")) || "";
|
|
3037
|
-
};
|
|
3038
|
-
var getCss = ({
|
|
3039
|
-
cssCode,
|
|
3040
|
-
contentId
|
|
3041
|
-
}) => {
|
|
3042
|
-
if (!cssCode) {
|
|
3043
|
-
return "";
|
|
3044
|
-
}
|
|
3045
|
-
if (!contentId) {
|
|
3046
|
-
return cssCode;
|
|
3047
|
-
}
|
|
3048
|
-
return (cssCode == null ? void 0 : cssCode.replace(/&/g, `div[builder-content-id="${contentId}"]`)) || "";
|
|
3049
|
-
};
|
|
3050
|
-
|
|
3051
|
-
// src/components/content/components/styles.jsx
|
|
3052
|
-
function ContentStyles(props) {
|
|
3053
|
-
const [injectedStyles, setInjectedStyles] = createSignal(`
|
|
3054
|
-
${getCss({
|
|
3055
|
-
cssCode: props.cssCode,
|
|
3056
|
-
contentId: props.contentId
|
|
3057
|
-
})}
|
|
3058
|
-
${getFontCss({
|
|
3059
|
-
customFonts: props.customFonts
|
|
3060
|
-
})}
|
|
3061
|
-
|
|
3062
|
-
.builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
|
|
3063
|
-
margin: 0;
|
|
3064
|
-
}
|
|
3065
|
-
.builder-text > p, .builder-text > .builder-paragraph {
|
|
3066
|
-
color: inherit;
|
|
3067
|
-
line-height: inherit;
|
|
3068
|
-
letter-spacing: inherit;
|
|
3069
|
-
font-weight: inherit;
|
|
3070
|
-
font-size: inherit;
|
|
3071
|
-
text-align: inherit;
|
|
3072
|
-
font-family: inherit;
|
|
3073
|
-
}
|
|
3074
|
-
`.trim());
|
|
3075
|
-
return createComponent(inlined_styles_default, {
|
|
3076
|
-
get styles() {
|
|
3077
|
-
return injectedStyles();
|
|
3078
|
-
}
|
|
3079
|
-
});
|
|
3080
|
-
}
|
|
3081
|
-
var styles_default = ContentStyles;
|
|
3082
|
-
|
|
3083
|
-
// src/components/content/content.helpers.js
|
|
3084
|
-
var __defProp12 = Object.defineProperty;
|
|
3085
|
-
var __defProps9 = Object.defineProperties;
|
|
3086
|
-
var __getOwnPropDescs9 = Object.getOwnPropertyDescriptors;
|
|
3087
|
-
var __getOwnPropSymbols12 = Object.getOwnPropertySymbols;
|
|
3088
|
-
var __hasOwnProp12 = Object.prototype.hasOwnProperty;
|
|
3089
|
-
var __propIsEnum12 = Object.prototype.propertyIsEnumerable;
|
|
3090
|
-
var __defNormalProp12 = (obj, key, value) => key in obj ? __defProp12(obj, key, {
|
|
3091
|
-
enumerable: true,
|
|
3092
|
-
configurable: true,
|
|
3093
|
-
writable: true,
|
|
3094
|
-
value
|
|
3095
|
-
}) : obj[key] = value;
|
|
3096
|
-
var __spreadValues12 = (a, b) => {
|
|
3097
|
-
for (var prop in b || (b = {}))
|
|
3098
|
-
if (__hasOwnProp12.call(b, prop))
|
|
3099
|
-
__defNormalProp12(a, prop, b[prop]);
|
|
3100
|
-
if (__getOwnPropSymbols12)
|
|
3101
|
-
for (var prop of __getOwnPropSymbols12(b)) {
|
|
3102
|
-
if (__propIsEnum12.call(b, prop))
|
|
3103
|
-
__defNormalProp12(a, prop, b[prop]);
|
|
3104
|
-
}
|
|
3105
|
-
return a;
|
|
3106
|
-
};
|
|
3107
|
-
var __spreadProps9 = (a, b) => __defProps9(a, __getOwnPropDescs9(b));
|
|
3108
|
-
var getContextStateInitialValue = ({
|
|
3109
|
-
content,
|
|
3110
|
-
data,
|
|
3111
|
-
locale
|
|
3112
|
-
}) => {
|
|
3113
|
-
var _a, _b, _c;
|
|
3114
|
-
const defaultValues = {};
|
|
3115
|
-
(_b = (_a = content == null ? void 0 : content.data) == null ? void 0 : _a.inputs) == null ? void 0 : _b.forEach((input) => {
|
|
3116
|
-
var _a2;
|
|
3117
|
-
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) {
|
|
3118
|
-
defaultValues[input.name] = input.defaultValue;
|
|
3119
|
-
}
|
|
3120
|
-
});
|
|
3121
|
-
const stateToUse = __spreadValues12(__spreadValues12(__spreadValues12({}, (_c = content == null ? void 0 : content.data) == null ? void 0 : _c.state), data), locale ? {
|
|
3122
|
-
locale
|
|
3123
|
-
} : {});
|
|
3124
|
-
return __spreadValues12(__spreadValues12({}, defaultValues), stateToUse);
|
|
3125
|
-
};
|
|
3126
|
-
var getContentInitialValue = ({
|
|
3127
|
-
content,
|
|
3128
|
-
data
|
|
3129
|
-
}) => {
|
|
3130
|
-
return !content ? void 0 : __spreadProps9(__spreadValues12({}, content), {
|
|
3131
|
-
data: __spreadValues12(__spreadValues12({}, content == null ? void 0 : content.data), data),
|
|
3132
|
-
meta: content == null ? void 0 : content.meta
|
|
3133
|
-
});
|
|
3134
|
-
};
|
|
3135
|
-
|
|
3136
|
-
// src/functions/get-global-this.js
|
|
3137
|
-
function getGlobalThis() {
|
|
3138
|
-
if (typeof globalThis !== "undefined") {
|
|
3139
|
-
return globalThis;
|
|
3140
|
-
}
|
|
3141
|
-
if (typeof window !== "undefined") {
|
|
3142
|
-
return window;
|
|
3143
|
-
}
|
|
3144
|
-
if (typeof global !== "undefined") {
|
|
3145
|
-
return global;
|
|
3146
|
-
}
|
|
3147
|
-
if (typeof self !== "undefined") {
|
|
3148
|
-
return self;
|
|
3149
|
-
}
|
|
3150
|
-
return globalThis;
|
|
3151
|
-
}
|
|
3152
|
-
|
|
3153
|
-
// src/functions/get-fetch.js
|
|
3154
|
-
function getFetch() {
|
|
3155
|
-
const globalFetch = getGlobalThis().fetch;
|
|
3156
|
-
if (typeof globalFetch === "undefined") {
|
|
3157
|
-
throw new Error("Builder SDK could not find a global `fetch` function");
|
|
3158
|
-
}
|
|
3159
|
-
return globalFetch;
|
|
3160
|
-
}
|
|
3161
|
-
var fetch2 = getFetch();
|
|
3162
|
-
|
|
3163
|
-
// src/helpers/url.js
|
|
3164
|
-
var getTopLevelDomain = (host) => {
|
|
3165
|
-
if (host === "localhost" || host === "127.0.0.1") {
|
|
3166
|
-
return host;
|
|
3167
|
-
}
|
|
3168
|
-
const parts = host.split(".");
|
|
3169
|
-
if (parts.length > 2) {
|
|
3170
|
-
return parts.slice(1).join(".");
|
|
3171
|
-
}
|
|
3172
|
-
return host;
|
|
3173
|
-
};
|
|
3174
|
-
|
|
3175
|
-
// src/helpers/cookie.js
|
|
3176
|
-
var __async = (__this, __arguments, generator) => {
|
|
3177
|
-
return new Promise((resolve, reject) => {
|
|
3178
|
-
var fulfilled = (value) => {
|
|
3179
|
-
try {
|
|
3180
|
-
step(generator.next(value));
|
|
3181
|
-
} catch (e) {
|
|
3182
|
-
reject(e);
|
|
3183
|
-
}
|
|
3184
|
-
};
|
|
3185
|
-
var rejected = (value) => {
|
|
3186
|
-
try {
|
|
3187
|
-
step(generator.throw(value));
|
|
3188
|
-
} catch (e) {
|
|
3189
|
-
reject(e);
|
|
3190
|
-
}
|
|
3191
|
-
};
|
|
3192
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
3193
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
3194
|
-
});
|
|
3195
|
-
};
|
|
3196
|
-
var getCookieSync = ({
|
|
3197
|
-
name,
|
|
3198
|
-
canTrack
|
|
3199
|
-
}) => {
|
|
3200
|
-
var _a;
|
|
3201
|
-
try {
|
|
3202
|
-
if (!canTrack) {
|
|
3203
|
-
return void 0;
|
|
3204
|
-
}
|
|
3205
|
-
return (_a = document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))) == null ? void 0 : _a.split("=")[1];
|
|
3206
|
-
} catch (err) {
|
|
3207
|
-
logger.warn("[COOKIE] GET error: ", (err == null ? void 0 : err.message) || err);
|
|
3208
|
-
return void 0;
|
|
3209
|
-
}
|
|
3210
|
-
};
|
|
3211
|
-
var getCookie = (args) => __async(void 0, null, function* () {
|
|
3212
|
-
return getCookieSync(args);
|
|
3213
|
-
});
|
|
3214
|
-
var stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).filter(checkIsDefined).join("; ");
|
|
3215
|
-
var SECURE_CONFIG = [["secure", ""], ["SameSite", "None"]];
|
|
3216
|
-
var createCookieString = ({
|
|
3217
|
-
name,
|
|
3218
|
-
value,
|
|
3219
|
-
expires
|
|
3220
|
-
}) => {
|
|
3221
|
-
const secure = isBrowser() ? location.protocol === "https:" : true;
|
|
3222
|
-
const secureObj = secure ? SECURE_CONFIG : [[]];
|
|
3223
|
-
const expiresObj = expires ? [["expires", expires.toUTCString()]] : [[]];
|
|
3224
|
-
const cookieValue = [[name, value], ...expiresObj, ["path", "/"], ["domain", getTopLevelDomain(window.location.hostname)], ...secureObj];
|
|
3225
|
-
const cookie = stringifyCookie(cookieValue);
|
|
3226
|
-
return cookie;
|
|
3227
|
-
};
|
|
3228
|
-
var setCookie = (_0) => __async(void 0, [_0], function* ({
|
|
3229
|
-
name,
|
|
3230
|
-
value,
|
|
3231
|
-
expires,
|
|
3232
|
-
canTrack
|
|
3233
|
-
}) {
|
|
3234
|
-
try {
|
|
3235
|
-
if (!canTrack) {
|
|
3236
|
-
return;
|
|
3237
|
-
}
|
|
3238
|
-
const cookie = createCookieString({
|
|
3239
|
-
name,
|
|
3240
|
-
value,
|
|
3241
|
-
expires
|
|
3242
|
-
});
|
|
3243
|
-
document.cookie = cookie;
|
|
3244
|
-
} catch (err) {
|
|
3245
|
-
logger.warn("[COOKIE] SET error: ", (err == null ? void 0 : err.message) || err);
|
|
3246
|
-
}
|
|
3247
|
-
});
|
|
3248
|
-
|
|
3249
|
-
// src/helpers/uuid.js
|
|
3250
|
-
function uuidv4() {
|
|
3251
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
3252
|
-
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
|
3253
|
-
return v.toString(16);
|
|
3254
|
-
});
|
|
3255
|
-
}
|
|
3256
|
-
function uuid() {
|
|
3257
|
-
return uuidv4().replace(/-/g, "");
|
|
3258
|
-
}
|
|
3259
|
-
|
|
3260
|
-
// src/helpers/sessionId.js
|
|
3261
|
-
var __async2 = (__this, __arguments, generator) => {
|
|
3262
|
-
return new Promise((resolve, reject) => {
|
|
3263
|
-
var fulfilled = (value) => {
|
|
3264
|
-
try {
|
|
3265
|
-
step(generator.next(value));
|
|
3266
|
-
} catch (e) {
|
|
3267
|
-
reject(e);
|
|
3268
|
-
}
|
|
3269
|
-
};
|
|
3270
|
-
var rejected = (value) => {
|
|
3271
|
-
try {
|
|
3272
|
-
step(generator.throw(value));
|
|
3273
|
-
} catch (e) {
|
|
3274
|
-
reject(e);
|
|
3275
|
-
}
|
|
3276
|
-
};
|
|
3277
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
3278
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
3279
|
-
});
|
|
3280
|
-
};
|
|
3281
|
-
var SESSION_LOCAL_STORAGE_KEY = "builderSessionId";
|
|
3282
|
-
var getSessionId = (_0) => __async2(void 0, [_0], function* ({
|
|
3283
|
-
canTrack
|
|
3284
|
-
}) {
|
|
3285
|
-
if (!canTrack) {
|
|
3286
|
-
return void 0;
|
|
3287
|
-
}
|
|
3288
|
-
const sessionId = yield getCookie({
|
|
3289
|
-
name: SESSION_LOCAL_STORAGE_KEY,
|
|
3290
|
-
canTrack
|
|
3291
|
-
});
|
|
3292
|
-
if (checkIsDefined(sessionId)) {
|
|
3293
|
-
return sessionId;
|
|
3294
|
-
} else {
|
|
3295
|
-
const newSessionId = createSessionId();
|
|
3296
|
-
setSessionId({
|
|
3297
|
-
id: newSessionId,
|
|
3298
|
-
canTrack
|
|
3299
|
-
});
|
|
3300
|
-
return newSessionId;
|
|
3301
|
-
}
|
|
3302
|
-
});
|
|
3303
|
-
var createSessionId = () => uuid();
|
|
3304
|
-
var setSessionId = ({
|
|
3305
|
-
id,
|
|
3306
|
-
canTrack
|
|
3307
|
-
}) => setCookie({
|
|
3308
|
-
name: SESSION_LOCAL_STORAGE_KEY,
|
|
3309
|
-
value: id,
|
|
3310
|
-
canTrack
|
|
3311
|
-
});
|
|
3312
|
-
|
|
3313
|
-
// src/helpers/localStorage.js
|
|
3314
|
-
var getLocalStorage = () => isBrowser() && typeof localStorage !== "undefined" ? localStorage : void 0;
|
|
3315
|
-
var getLocalStorageItem = ({
|
|
3316
|
-
key,
|
|
3317
|
-
canTrack
|
|
3318
|
-
}) => {
|
|
3319
|
-
var _a;
|
|
3320
|
-
try {
|
|
3321
|
-
if (canTrack) {
|
|
3322
|
-
return (_a = getLocalStorage()) == null ? void 0 : _a.getItem(key);
|
|
3323
|
-
}
|
|
3324
|
-
return void 0;
|
|
3325
|
-
} catch (err) {
|
|
3326
|
-
return void 0;
|
|
3327
|
-
}
|
|
3328
|
-
};
|
|
3329
|
-
var setLocalStorageItem = ({
|
|
3330
|
-
key,
|
|
3331
|
-
canTrack,
|
|
3332
|
-
value
|
|
3333
|
-
}) => {
|
|
3334
|
-
var _a;
|
|
3335
|
-
try {
|
|
3336
|
-
if (canTrack) {
|
|
3337
|
-
(_a = getLocalStorage()) == null ? void 0 : _a.setItem(key, value);
|
|
3338
|
-
}
|
|
3339
|
-
} catch (err) {
|
|
3340
|
-
}
|
|
3341
|
-
};
|
|
3342
|
-
|
|
3343
|
-
// src/helpers/visitorId.js
|
|
3344
|
-
var VISITOR_LOCAL_STORAGE_KEY = "builderVisitorId";
|
|
3345
|
-
var getVisitorId = ({
|
|
3346
|
-
canTrack
|
|
3347
|
-
}) => {
|
|
3348
|
-
if (!canTrack) {
|
|
3349
|
-
return void 0;
|
|
3350
|
-
}
|
|
3351
|
-
const visitorId = getLocalStorageItem({
|
|
3352
|
-
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
3353
|
-
canTrack
|
|
3354
|
-
});
|
|
3355
|
-
if (checkIsDefined(visitorId)) {
|
|
3356
|
-
return visitorId;
|
|
3357
|
-
} else {
|
|
3358
|
-
const newVisitorId = createVisitorId();
|
|
3359
|
-
setVisitorId({
|
|
3360
|
-
id: newVisitorId,
|
|
3361
|
-
canTrack
|
|
3362
|
-
});
|
|
3363
|
-
return newVisitorId;
|
|
3364
|
-
}
|
|
3365
|
-
};
|
|
3366
|
-
var createVisitorId = () => uuid();
|
|
3367
|
-
var setVisitorId = ({
|
|
3368
|
-
id,
|
|
3369
|
-
canTrack
|
|
3370
|
-
}) => setLocalStorageItem({
|
|
3371
|
-
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
3372
|
-
value: id,
|
|
3373
|
-
canTrack
|
|
3374
|
-
});
|
|
3375
|
-
|
|
3376
|
-
// src/functions/track/index.js
|
|
3377
|
-
var __defProp13 = Object.defineProperty;
|
|
3378
|
-
var __defProps10 = Object.defineProperties;
|
|
3379
|
-
var __getOwnPropDescs10 = Object.getOwnPropertyDescriptors;
|
|
3380
|
-
var __getOwnPropSymbols13 = Object.getOwnPropertySymbols;
|
|
3381
|
-
var __hasOwnProp13 = Object.prototype.hasOwnProperty;
|
|
3382
|
-
var __propIsEnum13 = Object.prototype.propertyIsEnumerable;
|
|
3383
|
-
var __defNormalProp13 = (obj, key, value) => key in obj ? __defProp13(obj, key, {
|
|
3384
|
-
enumerable: true,
|
|
3385
|
-
configurable: true,
|
|
3386
|
-
writable: true,
|
|
3387
|
-
value
|
|
3388
|
-
}) : obj[key] = value;
|
|
3389
|
-
var __spreadValues13 = (a, b) => {
|
|
3390
|
-
for (var prop in b || (b = {}))
|
|
3391
|
-
if (__hasOwnProp13.call(b, prop))
|
|
3392
|
-
__defNormalProp13(a, prop, b[prop]);
|
|
3393
|
-
if (__getOwnPropSymbols13)
|
|
3394
|
-
for (var prop of __getOwnPropSymbols13(b)) {
|
|
3395
|
-
if (__propIsEnum13.call(b, prop))
|
|
3396
|
-
__defNormalProp13(a, prop, b[prop]);
|
|
3397
|
-
}
|
|
3398
|
-
return a;
|
|
3399
|
-
};
|
|
3400
|
-
var __spreadProps10 = (a, b) => __defProps10(a, __getOwnPropDescs10(b));
|
|
3401
|
-
var __objRest3 = (source, exclude) => {
|
|
3402
|
-
var target = {};
|
|
3403
|
-
for (var prop in source)
|
|
3404
|
-
if (__hasOwnProp13.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
3405
|
-
target[prop] = source[prop];
|
|
3406
|
-
if (source != null && __getOwnPropSymbols13)
|
|
3407
|
-
for (var prop of __getOwnPropSymbols13(source)) {
|
|
3408
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum13.call(source, prop))
|
|
3409
|
-
target[prop] = source[prop];
|
|
3410
|
-
}
|
|
3411
|
-
return target;
|
|
3412
|
-
};
|
|
3413
|
-
var __async3 = (__this, __arguments, generator) => {
|
|
3414
|
-
return new Promise((resolve, reject) => {
|
|
3415
|
-
var fulfilled = (value) => {
|
|
3416
|
-
try {
|
|
3417
|
-
step(generator.next(value));
|
|
3418
|
-
} catch (e) {
|
|
3419
|
-
reject(e);
|
|
3420
|
-
}
|
|
3421
|
-
};
|
|
3422
|
-
var rejected = (value) => {
|
|
3423
|
-
try {
|
|
3424
|
-
step(generator.throw(value));
|
|
3425
|
-
} catch (e) {
|
|
3426
|
-
reject(e);
|
|
3427
|
-
}
|
|
3428
|
-
};
|
|
3429
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
3430
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
3431
|
-
});
|
|
3432
|
-
};
|
|
3433
|
-
var getTrackingEventData = (_0) => __async3(void 0, [_0], function* ({
|
|
3434
|
-
canTrack
|
|
3435
|
-
}) {
|
|
3436
|
-
if (!canTrack) {
|
|
2764
|
+
} : {}
|
|
2765
|
+
};
|
|
2766
|
+
}
|
|
2767
|
+
function spreadProps() {
|
|
3437
2768
|
return {
|
|
3438
|
-
|
|
3439
|
-
|
|
2769
|
+
...props.attributes,
|
|
2770
|
+
...videoProps()
|
|
3440
2771
|
};
|
|
3441
2772
|
}
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
});
|
|
3448
|
-
return {
|
|
3449
|
-
sessionId,
|
|
3450
|
-
visitorId
|
|
3451
|
-
};
|
|
3452
|
-
});
|
|
3453
|
-
var createEvent = (_a) => __async3(void 0, null, function* () {
|
|
3454
|
-
var _b = _a, {
|
|
3455
|
-
type: eventType,
|
|
3456
|
-
canTrack,
|
|
3457
|
-
apiKey,
|
|
3458
|
-
metadata
|
|
3459
|
-
} = _b, properties = __objRest3(_b, ["type", "canTrack", "apiKey", "metadata"]);
|
|
3460
|
-
return {
|
|
3461
|
-
type: eventType,
|
|
3462
|
-
data: __spreadProps10(__spreadValues13(__spreadProps10(__spreadValues13({}, properties), {
|
|
3463
|
-
metadata: __spreadValues13({
|
|
3464
|
-
url: location.href
|
|
3465
|
-
}, metadata)
|
|
3466
|
-
}), yield getTrackingEventData({
|
|
3467
|
-
canTrack
|
|
3468
|
-
})), {
|
|
3469
|
-
userAttributes: getUserAttributes(),
|
|
3470
|
-
ownerId: apiKey
|
|
3471
|
-
})
|
|
3472
|
-
};
|
|
3473
|
-
});
|
|
3474
|
-
function _track(eventProps) {
|
|
3475
|
-
return __async3(this, null, function* () {
|
|
3476
|
-
if (!eventProps.apiKey) {
|
|
3477
|
-
logger.error("Missing API key for track call. Please provide your API key.");
|
|
3478
|
-
return;
|
|
3479
|
-
}
|
|
3480
|
-
if (!eventProps.canTrack) {
|
|
3481
|
-
return;
|
|
3482
|
-
}
|
|
3483
|
-
if (isEditing()) {
|
|
3484
|
-
return;
|
|
3485
|
-
}
|
|
3486
|
-
if (!(isBrowser() || TARGET === "reactNative")) {
|
|
3487
|
-
return;
|
|
3488
|
-
}
|
|
3489
|
-
return fetch(`https://cdn.builder.io/api/v1/track`, {
|
|
3490
|
-
method: "POST",
|
|
3491
|
-
body: JSON.stringify({
|
|
3492
|
-
events: [yield createEvent(eventProps)]
|
|
3493
|
-
}),
|
|
3494
|
-
headers: {
|
|
3495
|
-
"content-type": "application/json"
|
|
2773
|
+
return (() => {
|
|
2774
|
+
const _el$ = _tmpl$13();
|
|
2775
|
+
spread(_el$, mergeProps(spreadProps, {
|
|
2776
|
+
get preload() {
|
|
2777
|
+
return props.preload || "metadata";
|
|
3496
2778
|
},
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
2779
|
+
get style() {
|
|
2780
|
+
return {
|
|
2781
|
+
width: "100%",
|
|
2782
|
+
height: "100%",
|
|
2783
|
+
...props.attributes?.style,
|
|
2784
|
+
"object-fit": props.fit,
|
|
2785
|
+
"object-position": props.position,
|
|
2786
|
+
// Hack to get object fit to work as expected and
|
|
2787
|
+
// not have the video overflow
|
|
2788
|
+
"border-radius": 1
|
|
2789
|
+
};
|
|
2790
|
+
},
|
|
2791
|
+
get src() {
|
|
2792
|
+
return props.video || "no-src";
|
|
2793
|
+
},
|
|
2794
|
+
get poster() {
|
|
2795
|
+
return props.posterImage;
|
|
2796
|
+
}
|
|
2797
|
+
}), false, false);
|
|
2798
|
+
return _el$;
|
|
2799
|
+
})();
|
|
3501
2800
|
}
|
|
3502
|
-
var
|
|
3503
|
-
canTrack: true
|
|
3504
|
-
}));
|
|
2801
|
+
var video_default = Video;
|
|
3505
2802
|
|
|
3506
|
-
// src/constants/
|
|
3507
|
-
var
|
|
2803
|
+
// src/constants/builder-registered-components.ts
|
|
2804
|
+
var getDefaultRegisteredComponents = () => [{
|
|
2805
|
+
component: button_default,
|
|
2806
|
+
...componentInfo
|
|
2807
|
+
}, {
|
|
2808
|
+
component: columns_default,
|
|
2809
|
+
...componentInfo2
|
|
2810
|
+
}, {
|
|
2811
|
+
component: custom_code_default,
|
|
2812
|
+
...componentInfo3
|
|
2813
|
+
}, {
|
|
2814
|
+
component: embed_default,
|
|
2815
|
+
...componentInfo4
|
|
2816
|
+
}, {
|
|
2817
|
+
component: fragment_default,
|
|
2818
|
+
...componentInfo5
|
|
2819
|
+
}, {
|
|
2820
|
+
component: image_default,
|
|
2821
|
+
...componentInfo6
|
|
2822
|
+
}, {
|
|
2823
|
+
component: img_default,
|
|
2824
|
+
...componentInfo7
|
|
2825
|
+
}, {
|
|
2826
|
+
component: section_default,
|
|
2827
|
+
...componentInfo8
|
|
2828
|
+
}, {
|
|
2829
|
+
component: symbol_default,
|
|
2830
|
+
...componentInfo9
|
|
2831
|
+
}, {
|
|
2832
|
+
component: text_default,
|
|
2833
|
+
...componentInfo10
|
|
2834
|
+
}, {
|
|
2835
|
+
component: video_default,
|
|
2836
|
+
...componentInfo11
|
|
2837
|
+
}];
|
|
3508
2838
|
|
|
3509
|
-
// src/functions/register.
|
|
3510
|
-
var
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
}
|
|
3532
|
-
}
|
|
3533
|
-
}
|
|
2839
|
+
// src/functions/register-component.ts
|
|
2840
|
+
var components = [];
|
|
2841
|
+
var createRegisterComponentMessage = (info) => ({
|
|
2842
|
+
type: "builder.registerComponent",
|
|
2843
|
+
data: serializeComponentInfo(info)
|
|
2844
|
+
});
|
|
2845
|
+
var serializeFn = (fnValue) => {
|
|
2846
|
+
const fnStr = fnValue.toString().trim();
|
|
2847
|
+
const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(");
|
|
2848
|
+
return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
|
|
2849
|
+
};
|
|
2850
|
+
var serializeValue = (value) => typeof value === "function" ? serializeFn(value) : fastClone(value);
|
|
2851
|
+
var serializeComponentInfo = ({
|
|
2852
|
+
inputs,
|
|
2853
|
+
...info
|
|
2854
|
+
}) => ({
|
|
2855
|
+
...fastClone(info),
|
|
2856
|
+
inputs: inputs?.map((input) => Object.entries(input).reduce((acc, [key, value]) => ({
|
|
2857
|
+
...acc,
|
|
2858
|
+
[key]: serializeValue(value)
|
|
2859
|
+
}), {}))
|
|
2860
|
+
});
|
|
3534
2861
|
|
|
3535
|
-
// src/
|
|
3536
|
-
var
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
});
|
|
2862
|
+
// src/components/content-variants/helpers.ts
|
|
2863
|
+
var getVariants = (content) => Object.values(content?.variations || {}).map((variant) => ({
|
|
2864
|
+
...variant,
|
|
2865
|
+
testVariationId: variant.id,
|
|
2866
|
+
id: content?.id
|
|
2867
|
+
}));
|
|
2868
|
+
var checkShouldRunVariants = ({
|
|
2869
|
+
canTrack,
|
|
2870
|
+
content
|
|
2871
|
+
}) => {
|
|
2872
|
+
const hasVariants = getVariants(content).length > 0;
|
|
2873
|
+
if (TARGET === "reactNative")
|
|
2874
|
+
return false;
|
|
2875
|
+
if (!hasVariants)
|
|
2876
|
+
return false;
|
|
2877
|
+
if (!canTrack)
|
|
2878
|
+
return false;
|
|
2879
|
+
if (TARGET === "vue2" || TARGET === "vue3")
|
|
2880
|
+
return true;
|
|
2881
|
+
if (isBrowser())
|
|
2882
|
+
return false;
|
|
2883
|
+
return true;
|
|
3558
2884
|
};
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
(_a = window.parent) == null ? void 0 : _a.postMessage({
|
|
3568
|
-
type: "builder.sdkInfo",
|
|
3569
|
-
data: {
|
|
3570
|
-
target: TARGET,
|
|
3571
|
-
version: SDK_VERSION,
|
|
3572
|
-
supportsPatchUpdates: false,
|
|
3573
|
-
supportsAddBlockScoping: true,
|
|
3574
|
-
supportsCustomBreakpoints: true
|
|
3575
|
-
}
|
|
3576
|
-
}, "*");
|
|
3577
|
-
(_b = window.parent) == null ? void 0 : _b.postMessage({
|
|
3578
|
-
type: "builder.updateContent",
|
|
3579
|
-
data: {
|
|
3580
|
-
options
|
|
2885
|
+
function bldrAbTest(contentId, variants, isHydrationTarget2) {
|
|
2886
|
+
function getAndSetVariantId2() {
|
|
2887
|
+
function setCookie2(name, value, days) {
|
|
2888
|
+
let expires = "";
|
|
2889
|
+
if (days) {
|
|
2890
|
+
const date = /* @__PURE__ */ new Date();
|
|
2891
|
+
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1e3);
|
|
2892
|
+
expires = "; expires=" + date.toUTCString();
|
|
3581
2893
|
}
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
2894
|
+
document.cookie = name + "=" + (value || "") + expires + "; path=/; Secure; SameSite=None";
|
|
2895
|
+
}
|
|
2896
|
+
function getCookie2(name) {
|
|
2897
|
+
const nameEQ = name + "=";
|
|
2898
|
+
const ca = document.cookie.split(";");
|
|
2899
|
+
for (let i = 0; i < ca.length; i++) {
|
|
2900
|
+
let c = ca[i];
|
|
2901
|
+
while (c.charAt(0) === " ")
|
|
2902
|
+
c = c.substring(1, c.length);
|
|
2903
|
+
if (c.indexOf(nameEQ) === 0)
|
|
2904
|
+
return c.substring(nameEQ.length, c.length);
|
|
3589
2905
|
}
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
id,
|
|
3608
|
-
error: error.message
|
|
3609
|
-
}
|
|
3610
|
-
}, "*");
|
|
3611
|
-
} else {
|
|
3612
|
-
if (result && typeof result.then === "function") {
|
|
3613
|
-
result.then((finalResult) => {
|
|
3614
|
-
var _a3;
|
|
3615
|
-
(_a3 = window.parent) == null ? void 0 : _a3.postMessage({
|
|
3616
|
-
type: "builder.evaluateResult",
|
|
3617
|
-
data: {
|
|
3618
|
-
id,
|
|
3619
|
-
result: finalResult
|
|
3620
|
-
}
|
|
3621
|
-
}, "*");
|
|
3622
|
-
}).catch(console.error);
|
|
3623
|
-
} else {
|
|
3624
|
-
(_b2 = window.parent) == null ? void 0 : _b2.postMessage({
|
|
3625
|
-
type: "builder.evaluateResult",
|
|
3626
|
-
data: {
|
|
3627
|
-
result,
|
|
3628
|
-
id
|
|
3629
|
-
}
|
|
3630
|
-
}, "*");
|
|
3631
|
-
}
|
|
3632
|
-
}
|
|
3633
|
-
break;
|
|
3634
|
-
}
|
|
2906
|
+
return null;
|
|
2907
|
+
}
|
|
2908
|
+
const cookieName = `builder.tests.${contentId}`;
|
|
2909
|
+
const variantInCookie = getCookie2(cookieName);
|
|
2910
|
+
const availableIDs = variants.map((vr) => vr.id).concat(contentId);
|
|
2911
|
+
if (variantInCookie && availableIDs.includes(variantInCookie)) {
|
|
2912
|
+
return variantInCookie;
|
|
2913
|
+
}
|
|
2914
|
+
let n = 0;
|
|
2915
|
+
const random = Math.random();
|
|
2916
|
+
for (let i = 0; i < variants.length; i++) {
|
|
2917
|
+
const variant = variants[i];
|
|
2918
|
+
const testRatio = variant.testRatio;
|
|
2919
|
+
n += testRatio;
|
|
2920
|
+
if (random < n) {
|
|
2921
|
+
setCookie2(cookieName, variant.id);
|
|
2922
|
+
return variant.id;
|
|
3635
2923
|
}
|
|
3636
|
-
}
|
|
2924
|
+
}
|
|
2925
|
+
setCookie2(cookieName, contentId);
|
|
2926
|
+
return contentId;
|
|
2927
|
+
}
|
|
2928
|
+
const winningVariantId = getAndSetVariantId2();
|
|
2929
|
+
const styleEl = document.currentScript?.previousElementSibling;
|
|
2930
|
+
if (isHydrationTarget2) {
|
|
2931
|
+
styleEl.remove();
|
|
2932
|
+
const thisScriptEl = document.currentScript;
|
|
2933
|
+
thisScriptEl?.remove();
|
|
2934
|
+
} else {
|
|
2935
|
+
const newStyleStr = variants.concat({
|
|
2936
|
+
id: contentId
|
|
2937
|
+
}).filter((variant) => variant.id !== winningVariantId).map((value) => {
|
|
2938
|
+
return `.variant-${value.id} { display: none; }
|
|
2939
|
+
`;
|
|
2940
|
+
}).join("");
|
|
2941
|
+
styleEl.innerHTML = newStyleStr;
|
|
3637
2942
|
}
|
|
3638
|
-
};
|
|
3639
|
-
|
|
3640
|
-
// src/functions/track/interaction.js
|
|
3641
|
-
function round(num) {
|
|
3642
|
-
return Math.round(num * 1e3) / 1e3;
|
|
3643
2943
|
}
|
|
3644
|
-
|
|
3645
|
-
if (!
|
|
3646
|
-
return
|
|
2944
|
+
function bldrCntntScrpt(variantContentId, defaultContentId, isHydrationTarget2) {
|
|
2945
|
+
if (!navigator.cookieEnabled) {
|
|
2946
|
+
return;
|
|
3647
2947
|
}
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
} while (parent2 = parent2.parentElement);
|
|
3658
|
-
return null;
|
|
3659
|
-
};
|
|
3660
|
-
var findBuilderParent = (target) => findParentElement(target, (el) => {
|
|
3661
|
-
const id = el.getAttribute("builder-id") || el.id;
|
|
3662
|
-
return Boolean((id == null ? void 0 : id.indexOf("builder-")) === 0);
|
|
3663
|
-
});
|
|
3664
|
-
var computeOffset = ({
|
|
3665
|
-
event,
|
|
3666
|
-
target
|
|
3667
|
-
}) => {
|
|
3668
|
-
const targetRect = target.getBoundingClientRect();
|
|
3669
|
-
const xOffset = event.clientX - targetRect.left;
|
|
3670
|
-
const yOffset = event.clientY - targetRect.top;
|
|
3671
|
-
const xRatio = round(xOffset / targetRect.width);
|
|
3672
|
-
const yRatio = round(yOffset / targetRect.height);
|
|
3673
|
-
return {
|
|
3674
|
-
x: xRatio,
|
|
3675
|
-
y: yRatio
|
|
3676
|
-
};
|
|
3677
|
-
};
|
|
3678
|
-
var getInteractionPropertiesForEvent = (event) => {
|
|
3679
|
-
const target = event.target;
|
|
3680
|
-
const targetBuilderElement = target && findBuilderParent(target);
|
|
3681
|
-
const builderId = (targetBuilderElement == null ? void 0 : targetBuilderElement.getAttribute("builder-id")) || (targetBuilderElement == null ? void 0 : targetBuilderElement.id);
|
|
3682
|
-
return {
|
|
3683
|
-
targetBuilderElement: builderId || void 0,
|
|
3684
|
-
metadata: {
|
|
3685
|
-
targetOffset: target ? computeOffset({
|
|
3686
|
-
event,
|
|
3687
|
-
target
|
|
3688
|
-
}) : void 0,
|
|
3689
|
-
builderTargetOffset: targetBuilderElement ? computeOffset({
|
|
3690
|
-
event,
|
|
3691
|
-
target: targetBuilderElement
|
|
3692
|
-
}) : void 0,
|
|
3693
|
-
builderElementIndex: targetBuilderElement && builderId ? [].slice.call(document.getElementsByClassName(builderId)).indexOf(targetBuilderElement) : void 0
|
|
2948
|
+
function getCookie2(name) {
|
|
2949
|
+
const nameEQ = name + "=";
|
|
2950
|
+
const ca = document.cookie.split(";");
|
|
2951
|
+
for (let i = 0; i < ca.length; i++) {
|
|
2952
|
+
let c = ca[i];
|
|
2953
|
+
while (c.charAt(0) === " ")
|
|
2954
|
+
c = c.substring(1, c.length);
|
|
2955
|
+
if (c.indexOf(nameEQ) === 0)
|
|
2956
|
+
return c.substring(nameEQ.length, c.length);
|
|
3694
2957
|
}
|
|
3695
|
-
|
|
3696
|
-
}
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
enumerable: true,
|
|
3705
|
-
configurable: true,
|
|
3706
|
-
writable: true,
|
|
3707
|
-
value
|
|
3708
|
-
}) : obj[key] = value;
|
|
3709
|
-
var __spreadValues14 = (a, b) => {
|
|
3710
|
-
for (var prop in b || (b = {}))
|
|
3711
|
-
if (__hasOwnProp14.call(b, prop))
|
|
3712
|
-
__defNormalProp14(a, prop, b[prop]);
|
|
3713
|
-
if (__getOwnPropSymbols14)
|
|
3714
|
-
for (var prop of __getOwnPropSymbols14(b)) {
|
|
3715
|
-
if (__propIsEnum14.call(b, prop))
|
|
3716
|
-
__defNormalProp14(a, prop, b[prop]);
|
|
2958
|
+
return null;
|
|
2959
|
+
}
|
|
2960
|
+
const cookieName = `builder.tests.${defaultContentId}`;
|
|
2961
|
+
const variantId = getCookie2(cookieName);
|
|
2962
|
+
const parentDiv = document.currentScript?.parentElement;
|
|
2963
|
+
const variantIsDefaultContent = variantContentId === defaultContentId;
|
|
2964
|
+
if (variantId === variantContentId) {
|
|
2965
|
+
if (variantIsDefaultContent) {
|
|
2966
|
+
return;
|
|
3717
2967
|
}
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
}
|
|
3728
|
-
};
|
|
3729
|
-
var rejected = (value) => {
|
|
3730
|
-
try {
|
|
3731
|
-
step(generator.throw(value));
|
|
3732
|
-
} catch (e) {
|
|
3733
|
-
reject(e);
|
|
2968
|
+
parentDiv?.removeAttribute("hidden");
|
|
2969
|
+
parentDiv?.removeAttribute("aria-hidden");
|
|
2970
|
+
} else {
|
|
2971
|
+
if (variantIsDefaultContent) {
|
|
2972
|
+
if (isHydrationTarget2) {
|
|
2973
|
+
parentDiv?.remove();
|
|
2974
|
+
} else {
|
|
2975
|
+
parentDiv?.setAttribute("hidden", "true");
|
|
2976
|
+
parentDiv?.setAttribute("aria-hidden", "true");
|
|
3734
2977
|
}
|
|
3735
|
-
};
|
|
3736
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
3737
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
3738
|
-
});
|
|
3739
|
-
};
|
|
3740
|
-
var BUILDER_STORE_PREFIX = "builder.tests";
|
|
3741
|
-
var getContentTestKey = (id) => `${BUILDER_STORE_PREFIX}.${id}`;
|
|
3742
|
-
var getContentVariationCookie = ({
|
|
3743
|
-
contentId
|
|
3744
|
-
}) => getCookie({
|
|
3745
|
-
name: getContentTestKey(contentId),
|
|
3746
|
-
canTrack: true
|
|
3747
|
-
});
|
|
3748
|
-
var getContentVariationCookieSync = ({
|
|
3749
|
-
contentId
|
|
3750
|
-
}) => getCookieSync({
|
|
3751
|
-
name: getContentTestKey(contentId),
|
|
3752
|
-
canTrack: true
|
|
3753
|
-
});
|
|
3754
|
-
var setContentVariationCookie = ({
|
|
3755
|
-
contentId,
|
|
3756
|
-
value
|
|
3757
|
-
}) => setCookie({
|
|
3758
|
-
name: getContentTestKey(contentId),
|
|
3759
|
-
value,
|
|
3760
|
-
canTrack: true
|
|
3761
|
-
});
|
|
3762
|
-
var checkIsBuilderContentWithVariations = (item) => checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
|
|
3763
|
-
var getRandomVariationId = ({
|
|
3764
|
-
id,
|
|
3765
|
-
variations
|
|
3766
|
-
}) => {
|
|
3767
|
-
var _a;
|
|
3768
|
-
let n = 0;
|
|
3769
|
-
const random = Math.random();
|
|
3770
|
-
for (const id2 in variations) {
|
|
3771
|
-
const testRatio = (_a = variations[id2]) == null ? void 0 : _a.testRatio;
|
|
3772
|
-
n += testRatio;
|
|
3773
|
-
if (random < n) {
|
|
3774
|
-
return id2;
|
|
3775
2978
|
}
|
|
2979
|
+
return;
|
|
3776
2980
|
}
|
|
3777
|
-
return
|
|
2981
|
+
return;
|
|
2982
|
+
}
|
|
2983
|
+
var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
|
|
2984
|
+
var isHydrationTarget = getIsHydrationTarget(TARGET);
|
|
2985
|
+
var AB_TEST_FN_NAME = "builderIoAbTest";
|
|
2986
|
+
var CONTENT_FN_NAME = "builderIoRenderContent";
|
|
2987
|
+
var getScriptString = () => {
|
|
2988
|
+
const fnStr = bldrAbTest.toString().replace(/\s+/g, " ");
|
|
2989
|
+
const fnStr2 = bldrCntntScrpt.toString().replace(/\s+/g, " ");
|
|
2990
|
+
return `
|
|
2991
|
+
window.${AB_TEST_FN_NAME} = ${fnStr}
|
|
2992
|
+
window.${CONTENT_FN_NAME} = ${fnStr2}
|
|
2993
|
+
`;
|
|
3778
2994
|
};
|
|
3779
|
-
var
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
contentId: args.id,
|
|
3783
|
-
value: randomVariationId
|
|
3784
|
-
}).catch((err) => {
|
|
3785
|
-
logger.error("could not store A/B test variation: ", err);
|
|
3786
|
-
});
|
|
3787
|
-
return randomVariationId;
|
|
2995
|
+
var getVariantsScriptString = (variants, contentId) => {
|
|
2996
|
+
return `
|
|
2997
|
+
window.${AB_TEST_FN_NAME}("${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget})`;
|
|
3788
2998
|
};
|
|
3789
|
-
var
|
|
3790
|
-
|
|
3791
|
-
|
|
2999
|
+
var getRenderContentScriptString = ({
|
|
3000
|
+
contentId,
|
|
3001
|
+
variationId
|
|
3792
3002
|
}) => {
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
return {
|
|
3796
|
-
testVariationId: item.id,
|
|
3797
|
-
testVariationName: "Default"
|
|
3798
|
-
};
|
|
3799
|
-
} else {
|
|
3800
|
-
return {
|
|
3801
|
-
data: variationValue.data,
|
|
3802
|
-
testVariationId: variationValue.id,
|
|
3803
|
-
testVariationName: variationValue.name || (variationValue.id === item.id ? "Default" : "")
|
|
3804
|
-
};
|
|
3805
|
-
}
|
|
3003
|
+
return `
|
|
3004
|
+
window.${CONTENT_FN_NAME}("${variationId}", "${contentId}", ${isHydrationTarget})`;
|
|
3806
3005
|
};
|
|
3807
|
-
var
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3006
|
+
var _tmpl$14 = /* @__PURE__ */ template(`<script>`);
|
|
3007
|
+
function InlinedScript(props) {
|
|
3008
|
+
return (() => {
|
|
3009
|
+
const _el$ = _tmpl$14();
|
|
3010
|
+
effect((_p$) => {
|
|
3011
|
+
const _v$ = props.scriptStr, _v$2 = props.id;
|
|
3012
|
+
_v$ !== _p$._v$ && (_el$.innerHTML = _p$._v$ = _v$);
|
|
3013
|
+
_v$2 !== _p$._v$2 && setAttribute(_el$, "id", _p$._v$2 = _v$2);
|
|
3014
|
+
return _p$;
|
|
3015
|
+
}, {
|
|
3016
|
+
_v$: void 0,
|
|
3017
|
+
_v$2: void 0
|
|
3018
|
+
});
|
|
3019
|
+
return _el$;
|
|
3020
|
+
})();
|
|
3021
|
+
}
|
|
3022
|
+
var inlined_script_default = InlinedScript;
|
|
3023
|
+
|
|
3024
|
+
// src/helpers/preview-lru-cache/get.ts
|
|
3025
|
+
function getPreviewContent(_searchParams) {
|
|
3026
|
+
return void 0;
|
|
3027
|
+
}
|
|
3028
|
+
|
|
3029
|
+
// src/functions/get-global-this.ts
|
|
3030
|
+
function getGlobalThis() {
|
|
3031
|
+
if (typeof globalThis !== "undefined") {
|
|
3032
|
+
return globalThis;
|
|
3818
3033
|
}
|
|
3819
|
-
if (
|
|
3820
|
-
return
|
|
3034
|
+
if (typeof window !== "undefined") {
|
|
3035
|
+
return window;
|
|
3821
3036
|
}
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
}) || getAndSetVariantId({
|
|
3825
|
-
variations: item.variations,
|
|
3826
|
-
id: item.id
|
|
3827
|
-
});
|
|
3828
|
-
const variationValue = getTestFields({
|
|
3829
|
-
item,
|
|
3830
|
-
testGroupId
|
|
3831
|
-
});
|
|
3832
|
-
return __spreadValues14(__spreadValues14({}, item), variationValue);
|
|
3833
|
-
};
|
|
3834
|
-
var handleABTesting = (_0) => __async4(void 0, [_0], function* ({
|
|
3835
|
-
item,
|
|
3836
|
-
canTrack
|
|
3837
|
-
}) {
|
|
3838
|
-
if (!canTrack) {
|
|
3839
|
-
return item;
|
|
3037
|
+
if (typeof global !== "undefined") {
|
|
3038
|
+
return global;
|
|
3840
3039
|
}
|
|
3841
|
-
if (
|
|
3842
|
-
return
|
|
3040
|
+
if (typeof self !== "undefined") {
|
|
3041
|
+
return self;
|
|
3843
3042
|
}
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
});
|
|
3847
|
-
const testGroupId = cookieValue || getAndSetVariantId({
|
|
3848
|
-
variations: item.variations,
|
|
3849
|
-
id: item.id
|
|
3850
|
-
});
|
|
3851
|
-
const variationValue = getTestFields({
|
|
3852
|
-
item,
|
|
3853
|
-
testGroupId
|
|
3854
|
-
});
|
|
3855
|
-
return __spreadValues14(__spreadValues14({}, item), variationValue);
|
|
3856
|
-
});
|
|
3857
|
-
|
|
3858
|
-
// src/helpers/canTrack.js
|
|
3859
|
-
var getDefaultCanTrack = (canTrack) => checkIsDefined(canTrack) ? canTrack : true;
|
|
3043
|
+
return globalThis;
|
|
3044
|
+
}
|
|
3860
3045
|
|
|
3861
|
-
// src/
|
|
3862
|
-
function
|
|
3863
|
-
|
|
3046
|
+
// src/functions/get-fetch.ts
|
|
3047
|
+
function getFetch() {
|
|
3048
|
+
const globalFetch = getGlobalThis().fetch;
|
|
3049
|
+
if (typeof globalFetch === "undefined") {
|
|
3050
|
+
throw new Error("Builder SDK could not find a global `fetch` function");
|
|
3051
|
+
}
|
|
3052
|
+
return globalFetch;
|
|
3864
3053
|
}
|
|
3054
|
+
var fetch2 = getFetch();
|
|
3865
3055
|
|
|
3866
|
-
// src/helpers/flatten.
|
|
3867
|
-
var __defProp15 = Object.defineProperty;
|
|
3868
|
-
var __defProps11 = Object.defineProperties;
|
|
3869
|
-
var __getOwnPropDescs11 = Object.getOwnPropertyDescriptors;
|
|
3870
|
-
var __getOwnPropSymbols15 = Object.getOwnPropertySymbols;
|
|
3871
|
-
var __hasOwnProp15 = Object.prototype.hasOwnProperty;
|
|
3872
|
-
var __propIsEnum15 = Object.prototype.propertyIsEnumerable;
|
|
3873
|
-
var __defNormalProp15 = (obj, key, value) => key in obj ? __defProp15(obj, key, {
|
|
3874
|
-
enumerable: true,
|
|
3875
|
-
configurable: true,
|
|
3876
|
-
writable: true,
|
|
3877
|
-
value
|
|
3878
|
-
}) : obj[key] = value;
|
|
3879
|
-
var __spreadValues15 = (a, b) => {
|
|
3880
|
-
for (var prop in b || (b = {}))
|
|
3881
|
-
if (__hasOwnProp15.call(b, prop))
|
|
3882
|
-
__defNormalProp15(a, prop, b[prop]);
|
|
3883
|
-
if (__getOwnPropSymbols15)
|
|
3884
|
-
for (var prop of __getOwnPropSymbols15(b)) {
|
|
3885
|
-
if (__propIsEnum15.call(b, prop))
|
|
3886
|
-
__defNormalProp15(a, prop, b[prop]);
|
|
3887
|
-
}
|
|
3888
|
-
return a;
|
|
3889
|
-
};
|
|
3890
|
-
var __spreadProps11 = (a, b) => __defProps11(a, __getOwnPropDescs11(b));
|
|
3056
|
+
// src/helpers/flatten.ts
|
|
3891
3057
|
function flatten(object, path = null, separator = ".") {
|
|
3892
3058
|
return Object.keys(object).reduce((acc, key) => {
|
|
3893
3059
|
const value = object[key];
|
|
3894
3060
|
const newPath = [path, key].filter(Boolean).join(separator);
|
|
3895
3061
|
const isObject = [typeof value === "object", value !== null, !(Array.isArray(value) && value.length === 0)].every(Boolean);
|
|
3896
|
-
return isObject ?
|
|
3062
|
+
return isObject ? {
|
|
3063
|
+
...acc,
|
|
3064
|
+
...flatten(value, newPath, separator)
|
|
3065
|
+
} : {
|
|
3066
|
+
...acc,
|
|
3897
3067
|
[newPath]: value
|
|
3898
|
-
}
|
|
3068
|
+
};
|
|
3899
3069
|
}, {});
|
|
3900
3070
|
}
|
|
3901
3071
|
|
|
3902
|
-
// src/
|
|
3072
|
+
// src/types/api-version.ts
|
|
3073
|
+
var DEFAULT_API_VERSION = "v3";
|
|
3074
|
+
|
|
3075
|
+
// src/functions/get-builder-search-params/index.ts
|
|
3903
3076
|
var BUILDER_SEARCHPARAMS_PREFIX = "builder.";
|
|
3904
3077
|
var BUILDER_OPTIONS_PREFIX = "options.";
|
|
3905
3078
|
var convertSearchParamsToQueryObject = (searchParams) => {
|
|
@@ -3932,31 +3105,7 @@ var getBuilderSearchParamsFromWindow = () => {
|
|
|
3932
3105
|
};
|
|
3933
3106
|
var normalizeSearchParams = (searchParams) => searchParams instanceof URLSearchParams ? convertSearchParamsToQueryObject(searchParams) : searchParams;
|
|
3934
3107
|
|
|
3935
|
-
// src/
|
|
3936
|
-
var DEFAULT_API_VERSION = "v3";
|
|
3937
|
-
|
|
3938
|
-
// src/functions/get-content/generate-content-url.js
|
|
3939
|
-
var __defProp16 = Object.defineProperty;
|
|
3940
|
-
var __getOwnPropSymbols16 = Object.getOwnPropertySymbols;
|
|
3941
|
-
var __hasOwnProp16 = Object.prototype.hasOwnProperty;
|
|
3942
|
-
var __propIsEnum16 = Object.prototype.propertyIsEnumerable;
|
|
3943
|
-
var __defNormalProp16 = (obj, key, value) => key in obj ? __defProp16(obj, key, {
|
|
3944
|
-
enumerable: true,
|
|
3945
|
-
configurable: true,
|
|
3946
|
-
writable: true,
|
|
3947
|
-
value
|
|
3948
|
-
}) : obj[key] = value;
|
|
3949
|
-
var __spreadValues16 = (a, b) => {
|
|
3950
|
-
for (var prop in b || (b = {}))
|
|
3951
|
-
if (__hasOwnProp16.call(b, prop))
|
|
3952
|
-
__defNormalProp16(a, prop, b[prop]);
|
|
3953
|
-
if (__getOwnPropSymbols16)
|
|
3954
|
-
for (var prop of __getOwnPropSymbols16(b)) {
|
|
3955
|
-
if (__propIsEnum16.call(b, prop))
|
|
3956
|
-
__defNormalProp16(a, prop, b[prop]);
|
|
3957
|
-
}
|
|
3958
|
-
return a;
|
|
3959
|
-
};
|
|
3108
|
+
// src/functions/get-content/generate-content-url.ts
|
|
3960
3109
|
var isPositiveNumber = (thing) => typeof thing === "number" && !isNaN(thing) && thing >= 0;
|
|
3961
3110
|
var generateContentUrl = (options) => {
|
|
3962
3111
|
let {
|
|
@@ -4014,7 +3163,10 @@ var generateContentUrl = (options) => {
|
|
|
4014
3163
|
url.searchParams.set(key, JSON.stringify(flattened2[key]));
|
|
4015
3164
|
}
|
|
4016
3165
|
}
|
|
4017
|
-
const queryOptions =
|
|
3166
|
+
const queryOptions = {
|
|
3167
|
+
...getBuilderSearchParamsFromWindow(),
|
|
3168
|
+
...normalizeSearchParams(options.options || {})
|
|
3169
|
+
};
|
|
4018
3170
|
const flattened = flatten(queryOptions);
|
|
4019
3171
|
for (const key in flattened) {
|
|
4020
3172
|
url.searchParams.set(key, String(flattened[key]));
|
|
@@ -4033,71 +3185,26 @@ var generateContentUrl = (options) => {
|
|
|
4033
3185
|
return url;
|
|
4034
3186
|
};
|
|
4035
3187
|
|
|
4036
|
-
// src/functions/get-content/index.
|
|
4037
|
-
var __defProp17 = Object.defineProperty;
|
|
4038
|
-
var __defProps12 = Object.defineProperties;
|
|
4039
|
-
var __getOwnPropDescs12 = Object.getOwnPropertyDescriptors;
|
|
4040
|
-
var __getOwnPropSymbols17 = Object.getOwnPropertySymbols;
|
|
4041
|
-
var __hasOwnProp17 = Object.prototype.hasOwnProperty;
|
|
4042
|
-
var __propIsEnum17 = Object.prototype.propertyIsEnumerable;
|
|
4043
|
-
var __defNormalProp17 = (obj, key, value) => key in obj ? __defProp17(obj, key, {
|
|
4044
|
-
enumerable: true,
|
|
4045
|
-
configurable: true,
|
|
4046
|
-
writable: true,
|
|
4047
|
-
value
|
|
4048
|
-
}) : obj[key] = value;
|
|
4049
|
-
var __spreadValues17 = (a, b) => {
|
|
4050
|
-
for (var prop in b || (b = {}))
|
|
4051
|
-
if (__hasOwnProp17.call(b, prop))
|
|
4052
|
-
__defNormalProp17(a, prop, b[prop]);
|
|
4053
|
-
if (__getOwnPropSymbols17)
|
|
4054
|
-
for (var prop of __getOwnPropSymbols17(b)) {
|
|
4055
|
-
if (__propIsEnum17.call(b, prop))
|
|
4056
|
-
__defNormalProp17(a, prop, b[prop]);
|
|
4057
|
-
}
|
|
4058
|
-
return a;
|
|
4059
|
-
};
|
|
4060
|
-
var __spreadProps12 = (a, b) => __defProps12(a, __getOwnPropDescs12(b));
|
|
4061
|
-
var __async5 = (__this, __arguments, generator) => {
|
|
4062
|
-
return new Promise((resolve, reject) => {
|
|
4063
|
-
var fulfilled = (value) => {
|
|
4064
|
-
try {
|
|
4065
|
-
step(generator.next(value));
|
|
4066
|
-
} catch (e) {
|
|
4067
|
-
reject(e);
|
|
4068
|
-
}
|
|
4069
|
-
};
|
|
4070
|
-
var rejected = (value) => {
|
|
4071
|
-
try {
|
|
4072
|
-
step(generator.throw(value));
|
|
4073
|
-
} catch (e) {
|
|
4074
|
-
reject(e);
|
|
4075
|
-
}
|
|
4076
|
-
};
|
|
4077
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
4078
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
4079
|
-
});
|
|
4080
|
-
};
|
|
3188
|
+
// src/functions/get-content/index.ts
|
|
4081
3189
|
var checkContentHasResults = (content) => "results" in content;
|
|
4082
|
-
function fetchOneEntry(options) {
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
}));
|
|
4087
|
-
if (allContent) {
|
|
4088
|
-
return allContent.results[0] || null;
|
|
4089
|
-
}
|
|
4090
|
-
return null;
|
|
3190
|
+
async function fetchOneEntry(options) {
|
|
3191
|
+
const allContent = await fetchEntries({
|
|
3192
|
+
...options,
|
|
3193
|
+
limit: 1
|
|
4091
3194
|
});
|
|
3195
|
+
if (allContent) {
|
|
3196
|
+
return allContent.results[0] || null;
|
|
3197
|
+
}
|
|
3198
|
+
return null;
|
|
4092
3199
|
}
|
|
4093
3200
|
var getContent = fetchOneEntry;
|
|
4094
|
-
var _fetchContent = (options) =>
|
|
3201
|
+
var _fetchContent = async (options) => {
|
|
4095
3202
|
const url = generateContentUrl(options);
|
|
4096
|
-
const res =
|
|
4097
|
-
const content =
|
|
3203
|
+
const res = await fetch2(url.href);
|
|
3204
|
+
const content = await res.json();
|
|
4098
3205
|
return content;
|
|
4099
|
-
}
|
|
4100
|
-
var _processContentResult =
|
|
3206
|
+
};
|
|
3207
|
+
var _processContentResult = async (options, content, url = generateContentUrl(options)) => {
|
|
4101
3208
|
const canTrack = getDefaultCanTrack(options.canTrack);
|
|
4102
3209
|
const isPreviewing2 = url.search.includes(`preview=`);
|
|
4103
3210
|
if (TARGET === "rsc" && isPreviewing2) {
|
|
@@ -4115,7 +3222,7 @@ var _processContentResult = (_0, _1, ..._2) => __async5(void 0, [_0, _1, ..._2],
|
|
|
4115
3222
|
try {
|
|
4116
3223
|
const newResults = [];
|
|
4117
3224
|
for (const item of content.results) {
|
|
4118
|
-
newResults.push(
|
|
3225
|
+
newResults.push(await handleABTesting({
|
|
4119
3226
|
item,
|
|
4120
3227
|
canTrack
|
|
4121
3228
|
}));
|
|
@@ -4125,42 +3232,409 @@ var _processContentResult = (_0, _1, ..._2) => __async5(void 0, [_0, _1, ..._2],
|
|
|
4125
3232
|
logger.error("Could not process A/B tests. ", e);
|
|
4126
3233
|
}
|
|
4127
3234
|
return content;
|
|
3235
|
+
};
|
|
3236
|
+
async function fetchEntries(options) {
|
|
3237
|
+
try {
|
|
3238
|
+
const url = generateContentUrl(options);
|
|
3239
|
+
const content = await _fetchContent(options);
|
|
3240
|
+
if (!checkContentHasResults(content)) {
|
|
3241
|
+
logger.error("Error fetching data. ", {
|
|
3242
|
+
url,
|
|
3243
|
+
content,
|
|
3244
|
+
options
|
|
3245
|
+
});
|
|
3246
|
+
return null;
|
|
3247
|
+
}
|
|
3248
|
+
return _processContentResult(options, content);
|
|
3249
|
+
} catch (error) {
|
|
3250
|
+
logger.error("Error fetching data. ", error);
|
|
3251
|
+
return null;
|
|
3252
|
+
}
|
|
3253
|
+
}
|
|
3254
|
+
var getAllContent = fetchEntries;
|
|
3255
|
+
|
|
3256
|
+
// src/functions/is-previewing.ts
|
|
3257
|
+
function isPreviewing() {
|
|
3258
|
+
if (!isBrowser()) {
|
|
3259
|
+
return false;
|
|
3260
|
+
}
|
|
3261
|
+
if (isEditing()) {
|
|
3262
|
+
return false;
|
|
3263
|
+
}
|
|
3264
|
+
return Boolean(location.search.indexOf("builder.preview=") !== -1);
|
|
3265
|
+
}
|
|
3266
|
+
|
|
3267
|
+
// src/helpers/uuid.ts
|
|
3268
|
+
function uuidv4() {
|
|
3269
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
3270
|
+
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
|
3271
|
+
return v.toString(16);
|
|
3272
|
+
});
|
|
3273
|
+
}
|
|
3274
|
+
function uuid() {
|
|
3275
|
+
return uuidv4().replace(/-/g, "");
|
|
3276
|
+
}
|
|
3277
|
+
|
|
3278
|
+
// src/helpers/sessionId.ts
|
|
3279
|
+
var SESSION_LOCAL_STORAGE_KEY = "builderSessionId";
|
|
3280
|
+
var getSessionId = async ({
|
|
3281
|
+
canTrack
|
|
3282
|
+
}) => {
|
|
3283
|
+
if (!canTrack) {
|
|
3284
|
+
return void 0;
|
|
3285
|
+
}
|
|
3286
|
+
const sessionId = await getCookie({
|
|
3287
|
+
name: SESSION_LOCAL_STORAGE_KEY,
|
|
3288
|
+
canTrack
|
|
3289
|
+
});
|
|
3290
|
+
if (checkIsDefined(sessionId)) {
|
|
3291
|
+
return sessionId;
|
|
3292
|
+
} else {
|
|
3293
|
+
const newSessionId = createSessionId();
|
|
3294
|
+
setSessionId({
|
|
3295
|
+
id: newSessionId,
|
|
3296
|
+
canTrack
|
|
3297
|
+
});
|
|
3298
|
+
return newSessionId;
|
|
3299
|
+
}
|
|
3300
|
+
};
|
|
3301
|
+
var createSessionId = () => uuid();
|
|
3302
|
+
var setSessionId = ({
|
|
3303
|
+
id,
|
|
3304
|
+
canTrack
|
|
3305
|
+
}) => setCookie({
|
|
3306
|
+
name: SESSION_LOCAL_STORAGE_KEY,
|
|
3307
|
+
value: id,
|
|
3308
|
+
canTrack
|
|
3309
|
+
});
|
|
3310
|
+
|
|
3311
|
+
// src/helpers/localStorage.ts
|
|
3312
|
+
var getLocalStorage = () => isBrowser() && typeof localStorage !== "undefined" ? localStorage : void 0;
|
|
3313
|
+
var getLocalStorageItem = ({
|
|
3314
|
+
key,
|
|
3315
|
+
canTrack
|
|
3316
|
+
}) => {
|
|
3317
|
+
try {
|
|
3318
|
+
if (canTrack) {
|
|
3319
|
+
return getLocalStorage()?.getItem(key);
|
|
3320
|
+
}
|
|
3321
|
+
return void 0;
|
|
3322
|
+
} catch (err) {
|
|
3323
|
+
return void 0;
|
|
3324
|
+
}
|
|
3325
|
+
};
|
|
3326
|
+
var setLocalStorageItem = ({
|
|
3327
|
+
key,
|
|
3328
|
+
canTrack,
|
|
3329
|
+
value
|
|
3330
|
+
}) => {
|
|
3331
|
+
try {
|
|
3332
|
+
if (canTrack) {
|
|
3333
|
+
getLocalStorage()?.setItem(key, value);
|
|
3334
|
+
}
|
|
3335
|
+
} catch (err) {
|
|
3336
|
+
}
|
|
3337
|
+
};
|
|
3338
|
+
|
|
3339
|
+
// src/helpers/visitorId.ts
|
|
3340
|
+
var VISITOR_LOCAL_STORAGE_KEY = "builderVisitorId";
|
|
3341
|
+
var getVisitorId = ({
|
|
3342
|
+
canTrack
|
|
3343
|
+
}) => {
|
|
3344
|
+
if (!canTrack) {
|
|
3345
|
+
return void 0;
|
|
3346
|
+
}
|
|
3347
|
+
const visitorId = getLocalStorageItem({
|
|
3348
|
+
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
3349
|
+
canTrack
|
|
3350
|
+
});
|
|
3351
|
+
if (checkIsDefined(visitorId)) {
|
|
3352
|
+
return visitorId;
|
|
3353
|
+
} else {
|
|
3354
|
+
const newVisitorId = createVisitorId();
|
|
3355
|
+
setVisitorId({
|
|
3356
|
+
id: newVisitorId,
|
|
3357
|
+
canTrack
|
|
3358
|
+
});
|
|
3359
|
+
return newVisitorId;
|
|
3360
|
+
}
|
|
3361
|
+
};
|
|
3362
|
+
var createVisitorId = () => uuid();
|
|
3363
|
+
var setVisitorId = ({
|
|
3364
|
+
id,
|
|
3365
|
+
canTrack
|
|
3366
|
+
}) => setLocalStorageItem({
|
|
3367
|
+
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
3368
|
+
value: id,
|
|
3369
|
+
canTrack
|
|
3370
|
+
});
|
|
3371
|
+
|
|
3372
|
+
// src/functions/track/index.ts
|
|
3373
|
+
var getTrackingEventData = async ({
|
|
3374
|
+
canTrack
|
|
3375
|
+
}) => {
|
|
3376
|
+
if (!canTrack) {
|
|
3377
|
+
return {
|
|
3378
|
+
visitorId: void 0,
|
|
3379
|
+
sessionId: void 0
|
|
3380
|
+
};
|
|
3381
|
+
}
|
|
3382
|
+
const sessionId = await getSessionId({
|
|
3383
|
+
canTrack
|
|
3384
|
+
});
|
|
3385
|
+
const visitorId = getVisitorId({
|
|
3386
|
+
canTrack
|
|
3387
|
+
});
|
|
3388
|
+
return {
|
|
3389
|
+
sessionId,
|
|
3390
|
+
visitorId
|
|
3391
|
+
};
|
|
3392
|
+
};
|
|
3393
|
+
var createEvent = async ({
|
|
3394
|
+
type: eventType,
|
|
3395
|
+
canTrack,
|
|
3396
|
+
apiKey,
|
|
3397
|
+
metadata,
|
|
3398
|
+
...properties
|
|
3399
|
+
}) => ({
|
|
3400
|
+
type: eventType,
|
|
3401
|
+
data: {
|
|
3402
|
+
...properties,
|
|
3403
|
+
metadata: {
|
|
3404
|
+
url: location.href,
|
|
3405
|
+
...metadata
|
|
3406
|
+
},
|
|
3407
|
+
...await getTrackingEventData({
|
|
3408
|
+
canTrack
|
|
3409
|
+
}),
|
|
3410
|
+
userAttributes: getUserAttributes(),
|
|
3411
|
+
ownerId: apiKey
|
|
3412
|
+
}
|
|
3413
|
+
});
|
|
3414
|
+
async function _track(eventProps) {
|
|
3415
|
+
if (!eventProps.apiKey) {
|
|
3416
|
+
logger.error("Missing API key for track call. Please provide your API key.");
|
|
3417
|
+
return;
|
|
3418
|
+
}
|
|
3419
|
+
if (!eventProps.canTrack) {
|
|
3420
|
+
return;
|
|
3421
|
+
}
|
|
3422
|
+
if (isEditing()) {
|
|
3423
|
+
return;
|
|
3424
|
+
}
|
|
3425
|
+
if (!(isBrowser() || TARGET === "reactNative")) {
|
|
3426
|
+
return;
|
|
3427
|
+
}
|
|
3428
|
+
return fetch(`https://cdn.builder.io/api/v1/track`, {
|
|
3429
|
+
method: "POST",
|
|
3430
|
+
body: JSON.stringify({
|
|
3431
|
+
events: [await createEvent(eventProps)]
|
|
3432
|
+
}),
|
|
3433
|
+
headers: {
|
|
3434
|
+
"content-type": "application/json"
|
|
3435
|
+
},
|
|
3436
|
+
mode: "cors"
|
|
3437
|
+
}).catch((err) => {
|
|
3438
|
+
});
|
|
3439
|
+
}
|
|
3440
|
+
var track = (args) => _track({
|
|
3441
|
+
...args,
|
|
3442
|
+
canTrack: true
|
|
3443
|
+
});
|
|
3444
|
+
|
|
3445
|
+
// src/functions/track/interaction.ts
|
|
3446
|
+
function round(num) {
|
|
3447
|
+
return Math.round(num * 1e3) / 1e3;
|
|
3448
|
+
}
|
|
3449
|
+
var findParentElement = (target, callback, checkElement = true) => {
|
|
3450
|
+
if (!(target instanceof HTMLElement)) {
|
|
3451
|
+
return null;
|
|
3452
|
+
}
|
|
3453
|
+
let parent2 = checkElement ? target : target.parentElement;
|
|
3454
|
+
do {
|
|
3455
|
+
if (!parent2) {
|
|
3456
|
+
return null;
|
|
3457
|
+
}
|
|
3458
|
+
const matches = callback(parent2);
|
|
3459
|
+
if (matches) {
|
|
3460
|
+
return parent2;
|
|
3461
|
+
}
|
|
3462
|
+
} while (parent2 = parent2.parentElement);
|
|
3463
|
+
return null;
|
|
3464
|
+
};
|
|
3465
|
+
var findBuilderParent = (target) => findParentElement(target, (el) => {
|
|
3466
|
+
const id = el.getAttribute("builder-id") || el.id;
|
|
3467
|
+
return Boolean(id?.indexOf("builder-") === 0);
|
|
4128
3468
|
});
|
|
4129
|
-
|
|
4130
|
-
|
|
3469
|
+
var computeOffset = ({
|
|
3470
|
+
event,
|
|
3471
|
+
target
|
|
3472
|
+
}) => {
|
|
3473
|
+
const targetRect = target.getBoundingClientRect();
|
|
3474
|
+
const xOffset = event.clientX - targetRect.left;
|
|
3475
|
+
const yOffset = event.clientY - targetRect.top;
|
|
3476
|
+
const xRatio = round(xOffset / targetRect.width);
|
|
3477
|
+
const yRatio = round(yOffset / targetRect.height);
|
|
3478
|
+
return {
|
|
3479
|
+
x: xRatio,
|
|
3480
|
+
y: yRatio
|
|
3481
|
+
};
|
|
3482
|
+
};
|
|
3483
|
+
var getInteractionPropertiesForEvent = (event) => {
|
|
3484
|
+
const target = event.target;
|
|
3485
|
+
const targetBuilderElement = target && findBuilderParent(target);
|
|
3486
|
+
const builderId = targetBuilderElement?.getAttribute("builder-id") || targetBuilderElement?.id;
|
|
3487
|
+
return {
|
|
3488
|
+
targetBuilderElement: builderId || void 0,
|
|
3489
|
+
metadata: {
|
|
3490
|
+
targetOffset: target ? computeOffset({
|
|
3491
|
+
event,
|
|
3492
|
+
target
|
|
3493
|
+
}) : void 0,
|
|
3494
|
+
builderTargetOffset: targetBuilderElement ? computeOffset({
|
|
3495
|
+
event,
|
|
3496
|
+
target: targetBuilderElement
|
|
3497
|
+
}) : void 0,
|
|
3498
|
+
builderElementIndex: targetBuilderElement && builderId ? [].slice.call(document.getElementsByClassName(builderId)).indexOf(targetBuilderElement) : void 0
|
|
3499
|
+
}
|
|
3500
|
+
};
|
|
3501
|
+
};
|
|
3502
|
+
|
|
3503
|
+
// src/constants/sdk-version.ts
|
|
3504
|
+
var SDK_VERSION = "0.7.2";
|
|
3505
|
+
|
|
3506
|
+
// src/functions/register.ts
|
|
3507
|
+
var registry = {};
|
|
3508
|
+
function register(type, info) {
|
|
3509
|
+
let typeList = registry[type];
|
|
3510
|
+
if (!typeList) {
|
|
3511
|
+
typeList = registry[type] = [];
|
|
3512
|
+
}
|
|
3513
|
+
typeList.push(info);
|
|
3514
|
+
if (isBrowser()) {
|
|
3515
|
+
const message = {
|
|
3516
|
+
type: "builder.register",
|
|
3517
|
+
data: {
|
|
3518
|
+
type,
|
|
3519
|
+
info
|
|
3520
|
+
}
|
|
3521
|
+
};
|
|
4131
3522
|
try {
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
logger.error("Error fetching data. ", {
|
|
4136
|
-
url,
|
|
4137
|
-
content,
|
|
4138
|
-
options
|
|
4139
|
-
});
|
|
4140
|
-
return null;
|
|
3523
|
+
parent.postMessage(message, "*");
|
|
3524
|
+
if (parent !== window) {
|
|
3525
|
+
window.postMessage(message, "*");
|
|
4141
3526
|
}
|
|
4142
|
-
|
|
4143
|
-
} catch (error) {
|
|
4144
|
-
logger.error("Error fetching data. ", error);
|
|
4145
|
-
return null;
|
|
3527
|
+
} catch (err) {
|
|
4146
3528
|
}
|
|
4147
|
-
}
|
|
3529
|
+
}
|
|
4148
3530
|
}
|
|
4149
|
-
var getAllContent = fetchEntries;
|
|
4150
3531
|
|
|
4151
|
-
// src/
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
3532
|
+
// src/scripts/init-editing.ts
|
|
3533
|
+
var registerInsertMenu = () => {
|
|
3534
|
+
register("insertMenu", {
|
|
3535
|
+
name: "_default",
|
|
3536
|
+
default: true,
|
|
3537
|
+
items: [{
|
|
3538
|
+
name: "Box"
|
|
3539
|
+
}, {
|
|
3540
|
+
name: "Text"
|
|
3541
|
+
}, {
|
|
3542
|
+
name: "Image"
|
|
3543
|
+
}, {
|
|
3544
|
+
name: "Columns"
|
|
3545
|
+
}, ...TARGET === "reactNative" ? [] : [{
|
|
3546
|
+
name: "Core:Section"
|
|
3547
|
+
}, {
|
|
3548
|
+
name: "Core:Button"
|
|
3549
|
+
}, {
|
|
3550
|
+
name: "Embed"
|
|
3551
|
+
}, {
|
|
3552
|
+
name: "Custom Code"
|
|
3553
|
+
}]]
|
|
3554
|
+
});
|
|
3555
|
+
};
|
|
3556
|
+
var isSetupForEditing = false;
|
|
3557
|
+
var setupBrowserForEditing = (options = {}) => {
|
|
3558
|
+
if (isSetupForEditing) {
|
|
3559
|
+
return;
|
|
4155
3560
|
}
|
|
4156
|
-
|
|
4157
|
-
|
|
3561
|
+
isSetupForEditing = true;
|
|
3562
|
+
if (isBrowser()) {
|
|
3563
|
+
window.parent?.postMessage({
|
|
3564
|
+
type: "builder.sdkInfo",
|
|
3565
|
+
data: {
|
|
3566
|
+
target: TARGET,
|
|
3567
|
+
version: SDK_VERSION,
|
|
3568
|
+
supportsPatchUpdates: false,
|
|
3569
|
+
// Supports builder-model="..." attribute which is needed to
|
|
3570
|
+
// scope our '+ add block' button styling
|
|
3571
|
+
supportsAddBlockScoping: true,
|
|
3572
|
+
supportsCustomBreakpoints: true
|
|
3573
|
+
}
|
|
3574
|
+
}, "*");
|
|
3575
|
+
window.parent?.postMessage({
|
|
3576
|
+
type: "builder.updateContent",
|
|
3577
|
+
data: {
|
|
3578
|
+
options
|
|
3579
|
+
}
|
|
3580
|
+
}, "*");
|
|
3581
|
+
window.addEventListener("message", ({
|
|
3582
|
+
data
|
|
3583
|
+
}) => {
|
|
3584
|
+
if (!data?.type) {
|
|
3585
|
+
return;
|
|
3586
|
+
}
|
|
3587
|
+
switch (data.type) {
|
|
3588
|
+
case "builder.evaluate": {
|
|
3589
|
+
const text = data.data.text;
|
|
3590
|
+
const args = data.data.arguments || [];
|
|
3591
|
+
const id = data.data.id;
|
|
3592
|
+
const fn = new Function(text);
|
|
3593
|
+
let result;
|
|
3594
|
+
let error = null;
|
|
3595
|
+
try {
|
|
3596
|
+
result = fn.apply(null, args);
|
|
3597
|
+
} catch (err) {
|
|
3598
|
+
error = err;
|
|
3599
|
+
}
|
|
3600
|
+
if (error) {
|
|
3601
|
+
window.parent?.postMessage({
|
|
3602
|
+
type: "builder.evaluateError",
|
|
3603
|
+
data: {
|
|
3604
|
+
id,
|
|
3605
|
+
error: error.message
|
|
3606
|
+
}
|
|
3607
|
+
}, "*");
|
|
3608
|
+
} else {
|
|
3609
|
+
if (result && typeof result.then === "function") {
|
|
3610
|
+
result.then((finalResult) => {
|
|
3611
|
+
window.parent?.postMessage({
|
|
3612
|
+
type: "builder.evaluateResult",
|
|
3613
|
+
data: {
|
|
3614
|
+
id,
|
|
3615
|
+
result: finalResult
|
|
3616
|
+
}
|
|
3617
|
+
}, "*");
|
|
3618
|
+
}).catch(console.error);
|
|
3619
|
+
} else {
|
|
3620
|
+
window.parent?.postMessage({
|
|
3621
|
+
type: "builder.evaluateResult",
|
|
3622
|
+
data: {
|
|
3623
|
+
result,
|
|
3624
|
+
id
|
|
3625
|
+
}
|
|
3626
|
+
}, "*");
|
|
3627
|
+
}
|
|
3628
|
+
}
|
|
3629
|
+
break;
|
|
3630
|
+
}
|
|
3631
|
+
}
|
|
3632
|
+
});
|
|
4158
3633
|
}
|
|
4159
|
-
|
|
4160
|
-
}
|
|
3634
|
+
};
|
|
4161
3635
|
|
|
4162
|
-
// src/components/content/components/enable-editor.
|
|
4163
|
-
var _tmpl$
|
|
3636
|
+
// src/components/content/components/enable-editor.tsx
|
|
3637
|
+
var _tmpl$15 = /* @__PURE__ */ template(`<div>`);
|
|
4164
3638
|
function EnableEditor(props) {
|
|
4165
3639
|
const [forceReRenderCount, setForceReRenderCount] = createSignal(0);
|
|
4166
3640
|
createSignal(0);
|
|
@@ -4386,7 +3860,7 @@ function EnableEditor(props) {
|
|
|
4386
3860
|
emitStateUpdate();
|
|
4387
3861
|
}
|
|
4388
3862
|
createEffect(on(() => [props.builderContextSignal.rootState], onUpdateFn_4));
|
|
4389
|
-
return createComponent(
|
|
3863
|
+
return createComponent(builder_context_default.Provider, {
|
|
4390
3864
|
get value() {
|
|
4391
3865
|
return props.builderContextSignal;
|
|
4392
3866
|
},
|
|
@@ -4396,7 +3870,7 @@ function EnableEditor(props) {
|
|
|
4396
3870
|
return props.builderContextSignal.content;
|
|
4397
3871
|
},
|
|
4398
3872
|
get children() {
|
|
4399
|
-
const _el$ = _tmpl$
|
|
3873
|
+
const _el$ = _tmpl$15();
|
|
4400
3874
|
const _ref$ = elementRef;
|
|
4401
3875
|
typeof _ref$ === "function" ? use(_ref$, _el$) : elementRef = _el$;
|
|
4402
3876
|
spread(_el$, mergeProps({
|
|
@@ -4426,25 +3900,133 @@ function EnableEditor(props) {
|
|
|
4426
3900
|
});
|
|
4427
3901
|
}
|
|
4428
3902
|
var enable_editor_default = EnableEditor;
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
})();
|
|
3903
|
+
|
|
3904
|
+
// src/components/content/components/styles.helpers.ts
|
|
3905
|
+
var getCssFromFont = (font) => {
|
|
3906
|
+
const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
|
|
3907
|
+
const name = family.split(",")[0];
|
|
3908
|
+
const url = font.fileUrl ?? font?.files?.regular;
|
|
3909
|
+
let str = "";
|
|
3910
|
+
if (url && family && name) {
|
|
3911
|
+
str += `
|
|
3912
|
+
@font-face {
|
|
3913
|
+
font-family: "${family}";
|
|
3914
|
+
src: local("${name}"), url('${url}') format('woff2');
|
|
3915
|
+
font-display: fallback;
|
|
3916
|
+
font-weight: 400;
|
|
4444
3917
|
}
|
|
4445
|
-
|
|
3918
|
+
`.trim();
|
|
3919
|
+
}
|
|
3920
|
+
if (font.files) {
|
|
3921
|
+
for (const weight in font.files) {
|
|
3922
|
+
const isNumber = String(Number(weight)) === weight;
|
|
3923
|
+
if (!isNumber) {
|
|
3924
|
+
continue;
|
|
3925
|
+
}
|
|
3926
|
+
const weightUrl = font.files[weight];
|
|
3927
|
+
if (weightUrl && weightUrl !== url) {
|
|
3928
|
+
str += `
|
|
3929
|
+
@font-face {
|
|
3930
|
+
font-family: "${family}";
|
|
3931
|
+
src: url('${weightUrl}') format('woff2');
|
|
3932
|
+
font-display: fallback;
|
|
3933
|
+
font-weight: ${weight};
|
|
3934
|
+
}
|
|
3935
|
+
`.trim();
|
|
3936
|
+
}
|
|
3937
|
+
}
|
|
3938
|
+
}
|
|
3939
|
+
return str;
|
|
3940
|
+
};
|
|
3941
|
+
var getFontCss = ({
|
|
3942
|
+
customFonts
|
|
3943
|
+
}) => {
|
|
3944
|
+
return customFonts?.map((font) => getCssFromFont(font))?.join(" ") || "";
|
|
3945
|
+
};
|
|
3946
|
+
var getCss = ({
|
|
3947
|
+
cssCode,
|
|
3948
|
+
contentId
|
|
3949
|
+
}) => {
|
|
3950
|
+
if (!cssCode) {
|
|
3951
|
+
return "";
|
|
3952
|
+
}
|
|
3953
|
+
if (!contentId) {
|
|
3954
|
+
return cssCode;
|
|
3955
|
+
}
|
|
3956
|
+
return cssCode?.replace(/&/g, `div[builder-content-id="${contentId}"]`) || "";
|
|
3957
|
+
};
|
|
3958
|
+
|
|
3959
|
+
// src/components/content/components/styles.tsx
|
|
3960
|
+
function ContentStyles(props) {
|
|
3961
|
+
const [injectedStyles, setInjectedStyles] = createSignal(`
|
|
3962
|
+
${getCss({
|
|
3963
|
+
cssCode: props.cssCode,
|
|
3964
|
+
contentId: props.contentId
|
|
3965
|
+
})}
|
|
3966
|
+
${getFontCss({
|
|
3967
|
+
customFonts: props.customFonts
|
|
3968
|
+
})}
|
|
3969
|
+
|
|
3970
|
+
.builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
|
|
3971
|
+
margin: 0;
|
|
3972
|
+
}
|
|
3973
|
+
.builder-text > p, .builder-text > .builder-paragraph {
|
|
3974
|
+
color: inherit;
|
|
3975
|
+
line-height: inherit;
|
|
3976
|
+
letter-spacing: inherit;
|
|
3977
|
+
font-weight: inherit;
|
|
3978
|
+
font-size: inherit;
|
|
3979
|
+
text-align: inherit;
|
|
3980
|
+
font-family: inherit;
|
|
3981
|
+
}
|
|
3982
|
+
`.trim());
|
|
3983
|
+
return createComponent(inlined_styles_default, {
|
|
3984
|
+
get styles() {
|
|
3985
|
+
return injectedStyles();
|
|
3986
|
+
}
|
|
3987
|
+
});
|
|
3988
|
+
}
|
|
3989
|
+
var styles_default = ContentStyles;
|
|
3990
|
+
|
|
3991
|
+
// src/components/content/content.helpers.ts
|
|
3992
|
+
var getContextStateInitialValue = ({
|
|
3993
|
+
content,
|
|
3994
|
+
data,
|
|
3995
|
+
locale
|
|
3996
|
+
}) => {
|
|
3997
|
+
const defaultValues = {};
|
|
3998
|
+
content?.data?.inputs?.forEach((input) => {
|
|
3999
|
+
if (input.name && input.defaultValue !== void 0 && content?.data?.state && content.data.state[input.name] === void 0) {
|
|
4000
|
+
defaultValues[input.name] = input.defaultValue;
|
|
4001
|
+
}
|
|
4002
|
+
});
|
|
4003
|
+
const stateToUse = {
|
|
4004
|
+
...content?.data?.state,
|
|
4005
|
+
...data,
|
|
4006
|
+
...locale ? {
|
|
4007
|
+
locale
|
|
4008
|
+
} : {}
|
|
4009
|
+
};
|
|
4010
|
+
return {
|
|
4011
|
+
...defaultValues,
|
|
4012
|
+
...stateToUse
|
|
4013
|
+
};
|
|
4014
|
+
};
|
|
4015
|
+
var getContentInitialValue = ({
|
|
4016
|
+
content,
|
|
4017
|
+
data
|
|
4018
|
+
}) => {
|
|
4019
|
+
return !content ? void 0 : {
|
|
4020
|
+
...content,
|
|
4021
|
+
data: {
|
|
4022
|
+
...content?.data,
|
|
4023
|
+
...data
|
|
4024
|
+
},
|
|
4025
|
+
meta: content?.meta
|
|
4026
|
+
};
|
|
4027
|
+
};
|
|
4446
4028
|
|
|
4447
|
-
// src/components/content/content.
|
|
4029
|
+
// src/components/content/content.tsx
|
|
4448
4030
|
function ContentComponent(props) {
|
|
4449
4031
|
const [scriptStr, setScriptStr] = createSignal(getRenderContentScriptString({
|
|
4450
4032
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
@@ -4510,7 +4092,7 @@ function ContentComponent(props) {
|
|
|
4510
4092
|
rootState: newRootState
|
|
4511
4093
|
}));
|
|
4512
4094
|
}
|
|
4513
|
-
return createComponent(
|
|
4095
|
+
return createComponent(components_context_default.Provider, {
|
|
4514
4096
|
get value() {
|
|
4515
4097
|
return {
|
|
4516
4098
|
registeredComponents: registeredComponents()
|
|
@@ -4599,7 +4181,7 @@ function ContentComponent(props) {
|
|
|
4599
4181
|
}
|
|
4600
4182
|
var content_default = ContentComponent;
|
|
4601
4183
|
|
|
4602
|
-
// src/components/content-variants/content-variants.
|
|
4184
|
+
// src/components/content-variants/content-variants.tsx
|
|
4603
4185
|
function ContentVariants(props) {
|
|
4604
4186
|
const [shouldRenderVariants, setShouldRenderVariants] = createSignal(checkShouldRunVariants({
|
|
4605
4187
|
canTrack: getDefaultCanTrack(props.canTrack),
|
|
@@ -4624,6 +4206,7 @@ function ContentVariants(props) {
|
|
|
4624
4206
|
});
|
|
4625
4207
|
}
|
|
4626
4208
|
onMount(() => {
|
|
4209
|
+
setShouldRenderVariants(false);
|
|
4627
4210
|
});
|
|
4628
4211
|
return [createComponent(Show, {
|
|
4629
4212
|
get when() {
|
|
@@ -4747,70 +4330,31 @@ function ContentVariants(props) {
|
|
|
4747
4330
|
}
|
|
4748
4331
|
var content_variants_default = ContentVariants;
|
|
4749
4332
|
|
|
4750
|
-
// src/blocks/symbol/symbol.helpers.
|
|
4751
|
-
var
|
|
4752
|
-
var __getOwnPropSymbols18 = Object.getOwnPropertySymbols;
|
|
4753
|
-
var __hasOwnProp18 = Object.prototype.hasOwnProperty;
|
|
4754
|
-
var __propIsEnum18 = Object.prototype.propertyIsEnumerable;
|
|
4755
|
-
var __defNormalProp18 = (obj, key, value) => key in obj ? __defProp18(obj, key, {
|
|
4756
|
-
enumerable: true,
|
|
4757
|
-
configurable: true,
|
|
4758
|
-
writable: true,
|
|
4759
|
-
value
|
|
4760
|
-
}) : obj[key] = value;
|
|
4761
|
-
var __spreadValues18 = (a, b) => {
|
|
4762
|
-
for (var prop in b || (b = {}))
|
|
4763
|
-
if (__hasOwnProp18.call(b, prop))
|
|
4764
|
-
__defNormalProp18(a, prop, b[prop]);
|
|
4765
|
-
if (__getOwnPropSymbols18)
|
|
4766
|
-
for (var prop of __getOwnPropSymbols18(b)) {
|
|
4767
|
-
if (__propIsEnum18.call(b, prop))
|
|
4768
|
-
__defNormalProp18(a, prop, b[prop]);
|
|
4769
|
-
}
|
|
4770
|
-
return a;
|
|
4771
|
-
};
|
|
4772
|
-
var __async6 = (__this, __arguments, generator) => {
|
|
4773
|
-
return new Promise((resolve, reject) => {
|
|
4774
|
-
var fulfilled = (value) => {
|
|
4775
|
-
try {
|
|
4776
|
-
step(generator.next(value));
|
|
4777
|
-
} catch (e) {
|
|
4778
|
-
reject(e);
|
|
4779
|
-
}
|
|
4780
|
-
};
|
|
4781
|
-
var rejected = (value) => {
|
|
4782
|
-
try {
|
|
4783
|
-
step(generator.throw(value));
|
|
4784
|
-
} catch (e) {
|
|
4785
|
-
reject(e);
|
|
4786
|
-
}
|
|
4787
|
-
};
|
|
4788
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
4789
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
4790
|
-
});
|
|
4791
|
-
};
|
|
4792
|
-
var fetchSymbolContent = (_0) => __async6(void 0, [_0], function* ({
|
|
4333
|
+
// src/blocks/symbol/symbol.helpers.ts
|
|
4334
|
+
var fetchSymbolContent = async ({
|
|
4793
4335
|
builderContextValue,
|
|
4794
4336
|
symbol
|
|
4795
|
-
}) {
|
|
4796
|
-
if (
|
|
4797
|
-
|
|
4337
|
+
}) => {
|
|
4338
|
+
if (symbol?.model && // This is a hack, we should not need to check for this, but it is needed for Svelte.
|
|
4339
|
+
builderContextValue?.apiKey) {
|
|
4340
|
+
return fetchOneEntry({
|
|
4798
4341
|
model: symbol.model,
|
|
4799
4342
|
apiKey: builderContextValue.apiKey,
|
|
4800
|
-
apiVersion: builderContextValue.apiVersion
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4343
|
+
apiVersion: builderContextValue.apiVersion,
|
|
4344
|
+
...symbol?.entry && {
|
|
4345
|
+
query: {
|
|
4346
|
+
id: symbol.entry
|
|
4347
|
+
}
|
|
4804
4348
|
}
|
|
4805
|
-
})
|
|
4349
|
+
}).catch((err) => {
|
|
4806
4350
|
logger.error("Could not fetch symbol content: ", err);
|
|
4807
4351
|
return void 0;
|
|
4808
4352
|
});
|
|
4809
4353
|
}
|
|
4810
4354
|
return void 0;
|
|
4811
|
-
}
|
|
4355
|
+
};
|
|
4812
4356
|
|
|
4813
|
-
// src/blocks/symbol/symbol.
|
|
4357
|
+
// src/blocks/symbol/symbol.tsx
|
|
4814
4358
|
var _tmpl$16 = /* @__PURE__ */ template(`<div>`);
|
|
4815
4359
|
function Symbol(props) {
|
|
4816
4360
|
const [contentToUse, setContentToUse] = createSignal(props.symbol?.content);
|
|
@@ -4876,11 +4420,11 @@ function Symbol(props) {
|
|
|
4876
4420
|
}
|
|
4877
4421
|
var symbol_default = Symbol;
|
|
4878
4422
|
|
|
4879
|
-
// src/index-helpers/blocks-exports.
|
|
4423
|
+
// src/index-helpers/blocks-exports.ts
|
|
4880
4424
|
var RenderBlocks = blocks_default;
|
|
4881
4425
|
var RenderContent = content_variants_default;
|
|
4882
4426
|
|
|
4883
|
-
// src/functions/set-editor-settings.
|
|
4427
|
+
// src/functions/set-editor-settings.ts
|
|
4884
4428
|
var settings = {};
|
|
4885
4429
|
function setEditorSettings(newSettings) {
|
|
4886
4430
|
if (isBrowser()) {
|
|
@@ -4893,67 +4437,26 @@ function setEditorSettings(newSettings) {
|
|
|
4893
4437
|
}
|
|
4894
4438
|
}
|
|
4895
4439
|
|
|
4896
|
-
// src/functions/fetch-builder-props.
|
|
4897
|
-
var
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
var __hasOwnProp19 = Object.prototype.hasOwnProperty;
|
|
4902
|
-
var __propIsEnum19 = Object.prototype.propertyIsEnumerable;
|
|
4903
|
-
var __defNormalProp19 = (obj, key, value) => key in obj ? __defProp19(obj, key, {
|
|
4904
|
-
enumerable: true,
|
|
4905
|
-
configurable: true,
|
|
4906
|
-
writable: true,
|
|
4907
|
-
value
|
|
4908
|
-
}) : obj[key] = value;
|
|
4909
|
-
var __spreadValues19 = (a, b) => {
|
|
4910
|
-
for (var prop in b || (b = {}))
|
|
4911
|
-
if (__hasOwnProp19.call(b, prop))
|
|
4912
|
-
__defNormalProp19(a, prop, b[prop]);
|
|
4913
|
-
if (__getOwnPropSymbols19)
|
|
4914
|
-
for (var prop of __getOwnPropSymbols19(b)) {
|
|
4915
|
-
if (__propIsEnum19.call(b, prop))
|
|
4916
|
-
__defNormalProp19(a, prop, b[prop]);
|
|
4917
|
-
}
|
|
4918
|
-
return a;
|
|
4919
|
-
};
|
|
4920
|
-
var __spreadProps13 = (a, b) => __defProps13(a, __getOwnPropDescs13(b));
|
|
4921
|
-
var __async7 = (__this, __arguments, generator) => {
|
|
4922
|
-
return new Promise((resolve, reject) => {
|
|
4923
|
-
var fulfilled = (value) => {
|
|
4924
|
-
try {
|
|
4925
|
-
step(generator.next(value));
|
|
4926
|
-
} catch (e) {
|
|
4927
|
-
reject(e);
|
|
4928
|
-
}
|
|
4929
|
-
};
|
|
4930
|
-
var rejected = (value) => {
|
|
4931
|
-
try {
|
|
4932
|
-
step(generator.throw(value));
|
|
4933
|
-
} catch (e) {
|
|
4934
|
-
reject(e);
|
|
4935
|
-
}
|
|
4936
|
-
};
|
|
4937
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
4938
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
4939
|
-
});
|
|
4940
|
-
};
|
|
4941
|
-
var fetchBuilderProps = (_args) => __async7(void 0, null, function* () {
|
|
4942
|
-
var _a, _b, _c;
|
|
4943
|
-
const urlPath = _args.path || ((_a = _args.url) == null ? void 0 : _a.pathname) || ((_b = _args.userAttributes) == null ? void 0 : _b.urlPath);
|
|
4944
|
-
const getContentArgs = __spreadProps13(__spreadValues19({}, _args), {
|
|
4440
|
+
// src/functions/fetch-builder-props.ts
|
|
4441
|
+
var fetchBuilderProps = async (_args) => {
|
|
4442
|
+
const urlPath = _args.path || _args.url?.pathname || _args.userAttributes?.urlPath;
|
|
4443
|
+
const getContentArgs = {
|
|
4444
|
+
..._args,
|
|
4945
4445
|
apiKey: _args.apiKey,
|
|
4946
4446
|
model: _args.model || "page",
|
|
4947
|
-
userAttributes:
|
|
4948
|
-
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
|
|
4447
|
+
userAttributes: {
|
|
4448
|
+
..._args.userAttributes,
|
|
4449
|
+
...urlPath ? {
|
|
4450
|
+
urlPath
|
|
4451
|
+
} : {}
|
|
4452
|
+
},
|
|
4453
|
+
options: getBuilderSearchParams(_args.searchParams || _args.url?.searchParams || _args.options)
|
|
4454
|
+
};
|
|
4952
4455
|
return {
|
|
4953
4456
|
apiKey: getContentArgs.apiKey,
|
|
4954
4457
|
model: getContentArgs.model,
|
|
4955
|
-
content:
|
|
4458
|
+
content: await fetchOneEntry(getContentArgs)
|
|
4956
4459
|
};
|
|
4957
|
-
}
|
|
4460
|
+
};
|
|
4958
4461
|
|
|
4959
4462
|
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 };
|