glitchgrab 1.55.0 → 1.57.0
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/README.md +29 -0
- package/dist/index.d.mts +10 -3
- package/dist/index.d.ts +10 -3
- package/dist/index.js +98 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +97 -2
- package/dist/index.mjs.map +1 -1
- package/dist/server.d.mts +46 -2
- package/dist/server.d.ts +46 -2
- package/dist/server.js +48 -0
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +47 -0
- package/dist/server.mjs.map +1 -1
- package/dist/{types-DcDF1mXc.d.mts → types-DfVtKZcp.d.mts} +26 -1
- package/dist/{types-DcDF1mXc.d.ts → types-DfVtKZcp.d.ts} +26 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -665,6 +665,36 @@ async function sendFeedback(payload, baseUrl) {
|
|
|
665
665
|
return null;
|
|
666
666
|
}
|
|
667
667
|
}
|
|
668
|
+
async function sendLead(token, lead, baseUrl) {
|
|
669
|
+
var _a, _b;
|
|
670
|
+
try {
|
|
671
|
+
const url = `${baseUrl != null ? baseUrl : DEFAULT_BASE_URL}/api/v1/sdk/leads`;
|
|
672
|
+
const body = JSON.stringify(lead);
|
|
673
|
+
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
|
674
|
+
try {
|
|
675
|
+
const response = await fetch(url, {
|
|
676
|
+
method: "POST",
|
|
677
|
+
headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}` },
|
|
678
|
+
body
|
|
679
|
+
});
|
|
680
|
+
if (response.ok) {
|
|
681
|
+
const envelope = await response.json();
|
|
682
|
+
return { success: envelope.success, id: (_a = envelope.data) == null ? void 0 : _a.leadId, created: (_b = envelope.data) == null ? void 0 : _b.created };
|
|
683
|
+
}
|
|
684
|
+
if (response.status >= 400 && response.status < 500 && response.status !== 429) {
|
|
685
|
+
return null;
|
|
686
|
+
}
|
|
687
|
+
} catch (e) {
|
|
688
|
+
}
|
|
689
|
+
if (attempt < MAX_RETRIES - 1) {
|
|
690
|
+
await new Promise((resolve) => setTimeout(resolve, RETRY_BASE_MS * Math.pow(2, attempt)));
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
return null;
|
|
694
|
+
} catch (e) {
|
|
695
|
+
return null;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
668
698
|
function signedFields(identity) {
|
|
669
699
|
if (!(identity == null ? void 0 : identity.signature) || !identity.userId) return {};
|
|
670
700
|
return { userId: identity.userId, signature: identity.signature };
|
|
@@ -7596,6 +7626,7 @@ var DARK = {
|
|
|
7596
7626
|
input: "#1c1c1c",
|
|
7597
7627
|
danger: "#f87171"
|
|
7598
7628
|
};
|
|
7629
|
+
var GLITCHGRAB_LOGO = "data:image/webp;base64,UklGRp4EAABXRUJQVlA4WAoAAAAQAAAALwAALwAAQUxQSEUBAAABkKNt27FHd2y7tm0nG7Dt9FblLODfQVLZdjpVKm1nbDyjD+8zaiNiAqCiqU9eFxFRf0moLcTbVQ0efybJr9dzre5i3DRXpPjlSLR6TprnpOrnkUCVUg5J9ZeNWipo9XwmkaO2imzGSPBOsALbdRJ+ESxLZ4IYHjvI6SGWS/pSyR95UI+E4wkx/Rj/Kw2x3db/yfklH8r8SUOMtw0A21tOlABUEes+YJDXsbHpMa/PwT6feFF1JjF/7OL2H9jPLpdd+BdmHTa3vL7GYZ7XjTVaeM0ALq9Z5QAY5XRqCSDqE6MaANCa4HNm9RMCXrEpw68buIxqS+iO8ThyhLTtPofXYZAbdCHuYxHkBx+KelkEpU6LYg7CoVy/+4OAEUeomrSh1lG5FlTWz95U47DGGgL1E3uPvsq6msmxgmjTkOpHibYEWygHAFZQOCAyAwAA8A8AnQEqMAAwAD5RIo5FI6IhFVqtVDgFBLYAWI97RVZAlk7wMR3bb89h6MN4A3i/9zvSAphf3vH3/0HC3r5457/O2wKZ749Pc73B/1W60i0ECBPawzM4trUtZQ8JtnKZx+cwouZ82/u4HWY5VC5OeeUWNuV9ET+TBNS1eRgMFyatx05O0aeAAAD+/7CUHtrj64E06fYjHM7Q6zHWgTd3U0C4VJrAF/R5hdPSi82mSQBF5QsO33GBZY8X0rVCdP/z4T1K4kahIp5q2b7v5a27kvLvT6COf70O+y7YmvruHd6RDcU1mBjIlm8lam4muqzNQUzxqeGx/jHt+J9b9i8HosTQeKYzbaueiRUr4JsXe8LUT5L/a/f/yKVjFFWpgGv10mBFfcEOWZIh8E05Ycfl3+usHVjX3TPD8CV0qYDRUWvkEliByCh0+LlmWIx+hfITiHKBEMnfETAvxOR9mmb+uq6rxA8jM4co//NoOTG0t5aeCEFeay8OZB54GerisvQV9nQEPqaHCz11f/LqoYK741K+CrbQxFXH6J5eaWL/GeJTngtDoj+gA9j9xAtjY1KpSt3MVV49bD2yr7RQ11A8S1rx5/AKmEPnvuMe8rjGBOnNy/3NLI0Et/IIL90XbGd1iwnOBKQo4L+bILSQoJBkGlRVBzLnBbHhGD61nqtu6E+abGIujbnpSkr0CGTkADsl+GhZiKsDk+/rrkzlRXKETXRvEkEijwm9kSEEyvZih4Q3G83MyTTncMY/rK3kygpJrXRvct4f2jYwk9v7+XSypDagws/032dx8xxVJXSXJ39MjKKEIFn7OWNuQHgTMtjrOa/oqen5l2w4X9ExYGneasi4Qx+vFjUCcm2WmUocqcP2PYmXWCYvCb/9GTfej/GE0Ow9xM4Ig9NrrL8g/wNMKu3W3GWpCEXljm6jSM9G1/EAwjoAAwE3M4pBphXhZ3lptxATFI3PHvirASzzBxTQOZKTE8kD8+cUUTnpLznfoM4L9zihNIlJl4NfTbxtKZpeaNMuzqZGwOxPBGzt/oi2nkR2B9/7ciZxk3EhbqrxGpEZ0VB0DldyrzwuF/G80twAAAA=";
|
|
7599
7630
|
var WEEKDAYS = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
|
|
7600
7631
|
var DAY_MS = 864e5;
|
|
7601
7632
|
var ZONE_PAD_MS = 14 * 36e5;
|
|
@@ -7870,6 +7901,55 @@ function BookingDialog({
|
|
|
7870
7901
|
const selectedEnd = selected ? (_e = selected.endsAt) != null ? _e : new Date(new Date(selected.startsAt).getTime() + page.slotMinutes * 6e4).toISOString() : null;
|
|
7871
7902
|
const monthDate = new Date(keyToUtc(`${month}-01`));
|
|
7872
7903
|
const muted = { color: t.muted };
|
|
7904
|
+
const credit = /* @__PURE__ */ jsx6(
|
|
7905
|
+
"div",
|
|
7906
|
+
{
|
|
7907
|
+
style: {
|
|
7908
|
+
marginTop: wide ? whatsappUrl && step === "slots" ? 14 : "auto" : 0,
|
|
7909
|
+
padding: wide ? 0 : "4px 20px 18px",
|
|
7910
|
+
display: "flex",
|
|
7911
|
+
justifyContent: wide ? "flex-start" : "center"
|
|
7912
|
+
},
|
|
7913
|
+
children: /* @__PURE__ */ jsxs6(
|
|
7914
|
+
"a",
|
|
7915
|
+
{
|
|
7916
|
+
href: "https://glitchgrab.dev/?utm_source=booking-dialog",
|
|
7917
|
+
target: "_blank",
|
|
7918
|
+
rel: "noreferrer",
|
|
7919
|
+
className: "gg-bk-ghost",
|
|
7920
|
+
style: {
|
|
7921
|
+
display: "inline-flex",
|
|
7922
|
+
alignItems: "center",
|
|
7923
|
+
gap: 7,
|
|
7924
|
+
padding: "4px 11px 4px 4px",
|
|
7925
|
+
borderRadius: 999,
|
|
7926
|
+
border: `1px solid ${t.border}`,
|
|
7927
|
+
fontSize: 11.5,
|
|
7928
|
+
letterSpacing: "0.01em",
|
|
7929
|
+
color: t.muted,
|
|
7930
|
+
textDecoration: "none",
|
|
7931
|
+
whiteSpace: "nowrap"
|
|
7932
|
+
},
|
|
7933
|
+
children: [
|
|
7934
|
+
/* @__PURE__ */ jsx6(
|
|
7935
|
+
"img",
|
|
7936
|
+
{
|
|
7937
|
+
src: GLITCHGRAB_LOGO,
|
|
7938
|
+
alt: "",
|
|
7939
|
+
width: 18,
|
|
7940
|
+
height: 18,
|
|
7941
|
+
style: { width: 18, height: 18, borderRadius: 999, display: "block" }
|
|
7942
|
+
}
|
|
7943
|
+
),
|
|
7944
|
+
/* @__PURE__ */ jsxs6("span", { children: [
|
|
7945
|
+
"Powered by ",
|
|
7946
|
+
/* @__PURE__ */ jsx6("span", { style: { color: t.text, fontWeight: 600 }, children: "Glitchgrab" })
|
|
7947
|
+
] })
|
|
7948
|
+
]
|
|
7949
|
+
}
|
|
7950
|
+
)
|
|
7951
|
+
}
|
|
7952
|
+
);
|
|
7873
7953
|
const summary = /* @__PURE__ */ jsxs6(
|
|
7874
7954
|
"div",
|
|
7875
7955
|
{
|
|
@@ -8017,7 +8097,8 @@ function BookingDialog({
|
|
|
8017
8097
|
] })
|
|
8018
8098
|
]
|
|
8019
8099
|
}
|
|
8020
|
-
)
|
|
8100
|
+
),
|
|
8101
|
+
wide && credit
|
|
8021
8102
|
]
|
|
8022
8103
|
}
|
|
8023
8104
|
);
|
|
@@ -8407,7 +8488,8 @@ function BookingDialog({
|
|
|
8407
8488
|
step === "slots" ? /* @__PURE__ */ jsxs6(Fragment5, { children: [
|
|
8408
8489
|
calendar,
|
|
8409
8490
|
times
|
|
8410
|
-
] }) : form
|
|
8491
|
+
] }) : form,
|
|
8492
|
+
!wide && credit
|
|
8411
8493
|
]
|
|
8412
8494
|
}
|
|
8413
8495
|
)
|
|
@@ -9021,6 +9103,17 @@ function GlitchgrabProviderInner({
|
|
|
9021
9103
|
},
|
|
9022
9104
|
[token, baseUrl, session]
|
|
9023
9105
|
);
|
|
9106
|
+
const submitLead = useCallback3(
|
|
9107
|
+
async (lead) => {
|
|
9108
|
+
try {
|
|
9109
|
+
const context = captureContext(visitedPagesRef.current);
|
|
9110
|
+
return await sendLead(token, { ...lead, pageUrl: context.url }, baseUrl);
|
|
9111
|
+
} catch (e) {
|
|
9112
|
+
return null;
|
|
9113
|
+
}
|
|
9114
|
+
},
|
|
9115
|
+
[token, baseUrl]
|
|
9116
|
+
);
|
|
9024
9117
|
const openFeedbackDialog = useCallback3(() => {
|
|
9025
9118
|
if (typeof window !== "undefined") {
|
|
9026
9119
|
window.dispatchEvent(
|
|
@@ -9198,6 +9291,7 @@ function GlitchgrabProviderInner({
|
|
|
9198
9291
|
setContext: setContext2,
|
|
9199
9292
|
setContexts: setContexts2,
|
|
9200
9293
|
sendFeedback: feedback,
|
|
9294
|
+
submitLead,
|
|
9201
9295
|
openFeedbackDialog,
|
|
9202
9296
|
addBreadcrumb: addBreadcrumb2,
|
|
9203
9297
|
openReportDialog,
|
|
@@ -9662,6 +9756,7 @@ export {
|
|
|
9662
9756
|
matchesShortcut,
|
|
9663
9757
|
sanitizeUrl,
|
|
9664
9758
|
sendFeedback,
|
|
9759
|
+
sendLead,
|
|
9665
9760
|
sendReport,
|
|
9666
9761
|
setContext,
|
|
9667
9762
|
setContexts,
|