vzcode 0.87.0 → 0.89.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/README.md +2 -20
- package/dist/assets/{index-DubfLBmh.js → index-C4h28erw.js} +57 -57
- package/dist/assets/{index-B4X7yIz8.js → index-pzvwg1lq.js} +58 -58
- package/dist/assets/{worker-DHoGVnSk.js → worker-BIf7QrAH.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +13 -13
- package/src/client/Icons/QuestionMarkSVG.tsx +18 -0
- package/src/client/Icons/index.tsx +1 -0
- package/src/client/SplitPaneResizeContext.tsx +1 -1
- package/src/client/VZCodeContext.tsx +11 -0
- package/src/client/VZKeyboardShortcutsDoc.tsx +121 -0
- package/src/client/VZLeft.tsx +4 -0
- package/src/client/VZSettings.tsx +41 -51
- package/src/client/VZSidebar/CreateDirModal.tsx +14 -2
- package/src/client/VZSidebar/CreateFileModal.tsx +14 -2
- package/src/client/VZSidebar/index.tsx +49 -36
- package/src/client/index.ts +1 -0
- package/src/client/useActions.ts +16 -0
- package/src/client/vzReducer/createInitialState.ts +1 -0
- package/src/client/vzReducer/index.ts +5 -0
- package/src/client/vzReducer/setIsDocOpenReducer.ts +9 -0
- package/src/client/featureFlags.js +0 -4
|
@@ -276,7 +276,7 @@ Did you specify these with the most recent transformation maps first?`);let I=C(
|
|
|
276
276
|
`)+1)),$0(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 b9(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 ch(e){const r=b9("lang",e)||b9("type",e);return r!=null?r.replace(/^text\//,""):null}function sG(e){const r=ch(e);return!(r&&jqe.includes(r))}function Hqe(e){const r=ch(e)||"";return["typescript","ts"].includes(r)}function Vqe(e){const r=ch(e)||"";return r.endsWith("json")||r.endsWith("importmap")}function Wqe(e){const r=ch(e)||"";return["less"].includes(r)}function Kqe(e){const r=ch(e)||"";return["sass","scss"].includes(r)}function Gqe(e){return e.type==="Element"&&e.name==="template"&&ch(e)==="pug"}function mT(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(mT(e.value)){const r=e.value[0].expression;return r.type==="Identifier"&&r.name===e.name}return!1}function Xs(e){return e.raw||e.data}function L0(e,r=1){return e.type==="Text"&&M0(Xs(e),r)}function M0(e,r=1){return new RegExp(`^([\\t\\f\\r ]*\\n){${r}}`).test(e)}function v9(e,r=1){return e.type==="Text"&&$0(Xs(e),r)}function $0(e,r=1){return new RegExp(`(\\n[\\t\\f\\r ]*){${r}}$`).test(e)}function j0(e){return e.type==="Text"&&/^\s/.test(Xs(e))}function ph(e){return e.type==="Text"&&/\s$/.test(Xs(e))}function q0(e){e.raw=e.raw&&e.raw.trimRight(),e.data=e.data&&e.data.trimRight()}function U0(e){e.raw=e.raw&&e.raw.trimLeft(),e.data=e.data&&e.data.trimLeft()}function Yqe(e,r){let n=e.findIndex(a=>!ma(a)&&!B0(a,r));n=n===-1?e.length-1:n;let i=ZK((a,o)=>!ma(a)&&(o===e.length-1&&a.type!=="Comment"||!B0(a,r)),e);i=i===-1?0:i;for(let a=0;a<=n;a++){const o=e[a];o.type==="Text"&&U0(o)}for(let a=e.length-1;a>=i;a--){const o=e[a];o.type==="Text"&&q0(o)}}function Qqe(e,r,n){if(!r)return!0;if(xu(e,n)||!O0(e))return!1;const i=e.children;if(i.length===0)return!0;if(n.htmlWhitespaceSensitivity==="ignore")return!1;const a=i[0];return!j0(a)}function Zqe(e,r,n){if(!r)return!0;if(xu(e,n)||!O0(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!ph(a)}function eUe(e,r){if(!nG(e)||!O0(e))return"none";const n=e.children;if(n.length===0)return"none";const i=n[0];if(L0(i))return"line";if(j0(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 M0(o)?"line":"space"}return"none"}function tUe(e,r){if(!nG(e)||!O0(e))return"none";const n=e.children;if(n.length===0)return"none";const i=n[n.length-1];if(v9(i))return"line";if(ph(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 $0(o)?"line":"space"}return"none"}function rUe(e,r){return e.stack.some(i=>i.type==="Attribute"&&(!mT(i.value)||r.svelteStrictMode))}function uG(e,r,n){return dT(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||!xu(n,r))return!1;const i=fT(n);return i[i.length-1]===e.getNode()}function aUe(e){e.module&&(e.module.comments=x9(e,e.module)),e.instance&&(e.instance.comments=x9(e,e.instance)),e.css&&(e.css.comments=x9(e,e.css))}function x9(e,r){const n=fT(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"&&!hT(u)&&!R0(u))i.push(u),i.length!==a.length&&a.push({type:"Text",data:"",raw:"",start:-1,end:-1});else if(ma(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:Xs(a[b]).split(`
|
|
278
278
|
`).length>2})).reverse()}const{join:_h,line:Ys,group:Or,indent:Du,dedent:J0,softline:dl,hardline:Mi,fill:sUe,breakParent:z0,literalline:D9}=a_.builders;function C9(e){return/^\s*<!--\s*@(format|prettier)\W/.test(e)}let H0=!1,yT=!1,dh;function oUe(e,r,n){var i,a;const o=dT(r),u=e.getValue();if(!u)return"";if(d9(u))return uUe(u,r,e,n);const[c,b]=r.svelteStrictMode?['"{','}"']:["{","}"],h=()=>[c,La(e,n,"expression"),b],d=u;if((H0||yT&&!R0(d))&&(d.type!=="Text"||!ma(d)))return H0&&(H0=!1),QK(r.originalText.slice(r.locStart(d),r.locEnd(d)).split(`
|
|
279
|
-
`).map((g,D)=>D==0?[g]:[D9,g]));switch(d.type){case"Fragment":const g=d.children;if(g.length===0||g.every(ma))return"";if(ic(e))return Or(e.map(n,"children"));{Yqe(d.children,e);const C=f9([gT(e,n,r)],S=>N0(S)||typeof S=="string"&&S.trim()===""||S===z0);return C.every(S=>U_(S))?"":Or([...C,Mi])}case"Text":if(ic(e)){let C=Xs(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,_,F,L,I)=>F?P:N+(L?I:" ")),C=C.replace(/([^ \t\n])[ \t]+$/,S.value.indexOf(d)===S.value.length-1?"$1":"$1 ")),Rqe(C,D9)):C}else{if(ma(d)){const C=Xs(d).trim().length<Xs(d).length,S=/\n/.test(Xs(d));return/\n\r?\s*\n\r?/.test(Xs(d))?[Mi,Mi]:S?Mi:C?Ys:""}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=>ma(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),F=e.map(P0(d,r,n),"attributes"),L=eG(d,r),I=d.type==="InlineComponent"&&d.expression?[L,"this=",...h()]:d.type==="Element"&&d.tag?[L,"this=",...typeof d.tag=="string"?[`"${d.tag}"`]:[c,La(e,n,"tag"),b]]:"";if(_)return Or(["<",d.name,Du(Or([I,...F,o||P?"":J0(Ys)])),o&&!P?" ":"",`${P?"":"/"}>`]);const M=d.children,U=M[0],z=M[M.length-1];let H;const Q=Qqe(d,C,r),q=Zqe(d,C,r);S?H=ac(e,r,d)&&d.children.length&&j0(d.children[0])&&!ic(e)?()=>Ys:()=>o?dl:"":ic(e)?H=()=>lUe(d,r.originalText,e,n):C?ac(e,r,d)&&!ic(e)?H=()=>gT(e,n,r):H=()=>gT(e,n,r):H=()=>aG(d,r.originalText,!0);const re=["<",d.name,Du(Or([I,...F,Q&&!S?"":!o&&!ic(e)?J0(dl):""]))];if(!C&&!S)return Or([...re,">",Or([Mi,H(),Mi]),`</${d.name}>`]);if(Q&&q){const ae=[dl,Or([">",H(),`</${d.name}`])],ge=S&&!o||uG(d,e,r);return Or([...re,Or(S?ae:Du(ae)),ge?"":dl,">"])}let ue=dl,ce=dl;if(ic(e))ue="",ce="";else{let ae=!1;!Q&&U&&U.type==="Text"&&(L0(U)&&U!==z&&(!ac(e,r,d)||ph(z))?(ue=Mi,ce=Mi,ae=!0):ac(e,r,d)&&(ue=Ys),U0(U)),!q&&z&&z.type==="Text"&&(ac(e,r,d)&&!ae&&(ce=Ys),q0(z))}return Or(Q?[...re,Du([dl,Or([">",H()])]),ce,`</${d.name}>`]:q?[...re,">",Du([ue,Or([H(),`</${d.name}`])]),uG(d,e,r)?"":dl,">"]:S?[...re,">",H(),`</${d.name}>`]:[...re,">",Du([ue,H()]),ce,`</${d.name}>`])}case"Options":if(r.svelteSortOrder!=="none")throw new Error("Options tags should have been handled by prepareChildren");case"Body":case"Document":return Or(["<",d.name,Du(Or([...e.map(P0(d,r,n),"attributes"),o?"":J0(Ys)])),o?" ":"","/>"]);case"Document":return Or(["<",d.name,Du(Or([...e.map(P0(d,r,n),"attributes"),o?"":J0(Ys)])),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=!mT(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["{",La(e,n,"expression"),"}"];case"IfBlock":{const C=["{#if ",La(e,n,"expression"),"}",J_(e,n,r)];return d.else&&C.push(e.call(n,"else")),C.push("{/if}"),Or([C,z0])}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=>La(N,n,"expression"),"children")[0],"}",e.map(N=>J_(N,n,r),"children")[0]];return S.else&&P.push(e.map(N=>N.call(n,"else"),"children")[0]),P}return["{:else}",J_(e,n,r)]}case"EachBlock":{const C=["{#each ",La(e,n,"expression")," as",V0(d.context,r.originalText)];return d.index&&C.push(", ",d.index),d.key&&C.push(" (",La(e,n,"key"),")"),C.push("}",J_(e,n,r)),d.else&&C.push(e.call(n,"else")),C.push("{/each}"),Or([C,z0])}case"AwaitBlock":{const C=d.pending.children.some(_=>!ma(_)),S=d.then.children.some(_=>!ma(_)),P=d.catch.children.some(_=>!ma(_));let N=[];return!C&&S?N.push(Or(["{#await ",La(e,n,"expression")," then",V0(d.value,r.originalText),"}"]),e.call(n,"then")):!C&&P?N.push(Or(["{#await ",La(e,n,"expression")," catch",V0(d.error,r.originalText),"}"]),e.call(n,"catch")):(N.push(Or(["{#await ",La(e,n,"expression"),"}"])),C&&N.push(e.call(n,"pending")),S&&N.push(Or(["{:then",V0(d.value,r.originalText),"}"]),e.call(n,"then"))),(C||S)&&P&&N.push(Or(["{:catch",V0(d.error,r.originalText),"}"]),e.call(n,"catch")),N.push("{/await}"),Or(N)}case"KeyBlock":{const C=["{#key ",La(e,n,"expression"),"}",J_(e,n,r)];return C.push("{/key}"),Or([C,z0])}case"ThenBlock":case"PendingBlock":case"CatchBlock":return J_(e,n,r);case"SnippetBlock":{const C=["{#snippet ",La(e,n,"expression")];return C.push("}",J_(e,n,r),"{/snippet}"),C}case"EventHandler":return["on:",d.name,d.modifiers&&d.modifiers.length?["|",_h("|",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?["|",_h("|",d.modifiers)]:""];if(oG(d)||d.value===!0)return r.svelteAllowShorthand?[...D]:r.svelteStrictMode?[...D,'="{',d.name,'}"']:[...D,"={",d.name,"}"];{const C=!mT(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?[" ",_h(", ",e.map(n,"identifiers"))]:"","}"];case"Ref":return["ref:",d.name];case"Comment":{const C=qqe(e);if(hT(d)&&g9(d,e))yT=!0;else if(R0(d)&&g9(d,e))yT=!1;else{if(B0(d,e)||ma(C)&&B0(C,e))return"";iG(d)&&(H0=!0)}return cG(d)}case"Transition":return[d.intro&&d.outro?"transition":d.intro?"in":"out",":",d.name,d.modifiers&&d.modifiers.length?["|",_h("|",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 ",La(e,n,"expression"),"}"];case"RenderTag":return["{@render ",La(e,n,"expression"),"}"];case"Spread":return["{...",La(e,n,"expression"),"}"];case"ConstTag":return["{@const ",La(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=fT(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&&!C9(r.originalText)?["<!-- @format -->",Mi,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),dh&&a.options.push(dh);const u=QK(Bqe(r.svelteSortOrder).map(c=>a[c]));if(H0=!1,yT=!1,dh=void 0,r.parentParser==="markdown"){const c=u[u.length-1];I0([c],N0)}return r.insertPragma&&!C9(r.originalText)?["<!-- @format -->",Mi,Or(u)]:Or([_h(Mi,u)])}function lG(e,r,n,i){const a=e.map(o=>o.call(r),"value");return!n||!KK.includes(i.name)?a:Du(Or(f9(a,N0)))}function J_(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"?Mi:Ys,b=u==="none"?"":u==="line"||o==="line"?Mi:Ys,h=a[0],d=a[a.length-1];return j0(h)&&U0(h),ph(d)&&q0(d),[Du([c,Or(gT(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(D9),a.push(h)}):a.push(n.call(i,"children",u))}return a}function gT(e,r,n){if(ic(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):xu(D,n)?h(g):ac(e,n,D)?b(g):(a.push(c(g)),o=!1)}return i.length>1&&i.some(g=>xu(g,n))&&a.push(z0),a;function c(g){return e.call(r,"children",g)}function b(g){o?a.push(Or([Ys,c(g)])):a.push(c(g)),o=!1}function h(g){const D=i[g-1];D&&!xu(D,n)&&(D.type!=="Text"||o||!ph(D))&&a.push(dl),a.push(c(g));const E=i[g+1];E&&(E.type!=="Text"||(!ma(E)||i[g+2]&&ac(e,n,i[g+2]))&&!L0(E))&&a.push(dl),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(j0(D)&&!ma(D)){if(ac(e,n,E)&&!L0(D)){U0(D);const S=a.pop();a.push(Or([S,Ys]))}xu(E,n)&&!L0(D)&&U0(D)}ph(D)&&(ac(e,n,C)&&!v9(D)&&(o=!E||!xu(E,n),q0(D)),xu(C,n)&&!v9(D,2)&&(o=!E||!xu(E,n),q0(D))),a.push(c(g))}}function cUe(e,r,n,i){let a;const o=[],u=dT(i);for(let d=0;d<e.length;d++){const g=e[d];if(!(g.type==="Text"&&Xs(g)==="")&&!(ma(g)&&B0(g,r))){if(i.svelteSortOrder!=="none"){if(h(g,d)){a=cG(g);const D=e[d+1];d+=D&&ma(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){dh=Or([["<",d.name,Du(Or([...D.map(P0(d,i,E),"children",g,"attributes"),u?"":J0(Ys)])),u?" ":"","/>"],Mi]),a&&(dh=Or([a,Mi,dh]))}function h(d,g){if(d.type!=="Comment"||R0(d)||hT(d))return!1;const D=e[g+1];if(D){if(ma(D)){const E=e[g+2];return E&&E.type==="Options"}return D.type==="Options"}return!1}}function pUe(e){const r=Xs(e),n=r.split(/[\t\n\f\r ]+/);let i=_h(Ys,n).filter(a=>a!=="");return M0(r)&&(i[0]=Mi),M0(r,2)&&(i=[Mi,...i]),$0(r)&&(i[i.length-1]=Mi),$0(r,2)&&(i=[...i,Mi]),i}function La(e,r,n){return e.call(r,n)}function V0(e,r){let n=fl(e);return e!=null&&e.typeAnnotation&&(n+=": "+r.slice(e.typeAnnotation.start,e.typeAnnotation.end)),n}function fl(e,r){if(e===null)return"";if(typeof e=="string")return" "+e;switch(e.type){case"ArrayExpression":case"ArrayPattern":return" ["+e.elements.map(fl).join(",").slice(1)+"]";case"AssignmentPattern":return fl(e.left)+" ="+fl(e.right);case"Identifier":return" "+e.name;case"Literal":return" "+e.raw;case"ObjectExpression":return" {"+e.properties.map(n=>fl(n,e)).join(",")+" }";case"ObjectPattern":return" {"+e.properties.map(fl).join(",")+" }";case"Property":return e.value.type==="ObjectPattern"||e.value.type==="ArrayPattern"?" "+e.key.name+":"+fl(e.value):e.value.type==="Identifier"&&e.key.name!==e.value.name||r&&r.type==="ObjectExpression"?fl(e.key)+":"+fl(e.value):fl(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)),Or(["<!--",r,"-->"])}function bT(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 vT(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:S9,hardline:hp,softline:fUe,indent:_G,dedent:hUe,literalline:mUe},utils:{removeLines:yUe}}=a_,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(d9(E))return aUe(E),E.module&&(E.module.type="Script",E.module.attributes=pG(vT(E.module,C))),E.instance&&(E.instance.type="Script",E.instance.attributes=pG(vT(E.instance,C))),E.css&&(E.css.type="Style",E.css.content.type="StyleProgram"),null;const S=e.getParentNode(),P=()=>{var M;return S.expression?mp(S,(M=C.svelteStrictMode)!==null&&M!==void 0?M:!1,!1,!1,"expression"):void 0},N=M=>mp(S,!1,!0,!1,M);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":mp(S,(c=C.svelteStrictMode)!==null&&c!==void 0?c:!1,!1,!1,"tag");break;case"MustacheTag":mp(S,rUe(e,C),!1,!1,"expression");break;case"RawMustacheTag":mp(S,!1,!1,!1,"expression");break;case"Spread":mp(S,!1,!1,!1,"expression");break;case"ConstTag":mp(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),mp(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 M=>bT(this,void 0,void 0,function*(){try{const U={parser:"svelteExpressionParser",singleQuote:E.forceSingleQuote?!0:C.singleQuote,_svelte_asFunction:E.asFunction},z=vT(E,C,!0);let H=yield M(E.asFunction?CUe(z):DUe(z),U);if(E.forceSingleLine&&(H=yUe(H)),E.removeParentheses&&(H=$qe(H)),E.asFunction)if(Array.isArray(H)&&typeof H[0]=="string")H[0]=H[0].replace("function ",""),H.splice(-1,1);else throw new Error("Prettier AST changed, asFunction logic needs to change");return H}catch{return vT(E,C,!0)}});const _=(M,U,z)=>(H,Q)=>bT(this,void 0,void 0,function*(){return EUe(M,C.originalText,e,q=>TUe(q,U,H,C),Q,z,C)}),F=M=>_("script",Hqe(E)?"typescript":Vqe(E)?"json":"babel-ts",M),L=M=>_("style",Wqe(E)?"less":Kqe(E)?"scss":"css",M),I=()=>_("template","pug",!1);switch(E.type){case"Script":return F(!0);case"Style":return L(!0);case"Element":{if(E.name==="script")return F(!1);if(E.name==="style")return L(!1);if(Gqe(E))return I()}}return null}function DUe(e){return`(${e}
|
|
279
|
+
`).map((g,D)=>D==0?[g]:[D9,g]));switch(d.type){case"Fragment":const g=d.children;if(g.length===0||g.every(ma))return"";if(ic(e))return Or(e.map(n,"children"));{Yqe(d.children,e);const C=f9([gT(e,n,r)],S=>N0(S)||typeof S=="string"&&S.trim()===""||S===z0);return C.every(S=>U_(S))?"":Or([...C,Mi])}case"Text":if(ic(e)){let C=Xs(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,_,F,L,I)=>F?P:N+(L?I:" ")),C=C.replace(/([^ \t\n])[ \t]+$/,S.value.indexOf(d)===S.value.length-1?"$1":"$1 ")),Rqe(C,D9)):C}else{if(ma(d)){const C=Xs(d).trim().length<Xs(d).length,S=/\n/.test(Xs(d));return/\n\r?\s*\n\r?/.test(Xs(d))?[Mi,Mi]:S?Mi:C?Ys:""}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=>ma(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==="Slot"||d.type==="SlotTemplate"||d.type==="Title")&&N||d.type==="Window"||Eqe.indexOf(d.name)!==-1||P),F=e.map(P0(d,r,n),"attributes"),L=eG(d,r),I=d.type==="InlineComponent"&&d.expression?[L,"this=",...h()]:d.type==="Element"&&d.tag?[L,"this=",...typeof d.tag=="string"?[`"${d.tag}"`]:[c,La(e,n,"tag"),b]]:"";if(_)return Or(["<",d.name,Du(Or([I,...F,o||P?"":J0(Ys)])),o&&!P?" ":"",`${P?"":"/"}>`]);const M=d.children,U=M[0],z=M[M.length-1];let H;const Q=Qqe(d,C,r),q=Zqe(d,C,r);S?H=ac(e,r,d)&&d.children.length&&j0(d.children[0])&&!ic(e)?()=>Ys:()=>o?dl:"":ic(e)?H=()=>lUe(d,r.originalText,e,n):C?ac(e,r,d)&&!ic(e)?H=()=>gT(e,n,r):H=()=>gT(e,n,r):H=()=>aG(d,r.originalText,!0);const re=["<",d.name,Du(Or([I,...F,Q&&!S?"":!o&&!ic(e)?J0(dl):""]))];if(!C&&!S)return Or([...re,">",Or([Mi,H(),Mi]),`</${d.name}>`]);if(Q&&q){const ae=[dl,Or([">",H(),`</${d.name}`])],ge=S&&!o||uG(d,e,r);return Or([...re,Or(S?ae:Du(ae)),ge?"":dl,">"])}let ue=dl,ce=dl;if(ic(e))ue="",ce="";else{let ae=!1;!Q&&U&&U.type==="Text"&&(L0(U)&&U!==z&&(!ac(e,r,d)||ph(z))?(ue=Mi,ce=Mi,ae=!0):ac(e,r,d)&&(ue=Ys),U0(U)),!q&&z&&z.type==="Text"&&(ac(e,r,d)&&!ae&&(ce=Ys),q0(z))}return Or(Q?[...re,Du([dl,Or([">",H()])]),ce,`</${d.name}>`]:q?[...re,">",Du([ue,Or([H(),`</${d.name}`])]),uG(d,e,r)?"":dl,">"]:S?[...re,">",H(),`</${d.name}>`]:[...re,">",Du([ue,H()]),ce,`</${d.name}>`])}case"Options":if(r.svelteSortOrder!=="none")throw new Error("Options tags should have been handled by prepareChildren");case"Body":case"Document":return Or(["<",d.name,Du(Or([...e.map(P0(d,r,n),"attributes"),o?"":J0(Ys)])),o?" ":"","/>"]);case"Document":return Or(["<",d.name,Du(Or([...e.map(P0(d,r,n),"attributes"),o?"":J0(Ys)])),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=!mT(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["{",La(e,n,"expression"),"}"];case"IfBlock":{const C=["{#if ",La(e,n,"expression"),"}",J_(e,n,r)];return d.else&&C.push(e.call(n,"else")),C.push("{/if}"),Or([C,z0])}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=>La(N,n,"expression"),"children")[0],"}",e.map(N=>J_(N,n,r),"children")[0]];return S.else&&P.push(e.map(N=>N.call(n,"else"),"children")[0]),P}return["{:else}",J_(e,n,r)]}case"EachBlock":{const C=["{#each ",La(e,n,"expression")," as",V0(d.context,r.originalText)];return d.index&&C.push(", ",d.index),d.key&&C.push(" (",La(e,n,"key"),")"),C.push("}",J_(e,n,r)),d.else&&C.push(e.call(n,"else")),C.push("{/each}"),Or([C,z0])}case"AwaitBlock":{const C=d.pending.children.some(_=>!ma(_)),S=d.then.children.some(_=>!ma(_)),P=d.catch.children.some(_=>!ma(_));let N=[];return!C&&S?N.push(Or(["{#await ",La(e,n,"expression")," then",V0(d.value,r.originalText),"}"]),e.call(n,"then")):!C&&P?N.push(Or(["{#await ",La(e,n,"expression")," catch",V0(d.error,r.originalText),"}"]),e.call(n,"catch")):(N.push(Or(["{#await ",La(e,n,"expression"),"}"])),C&&N.push(e.call(n,"pending")),S&&N.push(Or(["{:then",V0(d.value,r.originalText),"}"]),e.call(n,"then"))),(C||S)&&P&&N.push(Or(["{:catch",V0(d.error,r.originalText),"}"]),e.call(n,"catch")),N.push("{/await}"),Or(N)}case"KeyBlock":{const C=["{#key ",La(e,n,"expression"),"}",J_(e,n,r)];return C.push("{/key}"),Or([C,z0])}case"ThenBlock":case"PendingBlock":case"CatchBlock":return J_(e,n,r);case"SnippetBlock":{const C=["{#snippet ",La(e,n,"expression")];return C.push("}",J_(e,n,r),"{/snippet}"),C}case"EventHandler":return["on:",d.name,d.modifiers&&d.modifiers.length?["|",_h("|",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?["|",_h("|",d.modifiers)]:""];if(oG(d)||d.value===!0)return r.svelteAllowShorthand?[...D]:r.svelteStrictMode?[...D,'="{',d.name,'}"']:[...D,"={",d.name,"}"];{const C=!mT(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?[" ",_h(", ",e.map(n,"identifiers"))]:"","}"];case"Ref":return["ref:",d.name];case"Comment":{const C=qqe(e);if(hT(d)&&g9(d,e))yT=!0;else if(R0(d)&&g9(d,e))yT=!1;else{if(B0(d,e)||ma(C)&&B0(C,e))return"";iG(d)&&(H0=!0)}return cG(d)}case"Transition":return[d.intro&&d.outro?"transition":d.intro?"in":"out",":",d.name,d.modifiers&&d.modifiers.length?["|",_h("|",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 ",La(e,n,"expression"),"}"];case"RenderTag":return["{@render ",La(e,n,"expression"),"}"];case"Spread":return["{...",La(e,n,"expression"),"}"];case"ConstTag":return["{@const ",La(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=fT(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&&!C9(r.originalText)?["<!-- @format -->",Mi,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),dh&&a.options.push(dh);const u=QK(Bqe(r.svelteSortOrder).map(c=>a[c]));if(H0=!1,yT=!1,dh=void 0,r.parentParser==="markdown"){const c=u[u.length-1];I0([c],N0)}return r.insertPragma&&!C9(r.originalText)?["<!-- @format -->",Mi,Or(u)]:Or([_h(Mi,u)])}function lG(e,r,n,i){const a=e.map(o=>o.call(r),"value");return!n||!KK.includes(i.name)?a:Du(Or(f9(a,N0)))}function J_(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"?Mi:Ys,b=u==="none"?"":u==="line"||o==="line"?Mi:Ys,h=a[0],d=a[a.length-1];return j0(h)&&U0(h),ph(d)&&q0(d),[Du([c,Or(gT(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(D9),a.push(h)}):a.push(n.call(i,"children",u))}return a}function gT(e,r,n){if(ic(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):xu(D,n)?h(g):ac(e,n,D)?b(g):(a.push(c(g)),o=!1)}return i.length>1&&i.some(g=>xu(g,n))&&a.push(z0),a;function c(g){return e.call(r,"children",g)}function b(g){o?a.push(Or([Ys,c(g)])):a.push(c(g)),o=!1}function h(g){const D=i[g-1];D&&!xu(D,n)&&(D.type!=="Text"||o||!ph(D))&&a.push(dl),a.push(c(g));const E=i[g+1];E&&(E.type!=="Text"||(!ma(E)||i[g+2]&&ac(e,n,i[g+2]))&&!L0(E))&&a.push(dl),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(j0(D)&&!ma(D)){if(ac(e,n,E)&&!L0(D)){U0(D);const S=a.pop();a.push(Or([S,Ys]))}xu(E,n)&&!L0(D)&&U0(D)}ph(D)&&(ac(e,n,C)&&!v9(D)&&(o=!E||!xu(E,n),q0(D)),xu(C,n)&&!v9(D,2)&&(o=!E||!xu(E,n),q0(D))),a.push(c(g))}}function cUe(e,r,n,i){let a;const o=[],u=dT(i);for(let d=0;d<e.length;d++){const g=e[d];if(!(g.type==="Text"&&Xs(g)==="")&&!(ma(g)&&B0(g,r))){if(i.svelteSortOrder!=="none"){if(h(g,d)){a=cG(g);const D=e[d+1];d+=D&&ma(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){dh=Or([["<",d.name,Du(Or([...D.map(P0(d,i,E),"children",g,"attributes"),u?"":J0(Ys)])),u?" ":"","/>"],Mi]),a&&(dh=Or([a,Mi,dh]))}function h(d,g){if(d.type!=="Comment"||R0(d)||hT(d))return!1;const D=e[g+1];if(D){if(ma(D)){const E=e[g+2];return E&&E.type==="Options"}return D.type==="Options"}return!1}}function pUe(e){const r=Xs(e),n=r.split(/[\t\n\f\r ]+/);let i=_h(Ys,n).filter(a=>a!=="");return M0(r)&&(i[0]=Mi),M0(r,2)&&(i=[Mi,...i]),$0(r)&&(i[i.length-1]=Mi),$0(r,2)&&(i=[...i,Mi]),i}function La(e,r,n){return e.call(r,n)}function V0(e,r){let n=fl(e);return e!=null&&e.typeAnnotation&&(n+=": "+r.slice(e.typeAnnotation.start,e.typeAnnotation.end)),n}function fl(e,r){if(e===null)return"";if(typeof e=="string")return" "+e;switch(e.type){case"ArrayExpression":case"ArrayPattern":return" ["+e.elements.map(fl).join(",").slice(1)+"]";case"AssignmentPattern":return fl(e.left)+" ="+fl(e.right);case"Identifier":return" "+e.name;case"Literal":return" "+e.raw;case"ObjectExpression":return" {"+e.properties.map(n=>fl(n,e)).join(",")+" }";case"ObjectPattern":return" {"+e.properties.map(fl).join(",")+" }";case"Property":return e.value.type==="ObjectPattern"||e.value.type==="ArrayPattern"?" "+e.key.name+":"+fl(e.value):e.value.type==="Identifier"&&e.key.name!==e.value.name||r&&r.type==="ObjectExpression"?fl(e.key)+":"+fl(e.value):fl(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)),Or(["<!--",r,"-->"])}function bT(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 vT(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:S9,hardline:hp,softline:fUe,indent:_G,dedent:hUe,literalline:mUe},utils:{removeLines:yUe}}=a_,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(d9(E))return aUe(E),E.module&&(E.module.type="Script",E.module.attributes=pG(vT(E.module,C))),E.instance&&(E.instance.type="Script",E.instance.attributes=pG(vT(E.instance,C))),E.css&&(E.css.type="Style",E.css.content.type="StyleProgram"),null;const S=e.getParentNode(),P=()=>{var M;return S.expression?mp(S,(M=C.svelteStrictMode)!==null&&M!==void 0?M:!1,!1,!1,"expression"):void 0},N=M=>mp(S,!1,!0,!1,M);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":mp(S,(c=C.svelteStrictMode)!==null&&c!==void 0?c:!1,!1,!1,"tag");break;case"MustacheTag":mp(S,rUe(e,C),!1,!1,"expression");break;case"RawMustacheTag":mp(S,!1,!1,!1,"expression");break;case"Spread":mp(S,!1,!1,!1,"expression");break;case"ConstTag":mp(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),mp(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 M=>bT(this,void 0,void 0,function*(){try{const U={parser:"svelteExpressionParser",singleQuote:E.forceSingleQuote?!0:C.singleQuote,_svelte_asFunction:E.asFunction},z=vT(E,C,!0);let H=yield M(E.asFunction?CUe(z):DUe(z),U);if(E.forceSingleLine&&(H=yUe(H)),E.removeParentheses&&(H=$qe(H)),E.asFunction)if(Array.isArray(H)&&typeof H[0]=="string")H[0]=H[0].replace("function ",""),H.splice(-1,1);else throw new Error("Prettier AST changed, asFunction logic needs to change");return H}catch{return vT(E,C,!0)}});const _=(M,U,z)=>(H,Q)=>bT(this,void 0,void 0,function*(){return EUe(M,C.originalText,e,q=>TUe(q,U,H,C),Q,z,C)}),F=M=>_("script",Hqe(E)?"typescript":Vqe(E)?"json":"babel-ts",M),L=M=>_("style",Wqe(E)?"less":Kqe(E)?"scss":"css",M),I=()=>_("template","pug",!1);switch(E.type){case"Script":return F(!0);case"Style":return L(!0);case"Element":{if(E.name==="script")return F(!1);if(E.name==="style")return L(!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,""),hp]}function SUe(e){const r=b9(F0,e);return r?GK(r):""}function TUe(e,r,n,i){return bT(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[hp,c]}const o=u=>i.svelteIndentScriptAndStyle?_G(u):u;return I0([a],N0),[o([hp,a]),hp]}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 bT(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===""?"":hp:dG(h),E=S9(["<",e,_G(S9([...n.map(P0(b,u,a),"attributes"),dT(u)?"":hUe(fUe)])),">"]);let C=S9([E,D,"</",e,">"]);const S=[];for(const P of d)S.push("<!--",P.comment.data,"-->"),S.push(hp),P.emptyLineAfter&&S.push(hp);return o&&u.svelteSortOrder!=="none"?[...S,C,hp]:o&&S.length?[...S,C]:C})}function mp(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=x8.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:C9,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 _8(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,7 +20,7 @@
|
|
|
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-
|
|
23
|
+
<script type="module" crossorigin src="/assets/index-pzvwg1lq.js"></script>
|
|
24
24
|
<link rel="stylesheet" crossorigin href="/assets/index-9yhZQKtK.css">
|
|
25
25
|
</head>
|
|
26
26
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vzcode",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.89.0",
|
|
4
4
|
"description": "Multiplayer code editor system",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -67,15 +67,15 @@
|
|
|
67
67
|
},
|
|
68
68
|
"homepage": "https://github.com/vizhub-core/vzcode#readme",
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@codemirror/autocomplete": "^6.
|
|
70
|
+
"@codemirror/autocomplete": "^6.16.0",
|
|
71
71
|
"@codemirror/lang-css": "^6.2.1",
|
|
72
|
-
"@codemirror/lang-html": "^6.4.
|
|
72
|
+
"@codemirror/lang-html": "^6.4.9",
|
|
73
73
|
"@codemirror/lang-javascript": "^6.2.2",
|
|
74
74
|
"@codemirror/lang-json": "^6.0.1",
|
|
75
|
-
"@codemirror/lang-markdown": "^6.2.
|
|
75
|
+
"@codemirror/lang-markdown": "^6.2.5",
|
|
76
76
|
"@codemirror/state": "^6.4.1",
|
|
77
77
|
"@codemirror/theme-one-dark": "^6.1.2",
|
|
78
|
-
"@codemirror/view": "^6.26.
|
|
78
|
+
"@codemirror/view": "^6.26.3",
|
|
79
79
|
"@lezer/highlight": "^1.2.0",
|
|
80
80
|
"@replit/codemirror-indentation-markers": "^6.5.1",
|
|
81
81
|
"@replit/codemirror-interact": "^6.3.1",
|
|
@@ -104,8 +104,8 @@
|
|
|
104
104
|
"json0-ot-diff": "^1.1.2",
|
|
105
105
|
"ngrok": "^4.3.3",
|
|
106
106
|
"open": "^10.1.0",
|
|
107
|
-
"openai": "^4.
|
|
108
|
-
"prettier-plugin-svelte": "^3.2.
|
|
107
|
+
"openai": "^4.36.0",
|
|
108
|
+
"prettier-plugin-svelte": "^3.2.3",
|
|
109
109
|
"react": "^18.2.0",
|
|
110
110
|
"react-bootstrap": "^2.10.2",
|
|
111
111
|
"react-dom": "^18.2.0",
|
|
@@ -116,14 +116,14 @@
|
|
|
116
116
|
"ws": "^8.16.0"
|
|
117
117
|
},
|
|
118
118
|
"devDependencies": {
|
|
119
|
-
"@types/react": "^18.2.
|
|
120
|
-
"@types/react-dom": "^18.2.
|
|
119
|
+
"@types/react": "^18.2.79",
|
|
120
|
+
"@types/react-dom": "^18.2.25",
|
|
121
121
|
"@vitejs/plugin-react": "^4.2.1",
|
|
122
122
|
"concurrently": "^8.2.2",
|
|
123
123
|
"prettier": "^3.2.5",
|
|
124
|
-
"sass": "^1.
|
|
125
|
-
"typescript": "^5.4.
|
|
126
|
-
"vite": "^5.2.
|
|
127
|
-
"vitest": "^1.
|
|
124
|
+
"sass": "^1.75.0",
|
|
125
|
+
"typescript": "^5.4.5",
|
|
126
|
+
"vite": "^5.2.9",
|
|
127
|
+
"vitest": "^1.5.0"
|
|
128
128
|
}
|
|
129
129
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// From https://heroicons.com/
|
|
2
|
+
export const QuestionMarkSVG = () => (
|
|
3
|
+
<svg
|
|
4
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
5
|
+
fill="none"
|
|
6
|
+
width="24"
|
|
7
|
+
height="24"
|
|
8
|
+
viewBox="0 0 24 24"
|
|
9
|
+
strokeWidth="1.5"
|
|
10
|
+
stroke="currentColor"
|
|
11
|
+
>
|
|
12
|
+
<path
|
|
13
|
+
strokeLinecap="round"
|
|
14
|
+
strokeLinejoin="round"
|
|
15
|
+
d="M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9 5.25h.008v.008H12v-.008Z"
|
|
16
|
+
/>
|
|
17
|
+
</svg>
|
|
18
|
+
);
|
|
@@ -30,7 +30,7 @@ const localStorageWriteDebounceMS = 800;
|
|
|
30
30
|
const sidebarWidthProperty = 'vzCodeSidebarWidth';
|
|
31
31
|
const codeEditorWidthProperty = 'vzCodeCodeEditorWidth';
|
|
32
32
|
|
|
33
|
-
const initialSidebarWidthDefault =
|
|
33
|
+
const initialSidebarWidthDefault = 250;
|
|
34
34
|
let initialSidebarWidth: number =
|
|
35
35
|
initialSidebarWidthDefault;
|
|
36
36
|
|
|
@@ -87,6 +87,10 @@ export type VZCodeContextValue = {
|
|
|
87
87
|
setIsSettingsOpen: (isSettingsOpen: boolean) => void;
|
|
88
88
|
closeSettings: () => void;
|
|
89
89
|
|
|
90
|
+
isDocOpen: boolean;
|
|
91
|
+
setIsDocOpen: (isDocOpen: boolean) => void;
|
|
92
|
+
closeDoc: () => void;
|
|
93
|
+
|
|
90
94
|
theme: ThemeLabel;
|
|
91
95
|
setTheme: (theme: ThemeLabel) => void;
|
|
92
96
|
|
|
@@ -204,6 +208,7 @@ export const VZCodeProvider = ({
|
|
|
204
208
|
activeFileId,
|
|
205
209
|
theme,
|
|
206
210
|
isSettingsOpen,
|
|
211
|
+
isDocOpen,
|
|
207
212
|
editorWantsFocus,
|
|
208
213
|
username,
|
|
209
214
|
} = state;
|
|
@@ -217,7 +222,9 @@ export const VZCodeProvider = ({
|
|
|
217
222
|
closeTabs,
|
|
218
223
|
setTheme,
|
|
219
224
|
setIsSettingsOpen,
|
|
225
|
+
setIsDocOpen,
|
|
220
226
|
closeSettings,
|
|
227
|
+
closeDoc,
|
|
221
228
|
editorNoLongerWantsFocus,
|
|
222
229
|
setUsername,
|
|
223
230
|
} = useActions(dispatch);
|
|
@@ -344,6 +351,10 @@ export const VZCodeProvider = ({
|
|
|
344
351
|
setIsSettingsOpen,
|
|
345
352
|
closeSettings,
|
|
346
353
|
|
|
354
|
+
isDocOpen,
|
|
355
|
+
setIsDocOpen,
|
|
356
|
+
closeDoc,
|
|
357
|
+
|
|
347
358
|
theme,
|
|
348
359
|
setTheme,
|
|
349
360
|
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import React, { useCallback, useContext } from 'react';
|
|
2
|
+
import { Button, Modal, Form } from './bootstrap';
|
|
3
|
+
import { ThemeLabel, themes } from './themes';
|
|
4
|
+
import { VZCodeContext } from './VZCodeContext';
|
|
5
|
+
|
|
6
|
+
export const VZKeyboardShortcutsDoc = ({
|
|
7
|
+
enableUsernameField = true,
|
|
8
|
+
}: {
|
|
9
|
+
// Feature flag to enable/disable username field
|
|
10
|
+
enableUsernameField?: boolean;
|
|
11
|
+
}) => {
|
|
12
|
+
const {
|
|
13
|
+
isDocOpen,
|
|
14
|
+
closeDoc,
|
|
15
|
+
|
|
16
|
+
setTheme,
|
|
17
|
+
|
|
18
|
+
setUsername,
|
|
19
|
+
} = useContext(VZCodeContext);
|
|
20
|
+
|
|
21
|
+
const handleThemeChange = useCallback(
|
|
22
|
+
(event: React.ChangeEvent<HTMLSelectElement>) => {
|
|
23
|
+
setTheme(event.target.value as ThemeLabel);
|
|
24
|
+
},
|
|
25
|
+
[],
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
return isDocOpen ? (
|
|
29
|
+
<Modal
|
|
30
|
+
className="vz-settings"
|
|
31
|
+
show={isDocOpen}
|
|
32
|
+
onHide={closeDoc}
|
|
33
|
+
animation={false}
|
|
34
|
+
>
|
|
35
|
+
<Modal.Header closeButton>
|
|
36
|
+
<Modal.Title>Keyboard Shortcuts</Modal.Title>
|
|
37
|
+
</Modal.Header>
|
|
38
|
+
<Modal.Body className="pt-1">
|
|
39
|
+
<Form.Group className="mb-3">
|
|
40
|
+
<Form.Text className="text-muted">
|
|
41
|
+
Keyboard shortcuts and interactive widgets for
|
|
42
|
+
quick actions
|
|
43
|
+
</Form.Text>
|
|
44
|
+
</Form.Group>
|
|
45
|
+
<Form.Group>
|
|
46
|
+
{/* <Form.Label>WINDOWS</Form.Label> */}
|
|
47
|
+
<ul>
|
|
48
|
+
<li>
|
|
49
|
+
<strong>Ctrl + s</strong> or{' '}
|
|
50
|
+
<strong>Shift + Enter</strong> <br />
|
|
51
|
+
<span>Run and format code</span>
|
|
52
|
+
</li>
|
|
53
|
+
<li>
|
|
54
|
+
<strong>Alt + drag on a number</strong>
|
|
55
|
+
<br />
|
|
56
|
+
<span>
|
|
57
|
+
Modify the number by dragging left or right
|
|
58
|
+
</span>
|
|
59
|
+
</li>
|
|
60
|
+
<li>
|
|
61
|
+
<strong>Alt + click on a hex color</strong>
|
|
62
|
+
<br />
|
|
63
|
+
<span>
|
|
64
|
+
Open a color picker to modify the color
|
|
65
|
+
</span>
|
|
66
|
+
</li>
|
|
67
|
+
<li>
|
|
68
|
+
<strong>Alt + w</strong> <br />
|
|
69
|
+
<span>Close the current tab</span>
|
|
70
|
+
</li>
|
|
71
|
+
<li>
|
|
72
|
+
<strong>Alt + n</strong> <br />
|
|
73
|
+
<span>Open the create file modal</span>
|
|
74
|
+
</li>
|
|
75
|
+
<li>
|
|
76
|
+
<strong>Alt + Page Up</strong> <br />
|
|
77
|
+
<span>
|
|
78
|
+
Change the active tab to the previous one
|
|
79
|
+
</span>
|
|
80
|
+
</li>
|
|
81
|
+
<li>
|
|
82
|
+
<strong>Alt + Page Down</strong> <br />
|
|
83
|
+
<span>
|
|
84
|
+
Change the active tab to the next one
|
|
85
|
+
</span>
|
|
86
|
+
</li>
|
|
87
|
+
<li>
|
|
88
|
+
<strong>Most VSCode Shortcuts</strong> <br />
|
|
89
|
+
See VSCode docs:{' '}
|
|
90
|
+
<a
|
|
91
|
+
href="https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf"
|
|
92
|
+
target="_blank"
|
|
93
|
+
>
|
|
94
|
+
Windows
|
|
95
|
+
</a>
|
|
96
|
+
,{' '}
|
|
97
|
+
<a
|
|
98
|
+
href="https://code.visualstudio.com/shortcuts/keyboard-shortcuts-macos.pdf"
|
|
99
|
+
target="_blank"
|
|
100
|
+
>
|
|
101
|
+
MacOS
|
|
102
|
+
</a>
|
|
103
|
+
,{' '}
|
|
104
|
+
<a
|
|
105
|
+
href="https://code.visualstudio.com/shortcuts/keyboard-shortcuts-linux.pdf"
|
|
106
|
+
target="_blank"
|
|
107
|
+
>
|
|
108
|
+
Linux
|
|
109
|
+
</a>
|
|
110
|
+
</li>
|
|
111
|
+
</ul>
|
|
112
|
+
</Form.Group>
|
|
113
|
+
</Modal.Body>
|
|
114
|
+
<Modal.Footer>
|
|
115
|
+
<Button variant="primary" onClick={closeDoc}>
|
|
116
|
+
Done
|
|
117
|
+
</Button>
|
|
118
|
+
</Modal.Footer>
|
|
119
|
+
</Modal>
|
|
120
|
+
) : null;
|
|
121
|
+
};
|
package/src/client/VZLeft.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { VZSettings } from './VZSettings';
|
|
2
|
+
import { VZKeyboardShortcutsDoc } from './VZKeyboardShortcutsDoc';
|
|
2
3
|
import { VZSidebar } from './VZSidebar';
|
|
3
4
|
import { CreateFileModal } from './VZSidebar/CreateFileModal';
|
|
4
5
|
import { CreateDirModal } from './VZSidebar/CreateDirModal';
|
|
@@ -14,6 +15,9 @@ export const VZLeft = ({ enableUsernameField = true }) => {
|
|
|
14
15
|
<VZSettings
|
|
15
16
|
enableUsernameField={enableUsernameField}
|
|
16
17
|
/>
|
|
18
|
+
<VZKeyboardShortcutsDoc
|
|
19
|
+
enableUsernameField={enableUsernameField}
|
|
20
|
+
/>
|
|
17
21
|
<CreateFileModal />
|
|
18
22
|
<CreateDirModal />
|
|
19
23
|
</div>
|
|
@@ -35,14 +35,43 @@ export const VZSettings = ({
|
|
|
35
35
|
);
|
|
36
36
|
|
|
37
37
|
// Initialize font and size from localStorage or defaults
|
|
38
|
-
const [selectedFont, setSelectedFont] = useState(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
);
|
|
42
|
-
const [selectedFontSize, setSelectedFontSize] = useState(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
);
|
|
38
|
+
// const [selectedFont, setSelectedFont] = useState(
|
|
39
|
+
// localStorage.getItem('vzcodeSelectedFont') ||
|
|
40
|
+
// 'Roboto Mono',
|
|
41
|
+
// );
|
|
42
|
+
// const [selectedFontSize, setSelectedFontSize] = useState(
|
|
43
|
+
// localStorage.getItem('vzcodeSelectedFontSize') ||
|
|
44
|
+
// '16px',
|
|
45
|
+
// );
|
|
46
|
+
const [selectedFont, setSelectedFont] =
|
|
47
|
+
useState('Roboto Mono');
|
|
48
|
+
const [selectedFontSize, setSelectedFontSize] =
|
|
49
|
+
useState('16px');
|
|
50
|
+
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
// If we're in the browser,
|
|
53
|
+
if (typeof window !== 'undefined') {
|
|
54
|
+
const selectedFontFromLocalStorage: string | null =
|
|
55
|
+
window.localStorage.getItem('vzcodeSelectedFont');
|
|
56
|
+
|
|
57
|
+
const selectedFontSizeFromLocalStorage:
|
|
58
|
+
| string
|
|
59
|
+
| null = window.localStorage.getItem(
|
|
60
|
+
'vzcodeSelectedFontSize',
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
if (selectedFontFromLocalStorage !== null) {
|
|
64
|
+
setSelectedFont(selectedFontFromLocalStorage);
|
|
65
|
+
}
|
|
66
|
+
if (selectedFontSizeFromLocalStorage !== null) {
|
|
67
|
+
setSelectedFontSize(
|
|
68
|
+
selectedFontSizeFromLocalStorage,
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
// If we're not in the browser, use the default initial width.
|
|
73
|
+
}
|
|
74
|
+
}, []);
|
|
46
75
|
|
|
47
76
|
// Called when the user selects a different font
|
|
48
77
|
const handleFontChange = useCallback(
|
|
@@ -135,6 +164,7 @@ export const VZSettings = ({
|
|
|
135
164
|
|
|
136
165
|
<Form.Group className="mb-3" controlId="formFork">
|
|
137
166
|
<Form.Label>Font</Form.Label>
|
|
167
|
+
|
|
138
168
|
<select
|
|
139
169
|
className="form-select"
|
|
140
170
|
onChange={handleFontChange}
|
|
@@ -146,6 +176,7 @@ export const VZSettings = ({
|
|
|
146
176
|
</option>
|
|
147
177
|
))}
|
|
148
178
|
</select>
|
|
179
|
+
|
|
149
180
|
<Form.Text className="text-muted">
|
|
150
181
|
Select font for the editor
|
|
151
182
|
</Form.Text>
|
|
@@ -153,6 +184,7 @@ export const VZSettings = ({
|
|
|
153
184
|
|
|
154
185
|
<Form.Group className="mb-3" controlId="formFork">
|
|
155
186
|
<Form.Label>Font Size</Form.Label>
|
|
187
|
+
|
|
156
188
|
<select
|
|
157
189
|
className="form-select"
|
|
158
190
|
onChange={handleFontSizeChange}
|
|
@@ -164,51 +196,9 @@ export const VZSettings = ({
|
|
|
164
196
|
</option>
|
|
165
197
|
))}
|
|
166
198
|
</select>
|
|
167
|
-
<Form.Text className="text-muted">
|
|
168
|
-
Select a font size for the editor
|
|
169
|
-
</Form.Text>
|
|
170
|
-
</Form.Group>
|
|
171
199
|
|
|
172
|
-
{/* Keyboard Shortcuts Documentation */}
|
|
173
|
-
<Form.Group className="mb-3" controlId="formFork">
|
|
174
|
-
<Form.Label>Keyboard Shortcuts</Form.Label>
|
|
175
|
-
<ul>
|
|
176
|
-
<li>
|
|
177
|
-
<strong>Alt-w</strong> <span>⌥W</span>
|
|
178
|
-
<br />
|
|
179
|
-
<span>Close the current tab</span>
|
|
180
|
-
</li>
|
|
181
|
-
<li>
|
|
182
|
-
<strong>Alt-n</strong> <span>⌥N</span>
|
|
183
|
-
<br />
|
|
184
|
-
<span>Open the create file modal</span>
|
|
185
|
-
</li>
|
|
186
|
-
<li>
|
|
187
|
-
<strong>Alt-PageUp</strong> <span>⌥⇞</span>
|
|
188
|
-
<br />
|
|
189
|
-
<span>
|
|
190
|
-
Change the active tab to the previous one
|
|
191
|
-
</span>
|
|
192
|
-
</li>
|
|
193
|
-
<li>
|
|
194
|
-
<strong>Alt-PageDown</strong> <span>⌥⇟</span>
|
|
195
|
-
<br />
|
|
196
|
-
<span>
|
|
197
|
-
Change the active tab to the next one
|
|
198
|
-
</span>
|
|
199
|
-
</li>
|
|
200
|
-
<li>
|
|
201
|
-
<strong>Ctrl-s</strong> or{' '}
|
|
202
|
-
<strong>Shift-Enter</strong> <span>⌘S</span>{' '}
|
|
203
|
-
or <span>⇧↩</span>
|
|
204
|
-
<br />
|
|
205
|
-
<span>
|
|
206
|
-
Run the code and format it with Prettier
|
|
207
|
-
</span>
|
|
208
|
-
</li>
|
|
209
|
-
</ul>
|
|
210
200
|
<Form.Text className="text-muted">
|
|
211
|
-
|
|
201
|
+
Select a font size for the editor
|
|
212
202
|
</Form.Text>
|
|
213
203
|
</Form.Group>
|
|
214
204
|
</Modal.Body>
|
|
@@ -15,6 +15,7 @@ export const CreateDirModal = ({
|
|
|
15
15
|
const inputRef = useRef(null);
|
|
16
16
|
|
|
17
17
|
const {
|
|
18
|
+
files,
|
|
18
19
|
isCreateDirModalOpen,
|
|
19
20
|
handleCloseCreateDirModal,
|
|
20
21
|
handleCreateDirClick,
|
|
@@ -38,11 +39,22 @@ export const CreateDirModal = ({
|
|
|
38
39
|
// Returns true if file name is valid, false otherwise.
|
|
39
40
|
const validateFileName = useCallback(
|
|
40
41
|
(fileName: string) => {
|
|
42
|
+
let valid;
|
|
43
|
+
//General Character Check
|
|
41
44
|
const regex =
|
|
42
45
|
/^[a-zA-Z0-9](?:[a-zA-Z0-9 ./+=_-]*[a-zA-Z0-9])?$/;
|
|
43
|
-
|
|
46
|
+
valid = regex.test(fileName);
|
|
47
|
+
|
|
48
|
+
//Check for Duplicate Filename
|
|
49
|
+
for (const key in files) {
|
|
50
|
+
if (fileName + '/' === files[key].name) {
|
|
51
|
+
valid = false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return valid;
|
|
44
56
|
},
|
|
45
|
-
[],
|
|
57
|
+
[files],
|
|
46
58
|
);
|
|
47
59
|
|
|
48
60
|
const handleKeyDown = useCallback(
|
|
@@ -15,6 +15,7 @@ export const CreateFileModal = ({
|
|
|
15
15
|
const inputRef = useRef(null);
|
|
16
16
|
|
|
17
17
|
const {
|
|
18
|
+
files,
|
|
18
19
|
isCreateFileModalOpen,
|
|
19
20
|
handleCloseCreateFileModal,
|
|
20
21
|
handleCreateFileClick,
|
|
@@ -38,11 +39,22 @@ export const CreateFileModal = ({
|
|
|
38
39
|
// Returns true if file name is valid, false otherwise.
|
|
39
40
|
const validateFileName = useCallback(
|
|
40
41
|
(fileName: string) => {
|
|
42
|
+
let valid;
|
|
43
|
+
//General Character Check
|
|
41
44
|
const regex =
|
|
42
45
|
/^[a-zA-Z0-9](?:[a-zA-Z0-9 ./+=_-]*[a-zA-Z0-9])?$/;
|
|
43
|
-
|
|
46
|
+
valid = regex.test(fileName);
|
|
47
|
+
|
|
48
|
+
//Check for Duplicate Filename
|
|
49
|
+
for (const key in files) {
|
|
50
|
+
if (fileName === files[key].name) {
|
|
51
|
+
valid = false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return valid;
|
|
44
56
|
},
|
|
45
|
-
[],
|
|
57
|
+
[files],
|
|
46
58
|
);
|
|
47
59
|
|
|
48
60
|
const handleKeyDown = useCallback(
|