@nextcloud/files 3.0.0-beta.15 → 3.0.0-beta.16
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 +20 -3
- package/dist/fileAction.d.ts +31 -18
- package/dist/fileListHeaders.d.ts +7 -6
- package/dist/index.cjs +11 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.mjs +250 -105
- package/dist/index.mjs.map +1 -1
- package/dist/navigation/column.d.ts +48 -0
- package/dist/navigation/navigation.d.ts +32 -0
- package/dist/navigation/view.d.ts +99 -0
- package/dist/newFileMenu.d.ts +7 -5
- package/package.json +2 -1
package/dist/dav/dav.d.ts
CHANGED
|
@@ -22,12 +22,18 @@
|
|
|
22
22
|
*/
|
|
23
23
|
import type { FileStat, WebDAVClient } from 'webdav';
|
|
24
24
|
import type { Node } from '../files/node';
|
|
25
|
+
/**
|
|
26
|
+
* The DAV root path for the current user
|
|
27
|
+
*/
|
|
25
28
|
export declare const davRootPath: string;
|
|
26
|
-
|
|
29
|
+
/**
|
|
30
|
+
* The DAV remote URL used as base URL for the WebDAV client
|
|
31
|
+
*/
|
|
32
|
+
export declare const davRemoteURL: string;
|
|
27
33
|
/**
|
|
28
34
|
* Get a WebDAV client configured to include the Nextcloud request token
|
|
29
35
|
*
|
|
30
|
-
* @param davURL The DAV
|
|
36
|
+
* @param davURL The DAV remote URL
|
|
31
37
|
*/
|
|
32
38
|
export declare const davGetClient: (davURL?: string) => WebDAVClient;
|
|
33
39
|
/**
|
|
@@ -35,8 +41,19 @@ export declare const davGetClient: (davURL?: string) => WebDAVClient;
|
|
|
35
41
|
*
|
|
36
42
|
* @param davClient The WebDAV client to use for performing the request
|
|
37
43
|
* @param path Base path for the favorites, if unset all favorites are queried
|
|
44
|
+
* @param davRoot The root path for the DAV user (defaults to `davRootPath`)
|
|
45
|
+
* @example
|
|
46
|
+
* ```js
|
|
47
|
+
* import { davGetClient, davRootPath, getFavoriteNodes } from '@nextcloud/files'
|
|
48
|
+
*
|
|
49
|
+
* const client = davGetClient()
|
|
50
|
+
* // query favorites for the root
|
|
51
|
+
* const favorites = await getFavoriteNodes(client)
|
|
52
|
+
* // which is the same as writing:
|
|
53
|
+
* const favorites = await getFavoriteNodes(client, '/', davRootPath)
|
|
54
|
+
* ```
|
|
38
55
|
*/
|
|
39
|
-
export declare const getFavoriteNodes: (davClient: WebDAVClient, path?: string) => Promise<Node[]>;
|
|
56
|
+
export declare const getFavoriteNodes: (davClient: WebDAVClient, path?: string, davRoot?: string) => Promise<Node[]>;
|
|
40
57
|
/**
|
|
41
58
|
* Covert DAV result `FileStat` to `Node`
|
|
42
59
|
*
|
package/dist/fileAction.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @copyright Copyright (c)
|
|
2
|
+
* @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
|
|
3
3
|
*
|
|
4
4
|
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
|
5
5
|
*
|
|
@@ -20,56 +20,69 @@
|
|
|
20
20
|
*
|
|
21
21
|
*/
|
|
22
22
|
import { Node } from './files/node';
|
|
23
|
+
import { View } from './navigation/view';
|
|
24
|
+
export declare enum DefaultType {
|
|
25
|
+
DEFAULT = "default",
|
|
26
|
+
HIDDEN = "hidden"
|
|
27
|
+
}
|
|
23
28
|
interface FileActionData {
|
|
24
29
|
/** Unique ID */
|
|
25
30
|
id: string;
|
|
26
31
|
/** Translatable string displayed in the menu */
|
|
27
|
-
displayName: (files: Node[], view:
|
|
32
|
+
displayName: (files: Node[], view: View) => string;
|
|
28
33
|
/** Svg as inline string. <svg><path fill="..." /></svg> */
|
|
29
|
-
iconSvgInline: (files: Node[], view:
|
|
34
|
+
iconSvgInline: (files: Node[], view: View) => string;
|
|
30
35
|
/** Condition wether this action is shown or not */
|
|
31
|
-
enabled?: (files: Node[], view:
|
|
36
|
+
enabled?: (files: Node[], view: View) => boolean;
|
|
32
37
|
/**
|
|
33
38
|
* Function executed on single file action
|
|
34
39
|
* @return true if the action was executed successfully,
|
|
35
40
|
* false otherwise and null if the action is silent/undefined.
|
|
36
41
|
* @throws Error if the action failed
|
|
37
42
|
*/
|
|
38
|
-
exec: (file: Node, view:
|
|
43
|
+
exec: (file: Node, view: View, dir: string) => Promise<boolean | null>;
|
|
39
44
|
/**
|
|
40
45
|
* Function executed on multiple files action
|
|
41
46
|
* @return true if the action was executed successfully,
|
|
42
47
|
* false otherwise and null if the action is silent/undefined.
|
|
43
48
|
* @throws Error if the action failed
|
|
44
49
|
*/
|
|
45
|
-
execBatch?: (files: Node[], view:
|
|
50
|
+
execBatch?: (files: Node[], view: View, dir: string) => Promise<(boolean | null)[]>;
|
|
46
51
|
/** This action order in the list */
|
|
47
52
|
order?: number;
|
|
48
|
-
/**
|
|
49
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Make this action the default.
|
|
55
|
+
* If multiple actions are default, the first one
|
|
56
|
+
* will be used. The other ones will be put as first
|
|
57
|
+
* entries in the actions menu iff DefaultType.Hidden is not used.
|
|
58
|
+
* A DefaultType.Hidden action will never be shown
|
|
59
|
+
* in the actions menu even if another action takes
|
|
60
|
+
* its place as default.
|
|
61
|
+
*/
|
|
62
|
+
default?: DefaultType;
|
|
50
63
|
/**
|
|
51
64
|
* If true, the renderInline function will be called
|
|
52
65
|
*/
|
|
53
|
-
inline?: (file: Node, view:
|
|
66
|
+
inline?: (file: Node, view: View) => boolean;
|
|
54
67
|
/**
|
|
55
68
|
* If defined, the returned html element will be
|
|
56
69
|
* appended before the actions menu.
|
|
57
70
|
*/
|
|
58
|
-
renderInline?: (file: Node, view:
|
|
71
|
+
renderInline?: (file: Node, view: View) => Promise<HTMLElement | null>;
|
|
59
72
|
}
|
|
60
73
|
export declare class FileAction {
|
|
61
74
|
private _action;
|
|
62
75
|
constructor(action: FileActionData);
|
|
63
76
|
get id(): string;
|
|
64
|
-
get displayName(): (files: Node[], view:
|
|
65
|
-
get iconSvgInline(): (files: Node[], view:
|
|
66
|
-
get enabled(): ((files: Node[], view:
|
|
67
|
-
get exec(): (file: Node, view:
|
|
68
|
-
get execBatch(): ((files: Node[], view:
|
|
77
|
+
get displayName(): (files: Node[], view: View) => string;
|
|
78
|
+
get iconSvgInline(): (files: Node[], view: View) => string;
|
|
79
|
+
get enabled(): ((files: Node[], view: View) => boolean) | undefined;
|
|
80
|
+
get exec(): (file: Node, view: View, dir: string) => Promise<boolean | null>;
|
|
81
|
+
get execBatch(): ((files: Node[], view: View, dir: string) => Promise<(boolean | null)[]>) | undefined;
|
|
69
82
|
get order(): number | undefined;
|
|
70
|
-
get default():
|
|
71
|
-
get inline(): ((file: Node, view:
|
|
72
|
-
get renderInline(): ((file: Node, view:
|
|
83
|
+
get default(): DefaultType | undefined;
|
|
84
|
+
get inline(): ((file: Node, view: View) => boolean) | undefined;
|
|
85
|
+
get renderInline(): ((file: Node, view: View) => Promise<HTMLElement | null>) | undefined;
|
|
73
86
|
private validateAction;
|
|
74
87
|
}
|
|
75
88
|
export declare const registerFileAction: (action: FileAction) => void;
|
|
@@ -20,26 +20,27 @@
|
|
|
20
20
|
*
|
|
21
21
|
*/
|
|
22
22
|
import { Folder } from './files/folder';
|
|
23
|
+
import { View } from './navigation/view';
|
|
23
24
|
export interface HeaderData {
|
|
24
25
|
/** Unique ID */
|
|
25
26
|
id: string;
|
|
26
27
|
/** Order */
|
|
27
28
|
order: number;
|
|
28
29
|
/** Condition wether this header is shown or not */
|
|
29
|
-
enabled?: (folder: Folder, view:
|
|
30
|
+
enabled?: (folder: Folder, view: View) => boolean;
|
|
30
31
|
/** Executed when file list is initialized */
|
|
31
|
-
render: (el: HTMLElement, folder: Folder, view:
|
|
32
|
+
render: (el: HTMLElement, folder: Folder, view: View) => void;
|
|
32
33
|
/** Executed when root folder changed */
|
|
33
|
-
updated(folder: Folder, view:
|
|
34
|
+
updated(folder: Folder, view: View): any;
|
|
34
35
|
}
|
|
35
36
|
export declare class Header {
|
|
36
37
|
private _header;
|
|
37
38
|
constructor(header: HeaderData);
|
|
38
39
|
get id(): string;
|
|
39
40
|
get order(): number;
|
|
40
|
-
get enabled(): ((folder: Folder, view:
|
|
41
|
-
get render(): (el: HTMLElement, folder: Folder, view:
|
|
42
|
-
get updated(): (folder: Folder, view:
|
|
41
|
+
get enabled(): ((folder: Folder, view: View) => boolean) | undefined;
|
|
42
|
+
get render(): (el: HTMLElement, folder: Folder, view: View) => void;
|
|
43
|
+
get updated(): (folder: Folder, view: View) => any;
|
|
43
44
|
private validateHeader;
|
|
44
45
|
}
|
|
45
46
|
export declare const registerFileListHeaders: (header: Header) => void;
|
package/dist/index.cjs
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
<d:propfind ${
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@nextcloud/auth"),E=require("@nextcloud/logger"),T=require("@nextcloud/l10n"),d=require("path"),x=require("@nextcloud/router"),b=require("webdav"),L=require("webdav/dist/node/request.js"),P=require("is-svg"),B=e=>e===null?E.getLoggerBuilder().setApp("files").build():E.getLoggerBuilder().setApp("files").setUid(e.uid).build(),s=B(u.getCurrentUser());class M{_entries=[];registerEntry(t){this.validateEntry(t),this._entries.push(t)}unregisterEntry(t){const r=typeof t=="string"?this.getEntryIndex(t):this.getEntryIndex(t.id);if(r===-1){s.warn("Entry not found, nothing removed",{entry:t,entries:this.getEntries()});return}this._entries.splice(r,1)}getEntries(t,r){return t&&r?this._entries.filter(i=>typeof i.if=="function"?i.if(t,r):!0):this._entries}getEntryIndex(t){return this._entries.findIndex(r=>r.id===t)}validateEntry(t){if(!t.id||!t.displayName||!(t.iconSvgInline||t.iconClass))throw new Error("Invalid entry");if(typeof t.id!="string"||typeof t.displayName!="string")throw new Error("Invalid id or displayName property");if(t.iconClass&&typeof t.iconClass!="string"||t.iconSvgInline&&typeof t.iconSvgInline!="string")throw new Error("Invalid icon provided");if(t.if!==void 0&&typeof t.if!="function")throw new Error("Invalid if property");if(t.templateName&&typeof t.templateName!="string")throw new Error("Invalid templateName property");if(t.handler&&typeof t.handler!="function")throw new Error("Invalid handler property");if(!t.templateName&&!t.handler)throw new Error("At least a templateName or a handler must be provided");if(this.getEntryIndex(t.id)!==-1)throw new Error("Duplicate entry")}}const h=function(){return typeof window._nc_newfilemenu>"u"&&(window._nc_newfilemenu=new M,s.debug("NewFileMenu initialized")),window._nc_newfilemenu},w=["B","KB","MB","GB","TB","PB"],f=["B","KiB","MiB","GiB","TiB","PiB"];function z(e,t=!1,r=!1){typeof e=="string"&&(e=Number(e));let i=e>0?Math.floor(Math.log(e)/Math.log(r?1024:1e3)):0;i=Math.min((r?f.length:w.length)-1,i);const a=r?f[i]:w[i];let n=(e/Math.pow(r?1024:1e3,i)).toFixed(1);return t===!0&&i===0?(n!=="0.0"?"< 1 ":"0 ")+(r?f[1]:w[1]):(i<2?n=parseFloat(n).toFixed(0):n=parseFloat(n).toLocaleString(T.getCanonicalLocale()),n+" "+a)}var m=(e=>(e.DEFAULT="default",e.HIDDEN="hidden",e))(m||{});class U{_action;constructor(t){this.validateAction(t),this._action=t}get id(){return this._action.id}get displayName(){return this._action.displayName}get iconSvgInline(){return this._action.iconSvgInline}get enabled(){return this._action.enabled}get exec(){return this._action.exec}get execBatch(){return this._action.execBatch}get order(){return this._action.order}get default(){return this._action.default}get inline(){return this._action.inline}get renderInline(){return this._action.renderInline}validateAction(t){if(!t.id||typeof t.id!="string")throw new Error("Invalid id");if(!t.displayName||typeof t.displayName!="function")throw new Error("Invalid displayName function");if(!t.iconSvgInline||typeof t.iconSvgInline!="function")throw new Error("Invalid iconSvgInline function");if(!t.exec||typeof t.exec!="function")throw new Error("Invalid exec function");if("enabled"in t&&typeof t.enabled!="function")throw new Error("Invalid enabled function");if("execBatch"in t&&typeof t.execBatch!="function")throw new Error("Invalid execBatch function");if("order"in t&&typeof t.order!="number")throw new Error("Invalid order");if(t.default&&!Object.values(m).includes(t.default))throw new Error("Invalid default");if("inline"in t&&typeof t.inline!="function")throw new Error("Invalid inline function");if("renderInline"in t&&typeof t.renderInline!="function")throw new Error("Invalid renderInline function")}}const k=function(e){if(typeof window._nc_fileactions>"u"&&(window._nc_fileactions=[],s.debug("FileActions initialized")),window._nc_fileactions.find(t=>t.id===e.id)){s.error(`FileAction ${e.id} already registered`,{action:e});return}window._nc_fileactions.push(e)},H=function(){return typeof window._nc_fileactions>"u"&&(window._nc_fileactions=[],s.debug("FileActions initialized")),window._nc_fileactions};class O{_header;constructor(t){this.validateHeader(t),this._header=t}get id(){return this._header.id}get order(){return this._header.order}get enabled(){return this._header.enabled}get render(){return this._header.render}get updated(){return this._header.updated}validateHeader(t){if(!t.id||!t.render||!t.updated)throw new Error("Invalid header: id, render and updated are required");if(typeof t.id!="string")throw new Error("Invalid id property");if(t.enabled!==void 0&&typeof t.enabled!="function")throw new Error("Invalid enabled property");if(t.render&&typeof t.render!="function")throw new Error("Invalid render property");if(t.updated&&typeof t.updated!="function")throw new Error("Invalid updated property")}}const K=function(e){if(typeof window._nc_filelistheader>"u"&&(window._nc_filelistheader=[],s.debug("FileListHeaders initialized")),window._nc_filelistheader.find(t=>t.id===e.id)){s.error(`Header ${e.id} already registered`,{header:e});return}window._nc_filelistheader.push(e)},j=function(){return typeof window._nc_filelistheader>"u"&&(window._nc_filelistheader=[],s.debug("FileListHeaders initialized")),window._nc_filelistheader};var o=(e=>(e[e.NONE=0]="NONE",e[e.CREATE=4]="CREATE",e[e.READ=1]="READ",e[e.UPDATE=2]="UPDATE",e[e.DELETE=8]="DELETE",e[e.SHARE=16]="SHARE",e[e.ALL=31]="ALL",e))(o||{});const g=["d:getcontentlength","d:getcontenttype","d:getetag","d:getlastmodified","d:quota-available-bytes","d:resourcetype","nc:has-preview","nc:is-encrypted","nc:mount-type","nc:share-attributes","oc:comments-unread","oc:favorite","oc:fileid","oc:owner-display-name","oc:owner-id","oc:permissions","oc:share-types","oc:size","ocs:share-permissions"],_={d:"DAV:",nc:"http://nextcloud.org/ns",oc:"http://owncloud.org/ns",ocs:"http://open-collaboration-services.org/ns"},G=function(e,t={nc:"http://nextcloud.org/ns"}){typeof window._nc_dav_properties>"u"&&(window._nc_dav_properties=[...g],window._nc_dav_namespaces={..._});const r={...window._nc_dav_namespaces,...t};if(window._nc_dav_properties.find(a=>a===e))return s.error(`${e} already registered`,{prop:e}),!1;if(e.startsWith("<")||e.split(":").length!==2)return s.error(`${e} is not valid. See example: 'oc:fileid'`,{prop:e}),!1;const i=e.split(":")[0];return r[i]?(window._nc_dav_properties.push(e),window._nc_dav_namespaces=r,!0):(s.error(`${e} namespace unknown`,{prop:e,namespaces:r}),!1)},c=function(){return typeof window._nc_dav_properties>"u"&&(window._nc_dav_properties=[...g]),window._nc_dav_properties.map(e=>`<${e} />`).join(" ")},l=function(){return typeof window._nc_dav_namespaces>"u"&&(window._nc_dav_namespaces={..._}),Object.keys(window._nc_dav_namespaces).map(e=>`xmlns:${e}="${window._nc_dav_namespaces?.[e]}"`).join(" ")},W=function(){return`<?xml version="1.0"?>
|
|
2
|
+
<d:propfind ${l()}>
|
|
3
3
|
<d:prop>
|
|
4
|
-
${
|
|
4
|
+
${c()}
|
|
5
5
|
</d:prop>
|
|
6
|
-
</d:propfind>`},
|
|
7
|
-
<oc:filter-files ${
|
|
6
|
+
</d:propfind>`},D=function(){return`<?xml version="1.0"?>
|
|
7
|
+
<oc:filter-files ${l()}>
|
|
8
8
|
<d:prop>
|
|
9
|
-
${
|
|
9
|
+
${c()}
|
|
10
10
|
</d:prop>
|
|
11
11
|
<oc:filter-rules>
|
|
12
12
|
<oc:favorite>1</oc:favorite>
|
|
13
13
|
</oc:filter-rules>
|
|
14
|
-
</oc:filter-files>`},
|
|
15
|
-
<d:searchrequest ${
|
|
14
|
+
</oc:filter-files>`},J=function(e){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
15
|
+
<d:searchrequest ${l()}
|
|
16
16
|
xmlns:ns="https://github.com/icewind1991/SearchDAV/ns">
|
|
17
17
|
<d:basicsearch>
|
|
18
18
|
<d:select>
|
|
19
19
|
<d:prop>
|
|
20
|
-
${
|
|
20
|
+
${c()}
|
|
21
21
|
</d:prop>
|
|
22
22
|
</d:select>
|
|
23
23
|
<d:from>
|
|
24
24
|
<d:scope>
|
|
25
|
-
<d:href>/files/${
|
|
25
|
+
<d:href>/files/${u.getCurrentUser()?.uid}/</d:href>
|
|
26
26
|
<d:depth>infinity</d:depth>
|
|
27
27
|
</d:scope>
|
|
28
28
|
</d:from>
|
|
@@ -65,4 +65,4 @@
|
|
|
65
65
|
<ns:firstresult>0</ns:firstresult>
|
|
66
66
|
</d:limit>
|
|
67
67
|
</d:basicsearch>
|
|
68
|
-
</d:searchrequest>`},N=function(e=""){let t=o.NONE;return e&&((e.includes("C")||e.includes("K"))&&(t|=o.CREATE),e.includes("G")&&(t|=o.READ),(e.includes("W")||e.includes("N")||e.includes("V"))&&(t|=o.UPDATE),e.includes("D")&&(t|=o.DELETE),e.includes("R")&&(t|=o.SHARE)),t};var p=(e=>(e.Folder="folder",e.File="file",e))(p||{});const
|
|
68
|
+
</d:searchrequest>`},N=function(e=""){let t=o.NONE;return e&&((e.includes("C")||e.includes("K"))&&(t|=o.CREATE),e.includes("G")&&(t|=o.READ),(e.includes("W")||e.includes("N")||e.includes("V"))&&(t|=o.UPDATE),e.includes("D")&&(t|=o.DELETE),e.includes("R")&&(t|=o.SHARE)),t};var p=(e=>(e.Folder="folder",e.File="file",e))(p||{});const A=function(e,t){return e.match(t)!==null},I=(e,t)=>{if(e.id&&typeof e.id!="number")throw new Error("Invalid id type of value");if(!e.source)throw new Error("Missing mandatory source");try{new URL(e.source)}catch{throw new Error("Invalid source format, source must be a valid URL")}if(!e.source.startsWith("http"))throw new Error("Invalid source format, only http(s) is supported");if(e.mtime&&!(e.mtime instanceof Date))throw new Error("Invalid mtime type");if(e.crtime&&!(e.crtime instanceof Date))throw new Error("Invalid crtime type");if(!e.mime||typeof e.mime!="string"||!e.mime.match(/^[-\w.]+\/[-+\w.]+$/gi))throw new Error("Missing or invalid mandatory mime");if("size"in e&&typeof e.size!="number"&&e.size!==void 0)throw new Error("Invalid size type");if("permissions"in e&&e.permissions!==void 0&&!(typeof e.permissions=="number"&&e.permissions>=o.NONE&&e.permissions<=o.ALL))throw new Error("Invalid permissions");if(e.owner&&e.owner!==null&&typeof e.owner!="string")throw new Error("Invalid owner type");if(e.attributes&&typeof e.attributes!="object")throw new Error("Invalid attributes type");if(e.root&&typeof e.root!="string")throw new Error("Invalid root type");if(e.root&&!e.root.startsWith("/"))throw new Error("Root must start with a leading slash");if(e.root&&!e.source.includes(e.root))throw new Error("Root must be part of the source");if(e.root&&A(e.source,t)){const r=e.source.match(t)[0];if(!e.source.includes(d.join(r,e.root)))throw new Error("The root must be relative to the service. e.g /files/emma")}};class v{_data;_attributes;_knownDavService=/(remote|public)\.php\/(web)?dav/i;constructor(t,r){I(t,r||this._knownDavService),this._data=t;const i={set:(a,n,V)=>(this.updateMtime(),Reflect.set(a,n,V)),deleteProperty:(a,n)=>(this.updateMtime(),Reflect.deleteProperty(a,n))};this._attributes=new Proxy(t.attributes||{},i),delete this._data.attributes,r&&(this._knownDavService=r)}get source(){return this._data.source.replace(/\/$/i,"")}get basename(){return d.basename(this.source)}get extension(){return d.extname(this.source)}get dirname(){if(this.root){const r=this.source.indexOf(this.root);return d.dirname(this.source.slice(r+this.root.length)||"/")}const t=new URL(this.source);return d.dirname(t.pathname)}get mime(){return this._data.mime}get mtime(){return this._data.mtime}get crtime(){return this._data.crtime}get size(){return this._data.size}get attributes(){return this._attributes}get permissions(){return this.owner===null&&!this.isDavRessource?o.READ:this._data.permissions!==void 0?this._data.permissions:o.NONE}get owner(){return this.isDavRessource?this._data.owner:null}get isDavRessource(){return A(this.source,this._knownDavService)}get root(){return this._data.root?this._data.root.replace(/^(.+)\/$/,"$1"):this.isDavRessource&&d.dirname(this.source).split(this._knownDavService).pop()||null}get path(){if(this.root){const t=this.source.indexOf(this.root);return this.source.slice(t+this.root.length)||"/"}return(this.dirname+"/"+this.basename).replace(/\/\//g,"/")}get fileid(){return this._data?.id||this.attributes?.fileid}move(t){I({...this._data,source:t},this._knownDavService),this._data.source=t,this.updateMtime()}rename(t){if(t.includes("/"))throw new Error("Invalid basename");this.move(d.dirname(this.source)+"/"+t)}updateMtime(){this._data.mtime&&(this._data.mtime=new Date)}}class R extends v{get type(){return p.File}}class F extends v{constructor(t){super({...t,mime:"httpd/unix-directory"})}get type(){return p.Folder}get extension(){return null}get mime(){return"httpd/unix-directory"}}const y=`/files/${u.getCurrentUser()?.uid}`,S=x.generateRemoteUrl("dav"),Q=function(e=S){const t=b.createClient(e,{headers:{requesttoken:u.getRequestToken()||""}});return b.getPatcher().patch("request",r=>(r.headers?.method&&(r.method=r.headers.method,delete r.headers.method),L.request(r))),t},X=async(e,t="/",r=y)=>(await e.getDirectoryContents(`${r}${t}`,{details:!0,data:D(),headers:{method:"REPORT"},includeSelf:!0})).data.filter(i=>i.filename!==t).map(i=>q(i,r)),q=function(e,t=y){const r=e.props,i=N(r?.permissions),a=u.getCurrentUser()?.uid,n={id:r?.fileid||0,source:x.generateRemoteUrl(`dav${t}${e.filename}`),mtime:new Date(Date.parse(e.lastmod)),mime:e.mime,size:r?.size||Number.parseInt(r.getcontentlength||"0"),permissions:i,owner:a,root:t,attributes:{...e,...r,hasPreview:r?.["has-preview"]}};return delete n.attributes?.props,e.type==="file"?new R(n):new F(n)};class C{_views=[];_currentView=null;register(t){if(this._views.find(r=>r.id===t.id))throw new Error(`View id ${t.id} is already registered`);this._views.push(t)}remove(t){const r=this._views.findIndex(i=>i.id===t);r!==-1&&this._views.splice(r,1)}get views(){return this._views}setActive(t){this._currentView=t}get active(){return this._currentView}}const Y=function(){return typeof window._nc_navigation>"u"&&(window._nc_navigation=new C,s.debug("Navigation service initialized")),window._nc_navigation};class ${_column;constructor(t){Z(t),this._column=t}get id(){return this._column.id}get title(){return this._column.title}get render(){return this._column.render}get sort(){return this._column.sort}get summary(){return this._column.summary}}const Z=function(e){if(!e.id||typeof e.id!="string")throw new Error("A column id is required");if(!e.title||typeof e.title!="string")throw new Error("A column title is required");if(!e.render||typeof e.render!="function")throw new Error("A render function is required");if(e.sort&&typeof e.sort!="function")throw new Error("Column sortFunction must be a function");if(e.summary&&typeof e.summary!="function")throw new Error("Column summary must be a function");return!0};class ee{_view;constructor(t){te(t),this._view=t}get id(){return this._view.id}get name(){return this._view.name}get caption(){return this._view.caption}get emptyTitle(){return this._view.emptyTitle}get emptyCaption(){return this._view.emptyCaption}get getContents(){return this._view.getContents}get icon(){return this._view.icon}get order(){return this._view.order}get params(){return this._view.params}get columns(){return this._view.columns}get emptyView(){return this._view.emptyView}get parent(){return this._view.parent}get sticky(){return this._view.sticky}get expanded(){return this._view.expanded}get defaultSortKey(){return this._view.defaultSortKey}}const te=function(e){if(!e.id||typeof e.id!="string")throw new Error("View id is required and must be a string");if(!e.name||typeof e.name!="string")throw new Error("View name is required and must be a string");if(e.columns&&e.columns.length>0&&(!e.caption||typeof e.caption!="string"))throw new Error("View caption is required for top-level views and must be a string");if(!e.getContents||typeof e.getContents!="function")throw new Error("View getContents is required and must be a function");if(!e.icon||typeof e.icon!="string"||!P(e.icon))throw new Error("View icon is required and must be a valid svg string");if(!("order"in e)||typeof e.order!="number")throw new Error("View order is required and must be a number");if(e.columns&&e.columns.forEach(t=>{if(!(t instanceof $))throw new Error("View columns must be an array of Column. Invalid column found")}),e.emptyView&&typeof e.emptyView!="function")throw new Error("View emptyView must be a function");if(e.parent&&typeof e.parent!="string")throw new Error("View parent must be a string");if("sticky"in e&&typeof e.sticky!="boolean")throw new Error("View sticky must be a boolean");if("expanded"in e&&typeof e.expanded!="boolean")throw new Error("View expanded must be a boolean");if(e.defaultSortKey&&typeof e.defaultSortKey!="string")throw new Error("View defaultSortKey must be a string");return!0},re=function(e){return h().registerEntry(e)},ie=function(e){return h().unregisterEntry(e)},ne=function(e){return h().getEntries(e)};exports.Column=$,exports.DefaultType=m,exports.File=R,exports.FileAction=U,exports.FileType=p,exports.Folder=F,exports.Header=O,exports.Navigation=C,exports.Node=v,exports.Permission=o,exports.View=ee,exports.addNewFileMenuEntry=re,exports.davGetClient=Q,exports.davGetDefaultPropfind=W,exports.davGetFavoritesReport=D,exports.davGetRecentSearch=J,exports.davParsePermissions=N,exports.davRemoteURL=S,exports.davResultToNode=q,exports.davRootPath=y,exports.defaultDavNamespaces=_,exports.defaultDavProperties=g,exports.formatFileSize=z,exports.getDavNameSpaces=l,exports.getDavProperties=c,exports.getFavoriteNodes=X,exports.getFileActions=H,exports.getFileListHeaders=j,exports.getNavigation=Y,exports.getNewFileMenuEntries=ne,exports.registerDavProperty=G,exports.registerFileAction=k,exports.registerFileListHeaders=K,exports.removeNewFileMenuEntry=ie;
|