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

58 lines (57 loc) • 1.44 kB
JavaScript
import { CDN_ENVIRONMENTS as l, API_ENVIRONMENTS as $ } from "./constants.js";
import { httpGet as i } from "./Http/http.js";
const c = "test", a = "live", d = (r) => r?.replace?.(/([^/])$/, "$1/"), u = (r) => r?.replace(/^([^/])/, "/$1"), v = /* @__PURE__ */ (() => {
const r = $, e = l;
return (t) => {
const n = e[(t === "test" ? "live" : t) ?? a] || e[a];
return {
apiUrl: r[t ?? c] || r[c],
cdnTranslationsUrl: `${n}/assets/translations`,
cdnAssetsUrl: `${n}/assets`,
cdnConfigUrl: `${n}/config`
};
};
})(), E = ({ url: r }) => async ({
name: e,
extension: t = "json",
fallback: o,
subFolder: n = ""
}) => {
try {
return await i({
loadingContext: `${r}${n ? `/${n}` : ""}`,
path: `/${e}.${t}`,
versionless: !0,
skipContentType: !0,
errorLevel: "error"
});
} catch (s) {
return console.warn(s), o;
}
}, N = ({ url: r }) => async ({
name: e,
extension: t = "json",
fallback: o,
subFolder: n = ""
}) => {
try {
return await i({
loadingContext: `${r}${n ? `/${n}` : ""}`,
path: `/${e}.${t}`,
versionless: !0,
skipContentType: !0,
errorLevel: "error"
});
} catch (s) {
return console.warn(s), o;
}
};
export {
a as FALLBACK_CDN_ENV,
c as FALLBACK_ENV,
E as getConfigFromCdn,
N as getDatasetFromCdn,
d as normalizeLoadingContext,
u as normalizeUrl,
v as resolveEnvironment
};