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

33 lines (32 loc) • 1.18 kB
JavaScript
import { EVT_SESSION_EXPIRED as l } from "../constants.js";
import { createPromisor as m } from "../../../async/promisor/main.js";
import { isFunction as p } from "../../../../utils/value/is.js";
import { boolOrFalse as c, falsify as h } from "../../../../utils/value/bool.js";
import { getter as _ } from "../../../../utils/struct/property.js";
import { noop as i } from "../../../../utils/common.js";
import { tryResolve as d } from "../../../../utils/async/main.js";
const y = async (t) => {
const { specification: s } = t.context, e = await d(async () => {
const o = s.autoRefresh;
return p(o) ? o.call(s, t.session) : o;
}).catch(h);
return c(e);
}, v = (t) => {
let s = t.context.emitter.on(l, () => a(!1)), e, o = m(async (r, f = !1) => {
e = r;
const u = c(f) || await y(t);
e === r && u && t.pending && !t.refreshing && t.refresh(e).catch(i);
}), a = (r = !1) => {
t.refreshing || o(r);
}, n = () => {
s(), o.abort(), o = e = s = void 0, a = n = i;
};
return Object.defineProperties((r = !1) => a(r), {
destruct: _(() => n, !1)
});
};
export {
y as _canAutofresh,
v as createSessionAutofresher,
v as default
};