@builder.io/sdk-react 3.0.3-0 → 3.0.5
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/blocks-exports.cjs +32 -169
- package/lib/browser/blocks-exports.mjs +778 -1199
- package/lib/browser/index.cjs +1 -1
- package/lib/browser/index.mjs +16 -17
- package/lib/browser/server-entry-101d66b8.cjs +2 -0
- package/lib/browser/{server-entry-da1754bd.js → server-entry-785c0408.js} +237 -279
- package/lib/browser/server-entry.cjs +1 -1
- package/lib/browser/server-entry.mjs +1 -1
- package/lib/edge/{accordion-388f5e60.cjs → accordion-190c4426.cjs} +1 -1
- package/lib/edge/{accordion-50de133c.js → accordion-cd6e0363.js} +1 -1
- package/lib/edge/{blocks-a5193d52.cjs → blocks-766e8d45.cjs} +9 -9
- package/lib/edge/blocks-exports.cjs +1 -1
- package/lib/edge/blocks-exports.mjs +12 -13
- package/lib/edge/{blocks-5e476ddc.js → blocks-fe2d7c1a.js} +2 -3
- package/lib/edge/{button-c6ec3aea.cjs → button-694fcd4f.cjs} +1 -1
- package/lib/edge/{button-4261ae64.js → button-6a27481c.js} +2 -2
- package/lib/edge/{columns-28e9fb0a.js → columns-90e6407e.js} +18 -18
- package/lib/edge/{columns-8c831c02.cjs → columns-b38bf0f7.cjs} +2 -2
- package/lib/edge/content-variants-4e385c19.cjs +134 -0
- package/lib/edge/{content-variants-36ca4fe5.js → content-variants-cbb89349.js} +124 -165
- package/lib/edge/dynamic-blocks-exports.cjs +1 -3
- package/lib/edge/dynamic-blocks-exports.mjs +2 -5
- package/lib/edge/form-16bbf874.js +166 -0
- package/lib/edge/form-547645eb.cjs +1 -0
- package/lib/edge/{get-class-prop-name-a86a3e60.cjs → get-class-prop-name-58770197.cjs} +1 -1
- package/lib/edge/{get-class-prop-name-65d6824c.js → get-class-prop-name-8b719c6b.js} +1 -1
- package/lib/edge/{image-2a2b26d2.js → image-38917f45.js} +22 -24
- package/lib/edge/image-590e36ae.cjs +17 -0
- package/lib/edge/{img-7de3a3de.cjs → img-8859c851.cjs} +1 -1
- package/lib/edge/{img-61d29fb3.js → img-d3351743.js} +1 -1
- package/lib/edge/index.cjs +1 -1
- package/lib/edge/index.mjs +17 -18
- package/lib/edge/{input-c8539054.js → input-24c601b4.js} +1 -1
- package/lib/edge/{input-bd5387a6.cjs → input-4fe0fc6d.cjs} +1 -1
- package/lib/edge/{select-6b5cda00.js → select-af05377b.js} +1 -1
- package/lib/edge/{select-73accaf4.cjs → select-c73bd418.cjs} +1 -1
- package/lib/edge/server-entry-3c7fa63a.cjs +2 -0
- package/lib/edge/{server-entry-838c1f06.js → server-entry-67bfc740.js} +280 -322
- package/lib/edge/server-entry.cjs +1 -1
- package/lib/edge/server-entry.mjs +1 -1
- package/lib/edge/{slot-403c77da.js → slot-32a4df0c.js} +3 -3
- package/lib/edge/{slot-099112f1.cjs → slot-759c8dd9.cjs} +1 -1
- package/lib/edge/{symbol-97f456f4.js → symbol-50360a37.js} +2 -2
- package/lib/edge/{symbol-ffa6e6cd.cjs → symbol-8d63aa7d.cjs} +1 -1
- package/lib/edge/{tabs-a7c94ead.js → tabs-6535c934.js} +3 -3
- package/lib/edge/{tabs-ad55c6a7.cjs → tabs-fc6c1700.cjs} +1 -1
- package/lib/edge/video-4ecfd08b.cjs +1 -0
- package/lib/edge/{video-58c2cc8d.js → video-a3f10439.js} +0 -1
- package/lib/node/blocks-exports.cjs +32 -169
- package/lib/node/blocks-exports.mjs +896 -1317
- package/lib/node/index.cjs +1 -1
- package/lib/node/index.mjs +16 -17
- package/lib/node/init.cjs +1 -1
- package/lib/node/init.mjs +3 -3
- package/lib/node/server-entry-95273908.cjs +2 -0
- package/lib/node/{server-entry-51bc0b1d.js → server-entry-ffc70868.js} +237 -279
- package/lib/node/server-entry.cjs +1 -1
- package/lib/node/server-entry.mjs +1 -1
- package/lib/node/{setIvm-575cf1f1.js → setIvm-2cea7252.js} +1 -1
- package/lib/node/{setIvm-d912cf4d.cjs → setIvm-4ce0db03.cjs} +1 -1
- package/lib/node/setIvm.cjs +1 -1
- package/lib/node/setIvm.mjs +2 -2
- package/lib/node/{should-force-browser-runtime-in-node-66df4856.js → should-force-browser-runtime-in-node-c0d50009.js} +1 -1
- package/lib/node/{should-force-browser-runtime-in-node-23225980.cjs → should-force-browser-runtime-in-node-d3e6df07.cjs} +1 -1
- package/package.json +2 -2
- package/types/blocks/form/form/form.d.ts +1 -0
- package/types/constants/sdk-version.d.ts +1 -1
- package/types/index-helpers/blocks-exports.d.ts +0 -1
- package/types/types/components.d.ts +2 -2
- package/types/types/input.d.ts +0 -1
- package/lib/browser/server-entry-c7bda8b5.cjs +0 -2
- package/lib/edge/content-variants-81713434.cjs +0 -134
- package/lib/edge/form-039fb5ff.js +0 -176
- package/lib/edge/form-e7a1dec9.cjs +0 -1
- package/lib/edge/image-4db81d72.cjs +0 -17
- package/lib/edge/personalization-container-3fda6014.cjs +0 -138
- package/lib/edge/personalization-container-c76e4fef.js +0 -379
- package/lib/edge/server-entry-ea2a8b0e.cjs +0 -2
- package/lib/edge/video-e20dcbbc.cjs +0 -1
- package/lib/node/server-entry-d7316893.cjs +0 -2
- package/types/blocks/index.d.ts +0 -4
- package/types/blocks/personalization-container/component-info.d.ts +0 -2
- package/types/blocks/personalization-container/helpers/index.d.ts +0 -15
- package/types/blocks/personalization-container/helpers/inlined-fns.d.ts +0 -8
- package/types/blocks/personalization-container/helpers.d.ts +0 -27
- package/types/blocks/personalization-container/index.d.ts +0 -1
- package/types/blocks/personalization-container/personalization-container.d.ts +0 -4
- package/types/blocks/personalization-container/personalization-container.types.d.ts +0 -14
- package/types/blocks/textarea/component-info.d.ts +0 -2
- package/types/blocks/textarea/index.d.ts +0 -1
- package/types/blocks/textarea/textarea.d.ts +0 -14
- package/types/functions/filter-with-custom-targeting.d.ts +0 -15
- package/types/helpers/user-attributes.d.ts +0 -17
|
@@ -38,8 +38,7 @@ __export(stdin_exports, {
|
|
|
38
38
|
Section: () => Section,
|
|
39
39
|
Symbol: () => Symbol2,
|
|
40
40
|
Text: () => Text,
|
|
41
|
-
Video: () => Video
|
|
42
|
-
setClientUserAttributes: () => setClientUserAttributes
|
|
41
|
+
Video: () => Video
|
|
43
42
|
});
|
|
44
43
|
module.exports = __toCommonJS(stdin_exports);
|
|
45
44
|
var import_react = __toESM(require("react"));
|
|
@@ -59,4 +58,3 @@ const Video = import_blocks_exports.Video;
|
|
|
59
58
|
const Blocks = (props) => isBrowser() ? /* @__PURE__ */ import_react.default.createElement(BrowserSdk.Blocks, { ...props }) : /* @__PURE__ */ import_react.default.createElement(import_blocks_exports.Blocks, { ...props });
|
|
60
59
|
const Content = (props) => isBrowser() ? /* @__PURE__ */ import_react.default.createElement(BrowserSdk.Content, { ...props }) : /* @__PURE__ */ import_react.default.createElement(import_blocks_exports.Content, { ...props });
|
|
61
60
|
const BuilderContext = import_blocks_exports.BuilderContext;
|
|
62
|
-
const setClientUserAttributes = import_blocks_exports.setClientUserAttributes;
|
|
@@ -15,8 +15,7 @@ import {
|
|
|
15
15
|
Video as EdgeSdkVideo,
|
|
16
16
|
Blocks as EdgeSdkBlocks,
|
|
17
17
|
Content as EdgeSdkContent,
|
|
18
|
-
BuilderContext as EdgeSdkBuilderContext
|
|
19
|
-
setClientUserAttributes as EdgeSdksetClientUserAttributes
|
|
18
|
+
BuilderContext as EdgeSdkBuilderContext
|
|
20
19
|
} from "./blocks-exports.mjs";
|
|
21
20
|
const Button = EdgeSdkButton;
|
|
22
21
|
const Columns = EdgeSdkColumns;
|
|
@@ -29,7 +28,6 @@ const Video = EdgeSdkVideo;
|
|
|
29
28
|
const Blocks = (props) => isBrowser() ? /* @__PURE__ */ React.createElement(BrowserSdk.Blocks, { ...props }) : /* @__PURE__ */ React.createElement(EdgeSdkBlocks, { ...props });
|
|
30
29
|
const Content = (props) => isBrowser() ? /* @__PURE__ */ React.createElement(BrowserSdk.Content, { ...props }) : /* @__PURE__ */ React.createElement(EdgeSdkContent, { ...props });
|
|
31
30
|
const BuilderContext = EdgeSdkBuilderContext;
|
|
32
|
-
const setClientUserAttributes = EdgeSdksetClientUserAttributes;
|
|
33
31
|
export {
|
|
34
32
|
Blocks,
|
|
35
33
|
BuilderContext,
|
|
@@ -41,6 +39,5 @@ export {
|
|
|
41
39
|
Section,
|
|
42
40
|
Symbol,
|
|
43
41
|
Text,
|
|
44
|
-
Video
|
|
45
|
-
setClientUserAttributes
|
|
42
|
+
Video
|
|
46
43
|
};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { jsxs as k, Fragment as A, jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as j, useState as h } from "react";
|
|
3
|
+
import { Blocks as g, set as J, get as O } from "./blocks-fe2d7c1a.js";
|
|
4
|
+
import { isEditing as U, logFetch as R } from "./server-entry-67bfc740.js";
|
|
5
|
+
import "./blocks-exports.mjs";
|
|
6
|
+
import "./get-class-prop-name-8b719c6b.js";
|
|
7
|
+
import "./dynamic-renderer-8b343325.js";
|
|
8
|
+
const $ = ["production", "qa", "test", "development", "dev", "cdn-qa", "cloud", "fast", "cdn2", "cdn-prod"], q = () => {
|
|
9
|
+
const e = process.env.NODE_ENV || "production";
|
|
10
|
+
return $.includes(e) ? e : "production";
|
|
11
|
+
};
|
|
12
|
+
function _(e) {
|
|
13
|
+
const r = j(null), [T, b] = h(() => "unsubmitted"), [v, y] = h(() => null), [L, F] = h(() => "");
|
|
14
|
+
function N(s) {
|
|
15
|
+
var u, l;
|
|
16
|
+
const c = {
|
|
17
|
+
...e.builderContext.rootState,
|
|
18
|
+
...s
|
|
19
|
+
};
|
|
20
|
+
e.builderContext.rootSetState ? (l = (u = e.builderContext).rootSetState) == null || l.call(u, c) : e.builderContext.rootState = c;
|
|
21
|
+
}
|
|
22
|
+
function f() {
|
|
23
|
+
return U() && e.previewState || T;
|
|
24
|
+
}
|
|
25
|
+
function w(s) {
|
|
26
|
+
var u;
|
|
27
|
+
const c = e.sendWithJs || e.sendSubmissionsTo === "email";
|
|
28
|
+
if (e.sendSubmissionsTo === "zapier")
|
|
29
|
+
s.preventDefault();
|
|
30
|
+
else if (c) {
|
|
31
|
+
if (!(e.action || e.sendSubmissionsTo === "email")) {
|
|
32
|
+
s.preventDefault();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
s.preventDefault();
|
|
36
|
+
const l = s.currentTarget || s.target, S = e.customHeaders || {};
|
|
37
|
+
let d;
|
|
38
|
+
const D = new FormData(l), E = Array.from(l.querySelectorAll("input,select,textarea")).filter((t) => !!t.name).map((t) => {
|
|
39
|
+
let n;
|
|
40
|
+
const o = t.name;
|
|
41
|
+
if (t instanceof HTMLInputElement)
|
|
42
|
+
if (t.type === "radio") {
|
|
43
|
+
if (t.checked)
|
|
44
|
+
return n = t.name, {
|
|
45
|
+
key: o,
|
|
46
|
+
value: n
|
|
47
|
+
};
|
|
48
|
+
} else if (t.type === "checkbox")
|
|
49
|
+
n = t.checked;
|
|
50
|
+
else if (t.type === "number" || t.type === "range") {
|
|
51
|
+
const i = t.valueAsNumber;
|
|
52
|
+
isNaN(i) || (n = i);
|
|
53
|
+
} else
|
|
54
|
+
t.type === "file" ? n = t.files : n = t.value;
|
|
55
|
+
else
|
|
56
|
+
n = t.value;
|
|
57
|
+
return {
|
|
58
|
+
key: o,
|
|
59
|
+
value: n
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
let a = e.contentType;
|
|
63
|
+
if (e.sendSubmissionsTo === "email" && (a = "multipart/form-data"), Array.from(E).forEach(({ value: t }) => {
|
|
64
|
+
(t instanceof File || Array.isArray(t) && t[0] instanceof File || t instanceof FileList) && (a = "multipart/form-data");
|
|
65
|
+
}), a !== "application/json")
|
|
66
|
+
d = D;
|
|
67
|
+
else {
|
|
68
|
+
const t = {};
|
|
69
|
+
Array.from(E).forEach(({ value: n, key: o }) => {
|
|
70
|
+
J(t, o, n);
|
|
71
|
+
}), d = JSON.stringify(t);
|
|
72
|
+
}
|
|
73
|
+
a && a !== "multipart/form-data" && (c && ((u = e.action) != null && u.includes("zapier.com")) || (S["content-type"] = a));
|
|
74
|
+
const x = new CustomEvent("presubmit", { detail: { body: d } });
|
|
75
|
+
if (r.current && (r.current.dispatchEvent(x), x.defaultPrevented))
|
|
76
|
+
return;
|
|
77
|
+
b("sending");
|
|
78
|
+
const P = `${q() === "dev" ? "http://localhost:5000" : "https://builder.io"}/api/v1/form-submit?apiKey=${e.builderContext.apiKey}&to=${btoa(
|
|
79
|
+
e.sendSubmissionsToEmail || ""
|
|
80
|
+
)}&name=${encodeURIComponent(e.name || "")}`, C = e.sendSubmissionsTo === "email" ? P : e.action;
|
|
81
|
+
R(C), fetch(C, { body: d, headers: S, method: e.method || "post" }).then(
|
|
82
|
+
async (t) => {
|
|
83
|
+
let n;
|
|
84
|
+
const o = t.headers.get("content-type");
|
|
85
|
+
if (o && o.indexOf("application/json") !== -1 ? n = await t.json() : n = await t.text(), !t.ok && e.errorMessagePath) {
|
|
86
|
+
let i = O(n, e.errorMessagePath);
|
|
87
|
+
i && (typeof i != "string" && (i = JSON.stringify(i)), F(i), N({ formErrorMessage: i }));
|
|
88
|
+
}
|
|
89
|
+
if (y(n), b(t.ok ? "success" : "error"), t.ok) {
|
|
90
|
+
const i = new CustomEvent("submit:success", {
|
|
91
|
+
detail: { res: t, body: n }
|
|
92
|
+
});
|
|
93
|
+
if (r.current) {
|
|
94
|
+
if (r.current.dispatchEvent(i), i.defaultPrevented)
|
|
95
|
+
return;
|
|
96
|
+
e.resetFormOnSubmit !== !1 && r.current.reset();
|
|
97
|
+
}
|
|
98
|
+
if (e.successUrl)
|
|
99
|
+
if (r.current) {
|
|
100
|
+
const M = new CustomEvent("route", {
|
|
101
|
+
detail: { url: e.successUrl }
|
|
102
|
+
});
|
|
103
|
+
r.current.dispatchEvent(M), M.defaultPrevented || (location.href = e.successUrl);
|
|
104
|
+
} else
|
|
105
|
+
location.href = e.successUrl;
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
(t) => {
|
|
109
|
+
const n = new CustomEvent("submit:error", {
|
|
110
|
+
detail: { error: t }
|
|
111
|
+
});
|
|
112
|
+
r.current && (r.current.dispatchEvent(n), n.defaultPrevented) || (y(t), b("error"));
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return /* @__PURE__ */ k(A, { children: [
|
|
118
|
+
" ",
|
|
119
|
+
/* @__PURE__ */ k(
|
|
120
|
+
"form",
|
|
121
|
+
{
|
|
122
|
+
validate: e.validate,
|
|
123
|
+
ref: r,
|
|
124
|
+
action: !e.sendWithJs && e.action,
|
|
125
|
+
method: e.method,
|
|
126
|
+
name: e.name,
|
|
127
|
+
onSubmit: (s) => w(s),
|
|
128
|
+
...e.attributes,
|
|
129
|
+
children: [
|
|
130
|
+
e.children,
|
|
131
|
+
f() === "error" ? /* @__PURE__ */ m(
|
|
132
|
+
g,
|
|
133
|
+
{
|
|
134
|
+
path: "errorMessage",
|
|
135
|
+
blocks: e.errorMessage,
|
|
136
|
+
context: e.builderContext
|
|
137
|
+
}
|
|
138
|
+
) : null,
|
|
139
|
+
f() === "sending" ? /* @__PURE__ */ m(
|
|
140
|
+
g,
|
|
141
|
+
{
|
|
142
|
+
path: "sendingMessage",
|
|
143
|
+
blocks: e.sendingMessage,
|
|
144
|
+
context: e.builderContext
|
|
145
|
+
}
|
|
146
|
+
) : null,
|
|
147
|
+
f() === "error" && v ? /* @__PURE__ */ m("pre", { className: "builder-form-error-text pre-7acc3b46", children: JSON.stringify(v, null, 2) }) : null,
|
|
148
|
+
f() === "success" ? /* @__PURE__ */ m(
|
|
149
|
+
g,
|
|
150
|
+
{
|
|
151
|
+
path: "successMessage",
|
|
152
|
+
blocks: e.successMessage,
|
|
153
|
+
context: e.builderContext
|
|
154
|
+
}
|
|
155
|
+
) : null
|
|
156
|
+
]
|
|
157
|
+
}
|
|
158
|
+
),
|
|
159
|
+
" ",
|
|
160
|
+
/* @__PURE__ */ m("style", { children: ".pre-7acc3b46 { padding: 10px; color: red; text-align: center; }" }),
|
|
161
|
+
" "
|
|
162
|
+
] });
|
|
163
|
+
}
|
|
164
|
+
export {
|
|
165
|
+
_ as default
|
|
166
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),h=require("react"),f=require("./blocks-766e8d45.cjs"),j=require("./server-entry-3c7fa63a.cjs");require("./blocks-exports.cjs");require("./get-class-prop-name-58770197.cjs");require("./dynamic-renderer-b29b45ca.cjs");const P=["production","qa","test","development","dev","cdn-qa","cloud","fast","cdn2","cdn-prod"],D=()=>{const e=process.env.NODE_ENV||"production";return P.includes(e)?e:"production"};function A(e){const s=h.useRef(null),[M,g]=h.useState(()=>"unsubmitted"),[y,S]=h.useState(()=>null),[O,T]=h.useState(()=>"");function q(i){var l,d;const u={...e.builderContext.rootState,...i};e.builderContext.rootSetState?(d=(l=e.builderContext).rootSetState)==null||d.call(l,u):e.builderContext.rootState=u}function m(){return j.isEditing()&&e.previewState||M}function F(i){var l;const u=e.sendWithJs||e.sendSubmissionsTo==="email";if(e.sendSubmissionsTo==="zapier")i.preventDefault();else if(u){if(!(e.action||e.sendSubmissionsTo==="email")){i.preventDefault();return}i.preventDefault();const d=i.currentTarget||i.target,v=e.customHeaders||{};let b;const N=new FormData(d),x=Array.from(d.querySelectorAll("input,select,textarea")).filter(t=>!!t.name).map(t=>{let n;const a=t.name;if(t instanceof HTMLInputElement)if(t.type==="radio"){if(t.checked)return n=t.name,{key:a,value:n}}else if(t.type==="checkbox")n=t.checked;else if(t.type==="number"||t.type==="range"){const r=t.valueAsNumber;isNaN(r)||(n=r)}else t.type==="file"?n=t.files:n=t.value;else n=t.value;return{key:a,value:n}});let c=e.contentType;if(e.sendSubmissionsTo==="email"&&(c="multipart/form-data"),Array.from(x).forEach(({value:t})=>{(t instanceof File||Array.isArray(t)&&t[0]instanceof File||t instanceof FileList)&&(c="multipart/form-data")}),c!=="application/json")b=N;else{const t={};Array.from(x).forEach(({value:n,key:a})=>{f.set(t,a,n)}),b=JSON.stringify(t)}c&&c!=="multipart/form-data"&&(u&&((l=e.action)!=null&&l.includes("zapier.com"))||(v["content-type"]=c));const E=new CustomEvent("presubmit",{detail:{body:b}});if(s.current&&(s.current.dispatchEvent(E),E.defaultPrevented))return;g("sending");const w=`${D()==="dev"?"http://localhost:5000":"https://builder.io"}/api/v1/form-submit?apiKey=${e.builderContext.apiKey}&to=${btoa(e.sendSubmissionsToEmail||"")}&name=${encodeURIComponent(e.name||"")}`,C=e.sendSubmissionsTo==="email"?w:e.action;j.logFetch(C),fetch(C,{body:b,headers:v,method:e.method||"post"}).then(async t=>{let n;const a=t.headers.get("content-type");if(a&&a.indexOf("application/json")!==-1?n=await t.json():n=await t.text(),!t.ok&&e.errorMessagePath){let r=f.get(n,e.errorMessagePath);r&&(typeof r!="string"&&(r=JSON.stringify(r)),T(r),q({formErrorMessage:r}))}if(S(n),g(t.ok?"success":"error"),t.ok){const r=new CustomEvent("submit:success",{detail:{res:t,body:n}});if(s.current){if(s.current.dispatchEvent(r),r.defaultPrevented)return;e.resetFormOnSubmit!==!1&&s.current.reset()}if(e.successUrl)if(s.current){const k=new CustomEvent("route",{detail:{url:e.successUrl}});s.current.dispatchEvent(k),k.defaultPrevented||(location.href=e.successUrl)}else location.href=e.successUrl}},t=>{const n=new CustomEvent("submit:error",{detail:{error:t}});s.current&&(s.current.dispatchEvent(n),n.defaultPrevented)||(S(t),g("error"))})}}return o.jsxs(o.Fragment,{children:[" ",o.jsxs("form",{validate:e.validate,ref:s,action:!e.sendWithJs&&e.action,method:e.method,name:e.name,onSubmit:i=>F(i),...e.attributes,children:[e.children,m()==="error"?o.jsx(f.Blocks,{path:"errorMessage",blocks:e.errorMessage,context:e.builderContext}):null,m()==="sending"?o.jsx(f.Blocks,{path:"sendingMessage",blocks:e.sendingMessage,context:e.builderContext}):null,m()==="error"&&y?o.jsx("pre",{className:"builder-form-error-text pre-7acc3b46",children:JSON.stringify(y,null,2)}):null,m()==="success"?o.jsx(f.Blocks,{path:"successMessage",blocks:e.successMessage,context:e.builderContext}):null]})," ",o.jsx("style",{children:".pre-7acc3b46 { padding: 10px; color: red; text-align: center; }"})," "]})}exports.default=A;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("./server-entry-
|
|
1
|
+
"use strict";const e=require("./server-entry-3c7fa63a.cjs"),s=()=>{switch(e.TARGET){case"react":case"reactNative":case"rsc":return"className";case"svelte":case"vue":case"solid":case"qwik":case"angular":return"class"}};exports.getClassPropName=s;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useEffect as y } from "react";
|
|
1
|
+
import { jsxs as d, Fragment as m, jsx as o } from "react/jsx-runtime";
|
|
3
2
|
function x(e) {
|
|
4
3
|
return e.replace(/http(s)?:/, "");
|
|
5
4
|
}
|
|
6
|
-
function
|
|
5
|
+
function y(e = "", i, t) {
|
|
7
6
|
const n = new RegExp("([?&])" + i + "=.*?(&|$)", "i"), c = e.indexOf("?") !== -1 ? "&" : "?";
|
|
8
7
|
return e.match(n) ? e.replace(n, "$1" + i + "=" + encodeURIComponent(t) + "$2") : e + c + i + "=" + encodeURIComponent(t);
|
|
9
8
|
}
|
|
10
|
-
function
|
|
9
|
+
function v(e, i) {
|
|
11
10
|
if (!e || !(e != null && e.match(/cdn\.shopify\.com/)) || !i)
|
|
12
11
|
return e;
|
|
13
12
|
if (i === "master")
|
|
@@ -19,19 +18,19 @@ function $(e, i) {
|
|
|
19
18
|
}
|
|
20
19
|
return null;
|
|
21
20
|
}
|
|
22
|
-
function
|
|
21
|
+
function u(e) {
|
|
23
22
|
if (!e)
|
|
24
23
|
return e;
|
|
25
24
|
const i = [100, 200, 400, 800, 1200, 1600, 2e3];
|
|
26
25
|
if (e.match(/builder\.io/)) {
|
|
27
26
|
let t = e;
|
|
28
27
|
const n = Number(e.split("?width=")[1]);
|
|
29
|
-
return isNaN(n) || (t = `${t} ${n}w`), i.filter((c) => c !== n).map((c) => `${
|
|
28
|
+
return isNaN(n) || (t = `${t} ${n}w`), i.filter((c) => c !== n).map((c) => `${y(e, "width", c)} ${c}w`).concat([t]).join(", ");
|
|
30
29
|
}
|
|
31
|
-
return e.match(/cdn\.shopify\.com/) ? i.map((t) => [
|
|
30
|
+
return e.match(/cdn\.shopify\.com/) ? i.map((t) => [v(e, `${t}x${t}`), t]).filter(([t]) => !!t).map(([t, n]) => `${t} ${n}w`).concat([e]).join(", ") : e;
|
|
32
31
|
}
|
|
33
|
-
function
|
|
34
|
-
var c, r,
|
|
32
|
+
function w(e) {
|
|
33
|
+
var c, r, f, h, s, g;
|
|
35
34
|
function i() {
|
|
36
35
|
var b;
|
|
37
36
|
const a = e.image || e.src;
|
|
@@ -42,10 +41,10 @@ function R(e) {
|
|
|
42
41
|
if (!e.noWebp) {
|
|
43
42
|
if (e.srcset && ((b = e.image) != null && b.includes("builder.io/api/v1/image"))) {
|
|
44
43
|
if (!e.srcset.includes(e.image.split("?")[0]))
|
|
45
|
-
return console.debug("Removed given srcset"),
|
|
44
|
+
return console.debug("Removed given srcset"), u(a);
|
|
46
45
|
} else if (e.image && !e.srcset)
|
|
47
|
-
return
|
|
48
|
-
return
|
|
46
|
+
return u(a);
|
|
47
|
+
return u(a);
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
function t() {
|
|
@@ -62,10 +61,9 @@ function R(e) {
|
|
|
62
61
|
};
|
|
63
62
|
return e.aspectRatio ? l : void 0;
|
|
64
63
|
}
|
|
65
|
-
return
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
/* @__PURE__ */ f("picture", { children: [
|
|
64
|
+
return /* @__PURE__ */ d(m, { children: [
|
|
65
|
+
/* @__PURE__ */ d(m, { children: [
|
|
66
|
+
/* @__PURE__ */ d("picture", { children: [
|
|
69
67
|
t() ? /* @__PURE__ */ o("source", { type: "image/webp", srcSet: t() }) : null,
|
|
70
68
|
/* @__PURE__ */ o(
|
|
71
69
|
"img",
|
|
@@ -79,7 +77,7 @@ function R(e) {
|
|
|
79
77
|
objectFit: e.backgroundSize || "cover",
|
|
80
78
|
...n()
|
|
81
79
|
},
|
|
82
|
-
className: "builder-image" + (e.className ? " " + e.className : "") + " img-
|
|
80
|
+
className: "builder-image" + (e.className ? " " + e.className : "") + " img-9dac2184",
|
|
83
81
|
src: e.image,
|
|
84
82
|
srcSet: i(),
|
|
85
83
|
sizes: e.sizes
|
|
@@ -89,23 +87,23 @@ function R(e) {
|
|
|
89
87
|
e.aspectRatio && !((r = (c = e.builderBlock) == null ? void 0 : c.children) != null && r.length && e.fitContent) ? /* @__PURE__ */ o(
|
|
90
88
|
"div",
|
|
91
89
|
{
|
|
92
|
-
className: "builder-image-sizer div-
|
|
90
|
+
className: "builder-image-sizer div-9dac2184",
|
|
93
91
|
style: {
|
|
94
92
|
paddingTop: e.aspectRatio * 100 + "%"
|
|
95
93
|
}
|
|
96
94
|
}
|
|
97
95
|
) : null,
|
|
98
|
-
(h = (
|
|
99
|
-
!e.fitContent && ((g = (s = e.builderBlock) == null ? void 0 : s.children) != null && g.length) ? /* @__PURE__ */ o("div", { className: "div-
|
|
96
|
+
(h = (f = e.builderBlock) == null ? void 0 : f.children) != null && h.length && e.fitContent ? /* @__PURE__ */ o(m, { children: e.children }) : null,
|
|
97
|
+
!e.fitContent && ((g = (s = e.builderBlock) == null ? void 0 : s.children) != null && g.length) ? /* @__PURE__ */ o("div", { className: "div-9dac2184-2", children: e.children }) : null
|
|
100
98
|
] }),
|
|
101
|
-
/* @__PURE__ */ o("style", { children: `.img-
|
|
99
|
+
/* @__PURE__ */ o("style", { children: `.img-9dac2184 {
|
|
102
100
|
opacity: 1;
|
|
103
101
|
transition: opacity 0.2s ease-in-out;
|
|
104
|
-
}.div-
|
|
102
|
+
}.div-9dac2184 {
|
|
105
103
|
width: 100%;
|
|
106
104
|
pointer-events: none;
|
|
107
105
|
font-size: 0;
|
|
108
|
-
}.div-
|
|
106
|
+
}.div-9dac2184-2 {
|
|
109
107
|
display: flex;
|
|
110
108
|
flex-direction: column;
|
|
111
109
|
align-items: stretch;
|
|
@@ -118,5 +116,5 @@ function R(e) {
|
|
|
118
116
|
] });
|
|
119
117
|
}
|
|
120
118
|
export {
|
|
121
|
-
|
|
119
|
+
w as default
|
|
122
120
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime");function g(e){return e.replace(/http(s)?:/,"")}function b(e="",i,t){const n=new RegExp("([?&])"+i+"=.*?(&|$)","i"),a=e.indexOf("?")!==-1?"&":"?";return e.match(n)?e.replace(n,"$1"+i+"="+encodeURIComponent(t)+"$2"):e+a+i+"="+encodeURIComponent(t)}function x(e,i){if(!e||!(e!=null&&e.match(/cdn\.shopify\.com/))||!i)return e;if(i==="master")return g(e);const t=e.match(/(_\d+x(\d+)?)?(\.(jpg|jpeg|gif|png|bmp|bitmap|tiff|tif)(\?v=\d+)?)/i);if(t){const n=e.split(t[0]),a=t[3],r=i.match("x")?i:`${i}x`;return g(`${n[0]}_${r}${a}`)}return null}function d(e){if(!e)return e;const i=[100,200,400,800,1200,1600,2e3];if(e.match(/builder\.io/)){let t=e;const n=Number(e.split("?width=")[1]);return isNaN(n)||(t=`${t} ${n}w`),i.filter(a=>a!==n).map(a=>`${b(e,"width",a)} ${a}w`).concat([t]).join(", ")}return e.match(/cdn\.shopify\.com/)?i.map(t=>[x(e,`${t}x${t}`),t]).filter(([t])=>!!t).map(([t,n])=>`${t} ${n}w`).concat([e]).join(", "):e}function y(e){var a,r,s,u,m,f;function i(){var h;const o=e.image||e.src;if(!o||!(typeof o=="string"&&(o.match(/builder\.io/)||o.match(/cdn\.shopify\.com/))))return e.srcset;if(!e.noWebp){if(e.srcset&&((h=e.image)!=null&&h.includes("builder.io/api/v1/image"))){if(!e.srcset.includes(e.image.split("?")[0]))return console.debug("Removed given srcset"),d(o)}else if(e.image&&!e.srcset)return d(o);return d(o)}}function t(){var l;return(l=i==null?void 0:i())!=null&&l.match(/builder\.io/)&&!e.noWebp?i().replace(/\?/g,"?format=webp&"):""}function n(){const l={position:"absolute",height:"100%",width:"100%",left:"0px",top:"0px"};return e.aspectRatio?l:void 0}return c.jsxs(c.Fragment,{children:[c.jsxs(c.Fragment,{children:[c.jsxs("picture",{children:[t()?c.jsx("source",{type:"image/webp",srcSet:t()}):null,c.jsx("img",{loading:e.highPriority?"eager":"lazy",fetchPriority:e.highPriority?"high":"auto",alt:e.altText,role:e.altText?void 0:"presentation",style:{objectPosition:e.backgroundPosition||"center",objectFit:e.backgroundSize||"cover",...n()},className:"builder-image"+(e.className?" "+e.className:"")+" img-9dac2184",src:e.image,srcSet:i(),sizes:e.sizes})]}),e.aspectRatio&&!((r=(a=e.builderBlock)==null?void 0:a.children)!=null&&r.length&&e.fitContent)?c.jsx("div",{className:"builder-image-sizer div-9dac2184",style:{paddingTop:e.aspectRatio*100+"%"}}):null,(u=(s=e.builderBlock)==null?void 0:s.children)!=null&&u.length&&e.fitContent?c.jsx(c.Fragment,{children:e.children}):null,!e.fitContent&&((f=(m=e.builderBlock)==null?void 0:m.children)!=null&&f.length)?c.jsx("div",{className:"div-9dac2184-2",children:e.children}):null]}),c.jsx("style",{children:`.img-9dac2184 {
|
|
2
|
+
opacity: 1;
|
|
3
|
+
transition: opacity 0.2s ease-in-out;
|
|
4
|
+
}.div-9dac2184 {
|
|
5
|
+
width: 100%;
|
|
6
|
+
pointer-events: none;
|
|
7
|
+
font-size: 0;
|
|
8
|
+
}.div-9dac2184-2 {
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
align-items: stretch;
|
|
12
|
+
position: absolute;
|
|
13
|
+
top: 0;
|
|
14
|
+
left: 0;
|
|
15
|
+
width: 100%;
|
|
16
|
+
height: 100%;
|
|
17
|
+
}`})]})}exports.default=y;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),i=require("./server-entry-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),i=require("./server-entry-3c7fa63a.cjs");function n(e){return t.jsx("img",{style:{objectFit:e.backgroundSize||"cover",objectPosition:e.backgroundPosition||"center"},alt:e.altText,src:e.imgSrc||e.image,...e.attributes},i.isEditing()&&e.imgSrc||"default-key")}exports.default=n;
|
package/lib/edge/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./blocks-exports.cjs"),e=require("./server-entry-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./blocks-exports.cjs"),e=require("./server-entry-3c7fa63a.cjs");require("react");exports.Blocks=t.Blocks;exports.BuilderContext=t.BuilderContext;exports.Button=t.Button;exports.Columns=t.Columns;exports.Content=t.Content;exports.Fragment=t.Fragment;exports.Image=t.Image;exports.Section=t.Section;exports.Symbol=t.Symbol;exports.Text=t.Text;exports.Video=t.Video;exports._processContentResult=e._processContentResult;exports.createRegisterComponentMessage=e.createRegisterComponentMessage;exports.fetchBuilderProps=e.fetchBuilderProps;exports.fetchEntries=e.fetchEntries;exports.fetchOneEntry=e.fetchOneEntry;exports.getBuilderSearchParams=e.getBuilderSearchParams;exports.isEditing=e.isEditing;exports.isPreviewing=e.isPreviewing;exports.register=e.register;exports.setEditorSettings=e.setEditorSettings;exports.subscribeToEditor=e.subscribeToEditor;exports.track=e.track;
|
package/lib/edge/index.mjs
CHANGED
|
@@ -1,29 +1,28 @@
|
|
|
1
|
-
import { Blocks as
|
|
2
|
-
import { _processContentResult as
|
|
1
|
+
import { Blocks as o, BuilderContext as i, Button as s, Columns as n, Content as c, Fragment as g, Image as m, Section as a, Symbol as d, Text as l, Video as u } from "./blocks-exports.mjs";
|
|
2
|
+
import { _processContentResult as f, createRegisterComponentMessage as B, fetchBuilderProps as C, fetchEntries as E, fetchOneEntry as h, getBuilderSearchParams as x, isEditing as S, isPreviewing as b, register as P, setEditorSettings as k, subscribeToEditor as y, track as R } from "./server-entry-67bfc740.js";
|
|
3
3
|
import "react";
|
|
4
4
|
export {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
o as Blocks,
|
|
6
|
+
i as BuilderContext,
|
|
7
7
|
s as Button,
|
|
8
8
|
n as Columns,
|
|
9
9
|
c as Content,
|
|
10
10
|
g as Fragment,
|
|
11
11
|
m as Image,
|
|
12
12
|
a as Section,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
d as Symbol,
|
|
14
|
+
l as Text,
|
|
15
|
+
u as Video,
|
|
16
|
+
f as _processContentResult,
|
|
17
|
+
B as createRegisterComponentMessage,
|
|
18
|
+
C as fetchBuilderProps,
|
|
19
19
|
E as fetchEntries,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
h as fetchOneEntry,
|
|
21
|
+
x as getBuilderSearchParams,
|
|
22
|
+
S as isEditing,
|
|
23
|
+
b as isPreviewing,
|
|
24
24
|
P as register,
|
|
25
|
-
k as
|
|
26
|
-
y as
|
|
27
|
-
R as
|
|
28
|
-
T as track
|
|
25
|
+
k as setEditorSettings,
|
|
26
|
+
y as subscribeToEditor,
|
|
27
|
+
R as track
|
|
29
28
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),u=require("./server-entry-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),u=require("./server-entry-3c7fa63a.cjs");function a(e){return t.createElement("input",{...e.attributes,key:u.isEditing()&&e.defaultValue?e.defaultValue:"default-key",placeholder:e.placeholder,type:e.type,name:e.name,value:e.value,defaultValue:e.defaultValue,required:e.required})}exports.default=a;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as l } from "react/jsx-runtime";
|
|
2
2
|
import { createElement as m } from "react";
|
|
3
|
-
import { isEditing as n } from "./server-entry-
|
|
3
|
+
import { isEditing as n } from "./server-entry-67bfc740.js";
|
|
4
4
|
function r(e) {
|
|
5
5
|
var t;
|
|
6
6
|
return /* @__PURE__ */ m(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),n=require("react"),r=require("./server-entry-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),n=require("react"),r=require("./server-entry-3c7fa63a.cjs");function i(e){var u;return n.createElement("select",{...e.attributes,value:e.value,key:r.isEditing()&&e.defaultValue?e.defaultValue:"default-key",defaultValue:e.defaultValue,name:e.name,required:e.required},(u=e.options)==null?void 0:u.map((t,a)=>l.jsx("option",{value:t.value,children:t.name||t.value},`${t.name}-${a}`)))}exports.default=i;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const w="react",gt=t=>{const e={};return t.forEach((n,r)=>{e[r]=n}),e},M=t=>t instanceof URLSearchParams?gt(t):t,N=t=>typeof t=="string"?t:t instanceof URLSearchParams?t.toString():new URLSearchParams(t).toString();function c(){return typeof window!="undefined"&&typeof document!="undefined"}function pt(){return c()&&window.self!==window.top}function K(t){return pt()&&N(t||window.location.search).indexOf("builder.frameEditing=")!==-1}function mt(t){const e=t||(c()?window.location.search:void 0);return e?N(e).indexOf("builder.preview=")!==-1:!1}const yt=t=>({type:"builder.registerComponent",data:P(t)}),wt=t=>{const e=t.toString().trim(),n=/^[a-zA-Z0-9_]+\s*=>/i.test(e);return`return (${!e.startsWith("function")&&!e.startsWith("async")&&!e.startsWith("(")&&!n?"function ":""}${e}).apply(this, arguments)`};function P(t){return JSON.parse(JSON.stringify(t,(e,n)=>typeof n=="function"?wt(n):n))}const U={};function j(t,e){t==="plugin"&&(e=P(e));let n=U[t];if(n||(n=U[t]=[]),n.push(e),c()){const r={type:"builder.register",data:{type:t,info:e}};try{parent.postMessage(r,"*"),parent!==window&&window.postMessage(r,"*")}catch(s){console.debug("Could not postmessage",s)}}}const L={};function St(t){if(c()){Object.assign(L,t);const e={type:"builder.settingsChange",data:L};parent.postMessage(e,"*")}}const F="builder.",bt="options.",O=t=>{if(!t)return{};const e=M(t),n={};return Object.keys(e).forEach(r=>{if(r.startsWith(F)){const s=r.replace(F,"").replace(bt,"");n[s]=e[r]}}),n},vt=()=>{if(!c())return{};const t=new URLSearchParams(window.location.search);return O(t)},I="[Builder.io]: ",d={log:(...t)=>console.log(I,...t),error:(...t)=>console.error(I,...t),warn:(...t)=>console.warn(I,...t),debug:(...t)=>console.debug(I,...t)},W="3.0.5",_=()=>({"X-Builder-SDK":w,"X-Builder-SDK-GEN":"2","X-Builder-SDK-Version":W}),p=t=>t!=null,It=t=>{if(t==="localhost"||t==="127.0.0.1")return t;const e=t.split(".");return e.length>2?e.slice(1).join("."):t},$=({name:t,canTrack:e})=>{var n;try{return e?(n=document.cookie.split("; ").find(r=>r.startsWith(`${t}=`)))==null?void 0:n.split("=")[1]:void 0}catch(r){d.warn("[COOKIE] GET error: ",(r==null?void 0:r.message)||r);return}},G=async t=>$(t),kt=t=>t.map(([e,n])=>n?`${e}=${n}`:e).filter(p).join("; "),Et=[["secure",""],["SameSite","None"]],At=({name:t,value:e,expires:n})=>{const s=(c()?location.protocol==="https:":!0)?Et:[[]],o=n?[["expires",n.toUTCString()]]:[[]],i=[[t,e],...o,["path","/"],["domain",It(window.location.hostname)],...s];return kt(i)},z=async({name:t,value:e,expires:n,canTrack:r})=>{try{if(!r)return;const s=At({name:t,value:e,expires:n});document.cookie=s}catch(s){d.warn("[COOKIE] SET error: ",(s==null?void 0:s.message)||s)}};function Pt(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=Math.random()*16|0;return(t=="x"?e:e&3|8).toString(16)})}function H(){return Pt().replace(/-/g,"")}const J="builderSessionId",Ot=async({canTrack:t})=>{if(!t)return;const e=await G({name:J,canTrack:t});if(p(e))return e;{const n=Ct();return Tt({id:n,canTrack:t}),n}},Ct=()=>H(),Tt=({id:t,canTrack:e})=>z({name:J,value:t,canTrack:e}),X=()=>c()&&typeof localStorage!="undefined"?localStorage:void 0,xt=({key:t,canTrack:e})=>{var n;try{return e?(n=X())==null?void 0:n.getItem(t):void 0}catch(r){console.debug("[LocalStorage] GET error: ",r);return}},Bt=({key:t,canTrack:e,value:n})=>{var r;try{e&&((r=X())==null||r.setItem(t,n))}catch(s){console.debug("[LocalStorage] SET error: ",s)}},Q="builderVisitorId",Rt=({canTrack:t})=>{if(!t)return;const e=xt({key:Q,canTrack:t});if(p(e))return e;{const n=Ut();return Lt({id:n,canTrack:t}),n}},Ut=()=>H(),Lt=({id:t,canTrack:e})=>Bt({key:Q,value:t,canTrack:e});function Y(t){var e;typeof process!="undefined"&&((e=process.env)!=null&&e.DEBUG)&&String(process.env.DEBUG)=="true"&&d.log(t)}const Ft=()=>{if(c()){const t=new URL(location.href);return t.pathname===""&&(t.pathname="/"),t}else return console.warn("Cannot get location for tracking in non-browser environment"),null},Vt=()=>typeof navigator=="object"&&navigator.userAgent||"",Z=()=>{const t=Vt(),e={Android(){return t.match(/Android/i)},BlackBerry(){return t.match(/BlackBerry/i)},iOS(){return t.match(/iPhone|iPod/i)},Opera(){return t.match(/Opera Mini/i)},Windows(){return t.match(/IEMobile/i)||t.match(/WPDesktop/i)},any(){return e.Android()||e.BlackBerry()||e.iOS()||e.Opera()||e.Windows()||w==="reactNative"}},n=t.match(/Tablet|iPad/i),r=Ft();return{urlPath:r==null?void 0:r.pathname,host:(r==null?void 0:r.host)||(r==null?void 0:r.hostname),device:n?"tablet":e.any()?"mobile":"desktop"}},Dt=async({canTrack:t})=>{if(!t)return{visitorId:void 0,sessionId:void 0};const e=await Ot({canTrack:t}),n=Rt({canTrack:t});return{sessionId:e,visitorId:n}},Mt=async({type:t,canTrack:e,apiKey:n,metadata:r,...s})=>({type:t,data:{...s,metadata:{url:location.href,...r},...await Dt({canTrack:e}),userAttributes:Z(),ownerId:n}});async function q({apiHost:t,...e}){if(!e.apiKey){d.error("Missing API key for track call. Please provide your API key.");return}if(!e.canTrack||K()||!(c()||w==="reactNative"))return;const r=`${t||"https://cdn.builder.io"}/api/v1/track`;return Y(r),fetch(r,{method:"POST",body:JSON.stringify({events:[await Mt(e)]}),headers:{"content-type":"application/json",..._()},mode:"cors"}).catch(s=>{console.error("Failed to track: ",s)})}const Nt=t=>q({...t,canTrack:!0}),Kt=["*.beta.builder.io","beta.builder.io","builder.io","localhost","qa.builder.io"];function tt(t,e){if(!e.origin.startsWith("http")&&!e.origin.startsWith("https"))return!1;const n=new URL(e.origin),r=n.hostname;return(t||Kt).findIndex(s=>s.startsWith("*.")?r.endsWith(s.slice(1)):s===r)>-1}const jt=()=>{j("insertMenu",{name:"_default",default:!0,items:[{name:"Box"},{name:"Text"},{name:"Image"},{name:"Columns"},{name:"Core:Section"},{name:"Core:Button"},{name:"Embed"},{name:"Custom Code"}]})};let V=!1;const et=(t={})=>{var e,n;V||(V=!0,c()&&((e=window.parent)==null||e.postMessage({type:"builder.sdkInfo",data:{target:w,version:W,supportsPatchUpdates:!1,supportsAddBlockScoping:!0,supportsCustomBreakpoints:!0}},"*"),(n=window.parent)==null||n.postMessage({type:"builder.updateContent",data:{options:t}},"*"),window.addEventListener("message",r=>{var o,i;if(!tt(t.trustedHosts,r))return;const{data:s}=r;if(s!=null&&s.type)switch(s.type){case"builder.evaluate":{const u=s.data.text,S=s.data.arguments||[],m=s.data.id,k=new Function(u);let l,h=null;try{l=k.apply(null,S)}catch(g){h=g}h?(o=window.parent)==null||o.postMessage({type:"builder.evaluateError",data:{id:m,error:h.message}},"*"):l&&typeof l.then=="function"?l.then(g=>{var b;(b=window.parent)==null||b.postMessage({type:"builder.evaluateResult",data:{id:m,result:g}},"*")}).catch(console.error):(i=window.parent)==null||i.postMessage({type:"builder.evaluateResult",data:{result:l,id:m}},"*");break}}})))},nt=({model:t,trustedHosts:e,callbacks:n})=>r=>{if(!tt(e,r))return;const{data:s}=r;if(s)switch(s.type){case"builder.configureSdk":{n.configureSdk(s.data);break}case"builder.triggerAnimation":{n.animation(s.data);break}case"builder.contentUpdate":{const o=s.data,i=o.key||o.alias||o.entry||o.modelName,u=o.data;i===t&&n.contentUpdate(u);break}}},Wt=(t,e,n)=>{if(!c)return d.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."),()=>{};et();const r=nt({callbacks:{contentUpdate:e,animation:()=>{},configureSdk:()=>{}},model:t,trustedHosts:n==null?void 0:n.trustedHosts});return window.addEventListener("message",r),()=>{window.removeEventListener("message",r)}},_t="builder.tests",C=t=>`${_t}.${t}`,$t=({contentId:t})=>G({name:C(t),canTrack:!0}),Gt=({contentId:t})=>$({name:C(t),canTrack:!0}),zt=({contentId:t,value:e})=>z({name:C(t),value:e,canTrack:!0}),rt=t=>p(t.id)&&p(t.variations)&&Object.keys(t.variations).length>0,Ht=({id:t,variations:e})=>{var s;let n=0;const r=Math.random();for(const o in e){const i=(s=e[o])==null?void 0:s.testRatio;if(n+=i,r<n)return o}return t},st=t=>{const e=Ht(t);return zt({contentId:t.id,value:e}).catch(n=>{d.error("could not store A/B test variation: ",n)}),e},ot=({item:t,testGroupId:e})=>{const n=t.variations[e];return e===t.id||!n?{testVariationId:t.id,testVariationName:"Default"}:{data:n.data,testVariationId:n.id,testVariationName:n.name||(n.id===t.id?"Default":"")}},Jt=({item:t,canTrack:e})=>{if(!e)return t;if(!t)return;if(!rt(t))return t;const n=Gt({contentId:t.id})||st({variations:t.variations,id:t.id}),r=ot({item:t,testGroupId:n});return{...t,...r}},Xt=async({item:t,canTrack:e})=>{if(!e||!rt(t))return t;const r=await $t({contentId:t.id})||st({variations:t.variations,id:t.id}),s=ot({item:t,testGroupId:r});return{...t,...s}},it=t=>p(t)?t:!0;function Qt(){return typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:globalThis}function Yt(){const t=Qt().fetch;if(typeof t=="undefined")throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
|
|
2
|
+
For more information, read https://github.com/BuilderIO/this-package-uses-fetch`),new Error("Builder SDK could not find a global `fetch` function");return t}const Zt=Yt();function A(t,e=null,n="."){return Object.keys(t).reduce((r,s)=>{const o=t[s],i=[e,s].filter(Boolean).join(n);return[typeof o=="object",o!==null,!(Array.isArray(o)&&o.length===0)].every(Boolean)?{...r,...A(o,i,n)}:{...r,[i]:o}},{})}function at(t,e,n={}){for(const r in t){const s=t[r],o=e?e+"."+r:r;s&&typeof s=="object"&&!Array.isArray(s)&&!Object.keys(s).find(i=>i.startsWith("$"))?at(s,o,n):n[o]=s}return n}function qt(t){const e={};for(const n in t){const r=n.split(".");let s=e;for(let o=0;o<r.length;o++){const i=r[o];o===r.length-1?s[i]=t[n]:(s[i]=s[i]||{},s=s[i])}}return e}const te="v3",D=t=>typeof t=="number"&&!isNaN(t)&&t>=0,T=t=>{const{limit:e=30,userAttributes:n,query:r,model:s,apiKey:o,enrich:i,locale:u,apiVersion:S=te,fields:m,omit:k,offset:l,cacheSeconds:h,staleCacheSeconds:g,sort:b,includeUnpublished:x,apiHost:dt}=t;if(!o)throw new Error("Missing API key");if(!["v3"].includes(S))throw new Error(`Invalid apiVersion: expected 'v3', received '${S}'`);const ft=e!==1,ht=dt||"https://cdn.builder.io",a=new URL(`${ht}/api/${S}/content/${s}`);a.searchParams.set("apiKey",o),a.searchParams.set("limit",String(e)),a.searchParams.set("noTraverse",String(ft)),a.searchParams.set("includeRefs",String(!0));const E=u||(n==null?void 0:n.locale);let y=n||{};if(E&&(a.searchParams.set("locale",E),y={locale:E,...y}),i&&a.searchParams.set("enrich",String(i)),a.searchParams.set("omit",k||"meta.componentsUsed"),m&&a.searchParams.set("fields",m),Number.isFinite(l)&&l>-1&&a.searchParams.set("offset",String(Math.floor(l))),typeof x=="boolean"&&a.searchParams.set("includeUnpublished",String(x)),h&&D(h)&&a.searchParams.set("cacheSeconds",String(h)),g&&D(g)&&a.searchParams.set("staleCacheSeconds",String(g)),b){const f=A({sort:b});for(const v in f)a.searchParams.set(v,JSON.stringify(f[v]))}const B={...vt(),...M(t.options||{})};y={...y,...ne(B)};const R=A(B);for(const f in R)a.searchParams.set(f,String(R[f]));if(Object.keys(y).length>0&&a.searchParams.set("userAttributes",JSON.stringify(y)),r){const f=at({query:r});for(const v in f)a.searchParams.set(v,JSON.stringify(f[v]))}return a},ee=t=>{const e={};for(const n in t)n.startsWith("userAttributes.")&&(e[n]=t[n],delete t[n]);return e},ne=t=>{if(c()&&t.preview==="BUILDER_STUDIO"){t["userAttributes.urlPath"]=window.location.pathname,t["userAttributes.host"]=window.location.host;const e=ee(t),{userAttributes:n}=qt(e);return n}return{}},re=t=>"results"in t;async function ct(t){const e=await lt({...t,limit:1});return e&&e[0]||null}const se=async t=>{var i,u;const e=T(t),n=(i=t.fetch)!=null?i:Zt,r={...t.fetchOptions,headers:{...(u=t.fetchOptions)==null?void 0:u.headers,..._()}};return await(await n(e.href,r)).json()},ut=async(t,e,n=T(t))=>{const r=it(t.canTrack);if(n.search.includes("preview="),!r||!(c()||w==="reactNative"))return e.results;try{const s=[];for(const o of e.results)s.push(await Xt({item:o,canTrack:r}));e.results=s}catch(s){d.error("Could not process A/B tests. ",s)}return e.results};async function lt(t){const e=T(t),n=await se(t);if(!re(n))throw d.error("Error fetching data. ",{url:e,content:n,options:t}),n;return ut(t,n)}const oe=async t=>{var r,s,o;const e=t.path||((r=t.url)==null?void 0:r.pathname)||((s=t.userAttributes)==null?void 0:s.urlPath),n={...t,apiKey:t.apiKey,model:t.model||"page",userAttributes:{...t.userAttributes,...e?{urlPath:e}:{}},options:O(t.searchParams||((o=t.url)==null?void 0:o.searchParams)||t.options)};return{apiKey:n.apiKey,model:n.model,content:await ct(n)}};exports.TARGET=w;exports._processContentResult=ut;exports._track=q;exports.checkIsDefined=p;exports.createEditorListener=nt;exports.createRegisterComponentMessage=yt;exports.fetchBuilderProps=oe;exports.fetchEntries=lt;exports.fetchOneEntry=ct;exports.getBuilderSearchParams=O;exports.getDefaultCanTrack=it;exports.getUserAttributes=Z;exports.handleABTestingSync=Jt;exports.isBrowser=c;exports.isEditing=K;exports.isPreviewing=mt;exports.logFetch=Y;exports.logger=d;exports.register=j;exports.registerInsertMenu=jt;exports.serializeIncludingFunctions=P;exports.setEditorSettings=St;exports.setupBrowserForEditing=et;exports.subscribeToEditor=Wt;exports.track=Nt;
|