@nextcloud/files 3.0.0-beta.8 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js DELETED
@@ -1,711 +0,0 @@
1
- import { getCanonicalLocale } from '@nextcloud/l10n';
2
- import { getCurrentUser } from '@nextcloud/auth';
3
- import { getLoggerBuilder } from '@nextcloud/logger';
4
- import { basename, extname, dirname } from 'path';
5
-
6
- /**
7
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
8
- *
9
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
10
- * @author John Molakvoæ <skjnldsv@protonmail.com>
11
- *
12
- * @license AGPL-3.0-or-later
13
- *
14
- * This program is free software: you can redistribute it and/or modify
15
- * it under the terms of the GNU Affero General Public License as
16
- * published by the Free Software Foundation, either version 3 of the
17
- * License, or (at your option) any later version.
18
- *
19
- * This program is distributed in the hope that it will be useful,
20
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
- * GNU Affero General Public License for more details.
23
- *
24
- * You should have received a copy of the GNU Affero General Public License
25
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
26
- *
27
- */
28
- const humanList = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
29
- const humanListBinary = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB'];
30
- /**
31
- * Format a file size in a human-like format. e.g. 42GB
32
- *
33
- * @param size in bytes
34
- * @param skipSmallSizes avoid rendering tiny sizes and return '< 1 KB' instead
35
- */
36
- function formatFileSize(size, skipSmallSizes = false, binaryPrefixes = false) {
37
- if (typeof size === 'string') {
38
- size = Number(size);
39
- }
40
- /*
41
- * @note This block previously used Log base 1024, per IEC 80000-13;
42
- * however, the wrong prefix was used. Now we use decimal calculation
43
- * with base 1000 per the SI. Base 1024 calculation with binary
44
- * prefixes is optional, but has yet to be added to the UI.
45
- */
46
- // Calculate Log with base 1024 or 1000: size = base ** order
47
- let order = size > 0 ? Math.floor(Math.log(size) / Math.log(binaryPrefixes ? 1024 : 1000)) : 0;
48
- // Stay in range of the byte sizes that are defined
49
- order = Math.min((binaryPrefixes ? humanListBinary.length : humanList.length) - 1, order);
50
- const readableFormat = binaryPrefixes ? humanListBinary[order] : humanList[order];
51
- let relativeSize = (size / Math.pow(binaryPrefixes ? 1024 : 1000, order)).toFixed(1);
52
- if (skipSmallSizes === true && order === 0) {
53
- return (relativeSize !== '0.0' ? '< 1 ' : '0 ') + (binaryPrefixes ? humanListBinary[1] : humanList[1]);
54
- }
55
- if (order < 2) {
56
- relativeSize = parseFloat(relativeSize).toFixed(0);
57
- }
58
- else {
59
- relativeSize = parseFloat(relativeSize).toLocaleString(getCanonicalLocale());
60
- }
61
- return relativeSize + ' ' + readableFormat;
62
- }
63
-
64
- /**
65
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
66
- *
67
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
68
- *
69
- * @license AGPL-3.0-or-later
70
- *
71
- * This program is free software: you can redistribute it and/or modify
72
- * it under the terms of the GNU Affero General Public License as
73
- * published by the Free Software Foundation, either version 3 of the
74
- * License, or (at your option) any later version.
75
- *
76
- * This program is distributed in the hope that it will be useful,
77
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
78
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
79
- * GNU Affero General Public License for more details.
80
- *
81
- * You should have received a copy of the GNU Affero General Public License
82
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
83
- *
84
- */
85
- const getLogger = user => {
86
- if (user === null) {
87
- return getLoggerBuilder()
88
- .setApp('files')
89
- .build();
90
- }
91
- return getLoggerBuilder()
92
- .setApp('files')
93
- .setUid(user.uid)
94
- .build();
95
- };
96
- var logger = getLogger(getCurrentUser());
97
-
98
- /**
99
- * @copyright Copyright (c) 2021 John Molakvoæ <skjnldsv@protonmail.com>
100
- *
101
- * @author John Molakvoæ <skjnldsv@protonmail.com>
102
- *
103
- * @license AGPL-3.0-or-later
104
- *
105
- * This program is free software: you can redistribute it and/or modify
106
- * it under the terms of the GNU Affero General Public License as
107
- * published by the Free Software Foundation, either version 3 of the
108
- * License, or (at your option) any later version.
109
- *
110
- * This program is distributed in the hope that it will be useful,
111
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
112
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
113
- * GNU Affero General Public License for more details.
114
- *
115
- * You should have received a copy of the GNU Affero General Public License
116
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
117
- *
118
- */
119
- class NewFileMenu {
120
- _entries = [];
121
- registerEntry(entry) {
122
- this.validateEntry(entry);
123
- this._entries.push(entry);
124
- }
125
- unregisterEntry(entry) {
126
- const entryIndex = typeof entry === 'string'
127
- ? this.getEntryIndex(entry)
128
- : this.getEntryIndex(entry.id);
129
- if (entryIndex === -1) {
130
- logger.warn('Entry not found, nothing removed', { entry, entries: this.getEntries() });
131
- return;
132
- }
133
- this._entries.splice(entryIndex, 1);
134
- }
135
- /**
136
- * Get the list of registered entries
137
- *
138
- * @param {FileInfo} context the creation context. Usually the current folder FileInfo
139
- */
140
- getEntries(context) {
141
- if (context) {
142
- return this._entries
143
- .filter(entry => typeof entry.if === 'function' ? entry.if(context) : true);
144
- }
145
- return this._entries;
146
- }
147
- getEntryIndex(id) {
148
- return this._entries.findIndex(entry => entry.id === id);
149
- }
150
- validateEntry(entry) {
151
- if (!entry.id || !entry.displayName || !(entry.iconSvgInline || entry.iconClass)) {
152
- throw new Error('Invalid entry');
153
- }
154
- if (typeof entry.id !== 'string'
155
- || typeof entry.displayName !== 'string') {
156
- throw new Error('Invalid id or displayName property');
157
- }
158
- if ((entry.iconClass && typeof entry.iconClass !== 'string')
159
- || (entry.iconSvgInline && typeof entry.iconSvgInline !== 'string')) {
160
- throw new Error('Invalid icon provided');
161
- }
162
- if (entry.if !== undefined && typeof entry.if !== 'function') {
163
- throw new Error('Invalid if property');
164
- }
165
- if (entry.templateName && typeof entry.templateName !== 'string') {
166
- throw new Error('Invalid templateName property');
167
- }
168
- if (entry.handler && typeof entry.handler !== 'function') {
169
- throw new Error('Invalid handler property');
170
- }
171
- if (!entry.templateName && !entry.handler) {
172
- throw new Error('At least a templateName or a handler must be provided');
173
- }
174
- if (this.getEntryIndex(entry.id) !== -1) {
175
- throw new Error('Duplicate entry');
176
- }
177
- }
178
- }
179
- const getNewFileMenu = function () {
180
- if (typeof window._nc_newfilemenu === 'undefined') {
181
- window._nc_newfilemenu = new NewFileMenu();
182
- logger.debug('NewFileMenu initialized');
183
- }
184
- return window._nc_newfilemenu;
185
- };
186
-
187
- /**
188
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
189
- *
190
- * @author John Molakvoæ <skjnldsv@protonmail.com>
191
- *
192
- * @license AGPL-3.0-or-later
193
- *
194
- * This program is free software: you can redistribute it and/or modify
195
- * it under the terms of the GNU Affero General Public License as
196
- * published by the Free Software Foundation, either version 3 of the
197
- * License, or (at your option) any later version.
198
- *
199
- * This program is distributed in the hope that it will be useful,
200
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
201
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
202
- * GNU Affero General Public License for more details.
203
- *
204
- * You should have received a copy of the GNU Affero General Public License
205
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
206
- *
207
- */
208
- var FileType;
209
- (function (FileType) {
210
- FileType["Folder"] = "folder";
211
- FileType["File"] = "file";
212
- })(FileType || (FileType = {}));
213
-
214
- /**
215
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
216
- *
217
- * @author John Molakvoæ <skjnldsv@protonmail.com>
218
- *
219
- * @license AGPL-3.0-or-later
220
- *
221
- * This program is free software: you can redistribute it and/or modify
222
- * it under the terms of the GNU Affero General Public License as
223
- * published by the Free Software Foundation, either version 3 of the
224
- * License, or (at your option) any later version.
225
- *
226
- * This program is distributed in the hope that it will be useful,
227
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
228
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
229
- * GNU Affero General Public License for more details.
230
- *
231
- * You should have received a copy of the GNU Affero General Public License
232
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
233
- *
234
- */
235
- var Permission;
236
- (function (Permission) {
237
- Permission[Permission["NONE"] = 0] = "NONE";
238
- Permission[Permission["CREATE"] = 4] = "CREATE";
239
- Permission[Permission["READ"] = 1] = "READ";
240
- Permission[Permission["UPDATE"] = 2] = "UPDATE";
241
- Permission[Permission["DELETE"] = 8] = "DELETE";
242
- Permission[Permission["SHARE"] = 16] = "SHARE";
243
- Permission[Permission["ALL"] = 31] = "ALL";
244
- })(Permission || (Permission = {}));
245
- /**
246
- * Parse the webdav permission string to a permission enum
247
- * @see https://github.com/nextcloud/server/blob/71f698649f578db19a22457cb9d420fb62c10382/lib/public/Files/DavUtil.php#L58-L88
248
- */
249
- const parseWebdavPermissions = function (permString = '') {
250
- let permissions = Permission.NONE;
251
- if (!permString)
252
- return permissions;
253
- if (permString.includes('C') || permString.includes('K'))
254
- permissions |= Permission.CREATE;
255
- if (permString.includes('G'))
256
- permissions |= Permission.READ;
257
- if (permString.includes('W') || permString.includes('N') || permString.includes('V'))
258
- permissions |= Permission.UPDATE;
259
- if (permString.includes('D'))
260
- permissions |= Permission.DELETE;
261
- if (permString.includes('R'))
262
- permissions |= Permission.SHARE;
263
- return permissions;
264
- };
265
-
266
- /**
267
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
268
- *
269
- * @author John Molakvoæ <skjnldsv@protonmail.com>
270
- *
271
- * @license AGPL-3.0-or-later
272
- *
273
- * This program is free software: you can redistribute it and/or modify
274
- * it under the terms of the GNU Affero General Public License as
275
- * published by the Free Software Foundation, either version 3 of the
276
- * License, or (at your option) any later version.
277
- *
278
- * This program is distributed in the hope that it will be useful,
279
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
280
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
281
- * GNU Affero General Public License for more details.
282
- *
283
- * You should have received a copy of the GNU Affero General Public License
284
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
285
- *
286
- */
287
- /**
288
- * Validate Node construct data
289
- */
290
- const validateData = (data) => {
291
- if ('id' in data && (typeof data.id !== 'number' || data.id < 0)) {
292
- throw new Error('Invalid id type of value');
293
- }
294
- if (!data.source) {
295
- throw new Error('Missing mandatory source');
296
- }
297
- if (!data.source.startsWith('http')) {
298
- throw new Error('Invalid source format');
299
- }
300
- if ('mtime' in data && !(data.mtime instanceof Date)) {
301
- throw new Error('Invalid mtime type');
302
- }
303
- if ('crtime' in data && !(data.crtime instanceof Date)) {
304
- throw new Error('Invalid crtime type');
305
- }
306
- if (!data.mime || typeof data.mime !== 'string'
307
- || !data.mime.match(/^[-\w.]+\/[-+\w.]+$/gi)) {
308
- throw new Error('Missing or invalid mandatory mime');
309
- }
310
- if ('size' in data && typeof data.size !== 'number') {
311
- throw new Error('Invalid size type');
312
- }
313
- if ('permissions' in data && !(typeof data.permissions === 'number'
314
- && data.permissions >= Permission.NONE
315
- && data.permissions <= Permission.ALL)) {
316
- throw new Error('Invalid permissions');
317
- }
318
- if ('owner' in data
319
- && data.owner !== null
320
- && typeof data.owner !== 'string') {
321
- throw new Error('Invalid owner type');
322
- }
323
- if ('attributes' in data && typeof data.attributes !== 'object') {
324
- throw new Error('Invalid attributes format');
325
- }
326
- if ('root' in data && typeof data.root !== 'string') {
327
- throw new Error('Invalid root format');
328
- }
329
- if (data.root && !data.root.startsWith('/')) {
330
- throw new Error('Root must start with a leading slash');
331
- }
332
- };
333
-
334
- /**
335
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
336
- *
337
- * @author John Molakvoæ <skjnldsv@protonmail.com>
338
- *
339
- * @license AGPL-3.0-or-later
340
- *
341
- * This program is free software: you can redistribute it and/or modify
342
- * it under the terms of the GNU Affero General Public License as
343
- * published by the Free Software Foundation, either version 3 of the
344
- * License, or (at your option) any later version.
345
- *
346
- * This program is distributed in the hope that it will be useful,
347
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
348
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
349
- * GNU Affero General Public License for more details.
350
- *
351
- * You should have received a copy of the GNU Affero General Public License
352
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
353
- *
354
- */
355
- class Node {
356
- _data;
357
- _attributes;
358
- _knownDavService = /(remote|public)\.php\/(web)?dav/i;
359
- constructor(data, davService) {
360
- // Validate data
361
- validateData(data);
362
- this._data = data;
363
- this._attributes = data.attributes || {};
364
- delete this._data.attributes;
365
- if (davService) {
366
- this._knownDavService = davService;
367
- }
368
- }
369
- /**
370
- * Get the source url to this object
371
- */
372
- get source() {
373
- // strip any ending slash
374
- return this._data.source.replace(/\/$/i, '');
375
- }
376
- /**
377
- * Get this object name
378
- */
379
- get basename() {
380
- return basename(this.source);
381
- }
382
- /**
383
- * Get this object's extension
384
- */
385
- get extension() {
386
- return extname(this.source);
387
- }
388
- /**
389
- * Get the directory path leading to this object
390
- * Will use the relative path to root if available
391
- */
392
- get dirname() {
393
- if (this.root) {
394
- return dirname(this.source.split(this.root).pop() || '/');
395
- }
396
- return dirname(this.source);
397
- }
398
- /**
399
- * Get the file mime
400
- */
401
- get mime() {
402
- return this._data.mime;
403
- }
404
- /**
405
- * Get the file size
406
- */
407
- get size() {
408
- return this._data.size;
409
- }
410
- /**
411
- * Get the file attribute
412
- */
413
- get attributes() {
414
- return this._attributes;
415
- }
416
- /**
417
- * Get the file permissions
418
- */
419
- get permissions() {
420
- // If this is not a dav ressource, we can only read it
421
- if (this.owner === null && !this.isDavRessource) {
422
- return Permission.READ;
423
- }
424
- return this._data.permissions || Permission.READ;
425
- }
426
- /**
427
- * Get the file owner
428
- */
429
- get owner() {
430
- // Remote ressources have no owner
431
- if (!this.isDavRessource) {
432
- return null;
433
- }
434
- return this._data.owner;
435
- }
436
- /**
437
- * Is this a dav-related ressource ?
438
- */
439
- get isDavRessource() {
440
- return this.source.match(this._knownDavService) !== null;
441
- }
442
- /**
443
- * Get the dav root of this object
444
- */
445
- get root() {
446
- // If provided (recommended), use the root and strip away the ending slash
447
- if (this._data.root) {
448
- return this._data.root.replace(/^(.+)\/$/, '$1');
449
- }
450
- // Use the source to get the root from the dav service
451
- if (this.isDavRessource) {
452
- const root = dirname(this.source);
453
- return root.split(this._knownDavService).pop() || null;
454
- }
455
- return null;
456
- }
457
- /**
458
- * Get the absolute path of this object relative to the root
459
- */
460
- get path() {
461
- return (this.dirname + '/' + this.basename).replace(/\/\//g, '/');
462
- }
463
- /**
464
- * Get the file id if defined in attributes
465
- */
466
- get fileid() {
467
- return this.attributes?.fileid;
468
- }
469
- /**
470
- * Move the node to a new destination
471
- *
472
- * @param {string} destination the new source.
473
- * e.g. https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg
474
- */
475
- move(destination) {
476
- this._data.source = destination;
477
- }
478
- /**
479
- * Rename the node
480
- * This aliases the move method for easier usage
481
- */
482
- rename(basename) {
483
- if (basename.includes('/')) {
484
- throw new Error('Invalid basename');
485
- }
486
- this.move(dirname(this.source) + '/' + basename);
487
- }
488
- }
489
-
490
- /**
491
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
492
- *
493
- * @author John Molakvoæ <skjnldsv@protonmail.com>
494
- *
495
- * @license AGPL-3.0-or-later
496
- *
497
- * This program is free software: you can redistribute it and/or modify
498
- * it under the terms of the GNU Affero General Public License as
499
- * published by the Free Software Foundation, either version 3 of the
500
- * License, or (at your option) any later version.
501
- *
502
- * This program is distributed in the hope that it will be useful,
503
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
504
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
505
- * GNU Affero General Public License for more details.
506
- *
507
- * You should have received a copy of the GNU Affero General Public License
508
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
509
- *
510
- */
511
- class File extends Node {
512
- get type() {
513
- return FileType.File;
514
- }
515
- }
516
-
517
- /**
518
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
519
- *
520
- * @author John Molakvoæ <skjnldsv@protonmail.com>
521
- *
522
- * @license AGPL-3.0-or-later
523
- *
524
- * This program is free software: you can redistribute it and/or modify
525
- * it under the terms of the GNU Affero General Public License as
526
- * published by the Free Software Foundation, either version 3 of the
527
- * License, or (at your option) any later version.
528
- *
529
- * This program is distributed in the hope that it will be useful,
530
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
531
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
532
- * GNU Affero General Public License for more details.
533
- *
534
- * You should have received a copy of the GNU Affero General Public License
535
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
536
- *
537
- */
538
- class Folder extends Node {
539
- constructor(data) {
540
- // enforcing mimes
541
- super({
542
- ...data,
543
- mime: 'httpd/unix-directory'
544
- });
545
- }
546
- get type() {
547
- return FileType.Folder;
548
- }
549
- get extension() {
550
- return null;
551
- }
552
- get mime() {
553
- return 'httpd/unix-directory';
554
- }
555
- }
556
-
557
- /**
558
- * @copyright Copyright (c) 2021 John Molakvoæ <skjnldsv@protonmail.com>
559
- *
560
- * @author John Molakvoæ <skjnldsv@protonmail.com>
561
- *
562
- * @license AGPL-3.0-or-later
563
- *
564
- * This program is free software: you can redistribute it and/or modify
565
- * it under the terms of the GNU Affero General Public License as
566
- * published by the Free Software Foundation, either version 3 of the
567
- * License, or (at your option) any later version.
568
- *
569
- * This program is distributed in the hope that it will be useful,
570
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
571
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
572
- * GNU Affero General Public License for more details.
573
- *
574
- * You should have received a copy of the GNU Affero General Public License
575
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
576
- *
577
- */
578
- class FileAction {
579
- _action;
580
- constructor(action) {
581
- this.validateAction(action);
582
- this._action = action;
583
- }
584
- get id() {
585
- return this._action.id;
586
- }
587
- get displayName() {
588
- return this._action.displayName;
589
- }
590
- get iconSvgInline() {
591
- return this._action.iconSvgInline;
592
- }
593
- get enabled() {
594
- return this._action.enabled;
595
- }
596
- get exec() {
597
- return this._action.exec;
598
- }
599
- get execBatch() {
600
- return this._action.execBatch;
601
- }
602
- get order() {
603
- return this._action.order;
604
- }
605
- get default() {
606
- return this._action.default;
607
- }
608
- get inline() {
609
- return this._action.inline;
610
- }
611
- get renderInline() {
612
- return this._action.renderInline;
613
- }
614
- validateAction(action) {
615
- if (!action.id || typeof action.id !== 'string') {
616
- throw new Error('Invalid id');
617
- }
618
- if (!action.displayName || typeof action.displayName !== 'function') {
619
- throw new Error('Invalid displayName function');
620
- }
621
- if (!action.iconSvgInline || typeof action.iconSvgInline !== 'function') {
622
- throw new Error('Invalid iconSvgInline function');
623
- }
624
- if (!action.exec || typeof action.exec !== 'function') {
625
- throw new Error('Invalid exec function');
626
- }
627
- // Optional properties --------------------------------------------
628
- if ('enabled' in action && typeof action.enabled !== 'function') {
629
- throw new Error('Invalid enabled function');
630
- }
631
- if ('execBatch' in action && typeof action.execBatch !== 'function') {
632
- throw new Error('Invalid execBatch function');
633
- }
634
- if ('order' in action && typeof action.order !== 'number') {
635
- throw new Error('Invalid order');
636
- }
637
- if ('default' in action && typeof action.default !== 'boolean') {
638
- throw new Error('Invalid default');
639
- }
640
- if ('inline' in action && typeof action.inline !== 'function') {
641
- throw new Error('Invalid inline function');
642
- }
643
- if ('renderInline' in action && typeof action.renderInline !== 'function') {
644
- throw new Error('Invalid renderInline function');
645
- }
646
- }
647
- }
648
- const registerFileAction = function (action) {
649
- if (typeof window._nc_fileactions === 'undefined') {
650
- window._nc_fileactions = [];
651
- logger.debug('FileActions initialized');
652
- }
653
- // Check duplicates
654
- if (window._nc_fileactions.find(search => search.id === action.id)) {
655
- logger.error(`FileAction ${action.id} already registered`, { action });
656
- return;
657
- }
658
- window._nc_fileactions.push(action);
659
- };
660
- const getFileActions = function () {
661
- return window._nc_fileactions || [];
662
- };
663
-
664
- /**
665
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
666
- *
667
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
668
- * @author John Molakvoæ <skjnldsv@protonmail.com>
669
- *
670
- * @license AGPL-3.0-or-later
671
- *
672
- * This program is free software: you can redistribute it and/or modify
673
- * it under the terms of the GNU Affero General Public License as
674
- * published by the Free Software Foundation, either version 3 of the
675
- * License, or (at your option) any later version.
676
- *
677
- * This program is distributed in the hope that it will be useful,
678
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
679
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
680
- * GNU Affero General Public License for more details.
681
- *
682
- * You should have received a copy of the GNU Affero General Public License
683
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
684
- *
685
- */
686
- /**
687
- * Add a new menu entry to the upload manager menu
688
- */
689
- const addNewFileMenuEntry = function (entry) {
690
- const newFileMenu = getNewFileMenu();
691
- return newFileMenu.registerEntry(entry);
692
- };
693
- /**
694
- * Remove a previously registered entry from the upload menu
695
- */
696
- const removeNewFileMenuEntry = function (entry) {
697
- const newFileMenu = getNewFileMenu();
698
- return newFileMenu.unregisterEntry(entry);
699
- };
700
- /**
701
- * Get the list of registered entries from the upload menu
702
- *
703
- * @param {FileInfo} context the creation context. Usually the current folder FileInfo
704
- */
705
- const getNewFileMenuEntries = function (context) {
706
- const newFileMenu = getNewFileMenu();
707
- return newFileMenu.getEntries(context);
708
- };
709
-
710
- export { File, FileAction, FileType, Folder, Node, Permission, addNewFileMenuEntry, formatFileSize, getFileActions, getNewFileMenuEntries, parseWebdavPermissions, registerFileAction, removeNewFileMenuEntry };
711
- //# sourceMappingURL=index.esm.js.map