@stackable-labs/embeddables 1.68.0 → 1.69.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.
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import { type EventDomain } from '@stackable-labs/sdk-extension-contracts';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
stackable?: {
|
|
5
|
+
emit: (type: `${EventDomain}:${string}`, payload?: Record<string, unknown>) => void;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
}
|
|
1
9
|
export interface ExtensionSetupProps {
|
|
2
10
|
queryApiBase?: string;
|
|
3
11
|
apiBase?: string;
|
package/dist/react.js
CHANGED
|
@@ -5,7 +5,7 @@ import * as Cn from "react-dom";
|
|
|
5
5
|
import ps from "react-dom";
|
|
6
6
|
const el = () => {
|
|
7
7
|
try {
|
|
8
|
-
return "
|
|
8
|
+
return "f305b0bb-d5a0-4759-ad08-1563998460ba";
|
|
9
9
|
} catch {
|
|
10
10
|
return "dev";
|
|
11
11
|
}
|
|
@@ -894,7 +894,7 @@ function $l(e) {
|
|
|
894
894
|
}
|
|
895
895
|
const Fl = (e) => {
|
|
896
896
|
var t, n, o, r, s, a, i, c, d;
|
|
897
|
-
const { invert: p, toast: l, unstyled: m, interacting: h, setHeights: b, visibleToasts: g, heights: v, index: y, toasts: w, expanded: x, removeToast: C, defaultRichColors: E, closeButton: R, style: N, cancelButtonStyle: k, actionButtonStyle: P, className: O = "", descriptionClassName: F = "", duration: z, position: V, gap: q, expandByDefault: K, classNames: M, icons: B, closeButtonAriaLabel: Y = "Close toast" } = e, [T, S] = _.useState(null), [A,
|
|
897
|
+
const { invert: p, toast: l, unstyled: m, interacting: h, setHeights: b, visibleToasts: g, heights: v, index: y, toasts: w, expanded: x, removeToast: C, defaultRichColors: E, closeButton: R, style: N, cancelButtonStyle: k, actionButtonStyle: P, className: O = "", descriptionClassName: F = "", duration: z, position: V, gap: q, expandByDefault: K, classNames: M, icons: B, closeButtonAriaLabel: Y = "Close toast" } = e, [T, S] = _.useState(null), [A, L] = _.useState(null), [I, D] = _.useState(!1), [$, J] = _.useState(!1), [W, j] = _.useState(!1), [ee, te] = _.useState(!1), [se, oe] = _.useState(!1), [ue, fe] = _.useState(0), [at, Ke] = _.useState(0), Te = _.useRef(l.duration || z || br), Kt = _.useRef(null), be = _.useRef(null), Hc = y === 0, Vc = y + 1 <= g, Se = l.type, gt = l.dismissible !== !1, Wc = l.className || "", Uc = l.descriptionClassName || "", Xt = _.useMemo(() => v.findIndex((ne) => ne.toastId === l.id) || 0, [
|
|
898
898
|
v,
|
|
899
899
|
l.id
|
|
900
900
|
]), jc = _.useMemo(() => {
|
|
@@ -918,7 +918,7 @@ const Fl = (e) => {
|
|
|
918
918
|
}, [
|
|
919
919
|
dr
|
|
920
920
|
]), _.useEffect(() => {
|
|
921
|
-
|
|
921
|
+
D(!0);
|
|
922
922
|
}, []), _.useEffect(() => {
|
|
923
923
|
const ne = be.current;
|
|
924
924
|
if (ne) {
|
|
@@ -1062,7 +1062,7 @@ const Fl = (e) => {
|
|
|
1062
1062
|
bt.current = null;
|
|
1063
1063
|
const Ce = Number(((ne = be.current) == null ? void 0 : ne.style.getPropertyValue("--swipe-amount-x").replace("px", "")) || 0), Zt = Number(((me = be.current) == null ? void 0 : me.style.getPropertyValue("--swipe-amount-y").replace("px", "")) || 0), he = (/* @__PURE__ */ new Date()).getTime() - ((ge = Kt.current) == null ? void 0 : ge.getTime()), Ne = T === "x" ? Ce : Zt, Jt = Math.abs(Ne) / he;
|
|
1064
1064
|
if (Math.abs(Ne) >= Dl || Jt > 0.11) {
|
|
1065
|
-
fe(vt.current), l.onDismiss == null || l.onDismiss.call(l, l),
|
|
1065
|
+
fe(vt.current), l.onDismiss == null || l.onDismiss.call(l, l), L(T === "x" ? Ce > 0 ? "right" : "left" : Zt > 0 ? "down" : "up"), Xe(), te(!0);
|
|
1066
1066
|
return;
|
|
1067
1067
|
} else {
|
|
1068
1068
|
var Pe, Ae;
|
|
@@ -1182,16 +1182,16 @@ const Hl = /* @__PURE__ */ _.forwardRef(function(t, n) {
|
|
|
1182
1182
|
].concat(k.filter((I) => I.position).map((I) => I.position)))), [
|
|
1183
1183
|
k,
|
|
1184
1184
|
s
|
|
1185
|
-
]), [O, F] = _.useState([]), [z, V] = _.useState(!1), [q, K] = _.useState(!1), [M, B] = _.useState(m !== "system" ? m : typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"), Y = _.useRef(null), T = a.join("+").replace(/Key/g, "").replace(/Digit/g, ""), S = _.useRef(null), A = _.useRef(!1),
|
|
1186
|
-
N((
|
|
1185
|
+
]), [O, F] = _.useState([]), [z, V] = _.useState(!1), [q, K] = _.useState(!1), [M, B] = _.useState(m !== "system" ? m : typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"), Y = _.useRef(null), T = a.join("+").replace(/Key/g, "").replace(/Digit/g, ""), S = _.useRef(null), A = _.useRef(!1), L = _.useCallback((I) => {
|
|
1186
|
+
N((D) => {
|
|
1187
1187
|
var $;
|
|
1188
|
-
return ($ =
|
|
1188
|
+
return ($ = D.find((J) => J.id === I.id)) != null && $.delete || we.dismiss(I.id), D.filter(({ id: J }) => J !== I.id);
|
|
1189
1189
|
});
|
|
1190
1190
|
}, []);
|
|
1191
1191
|
return _.useEffect(() => we.subscribe((I) => {
|
|
1192
1192
|
if (I.dismiss) {
|
|
1193
1193
|
requestAnimationFrame(() => {
|
|
1194
|
-
N((
|
|
1194
|
+
N((D) => D.map(($) => $.id === I.id ? {
|
|
1195
1195
|
...$,
|
|
1196
1196
|
delete: !0
|
|
1197
1197
|
} : $));
|
|
@@ -1200,18 +1200,18 @@ const Hl = /* @__PURE__ */ _.forwardRef(function(t, n) {
|
|
|
1200
1200
|
}
|
|
1201
1201
|
setTimeout(() => {
|
|
1202
1202
|
ps.flushSync(() => {
|
|
1203
|
-
N((
|
|
1204
|
-
const $ =
|
|
1203
|
+
N((D) => {
|
|
1204
|
+
const $ = D.findIndex((J) => J.id === I.id);
|
|
1205
1205
|
return $ !== -1 ? [
|
|
1206
|
-
...
|
|
1206
|
+
...D.slice(0, $),
|
|
1207
1207
|
{
|
|
1208
|
-
...
|
|
1208
|
+
...D[$],
|
|
1209
1209
|
...I
|
|
1210
1210
|
},
|
|
1211
|
-
...
|
|
1211
|
+
...D.slice($ + 1)
|
|
1212
1212
|
] : [
|
|
1213
1213
|
I,
|
|
1214
|
-
...
|
|
1214
|
+
...D
|
|
1215
1215
|
];
|
|
1216
1216
|
});
|
|
1217
1217
|
});
|
|
@@ -1226,8 +1226,8 @@ const Hl = /* @__PURE__ */ _.forwardRef(function(t, n) {
|
|
|
1226
1226
|
if (m === "system" && (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? B("dark") : B("light")), typeof window > "u") return;
|
|
1227
1227
|
const I = window.matchMedia("(prefers-color-scheme: dark)");
|
|
1228
1228
|
try {
|
|
1229
|
-
I.addEventListener("change", ({ matches:
|
|
1230
|
-
B(
|
|
1229
|
+
I.addEventListener("change", ({ matches: D }) => {
|
|
1230
|
+
B(D ? "dark" : "light");
|
|
1231
1231
|
});
|
|
1232
1232
|
} catch {
|
|
1233
1233
|
I.addListener(({ matches: $ }) => {
|
|
@@ -1245,13 +1245,13 @@ const Hl = /* @__PURE__ */ _.forwardRef(function(t, n) {
|
|
|
1245
1245
|
}, [
|
|
1246
1246
|
R
|
|
1247
1247
|
]), _.useEffect(() => {
|
|
1248
|
-
const I = (
|
|
1248
|
+
const I = (D) => {
|
|
1249
1249
|
var $;
|
|
1250
|
-
if (a.every((j) =>
|
|
1250
|
+
if (a.every((j) => D[j] || D.code === j)) {
|
|
1251
1251
|
var W;
|
|
1252
1252
|
V(!0), (W = Y.current) == null || W.focus();
|
|
1253
1253
|
}
|
|
1254
|
-
|
|
1254
|
+
D.code === "Escape" && (document.activeElement === Y.current || ($ = Y.current) != null && $.contains(document.activeElement)) && V(!1);
|
|
1255
1255
|
};
|
|
1256
1256
|
return document.addEventListener("keydown", I), () => document.removeEventListener("keydown", I);
|
|
1257
1257
|
}, [
|
|
@@ -1274,7 +1274,7 @@ const Hl = /* @__PURE__ */ _.forwardRef(function(t, n) {
|
|
|
1274
1274
|
"aria-relevant": "additions text",
|
|
1275
1275
|
"aria-atomic": "false",
|
|
1276
1276
|
suppressHydrationWarning: !0
|
|
1277
|
-
}, P.map((I,
|
|
1277
|
+
}, P.map((I, D) => {
|
|
1278
1278
|
var $;
|
|
1279
1279
|
const [J, W] = I.split("-");
|
|
1280
1280
|
return k.length ? /* @__PURE__ */ _.createElement("ol", {
|
|
@@ -1312,7 +1312,7 @@ const Hl = /* @__PURE__ */ _.forwardRef(function(t, n) {
|
|
|
1312
1312
|
j.target instanceof HTMLElement && j.target.dataset.dismissible === "false" || K(!0);
|
|
1313
1313
|
},
|
|
1314
1314
|
onPointerUp: () => K(!1)
|
|
1315
|
-
}, k.filter((j) => !j.position &&
|
|
1315
|
+
}, k.filter((j) => !j.position && D === 0 || j.position === I).map((j, ee) => {
|
|
1316
1316
|
var te, se;
|
|
1317
1317
|
return /* @__PURE__ */ _.createElement(Fl, {
|
|
1318
1318
|
key: j.id,
|
|
@@ -1334,7 +1334,7 @@ const Hl = /* @__PURE__ */ _.forwardRef(function(t, n) {
|
|
|
1334
1334
|
cancelButtonStyle: y == null ? void 0 : y.cancelButtonStyle,
|
|
1335
1335
|
actionButtonStyle: y == null ? void 0 : y.actionButtonStyle,
|
|
1336
1336
|
closeButtonAriaLabel: y == null ? void 0 : y.closeButtonAriaLabel,
|
|
1337
|
-
removeToast:
|
|
1337
|
+
removeToast: L,
|
|
1338
1338
|
toasts: k.filter((oe) => oe.position == j.position),
|
|
1339
1339
|
heights: O.filter((oe) => oe.position == j.position),
|
|
1340
1340
|
setHeights: F,
|
|
@@ -2303,11 +2303,11 @@ const ru = (e, t) => {
|
|
|
2303
2303
|
span: ["full", Je, U, H]
|
|
2304
2304
|
}, Je, U, H], z = () => [Je, "auto", U, H], V = () => ["auto", "min", "max", "fr", U, H], q = () => ["start", "end", "center", "between", "around", "evenly", "stretch", "baseline", "center-safe", "end-safe"], K = () => ["start", "end", "center", "stretch", "center-safe", "end-safe"], M = () => ["auto", ...k()], B = () => [Ze, "auto", "full", "dvw", "dvh", "lvw", "lvh", "svw", "svh", "min", "max", "fit", ...k()], Y = () => [Ze, "screen", "full", "dvw", "lvw", "svw", "min", "max", "fit", ...k()], T = () => [Ze, "screen", "full", "lh", "dvh", "lvh", "svh", "min", "max", "fit", ...k()], S = () => [e, U, H], A = () => [...C(), Tr, Rr, {
|
|
2305
2305
|
position: [U, H]
|
|
2306
|
-
}],
|
|
2306
|
+
}], L = () => ["no-repeat", {
|
|
2307
2307
|
repeat: ["", "x", "y", "space", "round"]
|
|
2308
2308
|
}], I = () => ["auto", "cover", "contain", Hu, Du, {
|
|
2309
2309
|
size: [U, H]
|
|
2310
|
-
}],
|
|
2310
|
+
}], D = () => [Xn, Lt, ct], $ = () => [
|
|
2311
2311
|
// Deprecated since Tailwind CSS v4.0.0
|
|
2312
2312
|
"",
|
|
2313
2313
|
"none",
|
|
@@ -3384,7 +3384,7 @@ const ru = (e, t) => {
|
|
|
3384
3384
|
* @see https://tailwindcss.com/docs/background-repeat
|
|
3385
3385
|
*/
|
|
3386
3386
|
"bg-repeat": [{
|
|
3387
|
-
bg:
|
|
3387
|
+
bg: L()
|
|
3388
3388
|
}],
|
|
3389
3389
|
/**
|
|
3390
3390
|
* Background Size
|
|
@@ -3418,21 +3418,21 @@ const ru = (e, t) => {
|
|
|
3418
3418
|
* @see https://tailwindcss.com/docs/gradient-color-stops
|
|
3419
3419
|
*/
|
|
3420
3420
|
"gradient-from-pos": [{
|
|
3421
|
-
from:
|
|
3421
|
+
from: D()
|
|
3422
3422
|
}],
|
|
3423
3423
|
/**
|
|
3424
3424
|
* Gradient Color Stops Via Position
|
|
3425
3425
|
* @see https://tailwindcss.com/docs/gradient-color-stops
|
|
3426
3426
|
*/
|
|
3427
3427
|
"gradient-via-pos": [{
|
|
3428
|
-
via:
|
|
3428
|
+
via: D()
|
|
3429
3429
|
}],
|
|
3430
3430
|
/**
|
|
3431
3431
|
* Gradient Color Stops To Position
|
|
3432
3432
|
* @see https://tailwindcss.com/docs/gradient-color-stops
|
|
3433
3433
|
*/
|
|
3434
3434
|
"gradient-to-pos": [{
|
|
3435
|
-
to:
|
|
3435
|
+
to: D()
|
|
3436
3436
|
}],
|
|
3437
3437
|
/**
|
|
3438
3438
|
* Gradient Color Stops From
|
|
@@ -4089,7 +4089,7 @@ const ru = (e, t) => {
|
|
|
4089
4089
|
* @see https://tailwindcss.com/docs/mask-repeat
|
|
4090
4090
|
*/
|
|
4091
4091
|
"mask-repeat": [{
|
|
4092
|
-
mask:
|
|
4092
|
+
mask: L()
|
|
4093
4093
|
}],
|
|
4094
4094
|
/**
|
|
4095
4095
|
* Mask Size
|
|
@@ -8041,7 +8041,7 @@ var Qo = "PopperContent", [Wm, Um] = Fa(Qo), Ua = f.forwardRef(
|
|
|
8041
8041
|
de(() => {
|
|
8042
8042
|
B && (A == null || A());
|
|
8043
8043
|
}, [B, A]);
|
|
8044
|
-
const
|
|
8044
|
+
const L = (W = Y.arrow) == null ? void 0 : W.x, I = (j = Y.arrow) == null ? void 0 : j.y, D = ((ee = Y.arrow) == null ? void 0 : ee.centerOffset) !== 0, [$, J] = f.useState();
|
|
8045
8045
|
return de(() => {
|
|
8046
8046
|
y && J(window.getComputedStyle(y).zIndex);
|
|
8047
8047
|
}, [y]), /* @__PURE__ */ u(
|
|
@@ -8074,9 +8074,9 @@ var Qo = "PopperContent", [Wm, Um] = Fa(Qo), Ua = f.forwardRef(
|
|
|
8074
8074
|
scope: n,
|
|
8075
8075
|
placedSide: T,
|
|
8076
8076
|
onArrowChange: E,
|
|
8077
|
-
arrowX:
|
|
8077
|
+
arrowX: L,
|
|
8078
8078
|
arrowY: I,
|
|
8079
|
-
shouldHideArrow:
|
|
8079
|
+
shouldHideArrow: D,
|
|
8080
8080
|
children: /* @__PURE__ */ u(
|
|
8081
8081
|
Z.div,
|
|
8082
8082
|
{
|
|
@@ -9392,13 +9392,13 @@ var Ie = 10, [Wi, st] = Mt(pt), qh = "SelectContentImpl", Kh = /* @__PURE__ */ H
|
|
|
9392
9392
|
const [S, A] = sc((W) => {
|
|
9393
9393
|
const j = z().filter((se) => !se.disabled), ee = j.find((se) => se.ref.current === document.activeElement), te = ac(j, W, ee);
|
|
9394
9394
|
te && setTimeout(() => te.ref.current.focus());
|
|
9395
|
-
}),
|
|
9395
|
+
}), L = f.useCallback(
|
|
9396
9396
|
(W, j, ee) => {
|
|
9397
9397
|
const te = !K.current && !ee;
|
|
9398
9398
|
(w.value !== void 0 && w.value === j || te) && (P(W), te && (K.current = !0));
|
|
9399
9399
|
},
|
|
9400
9400
|
[w.value]
|
|
9401
|
-
), I = f.useCallback(() => x == null ? void 0 : x.focus(), [x]),
|
|
9401
|
+
), I = f.useCallback(() => x == null ? void 0 : x.focus(), [x]), D = f.useCallback(
|
|
9402
9402
|
(W, j, ee) => {
|
|
9403
9403
|
const te = !K.current && !ee;
|
|
9404
9404
|
(w.value !== void 0 && w.value === j || te) && F(W);
|
|
@@ -9423,10 +9423,10 @@ var Ie = 10, [Wi, st] = Mt(pt), qh = "SelectContentImpl", Kh = /* @__PURE__ */ H
|
|
|
9423
9423
|
content: x,
|
|
9424
9424
|
viewport: E,
|
|
9425
9425
|
onViewportChange: R,
|
|
9426
|
-
itemRefCallback:
|
|
9426
|
+
itemRefCallback: L,
|
|
9427
9427
|
selectedItem: k,
|
|
9428
9428
|
onItemLeave: I,
|
|
9429
|
-
itemTextRefCallback:
|
|
9429
|
+
itemTextRefCallback: D,
|
|
9430
9430
|
focusSelectedItem: B,
|
|
9431
9431
|
selectedItemText: O,
|
|
9432
9432
|
position: o,
|
|
@@ -9517,8 +9517,8 @@ var Xh = "SelectItemAlignedPosition", ji = f.forwardRef((e, t) => {
|
|
|
9517
9517
|
]);
|
|
9518
9518
|
i.style.minWidth = fe + "px", i.style.right = Te + "px";
|
|
9519
9519
|
}
|
|
9520
|
-
const F = m(), z = window.innerHeight - Ie * 2, V = g.scrollHeight, q = window.getComputedStyle(d), K = parseInt(q.borderTopWidth, 10), M = parseInt(q.paddingTop, 10), B = parseInt(q.borderBottomWidth, 10), Y = parseInt(q.paddingBottom, 10), T = K + M + V + Y + B, S = Math.min(v.offsetHeight * 5, T), A = window.getComputedStyle(g),
|
|
9521
|
-
if (j <=
|
|
9520
|
+
const F = m(), z = window.innerHeight - Ie * 2, V = g.scrollHeight, q = window.getComputedStyle(d), K = parseInt(q.borderTopWidth, 10), M = parseInt(q.paddingTop, 10), B = parseInt(q.borderBottomWidth, 10), Y = parseInt(q.paddingBottom, 10), T = K + M + V + Y + B, S = Math.min(v.offsetHeight * 5, T), A = window.getComputedStyle(g), L = parseInt(A.paddingTop, 10), I = parseInt(A.paddingBottom, 10), D = N.top + N.height / 2 - Ie, $ = z - D, J = v.offsetHeight / 2, W = v.offsetTop + J, j = K + M + W, ee = T - j;
|
|
9521
|
+
if (j <= D) {
|
|
9522
9522
|
const se = F.length > 0 && v === F[F.length - 1].ref.current;
|
|
9523
9523
|
i.style.bottom = "0px";
|
|
9524
9524
|
const oe = d.clientHeight - g.offsetTop - g.offsetHeight, ue = Math.max(
|
|
@@ -9531,11 +9531,11 @@ var Xh = "SelectItemAlignedPosition", ji = f.forwardRef((e, t) => {
|
|
|
9531
9531
|
const se = F.length > 0 && v === F[0].ref.current;
|
|
9532
9532
|
i.style.top = "0px";
|
|
9533
9533
|
const ue = Math.max(
|
|
9534
|
-
|
|
9534
|
+
D,
|
|
9535
9535
|
K + g.offsetTop + // viewport might have padding top, include it to avoid a scrollable viewport
|
|
9536
|
-
(se ?
|
|
9536
|
+
(se ? L : 0) + J
|
|
9537
9537
|
) + ee;
|
|
9538
|
-
i.style.height = ue + "px", g.scrollTop = j -
|
|
9538
|
+
i.style.height = ue + "px", g.scrollTop = j - D + g.offsetTop;
|
|
9539
9539
|
}
|
|
9540
9540
|
i.style.margin = `${Ie}px 0`, i.style.minHeight = S + "px", i.style.maxHeight = z + "px", o == null || o(), requestAnimationFrame(() => h.current = !0);
|
|
9541
9541
|
}
|
|
@@ -11830,7 +11830,18 @@ const Ot = (e) => e == null ? void 0 : e === !0 || e === "true", Mc = {
|
|
|
11830
11830
|
customerEmail: a,
|
|
11831
11831
|
customerName: i
|
|
11832
11832
|
}) => {
|
|
11833
|
-
const [c, d] = le([]), [p, l] = le([]), [m, h] = le(/* @__PURE__ */ new Map()), [b, g] = le(/* @__PURE__ */ new Map()), [v, y] = le(!1), [w, x] = le({ authenticated: !1, user: null }), [C, E] = le(void 0)
|
|
11833
|
+
const [c, d] = le([]), [p, l] = le([]), [m, h] = le(/* @__PURE__ */ new Map()), [b, g] = le(/* @__PURE__ */ new Map()), [v, y] = le(!1), [w, x] = le({ authenticated: !1, user: null }), [C, E] = le(void 0);
|
|
11834
|
+
ce(() => {
|
|
11835
|
+
window.stackable || (window.stackable = {
|
|
11836
|
+
emit: (T, S = {}) => {
|
|
11837
|
+
const [A, ...L] = T.split(":"), I = L.join(":");
|
|
11838
|
+
window.dispatchEvent(new CustomEvent(`stackable:${A}`, {
|
|
11839
|
+
detail: { eventName: I, data: S }
|
|
11840
|
+
}));
|
|
11841
|
+
}
|
|
11842
|
+
});
|
|
11843
|
+
}, []);
|
|
11844
|
+
const R = Me(null), N = Me(/* @__PURE__ */ new Set()), k = Bt(() => c.filter((T) => T.manifest.permissions.includes("extend:identity")).map((T) => T.id), [c]);
|
|
11834
11845
|
ce(() => {
|
|
11835
11846
|
(async () => {
|
|
11836
11847
|
const S = e;
|
|
@@ -11848,8 +11859,8 @@ const Ot = (e) => e == null ? void 0 : e === !0 || e === "true", Mc = {
|
|
|
11848
11859
|
console.warn(`[ExtensionSetup] Instance not found or failed to load: ${S}`), d([]), y(!0);
|
|
11849
11860
|
return;
|
|
11850
11861
|
}
|
|
11851
|
-
const
|
|
11852
|
-
d(
|
|
11862
|
+
const L = await A.json(), I = bs(typeof window < "u" ? window.location.search : ""), D = await jl(L, I), { tokens: $, errors: J } = await Mb(D, n, o, I);
|
|
11863
|
+
d(D), l(I), h(new Map($)), g(J);
|
|
11853
11864
|
} catch (A) {
|
|
11854
11865
|
console.error("Failed to load extensions:", A);
|
|
11855
11866
|
} finally {
|
|
@@ -11862,27 +11873,27 @@ const Ot = (e) => e == null ? void 0 : e === !0 || e === "true", Mc = {
|
|
|
11862
11873
|
const S = setInterval(async () => {
|
|
11863
11874
|
const A = [];
|
|
11864
11875
|
await Promise.all(
|
|
11865
|
-
c.filter((
|
|
11866
|
-
const I = p.find((j) => j.extensionId ===
|
|
11876
|
+
c.filter((L) => L.manifest.permissions.includes("data:fetch")).map(async (L) => {
|
|
11877
|
+
const I = p.find((j) => j.extensionId === L.id), D = I == null ? void 0 : I.token, $ = I == null ? void 0 : I.mode, J = zt(n, "/proxy-token"), W = await fetch(J, {
|
|
11867
11878
|
method: "POST",
|
|
11868
11879
|
headers: { "Content-Type": "application/json" },
|
|
11869
11880
|
body: JSON.stringify({
|
|
11870
11881
|
appId: o,
|
|
11871
|
-
extensionId:
|
|
11882
|
+
extensionId: L.id,
|
|
11872
11883
|
...$ && { mode: $ },
|
|
11873
|
-
...
|
|
11884
|
+
...D && { devSessionToken: D }
|
|
11874
11885
|
})
|
|
11875
11886
|
});
|
|
11876
11887
|
if (W.ok) {
|
|
11877
11888
|
const { token: j, encryptionKey: ee } = await W.json();
|
|
11878
|
-
A.push([
|
|
11889
|
+
A.push([L.id, { token: j, encryptionKey: ee }]);
|
|
11879
11890
|
} else
|
|
11880
|
-
console.warn(`[embeddables] Proxy token refresh failed for extension ${
|
|
11891
|
+
console.warn(`[embeddables] Proxy token refresh failed for extension ${L.id} (${W.status}) — using stale token`);
|
|
11881
11892
|
})
|
|
11882
|
-
), A.length > 0 && h((
|
|
11883
|
-
const I = new Map(
|
|
11884
|
-
for (const [
|
|
11885
|
-
I.set(
|
|
11893
|
+
), A.length > 0 && h((L) => {
|
|
11894
|
+
const I = new Map(L);
|
|
11895
|
+
for (const [D, $] of A)
|
|
11896
|
+
I.set(D, $);
|
|
11886
11897
|
return I;
|
|
11887
11898
|
});
|
|
11888
11899
|
}, 3300 * 1e3);
|
|
@@ -11894,24 +11905,24 @@ const Ot = (e) => e == null ? void 0 : e === !0 || e === "true", Mc = {
|
|
|
11894
11905
|
const A = S.data;
|
|
11895
11906
|
if ((A == null ? void 0 : A.type) !== "extension-ready")
|
|
11896
11907
|
return;
|
|
11897
|
-
const
|
|
11908
|
+
const L = A.extensionId, I = c.find((J) => J.id === L);
|
|
11898
11909
|
if (!(I != null && I.bundleUrl))
|
|
11899
11910
|
return;
|
|
11900
|
-
const
|
|
11901
|
-
if (Vl(I.bundleUrl) && (
|
|
11911
|
+
const D = p.find((J) => J.extensionId === L);
|
|
11912
|
+
if (Vl(I.bundleUrl) && (D == null ? void 0 : D.mode) !== "staging")
|
|
11902
11913
|
return;
|
|
11903
|
-
const $ = m.get(
|
|
11904
|
-
$ && $e(
|
|
11914
|
+
const $ = m.get(L);
|
|
11915
|
+
$ && $e(L, { type: "extension-encryption-key", encryptionKey: $.encryptionKey });
|
|
11905
11916
|
};
|
|
11906
11917
|
return window.addEventListener("message", T), () => window.removeEventListener("message", T);
|
|
11907
11918
|
}, [c, p, m]);
|
|
11908
11919
|
const P = ye((T, S) => {
|
|
11909
11920
|
const A = Ct();
|
|
11910
|
-
for (const [
|
|
11921
|
+
for (const [L, I] of A) {
|
|
11911
11922
|
if (!I.manifest.permissions.includes("events:identity"))
|
|
11912
11923
|
continue;
|
|
11913
|
-
const
|
|
11914
|
-
!
|
|
11924
|
+
const D = I.manifest.events ?? [];
|
|
11925
|
+
!D.includes("identity") && !D.includes(`identity:${T}`) || $e(L, {
|
|
11915
11926
|
type: "extension-event",
|
|
11916
11927
|
eventType: "identity",
|
|
11917
11928
|
payload: { eventName: T, data: { state: S, timestamp: Kn((/* @__PURE__ */ new Date()).toISOString()) } }
|
|
@@ -11919,10 +11930,10 @@ const Ot = (e) => e == null ? void 0 : e === !0 || e === "true", Mc = {
|
|
|
11919
11930
|
}
|
|
11920
11931
|
}, []), O = ye((T) => {
|
|
11921
11932
|
const S = Ct();
|
|
11922
|
-
for (const [A,
|
|
11923
|
-
if (!
|
|
11933
|
+
for (const [A, L] of S) {
|
|
11934
|
+
if (!L.manifest.permissions.includes("events:messaging"))
|
|
11924
11935
|
continue;
|
|
11925
|
-
const I =
|
|
11936
|
+
const I = L.manifest.events ?? [];
|
|
11926
11937
|
!I.includes("messaging") && !I.includes("messaging:postback") && !I.includes(`messaging:postback:${T.data.actionName}`) || $e(A, {
|
|
11927
11938
|
type: "extension-event",
|
|
11928
11939
|
eventType: "messaging",
|
|
@@ -11931,10 +11942,10 @@ const Ot = (e) => e == null ? void 0 : e === !0 || e === "true", Mc = {
|
|
|
11931
11942
|
}
|
|
11932
11943
|
}, []), F = ye((T) => {
|
|
11933
11944
|
const S = Ct();
|
|
11934
|
-
for (const [A,
|
|
11935
|
-
if (!
|
|
11945
|
+
for (const [A, L] of S) {
|
|
11946
|
+
if (!L.manifest.permissions.includes("events:activity"))
|
|
11936
11947
|
continue;
|
|
11937
|
-
const I =
|
|
11948
|
+
const I = L.manifest.events ?? [];
|
|
11938
11949
|
!I.includes("activity") && !I.includes(`activity:${T.eventName}`) || $e(A, {
|
|
11939
11950
|
type: "extension-event",
|
|
11940
11951
|
eventType: "activity",
|
|
@@ -11943,8 +11954,8 @@ const Ot = (e) => e == null ? void 0 : e === !0 || e === "true", Mc = {
|
|
|
11943
11954
|
}
|
|
11944
11955
|
}, []), z = ye(async (T) => {
|
|
11945
11956
|
const S = Ct(), A = [];
|
|
11946
|
-
for (const [I,
|
|
11947
|
-
if (!
|
|
11957
|
+
for (const [I, D] of S) {
|
|
11958
|
+
if (!D.manifest.permissions.includes("extend:identity"))
|
|
11948
11959
|
continue;
|
|
11949
11960
|
const $ = new Promise((J) => {
|
|
11950
11961
|
const W = `enrich_${I}_${Date.now()}`, j = (ee) => {
|
|
@@ -11963,8 +11974,8 @@ const Ot = (e) => e == null ? void 0 : e === !0 || e === "true", Mc = {
|
|
|
11963
11974
|
}
|
|
11964
11975
|
if (A.length === 0)
|
|
11965
11976
|
return {};
|
|
11966
|
-
const
|
|
11967
|
-
return Object.assign({}, ...
|
|
11977
|
+
const L = await Promise.all(A);
|
|
11978
|
+
return Object.assign({}, ...L);
|
|
11968
11979
|
}, []), V = ye(async (T) => {
|
|
11969
11980
|
if (!n || !o || !e)
|
|
11970
11981
|
return console.warn("[embeddables] signIdentity skipped — missing:", { apiBase: !!n, appId: !!o, instanceId: !!e }), null;
|
|
@@ -11978,8 +11989,8 @@ const Ot = (e) => e == null ? void 0 : e === !0 || e === "true", Mc = {
|
|
|
11978
11989
|
});
|
|
11979
11990
|
if (!A.ok)
|
|
11980
11991
|
return console.warn(`[embeddables] Identity sign failed (${A.status})`), null;
|
|
11981
|
-
const { token:
|
|
11982
|
-
return
|
|
11992
|
+
const { token: L } = await A.json();
|
|
11993
|
+
return L;
|
|
11983
11994
|
} catch (A) {
|
|
11984
11995
|
return console.warn("[embeddables] Identity sign request failed:", A), null;
|
|
11985
11996
|
}
|
|
@@ -11993,17 +12004,17 @@ const Ot = (e) => e == null ? void 0 : e === !0 || e === "true", Mc = {
|
|
|
11993
12004
|
T && T("messenger", "logoutUser");
|
|
11994
12005
|
}, []), M = ye((T) => {
|
|
11995
12006
|
console.log("[embeddables] Running sign lifecycle for user:", T.id);
|
|
11996
|
-
const { email: S, name: A } = T,
|
|
12007
|
+
const { email: S, name: A } = T, L = { external_id: String(T.id) };
|
|
11997
12008
|
(async () => {
|
|
11998
|
-
const I = await z({ ...
|
|
12009
|
+
const I = await z({ ...L, email: S, name: A });
|
|
11999
12010
|
console.log("[embeddables] Enriched claims:", I);
|
|
12000
|
-
const
|
|
12001
|
-
...
|
|
12011
|
+
const D = await V({
|
|
12012
|
+
...L,
|
|
12002
12013
|
...I,
|
|
12003
12014
|
email: S,
|
|
12004
12015
|
name: A
|
|
12005
12016
|
});
|
|
12006
|
-
console.log("[embeddables] Sign result:", { hasToken: !!
|
|
12017
|
+
console.log("[embeddables] Sign result:", { hasToken: !!D }), D && q(D);
|
|
12007
12018
|
})();
|
|
12008
12019
|
}, [z, V, q]), B = ye((T) => {
|
|
12009
12020
|
if (k.length > 0 && N.current.size < k.length) {
|
|
@@ -12029,8 +12040,8 @@ const Ot = (e) => e == null ? void 0 : e === !0 || e === "true", Mc = {
|
|
|
12029
12040
|
}
|
|
12030
12041
|
};
|
|
12031
12042
|
x((S) => {
|
|
12032
|
-
var A,
|
|
12033
|
-
return S.authenticated && ((A = S.user) == null ? void 0 : A.id) === ((
|
|
12043
|
+
var A, L;
|
|
12044
|
+
return S.authenticated && ((A = S.user) == null ? void 0 : A.id) === ((L = T.user) == null ? void 0 : L.id) ? S : (console.log("[embeddables] Identity state changed (props), starting sign lifecycle"), B(T.user), P("login", T), T);
|
|
12034
12045
|
});
|
|
12035
12046
|
} else {
|
|
12036
12047
|
if (s === void 0)
|
|
@@ -12044,24 +12055,24 @@ const Ot = (e) => e == null ? void 0 : e === !0 || e === "true", Mc = {
|
|
|
12044
12055
|
const A = document.getElementById("stackable-identity");
|
|
12045
12056
|
if (A)
|
|
12046
12057
|
try {
|
|
12047
|
-
const
|
|
12058
|
+
const L = JSON.parse(A.textContent ?? "{}"), I = {
|
|
12048
12059
|
authenticated: !0,
|
|
12049
12060
|
user: {
|
|
12050
|
-
id: String(
|
|
12051
|
-
email:
|
|
12052
|
-
name:
|
|
12061
|
+
id: String(L.customerId ?? ""),
|
|
12062
|
+
email: L.customerEmail,
|
|
12063
|
+
name: L.customerName,
|
|
12053
12064
|
provider: "shopify"
|
|
12054
12065
|
}
|
|
12055
12066
|
};
|
|
12056
|
-
x((
|
|
12067
|
+
x((D) => {
|
|
12057
12068
|
var $, J;
|
|
12058
|
-
return
|
|
12069
|
+
return D.authenticated && (($ = D.user) == null ? void 0 : $.id) === ((J = I.user) == null ? void 0 : J.id) ? D : (console.log("[embeddables] Identity state changed (DOM), starting sign lifecycle"), B(I.user), P("login", I), I);
|
|
12059
12070
|
});
|
|
12060
12071
|
} catch {
|
|
12061
12072
|
console.warn("[embeddables] Failed to parse #stackable-identity JSON");
|
|
12062
12073
|
}
|
|
12063
12074
|
else
|
|
12064
|
-
x((
|
|
12075
|
+
x((L) => L.authenticated ? (K(), P("logout", { authenticated: !1, user: null }), { authenticated: !1, user: null }) : L);
|
|
12065
12076
|
};
|
|
12066
12077
|
T();
|
|
12067
12078
|
const S = new MutationObserver(T);
|
|
@@ -12073,11 +12084,11 @@ const Ot = (e) => e == null ? void 0 : e === !0 || e === "true", Mc = {
|
|
|
12073
12084
|
const A = S.data;
|
|
12074
12085
|
if ((A == null ? void 0 : A.type) !== "extension-ready")
|
|
12075
12086
|
return;
|
|
12076
|
-
const
|
|
12087
|
+
const L = A.extensionId, I = c.find(($) => $.id === L);
|
|
12077
12088
|
if (!(I != null && I.manifest.permissions.includes("events:identity")))
|
|
12078
12089
|
return;
|
|
12079
|
-
const
|
|
12080
|
-
!
|
|
12090
|
+
const D = I.manifest.events ?? [];
|
|
12091
|
+
!D.includes("identity") && !D.includes("identity:login") || $e(L, {
|
|
12081
12092
|
type: "extension-event",
|
|
12082
12093
|
eventType: "identity",
|
|
12083
12094
|
payload: { eventName: "login", data: { state: w, timestamp: Kn((/* @__PURE__ */ new Date()).toISOString()) } }
|
|
@@ -12088,14 +12099,14 @@ const Ot = (e) => e == null ? void 0 : e === !0 || e === "true", Mc = {
|
|
|
12088
12099
|
if (k.length === 0)
|
|
12089
12100
|
return;
|
|
12090
12101
|
const T = (A) => {
|
|
12091
|
-
const
|
|
12092
|
-
if ((
|
|
12102
|
+
const L = A.data;
|
|
12103
|
+
if ((L == null ? void 0 : L.type) !== "extension-ready")
|
|
12093
12104
|
return;
|
|
12094
|
-
const I =
|
|
12105
|
+
const I = L.extensionId;
|
|
12095
12106
|
if (k.includes(I) && (N.current.add(I), console.log(`[embeddables] extend:identity extension ready: ${I} (${N.current.size}/${k.length})`), N.current.size >= k.length && R.current)) {
|
|
12096
12107
|
console.log("[embeddables] All extend:identity extensions ready, running deferred sign lifecycle");
|
|
12097
|
-
const
|
|
12098
|
-
R.current = null, M(
|
|
12108
|
+
const D = R.current;
|
|
12109
|
+
R.current = null, M(D);
|
|
12099
12110
|
}
|
|
12100
12111
|
};
|
|
12101
12112
|
window.addEventListener("message", T);
|
|
@@ -12119,7 +12130,7 @@ const Ot = (e) => e == null ? void 0 : e === !0 || e === "true", Mc = {
|
|
|
12119
12130
|
conversationId: A.data.conversationId ?? "",
|
|
12120
12131
|
timestamp: Kn((/* @__PURE__ */ new Date()).toISOString())
|
|
12121
12132
|
}
|
|
12122
|
-
}) : A.eventName === "context" && E((
|
|
12133
|
+
}) : A.eventName === "context" && E((L) => ({ ...L, ...A.data })));
|
|
12123
12134
|
};
|
|
12124
12135
|
return window.addEventListener("stackable:messaging", T), () => window.removeEventListener("stackable:messaging", T);
|
|
12125
12136
|
}, [O]), ce(() => {
|
|
@@ -12141,8 +12152,8 @@ const Ot = (e) => e == null ? void 0 : e === !0 || e === "true", Mc = {
|
|
|
12141
12152
|
messaging: C,
|
|
12142
12153
|
identity: w
|
|
12143
12154
|
}, S = Ct();
|
|
12144
|
-
for (const [A,
|
|
12145
|
-
|
|
12155
|
+
for (const [A, L] of S)
|
|
12156
|
+
L.manifest.permissions.includes("context:read") && $e(A, { type: "context-push", context: T });
|
|
12146
12157
|
}, [v, s, a, i, w, C]);
|
|
12147
12158
|
const Y = Bt(
|
|
12148
12159
|
() => ({
|
|
@@ -12158,12 +12169,12 @@ const Ot = (e) => e == null ? void 0 : e === !0 || e === "true", Mc = {
|
|
|
12158
12169
|
error: "data.fetch: proxy token unavailable — ensure the extension has data:fetch permission and allowedDomains configured"
|
|
12159
12170
|
}
|
|
12160
12171
|
};
|
|
12161
|
-
const
|
|
12172
|
+
const L = Ob(S) ? S : {
|
|
12162
12173
|
url: S.url,
|
|
12163
12174
|
method: S.method ?? "GET",
|
|
12164
12175
|
headers: S.headers ?? {},
|
|
12165
12176
|
body: S.body ?? null
|
|
12166
|
-
}, I = zt(n, "/proxy"),
|
|
12177
|
+
}, I = zt(n, "/proxy"), D = await fetch(I, {
|
|
12167
12178
|
method: "POST",
|
|
12168
12179
|
headers: {
|
|
12169
12180
|
"Content-Type": "application/json",
|
|
@@ -12171,11 +12182,11 @@ const Ot = (e) => e == null ? void 0 : e === !0 || e === "true", Mc = {
|
|
|
12171
12182
|
"X-Application-Id": o ?? "",
|
|
12172
12183
|
Authorization: `Bearer ${A.token}`
|
|
12173
12184
|
},
|
|
12174
|
-
body: JSON.stringify(
|
|
12175
|
-
}), $ = await
|
|
12185
|
+
body: JSON.stringify(L)
|
|
12186
|
+
}), $ = await D.json();
|
|
12176
12187
|
return {
|
|
12177
|
-
status: $.status ??
|
|
12178
|
-
ok: $.ok ??
|
|
12188
|
+
status: $.status ?? D.status,
|
|
12189
|
+
ok: $.ok ?? D.ok,
|
|
12179
12190
|
data: $.data
|
|
12180
12191
|
};
|
|
12181
12192
|
},
|
|
@@ -12188,10 +12199,10 @@ const Ot = (e) => e == null ? void 0 : e === !0 || e === "true", Mc = {
|
|
|
12188
12199
|
...S.closeButton != null && { closeButton: S.closeButton }
|
|
12189
12200
|
};
|
|
12190
12201
|
if (S.fetch) {
|
|
12191
|
-
const
|
|
12202
|
+
const L = (D) => new Promise(($) => setTimeout($, D)), I = Promise.all([
|
|
12192
12203
|
Y["data.fetch"](T, S.fetch),
|
|
12193
|
-
|
|
12194
|
-
]).then(([
|
|
12204
|
+
L(_b)
|
|
12205
|
+
]).then(([D]) => D);
|
|
12195
12206
|
yt.promise(I, {
|
|
12196
12207
|
loading: S.loading ?? S.message,
|
|
12197
12208
|
success: S.success ?? S.message,
|