Files
nextcloud-server-mirror/dist/files_sharing-init-public.mjs
2026-10-07 08:58:40 +00:00

28 lines
17 KiB
JavaScript

const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=[window.OC.filePath('', '', 'dist/DialogConfirmFileHidden-D6TnkPLU.chunk.mjs'),window.OC.filePath('', '', 'dist/index-UXL_i2di.chunk.mjs'),window.OC.filePath('', '', 'dist/star-outline-BpDZzOb8.chunk.mjs'),window.OC.filePath('', '', 'dist/AlertCircleOutline-jA3ki2Uu.chunk.mjs'),window.OC.filePath('', '', 'dist/TrayArrowDown-vMg8Cl05.chunk.mjs'),window.OC.filePath('', '', 'dist/PencilOutline-C4ZkKkas.chunk.mjs'),window.OC.filePath('', '', 'dist/translations-pLZlvQeM.chunk.mjs'),window.OC.filePath('', '', 'dist/Web-BMG0zIln.chunk.mjs'),window.OC.filePath('', '', 'dist/_l10n-CK24vgHE.chunk.mjs'),window.OC.filePath('', '', 'dist/File-xDTWu8L0.chunk.mjs'),window.OC.filePath('', '', 'dist/Link-CUdpEe-t.chunk.mjs'),window.OC.filePath('', '', 'dist/formatRelative-uuSCBZ1C.chunk.mjs'),window.OC.filePath('', '', 'dist/common-Link-3plNpBrB.chunk.css'),window.OC.filePath('', '', 'dist/ArrowRight-COu6qSN5.chunk.mjs'),window.OC.filePath('', '', 'dist/common-ArrowRight-C_oBIsvc.chunk.css'),window.OC.filePath('', '', 'dist/Check-CEU1oy_I.chunk.mjs'),window.OC.filePath('', '', 'dist/common-Check-BYHcrfvW.chunk.css'),window.OC.filePath('', '', 'dist/NcModal-BxLzaUZK.chunk.mjs'),window.OC.filePath('', '', 'dist/MapMarkerOutline-Ip3bQdll.chunk.mjs'),window.OC.filePath('', '', 'dist/livePhotoUtils-CVUhgL4S.chunk.mjs'),window.OC.filePath('', '', 'dist/index-D6fZh9CR.chunk.mjs'),window.OC.filePath('', '', 'dist/common-NcModal-Cclh_O_-.chunk.css'),window.OC.filePath('', '', 'dist/common-AlertCircleOutline-B7Bbzm8f.chunk.css'),window.OC.filePath('', '', 'dist/cancel-DDzvQ-HX.chunk.mjs'),window.OC.filePath('', '', 'dist/common-cancel-BWNFKLbC.chunk.css'),window.OC.filePath('', '', 'dist/index-D_oRcFiB.chunk.mjs'),window.OC.filePath('', '', 'dist/externalStorageUtils-mlnj1LcU.chunk.mjs'),window.OC.filePath('', '', 'dist/NcUploadPicker-Cla8uJJV.chunk.mjs'),window.OC.filePath('', '', 'dist/index-DHyMMYTN.chunk.mjs'),window.OC.filePath('', '', 'dist/index-GqSDnl3c.chunk.mjs'),window.OC.filePath('', '', 'dist/dav-BNCa0U-Z.chunk.mjs'),window.OC.filePath('', '', 'dist/NcActionButton-BvGszxyz.chunk.mjs'),window.OC.filePath('', '', 'dist/common-NcActionButton-BQBDvDX2.chunk.css'),window.OC.filePath('', '', 'dist/index-DKxdOjOX.chunk.mjs'),window.OC.filePath('', '', 'dist/common-index-DExoDmi9.chunk.css'),window.OC.filePath('', '', 'dist/NcProgressBar-Dixhlp8F.chunk.mjs'),window.OC.filePath('', '', 'dist/common-NcProgressBar-DiAmXTz0.chunk.css'),window.OC.filePath('', '', 'dist/common-NcUploadPicker-fC_XTit7.chunk.css'),window.OC.filePath('', '', 'dist/Folder-BcToKSIM.chunk.mjs'),window.OC.filePath('', '', 'dist/NcAppContent-WuNJWVSm.chunk.mjs'),window.OC.filePath('', '', 'dist/common-NcAppContent-Cl3uhtpo.chunk.css'),window.OC.filePath('', '', 'dist/MenuUp-DiApqAR0.chunk.mjs'),window.OC.filePath('', '', 'dist/common-MenuUp-Don1d5Bd.chunk.css'),window.OC.filePath('', '', 'dist/information-outline-CUvhpCqf.chunk.mjs'),window.OC.filePath('', '', 'dist/NcActionLink-DvEArNRM.chunk.mjs'),window.OC.filePath('', '', 'dist/common-NcActionLink-iJnZg6ii.chunk.css'),window.OC.filePath('', '', 'dist/NcActionRouter-X9XmAaxE.chunk.mjs'),window.OC.filePath('', '', 'dist/common-NcActionRouter-C1KErZDl.chunk.css'),window.OC.filePath('', '', 'dist/common-information-outline-cz7E3Mo9.chunk.css'),window.OC.filePath('', '', 'dist/NcHighlight.vue_vue_type_script_lang-CT7Xx-zK.chunk.mjs'),window.OC.filePath('', '', 'dist/NcInputField-wKF2DDSn.chunk.mjs'),window.OC.filePath('', '', 'dist/common-NcInputField-B5YBBomo.chunk.css'),window.OC.filePath('', '', 'dist/star-Dwot5QHD.chunk.mjs'),window.OC.filePath('', '', 'dist/common-star-pXJ_-D_I.chunk.css'),window.OC.filePath('', '', 'dist/NcCheckboxRadioSwitch-BgZXg73g.chunk.mjs'),window.OC.filePath('', '', 'dist/common-NcCheckboxRadioSwitch-BAaFbykd.chunk.css'),window.OC.filePath('', '', 'dist/NcAvatar-RT0QIft7.chunk.mjs'),window.OC.filePath('', '', 'dist/autolink-D1sObkXs.chunk.mjs'),window.OC.filePath('', '', 'dist/common-autolink-B8CEsDGb.chunk.css'),window.OC.filePath('', '', 'dist/colors-B1T-jIOW.chunk.mjs'),window.OC.filePath('', '', 'dist/NcUserStatusIcon-CWV4DI9J.chunk.mjs'),window.OC.filePath('', '', 'dist/common-NcUserStatusIcon-Bq_6hmXG.chunk.css'),window.OC.filePath('', '', 'dist/NcActionText-BWO7oBCL.chunk.mjs'),window.OC.filePath('', '', 'dist/common-NcActionText-BzbAkUEn.chunk.css'),window.OC.filePath('', '', 'dist/common-NcAvatar-o8Woel4F.chunk.css'),window.OC.filePath('', '', 'dist/NcChip-cyGdYKyD.chunk.mjs'),window.OC.filePath('', '', 'dist/common-NcChip-Som-mR4B.chunk.css'),window.OC.filePath('', '', 'dist/index-DJ32j2fv.chunk.mjs'),window.OC.filePath('', '', 'dist/common-DialogConfirmFileHidden-BI09HyuN.chunk.css'),window.OC.filePath('', '', 'dist/FilesViewFileDropEmptyContent-CTBQ_08j.chunk.mjs'),window.OC.filePath('', '', 'dist/files_sharing-FilesViewFileDropEmptyContent-D6QtpXU-.chunk.css')])))=>i.map(i=>d[i]);
import{s as f,e as B,u as oe}from"./index-D6fZh9CR.chunk.mjs";import{V as L,c as g}from"./index-D_oRcFiB.chunk.mjs";import{l as _,a as se,_ as M,b as ae}from"./star-outline-BpDZzOb8.chunk.mjs";import{g as U,a as j,h as V}from"./livePhotoUtils-CVUhgL4S.chunk.mjs";import{c as ne,a as de,s as le,d as ue}from"./File-xDTWu8L0.chunk.mjs";import{a8 as ce,a9 as fe,a as he,S as R,C as F,Z as H,q as y,c as pe,u as ge}from"./PencilOutline-C4ZkKkas.chunk.mjs";import{i as O,f as ve,c as T,a as w,r as b,g as me,b as I,d as we,e as ye}from"./dav-BNCa0U-Z.chunk.mjs";import{t as v,e as be}from"./translations-pLZlvQeM.chunk.mjs";import{b as A,P as $,F as q,a as _e}from"./externalStorageUtils-mlnj1LcU.chunk.mjs";import{a as Z}from"./Folder-BcToKSIM.chunk.mjs";const C=U().setApp("files_sharing").detectUser().build(),Pe=_("files_sharing","view"),Ce=_("files_sharing","sharingToken"),Ne=()=>M(()=>import("./DialogConfirmFileHidden-D6TnkPLU.chunk.mjs").then(t=>t.F),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68]),import.meta.url);function Re(t){return le(t).replace(/\+/g,"%20")}const E=ne({history:de(se("/s")),linkActiveClass:"active",stringifyQuery:Re,routes:[{path:"/",redirect:{name:"filelist",params:{view:Pe,token:Ce}}},{path:"/:token/:fileid?",name:"filelist",component:Ne,props:{isPublic:!0}}]});E.onError(t=>{if(ce(t,fe.aborted))C.debug("Navigation was aborted",{error:t});else throw t});const qe='<svg xmlns="http://www.w3.org/2000/svg" id="mdi-cloud-upload" viewBox="0 0 24 24"><path d="M11 20H6.5Q4.22 20 2.61 18.43 1 16.85 1 14.58 1 12.63 2.17 11.1 3.35 9.57 5.25 9.15 5.88 6.85 7.75 5.43 9.63 4 12 4 14.93 4 16.96 6.04 19 8.07 19 11 20.73 11.2 21.86 12.5 23 13.78 23 15.5 23 17.38 21.69 18.69 20.38 20 18.5 20H13V12.85L14.6 14.4L16 13L12 9L8 13L9.4 14.4L11 12.85Z" /></svg>',Fe=()=>{const t=_("files_sharing","filename");let i;const r=new L({id:"public-file-drop",name:v("files_sharing","File drop"),caption:v("files_sharing","Upload files to {foldername}",{foldername:t}),icon:qe,order:1,emptyView:async e=>{const{default:a}=await M(async()=>{const{default:n}=await import("./FilesViewFileDropEmptyContent-CTBQ_08j.chunk.mjs");return{default:n}},__vite__mapDeps([69,27,5,2,11,1,3,4,6,7,8,9,10,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,28,29,30,31,32,33,34,35,36,37,41,42,70]),import.meta.url);i?.unmount(),i=he(a,{foldername:t}),i.mount(e)},getContents:async()=>({contents:[],folder:new A({id:0,source:`${ve}${O}`,root:O,owner:null,permissions:$.CREATE})})});g().register(r)},z='<svg xmlns="http://www.w3.org/2000/svg" id="mdi-link" viewBox="0 0 24 24"><path d="M3.9,12C3.9,10.29 5.29,8.9 7,8.9H11V7H7A5,5 0 0,0 2,12A5,5 0 0,0 7,17H11V15.1H7C5.29,15.1 3.9,13.71 3.9,12M8,13H16V11H8V13M17,7H13V8.9H17C18.71,8.9 20.1,10.29 20.1,12C20.1,13.71 18.71,15.1 17,15.1H13V17H17A5,5 0 0,0 22,12A5,5 0 0,0 17,7Z" /></svg>',N=me();async function S(t){const i=T(),r=await N.stat(`${w()}${t}`,{details:!0,data:i});return b(r.data)}const Oe=()=>{const t=new L({id:"public-file-share",name:v("files_sharing","Public file share"),caption:v("files_sharing","Publicly shared file."),emptyTitle:v("files_sharing","No file"),emptyCaption:v("files_sharing","The file shared with you will show up here"),icon:z,order:1,getContents:async(i,{signal:r})=>{try{const e=await N.stat(w(),{data:T(),details:!0,signal:r});return{contents:[b(e.data)],folder:new A({id:0,source:`${I()}${w()}`,root:w(),owner:null,permissions:$.READ,attributes:{note:e.data.props?.note}})}}catch(e){throw r.aborted?(C.info("Fetching contents for public file share was aborted",{error:e}),new DOMException("Aborted","AbortError")):(C.error("Failed to get contents for public file share",{error:e}),e)}}});g().register(t)},u=U().setApp("files").detectUser().build(),Le=new A({id:0,source:I()+w(),root:w(),owner:j()?.uid||null,permissions:$.NONE}),Te=R("active",()=>{const t=H(),i=y(),r=H(),e=y(Le);F(i,()=>{i.value?.id&&i.value.id!==String(window.OCP.Files.Router.params?.fileid??"")&&(u.debug("Updating active fileid in URL query",{fileid:i.value.id}),window.OCP.Files.Router.goToRoute(null,{...window.OCP.Files.Router.params,fileid:i.value.id},{...window.OCP.Files.Router.query},!0))}),o();function a(l){i.value&&i.value.source===l.source&&(i.value=void 0)}function n(l=null){u.debug("Setting active view",{view:l}),r.value=l??void 0,i.value=void 0}function o(){const l=g();n(l.active),f("files:node:deleted",a),l.addEventListener("updateActive",p=>{n(p.detail)})}return{activeAction:t,activeFolder:e,activeNode:i,activeView:r}});function Ae(...t){const i=Q(...t),r=R("paths",{state:()=>({paths:{}}),getters:{getPath:e=>(a,n)=>{if(e.paths[a])return e.paths[a][n]}},actions:{addPath(e){this.paths[e.service]||(this.paths[e.service]={}),this.paths[e.service][e.path]=e.source},deletePath(e,a){this.paths[e]&&delete this.paths[e][a]},onCreatedNode(e){const a=g()?.active?.id||"files";if(!e.fileid){u.error("Node has no fileid",{node:e});return}e.type===q.Folder&&this.addPath({service:a,path:e.path,source:e.source}),this.addNodeToParentChildren(e)},onDeletedNode(e){const a=g()?.active?.id||"files";e.type===q.Folder&&this.deletePath(a,e.path),this.deleteNodeFromParentChildren(e)},onMovedNode({node:e,oldSource:a}){const n=g()?.active?.id||"files";if(e.type===q.Folder){const l=Object.entries(this.paths[n]).find(([,p])=>p===a);l?.[0]&&this.deletePath(n,l[0]),this.addPath({service:n,path:e.path,source:e.source})}const o=new _e({source:a,owner:e.owner,mime:e.mime,root:e.root});this.deleteNodeFromParentChildren(o),this.addNodeToParentChildren(e)},deleteNodeFromParentChildren(e){const a=g()?.active?.id||"files",n=V(e.source),o=e.dirname==="/"?i.getRoot(a):i.getNode(n);if(o){const l=new Set(o._children??[]);l.delete(e.source),o._children=[...l.values()],u.debug("Children updated",{parent:o,node:e,children:o._children});return}u.debug("Parent path does not exists, skipping children update",{node:e})},addNodeToParentChildren(e){const a=g()?.active?.id||"files",n=V(e.source),o=e.dirname==="/"?i.getRoot(a):i.getNode(n);if(o){const l=new Set(o._children??[]);l.add(e.source),o._children=[...l.values()],u.debug("Children updated",{parent:o,node:e,children:o._children});return}u.debug("Parent path does not exists, skipping children update",{node:e})}}})(...t);return r._initialized||(f("files:node:created",r.onCreatedNode),f("files:node:deleted",r.onDeletedNode),f("files:node:moved",r.onMovedNode),r._initialized=!0),r}const Q=R("files",()=>{const t=y({}),i=y({});K();function r(s){return t.value[s]}function e(s){return s.map(d=>t.value[d]).filter(Boolean)}function a(s){return Object.values(t.value).filter(d=>d.id===s)}function n(s){return i.value[s]}function o(s,d){const c=Ae();let h;if(!d||d==="/")h=n(s);else{const m=c.getPath(s,d);m&&(h=r(m))}return h}function l(s,d){return(o(s,d)?._children??[]).map(c=>r(c)).filter(Boolean)}function p(s){const d=s.reduce((h,m)=>t.value[m.source]?.id&&!m.id?(u.error("Trying to update/set a node without id",{node:m}),h):(h[m.source]=m,h),{});t.value={...t.value,...d};const c=Te();c.activeNode&&c.activeNode.source in d&&(c.activeNode=t.value[c.activeNode.source])}function k(s){const d=Object.entries(t.value).filter(([,c])=>!s.some(h=>h.source===c.source));t.value=Object.fromEntries(d)}function G({service:s,root:d}){i.value={...i.value,[s]:d}}return{files:t,roots:i,deleteNodes:k,getDirectoryByPath:o,getNode:r,getNodes:e,getNodesById:a,getNodesByPath:l,getRoot:n,setRoot:G,updateNodes:p};function K(){f("files:node:created",Y),f("files:node:deleted",X),f("files:node:updated",te),f("files:node:moved",ee),f("files:favorites:added",ie),f("files:favorites:removed",re)}function X(s){k([s])}function Y(s){p([s])}function ee({node:s,oldSource:d}){delete t.value[d],p([s])}async function te(s){const d=s.id?a(s.id):e([s.source]);if(d.length>1){await Promise.all(d.map(h=>S(h.path))).then(p),u.debug(d.length+" nodes updated in store",{fileid:s.id,source:s.source});return}if(d.length===1&&s.source===d[0].source){p([s]);return}const c=await S(s.path);p([c])}function ie(s){const d=r(s.source);d&&(d.attributes.favorite=1)}function re(s){const d=r(s.source);d&&(d.attributes.favorite=0)}}),J=pe();async function $e(t,{dir:i,signal:r}){const e=j();if(!e)return[];if(t=t.trim(),t.length<3)return[];i&&!i.startsWith("/")&&(i=`/${i}`),u.debug("Searching for nodes",{query:t,dir:i});const{data:a}=await N.search("/",{details:!0,signal:r,data:`
<d:searchrequest ${we()}>
<d:basicsearch>
<d:select>
<d:prop>
${ye()}
</d:prop>
</d:select>
<d:from>
<d:scope>
<d:href>/files/${e.uid}${i?be(i):""}</d:href>
<d:depth>infinity</d:depth>
</d:scope>
</d:from>
<d:where>
<d:like>
<d:prop>
<d:displayname/>
</d:prop>
<d:literal>%${t.replace("%","")}%</d:literal>
</d:like>
</d:where>
<d:orderby/>
</d:basicsearch>
</d:searchrequest>`});return r?.aborted?[]:a.results.map(n=>b(n,O,ae()))}const P="search",Ee=R("search",()=>{const t=y(""),i=y("filter");F(i,e),F(t,(o,l)=>{o.trim()!==l.trim()&&e()}),n();const r=ue(o=>{window.OCP.Files.Router.goToRoute(void 0,{view:P},{query:t.value},o)});function e(){B("files:search:updated",{query:t.value,scope:i.value});const o=window.OCP.Files.Router;if(o.params.view===P&&(t.value===""||i.value==="filter"))return i.value="filter",o.goToRoute(void 0,{view:"files"},{...o.query,query:void 0});if(i.value==="filter"||!t.value)return;const l=o.params.view===P;u.debug("Update route for updated search query",{query:t.value,isSearch:l}),r(l)}function a(o){o.id!==P&&(t.value="",i.value="filter")}function n(){f("files:navigation:changed",a);const o=window.OCP.Files.Router;o.params.view===P&&(t.value=[o.query.query].flat()[0]??"",t.value?(i.value="globally",u.debug("Directly navigated to search view",{query:t.value})):(u.info("Directly navigated to search view without any query, redirect to files view."),o.goToRoute(void 0,{...o.params,view:"files"},{...o.query,query:void 0},!0)))}return{query:t,scope:i}});async function ke(t="/",i){const r=Ee(J);return r.query.length<3?await Ve(t,i):await He(t,r.query,i?.signal)}async function Ve(t,i){t=Z.join(w(),t);const r=T(),e=await N.getDirectoryContents(t,{details:!0,data:r,includeSelf:!0,signal:i?.signal}),a=e.data[0],n=e.data.slice(1);if(a?.filename!==t&&`${a?.filename}/`!==t)throw u.debug(`Exepected "${t}" but got filename "${a.filename}" instead.`),new Error("Root node does not match requested path");return{folder:b(a),contents:n.map(o=>{try{return b(o)}catch(l){return u.error(`Invalid node detected '${o.basename}'`,{error:l}),null}}).filter(Boolean)}}async function He(t,i,r){let e=Q(J).getDirectoryByPath("files",t);if(!e){const n=Z.join(w(),t),o=await N.stat(n,{details:!0});e=b(o.data)}const a=await $e(i,{dir:t,signal:r});return{folder:e,contents:a}}const Se=()=>{const t=new L({id:"public-share",name:v("files_sharing","Public share"),caption:v("files_sharing","Publicly shared files."),emptyTitle:v("files_sharing","No files"),emptyCaption:v("files_sharing","Files and folders shared with you will show up here"),icon:z,order:1,getContents:ke});g().register(t)};class De{router;pendingLocation;constructor(i){this.router=i}get route(){return ge(this.router.currentRoute)}get name(){return this.pendingLocation?.name??this.route.name}get query(){return this.pendingLocation?.query??this.route.query??{}}get params(){return this.pendingLocation?.params??this.route.params??{}}get _router(){return this.router}goTo(i,r=!1){return this.pendingLocation=void 0,this.router.push({path:i,replace:r})}goToRoute(i,r,e,a){i??=this.name;const n={name:i,query:e,params:r};return this.pendingLocation=n,(a?this._router.replace(n):this._router.push(n)).finally(()=>{this.pendingLocation===n&&(this.pendingLocation=void 0)})}}Fe(),Se(),Oe();const xe=_("files_sharing","view"),D=g();try{D.setActive(xe)}catch{D.setActive(null)}window.OCP.Files=window.OCP.Files??{},window.OCP.Files.Router=new De(E);const x=_("files_sharing","fileId",null),Be=_("files_sharing","sharingToken");x!==null&&E.isReady().then(()=>window.OCP.Files.Router.goToRoute("filelist",{...window.OCP.Files.Router.params,token:Be,fileid:String(x)},{...window.OCP.Files.Router.query,openfile:"true"})).catch(t=>C.error("Could not open the shared file",{error:t})),f("files:list:updated",W);function W({folder:t}){if(oe("files:list:updated",W),t.attributes["share-attributes"]){const i=JSON.parse(t.attributes["share-attributes"]||"[]").find(({scope:r,key:e})=>r==="config"&&e==="grid_view");i!==void 0&&(C.debug("Loading share attributes",{gridViewAttribute:i}),B("files:config:updated",{key:"grid_view",value:i.value===!0}))}}export{Q as a,Ae as b,Ee as c,S as f,ke as g,u as l,J as p,Te as u};
//# sourceMappingURL=files_sharing-init-public.mjs.map