1 import { SORT_DIRECTION } from '../constants';
2 import { isMobile } from '../helpers/browser';
3 import type { UserSettings } from '../interfaces/drive/userSettings';
4 import { LayoutSetting, SortSetting } from '../interfaces/drive/userSettings';
6 export const MB = 1024 * 1024;
7 export const FOLDER_PAGE_SIZE = 150;
8 export const BATCH_REQUEST_SIZE = 50;
9 export const FILE_CHUNK_SIZE = 4 * MB;
10 export const MEMORY_DOWNLOAD_LIMIT = (isMobile() ? 100 : 500) * MB;
11 export const HARDWARE_CONCURRENCY = (typeof window !== 'undefined' && window.navigator?.hardwareConcurrency) || 1;
12 // openpgp.js creates hardwareConcurrency of web workers to do decryption.
13 // Using less threads for download means we don't use available potential.
14 // Using more threads will not speed things up much because thread in this
15 // context is not real thread but concurrently running downloads in the main
17 // In the future, with the openpgp.js v5, we will create web workers manually.
18 // That will allow us to create more workers and keep download and decryption
19 // part in the same thread to save some data exchanges between threads.
20 // We could really allow more workers than available CPUs, because decryption
21 // is done on the stream as data comes in, i.e., not that heavy operation.
22 // Of course, we cannot allow, lets say, twice as many workers per download
23 // of one file but for all downloads to not kill user's device. Ideally, we
24 // want to make download of one file as fast as possible, but limit it to the
25 // same speed with more ongoing downloads or uploads.
26 export const MAX_THREADS_PER_DOWNLOAD = HARDWARE_CONCURRENCY;
27 export const MAX_THREADS_PER_REQUEST = 5;
28 export const DEFAULT_SORT_FIELD = 'ModifyTime';
29 export const DEFAULT_SORT_ORDER: SORT_DIRECTION = SORT_DIRECTION.DESC;
31 export const DEFAULT_USER_SETTINGS: UserSettings = {
32 Layout: LayoutSetting.List,
33 Sort: SortSetting.ModifiedDesc,
34 RevisionRetentionDays: 0,
37 export const UPLOAD_TIMEOUT = 90000;
38 export const DOWNLOAD_TIMEOUT = 90000;
39 export const DOWNLOAD_RETRIES_ON_TIMEOUT = 3;
40 export const EXPENSIVE_REQUEST_TIMEOUT = 60000;
41 export const MAX_NAME_LENGTH = 255;
42 export const MAX_SHARED_URL_PASSWORD_LENGTH = 50;
44 export const SHARE_GENERATED_PASSWORD_LENGTH = 12;
46 export const DEFAULT_SHARE_MAX_ACCESSES = 0; // Zero means unlimited.
48 export const MAX_SAFE_UPLOADING_FILE_COUNT = 500;
49 export const MAX_SAFE_UPLOADING_FILE_SIZE = 5 * 1024 * 1024 * 1024; // GB
51 export const CUSTOM_DATA_FORMAT = 'pd-custom';
53 export const THUMBNAIL_MAX_SIDE = 512; // in pixels
54 export const THUMBNAIL_MAX_SIZE = 60 * 1024; // in bytes, 60kB
56 export const HD_THUMBNAIL_MAX_SIDE = 1920; // in pixels
57 export const HD_THUMBNAIL_MAX_SIZE = 1024 * 1024; // in bytes, 1mB
59 export const THUMBNAIL_QUALITIES = [0.7, 0.5, 0.3, 0.1, 0]; // Used qualities to stick under THUMBNAIL_MAX_SIZE.
61 export const VIDEO_THUMBNAIL_MAX_TIME_LOCATION: number = 300; // In seconds
63 export enum LinkURLType {
68 export enum EVENT_TYPES {
75 export enum EXPIRATION_DAYS {
85 * @deprecated common to different products, should be removed and use `API_CODES` from _/lib/constants.ts_ instead
87 export enum RESPONSE_CODE {
90 INVALID_REQUIREMENT = 2000,
91 INVALID_LINK_TYPE = 2001,
92 ALREADY_EXISTS = 2500,
97 export enum SupportedMimeTypes {
99 apk = 'application/vnd.android.package-archive',
101 arc = 'application/x-freearc',
102 avi = 'video/x-msvideo',
105 bzip2 = 'application/x-bzip2',
106 cr3 = 'image/x-canon-cr3',
107 docx = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
108 eot = 'application/vnd.ms-fontobject',
109 epub = 'application/epub+zip',
110 flac = 'audio/x-flac',
113 gzip = 'application/gzip',
115 heics = 'image/heic-sequence',
117 heifs = 'image/heif-sequence',
118 ico = 'image/x-icon',
121 keynote = 'application/vnd.apple.keynote',
132 numbers = 'application/vnd.apple.numbers',
133 odp = 'application/vnd.oasis.opendocument.presentation',
134 ods = 'application/vnd.oasis.opendocument.spreadsheet',
135 odt = 'application/vnd.oasis.opendocument.text',
137 ogg = 'application/ogg',
141 pages = 'application/vnd.apple.pages',
142 pdf = 'application/pdf',
144 pptx = 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
146 qt = 'video/quicktime',
147 rar = 'application/vnd.rar',
148 rtf = 'application/rtf',
149 svg = 'image/svg+xml',
150 swf = 'application/x-shockwave-flash',
151 tar = 'application/x-tar',
154 v3g2 = 'video/3gpp2',
159 woff2 = 'font/woff2',
160 x7zip = 'application/x-7z-compressed',
161 xlsx = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
163 zip = 'application/zip',
164 vdnMicrosoftIcon = 'image/vnd.microsoft.icon',
167 export enum SupportedProtonDocsMimeTypes {
168 docx = SupportedMimeTypes.docx,
170 md = 'text/markdown',
174 export const EXTRA_EXTENSION_TYPES: { [ext: string]: string } = {
176 ts: 'application/typescript',
180 export enum SHARE_MEMBER_PERMISSIONS {
188 export enum SHARE_MEMBER_STATE {
194 export enum SHARE_EXTERNAL_INVITATION_STATE {
199 export const DS_STORE = '.DS_Store';
201 // Delete once sharing between members is fully implemented.
202 export const MEMBER_SHARING_ENABLED = false;
204 export const PHOTOS_PAGE_SIZE = 500;
206 // Accepted files for photos. This value must be used in input `accept` attribute
207 export const PHOTOS_ACCEPTED_INPUT = `image/*,video/*,${SupportedMimeTypes.heic},${SupportedMimeTypes.heif}`;
209 const HOURS_IN_MS = 60 * 60 * 1000;
210 export const ACTIVE_PING_INTERVAL = 6 * HOURS_IN_MS;
212 export enum DRIVE_SIGNATURE_CONTEXT {
213 SHARE_MEMBER_INVITER = 'drive.share-member.inviter',
214 SHARE_MEMBER_MEMBER = 'drive.share-member.member',
215 SHARE_MEMBER_EXTERNAL_INVITATION = 'drive.share-member.external-invitation',
218 export const SHARE_INVITE_MESSAGE_MAX_LENGTH = 500;