@builder.io/sdk-solid 0.7.1-1 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +924 -25
- package/lib/browser/dev.js +1592 -2071
- package/lib/browser/dev.jsx +1629 -2134
- package/lib/browser/index.js +1573 -2052
- package/lib/browser/index.jsx +1624 -2129
- package/lib/edge/dev.js +1825 -2322
- package/lib/edge/dev.jsx +1787 -2310
- package/lib/edge/index.js +1758 -2255
- package/lib/edge/index.jsx +1786 -2309
- package/lib/node/dev.js +1748 -2245
- package/lib/node/dev.jsx +1628 -2149
- package/lib/node/index.js +1656 -2153
- package/lib/node/index.jsx +1640 -2161
- package/package.json +1 -1
package/lib/browser/dev.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,16 +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/evaluate/choose-eval.
|
|
213
|
+
// src/functions/evaluate/choose-eval.ts
|
|
230
214
|
var chooseBrowserOrServerEval = (args) => isBrowser() ? runInBrowser(args) : runInBrowser(args);
|
|
231
215
|
|
|
232
|
-
// src/functions/evaluate/evaluate.
|
|
216
|
+
// src/functions/evaluate/evaluate.ts
|
|
233
217
|
function evaluate({
|
|
234
218
|
code,
|
|
235
219
|
context,
|
|
@@ -264,7 +248,10 @@ function evaluate({
|
|
|
264
248
|
}
|
|
265
249
|
}
|
|
266
250
|
|
|
267
|
-
// src/functions/
|
|
251
|
+
// src/functions/fast-clone.ts
|
|
252
|
+
var fastClone = (obj) => JSON.parse(JSON.stringify(obj));
|
|
253
|
+
|
|
254
|
+
// src/functions/set.ts
|
|
268
255
|
var set = (obj, _path, value) => {
|
|
269
256
|
if (Object(obj) !== obj) {
|
|
270
257
|
return obj;
|
|
@@ -274,36 +261,12 @@ var set = (obj, _path, value) => {
|
|
|
274
261
|
return obj;
|
|
275
262
|
};
|
|
276
263
|
|
|
277
|
-
// src/functions/transform-block.
|
|
264
|
+
// src/functions/transform-block.ts
|
|
278
265
|
function transformBlock(block) {
|
|
279
266
|
return block;
|
|
280
267
|
}
|
|
281
268
|
|
|
282
|
-
// src/functions/get-processed-block.
|
|
283
|
-
var __defProp = Object.defineProperty;
|
|
284
|
-
var __defProps = Object.defineProperties;
|
|
285
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
286
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
287
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
288
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
289
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
290
|
-
enumerable: true,
|
|
291
|
-
configurable: true,
|
|
292
|
-
writable: true,
|
|
293
|
-
value
|
|
294
|
-
}) : obj[key] = value;
|
|
295
|
-
var __spreadValues = (a, b) => {
|
|
296
|
-
for (var prop in b || (b = {}))
|
|
297
|
-
if (__hasOwnProp.call(b, prop))
|
|
298
|
-
__defNormalProp(a, prop, b[prop]);
|
|
299
|
-
if (__getOwnPropSymbols)
|
|
300
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
301
|
-
if (__propIsEnum.call(b, prop))
|
|
302
|
-
__defNormalProp(a, prop, b[prop]);
|
|
303
|
-
}
|
|
304
|
-
return a;
|
|
305
|
-
};
|
|
306
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
269
|
+
// src/functions/get-processed-block.ts
|
|
307
270
|
var evaluateBindings = ({
|
|
308
271
|
block,
|
|
309
272
|
context,
|
|
@@ -315,10 +278,15 @@ var evaluateBindings = ({
|
|
|
315
278
|
return block;
|
|
316
279
|
}
|
|
317
280
|
const copy = fastClone(block);
|
|
318
|
-
const copied =
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
281
|
+
const copied = {
|
|
282
|
+
...copy,
|
|
283
|
+
properties: {
|
|
284
|
+
...copy.properties
|
|
285
|
+
},
|
|
286
|
+
actions: {
|
|
287
|
+
...copy.actions
|
|
288
|
+
}
|
|
289
|
+
};
|
|
322
290
|
for (const binding in block.bindings) {
|
|
323
291
|
const expression = block.bindings[binding];
|
|
324
292
|
const value = evaluate({
|
|
@@ -354,13 +322,135 @@ function getProcessedBlock({
|
|
|
354
322
|
}
|
|
355
323
|
}
|
|
356
324
|
|
|
357
|
-
// src/
|
|
325
|
+
// src/components/block/block.helpers.ts
|
|
326
|
+
var EMPTY_HTML_ELEMENTS = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
|
|
327
|
+
var isEmptyHtmlElement = (tagName) => {
|
|
328
|
+
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
|
|
329
|
+
};
|
|
330
|
+
var getComponent = ({
|
|
331
|
+
block,
|
|
332
|
+
context,
|
|
333
|
+
registeredComponents
|
|
334
|
+
}) => {
|
|
335
|
+
const componentName = getProcessedBlock({
|
|
336
|
+
block,
|
|
337
|
+
localState: context.localState,
|
|
338
|
+
rootState: context.rootState,
|
|
339
|
+
rootSetState: context.rootSetState,
|
|
340
|
+
context: context.context,
|
|
341
|
+
shouldEvaluateBindings: false
|
|
342
|
+
}).component?.name;
|
|
343
|
+
if (!componentName) {
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
const ref = registeredComponents[componentName];
|
|
347
|
+
if (!ref) {
|
|
348
|
+
console.warn(`
|
|
349
|
+
Could not find a registered component named "${componentName}".
|
|
350
|
+
If you registered it, is the file that registered it imported by the file that needs to render it?`);
|
|
351
|
+
return void 0;
|
|
352
|
+
} else {
|
|
353
|
+
return ref;
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
var getRepeatItemData = ({
|
|
357
|
+
block,
|
|
358
|
+
context
|
|
359
|
+
}) => {
|
|
360
|
+
const {
|
|
361
|
+
repeat,
|
|
362
|
+
...blockWithoutRepeat
|
|
363
|
+
} = block;
|
|
364
|
+
if (!repeat?.collection) {
|
|
365
|
+
return void 0;
|
|
366
|
+
}
|
|
367
|
+
const itemsArray = evaluate({
|
|
368
|
+
code: repeat.collection,
|
|
369
|
+
localState: context.localState,
|
|
370
|
+
rootState: context.rootState,
|
|
371
|
+
rootSetState: context.rootSetState,
|
|
372
|
+
context: context.context
|
|
373
|
+
});
|
|
374
|
+
if (!Array.isArray(itemsArray)) {
|
|
375
|
+
return void 0;
|
|
376
|
+
}
|
|
377
|
+
const collectionName = repeat.collection.split(".").pop();
|
|
378
|
+
const itemNameToUse = repeat.itemName || (collectionName ? collectionName + "Item" : "item");
|
|
379
|
+
const repeatArray = itemsArray.map((item, index) => ({
|
|
380
|
+
context: {
|
|
381
|
+
...context,
|
|
382
|
+
localState: {
|
|
383
|
+
...context.localState,
|
|
384
|
+
$index: index,
|
|
385
|
+
$item: item,
|
|
386
|
+
[itemNameToUse]: item,
|
|
387
|
+
[`$${itemNameToUse}Index`]: index
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
block: blockWithoutRepeat
|
|
391
|
+
}));
|
|
392
|
+
return repeatArray;
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
// src/components/block/components/block-styles.tsx
|
|
396
|
+
import { Show as Show2 } from "solid-js";
|
|
397
|
+
|
|
398
|
+
// src/constants/device-sizes.ts
|
|
399
|
+
var SIZES = {
|
|
400
|
+
small: {
|
|
401
|
+
min: 320,
|
|
402
|
+
default: 321,
|
|
403
|
+
max: 640
|
|
404
|
+
},
|
|
405
|
+
medium: {
|
|
406
|
+
min: 641,
|
|
407
|
+
default: 642,
|
|
408
|
+
max: 991
|
|
409
|
+
},
|
|
410
|
+
large: {
|
|
411
|
+
min: 990,
|
|
412
|
+
default: 991,
|
|
413
|
+
max: 1200
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
var getMaxWidthQueryForSize = (size, sizeValues = SIZES) => `@media (max-width: ${sizeValues[size].max}px)`;
|
|
417
|
+
var getSizesForBreakpoints = ({
|
|
418
|
+
small,
|
|
419
|
+
medium
|
|
420
|
+
}) => {
|
|
421
|
+
const newSizes = fastClone(SIZES);
|
|
422
|
+
if (!small || !medium) {
|
|
423
|
+
return newSizes;
|
|
424
|
+
}
|
|
425
|
+
const smallMin = Math.floor(small / 2);
|
|
426
|
+
newSizes.small = {
|
|
427
|
+
max: small,
|
|
428
|
+
min: smallMin,
|
|
429
|
+
default: smallMin + 1
|
|
430
|
+
};
|
|
431
|
+
const mediumMin = newSizes.small.max + 1;
|
|
432
|
+
newSizes.medium = {
|
|
433
|
+
max: medium,
|
|
434
|
+
min: mediumMin,
|
|
435
|
+
default: mediumMin + 1
|
|
436
|
+
};
|
|
437
|
+
const largeMin = newSizes.medium.max + 1;
|
|
438
|
+
newSizes.large = {
|
|
439
|
+
max: 2e3,
|
|
440
|
+
// TODO: decide upper limit
|
|
441
|
+
min: largeMin,
|
|
442
|
+
default: largeMin + 1
|
|
443
|
+
};
|
|
444
|
+
return newSizes;
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
// src/functions/camel-to-kebab-case.ts
|
|
358
448
|
var camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
359
449
|
|
|
360
|
-
// src/helpers/nullable.
|
|
450
|
+
// src/helpers/nullable.ts
|
|
361
451
|
var checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
|
|
362
452
|
|
|
363
|
-
// src/helpers/css.
|
|
453
|
+
// src/helpers/css.ts
|
|
364
454
|
var convertStyleMapToCSSArray = (style) => {
|
|
365
455
|
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
366
456
|
if (typeof value === "string") {
|
|
@@ -389,13 +479,13 @@ var createCssClass = ({
|
|
|
389
479
|
}
|
|
390
480
|
};
|
|
391
481
|
|
|
392
|
-
// src/components/inlined-styles.
|
|
482
|
+
// src/components/inlined-styles.tsx
|
|
393
483
|
function InlinedStyles(props) {
|
|
394
484
|
return <style innerHTML={props.styles} id={props.id} />;
|
|
395
485
|
}
|
|
396
486
|
var Inlined_styles_default = InlinedStyles;
|
|
397
487
|
|
|
398
|
-
// src/components/block/components/block-styles.
|
|
488
|
+
// src/components/block/components/block-styles.tsx
|
|
399
489
|
function BlockStyles(props) {
|
|
400
490
|
function canShowBlock() {
|
|
401
491
|
const processedBlock = getProcessedBlock({
|
|
@@ -461,66 +551,54 @@ function BlockStyles(props) {
|
|
|
461
551
|
}
|
|
462
552
|
var Block_styles_default = BlockStyles;
|
|
463
553
|
|
|
464
|
-
// src/components/block/block.
|
|
465
|
-
import { Show as
|
|
554
|
+
// src/components/block/components/block-wrapper.tsx
|
|
555
|
+
import { Show as Show3 } from "solid-js";
|
|
556
|
+
import { Dynamic } from "solid-js/web";
|
|
466
557
|
|
|
467
|
-
// src/functions/
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
var __getOwnPropDescs2 = Object.getOwnPropertyDescriptors;
|
|
471
|
-
var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
|
|
472
|
-
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
473
|
-
var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
|
|
474
|
-
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, {
|
|
475
|
-
enumerable: true,
|
|
476
|
-
configurable: true,
|
|
477
|
-
writable: true,
|
|
478
|
-
value
|
|
479
|
-
}) : obj[key] = value;
|
|
480
|
-
var __spreadValues2 = (a, b) => {
|
|
481
|
-
for (var prop in b || (b = {}))
|
|
482
|
-
if (__hasOwnProp2.call(b, prop))
|
|
483
|
-
__defNormalProp2(a, prop, b[prop]);
|
|
484
|
-
if (__getOwnPropSymbols2)
|
|
485
|
-
for (var prop of __getOwnPropSymbols2(b)) {
|
|
486
|
-
if (__propIsEnum2.call(b, prop))
|
|
487
|
-
__defNormalProp2(a, prop, b[prop]);
|
|
488
|
-
}
|
|
489
|
-
return a;
|
|
490
|
-
};
|
|
491
|
-
var __spreadProps2 = (a, b) => __defProps2(a, __getOwnPropDescs2(b));
|
|
492
|
-
function getBlockComponentOptions(block) {
|
|
493
|
-
var _a;
|
|
494
|
-
return __spreadProps2(__spreadValues2(__spreadValues2({}, (_a = block.component) == null ? void 0 : _a.options), block.options), {
|
|
495
|
-
builderBlock: block
|
|
496
|
-
});
|
|
558
|
+
// src/functions/event-handler-name.ts
|
|
559
|
+
function capitalizeFirstLetter(string) {
|
|
560
|
+
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
497
561
|
}
|
|
562
|
+
var getEventHandlerName = (key) => `on${capitalizeFirstLetter(key)}`;
|
|
498
563
|
|
|
499
|
-
// src/functions/
|
|
500
|
-
var
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
for (var prop of __getOwnPropSymbols3(b)) {
|
|
518
|
-
if (__propIsEnum3.call(b, prop))
|
|
519
|
-
__defNormalProp3(a, prop, b[prop]);
|
|
564
|
+
// src/functions/get-block-actions-handler.ts
|
|
565
|
+
var createEventHandler = (value, options) => (event) => evaluate({
|
|
566
|
+
code: value,
|
|
567
|
+
context: options.context,
|
|
568
|
+
localState: options.localState,
|
|
569
|
+
rootState: options.rootState,
|
|
570
|
+
rootSetState: options.rootSetState,
|
|
571
|
+
event,
|
|
572
|
+
isExpression: false
|
|
573
|
+
});
|
|
574
|
+
|
|
575
|
+
// src/functions/get-block-actions.ts
|
|
576
|
+
function getBlockActions(options) {
|
|
577
|
+
const obj = {};
|
|
578
|
+
const optionActions = options.block.actions ?? {};
|
|
579
|
+
for (const key in optionActions) {
|
|
580
|
+
if (!optionActions.hasOwnProperty(key)) {
|
|
581
|
+
continue;
|
|
520
582
|
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
583
|
+
const value = optionActions[key];
|
|
584
|
+
let eventHandlerName = getEventHandlerName(key);
|
|
585
|
+
if (options.stripPrefix) {
|
|
586
|
+
switch (TARGET) {
|
|
587
|
+
case "vue2":
|
|
588
|
+
case "vue3":
|
|
589
|
+
eventHandlerName = eventHandlerName.replace("v-on:", "");
|
|
590
|
+
break;
|
|
591
|
+
case "svelte":
|
|
592
|
+
eventHandlerName = eventHandlerName.replace("on:", "");
|
|
593
|
+
break;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
obj[eventHandlerName] = createEventHandler(value, options);
|
|
597
|
+
}
|
|
598
|
+
return obj;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
// src/functions/sanitize-react-native-block-styles.ts
|
|
524
602
|
var propertiesThatMustBeNumber = /* @__PURE__ */ new Set(["lineHeight"]);
|
|
525
603
|
var displayValues = /* @__PURE__ */ new Set(["flex", "none"]);
|
|
526
604
|
var SHOW_WARNINGS = false;
|
|
@@ -554,46 +632,28 @@ var sanitizeReactNativeBlockStyles = (styles) => {
|
|
|
554
632
|
const newValue = parseFloat(propertyValue);
|
|
555
633
|
const normalizedValue = normalizeNumber(newValue);
|
|
556
634
|
if (normalizedValue) {
|
|
557
|
-
return
|
|
635
|
+
return {
|
|
636
|
+
...acc,
|
|
558
637
|
[key]: normalizedValue
|
|
559
|
-
}
|
|
638
|
+
};
|
|
560
639
|
} else {
|
|
561
640
|
return acc;
|
|
562
641
|
}
|
|
563
642
|
} else if (propertyValue === "0") {
|
|
564
|
-
return
|
|
643
|
+
return {
|
|
644
|
+
...acc,
|
|
565
645
|
[key]: 0
|
|
566
|
-
}
|
|
646
|
+
};
|
|
567
647
|
}
|
|
568
648
|
}
|
|
569
|
-
return
|
|
649
|
+
return {
|
|
650
|
+
...acc,
|
|
570
651
|
[key]: propertyValue
|
|
571
|
-
}
|
|
652
|
+
};
|
|
572
653
|
}, {});
|
|
573
654
|
};
|
|
574
655
|
|
|
575
|
-
// src/functions/get-react-native-block-styles.
|
|
576
|
-
var __defProp4 = Object.defineProperty;
|
|
577
|
-
var __getOwnPropSymbols4 = Object.getOwnPropertySymbols;
|
|
578
|
-
var __hasOwnProp4 = Object.prototype.hasOwnProperty;
|
|
579
|
-
var __propIsEnum4 = Object.prototype.propertyIsEnumerable;
|
|
580
|
-
var __defNormalProp4 = (obj, key, value) => key in obj ? __defProp4(obj, key, {
|
|
581
|
-
enumerable: true,
|
|
582
|
-
configurable: true,
|
|
583
|
-
writable: true,
|
|
584
|
-
value
|
|
585
|
-
}) : obj[key] = value;
|
|
586
|
-
var __spreadValues4 = (a, b) => {
|
|
587
|
-
for (var prop in b || (b = {}))
|
|
588
|
-
if (__hasOwnProp4.call(b, prop))
|
|
589
|
-
__defNormalProp4(a, prop, b[prop]);
|
|
590
|
-
if (__getOwnPropSymbols4)
|
|
591
|
-
for (var prop of __getOwnPropSymbols4(b)) {
|
|
592
|
-
if (__propIsEnum4.call(b, prop))
|
|
593
|
-
__defNormalProp4(a, prop, b[prop]);
|
|
594
|
-
}
|
|
595
|
-
return a;
|
|
596
|
-
};
|
|
656
|
+
// src/functions/get-react-native-block-styles.ts
|
|
597
657
|
function getReactNativeBlockStyles({
|
|
598
658
|
block,
|
|
599
659
|
context,
|
|
@@ -603,41 +663,24 @@ function getReactNativeBlockStyles({
|
|
|
603
663
|
if (!responsiveStyles) {
|
|
604
664
|
return {};
|
|
605
665
|
}
|
|
606
|
-
const styles =
|
|
666
|
+
const styles = {
|
|
667
|
+
// recursively apply inherited styles so that they can be passed down to children `Text` blocks
|
|
668
|
+
...context.inheritedStyles,
|
|
669
|
+
...responsiveStyles.large || {},
|
|
670
|
+
...responsiveStyles.medium || {},
|
|
671
|
+
...responsiveStyles.small || {},
|
|
672
|
+
...blockStyles
|
|
673
|
+
};
|
|
607
674
|
const newStyles = sanitizeReactNativeBlockStyles(styles);
|
|
608
675
|
return newStyles;
|
|
609
676
|
}
|
|
610
677
|
|
|
611
|
-
// src/functions/transform-block-properties.
|
|
678
|
+
// src/functions/transform-block-properties.ts
|
|
612
679
|
function transformBlockProperties(properties) {
|
|
613
680
|
return properties;
|
|
614
681
|
}
|
|
615
682
|
|
|
616
|
-
// src/functions/get-block-properties.
|
|
617
|
-
var __defProp5 = Object.defineProperty;
|
|
618
|
-
var __defProps4 = Object.defineProperties;
|
|
619
|
-
var __getOwnPropDescs4 = Object.getOwnPropertyDescriptors;
|
|
620
|
-
var __getOwnPropSymbols5 = Object.getOwnPropertySymbols;
|
|
621
|
-
var __hasOwnProp5 = Object.prototype.hasOwnProperty;
|
|
622
|
-
var __propIsEnum5 = Object.prototype.propertyIsEnumerable;
|
|
623
|
-
var __defNormalProp5 = (obj, key, value) => key in obj ? __defProp5(obj, key, {
|
|
624
|
-
enumerable: true,
|
|
625
|
-
configurable: true,
|
|
626
|
-
writable: true,
|
|
627
|
-
value
|
|
628
|
-
}) : obj[key] = value;
|
|
629
|
-
var __spreadValues5 = (a, b) => {
|
|
630
|
-
for (var prop in b || (b = {}))
|
|
631
|
-
if (__hasOwnProp5.call(b, prop))
|
|
632
|
-
__defNormalProp5(a, prop, b[prop]);
|
|
633
|
-
if (__getOwnPropSymbols5)
|
|
634
|
-
for (var prop of __getOwnPropSymbols5(b)) {
|
|
635
|
-
if (__propIsEnum5.call(b, prop))
|
|
636
|
-
__defNormalProp5(a, prop, b[prop]);
|
|
637
|
-
}
|
|
638
|
-
return a;
|
|
639
|
-
};
|
|
640
|
-
var __spreadProps4 = (a, b) => __defProps4(a, __getOwnPropDescs4(b));
|
|
683
|
+
// src/functions/get-block-properties.ts
|
|
641
684
|
var extractRelevantRootBlockProperties = (block) => {
|
|
642
685
|
return {
|
|
643
686
|
href: block.href
|
|
@@ -647,12 +690,13 @@ function getBlockProperties({
|
|
|
647
690
|
block,
|
|
648
691
|
context
|
|
649
692
|
}) {
|
|
650
|
-
|
|
651
|
-
|
|
693
|
+
const properties = {
|
|
694
|
+
...extractRelevantRootBlockProperties(block),
|
|
695
|
+
...block.properties,
|
|
652
696
|
"builder-id": block.id,
|
|
653
697
|
style: block.style ? getStyleAttribute(block.style) : void 0,
|
|
654
|
-
class: [block.id, "builder-block", block.class,
|
|
655
|
-
}
|
|
698
|
+
class: [block.id, "builder-block", block.class, block.properties?.class].filter(Boolean).join(" ")
|
|
699
|
+
};
|
|
656
700
|
if (TARGET === "reactNative") {
|
|
657
701
|
properties.style = getReactNativeBlockStyles({
|
|
658
702
|
block,
|
|
@@ -677,193 +721,51 @@ function getStyleAttribute(style) {
|
|
|
677
721
|
}
|
|
678
722
|
}
|
|
679
723
|
|
|
680
|
-
// src/components/block/block.
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
}
|
|
715
|
-
return target;
|
|
716
|
-
};
|
|
717
|
-
var EMPTY_HTML_ELEMENTS = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
|
|
718
|
-
var isEmptyHtmlElement = (tagName) => {
|
|
719
|
-
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
|
|
720
|
-
};
|
|
721
|
-
var getComponent = ({
|
|
722
|
-
block,
|
|
723
|
-
context,
|
|
724
|
-
registeredComponents
|
|
725
|
-
}) => {
|
|
726
|
-
var _a;
|
|
727
|
-
const componentName = (_a = getProcessedBlock({
|
|
728
|
-
block,
|
|
729
|
-
localState: context.localState,
|
|
730
|
-
rootState: context.rootState,
|
|
731
|
-
rootSetState: context.rootSetState,
|
|
732
|
-
context: context.context,
|
|
733
|
-
shouldEvaluateBindings: false
|
|
734
|
-
}).component) == null ? void 0 : _a.name;
|
|
735
|
-
if (!componentName) {
|
|
736
|
-
return null;
|
|
737
|
-
}
|
|
738
|
-
const ref = registeredComponents[componentName];
|
|
739
|
-
if (!ref) {
|
|
740
|
-
console.warn(`
|
|
741
|
-
Could not find a registered component named "${componentName}".
|
|
742
|
-
If you registered it, is the file that registered it imported by the file that needs to render it?`);
|
|
743
|
-
return void 0;
|
|
744
|
-
} else {
|
|
745
|
-
return ref;
|
|
746
|
-
}
|
|
747
|
-
};
|
|
748
|
-
var getRepeatItemData = ({
|
|
749
|
-
block,
|
|
750
|
-
context
|
|
751
|
-
}) => {
|
|
752
|
-
const _a = block, {
|
|
753
|
-
repeat
|
|
754
|
-
} = _a, blockWithoutRepeat = __objRest(_a, ["repeat"]);
|
|
755
|
-
if (!(repeat == null ? void 0 : repeat.collection)) {
|
|
756
|
-
return void 0;
|
|
757
|
-
}
|
|
758
|
-
const itemsArray = evaluate({
|
|
759
|
-
code: repeat.collection,
|
|
760
|
-
localState: context.localState,
|
|
761
|
-
rootState: context.rootState,
|
|
762
|
-
rootSetState: context.rootSetState,
|
|
763
|
-
context: context.context
|
|
764
|
-
});
|
|
765
|
-
if (!Array.isArray(itemsArray)) {
|
|
766
|
-
return void 0;
|
|
767
|
-
}
|
|
768
|
-
const collectionName = repeat.collection.split(".").pop();
|
|
769
|
-
const itemNameToUse = repeat.itemName || (collectionName ? collectionName + "Item" : "item");
|
|
770
|
-
const repeatArray = itemsArray.map((item, index) => ({
|
|
771
|
-
context: __spreadProps5(__spreadValues6({}, context), {
|
|
772
|
-
localState: __spreadProps5(__spreadValues6({}, context.localState), {
|
|
773
|
-
$index: index,
|
|
774
|
-
$item: item,
|
|
775
|
-
[itemNameToUse]: item,
|
|
776
|
-
[`$${itemNameToUse}Index`]: index
|
|
777
|
-
})
|
|
778
|
-
}),
|
|
779
|
-
block: blockWithoutRepeat
|
|
780
|
-
}));
|
|
781
|
-
return repeatArray;
|
|
782
|
-
};
|
|
783
|
-
|
|
784
|
-
// src/components/block/components/repeated-block.jsx
|
|
785
|
-
import { createSignal as createSignal2 } from "solid-js";
|
|
786
|
-
|
|
787
|
-
// src/context/builder.context.js
|
|
788
|
-
import { createContext } from "solid-js";
|
|
789
|
-
var stdin_default = createContext({
|
|
790
|
-
content: null,
|
|
791
|
-
context: {},
|
|
792
|
-
localState: void 0,
|
|
793
|
-
rootSetState() {
|
|
794
|
-
},
|
|
795
|
-
rootState: {},
|
|
796
|
-
apiKey: null,
|
|
797
|
-
apiVersion: void 0,
|
|
798
|
-
componentInfos: {},
|
|
799
|
-
inheritedStyles: {}
|
|
800
|
-
});
|
|
801
|
-
|
|
802
|
-
// src/components/block/components/repeated-block.jsx
|
|
803
|
-
function RepeatedBlock(props) {
|
|
804
|
-
const [store, setStore] = createSignal2(props.repeatContext);
|
|
805
|
-
return <stdin_default.Provider value={store()}><Block_default
|
|
806
|
-
block={props.block}
|
|
807
|
-
context={store()}
|
|
808
|
-
registeredComponents={props.registeredComponents}
|
|
809
|
-
/></stdin_default.Provider>;
|
|
810
|
-
}
|
|
811
|
-
var Repeated_block_default = RepeatedBlock;
|
|
812
|
-
|
|
813
|
-
// src/components/block/components/component-ref/component-ref.jsx
|
|
814
|
-
import { Show as Show3, For, createSignal as createSignal3 } from "solid-js";
|
|
815
|
-
import { Dynamic as Dynamic2 } from "solid-js/web";
|
|
816
|
-
|
|
817
|
-
// src/components/block/components/interactive-element.jsx
|
|
818
|
-
import { Dynamic } from "solid-js/web";
|
|
819
|
-
|
|
820
|
-
// src/functions/event-handler-name.js
|
|
821
|
-
function capitalizeFirstLetter(string) {
|
|
822
|
-
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
724
|
+
// src/components/block/components/block-wrapper.tsx
|
|
725
|
+
function BlockWrapper(props) {
|
|
726
|
+
return <Show3
|
|
727
|
+
fallback={<Dynamic
|
|
728
|
+
{...getBlockProperties({
|
|
729
|
+
block: props.block,
|
|
730
|
+
context: props.context
|
|
731
|
+
})}
|
|
732
|
+
{...getBlockActions({
|
|
733
|
+
block: props.block,
|
|
734
|
+
rootState: props.context.rootState,
|
|
735
|
+
rootSetState: props.context.rootSetState,
|
|
736
|
+
localState: props.context.localState,
|
|
737
|
+
context: props.context.context,
|
|
738
|
+
stripPrefix: true
|
|
739
|
+
})}
|
|
740
|
+
component={props.Wrapper}
|
|
741
|
+
/>}
|
|
742
|
+
when={props.hasChildren}
|
|
743
|
+
><Dynamic
|
|
744
|
+
{...getBlockProperties({
|
|
745
|
+
block: props.block,
|
|
746
|
+
context: props.context
|
|
747
|
+
})}
|
|
748
|
+
{...getBlockActions({
|
|
749
|
+
block: props.block,
|
|
750
|
+
rootState: props.context.rootState,
|
|
751
|
+
rootSetState: props.context.rootSetState,
|
|
752
|
+
localState: props.context.localState,
|
|
753
|
+
context: props.context.context,
|
|
754
|
+
stripPrefix: true
|
|
755
|
+
})}
|
|
756
|
+
component={props.Wrapper}
|
|
757
|
+
>{props.children}</Dynamic></Show3>;
|
|
823
758
|
}
|
|
824
|
-
var
|
|
825
|
-
|
|
826
|
-
// src/functions/get-block-actions-handler.js
|
|
827
|
-
var createEventHandler = (value, options) => (event) => evaluate({
|
|
828
|
-
code: value,
|
|
829
|
-
context: options.context,
|
|
830
|
-
localState: options.localState,
|
|
831
|
-
rootState: options.rootState,
|
|
832
|
-
rootSetState: options.rootSetState,
|
|
833
|
-
event,
|
|
834
|
-
isExpression: false
|
|
835
|
-
});
|
|
759
|
+
var Block_wrapper_default = BlockWrapper;
|
|
836
760
|
|
|
837
|
-
// src/
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
const obj = {};
|
|
841
|
-
const optionActions = (_a = options.block.actions) != null ? _a : {};
|
|
842
|
-
for (const key in optionActions) {
|
|
843
|
-
if (!optionActions.hasOwnProperty(key)) {
|
|
844
|
-
continue;
|
|
845
|
-
}
|
|
846
|
-
const value = optionActions[key];
|
|
847
|
-
let eventHandlerName = getEventHandlerName(key);
|
|
848
|
-
if (options.stripPrefix) {
|
|
849
|
-
switch (TARGET) {
|
|
850
|
-
case "vue2":
|
|
851
|
-
case "vue3":
|
|
852
|
-
eventHandlerName = eventHandlerName.replace("v-on:", "");
|
|
853
|
-
break;
|
|
854
|
-
case "svelte":
|
|
855
|
-
eventHandlerName = eventHandlerName.replace("on:", "");
|
|
856
|
-
break;
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
obj[eventHandlerName] = createEventHandler(value, options);
|
|
860
|
-
}
|
|
861
|
-
return obj;
|
|
862
|
-
}
|
|
761
|
+
// src/components/block/components/component-ref/component-ref.tsx
|
|
762
|
+
import { Show as Show4, For, createSignal as createSignal2 } from "solid-js";
|
|
763
|
+
import { Dynamic as Dynamic3 } from "solid-js/web";
|
|
863
764
|
|
|
864
|
-
// src/components/block/components/interactive-element.
|
|
765
|
+
// src/components/block/components/interactive-element.tsx
|
|
766
|
+
import { Dynamic as Dynamic2 } from "solid-js/web";
|
|
865
767
|
function InteractiveElement(props) {
|
|
866
|
-
return <
|
|
768
|
+
return <Dynamic2
|
|
867
769
|
{...props.wrapperProps}
|
|
868
770
|
attributes={{
|
|
869
771
|
...getBlockProperties({
|
|
@@ -879,32 +781,11 @@ function InteractiveElement(props) {
|
|
|
879
781
|
})
|
|
880
782
|
}}
|
|
881
783
|
component={props.Wrapper}
|
|
882
|
-
>{props.children}</
|
|
784
|
+
>{props.children}</Dynamic2>;
|
|
883
785
|
}
|
|
884
786
|
var interactive_element_default = InteractiveElement;
|
|
885
787
|
|
|
886
|
-
// src/components/block/components/component-ref/component-ref.helpers.
|
|
887
|
-
var __defProp7 = Object.defineProperty;
|
|
888
|
-
var __getOwnPropSymbols7 = Object.getOwnPropertySymbols;
|
|
889
|
-
var __hasOwnProp7 = Object.prototype.hasOwnProperty;
|
|
890
|
-
var __propIsEnum7 = Object.prototype.propertyIsEnumerable;
|
|
891
|
-
var __defNormalProp7 = (obj, key, value) => key in obj ? __defProp7(obj, key, {
|
|
892
|
-
enumerable: true,
|
|
893
|
-
configurable: true,
|
|
894
|
-
writable: true,
|
|
895
|
-
value
|
|
896
|
-
}) : obj[key] = value;
|
|
897
|
-
var __spreadValues7 = (a, b) => {
|
|
898
|
-
for (var prop in b || (b = {}))
|
|
899
|
-
if (__hasOwnProp7.call(b, prop))
|
|
900
|
-
__defNormalProp7(a, prop, b[prop]);
|
|
901
|
-
if (__getOwnPropSymbols7)
|
|
902
|
-
for (var prop of __getOwnPropSymbols7(b)) {
|
|
903
|
-
if (__propIsEnum7.call(b, prop))
|
|
904
|
-
__defNormalProp7(a, prop, b[prop]);
|
|
905
|
-
}
|
|
906
|
-
return a;
|
|
907
|
-
};
|
|
788
|
+
// src/components/block/components/component-ref/component-ref.helpers.ts
|
|
908
789
|
var getWrapperProps = ({
|
|
909
790
|
componentOptions,
|
|
910
791
|
builderBlock,
|
|
@@ -920,20 +801,27 @@ var getWrapperProps = ({
|
|
|
920
801
|
context,
|
|
921
802
|
wrapperProps: componentOptions
|
|
922
803
|
};
|
|
923
|
-
return isInteractive ? interactiveElementProps :
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
804
|
+
return isInteractive ? interactiveElementProps : {
|
|
805
|
+
...componentOptions,
|
|
806
|
+
/**
|
|
807
|
+
* If `noWrap` is set to `true`, then the block's props/attributes are provided to the
|
|
808
|
+
* component itself directly. Otherwise, they are provided to the wrapper element.
|
|
809
|
+
*/
|
|
810
|
+
...includeBlockProps ? {
|
|
811
|
+
attributes: getBlockProperties({
|
|
812
|
+
block: builderBlock,
|
|
813
|
+
context: contextValue
|
|
814
|
+
})
|
|
815
|
+
} : {}
|
|
816
|
+
};
|
|
929
817
|
};
|
|
930
818
|
|
|
931
|
-
// src/components/block/components/component-ref/component-ref.
|
|
819
|
+
// src/components/block/components/component-ref/component-ref.tsx
|
|
932
820
|
function ComponentRef(props) {
|
|
933
|
-
const [Wrapper, setWrapper] =
|
|
821
|
+
const [Wrapper, setWrapper] = createSignal2(
|
|
934
822
|
props.isInteractive ? interactive_element_default : props.componentRef
|
|
935
823
|
);
|
|
936
|
-
return <
|
|
824
|
+
return <Show4 when={props.componentRef}><Dynamic3
|
|
937
825
|
{...getWrapperProps({
|
|
938
826
|
componentOptions: props.componentOptions,
|
|
939
827
|
builderBlock: props.builderBlock,
|
|
@@ -962,50 +850,23 @@ function ComponentRef(props) {
|
|
|
962
850
|
context={props.context}
|
|
963
851
|
/>;
|
|
964
852
|
}}</For>
|
|
965
|
-
</
|
|
853
|
+
</Dynamic3></Show4>;
|
|
966
854
|
}
|
|
967
855
|
var Component_ref_default = ComponentRef;
|
|
968
856
|
|
|
969
|
-
// src/components/block/components/block
|
|
970
|
-
import {
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
return <
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
})}
|
|
979
|
-
{...getBlockActions({
|
|
980
|
-
block: props.block,
|
|
981
|
-
rootState: props.context.rootState,
|
|
982
|
-
rootSetState: props.context.rootSetState,
|
|
983
|
-
localState: props.context.localState,
|
|
984
|
-
context: props.context.context,
|
|
985
|
-
stripPrefix: true
|
|
986
|
-
})}
|
|
987
|
-
component={props.Wrapper}
|
|
988
|
-
/>}
|
|
989
|
-
when={props.hasChildren}
|
|
990
|
-
><Dynamic3
|
|
991
|
-
{...getBlockProperties({
|
|
992
|
-
block: props.block,
|
|
993
|
-
context: props.context
|
|
994
|
-
})}
|
|
995
|
-
{...getBlockActions({
|
|
996
|
-
block: props.block,
|
|
997
|
-
rootState: props.context.rootState,
|
|
998
|
-
rootSetState: props.context.rootSetState,
|
|
999
|
-
localState: props.context.localState,
|
|
1000
|
-
context: props.context.context,
|
|
1001
|
-
stripPrefix: true
|
|
1002
|
-
})}
|
|
1003
|
-
component={props.Wrapper}
|
|
1004
|
-
>{props.children}</Dynamic3></Show4>;
|
|
857
|
+
// src/components/block/components/repeated-block.tsx
|
|
858
|
+
import { createSignal as createSignal3 } from "solid-js";
|
|
859
|
+
function RepeatedBlock(props) {
|
|
860
|
+
const [store, setStore] = createSignal3(props.repeatContext);
|
|
861
|
+
return <builder_context_default.Provider value={store()}><Block_default
|
|
862
|
+
block={props.block}
|
|
863
|
+
context={store()}
|
|
864
|
+
registeredComponents={props.registeredComponents}
|
|
865
|
+
/></builder_context_default.Provider>;
|
|
1005
866
|
}
|
|
1006
|
-
var
|
|
867
|
+
var Repeated_block_default = RepeatedBlock;
|
|
1007
868
|
|
|
1008
|
-
// src/components/block/block.
|
|
869
|
+
// src/components/block/block.tsx
|
|
1009
870
|
function Block(props) {
|
|
1010
871
|
const [childrenContext, setChildrenContext] = createSignal4(props.context);
|
|
1011
872
|
function blockComponent() {
|
|
@@ -1066,7 +927,16 @@ function Block(props) {
|
|
|
1066
927
|
};
|
|
1067
928
|
}
|
|
1068
929
|
return <Show5 when={canShowBlock()}><Show5
|
|
1069
|
-
fallback={<Component_ref_default
|
|
930
|
+
fallback={<Component_ref_default
|
|
931
|
+
componentRef={componentRefProps().componentRef}
|
|
932
|
+
componentOptions={componentRefProps().componentOptions}
|
|
933
|
+
blockChildren={componentRefProps().blockChildren}
|
|
934
|
+
context={componentRefProps().context}
|
|
935
|
+
registeredComponents={componentRefProps().registeredComponents}
|
|
936
|
+
builderBlock={componentRefProps().builderBlock}
|
|
937
|
+
includeBlockProps={componentRefProps().includeBlockProps}
|
|
938
|
+
isInteractive={componentRefProps().isInteractive}
|
|
939
|
+
/>}
|
|
1070
940
|
when={!blockComponent()?.noWrap}
|
|
1071
941
|
>
|
|
1072
942
|
<Show5 when={isEmptyHtmlElement(Tag())}><Block_wrapper_default
|
|
@@ -1090,7 +960,16 @@ function Block(props) {
|
|
|
1090
960
|
context={props.context}
|
|
1091
961
|
hasChildren={true}
|
|
1092
962
|
>
|
|
1093
|
-
<Component_ref_default
|
|
963
|
+
<Component_ref_default
|
|
964
|
+
componentRef={componentRefProps().componentRef}
|
|
965
|
+
componentOptions={componentRefProps().componentOptions}
|
|
966
|
+
blockChildren={componentRefProps().blockChildren}
|
|
967
|
+
context={componentRefProps().context}
|
|
968
|
+
registeredComponents={componentRefProps().registeredComponents}
|
|
969
|
+
builderBlock={componentRefProps().builderBlock}
|
|
970
|
+
includeBlockProps={componentRefProps().includeBlockProps}
|
|
971
|
+
isInteractive={componentRefProps().isInteractive}
|
|
972
|
+
/>
|
|
1094
973
|
<For2 each={childrenWithoutParentComponent()}>{(child, _index) => {
|
|
1095
974
|
const index = _index();
|
|
1096
975
|
return <Block
|
|
@@ -1113,8 +992,7 @@ function Block(props) {
|
|
|
1113
992
|
}
|
|
1114
993
|
var Block_default = Block;
|
|
1115
994
|
|
|
1116
|
-
// src/components/blocks/blocks-wrapper.
|
|
1117
|
-
import { createSignal as createSignal5 } from "solid-js";
|
|
995
|
+
// src/components/blocks/blocks-wrapper.tsx
|
|
1118
996
|
import { css as css2 } from "solid-styled-components";
|
|
1119
997
|
function BlocksWrapper(props) {
|
|
1120
998
|
function className() {
|
|
@@ -1165,14 +1043,10 @@ function BlocksWrapper(props) {
|
|
|
1165
1043
|
}
|
|
1166
1044
|
var Blocks_wrapper_default = BlocksWrapper;
|
|
1167
1045
|
|
|
1168
|
-
// src/
|
|
1169
|
-
import { createContext as createContext2 } from "solid-js";
|
|
1170
|
-
var stdin_default2 = createContext2({ registeredComponents: {} });
|
|
1171
|
-
|
|
1172
|
-
// src/components/blocks/blocks.jsx
|
|
1046
|
+
// src/components/blocks/blocks.tsx
|
|
1173
1047
|
function Blocks(props) {
|
|
1174
|
-
const builderContext = useContext(
|
|
1175
|
-
const componentsContext = useContext(
|
|
1048
|
+
const builderContext = useContext(builder_context_default);
|
|
1049
|
+
const componentsContext = useContext(components_context_default);
|
|
1176
1050
|
return <Blocks_wrapper_default
|
|
1177
1051
|
blocks={props.blocks}
|
|
1178
1052
|
parent={props.parent}
|
|
@@ -1200,14 +1074,14 @@ function Blocks(props) {
|
|
|
1200
1074
|
}
|
|
1201
1075
|
var Blocks_default = Blocks;
|
|
1202
1076
|
|
|
1203
|
-
// src/blocks/columns/columns.
|
|
1077
|
+
// src/blocks/columns/columns.tsx
|
|
1204
1078
|
function Columns(props) {
|
|
1205
|
-
const [gutterSize, setGutterSize] =
|
|
1079
|
+
const [gutterSize, setGutterSize] = createSignal5(
|
|
1206
1080
|
typeof props.space === "number" ? props.space || 0 : 20
|
|
1207
1081
|
);
|
|
1208
|
-
const [cols, setCols] =
|
|
1209
|
-
const [stackAt, setStackAt] =
|
|
1210
|
-
const [flexDir, setFlexDir] =
|
|
1082
|
+
const [cols, setCols] = createSignal5(props.columns || []);
|
|
1083
|
+
const [stackAt, setStackAt] = createSignal5(props.stackColumnsAt || "tablet");
|
|
1084
|
+
const [flexDir, setFlexDir] = createSignal5(
|
|
1211
1085
|
props.stackColumnsAt === "never" ? "row" : props.reverseColumnsWhenStacked ? "column-reverse" : "column"
|
|
1212
1086
|
);
|
|
1213
1087
|
function getWidth(index) {
|
|
@@ -1217,10 +1091,16 @@ function Columns(props) {
|
|
|
1217
1091
|
const subtractWidth = gutterSize() * (cols().length - 1) / cols().length;
|
|
1218
1092
|
return `calc(${getWidth(index)}% - ${subtractWidth}px)`;
|
|
1219
1093
|
}
|
|
1220
|
-
function getTabletStyle({
|
|
1094
|
+
function getTabletStyle({
|
|
1095
|
+
stackedStyle,
|
|
1096
|
+
desktopStyle
|
|
1097
|
+
}) {
|
|
1221
1098
|
return stackAt() === "tablet" ? stackedStyle : desktopStyle;
|
|
1222
1099
|
}
|
|
1223
|
-
function getMobileStyle({
|
|
1100
|
+
function getMobileStyle({
|
|
1101
|
+
stackedStyle,
|
|
1102
|
+
desktopStyle
|
|
1103
|
+
}) {
|
|
1224
1104
|
return stackAt() === "never" ? desktopStyle : stackedStyle;
|
|
1225
1105
|
}
|
|
1226
1106
|
function columnsCssVars() {
|
|
@@ -1328,17 +1208,17 @@ function Columns(props) {
|
|
|
1328
1208
|
}
|
|
1329
1209
|
var columns_default = Columns;
|
|
1330
1210
|
|
|
1331
|
-
// src/blocks/fragment/fragment.
|
|
1211
|
+
// src/blocks/fragment/fragment.tsx
|
|
1332
1212
|
function FragmentComponent(props) {
|
|
1333
1213
|
return <span>{props.children}</span>;
|
|
1334
1214
|
}
|
|
1335
1215
|
var fragment_default = FragmentComponent;
|
|
1336
1216
|
|
|
1337
|
-
// src/blocks/image/image.
|
|
1338
|
-
import { Show as Show8
|
|
1217
|
+
// src/blocks/image/image.tsx
|
|
1218
|
+
import { Show as Show8 } from "solid-js";
|
|
1339
1219
|
import { css as css4 } from "solid-styled-components";
|
|
1340
1220
|
|
|
1341
|
-
// src/blocks/image/image.helpers.
|
|
1221
|
+
// src/blocks/image/image.helpers.ts
|
|
1342
1222
|
function removeProtocol(path) {
|
|
1343
1223
|
return path.replace(/http(s)?:/, "");
|
|
1344
1224
|
}
|
|
@@ -1351,7 +1231,7 @@ function updateQueryParam(uri = "", key, value) {
|
|
|
1351
1231
|
return uri + separator + key + "=" + encodeURIComponent(value);
|
|
1352
1232
|
}
|
|
1353
1233
|
function getShopifyImageUrl(src, size) {
|
|
1354
|
-
if (!src || !
|
|
1234
|
+
if (!src || !src?.match(/cdn\.shopify\.com/) || !size) {
|
|
1355
1235
|
return src;
|
|
1356
1236
|
}
|
|
1357
1237
|
if (size === "master") {
|
|
@@ -1385,7 +1265,7 @@ function getSrcSet(url) {
|
|
|
1385
1265
|
return url;
|
|
1386
1266
|
}
|
|
1387
1267
|
|
|
1388
|
-
// src/blocks/image/image.
|
|
1268
|
+
// src/blocks/image/image.tsx
|
|
1389
1269
|
function Image(props) {
|
|
1390
1270
|
function srcSetToUse() {
|
|
1391
1271
|
const imageToUse = props.image || props.src;
|
|
@@ -1473,7 +1353,7 @@ function Image(props) {
|
|
|
1473
1353
|
}
|
|
1474
1354
|
var image_default = Image;
|
|
1475
1355
|
|
|
1476
|
-
// src/blocks/section/section.
|
|
1356
|
+
// src/blocks/section/section.tsx
|
|
1477
1357
|
function SectionComponent(props) {
|
|
1478
1358
|
return <section
|
|
1479
1359
|
{...{}}
|
|
@@ -1494,190 +1374,212 @@ function SectionComponent(props) {
|
|
|
1494
1374
|
}
|
|
1495
1375
|
var section_default = SectionComponent;
|
|
1496
1376
|
|
|
1497
|
-
// src/blocks/symbol/symbol.
|
|
1498
|
-
import { onMount as onMount4, on as on3, createEffect as createEffect3, createSignal as
|
|
1377
|
+
// src/blocks/symbol/symbol.tsx
|
|
1378
|
+
import { onMount as onMount4, on as on3, createEffect as createEffect3, createSignal as createSignal13 } from "solid-js";
|
|
1499
1379
|
|
|
1500
|
-
// src/components/content-variants/content-variants.
|
|
1501
|
-
import { Show as Show11, For as For5, onMount as onMount3, createSignal as
|
|
1380
|
+
// src/components/content-variants/content-variants.tsx
|
|
1381
|
+
import { Show as Show11, For as For5, onMount as onMount3, createSignal as createSignal12 } from "solid-js";
|
|
1502
1382
|
|
|
1503
|
-
// src/
|
|
1504
|
-
var
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
var
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
__defNormalProp8(a, prop, b[prop]);
|
|
1383
|
+
// src/helpers/url.ts
|
|
1384
|
+
var getTopLevelDomain = (host) => {
|
|
1385
|
+
if (host === "localhost" || host === "127.0.0.1") {
|
|
1386
|
+
return host;
|
|
1387
|
+
}
|
|
1388
|
+
const parts = host.split(".");
|
|
1389
|
+
if (parts.length > 2) {
|
|
1390
|
+
return parts.slice(1).join(".");
|
|
1391
|
+
}
|
|
1392
|
+
return host;
|
|
1393
|
+
};
|
|
1394
|
+
|
|
1395
|
+
// src/helpers/cookie.ts
|
|
1396
|
+
var getCookieSync = ({
|
|
1397
|
+
name,
|
|
1398
|
+
canTrack
|
|
1399
|
+
}) => {
|
|
1400
|
+
try {
|
|
1401
|
+
if (!canTrack) {
|
|
1402
|
+
return void 0;
|
|
1524
1403
|
}
|
|
1525
|
-
|
|
1404
|
+
return document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))?.split("=")[1];
|
|
1405
|
+
} catch (err) {
|
|
1406
|
+
logger.warn("[COOKIE] GET error: ", err?.message || err);
|
|
1407
|
+
return void 0;
|
|
1408
|
+
}
|
|
1526
1409
|
};
|
|
1527
|
-
var
|
|
1528
|
-
var
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
content
|
|
1410
|
+
var getCookie = async (args) => getCookieSync(args);
|
|
1411
|
+
var stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).filter(checkIsDefined).join("; ");
|
|
1412
|
+
var SECURE_CONFIG = [["secure", ""], ["SameSite", "None"]];
|
|
1413
|
+
var createCookieString = ({
|
|
1414
|
+
name,
|
|
1415
|
+
value,
|
|
1416
|
+
expires
|
|
1535
1417
|
}) => {
|
|
1536
|
-
const
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
return false;
|
|
1543
|
-
if (TARGET === "vue2" || TARGET === "vue3")
|
|
1544
|
-
return true;
|
|
1545
|
-
if (isBrowser())
|
|
1546
|
-
return false;
|
|
1547
|
-
return true;
|
|
1418
|
+
const secure = isBrowser() ? location.protocol === "https:" : true;
|
|
1419
|
+
const secureObj = secure ? SECURE_CONFIG : [[]];
|
|
1420
|
+
const expiresObj = expires ? [["expires", expires.toUTCString()]] : [[]];
|
|
1421
|
+
const cookieValue = [[name, value], ...expiresObj, ["path", "/"], ["domain", getTopLevelDomain(window.location.hostname)], ...secureObj];
|
|
1422
|
+
const cookie = stringifyCookie(cookieValue);
|
|
1423
|
+
return cookie;
|
|
1548
1424
|
};
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
}
|
|
1559
|
-
document.cookie = name + "=" + (value || "") + expires + "; path=/; Secure; SameSite=None";
|
|
1560
|
-
}
|
|
1561
|
-
function getCookie2(name) {
|
|
1562
|
-
const nameEQ = name + "=";
|
|
1563
|
-
const ca = document.cookie.split(";");
|
|
1564
|
-
for (let i = 0; i < ca.length; i++) {
|
|
1565
|
-
let c = ca[i];
|
|
1566
|
-
while (c.charAt(0) === " ")
|
|
1567
|
-
c = c.substring(1, c.length);
|
|
1568
|
-
if (c.indexOf(nameEQ) === 0)
|
|
1569
|
-
return c.substring(nameEQ.length, c.length);
|
|
1570
|
-
}
|
|
1571
|
-
return null;
|
|
1572
|
-
}
|
|
1573
|
-
const cookieName = `builder.tests.${contentId}`;
|
|
1574
|
-
const variantInCookie = getCookie2(cookieName);
|
|
1575
|
-
const availableIDs = variants.map((vr) => vr.id).concat(contentId);
|
|
1576
|
-
if (variantInCookie && availableIDs.includes(variantInCookie)) {
|
|
1577
|
-
return variantInCookie;
|
|
1425
|
+
var setCookie = async ({
|
|
1426
|
+
name,
|
|
1427
|
+
value,
|
|
1428
|
+
expires,
|
|
1429
|
+
canTrack
|
|
1430
|
+
}) => {
|
|
1431
|
+
try {
|
|
1432
|
+
if (!canTrack) {
|
|
1433
|
+
return;
|
|
1578
1434
|
}
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1435
|
+
const cookie = createCookieString({
|
|
1436
|
+
name,
|
|
1437
|
+
value,
|
|
1438
|
+
expires
|
|
1439
|
+
});
|
|
1440
|
+
document.cookie = cookie;
|
|
1441
|
+
} catch (err) {
|
|
1442
|
+
logger.warn("[COOKIE] SET error: ", err?.message || err);
|
|
1443
|
+
}
|
|
1444
|
+
};
|
|
1445
|
+
|
|
1446
|
+
// src/helpers/ab-tests.ts
|
|
1447
|
+
var BUILDER_STORE_PREFIX = "builder.tests";
|
|
1448
|
+
var getContentTestKey = (id) => `${BUILDER_STORE_PREFIX}.${id}`;
|
|
1449
|
+
var getContentVariationCookie = ({
|
|
1450
|
+
contentId
|
|
1451
|
+
}) => getCookie({
|
|
1452
|
+
name: getContentTestKey(contentId),
|
|
1453
|
+
canTrack: true
|
|
1454
|
+
});
|
|
1455
|
+
var getContentVariationCookieSync = ({
|
|
1456
|
+
contentId
|
|
1457
|
+
}) => getCookieSync({
|
|
1458
|
+
name: getContentTestKey(contentId),
|
|
1459
|
+
canTrack: true
|
|
1460
|
+
});
|
|
1461
|
+
var setContentVariationCookie = ({
|
|
1462
|
+
contentId,
|
|
1463
|
+
value
|
|
1464
|
+
}) => setCookie({
|
|
1465
|
+
name: getContentTestKey(contentId),
|
|
1466
|
+
value,
|
|
1467
|
+
canTrack: true
|
|
1468
|
+
});
|
|
1469
|
+
var checkIsBuilderContentWithVariations = (item) => checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
|
|
1470
|
+
var getRandomVariationId = ({
|
|
1471
|
+
id,
|
|
1472
|
+
variations
|
|
1473
|
+
}) => {
|
|
1474
|
+
let n = 0;
|
|
1475
|
+
const random = Math.random();
|
|
1476
|
+
for (const id2 in variations) {
|
|
1477
|
+
const testRatio = variations[id2]?.testRatio;
|
|
1478
|
+
n += testRatio;
|
|
1479
|
+
if (random < n) {
|
|
1480
|
+
return id2;
|
|
1589
1481
|
}
|
|
1590
|
-
setCookie2(cookieName, contentId);
|
|
1591
|
-
return contentId;
|
|
1592
1482
|
}
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1483
|
+
return id;
|
|
1484
|
+
};
|
|
1485
|
+
var getAndSetVariantId = (args) => {
|
|
1486
|
+
const randomVariationId = getRandomVariationId(args);
|
|
1487
|
+
setContentVariationCookie({
|
|
1488
|
+
contentId: args.id,
|
|
1489
|
+
value: randomVariationId
|
|
1490
|
+
}).catch((err) => {
|
|
1491
|
+
logger.error("could not store A/B test variation: ", err);
|
|
1492
|
+
});
|
|
1493
|
+
return randomVariationId;
|
|
1494
|
+
};
|
|
1495
|
+
var getTestFields = ({
|
|
1496
|
+
item,
|
|
1497
|
+
testGroupId
|
|
1498
|
+
}) => {
|
|
1499
|
+
const variationValue = item.variations[testGroupId];
|
|
1500
|
+
if (testGroupId === item.id || // handle edge-case where `testGroupId` points to non-existing variation
|
|
1501
|
+
!variationValue) {
|
|
1502
|
+
return {
|
|
1503
|
+
testVariationId: item.id,
|
|
1504
|
+
testVariationName: "Default"
|
|
1505
|
+
};
|
|
1599
1506
|
} else {
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
}).join("");
|
|
1606
|
-
styleEl.innerHTML = newStyleStr;
|
|
1507
|
+
return {
|
|
1508
|
+
data: variationValue.data,
|
|
1509
|
+
testVariationId: variationValue.id,
|
|
1510
|
+
testVariationName: variationValue.name || (variationValue.id === item.id ? "Default" : "")
|
|
1511
|
+
};
|
|
1607
1512
|
}
|
|
1608
|
-
}
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1513
|
+
};
|
|
1514
|
+
var handleABTestingSync = ({
|
|
1515
|
+
item,
|
|
1516
|
+
canTrack
|
|
1517
|
+
}) => {
|
|
1518
|
+
if (TARGET === "reactNative")
|
|
1519
|
+
return item;
|
|
1520
|
+
if (!canTrack) {
|
|
1521
|
+
return item;
|
|
1613
1522
|
}
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
const ca = document.cookie.split(";");
|
|
1617
|
-
for (let i = 0; i < ca.length; i++) {
|
|
1618
|
-
let c = ca[i];
|
|
1619
|
-
while (c.charAt(0) === " ")
|
|
1620
|
-
c = c.substring(1, c.length);
|
|
1621
|
-
if (c.indexOf(nameEQ) === 0)
|
|
1622
|
-
return c.substring(nameEQ.length, c.length);
|
|
1623
|
-
}
|
|
1624
|
-
return null;
|
|
1523
|
+
if (!item) {
|
|
1524
|
+
return void 0;
|
|
1625
1525
|
}
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
const parentDiv = (_a = document.currentScript) == null ? void 0 : _a.parentElement;
|
|
1629
|
-
const variantIsDefaultContent = variantContentId === defaultContentId;
|
|
1630
|
-
if (variantId === variantContentId) {
|
|
1631
|
-
if (variantIsDefaultContent) {
|
|
1632
|
-
return;
|
|
1633
|
-
}
|
|
1634
|
-
parentDiv == null ? void 0 : parentDiv.removeAttribute("hidden");
|
|
1635
|
-
parentDiv == null ? void 0 : parentDiv.removeAttribute("aria-hidden");
|
|
1636
|
-
} else {
|
|
1637
|
-
if (variantIsDefaultContent) {
|
|
1638
|
-
if (isHydrationTarget2) {
|
|
1639
|
-
parentDiv == null ? void 0 : parentDiv.remove();
|
|
1640
|
-
} else {
|
|
1641
|
-
parentDiv == null ? void 0 : parentDiv.setAttribute("hidden", "true");
|
|
1642
|
-
parentDiv == null ? void 0 : parentDiv.setAttribute("aria-hidden", "true");
|
|
1643
|
-
}
|
|
1644
|
-
}
|
|
1645
|
-
return;
|
|
1526
|
+
if (!checkIsBuilderContentWithVariations(item)) {
|
|
1527
|
+
return item;
|
|
1646
1528
|
}
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
};
|
|
1661
|
-
var getVariantsScriptString = (variants, contentId) => {
|
|
1662
|
-
return `
|
|
1663
|
-
window.${AB_TEST_FN_NAME}("${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget})`;
|
|
1529
|
+
const testGroupId = getContentVariationCookieSync({
|
|
1530
|
+
contentId: item.id
|
|
1531
|
+
}) || getAndSetVariantId({
|
|
1532
|
+
variations: item.variations,
|
|
1533
|
+
id: item.id
|
|
1534
|
+
});
|
|
1535
|
+
const variationValue = getTestFields({
|
|
1536
|
+
item,
|
|
1537
|
+
testGroupId
|
|
1538
|
+
});
|
|
1539
|
+
return {
|
|
1540
|
+
...item,
|
|
1541
|
+
...variationValue
|
|
1542
|
+
};
|
|
1664
1543
|
};
|
|
1665
|
-
var
|
|
1666
|
-
|
|
1667
|
-
|
|
1544
|
+
var handleABTesting = async ({
|
|
1545
|
+
item,
|
|
1546
|
+
canTrack
|
|
1668
1547
|
}) => {
|
|
1669
|
-
|
|
1670
|
-
|
|
1548
|
+
if (!canTrack) {
|
|
1549
|
+
return item;
|
|
1550
|
+
}
|
|
1551
|
+
if (!checkIsBuilderContentWithVariations(item)) {
|
|
1552
|
+
return item;
|
|
1553
|
+
}
|
|
1554
|
+
const cookieValue = await getContentVariationCookie({
|
|
1555
|
+
contentId: item.id
|
|
1556
|
+
});
|
|
1557
|
+
const testGroupId = cookieValue || getAndSetVariantId({
|
|
1558
|
+
variations: item.variations,
|
|
1559
|
+
id: item.id
|
|
1560
|
+
});
|
|
1561
|
+
const variationValue = getTestFields({
|
|
1562
|
+
item,
|
|
1563
|
+
testGroupId
|
|
1564
|
+
});
|
|
1565
|
+
return {
|
|
1566
|
+
...item,
|
|
1567
|
+
...variationValue
|
|
1568
|
+
};
|
|
1671
1569
|
};
|
|
1672
1570
|
|
|
1673
|
-
// src/
|
|
1674
|
-
|
|
1571
|
+
// src/helpers/canTrack.ts
|
|
1572
|
+
var getDefaultCanTrack = (canTrack) => checkIsDefined(canTrack) ? canTrack : true;
|
|
1573
|
+
|
|
1574
|
+
// src/components/content/content.tsx
|
|
1575
|
+
import { Show as Show10, createSignal as createSignal11 } from "solid-js";
|
|
1675
1576
|
|
|
1676
|
-
// src/blocks/button/component-info.
|
|
1577
|
+
// src/blocks/button/component-info.ts
|
|
1677
1578
|
var componentInfo = {
|
|
1678
1579
|
name: "Core:Button",
|
|
1679
1580
|
image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13",
|
|
1680
1581
|
defaultStyles: {
|
|
1582
|
+
// TODO: make min width more intuitive and set one
|
|
1681
1583
|
appearance: "none",
|
|
1682
1584
|
paddingTop: "15px",
|
|
1683
1585
|
paddingBottom: "15px",
|
|
@@ -1708,8 +1610,9 @@ var componentInfo = {
|
|
|
1708
1610
|
noWrap: true
|
|
1709
1611
|
};
|
|
1710
1612
|
|
|
1711
|
-
// src/blocks/columns/component-info.
|
|
1613
|
+
// src/blocks/columns/component-info.ts
|
|
1712
1614
|
var componentInfo2 = {
|
|
1615
|
+
// TODO: ways to statically preprocess JSON for references, functions, etc
|
|
1713
1616
|
name: "Columns",
|
|
1714
1617
|
isRSC: true,
|
|
1715
1618
|
inputs: [{
|
|
@@ -1927,48 +1830,204 @@ var componentInfo2 = {
|
|
|
1927
1830
|
}]
|
|
1928
1831
|
};
|
|
1929
1832
|
|
|
1930
|
-
// src/blocks/
|
|
1833
|
+
// src/blocks/custom-code/component-info.ts
|
|
1931
1834
|
var componentInfo3 = {
|
|
1932
|
-
name: "
|
|
1933
|
-
static: true,
|
|
1934
|
-
hidden: true,
|
|
1935
|
-
canHaveChildren: true,
|
|
1936
|
-
noWrap: true
|
|
1937
|
-
};
|
|
1938
|
-
|
|
1939
|
-
// src/blocks/image/component-info.js
|
|
1940
|
-
var componentInfo4 = {
|
|
1941
|
-
name: "Image",
|
|
1835
|
+
name: "Custom Code",
|
|
1942
1836
|
static: true,
|
|
1943
|
-
|
|
1944
|
-
defaultStyles: {
|
|
1945
|
-
position: "relative",
|
|
1946
|
-
minHeight: "20px",
|
|
1947
|
-
minWidth: "20px",
|
|
1948
|
-
overflow: "hidden"
|
|
1949
|
-
},
|
|
1950
|
-
canHaveChildren: true,
|
|
1837
|
+
requiredPermissions: ["editCode"],
|
|
1951
1838
|
inputs: [{
|
|
1952
|
-
name: "
|
|
1953
|
-
type: "
|
|
1954
|
-
bubble: true,
|
|
1955
|
-
allowedFileTypes: ["jpeg", "jpg", "png", "svg"],
|
|
1839
|
+
name: "code",
|
|
1840
|
+
type: "html",
|
|
1956
1841
|
required: true,
|
|
1957
|
-
defaultValue: "
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1842
|
+
defaultValue: "<p>Hello there, I am custom HTML code!</p>",
|
|
1843
|
+
code: true
|
|
1844
|
+
}, {
|
|
1845
|
+
name: "replaceNodes",
|
|
1846
|
+
type: "boolean",
|
|
1847
|
+
helperText: "Preserve server rendered dom nodes",
|
|
1848
|
+
advanced: true
|
|
1849
|
+
}, {
|
|
1850
|
+
name: "scriptsClientOnly",
|
|
1851
|
+
type: "boolean",
|
|
1852
|
+
defaultValue: false,
|
|
1853
|
+
helperText: "Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads",
|
|
1854
|
+
advanced: true
|
|
1855
|
+
}]
|
|
1856
|
+
};
|
|
1857
|
+
|
|
1858
|
+
// src/blocks/custom-code/custom-code.tsx
|
|
1859
|
+
import { onMount, createSignal as createSignal7 } from "solid-js";
|
|
1860
|
+
function CustomCode(props) {
|
|
1861
|
+
const [scriptsInserted, setScriptsInserted] = createSignal7([]);
|
|
1862
|
+
const [scriptsRun, setScriptsRun] = createSignal7([]);
|
|
1863
|
+
let elementRef;
|
|
1864
|
+
onMount(() => {
|
|
1865
|
+
if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
|
|
1866
|
+
return;
|
|
1867
|
+
}
|
|
1868
|
+
const scripts = elementRef.getElementsByTagName("script");
|
|
1869
|
+
for (let i = 0; i < scripts.length; i++) {
|
|
1870
|
+
const script = scripts[i];
|
|
1871
|
+
if (script.src) {
|
|
1872
|
+
if (scriptsInserted().includes(script.src)) {
|
|
1873
|
+
continue;
|
|
1874
|
+
}
|
|
1875
|
+
scriptsInserted().push(script.src);
|
|
1876
|
+
const newScript = document.createElement("script");
|
|
1877
|
+
newScript.async = true;
|
|
1878
|
+
newScript.src = script.src;
|
|
1879
|
+
document.head.appendChild(newScript);
|
|
1880
|
+
} else if (!script.type || [
|
|
1881
|
+
"text/javascript",
|
|
1882
|
+
"application/javascript",
|
|
1883
|
+
"application/ecmascript"
|
|
1884
|
+
].includes(script.type)) {
|
|
1885
|
+
if (scriptsRun().includes(script.innerText)) {
|
|
1886
|
+
continue;
|
|
1887
|
+
}
|
|
1888
|
+
try {
|
|
1889
|
+
scriptsRun().push(script.innerText);
|
|
1890
|
+
new Function(script.innerText)();
|
|
1891
|
+
} catch (error) {
|
|
1892
|
+
console.warn("`CustomCode`: Error running script:", error);
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
});
|
|
1897
|
+
return <div
|
|
1898
|
+
class={"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")}
|
|
1899
|
+
ref={elementRef}
|
|
1900
|
+
innerHTML={props.code}
|
|
1901
|
+
/>;
|
|
1902
|
+
}
|
|
1903
|
+
var custom_code_default = CustomCode;
|
|
1904
|
+
|
|
1905
|
+
// src/blocks/embed/component-info.ts
|
|
1906
|
+
var componentInfo4 = {
|
|
1907
|
+
name: "Embed",
|
|
1908
|
+
static: true,
|
|
1909
|
+
inputs: [{
|
|
1910
|
+
name: "url",
|
|
1911
|
+
type: "url",
|
|
1912
|
+
required: true,
|
|
1913
|
+
defaultValue: "",
|
|
1914
|
+
helperText: "e.g. enter a youtube url, google map, etc",
|
|
1915
|
+
onChange: (options) => {
|
|
1916
|
+
const url = options.get("url");
|
|
1917
|
+
if (url) {
|
|
1918
|
+
options.set("content", "Loading...");
|
|
1919
|
+
const apiKey = "ae0e60e78201a3f2b0de4b";
|
|
1920
|
+
return fetch(`https://iframe.ly/api/iframely?url=${url}&api_key=${apiKey}`).then((res) => res.json()).then((data) => {
|
|
1921
|
+
if (options.get("url") === url) {
|
|
1922
|
+
if (data.html) {
|
|
1923
|
+
options.set("content", data.html);
|
|
1924
|
+
} else {
|
|
1925
|
+
options.set("content", "Invalid url, please try another");
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1928
|
+
}).catch((_err) => {
|
|
1929
|
+
options.set("content", "There was an error embedding this URL, please try again or another URL");
|
|
1930
|
+
});
|
|
1931
|
+
} else {
|
|
1932
|
+
options.delete("content");
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
}, {
|
|
1936
|
+
name: "content",
|
|
1937
|
+
type: "html",
|
|
1938
|
+
defaultValue: '<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',
|
|
1939
|
+
hideFromUI: true
|
|
1940
|
+
}]
|
|
1941
|
+
};
|
|
1942
|
+
|
|
1943
|
+
// src/blocks/embed/embed.tsx
|
|
1944
|
+
import { on, createEffect, createSignal as createSignal8 } from "solid-js";
|
|
1945
|
+
|
|
1946
|
+
// src/blocks/embed/helpers.ts
|
|
1947
|
+
var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
|
|
1948
|
+
var isJsScript = (script) => SCRIPT_MIME_TYPES.includes(script.type);
|
|
1949
|
+
|
|
1950
|
+
// src/blocks/embed/embed.tsx
|
|
1951
|
+
function Embed(props) {
|
|
1952
|
+
const [scriptsInserted, setScriptsInserted] = createSignal8([]);
|
|
1953
|
+
const [scriptsRun, setScriptsRun] = createSignal8([]);
|
|
1954
|
+
const [ranInitFn, setRanInitFn] = createSignal8(false);
|
|
1955
|
+
function findAndRunScripts() {
|
|
1956
|
+
if (!elem || !elem.getElementsByTagName)
|
|
1957
|
+
return;
|
|
1958
|
+
const scripts = elem.getElementsByTagName("script");
|
|
1959
|
+
for (let i = 0; i < scripts.length; i++) {
|
|
1960
|
+
const script = scripts[i];
|
|
1961
|
+
if (script.src && !scriptsInserted().includes(script.src)) {
|
|
1962
|
+
scriptsInserted().push(script.src);
|
|
1963
|
+
const newScript = document.createElement("script");
|
|
1964
|
+
newScript.async = true;
|
|
1965
|
+
newScript.src = script.src;
|
|
1966
|
+
document.head.appendChild(newScript);
|
|
1967
|
+
} else if (isJsScript(script) && !scriptsRun().includes(script.innerText)) {
|
|
1968
|
+
try {
|
|
1969
|
+
scriptsRun().push(script.innerText);
|
|
1970
|
+
new Function(script.innerText)();
|
|
1971
|
+
} catch (error) {
|
|
1972
|
+
console.warn("`Embed`: Error running script:", error);
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
}
|
|
1977
|
+
let elem;
|
|
1978
|
+
function onUpdateFn_0() {
|
|
1979
|
+
if (elem && !ranInitFn()) {
|
|
1980
|
+
setRanInitFn(true);
|
|
1981
|
+
findAndRunScripts();
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
createEffect(on(() => [elem, ranInitFn()], onUpdateFn_0));
|
|
1985
|
+
return <div class="builder-embed" ref={elem} innerHTML={props.content} />;
|
|
1986
|
+
}
|
|
1987
|
+
var embed_default = Embed;
|
|
1988
|
+
|
|
1989
|
+
// src/blocks/fragment/component-info.ts
|
|
1990
|
+
var componentInfo5 = {
|
|
1991
|
+
name: "Fragment",
|
|
1992
|
+
static: true,
|
|
1993
|
+
hidden: true,
|
|
1994
|
+
canHaveChildren: true,
|
|
1995
|
+
noWrap: true
|
|
1996
|
+
};
|
|
1997
|
+
|
|
1998
|
+
// src/blocks/image/component-info.ts
|
|
1999
|
+
var componentInfo6 = {
|
|
2000
|
+
name: "Image",
|
|
2001
|
+
static: true,
|
|
2002
|
+
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",
|
|
2003
|
+
defaultStyles: {
|
|
2004
|
+
position: "relative",
|
|
2005
|
+
minHeight: "20px",
|
|
2006
|
+
minWidth: "20px",
|
|
2007
|
+
overflow: "hidden"
|
|
2008
|
+
},
|
|
2009
|
+
canHaveChildren: true,
|
|
2010
|
+
inputs: [{
|
|
2011
|
+
name: "image",
|
|
2012
|
+
type: "file",
|
|
2013
|
+
bubble: true,
|
|
2014
|
+
allowedFileTypes: ["jpeg", "jpg", "png", "svg"],
|
|
2015
|
+
required: true,
|
|
2016
|
+
defaultValue: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F72c80f114dc149019051b6852a9e3b7a",
|
|
2017
|
+
onChange: (options) => {
|
|
2018
|
+
const DEFAULT_ASPECT_RATIO = 0.7041;
|
|
2019
|
+
options.delete("srcset");
|
|
2020
|
+
options.delete("noWebp");
|
|
2021
|
+
function loadImage(url, timeout = 6e4) {
|
|
2022
|
+
return new Promise((resolve, reject) => {
|
|
2023
|
+
const img = document.createElement("img");
|
|
2024
|
+
let loaded = false;
|
|
2025
|
+
img.onload = () => {
|
|
2026
|
+
loaded = true;
|
|
2027
|
+
resolve(img);
|
|
2028
|
+
};
|
|
2029
|
+
img.addEventListener("error", (event) => {
|
|
2030
|
+
console.warn("Image load failed", event.error);
|
|
1972
2031
|
reject(event.error);
|
|
1973
2032
|
});
|
|
1974
2033
|
img.src = url;
|
|
@@ -2059,8 +2118,41 @@ var componentInfo4 = {
|
|
|
2059
2118
|
}]
|
|
2060
2119
|
};
|
|
2061
2120
|
|
|
2062
|
-
// src/blocks/
|
|
2063
|
-
var
|
|
2121
|
+
// src/blocks/img/component-info.ts
|
|
2122
|
+
var componentInfo7 = {
|
|
2123
|
+
// friendlyName?
|
|
2124
|
+
name: "Raw:Img",
|
|
2125
|
+
hideFromInsertMenu: true,
|
|
2126
|
+
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",
|
|
2127
|
+
inputs: [{
|
|
2128
|
+
name: "image",
|
|
2129
|
+
bubble: true,
|
|
2130
|
+
type: "file",
|
|
2131
|
+
allowedFileTypes: ["jpeg", "jpg", "png", "svg", "gif", "webp"],
|
|
2132
|
+
required: true
|
|
2133
|
+
}],
|
|
2134
|
+
noWrap: true,
|
|
2135
|
+
static: true
|
|
2136
|
+
};
|
|
2137
|
+
|
|
2138
|
+
// src/blocks/img/img.tsx
|
|
2139
|
+
function ImgComponent(props) {
|
|
2140
|
+
return <img
|
|
2141
|
+
style={{
|
|
2142
|
+
"object-fit": props.backgroundSize || "cover",
|
|
2143
|
+
"object-position": props.backgroundPosition || "center"
|
|
2144
|
+
}}
|
|
2145
|
+
key={isEditing() && props.imgSrc || "default-key"}
|
|
2146
|
+
alt={props.altText}
|
|
2147
|
+
src={props.imgSrc || props.image}
|
|
2148
|
+
{...{}}
|
|
2149
|
+
{...props.attributes}
|
|
2150
|
+
/>;
|
|
2151
|
+
}
|
|
2152
|
+
var img_default = ImgComponent;
|
|
2153
|
+
|
|
2154
|
+
// src/blocks/section/component-info.ts
|
|
2155
|
+
var componentInfo8 = {
|
|
2064
2156
|
name: "Core:Section",
|
|
2065
2157
|
static: true,
|
|
2066
2158
|
image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F682efef23ace49afac61748dd305c70a",
|
|
@@ -2101,8 +2193,8 @@ var componentInfo5 = {
|
|
|
2101
2193
|
}]
|
|
2102
2194
|
};
|
|
2103
2195
|
|
|
2104
|
-
// src/blocks/symbol/component-info.
|
|
2105
|
-
var
|
|
2196
|
+
// src/blocks/symbol/component-info.ts
|
|
2197
|
+
var componentInfo9 = {
|
|
2106
2198
|
name: "Symbol",
|
|
2107
2199
|
noWrap: true,
|
|
2108
2200
|
static: true,
|
|
@@ -2137,8 +2229,8 @@ var componentInfo6 = {
|
|
|
2137
2229
|
}]
|
|
2138
2230
|
};
|
|
2139
2231
|
|
|
2140
|
-
// src/blocks/text/component-info.
|
|
2141
|
-
var
|
|
2232
|
+
// src/blocks/text/component-info.ts
|
|
2233
|
+
var componentInfo10 = {
|
|
2142
2234
|
name: "Text",
|
|
2143
2235
|
static: true,
|
|
2144
2236
|
isRSC: true,
|
|
@@ -2158,7 +2250,7 @@ var componentInfo7 = {
|
|
|
2158
2250
|
}
|
|
2159
2251
|
};
|
|
2160
2252
|
|
|
2161
|
-
// src/blocks/text/text.
|
|
2253
|
+
// src/blocks/text/text.tsx
|
|
2162
2254
|
function Text(props) {
|
|
2163
2255
|
return <div
|
|
2164
2256
|
class="builder-text"
|
|
@@ -2170,8 +2262,8 @@ function Text(props) {
|
|
|
2170
2262
|
}
|
|
2171
2263
|
var text_default = Text;
|
|
2172
2264
|
|
|
2173
|
-
// src/blocks/video/component-info.
|
|
2174
|
-
var
|
|
2265
|
+
// src/blocks/video/component-info.ts
|
|
2266
|
+
var componentInfo11 = {
|
|
2175
2267
|
name: "Video",
|
|
2176
2268
|
canHaveChildren: true,
|
|
2177
2269
|
defaultStyles: {
|
|
@@ -2254,8 +2346,7 @@ var componentInfo8 = {
|
|
|
2254
2346
|
}]
|
|
2255
2347
|
};
|
|
2256
2348
|
|
|
2257
|
-
// src/blocks/video/video.
|
|
2258
|
-
import { createSignal as createSignal8 } from "solid-js";
|
|
2349
|
+
// src/blocks/video/video.tsx
|
|
2259
2350
|
function Video(props) {
|
|
2260
2351
|
function videoProps() {
|
|
2261
2352
|
return {
|
|
@@ -2301,277 +2392,43 @@ function Video(props) {
|
|
|
2301
2392
|
}
|
|
2302
2393
|
var video_default = Video;
|
|
2303
2394
|
|
|
2304
|
-
// src/
|
|
2305
|
-
var
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
// src/blocks/embed/embed.jsx
|
|
2343
|
-
import { on, createEffect, createSignal as createSignal9 } from "solid-js";
|
|
2344
|
-
|
|
2345
|
-
// src/blocks/embed/helpers.js
|
|
2346
|
-
var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
|
|
2347
|
-
var isJsScript = (script) => SCRIPT_MIME_TYPES.includes(script.type);
|
|
2348
|
-
|
|
2349
|
-
// src/blocks/embed/embed.jsx
|
|
2350
|
-
function Embed(props) {
|
|
2351
|
-
const [scriptsInserted, setScriptsInserted] = createSignal9([]);
|
|
2352
|
-
const [scriptsRun, setScriptsRun] = createSignal9([]);
|
|
2353
|
-
const [ranInitFn, setRanInitFn] = createSignal9(false);
|
|
2354
|
-
function findAndRunScripts() {
|
|
2355
|
-
if (!elem || !elem.getElementsByTagName)
|
|
2356
|
-
return;
|
|
2357
|
-
const scripts = elem.getElementsByTagName("script");
|
|
2358
|
-
for (let i = 0; i < scripts.length; i++) {
|
|
2359
|
-
const script = scripts[i];
|
|
2360
|
-
if (script.src && !scriptsInserted().includes(script.src)) {
|
|
2361
|
-
scriptsInserted().push(script.src);
|
|
2362
|
-
const newScript = document.createElement("script");
|
|
2363
|
-
newScript.async = true;
|
|
2364
|
-
newScript.src = script.src;
|
|
2365
|
-
document.head.appendChild(newScript);
|
|
2366
|
-
} else if (isJsScript(script) && !scriptsRun().includes(script.innerText)) {
|
|
2367
|
-
try {
|
|
2368
|
-
scriptsRun().push(script.innerText);
|
|
2369
|
-
new Function(script.innerText)();
|
|
2370
|
-
} catch (error) {
|
|
2371
|
-
console.warn("`Embed`: Error running script:", error);
|
|
2372
|
-
}
|
|
2373
|
-
}
|
|
2374
|
-
}
|
|
2375
|
-
}
|
|
2376
|
-
let elem;
|
|
2377
|
-
function onUpdateFn_0() {
|
|
2378
|
-
if (elem && !ranInitFn()) {
|
|
2379
|
-
setRanInitFn(true);
|
|
2380
|
-
findAndRunScripts();
|
|
2381
|
-
}
|
|
2382
|
-
}
|
|
2383
|
-
createEffect(on(() => [elem, ranInitFn()], onUpdateFn_0));
|
|
2384
|
-
return <div class="builder-embed" ref={elem} innerHTML={props.content} />;
|
|
2385
|
-
}
|
|
2386
|
-
var embed_default = Embed;
|
|
2387
|
-
|
|
2388
|
-
// src/blocks/img/img.jsx
|
|
2389
|
-
function ImgComponent(props) {
|
|
2390
|
-
return <img
|
|
2391
|
-
style={{
|
|
2392
|
-
"object-fit": props.backgroundSize || "cover",
|
|
2393
|
-
"object-position": props.backgroundPosition || "center"
|
|
2394
|
-
}}
|
|
2395
|
-
key={isEditing() && props.imgSrc || "default-key"}
|
|
2396
|
-
alt={props.altText}
|
|
2397
|
-
src={props.imgSrc || props.image}
|
|
2398
|
-
{...{}}
|
|
2399
|
-
{...props.attributes}
|
|
2400
|
-
/>;
|
|
2401
|
-
}
|
|
2402
|
-
var img_default = ImgComponent;
|
|
2403
|
-
|
|
2404
|
-
// src/blocks/img/component-info.js
|
|
2405
|
-
var componentInfo10 = {
|
|
2406
|
-
name: "Raw:Img",
|
|
2407
|
-
hideFromInsertMenu: true,
|
|
2408
|
-
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",
|
|
2409
|
-
inputs: [{
|
|
2410
|
-
name: "image",
|
|
2411
|
-
bubble: true,
|
|
2412
|
-
type: "file",
|
|
2413
|
-
allowedFileTypes: ["jpeg", "jpg", "png", "svg", "gif", "webp"],
|
|
2414
|
-
required: true
|
|
2415
|
-
}],
|
|
2416
|
-
noWrap: true,
|
|
2417
|
-
static: true
|
|
2418
|
-
};
|
|
2419
|
-
|
|
2420
|
-
// src/blocks/custom-code/custom-code.jsx
|
|
2421
|
-
import { onMount, createSignal as createSignal10 } from "solid-js";
|
|
2422
|
-
function CustomCode(props) {
|
|
2423
|
-
const [scriptsInserted, setScriptsInserted] = createSignal10([]);
|
|
2424
|
-
const [scriptsRun, setScriptsRun] = createSignal10([]);
|
|
2425
|
-
let elementRef;
|
|
2426
|
-
onMount(() => {
|
|
2427
|
-
if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
|
|
2428
|
-
return;
|
|
2429
|
-
}
|
|
2430
|
-
const scripts = elementRef.getElementsByTagName("script");
|
|
2431
|
-
for (let i = 0; i < scripts.length; i++) {
|
|
2432
|
-
const script = scripts[i];
|
|
2433
|
-
if (script.src) {
|
|
2434
|
-
if (scriptsInserted().includes(script.src)) {
|
|
2435
|
-
continue;
|
|
2436
|
-
}
|
|
2437
|
-
scriptsInserted().push(script.src);
|
|
2438
|
-
const newScript = document.createElement("script");
|
|
2439
|
-
newScript.async = true;
|
|
2440
|
-
newScript.src = script.src;
|
|
2441
|
-
document.head.appendChild(newScript);
|
|
2442
|
-
} else if (!script.type || [
|
|
2443
|
-
"text/javascript",
|
|
2444
|
-
"application/javascript",
|
|
2445
|
-
"application/ecmascript"
|
|
2446
|
-
].includes(script.type)) {
|
|
2447
|
-
if (scriptsRun().includes(script.innerText)) {
|
|
2448
|
-
continue;
|
|
2449
|
-
}
|
|
2450
|
-
try {
|
|
2451
|
-
scriptsRun().push(script.innerText);
|
|
2452
|
-
new Function(script.innerText)();
|
|
2453
|
-
} catch (error) {
|
|
2454
|
-
console.warn("`CustomCode`: Error running script:", error);
|
|
2455
|
-
}
|
|
2456
|
-
}
|
|
2457
|
-
}
|
|
2458
|
-
});
|
|
2459
|
-
return <div
|
|
2460
|
-
class={"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")}
|
|
2461
|
-
ref={elementRef}
|
|
2462
|
-
innerHTML={props.code}
|
|
2463
|
-
/>;
|
|
2464
|
-
}
|
|
2465
|
-
var custom_code_default = CustomCode;
|
|
2466
|
-
|
|
2467
|
-
// src/blocks/custom-code/component-info.js
|
|
2468
|
-
var componentInfo11 = {
|
|
2469
|
-
name: "Custom Code",
|
|
2470
|
-
static: true,
|
|
2471
|
-
requiredPermissions: ["editCode"],
|
|
2472
|
-
inputs: [{
|
|
2473
|
-
name: "code",
|
|
2474
|
-
type: "html",
|
|
2475
|
-
required: true,
|
|
2476
|
-
defaultValue: "<p>Hello there, I am custom HTML code!</p>",
|
|
2477
|
-
code: true
|
|
2478
|
-
}, {
|
|
2479
|
-
name: "replaceNodes",
|
|
2480
|
-
type: "boolean",
|
|
2481
|
-
helperText: "Preserve server rendered dom nodes",
|
|
2482
|
-
advanced: true
|
|
2483
|
-
}, {
|
|
2484
|
-
name: "scriptsClientOnly",
|
|
2485
|
-
type: "boolean",
|
|
2486
|
-
defaultValue: false,
|
|
2487
|
-
helperText: "Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads",
|
|
2488
|
-
advanced: true
|
|
2489
|
-
}]
|
|
2490
|
-
};
|
|
2491
|
-
|
|
2492
|
-
// src/constants/builder-registered-components.js
|
|
2493
|
-
var __defProp9 = Object.defineProperty;
|
|
2494
|
-
var __getOwnPropSymbols9 = Object.getOwnPropertySymbols;
|
|
2495
|
-
var __hasOwnProp9 = Object.prototype.hasOwnProperty;
|
|
2496
|
-
var __propIsEnum9 = Object.prototype.propertyIsEnumerable;
|
|
2497
|
-
var __defNormalProp9 = (obj, key, value) => key in obj ? __defProp9(obj, key, {
|
|
2498
|
-
enumerable: true,
|
|
2499
|
-
configurable: true,
|
|
2500
|
-
writable: true,
|
|
2501
|
-
value
|
|
2502
|
-
}) : obj[key] = value;
|
|
2503
|
-
var __spreadValues9 = (a, b) => {
|
|
2504
|
-
for (var prop in b || (b = {}))
|
|
2505
|
-
if (__hasOwnProp9.call(b, prop))
|
|
2506
|
-
__defNormalProp9(a, prop, b[prop]);
|
|
2507
|
-
if (__getOwnPropSymbols9)
|
|
2508
|
-
for (var prop of __getOwnPropSymbols9(b)) {
|
|
2509
|
-
if (__propIsEnum9.call(b, prop))
|
|
2510
|
-
__defNormalProp9(a, prop, b[prop]);
|
|
2511
|
-
}
|
|
2512
|
-
return a;
|
|
2513
|
-
};
|
|
2514
|
-
var getDefaultRegisteredComponents = () => [__spreadValues9({
|
|
2515
|
-
component: button_default
|
|
2516
|
-
}, componentInfo), __spreadValues9({
|
|
2517
|
-
component: columns_default
|
|
2518
|
-
}, componentInfo2), __spreadValues9({
|
|
2519
|
-
component: custom_code_default
|
|
2520
|
-
}, componentInfo11), __spreadValues9({
|
|
2521
|
-
component: embed_default
|
|
2522
|
-
}, componentInfo9), __spreadValues9({
|
|
2523
|
-
component: fragment_default
|
|
2524
|
-
}, componentInfo3), __spreadValues9({
|
|
2525
|
-
component: image_default
|
|
2526
|
-
}, componentInfo4), __spreadValues9({
|
|
2527
|
-
component: img_default
|
|
2528
|
-
}, componentInfo10), __spreadValues9({
|
|
2529
|
-
component: section_default
|
|
2530
|
-
}, componentInfo5), __spreadValues9({
|
|
2531
|
-
component: symbol_default
|
|
2532
|
-
}, componentInfo6), __spreadValues9({
|
|
2533
|
-
component: text_default
|
|
2534
|
-
}, componentInfo7), __spreadValues9({
|
|
2535
|
-
component: video_default
|
|
2536
|
-
}, componentInfo8)];
|
|
2537
|
-
|
|
2538
|
-
// src/functions/register-component.js
|
|
2539
|
-
var __defProp10 = Object.defineProperty;
|
|
2540
|
-
var __defProps7 = Object.defineProperties;
|
|
2541
|
-
var __getOwnPropDescs7 = Object.getOwnPropertyDescriptors;
|
|
2542
|
-
var __getOwnPropSymbols10 = Object.getOwnPropertySymbols;
|
|
2543
|
-
var __hasOwnProp10 = Object.prototype.hasOwnProperty;
|
|
2544
|
-
var __propIsEnum10 = Object.prototype.propertyIsEnumerable;
|
|
2545
|
-
var __defNormalProp10 = (obj, key, value) => key in obj ? __defProp10(obj, key, {
|
|
2546
|
-
enumerable: true,
|
|
2547
|
-
configurable: true,
|
|
2548
|
-
writable: true,
|
|
2549
|
-
value
|
|
2550
|
-
}) : obj[key] = value;
|
|
2551
|
-
var __spreadValues10 = (a, b) => {
|
|
2552
|
-
for (var prop in b || (b = {}))
|
|
2553
|
-
if (__hasOwnProp10.call(b, prop))
|
|
2554
|
-
__defNormalProp10(a, prop, b[prop]);
|
|
2555
|
-
if (__getOwnPropSymbols10)
|
|
2556
|
-
for (var prop of __getOwnPropSymbols10(b)) {
|
|
2557
|
-
if (__propIsEnum10.call(b, prop))
|
|
2558
|
-
__defNormalProp10(a, prop, b[prop]);
|
|
2559
|
-
}
|
|
2560
|
-
return a;
|
|
2561
|
-
};
|
|
2562
|
-
var __spreadProps7 = (a, b) => __defProps7(a, __getOwnPropDescs7(b));
|
|
2563
|
-
var __objRest2 = (source, exclude) => {
|
|
2564
|
-
var target = {};
|
|
2565
|
-
for (var prop in source)
|
|
2566
|
-
if (__hasOwnProp10.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
2567
|
-
target[prop] = source[prop];
|
|
2568
|
-
if (source != null && __getOwnPropSymbols10)
|
|
2569
|
-
for (var prop of __getOwnPropSymbols10(source)) {
|
|
2570
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum10.call(source, prop))
|
|
2571
|
-
target[prop] = source[prop];
|
|
2572
|
-
}
|
|
2573
|
-
return target;
|
|
2574
|
-
};
|
|
2395
|
+
// src/constants/builder-registered-components.ts
|
|
2396
|
+
var getDefaultRegisteredComponents = () => [{
|
|
2397
|
+
component: button_default,
|
|
2398
|
+
...componentInfo
|
|
2399
|
+
}, {
|
|
2400
|
+
component: columns_default,
|
|
2401
|
+
...componentInfo2
|
|
2402
|
+
}, {
|
|
2403
|
+
component: custom_code_default,
|
|
2404
|
+
...componentInfo3
|
|
2405
|
+
}, {
|
|
2406
|
+
component: embed_default,
|
|
2407
|
+
...componentInfo4
|
|
2408
|
+
}, {
|
|
2409
|
+
component: fragment_default,
|
|
2410
|
+
...componentInfo5
|
|
2411
|
+
}, {
|
|
2412
|
+
component: image_default,
|
|
2413
|
+
...componentInfo6
|
|
2414
|
+
}, {
|
|
2415
|
+
component: img_default,
|
|
2416
|
+
...componentInfo7
|
|
2417
|
+
}, {
|
|
2418
|
+
component: section_default,
|
|
2419
|
+
...componentInfo8
|
|
2420
|
+
}, {
|
|
2421
|
+
component: symbol_default,
|
|
2422
|
+
...componentInfo9
|
|
2423
|
+
}, {
|
|
2424
|
+
component: text_default,
|
|
2425
|
+
...componentInfo10
|
|
2426
|
+
}, {
|
|
2427
|
+
component: video_default,
|
|
2428
|
+
...componentInfo11
|
|
2429
|
+
}];
|
|
2430
|
+
|
|
2431
|
+
// src/functions/register-component.ts
|
|
2575
2432
|
var components = [];
|
|
2576
2433
|
var createRegisterComponentMessage = (info) => ({
|
|
2577
2434
|
type: "builder.registerComponent",
|
|
@@ -2583,936 +2440,225 @@ var serializeFn = (fnValue) => {
|
|
|
2583
2440
|
return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
|
|
2584
2441
|
};
|
|
2585
2442
|
var serializeValue = (value) => typeof value === "function" ? serializeFn(value) : fastClone(value);
|
|
2586
|
-
var serializeComponentInfo = (
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
})
|
|
2595
|
-
};
|
|
2596
|
-
|
|
2597
|
-
// src/components/content/components/styles.jsx
|
|
2598
|
-
import { createSignal as createSignal11 } from "solid-js";
|
|
2443
|
+
var serializeComponentInfo = ({
|
|
2444
|
+
inputs,
|
|
2445
|
+
...info
|
|
2446
|
+
}) => ({
|
|
2447
|
+
...fastClone(info),
|
|
2448
|
+
inputs: inputs?.map((input) => Object.entries(input).reduce((acc, [key, value]) => ({
|
|
2449
|
+
...acc,
|
|
2450
|
+
[key]: serializeValue(value)
|
|
2451
|
+
}), {}))
|
|
2452
|
+
});
|
|
2599
2453
|
|
|
2600
|
-
// src/components/content/
|
|
2601
|
-
var
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
@font-face {
|
|
2610
|
-
font-family: "${family}";
|
|
2611
|
-
src: local("${name}"), url('${url}') format('woff2');
|
|
2612
|
-
font-display: fallback;
|
|
2613
|
-
font-weight: 400;
|
|
2614
|
-
}
|
|
2615
|
-
`.trim();
|
|
2616
|
-
}
|
|
2617
|
-
if (font.files) {
|
|
2618
|
-
for (const weight in font.files) {
|
|
2619
|
-
const isNumber = String(Number(weight)) === weight;
|
|
2620
|
-
if (!isNumber) {
|
|
2621
|
-
continue;
|
|
2622
|
-
}
|
|
2623
|
-
const weightUrl = font.files[weight];
|
|
2624
|
-
if (weightUrl && weightUrl !== url) {
|
|
2625
|
-
str += `
|
|
2626
|
-
@font-face {
|
|
2627
|
-
font-family: "${family}";
|
|
2628
|
-
src: url('${weightUrl}') format('woff2');
|
|
2629
|
-
font-display: fallback;
|
|
2630
|
-
font-weight: ${weight};
|
|
2631
|
-
}
|
|
2632
|
-
`.trim();
|
|
2633
|
-
}
|
|
2634
|
-
}
|
|
2635
|
-
}
|
|
2636
|
-
return str;
|
|
2637
|
-
};
|
|
2638
|
-
var getFontCss = ({
|
|
2639
|
-
customFonts
|
|
2640
|
-
}) => {
|
|
2641
|
-
var _a;
|
|
2642
|
-
return ((_a = customFonts == null ? void 0 : customFonts.map((font) => getCssFromFont(font))) == null ? void 0 : _a.join(" ")) || "";
|
|
2643
|
-
};
|
|
2644
|
-
var getCss = ({
|
|
2645
|
-
cssCode,
|
|
2646
|
-
contentId
|
|
2454
|
+
// src/components/content-variants/helpers.ts
|
|
2455
|
+
var getVariants = (content) => Object.values(content?.variations || {}).map((variant) => ({
|
|
2456
|
+
...variant,
|
|
2457
|
+
testVariationId: variant.id,
|
|
2458
|
+
id: content?.id
|
|
2459
|
+
}));
|
|
2460
|
+
var checkShouldRunVariants = ({
|
|
2461
|
+
canTrack,
|
|
2462
|
+
content
|
|
2647
2463
|
}) => {
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
if (!
|
|
2652
|
-
return
|
|
2653
|
-
|
|
2654
|
-
|
|
2464
|
+
const hasVariants = getVariants(content).length > 0;
|
|
2465
|
+
if (TARGET === "reactNative")
|
|
2466
|
+
return false;
|
|
2467
|
+
if (!hasVariants)
|
|
2468
|
+
return false;
|
|
2469
|
+
if (!canTrack)
|
|
2470
|
+
return false;
|
|
2471
|
+
if (TARGET === "vue2" || TARGET === "vue3")
|
|
2472
|
+
return true;
|
|
2473
|
+
if (isBrowser())
|
|
2474
|
+
return false;
|
|
2475
|
+
return true;
|
|
2655
2476
|
};
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
function
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
customFonts: props.customFonts
|
|
2667
|
-
})}
|
|
2668
|
-
|
|
2669
|
-
.builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
|
|
2670
|
-
margin: 0;
|
|
2671
|
-
}
|
|
2672
|
-
.builder-text > p, .builder-text > .builder-paragraph {
|
|
2673
|
-
color: inherit;
|
|
2674
|
-
line-height: inherit;
|
|
2675
|
-
letter-spacing: inherit;
|
|
2676
|
-
font-weight: inherit;
|
|
2677
|
-
font-size: inherit;
|
|
2678
|
-
text-align: inherit;
|
|
2679
|
-
font-family: inherit;
|
|
2680
|
-
}
|
|
2681
|
-
`.trim()
|
|
2682
|
-
);
|
|
2683
|
-
return <Inlined_styles_default styles={injectedStyles()} />;
|
|
2684
|
-
}
|
|
2685
|
-
var Styles_default = ContentStyles;
|
|
2686
|
-
|
|
2687
|
-
// src/components/content/content.helpers.js
|
|
2688
|
-
var __defProp11 = Object.defineProperty;
|
|
2689
|
-
var __defProps8 = Object.defineProperties;
|
|
2690
|
-
var __getOwnPropDescs8 = Object.getOwnPropertyDescriptors;
|
|
2691
|
-
var __getOwnPropSymbols11 = Object.getOwnPropertySymbols;
|
|
2692
|
-
var __hasOwnProp11 = Object.prototype.hasOwnProperty;
|
|
2693
|
-
var __propIsEnum11 = Object.prototype.propertyIsEnumerable;
|
|
2694
|
-
var __defNormalProp11 = (obj, key, value) => key in obj ? __defProp11(obj, key, {
|
|
2695
|
-
enumerable: true,
|
|
2696
|
-
configurable: true,
|
|
2697
|
-
writable: true,
|
|
2698
|
-
value
|
|
2699
|
-
}) : obj[key] = value;
|
|
2700
|
-
var __spreadValues11 = (a, b) => {
|
|
2701
|
-
for (var prop in b || (b = {}))
|
|
2702
|
-
if (__hasOwnProp11.call(b, prop))
|
|
2703
|
-
__defNormalProp11(a, prop, b[prop]);
|
|
2704
|
-
if (__getOwnPropSymbols11)
|
|
2705
|
-
for (var prop of __getOwnPropSymbols11(b)) {
|
|
2706
|
-
if (__propIsEnum11.call(b, prop))
|
|
2707
|
-
__defNormalProp11(a, prop, b[prop]);
|
|
2477
|
+
function bldrAbTest(contentId, variants, isHydrationTarget2) {
|
|
2478
|
+
function getAndSetVariantId2() {
|
|
2479
|
+
function setCookie2(name, value, days) {
|
|
2480
|
+
let expires = "";
|
|
2481
|
+
if (days) {
|
|
2482
|
+
const date = /* @__PURE__ */ new Date();
|
|
2483
|
+
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1e3);
|
|
2484
|
+
expires = "; expires=" + date.toUTCString();
|
|
2485
|
+
}
|
|
2486
|
+
document.cookie = name + "=" + (value || "") + expires + "; path=/; Secure; SameSite=None";
|
|
2708
2487
|
}
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
const defaultValues = {};
|
|
2719
|
-
(_b = (_a = content == null ? void 0 : content.data) == null ? void 0 : _a.inputs) == null ? void 0 : _b.forEach((input) => {
|
|
2720
|
-
var _a2;
|
|
2721
|
-
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) {
|
|
2722
|
-
defaultValues[input.name] = input.defaultValue;
|
|
2723
|
-
}
|
|
2724
|
-
});
|
|
2725
|
-
const stateToUse = __spreadValues11(__spreadValues11(__spreadValues11({}, (_c = content == null ? void 0 : content.data) == null ? void 0 : _c.state), data), locale ? {
|
|
2726
|
-
locale
|
|
2727
|
-
} : {});
|
|
2728
|
-
return __spreadValues11(__spreadValues11({}, defaultValues), stateToUse);
|
|
2729
|
-
};
|
|
2730
|
-
var getContentInitialValue = ({
|
|
2731
|
-
content,
|
|
2732
|
-
data
|
|
2733
|
-
}) => {
|
|
2734
|
-
return !content ? void 0 : __spreadProps8(__spreadValues11({}, content), {
|
|
2735
|
-
data: __spreadValues11(__spreadValues11({}, content == null ? void 0 : content.data), data),
|
|
2736
|
-
meta: content == null ? void 0 : content.meta
|
|
2737
|
-
});
|
|
2738
|
-
};
|
|
2739
|
-
|
|
2740
|
-
// src/components/content/components/enable-editor.jsx
|
|
2741
|
-
import { Show as Show9, onMount as onMount2, on as on2, createEffect as createEffect2, createSignal as createSignal12 } from "solid-js";
|
|
2742
|
-
|
|
2743
|
-
// src/functions/get-global-this.js
|
|
2744
|
-
function getGlobalThis() {
|
|
2745
|
-
if (typeof globalThis !== "undefined") {
|
|
2746
|
-
return globalThis;
|
|
2747
|
-
}
|
|
2748
|
-
if (typeof window !== "undefined") {
|
|
2749
|
-
return window;
|
|
2750
|
-
}
|
|
2751
|
-
if (typeof global !== "undefined") {
|
|
2752
|
-
return global;
|
|
2753
|
-
}
|
|
2754
|
-
if (typeof self !== "undefined") {
|
|
2755
|
-
return self;
|
|
2756
|
-
}
|
|
2757
|
-
return globalThis;
|
|
2758
|
-
}
|
|
2759
|
-
|
|
2760
|
-
// src/functions/get-fetch.js
|
|
2761
|
-
function getFetch() {
|
|
2762
|
-
const globalFetch = getGlobalThis().fetch;
|
|
2763
|
-
if (typeof globalFetch === "undefined") {
|
|
2764
|
-
console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
|
|
2765
|
-
For more information, read https://github.com/BuilderIO/this-package-uses-fetch`);
|
|
2766
|
-
throw new Error("Builder SDK could not find a global `fetch` function");
|
|
2767
|
-
}
|
|
2768
|
-
return globalFetch;
|
|
2769
|
-
}
|
|
2770
|
-
var fetch2 = getFetch();
|
|
2771
|
-
|
|
2772
|
-
// src/helpers/url.js
|
|
2773
|
-
var getTopLevelDomain = (host) => {
|
|
2774
|
-
if (host === "localhost" || host === "127.0.0.1") {
|
|
2775
|
-
return host;
|
|
2776
|
-
}
|
|
2777
|
-
const parts = host.split(".");
|
|
2778
|
-
if (parts.length > 2) {
|
|
2779
|
-
return parts.slice(1).join(".");
|
|
2780
|
-
}
|
|
2781
|
-
return host;
|
|
2782
|
-
};
|
|
2783
|
-
|
|
2784
|
-
// src/helpers/cookie.js
|
|
2785
|
-
var __async = (__this, __arguments, generator) => {
|
|
2786
|
-
return new Promise((resolve, reject) => {
|
|
2787
|
-
var fulfilled = (value) => {
|
|
2788
|
-
try {
|
|
2789
|
-
step(generator.next(value));
|
|
2790
|
-
} catch (e) {
|
|
2791
|
-
reject(e);
|
|
2792
|
-
}
|
|
2793
|
-
};
|
|
2794
|
-
var rejected = (value) => {
|
|
2795
|
-
try {
|
|
2796
|
-
step(generator.throw(value));
|
|
2797
|
-
} catch (e) {
|
|
2798
|
-
reject(e);
|
|
2799
|
-
}
|
|
2800
|
-
};
|
|
2801
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
2802
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
2803
|
-
});
|
|
2804
|
-
};
|
|
2805
|
-
var getCookieSync = ({
|
|
2806
|
-
name,
|
|
2807
|
-
canTrack
|
|
2808
|
-
}) => {
|
|
2809
|
-
var _a;
|
|
2810
|
-
try {
|
|
2811
|
-
if (!canTrack) {
|
|
2812
|
-
return void 0;
|
|
2813
|
-
}
|
|
2814
|
-
return (_a = document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))) == null ? void 0 : _a.split("=")[1];
|
|
2815
|
-
} catch (err) {
|
|
2816
|
-
logger.warn("[COOKIE] GET error: ", (err == null ? void 0 : err.message) || err);
|
|
2817
|
-
return void 0;
|
|
2818
|
-
}
|
|
2819
|
-
};
|
|
2820
|
-
var getCookie = (args) => __async(void 0, null, function* () {
|
|
2821
|
-
return getCookieSync(args);
|
|
2822
|
-
});
|
|
2823
|
-
var stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).filter(checkIsDefined).join("; ");
|
|
2824
|
-
var SECURE_CONFIG = [["secure", ""], ["SameSite", "None"]];
|
|
2825
|
-
var createCookieString = ({
|
|
2826
|
-
name,
|
|
2827
|
-
value,
|
|
2828
|
-
expires
|
|
2829
|
-
}) => {
|
|
2830
|
-
const secure = isBrowser() ? location.protocol === "https:" : true;
|
|
2831
|
-
const secureObj = secure ? SECURE_CONFIG : [[]];
|
|
2832
|
-
const expiresObj = expires ? [["expires", expires.toUTCString()]] : [[]];
|
|
2833
|
-
const cookieValue = [[name, value], ...expiresObj, ["path", "/"], ["domain", getTopLevelDomain(window.location.hostname)], ...secureObj];
|
|
2834
|
-
const cookie = stringifyCookie(cookieValue);
|
|
2835
|
-
return cookie;
|
|
2836
|
-
};
|
|
2837
|
-
var setCookie = (_0) => __async(void 0, [_0], function* ({
|
|
2838
|
-
name,
|
|
2839
|
-
value,
|
|
2840
|
-
expires,
|
|
2841
|
-
canTrack
|
|
2842
|
-
}) {
|
|
2843
|
-
try {
|
|
2844
|
-
if (!canTrack) {
|
|
2845
|
-
return;
|
|
2846
|
-
}
|
|
2847
|
-
const cookie = createCookieString({
|
|
2848
|
-
name,
|
|
2849
|
-
value,
|
|
2850
|
-
expires
|
|
2851
|
-
});
|
|
2852
|
-
document.cookie = cookie;
|
|
2853
|
-
} catch (err) {
|
|
2854
|
-
logger.warn("[COOKIE] SET error: ", (err == null ? void 0 : err.message) || err);
|
|
2855
|
-
}
|
|
2856
|
-
});
|
|
2857
|
-
|
|
2858
|
-
// src/helpers/uuid.js
|
|
2859
|
-
function uuidv4() {
|
|
2860
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
2861
|
-
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
|
2862
|
-
return v.toString(16);
|
|
2863
|
-
});
|
|
2864
|
-
}
|
|
2865
|
-
function uuid() {
|
|
2866
|
-
return uuidv4().replace(/-/g, "");
|
|
2867
|
-
}
|
|
2868
|
-
|
|
2869
|
-
// src/helpers/sessionId.js
|
|
2870
|
-
var __async2 = (__this, __arguments, generator) => {
|
|
2871
|
-
return new Promise((resolve, reject) => {
|
|
2872
|
-
var fulfilled = (value) => {
|
|
2873
|
-
try {
|
|
2874
|
-
step(generator.next(value));
|
|
2875
|
-
} catch (e) {
|
|
2876
|
-
reject(e);
|
|
2877
|
-
}
|
|
2878
|
-
};
|
|
2879
|
-
var rejected = (value) => {
|
|
2880
|
-
try {
|
|
2881
|
-
step(generator.throw(value));
|
|
2882
|
-
} catch (e) {
|
|
2883
|
-
reject(e);
|
|
2884
|
-
}
|
|
2885
|
-
};
|
|
2886
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
2887
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
2888
|
-
});
|
|
2889
|
-
};
|
|
2890
|
-
var SESSION_LOCAL_STORAGE_KEY = "builderSessionId";
|
|
2891
|
-
var getSessionId = (_0) => __async2(void 0, [_0], function* ({
|
|
2892
|
-
canTrack
|
|
2893
|
-
}) {
|
|
2894
|
-
if (!canTrack) {
|
|
2895
|
-
return void 0;
|
|
2896
|
-
}
|
|
2897
|
-
const sessionId = yield getCookie({
|
|
2898
|
-
name: SESSION_LOCAL_STORAGE_KEY,
|
|
2899
|
-
canTrack
|
|
2900
|
-
});
|
|
2901
|
-
if (checkIsDefined(sessionId)) {
|
|
2902
|
-
return sessionId;
|
|
2903
|
-
} else {
|
|
2904
|
-
const newSessionId = createSessionId();
|
|
2905
|
-
setSessionId({
|
|
2906
|
-
id: newSessionId,
|
|
2907
|
-
canTrack
|
|
2908
|
-
});
|
|
2909
|
-
return newSessionId;
|
|
2910
|
-
}
|
|
2911
|
-
});
|
|
2912
|
-
var createSessionId = () => uuid();
|
|
2913
|
-
var setSessionId = ({
|
|
2914
|
-
id,
|
|
2915
|
-
canTrack
|
|
2916
|
-
}) => setCookie({
|
|
2917
|
-
name: SESSION_LOCAL_STORAGE_KEY,
|
|
2918
|
-
value: id,
|
|
2919
|
-
canTrack
|
|
2920
|
-
});
|
|
2921
|
-
|
|
2922
|
-
// src/helpers/localStorage.js
|
|
2923
|
-
var getLocalStorage = () => isBrowser() && typeof localStorage !== "undefined" ? localStorage : void 0;
|
|
2924
|
-
var getLocalStorageItem = ({
|
|
2925
|
-
key,
|
|
2926
|
-
canTrack
|
|
2927
|
-
}) => {
|
|
2928
|
-
var _a;
|
|
2929
|
-
try {
|
|
2930
|
-
if (canTrack) {
|
|
2931
|
-
return (_a = getLocalStorage()) == null ? void 0 : _a.getItem(key);
|
|
2932
|
-
}
|
|
2933
|
-
return void 0;
|
|
2934
|
-
} catch (err) {
|
|
2935
|
-
console.debug("[LocalStorage] GET error: ", err);
|
|
2936
|
-
return void 0;
|
|
2937
|
-
}
|
|
2938
|
-
};
|
|
2939
|
-
var setLocalStorageItem = ({
|
|
2940
|
-
key,
|
|
2941
|
-
canTrack,
|
|
2942
|
-
value
|
|
2943
|
-
}) => {
|
|
2944
|
-
var _a;
|
|
2945
|
-
try {
|
|
2946
|
-
if (canTrack) {
|
|
2947
|
-
(_a = getLocalStorage()) == null ? void 0 : _a.setItem(key, value);
|
|
2948
|
-
}
|
|
2949
|
-
} catch (err) {
|
|
2950
|
-
console.debug("[LocalStorage] SET error: ", err);
|
|
2951
|
-
}
|
|
2952
|
-
};
|
|
2953
|
-
|
|
2954
|
-
// src/helpers/visitorId.js
|
|
2955
|
-
var VISITOR_LOCAL_STORAGE_KEY = "builderVisitorId";
|
|
2956
|
-
var getVisitorId = ({
|
|
2957
|
-
canTrack
|
|
2958
|
-
}) => {
|
|
2959
|
-
if (!canTrack) {
|
|
2960
|
-
return void 0;
|
|
2961
|
-
}
|
|
2962
|
-
const visitorId = getLocalStorageItem({
|
|
2963
|
-
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
2964
|
-
canTrack
|
|
2965
|
-
});
|
|
2966
|
-
if (checkIsDefined(visitorId)) {
|
|
2967
|
-
return visitorId;
|
|
2968
|
-
} else {
|
|
2969
|
-
const newVisitorId = createVisitorId();
|
|
2970
|
-
setVisitorId({
|
|
2971
|
-
id: newVisitorId,
|
|
2972
|
-
canTrack
|
|
2973
|
-
});
|
|
2974
|
-
return newVisitorId;
|
|
2975
|
-
}
|
|
2976
|
-
};
|
|
2977
|
-
var createVisitorId = () => uuid();
|
|
2978
|
-
var setVisitorId = ({
|
|
2979
|
-
id,
|
|
2980
|
-
canTrack
|
|
2981
|
-
}) => setLocalStorageItem({
|
|
2982
|
-
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
2983
|
-
value: id,
|
|
2984
|
-
canTrack
|
|
2985
|
-
});
|
|
2986
|
-
|
|
2987
|
-
// src/functions/track/index.js
|
|
2988
|
-
var __defProp12 = Object.defineProperty;
|
|
2989
|
-
var __defProps9 = Object.defineProperties;
|
|
2990
|
-
var __getOwnPropDescs9 = Object.getOwnPropertyDescriptors;
|
|
2991
|
-
var __getOwnPropSymbols12 = Object.getOwnPropertySymbols;
|
|
2992
|
-
var __hasOwnProp12 = Object.prototype.hasOwnProperty;
|
|
2993
|
-
var __propIsEnum12 = Object.prototype.propertyIsEnumerable;
|
|
2994
|
-
var __defNormalProp12 = (obj, key, value) => key in obj ? __defProp12(obj, key, {
|
|
2995
|
-
enumerable: true,
|
|
2996
|
-
configurable: true,
|
|
2997
|
-
writable: true,
|
|
2998
|
-
value
|
|
2999
|
-
}) : obj[key] = value;
|
|
3000
|
-
var __spreadValues12 = (a, b) => {
|
|
3001
|
-
for (var prop in b || (b = {}))
|
|
3002
|
-
if (__hasOwnProp12.call(b, prop))
|
|
3003
|
-
__defNormalProp12(a, prop, b[prop]);
|
|
3004
|
-
if (__getOwnPropSymbols12)
|
|
3005
|
-
for (var prop of __getOwnPropSymbols12(b)) {
|
|
3006
|
-
if (__propIsEnum12.call(b, prop))
|
|
3007
|
-
__defNormalProp12(a, prop, b[prop]);
|
|
3008
|
-
}
|
|
3009
|
-
return a;
|
|
3010
|
-
};
|
|
3011
|
-
var __spreadProps9 = (a, b) => __defProps9(a, __getOwnPropDescs9(b));
|
|
3012
|
-
var __objRest3 = (source, exclude) => {
|
|
3013
|
-
var target = {};
|
|
3014
|
-
for (var prop in source)
|
|
3015
|
-
if (__hasOwnProp12.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
3016
|
-
target[prop] = source[prop];
|
|
3017
|
-
if (source != null && __getOwnPropSymbols12)
|
|
3018
|
-
for (var prop of __getOwnPropSymbols12(source)) {
|
|
3019
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum12.call(source, prop))
|
|
3020
|
-
target[prop] = source[prop];
|
|
3021
|
-
}
|
|
3022
|
-
return target;
|
|
3023
|
-
};
|
|
3024
|
-
var __async3 = (__this, __arguments, generator) => {
|
|
3025
|
-
return new Promise((resolve, reject) => {
|
|
3026
|
-
var fulfilled = (value) => {
|
|
3027
|
-
try {
|
|
3028
|
-
step(generator.next(value));
|
|
3029
|
-
} catch (e) {
|
|
3030
|
-
reject(e);
|
|
3031
|
-
}
|
|
3032
|
-
};
|
|
3033
|
-
var rejected = (value) => {
|
|
3034
|
-
try {
|
|
3035
|
-
step(generator.throw(value));
|
|
3036
|
-
} catch (e) {
|
|
3037
|
-
reject(e);
|
|
2488
|
+
function getCookie2(name) {
|
|
2489
|
+
const nameEQ = name + "=";
|
|
2490
|
+
const ca = document.cookie.split(";");
|
|
2491
|
+
for (let i = 0; i < ca.length; i++) {
|
|
2492
|
+
let c = ca[i];
|
|
2493
|
+
while (c.charAt(0) === " ")
|
|
2494
|
+
c = c.substring(1, c.length);
|
|
2495
|
+
if (c.indexOf(nameEQ) === 0)
|
|
2496
|
+
return c.substring(nameEQ.length, c.length);
|
|
3038
2497
|
}
|
|
3039
|
-
|
|
3040
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
3041
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
3042
|
-
});
|
|
3043
|
-
};
|
|
3044
|
-
var getTrackingEventData = (_0) => __async3(void 0, [_0], function* ({
|
|
3045
|
-
canTrack
|
|
3046
|
-
}) {
|
|
3047
|
-
if (!canTrack) {
|
|
3048
|
-
return {
|
|
3049
|
-
visitorId: void 0,
|
|
3050
|
-
sessionId: void 0
|
|
3051
|
-
};
|
|
3052
|
-
}
|
|
3053
|
-
const sessionId = yield getSessionId({
|
|
3054
|
-
canTrack
|
|
3055
|
-
});
|
|
3056
|
-
const visitorId = getVisitorId({
|
|
3057
|
-
canTrack
|
|
3058
|
-
});
|
|
3059
|
-
return {
|
|
3060
|
-
sessionId,
|
|
3061
|
-
visitorId
|
|
3062
|
-
};
|
|
3063
|
-
});
|
|
3064
|
-
var createEvent = (_a) => __async3(void 0, null, function* () {
|
|
3065
|
-
var _b = _a, {
|
|
3066
|
-
type: eventType,
|
|
3067
|
-
canTrack,
|
|
3068
|
-
apiKey,
|
|
3069
|
-
metadata
|
|
3070
|
-
} = _b, properties = __objRest3(_b, ["type", "canTrack", "apiKey", "metadata"]);
|
|
3071
|
-
return {
|
|
3072
|
-
type: eventType,
|
|
3073
|
-
data: __spreadProps9(__spreadValues12(__spreadProps9(__spreadValues12({}, properties), {
|
|
3074
|
-
metadata: __spreadValues12({
|
|
3075
|
-
url: location.href
|
|
3076
|
-
}, metadata)
|
|
3077
|
-
}), yield getTrackingEventData({
|
|
3078
|
-
canTrack
|
|
3079
|
-
})), {
|
|
3080
|
-
userAttributes: getUserAttributes(),
|
|
3081
|
-
ownerId: apiKey
|
|
3082
|
-
})
|
|
3083
|
-
};
|
|
3084
|
-
});
|
|
3085
|
-
function _track(eventProps) {
|
|
3086
|
-
return __async3(this, null, function* () {
|
|
3087
|
-
if (!eventProps.apiKey) {
|
|
3088
|
-
logger.error("Missing API key for track call. Please provide your API key.");
|
|
3089
|
-
return;
|
|
3090
|
-
}
|
|
3091
|
-
if (!eventProps.canTrack) {
|
|
3092
|
-
return;
|
|
3093
|
-
}
|
|
3094
|
-
if (isEditing()) {
|
|
3095
|
-
return;
|
|
3096
|
-
}
|
|
3097
|
-
if (!(isBrowser() || TARGET === "reactNative")) {
|
|
3098
|
-
return;
|
|
2498
|
+
return null;
|
|
3099
2499
|
}
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
headers: {
|
|
3106
|
-
"content-type": "application/json"
|
|
3107
|
-
},
|
|
3108
|
-
mode: "cors"
|
|
3109
|
-
}).catch((err) => {
|
|
3110
|
-
console.error("Failed to track: ", err);
|
|
3111
|
-
});
|
|
3112
|
-
});
|
|
3113
|
-
}
|
|
3114
|
-
var track = (args) => _track(__spreadProps9(__spreadValues12({}, args), {
|
|
3115
|
-
canTrack: true
|
|
3116
|
-
}));
|
|
3117
|
-
|
|
3118
|
-
// src/constants/sdk-version.js
|
|
3119
|
-
var SDK_VERSION = "0.7.1-1";
|
|
3120
|
-
|
|
3121
|
-
// src/functions/register.js
|
|
3122
|
-
var registry = {};
|
|
3123
|
-
function register(type, info) {
|
|
3124
|
-
let typeList = registry[type];
|
|
3125
|
-
if (!typeList) {
|
|
3126
|
-
typeList = registry[type] = [];
|
|
3127
|
-
}
|
|
3128
|
-
typeList.push(info);
|
|
3129
|
-
if (isBrowser()) {
|
|
3130
|
-
const message = {
|
|
3131
|
-
type: "builder.register",
|
|
3132
|
-
data: {
|
|
3133
|
-
type,
|
|
3134
|
-
info
|
|
3135
|
-
}
|
|
3136
|
-
};
|
|
3137
|
-
try {
|
|
3138
|
-
parent.postMessage(message, "*");
|
|
3139
|
-
if (parent !== window) {
|
|
3140
|
-
window.postMessage(message, "*");
|
|
3141
|
-
}
|
|
3142
|
-
} catch (err) {
|
|
3143
|
-
console.debug("Could not postmessage", err);
|
|
2500
|
+
const cookieName = `builder.tests.${contentId}`;
|
|
2501
|
+
const variantInCookie = getCookie2(cookieName);
|
|
2502
|
+
const availableIDs = variants.map((vr) => vr.id).concat(contentId);
|
|
2503
|
+
if (variantInCookie && availableIDs.includes(variantInCookie)) {
|
|
2504
|
+
return variantInCookie;
|
|
3144
2505
|
}
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
name: "Box"
|
|
3155
|
-
}, {
|
|
3156
|
-
name: "Text"
|
|
3157
|
-
}, {
|
|
3158
|
-
name: "Image"
|
|
3159
|
-
}, {
|
|
3160
|
-
name: "Columns"
|
|
3161
|
-
}, ...TARGET === "reactNative" ? [] : [{
|
|
3162
|
-
name: "Core:Section"
|
|
3163
|
-
}, {
|
|
3164
|
-
name: "Core:Button"
|
|
3165
|
-
}, {
|
|
3166
|
-
name: "Embed"
|
|
3167
|
-
}, {
|
|
3168
|
-
name: "Custom Code"
|
|
3169
|
-
}]]
|
|
3170
|
-
});
|
|
3171
|
-
};
|
|
3172
|
-
var isSetupForEditing = false;
|
|
3173
|
-
var setupBrowserForEditing = (options = {}) => {
|
|
3174
|
-
var _a, _b;
|
|
3175
|
-
if (isSetupForEditing) {
|
|
3176
|
-
return;
|
|
3177
|
-
}
|
|
3178
|
-
isSetupForEditing = true;
|
|
3179
|
-
if (isBrowser()) {
|
|
3180
|
-
(_a = window.parent) == null ? void 0 : _a.postMessage({
|
|
3181
|
-
type: "builder.sdkInfo",
|
|
3182
|
-
data: {
|
|
3183
|
-
target: TARGET,
|
|
3184
|
-
version: SDK_VERSION,
|
|
3185
|
-
supportsPatchUpdates: false,
|
|
3186
|
-
supportsAddBlockScoping: true,
|
|
3187
|
-
supportsCustomBreakpoints: true
|
|
3188
|
-
}
|
|
3189
|
-
}, "*");
|
|
3190
|
-
(_b = window.parent) == null ? void 0 : _b.postMessage({
|
|
3191
|
-
type: "builder.updateContent",
|
|
3192
|
-
data: {
|
|
3193
|
-
options
|
|
3194
|
-
}
|
|
3195
|
-
}, "*");
|
|
3196
|
-
window.addEventListener("message", ({
|
|
3197
|
-
data
|
|
3198
|
-
}) => {
|
|
3199
|
-
var _a2, _b2;
|
|
3200
|
-
if (!(data == null ? void 0 : data.type)) {
|
|
3201
|
-
return;
|
|
3202
|
-
}
|
|
3203
|
-
switch (data.type) {
|
|
3204
|
-
case "builder.evaluate": {
|
|
3205
|
-
const text = data.data.text;
|
|
3206
|
-
const args = data.data.arguments || [];
|
|
3207
|
-
const id = data.data.id;
|
|
3208
|
-
const fn = new Function(text);
|
|
3209
|
-
let result;
|
|
3210
|
-
let error = null;
|
|
3211
|
-
try {
|
|
3212
|
-
result = fn.apply(null, args);
|
|
3213
|
-
} catch (err) {
|
|
3214
|
-
error = err;
|
|
3215
|
-
}
|
|
3216
|
-
if (error) {
|
|
3217
|
-
(_a2 = window.parent) == null ? void 0 : _a2.postMessage({
|
|
3218
|
-
type: "builder.evaluateError",
|
|
3219
|
-
data: {
|
|
3220
|
-
id,
|
|
3221
|
-
error: error.message
|
|
3222
|
-
}
|
|
3223
|
-
}, "*");
|
|
3224
|
-
} else {
|
|
3225
|
-
if (result && typeof result.then === "function") {
|
|
3226
|
-
result.then((finalResult) => {
|
|
3227
|
-
var _a3;
|
|
3228
|
-
(_a3 = window.parent) == null ? void 0 : _a3.postMessage({
|
|
3229
|
-
type: "builder.evaluateResult",
|
|
3230
|
-
data: {
|
|
3231
|
-
id,
|
|
3232
|
-
result: finalResult
|
|
3233
|
-
}
|
|
3234
|
-
}, "*");
|
|
3235
|
-
}).catch(console.error);
|
|
3236
|
-
} else {
|
|
3237
|
-
(_b2 = window.parent) == null ? void 0 : _b2.postMessage({
|
|
3238
|
-
type: "builder.evaluateResult",
|
|
3239
|
-
data: {
|
|
3240
|
-
result,
|
|
3241
|
-
id
|
|
3242
|
-
}
|
|
3243
|
-
}, "*");
|
|
3244
|
-
}
|
|
3245
|
-
}
|
|
3246
|
-
break;
|
|
3247
|
-
}
|
|
2506
|
+
let n = 0;
|
|
2507
|
+
const random = Math.random();
|
|
2508
|
+
for (let i = 0; i < variants.length; i++) {
|
|
2509
|
+
const variant = variants[i];
|
|
2510
|
+
const testRatio = variant.testRatio;
|
|
2511
|
+
n += testRatio;
|
|
2512
|
+
if (random < n) {
|
|
2513
|
+
setCookie2(cookieName, variant.id);
|
|
2514
|
+
return variant.id;
|
|
3248
2515
|
}
|
|
3249
|
-
}
|
|
2516
|
+
}
|
|
2517
|
+
setCookie2(cookieName, contentId);
|
|
2518
|
+
return contentId;
|
|
2519
|
+
}
|
|
2520
|
+
const winningVariantId = getAndSetVariantId2();
|
|
2521
|
+
const styleEl = document.currentScript?.previousElementSibling;
|
|
2522
|
+
if (isHydrationTarget2) {
|
|
2523
|
+
styleEl.remove();
|
|
2524
|
+
const thisScriptEl = document.currentScript;
|
|
2525
|
+
thisScriptEl?.remove();
|
|
2526
|
+
} else {
|
|
2527
|
+
const newStyleStr = variants.concat({
|
|
2528
|
+
id: contentId
|
|
2529
|
+
}).filter((variant) => variant.id !== winningVariantId).map((value) => {
|
|
2530
|
+
return `.variant-${value.id} { display: none; }
|
|
2531
|
+
`;
|
|
2532
|
+
}).join("");
|
|
2533
|
+
styleEl.innerHTML = newStyleStr;
|
|
3250
2534
|
}
|
|
3251
|
-
};
|
|
3252
|
-
|
|
3253
|
-
// src/functions/track/interaction.js
|
|
3254
|
-
function round(num) {
|
|
3255
|
-
return Math.round(num * 1e3) / 1e3;
|
|
3256
2535
|
}
|
|
3257
|
-
|
|
3258
|
-
if (!
|
|
3259
|
-
return
|
|
2536
|
+
function bldrCntntScrpt(variantContentId, defaultContentId, isHydrationTarget2) {
|
|
2537
|
+
if (!navigator.cookieEnabled) {
|
|
2538
|
+
return;
|
|
3260
2539
|
}
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
} while (parent2 = parent2.parentElement);
|
|
3271
|
-
return null;
|
|
3272
|
-
};
|
|
3273
|
-
var findBuilderParent = (target) => findParentElement(target, (el) => {
|
|
3274
|
-
const id = el.getAttribute("builder-id") || el.id;
|
|
3275
|
-
return Boolean((id == null ? void 0 : id.indexOf("builder-")) === 0);
|
|
3276
|
-
});
|
|
3277
|
-
var computeOffset = ({
|
|
3278
|
-
event,
|
|
3279
|
-
target
|
|
3280
|
-
}) => {
|
|
3281
|
-
const targetRect = target.getBoundingClientRect();
|
|
3282
|
-
const xOffset = event.clientX - targetRect.left;
|
|
3283
|
-
const yOffset = event.clientY - targetRect.top;
|
|
3284
|
-
const xRatio = round(xOffset / targetRect.width);
|
|
3285
|
-
const yRatio = round(yOffset / targetRect.height);
|
|
3286
|
-
return {
|
|
3287
|
-
x: xRatio,
|
|
3288
|
-
y: yRatio
|
|
3289
|
-
};
|
|
3290
|
-
};
|
|
3291
|
-
var getInteractionPropertiesForEvent = (event) => {
|
|
3292
|
-
const target = event.target;
|
|
3293
|
-
const targetBuilderElement = target && findBuilderParent(target);
|
|
3294
|
-
const builderId = (targetBuilderElement == null ? void 0 : targetBuilderElement.getAttribute("builder-id")) || (targetBuilderElement == null ? void 0 : targetBuilderElement.id);
|
|
3295
|
-
return {
|
|
3296
|
-
targetBuilderElement: builderId || void 0,
|
|
3297
|
-
metadata: {
|
|
3298
|
-
targetOffset: target ? computeOffset({
|
|
3299
|
-
event,
|
|
3300
|
-
target
|
|
3301
|
-
}) : void 0,
|
|
3302
|
-
builderTargetOffset: targetBuilderElement ? computeOffset({
|
|
3303
|
-
event,
|
|
3304
|
-
target: targetBuilderElement
|
|
3305
|
-
}) : void 0,
|
|
3306
|
-
builderElementIndex: targetBuilderElement && builderId ? [].slice.call(document.getElementsByClassName(builderId)).indexOf(targetBuilderElement) : void 0
|
|
2540
|
+
function getCookie2(name) {
|
|
2541
|
+
const nameEQ = name + "=";
|
|
2542
|
+
const ca = document.cookie.split(";");
|
|
2543
|
+
for (let i = 0; i < ca.length; i++) {
|
|
2544
|
+
let c = ca[i];
|
|
2545
|
+
while (c.charAt(0) === " ")
|
|
2546
|
+
c = c.substring(1, c.length);
|
|
2547
|
+
if (c.indexOf(nameEQ) === 0)
|
|
2548
|
+
return c.substring(nameEQ.length, c.length);
|
|
3307
2549
|
}
|
|
3308
|
-
|
|
3309
|
-
}
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
enumerable: true,
|
|
3318
|
-
configurable: true,
|
|
3319
|
-
writable: true,
|
|
3320
|
-
value
|
|
3321
|
-
}) : obj[key] = value;
|
|
3322
|
-
var __spreadValues13 = (a, b) => {
|
|
3323
|
-
for (var prop in b || (b = {}))
|
|
3324
|
-
if (__hasOwnProp13.call(b, prop))
|
|
3325
|
-
__defNormalProp13(a, prop, b[prop]);
|
|
3326
|
-
if (__getOwnPropSymbols13)
|
|
3327
|
-
for (var prop of __getOwnPropSymbols13(b)) {
|
|
3328
|
-
if (__propIsEnum13.call(b, prop))
|
|
3329
|
-
__defNormalProp13(a, prop, b[prop]);
|
|
2550
|
+
return null;
|
|
2551
|
+
}
|
|
2552
|
+
const cookieName = `builder.tests.${defaultContentId}`;
|
|
2553
|
+
const variantId = getCookie2(cookieName);
|
|
2554
|
+
const parentDiv = document.currentScript?.parentElement;
|
|
2555
|
+
const variantIsDefaultContent = variantContentId === defaultContentId;
|
|
2556
|
+
if (variantId === variantContentId) {
|
|
2557
|
+
if (variantIsDefaultContent) {
|
|
2558
|
+
return;
|
|
3330
2559
|
}
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
}
|
|
3341
|
-
};
|
|
3342
|
-
var rejected = (value) => {
|
|
3343
|
-
try {
|
|
3344
|
-
step(generator.throw(value));
|
|
3345
|
-
} catch (e) {
|
|
3346
|
-
reject(e);
|
|
2560
|
+
parentDiv?.removeAttribute("hidden");
|
|
2561
|
+
parentDiv?.removeAttribute("aria-hidden");
|
|
2562
|
+
} else {
|
|
2563
|
+
if (variantIsDefaultContent) {
|
|
2564
|
+
if (isHydrationTarget2) {
|
|
2565
|
+
parentDiv?.remove();
|
|
2566
|
+
} else {
|
|
2567
|
+
parentDiv?.setAttribute("hidden", "true");
|
|
2568
|
+
parentDiv?.setAttribute("aria-hidden", "true");
|
|
3347
2569
|
}
|
|
3348
|
-
};
|
|
3349
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
3350
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
3351
|
-
});
|
|
3352
|
-
};
|
|
3353
|
-
var BUILDER_STORE_PREFIX = "builder.tests";
|
|
3354
|
-
var getContentTestKey = (id) => `${BUILDER_STORE_PREFIX}.${id}`;
|
|
3355
|
-
var getContentVariationCookie = ({
|
|
3356
|
-
contentId
|
|
3357
|
-
}) => getCookie({
|
|
3358
|
-
name: getContentTestKey(contentId),
|
|
3359
|
-
canTrack: true
|
|
3360
|
-
});
|
|
3361
|
-
var getContentVariationCookieSync = ({
|
|
3362
|
-
contentId
|
|
3363
|
-
}) => getCookieSync({
|
|
3364
|
-
name: getContentTestKey(contentId),
|
|
3365
|
-
canTrack: true
|
|
3366
|
-
});
|
|
3367
|
-
var setContentVariationCookie = ({
|
|
3368
|
-
contentId,
|
|
3369
|
-
value
|
|
3370
|
-
}) => setCookie({
|
|
3371
|
-
name: getContentTestKey(contentId),
|
|
3372
|
-
value,
|
|
3373
|
-
canTrack: true
|
|
3374
|
-
});
|
|
3375
|
-
var checkIsBuilderContentWithVariations = (item) => checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
|
|
3376
|
-
var getRandomVariationId = ({
|
|
3377
|
-
id,
|
|
3378
|
-
variations
|
|
3379
|
-
}) => {
|
|
3380
|
-
var _a;
|
|
3381
|
-
let n = 0;
|
|
3382
|
-
const random = Math.random();
|
|
3383
|
-
for (const id2 in variations) {
|
|
3384
|
-
const testRatio = (_a = variations[id2]) == null ? void 0 : _a.testRatio;
|
|
3385
|
-
n += testRatio;
|
|
3386
|
-
if (random < n) {
|
|
3387
|
-
return id2;
|
|
3388
2570
|
}
|
|
2571
|
+
return;
|
|
3389
2572
|
}
|
|
3390
|
-
return
|
|
2573
|
+
return;
|
|
2574
|
+
}
|
|
2575
|
+
var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
|
|
2576
|
+
var isHydrationTarget = getIsHydrationTarget(TARGET);
|
|
2577
|
+
var AB_TEST_FN_NAME = "builderIoAbTest";
|
|
2578
|
+
var CONTENT_FN_NAME = "builderIoRenderContent";
|
|
2579
|
+
var getScriptString = () => {
|
|
2580
|
+
const fnStr = bldrAbTest.toString().replace(/\s+/g, " ");
|
|
2581
|
+
const fnStr2 = bldrCntntScrpt.toString().replace(/\s+/g, " ");
|
|
2582
|
+
return `
|
|
2583
|
+
window.${AB_TEST_FN_NAME} = ${fnStr}
|
|
2584
|
+
window.${CONTENT_FN_NAME} = ${fnStr2}
|
|
2585
|
+
`;
|
|
3391
2586
|
};
|
|
3392
|
-
var
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
contentId: args.id,
|
|
3396
|
-
value: randomVariationId
|
|
3397
|
-
}).catch((err) => {
|
|
3398
|
-
logger.error("could not store A/B test variation: ", err);
|
|
3399
|
-
});
|
|
3400
|
-
return randomVariationId;
|
|
2587
|
+
var getVariantsScriptString = (variants, contentId) => {
|
|
2588
|
+
return `
|
|
2589
|
+
window.${AB_TEST_FN_NAME}("${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget})`;
|
|
3401
2590
|
};
|
|
3402
|
-
var
|
|
3403
|
-
|
|
3404
|
-
|
|
2591
|
+
var getRenderContentScriptString = ({
|
|
2592
|
+
contentId,
|
|
2593
|
+
variationId
|
|
3405
2594
|
}) => {
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
return {
|
|
3409
|
-
testVariationId: item.id,
|
|
3410
|
-
testVariationName: "Default"
|
|
3411
|
-
};
|
|
3412
|
-
} else {
|
|
3413
|
-
return {
|
|
3414
|
-
data: variationValue.data,
|
|
3415
|
-
testVariationId: variationValue.id,
|
|
3416
|
-
testVariationName: variationValue.name || (variationValue.id === item.id ? "Default" : "")
|
|
3417
|
-
};
|
|
3418
|
-
}
|
|
2595
|
+
return `
|
|
2596
|
+
window.${CONTENT_FN_NAME}("${variationId}", "${contentId}", ${isHydrationTarget})`;
|
|
3419
2597
|
};
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
}
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
2598
|
+
|
|
2599
|
+
// src/components/inlined-script.tsx
|
|
2600
|
+
function InlinedScript(props) {
|
|
2601
|
+
return <script innerHTML={props.scriptStr} id={props.id} />;
|
|
2602
|
+
}
|
|
2603
|
+
var Inlined_script_default = InlinedScript;
|
|
2604
|
+
|
|
2605
|
+
// src/components/content/components/enable-editor.tsx
|
|
2606
|
+
import { Show as Show9, onMount as onMount2, on as on2, createEffect as createEffect2, createSignal as createSignal9 } from "solid-js";
|
|
2607
|
+
|
|
2608
|
+
// src/helpers/preview-lru-cache/get.ts
|
|
2609
|
+
function getPreviewContent(_searchParams) {
|
|
2610
|
+
return void 0;
|
|
2611
|
+
}
|
|
2612
|
+
|
|
2613
|
+
// src/functions/get-global-this.ts
|
|
2614
|
+
function getGlobalThis() {
|
|
2615
|
+
if (typeof globalThis !== "undefined") {
|
|
2616
|
+
return globalThis;
|
|
3431
2617
|
}
|
|
3432
|
-
if (
|
|
3433
|
-
return
|
|
2618
|
+
if (typeof window !== "undefined") {
|
|
2619
|
+
return window;
|
|
3434
2620
|
}
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
}) || getAndSetVariantId({
|
|
3438
|
-
variations: item.variations,
|
|
3439
|
-
id: item.id
|
|
3440
|
-
});
|
|
3441
|
-
const variationValue = getTestFields({
|
|
3442
|
-
item,
|
|
3443
|
-
testGroupId
|
|
3444
|
-
});
|
|
3445
|
-
return __spreadValues13(__spreadValues13({}, item), variationValue);
|
|
3446
|
-
};
|
|
3447
|
-
var handleABTesting = (_0) => __async4(void 0, [_0], function* ({
|
|
3448
|
-
item,
|
|
3449
|
-
canTrack
|
|
3450
|
-
}) {
|
|
3451
|
-
if (!canTrack) {
|
|
3452
|
-
return item;
|
|
2621
|
+
if (typeof global !== "undefined") {
|
|
2622
|
+
return global;
|
|
3453
2623
|
}
|
|
3454
|
-
if (
|
|
3455
|
-
return
|
|
2624
|
+
if (typeof self !== "undefined") {
|
|
2625
|
+
return self;
|
|
3456
2626
|
}
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
});
|
|
3460
|
-
const testGroupId = cookieValue || getAndSetVariantId({
|
|
3461
|
-
variations: item.variations,
|
|
3462
|
-
id: item.id
|
|
3463
|
-
});
|
|
3464
|
-
const variationValue = getTestFields({
|
|
3465
|
-
item,
|
|
3466
|
-
testGroupId
|
|
3467
|
-
});
|
|
3468
|
-
return __spreadValues13(__spreadValues13({}, item), variationValue);
|
|
3469
|
-
});
|
|
3470
|
-
|
|
3471
|
-
// src/helpers/canTrack.js
|
|
3472
|
-
var getDefaultCanTrack = (canTrack) => checkIsDefined(canTrack) ? canTrack : true;
|
|
2627
|
+
return globalThis;
|
|
2628
|
+
}
|
|
3473
2629
|
|
|
3474
|
-
// src/
|
|
3475
|
-
function
|
|
3476
|
-
|
|
2630
|
+
// src/functions/get-fetch.ts
|
|
2631
|
+
function getFetch() {
|
|
2632
|
+
const globalFetch = getGlobalThis().fetch;
|
|
2633
|
+
if (typeof globalFetch === "undefined") {
|
|
2634
|
+
console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
|
|
2635
|
+
For more information, read https://github.com/BuilderIO/this-package-uses-fetch`);
|
|
2636
|
+
throw new Error("Builder SDK could not find a global `fetch` function");
|
|
2637
|
+
}
|
|
2638
|
+
return globalFetch;
|
|
3477
2639
|
}
|
|
2640
|
+
var fetch2 = getFetch();
|
|
3478
2641
|
|
|
3479
|
-
// src/helpers/flatten.
|
|
3480
|
-
var __defProp14 = Object.defineProperty;
|
|
3481
|
-
var __defProps10 = Object.defineProperties;
|
|
3482
|
-
var __getOwnPropDescs10 = Object.getOwnPropertyDescriptors;
|
|
3483
|
-
var __getOwnPropSymbols14 = Object.getOwnPropertySymbols;
|
|
3484
|
-
var __hasOwnProp14 = Object.prototype.hasOwnProperty;
|
|
3485
|
-
var __propIsEnum14 = Object.prototype.propertyIsEnumerable;
|
|
3486
|
-
var __defNormalProp14 = (obj, key, value) => key in obj ? __defProp14(obj, key, {
|
|
3487
|
-
enumerable: true,
|
|
3488
|
-
configurable: true,
|
|
3489
|
-
writable: true,
|
|
3490
|
-
value
|
|
3491
|
-
}) : obj[key] = value;
|
|
3492
|
-
var __spreadValues14 = (a, b) => {
|
|
3493
|
-
for (var prop in b || (b = {}))
|
|
3494
|
-
if (__hasOwnProp14.call(b, prop))
|
|
3495
|
-
__defNormalProp14(a, prop, b[prop]);
|
|
3496
|
-
if (__getOwnPropSymbols14)
|
|
3497
|
-
for (var prop of __getOwnPropSymbols14(b)) {
|
|
3498
|
-
if (__propIsEnum14.call(b, prop))
|
|
3499
|
-
__defNormalProp14(a, prop, b[prop]);
|
|
3500
|
-
}
|
|
3501
|
-
return a;
|
|
3502
|
-
};
|
|
3503
|
-
var __spreadProps10 = (a, b) => __defProps10(a, __getOwnPropDescs10(b));
|
|
2642
|
+
// src/helpers/flatten.ts
|
|
3504
2643
|
function flatten(object, path = null, separator = ".") {
|
|
3505
2644
|
return Object.keys(object).reduce((acc, key) => {
|
|
3506
2645
|
const value = object[key];
|
|
3507
2646
|
const newPath = [path, key].filter(Boolean).join(separator);
|
|
3508
2647
|
const isObject = [typeof value === "object", value !== null, !(Array.isArray(value) && value.length === 0)].every(Boolean);
|
|
3509
|
-
return isObject ?
|
|
2648
|
+
return isObject ? {
|
|
2649
|
+
...acc,
|
|
2650
|
+
...flatten(value, newPath, separator)
|
|
2651
|
+
} : {
|
|
2652
|
+
...acc,
|
|
3510
2653
|
[newPath]: value
|
|
3511
|
-
}
|
|
2654
|
+
};
|
|
3512
2655
|
}, {});
|
|
3513
2656
|
}
|
|
3514
2657
|
|
|
3515
|
-
// src/
|
|
2658
|
+
// src/types/api-version.ts
|
|
2659
|
+
var DEFAULT_API_VERSION = "v3";
|
|
2660
|
+
|
|
2661
|
+
// src/functions/get-builder-search-params/index.ts
|
|
3516
2662
|
var BUILDER_SEARCHPARAMS_PREFIX = "builder.";
|
|
3517
2663
|
var BUILDER_OPTIONS_PREFIX = "options.";
|
|
3518
2664
|
var convertSearchParamsToQueryObject = (searchParams) => {
|
|
@@ -3545,31 +2691,7 @@ var getBuilderSearchParamsFromWindow = () => {
|
|
|
3545
2691
|
};
|
|
3546
2692
|
var normalizeSearchParams = (searchParams) => searchParams instanceof URLSearchParams ? convertSearchParamsToQueryObject(searchParams) : searchParams;
|
|
3547
2693
|
|
|
3548
|
-
// src/
|
|
3549
|
-
var DEFAULT_API_VERSION = "v3";
|
|
3550
|
-
|
|
3551
|
-
// src/functions/get-content/generate-content-url.js
|
|
3552
|
-
var __defProp15 = Object.defineProperty;
|
|
3553
|
-
var __getOwnPropSymbols15 = Object.getOwnPropertySymbols;
|
|
3554
|
-
var __hasOwnProp15 = Object.prototype.hasOwnProperty;
|
|
3555
|
-
var __propIsEnum15 = Object.prototype.propertyIsEnumerable;
|
|
3556
|
-
var __defNormalProp15 = (obj, key, value) => key in obj ? __defProp15(obj, key, {
|
|
3557
|
-
enumerable: true,
|
|
3558
|
-
configurable: true,
|
|
3559
|
-
writable: true,
|
|
3560
|
-
value
|
|
3561
|
-
}) : obj[key] = value;
|
|
3562
|
-
var __spreadValues15 = (a, b) => {
|
|
3563
|
-
for (var prop in b || (b = {}))
|
|
3564
|
-
if (__hasOwnProp15.call(b, prop))
|
|
3565
|
-
__defNormalProp15(a, prop, b[prop]);
|
|
3566
|
-
if (__getOwnPropSymbols15)
|
|
3567
|
-
for (var prop of __getOwnPropSymbols15(b)) {
|
|
3568
|
-
if (__propIsEnum15.call(b, prop))
|
|
3569
|
-
__defNormalProp15(a, prop, b[prop]);
|
|
3570
|
-
}
|
|
3571
|
-
return a;
|
|
3572
|
-
};
|
|
2694
|
+
// src/functions/get-content/generate-content-url.ts
|
|
3573
2695
|
var isPositiveNumber = (thing) => typeof thing === "number" && !isNaN(thing) && thing >= 0;
|
|
3574
2696
|
var generateContentUrl = (options) => {
|
|
3575
2697
|
let {
|
|
@@ -3627,7 +2749,10 @@ var generateContentUrl = (options) => {
|
|
|
3627
2749
|
url.searchParams.set(key, JSON.stringify(flattened2[key]));
|
|
3628
2750
|
}
|
|
3629
2751
|
}
|
|
3630
|
-
const queryOptions =
|
|
2752
|
+
const queryOptions = {
|
|
2753
|
+
...getBuilderSearchParamsFromWindow(),
|
|
2754
|
+
...normalizeSearchParams(options.options || {})
|
|
2755
|
+
};
|
|
3631
2756
|
const flattened = flatten(queryOptions);
|
|
3632
2757
|
for (const key in flattened) {
|
|
3633
2758
|
url.searchParams.set(key, String(flattened[key]));
|
|
@@ -3646,71 +2771,26 @@ var generateContentUrl = (options) => {
|
|
|
3646
2771
|
return url;
|
|
3647
2772
|
};
|
|
3648
2773
|
|
|
3649
|
-
// src/functions/get-content/index.
|
|
3650
|
-
var __defProp16 = Object.defineProperty;
|
|
3651
|
-
var __defProps11 = Object.defineProperties;
|
|
3652
|
-
var __getOwnPropDescs11 = Object.getOwnPropertyDescriptors;
|
|
3653
|
-
var __getOwnPropSymbols16 = Object.getOwnPropertySymbols;
|
|
3654
|
-
var __hasOwnProp16 = Object.prototype.hasOwnProperty;
|
|
3655
|
-
var __propIsEnum16 = Object.prototype.propertyIsEnumerable;
|
|
3656
|
-
var __defNormalProp16 = (obj, key, value) => key in obj ? __defProp16(obj, key, {
|
|
3657
|
-
enumerable: true,
|
|
3658
|
-
configurable: true,
|
|
3659
|
-
writable: true,
|
|
3660
|
-
value
|
|
3661
|
-
}) : obj[key] = value;
|
|
3662
|
-
var __spreadValues16 = (a, b) => {
|
|
3663
|
-
for (var prop in b || (b = {}))
|
|
3664
|
-
if (__hasOwnProp16.call(b, prop))
|
|
3665
|
-
__defNormalProp16(a, prop, b[prop]);
|
|
3666
|
-
if (__getOwnPropSymbols16)
|
|
3667
|
-
for (var prop of __getOwnPropSymbols16(b)) {
|
|
3668
|
-
if (__propIsEnum16.call(b, prop))
|
|
3669
|
-
__defNormalProp16(a, prop, b[prop]);
|
|
3670
|
-
}
|
|
3671
|
-
return a;
|
|
3672
|
-
};
|
|
3673
|
-
var __spreadProps11 = (a, b) => __defProps11(a, __getOwnPropDescs11(b));
|
|
3674
|
-
var __async5 = (__this, __arguments, generator) => {
|
|
3675
|
-
return new Promise((resolve, reject) => {
|
|
3676
|
-
var fulfilled = (value) => {
|
|
3677
|
-
try {
|
|
3678
|
-
step(generator.next(value));
|
|
3679
|
-
} catch (e) {
|
|
3680
|
-
reject(e);
|
|
3681
|
-
}
|
|
3682
|
-
};
|
|
3683
|
-
var rejected = (value) => {
|
|
3684
|
-
try {
|
|
3685
|
-
step(generator.throw(value));
|
|
3686
|
-
} catch (e) {
|
|
3687
|
-
reject(e);
|
|
3688
|
-
}
|
|
3689
|
-
};
|
|
3690
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
3691
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
3692
|
-
});
|
|
3693
|
-
};
|
|
2774
|
+
// src/functions/get-content/index.ts
|
|
3694
2775
|
var checkContentHasResults = (content) => "results" in content;
|
|
3695
|
-
function fetchOneEntry(options) {
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
}));
|
|
3700
|
-
if (allContent) {
|
|
3701
|
-
return allContent.results[0] || null;
|
|
3702
|
-
}
|
|
3703
|
-
return null;
|
|
2776
|
+
async function fetchOneEntry(options) {
|
|
2777
|
+
const allContent = await fetchEntries({
|
|
2778
|
+
...options,
|
|
2779
|
+
limit: 1
|
|
3704
2780
|
});
|
|
2781
|
+
if (allContent) {
|
|
2782
|
+
return allContent.results[0] || null;
|
|
2783
|
+
}
|
|
2784
|
+
return null;
|
|
3705
2785
|
}
|
|
3706
2786
|
var getContent = fetchOneEntry;
|
|
3707
|
-
var _fetchContent = (options) =>
|
|
2787
|
+
var _fetchContent = async (options) => {
|
|
3708
2788
|
const url = generateContentUrl(options);
|
|
3709
|
-
const res =
|
|
3710
|
-
const content =
|
|
2789
|
+
const res = await fetch2(url.href);
|
|
2790
|
+
const content = await res.json();
|
|
3711
2791
|
return content;
|
|
3712
|
-
}
|
|
3713
|
-
var _processContentResult =
|
|
2792
|
+
};
|
|
2793
|
+
var _processContentResult = async (options, content, url = generateContentUrl(options)) => {
|
|
3714
2794
|
const canTrack = getDefaultCanTrack(options.canTrack);
|
|
3715
2795
|
const isPreviewing2 = url.search.includes(`preview=`);
|
|
3716
2796
|
if (TARGET === "rsc" && isPreviewing2) {
|
|
@@ -3728,7 +2808,7 @@ var _processContentResult = (_0, _1, ..._2) => __async5(void 0, [_0, _1, ..._2],
|
|
|
3728
2808
|
try {
|
|
3729
2809
|
const newResults = [];
|
|
3730
2810
|
for (const item of content.results) {
|
|
3731
|
-
newResults.push(
|
|
2811
|
+
newResults.push(await handleABTesting({
|
|
3732
2812
|
item,
|
|
3733
2813
|
canTrack
|
|
3734
2814
|
}));
|
|
@@ -3737,48 +2817,419 @@ var _processContentResult = (_0, _1, ..._2) => __async5(void 0, [_0, _1, ..._2],
|
|
|
3737
2817
|
} catch (e) {
|
|
3738
2818
|
logger.error("Could not process A/B tests. ", e);
|
|
3739
2819
|
}
|
|
3740
|
-
return content;
|
|
3741
|
-
}
|
|
3742
|
-
function fetchEntries(options) {
|
|
3743
|
-
|
|
2820
|
+
return content;
|
|
2821
|
+
};
|
|
2822
|
+
async function fetchEntries(options) {
|
|
2823
|
+
try {
|
|
2824
|
+
const url = generateContentUrl(options);
|
|
2825
|
+
const content = await _fetchContent(options);
|
|
2826
|
+
if (!checkContentHasResults(content)) {
|
|
2827
|
+
logger.error("Error fetching data. ", {
|
|
2828
|
+
url,
|
|
2829
|
+
content,
|
|
2830
|
+
options
|
|
2831
|
+
});
|
|
2832
|
+
return null;
|
|
2833
|
+
}
|
|
2834
|
+
return _processContentResult(options, content);
|
|
2835
|
+
} catch (error) {
|
|
2836
|
+
logger.error("Error fetching data. ", error);
|
|
2837
|
+
return null;
|
|
2838
|
+
}
|
|
2839
|
+
}
|
|
2840
|
+
var getAllContent = fetchEntries;
|
|
2841
|
+
|
|
2842
|
+
// src/functions/is-previewing.ts
|
|
2843
|
+
function isPreviewing() {
|
|
2844
|
+
if (!isBrowser()) {
|
|
2845
|
+
return false;
|
|
2846
|
+
}
|
|
2847
|
+
if (isEditing()) {
|
|
2848
|
+
return false;
|
|
2849
|
+
}
|
|
2850
|
+
return Boolean(location.search.indexOf("builder.preview=") !== -1);
|
|
2851
|
+
}
|
|
2852
|
+
|
|
2853
|
+
// src/helpers/uuid.ts
|
|
2854
|
+
function uuidv4() {
|
|
2855
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
2856
|
+
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
|
2857
|
+
return v.toString(16);
|
|
2858
|
+
});
|
|
2859
|
+
}
|
|
2860
|
+
function uuid() {
|
|
2861
|
+
return uuidv4().replace(/-/g, "");
|
|
2862
|
+
}
|
|
2863
|
+
|
|
2864
|
+
// src/helpers/sessionId.ts
|
|
2865
|
+
var SESSION_LOCAL_STORAGE_KEY = "builderSessionId";
|
|
2866
|
+
var getSessionId = async ({
|
|
2867
|
+
canTrack
|
|
2868
|
+
}) => {
|
|
2869
|
+
if (!canTrack) {
|
|
2870
|
+
return void 0;
|
|
2871
|
+
}
|
|
2872
|
+
const sessionId = await getCookie({
|
|
2873
|
+
name: SESSION_LOCAL_STORAGE_KEY,
|
|
2874
|
+
canTrack
|
|
2875
|
+
});
|
|
2876
|
+
if (checkIsDefined(sessionId)) {
|
|
2877
|
+
return sessionId;
|
|
2878
|
+
} else {
|
|
2879
|
+
const newSessionId = createSessionId();
|
|
2880
|
+
setSessionId({
|
|
2881
|
+
id: newSessionId,
|
|
2882
|
+
canTrack
|
|
2883
|
+
});
|
|
2884
|
+
return newSessionId;
|
|
2885
|
+
}
|
|
2886
|
+
};
|
|
2887
|
+
var createSessionId = () => uuid();
|
|
2888
|
+
var setSessionId = ({
|
|
2889
|
+
id,
|
|
2890
|
+
canTrack
|
|
2891
|
+
}) => setCookie({
|
|
2892
|
+
name: SESSION_LOCAL_STORAGE_KEY,
|
|
2893
|
+
value: id,
|
|
2894
|
+
canTrack
|
|
2895
|
+
});
|
|
2896
|
+
|
|
2897
|
+
// src/helpers/localStorage.ts
|
|
2898
|
+
var getLocalStorage = () => isBrowser() && typeof localStorage !== "undefined" ? localStorage : void 0;
|
|
2899
|
+
var getLocalStorageItem = ({
|
|
2900
|
+
key,
|
|
2901
|
+
canTrack
|
|
2902
|
+
}) => {
|
|
2903
|
+
try {
|
|
2904
|
+
if (canTrack) {
|
|
2905
|
+
return getLocalStorage()?.getItem(key);
|
|
2906
|
+
}
|
|
2907
|
+
return void 0;
|
|
2908
|
+
} catch (err) {
|
|
2909
|
+
console.debug("[LocalStorage] GET error: ", err);
|
|
2910
|
+
return void 0;
|
|
2911
|
+
}
|
|
2912
|
+
};
|
|
2913
|
+
var setLocalStorageItem = ({
|
|
2914
|
+
key,
|
|
2915
|
+
canTrack,
|
|
2916
|
+
value
|
|
2917
|
+
}) => {
|
|
2918
|
+
try {
|
|
2919
|
+
if (canTrack) {
|
|
2920
|
+
getLocalStorage()?.setItem(key, value);
|
|
2921
|
+
}
|
|
2922
|
+
} catch (err) {
|
|
2923
|
+
console.debug("[LocalStorage] SET error: ", err);
|
|
2924
|
+
}
|
|
2925
|
+
};
|
|
2926
|
+
|
|
2927
|
+
// src/helpers/visitorId.ts
|
|
2928
|
+
var VISITOR_LOCAL_STORAGE_KEY = "builderVisitorId";
|
|
2929
|
+
var getVisitorId = ({
|
|
2930
|
+
canTrack
|
|
2931
|
+
}) => {
|
|
2932
|
+
if (!canTrack) {
|
|
2933
|
+
return void 0;
|
|
2934
|
+
}
|
|
2935
|
+
const visitorId = getLocalStorageItem({
|
|
2936
|
+
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
2937
|
+
canTrack
|
|
2938
|
+
});
|
|
2939
|
+
if (checkIsDefined(visitorId)) {
|
|
2940
|
+
return visitorId;
|
|
2941
|
+
} else {
|
|
2942
|
+
const newVisitorId = createVisitorId();
|
|
2943
|
+
setVisitorId({
|
|
2944
|
+
id: newVisitorId,
|
|
2945
|
+
canTrack
|
|
2946
|
+
});
|
|
2947
|
+
return newVisitorId;
|
|
2948
|
+
}
|
|
2949
|
+
};
|
|
2950
|
+
var createVisitorId = () => uuid();
|
|
2951
|
+
var setVisitorId = ({
|
|
2952
|
+
id,
|
|
2953
|
+
canTrack
|
|
2954
|
+
}) => setLocalStorageItem({
|
|
2955
|
+
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
2956
|
+
value: id,
|
|
2957
|
+
canTrack
|
|
2958
|
+
});
|
|
2959
|
+
|
|
2960
|
+
// src/functions/track/index.ts
|
|
2961
|
+
var getTrackingEventData = async ({
|
|
2962
|
+
canTrack
|
|
2963
|
+
}) => {
|
|
2964
|
+
if (!canTrack) {
|
|
2965
|
+
return {
|
|
2966
|
+
visitorId: void 0,
|
|
2967
|
+
sessionId: void 0
|
|
2968
|
+
};
|
|
2969
|
+
}
|
|
2970
|
+
const sessionId = await getSessionId({
|
|
2971
|
+
canTrack
|
|
2972
|
+
});
|
|
2973
|
+
const visitorId = getVisitorId({
|
|
2974
|
+
canTrack
|
|
2975
|
+
});
|
|
2976
|
+
return {
|
|
2977
|
+
sessionId,
|
|
2978
|
+
visitorId
|
|
2979
|
+
};
|
|
2980
|
+
};
|
|
2981
|
+
var createEvent = async ({
|
|
2982
|
+
type: eventType,
|
|
2983
|
+
canTrack,
|
|
2984
|
+
apiKey,
|
|
2985
|
+
metadata,
|
|
2986
|
+
...properties
|
|
2987
|
+
}) => ({
|
|
2988
|
+
type: eventType,
|
|
2989
|
+
data: {
|
|
2990
|
+
...properties,
|
|
2991
|
+
metadata: {
|
|
2992
|
+
url: location.href,
|
|
2993
|
+
...metadata
|
|
2994
|
+
},
|
|
2995
|
+
...await getTrackingEventData({
|
|
2996
|
+
canTrack
|
|
2997
|
+
}),
|
|
2998
|
+
userAttributes: getUserAttributes(),
|
|
2999
|
+
ownerId: apiKey
|
|
3000
|
+
}
|
|
3001
|
+
});
|
|
3002
|
+
async function _track(eventProps) {
|
|
3003
|
+
if (!eventProps.apiKey) {
|
|
3004
|
+
logger.error("Missing API key for track call. Please provide your API key.");
|
|
3005
|
+
return;
|
|
3006
|
+
}
|
|
3007
|
+
if (!eventProps.canTrack) {
|
|
3008
|
+
return;
|
|
3009
|
+
}
|
|
3010
|
+
if (isEditing()) {
|
|
3011
|
+
return;
|
|
3012
|
+
}
|
|
3013
|
+
if (!(isBrowser() || TARGET === "reactNative")) {
|
|
3014
|
+
return;
|
|
3015
|
+
}
|
|
3016
|
+
return fetch(`https://cdn.builder.io/api/v1/track`, {
|
|
3017
|
+
method: "POST",
|
|
3018
|
+
body: JSON.stringify({
|
|
3019
|
+
events: [await createEvent(eventProps)]
|
|
3020
|
+
}),
|
|
3021
|
+
headers: {
|
|
3022
|
+
"content-type": "application/json"
|
|
3023
|
+
},
|
|
3024
|
+
mode: "cors"
|
|
3025
|
+
}).catch((err) => {
|
|
3026
|
+
console.error("Failed to track: ", err);
|
|
3027
|
+
});
|
|
3028
|
+
}
|
|
3029
|
+
var track = (args) => _track({
|
|
3030
|
+
...args,
|
|
3031
|
+
canTrack: true
|
|
3032
|
+
});
|
|
3033
|
+
|
|
3034
|
+
// src/functions/track/interaction.ts
|
|
3035
|
+
function round(num) {
|
|
3036
|
+
return Math.round(num * 1e3) / 1e3;
|
|
3037
|
+
}
|
|
3038
|
+
var findParentElement = (target, callback, checkElement = true) => {
|
|
3039
|
+
if (!(target instanceof HTMLElement)) {
|
|
3040
|
+
return null;
|
|
3041
|
+
}
|
|
3042
|
+
let parent2 = checkElement ? target : target.parentElement;
|
|
3043
|
+
do {
|
|
3044
|
+
if (!parent2) {
|
|
3045
|
+
return null;
|
|
3046
|
+
}
|
|
3047
|
+
const matches = callback(parent2);
|
|
3048
|
+
if (matches) {
|
|
3049
|
+
return parent2;
|
|
3050
|
+
}
|
|
3051
|
+
} while (parent2 = parent2.parentElement);
|
|
3052
|
+
return null;
|
|
3053
|
+
};
|
|
3054
|
+
var findBuilderParent = (target) => findParentElement(target, (el) => {
|
|
3055
|
+
const id = el.getAttribute("builder-id") || el.id;
|
|
3056
|
+
return Boolean(id?.indexOf("builder-") === 0);
|
|
3057
|
+
});
|
|
3058
|
+
var computeOffset = ({
|
|
3059
|
+
event,
|
|
3060
|
+
target
|
|
3061
|
+
}) => {
|
|
3062
|
+
const targetRect = target.getBoundingClientRect();
|
|
3063
|
+
const xOffset = event.clientX - targetRect.left;
|
|
3064
|
+
const yOffset = event.clientY - targetRect.top;
|
|
3065
|
+
const xRatio = round(xOffset / targetRect.width);
|
|
3066
|
+
const yRatio = round(yOffset / targetRect.height);
|
|
3067
|
+
return {
|
|
3068
|
+
x: xRatio,
|
|
3069
|
+
y: yRatio
|
|
3070
|
+
};
|
|
3071
|
+
};
|
|
3072
|
+
var getInteractionPropertiesForEvent = (event) => {
|
|
3073
|
+
const target = event.target;
|
|
3074
|
+
const targetBuilderElement = target && findBuilderParent(target);
|
|
3075
|
+
const builderId = targetBuilderElement?.getAttribute("builder-id") || targetBuilderElement?.id;
|
|
3076
|
+
return {
|
|
3077
|
+
targetBuilderElement: builderId || void 0,
|
|
3078
|
+
metadata: {
|
|
3079
|
+
targetOffset: target ? computeOffset({
|
|
3080
|
+
event,
|
|
3081
|
+
target
|
|
3082
|
+
}) : void 0,
|
|
3083
|
+
builderTargetOffset: targetBuilderElement ? computeOffset({
|
|
3084
|
+
event,
|
|
3085
|
+
target: targetBuilderElement
|
|
3086
|
+
}) : void 0,
|
|
3087
|
+
builderElementIndex: targetBuilderElement && builderId ? [].slice.call(document.getElementsByClassName(builderId)).indexOf(targetBuilderElement) : void 0
|
|
3088
|
+
}
|
|
3089
|
+
};
|
|
3090
|
+
};
|
|
3091
|
+
|
|
3092
|
+
// src/constants/sdk-version.ts
|
|
3093
|
+
var SDK_VERSION = "0.7.2";
|
|
3094
|
+
|
|
3095
|
+
// src/functions/register.ts
|
|
3096
|
+
var registry = {};
|
|
3097
|
+
function register(type, info) {
|
|
3098
|
+
let typeList = registry[type];
|
|
3099
|
+
if (!typeList) {
|
|
3100
|
+
typeList = registry[type] = [];
|
|
3101
|
+
}
|
|
3102
|
+
typeList.push(info);
|
|
3103
|
+
if (isBrowser()) {
|
|
3104
|
+
const message = {
|
|
3105
|
+
type: "builder.register",
|
|
3106
|
+
data: {
|
|
3107
|
+
type,
|
|
3108
|
+
info
|
|
3109
|
+
}
|
|
3110
|
+
};
|
|
3744
3111
|
try {
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
logger.error("Error fetching data. ", {
|
|
3749
|
-
url,
|
|
3750
|
-
content,
|
|
3751
|
-
options
|
|
3752
|
-
});
|
|
3753
|
-
return null;
|
|
3112
|
+
parent.postMessage(message, "*");
|
|
3113
|
+
if (parent !== window) {
|
|
3114
|
+
window.postMessage(message, "*");
|
|
3754
3115
|
}
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
logger.error("Error fetching data. ", error);
|
|
3758
|
-
return null;
|
|
3116
|
+
} catch (err) {
|
|
3117
|
+
console.debug("Could not postmessage", err);
|
|
3759
3118
|
}
|
|
3760
|
-
}
|
|
3119
|
+
}
|
|
3761
3120
|
}
|
|
3762
|
-
var getAllContent = fetchEntries;
|
|
3763
3121
|
|
|
3764
|
-
// src/
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3122
|
+
// src/scripts/init-editing.ts
|
|
3123
|
+
var registerInsertMenu = () => {
|
|
3124
|
+
register("insertMenu", {
|
|
3125
|
+
name: "_default",
|
|
3126
|
+
default: true,
|
|
3127
|
+
items: [{
|
|
3128
|
+
name: "Box"
|
|
3129
|
+
}, {
|
|
3130
|
+
name: "Text"
|
|
3131
|
+
}, {
|
|
3132
|
+
name: "Image"
|
|
3133
|
+
}, {
|
|
3134
|
+
name: "Columns"
|
|
3135
|
+
}, ...TARGET === "reactNative" ? [] : [{
|
|
3136
|
+
name: "Core:Section"
|
|
3137
|
+
}, {
|
|
3138
|
+
name: "Core:Button"
|
|
3139
|
+
}, {
|
|
3140
|
+
name: "Embed"
|
|
3141
|
+
}, {
|
|
3142
|
+
name: "Custom Code"
|
|
3143
|
+
}]]
|
|
3144
|
+
});
|
|
3145
|
+
};
|
|
3146
|
+
var isSetupForEditing = false;
|
|
3147
|
+
var setupBrowserForEditing = (options = {}) => {
|
|
3148
|
+
if (isSetupForEditing) {
|
|
3149
|
+
return;
|
|
3768
3150
|
}
|
|
3769
|
-
|
|
3770
|
-
|
|
3151
|
+
isSetupForEditing = true;
|
|
3152
|
+
if (isBrowser()) {
|
|
3153
|
+
window.parent?.postMessage({
|
|
3154
|
+
type: "builder.sdkInfo",
|
|
3155
|
+
data: {
|
|
3156
|
+
target: TARGET,
|
|
3157
|
+
version: SDK_VERSION,
|
|
3158
|
+
supportsPatchUpdates: false,
|
|
3159
|
+
// Supports builder-model="..." attribute which is needed to
|
|
3160
|
+
// scope our '+ add block' button styling
|
|
3161
|
+
supportsAddBlockScoping: true,
|
|
3162
|
+
supportsCustomBreakpoints: true
|
|
3163
|
+
}
|
|
3164
|
+
}, "*");
|
|
3165
|
+
window.parent?.postMessage({
|
|
3166
|
+
type: "builder.updateContent",
|
|
3167
|
+
data: {
|
|
3168
|
+
options
|
|
3169
|
+
}
|
|
3170
|
+
}, "*");
|
|
3171
|
+
window.addEventListener("message", ({
|
|
3172
|
+
data
|
|
3173
|
+
}) => {
|
|
3174
|
+
if (!data?.type) {
|
|
3175
|
+
return;
|
|
3176
|
+
}
|
|
3177
|
+
switch (data.type) {
|
|
3178
|
+
case "builder.evaluate": {
|
|
3179
|
+
const text = data.data.text;
|
|
3180
|
+
const args = data.data.arguments || [];
|
|
3181
|
+
const id = data.data.id;
|
|
3182
|
+
const fn = new Function(text);
|
|
3183
|
+
let result;
|
|
3184
|
+
let error = null;
|
|
3185
|
+
try {
|
|
3186
|
+
result = fn.apply(null, args);
|
|
3187
|
+
} catch (err) {
|
|
3188
|
+
error = err;
|
|
3189
|
+
}
|
|
3190
|
+
if (error) {
|
|
3191
|
+
window.parent?.postMessage({
|
|
3192
|
+
type: "builder.evaluateError",
|
|
3193
|
+
data: {
|
|
3194
|
+
id,
|
|
3195
|
+
error: error.message
|
|
3196
|
+
}
|
|
3197
|
+
}, "*");
|
|
3198
|
+
} else {
|
|
3199
|
+
if (result && typeof result.then === "function") {
|
|
3200
|
+
result.then((finalResult) => {
|
|
3201
|
+
window.parent?.postMessage({
|
|
3202
|
+
type: "builder.evaluateResult",
|
|
3203
|
+
data: {
|
|
3204
|
+
id,
|
|
3205
|
+
result: finalResult
|
|
3206
|
+
}
|
|
3207
|
+
}, "*");
|
|
3208
|
+
}).catch(console.error);
|
|
3209
|
+
} else {
|
|
3210
|
+
window.parent?.postMessage({
|
|
3211
|
+
type: "builder.evaluateResult",
|
|
3212
|
+
data: {
|
|
3213
|
+
result,
|
|
3214
|
+
id
|
|
3215
|
+
}
|
|
3216
|
+
}, "*");
|
|
3217
|
+
}
|
|
3218
|
+
}
|
|
3219
|
+
break;
|
|
3220
|
+
}
|
|
3221
|
+
}
|
|
3222
|
+
});
|
|
3771
3223
|
}
|
|
3772
|
-
|
|
3773
|
-
}
|
|
3224
|
+
};
|
|
3774
3225
|
|
|
3775
|
-
// src/components/content/components/enable-editor.
|
|
3226
|
+
// src/components/content/components/enable-editor.tsx
|
|
3776
3227
|
function EnableEditor(props) {
|
|
3777
|
-
const [forceReRenderCount, setForceReRenderCount] =
|
|
3778
|
-
const [lastUpdated, setLastUpdated] =
|
|
3779
|
-
const [shouldSendResetCookie, setShouldSendResetCookie] =
|
|
3780
|
-
const [httpReqsData, setHttpReqsData] =
|
|
3781
|
-
const [clicked, setClicked] =
|
|
3228
|
+
const [forceReRenderCount, setForceReRenderCount] = createSignal9(0);
|
|
3229
|
+
const [lastUpdated, setLastUpdated] = createSignal9(0);
|
|
3230
|
+
const [shouldSendResetCookie, setShouldSendResetCookie] = createSignal9(false);
|
|
3231
|
+
const [httpReqsData, setHttpReqsData] = createSignal9({});
|
|
3232
|
+
const [clicked, setClicked] = createSignal9(false);
|
|
3782
3233
|
function mergeNewContent(newContent) {
|
|
3783
3234
|
const newContentValue = {
|
|
3784
3235
|
...props.builderContextSignal.content,
|
|
@@ -3900,14 +3351,17 @@ function EnableEditor(props) {
|
|
|
3900
3351
|
function emitStateUpdate() {
|
|
3901
3352
|
if (isEditing()) {
|
|
3902
3353
|
window.dispatchEvent(
|
|
3903
|
-
new CustomEvent(
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3354
|
+
new CustomEvent(
|
|
3355
|
+
"builder:component:stateChange",
|
|
3356
|
+
{
|
|
3357
|
+
detail: {
|
|
3358
|
+
state: fastClone(props.builderContextSignal.rootState),
|
|
3359
|
+
ref: {
|
|
3360
|
+
name: props.model
|
|
3361
|
+
}
|
|
3908
3362
|
}
|
|
3909
3363
|
}
|
|
3910
|
-
|
|
3364
|
+
)
|
|
3911
3365
|
);
|
|
3912
3366
|
}
|
|
3913
3367
|
}
|
|
@@ -3929,12 +3383,12 @@ function EnableEditor(props) {
|
|
|
3929
3383
|
enrich: props.enrich
|
|
3930
3384
|
} : {}
|
|
3931
3385
|
});
|
|
3932
|
-
Object.values(
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
);
|
|
3386
|
+
Object.values(
|
|
3387
|
+
props.builderContextSignal.componentInfos
|
|
3388
|
+
).forEach((registeredComponent) => {
|
|
3389
|
+
const message = createRegisterComponentMessage(registeredComponent);
|
|
3390
|
+
window.parent?.postMessage(message, "*");
|
|
3391
|
+
});
|
|
3938
3392
|
window.addEventListener(
|
|
3939
3393
|
"builder:component:stateChangeListenerActivated",
|
|
3940
3394
|
emitStateUpdate
|
|
@@ -4018,7 +3472,7 @@ function EnableEditor(props) {
|
|
|
4018
3472
|
emitStateUpdate();
|
|
4019
3473
|
}
|
|
4020
3474
|
createEffect2(on2(() => [props.builderContextSignal.rootState], onUpdateFn_4));
|
|
4021
|
-
return <
|
|
3475
|
+
return <builder_context_default.Provider value={props.builderContextSignal}><Show9 when={props.builderContextSignal.content}><div
|
|
4022
3476
|
class={props.classNameProp}
|
|
4023
3477
|
{...{}}
|
|
4024
3478
|
key={forceReRenderCount()}
|
|
@@ -4031,19 +3485,139 @@ function EnableEditor(props) {
|
|
|
4031
3485
|
hidden: true,
|
|
4032
3486
|
"aria-hidden": true
|
|
4033
3487
|
}}
|
|
4034
|
-
>{props.children}</div></Show9></
|
|
3488
|
+
>{props.children}</div></Show9></builder_context_default.Provider>;
|
|
4035
3489
|
}
|
|
4036
3490
|
var Enable_editor_default = EnableEditor;
|
|
4037
3491
|
|
|
4038
|
-
// src/components/
|
|
4039
|
-
|
|
4040
|
-
|
|
3492
|
+
// src/components/content/components/styles.tsx
|
|
3493
|
+
import { createSignal as createSignal10 } from "solid-js";
|
|
3494
|
+
|
|
3495
|
+
// src/components/content/components/styles.helpers.ts
|
|
3496
|
+
var getCssFromFont = (font) => {
|
|
3497
|
+
const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
|
|
3498
|
+
const name = family.split(",")[0];
|
|
3499
|
+
const url = font.fileUrl ?? font?.files?.regular;
|
|
3500
|
+
let str = "";
|
|
3501
|
+
if (url && family && name) {
|
|
3502
|
+
str += `
|
|
3503
|
+
@font-face {
|
|
3504
|
+
font-family: "${family}";
|
|
3505
|
+
src: local("${name}"), url('${url}') format('woff2');
|
|
3506
|
+
font-display: fallback;
|
|
3507
|
+
font-weight: 400;
|
|
4041
3508
|
}
|
|
4042
|
-
|
|
3509
|
+
`.trim();
|
|
3510
|
+
}
|
|
3511
|
+
if (font.files) {
|
|
3512
|
+
for (const weight in font.files) {
|
|
3513
|
+
const isNumber = String(Number(weight)) === weight;
|
|
3514
|
+
if (!isNumber) {
|
|
3515
|
+
continue;
|
|
3516
|
+
}
|
|
3517
|
+
const weightUrl = font.files[weight];
|
|
3518
|
+
if (weightUrl && weightUrl !== url) {
|
|
3519
|
+
str += `
|
|
3520
|
+
@font-face {
|
|
3521
|
+
font-family: "${family}";
|
|
3522
|
+
src: url('${weightUrl}') format('woff2');
|
|
3523
|
+
font-display: fallback;
|
|
3524
|
+
font-weight: ${weight};
|
|
3525
|
+
}
|
|
3526
|
+
`.trim();
|
|
3527
|
+
}
|
|
3528
|
+
}
|
|
3529
|
+
}
|
|
3530
|
+
return str;
|
|
3531
|
+
};
|
|
3532
|
+
var getFontCss = ({
|
|
3533
|
+
customFonts
|
|
3534
|
+
}) => {
|
|
3535
|
+
return customFonts?.map((font) => getCssFromFont(font))?.join(" ") || "";
|
|
3536
|
+
};
|
|
3537
|
+
var getCss = ({
|
|
3538
|
+
cssCode,
|
|
3539
|
+
contentId
|
|
3540
|
+
}) => {
|
|
3541
|
+
if (!cssCode) {
|
|
3542
|
+
return "";
|
|
3543
|
+
}
|
|
3544
|
+
if (!contentId) {
|
|
3545
|
+
return cssCode;
|
|
3546
|
+
}
|
|
3547
|
+
return cssCode?.replace(/&/g, `div[builder-content-id="${contentId}"]`) || "";
|
|
3548
|
+
};
|
|
3549
|
+
|
|
3550
|
+
// src/components/content/components/styles.tsx
|
|
3551
|
+
function ContentStyles(props) {
|
|
3552
|
+
const [injectedStyles, setInjectedStyles] = createSignal10(
|
|
3553
|
+
`
|
|
3554
|
+
${getCss({
|
|
3555
|
+
cssCode: props.cssCode,
|
|
3556
|
+
contentId: props.contentId
|
|
3557
|
+
})}
|
|
3558
|
+
${getFontCss({
|
|
3559
|
+
customFonts: props.customFonts
|
|
3560
|
+
})}
|
|
3561
|
+
|
|
3562
|
+
.builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
|
|
3563
|
+
margin: 0;
|
|
3564
|
+
}
|
|
3565
|
+
.builder-text > p, .builder-text > .builder-paragraph {
|
|
3566
|
+
color: inherit;
|
|
3567
|
+
line-height: inherit;
|
|
3568
|
+
letter-spacing: inherit;
|
|
3569
|
+
font-weight: inherit;
|
|
3570
|
+
font-size: inherit;
|
|
3571
|
+
text-align: inherit;
|
|
3572
|
+
font-family: inherit;
|
|
3573
|
+
}
|
|
3574
|
+
`.trim()
|
|
3575
|
+
);
|
|
3576
|
+
return <Inlined_styles_default styles={injectedStyles()} />;
|
|
3577
|
+
}
|
|
3578
|
+
var Styles_default = ContentStyles;
|
|
3579
|
+
|
|
3580
|
+
// src/components/content/content.helpers.ts
|
|
3581
|
+
var getContextStateInitialValue = ({
|
|
3582
|
+
content,
|
|
3583
|
+
data,
|
|
3584
|
+
locale
|
|
3585
|
+
}) => {
|
|
3586
|
+
const defaultValues = {};
|
|
3587
|
+
content?.data?.inputs?.forEach((input) => {
|
|
3588
|
+
if (input.name && input.defaultValue !== void 0 && content?.data?.state && content.data.state[input.name] === void 0) {
|
|
3589
|
+
defaultValues[input.name] = input.defaultValue;
|
|
3590
|
+
}
|
|
3591
|
+
});
|
|
3592
|
+
const stateToUse = {
|
|
3593
|
+
...content?.data?.state,
|
|
3594
|
+
...data,
|
|
3595
|
+
...locale ? {
|
|
3596
|
+
locale
|
|
3597
|
+
} : {}
|
|
3598
|
+
};
|
|
3599
|
+
return {
|
|
3600
|
+
...defaultValues,
|
|
3601
|
+
...stateToUse
|
|
3602
|
+
};
|
|
3603
|
+
};
|
|
3604
|
+
var getContentInitialValue = ({
|
|
3605
|
+
content,
|
|
3606
|
+
data
|
|
3607
|
+
}) => {
|
|
3608
|
+
return !content ? void 0 : {
|
|
3609
|
+
...content,
|
|
3610
|
+
data: {
|
|
3611
|
+
...content?.data,
|
|
3612
|
+
...data
|
|
3613
|
+
},
|
|
3614
|
+
meta: content?.meta
|
|
3615
|
+
};
|
|
3616
|
+
};
|
|
4043
3617
|
|
|
4044
|
-
// src/components/content/content.
|
|
3618
|
+
// src/components/content/content.tsx
|
|
4045
3619
|
function ContentComponent(props) {
|
|
4046
|
-
const [scriptStr, setScriptStr] =
|
|
3620
|
+
const [scriptStr, setScriptStr] = createSignal11(
|
|
4047
3621
|
getRenderContentScriptString({
|
|
4048
3622
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
4049
3623
|
variationId: props.content?.testVariationId,
|
|
@@ -4051,7 +3625,7 @@ function ContentComponent(props) {
|
|
|
4051
3625
|
contentId: props.content?.id
|
|
4052
3626
|
})
|
|
4053
3627
|
);
|
|
4054
|
-
const [registeredComponents, setRegisteredComponents] =
|
|
3628
|
+
const [registeredComponents, setRegisteredComponents] = createSignal11(
|
|
4055
3629
|
[
|
|
4056
3630
|
...getDefaultRegisteredComponents(),
|
|
4057
3631
|
// While this `components` object is deprecated, we must maintain support for it.
|
|
@@ -4072,7 +3646,7 @@ function ContentComponent(props) {
|
|
|
4072
3646
|
{}
|
|
4073
3647
|
)
|
|
4074
3648
|
);
|
|
4075
|
-
const [builderContextSignal, setBuilderContextSignal] =
|
|
3649
|
+
const [builderContextSignal, setBuilderContextSignal] = createSignal11({
|
|
4076
3650
|
content: getContentInitialValue({
|
|
4077
3651
|
content: props.content,
|
|
4078
3652
|
data: props.data
|
|
@@ -4111,7 +3685,7 @@ function ContentComponent(props) {
|
|
|
4111
3685
|
rootState: newRootState
|
|
4112
3686
|
}));
|
|
4113
3687
|
}
|
|
4114
|
-
return <
|
|
3688
|
+
return <components_context_default.Provider
|
|
4115
3689
|
value={{
|
|
4116
3690
|
registeredComponents: registeredComponents()
|
|
4117
3691
|
}}
|
|
@@ -4142,13 +3716,13 @@ function ContentComponent(props) {
|
|
|
4142
3716
|
context={builderContextSignal()}
|
|
4143
3717
|
registeredComponents={registeredComponents()}
|
|
4144
3718
|
/>
|
|
4145
|
-
</Enable_editor_default></
|
|
3719
|
+
</Enable_editor_default></components_context_default.Provider>;
|
|
4146
3720
|
}
|
|
4147
3721
|
var Content_default = ContentComponent;
|
|
4148
3722
|
|
|
4149
|
-
// src/components/content-variants/content-variants.
|
|
3723
|
+
// src/components/content-variants/content-variants.tsx
|
|
4150
3724
|
function ContentVariants(props) {
|
|
4151
|
-
const [shouldRenderVariants, setShouldRenderVariants] =
|
|
3725
|
+
const [shouldRenderVariants, setShouldRenderVariants] = createSignal12(
|
|
4152
3726
|
checkShouldRunVariants({
|
|
4153
3727
|
canTrack: getDefaultCanTrack(props.canTrack),
|
|
4154
3728
|
content: props.content
|
|
@@ -4176,6 +3750,7 @@ function ContentVariants(props) {
|
|
|
4176
3750
|
});
|
|
4177
3751
|
}
|
|
4178
3752
|
onMount3(() => {
|
|
3753
|
+
setShouldRenderVariants(false);
|
|
4179
3754
|
});
|
|
4180
3755
|
return <>
|
|
4181
3756
|
<Show11 when={!props.__isNestedRender && TARGET !== "reactNative"}><Inlined_script_default scriptStr={getScriptString()} /></Show11>
|
|
@@ -4227,72 +3802,33 @@ function ContentVariants(props) {
|
|
|
4227
3802
|
}
|
|
4228
3803
|
var Content_variants_default = ContentVariants;
|
|
4229
3804
|
|
|
4230
|
-
// src/blocks/symbol/symbol.helpers.
|
|
4231
|
-
var
|
|
4232
|
-
var __getOwnPropSymbols17 = Object.getOwnPropertySymbols;
|
|
4233
|
-
var __hasOwnProp17 = Object.prototype.hasOwnProperty;
|
|
4234
|
-
var __propIsEnum17 = Object.prototype.propertyIsEnumerable;
|
|
4235
|
-
var __defNormalProp17 = (obj, key, value) => key in obj ? __defProp17(obj, key, {
|
|
4236
|
-
enumerable: true,
|
|
4237
|
-
configurable: true,
|
|
4238
|
-
writable: true,
|
|
4239
|
-
value
|
|
4240
|
-
}) : obj[key] = value;
|
|
4241
|
-
var __spreadValues17 = (a, b) => {
|
|
4242
|
-
for (var prop in b || (b = {}))
|
|
4243
|
-
if (__hasOwnProp17.call(b, prop))
|
|
4244
|
-
__defNormalProp17(a, prop, b[prop]);
|
|
4245
|
-
if (__getOwnPropSymbols17)
|
|
4246
|
-
for (var prop of __getOwnPropSymbols17(b)) {
|
|
4247
|
-
if (__propIsEnum17.call(b, prop))
|
|
4248
|
-
__defNormalProp17(a, prop, b[prop]);
|
|
4249
|
-
}
|
|
4250
|
-
return a;
|
|
4251
|
-
};
|
|
4252
|
-
var __async6 = (__this, __arguments, generator) => {
|
|
4253
|
-
return new Promise((resolve, reject) => {
|
|
4254
|
-
var fulfilled = (value) => {
|
|
4255
|
-
try {
|
|
4256
|
-
step(generator.next(value));
|
|
4257
|
-
} catch (e) {
|
|
4258
|
-
reject(e);
|
|
4259
|
-
}
|
|
4260
|
-
};
|
|
4261
|
-
var rejected = (value) => {
|
|
4262
|
-
try {
|
|
4263
|
-
step(generator.throw(value));
|
|
4264
|
-
} catch (e) {
|
|
4265
|
-
reject(e);
|
|
4266
|
-
}
|
|
4267
|
-
};
|
|
4268
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
4269
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
4270
|
-
});
|
|
4271
|
-
};
|
|
4272
|
-
var fetchSymbolContent = (_0) => __async6(void 0, [_0], function* ({
|
|
3805
|
+
// src/blocks/symbol/symbol.helpers.ts
|
|
3806
|
+
var fetchSymbolContent = async ({
|
|
4273
3807
|
builderContextValue,
|
|
4274
3808
|
symbol
|
|
4275
|
-
}) {
|
|
4276
|
-
if (
|
|
4277
|
-
|
|
3809
|
+
}) => {
|
|
3810
|
+
if (symbol?.model && // This is a hack, we should not need to check for this, but it is needed for Svelte.
|
|
3811
|
+
builderContextValue?.apiKey) {
|
|
3812
|
+
return fetchOneEntry({
|
|
4278
3813
|
model: symbol.model,
|
|
4279
3814
|
apiKey: builderContextValue.apiKey,
|
|
4280
|
-
apiVersion: builderContextValue.apiVersion
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
3815
|
+
apiVersion: builderContextValue.apiVersion,
|
|
3816
|
+
...symbol?.entry && {
|
|
3817
|
+
query: {
|
|
3818
|
+
id: symbol.entry
|
|
3819
|
+
}
|
|
4284
3820
|
}
|
|
4285
|
-
})
|
|
3821
|
+
}).catch((err) => {
|
|
4286
3822
|
logger.error("Could not fetch symbol content: ", err);
|
|
4287
3823
|
return void 0;
|
|
4288
3824
|
});
|
|
4289
3825
|
}
|
|
4290
3826
|
return void 0;
|
|
4291
|
-
}
|
|
3827
|
+
};
|
|
4292
3828
|
|
|
4293
|
-
// src/blocks/symbol/symbol.
|
|
3829
|
+
// src/blocks/symbol/symbol.tsx
|
|
4294
3830
|
function Symbol(props) {
|
|
4295
|
-
const [contentToUse, setContentToUse] =
|
|
3831
|
+
const [contentToUse, setContentToUse] = createSignal13(props.symbol?.content);
|
|
4296
3832
|
function className() {
|
|
4297
3833
|
return [
|
|
4298
3834
|
...[props.attributes.class],
|
|
@@ -4337,11 +3873,11 @@ function Symbol(props) {
|
|
|
4337
3873
|
}
|
|
4338
3874
|
var symbol_default = Symbol;
|
|
4339
3875
|
|
|
4340
|
-
// src/index-helpers/blocks-exports.
|
|
3876
|
+
// src/index-helpers/blocks-exports.ts
|
|
4341
3877
|
var RenderBlocks = Blocks_default;
|
|
4342
3878
|
var RenderContent = Content_variants_default;
|
|
4343
3879
|
|
|
4344
|
-
// src/functions/set-editor-settings.
|
|
3880
|
+
// src/functions/set-editor-settings.ts
|
|
4345
3881
|
var settings = {};
|
|
4346
3882
|
function setEditorSettings(newSettings) {
|
|
4347
3883
|
if (isBrowser()) {
|
|
@@ -4354,68 +3890,27 @@ function setEditorSettings(newSettings) {
|
|
|
4354
3890
|
}
|
|
4355
3891
|
}
|
|
4356
3892
|
|
|
4357
|
-
// src/functions/fetch-builder-props.
|
|
4358
|
-
var
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
var __hasOwnProp18 = Object.prototype.hasOwnProperty;
|
|
4363
|
-
var __propIsEnum18 = Object.prototype.propertyIsEnumerable;
|
|
4364
|
-
var __defNormalProp18 = (obj, key, value) => key in obj ? __defProp18(obj, key, {
|
|
4365
|
-
enumerable: true,
|
|
4366
|
-
configurable: true,
|
|
4367
|
-
writable: true,
|
|
4368
|
-
value
|
|
4369
|
-
}) : obj[key] = value;
|
|
4370
|
-
var __spreadValues18 = (a, b) => {
|
|
4371
|
-
for (var prop in b || (b = {}))
|
|
4372
|
-
if (__hasOwnProp18.call(b, prop))
|
|
4373
|
-
__defNormalProp18(a, prop, b[prop]);
|
|
4374
|
-
if (__getOwnPropSymbols18)
|
|
4375
|
-
for (var prop of __getOwnPropSymbols18(b)) {
|
|
4376
|
-
if (__propIsEnum18.call(b, prop))
|
|
4377
|
-
__defNormalProp18(a, prop, b[prop]);
|
|
4378
|
-
}
|
|
4379
|
-
return a;
|
|
4380
|
-
};
|
|
4381
|
-
var __spreadProps12 = (a, b) => __defProps12(a, __getOwnPropDescs12(b));
|
|
4382
|
-
var __async7 = (__this, __arguments, generator) => {
|
|
4383
|
-
return new Promise((resolve, reject) => {
|
|
4384
|
-
var fulfilled = (value) => {
|
|
4385
|
-
try {
|
|
4386
|
-
step(generator.next(value));
|
|
4387
|
-
} catch (e) {
|
|
4388
|
-
reject(e);
|
|
4389
|
-
}
|
|
4390
|
-
};
|
|
4391
|
-
var rejected = (value) => {
|
|
4392
|
-
try {
|
|
4393
|
-
step(generator.throw(value));
|
|
4394
|
-
} catch (e) {
|
|
4395
|
-
reject(e);
|
|
4396
|
-
}
|
|
4397
|
-
};
|
|
4398
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
4399
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
4400
|
-
});
|
|
4401
|
-
};
|
|
4402
|
-
var fetchBuilderProps = (_args) => __async7(void 0, null, function* () {
|
|
4403
|
-
var _a, _b, _c;
|
|
4404
|
-
const urlPath = _args.path || ((_a = _args.url) == null ? void 0 : _a.pathname) || ((_b = _args.userAttributes) == null ? void 0 : _b.urlPath);
|
|
4405
|
-
const getContentArgs = __spreadProps12(__spreadValues18({}, _args), {
|
|
3893
|
+
// src/functions/fetch-builder-props.ts
|
|
3894
|
+
var fetchBuilderProps = async (_args) => {
|
|
3895
|
+
const urlPath = _args.path || _args.url?.pathname || _args.userAttributes?.urlPath;
|
|
3896
|
+
const getContentArgs = {
|
|
3897
|
+
..._args,
|
|
4406
3898
|
apiKey: _args.apiKey,
|
|
4407
3899
|
model: _args.model || "page",
|
|
4408
|
-
userAttributes:
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
3900
|
+
userAttributes: {
|
|
3901
|
+
..._args.userAttributes,
|
|
3902
|
+
...urlPath ? {
|
|
3903
|
+
urlPath
|
|
3904
|
+
} : {}
|
|
3905
|
+
},
|
|
3906
|
+
options: getBuilderSearchParams(_args.searchParams || _args.url?.searchParams || _args.options)
|
|
3907
|
+
};
|
|
4413
3908
|
return {
|
|
4414
3909
|
apiKey: getContentArgs.apiKey,
|
|
4415
3910
|
model: getContentArgs.model,
|
|
4416
|
-
content:
|
|
3911
|
+
content: await fetchOneEntry(getContentArgs)
|
|
4417
3912
|
};
|
|
4418
|
-
}
|
|
3913
|
+
};
|
|
4419
3914
|
export {
|
|
4420
3915
|
Blocks_default as Blocks,
|
|
4421
3916
|
button_default as Button,
|