@adyen/adyen-platform-experience-web
Version:

47 lines (46 loc) • 1.11 kB
JavaScript
import b from "./session/utils/sessionAwareComponentAvailability/sessionAwareComponentAvailability.js";
import { isWatchlistUnsubscribeToken as f } from "../../primitives/reactive/watchlist/main.js";
import { noop as l } from "../../utils/common.js";
function a(e) {
const { context: n, http: t, refresh: r } = e;
return { ...n, http: t, refresh: r };
}
function m(e, n) {
return b(e, n);
}
function g(e, n, t = m) {
let r;
return {
connect(u) {
let o = !0, i = l;
const c = () => {
i(), o && (i = p(e, {
onContextChange: u,
onUnsubscribe: c
}));
};
return c(), t(n, e).then((s) => {
!o || r === s || (r = s, u());
}), () => {
o = !1, i();
};
},
getSnapshot() {
return {
contextValue: a(e),
hasPermission: r
};
}
};
}
function p(e, n) {
return e.subscribe((t) => {
f(t) ? n.onUnsubscribe() : n.onContextChange();
});
}
export {
m as checkComponentPermission,
a as createConfigContextValue,
g as createConfigController,
p as subscribeToSession
};