unvendor: Replace DOMPurify

This commit is contained in:
Cohee
2024-10-16 23:11:13 +03:00
parent e6d8f0a33e
commit 3387fe4bd6
20 changed files with 67 additions and 31 deletions

View File

@ -3,7 +3,33 @@
* They are bundled and exposed by Webpack in the /lib.js file.
*/
import Fuse from 'fuse.js';
import DOMPurify from 'dompurify';
/**
* Expose the libraries to the 'window' object.
* Needed for compatibility with old extensions.
* Note: New extensions are encouraged to import the libraries directly from lib.js.
*/
export function initLibraryShims() {
if (!window) {
return;
}
if (!('Fuse' in window)) {
// @ts-ignore
window.Fuse = Fuse;
}
if (!('DOMPurify' in window)) {
// @ts-ignore
window.DOMPurify = DOMPurify;
}
}
export default {
Fuse,
DOMPurify,
};
export {
Fuse,
DOMPurify,
};