Files
SillyTavern/public/lib.js
T
Roland4396 1c5091539c feat: optionally gzip large save uploads with fallback (#5259)
* feat: optionally gzip large save uploads with fallback

* fix: replace Safari-prone save compression with fflate fallback

* refactor: align save upload compression with review feedback

* refactor: use compressRequest wrapper for save uploads

* Refactor request compression settings

* Fix default value

* Avoid null in bytes parsing result

* fix: switch request compression to fflate gzip

* fix: add request compression maxBytes cap and clarify timeout semantics

* Refresh package-lock.json

* Unify payload limit setting names

* Expose compression termination function

* Add compression to group chat saves

---------

Co-authored-by: Roland4396 <Roland4396@users.noreply.github.com>
Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2026-03-10 23:32:36 +02:00

136 lines
3.0 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 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';
import seedrandom from 'seedrandom';
import * as Popper from '@popperjs/core';
import droll from 'droll';
import morphdom from 'morphdom';
import { toggle as slideToggle } from 'slidetoggle';
import chalk from 'chalk';
import yaml from 'yaml';
import * as chevrotain from 'chevrotain';
import { gzipSync, gzip } from 'fflate';
/**
* 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;
}
if (!('Popper' in window)) {
// @ts-ignore
window.Popper = Popper;
}
if (!('droll' in window)) {
// @ts-ignore
window.droll = droll;
}
}
export default {
lodash,
Fuse,
DOMPurify,
hljs,
localforage,
Handlebars,
css,
Bowser,
DiffMatchPatch,
Readability,
isProbablyReaderable,
SVGInject,
showdown,
moment,
seedrandom,
Popper,
droll,
morphdom,
slideToggle,
chalk,
yaml,
chevrotain,
gzipSync,
gzip,
};
export {
lodash,
Fuse,
DOMPurify,
hljs,
localforage,
Handlebars,
css,
Bowser,
DiffMatchPatch,
Readability,
isProbablyReaderable,
SVGInject,
showdown,
moment,
seedrandom,
Popper,
droll,
morphdom,
slideToggle,
chalk,
yaml,
chevrotain,
gzipSync,
gzip,
};