mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2024-12-12 17:36:22 +01:00
105 lines
2.3 KiB
JavaScript
105 lines
2.3 KiB
JavaScript
/**
|
|
* Add all the libraries that you want to expose to the client here.
|
|
* They are bundled and exposed by Webpack in the /lib.js file.
|
|
*/
|
|
import lodash from 'lodash';
|
|
import Fuse from 'fuse.js';
|
|
import DOMPurify from 'dompurify';
|
|
import hljs from 'highlight.js';
|
|
import localforage from 'localforage';
|
|
import Handlebars from 'handlebars';
|
|
import css from '@adobe/css-tools';
|
|
import Bowser from 'bowser';
|
|
import ePub from 'epubjs';
|
|
import * as pdfjsLib from 'pdfjs-dist/webpack.mjs';
|
|
import DiffMatchPatch from 'diff-match-patch';
|
|
import { isProbablyReaderable, Readability } from '@mozilla/readability';
|
|
import SVGInject from '@iconfu/svg-inject';
|
|
import showdown from 'showdown';
|
|
import moment from 'moment';
|
|
|
|
/**
|
|
* 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;
|
|
}
|
|
if (!('hljs' in window)) {
|
|
// @ts-ignore
|
|
window.hljs = hljs;
|
|
}
|
|
if (!('localforage' in window)) {
|
|
// @ts-ignore
|
|
window.localforage = localforage;
|
|
}
|
|
if (!('Handlebars' in window)) {
|
|
// @ts-ignore
|
|
window.Handlebars = Handlebars;
|
|
}
|
|
if (!('diff_match_patch' in window)) {
|
|
// @ts-ignore
|
|
window.diff_match_patch = DiffMatchPatch;
|
|
}
|
|
if (!('SVGInject' in window)) {
|
|
// @ts-ignore
|
|
window.SVGInject = SVGInject;
|
|
}
|
|
if (!('showdown' in window)) {
|
|
// @ts-ignore
|
|
window.showdown = showdown;
|
|
}
|
|
if (!('moment' in window)) {
|
|
// @ts-ignore
|
|
window.moment = moment;
|
|
}
|
|
}
|
|
|
|
export default {
|
|
lodash,
|
|
Fuse,
|
|
DOMPurify,
|
|
hljs,
|
|
localforage,
|
|
Handlebars,
|
|
css,
|
|
Bowser,
|
|
ePub,
|
|
pdfjsLib,
|
|
DiffMatchPatch,
|
|
Readability,
|
|
isProbablyReaderable,
|
|
SVGInject,
|
|
showdown,
|
|
moment,
|
|
};
|
|
|
|
export {
|
|
lodash,
|
|
Fuse,
|
|
DOMPurify,
|
|
hljs,
|
|
localforage,
|
|
Handlebars,
|
|
css,
|
|
Bowser,
|
|
ePub,
|
|
pdfjsLib,
|
|
DiffMatchPatch,
|
|
Readability,
|
|
isProbablyReaderable,
|
|
SVGInject,
|
|
showdown,
|
|
moment,
|
|
};
|