@nextcloud/files 3.4.1 → 3.5.1

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.cjs CHANGED
@@ -1,62 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const auth = require("@nextcloud/auth");
4
3
  const logger$1 = require("@nextcloud/logger");
4
+ const auth = require("@nextcloud/auth");
5
5
  const path = require("path");
6
6
  const paths = require("@nextcloud/paths");
7
7
  const router = require("@nextcloud/router");
8
- const webdav = require("webdav");
9
8
  const cancelablePromise = require("cancelable-promise");
9
+ const webdav = require("webdav");
10
+ const _public = require("@nextcloud/sharing/public");
10
11
  const l10n = require("@nextcloud/l10n");
11
- /**
12
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
13
- *
14
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
15
- *
16
- * @license AGPL-3.0-or-later
17
- *
18
- * This program is free software: you can redistribute it and/or modify
19
- * it under the terms of the GNU Affero General Public License as
20
- * published by the Free Software Foundation, either version 3 of the
21
- * License, or (at your option) any later version.
22
- *
23
- * This program is distributed in the hope that it will be useful,
24
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
25
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26
- * GNU Affero General Public License for more details.
27
- *
28
- * You should have received a copy of the GNU Affero General Public License
29
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
30
- *
31
- */
32
- const getLogger = (user) => {
33
- if (user === null) {
34
- return logger$1.getLoggerBuilder().setApp("files").build();
35
- }
36
- return logger$1.getLoggerBuilder().setApp("files").setUid(user.uid).build();
37
- };
38
- const logger = getLogger(auth.getCurrentUser());
39
- /**
40
- * @copyright Copyright (c) 2021 John Molakvoæ <skjnldsv@protonmail.com>
41
- *
42
- * @author John Molakvoæ <skjnldsv@protonmail.com>
43
- *
44
- * @license AGPL-3.0-or-later
45
- *
46
- * This program is free software: you can redistribute it and/or modify
47
- * it under the terms of the GNU Affero General Public License as
48
- * published by the Free Software Foundation, either version 3 of the
49
- * License, or (at your option) any later version.
50
- *
51
- * This program is distributed in the hope that it will be useful,
52
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
53
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
54
- * GNU Affero General Public License for more details.
55
- *
56
- * You should have received a copy of the GNU Affero General Public License
57
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
58
- *
59
- */
12
+ const typescriptEventTarget = require("typescript-event-target");
13
+ const logger = logger$1.getLoggerBuilder().setApp("@nextcloud/files").detectUser().build();
60
14
  var NewMenuEntryCategory = /* @__PURE__ */ ((NewMenuEntryCategory2) => {
61
15
  NewMenuEntryCategory2[NewMenuEntryCategory2["UploadFromDevice"] = 0] = "UploadFromDevice";
62
16
  NewMenuEntryCategory2[NewMenuEntryCategory2["CreateNew"] = 1] = "CreateNew";
@@ -123,27 +77,6 @@ const getNewFileMenu = function() {
123
77
  }
124
78
  return window._nc_newfilemenu;
125
79
  };
126
- /**
127
- * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
128
- *
129
- * @author John Molakvoæ <skjnldsv@protonmail.com>
130
- *
131
- * @license AGPL-3.0-or-later
132
- *
133
- * This program is free software: you can redistribute it and/or modify
134
- * it under the terms of the GNU Affero General Public License as
135
- * published by the Free Software Foundation, either version 3 of the
136
- * License, or (at your option) any later version.
137
- *
138
- * This program is distributed in the hope that it will be useful,
139
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
140
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
141
- * GNU Affero General Public License for more details.
142
- *
143
- * You should have received a copy of the GNU Affero General Public License
144
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
145
- *
146
- */
147
80
  var DefaultType = /* @__PURE__ */ ((DefaultType2) => {
148
81
  DefaultType2["DEFAULT"] = "default";
149
82
  DefaultType2["HIDDEN"] = "hidden";
@@ -248,27 +181,6 @@ const getFileActions = function() {
248
181
  }
249
182
  return window._nc_fileactions;
250
183
  };
251
- /**
252
- * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
253
- *
254
- * @author John Molakvoæ <skjnldsv@protonmail.com>
255
- *
256
- * @license AGPL-3.0-or-later
257
- *
258
- * This program is free software: you can redistribute it and/or modify
259
- * it under the terms of the GNU Affero General Public License as
260
- * published by the Free Software Foundation, either version 3 of the
261
- * License, or (at your option) any later version.
262
- *
263
- * This program is distributed in the hope that it will be useful,
264
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
265
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
266
- * GNU Affero General Public License for more details.
267
- *
268
- * You should have received a copy of the GNU Affero General Public License
269
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
270
- *
271
- */
272
184
  class Header {
273
185
  _header;
274
186
  constructor(header) {
@@ -326,27 +238,6 @@ const getFileListHeaders = function() {
326
238
  }
327
239
  return window._nc_filelistheader;
328
240
  };
329
- /**
330
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
331
- *
332
- * @author John Molakvoæ <skjnldsv@protonmail.com>
333
- *
334
- * @license AGPL-3.0-or-later
335
- *
336
- * This program is free software: you can redistribute it and/or modify
337
- * it under the terms of the GNU Affero General Public License as
338
- * published by the Free Software Foundation, either version 3 of the
339
- * License, or (at your option) any later version.
340
- *
341
- * This program is distributed in the hope that it will be useful,
342
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
343
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
344
- * GNU Affero General Public License for more details.
345
- *
346
- * You should have received a copy of the GNU Affero General Public License
347
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
348
- *
349
- */
350
241
  var Permission = /* @__PURE__ */ ((Permission2) => {
351
242
  Permission2[Permission2["NONE"] = 0] = "NONE";
352
243
  Permission2[Permission2["CREATE"] = 4] = "CREATE";
@@ -357,33 +248,13 @@ var Permission = /* @__PURE__ */ ((Permission2) => {
357
248
  Permission2[Permission2["ALL"] = 31] = "ALL";
358
249
  return Permission2;
359
250
  })(Permission || {});
360
- /**
361
- * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
362
- *
363
- * @author John Molakvoæ <skjnldsv@protonmail.com>
364
- * @author Ferdinand Thiessen <opensource@fthiessen.de>
365
- *
366
- * @license AGPL-3.0-or-later
367
- *
368
- * This program is free software: you can redistribute it and/or modify
369
- * it under the terms of the GNU Affero General Public License as
370
- * published by the Free Software Foundation, either version 3 of the
371
- * License, or (at your option) any later version.
372
- *
373
- * This program is distributed in the hope that it will be useful,
374
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
375
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376
- * GNU Affero General Public License for more details.
377
- *
378
- * You should have received a copy of the GNU Affero General Public License
379
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
380
- *
381
- */
382
251
  const defaultDavProperties = [
383
252
  "d:getcontentlength",
384
253
  "d:getcontenttype",
385
254
  "d:getetag",
386
255
  "d:getlastmodified",
256
+ "d:creationdate",
257
+ "d:displayname",
387
258
  "d:quota-available-bytes",
388
259
  "d:resourcetype",
389
260
  "nc:has-preview",
@@ -514,28 +385,6 @@ const davGetRecentSearch = function(lastModified) {
514
385
  </d:basicsearch>
515
386
  </d:searchrequest>`;
516
387
  };
517
- /**
518
- * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
519
- *
520
- * @author John Molakvoæ <skjnldsv@protonmail.com>
521
- * @author Ferdinand Thiessen <opensource@fthiessen.de>
522
- *
523
- * @license AGPL-3.0-or-later
524
- *
525
- * This program is free software: you can redistribute it and/or modify
526
- * it under the terms of the GNU Affero General Public License as
527
- * published by the Free Software Foundation, either version 3 of the
528
- * License, or (at your option) any later version.
529
- *
530
- * This program is distributed in the hope that it will be useful,
531
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
532
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
533
- * GNU Affero General Public License for more details.
534
- *
535
- * You should have received a copy of the GNU Affero General Public License
536
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
537
- *
538
- */
539
388
  const davParsePermissions = function(permString = "") {
540
389
  let permissions = Permission.NONE;
541
390
  if (!permString) {
@@ -558,53 +407,11 @@ const davParsePermissions = function(permString = "") {
558
407
  }
559
408
  return permissions;
560
409
  };
561
- /**
562
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
563
- *
564
- * @author John Molakvoæ <skjnldsv@protonmail.com>
565
- *
566
- * @license AGPL-3.0-or-later
567
- *
568
- * This program is free software: you can redistribute it and/or modify
569
- * it under the terms of the GNU Affero General Public License as
570
- * published by the Free Software Foundation, either version 3 of the
571
- * License, or (at your option) any later version.
572
- *
573
- * This program is distributed in the hope that it will be useful,
574
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
575
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
576
- * GNU Affero General Public License for more details.
577
- *
578
- * You should have received a copy of the GNU Affero General Public License
579
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
580
- *
581
- */
582
410
  var FileType = /* @__PURE__ */ ((FileType2) => {
583
411
  FileType2["Folder"] = "folder";
584
412
  FileType2["File"] = "file";
585
413
  return FileType2;
586
414
  })(FileType || {});
587
- /**
588
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
589
- *
590
- * @author John Molakvoæ <skjnldsv@protonmail.com>
591
- *
592
- * @license AGPL-3.0-or-later
593
- *
594
- * This program is free software: you can redistribute it and/or modify
595
- * it under the terms of the GNU Affero General Public License as
596
- * published by the Free Software Foundation, either version 3 of the
597
- * License, or (at your option) any later version.
598
- *
599
- * This program is distributed in the hope that it will be useful,
600
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
601
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
602
- * GNU Affero General Public License for more details.
603
- *
604
- * You should have received a copy of the GNU Affero General Public License
605
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
606
- *
607
- */
608
415
  const isDavRessource = function(source, davService) {
609
416
  return source.match(davService) !== null;
610
417
  };
@@ -663,27 +470,6 @@ const validateData = (data, davService) => {
663
470
  throw new Error("Status must be a valid NodeStatus");
664
471
  }
665
472
  };
666
- /**
667
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
668
- *
669
- * @author John Molakvoæ <skjnldsv@protonmail.com>
670
- *
671
- * @license AGPL-3.0-or-later
672
- *
673
- * This program is free software: you can redistribute it and/or modify
674
- * it under the terms of the GNU Affero General Public License as
675
- * published by the Free Software Foundation, either version 3 of the
676
- * License, or (at your option) any later version.
677
- *
678
- * This program is distributed in the hope that it will be useful,
679
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
680
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
681
- * GNU Affero General Public License for more details.
682
- *
683
- * You should have received a copy of the GNU Affero General Public License
684
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
685
- *
686
- */
687
473
  var NodeStatus = /* @__PURE__ */ ((NodeStatus2) => {
688
474
  NodeStatus2["NEW"] = "new";
689
475
  NodeStatus2["FAILED"] = "failed";
@@ -958,53 +744,11 @@ class Node {
958
744
  }
959
745
  }
960
746
  }
961
- /**
962
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
963
- *
964
- * @author John Molakvoæ <skjnldsv@protonmail.com>
965
- *
966
- * @license AGPL-3.0-or-later
967
- *
968
- * This program is free software: you can redistribute it and/or modify
969
- * it under the terms of the GNU Affero General Public License as
970
- * published by the Free Software Foundation, either version 3 of the
971
- * License, or (at your option) any later version.
972
- *
973
- * This program is distributed in the hope that it will be useful,
974
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
975
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
976
- * GNU Affero General Public License for more details.
977
- *
978
- * You should have received a copy of the GNU Affero General Public License
979
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
980
- *
981
- */
982
747
  class File extends Node {
983
748
  get type() {
984
749
  return FileType.File;
985
750
  }
986
751
  }
987
- /**
988
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
989
- *
990
- * @author John Molakvoæ <skjnldsv@protonmail.com>
991
- *
992
- * @license AGPL-3.0-or-later
993
- *
994
- * This program is free software: you can redistribute it and/or modify
995
- * it under the terms of the GNU Affero General Public License as
996
- * published by the Free Software Foundation, either version 3 of the
997
- * License, or (at your option) any later version.
998
- *
999
- * This program is distributed in the hope that it will be useful,
1000
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1001
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1002
- * GNU Affero General Public License for more details.
1003
- *
1004
- * You should have received a copy of the GNU Affero General Public License
1005
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1006
- *
1007
- */
1008
752
  class Folder extends Node {
1009
753
  constructor(data) {
1010
754
  super({
@@ -1022,30 +766,21 @@ class Folder extends Node {
1022
766
  return "httpd/unix-directory";
1023
767
  }
1024
768
  }
1025
- /**
1026
- * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
1027
- *
1028
- * @author John Molakvoæ <skjnldsv@protonmail.com>
1029
- * @author Ferdinand Thiessen <opensource@fthiessen.de>
1030
- *
1031
- * @license AGPL-3.0-or-later
1032
- *
1033
- * This program is free software: you can redistribute it and/or modify
1034
- * it under the terms of the GNU Affero General Public License as
1035
- * published by the Free Software Foundation, either version 3 of the
1036
- * License, or (at your option) any later version.
1037
- *
1038
- * This program is distributed in the hope that it will be useful,
1039
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1040
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1041
- * GNU Affero General Public License for more details.
1042
- *
1043
- * You should have received a copy of the GNU Affero General Public License
1044
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1045
- *
1046
- */
1047
- const davRootPath = `/files/${auth.getCurrentUser()?.uid}`;
1048
- const davRemoteURL = router.generateRemoteUrl("dav");
769
+ function davGetRootPath() {
770
+ if (_public.isPublicShare()) {
771
+ return `/files/${_public.getSharingToken()}`;
772
+ }
773
+ return `/files/${auth.getCurrentUser()?.uid}`;
774
+ }
775
+ const davRootPath = davGetRootPath();
776
+ function davGetRemoteURL() {
777
+ const url = router.generateRemoteUrl("dav");
778
+ if (_public.isPublicShare()) {
779
+ return url.replace("remote.php", "public.php");
780
+ }
781
+ return url;
782
+ }
783
+ const davRemoteURL = davGetRemoteURL();
1049
784
  const davGetClient = function(remoteURL = davRemoteURL, headers = {}) {
1050
785
  const client = webdav.createClient(remoteURL, { headers });
1051
786
  function setHeaders(token) {
@@ -1094,9 +829,7 @@ const getFavoriteNodes = (davClient, path2 = "/", davRoot = davRootPath) => {
1094
829
  };
1095
830
  const davResultToNode = function(node, filesRoot = davRootPath, remoteURL = davRemoteURL) {
1096
831
  let userId = auth.getCurrentUser()?.uid;
1097
- const isPublic = document.querySelector("input#isPublic")?.value;
1098
- if (isPublic) {
1099
- userId = userId ?? document.querySelector("input#sharingUserId")?.value;
832
+ if (_public.isPublicShare()) {
1100
833
  userId = userId ?? "anonymous";
1101
834
  } else if (!userId) {
1102
835
  throw new Error("No user id found");
@@ -1104,12 +837,15 @@ const davResultToNode = function(node, filesRoot = davRootPath, remoteURL = davR
1104
837
  const props = node.props;
1105
838
  const permissions = davParsePermissions(props?.permissions);
1106
839
  const owner = String(props?.["owner-id"] || userId);
840
+ const id = props.fileid || 0;
1107
841
  const nodeData = {
1108
- id: props?.fileid || 0,
842
+ id,
1109
843
  source: `${remoteURL}${node.filename}`,
1110
844
  mtime: new Date(Date.parse(node.lastmod)),
1111
845
  mime: node.mime || "application/octet-stream",
1112
846
  size: props?.size || Number.parseInt(props.getcontentlength || "0"),
847
+ // The fileid is set to -1 for failed requests
848
+ status: id < 0 ? NodeStatus.FAILED : void 0,
1113
849
  permissions,
1114
850
  owner,
1115
851
  root: filesRoot,
@@ -1133,28 +869,21 @@ function isFilenameValid(filename) {
1133
869
  }
1134
870
  return true;
1135
871
  }
1136
- /**
1137
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
1138
- *
1139
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
1140
- * @author John Molakvoæ <skjnldsv@protonmail.com>
1141
- *
1142
- * @license AGPL-3.0-or-later
1143
- *
1144
- * This program is free software: you can redistribute it and/or modify
1145
- * it under the terms of the GNU Affero General Public License as
1146
- * published by the Free Software Foundation, either version 3 of the
1147
- * License, or (at your option) any later version.
1148
- *
1149
- * This program is distributed in the hope that it will be useful,
1150
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1151
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1152
- * GNU Affero General Public License for more details.
1153
- *
1154
- * You should have received a copy of the GNU Affero General Public License
1155
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1156
- *
1157
- */
872
+ function getUniqueName(name, otherNames, options) {
873
+ const opts = {
874
+ suffix: (n) => `(${n})`,
875
+ ignoreFileExtension: false,
876
+ ...options
877
+ };
878
+ let newName = name;
879
+ let i = 1;
880
+ while (otherNames.includes(newName)) {
881
+ const ext = opts.ignoreFileExtension ? "" : path.extname(name);
882
+ const base = path.basename(name, ext);
883
+ newName = `${base} ${opts.suffix(i++)}${ext}`;
884
+ }
885
+ return newName;
886
+ }
1158
887
  const humanList = ["B", "KB", "MB", "GB", "TB", "PB"];
1159
888
  const humanListBinary = ["B", "KiB", "MiB", "GiB", "TiB", "PiB"];
1160
889
  function formatFileSize(size, skipSmallSizes = false, binaryPrefixes = false, base1000 = false) {
@@ -1241,15 +970,16 @@ function sortNodes(nodes, options = {}) {
1241
970
  sortingOrder: "asc",
1242
971
  ...options
1243
972
  };
973
+ const basename = (name) => name.lastIndexOf(".") > 0 ? name.slice(0, name.lastIndexOf(".")) : name;
1244
974
  const identifiers = [
1245
975
  // 1: Sort favorites first if enabled
1246
976
  ...sortingOptions.sortFavoritesFirst ? [(v) => v.attributes?.favorite !== 1] : [],
1247
977
  // 2: Sort folders first if sorting by name
1248
978
  ...sortingOptions.sortFoldersFirst ? [(v) => v.type !== "folder"] : [],
1249
- // 3: Use sorting mode if NOT basename (to be able to use displayName too)
979
+ // 3: Use sorting mode if NOT basename (to be able to use displayname too)
1250
980
  ...sortingOptions.sortingMode !== "basename" ? [(v) => v[sortingOptions.sortingMode]] : [],
1251
- // 4: Use displayName if available, fallback to name
1252
- (v) => v.attributes?.displayName || v.basename,
981
+ // 4: Use displayname if available, fallback to name
982
+ (v) => basename(v.attributes?.displayname || v.basename),
1253
983
  // 5: Finally, use basename if all previous sorting methods failed
1254
984
  (v) => v.basename
1255
985
  ];
@@ -1269,51 +999,54 @@ function sortNodes(nodes, options = {}) {
1269
999
  ];
1270
1000
  return orderBy(nodes, identifiers, orders);
1271
1001
  }
1272
- /**
1273
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
1274
- *
1275
- * @author John Molakvoæ <skjnldsv@protonmail.com>
1276
- *
1277
- * @license AGPL-3.0-or-later
1278
- *
1279
- * This program is free software: you can redistribute it and/or modify
1280
- * it under the terms of the GNU Affero General Public License as
1281
- * published by the Free Software Foundation, either version 3 of the
1282
- * License, or (at your option) any later version.
1283
- *
1284
- * This program is distributed in the hope that it will be useful,
1285
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1286
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1287
- * GNU Affero General Public License for more details.
1288
- *
1289
- * You should have received a copy of the GNU Affero General Public License
1290
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1291
- *
1292
- */
1293
- class Navigation {
1002
+ class Navigation extends typescriptEventTarget.TypedEventTarget {
1294
1003
  _views = [];
1295
1004
  _currentView = null;
1005
+ /**
1006
+ * Register a new view on the navigation
1007
+ * @param view The view to register
1008
+ * @throws `Error` is thrown if a view with the same id is already registered
1009
+ */
1296
1010
  register(view) {
1297
1011
  if (this._views.find((search) => search.id === view.id)) {
1298
1012
  throw new Error(`View id ${view.id} is already registered`);
1299
1013
  }
1300
1014
  this._views.push(view);
1015
+ this.dispatchTypedEvent("update", new CustomEvent("update"));
1301
1016
  }
1017
+ /**
1018
+ * Remove a registered view
1019
+ * @param id The id of the view to remove
1020
+ */
1302
1021
  remove(id) {
1303
1022
  const index = this._views.findIndex((view) => view.id === id);
1304
1023
  if (index !== -1) {
1305
1024
  this._views.splice(index, 1);
1025
+ this.dispatchTypedEvent("update", new CustomEvent("update"));
1306
1026
  }
1307
1027
  }
1308
- get views() {
1309
- return this._views;
1310
- }
1028
+ /**
1029
+ * Set the currently active view
1030
+ * @fires UpdateActiveViewEvent
1031
+ * @param view New active view
1032
+ */
1311
1033
  setActive(view) {
1312
1034
  this._currentView = view;
1035
+ const event = new CustomEvent("updateActive", { detail: view });
1036
+ this.dispatchTypedEvent("updateActive", event);
1313
1037
  }
1038
+ /**
1039
+ * The currently active files view
1040
+ */
1314
1041
  get active() {
1315
1042
  return this._currentView;
1316
1043
  }
1044
+ /**
1045
+ * All registered views
1046
+ */
1047
+ get views() {
1048
+ return this._views;
1049
+ }
1317
1050
  }
1318
1051
  const getNavigation = function() {
1319
1052
  if (typeof window._nc_navigation === "undefined") {
@@ -1322,27 +1055,6 @@ const getNavigation = function() {
1322
1055
  }
1323
1056
  return window._nc_navigation;
1324
1057
  };
1325
- /**
1326
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
1327
- *
1328
- * @author John Molakvoæ <skjnldsv@protonmail.com>
1329
- *
1330
- * @license AGPL-3.0-or-later
1331
- *
1332
- * This program is free software: you can redistribute it and/or modify
1333
- * it under the terms of the GNU Affero General Public License as
1334
- * published by the Free Software Foundation, either version 3 of the
1335
- * License, or (at your option) any later version.
1336
- *
1337
- * This program is distributed in the hope that it will be useful,
1338
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1339
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1340
- * GNU Affero General Public License for more details.
1341
- *
1342
- * You should have received a copy of the GNU Affero General Public License
1343
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1344
- *
1345
- */
1346
1058
  class Column {
1347
1059
  _column;
1348
1060
  constructor(column) {
@@ -1457,8 +1169,7 @@ validator$2.validate = function(xmlData, options) {
1457
1169
  if (xmlData[i] === "<" && xmlData[i + 1] === "?") {
1458
1170
  i += 2;
1459
1171
  i = readPI(xmlData, i);
1460
- if (i.err)
1461
- return i;
1172
+ if (i.err) return i;
1462
1173
  } else if (xmlData[i] === "<") {
1463
1174
  let tagStartPos = i;
1464
1175
  i++;
@@ -1532,8 +1243,7 @@ validator$2.validate = function(xmlData, options) {
1532
1243
  }
1533
1244
  if (reachedRoot === true) {
1534
1245
  return getErrorObject("InvalidXml", "Multiple possible root nodes found.", getLineNumberForPosition(xmlData, i));
1535
- } else if (options.unpairedTags.indexOf(tagName) !== -1)
1536
- ;
1246
+ } else if (options.unpairedTags.indexOf(tagName) !== -1) ;
1537
1247
  else {
1538
1248
  tags.push({ tagName, tagStartPos });
1539
1249
  }
@@ -1547,8 +1257,7 @@ validator$2.validate = function(xmlData, options) {
1547
1257
  continue;
1548
1258
  } else if (xmlData[i + 1] === "?") {
1549
1259
  i = readPI(xmlData, ++i);
1550
- if (i.err)
1551
- return i;
1260
+ if (i.err) return i;
1552
1261
  } else {
1553
1262
  break;
1554
1263
  }
@@ -1643,8 +1352,7 @@ function readAttributeStr(xmlData, i) {
1643
1352
  if (xmlData[i] === doubleQuote || xmlData[i] === singleQuote) {
1644
1353
  if (startChar === "") {
1645
1354
  startChar = xmlData[i];
1646
- } else if (startChar !== xmlData[i])
1647
- ;
1355
+ } else if (startChar !== xmlData[i]) ;
1648
1356
  else {
1649
1357
  startChar = "";
1650
1358
  }
@@ -1805,13 +1513,11 @@ class XmlNode {
1805
1513
  this[":@"] = {};
1806
1514
  }
1807
1515
  add(key, val2) {
1808
- if (key === "__proto__")
1809
- key = "#__proto__";
1516
+ if (key === "__proto__") key = "#__proto__";
1810
1517
  this.child.push({ [key]: val2 });
1811
1518
  }
1812
1519
  addChild(node) {
1813
- if (node.tagname === "__proto__")
1814
- node.tagname = "#__proto__";
1520
+ if (node.tagname === "__proto__") node.tagname = "#__proto__";
1815
1521
  if (node[":@"] && Object.keys(node[":@"]).length > 0) {
1816
1522
  this.child.push({ [node.tagname]: node.child, [":@"]: node[":@"] });
1817
1523
  } else {
@@ -1838,16 +1544,11 @@ function readDocType$1(xmlData, i) {
1838
1544
  regx: RegExp(`&${entityName};`, "g"),
1839
1545
  val
1840
1546
  };
1841
- } else if (hasBody && isElement(xmlData, i))
1842
- i += 8;
1843
- else if (hasBody && isAttlist(xmlData, i))
1844
- i += 8;
1845
- else if (hasBody && isNotation(xmlData, i))
1846
- i += 9;
1847
- else if (isComment)
1848
- comment = true;
1849
- else
1850
- throw new Error("Invalid DOCTYPE");
1547
+ } else if (hasBody && isElement(xmlData, i)) i += 8;
1548
+ else if (hasBody && isAttlist(xmlData, i)) i += 8;
1549
+ else if (hasBody && isNotation(xmlData, i)) i += 9;
1550
+ else if (isComment) comment = true;
1551
+ else throw new Error("Invalid DOCTYPE");
1851
1552
  angleBracketsCount++;
1852
1553
  exp = "";
1853
1554
  } else if (xmlData[i] === ">") {
@@ -1882,8 +1583,7 @@ function readEntityExp(xmlData, i) {
1882
1583
  entityName2 += xmlData[i];
1883
1584
  }
1884
1585
  entityName2 = entityName2.trim();
1885
- if (entityName2.indexOf(" ") !== -1)
1886
- throw new Error("External entites are not supported");
1586
+ if (entityName2.indexOf(" ") !== -1) throw new Error("External entites are not supported");
1887
1587
  const startChar = xmlData[i++];
1888
1588
  let val2 = "";
1889
1589
  for (; i < xmlData.length && xmlData[i] !== startChar; i++) {
@@ -1892,28 +1592,23 @@ function readEntityExp(xmlData, i) {
1892
1592
  return [entityName2, val2, i];
1893
1593
  }
1894
1594
  function isComment(xmlData, i) {
1895
- if (xmlData[i + 1] === "!" && xmlData[i + 2] === "-" && xmlData[i + 3] === "-")
1896
- return true;
1595
+ if (xmlData[i + 1] === "!" && xmlData[i + 2] === "-" && xmlData[i + 3] === "-") return true;
1897
1596
  return false;
1898
1597
  }
1899
1598
  function isEntity(xmlData, i) {
1900
- if (xmlData[i + 1] === "!" && xmlData[i + 2] === "E" && xmlData[i + 3] === "N" && xmlData[i + 4] === "T" && xmlData[i + 5] === "I" && xmlData[i + 6] === "T" && xmlData[i + 7] === "Y")
1901
- return true;
1599
+ if (xmlData[i + 1] === "!" && xmlData[i + 2] === "E" && xmlData[i + 3] === "N" && xmlData[i + 4] === "T" && xmlData[i + 5] === "I" && xmlData[i + 6] === "T" && xmlData[i + 7] === "Y") return true;
1902
1600
  return false;
1903
1601
  }
1904
1602
  function isElement(xmlData, i) {
1905
- if (xmlData[i + 1] === "!" && xmlData[i + 2] === "E" && xmlData[i + 3] === "L" && xmlData[i + 4] === "E" && xmlData[i + 5] === "M" && xmlData[i + 6] === "E" && xmlData[i + 7] === "N" && xmlData[i + 8] === "T")
1906
- return true;
1603
+ if (xmlData[i + 1] === "!" && xmlData[i + 2] === "E" && xmlData[i + 3] === "L" && xmlData[i + 4] === "E" && xmlData[i + 5] === "M" && xmlData[i + 6] === "E" && xmlData[i + 7] === "N" && xmlData[i + 8] === "T") return true;
1907
1604
  return false;
1908
1605
  }
1909
1606
  function isAttlist(xmlData, i) {
1910
- if (xmlData[i + 1] === "!" && xmlData[i + 2] === "A" && xmlData[i + 3] === "T" && xmlData[i + 4] === "T" && xmlData[i + 5] === "L" && xmlData[i + 6] === "I" && xmlData[i + 7] === "S" && xmlData[i + 8] === "T")
1911
- return true;
1607
+ if (xmlData[i + 1] === "!" && xmlData[i + 2] === "A" && xmlData[i + 3] === "T" && xmlData[i + 4] === "T" && xmlData[i + 5] === "L" && xmlData[i + 6] === "I" && xmlData[i + 7] === "S" && xmlData[i + 8] === "T") return true;
1912
1608
  return false;
1913
1609
  }
1914
1610
  function isNotation(xmlData, i) {
1915
- if (xmlData[i + 1] === "!" && xmlData[i + 2] === "N" && xmlData[i + 3] === "O" && xmlData[i + 4] === "T" && xmlData[i + 5] === "A" && xmlData[i + 6] === "T" && xmlData[i + 7] === "I" && xmlData[i + 8] === "O" && xmlData[i + 9] === "N")
1916
- return true;
1611
+ if (xmlData[i + 1] === "!" && xmlData[i + 2] === "N" && xmlData[i + 3] === "O" && xmlData[i + 4] === "T" && xmlData[i + 5] === "A" && xmlData[i + 6] === "T" && xmlData[i + 7] === "I" && xmlData[i + 8] === "O" && xmlData[i + 9] === "N") return true;
1917
1612
  return false;
1918
1613
  }
1919
1614
  function validateEntityName(name) {
@@ -1940,11 +1635,9 @@ const consider = {
1940
1635
  };
1941
1636
  function toNumber$1(str, options = {}) {
1942
1637
  options = Object.assign({}, consider, options);
1943
- if (!str || typeof str !== "string")
1944
- return str;
1638
+ if (!str || typeof str !== "string") return str;
1945
1639
  let trimmedStr = str.trim();
1946
- if (options.skipLike !== void 0 && options.skipLike.test(trimmedStr))
1947
- return str;
1640
+ if (options.skipLike !== void 0 && options.skipLike.test(trimmedStr)) return str;
1948
1641
  else if (options.hex && hexRegex.test(trimmedStr)) {
1949
1642
  return Number.parseInt(trimmedStr, 16);
1950
1643
  } else {
@@ -1954,45 +1647,30 @@ function toNumber$1(str, options = {}) {
1954
1647
  const leadingZeros = match[2];
1955
1648
  let numTrimmedByZeros = trimZeros(match[3]);
1956
1649
  const eNotation = match[4] || match[6];
1957
- if (!options.leadingZeros && leadingZeros.length > 0 && sign && trimmedStr[2] !== ".")
1958
- return str;
1959
- else if (!options.leadingZeros && leadingZeros.length > 0 && !sign && trimmedStr[1] !== ".")
1960
- return str;
1650
+ if (!options.leadingZeros && leadingZeros.length > 0 && sign && trimmedStr[2] !== ".") return str;
1651
+ else if (!options.leadingZeros && leadingZeros.length > 0 && !sign && trimmedStr[1] !== ".") return str;
1961
1652
  else {
1962
1653
  const num = Number(trimmedStr);
1963
1654
  const numStr = "" + num;
1964
1655
  if (numStr.search(/[eE]/) !== -1) {
1965
- if (options.eNotation)
1966
- return num;
1967
- else
1968
- return str;
1656
+ if (options.eNotation) return num;
1657
+ else return str;
1969
1658
  } else if (eNotation) {
1970
- if (options.eNotation)
1971
- return num;
1972
- else
1973
- return str;
1659
+ if (options.eNotation) return num;
1660
+ else return str;
1974
1661
  } else if (trimmedStr.indexOf(".") !== -1) {
1975
- if (numStr === "0" && numTrimmedByZeros === "")
1976
- return num;
1977
- else if (numStr === numTrimmedByZeros)
1978
- return num;
1979
- else if (sign && numStr === "-" + numTrimmedByZeros)
1980
- return num;
1981
- else
1982
- return str;
1662
+ if (numStr === "0" && numTrimmedByZeros === "") return num;
1663
+ else if (numStr === numTrimmedByZeros) return num;
1664
+ else if (sign && numStr === "-" + numTrimmedByZeros) return num;
1665
+ else return str;
1983
1666
  }
1984
1667
  if (leadingZeros) {
1985
- if (numTrimmedByZeros === numStr)
1986
- return num;
1987
- else if (sign + numTrimmedByZeros === numStr)
1988
- return num;
1989
- else
1990
- return str;
1668
+ if (numTrimmedByZeros === numStr) return num;
1669
+ else if (sign + numTrimmedByZeros === numStr) return num;
1670
+ else return str;
1991
1671
  }
1992
- if (trimmedStr === numStr)
1993
- return num;
1994
- else if (trimmedStr === sign + numStr)
1995
- return num;
1672
+ if (trimmedStr === numStr) return num;
1673
+ else if (trimmedStr === sign + numStr) return num;
1996
1674
  return str;
1997
1675
  }
1998
1676
  } else {
@@ -2003,12 +1681,9 @@ function toNumber$1(str, options = {}) {
2003
1681
  function trimZeros(numStr) {
2004
1682
  if (numStr && numStr.indexOf(".") !== -1) {
2005
1683
  numStr = numStr.replace(/0+$/, "");
2006
- if (numStr === ".")
2007
- numStr = "0";
2008
- else if (numStr[0] === ".")
2009
- numStr = "0" + numStr;
2010
- else if (numStr[numStr.length - 1] === ".")
2011
- numStr = numStr.substr(0, numStr.length - 1);
1684
+ if (numStr === ".") numStr = "0";
1685
+ else if (numStr[0] === ".") numStr = "0" + numStr;
1686
+ else if (numStr[numStr.length - 1] === ".") numStr = numStr.substr(0, numStr.length - 1);
2012
1687
  return numStr;
2013
1688
  }
2014
1689
  return numStr;
@@ -2076,8 +1751,7 @@ function parseTextData(val2, tagName, jPath, dontTrim, hasAttributes, isLeafNode
2076
1751
  val2 = val2.trim();
2077
1752
  }
2078
1753
  if (val2.length > 0) {
2079
- if (!escapeEntities)
2080
- val2 = this.replaceEntitiesValue(val2);
1754
+ if (!escapeEntities) val2 = this.replaceEntitiesValue(val2);
2081
1755
  const newval = this.options.tagValueProcessor(tagName, val2, jPath, hasAttributes, isLeafNode);
2082
1756
  if (newval === null || newval === void 0) {
2083
1757
  return val2;
@@ -2123,8 +1797,7 @@ function buildAttributesMap(attrStr, jPath, tagName) {
2123
1797
  if (this.options.transformAttributeName) {
2124
1798
  aName = this.options.transformAttributeName(aName);
2125
1799
  }
2126
- if (aName === "__proto__")
2127
- aName = "#__proto__";
1800
+ if (aName === "__proto__") aName = "#__proto__";
2128
1801
  if (oldVal !== void 0) {
2129
1802
  if (this.options.trimValues) {
2130
1803
  oldVal = oldVal.trim();
@@ -2199,11 +1872,9 @@ const parseXml = function(xmlData) {
2199
1872
  i = closeIndex;
2200
1873
  } else if (xmlData[i + 1] === "?") {
2201
1874
  let tagData = readTagExp(xmlData, i, false, "?>");
2202
- if (!tagData)
2203
- throw new Error("Pi Tag is not closed.");
1875
+ if (!tagData) throw new Error("Pi Tag is not closed.");
2204
1876
  textData = this.saveTextToParentTag(textData, currentNode, jPath);
2205
- if (this.options.ignoreDeclaration && tagData.tagName === "?xml" || this.options.ignorePiTags)
2206
- ;
1877
+ if (this.options.ignoreDeclaration && tagData.tagName === "?xml" || this.options.ignorePiTags) ;
2207
1878
  else {
2208
1879
  const childNode = new xmlNode(tagData.tagName);
2209
1880
  childNode.add(this.options.textNodeName, "");
@@ -2230,8 +1901,7 @@ const parseXml = function(xmlData) {
2230
1901
  const tagExp = xmlData.substring(i + 9, closeIndex);
2231
1902
  textData = this.saveTextToParentTag(textData, currentNode, jPath);
2232
1903
  let val2 = this.parseTextData(tagExp, currentNode.tagname, jPath, true, false, true, true);
2233
- if (val2 == void 0)
2234
- val2 = "";
1904
+ if (val2 == void 0) val2 = "";
2235
1905
  if (this.options.cdataPropName) {
2236
1906
  currentNode.add(this.options.cdataPropName, [{ [this.options.textNodeName]: tagExp }]);
2237
1907
  } else {
@@ -2276,8 +1946,7 @@ const parseXml = function(xmlData) {
2276
1946
  i = result.closeIndex;
2277
1947
  } else {
2278
1948
  const result2 = this.readStopNodeData(xmlData, rawTagName, closeIndex + 1);
2279
- if (!result2)
2280
- throw new Error(`Unexpected end of ${rawTagName}`);
1949
+ if (!result2) throw new Error(`Unexpected end of ${rawTagName}`);
2281
1950
  i = result2.i;
2282
1951
  tagContent = result2.tagContent;
2283
1952
  }
@@ -2330,8 +1999,7 @@ const parseXml = function(xmlData) {
2330
1999
  };
2331
2000
  function addChild(currentNode, childNode, jPath) {
2332
2001
  const result = this.options.updateTag(childNode.tagname, jPath, childNode[":@"]);
2333
- if (result === false)
2334
- ;
2002
+ if (result === false) ;
2335
2003
  else if (typeof result === "string") {
2336
2004
  childNode.tagname = result;
2337
2005
  currentNode.addChild(childNode);
@@ -2361,8 +2029,7 @@ const replaceEntitiesValue$1 = function(val2) {
2361
2029
  };
2362
2030
  function saveTextToParentTag(textData, currentNode, jPath, isLeafNode) {
2363
2031
  if (textData) {
2364
- if (isLeafNode === void 0)
2365
- isLeafNode = Object.keys(currentNode.child).length === 0;
2032
+ if (isLeafNode === void 0) isLeafNode = Object.keys(currentNode.child).length === 0;
2366
2033
  textData = this.parseTextData(
2367
2034
  textData,
2368
2035
  currentNode.tagname,
@@ -2381,8 +2048,7 @@ function isItStopNode(stopNodes, jPath, currentTagName) {
2381
2048
  const allNodesExp = "*." + currentTagName;
2382
2049
  for (const stopNodePath in stopNodes) {
2383
2050
  const stopNodeExp = stopNodes[stopNodePath];
2384
- if (allNodesExp === stopNodeExp || jPath === stopNodeExp)
2385
- return true;
2051
+ if (allNodesExp === stopNodeExp || jPath === stopNodeExp) return true;
2386
2052
  }
2387
2053
  return false;
2388
2054
  }
@@ -2392,8 +2058,7 @@ function tagExpWithClosingIndex(xmlData, i, closingChar = ">") {
2392
2058
  for (let index = i; index < xmlData.length; index++) {
2393
2059
  let ch = xmlData[index];
2394
2060
  if (attrBoundary) {
2395
- if (ch === attrBoundary)
2396
- attrBoundary = "";
2061
+ if (ch === attrBoundary) attrBoundary = "";
2397
2062
  } else if (ch === '"' || ch === "'") {
2398
2063
  attrBoundary = ch;
2399
2064
  } else if (ch === closingChar[0]) {
@@ -2426,8 +2091,7 @@ function findClosingIndex(xmlData, str, i, errMsg) {
2426
2091
  }
2427
2092
  function readTagExp(xmlData, i, removeNSPrefix, closingChar = ">") {
2428
2093
  const result = tagExpWithClosingIndex(xmlData, i + 1, closingChar);
2429
- if (!result)
2430
- return;
2094
+ if (!result) return;
2431
2095
  let tagExp = result.data;
2432
2096
  const closeIndex = result.index;
2433
2097
  const separatorIndex = tagExp.search(/\s/);
@@ -2496,12 +2160,9 @@ function readStopNodeData(xmlData, tagName, i) {
2496
2160
  function parseValue(val2, shouldParse, options) {
2497
2161
  if (shouldParse && typeof val2 === "string") {
2498
2162
  const newval = val2.trim();
2499
- if (newval === "true")
2500
- return true;
2501
- else if (newval === "false")
2502
- return false;
2503
- else
2504
- return toNumber(val2, options);
2163
+ if (newval === "true") return true;
2164
+ else if (newval === "false") return false;
2165
+ else return toNumber(val2, options);
2505
2166
  } else {
2506
2167
  if (util.isExist(val2)) {
2507
2168
  return val2;
@@ -2522,15 +2183,11 @@ function compress(arr, options, jPath) {
2522
2183
  const tagObj = arr[i];
2523
2184
  const property = propName$1(tagObj);
2524
2185
  let newJpath = "";
2525
- if (jPath === void 0)
2526
- newJpath = property;
2527
- else
2528
- newJpath = jPath + "." + property;
2186
+ if (jPath === void 0) newJpath = property;
2187
+ else newJpath = jPath + "." + property;
2529
2188
  if (property === options.textNodeName) {
2530
- if (text === void 0)
2531
- text = tagObj[property];
2532
- else
2533
- text += "" + tagObj[property];
2189
+ if (text === void 0) text = tagObj[property];
2190
+ else text += "" + tagObj[property];
2534
2191
  } else if (property === void 0) {
2535
2192
  continue;
2536
2193
  } else if (tagObj[property]) {
@@ -2541,10 +2198,8 @@ function compress(arr, options, jPath) {
2541
2198
  } else if (Object.keys(val2).length === 1 && val2[options.textNodeName] !== void 0 && !options.alwaysCreateTextNode) {
2542
2199
  val2 = val2[options.textNodeName];
2543
2200
  } else if (Object.keys(val2).length === 0) {
2544
- if (options.alwaysCreateTextNode)
2545
- val2[options.textNodeName] = "";
2546
- else
2547
- val2 = "";
2201
+ if (options.alwaysCreateTextNode) val2[options.textNodeName] = "";
2202
+ else val2 = "";
2548
2203
  }
2549
2204
  if (compressedObj[property] !== void 0 && compressedObj.hasOwnProperty(property)) {
2550
2205
  if (!Array.isArray(compressedObj[property])) {
@@ -2561,18 +2216,15 @@ function compress(arr, options, jPath) {
2561
2216
  }
2562
2217
  }
2563
2218
  if (typeof text === "string") {
2564
- if (text.length > 0)
2565
- compressedObj[options.textNodeName] = text;
2566
- } else if (text !== void 0)
2567
- compressedObj[options.textNodeName] = text;
2219
+ if (text.length > 0) compressedObj[options.textNodeName] = text;
2220
+ } else if (text !== void 0) compressedObj[options.textNodeName] = text;
2568
2221
  return compressedObj;
2569
2222
  }
2570
2223
  function propName$1(obj) {
2571
2224
  const keys = Object.keys(obj);
2572
2225
  for (let i = 0; i < keys.length; i++) {
2573
2226
  const key = keys[i];
2574
- if (key !== ":@")
2575
- return key;
2227
+ if (key !== ":@") return key;
2576
2228
  }
2577
2229
  }
2578
2230
  function assignAttributes(obj, attrMap, jpath, options) {
@@ -2616,16 +2268,14 @@ let XMLParser$1 = class XMLParser {
2616
2268
  * @param {boolean|Object} validationOption
2617
2269
  */
2618
2270
  parse(xmlData, validationOption) {
2619
- if (typeof xmlData === "string")
2620
- ;
2271
+ if (typeof xmlData === "string") ;
2621
2272
  else if (xmlData.toString) {
2622
2273
  xmlData = xmlData.toString();
2623
2274
  } else {
2624
2275
  throw new Error("XML data is accepted in String or Bytes[] form.");
2625
2276
  }
2626
2277
  if (validationOption) {
2627
- if (validationOption === true)
2628
- validationOption = {};
2278
+ if (validationOption === true) validationOption = {};
2629
2279
  const result = validator$1.validate(xmlData, validationOption);
2630
2280
  if (result !== true) {
2631
2281
  throw Error(`${result.err.msg}:${result.err.line}:${result.err.col}`);
@@ -2634,10 +2284,8 @@ let XMLParser$1 = class XMLParser {
2634
2284
  const orderedObjParser = new OrderedObjParser2(this.options);
2635
2285
  orderedObjParser.addExternalEntities(this.externalEntities);
2636
2286
  const orderedResult = orderedObjParser.parseXml(xmlData);
2637
- if (this.options.preserveOrder || orderedResult === void 0)
2638
- return orderedResult;
2639
- else
2640
- return prettify(orderedResult, this.options);
2287
+ if (this.options.preserveOrder || orderedResult === void 0) return orderedResult;
2288
+ else return prettify(orderedResult, this.options);
2641
2289
  }
2642
2290
  /**
2643
2291
  * Add Entity which is not by default supported by this library
@@ -2671,13 +2319,10 @@ function arrToStr(arr, options, jPath, indentation) {
2671
2319
  for (let i = 0; i < arr.length; i++) {
2672
2320
  const tagObj = arr[i];
2673
2321
  const tagName = propName(tagObj);
2674
- if (tagName === void 0)
2675
- continue;
2322
+ if (tagName === void 0) continue;
2676
2323
  let newJPath = "";
2677
- if (jPath.length === 0)
2678
- newJPath = tagName;
2679
- else
2680
- newJPath = `${jPath}.${tagName}`;
2324
+ if (jPath.length === 0) newJPath = tagName;
2325
+ else newJPath = `${jPath}.${tagName}`;
2681
2326
  if (tagName === options.textNodeName) {
2682
2327
  let tagText = tagObj[tagName];
2683
2328
  if (!isStopNode(newJPath, options)) {
@@ -2718,10 +2363,8 @@ function arrToStr(arr, options, jPath, indentation) {
2718
2363
  const tagStart = indentation + `<${tagName}${attStr}`;
2719
2364
  const tagValue = arrToStr(tagObj[tagName], options, newJPath, newIdentation);
2720
2365
  if (options.unpairedTags.indexOf(tagName) !== -1) {
2721
- if (options.suppressUnpairedNode)
2722
- xmlStr += tagStart + ">";
2723
- else
2724
- xmlStr += tagStart + "/>";
2366
+ if (options.suppressUnpairedNode) xmlStr += tagStart + ">";
2367
+ else xmlStr += tagStart + "/>";
2725
2368
  } else if ((!tagValue || tagValue.length === 0) && options.suppressEmptyNode) {
2726
2369
  xmlStr += tagStart + "/>";
2727
2370
  } else if (tagValue && tagValue.endsWith(">")) {
@@ -2743,18 +2386,15 @@ function propName(obj) {
2743
2386
  const keys = Object.keys(obj);
2744
2387
  for (let i = 0; i < keys.length; i++) {
2745
2388
  const key = keys[i];
2746
- if (!obj.hasOwnProperty(key))
2747
- continue;
2748
- if (key !== ":@")
2749
- return key;
2389
+ if (!obj.hasOwnProperty(key)) continue;
2390
+ if (key !== ":@") return key;
2750
2391
  }
2751
2392
  }
2752
2393
  function attr_to_str(attrMap, options) {
2753
2394
  let attrStr = "";
2754
2395
  if (attrMap && !options.ignoreAttributes) {
2755
2396
  for (let attr in attrMap) {
2756
- if (!attrMap.hasOwnProperty(attr))
2757
- continue;
2397
+ if (!attrMap.hasOwnProperty(attr)) continue;
2758
2398
  let attrVal = options.attributeValueProcessor(attr, attrMap[attr]);
2759
2399
  attrVal = replaceEntitiesValue(attrVal, options);
2760
2400
  if (attrVal === true && options.suppressBooleanAttributes) {
@@ -2770,8 +2410,7 @@ function isStopNode(jPath, options) {
2770
2410
  jPath = jPath.substr(0, jPath.length - options.textNodeName.length - 1);
2771
2411
  let tagName = jPath.substr(jPath.lastIndexOf(".") + 1);
2772
2412
  for (let index in options.stopNodes) {
2773
- if (options.stopNodes[index] === jPath || options.stopNodes[index] === "*." + tagName)
2774
- return true;
2413
+ if (options.stopNodes[index] === jPath || options.stopNodes[index] === "*." + tagName) return true;
2775
2414
  }
2776
2415
  return false;
2777
2416
  }
@@ -2859,8 +2498,7 @@ Builder.prototype.j2x = function(jObj, level) {
2859
2498
  let attrStr = "";
2860
2499
  let val2 = "";
2861
2500
  for (let key in jObj) {
2862
- if (!Object.prototype.hasOwnProperty.call(jObj, key))
2863
- continue;
2501
+ if (!Object.prototype.hasOwnProperty.call(jObj, key)) continue;
2864
2502
  if (typeof jObj[key] === "undefined") {
2865
2503
  if (this.isAttribute(key)) {
2866
2504
  val2 += "";
@@ -2892,13 +2530,10 @@ Builder.prototype.j2x = function(jObj, level) {
2892
2530
  let listTagVal = "";
2893
2531
  for (let j = 0; j < arrLen; j++) {
2894
2532
  const item = jObj[key][j];
2895
- if (typeof item === "undefined")
2896
- ;
2533
+ if (typeof item === "undefined") ;
2897
2534
  else if (item === null) {
2898
- if (key[0] === "?")
2899
- val2 += this.indentate(level) + "<" + key + "?" + this.tagEndChar;
2900
- else
2901
- val2 += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
2535
+ if (key[0] === "?") val2 += this.indentate(level) + "<" + key + "?" + this.tagEndChar;
2536
+ else val2 += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
2902
2537
  } else if (typeof item === "object") {
2903
2538
  if (this.options.oneListGroup) {
2904
2539
  listTagVal += this.j2x(item, level + 1).val;
@@ -2932,8 +2567,7 @@ Builder.prototype.buildAttrPairStr = function(attrName, val2) {
2932
2567
  val2 = this.replaceEntitiesValue(val2);
2933
2568
  if (this.options.suppressBooleanAttributes && val2 === "true") {
2934
2569
  return " " + attrName;
2935
- } else
2936
- return " " + attrName + '="' + val2 + '"';
2570
+ } else return " " + attrName + '="' + val2 + '"';
2937
2571
  };
2938
2572
  function processTextOrObjNode(object, key, level) {
2939
2573
  const result = this.j2x(object, level + 1);
@@ -2945,8 +2579,7 @@ function processTextOrObjNode(object, key, level) {
2945
2579
  }
2946
2580
  Builder.prototype.buildObjectNode = function(val2, key, attrStr, level) {
2947
2581
  if (val2 === "") {
2948
- if (key[0] === "?")
2949
- return this.indentate(level) + "<" + key + attrStr + "?" + this.tagEndChar;
2582
+ if (key[0] === "?") return this.indentate(level) + "<" + key + attrStr + "?" + this.tagEndChar;
2950
2583
  else {
2951
2584
  return this.indentate(level) + "<" + key + attrStr + this.closeTag(key) + this.tagEndChar;
2952
2585
  }
@@ -2969,8 +2602,7 @@ Builder.prototype.buildObjectNode = function(val2, key, attrStr, level) {
2969
2602
  Builder.prototype.closeTag = function(key) {
2970
2603
  let closeTag = "";
2971
2604
  if (this.options.unpairedTags.indexOf(key) !== -1) {
2972
- if (!this.options.suppressUnpairedNode)
2973
- closeTag = "/";
2605
+ if (!this.options.suppressUnpairedNode) closeTag = "/";
2974
2606
  } else if (this.options.suppressEmptyNode) {
2975
2607
  closeTag = "/";
2976
2608
  } else {
@@ -3049,27 +2681,6 @@ function isSvg(string) {
3049
2681
  }
3050
2682
  return true;
3051
2683
  }
3052
- /**
3053
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
3054
- *
3055
- * @author John Molakvoæ <skjnldsv@protonmail.com>
3056
- *
3057
- * @license AGPL-3.0-or-later
3058
- *
3059
- * This program is free software: you can redistribute it and/or modify
3060
- * it under the terms of the GNU Affero General Public License as
3061
- * published by the Free Software Foundation, either version 3 of the
3062
- * License, or (at your option) any later version.
3063
- *
3064
- * This program is distributed in the hope that it will be useful,
3065
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3066
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3067
- * GNU Affero General Public License for more details.
3068
- *
3069
- * You should have received a copy of the GNU Affero General Public License
3070
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
3071
- *
3072
- */
3073
2684
  class View {
3074
2685
  _view;
3075
2686
  constructor(view) {
@@ -3177,28 +2788,6 @@ const isValidView = function(view) {
3177
2788
  }
3178
2789
  return true;
3179
2790
  };
3180
- /**
3181
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
3182
- *
3183
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
3184
- * @author John Molakvoæ <skjnldsv@protonmail.com>
3185
- *
3186
- * @license AGPL-3.0-or-later
3187
- *
3188
- * This program is free software: you can redistribute it and/or modify
3189
- * it under the terms of the GNU Affero General Public License as
3190
- * published by the Free Software Foundation, either version 3 of the
3191
- * License, or (at your option) any later version.
3192
- *
3193
- * This program is distributed in the hope that it will be useful,
3194
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3195
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3196
- * GNU Affero General Public License for more details.
3197
- *
3198
- * You should have received a copy of the GNU Affero General Public License
3199
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
3200
- *
3201
- */
3202
2791
  const addNewFileMenuEntry = function(entry) {
3203
2792
  const newFileMenu = getNewFileMenu();
3204
2793
  return newFileMenu.registerEntry(entry);
@@ -3235,6 +2824,8 @@ exports.davGetClient = davGetClient;
3235
2824
  exports.davGetDefaultPropfind = davGetDefaultPropfind;
3236
2825
  exports.davGetFavoritesReport = davGetFavoritesReport;
3237
2826
  exports.davGetRecentSearch = davGetRecentSearch;
2827
+ exports.davGetRemoteURL = davGetRemoteURL;
2828
+ exports.davGetRootPath = davGetRootPath;
3238
2829
  exports.davParsePermissions = davParsePermissions;
3239
2830
  exports.davRemoteURL = davRemoteURL;
3240
2831
  exports.davResultToNode = davResultToNode;
@@ -3249,6 +2840,7 @@ exports.getFileActions = getFileActions;
3249
2840
  exports.getFileListHeaders = getFileListHeaders;
3250
2841
  exports.getNavigation = getNavigation;
3251
2842
  exports.getNewFileMenuEntries = getNewFileMenuEntries;
2843
+ exports.getUniqueName = getUniqueName;
3252
2844
  exports.isFilenameValid = isFilenameValid;
3253
2845
  exports.orderBy = orderBy;
3254
2846
  exports.parseFileSize = parseFileSize;