@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.jsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/blocks/button/button.
|
|
1
|
+
// src/blocks/button/button.tsx
|
|
2
2
|
import { Show } from "solid-js";
|
|
3
3
|
import { css } from "solid-styled-components";
|
|
4
4
|
function Button(props) {
|
|
@@ -13,80 +13,57 @@ function Button(props) {
|
|
|
13
13
|
>{props.text}</button>}
|
|
14
14
|
when={props.link}
|
|
15
15
|
><a
|
|
16
|
-
role="button"
|
|
17
16
|
{...{}}
|
|
18
17
|
{...props.attributes}
|
|
19
18
|
href={props.link}
|
|
20
19
|
target={props.openLinkInNewTab ? "_blank" : void 0}
|
|
20
|
+
role="button"
|
|
21
21
|
>{props.text}</a></Show>;
|
|
22
22
|
}
|
|
23
23
|
var button_default = Button;
|
|
24
24
|
|
|
25
|
-
// src/blocks/columns/columns.
|
|
26
|
-
import { Show as Show7, For as For4, createSignal as
|
|
25
|
+
// src/blocks/columns/columns.tsx
|
|
26
|
+
import { Show as Show7, For as For4, createSignal as createSignal5 } from "solid-js";
|
|
27
27
|
import { css as css3 } from "solid-styled-components";
|
|
28
28
|
|
|
29
|
-
// src/components/blocks/blocks.
|
|
29
|
+
// src/components/blocks/blocks.tsx
|
|
30
30
|
import { useContext, Show as Show6, For as For3 } from "solid-js";
|
|
31
31
|
|
|
32
|
-
// src/
|
|
33
|
-
import {
|
|
32
|
+
// src/context/builder.context.ts
|
|
33
|
+
import { createContext } from "solid-js";
|
|
34
|
+
var builder_context_default = createContext({
|
|
35
|
+
content: null,
|
|
36
|
+
context: {},
|
|
37
|
+
localState: void 0,
|
|
38
|
+
rootSetState() {
|
|
39
|
+
},
|
|
40
|
+
rootState: {},
|
|
41
|
+
apiKey: null,
|
|
42
|
+
apiVersion: void 0,
|
|
43
|
+
componentInfos: {},
|
|
44
|
+
inheritedStyles: {}
|
|
45
|
+
});
|
|
34
46
|
|
|
35
|
-
// src/
|
|
36
|
-
|
|
47
|
+
// src/context/components.context.ts
|
|
48
|
+
import { createContext as createContext2 } from "solid-js";
|
|
49
|
+
var components_context_default = createContext2({ registeredComponents: {} });
|
|
37
50
|
|
|
38
|
-
// src/
|
|
39
|
-
|
|
40
|
-
small: {
|
|
41
|
-
min: 320,
|
|
42
|
-
default: 321,
|
|
43
|
-
max: 640
|
|
44
|
-
},
|
|
45
|
-
medium: {
|
|
46
|
-
min: 641,
|
|
47
|
-
default: 642,
|
|
48
|
-
max: 991
|
|
49
|
-
},
|
|
50
|
-
large: {
|
|
51
|
-
min: 990,
|
|
52
|
-
default: 991,
|
|
53
|
-
max: 1200
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
var getMaxWidthQueryForSize = (size, sizeValues = SIZES) => `@media (max-width: ${sizeValues[size].max}px)`;
|
|
57
|
-
var getSizesForBreakpoints = ({
|
|
58
|
-
small,
|
|
59
|
-
medium
|
|
60
|
-
}) => {
|
|
61
|
-
const newSizes = fastClone(SIZES);
|
|
62
|
-
if (!small || !medium) {
|
|
63
|
-
return newSizes;
|
|
64
|
-
}
|
|
65
|
-
const smallMin = Math.floor(small / 2);
|
|
66
|
-
newSizes.small = {
|
|
67
|
-
max: small,
|
|
68
|
-
min: smallMin,
|
|
69
|
-
default: smallMin + 1
|
|
70
|
-
};
|
|
71
|
-
const mediumMin = newSizes.small.max + 1;
|
|
72
|
-
newSizes.medium = {
|
|
73
|
-
max: medium,
|
|
74
|
-
min: mediumMin,
|
|
75
|
-
default: mediumMin + 1
|
|
76
|
-
};
|
|
77
|
-
const largeMin = newSizes.medium.max + 1;
|
|
78
|
-
newSizes.large = {
|
|
79
|
-
max: 2e3,
|
|
80
|
-
min: largeMin,
|
|
81
|
-
default: largeMin + 1
|
|
82
|
-
};
|
|
83
|
-
return newSizes;
|
|
84
|
-
};
|
|
51
|
+
// src/components/block/block.tsx
|
|
52
|
+
import { Show as Show5, For as For2, createSignal as createSignal4 } from "solid-js";
|
|
85
53
|
|
|
86
|
-
// src/
|
|
87
|
-
|
|
54
|
+
// src/functions/get-block-component-options.ts
|
|
55
|
+
function getBlockComponentOptions(block) {
|
|
56
|
+
return {
|
|
57
|
+
...block.component?.options,
|
|
58
|
+
...block.options,
|
|
59
|
+
/**
|
|
60
|
+
* Our built-in components frequently make use of the block, so we provide all of it under `builderBlock`
|
|
61
|
+
*/
|
|
62
|
+
builderBlock: block
|
|
63
|
+
};
|
|
64
|
+
}
|
|
88
65
|
|
|
89
|
-
// src/helpers/logger.
|
|
66
|
+
// src/helpers/logger.ts
|
|
90
67
|
var MSG_PREFIX = "[Builder.io]: ";
|
|
91
68
|
var logger = {
|
|
92
69
|
log: (...message) => console.log(MSG_PREFIX, ...message),
|
|
@@ -95,22 +72,25 @@ var logger = {
|
|
|
95
72
|
debug: (...message) => console.debug(MSG_PREFIX, ...message)
|
|
96
73
|
};
|
|
97
74
|
|
|
98
|
-
// src/functions/is-browser.
|
|
75
|
+
// src/functions/is-browser.ts
|
|
99
76
|
function isBrowser() {
|
|
100
77
|
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
101
78
|
}
|
|
102
79
|
|
|
103
|
-
// src/
|
|
80
|
+
// src/constants/target.ts
|
|
81
|
+
var TARGET = "solid";
|
|
82
|
+
|
|
83
|
+
// src/functions/is-iframe.ts
|
|
104
84
|
function isIframe() {
|
|
105
85
|
return isBrowser() && window.self !== window.top;
|
|
106
86
|
}
|
|
107
87
|
|
|
108
|
-
// src/functions/is-editing.
|
|
88
|
+
// src/functions/is-editing.ts
|
|
109
89
|
function isEditing() {
|
|
110
90
|
return isIframe() && (TARGET === "reactNative" || window.location.search.indexOf("builder.frameEditing=") !== -1);
|
|
111
91
|
}
|
|
112
92
|
|
|
113
|
-
// src/functions/track/helpers.
|
|
93
|
+
// src/functions/track/helpers.ts
|
|
114
94
|
var getLocation = () => {
|
|
115
95
|
if (TARGET === "reactNative") {
|
|
116
96
|
return null;
|
|
@@ -151,13 +131,13 @@ var getUserAttributes = () => {
|
|
|
151
131
|
const isTablet = userAgent.match(/Tablet|iPad/i);
|
|
152
132
|
const url = getLocation();
|
|
153
133
|
return {
|
|
154
|
-
urlPath: url
|
|
155
|
-
host:
|
|
134
|
+
urlPath: url?.pathname,
|
|
135
|
+
host: url?.host || url?.hostname,
|
|
156
136
|
device: isTablet ? "tablet" : isMobile.any() ? "mobile" : "desktop"
|
|
157
137
|
};
|
|
158
138
|
};
|
|
159
139
|
|
|
160
|
-
// src/functions/evaluate/helpers.
|
|
140
|
+
// src/functions/evaluate/helpers.ts
|
|
161
141
|
var getFunctionArguments = ({
|
|
162
142
|
builder,
|
|
163
143
|
context,
|
|
@@ -167,6 +147,7 @@ var getFunctionArguments = ({
|
|
|
167
147
|
return Object.entries({
|
|
168
148
|
state,
|
|
169
149
|
Builder: builder,
|
|
150
|
+
// legacy
|
|
170
151
|
builder,
|
|
171
152
|
context,
|
|
172
153
|
event
|
|
@@ -181,12 +162,15 @@ var getBuilderGlobals = () => ({
|
|
|
181
162
|
var parseCode = (code, {
|
|
182
163
|
isExpression = true
|
|
183
164
|
}) => {
|
|
184
|
-
const useReturn =
|
|
165
|
+
const useReturn = (
|
|
166
|
+
// we disable this for cases where we definitely don't want a return
|
|
167
|
+
isExpression && !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "))
|
|
168
|
+
);
|
|
185
169
|
const useCode = useReturn ? `return (${code});` : code;
|
|
186
170
|
return useCode;
|
|
187
171
|
};
|
|
188
172
|
|
|
189
|
-
// src/functions/evaluate/browser-runtime/browser.
|
|
173
|
+
// src/functions/evaluate/browser-runtime/browser.ts
|
|
190
174
|
var runInBrowser = ({
|
|
191
175
|
code,
|
|
192
176
|
builder,
|
|
@@ -220,21 +204,16 @@ function flattenState(rootState, localState, rootSetState) {
|
|
|
220
204
|
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
221
205
|
}
|
|
222
206
|
rootState[prop] = value;
|
|
223
|
-
rootSetState
|
|
207
|
+
rootSetState?.(rootState);
|
|
224
208
|
return true;
|
|
225
209
|
}
|
|
226
210
|
});
|
|
227
211
|
}
|
|
228
212
|
|
|
229
|
-
// src/functions/
|
|
230
|
-
var
|
|
231
|
-
var safeDynamicRequire = noop;
|
|
232
|
-
try {
|
|
233
|
-
safeDynamicRequire = eval("require");
|
|
234
|
-
} catch (error) {
|
|
235
|
-
}
|
|
213
|
+
// src/functions/fast-clone.ts
|
|
214
|
+
var fastClone = (obj) => JSON.parse(JSON.stringify(obj));
|
|
236
215
|
|
|
237
|
-
// src/functions/set.
|
|
216
|
+
// src/functions/set.ts
|
|
238
217
|
var set = (obj, _path, value) => {
|
|
239
218
|
if (Object(obj) !== obj) {
|
|
240
219
|
return obj;
|
|
@@ -244,31 +223,16 @@ var set = (obj, _path, value) => {
|
|
|
244
223
|
return obj;
|
|
245
224
|
};
|
|
246
225
|
|
|
247
|
-
// src/functions/evaluate/node-runtime/
|
|
248
|
-
|
|
249
|
-
var
|
|
250
|
-
var
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
writable: true,
|
|
258
|
-
value
|
|
259
|
-
}) : obj[key] = value;
|
|
260
|
-
var __spreadValues = (a, b) => {
|
|
261
|
-
for (var prop in b || (b = {}))
|
|
262
|
-
if (__hasOwnProp.call(b, prop))
|
|
263
|
-
__defNormalProp(a, prop, b[prop]);
|
|
264
|
-
if (__getOwnPropSymbols)
|
|
265
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
266
|
-
if (__propIsEnum.call(b, prop))
|
|
267
|
-
__defNormalProp(a, prop, b[prop]);
|
|
268
|
-
}
|
|
269
|
-
return a;
|
|
270
|
-
};
|
|
271
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
226
|
+
// src/functions/evaluate/node-runtime/safeDynamicRequire.ts
|
|
227
|
+
import { createRequire } from "node:module";
|
|
228
|
+
var noop = () => null;
|
|
229
|
+
var safeDynamicRequire = noop;
|
|
230
|
+
try {
|
|
231
|
+
safeDynamicRequire = createRequire(import.meta.url);
|
|
232
|
+
} catch (error) {
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// src/functions/evaluate/node-runtime/node-runtime.ts
|
|
272
236
|
var ivm = safeDynamicRequire("isolated-vm");
|
|
273
237
|
var getSyncValName = (key) => `bldr_${key}_sync`;
|
|
274
238
|
var BUILDER_SET_STATE_NAME = "BUILDER_SET_STATE";
|
|
@@ -336,7 +300,10 @@ var runInNode = ({
|
|
|
336
300
|
rootSetState,
|
|
337
301
|
rootState
|
|
338
302
|
}) => {
|
|
339
|
-
const state = fastClone(
|
|
303
|
+
const state = fastClone({
|
|
304
|
+
...rootState,
|
|
305
|
+
...localState
|
|
306
|
+
});
|
|
340
307
|
const args = getFunctionArguments({
|
|
341
308
|
builder,
|
|
342
309
|
context,
|
|
@@ -351,12 +318,16 @@ var runInNode = ({
|
|
|
351
318
|
});
|
|
352
319
|
jail.setSync(BUILDER_SET_STATE_NAME, function(key, value) {
|
|
353
320
|
set(rootState, key, value);
|
|
354
|
-
rootSetState
|
|
321
|
+
rootSetState?.(rootState);
|
|
355
322
|
});
|
|
356
323
|
args.forEach(([key, arg]) => {
|
|
357
|
-
const val = typeof arg === "object" ? new ivm.Reference(
|
|
358
|
-
|
|
359
|
-
|
|
324
|
+
const val = typeof arg === "object" ? new ivm.Reference(
|
|
325
|
+
// workaround: methods with default values for arguments is not being cloned over
|
|
326
|
+
key === "builder" ? {
|
|
327
|
+
...arg,
|
|
328
|
+
getUserAttributes: () => arg.getUserAttributes()
|
|
329
|
+
} : arg
|
|
330
|
+
) : null;
|
|
360
331
|
jail.setSync(getSyncValName(key), val);
|
|
361
332
|
});
|
|
362
333
|
jail.setSync(INJECTED_IVM_GLOBAL, ivm);
|
|
@@ -373,10 +344,10 @@ var runInNode = ({
|
|
|
373
344
|
}
|
|
374
345
|
};
|
|
375
346
|
|
|
376
|
-
// src/functions/evaluate/choose-eval.
|
|
347
|
+
// src/functions/evaluate/choose-eval.ts
|
|
377
348
|
var chooseBrowserOrServerEval = (args) => isBrowser() ? runInBrowser(args) : runInNode(args);
|
|
378
349
|
|
|
379
|
-
// src/functions/evaluate/evaluate.
|
|
350
|
+
// src/functions/evaluate/evaluate.ts
|
|
380
351
|
function evaluate({
|
|
381
352
|
code,
|
|
382
353
|
context,
|
|
@@ -411,36 +382,12 @@ function evaluate({
|
|
|
411
382
|
}
|
|
412
383
|
}
|
|
413
384
|
|
|
414
|
-
// src/functions/transform-block.
|
|
385
|
+
// src/functions/transform-block.ts
|
|
415
386
|
function transformBlock(block) {
|
|
416
387
|
return block;
|
|
417
388
|
}
|
|
418
389
|
|
|
419
|
-
// src/functions/get-processed-block.
|
|
420
|
-
var __defProp2 = Object.defineProperty;
|
|
421
|
-
var __defProps2 = Object.defineProperties;
|
|
422
|
-
var __getOwnPropDescs2 = Object.getOwnPropertyDescriptors;
|
|
423
|
-
var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
|
|
424
|
-
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
425
|
-
var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
|
|
426
|
-
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, {
|
|
427
|
-
enumerable: true,
|
|
428
|
-
configurable: true,
|
|
429
|
-
writable: true,
|
|
430
|
-
value
|
|
431
|
-
}) : obj[key] = value;
|
|
432
|
-
var __spreadValues2 = (a, b) => {
|
|
433
|
-
for (var prop in b || (b = {}))
|
|
434
|
-
if (__hasOwnProp2.call(b, prop))
|
|
435
|
-
__defNormalProp2(a, prop, b[prop]);
|
|
436
|
-
if (__getOwnPropSymbols2)
|
|
437
|
-
for (var prop of __getOwnPropSymbols2(b)) {
|
|
438
|
-
if (__propIsEnum2.call(b, prop))
|
|
439
|
-
__defNormalProp2(a, prop, b[prop]);
|
|
440
|
-
}
|
|
441
|
-
return a;
|
|
442
|
-
};
|
|
443
|
-
var __spreadProps2 = (a, b) => __defProps2(a, __getOwnPropDescs2(b));
|
|
390
|
+
// src/functions/get-processed-block.ts
|
|
444
391
|
var evaluateBindings = ({
|
|
445
392
|
block,
|
|
446
393
|
context,
|
|
@@ -452,10 +399,15 @@ var evaluateBindings = ({
|
|
|
452
399
|
return block;
|
|
453
400
|
}
|
|
454
401
|
const copy = fastClone(block);
|
|
455
|
-
const copied =
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
402
|
+
const copied = {
|
|
403
|
+
...copy,
|
|
404
|
+
properties: {
|
|
405
|
+
...copy.properties
|
|
406
|
+
},
|
|
407
|
+
actions: {
|
|
408
|
+
...copy.actions
|
|
409
|
+
}
|
|
410
|
+
};
|
|
459
411
|
for (const binding in block.bindings) {
|
|
460
412
|
const expression = block.bindings[binding];
|
|
461
413
|
const value = evaluate({
|
|
@@ -491,13 +443,135 @@ function getProcessedBlock({
|
|
|
491
443
|
}
|
|
492
444
|
}
|
|
493
445
|
|
|
494
|
-
// src/
|
|
446
|
+
// src/components/block/block.helpers.ts
|
|
447
|
+
var EMPTY_HTML_ELEMENTS = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
|
|
448
|
+
var isEmptyHtmlElement = (tagName) => {
|
|
449
|
+
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
|
|
450
|
+
};
|
|
451
|
+
var getComponent = ({
|
|
452
|
+
block,
|
|
453
|
+
context,
|
|
454
|
+
registeredComponents
|
|
455
|
+
}) => {
|
|
456
|
+
const componentName = getProcessedBlock({
|
|
457
|
+
block,
|
|
458
|
+
localState: context.localState,
|
|
459
|
+
rootState: context.rootState,
|
|
460
|
+
rootSetState: context.rootSetState,
|
|
461
|
+
context: context.context,
|
|
462
|
+
shouldEvaluateBindings: false
|
|
463
|
+
}).component?.name;
|
|
464
|
+
if (!componentName) {
|
|
465
|
+
return null;
|
|
466
|
+
}
|
|
467
|
+
const ref = registeredComponents[componentName];
|
|
468
|
+
if (!ref) {
|
|
469
|
+
console.warn(`
|
|
470
|
+
Could not find a registered component named "${componentName}".
|
|
471
|
+
If you registered it, is the file that registered it imported by the file that needs to render it?`);
|
|
472
|
+
return void 0;
|
|
473
|
+
} else {
|
|
474
|
+
return ref;
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
var getRepeatItemData = ({
|
|
478
|
+
block,
|
|
479
|
+
context
|
|
480
|
+
}) => {
|
|
481
|
+
const {
|
|
482
|
+
repeat,
|
|
483
|
+
...blockWithoutRepeat
|
|
484
|
+
} = block;
|
|
485
|
+
if (!repeat?.collection) {
|
|
486
|
+
return void 0;
|
|
487
|
+
}
|
|
488
|
+
const itemsArray = evaluate({
|
|
489
|
+
code: repeat.collection,
|
|
490
|
+
localState: context.localState,
|
|
491
|
+
rootState: context.rootState,
|
|
492
|
+
rootSetState: context.rootSetState,
|
|
493
|
+
context: context.context
|
|
494
|
+
});
|
|
495
|
+
if (!Array.isArray(itemsArray)) {
|
|
496
|
+
return void 0;
|
|
497
|
+
}
|
|
498
|
+
const collectionName = repeat.collection.split(".").pop();
|
|
499
|
+
const itemNameToUse = repeat.itemName || (collectionName ? collectionName + "Item" : "item");
|
|
500
|
+
const repeatArray = itemsArray.map((item, index) => ({
|
|
501
|
+
context: {
|
|
502
|
+
...context,
|
|
503
|
+
localState: {
|
|
504
|
+
...context.localState,
|
|
505
|
+
$index: index,
|
|
506
|
+
$item: item,
|
|
507
|
+
[itemNameToUse]: item,
|
|
508
|
+
[`$${itemNameToUse}Index`]: index
|
|
509
|
+
}
|
|
510
|
+
},
|
|
511
|
+
block: blockWithoutRepeat
|
|
512
|
+
}));
|
|
513
|
+
return repeatArray;
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
// src/components/block/components/block-styles.tsx
|
|
517
|
+
import { Show as Show2 } from "solid-js";
|
|
518
|
+
|
|
519
|
+
// src/constants/device-sizes.ts
|
|
520
|
+
var SIZES = {
|
|
521
|
+
small: {
|
|
522
|
+
min: 320,
|
|
523
|
+
default: 321,
|
|
524
|
+
max: 640
|
|
525
|
+
},
|
|
526
|
+
medium: {
|
|
527
|
+
min: 641,
|
|
528
|
+
default: 642,
|
|
529
|
+
max: 991
|
|
530
|
+
},
|
|
531
|
+
large: {
|
|
532
|
+
min: 990,
|
|
533
|
+
default: 991,
|
|
534
|
+
max: 1200
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
var getMaxWidthQueryForSize = (size, sizeValues = SIZES) => `@media (max-width: ${sizeValues[size].max}px)`;
|
|
538
|
+
var getSizesForBreakpoints = ({
|
|
539
|
+
small,
|
|
540
|
+
medium
|
|
541
|
+
}) => {
|
|
542
|
+
const newSizes = fastClone(SIZES);
|
|
543
|
+
if (!small || !medium) {
|
|
544
|
+
return newSizes;
|
|
545
|
+
}
|
|
546
|
+
const smallMin = Math.floor(small / 2);
|
|
547
|
+
newSizes.small = {
|
|
548
|
+
max: small,
|
|
549
|
+
min: smallMin,
|
|
550
|
+
default: smallMin + 1
|
|
551
|
+
};
|
|
552
|
+
const mediumMin = newSizes.small.max + 1;
|
|
553
|
+
newSizes.medium = {
|
|
554
|
+
max: medium,
|
|
555
|
+
min: mediumMin,
|
|
556
|
+
default: mediumMin + 1
|
|
557
|
+
};
|
|
558
|
+
const largeMin = newSizes.medium.max + 1;
|
|
559
|
+
newSizes.large = {
|
|
560
|
+
max: 2e3,
|
|
561
|
+
// TODO: decide upper limit
|
|
562
|
+
min: largeMin,
|
|
563
|
+
default: largeMin + 1
|
|
564
|
+
};
|
|
565
|
+
return newSizes;
|
|
566
|
+
};
|
|
567
|
+
|
|
568
|
+
// src/functions/camel-to-kebab-case.ts
|
|
495
569
|
var camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
496
570
|
|
|
497
|
-
// src/helpers/nullable.
|
|
571
|
+
// src/helpers/nullable.ts
|
|
498
572
|
var checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
|
|
499
573
|
|
|
500
|
-
// src/helpers/css.
|
|
574
|
+
// src/helpers/css.ts
|
|
501
575
|
var convertStyleMapToCSSArray = (style) => {
|
|
502
576
|
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
503
577
|
if (typeof value === "string") {
|
|
@@ -526,13 +600,13 @@ var createCssClass = ({
|
|
|
526
600
|
}
|
|
527
601
|
};
|
|
528
602
|
|
|
529
|
-
// src/components/inlined-styles.
|
|
603
|
+
// src/components/inlined-styles.tsx
|
|
530
604
|
function InlinedStyles(props) {
|
|
531
605
|
return <style innerHTML={props.styles} id={props.id} />;
|
|
532
606
|
}
|
|
533
607
|
var Inlined_styles_default = InlinedStyles;
|
|
534
608
|
|
|
535
|
-
// src/components/block/components/block-styles.
|
|
609
|
+
// src/components/block/components/block-styles.tsx
|
|
536
610
|
function BlockStyles(props) {
|
|
537
611
|
function canShowBlock() {
|
|
538
612
|
const processedBlock = getProcessedBlock({
|
|
@@ -598,66 +672,54 @@ function BlockStyles(props) {
|
|
|
598
672
|
}
|
|
599
673
|
var Block_styles_default = BlockStyles;
|
|
600
674
|
|
|
601
|
-
// src/components/block/block.
|
|
602
|
-
import { Show as
|
|
675
|
+
// src/components/block/components/block-wrapper.tsx
|
|
676
|
+
import { Show as Show3 } from "solid-js";
|
|
677
|
+
import { Dynamic } from "solid-js/web";
|
|
603
678
|
|
|
604
|
-
// src/functions/
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
var __getOwnPropDescs3 = Object.getOwnPropertyDescriptors;
|
|
608
|
-
var __getOwnPropSymbols3 = Object.getOwnPropertySymbols;
|
|
609
|
-
var __hasOwnProp3 = Object.prototype.hasOwnProperty;
|
|
610
|
-
var __propIsEnum3 = Object.prototype.propertyIsEnumerable;
|
|
611
|
-
var __defNormalProp3 = (obj, key, value) => key in obj ? __defProp3(obj, key, {
|
|
612
|
-
enumerable: true,
|
|
613
|
-
configurable: true,
|
|
614
|
-
writable: true,
|
|
615
|
-
value
|
|
616
|
-
}) : obj[key] = value;
|
|
617
|
-
var __spreadValues3 = (a, b) => {
|
|
618
|
-
for (var prop in b || (b = {}))
|
|
619
|
-
if (__hasOwnProp3.call(b, prop))
|
|
620
|
-
__defNormalProp3(a, prop, b[prop]);
|
|
621
|
-
if (__getOwnPropSymbols3)
|
|
622
|
-
for (var prop of __getOwnPropSymbols3(b)) {
|
|
623
|
-
if (__propIsEnum3.call(b, prop))
|
|
624
|
-
__defNormalProp3(a, prop, b[prop]);
|
|
625
|
-
}
|
|
626
|
-
return a;
|
|
627
|
-
};
|
|
628
|
-
var __spreadProps3 = (a, b) => __defProps3(a, __getOwnPropDescs3(b));
|
|
629
|
-
function getBlockComponentOptions(block) {
|
|
630
|
-
var _a;
|
|
631
|
-
return __spreadProps3(__spreadValues3(__spreadValues3({}, (_a = block.component) == null ? void 0 : _a.options), block.options), {
|
|
632
|
-
builderBlock: block
|
|
633
|
-
});
|
|
679
|
+
// src/functions/event-handler-name.ts
|
|
680
|
+
function capitalizeFirstLetter(string) {
|
|
681
|
+
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
634
682
|
}
|
|
683
|
+
var getEventHandlerName = (key) => `on${capitalizeFirstLetter(key)}`;
|
|
635
684
|
|
|
636
|
-
// src/functions/
|
|
637
|
-
var
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
for (var prop of __getOwnPropSymbols4(b)) {
|
|
655
|
-
if (__propIsEnum4.call(b, prop))
|
|
656
|
-
__defNormalProp4(a, prop, b[prop]);
|
|
685
|
+
// src/functions/get-block-actions-handler.ts
|
|
686
|
+
var createEventHandler = (value, options) => (event) => evaluate({
|
|
687
|
+
code: value,
|
|
688
|
+
context: options.context,
|
|
689
|
+
localState: options.localState,
|
|
690
|
+
rootState: options.rootState,
|
|
691
|
+
rootSetState: options.rootSetState,
|
|
692
|
+
event,
|
|
693
|
+
isExpression: false
|
|
694
|
+
});
|
|
695
|
+
|
|
696
|
+
// src/functions/get-block-actions.ts
|
|
697
|
+
function getBlockActions(options) {
|
|
698
|
+
const obj = {};
|
|
699
|
+
const optionActions = options.block.actions ?? {};
|
|
700
|
+
for (const key in optionActions) {
|
|
701
|
+
if (!optionActions.hasOwnProperty(key)) {
|
|
702
|
+
continue;
|
|
657
703
|
}
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
704
|
+
const value = optionActions[key];
|
|
705
|
+
let eventHandlerName = getEventHandlerName(key);
|
|
706
|
+
if (options.stripPrefix) {
|
|
707
|
+
switch (TARGET) {
|
|
708
|
+
case "vue2":
|
|
709
|
+
case "vue3":
|
|
710
|
+
eventHandlerName = eventHandlerName.replace("v-on:", "");
|
|
711
|
+
break;
|
|
712
|
+
case "svelte":
|
|
713
|
+
eventHandlerName = eventHandlerName.replace("on:", "");
|
|
714
|
+
break;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
obj[eventHandlerName] = createEventHandler(value, options);
|
|
718
|
+
}
|
|
719
|
+
return obj;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
// src/functions/sanitize-react-native-block-styles.ts
|
|
661
723
|
var propertiesThatMustBeNumber = /* @__PURE__ */ new Set(["lineHeight"]);
|
|
662
724
|
var displayValues = /* @__PURE__ */ new Set(["flex", "none"]);
|
|
663
725
|
var SHOW_WARNINGS = false;
|
|
@@ -691,46 +753,28 @@ var sanitizeReactNativeBlockStyles = (styles) => {
|
|
|
691
753
|
const newValue = parseFloat(propertyValue);
|
|
692
754
|
const normalizedValue = normalizeNumber(newValue);
|
|
693
755
|
if (normalizedValue) {
|
|
694
|
-
return
|
|
756
|
+
return {
|
|
757
|
+
...acc,
|
|
695
758
|
[key]: normalizedValue
|
|
696
|
-
}
|
|
759
|
+
};
|
|
697
760
|
} else {
|
|
698
761
|
return acc;
|
|
699
762
|
}
|
|
700
763
|
} else if (propertyValue === "0") {
|
|
701
|
-
return
|
|
764
|
+
return {
|
|
765
|
+
...acc,
|
|
702
766
|
[key]: 0
|
|
703
|
-
}
|
|
767
|
+
};
|
|
704
768
|
}
|
|
705
769
|
}
|
|
706
|
-
return
|
|
770
|
+
return {
|
|
771
|
+
...acc,
|
|
707
772
|
[key]: propertyValue
|
|
708
|
-
}
|
|
773
|
+
};
|
|
709
774
|
}, {});
|
|
710
775
|
};
|
|
711
776
|
|
|
712
|
-
// src/functions/get-react-native-block-styles.
|
|
713
|
-
var __defProp5 = Object.defineProperty;
|
|
714
|
-
var __getOwnPropSymbols5 = Object.getOwnPropertySymbols;
|
|
715
|
-
var __hasOwnProp5 = Object.prototype.hasOwnProperty;
|
|
716
|
-
var __propIsEnum5 = Object.prototype.propertyIsEnumerable;
|
|
717
|
-
var __defNormalProp5 = (obj, key, value) => key in obj ? __defProp5(obj, key, {
|
|
718
|
-
enumerable: true,
|
|
719
|
-
configurable: true,
|
|
720
|
-
writable: true,
|
|
721
|
-
value
|
|
722
|
-
}) : obj[key] = value;
|
|
723
|
-
var __spreadValues5 = (a, b) => {
|
|
724
|
-
for (var prop in b || (b = {}))
|
|
725
|
-
if (__hasOwnProp5.call(b, prop))
|
|
726
|
-
__defNormalProp5(a, prop, b[prop]);
|
|
727
|
-
if (__getOwnPropSymbols5)
|
|
728
|
-
for (var prop of __getOwnPropSymbols5(b)) {
|
|
729
|
-
if (__propIsEnum5.call(b, prop))
|
|
730
|
-
__defNormalProp5(a, prop, b[prop]);
|
|
731
|
-
}
|
|
732
|
-
return a;
|
|
733
|
-
};
|
|
777
|
+
// src/functions/get-react-native-block-styles.ts
|
|
734
778
|
function getReactNativeBlockStyles({
|
|
735
779
|
block,
|
|
736
780
|
context,
|
|
@@ -740,41 +784,24 @@ function getReactNativeBlockStyles({
|
|
|
740
784
|
if (!responsiveStyles) {
|
|
741
785
|
return {};
|
|
742
786
|
}
|
|
743
|
-
const styles =
|
|
787
|
+
const styles = {
|
|
788
|
+
// recursively apply inherited styles so that they can be passed down to children `Text` blocks
|
|
789
|
+
...context.inheritedStyles,
|
|
790
|
+
...responsiveStyles.large || {},
|
|
791
|
+
...responsiveStyles.medium || {},
|
|
792
|
+
...responsiveStyles.small || {},
|
|
793
|
+
...blockStyles
|
|
794
|
+
};
|
|
744
795
|
const newStyles = sanitizeReactNativeBlockStyles(styles);
|
|
745
796
|
return newStyles;
|
|
746
797
|
}
|
|
747
798
|
|
|
748
|
-
// src/functions/transform-block-properties.
|
|
799
|
+
// src/functions/transform-block-properties.ts
|
|
749
800
|
function transformBlockProperties(properties) {
|
|
750
801
|
return properties;
|
|
751
802
|
}
|
|
752
803
|
|
|
753
|
-
// src/functions/get-block-properties.
|
|
754
|
-
var __defProp6 = Object.defineProperty;
|
|
755
|
-
var __defProps5 = Object.defineProperties;
|
|
756
|
-
var __getOwnPropDescs5 = Object.getOwnPropertyDescriptors;
|
|
757
|
-
var __getOwnPropSymbols6 = Object.getOwnPropertySymbols;
|
|
758
|
-
var __hasOwnProp6 = Object.prototype.hasOwnProperty;
|
|
759
|
-
var __propIsEnum6 = Object.prototype.propertyIsEnumerable;
|
|
760
|
-
var __defNormalProp6 = (obj, key, value) => key in obj ? __defProp6(obj, key, {
|
|
761
|
-
enumerable: true,
|
|
762
|
-
configurable: true,
|
|
763
|
-
writable: true,
|
|
764
|
-
value
|
|
765
|
-
}) : obj[key] = value;
|
|
766
|
-
var __spreadValues6 = (a, b) => {
|
|
767
|
-
for (var prop in b || (b = {}))
|
|
768
|
-
if (__hasOwnProp6.call(b, prop))
|
|
769
|
-
__defNormalProp6(a, prop, b[prop]);
|
|
770
|
-
if (__getOwnPropSymbols6)
|
|
771
|
-
for (var prop of __getOwnPropSymbols6(b)) {
|
|
772
|
-
if (__propIsEnum6.call(b, prop))
|
|
773
|
-
__defNormalProp6(a, prop, b[prop]);
|
|
774
|
-
}
|
|
775
|
-
return a;
|
|
776
|
-
};
|
|
777
|
-
var __spreadProps5 = (a, b) => __defProps5(a, __getOwnPropDescs5(b));
|
|
804
|
+
// src/functions/get-block-properties.ts
|
|
778
805
|
var extractRelevantRootBlockProperties = (block) => {
|
|
779
806
|
return {
|
|
780
807
|
href: block.href
|
|
@@ -784,12 +811,13 @@ function getBlockProperties({
|
|
|
784
811
|
block,
|
|
785
812
|
context
|
|
786
813
|
}) {
|
|
787
|
-
|
|
788
|
-
|
|
814
|
+
const properties = {
|
|
815
|
+
...extractRelevantRootBlockProperties(block),
|
|
816
|
+
...block.properties,
|
|
789
817
|
"builder-id": block.id,
|
|
790
818
|
style: block.style ? getStyleAttribute(block.style) : void 0,
|
|
791
|
-
class: [block.id, "builder-block", block.class,
|
|
792
|
-
}
|
|
819
|
+
class: [block.id, "builder-block", block.class, block.properties?.class].filter(Boolean).join(" ")
|
|
820
|
+
};
|
|
793
821
|
if (TARGET === "reactNative") {
|
|
794
822
|
properties.style = getReactNativeBlockStyles({
|
|
795
823
|
block,
|
|
@@ -814,193 +842,51 @@ function getStyleAttribute(style) {
|
|
|
814
842
|
}
|
|
815
843
|
}
|
|
816
844
|
|
|
817
|
-
// src/components/block/block.
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
}
|
|
852
|
-
return target;
|
|
853
|
-
};
|
|
854
|
-
var EMPTY_HTML_ELEMENTS = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
|
|
855
|
-
var isEmptyHtmlElement = (tagName) => {
|
|
856
|
-
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
|
|
857
|
-
};
|
|
858
|
-
var getComponent = ({
|
|
859
|
-
block,
|
|
860
|
-
context,
|
|
861
|
-
registeredComponents
|
|
862
|
-
}) => {
|
|
863
|
-
var _a;
|
|
864
|
-
const componentName = (_a = getProcessedBlock({
|
|
865
|
-
block,
|
|
866
|
-
localState: context.localState,
|
|
867
|
-
rootState: context.rootState,
|
|
868
|
-
rootSetState: context.rootSetState,
|
|
869
|
-
context: context.context,
|
|
870
|
-
shouldEvaluateBindings: false
|
|
871
|
-
}).component) == null ? void 0 : _a.name;
|
|
872
|
-
if (!componentName) {
|
|
873
|
-
return null;
|
|
874
|
-
}
|
|
875
|
-
const ref = registeredComponents[componentName];
|
|
876
|
-
if (!ref) {
|
|
877
|
-
console.warn(`
|
|
878
|
-
Could not find a registered component named "${componentName}".
|
|
879
|
-
If you registered it, is the file that registered it imported by the file that needs to render it?`);
|
|
880
|
-
return void 0;
|
|
881
|
-
} else {
|
|
882
|
-
return ref;
|
|
883
|
-
}
|
|
884
|
-
};
|
|
885
|
-
var getRepeatItemData = ({
|
|
886
|
-
block,
|
|
887
|
-
context
|
|
888
|
-
}) => {
|
|
889
|
-
const _a = block, {
|
|
890
|
-
repeat
|
|
891
|
-
} = _a, blockWithoutRepeat = __objRest(_a, ["repeat"]);
|
|
892
|
-
if (!(repeat == null ? void 0 : repeat.collection)) {
|
|
893
|
-
return void 0;
|
|
894
|
-
}
|
|
895
|
-
const itemsArray = evaluate({
|
|
896
|
-
code: repeat.collection,
|
|
897
|
-
localState: context.localState,
|
|
898
|
-
rootState: context.rootState,
|
|
899
|
-
rootSetState: context.rootSetState,
|
|
900
|
-
context: context.context
|
|
901
|
-
});
|
|
902
|
-
if (!Array.isArray(itemsArray)) {
|
|
903
|
-
return void 0;
|
|
904
|
-
}
|
|
905
|
-
const collectionName = repeat.collection.split(".").pop();
|
|
906
|
-
const itemNameToUse = repeat.itemName || (collectionName ? collectionName + "Item" : "item");
|
|
907
|
-
const repeatArray = itemsArray.map((item, index) => ({
|
|
908
|
-
context: __spreadProps6(__spreadValues7({}, context), {
|
|
909
|
-
localState: __spreadProps6(__spreadValues7({}, context.localState), {
|
|
910
|
-
$index: index,
|
|
911
|
-
$item: item,
|
|
912
|
-
[itemNameToUse]: item,
|
|
913
|
-
[`$${itemNameToUse}Index`]: index
|
|
914
|
-
})
|
|
915
|
-
}),
|
|
916
|
-
block: blockWithoutRepeat
|
|
917
|
-
}));
|
|
918
|
-
return repeatArray;
|
|
919
|
-
};
|
|
920
|
-
|
|
921
|
-
// src/components/block/components/repeated-block.jsx
|
|
922
|
-
import { createSignal as createSignal2 } from "solid-js";
|
|
923
|
-
|
|
924
|
-
// src/context/builder.context.js
|
|
925
|
-
import { createContext } from "solid-js";
|
|
926
|
-
var stdin_default = createContext({
|
|
927
|
-
content: null,
|
|
928
|
-
context: {},
|
|
929
|
-
localState: void 0,
|
|
930
|
-
rootSetState() {
|
|
931
|
-
},
|
|
932
|
-
rootState: {},
|
|
933
|
-
apiKey: null,
|
|
934
|
-
apiVersion: void 0,
|
|
935
|
-
componentInfos: {},
|
|
936
|
-
inheritedStyles: {}
|
|
937
|
-
});
|
|
938
|
-
|
|
939
|
-
// src/components/block/components/repeated-block.jsx
|
|
940
|
-
function RepeatedBlock(props) {
|
|
941
|
-
const [store, setStore] = createSignal2(props.repeatContext);
|
|
942
|
-
return <stdin_default.Provider value={store()}><Block_default
|
|
943
|
-
block={props.block}
|
|
944
|
-
context={store()}
|
|
945
|
-
registeredComponents={props.registeredComponents}
|
|
946
|
-
/></stdin_default.Provider>;
|
|
947
|
-
}
|
|
948
|
-
var Repeated_block_default = RepeatedBlock;
|
|
949
|
-
|
|
950
|
-
// src/components/block/components/component-ref/component-ref.jsx
|
|
951
|
-
import { Show as Show3, For, createSignal as createSignal3 } from "solid-js";
|
|
952
|
-
import { Dynamic as Dynamic2 } from "solid-js/web";
|
|
953
|
-
|
|
954
|
-
// src/components/block/components/interactive-element.jsx
|
|
955
|
-
import { Dynamic } from "solid-js/web";
|
|
956
|
-
|
|
957
|
-
// src/functions/event-handler-name.js
|
|
958
|
-
function capitalizeFirstLetter(string) {
|
|
959
|
-
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
845
|
+
// src/components/block/components/block-wrapper.tsx
|
|
846
|
+
function BlockWrapper(props) {
|
|
847
|
+
return <Show3
|
|
848
|
+
fallback={<Dynamic
|
|
849
|
+
{...getBlockProperties({
|
|
850
|
+
block: props.block,
|
|
851
|
+
context: props.context
|
|
852
|
+
})}
|
|
853
|
+
{...getBlockActions({
|
|
854
|
+
block: props.block,
|
|
855
|
+
rootState: props.context.rootState,
|
|
856
|
+
rootSetState: props.context.rootSetState,
|
|
857
|
+
localState: props.context.localState,
|
|
858
|
+
context: props.context.context,
|
|
859
|
+
stripPrefix: true
|
|
860
|
+
})}
|
|
861
|
+
component={props.Wrapper}
|
|
862
|
+
/>}
|
|
863
|
+
when={props.hasChildren}
|
|
864
|
+
><Dynamic
|
|
865
|
+
{...getBlockProperties({
|
|
866
|
+
block: props.block,
|
|
867
|
+
context: props.context
|
|
868
|
+
})}
|
|
869
|
+
{...getBlockActions({
|
|
870
|
+
block: props.block,
|
|
871
|
+
rootState: props.context.rootState,
|
|
872
|
+
rootSetState: props.context.rootSetState,
|
|
873
|
+
localState: props.context.localState,
|
|
874
|
+
context: props.context.context,
|
|
875
|
+
stripPrefix: true
|
|
876
|
+
})}
|
|
877
|
+
component={props.Wrapper}
|
|
878
|
+
>{props.children}</Dynamic></Show3>;
|
|
960
879
|
}
|
|
961
|
-
var
|
|
962
|
-
|
|
963
|
-
// src/functions/get-block-actions-handler.js
|
|
964
|
-
var createEventHandler = (value, options) => (event) => evaluate({
|
|
965
|
-
code: value,
|
|
966
|
-
context: options.context,
|
|
967
|
-
localState: options.localState,
|
|
968
|
-
rootState: options.rootState,
|
|
969
|
-
rootSetState: options.rootSetState,
|
|
970
|
-
event,
|
|
971
|
-
isExpression: false
|
|
972
|
-
});
|
|
880
|
+
var Block_wrapper_default = BlockWrapper;
|
|
973
881
|
|
|
974
|
-
// src/
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
const obj = {};
|
|
978
|
-
const optionActions = (_a = options.block.actions) != null ? _a : {};
|
|
979
|
-
for (const key in optionActions) {
|
|
980
|
-
if (!optionActions.hasOwnProperty(key)) {
|
|
981
|
-
continue;
|
|
982
|
-
}
|
|
983
|
-
const value = optionActions[key];
|
|
984
|
-
let eventHandlerName = getEventHandlerName(key);
|
|
985
|
-
if (options.stripPrefix) {
|
|
986
|
-
switch (TARGET) {
|
|
987
|
-
case "vue2":
|
|
988
|
-
case "vue3":
|
|
989
|
-
eventHandlerName = eventHandlerName.replace("v-on:", "");
|
|
990
|
-
break;
|
|
991
|
-
case "svelte":
|
|
992
|
-
eventHandlerName = eventHandlerName.replace("on:", "");
|
|
993
|
-
break;
|
|
994
|
-
}
|
|
995
|
-
}
|
|
996
|
-
obj[eventHandlerName] = createEventHandler(value, options);
|
|
997
|
-
}
|
|
998
|
-
return obj;
|
|
999
|
-
}
|
|
882
|
+
// src/components/block/components/component-ref/component-ref.tsx
|
|
883
|
+
import { Show as Show4, For, createSignal as createSignal2 } from "solid-js";
|
|
884
|
+
import { Dynamic as Dynamic3 } from "solid-js/web";
|
|
1000
885
|
|
|
1001
|
-
// src/components/block/components/interactive-element.
|
|
886
|
+
// src/components/block/components/interactive-element.tsx
|
|
887
|
+
import { Dynamic as Dynamic2 } from "solid-js/web";
|
|
1002
888
|
function InteractiveElement(props) {
|
|
1003
|
-
return <
|
|
889
|
+
return <Dynamic2
|
|
1004
890
|
{...props.wrapperProps}
|
|
1005
891
|
attributes={{
|
|
1006
892
|
...getBlockProperties({
|
|
@@ -1016,32 +902,11 @@ function InteractiveElement(props) {
|
|
|
1016
902
|
})
|
|
1017
903
|
}}
|
|
1018
904
|
component={props.Wrapper}
|
|
1019
|
-
>{props.children}</
|
|
905
|
+
>{props.children}</Dynamic2>;
|
|
1020
906
|
}
|
|
1021
907
|
var interactive_element_default = InteractiveElement;
|
|
1022
908
|
|
|
1023
|
-
// src/components/block/components/component-ref/component-ref.helpers.
|
|
1024
|
-
var __defProp8 = Object.defineProperty;
|
|
1025
|
-
var __getOwnPropSymbols8 = Object.getOwnPropertySymbols;
|
|
1026
|
-
var __hasOwnProp8 = Object.prototype.hasOwnProperty;
|
|
1027
|
-
var __propIsEnum8 = Object.prototype.propertyIsEnumerable;
|
|
1028
|
-
var __defNormalProp8 = (obj, key, value) => key in obj ? __defProp8(obj, key, {
|
|
1029
|
-
enumerable: true,
|
|
1030
|
-
configurable: true,
|
|
1031
|
-
writable: true,
|
|
1032
|
-
value
|
|
1033
|
-
}) : obj[key] = value;
|
|
1034
|
-
var __spreadValues8 = (a, b) => {
|
|
1035
|
-
for (var prop in b || (b = {}))
|
|
1036
|
-
if (__hasOwnProp8.call(b, prop))
|
|
1037
|
-
__defNormalProp8(a, prop, b[prop]);
|
|
1038
|
-
if (__getOwnPropSymbols8)
|
|
1039
|
-
for (var prop of __getOwnPropSymbols8(b)) {
|
|
1040
|
-
if (__propIsEnum8.call(b, prop))
|
|
1041
|
-
__defNormalProp8(a, prop, b[prop]);
|
|
1042
|
-
}
|
|
1043
|
-
return a;
|
|
1044
|
-
};
|
|
909
|
+
// src/components/block/components/component-ref/component-ref.helpers.ts
|
|
1045
910
|
var getWrapperProps = ({
|
|
1046
911
|
componentOptions,
|
|
1047
912
|
builderBlock,
|
|
@@ -1057,20 +922,27 @@ var getWrapperProps = ({
|
|
|
1057
922
|
context,
|
|
1058
923
|
wrapperProps: componentOptions
|
|
1059
924
|
};
|
|
1060
|
-
return isInteractive ? interactiveElementProps :
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
925
|
+
return isInteractive ? interactiveElementProps : {
|
|
926
|
+
...componentOptions,
|
|
927
|
+
/**
|
|
928
|
+
* If `noWrap` is set to `true`, then the block's props/attributes are provided to the
|
|
929
|
+
* component itself directly. Otherwise, they are provided to the wrapper element.
|
|
930
|
+
*/
|
|
931
|
+
...includeBlockProps ? {
|
|
932
|
+
attributes: getBlockProperties({
|
|
933
|
+
block: builderBlock,
|
|
934
|
+
context: contextValue
|
|
935
|
+
})
|
|
936
|
+
} : {}
|
|
937
|
+
};
|
|
1066
938
|
};
|
|
1067
939
|
|
|
1068
|
-
// src/components/block/components/component-ref/component-ref.
|
|
940
|
+
// src/components/block/components/component-ref/component-ref.tsx
|
|
1069
941
|
function ComponentRef(props) {
|
|
1070
|
-
const [Wrapper, setWrapper] =
|
|
942
|
+
const [Wrapper, setWrapper] = createSignal2(
|
|
1071
943
|
props.isInteractive ? interactive_element_default : props.componentRef
|
|
1072
944
|
);
|
|
1073
|
-
return <
|
|
945
|
+
return <Show4 when={props.componentRef}><Dynamic3
|
|
1074
946
|
{...getWrapperProps({
|
|
1075
947
|
componentOptions: props.componentOptions,
|
|
1076
948
|
builderBlock: props.builderBlock,
|
|
@@ -1099,50 +971,23 @@ function ComponentRef(props) {
|
|
|
1099
971
|
context={props.context}
|
|
1100
972
|
/>;
|
|
1101
973
|
}}</For>
|
|
1102
|
-
</
|
|
974
|
+
</Dynamic3></Show4>;
|
|
1103
975
|
}
|
|
1104
976
|
var Component_ref_default = ComponentRef;
|
|
1105
977
|
|
|
1106
|
-
// src/components/block/components/block
|
|
1107
|
-
import {
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
return <
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
})}
|
|
1116
|
-
{...getBlockActions({
|
|
1117
|
-
block: props.block,
|
|
1118
|
-
rootState: props.context.rootState,
|
|
1119
|
-
rootSetState: props.context.rootSetState,
|
|
1120
|
-
localState: props.context.localState,
|
|
1121
|
-
context: props.context.context,
|
|
1122
|
-
stripPrefix: true
|
|
1123
|
-
})}
|
|
1124
|
-
component={props.Wrapper}
|
|
1125
|
-
/>}
|
|
1126
|
-
when={props.hasChildren}
|
|
1127
|
-
><Dynamic3
|
|
1128
|
-
{...getBlockProperties({
|
|
1129
|
-
block: props.block,
|
|
1130
|
-
context: props.context
|
|
1131
|
-
})}
|
|
1132
|
-
{...getBlockActions({
|
|
1133
|
-
block: props.block,
|
|
1134
|
-
rootState: props.context.rootState,
|
|
1135
|
-
rootSetState: props.context.rootSetState,
|
|
1136
|
-
localState: props.context.localState,
|
|
1137
|
-
context: props.context.context,
|
|
1138
|
-
stripPrefix: true
|
|
1139
|
-
})}
|
|
1140
|
-
component={props.Wrapper}
|
|
1141
|
-
>{props.children}</Dynamic3></Show4>;
|
|
978
|
+
// src/components/block/components/repeated-block.tsx
|
|
979
|
+
import { createSignal as createSignal3 } from "solid-js";
|
|
980
|
+
function RepeatedBlock(props) {
|
|
981
|
+
const [store, setStore] = createSignal3(props.repeatContext);
|
|
982
|
+
return <builder_context_default.Provider value={store()}><Block_default
|
|
983
|
+
block={props.block}
|
|
984
|
+
context={store()}
|
|
985
|
+
registeredComponents={props.registeredComponents}
|
|
986
|
+
/></builder_context_default.Provider>;
|
|
1142
987
|
}
|
|
1143
|
-
var
|
|
988
|
+
var Repeated_block_default = RepeatedBlock;
|
|
1144
989
|
|
|
1145
|
-
// src/components/block/block.
|
|
990
|
+
// src/components/block/block.tsx
|
|
1146
991
|
function Block(props) {
|
|
1147
992
|
const [childrenContext, setChildrenContext] = createSignal4(props.context);
|
|
1148
993
|
function blockComponent() {
|
|
@@ -1203,7 +1048,16 @@ function Block(props) {
|
|
|
1203
1048
|
};
|
|
1204
1049
|
}
|
|
1205
1050
|
return <Show5 when={canShowBlock()}><Show5
|
|
1206
|
-
fallback={<Component_ref_default
|
|
1051
|
+
fallback={<Component_ref_default
|
|
1052
|
+
componentRef={componentRefProps().componentRef}
|
|
1053
|
+
componentOptions={componentRefProps().componentOptions}
|
|
1054
|
+
blockChildren={componentRefProps().blockChildren}
|
|
1055
|
+
context={componentRefProps().context}
|
|
1056
|
+
registeredComponents={componentRefProps().registeredComponents}
|
|
1057
|
+
builderBlock={componentRefProps().builderBlock}
|
|
1058
|
+
includeBlockProps={componentRefProps().includeBlockProps}
|
|
1059
|
+
isInteractive={componentRefProps().isInteractive}
|
|
1060
|
+
/>}
|
|
1207
1061
|
when={!blockComponent()?.noWrap}
|
|
1208
1062
|
>
|
|
1209
1063
|
<Show5 when={isEmptyHtmlElement(Tag())}><Block_wrapper_default
|
|
@@ -1227,7 +1081,16 @@ function Block(props) {
|
|
|
1227
1081
|
context={props.context}
|
|
1228
1082
|
hasChildren={true}
|
|
1229
1083
|
>
|
|
1230
|
-
<Component_ref_default
|
|
1084
|
+
<Component_ref_default
|
|
1085
|
+
componentRef={componentRefProps().componentRef}
|
|
1086
|
+
componentOptions={componentRefProps().componentOptions}
|
|
1087
|
+
blockChildren={componentRefProps().blockChildren}
|
|
1088
|
+
context={componentRefProps().context}
|
|
1089
|
+
registeredComponents={componentRefProps().registeredComponents}
|
|
1090
|
+
builderBlock={componentRefProps().builderBlock}
|
|
1091
|
+
includeBlockProps={componentRefProps().includeBlockProps}
|
|
1092
|
+
isInteractive={componentRefProps().isInteractive}
|
|
1093
|
+
/>
|
|
1231
1094
|
<For2 each={childrenWithoutParentComponent()}>{(child, _index) => {
|
|
1232
1095
|
const index = _index();
|
|
1233
1096
|
return <Block
|
|
@@ -1250,8 +1113,7 @@ function Block(props) {
|
|
|
1250
1113
|
}
|
|
1251
1114
|
var Block_default = Block;
|
|
1252
1115
|
|
|
1253
|
-
// src/components/blocks/blocks-wrapper.
|
|
1254
|
-
import { createSignal as createSignal5 } from "solid-js";
|
|
1116
|
+
// src/components/blocks/blocks-wrapper.tsx
|
|
1255
1117
|
import { css as css2 } from "solid-styled-components";
|
|
1256
1118
|
function BlocksWrapper(props) {
|
|
1257
1119
|
function className() {
|
|
@@ -1302,14 +1164,10 @@ function BlocksWrapper(props) {
|
|
|
1302
1164
|
}
|
|
1303
1165
|
var Blocks_wrapper_default = BlocksWrapper;
|
|
1304
1166
|
|
|
1305
|
-
// src/
|
|
1306
|
-
import { createContext as createContext2 } from "solid-js";
|
|
1307
|
-
var stdin_default2 = createContext2({ registeredComponents: {} });
|
|
1308
|
-
|
|
1309
|
-
// src/components/blocks/blocks.jsx
|
|
1167
|
+
// src/components/blocks/blocks.tsx
|
|
1310
1168
|
function Blocks(props) {
|
|
1311
|
-
const builderContext = useContext(
|
|
1312
|
-
const componentsContext = useContext(
|
|
1169
|
+
const builderContext = useContext(builder_context_default);
|
|
1170
|
+
const componentsContext = useContext(components_context_default);
|
|
1313
1171
|
return <Blocks_wrapper_default
|
|
1314
1172
|
blocks={props.blocks}
|
|
1315
1173
|
parent={props.parent}
|
|
@@ -1337,14 +1195,14 @@ function Blocks(props) {
|
|
|
1337
1195
|
}
|
|
1338
1196
|
var Blocks_default = Blocks;
|
|
1339
1197
|
|
|
1340
|
-
// src/blocks/columns/columns.
|
|
1198
|
+
// src/blocks/columns/columns.tsx
|
|
1341
1199
|
function Columns(props) {
|
|
1342
|
-
const [gutterSize, setGutterSize] =
|
|
1200
|
+
const [gutterSize, setGutterSize] = createSignal5(
|
|
1343
1201
|
typeof props.space === "number" ? props.space || 0 : 20
|
|
1344
1202
|
);
|
|
1345
|
-
const [cols, setCols] =
|
|
1346
|
-
const [stackAt, setStackAt] =
|
|
1347
|
-
const [flexDir, setFlexDir] =
|
|
1203
|
+
const [cols, setCols] = createSignal5(props.columns || []);
|
|
1204
|
+
const [stackAt, setStackAt] = createSignal5(props.stackColumnsAt || "tablet");
|
|
1205
|
+
const [flexDir, setFlexDir] = createSignal5(
|
|
1348
1206
|
props.stackColumnsAt === "never" ? "row" : props.reverseColumnsWhenStacked ? "column-reverse" : "column"
|
|
1349
1207
|
);
|
|
1350
1208
|
function getWidth(index) {
|
|
@@ -1354,10 +1212,16 @@ function Columns(props) {
|
|
|
1354
1212
|
const subtractWidth = gutterSize() * (cols().length - 1) / cols().length;
|
|
1355
1213
|
return `calc(${getWidth(index)}% - ${subtractWidth}px)`;
|
|
1356
1214
|
}
|
|
1357
|
-
function getTabletStyle({
|
|
1215
|
+
function getTabletStyle({
|
|
1216
|
+
stackedStyle,
|
|
1217
|
+
desktopStyle
|
|
1218
|
+
}) {
|
|
1358
1219
|
return stackAt() === "tablet" ? stackedStyle : desktopStyle;
|
|
1359
1220
|
}
|
|
1360
|
-
function getMobileStyle({
|
|
1221
|
+
function getMobileStyle({
|
|
1222
|
+
stackedStyle,
|
|
1223
|
+
desktopStyle
|
|
1224
|
+
}) {
|
|
1361
1225
|
return stackAt() === "never" ? desktopStyle : stackedStyle;
|
|
1362
1226
|
}
|
|
1363
1227
|
function columnsCssVars() {
|
|
@@ -1465,17 +1329,17 @@ function Columns(props) {
|
|
|
1465
1329
|
}
|
|
1466
1330
|
var columns_default = Columns;
|
|
1467
1331
|
|
|
1468
|
-
// src/blocks/fragment/fragment.
|
|
1332
|
+
// src/blocks/fragment/fragment.tsx
|
|
1469
1333
|
function FragmentComponent(props) {
|
|
1470
1334
|
return <span>{props.children}</span>;
|
|
1471
1335
|
}
|
|
1472
1336
|
var fragment_default = FragmentComponent;
|
|
1473
1337
|
|
|
1474
|
-
// src/blocks/image/image.
|
|
1475
|
-
import { Show as Show8
|
|
1338
|
+
// src/blocks/image/image.tsx
|
|
1339
|
+
import { Show as Show8 } from "solid-js";
|
|
1476
1340
|
import { css as css4 } from "solid-styled-components";
|
|
1477
1341
|
|
|
1478
|
-
// src/blocks/image/image.helpers.
|
|
1342
|
+
// src/blocks/image/image.helpers.ts
|
|
1479
1343
|
function removeProtocol(path) {
|
|
1480
1344
|
return path.replace(/http(s)?:/, "");
|
|
1481
1345
|
}
|
|
@@ -1488,7 +1352,7 @@ function updateQueryParam(uri = "", key, value) {
|
|
|
1488
1352
|
return uri + separator + key + "=" + encodeURIComponent(value);
|
|
1489
1353
|
}
|
|
1490
1354
|
function getShopifyImageUrl(src, size) {
|
|
1491
|
-
if (!src || !
|
|
1355
|
+
if (!src || !src?.match(/cdn\.shopify\.com/) || !size) {
|
|
1492
1356
|
return src;
|
|
1493
1357
|
}
|
|
1494
1358
|
if (size === "master") {
|
|
@@ -1522,7 +1386,7 @@ function getSrcSet(url) {
|
|
|
1522
1386
|
return url;
|
|
1523
1387
|
}
|
|
1524
1388
|
|
|
1525
|
-
// src/blocks/image/image.
|
|
1389
|
+
// src/blocks/image/image.tsx
|
|
1526
1390
|
function Image(props) {
|
|
1527
1391
|
function srcSetToUse() {
|
|
1528
1392
|
const imageToUse = props.image || props.src;
|
|
@@ -1610,7 +1474,7 @@ function Image(props) {
|
|
|
1610
1474
|
}
|
|
1611
1475
|
var image_default = Image;
|
|
1612
1476
|
|
|
1613
|
-
// src/blocks/section/section.
|
|
1477
|
+
// src/blocks/section/section.tsx
|
|
1614
1478
|
function SectionComponent(props) {
|
|
1615
1479
|
return <section
|
|
1616
1480
|
{...{}}
|
|
@@ -1631,190 +1495,212 @@ function SectionComponent(props) {
|
|
|
1631
1495
|
}
|
|
1632
1496
|
var section_default = SectionComponent;
|
|
1633
1497
|
|
|
1634
|
-
// src/blocks/symbol/symbol.
|
|
1635
|
-
import { onMount as onMount4, on as on3, createEffect as createEffect3, createSignal as
|
|
1498
|
+
// src/blocks/symbol/symbol.tsx
|
|
1499
|
+
import { onMount as onMount4, on as on3, createEffect as createEffect3, createSignal as createSignal13 } from "solid-js";
|
|
1636
1500
|
|
|
1637
|
-
// src/components/content-variants/content-variants.
|
|
1638
|
-
import { Show as Show11, For as For5, onMount as onMount3, createSignal as
|
|
1501
|
+
// src/components/content-variants/content-variants.tsx
|
|
1502
|
+
import { Show as Show11, For as For5, onMount as onMount3, createSignal as createSignal12 } from "solid-js";
|
|
1639
1503
|
|
|
1640
|
-
// src/
|
|
1641
|
-
var
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
writable: true,
|
|
1651
|
-
value
|
|
1652
|
-
}) : obj[key] = value;
|
|
1653
|
-
var __spreadValues9 = (a, b) => {
|
|
1654
|
-
for (var prop in b || (b = {}))
|
|
1655
|
-
if (__hasOwnProp9.call(b, prop))
|
|
1656
|
-
__defNormalProp9(a, prop, b[prop]);
|
|
1657
|
-
if (__getOwnPropSymbols9)
|
|
1658
|
-
for (var prop of __getOwnPropSymbols9(b)) {
|
|
1659
|
-
if (__propIsEnum9.call(b, prop))
|
|
1660
|
-
__defNormalProp9(a, prop, b[prop]);
|
|
1661
|
-
}
|
|
1662
|
-
return a;
|
|
1504
|
+
// src/helpers/url.ts
|
|
1505
|
+
var getTopLevelDomain = (host) => {
|
|
1506
|
+
if (host === "localhost" || host === "127.0.0.1") {
|
|
1507
|
+
return host;
|
|
1508
|
+
}
|
|
1509
|
+
const parts = host.split(".");
|
|
1510
|
+
if (parts.length > 2) {
|
|
1511
|
+
return parts.slice(1).join(".");
|
|
1512
|
+
}
|
|
1513
|
+
return host;
|
|
1663
1514
|
};
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
var checkShouldRunVariants = ({
|
|
1670
|
-
canTrack,
|
|
1671
|
-
content
|
|
1515
|
+
|
|
1516
|
+
// src/helpers/cookie.ts
|
|
1517
|
+
var getCookieSync = ({
|
|
1518
|
+
name,
|
|
1519
|
+
canTrack
|
|
1672
1520
|
}) => {
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
if (!hasVariants)
|
|
1677
|
-
return false;
|
|
1678
|
-
if (!canTrack)
|
|
1679
|
-
return false;
|
|
1680
|
-
if (TARGET === "vue2" || TARGET === "vue3")
|
|
1681
|
-
return true;
|
|
1682
|
-
if (isBrowser())
|
|
1683
|
-
return false;
|
|
1684
|
-
return true;
|
|
1685
|
-
};
|
|
1686
|
-
function bldrAbTest(contentId, variants, isHydrationTarget2) {
|
|
1687
|
-
var _a;
|
|
1688
|
-
function getAndSetVariantId2() {
|
|
1689
|
-
function setCookie2(name, value, days) {
|
|
1690
|
-
let expires = "";
|
|
1691
|
-
if (days) {
|
|
1692
|
-
const date = /* @__PURE__ */ new Date();
|
|
1693
|
-
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1e3);
|
|
1694
|
-
expires = "; expires=" + date.toUTCString();
|
|
1695
|
-
}
|
|
1696
|
-
document.cookie = name + "=" + (value || "") + expires + "; path=/; Secure; SameSite=None";
|
|
1521
|
+
try {
|
|
1522
|
+
if (!canTrack) {
|
|
1523
|
+
return void 0;
|
|
1697
1524
|
}
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1525
|
+
return document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))?.split("=")[1];
|
|
1526
|
+
} catch (err) {
|
|
1527
|
+
logger.warn("[COOKIE] GET error: ", err?.message || err);
|
|
1528
|
+
return void 0;
|
|
1529
|
+
}
|
|
1530
|
+
};
|
|
1531
|
+
var getCookie = async (args) => getCookieSync(args);
|
|
1532
|
+
var stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).filter(checkIsDefined).join("; ");
|
|
1533
|
+
var SECURE_CONFIG = [["secure", ""], ["SameSite", "None"]];
|
|
1534
|
+
var createCookieString = ({
|
|
1535
|
+
name,
|
|
1536
|
+
value,
|
|
1537
|
+
expires
|
|
1538
|
+
}) => {
|
|
1539
|
+
const secure = isBrowser() ? location.protocol === "https:" : true;
|
|
1540
|
+
const secureObj = secure ? SECURE_CONFIG : [[]];
|
|
1541
|
+
const expiresObj = expires ? [["expires", expires.toUTCString()]] : [[]];
|
|
1542
|
+
const cookieValue = [[name, value], ...expiresObj, ["path", "/"], ["domain", getTopLevelDomain(window.location.hostname)], ...secureObj];
|
|
1543
|
+
const cookie = stringifyCookie(cookieValue);
|
|
1544
|
+
return cookie;
|
|
1545
|
+
};
|
|
1546
|
+
var setCookie = async ({
|
|
1547
|
+
name,
|
|
1548
|
+
value,
|
|
1549
|
+
expires,
|
|
1550
|
+
canTrack
|
|
1551
|
+
}) => {
|
|
1552
|
+
try {
|
|
1553
|
+
if (!canTrack) {
|
|
1554
|
+
return;
|
|
1715
1555
|
}
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1556
|
+
const cookie = createCookieString({
|
|
1557
|
+
name,
|
|
1558
|
+
value,
|
|
1559
|
+
expires
|
|
1560
|
+
});
|
|
1561
|
+
document.cookie = cookie;
|
|
1562
|
+
} catch (err) {
|
|
1563
|
+
logger.warn("[COOKIE] SET error: ", err?.message || err);
|
|
1564
|
+
}
|
|
1565
|
+
};
|
|
1566
|
+
|
|
1567
|
+
// src/helpers/ab-tests.ts
|
|
1568
|
+
var BUILDER_STORE_PREFIX = "builder.tests";
|
|
1569
|
+
var getContentTestKey = (id) => `${BUILDER_STORE_PREFIX}.${id}`;
|
|
1570
|
+
var getContentVariationCookie = ({
|
|
1571
|
+
contentId
|
|
1572
|
+
}) => getCookie({
|
|
1573
|
+
name: getContentTestKey(contentId),
|
|
1574
|
+
canTrack: true
|
|
1575
|
+
});
|
|
1576
|
+
var getContentVariationCookieSync = ({
|
|
1577
|
+
contentId
|
|
1578
|
+
}) => getCookieSync({
|
|
1579
|
+
name: getContentTestKey(contentId),
|
|
1580
|
+
canTrack: true
|
|
1581
|
+
});
|
|
1582
|
+
var setContentVariationCookie = ({
|
|
1583
|
+
contentId,
|
|
1584
|
+
value
|
|
1585
|
+
}) => setCookie({
|
|
1586
|
+
name: getContentTestKey(contentId),
|
|
1587
|
+
value,
|
|
1588
|
+
canTrack: true
|
|
1589
|
+
});
|
|
1590
|
+
var checkIsBuilderContentWithVariations = (item) => checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
|
|
1591
|
+
var getRandomVariationId = ({
|
|
1592
|
+
id,
|
|
1593
|
+
variations
|
|
1594
|
+
}) => {
|
|
1595
|
+
let n = 0;
|
|
1596
|
+
const random = Math.random();
|
|
1597
|
+
for (const id2 in variations) {
|
|
1598
|
+
const testRatio = variations[id2]?.testRatio;
|
|
1599
|
+
n += testRatio;
|
|
1600
|
+
if (random < n) {
|
|
1601
|
+
return id2;
|
|
1726
1602
|
}
|
|
1727
|
-
setCookie2(cookieName, contentId);
|
|
1728
|
-
return contentId;
|
|
1729
1603
|
}
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1604
|
+
return id;
|
|
1605
|
+
};
|
|
1606
|
+
var getAndSetVariantId = (args) => {
|
|
1607
|
+
const randomVariationId = getRandomVariationId(args);
|
|
1608
|
+
setContentVariationCookie({
|
|
1609
|
+
contentId: args.id,
|
|
1610
|
+
value: randomVariationId
|
|
1611
|
+
}).catch((err) => {
|
|
1612
|
+
logger.error("could not store A/B test variation: ", err);
|
|
1613
|
+
});
|
|
1614
|
+
return randomVariationId;
|
|
1615
|
+
};
|
|
1616
|
+
var getTestFields = ({
|
|
1617
|
+
item,
|
|
1618
|
+
testGroupId
|
|
1619
|
+
}) => {
|
|
1620
|
+
const variationValue = item.variations[testGroupId];
|
|
1621
|
+
if (testGroupId === item.id || // handle edge-case where `testGroupId` points to non-existing variation
|
|
1622
|
+
!variationValue) {
|
|
1623
|
+
return {
|
|
1624
|
+
testVariationId: item.id,
|
|
1625
|
+
testVariationName: "Default"
|
|
1626
|
+
};
|
|
1736
1627
|
} else {
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
}).join("");
|
|
1743
|
-
styleEl.innerHTML = newStyleStr;
|
|
1628
|
+
return {
|
|
1629
|
+
data: variationValue.data,
|
|
1630
|
+
testVariationId: variationValue.id,
|
|
1631
|
+
testVariationName: variationValue.name || (variationValue.id === item.id ? "Default" : "")
|
|
1632
|
+
};
|
|
1744
1633
|
}
|
|
1745
|
-
}
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1634
|
+
};
|
|
1635
|
+
var handleABTestingSync = ({
|
|
1636
|
+
item,
|
|
1637
|
+
canTrack
|
|
1638
|
+
}) => {
|
|
1639
|
+
if (TARGET === "reactNative")
|
|
1640
|
+
return item;
|
|
1641
|
+
if (!canTrack) {
|
|
1642
|
+
return item;
|
|
1750
1643
|
}
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
const ca = document.cookie.split(";");
|
|
1754
|
-
for (let i = 0; i < ca.length; i++) {
|
|
1755
|
-
let c = ca[i];
|
|
1756
|
-
while (c.charAt(0) === " ")
|
|
1757
|
-
c = c.substring(1, c.length);
|
|
1758
|
-
if (c.indexOf(nameEQ) === 0)
|
|
1759
|
-
return c.substring(nameEQ.length, c.length);
|
|
1760
|
-
}
|
|
1761
|
-
return null;
|
|
1644
|
+
if (!item) {
|
|
1645
|
+
return void 0;
|
|
1762
1646
|
}
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
const parentDiv = (_a = document.currentScript) == null ? void 0 : _a.parentElement;
|
|
1766
|
-
const variantIsDefaultContent = variantContentId === defaultContentId;
|
|
1767
|
-
if (variantId === variantContentId) {
|
|
1768
|
-
if (variantIsDefaultContent) {
|
|
1769
|
-
return;
|
|
1770
|
-
}
|
|
1771
|
-
parentDiv == null ? void 0 : parentDiv.removeAttribute("hidden");
|
|
1772
|
-
parentDiv == null ? void 0 : parentDiv.removeAttribute("aria-hidden");
|
|
1773
|
-
} else {
|
|
1774
|
-
if (variantIsDefaultContent) {
|
|
1775
|
-
if (isHydrationTarget2) {
|
|
1776
|
-
parentDiv == null ? void 0 : parentDiv.remove();
|
|
1777
|
-
} else {
|
|
1778
|
-
parentDiv == null ? void 0 : parentDiv.setAttribute("hidden", "true");
|
|
1779
|
-
parentDiv == null ? void 0 : parentDiv.setAttribute("aria-hidden", "true");
|
|
1780
|
-
}
|
|
1781
|
-
}
|
|
1782
|
-
return;
|
|
1647
|
+
if (!checkIsBuilderContentWithVariations(item)) {
|
|
1648
|
+
return item;
|
|
1783
1649
|
}
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
};
|
|
1798
|
-
var getVariantsScriptString = (variants, contentId) => {
|
|
1799
|
-
return `
|
|
1800
|
-
window.${AB_TEST_FN_NAME}("${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget})`;
|
|
1650
|
+
const testGroupId = getContentVariationCookieSync({
|
|
1651
|
+
contentId: item.id
|
|
1652
|
+
}) || getAndSetVariantId({
|
|
1653
|
+
variations: item.variations,
|
|
1654
|
+
id: item.id
|
|
1655
|
+
});
|
|
1656
|
+
const variationValue = getTestFields({
|
|
1657
|
+
item,
|
|
1658
|
+
testGroupId
|
|
1659
|
+
});
|
|
1660
|
+
return {
|
|
1661
|
+
...item,
|
|
1662
|
+
...variationValue
|
|
1663
|
+
};
|
|
1801
1664
|
};
|
|
1802
|
-
var
|
|
1803
|
-
|
|
1804
|
-
|
|
1665
|
+
var handleABTesting = async ({
|
|
1666
|
+
item,
|
|
1667
|
+
canTrack
|
|
1805
1668
|
}) => {
|
|
1806
|
-
|
|
1807
|
-
|
|
1669
|
+
if (!canTrack) {
|
|
1670
|
+
return item;
|
|
1671
|
+
}
|
|
1672
|
+
if (!checkIsBuilderContentWithVariations(item)) {
|
|
1673
|
+
return item;
|
|
1674
|
+
}
|
|
1675
|
+
const cookieValue = await getContentVariationCookie({
|
|
1676
|
+
contentId: item.id
|
|
1677
|
+
});
|
|
1678
|
+
const testGroupId = cookieValue || getAndSetVariantId({
|
|
1679
|
+
variations: item.variations,
|
|
1680
|
+
id: item.id
|
|
1681
|
+
});
|
|
1682
|
+
const variationValue = getTestFields({
|
|
1683
|
+
item,
|
|
1684
|
+
testGroupId
|
|
1685
|
+
});
|
|
1686
|
+
return {
|
|
1687
|
+
...item,
|
|
1688
|
+
...variationValue
|
|
1689
|
+
};
|
|
1808
1690
|
};
|
|
1809
1691
|
|
|
1810
|
-
// src/
|
|
1811
|
-
|
|
1692
|
+
// src/helpers/canTrack.ts
|
|
1693
|
+
var getDefaultCanTrack = (canTrack) => checkIsDefined(canTrack) ? canTrack : true;
|
|
1694
|
+
|
|
1695
|
+
// src/components/content/content.tsx
|
|
1696
|
+
import { Show as Show10, createSignal as createSignal11 } from "solid-js";
|
|
1812
1697
|
|
|
1813
|
-
// src/blocks/button/component-info.
|
|
1698
|
+
// src/blocks/button/component-info.ts
|
|
1814
1699
|
var componentInfo = {
|
|
1815
1700
|
name: "Core:Button",
|
|
1816
1701
|
image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13",
|
|
1817
1702
|
defaultStyles: {
|
|
1703
|
+
// TODO: make min width more intuitive and set one
|
|
1818
1704
|
appearance: "none",
|
|
1819
1705
|
paddingTop: "15px",
|
|
1820
1706
|
paddingBottom: "15px",
|
|
@@ -1845,8 +1731,9 @@ var componentInfo = {
|
|
|
1845
1731
|
noWrap: true
|
|
1846
1732
|
};
|
|
1847
1733
|
|
|
1848
|
-
// src/blocks/columns/component-info.
|
|
1734
|
+
// src/blocks/columns/component-info.ts
|
|
1849
1735
|
var componentInfo2 = {
|
|
1736
|
+
// TODO: ways to statically preprocess JSON for references, functions, etc
|
|
1850
1737
|
name: "Columns",
|
|
1851
1738
|
isRSC: true,
|
|
1852
1739
|
inputs: [{
|
|
@@ -2064,17 +1951,173 @@ var componentInfo2 = {
|
|
|
2064
1951
|
}]
|
|
2065
1952
|
};
|
|
2066
1953
|
|
|
2067
|
-
// src/blocks/
|
|
1954
|
+
// src/blocks/custom-code/component-info.ts
|
|
2068
1955
|
var componentInfo3 = {
|
|
2069
|
-
name: "
|
|
1956
|
+
name: "Custom Code",
|
|
2070
1957
|
static: true,
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
1958
|
+
requiredPermissions: ["editCode"],
|
|
1959
|
+
inputs: [{
|
|
1960
|
+
name: "code",
|
|
1961
|
+
type: "html",
|
|
1962
|
+
required: true,
|
|
1963
|
+
defaultValue: "<p>Hello there, I am custom HTML code!</p>",
|
|
1964
|
+
code: true
|
|
1965
|
+
}, {
|
|
1966
|
+
name: "replaceNodes",
|
|
1967
|
+
type: "boolean",
|
|
1968
|
+
helperText: "Preserve server rendered dom nodes",
|
|
1969
|
+
advanced: true
|
|
1970
|
+
}, {
|
|
1971
|
+
name: "scriptsClientOnly",
|
|
1972
|
+
type: "boolean",
|
|
1973
|
+
defaultValue: false,
|
|
1974
|
+
helperText: "Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads",
|
|
1975
|
+
advanced: true
|
|
1976
|
+
}]
|
|
2074
1977
|
};
|
|
2075
1978
|
|
|
2076
|
-
// src/blocks/
|
|
1979
|
+
// src/blocks/custom-code/custom-code.tsx
|
|
1980
|
+
import { onMount, createSignal as createSignal7 } from "solid-js";
|
|
1981
|
+
function CustomCode(props) {
|
|
1982
|
+
const [scriptsInserted, setScriptsInserted] = createSignal7([]);
|
|
1983
|
+
const [scriptsRun, setScriptsRun] = createSignal7([]);
|
|
1984
|
+
let elementRef;
|
|
1985
|
+
onMount(() => {
|
|
1986
|
+
if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
|
|
1987
|
+
return;
|
|
1988
|
+
}
|
|
1989
|
+
const scripts = elementRef.getElementsByTagName("script");
|
|
1990
|
+
for (let i = 0; i < scripts.length; i++) {
|
|
1991
|
+
const script = scripts[i];
|
|
1992
|
+
if (script.src) {
|
|
1993
|
+
if (scriptsInserted().includes(script.src)) {
|
|
1994
|
+
continue;
|
|
1995
|
+
}
|
|
1996
|
+
scriptsInserted().push(script.src);
|
|
1997
|
+
const newScript = document.createElement("script");
|
|
1998
|
+
newScript.async = true;
|
|
1999
|
+
newScript.src = script.src;
|
|
2000
|
+
document.head.appendChild(newScript);
|
|
2001
|
+
} else if (!script.type || [
|
|
2002
|
+
"text/javascript",
|
|
2003
|
+
"application/javascript",
|
|
2004
|
+
"application/ecmascript"
|
|
2005
|
+
].includes(script.type)) {
|
|
2006
|
+
if (scriptsRun().includes(script.innerText)) {
|
|
2007
|
+
continue;
|
|
2008
|
+
}
|
|
2009
|
+
try {
|
|
2010
|
+
scriptsRun().push(script.innerText);
|
|
2011
|
+
new Function(script.innerText)();
|
|
2012
|
+
} catch (error) {
|
|
2013
|
+
console.warn("`CustomCode`: Error running script:", error);
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
});
|
|
2018
|
+
return <div
|
|
2019
|
+
class={"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")}
|
|
2020
|
+
ref={elementRef}
|
|
2021
|
+
innerHTML={props.code}
|
|
2022
|
+
/>;
|
|
2023
|
+
}
|
|
2024
|
+
var custom_code_default = CustomCode;
|
|
2025
|
+
|
|
2026
|
+
// src/blocks/embed/component-info.ts
|
|
2077
2027
|
var componentInfo4 = {
|
|
2028
|
+
name: "Embed",
|
|
2029
|
+
static: true,
|
|
2030
|
+
inputs: [{
|
|
2031
|
+
name: "url",
|
|
2032
|
+
type: "url",
|
|
2033
|
+
required: true,
|
|
2034
|
+
defaultValue: "",
|
|
2035
|
+
helperText: "e.g. enter a youtube url, google map, etc",
|
|
2036
|
+
onChange: (options) => {
|
|
2037
|
+
const url = options.get("url");
|
|
2038
|
+
if (url) {
|
|
2039
|
+
options.set("content", "Loading...");
|
|
2040
|
+
const apiKey = "ae0e60e78201a3f2b0de4b";
|
|
2041
|
+
return fetch(`https://iframe.ly/api/iframely?url=${url}&api_key=${apiKey}`).then((res) => res.json()).then((data) => {
|
|
2042
|
+
if (options.get("url") === url) {
|
|
2043
|
+
if (data.html) {
|
|
2044
|
+
options.set("content", data.html);
|
|
2045
|
+
} else {
|
|
2046
|
+
options.set("content", "Invalid url, please try another");
|
|
2047
|
+
}
|
|
2048
|
+
}
|
|
2049
|
+
}).catch((_err) => {
|
|
2050
|
+
options.set("content", "There was an error embedding this URL, please try again or another URL");
|
|
2051
|
+
});
|
|
2052
|
+
} else {
|
|
2053
|
+
options.delete("content");
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
2056
|
+
}, {
|
|
2057
|
+
name: "content",
|
|
2058
|
+
type: "html",
|
|
2059
|
+
defaultValue: '<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',
|
|
2060
|
+
hideFromUI: true
|
|
2061
|
+
}]
|
|
2062
|
+
};
|
|
2063
|
+
|
|
2064
|
+
// src/blocks/embed/embed.tsx
|
|
2065
|
+
import { on, createEffect, createSignal as createSignal8 } from "solid-js";
|
|
2066
|
+
|
|
2067
|
+
// src/blocks/embed/helpers.ts
|
|
2068
|
+
var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
|
|
2069
|
+
var isJsScript = (script) => SCRIPT_MIME_TYPES.includes(script.type);
|
|
2070
|
+
|
|
2071
|
+
// src/blocks/embed/embed.tsx
|
|
2072
|
+
function Embed(props) {
|
|
2073
|
+
const [scriptsInserted, setScriptsInserted] = createSignal8([]);
|
|
2074
|
+
const [scriptsRun, setScriptsRun] = createSignal8([]);
|
|
2075
|
+
const [ranInitFn, setRanInitFn] = createSignal8(false);
|
|
2076
|
+
function findAndRunScripts() {
|
|
2077
|
+
if (!elem || !elem.getElementsByTagName)
|
|
2078
|
+
return;
|
|
2079
|
+
const scripts = elem.getElementsByTagName("script");
|
|
2080
|
+
for (let i = 0; i < scripts.length; i++) {
|
|
2081
|
+
const script = scripts[i];
|
|
2082
|
+
if (script.src && !scriptsInserted().includes(script.src)) {
|
|
2083
|
+
scriptsInserted().push(script.src);
|
|
2084
|
+
const newScript = document.createElement("script");
|
|
2085
|
+
newScript.async = true;
|
|
2086
|
+
newScript.src = script.src;
|
|
2087
|
+
document.head.appendChild(newScript);
|
|
2088
|
+
} else if (isJsScript(script) && !scriptsRun().includes(script.innerText)) {
|
|
2089
|
+
try {
|
|
2090
|
+
scriptsRun().push(script.innerText);
|
|
2091
|
+
new Function(script.innerText)();
|
|
2092
|
+
} catch (error) {
|
|
2093
|
+
console.warn("`Embed`: Error running script:", error);
|
|
2094
|
+
}
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2098
|
+
let elem;
|
|
2099
|
+
function onUpdateFn_0() {
|
|
2100
|
+
if (elem && !ranInitFn()) {
|
|
2101
|
+
setRanInitFn(true);
|
|
2102
|
+
findAndRunScripts();
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
createEffect(on(() => [elem, ranInitFn()], onUpdateFn_0));
|
|
2106
|
+
return <div class="builder-embed" ref={elem} innerHTML={props.content} />;
|
|
2107
|
+
}
|
|
2108
|
+
var embed_default = Embed;
|
|
2109
|
+
|
|
2110
|
+
// src/blocks/fragment/component-info.ts
|
|
2111
|
+
var componentInfo5 = {
|
|
2112
|
+
name: "Fragment",
|
|
2113
|
+
static: true,
|
|
2114
|
+
hidden: true,
|
|
2115
|
+
canHaveChildren: true,
|
|
2116
|
+
noWrap: true
|
|
2117
|
+
};
|
|
2118
|
+
|
|
2119
|
+
// src/blocks/image/component-info.ts
|
|
2120
|
+
var componentInfo6 = {
|
|
2078
2121
|
name: "Image",
|
|
2079
2122
|
static: true,
|
|
2080
2123
|
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",
|
|
@@ -2196,8 +2239,41 @@ var componentInfo4 = {
|
|
|
2196
2239
|
}]
|
|
2197
2240
|
};
|
|
2198
2241
|
|
|
2199
|
-
// src/blocks/
|
|
2200
|
-
var
|
|
2242
|
+
// src/blocks/img/component-info.ts
|
|
2243
|
+
var componentInfo7 = {
|
|
2244
|
+
// friendlyName?
|
|
2245
|
+
name: "Raw:Img",
|
|
2246
|
+
hideFromInsertMenu: true,
|
|
2247
|
+
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",
|
|
2248
|
+
inputs: [{
|
|
2249
|
+
name: "image",
|
|
2250
|
+
bubble: true,
|
|
2251
|
+
type: "file",
|
|
2252
|
+
allowedFileTypes: ["jpeg", "jpg", "png", "svg", "gif", "webp"],
|
|
2253
|
+
required: true
|
|
2254
|
+
}],
|
|
2255
|
+
noWrap: true,
|
|
2256
|
+
static: true
|
|
2257
|
+
};
|
|
2258
|
+
|
|
2259
|
+
// src/blocks/img/img.tsx
|
|
2260
|
+
function ImgComponent(props) {
|
|
2261
|
+
return <img
|
|
2262
|
+
style={{
|
|
2263
|
+
"object-fit": props.backgroundSize || "cover",
|
|
2264
|
+
"object-position": props.backgroundPosition || "center"
|
|
2265
|
+
}}
|
|
2266
|
+
key={isEditing() && props.imgSrc || "default-key"}
|
|
2267
|
+
alt={props.altText}
|
|
2268
|
+
src={props.imgSrc || props.image}
|
|
2269
|
+
{...{}}
|
|
2270
|
+
{...props.attributes}
|
|
2271
|
+
/>;
|
|
2272
|
+
}
|
|
2273
|
+
var img_default = ImgComponent;
|
|
2274
|
+
|
|
2275
|
+
// src/blocks/section/component-info.ts
|
|
2276
|
+
var componentInfo8 = {
|
|
2201
2277
|
name: "Core:Section",
|
|
2202
2278
|
static: true,
|
|
2203
2279
|
image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F682efef23ace49afac61748dd305c70a",
|
|
@@ -2238,8 +2314,8 @@ var componentInfo5 = {
|
|
|
2238
2314
|
}]
|
|
2239
2315
|
};
|
|
2240
2316
|
|
|
2241
|
-
// src/blocks/symbol/component-info.
|
|
2242
|
-
var
|
|
2317
|
+
// src/blocks/symbol/component-info.ts
|
|
2318
|
+
var componentInfo9 = {
|
|
2243
2319
|
name: "Symbol",
|
|
2244
2320
|
noWrap: true,
|
|
2245
2321
|
static: true,
|
|
@@ -2274,8 +2350,8 @@ var componentInfo6 = {
|
|
|
2274
2350
|
}]
|
|
2275
2351
|
};
|
|
2276
2352
|
|
|
2277
|
-
// src/blocks/text/component-info.
|
|
2278
|
-
var
|
|
2353
|
+
// src/blocks/text/component-info.ts
|
|
2354
|
+
var componentInfo10 = {
|
|
2279
2355
|
name: "Text",
|
|
2280
2356
|
static: true,
|
|
2281
2357
|
isRSC: true,
|
|
@@ -2295,7 +2371,7 @@ var componentInfo7 = {
|
|
|
2295
2371
|
}
|
|
2296
2372
|
};
|
|
2297
2373
|
|
|
2298
|
-
// src/blocks/text/text.
|
|
2374
|
+
// src/blocks/text/text.tsx
|
|
2299
2375
|
function Text(props) {
|
|
2300
2376
|
return <div
|
|
2301
2377
|
class="builder-text"
|
|
@@ -2307,8 +2383,8 @@ function Text(props) {
|
|
|
2307
2383
|
}
|
|
2308
2384
|
var text_default = Text;
|
|
2309
2385
|
|
|
2310
|
-
// src/blocks/video/component-info.
|
|
2311
|
-
var
|
|
2386
|
+
// src/blocks/video/component-info.ts
|
|
2387
|
+
var componentInfo11 = {
|
|
2312
2388
|
name: "Video",
|
|
2313
2389
|
canHaveChildren: true,
|
|
2314
2390
|
defaultStyles: {
|
|
@@ -2391,8 +2467,7 @@ var componentInfo8 = {
|
|
|
2391
2467
|
}]
|
|
2392
2468
|
};
|
|
2393
2469
|
|
|
2394
|
-
// src/blocks/video/video.
|
|
2395
|
-
import { createSignal as createSignal8 } from "solid-js";
|
|
2470
|
+
// src/blocks/video/video.tsx
|
|
2396
2471
|
function Video(props) {
|
|
2397
2472
|
function videoProps() {
|
|
2398
2473
|
return {
|
|
@@ -2438,1218 +2513,273 @@ function Video(props) {
|
|
|
2438
2513
|
}
|
|
2439
2514
|
var video_default = Video;
|
|
2440
2515
|
|
|
2441
|
-
// src/
|
|
2442
|
-
var
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2516
|
+
// src/constants/builder-registered-components.ts
|
|
2517
|
+
var getDefaultRegisteredComponents = () => [{
|
|
2518
|
+
component: button_default,
|
|
2519
|
+
...componentInfo
|
|
2520
|
+
}, {
|
|
2521
|
+
component: columns_default,
|
|
2522
|
+
...componentInfo2
|
|
2523
|
+
}, {
|
|
2524
|
+
component: custom_code_default,
|
|
2525
|
+
...componentInfo3
|
|
2526
|
+
}, {
|
|
2527
|
+
component: embed_default,
|
|
2528
|
+
...componentInfo4
|
|
2529
|
+
}, {
|
|
2530
|
+
component: fragment_default,
|
|
2531
|
+
...componentInfo5
|
|
2532
|
+
}, {
|
|
2533
|
+
component: image_default,
|
|
2534
|
+
...componentInfo6
|
|
2535
|
+
}, {
|
|
2536
|
+
component: img_default,
|
|
2537
|
+
...componentInfo7
|
|
2538
|
+
}, {
|
|
2539
|
+
component: section_default,
|
|
2540
|
+
...componentInfo8
|
|
2541
|
+
}, {
|
|
2542
|
+
component: symbol_default,
|
|
2543
|
+
...componentInfo9
|
|
2544
|
+
}, {
|
|
2545
|
+
component: text_default,
|
|
2546
|
+
...componentInfo10
|
|
2547
|
+
}, {
|
|
2548
|
+
component: video_default,
|
|
2549
|
+
...componentInfo11
|
|
2550
|
+
}];
|
|
2551
|
+
|
|
2552
|
+
// src/functions/register-component.ts
|
|
2553
|
+
var components = [];
|
|
2554
|
+
var createRegisterComponentMessage = (info) => ({
|
|
2555
|
+
type: "builder.registerComponent",
|
|
2556
|
+
data: serializeComponentInfo(info)
|
|
2557
|
+
});
|
|
2558
|
+
var serializeFn = (fnValue) => {
|
|
2559
|
+
const fnStr = fnValue.toString().trim();
|
|
2560
|
+
const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(");
|
|
2561
|
+
return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
|
|
2477
2562
|
};
|
|
2563
|
+
var serializeValue = (value) => typeof value === "function" ? serializeFn(value) : fastClone(value);
|
|
2564
|
+
var serializeComponentInfo = ({
|
|
2565
|
+
inputs,
|
|
2566
|
+
...info
|
|
2567
|
+
}) => ({
|
|
2568
|
+
...fastClone(info),
|
|
2569
|
+
inputs: inputs?.map((input) => Object.entries(input).reduce((acc, [key, value]) => ({
|
|
2570
|
+
...acc,
|
|
2571
|
+
[key]: serializeValue(value)
|
|
2572
|
+
}), {}))
|
|
2573
|
+
});
|
|
2478
2574
|
|
|
2479
|
-
// src/
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
// src/blocks/embed/embed.jsx
|
|
2487
|
-
function Embed(props) {
|
|
2488
|
-
const [scriptsInserted, setScriptsInserted] = createSignal9([]);
|
|
2489
|
-
const [scriptsRun, setScriptsRun] = createSignal9([]);
|
|
2490
|
-
const [ranInitFn, setRanInitFn] = createSignal9(false);
|
|
2491
|
-
function findAndRunScripts() {
|
|
2492
|
-
if (!elem || !elem.getElementsByTagName)
|
|
2493
|
-
return;
|
|
2494
|
-
const scripts = elem.getElementsByTagName("script");
|
|
2495
|
-
for (let i = 0; i < scripts.length; i++) {
|
|
2496
|
-
const script = scripts[i];
|
|
2497
|
-
if (script.src && !scriptsInserted().includes(script.src)) {
|
|
2498
|
-
scriptsInserted().push(script.src);
|
|
2499
|
-
const newScript = document.createElement("script");
|
|
2500
|
-
newScript.async = true;
|
|
2501
|
-
newScript.src = script.src;
|
|
2502
|
-
document.head.appendChild(newScript);
|
|
2503
|
-
} else if (isJsScript(script) && !scriptsRun().includes(script.innerText)) {
|
|
2504
|
-
try {
|
|
2505
|
-
scriptsRun().push(script.innerText);
|
|
2506
|
-
new Function(script.innerText)();
|
|
2507
|
-
} catch (error) {
|
|
2508
|
-
console.warn("`Embed`: Error running script:", error);
|
|
2509
|
-
}
|
|
2510
|
-
}
|
|
2511
|
-
}
|
|
2512
|
-
}
|
|
2513
|
-
let elem;
|
|
2514
|
-
function onUpdateFn_0() {
|
|
2515
|
-
if (elem && !ranInitFn()) {
|
|
2516
|
-
setRanInitFn(true);
|
|
2517
|
-
findAndRunScripts();
|
|
2518
|
-
}
|
|
2519
|
-
}
|
|
2520
|
-
createEffect(on(() => [elem, ranInitFn()], onUpdateFn_0));
|
|
2521
|
-
return <div class="builder-embed" ref={elem} innerHTML={props.content} />;
|
|
2522
|
-
}
|
|
2523
|
-
var embed_default = Embed;
|
|
2524
|
-
|
|
2525
|
-
// src/blocks/img/img.jsx
|
|
2526
|
-
function ImgComponent(props) {
|
|
2527
|
-
return <img
|
|
2528
|
-
style={{
|
|
2529
|
-
"object-fit": props.backgroundSize || "cover",
|
|
2530
|
-
"object-position": props.backgroundPosition || "center"
|
|
2531
|
-
}}
|
|
2532
|
-
key={isEditing() && props.imgSrc || "default-key"}
|
|
2533
|
-
alt={props.altText}
|
|
2534
|
-
src={props.imgSrc || props.image}
|
|
2535
|
-
{...{}}
|
|
2536
|
-
{...props.attributes}
|
|
2537
|
-
/>;
|
|
2538
|
-
}
|
|
2539
|
-
var img_default = ImgComponent;
|
|
2540
|
-
|
|
2541
|
-
// src/blocks/img/component-info.js
|
|
2542
|
-
var componentInfo10 = {
|
|
2543
|
-
name: "Raw:Img",
|
|
2544
|
-
hideFromInsertMenu: true,
|
|
2545
|
-
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",
|
|
2546
|
-
inputs: [{
|
|
2547
|
-
name: "image",
|
|
2548
|
-
bubble: true,
|
|
2549
|
-
type: "file",
|
|
2550
|
-
allowedFileTypes: ["jpeg", "jpg", "png", "svg", "gif", "webp"],
|
|
2551
|
-
required: true
|
|
2552
|
-
}],
|
|
2553
|
-
noWrap: true,
|
|
2554
|
-
static: true
|
|
2555
|
-
};
|
|
2556
|
-
|
|
2557
|
-
// src/blocks/custom-code/custom-code.jsx
|
|
2558
|
-
import { onMount, createSignal as createSignal10 } from "solid-js";
|
|
2559
|
-
function CustomCode(props) {
|
|
2560
|
-
const [scriptsInserted, setScriptsInserted] = createSignal10([]);
|
|
2561
|
-
const [scriptsRun, setScriptsRun] = createSignal10([]);
|
|
2562
|
-
let elementRef;
|
|
2563
|
-
onMount(() => {
|
|
2564
|
-
if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
|
|
2565
|
-
return;
|
|
2566
|
-
}
|
|
2567
|
-
const scripts = elementRef.getElementsByTagName("script");
|
|
2568
|
-
for (let i = 0; i < scripts.length; i++) {
|
|
2569
|
-
const script = scripts[i];
|
|
2570
|
-
if (script.src) {
|
|
2571
|
-
if (scriptsInserted().includes(script.src)) {
|
|
2572
|
-
continue;
|
|
2573
|
-
}
|
|
2574
|
-
scriptsInserted().push(script.src);
|
|
2575
|
-
const newScript = document.createElement("script");
|
|
2576
|
-
newScript.async = true;
|
|
2577
|
-
newScript.src = script.src;
|
|
2578
|
-
document.head.appendChild(newScript);
|
|
2579
|
-
} else if (!script.type || [
|
|
2580
|
-
"text/javascript",
|
|
2581
|
-
"application/javascript",
|
|
2582
|
-
"application/ecmascript"
|
|
2583
|
-
].includes(script.type)) {
|
|
2584
|
-
if (scriptsRun().includes(script.innerText)) {
|
|
2585
|
-
continue;
|
|
2586
|
-
}
|
|
2587
|
-
try {
|
|
2588
|
-
scriptsRun().push(script.innerText);
|
|
2589
|
-
new Function(script.innerText)();
|
|
2590
|
-
} catch (error) {
|
|
2591
|
-
console.warn("`CustomCode`: Error running script:", error);
|
|
2592
|
-
}
|
|
2593
|
-
}
|
|
2594
|
-
}
|
|
2595
|
-
});
|
|
2596
|
-
return <div
|
|
2597
|
-
class={"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")}
|
|
2598
|
-
ref={elementRef}
|
|
2599
|
-
innerHTML={props.code}
|
|
2600
|
-
/>;
|
|
2601
|
-
}
|
|
2602
|
-
var custom_code_default = CustomCode;
|
|
2603
|
-
|
|
2604
|
-
// src/blocks/custom-code/component-info.js
|
|
2605
|
-
var componentInfo11 = {
|
|
2606
|
-
name: "Custom Code",
|
|
2607
|
-
static: true,
|
|
2608
|
-
requiredPermissions: ["editCode"],
|
|
2609
|
-
inputs: [{
|
|
2610
|
-
name: "code",
|
|
2611
|
-
type: "html",
|
|
2612
|
-
required: true,
|
|
2613
|
-
defaultValue: "<p>Hello there, I am custom HTML code!</p>",
|
|
2614
|
-
code: true
|
|
2615
|
-
}, {
|
|
2616
|
-
name: "replaceNodes",
|
|
2617
|
-
type: "boolean",
|
|
2618
|
-
helperText: "Preserve server rendered dom nodes",
|
|
2619
|
-
advanced: true
|
|
2620
|
-
}, {
|
|
2621
|
-
name: "scriptsClientOnly",
|
|
2622
|
-
type: "boolean",
|
|
2623
|
-
defaultValue: false,
|
|
2624
|
-
helperText: "Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads",
|
|
2625
|
-
advanced: true
|
|
2626
|
-
}]
|
|
2627
|
-
};
|
|
2628
|
-
|
|
2629
|
-
// src/constants/builder-registered-components.js
|
|
2630
|
-
var __defProp10 = Object.defineProperty;
|
|
2631
|
-
var __getOwnPropSymbols10 = Object.getOwnPropertySymbols;
|
|
2632
|
-
var __hasOwnProp10 = Object.prototype.hasOwnProperty;
|
|
2633
|
-
var __propIsEnum10 = Object.prototype.propertyIsEnumerable;
|
|
2634
|
-
var __defNormalProp10 = (obj, key, value) => key in obj ? __defProp10(obj, key, {
|
|
2635
|
-
enumerable: true,
|
|
2636
|
-
configurable: true,
|
|
2637
|
-
writable: true,
|
|
2638
|
-
value
|
|
2639
|
-
}) : obj[key] = value;
|
|
2640
|
-
var __spreadValues10 = (a, b) => {
|
|
2641
|
-
for (var prop in b || (b = {}))
|
|
2642
|
-
if (__hasOwnProp10.call(b, prop))
|
|
2643
|
-
__defNormalProp10(a, prop, b[prop]);
|
|
2644
|
-
if (__getOwnPropSymbols10)
|
|
2645
|
-
for (var prop of __getOwnPropSymbols10(b)) {
|
|
2646
|
-
if (__propIsEnum10.call(b, prop))
|
|
2647
|
-
__defNormalProp10(a, prop, b[prop]);
|
|
2648
|
-
}
|
|
2649
|
-
return a;
|
|
2650
|
-
};
|
|
2651
|
-
var getDefaultRegisteredComponents = () => [__spreadValues10({
|
|
2652
|
-
component: button_default
|
|
2653
|
-
}, componentInfo), __spreadValues10({
|
|
2654
|
-
component: columns_default
|
|
2655
|
-
}, componentInfo2), __spreadValues10({
|
|
2656
|
-
component: custom_code_default
|
|
2657
|
-
}, componentInfo11), __spreadValues10({
|
|
2658
|
-
component: embed_default
|
|
2659
|
-
}, componentInfo9), __spreadValues10({
|
|
2660
|
-
component: fragment_default
|
|
2661
|
-
}, componentInfo3), __spreadValues10({
|
|
2662
|
-
component: image_default
|
|
2663
|
-
}, componentInfo4), __spreadValues10({
|
|
2664
|
-
component: img_default
|
|
2665
|
-
}, componentInfo10), __spreadValues10({
|
|
2666
|
-
component: section_default
|
|
2667
|
-
}, componentInfo5), __spreadValues10({
|
|
2668
|
-
component: symbol_default
|
|
2669
|
-
}, componentInfo6), __spreadValues10({
|
|
2670
|
-
component: text_default
|
|
2671
|
-
}, componentInfo7), __spreadValues10({
|
|
2672
|
-
component: video_default
|
|
2673
|
-
}, componentInfo8)];
|
|
2674
|
-
|
|
2675
|
-
// src/functions/register-component.js
|
|
2676
|
-
var __defProp11 = Object.defineProperty;
|
|
2677
|
-
var __defProps8 = Object.defineProperties;
|
|
2678
|
-
var __getOwnPropDescs8 = Object.getOwnPropertyDescriptors;
|
|
2679
|
-
var __getOwnPropSymbols11 = Object.getOwnPropertySymbols;
|
|
2680
|
-
var __hasOwnProp11 = Object.prototype.hasOwnProperty;
|
|
2681
|
-
var __propIsEnum11 = Object.prototype.propertyIsEnumerable;
|
|
2682
|
-
var __defNormalProp11 = (obj, key, value) => key in obj ? __defProp11(obj, key, {
|
|
2683
|
-
enumerable: true,
|
|
2684
|
-
configurable: true,
|
|
2685
|
-
writable: true,
|
|
2686
|
-
value
|
|
2687
|
-
}) : obj[key] = value;
|
|
2688
|
-
var __spreadValues11 = (a, b) => {
|
|
2689
|
-
for (var prop in b || (b = {}))
|
|
2690
|
-
if (__hasOwnProp11.call(b, prop))
|
|
2691
|
-
__defNormalProp11(a, prop, b[prop]);
|
|
2692
|
-
if (__getOwnPropSymbols11)
|
|
2693
|
-
for (var prop of __getOwnPropSymbols11(b)) {
|
|
2694
|
-
if (__propIsEnum11.call(b, prop))
|
|
2695
|
-
__defNormalProp11(a, prop, b[prop]);
|
|
2696
|
-
}
|
|
2697
|
-
return a;
|
|
2698
|
-
};
|
|
2699
|
-
var __spreadProps8 = (a, b) => __defProps8(a, __getOwnPropDescs8(b));
|
|
2700
|
-
var __objRest2 = (source, exclude) => {
|
|
2701
|
-
var target = {};
|
|
2702
|
-
for (var prop in source)
|
|
2703
|
-
if (__hasOwnProp11.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
2704
|
-
target[prop] = source[prop];
|
|
2705
|
-
if (source != null && __getOwnPropSymbols11)
|
|
2706
|
-
for (var prop of __getOwnPropSymbols11(source)) {
|
|
2707
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum11.call(source, prop))
|
|
2708
|
-
target[prop] = source[prop];
|
|
2709
|
-
}
|
|
2710
|
-
return target;
|
|
2711
|
-
};
|
|
2712
|
-
var components = [];
|
|
2713
|
-
var createRegisterComponentMessage = (info) => ({
|
|
2714
|
-
type: "builder.registerComponent",
|
|
2715
|
-
data: serializeComponentInfo(info)
|
|
2716
|
-
});
|
|
2717
|
-
var serializeFn = (fnValue) => {
|
|
2718
|
-
const fnStr = fnValue.toString().trim();
|
|
2719
|
-
const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(");
|
|
2720
|
-
return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
|
|
2721
|
-
};
|
|
2722
|
-
var serializeValue = (value) => typeof value === "function" ? serializeFn(value) : fastClone(value);
|
|
2723
|
-
var serializeComponentInfo = (_a) => {
|
|
2724
|
-
var _b = _a, {
|
|
2725
|
-
inputs
|
|
2726
|
-
} = _b, info = __objRest2(_b, ["inputs"]);
|
|
2727
|
-
return __spreadProps8(__spreadValues11({}, fastClone(info)), {
|
|
2728
|
-
inputs: inputs == null ? void 0 : inputs.map((input) => Object.entries(input).reduce((acc, [key, value]) => __spreadProps8(__spreadValues11({}, acc), {
|
|
2729
|
-
[key]: serializeValue(value)
|
|
2730
|
-
}), {}))
|
|
2731
|
-
});
|
|
2732
|
-
};
|
|
2733
|
-
|
|
2734
|
-
// src/components/content/components/styles.jsx
|
|
2735
|
-
import { createSignal as createSignal11 } from "solid-js";
|
|
2736
|
-
|
|
2737
|
-
// src/components/content/components/styles.helpers.js
|
|
2738
|
-
var getCssFromFont = (font) => {
|
|
2739
|
-
var _a, _b;
|
|
2740
|
-
const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
|
|
2741
|
-
const name = family.split(",")[0];
|
|
2742
|
-
const url = (_b = font.fileUrl) != null ? _b : (_a = font == null ? void 0 : font.files) == null ? void 0 : _a.regular;
|
|
2743
|
-
let str = "";
|
|
2744
|
-
if (url && family && name) {
|
|
2745
|
-
str += `
|
|
2746
|
-
@font-face {
|
|
2747
|
-
font-family: "${family}";
|
|
2748
|
-
src: local("${name}"), url('${url}') format('woff2');
|
|
2749
|
-
font-display: fallback;
|
|
2750
|
-
font-weight: 400;
|
|
2751
|
-
}
|
|
2752
|
-
`.trim();
|
|
2753
|
-
}
|
|
2754
|
-
if (font.files) {
|
|
2755
|
-
for (const weight in font.files) {
|
|
2756
|
-
const isNumber = String(Number(weight)) === weight;
|
|
2757
|
-
if (!isNumber) {
|
|
2758
|
-
continue;
|
|
2759
|
-
}
|
|
2760
|
-
const weightUrl = font.files[weight];
|
|
2761
|
-
if (weightUrl && weightUrl !== url) {
|
|
2762
|
-
str += `
|
|
2763
|
-
@font-face {
|
|
2764
|
-
font-family: "${family}";
|
|
2765
|
-
src: url('${weightUrl}') format('woff2');
|
|
2766
|
-
font-display: fallback;
|
|
2767
|
-
font-weight: ${weight};
|
|
2768
|
-
}
|
|
2769
|
-
`.trim();
|
|
2770
|
-
}
|
|
2771
|
-
}
|
|
2772
|
-
}
|
|
2773
|
-
return str;
|
|
2774
|
-
};
|
|
2775
|
-
var getFontCss = ({
|
|
2776
|
-
customFonts
|
|
2777
|
-
}) => {
|
|
2778
|
-
var _a;
|
|
2779
|
-
return ((_a = customFonts == null ? void 0 : customFonts.map((font) => getCssFromFont(font))) == null ? void 0 : _a.join(" ")) || "";
|
|
2780
|
-
};
|
|
2781
|
-
var getCss = ({
|
|
2782
|
-
cssCode,
|
|
2783
|
-
contentId
|
|
2784
|
-
}) => {
|
|
2785
|
-
if (!cssCode) {
|
|
2786
|
-
return "";
|
|
2787
|
-
}
|
|
2788
|
-
if (!contentId) {
|
|
2789
|
-
return cssCode;
|
|
2790
|
-
}
|
|
2791
|
-
return (cssCode == null ? void 0 : cssCode.replace(/&/g, `div[builder-content-id="${contentId}"]`)) || "";
|
|
2792
|
-
};
|
|
2793
|
-
|
|
2794
|
-
// src/components/content/components/styles.jsx
|
|
2795
|
-
function ContentStyles(props) {
|
|
2796
|
-
const [injectedStyles, setInjectedStyles] = createSignal11(
|
|
2797
|
-
`
|
|
2798
|
-
${getCss({
|
|
2799
|
-
cssCode: props.cssCode,
|
|
2800
|
-
contentId: props.contentId
|
|
2801
|
-
})}
|
|
2802
|
-
${getFontCss({
|
|
2803
|
-
customFonts: props.customFonts
|
|
2804
|
-
})}
|
|
2805
|
-
|
|
2806
|
-
.builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
|
|
2807
|
-
margin: 0;
|
|
2808
|
-
}
|
|
2809
|
-
.builder-text > p, .builder-text > .builder-paragraph {
|
|
2810
|
-
color: inherit;
|
|
2811
|
-
line-height: inherit;
|
|
2812
|
-
letter-spacing: inherit;
|
|
2813
|
-
font-weight: inherit;
|
|
2814
|
-
font-size: inherit;
|
|
2815
|
-
text-align: inherit;
|
|
2816
|
-
font-family: inherit;
|
|
2817
|
-
}
|
|
2818
|
-
`.trim()
|
|
2819
|
-
);
|
|
2820
|
-
return <Inlined_styles_default styles={injectedStyles()} />;
|
|
2821
|
-
}
|
|
2822
|
-
var Styles_default = ContentStyles;
|
|
2823
|
-
|
|
2824
|
-
// src/components/content/content.helpers.js
|
|
2825
|
-
var __defProp12 = Object.defineProperty;
|
|
2826
|
-
var __defProps9 = Object.defineProperties;
|
|
2827
|
-
var __getOwnPropDescs9 = Object.getOwnPropertyDescriptors;
|
|
2828
|
-
var __getOwnPropSymbols12 = Object.getOwnPropertySymbols;
|
|
2829
|
-
var __hasOwnProp12 = Object.prototype.hasOwnProperty;
|
|
2830
|
-
var __propIsEnum12 = Object.prototype.propertyIsEnumerable;
|
|
2831
|
-
var __defNormalProp12 = (obj, key, value) => key in obj ? __defProp12(obj, key, {
|
|
2832
|
-
enumerable: true,
|
|
2833
|
-
configurable: true,
|
|
2834
|
-
writable: true,
|
|
2835
|
-
value
|
|
2836
|
-
}) : obj[key] = value;
|
|
2837
|
-
var __spreadValues12 = (a, b) => {
|
|
2838
|
-
for (var prop in b || (b = {}))
|
|
2839
|
-
if (__hasOwnProp12.call(b, prop))
|
|
2840
|
-
__defNormalProp12(a, prop, b[prop]);
|
|
2841
|
-
if (__getOwnPropSymbols12)
|
|
2842
|
-
for (var prop of __getOwnPropSymbols12(b)) {
|
|
2843
|
-
if (__propIsEnum12.call(b, prop))
|
|
2844
|
-
__defNormalProp12(a, prop, b[prop]);
|
|
2845
|
-
}
|
|
2846
|
-
return a;
|
|
2847
|
-
};
|
|
2848
|
-
var __spreadProps9 = (a, b) => __defProps9(a, __getOwnPropDescs9(b));
|
|
2849
|
-
var getContextStateInitialValue = ({
|
|
2850
|
-
content,
|
|
2851
|
-
data,
|
|
2852
|
-
locale
|
|
2853
|
-
}) => {
|
|
2854
|
-
var _a, _b, _c;
|
|
2855
|
-
const defaultValues = {};
|
|
2856
|
-
(_b = (_a = content == null ? void 0 : content.data) == null ? void 0 : _a.inputs) == null ? void 0 : _b.forEach((input) => {
|
|
2857
|
-
var _a2;
|
|
2858
|
-
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) {
|
|
2859
|
-
defaultValues[input.name] = input.defaultValue;
|
|
2860
|
-
}
|
|
2861
|
-
});
|
|
2862
|
-
const stateToUse = __spreadValues12(__spreadValues12(__spreadValues12({}, (_c = content == null ? void 0 : content.data) == null ? void 0 : _c.state), data), locale ? {
|
|
2863
|
-
locale
|
|
2864
|
-
} : {});
|
|
2865
|
-
return __spreadValues12(__spreadValues12({}, defaultValues), stateToUse);
|
|
2866
|
-
};
|
|
2867
|
-
var getContentInitialValue = ({
|
|
2868
|
-
content,
|
|
2869
|
-
data
|
|
2870
|
-
}) => {
|
|
2871
|
-
return !content ? void 0 : __spreadProps9(__spreadValues12({}, content), {
|
|
2872
|
-
data: __spreadValues12(__spreadValues12({}, content == null ? void 0 : content.data), data),
|
|
2873
|
-
meta: content == null ? void 0 : content.meta
|
|
2874
|
-
});
|
|
2875
|
-
};
|
|
2876
|
-
|
|
2877
|
-
// src/components/content/components/enable-editor.jsx
|
|
2878
|
-
import { Show as Show9, onMount as onMount2, on as on2, createEffect as createEffect2, createSignal as createSignal12 } from "solid-js";
|
|
2879
|
-
|
|
2880
|
-
// src/functions/get-global-this.js
|
|
2881
|
-
function getGlobalThis() {
|
|
2882
|
-
if (typeof globalThis !== "undefined") {
|
|
2883
|
-
return globalThis;
|
|
2884
|
-
}
|
|
2885
|
-
if (typeof window !== "undefined") {
|
|
2886
|
-
return window;
|
|
2887
|
-
}
|
|
2888
|
-
if (typeof global !== "undefined") {
|
|
2889
|
-
return global;
|
|
2890
|
-
}
|
|
2891
|
-
if (typeof self !== "undefined") {
|
|
2892
|
-
return self;
|
|
2893
|
-
}
|
|
2894
|
-
return globalThis;
|
|
2895
|
-
}
|
|
2896
|
-
|
|
2897
|
-
// src/functions/get-fetch.js
|
|
2898
|
-
function getFetch() {
|
|
2899
|
-
const globalFetch = getGlobalThis().fetch;
|
|
2900
|
-
if (typeof globalFetch === "undefined") {
|
|
2901
|
-
console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
|
|
2902
|
-
For more information, read https://github.com/BuilderIO/this-package-uses-fetch`);
|
|
2903
|
-
throw new Error("Builder SDK could not find a global `fetch` function");
|
|
2904
|
-
}
|
|
2905
|
-
return globalFetch;
|
|
2906
|
-
}
|
|
2907
|
-
var fetch2 = getFetch();
|
|
2908
|
-
|
|
2909
|
-
// src/helpers/url.js
|
|
2910
|
-
var getTopLevelDomain = (host) => {
|
|
2911
|
-
if (host === "localhost" || host === "127.0.0.1") {
|
|
2912
|
-
return host;
|
|
2913
|
-
}
|
|
2914
|
-
const parts = host.split(".");
|
|
2915
|
-
if (parts.length > 2) {
|
|
2916
|
-
return parts.slice(1).join(".");
|
|
2917
|
-
}
|
|
2918
|
-
return host;
|
|
2919
|
-
};
|
|
2920
|
-
|
|
2921
|
-
// src/helpers/cookie.js
|
|
2922
|
-
var __async = (__this, __arguments, generator) => {
|
|
2923
|
-
return new Promise((resolve, reject) => {
|
|
2924
|
-
var fulfilled = (value) => {
|
|
2925
|
-
try {
|
|
2926
|
-
step(generator.next(value));
|
|
2927
|
-
} catch (e) {
|
|
2928
|
-
reject(e);
|
|
2929
|
-
}
|
|
2930
|
-
};
|
|
2931
|
-
var rejected = (value) => {
|
|
2932
|
-
try {
|
|
2933
|
-
step(generator.throw(value));
|
|
2934
|
-
} catch (e) {
|
|
2935
|
-
reject(e);
|
|
2936
|
-
}
|
|
2937
|
-
};
|
|
2938
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
2939
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
2940
|
-
});
|
|
2941
|
-
};
|
|
2942
|
-
var getCookieSync = ({
|
|
2943
|
-
name,
|
|
2944
|
-
canTrack
|
|
2945
|
-
}) => {
|
|
2946
|
-
var _a;
|
|
2947
|
-
try {
|
|
2948
|
-
if (!canTrack) {
|
|
2949
|
-
return void 0;
|
|
2950
|
-
}
|
|
2951
|
-
return (_a = document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))) == null ? void 0 : _a.split("=")[1];
|
|
2952
|
-
} catch (err) {
|
|
2953
|
-
logger.warn("[COOKIE] GET error: ", (err == null ? void 0 : err.message) || err);
|
|
2954
|
-
return void 0;
|
|
2955
|
-
}
|
|
2956
|
-
};
|
|
2957
|
-
var getCookie = (args) => __async(void 0, null, function* () {
|
|
2958
|
-
return getCookieSync(args);
|
|
2959
|
-
});
|
|
2960
|
-
var stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).filter(checkIsDefined).join("; ");
|
|
2961
|
-
var SECURE_CONFIG = [["secure", ""], ["SameSite", "None"]];
|
|
2962
|
-
var createCookieString = ({
|
|
2963
|
-
name,
|
|
2964
|
-
value,
|
|
2965
|
-
expires
|
|
2966
|
-
}) => {
|
|
2967
|
-
const secure = isBrowser() ? location.protocol === "https:" : true;
|
|
2968
|
-
const secureObj = secure ? SECURE_CONFIG : [[]];
|
|
2969
|
-
const expiresObj = expires ? [["expires", expires.toUTCString()]] : [[]];
|
|
2970
|
-
const cookieValue = [[name, value], ...expiresObj, ["path", "/"], ["domain", getTopLevelDomain(window.location.hostname)], ...secureObj];
|
|
2971
|
-
const cookie = stringifyCookie(cookieValue);
|
|
2972
|
-
return cookie;
|
|
2973
|
-
};
|
|
2974
|
-
var setCookie = (_0) => __async(void 0, [_0], function* ({
|
|
2975
|
-
name,
|
|
2976
|
-
value,
|
|
2977
|
-
expires,
|
|
2978
|
-
canTrack
|
|
2979
|
-
}) {
|
|
2980
|
-
try {
|
|
2981
|
-
if (!canTrack) {
|
|
2982
|
-
return;
|
|
2983
|
-
}
|
|
2984
|
-
const cookie = createCookieString({
|
|
2985
|
-
name,
|
|
2986
|
-
value,
|
|
2987
|
-
expires
|
|
2988
|
-
});
|
|
2989
|
-
document.cookie = cookie;
|
|
2990
|
-
} catch (err) {
|
|
2991
|
-
logger.warn("[COOKIE] SET error: ", (err == null ? void 0 : err.message) || err);
|
|
2992
|
-
}
|
|
2993
|
-
});
|
|
2994
|
-
|
|
2995
|
-
// src/helpers/uuid.js
|
|
2996
|
-
function uuidv4() {
|
|
2997
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
2998
|
-
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
|
2999
|
-
return v.toString(16);
|
|
3000
|
-
});
|
|
3001
|
-
}
|
|
3002
|
-
function uuid() {
|
|
3003
|
-
return uuidv4().replace(/-/g, "");
|
|
3004
|
-
}
|
|
3005
|
-
|
|
3006
|
-
// src/helpers/sessionId.js
|
|
3007
|
-
var __async2 = (__this, __arguments, generator) => {
|
|
3008
|
-
return new Promise((resolve, reject) => {
|
|
3009
|
-
var fulfilled = (value) => {
|
|
3010
|
-
try {
|
|
3011
|
-
step(generator.next(value));
|
|
3012
|
-
} catch (e) {
|
|
3013
|
-
reject(e);
|
|
3014
|
-
}
|
|
3015
|
-
};
|
|
3016
|
-
var rejected = (value) => {
|
|
3017
|
-
try {
|
|
3018
|
-
step(generator.throw(value));
|
|
3019
|
-
} catch (e) {
|
|
3020
|
-
reject(e);
|
|
3021
|
-
}
|
|
3022
|
-
};
|
|
3023
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
3024
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
3025
|
-
});
|
|
3026
|
-
};
|
|
3027
|
-
var SESSION_LOCAL_STORAGE_KEY = "builderSessionId";
|
|
3028
|
-
var getSessionId = (_0) => __async2(void 0, [_0], function* ({
|
|
3029
|
-
canTrack
|
|
3030
|
-
}) {
|
|
3031
|
-
if (!canTrack) {
|
|
3032
|
-
return void 0;
|
|
3033
|
-
}
|
|
3034
|
-
const sessionId = yield getCookie({
|
|
3035
|
-
name: SESSION_LOCAL_STORAGE_KEY,
|
|
3036
|
-
canTrack
|
|
3037
|
-
});
|
|
3038
|
-
if (checkIsDefined(sessionId)) {
|
|
3039
|
-
return sessionId;
|
|
3040
|
-
} else {
|
|
3041
|
-
const newSessionId = createSessionId();
|
|
3042
|
-
setSessionId({
|
|
3043
|
-
id: newSessionId,
|
|
3044
|
-
canTrack
|
|
3045
|
-
});
|
|
3046
|
-
return newSessionId;
|
|
3047
|
-
}
|
|
3048
|
-
});
|
|
3049
|
-
var createSessionId = () => uuid();
|
|
3050
|
-
var setSessionId = ({
|
|
3051
|
-
id,
|
|
3052
|
-
canTrack
|
|
3053
|
-
}) => setCookie({
|
|
3054
|
-
name: SESSION_LOCAL_STORAGE_KEY,
|
|
3055
|
-
value: id,
|
|
3056
|
-
canTrack
|
|
3057
|
-
});
|
|
3058
|
-
|
|
3059
|
-
// src/helpers/localStorage.js
|
|
3060
|
-
var getLocalStorage = () => isBrowser() && typeof localStorage !== "undefined" ? localStorage : void 0;
|
|
3061
|
-
var getLocalStorageItem = ({
|
|
3062
|
-
key,
|
|
3063
|
-
canTrack
|
|
3064
|
-
}) => {
|
|
3065
|
-
var _a;
|
|
3066
|
-
try {
|
|
3067
|
-
if (canTrack) {
|
|
3068
|
-
return (_a = getLocalStorage()) == null ? void 0 : _a.getItem(key);
|
|
3069
|
-
}
|
|
3070
|
-
return void 0;
|
|
3071
|
-
} catch (err) {
|
|
3072
|
-
console.debug("[LocalStorage] GET error: ", err);
|
|
3073
|
-
return void 0;
|
|
3074
|
-
}
|
|
3075
|
-
};
|
|
3076
|
-
var setLocalStorageItem = ({
|
|
3077
|
-
key,
|
|
2575
|
+
// src/components/content-variants/helpers.ts
|
|
2576
|
+
var getVariants = (content) => Object.values(content?.variations || {}).map((variant) => ({
|
|
2577
|
+
...variant,
|
|
2578
|
+
testVariationId: variant.id,
|
|
2579
|
+
id: content?.id
|
|
2580
|
+
}));
|
|
2581
|
+
var checkShouldRunVariants = ({
|
|
3078
2582
|
canTrack,
|
|
3079
|
-
|
|
3080
|
-
}) => {
|
|
3081
|
-
var _a;
|
|
3082
|
-
try {
|
|
3083
|
-
if (canTrack) {
|
|
3084
|
-
(_a = getLocalStorage()) == null ? void 0 : _a.setItem(key, value);
|
|
3085
|
-
}
|
|
3086
|
-
} catch (err) {
|
|
3087
|
-
console.debug("[LocalStorage] SET error: ", err);
|
|
3088
|
-
}
|
|
3089
|
-
};
|
|
3090
|
-
|
|
3091
|
-
// src/helpers/visitorId.js
|
|
3092
|
-
var VISITOR_LOCAL_STORAGE_KEY = "builderVisitorId";
|
|
3093
|
-
var getVisitorId = ({
|
|
3094
|
-
canTrack
|
|
2583
|
+
content
|
|
3095
2584
|
}) => {
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
if (
|
|
3104
|
-
return
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
id: newVisitorId,
|
|
3109
|
-
canTrack
|
|
3110
|
-
});
|
|
3111
|
-
return newVisitorId;
|
|
3112
|
-
}
|
|
3113
|
-
};
|
|
3114
|
-
var createVisitorId = () => uuid();
|
|
3115
|
-
var setVisitorId = ({
|
|
3116
|
-
id,
|
|
3117
|
-
canTrack
|
|
3118
|
-
}) => setLocalStorageItem({
|
|
3119
|
-
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
3120
|
-
value: id,
|
|
3121
|
-
canTrack
|
|
3122
|
-
});
|
|
3123
|
-
|
|
3124
|
-
// src/functions/track/index.js
|
|
3125
|
-
var __defProp13 = Object.defineProperty;
|
|
3126
|
-
var __defProps10 = Object.defineProperties;
|
|
3127
|
-
var __getOwnPropDescs10 = Object.getOwnPropertyDescriptors;
|
|
3128
|
-
var __getOwnPropSymbols13 = Object.getOwnPropertySymbols;
|
|
3129
|
-
var __hasOwnProp13 = Object.prototype.hasOwnProperty;
|
|
3130
|
-
var __propIsEnum13 = Object.prototype.propertyIsEnumerable;
|
|
3131
|
-
var __defNormalProp13 = (obj, key, value) => key in obj ? __defProp13(obj, key, {
|
|
3132
|
-
enumerable: true,
|
|
3133
|
-
configurable: true,
|
|
3134
|
-
writable: true,
|
|
3135
|
-
value
|
|
3136
|
-
}) : obj[key] = value;
|
|
3137
|
-
var __spreadValues13 = (a, b) => {
|
|
3138
|
-
for (var prop in b || (b = {}))
|
|
3139
|
-
if (__hasOwnProp13.call(b, prop))
|
|
3140
|
-
__defNormalProp13(a, prop, b[prop]);
|
|
3141
|
-
if (__getOwnPropSymbols13)
|
|
3142
|
-
for (var prop of __getOwnPropSymbols13(b)) {
|
|
3143
|
-
if (__propIsEnum13.call(b, prop))
|
|
3144
|
-
__defNormalProp13(a, prop, b[prop]);
|
|
3145
|
-
}
|
|
3146
|
-
return a;
|
|
3147
|
-
};
|
|
3148
|
-
var __spreadProps10 = (a, b) => __defProps10(a, __getOwnPropDescs10(b));
|
|
3149
|
-
var __objRest3 = (source, exclude) => {
|
|
3150
|
-
var target = {};
|
|
3151
|
-
for (var prop in source)
|
|
3152
|
-
if (__hasOwnProp13.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
3153
|
-
target[prop] = source[prop];
|
|
3154
|
-
if (source != null && __getOwnPropSymbols13)
|
|
3155
|
-
for (var prop of __getOwnPropSymbols13(source)) {
|
|
3156
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum13.call(source, prop))
|
|
3157
|
-
target[prop] = source[prop];
|
|
3158
|
-
}
|
|
3159
|
-
return target;
|
|
2585
|
+
const hasVariants = getVariants(content).length > 0;
|
|
2586
|
+
if (TARGET === "reactNative")
|
|
2587
|
+
return false;
|
|
2588
|
+
if (!hasVariants)
|
|
2589
|
+
return false;
|
|
2590
|
+
if (!canTrack)
|
|
2591
|
+
return false;
|
|
2592
|
+
if (TARGET === "vue2" || TARGET === "vue3")
|
|
2593
|
+
return true;
|
|
2594
|
+
if (isBrowser())
|
|
2595
|
+
return false;
|
|
2596
|
+
return true;
|
|
3160
2597
|
};
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
};
|
|
3170
|
-
var rejected = (value) => {
|
|
3171
|
-
try {
|
|
3172
|
-
step(generator.throw(value));
|
|
3173
|
-
} catch (e) {
|
|
3174
|
-
reject(e);
|
|
2598
|
+
function bldrAbTest(contentId, variants, isHydrationTarget2) {
|
|
2599
|
+
function getAndSetVariantId2() {
|
|
2600
|
+
function setCookie2(name, value, days) {
|
|
2601
|
+
let expires = "";
|
|
2602
|
+
if (days) {
|
|
2603
|
+
const date = /* @__PURE__ */ new Date();
|
|
2604
|
+
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1e3);
|
|
2605
|
+
expires = "; expires=" + date.toUTCString();
|
|
3175
2606
|
}
|
|
3176
|
-
|
|
3177
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
3178
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
3179
|
-
});
|
|
3180
|
-
};
|
|
3181
|
-
var getTrackingEventData = (_0) => __async3(void 0, [_0], function* ({
|
|
3182
|
-
canTrack
|
|
3183
|
-
}) {
|
|
3184
|
-
if (!canTrack) {
|
|
3185
|
-
return {
|
|
3186
|
-
visitorId: void 0,
|
|
3187
|
-
sessionId: void 0
|
|
3188
|
-
};
|
|
3189
|
-
}
|
|
3190
|
-
const sessionId = yield getSessionId({
|
|
3191
|
-
canTrack
|
|
3192
|
-
});
|
|
3193
|
-
const visitorId = getVisitorId({
|
|
3194
|
-
canTrack
|
|
3195
|
-
});
|
|
3196
|
-
return {
|
|
3197
|
-
sessionId,
|
|
3198
|
-
visitorId
|
|
3199
|
-
};
|
|
3200
|
-
});
|
|
3201
|
-
var createEvent = (_a) => __async3(void 0, null, function* () {
|
|
3202
|
-
var _b = _a, {
|
|
3203
|
-
type: eventType,
|
|
3204
|
-
canTrack,
|
|
3205
|
-
apiKey,
|
|
3206
|
-
metadata
|
|
3207
|
-
} = _b, properties = __objRest3(_b, ["type", "canTrack", "apiKey", "metadata"]);
|
|
3208
|
-
return {
|
|
3209
|
-
type: eventType,
|
|
3210
|
-
data: __spreadProps10(__spreadValues13(__spreadProps10(__spreadValues13({}, properties), {
|
|
3211
|
-
metadata: __spreadValues13({
|
|
3212
|
-
url: location.href
|
|
3213
|
-
}, metadata)
|
|
3214
|
-
}), yield getTrackingEventData({
|
|
3215
|
-
canTrack
|
|
3216
|
-
})), {
|
|
3217
|
-
userAttributes: getUserAttributes(),
|
|
3218
|
-
ownerId: apiKey
|
|
3219
|
-
})
|
|
3220
|
-
};
|
|
3221
|
-
});
|
|
3222
|
-
function _track(eventProps) {
|
|
3223
|
-
return __async3(this, null, function* () {
|
|
3224
|
-
if (!eventProps.apiKey) {
|
|
3225
|
-
logger.error("Missing API key for track call. Please provide your API key.");
|
|
3226
|
-
return;
|
|
3227
|
-
}
|
|
3228
|
-
if (!eventProps.canTrack) {
|
|
3229
|
-
return;
|
|
3230
|
-
}
|
|
3231
|
-
if (isEditing()) {
|
|
3232
|
-
return;
|
|
3233
|
-
}
|
|
3234
|
-
if (!(isBrowser() || TARGET === "reactNative")) {
|
|
3235
|
-
return;
|
|
2607
|
+
document.cookie = name + "=" + (value || "") + expires + "; path=/; Secure; SameSite=None";
|
|
3236
2608
|
}
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
}).catch((err) => {
|
|
3247
|
-
console.error("Failed to track: ", err);
|
|
3248
|
-
});
|
|
3249
|
-
});
|
|
3250
|
-
}
|
|
3251
|
-
var track = (args) => _track(__spreadProps10(__spreadValues13({}, args), {
|
|
3252
|
-
canTrack: true
|
|
3253
|
-
}));
|
|
3254
|
-
|
|
3255
|
-
// src/constants/sdk-version.js
|
|
3256
|
-
var SDK_VERSION = "0.7.1-1";
|
|
3257
|
-
|
|
3258
|
-
// src/functions/register.js
|
|
3259
|
-
var registry = {};
|
|
3260
|
-
function register(type, info) {
|
|
3261
|
-
let typeList = registry[type];
|
|
3262
|
-
if (!typeList) {
|
|
3263
|
-
typeList = registry[type] = [];
|
|
3264
|
-
}
|
|
3265
|
-
typeList.push(info);
|
|
3266
|
-
if (isBrowser()) {
|
|
3267
|
-
const message = {
|
|
3268
|
-
type: "builder.register",
|
|
3269
|
-
data: {
|
|
3270
|
-
type,
|
|
3271
|
-
info
|
|
3272
|
-
}
|
|
3273
|
-
};
|
|
3274
|
-
try {
|
|
3275
|
-
parent.postMessage(message, "*");
|
|
3276
|
-
if (parent !== window) {
|
|
3277
|
-
window.postMessage(message, "*");
|
|
2609
|
+
function getCookie2(name) {
|
|
2610
|
+
const nameEQ = name + "=";
|
|
2611
|
+
const ca = document.cookie.split(";");
|
|
2612
|
+
for (let i = 0; i < ca.length; i++) {
|
|
2613
|
+
let c = ca[i];
|
|
2614
|
+
while (c.charAt(0) === " ")
|
|
2615
|
+
c = c.substring(1, c.length);
|
|
2616
|
+
if (c.indexOf(nameEQ) === 0)
|
|
2617
|
+
return c.substring(nameEQ.length, c.length);
|
|
3278
2618
|
}
|
|
3279
|
-
|
|
3280
|
-
console.debug("Could not postmessage", err);
|
|
2619
|
+
return null;
|
|
3281
2620
|
}
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
name: "Columns"
|
|
3298
|
-
}, ...TARGET === "reactNative" ? [] : [{
|
|
3299
|
-
name: "Core:Section"
|
|
3300
|
-
}, {
|
|
3301
|
-
name: "Core:Button"
|
|
3302
|
-
}, {
|
|
3303
|
-
name: "Embed"
|
|
3304
|
-
}, {
|
|
3305
|
-
name: "Custom Code"
|
|
3306
|
-
}]]
|
|
3307
|
-
});
|
|
3308
|
-
};
|
|
3309
|
-
var isSetupForEditing = false;
|
|
3310
|
-
var setupBrowserForEditing = (options = {}) => {
|
|
3311
|
-
var _a, _b;
|
|
3312
|
-
if (isSetupForEditing) {
|
|
3313
|
-
return;
|
|
3314
|
-
}
|
|
3315
|
-
isSetupForEditing = true;
|
|
3316
|
-
if (isBrowser()) {
|
|
3317
|
-
(_a = window.parent) == null ? void 0 : _a.postMessage({
|
|
3318
|
-
type: "builder.sdkInfo",
|
|
3319
|
-
data: {
|
|
3320
|
-
target: TARGET,
|
|
3321
|
-
version: SDK_VERSION,
|
|
3322
|
-
supportsPatchUpdates: false,
|
|
3323
|
-
supportsAddBlockScoping: true,
|
|
3324
|
-
supportsCustomBreakpoints: true
|
|
3325
|
-
}
|
|
3326
|
-
}, "*");
|
|
3327
|
-
(_b = window.parent) == null ? void 0 : _b.postMessage({
|
|
3328
|
-
type: "builder.updateContent",
|
|
3329
|
-
data: {
|
|
3330
|
-
options
|
|
3331
|
-
}
|
|
3332
|
-
}, "*");
|
|
3333
|
-
window.addEventListener("message", ({
|
|
3334
|
-
data
|
|
3335
|
-
}) => {
|
|
3336
|
-
var _a2, _b2;
|
|
3337
|
-
if (!(data == null ? void 0 : data.type)) {
|
|
3338
|
-
return;
|
|
3339
|
-
}
|
|
3340
|
-
switch (data.type) {
|
|
3341
|
-
case "builder.evaluate": {
|
|
3342
|
-
const text = data.data.text;
|
|
3343
|
-
const args = data.data.arguments || [];
|
|
3344
|
-
const id = data.data.id;
|
|
3345
|
-
const fn = new Function(text);
|
|
3346
|
-
let result;
|
|
3347
|
-
let error = null;
|
|
3348
|
-
try {
|
|
3349
|
-
result = fn.apply(null, args);
|
|
3350
|
-
} catch (err) {
|
|
3351
|
-
error = err;
|
|
3352
|
-
}
|
|
3353
|
-
if (error) {
|
|
3354
|
-
(_a2 = window.parent) == null ? void 0 : _a2.postMessage({
|
|
3355
|
-
type: "builder.evaluateError",
|
|
3356
|
-
data: {
|
|
3357
|
-
id,
|
|
3358
|
-
error: error.message
|
|
3359
|
-
}
|
|
3360
|
-
}, "*");
|
|
3361
|
-
} else {
|
|
3362
|
-
if (result && typeof result.then === "function") {
|
|
3363
|
-
result.then((finalResult) => {
|
|
3364
|
-
var _a3;
|
|
3365
|
-
(_a3 = window.parent) == null ? void 0 : _a3.postMessage({
|
|
3366
|
-
type: "builder.evaluateResult",
|
|
3367
|
-
data: {
|
|
3368
|
-
id,
|
|
3369
|
-
result: finalResult
|
|
3370
|
-
}
|
|
3371
|
-
}, "*");
|
|
3372
|
-
}).catch(console.error);
|
|
3373
|
-
} else {
|
|
3374
|
-
(_b2 = window.parent) == null ? void 0 : _b2.postMessage({
|
|
3375
|
-
type: "builder.evaluateResult",
|
|
3376
|
-
data: {
|
|
3377
|
-
result,
|
|
3378
|
-
id
|
|
3379
|
-
}
|
|
3380
|
-
}, "*");
|
|
3381
|
-
}
|
|
3382
|
-
}
|
|
3383
|
-
break;
|
|
3384
|
-
}
|
|
2621
|
+
const cookieName = `builder.tests.${contentId}`;
|
|
2622
|
+
const variantInCookie = getCookie2(cookieName);
|
|
2623
|
+
const availableIDs = variants.map((vr) => vr.id).concat(contentId);
|
|
2624
|
+
if (variantInCookie && availableIDs.includes(variantInCookie)) {
|
|
2625
|
+
return variantInCookie;
|
|
2626
|
+
}
|
|
2627
|
+
let n = 0;
|
|
2628
|
+
const random = Math.random();
|
|
2629
|
+
for (let i = 0; i < variants.length; i++) {
|
|
2630
|
+
const variant = variants[i];
|
|
2631
|
+
const testRatio = variant.testRatio;
|
|
2632
|
+
n += testRatio;
|
|
2633
|
+
if (random < n) {
|
|
2634
|
+
setCookie2(cookieName, variant.id);
|
|
2635
|
+
return variant.id;
|
|
3385
2636
|
}
|
|
3386
|
-
}
|
|
2637
|
+
}
|
|
2638
|
+
setCookie2(cookieName, contentId);
|
|
2639
|
+
return contentId;
|
|
2640
|
+
}
|
|
2641
|
+
const winningVariantId = getAndSetVariantId2();
|
|
2642
|
+
const styleEl = document.currentScript?.previousElementSibling;
|
|
2643
|
+
if (isHydrationTarget2) {
|
|
2644
|
+
styleEl.remove();
|
|
2645
|
+
const thisScriptEl = document.currentScript;
|
|
2646
|
+
thisScriptEl?.remove();
|
|
2647
|
+
} else {
|
|
2648
|
+
const newStyleStr = variants.concat({
|
|
2649
|
+
id: contentId
|
|
2650
|
+
}).filter((variant) => variant.id !== winningVariantId).map((value) => {
|
|
2651
|
+
return `.variant-${value.id} { display: none; }
|
|
2652
|
+
`;
|
|
2653
|
+
}).join("");
|
|
2654
|
+
styleEl.innerHTML = newStyleStr;
|
|
3387
2655
|
}
|
|
3388
|
-
};
|
|
3389
|
-
|
|
3390
|
-
// src/functions/track/interaction.js
|
|
3391
|
-
function round(num) {
|
|
3392
|
-
return Math.round(num * 1e3) / 1e3;
|
|
3393
2656
|
}
|
|
3394
|
-
|
|
3395
|
-
if (!
|
|
3396
|
-
return
|
|
2657
|
+
function bldrCntntScrpt(variantContentId, defaultContentId, isHydrationTarget2) {
|
|
2658
|
+
if (!navigator.cookieEnabled) {
|
|
2659
|
+
return;
|
|
3397
2660
|
}
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
} while (parent2 = parent2.parentElement);
|
|
3408
|
-
return null;
|
|
3409
|
-
};
|
|
3410
|
-
var findBuilderParent = (target) => findParentElement(target, (el) => {
|
|
3411
|
-
const id = el.getAttribute("builder-id") || el.id;
|
|
3412
|
-
return Boolean((id == null ? void 0 : id.indexOf("builder-")) === 0);
|
|
3413
|
-
});
|
|
3414
|
-
var computeOffset = ({
|
|
3415
|
-
event,
|
|
3416
|
-
target
|
|
3417
|
-
}) => {
|
|
3418
|
-
const targetRect = target.getBoundingClientRect();
|
|
3419
|
-
const xOffset = event.clientX - targetRect.left;
|
|
3420
|
-
const yOffset = event.clientY - targetRect.top;
|
|
3421
|
-
const xRatio = round(xOffset / targetRect.width);
|
|
3422
|
-
const yRatio = round(yOffset / targetRect.height);
|
|
3423
|
-
return {
|
|
3424
|
-
x: xRatio,
|
|
3425
|
-
y: yRatio
|
|
3426
|
-
};
|
|
3427
|
-
};
|
|
3428
|
-
var getInteractionPropertiesForEvent = (event) => {
|
|
3429
|
-
const target = event.target;
|
|
3430
|
-
const targetBuilderElement = target && findBuilderParent(target);
|
|
3431
|
-
const builderId = (targetBuilderElement == null ? void 0 : targetBuilderElement.getAttribute("builder-id")) || (targetBuilderElement == null ? void 0 : targetBuilderElement.id);
|
|
3432
|
-
return {
|
|
3433
|
-
targetBuilderElement: builderId || void 0,
|
|
3434
|
-
metadata: {
|
|
3435
|
-
targetOffset: target ? computeOffset({
|
|
3436
|
-
event,
|
|
3437
|
-
target
|
|
3438
|
-
}) : void 0,
|
|
3439
|
-
builderTargetOffset: targetBuilderElement ? computeOffset({
|
|
3440
|
-
event,
|
|
3441
|
-
target: targetBuilderElement
|
|
3442
|
-
}) : void 0,
|
|
3443
|
-
builderElementIndex: targetBuilderElement && builderId ? [].slice.call(document.getElementsByClassName(builderId)).indexOf(targetBuilderElement) : void 0
|
|
2661
|
+
function getCookie2(name) {
|
|
2662
|
+
const nameEQ = name + "=";
|
|
2663
|
+
const ca = document.cookie.split(";");
|
|
2664
|
+
for (let i = 0; i < ca.length; i++) {
|
|
2665
|
+
let c = ca[i];
|
|
2666
|
+
while (c.charAt(0) === " ")
|
|
2667
|
+
c = c.substring(1, c.length);
|
|
2668
|
+
if (c.indexOf(nameEQ) === 0)
|
|
2669
|
+
return c.substring(nameEQ.length, c.length);
|
|
3444
2670
|
}
|
|
3445
|
-
|
|
3446
|
-
}
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
enumerable: true,
|
|
3455
|
-
configurable: true,
|
|
3456
|
-
writable: true,
|
|
3457
|
-
value
|
|
3458
|
-
}) : obj[key] = value;
|
|
3459
|
-
var __spreadValues14 = (a, b) => {
|
|
3460
|
-
for (var prop in b || (b = {}))
|
|
3461
|
-
if (__hasOwnProp14.call(b, prop))
|
|
3462
|
-
__defNormalProp14(a, prop, b[prop]);
|
|
3463
|
-
if (__getOwnPropSymbols14)
|
|
3464
|
-
for (var prop of __getOwnPropSymbols14(b)) {
|
|
3465
|
-
if (__propIsEnum14.call(b, prop))
|
|
3466
|
-
__defNormalProp14(a, prop, b[prop]);
|
|
2671
|
+
return null;
|
|
2672
|
+
}
|
|
2673
|
+
const cookieName = `builder.tests.${defaultContentId}`;
|
|
2674
|
+
const variantId = getCookie2(cookieName);
|
|
2675
|
+
const parentDiv = document.currentScript?.parentElement;
|
|
2676
|
+
const variantIsDefaultContent = variantContentId === defaultContentId;
|
|
2677
|
+
if (variantId === variantContentId) {
|
|
2678
|
+
if (variantIsDefaultContent) {
|
|
2679
|
+
return;
|
|
3467
2680
|
}
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
}
|
|
3478
|
-
};
|
|
3479
|
-
var rejected = (value) => {
|
|
3480
|
-
try {
|
|
3481
|
-
step(generator.throw(value));
|
|
3482
|
-
} catch (e) {
|
|
3483
|
-
reject(e);
|
|
2681
|
+
parentDiv?.removeAttribute("hidden");
|
|
2682
|
+
parentDiv?.removeAttribute("aria-hidden");
|
|
2683
|
+
} else {
|
|
2684
|
+
if (variantIsDefaultContent) {
|
|
2685
|
+
if (isHydrationTarget2) {
|
|
2686
|
+
parentDiv?.remove();
|
|
2687
|
+
} else {
|
|
2688
|
+
parentDiv?.setAttribute("hidden", "true");
|
|
2689
|
+
parentDiv?.setAttribute("aria-hidden", "true");
|
|
3484
2690
|
}
|
|
3485
|
-
};
|
|
3486
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
3487
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
3488
|
-
});
|
|
3489
|
-
};
|
|
3490
|
-
var BUILDER_STORE_PREFIX = "builder.tests";
|
|
3491
|
-
var getContentTestKey = (id) => `${BUILDER_STORE_PREFIX}.${id}`;
|
|
3492
|
-
var getContentVariationCookie = ({
|
|
3493
|
-
contentId
|
|
3494
|
-
}) => getCookie({
|
|
3495
|
-
name: getContentTestKey(contentId),
|
|
3496
|
-
canTrack: true
|
|
3497
|
-
});
|
|
3498
|
-
var getContentVariationCookieSync = ({
|
|
3499
|
-
contentId
|
|
3500
|
-
}) => getCookieSync({
|
|
3501
|
-
name: getContentTestKey(contentId),
|
|
3502
|
-
canTrack: true
|
|
3503
|
-
});
|
|
3504
|
-
var setContentVariationCookie = ({
|
|
3505
|
-
contentId,
|
|
3506
|
-
value
|
|
3507
|
-
}) => setCookie({
|
|
3508
|
-
name: getContentTestKey(contentId),
|
|
3509
|
-
value,
|
|
3510
|
-
canTrack: true
|
|
3511
|
-
});
|
|
3512
|
-
var checkIsBuilderContentWithVariations = (item) => checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
|
|
3513
|
-
var getRandomVariationId = ({
|
|
3514
|
-
id,
|
|
3515
|
-
variations
|
|
3516
|
-
}) => {
|
|
3517
|
-
var _a;
|
|
3518
|
-
let n = 0;
|
|
3519
|
-
const random = Math.random();
|
|
3520
|
-
for (const id2 in variations) {
|
|
3521
|
-
const testRatio = (_a = variations[id2]) == null ? void 0 : _a.testRatio;
|
|
3522
|
-
n += testRatio;
|
|
3523
|
-
if (random < n) {
|
|
3524
|
-
return id2;
|
|
3525
2691
|
}
|
|
2692
|
+
return;
|
|
3526
2693
|
}
|
|
3527
|
-
return
|
|
2694
|
+
return;
|
|
2695
|
+
}
|
|
2696
|
+
var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
|
|
2697
|
+
var isHydrationTarget = getIsHydrationTarget(TARGET);
|
|
2698
|
+
var AB_TEST_FN_NAME = "builderIoAbTest";
|
|
2699
|
+
var CONTENT_FN_NAME = "builderIoRenderContent";
|
|
2700
|
+
var getScriptString = () => {
|
|
2701
|
+
const fnStr = bldrAbTest.toString().replace(/\s+/g, " ");
|
|
2702
|
+
const fnStr2 = bldrCntntScrpt.toString().replace(/\s+/g, " ");
|
|
2703
|
+
return `
|
|
2704
|
+
window.${AB_TEST_FN_NAME} = ${fnStr}
|
|
2705
|
+
window.${CONTENT_FN_NAME} = ${fnStr2}
|
|
2706
|
+
`;
|
|
3528
2707
|
};
|
|
3529
|
-
var
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
contentId: args.id,
|
|
3533
|
-
value: randomVariationId
|
|
3534
|
-
}).catch((err) => {
|
|
3535
|
-
logger.error("could not store A/B test variation: ", err);
|
|
3536
|
-
});
|
|
3537
|
-
return randomVariationId;
|
|
2708
|
+
var getVariantsScriptString = (variants, contentId) => {
|
|
2709
|
+
return `
|
|
2710
|
+
window.${AB_TEST_FN_NAME}("${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget})`;
|
|
3538
2711
|
};
|
|
3539
|
-
var
|
|
3540
|
-
|
|
3541
|
-
|
|
2712
|
+
var getRenderContentScriptString = ({
|
|
2713
|
+
contentId,
|
|
2714
|
+
variationId
|
|
3542
2715
|
}) => {
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
return {
|
|
3546
|
-
testVariationId: item.id,
|
|
3547
|
-
testVariationName: "Default"
|
|
3548
|
-
};
|
|
3549
|
-
} else {
|
|
3550
|
-
return {
|
|
3551
|
-
data: variationValue.data,
|
|
3552
|
-
testVariationId: variationValue.id,
|
|
3553
|
-
testVariationName: variationValue.name || (variationValue.id === item.id ? "Default" : "")
|
|
3554
|
-
};
|
|
3555
|
-
}
|
|
2716
|
+
return `
|
|
2717
|
+
window.${CONTENT_FN_NAME}("${variationId}", "${contentId}", ${isHydrationTarget})`;
|
|
3556
2718
|
};
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
}
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
2719
|
+
|
|
2720
|
+
// src/components/inlined-script.tsx
|
|
2721
|
+
function InlinedScript(props) {
|
|
2722
|
+
return <script innerHTML={props.scriptStr} id={props.id} />;
|
|
2723
|
+
}
|
|
2724
|
+
var Inlined_script_default = InlinedScript;
|
|
2725
|
+
|
|
2726
|
+
// src/components/content/components/enable-editor.tsx
|
|
2727
|
+
import { Show as Show9, onMount as onMount2, on as on2, createEffect as createEffect2, createSignal as createSignal9 } from "solid-js";
|
|
2728
|
+
|
|
2729
|
+
// src/helpers/preview-lru-cache/get.ts
|
|
2730
|
+
function getPreviewContent(_searchParams) {
|
|
2731
|
+
return void 0;
|
|
2732
|
+
}
|
|
2733
|
+
|
|
2734
|
+
// src/functions/get-global-this.ts
|
|
2735
|
+
function getGlobalThis() {
|
|
2736
|
+
if (typeof globalThis !== "undefined") {
|
|
2737
|
+
return globalThis;
|
|
3568
2738
|
}
|
|
3569
|
-
if (
|
|
3570
|
-
return
|
|
2739
|
+
if (typeof window !== "undefined") {
|
|
2740
|
+
return window;
|
|
3571
2741
|
}
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
}) || getAndSetVariantId({
|
|
3575
|
-
variations: item.variations,
|
|
3576
|
-
id: item.id
|
|
3577
|
-
});
|
|
3578
|
-
const variationValue = getTestFields({
|
|
3579
|
-
item,
|
|
3580
|
-
testGroupId
|
|
3581
|
-
});
|
|
3582
|
-
return __spreadValues14(__spreadValues14({}, item), variationValue);
|
|
3583
|
-
};
|
|
3584
|
-
var handleABTesting = (_0) => __async4(void 0, [_0], function* ({
|
|
3585
|
-
item,
|
|
3586
|
-
canTrack
|
|
3587
|
-
}) {
|
|
3588
|
-
if (!canTrack) {
|
|
3589
|
-
return item;
|
|
2742
|
+
if (typeof global !== "undefined") {
|
|
2743
|
+
return global;
|
|
3590
2744
|
}
|
|
3591
|
-
if (
|
|
3592
|
-
return
|
|
2745
|
+
if (typeof self !== "undefined") {
|
|
2746
|
+
return self;
|
|
3593
2747
|
}
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
});
|
|
3597
|
-
const testGroupId = cookieValue || getAndSetVariantId({
|
|
3598
|
-
variations: item.variations,
|
|
3599
|
-
id: item.id
|
|
3600
|
-
});
|
|
3601
|
-
const variationValue = getTestFields({
|
|
3602
|
-
item,
|
|
3603
|
-
testGroupId
|
|
3604
|
-
});
|
|
3605
|
-
return __spreadValues14(__spreadValues14({}, item), variationValue);
|
|
3606
|
-
});
|
|
3607
|
-
|
|
3608
|
-
// src/helpers/canTrack.js
|
|
3609
|
-
var getDefaultCanTrack = (canTrack) => checkIsDefined(canTrack) ? canTrack : true;
|
|
2748
|
+
return globalThis;
|
|
2749
|
+
}
|
|
3610
2750
|
|
|
3611
|
-
// src/
|
|
3612
|
-
function
|
|
3613
|
-
|
|
2751
|
+
// src/functions/get-fetch.ts
|
|
2752
|
+
function getFetch() {
|
|
2753
|
+
const globalFetch = getGlobalThis().fetch;
|
|
2754
|
+
if (typeof globalFetch === "undefined") {
|
|
2755
|
+
console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
|
|
2756
|
+
For more information, read https://github.com/BuilderIO/this-package-uses-fetch`);
|
|
2757
|
+
throw new Error("Builder SDK could not find a global `fetch` function");
|
|
2758
|
+
}
|
|
2759
|
+
return globalFetch;
|
|
3614
2760
|
}
|
|
2761
|
+
var fetch2 = getFetch();
|
|
3615
2762
|
|
|
3616
|
-
// src/helpers/flatten.
|
|
3617
|
-
var __defProp15 = Object.defineProperty;
|
|
3618
|
-
var __defProps11 = Object.defineProperties;
|
|
3619
|
-
var __getOwnPropDescs11 = Object.getOwnPropertyDescriptors;
|
|
3620
|
-
var __getOwnPropSymbols15 = Object.getOwnPropertySymbols;
|
|
3621
|
-
var __hasOwnProp15 = Object.prototype.hasOwnProperty;
|
|
3622
|
-
var __propIsEnum15 = Object.prototype.propertyIsEnumerable;
|
|
3623
|
-
var __defNormalProp15 = (obj, key, value) => key in obj ? __defProp15(obj, key, {
|
|
3624
|
-
enumerable: true,
|
|
3625
|
-
configurable: true,
|
|
3626
|
-
writable: true,
|
|
3627
|
-
value
|
|
3628
|
-
}) : obj[key] = value;
|
|
3629
|
-
var __spreadValues15 = (a, b) => {
|
|
3630
|
-
for (var prop in b || (b = {}))
|
|
3631
|
-
if (__hasOwnProp15.call(b, prop))
|
|
3632
|
-
__defNormalProp15(a, prop, b[prop]);
|
|
3633
|
-
if (__getOwnPropSymbols15)
|
|
3634
|
-
for (var prop of __getOwnPropSymbols15(b)) {
|
|
3635
|
-
if (__propIsEnum15.call(b, prop))
|
|
3636
|
-
__defNormalProp15(a, prop, b[prop]);
|
|
3637
|
-
}
|
|
3638
|
-
return a;
|
|
3639
|
-
};
|
|
3640
|
-
var __spreadProps11 = (a, b) => __defProps11(a, __getOwnPropDescs11(b));
|
|
2763
|
+
// src/helpers/flatten.ts
|
|
3641
2764
|
function flatten(object, path = null, separator = ".") {
|
|
3642
2765
|
return Object.keys(object).reduce((acc, key) => {
|
|
3643
2766
|
const value = object[key];
|
|
3644
2767
|
const newPath = [path, key].filter(Boolean).join(separator);
|
|
3645
2768
|
const isObject = [typeof value === "object", value !== null, !(Array.isArray(value) && value.length === 0)].every(Boolean);
|
|
3646
|
-
return isObject ?
|
|
2769
|
+
return isObject ? {
|
|
2770
|
+
...acc,
|
|
2771
|
+
...flatten(value, newPath, separator)
|
|
2772
|
+
} : {
|
|
2773
|
+
...acc,
|
|
3647
2774
|
[newPath]: value
|
|
3648
|
-
}
|
|
2775
|
+
};
|
|
3649
2776
|
}, {});
|
|
3650
2777
|
}
|
|
3651
2778
|
|
|
3652
|
-
// src/
|
|
2779
|
+
// src/types/api-version.ts
|
|
2780
|
+
var DEFAULT_API_VERSION = "v3";
|
|
2781
|
+
|
|
2782
|
+
// src/functions/get-builder-search-params/index.ts
|
|
3653
2783
|
var BUILDER_SEARCHPARAMS_PREFIX = "builder.";
|
|
3654
2784
|
var BUILDER_OPTIONS_PREFIX = "options.";
|
|
3655
2785
|
var convertSearchParamsToQueryObject = (searchParams) => {
|
|
@@ -3682,31 +2812,7 @@ var getBuilderSearchParamsFromWindow = () => {
|
|
|
3682
2812
|
};
|
|
3683
2813
|
var normalizeSearchParams = (searchParams) => searchParams instanceof URLSearchParams ? convertSearchParamsToQueryObject(searchParams) : searchParams;
|
|
3684
2814
|
|
|
3685
|
-
// src/
|
|
3686
|
-
var DEFAULT_API_VERSION = "v3";
|
|
3687
|
-
|
|
3688
|
-
// src/functions/get-content/generate-content-url.js
|
|
3689
|
-
var __defProp16 = Object.defineProperty;
|
|
3690
|
-
var __getOwnPropSymbols16 = Object.getOwnPropertySymbols;
|
|
3691
|
-
var __hasOwnProp16 = Object.prototype.hasOwnProperty;
|
|
3692
|
-
var __propIsEnum16 = Object.prototype.propertyIsEnumerable;
|
|
3693
|
-
var __defNormalProp16 = (obj, key, value) => key in obj ? __defProp16(obj, key, {
|
|
3694
|
-
enumerable: true,
|
|
3695
|
-
configurable: true,
|
|
3696
|
-
writable: true,
|
|
3697
|
-
value
|
|
3698
|
-
}) : obj[key] = value;
|
|
3699
|
-
var __spreadValues16 = (a, b) => {
|
|
3700
|
-
for (var prop in b || (b = {}))
|
|
3701
|
-
if (__hasOwnProp16.call(b, prop))
|
|
3702
|
-
__defNormalProp16(a, prop, b[prop]);
|
|
3703
|
-
if (__getOwnPropSymbols16)
|
|
3704
|
-
for (var prop of __getOwnPropSymbols16(b)) {
|
|
3705
|
-
if (__propIsEnum16.call(b, prop))
|
|
3706
|
-
__defNormalProp16(a, prop, b[prop]);
|
|
3707
|
-
}
|
|
3708
|
-
return a;
|
|
3709
|
-
};
|
|
2815
|
+
// src/functions/get-content/generate-content-url.ts
|
|
3710
2816
|
var isPositiveNumber = (thing) => typeof thing === "number" && !isNaN(thing) && thing >= 0;
|
|
3711
2817
|
var generateContentUrl = (options) => {
|
|
3712
2818
|
let {
|
|
@@ -3764,7 +2870,10 @@ var generateContentUrl = (options) => {
|
|
|
3764
2870
|
url.searchParams.set(key, JSON.stringify(flattened2[key]));
|
|
3765
2871
|
}
|
|
3766
2872
|
}
|
|
3767
|
-
const queryOptions =
|
|
2873
|
+
const queryOptions = {
|
|
2874
|
+
...getBuilderSearchParamsFromWindow(),
|
|
2875
|
+
...normalizeSearchParams(options.options || {})
|
|
2876
|
+
};
|
|
3768
2877
|
const flattened = flatten(queryOptions);
|
|
3769
2878
|
for (const key in flattened) {
|
|
3770
2879
|
url.searchParams.set(key, String(flattened[key]));
|
|
@@ -3783,71 +2892,26 @@ var generateContentUrl = (options) => {
|
|
|
3783
2892
|
return url;
|
|
3784
2893
|
};
|
|
3785
2894
|
|
|
3786
|
-
// src/functions/get-content/index.
|
|
3787
|
-
var __defProp17 = Object.defineProperty;
|
|
3788
|
-
var __defProps12 = Object.defineProperties;
|
|
3789
|
-
var __getOwnPropDescs12 = Object.getOwnPropertyDescriptors;
|
|
3790
|
-
var __getOwnPropSymbols17 = Object.getOwnPropertySymbols;
|
|
3791
|
-
var __hasOwnProp17 = Object.prototype.hasOwnProperty;
|
|
3792
|
-
var __propIsEnum17 = Object.prototype.propertyIsEnumerable;
|
|
3793
|
-
var __defNormalProp17 = (obj, key, value) => key in obj ? __defProp17(obj, key, {
|
|
3794
|
-
enumerable: true,
|
|
3795
|
-
configurable: true,
|
|
3796
|
-
writable: true,
|
|
3797
|
-
value
|
|
3798
|
-
}) : obj[key] = value;
|
|
3799
|
-
var __spreadValues17 = (a, b) => {
|
|
3800
|
-
for (var prop in b || (b = {}))
|
|
3801
|
-
if (__hasOwnProp17.call(b, prop))
|
|
3802
|
-
__defNormalProp17(a, prop, b[prop]);
|
|
3803
|
-
if (__getOwnPropSymbols17)
|
|
3804
|
-
for (var prop of __getOwnPropSymbols17(b)) {
|
|
3805
|
-
if (__propIsEnum17.call(b, prop))
|
|
3806
|
-
__defNormalProp17(a, prop, b[prop]);
|
|
3807
|
-
}
|
|
3808
|
-
return a;
|
|
3809
|
-
};
|
|
3810
|
-
var __spreadProps12 = (a, b) => __defProps12(a, __getOwnPropDescs12(b));
|
|
3811
|
-
var __async5 = (__this, __arguments, generator) => {
|
|
3812
|
-
return new Promise((resolve, reject) => {
|
|
3813
|
-
var fulfilled = (value) => {
|
|
3814
|
-
try {
|
|
3815
|
-
step(generator.next(value));
|
|
3816
|
-
} catch (e) {
|
|
3817
|
-
reject(e);
|
|
3818
|
-
}
|
|
3819
|
-
};
|
|
3820
|
-
var rejected = (value) => {
|
|
3821
|
-
try {
|
|
3822
|
-
step(generator.throw(value));
|
|
3823
|
-
} catch (e) {
|
|
3824
|
-
reject(e);
|
|
3825
|
-
}
|
|
3826
|
-
};
|
|
3827
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
3828
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
3829
|
-
});
|
|
3830
|
-
};
|
|
2895
|
+
// src/functions/get-content/index.ts
|
|
3831
2896
|
var checkContentHasResults = (content) => "results" in content;
|
|
3832
|
-
function fetchOneEntry(options) {
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
}));
|
|
3837
|
-
if (allContent) {
|
|
3838
|
-
return allContent.results[0] || null;
|
|
3839
|
-
}
|
|
3840
|
-
return null;
|
|
2897
|
+
async function fetchOneEntry(options) {
|
|
2898
|
+
const allContent = await fetchEntries({
|
|
2899
|
+
...options,
|
|
2900
|
+
limit: 1
|
|
3841
2901
|
});
|
|
2902
|
+
if (allContent) {
|
|
2903
|
+
return allContent.results[0] || null;
|
|
2904
|
+
}
|
|
2905
|
+
return null;
|
|
3842
2906
|
}
|
|
3843
2907
|
var getContent = fetchOneEntry;
|
|
3844
|
-
var _fetchContent = (options) =>
|
|
2908
|
+
var _fetchContent = async (options) => {
|
|
3845
2909
|
const url = generateContentUrl(options);
|
|
3846
|
-
const res =
|
|
3847
|
-
const content =
|
|
2910
|
+
const res = await fetch2(url.href);
|
|
2911
|
+
const content = await res.json();
|
|
3848
2912
|
return content;
|
|
3849
|
-
}
|
|
3850
|
-
var _processContentResult =
|
|
2913
|
+
};
|
|
2914
|
+
var _processContentResult = async (options, content, url = generateContentUrl(options)) => {
|
|
3851
2915
|
const canTrack = getDefaultCanTrack(options.canTrack);
|
|
3852
2916
|
const isPreviewing2 = url.search.includes(`preview=`);
|
|
3853
2917
|
if (TARGET === "rsc" && isPreviewing2) {
|
|
@@ -3865,7 +2929,7 @@ var _processContentResult = (_0, _1, ..._2) => __async5(void 0, [_0, _1, ..._2],
|
|
|
3865
2929
|
try {
|
|
3866
2930
|
const newResults = [];
|
|
3867
2931
|
for (const item of content.results) {
|
|
3868
|
-
newResults.push(
|
|
2932
|
+
newResults.push(await handleABTesting({
|
|
3869
2933
|
item,
|
|
3870
2934
|
canTrack
|
|
3871
2935
|
}));
|
|
@@ -3874,48 +2938,419 @@ var _processContentResult = (_0, _1, ..._2) => __async5(void 0, [_0, _1, ..._2],
|
|
|
3874
2938
|
} catch (e) {
|
|
3875
2939
|
logger.error("Could not process A/B tests. ", e);
|
|
3876
2940
|
}
|
|
3877
|
-
return content;
|
|
3878
|
-
}
|
|
3879
|
-
function fetchEntries(options) {
|
|
3880
|
-
|
|
2941
|
+
return content;
|
|
2942
|
+
};
|
|
2943
|
+
async function fetchEntries(options) {
|
|
2944
|
+
try {
|
|
2945
|
+
const url = generateContentUrl(options);
|
|
2946
|
+
const content = await _fetchContent(options);
|
|
2947
|
+
if (!checkContentHasResults(content)) {
|
|
2948
|
+
logger.error("Error fetching data. ", {
|
|
2949
|
+
url,
|
|
2950
|
+
content,
|
|
2951
|
+
options
|
|
2952
|
+
});
|
|
2953
|
+
return null;
|
|
2954
|
+
}
|
|
2955
|
+
return _processContentResult(options, content);
|
|
2956
|
+
} catch (error) {
|
|
2957
|
+
logger.error("Error fetching data. ", error);
|
|
2958
|
+
return null;
|
|
2959
|
+
}
|
|
2960
|
+
}
|
|
2961
|
+
var getAllContent = fetchEntries;
|
|
2962
|
+
|
|
2963
|
+
// src/functions/is-previewing.ts
|
|
2964
|
+
function isPreviewing() {
|
|
2965
|
+
if (!isBrowser()) {
|
|
2966
|
+
return false;
|
|
2967
|
+
}
|
|
2968
|
+
if (isEditing()) {
|
|
2969
|
+
return false;
|
|
2970
|
+
}
|
|
2971
|
+
return Boolean(location.search.indexOf("builder.preview=") !== -1);
|
|
2972
|
+
}
|
|
2973
|
+
|
|
2974
|
+
// src/helpers/uuid.ts
|
|
2975
|
+
function uuidv4() {
|
|
2976
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
2977
|
+
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
|
2978
|
+
return v.toString(16);
|
|
2979
|
+
});
|
|
2980
|
+
}
|
|
2981
|
+
function uuid() {
|
|
2982
|
+
return uuidv4().replace(/-/g, "");
|
|
2983
|
+
}
|
|
2984
|
+
|
|
2985
|
+
// src/helpers/sessionId.ts
|
|
2986
|
+
var SESSION_LOCAL_STORAGE_KEY = "builderSessionId";
|
|
2987
|
+
var getSessionId = async ({
|
|
2988
|
+
canTrack
|
|
2989
|
+
}) => {
|
|
2990
|
+
if (!canTrack) {
|
|
2991
|
+
return void 0;
|
|
2992
|
+
}
|
|
2993
|
+
const sessionId = await getCookie({
|
|
2994
|
+
name: SESSION_LOCAL_STORAGE_KEY,
|
|
2995
|
+
canTrack
|
|
2996
|
+
});
|
|
2997
|
+
if (checkIsDefined(sessionId)) {
|
|
2998
|
+
return sessionId;
|
|
2999
|
+
} else {
|
|
3000
|
+
const newSessionId = createSessionId();
|
|
3001
|
+
setSessionId({
|
|
3002
|
+
id: newSessionId,
|
|
3003
|
+
canTrack
|
|
3004
|
+
});
|
|
3005
|
+
return newSessionId;
|
|
3006
|
+
}
|
|
3007
|
+
};
|
|
3008
|
+
var createSessionId = () => uuid();
|
|
3009
|
+
var setSessionId = ({
|
|
3010
|
+
id,
|
|
3011
|
+
canTrack
|
|
3012
|
+
}) => setCookie({
|
|
3013
|
+
name: SESSION_LOCAL_STORAGE_KEY,
|
|
3014
|
+
value: id,
|
|
3015
|
+
canTrack
|
|
3016
|
+
});
|
|
3017
|
+
|
|
3018
|
+
// src/helpers/localStorage.ts
|
|
3019
|
+
var getLocalStorage = () => isBrowser() && typeof localStorage !== "undefined" ? localStorage : void 0;
|
|
3020
|
+
var getLocalStorageItem = ({
|
|
3021
|
+
key,
|
|
3022
|
+
canTrack
|
|
3023
|
+
}) => {
|
|
3024
|
+
try {
|
|
3025
|
+
if (canTrack) {
|
|
3026
|
+
return getLocalStorage()?.getItem(key);
|
|
3027
|
+
}
|
|
3028
|
+
return void 0;
|
|
3029
|
+
} catch (err) {
|
|
3030
|
+
console.debug("[LocalStorage] GET error: ", err);
|
|
3031
|
+
return void 0;
|
|
3032
|
+
}
|
|
3033
|
+
};
|
|
3034
|
+
var setLocalStorageItem = ({
|
|
3035
|
+
key,
|
|
3036
|
+
canTrack,
|
|
3037
|
+
value
|
|
3038
|
+
}) => {
|
|
3039
|
+
try {
|
|
3040
|
+
if (canTrack) {
|
|
3041
|
+
getLocalStorage()?.setItem(key, value);
|
|
3042
|
+
}
|
|
3043
|
+
} catch (err) {
|
|
3044
|
+
console.debug("[LocalStorage] SET error: ", err);
|
|
3045
|
+
}
|
|
3046
|
+
};
|
|
3047
|
+
|
|
3048
|
+
// src/helpers/visitorId.ts
|
|
3049
|
+
var VISITOR_LOCAL_STORAGE_KEY = "builderVisitorId";
|
|
3050
|
+
var getVisitorId = ({
|
|
3051
|
+
canTrack
|
|
3052
|
+
}) => {
|
|
3053
|
+
if (!canTrack) {
|
|
3054
|
+
return void 0;
|
|
3055
|
+
}
|
|
3056
|
+
const visitorId = getLocalStorageItem({
|
|
3057
|
+
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
3058
|
+
canTrack
|
|
3059
|
+
});
|
|
3060
|
+
if (checkIsDefined(visitorId)) {
|
|
3061
|
+
return visitorId;
|
|
3062
|
+
} else {
|
|
3063
|
+
const newVisitorId = createVisitorId();
|
|
3064
|
+
setVisitorId({
|
|
3065
|
+
id: newVisitorId,
|
|
3066
|
+
canTrack
|
|
3067
|
+
});
|
|
3068
|
+
return newVisitorId;
|
|
3069
|
+
}
|
|
3070
|
+
};
|
|
3071
|
+
var createVisitorId = () => uuid();
|
|
3072
|
+
var setVisitorId = ({
|
|
3073
|
+
id,
|
|
3074
|
+
canTrack
|
|
3075
|
+
}) => setLocalStorageItem({
|
|
3076
|
+
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
3077
|
+
value: id,
|
|
3078
|
+
canTrack
|
|
3079
|
+
});
|
|
3080
|
+
|
|
3081
|
+
// src/functions/track/index.ts
|
|
3082
|
+
var getTrackingEventData = async ({
|
|
3083
|
+
canTrack
|
|
3084
|
+
}) => {
|
|
3085
|
+
if (!canTrack) {
|
|
3086
|
+
return {
|
|
3087
|
+
visitorId: void 0,
|
|
3088
|
+
sessionId: void 0
|
|
3089
|
+
};
|
|
3090
|
+
}
|
|
3091
|
+
const sessionId = await getSessionId({
|
|
3092
|
+
canTrack
|
|
3093
|
+
});
|
|
3094
|
+
const visitorId = getVisitorId({
|
|
3095
|
+
canTrack
|
|
3096
|
+
});
|
|
3097
|
+
return {
|
|
3098
|
+
sessionId,
|
|
3099
|
+
visitorId
|
|
3100
|
+
};
|
|
3101
|
+
};
|
|
3102
|
+
var createEvent = async ({
|
|
3103
|
+
type: eventType,
|
|
3104
|
+
canTrack,
|
|
3105
|
+
apiKey,
|
|
3106
|
+
metadata,
|
|
3107
|
+
...properties
|
|
3108
|
+
}) => ({
|
|
3109
|
+
type: eventType,
|
|
3110
|
+
data: {
|
|
3111
|
+
...properties,
|
|
3112
|
+
metadata: {
|
|
3113
|
+
url: location.href,
|
|
3114
|
+
...metadata
|
|
3115
|
+
},
|
|
3116
|
+
...await getTrackingEventData({
|
|
3117
|
+
canTrack
|
|
3118
|
+
}),
|
|
3119
|
+
userAttributes: getUserAttributes(),
|
|
3120
|
+
ownerId: apiKey
|
|
3121
|
+
}
|
|
3122
|
+
});
|
|
3123
|
+
async function _track(eventProps) {
|
|
3124
|
+
if (!eventProps.apiKey) {
|
|
3125
|
+
logger.error("Missing API key for track call. Please provide your API key.");
|
|
3126
|
+
return;
|
|
3127
|
+
}
|
|
3128
|
+
if (!eventProps.canTrack) {
|
|
3129
|
+
return;
|
|
3130
|
+
}
|
|
3131
|
+
if (isEditing()) {
|
|
3132
|
+
return;
|
|
3133
|
+
}
|
|
3134
|
+
if (!(isBrowser() || TARGET === "reactNative")) {
|
|
3135
|
+
return;
|
|
3136
|
+
}
|
|
3137
|
+
return fetch(`https://cdn.builder.io/api/v1/track`, {
|
|
3138
|
+
method: "POST",
|
|
3139
|
+
body: JSON.stringify({
|
|
3140
|
+
events: [await createEvent(eventProps)]
|
|
3141
|
+
}),
|
|
3142
|
+
headers: {
|
|
3143
|
+
"content-type": "application/json"
|
|
3144
|
+
},
|
|
3145
|
+
mode: "cors"
|
|
3146
|
+
}).catch((err) => {
|
|
3147
|
+
console.error("Failed to track: ", err);
|
|
3148
|
+
});
|
|
3149
|
+
}
|
|
3150
|
+
var track = (args) => _track({
|
|
3151
|
+
...args,
|
|
3152
|
+
canTrack: true
|
|
3153
|
+
});
|
|
3154
|
+
|
|
3155
|
+
// src/functions/track/interaction.ts
|
|
3156
|
+
function round(num) {
|
|
3157
|
+
return Math.round(num * 1e3) / 1e3;
|
|
3158
|
+
}
|
|
3159
|
+
var findParentElement = (target, callback, checkElement = true) => {
|
|
3160
|
+
if (!(target instanceof HTMLElement)) {
|
|
3161
|
+
return null;
|
|
3162
|
+
}
|
|
3163
|
+
let parent2 = checkElement ? target : target.parentElement;
|
|
3164
|
+
do {
|
|
3165
|
+
if (!parent2) {
|
|
3166
|
+
return null;
|
|
3167
|
+
}
|
|
3168
|
+
const matches = callback(parent2);
|
|
3169
|
+
if (matches) {
|
|
3170
|
+
return parent2;
|
|
3171
|
+
}
|
|
3172
|
+
} while (parent2 = parent2.parentElement);
|
|
3173
|
+
return null;
|
|
3174
|
+
};
|
|
3175
|
+
var findBuilderParent = (target) => findParentElement(target, (el) => {
|
|
3176
|
+
const id = el.getAttribute("builder-id") || el.id;
|
|
3177
|
+
return Boolean(id?.indexOf("builder-") === 0);
|
|
3178
|
+
});
|
|
3179
|
+
var computeOffset = ({
|
|
3180
|
+
event,
|
|
3181
|
+
target
|
|
3182
|
+
}) => {
|
|
3183
|
+
const targetRect = target.getBoundingClientRect();
|
|
3184
|
+
const xOffset = event.clientX - targetRect.left;
|
|
3185
|
+
const yOffset = event.clientY - targetRect.top;
|
|
3186
|
+
const xRatio = round(xOffset / targetRect.width);
|
|
3187
|
+
const yRatio = round(yOffset / targetRect.height);
|
|
3188
|
+
return {
|
|
3189
|
+
x: xRatio,
|
|
3190
|
+
y: yRatio
|
|
3191
|
+
};
|
|
3192
|
+
};
|
|
3193
|
+
var getInteractionPropertiesForEvent = (event) => {
|
|
3194
|
+
const target = event.target;
|
|
3195
|
+
const targetBuilderElement = target && findBuilderParent(target);
|
|
3196
|
+
const builderId = targetBuilderElement?.getAttribute("builder-id") || targetBuilderElement?.id;
|
|
3197
|
+
return {
|
|
3198
|
+
targetBuilderElement: builderId || void 0,
|
|
3199
|
+
metadata: {
|
|
3200
|
+
targetOffset: target ? computeOffset({
|
|
3201
|
+
event,
|
|
3202
|
+
target
|
|
3203
|
+
}) : void 0,
|
|
3204
|
+
builderTargetOffset: targetBuilderElement ? computeOffset({
|
|
3205
|
+
event,
|
|
3206
|
+
target: targetBuilderElement
|
|
3207
|
+
}) : void 0,
|
|
3208
|
+
builderElementIndex: targetBuilderElement && builderId ? [].slice.call(document.getElementsByClassName(builderId)).indexOf(targetBuilderElement) : void 0
|
|
3209
|
+
}
|
|
3210
|
+
};
|
|
3211
|
+
};
|
|
3212
|
+
|
|
3213
|
+
// src/constants/sdk-version.ts
|
|
3214
|
+
var SDK_VERSION = "0.7.2";
|
|
3215
|
+
|
|
3216
|
+
// src/functions/register.ts
|
|
3217
|
+
var registry = {};
|
|
3218
|
+
function register(type, info) {
|
|
3219
|
+
let typeList = registry[type];
|
|
3220
|
+
if (!typeList) {
|
|
3221
|
+
typeList = registry[type] = [];
|
|
3222
|
+
}
|
|
3223
|
+
typeList.push(info);
|
|
3224
|
+
if (isBrowser()) {
|
|
3225
|
+
const message = {
|
|
3226
|
+
type: "builder.register",
|
|
3227
|
+
data: {
|
|
3228
|
+
type,
|
|
3229
|
+
info
|
|
3230
|
+
}
|
|
3231
|
+
};
|
|
3881
3232
|
try {
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
logger.error("Error fetching data. ", {
|
|
3886
|
-
url,
|
|
3887
|
-
content,
|
|
3888
|
-
options
|
|
3889
|
-
});
|
|
3890
|
-
return null;
|
|
3233
|
+
parent.postMessage(message, "*");
|
|
3234
|
+
if (parent !== window) {
|
|
3235
|
+
window.postMessage(message, "*");
|
|
3891
3236
|
}
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
logger.error("Error fetching data. ", error);
|
|
3895
|
-
return null;
|
|
3237
|
+
} catch (err) {
|
|
3238
|
+
console.debug("Could not postmessage", err);
|
|
3896
3239
|
}
|
|
3897
|
-
}
|
|
3240
|
+
}
|
|
3898
3241
|
}
|
|
3899
|
-
var getAllContent = fetchEntries;
|
|
3900
3242
|
|
|
3901
|
-
// src/
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3243
|
+
// src/scripts/init-editing.ts
|
|
3244
|
+
var registerInsertMenu = () => {
|
|
3245
|
+
register("insertMenu", {
|
|
3246
|
+
name: "_default",
|
|
3247
|
+
default: true,
|
|
3248
|
+
items: [{
|
|
3249
|
+
name: "Box"
|
|
3250
|
+
}, {
|
|
3251
|
+
name: "Text"
|
|
3252
|
+
}, {
|
|
3253
|
+
name: "Image"
|
|
3254
|
+
}, {
|
|
3255
|
+
name: "Columns"
|
|
3256
|
+
}, ...TARGET === "reactNative" ? [] : [{
|
|
3257
|
+
name: "Core:Section"
|
|
3258
|
+
}, {
|
|
3259
|
+
name: "Core:Button"
|
|
3260
|
+
}, {
|
|
3261
|
+
name: "Embed"
|
|
3262
|
+
}, {
|
|
3263
|
+
name: "Custom Code"
|
|
3264
|
+
}]]
|
|
3265
|
+
});
|
|
3266
|
+
};
|
|
3267
|
+
var isSetupForEditing = false;
|
|
3268
|
+
var setupBrowserForEditing = (options = {}) => {
|
|
3269
|
+
if (isSetupForEditing) {
|
|
3270
|
+
return;
|
|
3905
3271
|
}
|
|
3906
|
-
|
|
3907
|
-
|
|
3272
|
+
isSetupForEditing = true;
|
|
3273
|
+
if (isBrowser()) {
|
|
3274
|
+
window.parent?.postMessage({
|
|
3275
|
+
type: "builder.sdkInfo",
|
|
3276
|
+
data: {
|
|
3277
|
+
target: TARGET,
|
|
3278
|
+
version: SDK_VERSION,
|
|
3279
|
+
supportsPatchUpdates: false,
|
|
3280
|
+
// Supports builder-model="..." attribute which is needed to
|
|
3281
|
+
// scope our '+ add block' button styling
|
|
3282
|
+
supportsAddBlockScoping: true,
|
|
3283
|
+
supportsCustomBreakpoints: true
|
|
3284
|
+
}
|
|
3285
|
+
}, "*");
|
|
3286
|
+
window.parent?.postMessage({
|
|
3287
|
+
type: "builder.updateContent",
|
|
3288
|
+
data: {
|
|
3289
|
+
options
|
|
3290
|
+
}
|
|
3291
|
+
}, "*");
|
|
3292
|
+
window.addEventListener("message", ({
|
|
3293
|
+
data
|
|
3294
|
+
}) => {
|
|
3295
|
+
if (!data?.type) {
|
|
3296
|
+
return;
|
|
3297
|
+
}
|
|
3298
|
+
switch (data.type) {
|
|
3299
|
+
case "builder.evaluate": {
|
|
3300
|
+
const text = data.data.text;
|
|
3301
|
+
const args = data.data.arguments || [];
|
|
3302
|
+
const id = data.data.id;
|
|
3303
|
+
const fn = new Function(text);
|
|
3304
|
+
let result;
|
|
3305
|
+
let error = null;
|
|
3306
|
+
try {
|
|
3307
|
+
result = fn.apply(null, args);
|
|
3308
|
+
} catch (err) {
|
|
3309
|
+
error = err;
|
|
3310
|
+
}
|
|
3311
|
+
if (error) {
|
|
3312
|
+
window.parent?.postMessage({
|
|
3313
|
+
type: "builder.evaluateError",
|
|
3314
|
+
data: {
|
|
3315
|
+
id,
|
|
3316
|
+
error: error.message
|
|
3317
|
+
}
|
|
3318
|
+
}, "*");
|
|
3319
|
+
} else {
|
|
3320
|
+
if (result && typeof result.then === "function") {
|
|
3321
|
+
result.then((finalResult) => {
|
|
3322
|
+
window.parent?.postMessage({
|
|
3323
|
+
type: "builder.evaluateResult",
|
|
3324
|
+
data: {
|
|
3325
|
+
id,
|
|
3326
|
+
result: finalResult
|
|
3327
|
+
}
|
|
3328
|
+
}, "*");
|
|
3329
|
+
}).catch(console.error);
|
|
3330
|
+
} else {
|
|
3331
|
+
window.parent?.postMessage({
|
|
3332
|
+
type: "builder.evaluateResult",
|
|
3333
|
+
data: {
|
|
3334
|
+
result,
|
|
3335
|
+
id
|
|
3336
|
+
}
|
|
3337
|
+
}, "*");
|
|
3338
|
+
}
|
|
3339
|
+
}
|
|
3340
|
+
break;
|
|
3341
|
+
}
|
|
3342
|
+
}
|
|
3343
|
+
});
|
|
3908
3344
|
}
|
|
3909
|
-
|
|
3910
|
-
}
|
|
3345
|
+
};
|
|
3911
3346
|
|
|
3912
|
-
// src/components/content/components/enable-editor.
|
|
3347
|
+
// src/components/content/components/enable-editor.tsx
|
|
3913
3348
|
function EnableEditor(props) {
|
|
3914
|
-
const [forceReRenderCount, setForceReRenderCount] =
|
|
3915
|
-
const [lastUpdated, setLastUpdated] =
|
|
3916
|
-
const [shouldSendResetCookie, setShouldSendResetCookie] =
|
|
3917
|
-
const [httpReqsData, setHttpReqsData] =
|
|
3918
|
-
const [clicked, setClicked] =
|
|
3349
|
+
const [forceReRenderCount, setForceReRenderCount] = createSignal9(0);
|
|
3350
|
+
const [lastUpdated, setLastUpdated] = createSignal9(0);
|
|
3351
|
+
const [shouldSendResetCookie, setShouldSendResetCookie] = createSignal9(false);
|
|
3352
|
+
const [httpReqsData, setHttpReqsData] = createSignal9({});
|
|
3353
|
+
const [clicked, setClicked] = createSignal9(false);
|
|
3919
3354
|
function mergeNewContent(newContent) {
|
|
3920
3355
|
const newContentValue = {
|
|
3921
3356
|
...props.builderContextSignal.content,
|
|
@@ -4037,14 +3472,17 @@ function EnableEditor(props) {
|
|
|
4037
3472
|
function emitStateUpdate() {
|
|
4038
3473
|
if (isEditing()) {
|
|
4039
3474
|
window.dispatchEvent(
|
|
4040
|
-
new CustomEvent(
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
3475
|
+
new CustomEvent(
|
|
3476
|
+
"builder:component:stateChange",
|
|
3477
|
+
{
|
|
3478
|
+
detail: {
|
|
3479
|
+
state: fastClone(props.builderContextSignal.rootState),
|
|
3480
|
+
ref: {
|
|
3481
|
+
name: props.model
|
|
3482
|
+
}
|
|
4045
3483
|
}
|
|
4046
3484
|
}
|
|
4047
|
-
|
|
3485
|
+
)
|
|
4048
3486
|
);
|
|
4049
3487
|
}
|
|
4050
3488
|
}
|
|
@@ -4066,12 +3504,12 @@ function EnableEditor(props) {
|
|
|
4066
3504
|
enrich: props.enrich
|
|
4067
3505
|
} : {}
|
|
4068
3506
|
});
|
|
4069
|
-
Object.values(
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
);
|
|
3507
|
+
Object.values(
|
|
3508
|
+
props.builderContextSignal.componentInfos
|
|
3509
|
+
).forEach((registeredComponent) => {
|
|
3510
|
+
const message = createRegisterComponentMessage(registeredComponent);
|
|
3511
|
+
window.parent?.postMessage(message, "*");
|
|
3512
|
+
});
|
|
4075
3513
|
window.addEventListener(
|
|
4076
3514
|
"builder:component:stateChangeListenerActivated",
|
|
4077
3515
|
emitStateUpdate
|
|
@@ -4155,7 +3593,7 @@ function EnableEditor(props) {
|
|
|
4155
3593
|
emitStateUpdate();
|
|
4156
3594
|
}
|
|
4157
3595
|
createEffect2(on2(() => [props.builderContextSignal.rootState], onUpdateFn_4));
|
|
4158
|
-
return <
|
|
3596
|
+
return <builder_context_default.Provider value={props.builderContextSignal}><Show9 when={props.builderContextSignal.content}><div
|
|
4159
3597
|
class={props.classNameProp}
|
|
4160
3598
|
{...{}}
|
|
4161
3599
|
key={forceReRenderCount()}
|
|
@@ -4168,19 +3606,139 @@ function EnableEditor(props) {
|
|
|
4168
3606
|
hidden: true,
|
|
4169
3607
|
"aria-hidden": true
|
|
4170
3608
|
}}
|
|
4171
|
-
>{props.children}</div></Show9></
|
|
3609
|
+
>{props.children}</div></Show9></builder_context_default.Provider>;
|
|
4172
3610
|
}
|
|
4173
3611
|
var Enable_editor_default = EnableEditor;
|
|
4174
3612
|
|
|
4175
|
-
// src/components/
|
|
4176
|
-
|
|
4177
|
-
|
|
3613
|
+
// src/components/content/components/styles.tsx
|
|
3614
|
+
import { createSignal as createSignal10 } from "solid-js";
|
|
3615
|
+
|
|
3616
|
+
// src/components/content/components/styles.helpers.ts
|
|
3617
|
+
var getCssFromFont = (font) => {
|
|
3618
|
+
const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
|
|
3619
|
+
const name = family.split(",")[0];
|
|
3620
|
+
const url = font.fileUrl ?? font?.files?.regular;
|
|
3621
|
+
let str = "";
|
|
3622
|
+
if (url && family && name) {
|
|
3623
|
+
str += `
|
|
3624
|
+
@font-face {
|
|
3625
|
+
font-family: "${family}";
|
|
3626
|
+
src: local("${name}"), url('${url}') format('woff2');
|
|
3627
|
+
font-display: fallback;
|
|
3628
|
+
font-weight: 400;
|
|
4178
3629
|
}
|
|
4179
|
-
|
|
3630
|
+
`.trim();
|
|
3631
|
+
}
|
|
3632
|
+
if (font.files) {
|
|
3633
|
+
for (const weight in font.files) {
|
|
3634
|
+
const isNumber = String(Number(weight)) === weight;
|
|
3635
|
+
if (!isNumber) {
|
|
3636
|
+
continue;
|
|
3637
|
+
}
|
|
3638
|
+
const weightUrl = font.files[weight];
|
|
3639
|
+
if (weightUrl && weightUrl !== url) {
|
|
3640
|
+
str += `
|
|
3641
|
+
@font-face {
|
|
3642
|
+
font-family: "${family}";
|
|
3643
|
+
src: url('${weightUrl}') format('woff2');
|
|
3644
|
+
font-display: fallback;
|
|
3645
|
+
font-weight: ${weight};
|
|
3646
|
+
}
|
|
3647
|
+
`.trim();
|
|
3648
|
+
}
|
|
3649
|
+
}
|
|
3650
|
+
}
|
|
3651
|
+
return str;
|
|
3652
|
+
};
|
|
3653
|
+
var getFontCss = ({
|
|
3654
|
+
customFonts
|
|
3655
|
+
}) => {
|
|
3656
|
+
return customFonts?.map((font) => getCssFromFont(font))?.join(" ") || "";
|
|
3657
|
+
};
|
|
3658
|
+
var getCss = ({
|
|
3659
|
+
cssCode,
|
|
3660
|
+
contentId
|
|
3661
|
+
}) => {
|
|
3662
|
+
if (!cssCode) {
|
|
3663
|
+
return "";
|
|
3664
|
+
}
|
|
3665
|
+
if (!contentId) {
|
|
3666
|
+
return cssCode;
|
|
3667
|
+
}
|
|
3668
|
+
return cssCode?.replace(/&/g, `div[builder-content-id="${contentId}"]`) || "";
|
|
3669
|
+
};
|
|
3670
|
+
|
|
3671
|
+
// src/components/content/components/styles.tsx
|
|
3672
|
+
function ContentStyles(props) {
|
|
3673
|
+
const [injectedStyles, setInjectedStyles] = createSignal10(
|
|
3674
|
+
`
|
|
3675
|
+
${getCss({
|
|
3676
|
+
cssCode: props.cssCode,
|
|
3677
|
+
contentId: props.contentId
|
|
3678
|
+
})}
|
|
3679
|
+
${getFontCss({
|
|
3680
|
+
customFonts: props.customFonts
|
|
3681
|
+
})}
|
|
3682
|
+
|
|
3683
|
+
.builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
|
|
3684
|
+
margin: 0;
|
|
3685
|
+
}
|
|
3686
|
+
.builder-text > p, .builder-text > .builder-paragraph {
|
|
3687
|
+
color: inherit;
|
|
3688
|
+
line-height: inherit;
|
|
3689
|
+
letter-spacing: inherit;
|
|
3690
|
+
font-weight: inherit;
|
|
3691
|
+
font-size: inherit;
|
|
3692
|
+
text-align: inherit;
|
|
3693
|
+
font-family: inherit;
|
|
3694
|
+
}
|
|
3695
|
+
`.trim()
|
|
3696
|
+
);
|
|
3697
|
+
return <Inlined_styles_default styles={injectedStyles()} />;
|
|
3698
|
+
}
|
|
3699
|
+
var Styles_default = ContentStyles;
|
|
3700
|
+
|
|
3701
|
+
// src/components/content/content.helpers.ts
|
|
3702
|
+
var getContextStateInitialValue = ({
|
|
3703
|
+
content,
|
|
3704
|
+
data,
|
|
3705
|
+
locale
|
|
3706
|
+
}) => {
|
|
3707
|
+
const defaultValues = {};
|
|
3708
|
+
content?.data?.inputs?.forEach((input) => {
|
|
3709
|
+
if (input.name && input.defaultValue !== void 0 && content?.data?.state && content.data.state[input.name] === void 0) {
|
|
3710
|
+
defaultValues[input.name] = input.defaultValue;
|
|
3711
|
+
}
|
|
3712
|
+
});
|
|
3713
|
+
const stateToUse = {
|
|
3714
|
+
...content?.data?.state,
|
|
3715
|
+
...data,
|
|
3716
|
+
...locale ? {
|
|
3717
|
+
locale
|
|
3718
|
+
} : {}
|
|
3719
|
+
};
|
|
3720
|
+
return {
|
|
3721
|
+
...defaultValues,
|
|
3722
|
+
...stateToUse
|
|
3723
|
+
};
|
|
3724
|
+
};
|
|
3725
|
+
var getContentInitialValue = ({
|
|
3726
|
+
content,
|
|
3727
|
+
data
|
|
3728
|
+
}) => {
|
|
3729
|
+
return !content ? void 0 : {
|
|
3730
|
+
...content,
|
|
3731
|
+
data: {
|
|
3732
|
+
...content?.data,
|
|
3733
|
+
...data
|
|
3734
|
+
},
|
|
3735
|
+
meta: content?.meta
|
|
3736
|
+
};
|
|
3737
|
+
};
|
|
4180
3738
|
|
|
4181
|
-
// src/components/content/content.
|
|
3739
|
+
// src/components/content/content.tsx
|
|
4182
3740
|
function ContentComponent(props) {
|
|
4183
|
-
const [scriptStr, setScriptStr] =
|
|
3741
|
+
const [scriptStr, setScriptStr] = createSignal11(
|
|
4184
3742
|
getRenderContentScriptString({
|
|
4185
3743
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
4186
3744
|
variationId: props.content?.testVariationId,
|
|
@@ -4188,7 +3746,7 @@ function ContentComponent(props) {
|
|
|
4188
3746
|
contentId: props.content?.id
|
|
4189
3747
|
})
|
|
4190
3748
|
);
|
|
4191
|
-
const [registeredComponents, setRegisteredComponents] =
|
|
3749
|
+
const [registeredComponents, setRegisteredComponents] = createSignal11(
|
|
4192
3750
|
[
|
|
4193
3751
|
...getDefaultRegisteredComponents(),
|
|
4194
3752
|
// While this `components` object is deprecated, we must maintain support for it.
|
|
@@ -4209,7 +3767,7 @@ function ContentComponent(props) {
|
|
|
4209
3767
|
{}
|
|
4210
3768
|
)
|
|
4211
3769
|
);
|
|
4212
|
-
const [builderContextSignal, setBuilderContextSignal] =
|
|
3770
|
+
const [builderContextSignal, setBuilderContextSignal] = createSignal11({
|
|
4213
3771
|
content: getContentInitialValue({
|
|
4214
3772
|
content: props.content,
|
|
4215
3773
|
data: props.data
|
|
@@ -4248,7 +3806,7 @@ function ContentComponent(props) {
|
|
|
4248
3806
|
rootState: newRootState
|
|
4249
3807
|
}));
|
|
4250
3808
|
}
|
|
4251
|
-
return <
|
|
3809
|
+
return <components_context_default.Provider
|
|
4252
3810
|
value={{
|
|
4253
3811
|
registeredComponents: registeredComponents()
|
|
4254
3812
|
}}
|
|
@@ -4279,13 +3837,13 @@ function ContentComponent(props) {
|
|
|
4279
3837
|
context={builderContextSignal()}
|
|
4280
3838
|
registeredComponents={registeredComponents()}
|
|
4281
3839
|
/>
|
|
4282
|
-
</Enable_editor_default></
|
|
3840
|
+
</Enable_editor_default></components_context_default.Provider>;
|
|
4283
3841
|
}
|
|
4284
3842
|
var Content_default = ContentComponent;
|
|
4285
3843
|
|
|
4286
|
-
// src/components/content-variants/content-variants.
|
|
3844
|
+
// src/components/content-variants/content-variants.tsx
|
|
4287
3845
|
function ContentVariants(props) {
|
|
4288
|
-
const [shouldRenderVariants, setShouldRenderVariants] =
|
|
3846
|
+
const [shouldRenderVariants, setShouldRenderVariants] = createSignal12(
|
|
4289
3847
|
checkShouldRunVariants({
|
|
4290
3848
|
canTrack: getDefaultCanTrack(props.canTrack),
|
|
4291
3849
|
content: props.content
|
|
@@ -4313,6 +3871,7 @@ function ContentVariants(props) {
|
|
|
4313
3871
|
});
|
|
4314
3872
|
}
|
|
4315
3873
|
onMount3(() => {
|
|
3874
|
+
setShouldRenderVariants(false);
|
|
4316
3875
|
});
|
|
4317
3876
|
return <>
|
|
4318
3877
|
<Show11 when={!props.__isNestedRender && TARGET !== "reactNative"}><Inlined_script_default scriptStr={getScriptString()} /></Show11>
|
|
@@ -4364,72 +3923,33 @@ function ContentVariants(props) {
|
|
|
4364
3923
|
}
|
|
4365
3924
|
var Content_variants_default = ContentVariants;
|
|
4366
3925
|
|
|
4367
|
-
// src/blocks/symbol/symbol.helpers.
|
|
4368
|
-
var
|
|
4369
|
-
var __getOwnPropSymbols18 = Object.getOwnPropertySymbols;
|
|
4370
|
-
var __hasOwnProp18 = Object.prototype.hasOwnProperty;
|
|
4371
|
-
var __propIsEnum18 = Object.prototype.propertyIsEnumerable;
|
|
4372
|
-
var __defNormalProp18 = (obj, key, value) => key in obj ? __defProp18(obj, key, {
|
|
4373
|
-
enumerable: true,
|
|
4374
|
-
configurable: true,
|
|
4375
|
-
writable: true,
|
|
4376
|
-
value
|
|
4377
|
-
}) : obj[key] = value;
|
|
4378
|
-
var __spreadValues18 = (a, b) => {
|
|
4379
|
-
for (var prop in b || (b = {}))
|
|
4380
|
-
if (__hasOwnProp18.call(b, prop))
|
|
4381
|
-
__defNormalProp18(a, prop, b[prop]);
|
|
4382
|
-
if (__getOwnPropSymbols18)
|
|
4383
|
-
for (var prop of __getOwnPropSymbols18(b)) {
|
|
4384
|
-
if (__propIsEnum18.call(b, prop))
|
|
4385
|
-
__defNormalProp18(a, prop, b[prop]);
|
|
4386
|
-
}
|
|
4387
|
-
return a;
|
|
4388
|
-
};
|
|
4389
|
-
var __async6 = (__this, __arguments, generator) => {
|
|
4390
|
-
return new Promise((resolve, reject) => {
|
|
4391
|
-
var fulfilled = (value) => {
|
|
4392
|
-
try {
|
|
4393
|
-
step(generator.next(value));
|
|
4394
|
-
} catch (e) {
|
|
4395
|
-
reject(e);
|
|
4396
|
-
}
|
|
4397
|
-
};
|
|
4398
|
-
var rejected = (value) => {
|
|
4399
|
-
try {
|
|
4400
|
-
step(generator.throw(value));
|
|
4401
|
-
} catch (e) {
|
|
4402
|
-
reject(e);
|
|
4403
|
-
}
|
|
4404
|
-
};
|
|
4405
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
4406
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
4407
|
-
});
|
|
4408
|
-
};
|
|
4409
|
-
var fetchSymbolContent = (_0) => __async6(void 0, [_0], function* ({
|
|
3926
|
+
// src/blocks/symbol/symbol.helpers.ts
|
|
3927
|
+
var fetchSymbolContent = async ({
|
|
4410
3928
|
builderContextValue,
|
|
4411
3929
|
symbol
|
|
4412
|
-
}) {
|
|
4413
|
-
if (
|
|
4414
|
-
|
|
3930
|
+
}) => {
|
|
3931
|
+
if (symbol?.model && // This is a hack, we should not need to check for this, but it is needed for Svelte.
|
|
3932
|
+
builderContextValue?.apiKey) {
|
|
3933
|
+
return fetchOneEntry({
|
|
4415
3934
|
model: symbol.model,
|
|
4416
3935
|
apiKey: builderContextValue.apiKey,
|
|
4417
|
-
apiVersion: builderContextValue.apiVersion
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
3936
|
+
apiVersion: builderContextValue.apiVersion,
|
|
3937
|
+
...symbol?.entry && {
|
|
3938
|
+
query: {
|
|
3939
|
+
id: symbol.entry
|
|
3940
|
+
}
|
|
4421
3941
|
}
|
|
4422
|
-
})
|
|
3942
|
+
}).catch((err) => {
|
|
4423
3943
|
logger.error("Could not fetch symbol content: ", err);
|
|
4424
3944
|
return void 0;
|
|
4425
3945
|
});
|
|
4426
3946
|
}
|
|
4427
3947
|
return void 0;
|
|
4428
|
-
}
|
|
3948
|
+
};
|
|
4429
3949
|
|
|
4430
|
-
// src/blocks/symbol/symbol.
|
|
3950
|
+
// src/blocks/symbol/symbol.tsx
|
|
4431
3951
|
function Symbol(props) {
|
|
4432
|
-
const [contentToUse, setContentToUse] =
|
|
3952
|
+
const [contentToUse, setContentToUse] = createSignal13(props.symbol?.content);
|
|
4433
3953
|
function className() {
|
|
4434
3954
|
return [
|
|
4435
3955
|
...[props.attributes.class],
|
|
@@ -4474,11 +3994,11 @@ function Symbol(props) {
|
|
|
4474
3994
|
}
|
|
4475
3995
|
var symbol_default = Symbol;
|
|
4476
3996
|
|
|
4477
|
-
// src/index-helpers/blocks-exports.
|
|
3997
|
+
// src/index-helpers/blocks-exports.ts
|
|
4478
3998
|
var RenderBlocks = Blocks_default;
|
|
4479
3999
|
var RenderContent = Content_variants_default;
|
|
4480
4000
|
|
|
4481
|
-
// src/functions/set-editor-settings.
|
|
4001
|
+
// src/functions/set-editor-settings.ts
|
|
4482
4002
|
var settings = {};
|
|
4483
4003
|
function setEditorSettings(newSettings) {
|
|
4484
4004
|
if (isBrowser()) {
|
|
@@ -4491,68 +4011,27 @@ function setEditorSettings(newSettings) {
|
|
|
4491
4011
|
}
|
|
4492
4012
|
}
|
|
4493
4013
|
|
|
4494
|
-
// src/functions/fetch-builder-props.
|
|
4495
|
-
var
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
var __hasOwnProp19 = Object.prototype.hasOwnProperty;
|
|
4500
|
-
var __propIsEnum19 = Object.prototype.propertyIsEnumerable;
|
|
4501
|
-
var __defNormalProp19 = (obj, key, value) => key in obj ? __defProp19(obj, key, {
|
|
4502
|
-
enumerable: true,
|
|
4503
|
-
configurable: true,
|
|
4504
|
-
writable: true,
|
|
4505
|
-
value
|
|
4506
|
-
}) : obj[key] = value;
|
|
4507
|
-
var __spreadValues19 = (a, b) => {
|
|
4508
|
-
for (var prop in b || (b = {}))
|
|
4509
|
-
if (__hasOwnProp19.call(b, prop))
|
|
4510
|
-
__defNormalProp19(a, prop, b[prop]);
|
|
4511
|
-
if (__getOwnPropSymbols19)
|
|
4512
|
-
for (var prop of __getOwnPropSymbols19(b)) {
|
|
4513
|
-
if (__propIsEnum19.call(b, prop))
|
|
4514
|
-
__defNormalProp19(a, prop, b[prop]);
|
|
4515
|
-
}
|
|
4516
|
-
return a;
|
|
4517
|
-
};
|
|
4518
|
-
var __spreadProps13 = (a, b) => __defProps13(a, __getOwnPropDescs13(b));
|
|
4519
|
-
var __async7 = (__this, __arguments, generator) => {
|
|
4520
|
-
return new Promise((resolve, reject) => {
|
|
4521
|
-
var fulfilled = (value) => {
|
|
4522
|
-
try {
|
|
4523
|
-
step(generator.next(value));
|
|
4524
|
-
} catch (e) {
|
|
4525
|
-
reject(e);
|
|
4526
|
-
}
|
|
4527
|
-
};
|
|
4528
|
-
var rejected = (value) => {
|
|
4529
|
-
try {
|
|
4530
|
-
step(generator.throw(value));
|
|
4531
|
-
} catch (e) {
|
|
4532
|
-
reject(e);
|
|
4533
|
-
}
|
|
4534
|
-
};
|
|
4535
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
4536
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
4537
|
-
});
|
|
4538
|
-
};
|
|
4539
|
-
var fetchBuilderProps = (_args) => __async7(void 0, null, function* () {
|
|
4540
|
-
var _a, _b, _c;
|
|
4541
|
-
const urlPath = _args.path || ((_a = _args.url) == null ? void 0 : _a.pathname) || ((_b = _args.userAttributes) == null ? void 0 : _b.urlPath);
|
|
4542
|
-
const getContentArgs = __spreadProps13(__spreadValues19({}, _args), {
|
|
4014
|
+
// src/functions/fetch-builder-props.ts
|
|
4015
|
+
var fetchBuilderProps = async (_args) => {
|
|
4016
|
+
const urlPath = _args.path || _args.url?.pathname || _args.userAttributes?.urlPath;
|
|
4017
|
+
const getContentArgs = {
|
|
4018
|
+
..._args,
|
|
4543
4019
|
apiKey: _args.apiKey,
|
|
4544
4020
|
model: _args.model || "page",
|
|
4545
|
-
userAttributes:
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4021
|
+
userAttributes: {
|
|
4022
|
+
..._args.userAttributes,
|
|
4023
|
+
...urlPath ? {
|
|
4024
|
+
urlPath
|
|
4025
|
+
} : {}
|
|
4026
|
+
},
|
|
4027
|
+
options: getBuilderSearchParams(_args.searchParams || _args.url?.searchParams || _args.options)
|
|
4028
|
+
};
|
|
4550
4029
|
return {
|
|
4551
4030
|
apiKey: getContentArgs.apiKey,
|
|
4552
4031
|
model: getContentArgs.model,
|
|
4553
|
-
content:
|
|
4032
|
+
content: await fetchOneEntry(getContentArgs)
|
|
4554
4033
|
};
|
|
4555
|
-
}
|
|
4034
|
+
};
|
|
4556
4035
|
export {
|
|
4557
4036
|
Blocks_default as Blocks,
|
|
4558
4037
|
button_default as Button,
|