@nextcloud/files 3.5.1 → 3.7.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,6 +8,7 @@ const router = require("@nextcloud/router");
8
8
  const cancelablePromise = require("cancelable-promise");
9
9
  const webdav = require("webdav");
10
10
  const _public = require("@nextcloud/sharing/public");
11
+ const capabilities = require("@nextcloud/capabilities");
11
12
  const l10n = require("@nextcloud/l10n");
12
13
  const typescriptEventTarget = require("typescript-event-target");
13
14
  const logger = logger$1.getLoggerBuilder().setApp("@nextcloud/files").detectUser().build();
@@ -430,6 +431,9 @@ const validateData = (data, davService) => {
430
431
  if (!data.source.startsWith("http")) {
431
432
  throw new Error("Invalid source format, only http(s) is supported");
432
433
  }
434
+ if (data.displayname && typeof data.displayname !== "string") {
435
+ throw new Error("Invalid displayname type");
436
+ }
433
437
  if (data.mtime && !(data.mtime instanceof Date)) {
434
438
  throw new Error("Invalid mtime type");
435
439
  }
@@ -506,7 +510,12 @@ class Node {
506
510
  };
507
511
  constructor(data, davService) {
508
512
  validateData(data, davService || this._knownDavService);
509
- this._data = { ...data, attributes: {} };
513
+ this._data = {
514
+ // TODO: Remove with next major release, this is just for compatibility
515
+ displayname: data.attributes?.displayname,
516
+ ...data,
517
+ attributes: {}
518
+ };
510
519
  this._attributes = new Proxy(this._data.attributes, this.handler);
511
520
  this.update(data.attributes ?? {});
512
521
  if (davService) {
@@ -536,6 +545,21 @@ class Node {
536
545
  get basename() {
537
546
  return path.basename(this.source);
538
547
  }
548
+ /**
549
+ * The nodes displayname
550
+ * By default the display name and the `basename` are identical,
551
+ * but it is possible to have a different name. This happens
552
+ * on the files app for example for shared folders.
553
+ */
554
+ get displayname() {
555
+ return this._data.displayname || this.basename;
556
+ }
557
+ /**
558
+ * Set the displayname
559
+ */
560
+ set displayname(displayname) {
561
+ this._data.displayname = displayname;
562
+ }
539
563
  /**
540
564
  * Get this object's extension
541
565
  * There is no setter as the source is not meant to be changed manually.
@@ -698,7 +722,11 @@ class Node {
698
722
  */
699
723
  move(destination) {
700
724
  validateData({ ...this._data, source: destination }, this._knownDavService);
725
+ const oldBasename = this.basename;
701
726
  this._data.source = destination;
727
+ if (this.displayname === oldBasename && this.basename !== oldBasename) {
728
+ this.displayname = this.basename;
729
+ }
702
730
  this.updateMtime();
703
731
  }
704
732
  /**
@@ -843,6 +871,8 @@ const davResultToNode = function(node, filesRoot = davRootPath, remoteURL = davR
843
871
  source: `${remoteURL}${node.filename}`,
844
872
  mtime: new Date(Date.parse(node.lastmod)),
845
873
  mime: node.mime || "application/octet-stream",
874
+ // Manually cast to work around for https://github.com/perry-mitchell/webdav-client/pull/380
875
+ displayname: props.displayname !== void 0 ? String(props.displayname) : void 0,
846
876
  size: props?.size || Number.parseInt(props.getcontentlength || "0"),
847
877
  // The fileid is set to -1 for failed requests
848
878
  status: id < 0 ? NodeStatus.FAILED : void 0,
@@ -858,16 +888,81 @@ const davResultToNode = function(node, filesRoot = davRootPath, remoteURL = davR
858
888
  delete nodeData.attributes?.props;
859
889
  return node.type === "file" ? new File(nodeData) : new Folder(nodeData);
860
890
  };
861
- const forbiddenCharacters = window._oc_config?.forbidden_filenames_characters ?? ["/", "\\"];
862
- const forbiddenFilenameRegex = window._oc_config?.blacklist_files_regex ? new RegExp(window._oc_config.blacklist_files_regex) : null;
863
- function isFilenameValid(filename) {
864
- if (forbiddenCharacters.some((character) => filename.includes(character))) {
865
- return false;
891
+ var InvalidFilenameErrorReason = /* @__PURE__ */ ((InvalidFilenameErrorReason2) => {
892
+ InvalidFilenameErrorReason2["ReservedName"] = "reserved name";
893
+ InvalidFilenameErrorReason2["Character"] = "character";
894
+ InvalidFilenameErrorReason2["Extension"] = "extension";
895
+ return InvalidFilenameErrorReason2;
896
+ })(InvalidFilenameErrorReason || {});
897
+ class InvalidFilenameError extends Error {
898
+ constructor(options) {
899
+ super(`Invalid ${options.reason} '${options.segment}' in filename '${options.filename}'`, { cause: options });
866
900
  }
867
- if (forbiddenFilenameRegex !== null && filename.match(forbiddenFilenameRegex)) {
868
- return false;
901
+ /**
902
+ * The filename that was validated
903
+ */
904
+ get filename() {
905
+ return this.cause.filename;
906
+ }
907
+ /**
908
+ * Reason why the validation failed
909
+ */
910
+ get reason() {
911
+ return this.cause.reason;
912
+ }
913
+ /**
914
+ * Part of the filename that caused this error
915
+ */
916
+ get segment() {
917
+ return this.cause.segment;
918
+ }
919
+ }
920
+ function validateFilename(filename) {
921
+ const capabilities$1 = capabilities.getCapabilities().files;
922
+ const forbiddenCharacters = capabilities$1.forbidden_filename_characters ?? window._oc_config?.forbidden_filenames_characters ?? ["/", "\\"];
923
+ for (const character of forbiddenCharacters) {
924
+ if (filename.includes(character)) {
925
+ throw new InvalidFilenameError({ segment: character, reason: "character", filename });
926
+ }
927
+ }
928
+ filename = filename.toLocaleLowerCase();
929
+ const forbiddenFilenames = capabilities$1.forbidden_filenames ?? [".htaccess"];
930
+ if (forbiddenFilenames.includes(filename)) {
931
+ throw new InvalidFilenameError({
932
+ filename,
933
+ segment: filename,
934
+ reason: "reserved name"
935
+ /* ReservedName */
936
+ });
937
+ }
938
+ const endOfBasename = filename.indexOf(".", 1);
939
+ const basename = filename.substring(0, endOfBasename === -1 ? void 0 : endOfBasename);
940
+ const forbiddenFilenameBasenames = capabilities$1.forbidden_filename_basenames ?? [];
941
+ if (forbiddenFilenameBasenames.includes(basename)) {
942
+ throw new InvalidFilenameError({
943
+ filename,
944
+ segment: basename,
945
+ reason: "reserved name"
946
+ /* ReservedName */
947
+ });
948
+ }
949
+ const forbiddenFilenameExtensions = capabilities$1.forbidden_filename_extensions ?? [".part", ".filepart"];
950
+ for (const extension of forbiddenFilenameExtensions) {
951
+ if (filename.length > extension.length && filename.endsWith(extension)) {
952
+ throw new InvalidFilenameError({ segment: extension, reason: "extension", filename });
953
+ }
954
+ }
955
+ }
956
+ function isFilenameValid(filename) {
957
+ try {
958
+ validateFilename(filename);
959
+ return true;
960
+ } catch (error) {
961
+ if (error instanceof InvalidFilenameError) {
962
+ return false;
963
+ }
964
+ throw error;
869
965
  }
870
- return true;
871
966
  }
872
967
  function getUniqueName(name, otherNames, options) {
873
968
  const opts = {
@@ -934,10 +1029,10 @@ function stringify(value) {
934
1029
  }
935
1030
  return String(value);
936
1031
  }
937
- function orderBy(collection, identifiers, orders) {
938
- identifiers = identifiers ?? [(value) => value];
1032
+ function orderBy(collection, identifiers2, orders) {
1033
+ identifiers2 = identifiers2 ?? [(value) => value];
939
1034
  orders = orders ?? [];
940
- const sorting = identifiers.map((_, index) => (orders[index] ?? "asc") === "asc" ? 1 : -1);
1035
+ const sorting = identifiers2.map((_, index) => (orders[index] ?? "asc") === "asc" ? 1 : -1);
941
1036
  const collator = Intl.Collator(
942
1037
  [l10n.getLanguage(), l10n.getCanonicalLocale()],
943
1038
  {
@@ -947,7 +1042,7 @@ function orderBy(collection, identifiers, orders) {
947
1042
  }
948
1043
  );
949
1044
  return [...collection].sort((a, b) => {
950
- for (const [index, identifier] of identifiers.entries()) {
1045
+ for (const [index, identifier] of identifiers2.entries()) {
951
1046
  const value = collator.compare(stringify(identifier(a)), stringify(identifier(b)));
952
1047
  if (value !== 0) {
953
1048
  return value * sorting[index];
@@ -971,14 +1066,14 @@ function sortNodes(nodes, options = {}) {
971
1066
  ...options
972
1067
  };
973
1068
  const basename = (name) => name.lastIndexOf(".") > 0 ? name.slice(0, name.lastIndexOf(".")) : name;
974
- const identifiers = [
1069
+ const identifiers2 = [
975
1070
  // 1: Sort favorites first if enabled
976
1071
  ...sortingOptions.sortFavoritesFirst ? [(v) => v.attributes?.favorite !== 1] : [],
977
1072
  // 2: Sort folders first if sorting by name
978
1073
  ...sortingOptions.sortFoldersFirst ? [(v) => v.type !== "folder"] : [],
979
- // 3: Use sorting mode if NOT basename (to be able to use displayname too)
1074
+ // 3: Use sorting mode if NOT basename (to be able to use display name too)
980
1075
  ...sortingOptions.sortingMode !== "basename" ? [(v) => v[sortingOptions.sortingMode]] : [],
981
- // 4: Use displayname if available, fallback to name
1076
+ // 4: Use display name if available, fallback to name
982
1077
  (v) => basename(v.attributes?.displayname || v.basename),
983
1078
  // 5: Finally, use basename if all previous sorting methods failed
984
1079
  (v) => v.basename
@@ -997,7 +1092,7 @@ function sortNodes(nodes, options = {}) {
997
1092
  // for 5: use configured sorting direction
998
1093
  sortingOptions.sortingOrder
999
1094
  ];
1000
- return orderBy(nodes, identifiers, orders);
1095
+ return orderBy(nodes, identifiers2, orders);
1001
1096
  }
1002
1097
  class Navigation extends typescriptEventTarget.TypedEventTarget {
1003
1098
  _views = [];
@@ -1095,6 +1190,9 @@ const isValidColumn = function(column) {
1095
1190
  }
1096
1191
  return true;
1097
1192
  };
1193
+ function getDefaultExportFromCjs(x) {
1194
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
1195
+ }
1098
1196
  var validator$2 = {};
1099
1197
  var util$3 = {};
1100
1198
  (function(exports2) {
@@ -1288,7 +1386,7 @@ validator$2.validate = function(xmlData, options) {
1288
1386
  } else if (tags.length == 1) {
1289
1387
  return getErrorObject("InvalidTag", "Unclosed tag '" + tags[0].tagName + "'.", getLineNumberForPosition(xmlData, tags[0].tagStartPos));
1290
1388
  } else if (tags.length > 0) {
1291
- return getErrorObject("InvalidXml", "Invalid '" + JSON.stringify(tags.map((t) => t.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 });
1389
+ return getErrorObject("InvalidXml", "Invalid '" + JSON.stringify(tags.map((t2) => t2.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 });
1292
1390
  }
1293
1391
  return true;
1294
1392
  };
@@ -1398,15 +1496,15 @@ function validateAttributeString(attrStr, options) {
1398
1496
  return true;
1399
1497
  }
1400
1498
  function validateNumberAmpersand(xmlData, i) {
1401
- let re = /\d/;
1499
+ let re2 = /\d/;
1402
1500
  if (xmlData[i] === "x") {
1403
1501
  i++;
1404
- re = /[\da-fA-F]/;
1502
+ re2 = /[\da-fA-F]/;
1405
1503
  }
1406
1504
  for (; i < xmlData.length; i++) {
1407
1505
  if (xmlData[i] === ";")
1408
1506
  return i;
1409
- if (!xmlData[i].match(re))
1507
+ if (!xmlData[i].match(re2))
1410
1508
  break;
1411
1509
  }
1412
1510
  return -1;
@@ -2788,6 +2886,534 @@ const isValidView = function(view) {
2788
2886
  }
2789
2887
  return true;
2790
2888
  };
2889
+ const debug$1 = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {
2890
+ };
2891
+ var debug_1 = debug$1;
2892
+ const SEMVER_SPEC_VERSION = "2.0.0";
2893
+ const MAX_LENGTH$1 = 256;
2894
+ const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
2895
+ 9007199254740991;
2896
+ const MAX_SAFE_COMPONENT_LENGTH = 16;
2897
+ const MAX_SAFE_BUILD_LENGTH = MAX_LENGTH$1 - 6;
2898
+ const RELEASE_TYPES = [
2899
+ "major",
2900
+ "premajor",
2901
+ "minor",
2902
+ "preminor",
2903
+ "patch",
2904
+ "prepatch",
2905
+ "prerelease"
2906
+ ];
2907
+ var constants = {
2908
+ MAX_LENGTH: MAX_LENGTH$1,
2909
+ MAX_SAFE_COMPONENT_LENGTH,
2910
+ MAX_SAFE_BUILD_LENGTH,
2911
+ MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1,
2912
+ RELEASE_TYPES,
2913
+ SEMVER_SPEC_VERSION,
2914
+ FLAG_INCLUDE_PRERELEASE: 1,
2915
+ FLAG_LOOSE: 2
2916
+ };
2917
+ var re$1 = { exports: {} };
2918
+ (function(module2, exports2) {
2919
+ const {
2920
+ MAX_SAFE_COMPONENT_LENGTH: MAX_SAFE_COMPONENT_LENGTH2,
2921
+ MAX_SAFE_BUILD_LENGTH: MAX_SAFE_BUILD_LENGTH2,
2922
+ MAX_LENGTH: MAX_LENGTH2
2923
+ } = constants;
2924
+ const debug2 = debug_1;
2925
+ exports2 = module2.exports = {};
2926
+ const re2 = exports2.re = [];
2927
+ const safeRe = exports2.safeRe = [];
2928
+ const src = exports2.src = [];
2929
+ const t2 = exports2.t = {};
2930
+ let R = 0;
2931
+ const LETTERDASHNUMBER = "[a-zA-Z0-9-]";
2932
+ const safeRegexReplacements = [
2933
+ ["\\s", 1],
2934
+ ["\\d", MAX_LENGTH2],
2935
+ [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH2]
2936
+ ];
2937
+ const makeSafeRegex = (value) => {
2938
+ for (const [token, max] of safeRegexReplacements) {
2939
+ value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
2940
+ }
2941
+ return value;
2942
+ };
2943
+ const createToken = (name, value, isGlobal) => {
2944
+ const safe = makeSafeRegex(value);
2945
+ const index = R++;
2946
+ debug2(name, index, value);
2947
+ t2[name] = index;
2948
+ src[index] = value;
2949
+ re2[index] = new RegExp(value, isGlobal ? "g" : void 0);
2950
+ safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
2951
+ };
2952
+ createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
2953
+ createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
2954
+ createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
2955
+ createToken("MAINVERSION", `(${src[t2.NUMERICIDENTIFIER]})\\.(${src[t2.NUMERICIDENTIFIER]})\\.(${src[t2.NUMERICIDENTIFIER]})`);
2956
+ createToken("MAINVERSIONLOOSE", `(${src[t2.NUMERICIDENTIFIERLOOSE]})\\.(${src[t2.NUMERICIDENTIFIERLOOSE]})\\.(${src[t2.NUMERICIDENTIFIERLOOSE]})`);
2957
+ createToken("PRERELEASEIDENTIFIER", `(?:${src[t2.NUMERICIDENTIFIER]}|${src[t2.NONNUMERICIDENTIFIER]})`);
2958
+ createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t2.NUMERICIDENTIFIERLOOSE]}|${src[t2.NONNUMERICIDENTIFIER]})`);
2959
+ createToken("PRERELEASE", `(?:-(${src[t2.PRERELEASEIDENTIFIER]}(?:\\.${src[t2.PRERELEASEIDENTIFIER]})*))`);
2960
+ createToken("PRERELEASELOOSE", `(?:-?(${src[t2.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t2.PRERELEASEIDENTIFIERLOOSE]})*))`);
2961
+ createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
2962
+ createToken("BUILD", `(?:\\+(${src[t2.BUILDIDENTIFIER]}(?:\\.${src[t2.BUILDIDENTIFIER]})*))`);
2963
+ createToken("FULLPLAIN", `v?${src[t2.MAINVERSION]}${src[t2.PRERELEASE]}?${src[t2.BUILD]}?`);
2964
+ createToken("FULL", `^${src[t2.FULLPLAIN]}$`);
2965
+ createToken("LOOSEPLAIN", `[v=\\s]*${src[t2.MAINVERSIONLOOSE]}${src[t2.PRERELEASELOOSE]}?${src[t2.BUILD]}?`);
2966
+ createToken("LOOSE", `^${src[t2.LOOSEPLAIN]}$`);
2967
+ createToken("GTLT", "((?:<|>)?=?)");
2968
+ createToken("XRANGEIDENTIFIERLOOSE", `${src[t2.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
2969
+ createToken("XRANGEIDENTIFIER", `${src[t2.NUMERICIDENTIFIER]}|x|X|\\*`);
2970
+ createToken("XRANGEPLAIN", `[v=\\s]*(${src[t2.XRANGEIDENTIFIER]})(?:\\.(${src[t2.XRANGEIDENTIFIER]})(?:\\.(${src[t2.XRANGEIDENTIFIER]})(?:${src[t2.PRERELEASE]})?${src[t2.BUILD]}?)?)?`);
2971
+ createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t2.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t2.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t2.XRANGEIDENTIFIERLOOSE]})(?:${src[t2.PRERELEASELOOSE]})?${src[t2.BUILD]}?)?)?`);
2972
+ createToken("XRANGE", `^${src[t2.GTLT]}\\s*${src[t2.XRANGEPLAIN]}$`);
2973
+ createToken("XRANGELOOSE", `^${src[t2.GTLT]}\\s*${src[t2.XRANGEPLAINLOOSE]}$`);
2974
+ createToken("COERCEPLAIN", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH2}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH2}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH2}}))?`);
2975
+ createToken("COERCE", `${src[t2.COERCEPLAIN]}(?:$|[^\\d])`);
2976
+ createToken("COERCEFULL", src[t2.COERCEPLAIN] + `(?:${src[t2.PRERELEASE]})?(?:${src[t2.BUILD]})?(?:$|[^\\d])`);
2977
+ createToken("COERCERTL", src[t2.COERCE], true);
2978
+ createToken("COERCERTLFULL", src[t2.COERCEFULL], true);
2979
+ createToken("LONETILDE", "(?:~>?)");
2980
+ createToken("TILDETRIM", `(\\s*)${src[t2.LONETILDE]}\\s+`, true);
2981
+ exports2.tildeTrimReplace = "$1~";
2982
+ createToken("TILDE", `^${src[t2.LONETILDE]}${src[t2.XRANGEPLAIN]}$`);
2983
+ createToken("TILDELOOSE", `^${src[t2.LONETILDE]}${src[t2.XRANGEPLAINLOOSE]}$`);
2984
+ createToken("LONECARET", "(?:\\^)");
2985
+ createToken("CARETTRIM", `(\\s*)${src[t2.LONECARET]}\\s+`, true);
2986
+ exports2.caretTrimReplace = "$1^";
2987
+ createToken("CARET", `^${src[t2.LONECARET]}${src[t2.XRANGEPLAIN]}$`);
2988
+ createToken("CARETLOOSE", `^${src[t2.LONECARET]}${src[t2.XRANGEPLAINLOOSE]}$`);
2989
+ createToken("COMPARATORLOOSE", `^${src[t2.GTLT]}\\s*(${src[t2.LOOSEPLAIN]})$|^$`);
2990
+ createToken("COMPARATOR", `^${src[t2.GTLT]}\\s*(${src[t2.FULLPLAIN]})$|^$`);
2991
+ createToken("COMPARATORTRIM", `(\\s*)${src[t2.GTLT]}\\s*(${src[t2.LOOSEPLAIN]}|${src[t2.XRANGEPLAIN]})`, true);
2992
+ exports2.comparatorTrimReplace = "$1$2$3";
2993
+ createToken("HYPHENRANGE", `^\\s*(${src[t2.XRANGEPLAIN]})\\s+-\\s+(${src[t2.XRANGEPLAIN]})\\s*$`);
2994
+ createToken("HYPHENRANGELOOSE", `^\\s*(${src[t2.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t2.XRANGEPLAINLOOSE]})\\s*$`);
2995
+ createToken("STAR", "(<|>)?=?\\s*\\*");
2996
+ createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
2997
+ createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
2998
+ })(re$1, re$1.exports);
2999
+ var reExports = re$1.exports;
3000
+ const looseOption = Object.freeze({ loose: true });
3001
+ const emptyOpts = Object.freeze({});
3002
+ const parseOptions$1 = (options) => {
3003
+ if (!options) {
3004
+ return emptyOpts;
3005
+ }
3006
+ if (typeof options !== "object") {
3007
+ return looseOption;
3008
+ }
3009
+ return options;
3010
+ };
3011
+ var parseOptions_1 = parseOptions$1;
3012
+ const numeric = /^[0-9]+$/;
3013
+ const compareIdentifiers$1 = (a, b) => {
3014
+ const anum = numeric.test(a);
3015
+ const bnum = numeric.test(b);
3016
+ if (anum && bnum) {
3017
+ a = +a;
3018
+ b = +b;
3019
+ }
3020
+ return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
3021
+ };
3022
+ const rcompareIdentifiers = (a, b) => compareIdentifiers$1(b, a);
3023
+ var identifiers = {
3024
+ compareIdentifiers: compareIdentifiers$1,
3025
+ rcompareIdentifiers
3026
+ };
3027
+ const debug = debug_1;
3028
+ const { MAX_LENGTH, MAX_SAFE_INTEGER } = constants;
3029
+ const { safeRe: re, t } = reExports;
3030
+ const parseOptions = parseOptions_1;
3031
+ const { compareIdentifiers } = identifiers;
3032
+ let SemVer$2 = class SemVer {
3033
+ constructor(version, options) {
3034
+ options = parseOptions(options);
3035
+ if (version instanceof SemVer) {
3036
+ if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
3037
+ return version;
3038
+ } else {
3039
+ version = version.version;
3040
+ }
3041
+ } else if (typeof version !== "string") {
3042
+ throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
3043
+ }
3044
+ if (version.length > MAX_LENGTH) {
3045
+ throw new TypeError(
3046
+ `version is longer than ${MAX_LENGTH} characters`
3047
+ );
3048
+ }
3049
+ debug("SemVer", version, options);
3050
+ this.options = options;
3051
+ this.loose = !!options.loose;
3052
+ this.includePrerelease = !!options.includePrerelease;
3053
+ const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
3054
+ if (!m) {
3055
+ throw new TypeError(`Invalid Version: ${version}`);
3056
+ }
3057
+ this.raw = version;
3058
+ this.major = +m[1];
3059
+ this.minor = +m[2];
3060
+ this.patch = +m[3];
3061
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
3062
+ throw new TypeError("Invalid major version");
3063
+ }
3064
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
3065
+ throw new TypeError("Invalid minor version");
3066
+ }
3067
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
3068
+ throw new TypeError("Invalid patch version");
3069
+ }
3070
+ if (!m[4]) {
3071
+ this.prerelease = [];
3072
+ } else {
3073
+ this.prerelease = m[4].split(".").map((id) => {
3074
+ if (/^[0-9]+$/.test(id)) {
3075
+ const num = +id;
3076
+ if (num >= 0 && num < MAX_SAFE_INTEGER) {
3077
+ return num;
3078
+ }
3079
+ }
3080
+ return id;
3081
+ });
3082
+ }
3083
+ this.build = m[5] ? m[5].split(".") : [];
3084
+ this.format();
3085
+ }
3086
+ format() {
3087
+ this.version = `${this.major}.${this.minor}.${this.patch}`;
3088
+ if (this.prerelease.length) {
3089
+ this.version += `-${this.prerelease.join(".")}`;
3090
+ }
3091
+ return this.version;
3092
+ }
3093
+ toString() {
3094
+ return this.version;
3095
+ }
3096
+ compare(other) {
3097
+ debug("SemVer.compare", this.version, this.options, other);
3098
+ if (!(other instanceof SemVer)) {
3099
+ if (typeof other === "string" && other === this.version) {
3100
+ return 0;
3101
+ }
3102
+ other = new SemVer(other, this.options);
3103
+ }
3104
+ if (other.version === this.version) {
3105
+ return 0;
3106
+ }
3107
+ return this.compareMain(other) || this.comparePre(other);
3108
+ }
3109
+ compareMain(other) {
3110
+ if (!(other instanceof SemVer)) {
3111
+ other = new SemVer(other, this.options);
3112
+ }
3113
+ return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
3114
+ }
3115
+ comparePre(other) {
3116
+ if (!(other instanceof SemVer)) {
3117
+ other = new SemVer(other, this.options);
3118
+ }
3119
+ if (this.prerelease.length && !other.prerelease.length) {
3120
+ return -1;
3121
+ } else if (!this.prerelease.length && other.prerelease.length) {
3122
+ return 1;
3123
+ } else if (!this.prerelease.length && !other.prerelease.length) {
3124
+ return 0;
3125
+ }
3126
+ let i = 0;
3127
+ do {
3128
+ const a = this.prerelease[i];
3129
+ const b = other.prerelease[i];
3130
+ debug("prerelease compare", i, a, b);
3131
+ if (a === void 0 && b === void 0) {
3132
+ return 0;
3133
+ } else if (b === void 0) {
3134
+ return 1;
3135
+ } else if (a === void 0) {
3136
+ return -1;
3137
+ } else if (a === b) {
3138
+ continue;
3139
+ } else {
3140
+ return compareIdentifiers(a, b);
3141
+ }
3142
+ } while (++i);
3143
+ }
3144
+ compareBuild(other) {
3145
+ if (!(other instanceof SemVer)) {
3146
+ other = new SemVer(other, this.options);
3147
+ }
3148
+ let i = 0;
3149
+ do {
3150
+ const a = this.build[i];
3151
+ const b = other.build[i];
3152
+ debug("build compare", i, a, b);
3153
+ if (a === void 0 && b === void 0) {
3154
+ return 0;
3155
+ } else if (b === void 0) {
3156
+ return 1;
3157
+ } else if (a === void 0) {
3158
+ return -1;
3159
+ } else if (a === b) {
3160
+ continue;
3161
+ } else {
3162
+ return compareIdentifiers(a, b);
3163
+ }
3164
+ } while (++i);
3165
+ }
3166
+ // preminor will bump the version up to the next minor release, and immediately
3167
+ // down to pre-release. premajor and prepatch work the same way.
3168
+ inc(release, identifier, identifierBase) {
3169
+ switch (release) {
3170
+ case "premajor":
3171
+ this.prerelease.length = 0;
3172
+ this.patch = 0;
3173
+ this.minor = 0;
3174
+ this.major++;
3175
+ this.inc("pre", identifier, identifierBase);
3176
+ break;
3177
+ case "preminor":
3178
+ this.prerelease.length = 0;
3179
+ this.patch = 0;
3180
+ this.minor++;
3181
+ this.inc("pre", identifier, identifierBase);
3182
+ break;
3183
+ case "prepatch":
3184
+ this.prerelease.length = 0;
3185
+ this.inc("patch", identifier, identifierBase);
3186
+ this.inc("pre", identifier, identifierBase);
3187
+ break;
3188
+ case "prerelease":
3189
+ if (this.prerelease.length === 0) {
3190
+ this.inc("patch", identifier, identifierBase);
3191
+ }
3192
+ this.inc("pre", identifier, identifierBase);
3193
+ break;
3194
+ case "major":
3195
+ if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
3196
+ this.major++;
3197
+ }
3198
+ this.minor = 0;
3199
+ this.patch = 0;
3200
+ this.prerelease = [];
3201
+ break;
3202
+ case "minor":
3203
+ if (this.patch !== 0 || this.prerelease.length === 0) {
3204
+ this.minor++;
3205
+ }
3206
+ this.patch = 0;
3207
+ this.prerelease = [];
3208
+ break;
3209
+ case "patch":
3210
+ if (this.prerelease.length === 0) {
3211
+ this.patch++;
3212
+ }
3213
+ this.prerelease = [];
3214
+ break;
3215
+ case "pre": {
3216
+ const base = Number(identifierBase) ? 1 : 0;
3217
+ if (!identifier && identifierBase === false) {
3218
+ throw new Error("invalid increment argument: identifier is empty");
3219
+ }
3220
+ if (this.prerelease.length === 0) {
3221
+ this.prerelease = [base];
3222
+ } else {
3223
+ let i = this.prerelease.length;
3224
+ while (--i >= 0) {
3225
+ if (typeof this.prerelease[i] === "number") {
3226
+ this.prerelease[i]++;
3227
+ i = -2;
3228
+ }
3229
+ }
3230
+ if (i === -1) {
3231
+ if (identifier === this.prerelease.join(".") && identifierBase === false) {
3232
+ throw new Error("invalid increment argument: identifier already exists");
3233
+ }
3234
+ this.prerelease.push(base);
3235
+ }
3236
+ }
3237
+ if (identifier) {
3238
+ let prerelease = [identifier, base];
3239
+ if (identifierBase === false) {
3240
+ prerelease = [identifier];
3241
+ }
3242
+ if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
3243
+ if (isNaN(this.prerelease[1])) {
3244
+ this.prerelease = prerelease;
3245
+ }
3246
+ } else {
3247
+ this.prerelease = prerelease;
3248
+ }
3249
+ }
3250
+ break;
3251
+ }
3252
+ default:
3253
+ throw new Error(`invalid increment argument: ${release}`);
3254
+ }
3255
+ this.raw = this.format();
3256
+ if (this.build.length) {
3257
+ this.raw += `+${this.build.join(".")}`;
3258
+ }
3259
+ return this;
3260
+ }
3261
+ };
3262
+ var semver = SemVer$2;
3263
+ const SemVer$1 = semver;
3264
+ const parse$1 = (version, options, throwErrors = false) => {
3265
+ if (version instanceof SemVer$1) {
3266
+ return version;
3267
+ }
3268
+ try {
3269
+ return new SemVer$1(version, options);
3270
+ } catch (er) {
3271
+ if (!throwErrors) {
3272
+ return null;
3273
+ }
3274
+ throw er;
3275
+ }
3276
+ };
3277
+ var parse_1 = parse$1;
3278
+ const parse = parse_1;
3279
+ const valid = (version, options) => {
3280
+ const v = parse(version, options);
3281
+ return v ? v.version : null;
3282
+ };
3283
+ var valid_1 = valid;
3284
+ const valid$1 = /* @__PURE__ */ getDefaultExportFromCjs(valid_1);
3285
+ const SemVer2 = semver;
3286
+ const major = (a, loose) => new SemVer2(a, loose).major;
3287
+ var major_1 = major;
3288
+ const major$1 = /* @__PURE__ */ getDefaultExportFromCjs(major_1);
3289
+ class ProxyBus {
3290
+ bus;
3291
+ constructor(bus2) {
3292
+ if (typeof bus2.getVersion !== "function" || !valid$1(bus2.getVersion())) {
3293
+ console.warn("Proxying an event bus with an unknown or invalid version");
3294
+ } else if (major$1(bus2.getVersion()) !== major$1(this.getVersion())) {
3295
+ console.warn(
3296
+ "Proxying an event bus of version " + bus2.getVersion() + " with " + this.getVersion()
3297
+ );
3298
+ }
3299
+ this.bus = bus2;
3300
+ }
3301
+ getVersion() {
3302
+ return "3.3.1";
3303
+ }
3304
+ subscribe(name, handler) {
3305
+ this.bus.subscribe(name, handler);
3306
+ }
3307
+ unsubscribe(name, handler) {
3308
+ this.bus.unsubscribe(name, handler);
3309
+ }
3310
+ emit(name, event) {
3311
+ this.bus.emit(name, event);
3312
+ }
3313
+ }
3314
+ class SimpleBus {
3315
+ handlers = /* @__PURE__ */ new Map();
3316
+ getVersion() {
3317
+ return "3.3.1";
3318
+ }
3319
+ subscribe(name, handler) {
3320
+ this.handlers.set(
3321
+ name,
3322
+ (this.handlers.get(name) || []).concat(
3323
+ handler
3324
+ )
3325
+ );
3326
+ }
3327
+ unsubscribe(name, handler) {
3328
+ this.handlers.set(
3329
+ name,
3330
+ (this.handlers.get(name) || []).filter((h) => h !== handler)
3331
+ );
3332
+ }
3333
+ emit(name, event) {
3334
+ (this.handlers.get(name) || []).forEach((h) => {
3335
+ try {
3336
+ h(event);
3337
+ } catch (e) {
3338
+ console.error("could not invoke event listener", e);
3339
+ }
3340
+ });
3341
+ }
3342
+ }
3343
+ let bus = null;
3344
+ function getBus() {
3345
+ if (bus !== null) {
3346
+ return bus;
3347
+ }
3348
+ if (typeof window === "undefined") {
3349
+ return new Proxy({}, {
3350
+ get: () => {
3351
+ return () => console.error(
3352
+ "Window not available, EventBus can not be established!"
3353
+ );
3354
+ }
3355
+ });
3356
+ }
3357
+ if (window.OC?._eventBus && typeof window._nc_event_bus === "undefined") {
3358
+ console.warn(
3359
+ "found old event bus instance at OC._eventBus. Update your version!"
3360
+ );
3361
+ window._nc_event_bus = window.OC._eventBus;
3362
+ }
3363
+ if (typeof window?._nc_event_bus !== "undefined") {
3364
+ bus = new ProxyBus(window._nc_event_bus);
3365
+ } else {
3366
+ bus = window._nc_event_bus = new SimpleBus();
3367
+ }
3368
+ return bus;
3369
+ }
3370
+ function emit(name, event) {
3371
+ getBus().emit(name, event);
3372
+ }
3373
+ /*!
3374
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
3375
+ * SPDX-License-Identifier: AGPL-3.0-or-later
3376
+ */
3377
+ class FileListFilter extends typescriptEventTarget.TypedEventTarget {
3378
+ id;
3379
+ order;
3380
+ constructor(id, order = 100) {
3381
+ super();
3382
+ this.id = id;
3383
+ this.order = order;
3384
+ }
3385
+ filter(nodes) {
3386
+ throw new Error("Not implemented");
3387
+ }
3388
+ updateChips(chips) {
3389
+ this.dispatchTypedEvent("update:chips", new CustomEvent("update:chips", { detail: chips }));
3390
+ }
3391
+ filterUpdated() {
3392
+ this.dispatchTypedEvent("update:filter", new CustomEvent("update:filter"));
3393
+ }
3394
+ }
3395
+ function registerFileListFilter(filter) {
3396
+ if (!window._nc_filelist_filters) {
3397
+ window._nc_filelist_filters = /* @__PURE__ */ new Map();
3398
+ }
3399
+ if (window._nc_filelist_filters.has(filter.id)) {
3400
+ throw new Error(`File list filter "${filter.id}" already registered`);
3401
+ }
3402
+ window._nc_filelist_filters.set(filter.id, filter);
3403
+ emit("files:filter:added", filter);
3404
+ }
3405
+ function unregisterFileListFilter(filterId) {
3406
+ if (window._nc_filelist_filters && window._nc_filelist_filters.has(filterId)) {
3407
+ window._nc_filelist_filters.delete(filterId);
3408
+ emit("files:filter:removed", filterId);
3409
+ }
3410
+ }
3411
+ function getFileListFilters() {
3412
+ if (!window._nc_filelist_filters) {
3413
+ return [];
3414
+ }
3415
+ return [...window._nc_filelist_filters.values()];
3416
+ }
2791
3417
  const addNewFileMenuEntry = function(entry) {
2792
3418
  const newFileMenu = getNewFileMenu();
2793
3419
  return newFileMenu.registerEntry(entry);
@@ -2809,10 +3435,13 @@ exports.Column = Column;
2809
3435
  exports.DefaultType = DefaultType;
2810
3436
  exports.File = File;
2811
3437
  exports.FileAction = FileAction;
3438
+ exports.FileListFilter = FileListFilter;
2812
3439
  exports.FileType = FileType;
2813
3440
  exports.FilesSortingMode = FilesSortingMode;
2814
3441
  exports.Folder = Folder;
2815
3442
  exports.Header = Header;
3443
+ exports.InvalidFilenameError = InvalidFilenameError;
3444
+ exports.InvalidFilenameErrorReason = InvalidFilenameErrorReason;
2816
3445
  exports.Navigation = Navigation;
2817
3446
  exports.NewMenuEntryCategory = NewMenuEntryCategory;
2818
3447
  exports.Node = Node;
@@ -2837,6 +3466,7 @@ exports.getDavNameSpaces = getDavNameSpaces;
2837
3466
  exports.getDavProperties = getDavProperties;
2838
3467
  exports.getFavoriteNodes = getFavoriteNodes;
2839
3468
  exports.getFileActions = getFileActions;
3469
+ exports.getFileListFilters = getFileListFilters;
2840
3470
  exports.getFileListHeaders = getFileListHeaders;
2841
3471
  exports.getNavigation = getNavigation;
2842
3472
  exports.getNewFileMenuEntries = getNewFileMenuEntries;
@@ -2846,6 +3476,9 @@ exports.orderBy = orderBy;
2846
3476
  exports.parseFileSize = parseFileSize;
2847
3477
  exports.registerDavProperty = registerDavProperty;
2848
3478
  exports.registerFileAction = registerFileAction;
3479
+ exports.registerFileListFilter = registerFileListFilter;
2849
3480
  exports.registerFileListHeaders = registerFileListHeaders;
2850
3481
  exports.removeNewFileMenuEntry = removeNewFileMenuEntry;
2851
3482
  exports.sortNodes = sortNodes;
3483
+ exports.unregisterFileListFilter = unregisterFileListFilter;
3484
+ exports.validateFilename = validateFilename;