@nextcloud/files 3.0.0 → 3.1.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/dav/dav.d.ts CHANGED
@@ -34,8 +34,9 @@ export declare const davRemoteURL: string;
34
34
  * Get a WebDAV client configured to include the Nextcloud request token
35
35
  *
36
36
  * @param remoteURL The DAV server remote URL
37
+ * @param headers Optional additional headers to set for every request
37
38
  */
38
- export declare const davGetClient: (remoteURL?: string) => WebDAVClient;
39
+ export declare const davGetClient: (remoteURL?: string, headers?: Record<string, string>) => WebDAVClient;
39
40
  /**
40
41
  * Use WebDAV to query for favorite Nodes
41
42
  *
package/dist/index.cjs CHANGED
@@ -85,7 +85,7 @@ class Ee {
85
85
  throw new Error("Duplicate entry");
86
86
  }
87
87
  }
88
- const R = function() {
88
+ const S = function() {
89
89
  return typeof window._nc_newfilemenu > "u" && (window._nc_newfilemenu = new Ee(), N.debug("NewFileMenu initialized")), window._nc_newfilemenu;
90
90
  };
91
91
  /**
@@ -160,7 +160,7 @@ function be(e, t = !1) {
160
160
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
161
161
  *
162
162
  */
163
- var S = /* @__PURE__ */ ((e) => (e.DEFAULT = "default", e.HIDDEN = "hidden", e))(S || {});
163
+ var L = /* @__PURE__ */ ((e) => (e.DEFAULT = "default", e.HIDDEN = "hidden", e))(L || {});
164
164
  class ve {
165
165
  _action;
166
166
  constructor(t) {
@@ -221,7 +221,7 @@ class ve {
221
221
  throw new Error("Invalid order");
222
222
  if ("parent" in t && typeof t.parent != "string")
223
223
  throw new Error("Invalid parent");
224
- if (t.default && !Object.values(S).includes(t.default))
224
+ if (t.default && !Object.values(L).includes(t.default))
225
225
  throw new Error("Invalid default");
226
226
  if ("inline" in t && typeof t.inline != "function")
227
227
  throw new Error("Invalid inline function");
@@ -635,8 +635,10 @@ class q {
635
635
  */
636
636
  get dirname() {
637
637
  if (this.root) {
638
- const r = this.source.indexOf(this.root);
639
- return b.dirname(this.source.slice(r + this.root.length) || "/");
638
+ let r = this.source;
639
+ this.isDavRessource && (r = r.split(this._knownDavService).pop());
640
+ const s = r.indexOf(this.root), n = this.root.replace(/\/$/, "");
641
+ return b.dirname(r.slice(s + n.length) || "/");
640
642
  }
641
643
  const t = new URL(this.source);
642
644
  return b.dirname(t.pathname);
@@ -700,8 +702,10 @@ class q {
700
702
  */
701
703
  get path() {
702
704
  if (this.root) {
703
- const t = this.source.indexOf(this.root);
704
- return this.source.slice(t + this.root.length) || "/";
705
+ let t = this.source;
706
+ this.isDavRessource && (t = t.split(this._knownDavService).pop());
707
+ const r = t.indexOf(this.root), s = this.root.replace(/\/$/, "");
708
+ return t.slice(r + s.length) || "/";
705
709
  }
706
710
  return (this.dirname + "/" + this.basename).replace(/\/\//g, "/");
707
711
  }
@@ -837,20 +841,21 @@ class oe extends q {
837
841
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
838
842
  *
839
843
  */
840
- const U = `/files/${_.getCurrentUser()?.uid}`, X = me.generateRemoteUrl("dav"), xe = function(e = X) {
841
- const t = Z.createClient(e);
842
- function r(n) {
843
- t.setHeaders({
844
+ const U = `/files/${_.getCurrentUser()?.uid}`, X = me.generateRemoteUrl("dav"), xe = function(e = X, t = {}) {
845
+ const r = Z.createClient(e, { headers: t });
846
+ function s(i) {
847
+ r.setHeaders({
848
+ ...t,
844
849
  // Add this so the server knows it is an request from the browser
845
850
  "X-Requested-With": "XMLHttpRequest",
846
851
  // Inject user auth
847
- requesttoken: n ?? ""
852
+ requesttoken: i ?? ""
848
853
  });
849
854
  }
850
- return _.onRequestTokenUpdate(r), r(_.getRequestToken()), Z.getPatcher().patch("fetch", (n, i) => {
851
- const a = i.headers;
852
- return a?.method && (i.method = a.method, delete a.method), fetch(n, i);
853
- }), t;
855
+ return _.onRequestTokenUpdate(s), s(_.getRequestToken()), Z.getPatcher().patch("fetch", (i, a) => {
856
+ const u = a.headers;
857
+ return u?.method && (a.method = u.method, delete u.method), fetch(i, a);
858
+ }), r;
854
859
  }, $e = async (e, t = "/", r = U) => (await e.getDirectoryContents(`${r}${t}`, {
855
860
  details: !0,
856
861
  data: re(),
@@ -860,7 +865,7 @@ const U = `/files/${_.getCurrentUser()?.uid}`, X = me.generateRemoteUrl("dav"),
860
865
  },
861
866
  includeSelf: !0
862
867
  })).data.filter((n) => n.filename !== t).map((n) => ue(n, r)), ue = function(e, t = U, r = X) {
863
- const s = e.props, n = ne(s?.permissions), i = _.getCurrentUser()?.uid, a = {
868
+ const s = e.props, n = ne(s?.permissions), i = s?.["owner-id"] || _.getCurrentUser()?.uid, a = {
864
869
  id: s?.fileid || 0,
865
870
  source: `${r}${e.filename}`,
866
871
  mtime: new Date(Date.parse(e.lastmod)),
@@ -947,7 +952,7 @@ const Ve = function() {
947
952
  class de {
948
953
  _column;
949
954
  constructor(t) {
950
- Le(t), this._column = t;
955
+ Re(t), this._column = t;
951
956
  }
952
957
  get id() {
953
958
  return this._column.id;
@@ -965,7 +970,7 @@ class de {
965
970
  return this._column.summary;
966
971
  }
967
972
  }
968
- const Le = function(e) {
973
+ const Re = function(e) {
969
974
  if (!e.id || typeof e.id != "string")
970
975
  throw new Error("A column id is required");
971
976
  if (!e.title || typeof e.title != "string")
@@ -1010,13 +1015,13 @@ var G = {}, F = {};
1010
1015
  return e.isExist(u) ? u : "";
1011
1016
  }, e.isName = a, e.getAllMatches = i, e.nameRegexp = s;
1012
1017
  })(F);
1013
- const H = F, Re = {
1018
+ const H = F, Se = {
1014
1019
  allowBooleanAttributes: !1,
1015
1020
  //A tag can have attributes without any value
1016
1021
  unpairedTags: []
1017
1022
  };
1018
1023
  G.validate = function(e, t) {
1019
- t = Object.assign({}, Re, t);
1024
+ t = Object.assign({}, Se, t);
1020
1025
  const r = [];
1021
1026
  let s = !1, n = !1;
1022
1027
  e[0] === "\uFEFF" && (e = e.substr(1));
@@ -1153,11 +1158,11 @@ function Q(e, t) {
1153
1158
  }
1154
1159
  return t;
1155
1160
  }
1156
- const Se = '"', Me = "'";
1161
+ const Le = '"', Me = "'";
1157
1162
  function Be(e, t) {
1158
1163
  let r = "", s = "", n = !1;
1159
1164
  for (; t < e.length; t++) {
1160
- if (e[t] === Se || e[t] === Me)
1165
+ if (e[t] === Le || e[t] === Me)
1161
1166
  s === "" ? s = e[t] : s !== e[t] || (s = "");
1162
1167
  else if (e[t] === ">" && s === "") {
1163
1168
  n = !0;
@@ -1451,7 +1456,7 @@ function ht(e, t, r, s, n, i, a) {
1451
1456
  if (e !== void 0 && (this.options.trimValues && !s && (e = e.trim()), e.length > 0)) {
1452
1457
  a || (e = this.replaceEntitiesValue(e));
1453
1458
  const u = this.options.tagValueProcessor(t, e, r, n, i);
1454
- return u == null ? e : typeof u != typeof e || u !== e ? u : this.options.trimValues ? L(e, this.options.parseTagValue, this.options.numberParseOptions) : e.trim() === e ? L(e, this.options.parseTagValue, this.options.numberParseOptions) : e;
1459
+ return u == null ? e : typeof u != typeof e || u !== e ? u : this.options.trimValues ? R(e, this.options.parseTagValue, this.options.numberParseOptions) : e.trim() === e ? R(e, this.options.parseTagValue, this.options.numberParseOptions) : e;
1455
1460
  }
1456
1461
  }
1457
1462
  function pt(e) {
@@ -1474,7 +1479,7 @@ function wt(e, t, r) {
1474
1479
  if (this.options.transformAttributeName && (d = this.options.transformAttributeName(d)), d === "__proto__" && (d = "#__proto__"), o !== void 0) {
1475
1480
  this.options.trimValues && (o = o.trim()), o = this.replaceEntitiesValue(o);
1476
1481
  const l = this.options.attributeValueProcessor(u, o, t);
1477
- l == null ? i[d] = o : typeof l != typeof o || l !== o ? i[d] = l : i[d] = L(
1482
+ l == null ? i[d] = o : typeof l != typeof o || l !== o ? i[d] = l : i[d] = R(
1478
1483
  o,
1479
1484
  this.options.parseAttributeValue,
1480
1485
  this.options.numberParseOptions
@@ -1693,7 +1698,7 @@ function _t(e, t, r) {
1693
1698
  i && ((i && i.tagName) === t && i.tagExp[i.tagExp.length - 1] !== "/" && n++, r = i.closeIndex);
1694
1699
  }
1695
1700
  }
1696
- function L(e, t, r) {
1701
+ function R(e, t, r) {
1697
1702
  if (t && typeof e == "string") {
1698
1703
  const s = e.trim();
1699
1704
  return s === "true" ? !0 : s === "false" ? !1 : lt(e, r);
@@ -1788,12 +1793,12 @@ let Vt = class {
1788
1793
  this.externalEntities[t] = r;
1789
1794
  }
1790
1795
  };
1791
- var Lt = Vt;
1792
- const Rt = `
1796
+ var Rt = Vt;
1797
+ const St = `
1793
1798
  `;
1794
- function St(e, t) {
1799
+ function Lt(e, t) {
1795
1800
  let r = "";
1796
- return t.format && t.indentBy.length > 0 && (r = Rt), he(e, t, "", r);
1801
+ return t.format && t.indentBy.length > 0 && (r = St), he(e, t, "", r);
1797
1802
  }
1798
1803
  function he(e, t, r, s) {
1799
1804
  let n = "", i = !1;
@@ -1860,7 +1865,7 @@ function pe(e, t) {
1860
1865
  }
1861
1866
  return e;
1862
1867
  }
1863
- var kt = St;
1868
+ var kt = Lt;
1864
1869
  const qt = kt, Ut = {
1865
1870
  attributeNamePrefix: "@_",
1866
1871
  attributesGroupName: !1,
@@ -1990,7 +1995,7 @@ function Ht(e) {
1990
1995
  return e.startsWith(this.options.attributeNamePrefix) && e !== this.options.textNodeName ? e.substr(this.attrPrefixLen) : !1;
1991
1996
  }
1992
1997
  var zt = y;
1993
- const Kt = G, Wt = Lt, Zt = zt;
1998
+ const Kt = G, Wt = Rt, Zt = zt;
1994
1999
  var te = {
1995
2000
  XMLParser: Wt,
1996
2001
  XMLValidator: Kt,
@@ -2145,14 +2150,14 @@ const Jt = function(e) {
2145
2150
  *
2146
2151
  */
2147
2152
  const Qt = function(e) {
2148
- return R().registerEntry(e);
2153
+ return S().registerEntry(e);
2149
2154
  }, Dt = function(e) {
2150
- return R().unregisterEntry(e);
2155
+ return S().unregisterEntry(e);
2151
2156
  }, er = function(e) {
2152
- return R().getEntries(e).sort((r, s) => r.order !== void 0 && s.order !== void 0 && r.order !== s.order ? r.order - s.order : r.displayName.localeCompare(s.displayName, void 0, { numeric: !0, sensitivity: "base" }));
2157
+ return S().getEntries(e).sort((r, s) => r.order !== void 0 && s.order !== void 0 && r.order !== s.order ? r.order - s.order : r.displayName.localeCompare(s.displayName, void 0, { numeric: !0, sensitivity: "base" }));
2153
2158
  };
2154
2159
  exports.Column = de;
2155
- exports.DefaultType = S;
2160
+ exports.DefaultType = L;
2156
2161
  exports.File = se;
2157
2162
  exports.FileAction = ve;
2158
2163
  exports.FileType = O;