Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// @todo may want to make this more flexible
script.src = `../../haxcms-jwt`;
fetch(script.src).then(response => {
if (response.status != 404) {
document.documentElement.appendChild(script);
}
});
}
// dynamic import if this isn't published tho we'll double check
// that it's valid later
if (context !== "published") {
const basePath = this.pathFromUrl(decodeURIComponent(import.meta.url));
// import and set the tag based on the context
store.cmsSiteEditorBackend.tag = `haxcms-backend-${context}`;
// delay import slightly to ensure global scope is there
import(`${basePath}backends/${store.cmsSiteEditorBackend.tag}.js`).then(
e => {
if (!store.cmsSiteEditorBackend.instance) {
store.cmsSiteEditorBackend.instance = document.createElement(
store.cmsSiteEditorBackend.tag
);
document.body.append(store.cmsSiteEditorBackend.instance);
}
}
);
}
}
}
}
let script = document.createElement("script");
// IF we're in a live environment this will always be 2 levels back
// @todo may want to make this more flexible
script.src = `../../haxcms-jwt`;
fetch(script.src).then(response => {
if (response.status != 404) {
document.documentElement.appendChild(script);
}
});
}
// dynamic import if this isn't published tho we'll double check
// that it's valid later
if (context !== "published") {
const basePath = this.pathFromUrl(decodeURIComponent(import.meta.url));
// import and set the tag based on the context
store.cmsSiteEditorBackend.tag = `haxcms-backend-${context}`;
// delay import slightly to ensure global scope is there
import(`${basePath}backends/${store.cmsSiteEditorBackend.tag}.js`).then(
e => {
if (!store.cmsSiteEditorBackend.instance) {
store.cmsSiteEditorBackend.instance = document.createElement(
store.cmsSiteEditorBackend.tag
);
document.body.append(store.cmsSiteEditorBackend.instance);
}
}
);
}
}
}
}
e => {
if (!store.cmsSiteEditorBackend.instance) {
store.cmsSiteEditorBackend.instance = document.createElement(
store.cmsSiteEditorBackend.tag
);
document.body.append(store.cmsSiteEditorBackend.instance);
}
}
);