Merge branch 'staging' into bg-load-improvements
This commit is contained in:
commit
ef17702f6a
|
@ -20,7 +20,6 @@
|
|||
"cookie-parser": "^1.4.6",
|
||||
"cors": "^2.8.5",
|
||||
"csrf-csrf": "^2.2.3",
|
||||
"device-detector-js": "^3.0.3",
|
||||
"express": "^4.18.2",
|
||||
"form-data": "^4.0.0",
|
||||
"google-translate-api-browser": "^3.0.1",
|
||||
|
@ -1777,14 +1776,6 @@
|
|||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/device-detector-js": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/device-detector-js/-/device-detector-js-3.0.3.tgz",
|
||||
"integrity": "sha512-jM89LJAvP6uOd84at8OlD9dWP8KeYCCHUde0RT0HQo/stdoRH4b54Xl/fntx2nEXCmqiFhmo+/cJetS2VGUHPw==",
|
||||
"engines": {
|
||||
"node": ">= 8.11.4"
|
||||
}
|
||||
},
|
||||
"node_modules/digest-fetch": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/digest-fetch/-/digest-fetch-1.3.0.tgz",
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
"cookie-parser": "^1.4.6",
|
||||
"cors": "^2.8.5",
|
||||
"csrf-csrf": "^2.2.3",
|
||||
"device-detector-js": "^3.0.3",
|
||||
"express": "^4.18.2",
|
||||
"form-data": "^4.0.0",
|
||||
"google-translate-api-browser": "^3.0.1",
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -169,7 +169,6 @@ import {
|
|||
import { EventEmitter } from './lib/eventemitter.js';
|
||||
import { markdownExclusionExt } from './scripts/showdown-exclusion.js';
|
||||
import { NOTE_MODULE_NAME, initAuthorsNote, metadata_keys, setFloatingPrompt, shouldWIAddPrompt } from './scripts/authors-note.js';
|
||||
import { getDeviceInfo } from './scripts/RossAscends-mods.js';
|
||||
import { registerPromptManagerMigration } from './scripts/PromptManager.js';
|
||||
import { getRegexedString, regex_placement } from './scripts/extensions/regex/engine.js';
|
||||
import { FILTER_TYPES, FilterHelper } from './scripts/filters.js';
|
||||
|
@ -6842,8 +6841,7 @@ function openCharacterWorldPopup() {
|
|||
template.find('.character_name').text(name);
|
||||
|
||||
// Not needed on mobile
|
||||
const deviceInfo = getDeviceInfo();
|
||||
if (deviceInfo && deviceInfo.device.type === 'desktop') {
|
||||
if (!isMobile()) {
|
||||
$(extraSelect).select2({
|
||||
width: '100%',
|
||||
placeholder: 'No auxillary Lorebooks set. Click here to select.',
|
||||
|
@ -7820,7 +7818,7 @@ function addDebugFunctions() {
|
|||
|
||||
jQuery(async function () {
|
||||
|
||||
if (isMobile() === true) {
|
||||
if (isMobile()) {
|
||||
console.debug('hiding movingUI and sheldWidth toggles for mobile');
|
||||
$('#sheldWidthToggleBlock').hide();
|
||||
$('#movingUIModeCheckBlock').hide();
|
||||
|
|
|
@ -36,6 +36,7 @@ import { chat_completion_sources, oai_settings } from './openai.js';
|
|||
import { getTokenCount } from './tokenizers.js';
|
||||
import { textgen_types, textgenerationwebui_settings as textgen_settings } from './textgen-settings.js';
|
||||
|
||||
import Bowser from '../lib/bowser.min.js';
|
||||
|
||||
var RPanelPin = document.getElementById('rm_button_panel_pin');
|
||||
var LPanelPin = document.getElementById('lm_button_panel_pin');
|
||||
|
@ -98,43 +99,22 @@ export function humanizeGenTime(total_gen_time) {
|
|||
return time_spent;
|
||||
}
|
||||
|
||||
let parsedUA = null;
|
||||
try {
|
||||
parsedUA = Bowser.parse(navigator.userAgent);
|
||||
} catch {
|
||||
// In case the user agent is an empty string or Bowser can't parse it for some other reason
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the device is a mobile device.
|
||||
* @returns {boolean} - True if the device is a mobile device, false otherwise.
|
||||
*/
|
||||
export function isMobile() {
|
||||
const mobileTypes = ['smartphone', 'tablet', 'phablet', 'feature phone', 'portable media player'];
|
||||
const deviceInfo = getDeviceInfo();
|
||||
const mobileTypes = ['mobile', 'tablet'];
|
||||
|
||||
return mobileTypes.includes(deviceInfo?.device?.type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads device info from the server. Caches the result in sessionStorage.
|
||||
* @returns {object} - The device info object.
|
||||
*/
|
||||
export function getDeviceInfo() {
|
||||
let deviceInfo = null;
|
||||
|
||||
if (sessionStorage.getItem('deviceInfo')) {
|
||||
deviceInfo = JSON.parse(sessionStorage.getItem('deviceInfo'));
|
||||
} else {
|
||||
$.ajax({
|
||||
url: '/deviceinfo',
|
||||
dataType: 'json',
|
||||
async: false,
|
||||
cache: true,
|
||||
success: function (result) {
|
||||
sessionStorage.setItem('deviceInfo', JSON.stringify(result));
|
||||
deviceInfo = result;
|
||||
},
|
||||
error: function () {
|
||||
console.log('Couldn\'t load device info. Defaulting to desktop');
|
||||
deviceInfo = { device: { type: 'desktop' } };
|
||||
},
|
||||
});
|
||||
}
|
||||
return deviceInfo;
|
||||
return mobileTypes.includes(parsedUA?.platform?.type);
|
||||
}
|
||||
|
||||
function shouldSendOnEnter() {
|
||||
|
@ -431,8 +411,7 @@ function RA_autoconnect(PrevApi) {
|
|||
}
|
||||
|
||||
function OpenNavPanels() {
|
||||
const deviceInfo = getDeviceInfo();
|
||||
if (deviceInfo && deviceInfo.device.type === 'desktop') {
|
||||
if (!isMobile()) {
|
||||
//auto-open R nav if locked and previously open
|
||||
if (LoadLocalBool('NavLockOn') == true && LoadLocalBool('NavOpened') == true) {
|
||||
//console.log("RA -- clicking right nav to open");
|
||||
|
@ -508,7 +487,7 @@ export function dragElement(elmnt) {
|
|||
|| Number((String(target.height).replace('px', ''))) < 50
|
||||
|| Number((String(target.width).replace('px', ''))) < 50
|
||||
|| power_user.movingUI === false
|
||||
|| isMobile() === true
|
||||
|| isMobile()
|
||||
) {
|
||||
console.debug('aborting mutator');
|
||||
return;
|
||||
|
@ -716,7 +695,7 @@ export function dragElement(elmnt) {
|
|||
}
|
||||
|
||||
export async function initMovingUI() {
|
||||
if (isMobile() === false && power_user.movingUI === true) {
|
||||
if (!isMobile() && power_user.movingUI === true) {
|
||||
console.debug('START MOVING UI');
|
||||
dragElement($('#sheld'));
|
||||
dragElement($('#left-nav-panel'));
|
||||
|
|
|
@ -9,7 +9,7 @@ import {
|
|||
} from '../script.js';
|
||||
import { SECRET_KEYS, writeSecret } from './secrets.js';
|
||||
import { delay } from './utils.js';
|
||||
import { getDeviceInfo } from './RossAscends-mods.js';
|
||||
import { isMobile } from './RossAscends-mods.js';
|
||||
import { autoSelectInstructPreset } from './instruct-mode.js';
|
||||
|
||||
export {
|
||||
|
@ -303,8 +303,7 @@ jQuery(function () {
|
|||
$('#horde_kudos').on('click', showKudos);
|
||||
|
||||
// Not needed on mobile
|
||||
const deviceInfo = getDeviceInfo();
|
||||
if (deviceInfo && deviceInfo.device.type === 'desktop') {
|
||||
if (!isMobile()) {
|
||||
$('#horde_model').select2({
|
||||
width: '100%',
|
||||
placeholder: 'Select Horde models',
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { setGenerationParamsFromPreset } from '../script.js';
|
||||
import { getDeviceInfo } from './RossAscends-mods.js';
|
||||
import { isMobile } from './RossAscends-mods.js';
|
||||
import { textgenerationwebui_settings as textgen_settings } from './textgen-settings.js';
|
||||
|
||||
let models = [];
|
||||
|
@ -52,8 +52,7 @@ function getMancerModelTemplate(option) {
|
|||
jQuery(function () {
|
||||
$('#mancer_model').on('change', onMancerModelSelect);
|
||||
|
||||
const deviceInfo = getDeviceInfo();
|
||||
if (deviceInfo && deviceInfo.device.type === 'desktop') {
|
||||
if (!isMobile()) {
|
||||
$('#mancer_model').select2({
|
||||
placeholder: 'Select a model',
|
||||
searchInputPlaceholder: 'Search models...',
|
||||
|
|
|
@ -1530,7 +1530,7 @@ async function loadCharListState() {
|
|||
}
|
||||
|
||||
function loadMovingUIState() {
|
||||
if (isMobile() === false
|
||||
if (!isMobile()
|
||||
&& power_user.movingUIState
|
||||
&& power_user.movingUI === true) {
|
||||
console.debug('loading movingUI state');
|
||||
|
|
|
@ -637,9 +637,19 @@ function lenValuesCallback(value) {
|
|||
return parsedValue.length;
|
||||
}
|
||||
|
||||
function randValuesCallback(from, to) {
|
||||
function randValuesCallback(from, to, args) {
|
||||
const range = to - from;
|
||||
return from + Math.random() * range;
|
||||
const value = from + Math.random() * range;
|
||||
if (args.round == 'round') {
|
||||
return Math.round(value);
|
||||
}
|
||||
if (args.round == 'ceil') {
|
||||
return Math.ceil(value);
|
||||
}
|
||||
if (args.round == 'floor') {
|
||||
return Math.floor(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
export function registerVariableCommands() {
|
||||
|
@ -673,5 +683,5 @@ export function registerVariableCommands() {
|
|||
registerSlashCommand('sqrt', (_, value) => sqrtValuesCallback(value), [], '<span class="monospace">(a)</span> – performs a square root operation of a value and passes the result down the pipe, can use variable names, e.g. <tt>/sqrt i</tt>', true, true);
|
||||
registerSlashCommand('round', (_, value) => roundValuesCallback(value), [], '<span class="monospace">(a)</span> – rounds a value and passes the result down the pipe, can use variable names, e.g. <tt>/round i</tt>', true, true);
|
||||
registerSlashCommand('len', (_, value) => lenValuesCallback(value), [], '<span class="monospace">(a)</span> – gets the length of a value and passes the result down the pipe, can use variable names, e.g. <tt>/len i</tt>', true, true);
|
||||
registerSlashCommand('rand', (args, value) => randValuesCallback(Number(args.from ?? 0), Number(args.to ?? (value.length ? value : 1))), [], '<span class="monospace">(from=number=0 to=number=1)</span> – returns a random number between from and to, e.g. <tt>/rand</tt> or <tt>/rand 10</tt> or <tt>/rand from=5 to=10</tt>', true, true);
|
||||
registerSlashCommand('rand', (args, value) => randValuesCallback(Number(args.from ?? 0), Number(args.to ?? (value.length ? value : 1)), args), [], '<span class="monospace">(from=number=0 to=number=1 round=round|ceil|floor)</span> – returns a random number between from and to, e.g. <tt>/rand</tt> or <tt>/rand 10</tt> or <tt>/rand from=5 to=10</tt>', true, true);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import { download, debounce, initScrollHeight, resetScrollHeight, parseJsonFile,
|
|||
import { extension_settings, getContext } from './extensions.js';
|
||||
import { NOTE_MODULE_NAME, metadata_keys, shouldWIAddPrompt } from './authors-note.js';
|
||||
import { registerSlashCommand } from './slash-commands.js';
|
||||
import { getDeviceInfo } from './RossAscends-mods.js';
|
||||
import { isMobile } from './RossAscends-mods.js';
|
||||
import { FILTER_TYPES, FilterHelper } from './filters.js';
|
||||
import { getTokenCount } from './tokenizers.js';
|
||||
import { power_user } from './power-user.js';
|
||||
|
@ -896,8 +896,8 @@ function getWorldEntry(name, data, entry) {
|
|||
|
||||
const characterFilter = template.find('select[name="characterFilter"]');
|
||||
characterFilter.data('uid', entry.uid);
|
||||
const deviceInfo = getDeviceInfo();
|
||||
if (deviceInfo && deviceInfo.device.type === 'desktop') {
|
||||
|
||||
if (!isMobile()) {
|
||||
$(characterFilter).select2({
|
||||
width: '100%',
|
||||
placeholder: 'All characters will pull from this entry.',
|
||||
|
@ -2551,8 +2551,7 @@ jQuery(() => {
|
|||
$(document).on('click', '.chat_lorebook_button', assignLorebookToChat);
|
||||
|
||||
// Not needed on mobile
|
||||
const deviceInfo = getDeviceInfo();
|
||||
if (deviceInfo && deviceInfo.device.type === 'desktop') {
|
||||
if (!isMobile()) {
|
||||
$('#world_info').select2({
|
||||
width: '100%',
|
||||
placeholder: 'No Worlds active. Click here to select.',
|
||||
|
|
|
@ -27,7 +27,6 @@ const responseTime = require('response-time');
|
|||
// net related library imports
|
||||
const net = require('net');
|
||||
const dns = require('dns');
|
||||
const DeviceDetector = require('device-detector-js');
|
||||
const fetch = require('node-fetch').default;
|
||||
const ipaddr = require('ipaddr.js');
|
||||
const ipMatching = require('ip-matching');
|
||||
|
@ -288,12 +287,6 @@ app.use(multer({ dest: UPLOADS_PATH, limits: { fieldSize: 10 * 1024 * 1024 } }).
|
|||
app.get('/', function (request, response) {
|
||||
response.sendFile(process.cwd() + '/public/index.html');
|
||||
});
|
||||
app.get('/deviceinfo', function (request, response) {
|
||||
const userAgent = request.header('user-agent');
|
||||
const deviceDetector = new DeviceDetector();
|
||||
const deviceInfo = deviceDetector.parse(userAgent || '');
|
||||
return response.send(deviceInfo);
|
||||
});
|
||||
app.get('/version', async function (_, response) {
|
||||
const data = await getVersion();
|
||||
response.send(data);
|
||||
|
|
Loading…
Reference in New Issue