@nextcloud/files 3.4.0 → 3.5.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.mjs CHANGED
@@ -6,27 +6,7 @@ import { generateRemoteUrl } from "@nextcloud/router";
6
6
  import { createClient, getPatcher } from "webdav";
7
7
  import { CancelablePromise } from "cancelable-promise";
8
8
  import { getCanonicalLocale, getLanguage } from "@nextcloud/l10n";
9
- /**
10
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
11
- *
12
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
13
- *
14
- * @license AGPL-3.0-or-later
15
- *
16
- * This program is free software: you can redistribute it and/or modify
17
- * it under the terms of the GNU Affero General Public License as
18
- * published by the Free Software Foundation, either version 3 of the
19
- * License, or (at your option) any later version.
20
- *
21
- * This program is distributed in the hope that it will be useful,
22
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- * GNU Affero General Public License for more details.
25
- *
26
- * You should have received a copy of the GNU Affero General Public License
27
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
28
- *
29
- */
9
+ import { TypedEventTarget } from "typescript-event-target";
30
10
  const getLogger = (user) => {
31
11
  if (user === null) {
32
12
  return getLoggerBuilder().setApp("files").build();
@@ -34,27 +14,6 @@ const getLogger = (user) => {
34
14
  return getLoggerBuilder().setApp("files").setUid(user.uid).build();
35
15
  };
36
16
  const logger = getLogger(getCurrentUser());
37
- /**
38
- * @copyright Copyright (c) 2021 John Molakvoæ <skjnldsv@protonmail.com>
39
- *
40
- * @author John Molakvoæ <skjnldsv@protonmail.com>
41
- *
42
- * @license AGPL-3.0-or-later
43
- *
44
- * This program is free software: you can redistribute it and/or modify
45
- * it under the terms of the GNU Affero General Public License as
46
- * published by the Free Software Foundation, either version 3 of the
47
- * License, or (at your option) any later version.
48
- *
49
- * This program is distributed in the hope that it will be useful,
50
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
51
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
52
- * GNU Affero General Public License for more details.
53
- *
54
- * You should have received a copy of the GNU Affero General Public License
55
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
56
- *
57
- */
58
17
  var NewMenuEntryCategory = /* @__PURE__ */ ((NewMenuEntryCategory2) => {
59
18
  NewMenuEntryCategory2[NewMenuEntryCategory2["UploadFromDevice"] = 0] = "UploadFromDevice";
60
19
  NewMenuEntryCategory2[NewMenuEntryCategory2["CreateNew"] = 1] = "CreateNew";
@@ -121,27 +80,6 @@ const getNewFileMenu = function() {
121
80
  }
122
81
  return window._nc_newfilemenu;
123
82
  };
124
- /**
125
- * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
126
- *
127
- * @author John Molakvoæ <skjnldsv@protonmail.com>
128
- *
129
- * @license AGPL-3.0-or-later
130
- *
131
- * This program is free software: you can redistribute it and/or modify
132
- * it under the terms of the GNU Affero General Public License as
133
- * published by the Free Software Foundation, either version 3 of the
134
- * License, or (at your option) any later version.
135
- *
136
- * This program is distributed in the hope that it will be useful,
137
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
138
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
139
- * GNU Affero General Public License for more details.
140
- *
141
- * You should have received a copy of the GNU Affero General Public License
142
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
143
- *
144
- */
145
83
  var DefaultType = /* @__PURE__ */ ((DefaultType2) => {
146
84
  DefaultType2["DEFAULT"] = "default";
147
85
  DefaultType2["HIDDEN"] = "hidden";
@@ -246,27 +184,6 @@ const getFileActions = function() {
246
184
  }
247
185
  return window._nc_fileactions;
248
186
  };
249
- /**
250
- * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
251
- *
252
- * @author John Molakvoæ <skjnldsv@protonmail.com>
253
- *
254
- * @license AGPL-3.0-or-later
255
- *
256
- * This program is free software: you can redistribute it and/or modify
257
- * it under the terms of the GNU Affero General Public License as
258
- * published by the Free Software Foundation, either version 3 of the
259
- * License, or (at your option) any later version.
260
- *
261
- * This program is distributed in the hope that it will be useful,
262
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
263
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
264
- * GNU Affero General Public License for more details.
265
- *
266
- * You should have received a copy of the GNU Affero General Public License
267
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
268
- *
269
- */
270
187
  class Header {
271
188
  _header;
272
189
  constructor(header) {
@@ -324,27 +241,6 @@ const getFileListHeaders = function() {
324
241
  }
325
242
  return window._nc_filelistheader;
326
243
  };
327
- /**
328
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
329
- *
330
- * @author John Molakvoæ <skjnldsv@protonmail.com>
331
- *
332
- * @license AGPL-3.0-or-later
333
- *
334
- * This program is free software: you can redistribute it and/or modify
335
- * it under the terms of the GNU Affero General Public License as
336
- * published by the Free Software Foundation, either version 3 of the
337
- * License, or (at your option) any later version.
338
- *
339
- * This program is distributed in the hope that it will be useful,
340
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
341
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
342
- * GNU Affero General Public License for more details.
343
- *
344
- * You should have received a copy of the GNU Affero General Public License
345
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
346
- *
347
- */
348
244
  var Permission = /* @__PURE__ */ ((Permission2) => {
349
245
  Permission2[Permission2["NONE"] = 0] = "NONE";
350
246
  Permission2[Permission2["CREATE"] = 4] = "CREATE";
@@ -355,28 +251,6 @@ var Permission = /* @__PURE__ */ ((Permission2) => {
355
251
  Permission2[Permission2["ALL"] = 31] = "ALL";
356
252
  return Permission2;
357
253
  })(Permission || {});
358
- /**
359
- * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
360
- *
361
- * @author John Molakvoæ <skjnldsv@protonmail.com>
362
- * @author Ferdinand Thiessen <opensource@fthiessen.de>
363
- *
364
- * @license AGPL-3.0-or-later
365
- *
366
- * This program is free software: you can redistribute it and/or modify
367
- * it under the terms of the GNU Affero General Public License as
368
- * published by the Free Software Foundation, either version 3 of the
369
- * License, or (at your option) any later version.
370
- *
371
- * This program is distributed in the hope that it will be useful,
372
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
373
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
374
- * GNU Affero General Public License for more details.
375
- *
376
- * You should have received a copy of the GNU Affero General Public License
377
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
378
- *
379
- */
380
254
  const defaultDavProperties = [
381
255
  "d:getcontentlength",
382
256
  "d:getcontenttype",
@@ -512,28 +386,6 @@ const davGetRecentSearch = function(lastModified) {
512
386
  </d:basicsearch>
513
387
  </d:searchrequest>`;
514
388
  };
515
- /**
516
- * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
517
- *
518
- * @author John Molakvoæ <skjnldsv@protonmail.com>
519
- * @author Ferdinand Thiessen <opensource@fthiessen.de>
520
- *
521
- * @license AGPL-3.0-or-later
522
- *
523
- * This program is free software: you can redistribute it and/or modify
524
- * it under the terms of the GNU Affero General Public License as
525
- * published by the Free Software Foundation, either version 3 of the
526
- * License, or (at your option) any later version.
527
- *
528
- * This program is distributed in the hope that it will be useful,
529
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
530
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
531
- * GNU Affero General Public License for more details.
532
- *
533
- * You should have received a copy of the GNU Affero General Public License
534
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
535
- *
536
- */
537
389
  const davParsePermissions = function(permString = "") {
538
390
  let permissions = Permission.NONE;
539
391
  if (!permString) {
@@ -556,53 +408,6 @@ const davParsePermissions = function(permString = "") {
556
408
  }
557
409
  return permissions;
558
410
  };
559
- /**
560
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
561
- *
562
- * @author John Molakvoæ <skjnldsv@protonmail.com>
563
- *
564
- * @license AGPL-3.0-or-later
565
- *
566
- * This program is free software: you can redistribute it and/or modify
567
- * it under the terms of the GNU Affero General Public License as
568
- * published by the Free Software Foundation, either version 3 of the
569
- * License, or (at your option) any later version.
570
- *
571
- * This program is distributed in the hope that it will be useful,
572
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
573
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
574
- * GNU Affero General Public License for more details.
575
- *
576
- * You should have received a copy of the GNU Affero General Public License
577
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
578
- *
579
- */
580
- var FileType = /* @__PURE__ */ ((FileType2) => {
581
- FileType2["Folder"] = "folder";
582
- FileType2["File"] = "file";
583
- return FileType2;
584
- })(FileType || {});
585
- /**
586
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
587
- *
588
- * @author John Molakvoæ <skjnldsv@protonmail.com>
589
- *
590
- * @license AGPL-3.0-or-later
591
- *
592
- * This program is free software: you can redistribute it and/or modify
593
- * it under the terms of the GNU Affero General Public License as
594
- * published by the Free Software Foundation, either version 3 of the
595
- * License, or (at your option) any later version.
596
- *
597
- * This program is distributed in the hope that it will be useful,
598
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
599
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
600
- * GNU Affero General Public License for more details.
601
- *
602
- * You should have received a copy of the GNU Affero General Public License
603
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
604
- *
605
- */
606
411
  const isDavRessource = function(source, davService) {
607
412
  return source.match(davService) !== null;
608
413
  };
@@ -661,27 +466,6 @@ const validateData = (data, davService) => {
661
466
  throw new Error("Status must be a valid NodeStatus");
662
467
  }
663
468
  };
664
- /**
665
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
666
- *
667
- * @author John Molakvoæ <skjnldsv@protonmail.com>
668
- *
669
- * @license AGPL-3.0-or-later
670
- *
671
- * This program is free software: you can redistribute it and/or modify
672
- * it under the terms of the GNU Affero General Public License as
673
- * published by the Free Software Foundation, either version 3 of the
674
- * License, or (at your option) any later version.
675
- *
676
- * This program is distributed in the hope that it will be useful,
677
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
678
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
679
- * GNU Affero General Public License for more details.
680
- *
681
- * You should have received a copy of the GNU Affero General Public License
682
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
683
- *
684
- */
685
469
  var NodeStatus = /* @__PURE__ */ ((NodeStatus2) => {
686
470
  NodeStatus2["NEW"] = "new";
687
471
  NodeStatus2["FAILED"] = "failed";
@@ -699,14 +483,12 @@ class Node {
699
483
  if (this.readonlyAttributes.includes(prop)) {
700
484
  return false;
701
485
  }
702
- this.updateMtime();
703
486
  return Reflect.set(target, prop, value);
704
487
  },
705
488
  deleteProperty: (target, prop) => {
706
489
  if (this.readonlyAttributes.includes(prop)) {
707
490
  return false;
708
491
  }
709
- this.updateMtime();
710
492
  return Reflect.deleteProperty(target, prop);
711
493
  },
712
494
  // TODO: This is deprecated and only needed for files v3
@@ -723,7 +505,6 @@ class Node {
723
505
  this._data = { ...data, attributes: {} };
724
506
  this._attributes = new Proxy(this._data.attributes, this.handler);
725
507
  this.update(data.attributes ?? {});
726
- this._data.mtime = data.mtime;
727
508
  if (davService) {
728
509
  this._knownDavService = davService;
729
510
  }
@@ -788,12 +569,16 @@ class Node {
788
569
  }
789
570
  /**
790
571
  * Get the file modification time
791
- * There is no setter as the modification time is not meant to be changed manually.
792
- * It will be automatically updated when the attributes are changed.
793
572
  */
794
573
  get mtime() {
795
574
  return this._data.mtime;
796
575
  }
576
+ /**
577
+ * Set the file modification time
578
+ */
579
+ set mtime(mtime) {
580
+ this._data.mtime = mtime;
581
+ }
797
582
  /**
798
583
  * Get the file creation time
799
584
  * There is no setter as the creation time is not meant to be changed
@@ -925,7 +710,7 @@ class Node {
925
710
  this.move(dirname(this.source) + "/" + basename2);
926
711
  }
927
712
  /**
928
- * Update the mtime if exists.
713
+ * Update the mtime if exists
929
714
  */
930
715
  updateMtime() {
931
716
  if (this._data.mtime) {
@@ -934,6 +719,7 @@ class Node {
934
719
  }
935
720
  /**
936
721
  * Update the attributes of the node
722
+ * Warning, updating attributes will NOT automatically update the mtime.
937
723
  *
938
724
  * @param attributes The new attributes to update on the Node attributes
939
725
  */
@@ -954,53 +740,16 @@ class Node {
954
740
  }
955
741
  }
956
742
  }
957
- /**
958
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
959
- *
960
- * @author John Molakvoæ <skjnldsv@protonmail.com>
961
- *
962
- * @license AGPL-3.0-or-later
963
- *
964
- * This program is free software: you can redistribute it and/or modify
965
- * it under the terms of the GNU Affero General Public License as
966
- * published by the Free Software Foundation, either version 3 of the
967
- * License, or (at your option) any later version.
968
- *
969
- * This program is distributed in the hope that it will be useful,
970
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
971
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
972
- * GNU Affero General Public License for more details.
973
- *
974
- * You should have received a copy of the GNU Affero General Public License
975
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
976
- *
977
- */
743
+ var FileType = /* @__PURE__ */ ((FileType2) => {
744
+ FileType2["Folder"] = "folder";
745
+ FileType2["File"] = "file";
746
+ return FileType2;
747
+ })(FileType || {});
978
748
  class File extends Node {
979
749
  get type() {
980
750
  return FileType.File;
981
751
  }
982
752
  }
983
- /**
984
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
985
- *
986
- * @author John Molakvoæ <skjnldsv@protonmail.com>
987
- *
988
- * @license AGPL-3.0-or-later
989
- *
990
- * This program is free software: you can redistribute it and/or modify
991
- * it under the terms of the GNU Affero General Public License as
992
- * published by the Free Software Foundation, either version 3 of the
993
- * License, or (at your option) any later version.
994
- *
995
- * This program is distributed in the hope that it will be useful,
996
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
997
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
998
- * GNU Affero General Public License for more details.
999
- *
1000
- * You should have received a copy of the GNU Affero General Public License
1001
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1002
- *
1003
- */
1004
753
  class Folder extends Node {
1005
754
  constructor(data) {
1006
755
  super({
@@ -1018,28 +767,6 @@ class Folder extends Node {
1018
767
  return "httpd/unix-directory";
1019
768
  }
1020
769
  }
1021
- /**
1022
- * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
1023
- *
1024
- * @author John Molakvoæ <skjnldsv@protonmail.com>
1025
- * @author Ferdinand Thiessen <opensource@fthiessen.de>
1026
- *
1027
- * @license AGPL-3.0-or-later
1028
- *
1029
- * This program is free software: you can redistribute it and/or modify
1030
- * it under the terms of the GNU Affero General Public License as
1031
- * published by the Free Software Foundation, either version 3 of the
1032
- * License, or (at your option) any later version.
1033
- *
1034
- * This program is distributed in the hope that it will be useful,
1035
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1036
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1037
- * GNU Affero General Public License for more details.
1038
- *
1039
- * You should have received a copy of the GNU Affero General Public License
1040
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1041
- *
1042
- */
1043
770
  const davRootPath = `/files/${getCurrentUser()?.uid}`;
1044
771
  const davRemoteURL = generateRemoteUrl("dav");
1045
772
  const davGetClient = function(remoteURL = davRemoteURL, headers = {}) {
@@ -1100,12 +827,15 @@ const davResultToNode = function(node, filesRoot = davRootPath, remoteURL = davR
1100
827
  const props = node.props;
1101
828
  const permissions = davParsePermissions(props?.permissions);
1102
829
  const owner = String(props?.["owner-id"] || userId);
830
+ const id = props.fileid || 0;
1103
831
  const nodeData = {
1104
- id: props?.fileid || 0,
832
+ id,
1105
833
  source: `${remoteURL}${node.filename}`,
1106
834
  mtime: new Date(Date.parse(node.lastmod)),
1107
835
  mime: node.mime || "application/octet-stream",
1108
836
  size: props?.size || Number.parseInt(props.getcontentlength || "0"),
837
+ // The fileid is set to -1 for failed requests
838
+ status: id < 0 ? NodeStatus.FAILED : void 0,
1109
839
  permissions,
1110
840
  owner,
1111
841
  root: filesRoot,
@@ -1129,28 +859,21 @@ function isFilenameValid(filename) {
1129
859
  }
1130
860
  return true;
1131
861
  }
1132
- /**
1133
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
1134
- *
1135
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
1136
- * @author John Molakvoæ <skjnldsv@protonmail.com>
1137
- *
1138
- * @license AGPL-3.0-or-later
1139
- *
1140
- * This program is free software: you can redistribute it and/or modify
1141
- * it under the terms of the GNU Affero General Public License as
1142
- * published by the Free Software Foundation, either version 3 of the
1143
- * License, or (at your option) any later version.
1144
- *
1145
- * This program is distributed in the hope that it will be useful,
1146
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1147
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1148
- * GNU Affero General Public License for more details.
1149
- *
1150
- * You should have received a copy of the GNU Affero General Public License
1151
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1152
- *
1153
- */
862
+ function getUniqueName(name, otherNames, options) {
863
+ const opts = {
864
+ suffix: (n) => `(${n})`,
865
+ ignoreFileExtension: false,
866
+ ...options
867
+ };
868
+ let newName = name;
869
+ let i = 1;
870
+ while (otherNames.includes(newName)) {
871
+ const ext = opts.ignoreFileExtension ? "" : extname(name);
872
+ const base = basename(name, ext);
873
+ newName = `${base} ${opts.suffix(i++)}${ext}`;
874
+ }
875
+ return newName;
876
+ }
1154
877
  const humanList = ["B", "KB", "MB", "GB", "TB", "PB"];
1155
878
  const humanListBinary = ["B", "KiB", "MiB", "GiB", "TiB", "PiB"];
1156
879
  function formatFileSize(size, skipSmallSizes = false, binaryPrefixes = false, base1000 = false) {
@@ -1237,6 +960,7 @@ function sortNodes(nodes, options = {}) {
1237
960
  sortingOrder: "asc",
1238
961
  ...options
1239
962
  };
963
+ const basename2 = (name) => name.lastIndexOf(".") > 0 ? name.slice(0, name.lastIndexOf(".")) : name;
1240
964
  const identifiers = [
1241
965
  // 1: Sort favorites first if enabled
1242
966
  ...sortingOptions.sortFavoritesFirst ? [(v) => v.attributes?.favorite !== 1] : [],
@@ -1245,7 +969,7 @@ function sortNodes(nodes, options = {}) {
1245
969
  // 3: Use sorting mode if NOT basename (to be able to use displayName too)
1246
970
  ...sortingOptions.sortingMode !== "basename" ? [(v) => v[sortingOptions.sortingMode]] : [],
1247
971
  // 4: Use displayName if available, fallback to name
1248
- (v) => v.attributes?.displayName || v.basename,
972
+ (v) => basename2(v.attributes?.displayName || v.basename),
1249
973
  // 5: Finally, use basename if all previous sorting methods failed
1250
974
  (v) => v.basename
1251
975
  ];
@@ -1265,51 +989,54 @@ function sortNodes(nodes, options = {}) {
1265
989
  ];
1266
990
  return orderBy(nodes, identifiers, orders);
1267
991
  }
1268
- /**
1269
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
1270
- *
1271
- * @author John Molakvoæ <skjnldsv@protonmail.com>
1272
- *
1273
- * @license AGPL-3.0-or-later
1274
- *
1275
- * This program is free software: you can redistribute it and/or modify
1276
- * it under the terms of the GNU Affero General Public License as
1277
- * published by the Free Software Foundation, either version 3 of the
1278
- * License, or (at your option) any later version.
1279
- *
1280
- * This program is distributed in the hope that it will be useful,
1281
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1282
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1283
- * GNU Affero General Public License for more details.
1284
- *
1285
- * You should have received a copy of the GNU Affero General Public License
1286
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1287
- *
1288
- */
1289
- class Navigation {
992
+ class Navigation extends TypedEventTarget {
1290
993
  _views = [];
1291
994
  _currentView = null;
995
+ /**
996
+ * Register a new view on the navigation
997
+ * @param view The view to register
998
+ * @throws `Error` is thrown if a view with the same id is already registered
999
+ */
1292
1000
  register(view) {
1293
1001
  if (this._views.find((search) => search.id === view.id)) {
1294
1002
  throw new Error(`View id ${view.id} is already registered`);
1295
1003
  }
1296
1004
  this._views.push(view);
1005
+ this.dispatchTypedEvent("update", new CustomEvent("update"));
1297
1006
  }
1007
+ /**
1008
+ * Remove a registered view
1009
+ * @param id The id of the view to remove
1010
+ */
1298
1011
  remove(id) {
1299
1012
  const index = this._views.findIndex((view) => view.id === id);
1300
1013
  if (index !== -1) {
1301
1014
  this._views.splice(index, 1);
1015
+ this.dispatchTypedEvent("update", new CustomEvent("update"));
1302
1016
  }
1303
1017
  }
1304
- get views() {
1305
- return this._views;
1306
- }
1018
+ /**
1019
+ * Set the currently active view
1020
+ * @fires UpdateActiveViewEvent
1021
+ * @param view New active view
1022
+ */
1307
1023
  setActive(view) {
1308
1024
  this._currentView = view;
1025
+ const event = new CustomEvent("updateActive", { detail: view });
1026
+ this.dispatchTypedEvent("updateActive", event);
1309
1027
  }
1028
+ /**
1029
+ * The currently active files view
1030
+ */
1310
1031
  get active() {
1311
1032
  return this._currentView;
1312
1033
  }
1034
+ /**
1035
+ * All registered views
1036
+ */
1037
+ get views() {
1038
+ return this._views;
1039
+ }
1313
1040
  }
1314
1041
  const getNavigation = function() {
1315
1042
  if (typeof window._nc_navigation === "undefined") {
@@ -1318,27 +1045,6 @@ const getNavigation = function() {
1318
1045
  }
1319
1046
  return window._nc_navigation;
1320
1047
  };
1321
- /**
1322
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
1323
- *
1324
- * @author John Molakvoæ <skjnldsv@protonmail.com>
1325
- *
1326
- * @license AGPL-3.0-or-later
1327
- *
1328
- * This program is free software: you can redistribute it and/or modify
1329
- * it under the terms of the GNU Affero General Public License as
1330
- * published by the Free Software Foundation, either version 3 of the
1331
- * License, or (at your option) any later version.
1332
- *
1333
- * This program is distributed in the hope that it will be useful,
1334
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1335
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1336
- * GNU Affero General Public License for more details.
1337
- *
1338
- * You should have received a copy of the GNU Affero General Public License
1339
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1340
- *
1341
- */
1342
1048
  class Column {
1343
1049
  _column;
1344
1050
  constructor(column) {
@@ -1453,8 +1159,7 @@ validator$2.validate = function(xmlData, options) {
1453
1159
  if (xmlData[i] === "<" && xmlData[i + 1] === "?") {
1454
1160
  i += 2;
1455
1161
  i = readPI(xmlData, i);
1456
- if (i.err)
1457
- return i;
1162
+ if (i.err) return i;
1458
1163
  } else if (xmlData[i] === "<") {
1459
1164
  let tagStartPos = i;
1460
1165
  i++;
@@ -1528,8 +1233,7 @@ validator$2.validate = function(xmlData, options) {
1528
1233
  }
1529
1234
  if (reachedRoot === true) {
1530
1235
  return getErrorObject("InvalidXml", "Multiple possible root nodes found.", getLineNumberForPosition(xmlData, i));
1531
- } else if (options.unpairedTags.indexOf(tagName) !== -1)
1532
- ;
1236
+ } else if (options.unpairedTags.indexOf(tagName) !== -1) ;
1533
1237
  else {
1534
1238
  tags.push({ tagName, tagStartPos });
1535
1239
  }
@@ -1543,8 +1247,7 @@ validator$2.validate = function(xmlData, options) {
1543
1247
  continue;
1544
1248
  } else if (xmlData[i + 1] === "?") {
1545
1249
  i = readPI(xmlData, ++i);
1546
- if (i.err)
1547
- return i;
1250
+ if (i.err) return i;
1548
1251
  } else {
1549
1252
  break;
1550
1253
  }
@@ -1639,8 +1342,7 @@ function readAttributeStr(xmlData, i) {
1639
1342
  if (xmlData[i] === doubleQuote || xmlData[i] === singleQuote) {
1640
1343
  if (startChar === "") {
1641
1344
  startChar = xmlData[i];
1642
- } else if (startChar !== xmlData[i])
1643
- ;
1345
+ } else if (startChar !== xmlData[i]) ;
1644
1346
  else {
1645
1347
  startChar = "";
1646
1348
  }
@@ -1801,13 +1503,11 @@ class XmlNode {
1801
1503
  this[":@"] = {};
1802
1504
  }
1803
1505
  add(key, val2) {
1804
- if (key === "__proto__")
1805
- key = "#__proto__";
1506
+ if (key === "__proto__") key = "#__proto__";
1806
1507
  this.child.push({ [key]: val2 });
1807
1508
  }
1808
1509
  addChild(node) {
1809
- if (node.tagname === "__proto__")
1810
- node.tagname = "#__proto__";
1510
+ if (node.tagname === "__proto__") node.tagname = "#__proto__";
1811
1511
  if (node[":@"] && Object.keys(node[":@"]).length > 0) {
1812
1512
  this.child.push({ [node.tagname]: node.child, [":@"]: node[":@"] });
1813
1513
  } else {
@@ -1834,16 +1534,11 @@ function readDocType$1(xmlData, i) {
1834
1534
  regx: RegExp(`&${entityName};`, "g"),
1835
1535
  val
1836
1536
  };
1837
- } else if (hasBody && isElement(xmlData, i))
1838
- i += 8;
1839
- else if (hasBody && isAttlist(xmlData, i))
1840
- i += 8;
1841
- else if (hasBody && isNotation(xmlData, i))
1842
- i += 9;
1843
- else if (isComment)
1844
- comment = true;
1845
- else
1846
- throw new Error("Invalid DOCTYPE");
1537
+ } else if (hasBody && isElement(xmlData, i)) i += 8;
1538
+ else if (hasBody && isAttlist(xmlData, i)) i += 8;
1539
+ else if (hasBody && isNotation(xmlData, i)) i += 9;
1540
+ else if (isComment) comment = true;
1541
+ else throw new Error("Invalid DOCTYPE");
1847
1542
  angleBracketsCount++;
1848
1543
  exp = "";
1849
1544
  } else if (xmlData[i] === ">") {
@@ -1878,8 +1573,7 @@ function readEntityExp(xmlData, i) {
1878
1573
  entityName2 += xmlData[i];
1879
1574
  }
1880
1575
  entityName2 = entityName2.trim();
1881
- if (entityName2.indexOf(" ") !== -1)
1882
- throw new Error("External entites are not supported");
1576
+ if (entityName2.indexOf(" ") !== -1) throw new Error("External entites are not supported");
1883
1577
  const startChar = xmlData[i++];
1884
1578
  let val2 = "";
1885
1579
  for (; i < xmlData.length && xmlData[i] !== startChar; i++) {
@@ -1888,28 +1582,23 @@ function readEntityExp(xmlData, i) {
1888
1582
  return [entityName2, val2, i];
1889
1583
  }
1890
1584
  function isComment(xmlData, i) {
1891
- if (xmlData[i + 1] === "!" && xmlData[i + 2] === "-" && xmlData[i + 3] === "-")
1892
- return true;
1585
+ if (xmlData[i + 1] === "!" && xmlData[i + 2] === "-" && xmlData[i + 3] === "-") return true;
1893
1586
  return false;
1894
1587
  }
1895
1588
  function isEntity(xmlData, i) {
1896
- 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")
1897
- return true;
1589
+ 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;
1898
1590
  return false;
1899
1591
  }
1900
1592
  function isElement(xmlData, i) {
1901
- 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")
1902
- return true;
1593
+ 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;
1903
1594
  return false;
1904
1595
  }
1905
1596
  function isAttlist(xmlData, i) {
1906
- 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")
1907
- return true;
1597
+ 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;
1908
1598
  return false;
1909
1599
  }
1910
1600
  function isNotation(xmlData, i) {
1911
- 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")
1912
- return true;
1601
+ 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;
1913
1602
  return false;
1914
1603
  }
1915
1604
  function validateEntityName(name) {
@@ -1936,11 +1625,9 @@ const consider = {
1936
1625
  };
1937
1626
  function toNumber$1(str, options = {}) {
1938
1627
  options = Object.assign({}, consider, options);
1939
- if (!str || typeof str !== "string")
1940
- return str;
1628
+ if (!str || typeof str !== "string") return str;
1941
1629
  let trimmedStr = str.trim();
1942
- if (options.skipLike !== void 0 && options.skipLike.test(trimmedStr))
1943
- return str;
1630
+ if (options.skipLike !== void 0 && options.skipLike.test(trimmedStr)) return str;
1944
1631
  else if (options.hex && hexRegex.test(trimmedStr)) {
1945
1632
  return Number.parseInt(trimmedStr, 16);
1946
1633
  } else {
@@ -1950,45 +1637,30 @@ function toNumber$1(str, options = {}) {
1950
1637
  const leadingZeros = match[2];
1951
1638
  let numTrimmedByZeros = trimZeros(match[3]);
1952
1639
  const eNotation = match[4] || match[6];
1953
- if (!options.leadingZeros && leadingZeros.length > 0 && sign && trimmedStr[2] !== ".")
1954
- return str;
1955
- else if (!options.leadingZeros && leadingZeros.length > 0 && !sign && trimmedStr[1] !== ".")
1956
- return str;
1640
+ if (!options.leadingZeros && leadingZeros.length > 0 && sign && trimmedStr[2] !== ".") return str;
1641
+ else if (!options.leadingZeros && leadingZeros.length > 0 && !sign && trimmedStr[1] !== ".") return str;
1957
1642
  else {
1958
1643
  const num = Number(trimmedStr);
1959
1644
  const numStr = "" + num;
1960
1645
  if (numStr.search(/[eE]/) !== -1) {
1961
- if (options.eNotation)
1962
- return num;
1963
- else
1964
- return str;
1646
+ if (options.eNotation) return num;
1647
+ else return str;
1965
1648
  } else if (eNotation) {
1966
- if (options.eNotation)
1967
- return num;
1968
- else
1969
- return str;
1649
+ if (options.eNotation) return num;
1650
+ else return str;
1970
1651
  } else if (trimmedStr.indexOf(".") !== -1) {
1971
- if (numStr === "0" && numTrimmedByZeros === "")
1972
- return num;
1973
- else if (numStr === numTrimmedByZeros)
1974
- return num;
1975
- else if (sign && numStr === "-" + numTrimmedByZeros)
1976
- return num;
1977
- else
1978
- return str;
1652
+ if (numStr === "0" && numTrimmedByZeros === "") return num;
1653
+ else if (numStr === numTrimmedByZeros) return num;
1654
+ else if (sign && numStr === "-" + numTrimmedByZeros) return num;
1655
+ else return str;
1979
1656
  }
1980
1657
  if (leadingZeros) {
1981
- if (numTrimmedByZeros === numStr)
1982
- return num;
1983
- else if (sign + numTrimmedByZeros === numStr)
1984
- return num;
1985
- else
1986
- return str;
1658
+ if (numTrimmedByZeros === numStr) return num;
1659
+ else if (sign + numTrimmedByZeros === numStr) return num;
1660
+ else return str;
1987
1661
  }
1988
- if (trimmedStr === numStr)
1989
- return num;
1990
- else if (trimmedStr === sign + numStr)
1991
- return num;
1662
+ if (trimmedStr === numStr) return num;
1663
+ else if (trimmedStr === sign + numStr) return num;
1992
1664
  return str;
1993
1665
  }
1994
1666
  } else {
@@ -1999,12 +1671,9 @@ function toNumber$1(str, options = {}) {
1999
1671
  function trimZeros(numStr) {
2000
1672
  if (numStr && numStr.indexOf(".") !== -1) {
2001
1673
  numStr = numStr.replace(/0+$/, "");
2002
- if (numStr === ".")
2003
- numStr = "0";
2004
- else if (numStr[0] === ".")
2005
- numStr = "0" + numStr;
2006
- else if (numStr[numStr.length - 1] === ".")
2007
- numStr = numStr.substr(0, numStr.length - 1);
1674
+ if (numStr === ".") numStr = "0";
1675
+ else if (numStr[0] === ".") numStr = "0" + numStr;
1676
+ else if (numStr[numStr.length - 1] === ".") numStr = numStr.substr(0, numStr.length - 1);
2008
1677
  return numStr;
2009
1678
  }
2010
1679
  return numStr;
@@ -2072,8 +1741,7 @@ function parseTextData(val2, tagName, jPath, dontTrim, hasAttributes, isLeafNode
2072
1741
  val2 = val2.trim();
2073
1742
  }
2074
1743
  if (val2.length > 0) {
2075
- if (!escapeEntities)
2076
- val2 = this.replaceEntitiesValue(val2);
1744
+ if (!escapeEntities) val2 = this.replaceEntitiesValue(val2);
2077
1745
  const newval = this.options.tagValueProcessor(tagName, val2, jPath, hasAttributes, isLeafNode);
2078
1746
  if (newval === null || newval === void 0) {
2079
1747
  return val2;
@@ -2119,8 +1787,7 @@ function buildAttributesMap(attrStr, jPath, tagName) {
2119
1787
  if (this.options.transformAttributeName) {
2120
1788
  aName = this.options.transformAttributeName(aName);
2121
1789
  }
2122
- if (aName === "__proto__")
2123
- aName = "#__proto__";
1790
+ if (aName === "__proto__") aName = "#__proto__";
2124
1791
  if (oldVal !== void 0) {
2125
1792
  if (this.options.trimValues) {
2126
1793
  oldVal = oldVal.trim();
@@ -2195,11 +1862,9 @@ const parseXml = function(xmlData) {
2195
1862
  i = closeIndex;
2196
1863
  } else if (xmlData[i + 1] === "?") {
2197
1864
  let tagData = readTagExp(xmlData, i, false, "?>");
2198
- if (!tagData)
2199
- throw new Error("Pi Tag is not closed.");
1865
+ if (!tagData) throw new Error("Pi Tag is not closed.");
2200
1866
  textData = this.saveTextToParentTag(textData, currentNode, jPath);
2201
- if (this.options.ignoreDeclaration && tagData.tagName === "?xml" || this.options.ignorePiTags)
2202
- ;
1867
+ if (this.options.ignoreDeclaration && tagData.tagName === "?xml" || this.options.ignorePiTags) ;
2203
1868
  else {
2204
1869
  const childNode = new xmlNode(tagData.tagName);
2205
1870
  childNode.add(this.options.textNodeName, "");
@@ -2226,8 +1891,7 @@ const parseXml = function(xmlData) {
2226
1891
  const tagExp = xmlData.substring(i + 9, closeIndex);
2227
1892
  textData = this.saveTextToParentTag(textData, currentNode, jPath);
2228
1893
  let val2 = this.parseTextData(tagExp, currentNode.tagname, jPath, true, false, true, true);
2229
- if (val2 == void 0)
2230
- val2 = "";
1894
+ if (val2 == void 0) val2 = "";
2231
1895
  if (this.options.cdataPropName) {
2232
1896
  currentNode.add(this.options.cdataPropName, [{ [this.options.textNodeName]: tagExp }]);
2233
1897
  } else {
@@ -2272,8 +1936,7 @@ const parseXml = function(xmlData) {
2272
1936
  i = result.closeIndex;
2273
1937
  } else {
2274
1938
  const result2 = this.readStopNodeData(xmlData, rawTagName, closeIndex + 1);
2275
- if (!result2)
2276
- throw new Error(`Unexpected end of ${rawTagName}`);
1939
+ if (!result2) throw new Error(`Unexpected end of ${rawTagName}`);
2277
1940
  i = result2.i;
2278
1941
  tagContent = result2.tagContent;
2279
1942
  }
@@ -2326,8 +1989,7 @@ const parseXml = function(xmlData) {
2326
1989
  };
2327
1990
  function addChild(currentNode, childNode, jPath) {
2328
1991
  const result = this.options.updateTag(childNode.tagname, jPath, childNode[":@"]);
2329
- if (result === false)
2330
- ;
1992
+ if (result === false) ;
2331
1993
  else if (typeof result === "string") {
2332
1994
  childNode.tagname = result;
2333
1995
  currentNode.addChild(childNode);
@@ -2357,8 +2019,7 @@ const replaceEntitiesValue$1 = function(val2) {
2357
2019
  };
2358
2020
  function saveTextToParentTag(textData, currentNode, jPath, isLeafNode) {
2359
2021
  if (textData) {
2360
- if (isLeafNode === void 0)
2361
- isLeafNode = Object.keys(currentNode.child).length === 0;
2022
+ if (isLeafNode === void 0) isLeafNode = Object.keys(currentNode.child).length === 0;
2362
2023
  textData = this.parseTextData(
2363
2024
  textData,
2364
2025
  currentNode.tagname,
@@ -2377,8 +2038,7 @@ function isItStopNode(stopNodes, jPath, currentTagName) {
2377
2038
  const allNodesExp = "*." + currentTagName;
2378
2039
  for (const stopNodePath in stopNodes) {
2379
2040
  const stopNodeExp = stopNodes[stopNodePath];
2380
- if (allNodesExp === stopNodeExp || jPath === stopNodeExp)
2381
- return true;
2041
+ if (allNodesExp === stopNodeExp || jPath === stopNodeExp) return true;
2382
2042
  }
2383
2043
  return false;
2384
2044
  }
@@ -2388,8 +2048,7 @@ function tagExpWithClosingIndex(xmlData, i, closingChar = ">") {
2388
2048
  for (let index = i; index < xmlData.length; index++) {
2389
2049
  let ch = xmlData[index];
2390
2050
  if (attrBoundary) {
2391
- if (ch === attrBoundary)
2392
- attrBoundary = "";
2051
+ if (ch === attrBoundary) attrBoundary = "";
2393
2052
  } else if (ch === '"' || ch === "'") {
2394
2053
  attrBoundary = ch;
2395
2054
  } else if (ch === closingChar[0]) {
@@ -2422,8 +2081,7 @@ function findClosingIndex(xmlData, str, i, errMsg) {
2422
2081
  }
2423
2082
  function readTagExp(xmlData, i, removeNSPrefix, closingChar = ">") {
2424
2083
  const result = tagExpWithClosingIndex(xmlData, i + 1, closingChar);
2425
- if (!result)
2426
- return;
2084
+ if (!result) return;
2427
2085
  let tagExp = result.data;
2428
2086
  const closeIndex = result.index;
2429
2087
  const separatorIndex = tagExp.search(/\s/);
@@ -2492,12 +2150,9 @@ function readStopNodeData(xmlData, tagName, i) {
2492
2150
  function parseValue(val2, shouldParse, options) {
2493
2151
  if (shouldParse && typeof val2 === "string") {
2494
2152
  const newval = val2.trim();
2495
- if (newval === "true")
2496
- return true;
2497
- else if (newval === "false")
2498
- return false;
2499
- else
2500
- return toNumber(val2, options);
2153
+ if (newval === "true") return true;
2154
+ else if (newval === "false") return false;
2155
+ else return toNumber(val2, options);
2501
2156
  } else {
2502
2157
  if (util.isExist(val2)) {
2503
2158
  return val2;
@@ -2518,15 +2173,11 @@ function compress(arr, options, jPath) {
2518
2173
  const tagObj = arr[i];
2519
2174
  const property = propName$1(tagObj);
2520
2175
  let newJpath = "";
2521
- if (jPath === void 0)
2522
- newJpath = property;
2523
- else
2524
- newJpath = jPath + "." + property;
2176
+ if (jPath === void 0) newJpath = property;
2177
+ else newJpath = jPath + "." + property;
2525
2178
  if (property === options.textNodeName) {
2526
- if (text === void 0)
2527
- text = tagObj[property];
2528
- else
2529
- text += "" + tagObj[property];
2179
+ if (text === void 0) text = tagObj[property];
2180
+ else text += "" + tagObj[property];
2530
2181
  } else if (property === void 0) {
2531
2182
  continue;
2532
2183
  } else if (tagObj[property]) {
@@ -2537,10 +2188,8 @@ function compress(arr, options, jPath) {
2537
2188
  } else if (Object.keys(val2).length === 1 && val2[options.textNodeName] !== void 0 && !options.alwaysCreateTextNode) {
2538
2189
  val2 = val2[options.textNodeName];
2539
2190
  } else if (Object.keys(val2).length === 0) {
2540
- if (options.alwaysCreateTextNode)
2541
- val2[options.textNodeName] = "";
2542
- else
2543
- val2 = "";
2191
+ if (options.alwaysCreateTextNode) val2[options.textNodeName] = "";
2192
+ else val2 = "";
2544
2193
  }
2545
2194
  if (compressedObj[property] !== void 0 && compressedObj.hasOwnProperty(property)) {
2546
2195
  if (!Array.isArray(compressedObj[property])) {
@@ -2557,18 +2206,15 @@ function compress(arr, options, jPath) {
2557
2206
  }
2558
2207
  }
2559
2208
  if (typeof text === "string") {
2560
- if (text.length > 0)
2561
- compressedObj[options.textNodeName] = text;
2562
- } else if (text !== void 0)
2563
- compressedObj[options.textNodeName] = text;
2209
+ if (text.length > 0) compressedObj[options.textNodeName] = text;
2210
+ } else if (text !== void 0) compressedObj[options.textNodeName] = text;
2564
2211
  return compressedObj;
2565
2212
  }
2566
2213
  function propName$1(obj) {
2567
2214
  const keys = Object.keys(obj);
2568
2215
  for (let i = 0; i < keys.length; i++) {
2569
2216
  const key = keys[i];
2570
- if (key !== ":@")
2571
- return key;
2217
+ if (key !== ":@") return key;
2572
2218
  }
2573
2219
  }
2574
2220
  function assignAttributes(obj, attrMap, jpath, options) {
@@ -2612,16 +2258,14 @@ let XMLParser$1 = class XMLParser {
2612
2258
  * @param {boolean|Object} validationOption
2613
2259
  */
2614
2260
  parse(xmlData, validationOption) {
2615
- if (typeof xmlData === "string")
2616
- ;
2261
+ if (typeof xmlData === "string") ;
2617
2262
  else if (xmlData.toString) {
2618
2263
  xmlData = xmlData.toString();
2619
2264
  } else {
2620
2265
  throw new Error("XML data is accepted in String or Bytes[] form.");
2621
2266
  }
2622
2267
  if (validationOption) {
2623
- if (validationOption === true)
2624
- validationOption = {};
2268
+ if (validationOption === true) validationOption = {};
2625
2269
  const result = validator$1.validate(xmlData, validationOption);
2626
2270
  if (result !== true) {
2627
2271
  throw Error(`${result.err.msg}:${result.err.line}:${result.err.col}`);
@@ -2630,10 +2274,8 @@ let XMLParser$1 = class XMLParser {
2630
2274
  const orderedObjParser = new OrderedObjParser2(this.options);
2631
2275
  orderedObjParser.addExternalEntities(this.externalEntities);
2632
2276
  const orderedResult = orderedObjParser.parseXml(xmlData);
2633
- if (this.options.preserveOrder || orderedResult === void 0)
2634
- return orderedResult;
2635
- else
2636
- return prettify(orderedResult, this.options);
2277
+ if (this.options.preserveOrder || orderedResult === void 0) return orderedResult;
2278
+ else return prettify(orderedResult, this.options);
2637
2279
  }
2638
2280
  /**
2639
2281
  * Add Entity which is not by default supported by this library
@@ -2667,13 +2309,10 @@ function arrToStr(arr, options, jPath, indentation) {
2667
2309
  for (let i = 0; i < arr.length; i++) {
2668
2310
  const tagObj = arr[i];
2669
2311
  const tagName = propName(tagObj);
2670
- if (tagName === void 0)
2671
- continue;
2312
+ if (tagName === void 0) continue;
2672
2313
  let newJPath = "";
2673
- if (jPath.length === 0)
2674
- newJPath = tagName;
2675
- else
2676
- newJPath = `${jPath}.${tagName}`;
2314
+ if (jPath.length === 0) newJPath = tagName;
2315
+ else newJPath = `${jPath}.${tagName}`;
2677
2316
  if (tagName === options.textNodeName) {
2678
2317
  let tagText = tagObj[tagName];
2679
2318
  if (!isStopNode(newJPath, options)) {
@@ -2714,10 +2353,8 @@ function arrToStr(arr, options, jPath, indentation) {
2714
2353
  const tagStart = indentation + `<${tagName}${attStr}`;
2715
2354
  const tagValue = arrToStr(tagObj[tagName], options, newJPath, newIdentation);
2716
2355
  if (options.unpairedTags.indexOf(tagName) !== -1) {
2717
- if (options.suppressUnpairedNode)
2718
- xmlStr += tagStart + ">";
2719
- else
2720
- xmlStr += tagStart + "/>";
2356
+ if (options.suppressUnpairedNode) xmlStr += tagStart + ">";
2357
+ else xmlStr += tagStart + "/>";
2721
2358
  } else if ((!tagValue || tagValue.length === 0) && options.suppressEmptyNode) {
2722
2359
  xmlStr += tagStart + "/>";
2723
2360
  } else if (tagValue && tagValue.endsWith(">")) {
@@ -2739,18 +2376,15 @@ function propName(obj) {
2739
2376
  const keys = Object.keys(obj);
2740
2377
  for (let i = 0; i < keys.length; i++) {
2741
2378
  const key = keys[i];
2742
- if (!obj.hasOwnProperty(key))
2743
- continue;
2744
- if (key !== ":@")
2745
- return key;
2379
+ if (!obj.hasOwnProperty(key)) continue;
2380
+ if (key !== ":@") return key;
2746
2381
  }
2747
2382
  }
2748
2383
  function attr_to_str(attrMap, options) {
2749
2384
  let attrStr = "";
2750
2385
  if (attrMap && !options.ignoreAttributes) {
2751
2386
  for (let attr in attrMap) {
2752
- if (!attrMap.hasOwnProperty(attr))
2753
- continue;
2387
+ if (!attrMap.hasOwnProperty(attr)) continue;
2754
2388
  let attrVal = options.attributeValueProcessor(attr, attrMap[attr]);
2755
2389
  attrVal = replaceEntitiesValue(attrVal, options);
2756
2390
  if (attrVal === true && options.suppressBooleanAttributes) {
@@ -2766,8 +2400,7 @@ function isStopNode(jPath, options) {
2766
2400
  jPath = jPath.substr(0, jPath.length - options.textNodeName.length - 1);
2767
2401
  let tagName = jPath.substr(jPath.lastIndexOf(".") + 1);
2768
2402
  for (let index in options.stopNodes) {
2769
- if (options.stopNodes[index] === jPath || options.stopNodes[index] === "*." + tagName)
2770
- return true;
2403
+ if (options.stopNodes[index] === jPath || options.stopNodes[index] === "*." + tagName) return true;
2771
2404
  }
2772
2405
  return false;
2773
2406
  }
@@ -2855,8 +2488,7 @@ Builder.prototype.j2x = function(jObj, level) {
2855
2488
  let attrStr = "";
2856
2489
  let val2 = "";
2857
2490
  for (let key in jObj) {
2858
- if (!Object.prototype.hasOwnProperty.call(jObj, key))
2859
- continue;
2491
+ if (!Object.prototype.hasOwnProperty.call(jObj, key)) continue;
2860
2492
  if (typeof jObj[key] === "undefined") {
2861
2493
  if (this.isAttribute(key)) {
2862
2494
  val2 += "";
@@ -2888,13 +2520,10 @@ Builder.prototype.j2x = function(jObj, level) {
2888
2520
  let listTagVal = "";
2889
2521
  for (let j = 0; j < arrLen; j++) {
2890
2522
  const item = jObj[key][j];
2891
- if (typeof item === "undefined")
2892
- ;
2523
+ if (typeof item === "undefined") ;
2893
2524
  else if (item === null) {
2894
- if (key[0] === "?")
2895
- val2 += this.indentate(level) + "<" + key + "?" + this.tagEndChar;
2896
- else
2897
- val2 += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
2525
+ if (key[0] === "?") val2 += this.indentate(level) + "<" + key + "?" + this.tagEndChar;
2526
+ else val2 += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
2898
2527
  } else if (typeof item === "object") {
2899
2528
  if (this.options.oneListGroup) {
2900
2529
  listTagVal += this.j2x(item, level + 1).val;
@@ -2928,8 +2557,7 @@ Builder.prototype.buildAttrPairStr = function(attrName, val2) {
2928
2557
  val2 = this.replaceEntitiesValue(val2);
2929
2558
  if (this.options.suppressBooleanAttributes && val2 === "true") {
2930
2559
  return " " + attrName;
2931
- } else
2932
- return " " + attrName + '="' + val2 + '"';
2560
+ } else return " " + attrName + '="' + val2 + '"';
2933
2561
  };
2934
2562
  function processTextOrObjNode(object, key, level) {
2935
2563
  const result = this.j2x(object, level + 1);
@@ -2941,8 +2569,7 @@ function processTextOrObjNode(object, key, level) {
2941
2569
  }
2942
2570
  Builder.prototype.buildObjectNode = function(val2, key, attrStr, level) {
2943
2571
  if (val2 === "") {
2944
- if (key[0] === "?")
2945
- return this.indentate(level) + "<" + key + attrStr + "?" + this.tagEndChar;
2572
+ if (key[0] === "?") return this.indentate(level) + "<" + key + attrStr + "?" + this.tagEndChar;
2946
2573
  else {
2947
2574
  return this.indentate(level) + "<" + key + attrStr + this.closeTag(key) + this.tagEndChar;
2948
2575
  }
@@ -2965,8 +2592,7 @@ Builder.prototype.buildObjectNode = function(val2, key, attrStr, level) {
2965
2592
  Builder.prototype.closeTag = function(key) {
2966
2593
  let closeTag = "";
2967
2594
  if (this.options.unpairedTags.indexOf(key) !== -1) {
2968
- if (!this.options.suppressUnpairedNode)
2969
- closeTag = "/";
2595
+ if (!this.options.suppressUnpairedNode) closeTag = "/";
2970
2596
  } else if (this.options.suppressEmptyNode) {
2971
2597
  closeTag = "/";
2972
2598
  } else {
@@ -3045,27 +2671,6 @@ function isSvg(string) {
3045
2671
  }
3046
2672
  return true;
3047
2673
  }
3048
- /**
3049
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
3050
- *
3051
- * @author John Molakvoæ <skjnldsv@protonmail.com>
3052
- *
3053
- * @license AGPL-3.0-or-later
3054
- *
3055
- * This program is free software: you can redistribute it and/or modify
3056
- * it under the terms of the GNU Affero General Public License as
3057
- * published by the Free Software Foundation, either version 3 of the
3058
- * License, or (at your option) any later version.
3059
- *
3060
- * This program is distributed in the hope that it will be useful,
3061
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3062
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3063
- * GNU Affero General Public License for more details.
3064
- *
3065
- * You should have received a copy of the GNU Affero General Public License
3066
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
3067
- *
3068
- */
3069
2674
  class View {
3070
2675
  _view;
3071
2676
  constructor(view) {
@@ -3173,28 +2778,6 @@ const isValidView = function(view) {
3173
2778
  }
3174
2779
  return true;
3175
2780
  };
3176
- /**
3177
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
3178
- *
3179
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
3180
- * @author John Molakvoæ <skjnldsv@protonmail.com>
3181
- *
3182
- * @license AGPL-3.0-or-later
3183
- *
3184
- * This program is free software: you can redistribute it and/or modify
3185
- * it under the terms of the GNU Affero General Public License as
3186
- * published by the Free Software Foundation, either version 3 of the
3187
- * License, or (at your option) any later version.
3188
- *
3189
- * This program is distributed in the hope that it will be useful,
3190
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3191
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3192
- * GNU Affero General Public License for more details.
3193
- *
3194
- * You should have received a copy of the GNU Affero General Public License
3195
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
3196
- *
3197
- */
3198
2781
  const addNewFileMenuEntry = function(entry) {
3199
2782
  const newFileMenu = getNewFileMenu();
3200
2783
  return newFileMenu.registerEntry(entry);
@@ -3246,6 +2829,7 @@ export {
3246
2829
  getFileListHeaders,
3247
2830
  getNavigation,
3248
2831
  getNewFileMenuEntries,
2832
+ getUniqueName,
3249
2833
  isFilenameValid,
3250
2834
  orderBy,
3251
2835
  parseFileSize,