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