@nextcloud/files 3.6.0 → 3.8.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
@@ -871,7 +871,8 @@ const davResultToNode = function(node, filesRoot = davRootPath, remoteURL = davR
871
871
  source: `${remoteURL}${node.filename}`,
872
872
  mtime: new Date(Date.parse(node.lastmod)),
873
873
  mime: node.mime || "application/octet-stream",
874
- displayname: props.displayname,
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,
875
876
  size: props?.size || Number.parseInt(props.getcontentlength || "0"),
876
877
  // The fileid is set to -1 for failed requests
877
878
  status: id < 0 ? NodeStatus.FAILED : void 0,
@@ -1028,10 +1029,10 @@ function stringify(value) {
1028
1029
  }
1029
1030
  return String(value);
1030
1031
  }
1031
- function orderBy(collection, identifiers, orders) {
1032
- identifiers = identifiers ?? [(value) => value];
1032
+ function orderBy(collection, identifiers2, orders) {
1033
+ identifiers2 = identifiers2 ?? [(value) => value];
1033
1034
  orders = orders ?? [];
1034
- const sorting = identifiers.map((_, index) => (orders[index] ?? "asc") === "asc" ? 1 : -1);
1035
+ const sorting = identifiers2.map((_, index) => (orders[index] ?? "asc") === "asc" ? 1 : -1);
1035
1036
  const collator = Intl.Collator(
1036
1037
  [l10n.getLanguage(), l10n.getCanonicalLocale()],
1037
1038
  {
@@ -1041,7 +1042,7 @@ function orderBy(collection, identifiers, orders) {
1041
1042
  }
1042
1043
  );
1043
1044
  return [...collection].sort((a, b) => {
1044
- for (const [index, identifier] of identifiers.entries()) {
1045
+ for (const [index, identifier] of identifiers2.entries()) {
1045
1046
  const value = collator.compare(stringify(identifier(a)), stringify(identifier(b)));
1046
1047
  if (value !== 0) {
1047
1048
  return value * sorting[index];
@@ -1065,14 +1066,14 @@ function sortNodes(nodes, options = {}) {
1065
1066
  ...options
1066
1067
  };
1067
1068
  const basename = (name) => name.lastIndexOf(".") > 0 ? name.slice(0, name.lastIndexOf(".")) : name;
1068
- const identifiers = [
1069
+ const identifiers2 = [
1069
1070
  // 1: Sort favorites first if enabled
1070
1071
  ...sortingOptions.sortFavoritesFirst ? [(v) => v.attributes?.favorite !== 1] : [],
1071
1072
  // 2: Sort folders first if sorting by name
1072
1073
  ...sortingOptions.sortFoldersFirst ? [(v) => v.type !== "folder"] : [],
1073
- // 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)
1074
1075
  ...sortingOptions.sortingMode !== "basename" ? [(v) => v[sortingOptions.sortingMode]] : [],
1075
- // 4: Use displayname if available, fallback to name
1076
+ // 4: Use display name if available, fallback to name
1076
1077
  (v) => basename(v.attributes?.displayname || v.basename),
1077
1078
  // 5: Finally, use basename if all previous sorting methods failed
1078
1079
  (v) => v.basename
@@ -1091,7 +1092,7 @@ function sortNodes(nodes, options = {}) {
1091
1092
  // for 5: use configured sorting direction
1092
1093
  sortingOptions.sortingOrder
1093
1094
  ];
1094
- return orderBy(nodes, identifiers, orders);
1095
+ return orderBy(nodes, identifiers2, orders);
1095
1096
  }
1096
1097
  class Navigation extends typescriptEventTarget.TypedEventTarget {
1097
1098
  _views = [];
@@ -1189,6 +1190,9 @@ const isValidColumn = function(column) {
1189
1190
  }
1190
1191
  return true;
1191
1192
  };
1193
+ function getDefaultExportFromCjs(x) {
1194
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
1195
+ }
1192
1196
  var validator$2 = {};
1193
1197
  var util$3 = {};
1194
1198
  (function(exports2) {
@@ -1382,7 +1386,7 @@ validator$2.validate = function(xmlData, options) {
1382
1386
  } else if (tags.length == 1) {
1383
1387
  return getErrorObject("InvalidTag", "Unclosed tag '" + tags[0].tagName + "'.", getLineNumberForPosition(xmlData, tags[0].tagStartPos));
1384
1388
  } else if (tags.length > 0) {
1385
- 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 });
1386
1390
  }
1387
1391
  return true;
1388
1392
  };
@@ -1492,15 +1496,15 @@ function validateAttributeString(attrStr, options) {
1492
1496
  return true;
1493
1497
  }
1494
1498
  function validateNumberAmpersand(xmlData, i) {
1495
- let re = /\d/;
1499
+ let re2 = /\d/;
1496
1500
  if (xmlData[i] === "x") {
1497
1501
  i++;
1498
- re = /[\da-fA-F]/;
1502
+ re2 = /[\da-fA-F]/;
1499
1503
  }
1500
1504
  for (; i < xmlData.length; i++) {
1501
1505
  if (xmlData[i] === ";")
1502
1506
  return i;
1503
- if (!xmlData[i].match(re))
1507
+ if (!xmlData[i].match(re2))
1504
1508
  break;
1505
1509
  }
1506
1510
  return -1;
@@ -2622,6 +2626,7 @@ Builder.prototype.j2x = function(jObj, level) {
2622
2626
  } else if (Array.isArray(jObj[key])) {
2623
2627
  const arrLen = jObj[key].length;
2624
2628
  let listTagVal = "";
2629
+ let listTagAttr = "";
2625
2630
  for (let j = 0; j < arrLen; j++) {
2626
2631
  const item = jObj[key][j];
2627
2632
  if (typeof item === "undefined") ;
@@ -2630,16 +2635,26 @@ Builder.prototype.j2x = function(jObj, level) {
2630
2635
  else val2 += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
2631
2636
  } else if (typeof item === "object") {
2632
2637
  if (this.options.oneListGroup) {
2633
- listTagVal += this.j2x(item, level + 1).val;
2638
+ const result = this.j2x(item, level + 1);
2639
+ listTagVal += result.val;
2640
+ if (this.options.attributesGroupName && item.hasOwnProperty(this.options.attributesGroupName)) {
2641
+ listTagAttr += result.attrStr;
2642
+ }
2634
2643
  } else {
2635
2644
  listTagVal += this.processTextOrObjNode(item, key, level);
2636
2645
  }
2637
2646
  } else {
2638
- listTagVal += this.buildTextValNode(item, key, "", level);
2647
+ if (this.options.oneListGroup) {
2648
+ let textValue = this.options.tagValueProcessor(key, item);
2649
+ textValue = this.replaceEntitiesValue(textValue);
2650
+ listTagVal += textValue;
2651
+ } else {
2652
+ listTagVal += this.buildTextValNode(item, key, "", level);
2653
+ }
2639
2654
  }
2640
2655
  }
2641
2656
  if (this.options.oneListGroup) {
2642
- listTagVal = this.buildObjectNode(listTagVal, key, "", level);
2657
+ listTagVal = this.buildObjectNode(listTagVal, key, listTagAttr, level);
2643
2658
  }
2644
2659
  val2 += listTagVal;
2645
2660
  } else {
@@ -2838,6 +2853,9 @@ class View {
2838
2853
  get defaultSortKey() {
2839
2854
  return this._view.defaultSortKey;
2840
2855
  }
2856
+ get loadChildViews() {
2857
+ return this._view.loadChildViews;
2858
+ }
2841
2859
  }
2842
2860
  const isValidView = function(view) {
2843
2861
  if (!view.id || typeof view.id !== "string") {
@@ -2880,8 +2898,539 @@ const isValidView = function(view) {
2880
2898
  if (view.defaultSortKey && typeof view.defaultSortKey !== "string") {
2881
2899
  throw new Error("View defaultSortKey must be a string");
2882
2900
  }
2901
+ if (view.loadChildViews && typeof view.loadChildViews !== "function") {
2902
+ throw new Error("View loadChildViews must be a function");
2903
+ }
2883
2904
  return true;
2884
2905
  };
2906
+ 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) : () => {
2907
+ };
2908
+ var debug_1 = debug$1;
2909
+ const SEMVER_SPEC_VERSION = "2.0.0";
2910
+ const MAX_LENGTH$1 = 256;
2911
+ const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
2912
+ 9007199254740991;
2913
+ const MAX_SAFE_COMPONENT_LENGTH = 16;
2914
+ const MAX_SAFE_BUILD_LENGTH = MAX_LENGTH$1 - 6;
2915
+ const RELEASE_TYPES = [
2916
+ "major",
2917
+ "premajor",
2918
+ "minor",
2919
+ "preminor",
2920
+ "patch",
2921
+ "prepatch",
2922
+ "prerelease"
2923
+ ];
2924
+ var constants = {
2925
+ MAX_LENGTH: MAX_LENGTH$1,
2926
+ MAX_SAFE_COMPONENT_LENGTH,
2927
+ MAX_SAFE_BUILD_LENGTH,
2928
+ MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1,
2929
+ RELEASE_TYPES,
2930
+ SEMVER_SPEC_VERSION,
2931
+ FLAG_INCLUDE_PRERELEASE: 1,
2932
+ FLAG_LOOSE: 2
2933
+ };
2934
+ var re$1 = { exports: {} };
2935
+ (function(module2, exports2) {
2936
+ const {
2937
+ MAX_SAFE_COMPONENT_LENGTH: MAX_SAFE_COMPONENT_LENGTH2,
2938
+ MAX_SAFE_BUILD_LENGTH: MAX_SAFE_BUILD_LENGTH2,
2939
+ MAX_LENGTH: MAX_LENGTH2
2940
+ } = constants;
2941
+ const debug2 = debug_1;
2942
+ exports2 = module2.exports = {};
2943
+ const re2 = exports2.re = [];
2944
+ const safeRe = exports2.safeRe = [];
2945
+ const src = exports2.src = [];
2946
+ const t2 = exports2.t = {};
2947
+ let R = 0;
2948
+ const LETTERDASHNUMBER = "[a-zA-Z0-9-]";
2949
+ const safeRegexReplacements = [
2950
+ ["\\s", 1],
2951
+ ["\\d", MAX_LENGTH2],
2952
+ [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH2]
2953
+ ];
2954
+ const makeSafeRegex = (value) => {
2955
+ for (const [token, max] of safeRegexReplacements) {
2956
+ value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
2957
+ }
2958
+ return value;
2959
+ };
2960
+ const createToken = (name, value, isGlobal) => {
2961
+ const safe = makeSafeRegex(value);
2962
+ const index = R++;
2963
+ debug2(name, index, value);
2964
+ t2[name] = index;
2965
+ src[index] = value;
2966
+ re2[index] = new RegExp(value, isGlobal ? "g" : void 0);
2967
+ safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
2968
+ };
2969
+ createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
2970
+ createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
2971
+ createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
2972
+ createToken("MAINVERSION", `(${src[t2.NUMERICIDENTIFIER]})\\.(${src[t2.NUMERICIDENTIFIER]})\\.(${src[t2.NUMERICIDENTIFIER]})`);
2973
+ createToken("MAINVERSIONLOOSE", `(${src[t2.NUMERICIDENTIFIERLOOSE]})\\.(${src[t2.NUMERICIDENTIFIERLOOSE]})\\.(${src[t2.NUMERICIDENTIFIERLOOSE]})`);
2974
+ createToken("PRERELEASEIDENTIFIER", `(?:${src[t2.NUMERICIDENTIFIER]}|${src[t2.NONNUMERICIDENTIFIER]})`);
2975
+ createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t2.NUMERICIDENTIFIERLOOSE]}|${src[t2.NONNUMERICIDENTIFIER]})`);
2976
+ createToken("PRERELEASE", `(?:-(${src[t2.PRERELEASEIDENTIFIER]}(?:\\.${src[t2.PRERELEASEIDENTIFIER]})*))`);
2977
+ createToken("PRERELEASELOOSE", `(?:-?(${src[t2.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t2.PRERELEASEIDENTIFIERLOOSE]})*))`);
2978
+ createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
2979
+ createToken("BUILD", `(?:\\+(${src[t2.BUILDIDENTIFIER]}(?:\\.${src[t2.BUILDIDENTIFIER]})*))`);
2980
+ createToken("FULLPLAIN", `v?${src[t2.MAINVERSION]}${src[t2.PRERELEASE]}?${src[t2.BUILD]}?`);
2981
+ createToken("FULL", `^${src[t2.FULLPLAIN]}$`);
2982
+ createToken("LOOSEPLAIN", `[v=\\s]*${src[t2.MAINVERSIONLOOSE]}${src[t2.PRERELEASELOOSE]}?${src[t2.BUILD]}?`);
2983
+ createToken("LOOSE", `^${src[t2.LOOSEPLAIN]}$`);
2984
+ createToken("GTLT", "((?:<|>)?=?)");
2985
+ createToken("XRANGEIDENTIFIERLOOSE", `${src[t2.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
2986
+ createToken("XRANGEIDENTIFIER", `${src[t2.NUMERICIDENTIFIER]}|x|X|\\*`);
2987
+ createToken("XRANGEPLAIN", `[v=\\s]*(${src[t2.XRANGEIDENTIFIER]})(?:\\.(${src[t2.XRANGEIDENTIFIER]})(?:\\.(${src[t2.XRANGEIDENTIFIER]})(?:${src[t2.PRERELEASE]})?${src[t2.BUILD]}?)?)?`);
2988
+ createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t2.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t2.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t2.XRANGEIDENTIFIERLOOSE]})(?:${src[t2.PRERELEASELOOSE]})?${src[t2.BUILD]}?)?)?`);
2989
+ createToken("XRANGE", `^${src[t2.GTLT]}\\s*${src[t2.XRANGEPLAIN]}$`);
2990
+ createToken("XRANGELOOSE", `^${src[t2.GTLT]}\\s*${src[t2.XRANGEPLAINLOOSE]}$`);
2991
+ createToken("COERCEPLAIN", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH2}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH2}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH2}}))?`);
2992
+ createToken("COERCE", `${src[t2.COERCEPLAIN]}(?:$|[^\\d])`);
2993
+ createToken("COERCEFULL", src[t2.COERCEPLAIN] + `(?:${src[t2.PRERELEASE]})?(?:${src[t2.BUILD]})?(?:$|[^\\d])`);
2994
+ createToken("COERCERTL", src[t2.COERCE], true);
2995
+ createToken("COERCERTLFULL", src[t2.COERCEFULL], true);
2996
+ createToken("LONETILDE", "(?:~>?)");
2997
+ createToken("TILDETRIM", `(\\s*)${src[t2.LONETILDE]}\\s+`, true);
2998
+ exports2.tildeTrimReplace = "$1~";
2999
+ createToken("TILDE", `^${src[t2.LONETILDE]}${src[t2.XRANGEPLAIN]}$`);
3000
+ createToken("TILDELOOSE", `^${src[t2.LONETILDE]}${src[t2.XRANGEPLAINLOOSE]}$`);
3001
+ createToken("LONECARET", "(?:\\^)");
3002
+ createToken("CARETTRIM", `(\\s*)${src[t2.LONECARET]}\\s+`, true);
3003
+ exports2.caretTrimReplace = "$1^";
3004
+ createToken("CARET", `^${src[t2.LONECARET]}${src[t2.XRANGEPLAIN]}$`);
3005
+ createToken("CARETLOOSE", `^${src[t2.LONECARET]}${src[t2.XRANGEPLAINLOOSE]}$`);
3006
+ createToken("COMPARATORLOOSE", `^${src[t2.GTLT]}\\s*(${src[t2.LOOSEPLAIN]})$|^$`);
3007
+ createToken("COMPARATOR", `^${src[t2.GTLT]}\\s*(${src[t2.FULLPLAIN]})$|^$`);
3008
+ createToken("COMPARATORTRIM", `(\\s*)${src[t2.GTLT]}\\s*(${src[t2.LOOSEPLAIN]}|${src[t2.XRANGEPLAIN]})`, true);
3009
+ exports2.comparatorTrimReplace = "$1$2$3";
3010
+ createToken("HYPHENRANGE", `^\\s*(${src[t2.XRANGEPLAIN]})\\s+-\\s+(${src[t2.XRANGEPLAIN]})\\s*$`);
3011
+ createToken("HYPHENRANGELOOSE", `^\\s*(${src[t2.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t2.XRANGEPLAINLOOSE]})\\s*$`);
3012
+ createToken("STAR", "(<|>)?=?\\s*\\*");
3013
+ createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
3014
+ createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
3015
+ })(re$1, re$1.exports);
3016
+ var reExports = re$1.exports;
3017
+ const looseOption = Object.freeze({ loose: true });
3018
+ const emptyOpts = Object.freeze({});
3019
+ const parseOptions$1 = (options) => {
3020
+ if (!options) {
3021
+ return emptyOpts;
3022
+ }
3023
+ if (typeof options !== "object") {
3024
+ return looseOption;
3025
+ }
3026
+ return options;
3027
+ };
3028
+ var parseOptions_1 = parseOptions$1;
3029
+ const numeric = /^[0-9]+$/;
3030
+ const compareIdentifiers$1 = (a, b) => {
3031
+ const anum = numeric.test(a);
3032
+ const bnum = numeric.test(b);
3033
+ if (anum && bnum) {
3034
+ a = +a;
3035
+ b = +b;
3036
+ }
3037
+ return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
3038
+ };
3039
+ const rcompareIdentifiers = (a, b) => compareIdentifiers$1(b, a);
3040
+ var identifiers = {
3041
+ compareIdentifiers: compareIdentifiers$1,
3042
+ rcompareIdentifiers
3043
+ };
3044
+ const debug = debug_1;
3045
+ const { MAX_LENGTH, MAX_SAFE_INTEGER } = constants;
3046
+ const { safeRe: re, t } = reExports;
3047
+ const parseOptions = parseOptions_1;
3048
+ const { compareIdentifiers } = identifiers;
3049
+ let SemVer$2 = class SemVer {
3050
+ constructor(version, options) {
3051
+ options = parseOptions(options);
3052
+ if (version instanceof SemVer) {
3053
+ if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
3054
+ return version;
3055
+ } else {
3056
+ version = version.version;
3057
+ }
3058
+ } else if (typeof version !== "string") {
3059
+ throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
3060
+ }
3061
+ if (version.length > MAX_LENGTH) {
3062
+ throw new TypeError(
3063
+ `version is longer than ${MAX_LENGTH} characters`
3064
+ );
3065
+ }
3066
+ debug("SemVer", version, options);
3067
+ this.options = options;
3068
+ this.loose = !!options.loose;
3069
+ this.includePrerelease = !!options.includePrerelease;
3070
+ const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
3071
+ if (!m) {
3072
+ throw new TypeError(`Invalid Version: ${version}`);
3073
+ }
3074
+ this.raw = version;
3075
+ this.major = +m[1];
3076
+ this.minor = +m[2];
3077
+ this.patch = +m[3];
3078
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
3079
+ throw new TypeError("Invalid major version");
3080
+ }
3081
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
3082
+ throw new TypeError("Invalid minor version");
3083
+ }
3084
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
3085
+ throw new TypeError("Invalid patch version");
3086
+ }
3087
+ if (!m[4]) {
3088
+ this.prerelease = [];
3089
+ } else {
3090
+ this.prerelease = m[4].split(".").map((id) => {
3091
+ if (/^[0-9]+$/.test(id)) {
3092
+ const num = +id;
3093
+ if (num >= 0 && num < MAX_SAFE_INTEGER) {
3094
+ return num;
3095
+ }
3096
+ }
3097
+ return id;
3098
+ });
3099
+ }
3100
+ this.build = m[5] ? m[5].split(".") : [];
3101
+ this.format();
3102
+ }
3103
+ format() {
3104
+ this.version = `${this.major}.${this.minor}.${this.patch}`;
3105
+ if (this.prerelease.length) {
3106
+ this.version += `-${this.prerelease.join(".")}`;
3107
+ }
3108
+ return this.version;
3109
+ }
3110
+ toString() {
3111
+ return this.version;
3112
+ }
3113
+ compare(other) {
3114
+ debug("SemVer.compare", this.version, this.options, other);
3115
+ if (!(other instanceof SemVer)) {
3116
+ if (typeof other === "string" && other === this.version) {
3117
+ return 0;
3118
+ }
3119
+ other = new SemVer(other, this.options);
3120
+ }
3121
+ if (other.version === this.version) {
3122
+ return 0;
3123
+ }
3124
+ return this.compareMain(other) || this.comparePre(other);
3125
+ }
3126
+ compareMain(other) {
3127
+ if (!(other instanceof SemVer)) {
3128
+ other = new SemVer(other, this.options);
3129
+ }
3130
+ return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
3131
+ }
3132
+ comparePre(other) {
3133
+ if (!(other instanceof SemVer)) {
3134
+ other = new SemVer(other, this.options);
3135
+ }
3136
+ if (this.prerelease.length && !other.prerelease.length) {
3137
+ return -1;
3138
+ } else if (!this.prerelease.length && other.prerelease.length) {
3139
+ return 1;
3140
+ } else if (!this.prerelease.length && !other.prerelease.length) {
3141
+ return 0;
3142
+ }
3143
+ let i = 0;
3144
+ do {
3145
+ const a = this.prerelease[i];
3146
+ const b = other.prerelease[i];
3147
+ debug("prerelease compare", i, a, b);
3148
+ if (a === void 0 && b === void 0) {
3149
+ return 0;
3150
+ } else if (b === void 0) {
3151
+ return 1;
3152
+ } else if (a === void 0) {
3153
+ return -1;
3154
+ } else if (a === b) {
3155
+ continue;
3156
+ } else {
3157
+ return compareIdentifiers(a, b);
3158
+ }
3159
+ } while (++i);
3160
+ }
3161
+ compareBuild(other) {
3162
+ if (!(other instanceof SemVer)) {
3163
+ other = new SemVer(other, this.options);
3164
+ }
3165
+ let i = 0;
3166
+ do {
3167
+ const a = this.build[i];
3168
+ const b = other.build[i];
3169
+ debug("build compare", i, a, b);
3170
+ if (a === void 0 && b === void 0) {
3171
+ return 0;
3172
+ } else if (b === void 0) {
3173
+ return 1;
3174
+ } else if (a === void 0) {
3175
+ return -1;
3176
+ } else if (a === b) {
3177
+ continue;
3178
+ } else {
3179
+ return compareIdentifiers(a, b);
3180
+ }
3181
+ } while (++i);
3182
+ }
3183
+ // preminor will bump the version up to the next minor release, and immediately
3184
+ // down to pre-release. premajor and prepatch work the same way.
3185
+ inc(release, identifier, identifierBase) {
3186
+ switch (release) {
3187
+ case "premajor":
3188
+ this.prerelease.length = 0;
3189
+ this.patch = 0;
3190
+ this.minor = 0;
3191
+ this.major++;
3192
+ this.inc("pre", identifier, identifierBase);
3193
+ break;
3194
+ case "preminor":
3195
+ this.prerelease.length = 0;
3196
+ this.patch = 0;
3197
+ this.minor++;
3198
+ this.inc("pre", identifier, identifierBase);
3199
+ break;
3200
+ case "prepatch":
3201
+ this.prerelease.length = 0;
3202
+ this.inc("patch", identifier, identifierBase);
3203
+ this.inc("pre", identifier, identifierBase);
3204
+ break;
3205
+ case "prerelease":
3206
+ if (this.prerelease.length === 0) {
3207
+ this.inc("patch", identifier, identifierBase);
3208
+ }
3209
+ this.inc("pre", identifier, identifierBase);
3210
+ break;
3211
+ case "major":
3212
+ if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
3213
+ this.major++;
3214
+ }
3215
+ this.minor = 0;
3216
+ this.patch = 0;
3217
+ this.prerelease = [];
3218
+ break;
3219
+ case "minor":
3220
+ if (this.patch !== 0 || this.prerelease.length === 0) {
3221
+ this.minor++;
3222
+ }
3223
+ this.patch = 0;
3224
+ this.prerelease = [];
3225
+ break;
3226
+ case "patch":
3227
+ if (this.prerelease.length === 0) {
3228
+ this.patch++;
3229
+ }
3230
+ this.prerelease = [];
3231
+ break;
3232
+ case "pre": {
3233
+ const base = Number(identifierBase) ? 1 : 0;
3234
+ if (!identifier && identifierBase === false) {
3235
+ throw new Error("invalid increment argument: identifier is empty");
3236
+ }
3237
+ if (this.prerelease.length === 0) {
3238
+ this.prerelease = [base];
3239
+ } else {
3240
+ let i = this.prerelease.length;
3241
+ while (--i >= 0) {
3242
+ if (typeof this.prerelease[i] === "number") {
3243
+ this.prerelease[i]++;
3244
+ i = -2;
3245
+ }
3246
+ }
3247
+ if (i === -1) {
3248
+ if (identifier === this.prerelease.join(".") && identifierBase === false) {
3249
+ throw new Error("invalid increment argument: identifier already exists");
3250
+ }
3251
+ this.prerelease.push(base);
3252
+ }
3253
+ }
3254
+ if (identifier) {
3255
+ let prerelease = [identifier, base];
3256
+ if (identifierBase === false) {
3257
+ prerelease = [identifier];
3258
+ }
3259
+ if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
3260
+ if (isNaN(this.prerelease[1])) {
3261
+ this.prerelease = prerelease;
3262
+ }
3263
+ } else {
3264
+ this.prerelease = prerelease;
3265
+ }
3266
+ }
3267
+ break;
3268
+ }
3269
+ default:
3270
+ throw new Error(`invalid increment argument: ${release}`);
3271
+ }
3272
+ this.raw = this.format();
3273
+ if (this.build.length) {
3274
+ this.raw += `+${this.build.join(".")}`;
3275
+ }
3276
+ return this;
3277
+ }
3278
+ };
3279
+ var semver = SemVer$2;
3280
+ const SemVer$1 = semver;
3281
+ const parse$1 = (version, options, throwErrors = false) => {
3282
+ if (version instanceof SemVer$1) {
3283
+ return version;
3284
+ }
3285
+ try {
3286
+ return new SemVer$1(version, options);
3287
+ } catch (er) {
3288
+ if (!throwErrors) {
3289
+ return null;
3290
+ }
3291
+ throw er;
3292
+ }
3293
+ };
3294
+ var parse_1 = parse$1;
3295
+ const parse = parse_1;
3296
+ const valid = (version, options) => {
3297
+ const v = parse(version, options);
3298
+ return v ? v.version : null;
3299
+ };
3300
+ var valid_1 = valid;
3301
+ const valid$1 = /* @__PURE__ */ getDefaultExportFromCjs(valid_1);
3302
+ const SemVer2 = semver;
3303
+ const major = (a, loose) => new SemVer2(a, loose).major;
3304
+ var major_1 = major;
3305
+ const major$1 = /* @__PURE__ */ getDefaultExportFromCjs(major_1);
3306
+ class ProxyBus {
3307
+ bus;
3308
+ constructor(bus2) {
3309
+ if (typeof bus2.getVersion !== "function" || !valid$1(bus2.getVersion())) {
3310
+ console.warn("Proxying an event bus with an unknown or invalid version");
3311
+ } else if (major$1(bus2.getVersion()) !== major$1(this.getVersion())) {
3312
+ console.warn(
3313
+ "Proxying an event bus of version " + bus2.getVersion() + " with " + this.getVersion()
3314
+ );
3315
+ }
3316
+ this.bus = bus2;
3317
+ }
3318
+ getVersion() {
3319
+ return "3.3.1";
3320
+ }
3321
+ subscribe(name, handler) {
3322
+ this.bus.subscribe(name, handler);
3323
+ }
3324
+ unsubscribe(name, handler) {
3325
+ this.bus.unsubscribe(name, handler);
3326
+ }
3327
+ emit(name, event) {
3328
+ this.bus.emit(name, event);
3329
+ }
3330
+ }
3331
+ class SimpleBus {
3332
+ handlers = /* @__PURE__ */ new Map();
3333
+ getVersion() {
3334
+ return "3.3.1";
3335
+ }
3336
+ subscribe(name, handler) {
3337
+ this.handlers.set(
3338
+ name,
3339
+ (this.handlers.get(name) || []).concat(
3340
+ handler
3341
+ )
3342
+ );
3343
+ }
3344
+ unsubscribe(name, handler) {
3345
+ this.handlers.set(
3346
+ name,
3347
+ (this.handlers.get(name) || []).filter((h) => h !== handler)
3348
+ );
3349
+ }
3350
+ emit(name, event) {
3351
+ (this.handlers.get(name) || []).forEach((h) => {
3352
+ try {
3353
+ h(event);
3354
+ } catch (e) {
3355
+ console.error("could not invoke event listener", e);
3356
+ }
3357
+ });
3358
+ }
3359
+ }
3360
+ let bus = null;
3361
+ function getBus() {
3362
+ if (bus !== null) {
3363
+ return bus;
3364
+ }
3365
+ if (typeof window === "undefined") {
3366
+ return new Proxy({}, {
3367
+ get: () => {
3368
+ return () => console.error(
3369
+ "Window not available, EventBus can not be established!"
3370
+ );
3371
+ }
3372
+ });
3373
+ }
3374
+ if (window.OC?._eventBus && typeof window._nc_event_bus === "undefined") {
3375
+ console.warn(
3376
+ "found old event bus instance at OC._eventBus. Update your version!"
3377
+ );
3378
+ window._nc_event_bus = window.OC._eventBus;
3379
+ }
3380
+ if (typeof window?._nc_event_bus !== "undefined") {
3381
+ bus = new ProxyBus(window._nc_event_bus);
3382
+ } else {
3383
+ bus = window._nc_event_bus = new SimpleBus();
3384
+ }
3385
+ return bus;
3386
+ }
3387
+ function emit(name, event) {
3388
+ getBus().emit(name, event);
3389
+ }
3390
+ /*!
3391
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
3392
+ * SPDX-License-Identifier: AGPL-3.0-or-later
3393
+ */
3394
+ class FileListFilter extends typescriptEventTarget.TypedEventTarget {
3395
+ id;
3396
+ order;
3397
+ constructor(id, order = 100) {
3398
+ super();
3399
+ this.id = id;
3400
+ this.order = order;
3401
+ }
3402
+ filter(nodes) {
3403
+ throw new Error("Not implemented");
3404
+ }
3405
+ updateChips(chips) {
3406
+ this.dispatchTypedEvent("update:chips", new CustomEvent("update:chips", { detail: chips }));
3407
+ }
3408
+ filterUpdated() {
3409
+ this.dispatchTypedEvent("update:filter", new CustomEvent("update:filter"));
3410
+ }
3411
+ }
3412
+ function registerFileListFilter(filter) {
3413
+ if (!window._nc_filelist_filters) {
3414
+ window._nc_filelist_filters = /* @__PURE__ */ new Map();
3415
+ }
3416
+ if (window._nc_filelist_filters.has(filter.id)) {
3417
+ throw new Error(`File list filter "${filter.id}" already registered`);
3418
+ }
3419
+ window._nc_filelist_filters.set(filter.id, filter);
3420
+ emit("files:filter:added", filter);
3421
+ }
3422
+ function unregisterFileListFilter(filterId) {
3423
+ if (window._nc_filelist_filters && window._nc_filelist_filters.has(filterId)) {
3424
+ window._nc_filelist_filters.delete(filterId);
3425
+ emit("files:filter:removed", filterId);
3426
+ }
3427
+ }
3428
+ function getFileListFilters() {
3429
+ if (!window._nc_filelist_filters) {
3430
+ return [];
3431
+ }
3432
+ return [...window._nc_filelist_filters.values()];
3433
+ }
2885
3434
  const addNewFileMenuEntry = function(entry) {
2886
3435
  const newFileMenu = getNewFileMenu();
2887
3436
  return newFileMenu.registerEntry(entry);
@@ -2903,6 +3452,7 @@ exports.Column = Column;
2903
3452
  exports.DefaultType = DefaultType;
2904
3453
  exports.File = File;
2905
3454
  exports.FileAction = FileAction;
3455
+ exports.FileListFilter = FileListFilter;
2906
3456
  exports.FileType = FileType;
2907
3457
  exports.FilesSortingMode = FilesSortingMode;
2908
3458
  exports.Folder = Folder;
@@ -2933,6 +3483,7 @@ exports.getDavNameSpaces = getDavNameSpaces;
2933
3483
  exports.getDavProperties = getDavProperties;
2934
3484
  exports.getFavoriteNodes = getFavoriteNodes;
2935
3485
  exports.getFileActions = getFileActions;
3486
+ exports.getFileListFilters = getFileListFilters;
2936
3487
  exports.getFileListHeaders = getFileListHeaders;
2937
3488
  exports.getNavigation = getNavigation;
2938
3489
  exports.getNewFileMenuEntries = getNewFileMenuEntries;
@@ -2942,7 +3493,9 @@ exports.orderBy = orderBy;
2942
3493
  exports.parseFileSize = parseFileSize;
2943
3494
  exports.registerDavProperty = registerDavProperty;
2944
3495
  exports.registerFileAction = registerFileAction;
3496
+ exports.registerFileListFilter = registerFileListFilter;
2945
3497
  exports.registerFileListHeaders = registerFileListHeaders;
2946
3498
  exports.removeNewFileMenuEntry = removeNewFileMenuEntry;
2947
3499
  exports.sortNodes = sortNodes;
3500
+ exports.unregisterFileListFilter = unregisterFileListFilter;
2948
3501
  exports.validateFilename = validateFilename;