vzcode 0.72.0 → 0.74.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/assets/index-BaaNjNJK.js +147 -0
- package/dist/assets/{index-CpIQ8AoQ.css → index-Buql6gU0.css} +1 -1
- package/dist/assets/worker-BCgDdjKY.js +400 -0
- package/dist/assets/{worker-DoodSOTA.js → worker-Cy8ajBgn.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +13 -13
- package/src/client/VZCodeContext.tsx +8 -1
- package/src/client/VZSidebar/DirectoryListing.tsx +13 -4
- package/src/client/VZSidebar/DragAndDrop.tsx +74 -0
- package/src/client/VZSidebar/Item.tsx +19 -13
- package/src/client/VZSidebar/Listing.tsx +7 -0
- package/src/client/VZSidebar/index.tsx +10 -1
- package/src/client/VZSidebar/styles.scss +22 -1
- package/src/client/useFileCRUD.ts +44 -3
- package/src/client/useTypeScript/worker.ts +55 -40
- package/dist/assets/index-BfS1mzJK.js +0 -147
- package/dist/assets/worker-CH5jA9Si.js +0 -400
|
@@ -276,7 +276,7 @@ Did you specify these with the most recent transformation maps first?`);let I=C(
|
|
|
276
276
|
`)+1)),R1(o)&&(o=o.substring(0,o.lastIndexOf(`
|
|
277
277
|
`)),o.charAt(o.length-1)==="\r"&&(o=o.substring(0,o.length-1)))),o}function Jqe(e){return e.type==="Text"}function zqe(e,r){var n;const a=((n=r.attributes)!==null&&n!==void 0?n:[]).find(o=>o.name===e);return a&&a.value}function g9(e,r){const n=zqe(e,r);if(n!=null&&typeof n=="object"){const i=n.find(Jqe);if(i)return i.data}return null}function sh(e){const r=g9("lang",e)||g9("type",e);return r!=null?r.replace(/^text\//,""):null}function sG(e){const r=sh(e);return!(r&&jqe.includes(r))}function Hqe(e){const r=sh(e)||"";return["typescript","ts"].includes(r)}function Vqe(e){const r=sh(e)||"";return r.endsWith("json")||r.endsWith("importmap")}function Wqe(e){const r=sh(e)||"";return["less"].includes(r)}function Kqe(e){const r=sh(e)||"";return["sass","scss"].includes(r)}function Gqe(e){return e.type==="Element"&&e.name==="template"&&sh(e)==="pug"}function fT(e){return e!==!0&&e.length===1&&e[0].type==="MustacheTag"}function Xqe(e){return e!==!0&&e.length===1&&e[0].type==="AttributeShorthand"}function oG(e){if(Xqe(e.value))return!0;if(fT(e.value)){const r=e.value[0].expression;return r.type==="Identifier"&&r.name===e.name}return!1}function zs(e){return e.raw||e.data}function O1(e,r=1){return e.type==="Text"&&B1(zs(e),r)}function B1(e,r=1){return new RegExp(`^([\\t\\f\\r ]*\\n){${r}}`).test(e)}function b9(e,r=1){return e.type==="Text"&&R1(zs(e),r)}function R1(e,r=1){return new RegExp(`(\\n[\\t\\f\\r ]*){${r}}$`).test(e)}function L1(e){return e.type==="Text"&&/^\s/.test(zs(e))}function oh(e){return e.type==="Text"&&/\s$/.test(zs(e))}function M1(e){e.raw=e.raw&&e.raw.trimRight(),e.data=e.data&&e.data.trimRight()}function $1(e){e.raw=e.raw&&e.raw.trimLeft(),e.data=e.data&&e.data.trimLeft()}function Yqe(e,r){let n=e.findIndex(a=>!da(a)&&!N1(a,r));n=n===-1?e.length-1:n;let i=ZK((a,o)=>!da(a)&&(o===e.length-1&&a.type!=="Comment"||!N1(a,r)),e);i=i===-1?0:i;for(let a=0;a<=n;a++){const o=e[a];o.type==="Text"&&$1(o)}for(let a=e.length-1;a>=i;a--){const o=e[a];o.type==="Text"&&M1(o)}}function Qqe(e,r,n){if(!r)return!0;if(hu(e,n)||!P1(e))return!1;const i=e.children;if(i.length===0)return!0;if(n.htmlWhitespaceSensitivity==="ignore")return!1;const a=i[0];return!L1(a)}function Zqe(e,r,n){if(!r)return!0;if(hu(e,n)||!P1(e))return!1;const i=e.children;if(i.length===0)return!0;if(n.htmlWhitespaceSensitivity==="ignore")return!1;const a=i[i.length-1];return!oh(a)}function eUe(e,r){if(!nG(e)||!P1(e))return"none";const n=e.children;if(n.length===0)return"none";const i=n[0];if(O1(i))return"line";if(L1(i))return"space";const a=r.originalText.lastIndexOf("}",i.start);if(a>0&&i.start>a+1){const o=r.originalText.substring(a+1,i.start);if(o.trim()==="")return B1(o)?"line":"space"}return"none"}function tUe(e,r){if(!nG(e)||!P1(e))return"none";const n=e.children;if(n.length===0)return"none";const i=n[n.length-1];if(b9(i))return"line";if(oh(i))return"space";const a=r.originalText.indexOf("{",i.end);if(a>0&&i.end<a){const o=r.originalText.substring(i.end,a);if(o.trim()==="")return R1(o)?"line":"space"}return"none"}function rUe(e,r){return e.stack.some(i=>i.type==="Attribute"&&(!fT(i.value)||r.svelteStrictMode))}function uG(e,r,n){return pT(n)&&(!nUe(e,n)||iUe(r,n))}function nUe(e,r){return e.end===r.originalText.length?!1:!r.originalText.substring(e.end).match(/^\s/)}function iUe(e,r){const n=e.getParentNode();if(!n||!hu(n,r))return!1;const i=_T(n);return i[i.length-1]===e.getNode()}function aUe(e){e.module&&(e.module.comments=v9(e,e.module)),e.instance&&(e.instance.comments=v9(e,e.instance)),e.css&&(e.css.comments=v9(e,e.css))}function v9(e,r){const n=_T(e.html),i=[],a=[];if(!n.length)return[];let o=r,u=n.find(c=>c.end===o.start);for(;u;){if(u.type==="Comment"&&!dT(u)&&!I1(u))i.push(u),i.length!==a.length&&a.push({type:"Text",data:"",raw:"",start:-1,end:-1});else if(da(u))a.push(u);else break;o=u,u=n.find(c=>c.end===o.start)}a.length=i.length;for(const c of i)n.splice(n.indexOf(c),1);for(const c of a)n.splice(n.indexOf(c),1);return i.map((c,b)=>({comment:c,emptyLineAfter:zs(a[b]).split(`
|
|
278
278
|
`).length>2})).reverse()}const{join:uh,line:Hs,group:Br,indent:mu,dedent:j1,softline:ol,hardline:Oi,fill:sUe,breakParent:q1,literalline:x9}=t_.builders;function D9(e){return/^\s*<!--\s*@(format|prettier)\W/.test(e)}let U1=!1,hT=!1,lh;function oUe(e,r,n){var i,a;const o=pT(r),u=e.getValue();if(!u)return"";if(_9(u))return uUe(u,r,e,n);const[c,b]=r.svelteStrictMode?['"{','}"']:["{","}"],h=()=>[c,Ia(e,n,"expression"),b],d=u;if((U1||hT&&!I1(d))&&(d.type!=="Text"||!da(d)))return U1&&(U1=!1),QK(r.originalText.slice(r.locStart(d),r.locEnd(d)).split(`
|
|
279
|
-
`).map((g,D)=>D==0?[g]:[x9,g]));switch(d.type){case"Fragment":const g=d.children;if(g.length===0||g.every(da))return"";if(Zl(e))return Br(e.map(n,"children"));{Yqe(d.children,e);const C=d9([mT(e,n,r)],S=>k1(S)||typeof S=="string"&&S.trim()===""||S===q1);return C.every(S=>M_(S))?"":Br([...C,Oi])}case"Text":if(Zl(e)){let C=zs(d);const S=e.getParentNode();return S.type==="Attribute"?(S.name==="class"&&e.getParentNode(1).type==="Element"&&(C=C.replace(/([^ \t\n])(([ \t]+$)|([ \t]+(\r?\n))|[ \t]+)/g,(P,N,_,k,M,I)=>k?P:N+(M?I:" ")),C=C.replace(/([^ \t\n])[ \t]+$/,S.value.indexOf(d)===S.value.length-1?"$1":"$1 ")),Rqe(C,x9)):C}else{if(da(d)){const C=zs(d).trim().length<zs(d).length,S=/\n/.test(zs(d));return/\n\r?\s*\n\r?/.test(zs(d))?[Oi,Oi]:S?Oi:C?Hs:""}return sUe(pUe(d))}case"Element":case"InlineComponent":case"Slot":case"SlotTemplate":case"Window":case"Head":case"Title":{const C=!(d.name==="template"&&!sG(d)),S=d.children.every(ae=>da(ae)),P=d.name.toUpperCase()==="!DOCTYPE",N=r.originalText[d.end-2]==="/",_=S&&((d.type==="Element"&&!r.svelteStrictMode||d.type==="Head"||d.type==="InlineComponent"||d.type==="SlotTemplate"||d.type==="Title")&&N||d.type==="Slot"||d.type==="Window"||Eqe.indexOf(d.name)!==-1||P),k=e.map(w1(d,r,n),"attributes"),M=eG(d,r),I=d.type==="InlineComponent"&&d.expression?[M,"this=",...h()]:d.type==="Element"&&d.tag?[M,"this=",...typeof d.tag=="string"?[`"${d.tag}"`]:[c,Ia(e,n,"tag"),b]]:"";if(_)return Br(["<",d.name,mu(Br([I,...k,o||P?"":j1(Hs)])),o&&!P?" ":"",`${P?"":"/"}>`]);const L=d.children,U=L[0],J=L[L.length-1];let z;const Y=Qqe(d,C,r),j=Zqe(d,C,r);S?z=ec(e,r,d)&&d.children.length&&L1(d.children[0])&&!Zl(e)?()=>Hs:()=>o?ol:"":Zl(e)?z=()=>lUe(d,r.originalText,e,n):C?ec(e,r,d)&&!Zl(e)?z=()=>mT(e,n,r):z=()=>mT(e,n,r):z=()=>aG(d,r.originalText,!0);const re=["<",d.name,mu(Br([I,...k,Y&&!S?"":!o&&!Zl(e)?j1(ol):""]))];if(!C&&!S)return Br([...re,">",Br([Oi,z(),Oi]),`</${d.name}>`]);if(Y&&j){const ae=[ol,Br([">",z(),`</${d.name}`])],xe=S&&!o||uG(d,e,r);return Br([...re,Br(S?ae:mu(ae)),xe?"":ol,">"])}let se=ol,le=ol;if(Zl(e))se="",le="";else{let ae=!1;!Y&&U&&U.type==="Text"&&(O1(U)&&U!==J&&(!ec(e,r,d)||oh(J))?(se=Oi,le=Oi,ae=!0):ec(e,r,d)&&(se=Hs),$1(U)),!j&&J&&J.type==="Text"&&(ec(e,r,d)&&!ae&&(le=Hs),M1(J))}return Br(Y?[...re,mu([ol,Br([">",z()])]),le,`</${d.name}>`]:j?[...re,">",mu([se,Br([z(),`</${d.name}`])]),uG(d,e,r)?"":ol,">"]:S?[...re,">",z(),`</${d.name}>`]:[...re,">",mu([se,z()]),le,`</${d.name}>`])}case"Options":if(r.svelteSortOrder!=="none")throw new Error("Options tags should have been handled by prepareChildren");case"Body":case"Document":return Br(["<",d.name,mu(Br([...e.map(w1(d,r,n),"attributes"),o?"":j1(Hs)])),o?" ":"","/>"]);case"Document":return Br(["<",d.name,mu(Br([...e.map(w1(d,r,n),"attributes"),o?"":j1(Hs)])),o?" ":"","/>"]);case"Identifier":return d.name;case"AttributeShorthand":return d.expression.name;case"Attribute":{if(oG(d))return r.svelteAllowShorthand?["{",d.name,"}"]:r.svelteStrictMode?[d.name,'="{',d.name,'}"']:[d.name,"={",d.name,"}"];{if(d.value===!0)return[d.name];const C=!fT(d.value)||((i=r.svelteStrictMode)!==null&&i!==void 0?i:!1),S=lG(e,n,C,d);return C?[d.name,"=",'"',S,'"']:[d.name,"=",S]}}case"MustacheTag":return["{",Ia(e,n,"expression"),"}"];case"IfBlock":{const C=["{#if ",Ia(e,n,"expression"),"}",$_(e,n,r)];return d.else&&C.push(e.call(n,"else")),C.push("{/if}"),Br([C,q1])}case"ElseBlock":{const C=e.getParentNode();if(d.children.length===1&&d.children[0].type==="IfBlock"&&C.type!=="EachBlock"){const S=d.children[0],P=["{:else if ",e.map(N=>Ia(N,n,"expression"),"children")[0],"}",e.map(N=>$_(N,n,r),"children")[0]];return S.else&&P.push(e.map(N=>N.call(n,"else"),"children")[0]),P}return["{:else}",$_(e,n,r)]}case"EachBlock":{const C=["{#each ",Ia(e,n,"expression")," as",J1(d.context,r.originalText)];return d.index&&C.push(", ",d.index),d.key&&C.push(" (",Ia(e,n,"key"),")"),C.push("}",$_(e,n,r)),d.else&&C.push(e.call(n,"else")),C.push("{/each}"),Br([C,q1])}case"AwaitBlock":{const C=d.pending.children.some(_=>!da(_)),S=d.then.children.some(_=>!da(_)),P=d.catch.children.some(_=>!da(_));let N=[];return!C&&S?N.push(Br(["{#await ",Ia(e,n,"expression")," then",J1(d.value,r.originalText),"}"]),e.call(n,"then")):!C&&P?N.push(Br(["{#await ",Ia(e,n,"expression")," catch",J1(d.error,r.originalText),"}"]),e.call(n,"catch")):(N.push(Br(["{#await ",Ia(e,n,"expression"),"}"])),C&&N.push(e.call(n,"pending")),S&&N.push(Br(["{:then",J1(d.value,r.originalText),"}"]),e.call(n,"then"))),(C||S)&&P&&N.push(Br(["{:catch",J1(d.error,r.originalText),"}"]),e.call(n,"catch")),N.push("{/await}"),Br(N)}case"KeyBlock":{const C=["{#key ",Ia(e,n,"expression"),"}",$_(e,n,r)];return C.push("{/key}"),Br([C,q1])}case"ThenBlock":case"PendingBlock":case"CatchBlock":return $_(e,n,r);case"SnippetBlock":{const C=["{#snippet ",Ia(e,n,"expression")];return C.push("}",$_(e,n,r),"{/snippet}"),C}case"EventHandler":return["on:",d.name,d.modifiers&&d.modifiers.length?["|",uh("|",d.modifiers)]:"",d.expression?["=",...h()]:""];case"Binding":return["bind:",d.name,d.expression.type==="Identifier"&&d.expression.name===d.name&&r.svelteAllowShorthand?"":["=",...h()]];case"Class":return["class:",d.name,d.expression.type==="Identifier"&&d.expression.name===d.name&&r.svelteAllowShorthand?"":["=",...h()]];case"StyleDirective":const D=["style:",d.name,d.modifiers&&d.modifiers.length?["|",uh("|",d.modifiers)]:""];if(oG(d)||d.value===!0)return r.svelteAllowShorthand?[...D]:r.svelteStrictMode?[...D,'="{',d.name,'}"']:[...D,"={",d.name,"}"];{const C=!fT(d.value)||((a=r.svelteStrictMode)!==null&&a!==void 0?a:!1),S=lG(e,n,C,d);return C?[...D,"=",'"',S,'"']:[...D,"=",S]}case"Let":return["let:",d.name,!d.expression||d.expression.type==="Identifier"&&d.expression.name===d.name?"":["=",...h()]];case"DebugTag":return["{@debug",d.identifiers.length>0?[" ",uh(", ",e.map(n,"identifiers"))]:"","}"];case"Ref":return["ref:",d.name];case"Comment":{const C=qqe(e);if(dT(d)&&y9(d,e))hT=!0;else if(I1(d)&&y9(d,e))hT=!1;else{if(N1(d,e)||da(C)&&N1(C,e))return"";iG(d)&&(U1=!0)}return cG(d)}case"Transition":return[d.intro&&d.outro?"transition":d.intro?"in":"out",":",d.name,d.modifiers&&d.modifiers.length?["|",uh("|",d.modifiers)]:"",d.expression?["=",...h()]:""];case"Action":return["use:",d.name,d.expression?["=",...h()]:""];case"Animation":return["animate:",d.name,d.expression?["=",...h()]:""];case"RawMustacheTag":return["{@html ",Ia(e,n,"expression"),"}"];case"RenderTag":return["{@render ",Ia(e,n,"expression"),"}"];case"Spread":return["{...",Ia(e,n,"expression"),"}"];case"ConstTag":return["{@const ",Ia(e,n,"expression"),"}"]}throw console.error(JSON.stringify(d,null,4)),new Error("unknown node type: "+d.type)}function uUe(e,r,n,i){if(r.svelteSortOrder==="none"){const c={};e.module&&(c[e.module.end]=e.module),e.instance&&(c[e.instance.end]=e.instance),e.css&&(c[e.css.end]=e.css);const b=_T(e.html);for(let d=0;d<b.length;d++){const g=b[d];c[g.start]&&(b.splice(d,0,c[g.start]),delete c[g.start])}const h=n.call(i,"html");return r.insertPragma&&!D9(r.originalText)?["<!-- @format -->",Oi,h]:h}const a={options:[],scripts:[],markup:[],styles:[]};e.module&&a.scripts.push(n.call(i,"module")),e.instance&&a.scripts.push(n.call(i,"instance")),e.css&&a.styles.push(n.call(i,"css"));const o=n.call(i,"html");o&&a.markup.push(o),lh&&a.options.push(lh);const u=QK(Bqe(r.svelteSortOrder).map(c=>a[c]));if(U1=!1,hT=!1,lh=void 0,r.parentParser==="markdown"){const c=u[u.length-1];F1([c],k1)}return r.insertPragma&&!D9(r.originalText)?["<!-- @format -->",Oi,Br(u)]:Br([uh(Oi,u)])}function lG(e,r,n,i){const a=e.map(o=>o.call(r),"value");return!n||!KK.includes(i.name)?a:mu(Br(d9(a,k1)))}function $_(e,r,n){const i=e.getValue(),a=i.children;if(!a||a.length===0)return"";const o=eUe(i,n),u=tUe(i,n),c=o==="none"?"":u==="line"||o==="line"?Oi:Hs,b=u==="none"?"":u==="line"||o==="line"?Oi:Hs,h=a[0],d=a[a.length-1];return L1(h)&&$1(h),oh(d)&&M1(d),[mu([c,Br(mT(e,r,n))]),b]}function lUe(e,r,n,i){const a=[],o=e.children.length;for(let u=0;u<o;u++){const c=e.children[u];c.type==="Text"?r.substring(c.start,c.end).split(/\r?\n/).forEach((h,d)=>{d>0&&a.push(x9),a.push(h)}):a.push(n.call(i,"children",u))}return a}function mT(e,r,n){if(Zl(e))return e.map(r,"children");const i=cUe(e.getValue().children,e,r,n);if(e.getValue().children=i,i.length===0)return"";const a=[];let o=!1;for(let g=0;g<i.length;g++){const D=i[g];D.type==="Text"?d(g,D):hu(D,n)?h(g):ec(e,n,D)?b(g):(a.push(c(g)),o=!1)}return i.length>1&&i.some(g=>hu(g,n))&&a.push(q1),a;function c(g){return e.call(r,"children",g)}function b(g){o?a.push(Br([Hs,c(g)])):a.push(c(g)),o=!1}function h(g){const D=i[g-1];D&&!hu(D,n)&&(D.type!=="Text"||o||!oh(D))&&a.push(ol),a.push(c(g));const E=i[g+1];E&&(E.type!=="Text"||(!da(E)||i[g+2]&&ec(e,n,i[g+2]))&&!O1(E))&&a.push(ol),o=!1}function d(g,D){if(o=!1,g===0||g===i.length-1){a.push(c(g));return}const E=i[g-1],C=i[g+1];if(L1(D)&&!da(D)){if(ec(e,n,E)&&!O1(D)){$1(D);const S=a.pop();a.push(Br([S,Hs]))}hu(E,n)&&!O1(D)&&$1(D)}oh(D)&&(ec(e,n,C)&&!b9(D)&&(o=!E||!hu(E,n),M1(D)),hu(C,n)&&!b9(D,2)&&(o=!E||!hu(E,n),M1(D))),a.push(c(g))}}function cUe(e,r,n,i){let a;const o=[],u=pT(i);for(let d=0;d<e.length;d++){const g=e[d];if(!(g.type==="Text"&&zs(g)==="")&&!(da(g)&&N1(g,r))){if(i.svelteSortOrder!=="none"){if(h(g,d)){a=cG(g);const D=e[d+1];d+=D&&da(D)?1:0;continue}if(g.type==="Options"){b(g,d,r,n);continue}}o.push(g)}}const c=[];for(let d=0;d<o.length;d++){const g=o[d],D=o[d+1];g.type==="Text"&&D&&D.type==="Text"&&(g.raw+=D.raw,g.data+=D.data,d++),c.push(g)}return c;function b(d,g,D,E){lh=Br([["<",d.name,mu(Br([...D.map(w1(d,i,E),"children",g,"attributes"),u?"":j1(Hs)])),u?" ":"","/>"],Oi]),a&&(lh=Br([a,Oi,lh]))}function h(d,g){if(d.type!=="Comment"||I1(d)||dT(d))return!1;const D=e[g+1];if(D){if(da(D)){const E=e[g+2];return E&&E.type==="Options"}return D.type==="Options"}return!1}}function pUe(e){const r=zs(e),n=r.split(/[\t\n\f\r ]+/);let i=uh(Hs,n).filter(a=>a!=="");return B1(r)&&(i[0]=Oi),B1(r,2)&&(i=[Oi,...i]),R1(r)&&(i[i.length-1]=Oi),R1(r,2)&&(i=[...i,Oi]),i}function Ia(e,r,n){return e.call(r,n)}function J1(e,r){let n=ul(e);return e!=null&&e.typeAnnotation&&(n+=": "+r.slice(e.typeAnnotation.start,e.typeAnnotation.end)),n}function ul(e,r){if(e===null)return"";if(typeof e=="string")return" "+e;switch(e.type){case"ArrayExpression":case"ArrayPattern":return" ["+e.elements.map(ul).join(",").slice(1)+"]";case"AssignmentPattern":return ul(e.left)+" ="+ul(e.right);case"Identifier":return" "+e.name;case"Literal":return" "+e.raw;case"ObjectExpression":return" {"+e.properties.map(n=>ul(n,e)).join(",")+" }";case"ObjectPattern":return" {"+e.properties.map(ul).join(",")+" }";case"Property":return e.value.type==="ObjectPattern"||e.value.type==="ArrayPattern"?" "+e.key.name+":"+ul(e.value):e.value.type==="Identifier"&&e.key.name!==e.value.name||r&&r.type==="ObjectExpression"?ul(e.key)+":"+ul(e.value):ul(e.value);case"RestElement":return" ..."+e.argument.name}throw console.error(JSON.stringify(e,null,4)),new Error("unknown node type: "+e.type)}function cG(e){let r=e.data;return XK(r)&&(r=YK(r)),Br(["<!--",r,"-->"])}function yT(e,r,n,i){function a(o){return o instanceof n?o:new n(function(u){u(o)})}return new(n||(n=Promise))(function(o,u){function c(d){try{h(i.next(d))}catch(g){u(g)}}function b(d){try{h(i.throw(d))}catch(g){u(g)}}function h(d){d.done?o(d.value):a(d.value).then(c,b)}h((i=i.apply(e,r||[])).next())})}typeof SuppressedError=="function"&&SuppressedError;function gT(e,r,n=!1){const i=e.leadingComments,a=r.originalText.slice(r.locStart(i&&i[0]||e),r.locEnd(e));return!n||!XK(a)?a:YK(a)}const _Ue=/<[a-z]+((?:\s+[^=>'"\/]+=(?:"[^"]*"|'[^']*'|[^>\s]+)|\s+[^=>'"\/]+)*\s*)>/im,dUe=/([^\s=]+)(?:=(?:(?:("|')([\s\S]*?)\2)|(?:([^>\s]+?)(?:\s|>|$))))?/gim;function pG(e){const[,r]=e.match(_Ue),n=[];let i;for(;i=dUe.exec(r);){const[a,o,u,c,b]=i,h=c||b,d=i.index;let g;if(!h)g=!0;else{let D=d+o.length;u&&(D+=2),g=[{type:"Text",data:h,start:D,end:D+h.length}]}n.push({type:"Attribute",name:o,value:g,start:d,end:d+a.length})}return n}const{builders:{group:C9,hardline:pp,softline:fUe,indent:_G,dedent:hUe,literalline:mUe},utils:{removeLines:yUe}}=t_,gUe=new Set(["Script","Style","Identifier","MemberExpression","CallExpression","ArrowFunctionExpression"]),bUe=new Set(["start","end","type"]);function vUe(e,r){return Object.keys(e).filter(n=>!r.has(n)&&!gUe.has(e.type)&&!bUe.has(n))}function xUe(e,r){var n,i,a,o,u,c,b,h,d,g,D;const E=e.getNode(),C=r;if(!C.locStart||!C.locEnd||!C.originalText)throw new Error("Missing required options");if(_9(E))return aUe(E),E.module&&(E.module.type="Script",E.module.attributes=pG(gT(E.module,C))),E.instance&&(E.instance.type="Script",E.instance.attributes=pG(gT(E.instance,C))),E.css&&(E.css.type="Style",E.css.content.type="StyleProgram"),null;const S=e.getParentNode(),P=()=>{var L;return S.expression?_p(S,(L=C.svelteStrictMode)!==null&&L!==void 0?L:!1,!1,!1,"expression"):void 0},N=L=>_p(S,!1,!0,!1,L);switch(S.type){case"IfBlock":case"ElseBlock":case"AwaitBlock":case"KeyBlock":N("expression");break;case"EachBlock":N("expression"),N("key");break;case"SnippetBlock":E===S.expression&&(S.expression.end=C.originalText.indexOf(")",(u=(i=(n=S.context)===null||n===void 0?void 0:n.end)!==null&&i!==void 0?i:(o=(a=S.parameters)===null||a===void 0?void 0:a[S.parameters.length-1])===null||o===void 0?void 0:o.end)!==null&&u!==void 0?u:S.expression.end)+1,S.context=null,S.parameters=null,E.isJS=!0,E.asFunction=!0);break;case"Element":_p(S,(c=C.svelteStrictMode)!==null&&c!==void 0?c:!1,!1,!1,"tag");break;case"MustacheTag":_p(S,rUe(e,C),!1,!1,"expression");break;case"RawMustacheTag":_p(S,!1,!1,!1,"expression");break;case"Spread":_p(S,!1,!1,!1,"expression");break;case"ConstTag":_p(S,!1,!1,!0,"expression");break;case"RenderTag":E===S.expression&&(S.expression.end=C.originalText.indexOf(")",(D=(h=(b=S.argument)===null||b===void 0?void 0:b.end)!==null&&h!==void 0?h:(g=(d=S.arguments)===null||d===void 0?void 0:d[S.arguments.length-1])===null||g===void 0?void 0:g.end)!==null&&D!==void 0?D:S.expression.end)+1,S.argument=null,_p(S,!1,!1,!1,"expression"));break;case"EventHandler":case"Binding":case"Class":case"Let":case"Transition":case"Action":case"Animation":case"InlineComponent":P();break}if(E.isJS)return L=>yT(this,void 0,void 0,function*(){try{const U={parser:"svelteExpressionParser",singleQuote:E.forceSingleQuote?!0:C.singleQuote,_svelte_asFunction:E.asFunction},J=gT(E,C,!0);let z=yield L(E.asFunction?CUe(J):DUe(J),U);if(E.forceSingleLine&&(z=yUe(z)),E.removeParentheses&&(z=$qe(z)),E.asFunction)if(Array.isArray(z)&&typeof z[0]=="string")z[0]=z[0].replace("function ",""),z.splice(-1,1);else throw new Error("Prettier AST changed, asFunction logic needs to change");return z}catch{return gT(E,C,!0)}});const _=(L,U,J)=>(z,Y)=>yT(this,void 0,void 0,function*(){return EUe(L,C.originalText,e,j=>TUe(j,U,z,C),Y,J,C)}),k=L=>_("script",Hqe(E)?"typescript":Vqe(E)?"json":"babel-ts",L),M=L=>_("style",Wqe(E)?"less":Kqe(E)?"scss":"css",L),I=()=>_("template","pug",!1);switch(E.type){case"Script":return k(!0);case"Style":return M(!0);case"Element":{if(E.name==="script")return k(!1);if(E.name==="style")return M(!1);if(Gqe(E))return I()}}return null}function DUe(e){return`(${e}
|
|
279
|
+
`).map((g,D)=>D==0?[g]:[x9,g]));switch(d.type){case"Fragment":const g=d.children;if(g.length===0||g.every(da))return"";if(Zl(e))return Br(e.map(n,"children"));{Yqe(d.children,e);const C=d9([mT(e,n,r)],S=>k1(S)||typeof S=="string"&&S.trim()===""||S===q1);return C.every(S=>M_(S))?"":Br([...C,Oi])}case"Text":if(Zl(e)){let C=zs(d);const S=e.getParentNode();return S.type==="Attribute"?(S.name==="class"&&e.getParentNode(1).type==="Element"&&(C=C.replace(/([^ \t\n])(([ \t]+$)|([ \t]+(\r?\n))|[ \t]+)/g,(P,N,_,k,M,I)=>k?P:N+(M?I:" ")),C=C.replace(/([^ \t\n])[ \t]+$/,S.value.indexOf(d)===S.value.length-1?"$1":"$1 ")),Rqe(C,x9)):C}else{if(da(d)){const C=zs(d).trim().length<zs(d).length,S=/\n/.test(zs(d));return/\n\r?\s*\n\r?/.test(zs(d))?[Oi,Oi]:S?Oi:C?Hs:""}return sUe(pUe(d))}case"Element":case"InlineComponent":case"Slot":case"SlotTemplate":case"Window":case"Head":case"Title":{const C=!(d.name==="template"&&!sG(d)),S=d.children.every(ae=>da(ae)),P=d.name.toUpperCase()==="!DOCTYPE",N=r.originalText[d.end-2]==="/",_=S&&((d.type==="Element"&&!r.svelteStrictMode||d.type==="Head"||d.type==="InlineComponent"||d.type==="SlotTemplate"||d.type==="Title")&&N||d.type==="Slot"||d.type==="Window"||Eqe.indexOf(d.name)!==-1||P),k=e.map(w1(d,r,n),"attributes"),M=eG(d,r),I=d.type==="InlineComponent"&&d.expression?[M,"this=",...h()]:d.type==="Element"&&d.tag?[M,"this=",...typeof d.tag=="string"?[`"${d.tag}"`]:[c,Ia(e,n,"tag"),b]]:"";if(_)return Br(["<",d.name,mu(Br([I,...k,o||P?"":j1(Hs)])),o&&!P?" ":"",`${P?"":"/"}>`]);const L=d.children,U=L[0],J=L[L.length-1];let z;const Y=Qqe(d,C,r),j=Zqe(d,C,r);S?z=ec(e,r,d)&&d.children.length&&L1(d.children[0])&&!Zl(e)?()=>Hs:()=>o?ol:"":Zl(e)?z=()=>lUe(d,r.originalText,e,n):C?ec(e,r,d)&&!Zl(e)?z=()=>mT(e,n,r):z=()=>mT(e,n,r):z=()=>aG(d,r.originalText,!0);const re=["<",d.name,mu(Br([I,...k,Y&&!S?"":!o&&!Zl(e)?j1(ol):""]))];if(!C&&!S)return Br([...re,">",Br([Oi,z(),Oi]),`</${d.name}>`]);if(Y&&j){const ae=[ol,Br([">",z(),`</${d.name}`])],xe=S&&!o||uG(d,e,r);return Br([...re,Br(S?ae:mu(ae)),xe?"":ol,">"])}let se=ol,le=ol;if(Zl(e))se="",le="";else{let ae=!1;!Y&&U&&U.type==="Text"&&(O1(U)&&U!==J&&(!ec(e,r,d)||oh(J))?(se=Oi,le=Oi,ae=!0):ec(e,r,d)&&(se=Hs),$1(U)),!j&&J&&J.type==="Text"&&(ec(e,r,d)&&!ae&&(le=Hs),M1(J))}return Br(Y?[...re,mu([ol,Br([">",z()])]),le,`</${d.name}>`]:j?[...re,">",mu([se,Br([z(),`</${d.name}`])]),uG(d,e,r)?"":ol,">"]:S?[...re,">",z(),`</${d.name}>`]:[...re,">",mu([se,z()]),le,`</${d.name}>`])}case"Options":if(r.svelteSortOrder!=="none")throw new Error("Options tags should have been handled by prepareChildren");case"Body":case"Document":return Br(["<",d.name,mu(Br([...e.map(w1(d,r,n),"attributes"),o?"":j1(Hs)])),o?" ":"","/>"]);case"Document":return Br(["<",d.name,mu(Br([...e.map(w1(d,r,n),"attributes"),o?"":j1(Hs)])),o?" ":"","/>"]);case"Identifier":return d.name;case"AttributeShorthand":return d.expression.name;case"Attribute":{if(oG(d))return r.svelteAllowShorthand?["{",d.name,"}"]:r.svelteStrictMode?[d.name,'="{',d.name,'}"']:[d.name,"={",d.name,"}"];{if(d.value===!0)return[d.name];const C=!fT(d.value)||((i=r.svelteStrictMode)!==null&&i!==void 0?i:!1),S=lG(e,n,C,d);return C?[d.name,"=",'"',S,'"']:[d.name,"=",S]}}case"MustacheTag":return["{",Ia(e,n,"expression"),"}"];case"IfBlock":{const C=["{#if ",Ia(e,n,"expression"),"}",$_(e,n,r)];return d.else&&C.push(e.call(n,"else")),C.push("{/if}"),Br([C,q1])}case"ElseBlock":{const C=e.getParentNode();if(d.children.length===1&&d.children[0].type==="IfBlock"&&C.type!=="EachBlock"){const S=d.children[0],P=["{:else if ",e.map(N=>Ia(N,n,"expression"),"children")[0],"}",e.map(N=>$_(N,n,r),"children")[0]];return S.else&&P.push(e.map(N=>N.call(n,"else"),"children")[0]),P}return["{:else}",$_(e,n,r)]}case"EachBlock":{const C=["{#each ",Ia(e,n,"expression")," as",J1(d.context,r.originalText)];return d.index&&C.push(", ",d.index),d.key&&C.push(" (",Ia(e,n,"key"),")"),C.push("}",$_(e,n,r)),d.else&&C.push(e.call(n,"else")),C.push("{/each}"),Br([C,q1])}case"AwaitBlock":{const C=d.pending.children.some(_=>!da(_)),S=d.then.children.some(_=>!da(_)),P=d.catch.children.some(_=>!da(_));let N=[];return!C&&S?N.push(Br(["{#await ",Ia(e,n,"expression")," then",J1(d.value,r.originalText),"}"]),e.call(n,"then")):!C&&P?N.push(Br(["{#await ",Ia(e,n,"expression")," catch",J1(d.error,r.originalText),"}"]),e.call(n,"catch")):(N.push(Br(["{#await ",Ia(e,n,"expression"),"}"])),C&&N.push(e.call(n,"pending")),S&&N.push(Br(["{:then",J1(d.value,r.originalText),"}"]),e.call(n,"then"))),(C||S)&&P&&N.push(Br(["{:catch",J1(d.error,r.originalText),"}"]),e.call(n,"catch")),N.push("{/await}"),Br(N)}case"KeyBlock":{const C=["{#key ",Ia(e,n,"expression"),"}",$_(e,n,r)];return C.push("{/key}"),Br([C,q1])}case"ThenBlock":case"PendingBlock":case"CatchBlock":return $_(e,n,r);case"SnippetBlock":{const C=["{#snippet ",Ia(e,n,"expression")];return C.push("}",$_(e,n,r),"{/snippet}"),C}case"EventHandler":return["on:",d.name,d.modifiers&&d.modifiers.length?["|",uh("|",d.modifiers)]:"",d.expression?["=",...h()]:""];case"Binding":return["bind:",d.name,d.expression.type==="Identifier"&&d.expression.name===d.name&&r.svelteAllowShorthand?"":["=",...h()]];case"Class":return["class:",d.name,d.expression.type==="Identifier"&&d.expression.name===d.name&&r.svelteAllowShorthand?"":["=",...h()]];case"StyleDirective":const D=["style:",d.name,d.modifiers&&d.modifiers.length?["|",uh("|",d.modifiers)]:""];if(oG(d)||d.value===!0)return r.svelteAllowShorthand?[...D]:r.svelteStrictMode?[...D,'="{',d.name,'}"']:[...D,"={",d.name,"}"];{const C=!fT(d.value)||((a=r.svelteStrictMode)!==null&&a!==void 0?a:!1),S=lG(e,n,C,d);return C?[...D,"=",'"',S,'"']:[...D,"=",S]}case"Let":return["let:",d.name,!d.expression||d.expression.type==="Identifier"&&d.expression.name===d.name?"":["=",...h()]];case"DebugTag":return["{@debug",d.identifiers.length>0?[" ",uh(", ",e.map(n,"identifiers"))]:"","}"];case"Ref":return["ref:",d.name];case"Comment":{const C=qqe(e);if(dT(d)&&y9(d,e))hT=!0;else if(I1(d)&&y9(d,e))hT=!1;else{if(N1(d,e)||da(C)&&N1(C,e))return"";iG(d)&&(U1=!0)}return cG(d)}case"Transition":return[d.intro&&d.outro?"transition":d.intro?"in":"out",":",d.name,d.modifiers&&d.modifiers.length?["|",uh("|",d.modifiers)]:"",d.expression?["=",...h()]:""];case"Action":return["use:",d.name,d.expression?["=",...h()]:""];case"Animation":return["animate:",d.name,d.expression?["=",...h()]:""];case"RawMustacheTag":return["{@html ",Ia(e,n,"expression"),"}"];case"RenderTag":return["{@render ",Ia(e,n,"expression"),"}"];case"Spread":return["{...",Ia(e,n,"expression"),"}"];case"ConstTag":return["{@const ",Ia(e,n,"expression"),"}"]}throw console.error(JSON.stringify(d,null,4)),new Error("unknown node type: "+d.type)}function uUe(e,r,n,i){if(r.svelteSortOrder==="none"){const c={};e.module&&(c[e.module.end]=e.module),e.instance&&(c[e.instance.end]=e.instance),e.css&&(c[e.css.end]=e.css);const b=_T(e.html);for(let d=0;d<b.length;d++){const g=b[d];c[g.start]&&(b.splice(d,0,c[g.start]),delete c[g.start])}const h=n.call(i,"html");return r.insertPragma&&!D9(r.originalText)?["<!-- @format -->",Oi,h]:h}const a={options:[],scripts:[],markup:[],styles:[]};e.module&&a.scripts.push(n.call(i,"module")),e.instance&&a.scripts.push(n.call(i,"instance")),e.css&&a.styles.push(n.call(i,"css"));const o=n.call(i,"html");o&&a.markup.push(o),lh&&a.options.push(lh);const u=QK(Bqe(r.svelteSortOrder).map(c=>a[c]));if(U1=!1,hT=!1,lh=void 0,r.parentParser==="markdown"){const c=u[u.length-1];F1([c],k1)}return r.insertPragma&&!D9(r.originalText)?["<!-- @format -->",Oi,Br(u)]:Br([uh(Oi,u)])}function lG(e,r,n,i){const a=e.map(o=>o.call(r),"value");return!n||!KK.includes(i.name)?a:mu(Br(d9(a,k1)))}function $_(e,r,n){const i=e.getValue(),a=i.children;if(!a||a.length===0)return"";const o=eUe(i,n),u=tUe(i,n),c=o==="none"?"":u==="line"||o==="line"?Oi:Hs,b=u==="none"?"":u==="line"||o==="line"?Oi:Hs,h=a[0],d=a[a.length-1];return L1(h)&&$1(h),oh(d)&&M1(d),[mu([c,Br(mT(e,r,n))]),b]}function lUe(e,r,n,i){const a=[],o=e.children.length;for(let u=0;u<o;u++){const c=e.children[u];c.type==="Text"?r.substring(c.start,c.end).split(/\r?\n/).forEach((h,d)=>{d>0&&a.push(x9),a.push(h)}):a.push(n.call(i,"children",u))}return a}function mT(e,r,n){if(Zl(e))return e.map(r,"children");const i=cUe(e.getValue().children,e,r,n);if(e.getValue().children=i,i.length===0)return"";const a=[];let o=!1;for(let g=0;g<i.length;g++){const D=i[g];D.type==="Text"?d(g,D):hu(D,n)?h(g):ec(e,n,D)?b(g):(a.push(c(g)),o=!1)}return i.length>1&&i.some(g=>hu(g,n))&&a.push(q1),a;function c(g){return e.call(r,"children",g)}function b(g){o?a.push(Br([Hs,c(g)])):a.push(c(g)),o=!1}function h(g){const D=i[g-1];D&&!hu(D,n)&&(D.type!=="Text"||o||!oh(D))&&a.push(ol),a.push(c(g));const E=i[g+1];E&&(E.type!=="Text"||(!da(E)||i[g+2]&&ec(e,n,i[g+2]))&&!O1(E))&&a.push(ol),o=!1}function d(g,D){if(o=!1,g===0||g===i.length-1){a.push(c(g));return}const E=i[g-1],C=i[g+1];if(L1(D)&&!da(D)){if(ec(e,n,E)&&!O1(D)){$1(D);const S=a.pop();a.push(Br([S,Hs]))}hu(E,n)&&!O1(D)&&$1(D)}oh(D)&&(ec(e,n,C)&&!b9(D)&&(o=!E||!hu(E,n),M1(D)),hu(C,n)&&!b9(D,2)&&(o=!E||!hu(E,n),M1(D))),a.push(c(g))}}function cUe(e,r,n,i){let a;const o=[],u=pT(i);for(let d=0;d<e.length;d++){const g=e[d];if(!(g.type==="Text"&&zs(g)==="")&&!(da(g)&&N1(g,r))){if(i.svelteSortOrder!=="none"){if(h(g,d)){a=cG(g);const D=e[d+1];d+=D&&da(D)?1:0;continue}if(g.type==="Options"){b(g,d,r,n);continue}}o.push(g)}}const c=[];for(let d=0;d<o.length;d++){const g=o[d],D=o[d+1];g.type==="Text"&&D&&D.type==="Text"&&(g.raw+=D.raw,g.data+=D.data,d++),c.push(g)}return c;function b(d,g,D,E){lh=Br([["<",d.name,mu(Br([...D.map(w1(d,i,E),"children",g,"attributes"),u?"":j1(Hs)])),u?" ":"","/>"],Oi]),a&&(lh=Br([a,Oi,lh]))}function h(d,g){if(d.type!=="Comment"||I1(d)||dT(d))return!1;const D=e[g+1];if(D){if(da(D)){const E=e[g+2];return E&&E.type==="Options"}return D.type==="Options"}return!1}}function pUe(e){const r=zs(e),n=r.split(/[\t\n\f\r ]+/);let i=uh(Hs,n).filter(a=>a!=="");return B1(r)&&(i[0]=Oi),B1(r,2)&&(i=[Oi,...i]),R1(r)&&(i[i.length-1]=Oi),R1(r,2)&&(i=[...i,Oi]),i}function Ia(e,r,n){return e.call(r,n)}function J1(e,r){let n=ul(e);return e!=null&&e.typeAnnotation&&(n+=": "+r.slice(e.typeAnnotation.start,e.typeAnnotation.end)),n}function ul(e,r){if(e===null)return"";if(typeof e=="string")return" "+e;switch(e.type){case"ArrayExpression":case"ArrayPattern":return" ["+e.elements.map(ul).join(",").slice(1)+"]";case"AssignmentPattern":return ul(e.left)+" ="+ul(e.right);case"Identifier":return" "+e.name;case"Literal":return" "+e.raw;case"ObjectExpression":return" {"+e.properties.map(n=>ul(n,e)).join(",")+" }";case"ObjectPattern":return" {"+e.properties.map(ul).join(",")+" }";case"Property":return e.value.type==="ObjectPattern"||e.value.type==="ArrayPattern"?" "+e.key.name+":"+ul(e.value):e.value.type==="Identifier"&&e.key.name!==e.value.name||r&&r.type==="ObjectExpression"?ul(e.key)+":"+ul(e.value):ul(e.value);case"RestElement":return" ..."+e.argument.name}throw console.error(JSON.stringify(e,null,4)),new Error("unknown node type: "+e.type)}function cG(e){let r=e.data;return XK(r)&&(r=YK(r)),Br(["<!--",r,"-->"])}function yT(e,r,n,i){function a(o){return o instanceof n?o:new n(function(u){u(o)})}return new(n||(n=Promise))(function(o,u){function c(d){try{h(i.next(d))}catch(g){u(g)}}function b(d){try{h(i.throw(d))}catch(g){u(g)}}function h(d){d.done?o(d.value):a(d.value).then(c,b)}h((i=i.apply(e,r||[])).next())})}typeof SuppressedError=="function"&&SuppressedError;function gT(e,r,n=!1){const i=e.leadingComments,a=r.originalText.slice(r.locStart(i&&i[0]||e),r.locEnd(e));return!n||!XK(a)?a:YK(a)}const _Ue=/<[a-z]+((?:\s+[^=>'"\/]+=(?:"[^"]*"|'[^']*'|[^>\s]+)|\s+[^=>'"\/]+)*\s*)>/im,dUe=/([^\s=]+)(?:=(?:(?:("|')([\s\S]*?)\2)|(?:([^>\s]+?)(?:\s|>|$))))?/gim;function pG(e){const[,r]=e.match(_Ue),n=[];let i;for(;i=dUe.exec(r);){const[a,o,u,c,b]=i,h=c||b,d=i.index;let g;if(!h)g=!0;else{let D=d+o.length;u&&(D+=2),g=[{type:"Text",data:h,start:D,end:D+h.length}]}n.push({type:"Attribute",name:o,value:g,start:d,end:d+a.length})}return n}const{builders:{group:C9,hardline:pp,softline:fUe,indent:_G,dedent:hUe,literalline:mUe},utils:{removeLines:yUe}}=t_,gUe=new Set(["Script","Style","Identifier","MemberExpression","CallExpression","ArrowFunctionExpression"]),bUe=new Set(["start","end","type"]);function vUe(e,r){return Object.keys(e).filter(n=>!r.has(n)&&!gUe.has(e.type)&&!bUe.has(n))}function xUe(e,r){var n,i,a,o,u,c,b,h,d,g,D;const E=e.getNode(),C=r;if(!C.locStart||!C.locEnd||!C.originalText)throw new Error("Missing required options");if(_9(E))return aUe(E),E.module&&(E.module.type="Script",E.module.attributes=pG(gT(E.module,C))),E.instance&&(E.instance.type="Script",E.instance.attributes=pG(gT(E.instance,C))),E.css&&(E.css.type="Style",E.css.content.type="StyleProgram"),null;const S=e.getParentNode(),P=()=>{var L;return S.expression?_p(S,(L=C.svelteStrictMode)!==null&&L!==void 0?L:!1,!1,!1,"expression"):void 0},N=L=>_p(S,!1,!0,!1,L);switch(S.type){case"IfBlock":case"ElseBlock":case"AwaitBlock":case"KeyBlock":N("expression");break;case"EachBlock":N("expression"),N("key");break;case"SnippetBlock":E===S.expression&&(S.expression.end=C.originalText.indexOf(")",(u=(i=(n=S.context)===null||n===void 0?void 0:n.end)!==null&&i!==void 0?i:(o=(a=S.parameters)===null||a===void 0?void 0:a[S.parameters.length-1])===null||o===void 0?void 0:o.end)!==null&&u!==void 0?u:S.expression.end)+1,S.context=null,S.parameters=null,E.isJS=!0,E.asFunction=!0);break;case"Element":_p(S,(c=C.svelteStrictMode)!==null&&c!==void 0?c:!1,!1,!1,"tag");break;case"MustacheTag":_p(S,rUe(e,C),!1,!1,"expression");break;case"RawMustacheTag":_p(S,!1,!1,!1,"expression");break;case"Spread":_p(S,!1,!1,!1,"expression");break;case"ConstTag":_p(S,!1,!1,!0,"expression");break;case"RenderTag":E===S.expression&&(("argument"in S||"arguments"in S)&&(S.expression.end=C.originalText.indexOf(")",(D=(h=(b=S.argument)===null||b===void 0?void 0:b.end)!==null&&h!==void 0?h:(g=(d=S.arguments)===null||d===void 0?void 0:d[S.arguments.length-1])===null||g===void 0?void 0:g.end)!==null&&D!==void 0?D:S.expression.end)+1,S.argument=null,S.arguments=null),_p(S,!1,!1,!1,"expression"));break;case"EventHandler":case"Binding":case"Class":case"Let":case"Transition":case"Action":case"Animation":case"InlineComponent":P();break}if(E.isJS)return L=>yT(this,void 0,void 0,function*(){try{const U={parser:"svelteExpressionParser",singleQuote:E.forceSingleQuote?!0:C.singleQuote,_svelte_asFunction:E.asFunction},J=gT(E,C,!0);let z=yield L(E.asFunction?CUe(J):DUe(J),U);if(E.forceSingleLine&&(z=yUe(z)),E.removeParentheses&&(z=$qe(z)),E.asFunction)if(Array.isArray(z)&&typeof z[0]=="string")z[0]=z[0].replace("function ",""),z.splice(-1,1);else throw new Error("Prettier AST changed, asFunction logic needs to change");return z}catch{return gT(E,C,!0)}});const _=(L,U,J)=>(z,Y)=>yT(this,void 0,void 0,function*(){return EUe(L,C.originalText,e,j=>TUe(j,U,z,C),Y,J,C)}),k=L=>_("script",Hqe(E)?"typescript":Vqe(E)?"json":"babel-ts",L),M=L=>_("style",Wqe(E)?"less":Kqe(E)?"scss":"css",L),I=()=>_("template","pug",!1);switch(E.type){case"Script":return k(!0);case"Style":return M(!0);case"Element":{if(E.name==="script")return k(!1);if(E.name==="style")return M(!1);if(Gqe(E))return I()}}return null}function DUe(e){return`(${e}
|
|
280
280
|
)`}function CUe(e){return`function ${e} {}`}function dG(e){if(!e)return"";const r=/^[\t\f\r ]*\n/,n=/\n[\t\f\r ]*$/;return[mUe,e.replace(r,"").replace(n,""),pp]}function SUe(e){const r=g9(A1,e);return r?GK(r):""}function TUe(e,r,n,i){return yT(this,void 0,void 0,function*(){try{const a=yield n(e,{parser:r});if(r==="pug"&&typeof a=="string"){const u=i.useTabs?" ":" ".repeat(i.pugTabWidth&&i.pugTabWidth>0?i.pugTabWidth:i.tabWidth),c=a.split(`
|
|
281
281
|
`).map(b=>b&&u+b).join(`
|
|
282
282
|
`);return[pp,c]}const o=u=>i.svelteIndentScriptAndStyle?_G(u):u;return F1([a],k1),[o([pp,a]),pp]}catch(a){if(Tqe.PRETTIER_DEBUG)throw a;return console.error(a),dG(e)}})}function EUe(e,r,n,i,a,o,u){var c;return yT(this,void 0,void 0,function*(){const b=n.getNode(),h=e==="template"?aG(b,r):SUe(b),d=b.type==="Script"||b.type==="Style"?b.comments:[Uqe(n)].filter(Boolean).map(P=>({comment:P,emptyLineAfter:!1})),D=sG(b)&&!iG((c=d[d.length-1])===null||c===void 0?void 0:c.comment)&&(e!=="template"||u.plugins.some(P=>typeof P!="string"&&P.parsers&&P.parsers.pug))?h.trim()!==""?yield i(h):h===""?"":pp:dG(h),E=C9(["<",e,_G(C9([...n.map(w1(b,u,a),"attributes"),pT(u)?"":hUe(fUe)])),">"]);let C=C9([E,D,"</",e,">"]);const S=[];for(const P of d)S.push("<!--",P.comment.data,"-->"),S.push(pp),P.emptyLineAfter&&S.push(pp);return o&&u.svelteSortOrder!=="none"?[...S,C,pp]:o&&S.length?[...S,C]:C})}function _p(e,r,n,i,a){const o=e[a];!o||typeof o!="object"||(o.isJS=!0,o.forceSingleQuote=r,o.forceSingleLine=n,o.removeParentheses=i)}const fG=v8.babel;function AUe(e){return e.start}function wUe(e){return e.end}const kUe=[{name:"svelte",parsers:["svelte"],extensions:[".svelte"],vscodeLanguageIds:["svelte"]}],FUe={svelte:{hasPragma:D9,parse:e=>{try{return Object.assign(Object.assign({},W8e(e)),{__isRoot:!0})}catch(r){throw r.start!=null&&r.end!=null&&(r.loc={start:r.start,end:r.end}),r}},preprocess:(e,r)=>(e=Pqe(e),e=e.trim(),r.originalText=e,e),locStart:AUe,locEnd:wUe,astFormat:"svelte-ast"},svelteExpressionParser:Object.assign(Object.assign({},fG),{parse:(e,r)=>{const n=fG.parse(e,r);let i=n.program.body[0];return r._svelte_asFunction||(i=i.expression),Object.assign(Object.assign({},n),{program:i})}})};var PUe=Object.freeze({__proto__:null,languages:kUe,options:Iqe,parsers:FUe,printers:{"svelte-ast":{print:oUe,embed:xUe,getVisitorKeys:vUe}}});const hG={js:"babel",jsx:"babel",mjs:"babel",cjs:"babel",ts:"typescript",tsx:"typescript",css:"css",html:"html",json:"json",json5:"json5",md:"markdown",markdown:"markdown"};hG.svelte="svelte";const mG=[Zse,V_e,jme,xge,gDe,txe];mG.push(PUe),onmessage=async({data:e})=>{const{fileExtension:r,fileText:n,fileId:i}=e,a=hG[r];if(a)try{const o=await p8(n,{parser:a,plugins:mG,proseWrap:"always",singleQuote:!0,printWidth:60});postMessage({fileId:i,fileTextPrettified:o})}catch(o){console.error(o),postMessage({fileId:i,error:o.toString()})}}})();
|
package/dist/index.html
CHANGED
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap"
|
|
21
21
|
rel="stylesheet"
|
|
22
22
|
/>
|
|
23
|
-
<script type="module" crossorigin src="/assets/index-
|
|
24
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
23
|
+
<script type="module" crossorigin src="/assets/index-BaaNjNJK.js"></script>
|
|
24
|
+
<link rel="stylesheet" crossorigin href="/assets/index-Buql6gU0.css">
|
|
25
25
|
</head>
|
|
26
26
|
<body>
|
|
27
27
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vzcode",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.74.0",
|
|
4
4
|
"description": "Multiplayer code editor system",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
},
|
|
64
64
|
"homepage": "https://github.com/vizhub-core/vzcode#readme",
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@codemirror/autocomplete": "^6.
|
|
66
|
+
"@codemirror/autocomplete": "^6.14.0",
|
|
67
67
|
"@codemirror/lang-css": "^6.2.1",
|
|
68
68
|
"@codemirror/lang-html": "^6.4.8",
|
|
69
69
|
"@codemirror/lang-javascript": "^6.2.2",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"@codemirror/lang-markdown": "^6.2.4",
|
|
72
72
|
"@codemirror/state": "^6.4.1",
|
|
73
73
|
"@codemirror/theme-one-dark": "^6.1.2",
|
|
74
|
-
"@codemirror/view": "^6.
|
|
74
|
+
"@codemirror/view": "^6.25.1",
|
|
75
75
|
"@lezer/highlight": "^1.2.0",
|
|
76
76
|
"@replit/codemirror-indentation-markers": "^6.5.0",
|
|
77
77
|
"@replit/codemirror-interact": "^6.3.0",
|
|
@@ -90,36 +90,36 @@
|
|
|
90
90
|
"@uiw/codemirror-themes": "^4.21.24",
|
|
91
91
|
"body-parser": "^1.20.2",
|
|
92
92
|
"codemirror": "^6.0.1",
|
|
93
|
-
"codemirror-ot": "^4.
|
|
93
|
+
"codemirror-ot": "^4.3.0",
|
|
94
94
|
"color-hash": "^2.0.2",
|
|
95
95
|
"d3-array": "^3.2.4",
|
|
96
96
|
"diff-match-patch": "^1.0.5",
|
|
97
97
|
"dotenv": "^16.4.5",
|
|
98
|
-
"express": "^4.18.
|
|
98
|
+
"express": "^4.18.3",
|
|
99
99
|
"ignore": "^5.3.1",
|
|
100
100
|
"json0-ot-diff": "^1.1.2",
|
|
101
101
|
"ngrok": "^4.3.3",
|
|
102
|
-
"open": "^10.0
|
|
103
|
-
"openai": "^4.28.
|
|
104
|
-
"prettier-plugin-svelte": "^3.2.
|
|
102
|
+
"open": "^10.1.0",
|
|
103
|
+
"openai": "^4.28.4",
|
|
104
|
+
"prettier-plugin-svelte": "^3.2.2",
|
|
105
105
|
"react": "^18.2.0",
|
|
106
106
|
"react-bootstrap": "^2.10.1",
|
|
107
107
|
"react-dom": "^18.2.0",
|
|
108
|
-
"react-router-dom": "^6.22.
|
|
108
|
+
"react-router-dom": "^6.22.3",
|
|
109
109
|
"sharedb": "^4.1.2",
|
|
110
110
|
"sharedb-client-browser": "^4.4.0",
|
|
111
111
|
"vizhub-ui": "^3.21.0",
|
|
112
112
|
"ws": "^8.16.0"
|
|
113
113
|
},
|
|
114
114
|
"devDependencies": {
|
|
115
|
-
"@types/react": "^18.2.
|
|
116
|
-
"@types/react-dom": "^18.2.
|
|
115
|
+
"@types/react": "^18.2.64",
|
|
116
|
+
"@types/react-dom": "^18.2.21",
|
|
117
117
|
"@vitejs/plugin-react": "^4.2.1",
|
|
118
118
|
"concurrently": "^8.2.2",
|
|
119
119
|
"prettier": "^3.2.5",
|
|
120
120
|
"sass": "^1.71.1",
|
|
121
|
-
"typescript": "^5.
|
|
122
|
-
"vite": "^5.1.
|
|
121
|
+
"typescript": "^5.4.2",
|
|
122
|
+
"vite": "^5.1.5",
|
|
123
123
|
"vitest": "^1.3.1"
|
|
124
124
|
}
|
|
125
125
|
}
|
|
@@ -52,9 +52,14 @@ export type VZCodeContextValue = {
|
|
|
52
52
|
docPresence: any;
|
|
53
53
|
|
|
54
54
|
files: Files | null;
|
|
55
|
-
createFile: (fileName: string) => void;
|
|
55
|
+
createFile: (fileName: string, text?: string) => void;
|
|
56
56
|
renameFile: (fileId: string, fileName: string) => void;
|
|
57
57
|
deleteFile: (fileId: string) => void;
|
|
58
|
+
renameDirectory: (
|
|
59
|
+
directoryId: string,
|
|
60
|
+
directoryOldName: string,
|
|
61
|
+
directoryName: string,
|
|
62
|
+
) => void;
|
|
58
63
|
deleteDirectory: (directoryId: string) => void;
|
|
59
64
|
|
|
60
65
|
activeFileId: string | null;
|
|
@@ -227,6 +232,7 @@ export const VZCodeProvider = ({
|
|
|
227
232
|
createFile,
|
|
228
233
|
renameFile,
|
|
229
234
|
deleteFile,
|
|
235
|
+
renameDirectory,
|
|
230
236
|
deleteDirectory,
|
|
231
237
|
} = useFileCRUD({
|
|
232
238
|
submitOperation,
|
|
@@ -281,6 +287,7 @@ export const VZCodeProvider = ({
|
|
|
281
287
|
createFile,
|
|
282
288
|
renameFile,
|
|
283
289
|
deleteFile,
|
|
290
|
+
renameDirectory,
|
|
284
291
|
deleteDirectory,
|
|
285
292
|
|
|
286
293
|
activeFileId,
|
|
@@ -14,6 +14,7 @@ export const DirectoryListing = ({
|
|
|
14
14
|
children,
|
|
15
15
|
renameFile,
|
|
16
16
|
deleteFile,
|
|
17
|
+
renameDirectory,
|
|
17
18
|
deleteDirectory,
|
|
18
19
|
handleFileClick,
|
|
19
20
|
handleFileDoubleClick,
|
|
@@ -26,6 +27,11 @@ export const DirectoryListing = ({
|
|
|
26
27
|
children: Array<FileTree | FileTreeFile>;
|
|
27
28
|
renameFile: (fileId: string, newName: string) => void;
|
|
28
29
|
deleteFile: (fileId: string) => void;
|
|
30
|
+
renameDirectory: (
|
|
31
|
+
path: FileTreePath,
|
|
32
|
+
oldName: string,
|
|
33
|
+
newName: string,
|
|
34
|
+
) => void;
|
|
29
35
|
deleteDirectory: (path: FileTreePath) => void;
|
|
30
36
|
handleFileClick: (fileId: string) => void;
|
|
31
37
|
handleFileDoubleClick: (fileId: string) => void;
|
|
@@ -41,10 +47,12 @@ export const DirectoryListing = ({
|
|
|
41
47
|
deleteDirectory(path);
|
|
42
48
|
}, [deleteDirectory, path]);
|
|
43
49
|
|
|
44
|
-
const handleRenameClick = useCallback(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
const handleRenameClick = useCallback(
|
|
51
|
+
(newName: string) => {
|
|
52
|
+
renameDirectory(path, name, newName);
|
|
53
|
+
},
|
|
54
|
+
[renameDirectory, path, name],
|
|
55
|
+
);
|
|
48
56
|
|
|
49
57
|
const isOpen = useMemo(
|
|
50
58
|
() => isDirectoryOpen(path),
|
|
@@ -81,6 +89,7 @@ export const DirectoryListing = ({
|
|
|
81
89
|
key={fileId || path}
|
|
82
90
|
renameFile={renameFile}
|
|
83
91
|
deleteFile={deleteFile}
|
|
92
|
+
renameDirectory={renameDirectory}
|
|
84
93
|
deleteDirectory={deleteDirectory}
|
|
85
94
|
handleFileClick={handleFileClick}
|
|
86
95
|
handleFileDoubleClick={
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { useState, useContext, useCallback } from 'react';
|
|
2
|
+
import { VZCodeContext } from '../VZCodeContext';
|
|
3
|
+
import './styles.scss';
|
|
4
|
+
|
|
5
|
+
const debug = false;
|
|
6
|
+
|
|
7
|
+
export const DragAndDrop = () => {
|
|
8
|
+
const [isDragOver, setIsDragOver] = useState(false);
|
|
9
|
+
const { createFile } = useContext(VZCodeContext);
|
|
10
|
+
|
|
11
|
+
const handleDragEnter = useCallback((event) => {
|
|
12
|
+
event.preventDefault();
|
|
13
|
+
event.stopPropagation();
|
|
14
|
+
setIsDragOver(true);
|
|
15
|
+
}, []);
|
|
16
|
+
|
|
17
|
+
const handleDragOver = useCallback(
|
|
18
|
+
(event) => {
|
|
19
|
+
event.preventDefault();
|
|
20
|
+
event.stopPropagation();
|
|
21
|
+
if (!isDragOver) setIsDragOver(true);
|
|
22
|
+
},
|
|
23
|
+
[isDragOver],
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const handleDragLeave = useCallback(
|
|
27
|
+
(event: React.DragEvent<HTMLDivElement>) => {
|
|
28
|
+
event.preventDefault();
|
|
29
|
+
event.stopPropagation();
|
|
30
|
+
setIsDragOver(false);
|
|
31
|
+
},
|
|
32
|
+
[],
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const handleDrop = useCallback(
|
|
36
|
+
(event: React.DragEvent<HTMLDivElement>) => {
|
|
37
|
+
event.preventDefault();
|
|
38
|
+
event.stopPropagation();
|
|
39
|
+
setIsDragOver(false);
|
|
40
|
+
const files = event.dataTransfer.files;
|
|
41
|
+
|
|
42
|
+
if (debug) {
|
|
43
|
+
console.log(files);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
Array.from(files).forEach((file) => {
|
|
47
|
+
const reader = new FileReader();
|
|
48
|
+
reader.onload = (readEvent) => {
|
|
49
|
+
createFile(
|
|
50
|
+
file.name,
|
|
51
|
+
readEvent.target.result as string,
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
reader.onerror = (error) => {
|
|
55
|
+
console.error('Error reading file:', error);
|
|
56
|
+
};
|
|
57
|
+
reader.readAsText(file);
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
[createFile],
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<div
|
|
65
|
+
className={`drop-zone ${isDragOver ? 'dragover' : ''}`}
|
|
66
|
+
onDragEnter={handleDragEnter}
|
|
67
|
+
onDragOver={handleDragOver}
|
|
68
|
+
onDragLeave={handleDragLeave}
|
|
69
|
+
onDrop={handleDrop}
|
|
70
|
+
>
|
|
71
|
+
Drag files here
|
|
72
|
+
</div>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
useEffect,
|
|
6
6
|
} from 'react';
|
|
7
7
|
import { EditSVG, FileSVG, TrashSVG } from '../Icons';
|
|
8
|
-
|
|
9
8
|
import { Tooltip, OverlayTrigger } from '../bootstrap';
|
|
10
9
|
|
|
11
10
|
// TODO consider moving this up to a higher level of the component tree
|
|
@@ -13,7 +12,7 @@ import { DeleteConfirmationModal } from './DeleteConfirmationModal';
|
|
|
13
12
|
|
|
14
13
|
// TODO support renaming directories
|
|
15
14
|
// See https://github.com/vizhub-core/vzcode/issues/103
|
|
16
|
-
const enableRenameDirectory =
|
|
15
|
+
const enableRenameDirectory = true;
|
|
17
16
|
|
|
18
17
|
// A file or directory in the sidebar.
|
|
19
18
|
export const Item = ({
|
|
@@ -25,7 +24,9 @@ export const Item = ({
|
|
|
25
24
|
handleDeleteClick,
|
|
26
25
|
isDirectory = false,
|
|
27
26
|
isActive = false,
|
|
28
|
-
renameFileTooltipText =
|
|
27
|
+
renameFileTooltipText = isDirectory
|
|
28
|
+
? 'Rename Directory'
|
|
29
|
+
: 'Rename File',
|
|
29
30
|
deleteFileTooltipText = isDirectory
|
|
30
31
|
? 'Delete Directory'
|
|
31
32
|
: 'Delete File',
|
|
@@ -148,16 +149,21 @@ export const Item = ({
|
|
|
148
149
|
>
|
|
149
150
|
<div className="name">
|
|
150
151
|
{isRenaming ? (
|
|
151
|
-
<
|
|
152
|
-
className="
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
152
|
+
<React.Fragment>
|
|
153
|
+
<i className="file-icon">
|
|
154
|
+
<FileSVG />
|
|
155
|
+
</i>
|
|
156
|
+
<input
|
|
157
|
+
className="rename-input"
|
|
158
|
+
ref={renameInputRef}
|
|
159
|
+
type="text"
|
|
160
|
+
aria-label="Field name"
|
|
161
|
+
value={renameValue}
|
|
162
|
+
onKeyDown={onKeyDown}
|
|
163
|
+
onBlur={onBlur}
|
|
164
|
+
onChange={onChange}
|
|
165
|
+
/>
|
|
166
|
+
</React.Fragment>
|
|
161
167
|
) : (
|
|
162
168
|
children
|
|
163
169
|
)}
|
|
@@ -13,6 +13,7 @@ export const Listing = ({
|
|
|
13
13
|
entity,
|
|
14
14
|
renameFile,
|
|
15
15
|
deleteFile,
|
|
16
|
+
renameDirectory,
|
|
16
17
|
deleteDirectory,
|
|
17
18
|
handleFileClick,
|
|
18
19
|
handleFileDoubleClick,
|
|
@@ -23,6 +24,11 @@ export const Listing = ({
|
|
|
23
24
|
entity: FileTree | FileTreeFile;
|
|
24
25
|
renameFile: (fileId: FileId, newName: string) => void;
|
|
25
26
|
deleteFile: (fileId: FileId) => void;
|
|
27
|
+
renameDirectory: (
|
|
28
|
+
path: FileTreePath,
|
|
29
|
+
oldName: string,
|
|
30
|
+
newName: string,
|
|
31
|
+
) => void;
|
|
26
32
|
deleteDirectory: (path: FileTreePath) => void;
|
|
27
33
|
handleFileClick: (fileId: FileId) => void;
|
|
28
34
|
handleFileDoubleClick: (fileId: FileId) => void;
|
|
@@ -49,6 +55,7 @@ export const Listing = ({
|
|
|
49
55
|
children={children}
|
|
50
56
|
renameFile={renameFile}
|
|
51
57
|
deleteFile={deleteFile}
|
|
58
|
+
renameDirectory={renameDirectory}
|
|
52
59
|
deleteDirectory={deleteDirectory}
|
|
53
60
|
handleFileClick={handleFileClick}
|
|
54
61
|
handleFileDoubleClick={handleFileDoubleClick}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
useCallback,
|
|
3
|
+
useContext,
|
|
4
|
+
useEffect,
|
|
5
|
+
useMemo,
|
|
6
|
+
} from 'react';
|
|
2
7
|
import {
|
|
3
8
|
FileId,
|
|
4
9
|
FileTree,
|
|
@@ -12,6 +17,7 @@ import { SplitPaneResizeContext } from '../SplitPaneResizeContext';
|
|
|
12
17
|
import { BugSVG, GearSVG, NewSVG } from '../Icons';
|
|
13
18
|
import { Listing } from './Listing';
|
|
14
19
|
import { VZCodeContext } from '../VZCodeContext';
|
|
20
|
+
import { DragAndDrop } from './DragAndDrop';
|
|
15
21
|
import './styles.scss';
|
|
16
22
|
|
|
17
23
|
// TODO turn this UI back on when we are actually detecting
|
|
@@ -32,6 +38,7 @@ export const VZSidebar = ({
|
|
|
32
38
|
files,
|
|
33
39
|
renameFile,
|
|
34
40
|
deleteFile,
|
|
41
|
+
renameDirectory,
|
|
35
42
|
deleteDirectory,
|
|
36
43
|
activeFileId,
|
|
37
44
|
openTab,
|
|
@@ -140,6 +147,7 @@ export const VZSidebar = ({
|
|
|
140
147
|
</OverlayTrigger>
|
|
141
148
|
</div>
|
|
142
149
|
</div>
|
|
150
|
+
<DragAndDrop />
|
|
143
151
|
{filesExist ? (
|
|
144
152
|
fileTree.children.map((entity) => {
|
|
145
153
|
const { fileId } = entity as FileTreeFile;
|
|
@@ -151,6 +159,7 @@ export const VZSidebar = ({
|
|
|
151
159
|
entity={entity}
|
|
152
160
|
renameFile={renameFile}
|
|
153
161
|
deleteFile={deleteFile}
|
|
162
|
+
renameDirectory={renameDirectory}
|
|
154
163
|
deleteDirectory={deleteDirectory}
|
|
155
164
|
handleFileClick={handleFileClick}
|
|
156
165
|
handleFileDoubleClick={
|
|
@@ -89,8 +89,15 @@
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
.rename-input {
|
|
92
|
-
|
|
92
|
+
width: 100%;
|
|
93
93
|
border: 0px;
|
|
94
|
+
outline: none;
|
|
95
|
+
background: transparent;
|
|
96
|
+
color: var(--vh-color-neutral-04);
|
|
97
|
+
font-family: var(--vzcode-font-family);
|
|
98
|
+
font-size: inherit;
|
|
99
|
+
font-weight: inherit;
|
|
100
|
+
padding: 0px;
|
|
94
101
|
margin: 0px;
|
|
95
102
|
}
|
|
96
103
|
|
|
@@ -147,4 +154,18 @@
|
|
|
147
154
|
}
|
|
148
155
|
}
|
|
149
156
|
}
|
|
157
|
+
|
|
158
|
+
.drop-zone {
|
|
159
|
+
border: 3px dashed #bdc7dc;
|
|
160
|
+
width: auto;
|
|
161
|
+
padding: 20px;
|
|
162
|
+
color: #bdc7dc;
|
|
163
|
+
text-align: center;
|
|
164
|
+
font-family: var(--vzcode-font-family);
|
|
165
|
+
font-weight: 500;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.drop-zone.dragover {
|
|
169
|
+
border-color: #009639;
|
|
170
|
+
}
|
|
150
171
|
}
|
|
@@ -27,14 +27,14 @@ export const useFileCRUD = ({
|
|
|
27
27
|
}) => {
|
|
28
28
|
// Create a new file
|
|
29
29
|
const createFile = useCallback(
|
|
30
|
-
(name: string) => {
|
|
30
|
+
(name: string, text = '') => {
|
|
31
31
|
if (name) {
|
|
32
32
|
const fileId: FileId = randomId();
|
|
33
33
|
submitOperation((document: VZCodeContent) => ({
|
|
34
34
|
...document,
|
|
35
35
|
files: {
|
|
36
36
|
...document.files,
|
|
37
|
-
[fileId]: { name, text
|
|
37
|
+
[fileId]: { name, text },
|
|
38
38
|
},
|
|
39
39
|
}));
|
|
40
40
|
// When a new file is created, open it in a new tab
|
|
@@ -54,7 +54,13 @@ export const useFileCRUD = ({
|
|
|
54
54
|
...document.files,
|
|
55
55
|
[fileId]: {
|
|
56
56
|
...document.files[fileId],
|
|
57
|
-
name:
|
|
57
|
+
name:
|
|
58
|
+
document.files[fileId].name.substring(
|
|
59
|
+
0,
|
|
60
|
+
document.files[fileId].name.lastIndexOf(
|
|
61
|
+
'/',
|
|
62
|
+
) + 1,
|
|
63
|
+
) + newName,
|
|
58
64
|
},
|
|
59
65
|
},
|
|
60
66
|
}));
|
|
@@ -62,6 +68,40 @@ export const useFileCRUD = ({
|
|
|
62
68
|
[submitOperation],
|
|
63
69
|
);
|
|
64
70
|
|
|
71
|
+
// Renames a directory
|
|
72
|
+
const renameDirectory = useCallback(
|
|
73
|
+
(
|
|
74
|
+
path: FileTreePath,
|
|
75
|
+
oldName: string,
|
|
76
|
+
newName: string,
|
|
77
|
+
) => {
|
|
78
|
+
submitOperation((document: VZCodeContent) => {
|
|
79
|
+
const updatedFiles = Object.keys(
|
|
80
|
+
document.files,
|
|
81
|
+
).reduce((acc, key) => {
|
|
82
|
+
const file = document.files[key];
|
|
83
|
+
const fileName = file.name;
|
|
84
|
+
if (fileName.includes(path)) {
|
|
85
|
+
const oldNamePos = fileName.indexOf(oldName);
|
|
86
|
+
const fileNewName =
|
|
87
|
+
fileName.substring(0, oldNamePos) +
|
|
88
|
+
newName +
|
|
89
|
+
fileName.substring(
|
|
90
|
+
oldNamePos + oldName.length,
|
|
91
|
+
);
|
|
92
|
+
acc[key] = { ...file, name: fileNewName };
|
|
93
|
+
} else {
|
|
94
|
+
acc[key] = file;
|
|
95
|
+
}
|
|
96
|
+
return acc;
|
|
97
|
+
}, {});
|
|
98
|
+
|
|
99
|
+
return { ...document, files: updatedFiles };
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
[submitOperation],
|
|
103
|
+
);
|
|
104
|
+
|
|
65
105
|
// Deletes a file
|
|
66
106
|
const deleteFile = useCallback(
|
|
67
107
|
(fileId: FileId) => {
|
|
@@ -98,6 +138,7 @@ export const useFileCRUD = ({
|
|
|
98
138
|
createFile,
|
|
99
139
|
renameFile,
|
|
100
140
|
deleteFile,
|
|
141
|
+
renameDirectory,
|
|
101
142
|
deleteDirectory,
|
|
102
143
|
};
|
|
103
144
|
};
|