unvendor: Replace localforage
| @@ -52,7 +52,6 @@ module.exports = { | ||
| 52 | 52 | globals: { |
| 53 | 53 | droll: 'readonly', |
| 54 | 54 | Handlebars: 'readonly', |
| 55 | - localforage: 'readonly', | |
| 56 | 55 | moment: 'readonly', |
| 57 | 56 | pdfjsLib: 'readonly', |
| 58 | 57 | Popper: 'readonly', |
| @@ -34,6 +34,7 @@ | ||
| 34 | 34 | "ip-matching": "^2.1.2", |
| 35 | 35 | "ipaddr.js": "^2.0.1", |
| 36 | 36 | "jimp": "^0.22.10", |
| 37 | + "localforage": "^1.10.0", | |
| 37 | 38 | "lodash": "^4.17.21", |
| 38 | 39 | "mime-types": "^2.1.35", |
| 39 | 40 | "multer": "^1.4.5-lts.1", |
| @@ -4504,6 +4505,12 @@ | ||
| 4504 | 4505 | "integrity": "sha512-QpLcX9ZSsq3YYUUnD3nFDY8H7wctAhQj/TFKL8Ya8v5fMm3CFXxo8zStsLAl780ltoYoo1WvKUVGBQK+1ifr7g==", |
| 4505 | 4506 | "license": "MIT" |
| 4506 | 4507 | }, |
| 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 | + }, | |
| 4507 | 4514 | "node_modules/import-fresh": { |
| 4508 | 4515 | "version": "3.3.0", |
| 4509 | 4516 | "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", |
| @@ -4946,6 +4953,15 @@ | ||
| 4946 | 4953 | "node": ">= 0.8.0" |
| 4947 | 4954 | } |
| 4948 | 4955 | }, |
| 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 | + }, | |
| 4949 | 4965 | "node_modules/load-bmfont": { |
| 4950 | 4966 | "version": "1.4.2", |
| 4951 | 4967 | "resolved": "https://registry.npmjs.org/load-bmfont/-/load-bmfont-1.4.2.tgz", |
| @@ -4971,6 +4987,15 @@ | ||
| 4971 | 4987 | "node": ">=6.11.5" |
| 4972 | 4988 | } |
| 4973 | 4989 | }, |
| 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 | + }, | |
| 4974 | 4999 | "node_modules/locate-path": { |
| 4975 | 5000 | "version": "6.0.0", |
| 4976 | 5001 | "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", |
| @@ -24,6 +24,7 @@ | ||
| 24 | 24 | "ip-matching": "^2.1.2", |
| 25 | 25 | "ipaddr.js": "^2.0.1", |
| 26 | 26 | "jimp": "^0.22.10", |
| 27 | + "localforage": "^1.10.0", | |
| 27 | 28 | "lodash": "^4.17.21", |
| 28 | 29 | "mime-types": "^2.1.35", |
| 29 | 30 | "multer": "^1.4.5-lts.1", |
| @@ -1,7 +1,6 @@ | ||
| 1 | 1 | // Global namespace modules |
| 2 | 2 | declare var droll; |
| 3 | 3 | declare var Handlebars; |
| 4 | -declare var localforage; | |
| 5 | 4 | declare var pdfjsLib; |
| 6 | 5 | declare var Popper; |
| 7 | 6 | declare var showdown; |
| @@ -6758,7 +6758,6 @@ | ||
| 6758 | 6758 | <script src="lib/select2-search-placeholder.js"></script> |
| 6759 | 6759 | <script src="lib/seedrandom.min.js"></script> |
| 6760 | 6760 | <script src="lib/droll.js"></script> |
| 6761 | - <script src="lib/localforage.min.js"></script> | |
| 6762 | 6761 | <script src="lib/handlebars.js"></script> |
| 6763 | 6762 | <script src="lib/pagination.js"></script> |
| 6764 | 6763 | <script src="lib/toolcool-color-picker.js"></script> |
| @@ -24,7 +24,6 @@ | ||
| 24 | 24 | "droll", |
| 25 | 25 | "handlebars", |
| 26 | 26 | "highlight.js", |
| 27 | - "localforage", | |
| 28 | 27 | "pdfjs-dist", |
| 29 | 28 | "@mozilla/readability" |
| 30 | 29 | ] |
| @@ -5,6 +5,7 @@ | ||
| 5 | 5 | import Fuse from 'fuse.js'; |
| 6 | 6 | import DOMPurify from 'dompurify'; |
| 7 | 7 | import hljs from 'highlight.js'; |
| 8 | +import localforage from 'localforage'; | |
| 8 | 9 | |
| 9 | 10 | /** |
| 10 | 11 | * Expose the libraries to the 'window' object. |
| @@ -27,16 +28,22 @@ export function initLibraryShims() { | ||
| 27 | 28 | // @ts-ignore |
| 28 | 29 | window.hljs = hljs; |
| 29 | 30 | } |
| 31 | + if (!('localforage' in window)) { | |
| 32 | + // @ts-ignore | |
| 33 | + window.localforage = localforage; | |
| 34 | + } | |
| 30 | 35 | } |
| 31 | 36 | |
| 32 | 37 | export default { |
| 33 | 38 | Fuse, |
| 34 | 39 | DOMPurify, |
| 35 | 40 | hljs, |
| 41 | + localforage, | |
| 36 | 42 | }; |
| 37 | 43 | |
| 38 | 44 | export { |
| 39 | 45 | Fuse, |
| 40 | 46 | DOMPurify, |
| 41 | 47 | hljs, |
| 48 | + localforage, | |
| 42 | 49 | }; |
| @@ -2,6 +2,7 @@ import { | ||
| 2 | 2 | Fuse, |
| 3 | 3 | DOMPurify, |
| 4 | 4 | hljs, |
| 5 | + localforage, | |
| 5 | 6 | initLibraryShims, |
| 6 | 7 | default as libs, |
| 7 | 8 | } from './lib.js'; |
| @@ -503,7 +504,7 @@ reloadMarkdownProcessor(); | ||
| 503 | 504 | |
| 504 | 505 | // array for prompt token calculations |
| 505 | 506 | console.debug('initializing Prompt Itemization Array on Startup'); |
| 506 | 507 | const promptStorage = new localforage.createInstance({ name: 'SillyTavern_Prompts' }); |
| 507 | 508 | export let itemizedPrompts = []; |
| 508 | 509 | |
| 509 | 510 | export const systemUserName = 'SillyTavern System'; |
| @@ -1,3 +1,4 @@ | ||
| 1 | +import { localforage } from '../lib.js'; | |
| 1 | 2 | import { characters, main_api, api_server, nai_settings, online_status, this_chid } from '../script.js'; |
| 2 | 3 | import { power_user, registerDebugFunction } from './power-user.js'; |
| 3 | 4 | import { chat_completion_sources, model_list, oai_settings } from './openai.js'; |
| @@ -135,7 +136,7 @@ const TOKENIZER_URLS = { | ||
| 135 | 136 | }, |
| 136 | 137 | }; |
| 137 | 138 | |
| 138 | 139 | const objectStore = new localforage.createInstance({ name: 'SillyTavern_ChatCompletions' }); |
| 139 | 140 | |
| 140 | 141 | let tokenCache = {}; |
| 141 | 142 | |