@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.cjs CHANGED
@@ -8,27 +8,7 @@ const router = require("@nextcloud/router");
8
8
  const webdav = require("webdav");
9
9
  const cancelablePromise = require("cancelable-promise");
10
10
  const l10n = require("@nextcloud/l10n");
11
- /**
12
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
13
- *
14
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
15
- *
16
- * @license AGPL-3.0-or-later
17
- *
18
- * This program is free software: you can redistribute it and/or modify
19
- * it under the terms of the GNU Affero General Public License as
20
- * published by the Free Software Foundation, either version 3 of the
21
- * License, or (at your option) any later version.
22
- *
23
- * This program is distributed in the hope that it will be useful,
24
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
25
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26
- * GNU Affero General Public License for more details.
27
- *
28
- * You should have received a copy of the GNU Affero General Public License
29
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
30
- *
31
- */
11
+ const typescriptEventTarget = require("typescript-event-target");
32
12
  const getLogger = (user) => {
33
13
  if (user === null) {
34
14
  return logger$1.getLoggerBuilder().setApp("files").build();
@@ -36,27 +16,6 @@ const getLogger = (user) => {
36
16
  return logger$1.getLoggerBuilder().setApp("files").setUid(user.uid).build();
37
17
  };
38
18
  const logger = getLogger(auth.getCurrentUser());
39
- /**
40
- * @copyright Copyright (c) 2021 John Molakvoæ <skjnldsv@protonmail.com>
41
- *
42
- * @author John Molakvoæ <skjnldsv@protonmail.com>
43
- *
44
- * @license AGPL-3.0-or-later
45
- *
46
- * This program is free software: you can redistribute it and/or modify
47
- * it under the terms of the GNU Affero General Public License as
48
- * published by the Free Software Foundation, either version 3 of the
49
- * License, or (at your option) any later version.
50
- *
51
- * This program is distributed in the hope that it will be useful,
52
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
53
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
54
- * GNU Affero General Public License for more details.
55
- *
56
- * You should have received a copy of the GNU Affero General Public License
57
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
58
- *
59
- */
60
19
  var NewMenuEntryCategory = /* @__PURE__ */ ((NewMenuEntryCategory2) => {
61
20
  NewMenuEntryCategory2[NewMenuEntryCategory2["UploadFromDevice"] = 0] = "UploadFromDevice";
62
21
  NewMenuEntryCategory2[NewMenuEntryCategory2["CreateNew"] = 1] = "CreateNew";
@@ -123,27 +82,6 @@ const getNewFileMenu = function() {
123
82
  }
124
83
  return window._nc_newfilemenu;
125
84
  };
126
- /**
127
- * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
128
- *
129
- * @author John Molakvoæ <skjnldsv@protonmail.com>
130
- *
131
- * @license AGPL-3.0-or-later
132
- *
133
- * This program is free software: you can redistribute it and/or modify
134
- * it under the terms of the GNU Affero General Public License as
135
- * published by the Free Software Foundation, either version 3 of the
136
- * License, or (at your option) any later version.
137
- *
138
- * This program is distributed in the hope that it will be useful,
139
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
140
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
141
- * GNU Affero General Public License for more details.
142
- *
143
- * You should have received a copy of the GNU Affero General Public License
144
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
145
- *
146
- */
147
85
  var DefaultType = /* @__PURE__ */ ((DefaultType2) => {
148
86
  DefaultType2["DEFAULT"] = "default";
149
87
  DefaultType2["HIDDEN"] = "hidden";
@@ -248,27 +186,6 @@ const getFileActions = function() {
248
186
  }
249
187
  return window._nc_fileactions;
250
188
  };
251
- /**
252
- * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
253
- *
254
- * @author John Molakvoæ <skjnldsv@protonmail.com>
255
- *
256
- * @license AGPL-3.0-or-later
257
- *
258
- * This program is free software: you can redistribute it and/or modify
259
- * it under the terms of the GNU Affero General Public License as
260
- * published by the Free Software Foundation, either version 3 of the
261
- * License, or (at your option) any later version.
262
- *
263
- * This program is distributed in the hope that it will be useful,
264
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
265
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
266
- * GNU Affero General Public License for more details.
267
- *
268
- * You should have received a copy of the GNU Affero General Public License
269
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
270
- *
271
- */
272
189
  class Header {
273
190
  _header;
274
191
  constructor(header) {
@@ -326,27 +243,6 @@ const getFileListHeaders = function() {
326
243
  }
327
244
  return window._nc_filelistheader;
328
245
  };
329
- /**
330
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
331
- *
332
- * @author John Molakvoæ <skjnldsv@protonmail.com>
333
- *
334
- * @license AGPL-3.0-or-later
335
- *
336
- * This program is free software: you can redistribute it and/or modify
337
- * it under the terms of the GNU Affero General Public License as
338
- * published by the Free Software Foundation, either version 3 of the
339
- * License, or (at your option) any later version.
340
- *
341
- * This program is distributed in the hope that it will be useful,
342
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
343
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
344
- * GNU Affero General Public License for more details.
345
- *
346
- * You should have received a copy of the GNU Affero General Public License
347
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
348
- *
349
- */
350
246
  var Permission = /* @__PURE__ */ ((Permission2) => {
351
247
  Permission2[Permission2["NONE"] = 0] = "NONE";
352
248
  Permission2[Permission2["CREATE"] = 4] = "CREATE";
@@ -357,28 +253,6 @@ var Permission = /* @__PURE__ */ ((Permission2) => {
357
253
  Permission2[Permission2["ALL"] = 31] = "ALL";
358
254
  return Permission2;
359
255
  })(Permission || {});
360
- /**
361
- * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
362
- *
363
- * @author John Molakvoæ <skjnldsv@protonmail.com>
364
- * @author Ferdinand Thiessen <opensource@fthiessen.de>
365
- *
366
- * @license AGPL-3.0-or-later
367
- *
368
- * This program is free software: you can redistribute it and/or modify
369
- * it under the terms of the GNU Affero General Public License as
370
- * published by the Free Software Foundation, either version 3 of the
371
- * License, or (at your option) any later version.
372
- *
373
- * This program is distributed in the hope that it will be useful,
374
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
375
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376
- * GNU Affero General Public License for more details.
377
- *
378
- * You should have received a copy of the GNU Affero General Public License
379
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
380
- *
381
- */
382
256
  const defaultDavProperties = [
383
257
  "d:getcontentlength",
384
258
  "d:getcontenttype",
@@ -514,28 +388,6 @@ const davGetRecentSearch = function(lastModified) {
514
388
  </d:basicsearch>
515
389
  </d:searchrequest>`;
516
390
  };
517
- /**
518
- * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
519
- *
520
- * @author John Molakvoæ <skjnldsv@protonmail.com>
521
- * @author Ferdinand Thiessen <opensource@fthiessen.de>
522
- *
523
- * @license AGPL-3.0-or-later
524
- *
525
- * This program is free software: you can redistribute it and/or modify
526
- * it under the terms of the GNU Affero General Public License as
527
- * published by the Free Software Foundation, either version 3 of the
528
- * License, or (at your option) any later version.
529
- *
530
- * This program is distributed in the hope that it will be useful,
531
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
532
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
533
- * GNU Affero General Public License for more details.
534
- *
535
- * You should have received a copy of the GNU Affero General Public License
536
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
537
- *
538
- */
539
391
  const davParsePermissions = function(permString = "") {
540
392
  let permissions = Permission.NONE;
541
393
  if (!permString) {
@@ -558,53 +410,6 @@ const davParsePermissions = function(permString = "") {
558
410
  }
559
411
  return permissions;
560
412
  };
561
- /**
562
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
563
- *
564
- * @author John Molakvoæ <skjnldsv@protonmail.com>
565
- *
566
- * @license AGPL-3.0-or-later
567
- *
568
- * This program is free software: you can redistribute it and/or modify
569
- * it under the terms of the GNU Affero General Public License as
570
- * published by the Free Software Foundation, either version 3 of the
571
- * License, or (at your option) any later version.
572
- *
573
- * This program is distributed in the hope that it will be useful,
574
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
575
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
576
- * GNU Affero General Public License for more details.
577
- *
578
- * You should have received a copy of the GNU Affero General Public License
579
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
580
- *
581
- */
582
- var FileType = /* @__PURE__ */ ((FileType2) => {
583
- FileType2["Folder"] = "folder";
584
- FileType2["File"] = "file";
585
- return FileType2;
586
- })(FileType || {});
587
- /**
588
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
589
- *
590
- * @author John Molakvoæ <skjnldsv@protonmail.com>
591
- *
592
- * @license AGPL-3.0-or-later
593
- *
594
- * This program is free software: you can redistribute it and/or modify
595
- * it under the terms of the GNU Affero General Public License as
596
- * published by the Free Software Foundation, either version 3 of the
597
- * License, or (at your option) any later version.
598
- *
599
- * This program is distributed in the hope that it will be useful,
600
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
601
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
602
- * GNU Affero General Public License for more details.
603
- *
604
- * You should have received a copy of the GNU Affero General Public License
605
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
606
- *
607
- */
608
413
  const isDavRessource = function(source, davService) {
609
414
  return source.match(davService) !== null;
610
415
  };
@@ -663,27 +468,6 @@ const validateData = (data, davService) => {
663
468
  throw new Error("Status must be a valid NodeStatus");
664
469
  }
665
470
  };
666
- /**
667
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
668
- *
669
- * @author John Molakvoæ <skjnldsv@protonmail.com>
670
- *
671
- * @license AGPL-3.0-or-later
672
- *
673
- * This program is free software: you can redistribute it and/or modify
674
- * it under the terms of the GNU Affero General Public License as
675
- * published by the Free Software Foundation, either version 3 of the
676
- * License, or (at your option) any later version.
677
- *
678
- * This program is distributed in the hope that it will be useful,
679
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
680
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
681
- * GNU Affero General Public License for more details.
682
- *
683
- * You should have received a copy of the GNU Affero General Public License
684
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
685
- *
686
- */
687
471
  var NodeStatus = /* @__PURE__ */ ((NodeStatus2) => {
688
472
  NodeStatus2["NEW"] = "new";
689
473
  NodeStatus2["FAILED"] = "failed";
@@ -958,53 +742,16 @@ class Node {
958
742
  }
959
743
  }
960
744
  }
961
- /**
962
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
963
- *
964
- * @author John Molakvoæ <skjnldsv@protonmail.com>
965
- *
966
- * @license AGPL-3.0-or-later
967
- *
968
- * This program is free software: you can redistribute it and/or modify
969
- * it under the terms of the GNU Affero General Public License as
970
- * published by the Free Software Foundation, either version 3 of the
971
- * License, or (at your option) any later version.
972
- *
973
- * This program is distributed in the hope that it will be useful,
974
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
975
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
976
- * GNU Affero General Public License for more details.
977
- *
978
- * You should have received a copy of the GNU Affero General Public License
979
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
980
- *
981
- */
745
+ var FileType = /* @__PURE__ */ ((FileType2) => {
746
+ FileType2["Folder"] = "folder";
747
+ FileType2["File"] = "file";
748
+ return FileType2;
749
+ })(FileType || {});
982
750
  class File extends Node {
983
751
  get type() {
984
752
  return FileType.File;
985
753
  }
986
754
  }
987
- /**
988
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
989
- *
990
- * @author John Molakvoæ <skjnldsv@protonmail.com>
991
- *
992
- * @license AGPL-3.0-or-later
993
- *
994
- * This program is free software: you can redistribute it and/or modify
995
- * it under the terms of the GNU Affero General Public License as
996
- * published by the Free Software Foundation, either version 3 of the
997
- * License, or (at your option) any later version.
998
- *
999
- * This program is distributed in the hope that it will be useful,
1000
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1001
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1002
- * GNU Affero General Public License for more details.
1003
- *
1004
- * You should have received a copy of the GNU Affero General Public License
1005
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1006
- *
1007
- */
1008
755
  class Folder extends Node {
1009
756
  constructor(data) {
1010
757
  super({
@@ -1022,28 +769,6 @@ class Folder extends Node {
1022
769
  return "httpd/unix-directory";
1023
770
  }
1024
771
  }
1025
- /**
1026
- * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
1027
- *
1028
- * @author John Molakvoæ <skjnldsv@protonmail.com>
1029
- * @author Ferdinand Thiessen <opensource@fthiessen.de>
1030
- *
1031
- * @license AGPL-3.0-or-later
1032
- *
1033
- * This program is free software: you can redistribute it and/or modify
1034
- * it under the terms of the GNU Affero General Public License as
1035
- * published by the Free Software Foundation, either version 3 of the
1036
- * License, or (at your option) any later version.
1037
- *
1038
- * This program is distributed in the hope that it will be useful,
1039
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1040
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1041
- * GNU Affero General Public License for more details.
1042
- *
1043
- * You should have received a copy of the GNU Affero General Public License
1044
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1045
- *
1046
- */
1047
772
  const davRootPath = `/files/${auth.getCurrentUser()?.uid}`;
1048
773
  const davRemoteURL = router.generateRemoteUrl("dav");
1049
774
  const davGetClient = function(remoteURL = davRemoteURL, headers = {}) {
@@ -1104,12 +829,15 @@ const davResultToNode = function(node, filesRoot = davRootPath, remoteURL = davR
1104
829
  const props = node.props;
1105
830
  const permissions = davParsePermissions(props?.permissions);
1106
831
  const owner = String(props?.["owner-id"] || userId);
832
+ const id = props.fileid || 0;
1107
833
  const nodeData = {
1108
- id: props?.fileid || 0,
834
+ id,
1109
835
  source: `${remoteURL}${node.filename}`,
1110
836
  mtime: new Date(Date.parse(node.lastmod)),
1111
837
  mime: node.mime || "application/octet-stream",
1112
838
  size: props?.size || Number.parseInt(props.getcontentlength || "0"),
839
+ // The fileid is set to -1 for failed requests
840
+ status: id < 0 ? NodeStatus.FAILED : void 0,
1113
841
  permissions,
1114
842
  owner,
1115
843
  root: filesRoot,
@@ -1133,28 +861,21 @@ function isFilenameValid(filename) {
1133
861
  }
1134
862
  return true;
1135
863
  }
1136
- /**
1137
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
1138
- *
1139
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
1140
- * @author John Molakvoæ <skjnldsv@protonmail.com>
1141
- *
1142
- * @license AGPL-3.0-or-later
1143
- *
1144
- * This program is free software: you can redistribute it and/or modify
1145
- * it under the terms of the GNU Affero General Public License as
1146
- * published by the Free Software Foundation, either version 3 of the
1147
- * License, or (at your option) any later version.
1148
- *
1149
- * This program is distributed in the hope that it will be useful,
1150
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1151
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1152
- * GNU Affero General Public License for more details.
1153
- *
1154
- * You should have received a copy of the GNU Affero General Public License
1155
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1156
- *
1157
- */
864
+ function getUniqueName(name, otherNames, options) {
865
+ const opts = {
866
+ suffix: (n) => `(${n})`,
867
+ ignoreFileExtension: false,
868
+ ...options
869
+ };
870
+ let newName = name;
871
+ let i = 1;
872
+ while (otherNames.includes(newName)) {
873
+ const ext = opts.ignoreFileExtension ? "" : path.extname(name);
874
+ const base = path.basename(name, ext);
875
+ newName = `${base} ${opts.suffix(i++)}${ext}`;
876
+ }
877
+ return newName;
878
+ }
1158
879
  const humanList = ["B", "KB", "MB", "GB", "TB", "PB"];
1159
880
  const humanListBinary = ["B", "KiB", "MiB", "GiB", "TiB", "PiB"];
1160
881
  function formatFileSize(size, skipSmallSizes = false, binaryPrefixes = false, base1000 = false) {
@@ -1241,6 +962,7 @@ function sortNodes(nodes, options = {}) {
1241
962
  sortingOrder: "asc",
1242
963
  ...options
1243
964
  };
965
+ const basename = (name) => name.lastIndexOf(".") > 0 ? name.slice(0, name.lastIndexOf(".")) : name;
1244
966
  const identifiers = [
1245
967
  // 1: Sort favorites first if enabled
1246
968
  ...sortingOptions.sortFavoritesFirst ? [(v) => v.attributes?.favorite !== 1] : [],
@@ -1249,7 +971,7 @@ function sortNodes(nodes, options = {}) {
1249
971
  // 3: Use sorting mode if NOT basename (to be able to use displayName too)
1250
972
  ...sortingOptions.sortingMode !== "basename" ? [(v) => v[sortingOptions.sortingMode]] : [],
1251
973
  // 4: Use displayName if available, fallback to name
1252
- (v) => v.attributes?.displayName || v.basename,
974
+ (v) => basename(v.attributes?.displayName || v.basename),
1253
975
  // 5: Finally, use basename if all previous sorting methods failed
1254
976
  (v) => v.basename
1255
977
  ];
@@ -1269,51 +991,54 @@ function sortNodes(nodes, options = {}) {
1269
991
  ];
1270
992
  return orderBy(nodes, identifiers, orders);
1271
993
  }
1272
- /**
1273
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
1274
- *
1275
- * @author John Molakvoæ <skjnldsv@protonmail.com>
1276
- *
1277
- * @license AGPL-3.0-or-later
1278
- *
1279
- * This program is free software: you can redistribute it and/or modify
1280
- * it under the terms of the GNU Affero General Public License as
1281
- * published by the Free Software Foundation, either version 3 of the
1282
- * License, or (at your option) any later version.
1283
- *
1284
- * This program is distributed in the hope that it will be useful,
1285
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1286
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1287
- * GNU Affero General Public License for more details.
1288
- *
1289
- * You should have received a copy of the GNU Affero General Public License
1290
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1291
- *
1292
- */
1293
- class Navigation {
994
+ class Navigation extends typescriptEventTarget.TypedEventTarget {
1294
995
  _views = [];
1295
996
  _currentView = null;
997
+ /**
998
+ * Register a new view on the navigation
999
+ * @param view The view to register
1000
+ * @throws `Error` is thrown if a view with the same id is already registered
1001
+ */
1296
1002
  register(view) {
1297
1003
  if (this._views.find((search) => search.id === view.id)) {
1298
1004
  throw new Error(`View id ${view.id} is already registered`);
1299
1005
  }
1300
1006
  this._views.push(view);
1007
+ this.dispatchTypedEvent("update", new CustomEvent("update"));
1301
1008
  }
1009
+ /**
1010
+ * Remove a registered view
1011
+ * @param id The id of the view to remove
1012
+ */
1302
1013
  remove(id) {
1303
1014
  const index = this._views.findIndex((view) => view.id === id);
1304
1015
  if (index !== -1) {
1305
1016
  this._views.splice(index, 1);
1017
+ this.dispatchTypedEvent("update", new CustomEvent("update"));
1306
1018
  }
1307
1019
  }
1308
- get views() {
1309
- return this._views;
1310
- }
1020
+ /**
1021
+ * Set the currently active view
1022
+ * @fires UpdateActiveViewEvent
1023
+ * @param view New active view
1024
+ */
1311
1025
  setActive(view) {
1312
1026
  this._currentView = view;
1027
+ const event = new CustomEvent("updateActive", { detail: view });
1028
+ this.dispatchTypedEvent("updateActive", event);
1313
1029
  }
1030
+ /**
1031
+ * The currently active files view
1032
+ */
1314
1033
  get active() {
1315
1034
  return this._currentView;
1316
1035
  }
1036
+ /**
1037
+ * All registered views
1038
+ */
1039
+ get views() {
1040
+ return this._views;
1041
+ }
1317
1042
  }
1318
1043
  const getNavigation = function() {
1319
1044
  if (typeof window._nc_navigation === "undefined") {
@@ -1322,27 +1047,6 @@ const getNavigation = function() {
1322
1047
  }
1323
1048
  return window._nc_navigation;
1324
1049
  };
1325
- /**
1326
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
1327
- *
1328
- * @author John Molakvoæ <skjnldsv@protonmail.com>
1329
- *
1330
- * @license AGPL-3.0-or-later
1331
- *
1332
- * This program is free software: you can redistribute it and/or modify
1333
- * it under the terms of the GNU Affero General Public License as
1334
- * published by the Free Software Foundation, either version 3 of the
1335
- * License, or (at your option) any later version.
1336
- *
1337
- * This program is distributed in the hope that it will be useful,
1338
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1339
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1340
- * GNU Affero General Public License for more details.
1341
- *
1342
- * You should have received a copy of the GNU Affero General Public License
1343
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1344
- *
1345
- */
1346
1050
  class Column {
1347
1051
  _column;
1348
1052
  constructor(column) {
@@ -1457,8 +1161,7 @@ validator$2.validate = function(xmlData, options) {
1457
1161
  if (xmlData[i] === "<" && xmlData[i + 1] === "?") {
1458
1162
  i += 2;
1459
1163
  i = readPI(xmlData, i);
1460
- if (i.err)
1461
- return i;
1164
+ if (i.err) return i;
1462
1165
  } else if (xmlData[i] === "<") {
1463
1166
  let tagStartPos = i;
1464
1167
  i++;
@@ -1532,8 +1235,7 @@ validator$2.validate = function(xmlData, options) {
1532
1235
  }
1533
1236
  if (reachedRoot === true) {
1534
1237
  return getErrorObject("InvalidXml", "Multiple possible root nodes found.", getLineNumberForPosition(xmlData, i));
1535
- } else if (options.unpairedTags.indexOf(tagName) !== -1)
1536
- ;
1238
+ } else if (options.unpairedTags.indexOf(tagName) !== -1) ;
1537
1239
  else {
1538
1240
  tags.push({ tagName, tagStartPos });
1539
1241
  }
@@ -1547,8 +1249,7 @@ validator$2.validate = function(xmlData, options) {
1547
1249
  continue;
1548
1250
  } else if (xmlData[i + 1] === "?") {
1549
1251
  i = readPI(xmlData, ++i);
1550
- if (i.err)
1551
- return i;
1252
+ if (i.err) return i;
1552
1253
  } else {
1553
1254
  break;
1554
1255
  }
@@ -1643,8 +1344,7 @@ function readAttributeStr(xmlData, i) {
1643
1344
  if (xmlData[i] === doubleQuote || xmlData[i] === singleQuote) {
1644
1345
  if (startChar === "") {
1645
1346
  startChar = xmlData[i];
1646
- } else if (startChar !== xmlData[i])
1647
- ;
1347
+ } else if (startChar !== xmlData[i]) ;
1648
1348
  else {
1649
1349
  startChar = "";
1650
1350
  }
@@ -1805,13 +1505,11 @@ class XmlNode {
1805
1505
  this[":@"] = {};
1806
1506
  }
1807
1507
  add(key, val2) {
1808
- if (key === "__proto__")
1809
- key = "#__proto__";
1508
+ if (key === "__proto__") key = "#__proto__";
1810
1509
  this.child.push({ [key]: val2 });
1811
1510
  }
1812
1511
  addChild(node) {
1813
- if (node.tagname === "__proto__")
1814
- node.tagname = "#__proto__";
1512
+ if (node.tagname === "__proto__") node.tagname = "#__proto__";
1815
1513
  if (node[":@"] && Object.keys(node[":@"]).length > 0) {
1816
1514
  this.child.push({ [node.tagname]: node.child, [":@"]: node[":@"] });
1817
1515
  } else {
@@ -1838,16 +1536,11 @@ function readDocType$1(xmlData, i) {
1838
1536
  regx: RegExp(`&${entityName};`, "g"),
1839
1537
  val
1840
1538
  };
1841
- } else if (hasBody && isElement(xmlData, i))
1842
- i += 8;
1843
- else if (hasBody && isAttlist(xmlData, i))
1844
- i += 8;
1845
- else if (hasBody && isNotation(xmlData, i))
1846
- i += 9;
1847
- else if (isComment)
1848
- comment = true;
1849
- else
1850
- throw new Error("Invalid DOCTYPE");
1539
+ } else if (hasBody && isElement(xmlData, i)) i += 8;
1540
+ else if (hasBody && isAttlist(xmlData, i)) i += 8;
1541
+ else if (hasBody && isNotation(xmlData, i)) i += 9;
1542
+ else if (isComment) comment = true;
1543
+ else throw new Error("Invalid DOCTYPE");
1851
1544
  angleBracketsCount++;
1852
1545
  exp = "";
1853
1546
  } else if (xmlData[i] === ">") {
@@ -1882,8 +1575,7 @@ function readEntityExp(xmlData, i) {
1882
1575
  entityName2 += xmlData[i];
1883
1576
  }
1884
1577
  entityName2 = entityName2.trim();
1885
- if (entityName2.indexOf(" ") !== -1)
1886
- throw new Error("External entites are not supported");
1578
+ if (entityName2.indexOf(" ") !== -1) throw new Error("External entites are not supported");
1887
1579
  const startChar = xmlData[i++];
1888
1580
  let val2 = "";
1889
1581
  for (; i < xmlData.length && xmlData[i] !== startChar; i++) {
@@ -1892,28 +1584,23 @@ function readEntityExp(xmlData, i) {
1892
1584
  return [entityName2, val2, i];
1893
1585
  }
1894
1586
  function isComment(xmlData, i) {
1895
- if (xmlData[i + 1] === "!" && xmlData[i + 2] === "-" && xmlData[i + 3] === "-")
1896
- return true;
1587
+ if (xmlData[i + 1] === "!" && xmlData[i + 2] === "-" && xmlData[i + 3] === "-") return true;
1897
1588
  return false;
1898
1589
  }
1899
1590
  function isEntity(xmlData, i) {
1900
- if (xmlData[i + 1] === "!" && xmlData[i + 2] === "E" && xmlData[i + 3] === "N" && xmlData[i + 4] === "T" && xmlData[i + 5] === "I" && xmlData[i + 6] === "T" && xmlData[i + 7] === "Y")
1901
- return true;
1591
+ if (xmlData[i + 1] === "!" && xmlData[i + 2] === "E" && xmlData[i + 3] === "N" && xmlData[i + 4] === "T" && xmlData[i + 5] === "I" && xmlData[i + 6] === "T" && xmlData[i + 7] === "Y") return true;
1902
1592
  return false;
1903
1593
  }
1904
1594
  function isElement(xmlData, i) {
1905
- if (xmlData[i + 1] === "!" && xmlData[i + 2] === "E" && xmlData[i + 3] === "L" && xmlData[i + 4] === "E" && xmlData[i + 5] === "M" && xmlData[i + 6] === "E" && xmlData[i + 7] === "N" && xmlData[i + 8] === "T")
1906
- return true;
1595
+ if (xmlData[i + 1] === "!" && xmlData[i + 2] === "E" && xmlData[i + 3] === "L" && xmlData[i + 4] === "E" && xmlData[i + 5] === "M" && xmlData[i + 6] === "E" && xmlData[i + 7] === "N" && xmlData[i + 8] === "T") return true;
1907
1596
  return false;
1908
1597
  }
1909
1598
  function isAttlist(xmlData, i) {
1910
- if (xmlData[i + 1] === "!" && xmlData[i + 2] === "A" && xmlData[i + 3] === "T" && xmlData[i + 4] === "T" && xmlData[i + 5] === "L" && xmlData[i + 6] === "I" && xmlData[i + 7] === "S" && xmlData[i + 8] === "T")
1911
- return true;
1599
+ if (xmlData[i + 1] === "!" && xmlData[i + 2] === "A" && xmlData[i + 3] === "T" && xmlData[i + 4] === "T" && xmlData[i + 5] === "L" && xmlData[i + 6] === "I" && xmlData[i + 7] === "S" && xmlData[i + 8] === "T") return true;
1912
1600
  return false;
1913
1601
  }
1914
1602
  function isNotation(xmlData, i) {
1915
- if (xmlData[i + 1] === "!" && xmlData[i + 2] === "N" && xmlData[i + 3] === "O" && xmlData[i + 4] === "T" && xmlData[i + 5] === "A" && xmlData[i + 6] === "T" && xmlData[i + 7] === "I" && xmlData[i + 8] === "O" && xmlData[i + 9] === "N")
1916
- return true;
1603
+ if (xmlData[i + 1] === "!" && xmlData[i + 2] === "N" && xmlData[i + 3] === "O" && xmlData[i + 4] === "T" && xmlData[i + 5] === "A" && xmlData[i + 6] === "T" && xmlData[i + 7] === "I" && xmlData[i + 8] === "O" && xmlData[i + 9] === "N") return true;
1917
1604
  return false;
1918
1605
  }
1919
1606
  function validateEntityName(name) {
@@ -1940,11 +1627,9 @@ const consider = {
1940
1627
  };
1941
1628
  function toNumber$1(str, options = {}) {
1942
1629
  options = Object.assign({}, consider, options);
1943
- if (!str || typeof str !== "string")
1944
- return str;
1630
+ if (!str || typeof str !== "string") return str;
1945
1631
  let trimmedStr = str.trim();
1946
- if (options.skipLike !== void 0 && options.skipLike.test(trimmedStr))
1947
- return str;
1632
+ if (options.skipLike !== void 0 && options.skipLike.test(trimmedStr)) return str;
1948
1633
  else if (options.hex && hexRegex.test(trimmedStr)) {
1949
1634
  return Number.parseInt(trimmedStr, 16);
1950
1635
  } else {
@@ -1954,45 +1639,30 @@ function toNumber$1(str, options = {}) {
1954
1639
  const leadingZeros = match[2];
1955
1640
  let numTrimmedByZeros = trimZeros(match[3]);
1956
1641
  const eNotation = match[4] || match[6];
1957
- if (!options.leadingZeros && leadingZeros.length > 0 && sign && trimmedStr[2] !== ".")
1958
- return str;
1959
- else if (!options.leadingZeros && leadingZeros.length > 0 && !sign && trimmedStr[1] !== ".")
1960
- return str;
1642
+ if (!options.leadingZeros && leadingZeros.length > 0 && sign && trimmedStr[2] !== ".") return str;
1643
+ else if (!options.leadingZeros && leadingZeros.length > 0 && !sign && trimmedStr[1] !== ".") return str;
1961
1644
  else {
1962
1645
  const num = Number(trimmedStr);
1963
1646
  const numStr = "" + num;
1964
1647
  if (numStr.search(/[eE]/) !== -1) {
1965
- if (options.eNotation)
1966
- return num;
1967
- else
1968
- return str;
1648
+ if (options.eNotation) return num;
1649
+ else return str;
1969
1650
  } else if (eNotation) {
1970
- if (options.eNotation)
1971
- return num;
1972
- else
1973
- return str;
1651
+ if (options.eNotation) return num;
1652
+ else return str;
1974
1653
  } else if (trimmedStr.indexOf(".") !== -1) {
1975
- if (numStr === "0" && numTrimmedByZeros === "")
1976
- return num;
1977
- else if (numStr === numTrimmedByZeros)
1978
- return num;
1979
- else if (sign && numStr === "-" + numTrimmedByZeros)
1980
- return num;
1981
- else
1982
- return str;
1654
+ if (numStr === "0" && numTrimmedByZeros === "") return num;
1655
+ else if (numStr === numTrimmedByZeros) return num;
1656
+ else if (sign && numStr === "-" + numTrimmedByZeros) return num;
1657
+ else return str;
1983
1658
  }
1984
1659
  if (leadingZeros) {
1985
- if (numTrimmedByZeros === numStr)
1986
- return num;
1987
- else if (sign + numTrimmedByZeros === numStr)
1988
- return num;
1989
- else
1990
- return str;
1660
+ if (numTrimmedByZeros === numStr) return num;
1661
+ else if (sign + numTrimmedByZeros === numStr) return num;
1662
+ else return str;
1991
1663
  }
1992
- if (trimmedStr === numStr)
1993
- return num;
1994
- else if (trimmedStr === sign + numStr)
1995
- return num;
1664
+ if (trimmedStr === numStr) return num;
1665
+ else if (trimmedStr === sign + numStr) return num;
1996
1666
  return str;
1997
1667
  }
1998
1668
  } else {
@@ -2003,12 +1673,9 @@ function toNumber$1(str, options = {}) {
2003
1673
  function trimZeros(numStr) {
2004
1674
  if (numStr && numStr.indexOf(".") !== -1) {
2005
1675
  numStr = numStr.replace(/0+$/, "");
2006
- if (numStr === ".")
2007
- numStr = "0";
2008
- else if (numStr[0] === ".")
2009
- numStr = "0" + numStr;
2010
- else if (numStr[numStr.length - 1] === ".")
2011
- numStr = numStr.substr(0, numStr.length - 1);
1676
+ if (numStr === ".") numStr = "0";
1677
+ else if (numStr[0] === ".") numStr = "0" + numStr;
1678
+ else if (numStr[numStr.length - 1] === ".") numStr = numStr.substr(0, numStr.length - 1);
2012
1679
  return numStr;
2013
1680
  }
2014
1681
  return numStr;
@@ -2076,8 +1743,7 @@ function parseTextData(val2, tagName, jPath, dontTrim, hasAttributes, isLeafNode
2076
1743
  val2 = val2.trim();
2077
1744
  }
2078
1745
  if (val2.length > 0) {
2079
- if (!escapeEntities)
2080
- val2 = this.replaceEntitiesValue(val2);
1746
+ if (!escapeEntities) val2 = this.replaceEntitiesValue(val2);
2081
1747
  const newval = this.options.tagValueProcessor(tagName, val2, jPath, hasAttributes, isLeafNode);
2082
1748
  if (newval === null || newval === void 0) {
2083
1749
  return val2;
@@ -2123,8 +1789,7 @@ function buildAttributesMap(attrStr, jPath, tagName) {
2123
1789
  if (this.options.transformAttributeName) {
2124
1790
  aName = this.options.transformAttributeName(aName);
2125
1791
  }
2126
- if (aName === "__proto__")
2127
- aName = "#__proto__";
1792
+ if (aName === "__proto__") aName = "#__proto__";
2128
1793
  if (oldVal !== void 0) {
2129
1794
  if (this.options.trimValues) {
2130
1795
  oldVal = oldVal.trim();
@@ -2199,11 +1864,9 @@ const parseXml = function(xmlData) {
2199
1864
  i = closeIndex;
2200
1865
  } else if (xmlData[i + 1] === "?") {
2201
1866
  let tagData = readTagExp(xmlData, i, false, "?>");
2202
- if (!tagData)
2203
- throw new Error("Pi Tag is not closed.");
1867
+ if (!tagData) throw new Error("Pi Tag is not closed.");
2204
1868
  textData = this.saveTextToParentTag(textData, currentNode, jPath);
2205
- if (this.options.ignoreDeclaration && tagData.tagName === "?xml" || this.options.ignorePiTags)
2206
- ;
1869
+ if (this.options.ignoreDeclaration && tagData.tagName === "?xml" || this.options.ignorePiTags) ;
2207
1870
  else {
2208
1871
  const childNode = new xmlNode(tagData.tagName);
2209
1872
  childNode.add(this.options.textNodeName, "");
@@ -2230,8 +1893,7 @@ const parseXml = function(xmlData) {
2230
1893
  const tagExp = xmlData.substring(i + 9, closeIndex);
2231
1894
  textData = this.saveTextToParentTag(textData, currentNode, jPath);
2232
1895
  let val2 = this.parseTextData(tagExp, currentNode.tagname, jPath, true, false, true, true);
2233
- if (val2 == void 0)
2234
- val2 = "";
1896
+ if (val2 == void 0) val2 = "";
2235
1897
  if (this.options.cdataPropName) {
2236
1898
  currentNode.add(this.options.cdataPropName, [{ [this.options.textNodeName]: tagExp }]);
2237
1899
  } else {
@@ -2276,8 +1938,7 @@ const parseXml = function(xmlData) {
2276
1938
  i = result.closeIndex;
2277
1939
  } else {
2278
1940
  const result2 = this.readStopNodeData(xmlData, rawTagName, closeIndex + 1);
2279
- if (!result2)
2280
- throw new Error(`Unexpected end of ${rawTagName}`);
1941
+ if (!result2) throw new Error(`Unexpected end of ${rawTagName}`);
2281
1942
  i = result2.i;
2282
1943
  tagContent = result2.tagContent;
2283
1944
  }
@@ -2330,8 +1991,7 @@ const parseXml = function(xmlData) {
2330
1991
  };
2331
1992
  function addChild(currentNode, childNode, jPath) {
2332
1993
  const result = this.options.updateTag(childNode.tagname, jPath, childNode[":@"]);
2333
- if (result === false)
2334
- ;
1994
+ if (result === false) ;
2335
1995
  else if (typeof result === "string") {
2336
1996
  childNode.tagname = result;
2337
1997
  currentNode.addChild(childNode);
@@ -2361,8 +2021,7 @@ const replaceEntitiesValue$1 = function(val2) {
2361
2021
  };
2362
2022
  function saveTextToParentTag(textData, currentNode, jPath, isLeafNode) {
2363
2023
  if (textData) {
2364
- if (isLeafNode === void 0)
2365
- isLeafNode = Object.keys(currentNode.child).length === 0;
2024
+ if (isLeafNode === void 0) isLeafNode = Object.keys(currentNode.child).length === 0;
2366
2025
  textData = this.parseTextData(
2367
2026
  textData,
2368
2027
  currentNode.tagname,
@@ -2381,8 +2040,7 @@ function isItStopNode(stopNodes, jPath, currentTagName) {
2381
2040
  const allNodesExp = "*." + currentTagName;
2382
2041
  for (const stopNodePath in stopNodes) {
2383
2042
  const stopNodeExp = stopNodes[stopNodePath];
2384
- if (allNodesExp === stopNodeExp || jPath === stopNodeExp)
2385
- return true;
2043
+ if (allNodesExp === stopNodeExp || jPath === stopNodeExp) return true;
2386
2044
  }
2387
2045
  return false;
2388
2046
  }
@@ -2392,8 +2050,7 @@ function tagExpWithClosingIndex(xmlData, i, closingChar = ">") {
2392
2050
  for (let index = i; index < xmlData.length; index++) {
2393
2051
  let ch = xmlData[index];
2394
2052
  if (attrBoundary) {
2395
- if (ch === attrBoundary)
2396
- attrBoundary = "";
2053
+ if (ch === attrBoundary) attrBoundary = "";
2397
2054
  } else if (ch === '"' || ch === "'") {
2398
2055
  attrBoundary = ch;
2399
2056
  } else if (ch === closingChar[0]) {
@@ -2426,8 +2083,7 @@ function findClosingIndex(xmlData, str, i, errMsg) {
2426
2083
  }
2427
2084
  function readTagExp(xmlData, i, removeNSPrefix, closingChar = ">") {
2428
2085
  const result = tagExpWithClosingIndex(xmlData, i + 1, closingChar);
2429
- if (!result)
2430
- return;
2086
+ if (!result) return;
2431
2087
  let tagExp = result.data;
2432
2088
  const closeIndex = result.index;
2433
2089
  const separatorIndex = tagExp.search(/\s/);
@@ -2496,12 +2152,9 @@ function readStopNodeData(xmlData, tagName, i) {
2496
2152
  function parseValue(val2, shouldParse, options) {
2497
2153
  if (shouldParse && typeof val2 === "string") {
2498
2154
  const newval = val2.trim();
2499
- if (newval === "true")
2500
- return true;
2501
- else if (newval === "false")
2502
- return false;
2503
- else
2504
- return toNumber(val2, options);
2155
+ if (newval === "true") return true;
2156
+ else if (newval === "false") return false;
2157
+ else return toNumber(val2, options);
2505
2158
  } else {
2506
2159
  if (util.isExist(val2)) {
2507
2160
  return val2;
@@ -2522,15 +2175,11 @@ function compress(arr, options, jPath) {
2522
2175
  const tagObj = arr[i];
2523
2176
  const property = propName$1(tagObj);
2524
2177
  let newJpath = "";
2525
- if (jPath === void 0)
2526
- newJpath = property;
2527
- else
2528
- newJpath = jPath + "." + property;
2178
+ if (jPath === void 0) newJpath = property;
2179
+ else newJpath = jPath + "." + property;
2529
2180
  if (property === options.textNodeName) {
2530
- if (text === void 0)
2531
- text = tagObj[property];
2532
- else
2533
- text += "" + tagObj[property];
2181
+ if (text === void 0) text = tagObj[property];
2182
+ else text += "" + tagObj[property];
2534
2183
  } else if (property === void 0) {
2535
2184
  continue;
2536
2185
  } else if (tagObj[property]) {
@@ -2541,10 +2190,8 @@ function compress(arr, options, jPath) {
2541
2190
  } else if (Object.keys(val2).length === 1 && val2[options.textNodeName] !== void 0 && !options.alwaysCreateTextNode) {
2542
2191
  val2 = val2[options.textNodeName];
2543
2192
  } else if (Object.keys(val2).length === 0) {
2544
- if (options.alwaysCreateTextNode)
2545
- val2[options.textNodeName] = "";
2546
- else
2547
- val2 = "";
2193
+ if (options.alwaysCreateTextNode) val2[options.textNodeName] = "";
2194
+ else val2 = "";
2548
2195
  }
2549
2196
  if (compressedObj[property] !== void 0 && compressedObj.hasOwnProperty(property)) {
2550
2197
  if (!Array.isArray(compressedObj[property])) {
@@ -2561,18 +2208,15 @@ function compress(arr, options, jPath) {
2561
2208
  }
2562
2209
  }
2563
2210
  if (typeof text === "string") {
2564
- if (text.length > 0)
2565
- compressedObj[options.textNodeName] = text;
2566
- } else if (text !== void 0)
2567
- compressedObj[options.textNodeName] = text;
2211
+ if (text.length > 0) compressedObj[options.textNodeName] = text;
2212
+ } else if (text !== void 0) compressedObj[options.textNodeName] = text;
2568
2213
  return compressedObj;
2569
2214
  }
2570
2215
  function propName$1(obj) {
2571
2216
  const keys = Object.keys(obj);
2572
2217
  for (let i = 0; i < keys.length; i++) {
2573
2218
  const key = keys[i];
2574
- if (key !== ":@")
2575
- return key;
2219
+ if (key !== ":@") return key;
2576
2220
  }
2577
2221
  }
2578
2222
  function assignAttributes(obj, attrMap, jpath, options) {
@@ -2616,16 +2260,14 @@ let XMLParser$1 = class XMLParser {
2616
2260
  * @param {boolean|Object} validationOption
2617
2261
  */
2618
2262
  parse(xmlData, validationOption) {
2619
- if (typeof xmlData === "string")
2620
- ;
2263
+ if (typeof xmlData === "string") ;
2621
2264
  else if (xmlData.toString) {
2622
2265
  xmlData = xmlData.toString();
2623
2266
  } else {
2624
2267
  throw new Error("XML data is accepted in String or Bytes[] form.");
2625
2268
  }
2626
2269
  if (validationOption) {
2627
- if (validationOption === true)
2628
- validationOption = {};
2270
+ if (validationOption === true) validationOption = {};
2629
2271
  const result = validator$1.validate(xmlData, validationOption);
2630
2272
  if (result !== true) {
2631
2273
  throw Error(`${result.err.msg}:${result.err.line}:${result.err.col}`);
@@ -2634,10 +2276,8 @@ let XMLParser$1 = class XMLParser {
2634
2276
  const orderedObjParser = new OrderedObjParser2(this.options);
2635
2277
  orderedObjParser.addExternalEntities(this.externalEntities);
2636
2278
  const orderedResult = orderedObjParser.parseXml(xmlData);
2637
- if (this.options.preserveOrder || orderedResult === void 0)
2638
- return orderedResult;
2639
- else
2640
- return prettify(orderedResult, this.options);
2279
+ if (this.options.preserveOrder || orderedResult === void 0) return orderedResult;
2280
+ else return prettify(orderedResult, this.options);
2641
2281
  }
2642
2282
  /**
2643
2283
  * Add Entity which is not by default supported by this library
@@ -2671,13 +2311,10 @@ function arrToStr(arr, options, jPath, indentation) {
2671
2311
  for (let i = 0; i < arr.length; i++) {
2672
2312
  const tagObj = arr[i];
2673
2313
  const tagName = propName(tagObj);
2674
- if (tagName === void 0)
2675
- continue;
2314
+ if (tagName === void 0) continue;
2676
2315
  let newJPath = "";
2677
- if (jPath.length === 0)
2678
- newJPath = tagName;
2679
- else
2680
- newJPath = `${jPath}.${tagName}`;
2316
+ if (jPath.length === 0) newJPath = tagName;
2317
+ else newJPath = `${jPath}.${tagName}`;
2681
2318
  if (tagName === options.textNodeName) {
2682
2319
  let tagText = tagObj[tagName];
2683
2320
  if (!isStopNode(newJPath, options)) {
@@ -2718,10 +2355,8 @@ function arrToStr(arr, options, jPath, indentation) {
2718
2355
  const tagStart = indentation + `<${tagName}${attStr}`;
2719
2356
  const tagValue = arrToStr(tagObj[tagName], options, newJPath, newIdentation);
2720
2357
  if (options.unpairedTags.indexOf(tagName) !== -1) {
2721
- if (options.suppressUnpairedNode)
2722
- xmlStr += tagStart + ">";
2723
- else
2724
- xmlStr += tagStart + "/>";
2358
+ if (options.suppressUnpairedNode) xmlStr += tagStart + ">";
2359
+ else xmlStr += tagStart + "/>";
2725
2360
  } else if ((!tagValue || tagValue.length === 0) && options.suppressEmptyNode) {
2726
2361
  xmlStr += tagStart + "/>";
2727
2362
  } else if (tagValue && tagValue.endsWith(">")) {
@@ -2743,18 +2378,15 @@ function propName(obj) {
2743
2378
  const keys = Object.keys(obj);
2744
2379
  for (let i = 0; i < keys.length; i++) {
2745
2380
  const key = keys[i];
2746
- if (!obj.hasOwnProperty(key))
2747
- continue;
2748
- if (key !== ":@")
2749
- return key;
2381
+ if (!obj.hasOwnProperty(key)) continue;
2382
+ if (key !== ":@") return key;
2750
2383
  }
2751
2384
  }
2752
2385
  function attr_to_str(attrMap, options) {
2753
2386
  let attrStr = "";
2754
2387
  if (attrMap && !options.ignoreAttributes) {
2755
2388
  for (let attr in attrMap) {
2756
- if (!attrMap.hasOwnProperty(attr))
2757
- continue;
2389
+ if (!attrMap.hasOwnProperty(attr)) continue;
2758
2390
  let attrVal = options.attributeValueProcessor(attr, attrMap[attr]);
2759
2391
  attrVal = replaceEntitiesValue(attrVal, options);
2760
2392
  if (attrVal === true && options.suppressBooleanAttributes) {
@@ -2770,8 +2402,7 @@ function isStopNode(jPath, options) {
2770
2402
  jPath = jPath.substr(0, jPath.length - options.textNodeName.length - 1);
2771
2403
  let tagName = jPath.substr(jPath.lastIndexOf(".") + 1);
2772
2404
  for (let index in options.stopNodes) {
2773
- if (options.stopNodes[index] === jPath || options.stopNodes[index] === "*." + tagName)
2774
- return true;
2405
+ if (options.stopNodes[index] === jPath || options.stopNodes[index] === "*." + tagName) return true;
2775
2406
  }
2776
2407
  return false;
2777
2408
  }
@@ -2859,8 +2490,7 @@ Builder.prototype.j2x = function(jObj, level) {
2859
2490
  let attrStr = "";
2860
2491
  let val2 = "";
2861
2492
  for (let key in jObj) {
2862
- if (!Object.prototype.hasOwnProperty.call(jObj, key))
2863
- continue;
2493
+ if (!Object.prototype.hasOwnProperty.call(jObj, key)) continue;
2864
2494
  if (typeof jObj[key] === "undefined") {
2865
2495
  if (this.isAttribute(key)) {
2866
2496
  val2 += "";
@@ -2892,13 +2522,10 @@ Builder.prototype.j2x = function(jObj, level) {
2892
2522
  let listTagVal = "";
2893
2523
  for (let j = 0; j < arrLen; j++) {
2894
2524
  const item = jObj[key][j];
2895
- if (typeof item === "undefined")
2896
- ;
2525
+ if (typeof item === "undefined") ;
2897
2526
  else if (item === null) {
2898
- if (key[0] === "?")
2899
- val2 += this.indentate(level) + "<" + key + "?" + this.tagEndChar;
2900
- else
2901
- val2 += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
2527
+ if (key[0] === "?") val2 += this.indentate(level) + "<" + key + "?" + this.tagEndChar;
2528
+ else val2 += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
2902
2529
  } else if (typeof item === "object") {
2903
2530
  if (this.options.oneListGroup) {
2904
2531
  listTagVal += this.j2x(item, level + 1).val;
@@ -2932,8 +2559,7 @@ Builder.prototype.buildAttrPairStr = function(attrName, val2) {
2932
2559
  val2 = this.replaceEntitiesValue(val2);
2933
2560
  if (this.options.suppressBooleanAttributes && val2 === "true") {
2934
2561
  return " " + attrName;
2935
- } else
2936
- return " " + attrName + '="' + val2 + '"';
2562
+ } else return " " + attrName + '="' + val2 + '"';
2937
2563
  };
2938
2564
  function processTextOrObjNode(object, key, level) {
2939
2565
  const result = this.j2x(object, level + 1);
@@ -2945,8 +2571,7 @@ function processTextOrObjNode(object, key, level) {
2945
2571
  }
2946
2572
  Builder.prototype.buildObjectNode = function(val2, key, attrStr, level) {
2947
2573
  if (val2 === "") {
2948
- if (key[0] === "?")
2949
- return this.indentate(level) + "<" + key + attrStr + "?" + this.tagEndChar;
2574
+ if (key[0] === "?") return this.indentate(level) + "<" + key + attrStr + "?" + this.tagEndChar;
2950
2575
  else {
2951
2576
  return this.indentate(level) + "<" + key + attrStr + this.closeTag(key) + this.tagEndChar;
2952
2577
  }
@@ -2969,8 +2594,7 @@ Builder.prototype.buildObjectNode = function(val2, key, attrStr, level) {
2969
2594
  Builder.prototype.closeTag = function(key) {
2970
2595
  let closeTag = "";
2971
2596
  if (this.options.unpairedTags.indexOf(key) !== -1) {
2972
- if (!this.options.suppressUnpairedNode)
2973
- closeTag = "/";
2597
+ if (!this.options.suppressUnpairedNode) closeTag = "/";
2974
2598
  } else if (this.options.suppressEmptyNode) {
2975
2599
  closeTag = "/";
2976
2600
  } else {
@@ -3049,27 +2673,6 @@ function isSvg(string) {
3049
2673
  }
3050
2674
  return true;
3051
2675
  }
3052
- /**
3053
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
3054
- *
3055
- * @author John Molakvoæ <skjnldsv@protonmail.com>
3056
- *
3057
- * @license AGPL-3.0-or-later
3058
- *
3059
- * This program is free software: you can redistribute it and/or modify
3060
- * it under the terms of the GNU Affero General Public License as
3061
- * published by the Free Software Foundation, either version 3 of the
3062
- * License, or (at your option) any later version.
3063
- *
3064
- * This program is distributed in the hope that it will be useful,
3065
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3066
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3067
- * GNU Affero General Public License for more details.
3068
- *
3069
- * You should have received a copy of the GNU Affero General Public License
3070
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
3071
- *
3072
- */
3073
2676
  class View {
3074
2677
  _view;
3075
2678
  constructor(view) {
@@ -3177,28 +2780,6 @@ const isValidView = function(view) {
3177
2780
  }
3178
2781
  return true;
3179
2782
  };
3180
- /**
3181
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
3182
- *
3183
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
3184
- * @author John Molakvoæ <skjnldsv@protonmail.com>
3185
- *
3186
- * @license AGPL-3.0-or-later
3187
- *
3188
- * This program is free software: you can redistribute it and/or modify
3189
- * it under the terms of the GNU Affero General Public License as
3190
- * published by the Free Software Foundation, either version 3 of the
3191
- * License, or (at your option) any later version.
3192
- *
3193
- * This program is distributed in the hope that it will be useful,
3194
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3195
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3196
- * GNU Affero General Public License for more details.
3197
- *
3198
- * You should have received a copy of the GNU Affero General Public License
3199
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
3200
- *
3201
- */
3202
2783
  const addNewFileMenuEntry = function(entry) {
3203
2784
  const newFileMenu = getNewFileMenu();
3204
2785
  return newFileMenu.registerEntry(entry);
@@ -3249,6 +2830,7 @@ exports.getFileActions = getFileActions;
3249
2830
  exports.getFileListHeaders = getFileListHeaders;
3250
2831
  exports.getNavigation = getNavigation;
3251
2832
  exports.getNewFileMenuEntries = getNewFileMenuEntries;
2833
+ exports.getUniqueName = getUniqueName;
3252
2834
  exports.isFilenameValid = isFilenameValid;
3253
2835
  exports.orderBy = orderBy;
3254
2836
  exports.parseFileSize = parseFileSize;