@nextcloud/files 3.4.1 → 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";
@@ -956,53 +740,16 @@ class Node {
956
740
  }
957
741
  }
958
742
  }
959
- /**
960
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
961
- *
962
- * @author John Molakvoæ <skjnldsv@protonmail.com>
963
- *
964
- * @license AGPL-3.0-or-later
965
- *
966
- * This program is free software: you can redistribute it and/or modify
967
- * it under the terms of the GNU Affero General Public License as
968
- * published by the Free Software Foundation, either version 3 of the
969
- * License, or (at your option) any later version.
970
- *
971
- * This program is distributed in the hope that it will be useful,
972
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
973
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
974
- * GNU Affero General Public License for more details.
975
- *
976
- * You should have received a copy of the GNU Affero General Public License
977
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
978
- *
979
- */
743
+ var FileType = /* @__PURE__ */ ((FileType2) => {
744
+ FileType2["Folder"] = "folder";
745
+ FileType2["File"] = "file";
746
+ return FileType2;
747
+ })(FileType || {});
980
748
  class File extends Node {
981
749
  get type() {
982
750
  return FileType.File;
983
751
  }
984
752
  }
985
- /**
986
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
987
- *
988
- * @author John Molakvoæ <skjnldsv@protonmail.com>
989
- *
990
- * @license AGPL-3.0-or-later
991
- *
992
- * This program is free software: you can redistribute it and/or modify
993
- * it under the terms of the GNU Affero General Public License as
994
- * published by the Free Software Foundation, either version 3 of the
995
- * License, or (at your option) any later version.
996
- *
997
- * This program is distributed in the hope that it will be useful,
998
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
999
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1000
- * GNU Affero General Public License for more details.
1001
- *
1002
- * You should have received a copy of the GNU Affero General Public License
1003
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1004
- *
1005
- */
1006
753
  class Folder extends Node {
1007
754
  constructor(data) {
1008
755
  super({
@@ -1020,28 +767,6 @@ class Folder extends Node {
1020
767
  return "httpd/unix-directory";
1021
768
  }
1022
769
  }
1023
- /**
1024
- * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
1025
- *
1026
- * @author John Molakvoæ <skjnldsv@protonmail.com>
1027
- * @author Ferdinand Thiessen <opensource@fthiessen.de>
1028
- *
1029
- * @license AGPL-3.0-or-later
1030
- *
1031
- * This program is free software: you can redistribute it and/or modify
1032
- * it under the terms of the GNU Affero General Public License as
1033
- * published by the Free Software Foundation, either version 3 of the
1034
- * License, or (at your option) any later version.
1035
- *
1036
- * This program is distributed in the hope that it will be useful,
1037
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1038
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1039
- * GNU Affero General Public License for more details.
1040
- *
1041
- * You should have received a copy of the GNU Affero General Public License
1042
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1043
- *
1044
- */
1045
770
  const davRootPath = `/files/${getCurrentUser()?.uid}`;
1046
771
  const davRemoteURL = generateRemoteUrl("dav");
1047
772
  const davGetClient = function(remoteURL = davRemoteURL, headers = {}) {
@@ -1102,12 +827,15 @@ const davResultToNode = function(node, filesRoot = davRootPath, remoteURL = davR
1102
827
  const props = node.props;
1103
828
  const permissions = davParsePermissions(props?.permissions);
1104
829
  const owner = String(props?.["owner-id"] || userId);
830
+ const id = props.fileid || 0;
1105
831
  const nodeData = {
1106
- id: props?.fileid || 0,
832
+ id,
1107
833
  source: `${remoteURL}${node.filename}`,
1108
834
  mtime: new Date(Date.parse(node.lastmod)),
1109
835
  mime: node.mime || "application/octet-stream",
1110
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,
1111
839
  permissions,
1112
840
  owner,
1113
841
  root: filesRoot,
@@ -1131,28 +859,21 @@ function isFilenameValid(filename) {
1131
859
  }
1132
860
  return true;
1133
861
  }
1134
- /**
1135
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
1136
- *
1137
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
1138
- * @author John Molakvoæ <skjnldsv@protonmail.com>
1139
- *
1140
- * @license AGPL-3.0-or-later
1141
- *
1142
- * This program is free software: you can redistribute it and/or modify
1143
- * it under the terms of the GNU Affero General Public License as
1144
- * published by the Free Software Foundation, either version 3 of the
1145
- * License, or (at your option) any later version.
1146
- *
1147
- * This program is distributed in the hope that it will be useful,
1148
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1149
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1150
- * GNU Affero General Public License for more details.
1151
- *
1152
- * You should have received a copy of the GNU Affero General Public License
1153
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1154
- *
1155
- */
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
+ }
1156
877
  const humanList = ["B", "KB", "MB", "GB", "TB", "PB"];
1157
878
  const humanListBinary = ["B", "KiB", "MiB", "GiB", "TiB", "PiB"];
1158
879
  function formatFileSize(size, skipSmallSizes = false, binaryPrefixes = false, base1000 = false) {
@@ -1239,6 +960,7 @@ function sortNodes(nodes, options = {}) {
1239
960
  sortingOrder: "asc",
1240
961
  ...options
1241
962
  };
963
+ const basename2 = (name) => name.lastIndexOf(".") > 0 ? name.slice(0, name.lastIndexOf(".")) : name;
1242
964
  const identifiers = [
1243
965
  // 1: Sort favorites first if enabled
1244
966
  ...sortingOptions.sortFavoritesFirst ? [(v) => v.attributes?.favorite !== 1] : [],
@@ -1247,7 +969,7 @@ function sortNodes(nodes, options = {}) {
1247
969
  // 3: Use sorting mode if NOT basename (to be able to use displayName too)
1248
970
  ...sortingOptions.sortingMode !== "basename" ? [(v) => v[sortingOptions.sortingMode]] : [],
1249
971
  // 4: Use displayName if available, fallback to name
1250
- (v) => v.attributes?.displayName || v.basename,
972
+ (v) => basename2(v.attributes?.displayName || v.basename),
1251
973
  // 5: Finally, use basename if all previous sorting methods failed
1252
974
  (v) => v.basename
1253
975
  ];
@@ -1267,51 +989,54 @@ function sortNodes(nodes, options = {}) {
1267
989
  ];
1268
990
  return orderBy(nodes, identifiers, orders);
1269
991
  }
1270
- /**
1271
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
1272
- *
1273
- * @author John Molakvoæ <skjnldsv@protonmail.com>
1274
- *
1275
- * @license AGPL-3.0-or-later
1276
- *
1277
- * This program is free software: you can redistribute it and/or modify
1278
- * it under the terms of the GNU Affero General Public License as
1279
- * published by the Free Software Foundation, either version 3 of the
1280
- * License, or (at your option) any later version.
1281
- *
1282
- * This program is distributed in the hope that it will be useful,
1283
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1284
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1285
- * GNU Affero General Public License for more details.
1286
- *
1287
- * You should have received a copy of the GNU Affero General Public License
1288
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1289
- *
1290
- */
1291
- class Navigation {
992
+ class Navigation extends TypedEventTarget {
1292
993
  _views = [];
1293
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
+ */
1294
1000
  register(view) {
1295
1001
  if (this._views.find((search) => search.id === view.id)) {
1296
1002
  throw new Error(`View id ${view.id} is already registered`);
1297
1003
  }
1298
1004
  this._views.push(view);
1005
+ this.dispatchTypedEvent("update", new CustomEvent("update"));
1299
1006
  }
1007
+ /**
1008
+ * Remove a registered view
1009
+ * @param id The id of the view to remove
1010
+ */
1300
1011
  remove(id) {
1301
1012
  const index = this._views.findIndex((view) => view.id === id);
1302
1013
  if (index !== -1) {
1303
1014
  this._views.splice(index, 1);
1015
+ this.dispatchTypedEvent("update", new CustomEvent("update"));
1304
1016
  }
1305
1017
  }
1306
- get views() {
1307
- return this._views;
1308
- }
1018
+ /**
1019
+ * Set the currently active view
1020
+ * @fires UpdateActiveViewEvent
1021
+ * @param view New active view
1022
+ */
1309
1023
  setActive(view) {
1310
1024
  this._currentView = view;
1025
+ const event = new CustomEvent("updateActive", { detail: view });
1026
+ this.dispatchTypedEvent("updateActive", event);
1311
1027
  }
1028
+ /**
1029
+ * The currently active files view
1030
+ */
1312
1031
  get active() {
1313
1032
  return this._currentView;
1314
1033
  }
1034
+ /**
1035
+ * All registered views
1036
+ */
1037
+ get views() {
1038
+ return this._views;
1039
+ }
1315
1040
  }
1316
1041
  const getNavigation = function() {
1317
1042
  if (typeof window._nc_navigation === "undefined") {
@@ -1320,27 +1045,6 @@ const getNavigation = function() {
1320
1045
  }
1321
1046
  return window._nc_navigation;
1322
1047
  };
1323
- /**
1324
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
1325
- *
1326
- * @author John Molakvoæ <skjnldsv@protonmail.com>
1327
- *
1328
- * @license AGPL-3.0-or-later
1329
- *
1330
- * This program is free software: you can redistribute it and/or modify
1331
- * it under the terms of the GNU Affero General Public License as
1332
- * published by the Free Software Foundation, either version 3 of the
1333
- * License, or (at your option) any later version.
1334
- *
1335
- * This program is distributed in the hope that it will be useful,
1336
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1337
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1338
- * GNU Affero General Public License for more details.
1339
- *
1340
- * You should have received a copy of the GNU Affero General Public License
1341
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1342
- *
1343
- */
1344
1048
  class Column {
1345
1049
  _column;
1346
1050
  constructor(column) {
@@ -1455,8 +1159,7 @@ validator$2.validate = function(xmlData, options) {
1455
1159
  if (xmlData[i] === "<" && xmlData[i + 1] === "?") {
1456
1160
  i += 2;
1457
1161
  i = readPI(xmlData, i);
1458
- if (i.err)
1459
- return i;
1162
+ if (i.err) return i;
1460
1163
  } else if (xmlData[i] === "<") {
1461
1164
  let tagStartPos = i;
1462
1165
  i++;
@@ -1530,8 +1233,7 @@ validator$2.validate = function(xmlData, options) {
1530
1233
  }
1531
1234
  if (reachedRoot === true) {
1532
1235
  return getErrorObject("InvalidXml", "Multiple possible root nodes found.", getLineNumberForPosition(xmlData, i));
1533
- } else if (options.unpairedTags.indexOf(tagName) !== -1)
1534
- ;
1236
+ } else if (options.unpairedTags.indexOf(tagName) !== -1) ;
1535
1237
  else {
1536
1238
  tags.push({ tagName, tagStartPos });
1537
1239
  }
@@ -1545,8 +1247,7 @@ validator$2.validate = function(xmlData, options) {
1545
1247
  continue;
1546
1248
  } else if (xmlData[i + 1] === "?") {
1547
1249
  i = readPI(xmlData, ++i);
1548
- if (i.err)
1549
- return i;
1250
+ if (i.err) return i;
1550
1251
  } else {
1551
1252
  break;
1552
1253
  }
@@ -1641,8 +1342,7 @@ function readAttributeStr(xmlData, i) {
1641
1342
  if (xmlData[i] === doubleQuote || xmlData[i] === singleQuote) {
1642
1343
  if (startChar === "") {
1643
1344
  startChar = xmlData[i];
1644
- } else if (startChar !== xmlData[i])
1645
- ;
1345
+ } else if (startChar !== xmlData[i]) ;
1646
1346
  else {
1647
1347
  startChar = "";
1648
1348
  }
@@ -1803,13 +1503,11 @@ class XmlNode {
1803
1503
  this[":@"] = {};
1804
1504
  }
1805
1505
  add(key, val2) {
1806
- if (key === "__proto__")
1807
- key = "#__proto__";
1506
+ if (key === "__proto__") key = "#__proto__";
1808
1507
  this.child.push({ [key]: val2 });
1809
1508
  }
1810
1509
  addChild(node) {
1811
- if (node.tagname === "__proto__")
1812
- node.tagname = "#__proto__";
1510
+ if (node.tagname === "__proto__") node.tagname = "#__proto__";
1813
1511
  if (node[":@"] && Object.keys(node[":@"]).length > 0) {
1814
1512
  this.child.push({ [node.tagname]: node.child, [":@"]: node[":@"] });
1815
1513
  } else {
@@ -1836,16 +1534,11 @@ function readDocType$1(xmlData, i) {
1836
1534
  regx: RegExp(`&${entityName};`, "g"),
1837
1535
  val
1838
1536
  };
1839
- } else if (hasBody && isElement(xmlData, i))
1840
- i += 8;
1841
- else if (hasBody && isAttlist(xmlData, i))
1842
- i += 8;
1843
- else if (hasBody && isNotation(xmlData, i))
1844
- i += 9;
1845
- else if (isComment)
1846
- comment = true;
1847
- else
1848
- 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");
1849
1542
  angleBracketsCount++;
1850
1543
  exp = "";
1851
1544
  } else if (xmlData[i] === ">") {
@@ -1880,8 +1573,7 @@ function readEntityExp(xmlData, i) {
1880
1573
  entityName2 += xmlData[i];
1881
1574
  }
1882
1575
  entityName2 = entityName2.trim();
1883
- if (entityName2.indexOf(" ") !== -1)
1884
- throw new Error("External entites are not supported");
1576
+ if (entityName2.indexOf(" ") !== -1) throw new Error("External entites are not supported");
1885
1577
  const startChar = xmlData[i++];
1886
1578
  let val2 = "";
1887
1579
  for (; i < xmlData.length && xmlData[i] !== startChar; i++) {
@@ -1890,28 +1582,23 @@ function readEntityExp(xmlData, i) {
1890
1582
  return [entityName2, val2, i];
1891
1583
  }
1892
1584
  function isComment(xmlData, i) {
1893
- if (xmlData[i + 1] === "!" && xmlData[i + 2] === "-" && xmlData[i + 3] === "-")
1894
- return true;
1585
+ if (xmlData[i + 1] === "!" && xmlData[i + 2] === "-" && xmlData[i + 3] === "-") return true;
1895
1586
  return false;
1896
1587
  }
1897
1588
  function isEntity(xmlData, i) {
1898
- 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")
1899
- 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;
1900
1590
  return false;
1901
1591
  }
1902
1592
  function isElement(xmlData, i) {
1903
- 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")
1904
- 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;
1905
1594
  return false;
1906
1595
  }
1907
1596
  function isAttlist(xmlData, i) {
1908
- 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")
1909
- 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;
1910
1598
  return false;
1911
1599
  }
1912
1600
  function isNotation(xmlData, i) {
1913
- 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")
1914
- 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;
1915
1602
  return false;
1916
1603
  }
1917
1604
  function validateEntityName(name) {
@@ -1938,11 +1625,9 @@ const consider = {
1938
1625
  };
1939
1626
  function toNumber$1(str, options = {}) {
1940
1627
  options = Object.assign({}, consider, options);
1941
- if (!str || typeof str !== "string")
1942
- return str;
1628
+ if (!str || typeof str !== "string") return str;
1943
1629
  let trimmedStr = str.trim();
1944
- if (options.skipLike !== void 0 && options.skipLike.test(trimmedStr))
1945
- return str;
1630
+ if (options.skipLike !== void 0 && options.skipLike.test(trimmedStr)) return str;
1946
1631
  else if (options.hex && hexRegex.test(trimmedStr)) {
1947
1632
  return Number.parseInt(trimmedStr, 16);
1948
1633
  } else {
@@ -1952,45 +1637,30 @@ function toNumber$1(str, options = {}) {
1952
1637
  const leadingZeros = match[2];
1953
1638
  let numTrimmedByZeros = trimZeros(match[3]);
1954
1639
  const eNotation = match[4] || match[6];
1955
- if (!options.leadingZeros && leadingZeros.length > 0 && sign && trimmedStr[2] !== ".")
1956
- return str;
1957
- else if (!options.leadingZeros && leadingZeros.length > 0 && !sign && trimmedStr[1] !== ".")
1958
- 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;
1959
1642
  else {
1960
1643
  const num = Number(trimmedStr);
1961
1644
  const numStr = "" + num;
1962
1645
  if (numStr.search(/[eE]/) !== -1) {
1963
- if (options.eNotation)
1964
- return num;
1965
- else
1966
- return str;
1646
+ if (options.eNotation) return num;
1647
+ else return str;
1967
1648
  } else if (eNotation) {
1968
- if (options.eNotation)
1969
- return num;
1970
- else
1971
- return str;
1649
+ if (options.eNotation) return num;
1650
+ else return str;
1972
1651
  } else if (trimmedStr.indexOf(".") !== -1) {
1973
- if (numStr === "0" && numTrimmedByZeros === "")
1974
- return num;
1975
- else if (numStr === numTrimmedByZeros)
1976
- return num;
1977
- else if (sign && numStr === "-" + numTrimmedByZeros)
1978
- return num;
1979
- else
1980
- 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;
1981
1656
  }
1982
1657
  if (leadingZeros) {
1983
- if (numTrimmedByZeros === numStr)
1984
- return num;
1985
- else if (sign + numTrimmedByZeros === numStr)
1986
- return num;
1987
- else
1988
- return str;
1658
+ if (numTrimmedByZeros === numStr) return num;
1659
+ else if (sign + numTrimmedByZeros === numStr) return num;
1660
+ else return str;
1989
1661
  }
1990
- if (trimmedStr === numStr)
1991
- return num;
1992
- else if (trimmedStr === sign + numStr)
1993
- return num;
1662
+ if (trimmedStr === numStr) return num;
1663
+ else if (trimmedStr === sign + numStr) return num;
1994
1664
  return str;
1995
1665
  }
1996
1666
  } else {
@@ -2001,12 +1671,9 @@ function toNumber$1(str, options = {}) {
2001
1671
  function trimZeros(numStr) {
2002
1672
  if (numStr && numStr.indexOf(".") !== -1) {
2003
1673
  numStr = numStr.replace(/0+$/, "");
2004
- if (numStr === ".")
2005
- numStr = "0";
2006
- else if (numStr[0] === ".")
2007
- numStr = "0" + numStr;
2008
- else if (numStr[numStr.length - 1] === ".")
2009
- 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);
2010
1677
  return numStr;
2011
1678
  }
2012
1679
  return numStr;
@@ -2074,8 +1741,7 @@ function parseTextData(val2, tagName, jPath, dontTrim, hasAttributes, isLeafNode
2074
1741
  val2 = val2.trim();
2075
1742
  }
2076
1743
  if (val2.length > 0) {
2077
- if (!escapeEntities)
2078
- val2 = this.replaceEntitiesValue(val2);
1744
+ if (!escapeEntities) val2 = this.replaceEntitiesValue(val2);
2079
1745
  const newval = this.options.tagValueProcessor(tagName, val2, jPath, hasAttributes, isLeafNode);
2080
1746
  if (newval === null || newval === void 0) {
2081
1747
  return val2;
@@ -2121,8 +1787,7 @@ function buildAttributesMap(attrStr, jPath, tagName) {
2121
1787
  if (this.options.transformAttributeName) {
2122
1788
  aName = this.options.transformAttributeName(aName);
2123
1789
  }
2124
- if (aName === "__proto__")
2125
- aName = "#__proto__";
1790
+ if (aName === "__proto__") aName = "#__proto__";
2126
1791
  if (oldVal !== void 0) {
2127
1792
  if (this.options.trimValues) {
2128
1793
  oldVal = oldVal.trim();
@@ -2197,11 +1862,9 @@ const parseXml = function(xmlData) {
2197
1862
  i = closeIndex;
2198
1863
  } else if (xmlData[i + 1] === "?") {
2199
1864
  let tagData = readTagExp(xmlData, i, false, "?>");
2200
- if (!tagData)
2201
- throw new Error("Pi Tag is not closed.");
1865
+ if (!tagData) throw new Error("Pi Tag is not closed.");
2202
1866
  textData = this.saveTextToParentTag(textData, currentNode, jPath);
2203
- if (this.options.ignoreDeclaration && tagData.tagName === "?xml" || this.options.ignorePiTags)
2204
- ;
1867
+ if (this.options.ignoreDeclaration && tagData.tagName === "?xml" || this.options.ignorePiTags) ;
2205
1868
  else {
2206
1869
  const childNode = new xmlNode(tagData.tagName);
2207
1870
  childNode.add(this.options.textNodeName, "");
@@ -2228,8 +1891,7 @@ const parseXml = function(xmlData) {
2228
1891
  const tagExp = xmlData.substring(i + 9, closeIndex);
2229
1892
  textData = this.saveTextToParentTag(textData, currentNode, jPath);
2230
1893
  let val2 = this.parseTextData(tagExp, currentNode.tagname, jPath, true, false, true, true);
2231
- if (val2 == void 0)
2232
- val2 = "";
1894
+ if (val2 == void 0) val2 = "";
2233
1895
  if (this.options.cdataPropName) {
2234
1896
  currentNode.add(this.options.cdataPropName, [{ [this.options.textNodeName]: tagExp }]);
2235
1897
  } else {
@@ -2274,8 +1936,7 @@ const parseXml = function(xmlData) {
2274
1936
  i = result.closeIndex;
2275
1937
  } else {
2276
1938
  const result2 = this.readStopNodeData(xmlData, rawTagName, closeIndex + 1);
2277
- if (!result2)
2278
- throw new Error(`Unexpected end of ${rawTagName}`);
1939
+ if (!result2) throw new Error(`Unexpected end of ${rawTagName}`);
2279
1940
  i = result2.i;
2280
1941
  tagContent = result2.tagContent;
2281
1942
  }
@@ -2328,8 +1989,7 @@ const parseXml = function(xmlData) {
2328
1989
  };
2329
1990
  function addChild(currentNode, childNode, jPath) {
2330
1991
  const result = this.options.updateTag(childNode.tagname, jPath, childNode[":@"]);
2331
- if (result === false)
2332
- ;
1992
+ if (result === false) ;
2333
1993
  else if (typeof result === "string") {
2334
1994
  childNode.tagname = result;
2335
1995
  currentNode.addChild(childNode);
@@ -2359,8 +2019,7 @@ const replaceEntitiesValue$1 = function(val2) {
2359
2019
  };
2360
2020
  function saveTextToParentTag(textData, currentNode, jPath, isLeafNode) {
2361
2021
  if (textData) {
2362
- if (isLeafNode === void 0)
2363
- isLeafNode = Object.keys(currentNode.child).length === 0;
2022
+ if (isLeafNode === void 0) isLeafNode = Object.keys(currentNode.child).length === 0;
2364
2023
  textData = this.parseTextData(
2365
2024
  textData,
2366
2025
  currentNode.tagname,
@@ -2379,8 +2038,7 @@ function isItStopNode(stopNodes, jPath, currentTagName) {
2379
2038
  const allNodesExp = "*." + currentTagName;
2380
2039
  for (const stopNodePath in stopNodes) {
2381
2040
  const stopNodeExp = stopNodes[stopNodePath];
2382
- if (allNodesExp === stopNodeExp || jPath === stopNodeExp)
2383
- return true;
2041
+ if (allNodesExp === stopNodeExp || jPath === stopNodeExp) return true;
2384
2042
  }
2385
2043
  return false;
2386
2044
  }
@@ -2390,8 +2048,7 @@ function tagExpWithClosingIndex(xmlData, i, closingChar = ">") {
2390
2048
  for (let index = i; index < xmlData.length; index++) {
2391
2049
  let ch = xmlData[index];
2392
2050
  if (attrBoundary) {
2393
- if (ch === attrBoundary)
2394
- attrBoundary = "";
2051
+ if (ch === attrBoundary) attrBoundary = "";
2395
2052
  } else if (ch === '"' || ch === "'") {
2396
2053
  attrBoundary = ch;
2397
2054
  } else if (ch === closingChar[0]) {
@@ -2424,8 +2081,7 @@ function findClosingIndex(xmlData, str, i, errMsg) {
2424
2081
  }
2425
2082
  function readTagExp(xmlData, i, removeNSPrefix, closingChar = ">") {
2426
2083
  const result = tagExpWithClosingIndex(xmlData, i + 1, closingChar);
2427
- if (!result)
2428
- return;
2084
+ if (!result) return;
2429
2085
  let tagExp = result.data;
2430
2086
  const closeIndex = result.index;
2431
2087
  const separatorIndex = tagExp.search(/\s/);
@@ -2494,12 +2150,9 @@ function readStopNodeData(xmlData, tagName, i) {
2494
2150
  function parseValue(val2, shouldParse, options) {
2495
2151
  if (shouldParse && typeof val2 === "string") {
2496
2152
  const newval = val2.trim();
2497
- if (newval === "true")
2498
- return true;
2499
- else if (newval === "false")
2500
- return false;
2501
- else
2502
- return toNumber(val2, options);
2153
+ if (newval === "true") return true;
2154
+ else if (newval === "false") return false;
2155
+ else return toNumber(val2, options);
2503
2156
  } else {
2504
2157
  if (util.isExist(val2)) {
2505
2158
  return val2;
@@ -2520,15 +2173,11 @@ function compress(arr, options, jPath) {
2520
2173
  const tagObj = arr[i];
2521
2174
  const property = propName$1(tagObj);
2522
2175
  let newJpath = "";
2523
- if (jPath === void 0)
2524
- newJpath = property;
2525
- else
2526
- newJpath = jPath + "." + property;
2176
+ if (jPath === void 0) newJpath = property;
2177
+ else newJpath = jPath + "." + property;
2527
2178
  if (property === options.textNodeName) {
2528
- if (text === void 0)
2529
- text = tagObj[property];
2530
- else
2531
- text += "" + tagObj[property];
2179
+ if (text === void 0) text = tagObj[property];
2180
+ else text += "" + tagObj[property];
2532
2181
  } else if (property === void 0) {
2533
2182
  continue;
2534
2183
  } else if (tagObj[property]) {
@@ -2539,10 +2188,8 @@ function compress(arr, options, jPath) {
2539
2188
  } else if (Object.keys(val2).length === 1 && val2[options.textNodeName] !== void 0 && !options.alwaysCreateTextNode) {
2540
2189
  val2 = val2[options.textNodeName];
2541
2190
  } else if (Object.keys(val2).length === 0) {
2542
- if (options.alwaysCreateTextNode)
2543
- val2[options.textNodeName] = "";
2544
- else
2545
- val2 = "";
2191
+ if (options.alwaysCreateTextNode) val2[options.textNodeName] = "";
2192
+ else val2 = "";
2546
2193
  }
2547
2194
  if (compressedObj[property] !== void 0 && compressedObj.hasOwnProperty(property)) {
2548
2195
  if (!Array.isArray(compressedObj[property])) {
@@ -2559,18 +2206,15 @@ function compress(arr, options, jPath) {
2559
2206
  }
2560
2207
  }
2561
2208
  if (typeof text === "string") {
2562
- if (text.length > 0)
2563
- compressedObj[options.textNodeName] = text;
2564
- } else if (text !== void 0)
2565
- compressedObj[options.textNodeName] = text;
2209
+ if (text.length > 0) compressedObj[options.textNodeName] = text;
2210
+ } else if (text !== void 0) compressedObj[options.textNodeName] = text;
2566
2211
  return compressedObj;
2567
2212
  }
2568
2213
  function propName$1(obj) {
2569
2214
  const keys = Object.keys(obj);
2570
2215
  for (let i = 0; i < keys.length; i++) {
2571
2216
  const key = keys[i];
2572
- if (key !== ":@")
2573
- return key;
2217
+ if (key !== ":@") return key;
2574
2218
  }
2575
2219
  }
2576
2220
  function assignAttributes(obj, attrMap, jpath, options) {
@@ -2614,16 +2258,14 @@ let XMLParser$1 = class XMLParser {
2614
2258
  * @param {boolean|Object} validationOption
2615
2259
  */
2616
2260
  parse(xmlData, validationOption) {
2617
- if (typeof xmlData === "string")
2618
- ;
2261
+ if (typeof xmlData === "string") ;
2619
2262
  else if (xmlData.toString) {
2620
2263
  xmlData = xmlData.toString();
2621
2264
  } else {
2622
2265
  throw new Error("XML data is accepted in String or Bytes[] form.");
2623
2266
  }
2624
2267
  if (validationOption) {
2625
- if (validationOption === true)
2626
- validationOption = {};
2268
+ if (validationOption === true) validationOption = {};
2627
2269
  const result = validator$1.validate(xmlData, validationOption);
2628
2270
  if (result !== true) {
2629
2271
  throw Error(`${result.err.msg}:${result.err.line}:${result.err.col}`);
@@ -2632,10 +2274,8 @@ let XMLParser$1 = class XMLParser {
2632
2274
  const orderedObjParser = new OrderedObjParser2(this.options);
2633
2275
  orderedObjParser.addExternalEntities(this.externalEntities);
2634
2276
  const orderedResult = orderedObjParser.parseXml(xmlData);
2635
- if (this.options.preserveOrder || orderedResult === void 0)
2636
- return orderedResult;
2637
- else
2638
- return prettify(orderedResult, this.options);
2277
+ if (this.options.preserveOrder || orderedResult === void 0) return orderedResult;
2278
+ else return prettify(orderedResult, this.options);
2639
2279
  }
2640
2280
  /**
2641
2281
  * Add Entity which is not by default supported by this library
@@ -2669,13 +2309,10 @@ function arrToStr(arr, options, jPath, indentation) {
2669
2309
  for (let i = 0; i < arr.length; i++) {
2670
2310
  const tagObj = arr[i];
2671
2311
  const tagName = propName(tagObj);
2672
- if (tagName === void 0)
2673
- continue;
2312
+ if (tagName === void 0) continue;
2674
2313
  let newJPath = "";
2675
- if (jPath.length === 0)
2676
- newJPath = tagName;
2677
- else
2678
- newJPath = `${jPath}.${tagName}`;
2314
+ if (jPath.length === 0) newJPath = tagName;
2315
+ else newJPath = `${jPath}.${tagName}`;
2679
2316
  if (tagName === options.textNodeName) {
2680
2317
  let tagText = tagObj[tagName];
2681
2318
  if (!isStopNode(newJPath, options)) {
@@ -2716,10 +2353,8 @@ function arrToStr(arr, options, jPath, indentation) {
2716
2353
  const tagStart = indentation + `<${tagName}${attStr}`;
2717
2354
  const tagValue = arrToStr(tagObj[tagName], options, newJPath, newIdentation);
2718
2355
  if (options.unpairedTags.indexOf(tagName) !== -1) {
2719
- if (options.suppressUnpairedNode)
2720
- xmlStr += tagStart + ">";
2721
- else
2722
- xmlStr += tagStart + "/>";
2356
+ if (options.suppressUnpairedNode) xmlStr += tagStart + ">";
2357
+ else xmlStr += tagStart + "/>";
2723
2358
  } else if ((!tagValue || tagValue.length === 0) && options.suppressEmptyNode) {
2724
2359
  xmlStr += tagStart + "/>";
2725
2360
  } else if (tagValue && tagValue.endsWith(">")) {
@@ -2741,18 +2376,15 @@ function propName(obj) {
2741
2376
  const keys = Object.keys(obj);
2742
2377
  for (let i = 0; i < keys.length; i++) {
2743
2378
  const key = keys[i];
2744
- if (!obj.hasOwnProperty(key))
2745
- continue;
2746
- if (key !== ":@")
2747
- return key;
2379
+ if (!obj.hasOwnProperty(key)) continue;
2380
+ if (key !== ":@") return key;
2748
2381
  }
2749
2382
  }
2750
2383
  function attr_to_str(attrMap, options) {
2751
2384
  let attrStr = "";
2752
2385
  if (attrMap && !options.ignoreAttributes) {
2753
2386
  for (let attr in attrMap) {
2754
- if (!attrMap.hasOwnProperty(attr))
2755
- continue;
2387
+ if (!attrMap.hasOwnProperty(attr)) continue;
2756
2388
  let attrVal = options.attributeValueProcessor(attr, attrMap[attr]);
2757
2389
  attrVal = replaceEntitiesValue(attrVal, options);
2758
2390
  if (attrVal === true && options.suppressBooleanAttributes) {
@@ -2768,8 +2400,7 @@ function isStopNode(jPath, options) {
2768
2400
  jPath = jPath.substr(0, jPath.length - options.textNodeName.length - 1);
2769
2401
  let tagName = jPath.substr(jPath.lastIndexOf(".") + 1);
2770
2402
  for (let index in options.stopNodes) {
2771
- if (options.stopNodes[index] === jPath || options.stopNodes[index] === "*." + tagName)
2772
- return true;
2403
+ if (options.stopNodes[index] === jPath || options.stopNodes[index] === "*." + tagName) return true;
2773
2404
  }
2774
2405
  return false;
2775
2406
  }
@@ -2857,8 +2488,7 @@ Builder.prototype.j2x = function(jObj, level) {
2857
2488
  let attrStr = "";
2858
2489
  let val2 = "";
2859
2490
  for (let key in jObj) {
2860
- if (!Object.prototype.hasOwnProperty.call(jObj, key))
2861
- continue;
2491
+ if (!Object.prototype.hasOwnProperty.call(jObj, key)) continue;
2862
2492
  if (typeof jObj[key] === "undefined") {
2863
2493
  if (this.isAttribute(key)) {
2864
2494
  val2 += "";
@@ -2890,13 +2520,10 @@ Builder.prototype.j2x = function(jObj, level) {
2890
2520
  let listTagVal = "";
2891
2521
  for (let j = 0; j < arrLen; j++) {
2892
2522
  const item = jObj[key][j];
2893
- if (typeof item === "undefined")
2894
- ;
2523
+ if (typeof item === "undefined") ;
2895
2524
  else if (item === null) {
2896
- if (key[0] === "?")
2897
- val2 += this.indentate(level) + "<" + key + "?" + this.tagEndChar;
2898
- else
2899
- 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;
2900
2527
  } else if (typeof item === "object") {
2901
2528
  if (this.options.oneListGroup) {
2902
2529
  listTagVal += this.j2x(item, level + 1).val;
@@ -2930,8 +2557,7 @@ Builder.prototype.buildAttrPairStr = function(attrName, val2) {
2930
2557
  val2 = this.replaceEntitiesValue(val2);
2931
2558
  if (this.options.suppressBooleanAttributes && val2 === "true") {
2932
2559
  return " " + attrName;
2933
- } else
2934
- return " " + attrName + '="' + val2 + '"';
2560
+ } else return " " + attrName + '="' + val2 + '"';
2935
2561
  };
2936
2562
  function processTextOrObjNode(object, key, level) {
2937
2563
  const result = this.j2x(object, level + 1);
@@ -2943,8 +2569,7 @@ function processTextOrObjNode(object, key, level) {
2943
2569
  }
2944
2570
  Builder.prototype.buildObjectNode = function(val2, key, attrStr, level) {
2945
2571
  if (val2 === "") {
2946
- if (key[0] === "?")
2947
- return this.indentate(level) + "<" + key + attrStr + "?" + this.tagEndChar;
2572
+ if (key[0] === "?") return this.indentate(level) + "<" + key + attrStr + "?" + this.tagEndChar;
2948
2573
  else {
2949
2574
  return this.indentate(level) + "<" + key + attrStr + this.closeTag(key) + this.tagEndChar;
2950
2575
  }
@@ -2967,8 +2592,7 @@ Builder.prototype.buildObjectNode = function(val2, key, attrStr, level) {
2967
2592
  Builder.prototype.closeTag = function(key) {
2968
2593
  let closeTag = "";
2969
2594
  if (this.options.unpairedTags.indexOf(key) !== -1) {
2970
- if (!this.options.suppressUnpairedNode)
2971
- closeTag = "/";
2595
+ if (!this.options.suppressUnpairedNode) closeTag = "/";
2972
2596
  } else if (this.options.suppressEmptyNode) {
2973
2597
  closeTag = "/";
2974
2598
  } else {
@@ -3047,27 +2671,6 @@ function isSvg(string) {
3047
2671
  }
3048
2672
  return true;
3049
2673
  }
3050
- /**
3051
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
3052
- *
3053
- * @author John Molakvoæ <skjnldsv@protonmail.com>
3054
- *
3055
- * @license AGPL-3.0-or-later
3056
- *
3057
- * This program is free software: you can redistribute it and/or modify
3058
- * it under the terms of the GNU Affero General Public License as
3059
- * published by the Free Software Foundation, either version 3 of the
3060
- * License, or (at your option) any later version.
3061
- *
3062
- * This program is distributed in the hope that it will be useful,
3063
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3064
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3065
- * GNU Affero General Public License for more details.
3066
- *
3067
- * You should have received a copy of the GNU Affero General Public License
3068
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
3069
- *
3070
- */
3071
2674
  class View {
3072
2675
  _view;
3073
2676
  constructor(view) {
@@ -3175,28 +2778,6 @@ const isValidView = function(view) {
3175
2778
  }
3176
2779
  return true;
3177
2780
  };
3178
- /**
3179
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
3180
- *
3181
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
3182
- * @author John Molakvoæ <skjnldsv@protonmail.com>
3183
- *
3184
- * @license AGPL-3.0-or-later
3185
- *
3186
- * This program is free software: you can redistribute it and/or modify
3187
- * it under the terms of the GNU Affero General Public License as
3188
- * published by the Free Software Foundation, either version 3 of the
3189
- * License, or (at your option) any later version.
3190
- *
3191
- * This program is distributed in the hope that it will be useful,
3192
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3193
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3194
- * GNU Affero General Public License for more details.
3195
- *
3196
- * You should have received a copy of the GNU Affero General Public License
3197
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
3198
- *
3199
- */
3200
2781
  const addNewFileMenuEntry = function(entry) {
3201
2782
  const newFileMenu = getNewFileMenu();
3202
2783
  return newFileMenu.registerEntry(entry);
@@ -3248,6 +2829,7 @@ export {
3248
2829
  getFileListHeaders,
3249
2830
  getNavigation,
3250
2831
  getNewFileMenuEntries,
2832
+ getUniqueName,
3251
2833
  isFilenameValid,
3252
2834
  orderBy,
3253
2835
  parseFileSize,