vzcode 0.21.0 → 0.24.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.
@@ -0,0 +1 @@
1
+ .vz-code-editor{flex:1;display:flex;font-family:var(--vzcode-font-family);overflow-x:auto}.vz-code-editor .cm-editor{flex:1}.vz-sidebar{height:100%;background:rgb(54,65,89);display:flex;flex-direction:column;justify-content:space-between}.vz-sidebar .full-box{padding:7px;display:flex;flex-direction:row;align-items:center;justify-content:space-between}.vz-sidebar .files{overflow:auto}.vz-sidebar .file-or-directory{display:flex;flex-direction:row;align-items:center;justify-content:space-between;cursor:pointer;margin:0 10px;color:#dbdde1;border-radius:5px}.vz-sidebar .link-name{margin-top:30px;margin-left:10px;color:#9aa0ac;font-size:12px;text-decoration:none}.vz-sidebar .new-btn{justify-content:right;margin-right:10px;cursor:pointer}.vz-sidebar .utils{display:flex}.vz-sidebar .utilities{margin-right:3px}.vz-sidebar .file-or-directory:hover,.vz-sidebar .settings:hover{background-color:#4a5469}.vz-sidebar .name{display:flex;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.vz-sidebar .indentation{margin-left:20px}.vz-sidebar .arrow-wrapper{margin-right:4px}.vz-sidebar .settings{height:30px;color:#dbdde1;cursor:pointer;display:flex;align-items:center;justify-content:center;padding:14px 0;margin:10px;border-radius:5px}.vz-tab-list{display:flex;background-color:#252526;overflow-x:auto}.vz-tab-list .tab{background:rgb(45,45,45);color:#fff;font-family:var(--vzcode-font-family);align-items:center;display:flex;padding-top:2px;padding-left:10px;padding-right:10px;border-top-left-radius:10px;border-top-right-radius:10px;margin-top:5px;margin-left:2px;margin-right:2px;cursor:pointer;white-space:nowrap}.vz-tab-list .tab .tab-close{margin-left:5px}.vz-tab-list .tab .tab-close:hover{border-radius:30%;background-color:#252526}.vz-tab-list .tab.active{background-color:#292c34}.vz-resizer{position:absolute;top:0;left:0;bottom:0}.vz-resizer:hover{cursor:col-resize}.vz-resizer .vz-resizer-thumb{position:absolute;top:0;bottom:0;transition:background-color .15s .25s}.vz-resizer:hover .vz-resizer-thumb{background-color:#0078d4}.vz-notification{position:fixed;display:flex;flex-direction:column;gap:10px;bottom:20px;right:20px;color:#9aa0ac;padding:15px}.vz-notification .vz-notification-item{background-color:#364159;padding:5px;border-radius:5px}:root{--vzcode-font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace;--vz-bg-color: rgb( 41, 44, 52 )}::-webkit-scrollbar{width:10px;height:10px}::-webkit-scrollbar-track{background:var(--app-bg-color)}::-webkit-scrollbar-thumb{background:rgb(37,37,38)}::-webkit-scrollbar-thumb:hover{background:#555}html,body,#root,.app{height:100%}.app{background-color:var(--vz-bg-color);font-family:Poppins,sans-serif;display:flex;position:relative}.app .left,.app .right{display:flex;position:relative}.app .right{flex:1;flex-direction:column;min-width:0}.prettier-error-overlay{color:#ff3535;background-color:#0009;position:absolute;bottom:0;left:0;right:0;pointer-events:none}
@@ -234,4 +234,4 @@ ${j.join(`
234
234
  `;N=N.replace(n,"").replace(r,"").replace(v,"$1");let k="";for(;k!==N;)k=N,N=N.replace(_,`${m}$1 $2${m}`);N=N.replace(u,"").trimRight();let F=Object.create(null),q=N.replace(f,"").replace(u,"").trimRight(),$;for(;$=f.exec(N);){let R=$[2].replace(s,"");typeof F[$[1]]=="string"||Array.isArray(F[$[1]])?F[$[1]]=g.concat(F[$[1]],R):F[$[1]]=R}return{comments:q,pragmas:F}}function S({comments:N="",pragmas:m={}}){let k=`
235
235
  `,F="/**",q=" *",$=" */",R=Object.keys(m),H=R.map(X=>L(X,m[X])).reduce((X,ne)=>X.concat(ne),[]).map(X=>`${q} ${X}${k}`).join("");if(!N){if(R.length===0)return"";if(R.length===1&&!Array.isArray(m[R[0]])){let X=m[R[0]];return`${F} ${L(R[0],X)[0]}${$}`}}let U=N.split(k).map(X=>`${q} ${X}`).join(k)+k;return F+k+(N?U:"")+(N&&R.length?q+k:"")+H+$}function L(N,m){return g.concat(m).map(k=>`@${N} ${k}`.trim())}}),BP={};UT(BP,{parsers:()=>HT});var HT={};UT(HT,{typescript:()=>roe});var xse=AP(Dse(),1);function vse(t,r){let n=new SyntaxError(t+" ("+r.loc.start.line+":"+r.loc.start.column+")");return Object.assign(n,r)}var Tse=vse;function Sse(t){let r=[];for(let n of t)try{return n()}catch(a){r.push(a)}throw Object.assign(new Error("All combinations failed"),{errors:r})}var Cse=Sse,OP=AP(bse(),1);function Ase(t){if(!t.startsWith("#!"))return"";let r=t.indexOf(`
236
236
  `);return r===-1?t:t.slice(0,r)}var Ese=Ase;function wse(t){let r=Ese(t);r&&(t=t.slice(r.length+1));let n=(0,OP.extract)(t),{pragmas:a,comments:s}=(0,OP.parseWithComments)(n);return{shebang:r,text:t,pragmas:a,comments:s}}function kse(t){let{pragmas:r}=wse(t);return Object.prototype.hasOwnProperty.call(r,"prettier")||Object.prototype.hasOwnProperty.call(r,"format")}function Fse(t){return Array.isArray(t)&&t.length>0}var LP=Fse;function ao(t){var r;let n=t.range?t.range[0]:t.start,a=((r=t.declaration)==null?void 0:r.decorators)??t.decorators;return LP(a)?Math.min(ao(a[0]),n):n}function tc(t){return t.range?t.range[1]:t.end}function Pse(t){return t=typeof t=="function"?{parse:t}:t,{astFormat:"estree",hasPragma:kse,locStart:ao,locEnd:tc,...t}}var Nse=Pse;function Ise(t){return t.charAt(0)==="#"&&t.charAt(1)==="!"?"//"+t.slice(2):t}var Bse=Ise,Ose=(t,r,n)=>{if(!(t&&r==null))return Array.isArray(r)||typeof r=="string"?r[n<0?r.length+n:n]:r.at(n)},MP=Ose;function Lse(t){return t=new Set(t),r=>t.has(r==null?void 0:r.type)}var Mse=Lse,jse=Mse(["Block","CommentBlock","MultiLine"]),GT=jse;function Rse(t){return GT(t)&&t.value[0]==="*"&&/@(?:type|satisfies)\b/.test(t.value)}var $se=Rse;function Jse(t){let r=`*${t.value}*`.split(`
237
- `);return r.length>1&&r.every(n=>n.trimStart()[0]==="*")}var jP=Jse,Th=null;function Sh(t){if(Th!==null&&typeof Th.property){let r=Th;return Th=Sh.prototype=null,r}return Th=Sh.prototype=t??Object.create(null),new Sh}var qse=10;for(let t=0;t<=qse;t++)Sh();function Use(t){return Sh(t)}function zse(t,r="type"){Use(t);function n(a){let s=a[r],u=t[s];if(!Array.isArray(u))throw Object.assign(new Error(`Missing visitor keys for '${s}'.`),{node:a});return u}return n}var Kse=zse,Wse={ArrayExpression:["elements"],AssignmentExpression:["left","right"],BinaryExpression:["left","right"],InterpreterDirective:[],Directive:["value"],DirectiveLiteral:[],BlockStatement:["directives","body"],BreakStatement:["label"],CallExpression:["callee","arguments","typeParameters","typeArguments"],CatchClause:["param","body"],ConditionalExpression:["test","consequent","alternate"],ContinueStatement:["label"],DebuggerStatement:[],DoWhileStatement:["test","body"],EmptyStatement:[],ExpressionStatement:["expression"],File:["program"],ForInStatement:["left","right","body"],ForStatement:["init","test","update","body"],FunctionDeclaration:["id","params","body","returnType","typeParameters","predicate"],FunctionExpression:["id","params","body","returnType","typeParameters"],Identifier:["typeAnnotation","decorators"],IfStatement:["test","consequent","alternate"],LabeledStatement:["label","body"],StringLiteral:[],NumericLiteral:[],NullLiteral:[],BooleanLiteral:[],RegExpLiteral:[],LogicalExpression:["left","right"],MemberExpression:["object","property"],NewExpression:["callee","arguments","typeParameters","typeArguments"],Program:["directives","body"],ObjectExpression:["properties"],ObjectMethod:["key","params","body","decorators","returnType","typeParameters"],ObjectProperty:["key","value","decorators"],RestElement:["argument","typeAnnotation","decorators"],ReturnStatement:["argument"],SequenceExpression:["expressions"],ParenthesizedExpression:["expression"],SwitchCase:["test","consequent"],SwitchStatement:["discriminant","cases"],ThisExpression:[],ThrowStatement:["argument"],TryStatement:["block","handler","finalizer"],UnaryExpression:["argument"],UpdateExpression:["argument"],VariableDeclaration:["declarations"],VariableDeclarator:["id","init"],WhileStatement:["test","body"],WithStatement:["object","body"],AssignmentPattern:["left","right","decorators","typeAnnotation"],ArrayPattern:["elements","typeAnnotation","decorators"],ArrowFunctionExpression:["params","body","returnType","typeParameters","predicate"],ClassBody:["body"],ClassExpression:["id","body","superClass","mixins","typeParameters","superTypeParameters","implements","decorators","superTypeArguments"],ClassDeclaration:["id","body","superClass","mixins","typeParameters","superTypeParameters","implements","decorators","superTypeArguments"],ExportAllDeclaration:["source","attributes","assertions","exported"],ExportDefaultDeclaration:["declaration"],ExportNamedDeclaration:["declaration","specifiers","source","attributes","assertions"],ExportSpecifier:["local","exported"],ForOfStatement:["left","right","body"],ImportDeclaration:["specifiers","source","attributes","assertions"],ImportDefaultSpecifier:["local"],ImportNamespaceSpecifier:["local"],ImportSpecifier:["local","imported"],MetaProperty:["meta","property"],ClassMethod:["key","params","body","decorators","returnType","typeParameters"],ObjectPattern:["properties","typeAnnotation","decorators"],SpreadElement:["argument"],Super:[],TaggedTemplateExpression:["tag","quasi","typeParameters","typeArguments"],TemplateElement:[],TemplateLiteral:["quasis","expressions"],YieldExpression:["argument"],AwaitExpression:["argument"],Import:[],BigIntLiteral:[],ExportNamespaceSpecifier:["exported"],OptionalMemberExpression:["object","property"],OptionalCallExpression:["callee","arguments","typeParameters","typeArguments"],ClassProperty:["key","value","typeAnnotation","decorators","variance"],ClassAccessorProperty:["key","value","typeAnnotation","decorators"],ClassPrivateProperty:["key","value","decorators","typeAnnotation","variance"],ClassPrivateMethod:["key","params","body","decorators","returnType","typeParameters"],PrivateName:["id"],StaticBlock:["body"],AnyTypeAnnotation:[],ArrayTypeAnnotation:["elementType"],BooleanTypeAnnotation:[],BooleanLiteralTypeAnnotation:[],NullLiteralTypeAnnotation:[],ClassImplements:["id","typeParameters"],DeclareClass:["id","typeParameters","extends","mixins","implements","body"],DeclareFunction:["id","predicate"],DeclareInterface:["id","typeParameters","extends","body"],DeclareModule:["id","body"],DeclareModuleExports:["typeAnnotation"],DeclareTypeAlias:["id","typeParameters","right"],DeclareOpaqueType:["id","typeParameters","supertype"],DeclareVariable:["id"],DeclareExportDeclaration:["declaration","specifiers","source"],DeclareExportAllDeclaration:["source"],DeclaredPredicate:["value"],ExistsTypeAnnotation:[],FunctionTypeAnnotation:["typeParameters","params","rest","returnType","this"],FunctionTypeParam:["name","typeAnnotation"],GenericTypeAnnotation:["id","typeParameters"],InferredPredicate:[],InterfaceExtends:["id","typeParameters"],InterfaceDeclaration:["id","typeParameters","extends","body"],InterfaceTypeAnnotation:["extends","body"],IntersectionTypeAnnotation:["types"],MixedTypeAnnotation:[],EmptyTypeAnnotation:[],NullableTypeAnnotation:["typeAnnotation"],NumberLiteralTypeAnnotation:[],NumberTypeAnnotation:[],ObjectTypeAnnotation:["properties","indexers","callProperties","internalSlots"],ObjectTypeInternalSlot:["id","value","optional","static","method"],ObjectTypeCallProperty:["value"],ObjectTypeIndexer:["id","key","value","variance"],ObjectTypeProperty:["key","value","variance"],ObjectTypeSpreadProperty:["argument"],OpaqueType:["id","typeParameters","supertype","impltype"],QualifiedTypeIdentifier:["id","qualification"],StringLiteralTypeAnnotation:[],StringTypeAnnotation:[],SymbolTypeAnnotation:[],ThisTypeAnnotation:[],TupleTypeAnnotation:["types","elementTypes"],TypeofTypeAnnotation:["argument"],TypeAlias:["id","typeParameters","right"],TypeAnnotation:["typeAnnotation"],TypeCastExpression:["expression","typeAnnotation"],TypeParameter:["bound","default","variance"],TypeParameterDeclaration:["params"],TypeParameterInstantiation:["params"],UnionTypeAnnotation:["types"],Variance:[],VoidTypeAnnotation:[],EnumDeclaration:["id","body"],EnumBooleanBody:["members"],EnumNumberBody:["members"],EnumStringBody:["members"],EnumSymbolBody:["members"],EnumBooleanMember:["id","init"],EnumNumberMember:["id","init"],EnumStringMember:["id","init"],EnumDefaultedMember:["id"],IndexedAccessType:["objectType","indexType"],OptionalIndexedAccessType:["objectType","indexType"],JSXAttribute:["name","value"],JSXClosingElement:["name"],JSXElement:["openingElement","children","closingElement"],JSXEmptyExpression:[],JSXExpressionContainer:["expression"],JSXSpreadChild:["expression"],JSXIdentifier:[],JSXMemberExpression:["object","property"],JSXNamespacedName:["namespace","name"],JSXOpeningElement:["name","attributes","typeArguments","typeParameters"],JSXSpreadAttribute:["argument"],JSXText:[],JSXFragment:["openingFragment","children","closingFragment"],JSXOpeningFragment:[],JSXClosingFragment:[],Noop:[],Placeholder:[],V8IntrinsicIdentifier:[],ArgumentPlaceholder:[],BindExpression:["object","callee"],ImportAttribute:["key","value"],Decorator:["expression"],DoExpression:["body"],ExportDefaultSpecifier:["exported"],RecordExpression:["properties"],TupleExpression:["elements"],DecimalLiteral:[],ModuleExpression:["body"],TopicReference:[],PipelineTopicExpression:["expression"],PipelineBareFunction:["callee"],PipelinePrimaryTopicReference:[],TSParameterProperty:["parameter","decorators"],TSDeclareFunction:["id","typeParameters","params","returnType","body"],TSDeclareMethod:["decorators","key","typeParameters","params","returnType"],TSQualifiedName:["left","right"],TSCallSignatureDeclaration:["typeParameters","parameters","typeAnnotation","params","returnType"],TSConstructSignatureDeclaration:["typeParameters","parameters","typeAnnotation","params","returnType"],TSPropertySignature:["key","typeAnnotation"],TSMethodSignature:["key","typeParameters","parameters","typeAnnotation","params","returnType"],TSIndexSignature:["parameters","typeAnnotation"],TSAnyKeyword:[],TSBooleanKeyword:[],TSBigIntKeyword:[],TSIntrinsicKeyword:[],TSNeverKeyword:[],TSNullKeyword:[],TSNumberKeyword:[],TSObjectKeyword:[],TSStringKeyword:[],TSSymbolKeyword:[],TSUndefinedKeyword:[],TSUnknownKeyword:[],TSVoidKeyword:[],TSThisType:[],TSFunctionType:["typeParameters","parameters","typeAnnotation","params","returnType"],TSConstructorType:["typeParameters","parameters","typeAnnotation","params","returnType"],TSTypeReference:["typeName","typeParameters","typeArguments"],TSTypePredicate:["parameterName","typeAnnotation"],TSTypeQuery:["exprName","typeParameters","typeArguments"],TSTypeLiteral:["members"],TSArrayType:["elementType"],TSTupleType:["elementTypes"],TSOptionalType:["typeAnnotation"],TSRestType:["typeAnnotation"],TSNamedTupleMember:["label","elementType"],TSUnionType:["types"],TSIntersectionType:["types"],TSConditionalType:["checkType","extendsType","trueType","falseType"],TSInferType:["typeParameter"],TSParenthesizedType:["typeAnnotation"],TSTypeOperator:["typeAnnotation"],TSIndexedAccessType:["objectType","indexType"],TSMappedType:["typeParameter","typeAnnotation","nameType"],TSLiteralType:["literal"],TSExpressionWithTypeArguments:["expression","typeParameters"],TSInterfaceDeclaration:["id","typeParameters","extends","body"],TSInterfaceBody:["body"],TSTypeAliasDeclaration:["id","typeParameters","typeAnnotation"],TSInstantiationExpression:["expression","typeParameters","typeArguments"],TSAsExpression:["expression","typeAnnotation"],TSSatisfiesExpression:["expression","typeAnnotation"],TSTypeAssertion:["typeAnnotation","expression"],TSEnumDeclaration:["id","members"],TSEnumMember:["id","initializer"],TSModuleDeclaration:["id","body"],TSModuleBlock:["body"],TSImportType:["argument","qualifier","typeParameters","typeArguments"],TSImportEqualsDeclaration:["id","moduleReference"],TSExternalModuleReference:["expression"],TSNonNullExpression:["expression"],TSExportAssignment:["expression"],TSNamespaceExportDeclaration:["id"],TSTypeAnnotation:["typeAnnotation"],TSTypeParameterInstantiation:["params"],TSTypeParameterDeclaration:["params"],TSTypeParameter:["constraint","default","name"],ChainExpression:["expression"],ExperimentalRestProperty:["argument"],ExperimentalSpreadProperty:["argument"],ImportExpression:["source","attributes"],Literal:[],MethodDefinition:["decorators","key","value"],PrivateIdentifier:[],Property:["key","value"],PropertyDefinition:["decorators","key","typeAnnotation","value","variance"],AccessorProperty:["decorators","key","typeAnnotation","value"],TSAbstractAccessorProperty:["decorators","key","typeAnnotation"],TSAbstractKeyword:[],TSAbstractMethodDefinition:["key","value"],TSAbstractPropertyDefinition:["decorators","key","typeAnnotation"],TSAsyncKeyword:[],TSClassImplements:["expression","typeArguments","typeParameters"],TSDeclareKeyword:[],TSEmptyBodyFunctionExpression:["id","typeParameters","params","returnType"],TSExportKeyword:[],TSInterfaceHeritage:["expression","typeArguments","typeParameters"],TSPrivateKeyword:[],TSProtectedKeyword:[],TSPublicKeyword:[],TSReadonlyKeyword:[],TSStaticKeyword:[],TSTemplateLiteralType:["quasis","types"],BigIntLiteralTypeAnnotation:[],BigIntTypeAnnotation:[],ConditionalTypeAnnotation:["checkType","extendsType","trueType","falseType"],DeclareEnum:["id","body"],InferTypeAnnotation:["typeParameter"],KeyofTypeAnnotation:["argument"],ObjectTypeMappedTypeProperty:["keyTparam","propType","sourceType","variance"],QualifiedTypeofIdentifier:["qualification","id"],TupleTypeLabeledElement:["label","elementType","variance"],TupleTypeSpreadElement:["label","typeAnnotation"],TypePredicate:["parameterName","typeAnnotation","asserts"],NGRoot:["node"],NGPipeExpression:["left","right","arguments"],NGChainedExpression:["expressions"],NGEmptyExpression:[],NGMicrosyntax:["body"],NGMicrosyntaxKey:[],NGMicrosyntaxExpression:["expression","alias"],NGMicrosyntaxKeyedExpression:["key","expression"],NGMicrosyntaxLet:["key","value"],NGMicrosyntaxAs:["key","alias"],JsExpressionRoot:["node"],JsonRoot:["node"],TSJSDocAllType:[],TSJSDocUnknownType:[],TSJSDocNullableType:["typeAnnotation"],TSJSDocNonNullableType:["typeAnnotation"],NeverTypeAnnotation:[],UndefinedTypeAnnotation:[],UnknownTypeAnnotation:[]},Vse=Kse(Wse),Hse=Vse;function XT(t,r){if(!(t!==null&&typeof t=="object"))return t;if(Array.isArray(t)){for(let a=0;a<t.length;a++)t[a]=XT(t[a],r);return t}let n=Hse(t);for(let a=0;a<n.length;a++)t[n[a]]=XT(t[n[a]],r);return r(t)||t}var YT=XT;function Gse(t,r){let{parser:n,text:a}=r;if(t.type==="File"&&t.program.interpreter){let{program:{interpreter:u},comments:_}=t;delete t.program.interpreter,_.unshift(u)}if(n==="babel"){let u=new Set;t=YT(t,_=>{var f;(f=_.leadingComments)!=null&&f.some($se)&&u.add(ao(_))}),t=YT(t,_=>{if(_.type==="ParenthesizedExpression"){let{expression:f}=_;if(f.type==="TypeCastExpression")return f.range=_.range,f;let v=ao(_);if(!u.has(v))return f.extra={...f.extra,parenthesized:!0},f}})}if(t=YT(t,u=>{switch(u.type){case"LogicalExpression":if(RP(u))return QT(u);break;case"VariableDeclaration":{let _=MP(!1,u.declarations,-1);_!=null&&_.init&&s(u,_);break}case"TSParenthesizedType":return u.typeAnnotation;case"TSTypeParameter":if(typeof u.name=="string"){let _=ao(u);u.name={type:"Identifier",name:u.name,range:[_,_+u.name.length]}}break;case"TopicReference":t.extra={...t.extra,__isUsingHackPipeline:!0};break;case"ExportAllDeclaration":{let{exported:_}=u;if(n==="meriyah"&&(_==null?void 0:_.type)==="Identifier"){let f=a.slice(ao(_),tc(_));(f.startsWith('"')||f.startsWith("'"))&&(u.exported={...u.exported,type:"Literal",value:u.exported.name,raw:f})}break}case"TSUnionType":case"TSIntersectionType":if(u.types.length===1)return u.types[0];break}}),LP(t.comments)){let u=MP(!1,t.comments,-1);for(let _=t.comments.length-2;_>=0;_--){let f=t.comments[_];tc(f)===ao(u)&&GT(f)&&GT(u)&&jP(f)&&jP(u)&&(t.comments.splice(_+1,1),f.value+="*//*"+u.value,f.range=[ao(f),tc(u)]),u=f}}return t.type==="Program"&&(t.range=[0,a.length]),t;function s(u,_){a[tc(_)]!==";"&&(u.range=[ao(u),tc(_)])}}function RP(t){return t.type==="LogicalExpression"&&t.right.type==="LogicalExpression"&&t.operator===t.right.operator}function QT(t){return RP(t)?QT({type:"LogicalExpression",operator:t.operator,left:QT({type:"LogicalExpression",operator:t.operator,left:t.left,right:t.right.left,range:[ao(t.left),tc(t.right.left)]}),right:t.right.right,range:[ao(t),tc(t)]}):t}var Xse=Gse,ZT={loc:!0,range:!0,comment:!0,tokens:!0,loggerFn:!1,project:[],suppressDeprecatedPropertyWarnings:!0};function Yse(t){let{message:r,location:n}=t;if(!n)return t;let{start:a,end:s}=n;return Tse(r,{loc:{start:{line:a.line,column:a.column+1},end:{line:s.line,column:s.column+1}},cause:t})}var Qse=t=>/\.(?:js|mjs|cjs|jsx|ts|mts|cts|tsx)$/i.test(t);function Zse(t,r){let n=r==null?void 0:r.filepath;if(n&&Qse(n))return[{...ZT,filePath:n}];let a=toe(t);return[{...ZT,jsx:a},{...ZT,jsx:!a}]}function eoe(t,r){let n=Bse(t),a=Zse(t,r),s;try{s=Cse(a.map(u=>()=>(0,xse.parse)(n,u)))}catch({errors:[u]}){throw Yse(u)}return Xse(s,{text:t})}function toe(t){return new RegExp(["(?:^[^\"'`]*</)","|","(?:^[^/]{2}.*/>)"].join(""),"m").test(t)}var roe=Nse(eoe),noe=BP,ioe=Object.freeze({__proto__:null,default:noe,parsers:HT});const aoe={js:"babel",jsx:"babel",mjs:"babel",cjs:"babel",ts:"typescript",tsx:"typescript",css:"css",html:"html",json:"json",json5:"json5",md:"markdown",markdown:"markdown"},soe=[dU,WH,NQ,cre,ioe,zae];onmessage=async({data:t})=>{const{fileExtension:r,fileText:n,fileId:a}=t,s=aoe[r];if(!s){postMessage({fileId:a,error:`Unsupported file extension for Prettier: ${r}`});return}try{const u=await dv(n,{parser:s,plugins:soe});postMessage({fileId:a,fileTextPrettified:u})}catch(u){postMessage({fileId:a,error:u})}}})();
237
+ `);return r.length>1&&r.every(n=>n.trimStart()[0]==="*")}var jP=Jse,Th=null;function Sh(t){if(Th!==null&&typeof Th.property){let r=Th;return Th=Sh.prototype=null,r}return Th=Sh.prototype=t??Object.create(null),new Sh}var qse=10;for(let t=0;t<=qse;t++)Sh();function Use(t){return Sh(t)}function zse(t,r="type"){Use(t);function n(a){let s=a[r],u=t[s];if(!Array.isArray(u))throw Object.assign(new Error(`Missing visitor keys for '${s}'.`),{node:a});return u}return n}var Kse=zse,Wse={ArrayExpression:["elements"],AssignmentExpression:["left","right"],BinaryExpression:["left","right"],InterpreterDirective:[],Directive:["value"],DirectiveLiteral:[],BlockStatement:["directives","body"],BreakStatement:["label"],CallExpression:["callee","arguments","typeParameters","typeArguments"],CatchClause:["param","body"],ConditionalExpression:["test","consequent","alternate"],ContinueStatement:["label"],DebuggerStatement:[],DoWhileStatement:["test","body"],EmptyStatement:[],ExpressionStatement:["expression"],File:["program"],ForInStatement:["left","right","body"],ForStatement:["init","test","update","body"],FunctionDeclaration:["id","params","body","returnType","typeParameters","predicate"],FunctionExpression:["id","params","body","returnType","typeParameters"],Identifier:["typeAnnotation","decorators"],IfStatement:["test","consequent","alternate"],LabeledStatement:["label","body"],StringLiteral:[],NumericLiteral:[],NullLiteral:[],BooleanLiteral:[],RegExpLiteral:[],LogicalExpression:["left","right"],MemberExpression:["object","property"],NewExpression:["callee","arguments","typeParameters","typeArguments"],Program:["directives","body"],ObjectExpression:["properties"],ObjectMethod:["key","params","body","decorators","returnType","typeParameters"],ObjectProperty:["key","value","decorators"],RestElement:["argument","typeAnnotation","decorators"],ReturnStatement:["argument"],SequenceExpression:["expressions"],ParenthesizedExpression:["expression"],SwitchCase:["test","consequent"],SwitchStatement:["discriminant","cases"],ThisExpression:[],ThrowStatement:["argument"],TryStatement:["block","handler","finalizer"],UnaryExpression:["argument"],UpdateExpression:["argument"],VariableDeclaration:["declarations"],VariableDeclarator:["id","init"],WhileStatement:["test","body"],WithStatement:["object","body"],AssignmentPattern:["left","right","decorators","typeAnnotation"],ArrayPattern:["elements","typeAnnotation","decorators"],ArrowFunctionExpression:["params","body","returnType","typeParameters","predicate"],ClassBody:["body"],ClassExpression:["id","body","superClass","mixins","typeParameters","superTypeParameters","implements","decorators","superTypeArguments"],ClassDeclaration:["id","body","superClass","mixins","typeParameters","superTypeParameters","implements","decorators","superTypeArguments"],ExportAllDeclaration:["source","attributes","assertions","exported"],ExportDefaultDeclaration:["declaration"],ExportNamedDeclaration:["declaration","specifiers","source","attributes","assertions"],ExportSpecifier:["local","exported"],ForOfStatement:["left","right","body"],ImportDeclaration:["specifiers","source","attributes","assertions"],ImportDefaultSpecifier:["local"],ImportNamespaceSpecifier:["local"],ImportSpecifier:["local","imported"],MetaProperty:["meta","property"],ClassMethod:["key","params","body","decorators","returnType","typeParameters"],ObjectPattern:["properties","typeAnnotation","decorators"],SpreadElement:["argument"],Super:[],TaggedTemplateExpression:["tag","quasi","typeParameters","typeArguments"],TemplateElement:[],TemplateLiteral:["quasis","expressions"],YieldExpression:["argument"],AwaitExpression:["argument"],Import:[],BigIntLiteral:[],ExportNamespaceSpecifier:["exported"],OptionalMemberExpression:["object","property"],OptionalCallExpression:["callee","arguments","typeParameters","typeArguments"],ClassProperty:["key","value","typeAnnotation","decorators","variance"],ClassAccessorProperty:["key","value","typeAnnotation","decorators"],ClassPrivateProperty:["key","value","decorators","typeAnnotation","variance"],ClassPrivateMethod:["key","params","body","decorators","returnType","typeParameters"],PrivateName:["id"],StaticBlock:["body"],AnyTypeAnnotation:[],ArrayTypeAnnotation:["elementType"],BooleanTypeAnnotation:[],BooleanLiteralTypeAnnotation:[],NullLiteralTypeAnnotation:[],ClassImplements:["id","typeParameters"],DeclareClass:["id","typeParameters","extends","mixins","implements","body"],DeclareFunction:["id","predicate"],DeclareInterface:["id","typeParameters","extends","body"],DeclareModule:["id","body"],DeclareModuleExports:["typeAnnotation"],DeclareTypeAlias:["id","typeParameters","right"],DeclareOpaqueType:["id","typeParameters","supertype"],DeclareVariable:["id"],DeclareExportDeclaration:["declaration","specifiers","source"],DeclareExportAllDeclaration:["source"],DeclaredPredicate:["value"],ExistsTypeAnnotation:[],FunctionTypeAnnotation:["typeParameters","params","rest","returnType","this"],FunctionTypeParam:["name","typeAnnotation"],GenericTypeAnnotation:["id","typeParameters"],InferredPredicate:[],InterfaceExtends:["id","typeParameters"],InterfaceDeclaration:["id","typeParameters","extends","body"],InterfaceTypeAnnotation:["extends","body"],IntersectionTypeAnnotation:["types"],MixedTypeAnnotation:[],EmptyTypeAnnotation:[],NullableTypeAnnotation:["typeAnnotation"],NumberLiteralTypeAnnotation:[],NumberTypeAnnotation:[],ObjectTypeAnnotation:["properties","indexers","callProperties","internalSlots"],ObjectTypeInternalSlot:["id","value","optional","static","method"],ObjectTypeCallProperty:["value"],ObjectTypeIndexer:["id","key","value","variance"],ObjectTypeProperty:["key","value","variance"],ObjectTypeSpreadProperty:["argument"],OpaqueType:["id","typeParameters","supertype","impltype"],QualifiedTypeIdentifier:["id","qualification"],StringLiteralTypeAnnotation:[],StringTypeAnnotation:[],SymbolTypeAnnotation:[],ThisTypeAnnotation:[],TupleTypeAnnotation:["types","elementTypes"],TypeofTypeAnnotation:["argument"],TypeAlias:["id","typeParameters","right"],TypeAnnotation:["typeAnnotation"],TypeCastExpression:["expression","typeAnnotation"],TypeParameter:["bound","default","variance"],TypeParameterDeclaration:["params"],TypeParameterInstantiation:["params"],UnionTypeAnnotation:["types"],Variance:[],VoidTypeAnnotation:[],EnumDeclaration:["id","body"],EnumBooleanBody:["members"],EnumNumberBody:["members"],EnumStringBody:["members"],EnumSymbolBody:["members"],EnumBooleanMember:["id","init"],EnumNumberMember:["id","init"],EnumStringMember:["id","init"],EnumDefaultedMember:["id"],IndexedAccessType:["objectType","indexType"],OptionalIndexedAccessType:["objectType","indexType"],JSXAttribute:["name","value"],JSXClosingElement:["name"],JSXElement:["openingElement","children","closingElement"],JSXEmptyExpression:[],JSXExpressionContainer:["expression"],JSXSpreadChild:["expression"],JSXIdentifier:[],JSXMemberExpression:["object","property"],JSXNamespacedName:["namespace","name"],JSXOpeningElement:["name","attributes","typeArguments","typeParameters"],JSXSpreadAttribute:["argument"],JSXText:[],JSXFragment:["openingFragment","children","closingFragment"],JSXOpeningFragment:[],JSXClosingFragment:[],Noop:[],Placeholder:[],V8IntrinsicIdentifier:[],ArgumentPlaceholder:[],BindExpression:["object","callee"],ImportAttribute:["key","value"],Decorator:["expression"],DoExpression:["body"],ExportDefaultSpecifier:["exported"],RecordExpression:["properties"],TupleExpression:["elements"],DecimalLiteral:[],ModuleExpression:["body"],TopicReference:[],PipelineTopicExpression:["expression"],PipelineBareFunction:["callee"],PipelinePrimaryTopicReference:[],TSParameterProperty:["parameter","decorators"],TSDeclareFunction:["id","typeParameters","params","returnType","body"],TSDeclareMethod:["decorators","key","typeParameters","params","returnType"],TSQualifiedName:["left","right"],TSCallSignatureDeclaration:["typeParameters","parameters","typeAnnotation","params","returnType"],TSConstructSignatureDeclaration:["typeParameters","parameters","typeAnnotation","params","returnType"],TSPropertySignature:["key","typeAnnotation"],TSMethodSignature:["key","typeParameters","parameters","typeAnnotation","params","returnType"],TSIndexSignature:["parameters","typeAnnotation"],TSAnyKeyword:[],TSBooleanKeyword:[],TSBigIntKeyword:[],TSIntrinsicKeyword:[],TSNeverKeyword:[],TSNullKeyword:[],TSNumberKeyword:[],TSObjectKeyword:[],TSStringKeyword:[],TSSymbolKeyword:[],TSUndefinedKeyword:[],TSUnknownKeyword:[],TSVoidKeyword:[],TSThisType:[],TSFunctionType:["typeParameters","parameters","typeAnnotation","params","returnType"],TSConstructorType:["typeParameters","parameters","typeAnnotation","params","returnType"],TSTypeReference:["typeName","typeParameters","typeArguments"],TSTypePredicate:["parameterName","typeAnnotation"],TSTypeQuery:["exprName","typeParameters","typeArguments"],TSTypeLiteral:["members"],TSArrayType:["elementType"],TSTupleType:["elementTypes"],TSOptionalType:["typeAnnotation"],TSRestType:["typeAnnotation"],TSNamedTupleMember:["label","elementType"],TSUnionType:["types"],TSIntersectionType:["types"],TSConditionalType:["checkType","extendsType","trueType","falseType"],TSInferType:["typeParameter"],TSParenthesizedType:["typeAnnotation"],TSTypeOperator:["typeAnnotation"],TSIndexedAccessType:["objectType","indexType"],TSMappedType:["typeParameter","typeAnnotation","nameType"],TSLiteralType:["literal"],TSExpressionWithTypeArguments:["expression","typeParameters"],TSInterfaceDeclaration:["id","typeParameters","extends","body"],TSInterfaceBody:["body"],TSTypeAliasDeclaration:["id","typeParameters","typeAnnotation"],TSInstantiationExpression:["expression","typeParameters","typeArguments"],TSAsExpression:["expression","typeAnnotation"],TSSatisfiesExpression:["expression","typeAnnotation"],TSTypeAssertion:["typeAnnotation","expression"],TSEnumDeclaration:["id","members"],TSEnumMember:["id","initializer"],TSModuleDeclaration:["id","body"],TSModuleBlock:["body"],TSImportType:["argument","qualifier","typeParameters","typeArguments"],TSImportEqualsDeclaration:["id","moduleReference"],TSExternalModuleReference:["expression"],TSNonNullExpression:["expression"],TSExportAssignment:["expression"],TSNamespaceExportDeclaration:["id"],TSTypeAnnotation:["typeAnnotation"],TSTypeParameterInstantiation:["params"],TSTypeParameterDeclaration:["params"],TSTypeParameter:["constraint","default","name"],ChainExpression:["expression"],ExperimentalRestProperty:["argument"],ExperimentalSpreadProperty:["argument"],ImportExpression:["source","attributes"],Literal:[],MethodDefinition:["decorators","key","value"],PrivateIdentifier:[],Property:["key","value"],PropertyDefinition:["decorators","key","typeAnnotation","value","variance"],AccessorProperty:["decorators","key","typeAnnotation","value"],TSAbstractAccessorProperty:["decorators","key","typeAnnotation"],TSAbstractKeyword:[],TSAbstractMethodDefinition:["key","value"],TSAbstractPropertyDefinition:["decorators","key","typeAnnotation"],TSAsyncKeyword:[],TSClassImplements:["expression","typeArguments","typeParameters"],TSDeclareKeyword:[],TSEmptyBodyFunctionExpression:["id","typeParameters","params","returnType"],TSExportKeyword:[],TSInterfaceHeritage:["expression","typeArguments","typeParameters"],TSPrivateKeyword:[],TSProtectedKeyword:[],TSPublicKeyword:[],TSReadonlyKeyword:[],TSStaticKeyword:[],TSTemplateLiteralType:["quasis","types"],BigIntLiteralTypeAnnotation:[],BigIntTypeAnnotation:[],ConditionalTypeAnnotation:["checkType","extendsType","trueType","falseType"],DeclareEnum:["id","body"],InferTypeAnnotation:["typeParameter"],KeyofTypeAnnotation:["argument"],ObjectTypeMappedTypeProperty:["keyTparam","propType","sourceType","variance"],QualifiedTypeofIdentifier:["qualification","id"],TupleTypeLabeledElement:["label","elementType","variance"],TupleTypeSpreadElement:["label","typeAnnotation"],TypePredicate:["parameterName","typeAnnotation","asserts"],NGRoot:["node"],NGPipeExpression:["left","right","arguments"],NGChainedExpression:["expressions"],NGEmptyExpression:[],NGMicrosyntax:["body"],NGMicrosyntaxKey:[],NGMicrosyntaxExpression:["expression","alias"],NGMicrosyntaxKeyedExpression:["key","expression"],NGMicrosyntaxLet:["key","value"],NGMicrosyntaxAs:["key","alias"],JsExpressionRoot:["node"],JsonRoot:["node"],TSJSDocAllType:[],TSJSDocUnknownType:[],TSJSDocNullableType:["typeAnnotation"],TSJSDocNonNullableType:["typeAnnotation"],NeverTypeAnnotation:[],UndefinedTypeAnnotation:[],UnknownTypeAnnotation:[]},Vse=Kse(Wse),Hse=Vse;function XT(t,r){if(!(t!==null&&typeof t=="object"))return t;if(Array.isArray(t)){for(let a=0;a<t.length;a++)t[a]=XT(t[a],r);return t}let n=Hse(t);for(let a=0;a<n.length;a++)t[n[a]]=XT(t[n[a]],r);return r(t)||t}var YT=XT;function Gse(t,r){let{parser:n,text:a}=r;if(t.type==="File"&&t.program.interpreter){let{program:{interpreter:u},comments:_}=t;delete t.program.interpreter,_.unshift(u)}if(n==="babel"){let u=new Set;t=YT(t,_=>{var f;(f=_.leadingComments)!=null&&f.some($se)&&u.add(ao(_))}),t=YT(t,_=>{if(_.type==="ParenthesizedExpression"){let{expression:f}=_;if(f.type==="TypeCastExpression")return f.range=_.range,f;let v=ao(_);if(!u.has(v))return f.extra={...f.extra,parenthesized:!0},f}})}if(t=YT(t,u=>{switch(u.type){case"LogicalExpression":if(RP(u))return QT(u);break;case"VariableDeclaration":{let _=MP(!1,u.declarations,-1);_!=null&&_.init&&s(u,_);break}case"TSParenthesizedType":return u.typeAnnotation;case"TSTypeParameter":if(typeof u.name=="string"){let _=ao(u);u.name={type:"Identifier",name:u.name,range:[_,_+u.name.length]}}break;case"TopicReference":t.extra={...t.extra,__isUsingHackPipeline:!0};break;case"ExportAllDeclaration":{let{exported:_}=u;if(n==="meriyah"&&(_==null?void 0:_.type)==="Identifier"){let f=a.slice(ao(_),tc(_));(f.startsWith('"')||f.startsWith("'"))&&(u.exported={...u.exported,type:"Literal",value:u.exported.name,raw:f})}break}case"TSUnionType":case"TSIntersectionType":if(u.types.length===1)return u.types[0];break}}),LP(t.comments)){let u=MP(!1,t.comments,-1);for(let _=t.comments.length-2;_>=0;_--){let f=t.comments[_];tc(f)===ao(u)&&GT(f)&&GT(u)&&jP(f)&&jP(u)&&(t.comments.splice(_+1,1),f.value+="*//*"+u.value,f.range=[ao(f),tc(u)]),u=f}}return t.type==="Program"&&(t.range=[0,a.length]),t;function s(u,_){a[tc(_)]!==";"&&(u.range=[ao(u),tc(_)])}}function RP(t){return t.type==="LogicalExpression"&&t.right.type==="LogicalExpression"&&t.operator===t.right.operator}function QT(t){return RP(t)?QT({type:"LogicalExpression",operator:t.operator,left:QT({type:"LogicalExpression",operator:t.operator,left:t.left,right:t.right.left,range:[ao(t.left),tc(t.right.left)]}),right:t.right.right,range:[ao(t),tc(t)]}):t}var Xse=Gse,ZT={loc:!0,range:!0,comment:!0,tokens:!0,loggerFn:!1,project:[],suppressDeprecatedPropertyWarnings:!0};function Yse(t){let{message:r,location:n}=t;if(!n)return t;let{start:a,end:s}=n;return Tse(r,{loc:{start:{line:a.line,column:a.column+1},end:{line:s.line,column:s.column+1}},cause:t})}var Qse=t=>/\.(?:js|mjs|cjs|jsx|ts|mts|cts|tsx)$/i.test(t);function Zse(t,r){let n=r==null?void 0:r.filepath;if(n&&Qse(n))return[{...ZT,filePath:n}];let a=toe(t);return[{...ZT,jsx:a},{...ZT,jsx:!a}]}function eoe(t,r){let n=Bse(t),a=Zse(t,r),s;try{s=Cse(a.map(u=>()=>(0,xse.parse)(n,u)))}catch({errors:[u]}){throw Yse(u)}return Xse(s,{text:t})}function toe(t){return new RegExp(["(?:^[^\"'`]*</)","|","(?:^[^/]{2}.*/>)"].join(""),"m").test(t)}var roe=Nse(eoe),noe=BP,ioe=Object.freeze({__proto__:null,default:noe,parsers:HT});const aoe={js:"babel",jsx:"babel",mjs:"babel",cjs:"babel",ts:"typescript",tsx:"typescript",css:"css",html:"html",json:"json",json5:"json5",md:"markdown",markdown:"markdown"},soe=[dU,WH,NQ,cre,ioe,zae];onmessage=async({data:t})=>{const{fileExtension:r,fileText:n,fileId:a}=t,s=aoe[r];if(!s){postMessage({fileId:a,error:`Unsupported file extension for Prettier: ${r}`});return}try{const u=await dv(n,{parser:s,plugins:soe});postMessage({fileId:a,fileTextPrettified:u})}catch(u){postMessage({fileId:a,error:u.toString()})}}})();
package/dist/index.html CHANGED
@@ -28,8 +28,8 @@
28
28
  href="https://unpkg.com/bootstrap@5.3.0/dist/css/bootstrap.min.css"
29
29
  rel="stylesheet"
30
30
  />
31
- <script type="module" crossorigin src="/assets/index-37015623.js"></script>
32
- <link rel="stylesheet" href="/assets/index-1547f7b8.css">
31
+ <script type="module" crossorigin src="/assets/index-9c8bbae0.js"></script>
32
+ <link rel="stylesheet" href="/assets/index-cf19de3b.css">
33
33
  </head>
34
34
  <body>
35
35
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vzcode",
3
- "version": "0.21.0",
3
+ "version": "0.24.0",
4
4
  "description": "Multiplayer code editor system",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -49,12 +49,20 @@
49
49
  "@codemirror/lang-css": "^6.2.1",
50
50
  "@codemirror/lang-html": "^6.4.6",
51
51
  "@codemirror/lang-javascript": "^6.2.1",
52
- "@codemirror/lang-markdown": "^6.2.1",
53
- "@codemirror/state": "^6.2.1",
52
+ "@codemirror/lang-markdown": "^6.2.2",
53
+ "@codemirror/state": "^6.3.1",
54
54
  "@codemirror/theme-one-dark": "^6.1.2",
55
+ "@codemirror/view": "^6.21.3",
55
56
  "@replit/codemirror-interact": "^6.3.0",
56
57
  "@teamwork/websocket-json-stream": "^2.0.0",
57
- "@uiw/codemirror-themes-all": "^4.21.18",
58
+ "@uiw/codemirror-theme-abcdef": "^4.21.20",
59
+ "@uiw/codemirror-theme-dracula": "^4.21.20",
60
+ "@uiw/codemirror-theme-eclipse": "^4.21.20",
61
+ "@uiw/codemirror-theme-github": "^4.21.20",
62
+ "@uiw/codemirror-theme-material": "^4.21.20",
63
+ "@uiw/codemirror-theme-nord": "^4.21.20",
64
+ "@uiw/codemirror-theme-okaidia": "^4.21.20",
65
+ "@uiw/codemirror-theme-xcode": "^4.21.20",
58
66
  "codemirror": "^6.0.1",
59
67
  "codemirror-ot": "^4.1.0",
60
68
  "d3-array": "^3.2.4",
@@ -64,23 +72,22 @@
64
72
  "json0-ot-diff": "^1.1.2",
65
73
  "ngrok": "^4.3.3",
66
74
  "open": "^9.1.0",
75
+ "ot-json1": "^1.0.2",
67
76
  "react": "^18.2.0",
68
77
  "react-bootstrap": "^2.9.0",
69
78
  "react-dom": "^18.2.0",
70
- "react-select": "^5.7.5",
71
- "sharedb": "^4.0.1",
79
+ "sharedb": "^4.1.1",
72
80
  "sharedb-client-browser": "^4.3.1",
73
- "ot-json1": "^1.0.2",
74
81
  "ws": "^8.14.2"
75
82
  },
76
83
  "devDependencies": {
77
- "@types/react": "^18.2.23",
78
- "@types/react-dom": "^18.2.8",
84
+ "@types/react": "^18.2.29",
85
+ "@types/react-dom": "^18.2.14",
79
86
  "@vitejs/plugin-react": "^4.1.0",
80
87
  "prettier": "^3.0.3",
81
- "sass": "^1.68.0",
88
+ "sass": "^1.69.4",
82
89
  "typescript": "^5.2.2",
83
- "vite": "^4.4.9",
84
- "vitest": "^0.34.5"
90
+ "vite": "^4.5.0",
91
+ "vitest": "^0.34.6"
85
92
  }
86
93
  }
@@ -3,6 +3,7 @@ import {
3
3
  useEffect,
4
4
  useCallback,
5
5
  useRef,
6
+ useReducer,
6
7
  } from 'react';
7
8
  import ShareDBClient from 'sharedb-client-browser/dist/sharedb-client-umd.cjs';
8
9
  import { json1Presence } from '../ot';
@@ -29,7 +30,9 @@ import PrettierWorker from './usePrettier/worker?worker';
29
30
  import { SplitPaneResizeProvider } from './SplitPaneResizeContext';
30
31
  import { Resizer } from './Resizer';
31
32
  import { PresenceNotifications } from './PresenceNotifications';
33
+ import { reducer } from './reducer';
32
34
  import './style.scss';
35
+ import { PrettierErrorOverlay } from './PrettierErrorOverlay';
33
36
 
34
37
  // Instantiate the Prettier worker.
35
38
  const prettierWorker = new PrettierWorker();
@@ -71,7 +74,13 @@ function App() {
71
74
  );
72
75
 
73
76
  // Auto-run Pretter after local changes.
74
- usePrettier(shareDBDoc, submitOperation, prettierWorker);
77
+ const { prettierError } = usePrettier(
78
+ shareDBDoc,
79
+ submitOperation,
80
+ prettierWorker,
81
+ );
82
+
83
+ console.log('prettierError', prettierError);
75
84
 
76
85
  // Local ShareDB presence, for broadcasting our cursor position
77
86
  // so other clients can see it.
@@ -146,20 +155,69 @@ function App() {
146
155
 
147
156
  // The id of the currently open file tab.
148
157
  // TODO make this a URL param
149
- const [activeFileId, setActiveFileId] =
150
- useState<FileId | null>(null);
158
+ // Migrated to useReducer
159
+ //const [activeFileId, setActiveFileId] =
160
+ //useState<FileId | null>(null);
151
161
 
152
162
  // The ordered list of tabs.
153
163
  // TODO make this a URL param
154
- const [tabList, setTabList] = useState<Array<FileId>>([]);
164
+ // https://react.dev/reference/react/useReducer
165
+ // const [tabList, setTabList] = useState<Array<FileId>>([]);
166
+ const [state, dispatch] = useReducer(reducer, {
167
+ submitOperation,
168
+ tabList: [],
169
+ // activeFileId: null,
170
+ // theme: defaultTheme,
171
+ // isSettingsOpen:false
172
+ });
173
+
174
+ //Reducer states
175
+ const tabList = state.tabList;
176
+ const activeFileId = state.activeFileId;
177
+ // TODO phase this out as we complete the refactoring
178
+ // It's here now for backwards compatibility
179
+ const setTabList = (tabList) => {
180
+ dispatch({
181
+ type: 'set_tab_list',
182
+ tabList,
183
+ });
184
+ };
185
+
186
+ const setActiveFileId = (activeFileId) => {
187
+ dispatch({
188
+ type: 'set_active_fileId',
189
+ activeFileId,
190
+ });
191
+ };
192
+ const openTab = (fileId: FileId) => {
193
+ dispatch({
194
+ type: 'open_tab',
195
+ fileId,
196
+ });
197
+ };
155
198
 
156
- // Logic for opening and closing tabs.
157
- const { closeTab, openTab } = useTabsState(
199
+ const closeTab = (fileIdToRemove: FileId) => {
200
+ dispatch({
201
+ type: 'close_tab',
202
+ fileIdToRemove,
203
+ });
204
+ };
205
+
206
+ const multiCloseTab = (idsToDelete: Array<FileId>) => {
207
+ dispatch({
208
+ type: 'multi_close_tab',
209
+ idsToDelete,
210
+ });
211
+ };
212
+
213
+ // Logic for opening and closing tabs. Migrated to useReducer
214
+ /*
215
+ const {} = useTabsState(
158
216
  activeFileId,
159
217
  setActiveFileId,
160
218
  tabList,
161
219
  setTabList,
162
- );
220
+ ); */
163
221
 
164
222
  // The current theme.
165
223
  // TODO persist this in local storage
@@ -218,21 +276,48 @@ function App() {
218
276
 
219
277
  const deleteFile = useCallback(
220
278
  (fileId: FileId) => {
221
- closeTab(fileId);
222
279
  submitOperation((document) => {
223
280
  const updatedFiles = { ...document.files };
224
281
  delete updatedFiles[fileId];
225
282
  return { ...document, files: updatedFiles };
226
283
  });
284
+ closeTab(fileId);
227
285
  },
228
286
  [submitOperation, closeTab],
229
287
  );
230
288
 
231
- const handleDeleteFileClick = useCallback(
232
- (fileId: FileId) => {
233
- deleteFile(fileId);
289
+ const deleteDirectory = useCallback(
290
+ (path: FileId) => {
291
+ let tabsToDelete: Array<FileId> = [];
292
+ submitOperation((document) => {
293
+ const updatedFiles = { ...document.files };
294
+ for (const key in updatedFiles) {
295
+ if (updatedFiles[key].name.includes(path)) {
296
+ tabsToDelete.push(key);
297
+ delete updatedFiles[key];
298
+ }
299
+ }
300
+ return { ...document, files: updatedFiles };
301
+ });
302
+ multiCloseTab(tabsToDelete);
234
303
  },
235
- [deleteFile],
304
+ [submitOperation, multiCloseTab],
305
+ );
306
+
307
+ const handleDeleteClick = useCallback(
308
+ (key: string) => {
309
+ //Regex to identify if the key is a file path or a file id.
310
+ if (/^[0-9]*$/.test(key)) {
311
+ if (key.length == 8) {
312
+ deleteFile(key);
313
+ } else {
314
+ deleteDirectory(key);
315
+ }
316
+ } else {
317
+ deleteDirectory(key);
318
+ }
319
+ },
320
+ [deleteFile, deleteDirectory],
236
321
  );
237
322
 
238
323
  const handleSettingsClose = useCallback(() => {
@@ -276,7 +361,7 @@ function App() {
276
361
  createFile={createFile}
277
362
  files={files}
278
363
  handleRenameFileClick={handleRenameFileClick}
279
- handleDeleteFileClick={handleDeleteFileClick}
364
+ handleDeleteFileClick={handleDeleteClick}
280
365
  handleFileClick={openTab}
281
366
  setIsSettingsOpen={setIsSettingsOpen}
282
367
  isDirectoryOpen={isDirectoryOpen}
@@ -308,6 +393,9 @@ function App() {
308
393
  editorCache={editorCache}
309
394
  />
310
395
  ) : null}
396
+ <PrettierErrorOverlay
397
+ prettierError={prettierError}
398
+ />
311
399
  <PresenceNotifications
312
400
  docPresence={docPresence}
313
401
  />
@@ -16,7 +16,11 @@ import {
16
16
  } from '../../types';
17
17
  import { json1PresenceBroadcast } from './json1PresenceBroadcast';
18
18
  import { json1PresenceDisplay } from './json1PresenceDisplay';
19
- import { widgets } from './widgets';
19
+ import {
20
+ colorsInTextPlugin,
21
+ highlightWidgets,
22
+ widgets,
23
+ } from './widgets';
20
24
  import {
21
25
  EditorCache,
22
26
  EditorCacheValue,
@@ -127,6 +131,8 @@ export const getOrCreateEditor = ({
127
131
  json1PresenceDisplay({ path: textPath, docPresence }),
128
132
  );
129
133
 
134
+ extensions.push(colorsInTextPlugin);
135
+
130
136
  // This is the "basic setup" for CodeMirror,
131
137
  // which actually adds a ton on functionality.
132
138
  // TODO vet this functionality, and determine how much
@@ -184,6 +190,8 @@ export const getOrCreateEditor = ({
184
190
  // See https://github.com/replit/codemirror-interact/issues/14
185
191
  extensions.push(widgets({ onInteract }));
186
192
 
193
+ extensions.push(highlightWidgets);
194
+
187
195
  const editor = new EditorView({
188
196
  state: EditorState.create({
189
197
  doc: text,
@@ -1,5 +1,9 @@
1
- import { useRef, useLayoutEffect } from 'react';
2
- import { FileId } from '../../types';
1
+ import { useRef, useLayoutEffect, useContext } from 'react';
2
+ import {
3
+ FileId,
4
+ ShareDBDoc,
5
+ VZCodeContent,
6
+ } from '../../types';
3
7
  import { ThemeLabel, defaultTheme } from '../themes';
4
8
  import {
5
9
  EditorCache,
@@ -7,6 +11,7 @@ import {
7
11
  } from '../useEditorCache';
8
12
  import { getOrCreateEditor } from './getOrCreateEditor';
9
13
  import './style.scss';
14
+ // import { usePrettier } from '../usePrettier';
10
15
 
11
16
  export const CodeEditor = ({
12
17
  activeFileId,
@@ -19,7 +24,7 @@ export const CodeEditor = ({
19
24
  editorCache,
20
25
  }: {
21
26
  activeFileId: FileId;
22
- shareDBDoc: any;
27
+ shareDBDoc: ShareDBDoc<VZCodeContent> | null;
23
28
  localPresence?: any;
24
29
  docPresence?: any;
25
30
  theme?: ThemeLabel;
@@ -31,7 +36,6 @@ export const CodeEditor = ({
31
36
  editorCache: EditorCache;
32
37
  }) => {
33
38
  const ref = useRef<HTMLDivElement>(null);
34
-
35
39
  // Every time the active file switches from one file to another,
36
40
  // the editor corresponding to the old file is removed from the DOM,
37
41
  // and the editor corresponding to the new file is added to the DOM.
@@ -65,5 +69,5 @@ export const CodeEditor = ({
65
69
  };
66
70
  }, [shareDBDoc, activeFileId]);
67
71
 
68
- return <div className="vz-code-editor" ref={ref} />;
72
+ return <div className="vz-code-editor" ref={ref}></div>;
69
73
  };