@builder.io/sdk-react-nextjs 0.12.6 → 0.12.8
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/lib/browser/{USE_CLIENT_BUNDLE-4d4e23b4.js → USE_CLIENT_BUNDLE-164b0828.js} +193 -195
- package/lib/browser/USE_CLIENT_BUNDLE-a350a268.cjs +21 -0
- package/lib/{edge/USE_SERVER_BUNDLE-fda604b6.js → browser/USE_SERVER_BUNDLE-5219d3fc.js} +1 -1
- package/lib/{edge/USE_SERVER_BUNDLE-19879780.cjs → browser/USE_SERVER_BUNDLE-b1e8364e.cjs} +1 -1
- package/lib/browser/{bundle-6e21e129.cjs → bundle-f375f07b.cjs} +21 -21
- package/lib/browser/{bundle-b3104268.js → bundle-f83a1ca5.js} +537 -447
- package/lib/browser/index.cjs +1 -1
- package/lib/browser/index.mjs +23 -22
- package/lib/{node/USE_CLIENT_BUNDLE-aa8ab44a.js → edge/USE_CLIENT_BUNDLE-b8d07605.js} +193 -195
- package/lib/edge/USE_CLIENT_BUNDLE-f1ccd54b.cjs +21 -0
- package/lib/{node/USE_SERVER_BUNDLE-cbcb1baf.cjs → edge/USE_SERVER_BUNDLE-2e4c0a0a.cjs} +1 -1
- package/lib/{node/USE_SERVER_BUNDLE-2fdc522e.js → edge/USE_SERVER_BUNDLE-cd7a6238.js} +1 -1
- package/lib/edge/{bundle-ee1ebe27.js → bundle-3da03df6.js} +574 -484
- package/lib/edge/{bundle-f2d4a6db.cjs → bundle-5b207761.cjs} +29 -29
- package/lib/edge/index.cjs +1 -1
- package/lib/edge/index.mjs +23 -22
- package/lib/{edge/USE_CLIENT_BUNDLE-41ee32e4.js → node/USE_CLIENT_BUNDLE-e0108fb4.js} +193 -195
- package/lib/node/USE_CLIENT_BUNDLE-e31c74cc.cjs +21 -0
- package/lib/{browser/USE_SERVER_BUNDLE-ccca985e.cjs → node/USE_SERVER_BUNDLE-29398256.cjs} +1 -1
- package/lib/{browser/USE_SERVER_BUNDLE-2bf0dc28.js → node/USE_SERVER_BUNDLE-3e951ab1.js} +1 -1
- package/lib/node/{bundle-99e5b33f.js → bundle-6c5cef2d.js} +268 -178
- package/lib/node/{bundle-c799b7fc.cjs → bundle-83186530.cjs} +9 -9
- package/lib/node/index.cjs +1 -1
- package/lib/node/index.mjs +23 -22
- package/package.json +1 -1
- package/types/cjs/components/block/animator.d.ts +5 -0
- package/types/cjs/components/content-variants/helpers.d.ts +1 -1
- package/types/cjs/constants/sdk-version.d.ts +1 -1
- package/types/cjs/helpers/preview-lru-cache/get.d.ts +1 -1
- package/types/cjs/helpers/subscribe-to-editor.d.ts +35 -0
- package/types/cjs/server-index.d.ts +18 -3
- package/types/cjs/types/builder-block.d.ts +18 -1
- package/types/esm/components/block/animator.d.ts +5 -0
- package/types/esm/components/content-variants/helpers.d.ts +1 -1
- package/types/esm/constants/sdk-version.d.ts +1 -1
- package/types/esm/helpers/preview-lru-cache/get.d.ts +1 -1
- package/types/esm/helpers/subscribe-to-editor.d.ts +35 -0
- package/types/esm/server-index.d.ts +18 -3
- package/types/esm/types/builder-block.d.ts +18 -1
- package/lib/browser/USE_CLIENT_BUNDLE-e5d64246.cjs +0 -21
- package/lib/edge/USE_CLIENT_BUNDLE-cc55e91d.cjs +0 -21
- package/lib/node/USE_CLIENT_BUNDLE-343cb348.cjs +0 -21
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LRUCache } from "lru-cache";
|
|
2
2
|
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { I as InteractiveElement, B as BlockWrapper, a as BlocksWrapper, D as DynamicRenderer, b as Button, C as CustomCode, E as Embed, F as FragmentComponent, c as Image, d as ImgComponent, S as SectionComponent, V as Video, e as EnableEditor } from "./USE_CLIENT_BUNDLE-
|
|
3
|
+
import { I as InteractiveElement, B as BlockWrapper, a as BlocksWrapper, D as DynamicRenderer, b as Button, C as CustomCode, E as Embed, F as FragmentComponent, c as Image, d as ImgComponent, S as SectionComponent, V as Video, e as EnableEditor } from "./USE_CLIENT_BUNDLE-e0108fb4.js";
|
|
4
4
|
import "react";
|
|
5
5
|
import "next/navigation";
|
|
6
6
|
const EMPTY_HTML_ELEMENTS = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]), isEmptyElement = (e) => typeof e == "string" && EMPTY_HTML_ELEMENTS.has(e.toLowerCase()), TARGET = "rsc", getClassPropName = () => {
|
|
@@ -98,8 +98,8 @@ const getLocation = () => {
|
|
|
98
98
|
builder: t,
|
|
99
99
|
context: n,
|
|
100
100
|
event: o,
|
|
101
|
-
localState:
|
|
102
|
-
rootSetState:
|
|
101
|
+
localState: r,
|
|
102
|
+
rootSetState: i,
|
|
103
103
|
rootState: a
|
|
104
104
|
}) => {
|
|
105
105
|
const s = getFunctionArguments({
|
|
@@ -108,8 +108,8 @@ const getLocation = () => {
|
|
|
108
108
|
event: o,
|
|
109
109
|
state: flattenState({
|
|
110
110
|
rootState: a,
|
|
111
|
-
localState:
|
|
112
|
-
rootSetState:
|
|
111
|
+
localState: r,
|
|
112
|
+
rootSetState: i
|
|
113
113
|
})
|
|
114
114
|
});
|
|
115
115
|
return new Function(...s.map(([c]) => c), e)(...s.map(([, c]) => c));
|
|
@@ -120,22 +120,22 @@ function flattenState({
|
|
|
120
120
|
rootSetState: n
|
|
121
121
|
}) {
|
|
122
122
|
return new Proxy(e, {
|
|
123
|
-
get: (o,
|
|
124
|
-
if (t &&
|
|
125
|
-
return t[
|
|
126
|
-
const
|
|
127
|
-
return typeof
|
|
128
|
-
rootState:
|
|
123
|
+
get: (o, r) => {
|
|
124
|
+
if (t && r in t)
|
|
125
|
+
return t[r];
|
|
126
|
+
const i = o[r];
|
|
127
|
+
return typeof i == "object" ? flattenState({
|
|
128
|
+
rootState: i,
|
|
129
129
|
localState: void 0,
|
|
130
130
|
rootSetState: n ? (a) => {
|
|
131
|
-
o[
|
|
131
|
+
o[r] = a, n(o);
|
|
132
132
|
} : void 0
|
|
133
|
-
}) :
|
|
133
|
+
}) : i;
|
|
134
134
|
},
|
|
135
|
-
set: (o,
|
|
136
|
-
if (t &&
|
|
135
|
+
set: (o, r, i) => {
|
|
136
|
+
if (t && r in t)
|
|
137
137
|
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
138
|
-
return o[
|
|
138
|
+
return o[r] = i, n == null || n(o), !0;
|
|
139
139
|
}
|
|
140
140
|
});
|
|
141
141
|
}
|
|
@@ -143,7 +143,7 @@ const fastClone = (e) => JSON.parse(JSON.stringify(e)), set = (e, t, n) => {
|
|
|
143
143
|
if (Object(e) !== e)
|
|
144
144
|
return e;
|
|
145
145
|
const o = Array.isArray(t) ? t : t.toString().match(/[^.[\]]+/g);
|
|
146
|
-
return o.slice(0, -1).reduce((
|
|
146
|
+
return o.slice(0, -1).reduce((r, i, a) => Object(r[i]) === r[i] ? r[i] : r[i] = Math.abs(Number(o[a + 1])) >> 0 === +o[a + 1] ? [] : {}, e)[o[o.length - 1]] = n, e;
|
|
147
147
|
}, noop = () => {
|
|
148
148
|
};
|
|
149
149
|
let safeDynamicRequire = noop;
|
|
@@ -204,13 +204,13 @@ output;
|
|
|
204
204
|
builder: t,
|
|
205
205
|
context: n,
|
|
206
206
|
event: o,
|
|
207
|
-
localState:
|
|
208
|
-
rootSetState:
|
|
207
|
+
localState: r,
|
|
208
|
+
rootSetState: i,
|
|
209
209
|
rootState: a
|
|
210
210
|
}) => {
|
|
211
211
|
const s = fastClone({
|
|
212
212
|
...a,
|
|
213
|
-
...
|
|
213
|
+
...r
|
|
214
214
|
}), c = getFunctionArguments({
|
|
215
215
|
builder: t,
|
|
216
216
|
context: n,
|
|
@@ -220,7 +220,7 @@ output;
|
|
|
220
220
|
f.setSync("global", f.derefInto()), f.setSync("log", function(...d) {
|
|
221
221
|
console.log(...d);
|
|
222
222
|
}), f.setSync(BUILDER_SET_STATE_NAME, function(d, l) {
|
|
223
|
-
set(a, d, l),
|
|
223
|
+
set(a, d, l), i == null || i(a);
|
|
224
224
|
}), c.forEach(([d, l]) => {
|
|
225
225
|
const u = typeof l == "object" ? new ivm.Reference(
|
|
226
226
|
// workaround: methods with default values for arguments is not being cloned over
|
|
@@ -257,8 +257,8 @@ function evaluate({
|
|
|
257
257
|
context: t,
|
|
258
258
|
localState: n,
|
|
259
259
|
rootState: o,
|
|
260
|
-
rootSetState:
|
|
261
|
-
event:
|
|
260
|
+
rootSetState: r,
|
|
261
|
+
event: i,
|
|
262
262
|
isExpression: a = !0
|
|
263
263
|
}) {
|
|
264
264
|
if (e === "") {
|
|
@@ -271,8 +271,8 @@ function evaluate({
|
|
|
271
271
|
}),
|
|
272
272
|
builder: getBuilderGlobals(),
|
|
273
273
|
context: t,
|
|
274
|
-
event:
|
|
275
|
-
rootSetState:
|
|
274
|
+
event: i,
|
|
275
|
+
rootSetState: r,
|
|
276
276
|
rootState: o,
|
|
277
277
|
localState: n
|
|
278
278
|
};
|
|
@@ -293,17 +293,17 @@ const evaluateBindings = ({
|
|
|
293
293
|
context: t,
|
|
294
294
|
localState: n,
|
|
295
295
|
rootState: o,
|
|
296
|
-
rootSetState:
|
|
296
|
+
rootSetState: r
|
|
297
297
|
}) => {
|
|
298
298
|
if (!e.bindings)
|
|
299
299
|
return e;
|
|
300
|
-
const
|
|
301
|
-
...
|
|
300
|
+
const i = fastClone(e), a = {
|
|
301
|
+
...i,
|
|
302
302
|
properties: {
|
|
303
|
-
...
|
|
303
|
+
...i.properties
|
|
304
304
|
},
|
|
305
305
|
actions: {
|
|
306
|
-
...
|
|
306
|
+
...i.actions
|
|
307
307
|
}
|
|
308
308
|
};
|
|
309
309
|
for (const s in e.bindings) {
|
|
@@ -311,7 +311,7 @@ const evaluateBindings = ({
|
|
|
311
311
|
code: c,
|
|
312
312
|
localState: n,
|
|
313
313
|
rootState: o,
|
|
314
|
-
rootSetState:
|
|
314
|
+
rootSetState: r,
|
|
315
315
|
context: t
|
|
316
316
|
});
|
|
317
317
|
set(a, s, m);
|
|
@@ -323,15 +323,15 @@ function getProcessedBlock({
|
|
|
323
323
|
context: t,
|
|
324
324
|
shouldEvaluateBindings: n,
|
|
325
325
|
localState: o,
|
|
326
|
-
rootState:
|
|
327
|
-
rootSetState:
|
|
326
|
+
rootState: r,
|
|
327
|
+
rootSetState: i
|
|
328
328
|
}) {
|
|
329
329
|
const a = e;
|
|
330
330
|
return n ? evaluateBindings({
|
|
331
331
|
block: a,
|
|
332
332
|
localState: o,
|
|
333
|
-
rootState:
|
|
334
|
-
rootSetState:
|
|
333
|
+
rootState: r,
|
|
334
|
+
rootSetState: i,
|
|
335
335
|
context: t
|
|
336
336
|
}) : a;
|
|
337
337
|
}
|
|
@@ -340,20 +340,20 @@ const getComponent = ({
|
|
|
340
340
|
context: t,
|
|
341
341
|
registeredComponents: n
|
|
342
342
|
}) => {
|
|
343
|
-
var
|
|
344
|
-
const o = (
|
|
343
|
+
var i;
|
|
344
|
+
const o = (i = getProcessedBlock({
|
|
345
345
|
block: e,
|
|
346
346
|
localState: t.localState,
|
|
347
347
|
rootState: t.rootState,
|
|
348
348
|
rootSetState: t.rootSetState,
|
|
349
349
|
context: t.context,
|
|
350
350
|
shouldEvaluateBindings: !1
|
|
351
|
-
}).component) == null ? void 0 :
|
|
351
|
+
}).component) == null ? void 0 : i.name;
|
|
352
352
|
if (!o)
|
|
353
353
|
return null;
|
|
354
|
-
const
|
|
355
|
-
if (
|
|
356
|
-
return
|
|
354
|
+
const r = n[o];
|
|
355
|
+
if (r)
|
|
356
|
+
return r;
|
|
357
357
|
console.warn(`
|
|
358
358
|
Could not find a registered component named "${o}".
|
|
359
359
|
If you registered it, is the file that registered it imported by the file that needs to render it?`);
|
|
@@ -367,17 +367,17 @@ const getComponent = ({
|
|
|
367
367
|
} = e;
|
|
368
368
|
if (!(n != null && n.collection))
|
|
369
369
|
return;
|
|
370
|
-
const
|
|
370
|
+
const r = evaluate({
|
|
371
371
|
code: n.collection,
|
|
372
372
|
localState: t.localState,
|
|
373
373
|
rootState: t.rootState,
|
|
374
374
|
rootSetState: t.rootSetState,
|
|
375
375
|
context: t.context
|
|
376
376
|
});
|
|
377
|
-
if (!Array.isArray(
|
|
377
|
+
if (!Array.isArray(r))
|
|
378
378
|
return;
|
|
379
|
-
const
|
|
380
|
-
return
|
|
379
|
+
const i = n.collection.split(".").pop(), a = n.itemName || (i ? i + "Item" : "item");
|
|
380
|
+
return r.map((c, m) => ({
|
|
381
381
|
context: {
|
|
382
382
|
...t,
|
|
383
383
|
localState: {
|
|
@@ -419,18 +419,18 @@ const getComponent = ({
|
|
|
419
419
|
min: o,
|
|
420
420
|
default: o + 1
|
|
421
421
|
};
|
|
422
|
-
const
|
|
422
|
+
const r = n.small.max + 1;
|
|
423
423
|
n.medium = {
|
|
424
424
|
max: t,
|
|
425
|
-
min:
|
|
426
|
-
default:
|
|
425
|
+
min: r,
|
|
426
|
+
default: r + 1
|
|
427
427
|
};
|
|
428
|
-
const
|
|
428
|
+
const i = n.medium.max + 1;
|
|
429
429
|
return n.large = {
|
|
430
430
|
max: 2e3,
|
|
431
431
|
// TODO: decide upper limit
|
|
432
|
-
min:
|
|
433
|
-
default:
|
|
432
|
+
min: i,
|
|
433
|
+
default: i + 1
|
|
434
434
|
}, n;
|
|
435
435
|
}, camelToKebabCase = (e) => e.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase(), convertStyleMapToCSSArray = (e) => Object.entries(e).map(([n, o]) => {
|
|
436
436
|
if (typeof o == "string")
|
|
@@ -453,7 +453,7 @@ function InlinedStyles(e) {
|
|
|
453
453
|
}
|
|
454
454
|
function BlockStyles(e) {
|
|
455
455
|
const t = function() {
|
|
456
|
-
const
|
|
456
|
+
const r = getProcessedBlock({
|
|
457
457
|
block: e.block,
|
|
458
458
|
localState: e.context.localState,
|
|
459
459
|
rootState: e.context.rootState,
|
|
@@ -461,19 +461,19 @@ function BlockStyles(e) {
|
|
|
461
461
|
context: e.context.context,
|
|
462
462
|
shouldEvaluateBindings: !0
|
|
463
463
|
});
|
|
464
|
-
return checkIsDefined(
|
|
464
|
+
return checkIsDefined(r.hide) ? !r.hide : checkIsDefined(r.show) ? r.show : !0;
|
|
465
465
|
}, n = function() {
|
|
466
466
|
var u;
|
|
467
|
-
const
|
|
467
|
+
const r = getProcessedBlock({
|
|
468
468
|
block: e.block,
|
|
469
469
|
localState: e.context.localState,
|
|
470
470
|
rootState: e.context.rootState,
|
|
471
471
|
rootSetState: e.context.rootSetState,
|
|
472
472
|
context: e.context.context,
|
|
473
473
|
shouldEvaluateBindings: !0
|
|
474
|
-
}),
|
|
474
|
+
}), i = r.responsiveStyles, a = e.context.content, s = getSizesForBreakpoints(
|
|
475
475
|
((u = a == null ? void 0 : a.meta) == null ? void 0 : u.breakpoints) || {}
|
|
476
|
-
), c =
|
|
476
|
+
), c = i == null ? void 0 : i.large, m = i == null ? void 0 : i.medium, f = i == null ? void 0 : i.small, p = r.id;
|
|
477
477
|
if (!p)
|
|
478
478
|
return "";
|
|
479
479
|
const g = c ? createCssClass({
|
|
@@ -515,18 +515,18 @@ function getBlockActions(e) {
|
|
|
515
515
|
for (const o in n) {
|
|
516
516
|
if (!n.hasOwnProperty(o))
|
|
517
517
|
continue;
|
|
518
|
-
const
|
|
519
|
-
let
|
|
518
|
+
const r = n[o];
|
|
519
|
+
let i = getEventHandlerName(o);
|
|
520
520
|
if (e.stripPrefix)
|
|
521
521
|
switch (TARGET) {
|
|
522
522
|
case "vue":
|
|
523
|
-
|
|
523
|
+
i = i.replace("v-on:", "");
|
|
524
524
|
break;
|
|
525
525
|
case "svelte":
|
|
526
|
-
|
|
526
|
+
i = i.replace("on:", "");
|
|
527
527
|
break;
|
|
528
528
|
}
|
|
529
|
-
t[
|
|
529
|
+
t[i] = createEventHandler(r, e);
|
|
530
530
|
}
|
|
531
531
|
return t;
|
|
532
532
|
}
|
|
@@ -590,8 +590,8 @@ const getWrapperProps = ({
|
|
|
590
590
|
builderBlock: t,
|
|
591
591
|
context: n,
|
|
592
592
|
componentRef: o,
|
|
593
|
-
includeBlockProps:
|
|
594
|
-
isInteractive:
|
|
593
|
+
includeBlockProps: r,
|
|
594
|
+
isInteractive: i,
|
|
595
595
|
contextValue: a
|
|
596
596
|
}) => {
|
|
597
597
|
const s = {
|
|
@@ -600,19 +600,19 @@ const getWrapperProps = ({
|
|
|
600
600
|
* If `noWrap` is set to `true`, then the block's props/attributes are provided to the
|
|
601
601
|
* component itself directly. Otherwise, they are provided to the wrapper element.
|
|
602
602
|
*/
|
|
603
|
-
...
|
|
603
|
+
...r ? {
|
|
604
604
|
attributes: getBlockProperties({
|
|
605
605
|
block: t,
|
|
606
606
|
context: a
|
|
607
607
|
})
|
|
608
608
|
} : {}
|
|
609
609
|
};
|
|
610
|
-
return
|
|
610
|
+
return i ? {
|
|
611
611
|
Wrapper: o,
|
|
612
612
|
block: t,
|
|
613
613
|
context: n,
|
|
614
614
|
wrapperProps: e,
|
|
615
|
-
includeBlockProps:
|
|
615
|
+
includeBlockProps: r
|
|
616
616
|
} : s;
|
|
617
617
|
};
|
|
618
618
|
function ComponentRef(e) {
|
|
@@ -679,10 +679,10 @@ function Block(e) {
|
|
|
679
679
|
context: e.context.context,
|
|
680
680
|
shouldEvaluateBindings: !0
|
|
681
681
|
});
|
|
682
|
-
},
|
|
682
|
+
}, r = function() {
|
|
683
683
|
var l;
|
|
684
684
|
return e.block.tagName === "a" || ((l = o().properties) == null ? void 0 : l.href) || o().href ? e.linkComponent || "a" : e.block.tagName || "div";
|
|
685
|
-
},
|
|
685
|
+
}, i = function() {
|
|
686
686
|
var u, b;
|
|
687
687
|
if ((u = e.block.repeat) != null && u.collection)
|
|
688
688
|
return !!((b = n()) != null && b.length);
|
|
@@ -714,7 +714,7 @@ function Block(e) {
|
|
|
714
714
|
isInteractive: !((C = t()) != null && C.isRSC)
|
|
715
715
|
};
|
|
716
716
|
}, c = e.context;
|
|
717
|
-
return /* @__PURE__ */ jsx(Fragment, { children:
|
|
717
|
+
return /* @__PURE__ */ jsx(Fragment, { children: i() ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
718
718
|
/* @__PURE__ */ jsx(BlockStyles, { block: e.block, context: e.context }),
|
|
719
719
|
(m = t()) != null && m.noWrap ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
720
720
|
ComponentRef,
|
|
@@ -741,7 +741,7 @@ function Block(e) {
|
|
|
741
741
|
)) }) : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
742
742
|
BlockWrapper,
|
|
743
743
|
{
|
|
744
|
-
Wrapper:
|
|
744
|
+
Wrapper: r(),
|
|
745
745
|
block: o(),
|
|
746
746
|
context: e.context,
|
|
747
747
|
linkComponent: e.linkComponent,
|
|
@@ -786,27 +786,27 @@ function Blocks(e) {
|
|
|
786
786
|
styleProp: e.styleProp,
|
|
787
787
|
BlocksWrapper: (t = e.context) == null ? void 0 : t.BlocksWrapper,
|
|
788
788
|
BlocksWrapperProps: (n = e.context) == null ? void 0 : n.BlocksWrapperProps,
|
|
789
|
-
children: e.blocks ? /* @__PURE__ */ jsx(Fragment, { children: (o = e.blocks) == null ? void 0 : o.map((
|
|
789
|
+
children: e.blocks ? /* @__PURE__ */ jsx(Fragment, { children: (o = e.blocks) == null ? void 0 : o.map((r) => /* @__PURE__ */ jsx(
|
|
790
790
|
Block,
|
|
791
791
|
{
|
|
792
|
-
block:
|
|
792
|
+
block: r,
|
|
793
793
|
linkComponent: e.linkComponent,
|
|
794
794
|
context: e.context,
|
|
795
795
|
registeredComponents: e.registeredComponents
|
|
796
796
|
},
|
|
797
|
-
|
|
797
|
+
r.id
|
|
798
798
|
)) }) : null
|
|
799
799
|
}
|
|
800
800
|
);
|
|
801
801
|
}
|
|
802
802
|
function Columns(e) {
|
|
803
803
|
var d;
|
|
804
|
-
const t = typeof e.space == "number" ? e.space || 0 : 20, n = e.columns || [], o = e.stackColumnsAt || "tablet",
|
|
804
|
+
const t = typeof e.space == "number" ? e.space || 0 : 20, n = e.columns || [], o = e.stackColumnsAt || "tablet", r = function(u) {
|
|
805
805
|
var b;
|
|
806
806
|
return ((b = n[u]) == null ? void 0 : b.width) || 100 / n.length;
|
|
807
|
-
},
|
|
807
|
+
}, i = function(u) {
|
|
808
808
|
const b = t * (n.length - 1) / n.length;
|
|
809
|
-
return `calc(${
|
|
809
|
+
return `calc(${r(u)}% - ${b}px)`;
|
|
810
810
|
}, a = function({
|
|
811
811
|
stackedStyle: u,
|
|
812
812
|
desktopStyle: b
|
|
@@ -826,7 +826,7 @@ function Columns(e) {
|
|
|
826
826
|
})
|
|
827
827
|
};
|
|
828
828
|
}, f = function(u) {
|
|
829
|
-
const b = u === 0 ? 0 : t, y =
|
|
829
|
+
const b = u === 0 ? 0 : t, y = i(u), h = `${b}px`, k = "100%", C = 0;
|
|
830
830
|
return {
|
|
831
831
|
...{
|
|
832
832
|
display: "flex",
|
|
@@ -934,8 +934,8 @@ function removeProtocol(e) {
|
|
|
934
934
|
return e.replace(/http(s)?:/, "");
|
|
935
935
|
}
|
|
936
936
|
function updateQueryParam(e = "", t, n) {
|
|
937
|
-
const o = new RegExp("([?&])" + t + "=.*?(&|$)", "i"),
|
|
938
|
-
return e.match(o) ? e.replace(o, "$1" + t + "=" + encodeURIComponent(n) + "$2") : e +
|
|
937
|
+
const o = new RegExp("([?&])" + t + "=.*?(&|$)", "i"), r = e.indexOf("?") !== -1 ? "&" : "?";
|
|
938
|
+
return e.match(o) ? e.replace(o, "$1" + t + "=" + encodeURIComponent(n) + "$2") : e + r + t + "=" + encodeURIComponent(n);
|
|
939
939
|
}
|
|
940
940
|
function getShopifyImageUrl(e, t) {
|
|
941
941
|
if (!e || !(e != null && e.match(/cdn\.shopify\.com/)) || !t)
|
|
@@ -944,8 +944,8 @@ function getShopifyImageUrl(e, t) {
|
|
|
944
944
|
return removeProtocol(e);
|
|
945
945
|
const n = e.match(/(_\d+x(\d+)?)?(\.(jpg|jpeg|gif|png|bmp|bitmap|tiff|tif)(\?v=\d+)?)/i);
|
|
946
946
|
if (n) {
|
|
947
|
-
const o = e.split(n[0]),
|
|
948
|
-
return removeProtocol(`${o[0]}_${
|
|
947
|
+
const o = e.split(n[0]), r = n[3], i = t.match("x") ? t : `${t}x`;
|
|
948
|
+
return removeProtocol(`${o[0]}_${i}${r}`);
|
|
949
949
|
}
|
|
950
950
|
return null;
|
|
951
951
|
}
|
|
@@ -956,7 +956,7 @@ function getSrcSet(e) {
|
|
|
956
956
|
if (e.match(/builder\.io/)) {
|
|
957
957
|
let n = e;
|
|
958
958
|
const o = Number(e.split("?width=")[1]);
|
|
959
|
-
return isNaN(o) || (n = `${n} ${o}w`), t.filter((
|
|
959
|
+
return isNaN(o) || (n = `${n} ${o}w`), t.filter((r) => r !== o).map((r) => `${updateQueryParam(e, "width", r)} ${r}w`).concat([n]).join(", ");
|
|
960
960
|
}
|
|
961
961
|
return e.match(/cdn\.shopify\.com/) ? t.map((n) => [getShopifyImageUrl(e, `${n}x${n}`), n]).filter(([n]) => !!n).map(([n, o]) => `${n} ${o}w`).concat([e]).join(", ") : e;
|
|
962
962
|
}
|
|
@@ -981,7 +981,7 @@ const getTopLevelDomain = (e) => {
|
|
|
981
981
|
value: t,
|
|
982
982
|
expires: n
|
|
983
983
|
}) => {
|
|
984
|
-
const
|
|
984
|
+
const r = (isBrowser() ? location.protocol === "https:" : !0) ? SECURE_CONFIG : [[]], i = n ? [["expires", n.toUTCString()]] : [[]], a = [[e, t], ...i, ["path", "/"], ["domain", getTopLevelDomain(window.location.hostname)], ...r];
|
|
985
985
|
return stringifyCookie(a);
|
|
986
986
|
}, setCookie = async ({
|
|
987
987
|
name: e,
|
|
@@ -992,14 +992,14 @@ const getTopLevelDomain = (e) => {
|
|
|
992
992
|
try {
|
|
993
993
|
if (!o)
|
|
994
994
|
return;
|
|
995
|
-
const
|
|
995
|
+
const r = createCookieString({
|
|
996
996
|
name: e,
|
|
997
997
|
value: t,
|
|
998
998
|
expires: n
|
|
999
999
|
});
|
|
1000
|
-
document.cookie =
|
|
1001
|
-
} catch (
|
|
1002
|
-
logger.warn("[COOKIE] SET error: ", (
|
|
1000
|
+
document.cookie = r;
|
|
1001
|
+
} catch (r) {
|
|
1002
|
+
logger.warn("[COOKIE] SET error: ", (r == null ? void 0 : r.message) || r);
|
|
1003
1003
|
}
|
|
1004
1004
|
}, BUILDER_STORE_PREFIX = "builder.tests", getContentTestKey = (e) => `${BUILDER_STORE_PREFIX}.${e}`, getContentVariationCookie = ({
|
|
1005
1005
|
contentId: e
|
|
@@ -1022,13 +1022,13 @@ const getTopLevelDomain = (e) => {
|
|
|
1022
1022
|
id: e,
|
|
1023
1023
|
variations: t
|
|
1024
1024
|
}) => {
|
|
1025
|
-
var
|
|
1025
|
+
var r;
|
|
1026
1026
|
let n = 0;
|
|
1027
1027
|
const o = Math.random();
|
|
1028
|
-
for (const
|
|
1029
|
-
const a = (
|
|
1028
|
+
for (const i in t) {
|
|
1029
|
+
const a = (r = t[i]) == null ? void 0 : r.testRatio;
|
|
1030
1030
|
if (n += a, o < n)
|
|
1031
|
-
return
|
|
1031
|
+
return i;
|
|
1032
1032
|
}
|
|
1033
1033
|
return e;
|
|
1034
1034
|
}, getAndSetVariantId = (e) => {
|
|
@@ -1087,13 +1087,13 @@ const getTopLevelDomain = (e) => {
|
|
|
1087
1087
|
}) || getAndSetVariantId({
|
|
1088
1088
|
variations: e.variations,
|
|
1089
1089
|
id: e.id
|
|
1090
|
-
}),
|
|
1090
|
+
}), r = getTestFields({
|
|
1091
1091
|
item: e,
|
|
1092
1092
|
testGroupId: o
|
|
1093
1093
|
});
|
|
1094
1094
|
return {
|
|
1095
1095
|
...e,
|
|
1096
|
-
...
|
|
1096
|
+
...r
|
|
1097
1097
|
};
|
|
1098
1098
|
}, getDefaultCanTrack = (e) => checkIsDefined(e) ? e : !0, componentInfo$b = {
|
|
1099
1099
|
name: "Core:Button",
|
|
@@ -1307,7 +1307,7 @@ const getTopLevelDomain = (e) => {
|
|
|
1307
1307
|
});
|
|
1308
1308
|
}
|
|
1309
1309
|
const n = e.get("columns");
|
|
1310
|
-
Array.isArray(n) && n.find((
|
|
1310
|
+
Array.isArray(n) && n.find((r) => r.get("width")) && (n.find((i) => !i.get("width")) || n.reduce((s, c) => s + c.get("width"), 0) !== 100) && t();
|
|
1311
1311
|
}
|
|
1312
1312
|
}, {
|
|
1313
1313
|
name: "space",
|
|
@@ -1418,13 +1418,13 @@ const getTopLevelDomain = (e) => {
|
|
|
1418
1418
|
function o(a) {
|
|
1419
1419
|
return Math.round(a * 1e3) / 1e3;
|
|
1420
1420
|
}
|
|
1421
|
-
const
|
|
1422
|
-
if (fetch(
|
|
1421
|
+
const r = e.get("image"), i = e.get("aspectRatio");
|
|
1422
|
+
if (fetch(r).then((a) => a.blob()).then((a) => {
|
|
1423
1423
|
a.type.includes("svg") && e.set("noWebp", !0);
|
|
1424
|
-
}),
|
|
1425
|
-
return n(
|
|
1424
|
+
}), r && (!i || i === 0.7041))
|
|
1425
|
+
return n(r).then((a) => {
|
|
1426
1426
|
const s = e.get("aspectRatio");
|
|
1427
|
-
e.get("image") ===
|
|
1427
|
+
e.get("image") === r && (!s || s === 0.7041) && a.width && a.height && (e.set("aspectRatio", o(a.height / a.width)), e.set("height", a.height), e.set("width", a.width));
|
|
1428
1428
|
});
|
|
1429
1429
|
}
|
|
1430
1430
|
}, {
|
|
@@ -1765,9 +1765,9 @@ const componentInfo = {
|
|
|
1765
1765
|
...t
|
|
1766
1766
|
}) => ({
|
|
1767
1767
|
...fastClone(t),
|
|
1768
|
-
inputs: e == null ? void 0 : e.map((n) => Object.entries(n).reduce((o, [
|
|
1768
|
+
inputs: e == null ? void 0 : e.map((n) => Object.entries(n).reduce((o, [r, i]) => ({
|
|
1769
1769
|
...o,
|
|
1770
|
-
[
|
|
1770
|
+
[r]: serializeValue(i)
|
|
1771
1771
|
}), {}))
|
|
1772
1772
|
}), UPDATE_COOKIES_AND_STYLES_SCRIPT = `function updateCookiesAndStyles(contentId, variants, isHydrationTarget) {
|
|
1773
1773
|
function getAndSetVariantId() {
|
|
@@ -1915,14 +1915,14 @@ function getFetch() {
|
|
|
1915
1915
|
}
|
|
1916
1916
|
const fetch$1 = getFetch();
|
|
1917
1917
|
function flatten(e, t = null, n = ".") {
|
|
1918
|
-
return Object.keys(e).reduce((o,
|
|
1919
|
-
const
|
|
1920
|
-
return [typeof
|
|
1918
|
+
return Object.keys(e).reduce((o, r) => {
|
|
1919
|
+
const i = e[r], a = [t, r].filter(Boolean).join(n);
|
|
1920
|
+
return [typeof i == "object", i !== null, !(Array.isArray(i) && i.length === 0)].every(Boolean) ? {
|
|
1921
1921
|
...o,
|
|
1922
|
-
...flatten(
|
|
1922
|
+
...flatten(i, a, n)
|
|
1923
1923
|
} : {
|
|
1924
1924
|
...o,
|
|
1925
|
-
[a]:
|
|
1925
|
+
[a]: i
|
|
1926
1926
|
};
|
|
1927
1927
|
}, {});
|
|
1928
1928
|
}
|
|
@@ -1937,8 +1937,8 @@ const DEFAULT_API_VERSION = "v3", BUILDER_SEARCHPARAMS_PREFIX = "builder.", BUIL
|
|
|
1937
1937
|
const t = normalizeSearchParams(e), n = {};
|
|
1938
1938
|
return Object.keys(t).forEach((o) => {
|
|
1939
1939
|
if (o.startsWith(BUILDER_SEARCHPARAMS_PREFIX)) {
|
|
1940
|
-
const
|
|
1941
|
-
n[
|
|
1940
|
+
const r = o.replace(BUILDER_SEARCHPARAMS_PREFIX, "").replace(BUILDER_OPTIONS_PREFIX, "");
|
|
1941
|
+
n[r] = t[o];
|
|
1942
1942
|
}
|
|
1943
1943
|
}), n;
|
|
1944
1944
|
}, getBuilderSearchParamsFromWindow = () => {
|
|
@@ -1953,8 +1953,8 @@ const DEFAULT_API_VERSION = "v3", BUILDER_SEARCHPARAMS_PREFIX = "builder.", BUIL
|
|
|
1953
1953
|
const {
|
|
1954
1954
|
limit: n = 30,
|
|
1955
1955
|
userAttributes: o,
|
|
1956
|
-
query:
|
|
1957
|
-
model:
|
|
1956
|
+
query: r,
|
|
1957
|
+
model: i,
|
|
1958
1958
|
apiKey: a,
|
|
1959
1959
|
includeRefs: s = !0,
|
|
1960
1960
|
enrich: c,
|
|
@@ -1973,7 +1973,7 @@ const DEFAULT_API_VERSION = "v3", BUILDER_SEARCHPARAMS_PREFIX = "builder.", BUIL
|
|
|
1973
1973
|
if (!["v2", "v3"].includes(f))
|
|
1974
1974
|
throw new Error(`Invalid apiVersion: expected 'v2' or 'v3', received '${f}'`);
|
|
1975
1975
|
(e.limit === void 0 || e.limit > 1) && !("noTraverse" in e) && (t = !0);
|
|
1976
|
-
const h = new URL(`https://cdn.builder.io/api/${f}/content/${
|
|
1976
|
+
const h = new URL(`https://cdn.builder.io/api/${f}/content/${i}?apiKey=${a}&limit=${n}&noTraverse=${t}&includeRefs=${s}${m ? `&locale=${m}` : ""}${c ? `&enrich=${c}` : ""}`);
|
|
1977
1977
|
if (h.searchParams.set("omit", g || "meta.componentsUsed"), p && h.searchParams.set("fields", p), Number.isFinite(d) && d > -1 && h.searchParams.set("offset", String(Math.floor(d))), typeof y == "boolean" && h.searchParams.set("includeUnpublished", String(y)), l && isPositiveNumber(l) && h.searchParams.set("cacheSeconds", String(l)), u && isPositiveNumber(u) && h.searchParams.set("staleCacheSeconds", String(u)), b) {
|
|
1978
1978
|
const S = flatten({
|
|
1979
1979
|
sort: b
|
|
@@ -1987,9 +1987,9 @@ const DEFAULT_API_VERSION = "v3", BUILDER_SEARCHPARAMS_PREFIX = "builder.", BUIL
|
|
|
1987
1987
|
}, C = flatten(k);
|
|
1988
1988
|
for (const S in C)
|
|
1989
1989
|
h.searchParams.set(S, String(C[S]));
|
|
1990
|
-
if (o && h.searchParams.set("userAttributes", JSON.stringify(o)),
|
|
1990
|
+
if (o && h.searchParams.set("userAttributes", JSON.stringify(o)), r) {
|
|
1991
1991
|
const S = flatten({
|
|
1992
|
-
query:
|
|
1992
|
+
query: r
|
|
1993
1993
|
});
|
|
1994
1994
|
for (const x in S)
|
|
1995
1995
|
h.searchParams.set(x, JSON.stringify(S[x]));
|
|
@@ -2009,25 +2009,25 @@ const getContent = fetchOneEntry, _fetchContent = async (e) => {
|
|
|
2009
2009
|
}, _processContentResult = async (e, t, n = generateContentUrl(e)) => {
|
|
2010
2010
|
const o = getDefaultCanTrack(e.canTrack);
|
|
2011
2011
|
if (n.search.includes("preview=")) {
|
|
2012
|
-
const
|
|
2012
|
+
const i = [];
|
|
2013
2013
|
for (const a of t.results) {
|
|
2014
2014
|
const s = getPreviewContent(n.searchParams);
|
|
2015
|
-
|
|
2015
|
+
i.push(s || a);
|
|
2016
2016
|
}
|
|
2017
|
-
t.results =
|
|
2017
|
+
t.results = i;
|
|
2018
2018
|
}
|
|
2019
2019
|
if (!o || !(isBrowser() || TARGET === "reactNative"))
|
|
2020
2020
|
return t.results;
|
|
2021
2021
|
try {
|
|
2022
|
-
const
|
|
2022
|
+
const i = [];
|
|
2023
2023
|
for (const a of t.results)
|
|
2024
|
-
|
|
2024
|
+
i.push(await handleABTesting({
|
|
2025
2025
|
item: a,
|
|
2026
2026
|
canTrack: o
|
|
2027
2027
|
}));
|
|
2028
|
-
t.results =
|
|
2029
|
-
} catch (
|
|
2030
|
-
logger.error("Could not process A/B tests. ",
|
|
2028
|
+
t.results = i;
|
|
2029
|
+
} catch (i) {
|
|
2030
|
+
logger.error("Could not process A/B tests. ", i);
|
|
2031
2031
|
}
|
|
2032
2032
|
return t.results;
|
|
2033
2033
|
};
|
|
@@ -2043,11 +2043,7 @@ async function fetchEntries(e) {
|
|
|
2043
2043
|
return logger.error("Error fetching data. ", t), null;
|
|
2044
2044
|
}
|
|
2045
2045
|
}
|
|
2046
|
-
const getAllContent = fetchEntries
|
|
2047
|
-
function isFromTrustedHost(e, t) {
|
|
2048
|
-
const n = new URL(t.origin), o = n.hostname;
|
|
2049
|
-
return (e || DEFAULT_TRUSTED_HOSTS).findIndex((i) => i.startsWith("*.") ? o.endsWith(i.slice(1)) : i === o) > -1;
|
|
2050
|
-
}
|
|
2046
|
+
const getAllContent = fetchEntries;
|
|
2051
2047
|
function isPreviewing() {
|
|
2052
2048
|
return !isBrowser() || isEditing() ? !1 : location.search.indexOf("builder.preview=") !== -1;
|
|
2053
2049
|
}
|
|
@@ -2104,8 +2100,8 @@ const SESSION_LOCAL_STORAGE_KEY = "builderSessionId", getSessionId = async ({
|
|
|
2104
2100
|
var o;
|
|
2105
2101
|
try {
|
|
2106
2102
|
t && ((o = getLocalStorage()) == null || o.setItem(e, n));
|
|
2107
|
-
} catch (
|
|
2108
|
-
console.debug("[LocalStorage] SET error: ",
|
|
2103
|
+
} catch (r) {
|
|
2104
|
+
console.debug("[LocalStorage] SET error: ", r);
|
|
2109
2105
|
}
|
|
2110
2106
|
}, VISITOR_LOCAL_STORAGE_KEY = "builderVisitorId", getVisitorId = ({
|
|
2111
2107
|
canTrack: e
|
|
@@ -2154,11 +2150,11 @@ const SESSION_LOCAL_STORAGE_KEY = "builderSessionId", getSessionId = async ({
|
|
|
2154
2150
|
canTrack: t,
|
|
2155
2151
|
apiKey: n,
|
|
2156
2152
|
metadata: o,
|
|
2157
|
-
...
|
|
2153
|
+
...r
|
|
2158
2154
|
}) => ({
|
|
2159
2155
|
type: e,
|
|
2160
2156
|
data: {
|
|
2161
|
-
...
|
|
2157
|
+
...r,
|
|
2162
2158
|
metadata: {
|
|
2163
2159
|
url: location.href,
|
|
2164
2160
|
...o
|
|
@@ -2214,9 +2210,9 @@ const findParentElement = (e, t, n = !0) => {
|
|
|
2214
2210
|
event: e,
|
|
2215
2211
|
target: t
|
|
2216
2212
|
}) => {
|
|
2217
|
-
const n = t.getBoundingClientRect(), o = e.clientX - n.left,
|
|
2213
|
+
const n = t.getBoundingClientRect(), o = e.clientX - n.left, r = e.clientY - n.top, i = round(o / n.width), a = round(r / n.height);
|
|
2218
2214
|
return {
|
|
2219
|
-
x:
|
|
2215
|
+
x: i,
|
|
2220
2216
|
y: a
|
|
2221
2217
|
};
|
|
2222
2218
|
}, getInteractionPropertiesForEvent = (e) => {
|
|
@@ -2235,7 +2231,12 @@ const findParentElement = (e, t, n = !0) => {
|
|
|
2235
2231
|
builderElementIndex: n && o ? [].slice.call(document.getElementsByClassName(o)).indexOf(n) : void 0
|
|
2236
2232
|
}
|
|
2237
2233
|
};
|
|
2238
|
-
},
|
|
2234
|
+
}, DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
|
|
2235
|
+
function isFromTrustedHost(e, t) {
|
|
2236
|
+
const n = new URL(t.origin), o = n.hostname;
|
|
2237
|
+
return (e || DEFAULT_TRUSTED_HOSTS).findIndex((r) => r.startsWith("*.") ? o.endsWith(r.slice(1)) : r === o) > -1;
|
|
2238
|
+
}
|
|
2239
|
+
const SDK_VERSION = "0.12.8", registry = {};
|
|
2239
2240
|
function register(e, t) {
|
|
2240
2241
|
let n = registry[e];
|
|
2241
2242
|
if (n || (n = registry[e] = []), n.push(t), isBrowser()) {
|
|
@@ -2248,8 +2249,8 @@ function register(e, t) {
|
|
|
2248
2249
|
};
|
|
2249
2250
|
try {
|
|
2250
2251
|
parent.postMessage(o, "*"), parent !== window && window.postMessage(o, "*");
|
|
2251
|
-
} catch (
|
|
2252
|
-
console.debug("Could not postmessage",
|
|
2252
|
+
} catch (r) {
|
|
2253
|
+
console.debug("Could not postmessage", r);
|
|
2253
2254
|
}
|
|
2254
2255
|
}
|
|
2255
2256
|
}
|
|
@@ -2296,23 +2297,23 @@ const setupBrowserForEditing = (e = {}) => {
|
|
|
2296
2297
|
options: e
|
|
2297
2298
|
}
|
|
2298
2299
|
}, "*"), window.addEventListener("message", (o) => {
|
|
2299
|
-
var
|
|
2300
|
+
var i, a;
|
|
2300
2301
|
if (!isFromTrustedHost(e.trustedHosts, o))
|
|
2301
2302
|
return;
|
|
2302
2303
|
const {
|
|
2303
|
-
data:
|
|
2304
|
+
data: r
|
|
2304
2305
|
} = o;
|
|
2305
|
-
if (
|
|
2306
|
-
switch (
|
|
2306
|
+
if (r != null && r.type)
|
|
2307
|
+
switch (r.type) {
|
|
2307
2308
|
case "builder.evaluate": {
|
|
2308
|
-
const s =
|
|
2309
|
+
const s = r.data.text, c = r.data.arguments || [], m = r.data.id, f = new Function(s);
|
|
2309
2310
|
let p, g = null;
|
|
2310
2311
|
try {
|
|
2311
2312
|
p = f.apply(null, c);
|
|
2312
2313
|
} catch (d) {
|
|
2313
2314
|
g = d;
|
|
2314
2315
|
}
|
|
2315
|
-
g ? (
|
|
2316
|
+
g ? (i = window.parent) == null || i.postMessage({
|
|
2316
2317
|
type: "builder.evaluateError",
|
|
2317
2318
|
data: {
|
|
2318
2319
|
id: m,
|
|
@@ -2338,11 +2339,98 @@ const setupBrowserForEditing = (e = {}) => {
|
|
|
2338
2339
|
}
|
|
2339
2340
|
}
|
|
2340
2341
|
})));
|
|
2341
|
-
},
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2342
|
+
}, createEditorListener = ({
|
|
2343
|
+
model: e,
|
|
2344
|
+
trustedHosts: t,
|
|
2345
|
+
callbacks: n
|
|
2346
|
+
}) => (o) => {
|
|
2347
|
+
if (!isFromTrustedHost(t, o))
|
|
2348
|
+
return;
|
|
2349
|
+
const {
|
|
2350
|
+
data: r
|
|
2351
|
+
} = o;
|
|
2352
|
+
if (r)
|
|
2353
|
+
switch (r.type) {
|
|
2354
|
+
case "builder.configureSdk": {
|
|
2355
|
+
n.configureSdk(r.data);
|
|
2356
|
+
break;
|
|
2357
|
+
}
|
|
2358
|
+
case "builder.triggerAnimation": {
|
|
2359
|
+
n.animation(r.data);
|
|
2360
|
+
break;
|
|
2361
|
+
}
|
|
2362
|
+
case "builder.contentUpdate": {
|
|
2363
|
+
const i = r.data, a = i.key || i.alias || i.entry || i.modelName, s = i.data;
|
|
2364
|
+
a === e && n.contentUpdate(s);
|
|
2365
|
+
break;
|
|
2366
|
+
}
|
|
2367
|
+
}
|
|
2368
|
+
}, subscribeToEditor = (e, t, n) => {
|
|
2369
|
+
if (!isBrowser)
|
|
2370
|
+
return logger.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."), () => {
|
|
2371
|
+
};
|
|
2372
|
+
setupBrowserForEditing();
|
|
2373
|
+
const o = createEditorListener({
|
|
2374
|
+
callbacks: {
|
|
2375
|
+
contentUpdate: t,
|
|
2376
|
+
animation: () => {
|
|
2377
|
+
},
|
|
2378
|
+
configureSdk: () => {
|
|
2379
|
+
}
|
|
2380
|
+
},
|
|
2381
|
+
model: e,
|
|
2382
|
+
trustedHosts: n == null ? void 0 : n.trustedHosts
|
|
2383
|
+
});
|
|
2384
|
+
return window.addEventListener("message", o), () => {
|
|
2385
|
+
window.removeEventListener("message", o);
|
|
2386
|
+
};
|
|
2387
|
+
};
|
|
2388
|
+
function assign(e, ...t) {
|
|
2389
|
+
const n = Object(e);
|
|
2390
|
+
for (let o = 1; o < arguments.length; o++) {
|
|
2391
|
+
const r = arguments[o];
|
|
2392
|
+
if (r != null)
|
|
2393
|
+
for (const i in r)
|
|
2394
|
+
Object.prototype.hasOwnProperty.call(r, i) && (n[i] = r[i]);
|
|
2395
|
+
}
|
|
2396
|
+
return n;
|
|
2397
|
+
}
|
|
2398
|
+
const camelCaseToKebabCase = (e) => e ? e.replace(/([A-Z])/g, (t) => `-${t[0].toLowerCase()}`) : "";
|
|
2399
|
+
function warnElementNotPresent(e) {
|
|
2400
|
+
console.warn(`Cannot animate element: element with ID ${e} not found!`);
|
|
2401
|
+
}
|
|
2402
|
+
function augmentAnimation(e, t) {
|
|
2403
|
+
const n = getAllStylesUsed(e), o = getComputedStyle(t), r = e.steps[0].styles, i = e.steps[e.steps.length - 1].styles, a = [r, i];
|
|
2404
|
+
for (const s of a)
|
|
2405
|
+
for (const c of n)
|
|
2406
|
+
c in s || (s[c] = o[c]);
|
|
2407
|
+
}
|
|
2408
|
+
function getAllStylesUsed(e) {
|
|
2409
|
+
const t = [];
|
|
2410
|
+
for (const n of e.steps)
|
|
2411
|
+
for (const o in n.styles)
|
|
2412
|
+
t.indexOf(o) === -1 && t.push(o);
|
|
2413
|
+
return t;
|
|
2414
|
+
}
|
|
2415
|
+
function triggerAnimation(e) {
|
|
2416
|
+
const t = Array.prototype.slice.call(document.getElementsByClassName(e.elementId || e.id || ""));
|
|
2417
|
+
if (!t.length) {
|
|
2418
|
+
warnElementNotPresent(e.elementId || e.id || "");
|
|
2419
|
+
return;
|
|
2420
|
+
}
|
|
2421
|
+
Array.from(t).forEach((n) => {
|
|
2422
|
+
augmentAnimation(e, n), n.style.transition = "none", n.style.transitionDelay = "0", assign(n.style, e.steps[0].styles), setTimeout(() => {
|
|
2423
|
+
n.style.transition = `all ${e.duration}s ${camelCaseToKebabCase(e.easing)}`, e.delay && (n.style.transitionDelay = e.delay + "s"), assign(n.style, e.steps[1].styles), setTimeout(() => {
|
|
2424
|
+
n.style.transition = "", n.style.transitionDelay = "";
|
|
2425
|
+
}, (e.delay || 0) * 1e3 + e.duration * 1e3 + 100);
|
|
2426
|
+
});
|
|
2427
|
+
});
|
|
2428
|
+
}
|
|
2429
|
+
const getCssFromFont = (e) => {
|
|
2430
|
+
var i;
|
|
2431
|
+
const t = e.family + (e.kind && !e.kind.includes("#") ? ", " + e.kind : ""), n = t.split(",")[0], o = e.fileUrl ?? ((i = e == null ? void 0 : e.files) == null ? void 0 : i.regular);
|
|
2432
|
+
let r = "";
|
|
2433
|
+
if (o && t && n && (r += `
|
|
2346
2434
|
@font-face {
|
|
2347
2435
|
font-family: "${t}";
|
|
2348
2436
|
src: local("${n}"), url('${o}') format('woff2');
|
|
@@ -2354,7 +2442,7 @@ font-weight: 400;
|
|
|
2354
2442
|
if (!(String(Number(a)) === a))
|
|
2355
2443
|
continue;
|
|
2356
2444
|
const c = e.files[a];
|
|
2357
|
-
c && c !== o && (
|
|
2445
|
+
c && c !== o && (r += `
|
|
2358
2446
|
@font-face {
|
|
2359
2447
|
font-family: "${t}";
|
|
2360
2448
|
src: url('${c}') format('woff2');
|
|
@@ -2363,7 +2451,7 @@ font-weight: ${a};
|
|
|
2363
2451
|
}
|
|
2364
2452
|
`.trim());
|
|
2365
2453
|
}
|
|
2366
|
-
return
|
|
2454
|
+
return r;
|
|
2367
2455
|
}, getFontCss = ({
|
|
2368
2456
|
customFonts: e
|
|
2369
2457
|
}) => {
|
|
@@ -2407,13 +2495,13 @@ const getRootStateInitialValue = ({
|
|
|
2407
2495
|
data: t,
|
|
2408
2496
|
locale: n
|
|
2409
2497
|
}) => {
|
|
2410
|
-
var
|
|
2411
|
-
const o = {},
|
|
2498
|
+
var i, a, s;
|
|
2499
|
+
const o = {}, r = ((i = e == null ? void 0 : e.data) == null ? void 0 : i.state) || {};
|
|
2412
2500
|
return (s = (a = e == null ? void 0 : e.data) == null ? void 0 : a.inputs) == null || s.forEach((c) => {
|
|
2413
2501
|
c.name && c.defaultValue !== void 0 && (o[c.name] = c.defaultValue);
|
|
2414
2502
|
}), {
|
|
2415
2503
|
...o,
|
|
2416
|
-
...
|
|
2504
|
+
...r,
|
|
2417
2505
|
...t,
|
|
2418
2506
|
...n ? {
|
|
2419
2507
|
locale: n
|
|
@@ -2431,12 +2519,12 @@ const getRootStateInitialValue = ({
|
|
|
2431
2519
|
meta: e == null ? void 0 : e.meta
|
|
2432
2520
|
} : void 0;
|
|
2433
2521
|
function ContentComponent(e) {
|
|
2434
|
-
var
|
|
2522
|
+
var r, i, a, s, c, m, f, p, g;
|
|
2435
2523
|
const t = getUpdateVariantVisibilityScript({
|
|
2436
2524
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
2437
|
-
variationId: (
|
|
2525
|
+
variationId: (r = e.content) == null ? void 0 : r.testVariationId,
|
|
2438
2526
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
2439
|
-
contentId: (
|
|
2527
|
+
contentId: (i = e.content) == null ? void 0 : i.id
|
|
2440
2528
|
}), n = [
|
|
2441
2529
|
...getDefaultRegisteredComponents(),
|
|
2442
2530
|
// While this `components` object is deprecated, we must maintain support for it.
|
|
@@ -2532,7 +2620,7 @@ function ContentComponent(e) {
|
|
|
2532
2620
|
);
|
|
2533
2621
|
}
|
|
2534
2622
|
function ContentVariants(e) {
|
|
2535
|
-
var
|
|
2623
|
+
var i, a;
|
|
2536
2624
|
const t = checkShouldRenderVariants({
|
|
2537
2625
|
canTrack: getDefaultCanTrack(e.canTrack),
|
|
2538
2626
|
content: e.content
|
|
@@ -2547,7 +2635,7 @@ function ContentVariants(e) {
|
|
|
2547
2635
|
);
|
|
2548
2636
|
}, o = function() {
|
|
2549
2637
|
return getVariants(e.content).map((c) => `.variant-${c.testVariationId} { display: none; } `).join("");
|
|
2550
|
-
},
|
|
2638
|
+
}, r = function() {
|
|
2551
2639
|
var c;
|
|
2552
2640
|
return t ? {
|
|
2553
2641
|
...e.content,
|
|
@@ -2563,7 +2651,7 @@ function ContentVariants(e) {
|
|
|
2563
2651
|
/* @__PURE__ */ jsx(
|
|
2564
2652
|
InlinedStyles,
|
|
2565
2653
|
{
|
|
2566
|
-
id: `variants-styles-${(
|
|
2654
|
+
id: `variants-styles-${(i = e.content) == null ? void 0 : i.id}`,
|
|
2567
2655
|
styles: o()
|
|
2568
2656
|
}
|
|
2569
2657
|
),
|
|
@@ -2597,7 +2685,7 @@ function ContentVariants(e) {
|
|
|
2597
2685
|
/* @__PURE__ */ jsx(
|
|
2598
2686
|
ContentComponent,
|
|
2599
2687
|
{
|
|
2600
|
-
content:
|
|
2688
|
+
content: r(),
|
|
2601
2689
|
showContent: !0,
|
|
2602
2690
|
model: e.model,
|
|
2603
2691
|
data: e.data,
|
|
@@ -2640,7 +2728,7 @@ const fetchSymbolContent = async ({
|
|
|
2640
2728
|
});
|
|
2641
2729
|
};
|
|
2642
2730
|
async function Symbol$1(e) {
|
|
2643
|
-
var o,
|
|
2731
|
+
var o, r, i, a, s;
|
|
2644
2732
|
const t = function() {
|
|
2645
2733
|
var m, f;
|
|
2646
2734
|
return [
|
|
@@ -2661,11 +2749,11 @@ async function Symbol$1(e) {
|
|
|
2661
2749
|
apiKey: e.builderContext.apiKey,
|
|
2662
2750
|
context: {
|
|
2663
2751
|
...e.builderContext.context,
|
|
2664
|
-
symbolId: (
|
|
2752
|
+
symbolId: (r = e.builderBlock) == null ? void 0 : r.id
|
|
2665
2753
|
},
|
|
2666
2754
|
customComponents: Object.values(e.builderComponents),
|
|
2667
2755
|
data: {
|
|
2668
|
-
...(
|
|
2756
|
+
...(i = e.symbol) == null ? void 0 : i.data,
|
|
2669
2757
|
...e.builderContext.localState,
|
|
2670
2758
|
...(a = n == null ? void 0 : n.data) == null ? void 0 : a.state
|
|
2671
2759
|
},
|
|
@@ -2687,8 +2775,8 @@ function setEditorSettings(e) {
|
|
|
2687
2775
|
}
|
|
2688
2776
|
}
|
|
2689
2777
|
const fetchBuilderProps = async (e) => {
|
|
2690
|
-
var o,
|
|
2691
|
-
const t = e.path || ((o = e.url) == null ? void 0 : o.pathname) || ((
|
|
2778
|
+
var o, r, i;
|
|
2779
|
+
const t = e.path || ((o = e.url) == null ? void 0 : o.pathname) || ((r = e.userAttributes) == null ? void 0 : r.urlPath), n = {
|
|
2692
2780
|
...e,
|
|
2693
2781
|
apiKey: e.apiKey,
|
|
2694
2782
|
model: e.model || "page",
|
|
@@ -2698,7 +2786,7 @@ const fetchBuilderProps = async (e) => {
|
|
|
2698
2786
|
urlPath: t
|
|
2699
2787
|
} : {}
|
|
2700
2788
|
},
|
|
2701
|
-
options: getBuilderSearchParams(e.searchParams || ((
|
|
2789
|
+
options: getBuilderSearchParams(e.searchParams || ((i = e.url) == null ? void 0 : i.searchParams) || e.options)
|
|
2702
2790
|
};
|
|
2703
2791
|
return {
|
|
2704
2792
|
apiKey: n.apiKey,
|
|
@@ -2707,14 +2795,16 @@ const fetchBuilderProps = async (e) => {
|
|
|
2707
2795
|
};
|
|
2708
2796
|
};
|
|
2709
2797
|
export {
|
|
2710
|
-
|
|
2798
|
+
getBuilderSearchParams as A,
|
|
2711
2799
|
Blocks as B,
|
|
2712
2800
|
ContentVariants as C,
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2801
|
+
track as D,
|
|
2802
|
+
subscribeToEditor as E,
|
|
2803
|
+
fetchBuilderProps as F,
|
|
2804
|
+
_processContentResult as G,
|
|
2805
|
+
fetchEntries as H,
|
|
2806
|
+
getAllContent as I,
|
|
2807
|
+
getContent as J,
|
|
2718
2808
|
RenderBlocks as R,
|
|
2719
2809
|
Symbol$1 as S,
|
|
2720
2810
|
Text as T,
|
|
@@ -2729,7 +2819,7 @@ export {
|
|
|
2729
2819
|
getDefaultCanTrack as h,
|
|
2730
2820
|
isEmptyElement as i,
|
|
2731
2821
|
isPreviewing as j,
|
|
2732
|
-
|
|
2822
|
+
createEditorListener as k,
|
|
2733
2823
|
logger as l,
|
|
2734
2824
|
evaluate as m,
|
|
2735
2825
|
getInteractionPropertiesForEvent as n,
|
|
@@ -2738,11 +2828,11 @@ export {
|
|
|
2738
2828
|
fetchOneEntry as q,
|
|
2739
2829
|
registerInsertMenu as r,
|
|
2740
2830
|
setupBrowserForEditing as s,
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2831
|
+
triggerAnimation as t,
|
|
2832
|
+
fetch$1 as u,
|
|
2833
|
+
init as v,
|
|
2834
|
+
RenderContent as w,
|
|
2835
|
+
Columns as x,
|
|
2836
|
+
register as y,
|
|
2837
|
+
setEditorSettings as z
|
|
2748
2838
|
};
|