unvendor: Replace seedrandom

e1694ede9df77b0b40780e0052a3d9ec9c0f7537

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

8 files changed, +15 -8Ignore whitespace
package-lock.json+7 -0
@@ -57,6 +57,7 @@
5757 "rate-limiter-flexible": "^5.0.0",
5858 "response-time": "^2.3.2",
5959 "sanitize-filename": "^1.6.3",
60+ "seedrandom": "^3.0.5",
6061 "showdown": "^2.1.0",
6162 "sillytavern-transformers": "2.14.6",
6263 "simple-git": "^3.19.1",
@@ -7015,6 +7016,12 @@
70157016 "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==",
70167017 "license": "MIT"
70177018 },
7019+ "node_modules/seedrandom": {
7020+ "version": "3.0.5",
7021+ "resolved": "https://registry.npmjs.org/seedrandom/-/seedrandom-3.0.5.tgz",
7022+ "integrity": "sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg==",
7023+ "license": "MIT"
7024+ },
70187025 "node_modules/semver": {
70197026 "version": "7.6.3",
70207027 "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz",
package.json+1 -0
@@ -47,6 +47,7 @@
4747 "rate-limiter-flexible": "^5.0.0",
4848 "response-time": "^2.3.2",
4949 "sanitize-filename": "^1.6.3",
50+ "seedrandom": "^3.0.5",
5051 "showdown": "^2.1.0",
5152 "sillytavern-transformers": "2.14.6",
5253 "simple-git": "^3.19.1",
public/index.html+0 -1
@@ -6752,7 +6752,6 @@
67526752 <script src="lib/toastr.min.js"></script>
67536753 <script src="lib/select2.min.js"></script>
67546754 <script src="lib/select2-search-placeholder.js"></script>
6755- <script src="lib/seedrandom.min.js"></script>
67566755 <script src="lib/droll.js"></script>
67576756 <script src="lib/pagination.js"></script>
67586757 <script src="lib/toolcool-color-picker.js"></script>
public/jsconfig.json+0 -1
@@ -18,7 +18,6 @@
1818 "typeAcquisition": {
1919 "include": [
2020 "@popperjs/core",
21- "seedrandom",
2221 "showdown-katex",
2322 "droll"
2423 ]
public/lib.js+3 -0
@@ -17,6 +17,7 @@ import { isProbablyReaderable, Readability } from '@mozilla/readability';
1717import SVGInject from '@iconfu/svg-inject';
1818import showdown from 'showdown';
1919import moment from 'moment';
20+import seedrandom from 'seedrandom';
2021
2122/**
2223 * Expose the libraries to the 'window' object.
@@ -82,6 +83,7 @@ export default {
8283 SVGInject,
8384 showdown,
8485 moment,
86+ seedrandom,
8587};
8688
8789export {
@@ -101,4 +103,5 @@ export {
101103 SVGInject,
102104 showdown,
103105 moment,
106+ seedrandom,
104107};
public/lib/seedrandom.min.js+0 -1
@@ -1 +0,0 @@
1-!function(f,a,c){var s,l=256,p="random",d=c.pow(l,6),g=c.pow(2,52),y=2*g,h=l-1;function n(n,t,r){function e(){for(var n=u.g(6),t=d,r=0;n<g;)n=(n+r)*l,t*=l,r=u.g(1);for(;y<=n;)n/=2,t/=2,r>>>=1;return(n+r)/t}var o=[],i=j(function n(t,r){var e,o=[],i=typeof t;if(r&&"object"==i)for(e in t)try{o.push(n(t[e],r-1))}catch(n){}return o.length?o:"string"==i?t:t+"\0"}((t=1==t?{entropy:!0}:t||{}).entropy?[n,S(a)]:null==n?function(){try{var n;return s&&(n=s.randomBytes)?n=n(l):(n=new Uint8Array(l),(f.crypto||f.msCrypto).getRandomValues(n)),S(n)}catch(n){var t=f.navigator,r=t&&t.plugins;return[+new Date,f,r,f.screen,S(a)]}}():n,3),o),u=new m(o);return e.int32=function(){return 0|u.g(4)},e.quick=function(){return u.g(4)/4294967296},e.double=e,j(S(u.S),a),(t.pass||r||function(n,t,r,e){return e&&(e.S&&v(e,u),n.state=function(){return v(u,{})}),r?(c[p]=n,t):n})(e,i,"global"in t?t.global:this==c,t.state)}function m(n){var t,r=n.length,u=this,e=0,o=u.i=u.j=0,i=u.S=[];for(r||(n=[r++]);e<l;)i[e]=e++;for(e=0;e<l;e++)i[e]=i[o=h&o+n[e%r]+(t=i[e])],i[o]=t;(u.g=function(n){for(var t,r=0,e=u.i,o=u.j,i=u.S;n--;)t=i[e=h&e+1],r=r*l+i[h&(i[e]=i[o=h&o+t])+(i[o]=t)];return u.i=e,u.j=o,r})(l)}function v(n,t){return t.i=n.i,t.j=n.j,t.S=n.S.slice(),t}function j(n,t){for(var r,e=n+"",o=0;o<e.length;)t[h&o]=h&(r^=19*t[h&o])+e.charCodeAt(o++);return S(t)}function S(n){return String.fromCharCode.apply(0,n)}if(j(c.random(),a),"object"==typeof module&&module.exports){module.exports=n;try{s=require("crypto")}catch(n){}}else"function"==typeof define&&define.amd?define(function(){return n}):c["seed"+p]=n}("undefined"!=typeof self?self:this,[],Math);
1 \ No newline at end of file
public/lib/showdown-toc.min.js+0 -1
@@ -1 +0,0 @@
1-!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).showdownToc=t()}(this,(function(){"use strict";function e(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function t(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}return function(){var r=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).toc;return function(){return[{type:"output",filter:function(n){var o=[];n.replace(/(<h([1-6]).*?id="([^"]*?)".*?>(.+?)<\/h[1-6]>)|(<p>\[toc\]<\/p>)/g,(function(n,c,u,i,p){if("<p>[toc]</p>"===n)o.push({type:"toc"});else{p=p.replace(/<[^>]+>/g,"");var f={anchor:i,level:Number(u),text:p};r&&r.push(f),o.push(function(r){for(var n=1;arguments.length>n;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?t(o,!0).forEach((function(t){e(r,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):t(o).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}))}return r}({type:"header"},f))}return""}));var c=[];return o.forEach((function(e,t){if("toc"===e.type)if(o[t+1]&&"header"===o[t+1].type){for(var r=[],n=o[t+1].level,u=t+1;o.length>u&&"toc"!==o[u].type;u++){o[u].level===n&&r.push(o[u])}c.push(r)}else c.push([])})),n=n.replace(/<p>\[toc\]<\/p>[\n]*/g,(function(){var e=c.shift();return e&&e.length?"<ol>".concat(e.map((function(e){var t=e.text;return'<li><a href="#'.concat(e.anchor,'">').concat(t,"</a></li>")})).join(""),"</ol>\n"):""}))}}]}}}));
public/scripts/macros.js+4 -4
@@ -1,4 +1,4 @@
11import { Handlebars, moment, seedrandom } from '../lib.js';
22import { chat, chat_metadata, main_api, getMaxContextSize, getCurrentChatId, substituteParams } from '../script.js';
33import { timestampToMoment, isDigitsOnly, getStringHash, escapeRegex, uuidv4 } from './utils.js';
44import { textgenerationwebui_banned_in_macros } from './textgen-settings.js';
@@ -330,7 +330,7 @@ function randomReplace(input, emptyListPlaceholder = '') {
330330 if (list.length === 0) {
331331 return emptyListPlaceholder;
332332 }
333333 const rng = new Math.seedrandom('added entropy.', { entropy: true });
334334 const randomIndex = Math.floor(rng() * list.length);
335335 return list[randomIndex];
336336 });
@@ -359,8 +359,8 @@ function pickReplace(input, rawContent, emptyListPlaceholder = '') {
359359 // We build a hash seed based on: unique chat file, raw content, and the placement inside this content
360360 // This allows us to get unique but repeatable picks in nearly all cases
361361 const combinedSeedString = `${chatIdHash}-${rawContentHash}-${offset}`;
362362 const finalSeed = getStringHash(combinedSeedString).toString();
363363 const rng = new Math.seedrandom(finalSeed);
364364 const randomIndex = Math.floor(rng() * list.length);
365365 return list[randomIndex];
366366 });