unvendor: Replace moment

This commit is contained in:
Cohee
2024-10-17 02:02:45 +03:00
parent 7b0f7306c0
commit 81bdeb6da8
15 changed files with 33 additions and 804 deletions

View File

@ -1,3 +1,4 @@
import { moment } from '../lib.js';
import { registerDebugFunction } from './power-user.js';
import { updateSecretDisplay } from './secrets.js';

View File

@ -1,4 +1,4 @@
import { Handlebars } from '../lib.js';
import { Handlebars, moment } from '../lib.js';
import { chat, chat_metadata, main_api, getMaxContextSize, getCurrentChatId, substituteParams } from '../script.js';
import { timestampToMoment, isDigitsOnly, getStringHash, escapeRegex, uuidv4 } from './utils.js';
import { textgenerationwebui_banned_in_macros } from './textgen-settings.js';

View File

@ -1,4 +1,5 @@
// statsHelper.js
import { moment } from '../lib.js';
import { getRequestHeaders, callPopup, characters, this_chid } from '../script.js';
import { humanizeGenTime } from './RossAscends-mods.js';
import { registerDebugFunction } from './power-user.js';

View File

@ -1,4 +1,11 @@
import { DOMPurify, ePub, pdfjsLib, Readability, isProbablyReaderable } from '../lib.js';
import {
moment,
DOMPurify,
ePub,
pdfjsLib,
Readability,
isProbablyReaderable,
} from '../lib.js';
import { getContext } from './extensions.js';
import { characters, getRequestHeaders, this_chid } from '../script.js';
@ -773,8 +780,8 @@ export function isOdd(number) {
/**
* Compare two moment objects for sorting.
* @param {moment.Moment} a The first moment object.
* @param {moment.Moment} b The second moment object.
* @param {import('moment').Moment} a The first moment object.
* @param {import('moment').Moment} b The second moment object.
* @returns {number} A negative number if a is before b, a positive number if a is after b, or 0 if they are equal.
*/
export function sortMoments(a, b) {
@ -793,7 +800,7 @@ const dateCache = new Map();
* Cached version of moment() to avoid re-parsing the same date strings.
* Important: Moment objects are mutable, so use clone() before modifying them!
* @param {string|number} timestamp String or number representing a date.
* @returns {moment.Moment} Moment object
* @returns {import('moment').Moment} Moment object
*/
export function timestampToMoment(timestamp) {
if (dateCache.has(timestamp)) {