@nextcloud/files 3.12.0 → 3.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { o as logger } from "./chunks/dav-CQDyL7M_.mjs";
2
- import { q, F, s, N, t, P, c, l, m, n, a, g, p, b, r, d, h, f, k, j, e, i } from "./chunks/dav-CQDyL7M_.mjs";
1
+ import { o as logger, F as FileType } from "./chunks/dav-CQDyL7M_.mjs";
2
+ import { q, s, N, t, P, c, l, m, n, a, g, p, b, r, d, h, f, k, j, e, i } from "./chunks/dav-CQDyL7M_.mjs";
3
3
  import { TypedEventTarget } from "typescript-event-target";
4
4
  import require$$1 from "string_decoder";
5
5
  import { getCapabilities } from "@nextcloud/capabilities";
@@ -251,6 +251,7 @@ function requireRe() {
251
251
  const re2 = exports.re = [];
252
252
  const safeRe = exports.safeRe = [];
253
253
  const src = exports.src = [];
254
+ const safeSrc = exports.safeSrc = [];
254
255
  const t2 = exports.t = {};
255
256
  let R = 0;
256
257
  const LETTERDASHNUMBER = "[a-zA-Z0-9-]";
@@ -271,6 +272,7 @@ function requireRe() {
271
272
  debug(name, index, value);
272
273
  t2[name] = index;
273
274
  src[index] = value;
275
+ safeSrc[index] = safe;
274
276
  re2[index] = new RegExp(value, isGlobal ? "g" : void 0);
275
277
  safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
276
278
  };
@@ -279,8 +281,8 @@ function requireRe() {
279
281
  createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
280
282
  createToken("MAINVERSION", `(${src[t2.NUMERICIDENTIFIER]})\\.(${src[t2.NUMERICIDENTIFIER]})\\.(${src[t2.NUMERICIDENTIFIER]})`);
281
283
  createToken("MAINVERSIONLOOSE", `(${src[t2.NUMERICIDENTIFIERLOOSE]})\\.(${src[t2.NUMERICIDENTIFIERLOOSE]})\\.(${src[t2.NUMERICIDENTIFIERLOOSE]})`);
282
- createToken("PRERELEASEIDENTIFIER", `(?:${src[t2.NUMERICIDENTIFIER]}|${src[t2.NONNUMERICIDENTIFIER]})`);
283
- createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t2.NUMERICIDENTIFIERLOOSE]}|${src[t2.NONNUMERICIDENTIFIER]})`);
284
+ createToken("PRERELEASEIDENTIFIER", `(?:${src[t2.NONNUMERICIDENTIFIER]}|${src[t2.NUMERICIDENTIFIER]})`);
285
+ createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t2.NONNUMERICIDENTIFIER]}|${src[t2.NUMERICIDENTIFIERLOOSE]})`);
284
286
  createToken("PRERELEASE", `(?:-(${src[t2.PRERELEASEIDENTIFIER]}(?:\\.${src[t2.PRERELEASEIDENTIFIER]})*))`);
285
287
  createToken("PRERELEASELOOSE", `(?:-?(${src[t2.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t2.PRERELEASEIDENTIFIERLOOSE]})*))`);
286
288
  createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
@@ -349,6 +351,9 @@ function requireIdentifiers() {
349
351
  hasRequiredIdentifiers = 1;
350
352
  const numeric = /^[0-9]+$/;
351
353
  const compareIdentifiers = (a2, b2) => {
354
+ if (typeof a2 === "number" && typeof b2 === "number") {
355
+ return a2 === b2 ? 0 : a2 < b2 ? -1 : 1;
356
+ }
352
357
  const anum = numeric.test(a2);
353
358
  const bnum = numeric.test(b2);
354
359
  if (anum && bnum) {
@@ -455,7 +460,25 @@ function requireSemver() {
455
460
  if (!(other instanceof SemVer)) {
456
461
  other = new SemVer(other, this.options);
457
462
  }
458
- return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
463
+ if (this.major < other.major) {
464
+ return -1;
465
+ }
466
+ if (this.major > other.major) {
467
+ return 1;
468
+ }
469
+ if (this.minor < other.minor) {
470
+ return -1;
471
+ }
472
+ if (this.minor > other.minor) {
473
+ return 1;
474
+ }
475
+ if (this.patch < other.patch) {
476
+ return -1;
477
+ }
478
+ if (this.patch > other.patch) {
479
+ return 1;
480
+ }
481
+ return 0;
459
482
  }
460
483
  comparePre(other) {
461
484
  if (!(other instanceof SemVer)) {
@@ -511,6 +534,17 @@ function requireSemver() {
511
534
  // preminor will bump the version up to the next minor release, and immediately
512
535
  // down to pre-release. premajor and prepatch work the same way.
513
536
  inc(release, identifier, identifierBase) {
537
+ if (release.startsWith("pre")) {
538
+ if (!identifier && identifierBase === false) {
539
+ throw new Error("invalid increment argument: identifier is empty");
540
+ }
541
+ if (identifier) {
542
+ const match = `-${identifier}`.match(this.options.loose ? re2[t2.PRERELEASELOOSE] : re2[t2.PRERELEASE]);
543
+ if (!match || match[1] !== identifier) {
544
+ throw new Error(`invalid identifier: ${identifier}`);
545
+ }
546
+ }
547
+ }
514
548
  switch (release) {
515
549
  case "premajor":
516
550
  this.prerelease.length = 0;
@@ -538,6 +572,12 @@ function requireSemver() {
538
572
  }
539
573
  this.inc("pre", identifier, identifierBase);
540
574
  break;
575
+ case "release":
576
+ if (this.prerelease.length === 0) {
577
+ throw new Error(`version ${this.raw} is not a prerelease`);
578
+ }
579
+ this.prerelease.length = 0;
580
+ break;
541
581
  case "major":
542
582
  if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
543
583
  this.major++;
@@ -563,9 +603,6 @@ function requireSemver() {
563
603
  // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
564
604
  case "pre": {
565
605
  const base = Number(identifierBase) ? 1 : 0;
566
- if (!identifier && identifierBase === false) {
567
- throw new Error("invalid increment argument: identifier is empty");
568
- }
569
606
  if (this.prerelease.length === 0) {
570
607
  this.prerelease = [base];
571
608
  } else {
@@ -611,6 +648,18 @@ function requireSemver() {
611
648
  semver = SemVer;
612
649
  return semver;
613
650
  }
651
+ var major_1;
652
+ var hasRequiredMajor;
653
+ function requireMajor() {
654
+ if (hasRequiredMajor) return major_1;
655
+ hasRequiredMajor = 1;
656
+ const SemVer = requireSemver();
657
+ const major2 = (a2, loose) => new SemVer(a2, loose).major;
658
+ major_1 = major2;
659
+ return major_1;
660
+ }
661
+ var majorExports = requireMajor();
662
+ const major = /* @__PURE__ */ getDefaultExportFromCjs(majorExports);
614
663
  var parse_1;
615
664
  var hasRequiredParse;
616
665
  function requireParse() {
@@ -648,18 +697,10 @@ function requireValid() {
648
697
  }
649
698
  var validExports = requireValid();
650
699
  const valid = /* @__PURE__ */ getDefaultExportFromCjs(validExports);
651
- var major_1;
652
- var hasRequiredMajor;
653
- function requireMajor() {
654
- if (hasRequiredMajor) return major_1;
655
- hasRequiredMajor = 1;
656
- const SemVer = requireSemver();
657
- const major2 = (a2, loose) => new SemVer(a2, loose).major;
658
- major_1 = major2;
659
- return major_1;
660
- }
661
- var majorExports = requireMajor();
662
- const major = /* @__PURE__ */ getDefaultExportFromCjs(majorExports);
700
+ /*!
701
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
702
+ * SPDX-License-Identifier: GPL-3.0-or-later
703
+ */
663
704
  class ProxyBus {
664
705
  bus;
665
706
  constructor(bus2) {
@@ -673,7 +714,7 @@ class ProxyBus {
673
714
  this.bus = bus2;
674
715
  }
675
716
  getVersion() {
676
- return "3.3.2";
717
+ return "3.3.3";
677
718
  }
678
719
  subscribe(name, handler) {
679
720
  this.bus.subscribe(name, handler);
@@ -685,10 +726,14 @@ class ProxyBus {
685
726
  this.bus.emit(name, ...event);
686
727
  }
687
728
  }
729
+ /*!
730
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
731
+ * SPDX-License-Identifier: GPL-3.0-or-later
732
+ */
688
733
  class SimpleBus {
689
734
  handlers = /* @__PURE__ */ new Map();
690
735
  getVersion() {
691
- return "3.3.2";
736
+ return "3.3.3";
692
737
  }
693
738
  subscribe(name, handler) {
694
739
  this.handlers.set(
@@ -716,6 +761,10 @@ class SimpleBus {
716
761
  });
717
762
  }
718
763
  }
764
+ /*!
765
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
766
+ * SPDX-License-Identifier: GPL-3.0-or-later
767
+ */
719
768
  let bus = null;
720
769
  function getBus() {
721
770
  if (bus !== null) {
@@ -1025,10 +1074,10 @@ function requireSax() {
1025
1074
  }
1026
1075
  if (!Object.create) {
1027
1076
  Object.create = function(o) {
1028
- function F2() {
1077
+ function F() {
1029
1078
  }
1030
- F2.prototype = o;
1031
- var newf = new F2();
1079
+ F.prototype = o;
1080
+ var newf = new F();
1032
1081
  return newf;
1033
1082
  };
1034
1083
  }
@@ -2486,7 +2535,7 @@ class XmlTextDetector {
2486
2535
  return this.nesting === 0;
2487
2536
  }
2488
2537
  }
2489
- function isSvg(string) {
2538
+ function isSvg(string, { validate = true } = {}) {
2490
2539
  if (typeof string !== "string") {
2491
2540
  throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
2492
2541
  }
@@ -2494,9 +2543,21 @@ function isSvg(string) {
2494
2543
  if (string.length === 0) {
2495
2544
  return false;
2496
2545
  }
2497
- const xmlTextDetector = new XmlTextDetector();
2498
- xmlTextDetector.write(string);
2499
- return xmlTextDetector.isValid() && xmlTextDetector.fileType?.ext === "svg";
2546
+ const xmlTextDetector = new XmlTextDetector({ fullScan: validate });
2547
+ if (validate) {
2548
+ xmlTextDetector.write(string);
2549
+ if (!xmlTextDetector.isValid()) {
2550
+ return false;
2551
+ }
2552
+ } else {
2553
+ const chunkSize = 128;
2554
+ let offset = 0;
2555
+ while (string.length > offset && !xmlTextDetector.onEnd) {
2556
+ xmlTextDetector.write(string.slice(offset, Math.min(offset + chunkSize, string.length)));
2557
+ offset += chunkSize;
2558
+ }
2559
+ }
2560
+ return xmlTextDetector.fileType?.ext === "svg";
2500
2561
  }
2501
2562
  class View {
2502
2563
  _view;
@@ -2877,7 +2938,13 @@ function sortNodes(nodes, options = {}) {
2877
2938
  sortingOrder: "asc",
2878
2939
  ...options
2879
2940
  };
2880
- const basename2 = (name) => name.lastIndexOf(".") > 0 ? name.slice(0, name.lastIndexOf(".")) : name;
2941
+ function basename2(node) {
2942
+ const name = node.displayname || node.attributes?.displayname || node.basename || "";
2943
+ if (node.type === FileType.Folder) {
2944
+ return name;
2945
+ }
2946
+ return name.lastIndexOf(".") > 0 ? name.slice(0, name.lastIndexOf(".")) : name;
2947
+ }
2881
2948
  const identifiers2 = [
2882
2949
  // 1: Sort favorites first if enabled
2883
2950
  ...sortingOptions.sortFavoritesFirst ? [(v) => v.attributes?.favorite !== 1] : [],
@@ -2886,7 +2953,7 @@ function sortNodes(nodes, options = {}) {
2886
2953
  // 3: Use sorting mode if NOT basename (to be able to use display name too)
2887
2954
  ...sortingOptions.sortingMode !== "basename" ? [(v) => v[sortingOptions.sortingMode] ?? v.attributes[sortingOptions.sortingMode]] : [],
2888
2955
  // 4: Use display name if available, fallback to name
2889
- (v) => basename2(v.displayname || v.attributes?.displayname || v.basename || ""),
2956
+ (v) => basename2(v),
2890
2957
  // 5: Finally, use basename if all previous sorting methods failed
2891
2958
  (v) => v.basename
2892
2959
  ];
@@ -2913,7 +2980,7 @@ export {
2913
2980
  FileAction,
2914
2981
  FileListAction,
2915
2982
  FileListFilter,
2916
- F as FileType,
2983
+ FileType,
2917
2984
  FilesSortingMode,
2918
2985
  s as Folder,
2919
2986
  Header,