index int64 0 0 | repo_id stringlengths 16 181 | file_path stringlengths 28 270 | content stringlengths 1 11.6M | __index_level_0__ int64 0 10k |
|---|---|---|---|---|
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib/calendar | petrpan-code/ProtonMail/WebClients/packages/shared/lib/calendar/sharing/getHasSharedCalendars.ts | import { getAllMembers, getCalendarInvitations, getPublicLinks } from '@proton/shared/lib/api/calendars';
import { getApiWithAbort } from '@proton/shared/lib/api/helpers/customConfig';
import { filterOutDeclinedInvitations } from '@proton/shared/lib/calendar/sharing/shareProton/shareProton';
import { Api } from '../..... | 8,400 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib/calendar/sharing | petrpan-code/ProtonMail/WebClients/packages/shared/lib/calendar/sharing/shareProton/ShareCalendarSignatureVerificationError.ts | export class ShareCalendarSignatureVerificationError extends Error {
senderEmail: string;
errors?: Error[];
constructor(senderEmail: string, errors?: Error[]) {
super('Authenticity of calendar invite could not be verified');
this.senderEmail = senderEmail;
this.errors = errors;
... | 8,401 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib/calendar/sharing | petrpan-code/ProtonMail/WebClients/packages/shared/lib/calendar/sharing/shareProton/shareProton.ts | import { c } from 'ttag';
import { CryptoProxy, VERIFICATION_STATUS, serverTime } from '@proton/crypto';
import { SIGNATURE_CONTEXT } from '@proton/shared/lib/calendar/crypto/constants';
import { ShareCalendarSignatureVerificationError } from '@proton/shared/lib/calendar/sharing/shareProton/ShareCalendarSignatureVerif... | 8,402 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib/calendar/sharing | petrpan-code/ProtonMail/WebClients/packages/shared/lib/calendar/sharing/shareUrl/shareUrl.ts | import { CryptoProxy, PrivateKeyReference, PublicKeyReference } from '@proton/crypto';
import { arrayToBinaryString, decodeBase64, encodeBase64 } from '@proton/crypto/lib/utils';
import { AES256, EVENT_ACTIONS } from '../../../constants';
import { generateRandomBytes, getSHA256Base64String, xorEncryptDecrypt } from '.... | 8,403 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib/calendar | petrpan-code/ProtonMail/WebClients/packages/shared/lib/calendar/subscribe/helpers.ts | import { c } from 'ttag';
import { CALENDAR_APP_NAME, EVENT_ACTIONS, HOUR } from '../../constants';
import { CALENDAR_SUBSCRIPTION_STATUS, Calendar, SubscribedCalendar } from '../../interfaces/calendar';
import {
CalendarSubscriptionEventManager,
CalendarSubscriptionEventManagerCreate,
CalendarSubscription... | 8,404 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib/calendar | petrpan-code/ProtonMail/WebClients/packages/shared/lib/calendar/sync/reencrypt.ts | import { SessionKey } from '@proton/crypto';
import { upgradeP2PInvite } from '../../api/calendars';
import { uint8ArrayToBase64String } from '../../helpers/encoding';
import { Api } from '../../interfaces';
import { CalendarEvent, DecryptedCalendarKey } from '../../interfaces/calendar';
import { getEncryptedSessionKe... | 8,405 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts/constants.ts | // BACK-END DATA
import { BASE_SIZE } from '../constants';
export const VCARD_KEY_FIELDS = [
'key',
'x-pm-mimetype',
'x-pm-encrypt',
'x-pm-encrypt-untrusted',
'x-pm-sign',
'x-pm-scheme',
'x-pm-tls',
];
export const CLEAR_FIELDS = ['version', 'prodid', 'categories'];
export const SIGNED_FIEL... | 8,406 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts/contactEmail.ts | import { normalize } from '@proton/shared/lib/helpers/string';
export const getContactDisplayNameEmail = ({
name,
email,
emailDelimiters = ['<', '>'],
}: {
name?: string;
email: string;
emailDelimiters?: string[];
}) => {
const displayOnlyEmail = !name || normalize(name) === normalize(email... | 8,407 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts/decrypt.ts | import { c } from 'ttag';
import { CryptoProxy, VERIFICATION_STATUS } from '@proton/crypto';
import { CONTACT_CARD_TYPE } from '../constants';
import { KeysPair } from '../interfaces';
import { Contact, ContactCard } from '../interfaces/contacts';
import { VCardContact } from '../interfaces/contacts/VCard';
import { ... | 8,408 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts/encrypt.ts | import { CryptoProxy } from '@proton/crypto';
import { CONTACT_CARD_TYPE } from '../constants';
import { generateProtonWebUID } from '../helpers/uid';
import { KeyPair } from '../interfaces';
import { Contact, ContactCard } from '../interfaces/contacts/Contact';
import { VCardContact, VCardProperty } from '../interfac... | 8,409 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts/globalOperations.ts | import { CryptoProxy, VERIFICATION_STATUS } from '@proton/crypto';
import { getContact, updateContact } from '../api/contacts';
import { CONTACT_CARD_TYPE } from '../constants';
import { Api, DecryptedKey, Key } from '../interfaces';
import { Contact } from '../interfaces/contacts';
import { splitKeys } from '../keys/... | 8,410 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts/keyPinning.ts | import { c } from 'ttag';
import { CryptoProxy, PrivateKeyReference, PublicKeyReference } from '@proton/crypto';
import isTruthy from '@proton/utils/isTruthy';
import { CONTACT_CARD_TYPE } from '../constants';
import { CANONICALIZE_SCHEME, canonicalizeEmail } from '../helpers/email';
import { generateProtonWebUID } f... | 8,411 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts/keyProperties.ts | import { CryptoProxy, PublicKeyReference } from '@proton/crypto';
import { arrayToBinaryString, binaryStringToArray, decodeBase64, encodeBase64 } from '@proton/crypto/lib/utils';
import isTruthy from '@proton/utils/isTruthy';
import { MIME_TYPES, PGP_SCHEMES } from '../constants';
import { MimeTypeVcard, PinnedKeysCon... | 8,412 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts/keyVerifications.ts | import { CryptoProxy, KeyID } from '@proton/crypto';
import { CONTACT_CARD_TYPE } from '../constants';
import { Key } from '../interfaces';
import { Contact } from '../interfaces/contacts';
export interface KeyWithIds {
key: Key;
ids: KeyID[];
}
/**
* Get all the key ids of each user keys
*/
export const g... | 8,413 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts/properties.ts | import generateUID from '../helpers/generateUID';
import { ContactValue } from '../interfaces/contacts';
import { VCardContact, VCardProperty } from '../interfaces/contacts/VCard';
import { UID_PREFIX } from './constants';
import { isMultiValue } from './vcard';
export const FIELDS_WITH_PREF = ['fn', 'email', 'tel', '... | 8,414 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts/property.ts | import { isValid, parseISO } from 'date-fns';
import { VCardDateOrText, VCardProperty } from '@proton/shared/lib/interfaces/contacts/VCard';
import { ContactValue } from '../interfaces/contacts';
import { CONTACT_FIRST_LAST_NAME_MAX_LENGTH, CONTACT_NAME_MAX_LENGTH } from './constants';
import { isDateTextValue, isVal... | 8,415 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts/resign.ts | import { CryptoProxy, PrivateKeyReference } from '@proton/crypto';
import { CONTACT_CARD_TYPE } from '../constants';
import { ContactCard } from '../interfaces/contacts';
/**
* Re-sign contact cards
* Private keys (typically only the primary one) need to be passed to re-sign the contact cards
* No public key is ne... | 8,416 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts/surgery.ts | import { isValid } from 'date-fns';
import { c } from 'ttag';
import isTruthy from '@proton/utils/isTruthy';
import { VCardContact, VCardProperty } from '../interfaces/contacts/VCard';
import {
FIELDS_WITH_PREF,
compareVCardPropertyByPref,
createContactPropertyUid,
fromVCardProperties,
generateNew... | 8,417 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts/vcard.ts | import { format, parseISO } from 'date-fns';
import ICAL from 'ical.js';
import isTruthy from '@proton/utils/isTruthy';
import range from '@proton/utils/range';
import { isValidDate } from '../date/date';
import { readFileAsString } from '../helpers/file';
import {
VCardAddress,
VCardContact,
VCardDateOrT... | 8,418 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts/errors/ImportContactError.ts | import { c } from 'ttag';
export enum IMPORT_CONTACT_ERROR_TYPE {
UNSUPPORTED_VCARD_VERSION,
MISSING_FN,
ENCRYPTION_ERROR,
EXTERNAL_ERROR,
}
const getErrorMessage = (errorType: IMPORT_CONTACT_ERROR_TYPE, externalError?: Error) => {
if (errorType === IMPORT_CONTACT_ERROR_TYPE.UNSUPPORTED_VCARD_VERS... | 8,419 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts/errors/ImportFatalError.ts | import { c } from 'ttag';
export class ImportFatalError extends Error {
error: Error;
constructor(error: Error) {
super(c('Error importing calendar').t`An unexpected error occurred. Import must be restarted.`);
this.error = error;
Object.setPrototypeOf(this, ImportFatalError.prototype)... | 8,420 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts/errors/ImportFileError.ts | import { c } from 'ttag';
import truncate from '@proton/utils/truncate';
import { MAX_FILENAME_CHARS_DISPLAY, MAX_IMPORT_CONTACTS_STRING, MAX_IMPORT_FILE_SIZE_STRING } from '../constants';
export enum IMPORT_ERROR_TYPE {
NO_FILE_SELECTED,
NO_CSV_OR_VCF_FILE,
FILE_EMPTY,
FILE_TOO_BIG,
FILE_CORRUPT... | 8,421 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts/helpers/address.ts | // Remove all commas at the beginning and at the end of the string
import { VCardAddress } from '@proton/shared/lib/interfaces/contacts/VCard';
const trimCommas = (string: string) => {
return string.replace(/(^,+|,+$)/g, '');
};
/**
* Remove all commas at the beginning and end of each contact address field
*/
e... | 8,422 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts/helpers/array.ts | import move from '@proton/utils/move';
/**
* Re-order elements in an array inside a group of arrays
*/
export const moveInGroup = <T>(
collection: T[][],
groupIndex: number,
{ oldIndex, newIndex }: { oldIndex: number; newIndex: number }
) => {
return collection.map((group, i) => {
if (i === g... | 8,423 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts/helpers/contactGroup.ts | import { ContactGroupLimitReachedProps } from '@proton/components/containers/contacts/modals/ContactGroupLimitReachedModal';
import { MailSettings } from '../../interfaces';
import { ContactEmail } from '../../interfaces/contacts';
import { DEFAULT_MAILSETTINGS } from '../../mail/mailSettings';
/**
* Check that the ... | 8,424 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts/helpers/csv.ts | import Papa from 'papaparse';
import { IMPORT_CONTACT_ERROR_TYPE, ImportContactError } from '@proton/shared/lib/contacts/errors/ImportContactError';
import { getContactId, getSupportedContactProperties, splitErrors } from '@proton/shared/lib/contacts/helpers/import';
import isTruthy from '@proton/utils/isTruthy';
impo... | 8,425 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts/helpers/csvFormat.ts | import { guessDateFromText } from '@proton/shared/lib/contacts/property';
import capitalize from '@proton/utils/capitalize';
import isTruthy from '@proton/utils/isTruthy';
import { normalize } from '../../helpers/string';
import { ContactValue } from '../../interfaces/contacts';
import {
Combine,
Display,
... | 8,426 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts/helpers/export.ts | import { format } from 'date-fns';
import { getApiWithAbort } from '@proton/shared/lib/api/helpers/customConfig';
import uniqueBy from '@proton/utils/uniqueBy';
import { getContact, queryContactExport } from '../../api/contacts';
import downloadFile from '../../helpers/downloadFile';
import { wait } from '../../helpe... | 8,427 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts/helpers/import.ts | import { c } from 'ttag';
import isTruthy from '@proton/utils/isTruthy';
import truncate from '@proton/utils/truncate';
import { CONTACT_CARD_TYPE, FORBIDDEN_LABEL_NAMES } from '../../constants';
import { normalize } from '../../helpers/string';
import {
ContactGroup,
ContactMetadata,
IMPORT_GROUPS_ACTION... | 8,428 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts/helpers/importCsv.ts | import { getTypeValues } from '../../helpers/contacts';
import { PreVcardProperty, PreVcardsContact } from '../../interfaces/contacts/Import';
import { VCardKey } from '../../interfaces/contacts/VCard';
// See './csv.ts' for the definition of pre-vCard and pre-vCards contact
/**
* Modify the field (and accordingly t... | 8,429 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts/helpers/merge.ts | import isTruthy from '@proton/utils/isTruthy';
import unique from '@proton/utils/unique';
import { normalize } from '../../helpers/string';
import { FormattedContact } from '../../interfaces/contacts/FormattedContact';
import { VCardContact, VCardProperty } from '../../interfaces/contacts/VCard';
import {
fromVCar... | 8,430 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts | petrpan-code/ProtonMail/WebClients/packages/shared/lib/contacts/helpers/progress.ts | /**
* Calculate progress percentage (0 <= integer <= 100) of a certain process
* that involves carrying out several tasks, that can either fail or be successful
* @param successful Number of tasks completed successfully
* @param failed Number of tasks that failed
* @param total Total number of tasks... | 8,431 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/date-fns-utc/differenceInCalendarDays.ts | import { DAY } from '@proton/shared/lib/constants';
import startOfDay from './startOfDay';
const differenceInCalendarDays = (left: Date, right: Date) => {
const startOfDayLeft = startOfDay(left);
const startOfDayRight = startOfDay(right);
const diff = startOfDayLeft.getTime() - startOfDayRight.getTime();... | 8,432 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/date-fns-utc/differenceInCalendarWeeks.ts | import { WEEK } from '@proton/shared/lib/constants';
import startOfDay from './startOfDay';
const differenceInCalendarWeeks = (left: Date, right: Date) => {
const startOfDayLeft = startOfDay(left);
const startOfDayRight = startOfDay(right);
const diff = startOfDayLeft.getTime() - startOfDayRight.getTime(... | 8,433 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/date-fns-utc/differenceInCalendarYears.ts | const differenceInCalendarYears = (left: Date, right: Date) => {
return left.getUTCFullYear() - right.getUTCFullYear();
};
export default differenceInCalendarYears;
| 8,434 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/date-fns-utc/eachDayOfInterval.ts | const eachDayOfInterval = (start: Date, end: Date) => {
const endTime = end.getTime();
if (!(start.getTime() <= endTime)) {
throw new RangeError('Invalid interval');
}
const dates: Date[] = [];
const currentDate = new Date(start);
currentDate.setUTCHours(0, 0, 0, 0);
const step =... | 8,435 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/date-fns-utc/endOfDay.ts | const endOfDay = (date: Date) => {
const result = new Date(+date);
result.setUTCHours(23, 59, 59, 999);
return result;
};
export default endOfDay;
| 8,436 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/date-fns-utc/endOfWeek.ts | import { WeekStartsOn } from './interface';
interface Options {
weekStartsOn: WeekStartsOn;
}
const endfWeek = (date: Date, options?: Options) => {
const weekStartsOn = !options || typeof options.weekStartsOn === 'undefined' ? 0 : options.weekStartsOn;
const result = new Date(+date);
const day = resul... | 8,437 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/date-fns-utc/format.ts | import formatters from 'date-fns/_lib/format/formatters/index';
import longFormatters from 'date-fns/_lib/format/longFormatters';
import defaultLocale from 'date-fns/locale/en-US';
import { WeekStartsOn } from './interface';
/**
* We copy here (with some refactor) the code for the format function from the 'date-fns'... | 8,438 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/date-fns-utc/getWeekNumber.ts | const MILLISECONDS_IN_WEEK = 604800000;
const getWeekNumber = (date: Date) => {
const start = new Date(date);
start.setUTCHours(0, 0, 0, 0);
const startOfYear = new Date(0);
startOfYear.setUTCFullYear(start.getUTCFullYear());
const diff = Math.max(start.getTime() - startOfYear.getTime(), 0);
... | 8,439 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/date-fns-utc/index.ts | /**
* Pending date-fn to implement UTC functions https://github.com/date-fns/date-fns/issues/376
*/
export { default as eachDayOfInterval } from './eachDayOfInterval';
export { default as startOfDay } from './startOfDay';
export { default as endOfDay } from './endOfDay';
export { default as startOfWeek } from './star... | 8,440 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/date-fns-utc/interface.ts | export type WeekStartsOn = 0 | 1 | 2 | 3 | 4 | 5 | 6;
| 8,441 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/date-fns-utc/startOfDay.ts | const startOfDay = (date: Date) => {
const result = new Date(+date);
result.setUTCHours(0, 0, 0, 0);
return result;
};
export default startOfDay;
| 8,442 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/date-fns-utc/startOfWeek.ts | import { WeekStartsOn } from './interface';
interface Options {
weekStartsOn: WeekStartsOn;
}
const startOfWeek = (date: Date, options?: Options) => {
const weekStartsOn = !options || typeof options.weekStartsOn === 'undefined' ? 0 : options.weekStartsOn;
const result = new Date(+date);
const day = re... | 8,443 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/date-utc/formatIntlUTCDate.ts | import { formatIntlDate } from '../date/formatIntlDate';
import { fromUTCDate, toLocalDate } from '../date/timezone';
import { localeCode } from '../i18n';
/**
* Format UTC date with Intl.DateTimeFormat
* @param date date to be formatted
* @param options formatting options, e.g. { weekday: 'short', month: 'l... | 8,444 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/date/date.ts | import {
addMonths,
differenceInMilliseconds,
eachDayOfInterval,
endOfWeek,
format,
getDaysInMonth,
isAfter,
startOfWeek,
startOfYear,
sub,
} from 'date-fns';
import { DAY } from '../constants';
interface FormatOptions {
locale?: Locale;
}
export const YEAR_REGEX = /[0-9]{... | 8,445 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/date/formatIntlDate.ts | import { localeCode } from '../i18n';
import { getIntlLocale } from '../i18n/helper';
/**
* Format date with Intl.DateTimeFormat
* @param date date to be formatted
* @param options formatting options, e.g. { weekday: 'short', month: 'long', year: 'numeric', timeStyle: 'short' }
* @param locale [Optional]... | 8,446 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/date/singleCountryTimezoneDatabase.ts | export const singleCountryTimezoneDatabase = {
'Africa/Abidjan': 'CI',
'Africa/Accra': 'GH',
'Africa/Addis_Ababa': 'ET',
'Africa/Algiers': 'DZ',
'Africa/Asmara': 'ER',
'Africa/Bamako': 'ML',
'Africa/Bangui': 'CF',
'Africa/Banjul': 'GM',
'Africa/Bissau': 'GW',
'Africa/Blantyre': '... | 8,447 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/date/timezone.ts | import { findTimeZone, getTimeZoneLinks, getUTCOffset, getZonedTime } from '@protontech/timezone-support';
import isTruthy from '@proton/utils/isTruthy';
import { getAllowedTimeZones } from '../api/calendars';
import { SECOND } from '../constants';
import { Api } from '../interfaces';
import { DateTime } from '../int... | 8,448 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/date/timezoneDatabase.ts | // Fall back list of supported time zones. It should be updated manually when the BE deploys a new list.
// This list is only used as a fallback in case at app load the call to fetch BE time zones fails
export const FALLBACK_ALLOWED_SUPPORTED_TIMEZONES_LIST = [
'Africa/Abidjan',
'Africa/Accra',
'Africa/Nair... | 8,449 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/drawer/calendar.ts | import { Dispatch, SetStateAction } from 'react';
import { getAppHref } from '../apps/helper';
import { getLinkToCalendarEvent } from '../calendar/helper';
import { APPS, APP_NAMES } from '../constants';
import { addParentAppToUrl, postMessageToIframe } from './helpers';
import { DRAWER_APPS, DRAWER_EVENTS, IframeSrcM... | 8,450 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/drawer/constants.ts | export const LOCALSTORAGE_DRAWER_KEY = 'PreviouslyOpenedAppInDrawer';
| 8,451 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/drawer/helpers.ts | import { isURLProtonInternal } from '@proton/components/helpers/url';
import { LOCALSTORAGE_DRAWER_KEY } from '@proton/shared/lib/drawer/constants';
import { getAppHref } from '../apps/helper';
import { getLocalIDFromPathname } from '../authentication/pathnameHelper';
import { APPS, APPS_CONFIGURATION, APP_NAMES } fro... | 8,452 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/drawer/interfaces.ts | import { ThemeColor } from '@proton/colors/types';
import { IconName } from '@proton/components/components';
import { APPS } from '@proton/shared/lib/constants';
import { Environment } from '@proton/shared/lib/interfaces';
import { User as tsUser } from '../interfaces';
import { VCardContact } from '../interfaces/cont... | 8,453 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/drive/constants.ts | import { SORT_DIRECTION } from '../constants';
import { isMobile } from '../helpers/browser';
import { LayoutSetting, SortSetting, UserSettings } from '../interfaces/drive/userSettings';
export const MB = 1024 * 1024;
export const FOLDER_PAGE_SIZE = 150;
export const BATCH_REQUEST_SIZE = 50;
export const FILE_CHUNK_SI... | 8,454 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/drive/translations.ts | import { c } from 'ttag';
export const getNumAccessesTooltipMessage = () =>
c('Info').t`The download count includes both actual downloads and instances when files are previewed.`;
export const getSizeTooltipMessage = () =>
c('Info')
.t`The encrypted data is slightly larger due to the overhead of the en... | 8,455 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/drive/urls.ts | import { getStaticURL } from '@proton/shared/lib/helpers/url';
export const DRIVE_LANDING_PAGE = getStaticURL('/drive');
export const DRIVE_PRICING_PAGE = getStaticURL('/drive/pricing?product=drive ');
export const DRIVE_IOS_APP = 'https://apps.apple.com/app/proton-drive-cloud-storage/id1509667851';
export const DRIVE... | 8,456 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib/drive | petrpan-code/ProtonMail/WebClients/packages/shared/lib/drive/utils/share.ts | import { ShareFlags } from '../../interfaces/drive/share';
export const isMainShare = (meta: { Flags?: number }) => {
return !!(typeof meta.Flags !== 'undefined' && meta.Flags & ShareFlags.MainShare);
};
| 8,457 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/eventManager/eventManager.ts | import noop from '@proton/utils/noop';
import { getEvents } from '../api/events';
import { FIBONACCI_LIST, INTERVAL_EVENT_TIMER } from '../constants';
import createListeners, { Listener } from '../helpers/listeners';
import { onceWithQueue } from '../helpers/onceWithQueue';
import { Api } from '../interfaces';
export... | 8,458 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib/eventManager | petrpan-code/ProtonMail/WebClients/packages/shared/lib/eventManager/calendar/calendarBootstrap.ts | import { CalendarKey, CalendarMember, CalendarSettings as tsCalendarSettings } from '../../interfaces/calendar';
import { CalendarMemberEventManager } from '../../interfaces/calendar/EventManager';
import {
getIsCalendarMemberEventManagerCreate,
getIsCalendarMemberEventManagerDelete,
getIsCalendarMemberEven... | 8,459 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib/eventManager | petrpan-code/ProtonMail/WebClients/packages/shared/lib/eventManager/calendar/calendarUserSettings.ts | import { CalendarUserSettingsModel } from '../../models';
import { STATUS } from '../../models/cache';
const calendarUserSettingsModelKey = CalendarUserSettingsModel.key;
export const updateCalendarsUserSettings = (cache: Map<string, any>, data: any) => {
if (data[calendarUserSettingsModelKey]) {
const { v... | 8,460 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib/eventManager | petrpan-code/ProtonMail/WebClients/packages/shared/lib/eventManager/calendar/calendarsWithMembers.ts | import { CalendarWithOwnMembers } from '../../interfaces/calendar';
import { CalendarEventManager, CalendarMemberEventManager } from '../../interfaces/calendar/EventManager';
import { STATUS } from '../../models/cache';
import { CALENDARS_CACHE_KEY } from '../../models/calendarsModel';
import {
findMemberIndices,
... | 8,461 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib/eventManager | petrpan-code/ProtonMail/WebClients/packages/shared/lib/eventManager/calendar/helpers.ts | import { EVENT_ACTIONS } from '../../constants';
import { CalendarWithOwnMembers } from '../../interfaces/calendar';
import {
CalendarEventManager,
CalendarEventManagerCreate,
CalendarEventManagerDelete,
CalendarEventManagerUpdate,
CalendarMemberEventManager,
CalendarMemberEventManagerCreate,
... | 8,462 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/fetch/ApiError.ts | export class ApiError extends Error {
response?: Response;
status: number;
data?: any;
config: any;
constructor(message: string, status: number, name: string) {
super(message);
Object.setPrototypeOf(this, ApiError.prototype);
this.status = status;
this.name = name... | 8,463 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/fetch/fetch.js | import { DEFAULT_TIMEOUT } from '../constants';
import { createOfflineError, createTimeoutError } from './ApiError';
import { checkStatus, createUrl, serializeData } from './helpers';
const fetchHelper = ({ url: urlString, params, signal, timeout = DEFAULT_TIMEOUT, ...rest }) => {
const abortController = new Abort... | 8,464 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/fetch/headers.ts | import { HumanVerificationMethodType } from '../interfaces';
interface Headers {
[key: string]: any;
}
interface MergeHeaderArgs {
headers?: Headers;
[key: string]: any;
}
export const mergeHeaders = ({ headers: configHeaders, ...restConfig }: MergeHeaderArgs, headers: Headers) => ({
...restConfig,
... | 8,465 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/fetch/helpers.ts | import window from '../window';
import { createApiError } from './ApiError';
const appendQueryParams = (url: URL, params: { [key: string]: any }) => {
Object.keys(params).forEach((key) => {
const value = params[key];
if (typeof value === 'undefined') {
return;
}
url.sear... | 8,466 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/address.ts | import unary from '@proton/utils/unary';
import { ADDRESS_RECEIVE, ADDRESS_SEND, ADDRESS_STATUS, ADDRESS_TYPE } from '../constants';
import { Address, Recipient } from '../interfaces';
import { ContactEmail } from '../interfaces/contacts';
import { canonicalizeInternalEmail } from './email';
export const getIsAddress... | 8,467 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/bitset.ts | import JSBI from 'jsbi';
/**
* Set bit on the number
*/
export const setBit = (number = 0, mask: number): number => number | mask;
/**
* Toggle a bit from the number
*/
export const toggleBit = (number = 0, mask: number): number => number ^ mask;
/**
* Clear a bit from the number
*/
export const clearBit = (nu... | 8,468 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/blackfriday.ts | import { isWithinInterval } from 'date-fns';
import { PlanIDs } from '@proton/shared/lib/interfaces';
import { BLACK_FRIDAY, COUPON_CODES, CYCLE, PLANS } from '../constants';
export const isBlackFridayPeriod = () => {
return isWithinInterval(new Date(), { start: BLACK_FRIDAY.START, end: BLACK_FRIDAY.END });
};
... | 8,469 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/boolean.ts | /**
* This function is the same as (bool) => +bool,
* but the return type is 0 | 1 instead of number
*/
export const booleanToNumber = (bool: boolean): 0 | 1 => {
return bool ? 1 : 0;
};
| 8,470 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/browser.ts | import UAParser from 'ua-parser-js';
const uaParser = new UAParser();
const ua = uaParser.getResult();
export const hasModulesSupport = () => {
const script = document.createElement('script');
return 'noModule' in script;
};
export const isFileSaverSupported = () => !!new Blob();
export const textToClipboar... | 8,471 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/cache.ts | import createListeners, { Listeners } from './listeners';
export interface Cache<K, V> extends Pick<Listeners<[K, V | undefined], void>, 'subscribe'>, Map<K, V> {
clearListeners: () => void;
}
/**
* Wraps a map with support for subscribe/unsubscribe on changes.
*/
const createCache = <K, V>(map = new Map<K, V>(... | 8,472 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/checkout.ts | import { c, msgid } from 'ttag';
import {
get2FAAuthenticatorText,
getDevicesText,
getLoginsAndNotesText,
getUnlimitedHideMyEmailAliasesText,
} from '@proton/components/containers/payments/features/pass';
import { getVpnConnections, getVpnServers } from '@proton/shared/lib/vpn/features';
import {
... | 8,473 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/contactGroups.ts | import { ContactGroup } from '../interfaces/contacts';
export const orderContactGroups = (contactGroups: ContactGroup[]) => {
return [...contactGroups].sort((contactGroupA, contactGroupB) =>
contactGroupA.Name.localeCompare(contactGroupB.Name)
);
};
| 8,474 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/contacts.ts | import { c } from 'ttag';
import { encodeImageUri, forgeImageURL } from '@proton/shared/lib/helpers/image';
import { isBase64Image } from '@proton/shared/lib/helpers/validators';
export const getAllFields = () => [
// translator: this field is used to specify the display name of the contact (e.g. Jane Appleseed)
... | 8,475 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/cookies.ts | import isTruthy from '@proton/utils/isTruthy';
export const getCookies = (): string[] => {
try {
return document.cookie.split(';').map((item) => item.trim());
} catch (e: any) {
return [];
}
};
export const getCookie = (name: string, cookies = document.cookie) => {
return `; ${cookies}... | 8,476 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/crossTab.ts | import { uint8ArrayToBase64String } from './encoding';
import { removeItem, setItem } from './storage';
export const PASSWORD_CHANGE_MESSAGE_TYPE = 'password-change';
const CROSS_TAB_EVENT_KEY = 'cte';
let id: string | undefined;
const generateId = () => {
return uint8ArrayToBase64String(crypto.getRandomValues(... | 8,477 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/crypto.ts | import { CryptoProxy } from '@proton/crypto';
import { arrayToBinaryString, arrayToHexString, binaryStringToArray } from '@proton/crypto/lib/utils';
import { stringToUint8Array, uint8ArrayToBase64String, uint8ArrayToString } from './encoding';
export const getSHA256String = async (data: string) => {
const value =... | 8,478 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/desktop.ts | import UAParser from 'ua-parser-js';
import { isMac } from './browser';
const uaParser = new UAParser();
const ua = uaParser.getResult();
export const isElectronApp = () => {
return /electron/i.test(ua.ua);
};
export const isElectronOnMac = () => {
return isElectronApp() && isMac();
};
| 8,479 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/desktopNotification.ts | import Push from 'push.js';
import noop from '@proton/utils/noop';
Push.config({
serviceWorker: './assets/serviceWorker.min.js', // Sets a custom service worker script
});
export enum Status {
DENIED = 'denied',
DEFAULT = 'default',
GRANTED = 'granted',
}
export const getStatus = (): Status => {
... | 8,480 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/dom.ts | import tinycolor from 'tinycolor2';
interface ScriptInfo {
path: string;
integrity?: string;
}
interface Callback {
(event?: Event, error?: string | Event): void;
}
const loadScriptHelper = ({ path, integrity }: ScriptInfo, cb: Callback) => {
const script = document.createElement('script');
scri... | 8,481 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/downloadFile.ts | import saveAs from 'file-saver';
import { isFileSaverSupported } from './browser';
const downloadFile = (blob: Blob | undefined, filename: string | undefined) => {
if (!isFileSaverSupported()) {
throw new Error('Download requires a newer browser.');
}
saveAs(blob, filename);
};
export default do... | 8,482 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/email.ts | /**
* Validate the local part of an email string according to the RFC https://tools.ietf.org/html/rfc5321#section-4.1.2;
* see also https://tools.ietf.org/html/rfc3696#page-5 and https://en.wikipedia.org/wiki/Email_address#Local-part
*
* NOTE: Email providers respect the RFC only loosely. We do not want to invalida... | 8,483 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/encoding.ts | import { arrayToBinaryString, binaryStringToArray, decodeBase64, encodeBase64 } from '@proton/crypto/lib/utils';
export const uint8ArrayToString = arrayToBinaryString;
export const stringToUint8Array = binaryStringToArray;
export const uint8ArrayToBase64String = (array: Uint8Array) => encodeBase64(uint8ArrayToString... | 8,484 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/events.ts | export const isKeyboardEvent = (event: Event): event is KeyboardEvent => {
if ('key' in event) {
return true;
}
return false;
};
export const isDragEvent = (event: Event): event is DragEvent => {
if ('dataTransfer' in event) {
return true;
}
return false;
};
const assignKeyboar... | 8,485 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/file.ts | import { base64StringToUint8Array, uint8ArrayToString } from './encoding';
/**
* Convert file to encoded base 64 string
*/
export const toBase64 = async (file: Blob, isValid: (file: Blob) => boolean = () => true) => {
if (file && !isValid(file)) {
throw new Error('Invalid file format');
}
return ... | 8,486 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/filters.ts | import { Filter } from '@proton/components/containers/filters/interfaces';
import { FILTER_STATUS, FREE_USER_ACTIVE_FILTERS_LIMIT } from '@proton/shared/lib/constants';
import { UserModel } from '@proton/shared/lib/interfaces';
export const hasReachedFiltersLimit = (user: UserModel, userFilters: Filter[]) => {
con... | 8,487 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/folder.ts | import { Label, UserModel } from '@proton/shared/lib/interfaces';
import orderBy from '@proton/utils/orderBy';
import range from '@proton/utils/range';
import { FREE_USER_FOLDERS_LIMIT, FREE_USER_LABELS_LIMIT, ROOT_FOLDER } from '../constants';
import { Folder, FolderWithSubFolders } from '../interfaces/Folder';
expo... | 8,488 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/formValidators.ts | import { c, msgid } from 'ttag';
import { validateEmailAddress } from './email';
import { REGEX_USERNAME, REGEX_USERNAME_END, REGEX_USERNAME_START, isNumber } from './validators';
export const requiredValidator = (value: any) =>
value === undefined || value === null || value?.trim?.() === '' ? c('Error').t`This f... | 8,489 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/generateUID.ts | let current = 0;
const generateUID = (prefix?: string) => `${prefix || 'id'}-${current++}`;
export default generateUID;
| 8,490 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/getUsername.ts | import { Address, User, UserType } from '../interfaces';
import { getIsAddressEnabled } from './address';
export default function getUsername(user: User, addresses: Address[]) {
const primaryAddress = addresses?.find(getIsAddressEnabled);
return user.Type === UserType.EXTERNAL && primaryAddress ? primaryAddres... | 8,491 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/humanPrice.ts | import { Currency } from '../interfaces';
/**
* Make amount readable
* 600 -> 6, 650 -> 6.50, 633 -> 6.33
*/
const humanPrice = (amount: number = 0, divisor: number = 100) => {
const fixedValue = Number(amount / divisor).toFixed(2);
return fixedValue.replace('.00', '').replace('-', '');
};
export default h... | 8,492 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/humanSize.ts | import { c, msgid } from 'ttag';
import { BASE_SIZE } from '../constants';
export const sizeUnits = {
B: 1,
KB: BASE_SIZE,
MB: BASE_SIZE * BASE_SIZE,
GB: BASE_SIZE * BASE_SIZE * BASE_SIZE,
TB: BASE_SIZE * BASE_SIZE * BASE_SIZE * BASE_SIZE,
};
export type SizeUnits = keyof typeof sizeUnits;
expor... | 8,493 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/image.ts | import { getImage } from '../api/images';
import { REGEX_IMAGE_EXTENSION } from '../constants';
import { createUrl } from '../fetch/helpers';
import { toBase64 } from './file';
/**
* Use to encode Image URI when loading images
*/
export const encodeImageUri = (url: string) => {
// Only replace spaces for the mom... | 8,494 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/incomingDefaults.ts | import { INCOMING_DEFAULTS_LOCATION } from '../constants';
import { IncomingDefault } from '../interfaces';
/**
* Check if an email address is inside email in incomingDefaults
*/
const isAddressIncluded = (
incomingDefaults: IncomingDefault[] = [],
emailAddress: string,
location?: INCOMING_DEFAULTS_LOCAT... | 8,495 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/isDeepEqual.ts | export { default } from 'lodash/isEqual';
// Using lodash for now...
| 8,496 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/listeners.ts | export type Listener<A extends any[], R> = (...args: A) => R;
export interface Listeners<A extends any[], R> {
notify: (...args: A) => R[];
subscribe: (listener: Listener<A, R>) => () => void;
clear: () => void;
}
const createListeners = <A extends any[], R = void>(): Listeners<A, R> => {
let listener... | 8,497 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/lru.ts | interface Args<K, V> {
max: number;
onDispose?: ([key, value]: [K, V | undefined]) => void;
}
function createLRU<K, V>({ max, onDispose }: Args<K, V>): Map<K, V> {
const map = new Map<K, V>();
const getOldestKey = () => map.keys().next().value;
return {
get size() {
return map... | 8,498 |
0 | petrpan-code/ProtonMail/WebClients/packages/shared/lib | petrpan-code/ProtonMail/WebClients/packages/shared/lib/helpers/metrics.ts | import { getSilentApi } from '@proton/shared/lib/api/helpers/customConfig';
import { metrics } from '../api/metrics';
import { TelemetryReport, sendMultipleTelemetryData, sendTelemetryData } from '../api/telemetry';
import { METRICS_LOG, SECOND } from '../constants';
import { Api } from '../interfaces';
import { wait ... | 8,499 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.