unvendor: Replace localforage

1c4e87b25b54cc83ae12dcdf6b359889f9931d3e

Cohee <18619528+Cohee1207@users.noreply.github.com>

9 files changed, +37 -6Showing whitespace changes
.eslintrc.cjs+0 -1
@@ -52,7 +52,6 @@ module.exports = {
5252 globals: {
5353 droll: 'readonly',
5454 Handlebars: 'readonly',
55- localforage: 'readonly',
5655 moment: 'readonly',
5756 pdfjsLib: 'readonly',
5857 Popper: 'readonly',
package-lock.json+25 -0
@@ -34,6 +34,7 @@
3434 "ip-matching": "^2.1.2",
3535 "ipaddr.js": "^2.0.1",
3636 "jimp": "^0.22.10",
37+ "localforage": "^1.10.0",
3738 "lodash": "^4.17.21",
3839 "mime-types": "^2.1.35",
3940 "multer": "^1.4.5-lts.1",
@@ -4504,6 +4505,12 @@
45044505 "integrity": "sha512-QpLcX9ZSsq3YYUUnD3nFDY8H7wctAhQj/TFKL8Ya8v5fMm3CFXxo8zStsLAl780ltoYoo1WvKUVGBQK+1ifr7g==",
45054506 "license": "MIT"
45064507 },
4508+ "node_modules/immediate": {
4509+ "version": "3.0.6",
4510+ "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz",
4511+ "integrity": "sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==",
4512+ "license": "MIT"
4513+ },
45074514 "node_modules/import-fresh": {
45084515 "version": "3.3.0",
45094516 "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz",
@@ -4946,6 +4953,15 @@
49464953 "node": ">= 0.8.0"
49474954 }
49484955 },
4956+ "node_modules/lie": {
4957+ "version": "3.1.1",
4958+ "resolved": "https://registry.npmjs.org/lie/-/lie-3.1.1.tgz",
4959+ "integrity": "sha512-RiNhHysUjhrDQntfYSfY4MU24coXXdEOgw9WGcKHNeEwffDYbF//u87M1EWaMGzuFoSbqW0C9C6lEEhDOAswfw==",
4960+ "license": "MIT",
4961+ "dependencies": {
4962+ "immediate": "~3.0.5"
4963+ }
4964+ },
49494965 "node_modules/load-bmfont": {
49504966 "version": "1.4.2",
49514967 "resolved": "https://registry.npmjs.org/load-bmfont/-/load-bmfont-1.4.2.tgz",
@@ -4971,6 +4987,15 @@
49714987 "node": ">=6.11.5"
49724988 }
49734989 },
4990+ "node_modules/localforage": {
4991+ "version": "1.10.0",
4992+ "resolved": "https://registry.npmjs.org/localforage/-/localforage-1.10.0.tgz",
4993+ "integrity": "sha512-14/H1aX7hzBBmmh7sGPd+AOMkkIrHM3Z1PAyGgZigA1H1p5O5ANnMyWzvpAETtG68/dC4pC0ncy3+PPGzXZHPg==",
4994+ "license": "Apache-2.0",
4995+ "dependencies": {
4996+ "lie": "3.1.1"
4997+ }
4998+ },
49744999 "node_modules/locate-path": {
49755000 "version": "6.0.0",
49765001 "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz",
package.json+1 -0
@@ -24,6 +24,7 @@
2424 "ip-matching": "^2.1.2",
2525 "ipaddr.js": "^2.0.1",
2626 "jimp": "^0.22.10",
27+ "localforage": "^1.10.0",
2728 "lodash": "^4.17.21",
2829 "mime-types": "^2.1.35",
2930 "multer": "^1.4.5-lts.1",
public/global.d.ts+0 -1
@@ -1,7 +1,6 @@
11// Global namespace modules
22declare var droll;
33declare var Handlebars;
4-declare var localforage;
54declare var pdfjsLib;
65declare var Popper;
76declare var showdown;
public/index.html+0 -1
@@ -6758,7 +6758,6 @@
67586758 <script src="lib/select2-search-placeholder.js"></script>
67596759 <script src="lib/seedrandom.min.js"></script>
67606760 <script src="lib/droll.js"></script>
6761- <script src="lib/localforage.min.js"></script>
67626761 <script src="lib/handlebars.js"></script>
67636762 <script src="lib/pagination.js"></script>
67646763 <script src="lib/toolcool-color-picker.js"></script>
public/jsconfig.json+0 -1
@@ -24,7 +24,6 @@
2424 "droll",
2525 "handlebars",
2626 "highlight.js",
27- "localforage",
2827 "pdfjs-dist",
2928 "@mozilla/readability"
3029 ]
public/lib.js+7 -0
@@ -5,6 +5,7 @@
55import Fuse from 'fuse.js';
66import DOMPurify from 'dompurify';
77import hljs from 'highlight.js';
8+import localforage from 'localforage';
89
910/**
1011 * Expose the libraries to the 'window' object.
@@ -27,16 +28,22 @@ export function initLibraryShims() {
2728 // @ts-ignore
2829 window.hljs = hljs;
2930 }
31+ if (!('localforage' in window)) {
32+ // @ts-ignore
33+ window.localforage = localforage;
34+ }
3035}
3136
3237export default {
3338 Fuse,
3439 DOMPurify,
3540 hljs,
41+ localforage,
3642};
3743
3844export {
3945 Fuse,
4046 DOMPurify,
4147 hljs,
48+ localforage,
4249};
public/script.js+2 -1
@@ -2,6 +2,7 @@ import {
22 Fuse,
33 DOMPurify,
44 hljs,
5+ localforage,
56 initLibraryShims,
67 default as libs,
78} from './lib.js';
@@ -503,7 +504,7 @@ reloadMarkdownProcessor();
503504
504505// array for prompt token calculations
505506console.debug('initializing Prompt Itemization Array on Startup');
506507const promptStorage = new localforage.createInstance({ name: 'SillyTavern_Prompts' });
507508export let itemizedPrompts = [];
508509
509510export const systemUserName = 'SillyTavern System';
public/scripts/tokenizers.js+2 -1
@@ -1,3 +1,4 @@
1+import { localforage } from '../lib.js';
12import { characters, main_api, api_server, nai_settings, online_status, this_chid } from '../script.js';
23import { power_user, registerDebugFunction } from './power-user.js';
34import { chat_completion_sources, model_list, oai_settings } from './openai.js';
@@ -135,7 +136,7 @@ const TOKENIZER_URLS = {
135136 },
136137};
137138
138139const objectStore = new localforage.createInstance({ name: 'SillyTavern_ChatCompletions' });
139140
140141let tokenCache = {};
141142