@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.cjs CHANGED
@@ -254,6 +254,7 @@ function requireRe() {
254
254
  const re2 = exports2.re = [];
255
255
  const safeRe = exports2.safeRe = [];
256
256
  const src = exports2.src = [];
257
+ const safeSrc = exports2.safeSrc = [];
257
258
  const t = exports2.t = {};
258
259
  let R = 0;
259
260
  const LETTERDASHNUMBER = "[a-zA-Z0-9-]";
@@ -274,6 +275,7 @@ function requireRe() {
274
275
  debug(name, index, value);
275
276
  t[name] = index;
276
277
  src[index] = value;
278
+ safeSrc[index] = safe;
277
279
  re2[index] = new RegExp(value, isGlobal ? "g" : void 0);
278
280
  safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
279
281
  };
@@ -282,8 +284,8 @@ function requireRe() {
282
284
  createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
283
285
  createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
284
286
  createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
285
- createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NUMERICIDENTIFIER]}|${src[t.NONNUMERICIDENTIFIER]})`);
286
- createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NUMERICIDENTIFIERLOOSE]}|${src[t.NONNUMERICIDENTIFIER]})`);
287
+ createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
288
+ createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
287
289
  createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
288
290
  createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
289
291
  createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
@@ -352,6 +354,9 @@ function requireIdentifiers() {
352
354
  hasRequiredIdentifiers = 1;
353
355
  const numeric = /^[0-9]+$/;
354
356
  const compareIdentifiers = (a, b) => {
357
+ if (typeof a === "number" && typeof b === "number") {
358
+ return a === b ? 0 : a < b ? -1 : 1;
359
+ }
355
360
  const anum = numeric.test(a);
356
361
  const bnum = numeric.test(b);
357
362
  if (anum && bnum) {
@@ -458,7 +463,25 @@ function requireSemver() {
458
463
  if (!(other instanceof SemVer)) {
459
464
  other = new SemVer(other, this.options);
460
465
  }
461
- return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
466
+ if (this.major < other.major) {
467
+ return -1;
468
+ }
469
+ if (this.major > other.major) {
470
+ return 1;
471
+ }
472
+ if (this.minor < other.minor) {
473
+ return -1;
474
+ }
475
+ if (this.minor > other.minor) {
476
+ return 1;
477
+ }
478
+ if (this.patch < other.patch) {
479
+ return -1;
480
+ }
481
+ if (this.patch > other.patch) {
482
+ return 1;
483
+ }
484
+ return 0;
462
485
  }
463
486
  comparePre(other) {
464
487
  if (!(other instanceof SemVer)) {
@@ -514,6 +537,17 @@ function requireSemver() {
514
537
  // preminor will bump the version up to the next minor release, and immediately
515
538
  // down to pre-release. premajor and prepatch work the same way.
516
539
  inc(release, identifier, identifierBase) {
540
+ if (release.startsWith("pre")) {
541
+ if (!identifier && identifierBase === false) {
542
+ throw new Error("invalid increment argument: identifier is empty");
543
+ }
544
+ if (identifier) {
545
+ const match = `-${identifier}`.match(this.options.loose ? re2[t.PRERELEASELOOSE] : re2[t.PRERELEASE]);
546
+ if (!match || match[1] !== identifier) {
547
+ throw new Error(`invalid identifier: ${identifier}`);
548
+ }
549
+ }
550
+ }
517
551
  switch (release) {
518
552
  case "premajor":
519
553
  this.prerelease.length = 0;
@@ -541,6 +575,12 @@ function requireSemver() {
541
575
  }
542
576
  this.inc("pre", identifier, identifierBase);
543
577
  break;
578
+ case "release":
579
+ if (this.prerelease.length === 0) {
580
+ throw new Error(`version ${this.raw} is not a prerelease`);
581
+ }
582
+ this.prerelease.length = 0;
583
+ break;
544
584
  case "major":
545
585
  if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
546
586
  this.major++;
@@ -566,9 +606,6 @@ function requireSemver() {
566
606
  // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
567
607
  case "pre": {
568
608
  const base = Number(identifierBase) ? 1 : 0;
569
- if (!identifier && identifierBase === false) {
570
- throw new Error("invalid increment argument: identifier is empty");
571
- }
572
609
  if (this.prerelease.length === 0) {
573
610
  this.prerelease = [base];
574
611
  } else {
@@ -614,6 +651,18 @@ function requireSemver() {
614
651
  semver = SemVer;
615
652
  return semver;
616
653
  }
654
+ var major_1;
655
+ var hasRequiredMajor;
656
+ function requireMajor() {
657
+ if (hasRequiredMajor) return major_1;
658
+ hasRequiredMajor = 1;
659
+ const SemVer = requireSemver();
660
+ const major2 = (a, loose) => new SemVer(a, loose).major;
661
+ major_1 = major2;
662
+ return major_1;
663
+ }
664
+ var majorExports = requireMajor();
665
+ const major = /* @__PURE__ */ getDefaultExportFromCjs(majorExports);
617
666
  var parse_1;
618
667
  var hasRequiredParse;
619
668
  function requireParse() {
@@ -651,18 +700,10 @@ function requireValid() {
651
700
  }
652
701
  var validExports = requireValid();
653
702
  const valid = /* @__PURE__ */ getDefaultExportFromCjs(validExports);
654
- var major_1;
655
- var hasRequiredMajor;
656
- function requireMajor() {
657
- if (hasRequiredMajor) return major_1;
658
- hasRequiredMajor = 1;
659
- const SemVer = requireSemver();
660
- const major2 = (a, loose) => new SemVer(a, loose).major;
661
- major_1 = major2;
662
- return major_1;
663
- }
664
- var majorExports = requireMajor();
665
- const major = /* @__PURE__ */ getDefaultExportFromCjs(majorExports);
703
+ /*!
704
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
705
+ * SPDX-License-Identifier: GPL-3.0-or-later
706
+ */
666
707
  class ProxyBus {
667
708
  bus;
668
709
  constructor(bus2) {
@@ -676,7 +717,7 @@ class ProxyBus {
676
717
  this.bus = bus2;
677
718
  }
678
719
  getVersion() {
679
- return "3.3.2";
720
+ return "3.3.3";
680
721
  }
681
722
  subscribe(name, handler) {
682
723
  this.bus.subscribe(name, handler);
@@ -688,10 +729,14 @@ class ProxyBus {
688
729
  this.bus.emit(name, ...event);
689
730
  }
690
731
  }
732
+ /*!
733
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
734
+ * SPDX-License-Identifier: GPL-3.0-or-later
735
+ */
691
736
  class SimpleBus {
692
737
  handlers = /* @__PURE__ */ new Map();
693
738
  getVersion() {
694
- return "3.3.2";
739
+ return "3.3.3";
695
740
  }
696
741
  subscribe(name, handler) {
697
742
  this.handlers.set(
@@ -719,6 +764,10 @@ class SimpleBus {
719
764
  });
720
765
  }
721
766
  }
767
+ /*!
768
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
769
+ * SPDX-License-Identifier: GPL-3.0-or-later
770
+ */
722
771
  let bus = null;
723
772
  function getBus() {
724
773
  if (bus !== null) {
@@ -2489,7 +2538,7 @@ class XmlTextDetector {
2489
2538
  return this.nesting === 0;
2490
2539
  }
2491
2540
  }
2492
- function isSvg(string) {
2541
+ function isSvg(string, { validate = true } = {}) {
2493
2542
  if (typeof string !== "string") {
2494
2543
  throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
2495
2544
  }
@@ -2497,9 +2546,21 @@ function isSvg(string) {
2497
2546
  if (string.length === 0) {
2498
2547
  return false;
2499
2548
  }
2500
- const xmlTextDetector = new XmlTextDetector();
2501
- xmlTextDetector.write(string);
2502
- return xmlTextDetector.isValid() && xmlTextDetector.fileType?.ext === "svg";
2549
+ const xmlTextDetector = new XmlTextDetector({ fullScan: validate });
2550
+ if (validate) {
2551
+ xmlTextDetector.write(string);
2552
+ if (!xmlTextDetector.isValid()) {
2553
+ return false;
2554
+ }
2555
+ } else {
2556
+ const chunkSize = 128;
2557
+ let offset = 0;
2558
+ while (string.length > offset && !xmlTextDetector.onEnd) {
2559
+ xmlTextDetector.write(string.slice(offset, Math.min(offset + chunkSize, string.length)));
2560
+ offset += chunkSize;
2561
+ }
2562
+ }
2563
+ return xmlTextDetector.fileType?.ext === "svg";
2503
2564
  }
2504
2565
  class View {
2505
2566
  _view;
@@ -2880,7 +2941,13 @@ function sortNodes(nodes, options = {}) {
2880
2941
  sortingOrder: "asc",
2881
2942
  ...options
2882
2943
  };
2883
- const basename = (name) => name.lastIndexOf(".") > 0 ? name.slice(0, name.lastIndexOf(".")) : name;
2944
+ function basename(node) {
2945
+ const name = node.displayname || node.attributes?.displayname || node.basename || "";
2946
+ if (node.type === dav.FileType.Folder) {
2947
+ return name;
2948
+ }
2949
+ return name.lastIndexOf(".") > 0 ? name.slice(0, name.lastIndexOf(".")) : name;
2950
+ }
2884
2951
  const identifiers2 = [
2885
2952
  // 1: Sort favorites first if enabled
2886
2953
  ...sortingOptions.sortFavoritesFirst ? [(v) => v.attributes?.favorite !== 1] : [],
@@ -2889,7 +2956,7 @@ function sortNodes(nodes, options = {}) {
2889
2956
  // 3: Use sorting mode if NOT basename (to be able to use display name too)
2890
2957
  ...sortingOptions.sortingMode !== "basename" ? [(v) => v[sortingOptions.sortingMode] ?? v.attributes[sortingOptions.sortingMode]] : [],
2891
2958
  // 4: Use display name if available, fallback to name
2892
- (v) => basename(v.displayname || v.attributes?.displayname || v.basename || ""),
2959
+ (v) => basename(v),
2893
2960
  // 5: Finally, use basename if all previous sorting methods failed
2894
2961
  (v) => v.basename
2895
2962
  ];