@nextcloud/files 3.5.0 → 3.5.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/dav/dav.d.ts +11 -0
- package/dist/index.cjs +32 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +32 -22
- package/dist/index.mjs.map +1 -1
- package/dist/utils/logger.d.ts +0 -4
- package/package.json +5 -4
package/dist/index.mjs
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
import { getCurrentUser, onRequestTokenUpdate, getRequestToken } from "@nextcloud/auth";
|
|
2
1
|
import { getLoggerBuilder } from "@nextcloud/logger";
|
|
2
|
+
import { getCurrentUser, onRequestTokenUpdate, getRequestToken } from "@nextcloud/auth";
|
|
3
3
|
import { join, basename, extname, dirname } from "path";
|
|
4
4
|
import { encodePath } from "@nextcloud/paths";
|
|
5
5
|
import { generateRemoteUrl } from "@nextcloud/router";
|
|
6
|
-
import { createClient, getPatcher } from "webdav";
|
|
7
6
|
import { CancelablePromise } from "cancelable-promise";
|
|
7
|
+
import { createClient, getPatcher } from "webdav";
|
|
8
|
+
import { isPublicShare, getSharingToken } from "@nextcloud/sharing/public";
|
|
8
9
|
import { getCanonicalLocale, getLanguage } from "@nextcloud/l10n";
|
|
9
10
|
import { TypedEventTarget } from "typescript-event-target";
|
|
10
|
-
const
|
|
11
|
-
if (user === null) {
|
|
12
|
-
return getLoggerBuilder().setApp("files").build();
|
|
13
|
-
}
|
|
14
|
-
return getLoggerBuilder().setApp("files").setUid(user.uid).build();
|
|
15
|
-
};
|
|
16
|
-
const logger = getLogger(getCurrentUser());
|
|
11
|
+
const logger = getLoggerBuilder().setApp("@nextcloud/files").detectUser().build();
|
|
17
12
|
var NewMenuEntryCategory = /* @__PURE__ */ ((NewMenuEntryCategory2) => {
|
|
18
13
|
NewMenuEntryCategory2[NewMenuEntryCategory2["UploadFromDevice"] = 0] = "UploadFromDevice";
|
|
19
14
|
NewMenuEntryCategory2[NewMenuEntryCategory2["CreateNew"] = 1] = "CreateNew";
|
|
@@ -256,6 +251,8 @@ const defaultDavProperties = [
|
|
|
256
251
|
"d:getcontenttype",
|
|
257
252
|
"d:getetag",
|
|
258
253
|
"d:getlastmodified",
|
|
254
|
+
"d:creationdate",
|
|
255
|
+
"d:displayname",
|
|
259
256
|
"d:quota-available-bytes",
|
|
260
257
|
"d:resourcetype",
|
|
261
258
|
"nc:has-preview",
|
|
@@ -408,6 +405,11 @@ const davParsePermissions = function(permString = "") {
|
|
|
408
405
|
}
|
|
409
406
|
return permissions;
|
|
410
407
|
};
|
|
408
|
+
var FileType = /* @__PURE__ */ ((FileType2) => {
|
|
409
|
+
FileType2["Folder"] = "folder";
|
|
410
|
+
FileType2["File"] = "file";
|
|
411
|
+
return FileType2;
|
|
412
|
+
})(FileType || {});
|
|
411
413
|
const isDavRessource = function(source, davService) {
|
|
412
414
|
return source.match(davService) !== null;
|
|
413
415
|
};
|
|
@@ -740,11 +742,6 @@ class Node {
|
|
|
740
742
|
}
|
|
741
743
|
}
|
|
742
744
|
}
|
|
743
|
-
var FileType = /* @__PURE__ */ ((FileType2) => {
|
|
744
|
-
FileType2["Folder"] = "folder";
|
|
745
|
-
FileType2["File"] = "file";
|
|
746
|
-
return FileType2;
|
|
747
|
-
})(FileType || {});
|
|
748
745
|
class File extends Node {
|
|
749
746
|
get type() {
|
|
750
747
|
return FileType.File;
|
|
@@ -767,8 +764,21 @@ class Folder extends Node {
|
|
|
767
764
|
return "httpd/unix-directory";
|
|
768
765
|
}
|
|
769
766
|
}
|
|
770
|
-
|
|
771
|
-
|
|
767
|
+
function davGetRootPath() {
|
|
768
|
+
if (isPublicShare()) {
|
|
769
|
+
return `/files/${getSharingToken()}`;
|
|
770
|
+
}
|
|
771
|
+
return `/files/${getCurrentUser()?.uid}`;
|
|
772
|
+
}
|
|
773
|
+
const davRootPath = davGetRootPath();
|
|
774
|
+
function davGetRemoteURL() {
|
|
775
|
+
const url = generateRemoteUrl("dav");
|
|
776
|
+
if (isPublicShare()) {
|
|
777
|
+
return url.replace("remote.php", "public.php");
|
|
778
|
+
}
|
|
779
|
+
return url;
|
|
780
|
+
}
|
|
781
|
+
const davRemoteURL = davGetRemoteURL();
|
|
772
782
|
const davGetClient = function(remoteURL = davRemoteURL, headers = {}) {
|
|
773
783
|
const client = createClient(remoteURL, { headers });
|
|
774
784
|
function setHeaders(token) {
|
|
@@ -817,9 +827,7 @@ const getFavoriteNodes = (davClient, path = "/", davRoot = davRootPath) => {
|
|
|
817
827
|
};
|
|
818
828
|
const davResultToNode = function(node, filesRoot = davRootPath, remoteURL = davRemoteURL) {
|
|
819
829
|
let userId = getCurrentUser()?.uid;
|
|
820
|
-
|
|
821
|
-
if (isPublic) {
|
|
822
|
-
userId = userId ?? document.querySelector("input#sharingUserId")?.value;
|
|
830
|
+
if (isPublicShare()) {
|
|
823
831
|
userId = userId ?? "anonymous";
|
|
824
832
|
} else if (!userId) {
|
|
825
833
|
throw new Error("No user id found");
|
|
@@ -966,10 +974,10 @@ function sortNodes(nodes, options = {}) {
|
|
|
966
974
|
...sortingOptions.sortFavoritesFirst ? [(v) => v.attributes?.favorite !== 1] : [],
|
|
967
975
|
// 2: Sort folders first if sorting by name
|
|
968
976
|
...sortingOptions.sortFoldersFirst ? [(v) => v.type !== "folder"] : [],
|
|
969
|
-
// 3: Use sorting mode if NOT basename (to be able to use
|
|
977
|
+
// 3: Use sorting mode if NOT basename (to be able to use displayname too)
|
|
970
978
|
...sortingOptions.sortingMode !== "basename" ? [(v) => v[sortingOptions.sortingMode]] : [],
|
|
971
|
-
// 4: Use
|
|
972
|
-
(v) => basename2(v.attributes?.
|
|
979
|
+
// 4: Use displayname if available, fallback to name
|
|
980
|
+
(v) => basename2(v.attributes?.displayname || v.basename),
|
|
973
981
|
// 5: Finally, use basename if all previous sorting methods failed
|
|
974
982
|
(v) => v.basename
|
|
975
983
|
];
|
|
@@ -2815,6 +2823,8 @@ export {
|
|
|
2815
2823
|
davGetDefaultPropfind,
|
|
2816
2824
|
davGetFavoritesReport,
|
|
2817
2825
|
davGetRecentSearch,
|
|
2826
|
+
davGetRemoteURL,
|
|
2827
|
+
davGetRootPath,
|
|
2818
2828
|
davParsePermissions,
|
|
2819
2829
|
davRemoteURL,
|
|
2820
2830
|
davResultToNode,
|