cleanup dependencies

pull/2141/head
audric 2 years ago
parent 2e1016a90e
commit 247cb7c065

@ -9,7 +9,6 @@ const toConcatForApp = [
'node_modules/long/dist/long.js',
'components/protobuf/**/*.js',
'node_modules/mustache/mustache.js',
'node_modules/underscore/underscore.js',
'node_modules/backbone/backbone.js',
];

@ -1,10 +1,9 @@
/* eslint-env node */
const is = require('@sindresorhus/is');
const path = require('path');
const { compose } = require('lodash/fp');
const { escapeRegExp } = require('lodash');
const { escapeRegExp, isRegExp, isString } = require('lodash');
const APP_ROOT_PATH = path.join(__dirname, '..', '..', '..');
const SESSION_ID_PATTERN = /\b((05)?[0-9a-f]{64})\b/gi;
@ -15,18 +14,18 @@ const REDACTION_PLACEHOLDER = '[REDACTED]';
// _redactPath :: Path -> String -> String
exports._redactPath = filePath => {
if (!is.string(filePath)) {
if (!filePath) {
throw new TypeError("'filePath' must be a string");
}
const filePathPattern = exports._pathToRegExp(filePath);
return text => {
if (!is.string(text)) {
if (!isString(text)) {
throw new TypeError("'text' must be a string");
}
if (!is.regExp(filePathPattern)) {
if (!isRegExp(filePathPattern)) {
return text;
}
@ -59,7 +58,7 @@ exports._pathToRegExp = filePath => {
// Public API
// redactSessionID :: String -> String
exports.redactSessionID = text => {
if (!is.string(text)) {
if (!isString(text)) {
throw new TypeError("'text' must be a string");
}
@ -67,7 +66,7 @@ exports.redactSessionID = text => {
};
exports.redactSnodeIP = text => {
if (!is.string(text)) {
if (!isString(text)) {
throw new TypeError("'text' must be a string");
}
@ -75,7 +74,7 @@ exports.redactSnodeIP = text => {
};
exports.redactServerUrl = text => {
if (!is.string(text)) {
if (!isString(text)) {
throw new TypeError("'text' must be a string");
}
@ -84,7 +83,7 @@ exports.redactServerUrl = text => {
// redactGroupIds :: String -> String
exports.redactGroupIds = text => {
if (!is.string(text)) {
if (!isString(text)) {
throw new TypeError("'text' must be a string");
}

@ -51,7 +51,6 @@
},
"dependencies": {
"@reduxjs/toolkit": "^1.4.0",
"@sindresorhus/is": "0.8.0",
"abort-controller": "3.0.0",
"auto-bind": "^4.0.0",
"backbone": "1.3.3",
@ -76,10 +75,8 @@
"emoji-mart": "^2.11.2",
"filesize": "3.6.1",
"firstline": "1.2.1",
"form-data": "^3.0.0",
"fs-extra": "9.0.0",
"glob": "7.1.2",
"he": "1.2.0",
"image-type": "^4.1.0",
"ip2country": "1.0.1",
"jquery": "3.3.1",
@ -97,13 +94,11 @@
"os-locale": "2.1.0",
"p-retry": "^4.2.0",
"pify": "3.0.0",
"protobufjs": "^6.9.0",
"rc-slider": "^8.7.1",
"react": "^17.0.2",
"react-contexify": "5.0.0",
"react-dom": "^17.0.2",
"react-draggable": "^4.4.4",
"react-emoji": "^0.5.0",
"react-emoji-render": "^1.2.4",
"react-h5-audio-player": "^3.2.0",
"react-intersection-observer": "^8.30.3",
@ -124,12 +119,6 @@
"sanitize.css": "^12.0.1",
"semver": "5.4.1",
"styled-components": "5.1.1",
"tar": "4.4.8",
"tmp": "0.0.33",
"to-arraybuffer": "1.0.1",
"typings-for-css-modules-loader": "^1.7.0",
"underscore": "1.9.0",
"use-hooks": "^2.0.0-rc.5",
"uuid": "3.3.2"
},
"devDependencies": {
@ -156,7 +145,6 @@
"@types/mocha": "5.0.0",
"@types/node-fetch": "^2.5.7",
"@types/pify": "3.0.2",
"@types/qs": "6.5.1",
"@types/rc-slider": "^8.6.5",
"@types/react": "^17.0.15",
"@types/react-dom": "^17.0.2",
@ -170,16 +158,12 @@
"@types/semver": "5.5.0",
"@types/sinon": "9.0.4",
"@types/styled-components": "^5.1.4",
"@types/tmp": "^0.2.0",
"@types/uuid": "3.4.4",
"@types/webpack": "^5.28.0",
"arraybuffer-loader": "1.0.3",
"asar": "0.14.0",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
"chai-bytes": "^0.1.2",
"css-loader": "^3.6.0",
"dashdash": "1.14.1",
"electron": "^13.6.2",
"electron-builder": "22.8.0",
"electron-notarize": "^0.2.0",
@ -197,7 +181,6 @@
"grunt-exec": "3.0.0",
"grunt-gitinfo": "0.1.7",
"grunt-sass": "3.0.1",
"lint-staged": ">=10",
"mocha": "4.1.0",
"mocha-testcheck": "1.0.0-rc.0",
"node-gyp": "3.8.0",
@ -205,7 +188,7 @@
"playwright": "^1.16.3",
"postinstall-prepare": "^1.0.1",
"prettier": "1.19.0",
"qs": "6.5.1",
"protobufjs": "^6.11.2",
"run-script-os": "^1.1.6",
"sinon": "9.0.2",
"ts-loader": "4.1.0",
@ -354,10 +337,5 @@
"!dev-app-update.yml"
],
"afterPack": "./build/afterPackHook.js"
},
"lint-staged": {
"*.{css,js,json,scss,ts,tsx}": "prettier --write",
"*/**/*.{css,js,json,scss,ts,tsx}": "prettier --write",
"*.js": "eslint --cache --fix"
}
}

@ -103,6 +103,7 @@ window.getStartInTray = () =>
});
window.libsession = require('./ts/session');
window._ = require('lodash');
window.getConversationController = window.libsession.Conversations.getConversationController;

@ -1,4 +1,4 @@
import is from '@sindresorhus/is';
import _ from 'lodash';
import os from 'os';
import semver from 'semver';
@ -11,5 +11,5 @@ export const isWindows = (minVersion?: string) => {
return false;
}
return is.undefined(minVersion) ? true : semver.gte(osRelease, minVersion);
return _.isUndefined(minVersion) ? true : semver.gte(osRelease, minVersion);
};

@ -4,7 +4,6 @@ import path from 'path';
import pify from 'pify';
import { default as glob } from 'glob';
import fse from 'fs-extra';
import toArrayBuffer from 'to-arraybuffer';
import { isArrayBuffer, isString, map } from 'lodash';
import { decryptAttachmentBuffer, encryptAttachmentBuffer } from '../../ts/types/Attachment';
@ -53,7 +52,7 @@ export const createReader = (root: string) => {
}
const buffer = await fse.readFile(normalized);
const decryptedData = await decryptAttachmentBuffer(toArrayBuffer(buffer));
const decryptedData = await decryptAttachmentBuffer(buffer.buffer);
return decryptedData.buffer;
};

@ -1,7 +1,7 @@
import React, { useState } from 'react';
import classNames from 'classnames';
import { useEncryptedFileFetch } from '../../hooks/useEncryptedFileFetch';
import _ from 'underscore';
import { isEqual } from 'lodash';
import {
useAvatarPath,
useConversationUsername,
@ -163,4 +163,4 @@ const AvatarInner = (props: Props) => {
);
};
export const Avatar = React.memo(AvatarInner, _.isEqual);
export const Avatar = React.memo(AvatarInner, isEqual);

@ -3,7 +3,6 @@ import { useSelector } from 'react-redux';
import Draggable, { DraggableData, DraggableEvent } from 'react-draggable';
import styled from 'styled-components';
import _ from 'underscore';
import { getSelectedConversationKey } from '../../state/selectors/conversations';
import { getHasOngoingCall, getHasOngoingCallWith } from '../../state/selectors/call';
import { openConversationWithMessages } from '../../state/ducks/conversations';

@ -2,7 +2,6 @@ import { useSelector } from 'react-redux';
import React, { useRef, useState } from 'react';
import styled from 'styled-components';
import _ from 'underscore';
import { CallManager, UserUtils } from '../../session/utils';
import {
getCallIsInFullScreen,

@ -2,7 +2,6 @@ import React, { useEffect } from 'react';
import { useSelector } from 'react-redux';
import styled from 'styled-components';
import _ from 'underscore';
import { useConversationUsername } from '../../hooks/useParamSelector';
import { ed25519Str } from '../../session/onions/onionPath';
import { CallManager } from '../../session/utils';

@ -1,7 +1,7 @@
import classNames from 'classnames';
import React, { useCallback } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import _ from 'underscore';
import { clone } from 'lodash';
import { getMessageById } from '../../../../data/data';
import { MessageRenderingProps } from '../../../../models/messageType';
import {
@ -223,7 +223,7 @@ const onClickAttachment = async (onClickProps: {
found.get('timestamp') || found.get('serverTimestamp') || found.get('received_at');
return {
index: _.clone(index),
index: clone(index),
objectURL: attachmentForMedia.url || undefined,
contentType: attachmentForMedia.contentType,
attachment: attachmentForMedia,

@ -3,7 +3,7 @@ import moment from 'moment';
import React, { createContext, useCallback, useState } from 'react';
import { InView } from 'react-intersection-observer';
import { useSelector } from 'react-redux';
import _ from 'underscore';
import { isEmpty } from 'lodash';
import { MessageRenderingProps, QuoteClickOptions } from '../../../../models/messageType';
import {
getMessageContentSelectorProps,
@ -143,8 +143,8 @@ export const MessageContent = (props: Props) => {
const width = getWidth({ previews, attachments });
const isShowingImage = getIsShowingImage({ attachments, imageBroken, previews, text });
const hasText = Boolean(text);
const hasQuote = !_.isEmpty(quote);
const hasContentAfterAttachmentAndQuote = !_.isEmpty(previews) || !_.isEmpty(text);
const hasQuote = !isEmpty(quote);
const hasContentAfterAttachmentAndQuote = !isEmpty(previews) || !isEmpty(text);
const bgShouldBeTransparent = isShowingImage && !hasText && !hasQuote;
const toolTipTitle = moment(serverTimestamp || timestamp).format('llll');

@ -1,7 +1,6 @@
import classNames from 'classnames';
import React, { useCallback } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import _ from 'underscore';
import { replyToMessage } from '../../../../interactions/conversationInteractions';
import { MessageRenderingProps, QuoteClickOptions } from '../../../../models/messageType';
import { toggleSelectedMessageId } from '../../../../state/ducks/conversations';

@ -6,7 +6,7 @@ import * as GoogleChrome from '../../../../../ts/util/GoogleChrome';
import { useSelector } from 'react-redux';
import { noop } from 'underscore';
import { noop } from 'lodash';
import { useDisableDrag } from '../../../../hooks/useDisableDrag';
import { useEncryptedFileFetch } from '../../../../hooks/useEncryptedFileFetch';
import { PubKey } from '../../../../session/types';

@ -4,7 +4,6 @@ import {
PropsForGroupUpdate,
PropsForGroupUpdateType,
} from '../../../../state/ducks/conversations';
import _ from 'underscore';
import { NotificationBubble } from './notification-bubble/NotificationBubble';
import { ReadableMessage } from './ReadableMessage';
import { arrayContainsUsOnly } from '../../../../models/message';

@ -34,7 +34,7 @@ import { conversationChanged, conversationRemoved } from '../../state/ducks/conv
import { editProfileModal, onionPathModal } from '../../state/ducks/modalDialog';
import { uploadOurAvatar } from '../../interactions/conversationInteractions';
import { ModalContainer } from '../dialog/ModalContainer';
import { debounce } from 'underscore';
import { debounce } from 'lodash';
// tslint:disable-next-line: no-import-side-effect no-submodule-imports

@ -9,7 +9,6 @@ import {
openConversationWithMessages,
ReduxConversationType,
} from '../../../state/ducks/conversations';
import _ from 'underscore';
import { useDispatch } from 'react-redux';
import { updateUserDetailsModal } from '../../../state/ducks/modalDialog';
@ -21,6 +20,7 @@ import {
import { MemoConversationListItemContextMenu } from '../../menu/ConversationListItemContextMenu';
import { ConversationListItemHeaderItem } from './HeaderItem';
import { MessageItem } from './MessageItem';
import _ from 'lodash';
// tslint:disable-next-line: no-empty-interface
export type ConversationListItemProps = Pick<

@ -1,6 +1,6 @@
import classNames from 'classnames';
import React, { useContext } from 'react';
import { isEmpty } from 'underscore';
import { isEmpty } from 'lodash';
import { useConversationPropsById } from '../../../hooks/useParamSelector';
import { MessageBody } from '../../conversation/message/message-content/MessageBody';
import { OutgoingMessageStatus } from '../../conversation/message/message-content/OutgoingMessageStatus';

@ -2,8 +2,6 @@
import React, { useRef } from 'react';
import is from '@sindresorhus/is';
// useCss has some issues on our setup. so import it directly
// tslint:disable-next-line: no-submodule-imports
import useUnmount from 'react-use/lib/useUnmount';
@ -15,6 +13,7 @@ import { GoogleChrome } from '../../util';
import { Flex } from '../basic/Flex';
import { SessionIconButton, SessionIconType } from '../icon';
import * as MIME from '../../types/MIME';
import { isUndefined } from 'lodash';
const Colors = {
TEXT_SECONDARY: '#bbb',
@ -288,7 +287,7 @@ export const Lightbox = (props: Props) => {
<div style={styles.controlsOffsetPlaceholder} />
<div style={styles.objectParentContainer} role="button">
<div style={styles.objectContainer as any}>
{!is.undefined(contentType) ? (
{!isUndefined(contentType) ? (
<LightboxObject
objectURL={objectURL}
contentType={contentType}

@ -1,6 +1,6 @@
import React from 'react';
import { animation, Menu } from 'react-contexify';
import _ from 'underscore';
import _ from 'lodash';
import {
BanMenuItem,

@ -1 +0,0 @@
declare module 'to-arraybuffer';

@ -1,4 +1,4 @@
import _ from 'underscore';
import { compact } from 'lodash';
import { getMessageById } from '../../data/data';
import { ConversationModel } from '../../models/conversation';
import { MessageModel } from '../../models/message';
@ -67,7 +67,7 @@ async function unsendMessagesForEveryone(
function getUnsendMessagesObjects(messages: Array<MessageModel>) {
//#region building request
return _.compact(
return compact(
messages.map(message => {
const author = message.get('source');
@ -98,7 +98,7 @@ function getUnsendMessagesObjects(messages: Array<MessageModel>) {
*/
export async function deleteMessagesFromSwarmOnly(messages: Array<MessageModel>) {
try {
const deletionMessageHashes = _.compact(messages.map(m => m.get('messageHash')));
const deletionMessageHashes = compact(messages.map(m => m.get('messageHash')));
if (deletionMessageHashes.length > 0) {
const errorOnSnode = await networkDeleteMessages(deletionMessageHashes);
return errorOnSnode === null || errorOnSnode.length === 0;
@ -332,7 +332,7 @@ export async function deleteMessagesByIdForEveryone(
conversationId: string
) {
const conversation = getConversationController().getOrThrow(conversationId);
const selectedMessages = _.compact(
const selectedMessages = compact(
await Promise.all(messageIds.map(m => getMessageById(m, false)))
);
@ -360,7 +360,7 @@ export async function deleteMessagesByIdForEveryone(
export async function deleteMessagesById(messageIds: Array<string>, conversationId: string) {
const conversation = getConversationController().getOrThrow(conversationId);
const selectedMessages = _.compact(
const selectedMessages = compact(
await Promise.all(messageIds.map(m => getMessageById(m, false)))
);
@ -407,13 +407,13 @@ async function deleteOpenGroupMessages(
const roomInfos = convo.toOpenGroupV2();
// on v2 servers we can only remove a single message per request..
// so logic here is to delete each messages and get which one where not removed
const validServerIdsToRemove = _.compact(
const validServerIdsToRemove = compact(
messages.map(msg => {
return msg.get('serverId');
})
);
const validMessageModelsToRemove = _.compact(
const validMessageModelsToRemove = compact(
messages.map(msg => {
const serverId = msg.get('serverId');
if (serverId) {

@ -1,4 +1,4 @@
import _ from 'underscore';
import { defaultsDeep } from 'lodash';
import { v4 as uuidv4 } from 'uuid';
import { CallNotificationType, PropsForMessageWithConvoProps } from '../state/ducks/conversations';
import { AttachmentTypeWithPath } from '../types/Attachment';
@ -199,7 +199,7 @@ export interface MessageAttributesOptionals {
export const fillMessageAttributesWithDefaults = (
optAttributes: MessageAttributesOptionals
): MessageAttributes => {
const defaulted = _.defaults(optAttributes, {
const defaulted = defaultsDeep(optAttributes, {
expireTimer: 0, // disabled
id: uuidv4(),
unread: 0, // if nothing is set, this message is considered read

@ -6,7 +6,6 @@
*
*/
import toArrayBuffer from 'to-arraybuffer';
import * as fse from 'fs-extra';
import { decryptAttachmentBuffer } from '../../types/Attachment';
import { DURATION } from '../constants';
@ -86,9 +85,7 @@ export const getDecryptedMediaUrl = async (
window.log.info('about to read and decrypt file :', url);
try {
const encryptedFileContent = await fse.readFile(url);
const decryptedContent = await decryptAttachmentBuffer(
toArrayBuffer(encryptedFileContent)
);
const decryptedContent = await decryptAttachmentBuffer(encryptedFileContent.buffer);
if (decryptedContent?.length) {
const arrayBuffer = decryptedContent.buffer;
const obj = makeObjectUrl(arrayBuffer, contentType);

@ -1,8 +1,6 @@
import test, { _electron, Page } from '@playwright/test';
import { getAppDataPath } from './open';
export const cleanUp = async (window: Page) => {
await window.click('[data-testid=settings-section]');
await window.click('text=Clear All Data');

@ -1,6 +1,5 @@
import is from '@sindresorhus/is';
import moment from 'moment';
import { isArrayBuffer, padStart } from 'lodash';
import { isArrayBuffer, isUndefined, padStart } from 'lodash';
import * as MIME from './MIME';
import { saveURLAsFile } from '../util/saveURLAsFile';
@ -276,7 +275,7 @@ interface AttachmentSchemaVersion3 {
export const isVisualMedia = (attachment: Attachment): boolean => {
const { contentType } = attachment;
if (is.undefined(contentType)) {
if (isUndefined(contentType)) {
return false;
}
@ -290,7 +289,7 @@ export const isVisualMedia = (attachment: Attachment): boolean => {
export const isFile = (attachment: Attachment): boolean => {
const { contentType } = attachment;
if (is.undefined(contentType)) {
if (isUndefined(contentType)) {
return false;
}
@ -309,13 +308,13 @@ export const isVoiceMessage = (attachment: Attachment): boolean => {
const flag = SignalService.AttachmentPointer.Flags.VOICE_MESSAGE;
const hasFlag =
// tslint:disable-next-line no-bitwise
!is.undefined(attachment.flags) && (attachment.flags & flag) === flag;
!isUndefined(attachment.flags) && (attachment.flags & flag) === flag;
if (hasFlag) {
return true;
}
const isLegacyAndroidVoiceMessage =
!is.undefined(attachment.contentType) &&
!isUndefined(attachment.contentType) &&
MIME.isAudio(attachment.contentType) &&
!attachment.fileName;
if (isLegacyAndroidVoiceMessage) {
@ -337,7 +336,7 @@ export const save = ({
getAbsolutePath: (relativePath: string) => string;
timestamp?: number;
}): void => {
const isObjectURLRequired = is.undefined(attachment.fileName);
const isObjectURLRequired = isUndefined(attachment.fileName);
const filename = getSuggestedFilename({ attachment, timestamp, index });
saveURLAsFile({ url: attachment.url, filename, document });
if (isObjectURLRequired) {

@ -1,5 +1,4 @@
import is from '@sindresorhus/is';
import { isArrayBuffer } from 'lodash';
import { MIMEType } from '../types/MIME';
export const arrayBufferToObjectURL = ({
@ -9,7 +8,7 @@ export const arrayBufferToObjectURL = ({
data: ArrayBuffer;
type: MIMEType;
}): string => {
if (!is.arrayBuffer(data)) {
if (!isArrayBuffer(data)) {
throw new TypeError('`data` must be an ArrayBuffer');
}

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save